 |
Belle II Software
release-05-01-25
|
15 #include <framework/logging/Logger.h>
16 #include <framework/gearbox/Unit.h>
18 #include <unordered_map>
21 #include <TParameter.h>
34 class ECLChargedPidPDFs:
public TObject {
85 class VarTransfoSettings {
88 VarTransfoSettings() {};
96 std::vector<double>
x;
121 void setVars(
const unsigned int pdg,
const int true_charge,
const unsigned int i,
const unsigned int j,
122 const std::vector<InputVar>& vars)
128 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
141 const std::vector<InputVar>*
getVars(
const unsigned int pdg,
const int charge,
const double& p,
const double& theta)
const
146 const int signed_pdg = pdg * charge / std::abs(charge);
156 const double& p = -1.0,
const double& theta = -999.0,
157 const int true_charge = 1,
161 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
163 std::cout <<
"Printing PDF info: " << std::endl;
164 if (pdg) std::cout <<
"-) |pdgId| * true_charge = " << signed_pdg << std::endl;
165 if (p != -1.0) std::cout <<
"-) p = " << p <<
" [GeV/c]" << std::endl;
166 if (theta != -999.0) std::cout <<
"-) clusterTheta = " << theta <<
" [rad]" << std::endl;
167 if (varid !=
InputVar::c_NONE) std::cout <<
"-) varid = " <<
static_cast<unsigned int>(varid) << std::endl;
172 if (signed_pdg && signed_pdg != pair0.first)
continue;
174 for (
const auto& pair1 : pair0.second) {
177 if (p != -1.0 && theta != -999.0) {
181 if (ji > 0 && ji != pair1.first)
continue;
183 std::cout <<
"\tglobal_bin_idx: " << pair1.first <<
" (" << x <<
"," << y <<
")" << std::endl;
185 for (
const auto& pair2 : pair1.second) {
187 std::cout <<
"\t\tvarid: " <<
static_cast<unsigned int>(varid) <<
", TF1: " << pair2.second->GetName() << std::endl;
228 void add(
const unsigned int pdg,
const int true_charge,
const unsigned int i,
const unsigned int j,
const InputVar varid, TF1* pdf)
233 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
247 const TF1*
getPdf(
const unsigned int pdg,
const int charge,
const double& p,
const double& theta,
const InputVar varid)
const
250 const int signed_pdg = pdg * charge / std::abs(charge);
253 double th = TMath::Abs(theta) /
m_ang_unit.GetVal();
260 B2DEBUG(30,
"\t\tAngular unit: " <<
m_ang_unit.GetVal());
262 B2DEBUG(30,
"\t\t|pdgId| * reco_charge = " << signed_pdg <<
", clusterTheta = " << th <<
", p = " << pp);
263 B2DEBUG(30,
"\t\tgbin = " << gbin <<
", x,y = (" << x <<
"," << y <<
")");
264 B2DEBUG(30,
"\t\tvariable id = " <<
static_cast<unsigned int>(varid));
266 return m_pdfsmap.at(signed_pdg).at(gbin).at(varid);
288 const int true_charge,
289 const unsigned int i,
const unsigned int j,
291 const std::string& classPath =
"",
292 const std::vector<int>& nDivisions = std::vector<int>(),
293 const std::vector<double>& cumulDist = std::vector<double>(),
294 const std::vector<double>& x = std::vector<double>(),
295 const std::vector<double>& covMatrix = std::vector<double>())
298 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
305 vts.classPath = classPath;
306 vts.nDivisionsMax = (!nDivisions.empty()) ? *(std::max_element(std::begin(nDivisions), std::end(nDivisions))) : 0;
307 vts.nDivisions = nDivisions;
308 vts.cumulDist = cumulDist;
310 vts.covMatrix = covMatrix;
330 const VarTransfoSettings*
getVTS(
const unsigned int pdg,
const int charge,
const double& p,
const double& theta)
const
333 const int signed_pdg = pdg * charge / std::abs(charge);
337 return &(
m_vtsmap.at(signed_pdg).at(gbin));
350 int findBin(
const TH2F* h,
const double& x,
const double& y)
const
353 int nbinsx_vis = h->GetXaxis()->GetNbins();
354 int nbinsy_vis = h->GetYaxis()->GetNbins();
361 if (x < h->GetXaxis()->GetBinLowEdge(1)) { xx = h->GetXaxis()->GetBinCenter(1); }
362 if (x >= h->GetXaxis()->GetBinLowEdge(nbinsx_vis + 1)) { xx = h->GetXaxis()->GetBinCenter(nbinsx_vis); }
363 if (y < h->GetYaxis()->GetBinLowEdge(1)) { yy = h->GetYaxis()->GetBinCenter(1); }
364 if (y >= h->GetYaxis()->GetBinLowEdge(nbinsy_vis + 1)) { yy = h->GetYaxis()->GetBinCenter(nbinsy_vis); }
366 int nbinsx = h->GetXaxis()->GetNbins() + 2;
367 int j = h->GetXaxis()->FindBin(xx);
368 int i = h->GetYaxis()->FindBin(yy);
370 return j + nbinsx * i;
bool doVarsTransfo() const
Check whether variables transformation is applied.
@ c_Z51
Zernike moment 51.
void setAngularUnit(const double &unit)
Set the angular unit to be consistent w/ the one used in the fit.
unsigned int jth
p bin index
const std::vector< InputVar > * getVars(const unsigned int pdg, const int charge, const double &p, const double &theta) const
Getter for list of input variables (enums) for which PDFs are stored for a given hypothesis and categ...
std::string classPath
Number of variables.
void setEnergyUnit(const double &unit)
Set the energy unit to be consistent w/ the one used in the fit.
void add(const unsigned int pdg, const int true_charge, const unsigned int i, const unsigned int j, const InputVar varid, TF1 *pdf)
Fills the internal maps for a given hypothesis and category (clusterTheta, p).
TH2F * m_categories
A 2D (x, y) = (clusterTheta, p) histogram whose bins represent the categories for which PDFs are defi...
std::unordered_map< int, VariablesMapByCategory > VariablesMapByParticle
Typedef.
~ECLChargedPidPDFs()
Destructor.
PdfsMapByParticle m_pdfsmap
Internal map.
const TF1 * getPdf(const unsigned int pdg, const int charge, const double &p, const double &theta, const InputVar varid) const
Return the PDF of this observable for this candidate's reconstructed (p, clusterTheta),...
unsigned int gbin
theta bin index
VTSMapByCategory m_vtsmap_bycategory
Internal map.
const TH2F * getPdfCategories() const
Get the 2D (clusterTheta, p) grid representing the categories for which PDFs are defined.
TParameter< double > m_energy_unit
The energy unit used for the binning.
const VarTransfoSettings * getVTS(const unsigned int pdg, const int charge, const double &p, const double &theta) const
Getter for variable transformation settings.
int findBin(const TH2F *h, const double &x, const double &y) const
Find global bin index of a 2D histogram for the given (x, y) values.
ClassDef(ECLChargedPidPDFs, 2)
ClassDef.
std::vector< double > covMatrix
Variable value at each step.
TParameter< double > m_ang_unit
The angular unit used for the binning.
ECLChargedPidPDFs()
Default constructor.
void printPdfMap(const unsigned int pdg=0, const double &p=-1.0, const double &theta=-999.0, const int true_charge=1, const InputVar varid=InputVar::c_NONE) const
Print out the content of the internal 'matrioska' maps.
VariablesMapByParticle m_variablesmap
Internal map.
PdfsByVariable m_pdfs_byvariable
Internal map.
InputVar
Enum type for observables for which PDFs are stored.
std::vector< int > nDivisions
Path of the class used to get the variables transfo.
std::unordered_map< int, VarTransfoSettings > VTSMapByCategory
Typedef.
VariablesMapByCategory m_variablesmap_bycategory
Internal map.
Class to hold parameters needed to perform pre-processing of input variables (e.g....
PdfsMapByCategory m_pdfsmap_bycategory
Internal map.
VTSMapByParticle m_vtsmap
Internal map.
void storeVarsTransfoSettings(const unsigned int pdg, const int true_charge, const unsigned int i, const unsigned int j, const int nVars, const std::string &classPath="", const std::vector< int > &nDivisions=std::vector< int >(), const std::vector< double > &cumulDist=std::vector< double >(), const std::vector< double > &x=std::vector< double >(), const std::vector< double > &covMatrix=std::vector< double >())
Setup the variable transformations for a given hypothesis in a category (p, clusterTheta),...
Abstract base class for different kinds of events.
@ c_LAT
Lateral shower shape.
void setVars(const unsigned int pdg, const int true_charge, const unsigned int i, const unsigned int j, const std::vector< InputVar > &vars)
Set the names of the input variables for which PDFs are stored for a given hypothesis and category (p...
std::unordered_map< int, VTSMapByCategory > VTSMapByParticle
Typedef.
std::unordered_map< int, PdfsMapByCategory > PdfsMapByParticle
Typedef.
int nDivisionsMax
Number of steps in which each variable range is sub-divided.
bool m_do_varstransform
To be toggled on if input variables have been transformed (i.e., if storeVarsTransfoSettings() was ca...
Class representing the DB payload w/ information about ECL PDF parameters for a set of particle hypot...
@ c_Z40
Zernike moment 40.
unsigned int ip
Variables covariance matrix.
@ c_E
Energy of maxE shower.
@ c_DeltaL
DeltaL (track depth)
std::unordered_map< int, PdfsByVariable > PdfsMapByCategory
Typedef.
~VarTransfoSettings()
Constructor.
std::unordered_map< int, std::vector< InputVar > > VariablesMapByCategory
Typedef.
std::vector< double > cumulDist
Maximal number of steps, across all variables.
void setPdfCategories(TH2F *h)
Set the 2D (clusterTheta, p) grid representing the categories for which PDFs are defined.
std::unordered_map< InputVar, TF1 * > PdfsByVariable
Typedef.
std::vector< double > x
Cumulative density function at each step.