12 #include <top/modules/TOPReconstruction/TOPReconstructorModule.h>
13 #include <top/reconstruction/TOPreco.h>
14 #include <top/reconstruction/TOPtrack.h>
15 #include <top/reconstruction/TOPconfigure.h>
18 #include <framework/gearbox/Const.h>
19 #include <framework/logging/Logger.h>
43 setDescription(
"Reconstruction for TOP counter. Uses reconstructed tracks "
44 "extrapolated to TOP and TOPDigits to calculate log likelihoods "
45 "for charged stable particles");
48 setPropertyFlags(c_ParallelProcessingCertified);
51 addParam(
"minBkgPerBar", m_minBkgPerBar,
52 "Minimal number of background photons per bar", 0.0);
53 addParam(
"scaleN0", m_scaleN0,
54 "Scale factor for N0", 1.0);
55 addParam(
"sigmaRphi", m_sigmaRphi,
56 "track smearing sigma in Rphi [cm]", 0.0);
57 addParam(
"sigmaZ", m_sigmaZ,
58 "track smearing sigma in Z [cm]", 0.0);
59 addParam(
"sigmaTheta", m_sigmaTheta,
60 "track smearing sigma in Theta [radians]", 0.0);
61 addParam(
"sigmaPhi", m_sigmaPhi,
62 "track smearing sigma in Phi [radians]", 0.0);
63 addParam(
"minTime", m_minTime,
64 "lower limit for photon time [ns] (default if minTime >= maxTime)", 0.0);
65 addParam(
"maxTime", m_maxTime,
66 "upper limit for photon time [ns] (default if minTime >= maxTime)", 0.0);
67 addParam(
"PDGCode", m_PDGCode,
68 "PDG code of hypothesis to construct pulls (0 means: use MC truth)",
70 addParam(
"TOPDigitCollectionName", m_topDigitCollectionName,
71 "Name of the collection of TOPDigits",
string(
""));
72 addParam(
"TOPLikelihoodCollectionName", m_topLikelihoodCollectionName,
73 "Name of the produced collection of TOPLikelihoods",
string(
""));
74 addParam(
"TOPPullCollectionName", m_topPullCollectionName,
"Name of the collection of produced TOPPulls",
string(
""));
79 TOPReconstructorModule::~TOPReconstructorModule()
84 void TOPReconstructorModule::initialize()
88 m_digits.isRequired(m_topDigitCollectionName);
89 m_tracks.isRequired();
90 m_extHits.isRequired();
91 m_barHits.isOptional();
92 m_recBunch.isOptional();
96 m_likelihoods.registerInDataStore(m_topLikelihoodCollectionName);
97 m_likelihoods.registerRelationTo(m_extHits);
98 m_likelihoods.registerRelationTo(m_barHits);
99 m_tracks.registerRelationTo(m_likelihoods);
101 m_topPulls.registerInDataStore(m_topPullCollectionName, DataStore::c_DontWriteOut);
102 m_tracks.registerRelationTo(m_topPulls, DataStore::c_Event, DataStore::c_DontWriteOut);
106 if (getLogConfig().getLogLevel() == LogConfig::c_Debug) {
107 m_debugLevel = getLogConfig().getDebugLevel();
112 for (
const auto& part : Const::chargedStableSet) {
113 m_masses[part.getIndex()] = part.getMass();
114 m_pdgCodes[part.getIndex()] = part.getPDGCode();
119 m_smearTrack = m_sigmaRphi > 0 || m_sigmaZ > 0 || m_sigmaTheta > 0 ||
125 if (m_debugLevel > 0) config.print();
128 void TOPReconstructorModule::beginRun()
132 void TOPReconstructorModule::event()
137 m_likelihoods.clear();
144 if (m_recBunch.isValid()) {
145 if (!m_recBunch->isReconstructed())
return;
150 TOPreco reco(Const::ChargedStable::c_SetSize, m_masses, m_pdgCodes,
151 m_minBkgPerBar, m_scaleN0);
154 if (m_maxTime > m_minTime) {
160 for (
const auto& digit : m_digits) {
161 if (digit.getHitQuality() == TOPDigit::EHitQuality::c_Good) {
162 reco.
addData(digit.getModuleID(), digit.getPixelID(), digit.getTime(),
163 digit.getTimeError());
169 for (
const auto& track : m_tracks) {
177 trk.
smear(m_sigmaRphi, m_sigmaZ, m_sigmaTheta, m_sigmaPhi);
178 B2INFO(
"TOPReconstructor: additional smearing of track parameters done");
183 if (m_debugLevel > 1) {
186 reco.
dumpLogL(Const::ChargedStable::c_SetSize);
191 double logl[Const::ChargedStable::c_SetSize];
192 double estPhot[Const::ChargedStable::c_SetSize];
194 reco.
getLogL(Const::ChargedStable::c_SetSize, logl, estPhot, nphot);
199 logl, estPhot, estBkg);
201 track.addRelationTo(topL);
206 int pixelID;
float t, t0, wid, fic, wt;
208 reco.
getPull(k, pixelID, t, t0, wid, fic, wt);
209 auto* pull = m_topPulls.appendNew(pixelID, t, t0, wid, fic, wt);
210 track.addRelationTo(pull);
218 void TOPReconstructorModule::endRun()
222 void TOPReconstructorModule::terminate()