ATLAS Offline Software
LArPhysWaves2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 
9 LArPhysWaves2Ntuple::LArPhysWaves2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArWaves2Ntuple(name, pSvcLocator)
10 {
11  m_keylist.clear() ;
12  declareProperty("KeyList", m_keylist);
13  declareProperty("NtupleName", m_ntName);
14  declareProperty("AddCorrUndo", m_addCorrUndo=true);
15  declareProperty("ApplyCorrection",m_applyCorr=false);
16 }
17 
19 = default;
20 
21 
23  m_ntTitle="Physics Wave";
24  m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName;
26 }
27 
28 
30 {
31 
32  StatusCode sc;
33 
34  sc=m_nt->addItem("gain",m_gain,0,3);
35  if (sc!=StatusCode::SUCCESS) {
36  ATH_MSG_ERROR( "addItem 'gain' failed" );
37  return StatusCode::FAILURE;
38  }
39 
40  sc=m_nt->addItem("timeOffset",m_timeOffset,0.,100.);
41  if (sc!=StatusCode::SUCCESS) {
42  ATH_MSG_ERROR( "addItem 'timeOffset' failed" );
43  return StatusCode::FAILURE;
44  }
45 
46 
47  if (m_addCorrUndo) {
48  sc=m_nt->addItem("corrUndo",m_corrUndo,0,1);
49  if (sc!=StatusCode::SUCCESS) {
50  ATH_MSG_ERROR( "addItem 'corrUndo' failed" );
51  return StatusCode::FAILURE;
52  }
53  }
54 
55  for ( unsigned k=0 ; k<m_keylist.size() ; k++ ) {
56  const std::string& key = m_keylist[k] ;
57 
58 
59  ATH_MSG_INFO( "Processing WaveContainer from StoreGate! key=" << m_keylist[k] );
60  const LArPhysWaveContainer* physWaveContainer = nullptr;
61  LArPhysWaveContainer* physWaveContainer_nc = nullptr;
62  StatusCode sc;
63  if (m_applyCorr) {
64  sc = m_detStore->retrieve(physWaveContainer_nc,key);
65  if (sc.isFailure()) {
66  ATH_MSG_ERROR( "Cannot read non-const LArPhysWaveContainer from StoreGate! key=" << key );
67  ATH_MSG_ERROR( "The ApplyCorrection option works only for non-const containers!" );
68  return sc;
69  }
70  else
71  ATH_MSG_INFO( "Read non-const LArPhysWaveContainer from StoreGate! key= " << key );
72 
73  if (!physWaveContainer_nc->correctionsApplied()) {
74  sc=physWaveContainer_nc->applyCorrections();
75  if (sc.isFailure()) {
76  ATH_MSG_ERROR( "Failed to apply corrections to LArPhysWaveContainer!" );
77  }
78  }
79  physWaveContainer=physWaveContainer_nc;
80  }
81  else {
82  sc = m_detStore->retrieve(physWaveContainer,key);
83  if (sc.isFailure()) {
84  ATH_MSG_ERROR( "Cannot read LArPhysWaveContainer from StoreGate! key=" << key );
85  return StatusCode::FAILURE;
86  } else
87  ATH_MSG_INFO( "Read const LArPhysWaveContainer from StoreGate! key= " << key );
88  }
89 
91  for (const HWIdentifier chid: m_onlineId->channel_range()) {
92  m_gain=(long)igain;
93  const LArPhysWave& wave=physWaveContainer->get(chid,igain);
94  if (wave.isEmpty()) continue;
96  fillWave(chid,wave); //Fill method from base-class
97  m_timeOffset = wave.getTimeOffset();
98  sc=ntupleSvc()->writeRecord(m_nt);
99  if (sc!=StatusCode::SUCCESS) {
100  ATH_MSG_ERROR( "writeRecord failed" );
101  return sc;
102  }
103  }//end loop over identifiers
104  }//end loop over gains
105 
106  if (m_addCorrUndo) {
109  LArPhysWaveContainer::ConstCorrectionIt itUndo_e=physWaveContainer->undoCorrEnd(igain);
110  for(;itUndo!=itUndo_e;itUndo++) {
111  const HWIdentifier chid(itUndo->first);
112  const LArPhysWave& wave = itUndo->second;
113  m_gain = (long)igain;
114  m_corrUndo = 1;
115  fillWave(chid,wave); //Fill method from base-class
116  sc=ntupleSvc()->writeRecord(m_nt);
117  if (sc!=StatusCode::SUCCESS) {
118  ATH_MSG_ERROR( "writeRecord failed" );
119  return sc;
120  }
121  }//end loop over corrections
122  }//end loop over gain
123  }//end if addCorrUndo
124  }//end loop over container keys
125  ATH_MSG_INFO( "LArWave2Ntuple has finished." );
126  return StatusCode::SUCCESS;
127 } // end finalize-method.
128 
LArPhysWaves2Ntuple::LArPhysWaves2Ntuple
LArPhysWaves2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArPhysWaves2Ntuple.cxx:9
LArConditionsContainer::applyCorrections
StatusCode applyCorrections()
apply correction set
LArWaves2Ntuple::initialize
StatusCode initialize()
Definition: LArWaves2Ntuple.cxx:18
LArPhysWaves2Ntuple::m_addCorrUndo
bool m_addCorrUndo
Definition: LArPhysWaves2Ntuple.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArPhysWaves2Ntuple::initialize
StatusCode initialize()
Definition: LArPhysWaves2Ntuple.cxx:22
LArPhysWaves2Ntuple::m_corrUndo
NTuple::Item< long > m_corrUndo
Definition: LArPhysWaves2Ntuple.h:48
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArWaves2Ntuple::fillWave
bool fillWave(const HWIdentifier chid, const LArWaveCumul &wave)
Definition: LArWaves2Ntuple.cxx:107
LArPhysWaves2Ntuple::stop
virtual StatusCode stop()
Definition: LArPhysWaves2Ntuple.cxx:29
LArPhysWaves2Ntuple::m_applyCorr
bool m_applyCorr
Definition: LArPhysWaves2Ntuple.h:44
LArConditionsContainer::undoCorrEnd
ConstCorrectionIt undoCorrEnd(unsigned int gain) const
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArPhysWave
Definition: LArPhysWave.h:14
LArPhysWaveContainer
Liquid Argon Physics Wave Container.
Definition: LArPhysWaveContainer.h:23
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
LArPhysWaves2Ntuple::m_keylist
std::vector< std::string > m_keylist
Definition: LArPhysWaves2Ntuple.h:42
LArConditionsContainer< LArPhysWave >::ConstCorrectionIt
Subset::ConstCorrectionVecIt ConstCorrectionIt
Definition: LArConditionsContainer.h:78
LArWave::isEmpty
bool isEmpty() const
is LArWave uninitialized?
Definition: LArWave.h:183
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
LArConditionsContainer::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArWaves2Ntuple
Definition: LArWaves2Ntuple.h:25
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArPhysWaves2Ntuple::m_ntName
std::string m_ntName
Definition: LArPhysWaves2Ntuple.h:43
LArPhysWave::getTimeOffset
int getTimeOffset() const
Definition: LArPhysWave.h:97
LArPhysWaves2Ntuple::m_gain
NTuple::Item< long > m_gain
Definition: LArPhysWaves2Ntuple.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArConditionsContainer::undoCorrBegin
ConstCorrectionIt undoCorrBegin(unsigned int gain) const
get iterator over the Undo-Vector for a certain gain
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArPhysWaves2Ntuple.h
LArCond2NtupleBase::m_detStore
StoreGateSvc * m_detStore
Definition: LArCond2NtupleBase.h:81
LArPhysWaves2Ntuple::m_timeOffset
NTuple::Item< float > m_timeOffset
Definition: LArPhysWaves2Ntuple.h:49
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
fitman.k
k
Definition: fitman.py:528
LArConditionsContainer::correctionsApplied
bool correctionsApplied() const
Have corrections been applied?
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
LArPhysWaves2Ntuple::~LArPhysWaves2Ntuple
~LArPhysWaves2Ntuple()