14 #include <ecl/modules/eclSplitterN2/ECLSplitterN2Module.h>
17 #include <framework/datastore/RelationArray.h>
18 #include <framework/logging/Logger.h>
21 #include <ecl/utility/Position.h>
22 #include <ecl/dataobjects/ECLCalDigit.h>
23 #include <ecl/dataobjects/ECLConnectedRegion.h>
24 #include <ecl/dataobjects/ECLLocalMaximum.h>
25 #include <ecl/dataobjects/ECLShower.h>
28 #include <mdst/dataobjects/ECLCluster.h>
48 m_eclConnectedRegions(eclConnectedRegionArrayName()),
49 m_eclLocalMaximums(eclLocalMaximumArrayName()),
50 m_eclShowers(eclShowerArrayName())
53 setDescription(
"ECLSplitterN2Module: Baseline reconstruction splitter code for the neutral hadron hypothesis.");
56 addParam(
"positionMethod", m_positionMethod,
"Position determination method.", std::string(
"lilo"));
57 addParam(
"liloParameterA", m_liloParameterA,
"Position determination linear-log. parameter A.", 4.0);
58 addParam(
"liloParameterB", m_liloParameterB,
"Position determination linear-log. parameter B.", 0.0);
59 addParam(
"liloParameterC", m_liloParameterC,
"Position determination linear-log. parameter C.", 0.0);
62 setPropertyFlags(c_ParallelProcessingCertified);
73 m_liloParameters.resize(3);
74 m_liloParameters.at(0) = m_liloParameterA;
75 m_liloParameters.at(1) = m_liloParameterB;
76 m_liloParameters.at(2) = m_liloParameterC;
79 m_eclCalDigits.registerInDataStore(eclCalDigitArrayName());
80 m_eclConnectedRegions.registerInDataStore(eclConnectedRegionArrayName());
81 m_eclShowers.registerInDataStore(eclShowerArrayName());
84 m_eclShowers.registerRelationTo(m_eclConnectedRegions);
85 m_eclShowers.registerRelationTo(m_eclCalDigits);
86 m_eclShowers.registerRelationTo(m_eclLocalMaximums);
97 B2DEBUG(175,
"ECLCRSplitterN2Module::event()");
100 for (
auto& aCR : m_eclConnectedRegions) {
101 unsigned int iShower = 1;
103 const auto aECLShower = m_eclShowers.appendNew();
106 aECLShower->addRelationTo(&aCR);
109 for (
auto& aLM : aCR.getRelationsWith<
ECLLocalMaximum>(eclLocalMaximumArrayName())) {
111 aECLShower->addRelationTo(&aLM);
115 double highestEnergy = 0.0;
116 double highestEnergyTime = 0.;
117 double highestEnergyTimeResolution = 0.;
118 double weightSum = 0.0;
119 double energySum = 0.0;
120 unsigned int highestEnergyID = 0;
121 std::vector< ECLCalDigit > digits;
122 std::vector< double > weights;
125 auto relatedDigitsPairs = aCR.getRelationsTo<
ECLCalDigit>(eclCalDigitArrayName());
126 for (
unsigned int iRel = 0; iRel < relatedDigitsPairs.size(); iRel++) {
127 const auto aECLCalDigit = relatedDigitsPairs.object(iRel);
128 const auto weight = relatedDigitsPairs.weight(iRel);
131 aECLShower->addRelationTo(aECLCalDigit, weight);
134 const double energyDigit = aECLCalDigit->getEnergy();
135 if (energyDigit > highestEnergy) {
136 highestEnergy = energyDigit * weight;
137 highestEnergyID = aECLCalDigit->getCellId();
138 highestEnergyTime = aECLCalDigit->getTime();
139 highestEnergyTimeResolution = aECLCalDigit->getTimeResolution();
142 digits.push_back(*aECLCalDigit);
143 weights.push_back(weight);
146 energySum += energyDigit * weight;
150 const TVector3& showerposition = Belle2::ECL::computePositionLiLo(digits, weights, m_liloParameters);
151 aECLShower->setTheta(showerposition.Theta());
152 aECLShower->setPhi(showerposition.Phi());
153 aECLShower->setR(showerposition.Mag());
155 aECLShower->setEnergy(energySum);
156 aECLShower->setEnergyRaw(energySum);
157 aECLShower->setEnergyHighestCrystal(highestEnergy);
158 aECLShower->setCentralCellId(highestEnergyID);
159 aECLShower->setTime(highestEnergyTime);
160 aECLShower->setDeltaTime99(highestEnergyTimeResolution);
161 aECLShower->setNumberOfCrystals(weightSum);
163 aECLShower->setShowerId(iShower);
165 aECLShower->setConnectedRegionId(aCR.getCRId());
167 B2DEBUG(175,
"N2 shower " << iShower);
168 B2DEBUG(175,
" theta = " << aECLShower->getTheta());
169 B2DEBUG(175,
" phi = " << aECLShower->getPhi());
170 B2DEBUG(175,
" R = " << aECLShower->getR());
171 B2DEBUG(175,
" energy = " << aECLShower->getEnergy());
172 B2DEBUG(175,
" time = " << aECLShower->getTime());
173 B2DEBUG(175,
" time resolution = " << aECLShower->getDeltaTime99());