11#include <framework/logging/Logger.h>
12#include <framework/gearbox/Unit.h>
14#include <unordered_map>
17#include <TParameter.h>
94 std::vector<double>
x;
119 void setVars(
const unsigned int pdg,
const int true_charge,
const unsigned int i,
const unsigned int j,
120 const std::vector<InputVar>& vars)
126 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
139 const std::vector<InputVar>*
getVars(
const unsigned int pdg,
const int charge,
const double& p,
const double& theta)
const
144 const int signed_pdg = pdg * charge / std::abs(charge);
154 const double& p = -1.0,
const double& theta = -999.0,
155 const int true_charge = 1,
159 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
161 std::cout <<
"Printing PDF info: " << std::endl;
162 if (pdg) std::cout <<
"-) |pdgId| * true_charge = " << signed_pdg << std::endl;
163 if (p != -1.0) std::cout <<
"-) p = " << p <<
" [GeV/c]" << std::endl;
164 if (theta != -999.0) std::cout <<
"-) clusterTheta = " << theta <<
" [rad]" << std::endl;
165 if (varid !=
InputVar::c_NONE) std::cout <<
"-) varid = " <<
static_cast<unsigned int>(varid) << std::endl;
170 if (signed_pdg && signed_pdg != pair0.first)
continue;
172 for (
const auto& pair1 : pair0.second) {
175 if (p != -1.0 && theta != -999.0) {
179 if (ji > 0 && ji != pair1.first)
continue;
181 std::cout <<
"\tglobal_bin_idx: " << pair1.first <<
" (" << x <<
"," << y <<
")" << std::endl;
183 for (
const auto& pair2 : pair1.second) {
185 std::cout <<
"\t\tvarid: " <<
static_cast<unsigned int>(varid) <<
", TF1: " << pair2.second->GetName() << std::endl;
226 void add(
const unsigned int pdg,
const int true_charge,
const unsigned int i,
const unsigned int j,
const InputVar varid, TF1* pdf)
231 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
245 const TF1*
getPdf(
const unsigned int pdg,
const int charge,
const double& p,
const double& theta,
const InputVar varid)
const
248 const int signed_pdg = pdg * charge / std::abs(charge);
251 double th = TMath::Abs(theta) /
m_ang_unit.GetVal();
258 B2DEBUG(30,
"\t\tAngular unit: " <<
m_ang_unit.GetVal());
260 B2DEBUG(30,
"\t\t|pdgId| * reco_charge = " << signed_pdg <<
", clusterTheta = " << th <<
", p = " << pp);
261 B2DEBUG(30,
"\t\tgbin = " << gbin <<
", x,y = (" << x <<
"," << y <<
")");
262 B2DEBUG(30,
"\t\tvariable id = " <<
static_cast<unsigned int>(varid));
264 return m_pdfsmap.at(signed_pdg).at(gbin).at(varid);
286 const int true_charge,
287 const unsigned int i,
const unsigned int j,
289 const std::string& classPath =
"",
290 const std::vector<int>& nDivisions = std::vector<int>(),
291 const std::vector<double>& cumulDist = std::vector<double>(),
292 const std::vector<double>& x = std::vector<double>(),
293 const std::vector<double>& covMatrix = std::vector<double>())
296 const int signed_pdg = pdg * true_charge / std::abs(true_charge);
304 vts.
nDivisionsMax = (!nDivisions.empty()) ? *(std::max_element(std::begin(nDivisions), std::end(nDivisions))) : 0;
331 const int signed_pdg = pdg * charge / std::abs(charge);
335 return &(
m_vtsmap.at(signed_pdg).at(gbin));
349 int findBin(
const TH2F* h,
const double& x,
const double& y)
const
352 int nbinsx_vis = h->GetXaxis()->GetNbins();
353 int nbinsy_vis = h->GetYaxis()->GetNbins();
360 if (x < h->GetXaxis()->GetBinLowEdge(1)) { xx = h->GetXaxis()->GetBinCenter(1); }
361 if (x >= h->GetXaxis()->GetBinLowEdge(nbinsx_vis + 1)) { xx = h->GetXaxis()->GetBinCenter(nbinsx_vis); }
362 if (y < h->GetYaxis()->GetBinLowEdge(1)) { yy = h->GetYaxis()->GetBinCenter(1); }
363 if (y >= h->GetYaxis()->GetBinLowEdge(nbinsy_vis + 1)) { yy = h->GetYaxis()->GetBinCenter(nbinsy_vis); }
365 int nbinsx = h->GetXaxis()->GetNbins() + 2;
366 int j = h->GetXaxis()->FindBin(xx);
367 int i = h->GetYaxis()->FindBin(yy);
369 return j + nbinsx * i;
Class to hold parameters needed to perform pre-processing of input variables (e.g....
unsigned int jth
theta bin index
unsigned int gbin
Global bin corresponding to (jth,ip)
std::vector< double > cumulDist
Cumulative density function at each step.
VarTransfoSettings()
Constructor.
int nDivisionsMax
Maximal number of steps, across all variables.
std::vector< double > x
Variable value at each step.
std::string classPath
Path of the class used to get the variables transfo.
~VarTransfoSettings()
Destructor.
int nVars
Number of variables.
std::vector< int > nDivisions
Number of steps in which each variable range is sub-divided.
std::vector< double > covMatrix
Variables covariance matrix.
unsigned int ip
p bin index
Class representing the DB payload w/ information about ECL PDF parameters for a set of particle hypot...
TParameter< double > m_energy_unit
The energy unit used for the binning.
InputVar
Enum type for observables for which PDFs are stored.
@ c_DeltaL
DeltaL (track depth)
@ c_Z40
Zernike moment 40.
@ c_E
Energy of maxE shower.
@ c_Z51
Zernike moment 51.
@ c_LAT
Lateral shower shape.
ClassDef(ECLChargedPidPDFs, 2)
ClassDef.
VTSMapByParticle m_vtsmap
Internal map.
bool doVarsTransfo() const
Check whether variables transformation is applied.
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).
std::unordered_map< int, std::vector< InputVar > > VariablesMapByCategory
Typedef.
std::unordered_map< int, VariablesMapByCategory > VariablesMapByParticle
Typedef.
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...
PdfsMapByCategory m_pdfsmap_bycategory
Internal map.
~ECLChargedPidPDFs()
Destructor.
ECLChargedPidPDFs()
Default constructor.
std::unordered_map< int, PdfsMapByCategory > PdfsMapByParticle
Typedef.
void setPdfCategories(TH2F *h)
Set the 2D (clusterTheta, p) grid representing the categories for which PDFs are defined.
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.
VTSMapByCategory m_vtsmap_bycategory
Internal map.
std::unordered_map< int, VarTransfoSettings > VTSMapByCategory
Typedef.
TParameter< double > m_ang_unit
The angular unit used for the binning.
VariablesMapByCategory m_variablesmap_bycategory
Internal map.
const VarTransfoSettings * getVTS(const unsigned int pdg, const int charge, const double &p, const double &theta) const
Getter for variable transformation settings.
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),...
TH2F * m_categories
A 2D (x, y) = (clusterTheta, p) histogram whose bins represent the categories for which PDFs are defi...
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.
std::unordered_map< int, VTSMapByCategory > VTSMapByParticle
Typedef.
PdfsMapByParticle m_pdfsmap
Internal map.
std::unordered_map< int, PdfsByVariable > PdfsMapByCategory
Typedef.
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...
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),...
std::unordered_map< InputVar, TF1 * > PdfsByVariable
Typedef.
void setAngularUnit(const double &unit)
Set the angular unit to be consistent w/ the one used in the fit.
bool m_do_varstransform
To be toggled on if input variables have been transformed (i.e., if storeVarsTransfoSettings() was ca...
void setEnergyUnit(const double &unit)
Set the energy unit to be consistent w/ the one used in the fit.
const TH2F * getPdfCategories() const
Get the 2D (clusterTheta, p) grid representing the categories for which PDFs are defined.
PdfsByVariable m_pdfs_byvariable
Internal map.
Abstract base class for different kinds of events.