10 #include <top/modules/TOPReconstruction/TOPReconstructorModule.h>
11 #include <top/reconstruction_cpp/TOPRecoManager.h>
12 #include <top/reconstruction_cpp/TOPTrack.h>
13 #include <top/reconstruction_cpp/PDFConstructor.h>
16 #include <framework/gearbox/Const.h>
17 #include <framework/logging/Logger.h>
42 setDescription(
"Reconstruction for TOP counter. Uses reconstructed tracks "
43 "extrapolated to TOP and TOPDigits to calculate log likelihoods "
44 "for charged stable particles");
47 setPropertyFlags(c_ParallelProcessingCertified);
50 addParam(
"minTime", m_minTime,
51 "lower limit for photon time [ns] (if minTime >= maxTime use the default from DB)", 0.0);
52 addParam(
"maxTime", m_maxTime,
53 "upper limit for photon time [ns] (if minTime >= maxTime use the default from DB)", 0.0);
54 addParam(
"PDGCode", m_PDGCode,
55 "PDG code of hypothesis to construct pulls (0 means: use MC truth)", 211);
56 addParam(
"deltaRayModeling", m_deltaRayModeling,
57 "include (True) or exclude (False) delta-ray modeling in log likelihood calculation",
false);
58 addParam(
"pTCut", m_pTCut,
59 "pT cut to suppress badly extrapolated tracks that cannot reach TOP counter", 0.27);
60 addParam(
"TOPDigitCollectionName", m_topDigitCollectionName,
61 "Name of the collection of TOPDigits",
string(
""));
62 addParam(
"TOPLikelihoodCollectionName", m_topLikelihoodCollectionName,
63 "Name of the produced collection of TOPLikelihoods",
string(
""));
64 addParam(
"TOPPullCollectionName", m_topPullCollectionName,
"Name of the collection of produced TOPPulls",
string(
""));
68 void TOPReconstructorModule::initialize()
72 m_digits.isRequired(m_topDigitCollectionName);
73 m_tracks.isRequired();
74 m_extHits.isRequired();
75 m_barHits.isOptional();
76 m_recBunch.isOptional();
80 m_likelihoods.registerInDataStore(m_topLikelihoodCollectionName);
81 m_likelihoods.registerRelationTo(m_extHits);
82 m_likelihoods.registerRelationTo(m_barHits);
83 m_tracks.registerRelationTo(m_likelihoods);
85 m_topPulls.registerInDataStore(m_topPullCollectionName, DataStore::c_DontWriteOut);
86 m_tracks.registerRelationTo(m_topPulls, DataStore::c_Event, DataStore::c_DontWriteOut);
90 void TOPReconstructorModule::event()
94 m_likelihoods.clear();
101 if (m_recBunch.isValid()) {
102 if (not m_recBunch->isReconstructed())
return;
107 TOPRecoManager::setTimeWindow(m_minTime, m_maxTime);
111 for (
const auto& track : m_tracks) {
113 const TOPTrack trk(track, m_topDigitCollectionName);
114 if (not trk.
isValid())
continue;
117 auto* topLL = m_likelihoods.appendNew();
118 track.addRelationTo(topLL);
122 int pdgCode = (m_PDGCode != 0) ? m_PDGCode : trk.
getPDGCode();
123 std::set<int> nfotSet;
124 std::set<double> nbkgSet;
126 for (
const auto& chargedStable : Const::chargedStableSet) {
129 if (not pdfConstructor.
isValid()) {
133 auto LL = pdfConstructor.
getLogL();
134 topLL->set(chargedStable, LL.numPhotons, LL.logL, LL.expPhotons, pdfConstructor.
getExpectedBkgPhotons());
136 nfotSet.insert(LL.numPhotons);
139 if (abs(chargedStable.getPDGCode()) == abs(pdgCode)) {
140 for (
const auto& p : pdfConstructor.
getPulls()) {
141 auto* pull = m_topPulls.appendNew(p.pixelID, p.time, p.peakT0 + p.ttsT0, p.sigma, p.phiCer, p.wt);
142 track.addRelationTo(pull);
146 topLL->setFlag(flag);
148 if (nfotSet.size() > 1) B2ERROR(
"Bug in TOP::PDFConstructor: number of photons differs between particle hypotheses");
149 if (nbkgSet.size() > 1) B2ERROR(
"Bug in TOP::PDFConstructor: estimated background differs between particle hypotheses");
TOP reconstruction module.
PDF construction and log likelihood determination for a given track and particle hypothesis.
LogL getLogL() const
Returns extended log likelihood (using the default time window)
bool isValid() const
Checks the object status.
const std::vector< Pull > & getPulls() const
Returns photon pulls w.r.t PDF peaks.
double getExpectedBkgPhotons() const
Returns the expected number of background photons within the default time window.
void switchDeltaRayPDF(bool deltaPDFOn) const
Include or exclude delta-ray PDF in log likelihood calculation.
Reconstructed track at TOP.
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
bool isValid() const
Checks if track is successfully constructed.
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
const TOPBarHit * getBarHit() const
Returns bar hit of MC particle assigned to this track (if any)
double getTransverseMomentum() const
Returns transverse momentum (at POCA)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.