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_WARNING(" NOOOOOOO! Different number of entries in DigitContainer_next"<< cellsno << " " << DigitContainer_next->size() );
401 return StatusCode::SUCCESS;
402 }
403 }
404 if (etcontainer){
405 if ( cellsno == 0 ){
406 cellsno = etcontainer->size();
407 }else if(etcontainer->size() != (unsigned)cellsno ){ ATH_MSG_WARNING(" NOOOOOOO! Different number of entries in etcontainer"<< cellsno << " " << etcontainer->size() );
408 return StatusCode::SUCCESS;
409 }
410 }
411 if (etcontainer_next){
412 if ( cellsno == 0 ){
413 cellsno = etcontainer_next->size();
414 }else if(etcontainer_next->size() != (unsigned)cellsno ){ ATH_MSG_WARNING(" NOOOOOOO! Different number of entries in etcontainer_next"<< cellsno << " " << etcontainer_next->size() );
415 return StatusCode::SUCCESS;
416 }
417 }
418 unsigned cellCounter = 0;
419 ATH_MSG_DEBUG("cellsno size: "<<cellsno);
420
421 for( int c = 0;c<cellsno;++c ){
422 if(m_fillBCID) m_bcid = thisbcid;
423
424 m_ELVL1Id = thisELVL1Id;
425 m_IEvent = thisevent;
426 if(m_overwriteEventNumber) m_IEvent = ctx.evt();
427
428 bool acceptETMain = true;
429
430 if( hasAccDigitContainer ){
431
432 const LArAccumulatedDigit* digi = AccDigitContainer->at(c);
433 // ======================
434
435
436 unsigned int trueMaxSample = digi->nsample();
437
438 if(trueMaxSample>m_Nsamples){
439 if(!m_ipass){
440 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 " );
441 m_ipass = 1;
442 }
443 trueMaxSample = m_Nsamples;
444 }
445 m_ntNsamples = trueMaxSample;
446
448
449 float adcmax=-1.;
450 for(unsigned i = 0; i<trueMaxSample;++i) {
451 m_mean[i] = digi->mean(i);
452 m_RMS[i] = digi->RMS(i);
453 if(m_ADCThresh > 0 && m_mean[i]>adcmax) adcmax=m_mean[i];
454 }
455 if(m_ADCThresh > 0 && adcmax-m_mean[0] <= m_ADCThresh) continue;
456
457 }//hasAccDigitContainer
458
459 if( hasAccCalibDigitContainer ){
460
461 const LArAccumulatedCalibDigit* digi = AccCalibDigitContainer->at(c);
462 // ======================
463
464
465 unsigned int trueMaxSample = digi->nsamples();
466
467 if(trueMaxSample>m_Nsamples){
468 if(!m_ipass){
469 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 " );
470 m_ipass = 1;
471 }
472 trueMaxSample = m_Nsamples;
473 }
474 m_ntNsamples = trueMaxSample;
475
477
478 float adcmax=-1.;
479 for(unsigned i = 0; i<trueMaxSample;++i) {
480 m_mean[i] = digi->mean(i);
481 m_RMS[i] = digi->RMS(i);
482 if(m_ADCThresh > 0 && m_mean[i]>adcmax) adcmax=m_mean[i];
483 }
484 if(m_ADCThresh > 0 && adcmax-m_mean[0] <= m_ADCThresh) continue;
485 m_dac = digi->DAC();
486 m_delay = digi->delay();
487 m_pulsed = digi->getIsPulsedInt();
488
489 }//hasAccCalibDigitContainer
490
491 if( hasDigitContainer ){
492
493 const LArDigit* digi = DigitContainer->at(c);
494 // ======================
495
496 unsigned int trueMaxSample = digi->nsamples();
497
498 if(trueMaxSample>m_Nsamples){
499 if(!m_ipass){
500 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 " );
501 m_ipass = 1;
502 }
503 trueMaxSample = m_Nsamples;
504 }
505 m_ntNsamples = trueMaxSample;
506
508
509 if(m_FTlist.size() > 0) { // should do a selection
510 if(std::find(std::begin(m_FTlist), std::end(m_FTlist), m_FT) == std::end(m_FTlist)) { // is our FT in list ?
511 continue;
512 }
513 }
514
515 if( m_fillRawChan && RawChannelContainer ){
516 fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
517 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
518 }
519
520 short adcmax=0;
521 for(unsigned i = 0; i<trueMaxSample;++i) {
522 m_samples[i] = digi->samples().at(i);
523 if(m_ADCThresh > 0 && m_samples[i]>adcmax) adcmax=m_samples[i];
524 }
525 if(m_ADCThresh > 0 && adcmax-m_samples[0] <= m_ADCThresh) continue;
526
527 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
528 if(!scdigi){
529 ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
530 }else{
531 if (headcontainer){
532 ATH_MSG_DEBUG(" Accessing LATOME header ");
533 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
534 if(headmap){
535 m_bcidLATOMEHEAD = headmap->BCId();
536 m_ELVL1Id = headmap->L1Id();
537 }
538 }
539 m_latomeChannel = scdigi->Channel();
540 unsigned int trueMaxBcid = trueMaxSample;
541 if(trueMaxBcid > scdigi->BCId().size()) trueMaxBcid=scdigi->BCId().size();
542 for( unsigned i = 0; i<trueMaxBcid; ++i){
543 m_bcidVec[i] = scdigi->BCId().at(i);
544 }
545 m_latomeSourceId = scdigi->SourceId();
546 }
547
548
549 }//hasDigitContainer
550 ATH_MSG_DEBUG("After hasDigitContainer ");
551
552
553 // DigitContainer 1 -> SC_ADC_BAS
554 if( DigitContainer_next ){
555
556 const LArDigit* digi = DigitContainer_next->at(c);
557
558 unsigned int trueMaxSample = digi->nsamples();
559
560 if(trueMaxSample>m_Nsamples){
561 if(!m_ipass){
562 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 " );
563 m_ipass=1;
564 }
565 trueMaxSample = m_Nsamples;
566 }
567 m_ntNsamples = trueMaxSample;
568
569 if( !hasDigitContainer){
571 if( m_fillRawChan && RawChannelContainer ){
572 fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
573 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
574 }
575 }
576
577 short adcmax=0;
578 for(unsigned i = 0; i<trueMaxSample;++i) {
579 m_samples_ADC_BAS[i] = digi->samples().at(i);
580 if(m_ADCThresh > 0 && m_samples_ADC_BAS[i]>adcmax) adcmax=m_samples_ADC_BAS[i];
581 }
582 if(m_ADCThresh > 0 && adcmax-m_samples_ADC_BAS[0] <= m_ADCThresh) continue;
583
584 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
585 if(!scdigi){ ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*");
586 }else{
587 if (headcontainer){
588 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()];
589 if(headmap){
590 m_bcidLATOMEHEAD = headmap->BCId();
591 m_ELVL1Id = headmap->L1Id();
592 }
593 }
594 m_latomeChannel = scdigi->Channel();
595 for( unsigned i = 0; i<trueMaxSample;++i){
596 m_bcidVec[i] = scdigi->BCId().at(i);
597 }
598 m_latomeSourceId = scdigi->SourceId();
599 }
600
601 }
602 ATH_MSG_DEBUG("After DigitContainer_next ");
603
604
605
606 // etcontainer -> SC_ET
607 if( etcontainer ){
608 const LArRawSC*rawSC = etcontainer->at(c);
609
610 if ( !hasDigitContainer && !DigitContainer_next ){
612 m_latomeChannel = rawSC->chan();
613 if (headcontainer){
614 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
615 if(headmap){
616 m_bcidLATOMEHEAD = headmap->BCId();
617 m_ELVL1Id = headmap->L1Id();
618 }
619 }
620 if( m_fillRawChan && RawChannelContainer ){
621 fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
622 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
623 }
624 }
625 unsigned int truenet = m_Net;
626 if(truenet > rawSC->bcids().size()) truenet=rawSC->bcids().size();
627 for( unsigned i=0; i<truenet;++i){ // just use the vector directly?
628 m_bcidVec_ET[i] = rawSC->bcids().at(i);
629 }
630 if(truenet > rawSC->energies().size()) truenet=rawSC->energies().size();
631 unsigned i;
632 for( i=0; i<truenet;++i){ // just use the vector directly?
633 m_energyVec_ET[i] = rawSC->energies().at(i);
634 if(rawSC->bcids().size()) {
635 if(m_ETThresh > 0. && m_bcidVec_ET[i] == thisbcid) { // our ET
636 if(m_energyVec_ET[i] < m_ETThresh) break;
637 }
638 } else {
639 if(m_ETThresh > 0. ) { // our ET
640 if(m_energyVec_ET[i] < m_ETThresh) break;
641 }
642 }
643 }
644 if(i<truenet) continue; // energy cut
645
646 if(truenet > rawSC->satur().size()) truenet=rawSC->satur().size();
647 for( unsigned i = 0; i<truenet;++i){ // just use the vector directly?
648 m_saturVec_ET[i] = rawSC->satur().at(i);
649 }
650 m_Net=truenet;
651 m_ntNet=truenet;
652
653 }
654 ATH_MSG_DEBUG("After etcontainer");
655 // etcontainer_next -> SC_ET_ID
656 if( etcontainer_next ){
657 const LArRawSC*rawSC = etcontainer_next->at(c);
658
659 if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){
661 m_latomeChannel = rawSC->chan();
662 if (headcontainer){
663 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()];
664 if(headmap){
665 m_bcidLATOMEHEAD = headmap->BCId();
666 m_ELVL1Id = headmap->L1Id();
667 }
668 }
669 if( m_fillRawChan && RawChannelContainer ){
670 fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD, acceptETMain);
671 if(!acceptETMain) continue; // do not pass the ETThreshMain cut
672 }
673 }
674 ATH_MSG_DEBUG("Mid etcontainer_next "<<c);
675 for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly?
676 m_bcidVec_ET_ID[i] = rawSC->bcids()[i];
677 }
678 unsigned i;
679 for( i=0; i<rawSC->energies().size();++i){ // just use the vector directly?
680 m_energyVec_ET_ID[i] = rawSC->energies()[i];
681 if(rawSC->bcids().size()) {
682 if(m_ETThresh > 0. && m_bcidVec_ET_ID[i] == thisbcid) { // our ET
683 if(m_energyVec_ET_ID[i] < m_ETThresh) break;
684 }
685 } else {
686 if(m_ETThresh > 0.) { // our ET
687 if(m_energyVec_ET_ID[i] < m_ETThresh) break;
688 }
689 }
690 }
691 if(i<rawSC->energies().size()) {
692 continue; // energy cut
693 }
694
695 for( unsigned i = 0; i<rawSC->satur().size();++i){ // just use the vector directly?
696 m_saturVec_ET_ID[i] = rawSC->satur()[i];
697 }
698 }
699 ATH_MSG_DEBUG("After etcontainer_next");
700
701 sc = ntupleSvc()->writeRecord(m_nt);
702 if (sc != StatusCode::SUCCESS) {
703 ATH_MSG_ERROR( "writeRecord failed" );
704 return sc;
705 }
706 cellCounter++;
707 }// over cells
708
709 if(m_fillTType) {
710 m_TType = thisttype;
711 m_IEventEvt = thisevent;
713 m_LB = thislb;
714
715 for (auto const & x : m_trigNames) {
716 if( ! m_trigDec->getListOfTriggers(x).empty() ){
717 m_trigNameMap[x] = m_trigDec->isPassedBits( x );
718 }
719 }
720 m_LArEventBits = evt->eventFlags(xAOD::EventInfo::LAr);
721 m_LArInError = 0;
724
725 }
726
727 if(m_fillCaloTT){
728 const DataVector<LVL1::TriggerTower>* TTVector = nullptr;
729 if ( evtStore()->retrieve(TTVector,m_triggerTowerKey).isFailure() ) {
730 ATH_MSG_WARNING("Could not get the Calo TTs, will not fill...");
731 } else {
732 unsigned count=0;
733 ATH_MSG_INFO("Got TT vector of the sixe " << TTVector->size());
735 for ( x = TTVector->begin(); x < TTVector->end(); ++x ){
736 m_TTeta[count]=(*x)->eta();
737 m_TTphi[count]=(*x)->phi();
738 m_TTEem[count]=(*x)->emEnergy();
739 m_TTEhad[count]=(*x)->hadEnergy();
740 ++count;
741 if(count==20000) break;
742 }
744 }
745 }
746
748 sc = ntupleSvc()->writeRecord(m_evt_nt);
749 if (sc != StatusCode::SUCCESS) {
750 ATH_MSG_ERROR( "writeRecord failed" );
751 return sc;
752 }
753 }
754
755 ATH_MSG_DEBUG( "LArSC2Ntuple has finished, filled " << cellCounter << " cells");
756 return StatusCode::SUCCESS;
757}// end execute-method.
758
759void LArSC2Ntuple::fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping* cabling, const LArOnOffIdMapping* cablingROD, bool &acceptETMain)
760{
761 const Identifier offId = cabling->cnvToIdentifier(SCId);
762 const std::vector<Identifier> cellIds = m_scidtool->superCellToOfflineID(offId);
763 std::fill(m_ROD_energy.begin(), m_ROD_energy.end(), 0.);
764 std::fill(m_ROD_time.begin(), m_ROD_time.end(), 0.);
765 std::fill(m_ROD_id.begin(), m_ROD_id.end(), 0.);
766 for(unsigned i=0; i<cellIds.size(); ++i ) {
767 const HWIdentifier hwcell=cablingROD->createSignalChannelID(cellIds[i]);
768 if (hwcell.is_valid() && (rawChanMap.count(hwcell) != 0) ) {
769 m_ROD_energy[i] = rawChanMap[hwcell]->energy();
770 m_ROD_time[i] = rawChanMap[hwcell]->time();
771 m_ROD_id[i] = rawChanMap[hwcell]->hardwareID().get_identifier32().get_compact();
772 } else {
773 ATH_MSG_DEBUG(i<<"-th cell invalid Id");
774 }
775 }
776 if(acceptETMain && m_ETThreshMain > 0. && m_caloMgrSC) { // check if cell is above threshold
777 auto result = std::reduce(m_ROD_energy.begin(), m_ROD_energy.end());
778 auto dde = m_caloMgrSC->get_element(offId);
779 if(dde && result / cosh(dde->eta()) < m_ETThreshMain) acceptETMain = false;
780 }
781}
#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.
bool hit(const std::valarray< int > &ids, int pdgId)
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:21
unsigned int SourceId() const
Definition LArSCDigit.h:47
const std::vector< unsigned short > & BCId() const
Definition LArSCDigit.h:50
short Channel() const
Definition LArSCDigit.h:44
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