ATLAS Offline Software
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 
11 CaloCellGroup2Ntuple::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  }
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)) {
69  fillFromIdentifier(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.
CaloCellGroup2Ntuple::CaloCellGroup2Ntuple
CaloCellGroup2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloCellGroup2Ntuple.cxx:11
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
CaloCellGroup2Ntuple::~CaloCellGroup2Ntuple
~CaloCellGroup2Ntuple()
HWIdentifier
Definition: HWIdentifier.h:13
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
CaloCell_ID.h
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1936
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
LArCond2NtupleBase::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCond2NtupleBase.h:89
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
beamspotman.stat
stat
Definition: beamspotman.py:266
CaloCellGroup2Ntuple::stop
StatusCode stop()
Definition: CaloCellGroup2Ntuple.cxx:24
CaloCellGroup2Ntuple::m_cellGroupList
CaloCellGroupList m_cellGroupList
Definition: CaloCellGroup2Ntuple.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
python.PyAthena.v
v
Definition: PyAthena.py:157
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCellGroup2Ntuple::m_groupInit
std::vector< std::string > m_groupInit
Definition: CaloCellGroup2Ntuple.h:24
CaloCellGroup2Ntuple.h
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArCond2NtupleBase::m_detStore
StoreGateSvc * m_detStore
Definition: LArCond2NtupleBase.h:81
CaloCellGroupList::printDef
void printDef() const
Definition: CaloCellGroup.cxx:301
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition: CaloCell_Base_ID.h:41
CaloCellGroupList::valuesForCell
const std::vector< float > & valuesForCell(const Identifier id)
Definition: CaloCellGroup.cxx:266
StoreGateSvc.h
CaloCellGroupList::setDefinition
bool setDefinition(const CaloCell_Base_ID *caloCellId, const std::vector< std::string > &definitions, MsgStream &logStr)
Definition: CaloCellGroup.cxx:225
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20