All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROC.h
Go to the documentation of this file.
1 #ifndef _sbncode_ROC_hh
2 #define _sbncode_ROC_hh
3 
4 #include <vector>
5 
6 #include "TH1D.h"
7 
8 #include "../Data/RecoEvent.h"
9 
10 #include "Cuts.h"
11 
12 namespace ana {
13  namespace SBNOsc {
14 
15  /**
16  * Class to handle making of ROC plots for cut values
17  */
18  struct ROC {
19  /** Initialize the class */
20  void Initialize();
21  /** Fill the class with a reconstructed event
22  * \param event The RecoEvent information
23  */
24  void Fill(const Cuts &cuts, const numu::RecoEvent &event, bool file_is_neutrino);
25  /** Write the ROC plots to disk */
26  void Write() const;
27  /** Get the optimal cut values by S/sqrt(S+B)
28  */
29  void BestCuts() const;
30  void Normalize(float neutrino_scale, float cosmic_scale);
31 
32  /**
33  * Primitive used to make ROC plots
34  */
35  struct Primitive {
36  void Initialize(const std::string &name, float cut_low, float cut_high, unsigned n_bin);
37  void Fill(bool is_signal, float value);
38  void FillNever(bool is_signal);
39  void FillAlways(bool is_signal);
40  void Scale(float scale);
41  ~Primitive();
42 
43  std::string name;
44  TH1D *signal;
45  unsigned n_signal;
46  TH1D *background;
47  unsigned n_background;
48  };
49 
53  std::string name;
54 
55  void Initialize(const std::string &name, float cut_low, float cut_high, unsigned n_bin);
56  void FillNeutrino(bool is_signal, float value) {fNeutrino.Fill(is_signal, value);}
57  void FillNeverNeutrino(bool is_signal) {fNeutrino.FillNever(is_signal);}
58  void FillAlwaysNeutrino(bool is_signal) {fNeutrino.FillAlways(is_signal);}
59 
60  void FillCosmic(bool is_signal, float value) {fCosmic.Fill(is_signal, value);}
61  void FillNeverCosmic(bool is_signal) {fCosmic.FillNever(is_signal);}
62  void FillAlwaysCosmic(bool is_signal) {fCosmic.FillAlways(is_signal);}
63 
64  void Normalize(float scale_neutrino, float scale_cosmic);
65  void Write() const;
66  // float BestCut(float scale_neutrino, float scale_cosmic, float n_background_data) const;
67  float BestCut() const;
68 
69  float Signal(unsigned bin) const;
70  float Background(unsigned bin) const;
71  float NSignal() const;
72  float NBackground() const;
73  unsigned NCutVals() const;
74  float GetCutVal(unsigned bin) const;
75  };
76 
79  std::vector<NormalizedPrimitive *> fAllPrimitives;
80  };
81 
82  } // namespace SBNOsc
83 } // namespace ana
84 
85 
86 
87 #endif
NormalizedPrimitive crt_hit_distance
Definition: ROC.h:78
void Initialize(const std::string &name, float cut_low, float cut_high, unsigned n_bin)
Definition: ROC.cc:71
std::string name
Definition: ROC.h:43
void Fill(bool is_signal, float value)
Definition: ROC.cc:79
void FillNever(bool is_signal)
Definition: ROC.cc:90
float Signal(unsigned bin) const
Definition: ROC.cc:117
void FillNeutrino(bool is_signal, float value)
Definition: ROC.h:56
process_name opflashCryoW ana
void Write() const
Definition: ROC.cc:12
float Background(unsigned bin) const
Definition: ROC.cc:121
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
void FillAlwaysCosmic(bool is_signal)
Definition: ROC.h:62
void FillNeverCosmic(bool is_signal)
Definition: ROC.h:61
void FillAlwaysNeutrino(bool is_signal)
Definition: ROC.h:58
void Fill(const Cuts &cuts, const numu::RecoEvent &event, bool file_is_neutrino)
Definition: ROC.cc:30
void FillCosmic(bool is_signal, float value)
Definition: ROC.h:60
void Normalize(float neutrino_scale, float cosmic_scale)
Definition: ROC.cc:18
void FillNeverNeutrino(bool is_signal)
Definition: ROC.h:57
float GetCutVal(unsigned bin) const
Definition: ROC.cc:129
void Normalize(float scale_neutrino, float scale_cosmic)
Definition: ROC.cc:112
unsigned NCutVals() const
Definition: ROC.cc:125
temporary value
void FillAlways(bool is_signal)
Definition: ROC.cc:100
void BestCuts() const
Definition: ROC.cc:24
NormalizedPrimitive crt_track_angle
Definition: ROC.h:77
void Scale(float scale)
Definition: ROC.cc:105
void Initialize(const std::string &name, float cut_low, float cut_high, unsigned n_bin)
Definition: ROC.cc:65
unsigned n_background
Definition: ROC.h:47
std::vector< NormalizedPrimitive * > fAllPrimitives
Definition: ROC.h:79
void Initialize()
Definition: ROC.cc:5