LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PIDAAlg.h
Go to the documentation of this file.
1 #ifndef PIDAALG_H
2 #define PIDAALG_H
3 
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 namespace fhicl {
17  class ParameterSet;
18 }
19 namespace anab {
20  class Calorimetry;
21 }
22 
23 class TH1F;
24 class TTree;
25 
26 namespace util {
27  class NormalDistribution;
28 }
29 
31 
32 public:
34  NormalDistribution(float, float);
35 
36  float getValue(float);
37 
38 private:
39  float fStepSize;
40  float fMaxSigma;
41  std::vector<float> fValues;
42 };
43 
44 namespace pid {
45  class PIDAAlg;
46 }
47 
48 const unsigned int MAX_BANDWIDTHS = 100;
49 
50 class pid::PIDAAlg {
51 public:
52  PIDAAlg(fhicl::ParameterSet const& p);
53 
54  void RunPIDAAlg(std::vector<float> const&, std::vector<float> const&);
55  void RunPIDAAlg(anab::Calorimetry const&);
56  void RunPIDAAlg(anab::Calorimetry const&, float&, float&);
57 
58  float getPIDAMean();
59  float getPIDASigma();
60 
61  const std::vector<float>& getPIDAValues();
62  const std::vector<float>& getPIDAErrors();
63 
64  size_t getNKDEBandwidths() { return fKDEBandwidths.size(); }
65  float getKDEBandwidth(const size_t i_b) { return fKDEBandwidths.at(i_b); }
66  float getPIDAKDEMostProbable(const size_t);
67  float getPIDAKDEFullWidthHalfMax(const size_t);
68 
69  void PrintPIDAValues();
70 
71  void setExponentConstant(float const& ex) { fExponentConstant = ex; }
72 
73  void SetPIDATree(TTree*, TH1F*, std::vector<TH1F*>);
74  void FillPIDATree(unsigned int, unsigned int, unsigned int, anab::Calorimetry const&);
75 
76 private:
77  const float fPIDA_BOGUS;
78 
80  float fMinResRange;
81  float fMaxResRange;
85  std::vector<float> fKDEBandwidths;
86 
87  std::vector<float> fpida_values;
88  std::vector<float> fpida_errors;
89  float fpida_mean;
90  float fpida_sigma;
93 
94  void calculatePIDAMean();
95  void calculatePIDASigma();
96  void calculatePIDAIntegral(std::map<double, double> const&);
97 
98  void ClearInternalData();
99 
100  void createKDEs();
101  void createKDE(const size_t);
102  void calculatePIDAKDEMostProbable();
103  void calculatePIDAKDEFullWidthHalfMax();
104  std::vector<float> fpida_kde_mp;
105  std::vector<float> fpida_kde_fwhm;
106  std::vector<float> fpida_kde_b;
107 
108  //this is only for making a histogram later ...
109  std::vector<std::vector<float>> fkde_distribution;
110  std::vector<float> fkde_dist_min;
111  std::vector<float> fkde_dist_max;
112 
114 
115  TTree* fPIDATree;
116  TH1F* hPIDAvalues;
117  TH1F* hPIDAKDE[MAX_BANDWIDTHS];
118  unsigned int fPIDAHistNbins;
121  typedef struct PIDAProperties {
122  unsigned int run;
123  unsigned int event;
124  unsigned int calo_index;
125  unsigned int planeid;
126  float trk_range;
127  float calo_KE;
128 
129  unsigned int n_pid_pts;
130  float mean;
131  float sigma;
134 
135  unsigned int n_bandwidths;
136  float kde_bandwidth[MAX_BANDWIDTHS];
137  float kde_mp[MAX_BANDWIDTHS];
138  float kde_fwhm[MAX_BANDWIDTHS];
139 
140  std::string leaf_structure;
142  : leaf_structure("run/i:event/i:calo_index/i:planeid/i:trk_range/F:calo_KE/F:n_pid_pts/"
143  "i:mean/F:sigma/F:integral_dedx/F:integral_pida/F")
144  {}
145 
148  void FillPIDAProperties(unsigned int, unsigned int, unsigned int, anab::Calorimetry const&);
149 };
150 
151 #endif
std::vector< float > fpida_errors
Definition: PIDAAlg.h:88
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
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 fpida_integral_pida
Definition: PIDAAlg.h:92
util::NormalDistribution fnormalDist
Definition: PIDAAlg.h:113
size_t getNKDEBandwidths()
Definition: PIDAAlg.h:64
float fMaxPIDAValue
Definition: PIDAAlg.h:82
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 fMinResRange
Definition: PIDAAlg.h:80
float fMaxResRange
Definition: PIDAAlg.h:81
unsigned int n_bandwidths
Definition: PIDAAlg.h:135
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
unsigned int fPIDAHistNbins
Definition: PIDAAlg.h:118
float fPIDAHistMax
Definition: PIDAAlg.h:120
parameter set interface
const float fPIDA_BOGUS
Definition: PIDAAlg.h:77
const unsigned int MAX_BANDWIDTHS
Definition: PIDAAlg.h:48
std::vector< float > fpida_values
Definition: PIDAAlg.h:87
std::vector< float > fValues
Definition: PIDAAlg.h:41
float fpida_sigma
Definition: PIDAAlg.h:90
std::vector< float > fpida_kde_b
Definition: PIDAAlg.h:106
float fExponentConstant
Definition: PIDAAlg.h:79
std::vector< float > fKDEBandwidths
Definition: PIDAAlg.h:85
float getKDEBandwidth(const size_t i_b)
Definition: PIDAAlg.h:65
float fpida_mean
Definition: PIDAAlg.h:89
PIDAProperties_t fPIDAProperties
Definition: PIDAAlg.h:147
float fpida_integral_dedx
Definition: PIDAAlg.h:91
void setExponentConstant(float const &ex)
Definition: PIDAAlg.h:71