LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pid::PIDAAlg Class Reference

#include "PIDAAlg.h"

Classes

struct  PIDAProperties
 

Public Member Functions

 PIDAAlg (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 50 of file PIDAAlg.h.

Member Typedef Documentation

Constructor & Destructor Documentation

pid::PIDAAlg::PIDAAlg ( 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 24 of file PIDAAlg.cxx.

References ClearInternalData().

25  : fPIDA_BOGUS(-9999)
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))
32  , fKDEBandwidths(p.get<std::vector<float>>("KDEBandwidths"))
34  , fPIDAHistNbins(p.get<unsigned int>("PIDAHistNbins", 100))
35  , fPIDAHistMin(p.get<float>("PIDAHistMin", 0.0))
36  , fPIDAHistMax(p.get<float>("PIDAHistMax", 50.0))
37 {
39 }
float fPIDAHistMin
Definition: PIDAAlg.h:119
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:113
float fMaxPIDAValue
Definition: PIDAAlg.h:82
float fMinResRange
Definition: PIDAAlg.h:80
float fMaxResRange
Definition: PIDAAlg.h:81
float fKDEEvalMaxSigma
Definition: PIDAAlg.h:83
float fKDEEvalStepSize
Definition: PIDAAlg.h:84
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:118
float fPIDAHistMax
Definition: PIDAAlg.h:120
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
void ClearInternalData()
Definition: PIDAAlg.cxx:41
float fExponentConstant
Definition: PIDAAlg.h:79
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85

Member Function Documentation

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

Definition at line 208 of file PIDAAlg.cxx.

References fExponentConstant, fpida_integral_dedx, and fpida_integral_pida.

Referenced by RunPIDAAlg().

209 {
210 
211  if (range_dEdx_map.size() < 2) return;
212 
214 
215  for (std::map<double, double>::const_iterator map_iter = range_dEdx_map.begin();
216  map_iter != std::prev(range_dEdx_map.end());
217  map_iter++) {
218  double range_width = std::next(map_iter)->first - map_iter->first;
219  fpida_integral_dedx += range_width * (std::next(map_iter)->second +
220  0.5 * (map_iter->second - std::next(map_iter)->second));
221  }
222 
225  std::pow((std::prev(range_dEdx_map.end())->first - range_dEdx_map.begin()->first),
226  (fExponentConstant - 1));
227 }
float fpida_integral_pida
Definition: PIDAAlg.h:92
intermediate_table::const_iterator const_iterator
float fExponentConstant
Definition: PIDAAlg.h:79
float fpida_integral_dedx
Definition: PIDAAlg.h:91
void pid::PIDAAlg::calculatePIDAKDEFullWidthHalfMax ( )
private
void pid::PIDAAlg::calculatePIDAKDEMostProbable ( )
private
void pid::PIDAAlg::calculatePIDAMean ( )
private

Definition at line 185 of file PIDAAlg.cxx.

References fpida_mean, and fpida_values.

Referenced by calculatePIDASigma(), and getPIDAMean().

186 {
187 
188  if (fpida_values.size() == 0) throw "pid::PIDAAlg --- PIDA Values not filled!";
189 
190  fpida_mean = 0;
191  for (auto const& val : fpida_values)
192  fpida_mean += val;
193  fpida_mean /= fpida_values.size();
194 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
float fpida_mean
Definition: PIDAAlg.h:89
void pid::PIDAAlg::calculatePIDASigma ( )
private

Definition at line 196 of file PIDAAlg.cxx.

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

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

197 {
198 
200 
201  fpida_sigma = 0;
202  for (auto const& val : fpida_values)
203  fpida_sigma += (fpida_mean - val) * (fpida_mean - val);
204 
205  fpida_sigma = std::sqrt(fpida_sigma) / fpida_values.size();
206 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
float fpida_sigma
Definition: PIDAAlg.h:90
void calculatePIDAMean()
Definition: PIDAAlg.cxx:185
float fpida_mean
Definition: PIDAAlg.h:89
void pid::PIDAAlg::ClearInternalData ( )
private

Definition at line 41 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 PIDAAlg(), and RunPIDAAlg().

42 {
47  fpida_values.clear();
48  fpida_errors.clear();
49 
50  fpida_kde_mp = std::vector<float>(fKDEBandwidths.size(), fPIDA_BOGUS);
51  fpida_kde_fwhm = std::vector<float>(fKDEBandwidths.size(), fPIDA_BOGUS);
52  fpida_kde_b = std::vector<float>(fKDEBandwidths.size(), fPIDA_BOGUS);
53  fkde_distribution = std::vector<std::vector<float>>(fKDEBandwidths.size());
54  fkde_dist_min = std::vector<float>(fKDEBandwidths.size(), fPIDA_BOGUS);
55  fkde_dist_max = std::vector<float>(fKDEBandwidths.size(), fPIDA_BOGUS);
56 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:88
float fpida_integral_pida
Definition: PIDAAlg.h:92
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:110
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:104
std::vector< float > fkde_dist_max
Definition: PIDAAlg.h:111
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:105
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
float fpida_sigma
Definition: PIDAAlg.h:90
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:106
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
float fpida_mean
Definition: PIDAAlg.h:89
float fpida_integral_dedx
Definition: PIDAAlg.h:91
void pid::PIDAAlg::createKDE ( const size_t  i_b)
private

Definition at line 229 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().

230 {
231 
232  if (fpida_values.size() == 0) throw "pid::PIDAAlg --- PIDA Values not filled!";
233 
234  //if( fkde_distribution[i_b].size()!=0 ) return;
235 
236  if (fKDEBandwidths[i_b] <= 0) {
238  float bandwidth = fpida_sigma * 1.06 * std::pow((float)(fpida_values.size()), -0.2);
239  fpida_errors = std::vector<float>(fpida_values.size(), bandwidth);
240  fpida_kde_b[i_b] = bandwidth;
241  }
242  else {
243  fpida_errors = std::vector<float>(fpida_values.size(), fKDEBandwidths[i_b]);
244  fpida_kde_b[i_b] = fKDEBandwidths[i_b];
245  }
246 
247  const auto min_pida_iterator = std::min_element(fpida_values.begin(), fpida_values.end());
248  const size_t min_pida_location = std::distance(fpida_values.begin(), min_pida_iterator);
249  fkde_dist_min[i_b] =
250  fpida_values[min_pida_location] - fKDEEvalMaxSigma * fpida_errors[min_pida_location];
251 
252  const auto max_pida_iterator = std::max_element(fpida_values.begin(), fpida_values.end());
253  const size_t max_pida_location = std::distance(fpida_values.begin(), max_pida_iterator);
254  fkde_dist_max[i_b] =
255  fpida_values[max_pida_location] + fKDEEvalMaxSigma * fpida_errors[max_pida_location];
256 
257  //make the kde distribution, and get the max value
258  const size_t kde_dist_size =
259  (size_t)((fkde_dist_max[i_b] - fkde_dist_min[i_b]) / fKDEEvalStepSize) + 1;
260  fkde_distribution[i_b].resize(kde_dist_size);
261  float kde_max = 0;
262  size_t step_max = 0;
263  for (size_t i_step = 0; i_step < kde_dist_size; i_step++) {
264  float pida_val = fkde_dist_min[i_b] + i_step * fKDEEvalStepSize;
265  fkde_distribution[i_b][i_step] = 0;
266 
267  for (size_t i_pida = 0; i_pida < fpida_values.size(); i_pida++)
268  fkde_distribution[i_b][i_step] +=
269  fnormalDist.getValue((fpida_values[i_pida] - pida_val) / fpida_errors[i_pida]) /
270  fpida_errors[i_pida];
271 
272  if (fkde_distribution[i_b][i_step] > kde_max) {
273  kde_max = fkde_distribution[i_b][i_step];
274  step_max = i_step;
275  fpida_kde_mp[i_b] = pida_val;
276  }
277  }
278 
279  //now get fwhm
280  float half_max = 0.5 * fpida_kde_mp[i_b];
281  float low_width = 0;
282  for (size_t i_step = step_max; i_step > 0; i_step--) {
283  if (fkde_distribution[i_b][i_step] < half_max) break;
284  low_width += fKDEEvalStepSize;
285  }
286  float high_width = 0;
287  for (size_t i_step = step_max; i_step < kde_dist_size; i_step++) {
288  if (fkde_distribution[i_b][i_step] < half_max) break;
289  high_width += fKDEEvalStepSize;
290  }
291  fpida_kde_fwhm[i_b] = low_width + high_width;
292 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:88
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:113
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:110
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:104
float fKDEEvalMaxSigma
Definition: PIDAAlg.h:83
float fKDEEvalStepSize
Definition: PIDAAlg.h:84
std::vector< float > fkde_dist_max
Definition: PIDAAlg.h:111
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:105
float getValue(float)
Definition: PIDAAlg.cxx:376
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
float fpida_sigma
Definition: PIDAAlg.h:90
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:106
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
void calculatePIDASigma()
Definition: PIDAAlg.cxx:196
void pid::PIDAAlg::createKDEs ( )
private

Definition at line 294 of file PIDAAlg.cxx.

References createKDE(), and fKDEBandwidths.

Referenced by FillPIDAProperties().

295 {
296  for (size_t i_b = 0; i_b < fKDEBandwidths.size(); i_b++)
297  createKDE(i_b);
298 }
void createKDE(const size_t)
Definition: PIDAAlg.cxx:229
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
void pid::PIDAAlg::FillPIDAProperties ( unsigned int  run,
unsigned int  event,
unsigned int  calo_index,
anab::Calorimetry const &  calo 
)
private

Definition at line 300 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().

304 {
305 
306  fPIDAProperties.run = run;
308  fPIDAProperties.calo_index = calo_index;
309  fPIDAProperties.planeid = calo.PlaneID().Plane;
310  fPIDAProperties.trk_range = calo.Range();
311  fPIDAProperties.calo_KE = calo.KineticEnergy();
312 
314  for (size_t i_b = 0; i_b < fPIDAProperties.n_bandwidths; i_b++)
315 
320 
323 
324  createKDEs();
325  for (size_t i_b = 0; i_b < fPIDAProperties.n_bandwidths; i_b++) {
326  fPIDAProperties.kde_mp[i_b] = fpida_kde_mp[i_b];
329  }
330 
331  hPIDAvalues->Reset();
332  for (auto const& val : fpida_values)
333  hPIDAvalues->Fill(val);
334 
335  for (size_t i_b = 0; i_b < fPIDAProperties.n_bandwidths; i_b++) {
336  hPIDAKDE[i_b]->Reset();
337  for (size_t i_step = 0; i_step < fkde_distribution[i_b].size(); i_step++)
338  hPIDAKDE[i_b]->AddBinContent(
339  hPIDAKDE[i_b]->FindBin(i_step * fKDEEvalStepSize + fkde_dist_min[i_b]),
340  fkde_distribution[i_b][i_step]);
341  }
342 
343  fPIDATree->Fill();
344 }
TH1F * hPIDAKDE[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:117
TH1F * hPIDAvalues
Definition: PIDAAlg.h:116
TTree * fPIDATree
Definition: PIDAAlg.h:115
float kde_bandwidth[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:136
float fpida_integral_pida
Definition: PIDAAlg.h:92
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:110
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:104
void createKDEs()
Definition: PIDAAlg.cxx:294
unsigned int n_bandwidths
Definition: PIDAAlg.h:135
float fKDEEvalStepSize
Definition: PIDAAlg.h:84
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:105
float kde_fwhm[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:138
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
float fpida_sigma
Definition: PIDAAlg.h:90
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:106
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
float fpida_mean
Definition: PIDAAlg.h:89
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:147
float fpida_integral_dedx
Definition: PIDAAlg.h:91
void calculatePIDASigma()
Definition: PIDAAlg.cxx:196
float kde_mp[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:137
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 176 of file PIDAAlg.cxx.

References FillPIDAProperties(), and RunPIDAAlg().

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

180 {
181  RunPIDAAlg(calo);
182  FillPIDAProperties(run, event, calo_index, calo);
183 }
void FillPIDAProperties(unsigned int, unsigned int, unsigned int, anab::Calorimetry const &)
Definition: PIDAAlg.cxx:300
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:149
calorimetry
Event finding and building.
float pid::PIDAAlg::getKDEBandwidth ( const size_t  i_b)
inline

Definition at line 65 of file PIDAAlg.h.

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

Definition at line 64 of file PIDAAlg.h.

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

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

Definition at line 130 of file PIDAAlg.cxx.

References fpida_errors.

131 {
132  return fpida_errors;
133 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:88
float pid::PIDAAlg::getPIDAKDEFullWidthHalfMax ( const size_t  i_b)

Definition at line 118 of file PIDAAlg.cxx.

References createKDE(), fPIDA_BOGUS, and fpida_kde_fwhm.

119 {
120  if (fpida_kde_fwhm[i_b] == fPIDA_BOGUS) createKDE(i_b);
121 
122  return fpida_kde_fwhm[i_b];
123 }
void createKDE(const size_t)
Definition: PIDAAlg.cxx:229
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:105
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
float pid::PIDAAlg::getPIDAKDEMostProbable ( const size_t  i_b)

Definition at line 111 of file PIDAAlg.cxx.

References createKDE(), fPIDA_BOGUS, and fpida_kde_mp.

112 {
113  if (fpida_kde_mp[i_b] == fPIDA_BOGUS) createKDE(i_b);
114 
115  return fpida_kde_mp[i_b];
116 }
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:104
void createKDE(const size_t)
Definition: PIDAAlg.cxx:229
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
float pid::PIDAAlg::getPIDAMean ( )

Definition at line 97 of file PIDAAlg.cxx.

References calculatePIDAMean(), fPIDA_BOGUS, and fpida_mean.

Referenced by RunPIDAAlg().

98 {
100 
101  return fpida_mean;
102 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
void calculatePIDAMean()
Definition: PIDAAlg.cxx:185
float fpida_mean
Definition: PIDAAlg.h:89
float pid::PIDAAlg::getPIDASigma ( )

Definition at line 104 of file PIDAAlg.cxx.

References calculatePIDASigma(), fPIDA_BOGUS, and fpida_sigma.

Referenced by RunPIDAAlg().

105 {
107 
108  return fpida_sigma;
109 }
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
float fpida_sigma
Definition: PIDAAlg.h:90
void calculatePIDASigma()
Definition: PIDAAlg.cxx:196
const std::vector< float > & pid::PIDAAlg::getPIDAValues ( )

Definition at line 125 of file PIDAAlg.cxx.

References fpida_values.

126 {
127  return fpida_values;
128 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
void pid::PIDAAlg::PrintPIDAValues ( )

Definition at line 346 of file PIDAAlg.cxx.

References fpida_values.

347 {
348  for (size_t i_pida = 0; i_pida < fpida_values.size(); i_pida++)
349  std::cout << "\tPIDA --- " << i_pida << "\t" << fpida_values[i_pida] << std::endl;
350 }
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
void pid::PIDAAlg::RunPIDAAlg ( std::vector< float > const &  resRange,
std::vector< float > const &  dEdx 
)

Definition at line 149 of file PIDAAlg.cxx.

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

Referenced by FillPIDATree(), and RunPIDAAlg().

150 {
151 
153 
154  fpida_values.reserve(resRange.size());
155  fpida_errors.reserve(resRange.size());
156 
157  std::map<double, double> range_dEdx_map;
158 
159  for (size_t i_r = 0; i_r < resRange.size(); i_r++) {
160  if (resRange[i_r] > fMaxResRange || resRange[i_r] < fMinResRange) continue;
161 
162  range_dEdx_map[resRange[i_r]] = dEdx[i_r];
163 
164  float val = dEdx[i_r] * std::pow(resRange[i_r], fExponentConstant);
165  if (val < fMaxPIDAValue) {
166  fpida_values.push_back(val);
167  //fpida_errors.push_back(0);
168  }
169  }
170 
171  calculatePIDAIntegral(range_dEdx_map);
172 
173  if (fpida_values.size() == 0) fpida_values.push_back(-99);
174 }
std::vector< float > fpida_errors
Definition: PIDAAlg.h:88
float fMaxPIDAValue
Definition: PIDAAlg.h:82
float fMinResRange
Definition: PIDAAlg.h:80
float fMaxResRange
Definition: PIDAAlg.h:81
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
void ClearInternalData()
Definition: PIDAAlg.cxx:41
void calculatePIDAIntegral(std::map< double, double > const &)
Definition: PIDAAlg.cxx:208
float fExponentConstant
Definition: PIDAAlg.h:79
void pid::PIDAAlg::RunPIDAAlg ( anab::Calorimetry const &  calo)

Definition at line 135 of file PIDAAlg.cxx.

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

136 {
137  std::vector<float> const& resRange = calo.ResidualRange();
138  std::vector<float> const& dEdx = calo.dEdx();
139  RunPIDAAlg(resRange, dEdx);
140 }
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:149
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
calorimetry
void pid::PIDAAlg::RunPIDAAlg ( anab::Calorimetry const &  calo,
float &  mean,
float &  sigma 
)

Definition at line 142 of file PIDAAlg.cxx.

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

143 {
144  RunPIDAAlg(calo);
145  mean = getPIDAMean();
146  sigma = getPIDASigma();
147 }
float getPIDAMean()
Definition: PIDAAlg.cxx:97
float getPIDASigma()
Definition: PIDAAlg.cxx:104
void RunPIDAAlg(std::vector< float > const &, std::vector< float > const &)
Definition: PIDAAlg.cxx:149
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
calorimetry
void pid::PIDAAlg::setExponentConstant ( float const &  ex)
inline

Definition at line 71 of file PIDAAlg.h.

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

Definition at line 58 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().

59 {
60 
61  if (hist_kde.size() > MAX_BANDWIDTHS)
62  throw "Error: input histograms larger than max allowed bandwidths.";
63  if (hist_kde.size() != fKDEBandwidths.size())
64  throw "Error: input histograms do not have same size as bandwidths.";
65 
66  fPIDATree = tree;
67 
68  hPIDAvalues = hist_vals;
69  hPIDAvalues->SetNameTitle("hPIDAvalues", "PIDA Distribution");
71 
72  for (size_t i_hist = 0; i_hist < hist_kde.size(); i_hist++) {
73  hPIDAKDE[i_hist] = hist_kde[i_hist];
74 
75  std::stringstream hname, htitle;
76  hname << "hPIDAKDE_" << i_hist;
77  htitle << "PIDA KDE-smoothed Distribution, Bandwidth=" << fKDEBandwidths.at(i_hist);
78 
79  hPIDAKDE[i_hist]->SetNameTitle(hname.str().c_str(), htitle.str().c_str());
81  }
82 
83  fPIDATree->Branch("pida", &fPIDAProperties, fPIDAProperties.leaf_structure.c_str());
84  fPIDATree->Branch("hpida_vals", "TH1F", hPIDAvalues);
85  fPIDATree->Branch("n_bandwidths", &(fPIDAProperties.n_bandwidths), "n_bandwidths/i");
86  fPIDATree->Branch(
87  "kde_bandwidth", fPIDAProperties.kde_bandwidth, "kde_bandwidth[n_bandwidths]/F");
88  fPIDATree->Branch("kde_mp", fPIDAProperties.kde_mp, "kde_mp[n_bandwidths]/F");
89  fPIDATree->Branch("kde_fwhm", fPIDAProperties.kde_fwhm, "kde_fwhm[n_bandwidths]/F");
90  for (size_t i_hist = 0; i_hist < hist_kde.size(); i_hist++) {
91  std::stringstream bname;
92  bname << "hpida_kde_" << i_hist;
93  fPIDATree->Branch(bname.str().c_str(), "TH1F", hPIDAKDE[i_hist]);
94  }
95 }
TH1F * hPIDAKDE[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:117
TH1F * hPIDAvalues
Definition: PIDAAlg.h:116
std::string leaf_structure
Definition: PIDAAlg.h:140
float fPIDAHistMin
Definition: PIDAAlg.h:119
TTree * fPIDATree
Definition: PIDAAlg.h:115
float kde_bandwidth[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:136
unsigned int n_bandwidths
Definition: PIDAAlg.h:135
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:118
float kde_fwhm[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:138
float fPIDAHistMax
Definition: PIDAAlg.h:120
const unsigned int MAX_BANDWIDTHS
Definition: PIDAAlg.h:48
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:147
float kde_mp[MAX_BANDWIDTHS]
Definition: PIDAAlg.h:137

Member Data Documentation

float pid::PIDAAlg::fExponentConstant
private

Definition at line 79 of file PIDAAlg.h.

Referenced by calculatePIDAIntegral(), and RunPIDAAlg().

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

Definition at line 111 of file PIDAAlg.h.

Referenced by ClearInternalData(), and createKDE().

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

Definition at line 110 of file PIDAAlg.h.

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

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

Definition at line 109 of file PIDAAlg.h.

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

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

Definition at line 85 of file PIDAAlg.h.

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

float pid::PIDAAlg::fKDEEvalMaxSigma
private

Definition at line 83 of file PIDAAlg.h.

Referenced by createKDE().

float pid::PIDAAlg::fKDEEvalStepSize
private

Definition at line 84 of file PIDAAlg.h.

Referenced by createKDE(), and FillPIDAProperties().

float pid::PIDAAlg::fMaxPIDAValue
private

Definition at line 82 of file PIDAAlg.h.

Referenced by RunPIDAAlg().

float pid::PIDAAlg::fMaxResRange
private

Definition at line 81 of file PIDAAlg.h.

Referenced by RunPIDAAlg().

float pid::PIDAAlg::fMinResRange
private

Definition at line 80 of file PIDAAlg.h.

Referenced by RunPIDAAlg().

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

Definition at line 113 of file PIDAAlg.h.

Referenced by createKDE().

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

Definition at line 88 of file PIDAAlg.h.

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

float pid::PIDAAlg::fpida_integral_dedx
private

Definition at line 91 of file PIDAAlg.h.

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

float pid::PIDAAlg::fpida_integral_pida
private

Definition at line 92 of file PIDAAlg.h.

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

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

Definition at line 106 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 120 of file PIDAAlg.h.

Referenced by SetPIDATree().

float pid::PIDAAlg::fPIDAHistMin
private

Definition at line 119 of file PIDAAlg.h.

Referenced by SetPIDATree().

unsigned int pid::PIDAAlg::fPIDAHistNbins
private

Definition at line 118 of file PIDAAlg.h.

Referenced by SetPIDATree().

PIDAProperties_t pid::PIDAAlg::fPIDAProperties
private

Definition at line 147 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

TTree* pid::PIDAAlg::fPIDATree
private

Definition at line 115 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

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

Definition at line 117 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().

TH1F* pid::PIDAAlg::hPIDAvalues
private

Definition at line 116 of file PIDAAlg.h.

Referenced by FillPIDAProperties(), and SetPIDATree().


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