ATLAS Offline Software
LArPedestals2Ntuple.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 LArPedestals2Ntuple::LArPedestals2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
11  LArCond2NtupleBase(name, pSvcLocator),
12  m_pedKey("Pedestal"){
13 
14  declareProperty("ContainerKey",m_pedKey);
15  m_ntTitle="Pedestals";
16  m_ntpath="/NTUPLES/FILE1/PEDESTALS";
17 
18 }
19 
21 = default;
22 
26 }
27 
29 {
30  // For compatibility with existing configurations, look in the detector
31  // store first, then in conditions.
32  const ILArPedestal* larPedestal =
33  detStore()->tryConstRetrieve<ILArPedestal> (m_pedKey.key());
34  if (!larPedestal) {
36  larPedestal = *pedHandle;
37  }
38 
39  if (larPedestal==nullptr) {
40  ATH_MSG_ERROR( "Unable to retrieve ILArPedestal with key "
41  << m_pedKey.key() << " from DetectorStore");
42  return StatusCode::FAILURE;
43  }
44 
45  NTuple::Item<long> cellIndex,gain;
46  NTuple::Item<double> ped;
47  NTuple::Item<double> rms;
48 
49 
50  StatusCode sc=m_nt->addItem("icell",cellIndex,0,200000);
51  if (sc!=StatusCode::SUCCESS)
52  {ATH_MSG_ERROR( "addItem 'Cell Index' failed" );
53  return StatusCode::FAILURE;
54  }
55 
56  sc=m_nt->addItem("gain",gain,0,3);
57  if (sc!=StatusCode::SUCCESS) {
58  ATH_MSG_ERROR( "addItem 'gain' failed" );
59  return StatusCode::FAILURE;
60  }
61 
62 
63  sc=m_nt->addItem("ped",ped,-1000.,5000.);
64  if (sc!=StatusCode::SUCCESS) {
65  ATH_MSG_ERROR( "addItem 'ped' failed" );
66  return StatusCode::FAILURE;
67  }
68 
69  sc=m_nt->addItem("rms",rms,0.,1e12);
70  if (sc!=StatusCode::SUCCESS) {
71  ATH_MSG_ERROR( "addItem 'rms' failed" );
72  return StatusCode::FAILURE;
73  }
74 
75 
76  unsigned cellCounter=0;
77  auto maxgain = CaloGain::LARNGAIN;
78  if(m_isSC) maxgain=CaloGain::LARMEDIUMGAIN;
79 
80  for(long igain=CaloGain::LARHIGHGAIN; igain<maxgain; igain++) {
81  for (const HWIdentifier hwid: m_onlineId->channel_range()) {
82  if (larPedestal->pedestal(hwid,igain)>ILArPedestal::ERRORCODE) {
83  fillFromIdentifier(hwid);
84  cellIndex = cellCounter;
85 
86  ped=larPedestal->pedestal(hwid,igain);
87  rms=larPedestal->pedestalRMS(hwid,igain);
88  gain=igain;
89 
90  sc=ntupleSvc()->writeRecord(m_nt);
91  if (sc!=StatusCode::SUCCESS) {
92  ATH_MSG_ERROR( "writeRecord failed" );
93  return StatusCode::FAILURE;
94  }
95  }// end if Pedestal exists for this channel
96  cellCounter++;
97  }//end loop over gains
98  }//end loop over online ID
99 
100  ATH_MSG_INFO( "LArPedestals2Ntuple has finished." );
101  return StatusCode::SUCCESS;
102 }// end finalize-method.
103 
LArPedestals2Ntuple::~LArPedestals2Ntuple
~LArPedestals2Ntuple()
ILArPedestal::pedestal
virtual float pedestal(const HWIdentifier &id, int gain) const =0
LArPedestals2Ntuple::LArPedestals2Ntuple
LArPedestals2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArPedestals2Ntuple.cxx:10
LArPedestals2Ntuple::m_pedKey
SG::ReadCondHandleKey< ILArPedestal > m_pedKey
Definition: LArPedestals2Ntuple.h:38
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
ILArPedestal
Definition: ILArPedestal.h:12
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArPedestals2Ntuple.h
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
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
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:1932
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArPedestals2Ntuple::stop
virtual StatusCode stop()
Definition: LArPedestals2Ntuple.cxx:28
ILArPedestal::ERRORCODE
@ ERRORCODE
Definition: ILArPedestal.h:47
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
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
LArPedestals2Ntuple::initialize
StatusCode initialize()
Definition: LArPedestals2Ntuple.cxx:23
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArPedestalComplete.h
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
ILArPedestal::pedestalRMS
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting