ATLAS Offline Software
Loading...
Searching...
No Matches
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#include <numeric>
14
15LArSC2Ntuple::LArSC2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
16 LArDigits2Ntuple(name, pSvcLocator), m_caloMgrSC(nullptr) {
17 m_ntTitle = "SCDigits";
18 m_ntpath = "/NTUPLES/FILE1/SCDIGITS";
19 }
20
22
23 ATH_MSG_DEBUG( "LArSC2Ntuple in initialize" );
24
25 m_isSC = true;
26 if(m_fillTType && (! m_fillLB)) m_fillLB = true;
27 if(m_fillCaloTT && (! m_fillLB)) m_fillLB = true;
28
30 ATH_CHECK( m_scidtool.retrieve() );
31
33 ATH_CHECK( m_eventInfoKey.initialize() );
34 ATH_CHECK( m_eventInfoDecorKey.initialize() );
35
37
38 ATH_CHECK( m_caloSCMgrKey.initialize(m_ETThresh > 0. || m_ETThreshMain > 0.) );
39
40 StatusCode sc=m_nt->addItem("latomeChannel",m_latomeChannel);
41 if (sc.isFailure()) {
42 ATH_MSG_ERROR( "addItem 'latomeChannel' failed" );
43 return sc;
44 }
45
46 sc = m_nt->addItem("bcidVec",m_Nsamples, m_bcidVec);//here - > define length?
47 if (sc.isFailure()) {
48 ATH_MSG_ERROR( "addItem 'bcidVec' failed" );
49 return sc;
50 }
51 sc = m_nt->addItem("latomeSourceId",m_latomeSourceId);
52 if (sc.isFailure()) {
53 ATH_MSG_ERROR( "addItem 'latomeSourceId' failed" );
54 return sc;
55 }
56 sc = m_nt->addItem("Net",m_ntNet);
57 if (sc.isFailure()) {
58 ATH_MSG_ERROR( "addItem 'Net' failed" );
59 return sc;
60 }
61
62 // Loop over container keys
63 for ( const std::string &ck : m_contKeys ){
64 if ( ck.find("SC") == std::string::npos){ // main readout only
65 if ( m_fillRawChan && ck == "LArRawChannels" ){
66 sc = m_nt->addItem("ROD_energy", 16, m_ROD_energy);
67 if (sc.isFailure()) {
68 ATH_MSG_ERROR( "addItem 'ROD_energy' failed" );
69 return sc;
70 }
71 sc = m_nt->addItem("ROD_time", 16, m_ROD_time);
72 if (sc.isFailure()) {
73 ATH_MSG_ERROR( "addItem 'ROD_time' failed" );
74 return sc;
75 }
76 sc = m_nt->addItem("ROD_id", 16, m_ROD_id);
77 if (sc.isFailure()) {
78 ATH_MSG_ERROR( "addItem 'ROD_id' failed" );
79 return sc;
80 }
81 }
82
83 }else if ( ck == "SC_ADC_BAS" ){ // SC_ADC_BAS DigitContainer
84 sc = m_nt->addItem("samples_ADC_BAS",m_Nsamples,m_samples_ADC_BAS);
85 if (sc.isFailure()) {
86 ATH_MSG_ERROR( "addItem 'samples_ADC_BAS' failed" );
87 return sc;
88 }
89
90 sc = m_nt->addItem("bcidVec_ADC_BAS",m_Nsamples, m_bcidVec_ADC_BAS);//here - > define length?
91 if (sc.isFailure()) {
92 ATH_MSG_ERROR( "addItem 'bcidVec_ADC_BAS' failed" );
93 return sc;
94 }
95
96 }else if ( ck == "SC_ET" ){ // SC_ET RawSCContainer
97 sc = m_nt->addItem("energyVec_ET", m_Net, m_energyVec_ET);
98 if (sc.isFailure()) {
99 ATH_MSG_ERROR( "addItem 'energyVec_ET' failed" );
100 return sc;
101 }
102 sc = m_nt->addItem("bcidVec_ET", m_Net, m_bcidVec_ET);
103 if (sc.isFailure()) {
104 ATH_MSG_ERROR( "addItem 'bcidVec_ET' failed" );
105 return sc;
106 }
107 sc = m_nt->addItem("saturVec_ET", m_Net, m_saturVec_ET);
108 if (sc.isFailure()) {
109 ATH_MSG_ERROR( "addItem 'saturVec_ET' failed" );
110 return sc;
111 }
112
113 }else if ( ck == "SC_ET_ID" ){ // SC_ET_ID RawSCContainer
114
115 sc = m_nt->addItem("energyVec_ET_ID", m_Net, m_energyVec_ET_ID);
116 if (sc.isFailure()) {
117 ATH_MSG_ERROR( "addItem 'energyVec_ET_ID' failed" );
118 return sc;
119 }
120 sc = m_nt->addItem("bcidVec_ET_ID", m_Net, m_bcidVec_ET_ID);
121 if (sc.isFailure()) {
122 ATH_MSG_ERROR( "addItem 'bcidVec_ET_ID' failed" );
123 return sc;
124 }
125 sc = m_nt->addItem("saturVec_ET_ID", m_Net, m_saturVec_ET_ID);
126 if (sc.isFailure()) {
127 ATH_MSG_ERROR( "addItem 'saturVec_ET_ID' failed" );
128 return sc;
129 }
130 }
131
132 }// end container key loop
133
134 sc = m_nt->addItem("bcidLATOMEHEAD",m_bcidLATOMEHEAD);
135 if (sc.isFailure()) {
136 ATH_MSG_ERROR( "addItem 'bcidLATOMEHEAD' failed" );
137 return sc;
138 }
139
140 if(m_fillTType) {
141 sc = m_evt_nt->addItem("TType", m_TType);
142 if (sc.isFailure()) {
143 ATH_MSG_ERROR( "addItem 'TType' failed" );
144 return sc;
145 }
146
147 sc = m_evt_nt->addItem("LArEventBits", m_LArEventBits);
148 if (sc.isFailure()) {
149 ATH_MSG_ERROR( "addItem 'LArEventBits' failed" );
150 return sc;
151 }
152 sc = m_evt_nt->addItem("LArError", m_LArInError);
153 if (sc.isFailure()) {
154 ATH_MSG_ERROR( "addItem 'LArError' failed" );
155 return sc;
156 }
157 //Adding trigger decision bit branches
158 CHECK( m_trigDec.retrieve() );
159 for ( const std::string &tn : m_trigNames ){
160 sc = m_evt_nt->addItem(tn,m_trigNameMap[tn]);
161 if (sc.isFailure()) {
162 ATH_MSG_ERROR( "addItem '"+tn+"' failed" );
163 return sc;
164 }
165 }
166
167 }//m_fillTType
168
169 if(m_fillCaloTT) {
170 sc = m_evt_nt->addItem("NTT",m_ntNTT,0,20000);
171 if (sc.isFailure()) {
172 ATH_MSG_ERROR( "addItem 'Net' failed" );
173 return sc;
174 }
175 sc = m_evt_nt->addItem("TTeta", m_ntNTT, m_TTeta);
176 if (sc.isFailure()) {
177 ATH_MSG_ERROR( "addItem 'TTeta' failed" );
178 return sc;
179 }
180 sc = m_evt_nt->addItem("TTphi", m_ntNTT, m_TTphi);
181 if (sc.isFailure()) {
182 ATH_MSG_ERROR( "addItem 'TTphi' failed" );
183 return sc;
184 }
185 sc = m_evt_nt->addItem("TTEem", m_ntNTT, m_TTEem);
186 if (sc.isFailure()) {
187 ATH_MSG_ERROR( "addItem 'TTEem' failed" );
188 return sc;
189 }
190 sc = m_evt_nt->addItem("TTEhad", m_ntNTT, m_TTEhad);
191 if (sc.isFailure()) {
192 ATH_MSG_ERROR( "addItem 'TTEhad' failed" );
193 return sc;
194 }
195 } // end m_fillCaloTT
196
197 return StatusCode::SUCCESS;
198
199}
200
202{
203
204 StatusCode sc;
205
206 const EventContext& ctx = Gaudi::Hive::currentContext();
207
209 ATH_CHECK(evt.isValid());
210
211 unsigned long long thisevent = evt->eventNumber();
212 unsigned short thislb = evt->lumiBlock();
213
214 // This should be used for main readout later, once TDAQ fill event headers also in calib. runs properly
215 unsigned long thisbcid = evt->bcid();
216 unsigned long thisELVL1Id = 0;
217 unsigned long thisttype = evt->level1TriggerType();
218 //
220 bool hasDigitContainer=true;
221 const LArDigitContainer *DigitContainer = nullptr;
222 if(!m_contKey.key().empty()) {
224 if(!hdlDigit.isValid()) {
225 ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey << " from DetectorStore. " );
226 hasDigitContainer=false;
227 } else {
228 ATH_MSG_DEBUG( "Got LArDigitContainer with key " << m_contKey.key() );
229 DigitContainer = hdlDigit.cptr();
230 }
231 } else hasDigitContainer=false;
232
233 bool hasAccCalibDigitContainer=true;
234 const LArAccumulatedCalibDigitContainer *AccCalibDigitContainer = nullptr;
235 if(!m_accCalibContKey.key().empty()) {
237 if(!hdlAccDigit.isValid()) {
238 ATH_MSG_WARNING( "Unable to retrieve LArAccumulatedCalibDigitContainer with key " << m_accCalibContKey << " from DetectorStore. " );
239 hasAccCalibDigitContainer=false;
240 } else {
241 ATH_MSG_DEBUG( "Got LArAccumulatedCalibDigitContainer with key " << m_accCalibContKey.key() );
242 AccCalibDigitContainer = hdlAccDigit.cptr();
243 }
244 } else hasAccCalibDigitContainer=false;
245
246 bool hasAccDigitContainer=true;
247 const LArAccumulatedDigitContainer *AccDigitContainer = nullptr;
248 if(!m_accContKey.key().empty()) {
250 if(!hdlAccDigit.isValid()) {
251 ATH_MSG_WARNING( "Unable to retrieve LArAccumulatedDigitContainer with key " << m_accContKey << " from DetectorStore. " );
252 hasAccDigitContainer=false;
253 } else {
254 ATH_MSG_DEBUG( "Got LArAccumulatedDigitContainer with key " << m_accContKey.key() );
255 AccDigitContainer = hdlAccDigit.cptr();
256 }
257 } else hasAccDigitContainer=false;
258
259 const LArDigitContainer* DigitContainer_next = nullptr;
260 const LArRawSCContainer* etcontainer = nullptr;
261 const LArRawSCContainer* etcontainer_next = nullptr;
262 const LArRawChannelContainer* RawChannelContainer = nullptr;
263 const LArLATOMEHeaderContainer*headcontainer = nullptr;
264 std::map<unsigned int, const LArLATOMEHeader*> LATOMEHeadMap;
265 rawChanMap_t rawChannelMap;
266
267 if ((std::find(m_contKeys.begin(), m_contKeys.end(), "LArRawChannels") != m_contKeys.end()) ){
268 sc = evtStore()->retrieve(RawChannelContainer,"LArRawChannels");
269 if (sc.isFailure()) {
270 ATH_MSG_WARNING( "Unable to retrieve LArRawChannelContainer with key LArRawChannels from DetectorStore. " );
271 }
272 else
273 ATH_MSG_DEBUG( "Got LArRawChannelContainer with key LArRawChannels" );
274 }
275
276 if(m_ETThreshMain > 0. && !RawChannelContainer) {
277 ATH_MSG_WARNING( "Asked for ETThresholdMain, but no LArRawChannelContainer, will not apply ! " );
278 m_ETThreshMain = -1.;
279 }
280
281 if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ADC_BAS") != m_contKeys.end()) ){
282 sc = evtStore()->retrieve(DigitContainer_next,"SC_ADC_BAS");
283 if (sc.isFailure()) {
284 ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key SC_ADC_BAS from DetectorStore. " );
285 }
286 else
287 ATH_MSG_DEBUG( "Got additional LArDigitContainer with key SC_ADC_BAS " );
288 }
289
290 if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ET") != m_contKeys.end()) ){
291 sc = evtStore()->retrieve(etcontainer,"SC_ET");
292 if (sc.isFailure()) {
293 ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " );
294 }
295 else
296 ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET " );
297 }
298
299 if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ET_ID") != m_contKeys.end()) ){
300 sc = evtStore()->retrieve(etcontainer_next,"SC_ET_ID");
301 if (sc.isFailure()) {
302 ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " );
303 }
304 else
305 ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET_ID" );
306 }
307
309 if (! hdrCont.isValid()) {
310 ATH_MSG_WARNING( "No LArLATOME container found in TDS" );
311 } else {
312 ATH_MSG_DEBUG( "LArLATOME container found");
313 headcontainer=&*hdrCont;
314 if(headcontainer != nullptr && *hdrCont->begin()) thisELVL1Id = (*hdrCont->begin())->L1Id();
315 ATH_MSG_DEBUG( " ELVL1I FROM LATOME HEADER " << thisELVL1Id );
316 }
317
318 if (headcontainer){// loop through header container and fill map
319 for (const LArLATOMEHeader* hit : *headcontainer) {
320 LATOMEHeadMap.try_emplace ( hit->SourceId(), hit );
321 }
322 }
323 if(m_fillRawChan && RawChannelContainer){
324 for (const LArRawChannel& raw : *RawChannelContainer) {
325 rawChannelMap.try_emplace( raw.channelID(), &raw );
326 }
327 }
328 const LArOnOffIdMapping* cabling=nullptr;
329 const LArOnOffIdMapping* cablingROD=nullptr;
330 if(m_fillRawChan){
332 cabling=*cablingHdl;
333 if(!cabling) {
334 ATH_MSG_ERROR( "Do not have cabling for SC!" );
335 return StatusCode::FAILURE;
336 }
338 cablingROD=*cablingHdlROD;
339 if(!cablingROD) {
340 ATH_MSG_ERROR( "Do not have cabling for ROD!" );
341 return StatusCode::FAILURE;
342 }
343 }
344
346 if( DigitContainer_next && DigitContainer_next->empty() ) DigitContainer_next = nullptr;
347
348 if( etcontainer && etcontainer->empty() ) etcontainer = nullptr;
349
350 if( etcontainer_next && etcontainer_next->empty() ) etcontainer_next = nullptr;
351
352 int cellsno = 0;
353 if (hasDigitContainer) {
354 if( !DigitContainer->empty() ) cellsno = DigitContainer->size();
355 else {
356 ATH_MSG_WARNING("DigitContainer has zero size, but asked, will be not filled... ");
357 return StatusCode::SUCCESS;
358 }
359 }
360 ATH_MSG_DEBUG("DigitContainer has size: "<<cellsno<<" hasDigitContainer: "<<hasDigitContainer);
361
362 if(m_ETThresh > 0. && !etcontainer && !etcontainer_next) {
363 ATH_MSG_WARNING( "Asked for ETThreshold, but no SC_ET* container, will not apply ! " );
364 m_ETThresh = -1.;
365 }
366
367 if(m_ETThresh > 0. || m_ETThreshMain > 0.) {
369 ATH_CHECK(caloMgrHandle.isValid());
370 m_caloMgrSC = *caloMgrHandle;
371 }
372
373 if(m_ADCThresh > 0. && ! DigitContainer&& !DigitContainer_next) {
374 ATH_MSG_WARNING( "Asked for ADCThreshold, but no digits container, will not apply ! " );
375 m_ADCThresh = -1.;
376 }
377
378 if (hasAccCalibDigitContainer) {
379 if( !AccCalibDigitContainer->empty() ) {
380 cellsno = AccCalibDigitContainer->size();
381 ATH_MSG_DEBUG("AccCalibDigitContainer has size: "<<cellsno<<" hasAccCalibDigitContainer: "<<hasAccCalibDigitContainer);
382 } else {
383 ATH_MSG_WARNING("AccCalibDigitContainer has zero size, but asked, will be not filled... ");
384 return StatusCode::SUCCESS;
385 }
386 }
387 if (hasAccDigitContainer) {
388 if( !AccDigitContainer->empty() ) {
389 cellsno = AccDigitContainer->size();
390 ATH_MSG_DEBUG("AccDigitContainer has size: "<<cellsno<<" hasAccDigitContainer: "<<hasAccDigitContainer);
391 } else {
392 ATH_MSG_WARNING("AccDigitContainer has zero size, but asked, will be not filled... ");
393 return StatusCode::SUCCESS;
394 }
395 }
396
397 if (DigitContainer_next){
398 if ( cellsno == 0 ){
399 cellsno = DigitContainer_next->size();
400 }else if(DigitContainer_next->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in DigitContainer_next"<< cellsno << " " << DigitContainer_next->size() );
401 }
402 }
403 if (etcontainer){
404 if ( cellsno == 0 ){
405 cellsno = etcontainer->size();
406 }else if(etcontainer->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in etcontainer"<< cellsno << " " << etcontainer->size() );
407 }
408 }
409 if (etcontainer_next){
410 if ( cellsno == 0 ){
411 cellsno = etcontainer_next->size();
412 }else if(etcontainer_next->size() != (unsigned)cellsno ){ ATH_MSG_ERROR(" NOOOOOOO! Different number of entries in etcontainer_next"<< cellsno << " " << etcontainer_next->size() );
413 }
414 }
415 unsigned cellCounter = 0;
416 ATH_MSG_DEBUG("cellsno size: "<<cellsno);
417
418 for( int c = 0;c<cellsno;++c ){
419 if(m_fillBCID) m_bcid = thisbcid;
420
421 m_ELVL1Id = thisELVL1Id;
422 m_IEvent = thisevent;
423 if(m_overwriteEventNumber) m_IEvent = ctx.evt();
424
425 bool acceptETMain = true;
426
427 if( hasAccDigitContainer ){
428
429 const LArAccumulatedDigit* digi = AccDigitContainer->at(c);
430 // ======================
431
432
433 unsigned int trueMaxSample = digi->nsample();
434
435 if(trueMaxSample>m_Nsamples){
436 if(!m_ipass){
437 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 " );
438 m_ipass = 1;
439 }
440 trueMaxSample = m_Nsamples;
441 }
442 m_ntNsamples = trueMaxSample;
443
445
446 float adcmax=-1.;
447 for(unsigned i = 0; i<trueMaxSample;++i) {
448 m_mean[i] = digi->mean(i);
449 m_RMS[i] = digi->RMS(i);
450 if(m_ADCThresh > 0 && m_mean[i]>adcmax) adcmax=m_mean[i];
451 }
452 if(m_ADCThresh > 0 && adcmax-m_mean[0] <= m_ADCThresh) continue;
453
454 }//hasAccDigitContainer
455
456 if( hasAccCalibDigitContainer ){
457
458 const LArAccumulatedCalibDigit* digi = AccCalibDigitContainer->at(c);
459 // ======================
460
461
462 unsigned int trueMaxSample = digi->nsamples();
463
464 if(trueMaxSample>m_Nsamples){
465 if(!m_ipass){
466 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 " );
467 m_ipass = 1;
468 }
469 trueMaxSample = m_Nsamples;
470 }
471 m_ntNsamples = trueMaxSample;
472
474
475 float adcmax=-1.;
476 for(unsigned i = 0; i<trueMaxSample;++i) {
477 m_mean[i] = digi->mean(i);
478 m_RMS[i] = digi->RMS(i);
479 if(m_ADCThresh > 0 && m_mean[i]>adcmax) adcmax=m_mean[i];
480 }
481 if(m_ADCThresh > 0 && adcmax-m_mean[0] <= m_ADCThresh) continue;
482 m_dac = digi->DAC();
483 m_delay = digi->delay();
484 m_pulsed = digi->getIsPulsedInt();
485
486 }//hasAccCalibDigitContainer
487
488 if( hasDigitContainer ){
489
490 const LArDigit* digi = DigitContainer->at(c);
491 // ======================
492
493 unsigned int trueMaxSample = digi->nsamples();
494
495 if(trueMaxSample>m_Nsamples){
496 if(!m_ipass){
497 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 " );
498 m_ipass = 1;
499 }
500 trueMaxSample = m_Nsamples;
501 }
502 m_ntNsamples = trueMaxSample;
503
505
506 if(m_FTlist.size() > 0) { // should do a selection
507 if(std::find(std::begin(m_FTlist), std::end(m_FTlist), m_FT) == std::end(m_FTlist)) { // is our FT in list ?
508 continue;
509 }
510 }
511
512 if( m_fillRawChan && RawChannelContainer ){
513 fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
514 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
515 }
516
517 short adcmax=0;
518 for(unsigned i = 0; i<trueMaxSample;++i) {
519 m_samples[i] = digi->samples().at(i);
520 if(m_ADCThresh > 0 && m_samples[i]>adcmax) adcmax=m_samples[i];
521 }
522 if(m_ADCThresh > 0 && adcmax-m_samples[0] <= m_ADCThresh) continue;
523
524 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
525 if(!scdigi){
526 ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
527 }else{
528 if (headcontainer){
529 ATH_MSG_DEBUG(" Accessing LATOME header ");
530 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
531 if(headmap){
532 m_bcidLATOMEHEAD = headmap->BCId();
533 m_ELVL1Id = headmap->L1Id();
534 }
535 }
536 m_latomeChannel = scdigi->Channel();
537 unsigned int trueMaxBcid = trueMaxSample;
538 if(trueMaxBcid > scdigi->BCId().size()) trueMaxBcid=scdigi->BCId().size();
539 for( unsigned i = 0; i<trueMaxBcid; ++i){
540 m_bcidVec[i] = scdigi->BCId().at(i);
541 }
542 m_latomeSourceId = scdigi->SourceId();
543 }
544
545
546 }//hasDigitContainer
547 ATH_MSG_DEBUG("After hasDigitContainer ");
548
549
550 // DigitContainer 1 -> SC_ADC_BAS
551 if( DigitContainer_next ){
552
553 const LArDigit* digi = DigitContainer_next->at(c);
554
555 unsigned int trueMaxSample = digi->nsamples();
556
557 if(trueMaxSample>m_Nsamples){
558 if(!m_ipass){
559 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 " );
560 m_ipass=1;
561 }
562 trueMaxSample = m_Nsamples;
563 }
564 m_ntNsamples = trueMaxSample;
565
566 if( !hasDigitContainer){
568 if( m_fillRawChan && RawChannelContainer ){
569 fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
570 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
571 }
572 }
573
574 short adcmax=0;
575 for(unsigned i = 0; i<trueMaxSample;++i) {
576 m_samples_ADC_BAS[i] = digi->samples().at(i);
577 if(m_ADCThresh > 0 && m_samples_ADC_BAS[i]>adcmax) adcmax=m_samples_ADC_BAS[i];
578 }
579 if(m_ADCThresh > 0 && adcmax-m_samples_ADC_BAS[0] <= m_ADCThresh) continue;
580
581 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
582 if(!scdigi){ ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
583 }else{
584 if (headcontainer){
585 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
586 if(headmap){
587 m_bcidLATOMEHEAD = headmap->BCId();
588 m_ELVL1Id = headmap->L1Id();
589 }
590 }
591 m_latomeChannel = scdigi->Channel();
592 for( unsigned i = 0; i<trueMaxSample;++i){
593 m_bcidVec[i] = scdigi->BCId().at(i);
594 }
595 m_latomeSourceId = scdigi->SourceId();
596 }
597
598 }
599 ATH_MSG_DEBUG("After DigitContainer_next ");
600
601
602
603 // etcontainer -> SC_ET
604 if( etcontainer ){
605 const LArRawSC*rawSC = etcontainer->at(c);
606
607 if ( !hasDigitContainer && !DigitContainer_next ){
609 m_latomeChannel = rawSC->chan();
610 if (headcontainer){
611 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
612 if(headmap){
613 m_bcidLATOMEHEAD = headmap->BCId();
614 m_ELVL1Id = headmap->L1Id();
615 }
616 }
617 if( m_fillRawChan && RawChannelContainer ){
618 fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
619 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
620 }
621 }
622 unsigned int truenet = m_Net;
623 if(truenet > rawSC->bcids().size()) truenet=rawSC->bcids().size();
624 for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
625 m_bcidVec_ET[i] = rawSC->bcids().at(i);
626 }
627 if(truenet > rawSC->energies().size()) truenet=rawSC->energies().size();
628 unsigned i;
629 for( i=0; i<truenet;++i){ // just use the vector directly?
630 m_energyVec_ET[i] = rawSC->energies().at(i);
631 if(rawSC->bcids().size()) {
632 if(m_ETThresh > 0. && m_bcidVec_ET[i] == thisbcid) { // our ET
633 if(m_energyVec_ET[i] < m_ETThresh) break;
634 }
635 } else {
636 if(m_ETThresh > 0. ) { // our ET
637 if(m_energyVec_ET[i] < m_ETThresh) break;
638 }
639 }
640 }
641 if(i<truenet) continue; // energy cut
642
643 if(truenet > rawSC->satur().size()) truenet=rawSC->satur().size();
644 for( unsigned i = 0; i<truenet;++i){ // just use the vector directly?
645 m_saturVec_ET[i] = rawSC->satur().at(i);
646 }
647 m_Net=truenet;
648 m_ntNet=truenet;
649
650 }
651 ATH_MSG_DEBUG("After etcontainer");
652 // etcontainer_next -> SC_ET_ID
653 if( etcontainer_next ){
654 const LArRawSC*rawSC = etcontainer_next->at(c);
655
656 if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){
658 m_latomeChannel = rawSC->chan();
659 if (headcontainer){
660 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
661 if(headmap){
662 m_bcidLATOMEHEAD = headmap->BCId();
663 m_ELVL1Id = headmap->L1Id();
664 }
665 }
666 if( m_fillRawChan && RawChannelContainer ){
667 fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
668 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
669 }
670 }
671 ATH_MSG_DEBUG("Mid etcontainer_next "<<c);
672 for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly?
673 m_bcidVec_ET_ID[i] = rawSC->bcids()[i];
674 }
675 unsigned i;
676 for( i=0; i<rawSC->energies().size();++i){ // just use the vector directly?
677 m_energyVec_ET_ID[i] = rawSC->energies()[i];
678 if(rawSC->bcids().size()) {
679 if(m_ETThresh > 0. && m_bcidVec_ET_ID[i] == thisbcid) { // our ET
680 if(m_energyVec_ET_ID[i] < m_ETThresh) break;
681 }
682 } else {
683 if(m_ETThresh > 0.) { // our ET
684 if(m_energyVec_ET_ID[i] < m_ETThresh) break;
685 }
686 }
687 }
688 if(i<rawSC->energies().size()) {
689 continue; // energy cut
690 }
691
692 for( unsigned i = 0; i<rawSC->satur().size();++i){ // just use the vector directly?
693 m_saturVec_ET_ID[i] = rawSC->satur()[i];
694 }
695 }
696 ATH_MSG_DEBUG("After etcontainer_next");
697
698 sc = ntupleSvc()->writeRecord(m_nt);
699 if (sc != StatusCode::SUCCESS) {
700 ATH_MSG_ERROR( "writeRecord failed" );
701 return sc;
702 }
703 cellCounter++;
704 }// over cells
705
706 if(m_fillTType) {
707 m_TType = thisttype;
708 m_IEventEvt = thisevent;
710 m_LB = thislb;
711
712 for (auto const & x : m_trigNames) {
713 if( ! m_trigDec->getListOfTriggers(x).empty() ){
714 m_trigNameMap[x] = m_trigDec->isPassedBits( x );
715 }
716 }
717 m_LArEventBits = evt->eventFlags(xAOD::EventInfo::LAr);
718 m_LArInError = 0;
721
722 }
723
724 if(m_fillCaloTT){
725 const DataVector<LVL1::TriggerTower>* TTVector = nullptr;
726 if ( evtStore()->retrieve(TTVector,m_triggerTowerKey).isFailure() ) {
727 ATH_MSG_WARNING("Could not get the Calo TTs, will not fill...");
728 } else {
729 unsigned count=0;
730 ATH_MSG_INFO("Got TT vector of the sixe " << TTVector->size());
732 for ( x = TTVector->begin(); x < TTVector->end(); ++x ){
733 m_TTeta[count]=(*x)->eta();
734 m_TTphi[count]=(*x)->phi();
735 m_TTEem[count]=(*x)->emEnergy();
736 m_TTEhad[count]=(*x)->hadEnergy();
737 ++count;
738 if(count==20000) break;
739 }
741 }
742 }
743
745 sc = ntupleSvc()->writeRecord(m_evt_nt);
746 if (sc != StatusCode::SUCCESS) {
747 ATH_MSG_ERROR( "writeRecord failed" );
748 return sc;
749 }
750 }
751
752 ATH_MSG_DEBUG( "LArSC2Ntuple has finished, filled " << cellCounter << " cells");
753 return StatusCode::SUCCESS;
754}// end execute-method.
755
756void LArSC2Ntuple::fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping* cabling, const LArOnOffIdMapping* cablingROD, bool &acceptETMain)
757{
758 const Identifier offId = cabling->cnvToIdentifier(SCId);
759 const std::vector<Identifier> cellIds = m_scidtool->superCellToOfflineID(offId);
760 std::fill(m_ROD_energy.begin(), m_ROD_energy.end(), 0.);
761 std::fill(m_ROD_time.begin(), m_ROD_time.end(), 0.);
762 std::fill(m_ROD_id.begin(), m_ROD_id.end(), 0.);
763 for(unsigned i=0; i<cellIds.size(); ++i ) {
764 const HWIdentifier hwcell=cablingROD->createSignalChannelID(cellIds[i]);
765 if (hwcell.is_valid() && (rawChanMap.count(hwcell) != 0) ) {
766 m_ROD_energy[i] = rawChanMap[hwcell]->energy();
767 m_ROD_time[i] = rawChanMap[hwcell]->time();
768 m_ROD_id[i] = rawChanMap[hwcell]->hardwareID().get_identifier32().get_compact();
769 } else {
770 ATH_MSG_DEBUG(i<<"-th cell invalid Id");
771 }
772 }
773 if(acceptETMain && m_ETThreshMain > 0. && m_caloMgrSC) { // check if cell is above threshold
774 auto result = std::reduce(m_ROD_energy.begin(), m_ROD_energy.end());
775 auto dde = m_caloMgrSC->get_element(offId);
776 if(dde && result / cosh(dde->eta()) < m_ETThreshMain) acceptETMain = false;
777 }
778}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sc
INTupleSvc * ntupleSvc()
#define x
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const T * at(size_type n) const
Access an element, as an rvalue.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
bool is_valid() const
Check if id is in a valid state.
Container class for LArAccumulatedCalibDigit.
Data class for calibration ADC samples preprocessed by the DSP.
int delay() const
return the setting of the delay
const HWIdentifier & hardwareID() const
Return HWIdentifier.
uint16_t getIsPulsedInt() const
get the four bit int that tells which lines pulsed
int DAC() const
return the number of samples
std::vector< float > RMS() const
Calculates and returns the RMS value of each ADC sample.
std::vector< float > mean() const
Calculates and returns the Mean value of each ADC sample.
size_t nsamples() const
return number of samples
Container class for LArAccumulatedDigit.
Data class for ADC samples and autocorr preprocessed by the DSP.
const HWIdentifier & hardwareID() const
Return HWIdentifier.
float RMS(int n_min=-1, int n_max=-1) const
Calculates and returns the RMS value of ADC samples.
float mean(int n_min=-1, int n_max=-1) const
Calculates and returns the Mean value of ADC samples.
int nsample() const
return number of samples
Gaudi::Property< bool > m_isSC
const SG::ReadCondHandleKey< LArOnOffIdMapping > & cablingKey() const
NTuple::Item< long > m_FT
bool fillFromIdentifier(const HWIdentifier &id)
Container class for LArDigit.
Liquid Argon digit base class.
Definition LArDigit.h:25
const HWIdentifier & hardwareID() const
Definition LArDigit.h:66
int nsamples() const
Definition LArDigit.h:75
const std::vector< short > & samples() const
Definition LArDigit.h:78
NTuple::Array< short > m_samples
Gaudi::Property< bool > m_fillLB
Gaudi::Property< bool > m_fillBCID
NTuple::Item< unsigned int > m_delay
SG::ReadHandleKey< LArDigitContainer > m_contKey
NTuple::Array< float > m_RMS
NTuple::Item< short > m_LB
LArDigits2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
NTuple::Array< float > m_mean
Gaudi::Property< std::vector< unsigned int > > m_FTlist
Gaudi::Property< unsigned int > m_Nsamples
NTuple::Item< long > m_ntNsamples
NTuple::Item< short > m_bcid
NTuple::Item< unsigned long long > m_IEvent
SG::ReadHandleKey< LArAccumulatedDigitContainer > m_accContKey
NTuple::Item< unsigned long > m_ELVL1Id
virtual StatusCode initialize()
NTuple::Item< unsigned int > m_pulsed
NTuple::Tuple * m_evt_nt
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_accCalibContKey
NTuple::Item< unsigned long long > m_IEventEvt
NTuple::Item< unsigned int > m_dac
Container class for LArLATOMEHeader.
Holds information from the LATOME Header.
uint32_t L1Id() const
get the L1 Id
uint16_t BCId() const
get the Bunch Crossing IDs
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Container for LArRawChannel (IDC using LArRawChannelCollection)
Liquid Argon ROD output object base class.
Container class for LArRawSC.
Liquid Argon SuperCell raw data.
Definition LArRawSC.h:19
unsigned int SourceId() const
Definition LArRawSC.h:95
short chan() const
Definition LArRawSC.h:92
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
const HWIdentifier & hardwareID() const
Definition LArRawSC.h:89
NTuple::Array< bool > m_saturVec_ET_ID
Gaudi::Property< float > m_ETThresh
NTuple::Array< int > m_energyVec_ET_ID
std::map< std::string, NTuple::Item< unsigned int > > m_trigNameMap
NTuple::Array< bool > m_saturVec_ET
std::map< HWIdentifier, const LArRawChannel * > rawChanMap_t
NTuple::Array< unsigned short > m_bcidVec_ET
Gaudi::Property< std::string > m_triggerTowerKey
Gaudi::Property< bool > m_fillRawChan
Gaudi::Property< bool > m_fillTType
NTuple::Array< short > m_samples_ADC_BAS
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
NTuple::Array< unsigned short > m_bcidVec
virtual StatusCode execute() override
Gaudi::Property< std::vector< std::string > > m_contKeys
void fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping *cabling, const LArOnOffIdMapping *cablingROD, bool &acceptMain)
NTuple::Item< uint32_t > m_latomeSourceId
NTuple::Array< unsigned short > m_bcidVec_ADC_BAS
Gaudi::Property< float > m_ETThreshMain
NTuple::Item< short > m_LArInError
NTuple::Array< int > m_TTEem
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSCMgrKey
NTuple::Item< uint32_t > m_ntNTT
Gaudi::Property< float > m_ADCThresh
Gaudi::Property< bool > m_fillCaloTT
Gaudi::Property< std::vector< std::string > > m_trigNames
NTuple::Item< unsigned int > m_TType
ToolHandle< ICaloSuperCellIDTool > m_scidtool
NTuple::Array< double > m_TTeta
NTuple::Array< float > m_ROD_id
SG::ReadHandleKey< LArLATOMEHeaderContainer > m_LArLatomeHeaderContainerKey
NTuple::Array< unsigned short > m_bcidVec_ET_ID
Gaudi::Property< bool > m_overwriteEventNumber
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< unsigned int > m_Net
NTuple::Item< uint32_t > m_LArEventBits
NTuple::Array< double > m_TTphi
const CaloSuperCellDetDescrManager * m_caloMgrSC
NTuple::Array< int > m_TTEhad
NTuple::Array< float > m_ROD_energy
NTuple::Item< short > m_latomeChannel
NTuple::Array< int > m_energyVec_ET
NTuple::Item< uint32_t > m_ntNet
NTuple::Array< float > m_ROD_time
LArSC2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeyAdditional
ToolHandle< Trig::TrigDecisionTool > m_trigDec
virtual StatusCode initialize() override
NTuple::Item< uint16_t > m_bcidLATOMEHEAD
Base class for LArDigits taken by LATOME.
Definition LArSCDigit.h:19
unsigned int SourceId() const
Definition LArSCDigit.h:45
const std::vector< unsigned short > & BCId() const
Definition LArSCDigit.h:48
short Channel() const
Definition LArSCDigit.h:42
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
@ LAr
The LAr calorimeter.
@ Warning
The sub-detector issued a warning.
@ Error
The sub-detector issued an error.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146