10#include <top/modules/TOPPDFChecker/TOPPDFCheckerModule.h>
13#include <top/geometry/TOPGeometryPar.h>
14#include <top/reconstruction_cpp/TOPTrack.h>
15#include <top/reconstruction_cpp/PDFConstructor.h>
16#include <top/reconstruction_cpp/TOPRecoManager.h>
19#include <tracking/dataobjects/ExtHit.h>
20#include <top/dataobjects/TOPBarHit.h>
23#include <framework/gearbox/Unit.h>
24#include <framework/gearbox/Const.h>
25#include <framework/logging/Logger.h>
33using namespace ROOT::Math;
56 setDescription(
"Module for checking analytic PDF used in likelihood calculation");
61 "histogram lower bound in time [ns]", 0.0);
63 "histogram upper bound in time [ns]", 50.0);
65 "histogram number of bins in time", 1000);
73 m_hits =
new TH2F(
"hits",
"photon hits", 512, 0.5, 512.5,
75 m_hits->SetXTitle(
"pixel ID");
76 m_hits->SetYTitle(
"time [ns]");
78 m_pdf =
new TH2F(
"pdf",
"PDF", 512, 0.5, 512.5,
80 m_pdf->SetXTitle(
"pixel ID");
81 m_pdf->SetYTitle(
"time [ns]");
84 m_hitsCol =
new TH2F(
"hitsCol",
"photon hits", 64, 0.5, 64.5,
89 m_pdfCol =
new TH2F(
"pdfCol",
"PDF", 64, 0.5, 64.5,
126 for (
const auto& track :
m_tracks) {
128 if (not trk.
isValid())
continue;
136 if (not pdfConstructor.
isValid())
continue;
140 const auto& module = geo->getModule(trk.
getModuleID());
148 for (
const auto& digit :
m_digits) {
151 m_hits->Fill(digit.getPixelID(), digit.getTime());
152 m_hitsCol->Fill(digit.getPixelCol(), digit.getTime());
157 for (
const auto& signalPDF : pdfConstructor.
getSignalPDF()) {
158 int pixelID = signalPDF.getPixelID();
159 for (
const auto& peak : signalPDF.getPDFPeaks()) {
161 double sigma =
sqrt(peak.wid);
162 for (
int i = 0; i < gRandom->Poisson(numPhot); i++) {
163 double time = gRandom->Gaus(peak.t0, sigma);
164 m_pdf->Fill(pixelID, time);
165 int pixelCol = (pixelID - 1) % 64 + 1;
174 B2WARNING(
"No track hitting the bars");
175 }
else if (numTrk > 1) {
176 B2WARNING(
"More than one track hits the bars");
187 cout <<
"Average particle parameters at entrance to bar (in local frame):" << endl;
188 cout <<
" slot ID: ";
189 for (
auto slot :
m_slotIDs) cout << slot <<
" ";
191 cout <<
" PDG code: ";
192 for (
auto pdg :
m_PDGCodes) cout << pdg <<
" ";
200 cout <<
"Number of particles: " <<
m_numTracks << endl;
211 for (
unsigned i = 0; i < particles.size(); ++i) {
212 if (particles[i] == particle and particles.weight(i) > 0)
return true;
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
static const ParticleSet chargedStableSet
set of charged stable particles
static const ParticleType invalidParticle
Invalid particle, used internally.
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHi...
TH2F * m_pdfCol
histogram of PDF projected to pixel columns
TH2F * m_hits
histogram of photon hits
double m_maxTime
histogram upper bound in time [ns]
double m_minTime
histogram lower bound in time [ns]
TH2F * m_hitsCol
histogram of photon hits projected to pixel columns
ROOT::Math::XYZPoint m_avrgPosition
average particle position at bar entrance (bar frame)
int m_numBins
number of bins in time
int m_numTracks
number of tracks
StoreArray< Track > m_tracks
collection of tracks
std::set< int > m_PDGCodes
particle PDG codes
TH2F * m_pdf
histogram of PDF
StoreArray< TOPDigit > m_digits
collection of digits
std::set< int > m_slotIDs
slot ID's that are hit by particle
ROOT::Math::XYZVector m_avrgMomentum
average particle momentum at bar entrance (bar frame)
PDF construction and log likelihood determination for a given track and particle hypothesis.
bool isValid() const
Checks the object status.
const std::vector< SignalPDF > & getSignalPDF() const
Returns signal PDF.
double getExpectedSignalPhotons() const
Returns the expected number of signal photons within the default time window.
@ c_Fine
y dependent everywhere
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
static void setTimeWindow(double minTime, double maxTime)
Sets time window.
Reconstructed track at TOP.
int getPDGCode() const
Returns PDG code of associated MCParticle (returns 0 if none)
const MCParticle * getMCParticle() const
Returns MC particle assigned to this track (if any)
bool isValid() const
Checks if track is successfully constructed.
const ExtHit * getExtHit() const
Returns extrapolated hit (track entrance to the bar)
int getModuleID() const
Returns slot ID.
const TOPBarHit * getBarHit() const
Returns bar hit of MC particle assigned to this track (if any)
static const double deg
degree to radians
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void terminate() override
Termination action.
bool isFromThisParticle(const TOPDigit &digit, const MCParticle *particle)
Checks if digit comes from given MC particle.
TOPPDFCheckerModule()
Constructor.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
Abstract base class for different kinds of events.