ATLAS Offline Software
Loading...
Searching...
No Matches
LarDigits2NtupleEB.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12LArDigits2NtupleEB::LArDigits2NtupleEB(const std::string& name, ISvcLocator* pSvcLocator):
13 LArCond2NtupleBaseEB(name, pSvcLocator),
14 m_ipass(0),
15 m_event(0)
16{
17 m_ntTitle = "LArDigits";
18 m_ntpath = "/NTUPLES/FILE1/LARDIGITS";
19}
20
21
23{
24 ATH_MSG_DEBUG( "in initialize" );
25
26 ATH_MSG_DEBUG(" IS it SC?? " << m_isSC );
27
29
30 StatusCode sc = m_nt->addItem("IEvent",m_IEvent);
31 if (sc!=StatusCode::SUCCESS) {
32 ATH_MSG_ERROR( "addItem 'IEvent' failed" );
33 return sc;
34 }
35
36 sc = m_nt->addItem("samples",m_SC,m_Nsamples,m_samples);
37 if (sc!=StatusCode::SUCCESS) {
38 ATH_MSG_ERROR( "addItem 'samples' failed" );
39 return sc;
40 }
41
42 sc = m_nt->addItem("Nsamples",m_SC,m_ntNsamples,0,32);
43 if (sc!=StatusCode::SUCCESS) {
44 ATH_MSG_ERROR( "addItem 'Nsamples' failed" );
45 return sc;
46 }
47
48 if(m_fillBCID){
49 sc = m_nt->addItem("BCID",m_bcid);
50 if (sc!=StatusCode::SUCCESS) {
51 ATH_MSG_ERROR( "addItem 'BCID' failed" );
52 return sc;
53 }
54 }
55
56 if(!m_isSC){
57 sc = m_nt->addItem("ELVL1Id",m_SC,m_ELVL1Id);
58 if (sc!=StatusCode::SUCCESS) {
59 ATH_MSG_ERROR( "addItem 'ELVL1Id' failed" );
60 return sc;
61 }
62 }
63
64 // SC_ET RawSCContainer
65 sc = m_nt->addItem("energyVec_ET", m_SC, m_Net, m_energyVec_ET);
66 if (sc.isFailure()) {
67 ATH_MSG_ERROR( "addItem 'energyVec_ET' failed" );
68 return sc;
69 }
70
71 sc = m_nt->addItem("bcidVec_ET", m_SC, m_Net, m_bcidVec_ET);
72 if (sc.isFailure()) {
73 ATH_MSG_ERROR( "addItem 'bcidVec_ET' failed" );
74 return sc;
75 }
76
77 sc = m_nt->addItem("saturVec_ET", m_SC, m_Net, m_saturVec_ET);
78 if (sc.isFailure()) {
79 ATH_MSG_ERROR( "addItem 'saturVec_ET' failed" );
80 return sc;
81 }
82
83 sc = m_nt->addItem("energyVec_ET_ID", m_SC, m_Net, m_energyVec_ET_ID);
84 if (sc.isFailure()) {
85 ATH_MSG_ERROR( "addItem 'energyVec_ET_ID' failed" );
86 return sc;
87 }
88
89 sc = m_nt->addItem("bcidVec_ET_ID", m_SC, m_Net, m_bcidVec_ET_ID);
90 if (sc.isFailure()) {
91 ATH_MSG_ERROR( "addItem 'bcidVec_ET_ID' failed" );
92 return sc;
93 }
94
95 sc = m_nt->addItem("saturVec_ET_ID", m_SC, m_Net, m_saturVec_ET_ID);
96 if (sc.isFailure()) {
97 ATH_MSG_ERROR( "addItem 'saturVec_ET_ID' failed" );
98 return sc;
99 }
100
101 ATH_CHECK(m_contKey.initialize() );
102 ATH_CHECK(m_evtInfoKey.initialize() );
104
105 m_ipass = 0;
106 m_event = 0;
107
108 return StatusCode::SUCCESS;
109
110}
111
113{
114
115 StatusCode sc;
116
117 ATH_MSG_DEBUG( "LArDigits2NtupleEB in execute" );
118 m_event++;
119 unsigned long long thisevent;
120 unsigned long thisbcid = 0;
121 unsigned long thisELVL1Id = 0;
122
124 thisevent = evt->eventNumber();
125
126 // Get BCID from FEB header
127 if ( !m_isSC ){ // we are not processing SC data, Feb header could be accessed
129 if (! hdrCont.isValid()) {
130 ATH_MSG_WARNING( "No LArFEB container found in TDS" );
131 }
132 else {
133 ATH_MSG_DEBUG( "LArFEB container found");
134 if(m_fillBCID) thisbcid = (*hdrCont->begin())->BCId() ;
135 ATH_MSG_DEBUG( "BCID FROM FEB HEADER " << thisbcid );
136 thisELVL1Id = (*hdrCont->begin())->ELVL1Id();
137 ATH_MSG_DEBUG( "NSAMPLES FROM FEB HEADER " << (*hdrCont->begin())->NbSamples() );
138 }
139 }else{
140 // This should be used for main readout later, once TDAQ fill event headers also in calib. runs properly
141 thisbcid = evt->bcid();
142 }
143
144 m_contKey="SC";
146
147 if(!hdlDigit.isValid()) {
148 ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey << " from DetectorStore. " );
149 return StatusCode::SUCCESS;
150 } else
151 ATH_MSG_DEBUG( "Got LArDigitContainer with key " << m_contKey.key() );
152
153 const LArDigitContainer DigitContainer = *hdlDigit;
154 const LArRawSCContainer* etcontainer = nullptr;
155 const LArRawSCContainer* etcontainer_next = nullptr;
156
157 unsigned cellCounter=0;
158
159 if(m_fillBCID) m_bcid = thisbcid;
160 m_IEvent = thisevent;
161
162
163 sc = evtStore()->retrieve(etcontainer,"SC_ET");
164 if (sc.isFailure()) { ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " );}
165 else ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET " );
166
167 sc = evtStore()->retrieve(etcontainer_next,"SC_ET_ID");
168 if (sc.isFailure()) { ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " );}
169 else ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET_ID" );
170
171
172
173 for( const LArDigit *digi : DigitContainer ){
174
175 unsigned int trueMaxSample = digi->nsamples();
176 m_ntNsamples[cellCounter] = trueMaxSample;
177
178 if (!m_isSC){
179 m_gain[cellCounter] = digi->gain();
180 m_ELVL1Id[cellCounter] = thisELVL1Id;
181 if(m_gain[cellCounter] < CaloGain::INVALIDGAIN || m_gain[cellCounter] > CaloGain::LARNGAIN) m_gain[cellCounter] = CaloGain::LARNGAIN;
182 }
183 if(trueMaxSample>m_Nsamples){
184 if(!m_ipass){
185 ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " );
186 m_ipass = 1;
187 }
188 trueMaxSample = m_Nsamples;
189 }
190
191 fillFromIdentifier(digi->hardwareID(), cellCounter);
192
193
194 for(unsigned i = 0; i<trueMaxSample;++i) m_samples[cellCounter][i] = digi->samples().at(i);
195
196 if( etcontainer ){
197 const LArRawSC*rawSC = etcontainer->at(cellCounter);
198
199 unsigned int truenet = m_Net;
200
201 if(truenet > rawSC->bcids().size()) truenet=rawSC->bcids().size();
202 for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
203 m_bcidVec_ET[cellCounter][i] = rawSC->bcids().at(i);
204 }
205
206 if(truenet > rawSC->energies().size()) truenet=rawSC->energies().size();
207 for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
208 m_energyVec_ET[cellCounter][i] = rawSC->energies().at(i);
209
210 }
211
212 if(truenet > rawSC->satur().size()) truenet=rawSC->satur().size();
213
214 for( unsigned i = 0; i<truenet;++i){ // just use the vector directly?
215 m_saturVec_ET[cellCounter][i] = rawSC->satur().at(i);
216 }
217
218 m_Net=truenet;
219 }
220
221 if( etcontainer_next ){
222 const LArRawSC*rawSC = etcontainer_next->at(cellCounter);
223
224 for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly?
225 m_bcidVec_ET_ID[cellCounter][i] = rawSC->bcids()[i];
226 }
227 for( unsigned i=0; i<rawSC->energies().size();++i){ // just use the vector directly?
228 m_energyVec_ET_ID[cellCounter][i] = rawSC->energies()[i];
229 }
230 for( unsigned i = 0; i<rawSC->satur().size();++i){ // just use the vector directly? ?
231 m_saturVec_ET_ID[cellCounter][i] = rawSC->satur()[i];
232 }
233 }
234
235 cellCounter++;
236 }// over cells
237
238
239 ATH_CHECK( ntupleSvc()->writeRecord(m_nt) );
240
241 ATH_MSG_DEBUG( "LArDigits2NtupleEB has finished, filled"<< cellCounter << " cells" );
242 return StatusCode::SUCCESS;
243}// end finalize-method.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
INTupleSvc * ntupleSvc()
const T * at(size_type n) const
Access an element, as an rvalue.
Gaudi::Property< bool > m_isSC
bool fillFromIdentifier(const HWIdentifier &id, int C)
LArCond2NtupleBaseEB(const std::string &name, ISvcLocator *pSvcLocator)
Container class for LArDigit.
Liquid Argon digit base class.
Definition LArDigit.h:25
NTuple::Array< short > m_ELVL1Id
Gaudi::Property< unsigned int > m_Net
NTuple::Item< unsigned long long > m_IEvent
NTuple::Array< int > m_ntNsamples
NTuple::Matrix< float > m_bcidVec_ET
LArDigits2NtupleEB(const std::string &name, ISvcLocator *pSvcLocator)
NTuple::Array< short > m_gain
virtual StatusCode initialize() override
virtual StatusCode execute() override
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
SG::ReadHandleKey< LArFebHeaderContainer > m_LArFebHeaderContainerKey
Gaudi::Property< unsigned int > m_Nsamples
Gaudi::Property< bool > m_fillBCID
NTuple::Matrix< float > m_energyVec_ET_ID
NTuple::Matrix< short > m_samples
NTuple::Matrix< bool > m_saturVec_ET_ID
NTuple::Matrix< bool > m_saturVec_ET
NTuple::Matrix< float > m_bcidVec_ET_ID
NTuple::Matrix< float > m_energyVec_ET
NTuple::Item< short > m_bcid
SG::ReadHandleKey< LArDigitContainer > m_contKey
Container class for LArRawSC.
Liquid Argon SuperCell raw data.
Definition LArRawSC.h:19
const std::vector< bool > & satur() const
Definition LArRawSC.h:107
const std::vector< unsigned short > & bcids() const
Definition LArRawSC.h:104
const std::vector< int > & energies() const
Definition LArRawSC.h:101
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ INVALIDGAIN
Definition CaloGain.h:18
@ LARNGAIN
Definition CaloGain.h:19