ATLAS Offline Software
Loading...
Searching...
No Matches
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
9LArPhysWaves2Ntuple::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
90 for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain){
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
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) {
107 for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain) {
108 LArPhysWaveContainer::ConstCorrectionIt itUndo=physWaveContainer->undoCorrBegin(igain);
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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static Double_t sc
INTupleSvc * ntupleSvc()
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StoreGateSvc * m_detStore
const LArOnlineID_Base * m_onlineId
bool correctionsApplied() const
Have corrections been applied?
StatusCode applyCorrections()
apply correction set
ConstCorrectionIt undoCorrBegin(unsigned int gain) const
get iterator over the Undo-Vector for a certain gain
ConstCorrectionIt undoCorrEnd(unsigned int gain) const
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
Subset::ConstCorrectionVecIt ConstCorrectionIt
Liquid Argon Physics Wave Container.
int getTimeOffset() const
Definition LArPhysWave.h:97
std::vector< std::string > m_keylist
NTuple::Item< float > m_timeOffset
virtual StatusCode stop()
NTuple::Item< long > m_corrUndo
LArPhysWaves2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
NTuple::Item< long > m_gain
bool isEmpty() const
is LArWave uninitialized?
Definition LArWave.h:183
StatusCode initialize()
LArWaves2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
bool fillWave(const HWIdentifier chid, const LArWaveCumul &wave)
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18