9 #include <top/modules/TOPLLScannerModule/TOPLLScannerModule.h>
11 #include <top/reconstruction_cpp/TOPRecoManager.h>
12 #include <top/reconstruction_cpp/TOPTrack.h>
13 #include <top/reconstruction_cpp/PDFConstructor.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
27 #include <framework/datastore/DataStore.h>
28 #include <framework/datastore/StoreArray.h>
29 #include <framework/datastore/StoreObjPtr.h>
32 #include <framework/gearbox/Unit.h>
33 #include <framework/gearbox/Const.h>
34 #include <framework/logging/Logger.h>
43 setDescription(R
"DOC(A module to perform the TOP PID likelihood scan and find the actual minimum as function of the mass)DOC");
51 float& massMax,
float& minMassRange,
float& maxMassRange)
54 auto llMaxIndex = std::distance(logLs.begin(), std::max_element(logLs.begin(), logLs.end()));
55 maxLL = logLs[llMaxIndex];
56 massMax = masses[llMaxIndex];
60 minMassRange = massMax - 0.03;
61 if (minMassRange < masses[0])
62 minMassRange = masses[0];
64 maxMassRange = massMax + 0.03;
65 if (maxMassRange < masses[0])
66 maxMassRange = masses.back();
70 int llIndex = llMaxIndex;
71 while (llValue > maxLL - deltaLL && llIndex <
int(masses.size())) {
72 llValue = logLs[llIndex];
73 maxMassRange = masses[llIndex];
79 while (llValue > maxLL - deltaLL && llIndex >= 0) {
80 llValue = logLs[llIndex];
81 minMassRange = masses[llIndex];
89 m_digits.isRequired();
90 m_tracks.isRequired();
91 m_extHits.isRequired();
92 m_barHits.isOptional();
93 m_recBunch.isOptional();
96 m_likelihoodScanResults.registerInDataStore();
97 m_likelihoodScanResults.registerRelationTo(m_extHits);
98 m_likelihoodScanResults.registerRelationTo(m_barHits);
99 m_tracks.registerRelationTo(m_likelihoodScanResults);
104 float lastVal = 0.0002;
105 for (
auto i = 1; i < 240; i++) {
111 m_massPoints.push_back(lastVal);
112 lastVal = lastVal + step;
119 for (
const auto& track : m_tracks) {
120 auto* topLLScanRes = m_likelihoodScanResults.appendNew();
121 track.addRelationTo(topLLScanRes);
127 topLLScanRes->addRelationTo(trk.
getExtHit());
128 topLLScanRes->addRelationTo(trk.
getBarHit());
133 std::vector<float> logLcoarseScan;
134 std::vector<float> nSignalPhotonsCoarseScan;
136 for (
const auto& mass : m_massPoints) {
139 auto LL = pdfConstructor.
getLogL();
140 logLcoarseScan.push_back(LL.logL);
145 float minMassRange = 0;
146 float maxMassRange = 0;
148 scanLikelihood(m_massPoints, logLcoarseScan, 0.8, maxLL, massMax, minMassRange, maxMassRange);
154 std::vector<float> logLfineScan;
155 std::vector<float> massPointsFineScan;
156 std::vector<float> nSignalPhotonsFineScan;
157 auto mass = minMassRange;
158 auto step = (maxMassRange - minMassRange) / m_nFineScanPoints;
161 while (mass < maxMassRange) {
164 auto LL = pdfConstructor.
getLogL();
165 logLfineScan.push_back(LL.logL);
167 massPointsFineScan.push_back(mass);
172 scanLikelihood(massPointsFineScan, logLfineScan, 0.5, maxLL, massMax, minMassRange, maxMassRange);
177 auto lastLL = logLcoarseScan.back();
178 auto currentLL = logLcoarseScan.back();
179 auto index = m_massPoints.size() - 1;
180 while (TMath::Abs(lastLL - currentLL) < 0.01 && index > 0) {
182 currentLL = logLcoarseScan[index];
185 float threshold = m_massPoints[index + 1];
194 topLLScanRes->set(massMax,
201 m_massPoints, massPointsFineScan,
202 logLcoarseScan, logLfineScan,
203 nSignalPhotonsCoarseScan, nSignalPhotonsFineScan);
static const ChargedStable pion
charged pion particle
A module to perform the TOP PID likelihood scan and find the actual minimum as function of the mass.
void initialize() override
Setup the storearrays.
void event() override
Performs the scan.
void scanLikelihood(std::vector< float >masses, std::vector< float >logLs, float deltaLL, float &maxLL, float &massMax, float &minMassRange, float &maxMassRange)
Finds best fit value and confidence interval form a LL vie direct scan.
void terminate() override
Saves the results.
~TOPLLScannerModule() override
Default destructor, Nothing to see here.
PDF construction and log likelihood determination for a given track and particle hypothesis.
void switchOffDeltaRayPDF() const
Exclude delta-ray PDF in log likelihood calculation.
LogL getLogL() const
Returns extended log likelihood (using the default time window)
double getExpectedDeltaPhotons() const
Returns the expected number of delta-ray photons within the default time window.
double getExpectedSignalPhotons() const
Returns the expected number of signal photons within the default time window.
@ c_Reduced
only PDF peak data
@ c_Optimal
y dependent only where necessary
double getExpectedBkgPhotons() const
Returns the expected number of background photons within the default time window.
Reconstructed track at TOP.
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)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.