ATLAS Offline Software
LArfSampl2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 
10 LArfSampl2Ntuple::LArfSampl2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
11  LArCond2NtupleBase(name, pSvcLocator) {
12  m_ntTitle="fSampl";
13  m_ntpath="/NTUPLES/FILE1/FSAMPL";
14 
15 }
16 
18 = default;
19 
23 }
24 
26 
27  // For compatibility with existing configurations, look in the detector
28  // store first, then in conditions store
29  const ILArfSampl* larfSampl = detStore()->tryConstRetrieve<ILArfSampl>(m_contKey.key());
30  if (!larfSampl){
32  larfSampl=*fsamplHdl;
33  }
34 
35  StatusCode sc;
36 
37  NTuple::Item<long> cellIndex;
38  NTuple::Item<float> fsampl;
39 
40  sc=m_nt->addItem("icell",cellIndex,0,2000);
41  if (sc!=StatusCode::SUCCESS)
42  {ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
43  return StatusCode::FAILURE;
44  }
45 
46  sc=m_nt->addItem("fsampl",fsampl);
47  if (sc!=StatusCode::SUCCESS)
48  {ATH_MSG_ERROR( "addItem 'fsampl' failed" );
49  return StatusCode::FAILURE;
50  }
51 
53  const LArOnOffIdMapping* cabling=*cablingHdl;
54  if(!cabling) {
55  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
56  return StatusCode::FAILURE;
57  }
58 
59  unsigned cellCounter=0;
60  for (const HWIdentifier hwid: m_onlineId->channel_range()) {
61  if ( cabling->isOnlineConnected(hwid)) {
62  fillFromIdentifier(hwid);
63  cellIndex = cellCounter;
64  fsampl = larfSampl->FSAMPL(hwid);
65  sc=ntupleSvc()->writeRecord(m_nt);
66  if (sc!=StatusCode::SUCCESS) {
67  ATH_MSG_ERROR( "writeRecord failed" );
68  return StatusCode::FAILURE;
69  }
70  }//end if isConnected
71  cellCounter++;
72  }//end loop over online ID
73 
74  ATH_MSG_INFO( "LArfSampl2Ntuple has finished." );
75  return StatusCode::SUCCESS;
76 }// end finalize-method.
77 
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArfSampl2Ntuple::~LArfSampl2Ntuple
~LArfSampl2Ntuple()
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
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
LArfSampl2Ntuple::stop
virtual StatusCode stop()
Definition: LArfSampl2Ntuple.cxx:25
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
ILArfSampl::FSAMPL
virtual const float & FSAMPL(const HWIdentifier &id) const =0
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
LArfSamplMC.h
LArfSampl2Ntuple.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArfSampl2Ntuple::LArfSampl2Ntuple
LArfSampl2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArfSampl2Ntuple.cxx:10
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
LArfSampl2Ntuple::initialize
StatusCode initialize()
Definition: LArfSampl2Ntuple.cxx:20
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArfSampl2Ntuple::m_contKey
SG::ReadCondHandleKey< ILArfSampl > m_contKey
Definition: LArfSampl2Ntuple.h:22
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
ILArfSampl
Definition: ILArfSampl.h:14
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20