10 #include <analysis/VariableManager/Manager.h>
13 #include <framework/core/Module.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/datastore/StoreArray.h>
18 #include <mdst/dataobjects/ECLCluster.h>
20 #include <analysis/dataobjects/Particle.h>
21 #include <ecl/dataobjects/ECLShower.h>
34 double getShowerNumberOfCrystalsForEnergy(
const Particle* particle)
36 const ECLCluster* cluster = particle->getECLCluster();
38 auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>();
39 if (clusterShowerRelations.size() == 1) {
40 return clusterShowerRelations.object(0)->getNumberOfCrystalsForEnergy();
42 B2ERROR(
"Somehow found more than 1 ECLShower matched to the ECLCluster. This should not be possible!");
45 return std::numeric_limits<double>::quiet_NaN();
49 double getShowerNominalNumberOfCrystalsForEnergy(
const Particle* particle)
51 const ECLCluster* cluster = particle->getECLCluster();
53 auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>();
54 if (clusterShowerRelations.size() == 1) {
55 return clusterShowerRelations.object(0)->getNominalNumberOfCrystalsForEnergy();
57 B2ERROR(
"Somehow found more than 1 ECLShower matched to the ECLCluster. This should not be possible!");
60 return std::numeric_limits<double>::quiet_NaN();
64 double getShowerHadronIntensity(
const Particle* particle)
66 const ECLCluster* cluster = particle->getECLCluster();
68 auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>();
69 if (clusterShowerRelations.size() == 1) {
70 return clusterShowerRelations.object(0)->getShowerHadronIntensity();
72 B2ERROR(
"Somehow found more than 1 ECLShower matched to the ECLCluster. This should not be possible!");
75 return std::numeric_limits<double>::quiet_NaN();
79 double getShowerNumberOfHadronDigits(
const Particle* particle)
81 const ECLCluster* cluster = particle->getECLCluster();
83 auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>();
84 if (clusterShowerRelations.size() == 1) {
85 return clusterShowerRelations.object(0)->getNumberOfHadronDigits();
87 B2ERROR(
"Somehow found more than 1 ECLShower matched to the ECLCluster. This should not be possible!");
90 return std::numeric_limits<double>::quiet_NaN();
94 double getAbsZernikeMomentNM(
const Particle* particle,
95 const std::vector<double>& arguments)
97 if (arguments.size() != 2) {
98 B2FATAL(
"Wrong number of arguments, 2 required for meta function absZernikeMoment");
100 const long n = std::lround(arguments[0]);
101 const long m = std::lround(arguments[1]);
103 if ((n < 1) or (n > 5)) {
104 B2FATAL(
"n must be between 1 and 5 for meta function absZernikeMoment");
107 B2FATAL(
"m must be less than or equal to n for meta function absZernikeMoment");
110 const ECLCluster* cluster = particle->getECLCluster();
112 auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>();
113 if (clusterShowerRelations.size() == 1) {
114 return clusterShowerRelations.object(0)->getAbsZernikeMoment(n, m);
116 B2ERROR(
"Somehow found more than 1 ECLShower matched to the ECLCluster. This should not be possible!");
119 return std::numeric_limits<float>::quiet_NaN();
123 VARIABLE_GROUP(
"ECL Shower Debugging (cDST)");
125 REGISTER_VARIABLE(
"eclShowerNumberOfCrystalsForEnergy", getShowerNumberOfCrystalsForEnergy,
126 "[debugging] Returns the number of crystals ued to calculate the shower energy (optimized to minimize the energy resolution). This should not be confused with the number of crystals contained in the cluster. ");
128 REGISTER_VARIABLE(
"eclShowerNominalNumberOfCrystalsForEnergy", getShowerNominalNumberOfCrystalsForEnergy,
129 "[debugging] Returns the nominal number of crystals ued to calculate the shower energy (optimized to minimize the energy resolution). This should not be confused with the number of crystals contained in the cluster. ");
131 REGISTER_VARIABLE(
"eclShowerHadronIntensity", getShowerHadronIntensity,
132 "[debugging] Returns the hadron intensity of the shower associated with the particle.");
134 REGISTER_VARIABLE(
"eclShowerNumberOfHadronDigits", getShowerNumberOfHadronDigits,
135 "[debugging] Returns the number of hadron digits of the shower associated with the particle.");
137 VARIABLE_GROUP(
"ECL Shower Variables (cDST)");
139 REGISTER_VARIABLE(
"absZernikeMoment(n, m)", getAbsZernikeMomentNM,
140 "[eclChargedPIDExpert] the absolute value of zernike moment nm. Requires n <= 5 and m <= n.");
Abstract base class for different kinds of events.