PIDAAlg.h
Go to the documentation of this file.
1 #ifndef PIDAALG_H
2 #define PIDAALG_H
3 /*!
4  * Title: PIDA Algorithim Class
5  * Author: Wes Ketchum (wketchum@lanl.gov), based on ideas/code from Bruce Baller
6  *
7  * Description: Algorithm that calculates the PIDA from a calorimetry object
8  * Input: anab::Calorimetry
9  * Output: PIDA information
10 */
11 
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 #include "fhiclcpp/fwd.h"
17 namespace anab { class Calorimetry; }
18 
19 class TH1F;
20 class TTree;
21 
22 namespace util{
23  class NormalDistribution;
24 }
25 
27 
28  public:
30  NormalDistribution(float,float);
31 
32  float getValue(float);
33 
34  private:
35  float fStepSize;
36  float fMaxSigma;
37  std::vector<float> fValues;
38 
39 
40 };
41 
42 namespace pid{
43  class PIDAAlg;
44 }
45 
46 const unsigned int MAX_BANDWIDTHS=100;
47 
49  public:
51 
52  void RunPIDAAlg(std::vector<float> const&, std::vector<float> const&);
53  void RunPIDAAlg(anab::Calorimetry const&);
54  void RunPIDAAlg(anab::Calorimetry const&, float&, float&);
55 
56  float getPIDAMean();
57  float getPIDASigma();
58 
59  const std::vector<float>& getPIDAValues();
60  const std::vector<float>& getPIDAErrors();
61 
62  size_t getNKDEBandwidths() { return fKDEBandwidths.size(); }
63  float getKDEBandwidth(const size_t i_b) { return fKDEBandwidths.at(i_b); }
64  float getPIDAKDEMostProbable(const size_t);
65  float getPIDAKDEFullWidthHalfMax(const size_t);
66 
67  void PrintPIDAValues();
68 
69  void setExponentConstant(float const& ex) { fExponentConstant = ex; }
70 
71  void SetPIDATree(TTree*,TH1F*,std::vector<TH1F*>);
72  void FillPIDATree(unsigned int, unsigned int, unsigned int, anab::Calorimetry const&);
73 
74  private:
75 
76  const float fPIDA_BOGUS;
77 
79  float fMinResRange;
80  float fMaxResRange;
84  std::vector<float> fKDEBandwidths;
85 
86  std::vector<float> fpida_values;
87  std::vector<float> fpida_errors;
88  float fpida_mean;
89  float fpida_sigma;
92 
93  void calculatePIDAMean();
94  void calculatePIDASigma();
95  void calculatePIDAIntegral(std::map<double,double> const&);
96 
97  void ClearInternalData();
98 
99  void createKDEs();
100  void createKDE(const size_t);
101  void calculatePIDAKDEMostProbable();
102  void calculatePIDAKDEFullWidthHalfMax();
103  std::vector<float> fpida_kde_mp;
104  std::vector<float> fpida_kde_fwhm;
105  std::vector<float> fpida_kde_b;
106 
107  //this is only for making a histogram later ...
108  std::vector< std::vector<float> > fkde_distribution;
109  std::vector<float> fkde_dist_min;
110  std::vector<float> fkde_dist_max;
111 
113 
114  TTree* fPIDATree;
115  TH1F* hPIDAvalues;
116  TH1F* hPIDAKDE[MAX_BANDWIDTHS];
117  unsigned int fPIDAHistNbins;
120  typedef struct PIDAProperties{
121  unsigned int run;
122  unsigned int event;
123  unsigned int calo_index;
124  unsigned int planeid;
125  float trk_range;
126  float calo_KE;
127 
128  unsigned int n_pid_pts;
129  float mean;
130  float sigma;
133 
134  unsigned int n_bandwidths;
135  float kde_bandwidth[MAX_BANDWIDTHS];
136  float kde_mp[MAX_BANDWIDTHS];
137  float kde_fwhm[MAX_BANDWIDTHS];
138 
141  leaf_structure("run/i:event/i:calo_index/i:planeid/i:trk_range/F:calo_KE/F:n_pid_pts/i:mean/F:sigma/F:integral_dedx/F:integral_pida/F"){}
142 
145  void FillPIDAProperties(unsigned int, unsigned int, unsigned int, anab::Calorimetry const&);
146 
147 };
148 
149 #endif
std::vector< float > fpida_errors
Definition: PIDAAlg.h:87
Namespace for general, non-LArSoft-specific utilities.
TH1F * hPIDAvalues
Definition: PIDAAlg.h:115
std::string leaf_structure
Definition: PIDAAlg.h:139
float fPIDAHistMin
Definition: PIDAAlg.h:118
TTree * fPIDATree
Definition: PIDAAlg.h:114
float fpida_integral_pida
Definition: PIDAAlg.h:91
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:112
std::string string
Definition: nybbler.cc:12
size_t getNKDEBandwidths()
Definition: PIDAAlg.h:62
float fMaxPIDAValue
Definition: PIDAAlg.h:81
std::vector< float > fkde_dist_min
Definition: PIDAAlg.h:109
std::vector< float > fpida_kde_mp
Definition: PIDAAlg.h:103
float fMinResRange
Definition: PIDAAlg.h:79
float fMaxResRange
Definition: PIDAAlg.h:80
unsigned int n_bandwidths
Definition: PIDAAlg.h:134
float fKDEEvalMaxSigma
Definition: PIDAAlg.h:82
float fKDEEvalStepSize
Definition: PIDAAlg.h:83
std::vector< float > fkde_dist_max
Definition: PIDAAlg.h:110
std::vector< float > fpida_kde_fwhm
Definition: PIDAAlg.h:104
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:117
float fPIDAHistMax
Definition: PIDAAlg.h:119
const float fPIDA_BOGUS
Definition: PIDAAlg.h:76
p
Definition: test.py:223
const unsigned int MAX_BANDWIDTHS
Definition: PIDAAlg.h:46
std::vector< float > fpida_values
Definition: PIDAAlg.h:86
std::vector< float > fValues
Definition: PIDAAlg.h:37
float fpida_sigma
Definition: PIDAAlg.h:89
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:105
float fExponentConstant
Definition: PIDAAlg.h:78
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:84
std::vector< std::vector< float > > fkde_distribution
Definition: PIDAAlg.h:108
float getKDEBandwidth(const size_t i_b)
Definition: PIDAAlg.h:63
float fpida_mean
Definition: PIDAAlg.h:88
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:144
float fpida_integral_dedx
Definition: PIDAAlg.h:90
void setExponentConstant(float const &ex)
Definition: PIDAAlg.h:69