ATLAS Offline Software
LArSC2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 
13 LArSC2Ntuple::LArSC2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
14  LArDigits2Ntuple(name, pSvcLocator) {
15  m_ntTitle = "SCDigits";
16  m_ntpath = "/NTUPLES/FILE1/SCDIGITS";
17  }
18 
20 
21  ATH_MSG_DEBUG( "LArSC2Ntuple in initialize" );
22 
23  m_isSC = true;
24  if(m_fillTType && (! m_fillLB)) m_fillLB = true;
25  if(m_fillCaloTT && (! m_fillLB)) m_fillLB = true;
26 
28  ATH_CHECK( m_scidtool.retrieve() );
29 
32  ATH_CHECK( m_eventInfoDecorKey.initialize() );
33 
35 
36  StatusCode sc=m_nt->addItem("latomeChannel",m_latomeChannel);
37  if (sc.isFailure()) {
38  ATH_MSG_ERROR( "addItem 'latomeChannel' failed" );
39  return sc;
40  }
41 
42  sc = m_nt->addItem("bcidVec",m_Nsamples, m_bcidVec);//here - > define length?
43  if (sc.isFailure()) {
44  ATH_MSG_ERROR( "addItem 'bcidVec' failed" );
45  return sc;
46  }
47  sc = m_nt->addItem("latomeSourceId",m_latomeSourceId);
48  if (sc.isFailure()) {
49  ATH_MSG_ERROR( "addItem 'latomeSourceId' failed" );
50  return sc;
51  }
52  sc = m_nt->addItem("Net",m_ntNet);
53  if (sc.isFailure()) {
54  ATH_MSG_ERROR( "addItem 'Net' failed" );
55  return sc;
56  }
57 
58  // Loop over container keys
59  for ( const std::string &ck : m_contKeys ){
60  if ( ck.find("SC") == std::string::npos){ // main readout only
61  if ( m_fillRawChan && ck == "LArRawChannels" ){
62  sc = m_nt->addItem("ROD_energy", 16, m_ROD_energy);
63  if (sc.isFailure()) {
64  ATH_MSG_ERROR( "addItem 'ROD_energy' failed" );
65  return sc;
66  }
67  sc = m_nt->addItem("ROD_time", 16, m_ROD_time);
68  if (sc.isFailure()) {
69  ATH_MSG_ERROR( "addItem 'ROD_time' failed" );
70  return sc;
71  }
72  sc = m_nt->addItem("ROD_id", 16, m_ROD_id);
73  if (sc.isFailure()) {
74  ATH_MSG_ERROR( "addItem 'ROD_id' failed" );
75  return sc;
76  }
77  }
78 
79  }else if ( ck == "SC_ADC_BAS" ){ // SC_ADC_BAS DigitContainer
80  sc = m_nt->addItem("samples_ADC_BAS",m_Nsamples,m_samples_ADC_BAS);
81  if (sc.isFailure()) {
82  ATH_MSG_ERROR( "addItem 'samples_ADC_BAS' failed" );
83  return sc;
84  }
85 
86  sc = m_nt->addItem("bcidVec_ADC_BAS",m_Nsamples, m_bcidVec_ADC_BAS);//here - > define length?
87  if (sc.isFailure()) {
88  ATH_MSG_ERROR( "addItem 'bcidVec_ADC_BAS' failed" );
89  return sc;
90  }
91 
92  }else if ( ck == "SC_ET" ){ // SC_ET RawSCContainer
93  sc = m_nt->addItem("energyVec_ET", m_Net, m_energyVec_ET);
94  if (sc.isFailure()) {
95  ATH_MSG_ERROR( "addItem 'energyVec_ET' failed" );
96  return sc;
97  }
98  sc = m_nt->addItem("bcidVec_ET", m_Net, m_bcidVec_ET);
99  if (sc.isFailure()) {
100  ATH_MSG_ERROR( "addItem 'bcidVec_ET' failed" );
101  return sc;
102  }
103  sc = m_nt->addItem("saturVec_ET", m_Net, m_saturVec_ET);
104  if (sc.isFailure()) {
105  ATH_MSG_ERROR( "addItem 'saturVec_ET' failed" );
106  return sc;
107  }
108 
109  }else if ( ck == "SC_ET_ID" ){ // SC_ET_ID RawSCContainer
110 
111  sc = m_nt->addItem("energyVec_ET_ID", m_Net, m_energyVec_ET_ID);
112  if (sc.isFailure()) {
113  ATH_MSG_ERROR( "addItem 'energyVec_ET_ID' failed" );
114  return sc;
115  }
116  sc = m_nt->addItem("bcidVec_ET_ID", m_Net, m_bcidVec_ET_ID);
117  if (sc.isFailure()) {
118  ATH_MSG_ERROR( "addItem 'bcidVec_ET_ID' failed" );
119  return sc;
120  }
121  sc = m_nt->addItem("saturVec_ET_ID", m_Net, m_saturVec_ET_ID);
122  if (sc.isFailure()) {
123  ATH_MSG_ERROR( "addItem 'saturVec_ET_ID' failed" );
124  return sc;
125  }
126  }
127 
128  }// end container key loop
129 
130  sc = m_nt->addItem("bcidLATOMEHEAD",m_bcidLATOMEHEAD);
131  if (sc.isFailure()) {
132  ATH_MSG_ERROR( "addItem 'bcidLATOMEHEAD' failed" );
133  return sc;
134  }
135 
136  if(m_fillTType) {
137  sc = m_evt_nt->addItem("TType", m_TType);
138  if (sc.isFailure()) {
139  ATH_MSG_ERROR( "addItem 'TType' failed" );
140  return sc;
141  }
142 
143  sc = m_evt_nt->addItem("LArEventBits", m_LArEventBits);
144  if (sc.isFailure()) {
145  ATH_MSG_ERROR( "addItem 'LArEventBits' failed" );
146  return sc;
147  }
148  sc = m_evt_nt->addItem("LArError", m_LArInError);
149  if (sc.isFailure()) {
150  ATH_MSG_ERROR( "addItem 'LArError' failed" );
151  return sc;
152  }
153  //Adding trigger decision bit branches
154  CHECK( m_trigDec.retrieve() );
155  for ( const std::string &tn : m_trigNames ){
156  sc = m_evt_nt->addItem(tn,m_trigNameMap[tn]);
157  if (sc.isFailure()) {
158  ATH_MSG_ERROR( "addItem '"+tn+"' failed" );
159  return sc;
160  }
161  }
162 
163  }//m_fillTType
164 
165  if(m_fillCaloTT) {
166  sc = m_evt_nt->addItem("NTT",m_ntNTT,0,20000);
167  if (sc.isFailure()) {
168  ATH_MSG_ERROR( "addItem 'Net' failed" );
169  return sc;
170  }
171  sc = m_evt_nt->addItem("TTeta", m_ntNTT, m_TTeta);
172  if (sc.isFailure()) {
173  ATH_MSG_ERROR( "addItem 'TTeta' failed" );
174  return sc;
175  }
176  sc = m_evt_nt->addItem("TTphi", m_ntNTT, m_TTphi);
177  if (sc.isFailure()) {
178  ATH_MSG_ERROR( "addItem 'TTphi' failed" );
179  return sc;
180  }
181  sc = m_evt_nt->addItem("TTEem", m_ntNTT, m_TTEem);
182  if (sc.isFailure()) {
183  ATH_MSG_ERROR( "addItem 'TTEem' failed" );
184  return sc;
185  }
186  sc = m_evt_nt->addItem("TTEhad", m_ntNTT, m_TTEhad);
187  if (sc.isFailure()) {
188  ATH_MSG_ERROR( "addItem 'TTEhad' failed" );
189  return sc;
190  }
191  } // end m_fillCaloTT
192 
193  return StatusCode::SUCCESS;
194 
195 }
196 
198 {
199 
200  StatusCode sc;
201 
202  const EventContext& ctx = Gaudi::Hive::currentContext();
203 
205  ATH_CHECK(evt.isValid());
206 
207  unsigned long long thisevent = evt->eventNumber();
208  unsigned short thislb = evt->lumiBlock();
209 
210  // This should be used for main readout later, once TDAQ fill event headers also in calib. runs properly
211  unsigned long thisbcid = evt->bcid();
212  unsigned long thisELVL1Id = 0;
213  unsigned long thisttype = evt->level1TriggerType();
214  //
216  bool hasDigitContainer=true;
217  const LArDigitContainer *DigitContainer = nullptr;
218  if(!m_contKey.key().empty()) {
220  if(!hdlDigit.isValid()) {
221  ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey << " from DetectorStore. " );
222  hasDigitContainer=false;
223  } else {
224  ATH_MSG_DEBUG( "Got LArDigitContainer with key " << m_contKey.key() );
225  DigitContainer = hdlDigit.cptr();
226  }
227  } else hasDigitContainer=false;
228 
229  const LArDigitContainer* DigitContainer_next = nullptr;
230  const LArRawSCContainer* etcontainer = nullptr;
231  const LArRawSCContainer* etcontainer_next = nullptr;
232  const LArRawChannelContainer* RawChannelContainer = nullptr;
233  const LArLATOMEHeaderContainer*headcontainer = nullptr;
234  std::map<unsigned int, const LArLATOMEHeader*> LATOMEHeadMap;
235  rawChanMap_t rawChannelMap;
236 
237  if ((std::find(m_contKeys.begin(), m_contKeys.end(), "LArRawChannels") != m_contKeys.end()) ){
238  sc = evtStore()->retrieve(RawChannelContainer,"LArRawChannels");
239  if (sc.isFailure()) {
240  ATH_MSG_WARNING( "Unable to retrieve LArRawChannelContainer with key LArRawChannels from DetectorStore. " );
241  }
242  else
243  ATH_MSG_DEBUG( "Got LArRawChannelContainer with key LArRawChannels" );
244  }
245 
246  if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ADC_BAS") != m_contKeys.end()) ){
247  sc = evtStore()->retrieve(DigitContainer_next,"SC_ADC_BAS");
248  if (sc.isFailure()) {
249  ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key SC_ADC_BAS from DetectorStore. " );
250  }
251  else
252  ATH_MSG_DEBUG( "Got additional LArDigitContainer with key SC_ADC_BAS " );
253  }
254 
255  if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ET") != m_contKeys.end()) ){
256  sc = evtStore()->retrieve(etcontainer,"SC_ET");
257  if (sc.isFailure()) {
258  ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " );
259  }
260  else
261  ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET " );
262  }
263 
264  if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ET_ID") != m_contKeys.end()) ){
265  sc = evtStore()->retrieve(etcontainer_next,"SC_ET_ID");
266  if (sc.isFailure()) {
267  ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " );
268  }
269  else
270  ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET_ID" );
271  }
272 
274  if (! hdrCont.isValid()) {
275  ATH_MSG_WARNING( "No LArLATOME container found in TDS" );
276  } else {
277  ATH_MSG_DEBUG( "LArLATOME container found");
278  headcontainer=&*hdrCont;
279  thisELVL1Id = (*hdrCont->begin())->L1Id();
280  ATH_MSG_DEBUG( " ELVL1I FROM LATOME HEADER " << thisELVL1Id );
281  }
282 
283  if (headcontainer){// loop through header container and fill map
284  for (const LArLATOMEHeader* hit : *headcontainer) {
285  LATOMEHeadMap.try_emplace ( hit->SourceId(), hit );
286  }
287  }
288  if(m_fillRawChan && RawChannelContainer){
289  for (const LArRawChannel& raw : *RawChannelContainer) {
290  rawChannelMap.try_emplace( raw.channelID(), &raw );
291  }
292  }
293  const LArOnOffIdMapping* cabling=nullptr;
294  const LArOnOffIdMapping* cablingROD=nullptr;
295  if(m_fillRawChan){
297  cabling=*cablingHdl;
298  if(!cabling) {
299  ATH_MSG_ERROR( "Do not have cabling for SC!" );
300  return StatusCode::FAILURE;
301  }
303  cablingROD=*cablingHdlROD;
304  if(!cablingROD) {
305  ATH_MSG_ERROR( "Do not have cabling for ROD!" );
306  return StatusCode::FAILURE;
307  }
308  }
309 
311  if( DigitContainer_next && DigitContainer_next->empty() ) DigitContainer_next = nullptr;
312 
313  if( etcontainer && etcontainer->empty() ) etcontainer = nullptr;
314 
315  if( etcontainer_next && etcontainer_next->empty() ) etcontainer_next = nullptr;
316 
317  int cellsno = 0;
318  if (hasDigitContainer) {
319  if( !DigitContainer->empty() ) cellsno = DigitContainer->size();
320  else {
321  ATH_MSG_WARNING("DigitContainer has zero size, but asked, will be not filled... ");
322  return StatusCode::SUCCESS;
323  }
324  }
325  ATH_MSG_DEBUG("DigitContainer has size: "<<cellsno<<" hasDigitContainer: "<<hasDigitContainer);
326 
327  if (DigitContainer_next){
328  if ( cellsno == 0 ){
329  cellsno = DigitContainer_next->size();
330  }else if(DigitContainer_next->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in DigitContainer_next"<< cellsno << " " << DigitContainer_next->size() );
331  }
332  }
333  if (etcontainer){
334  if ( cellsno == 0 ){
335  cellsno = etcontainer->size();
336  }else if(etcontainer->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in etcontainer"<< cellsno << " " << etcontainer->size() );
337  }
338  }
339  if (etcontainer_next){
340  if ( cellsno == 0 ){
341  cellsno = etcontainer_next->size();
342  }else if(etcontainer_next->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in etcontainer_next"<< cellsno << " " << etcontainer_next->size() );
343  }
344  }
345  unsigned cellCounter = 0;
346  ATH_MSG_DEBUG("cellsno size: "<<cellsno);
347  for( int c = 0;c<cellsno;++c ){
348  if(m_fillBCID) m_bcid = thisbcid;
349 
350  m_ELVL1Id = thisELVL1Id;
351  m_IEvent = thisevent;
352  if(m_overwriteEventNumber) m_IEvent = ctx.evt();
353 
354  if( hasDigitContainer ){
355 
356  const LArDigit* digi = DigitContainer->at(c);
357  // ======================
358 
359  if(m_FTlist.size() > 0) { // should do a selection
360  if(std::find(std::begin(m_FTlist), std::end(m_FTlist), m_FT) == std::end(m_FTlist)) { // is our FT in list ?
361  continue;
362  }
363  }
364 
365  unsigned int trueMaxSample = digi->nsamples();
366 
367  if(trueMaxSample>m_Nsamples){
368  if(!m_ipass){
369  ATH_MSG_DEBUG( "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 " );
370  m_ipass = 1;
371  }
372  trueMaxSample = m_Nsamples;
373  }
374  m_ntNsamples = trueMaxSample;
375 
376  fillFromIdentifier(digi->hardwareID());
377 
378  for(unsigned i = 0; i<trueMaxSample;++i) m_samples[i] = digi->samples().at(i);
379 
380  const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
381  if(!scdigi){
382  ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
383  }else{
384  if (headcontainer){
385  ATH_MSG_DEBUG(" Accessing LATOME header ");
386  const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
387  if(headmap){
388  m_bcidLATOMEHEAD = headmap->BCId();
389  m_ELVL1Id = headmap->L1Id();
390  }
391  }
392  m_latomeChannel = scdigi->Channel();
393  unsigned int trueMaxBcid = trueMaxSample;
394  if(trueMaxBcid > scdigi->BCId().size()) trueMaxBcid=scdigi->BCId().size();
395  for( unsigned i = 0; i<trueMaxBcid; ++i){
396  m_bcidVec[i] = scdigi->BCId().at(i);
397  }
398  m_latomeSourceId = scdigi->SourceId();
399  }
400 
401 
402  if( m_fillRawChan && RawChannelContainer ){
403  fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD);
404  }
405  }//hasDigitContainer
406  ATH_MSG_DEBUG("After hasDigitContainer ");
407 
408 
409  // DigitContainer 1 -> SC_ADC_BAS
410  if( DigitContainer_next ){
411 
412  const LArDigit* digi = DigitContainer_next->at(c);
413 
414  unsigned int trueMaxSample = digi->nsamples();
415 
416  if(trueMaxSample>m_Nsamples){
417  if(!m_ipass){
418  ATH_MSG_DEBUG( "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 " );
419  m_ipass=1;
420  }
421  trueMaxSample = m_Nsamples;
422  }
423  m_ntNsamples = trueMaxSample;
424 
425  if( !hasDigitContainer){
427  if( m_fillRawChan && RawChannelContainer ){
428  fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD);
429  }
430  }
431 
432  for(unsigned i = 0; i<trueMaxSample;++i) m_samples_ADC_BAS[i] = digi->samples().at(i);
433 
434  const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
435  if(!scdigi){ ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
436  }else{
437  if (headcontainer){
438  const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
439  if(headmap){
440  m_bcidLATOMEHEAD = headmap->BCId();
441  m_ELVL1Id = headmap->L1Id();
442  }
443  }
444  m_latomeChannel = scdigi->Channel();
445  for( unsigned i = 0; i<trueMaxSample;++i){
446  m_bcidVec[i] = scdigi->BCId().at(i);
447  }
448  m_latomeSourceId = scdigi->SourceId();
449  }
450 
451  if( !hasDigitContainer && m_fillRawChan && RawChannelContainer ){
452  fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD);
453  }
454  }
455  ATH_MSG_DEBUG("After DigitContainer_next ");
456 
457 
458  // DigitContainer 1 -> SC_ADC_BAS
459  if( DigitContainer_next ){
460 
461  const LArDigit* digi = DigitContainer_next->at(c);
462 
463  unsigned int trueMaxSample = digi->nsamples();
464 
465  if(trueMaxSample>m_Nsamples){
466  if(!m_ipass){
467  ATH_MSG_DEBUG( "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 " );
468  m_ipass=1;
469  }
470  trueMaxSample = m_Nsamples;
471  }
472  m_ntNsamples = trueMaxSample;
473  ATH_MSG_DEBUG("m_ntNsamples: "<<m_ntNsamples);
474 
475  if( !hasDigitContainer){
477  if( m_fillRawChan && RawChannelContainer ){
478  fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD);
479  }
480  }
481 
482  for(unsigned i = 0; i<trueMaxSample;++i) m_samples_ADC_BAS[i] = digi->samples().at(i);
483 
484  const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
485  if(!scdigi){
486  ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
487  }else{
488  if ( !hasDigitContainer){
489  if (headcontainer){
490  const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
491  if(headmap){
492  m_bcidLATOMEHEAD = headmap->BCId();
493  m_ELVL1Id = headmap->L1Id();
494  }
495  }
496  m_latomeChannel = scdigi->Channel();
497  m_latomeSourceId = scdigi->SourceId();
498  }
499 
500  for( unsigned i = 0; i<scdigi->BCId().size();++i){
501  m_bcidVec_ADC_BAS[i] = scdigi->BCId().at(i);
502  }
503  }
504  }//DigitContainer_next
505 
506  // etcontainer -> SC_ET
507  if( etcontainer ){
508  const LArRawSC*rawSC = etcontainer->at(c);
509 
510  if ( !hasDigitContainer && !DigitContainer_next ){
511  fillFromIdentifier(rawSC->hardwareID());
512  m_latomeChannel = rawSC->chan();
513  if (headcontainer){
514  const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
515  if(headmap){
516  m_bcidLATOMEHEAD = headmap->BCId();
517  m_ELVL1Id = headmap->L1Id();
518  }
519  }
520  if( m_fillRawChan && RawChannelContainer ){
521  fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD);
522  }
523  }
524  unsigned int truenet = m_Net;
525  if(truenet > rawSC->bcids().size()) truenet=rawSC->bcids().size();
526  for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
527  m_bcidVec_ET[i] = rawSC->bcids().at(i);
528  }
529  if(truenet > rawSC->energies().size()) truenet=rawSC->energies().size();
530  for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
531  m_energyVec_ET[i] = rawSC->energies().at(i);
532  }
533  if(truenet > rawSC->satur().size()) truenet=rawSC->satur().size();
534  for( unsigned i = 0; i<truenet;++i){ // just use the vector directly?
535  m_saturVec_ET[i] = rawSC->satur().at(i);
536  }
537  m_Net=truenet;
538  m_ntNet=truenet;
539 
540  }
541  // etcontainer_next -> SC_ET_ID
542  if( etcontainer_next ){
543  const LArRawSC*rawSC = etcontainer_next->at(c);
544 
545  if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){
546  fillFromIdentifier(rawSC->hardwareID());
547  m_latomeChannel = rawSC->chan();
548  if (headcontainer){
549  const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
550  if(headmap){
551  m_bcidLATOMEHEAD = headmap->BCId();
552  m_ELVL1Id = headmap->L1Id();
553  }
554  }
555  if( m_fillRawChan && RawChannelContainer ){
556  fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD);
557  }
558  }
559  for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly?
560  m_bcidVec_ET_ID[i] = rawSC->bcids()[i];
561  }
562  for( unsigned i=0; i<rawSC->energies().size();++i){ // just use the vector directly?
563  m_energyVec_ET_ID[i] = rawSC->energies()[i];
564  }
565  for( unsigned i = 0; i<rawSC->satur().size();++i){ // just use the vector directly?
566  m_saturVec_ET_ID[i] = rawSC->satur()[i];
567  }
568  }
569 
570  sc = ntupleSvc()->writeRecord(m_nt);
571  if (sc != StatusCode::SUCCESS) {
572  ATH_MSG_ERROR( "writeRecord failed" );
573  return sc;
574  }
575  cellCounter++;
576  }// over cells
577  if(m_fillTType) {
578  m_TType = thisttype;
579  m_IEventEvt = thisevent;
581  m_LB = thislb;
582 
583  for (auto const & x : m_trigNames) {
584  if( ! m_trigDec->getListOfTriggers(x).empty() ){
585  m_trigNameMap[x] = m_trigDec->isPassedBits( x );
586  }
587  }
588  m_LArEventBits = evt->eventFlags(xAOD::EventInfo::LAr);
589  m_LArInError = 0;
592 
593  }
594  if(m_fillCaloTT){
595  const DataVector<LVL1::TriggerTower>* TTVector = nullptr;
596  if ( evtStore()->retrieve(TTVector,m_triggerTowerKey).isFailure() ) {
597  ATH_MSG_WARNING("Could not get the Calo TTs, will not fill...");
598  } else {
599  unsigned count=0;
600  ATH_MSG_INFO("Got TT vector of the sixe " << TTVector->size());
602  for ( x = TTVector->begin(); x < TTVector->end(); ++x ){
603  m_TTeta[count]=(*x)->eta();
604  m_TTphi[count]=(*x)->phi();
605  m_TTEem[count]=(*x)->emEnergy();
606  m_TTEhad[count]=(*x)->hadEnergy();
607  ++count;
608  if(count==20000) break;
609  }
610  m_ntNTT=count;
611  }
612  }
613 
614  if(m_fillTType || m_fillCaloTT){
615  sc = ntupleSvc()->writeRecord(m_evt_nt);
616  if (sc != StatusCode::SUCCESS) {
617  ATH_MSG_ERROR( "writeRecord failed" );
618  return sc;
619  }
620  }
621 
622  ATH_MSG_DEBUG( "LArSC2Ntuple has finished, filled " << cellCounter << " cells");
623  return StatusCode::SUCCESS;
624 }// end finalize-method.
625 
627 {
628  const Identifier offId = cabling->cnvToIdentifier(SCId);
629  const std::vector<Identifier> cellIds = m_scidtool->superCellToOfflineID(offId);
630  std::fill(m_ROD_energy.begin(), m_ROD_energy.end(), 0.);
631  std::fill(m_ROD_time.begin(), m_ROD_time.end(), 0.);
632  std::fill(m_ROD_id.begin(), m_ROD_id.end(), 0.);
633  for(unsigned i=0; i<cellIds.size(); ++i ) {
634  const HWIdentifier hwcell=cablingROD->createSignalChannelID(cellIds[i]);
635  if (hwcell.is_valid() && (rawChanMap.count(hwcell) != 0) ) {
636  m_ROD_energy[i] = rawChanMap[hwcell]->energy();
637  m_ROD_time[i] = rawChanMap[hwcell]->time();
638  m_ROD_id[i] = rawChanMap[hwcell]->hardwareID().get_identifier32().get_compact();
639  } else {
640  ATH_MSG_DEBUG(i<<"-th cell invalid Id");
641  }
642  }
643 
644 }
LArDigits2Ntuple::m_evt_nt
NTuple::Tuple * m_evt_nt
Definition: LArDigits2Ntuple.h:45
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArRawSC
Liquid Argon SuperCell raw data.
Definition: LArRawSC.h:19
LArSC2Ntuple::m_ROD_time
NTuple::Array< float > m_ROD_time
Definition: LArSC2Ntuple.h:55
LArSC2Ntuple::m_TTphi
NTuple::Array< double > m_TTphi
Definition: LArSC2Ntuple.h:88
LArSC2Ntuple::m_cablingKeyAdditional
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeyAdditional
Definition: LArSC2Ntuple.h:42
LArSC2Ntuple::m_trigNames
Gaudi::Property< std::vector< std::string > > m_trigNames
Definition: LArSC2Ntuple.h:39
LArRawSCContainer.h
LArSC2Ntuple::m_LArLatomeHeaderContainerKey
SG::ReadHandleKey< LArLATOMEHeaderContainer > m_LArLatomeHeaderContainerKey
Definition: LArSC2Ntuple.h:49
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArDigits2Ntuple::m_IEventEvt
NTuple::Item< unsigned long long > m_IEventEvt
Definition: LArDigits2Ntuple.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
LArSC2Ntuple::m_samples_ADC_BAS
NTuple::Array< short > m_samples_ADC_BAS
Definition: LArSC2Ntuple.h:69
FeatureContainer.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArDigits2Ntuple::m_Nsamples
Gaudi::Property< unsigned int > m_Nsamples
Definition: LArDigits2Ntuple.h:29
LArRawSC::SourceId
unsigned int SourceId() const
Definition: LArRawSC.h:95
LArSC2Ntuple::m_bcidLATOMEHEAD
NTuple::Item< uint16_t > m_bcidLATOMEHEAD
Definition: LArSC2Ntuple.h:62
LArDigits2Ntuple::m_fillBCID
Gaudi::Property< bool > m_fillBCID
Definition: LArDigits2Ntuple.h:34
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
LArRawSC::hardwareID
const HWIdentifier & hardwareID() const
Definition: LArRawSC.h:89
LArDigits2Ntuple::m_fillLB
Gaudi::Property< bool > m_fillLB
Definition: LArDigits2Ntuple.h:35
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArLATOMEHeaderContainer.h
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
LArDigit::samples
const std::vector< short > & samples() const
Definition: LArDigit.h:78
LArDigit::hardwareID
const HWIdentifier & hardwareID() const
Definition: LArDigit.h:66
Feature.h
LArSC2Ntuple::m_energyVec_ET_ID
NTuple::Array< int > m_energyVec_ET_ID
Definition: LArSC2Ntuple.h:76
LArDigits2Ntuple::m_IEvent
NTuple::Item< unsigned long long > m_IEvent
Definition: LArDigits2Ntuple.h:41
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
LArSC2Ntuple::m_bcidVec
NTuple::Array< unsigned short > m_bcidVec
Definition: LArSC2Ntuple.h:67
LArLATOMEHeaderContainer
Container class for LArLATOMEHeader.
Definition: LArLATOMEHeaderContainer.h:19
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArSC2Ntuple::rawChanMap_t
std::map< HWIdentifier, const LArRawChannel * > rawChanMap_t
Definition: LArSC2Ntuple.h:28
HWIdentifier
Definition: HWIdentifier.h:13
LArSC2Ntuple::m_ntNet
NTuple::Item< uint32_t > m_ntNet
Definition: LArSC2Ntuple.h:64
LArSCDigit::SourceId
unsigned int SourceId() const
Definition: LArSCDigit.h:45
ChainGroup.h
x
#define x
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
LArDigits2Ntuple::m_ntNsamples
NTuple::Item< long > m_ntNsamples
Definition: LArDigits2Ntuple.h:37
LArDigits2Ntuple::m_ELVL1Id
NTuple::Item< unsigned long > m_ELVL1Id
Definition: LArDigits2Ntuple.h:40
LArRawSC::satur
const std::vector< bool > & satur() const
Definition: LArRawSC.h:107
LArCond2NtupleBase::cablingKey
const SG::ReadCondHandleKey< LArOnOffIdMapping > & cablingKey() const
Definition: LArCond2NtupleBase.cxx:449
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
LArLATOMEHeader::L1Id
uint32_t L1Id() const
get the L1 Id
Definition: LArLATOMEHeader.h:44
LArSC2Ntuple::LArSC2Ntuple
LArSC2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArSC2Ntuple.cxx:13
LArSC2Ntuple::m_saturVec_ET
NTuple::Array< bool > m_saturVec_ET
Definition: LArSC2Ntuple.h:74
LArSC2Ntuple::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: LArSC2Ntuple.h:46
LArDigits2Ntuple::m_event
long m_event
Definition: LArDigits2Ntuple.h:27
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LArSC2Ntuple::m_saturVec_ET_ID
NTuple::Array< bool > m_saturVec_ET_ID
Definition: LArSC2Ntuple.h:78
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
LArDigits2Ntuple::m_FTlist
Gaudi::Property< std::vector< unsigned int > > m_FTlist
Definition: LArDigits2Ntuple.h:30
LArSC2Ntuple::m_TTEhad
NTuple::Array< int > m_TTEhad
Definition: LArSC2Ntuple.h:86
LArDigits2Ntuple::m_bcid
NTuple::Item< short > m_bcid
Definition: LArDigits2Ntuple.h:39
LArSC2Ntuple::m_TTEem
NTuple::Array< int > m_TTEem
Definition: LArSC2Ntuple.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArDigit::nsamples
int nsamples() const
Definition: LArDigit.h:75
LArSC2Ntuple::m_bcidVec_ET_ID
NTuple::Array< unsigned short > m_bcidVec_ET_ID
Definition: LArSC2Ntuple.h:77
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArSC2Ntuple::m_latomeSourceId
NTuple::Item< uint32_t > m_latomeSourceId
Definition: LArSC2Ntuple.h:68
LArRawChannel
Liquid Argon ROD output object base class.
Definition: LArRawChannel.h:40
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
LArSC2Ntuple::m_LArEventBits
NTuple::Item< uint32_t > m_LArEventBits
Definition: LArSC2Ntuple.h:81
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
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArSC2Ntuple::m_fillRawChan
Gaudi::Property< bool > m_fillRawChan
Definition: LArSC2Ntuple.h:37
LArSC2Ntuple::m_fillTType
Gaudi::Property< bool > m_fillTType
Definition: LArSC2Ntuple.h:38
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
LArRawSC::chan
short chan() const
Definition: LArRawSC.h:92
LArSCDigit.h
LArLATOMEHeader::BCId
uint16_t BCId() const
get the Bunch Crossing IDs
Definition: LArLATOMEHeader.h:41
LArSC2Ntuple::m_eventInfoDecorKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: LArSC2Ntuple.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArSC2Ntuple::execute
virtual StatusCode execute() override
Definition: LArSC2Ntuple.cxx:197
LArSC2Ntuple::m_trigDec
ToolHandle< Trig::TrigDecisionTool > m_trigDec
Definition: LArSC2Ntuple.h:44
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
LArSC2Ntuple::m_latomeChannel
NTuple::Item< short > m_latomeChannel
Definition: LArSC2Ntuple.h:52
LArSCDigit::Channel
short Channel() const
Definition: LArSCDigit.h:42
LArSC2Ntuple::m_energyVec_ET
NTuple::Array< int > m_energyVec_ET
Definition: LArSC2Ntuple.h:72
LArSC2Ntuple::m_overwriteEventNumber
Gaudi::Property< bool > m_overwriteEventNumber
Definition: LArSC2Ntuple.h:35
LArSC2Ntuple::m_TType
NTuple::Item< unsigned int > m_TType
Definition: LArSC2Ntuple.h:58
DataVector< LVL1::TriggerTower >
LArSC2Ntuple::fillRODEnergy
void fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping *cabling, const LArOnOffIdMapping *cablingROD)
Definition: LArSC2Ntuple.cxx:626
LArSC2Ntuple::m_bcidVec_ET
NTuple::Array< unsigned short > m_bcidVec_ET
Definition: LArSC2Ntuple.h:73
LArDigits2Ntuple::m_ipass
int m_ipass
Definition: LArDigits2Ntuple.h:26
LArOnOffIdMapping::createSignalChannelID
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Definition: LArOnOffIdMapping.h:126
LArSC2Ntuple::m_contKeys
Gaudi::Property< std::vector< std::string > > m_contKeys
Definition: LArSC2Ntuple.h:34
LArSCDigit
Base class for LArDigits taken by LATOME.
Definition: LArSCDigit.h:19
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArSC2Ntuple::m_ROD_id
NTuple::Array< float > m_ROD_id
Definition: LArSC2Ntuple.h:56
LArSC2Ntuple::m_triggerTowerKey
Gaudi::Property< std::string > m_triggerTowerKey
Definition: LArSC2Ntuple.h:50
LArSC2Ntuple::m_ntNTT
NTuple::Item< uint32_t > m_ntNTT
Definition: LArSC2Ntuple.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArDigits2Ntuple
Definition: LArDigits2Ntuple.h:15
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArDigits2Ntuple::m_contKey
SG::ReadHandleKey< LArDigitContainer > m_contKey
Definition: LArDigits2Ntuple.h:50
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArSC2Ntuple::m_ROD_energy
NTuple::Array< float > m_ROD_energy
Definition: LArSC2Ntuple.h:54
LArRawSC::bcids
const std::vector< unsigned short > & bcids() const
Definition: LArRawSC.h:104
LArSC2Ntuple::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Definition: LArSC2Ntuple.h:43
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
xAOD::EventInfo_v1::Warning
@ Warning
The sub-detector issued a warning.
Definition: EventInfo_v1.h:348
LArLATOMEHeader
Holds information from the LATOME Header.
Definition: LArLATOMEHeader.h:19
LArDigits2Ntuple::initialize
virtual StatusCode initialize()
Definition: LArDigits2Ntuple.cxx:23
lumiFormat.fill
fill
Definition: lumiFormat.py:111
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArCond2NtupleBase.h:55
LArDigits2Ntuple::m_samples
NTuple::Array< short > m_samples
Definition: LArDigits2Ntuple.h:42
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
LArSC2Ntuple::initialize
virtual StatusCode initialize() override
Definition: LArSC2Ntuple.cxx:19
LArSC2Ntuple::m_Net
Gaudi::Property< unsigned int > m_Net
Definition: LArSC2Ntuple.h:36
LArSC2Ntuple::m_bcidVec_ADC_BAS
NTuple::Array< unsigned short > m_bcidVec_ADC_BAS
Definition: LArSC2Ntuple.h:70
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
python.compressB64.c
def c
Definition: compressB64.py:93
LArSCDigit::BCId
const std::vector< unsigned short > & BCId() const
Definition: LArSCDigit.h:48
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArSC2Ntuple::m_LArInError
NTuple::Item< short > m_LArInError
Definition: LArSC2Ntuple.h:82
LArCond2NtupleBase::m_FT
NTuple::Item< long > m_FT
Definition: LArCond2NtupleBase.h:72
LArDigits2Ntuple::m_LB
NTuple::Item< short > m_LB
Definition: LArDigits2Ntuple.h:48
LArSC2Ntuple::m_TTeta
NTuple::Array< double > m_TTeta
Definition: LArSC2Ntuple.h:87
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
LArSC2Ntuple::m_trigNameMap
std::map< std::string, NTuple::Item< unsigned int > > m_trigNameMap
Definition: LArSC2Ntuple.h:80
LArSC2Ntuple.h
LArSC2Ntuple::m_fillCaloTT
Gaudi::Property< bool > m_fillCaloTT
Definition: LArSC2Ntuple.h:40
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
LArRawChannelContainer
Container for LArRawChannel (IDC using LArRawChannelCollection)
Definition: LArRawChannelContainer.h:26
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
LArRawSC::energies
const std::vector< int > & energies() const
Definition: LArRawSC.h:101