10#include <analysis/variables/ECLVariables.h>
13#include <framework/logging/Logger.h>
14#include <framework/database/DBObjPtr.h>
15#include <framework/core/Environment.h>
18#include <analysis/dataobjects/Particle.h>
19#include <analysis/dataobjects/ParticleList.h>
20#include <analysis/dataobjects/ECLEnergyCloseToTrack.h>
21#include <analysis/utility/ReferenceFrame.h>
22#include <analysis/ClusterUtility/ClusterUtils.h>
23#include <analysis/VariableManager/Utility.h>
24#include <analysis/dbobjects/ECLTimingNormalization.h>
27#include <mdst/dataobjects/KlId.h>
28#include <mdst/dataobjects/ECLCluster.h>
29#include <mdst/dataobjects/Track.h>
30#include <mdst/dataobjects/EventLevelClusteringInfo.h>
32#include <Math/Vector4D.h>
45 double distanceToMcKl(
const Particle* particle)
47 if (particle->hasExtraInfo(
"mcdistanceKL")) {
48 return particle->getExtraInfo(
"mcdistanceKL");
50 B2WARNING(
"The extraInfo mcdistanceKL is not registered! \n"
51 "This variable is only available for ECL based lists, and you have to run the function getNeutralHadronGeomMatches to use it");
56 double distanceToMcNeutron(
const Particle* particle)
58 if (particle->hasExtraInfo(
"mcdistanceNeutron")) {
59 return particle->getExtraInfo(
"mcdistanceNeutron");
61 B2WARNING(
"The extraInfo mcdistanceNeutron is not registered! \n"
62 "This variable is only available for ECL based lists, and you have to run the function getNeutralHadronGeomMatches to use it");
67 int mdstIndexMcKl(
const Particle* particle)
69 if (particle->hasExtraInfo(
"mdstIndexTruthKL")) {
70 return int(particle->getExtraInfo(
"mdstIndexTruthKL") + 0.1);
72 B2WARNING(
"The extraInfo mdstIndexTruthKL is not registered! \n"
73 "This variable is only available for ECL based lists, and you have to run the function getNeutralHadronGeomMatches to use it");
78 int mdstIndexMcNeutron(
const Particle* particle)
80 if (particle->hasExtraInfo(
"mdstIndexTruthNeutron")) {
81 return int(particle->getExtraInfo(
"mdstIndexTruthNeutron") + 0.1);
83 B2WARNING(
"The extraInfo mdstIndexTruthNeutron is not registered! \n"
84 "This variable is only available for ECL based lists, and you have to run the function getNeutralHadronGeomMatches to use it");
90 double beamBackgroundSuppression(
const Particle* particle)
92 if (particle->hasExtraInfo(
"beamBackgroundSuppression")) {
93 return particle->getExtraInfo(
"beamBackgroundSuppression");
95 B2WARNING(
"The extraInfo beamBackgroundSuppression is not registered! \n"
96 "This variable is only available for photons, and you either have to use the standard particle lists (stdPhotons or stdPi0s) or run getBeamBackgroundProbability on a photon list.");
101 double fakePhotonSuppression(
const Particle* particle)
103 if (particle->hasExtraInfo(
"fakePhotonSuppression")) {
104 return particle->getExtraInfo(
"fakePhotonSuppression");
106 B2WARNING(
"The extraInfo fakePhotonSuppression is not registered! \n"
107 "This variable is only available for photons, and you either have to use the standard particle lists (stdPhotons or stdPi0s) or run getFakePhotonProbability on a photon list.");
112 double hadronicSplitOffSuppression(
const Particle* particle)
114 B2WARNING(
"This variable has been deprecated since light-2302-genetta and is no longer maintained with up to date weights. Please use the variable fakePhotonSuppression instead.");
115 return fakePhotonSuppression(particle);
118 double eclClusterKlId(
const Particle* particle)
120 const ECLCluster* cluster = particle->getECLCluster();
124 const KlId* klid = cluster->getRelatedTo<KlId>();
128 return klid->getKlId();
131 double eclPulseShapeDiscriminationMVA(
const Particle* particle)
133 const ECLCluster* cluster = particle->getECLCluster();
135 if (eclClusterHasPulseShapeDiscrimination(particle)) {
136 return cluster->getPulseShapeDiscriminationMVA();
144 double eclClusterNumberOfHadronDigits(
const Particle* particle)
147 const ECLCluster* cluster = particle->getECLCluster();
149 if (eclClusterHasPulseShapeDiscrimination(particle)) {
150 return cluster->getNumberOfHadronDigits();
157 double eclClusterDetectionRegion(
const Particle* particle)
160 const ECLCluster* cluster = particle->getECLCluster();
162 return cluster->getDetectorRegion();
167 double eclClusterIsolation(
const Particle* particle)
170 const ECLCluster* cluster = particle->getECLCluster();
172 auto minDist = cluster->getMinTrkDistance();
179 double eclClusterIsolationID(
const Particle* particle)
182 const ECLCluster* cluster = particle->getECLCluster();
184 return cluster->getMinTrkDistanceID();
191 if (arguments.size() > 2 or arguments.size() == 0)
192 B2FATAL(
"Wrong number of arguments (2 required) for meta variable minC2TDistVar");
193 std::string listName =
"pi-:all";
194 std::string variableName = arguments[0];
195 if (arguments.size() == 2)
196 listName = arguments[1];
199 auto func = [listName, variableName](
const Particle * particle) ->
double {
200 StoreObjPtr<ParticleList> particleList(listName);
201 if (!(particleList.isValid()))
203 B2FATAL(
"Invalid Listname " << listName <<
" given to minC2TDistVar!");
206 const ECLCluster* cluster = particle->getECLCluster();
209 auto trackID = cluster->getMinTrkDistanceID();
212 for (
unsigned int i = 0; i < particleList->getListSize(); i++)
214 const Particle* listParticle = particleList->getParticle(i);
215 if (listParticle and listParticle->getTrack() and listParticle->getTrack()->getArrayIndex() == trackID) {
216 result = std::get<double>(var->function(listParticle));
225 double eclClusterConnectedRegionID(
const Particle* particle)
228 const ECLCluster* cluster = particle->getECLCluster();
230 return cluster->getConnectedRegionId();
235 double eclClusterDeltaL(
const Particle* particle)
238 const ECLCluster* cluster = particle->getECLCluster();
240 return cluster->getDeltaL();
245 double eclClusterErrorE(
const Particle* particle)
248 const ECLCluster* cluster = particle->getECLCluster();
251 const auto EPhiThetaCov = clutls.GetCovarianceMatrix3x3FromCluster(cluster);
252 return sqrt(fabs(EPhiThetaCov[0][0]));
257 double eclClusterUncorrectedE(
const Particle* particle)
260 const ECLCluster* cluster = particle->getECLCluster();
262 return cluster->getEnergyRaw();
267 double eclClusterE(
const Particle* particle)
271 const ECLCluster* cluster = particle->getECLCluster();
274 ROOT::Math::PxPyPzEVector p4Cluster = clutls.GetCluster4MomentumFromCluster(cluster, particle->getECLClusterEHypothesisBit());
276 return frame.getMomentum(p4Cluster).E();
281 double eclClusterHighestE(
const Particle* particle)
284 const ECLCluster* cluster = particle->getECLCluster();
286 return cluster->getEnergyHighestCrystal();
291 double eclClusterCellId(
const Particle* particle)
294 const ECLCluster* cluster = particle->getECLCluster();
296 return cluster->getMaxECellId();
302 const std::array<int, 69> lastCellIDperThetaID{48, 96, 160, 224, 288, 384, 480, 576, 672, 768, 864,
303 1008, 1152, 1296, 1440, 1584, 1728, 1872, 2016, 2160, 2304, 2448,
304 2592, 2736, 2880, 3024, 3168, 3312, 3456, 3600, 3744, 3888, 4032,
305 4176, 4320, 4464, 4608, 4752, 4896, 5040, 5184, 5328, 5472, 5616,
306 5760, 5904, 6048, 6192, 6336, 6480, 6624, 6768, 6912, 7056, 7200,
307 7344, 7488, 7632, 7776, 7920, 8064, 8160, 8256, 8352, 8448, 8544,
310 double eclClusterThetaId(
const Particle* particle)
313 const ECLCluster* cluster = particle->getECLCluster();
315 int cellID = cluster->getMaxECellId();
316 return std::distance(lastCellIDperThetaID.begin(), std::lower_bound(lastCellIDperThetaID.begin(), lastCellIDperThetaID.end(),
322 double eclClusterPhiId(
const Particle* particle)
325 const ECLCluster* cluster = particle->getECLCluster();
327 int cellID = cluster->getMaxECellId();
331 int closestinlist = lastCellIDperThetaID[std::distance(lastCellIDperThetaID.begin(), std::lower_bound(lastCellIDperThetaID.begin(),
332 lastCellIDperThetaID.end(), cellID)) - 1];
333 return cellID - closestinlist - 1;
339 double eclClusterTiming(
const Particle* particle)
342 const ECLCluster* cluster = particle->getECLCluster();
344 return cluster->getTime();
349 double eclClusterHasFailedTiming(
const Particle* particle)
351 const ECLCluster* cluster = particle->getECLCluster();
353 return cluster->hasFailedFitTime();
358 double eclClusterErrorTiming(
const Particle* particle)
361 const ECLCluster* cluster = particle->getECLCluster();
363 return cluster->getDeltaTime99();
368 double eclClusterHasFailedErrorTiming(
const Particle* particle)
370 const ECLCluster* cluster = particle->getECLCluster();
372 return cluster->hasFailedTimeResolution();
377 double eclClusterTheta(
const Particle* particle)
381 const ECLCluster* cluster = particle->getECLCluster();
384 ROOT::Math::PxPyPzEVector p4Cluster = clutls.Get4MomentumFromCluster(cluster, particle->getECLClusterEHypothesisBit());
386 return frame.getMomentum(p4Cluster).Theta();
391 double eclClusterErrorTheta(
const Particle* particle)
394 const ECLCluster* cluster = particle->getECLCluster();
397 const auto EPhiThetaCov = clutls.GetCovarianceMatrix3x3FromCluster(cluster);
398 return sqrt(fabs(EPhiThetaCov[2][2]));
403 double eclClusterErrorPhi(
const Particle* particle)
406 const ECLCluster* cluster = particle->getECLCluster();
409 const auto EPhiThetaCov = clutls.GetCovarianceMatrix3x3FromCluster(cluster);
410 return sqrt(fabs(EPhiThetaCov[1][1]));
415 double eclClusterPhi(
const Particle* particle)
419 const ECLCluster* cluster = particle->getECLCluster();
422 ROOT::Math::PxPyPzEVector p4Cluster = clutls.Get4MomentumFromCluster(cluster, particle->getECLClusterEHypothesisBit());
424 return frame.getMomentum(p4Cluster).Phi();
429 double eclClusterR(
const Particle* particle)
432 const ECLCluster* cluster = particle->getECLCluster();
434 return cluster->getR();
439 double eclClusterE1E9(
const Particle* particle)
442 const ECLCluster* cluster = particle->getECLCluster();
444 return cluster->getE1oE9();
449 double eclClusterE9E21(
const Particle* particle)
452 const ECLCluster* cluster = particle->getECLCluster();
454 return cluster->getE9oE21();
459 double eclClusterAbsZernikeMoment40(
const Particle* particle)
462 const ECLCluster* cluster = particle->getECLCluster();
464 return cluster->getAbsZernike40();
469 double eclClusterAbsZernikeMoment51(
const Particle* particle)
472 const ECLCluster* cluster = particle->getECLCluster();
474 return cluster->getAbsZernike51();
479 double eclClusterZernikeMVA(
const Particle* particle)
482 const ECLCluster* cluster = particle->getECLCluster();
484 return cluster->getZernikeMVA();
489 double eclClusterSecondMoment(
const Particle* particle)
492 const ECLCluster* cluster = particle->getECLCluster();
494 return cluster->getSecondMoment();
499 double eclClusterLAT(
const Particle* particle)
502 const ECLCluster* cluster = particle->getECLCluster();
504 return cluster->getLAT();
509 double eclClusterNHits(
const Particle* particle)
512 const ECLCluster* cluster = particle->getECLCluster();
514 return cluster->getNumberOfCrystals();
519 double eclClusterTrackMatched(
const Particle* particle)
522 const ECLCluster* cluster = particle->getECLCluster();
524 const Track* track = cluster->getRelatedFrom<Track>();
534 double nECLClusterTrackMatches(
const Particle* particle)
537 const ECLCluster* cluster = particle->getECLCluster();
542 size_t out = cluster->getRelationsFrom<Track>().size();
546 double eclClusterId(
const Particle* particle)
548 const ECLCluster* cluster = particle->getECLCluster();
550 return cluster->getClusterId();
555 double eclClusterHasNPhotonsHypothesis(
const Particle* particle)
557 const ECLCluster* cluster = particle->getECLCluster();
564 double eclClusterHasNeutralHadronHypothesis(
const Particle* particle)
566 const ECLCluster* cluster = particle->getECLCluster();
573 double eclClusterHasPulseShapeDiscrimination(
const Particle* particle)
575 const ECLCluster* cluster = particle->getECLCluster();
577 return cluster->hasPulseShapeDiscrimination();
582 double eclExtTheta(
const Particle* particle)
585 const Track* track = particle->getTrack();
588 auto* eclinfo = track->getRelatedTo<ECLEnergyCloseToTrack>();
591 return eclinfo->getExtTheta();
593 B2WARNING(
"Relation to ECLEnergyCloseToTrack not found, did you forget to run ECLTrackCalDigitMatchModule?");
601 double eclExtPhi(
const Particle* particle)
604 const Track* track = particle->getTrack();
607 auto* eclinfo = track->getRelatedTo<ECLEnergyCloseToTrack>();
610 return eclinfo->getExtPhi();
612 B2WARNING(
"Relation to ECLEnergyCloseToTrack not found, did you forget to run ECLTrackCalDigitMatchModule?");
620 double eclExtPhiId(
const Particle* particle)
622 const Track* track = particle->getTrack();
625 auto* eclinfo = track->getRelatedTo<ECLEnergyCloseToTrack>();
628 return eclinfo->getExtPhiId();
630 B2WARNING(
"Relation to ECLEnergyCloseToTrack not found, did you forget to run ECLTrackCalDigitMatchModule?");
638 double weightedAverageECLTime(
const Particle* particle)
640 int nDaughters = particle->getNDaughters();
641 if (nDaughters < 1) {
642 B2WARNING(
"The provided particle has no daughters!");
646 double numer = 0, denom = 0;
647 int numberOfClusterDaughters = 0;
649 auto weightedECLTimeAverage = [&numer, &denom, &numberOfClusterDaughters](
const Particle * p) {
650 const ECLCluster* cluster = p->getECLCluster();
651 if (cluster and not cluster->hasFailedFitTime()) {
652 numberOfClusterDaughters ++;
654 double time = cluster->getTime();
655 B2DEBUG(10,
"time[" << numberOfClusterDaughters <<
"] = " << time);
656 double deltatime = cluster->getDeltaTime99();
657 B2DEBUG(10,
"deltatime[" << numberOfClusterDaughters <<
"] = " << deltatime);
658 numer += time / pow(deltatime, 2);
659 B2DEBUG(11,
"numer[" << numberOfClusterDaughters <<
"] = " << numer);
660 denom += 1 / pow(deltatime, 2);
661 B2DEBUG(11,
"denom[" << numberOfClusterDaughters <<
"] = " << denom);
666 particle->forEachDaughter(weightedECLTimeAverage,
true,
true);
668 if (numberOfClusterDaughters < 1) {
669 B2WARNING(
"There are no clusters or cluster matches amongst the daughters of the provided particle!");
674 B2WARNING(
"The denominator of the weighted mean is zero!");
677 B2DEBUG(10,
"numer/denom = " << numer / denom);
678 return numer / denom;
682 double maxWeightedDistanceFromAverageECLTime(
const Particle* particle)
684 int nDaughters = particle->getNDaughters();
685 if (nDaughters < 1) {
686 B2WARNING(
"The provided particle has no daughters!");
690 double maxTimeDiff = -DBL_MAX;
691 int numberOfClusterDaughters = 0;
693 double averageECLTime = weightedAverageECLTime(particle);
695 auto maxTimeDifference = [&maxTimeDiff, &numberOfClusterDaughters, &averageECLTime](
const Particle * p) {
697 const ECLCluster* cluster = p->getECLCluster();
699 numberOfClusterDaughters ++;
701 double time = cluster->getTime();
702 B2DEBUG(10,
"time[" << numberOfClusterDaughters <<
"] = " << time);
703 double deltatime = cluster->getDeltaTime99();
704 B2DEBUG(10,
"deltatime[" << numberOfClusterDaughters <<
"] = " << deltatime);
705 double maxTimeDiff_temp = fabs((time - averageECLTime) / deltatime);
706 B2DEBUG(11,
"maxTimeDiff_temp[" << numberOfClusterDaughters <<
"] = " << maxTimeDiff_temp);
707 if (maxTimeDiff_temp > maxTimeDiff)
708 maxTimeDiff = maxTimeDiff_temp;
709 B2DEBUG(11,
"maxTimeDiff[" << numberOfClusterDaughters <<
"] = " << maxTimeDiff);
714 particle->forEachDaughter(maxTimeDifference,
true,
true);
716 if (numberOfClusterDaughters < 1) {
717 B2WARNING(
"There are no clusters or cluster matches amongst the daughters of the provided particle!");
721 if (maxTimeDiff < 0) {
722 B2WARNING(
"The max time difference is negative!");
725 B2DEBUG(10,
"maxTimeDiff = " << maxTimeDiff);
730 double eclClusterMdstIndex(
const Particle* particle)
732 const ECLCluster* cluster = particle->getECLCluster();
734 return cluster->getArrayIndex();
740 double eclClusterTimeNorm90(
const Particle* particle)
743 const ECLCluster* cluster = particle->getECLCluster();
744 StoreObjPtr<EventLevelClusteringInfo> elci;
747 std::string payloadName =
"ECLTimingNormalization_data";
749 static DBObjPtr<ECLTimingNormalization> ECLTimingNormalization(payloadName);
750 if (!ECLTimingNormalization.isValid()) {
751 B2FATAL(payloadName <<
" payload is not available");
754 if (elci and cluster) {
758 unsigned short cellID = cluster->getMaxECellId();
759 const unsigned short firstCellID = 161;
760 const unsigned short lastCellID = 8608;
761 const double time = cluster->getTime();
762 double tNorm90 = -99.;
763 if (cellID < firstCellID or cellID > lastCellID) {
764 const double dt99 = cluster->getDeltaTime99();
765 if (dt99 != 0) {tNorm90 = 1.5 * time / dt99;}
768 int iCrys = cellID - 1;
772 double clusterERaw = cluster->getEnergyRaw();
773 double singleECorrected = cluster->getEnergyHighestCrystal();
774 double singleCrystalE = singleECorrected * clusterERaw / clusterECorrected;
775 double basicEScale = 0.1 / singleCrystalE;
778 const int firstBarrel = 1153;
779 const int lastBarrel = 7776;
780 double ootCrys = elci->getNECLCalDigitsOutOfTimeBarrel();
781 if (cellID < firstBarrel) {ootCrys = elci->getNECLCalDigitsOutOfTimeFWD();}
782 if (cellID > lastBarrel) {ootCrys = elci->getNECLCalDigitsOutOfTimeBWD();}
786 const auto& par7 = ECLTimingNormalization->getTimeWalkPar();
787 float EForCor = singleCrystalE;
788 if (EForCor < par7[iCrys][5]) {EForCor = par7[iCrys][5];}
789 if (EForCor > par7[iCrys][6]) {EForCor = par7[iCrys][6];}
790 float dE = EForCor - par7[iCrys][0];
791 double timeWalkCor = par7[iCrys][1] + par7[iCrys][2] * dE;
793 timeWalkCor = par7[iCrys][1] + par7[iCrys][3] * dE + par7[iCrys][4] * dE * dE;
798 const auto& bPar = ECLTimingNormalization->getBackgroundPar();
800 if (oot < bPar[iCrys][3]) {oot = bPar[iCrys][3];}
801 if (oot > bPar[iCrys][4]) {oot = bPar[iCrys][4];}
802 double backgroundNorm = bPar[iCrys][0] + bPar[iCrys][1] * oot + bPar[iCrys][2] * oot * oot;
806 const auto& par7Energy = ECLTimingNormalization->getEnergyPar();
808 EForCor = singleCrystalE;
809 if (EForCor < par7Energy[iCrys][5]) {EForCor = par7Energy[iCrys][5];}
810 if (EForCor > par7Energy[iCrys][6]) {EForCor = par7Energy[iCrys][6];}
811 dE = EForCor - par7Energy[iCrys][0];
812 double energyNorm = par7Energy[iCrys][1] + par7Energy[iCrys][2] * dE;
814 energyNorm = par7Energy[iCrys][1] + par7Energy[iCrys][3] * dE + par7Energy[iCrys][4] * dE * dE;
818 double minTNorm = (double)ECLTimingNormalization->getMinTNormalization();
819 double tNormalization = basicEScale * backgroundNorm * energyNorm;
820 if (tNormalization < minTNorm) {tNormalization = minTNorm;}
821 tNorm90 = (time - timeWalkCor) / tNormalization;
834 double nECLOutOfTimeCrystalsFWDEndcap(
const Particle*)
836 StoreObjPtr<EventLevelClusteringInfo> elci;
838 return (
double)elci->getNECLCalDigitsOutOfTimeFWD();
841 double nECLOutOfTimeCrystalsBarrel(
const Particle*)
843 StoreObjPtr<EventLevelClusteringInfo> elci;
845 return (
double)elci->getNECLCalDigitsOutOfTimeBarrel();
848 double nECLOutOfTimeCrystalsBWDEndcap(
const Particle*)
850 StoreObjPtr<EventLevelClusteringInfo> elci;
852 return (
double)elci->getNECLCalDigitsOutOfTimeBWD();
855 double nECLOutOfTimeCrystals(
const Particle*)
857 StoreObjPtr<EventLevelClusteringInfo> elci;
859 return (
double)elci->getNECLCalDigitsOutOfTime();
862 double nRejectedECLShowersFWDEndcap(
const Particle*)
864 StoreObjPtr<EventLevelClusteringInfo> elci;
866 return (
double)elci->getNECLShowersRejectedFWD();
869 double nRejectedECLShowersBarrel(
const Particle*)
871 StoreObjPtr<EventLevelClusteringInfo> elci;
873 return (
double)elci->getNECLShowersRejectedBarrel();
876 double nRejectedECLShowersBWDEndcap(
const Particle*)
878 StoreObjPtr<EventLevelClusteringInfo> elci;
880 return (
double)elci->getNECLShowersRejectedBWD();
883 double nRejectedECLShowers(
const Particle*)
885 StoreObjPtr<EventLevelClusteringInfo> elci;
887 return (
double) elci->getNECLShowersRejected();
890 double nKLMMultistripHitsFWDEndcap(
const Particle*)
892 StoreObjPtr<EventLevelClusteringInfo> elci;
894 return (
double) elci->getNKLMDigitsMultiStripFWD();
897 double nKLMMultistripHitsBarrel(
const Particle*)
899 StoreObjPtr<EventLevelClusteringInfo> elci;
901 return (
double) elci->getNKLMDigitsMultiStripBarrel();
904 double nKLMMultistripHitsBWDEndcap(
const Particle*)
906 StoreObjPtr<EventLevelClusteringInfo> elci;
908 return (
double) elci->getNKLMDigitsMultiStripBWD();
911 double nKLMMultistripHits(
const Particle*)
913 StoreObjPtr<EventLevelClusteringInfo> elci;
915 return (
double) elci->getNKLMDigitsMultiStrip();
918 double nECLShowersFWDEndcap(
const Particle*)
920 StoreObjPtr<EventLevelClusteringInfo> elci;
922 return (
double) elci->getNECLShowersFWD();
925 double nECLShowersBarrel(
const Particle*)
927 StoreObjPtr<EventLevelClusteringInfo> elci;
929 return (
double) elci->getNECLShowersBarrel();
932 double nECLShowersBWDEndcap(
const Particle*)
934 StoreObjPtr<EventLevelClusteringInfo> elci;
936 return (
double) elci->getNECLShowersBWD();
939 double nECLShowers(
const Particle*)
941 StoreObjPtr<EventLevelClusteringInfo> elci;
943 return (
double) elci->getNECLShowers();
946 double nECLLocalMaximumsFWDEndcap(
const Particle*)
948 StoreObjPtr<EventLevelClusteringInfo> elci;
950 return (
double) elci->getNECLLocalMaximumsFWD();
953 double nECLLocalMaximumsBarrel(
const Particle*)
955 StoreObjPtr<EventLevelClusteringInfo> elci;
957 return (
double) elci->getNECLLocalMaximumsBarrel();
960 double nECLLocalMaximumsBWDEndcap(
const Particle*)
962 StoreObjPtr<EventLevelClusteringInfo> elci;
964 return (
double) elci->getNECLLocalMaximumsBWD();
967 double nECLLocalMaximums(
const Particle*)
969 StoreObjPtr<EventLevelClusteringInfo> elci;
971 return (
double) elci->getNECLLocalMaximums();
974 double nECLTriggerCellsFWDEndcap(
const Particle*)
976 StoreObjPtr<EventLevelClusteringInfo> elci;
978 return (
double) elci->getNECLTriggerCellsFWD();
981 double nECLTriggerCellsBarrel(
const Particle*)
983 StoreObjPtr<EventLevelClusteringInfo> elci;
985 return (
double) elci->getNECLTriggerCellsBarrel();
988 double nECLTriggerCellsBWDEndcap(
const Particle*)
990 StoreObjPtr<EventLevelClusteringInfo> elci;
992 return (
double) elci->getNECLTriggerCellsBWD();
995 double nECLTriggerCells(
const Particle*)
997 StoreObjPtr<EventLevelClusteringInfo> elci;
999 return (
double) elci->getNECLTriggerCells();
1002 double eclClusterEoP(
const Particle* part)
1004 double E = eclClusterE(part);
1005 if (part->hasExtraInfo(
"bremsCorrectedPhotonEnergy")) {
1006 E += part->getExtraInfo(
"bremsCorrectedPhotonEnergy");
1008 const double p = part->getMomentumMagnitude();
1013 double eclClusterOnlyInvariantMass(
const Particle* part)
1015 int nDaughters = part->getNDaughters();
1016 ROOT::Math::PxPyPzEVector sum;
1018 if (nDaughters < 1) {
1019 return part->getMass();
1021 int nClusterDaughters = 0;
1022 std::stack<const Particle*> stacked;
1024 while (!stacked.empty()) {
1025 const Particle* current = stacked.top();
1028 const ECLCluster* cluster = current->getECLCluster();
1031 nClusterDaughters ++;
1032 ClusterUtils clutls;
1033 ROOT::Math::PxPyPzEVector p4Cluster = clutls.Get4MomentumFromCluster(cluster, clusterBit);
1036 const std::vector<Particle*> daughters = current->getDaughters();
1037 nDaughters = current->getNDaughters();
1038 for (
int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
1039 stacked.push(daughters[iDaughter]);
1044 if (nClusterDaughters < 1) {
1045 B2WARNING(
"There are no clusters amongst the daughters of the provided particle!");
1048 B2DEBUG(10,
"Number of daughters with cluster associated = " << nClusterDaughters);
1055 std::string cutString =
"";
1056 if (arguments.size() > 0) {
1057 cutString = arguments[0];
1061 std::string photonlistname =
"gamma:all";
1062 if (arguments.size() > 1) {
1063 photonlistname = arguments[1];
1066 std::string tracklistname =
"e-:all";
1067 if (arguments.size() > 2) {
1068 tracklistname = arguments[2];
1071 auto func = [cut, photonlistname, tracklistname](
const Particle * particle) ->
double {
1075 B2WARNING(
"The variable photonHasOverlap is supposed to be calculated for photons. Returning NaN.");
1079 StoreObjPtr<ParticleList> photonlist(photonlistname);
1080 if (!(photonlist.isValid()))
1082 B2WARNING(
"The provided particle list " << photonlistname <<
" does not exist."
1083 " Therefore, the variable photonHasOverlap can not be calculated. Returning NaN.");
1088 B2WARNING(
"The list " << photonlistname <<
" does not contain photons."
1089 " Therefore, the variable photonHasOverlap can not be calculated reliably. Returning NaN.");
1093 StoreObjPtr<ParticleList> tracklist(tracklistname);
1094 if (!(tracklist.isValid()))
1096 B2WARNING(
"The provided particle list " << tracklistname <<
" does not exist."
1097 " Therefore, the variable photonHasOverlap can not be calculated. Returning NaN.");
1102 B2WARNING(
"The list " << tracklistname <<
" does not contain charged final state particles."
1103 " Therefore, the variable photonHasOverlap can not be calculated reliably. Returning NaN.");
1107 double connectedRegionID = eclClusterConnectedRegionID(particle);
1108 int mdstSource = particle->getMdstSource();
1110 for (
unsigned int i = 0; i < photonlist->getListSize(); i++)
1112 const Particle* part = photonlist->getParticle(i);
1115 if (part->getMdstSource() == mdstSource) {
1120 if (!cut->check(part)) {
1124 if (connectedRegionID == eclClusterConnectedRegionID(part)) {
1129 for (
unsigned int i = 0; i < tracklist->getListSize(); i++)
1131 const Particle* part = tracklist->getParticle(i);
1134 if (!cut->check(part)) {
1138 if (connectedRegionID == eclClusterConnectedRegionID(part)) {
1148 VARIABLE_GROUP(
"ECL cluster related");
1149 REGISTER_VARIABLE(
"clusterEoP", eclClusterEoP, R
"DOC(
1150Returns ratio of the cluster energy `clusterE` over momentum :math:`p`.
1153 The cluster energy is already corrected for Bremsstrahlung.
1156 REGISTER_VARIABLE("clusterReg", eclClusterDetectionRegion, R
"DOC(
1157Returns an integer code representing the ECL region for the cluster:
1159- 1: forward, 2: barrel, 3: backward
1160- 11: between forward endcap and barrel, 13: between backward endcap and barrel
1161- 0: outside the ECL acceptance region
1164 REGISTER_VARIABLE("clusterDeltaLTemp", eclClusterDeltaL, R
"DOC(
1165Returns the :math:`\Delta L` for the cluster shape as defined below.
1167First, the cluster direction is constructed by calculating the weighted average of the orientation
1168for the crystals in the cluster. The POCA of the vector with this direction originating from the
1169cluster center and an extrapolated track can be used to the calculate the shower
1170depth. :math:`\Delta L` is then defined as the distance between this intersection and the cluster center.
1173 This distance is calculated on the reconstruction level and is temporarily
1174 included in mdst for investigation purposes. If it is found
1175 that it is not crucial for physics analyses then this variable will be removed
1176 in future releases. So keep in mind that this variable might be removed in the future.
1179 Please read `this <importantNoteECL>` first.
1181 - Lower limit: :math:`-250.0`
1182 - Upper limit: :math:`250.0`
1183 - Precision: :math:`10` bit
1186 REGISTER_VARIABLE("minC2TDist", eclClusterIsolation, R"DOC(
1187Returns the distance between the cluster and its nearest track.
1189For all tracks in the event, the distance between each of their extrapolated hits in the ECL and the ECL shower
1190position is calculated, and the overall smallest distance is returned. If there are no extrapolated hits found in the ECL
1191for the event, ``NaN`` will be returned. The track array index of the track that is closest to the cluster can be
1192retrieved using `minC2TDistID`.
1195 Please read `this <importantNoteECL>` first.
1197 - Lower limit: :math:`0.0`
1198 - Upper limit: :math:`250.0`
1199 - Precision: :math:`10` bit
1202 REGISTER_VARIABLE("minC2TDistID", eclClusterIsolationID, R"DOC(
1203Returns the track array index of the nearest track to the cluster. The nearest track is calculated
1204using the `minC2TDist` variable.
1207 REGISTER_METAVARIABLE("minC2TDistVar(variable[, particleList])", eclClusterIsolationVar, R
"DOC(
1208Returns the value of your chosen variable for the track nearest to the given cluster as calculated by
1211The first parameter ``variable`` is the variable name e.g. `nCDCHits`, while the second (optional) parameter ``particleList``
1212is the particle list name which will be used in the calculation of `minC2TDist`. The default value of ``particleList``
1215)DOC", Manager::VariableDataType::c_double);
1216 REGISTER_VARIABLE("clusterE", eclClusterE, R
"DOC(
1217Returns the cluster energy corrected for leakage and background.
1220 We only store clusters with :math:`E > 20\,` MeV.
1222.. topic:: Calculating Photon Energy
1224 The raw photon energy is given by the weighted sum of all crystal energies within the cluster.
1225 The weights per crystals are :math:`\leq 1` after cluster energy splitting in the case of overlapping
1226 clusters. The number of crystals that are included in the sum depends on a initial energy estimation
1227 and local beam background levels for the highest energy crystal. The crystal number is optimized to minimize
1228 the resolution of photons. Photon energy distributions always show a low energy tail
1229 due to unavoidable longitudinal and transverse leakage. The peak position of the photon energy distributions are
1230 corrected to match the true photon energy in MC. The corrections applied include:
1232 - Leakage correction: using MC samples of mono-energetic single photon, a correction factor
1233 :math:`f` as function of the reconstructed detector position, photon energy and beam background level
1234 is determined via :math:`f = \frac{\text{peak_reconstructed}}{\text{energy_true}}`
1236 - Cluster energy calibration (data only): to reach the target precision of :math:`< 1.8\%` energy
1237 resolution for high energetic photons, the remaining difference between MC and data is calibrated
1238 using kinematically fits to muon pairs
1240 It is important to note that after perfect leakage corrections and cluster energy calibrations,
1241 the :math:`\pi^{0}` mass peak will be shifted slightly to smaller values than the PDG average
1242 due to the low energy tails of photons.
1245 Please read `this <importantNoteECL>` first.
1247 - Lower limit: :math:`-5` (:math:`e^{-5} = 0.00674\,` GeV in the lab frame)
1248 - Upper limit: :math:`3.0` (:math:`e^3 = 20.08553\,` GeV in the lab frame)
1249 - Precision: :math:`18` bit
1252 REGISTER_VARIABLE("clusterErrorE", eclClusterErrorE, R"DOC(
1253Returns the uncertainty on the cluster energy. It is derived from
1254a background level and energy-dependent error tabulation.
1257 This variable should not be used a selection variable or in an MVA for photon identification as it is not
1258 a directly-reconstructed quantity. For more information please see the
1259 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1263 REGISTER_VARIABLE("clusterErrorPhi", eclClusterErrorPhi, R"DOC(
1264Returns the uncertainty on the phi angle of the cluster. It is derived from
1265a background level and energy-dependent error tabulation.
1268 This variable should not be used a selection variable or in an MVA for photon identification as it is not
1269 a directly-reconstructed quantity. For more information please see the
1270 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1274 REGISTER_VARIABLE("clusterErrorTheta", eclClusterErrorTheta, R"DOC(
1275Returns the uncertainty on the theta angle of the cluster. It is derived from
1276a background level and energy-dependent error tabulation.
1279 This variable should not be used a selection variable or in an MVA for photon identification as it is not
1280 a directly-reconstructed quantity. For more information please see the
1281 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1285 REGISTER_VARIABLE("clusterR", eclClusterR, R"DOC(
1286Returns the distance of the cluster centroid from :math:`(0,0,0)`.
1289 This variable is not recommended for use in analyses as they are difficult to interpret. For more information please see the
1290 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1294 REGISTER_VARIABLE("clusterPhi", eclClusterPhi, R"DOC(
1295Returns the azimuthal angle :math:`\phi` of the cluster. This is generally not equal
1296to the azimuthal angle of the photon.
1298.. topic:: Calculating Cluster Direction
1300 The direction of a cluster is given by the connecting line from :math:`\,(0,0,0)\,` to
1301 cluster centroid position in the ECL. The centroid position is calculated using up to 21 crystals
1302 (as 5x5 grid excluding corners) after the crystal energies are split in the case of overlapping clusters.
1303 The centroid position is the logarithmically weighted average of all crystals evaluated at the
1304 crystal centers. The centroid is generally biased towards the centers of the highest energetic
1305 crystal. This effect is larger for low energy photons. Beam backgrounds slightly decrease the
1306 position resolution, and mainly effects the low energy photons.
1308 Unlike for charged tracks, the uncertainty (covariance) of the photon direction is not determined
1309 based on individual cluster properties but taken from MC-based parametrizations of the resolution
1310 as function of true photon energy, true photon direction and beam background level.
1313 Please read `this <importantNoteECL>` first.
1315 - Lower limit: :math:`-\pi`
1316 - Upper limit: :math:`\pi`
1317 - Precision: :math:`16` bit
1320 REGISTER_VARIABLE("clusterConnectedRegionID", eclClusterConnectedRegionID, R"DOC(
1321Returns connected region ID for the cluster.
1323 REGISTER_VARIABLE("clusterTheta", eclClusterTheta, R
"DOC(
1324Returns the polar angle :math:`\theta` of the cluster. This is generally not equal
1325to the polar angle of the photon.
1327.. topic:: Calculating Cluster Direction
1329 The direction of a cluster is given by the connecting line from :math:`\,(0,0,0)\,` to
1330 cluster centroid position in the ECL. The centroid position is calculated using up to 21 crystals
1331 (as 5x5 grid excluding corners) after the crystal energies are split in the case of overlapping clusters.
1332 The centroid position is the logarithmically weighted average of all crystals evaluated at the
1333 crystal centers. The centroid is generally biased towards the centers of the highest energetic
1334 crystal. This effect is larger for low energy photons. Beam backgrounds slightly decrease the
1335 position resolution, and mainly effects the low energy photons.
1337 Unlike for charged tracks, the uncertainty (covariance) of the photon direction is not determined
1338 based on individual cluster properties but taken from MC-based parametrizations of the resolution
1339 as function of true photon energy, true photon direction and beam background level.
1342 Please read `this <importantNoteECL>` first.
1344 - Lower limit: :math:`0.0`
1345 - Upper limit: :math:`\pi`
1346 - Precision: :math:`16` bit
1349 REGISTER_VARIABLE("clusterTiming", eclClusterTiming, R"DOC(
1350Returns the time of the cluster. This is calculated **differently** in Belle and Belle II. Please
1351read their definitions below.
1353.. topic:: In Belle II
1355 It is calculated as the cluster time minus the event time (``eventT0``). The cluster time is obtained by a fit to
1356 the recorded waveform of the highest energy crystal in the cluster. For a cluster produced by a
1357 particle from the IP, the cluster time should be consistent with the event time (``eventT0``) within the uncertainties
1358 following all calibrations and corrections. For MC, note that the calibrations and corrections are not
1359 fully simulated. In order to see if the waveform fit fails, see `clusterHasFailedTiming`.
1362 Please read `this <importantNoteECL>` first.
1364 - Lower limit: :math:`-1000.0`
1365 - Upper limit: :math:`1000.0`
1366 - Precision: :math:`12` bit
1370 It is equal to the trigger cell (TC) time corresponding to the cluster. This information is only
1371 available in Belle data since experiment 31, and not available in Belle MC. Clusters produced at the IP
1372 in time with the event have a TC time in the range of 9000 - 11000. More information can be found in the
1373 Appendix of Belle note 831.
1376 In case this variable is obtained from Belle data that is stored in Belle II mdst/udst format, it will be truncated to:
1378 - Lower limit: :math:`-1000.0`
1379 - Upper limit: :math:`1000.0`
1380 - Precision: :math:`12` bit
1383 REGISTER_VARIABLE("clusterHasFailedTiming", eclClusterHasFailedTiming, R"DOC(
1384Status bit indicating if the waveform fit for the `clusterTiming` calculation has failed.
1386 REGISTER_VARIABLE("clusterErrorTiming", eclClusterErrorTiming, R
"DOC(
1387Returns the cluster timing uncertainty which is equal to the :math:`dt99` value as defined below. Very large
1388values of :math:`dt99` are an indication of a failed waveform fit for the cluster.
1390The timing distribution for each cluster is non-Gaussian and so the value :math:`dt99` is stored where
1391:math:`|\text{timing}| / \text{dt99} < 1` is designed to give a :math:`99\%` timing efficiency for
1392true photons from the IP. (This definition results in an efficiency that is approximately flat in energy
1393and independent of the beam background level). The :math:`dt99` value stored is determined using MC with a
1394parametrisation that depends on the true energy deposition in the highest energetic crystal and the
1395local beam background level in that crystal.
1398 This variable should should only be used for relative timing selections as it is not
1399 a directly-reconstructed quantity. For more information please see the
1400 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1404 Please read `this <importantNoteECL>` first.
1406 - Lower limit: :math:`0.0`
1407 - Upper limit: :math:`1000.0`
1408 - Precision: :math:`12` bit
1411 REGISTER_VARIABLE("clusterHasFailedErrorTiming", eclClusterHasFailedErrorTiming, R"DOC(
1412Status bit indicating if the calculation of `clusterErrorTiming` has failed due to a failed
1415 REGISTER_VARIABLE("clusterHighestE", eclClusterHighestE, R
"DOC(
1416Returns the energy of the highest energetic crystal in the cluster after reweighting.
1419 This variable is not recommended for use in analyses as they are difficult to interpret. For more information please see the
1420 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1424 Please read `this <importantNoteECL>` first.
1426 - Lower limit: :math:`-5` (:math:`e^{-5} = 0.00674\,` GeV)
1427 - Upper limit: :math:`3.0` (:math:`e^3 = 20.08553\,` GeV)
1428 - Precision: :math:`18` bit
1431 REGISTER_VARIABLE("clusterCellID", eclClusterCellId,
1432 "Returns the cell ID of the crystal with highest energy in the cluster.");
1433 REGISTER_VARIABLE("clusterThetaID", eclClusterThetaId, R"DOC(
1434Returns the :math:`\theta` ID of the crystal with highest energy in the cluster. There are
143569 :math:`\theta` IDs in total covering the entire ECL acceptance. The mapping between cell ID number
1436and :math:`\theta` ID can be found in the source code linked to the right of this variable description.
1438 REGISTER_VARIABLE("clusterPhiID", eclClusterPhiId, R
"DOC(
1439Returns the :math:`\phi` ID of the crystal with highest energy in the cluster.
1440While :math:`\theta` ID indicates the specific ring of the calorimeter,
1441:math:`\phi` ID indicates a position of a crystal in that ring. When facing
1442towards the direction of an electron beam, :math:`\phi` IDs go clockwise, with
14430 corresponding to the crystal closest to the outer side of the main ring tunnel.
1445.. admonition:: Diagram
1446 :class: dropdown xhint stacked
1448 .. code-block:: text
1450 phi_id = (nring/4) phi_id = (nring/4) - 1
1453 .... . . ││.. .. . .
1454 .. . . .... ││ ..... . . . .
1462 nring/2 ───── (towards the ───── phi_id = 0
1463 nring/2 - 1 ───── electron beam) ───── phi_id = (nring - 1)
1471 ... . . . .. ││. .. . .... .
1472 . . . . .││ ... ... .
1475 phi_id = (nring*3/4) - 1 phi_id = (nring/4) - 1
1477 The number of crystals per ring can be found see the `code <https://software.belle2.org/development/doxygen/classBelle2_1_1ECL_1_1ECLNeighbours.html#a4d5f886765986da6afb0559fb398106b>`_.
1480 REGISTER_VARIABLE("clusterE1E9", eclClusterE1E9, R
"DOC(
1481Returns the ratio of the energy in the central crystal (:math:`E_1`) to the total energy in the
14823x3 crystal grid around the central crystal (:math:`E_9`). Since :math:`E_1 \leq E_9`, this ratio is
1483:math:`\leq 1` and tends towards larger values for photons and smaller values for hadrons.
1486 Please read `this <importantNoteECL>` first.
1488 - Lower limit: :math:`0.0`
1489 - Upper limit: :math:`1.0`
1490 - Precision: :math:`10` bit
1493 REGISTER_VARIABLE("clusterE9E25", eclClusterE9E25, R
"DOC(
1494Returns `clusterE9E21`. This variable is kept for backwards compatibility.
1496 REGISTER_VARIABLE("clusterE9E21", eclClusterE9E21, R
"DOC(
1497Returns the ratio of the total energy in the 3x3 crystal grid around the central
1498crystal (:math:`E_9`) to the total energy in the 5x5 crystal grid around the central crystal
1499excluding the corners (:math:`E_{21}`). Since :math:`E_9 \leq E_{21}`, this ratio is :math:`\leq 1` and tends towards larger
1500values for photons and smaller values for hadrons.
1503 Please read `this <importantNoteECL>` first.
1505 - Lower limit: :math:`0.0`
1506 - Upper limit: :math:`1.0`
1507 - Precision: :math:`10` bit
1510 REGISTER_VARIABLE("clusterAbsZernikeMoment40", eclClusterAbsZernikeMoment40, R
"DOC(
1511Returns absolute value of the 40th Zernike moment :math:`|Z_{40}|`. An explanation on this shower
1512shape variable is in the description for the `clusterZernikeMVA` variable.
1515 Please read `this <importantNoteECL>` first.
1517 - Lower limit: :math:`0.0`
1518 - Upper limit: :math:`1.7`
1519 - Precision: :math:`10` bit
1522 REGISTER_VARIABLE("clusterAbsZernikeMoment51", eclClusterAbsZernikeMoment51, R
"DOC(
1523Returns absolute value of the 51st Zernike moment :math:`|Z_{51}|`. An explanation on this shower
1524shape variable is in the description for the `clusterZernikeMVA` variable.
1527 Please read `this <importantNoteECL>` first.
1529 - Lower limit: :math:`0.0`
1530 - Upper limit: :math:`1.2`
1531 - Precision: :math:`10` bit
1534 REGISTER_VARIABLE("clusterZernikeMVA", eclClusterZernikeMVA, R
"DOC(
1535Returns output of an MVA trained to use eleven Zernike moments of the cluster.
1537Zernike moments are calculated for each shower in the plane perpendicular to
1538the shower direction via
1541 |Z_{nm}| = \frac{n+1}{\pi} \frac{1}{\sum_{i} w_{i} E_{i}} \left|\sum_{i} R_{nm}(\rho_{i}) e^{-im\alpha_{i}} w_{i} E_{i} \right|
1543where :math:`n, m` are the integers, :math:`i` runs over each crystal in the shower,
1544:math:`E_{i}` is the energy of the i-th crystal in the shower,
1545:math:`R_{nm}` is a polynomial of degree :math:`n`,
1546:math:`\rho_{i}` is the radial distance of the :math:`i`-th crystal in the perpendicular plane,
1547and :math:`\alpha_{i}` is the polar angle of the :math:`i`-th crystal in the perpendicular plane.
1548As a crystal can be related to more than one shower, :math:`w_{i}` is the fraction of the
1549energy of the :math:`i`-th crystal associated with the shower.
1552 This variable is sensitive to other nearby particles and so cluster isolation properties shoud
1553 always be checked. For more information please see the
1554 `ECL Cluster Recommendations <https://indico.belle2.org/event/13722/contributions/84645/attachments/31512/51585/ecl_recommendation.pdf>`_
1558 - More details about the implementation can be found in `BELLE2-NOTE-TE-2017-001 <https://docs.belle2.org/record/454?ln=en>`_ .
1559 - More details about Zernike polynomials can be found on `Wikipedia <https://en.wikipedia.org/wiki/Zernike_polynomials>`_ .
1562 Please read `this <importantNoteECL>` first.
1564 - Lower limit: :math:`0.0`
1565 - Upper limit: :math:`1.0`
1566 - Precision: :math:`10` bit
1569 REGISTER_VARIABLE("clusterSecondMoment", eclClusterSecondMoment, R
"DOC(
1570Returns the second moment :math:`S` of the cluster. This is mainly implemented for reconstructing high a
1571energy :math:`\pi^0` originating from merged clusters.
1576 S = \frac{1}{S_{0}(\theta)}\frac{\sum_{i=0}^{n} w_{i} E_{i} r^2_{i}}{\sum_{i=0}^{n} w_{i} E_{i}}
1578where :math:`E_{i} = (E_0, E_1, ...)` are the crystal energies sorted by descending energy, :math:`w_{i}` is
1579the fraction of the crystal energy associated with the shower, and :math:`r_{i}` is the distance of
1580the :math:`i`-th digit to the shower center projected onto a plane perpendicular to the
1581shower axis. :math:`S_{0}(\theta)` normalizes :math:`S` to 1 for isolated photons.
1584 Please read `this <importantNoteECL>` first.
1586 - Lower limit: :math:`0.0`
1587 - Upper limit: :math:`40.0`
1588 - Precision: :math:`10` bit
1590)DOC","dimensionless");
1591 REGISTER_VARIABLE("clusterLAT", eclClusterLAT, R"DOC(
1592Returns lateral energy distribution of the shower. For radially-symmetric electromagnetic showers, this
1593variable peaks at :math:`\approx 0.3`. It is larger for hadronic particles and electrons with a nearby relative
1594or Bremsstrahlung photon.
1596It is defined as following:
1599 S = \frac{\sum_{i=2}^{n} w_{i} E_{i} r^2_{i}}{(w_{0} E_{0} + w_{1} E_{1}) r^2_{0} + \sum_{i=2}^{n} w_{i} E_{i} r^2_{i}}
1601where :math:`E_{i} = (E_0, E_1, ...)` are the crystal energies sorted by descending energy, :math:`w_{i}` is
1602the fraction of the crystal energy associated with the shower, :math:`r_{i}` is the distance of
1603the :math:`i`-th digit to the shower center projected onto a plane perpendicular to the shower axis,
1604and :math:`r_{0} \approx 5\,cm` is the average distance between two crystal centres.
1607 This variable peaks around 0.3 for symmetrical electromagnetic showers and is larger for hadronic
1608 showers and electrons with a close-by radiative or Bremsstrahlung photon.
1611 Please read `this <importantNoteECL>` first.
1613 - Lower limit: :math:`0.0`
1614 - Upper limit: :math:`1.0`
1615 - Precision: :math:`10` bit
1618 REGISTER_VARIABLE("clusterNHits", eclClusterNHits, R
"DOC(
1619Returns sum of weights :math:`w_{i}` (:math:`w_{i} \leq 1`) of all crystals in the cluster.
1620For non-overlapping clusters this is equal to the number of crystals in the cluster. However, in the case
1621of overlapping clusters where individual crystal energies are split among them, this can be a non-integer value.
1624 If fractional weights are not of interest, this value should be cast to the nearest `int`
1627 Please read `this <importantNoteECL>` first.
1629 - Lower limit: :math:`0.0`
1630 - Upper limit: :math:`200.0`
1631 - Precision: :math:`10` bit
1634 REGISTER_VARIABLE("clusterTrackMatch", eclClusterTrackMatched, R
"DOC(
1635Returns 1.0 if at least one reconstructed charged track is matched to the cluster. Track-cluster
1636matching is briefly described below.
1638Every reconstructed track is extrapolated to the ECL. Every ECL crystal that is crossed by
1639the extrapolated track is marked. Following this, every cluster that contains a marked crystal
1640becomes associated with the original track. The current algorithm matches only one cluster to a
1641track but can match multiple tracks to the same cluster. In the latter case, all tracks matched
1642to the same cluster will return the same cluster variables e.g. all will have the same `clusterE`.
1644 REGISTER_VARIABLE("nECLClusterTrackMatches", nECLClusterTrackMatches, R
"DOC(
1645Returns the number of tracks matched to the cluster. For more information on track-cluster matching
1646please see the description for `clusterTrackMatch`.
1648For the clusters of neutral particles, this should always return 0. If there is no cluster ``NaN`` is
1651 REGISTER_VARIABLE("clusterHasPulseShapeDiscrimination", eclClusterHasPulseShapeDiscrimination, R
"DOC(
1652Status bit to indicate if the waveforms from the cluster pass the requirements for computing pulse
1653shape discrimination variables such as `clusterPulseShapeDiscriminationMVA`.
1655.. topic:: Pulse Shape Information Requirements
1657 The exact requirements for a cluster have pulse shape information are as follows:
1658 - there is at least one crystal with energy above 30 MeV for phase 2 data or 50 MeV for phase 3 data
1659 (this is the energy threshold requirement for saving waveforms offline)
1660 - one of the waveforms for the cluster must have a good :math:`\chi^2` fit
1663 REGISTER_VARIABLE("beamBackgroundSuppression", beamBackgroundSuppression, R
"DOC(
1664Returns the output of an MVA classifier that uses shower-related variables to distinguish true photon clusters from beam background clusters.
1665Class 1 is for true photon clusters while class 0 is for beam background clusters.
1667The MVA has been trained using MC and the features used, in decreasing importance, are:
1670- `clusterPulseShapeDiscriminationMVA`
1673- `clusterZernikeMVA` (this has been removed starting from the MC16 training)
1677 For the correct usage, please see
1678 the `Performance Recommendations Webpage <https://belle2.pages.desy.de/performance/recommendations/>`_.
1682 Please cite `this proceeding <https://inspirehep.net/literature/2785196>`_ if using this tool.
1684 REGISTER_VARIABLE("fakePhotonSuppression", fakePhotonSuppression, R
"DOC(
1685Returns the output of an MVA classifier that uses shower-related variables to distinguish true photon clusters from fake photon clusters.
1686Class 1 is for true photon clusters while class 0 is for fake photon clusters.
1688The MVA has been trained using MC and the features, in decreasing importance, are:
1690- `clusterPulseShapeDiscriminationMVA`
1695- `clusterZernikeMVA` (this has been removed starting from the MC16 training)
1698 For the correct usage, please see
1699 the `Performance Recommendations Webpage <https://belle2.pages.desy.de/performance/recommendations/>`_.
1702 Please cite `this proceeding <https://inspirehep.net/literature/2785196>`_ if using this tool.
1705 REGISTER_VARIABLE("hadronicSplitOffSuppression", hadronicSplitOffSuppression, R
"DOC(
1706Returns the output of an MVA classifier that uses shower-related variables to distinguish true photon clusters from hadronic splitoff clusters.
1709- 1 for true photon clusters
1710- 0 for hadronic splitoff clusters
1712The MVA has been trained using samples of signal photons and hadronic splitoff photons coming from MC.
1713The features used are (in decreasing order of significance):
1715- `clusterPulseShapeDiscriminationMVA`
1717- `clusterZernikeMVA`
1721- `clusterSecondMoment`
1724 MAKE_DEPRECATED("hadronicSplitOffSuppression",
true,
"light-2302-genetta", R
"DOC(
1725 Use the variable `fakePhotonSuppression` instead which is maintained and uses the latest weight files.
1727 REGISTER_VARIABLE("clusterKlId", eclClusterKlId, R
"DOC(
1728Returns MVA classifier that uses ECL clusters variables to discriminate Klong clusters from em background.
1737 REGISTER_VARIABLE("clusterPulseShapeDiscriminationMVA", eclPulseShapeDiscriminationMVA, R
"DOC(
1738Returns the output of an MVA classifier that uses pulse shape information to discriminate between electromagnetic
1739and hadronic showers. Class 1 is for electromagnetic showers while class 0 is for hadronic showers.
1742 Please cite `this paper <https://inspirehep.net/literature/1807894>`_ if using this tool.
1745 REGISTER_VARIABLE("clusterNumberOfHadronDigits", eclClusterNumberOfHadronDigits, R
"DOC(
1746Returns the number of hadron digits in the cluster based on pulse shape information. This is the weight sum of cluster digits
1747that have :math:`> 3\,` MeV for the hadronic scintillation component. The digits must have pulse shape information available
1748(see `clusterHasPulseShapeDiscrimination` for more information).
1751 This is a purely technical flag and should not be used for any physics-level selection
1754 Please read `this <importantNoteECL>` first.
1756 - Lower limit: :math:`0.0`
1757 - Upper limit: :math:`255.0`
1758 - Precision: :math:`18` bit
1761 REGISTER_VARIABLE("clusterClusterID", eclClusterId, R
"DOC(
1762Returns the ID the cluster within the connected region to which it belongs.
1764 REGISTER_VARIABLE("clusterHasNPhotons", eclClusterHasNPhotonsHypothesis, R
"DOC(
1765Returns 1.0 if the cluster has the "N photons" hypothesis (historically called "N1"),
17660.0 if not, and ``NaN`` if no cluster is associated to the particle.
1768 REGISTER_VARIABLE("clusterHasNeutralHadron", eclClusterHasNeutralHadronHypothesis, R
"DOC(
1769Returns 1.0 if the cluster has the "neutral hadrons" hypothesis (historically called "N2"),
17700.0 if not, and ``NaN`` if no cluster is associated to the particle.
1772 REGISTER_VARIABLE("eclExtTheta", eclExtTheta, R
"DOC(
1773Returns the :math:`\theta` angle of the extrapolated track associated to the cluster (if any).
1776 This requires the ``ECLTrackCalDigitMatch`` module to be executed.
1779 REGISTER_VARIABLE("eclExtPhi", eclExtPhi, R"DOC(
1780Returns the :math:`\phi` angle of the extrapolated track associated to the cluster (if any).
1783 This requires the ``ECLTrackCalDigitMatch`` module to be executed.
1786 REGISTER_VARIABLE("eclExtPhiId", eclExtPhiId, R"DOC(
1787Returns the :math:`\phi` ID of the extrapolated track associated to the cluster (if any).
1790 This requires the ``ECLTrackCalDigitMatch`` module to be executed.
1793 REGISTER_VARIABLE("weightedAverageECLTime", weightedAverageECLTime, R
"DOC(
1794Returns the weighted average time of all clusters corresponding to daughter particles of the provided particle.
1797 REGISTER_VARIABLE(
"maxWeightedDistanceFromAverageECLTime", maxWeightedDistanceFromAverageECLTime, R
"DOC(
1798Returns maximum weighted distance between time of the cluster of a photon and the ECL average time, amongst
1799the clusters (neutrals) and matched clusters (charged) of daughters (of all generations) of the provided particle.
1802 REGISTER_VARIABLE(
"clusterMdstIndex", eclClusterMdstIndex, R
"DOC(
1803Returns the ``StoreArray`` index of the cluster mDST object. This can be useful for track-based particles that are matched to an cluster.
1806 REGISTER_VARIABLE("nECLOutOfTimeCrystals", nECLOutOfTimeCrystals, R
"DOC(
1807**[Eventbased]** Returns the number of crystals that are out of time with the event time (``eventT0``) by more than 110.0 ns. Only crystals with an energy greater than
1811 REGISTER_VARIABLE("nECLOutOfTimeCrystalsFWDEndcap", nECLOutOfTimeCrystalsFWDEndcap, R
"DOC(
1812**[Eventbased]** Returns the number of crystals in the forward endcap that are out of time with the event time (``eventT0``) by more than 110.0 ns. Only crystals with an energy greater than
1816 REGISTER_VARIABLE("nECLOutOfTimeCrystalsBarrel", nECLOutOfTimeCrystalsBarrel, R
"DOC(
1817**[Eventbased]** Returns the number of crystals in the barrel that are out of time with the event time (``eventT0``) by more than 110.0 ns. Only crystals with an energy greater than
1821 REGISTER_VARIABLE("nECLOutOfTimeCrystalsBWDEndcap", nECLOutOfTimeCrystalsBWDEndcap, R
"DOC(
1822**[Eventbased]** Returns the number of crystals in the backward endcap that are out of time with the event time (``eventT0``) by more than 110.0 ns. Only crystals with an energy greater than
1826 REGISTER_VARIABLE("nRejectedECLShowers", nRejectedECLShowers, R
"DOC(
1827**[Eventbased]** Returns the number of ECL showers that do not become clusters. If the number exceeds 255, the variable is set to 255.
1830 REGISTER_VARIABLE("nRejectedECLShowersFWDEndcap", nRejectedECLShowersFWDEndcap, R
"DOC(
1831**[Eventbased]** Returns the number of ECL showers in the forward endcap that do not become clusters.
1832If the number exceeds 255, the variable is set to 255.
1835 REGISTER_VARIABLE("nRejectedECLShowersBarrel", nRejectedECLShowersBarrel, R
"DOC(
1836**[Eventbased]** Returns the number of ECL showers in the barrel that do not become clusters.
1837If the number exceeds 255, the variable is set to 255.
1840 REGISTER_VARIABLE("nRejectedECLShowersBWDEndcap", nRejectedECLShowersBWDEndcap, R
"DOC(
1841**[Eventbased]** Returns the number of ECL showers in the backward endcap that do not become clusters.
1842If the number exceeds 255, the variable is set to 255.
1845 REGISTER_VARIABLE("nKLMMultistripHitsFWDEndcap", nKLMMultistripHitsFWDEndcap, R
"DOC(
1846**[Eventbased]** Returns the number of multi-strip hits in the KLM forward endcap associated with the ECL cluster.
1849 REGISTER_VARIABLE("nKLMMultistripHitsBarrel", nKLMMultistripHitsBarrel, R
"DOC(
1850**[Eventbased]** Returns the number of multi-strip hits in the KLM barrel associated with the ECL cluster.
1853 REGISTER_VARIABLE("nKLMMultistripHitsBWDEndcap", nKLMMultistripHitsBWDEndcap, R
"DOC(
1854**[Eventbased]** Returns the number of multi-strip hits in the KLM backward endcap associated with the ECL cluster.
1857 REGISTER_VARIABLE("nKLMMultistripHits", nKLMMultistripHits, R
"DOC(
1858**[Eventbased]** Returns the number of multi-strip hits in the KLM associated with the ECL cluster.
1861 REGISTER_VARIABLE("nECLShowersFWDEndcap", nECLShowersFWDEndcap, R
"DOC(
1862**[Eventbased]** Returns the number of ECL showers in the forward endcap.
1865 REGISTER_VARIABLE("nECLShowersBarrel", nECLShowersBarrel, R
"DOC(
1866**[Eventbased]** Returns the number of ECL showers in the barrel.
1869 REGISTER_VARIABLE("nECLShowersBWDEndcap", nECLShowersBWDEndcap, R
"DOC(
1870**[Eventbased]** Returns the number of ECL showers in the backward endcap.
1873 REGISTER_VARIABLE("nECLShowers", nECLShowers, R
"DOC(
1874**[Eventbased]** Returns the number of ECL showers.
1877 REGISTER_VARIABLE("nECLLocalMaximumsFWDEndcap", nECLLocalMaximumsFWDEndcap, R
"DOC(
1878**[Eventbased]** Returns the number of Local Maximums in the ECL forward endcap.
1881 REGISTER_VARIABLE("nECLLocalMaximumsBarrel", nECLLocalMaximumsBarrel, R
"DOC(
1882**[Eventbased]** Returns the number of Local Maximums in the ECL barrel.
1885 REGISTER_VARIABLE("nECLLocalMaximumsBWDEndcap", nECLLocalMaximumsBWDEndcap, R
"DOC(
1886**[Eventbased]** Returns the number of Local Maximums in the ECL backward endcap.
1889 REGISTER_VARIABLE("nECLLocalMaximums", nECLLocalMaximums, R
"DOC(
1890**[Eventbased]** Returns the number of Local Maximums in the ECL.
1893 REGISTER_VARIABLE("nECLTriggerCellsFWDEndcap", nECLTriggerCellsFWDEndcap, R
"DOC(
1894**[Eventbased]** Returns the number of ECL trigger cells above 100 MeV in the forward endcap.
1897 REGISTER_VARIABLE("nECLTriggerCellsBarrel", nECLTriggerCellsBarrel, R
"DOC(
1898**[Eventbased]** Returns the number of ECL trigger cells above 100 MeV in the barrel.
1901 REGISTER_VARIABLE("nECLTriggerCellsBWDEndcap", nECLTriggerCellsBWDEndcap, R
"DOC(
1902**[Eventbased]** Returns the number of ECL trigger cells above 100 MeV in the backward endcap.
1905 REGISTER_VARIABLE("nECLTriggerCells", nECLTriggerCells, R
"DOC(
1906**[Eventbased]** Returns the number of ECL trigger cells above 100 MeV.
1909 REGISTER_VARIABLE("eclClusterOnlyInvariantMass", eclClusterOnlyInvariantMass, R
"DOC(
1910Returns the invariant mass calculated from all neutral and track-matched cluster daughters using the cluster 4-momenta.
1911This is primarily used for ECL-based dark sector physics and debugging track-cluster matching.
1913)DOC","GeV/:math:`\\text{c}^2`");
1915 REGISTER_METAVARIABLE("photonHasOverlap(cutString, photonlistname, tracklistname)", photonHasOverlap, R"DOC(
1916Returns ``True`` if the connection region of the cluster is shared by another cluster. Both neutral and track-matched clusters
1919A ``cutString`` can be provided in order to ignore clusters that do not satisfy a given criteria. By default, the particle lists
1920``gamma:all`` and ``e-:all`` are used to check for neutral and track-matched clusters respectively. However, this can be customised
1921by using the ``photonlistname`` and ``tracklistname`` parameters. If ``gamma:all`` or ``e-:all`` does not exist or if this variable is applied
1922to a particle that is not a photon, ``NaN`` will be returned.
1923)DOC", Manager::VariableDataType::c_double);
1925 REGISTER_VARIABLE("clusterUncorrE", eclClusterUncorrectedE, R
"DOC(
1926Returns the uncorrected energy of the cluster.
1929 This variable should not be used for any physics analysis but only for ECL or calibration studies.
1933 REGISTER_VARIABLE("distanceToMcKl",distanceToMcKl,R"DOC(
1934Returns the distance to the nearest truth-matched :math:`K_L^0` particle that has been extrapolated to the cluster.
1937 This requires the `getNeutralHadronGeomMatches` function to be used.
1941 REGISTER_VARIABLE(
"distanceToMcNeutron",distanceToMcNeutron,R
"DOC(
1942Returns the distance to the nearest truth-matched (anti)neutron particle that has been extrapolated to the cluster.
1945 This requires the `getNeutralHadronGeomMatches` function to be used.
1949 REGISTER_VARIABLE(
"mdstIndexMcKl",mdstIndexMcKl,R
"DOC(
1950Returns the ``StoreArray`` index of the mDST object corresponding to the nearest truth-matched :math:`K_L^0` particle as determined
1951during the calculation of the `distanceToMcKl` variable.
1954 This requires the `getNeutralHadronGeomMatches` function to be used.
1958 REGISTER_VARIABLE("mdstIndexMcNeutron",mdstIndexMcNeutron,R
"DOC(
1959Returns the ``StoreArray`` index of the mDST object corresponding to the nearest truth-matched (anti)neutron particle as determined
1960during the calculation of the `distanceToMcKl` variable.
1963 This requires the `getNeutralHadronGeomMatches` function to be used.
1965 REGISTER_VARIABLE("clusterTimeNorm90", eclClusterTimeNorm90,R
"DOC(
1966Returns a normalised version of `clusterTiming` such that :math:`90\%` of real photons will
1967have :math:`|\text{timing normalised}| < 1`.
1969This is calculated only for crystals within the CDC acceptance (:math:`161 \leq` `clusterCellID` :math:`\leq 8608`). Outside
1970this region, :math:`1.5 \times` `clusterTiming` / `clusterErrorTiming` is returned. The normalisation depends on the photon
1971energy, beam background level and cell ID. It also differs for data and MC.
1974 A typical requirement for this variable is :math:`|\text{clusterTimeNorm90}| < 3`
1977 The required payloads for this variable are stored in the Neutrals global tag. The recommended global tag to use can be
1978 found on the `Performance Recommendations Webpage <https://belle2.pages.desy.de/performance/recommendations/>`_.
1980)DOC", "dimensionless");
int getPDGCode() const
PDG code.
static const ParticleSet chargedStableSet
set of charged stable particles
static const double doubleNaN
quiet_NaN
static const ParticleType photon
photon particle
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
@ c_nPhotons
CR is split into n photons (N1)
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
static Environment & Instance()
Static method to get a reference to the Environment instance.
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
static const ReferenceFrame & GetCurrent()
Get current rest frame.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
#define MAKE_DEPRECATED(name, make_fatal, version, description)
Registers a variable as deprecated.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.