LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
pid::PIDAAlg Class Reference

#include "PIDAAlg.h"

Classes

struct  PIDAProperties
 

Public Member Functions

 PIDAAlg (fhicl::ParameterSet const &p)
 
void reconfigure (fhicl::ParameterSet const &p)
 
void RunPIDAAlg (std::vector< float > const &, std::vector< float > const &)
 
void RunPIDAAlg (anab::Calorimetry const &)
 
void RunPIDAAlg (anab::Calorimetry const &, float &, float &)
 
float getPIDAMean ()
 
float getPIDASigma ()
 
const std::vector< float > & getPIDAValues ()
 
const std::vector< float > & getPIDAErrors ()
 
size_t getNKDEBandwidths ()
 
float getKDEBandwidth (const size_t i_b)
 
float getPIDAKDEMostProbable (const size_t)
 
float getPIDAKDEFullWidthHalfMax (const size_t)
 
void PrintPIDAValues ()
 
void setExponentConstant (float const &ex)
 
void SetPIDATree (TTree *, TH1F *, std::vector< TH1F * >)
 
void FillPIDATree (unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
 

Private Types

typedef struct pid::PIDAAlg::PIDAProperties PIDAProperties_t
 

Private Member Functions

void calculatePIDAMean ()
 
void calculatePIDASigma ()
 
void calculatePIDAIntegral (std::map< double, double > const &)
 
void ClearInternalData ()
 
void createKDEs ()
 
void createKDE (const size_t)
 
void calculatePIDAKDEMostProbable ()
 
void calculatePIDAKDEFullWidthHalfMax ()
 
void FillPIDAProperties (unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
 

Private Attributes

const float fPIDA_BOGUS
 
float fExponentConstant
 
float fMinResRange
 
float fMaxResRange
 
float fMaxPIDAValue
 
float fKDEEvalMaxSigma
 
float fKDEEvalStepSize
 
std::vector< float > fKDEBandwidths
 
std::vector< float > fpida_values
 
std::vector< float > fpida_errors
 
float fpida_mean
 
float fpida_sigma
 
float fpida_integral_dedx
 
float fpida_integral_pida
 
std::vector< float > fpida_kde_mp
 
std::vector< float > fpida_kde_fwhm
 
std::vector< float > fpida_kde_b
 
std::vector< std::vector< float > > fkde_distribution
 
std::vector< float > fkde_dist_min
 
std::vector< float > fkde_dist_max
 
util::NormalDistribution fnormalDist
 
TTree * fPIDATree
 
TH1F * hPIDAvalues
 
TH1F * hPIDAKDE [MAX_BANDWIDTHS]
 
unsigned int fPIDAHistNbins
 
float fPIDAHistMin
 
float fPIDAHistMax
 
PIDAProperties_t fPIDAProperties
 

Detailed Description

Definition at line 43 of file PIDAAlg.h.

Member Typedef Documentation

Constructor & Destructor Documentation

pid::PIDAAlg::PIDAAlg ( fhicl::ParameterSet const &  p)
inline

Definition at line 45 of file PIDAAlg.h.

45  :
46  fPIDA_BOGUS(-9999)
47  { this->reconfigure(p); }
void reconfigure(fhicl::ParameterSet const &p)
Definition: PIDAAlg.cxx:16
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75

Member Function Documentation

void pid::PIDAAlg::calculatePIDAIntegral ( std::map< double, double > const &  range_dEdx_map)
private

Definition at line 202 of file PIDAAlg.cxx.

References fExponentConstant, fpida_integral_dedx, and fpida_integral_pida.

Referenced by RunPIDAAlg().

202  {
203 
204  if(range_dEdx_map.size()<2) return;
205 
207 
208  for( std::map<double,double>::const_iterator map_iter = range_dEdx_map.begin();
209  map_iter != std::prev(range_dEdx_map.end());
210  map_iter++)
211  {
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));
214  }
215 
217  std::pow( (std::prev(range_dEdx_map.end())->first - range_dEdx_map.begin()->first),(fExponentConstant-1) );
218 }
float fpida_integral_pida
Definition: PIDAAlg.h:90
intermediate_table::const_iterator const_iterator
float fExponentConstant
Definition: PIDAAlg.h:77
float fpida_integral_dedx
Definition: PIDAAlg.h:89
void pid::PIDAAlg::calculatePIDAKDEFullWidthHalfMax ( )
private
void pid::PIDAAlg::calculatePIDAKDEMostProbable ( )
private
void pid::PIDAAlg::calculatePIDAMean ( )
private

Definition at line 178 of file PIDAAlg.cxx.

References fpida_mean, and fpida_values.

Referenced by calculatePIDASigma(), and getPIDAMean().

178  {
179 
180  if(fpida_values.size()==0)
181  throw "pid::PIDAAlg --- PIDA Values not filled!";
182 
183  fpida_mean = 0;
184  for(auto const& val : fpida_values)
185  fpida_mean += val;
186  fpida_mean /= fpida_values.size();
187 
188 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
float fpida_mean
Definition: PIDAAlg.h:87
void pid::PIDAAlg::calculatePIDASigma ( )
private

Definition at line 190 of file PIDAAlg.cxx.

References calculatePIDAMean(), fPIDA_BOGUS, fpida_mean, fpida_sigma, and fpida_values.

Referenced by createKDE(), FillPIDAProperties(), and getPIDASigma().

190  {
191 
194 
195  fpida_sigma = 0;
196  for(auto const& val : fpida_values)
197  fpida_sigma += (fpida_mean-val)*(fpida_mean-val);
198 
199  fpida_sigma = std::sqrt(fpida_sigma)/fpida_values.size();
200 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
float fpida_sigma
Definition: PIDAAlg.h:88
void calculatePIDAMean()
Definition: PIDAAlg.cxx:178
float fpida_mean
Definition: PIDAAlg.h:87
void pid::PIDAAlg::ClearInternalData ( )
private

Definition at line 35 of file PIDAAlg.cxx.

References fkde_dist_max, fkde_dist_min, fkde_distribution, fKDEBandwidths, fPIDA_BOGUS, fpida_errors, fpida_integral_dedx, fpida_integral_pida, fpida_kde_b, fpida_kde_fwhm, fpida_kde_mp, fpida_mean, fpida_sigma, and fpida_values.

Referenced by reconfigure(), and RunPIDAAlg().

35  {
40  fpida_values.clear();
41  fpida_errors.clear();
42 
43  fpida_kde_mp = std::vector<float>(fKDEBandwidths.size(),fPIDA_BOGUS);
44  fpida_kde_fwhm = std::vector<float>(fKDEBandwidths.size(),fPIDA_BOGUS);
45  fpida_kde_b = std::vector<float>(fKDEBandwidths.size(),fPIDA_BOGUS);
46  fkde_distribution = std::vector< std::vector<float> >(fKDEBandwidths.size());
47  fkde_dist_min = std::vector<float>(fKDEBandwidths.size(),fPIDA_BOGUS);
48  fkde_dist_max = std::vector<float>(fKDEBandwidths.size(),fPIDA_BOGUS);
49 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:86
float fpida_integral_pida
Definition: PIDAAlg.h:90
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:108
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:102
std::vector< float > fkde_dist_max
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:103
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
float fpida_sigma
Definition: PIDAAlg.h:88
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:104
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:107
float fpida_mean
Definition: PIDAAlg.h:87
float fpida_integral_dedx
Definition: PIDAAlg.h:89
void pid::PIDAAlg::createKDE ( const size_t  i_b)
private

Definition at line 220 of file PIDAAlg.cxx.

References calculatePIDASigma(), fkde_dist_max, fkde_dist_min, fkde_distribution, fKDEBandwidths, fKDEEvalMaxSigma, fKDEEvalStepSize, fnormalDist, fpida_errors, fpida_kde_b, fpida_kde_fwhm, fpida_kde_mp, fpida_sigma, fpida_values, and util::NormalDistribution::getValue().

Referenced by createKDEs(), getPIDAKDEFullWidthHalfMax(), and getPIDAKDEMostProbable().

220  {
221 
222  if(fpida_values.size()==0)
223  throw "pid::PIDAAlg --- PIDA Values not filled!";
224 
225  //if( fkde_distribution[i_b].size()!=0 ) return;
226 
227  if(fKDEBandwidths[i_b]<=0) {
229  float bandwidth = fpida_sigma*1.06*std::pow((float)(fpida_values.size()),-0.2);
230  fpida_errors = std::vector<float>(fpida_values.size(),bandwidth);
231  fpida_kde_b[i_b] = bandwidth;
232  }
233  else{
234  fpida_errors = std::vector<float>(fpida_values.size(),fKDEBandwidths[i_b]);
235  fpida_kde_b[i_b] = fKDEBandwidths[i_b];
236  }
237 
238  const auto min_pida_iterator = std::min_element(fpida_values.begin(),fpida_values.end());
239  const size_t min_pida_location = std::distance(fpida_values.begin(),min_pida_iterator);
240  fkde_dist_min[i_b] = fpida_values[min_pida_location] - fKDEEvalMaxSigma*fpida_errors[min_pida_location];
241 
242  const auto max_pida_iterator = std::max_element(fpida_values.begin(),fpida_values.end());
243  const size_t max_pida_location = std::distance(fpida_values.begin(),max_pida_iterator);
244  fkde_dist_max[i_b] = fpida_values[max_pida_location] + fKDEEvalMaxSigma*fpida_errors[max_pida_location];
245 
246  //make the kde distribution, and get the max value
247  const size_t kde_dist_size = (size_t)( (fkde_dist_max[i_b] - fkde_dist_min[i_b])/fKDEEvalStepSize ) + 1;
248  fkde_distribution[i_b].resize(kde_dist_size);
249  float kde_max=0;
250  size_t step_max=0;
251  for(size_t i_step=0; i_step<kde_dist_size; i_step++){
252  float pida_val = fkde_dist_min[i_b] + i_step*fKDEEvalStepSize;
253  fkde_distribution[i_b][i_step]=0;
254 
255  for(size_t i_pida=0; i_pida<fpida_values.size(); i_pida++)
256  fkde_distribution[i_b][i_step] += fnormalDist.getValue((fpida_values[i_pida]-pida_val)/fpida_errors[i_pida])/fpida_errors[i_pida];
257 
258  if(fkde_distribution[i_b][i_step]>kde_max){
259  kde_max = fkde_distribution[i_b][i_step];
260  step_max = i_step;
261  fpida_kde_mp[i_b] = pida_val;
262  }
263  }
264 
265  //now get fwhm
266  float half_max = 0.5*fpida_kde_mp[i_b];
267  float low_width=0;
268  for(size_t i_step=step_max; i_step>0; i_step--){
269  if(fkde_distribution[i_b][i_step] < half_max) break;
270  low_width += fKDEEvalStepSize;
271  }
272  float high_width=0;
273  for(size_t i_step=step_max; i_step<kde_dist_size; i_step++){
274  if(fkde_distribution[i_b][i_step] < half_max) break;
275  high_width += fKDEEvalStepSize;
276  }
277  fpida_kde_fwhm[i_b] = low_width+high_width;
278 
279 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:86
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:111
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:108
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:102
float fKDEEvalMaxSigma
Definition: PIDAAlg.h:81
float fKDEEvalStepSize
Definition: PIDAAlg.h:82
std::vector< float > fkde_dist_max
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:103
float getValue(float)
Definition: PIDAAlg.cxx:360
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
float fpida_sigma
Definition: PIDAAlg.h:88
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:104
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:107
void calculatePIDASigma()
Definition: PIDAAlg.cxx:190
void pid::PIDAAlg::createKDEs ( )
private

Definition at line 281 of file PIDAAlg.cxx.

References createKDE(), and fKDEBandwidths.

Referenced by FillPIDAProperties().

281  {
282  for(size_t i_b=0; i_b < fKDEBandwidths.size(); i_b++)
283  createKDE(i_b);
284 }
void createKDE(const size_t)
Definition: PIDAAlg.cxx:220
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
void pid::PIDAAlg::FillPIDAProperties ( unsigned int  run,
unsigned int  event,
unsigned int  calo_index,
anab::Calorimetry const &  calo 
)
private

Definition at line 286 of file PIDAAlg.cxx.

References calculatePIDASigma(), pid::PIDAAlg::PIDAProperties::calo_index, pid::PIDAAlg::PIDAProperties::calo_KE, createKDEs(), pid::PIDAAlg::PIDAProperties::event, fkde_dist_min, fkde_distribution, fKDEBandwidths, fKDEEvalStepSize, fpida_integral_dedx, fpida_integral_pida, fpida_kde_b, fpida_kde_fwhm, fpida_kde_mp, fpida_mean, fpida_sigma, fpida_values, fPIDAProperties, fPIDATree, hPIDAKDE, hPIDAvalues, pid::PIDAAlg::PIDAProperties::integral_dedx, pid::PIDAAlg::PIDAProperties::integral_pida, pid::PIDAAlg::PIDAProperties::kde_bandwidth, pid::PIDAAlg::PIDAProperties::kde_fwhm, pid::PIDAAlg::PIDAProperties::kde_mp, anab::Calorimetry::KineticEnergy(), pid::PIDAAlg::PIDAProperties::mean, pid::PIDAAlg::PIDAProperties::n_bandwidths, pid::PIDAAlg::PIDAProperties::n_pid_pts, geo::PlaneID::Plane, anab::Calorimetry::PlaneID(), pid::PIDAAlg::PIDAProperties::planeid, anab::Calorimetry::Range(), pid::PIDAAlg::PIDAProperties::run, pid::PIDAAlg::PIDAProperties::sigma, and pid::PIDAAlg::PIDAProperties::trk_range.

Referenced by FillPIDATree().

289  {
290 
291  fPIDAProperties.run = run;
293  fPIDAProperties.calo_index = calo_index;
294  fPIDAProperties.planeid = calo.PlaneID().Plane;
295  fPIDAProperties.trk_range = calo.Range();
296  fPIDAProperties.calo_KE = calo.KineticEnergy();
297 
299  for(size_t i_b=0; i_b<fPIDAProperties.n_bandwidths; i_b++)
300 
305 
308 
309  createKDEs();
310  for(size_t i_b=0; i_b<fPIDAProperties.n_bandwidths; i_b++){
311  fPIDAProperties.kde_mp[i_b] = fpida_kde_mp[i_b];
314  }
315 
316  hPIDAvalues->Reset();
317  for(auto const& val: fpida_values)
318  hPIDAvalues->Fill(val);
319 
320  for(size_t i_b=0; i_b<fPIDAProperties.n_bandwidths; i_b++){
321  hPIDAKDE[i_b]->Reset();
322  for(size_t i_step=0; i_step<fkde_distribution[i_b].size(); i_step++)
323  hPIDAKDE[i_b]->AddBinContent(hPIDAKDE[i_b]->FindBin(i_step*fKDEEvalStepSize+fkde_dist_min[i_b]),
324  fkde_distribution[i_b][i_step]);
325  }
326 
327  fPIDATree->Fill();
328 }
TH1F * hPIDAKDE[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:115
TH1F * hPIDAvalues
Definition: PIDAAlg.h:114
TTree * fPIDATree
Definition: PIDAAlg.h:113
float kde_bandwidth[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:134
float fpida_integral_pida
Definition: PIDAAlg.h:90
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:108
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:102
void createKDEs()
Definition: PIDAAlg.cxx:281
unsigned int n_bandwidths
Definition: PIDAAlg.h:133
float fKDEEvalStepSize
Definition: PIDAAlg.h:82
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:103
float kde_fwhm[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:136
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
float fpida_sigma
Definition: PIDAAlg.h:88
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:104
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:107
float fpida_mean
Definition: PIDAAlg.h:87
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:143
float fpida_integral_dedx
Definition: PIDAAlg.h:89
void calculatePIDASigma()
Definition: PIDAAlg.cxx:190
float kde_mp[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:135
calorimetry
Event finding and building.
void pid::PIDAAlg::FillPIDATree ( unsigned int  run,
unsigned int  event,
unsigned int  calo_index,
anab::Calorimetry const &  calo 
)

Definition at line 170 of file PIDAAlg.cxx.

References FillPIDAProperties(), and RunPIDAAlg().

Referenced by pid::PIDAAnalyzer::analyze().

173  {
174  RunPIDAAlg(calo);
175  FillPIDAProperties(run,event,calo_index,calo);
176 }
void FillPIDAProperties(unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
Definition: PIDAAlg.cxx:286
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:140
calorimetry
Event finding and building.
float pid::PIDAAlg::getKDEBandwidth ( const size_t  i_b)
inline

Definition at line 62 of file PIDAAlg.h.

62 { return fKDEBandwidths.at(i_b); }
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
size_t pid::PIDAAlg::getNKDEBandwidths ( )
inline

Definition at line 61 of file PIDAAlg.h.

Referenced by pid::PIDAAnalyzer::beginJob().

61 { return fKDEBandwidths.size(); }
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
const std::vector< float > & pid::PIDAAlg::getPIDAErrors ( )

Definition at line 121 of file PIDAAlg.cxx.

References fpida_errors.

121  {
122  return fpida_errors;
123 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:86
float pid::PIDAAlg::getPIDAKDEFullWidthHalfMax ( const size_t  i_b)

Definition at line 110 of file PIDAAlg.cxx.

References createKDE(), fPIDA_BOGUS, and fpida_kde_fwhm.

110  {
111  if(fpida_kde_fwhm[i_b]==fPIDA_BOGUS)
112  createKDE(i_b);
113 
114  return fpida_kde_fwhm[i_b];
115 }
void createKDE(const size_t)
Definition: PIDAAlg.cxx:220
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:103
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
float pid::PIDAAlg::getPIDAKDEMostProbable ( const size_t  i_b)

Definition at line 103 of file PIDAAlg.cxx.

References createKDE(), fPIDA_BOGUS, and fpida_kde_mp.

103  {
104  if(fpida_kde_mp[i_b]==fPIDA_BOGUS)
105  createKDE(i_b);
106 
107  return fpida_kde_mp[i_b];
108 }
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:102
void createKDE(const size_t)
Definition: PIDAAlg.cxx:220
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
float pid::PIDAAlg::getPIDAMean ( )

Definition at line 89 of file PIDAAlg.cxx.

References calculatePIDAMean(), fPIDA_BOGUS, and fpida_mean.

Referenced by RunPIDAAlg().

89  {
92 
93  return fpida_mean;
94 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
void calculatePIDAMean()
Definition: PIDAAlg.cxx:178
float fpida_mean
Definition: PIDAAlg.h:87
float pid::PIDAAlg::getPIDASigma ( )

Definition at line 96 of file PIDAAlg.cxx.

References calculatePIDASigma(), fPIDA_BOGUS, and fpida_sigma.

Referenced by RunPIDAAlg().

96  {
99 
100  return fpida_sigma;
101 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:75
float fpida_sigma
Definition: PIDAAlg.h:88
void calculatePIDASigma()
Definition: PIDAAlg.cxx:190
const std::vector< float > & pid::PIDAAlg::getPIDAValues ( )

Definition at line 117 of file PIDAAlg.cxx.

References fpida_values.

117  {
118  return fpida_values;
119 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
void pid::PIDAAlg::PrintPIDAValues ( )

Definition at line 330 of file PIDAAlg.cxx.

References fpida_values.

330  {
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;
333 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
void pid::PIDAAlg::reconfigure ( fhicl::ParameterSet const &  p)

Title: PIDA Algorithim Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov), based on ideas/code from Bruce Baller

Description: Algorithm that calculates the PIDA from a calorimetry object Input: anab::Calorimetry Output: PIDA information

Definition at line 16 of file PIDAAlg.cxx.

References ClearInternalData(), fExponentConstant, fKDEBandwidths, fKDEEvalMaxSigma, fKDEEvalStepSize, fMaxPIDAValue, fMaxResRange, fMinResRange, fnormalDist, fPIDAHistMax, fPIDAHistMin, fPIDAHistNbins, and fhicl::ParameterSet::get().

Referenced by pid::PIDAAnalyzer::reconfigure().

16  {
17  fExponentConstant = p.get<float>("ExponentConstant",0.42);
18  fMinResRange = p.get<float>("MinResRange",0);
19  fMaxResRange = p.get<float>("MaxResRange",30);
20  fMaxPIDAValue = p.get<float>("MaxPIDAValue",50);
21 
22  fKDEEvalMaxSigma = p.get<float>("KDEEvalMaxSigma",3);
23  fKDEEvalStepSize = p.get<float>("KDEEvalStepSize",0.01);
24  fKDEBandwidths = p.get< std::vector<float> >("KDEBandwidths");
25 
27 
28  fPIDAHistNbins = p.get<unsigned int>("PIDAHistNbins",100);
29  fPIDAHistMin = p.get<float>("PIDAHistMin",0.0);
30  fPIDAHistMax = p.get<float>("PIDAHistMax",50.0);
31 
33 }
float fPIDAHistMin
Definition: PIDAAlg.h:117
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:111
float fMaxPIDAValue
Definition: PIDAAlg.h:80
float fMinResRange
Definition: PIDAAlg.h:78
float fMaxResRange
Definition: PIDAAlg.h:79
float fKDEEvalMaxSigma
Definition: PIDAAlg.h:81
float fKDEEvalStepSize
Definition: PIDAAlg.h:82
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:116
float fPIDAHistMax
Definition: PIDAAlg.h:118
void ClearInternalData()
Definition: PIDAAlg.cxx:35
float fExponentConstant
Definition: PIDAAlg.h:77
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
void pid::PIDAAlg::RunPIDAAlg ( std::vector< float > const &  resRange,
std::vector< float > const &  dEdx 
)

Definition at line 140 of file PIDAAlg.cxx.

References calculatePIDAIntegral(), ClearInternalData(), fExponentConstant, fMaxPIDAValue, fMaxResRange, fMinResRange, fpida_errors, and fpida_values.

Referenced by FillPIDATree(), and RunPIDAAlg().

141  {
142 
144 
145  fpida_values.reserve( resRange.size() );
146  fpida_errors.reserve( resRange.size() );
147 
148  std::map<double,double> range_dEdx_map;
149 
150  for(size_t i_r=0; i_r<resRange.size(); i_r++){
151  if(resRange[i_r]>fMaxResRange || resRange[i_r]<fMinResRange) continue;
152 
153  range_dEdx_map[ resRange[i_r] ] = dEdx[i_r];
154 
155  float val = dEdx[i_r]*std::pow(resRange[i_r],fExponentConstant);
156  if(val < fMaxPIDAValue){
157  fpida_values.push_back(val);
158  //fpida_errors.push_back(0);
159  }
160 
161  }
162 
163  calculatePIDAIntegral(range_dEdx_map);
164 
165  if(fpida_values.size()==0)
166  fpida_values.push_back(-99);
167 
168 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:86
float fMaxPIDAValue
Definition: PIDAAlg.h:80
float fMinResRange
Definition: PIDAAlg.h:78
float fMaxResRange
Definition: PIDAAlg.h:79
std::vector< float > fpida_values
Definition: PIDAAlg.h:85
void ClearInternalData()
Definition: PIDAAlg.cxx:35
void calculatePIDAIntegral(std::map< double, double > const &)
Definition: PIDAAlg.cxx:202
float fExponentConstant
Definition: PIDAAlg.h:77
void pid::PIDAAlg::RunPIDAAlg ( anab::Calorimetry const &  calo)

Definition at line 125 of file PIDAAlg.cxx.

References anab::Calorimetry::dEdx(), anab::Calorimetry::ResidualRange(), and RunPIDAAlg().

125  {
126  std::vector<float> const& resRange = calo.ResidualRange();
127  std::vector<float> const& dEdx = calo.dEdx();
128  RunPIDAAlg(resRange,dEdx);
129 }
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:140
calorimetry
void pid::PIDAAlg::RunPIDAAlg ( anab::Calorimetry const &  calo,
float &  mean,
float &  sigma 
)

Definition at line 131 of file PIDAAlg.cxx.

References getPIDAMean(), getPIDASigma(), and RunPIDAAlg().

134 {
135  RunPIDAAlg(calo);
136  mean = getPIDAMean();
137  sigma = getPIDASigma();
138 }
float getPIDAMean()
Definition: PIDAAlg.cxx:89
float getPIDASigma()
Definition: PIDAAlg.cxx:96
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:140
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
calorimetry
void pid::PIDAAlg::setExponentConstant ( float const &  ex)
inline

Definition at line 68 of file PIDAAlg.h.

68 { fExponentConstant = ex; }
float fExponentConstant
Definition: PIDAAlg.h:77
void pid::PIDAAlg::SetPIDATree ( TTree *  tree,
TH1F *  hist_vals,
std::vector< TH1F * >  hist_kde 
)

Definition at line 51 of file PIDAAlg.cxx.

References fKDEBandwidths, fPIDAHistMax, fPIDAHistMin, fPIDAHistNbins, fPIDAProperties, fPIDATree, hPIDAKDE, hPIDAvalues, pid::PIDAAlg::PIDAProperties::kde_bandwidth, pid::PIDAAlg::PIDAProperties::kde_fwhm, pid::PIDAAlg::PIDAProperties::kde_mp, pid::PIDAAlg::PIDAProperties::leaf_structure, MAX_BANDWIDTHS, and pid::PIDAAlg::PIDAProperties::n_bandwidths.

Referenced by pid::PIDAAnalyzer::beginJob().

51  {
52 
53  if(hist_kde.size()>MAX_BANDWIDTHS)
54  throw "Error: input histograms larger than max allowed bandwidths.";
55  if(hist_kde.size()!=fKDEBandwidths.size())
56  throw "Error: input histograms do not have same size as bandwidths.";
57 
58  fPIDATree = tree;
59 
60  hPIDAvalues = hist_vals;
61  hPIDAvalues->SetNameTitle("hPIDAvalues","PIDA Distribution");
63 
64  for(size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
65  hPIDAKDE[i_hist] = hist_kde[i_hist];
66 
67  std::stringstream hname,htitle;
68  hname << "hPIDAKDE_" << i_hist;
69  htitle << "PIDA KDE-smoothed Distribution, Bandwidth=" << fKDEBandwidths.at(i_hist);
70 
71  hPIDAKDE[i_hist]->SetNameTitle(hname.str().c_str(),htitle.str().c_str());
73  }
74 
76  fPIDATree->Branch("hpida_vals","TH1F",hPIDAvalues);
77  fPIDATree->Branch("n_bandwidths",&(fPIDAProperties.n_bandwidths),"n_bandwidths/i");
78  fPIDATree->Branch("kde_bandwidth",fPIDAProperties.kde_bandwidth,"kde_bandwidth[n_bandwidths]/F");
79  fPIDATree->Branch("kde_mp",fPIDAProperties.kde_mp,"kde_mp[n_bandwidths]/F");
80  fPIDATree->Branch("kde_fwhm",fPIDAProperties.kde_fwhm,"kde_fwhm[n_bandwidths]/F");
81  for(size_t i_hist=0; i_hist<hist_kde.size(); i_hist++){
82  std::stringstream bname;
83  bname << "hpida_kde_" << i_hist;
84  fPIDATree->Branch(bname.str().c_str(),"TH1F",hPIDAKDE[i_hist]);
85  }
86 
87 }
TH1F * hPIDAKDE[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:115
TH1F * hPIDAvalues
Definition: PIDAAlg.h:114
std::string leaf_structure
Definition: PIDAAlg.h:138
float fPIDAHistMin
Definition: PIDAAlg.h:117
TTree * fPIDATree
Definition: PIDAAlg.h:113
float kde_bandwidth[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:134
unsigned int n_bandwidths
Definition: PIDAAlg.h:133
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:116
float kde_fwhm[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:136
float fPIDAHistMax
Definition: PIDAAlg.h:118
const unsigned int MAX_BANDWIDTHS
Definition: PIDAAlg.h:41
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:83
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:143
float kde_mp[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:135

Member Data Documentation

float pid::PIDAAlg::fExponentConstant
private

Definition at line 77 of file PIDAAlg.h.

Referenced by calculatePIDAIntegral(), reconfigure(), and RunPIDAAlg().

std::vector<float> pid::PIDAAlg::fkde_dist_max
private

Definition at line 109 of file PIDAAlg.h.

Referenced by ClearInternalData(), and createKDE().

std::vector<float> pid::PIDAAlg::fkde_dist_min
private

Definition at line 108 of file PIDAAlg.h.

Referenced by ClearInternalData(), createKDE(), and FillPIDAProperties().

std::vector< std::vector<float> > pid::PIDAAlg::fkde_distribution
private

Definition at line 107 of file PIDAAlg.h.

Referenced by ClearInternalData(), createKDE(), and FillPIDAProperties().

std::vector<float> pid::PIDAAlg::fKDEBandwidths
private
float pid::PIDAAlg::fKDEEvalMaxSigma
private

Definition at line 81 of file PIDAAlg.h.

Referenced by createKDE(), and reconfigure().

float pid::PIDAAlg::fKDEEvalStepSize
private

Definition at line 82 of file PIDAAlg.h.

Referenced by createKDE(), FillPIDAProperties(), and reconfigure().

float pid::PIDAAlg::fMaxPIDAValue
private

Definition at line 80 of file PIDAAlg.h.

Referenced by reconfigure(), and RunPIDAAlg().

float pid::PIDAAlg::fMaxResRange
private

Definition at line 79 of file PIDAAlg.h.

Referenced by reconfigure(), and RunPIDAAlg().

float pid::PIDAAlg::fMinResRange
private

Definition at line 78 of file PIDAAlg.h.

Referenced by reconfigure(), and RunPIDAAlg().

util::NormalDistribution pid::PIDAAlg::fnormalDist
private

Definition at line 111 of file PIDAAlg.h.

Referenced by createKDE(), and reconfigure().

const float pid::PIDAAlg::fPIDA_BOGUS
private
std::vector<float> pid::PIDAAlg::fpida_errors
private

Definition at line 86 of file PIDAAlg.h.

Referenced by ClearInternalData(), createKDE(), getPIDAErrors(), and RunPIDAAlg().

float pid::PIDAAlg::fpida_integral_dedx
private

Definition at line 89 of file PIDAAlg.h.

Referenced by calculatePIDAIntegral(), ClearInternalData(), and FillPIDAProperties().

float pid::PIDAAlg::fpida_integral_pida
private

Definition at line 90 of file PIDAAlg.h.

Referenced by calculatePIDAIntegral(), ClearInternalData(), and FillPIDAProperties().

std::vector<float> pid::PIDAAlg::fpida_kde_b
private

Definition at line 104 of file PIDAAlg.h.

Referenced by ClearInternalData(), createKDE(), and FillPIDAProperties().

std::vector<float> pid::PIDAAlg::fpida_kde_fwhm
private
std::vector<float> pid::PIDAAlg::fpida_kde_mp
private
float pid::PIDAAlg::fpida_mean
private
float pid::PIDAAlg::fpida_sigma
private
std::vector<float> pid::PIDAAlg::fpida_values
private
float pid::PIDAAlg::fPIDAHistMax
private

Definition at line 118 of file PIDAAlg.h.

Referenced by reconfigure(), and SetPIDATree().

float pid::PIDAAlg::fPIDAHistMin
private

Definition at line 117 of file PIDAAlg.h.

Referenced by reconfigure(), and SetPIDATree().

unsigned int pid::PIDAAlg::fPIDAHistNbins
private

Definition at line 116 of file PIDAAlg.h.

Referenced by reconfigure(), and SetPIDATree().

PIDAProperties_t pid::PIDAAlg::fPIDAProperties
private

Definition at line 143 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

TTree* pid::PIDAAlg::fPIDATree
private

Definition at line 113 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

TH1F* pid::PIDAAlg::hPIDAKDE[MAX_BANDWIDTHS]
private

Definition at line 115 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

TH1F* pid::PIDAAlg::hPIDAvalues
private

Definition at line 114 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().


The documentation for this class was generated from the following files: