54 throw "Error: input histograms larger than max allowed bandwidths.";
56 throw "Error: input histograms do not have same size as bandwidths.";
61 hPIDAvalues->SetNameTitle(
"hPIDAvalues",
"PIDA Distribution");
64 for(
size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
67 std::stringstream hname,htitle;
68 hname <<
"hPIDAKDE_" << i_hist;
69 htitle <<
"PIDA KDE-smoothed Distribution, Bandwidth=" <<
fKDEBandwidths.at(i_hist);
71 hPIDAKDE[i_hist]->SetNameTitle(hname.str().c_str(),htitle.str().c_str());
81 for(
size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
82 std::stringstream bname;
83 bname <<
"hpida_kde_" << i_hist;
127 std::vector<double>
const& dEdx = calo.
dEdx();
141 std::vector<double>
const& dEdx){
148 std::map<double,double> range_dEdx_map;
150 for(
size_t i_r=0; i_r<resRange.size(); i_r++){
153 range_dEdx_map[ resRange[i_r] ] = dEdx[i_r];
172 unsigned int calo_index,
181 throw "pid::PIDAAlg --- PIDA Values not filled!";
204 if(range_dEdx_map.size()<2)
return;
209 map_iter != std::prev(range_dEdx_map.end());
212 double range_width = std::next(map_iter)->first - map_iter->first;
213 fpida_integral_dedx += range_width*( std::next(map_iter)->second + 0.5*(map_iter->second-std::next(map_iter)->second));
217 std::pow( (std::prev(range_dEdx_map.end())->first - range_dEdx_map.begin()->first),(
fExponentConstant-1) );
223 throw "pid::PIDAAlg --- PIDA Values not filled!";
239 const size_t min_pida_location = std::distance(
fpida_values.begin(),min_pida_iterator);
243 const size_t max_pida_location = std::distance(
fpida_values.begin(),max_pida_iterator);
247 const size_t kde_dist_size = (size_t)( (fkde_dist_max[i_b] - fkde_dist_min[i_b])/
fKDEEvalStepSize ) + 1;
251 for(
size_t i_step=0; i_step<kde_dist_size; i_step++){
255 for(
size_t i_pida=0; i_pida<
fpida_values.size(); i_pida++)
268 for(
size_t i_step=step_max; i_step>0; i_step--){
273 for(
size_t i_step=step_max; i_step<kde_dist_size; i_step++){
288 unsigned int calo_index,
331 for(
size_t i_pida=0; i_pida<
fpida_values.size(); i_pida++)
332 std::cout <<
"\tPIDA --- " << i_pida <<
"\t" <<
fpida_values[i_pida] << std::endl;
338 throw "util::NormalDistribution --- Cannot have zero step size!";
340 const size_t vector_size = (size_t)(max_sigma / step_size);
341 fValues.resize(vector_size);
343 const float AMPLITUDE = 1. / std::sqrt(2*M_PI);
346 for(
size_t i_step=0; i_step<vector_size; i_step++){
347 float diff = i_step*step_size;
348 fValues[i_step] = AMPLITUDE * std::exp(-0.5*diff*diff);
349 integral+= fValues[i_step];
352 for(
size_t i_step=0; i_step<vector_size; i_step++)
353 fValues[i_step] /= (integral*2);
355 fStepSize = step_size;
356 fMaxSigma = fStepSize * vector_size;
363 if(x > fMaxSigma)
return 0;
365 size_t bin_low = x / fStepSize;
366 float remainder = (x - (bin_low*fStepSize)) / fStepSize;
368 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 * >)
std::string leaf_structure
float kde_bandwidth[MAX_BANDWIDTHS]
float fpida_integral_pida
void FillPIDATree(unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
const double & KineticEnergy() const
util::NormalDistribution fnormalDist
std::vector< float > fkde_dist_min
const geo::PlaneID & PlaneID() const
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 > & getPIDAValues()
std::vector< float > fkde_dist_max
std::vector< float > fpida_kde_fwhm
unsigned int fPIDAHistNbins
float kde_fwhm[MAX_BANDWIDTHS]
void reconfigure(fhicl::ParameterSet const &p)
float getPIDAKDEMostProbable(const size_t)
T get(std::string const &key) const
const unsigned int MAX_BANDWIDTHS
std::vector< float > fpida_values
PlaneID_t Plane
Index of the plane within its TPC.
const std::vector< double > & ResidualRange() const
float getPIDAKDEFullWidthHalfMax(const size_t)
std::vector< float > fpida_kde_b
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
void calculatePIDAIntegral(std::map< double, double > const &)
void RunPIDAAlg(std::vector< double > const &, std::vector< double > const &)
std::vector< float > fKDEBandwidths
std::vector< std::vector< float > > fkde_distribution
const double & Range() const
const std::vector< float > & getPIDAErrors()
const std::vector< double > & dEdx() const
PIDAProperties_t fPIDAProperties
float fpida_integral_dedx
void calculatePIDASigma()
float kde_mp[MAX_BANDWIDTHS]
Event finding and building.