MVASelect_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file MVASelect_module.cc
4 //
5 // tylerdalion@gmail.com
6 //
7 ///////////////////////////////////////////////////////////////////////
8 
9 #ifndef MVASelect_H
10 #define MVASelect_H
11 
12 // Generic C++ includes
13 #include <iostream>
14 
15 // Framework includes
20 #include "fhiclcpp/ParameterSet.h"
22 #include "art_root_io/TFileService.h"
23 
24 #include "nugen/NuReweight/art/NuReweight.h"
31 
33 
34 #include "TTree.h"
35 #include "TH1D.h"
36 #include "TH2D.h"
37 
41 
44 
45 namespace dunemva {
46 
47  class MVASelect : public art::EDProducer {
48 
49  public:
50 
51  explicit MVASelect(fhicl::ParameterSet const& pset);
52  virtual ~MVASelect();
53  void beginJob() override;
54  void beginSubRun(art::SubRun& sr) override;
55  void endSubRun(art::SubRun& sr) override;
56  void reconfigure(fhicl::ParameterSet const& pset) ;
57  void produce(art::Event& evt) override;
58 
59 
60  private:
61 
64 
65  bool fSelNuE;
66  bool fSelNuMu;
67 
68  }; // class MVASelect
69 
70 
71  //------------------------------------------------------------------------------
73  : EDProducer(pset), fMVAAlg(pset)
74  {
75  produces<dunemva::MVASelectPID>();
76 
77  this->reconfigure(pset);
78  }
79 
81 
82  //------------------------------------------------------------------------------
84  {
85  fMVAMethod=pset.get< std::string >("MVAMethod");
86  fMVAAlg.reconfigure(pset);
87 
88  if(pset.get<std::string>("Select") == "nue"){
89  fSelNuE = true;
90  fSelNuMu = false;
91  } else if(pset.get<std::string>("Select") == "numu"){
92  fSelNuE = false;
93  fSelNuMu = true;
94  }
95 
96  }
97 
98 
99  //------------------------------------------------------------------------------
101  {
102  }
103 
104  //------------------------------------------------------------------------------
105  /*
106  TH2D* MVASelect::MakeRespoHist(TString name){
107  return fTfs->make<TH2D>( name, name,
108  bins_true_E, bin_edges_true_E,
109  n_respo_bins,bin_edges_respo);
110  }
111  */
112 
113  //------------------------------------------------------------------------------
115  }
116 
117 
118  //------------------------------------------------------------------------------
120  {
121  std::unique_ptr<dunemva::MVASelectPID> pidout = std::make_unique<MVASelectPID>();
122 
123  if(fSelNuE) pidout->selectMode = 12;
124  if(fSelNuMu) pidout->selectMode = 14;
125 
126  // Weight seems to have osc probability etc in it. Not suitable for a reco
127  // module, drop that output on the floor
128  double weight;
129  fMVAAlg.Run(evt, pidout->pid, weight);
130 
131  pidout->evtcharge = fMVAAlg.evtcharge;
132  pidout->rawcharge = fMVAAlg.rawcharge;
133  pidout->wirecharge = fMVAAlg.wirecharge;
134 
135  pidout->ntrack = fMVAAlg.ntrack;
138  pidout->trkdedx = fMVAAlg.trkdedx;
139  pidout->trkrch = fMVAAlg.trkrch;
140  pidout->trkrt = fMVAAlg.trkrt;
141  pidout->trkfr = fMVAAlg.trkfr;
143  pidout->nshower = fMVAAlg.nshower;
144  pidout->showerdedx = fMVAAlg.showerdedx;
145  pidout->eshower = fMVAAlg.eshower;
146  pidout->frshower = fMVAAlg.frshower;
147  pidout->nhitspershw = fMVAAlg.nhitspershw;
148  pidout->shwlength = fMVAAlg.shwlength;
149  pidout->shwmax = fMVAAlg.shwmax;
154  pidout->shwdis = fMVAAlg.shwdis;
155  pidout->shwdisx = fMVAAlg.shwdisx;
156  pidout->shwdisy = fMVAAlg.shwdisy;
157  pidout->shwdisz = fMVAAlg.shwdisz;
158  pidout->shwcosx = fMVAAlg.shwcosx;
159  pidout->shwcosy = fMVAAlg.shwcosy;
160  pidout->shwcosz = fMVAAlg.shwcosz;
161  pidout->trkcosx = fMVAAlg.trkcosx;
162  pidout->trkcosy = fMVAAlg.trkcosy;
163  pidout->trkcosz = fMVAAlg.trkcosz;
164  pidout->et = fMVAAlg.ET;
165 
166  evt.put(std::move(pidout));
167  }
168 
169  //------------------------------------------------------------------------------
171  fMVAAlg.endSubRun(sr);
172  }
173 
175 
176 } // namespace dunemva
177 
178 #endif // MVASelect_H
179 
180 
181 /*
182 
183 ReweightLabel_t:
184 
185 fReweightMFP_pi = genie::rew::kINukeTwkDial_MFP_pi, ///< tweak mean free path for pions
186 fReweightMFP_N = genie::rew::kINukeTwkDial_MFP_N, ///< tweak mean free path for nucleons
187 fReweightFrCEx_pi = genie::rew::kINukeTwkDial_FrCEx_pi, ///< tweak charge exchange probability for pions, for given total rescattering probability
188 fReweightFrElas_pi = genie::rew::kINukeTwkDial_FrElas_pi, ///< tweak elastic probability for pions, for given total rescattering probability
189 fReweightFrInel_pi = genie::rew::kINukeTwkDial_FrInel_pi, ///< tweak inelastic probability for pions, for given total rescattering probability
190 fReweightFrAbs_pi = genie::rew::kINukeTwkDial_FrAbs_pi, ///< tweak absorption probability for pions, for given total rescattering probability
191 fReweightFrPiProd_pi = genie::rew::kINukeTwkDial_FrPiProd_pi, ///< tweak pion production probability for pions, for given total rescattering probability
192 fReweightFrCEx_N = genie::rew::kINukeTwkDial_FrCEx_N, ///< tweak charge exchange probability for nucleons, for given total rescattering probability
193 fReweightFrElas_N = genie::rew::kINukeTwkDial_FrElas_N, ///< tweak elastic probability for nucleons, for given total rescattering probability
194 fReweightFrInel_N = genie::rew::kINukeTwkDial_FrInel_N, ///< tweak inelastic probability for nucleons, for given total rescattering probability
195 fReweightFrAbs_N = genie::rew::kINukeTwkDial_FrAbs_N, ///< tweak absorption probability for nucleons, for given total rescattering probability
196 fReweightFrPiProd_N = genie::rew::kINukeTwkDial_FrPiProd_N, ///< tweak pion production probability for nucleons, for given total rescattering probability
197 
198 kINukeTwkDial_MFP_pi 20%
199 kINukeTwkDial_MFP_N 20%
200 kINukeTwkDial_FrAbs_pi 20%
201 kINukeTwkDial_FrCEx_pi 50%
202 kINukeTwkDial_FrElas_pi 10%
203 kINukeTwkDial_FrInel_pi 40%
204 kINukeTwkDial_FrPiProd_pi 20%
205 kINukeTwkDial_FrAbs_N 20%
206 kINukeTwkDial_FrCEx_N 50%
207 kINukeTwkDial_FrElas_N 30%
208 kINukeTwkDial_FrInel_N 40%
209 kINukeTwkDial_FrPiProd_N 20%
210 
211 */
void beginJob() override
float maxtrklength
Definition: MVAAlg.h:99
double wirecharge
Definition: MVAAlg.h:130
MVASelect(fhicl::ParameterSet const &pset)
float fract_5_wires
Definition: MVAAlg.h:112
int selectMode
What neutrino species are we IDing? Use PDG code to identify numu or nue selection.
Definition: MVASelectPID.h:10
std::string string
Definition: nybbler.cc:12
float showerdedx
Definition: MVAAlg.h:106
void reconfigure(fhicl::ParameterSet const &p)
Definition: MVAAlg.cxx:273
float shwmax
Definition: MVAAlg.h:111
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
double rawcharge
Definition: MVAAlg.h:129
float trkpida_save
Definition: MVAAlg.h:104
float trkdedx
Definition: MVAAlg.h:100
weight
Definition: test.py:257
float fract_10_wires
Definition: MVAAlg.h:113
void Run(const art::Event &evt, std::vector< double > &result, double &wgt)
object containing MC flux information
float trkcosy
Definition: MVAAlg.h:124
float shwdisz
Definition: MVAAlg.h:119
float shwcosx
Definition: MVAAlg.h:120
void reconfigure(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
float fract_100_wires
Definition: MVAAlg.h:115
void produce(art::Event &evt) override
float trkcosz
Definition: MVAAlg.h:125
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
float frshower
Definition: MVAAlg.h:108
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
float shwdisy
Definition: MVAAlg.h:118
void endSubRun(art::SubRun &sr) override
void beginSubRun(art::SubRun &sr) override
float shwcosy
Definition: MVAAlg.h:121
float avgtrklength
Definition: MVAAlg.h:98
float shwdisx
Definition: MVAAlg.h:117
float evtcharge
Definition: MVAAlg.h:96
float fract_50_wires
Definition: MVAAlg.h:114
float eshower
Definition: MVAAlg.h:107
float trkrch
Definition: MVAAlg.h:101
float trkfr
Definition: MVAAlg.h:103
float trkcosx
Definition: MVAAlg.h:123
double pid
How confident are we?
Definition: MVASelectPID.h:11
float nhitspershw
Definition: MVAAlg.h:109
TCEvent evt
Definition: DataStructs.cxx:7
float shwdis
Definition: MVAAlg.h:116
float ntrack
Definition: MVAAlg.h:97
static constexpr double sr
Definition: Units.h:166
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void endSubRun(const art::SubRun &sr)
Definition: MVAAlg.cxx:373
float shwlength
Definition: MVAAlg.h:110
float nshower
Definition: MVAAlg.h:105
float shwcosz
Definition: MVAAlg.h:122
float trkrt
Definition: MVAAlg.h:102