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];
104 float lastVal = 0.0002;
105 for (
auto i = 1; i < 240; i++) {
112 lastVal = lastVal + step;
119 for (
const auto& track :
m_tracks) {
121 track.addRelationTo(topLLScanRes);
127 topLLScanRes->addRelationTo(trk.
getExtHit());
128 topLLScanRes->addRelationTo(trk.
getBarHit());
133 std::vector<float> logLcoarseScan;
134 std::vector<float> nSignalPhotonsCoarseScan;
139 auto LL = pdfConstructor.
getLogL();
140 logLcoarseScan.push_back(LL.logL);
145 float minMassRange = 0;
146 float maxMassRange = 0;
154 std::vector<float> logLfineScan;
155 std::vector<float> massPointsFineScan;
156 std::vector<float> nSignalPhotonsFineScan;
157 auto mass = minMassRange;
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();
180 while (TMath::Abs(lastLL - currentLL) < 0.01 && index > 0) {
182 currentLL = logLcoarseScan[index];
194 topLLScanRes->set(massMax,
202 logLcoarseScan, logLfineScan,
203 nSignalPhotonsCoarseScan, nSignalPhotonsFineScan);
static const ChargedStable pion
charged pion particle
void setDescription(const std::string &description)
Sets the description of the module.
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
void initialize() override
Setup the storearrays.
TOPLLScannerModule()
Constructor: Sets the description, the properties and the parameters of the module.
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.
short m_nFineScanPoints
number of points for the fine-graned scan
~TOPLLScannerModule() override
Default destructor, Nothing to see here.
StoreArray< Track > m_tracks
collection of tracks
StoreArray< TOPDigit > m_digits
collection of digits
StoreArray< ExtHit > m_extHits
collection of extrapolated hits
StoreArray< TOPBarHit > m_barHits
collection of MCParticle hits at TOP
std::vector< float > m_massPoints
vector with the mass points used in the coarse scan
StoreArray< TOPLikelihoodScanResult > m_likelihoodScanResults
collection of likelihoods
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.