ATLAS Offline Software
LArOFCBin2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9 
10 
11 LArOFCBin2Ntuple::LArOFCBin2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
12  LArCond2NtupleBase(name, pSvcLocator) {
13  m_ntTitle="OFCBIN";
14  m_ntpath="/NTUPLES/FILE1/OFCBIN";
15 
16 }
17 
19 {
23 
25  return StatusCode::SUCCESS;
26 }
27 
29 
30  const EventContext& ctx = Gaudi::Hive::currentContext();
31 
32  NTuple::Item<long> cellIndex;
33  NTuple::Item<int> ofcbin;
34 
35  StatusCode sc=m_nt->addItem("icell",cellIndex,0,2000);
36  if (sc!=StatusCode::SUCCESS)
37  {ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
38  return StatusCode::FAILURE;
39  }
40 
41 
42  sc=m_nt->addItem("OFCBin",ofcbin,0,50);
43  if (sc!=StatusCode::SUCCESS) {
44  ATH_MSG_ERROR( "addItem 'OFCBin' failed" );
45  return StatusCode::FAILURE;
46  }
47 
48  const LArOnOffIdMapping *cabling=nullptr;
49  if(m_isSC) {
50  ATH_MSG_DEBUG( "LArOFC2Ntuple: using SC cabling" );
52  cabling=*cablingHdl;
53  }else{
55  cabling=*cablingHdl;
56  }
57 
58 
59  if(!cabling) {
60  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
61  return StatusCode::FAILURE;
62  }
63 
64  const ILArOFCBin* LArbin = nullptr;
66  LArbin = ofcbinHdl.cptr();
67  if(!LArbin) {
68  ATH_MSG_ERROR( "Unable to retrieve ILArOFCBin with key "
69  << m_binKey << " from ConditionsStore" );
70  return StatusCode::FAILURE;
71  }
72 
73  unsigned cellCounter=0;
74  for(HWIdentifier hwid : m_onlineId->channel_range()){
75  if ( cabling->isOnlineConnected(hwid)) {
76  fillFromIdentifier(hwid);
77  cellIndex = cellCounter;
78  ofcbin = LArbin->bin(hwid,0);
79  sc=ntupleSvc()->writeRecord(m_nt);
80  if (sc!=StatusCode::SUCCESS) {
81  ATH_MSG_ERROR( "writeRecord failed" );
82  return StatusCode::FAILURE;
83  }
84  cellCounter++;
85  }//end if isConnected
86  }//end loop over online ID
87  ATH_MSG_INFO("LArOFCBin2Ntuple: filled "<<cellCounter);
88  ATH_MSG_INFO( "LArOFCBin2Ntuple has finished." );
89  return StatusCode::SUCCESS;
90 }// end finalize-method.
91 
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArOFCBin2Ntuple.h
HWIdentifier
Definition: HWIdentifier.h:13
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArCond2NtupleBase::m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
Definition: LArCond2NtupleBase.h:90
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArRinjComplete.h
LArOFCBin2Ntuple::stop
virtual StatusCode stop() override
Definition: LArOFCBin2Ntuple.cxx:28
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:1932
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArOFCBin2Ntuple::m_binKey
SG::ReadCondHandleKey< ILArOFCBin > m_binKey
Definition: LArOFCBin2Ntuple.h:27
ILArOFCBin
Definition: ILArOFCBin.h:12
ILArOFCBin::bin
virtual const int & bin(const HWIdentifier &id, const int &gain) const =0
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArOFCBin2Ntuple::LArOFCBin2Ntuple
LArOFCBin2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArOFCBin2Ntuple.cxx:11
LArOFCBin2Ntuple::initialize
virtual StatusCode initialize() override
Definition: LArOFCBin2Ntuple.cxx:18
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67