ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellGroup2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11CaloCellGroup2Ntuple::CaloCellGroup2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
12 LArCond2NtupleBase(name, pSvcLocator) {
14
15 m_ntTitle="CaloCellGroup";
16 m_ntpath="/NTUPLES/FILE1/CaloCellGroup";
17
18
19}
20
22= default;
23
25 StatusCode sc;
26
27 NTuple::Array<float> values;
28 NTuple::Item<long> nValues;
29
30 sc=m_nt->addItem("nvalues",nValues,0,1000);
31 if (sc!=StatusCode::SUCCESS)
32 {ATH_MSG_ERROR( "addItem 'nvalues' failed" );
33 return StatusCode::FAILURE;
34 }
35
36 sc=m_nt->addItem("values",nValues,values);
37 if (sc!=StatusCode::SUCCESS)
38 {ATH_MSG_ERROR( "addItem 'values' failed" );
39 return StatusCode::FAILURE;
40 }
41
42
43
44
45 const CaloCell_ID* caloCellId;
46 sc = m_detStore->retrieve(caloCellId,"CaloCell_ID");
47 if (sc.isFailure()) {
48 ATH_MSG_ERROR( "Could not get CaloCellID helper !" );
49 return StatusCode::FAILURE;
50 }
51
52 bool stat=m_cellGroupList.setDefinition(dynamic_cast<const CaloCell_Base_ID*>(caloCellId),m_groupInit,msg());
53 if (!stat) {
54 ATH_MSG_ERROR( "CaloCellGroupList::setDefinition failed!" );
55 return StatusCode::FAILURE;
56 }
57 m_cellGroupList.printDef();
58
59
61 const LArOnOffIdMapping* cabling=*cablingHdl;
62 if(!cabling) {
63 ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
64 return StatusCode::FAILURE;
65 }
66
67 for (const HWIdentifier hwid: m_onlineId->channel_range()) {
68 if (cabling->isOnlineConnected(hwid)) {
70 Identifier id=cabling->cnvToIdentifier(hwid);
71 const std::vector<float>& v=m_cellGroupList.valuesForCell(id);
72 nValues=v.size();
73 for (size_t i=0;i<v.size();i++)
74 values[i]=v[i];
75 //cellCounter++;
76 sc=ntupleSvc()->writeRecord(m_nt);
77 if (sc!=StatusCode::SUCCESS) {
78 ATH_MSG_ERROR( "writeRecord failed" );
79 return StatusCode::FAILURE;
80 }
81 }//end if isConnected
82 }//end loop over online ID
83
84 ATH_MSG_INFO( "CaloCellGroup2Ntuple has finished." );
85 return StatusCode::SUCCESS;
86}// end finalize-method.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static Double_t sc
INTupleSvc * ntupleSvc()
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
CaloCellGroupList m_cellGroupList
CaloCellGroup2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_groupInit
Helper base class for offline cell identifiers.
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
StoreGateSvc * m_detStore
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
const LArOnlineID_Base * m_onlineId
bool fillFromIdentifier(const HWIdentifier &id)
LArCond2NtupleBase(const std::string &name, ISvcLocator *pSvcLocator)
MsgStream & msg
Definition testRead.cxx:32