26 fExponentConstant(p.
get<
float>(
"ExponentConstant",0.42)),
27 fMinResRange(p.
get<
float>(
"MinResRange",0)),
28 fMaxResRange(p.
get<
float>(
"MaxResRange",30)),
29 fMaxPIDAValue(p.
get<
float>(
"MaxPIDAValue",50)),
30 fKDEEvalMaxSigma(p.
get<
float>(
"KDEEvalMaxSigma",3)),
31 fKDEEvalStepSize(p.
get<
float>(
"KDEEvalStepSize",0.01)),
33 fnormalDist(
util::NormalDistribution(fKDEEvalMaxSigma,fKDEEvalStepSize)),
34 fPIDAHistNbins(p.
get<unsigned
int>(
"PIDAHistNbins",100)),
35 fPIDAHistMin(p.
get<
float>(
"PIDAHistMin",0.0)),
36 fPIDAHistMax(p.
get<
float>(
"PIDAHistMax",50.0))
60 throw "Error: input histograms larger than max allowed bandwidths.";
62 throw "Error: input histograms do not have same size as bandwidths.";
67 hPIDAvalues->SetNameTitle(
"hPIDAvalues",
"PIDA Distribution");
70 for(
size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
73 std::stringstream hname,htitle;
74 hname <<
"hPIDAKDE_" << i_hist;
75 htitle <<
"PIDA KDE-smoothed Distribution, Bandwidth=" <<
fKDEBandwidths.at(i_hist);
77 hPIDAKDE[i_hist]->SetNameTitle(hname.str().c_str(),htitle.str().c_str());
87 for(
size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
88 std::stringstream bname;
89 bname <<
"hpida_kde_" << i_hist;
133 std::vector<float>
const&
dEdx = calo.
dEdx();
147 std::vector<float>
const&
dEdx){
154 std::map<double,double> range_dEdx_map;
156 for(
size_t i_r=0; i_r<resRange.size(); i_r++){
159 range_dEdx_map[ resRange[i_r] ] = dEdx[i_r];
178 unsigned int calo_index,
187 throw "pid::PIDAAlg --- PIDA Values not filled!";
210 if(range_dEdx_map.size()<2)
return;
215 map_iter != std::prev(range_dEdx_map.end());
218 double range_width = std::next(map_iter)->first - map_iter->first;
219 fpida_integral_dedx += range_width*( std::next(map_iter)->second + 0.5*(map_iter->second-std::next(map_iter)->second));
229 throw "pid::PIDAAlg --- PIDA Values not filled!";
253 const size_t kde_dist_size = (size_t)( (fkde_dist_max[i_b] - fkde_dist_min[i_b])/
fKDEEvalStepSize ) + 1;
257 for(
size_t i_step=0; i_step<kde_dist_size; i_step++){
261 for(
size_t i_pida=0; i_pida<
fpida_values.size(); i_pida++)
274 for(
size_t i_step=step_max; i_step>0; i_step--){
279 for(
size_t i_step=step_max; i_step<kde_dist_size; i_step++){
294 unsigned int calo_index,
337 for(
size_t i_pida=0; i_pida<
fpida_values.size(); i_pida++)
344 throw "util::NormalDistribution --- Cannot have zero step size!";
346 const size_t vector_size = (size_t)(max_sigma / step_size);
347 fValues.resize(vector_size);
349 const float AMPLITUDE = 1. / std::sqrt(2*
M_PI);
352 for(
size_t i_step=0; i_step<vector_size; i_step++){
353 float diff = i_step*step_size;
354 fValues[i_step] = AMPLITUDE * std::exp(-0.5*diff*diff);
355 integral+= fValues[i_step];
358 for(
size_t i_step=0; i_step<vector_size; i_step++)
359 fValues[i_step] /= (integral*2);
361 fStepSize = step_size;
362 fMaxSigma = fStepSize * vector_size;
369 if(x > fMaxSigma)
return 0;
371 size_t bin_low = x / fStepSize;
372 float remainder = (x - (bin_low*fStepSize)) / fStepSize;
374 return fValues[bin_low]*(1-remainder) + remainder*fValues[bin_low+1];
std::vector< float > fpida_errors
TH1F * hPIDAKDE[MAX_BANDWIDTHS]
void SetPIDATree(TTree *, TH1F *, std::vector< TH1F * >)
Namespace for general, non-LArSoft-specific utilities.
std::string leaf_structure
float kde_bandwidth[MAX_BANDWIDTHS]
float fpida_integral_pida
void FillPIDATree(unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
util::NormalDistribution fnormalDist
std::vector< float > fkde_dist_min
const geo::PlaneID & PlaneID() const
PIDAAlg(fhicl::ParameterSet const &p)
int FindBin(double value, std::vector< double > binning)
std::vector< float > fpida_kde_mp
void FillPIDAProperties(unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
void createKDE(const size_t)
unsigned int n_bandwidths
const std::vector< float > & ResidualRange() const
const std::vector< float > & getPIDAValues()
std::vector< float > fkde_dist_max
std::vector< float > fpida_kde_fwhm
unsigned int fPIDAHistNbins
float kde_fwhm[MAX_BANDWIDTHS]
double dEdx(float dqdx, float Efield)
float getPIDAKDEMostProbable(const size_t)
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
const unsigned int MAX_BANDWIDTHS
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
std::vector< float > fpida_values
PlaneID_t Plane
Index of the plane within its TPC.
Definition of data types for geometry description.
const std::vector< float > & dEdx() const
float getPIDAKDEFullWidthHalfMax(const size_t)
std::vector< float > fpida_kde_b
void calculatePIDAIntegral(std::map< double, double > const &)
const float & KineticEnergy() const
std::vector< float > fKDEBandwidths
std::vector< std::vector< float > > fkde_distribution
auto const & get(AssnsNode< L, R, D > const &r)
const std::vector< float > & getPIDAErrors()
PIDAProperties_t fPIDAProperties
float fpida_integral_dedx
const float & Range() const
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
void calculatePIDASigma()
float kde_mp[MAX_BANDWIDTHS]
QTextStream & endl(QTextStream &s)
Event finding and building.