CAFMaker_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file CAFMaker_module.cc
4 //
5 // Chris Marshall's version
6 // Largely based on historical FDSensOpt/CAFMaker_module.cc
7 //
8 ///////////////////////////////////////////////////////////////////////
9 
10 #ifndef CAFMaker_H
11 #define CAFMaker_H
12 
13 // Generic C++ includes
14 #include <iostream>
15 
16 // Framework includes
21 #include "fhiclcpp/ParameterSet.h"
23 #include "art_root_io/TFileService.h"
24 
25 //#include "Utils/AppInit.h"
35 
36 // dunerw stuff
37 #include "systematicstools/interface/ISystProviderTool.hh"
38 #include "systematicstools/utility/ParameterAndProviderConfigurationUtility.hh"
39 #include "systematicstools/utility/exceptions.hh"
40 //#include "systematicstools/utility/md5.hh"
41 
42 // root
43 #include "TTree.h"
44 #include "TH1D.h"
45 #include "TH2D.h"
46 
47 // pdg
51 
52 // genie
55 
56 constexpr int knShifts = 100; // number of shifts
57 constexpr int kmaxRwgts = 100; // Largest number of reweights in a shift
58 
59 namespace dunemva {
60 
61  class CAFMaker : public art::EDAnalyzer {
62 
63  public:
64 
65  explicit CAFMaker(fhicl::ParameterSet const& pset);
66  virtual ~CAFMaker();
67  void beginJob() override;
68  void endJob() override;
69  void beginSubRun(const art::SubRun& sr) override;
70  void endSubRun(const art::SubRun& sr) override;
71  void reconfigure(fhicl::ParameterSet const& pset) /*override*/;
72  void analyze(art::Event const & evt) override;
73 
74 
75  private:
79 
82 
86 
87  float fOscPro;
88  double fWeight;
89  TTree* fTree;
90  TTree* fMetaTree;
91 
92  // Get reweight knobs from fhicl file -- no hard-coded shifts
94  double fCvWgts[knShifts];
96 
97  // CAF variables
98  // configuration variables
99  int fIsFD, fIsFHC;
100  // event accounting
102  // Truth information
105  // True particle counts
107  double eP, eN, ePip, ePim, ePi0, eOther;
108  double vtx_x, vtx_y, vtx_z;
109 
110  // Reco information
111  double fErecoNue;
114  int fRecoMethodNue; // 1 = longest reco track + hadronic, 2 = reco shower with highest charge + hadronic, 3 = all hit charges, -1 = not set
115  double fErecoNumu;
118  int fRecoMethodNumu; // 1 = longest reco track + hadronic, 2 = reco shower with highest charge + hadronic, 3 = all hit charges, -1 = not set
119  int fLongestTrackContNumu; // 1 = contained, 0 = exiting, -1 = not set
120  int fTrackMomMethodNumu; // 1 = range, 0 = MCS, -1 = not set
121 
122  double fMVAResult;
125 
126  // CVN outputs
133 
134  double fRegCNNNueE;
135 
136  double meta_pot;
138 
139  systtools::provider_list_t fSystProviders;
140 
141  }; // class CAFMaker
142 
143 
144  //------------------------------------------------------------------------------
146  : EDAnalyzer(pset)
147  {
148  this->reconfigure(pset);
149  }
150 
152 
153  //------------------------------------------------------------------------------
155  {
156 
157  fMVASelectLabel = pset.get<std::string>("MVASelectLabel");
158  fMVASelectNueLabel = pset.get<std::string>("MVASelectNueLabel");
159  fMVASelectNumuLabel = pset.get<std::string>("MVASelectNumuLabel");
160  fCVNLabel = pset.get<std::string>("CVNLabel");
161  fRegCNNLabel = pset.get<std::string>("RegCNNLabel");
162 
163  fEnergyRecoNueLabel = pset.get<std::string>("EnergyRecoNueLabel");
164  fEnergyRecoNumuLabel = pset.get<std::string>("EnergyRecoNumuLabel");
165 
166  // Get DUNErw stuff from its fhicl, which should be included on the CAFMaker config file
167  //if( !pset.has_key("generated_systematic_provider_configuration") ) {
168  // std::cout << "[ERROR]: Could not find producer key: "
169  // "\"generated_systematic_provider_configuration\". This should "
170  // "contain a list of configured systematic providers generated by "
171  // "GenerateSystProviderConfig." << std::endl;
172  // return;
173  //}
174 
175  fhicl::ParameterSet syst_provider_config = pset.get<fhicl::ParameterSet>("generated_systematic_provider_configuration");
176 
177  fSystProviders = systtools::ConfigureISystProvidersFromParameterHeaders(syst_provider_config);
178  }
179 
180 
181  //------------------------------------------------------------------------------
183  {
184 
186  fTree = tfs->make<TTree>("caf", "caf");
187  fMetaTree = tfs->make<TTree>("meta", "meta");
188 
189  // book-keeping
190  fTree->Branch("run", &fRun, "run/I");
191  fTree->Branch("subrun", &fSubrun, "subrun/I");
192  fTree->Branch("event", &fEvent, "event/I");
193  fTree->Branch("isFD", &fIsFD, "isFD/I");
194  fTree->Branch("isFHC", &fIsFHC, "isFHC/I");
195  fTree->Branch("isCC", &fIsCC, "isCC/I");
196 
197  // true interaction quantities
198  fTree->Branch("nuPDG", &fNuPDG, "nuPDG/I");
199  fTree->Branch("nuPDGunosc", &fNuPDGunosc, "nuPDGunosc/I");
200  fTree->Branch("NuMomX", &fNuMomX, "NuMomX/D");
201  fTree->Branch("NuMomY", &fNuMomY, "NuMomY/D");
202  fTree->Branch("NuMomZ", &fNuMomZ, "NuMomZ/D");
203  fTree->Branch("Ev", &fEv, "Ev/D");
204  fTree->Branch("mode", &fMode, "mode/I");
205  fTree->Branch("LepPDG", &fLepPDG, "LepPDG/I");
206  fTree->Branch("LepMomX", &fLepMomX, "LepMomX/D");
207  fTree->Branch("LepMomY", &fLepMomY, "LepMomY/D");
208  fTree->Branch("LepMomZ", &fLepMomZ, "LepMomZ/D");
209  fTree->Branch("LepE", &fLepE, "LepE/D");
210  fTree->Branch("LepNuAngle", &fLepNuAngle, "LepNuAngle/D");
211  fTree->Branch("Q2", &fQ2, "Q2/D");
212  fTree->Branch("W", &fW, "W/D");
213  fTree->Branch("X", &fX, "X/D");
214  fTree->Branch("Y", &fY, "Y/D");
215 
216  // FS particle counts
217  fTree->Branch("nP", &nP, "nP/I");
218  fTree->Branch("nN", &nN, "nN/I");
219  fTree->Branch("nipip", &nPip, "nipip/I");
220  fTree->Branch("nipim", &nPim, "nipim/I");
221  fTree->Branch("nipi0", &nPi0, "nipi0/I");
222  fTree->Branch("nikp", &nKp, "nikp/I");
223  fTree->Branch("nikm", &nKm, "nikm/I");
224  fTree->Branch("nik0", &nK0, "nik0/I");
225  fTree->Branch("niem", &nEM, "niem/I");
226  fTree->Branch("niother", &nOtherHad, "niother/I");
227  fTree->Branch("nNucleus", &nNucleus, "nNucleus/I");
228  fTree->Branch("nUNKNOWN", &nUNKNOWN, "nUNKNOWN/I");
229  fTree->Branch("eP", &eP, "eP/D");
230  fTree->Branch("eN", &eN, "eN/D");
231  fTree->Branch("ePip", &ePip, "ePip/D");
232  fTree->Branch("ePim", &ePim, "ePim/D");
233  fTree->Branch("ePi0", &ePi0, "ePi0/D");
234  fTree->Branch("eOther", &eOther, "eOther/D");
235 
236  // vertex position
237  fTree->Branch("vtx_x", &vtx_x, "vtx_x/D");
238  fTree->Branch("vtx_y", &vtx_y, "vtx_y/D");
239  fTree->Branch("vtx_z", &vtx_z, "vtx_z/D");
240 
241  // Reco variables
242  fTree->Branch("mvaresult", &fMVAResult, "mvaresult/D");
243  fTree->Branch("mvanue", &fMVAResultNue, "mvanue/D");
244  fTree->Branch("mvanumu", &fMVAResultNumu, "mvanumu/D");
245 
246  fTree->Branch("cvnisantineutrino", &fCVNResultIsAntineutrino, "cvnisantineutrino/D");
247  fTree->Branch("cvnnue", &fCVNResultNue, "cvnnue/D");
248  fTree->Branch("cvnnumu", &fCVNResultNumu, "cvnnumu/D");
249  fTree->Branch("cvnnutau", &fCVNResultNutau, "cvnnutau/D");
250  fTree->Branch("cvnnc", &fCVNResultNC, "cvnnc/D");
251  fTree->Branch("cvn0protons", &fCVNResult0Protons, "cvn0protons/D");
252  fTree->Branch("cvn1protons", &fCVNResult1Protons, "cvn1protons/D");
253  fTree->Branch("cvn2protons", &fCVNResult2Protons, "cvn2protons/D");
254  fTree->Branch("cvnNprotons", &fCVNResultNProtons, "cvnNprotons/D");
255  fTree->Branch("cvn0pions", &fCVNResult0Pions, "cvn0pions/D");
256  fTree->Branch("cvn1pions", &fCVNResult1Pions, "cvn1pions/D");
257  fTree->Branch("cvn2pions", &fCVNResult2Pions, "cvn2pions/D");
258  fTree->Branch("cvnNpions", &fCVNResultNPions, "cvnNpions/D");
259  fTree->Branch("cvn0pizeros", &fCVNResult0Pizeros, "cvn0pizeros/D");
260  fTree->Branch("cvn1pizeros", &fCVNResult1Pizeros, "cvn1pizeros/D");
261  fTree->Branch("cvn2pizeros", &fCVNResult2Pizeros, "cvn2pizeros/D");
262  fTree->Branch("cvnNpizeros", &fCVNResultNPizeros, "cvnNpizeros/D");
263  fTree->Branch("cvn0neutrons", &fCVNResult0Neutrons, "cvn0neutrons/D");
264  fTree->Branch("cvn1neutrons", &fCVNResult1Neutrons, "cvn1neutrons/D");
265  fTree->Branch("cvn2neutrons", &fCVNResult2Neutrons, "cvn2neutrons/D");
266  fTree->Branch("cvnNneutrons", &fCVNResultNNeutrons, "cvnNneutrons/D");
267 
268  fTree->Branch("RegCNNNueE", &fRegCNNNueE, "RegCNNNueE/D");
269  fTree->Branch("weight", &fWeight, "weight/D");
270  fTree->Branch("oscpro", &fOscPro, "oscpro/F");
271 
272  fTree->Branch("Ev_reco_nue", &fErecoNue, "Ev_reco_nue/D");
273  fTree->Branch("RecoLepEnNue", &fRecoLepEnNue, "RecoLepEnNue/D");
274  fTree->Branch("RecoHadEnNue", &fRecoHadEnNue, "RecoHadEnNue/D");
275  fTree->Branch("RecoMethodNue", &fRecoMethodNue, "RecoMethodNue/I");
276  fTree->Branch("Ev_reco_numu", &fErecoNumu, "Ev_reco_numu/D");
277  fTree->Branch("RecoLepEnNumu", &fRecoLepEnNumu, "RecoLepEnNumu/D");
278  fTree->Branch("RecoHadEnNumu", &fRecoHadEnNumu, "RecoHadEnNumu/D");
279  fTree->Branch("RecoMethodNumu", &fRecoMethodNumu, "RecoMethodNumu/I");
280  fTree->Branch("LongestTrackContNumu", &fLongestTrackContNumu, "LongestTrackContNumu/I");
281  fTree->Branch("TrackMomMethodNumu", &fTrackMomMethodNumu, "TrackMomMethodNumu/I");
282 
283  fMetaTree->Branch("pot", &meta_pot, "pot/D");
284  fMetaTree->Branch("run", &meta_run, "run/I");
285  fMetaTree->Branch("subrun", &meta_subrun, "subrun/I");
286  fMetaTree->Branch("version", &meta_version, "version/I");
287 
288  // make DUNErw variables
289  for( auto &sp : fSystProviders ) {
290  systtools::SystMetaData metaData = sp->GetSystMetaData();
291  for( systtools::SystMetaData::iterator itMeta = metaData.begin(); itMeta != metaData.end(); ++itMeta ) {
292  systtools::SystParamHeader head = *itMeta;
293  std::string name = head.prettyName;
294  unsigned int parId = head.systParamId;
295  std::cout << "Adding reweight branch " << parId << " for " << name << " with " << head.paramVariations.size() << " shifts" << std::endl;
296  fTree->Branch( Form("%s_nshifts", name.c_str()), &fNwgt[parId], Form("%s_nshifts/I", name.c_str()) );
297  fTree->Branch( Form("%s_cvwgt", name.c_str()), &fCvWgts[parId], Form("%s_cvwgt/D", name.c_str()) );
298  fTree->Branch( Form("wgt_%s", name.c_str()), fWgts[parId], Form("wgt_%s[%s_nshifts]/D", name.c_str(), name.c_str()) );
299  }
300  }
301 
302  // initialize weight variables -- some won't ever be set
303  for( int i = 0; i < knShifts; ++i ) {
304  fNwgt[i] = 0;
305  fCvWgts[i] = 1.;
306  for( int j = 0; j < kmaxRwgts; ++j ) {
307  fWgts[i][j] = 0.;
308  }
309  }
310 
311  meta_pot = 0.;
312  meta_version = 1;
313  }
314 
315  //------------------------------------------------------------------------------
317  {
318  auto pots = sr.getHandle< sumdata::POTSummary >("generator");
319  if( pots ) meta_pot += pots->totpot;
320  }
321 
322  //------------------------------------------------------------------------------
324  {
326  auto pidinnue = evt.getHandle<dunemva::MVASelectPID>(fMVASelectNueLabel);
327  auto pidinnumu = evt.getHandle<dunemva::MVASelectPID>(fMVASelectNumuLabel);
328  art::InputTag itag1(fCVNLabel, "cvnresult");
329  auto cvnin = evt.getHandle<std::vector<cvn::Result>>(itag1);
330  art::InputTag itag2(fRegCNNLabel, "regcnnresult");
331  auto regcnnin = evt.getHandle<std::vector<cnn::RegCNNResult>>(itag2);
332  auto ereconuein = evt.getHandle<dune::EnergyRecoOutput>(fEnergyRecoNueLabel);
333  auto ereconumuin = evt.getHandle<dune::EnergyRecoOutput>(fEnergyRecoNumuLabel);
334 
335  fRun = evt.id().run();
336  fSubrun = evt.id().subRun();
337  fEvent = evt.id().event();
338  meta_run = fRun;
340 
341  if( !pidin.failedToGet() ) {
342  fMVAResult = pidin->pid;
343 
344  //Fill MVA reco stuff
345  fErecoNue = ereconuein->fNuLorentzVector.E();
346  fRecoLepEnNue = ereconuein->fLepLorentzVector.E();
347  fRecoHadEnNue = ereconuein->fHadLorentzVector.E();
348  fRecoMethodNue = ereconuein->recoMethodUsed;
349  fErecoNumu = ereconumuin->fNuLorentzVector.E();
350  fRecoLepEnNumu = ereconumuin->fLepLorentzVector.E();
351  fRecoHadEnNumu = ereconumuin->fHadLorentzVector.E();
352  fRecoMethodNumu = ereconumuin->recoMethodUsed;
354  fTrackMomMethodNumu = ereconumuin->trackMomMethod;
355  }
356 
357  if( !pidinnue.failedToGet() ) {
358  fMVAResultNue = pidinnue->pid;
359  }
360 
361  if( !pidinnumu.failedToGet() ) {
362  fMVAResultNumu = pidinnumu->pid;
363  }
364 
365  if( !cvnin.failedToGet() ) {
366  //using i = cvn::Interaction;
367  //if(cvnin->empty() || (*cvnin)[0].fOutput.size() <= i::kNutauOther){
368  if(cvnin->empty()){
370  fCVNResult0Protons = fCVNResult1Protons = fCVNResult2Protons = fCVNResultNProtons = \
371  fCVNResult0Pions = fCVNResult1Pions = fCVNResult2Pions = fCVNResultNPions = \
372  fCVNResult0Pizeros = fCVNResult1Pizeros = fCVNResult2Pizeros = fCVNResultNPizeros = \
373  fCVNResult0Neutrons = fCVNResult1Neutrons = fCVNResult2Neutrons = fCVNResultNNeutrons = -3;
374  }
375  else{
376  //const std::vector<float>& v = (*cvnin)[0].fOutput;
377  //fCVNResultNue = v[i::kNueQE] + v[i::kNueRes] + v[i::kNueDIS] + v[i::kNueOther];
378  //fCVNResultNumu = v[i::kNumuQE] + v[i::kNumuRes] + v[i::kNumuDIS] + v[i::kNumuOther];
379  //fCVNResultNutau = v[i::kNutauQE] + v[i::kNutauRes] + v[i::kNutauDIS] + v[i::kNutauOther]
380 
381  fCVNResultIsAntineutrino = (*cvnin)[0].GetIsAntineutrinoProbability();
382 
383  fCVNResultNue = (*cvnin)[0].GetNueProbability();
384  fCVNResultNumu = (*cvnin)[0].GetNumuProbability();
385  fCVNResultNutau = (*cvnin)[0].GetNutauProbability();
386  fCVNResultNC = (*cvnin)[0].GetNCProbability();
387 
388  fCVNResult0Protons = (*cvnin)[0].Get0protonsProbability();
389  fCVNResult1Protons = (*cvnin)[0].Get1protonsProbability();
390  fCVNResult2Protons = (*cvnin)[0].Get2protonsProbability();
391  fCVNResultNProtons = (*cvnin)[0].GetNprotonsProbability();
392 
393  fCVNResult0Pions = (*cvnin)[0].Get0pionsProbability();
394  fCVNResult1Pions = (*cvnin)[0].Get1pionsProbability();
395  fCVNResult2Pions = (*cvnin)[0].Get2pionsProbability();
396  fCVNResultNPions = (*cvnin)[0].GetNpionsProbability();
397 
398  fCVNResult0Pizeros = (*cvnin)[0].Get0pizerosProbability();
399  fCVNResult1Pizeros = (*cvnin)[0].Get1pizerosProbability();
400  fCVNResult2Pizeros = (*cvnin)[0].Get2pizerosProbability();
401  fCVNResultNPizeros = (*cvnin)[0].GetNpizerosProbability();
402 
403  fCVNResult0Neutrons = (*cvnin)[0].Get0neutronsProbability();
404  fCVNResult1Neutrons = (*cvnin)[0].Get1neutronsProbability();
405  fCVNResult2Neutrons = (*cvnin)[0].Get2neutronsProbability();
406  fCVNResultNNeutrons = (*cvnin)[0].GetNneutronsProbability();
407  }
408  }
409 
410  fRegCNNNueE = -1.; // initializing
411  if(!regcnnin.failedToGet()){
412  if (!regcnnin->empty()){
413  const std::vector<float>& v = (*regcnnin)[0].fOutput;
414  fRegCNNNueE = v[0];
415  }
416  }
417 
418  std::vector< art::Ptr<simb::MCTruth> > truth;
419  auto mct = evt.getHandle< std::vector<simb::MCTruth> >("generator");
420  if ( mct )
421  art::fill_ptr_vector(truth, mct);
422  else
423  mf::LogWarning("CAFMaker") << "No MCTruth.";
424 
425  std::vector< art::Ptr<simb::MCFlux> > flux;
426  auto mcf = evt.getHandle< std::vector<simb::MCFlux> >("generator");
427  if ( mcf )
428  art::fill_ptr_vector(flux, mcf);
429  else
430  mf::LogWarning("CAFMaker") << "No MCFlux.";
431 /*
432  std::vector< art::Ptr<simb::GTruth> > gtru;
433  auto gt = evt.getHandle< std::vector<simb::GTruth> >("generator");
434  if ( gt )
435  art::fill_ptr_vector(gtru, gt);
436  else
437  mf::LogWarning("CAFMaker") << "No GTruth.";
438 */
439 
440  for(size_t i=0; i<truth.size(); i++){
441 
442  if(i>1){
443  mf::LogWarning("CAFMaker") << "Skipping MC truth index " << i;
444  continue;
445  }
446 
447  fIsFD = 1; // always FD
448  fIsFHC = 999; // don't know how to get this?
449  fIsCC = !(truth[i]->GetNeutrino().CCNC()); // ccnc is 0=CC 1=NC
450  fNuPDG = truth[i]->GetNeutrino().Nu().PdgCode();
451  fNuPDGunosc = flux[i]->fntype;
452  fMode = truth[i]->GetNeutrino().Mode(); //0=QE/El, 1=RES, 2=DIS, 3=Coherent production; this is different than mode in ND
453  fEv = truth[i]->GetNeutrino().Nu().E();
454  fQ2 = truth[i]->GetNeutrino().QSqr();
455  fW = truth[i]->GetNeutrino().W();
456  fX = truth[i]->GetNeutrino().X();
457  fY = truth[i]->GetNeutrino().Y();
458  fNuMomX = truth[i]->GetNeutrino().Nu().Momentum().X();
459  fNuMomY = truth[i]->GetNeutrino().Nu().Momentum().Y();
460  fNuMomZ = truth[i]->GetNeutrino().Nu().Momentum().Z();
461 
462  vtx_x = truth[i]->GetNeutrino().Lepton().Vx();
463  vtx_y = truth[i]->GetNeutrino().Lepton().Vy();
464  vtx_z = truth[i]->GetNeutrino().Lepton().Vz();
465 
466  //Lepton stuff
467  fLepPDG = truth[i]->GetNeutrino().Lepton().PdgCode();
468  fLepMomX = truth[i]->GetNeutrino().Lepton().Momentum().X();
469  fLepMomY = truth[i]->GetNeutrino().Lepton().Momentum().Y();
470  fLepMomZ = truth[i]->GetNeutrino().Lepton().Momentum().Z();
471  fLepE = truth[i]->GetNeutrino().Lepton().Momentum().T();
472  fLepNuAngle = truth[i]->GetNeutrino().Nu().Momentum().Vect().Angle(truth[i]->GetNeutrino().Lepton().Momentum().Vect());
473 
474  // TODO
475  fWeight = 0.;
476  fOscPro = 0.;
477  // fOscPro = fMVAAlg.OscPro(fCCNC,fBeamPdg,fNuPDG,fEtrue);
478 
479  nP = 0;
480  nN = 0;
481  nPip = 0;
482  nPim = 0;
483  nPi0 = 0;
484  nKp = 0;
485  nKm = 0;
486  nK0 = 0;
487  nEM = 0;
488  nOtherHad = 0;
489  nNucleus = 0;
490  nUNKNOWN = 0;
491 
492  eP = 0.;
493  eN = 0.;
494  ePip = 0.;
495  ePim = 0.;
496  ePi0 = 0.;
497  eOther = 0.;
498 
499  for( int p = 0; p < truth[i]->NParticles(); p++ ) {
500  if( truth[i]->GetParticle(p).StatusCode() == genie::kIStHadronInTheNucleus ) {
501 
502  int pdg = truth[i]->GetParticle(p).PdgCode();
503  double ke = truth[i]->GetParticle(p).E() - truth[i]->GetParticle(p).Mass();
504  if ( pdg == genie::kPdgProton ) {
505  nP++;
506  eP += ke;
507  } else if( pdg == genie::kPdgNeutron ) {
508  nN++;
509  eN += ke;
510  } else if( pdg == genie::kPdgPiP ) {
511  nPip++;
512  ePip += ke;
513  } else if( pdg == genie::kPdgPiM ) {
514  nPim++;
515  ePim += ke;
516  } else if( pdg == genie::kPdgPi0 ) {
517  nPi0++;
518  ePi0 += ke;
519  } else if( pdg == genie::kPdgKP ) {
520  nKp++;
521  eOther += ke;
522  } else if( pdg == genie::kPdgKM ) {
523  nKm++;
524  eOther += ke;
525  } else if( pdg == genie::kPdgK0 || pdg == genie::kPdgAntiK0 || pdg == genie::kPdgK0L || pdg == genie::kPdgK0S ) {
526  nK0++;
527  eOther += ke;
528  } else if( pdg == genie::kPdgGamma ) {
529  nEM++;
530  eOther += ke;
531  } else if( genie::pdg::IsHadron(pdg) ) {
532  nOtherHad++; // charm mesons, strange and charm baryons, antibaryons, etc.
533  eOther += ke;
534  } else if( genie::pdg::IsIon(pdg) ) {
535  nNucleus++;
536  } else {
537  nUNKNOWN++;
538  }
539 
540  }
541  }
542 
543  // Reweighting variables
544  //systtools::ScrubUnityEventResponses(er);
545 
546  // struct ParamResponses {
547  // paramId_t pid;
548  // std::vector<double> responses;
549  // }
550  // typedef std::vector<ParamResponses> event_unit_response_t;
551  // typedef std::vector<event_unit_response_t> EventResponse;
552 
553  for( auto &sp : fSystProviders ) {
554  std::unique_ptr<systtools::EventResponse> syst_resp = sp->GetEventResponse(evt);
555  if( !syst_resp ) {
556  std::cout << "[ERROR]: Got nullptr systtools::EventResponse from provider "
557  << sp->GetFullyQualifiedName();
558  continue;
559  }
560 
561  for( systtools::EventResponse::iterator itResp = syst_resp->begin(); itResp != syst_resp->end(); ++itResp ) {
562  systtools::event_unit_response_t resp = *itResp;
563  for( systtools::event_unit_response_t::iterator it = resp.begin(); it != resp.end(); ++it ) {
564  fNwgt[(*it).pid] = (*it).responses.size();
565  //fCvWgts[(*it).pid] = (*it).CV_weight;
566  for( unsigned int i = 0; i < (*it).responses.size(); ++i ) {
567  fWgts[(*it).pid][i] = (*it).responses[i];
568  }
569  }
570  }
571  }
572  } // loop through MC truth i
573 
574  fTree->Fill();
575  return;
576  }
577 
578  //------------------------------------------------------------------------------
579 
580  //------------------------------------------------------------------------------
582  }
583 
585  {
586  fMetaTree->Fill();
587  }
588 
590 
591 } // namespace dunemva
592 
593 #endif // CAFMaker_H
static QCString name
Definition: declinfo.cpp:673
intermediate_table::iterator iterator
systtools::provider_list_t fSystProviders
void analyze(art::Event const &evt) override
int fNwgt[knShifts]
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
void beginSubRun(const art::SubRun &sr) override
double fCvWgts[knShifts]
std::string fCVNLabel
constexpr int knShifts
uint size() const
Definition: qcstring.h:201
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
RunNumber_t run() const
Definition: EventID.h:98
std::string fMVASelectNueLabel
object containing MC flux information
const int kPdgK0
Definition: PDGCodes.h:174
bool IsHadron(int pdgc)
Definition: PDGUtils.cxx:389
void beginJob() override
std::string fEnergyRecoNueLabel
Result for CVN.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
const int kPdgKM
Definition: PDGCodes.h:173
T get(std::string const &key) const
Definition: ParameterSet.h:271
const int kPdgGamma
Definition: PDGCodes.h:189
const int kPdgKP
Definition: PDGCodes.h:172
p
Definition: test.py:223
const int kPdgPiP
Definition: PDGCodes.h:158
const int kPdgPi0
Definition: PDGCodes.h:160
std::string fRegCNNLabel
const int kPdgAntiK0
Definition: PDGCodes.h:175
const int kPdgK0L
Definition: PDGCodes.h:176
std::string fMVAMethod
RegCNNResult for RegCNN modified from Result.h.
std::string fEnergyRecoNumuLabel
std::string fMVASelectNumuLabel
bool IsIon(int pdgc)
Definition: PDGUtils.cxx:39
std::string fMVASelectLabel
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const int kPdgPiM
Definition: PDGCodes.h:159
EventNumber_t event() const
Definition: EventID.h:116
const int kPdgProton
Definition: PDGCodes.h:81
double pid
How confident are we?
Definition: MVASelectPID.h:11
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
const int kPdgK0S
Definition: PDGCodes.h:177
static constexpr double sr
Definition: Units.h:166
void reconfigure(fhicl::ParameterSet const &pset)
double fWgts[knShifts][kmaxRwgts]
const int kPdgNeutron
Definition: PDGCodes.h:83
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:34
QTextStream & endl(QTextStream &s)
void endJob() override
constexpr int kmaxRwgts
CAFMaker(fhicl::ParameterSet const &pset)
void endSubRun(const art::SubRun &sr) override