ATLAS Offline Software
LArNoise2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 
11 LArNoise2Ntuple::LArNoise2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
12  LArCond2NtupleBase(name, pSvcLocator) {
13  declareProperty("ContainerKey",m_contKey);
14 
15  m_ntTitle="Noise";
16  m_ntpath="/NTUPLES/FILE1/NOISE";
17 
18 }
19 
21 = default;
22 
24  const ILArNoise* larNoise = nullptr;
25  StatusCode sc;
26  sc=m_detStore->retrieve(larNoise,m_contKey);
27  if (sc!=StatusCode::SUCCESS) {
28  ATH_MSG_ERROR( "Unable to retrieve ILArNoise with key "
29  << m_contKey << " from DetectorStore" );
30  return StatusCode::FAILURE;
31  }
32 
33  NTuple::Item<long> cellIndex,gain;
34  NTuple::Item<float> noise;
35 
36  sc=m_nt->addItem("icell",cellIndex,0,2000);
37  if (sc!=StatusCode::SUCCESS)
38  {ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
39  return StatusCode::FAILURE;
40  }
41 
42  sc=m_nt->addItem("gain",gain,0,3);
43  if (sc!=StatusCode::SUCCESS)
44  {ATH_MSG_ERROR( "addItem 'gain' failed" );
45  return StatusCode::FAILURE;
46  }
47 
48 
49  sc=m_nt->addItem("noise",noise);
50  if (sc!=StatusCode::SUCCESS)
51  {ATH_MSG_ERROR( "addItem 'noise' failed" );
52  return StatusCode::FAILURE;
53  }
54 
56  const LArOnOffIdMapping* cabling=*cablingHdl;
57  if(!cabling) {
58  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
59  return StatusCode::FAILURE;
60  }
61 
62  unsigned cellCounter=0;
64  for (const HWIdentifier hwid: m_onlineId->channel_range()) {
65  if ( cabling->isOnlineConnected(hwid)) {
66  fillFromIdentifier(hwid);
67  cellIndex = cellCounter;
68  gain=igain;
69  noise = larNoise->noise(hwid,igain);
70  sc=ntupleSvc()->writeRecord(m_nt);
71  if (sc!=StatusCode::SUCCESS) {
72  ATH_MSG_ERROR( "writeRecord failed" );
73  return StatusCode::FAILURE;
74  }
75  }//end if isConnected
76  cellCounter++;
77  }//end loop over online ID
78  } // ovr gains
79 
80  ATH_MSG_INFO( "LArNoise2Ntuple has finished." );
81  return StatusCode::SUCCESS;
82 }// end finalize-method.
83 
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
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArNoise2Ntuple.h
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArNoise2Ntuple::m_contKey
std::string m_contKey
Definition: LArNoise2Ntuple.h:22
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ILArNoise
Definition: ILArNoise.h:12
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
LArNoiseComplete.h
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
LArNoise2Ntuple::LArNoise2Ntuple
LArNoise2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArNoise2Ntuple.cxx:11
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
ILArNoise::noise
virtual const float & noise(const HWIdentifier &id, int gain) const =0
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArNoise2Ntuple::~LArNoise2Ntuple
~LArNoise2Ntuple()
LArCond2NtupleBase::m_detStore
StoreGateSvc * m_detStore
Definition: LArCond2NtupleBase.h:81
LArNoise2Ntuple::stop
virtual StatusCode stop()
Definition: LArNoise2Ntuple.cxx:23
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
LArNoiseMC.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20