TwoProngBDTAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TwoProngBDTAna
3 // Module Type: analyzer
4 // File: TwoProngBDTAna_module.cc
5 //
6 // Generated at Mon Jul 30 23:21:25 2018 by Reed Bowles using artmod
7 // from cetpkgsupport v1_14_01.
8 ////////////////////////////////////////////////////////////////////////
9 
10 // C/C++ includes
11 #include <cmath>
12 #include <iostream>
13 #include <map>
14 #include <vector>
15 #include <string>
16 
17 // ROOT includes
18 #include "TTree.h"
19 #include "TH1F.h"
20 #include "TH2F.h"
21 
31 #include "fhiclcpp/ParameterSet.h"
36 
37 // NOvASoft includes
42 #include "Utilities/func/MathUtil.h"
43 #include "MCCheater/BackTracker.h"
44 #include "Geometry/Geometry.h"
46 #include "GeometryObjects/Geo.h"
47 #include "RecoBase/Cluster.h"
48 #include "RecoBase/Vertex.h"
49 
50 
51 
52 namespace ncpi0 {
53  class TwoProngBDTAna;
54 }
55 
57 public:
58  explicit TwoProngBDTAna(fhicl::ParameterSet const & p);
59 
60  // Plugins should not be copied or assigned.
61  TwoProngBDTAna(TwoProngBDTAna const &) = delete;
62  TwoProngBDTAna(TwoProngBDTAna &&) = delete;
63  TwoProngBDTAna & operator = (TwoProngBDTAna const &) = delete;
65 
66  // Required functions.
67  void analyze(art::Event const & e);
68 
69  // Selected optional functions.
70  void beginJob();
71  void reconfigure(fhicl::ParameterSet const & p);
72 
73 private:
74 
75  //Initialize the handle labels
78 
79  //NCPi0BkgRej histograms
82 };
83 
84 
86  :
87  EDAnalyzer(p)
88 {
89  this->reconfigure(p);
90 }
91 
92 
93 
95 {
97  fNCPi0BkgRejHist = tfs->make<TH1F>("NCPi0BkgRej","BDT Output; BDT Output", 100,-1,1);
98  fNCPi0BkgRejLTHist = tfs->make<TH1F>("NCPi0BkgRejLT","LT BDT Output; LT BDT Output", 100,-1,1);
99 }
100 
102 {
103  //Loop over all slices in the file
105  e.getByLabel(fSliceLabel, sHandle);
106 
107  if(sHandle.failedToGet())
108  {
109  std::cout<<"No slices found, skipping event" << std::endl;
110  }
112 
113  //Loop over slices
114  for(unsigned int i=0; i<sHandle->size(); ++i)
115  {
116  slices.push_back(art::Ptr<rb::Cluster>(sHandle, i));
117  }
118 
119  //Get associations between slices and ncpi0 events.
121 
122  //Loop over slices.
123  for(unsigned int i=0; i<slices.size();i++)
124  {
125  //Run some quality assurance on the slices.
126  if(slices[i]->IsNoise()) continue;
127  if(!fmNCPi0.isValid()) continue;
128 
129  //Create a vector pointer containing the ncpi0bkgrej info within each slice.
130  std::vector<art::Ptr<ncpi0::NCPi0BkgRej>> ncpi0bkgrej = fmNCPi0.at(i);
131 
132  //Make sure there are ncpi0 events in the slice.
133  if(ncpi0bkgrej.empty()) continue;
134 
135  //Fill the histograms.
136  fNCPi0BkgRejHist->Fill(ncpi0bkgrej[0]->NCPIDBDTG());
137  fNCPi0BkgRejLTHist->Fill(ncpi0bkgrej[0]->NCPIDBDTGLT());
138  }
139 }
140 
142 {
143  fSliceLabel = p.get< std::string >("SliceLabel");
144  fNCPi0Label = p.get< std::string >("NCPi0Label");
145 }
146 
147 
back track the reconstruction to the simulation
void analyze(art::Event const &e)
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
void reconfigure(fhicl::ParameterSet const &p)
TwoProngBDTAna(fhicl::ParameterSet const &p)
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
T get(std::string const &key) const
Definition: ParameterSet.h:231
Collect Geo headers and supply basic geometry functions.
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Vertex location in position and time.
size_type size() const
Definition: PtrVector.h:308
OStream cout
Definition: OStream.cxx:6
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TwoProngBDTAna & operator=(TwoProngBDTAna const &)=delete
Definition: FillPIDs.h:19
Float_t e
Definition: plot.C:35
Encapsulate the geometry of one entire detector (near, far, ndos)
bool failedToGet() const
Definition: Handle.h:196
enum BeamMode string