Execute on an entire collection of clusters.
431{
432
433 ATH_MSG_DEBUG(
"Starting CaloCalibClusterMomentsMaker2::execute");
435 const CaloDetDescrManager* calo_dd_man = *caloMgrHandle;
436
437 bool foundAllContainers (true);
438 std::vector<const CaloCalibrationHitContainer *> v_cchc;
439 for (const SG::ReadHandleKey<CaloCalibrationHitContainer>& key :
441 {
442 SG::ReadHandle<CaloCalibrationHitContainer> cchc (key, ctx);
443 if ( !cchc.isValid() ) {
445
446
447 msg(MSG::ERROR) <<
"SG does not contain calibration hit container "
449 }
450 foundAllContainers = false;
451 }
452 else {
453 v_cchc.push_back(cchc.cptr());
454 }
455 }
456
457 std::vector<const CaloCalibrationHitContainer *> v_dmcchc;
458 for (const SG::ReadHandleKey<CaloCalibrationHitContainer>& key :
460 {
461 SG::ReadHandle<CaloCalibrationHitContainer> cchc (key, ctx);
462 if ( !cchc.isValid() ) {
464
465
466 ATH_MSG_ERROR(
"SG does not contain DM calibration hit container "
468 }
469 foundAllContainers = false;
470 }
471 else {
472 v_dmcchc.push_back(cchc.cptr());
473 }
474 }
475
478 }
479
480 if ( !foundAllContainers ) {
481 return StatusCode::SUCCESS;
482 }
484
485
487
490
493
494
495
496
497 unsigned int nHitsTotal = 0;
498 unsigned int nHitsWithoutParticleUID = 0;
499
501 v_cchc,
502 cellInfo,
504 clusInfoVec,
505 nHitsTotal,
506 nHitsWithoutParticleUID,
508 [this]() {
509 ATH_MSG_ERROR(
"Invalid uniqueID detected - this sample cannot be properly analysed.");
510 });
511
512
513
517 ATH_MSG_INFO(
"Calibration hits do not have ParticleUID, ids of particle-caused hits are always 0. Continuing without ParticleID machinery.");
518 useParticleID = false;
519 }
520
521
522
524
525 if (doCalibFrac && !truthParticleContainerReadHandle.isValid()) {
526 ATH_MSG_WARNING(
"Invalid read handle to TruthParticleContainer with key: "
528 doCalibFrac = false;
529 }
530
531 std::array<std::vector<double>, 3> engCalibOut;
532
533
534
535
536 std::array<ClusList, 3> clusLists;
539 }};
540 const std::array<bool, 3> doClusterLists{{
547 }};
548
549 for (unsigned int ii = 0; ii < 3; ++ii) {
550 if (doClusterLists[ii]) {
552 engCalibOut[ii].resize(theClusColl->size(), 0.0);
553 }
554 }
555
556 std::array<ClusList*, 3> clusListPtrs{{&clusLists[0], &clusLists[1], &clusLists[2]}};
558 *theClusColl,
559 clusInfoVec,
565 doClusterLists,
566 clusListPtrs);
567
568
569
570
572 std::array<const ClusList*, 3> constClusListPtrs{{
573 &clusLists[0], &clusLists[1], &clusLists[2]
574 }};
576 v_cchc,
577 cellInfo,
578 *calo_dd_man,
579 clusInfoVec,
584 doOutOfCluster,
585 constClusListPtrs,
586 [&engCalibOut](unsigned int ii, int iClus, int , double energy) {
587 engCalibOut[ii][iClus] +=
energy;
588 });
589 }
590
591
592
593
594
595
598 pClusList = &clusLists[0];
600 pClusList = &clusLists[1];
602 pClusList = &clusLists[2];
603 }
604
607 v_dmcchc,
608 *theClusColl,
609 clusInfoVec,
610 *pClusList,
611 useParticleID,
612 [&clusInfoVec](int iClus, int , int nDmArea, double energy) {
613 clusInfoVec[iClus].engCalibDeadInArea[nDmArea] +=
energy;
615 });
616 }
617
618
619 std::vector<double> engCalibFrac;
621
622 std::map<unsigned int, int> truthIDToPdgCodeMap;
623
624
625 for ( const auto *thisTruthParticle : *truthParticleContainerReadHandle ) {
626
627 if (!thisTruthParticle) {
629 continue;
630 }
631
632 truthIDToPdgCodeMap[
HepMC::uniqueID(thisTruthParticle)] = thisTruthParticle->pdgId();
633 }
634
635
636 int iClus = 0;
637 for (clusIter = theClusColl->begin(), iClus = 0;
638 clusIter != clusIterEnd;
639 ++clusIter, ++iClus) {
642
643
645 + clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerB]
646 + clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerE]
647 + clusInfo.engCalibIn.engSmp[CaloSampling::TileGap3];
648
651 + clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerB];
652
654
656 + clusInfo.engCalibIn.engSmp[CaloSampling::TileGap3];
657
660 + clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerE];
661
663
666
668
669 double eng_calib_dead_unclass = eng_calib_dead_tot - eng_calib_dead_emb0 - eng_calib_dead_tile0
670 - eng_calib_dead_tileg3 - eng_calib_dead_eme0 - eng_calib_dead_hec0 - eng_calib_dead_fcal
671 - eng_calib_dead_leakage;
672
673 if (doCalibFrac) {
674
675
676
678 if (clusInfo.engCalibIn.engTot > 0.0) {
679
680 for (const auto& p : clusInfo.engCalibParticle) {
681 int pdg_id = 0;
682 if (
auto it = truthIDToPdgCodeMap.find(
p.first); it != truthIDToPdgCodeMap.end()) {
684 } else {
685 ATH_MSG_WARNING(
"truthIDToPdgCodeMap cannot find an entry with uniqueID " <<
p.first);
686 continue;
687 }
688 if (std::abs(pdg_id) == 211) {
690 } else if (pdg_id == 111 || pdg_id == 22 || std::abs(pdg_id) == 11) {
692 } else {
694 }
695 }
696 for (
size_t i = 0;
i < engCalibFrac.size();
i++) {
697 engCalibFrac[
i] = engCalibFrac[
i] / clusInfo.engCalibIn.engTot;
698 }
699 }
700 }
701
704
705 moment_name_set::const_iterator vMomentsIter =
m_validMoments.begin();
706 moment_name_set::const_iterator vMomentsIterEnd =
m_validMoments.end();
707
708 int iMoment = 0;
709 for (; vMomentsIter != vMomentsIterEnd; ++vMomentsIter, ++iMoment) {
710
711 switch (vMomentsIter->second) {
714 myMoments[iMoment] = clusInfo.engCalibIn.engTot;
715 break;
717 myMoments[iMoment] = engCalibOut[0][iClus];
718 break;
720 myMoments[iMoment] = engCalibOut[1][iClus];
721 break;
723 myMoments[iMoment] = engCalibOut[2][iClus];
724 break;
726 myMoments[iMoment] = clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerB];
727 break;
729 myMoments[iMoment] = clusInfo.engCalibIn.engSmp[CaloSampling::PreSamplerE];
730 break;
732 myMoments[iMoment] = clusInfo.engCalibIn.engSmp[CaloSampling::TileGap3];
733 break;
735 myMoments[iMoment] = eng_calib_dead_tot;
736 break;
738 myMoments[iMoment] = eng_calib_dead_emb0;
739 break;
741 myMoments[iMoment] = eng_calib_dead_tile0;
742 break;
744 myMoments[iMoment] = eng_calib_dead_tileg3;
745 break;
747 myMoments[iMoment] = eng_calib_dead_eme0;
748 break;
750 myMoments[iMoment] = eng_calib_dead_hec0;
751 break;
753 myMoments[iMoment] = eng_calib_dead_fcal;
754 break;
756 myMoments[iMoment] = eng_calib_dead_leakage;
757 break;
759 myMoments[iMoment] = eng_calib_dead_unclass;
760 break;
763 break;
766 break;
769 break;
770 default:
771
772 break;
773 }
774
775 theCluster->
insertMoment(vMomentsIter->second, myMoments[iMoment]);
776 }
777 }
778 }
779
780 return StatusCode::SUCCESS;
781}
#define ATH_MSG_WARNING(x)
std::array< double, CaloDmDescrArea::DMA_MAX > engCalibDeadInArea
void accumulateDeadMaterialEnergy(const std::vector< const CaloCalibrationHitContainer * > &v_dmcchc, const xAOD::CaloClusterContainer &theClusColl, const ClusInfo_t &clusInfoVec, const ClusList &clusList, bool useParticleID, AddDeadMaterialEnergy &&addDeadMaterialEnergy) const
Accumulate dead-material calibration-hit energy assigned to clusters.
std::vector< MyClusInfo > ClusInfo_t
moment_name_set m_validMoments
std::map< Identifier, MyCellInfo > CellInfoSet_t
static void accumulateClusterCalibHits(const std::vector< const CaloCalibrationHitContainer * > &v_cchc, const CellInfoSet_t &cellInfo, const CaloCell_ID &calo_id, ClusInfo_t &clusInfoVec, unsigned int &nHitsTotal, unsigned int &nHitsWithoutParticleUID, bool useParticleID, InvalidUniqueIdHandler &&invalidUniqueIdHandler)
Accumulate calibration-hit energy inside clusters.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
static void buildOutOfClusterClusterLists(const xAOD::CaloClusterContainer &theClusColl, const ClusInfo_t &clusInfoVec, int n_phi_out, int n_eta_out, double out_phi_max, double out_eta_max, const std::array< std::vector< std::vector< CalibHitIPhiIEtaRange > >, 3 > &i_phi_eta, const std::array< bool, 3 > &doOutOfCluster, const std::array< ClusList *, 3 > &clusLists)
Build lookup lists of clusters for out-of-cluster energy sharing.
static void buildCellInfoMap(const xAOD::CaloClusterContainer &theClusColl, CellInfoSet_t &cellInfo)
Build a map of calorimeter cells contributing to clusters.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
static void accumulateOutOfClusterEnergy(const std::vector< const CaloCalibrationHitContainer * > &v_cchc, const CellInfoSet_t &cellInfo, const CaloDetDescrManager &calo_dd_man, const ClusInfo_t &clusInfoVec, int n_phi_out, int n_eta_out, double out_phi_max, double out_eta_max, const std::array< bool, 3 > &doOutOfCluster, const std::array< const ClusList *, 3 > &clusLists, AddOutOfClusterEnergy &&addOutOfClusterEnergy)
DataModel_detail::iterator< DataVector > iterator
void insertMoment(MomentType type, double value)
@ ENG_CALIB_OUT_M
Attached Calibration Hit energy outside clusters but inside the calorimeter with medium matching (Ang...
@ ENG_CALIB_OUT_L
Attached Calibration Hit energy outside clusters but inside the calorimeter with loose matching (Angl...
@ ENG_CALIB_DEAD_UNCLASS
Attached Calibration Hit energy in dead material in unclassified areas of the detector.
@ ENG_CALIB_DEAD_HEC0
Attached Calibration Hit energy in dead material between EME3 and HEC0.
@ ENG_CALIB_DEAD_TILEG3
Attached Calibration Hit energy in dead material before scintillator.
@ ENG_CALIB_FRAC_REST
Calibration Hit energy inside the cluster caused by other particles.
@ ENG_CALIB_DEAD_EME0
Attached Calibration Hit energy in dead material before EME0, between EME0 and EME1.
@ ENG_CALIB_DEAD_TILE0
Attached Calibration Hit energy in dead material between EMB3 and TILE0.
@ ENG_CALIB_FRAC_EM
Calibration Hit energy inside the cluster caused by e/gamma/pi0.
@ ENG_CALIB_DEAD_FCAL
Attached Calibration Hit energy in dead material before FCAL, between FCAL and HEC.
@ ENG_CALIB_TOT
Calibration Hit energy inside the cluster.
@ ENG_CALIB_OUT_T
Attached Calibration Hit energy outside clusters but inside the calorimeter with tight matching (Angl...
@ ENG_CALIB_DEAD_LEAKAGE
Attached Calibration Hit energy in dead material behind calorimeters.
@ ENG_CALIB_FRAC_HAD
Calibration Hit energy inside the cluster caused by charged pi+ and pi-.
@ ENG_CALIB_EMB0
Calibration Hit energy inside the cluster barrel presampler.
@ ENG_CALIB_EME0
Calibration Hit energy inside the cluster endcap presampler.
@ ENG_CALIB_DEAD_EMB0
Attached Calibration Hit energy in dead material before EMB0, between EMB0 and EMB1.
@ ENG_CALIB_DEAD_TOT
Attached Calibration Hit energy in dead material.
@ ENG_CALIB_TILEG3
Calibration Hit energy inside the cluster scintillator.