10#include <top/modules/TOPPDFDebugger/TOPPDFDebuggerModule.h>
13#include <top/geometry/TOPGeometryPar.h>
14#include <top/reconstruction_cpp/TOPRecoManager.h>
15#include <top/reconstruction_cpp/TOPTrack.h>
16#include <top/reconstruction_cpp/PDFConstructor.h>
19#include <tracking/dataobjects/ExtHit.h>
20#include <mdst/dataobjects/MCParticle.h>
21#include <top/dataobjects/TOPBarHit.h>
24#include <framework/logging/Logger.h>
30using namespace ROOT::Math;
53 "a store array TOPPDFCollections, related from Tracks");
60 "lower limit for photon time [ns] (default from DB used, if minTime >= maxTime)", 0.0);
62 "upper limit for photon time [ns] (default from DB used, if minTime >= maxTime)", 0.0);
64 "PDF option, one of 'rough', 'fine', 'optimal'", std::string(
"fine"));
66 "PDG codes of charged stable particles for which to construct PDF. "
67 "Empty list means all charged stable particles.",
115 B2ERROR(
"TOPPDFDebuggerModule: unknown PDF option '" <<
m_pdfOption <<
"'");
128 for (
const auto& track :
m_tracks) {
130 if (not trk.
isValid())
continue;
134 const auto& module = geo->getModule(trk.
getModuleID());
144 if (not pdfConstructor.
isValid()) {
145 B2ERROR(
"PDFConstructor found not valid - bug in reconstruction code?"
146 <<
LogVar(
"PDG", chargedStable.getPDGCode()));
157 for (
const auto& signalPDF : pdfConstructor.
getSignalPDF()) {
158 int pixelID = signalPDF.getPixelID();
159 for (
const auto& peak : signalPDF.getPDFPeaks()) {
160 float position = peak.t0;
161 float width =
sqrt(peak.wid);
164 channelPDFCollection.at(pixelID - 1).push_back(tp);
168 topPDFColl->
addHypothesisPDF(channelPDFCollection, chargedStable.getPDGCode());
176 for (
size_t i = 0; i < std::min(pixelLogLs.size(), pixLogLs.size()); i++) {
177 pixLogLs[i] = pixelLogLs[i].logL;
178 pixSigPhots[i] = pixelLogLs[i].expPhotons;
184 track.addRelationTo(topPDFColl);
185 track.addRelationTo(topPLkhs);
201 for (
const auto& digit :
m_digits) {
202 if (digit.getModuleID() != pdfConstructor.
getModuleID())
continue;
203 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
204 int pixelID = digit.getPixelID();
205 unsigned index = pixelID - 1;
206 if (index >= signalPDFs.size())
continue;
207 const auto& signalPDF = signalPDFs[index];
208 const auto* tts = signalPDF.getTTS();
209 const auto& pdfPeaks = signalPDF.getPDFPeaks();
210 const auto& extraInfos = signalPDF.getPDFExtraInfo();
211 if (extraInfos.size() != pdfPeaks.size()) {
212 B2ERROR(
"associatePDFPeaks: sizes of PDFPeaks and ExtraInfo's differ");
217 digit.addRelationTo(associatedPDF);
220 associatedPDF->setBackgroundWeight(bkgLevel);
222 associatedPDF->setDeltaRayWeight(deltaLevel);
224 float time = digit.getTime();
225 float timeErr = digit.getTimeError();
227 for (
size_t k = 0; k < pdfPeaks.size(); k++) {
228 const auto& pdfPeak = pdfPeaks[k];
229 const auto& pdfExtra = extraInfos[k];
233 peak.
numPhotons = pdfPeak.nph * signalPhotons;
235 for (
const auto& gaus : tts->getTTS()) {
236 float sig2 = peak.
width * peak.
width + gaus.sigma * gaus.sigma + timeErr * timeErr;
237 float x = pow(time - peak.
position - gaus.position, 2) / sig2;
238 if (x > 20)
continue;
239 wt += peak.
numPhotons * gaus.fraction /
sqrt(2 * M_PI * sig2) * exp(-x / 2);
242 peak.
fic = pdfPeak.fic;
244 peak.
sige = pdfExtra.sige;
245 peak.
nx = abs(pdfExtra.Nxm) + abs(pdfExtra.Nxb) + abs(pdfExtra.Nxe);
246 peak.
ny = abs(pdfExtra.Nym) + abs(pdfExtra.Nyb) + abs(pdfExtra.Nye);
247 peak.
nxm = abs(pdfExtra.Nxm);
248 peak.
nym = abs(pdfExtra.Nym);
249 peak.
nxe = abs(pdfExtra.Nxe);
250 peak.
nye = abs(pdfExtra.Nye);
251 peak.
xd = pdfExtra.xD;
252 peak.
yd = pdfExtra.yD;
253 peak.
type = pdfExtra.type;
254 peak.
kxe = pdfExtra.kxE;
255 peak.
kye = pdfExtra.kyE;
256 peak.
kze = pdfExtra.kzE;
257 peak.
kxd = pdfExtra.kxD;
258 peak.
kyd = pdfExtra.kyD;
259 peak.
kzd = pdfExtra.kzD;
260 associatedPDF->appendPeak(peak, wt);
Provides a type-safe way to pass members of the chargedStableSet set.
int getPDGCode() const
PDG code.
static const ParticleSet chargedStableSet
set of charged stable particles
ROOT::Math::XYZVector getMomentum() const
Get momentum at this extrapolation hit.
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
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...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Class to store analytical PDF relation from Tracks filled top/modules/TOPPDFDebugger/src/TOPPDFDebugg...
std::array< channelPDF_t, 512 > modulePDF_t
the PDF of the module is a list of 512 channel PDFs
void setLocalPositionMomentum(const ROOT::Math::XYZPoint &pos, const ROOT::Math::XYZVector &mom, int moduleID)
Sets the position and momentum of the exthit in local coordinates.
bool addHypothesisPDF(const modulePDF_t &pdf, const int hypothesis)
Adds the pdf for the given hypothesis (PDG code)
double m_maxTime
optional time limit for photons
double m_minTime
optional time limit for photons
StoreArray< TOPPDFCollection > m_pdfCollection
collection of analytic PDF's
TOP::PDFConstructor::EPDFOption m_PDFOption
PDF option.
StoreArray< TOPPixelLikelihood > m_pixelData
collection of per-pixel data
StoreArray< Track > m_tracks
collection of tracks
StoreArray< TOPAssociatedPDF > m_associatedPDFs
collection of associated PDF's
std::vector< int > m_pdgCodes
particle codes
StoreArray< TOPDigit > m_digits
collection of digits
std::vector< Const::ChargedStable > m_chargedStables
particle hypotheses
std::string m_pdfOption
PDF option name.
Class to store pixel-by-pixel likelihoods for a track relation from Tracks filled in top/modules/TOPP...
std::array< float, 512 > PixelArray_t
Array of length 512 to hold per-pixel information.
void setModuleID(int moduleID)
Sets module ID of the associated exthit.
bool addHypothesisSignalPhotons(const PixelArray_t &sfots, const int hypothesis)
Adds the signal photon array for the given hypothesis (PDG code)
bool addHypothesisLikelihoods(const PixelArray_t &plkhs, const int hypothesis)
Adds the likelihood array for the given hypothesis (PDG code)
double getPDFValue(int pixelID) const
Returns PDF value for given pixel.
double getPDFValue(int pixelID, double time) const
Returns PDF value at given time and pixel.
PDF construction and log likelihood determination for a given track and particle hypothesis.
const BackgroundPDF * getBackgroundPDF() const
Returns background PDF.
double getExpectedDeltaPhotons() const
Returns the expected number of delta-ray photons within the default time window.
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.
const std::vector< LogL > & getPixelLogLs(double t0, double sigt=0) const
Returns extended log likelihoods in pixels for PDF shifted in time.
int getModuleID() const
Returns slot ID.
const Const::ChargedStable & getHypothesis() const
Returns particle hypothesis.
@ c_Full
also extra information and derivatives
@ c_Optimal
y dependent only where necessary
@ c_Fine
y dependent everywhere
@ c_Rough
no dependence on y
double getExpectedBkgPhotons() const
Returns the expected number of background photons within the default time window.
const DeltaRayPDF & getDeltaRayPDF() const
Returns delta-ray PDF.
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.
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.
Class to store variables with their name which were sent to the logging service.
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.
void associatePDFPeaks(const TOP::PDFConstructor &pdfConstructor)
Associate PDF peaks with photons using S-plot technique.
TOPPDFDebuggerModule()
Constructor.
Abstract base class for different kinds of events.
int nx
total number of reflections in x
float kxd
reconstructed photon direction in x at detection
float fic
Cerenkov azimuthal angle phi.
float kze
reconstructed photon direction in z at emission
float e
mean photon energy [eV]
float xd
unfolded x coordinate of a pixel
int nym
number of reflections in y before mirror
int nxe
number of reflections in x in prism
int nye
number of reflections in y in prism
int nxm
number of reflections in x before mirror
float position
position in time
float kzd
reconstructed photon direction in z at detection
float sige
photon energy sigma squared [eV^2]
int ny
total number of reflections in y
float numPhotons
number of photons
float kyd
reconstructed photon direction in y at detection
int type
0 unknown, 1 direct photon, 2 reflected photon
float yd
unfolded y coordinate of a pixel
float kxe
reconstructed photon direction in x at emission
float kye
reconstructed photon direction in y at emission
Parameters to describe a Gaussian.