ATLAS Offline Software
Loading...
Searching...
No Matches
TileTBAANtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileTBAANtuple.cxx
7// Author : Luca Fiorini
8// Created : Mar, 2007
9//
10// DESCRIPTION:
11// Implement the algorithm to save TB Beam ROD dataX
12//
13// HISTORY:
14//
15// BUGS:
16//
17//*****************************************************************************
18
19//Gaudi Includes
20//#include "GaudiKernel/ITHistSvc.h"
21
22//Event info
24
27
28#include <cmath>
29
30//Calo includes
33
34//TileCalo includes
43
44#include <fstream>
45#include <sstream>
46
47#define WRONG_SAMPLE(frag,chan,size) \
48msg(MSG::ERROR) << "Wrong no. of samples (" << size \
49 << ") for channel " << chan \
50 << " in frag 0x"<<MSG::hex << frag << MSG::dec \
51 << " - " << BeamFragName[frag&0x1F] << endmsg;
52
53#define WRONG_CHANNEL(frag,chan) \
54msg(MSG::ERROR) << "Wrong channel " << chan \
55 << " in frag 0x"<<MSG::hex << frag << MSG::dec \
56 << " - " << BeamFragName[frag&0x1F] << endmsg;
57
58#define FRAG_FOUND(frag,chan,size) \
59if (msgLvl(MSG::DEBUG)) \
60 msg(MSG::DEBUG) << "Found channel " << chan \
61 << " in frag 0x"<<MSG::hex << frag << MSG::dec \
62 << " - " << BeamFragName[frag&0x1F] \
63 << " of size " << size << endmsg;
64
65
66#define SIGNAL_FOUND(frag,chan,amplitude) \
67if (msgLvl(MSG::DEBUG)) \
68 msg(MSG::DEBUG) << "Found channel " << chan \
69 << " in frag 0x"<<MSG::hex << frag << MSG::dec \
70 << " - " << BeamFragName[frag&0x1F] \
71 << " with amp=" << amplitude << endmsg;
72
73#define MAX_DRAWERS 256
74#define N_CHANS 48
75#define N_DMUS 16
76
77// Constructor & deconstructor
81
82TileTBAANtuple::TileTBAANtuple(const std::string& name, ISvcLocator* pSvcLocator)
83 : AthAlgorithm(name, pSvcLocator)
84 , m_thistSvc("THistSvc", name)
85 , m_rchUnit(TileRawChannelUnit::MegaElectronVolts)
86 , m_dspUnit(TileRawChannelUnit::ADCcounts)
87{
88
89 char frg[6] = "0x000";
90 m_beamFragList.clear();
91 for (unsigned int i=0; i<sizeof(m_beamIdList)/sizeof(bool); ++i) {
92 m_beamIdList[i] = false;
93 // no coins trig by default (this is the case for 2004)
94 if (i <= ECAL_ADC_FRAG || i >= COMMON_ADC1_FRAG ) {
95 sprintf(frg,"0x%3.3x",i);
96 m_beamFragList.value().push_back((std::string)frg);
97 }
98 }
99
100}
101
105
120
121 ATH_CHECK( m_tileToolEmscale.retrieve() );
122 ATH_CHECK( m_adderFilterAlgTool.retrieve(EnableTool{m_unpackAdder}) );
123
125
126 return StatusCode::SUCCESS;
127}
128
135StatusCode TileTBAANtuple::ntuple_initialize(const EventContext& ctx) {
136
137 CHECK( m_thistSvc.retrieve() );
138
139 // find TileCablingService
141
142 // retrieve TileID helper from det store
143
144 CHECK( detStore()->retrieve(m_tileID) );
145
146 CHECK( detStore()->retrieve(m_tileHWID) );
147
148 if (m_nSamples < 0) {
149 m_nSamples = 7;
150 }
151 if (m_nSamplesFlx < 0) {
153 }
154
155 if (m_TBperiod >= 2015) {
156 m_unpackAdder = false;
157
158 if (m_TBperiod == 2015) {
159 m_nDrawers = 2;
160 m_drawerList.value().resize(m_nDrawers);
161 m_drawerType.value().resize(m_nDrawers);
162 m_drawerList[0] = "0x200"; m_drawerType[0] = 2; // barrel neg
163 m_drawerList[1] = "0x401"; m_drawerType[1] = 4; // ext.barrel neg
164 } else if (m_TBperiod == 2016 || m_TBperiod == 2018 || m_TBperiod == 2021 || m_TBperiod == 2022) {
165 m_nDrawers = 5;
166 m_drawerList.value().resize(m_nDrawers); m_drawerType.value().resize(m_nDrawers);
167 m_drawerList[0] = "0x100"; m_drawerType[0] = 1; // M0 pos
168 m_drawerList[1] = "0x101"; m_drawerType[1] = 1; // barrel pos
169 m_drawerList[2] = "0x200"; m_drawerType[2] = 2; // M0 neg
170 m_drawerList[3] = "0x201"; m_drawerType[3] = 2; // barrel neg
171 m_drawerList[4] = "0x402"; m_drawerType[4] = 4; // ext.barrel neg
172 } else if (m_TBperiod == 2017) {
173 m_nDrawers = 6;
174 m_drawerList.value().resize(m_nDrawers); m_drawerType.value().resize(m_nDrawers);
175 m_drawerList[0] = "0x100"; m_drawerType[0] = 1; // M0 pos
176 m_drawerList[1] = "0x101"; m_drawerType[1] = 1; // barrel pos
177 m_drawerList[2] = "0x200"; m_drawerType[2] = 2; // M0 neg
178 m_drawerList[3] = "0x201"; m_drawerType[3] = 2; // barrel neg
179 m_drawerList[4] = "0x203"; m_drawerType[4] = 2; // barrel neg
180 m_drawerList[5] = "0x402"; m_drawerType[5] = 4; // ext.barrel neg
181 } else if (m_TBperiod == 2019) {
182 m_nDrawers = 7;
183 m_drawerList.value().resize(m_nDrawers); m_drawerType.value().resize(m_nDrawers);
184 m_drawerList[0] = "0x100"; m_drawerType[0] = 1; // M0 pos
185 m_drawerList[1] = "0x101"; m_drawerType[1] = 1; // barrel pos
186 m_drawerList[2] = "0x200"; m_drawerType[2] = 2; // M0 neg
187 m_drawerList[3] = "0x201"; m_drawerType[3] = 2; // barrel neg
188 m_drawerList[4] = "0x203"; m_drawerType[4] = 2; // barrel neg
189 m_drawerList[5] = "0x402"; m_drawerType[5] = 4; // ext.barrel neg
190 m_drawerList[6] = "0x405"; m_drawerType[6] = 4; // ext.barrel neg
191 }
192
193 if (m_TBperiod < 2016) {
195 } else if (m_TBperiod < 2021) {
197 } else {
198 // Strating from 2021 the following properties should be setup via JO
207
216 }
217
218 } else {
220 }
221
222
223 if (m_unpackAdder) {
224 // get TileRawChannelBuilderFlatFilter for adder energy calculation
225
226 StatusCode sc;
227 sc &= m_adderFilterAlgTool->setProperty("TileRawChannelContainer", "TileAdderFlat");
228 sc &= m_adderFilterAlgTool->setProperty("calibrateEnergy", "true");
229
230 sc &= m_adderFilterAlgTool->setProperty("PedStart", "0");
231 sc &= m_adderFilterAlgTool->setProperty("PedLength", "1");
232 sc &= m_adderFilterAlgTool->setProperty("PedOffset", "0");
233 sc &= m_adderFilterAlgTool->setProperty("SignalStart", "1");
234 sc &= m_adderFilterAlgTool->setProperty("SignalLength", "15");
235 sc &= m_adderFilterAlgTool->setProperty("FilterLength", "5");
236 sc &= m_adderFilterAlgTool->setProperty("FrameLength", "16");
237 sc &= m_adderFilterAlgTool->setProperty("DeltaCutLo", "9.5");
238 sc &= m_adderFilterAlgTool->setProperty("DeltaCutHi", "9.5");
239 sc &= m_adderFilterAlgTool->setProperty("RMSCutLo", "1.0");
240 sc &= m_adderFilterAlgTool->setProperty("RMSCutHi", "1.0");
241 if (sc.isFailure()) {
242 ATH_MSG_ERROR("Failure setting properties of " << m_adderFilterAlgTool);
243 return StatusCode::FAILURE;
244 }
245 }
246
249
250 m_finalUnit = -1;
252 m_useDspUnits = true;
253 ATH_MSG_INFO( "Final offline units are not set, will use DSP units" );
254 }
255 }
256
257 if (!m_calibrateEnergy) {
258 if (m_useDspUnits) {
259 ATH_MSG_INFO( "calibrateEnergy is disabled, don't want to use DSP units" );
260 m_useDspUnits = false;
261 }
262 }
263
264 ATH_MSG_INFO( "TestBeam period " << m_TBperiod.value() );
265 ATH_MSG_INFO( "calibMode " << m_calibMode.value() );
266 ATH_MSG_INFO( "calibrateEnergy " << m_calibrateEnergy.value() );
267 ATH_MSG_INFO( "offlineUnits " << m_finalUnit.value() );
268 ATH_MSG_INFO( "useDspUnits " << m_useDspUnits.value() );
269 ATH_MSG_INFO( "number of samples " << m_nSamples.value() );
270
271
272 msg(MSG::INFO) << "drawerList " << MSG::hex;
273 unsigned int size = m_drawerList.size();
274 for (unsigned int dr = 0; dr < size; ++dr) {
275 int frag = strtol(m_drawerList[dr].data(), NULL, 0);
276 if (frag >= 0) {
277 m_drawerMap[frag] = dr;
278 if (dr == m_drawerType.size()) m_drawerType.value().push_back(frag >> 8);
279 msg(MSG::INFO) << " 0x" << frag;
280 } else {
281 msg(MSG::INFO) << " " << m_drawerList[dr];
282 // put negative number in first element (flag to read frag ID from data)
283 m_drawerList[0] = m_drawerList[dr];
284 m_drawerList.value().resize(1);
285 // m_drawerType.clear();
286 m_drawerMap.clear();
287 size = 0;
288 break;
289 }
290 }
291 if (size == 0) {
292 if (m_drawerList.size() > 0)
293 msg(MSG::INFO) << " - negative number, will read frag IDs from the data" << MSG::dec << endmsg;
294 else
295 msg(MSG::INFO) << "is empty, no drawer fragments in ntuple" << MSG::dec << endmsg;
296 } else {
297 msg(MSG::INFO) << MSG::dec << endmsg;
298
299 size = m_drawerType.size();
300 if (size < m_nDrawers) {
301 m_drawerType.value().resize(m_nDrawers);
302 for (; size < m_nDrawers; ++size)
303 m_drawerType[size] = 0;
304 }
305
306 msg(MSG::INFO) << MSG::INFO << "drawerType ";
307 for (unsigned int dr = 0; dr < size; ++dr)
308 msg(MSG::INFO) << " " << m_drawerType[dr];
309 msg(MSG::INFO) << endmsg;
310
311 if (size > m_nDrawers) {
312 ATH_MSG_INFO( "increasing m_nDrawers from " << m_nDrawers << " to " << size );
313 m_nDrawers = size;
314 }
315 }
316
317 msg(MSG::INFO) << MSG::INFO << "Beam Frag List " << MSG::hex;
318 size = m_beamFragList.size();
319 for (unsigned int dr = 0; dr < size; ++dr) {
320 int frag = strtol(m_beamFragList[dr].data(), NULL, 0);
321 if (frag >= 0) {
322 m_beamIdList[frag & 0x1F] = true;
323 msg(MSG::INFO) << " 0x" << frag;
324 }
325 }
326 if (size == 0) {
327 msg(MSG::INFO) << "is empty, no beam fragments in ntuple" << MSG::dec << endmsg;
328 } else {
329 msg(MSG::INFO) << MSG::dec << endmsg;
330 }
331
332 // set event number to 0 before first event
333 m_evtNr = 0;
335
336 // find event and beam ROD header, calib mode for digitizers
337
341 if (m_evtNr == 0) {
342 if (m_unpackAdder) // in 2003 event number starts from 1
343 ++m_evtNr;
344 }
345
346 if (initList(ctx).isFailure()) {
347 ATH_MSG_ERROR( " Error during drawer list initialization" );
348 }
349
350 if (m_saveFelixData && initListFlx(ctx).isFailure()) {
351 ATH_MSG_ERROR( " Error during drawer list initialization" );
352 }
353
354 if (initNTuple().isFailure()) {
355 ATH_MSG_ERROR( " Error during ntuple initialization" );
356 }
357
358 ATH_MSG_INFO( "initialization completed" );
359 return StatusCode::SUCCESS;
360}
361
363
364 const EventContext& ctx = Gaudi::Hive::currentContext();
365 const TileDQstatus* dqStatus = (!m_dqStatusKey.empty()) ? SG::makeHandle(m_dqStatusKey, ctx).get() : nullptr;
366
367 if (m_evtNr < 0) {
368
369 //bool calibMode = (m_beamInfo->calibMode() == 1);
370 //if ( calibMode != m_calibMode ) {
371 // ATH_MSG_INFO( "Calib mode from data is " << calibMode );
372 // ATH_MSG_INFO( " Overwriting calib mode " );
373 // m_calibMode = calibMode;
374 //}
375
376 if (ntuple_initialize(ctx).isFailure()) {
377 ATH_MSG_ERROR( "ntuple_initialize failed" );
378 }
379
380 }
381
382 m_dspFlags = 0;
383 if (ntuple_clear().isFailure()) {
384 ATH_MSG_ERROR( "ntuple_clear failed" );
385 }
386
387 if (m_evtNr % 1000 == 0)
388 ATH_MSG_INFO( m_evtNr << " events processed so far" );
389
390 m_run = ctx.eventID().run_number();
391 m_evt = ctx.eventID().event_number();
392
393 //Get timestamp of the event
394 if (ctx.eventID().time_stamp() > 0) {
395 m_evTime = ctx.eventID().time_stamp();
396 }
397
398 // store BeamElements
399 bool empty = storeBeamElements(ctx).isFailure();
400
401 //store Laser Object
402 empty &= storeLaser(ctx).isFailure();
403
404 if (m_drawerMap.size() > 0) {
405
406 // store TileDigits
407 if (m_nSamples > 0) {
408 empty &= (storeDigits(ctx, m_digitsContainerKey, dqStatus).isFailure());
409 }
410 if (m_nSamplesFlx > 0) {
411 empty &= (storeDigitsFlx(ctx, m_digitsContainerFlxKey).isFailure());
412 }
413
414 // store TileRawChannels
415 // start from DSP channels - so we can find out what is the DSP units
423
424 empty &= (storeHitVector(ctx).isFailure());
425 empty &= (storeHitContainer(ctx).isFailure());
426 }
427
428
429 if (m_completeNtuple && m_TBperiod < 2015) {
430 // store energy per sampling from all calorimeters
431 empty &= (storeCells(ctx).isFailure());
432 }
433
434 // increase event nr
435 // this number can be different from real event number if we skip events
436
437 if (empty) {
438 ATH_MSG_WARNING( "Error in execute " );
439 }
440
441 m_ntuplePtr->Fill();
442
443 ++m_evtNr;
444
445 // Execution completed.
446 ATH_MSG_DEBUG( "execute() completed successfully" );
447
448 return StatusCode::SUCCESS;
449}
450
451//
452// Here the LASER object is opened and corresponding variable are stored
453//
454
455
456StatusCode TileTBAANtuple::storeLaser(const EventContext& ctx) {
457
458 if (m_laserObjectKey.empty()) { // empty name, nothing to do
459 return StatusCode::FAILURE;
460 }
461
462 // Read Hit Vector from TDS
463 const TileLaserObject* laserObj = SG::makeHandle (m_laserObjectKey, ctx).get();
464
465 m_las_BCID = laserObj->getBCID();
466
467 m_las_Filt = laserObj->getFiltNumber();
468 m_las_ReqAmp = laserObj->getDiodeCurrOrd();
469 m_las_MeasAmp = laserObj->getDiodeCurrMeas();
470
471
472 m_las_D1_ADC = laserObj->getDiodeADC(0);
473 m_las_D2_ADC = laserObj->getDiodeADC(1);
474 m_las_D3_ADC = laserObj->getDiodeADC(2);
475 m_las_D4_ADC = laserObj->getDiodeADC(3);
476
477 m_las_D1_Ped = laserObj->getDiodePedestal(0);
478 m_las_D2_Ped = laserObj->getDiodePedestal(1);
479 m_las_D3_Ped = laserObj->getDiodePedestal(2);
480 m_las_D4_Ped = laserObj->getDiodePedestal(3);
481
486
487 m_las_D1_Alpha = laserObj->getAlpha(0);
488 m_las_D2_Alpha = laserObj->getAlpha(1);
489 m_las_D3_Alpha = laserObj->getAlpha(2);
490 m_las_D4_Alpha = laserObj->getAlpha(3);
491
492 m_las_D1_Alpha_RMS = laserObj->getSigmaAlpha(0);
493 m_las_D2_Alpha_RMS = laserObj->getSigmaAlpha(1);
494 m_las_D3_Alpha_RMS = laserObj->getSigmaAlpha(2);
495 m_las_D4_Alpha_RMS = laserObj->getSigmaAlpha(3);
496
497 m_las_D1_AlphaPed = laserObj->getPedestalAlpha(0);
498 m_las_D2_AlphaPed = laserObj->getPedestalAlpha(1);
499 m_las_D3_AlphaPed = laserObj->getPedestalAlpha(2);
500 m_las_D4_AlphaPed = laserObj->getPedestalAlpha(3);
501
506
507 m_las_PMT1_ADC = laserObj->getPMADC(0);
508 m_las_PMT2_ADC = laserObj->getPMADC(1);
509
510 m_las_PMT1_TDC = laserObj->getTDC(0);
511 m_las_PMT2_TDC = laserObj->getTDC(1);
512
513 m_las_PMT1_Ped = laserObj->getPMPedestal(0);
514 m_las_PMT2_Ped = laserObj->getPMPedestal(1);
515
518
520
521 ATH_MSG_DEBUG( "storeLaser() completed" );
522
523 return StatusCode::SUCCESS;
524}
525
526StatusCode TileTBAANtuple::storeBeamElements(const EventContext& ctx) {
527
528 if ( m_beamElemContainerKey.empty()) {
529 return StatusCode::SUCCESS;
530 }
531
532 // Read Beam Elements from TES
533 const TileBeamElemContainer* beamElemCnt = SG::makeHandle (m_beamElemContainerKey, ctx).get();
534
535 TileBeamElemContainer::const_iterator collItr = beamElemCnt->begin();
536 TileBeamElemContainer::const_iterator lastColl = beamElemCnt->end();
537
538 if ( m_completeNtuple ) {
539 // Store ROD header info from collection (just from first one)
540 int nDrawersAll = m_nDrawers.value() + m_nDrawersFlx.value();
541 if ( collItr!=lastColl ) {
542 m_l1ID.at(nDrawersAll) = (*collItr)->getLvl1Id();
543 m_l1Type.at(nDrawersAll) = (*collItr)->getLvl1Type();
544 m_evType.at(nDrawersAll) = (*collItr)->getDetEvType();
545 m_evBCID.at(nDrawersAll) = (*collItr)->getRODBCID();
546 } else {
547 m_l1ID.at(nDrawersAll) = 0xFFFFFFFF;
548 m_l1Type.at(nDrawersAll) = 0xFFFFFFFF;
549 m_evType.at(nDrawersAll) = 0xFFFFFFFF;
550 m_evBCID.at(nDrawersAll) = 0xFFFFFFFF;
551 }
552 }
553
554
555 m_trigType = 0;
556
557 for(; collItr != lastColl; ++collItr) {
558
559 TileBeamElemCollection::const_iterator beamItr=(*collItr)->begin();
560 TileBeamElemCollection::const_iterator lastBeam=(*collItr)->end();
561
562 if (msgLvl(MSG::VERBOSE)) {
563
564 for (; beamItr != lastBeam; ++beamItr) {
565 HWIdentifier id = (*beamItr)->adc_HWID();
566 std::vector<uint32_t> digits = (*beamItr)->get_digits();
567 msg(MSG::VERBOSE) << " --- TileBeamElem -- Identifier " << m_tileHWID->to_string(id)
568 << MSG::hex << " frag: 0x" << (*collItr)->identify()
569 << MSG::dec << " channel " << m_tileHWID->channel(id)
570 << " digits size " << digits.size() << endmsg;
571 msg(MSG::VERBOSE) << " --- TileBeamElem -- BeamElem : ";
572 for (unsigned int k = 0; k < digits.size(); k++)
573 msg(MSG::VERBOSE) << digits[k] << " ";
574 msg(MSG::VERBOSE) << endmsg;
575 }
576 //restore iterator
577 beamItr = (*collItr)->begin();
578 }
579
580 int frag = (*collItr)->identify();
581 ATH_MSG_DEBUG( " frag: " << frag );
582 ATH_MSG_DEBUG( " trigType " << (*collItr)->getLvl1Type() );
583
584 if ( m_trigType == 0 && (*collItr)->getLvl1Type() != 0 ) // take it from the ROD header
585 m_trigType = (*collItr)->getLvl1Type();
586
587 // unpack only fragments which we want to store in ntuple
588 if ( m_beamIdList[frag&0x1F] ) {
589
590 for (; beamItr != lastBeam; ++beamItr) {
591
592 HWIdentifier id = (*beamItr)->adc_HWID();
593 std::vector<uint32_t> digits = (*beamItr)->get_digits();
594 int cha = m_tileHWID->channel(id);
595 int dsize = digits.size();
596
597 if ( dsize <= 0 ) {
598
599 WRONG_SAMPLE(frag,cha,dsize);
600
601 } else if ( dsize != 16 && frag == ADD_FADC_FRAG ) {
602
603 WRONG_SAMPLE(frag,cha,dsize);
604
605 } else if ( dsize != 1 && frag != ADD_FADC_FRAG &&
606 frag != BEAM_TDC_FRAG && frag != COMMON_TDC1_FRAG &&
607 frag != COMMON_TOF_FRAG && frag != COMMON_TDC2_FRAG &&
608 !(frag == ECAL_ADC_FRAG)) {
609
610 WRONG_SAMPLE(frag,cha,dsize);
611
612 } else {
613
614 uint32_t amplitude = digits[0];
615 SIGNAL_FOUND(frag, cha, amplitude);
616
617 switch (frag) {
618
619 case BEAM_TDC_FRAG:
620
621 FRAG_FOUND(frag,cha,dsize);
622 if(cha < 8) m_btdc1[cha] = amplitude;
623 else if(cha < 16) m_btdc2[cha-8] = amplitude;
624 else WRONG_CHANNEL(frag,cha);
625 break;
626
627 case BEAM_ADC_FRAG:
628
629 if ( m_TBperiod >= 2015 ) {
630 switch(cha) {
631 // BEAM
632 case 0: m_s1cou = amplitude; break;
633 case 1: m_s2cou = amplitude; break;
634 case 2: m_s3cou = amplitude; break;
635 case 3: m_cher1 = amplitude; break; // ATH_MSG_VERBOSE("load beam adc " << m_cher1); break;
636 case 4: m_cher2 = amplitude; break;
637 case 5: m_muTag = amplitude; break;
638 case 6: m_muHalo= amplitude; break;
639 case 7: m_muVeto= amplitude; break;
640 default: WRONG_CHANNEL(frag, cha);
641 }
642 } else if ( m_unpackAdder ) {
643 switch(cha) {
644 // BEAM
645 case 0: m_s1cou = amplitude; break;
646 case 1: m_s2cou = amplitude; break;
647 case 2: m_s3cou = amplitude; break;
648 case 3: m_cher1 = amplitude; break; // swap of Cher1
649 case 4: m_muTag = amplitude; break; // and S4 in 2003 data
650 case 5: m_cher2 = amplitude; break;
651 case 6: m_muHalo= amplitude; break;
652 case 7: m_muVeto= amplitude; break;
653 // LASER
654 case 8: m_las0 = amplitude; break;
655 case 9: m_las1 = amplitude; break;
656 case 10: m_las2 = amplitude; break;
657 case 11: m_las3 = amplitude; break;
658 case 12: m_lasExtra[0] = amplitude; break;
659 case 13: m_lasExtra[1] = amplitude; break;
660 case 14: m_lasExtra[2] = amplitude; break;
661 case 15: m_lasExtra[3] = amplitude; break;
662 default: WRONG_CHANNEL(frag, cha);
663 }
664 } else { // 2004 data
665 switch(cha) {
666 // BEAM
667 case 0: m_sc1 = amplitude; break;
668 case 1: m_sc2 = amplitude; break;
669 case 2:
670 case 3:
671 case 4:
672 case 5:
673 case 6:
674 case 7: break;
675 default: WRONG_CHANNEL(frag, cha);
676 }
677 }
678 break;
679
680 case MUON_ADC_FRAG:
681
682 // first 14 are m_muBack
683 if(cha < 14) m_muBack[cha] = amplitude;
684 // last 2 are m_muCalib
685 else if (cha < 16) m_muCalib[cha - 14] = amplitude;
686 else WRONG_CHANNEL(frag, cha);
687 break;
688
689 case ADDR_ADC_FRAG:
690
691 // second half of Muon Wall in 2004
692 if(cha < 6) m_muBack[cha + 8] = amplitude;
693 // last 2 are m_muCalib
694 else if (cha < 8) m_muCalib[cha - 6] = amplitude;
695 else WRONG_CHANNEL(frag,cha);
696 break;
697
698 case LASE_PTN_FRAG:
699
700 if (cha == 0) {
701 // laser pattern unit
702 m_lasFlag = amplitude;
703 if (amplitude & 0xFF00) m_trigType = amplitude >> 8;
704 } else {
705 WRONG_CHANNEL(frag, cha);
706 }
707 break;
708
709 case LASE_ADC_FRAG:
710
711 // laser in 2004
712 switch(cha) {
713 case 0: m_las0 = amplitude; break;
714 case 1: m_las1 = amplitude; break;
715 case 2: m_las2 = amplitude; break;
716 case 3: m_las3 = amplitude; break;
717 case 4: m_lasExtra[0] = amplitude; break;
718 case 5: m_lasExtra[1] = amplitude; break;
719 case 6: m_lasExtra[2] = amplitude; break;
720 case 7: m_lasExtra[3] = amplitude; break;
721 default: WRONG_CHANNEL(frag,cha);
722 }
723 break;
724
725 case ADD_FADC_FRAG:
726
727 if (m_unpackAdder) {
728
729 for (int k = 0; k < dsize; k++) {
730 //m_addx[k]=k;
731 //check how the matrix is filled
732 m_adder[cha][k] = digits[k];
733 }
734 // FlatFiler adders
735 double ene, tim;
736 m_adderFilterAlgTool->flatFilter(digits, 0, ene, tim);
737 m_eneAdd[cha] = ene;
738 m_timeAdd[cha] = tim;
739 }
740
741 break;
742
743 case ECAL_ADC_FRAG:
744
745 if (m_TBperiod > 2015) {
746
747 if(cha < 15) {
748 m_qdc[cha] = amplitude;
749 ATH_MSG_VERBOSE( "QDC: " << cha << " amp: " << amplitude);
750 } else if (cha == 15) {
751 for (int idx = 0; idx < dsize && idx < 18; ++idx) {
752 m_qdc[idx + 15] = digits[idx];
753 ATH_MSG_VERBOSE("QDC2: " << cha << " amp: " << amplitude);
754 }
755 } else {
756 WRONG_CHANNEL(frag, cha);
757 }
758
759 } else {
760 if(cha < 8) m_ecal[cha] = amplitude;
761 else WRONG_CHANNEL(frag, cha);
762 }
763
764 break;
765
766 case DIGI_PAR_FRAG:
767
768 if(cha < 16) m_cispar[cha] = amplitude; //m_cispar->at(cha)=amplitude;
769 else WRONG_CHANNEL(frag,cha);
770 break;
771
772 case COMMON_ADC1_FRAG:
773 if (m_TBperiod > 2015) {
774 if (cha < 16) {
775 if (m_run > 2211444) {
776 switch(cha) {
777 // BEAM
778 case 0: m_s1cou = amplitude; break;
779 case 1: m_s2cou = amplitude; break;
780 case 2: {
781 if (m_run < 2310000) {
782 m_muBack[10] = amplitude;
783 } else {
784 m_s3cou = amplitude;
785 }
786 }
787 break;
788 case 3: m_cher1 = amplitude; break;
789 case 4: m_cher2 = amplitude; break;
790 case 5: m_cher3 = amplitude; break;
791 default: m_muBack[cha - 6] = amplitude;
792 }
793 } else {
794 switch(cha) {
795 // BEAM
796 case 0: m_s1cou = amplitude; break;
797 case 1: m_s2cou = amplitude; break;
798 case 2: m_s3cou = amplitude; break;
799 case 3: m_cher1 = amplitude; break;
800 case 4: m_cher2 = amplitude; break;
801 case 5: m_cher3 = amplitude; break;
802 }
803 }
804 } else {
805 WRONG_CHANNEL(frag, cha);
806 }
807 } else {
808 switch(cha) {
809 // BEAM
810 case 0: m_s1cou = amplitude; break;
811 case 1: m_s2cou = amplitude; break;
812 case 2: m_s3cou = amplitude; break;
813 case 3: m_muTag = amplitude; break;
814 case 4: m_cher1 = amplitude; break;
815 case 5: m_cher2 = amplitude; break;
816 case 6: m_muHalo= amplitude; break;
817 case 7: m_muVeto= amplitude; break;
818 default: WRONG_CHANNEL(frag, cha);
819 }
820 }
821 break;
822
823 case COMMON_ADC2_FRAG:
824
825 if (m_TBperiod > 2015) {
826 if(cha < 14) {
827 m_muBack[cha] = amplitude;
828 } else {
829 WRONG_CHANNEL(frag, cha);
830 }
831 } else {
832 if ( ! m_unpackAdder ) {
833 switch(cha) {
834 // BEAM
835 case 0: break;
836 case 1: m_s2extra = amplitude; break;
837 case 2: m_s3extra = amplitude; break;
838 case 3:
839 case 4:
840 case 5:
841 case 6:
842 case 7: break;
843 default: WRONG_CHANNEL(frag, cha);
844 }
845 }
846 }
847 break;
848
849 case COMMON_PTN_FRAG:
850 if (m_run > 2310000 && cha < 16) {
851 m_scaler[cha] = amplitude;
852 } else if (cha == 0) {
853 m_commonPU = amplitude;
854 } else {
855 WRONG_CHANNEL(frag, cha);
856 }
857 break;
858
859 case COMMON_TOF_FRAG:
860
861 if (m_TBperiod >= 2022) {
862 if (cha > 11) { // The first 12 channels are (can be) connected to BC1 and BC2, the last 4 channels are supposed to be TOF
863 if(cha < 16) {
864 m_tof[cha] = amplitude;
865 ATH_MSG_VERBOSE( "TOF: " << cha << " amp: " << amplitude);
866 } else {
867 WRONG_CHANNEL(frag, cha);
868 }
869 break;
870 }
871 // Fall through to case COMMON_TDC1_FRAG to unpack the first 12 channels of BC1 and BC2
872 [[fallthrough]]; // silent the warning on fall through
873 } else if (m_TBperiod > 2015) {
874
875 if(cha < 16) {
876 m_tof[cha] = amplitude;
877 ATH_MSG_VERBOSE( "TOF: " << cha << " amp: " << amplitude);
878 } else {
879 WRONG_CHANNEL(frag, cha);
880 }
881 break;
882 } else {
883 if(cha < 8) m_tof[cha] = amplitude;
884 else WRONG_CHANNEL(frag, cha);
885 break;
886 }
887
888 case COMMON_TDC1_FRAG:
889
890 FRAG_FOUND(frag,cha,dsize);
891 if ((cha > 11) && (cha < 16) && (m_run > 2211136)) {
892 m_tof[cha] = amplitude;
893 ATH_MSG_VERBOSE( "TOF: " << cha << " amp: " << amplitude);
894 } if(cha < 16) {
895 m_btdc1[cha] = amplitude;
896 ATH_MSG_VERBOSE( "TDC: " << cha << " amp: " << amplitude);
897 if (m_btdcNhit[cha]==0) {
898 m_btdc2[cha] = amplitude;
899 }
900 (*m_btdc)[cha].push_back(amplitude);
901 ++m_btdcNhit[cha];
902 } else WRONG_CHANNEL(frag, cha);
903 break;
904
905 case COMMON_TDC2_FRAG:
906
907 FRAG_FOUND(frag,cha,dsize);
908 if(cha < 16) m_btdc2[cha] = amplitude;
909 else WRONG_CHANNEL(frag, cha);
910 break;
911
912 case COIN_TRIG1_FRAG:
913
914 if(cha < 3) {
915 int idx = cha * 32;
916 for (int ibit = 0; ibit < 32; ++ibit){
917 m_coincTrig1[idx++] = (amplitude >> ibit) & 1;
918 }
919 } else if (cha == 3) {
920 m_coincFlag1 = amplitude;
921 } else WRONG_CHANNEL(frag, cha);
922
923 break;
924
925 case COIN_TRIG2_FRAG:
926
927 if(cha < 3) {
928 int idx = cha * 32;
929 for (int ibit=0; ibit < 32; ++ibit){
930 m_coincTrig2[idx++] = (amplitude >> ibit) & 1;
931 }
932 } else if (cha == 3) {
933 m_coincFlag2 = amplitude;
934 } else WRONG_CHANNEL(frag, cha);
935
936 break;
937
938 case COIN_TRIG3_FRAG:
939
940 if(cha < 3) {
941 int idx = cha * 32;
942 for (int ibit = 0; ibit < 32; ++ibit){
943 m_coincTrig3[idx++] = (amplitude >> ibit) & 1;
944 }
945 } else if (cha == 3) {
946 m_coincFlag3 = amplitude;
947 } else WRONG_CHANNEL(frag,cha);
948
949 break;
950
951 case COIN_TRIG4_FRAG:
952
953 if(cha < 3) {
954 int idx = cha * 32;
955 for (int ibit = 0; ibit < 32; ++ibit){
956 m_coincTrig4[idx++] = (amplitude >> ibit) & 1;
957 }
958 } else if (cha == 3) {
959 m_coincFlag4 = amplitude;
960 } else WRONG_CHANNEL(frag, cha);
961
962 break;
963
964 case COIN_TRIG5_FRAG:
965
966 if(cha < 3) {
967 int idx = cha * 32;
968 for (int ibit = 0; ibit < 32; ++ibit){
969 m_coincTrig5[idx++] = (amplitude >> ibit) & 1;
970 }
971 } else if (cha == 3) {
972 m_coincFlag5 = amplitude;
973 } else WRONG_CHANNEL(frag, cha);
974
975 break;
976
977 case COIN_TRIG6_FRAG:
978
979 if(cha < 3) {
980 int idx = cha * 32;
981 for (int ibit = 0; ibit < 32; ++ibit){
982 m_coincTrig6[idx++] = (amplitude >> ibit) & 1;
983 }
984 } else if (cha == 3) {
985 m_coincFlag6 = amplitude;
986 } else WRONG_CHANNEL(frag, cha);
987
988 break;
989
990 case COIN_TRIG7_FRAG:
991
992 if(cha < 3) {
993 int idx = cha * 32;
994 for (int ibit = 0; ibit < 32; ++ibit){
995 m_coincTrig7[idx++] = (amplitude >> ibit) & 1;
996 }
997 } else if (cha == 3) {
998 m_coincFlag7 = amplitude;
999 } else WRONG_CHANNEL(frag,cha);
1000
1001 break;
1002
1003 case COIN_TRIG8_FRAG:
1004
1005 if(cha < 3) {
1006 int idx = cha * 32;
1007 for (int ibit = 0; ibit < 32; ++ibit){
1008 m_coincTrig8[idx++] = (amplitude >> ibit) & 1;
1009 }
1010 } else if (cha == 3) {
1011 m_coincFlag8 = amplitude;
1012 } else WRONG_CHANNEL(frag, cha);
1013
1014 break;
1015
1016 default:
1017 break;
1018 }
1019 }
1020 }
1021 }
1022 }
1023
1024 for (int i=0; i<8; ++i) {
1025 if (m_btdcNhit[i] > 1) ++m_btdcNchMultiHit[i>>2];
1026 }
1027 // calculate beam coords in Beam Chambers
1028 if ( m_TBperiod >= 2015 ) {
1029
1030// For BC1
1031// -------
1032// m_xCha1 = -0.0462586 + (-0.175666)*(m_btdc1[1] - m_btdc1[0]);
1033// m_yCha1 = -0.051923 + (-0.176809)*(m_btdc1[2] - m_btdc1[3]);
1034//
1035// For BC2
1036// -------
1037// m_xCha2 = 0.25202 + (-0.18053)*(m_btdc1[5] - m_btdc1[4]);
1038// m_yCha2 = 0.0431688 + (-0.181128)*(m_btdc1[6] - m_btdc1[7]);
1039
1040 if (m_run > 2211444) {
1043 } else {
1046 }
1047 if (m_run > 612543 && m_run< 614141) {
1050 } else {
1053 }
1054
1055 // Using the first value from the TDC
1056 if (m_run > 2211444) {
1059 } else {
1062 }
1065
1066 m_tjitter = m_btdc1[8];
1067 m_tscTOF = m_btdc1[14];
1068
1071
1072// Work in progress
1073
1081
1082 if (m_run > 2211444) {
1083 ATH_MSG_DEBUG( "BC1x : ( "<< m_btdc1[0] <<" - "<< m_btdc1[8] <<" )\t" << m_xCha1 );
1084 ATH_MSG_DEBUG( "BC1y : ( "<< m_btdc1[2] <<" - "<< m_btdc1[9] <<" )\t" << m_yCha1 );
1085 } else {
1086 ATH_MSG_DEBUG( "BC1x : ( "<< m_btdc1[0] <<" - "<< m_btdc1[1] <<" )\t" << m_xCha1 );
1087 ATH_MSG_DEBUG( "BC1y : ( "<< m_btdc1[2] <<" - "<< m_btdc1[3] <<" )\t" << m_yCha1 );
1088 }
1089 ATH_MSG_DEBUG( "BC2x : ( "<< m_btdc1[4] <<" - "<< m_btdc1[5] <<" )\t" << m_xCha2 );
1090 ATH_MSG_DEBUG( "BC2y : ( "<< m_btdc1[6] <<" - "<< m_btdc1[7] <<" )\t" << m_yCha2 );
1091
1092 } else if ( m_unpackAdder ) { // this is 2003 data
1093
1094 if ( m_beamIdList[BEAM_TDC_FRAG] ) {
1095 m_xCha1 = m_beamBC1X1 + m_beamBC1X2*(m_btdc1[6] - m_btdc1[7]); // last two channels of TDC !!!
1099
1102 }
1103
1104 } else { // this is 2004 data
1105
1111
1114
1115 ATH_MSG_DEBUG( "BC-2x : ( "<< m_btdc1[2] <<" - "<< m_btdc1[3] <<" )\t" <<m_xChN2 );
1116 ATH_MSG_DEBUG( "BC-2y : ( "<< m_btdc1[0] <<" - "<< m_btdc1[1] <<" )\t" <<m_yChN2 );
1117 ATH_MSG_DEBUG( "BC-1x : ( "<< m_btdc1[6] <<" - "<< m_btdc1[7] <<" )\t" <<m_xChN1 );
1118 ATH_MSG_DEBUG( "BC-1y : ( "<< m_btdc1[4] <<" - "<< m_btdc1[5] <<" )\t" <<m_yChN1 );
1119 ATH_MSG_DEBUG( "BC0x : ( "<< m_btdc1[10] <<" - "<< m_btdc1[11] <<" )\t" <<m_xCha0 );
1120 ATH_MSG_DEBUG( "BC0y : ( "<< m_btdc1[8] <<" - "<< m_btdc1[9] <<" )\t" <<m_yCha0 );
1121
1122 }
1123
1129
1130 m_xImp = 0.0;
1131 m_yImp = 0.0;
1132
1133 ATH_MSG_DEBUG( "BC1x : ( "<< m_btdc2[2] <<" - "<< m_btdc2[3] <<" )\t" <<m_xCha1 );
1134 ATH_MSG_DEBUG( "BC1y : ( "<< m_btdc2[0] <<" - "<< m_btdc2[1] <<" )\t" <<m_yCha1 );
1135 ATH_MSG_DEBUG( "BC2x : ( "<< m_btdc2[6] <<" - "<< m_btdc2[7] <<" )\t" <<m_xCha2 );
1136 ATH_MSG_DEBUG( "BC2y : ( "<< m_btdc2[4] <<" - "<< m_btdc2[5] <<" )\t" <<m_yCha2 );
1137
1138 }
1139
1141
1143 // Get run number and eta
1144 if ( 0==m_runNumber ){
1145 const xAOD::EventInfo* eventInfo(0);
1146 if (evtStore()->retrieve(eventInfo).isFailure()){
1147 ATH_MSG_ERROR( "No EventInfo object found! Can't read run number!" );
1148 m_runNumber = -1;
1149 } else {
1150 m_runNumber = eventInfo->runNumber();
1151 getEta();
1152 }
1153 }
1155
1156 // Computation of X,Y imp on TileCal/LAr front
1157 float tanBx = (m_xCha1-m_xCha0) / (m_beamBC0Z - m_beamBC1Z);
1158 float tanBy = (m_yCha1-m_yCha0) / (m_beamBC0Z - m_beamBC1Z);
1159
1160 float Ximp = m_xCha1 + m_beamBC1Z * tanBx;
1161 float Yimp = m_yCha1 + m_beamBC1Z * tanBy;
1162
1163 if ( 0.0 != cos(m_theta) * (1 + tanBx * tan(m_theta)) ){
1164 m_xImp = (Ximp + m_radius *(tanBx * (cos(m_theta) - 1) -sin(m_theta))) / (cos(m_theta) * (1 + tanBx * tan(m_theta)));
1165 m_yImp = Yimp + tanBy * (m_radius * (1 - cos(m_theta)) -Ximp * sin(m_theta)) / (cos(m_theta) * (1+tanBx * tan(m_theta)));
1166 }
1167 }
1168 }
1169
1170
1171 // do not apply Cesium and Laser calibration for CIS events
1172 // m_calibrateEnergyThisEvent = m_calibrateEnergy && (m_trigType != 8);
1173
1174 return StatusCode::SUCCESS;
1175}
1176
1177
1182 */
1183StatusCode TileTBAANtuple::storeRawChannels(const EventContext& ctx
1184 , const SG::ReadHandleKey<TileRawChannelContainer>& containerKey
1185 , bool calib_mode
1186 , std::vector<std::array<float, MAX_CHAN>>* eneVec
1187 , std::vector<std::array<float, MAX_CHAN>>* timeVec
1188 , std::vector<std::array<float, MAX_CHAN>>* chi2Vec
1189 , std::vector<std::array<float, MAX_CHAN>>* pedVec
1190 , bool saveDQstatus)
1191{
1192
1193
1194 if (containerKey.empty()) {// empty name, nothing to do
1195 return StatusCode::FAILURE;
1196 }
1197
1198 bool isFELIX = containerKey.key().find("Flx") != std::string::npos;
1199 int nDrawers = isFELIX ? m_nDrawersFlx : m_nDrawers;
1200 std::map<unsigned int, unsigned int, std::less<unsigned int>>& drawerMap = (isFELIX) ? m_drawerFlxMap : m_drawerMap;
1201
1202 // get named container
1203 const TileRawChannelContainer* rcCnt = SG::makeHandle (containerKey, ctx).get();
1204
1205 TileRawChannelUnit::UNIT rChUnit = rcCnt->get_unit();
1206 ATH_MSG_DEBUG( "RawChannel unit is " << rChUnit );
1207
1208
1209 if (rChUnit >= TileRawChannelUnit::OnlineADCcounts) { // this is container with DSP results
1210 m_dspUnit = rChUnit;
1211 m_dspFlags = rcCnt->get_bsflags() >> 16;
1212 ATH_MSG_DEBUG( "DSP flag is 0x" << MSG::hex << m_dspFlags << MSG::dec << " DSP unit is " << m_dspUnit );
1213
1215 && rChUnit != TileRawChannelUnit::ADCcounts) {
1216
1217 ATH_MSG_ERROR( "RawChannel units are not ADC counts, can't apply DSP-like calibration" );
1218 return StatusCode::FAILURE;
1219 }
1220
1222 if (m_useDspUnits) { // calibrate a-la online
1224 } else { // convert to final units
1226 }
1227 } else {
1228 m_rchUnit = rChUnit;
1229 }
1230
1231 ATH_MSG_DEBUG( "Final RawChannel unit is " << m_rchUnit );
1232
1233 // drawerIndex is 0 - m_nDrawers-1, fragType is 1-4 B+/B-/EB+/EB-
1234 int drawerIndex, fragType;
1235
1236 // Go through all TileRawChannelCollections
1237 for (const TileRawChannelCollection* rawChannelCollection : *rcCnt) {
1238 // determine type
1239 int fragId = rawChannelCollection->identify();
1240 int drawerIdx = TileCalibUtils::getDrawerIdxFromFragId(fragId);
1241
1242 drawerMap_iterator itr = drawerMap.find(fragId);
1243 if ( itr != drawerMap.end() ) {
1244 drawerIndex = (*itr).second;
1245 } else {
1246 drawerIndex= -1;
1247 }
1248
1249 if (drawerIndex < 0) {
1250 if ( !rawChannelCollection->empty() )
1251 ATH_MSG_DEBUG( "frag id 0x" << MSG::hex << fragId << MSG::dec << " was not found among valid frag IDs when storing TRC!" );
1252 } else {
1253 fragType = isFELIX ? fragId >> 8 : m_drawerType[drawerIndex];
1254 ATH_MSG_DEBUG( "TRC (" << containerKey.key()
1255 << ") Event# " << m_evtNr
1256 << " Frag id 0x" << MSG::hex << fragId << MSG::dec
1257 << " index "<< drawerIndex );
1258
1259 // go through all TileRawChannels in collection
1260 for (const TileRawChannel* rch : *rawChannelCollection) {
1261 int index = drawerIndex;
1262 HWIdentifier hwid = rch->adc_HWID();
1263
1264 // determine channel and gain
1265 int channel = m_tileHWID->channel(hwid);
1266 int gain = m_tileHWID->adc(hwid);
1267
1268 if (calib_mode) {
1269 // gain, if hi add m_nDrawers to index
1270 if (gain == 1) index += nDrawers;
1271 }
1272
1274 double energy = rch->amplitude();
1275 if (m_rchUnit != rChUnit) {
1277 energy = m_tileToolEmscale->channelCalib(drawerIdx, channel, gain, energy, rChUnit, m_rchUnit);
1278 else
1279 energy = m_tileToolEmscale->channelCalibOnl(drawerIdx, channel, gain, energy, m_rchUnit);
1280 }
1281
1282 // cabling for testbeam (convert to pmt#-1)
1283 if ((m_TBperiod < 2015 ||
1284 (m_TBperiod==2015 && fragType<3) ||
1285 ((m_TBperiod==2016 || m_TBperiod==2021) && ((fragId&0xFF)<4 && fragId != 0x201)) ||
1286 (m_TBperiod==2017 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x203))) ||
1287 (m_TBperiod==2018 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x402))) ||
1288 (m_TBperiod==2019 && ((fragId&0xFF)<5 && !(fragId == 0x201 || fragId == 0x203 || fragId >= 0x402))) ||
1289 (m_TBperiod==2022 && ((fragId&0xFF)<4 && !(fragId == 0x201 || (m_run >= 2210456 && fragId == 0x402)))))
1290 && fragType > 0 && m_pmtOrder)
1291 channel = digiChannel2PMT(fragType, channel);
1292
1293 eneVec->at(index)[channel] = energy;
1294 timeVec->at(index)[channel] = rch->time();
1295 if (chi2Vec) {
1296 chi2Vec->at(index)[channel] = rch->quality();
1297 }
1298 if (pedVec) {
1299 pedVec->at(index)[channel] = rch->pedestal();
1300 }
1301
1302 ATH_MSG_DEBUG( "TRC ene=" << energy
1303 << " time=" << rch->time()
1304 << " chi2=" << rch->quality()
1305 << " ped=" << rch->pedestal()
1306 << " pmt-1=" << channel
1307 << " index " << index );
1308
1309 }
1310
1311 if (saveDQstatus && !isFELIX) {
1312
1313 int index1 = drawerIndex, index2 = drawerIndex + 1;
1314 if (calib_mode) index2 += m_nDrawers;
1315
1316 for (int index = index1; index < index2; index += m_nDrawers) {
1317
1318 m_ROD_GlobalCRCVec.at(index) = rawChannelCollection->getFragGlobalCRC() & 1;
1319 m_ROD_DMUMaskVec.at(index)[0] = rawChannelCollection->getFragRODChipMask();
1320 m_ROD_DMUMaskVec.at(index)[1] = rawChannelCollection->getFragFEChipMask();
1321
1322 for (unsigned int dmu = 0; dmu < MAX_DMU; ++dmu) {
1323
1324 m_ROD_DMUBCIDVec.at(index)[dmu] = (rawChannelCollection->getFragBCID() >> dmu) & 1;
1325 m_ROD_DMUmemoryErrVec.at(index)[dmu] = (rawChannelCollection->getFragMemoryPar() >> dmu) & 1;
1326 m_ROD_DMUSstrobeErrVec.at(index)[dmu] = (rawChannelCollection->getFragSstrobe() >> dmu) & 1;
1327 m_ROD_DMUDstrobeErrVec.at(index)[dmu] = (rawChannelCollection->getFragDstrobe() >> dmu) & 1;
1328 m_ROD_DMUHeadformatErrVec.at(index)[dmu] = (rawChannelCollection->getFragHeaderBit() >> dmu) & 1;
1329 m_ROD_DMUDataformatErrVec.at(index)[dmu] = (rawChannelCollection->getFragSampleBit() >> dmu) & 1;
1330 }
1331 }
1332 }
1333 }
1334 }
1335
1336 return StatusCode::SUCCESS;
1337}
1338
1339
1344 */
1345StatusCode TileTBAANtuple::storeDigits(const EventContext& ctx, const SG::ReadHandleKey<TileDigitsContainer>& containerKey, const TileDQstatus* dqStatus) {
1346
1347 if (containerKey.empty()) { // empty name, nothing to do
1348 return StatusCode::FAILURE;
1349 }
1350
1351 // Read Digits from TES
1352 const TileDigitsContainer* digitsCnt = SG::makeHandle (containerKey, ctx).get();
1353
1354 bool emptyColl = true;
1355
1356 // drawerIndex is 0 - m_nDrawers-1, fragType is 1-4 B+/B-/EB+/EB-
1357 int drawerIndex, fragType, channel;
1358
1359 std::vector<float> sampleVec;
1360 std::vector<uint32_t> headerVec;
1361 std::vector<uint32_t> headerVecHi;
1362 uint32_t CRCmask;
1363 uint32_t fe_crc;
1364 uint32_t rod_crc;
1365
1366 // Go through all TileDigitsCollections
1367 for (const TileDigitsCollection* digitsCollection : * digitsCnt) {
1368 // determine type of frag
1369 int fragId = digitsCollection->identify();
1370 int ros = (fragId >> 8);
1371 int drawer = fragId & 0x3F;
1372
1373 drawerMap_iterator itr = m_drawerMap.find(fragId);
1374 if ( itr != m_drawerMap.end() ) {
1375 drawerIndex = (*itr).second;
1376 } else {
1377 drawerIndex= -1;
1378 }
1379
1380 if (drawerIndex < 0) {
1381 if ( !digitsCollection->empty() )
1382 ATH_MSG_DEBUG( "frag id 0x" << MSG::hex << fragId << MSG::dec <<" was not found among valid frag IDs when storing TRC!" );
1383
1384 } else {
1385 fragType = m_drawerType[drawerIndex];
1386
1387 ATH_MSG_DEBUG( "Event# " << m_evtNr
1388 << " Frag id 0x" << MSG::hex << fragId << MSG::dec
1389 << " index " << drawerIndex
1390 << " Calib " << m_calibMode );
1391
1392 ATH_MSG_DEBUG( " Size=" << digitsCollection->getFragSize()
1393 << " BCID=" << digitsCollection->getFragBCID()<<MSG::hex
1394 << " CRC=0x" << (digitsCollection->getFragCRC()&0xffff)
1395 << " DMUMask=0x" << (digitsCollection->getFragDMUMask()&0xffff)<<MSG::dec );
1396
1397 ATH_MSG_DEBUG( " Lvl1ID=" << digitsCollection->getLvl1Id()
1398 << " Lvl1Type=" << digitsCollection->getLvl1Type()
1399 << " EvBCID=" << digitsCollection->getRODBCID()
1400 << " EvType=" << digitsCollection->getDetEvType() );
1401
1402 ATH_MSG_DEBUG( " Header=" << digitsCollection->getFragChipHeaderWords() );
1403
1404 if (m_completeNtuple) {
1409 m_l1ID.at(drawerIndex) = digitsCollection->getLvl1Id();
1410 m_l1Type.at(drawerIndex) = digitsCollection->getLvl1Type();
1411 m_evType.at(drawerIndex) = digitsCollection->getDetEvType();
1412 m_evBCID.at(drawerIndex) = digitsCollection->getRODBCID();
1413 // store FrBCID
1414 m_frBCID.at(drawerIndex) = digitsCollection->getFragBCID();
1415 }
1416
1417 if(m_calibMode) {
1418 // Digits in calib mode
1419 // check gain for first digits in collection
1420
1421 int dcnt=0;
1422 int drawerIndexHi = drawerIndex + m_nDrawers;
1423 // non empty collection
1424 if (!digitsCollection->empty()) {
1425 // store evtnr, bcid,crc, size
1426 // Same for lo and hi, because they come from the same fragment
1427 m_rodBCIDVec.at(drawerIndex) = digitsCollection->getRODBCID();
1428 m_sizeVec.at(drawerIndex) = digitsCollection->getFragSize();
1429 m_sizeVec.at(drawerIndexHi) = digitsCollection->getFragSize();
1430 m_evtVec.at(drawerIndex) = m_evtNr;
1431 m_evtVec.at(drawerIndexHi) = m_evtNr;
1432
1433 headerVec = digitsCollection->getFragChipHeaderWords();
1434 headerVecHi = digitsCollection->getFragChipHeaderWordsHigh();
1435 CRCmask = digitsCollection->getFragDMUMask(); //mask of FE+ROD DMU crc check (16bit+16bit) 0xffffffff == All ok
1436 fe_crc = CRCmask & 0xFFFF;
1437 rod_crc = CRCmask >> 16;
1438
1439 unsigned int headsize = std::min(16U, static_cast<unsigned int>(headerVec.size()));
1440 unsigned int headsizehi = std::min(16U, static_cast<unsigned int>(headerVecHi.size()));
1441
1442 for (unsigned int ih = 0; ih < headsize; ++ih) {
1443
1444 m_bcidVec.at(drawerIndex)[ih] = (headerVec[ih] & 0xFFF);
1445 m_DMUheaderVec.at(drawerIndex)[ih] = headerVec[ih];
1446 m_DMUformatErrVec.at(drawerIndex)[ih] = CheckDMUFormat(headerVec[ih]);
1447 m_DMUparityErrVec.at(drawerIndex)[ih] = CheckDMUParity(headerVec[ih]);
1448 m_DMUmemoryErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 25 & 0x1);
1449 m_DMUSstrobeErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 24 & 0x1);
1450 m_DMUDstrobeErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 23 & 0x1);
1451 m_feCRCVec.at(drawerIndex)[ih] = (fe_crc >> ih & 0x1);
1452 m_rodCRCVec.at(drawerIndex)[ih] = (rod_crc >> ih & 0x1);
1453
1454 if (dqStatus) {
1455 m_DMUHeadparityErrVec.at(drawerIndex)[ih] = dqStatus->checkHeaderParityErr(ros, drawer, ih, 0);
1456 m_DMUDataparityErrVec.at(drawerIndex)[ih] = dqStatus->checkSampleParityErr(ros, drawer, ih, 0);
1457 }
1458 }
1459
1460 for (unsigned int ihhi = 0; ihhi < headsizehi; ++ihhi) {
1461 m_bcidVec.at(drawerIndexHi)[ihhi] = (headerVecHi[ihhi] & 0xFFF);
1462 m_DMUheaderVec.at(drawerIndexHi)[ihhi] = headerVecHi[ihhi];
1463 m_DMUformatErrVec.at(drawerIndexHi)[ihhi] = CheckDMUFormat(headerVecHi[ihhi]);
1464 m_DMUparityErrVec.at(drawerIndexHi)[ihhi] = CheckDMUParity(headerVecHi[ihhi]);
1465 m_DMUmemoryErrVec.at(drawerIndexHi)[ihhi] = (headerVecHi[ihhi] >> 25 & 0x1);
1466 m_DMUSstrobeErrVec.at(drawerIndexHi)[ihhi] = (headerVecHi[ihhi] >> 24 & 0x1);
1467 m_DMUDstrobeErrVec.at(drawerIndexHi)[ihhi] = (headerVecHi[ihhi] >> 23 & 0x1);
1468 m_feCRCVec.at(drawerIndex)[ihhi] = -1; //Variables must be filled anyway, empty variables are not allowed
1469 m_rodCRCVec.at(drawerIndex)[ihhi] = -1; //Variables must be filled anyway, empty variables are not allowed
1470
1471 if (dqStatus) {
1472 m_DMUHeadparityErrVec.at(drawerIndex)[ihhi] = dqStatus->checkHeaderParityErr(ros, drawer, ihhi, 1);
1473 m_DMUDataparityErrVec.at(drawerIndex)[ihhi] = dqStatus->checkSampleParityErr(ros, drawer, ihhi, 1);
1474 }
1475 }
1476
1477 m_slinkCRCVec.at(drawerIndex)[0] = (digitsCollection->getFragCRC() >> 16) & 0xffff;
1478 m_dmuMaskVec.at(drawerIndex)[0] = (digitsCollection->getFragDMUMask() >> 16) & 0xffff;
1479 m_slinkCRCVec.at(drawerIndex)[1] = digitsCollection->getFragCRC() & 0xffff;
1480 m_dmuMaskVec.at(drawerIndex)[1] = digitsCollection->getFragDMUMask() & 0xffff;
1481
1482 m_slinkCRCVec.at(drawerIndexHi)[0] = (digitsCollection->getFragCRC() >> 16) & 0xffff;
1483 m_dmuMaskVec.at(drawerIndexHi)[0] = (digitsCollection->getFragDMUMask() >> 16) & 0xffff;
1484 m_slinkCRCVec.at(drawerIndexHi)[1] = digitsCollection->getFragCRC() & 0xffff;
1485 m_dmuMaskVec.at(drawerIndexHi)[1] = digitsCollection->getFragDMUMask() & 0xffff;
1486
1487 // go through all TileDigits in collection
1488 for (const TileDigits* tile_digits : *digitsCollection) {
1489
1490 emptyColl = false;
1491
1492 HWIdentifier hwid = tile_digits->adc_HWID();
1493 // determine gain
1494 int gain = m_tileHWID->adc(hwid);
1495 // add m_nDrawers to index if hi gain
1496 int index = (gain == 1) ? drawerIndexHi : drawerIndex;
1497 int nSamplesInDrawer = m_nSamplesInDrawer[index];
1498
1499 // determine channel
1500 channel = m_tileHWID->channel(hwid);
1501 // cabling for testbeam (convert to pmt#-1)
1502
1503 if ((m_TBperiod < 2015 ||
1504 (m_TBperiod==2015 && fragType<3) ||
1505 ((m_TBperiod==2016 || m_TBperiod==2021) && ((fragId&0xFF)<4 && fragId != 0x201)) ||
1506 (m_TBperiod==2017 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x203))) ||
1507 (m_TBperiod==2018 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x402))) ||
1508 (m_TBperiod==2019 && ((fragId&0xFF)<5 && !(fragId == 0x201 || fragId == 0x203 || fragId >= 0x402))) ||
1509 (m_TBperiod==2022 && ((fragId&0xFF)<4 && !(fragId == 0x201 || (m_run >= 2210456 && fragId == 0x402)))))
1510 && fragType > 0 && m_pmtOrder)
1511
1512 channel = digiChannel2PMT(fragType, channel);
1513
1514
1515 // gain determined for all digits in collection
1516 m_gainVec.at(index)[channel] = gain;
1517 ATH_MSG_DEBUG( "Storing TD for channel: " << channel
1518 << " with gain " << m_tileHWID->adc(hwid)
1519 << " index " << index );
1520
1521 // get digits
1522 sampleVec = tile_digits->samples();
1523 int siz = sampleVec.size();
1524
1525 if (msgLvl(MSG::DEBUG)) {
1526 msg(MSG::DEBUG) << "Digits(" << siz << ")." << (dcnt++) << " {";
1527 for (int i = 0; i < siz; i++) {
1528 msg(MSG::DEBUG) << static_cast<int>(sampleVec[i]) << " ";
1529 }
1530
1531 if (siz > nSamplesInDrawer) {
1532 msg(MSG::DEBUG) << "} ONLY " << nSamplesInDrawer << " digits saved to ntuple" << endmsg;
1533 } else {
1534 msg(MSG::DEBUG) << "}" << endmsg;
1535 }
1536 }
1537
1538 if (siz > nSamplesInDrawer) siz = nSamplesInDrawer;
1539 std::transform(sampleVec.begin(), sampleVec.begin() + siz, &m_sampleVec.at(index).get()[0] + nSamplesInDrawer * channel, [] (float v) {return static_cast<int>(v);});
1540 }
1541 }
1542 } else {
1543 // Digits in normal mode
1544 // store evtnr, bcid,crc, size
1545 m_rodBCIDVec.at(drawerIndex) = digitsCollection->getRODBCID();
1546 m_sizeVec.at(drawerIndex) = digitsCollection->getFragSize();
1547 m_evtVec.at(drawerIndex) = m_evtNr;
1548
1549 headerVec = digitsCollection->getFragChipHeaderWords();
1550 CRCmask = digitsCollection->getFragDMUMask(); //mask of FE+ROD DMU crc check (16bit+16bit) 0xffffffff == All ok
1551 fe_crc = CRCmask & 0xFFFF;
1552 rod_crc = CRCmask >> 16;
1553
1554 int headsize = headerVec.size();
1555
1556 for (int ih = 0; ih < headsize; ++ih) {
1557 m_bcidVec.at(drawerIndex)[ih] = (headerVec[ih] & 0xFFF);
1558 m_DMUheaderVec.at(drawerIndex)[ih] = headerVec[ih];
1559 m_DMUformatErrVec.at(drawerIndex)[ih] = CheckDMUFormat(headerVec[ih]);
1560 m_DMUparityErrVec.at(drawerIndex)[ih] = CheckDMUParity(headerVec[ih]);
1561 m_DMUmemoryErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 25 & 0x1);
1562 m_DMUSstrobeErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 24 & 0x1);
1563 m_DMUDstrobeErrVec.at(drawerIndex)[ih] = (headerVec[ih] >> 23 & 0x1);
1564 m_feCRCVec.at(drawerIndex)[ih] = (fe_crc >> ih & 0x1);
1565 m_rodCRCVec.at(drawerIndex)[ih] = (rod_crc >> ih & 0x1);
1566
1567 if (dqStatus) {
1568 m_DMUHeadparityErrVec.at(drawerIndex)[ih] = dqStatus->checkHeaderParityErr(ros, drawer, ih, 0);
1569 m_DMUDataparityErrVec.at(drawerIndex)[ih] = dqStatus->checkSampleParityErr(ros, drawer, ih, 0);
1570 }
1571 }
1572
1573 m_slinkCRCVec.at(drawerIndex)[0] = (digitsCollection->getFragCRC() >> 16) & 0xffff;
1574 m_dmuMaskVec.at(drawerIndex)[0] = (digitsCollection->getFragDMUMask() >> 16) & 0xffff;
1575 m_slinkCRCVec.at(drawerIndex)[1] = digitsCollection->getFragCRC() & 0xffff;
1576 m_dmuMaskVec.at(drawerIndex)[1] = digitsCollection->getFragDMUMask() & 0xffff;
1577
1578 int nSamplesInDrawer = m_nSamplesInDrawer[drawerIndex];
1579
1580 int dcnt = 0;
1581 // go through all TileDigits in collection
1582 for (const TileDigits* tile_digits : *digitsCollection) {
1583 emptyColl = false;
1584
1585 HWIdentifier hwid = tile_digits->adc_HWID();
1586 // determine channel
1587 channel = m_tileHWID->channel(hwid);
1588 // cabling for testbeam
1589 if ((m_TBperiod < 2015 ||
1590 (m_TBperiod==2015 && fragType<3) ||
1591 ((m_TBperiod==2016 || m_TBperiod==2021) && ((fragId&0xFF)<4 && fragId != 0x201)) ||
1592 (m_TBperiod==2017 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x203))) ||
1593 (m_TBperiod==2018 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x402))) ||
1594 (m_TBperiod==2019 && ((fragId&0xFF)<5 && !(fragId == 0x201 || fragId == 0x203 || fragId >= 0x402))) ||
1595 (m_TBperiod==2022 && ((fragId&0xFF)<4 && !(fragId == 0x201 || (m_run >= 2210456 && fragId == 0x402)))))
1596 && fragType > 0 && m_pmtOrder)
1597 channel = digiChannel2PMT(fragType, channel);
1598
1599 // gain
1600 m_gainVec.at(drawerIndex)[channel] = m_tileHWID->adc(hwid);
1601 ATH_MSG_DEBUG( "Storing TD for channel: " << channel
1602 << " with gain " << m_tileHWID->adc(hwid) );
1603
1604 // get digits
1605 sampleVec = tile_digits->samples();
1606 int siz = sampleVec.size();
1607 if (msgLvl(MSG::DEBUG)) {
1608 msg(MSG::DEBUG) << "Digits(" << siz << ")." << (dcnt++) << " {";
1609
1610 for (int i = 0; i < siz; i++) {
1611 msg(MSG::DEBUG) << static_cast<int>(sampleVec[i]) << " ";
1612 }
1613
1614 if (siz > nSamplesInDrawer) {
1615 msg(MSG::DEBUG) << "} ONLY " << nSamplesInDrawer << " digits saved to ntuple" << endmsg;
1616 } else {
1617 msg(MSG::DEBUG) << "}" << endmsg;
1618 }
1619 }
1620
1621 if (siz > nSamplesInDrawer) siz = nSamplesInDrawer;
1622 std::transform(sampleVec.begin(), sampleVec.begin() + siz, &m_sampleVec.at(drawerIndex).get()[0] + nSamplesInDrawer * channel, [] (float v) {return static_cast<int>(v);});
1623 }
1624 }
1625 }
1626 // next container
1627 }
1628
1629 if (emptyColl)
1630 return StatusCode::FAILURE;
1631 else
1632 return StatusCode::SUCCESS;
1633}
1634
1635
1636StatusCode TileTBAANtuple::storeDigitsFlx(const EventContext& ctx, const SG::ReadHandleKey<TileDigitsContainer>& containerKey) {
1637
1638 if (containerKey.empty()) { // empty name, nothing to do
1639 return StatusCode::FAILURE;
1640 }
1641
1642 // Read Digits from TES
1643 const TileDigitsContainer* digitsCntFlx = SG::makeHandle (containerKey, ctx).get();
1644
1645 bool emptyColl = true;
1646
1647 // drawerIndex is 0 - m_nDrawersFlx-1, fragType is 1-4 B+/B-/EB+/EB-
1648 int drawerIndex, channel;
1649
1650 std::vector<float> sampleVecLo;
1651 std::vector<float> sampleVecHi;
1652 // Go through all TileDigitsCollections
1653 for (const TileDigitsCollection* digitsCollection : *digitsCntFlx) {
1654 // determine type of frag
1655 int fragId = digitsCollection->identify();
1656 drawerMap_iterator itr = m_drawerFlxMap.find(fragId);
1657 if ( itr != m_drawerFlxMap.end() ) {
1658 drawerIndex = (*itr).second;
1659 } else {
1660 drawerIndex = -1;
1661 }
1662
1663 if (drawerIndex < 0) {
1664 if ( !digitsCollection->empty() )
1665 ATH_MSG_DEBUG( "FELIX frag id 0x" << MSG::hex << fragId << MSG::dec <<" was not found among valid frag IDs when storing TRC!" );
1666
1667 } else {
1668
1669 ATH_MSG_DEBUG( "Event# " << m_evtNr
1670 << " FELIX Frag id 0x" << MSG::hex << fragId << MSG::dec
1671 << " index " << drawerIndex);
1672
1673 ATH_MSG_DEBUG( " Size=" << digitsCollection->getFragSize());
1674
1675 ATH_MSG_DEBUG( " Lvl1ID=" << digitsCollection->getLvl1Id()
1676 << " EvBCID=" << digitsCollection->getRODBCID()
1677 << " EvType=" << digitsCollection->getDetEvType() );
1678 ATH_MSG_DEBUG( " Headers = "<< digitsCollection->getFragExtraWords() );
1679
1680 if (m_completeNtuple) {
1685 int index = drawerIndex + m_nDrawers;
1686 m_l1ID.at(index) = digitsCollection->getLvl1Id();
1687 m_l1Type.at(index) = digitsCollection->getLvl1Type();
1688 m_evType.at(index) = digitsCollection->getDetEvType();
1689 m_evBCID.at(index) = digitsCollection->getRODBCID();
1690 // store FrBCID
1691 m_frBCID.at(index) = digitsCollection->getFragBCID();
1692 }
1693
1694 // Digits in calib mode
1695 // check gain for first digits in collection
1696
1697
1698 std::vector<uint32_t> extraWords = digitsCollection->getFragExtraWords();
1699 if (extraWords.size() >= 10 * MAX_MINIDRAWER) {
1700
1701 std::reference_wrapper<std::array<int,MAX_MINIDRAWER>>
1702 md[] = {m_mdL1idflxVec.at(drawerIndex), m_mdBcidflxVec.at(drawerIndex),
1703 m_mdModuleflxVec.at(drawerIndex), m_mdRunTypeflxVec.at(drawerIndex),
1704 m_mdRunflxVec.at(drawerIndex), m_mdPedLoflxVec.at(drawerIndex),
1705 m_mdPedHiflxVec.at(drawerIndex), m_mdChargeflxVec.at(drawerIndex),
1706 m_mdChargeTimeflxVec.at(drawerIndex), m_mdCapacitorflxVec.at(drawerIndex)};
1707
1708 auto it = extraWords.begin();
1709 for (int i = 0; i < 10; ++i) {
1710 std::copy(it + i * MAX_MINIDRAWER, it + (i + 1) * MAX_MINIDRAWER, &md[i].get()[0]);
1711 }
1712
1713 }
1714
1715 int dcnt=0;
1716 // non empty collection
1717 if(!digitsCollection->empty()) {
1718 int drawerIndexHi = drawerIndex + m_nDrawersFlx;
1719 // store evtnr, bcid,crc, size
1720 if (m_bsInput) {
1721 m_rodBCIDflxVec.at(drawerIndex) = digitsCollection->getRODBCID();
1722 m_sizeflxVec.at(drawerIndex) = digitsCollection->getFragSize();
1723 m_evtflxVec.at(drawerIndex) = m_evtNr;
1724 }
1725
1726 // go through all TileDigits in collection
1727 for (const TileDigits* tile_digits : *digitsCollection) {
1728 emptyColl = false;
1729 HWIdentifier hwid = tile_digits->adc_HWID();
1730 // determine gain
1731 int gain = m_tileHWID->adc(hwid);
1732 // add m_nDrawersFlx to index if hi gain
1733 int index = (gain == 1) ? drawerIndexHi : drawerIndex;
1734
1735 // determine channel
1736 channel = m_tileHWID->channel(hwid);
1737 // cabling for testbeam (convert to pmt#-1)
1738
1739 // gain determined for all digits in collection
1740 m_gainflxVec.at(index)[channel] = gain;
1741 ATH_MSG_DEBUG( "Storing TD for channel: " << channel
1742 << " with gain " << m_tileHWID->adc(hwid)
1743 << " index " << index );
1744
1745 // get digits
1746 if (gain == 0) {
1747 sampleVecLo = tile_digits->samples();
1748 } else if (gain == 1) {
1749 sampleVecHi = tile_digits->samples();
1750 }
1751
1752 int sizLo = sampleVecLo.size();
1753 int sizHi = sampleVecHi.size();
1754
1755 int nSamplesInDrawer = m_nSamplesFlxInDrawer[index];
1756
1757 if (msgLvl(MSG::DEBUG)) {
1758 if (sizLo > 0 ){
1759 msg(MSG::DEBUG) << "Low gain Digits(" << sizLo << ")." << (dcnt++) << " {";
1760 for (int i = 0; i < sizLo; i++) {
1761 msg(MSG::DEBUG) << static_cast<int>(sampleVecLo[i]) << " ";
1762 }
1763
1764 if (sizLo > nSamplesInDrawer) {
1765 msg(MSG::DEBUG) << "} ONLY " << nSamplesInDrawer << " digits saved to ntuple" << endmsg;
1766 } else {
1767 msg(MSG::DEBUG) << "}" << endmsg;
1768 }
1769 }
1770
1771 if (sizHi > 0 ){
1772 msg(MSG::DEBUG) << "High gain Digits(" << sizHi << ")." << (dcnt++) << " {";
1773 for (int i = 0; i < sizHi; i++) {
1774 msg(MSG::DEBUG) << static_cast<int>(sampleVecHi[i]) << " ";
1775 }
1776
1777 if (sizHi > nSamplesInDrawer) {
1778 msg(MSG::DEBUG) << "} ONLY " << nSamplesInDrawer << " digits saved to ntuple" << endmsg;
1779 } else {
1780 msg(MSG::DEBUG) << "}" << endmsg;
1781 }
1782 }
1783
1784
1785 }
1786 if (sizLo > nSamplesInDrawer) sizLo = nSamplesInDrawer;
1787 if (sizHi > nSamplesInDrawer) sizHi = nSamplesInDrawer;
1788 std::transform(sampleVecLo.begin(), sampleVecLo.begin() + sizLo, &m_sampleflxVec.at(index).get()[0] + nSamplesInDrawer * channel, [] (float v) {return static_cast<int>(v);});
1789 std::transform(sampleVecHi.begin(), sampleVecHi.begin() + sizHi, &m_sampleflxVec.at(index).get()[0] + nSamplesInDrawer * channel, [] (float v) {return static_cast<int>(v);});
1790 sampleVecLo.clear();
1791 sampleVecHi.clear();
1792 }
1793 }
1794 }
1795 // next container
1796 }
1797
1798 if (emptyColl)
1799 return StatusCode::FAILURE;
1800 else
1801 return StatusCode::SUCCESS;
1802}
1803
1804
1805/*
1808 */
1809StatusCode TileTBAANtuple::storeHitVector(const EventContext& ctx) {
1810
1811 if (m_hitVectorKey.empty()) { // empty name, nothing to do
1812 return StatusCode::FAILURE;
1813 }
1814
1815 // Read Hit Vector from TDS
1816 const TileHitVector* hitVec = SG::makeHandle (m_hitVectorKey, ctx).get();
1817
1818 ATH_MSG_DEBUG( "Event# " << m_evtNr << " reading Hit Vector");
1819
1821 ATH_CHECK( samplingFraction.isValid() );
1822
1823 // Go through all TileHit
1824 for (const TileHit& cinp : *hitVec) {
1825
1826 // get hits
1827 HWIdentifier hwid = cinp.pmt_HWID();
1828
1829 // determine type of frag
1830 int fragId = m_tileHWID->frag(hwid);
1831 drawerMap_iterator itr = m_drawerMap.find(fragId);
1832 int drawerIndex = ( itr != m_drawerMap.end() ) ? static_cast<int>((*itr).second) : -1;
1833
1834 if (drawerIndex < 0) {
1835 ATH_MSG_WARNING( "frag id 0x" << MSG::hex << fragId << MSG::dec <<" was not found among valid frag IDs when storing HITS!" );
1836
1837 } else {
1838 int fragType = m_drawerType[drawerIndex];
1839 storeHit(&cinp,fragType,fragId,m_ehitVec.at(drawerIndex),m_thitVec.at(drawerIndex), *samplingFraction);
1840 }
1841 }
1842
1843 if (hitVec->empty())
1844 return StatusCode::FAILURE;
1845 else
1846 return StatusCode::SUCCESS;
1847}
1848
1849
1853 */
1854StatusCode TileTBAANtuple::storeHitContainer(const EventContext& ctx) {
1855
1856 if (m_hitContainerKey.empty()) { // empty name, nothing to do
1857 return StatusCode::FAILURE;
1858 }
1859
1860 // Read Hit Vector from TDS
1861 const TileHitContainer* hitCnt = SG::makeHandle (m_hitContainerKey, ctx).get();
1862
1864 ATH_CHECK( samplingFraction.isValid() );
1865
1866 bool emptyColl = true;
1867
1868 // Go through all TileHitCollections
1869 for (const TileHitCollection* hitCollection : *hitCnt) {
1870
1871 // determine type of frag
1872 int fragId = hitCollection->identify();
1873 drawerMap_iterator itr = m_drawerMap.find(fragId);
1874 int drawerIndex = ( itr != m_drawerMap.end() ) ? static_cast<int>((*itr).second) : -1;
1875
1876 if (drawerIndex < 0) {
1877 if ( !hitCollection->empty() )
1878 ATH_MSG_WARNING( "frag id 0x" << MSG::hex << fragId << MSG::dec <<" was not found among valid frag IDs when storing HITS!" );
1879
1880 } else {
1881 int fragType = m_drawerType[drawerIndex];
1882
1883 ATH_MSG_DEBUG( "Event# " << m_evtNr
1884 << " Frag id 0x" << MSG::hex << fragId << MSG::dec
1885 << " index " << drawerIndex );
1886
1887 if (emptyColl) emptyColl = hitCollection->empty();
1888 // go through all TileHit in collection
1889 for (const TileHit* cinp : *hitCollection) {
1890 storeHit(cinp,fragType,fragId,m_ehitCnt.at(drawerIndex),m_thitCnt.at(drawerIndex),*samplingFraction);
1891 }
1892 }
1893 }
1894
1895 if (emptyColl)
1896 return StatusCode::FAILURE;
1897 else
1898 return StatusCode::SUCCESS;
1899}
1900
1901void TileTBAANtuple::storeHit(const TileHit *cinp, int fragType, int fragId,
1902 std::array<float, MAX_CHAN>& ehitVec,
1903 std::array<float, MAX_CHAN>& thitVec,
1904 const TileSamplingFraction* samplingFraction) {
1905
1906 // determine channel
1907 HWIdentifier hwid = cinp->pmt_HWID();
1908 int channel = m_tileHWID->channel(hwid);
1909
1910 int size = cinp->size();
1911 if (msgLvl(MSG::VERBOSE)) {
1912 msg(MSG::VERBOSE) << "hit hwid="
1913 << m_tileHWID->to_string(hwid, -1) << " ener=";
1914
1915 for (int i = 0; i < size; ++i)
1916 msg(MSG::VERBOSE) << cinp->energy(i) << " ";
1917
1918 msg(MSG::VERBOSE) << "time=";
1919 for (int i = 0; i < size; ++i)
1920 msg(MSG::VERBOSE) << cinp->time(i) << " ";
1921
1922 msg(MSG::VERBOSE) << endmsg;
1923 }
1924
1925 double ehit=0.0, thit=0.0;
1926 for(int i=0;i<size;++i) {
1927
1928 double e = cinp->energy(i);
1929 double t = cinp->time(i);
1930
1931 if (-75.<t && t<75.) {
1932 ehit += e;
1933 thit += e*t;
1934 }
1935 }
1936
1937 if (ehit!=0) {
1938 thit /= ehit;
1939 // conversion factor from hit energy to final energy units
1940 int drawerIdx = TileCalibUtils::getDrawerIdxFromFragId(fragId);
1941 ehit *= samplingFraction->getSamplingFraction(drawerIdx, channel);
1943 ehit /= m_tileToolEmscale->channelCalib(drawerIdx, channel, TileID::HIGHGAIN, 1.,
1945 }
1946 } else {
1947 thit=0.0;
1948 }
1949
1950 // cabling for testbeam
1951 if ((m_TBperiod < 2015 ||
1952 (m_TBperiod==2015 && fragType<3) ||
1953 ((m_TBperiod==2016 || m_TBperiod==2021) && ((fragId&0xFF)<4 && fragId != 0x201)) ||
1954 (m_TBperiod==2017 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x203))) ||
1955 (m_TBperiod==2018 && ((fragId&0xFF)<4 && !(fragId == 0x201 || fragId == 0x402))) ||
1956 (m_TBperiod==2019 && ((fragId&0xFF)<5 && !(fragId == 0x201 || fragId == 0x203 || fragId >= 0x402))) ||
1957 (m_TBperiod==2022 && ((fragId&0xFF)<4 && !(fragId == 0x201 || (m_run >= 2210456 && fragId == 0x402)))))
1958 && fragType > 0 && m_pmtOrder)
1959 channel = digiChannel2PMT(fragType, channel);
1960
1961 ehitVec[channel] = ehit;
1962 thitVec[channel] = thit;
1963
1964 ATH_MSG_DEBUG( "HIT ene=" << ehit
1965 << " time=" << thit
1966 << " pmt-1=" << channel
1967 << " index " << m_drawerMap.at(fragId) );
1968
1969}
1971
1973
1976 }
1977
1980 if (m_TBperiod > 2015) QDC_clearBranch();
1981 }
1982
1984
1985 if (m_unpackAdder) {
1988 }
1989 }
1990
1991 if (m_beamIdList[DIGI_PAR_FRAG & 0x1F]) {
1993 }
1994
1995 if (((m_TBperiod >= 2015 || m_unpackAdder) && m_beamIdList[BEAM_ADC_FRAG])
1997 || (m_TBperiod >= 2022 && m_beamIdList[COMMON_TOF_FRAG])) {
1999 ATH_MSG_VERBOSE( "clear branch");
2000 }
2001
2002 if (m_completeNtuple && m_TBperiod < 2015) {
2004 }
2005
2007
2008 DIGI_clearBranch(); // working now
2009 if (m_saveFelixData) {
2011 }
2012
2014 ATH_MSG_DEBUG( "clear() successfully" );
2015
2016 return StatusCode::SUCCESS;
2017}
2018
2019
2021 MsgStream log(msgSvc(), name());
2022
2023 m_evtVec.clear();
2024 m_bcidVec.clear();
2025 m_DMUheaderVec.clear();
2026 m_DMUformatErrVec.clear();
2027 m_DMUparityErrVec.clear();
2028 m_DMUmemoryErrVec.clear();
2029 m_DMUDstrobeErrVec.clear();
2030 m_DMUSstrobeErrVec.clear();
2031 m_DMUHeadparityErrVec.clear();
2032 m_DMUDataparityErrVec.clear();
2033 m_rodBCIDVec.clear();
2034 m_sizeVec.clear();
2035 m_dmuMaskVec.clear();
2036 m_slinkCRCVec.clear();
2037 m_gainVec.clear();
2038 m_sampleVec.clear();
2039 m_feCRCVec.clear();
2040 m_rodCRCVec.clear();
2041
2042 m_evtflxVec.clear();
2043 m_rodBCIDflxVec.clear();
2044 m_sizeflxVec.clear();
2045 m_gainflxVec.clear();
2046 m_sampleflxVec.clear();
2047
2048 m_eneVec.clear();
2049 m_timeVec.clear();
2050 m_pedFlatVec.clear();
2051 m_chi2FlatVec.clear();
2052
2053 m_efitVec.clear();
2054 m_tfitVec.clear();
2055 m_pedfitVec.clear();
2056 m_chi2Vec.clear();
2057
2058 m_efitcVec.clear();
2059 m_tfitcVec.clear();
2060 m_pedfitcVec.clear();
2061 m_chi2cVec.clear();
2062
2063 m_eOptVec.clear();
2064 m_tOptVec.clear();
2065 m_pedOptVec.clear();
2066 m_chi2OptVec.clear();
2067
2068 m_eflxfitVec.clear();
2069 m_tflxfitVec.clear();
2070 m_pedflxfitVec.clear();
2071 m_chi2flxfitVec.clear();
2072
2073 m_eflxoptVec.clear();
2074 m_tflxoptVec.clear();
2075 m_pedflxoptVec.clear();
2076 m_chi2flxoptVec.clear();
2077
2078 m_eDspVec.clear();
2079 m_tDspVec.clear();
2080 m_chi2DspVec.clear();
2081
2082 m_ROD_GlobalCRCVec.clear();
2083 m_ROD_DMUBCIDVec.clear();
2084 m_ROD_DMUmemoryErrVec.clear();
2085 m_ROD_DMUSstrobeErrVec.clear();
2086 m_ROD_DMUDstrobeErrVec.clear();
2089 m_ROD_DMUMaskVec.clear();
2090
2091 //Ntuple creation
2092
2093 auto tree = std::make_unique<TTree>(m_ntupleID.value().c_str(), "TileBEAM-Ntuple");
2094 tree->SetMaxTreeSize(m_treeSize);
2095 m_ntuplePtr = tree.get();
2096 if (m_thistSvc->regTree("/" + m_streamName + "/" + m_ntupleID, std::move(tree)).isFailure()) {
2097 ATH_MSG_ERROR( "Problem registering TileRec Tree" );
2098 m_ntupleCreated = false;
2099 } else {
2100 m_ntupleCreated = true;
2101 }
2102
2105
2106 if (m_TBperiod < 2015) {
2112 }
2113
2114 if (m_TBperiod > 2015) {
2115 QDC_addBranch();
2116 }
2117
2120 DIGI_addBranch(); //working now
2121 if (m_saveFelixData) {
2123 }
2124
2125 HIT_addBranch();
2126
2127 return StatusCode::SUCCESS;
2128}
2129
2130StatusCode TileTBAANtuple::storeCells(const EventContext& ctx) {
2131
2132 if (m_cellContainerKey.empty()) { // empty name, nothing to do
2133 return StatusCode::FAILURE;
2134 }
2135
2136 //Retrieve Cell collection from SG
2137 const CaloCellContainer* cellContainer = SG::makeHandle (m_cellContainerKey, ctx).get();
2138
2139 //Loop over all cells in container. Sum up the Energy and fill 2DHistograms
2140 ATH_MSG_DEBUG( "succeeded retrieving cellContainer from SG" );
2141
2142 ATH_MSG_DEBUG( "TileTBAANtuple : about to iterate over CaloCells" );
2143
2144 m_LarEne[0] = m_LarEne[1] = m_LarEne[2] = m_LarEne[3] = 0.0;
2145 m_BarEne[0] = m_BarEne[1] = m_BarEne[2] = 0.0;
2146 m_ExtEne[0] = m_ExtEne[1] = m_ExtEne[2] = 0.0;
2147 m_GapEne[0] = m_GapEne[1] = m_GapEne[2] = 0.0;
2148
2149 for (const CaloCell* cell : *cellContainer) {
2150 //Decode cell information
2151 const double energy = cell->energy();
2152 const CaloDetDescrElement* caloDDE = cell->caloDDE(); //pointer to the DetectorDescriptionElement
2153 const CaloCell_ID::CaloSample sampl = caloDDE->getSampling(); //To which sampling belongs this cell?
2154
2155 if (sampl == CaloCell_ID::PreSamplerB) {
2156 m_LarEne[0] += energy;
2157 } else if (sampl == CaloCell_ID::EMB1) {
2158 m_LarEne[1] += energy;
2159 } else if (sampl == CaloCell_ID::EMB2) {
2160 m_LarEne[2] += energy;
2161 } else if (sampl == CaloCell_ID::EMB3) {
2162 m_LarEne[3] += energy;
2163 } else if (sampl == CaloCell_ID::TileBar0) {
2164 m_BarEne[0] += energy;
2165 } else if (sampl == CaloCell_ID::TileBar1) {
2166 m_BarEne[1] += energy;
2167 } else if (sampl == CaloCell_ID::TileBar2) {
2168 m_BarEne[2] += energy;
2169 } else if (sampl == CaloCell_ID::TileExt0) {
2170 m_ExtEne[0] += energy;
2171 } else if (sampl == CaloCell_ID::TileExt1) {
2172 m_ExtEne[1] += energy;
2173 } else if (sampl == CaloCell_ID::TileExt2) {
2174 m_ExtEne[2] += energy;
2175 } else if (sampl == CaloCell_ID::TileGap1) {
2176 m_GapEne[1] += energy;
2177 } else if (sampl == CaloCell_ID::TileGap2) {
2178 m_GapEne[2] += energy;
2179 } else if (sampl == CaloCell_ID::TileGap3) {
2180 m_GapEne[0] += energy;
2181 }
2182 }
2183
2184 return StatusCode::SUCCESS;
2185}
2186
2187
2188
2189StatusCode TileTBAANtuple::initList(const EventContext& ctx) {
2190
2191 unsigned int size = m_drawerList.size();
2192
2193 if (size > 0) {
2194
2195 if (m_digitsContainerKey.empty()) { // empty name, nothing to do
2196
2197 ATH_MSG_WARNING( "can't retrieve Digits from TDS" );
2198 ATH_MSG_WARNING( "can't set up fragment list for ntuple" );
2199
2200 if (m_nSamples != 0) {
2201 ATH_MSG_WARNING( "Disable digit samples in ntuple" );
2202 m_nSamples = 0;
2203 }
2204
2205 return StatusCode::SUCCESS;
2206 }
2207
2208 // Read Digits from TES
2209 const TileDigitsContainer* digitsCnt = SG::makeHandle (m_digitsContainerKey, ctx).get();
2210
2211 int frag = strtol(m_drawerList[0].data(), NULL, 0);
2212 if (frag < 0) { // setup frags IDs from the data
2213
2214 std::vector<unsigned int> frags;
2215 // Go through all TileDigitsCollections
2216 for (const TileDigitsCollection* digitsCollection : *digitsCnt) {
2217 if (!digitsCollection->empty()) {
2218 // determine type of frag
2219 frags.push_back(digitsCollection->identify());
2220 }
2221 }
2222 size = frags.size();
2223
2224 if (size > 0) {
2225
2226 if (size < m_nDrawers) {
2227 ATH_MSG_INFO( "decreasing m_nDrawers from " << m_nDrawers << " to " << size );
2228 m_nDrawers = size;
2229 }
2230
2231 unsigned int rosOrder[5] = { 2, 1, 3, 4, 0 };
2232 unsigned int dr = 0;
2233 char frg[6] = "0x000";
2234
2235 m_drawerList.clear();
2236 // m_drawerType.clear();
2237 m_drawerMap.clear();
2238
2239 msg(MSG::INFO) << "setting drawerList from data " << MSG::hex;
2240 for (unsigned int ir = 0; ir < 5; ++ir) {
2241 for (unsigned int i = 0; i < size; ++i) {
2242 unsigned int frag = frags[i];
2243 if (frag >> 8 == rosOrder[ir]) {
2244 sprintf(frg, "0x%3.3x", frag);
2245 m_drawerList.value().push_back((std::string) frg);
2246 if (dr == m_drawerType.size()) m_drawerType.value().push_back(frag >> 8);
2247 m_drawerMap[frag] = dr;
2248 msg(MSG::INFO) << " 0x" << frag;
2249 ++dr;
2250 }
2251 }
2252 }
2253
2254 msg(MSG::INFO) << MSG::dec << endmsg;
2255
2256 size = m_drawerType.size();
2257 if (size < m_nDrawers) {
2258 m_drawerType.value().resize(m_nDrawers);
2259 for (; size < m_nDrawers; ++size)
2260 m_drawerType[size] = 0;
2261 }
2262
2263 msg(MSG::INFO) << MSG::INFO << "drawerType ";
2264 for (unsigned int dr = 0; dr < size; ++dr)
2265 msg(MSG::INFO) << " " << m_drawerType[dr];
2266 msg(MSG::INFO) << endmsg;
2267
2268 if (size > m_nDrawers) {
2269 ATH_MSG_INFO( "increasing m_nDrawers from " << m_nDrawers << " to " << size );
2270 m_nDrawers = size;
2271 }
2272
2273 if (size < 1) size = 1;
2274 if (m_eventsPerFile == 0) {
2275 m_eventsPerFile = static_cast<int>(200 / size) * 1000;
2276 ATH_MSG_INFO( "Number of events per file was 0, set it to 200k/" << size << " = " << m_eventsPerFile );
2277 }
2278
2279 } else {
2280
2281 ATH_MSG_ERROR( "can't find any TileDigits collections" );
2282 ATH_MSG_ERROR( "can't set up fragment list for ntuple" );
2283 }
2284 }
2285
2286 // once again - check number of samples in the data
2287 // but do not print any ERRORs now
2288
2289 // Go through all TileDigitsCollections
2290 for (const TileDigitsCollection* digitsCollection : *digitsCnt) {
2291 if (!digitsCollection->empty()) {
2292 int siz = digitsCollection->front()->samples().size();
2293 m_nSamplesInDrawerMap[digitsCollection->identify()] = siz;
2294 if (siz > m_nSamples && m_nSamples != 0) {
2295 ATH_MSG_WARNING( "Increasing number of digit samples in ntuple from " << m_nSamples << " to " << siz );
2296 m_nSamples = siz;
2297 }
2298 }
2299 }
2300 }
2301
2302 return StatusCode::SUCCESS;
2303}
2304
2305
2306StatusCode TileTBAANtuple::initListFlx(const EventContext& ctx) {
2307
2308 unsigned int listSize = m_drawerList.size();
2309
2310 if (listSize > 0) {
2311
2312 if (m_digitsContainerFlxKey.empty()) { // empty name, nothing to do
2313
2314 ATH_MSG_WARNING( "can't retrieve FELIX Digits from TDS" );
2315 ATH_MSG_WARNING( "can't set up FELIX fragment list for ntuple" );
2316
2317 if (m_nSamples != 0) {
2318 ATH_MSG_WARNING( "Disable FELIX digit samples in ntuple" );
2319 m_nSamplesFlx = 0;
2320 }
2321
2322 return StatusCode::SUCCESS;
2323 }
2324
2325 // Read Digits from TES
2326 const TileDigitsContainer* digitsCntFlx = SG::makeHandle (m_digitsContainerFlxKey, ctx).get();
2327
2328 if (listSize == m_nDrawers) {
2329 // Only legacy drawers in the list, setup FELIX frags IDs from the data
2330
2331 std::vector<unsigned int> frags;
2332 // Go through all TileDigitsCollections
2333 for (const TileDigitsCollection* digitsCollection : *digitsCntFlx) {
2334 if (!digitsCollection->empty()) {
2335 // Determine type of frag
2336 frags.push_back(digitsCollection->identify());
2337 }
2338 }
2339
2340 unsigned int nFrags = frags.size();
2341
2342 if (nFrags > 0) {
2343
2344 if (nFrags != m_nDrawersFlx) {
2345 ATH_MSG_INFO( "changing m_nDrawersFlx from " << m_nDrawersFlx.value() << " to " << nFrags );
2346 m_nDrawersFlx = nFrags;
2347 }
2348
2349 m_drawerFlxMap.clear();
2350
2351 std::ostringstream os;
2352 os << "setting FELIX drawers from data " << std::hex;
2353 unsigned int drawerIndex = 0;
2354 for (unsigned int frag : frags) {
2355 m_drawerFlxMap[frag] = drawerIndex;
2356 os << " 0x" << frag;
2357 ++drawerIndex;
2358 }
2359 os << std::dec;
2360
2361 ATH_MSG_INFO(os.str());
2362
2363 if (m_eventsPerFile == 0) {
2364 int nDrawersAll = m_nDrawers.value() + m_nDrawersFlx.value();
2365 m_eventsPerFile = static_cast<int>(200 / nDrawersAll) * 1000;
2366 ATH_MSG_INFO( "Number of events per file was 0, set it to 200k/" << nDrawersAll << " = " << m_eventsPerFile );
2367 }
2368
2369 } else {
2370 ATH_MSG_ERROR( "can't find any FELIX TileDigits collections" );
2371 ATH_MSG_ERROR( "can't set up FELIX fragment list for ntuple" );
2372 }
2373 }
2374
2375
2376 // once again - check number of samples in the data
2377 // but do not print any ERRORs now
2378
2379 for (const TileDigitsCollection* digitsCollection : *digitsCntFlx) {
2380 if (!digitsCollection->empty()) {
2381 int siz = digitsCollection->front()->samples().size();
2382 m_nSamplesFlxInDrawerMap[digitsCollection->identify()] = siz;
2383 if (siz > m_nSamplesFlx && m_nSamplesFlx != 0) {
2384 ATH_MSG_WARNING( "Increasing number of FELIX digit samples in ntuple from " << m_nSamplesFlx << " to " << siz );
2385 m_nSamplesFlx = siz;
2386 }
2387 }
2388 }
2389 }
2390
2391 return StatusCode::SUCCESS;
2392}
2393
2394
2395
2398
2399 // Get eta from an ASCII file with the following structure :
2400 // runnumber eta
2401
2402 ATH_MSG_INFO( "Get eta for run " << m_runNumber );
2403
2404 // Find the full path to filename:
2405 std::string fileName = PathResolver::find_file(m_etaFileName, "DATAPATH");
2406 ATH_MSG_INFO( "Reading file " << fileName );
2407
2408 if (fileName.size() == 0) {
2409
2410 ATH_MSG_WARNING( "Could not find input file " << m_etaFileName );
2411 ATH_MSG_WARNING( "Skip reading of eta value " );
2412
2413 } else {
2414
2415 std::ifstream etafile;
2416 etafile.open(fileName.c_str());
2417
2418 if (etafile.good()) {
2419
2420 int runNumber = 0;
2421 float eta = 0;
2422 //coverity[TAINTED_SCALAR]
2423 while ((runNumber != m_runNumber) && (!etafile.eof())) {
2424 etafile >> runNumber >> eta;
2425 }
2426
2427 if (runNumber != m_runNumber) {
2428 ATH_MSG_INFO( "Run " << m_runNumber << " has not been found, keep eta and theta at zero" );
2429
2430 m_eta = m_theta = 0.0;
2431 } else {
2432 m_eta = eta;
2433 m_theta = (M_PI_2 - 2 * atan(exp(m_eta)));
2434 ATH_MSG_INFO( "Run " << m_runNumber << " has been found with eta=" << m_eta << ", theta =" << m_theta );
2435
2436 }
2437
2438 } else {
2439
2440 ATH_MSG_WARNING( "Problem with file " << fileName );
2441 ATH_MSG_WARNING( "Skip reading of eta value " );
2442
2443 }
2444
2445 etafile.close();
2446 }
2447}
2448
2451//
2466//
2467*/
2471//
2473*/
2475{
2476
2477 m_ntuplePtr->Branch("EvTime",&m_evTime,"EvTime/I");
2478 m_ntuplePtr->Branch("Run",&m_run,"Run/I");
2479 m_ntuplePtr->Branch("Evt",&m_evt,"Evt/I");
2480 m_ntuplePtr->Branch("Trig",&m_trigType,"Trig/S");
2481 m_ntuplePtr->Branch("DSPflags",&m_dspFlags,"DSPflags/I");
2482 m_ntuplePtr->Branch("DSPunits",&m_dspUnit,"DSPunits/S");
2483 m_ntuplePtr->Branch("OFLunits",&m_rchUnit,"OFLunits/S");
2484
2485 if ( m_completeNtuple ) {
2486 int nDrawersAll = m_nDrawers.value() + m_nDrawersFlx.value();
2487 if (nDrawersAll > 0) {
2488 m_l1ID.resize(nDrawersAll + 1);
2489 m_l1Type.resize(nDrawersAll + 1);
2490 m_evType.resize(nDrawersAll + 1);
2491 m_evBCID.resize(nDrawersAll + 1);
2492 m_frBCID.resize(nDrawersAll);
2493 }
2494
2495 // Info from ROD headers
2496 // m_nDrawers drawers separately (i.e. with duplications) + Beam ROD
2497 m_ntuplePtr->Branch("L1ID",&m_l1ID);
2498 m_ntuplePtr->Branch("L1Type",&m_l1Type);
2499 m_ntuplePtr->Branch("EvType",&m_evType);
2500 m_ntuplePtr->Branch("EvBCID",&m_evBCID);
2501 m_ntuplePtr->Branch("FrBCID",&m_frBCID);
2502 }
2503
2504
2505}
2506
2510//
2512*/
2514{
2515
2518 {
2519 m_ntuplePtr->Branch("MuBackHit",&m_muBackHit,"MuBackHit/F");
2520 m_ntuplePtr->Branch("MuBackSum",&m_muBackSum,"MuBackSum/F");
2521
2522 if (m_TBperiod < 2015) {
2523 m_ntuplePtr->Branch("MuBack",&m_muBack,"m_muBack[14]");
2524 m_ntuplePtr->Branch("MuCalib",&m_muCalib,"m_muCalib[2]");
2525 } else if (m_TBperiod == 2015) {
2526 m_ntuplePtr->Branch("MuBack",&m_muBack,"MuBack[8]/F");
2527 } else {
2528 m_ntuplePtr->Branch("MuBack",&m_muBack,"MuBack[12]/F");
2529 }
2530 }
2531
2532
2533}
2534
2538//
2540*/
2542{
2543
2545 m_ntuplePtr->Branch("Ecal",&m_ecal,"m_ecal[8]/F");
2546 }
2547
2548}
2549
2553//
2555*/
2557{
2558
2560 for(unsigned i=0; i<33; ++i){ m_qdc[i]=0.0; }
2561 m_ntuplePtr->Branch("qdc", &m_qdc, "qdc[33]/i");
2562 }
2563
2564}
2565
2566
2569//Clear Tree TRIGGER variables
2570//
2572*/
2574
2575 m_evTime = 0;
2576 m_run = 0;
2577 m_evt = 0;
2578 m_trigType = 0;
2579
2580 if (m_completeNtuple) {
2581 std::fill(m_l1ID.begin(), m_l1ID.end(), 0);
2582 std::fill(m_l1Type.begin(), m_l1Type.end(), 0);
2583 std::fill(m_evType.begin(), m_evType.end(), 0);
2584 std::fill(m_evBCID.begin(), m_evBCID.end(), 0);
2585 std::fill(m_frBCID.begin(), m_frBCID.end(), 0);
2586 }
2587}
2588
2591//Clear Tree MUON variables
2592//
2594*/
2596 m_muBackHit = 0.;
2597 m_muBackSum = 0.;
2598
2599}
2600
2603//Clear Tree ECAL variables
2604//
2606*/
2608{
2609
2610}
2611
2614//Clear Tree QDC variables
2615//
2617*/
2619{
2620 for(unsigned i=0; i<33; ++i){ m_qdc[i]=0.0; }
2621}
2622
2623
2627//
2629*/
2631
2632 if (!m_laserObjectKey.empty() > 0) {
2633
2634 m_ntuplePtr->Branch("LASER_BCID", &m_las_BCID, "LASER_BCID/I");
2635
2636 m_ntuplePtr->Branch("LASER_FILTER", &m_las_Filt, "LASER_FILTER/I");
2637 m_ntuplePtr->Branch("LASER_REQAMP", &m_las_ReqAmp, "LASER_REQAMP/D");
2638 m_ntuplePtr->Branch("LASER_MEASAMP", &m_las_MeasAmp, "LASER_MEASAMP/D");
2639
2640 m_ntuplePtr->Branch("LASER_Diode_1_ADC", &m_las_D1_ADC, "LASER_Diode_1_ADC/I");
2641 m_ntuplePtr->Branch("LASER_Diode_2_ADC", &m_las_D2_ADC, "LASER_Diode_2_ADC/I");
2642 m_ntuplePtr->Branch("LASER_Diode_3_ADC", &m_las_D3_ADC, "LASER_Diode_3_ADC/I");
2643 m_ntuplePtr->Branch("LASER_Diode_4_ADC", &m_las_D4_ADC, "LASER_Diode_4_ADC/I");
2644
2645 m_ntuplePtr->Branch("LASER_Diode_1_Ped", &m_las_D1_Ped, "LASER_Diode_1_Ped/D");
2646 m_ntuplePtr->Branch("LASER_Diode_2_Ped", &m_las_D2_Ped, "LASER_Diode_2_Ped/D");
2647 m_ntuplePtr->Branch("LASER_Diode_3_Ped", &m_las_D3_Ped, "LASER_Diode_3_Ped/D");
2648 m_ntuplePtr->Branch("LASER_Diode_4_Ped", &m_las_D4_Ped, "LASER_Diode_4_Ped/D");
2649
2650 m_ntuplePtr->Branch("LASER_Diode_1_Ped_RMS", &m_las_D1_Ped_RMS, "LASER_Diode_1_Ped_RMS/D");
2651 m_ntuplePtr->Branch("LASER_Diode_2_Ped_RMS", &m_las_D2_Ped_RMS, "LASER_Diode_2_Ped_RMS/D");
2652 m_ntuplePtr->Branch("LASER_Diode_3_Ped_RMS", &m_las_D1_Ped_RMS, "LASER_Diode_3_Ped_RMS/D");
2653 m_ntuplePtr->Branch("LASER_Diode_4_Ped_RMS", &m_las_D1_Ped_RMS, "LASER_Diode_4_Ped_RMS/D");
2654
2655 m_ntuplePtr->Branch("LASER_Diode_1_Alpha", &m_las_D1_Alpha, "LASER_Diode_1_Alpha/D");
2656 m_ntuplePtr->Branch("LASER_Diode_2_Alpha", &m_las_D2_Alpha, "LASER_Diode_2_Alpha/D");
2657 m_ntuplePtr->Branch("LASER_Diode_3_Alpha", &m_las_D3_Alpha, "LASER_Diode_3_Alpha/D");
2658 m_ntuplePtr->Branch("LASER_Diode_4_Alpha", &m_las_D4_Alpha, "LASER_Diode_4_Alpha/D");
2659
2660 m_ntuplePtr->Branch("LASER_Diode_1_Alpha_RMS", &m_las_D1_Alpha_RMS, "LASER_Diode_1_Alpha_RMS/D");
2661 m_ntuplePtr->Branch("LASER_Diode_2_Alpha_RMS", &m_las_D2_Alpha_RMS, "LASER_Diode_2_Alpha_RMS/D");
2662 m_ntuplePtr->Branch("LASER_Diode_3_Alpha_RMS", &m_las_D3_Alpha_RMS, "LASER_Diode_3_Alpha_RMS/D");
2663 m_ntuplePtr->Branch("LASER_Diode_4_Alpha_RMS", &m_las_D4_Alpha_RMS, "LASER_Diode_4_Alpha_RMS/D");
2664
2665 m_ntuplePtr->Branch("LASER_Diode_1_AlphaPed", &m_las_D1_AlphaPed, "LASER_Diode_1_AlphaPed/D");
2666 m_ntuplePtr->Branch("LASER_Diode_2_AlphaPed", &m_las_D2_AlphaPed, "LASER_Diode_2_AlphaPed/D");
2667 m_ntuplePtr->Branch("LASER_Diode_3_AlphaPed", &m_las_D3_AlphaPed, "LASER_Diode_3_AlphaPed/D");
2668 m_ntuplePtr->Branch("LASER_Diode_4_AlphaPed", &m_las_D4_AlphaPed, "LASER_Diode_4_AlphaPed/D");
2669
2670 m_ntuplePtr->Branch("LASER_Diode_1_AlphaPed_RMS", &m_las_D1_AlphaPed_RMS, "LASER_Diode_1_AlphaPed_RMS/D");
2671 m_ntuplePtr->Branch("LASER_Diode_2_AlphaPed_RMS", &m_las_D2_AlphaPed_RMS, "LASER_Diode_2_AlphaPed_RMS/D");
2672 m_ntuplePtr->Branch("LASER_Diode_3_AlphaPed_RMS", &m_las_D3_AlphaPed_RMS, "LASER_Diode_3_AlphaPed_RMS/D");
2673 m_ntuplePtr->Branch("LASER_Diode_4_AlphaPed_RMS", &m_las_D4_AlphaPed_RMS, "LASER_Diode_4_AlphaPed_RMS/D");
2674
2675 m_ntuplePtr->Branch("LASER_PMT_1_ADC", &m_las_PMT1_ADC, "LASER_PMT_1_ADC/I");
2676 m_ntuplePtr->Branch("LASER_PMT_2_ADC", &m_las_PMT2_ADC, "LASER_PMT_2_ADC/I");
2677
2678 m_ntuplePtr->Branch("LASER_PMT_1_TDC", &m_las_PMT1_TDC, "LASER_PMT_1_TDC/I");
2679 m_ntuplePtr->Branch("LASER_PMT_2_TDC", &m_las_PMT2_TDC, "LASER_PMT_2_TDC/I");
2680
2681 m_ntuplePtr->Branch("LASER_PMT_1_Ped", &m_las_PMT1_Ped, "LASER_PMT_1_Ped/D");
2682 m_ntuplePtr->Branch("LASER_PMT_2_Ped", &m_las_PMT2_Ped, "LASER_PMT_2_Ped/D");
2683
2684 m_ntuplePtr->Branch("LASER_PMT_1_Ped_RMS", &m_las_PMT1_Ped_RMS, "LASER_PMT_1_Ped_RMS/D");
2685 m_ntuplePtr->Branch("LASER_PMT_2_Ped_RMS", &m_las_PMT2_Ped_RMS, "LASER_PMT_2_Ped_RMS/D");
2686
2687 m_ntuplePtr->Branch("LASER_HEAD_Temp", &m_las_Temperature, "LASER_HEAD_Temp/D");
2688 }
2689
2691 m_ntuplePtr->Branch("LasFlag", &m_lasFlag, "LasFlag/s");
2692 }
2693
2696 m_ntuplePtr->Branch("Las0", &m_las0, "Las0/F");
2697 m_ntuplePtr->Branch("Las1", &m_las1, "Las1/F");
2698 m_ntuplePtr->Branch("Las2", &m_las2, "Las2/F");
2699 m_ntuplePtr->Branch("Las3", &m_las3, "Las3/F");
2700 m_ntuplePtr->Branch("LasExtra", &m_lasExtra, "m_lasExtra[4]/F");
2701 }
2702
2703}
2704
2707//Clear Tree LASER variables
2708//
2710*/
2712{
2713
2714 if (!m_laserObjectKey.empty()) {
2715
2716 m_las_BCID = 0;
2717 m_las_D1_ADC = 0;
2718 m_las_D2_ADC = 0;
2719 m_las_D3_ADC = 0;
2720 m_las_D4_ADC = 0;
2721
2722 m_las_D1_Ped = 0;
2723 m_las_D2_Ped = 0;
2724 m_las_D3_Ped = 0;
2725 m_las_D4_Ped = 0;
2726
2727 m_las_D1_Alpha = 0;
2728 m_las_D2_Alpha = 0;
2729 m_las_D3_Alpha = 0;
2730 m_las_D4_Alpha = 0;
2731
2732 m_las_PMT1_ADC = 0;
2733 m_las_PMT2_ADC = 0;
2734
2735 m_las_PMT1_TDC = 0;
2736 m_las_PMT2_TDC = 0;
2737
2738 m_las_PMT1_Ped = 0;
2739 m_las_PMT2_Ped = 0;
2740 }
2741
2743 m_lasFlag=0;
2744 }
2745
2748
2749 m_las0 = 0.;
2750 m_las1 = 0.;
2751 m_las2 = 0.;
2752 m_las3 = 0.;
2753
2754 }
2755}
2756
2760//
2762*/
2764
2765 if (m_unpackAdder) {
2767 m_adder.resize(16);
2768 m_adderPayload.resize(16*16);
2769 for (int j = 0; j < 16; j++) {
2770 m_adder[j] = m_adderPayload.data() + j * 16;
2771 }
2772
2773 m_ntuplePtr->Branch("Adder", *m_adder.data(), "m_adder[16][16]/I");
2774 m_ntuplePtr->Branch("EneAdd", &m_eneAdd, "m_eneAdd[16]/F");
2775 m_ntuplePtr->Branch("TimeAdd", &m_timeAdd, "m_timeAdd[16]/F");
2776 }
2777 }
2778}
2779
2782//Clear Tree ADDER variables
2783//
2785*/
2787{
2788
2789
2790}
2791
2795//
2797*/
2799
2800 if (m_beamIdList[DIGI_PAR_FRAG & 0x1F]) {
2801
2802 m_ntuplePtr->Branch("cispar", m_cispar, "cispar[16]/I");
2803 }
2804}
2805
2808//Clear Tree CISPAR variables
2809//
2811*/
2813{
2814 memset(m_cispar,-1,sizeof(m_cispar));
2815}
2816
2817
2821//
2823*/
2825
2826 if (((m_TBperiod >= 2015 || m_unpackAdder) && m_beamIdList[BEAM_ADC_FRAG])
2827 || ((!m_unpackAdder || m_TBperiod >= 2022) && m_beamIdList[COMMON_ADC1_FRAG])) {
2828
2829 m_ntuplePtr->Branch("S1cou", &m_s1cou, "S1cou/S");
2830 m_ntuplePtr->Branch("S2cou", &m_s2cou, "S2cou/S");
2831 if (m_TBperiod >= 2016 && m_TBperiod < 2022) {
2832 m_ntuplePtr->Branch("Cher3", &m_s3cou, "Cher3/S"); // dropped S3 in favor of Cher3 in September 2016 TB
2833 // m_ntuplePtr->Branch("SpmFinger", &m_muVeto, "SmpFinger/S"); // muVeto replaced by SPM for testing
2834 m_ntuplePtr->Branch("SiPM1", &m_muTag, "SiPM1/S"); // muTag replaced by SiPM1 for testing
2835 m_ntuplePtr->Branch("SiPM2", &m_muHalo, "SiPM2/S");// muHalo repalce by SiPM1 for testing
2836 } else {
2837 m_ntuplePtr->Branch("S3cou", &m_s3cou, "S3cou/S");
2838 }
2839
2840 m_ntuplePtr->Branch("Cher1", &m_cher1, "Cher1/S");
2841 m_ntuplePtr->Branch("Cher2", &m_cher2, "Cher2/S");
2842 if (m_TBperiod >= 2022) {
2843 m_ntuplePtr->Branch("Cher3", &m_cher3, "Cher3/S");
2844 }
2845
2846 if (m_TBperiod < 2015) {
2847 m_ntuplePtr->Branch("MuTag", &m_muTag, "MuTag/S");
2848 m_ntuplePtr->Branch("MuHalo", &m_muHalo, "MuHalo/S");
2849 m_ntuplePtr->Branch("MuVeto", &m_muVeto, "MuVeto/S");
2850 //} else if (m_TBperiod == 2015) {
2851 // nothing
2852 } else if (m_TBperiod >= 2016) {
2853 m_ntuplePtr->Branch("SCalo1", &m_muTag, "SCalo1/S");
2854 m_ntuplePtr->Branch("SCalo2", &m_muHalo, "SCalo2/S");
2855 //m_ntuplePtr->Branch("SCalo3", &m_muVeto, "SCalo3/S");
2856 }
2857 }
2858
2859 if (m_TBperiod >= 2015) {
2861 m_btdc = new std::vector<std::vector<int> >(16);
2862 m_ntuplePtr->Branch("btdc1", &m_btdc1, "m_btdc1[16]/I");
2863 m_ntuplePtr->Branch("btdc2", &m_btdc2, "m_btdc2[16]/I");
2864 m_ntuplePtr->Branch("btdc", &m_btdc);
2865 m_ntuplePtr->Branch("tjitter", &m_tjitter, "tjitter/I");
2866 m_ntuplePtr->Branch("tscTOF", &m_tscTOF, "tscTOF/I");
2867 m_ntuplePtr->Branch("btdcNhit", m_btdcNhit, "btdcNhit[16]/I");
2868 m_ntuplePtr->Branch("btdcNchMultiHit", m_btdcNchMultiHit, "btdcNchMultiHit[2]/I");
2869 }
2871 m_ntuplePtr->Branch("tof", &m_tof, "m_tof[16]/I");
2872 }
2874 m_ntuplePtr->Branch("scaler", &m_scaler, "m_scaler[16]/I");
2875 }
2876 } else if (!m_unpackAdder) {
2878 m_ntuplePtr->Branch("S2extra", &m_s2extra, "S2extra/S");
2879 m_ntuplePtr->Branch("S2cou", &m_s3extra, "S3extra/S");
2880 }
2882 m_ntuplePtr->Branch("SC1", &m_sc1, "SC1/S");
2883 m_ntuplePtr->Branch("SC2", &m_sc2, "SC2/S");
2884 }
2886 m_ntuplePtr->Branch("pu", &m_commonPU, "pu/S");
2887 }
2889 m_ntuplePtr->Branch("tof", &m_tof, "m_tof[8]/I");
2890 }
2892 m_ntuplePtr->Branch("btdc1", &m_btdc1, "m_btdc1/I");
2893 }
2895 m_ntuplePtr->Branch("btdc2", &m_btdc2, "m_btdc2/I");
2896 }
2897
2899 m_ntuplePtr->Branch("XchN2", &m_xChN2, "XchN2/F");
2900 m_ntuplePtr->Branch("YchN2", &m_yChN2, "YchN2/F");
2901 m_ntuplePtr->Branch("XchN1", &m_xChN1, "XchN1/F");
2902 m_ntuplePtr->Branch("YchN1", &m_yChN1, "YchN1/F");
2903 }
2905 m_ntuplePtr->Branch("Xcha0", &m_xCha0, "Xcha0/F");
2906 m_ntuplePtr->Branch("Ycha0", &m_yCha0, "Ycha0/F");
2907 }
2908 } else {
2910 m_ntuplePtr->Branch("btdc1", &m_btdc1, "m_btdc1[16]/I");
2911 m_ntuplePtr->Branch("btdc2", &m_btdc2, "m_btdc2[16]/I");
2912 }
2913 }
2914
2915 if ((m_TBperiod >= 2015 && m_beamIdList[COMMON_TDC1_FRAG])
2918 || (m_TBperiod >= 2022 && m_beamIdList[COMMON_TOF_FRAG])) {
2919
2920 m_ntuplePtr->Branch("Xcha1", &m_xCha1, "Xcha1/F");
2921 m_ntuplePtr->Branch("Ycha1", &m_yCha1, "Ycha1/F");
2922 m_ntuplePtr->Branch("Xcha2", &m_xCha2, "Xcha2/F");
2923 m_ntuplePtr->Branch("Ycha2", &m_yCha2, "Ycha2/F");
2924 m_ntuplePtr->Branch("Xcha1_0", &m_xCha1_0, "Xcha1_0/F");
2925 m_ntuplePtr->Branch("Ycha1_0", &m_yCha1_0, "Ycha1_0/F");
2926 m_ntuplePtr->Branch("Xcha2_0", &m_xCha2_0, "Xcha2_0/F");
2927 m_ntuplePtr->Branch("Ycha2_0", &m_yCha2_0, "Ycha2_0/F");
2928 m_ntuplePtr->Branch("Ximp", &m_xImp, "Ximp/F");
2929 m_ntuplePtr->Branch("Yimp", &m_yImp, "Yimp/F");
2930 m_ntuplePtr->Branch("Ximp_0", &m_xImp_0, "Ximp_0/F");
2931 m_ntuplePtr->Branch("Yimp_0", &m_yImp_0, "Yimp_0/F");
2932 m_ntuplePtr->Branch("Ximp_90", &m_xImp_90, "Ximp_90/F");
2933 m_ntuplePtr->Branch("Yimp_90", &m_yImp_90, "Yimp_90/F");
2934 m_ntuplePtr->Branch("Ximp_min90", &m_xImp_min90, "Ximp_min90/F");
2935 m_ntuplePtr->Branch("Yimp_min90", &m_yImp_min90, "Yimp_min90/F");
2936 }
2937
2938}
2939
2942//Clear Tree BEAM variables
2943//
2945*/
2947
2950
2951 m_s1cou = 0;
2952 m_s2cou = 0;
2953 m_s3cou = 0;
2954 m_cher1 = 0;
2955 m_cher2 = 0;
2956 m_cher3 = 0;
2957 m_muTag = 0;
2958 m_muHalo = 0;
2959 m_muVeto = 0;
2960 }
2961 if (!m_unpackAdder) {
2963
2964 m_s2extra = 0;
2965 m_s3extra = 0;
2966 }
2968 m_sc1 = 0;
2969 m_sc2 = 0;
2970 }
2972 m_commonPU = 0;
2973 }
2975 m_xChN2 = 0.;
2976 m_yChN2 = 0.;
2977 m_xChN1 = 0.;
2978 m_yChN1 = 0.;
2979 }
2981 m_xCha0 = 0.;
2982 m_yCha0 = 0.;
2983 }
2984 }
2985
2986 if ((m_TBperiod >= 2015 && m_beamIdList[COMMON_TDC1_FRAG])
2989 || (m_TBperiod >= 2022 && m_beamIdList[COMMON_TOF_FRAG])) {
2990
2991 m_xCha1 = 0.;
2992 m_yCha1 = 0.;
2993 m_xCha2 = 0.;
2994 m_yCha2 = 0.;
2995 m_xCha1_0 = 0.;
2996 m_yCha1_0 = 0.;
2997 m_xCha2_0 = 0.;
2998 m_yCha2_0 = 0.;
2999 m_xImp = 0.;
3000 m_yImp = 0.;
3001 }
3002
3003 m_muBack.fill(0.0F);
3004
3005 for (int i=0; i<16; i+=2) {
3006 m_tof[i] = +0xFFFF;
3007 m_tof[i+1] = -0xFFFF;
3008 }
3009
3010 for (int i=0; i<16; i+=2) {
3011 m_btdc1[i] = +0xFFFF;
3012 m_btdc1[i+1] = -0xFFFF;
3013 }
3014
3015 for (int i=0; i<16; i+=2) {
3016 m_btdc2[i] = +0xFFFF;
3017 m_btdc2[i+1] = -0xFFFF;
3018 }
3019
3020 if (m_btdc) {
3021 for (std::vector<int>& btdc_amplitudes : *m_btdc) {
3022 btdc_amplitudes.clear();
3023 }
3024 }
3025
3026 memset(&m_scaler, 0, sizeof(m_scaler));
3027
3028 memset(m_btdcNhit,0,sizeof(m_btdcNhit));
3029 memset(m_btdcNchMultiHit,0,sizeof(m_btdcNchMultiHit));
3030}
3031
3035//
3037*/
3039{
3040 if (m_completeNtuple) {
3041 m_ntuplePtr->Branch("LarSmp", &m_LarEne, "m_LarEne[4]/F");
3042 m_ntuplePtr->Branch("BarSmp", &m_BarEne, "m_BarEne[3]/F");
3043 m_ntuplePtr->Branch("ExtSmp", &m_ExtEne, "m_ExtEne[3]/F");
3044 m_ntuplePtr->Branch("GapSmp", &m_GapEne, "m_GapEne[3]/F");
3045 }
3046}
3047
3050//Clear Tree ENETOTAL variables
3051//
3053*/
3055{
3056
3057
3058}
3059
3063//
3065*/
3068 m_ntuplePtr->Branch("CoincTrig1", &m_coincTrig1, "m_coincTrig1[96]/I");
3069 m_ntuplePtr->Branch("CoincFlag1", &m_coincFlag1, "CoincFlag1/I");
3070 }
3071
3073 m_ntuplePtr->Branch("CoincTrig2", &m_coincTrig2, "m_coincTrig2[96]/I");
3074 m_ntuplePtr->Branch("CoincFlag2", &m_coincFlag2, "CoincFlag2/I");
3075 }
3076
3078 m_ntuplePtr->Branch("CoincTrig3", &m_coincTrig3, "m_coincTrig3[96]/I");
3079 m_ntuplePtr->Branch("CoincFlag3", &m_coincFlag3, "CoincFlag3/I");
3080 }
3081
3083 m_ntuplePtr->Branch("CoincTrig4", &m_coincTrig4, "m_coincTrig4[96]/I");
3084 m_ntuplePtr->Branch("CoincFlag4", &m_coincFlag4, "CoincFlag4/I");
3085 }
3087 m_ntuplePtr->Branch("CoincTrig5", &m_coincTrig5, "m_coincTrig5[96]/I");
3088 m_ntuplePtr->Branch("CoincFlag5", &m_coincFlag5, "CoincFlag5/I");
3089 }
3090
3092 m_ntuplePtr->Branch("CoincTrig6", &m_coincTrig6, "m_coincTrig6[96]/I");
3093 m_ntuplePtr->Branch("CoincFlag6", &m_coincFlag6, "CoincFlag6/I");
3094 }
3095
3097 m_ntuplePtr->Branch("CoincTrig7", &m_coincTrig7, "m_coincTrig7[96]/I");
3098 m_ntuplePtr->Branch("CoincFlag7", &m_coincFlag7, "CoincFlag7/I");
3099 }
3100
3102 m_ntuplePtr->Branch("CoincTrig8", &m_coincTrig8, "m_coincTrig8[96]/I");
3103 m_ntuplePtr->Branch("CoincFlag8", &m_coincFlag8, "CoincFlag8/I");
3104 }
3105
3106}
3107
3110//Clear Tree COINCBOARD variables
3111//
3113*/
3115{
3116
3117
3118
3119}
3120
3124//
3126*/
3128{
3129
3130
3133 m_bcidVec.reserve(MAX_DRAWERS);
3134 m_DMUheaderVec.reserve(MAX_DRAWERS);
3142 m_dmuMaskVec.reserve(MAX_DRAWERS);
3143 m_slinkCRCVec.reserve(MAX_DRAWERS);
3144 m_gainVec.reserve(MAX_DRAWERS);
3145 m_sampleVec.reserve(MAX_DRAWERS);
3146 m_feCRCVec.reserve(MAX_DRAWERS);
3147 m_rodCRCVec.reserve(MAX_DRAWERS);
3148 m_eneVec.reserve(MAX_DRAWERS);
3149 m_timeVec.reserve(MAX_DRAWERS);
3150 m_pedFlatVec.reserve(MAX_DRAWERS);
3151 m_chi2FlatVec.reserve(MAX_DRAWERS);
3152 m_efitVec.reserve(MAX_DRAWERS);
3153 m_tfitVec.reserve(MAX_DRAWERS);
3154 m_pedfitVec.reserve(MAX_DRAWERS);
3155 m_chi2Vec.reserve(MAX_DRAWERS);
3156 m_efitcVec.reserve(MAX_DRAWERS);
3157 m_tfitcVec.reserve(MAX_DRAWERS);
3158 m_pedfitcVec.reserve(MAX_DRAWERS);
3159 m_chi2cVec.reserve(MAX_DRAWERS);
3160 m_eOptVec.reserve(MAX_DRAWERS);
3161 m_tOptVec.reserve(MAX_DRAWERS);
3162 m_pedOptVec.reserve(MAX_DRAWERS);
3163 m_chi2OptVec.reserve(MAX_DRAWERS);
3164 m_eDspVec.reserve(MAX_DRAWERS);
3165 m_tDspVec.reserve(MAX_DRAWERS);
3166 m_chi2DspVec.reserve(MAX_DRAWERS);
3175
3176 std::ostringstream oss;
3177 oss << m_nSamples;
3178 std::string nSampStr=oss.str();
3179
3180 unsigned int listSize = std::min(m_nDrawers.value(), static_cast<unsigned int>(m_drawerMap.size()));
3181
3182 if (listSize > 0) {
3183
3184 std::string digit[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
3185 std::vector<std::string> suffixArr;
3186 unsigned int length;
3187 bool testbeam = TileCablingService::getInstance()->getTestBeam();
3188
3189 if (m_calibMode) {
3190
3191 length = 2 * m_nDrawers;
3192 suffixArr.resize(length);
3193
3194 for (unsigned int i = 0; i < listSize; ++i) {
3195 unsigned int ros = m_drawerType[i];
3196 unsigned int drawer = strtol(m_drawerList[i].data(), NULL, 0) & 0x3F;
3197 std::string digits;
3198 if (m_TBperiod >= 2010) {
3199 ++drawer; // count modules from 1
3200 digits = digit[drawer / 10] + digit[drawer % 10];
3201 } else if (testbeam) {
3202 digits = digit[drawer & 7];
3203 } else {
3204 ++drawer; // count modules from 1
3205 digits = digit[drawer / 10] + digit[drawer % 10];
3206 }
3207
3208 if (ros == 0) {
3209 std::string suff = m_drawerList[i];
3210 suff.replace(suff.find("0x"), 2, "");
3211 suffixArr[i] = suff + "lo";
3212 suffixArr[i + m_nDrawers] = suff + "hi";
3213 } else {
3214 suffixArr[i] = m_rosName[ros] + digits + "lo";
3215 suffixArr[i + m_nDrawers] = m_rosName[ros] + digits + "hi";
3216 }
3217 }
3218 } else {
3219
3221 suffixArr.resize(length);
3222
3223 for (unsigned int i = 0; i < listSize; ++i) {
3224 unsigned int ros = m_drawerType[i];
3225 unsigned int drawer = strtol(m_drawerList[i].data(), NULL, 0) & 0x3F;
3226 std::string digits;
3227 if (m_TBperiod >= 2010) {
3228 ++drawer; // count modules from 1
3229 digits = digit[drawer / 10] + digit[drawer % 10];
3230 } else if (testbeam) {
3231 digits = digit[drawer & 7];
3232 } else {
3233 ++drawer; // count modules from 1
3234 digits = digit[drawer / 10] + digit[drawer % 10];
3235 }
3236
3237 if (ros == 0) {
3238 std::string suff = m_drawerList[i];
3239 suff.replace(suff.find("0x"), 2, "");
3240 suffixArr[i] = std::move(suff);
3241 } else {
3242 suffixArr[i] = m_rosName[ros] + digits;
3243 }
3244 }
3245 }
3246
3247 m_nSamplesInDrawer.reserve(length);
3248
3249 m_evtVec.resize(length);
3250 m_rodBCIDVec.resize(length);
3251 m_sizeVec.resize(length);
3252 m_ROD_GlobalCRCVec.resize(length);
3253
3254 for (unsigned int i = 0; i < length; i++) {
3255
3256 int nSamplesInDrawer(m_nSamples);
3257 int frag = std::stoi(m_drawerList[i%m_nDrawers], nullptr, 0);
3258
3259 auto it = m_nSamplesInDrawerMap.find(frag);
3260 if (it != m_nSamplesInDrawerMap.end()) {
3261 nSamplesInDrawer = it->second;
3262 }
3263 m_nSamplesInDrawer.push_back(nSamplesInDrawer);
3264
3265 m_bcidVec.push_back(std::array<int, MAX_DMU>()); // U
3266 m_DMUheaderVec.push_back(std::array<uint32_t, MAX_DMU>()); // U32
3267 m_DMUformatErrVec.push_back(std::array<short, MAX_DMU>()); // U32
3268 m_DMUparityErrVec.push_back(std::array<short, MAX_DMU>()); // U32
3269 m_DMUmemoryErrVec.push_back(std::array<short, MAX_DMU>()); // U32
3270 m_DMUDstrobeErrVec.push_back(std::array<short, MAX_DMU>()); // U32
3271 m_DMUSstrobeErrVec.push_back(std::array<short, MAX_DMU>()); // U32
3272 m_DMUHeadparityErrVec.push_back(std::array<short, MAX_DMU>());
3273 m_DMUDataparityErrVec.push_back(std::array<short, MAX_DMU>());
3274
3275 m_dmuMaskVec.push_back(std::array<int, 2>()); // U(2)
3276 m_slinkCRCVec.push_back(std::array<int, 2>()); // U(2)
3277 m_gainVec.push_back(std::array<int, MAX_CHAN>()); // U(48/96)
3278 m_sampleVec.push_back(std::make_unique<int[]>(MAX_CHAN * nSamplesInDrawer)); // U(48/96,9)
3279 m_feCRCVec.push_back(std::array<int, MAX_DMU>()); //U
3280 m_rodCRCVec.push_back(std::array<int, MAX_DMU>()); //U
3281
3282 m_eneVec.push_back(std::array<float, MAX_CHAN>());
3283 m_timeVec.push_back(std::array<float, MAX_CHAN>());
3284 m_pedFlatVec.push_back(std::array<float, MAX_CHAN>());
3285 m_chi2FlatVec.push_back(std::array<float, MAX_CHAN>());
3286
3287 m_efitVec.push_back(std::array<float, MAX_CHAN>());
3288 m_tfitVec.push_back(std::array<float, MAX_CHAN>());
3289 m_pedfitVec.push_back(std::array<float, MAX_CHAN>());
3290 m_chi2Vec.push_back(std::array<float, MAX_CHAN>());
3291
3292 m_efitcVec.push_back(std::array<float, MAX_CHAN>());
3293 m_tfitcVec.push_back(std::array<float, MAX_CHAN>());
3294 m_pedfitcVec.push_back(std::array<float, MAX_CHAN>());
3295 m_chi2cVec.push_back(std::array<float, MAX_CHAN>());
3296
3297 m_eOptVec.push_back(std::array<float, MAX_CHAN>());
3298 m_tOptVec.push_back(std::array<float, MAX_CHAN>());
3299 m_pedOptVec.push_back(std::array<float, MAX_CHAN>());
3300 m_chi2OptVec.push_back(std::array<float, MAX_CHAN>());
3301
3302 m_eDspVec.push_back(std::array<float, MAX_CHAN>());
3303 m_tDspVec.push_back(std::array<float, MAX_CHAN>());
3304 m_chi2DspVec.push_back(std::array<float, MAX_CHAN>());
3305
3306 m_ROD_DMUBCIDVec.push_back(std::array<short, MAX_DMU>());
3307 m_ROD_DMUmemoryErrVec.push_back(std::array<short, MAX_DMU>());
3308 m_ROD_DMUSstrobeErrVec.push_back(std::array<short, MAX_DMU>());
3309 m_ROD_DMUDstrobeErrVec.push_back(std::array<short, MAX_DMU>());
3310 m_ROD_DMUHeadformatErrVec.push_back(std::array<short, MAX_DMU>());
3311 m_ROD_DMUDataformatErrVec.push_back(std::array<short, MAX_DMU>());
3312 m_ROD_DMUMaskVec.push_back(std::array<short, 2>());
3313
3314 if (i % m_nDrawers < listSize) {
3315
3316 ATH_MSG_DEBUG( "Adding items for " << suffixArr[i] );
3317 // create ntuple layout
3318 if (m_bsInput) {
3319 m_ntuplePtr->Branch(("Evt"+suffixArr[i]).c_str(), &m_evtVec.data()[i], ("Evt"+suffixArr[i]+"/I").c_str()); // int
3320 m_ntuplePtr->Branch(("rodBCID"+suffixArr[i]).c_str(), &m_rodBCIDVec.data()[i], ("rodBCID"+suffixArr[i]+"/S").c_str());//int
3321 m_ntuplePtr->Branch(("Size"+suffixArr[i]).c_str(), &m_sizeVec.data()[i], ("Size"+suffixArr[i]+"/S").c_str()); // short
3322 m_ntuplePtr->Branch(("BCID"+suffixArr[i]).c_str(), &m_bcidVec.back(), ("bcid"+suffixArr[i]+"[16]/I").c_str()); // int
3323 m_ntuplePtr->Branch(("DMUheader"+suffixArr[i]).c_str(), &m_DMUheaderVec.back(), ("DMUheader"+suffixArr[i]+"[16]/i").c_str()); // uint32
3324 m_ntuplePtr->Branch(("DMUformatErr"+suffixArr[i]).c_str(), &m_DMUformatErrVec.back(), ("DMUformatErr"+suffixArr[i]+"[16]/S").c_str()); // short
3325 m_ntuplePtr->Branch(("DMUparityErr"+suffixArr[i]).c_str(), &m_DMUparityErrVec.back(), ("DMUparityErr"+suffixArr[i]+"[16]/S").c_str()); // short
3326 m_ntuplePtr->Branch(("DMUmemoryErr"+suffixArr[i]).c_str(), &m_DMUmemoryErrVec.back(), ("DMUmemoryErr"+suffixArr[i]+"[16]/S").c_str()); // short
3327 m_ntuplePtr->Branch(("DMUSstrobeErr"+suffixArr[i]).c_str(), &m_DMUSstrobeErrVec.back(), ("DMUSstrobeErr"+suffixArr[i]+"[16]/S").c_str()); // short
3328 m_ntuplePtr->Branch(("DMUDstrobeErr"+suffixArr[i]).c_str(), &m_DMUDstrobeErrVec.back(), ("DMUDstrobeErr"+suffixArr[i]+"[16]/S").c_str()); // short
3329 m_ntuplePtr->Branch(("DMUMask"+suffixArr[i]).c_str(), &m_dmuMaskVec.back(), ("dmumask"+suffixArr[i]+"[2]/I").c_str()); // int
3330 m_ntuplePtr->Branch(("SlinkCRC"+suffixArr[i]).c_str(), &m_slinkCRCVec.back(), ("crc"+suffixArr[i]+"[2]/I").c_str()); // int
3331 m_ntuplePtr->Branch(("DMUHeadparityErr"+suffixArr[i]).c_str(), &m_DMUHeadparityErrVec.back(), ("DMUHeadparityErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3332 m_ntuplePtr->Branch(("DMUDataparityErr"+suffixArr[i]).c_str(), &m_DMUDataparityErrVec.back(), ("DMUDataparityErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3333 }
3334
3335 m_ntuplePtr->Branch(("Gain"+suffixArr[i]).c_str(),&m_gainVec.back(), ("gain"+suffixArr[i]+"[48]/I").c_str()); // int
3336
3337 if (nSamplesInDrawer > 0) {
3338 nSampStr = std::to_string(nSamplesInDrawer);
3339 m_ntuplePtr->Branch(("Sample" + suffixArr[i]).c_str(), m_sampleVec.back().get(),
3340 ("sample" + suffixArr[i] + "[48]["+nSampStr+"]/I").c_str()); // size m_nsample and type int
3341 }
3342
3343 if (m_bsInput) {
3344 m_ntuplePtr->Branch(("feCRC" + suffixArr[i]).c_str(), &m_feCRCVec.back(), ("fe_crc" + suffixArr[i] + "[16]/I").c_str()); // int
3345 m_ntuplePtr->Branch(("rodCRC" + suffixArr[i]).c_str(), &m_rodCRCVec.back(), ("rod_crc" + suffixArr[i] + "[16]/I").c_str()); // int
3346 }
3347
3348 if (!m_flatRawChannelContainerKey.empty()) {
3349
3350 m_ntuplePtr->Branch(("Ene" + suffixArr[i]).c_str(), &m_eneVec.back(), ("ene" + suffixArr[i] + "[48]/F").c_str()); // float
3351 m_ntuplePtr->Branch(("Time" + suffixArr[i]).c_str(), &m_timeVec.back(), ("time" + suffixArr[i] + "[48]/F").c_str()); // float
3352 m_ntuplePtr->Branch(("Ped" + suffixArr[i]).c_str(), &m_pedFlatVec.back(), ("pedflat" + suffixArr[i] + "[48]/F").c_str()); // float
3353 m_ntuplePtr->Branch(("Chi2ene" + suffixArr[i]).c_str(), &m_chi2FlatVec.back(), ("chiflat" + suffixArr[i] + "[48]/F").c_str()); // float
3354
3355 }
3356
3357 if (!m_fitRawChannelContainerKey.empty()) {
3358
3359 m_ntuplePtr->Branch(("Efit" + suffixArr[i]).c_str(), &m_efitVec.back(), ("efit" + suffixArr[i] + "[48]/F").c_str()); // float
3360 m_ntuplePtr->Branch(("Tfit" + suffixArr[i]).c_str(), &m_tfitVec.back(), ("tfit" + suffixArr[i] + "[48]/F").c_str()); // float
3361 m_ntuplePtr->Branch(("Pedfit" + suffixArr[i]).c_str(), &m_pedfitVec.back(), ("pedfit" + suffixArr[i] + "[48]/F").c_str()); // float
3362 m_ntuplePtr->Branch(("Chi2fit" + suffixArr[i]).c_str(), &m_chi2Vec.back(), ("chifit" + suffixArr[i] + "[48]/F").c_str()); // float
3363
3364 }
3365
3366 if (!m_fitcRawChannelContainerKey.empty()) {
3367
3368 m_ntuplePtr->Branch(("Efitc" + suffixArr[i]).c_str(), &m_efitcVec.back(), ("efitc" + suffixArr[i] + "[48]/F").c_str()); // float
3369 m_ntuplePtr->Branch(("Tfitc" + suffixArr[i]).c_str(), &m_tfitcVec.back(), ("tfitc" + suffixArr[i] + "[48]/F").c_str()); // float
3370 m_ntuplePtr->Branch(("Pedfitc" + suffixArr[i]).c_str(), &m_pedfitcVec.back(), ("pedfitc" + suffixArr[i] + "[48]/F").c_str()); // float
3371 m_ntuplePtr->Branch(("Chi2fitc" + suffixArr[i]).c_str(), &m_chi2cVec.back(), ("chifitc" + suffixArr[i] + "[48]/F").c_str()); // float
3372
3373 }
3374
3375 if (!m_optRawChannelContainerKey.empty()) {
3376
3377 m_ntuplePtr->Branch(("Eopt"+suffixArr[i]).c_str(), &m_eOptVec.back(), ("eOpt"+suffixArr[i]+"[48]/F").c_str()); // float
3378 m_ntuplePtr->Branch(("Topt"+suffixArr[i]).c_str(), &m_tOptVec.back(), ("tOpt"+suffixArr[i]+"[48]/F").c_str()); // float
3379 m_ntuplePtr->Branch(("Pedopt"+suffixArr[i]).c_str(), &m_pedOptVec.back(), ("pedOpt"+suffixArr[i]+"[48]/F").c_str()); // float
3380 m_ntuplePtr->Branch(("Chi2opt"+suffixArr[i]).c_str(), &m_chi2OptVec.back(), ("chiOpt"+suffixArr[i]+"[48]/F").c_str()); // float
3381
3382 }
3383
3384 if (!m_dspRawChannelContainerKey.empty()) {
3385
3386 m_ntuplePtr->Branch(("Edsp"+suffixArr[i]).c_str(), &m_eDspVec.back(), ("eDsp"+suffixArr[i]+"[48]/F").c_str()); // float
3387 m_ntuplePtr->Branch(("Tdsp"+suffixArr[i]).c_str(), &m_tDspVec.back(), ("tDsp"+suffixArr[i]+"[48]/F").c_str()); // float
3388 m_ntuplePtr->Branch(("Chi2dsp"+suffixArr[i]).c_str(), &m_chi2DspVec.back(), ("chiDsp"+suffixArr[i]+"[48]/F").c_str()); // float
3389 m_ntuplePtr->Branch(("ROD_GlobalCRC"+suffixArr[i]).c_str(), &m_ROD_GlobalCRCVec.data()[i], ("ROD_GlobalCRC"+suffixArr[i]+"/s").c_str()); // unsigned short
3390 m_ntuplePtr->Branch(("ROD_DMUBCID"+suffixArr[i]).c_str(), &m_ROD_DMUBCIDVec.back(), ("ROD_DMUBCID"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3391 m_ntuplePtr->Branch(("ROD_DMUmemoryErr"+suffixArr[i]).c_str(), &m_ROD_DMUmemoryErrVec.back(), ("ROD_DMUmemoryErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3392 m_ntuplePtr->Branch(("ROD_DMUSstrobeErr"+suffixArr[i]).c_str(), &m_ROD_DMUSstrobeErrVec.back(), ("ROD_DMUSstrobeErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3393 m_ntuplePtr->Branch(("ROD_DMUDstrobeErr"+suffixArr[i]).c_str(), &m_ROD_DMUDstrobeErrVec.back(), ("ROD_DMUDstrobeErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3394 m_ntuplePtr->Branch(("ROD_DMUHeadformatErr"+suffixArr[i]).c_str(), &m_ROD_DMUHeadformatErrVec.back(), ("ROD_DMUHeadformatErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3395 m_ntuplePtr->Branch(("ROD_DMUDataformatErr"+suffixArr[i]).c_str(), &m_ROD_DMUDataformatErrVec.back(), ("ROD_DMUDataformatErr"+suffixArr[i]+"[16]/s").c_str()); // unsigned short
3396 m_ntuplePtr->Branch(("ROD_DMUMask"+suffixArr[i]).c_str(), &m_ROD_DMUMaskVec.back(), ("ROD_DMUMask"+suffixArr[i]+"[2]/s").c_str()); // unsigned short
3397
3398 }
3399 }
3400 }
3401 }
3402}
3403
3408*/
3410{
3414
3424
3433
3440
3460
3461}
3462
3463
3465{
3466
3468 m_sizeflxVec.reserve(MAX_DRAWERS);
3469 m_evtflxVec.reserve(MAX_DRAWERS);
3470
3471 m_eflxfitVec.reserve(MAX_DRAWERS);
3472 m_tflxfitVec.reserve(MAX_DRAWERS);
3474 m_pedflxfitVec.reserve(MAX_DRAWERS);
3475 m_eflxoptVec.reserve(MAX_DRAWERS);
3476 m_tflxoptVec.reserve(MAX_DRAWERS);
3478 m_pedflxoptVec.reserve(MAX_DRAWERS);
3479 m_gainflxVec.reserve(MAX_DRAWERS);
3480 m_sampleflxVec.reserve(MAX_DRAWERS);
3481
3482 m_mdL1idflxVec.reserve(MAX_DRAWERS);
3483 m_mdBcidflxVec.reserve(MAX_DRAWERS);
3488 m_mdRunflxVec.reserve(MAX_DRAWERS);
3492
3493 std::string nSampStrFlx = std::to_string(m_nSamplesFlx);
3494 unsigned int listSize = std::min(m_nDrawersFlx.value(), static_cast<unsigned int>(m_drawerFlxMap.size()));
3495
3496 bool testbeam = TileCablingService::getInstance()->getTestBeam();
3497 std::vector<std::string> moduleNames(m_nDrawersFlx, "");
3498 unsigned int length = 2 * m_nDrawersFlx;
3499 std::vector<std::string> suffixArr(length, "");
3501
3502 for (const std::pair<const unsigned int, unsigned int>& fragAndDrawer : m_drawerFlxMap) {
3503 unsigned int frag = fragAndDrawer.first;
3504 unsigned int ros = frag >> 8;
3505 unsigned int drawer = frag & 0x3F;
3506 unsigned int drawerIndex = fragAndDrawer.second;
3507
3508 std::ostringstream drawerName;
3509 drawerName << m_rosName[ros];
3510 if (testbeam) {
3511 drawerName << (drawer & 7);
3512 } else {
3513 ++drawer; // count modules from 1
3514 drawerName << std::setw(2) << std::setfill('0') << drawer;
3515 }
3516
3517 moduleNames.at(drawerIndex) = drawerName.str();
3518 suffixArr.at(drawerIndex) = drawerName.str() + "lo";
3519 suffixArr.at(drawerIndex + m_nDrawersFlx) = drawerName.str() + "hi";
3520
3521 int nSamples(m_nSamplesFlx);
3522 auto it = m_nSamplesFlxInDrawerMap.find(frag);
3523 if (it != m_nSamplesFlxInDrawerMap.end()) {
3524 nSamples = it->second;
3525 }
3526
3527 m_nSamplesFlxInDrawer[drawerIndex] = nSamples;
3528 m_nSamplesFlxInDrawer[drawerIndex + m_nDrawersFlx] = nSamples;
3529 }
3530
3533 m_evtflxVec.resize(m_nDrawersFlx);
3534
3535 for (unsigned int i = 0; i < length; ++i) {
3536
3537 int nSamplesInDrawer = m_nSamplesFlxInDrawer[i];
3538
3539 m_eflxfitVec.push_back(std::array<float, MAX_CHAN>());
3540 m_tflxfitVec.push_back(std::array<float, MAX_CHAN>());
3541 m_pedflxfitVec.push_back(std::array<float, MAX_CHAN>());
3542 m_chi2flxfitVec.push_back(std::array<float, MAX_CHAN>());
3543
3544 m_eflxoptVec.push_back(std::array<float, MAX_CHAN>());
3545 m_tflxoptVec.push_back(std::array<float, MAX_CHAN>());
3546 m_pedflxoptVec.push_back(std::array<float, MAX_CHAN>());
3547 m_chi2flxoptVec.push_back(std::array<float, MAX_CHAN>());
3548
3549 if (i < m_nDrawersFlx) {
3550 m_mdL1idflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3551 m_mdBcidflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3552 m_mdModuleflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3553 m_mdRunTypeflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3554 m_mdPedLoflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3555 m_mdPedHiflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3556 m_mdRunflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3557 m_mdChargeflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3558 m_mdChargeTimeflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3559 m_mdCapacitorflxVec.push_back(std::array<int, MAX_MINIDRAWER>());
3560
3561 std::string suffix = moduleNames[i];
3562 ATH_MSG_DEBUG( "Adding items for " << suffix );
3563
3564 if (m_bsInput) {
3565 m_ntuplePtr->Branch(("FlxEvt"+suffix).c_str(), &m_evtflxVec.data()[i]); // int
3566 m_ntuplePtr->Branch(("FlxRodBCID"+suffix).c_str(), &m_rodBCIDflxVec.data()[i]);//int
3567 m_ntuplePtr->Branch(("FlxSize"+suffix).c_str(), &m_sizeflxVec.data()[i]); // short
3568 }
3569
3570 m_ntuplePtr->Branch(("FlxL1ID"+suffix).c_str(), &m_mdL1idflxVec.back()); // int
3571 m_ntuplePtr->Branch(("FlxBCID"+suffix).c_str(), &m_mdBcidflxVec.back()); // int
3572 m_ntuplePtr->Branch(("FlxModule"+suffix).c_str(), &m_mdModuleflxVec.back()); // int
3573 m_ntuplePtr->Branch(("FlxRun"+suffix).c_str(), &m_mdRunflxVec.back()); // int
3574 m_ntuplePtr->Branch(("FlxRunType"+suffix).c_str(), &m_mdRunTypeflxVec.back()); // int
3575 m_ntuplePtr->Branch(("FlxPedLo"+suffix).c_str(), &m_mdPedLoflxVec.back()); // int
3576 m_ntuplePtr->Branch(("FlxPedHi"+suffix).c_str(), &m_mdPedHiflxVec.back()); // int
3577 m_ntuplePtr->Branch(("FlxCharge"+suffix).c_str(), &m_mdChargeflxVec.back()); // int
3578 m_ntuplePtr->Branch(("FlxChargeTime"+suffix).c_str(), &m_mdChargeTimeflxVec.back()); // int
3579 m_ntuplePtr->Branch(("FlxCapacitor"+suffix).c_str(), &m_mdCapacitorflxVec.back()); // int
3580
3581 }
3582
3583 m_gainflxVec.push_back(std::array<int, MAX_CHAN>());
3584 m_sampleflxVec.push_back(std::make_unique<int[]>(MAX_CHAN * nSamplesInDrawer)); // U(48/96,9)
3585
3586 if (i % m_nDrawersFlx < listSize) {
3587 ATH_MSG_DEBUG( "Adding items for " << suffixArr[i] );
3588
3589 m_ntuplePtr->Branch(("FlxGain"+suffixArr[i]).c_str(), &m_gainflxVec.back()); // int
3590
3591 if (nSamplesInDrawer > 0) {
3592 nSampStrFlx = std::to_string(nSamplesInDrawer);
3593 m_ntuplePtr->Branch(("FlxSample" + suffixArr[i]).c_str(), m_sampleflxVec.back().get(),
3594 ("Flxsample" + suffixArr[i] + "[48]["+nSampStrFlx+"]/I").c_str()); // size m_nsample and type int
3595 }
3596
3597 if (!m_flxFitRawChannelContainerKey.empty()) {
3598 m_ntuplePtr->Branch(("FlxEfit" + suffixArr[i]).c_str(), &m_eflxfitVec.back()); // float
3599 m_ntuplePtr->Branch(("FlxTfit" + suffixArr[i]).c_str(), &m_tflxfitVec.back()); // float
3600 m_ntuplePtr->Branch(("FlxPedfit" + suffixArr[i]).c_str(), &m_pedflxfitVec.back()); // float
3601 m_ntuplePtr->Branch(("FlxChi2fit" + suffixArr[i]).c_str(), &m_chi2flxfitVec.back()); // float
3602 }
3603
3604 if (!m_flxOptRawChannelContainerKey.empty()) {
3605 m_ntuplePtr->Branch(("FlxEOpt" + suffixArr[i]).c_str(), &m_eflxoptVec.back()); // float
3606 m_ntuplePtr->Branch(("FlxTOpt" + suffixArr[i]).c_str(), &m_tflxoptVec.back()); // float
3607 m_ntuplePtr->Branch(("FlxPedOpt" + suffixArr[i]).c_str(), &m_pedflxoptVec.back()); // float
3608 m_ntuplePtr->Branch(("FlxChi2Opt" + suffixArr[i]).c_str(), &m_chi2flxoptVec.back()); // float
3609 }
3610 }
3611 }
3612}
3613
3614
3615
3646
3650//
3652*/
3654{
3655 m_ehitVec.clear();
3656 m_thitVec.clear();
3657 m_ehitCnt.clear();
3658 m_thitCnt.clear();
3659
3660 m_ehitVec.reserve(MAX_DRAWERS);
3661 m_thitVec.reserve(MAX_DRAWERS);
3662 m_ehitCnt.reserve(MAX_DRAWERS);
3663 m_thitCnt.reserve(MAX_DRAWERS);
3664
3665 unsigned int listSize = std::min(m_nDrawers.value(), static_cast<unsigned int>(m_drawerMap.size()));
3666
3667 if (listSize > 0) {
3668
3669 std::string digit[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
3670 std::vector<std::string> suffixArr;
3671 unsigned int length;
3672 bool testbeam = TileCablingService::getInstance()->getTestBeam();
3673
3675 suffixArr.resize(length);
3676
3677 for (unsigned int i = 0; i < listSize; ++i) {
3678 unsigned int ros = m_drawerType[i];
3679 unsigned int drawer = strtol(m_drawerList[i].data(), NULL, 0) & 0x3F;
3680 std::string digits;
3681 if (m_TBperiod >= 2010) {
3682 ++drawer; // count modules from 1
3683 digits = digit[drawer / 10] + digit[drawer % 10];
3684 } else if (testbeam) {
3685 digits = digit[drawer & 7];
3686 } else {
3687 ++drawer; // count modules from 1
3688 digits = digit[drawer / 10] + digit[drawer % 10];
3689 }
3690
3691 if (ros == 0) {
3692 std::string suff = m_drawerList[i];
3693 suff.replace(suff.find("0x"), 2, "");
3694 suffixArr[i] = std::move(suff);
3695 } else {
3696 suffixArr[i] = m_rosName[ros] + digits;
3697 }
3698 }
3699
3700 for (unsigned int i = 0; i < length; i++) {
3701
3702 if (i % m_nDrawers < listSize)
3703 ATH_MSG_DEBUG( "Adding items for " << suffixArr[i] );
3704
3705 m_ehitVec.push_back(std::array<float, MAX_CHAN>());
3706 m_thitVec.push_back(std::array<float, MAX_CHAN>());
3707 m_ehitCnt.push_back(std::array<float, MAX_CHAN>());
3708 m_thitCnt.push_back(std::array<float, MAX_CHAN>());
3709
3710 if (i%m_nDrawers < listSize) {
3711
3712 if (!m_hitVectorKey.empty()) {
3713
3714 if (i % m_nDrawers < listSize)
3715 ATH_MSG_DEBUG( "Adding G4 hit info for " << suffixArr[i] );
3716
3717 m_ntuplePtr->Branch(("EhitG4"+suffixArr[i]).c_str(),&m_ehitVec.back(),("eHitG4"+suffixArr[i]+"[48]/F").c_str());
3718 m_ntuplePtr->Branch(("ThitG4"+suffixArr[i]).c_str(),&m_thitVec.back(),("tHitG4"+suffixArr[i]+"[48]/F").c_str());
3719 }
3720
3721 if (!m_hitContainerKey.empty()) {
3722
3723 if (i % m_nDrawers < listSize)
3724 ATH_MSG_DEBUG( "Adding G4 corrected hit info for " << suffixArr[i] );
3725
3726 m_ntuplePtr->Branch(("EhitSim"+suffixArr[i]).c_str(),&m_ehitCnt.back(),("eHitSim"+suffixArr[i]+"[48]/F").c_str());
3727 m_ntuplePtr->Branch(("ThitSim"+suffixArr[i]).c_str(),&m_thitCnt.back(),("tHitSim"+suffixArr[i]+"[48]/F").c_str());
3728 }
3729 }
3730 }
3731 }
3732}
3733
3738*/
3746
3747template<typename T>
3749 std::fill(vec.begin(), vec.end(), static_cast<T>(-1));
3750}
3751
3752template<typename T, size_t N>
3753void TileTBAANtuple::clear_init_minus1(std::vector<std::array<T,N>>& vec) {
3754 for (std::array<T,N>& arr : vec) {
3755 std::fill(arr.begin(), arr.end(), static_cast<T>(-1));
3756 }
3757}
3758
3759template<typename T, size_t N>
3760void TileTBAANtuple::clear_init_zero(std::vector<std::array<T,N>>& vec) {
3761 for (std::array<T,N>& arr : vec) {
3762 std::fill(arr.begin(), arr.end(), static_cast<T>(0));
3763 }
3764}
3765
3766void TileTBAANtuple::clear_samples(std::vector<std::unique_ptr<int []>> & vec, const std::vector<int>& nsamples, int nchan)
3767{
3768 for (unsigned int i = 0; i < vec.size(); ++i) {
3769 std::fill(vec[i].get(), vec[i].get() + nsamples.at(i) * nchan, -1);
3770 }
3771}
3772
3774 // Setup default value for the following properties, if they are not setup via JO
3775 setupPropertyDefaultValue(m_beamBC1X1, -0.938, "BC1X1");
3776 setupPropertyDefaultValue(m_beamBC1X2, 0.1747, "BC1X2");
3777 setupPropertyDefaultValue(m_beamBC1Y1, 0.125, "BC1Y1");
3778 setupPropertyDefaultValue(m_beamBC1Y2, 0.1765, "BC1Y2");
3779 setupPropertyDefaultValue(m_beamBC1Z, 13788.0, "BC1Z");
3780 setupPropertyDefaultValue(m_beamBC1Z_0, 13788.0, "BC1Z_0");
3781 setupPropertyDefaultValue(m_beamBC1Z_90, 13788.0, "BC1Z_90");
3782 setupPropertyDefaultValue(m_beamBC1Z_min90, 13788.0, "BC1Z_min90");
3783
3784 setupPropertyDefaultValue(m_beamBC2X1, -0.9369, "BC2X1");
3785 setupPropertyDefaultValue(m_beamBC2X2, 0.191, "BC2X2");
3786 setupPropertyDefaultValue(m_beamBC2Y1, -1.29, "BC2Y1");
3787 setupPropertyDefaultValue(m_beamBC2Y2, 0.187, "BC2Y2");
3788 setupPropertyDefaultValue(m_beamBC2Z, 9411.0, "BC2Z");
3789 setupPropertyDefaultValue(m_beamBC2Z_0, 9411.0, "BC2Z_0");
3790 setupPropertyDefaultValue(m_beamBC2Z_90, 9411.0, "BC2Z_90");
3791 setupPropertyDefaultValue(m_beamBC2Z_min90, 9411.0, "BC2Z_min90");
3792}
3793
3795 setupPropertyDefaultValue(m_beamBC1X1, -0.0462586, "BC1X1");
3796 setupPropertyDefaultValue(m_beamBC1X2, -0.175666, "BC1X2");
3797 setupPropertyDefaultValue(m_beamBC1Y1, -0.051923, "BC1Y1");
3798 setupPropertyDefaultValue(m_beamBC1Y2, -0.176809, "BC1Y2");
3799 setupPropertyDefaultValue(m_beamBC1Z, 13000. + 2760, "BC1Z");
3800 setupPropertyDefaultValue(m_beamBC1Z_0, 13788.0, "BC1Z_0");
3801 setupPropertyDefaultValue(m_beamBC1Z_90, 13788.0, "BC1Z_90");
3802 setupPropertyDefaultValue(m_beamBC1Z_min90, 13788.0, "BC1Z_min90");
3803
3804 setupPropertyDefaultValue(m_beamBC2X1, 0.25202, "BC2X1");
3805 setupPropertyDefaultValue(m_beamBC2X2, -0.18053, "BC2X2");
3806 setupPropertyDefaultValue(m_beamBC2Y1, 0.0431688, "BC2Y1");
3807 setupPropertyDefaultValue(m_beamBC2Y2, -0.181128, "BC2Y2");
3809 setupPropertyDefaultValue(m_beamBC2Z_0, 9411.0, "BC2Z_0");
3810 setupPropertyDefaultValue(m_beamBC2Z_90, 9411.0, "BC2Z_90");
3811 setupPropertyDefaultValue(m_beamBC2Z_min90, 9411.0, "BC2Z_min90");
3812}
3813
3815 // 2016 settings:
3816 //
3817 // https://pcata007.cern.ch/elog/TB2016/88
3818 //
3819 //
3820 // The calibration has been done with the following runs :
3821 // BC1:
3822 // Center : 610212
3823 // Left/up : 610210
3824 // Right/down : 610209
3825 //
3826 // BC2:
3827 // Center : 610256
3828 // Left/up : 610321
3829 // Right/down : 610320
3830 //
3831 // Here are the new constants :
3832 //
3833 // BC1
3834 // horizontal slope = -0.171928
3835 // horizontal offset = -0.047624
3836 //
3837 // vertical slope = -0.172942
3838 // vertical offset = -0.0958677
3839 //
3840 // BC2
3841 // horizontal slope = -0.175698
3842 // horizontal offset = -1.04599
3843 //
3844 // vertical slope = -0.174535
3845 // vertical offset = -3.10666
3846
3847 // June 2016 calibration
3848 //m_beamBC1X1 = -0.047624;
3849 //m_beamBC1X2 = -0.171928;
3850 //m_beamBC1Y1 = -0.0958677;
3851 //m_beamBC1Y2 = -0.172942;
3852 //m_beamBC1Z = 13000. + 2760 /* 2600. */;
3853
3854 //m_beamBC2X1 = -1.04599;
3855 //m_beamBC2X2 = -0.175698;
3856 //m_beamBC2Y1 = -3.10666;
3857 //m_beamBC2Y2 = -0.174535;
3858 //m_beamBC2Z = 2760 /* 2600. */;
3859
3860 // September 2016 calibration, https://pcata007.cern.ch/elog/TB2016/300 (joakim.olsson@cern.ch)
3861 //m_beamBC1X1 = 0.100857923042;
3862 //m_beamBC1X2 = -0.172098;
3863 //m_beamBC1Y1 = -0.133045996607;
3864 //m_beamBC1Y2 = -0.172855178323;
3865 //m_beamBC1Z = 13000. + 2760 /* 2600. */;
3866 //
3867 //m_beamBC2X1 = 0.271555258578 ;
3868 //m_beamBC2X2 = -0.173463 ;
3869 //m_beamBC2Y1 = 0.305483228502;
3870 //m_beamBC2Y2 = -0.173805131744 ;
3871 //m_beamBC2Z = 2760 /* 2600. */;
3872
3873 // June 2017 calibration, https://pcata007.cern.ch/elog/TB2017/550 (schae@cern.ch)
3874 //m_beamBC1X1 = 0.153584934082;
3875 //m_beamBC1X2 = -0.175220;
3876 //m_beamBC1Y1 = -0.493246053303;
3877 //m_beamBC1Y2 = -0.176567356723;
3878 //m_beamBC1Z = 13000. + 2760 /* 2600. */;
3879 //
3880 //m_beamBC2X1 = 0.414611893278;
3881 //m_beamBC2X2 = -0.176122;
3882 //m_beamBC2Y1 = 0.150807740888;
3883 //m_beamBC2Y2 = -0.173472808704;
3884 //m_beamBC2Z = 2760 /* 2600. */;
3885
3886 // August 2017 calibration, https://pcata007.cern.ch/elog/TB2017/550 (schae@cern.ch)
3887 //m_beamBC1X1 = 0.181797;
3888 //m_beamBC1X2 = -0.175657;
3889 //m_beamBC1Y1 = -0.128910;
3890 //m_beamBC1Y2 = -0.175965;
3891 //m_beamBC1Z = 13000. + 2760 /* 2600. */;
3892 //
3893 //m_beamBC2X1 = 0.611502;
3894 //m_beamBC2X2 = -0.183116;
3895 //m_beamBC2Y1 = 0.541212;
3896 //m_beamBC2Y2 = -0.183115;
3897 //m_beamBC2Z = 2760 /* 2600. */;
3898
3899 // September 2017 calibration, https://pcata007.cern.ch/elog/TB2017/550 (schae@cern.ch)
3900 //m_beamBC1X1 = 0.181797;
3901 //m_beamBC1X2 = -0.175657;
3902 //m_beamBC1Y1 = -0.128910;
3903 //m_beamBC1Y2 = -0.175965;
3904 //m_beamBC1Z = 13000. + 2760 /* 2600. */;
3905
3906 //m_beamBC2X1 = 0.622896039922;
3907 //m_beamBC2X2 = -0.176735;
3908 //m_beamBC2Y1 = 0.195954125116;
3909 //m_beamBC2Y2 = -0.176182117624;
3910 //m_beamBC2Z = 2760 /* 2600. */;
3911
3912 // September 2017 calibration with additional precision from Survey
3913 setupPropertyDefaultValue(m_beamBC1X1, 0.681797, "BC1X1");
3914 setupPropertyDefaultValue(m_beamBC1X2, -0.175657, "BC1X2");
3915 setupPropertyDefaultValue(m_beamBC1Y1, -2.02891, "BC1Y1");
3916 setupPropertyDefaultValue(m_beamBC1Y2, -0.175965, "BC1Y2");
3917 setupPropertyDefaultValue(m_beamBC1Z, 17348.8, "BC1Z");
3918 setupPropertyDefaultValue(m_beamBC1Z_0, 17348.8, "BC1Z_0");
3919 setupPropertyDefaultValue(m_beamBC1Z_90, 15594.05, "BC1Z_90");
3920 setupPropertyDefaultValue(m_beamBC1Z_min90, 15571.8, "BC1Z_min90");
3921
3922 setupPropertyDefaultValue(m_beamBC2X1, -24.377104, "BC2X1");
3923 setupPropertyDefaultValue(m_beamBC2X2, -0.176735, "BC2X2");
3924 setupPropertyDefaultValue(m_beamBC2Y1, 17.895954, "BC2Y1");
3925 setupPropertyDefaultValue(m_beamBC2Y2, -0.176182117624, "BC2Y2");
3926 setupPropertyDefaultValue(m_beamBC2Z, 4404.2, "BC2Z");
3927 setupPropertyDefaultValue(m_beamBC2Z_0, 4420.7, "BC2Z_0");
3928 setupPropertyDefaultValue(m_beamBC2Z_90, 2649.45, "BC2Z_90");
3929 setupPropertyDefaultValue(m_beamBC2Z_min90, 2627.2, "BC2Z_min90");
3930
3931}
Scalar eta() const
pseudorapidity method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< size_t > vec
#define CHECK(...)
Evaluate an expression and check for errors.
double length(const pvec &v)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t sc
AtlasHitsVector< TileHit > TileHitVector
#define WRONG_CHANNEL(frag, chan)
#define SIGNAL_FOUND(frag, chan, amplitude)
#define MAX_DRAWERS
#define FRAG_FOUND(frag, chan, size)
#define WRONG_SAMPLE(frag, chan, size)
#define COIN_TRIG4_FRAG
Definition TileTBFrag.h:35
#define COIN_TRIG2_FRAG
Definition TileTBFrag.h:33
#define MUON_ADC_FRAG
Definition TileTBFrag.h:25
#define COIN_TRIG7_FRAG
Definition TileTBFrag.h:38
#define COIN_TRIG5_FRAG
Definition TileTBFrag.h:36
#define COIN_TRIG8_FRAG
Definition TileTBFrag.h:39
#define COIN_TRIG6_FRAG
Definition TileTBFrag.h:37
#define LASE_ADC_FRAG
Definition TileTBFrag.h:28
#define LASE_PTN_FRAG
Definition TileTBFrag.h:27
#define COMMON_TDC2_FRAG
Definition TileTBFrag.h:47
#define COMMON_PTN_FRAG
Definition TileTBFrag.h:48
#define COMMON_ADC1_FRAG
Definition TileTBFrag.h:43
#define COMMON_ADC2_FRAG
Definition TileTBFrag.h:44
#define COMMON_TDC1_FRAG
Definition TileTBFrag.h:46
#define BEAM_TDC_FRAG
Definition TileTBFrag.h:23
#define COIN_TRIG3_FRAG
Definition TileTBFrag.h:34
#define DIGI_PAR_FRAG
Definition TileTBFrag.h:41
#define COMMON_TOF_FRAG
Definition TileTBFrag.h:45
#define COIN_TRIG1_FRAG
Definition TileTBFrag.h:32
#define ADDR_ADC_FRAG
Definition TileTBFrag.h:26
#define BEAM_ADC_FRAG
Definition TileTBFrag.h:24
#define ADD_FADC_FRAG
Definition TileTBFrag.h:29
#define ECAL_ADC_FRAG
Definition TileTBFrag.h:30
static const Attributes_t empty
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
bool empty() const
Container class for CaloCell.
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const T * get(size_type n) const
Access an element, as an rvalue.
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Property holding a SG store/key/clid from which a ReadHandle is made.
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool empty() const
Test if the key is blank.
static const TileCablingService * getInstance()
get pointer to service instance
static unsigned int getDrawerIdxFromFragId(unsigned int fragId)
Returns a drawer hash from fragId This function assumes drawer context (i.e.
Class that holds Data Quality fragment information and provides functions to extract the data quality...
int checkHeaderParityErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has header word parity error
int checkSampleParityErr(int partition, int drawer, int dmu, int gain) const
returns 1 if DMU has data word parity error
HWIdentifier pmt_HWID(void) const
Return pmt hardware ID (== channel ID)
Definition TileHit.cxx:125
float time(int ind=0) const
Return time of ind-th sub-hit.
float energy(int ind=0) const
Return energy of ind-th sub-hit.
int size(void) const
Return length of energy/time vectors.
int getFiltNumber() const
double getSigmaPedAlpha(const unsigned int i, const unsigned int gain=0) const
double getSigmaAlpha(const unsigned int i, const unsigned int gain=0) const
double getPedestalAlpha(const unsigned int i, const unsigned int gain=0) const
double getPumpDiodeTemp() const
int getPMADC(const unsigned int j, const unsigned int gain=0) const
double getPMSigmaPedestal(const unsigned int j, const unsigned int gain=0) const
double getAlpha(const unsigned int i, const unsigned int gain=0) const
double getDiodeCurrOrd() const
int getDiodeADC(const unsigned int i, const unsigned int gain=0) const
double getDiodeSigmaPedestal(const unsigned int i, const unsigned int gain=0) const
int getBCID() const
double getDiodePedestal(const unsigned int i, const unsigned int gain=0) const
int getTDC(const unsigned int j, const unsigned int gain=0) const
double getDiodeCurrMeas() const
double getPMPedestal(const unsigned int j, const unsigned int gain=0) const
uint32_t get_bsflags() const
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
std::vector< std::array< float, MAX_CHAN > > m_pedflxfitVec
std::vector< std::array< int, MAX_CHAN > > m_gainVec
std::vector< std::array< float, MAX_CHAN > > m_tfitcVec
SG::ReadHandleKey< TileHitVector > m_hitVectorKey
void ENETOTAL_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree ENETOTAL vari...
StatusCode ntuple_initialize(const EventContext &ctx)
Alg standard interface function LF TODO: We could have a problem with the new feature introduced by S...
std::vector< std::array< float, MAX_CHAN > > m_chi2DspVec
Gaudi::Property< float > m_beamBN1Y1
Gaudi::Property< float > m_beamBC1Y2
StatusCode storeRawChannels(const EventContext &ctx, const SG::ReadHandleKey< TileRawChannelContainer > &containerKey, bool calibMode, std::vector< std::array< float, MAX_CHAN > > *eneVec, std::vector< std::array< float, MAX_CHAN > > *timeVec, std::vector< std::array< float, MAX_CHAN > > *chi2Vec, std::vector< std::array< float, MAX_CHAN > > *pedVec, bool saveDQstatus=false)
/ Fill ntuple with data from TRC.
Gaudi::Property< float > m_beamBC2Z_90
StatusCode initList(const EventContext &ctx)
Gaudi::Property< float > m_beamBC0Z
std::array< float, 4 > m_LarEne
std::array< unsigned int, 96 > m_coincTrig2
Gaudi::Property< float > m_beamBN2Y1
StatusCode storeBeamElements(const EventContext &ctx)
Gaudi::Property< int > m_nSamplesFlx
void DIGI_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree DIGI variables...
const TileHWID * m_tileHWID
std::vector< std::vector< int > > * m_btdc
std::array< unsigned int, 96 > m_coincTrig6
std::array< int, 16 > m_btdc1
std::vector< short > m_sizeVec
void FELIX_addBranch(void)
std::array< float, 8 > m_ecal
short CheckDMUParity(uint32_t header)
Parity of the DMU header should be odd.
void ADDER_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree ADDER variable...
std::array< float, 3 > m_ExtEne
std::vector< int > m_l1Type
Gaudi::Property< std::vector< std::string > > m_beamFragList
SG::ReadHandleKey< TileDQstatus > m_dqStatusKey
std::vector< int > m_nSamplesFlxInDrawer
void MUON_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree MUON variable...
StatusCode initListFlx(const EventContext &ctx)
Gaudi::Property< Long64_t > m_treeSize
std::vector< std::array< uint32_t, MAX_DMU > > m_DMUheaderVec
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdBcidflxVec
Gaudi::Property< float > m_beamBC1X2
std::vector< std::array< float, MAX_CHAN > > m_tDspVec
std::vector< int > m_frBCID
void ADDER_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree ADDER variabl...
Gaudi::Property< std::string > m_ntupleID
std::vector< int * > m_adder
SG::ReadHandleKey< TileRawChannelContainer > m_fitRawChannelContainerKey
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUDstrobeErrVec
const TileCablingService * m_cabling
StatusCode storeLaser(const EventContext &ctx)
Gaudi::Property< float > m_beamBC1Z
SG::ReadHandleKey< TileRawChannelContainer > m_flxOptRawChannelContainerKey
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdChargeflxVec
std::array< float, 3 > m_GapEne
void ENETOTAL_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree ENETOTAL varia...
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdChargeTimeflxVec
Gaudi::Property< float > m_beamBC1Z_min90
std::vector< std::array< float, MAX_CHAN > > m_tflxoptVec
double m_las_D2_AlphaPed_RMS
Gaudi::Property< std::vector< std::string > > m_drawerList
Gaudi::Property< float > m_beamBC2X2
SG::ReadHandleKey< TileRawChannelContainer > m_fitcRawChannelContainerKey
Gaudi::Property< std::string > m_etaFileName
TileRawChannelUnit::UNIT m_rchUnit
Unit for TileRawChannels (ADC, pCb, MeV)
void QDC_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add QDC variables to th...
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdCapacitorflxVec
Gaudi::Property< unsigned int > m_nDrawersFlx
std::vector< std::array< float, MAX_CHAN > > m_chi2OptVec
void setupBeamChambersTB2016_2020(void)
double m_las_PMT1_Ped_RMS
Gaudi::Property< int > m_finalUnit
std::vector< std::array< float, MAX_CHAN > > m_thitCnt
std::vector< std::array< float, MAX_CHAN > > m_chi2cVec
SG::ReadHandleKey< TileRawChannelContainer > m_flxFitRawChannelContainerKey
Gaudi::Property< float > m_beamBN2Y2
std::vector< std::array< float, MAX_CHAN > > m_chi2flxfitVec
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdPedLoflxVec
bool m_calibrateEnergyThisEvent
StatusCode storeHitContainer(const EventContext &ctx)
/ Fill Ntuple with MC truth info from simulation / Namely, hit energies corrected by photoelectron st...
ServiceHandle< ITHistSvc > m_thistSvc
Gaudi::Property< float > m_beamBC2Z_0
Gaudi::Property< bool > m_completeNtuple
Gaudi::Property< bool > m_calibrateEnergy
Gaudi::Property< float > m_beamBC2X1
std::vector< std::array< float, MAX_CHAN > > m_ehitVec
std::array< unsigned int, 96 > m_coincTrig7
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdRunTypeflxVec
std::vector< short > m_sizeflxVec
void MUON_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add MUON variables to t...
void setupBeamChambersBeforeTB2015(void)
short CheckDMUFormat(uint32_t header)
bit_31 of the DMU header must be 1 and bit_17 of the DMU header must be 0
Gaudi::Property< float > m_beamBC2Z
std::vector< std::array< float, MAX_CHAN > > m_pedflxoptVec
StatusCode storeCells(const EventContext &ctx)
std::vector< std::array< float, MAX_CHAN > > m_eflxoptVec
Gaudi::Property< float > m_beamBC1Y1
void setupPropertyDefaultValue(float property, float defaultValue, const std::string &name)
Gaudi::Property< float > m_radius
SG::ReadHandleKey< TileRawChannelContainer > m_dspRawChannelContainerKey
void setupBeamChambersTB2015(void)
std::array< int, 16 > m_btdc2
Gaudi::Property< std::vector< int > > m_drawerType
SG::ReadHandleKey< TileLaserObject > m_laserObjectKey
std::vector< int > m_nSamplesInDrawer
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdRunflxVec
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
std::vector< std::array< float, MAX_CHAN > > m_pedfitVec
TileTBAANtuple(const std::string &name, ISvcLocator *pSvcLocator)
void LASER_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree LASER variable...
std::vector< std::array< float, MAX_CHAN > > m_eOptVec
std::vector< std::array< int, MAX_DMU > > m_bcidVec
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdPedHiflxVec
std::vector< std::array< short, 2 > > m_ROD_DMUMaskVec
std::vector< std::array< int, MAX_DMU > > m_feCRCVec
std::vector< std::unique_ptr< int[]> > m_sampleVec
StatusCode initNTuple(void)
std::map< unsigned int, unsigned int, std::less< unsigned int > > m_drawerMap
double m_las_D3_AlphaPed_RMS
std::array< float, 14 > m_muBack
std::vector< int > m_l1ID
std::vector< std::array< float, MAX_CHAN > > m_tfitVec
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdModuleflxVec
Gaudi::Property< float > m_beamBC0X1
std::vector< int > m_adderPayload
std::vector< std::array< float, MAX_CHAN > > m_chi2flxoptVec
std::vector< std::array< float, MAX_CHAN > > m_pedFlatVec
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUSstrobeErrVec
int digiChannel2PMT(int fragType, int chan)
void HIT_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// /Clear Tree HIT variable...
void TRIGGER_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree TRIGGER varia...
void LASER_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree LASER variabl...
Gaudi::Property< float > m_beamBN1X1
std::vector< std::array< short, MAX_DMU > > m_DMUformatErrVec
void CISPAR_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree CISPAR variabl...
void CISPAR_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree CISPAR variab...
std::array< float, 16 > m_timeAdd
std::vector< std::array< short, MAX_DMU > > m_DMUDataparityErrVec
std::array< unsigned int, 96 > m_coincTrig1
std::map< int, int > m_nSamplesFlxInDrawerMap
std::vector< std::array< short, MAX_DMU > > m_DMUHeadparityErrVec
void clear_init_minus1(std::vector< T > &vec)
TileRawChannelUnit::UNIT m_dspUnit
Unit for TileRawChannels in DSP.
std::vector< std::array< float, MAX_CHAN > > m_efitcVec
std::array< uint32_t, 33 > m_qdc
Gaudi::Property< float > m_beamBN1X2
StatusCode storeDigitsFlx(const EventContext &ctx, const SG::ReadHandleKey< TileDigitsContainer > &containerKey)
std::vector< std::array< float, MAX_CHAN > > m_chi2FlatVec
Gaudi::Property< int > m_nSamples
std::vector< std::array< short, MAX_DMU > > m_DMUmemoryErrVec
std::vector< std::array< float, MAX_CHAN > > m_thitVec
void HIT_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree HIT variables ...
double m_las_D4_AlphaPed_RMS
Gaudi::Property< float > m_beamBC1X1
std::vector< int > m_evType
Gaudi::Property< float > m_beamBC1Z_90
Gaudi::Property< int > m_eventsPerFile
std::vector< std::array< float, MAX_CHAN > > m_pedfitcVec
std::vector< std::array< float, MAX_CHAN > > m_eflxfitVec
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUmemoryErrVec
std::vector< short > m_ROD_GlobalCRCVec
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUHeadformatErrVec
std::vector< std::array< int, 2 > > m_slinkCRCVec
std::array< int, 16 > m_tof
double m_las_D1_AlphaPed_RMS
Gaudi::Property< float > m_beamBN2X2
std::vector< std::array< float, MAX_CHAN > > m_eDspVec
std::array< float, 3 > m_BarEne
Gaudi::Property< unsigned int > m_nDrawers
Gaudi::Property< std::string > m_streamName
SG::ReadHandleKey< TileRawChannelContainer > m_flatRawChannelContainerKey
ToolHandle< TileRawChannelBuilderFlatFilter > m_adderFilterAlgTool
double m_las_PMT2_Ped_RMS
std::vector< std::array< float, MAX_CHAN > > m_efitVec
std::vector< std::array< float, MAX_CHAN > > m_ehitCnt
double m_las_D4_Alpha_RMS
Gaudi::Property< float > m_beamBC1Z_0
std::vector< std::array< float, MAX_CHAN > > m_eneVec
void FELIX_clearBranch(void)
std::array< float, 2 > m_muCalib
std::vector< std::array< int, MAX_DMU > > m_rodCRCVec
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
void TRIGGER_addBranch(void)
///////////////////////////////////////////////////////////////////////////
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUDataformatErrVec
Gaudi::Property< int > m_TBperiod
double m_las_D2_Alpha_RMS
std::array< unsigned int, 96 > m_coincTrig8
virtual StatusCode initialize() override
std::array< unsigned int, 96 > m_coincTrig4
std::array< float, 16 > m_eneAdd
StatusCode storeDigits(const EventContext &ctx, const SG::ReadHandleKey< TileDigitsContainer > &containerKey, const TileDQstatus *dqStatus=nullptr)
/ Fill Ntuple with info from TileDigits / Return true if the collection is empty, / which means that ...
std::array< int, 16 > m_scaler
void clear_init_zero(std::vector< std::array< T, N > > &vec)
Gaudi::Property< bool > m_bsInput
void ECAL_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree ECAL variable...
std::array< float, 4 > m_lasExtra
void BEAM_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree BEAM variable...
std::array< unsigned int, 96 > m_coincTrig3
double m_las_D1_Alpha_RMS
std::vector< std::array< float, MAX_CHAN > > m_tflxfitVec
void QDC_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree QDC variables
std::vector< std::array< int, MAX_MINIDRAWER > > m_mdL1idflxVec
std::map< unsigned int, unsigned int, std::less< unsigned int > > m_drawerFlxMap
Gaudi::Property< float > m_beamBC0Y1
Gaudi::Property< float > m_beamBN1Y2
std::vector< std::array< short, MAX_DMU > > m_ROD_DMUBCIDVec
Gaudi::Property< float > m_beamBC2Z_min90
void ECAL_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add ECAL variables to t...
std::vector< std::unique_ptr< int[]> > m_sampleflxVec
std::vector< int > m_evtflxVec
std::vector< std::array< short, MAX_DMU > > m_DMUparityErrVec
std::vector< std::array< short, MAX_DMU > > m_DMUDstrobeErrVec
Gaudi::Property< float > m_beamBC0Y2
void DIGI_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// /Clear Tree DIGI variabl...
std::vector< std::array< int, MAX_CHAN > > m_gainflxVec
std::vector< std::array< short, MAX_DMU > > m_DMUSstrobeErrVec
void storeHit(const TileHit *hit, int fragType, int fragId, std::array< float, MAX_CHAN > &ehitVec, std::array< float, MAX_CHAN > &thitVec, const TileSamplingFraction *samplingFraction)
Gaudi::Property< float > m_beamBC0X2
bool m_beamIdList[32]
std::array< unsigned int, 96 > m_coincTrig5
Gaudi::Property< float > m_beamBN2X1
StatusCode ntuple_clear()
Gaudi::Property< bool > m_calibMode
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerFlxKey
void COINCBOARD_clearBranch(void)
//////////////////////////////////////////////////////////////////////////// Clear Tree COINCBOARD va...
std::vector< short > m_rodBCIDflxVec
void BEAM_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree BEAM variables...
Gaudi::Property< float > m_beamBC2Y2
double m_las_D3_Alpha_RMS
std::map< int, int > m_nSamplesInDrawerMap
std::map< unsignedint, unsignedint, std::less< unsignedint > >::iterator drawerMap_iterator
std::vector< std::array< float, MAX_CHAN > > m_timeVec
Gaudi::Property< bool > m_pmtOrder
SG::ReadHandleKey< TileRawChannelContainer > m_optRawChannelContainerKey
const TileID * m_tileID
std::vector< std::array< float, MAX_CHAN > > m_chi2Vec
SG::ReadHandleKey< TileBeamElemContainer > m_beamElemContainerKey
Gaudi::Property< float > m_beamBC2Y1
Gaudi::Property< std::vector< std::string > > m_rosName
std::vector< short > m_rodBCIDVec
std::vector< std::array< float, MAX_CHAN > > m_tOptVec
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
std::vector< int > m_evBCID
std::vector< std::array< int, 2 > > m_dmuMaskVec
Gaudi::Property< bool > m_unpackAdder
void COINCBOARD_addBranch(void)
//////////////////////////////////////////////////////////////////////////// /Add Tree COINCBOARD var...
std::vector< std::array< float, MAX_CHAN > > m_pedOptVec
void clear_samples(std::vector< std::unique_ptr< int[]> > &vec, const std::vector< int > &nsamples, int nchan=MAX_CHAN)
Gaudi::Property< bool > m_useDspUnits
std::vector< int > m_evtVec
void checkIsPropertySetup(float property, const std::string &name)
StatusCode storeHitVector(const EventContext &ctx)
virtual StatusCode execute() override
uint32_t runNumber() const
The current event's run number.
int ir
counter of the current depth
Definition fastadd.cxx:49
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1
EventInfo_v1 EventInfo
Definition of the latest event info version.
TChain * tree