 |
Belle II Software
release-05-02-19
|
15 #include <top/modules/TOPPDFDebugger/TOPPDFDebuggerModule.h>
16 #include <top/geometry/TOPGeometryPar.h>
17 #include <top/reconstruction/TOPreco.h>
18 #include <top/reconstruction/TOPtrack.h>
19 #include <top/reconstruction/TOPconfigure.h>
22 #include <tracking/dataobjects/ExtHit.h>
23 #include <mdst/dataobjects/MCParticle.h>
24 #include <top/dataobjects/TOPBarHit.h>
27 #include <framework/datastore/StoreArray.h>
30 #include <framework/gearbox/Const.h>
31 #include <framework/logging/Logger.h>
57 setDescription(
"This module makes an analytic PDF available in "
58 "a store array TOPPDFCollections, related from Tracks");
61 setPropertyFlags(c_ParallelProcessingCertified);
64 addParam(
"minBkgPerBar", m_minBkgPerBar,
65 "Minimal number of background photons per bar", 0.0);
66 addParam(
"scaleN0", m_scaleN0,
67 "Scale factor for N0", 1.0);
68 addParam(
"minTime", m_minTime,
69 "lower limit for photon time [ns] (default if minTime >= maxTime)", 0.0);
70 addParam(
"maxTime", m_maxTime,
71 "upper limit for photon time [ns] (default if minTime >= maxTime)", 0.0);
78 addParam(
"pdfOption", m_pdfOption,
79 "PDF option, one of 'rough', 'fine', 'optimal'", std::string(
"fine"));
80 addParam(
"pdgCodes", m_pdgCodes,
81 "PDG codes of charged stable particles for which to construct PDF. "
82 "Empty list means all charged stable particles.",
87 TOPPDFDebuggerModule::~TOPPDFDebuggerModule()
92 void TOPPDFDebuggerModule::initialize()
95 m_digits.isRequired();
96 m_tracks.isRequired();
102 mcParticles.isOptional();
105 barHits.isOptional();
108 m_pdfCollection.registerInDataStore();
110 m_associatedPDFs.registerInDataStore();
111 m_digits.registerRelationTo(m_associatedPDFs);
114 if (getLogConfig().getLogLevel() == LogConfig::c_Debug) {
115 m_debugLevel = getLogConfig().getDebugLevel();
119 if (m_pdgCodes.empty()) {
120 for (
const auto& part : Const::chargedStableSet) {
121 m_pdgCodes.push_back(abs(part.getPDGCode()));
122 m_masses.push_back(part.getMass());
125 for (
auto& pdg : m_pdgCodes) pdg = abs(pdg);
126 for (
auto pdg : m_pdgCodes) {
128 m_masses.push_back(part.getMass());
134 if (m_debugLevel > 0) config.print();
137 if (m_pdfOption ==
"rough") {
138 m_PDFOption = TOPreco::c_Rough;
139 }
else if (m_pdfOption ==
"fine") {
140 m_PDFOption = TOPreco::c_Fine;
141 }
else if (m_pdfOption ==
"optimal") {
142 m_PDFOption = TOPreco::c_Optimal;
144 B2ERROR(
"TOPPDFDebuggerModule: unknown PDF option '" << m_pdfOption <<
"'");
149 void TOPPDFDebuggerModule::beginRun()
153 void TOPPDFDebuggerModule::event()
155 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
158 TOPreco reco(m_masses.size(), m_masses.data(), m_pdgCodes.data(),
159 m_minBkgPerBar, m_scaleN0);
164 if (m_maxTime > m_minTime) {
169 for (
const auto& digit : m_digits) {
170 if (digit.getHitQuality() == TOPDigit::EHitQuality::c_Good) {
171 reco.
addData(digit.getModuleID(), digit.getPixelID(),
172 digit.getTime(), digit.getTimeError());
177 for (
const auto& track : m_tracks) {
184 const auto& module = geo->getModule(trk.
getModuleID());
190 for (
unsigned i = 0; i < m_pdgCodes.size(); i++) {
191 double mass = m_masses[i];
192 int iPDGCode = m_pdgCodes[i];
195 if (reco.
getFlag() != 1)
break;
198 associatePDFPeaks(reco, trk.
getModuleID(), iPDGCode);
204 float position = 0, width = 0, numPhotons = 0;
205 for (
int pixelID = 1; pixelID <= static_cast<int>(channelPDFCollection.size()); pixelID++) {
209 reco.
getPDFPeak(pixelID, k, position, width, numPhotons);
212 channelPDFCollection.at(pixelID - 1).push_back(tp);
219 if (reco.
getFlag() == 1) track.addRelationTo(topPDFColl);
225 void TOPPDFDebuggerModule::associatePDFPeaks(
const TOPreco& reco,
int moduleID,
int pdg)
228 for (
const auto& digit : m_digits) {
229 if (digit.getModuleID() != moduleID)
continue;
230 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
232 auto* associatedPDF = m_associatedPDFs.appendNew(pdg);
233 digit.addRelationTo(associatedPDF);
235 int pixelID = digit.getPixelID();
236 associatedPDF->setBackgroundWeight(reco.
getBkgLevel(pixelID));
238 const auto& tts = TOPGeometryPar::Instance()->getTTS(moduleID, digit.getPMTNumber());
239 float time = digit.getTime();
240 float timeErr = digit.getTimeError();
245 for (
const auto& gaus : tts.getTTS()) {
246 float sig2 = peak.
width * peak.
width + gaus.sigma * gaus.sigma + timeErr * timeErr;
247 float x = pow(time - peak.
position - gaus.position, 2) / sig2;
248 if (x > 20)
continue;
249 wt += peak.
numPhotons * gaus.fraction / sqrt(2 * M_PI * sig2) * exp(-x / 2);
270 associatedPDF->appendPeak(peak, wt);
278 void TOPPDFDebuggerModule::endRun()
282 void TOPPDFDebuggerModule::terminate()
float kyd
reconstructed photon direction in y at detection
bool addHypothesisPDF(const modulePDF_t &pdf, const int hypothesis)
adds the pdf for the given hypothesis (PDG code)
int getPDFPeakNy(int pixelID, int k) const
Returns total number of reflections in y of PDF peak.
int getFlag()
Return status.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Class to store analytical PDF relation from Tracks filled top/modules/TOPPDFDebugger/src/TOPPDFDebugg...
void reconstruct(const TOPtrack &trk, int pdg=0)
Run reconstruction for a given track.
int getPDFPeakNxe(int pixelID, int k) const
Returns number of reflections in x in prism.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
int getPDFPeakNxm(int pixelID, int k) const
Returns number of reflections in x before mirror.
Class to hold reconstructed track, interface to fortran.
int getPDFPeakNx(int pixelID, int k) const
Returns total number of reflections in x of PDF peak.
std::array< channelPDF_t, 512 > modulePDF_t
the PDF of the module is a list of 512 channel PDFs
float kye
reconstructed photon direction in y at emission
bool isValid() const
Check if track is properly defined.
float getPDFPeakKxe(int pixelID, int k) const
Returns photon reconstructed direction in x at emission.
parameters to describe a Gaussian
float xd
unfolded x coordinate of a pixel
int getNumofPDFPeaks(int pixelID) const
Returns number of peaks for given pixel describing signal PDF.
int addData(int moduleID, int pixelID, double time, double timeError)
Add data.
float getPDFPeakKyd(int pixelID, int k) const
Returns photon reconstructed direction in y at detection.
int getModuleID() const
Return module ID.
int nxm
number of reflections in x before mirror
float getPDFPeakYD(int pixelID, int k) const
Returns unfolded y position of pixel.
int nye
number of reflections in y in prism
int nxe
number of reflections in x in prism
TOP reconstruction module.
int nx
total number of reflections in x
TOP reconstruction: this class provides interface to fortran code.
void setMass(double mass, int pdg)
Set mass of the particle hypothesis (overrides settings in the constructor)
float getPDFPeakXD(int pixelID, int k) const
Returns unfolded x position of pixel.
int getPDFPeakNye(int pixelID, int k) const
Returns number of reflections in y in prism.
Abstract base class for different kinds of events.
float fic
Cerenkov azimuthal angle phi.
float position
position in time
int getPDFPeakType(int pixelID, int k) const
Returns type of the k-th PDF peak for given pixel.
int ny
total number of reflections in y
void setLocalPositionMomentum(const TVector3 &pos, const TVector3 &mom, int moduleID)
sets the position and momentum of the exthit in local coordinates
const TVector3 & getPosition() const
Return spatial position.
int type
0 unknown, 1 direct photon, 2 reflected photon
float getPDFPeakKze(int pixelID, int k) const
Returns photon reconstructed direction in z at emission.
int getPDFPeakNym(int pixelID, int k) const
Returns number of reflections in y before mirror.
const TVector3 & getMomentum() const
Return momentum vector.
float e
mean photon energy [eV]
float getPDFPeakSigE(int pixelID, int k) const
Returns photon energy spread of PDF peak.
void getPDFPeak(int pixelID, int k, float &position, float &width, float &numPhotons) const
Returns k-th PDF peak for given pixel describing signal PDF.
float numPhotons
number of photons
Provides a type-safe way to pass members of the chargedStableSet set.
float kzd
reconstructed photon direction in z at detection
float getPDFPeakKzd(int pixelID, int k) const
Returns photon reconstructed direction in z at detection.
float kze
reconstructed photon direction in z at emission
float yd
unfolded y coordinate of a pixel
float sige
photon energy sigma squared [eV^2]
float getPDFPeakKxd(int pixelID, int k) const
Returns photon reconstructed direction in x at detection.
Accessor to arrays stored in the data store.
float getPDFPeakFic(int pixelID, int k) const
Returns Cerenkov azimuthal angle of PDF peak.
int nym
number of reflections in y before mirror
float kxd
reconstructed photon direction in x at detection
float getBkgLevel(int pixelID) const
Returns estimated background level for given pixel.
void setStoreOption(StoreOption opt)
Sets option for storing PDF parameters in Fortran common TOP_PIK.
float getPDFPeakE(int pixelID, int k) const
Returns photon energy of PDF peak.
float getPDFPeakKye(int pixelID, int k) const
Returns photon reconstructed direction in y at emission.
void setPDFoption(PDFoption opt, int NP=0, int NC=0)
Sets PDF option.
void setTimeWindow(double Tmin, double Tmax)
Set time window for photons.
float kxe
reconstructed photon direction in x at emission