ATLAS Offline Software
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 
12 LArDigits2NtupleEB::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 
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.
LArCond2NtupleBaseEB::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBaseEB.h:63
LArRawSC
Liquid Argon SuperCell raw data.
Definition: LArRawSC.h:19
LArDigits2NtupleEB::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
Definition: LArDigits2NtupleEB.h:52
LArRawSCContainer.h
LArDigits2NtupleEB::initialize
virtual StatusCode initialize() override
Definition: LarDigits2NtupleEB.cxx:22
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArDigits2NtupleEB::m_bcidVec_ET_ID
NTuple::Matrix< float > m_bcidVec_ET_ID
Definition: LArDigits2NtupleEB.h:48
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
LArDigits2NtupleEB::m_Net
Gaudi::Property< unsigned int > m_Net
Definition: LArDigits2NtupleEB.h:32
LArLATOMEHeaderContainer.h
LArCond2NtupleBaseEB::initialize
StatusCode initialize()
Definition: LArCond2NtupleBaseEB.cxx:29
LArCond2NtupleBaseEB::m_SC
const int m_SC
Definition: LArCond2NtupleBaseEB.h:80
LArDigits2NtupleEB::m_ntNsamples
NTuple::Array< int > m_ntNsamples
Definition: LArDigits2NtupleEB.h:36
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
LArDigits2NtupleEB::m_bcidVec_ET
NTuple::Matrix< float > m_bcidVec_ET
Definition: LArDigits2NtupleEB.h:44
LArCond2NtupleBaseEB::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBaseEB.h:63
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArRawSC::satur
const std::vector< bool > & satur() const
Definition: LArRawSC.h:107
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArDigits2NtupleEB::LArDigits2NtupleEB
LArDigits2NtupleEB(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LarDigits2NtupleEB.cxx:12
LArDigits2NtupleEB::m_saturVec_ET_ID
NTuple::Matrix< bool > m_saturVec_ET_ID
Definition: LArDigits2NtupleEB.h:49
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition: CaloGain.h:18
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArDigits2NtupleEB::m_bcid
NTuple::Item< short > m_bcid
Definition: LArDigits2NtupleEB.h:41
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArDigits2NtupleEB::m_energyVec_ET
NTuple::Matrix< float > m_energyVec_ET
Definition: LArDigits2NtupleEB.h:43
LArDigits2NtupleEB::m_LArFebHeaderContainerKey
SG::ReadHandleKey< LArFebHeaderContainer > m_LArFebHeaderContainerKey
Definition: LArDigits2NtupleEB.h:53
LArSCDigit.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArCond2NtupleBaseEB::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id, int C)
Definition: LArCond2NtupleBaseEB.cxx:280
LArCond2NtupleBaseEB
Definition: LArCond2NtupleBaseEB.h:32
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArDigits2NtupleEB::m_energyVec_ET_ID
NTuple::Matrix< float > m_energyVec_ET_ID
Definition: LArDigits2NtupleEB.h:47
LArCond2NtupleBaseEB::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBaseEB.h:66
LArDigits2NtupleEB::m_samples
NTuple::Matrix< short > m_samples
Definition: LArDigits2NtupleEB.h:40
HWIdentifier.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArDigits2NtupleEB::m_Nsamples
Gaudi::Property< unsigned int > m_Nsamples
Definition: LArDigits2NtupleEB.h:31
LArDigits2NtupleEB::m_IEvent
NTuple::Item< unsigned long long > m_IEvent
Definition: LArDigits2NtupleEB.h:39
LArDigits2NtupleEB::m_contKey
SG::ReadHandleKey< LArDigitContainer > m_contKey
Definition: LArDigits2NtupleEB.h:51
LArDigitContainer.h
LArRawSC::bcids
const std::vector< unsigned short > & bcids() const
Definition: LArRawSC.h:104
LArDigits2NtupleEB::m_ELVL1Id
NTuple::Array< short > m_ELVL1Id
Definition: LArDigits2NtupleEB.h:38
LArDigits2NtupleEB::execute
virtual StatusCode execute() override
Definition: LarDigits2NtupleEB.cxx:112
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArDigits2NtupleEB::m_event
long m_event
Definition: LArDigits2NtupleEB.h:29
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
LArDigits2NtupleEB::m_gain
NTuple::Array< short > m_gain
Definition: LArDigits2NtupleEB.h:37
LArDigits2NtupleEB::m_ipass
int m_ipass
Definition: LArDigits2NtupleEB.h:27
LArDigits2NtupleEB.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
LArDigits2NtupleEB::m_saturVec_ET
NTuple::Matrix< bool > m_saturVec_ET
Definition: LArDigits2NtupleEB.h:45
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
LArCond2NtupleBaseEB::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBaseEB.h:53
LArRawSC::energies
const std::vector< int > & energies() const
Definition: LArRawSC.h:101
LArDigits2NtupleEB::m_fillBCID
Gaudi::Property< bool > m_fillBCID
Definition: LArDigits2NtupleEB.h:34