200 {
201
202
203
204
205
206
207
208
210
211
212 ATHRNG::RNGWrapper* rngWrapper =
219 CLHEP::HepRandomEngine* rndmEngine = *rngWrapper;
220
221
222
223
226 }
227
228 SG::ReadCondHandle<ILArfSampl> fSamplhdl(
m_fSamplKey);
229 const ILArfSampl* fSampl = *fSamplhdl;
230
232
236 }
237
238
239
240
241 double trigtime = 0;
244 }
246
247
248
249
250
252 ATH_CHECK(ttL1ContainerEm.record(std::make_unique<LArTTL1Container>()));
253
255 ATH_CHECK(ttL1ContainerHad.record(std::make_unique<LArTTL1Container>()));
256
257 std::unique_ptr<LArTTL1Container> truth_ttL1ContainerEm;
258 std::unique_ptr<LArTTL1Container> truth_ttL1ContainerHad;
260 truth_ttL1ContainerEm = std::make_unique<LArTTL1Container>();
261 truth_ttL1ContainerHad = std::make_unique<LArTTL1Container>();
262 }
263
264
265
268 std::vector<std::vector<float> >
269 sumEnergy;
270 std::vector<std::vector<float> >
271 sumEnergy2;
272 sumEnergy.resize(nbTT);
273 sumEnergy2.resize(nbTT);
274 std::vector<float> ttSumE;
275 int ttSumEvecSize = 0;
276 int refTime = 0;
278 ttSumEvecSize = 2 * crossingTime - 1;
279 refTime = crossingTime - 1;
280 } else {
283 }
285 << ttSumEvecSize << " reference time= " << refTime);
286 ttSumE.resize(ttSumEvecSize);
287 for (unsigned int iTT = 0; iTT < nbTT; iTT++) {
288 sumEnergy[iTT] = ttSumE;
289 sumEnergy2[iTT] = ttSumE;
290 }
291
292 m_chronSvc->chronoStart(
"LArTTL1Mk hit loop ");
293
295 int it_end = hitmap->GetNbCells();
297
298
299
300
301
302
303 float outOfTimeE = 0.;
304 int nOutOfTime = 0;
305 float inTimeE = 0.;
306 int nInTime = 0;
307 float printEthresh = 20.;
308 int nMissingGain = 0;
309 for (;
it != it_end; ++
it) {
310 const LArHitList& hitlist = hitmap->GetCell(it);
311 const std::vector<std::pair<float, float> >& timeE = hitlist.
getData();
312 if (!timeE.empty()) {
313 Identifier cellId =
m_OflHelper->cell_id(IdentifierHash(it));
314 int specialCase = 0;
315 bool skipCell = false;
316
317
318
319
320 if (!
m_ttSvc->is_in_lvl1(cellId))
321 skipCell = true;
322
323 if (!skipCell) {
324
325
326
327 Identifier ttId =
m_ttSvc->whichTTID(cellId);
328
331 }
332
333
334
335
336
337 const float cellSampFraction = fSampl->
FSAMPL(cellId);
338 const float inv_cellSampFraction = 1. / cellSampFraction;
339
340
341
342 float relGain = 0.;
343 float sinTheta = 0.;
344
348
349
352 std::vector<float> vecRG;
354
356 } else {
357
358 if (!barrelEnd) {
360 } else {
361
362
363
365 specialCase = 1;
368 }
369 }
370 relGain = 1.;
371 }
372
373
376 relGain = 1.;
377 }
378
379
381 IdentifierHash fcalHash =
m_fcalHelper->channel_hash(cellId);
383 if (relGain < 0.001) {
384 nMissingGain++;
386 <<
m_emHelper->show_to_string(cellId) <<
" (index "
387 << fcalHash << "), setting default value 1. ");
388 relGain = 1.;
389 }
390 sinTheta = 1.;
391 }
395 }
396
398
399
400
401
402
403
404
405 for (const auto& first : timeE) {
406 float hitEnergy =
first.first;
409 if (hitEnergy > printEthresh) {
413 << " energy= " << hitEnergy);
414 }
415
416
418 }
419
420
421 if (fabs(hitEnergy) > 1e+9) {
424 << " energy= " << hitEnergy);
425 hitEnergy = 0.;
427 }
428
429
430
431 int iShift = 0;
433
434
435 iShift =
static_cast<int>(floor(
hitTime + 0.5));
436 } else {
437
438
439 iShift =
static_cast<int>(floor(
hitTime * crossingRate + 0.5));
440 }
441
442
443
444 int iTime = iShift + refTime;
445
446
447
448 if (iTime >= 0 && iTime < ttSumEvecSize) {
449
450 if (!specialCase) {
451
452
453 ttSumE = sumEnergy[ttHash];
454 ttSumE[iTime] +=
455 hitEnergy * inv_cellSampFraction * sinTheta * relGain;
456 sumEnergy[ttHash] = ttSumE;
457 } else {
458
459
460 ttSumE = sumEnergy2[ttHash];
461 ttSumE[iTime] +=
462 hitEnergy * inv_cellSampFraction * sinTheta * relGain;
463 sumEnergy2[ttHash] = ttSumE;
464 }
465
466
467
468
469 inTimeE += hitEnergy;
470 nInTime++;
471 }
472 else {
473 outOfTimeE += hitEnergy;
474 nOutOfTime++;
475 if (hitEnergy > printEthresh) {
477 ATH_MSG_DEBUG(
"Found a hit out of the timing window, hitTime= "
478 <<
hitTime <<
" with more than " << printEthresh
479 << " MeV: hitEnergy= " << hitEnergy << " MeV");
480 } else {
482 "Found a hit out of the timing window, hitTime= "
483 <<
hitTime <<
" with more than " << printEthresh
484 << " MeV: hitEnergy= " << hitEnergy << " MeV");
485 }
486 }
487 }
488 }
489 }
490 }
491
492 }
493
494 ATH_MSG_DEBUG(
"Number of missing relative FCAL gains for this event = "
495 << nMissingGain);
496 if (inTimeE == 0 || nInTime == 0)
498 else
500 << outOfTimeE << " MeV"
501 << " represents " << 100. * outOfTimeE / inTimeE
502 << " % of in time energy for " << nOutOfTime << " ("
503 << 100. * nOutOfTime / nInTime << " %) hits");
504 if (outOfTimeE > 0.02 * inTimeE) {
506 << outOfTimeE << " MeV"
507 << " larger than 2% of in time energy = " << inTimeE
508 << " MeV; nb of out of time hits = " << nInTime << " ("
509 << (nInTime > 0 ? 100. * nOutOfTime / nInTime : 0)
510 << " %)");
511 }
512
514 m_chronSvc->chronoStop(
"LArTTL1Mk hit loop ");
515 m_chronSvc->chronoPrint(
"LArTTL1Mk hit loop ");
516 m_chronSvc->chronoStart(
"LArTTL1Mk TT loop ");
517 }
518
519 std::vector<std::string> emHadString(2);
520 emHadString[0] = "ElectroMagnetic";
521 emHadString[1] = "Hadronic";
522
523 std::vector<Identifier>::const_iterator itTt =
m_lvl1Helper->tower_begin();
524 std::vector<Identifier>::const_iterator itEnd =
m_lvl1Helper->tower_end();
525
526
527
528
529
531 for (; itTt != itEnd; ++itTt) {
532
533 Identifier towerId = (*itTt);
534
535
536
537
539
541
542 IdentifierHash ttHash =
m_lvl1Helper->tower_hash(towerId);
546
547
548
549
552 }
555 std::vector<float> sumTTE = sumEnergy[ttHash];
556 std::vector<float> sumTTE2 = sumEnergy2[ttHash];
557 int nSpecialCase = 0;
558
559 bool hasE = false;
560 for (
unsigned int i = 0;
i < sumTTE.size(); ++
i) {
561 if (fabs(sumTTE[i]) > 0.) {
562 hasE = true;
563 break;
564 }
565 }
566
567 bool hasE2 = false;
568 for (
unsigned int i = 0;
i < sumTTE2.size(); ++
i) {
569 if (fabs(sumTTE2[i]) > 0.) {
570 hasE2 = true;
571 break;
572 }
573 }
574
575
576 if (hasE || hasE2) {
577
578
579 if (hasE) {
580 analogSum =
computeSignal(towerId, Ieta, 0, sumTTE, refTime);
581 }
582
583
584
585
586
587 if (hasE2) {
588 nSpecialCase += 1;
589 if (nSpecialCase > 1) {
591 " more than 1 special case, current Trigger Tower is "
592 << emHadString[emHad] << ": "
593 <<
m_emHelper->show_to_string(towerId) <<
" ");
594 }
595 analogSum2 =
computeSignal(towerId, Ieta, 1, sumTTE2, refTime);
596 for (
int isamp = 0; isamp <
s_NBSAMPLES; isamp++) {
597 analogSum[isamp] += analogSum2[isamp];
598 }
599 }
600
603 << emHadString[emHad] << ": "
604 <<
m_emHelper->show_to_string(towerId) <<
" ");
606 " transverse E (i.e. sum E / sampling fraction * sin_theta * rel "
607 "gain)= (at ref. time, before calib)"
608 << sumTTE[refTime] << " + " << sumTTE2[refTime]
609 << " (special cases) ");
610 } else if (sumTTE[refTime] > 0.) {
612 << emHadString[emHad] << ": "
613 <<
m_emHelper->show_to_string(towerId) <<
" ");
615 " [very low] transverse E (i.e. sum E / sampling fraction * "
616 "sin_theta * rel gain)= (at ref. time, before calib)"
617 << sumTTE[refTime] << " + " << sumTTE2[refTime]
618 << " (special cases) ");
619 }
620 }
624 }
625
626
627
628
631 }
634 fullSignal =
computeNoise(towerId, Ieta, analogSum, rndmEngine);
635 } else {
636 fullSignal = analogSum;
637 }
638
642 }
643
645 ATH_MSG_DEBUG(
" uncalibrated amplitudes around peak (+-3 time slots): "
646 << sumTTE[refTime - 3] << ", " << sumTTE[refTime - 2]
647 << ", " << sumTTE[refTime - 1] << ", " << sumTTE[refTime]
648 << ", " << sumTTE[refTime + 1] << ", "
649 << sumTTE[refTime + 2] << ", " << sumTTE[refTime + 3]);
651 << analogSum[0] << ", " << analogSum[1] << ", "
652 << analogSum[2] << ", " << analogSum[3] << ", "
653 << analogSum[4] << ", " << analogSum[5] << ", "
654 << analogSum[6]);
656 << analogSum[0] / analogSum[3] << ", "
657 << analogSum[1] / analogSum[3] << ", "
658 << analogSum[2] / analogSum[3] << ", "
659 << analogSum[3] / analogSum[3] << ", "
660 << analogSum[4] / analogSum[3] << ", "
661 << analogSum[5] / analogSum[3] << ", "
662 << analogSum[6] / analogSum[3]);
664 << fullSignal[0] << ", " << fullSignal[1] << ", "
665 << fullSignal[2] << ", " << fullSignal[3] << ", "
666 << fullSignal[4] << ", " << fullSignal[5] << ", "
667 << fullSignal[6]);
668 if (
msgLvl(MSG::VERBOSE)) {
669 for (unsigned int iTime = 0; iTime < sumTTE.size(); iTime++) {
671 << iTime << " hit energy = " << sumTTE[iTime]);
672 }
673 }
674 } else if (sumTTE[refTime] > 0.) {
676 " uncalibrated amplitudes around peak (+-3 time slots): "
677 << sumTTE[refTime - 3] << ", " << sumTTE[refTime - 2] << ", "
678 << sumTTE[refTime - 1] << ", " << sumTTE[refTime] << ", "
679 << sumTTE[refTime + 1] << ", " << sumTTE[refTime + 2] << ", "
680 << sumTTE[refTime + 3]);
682 << analogSum[0] << ", " << analogSum[1] << ", "
683 << analogSum[2] << ", " << analogSum[3] << ", "
684 << analogSum[4] << ", " << analogSum[5] << ", "
685 << analogSum[6]);
687 << analogSum[0] / analogSum[3] << ", "
688 << analogSum[1] / analogSum[3] << ", "
689 << analogSum[2] / analogSum[3] << ", "
690 << analogSum[3] / analogSum[3] << ", "
691 << analogSum[4] / analogSum[3] << ", "
692 << analogSum[5] / analogSum[3] << ", "
693 << analogSum[6] / analogSum[3]);
695 << fullSignal[0] << ", " << fullSignal[1] << ", "
696 << fullSignal[2] << ", " << fullSignal[3] << ", "
697 << fullSignal[4] << ", " << fullSignal[5] << ", "
698 << fullSignal[6]);
699 }
700
702
703
704
705
706 LArTTL1* ttL1;
707 HWIdentifier ttChannel;
708 ttL1 = new LArTTL1(ttChannel, towerId, fullSignal);
709 if (emHad) {
710 ttL1ContainerHad->push_back(ttL1);
711 } else {
712 ttL1ContainerEm->push_back(ttL1);
713 }
714
716 std::vector<float>
et(3);
717 et[0] = sumTTE[refTime - 1];
718 et[1] = sumTTE[refTime];
719 et[2] = sumTTE[refTime + 1];
720 LArTTL1* truth_ttL1 =
new LArTTL1(ttChannel, towerId,
et);
721 if (emHad) {
722 truth_ttL1ContainerHad->push_back(truth_ttL1);
723 } else {
724 truth_ttL1ContainerEm->push_back(truth_ttL1);
725 }
726 }
727 }
728
729 }
730 }
733 m_chronSvc->chronoPrint(
"LArTTL1Mk TT loop ");
734 }
735
737 << ttL1ContainerEm->size() << " , "
738 << ttL1ContainerHad->size());
739
740 return StatusCode::SUCCESS;
741}
#define ATH_CHECK
Evaluate an expression and check for errors.
float et(const xAOD::jFexSRJetRoI *j)
SeedingOptionType
Options for seeding option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is s...
void setSeedLegacy(const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint64_t offset, SeedingOptionType seeding, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT)
Set the random seed using a string (e.g.
bool msgLvl(const MSG::Level lvl) const
virtual const float & FSAMPL(const HWIdentifier &id) const =0
const LARLIST & getData() const
std::vector< float > m_sinThetaEmec
auxiliary EMEC data: sin(theta)
SG::WriteHandleKey< LArTTL1Container > m_HadTTL1ContainerName
algorithm property: container name for the HAD TTL1s
SG::WriteHandleKey< LArTTL1Container > m_EmTTL1ContainerName
algorithm property: container name for the EM TTL1s
Gaudi::Property< bool > m_useLegacyRandomSeeds
Gaudi::Property< bool > m_useTriggerTime
Alorithm property: use trigger time or not.
std::vector< float > m_sinThetaEmb
auxiliary EMBarrel data: sin(theta)
IChronoStatSvc * m_chronSvc
std::vector< float > computeNoise(const Identifier towerId, const int Ieta, std::vector< float > &inputV, CLHEP::HepRandomEngine *rndmEngine)
std::vector< float > computeSignal(const Identifier towerId, const int Ieta, const int specialCase, std::vector< float > visEnergy, const int refTime) const
initialize hit map
Gaudi::Property< std::string > m_truthHitsContainer
key for saving truth
PublicToolHandle< CaloTriggerTowerService > m_ttSvc
SG::ReadHandleKey< LArHitEMap > m_hitMapKey
hit map
std::vector< float > m_sinThetaHec
auxiliary HEC data: sin(theta)
const LArFCAL_ID * m_fcalHelper
pointer to the offline FCAL helper
PublicToolHandle< ITriggerTime > m_triggerTimeTool
Alorithm property: name of the TriggerTimeTool.
Gaudi::Property< float > m_debugThresh
algorithm property: debug threshold
Gaudi::Property< std::string > m_randomStreamName
const CaloCell_ID * m_OflHelper
pointer to the offline id helper
Gaudi::Property< bool > m_chronoTest
algorithm property: switch chrono on
Gaudi::Property< bool > m_NoiseOnOff
algorithm property: noise (in all sub-detectors) is on if true
Gaudi::Property< uint32_t > m_randomSeedOffset
ServiceHandle< IAthRNGSvc > m_RandomSvc
std::vector< float > m_cellRelGainFcal
auxiliary FCAL data: relative gains
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
Sampling fractions retrieved from DB.
static const short s_PEAKPOS
peak position
int decodeInverse(int region, int eta)