10 #include <ecl/modules/eclSplitterN2/ECLSplitterN2Module.h>
13 #include <framework/datastore/RelationArray.h>
14 #include <framework/logging/Logger.h>
17 #include <ecl/utility/Position.h>
18 #include <ecl/dataobjects/ECLCalDigit.h>
19 #include <ecl/dataobjects/ECLConnectedRegion.h>
20 #include <ecl/dataobjects/ECLLocalMaximum.h>
21 #include <ecl/dataobjects/ECLShower.h>
24 #include <mdst/dataobjects/ECLCluster.h>
44 m_eclConnectedRegions(eclConnectedRegionArrayName()),
45 m_eclLocalMaximums(eclLocalMaximumArrayName()),
46 m_eclShowers(eclShowerArrayName())
49 setDescription(
"ECLSplitterN2Module: Baseline reconstruction splitter code for the neutral hadron hypothesis.");
52 addParam(
"positionMethod", m_positionMethod,
"Position determination method.", std::string(
"lilo"));
53 addParam(
"liloParameterA", m_liloParameterA,
"Position determination linear-log. parameter A.", 4.0);
54 addParam(
"liloParameterB", m_liloParameterB,
"Position determination linear-log. parameter B.", 0.0);
55 addParam(
"liloParameterC", m_liloParameterC,
"Position determination linear-log. parameter C.", 0.0);
58 setPropertyFlags(c_ParallelProcessingCertified);
69 m_liloParameters.resize(3);
70 m_liloParameters.at(0) = m_liloParameterA;
71 m_liloParameters.at(1) = m_liloParameterB;
72 m_liloParameters.at(2) = m_liloParameterC;
75 m_eclCalDigits.registerInDataStore(eclCalDigitArrayName());
76 m_eclConnectedRegions.registerInDataStore(eclConnectedRegionArrayName());
77 m_eclShowers.registerInDataStore(eclShowerArrayName());
80 m_eclShowers.registerRelationTo(m_eclConnectedRegions);
81 m_eclShowers.registerRelationTo(m_eclCalDigits);
82 m_eclShowers.registerRelationTo(m_eclLocalMaximums);
93 B2DEBUG(175,
"ECLCRSplitterN2Module::event()");
96 for (
auto& aCR : m_eclConnectedRegions) {
97 unsigned int iShower = 1;
99 const auto aECLShower = m_eclShowers.appendNew();
102 aECLShower->addRelationTo(&aCR);
105 for (
auto& aLM : aCR.getRelationsWith<
ECLLocalMaximum>(eclLocalMaximumArrayName())) {
107 aECLShower->addRelationTo(&aLM);
111 double highestEnergy = 0.0;
112 double highestEnergyTime = 0.;
113 double highestEnergyTimeResolution = 0.;
114 double weightSum = 0.0;
115 double energySum = 0.0;
116 unsigned int highestEnergyID = 0;
117 std::vector< ECLCalDigit > digits;
118 std::vector< double > weights;
121 auto relatedDigitsPairs = aCR.getRelationsTo<
ECLCalDigit>(eclCalDigitArrayName());
122 for (
unsigned int iRel = 0; iRel < relatedDigitsPairs.size(); iRel++) {
123 const auto aECLCalDigit = relatedDigitsPairs.object(iRel);
124 const auto weight = relatedDigitsPairs.weight(iRel);
127 aECLShower->addRelationTo(aECLCalDigit, weight);
130 const double energyDigit = aECLCalDigit->getEnergy();
131 if (energyDigit > highestEnergy) {
132 highestEnergy = energyDigit * weight;
133 highestEnergyID = aECLCalDigit->getCellId();
134 highestEnergyTime = aECLCalDigit->getTime();
135 highestEnergyTimeResolution = aECLCalDigit->getTimeResolution();
138 digits.push_back(*aECLCalDigit);
139 weights.push_back(weight);
142 energySum += energyDigit * weight;
146 const TVector3& showerposition = Belle2::ECL::computePositionLiLo(digits, weights, m_liloParameters);
147 aECLShower->setTheta(showerposition.Theta());
148 aECLShower->setPhi(showerposition.Phi());
149 aECLShower->setR(showerposition.Mag());
151 aECLShower->setEnergy(energySum);
152 aECLShower->setEnergyRaw(energySum);
153 aECLShower->setEnergyHighestCrystal(highestEnergy);
154 aECLShower->setCentralCellId(highestEnergyID);
155 aECLShower->setTime(highestEnergyTime);
156 aECLShower->setDeltaTime99(highestEnergyTimeResolution);
157 aECLShower->setNumberOfCrystals(weightSum);
159 aECLShower->setShowerId(iShower);
161 aECLShower->setConnectedRegionId(aCR.getCRId());
163 B2DEBUG(175,
"N2 shower " << iShower);
164 B2DEBUG(175,
" theta = " << aECLShower->getTheta());
165 B2DEBUG(175,
" phi = " << aECLShower->getPhi());
166 B2DEBUG(175,
" R = " << aECLShower->getR());
167 B2DEBUG(175,
" energy = " << aECLShower->getEnergy());
168 B2DEBUG(175,
" time = " << aECLShower->getTime());
169 B2DEBUG(175,
" time resolution = " << aECLShower->getDeltaTime99());
Class to store calibrated ECLDigits: ECLCalDigits.
Class to store local maxima (LM)
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
Class to perform the shower correction.
virtual void initialize() override
Initialize.
virtual void event() override
Event.
virtual void endRun() override
End run.
virtual void terminate() override
Terminate.
~ECLSplitterN2Module()
Destructor.
virtual void beginRun() override
Begin run.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.