CMFCAFToEventList_module.cc
Go to the documentation of this file.
1 //
2 // Created by Brian Rebel on 3/13/19.
3 //
4 // Module to take CAF formatted files and turn them into EventList formats
5 //
6 // History
7 // - The last production 4 commit is 42775
8 
9 #include <memory>
10 #include <cmath>
11 #include <string>
12 #include <vector>
13 #include <set>
14 
15 // Framework includes
24 #include "fhiclcpp/ParameterSet.h"
26 #include "cetlib_except/exception.h"
27 #include "cetlib/search_path.h"
28 
29 // NOvA includes
30 #include "SummaryData/POTSum.h"
35 #include "nugen/NuReweight/ReweightLabels.h"
38 
39 // standard record
42 #include "StandardRecord/SRSpill.h"
43 
44 // cafana cuts and vars
45 #include "CAFAna/Cuts/Cuts.h"
46 #include "CAFAna/Cuts/SpillCuts.h"
47 #include "CAFAna/Cuts/TruthCuts.h"
48 #include "CAFAna/Cuts/TimingCuts.h"
49 #include "CAFAna/Vars/HistAxes.h"
50 #include "CAFAna/Vars/Vars.h"
53 #include "CAFAna/Vars/TruthVars.h"
54 #include "CAFAna/Vars/XsecTunes.h"
61 #include "NuXAna/Vars/NusVars.h"
62 
63 // cafana systs
65 #include "CAFAna/Systs/XSecSysts.h"
66 #include "CAFAna/Systs/MECSysts.h"
67 #include "CAFAna/Systs/RPASysts.h"
68 #include "CAFAna/Systs/FSISysts.h"
69 #include "CAFAna/Systs/RESSysts.h"
70 #include "CAFAna/Systs/DISSysts.h"
71 #include "CAFAna/Systs/BeamSysts.h"
72 #include "CAFAna/Systs/Systs.h"
83 
84 // 2020 specific includes
91 #include "NuXAna/Cuts/NusCuts20.h"
93 
94 // ROOT includes
95 #include "TTree.h"
96 #include "TFile.h"
97 #include "TH1.h"
98 #include "TRandom3.h"
99 
100 namespace cmf {
101 
102  struct POTLiveTime{
103 
105  : pot (-1.)
106  , liveTime(-1.)
107  {}
108 
109  POTLiveTime(double const& p,
110  double const& l)
111  : pot (p)
112  , liveTime(l)
113  {}
114 
115  double pot;
116  double liveTime;
117 
118  void operator+=(POTLiveTime const& o) { pot = o.pot; liveTime = o.liveTime; }
119 
120  };
121 
122  struct PeriodRun{
123 
125  int startRun,
126  int endRun)
127  : fPeriod(period)
128  , fStartRun(startRun)
129  , fEndRun(endRun)
130  {}
131 
132  bool RunInPeriod(int run) const { return ((run > fStartRun - 1) && (run < fEndRun + 1)); }
133 
134  int fPeriod;
136  int fEndRun;
137 
138  };
139 
141  public:
142  explicit CAFToEventList(fhicl::ParameterSet const& pset);
143  virtual ~CAFToEventList();
144 
145  // Plugins should not be copied or assigned.
146  CAFToEventList(CAFToEventList const &) = delete;
147  CAFToEventList(CAFToEventList &&) = delete;
148  CAFToEventList & operator = (CAFToEventList const &) = delete;
149  CAFToEventList & operator = (CAFToEventList &&) = delete;
150 
151  void analyze(art::Event const& e) override;
152  void reconfigure(fhicl::ParameterSet const& p) ;
153  void endJob() override;
154 
155  private:
156 
157  void clear ();
158  void DefineNumuQuantiles ();
159  void InitializeEventListColls();
160  int RunToPeriod (int run);
161  bool PassesSelections (caf::SRProxy const& proxy) const;
162  bool PassesNueSelections (caf::SRProxy const& proxy) const;
163  bool PassesNumuSelections (caf::SRProxy const& proxy) const;
164  bool PassesNCSelections (caf::SRProxy const& proxy) const;
165  bool PassesSpillAndBeamCuts (caf::SRProxy const& proxy) const;
166  void FillVariables (std::vector<cmf::DataVarVals> & dataVals,
167  std::vector<cmf::MCVarVals> & mcVals,
168  std::vector<cmf::EventId> & evIds,
169  std::vector<cmf::SelectionType_t> & sels);
170  void FillMCVals (cmf::TruthVars & truthVars,
171  cmf::WeightVars & weightVars,
172  cmf::SystVarColl & systVars,
173  caf::SRProxy & srProxy) const;
174  void FillDataVarVals (cmf::DataVarVals & dataVals,
175  caf::SRProxy const& srProxy) const;
176  void FillEventId (cmf::EventId & evId,
177  caf::SRProxy const& srProxy) const;
178  void FindPOTPerPeriod (TFile & tf);
179  cmf::SelectionType_t FindSelectionType (caf::SRProxy const& srProxy) const;
180 
181  std::vector<std::string> fCAFFileNames; ///< name of the CAF file we are using
182  std::string fFHCQuantFileName; ///< name of file in numudata ups product with FHC quantiles
183  std::string fRHCQuantFileName; ///< name of file in numudata ups product with FHC quantiles
184  std::string fSpillTreeName; ///< names of the Spill tree in the file
185  std::string fPOTHistName; ///< names of the CAF histogram with the total POT
186  std::string fCAFRecTreeName; ///< names of the CAF tree with the reco info
187  cmf::DetType_t fDetector; ///< which detector are we using
188  cmf::EventListColl fMDToEvents; ///< each entry in the vector is for a single slice
189  cmf::FileType_t fFileType; ///< get from the configuration for now
190  std::string fSystType; ///< systematic type
191  bool fIsRealData; ///< are we looking at real data?
192  bool fIsFHC; ///< are we looking at FHC files?
193  std::vector<ana::Cut> fNumuFHCQuantCuts; ///< quantile boundaries for the numu FHC data
194  std::vector<ana::Cut> fNumuRHCQuantCuts; ///< quantile boundaries for the numu RHC data
195  unsigned int fNumQuantiles; ///< number of quantiles
196  //std::set<cmf::EventId> fMissingEvents; ///< events missing compared to CAF sample
197  std::map<int, POTLiveTime> fPeriodToPOTLiveTime; ///< keep track of the POT in each period
198  std::set<cmf::SelectionType_t> fSelections; ///< Selections to use
199  bool fMakeSelectedList; ///< configure to true to make a list
200  std::vector<cmf::PeriodRun> fPeriodRuns; ///< vector of periods to runs
201  };
202 
203  //......................................................................
205  : EDAnalyzer (pset)
206  , fDetector (cmf::kNEARDET)
207  , fFileType (cmf::kUnknownFileType)
208  , fIsRealData (false)
209  , fIsFHC (true)
210  , fNumQuantiles (1)
211  , fMakeSelectedList(false)
212  {
213  // make sure everything is zeroed out.
214  this->clear();
215 
216  this->reconfigure(pset);
217 
218  // initialize the period to POT map
219  // just allow for many periods, unlikely we will
220  // have more than 50, but it doesn't matter if we
221  // plan ahead
222  for(int i = 1; i < 51; ++i) fPeriodToPOTLiveTime[i] = POTLiveTime(0., 0.);
223 
224  // fMissingEvents.insert(cmf::EventId(19195, 10, 73, 0, 37));
225  // fMissingEvents.insert(cmf::EventId(19546, 12, 222, 0, 30));
226  // fMissingEvents.insert(cmf::EventId(19580, 19, 584, 0, 36));
227  // fMissingEvents.insert(cmf::EventId(19662, 58, 54, 0, 27));
228  // fMissingEvents.insert(cmf::EventId(21650, 54, 267, 0, 28));
229  // fMissingEvents.insert(cmf::EventId(22797, 43, 678, 0, 22));
230  // fMissingEvents.insert(cmf::EventId(23330, 24, 252, 0, 33));
231 
232  }
233 
234  //......................................................................
236  {
237  this->clear();
238  }
239 
240  //......................................................................
241  // Method to clear out the collections of data products after the
242  // writeResults method is called.
244  {
245  fMDToEvents .clear();
246  fNumuFHCQuantCuts.clear();
247  fNumuRHCQuantCuts.clear();
248  fSelections .clear();
249  }
250 
251  //......................................................................
253  {
254  fCAFFileNames = p.get<std::vector<std::string> >("CAFFileNames" );
255 
256  // assume we don't mix FHC and RHC files in the same job, and the
257  // fIsFHC should only be used for cosmics
258  if(fCAFFileNames.begin()->find("rhc") != std::string::npos)
259  fIsFHC = false;
260 
261  fCAFRecTreeName = p.get<std::string >("CAFRecTreeName" , "recTree" );
262  fSpillTreeName = p.get<std::string >("SpillTreeName" , "spillTree" );
263  fPOTHistName = p.get<std::string >("CAFPOTHistName" , "TotalPOT" );
264  fNumQuantiles = p.get<unsigned int>("NumQuantiles" , 4 );
265  fMakeSelectedList = p.get<bool >("MakeSelectedList" , false );
266  fFHCQuantFileName = p.get<std::string >("FHCQuantFileName" );
267  fRHCQuantFileName = p.get<std::string >("RHCQuantFileName" );
268  fSystType = p.get<std::string >("SystematicType" , "NOSYST" );
269 
270  auto detName = p.get<std::string>("DetectorName", "Near");
271  fDetector = (detName == "Near") ? cmf::kNEARDET : cmf::kFARDET;
272 
273  auto selType = p.get<std::string>("Selections");
274 
275  if(selType == "NuESel"){
279  }
280  else if(selType == "NuMuSel"){
285 
286  this->DefineNumuQuantiles();
287  }
288  else if(selType == "NCSel"){
290  }
291 
292  auto ftString = p.get<std::string>("FileType");
293 
294  if (ftString == "FluxSwap") fFileType = kSwap;
295  else if(ftString == "NonSwap" ) fFileType = kBeam;
296  else if(ftString == "TauSwap" ) fFileType = kTauSwap;
297  else if(ftString == "CosmicBackground") fFileType = kCosmicBackgroundFile;
298  else if(ftString == "RockFluxSwap" ) fFileType = kRockFluxSwap;
299  else if(ftString == "RockNonSwap" ) fFileType = kRockNonSwap;
300  else{
302  fIsRealData = true;
303  } // end tests on ftString
304 
305  // load up the epochs to use
306  auto periodPOTPars = p.get< std::vector<fhicl::ParameterSet> >("PeriodsToUse");
307 
308  for(auto const& itr : periodPOTPars){
309  if(cmf::StringToDetectorType(itr.get<std::string>("Detector")) != fDetector) continue;
310  fPeriodRuns.emplace_back(itr.get<int>("Period"),
311  itr.get<int>("StartRun"),
312  itr.get<int>("EndRun"));
313  }
314 
316 
317  }
318 
319  //......................................................................
320  // since we are using CAF files, which are not art files, we don't need the
321  // analyze function to do anything
323  {
324  }
325 
326 
327  //......................................................................
329  {
330  // set up the numu quantile cuts
331 
332  std::string filePath;
333 
334  cet::search_path sp("FW_SEARCH_PATH");
335  if( !sp.find_file(fFHCQuantFileName, filePath) )
336  throw cet::exception("CAFToEventList")
337  << "Cannot find FHC numu quantile file "
339 
340  TFile fhcTF(filePath.c_str(), "READ");
341  TH2D *FDSpec2D = dynamic_cast<TH2D*>(fhcTF.Get("FDSpec2D"));
342  if(FDSpec2D == nullptr)
343  throw cet::exception("CAFToEventList")
344  << "Cannot find histogram FDSpec2D in "
345  << filePath;
346 
348 
349  if( !sp.find_file(fRHCQuantFileName, filePath) )
350  throw cet::exception("EventListMaker")
351  << "Cannot find RHC numu quantile file "
353 
354  TFile rhcTF(filePath.c_str(), "READ");
355  FDSpec2D = dynamic_cast<TH2D*>(rhcTF.Get("FDSpec2D"));
356  if(FDSpec2D == nullptr)
357  throw cet::exception("CAFToEventList")
358  << "Cannot find histogram FDSpec2D in "
359  << filePath;
360 
362 
363  }
364 
365  //......................................................................
366  // see https://cdcvs.fnal.gov/redmine/projects/novaart/wiki/Period_and_Epoch_Naming
368  {
369  for(auto const& itr : fPeriodRuns){
370  if(itr.RunInPeriod(run)) return itr.fPeriod;
371  }
372 
373  // no period found for this run and detector, got a problem
374  throw cet::exception("RunToPeriod")
375  << "no period found for run "
376  << run;
377 
378  return 0;
379  }
380 
381  //......................................................................
383  {
384  // here we will create an event list for each possible meta data
385  // for the current epoch and data/MC type.
386 
387  // if we are looking at the ND, there are no cosmic or rock events
388  // there, so don't bother
389  if(fDetector == cmf::kNEARDET &&
392  fFileType == cmf::kRockNonSwap) ) return;
393 
395 
396  std::set<cmf::InteractionType_t> intTypes({cmf::kNuMuCC,
398  cmf::kNuECC,
402  cmf::kNC,
404 
405  // set the bits of the metadata that won't change
406  bool isMC = (fFileType != cmf::kDataFile);
407 
408  for(auto const& itr : fPeriodRuns){
409  // loop over the selection and interaction types to flesh out the lists
410  for(auto const& s : fSelections){
411 
412  // there are no nue peripheral events in the ND
413  if(fDetector == cmf::kNEARDET &&
414  s == cmf::kNuESelectionPeripheral) continue;
415 
416  if(fFileType == cmf::kDataFile){
417 
418  // data have an unknown interaction type
419  cmf::MetaData md(isMC,
420  fDetector,
421  fFileType,
422  s,
424  itr.fPeriod);
425 
426  // make a new EventList for the data
427  if(cmf::FindEventList(md, fMDToEvents) == fMDToEvents.end())
428  fMDToEvents.emplace_back(cmf::EventList(md, ss));
429  } // end if data
431 
432  cmf::MetaData md(true,
433  fDetector,
434  fFileType,
435  s,
437  itr.fPeriod);
438 
439  // make a new EventList for the cosmic background
440  if(cmf::FindEventList(md, fMDToEvents) == fMDToEvents.end())
441  fMDToEvents.emplace_back(cmf::EventList(md, ss));
442  } // end if cosmic background
443  else{
444  // loop over possible interaction types for the metadata
445  // don't use cosmic muons, those are special and are handled
446  // in another way - we don't want to inflate the POT for those lists
447  for(auto const& i : intTypes){
448 
449  cmf::MetaData md(isMC,
450  fDetector,
451  fFileType,
452  s,
453  i,
454  itr.fPeriod);
455 
456  // make a new EventList for the MC
457  if(cmf::FindEventList(md, fMDToEvents) == fMDToEvents.end())
458  fMDToEvents.emplace_back(cmf::EventList(md, ss));
459  } // end loop over interaction types
460  } // end if not data or MC, ie cosmic background
461 
462  } // end loop over selection types
463  } // end loop over epochs
464  }
465 
466 
467  //......................................................................
469  {
470  // only apply kInBeamSpill to far detector since spill.cosmicvn doesn't
471  // exist for ND cafs
472  if (ana::kIsFarDet(&proxy)){
474  return ana::kInCosmicTimingWindow(&proxy) &&
476  else
477  return ana::kInBeamSpill(&proxy) &&
479  }
480  else {
481  return ana::kStandardSpillCuts(&proxy.spill);
482  }
483  }
484 
485  //......................................................................
487  {
488  if(!this->PassesSpillAndBeamCuts(proxy)) return false;
489 
490  // use a series of if statements rather than if/else if because
491  // we want to check each selection option for each event, not
492  // give up if we are looking for numu and nue and an event
493  // happens to not be which ever comes first
494  if(fSelections.find(cmf::kNuMuSelectionQ1) != fSelections.end()){
495  if(this->PassesNumuSelections(proxy)) return true;
496  }
497 
499  if(this->PassesNueSelections(proxy)) return true;
500  }
501 
502  if(fSelections.find(cmf::kNCSelection) != fSelections.end()){
503  if(this->PassesNCSelections(proxy)) return true;
504  }
505 
506  return false;
507  }
508 
509  //......................................................................
511  {
512  if(fDetector == cmf::kFARDET){
513  if(!ana::kNue2020FDAllSamples_ML(&proxy)){
514  LOG_DEBUG("CAFToEventList")
515  << "Fails nue FD main and peripheral cuts";
516  return false;
517  }
518  }
519  else if(fDetector == cmf::kNEARDET){
520  if(!ana::kNue2020ND(&proxy)){
521  LOG_DEBUG("CAFToEventList")
522  << "Fails nue ND cuts, reasons:"
523  << "\n -- kNue2020NDPresel: " << ana::kNue2020NDPresel(&proxy)
524  << "\n ---- kNue2020RecoQuality: " << ana::kNue2020RecoQuality(&proxy)
525  << "\n ---- kNue2020NDContain: " << ana::kNue2020NDContain(&proxy)
526  << "\n -- kNue2020PID: " << ana::kNue2020PID(&proxy);
527  return false;
528  }
529  }
530 
531  return true;
532  }
533 
534  //......................................................................
536  {
537  // check that this event passes the quality cuts and PID selections
538  // for numu
539  if ((float)ana::kCCE(&proxy) >= 5) return false;
540  if(fDetector == cmf::kFARDET){
541  if(!(ana::kNumu2020FD_ML(&proxy))){
542  LOG_DEBUG("CAFToEventList")
543  << "failed numu FD cuts, reasons:"
544  << "\n -- kNumuQuality: " << ana::kNumuQuality(&proxy)
545  << "\n -- kNumuContainFD2020: " << ana::kNumuContainFD2020(&proxy)
546  << "\n -- kNumu2020PID: " << ana::kNumu2020PID(&proxy)
547  << "\n -- kNumu2020CosRej: " << ana::kNumu2020CosRej(&proxy);
548  return false;
549  }
550  }
551  else if(fDetector == cmf::kNEARDET){
552  if(!(ana::kNumu2020ND(&proxy))){
553  LOG_DEBUG("CAFToEventList")
554  << "failed numu ND cuts, reasons:"
555  << "\n -- kNumuQuality: " << ana::kNumuQuality(&proxy)
556  << "\n -- kNumuContainND2020: " << ana::kNumuContainND2020(&proxy)
557  << "\n -- kNumu2020PID: " << ana::kNumu2020PID(&proxy);
558  return false;
559  }
560  }
561 
562  return true;
563  }
564 
565  //......................................................................
567  {
568  if(fDetector == cmf::kFARDET){
569  if(!ana::kNus20FDCuts_ML(&proxy)){
570  LOG_DEBUG("CAFToEventList")
571  << "Fails nc FD selection, reasons:"
572  << "\n -- kNus20QualityCuts: " << ana::kNus20QualityCuts(&proxy)
573  << "\n -- kNus20FDMinSliceDistCut: " << ana::kNus20FDMinSliceDistCut(&proxy)
574  << "\n -- kNus20FDSelectionCuts: " << ana::kNus20FDSelectionCuts(&proxy)
575  << "\n -- kNus20FDCosRejCuts: " << ana::kNus20FDCosRejCuts(&proxy);
576  return false;
577  }
578  }
579  else if(fDetector == cmf::kNEARDET){
580  if(!ana::kNus20NDCuts(&proxy)){
581  LOG_DEBUG("CAFToEventList")
582  << "Fails nc ND selection, reasons:"
583  << "\n -- kNus20QualityCuts: " << ana::kNus20QualityCuts(&proxy)
584  << "\n -- kNus20NDFiducialCuts: " << ana::kNus20NDFiducialCuts(&proxy)
585  << "\n -- kNus20NDSelectionCuts: " << ana::kNus20NDSelectionCuts(&proxy);
586  return false;
587  }
588  }
589 
590  return true;
591  }
592 
593  //......................................................................
595  {
596  int period;
597  float totalPOT = 0.;
598 
599  // TODO this is just using the standard spill cuts to figure out the POT
600  // which is a potential problem. I think ideally we want to check
601  // PassesSpillAndbeamCuts, which should set the right spill cuts based
602  // on detector/sample but that only takes an srProxy, not a spProxy.
603  // the below was my attempt at getting it working but i couldn't quite get
604  // there, I'll get back to it later.
605 /*
606  auto *cafTree = dynamic_cast<TTree*>(tf.Get(fCAFRecTreeName.c_str()));
607 
608  // hook the TTree up to a standard record and get the first entry to initialize things
609  caf::StandardRecord *sr = nullptr;
610 
611  cafTree->SetBranchAddress("rec", &sr);
612  cafTree->GetEntry(0);
613 
614  static caf::SRProxy srProxy(nullptr, nullptr, "", 0, 0);
615  static caf::SRSpillProxy spProxy(nullptr, nullptr, "", 0, 0);
616 
617  LOG_DEBUG("CAFToEventList")
618  << "There are "
619  << cafTree->GetEntriesFast()
620  << " caf entries";
621 
622  for(int i = 0; i < cafTree->GetEntriesFast(); ++i){
623  cafTree->GetEntry(i);
624 
625  // get a proxy for each entry
626  srProxy = *sr;
627  spProxy = &(srProxy.spill);
628 
629  if !(this->PassesSpillAndBeamCuts(srProxy)) continue;
630 
631  period = this->RunToPeriod(spProxy.run);
632 
633  if (std::isnan(sp.spillpot) || std::isnan(sp.livetime))
634  continue;
635  }
636 */
637 
638  auto *spillTree = dynamic_cast<TTree*>(tf.Get(fSpillTreeName.c_str()));
639 
640  caf::SRSpill *sp = nullptr;
641 
642  spillTree->SetBranchAddress("spill", &sp);
643  spillTree->GetEntry(0);
644 
645  static caf::SRSpillProxy spProxy(nullptr, nullptr, "", 0, 0);
646 
647  LOG_VERBATIM("CAFToEventList")
648  << "There are "
649  << spillTree->GetEntriesFast()
650  << " spills";
651 
652  // loop over the spill tree to add up the POT for each period
653  //for(int i = 0; i < 10; ++i){
654  for(int i = 0; i < spillTree->GetEntries(); ++i){
655 
656  spillTree->GetEntry(i);
657 
658  // get a proxy for each entry
659  spProxy = *sp;
660 
661  // ignore spills that don't pass the standard cuts
662  if(!ana::kStandardSpillCuts(&spProxy)) continue;
663 
664  // now figure out which period this spill belongs to
665  period = this->RunToPeriod(sp->run);
666 
667  if(std::isnan(sp->spillpot) ||
668  std::isnan(sp->livetime) ){
669  LOG_VERBATIM("CAFToEventList")
670  << tf.GetName()
671  << " "
672  << sp->run
673  << " "
674  << sp->subrun
675  << " "
676  << sp->evt
677  << " spill has nan for pot or livetime "
678  << sp->spillpot
679  << " "
680  << sp->livetime
681  << " period "
682  << period;
683 
684  continue;
685  }
686  // spillpot is in units of 10^20 POT
688  fPeriodToPOTLiveTime[period].liveTime += sp->livetime;
689 
690  totalPOT += spProxy.spillpot;
691 
692  } // end loop over the entries in the spill tree
693 
694  // if the spill tree and histogram totals are off by more than 1%, say something
695  // n.b. the histogram stores only spills that pass spill cuts, so we actually expect these
696  // to be a little different
697  if(std::abs(1. - totalPOT / dynamic_cast<TH1F* >(tf.Get(fPOTHistName.c_str()))->Integral()) > 0.01)
698  LOG_VERBATIM("CAFToEventList")
699  << "pot hist has "
700  << dynamic_cast<TH1F* >(tf.Get(fPOTHistName.c_str()))->Integral()
701  << " POT compared to "
702  << totalPOT
703  << " from the tree";
704 
705  // print out the number of pot for all files so far
706  for(auto const& itr : fPeriodToPOTLiveTime){
707  if(itr.second.pot > 0. ||
708  itr.second.liveTime > 0.)
709  LOG_VERBATIM("CAFToEventList")
710  << "period "
711  << itr.first
712  << " has "
713  << itr.second.pot * 1.e-20
714  << " x 10^20 POT and "
715  << itr.second.liveTime
716  << " s live time";
717  }
718  }
719 
720  //......................................................................
722  {
723  if(this->PassesNumuSelections(srProxy)){
724  if(srProxy.spill.isFHC){
725  if (fNumuFHCQuantCuts[0](&srProxy)) return cmf::kNuMuSelectionQ1;
726  else if(fNumuFHCQuantCuts[1](&srProxy)) return cmf::kNuMuSelectionQ2;
727  else if(fNumuFHCQuantCuts[2](&srProxy)) return cmf::kNuMuSelectionQ3;
728  else if(fNumuFHCQuantCuts[3](&srProxy)) return cmf::kNuMuSelectionQ4;
729  } // end if fhc
730  else{
731  if (fNumuRHCQuantCuts[0](&srProxy)) return cmf::kNuMuSelectionQ1;
732  else if(fNumuRHCQuantCuts[1](&srProxy)) return cmf::kNuMuSelectionQ2;
733  else if(fNumuRHCQuantCuts[2](&srProxy)) return cmf::kNuMuSelectionQ3;
734  else if(fNumuRHCQuantCuts[3](&srProxy)) return cmf::kNuMuSelectionQ4;
735  }
736  } // end if numu
737  else if(this->PassesNueSelections(srProxy)){
738  auto cvnHighEdge = (srProxy.spill.isFHC) ? ana::kNue2020CVNFHCHighEdge : ana::kNue2020CVNRHCHighEdge;
739  if(ana::kNue2020FDPeripheral(&srProxy))
741  if(ana::kCVNe_looseptp(&srProxy) > cvnHighEdge)
743 
744  // event is NuE and passes the CVN cut, but isn't high or peripheral,
745  // it must be low
747  }
748  else if(this->PassesNCSelections(srProxy)) return cmf::kNCSelection;
749 
750 
751  return cmf::kUnknownSelection;
752  }
753 
754  //......................................................................
755  // note that srProxy is not const here because some of the CAF/Var functions
756  // do not take const pointers to it...seems silly to not have it const.
758  cmf::WeightVars & weightVars,
759  cmf::SystVarColl & systShifts,
760  caf::SRProxy & srProxy) const
761  {
762 
763  truthVars.fTrueE = (float)ana::kTrueE(&srProxy) ;
764  truthVars.fTruePDG = (float)ana::kTruePDG(&srProxy) ;
765  truthVars.fTrueCCNC = (srProxy.mc.nu[0].iscc) ? simb::kCC : simb::kNC;
766  truthVars.fTrueIntType = srProxy.mc.nu[0].inttype ;
767  truthVars.fTrueIntMode = (float)ana::kMode(&srProxy) ;
768  truthVars.fTrueHitNuc = (float)ana::kHitNuc(&srProxy) ;
769  truthVars.fTruePDGOrig = srProxy.mc.nu[0].pdgorig ;
770  truthVars.fTrueParentPDG = srProxy.mc.nu[0].beam.ptype ;
771  truthVars.fTrueParentDecay = srProxy.mc.nu[0].beam.ndecay ;
772  truthVars.fTrueParentTargetPDG = srProxy.mc.nu[0].beam.tptype ;
773  truthVars.fTrueParentPZ = (float)ana::kTruetpz(&srProxy) ;
774  truthVars.fTrueParentPT = (float)ana::kTruetpT(&srProxy) ;
775 
776  // we only care about the following systematics if we're not running a
777  // systematically shifted dataset
778  if (fSystType != "NOSYST") return;
779 
780  // these are weights applied to the event
781  weightVars.fXSecCVPPFX_Weight = (float)(ana::kXSecCVWgt2020(&srProxy) * ana::kPPFXFluxCVWgt(&srProxy));
782  weightVars.fXSecCV2020_Weight = (float)(ana::kXSecCVWgt2020(&srProxy));
783  weightVars.fPPFXFluxCV_Weight = (float)(ana::kPPFXFluxCVWgt(&srProxy));
784 
785  // Now for the full set of systematic knobs
786  // These systematics for the 2020 analysis are taken from Analysis/3FlavorAna2020Systs.cxx
787  //
788  // Note that we don't take:
789  // -- file systematics -> just produce systematically shifted event lists
790  // -- beam systematics -> we have our own handling of that. See core/ShifterAndWeighter.cxx
791 
792  static std::map<const ana::ISyst*, std::string> labelMap =
793  {
794  // xsec systematics
795  {ana::GetGenieKnobSyst(rwgt::fReweightMaCCRES) , "MaCCRES" },
796  {ana::GetGenieKnobSyst(rwgt::fReweightMvCCRES) , "MvCCRES" },
797  {ana::GetGenieKnobSyst(rwgt::fReweightMaNCRES) , "MaNCRES" },
798  {ana::GetGenieKnobSyst(rwgt::fReweightMvNCRES) , "MvNCRES" },
799  {ana::GetGenieKnobSyst(rwgt::fReweightZNormCCQE), "ZNormCCQE" },
800  {&ana::kZExpEV1Syst2020 , "ZExpAxialFFSyst2020_eV1" },
801  {&ana::kZExpEV2Syst2020 , "ZExpAxialFFSyst2020_eV2" },
802  {&ana::kZExpEV3Syst2020 , "ZExpAxialFFSyst2020_eV3" },
803  {&ana::kZExpEV4Syst2020 , "ZExpAxialFFSyst2020_eV4" },
804  {&ana::kRPACCQEEnhSyst2020 , "RPACCQEshapeEnh" }, // ?
805  {&ana::kRPACCQESuppSyst2020 , "RPACCQEshapeSupp" }, // ?
806  {&ana::kRESLowQ2SuppressionSyst2020 , "RESLowQ2SuppSyst2020" },
807  {&ana::kDISvnCC1pi_2020 , "DISvnCC1piWgt_2020" }, // ?
808  {&ana::khNFSISyst2020_MFP , "hNFSISyst2020_MFP" },
809  {&ana::khNFSISyst2020_EV1 , "hNFSISyst2020_EV1" },
810  {&ana::kMECEnuShapeSyst2020Nu , "MECEnuShapeSyst2020Nu" },
811  {&ana::kMECEnuShapeSyst2020AntiNu , "MECEnuShapeSyst2020AntiNu" },
812  {&ana::kMECShapeSyst2020Nu , "MECShapeSyst2020Nu" },
813  {&ana::kMECShapeSyst2020AntiNu , "MECShapeSyst2020AntiNu" },
814  {&ana::kMECInitStateNPFracSyst2020Nu , "MECInitStateNPFracSyst2020Nu" },
815  {&ana::kMECInitStateNPFracSyst2020AntiNu , "MECInitStateNPFracSyst2020AntiNu" },
816  {&ana::kRadCorrNue , "RadCorrNue" },
817  {&ana::kRadCorrNuebar , "RadCorrNuebar" },
818  {&ana::k2ndClassCurrs , "2ndClassCurrs" },
819  // muon energy scale systematics
820  {&ana::kUnCorrNDMuEScaleSyst2020 , "UnCorrNDMuEScaleSyst2020" },
821  {&ana::kUnCorrMuCatMuESyst2020 , "UnCorrMuCatMuESyst2020" },
822  {&ana::kPileupMuESyst2020 , "PileupMuESyst2020" },
823  {&ana::kCorrMuEScaleSyst2020 , "CorrMuEScaleSyst2020" },
824  // neutron systematics
825  {&ana::kNeutronVisEScalePrimariesSyst2018 , "NeutronVisEScalePrimariesSyst2018"},
826  // michel systematics
827  {&ana::kMichelTaggingSyst2020 , "MichelTaggingSyst2020" },
828  // norm systemaitics
829  {&ana::kAna2020NormFHC , "Ana2020NormFHC" },
830  {&ana::kAna2020NormRHC , "Ana2020NormRHC" },
831  // other systematics
832  {&ana::kTauScaleSyst , "TauScaleSyst" },
833  // loads of DIS systs, likely in pca systs, but worth having just in case
834  {&ana::kDISvpCC0pi_2020 , "DISvpCC0pi_2020" },
835  {&ana::kDISvpCC1pi_2020 , "DISvpCC1pi_2020" },
836  {&ana::kDISvpCC2pi_2020 , "DISvpCC2pi_2020" },
837  {&ana::kDISvpCC3pi_2020 , "DISvpCC3pi_2020" },
838  {&ana::kDISvpNC0pi_2020 , "DISvpNC0pi_2020" },
839  {&ana::kDISvpNC1pi_2020 , "DISvpNC1pi_2020" },
840  {&ana::kDISvpNC2pi_2020 , "DISvpNC2pi_2020" },
841  {&ana::kDISvpNC3pi_2020 , "DISvpNC3pi_2020" },
842  {&ana::kDISvnCC0pi_2020 , "DISvnCC0pi_2020" },
843  {&ana::kDISvnCC1pi_2020 , "DISvnCC1pi_2020" },
844  {&ana::kDISvnCC2pi_2020 , "DISvnCC2pi_2020" },
845  {&ana::kDISvnCC3pi_2020 , "DISvnCC3pi_2020" },
846  {&ana::kDISvnNC0pi_2020 , "DISvnNC0pi_2020" },
847  {&ana::kDISvnNC1pi_2020 , "DISvnNC1pi_2020" },
848  {&ana::kDISvnNC2pi_2020 , "DISvnNC2pi_2020" },
849  {&ana::kDISvnNC3pi_2020 , "DISvnNC3pi_2020" },
850  {&ana::kDISvbarpCC0pi_2020 , "DISvbarpCC0pi_2020" },
851  {&ana::kDISvbarpCC1pi_2020 , "DISvbarpCC1pi_2020" },
852  {&ana::kDISvbarpCC2pi_2020 , "DISvbarpCC2pi_2020" },
853  {&ana::kDISvbarpCC3pi_2020 , "DISvbarpCC3pi_2020" },
854  {&ana::kDISvbarpNC0pi_2020 , "DISvbarpNC0pi_2020" },
855  {&ana::kDISvbarpNC1pi_2020 , "DISvbarpNC1pi_2020" },
856  {&ana::kDISvbarpNC2pi_2020 , "DISvbarpNC2pi_2020" },
857  {&ana::kDISvbarpNC3pi_2020 , "DISvbarpNC3pi_2020" },
858  {&ana::kDISvbarnCC0pi_2020 , "DISvbarnCC0pi_2020" },
859  {&ana::kDISvbarnCC1pi_2020 , "DISvbarnCC1pi_2020" },
860  {&ana::kDISvbarnCC2pi_2020 , "DISvbarnCC2pi_2020" },
861  {&ana::kDISvbarnCC3pi_2020 , "DISvbarnCC3pi_2020" },
862  {&ana::kDISvbarnNC0pi_2020 , "DISvbarnNC0pi_2020" },
863  {&ana::kDISvbarnNC1pi_2020 , "DISvbarnNC1pi_2020" },
864  {&ana::kDISvbarnNC2pi_2020 , "DISvbarnNC2pi_2020" },
865  {&ana::kDISvbarnNC3pi_2020 , "DISvbarnNC3pi_2020" },
866  // and some additional likely-pca systs
867  {&ana::kFormZone_2020 , "FormZone_2020" } ,
868  {&ana::khNFSISyst2020_EV2 , "hNFSISyst2020_EV2" } ,
869  {&ana::khNFSISyst2020_EV3 , "hNFSISyst2020_EV3" } ,
870  {ana::GetGenieKnobSyst(rwgt::fReweightMaNCEL) , "MaNCEL" } ,
871  {ana::GetGenieKnobSyst(rwgt::fReweightEtaNCEL) , "EtaNCEL" } ,
872  {&ana::kCOHCCScaleSyst2018 , "COHCCScale2018" } ,
873  {&ana::kCOHNCScaleSyst2018 , "COHNCScale2018" } ,
874  {ana::GetGenieKnobSyst(rwgt::fReweightAhtBY) , "AhtBY" } ,
875  {ana::GetGenieKnobSyst(rwgt::fReweightBhtBY) , "BhtBY" } ,
876  {ana::GetGenieKnobSyst(rwgt::fReweightCV1uBY) , "CV1uBY" } ,
877  {ana::GetGenieKnobSyst(rwgt::fReweightCV2uBY) , "CV2uBY" } ,
878  {ana::GetGenieKnobSyst(rwgt::fReweightAGKY_xF1pi) , "AGKY_xF1pi" } ,
879  {ana::GetGenieKnobSyst(rwgt::fReweightAGKY_pT1pi) , "AGKY_pT1pi" } ,
880  {ana::GetGenieKnobSyst(rwgt::fReweightBR1gamma) , "BR1gamma" } ,
881  {ana::GetGenieKnobSyst(rwgt::fReweightBR1eta) , "BR1eta" } ,
882  {ana::GetGenieKnobSyst(rwgt::fReweightTheta_Delta2Npi) , "Theta_Delta2Npi" } ,
883  // mec for NuX
896  {new ana::MECDoubleGaussEnhSystNux( ana::MECDoubleGaussEnhParamNux::kBaselineNux , "BaselineNux" ), "BaselineNux" }
897  };
898 
899  // add small GENIE PCA scale systs
900  for (int ipca = 0; ipca < 12; ++ipca){
901  std::string gpcaname = "GENIEPCA" + std::to_string(ipca);
902  labelMap[ana::GetGeniePrincipals2020Small(ipca)] = gpcaname;
903  }
904 
905  // now that we have the ISysts for all of the systematics we want to use, get
906  // the -2, -1, +1, +2 shifts and store them in the files.
907  std::string rwgtLabel;
908  std::vector<double> wgt(4, 1.);
909  systShifts.clear();
910  for (auto const& rwgtPair : labelMap){
911 
912  auto wgtFunc = rwgtPair.first;
913  rwgtLabel = rwgtPair.second;
914 
915  wgt[0] = 1.;
916  wgtFunc->Shift(-2., &srProxy, wgt[0]);
917 
918  wgt[1] = 1.;
919  wgtFunc->Shift(-1., &srProxy, wgt[1]);
920 
921  wgt[2] = 1.;
922  wgtFunc->Shift( 1., &srProxy, wgt[2]);
923 
924  wgt[3] = 1.;
925  wgtFunc->Shift( 2., &srProxy, wgt[3]);
926 
927  systShifts.emplace_back(cmf::VarNameToKey(rwgtLabel),
928  (float)wgt[0],
929  (float)wgt[1],
930  (float)wgt[2],
931  (float)wgt[3]);
932 
933  } // end loop over genie reweight variables
934 
935  }
936 
937  //......................................................................
938  // in this function we save the lepton and hadronic energy separately and
939  // construct the final energy in VarVals
941  caf::SRProxy const& srProxy) const
942  {
943 
944  if(this->PassesNueSelections(srProxy)){
945  dataVals.set_val_at(cmf::kLep_RecoE , (float)ana::kEME_2020(&srProxy));
946  dataVals.set_val_at(cmf::kHad_RecoE , (float)ana::kHADE_2020(&srProxy));
947  dataVals.set_val_at(cmf::kNuE_CVN , (float)ana::kCVNe_looseptp(&srProxy));
948  dataVals.set_val_at(cmf::kNuE_NumMichel , (float)ana::kNMichels(&srProxy));
949  }
950  else if(this->PassesNumuSelections(srProxy)){
951  // new implementation
952  dataVals.set_val_at(cmf::kLep_RecoE, (float)ana::kNumuMuE2020(&srProxy));
953  dataVals.set_val_at(cmf::kHad_RecoE, (float)ana::kNumuHadE2020(&srProxy));
954  dataVals.set_val_at(cmf::kRecoQ2 , (float)ana::kRecoQ2(&srProxy));
955  //dataVals.set_val_at(cmf::kLep_RecoE_MCFrac, (float)ana::kNumuHadEFrac2020(&srProxy));
956  }
957  else if(this->PassesNCSelections(srProxy)){
958  // NOTE: the energies here are NOT the leptonic and hadronic energies
959  // for the NC energy estimator we need the "EM-like" and "Hadronic-like" energies
960  // and so we store them in the leptonic and hadronic energies repsectively
961 
962  dataVals.set_val_at(cmf::kLep_RecoE, ana::kEME_2020 (&srProxy));
963  dataVals.set_val_at(cmf::kHad_RecoE, ana::kHADE_2020(&srProxy));
964 
965  }
966 
967  }
968 
969  //......................................................................
971  caf::SRProxy const& srProxy) const
972  {
973  evId.run = srProxy.hdr.run;
974  evId.subrun = srProxy.hdr.subrun;
975  evId.event = srProxy.hdr.evt;
976  evId.slice = srProxy.hdr.subevt;
977  evId.cycle = srProxy.hdr.cycle;
978  }
979 
980  //......................................................................
981  void CAFToEventList::FillVariables(std::vector<cmf::DataVarVals> & dataVals,
982  std::vector<cmf::MCVarVals> & mcVals,
983  std::vector<cmf::EventId> & evIds,
984  std::vector<cmf::SelectionType_t> & sels)
985  {
986  dataVals.clear();
987  mcVals .clear();
988  evIds .clear();
989 
990  for(auto const& fileName : fCAFFileNames){
991 
992  // open the CAF file and get the TTrees and histograms for reading
993  TFile *tf = TFile::Open(fileName.c_str());
994 
995  this->FindPOTPerPeriod(*tf);
996 
997  auto *cafTree = dynamic_cast<TTree*>(tf->Get(fCAFRecTreeName.c_str()));
998 
999  // hook the TTree up to a standard record and get the first entry to initialize things
1000  caf::StandardRecord *sr = nullptr;
1001 
1002  cafTree->SetBranchAddress("rec", &sr);
1003  cafTree->GetEntry(0);
1004 
1005  static caf::SRProxy srProxy(nullptr, nullptr, "", 0, 0);
1006 
1007  LOG_DEBUG("CAFToEventList")
1008  << "There are "
1009  << cafTree->GetEntriesFast()
1010  << " caf entries";
1011 
1012  // now loop over the CAF entries and fill the event list variables
1013  //for(int i = 0; i < 10; ++i){
1014  for(int i = 0; i < cafTree->GetEntriesFast(); ++i){
1015  cafTree->GetEntry(i);
1016 
1017  // get a proxy for each entry
1018  srProxy = *sr;
1019 
1020  // Uncomment the following block to debug cases where events
1021  // show up in the official CAF selection but not this one, or
1022  // vice versa
1023  /*
1024  cmf::EventId curEvent(srProxy.hdr.run,
1025  srProxy.hdr.subrun,
1026  srProxy.hdr.evt,
1027  srProxy.hdr.cycle,
1028  srProxy.hdr.subevt);
1029 
1030  if( fMissingEvents.find(curEvent) != fMissingEvents.end())
1031  LOG_VERBATIM("MissingEventsCheck")
1032  << curEvent
1033  << " beam "
1034  << ana::kInBeamSpill(&srProxy)
1035  << " spill "
1036  << ana::kStandardSpillCuts(&(srProxy.spill))
1037  << " FD all "
1038  << ana::kNue2020FDAllSamples(&srProxy);
1039  */
1040 
1041  if ( !this->PassesSelections(srProxy) ) continue;
1042  sels .emplace_back(this->FindSelectionType(srProxy));
1043 
1044 
1045  cmf::TruthVars truthVars;
1046  cmf::WeightVars weightVars;
1047  cmf::SystVarColl systVars;
1048  cmf::DataVarVals dataVarVals;
1049  cmf::EventId evId;
1050 
1051  // TODO: right now we must emplace back the information
1052  // immediately after we fill it, else ISyst::Shift, called in
1053  // FillMCVals will modify them. This shouldn't happen and really
1054  // bothers me, figure that out.
1055 
1056  // fill the event id information
1057  this->FillEventId(evId, srProxy);
1058  evIds .emplace_back(evId);
1059 
1060  // fill the data values
1061  this->FillDataVarVals(dataVarVals, srProxy);
1062  dataVals.emplace_back(dataVarVals);
1063 
1064  // fill MC information if this is mc
1065  if(srProxy.hdr.ismc){
1066  if(srProxy.mc.nu.size() == 1){
1067  this->FillMCVals(truthVars,
1068  weightVars,
1069  systVars,
1070  srProxy);
1071  }
1072  } // end if the event is MC
1073 
1074 
1075  // add everything to the vectors
1076  mcVals .emplace_back(truthVars, weightVars, systVars);
1077 
1078  } // end loop over the CAF StandardRecords
1079 
1080  tf->Close();
1081 
1082  } // end loop over CAF file names
1083  }
1084 
1085  //......................................................................
1087  {
1088  this->InitializeEventListColls();
1089 
1090  cmf::MetaData md;
1092  float pdg = 0;
1093 
1094  std::vector<cmf::DataVarVals > dataVals;
1095  std::vector<cmf::MCVarVals > mcVals;
1096  std::vector<cmf::EventId > evIds;
1097  std::vector<cmf::SelectionType_t> sels;
1098 
1099  this->FillVariables(dataVals, mcVals, evIds, sels);
1100 
1101  LOG_VERBATIM("CAFToEventList")
1102  << "there are "
1103  << dataVals.size()
1104  << " data vals "
1105  << mcVals.size()
1106  << " mc vals "
1107  << evIds.size()
1108  << " event ids "
1109  << sels.size()
1110  << " selections ";
1111 
1112  auto periodToPOTItr = fPeriodToPOTLiveTime.begin();
1113 
1114  // need these *Vars for the cosmic muon files
1115  cmf::TruthVars tv;
1116  cmf::WeightVars wv;
1117 
1118  // loop over the event lists and add SpillSummary info
1119  for(auto & itr : fMDToEvents){
1120 
1121  auto const& md = itr.ListMetaData();
1123 
1124  periodToPOTItr = fPeriodToPOTLiveTime.find(md.Period());
1125 
1126  // multiply the weight for this period by the total POT
1127  // indicated in the list of CAF files used. We only
1128  // look at either FHC or RHC SAM datalists separately,
1129  // so we don't have to worry about separate accounting
1130  // for those
1131  if(periodToPOTItr != fPeriodToPOTLiveTime.end()){
1132  ss += cmf::SpillSummary(periodToPOTItr->second.pot,
1133  periodToPOTItr->second.pot,
1134  periodToPOTItr->second.liveTime,
1135  1,
1136  1);
1137 
1138  LOG_DEBUG("CAFTToEventList")
1139  << " checking spill summary to add "
1140  << ss
1141  << " "
1142  << periodToPOTItr->second.pot
1143  << " "
1144  << periodToPOTItr->second.liveTime;
1145  }
1146  else{
1147  LOG_WARNING("CAFToEventList")
1148  << md.ToString()
1149  << " could not find period "
1150  << md.Period()
1151  << " in POT weight map, just add zeros";
1152  }
1153 
1154  itr.AddSpillSummary(ss);
1155 
1156  LOG_VERBATIM("CAFToEventList")
1157  << "adding "
1158  << ss
1159  << " to "
1160  << md.ToString()
1161  << " "
1162  << itr.ListSpillSummary();
1163 
1164  } // end loop over the metadata to event lists map
1165 
1166  // now make event lists
1167  for(size_t i = 0; i < dataVals.size(); ++i){
1168 
1170 
1171  // figure out the interaction type and then get the correct metadata
1172  // for it
1174  it = cmf::kCosmicMuon;
1175  }
1176  else if(!fIsRealData){
1177  if( mcVals[i].val_at(cmf::kTrueCCNC) == 1. * simb::kNC )
1178  it = cmf::kNC;
1179  else{
1180  pdg = mcVals[i].val_at(cmf::kTruePDG);
1181  if (pdg == 12) it = cmf::kNuECC;
1182  else if(pdg == -12) it = cmf::kNuEBarCC;
1183  else if(pdg == 14) it = cmf::kNuMuCC;
1184  else if(pdg == -14) it = cmf::kNuMuBarCC;
1185  else if(pdg == 16) it = cmf::kNuTauCC;
1186  else if(pdg == -16) it = cmf::kNuTauBarCC;
1187  else it = cmf::kUncategorised;
1188  }
1189  } // end if neutrino MC
1190 
1191  md = cmf::MetaData(!fIsRealData,
1192  fDetector,
1193  fFileType,
1194  sels[i],
1195  it,
1196  this->RunToPeriod(evIds[i].run));
1197 
1198  // get an iterator to the event list for this md
1199  auto listItr = cmf::FindEventList(md, fMDToEvents);
1200  if(listItr == fMDToEvents.end())
1201  throw cet::exception("CMFCAFToEventList")
1202  << "cannot find metadata "
1203  << md.ToString()
1204  << " in event list";
1205 
1207  tv = cmf::TruthVars(mcVals[i].TruthVars());
1208  tv.fTrueE = 0. ;
1209  tv.fTruePDG = 13 ;
1210  tv.fTruePDGOrig = 13 ;
1211  tv.fTrueCCNC = 0. ;
1213 
1214  wv = cmf::WeightVars(mcVals[i].WeightVars());
1215  wv.fXSecCVPPFX_Weight = 1. ;
1216  wv.fRPACCQE_Weight = 1. ;
1217 
1218  mcVals[i] = cmf::MCVarVals(tv, wv, mcVals[i].SystematicShifts());
1219  listItr->AddEvent(evIds[i],
1220  dataVals[i],
1221  mcVals[i]);
1222  } // end if cosmic backgrounds
1223  else if(md.isMC){
1224  listItr->AddEvent(evIds[i],
1225  dataVals[i],
1226  mcVals[i]);
1227  }
1228  else
1229  listItr->AddEvent(evIds[i],
1230  dataVals[i]);
1231 
1232  LOG_DEBUG("CAFToEventList")
1233  << "add the event to "
1234  << md.ToString()
1235  << " "
1236  << i;
1237 
1238  } // end loop to insert events
1239 
1240 
1241  for(auto const& itr : fMDToEvents){
1242 
1243  auto const& md = itr.ListMetaData();
1244 
1245  LOG_VERBATIM("CAFToEventList")
1246  << "metadata "
1247  << md.ToString()
1248  << " has "
1249  << itr.ListSpillSummary()
1250  << " and "
1251  << itr.size()
1252  << " events";
1253 
1254  if(fMakeSelectedList){
1255  for(auto const& ev : itr){
1256  std::stringstream selectionOutput;
1257  selectionOutput << cmf::cSelectionType_Strings[md.selectionType]
1258  << "\t\t" << ev->EventID().run
1259  << "\t" << ev->EventID().subrun
1260  << "\t" << ev->EventID().event
1261  << "\t" << ev->EventID().slice
1262  << "\t" << ev->EventID().cycle
1263  << "\t" << ev->DataVals().val_at(cmf::kNu_RecoE, md)
1264  << "\t" << ev->DataVals().val_at(cmf::kNuE_CVN, md)
1265  << "\t";
1266  if(md.isMC)
1267  selectionOutput << ev->MCVals().val_at(cmf::kXSecCVPPFX_Weight);
1268 
1269  LOG_VERBATIM("SelectedEvents")
1270  << selectionOutput.str();
1271 
1272  } // end loop over events
1273  } // end if we are making a list of selected events
1274  }
1275 
1276  LOG_DEBUG("CAFToEventList")
1277  << "Serialize the events";
1278 
1280  fMDToEvents);
1281 
1282  LOG_DEBUG("CAFToEventList")
1283  << "endJob() done";
1284 
1285  }
1286 
1288 
1289 } // end cmf namespace
const SpillCut kStandardSpillCuts_FD_Prod4MotivatedDQ
Definition: SpillCuts.h:69
const Var kTruePDG
Definition: TruthVars.h:48
float fTruePDGOrig
true PDG of original neutrino
Definition: VarVals.h:50
POTLiveTime(double const &p, double const &l)
bool RunInPeriod(int run) const
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2142
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const Var kMode([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?-1:int(sr->mc.nu[0].mode);})
Neutrino interaction mode.
Definition: Vars.h:99
std::string fSpillTreeName
names of the Spill tree in the file
const NOvARwgtSyst kZExpEV2Syst2020("ZExpAxialFFSyst2020_EV2","CCQE z-exp EV shift #2", novarwgt::kZExpEV2Syst2020)
Definition: XSecSysts.h:57
const NOvARwgtSyst kDISvpNC2pi_2020("DISvpNC2pi_2020","DIS vpNC2pi", novarwgt::kDIS_NC_2pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:21
const DummyAnaSyst kAna2020NormFHC("NormFHC2020","FHC. Norm.")
PeriodRun(int period, int startRun, int endRun)
const ana::Var kRecoQ2([](const caf::SRProxy *sr){const double M_mu_sqrd=util::sqr(0.1056);double E_mu=kMuE(sr);double p_mu=sqrt(util::sqr(E_mu)-M_mu_sqrd);return 2 *kCCE(sr)*(E_mu-p_mu *kCosNumi(sr))-M_mu_sqrd;})
Reconstructed four-momentum transfer invariant (Q^2)
Definition: NumuVars.h:146
std::string fFHCQuantFileName
name of file in numudata ups product with FHC quantiles
fileName
Definition: plotROC.py:78
std::string fPOTHistName
names of the CAF histogram with the total POT
enum cmf::interaction_type InteractionType_t
bool fIsRealData
are we looking at real data?
const NOvARwgtSyst k2ndClassCurrs("2ndclasscurr","Second class currents", novarwgt::kSimpleSecondClassCurrentsSystKnob)
Second-class current syst. See documentation in NOvARwgt.
Definition: XSecSysts.h:71
void FillMCVals(cmf::TruthVars &truthVars, cmf::WeightVars &weightVars, cmf::SystVarColl &systVars, caf::SRProxy &srProxy) const
CAFToEventList(fhicl::ParameterSet const &pset)
const NOvARwgtSyst khNFSISyst2020_MFP("hNFSI_MFP_2020","hN FSI mean free path", novarwgt::khNFSISyst2020_MFP)
Definition: FSISysts.h:13
set< int >::iterator it
const NOvARwgtSyst kDISvnNC3pi_2020("DISvnNC3pi_2020","DIS vnNC3pi", novarwgt::kDIS_NC_3pluspi_nu_n_SystKnob_2020)
Definition: DISSysts.h:30
bool fMakeSelectedList
configure to true to make a list
void analyze(art::Event const &e) override
const std::string cSelectionType_Strings[12]
Definition: Constants.h:79
const NOvARwgtSyst kDISvbarpCC2pi_2020("DISvbarpCC2pi_2020","DIS vbarpCC2pi", novarwgt::kDIS_CC_2pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:33
bool PassesSelections(caf::SRProxy const &proxy) const
long Period() const
Definition: Structs.h:128
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
void Initialize(fhicl::ParameterSet const &pset)
caf::Proxy< unsigned int > subrun
Definition: SRProxy.h:253
const NOvARwgtSyst kDISvbarpNC3pi_2020("DISvbarpNC3pi_2020","DIS vbarpNC3pi", novarwgt::kDIS_NC_3pluspi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:38
const NOvARwgtSyst kDISvbarnNC3pi_2020("DISvbarnNC3pi_2020","DIS vbarnNC3pi", novarwgt::kDIS_NC_3pluspi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:46
float fPPFXFluxCV_Weight
For 2020 Ana, store weights seperately.
Definition: VarVals.h:159
float fTrueHitNuc
true hit nucleus
Definition: VarVals.h:56
const Cut kNue2020PID([](const caf::SRProxy *sr){if(kIsRHC(sr)) return kNue2020PIDRHC(sr);else return kNue2020PIDFHC(sr);})
Definition: NueCuts2020.h:61
const NOvARwgtSyst kDISvbarpCC0pi_2020("DISvbarpCC0pi_2020","DIS vbarpCC0pi", novarwgt::kDIS_CC_0pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:31
float fTrueCCNC
true cc vs nc
Definition: VarVals.h:48
const NOvARwgtSyst kDISvbarnCC2pi_2020("DISvbarnCC2pi_2020","DIS vbarnCC2pi", novarwgt::kDIS_CC_2pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:41
bool PassesNumuSelections(caf::SRProxy const &proxy) const
const NOvARwgtSyst kDISvnNC2pi_2020("DISvnNC2pi_2020","DIS vnNC2pi", novarwgt::kDIS_NC_2pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:29
float fTrueParentDecay
true parent decay mode
Definition: VarVals.h:54
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2136
float fTruePDG
true PDG
Definition: VarVals.h:47
const NOvARwgtSyst kMECShapeSyst2020Nu("MECShape2020Nu","MEC 2020 (q_{0}, |#vec{q}|) response, neutrinos", novarwgt::kMECQ0Q3RespSyst2020_NuOnly)
Definition: MECSysts.h:11
double liveTime
Definition: Structs.h:187
const NOvARwgtSyst kDISvpCC0pi_2020("DISvpCC0pi_2020","DIS vpCC0pi", novarwgt::kDIS_CC_0pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:15
const NOvARwgtSyst kDISvnCC1pi_2020("DISvnCC1pi_2020","DIS vnCC1pi", novarwgt::kDIS_CC_1pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:24
const NOvARwgtSyst kDISvbarnNC2pi_2020("DISvbarnNC2pi_2020","DIS vbarnNC2pi", novarwgt::kDIS_NC_2pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:45
const char * p
Definition: xmltok.h:285
const Cut kNus20FDSelectionCuts
Definition: NusCuts20.h:168
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2125
const NOvARwgtSyst kDISvpCC2pi_2020("DISvpCC2pi_2020","DIS vpCC2pi", novarwgt::kDIS_CC_2pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:17
const NOvARwgtSyst kDISvpCC3pi_2020("DISvpCC3pi_2020","DIS vpCC3pi", novarwgt::kDIS_CC_3pluspi_nu_p_SystKnob_2020)
Definition: DISSysts.h:18
const NOvARwgtSyst kDISvbarpNC1pi_2020("DISvbarpNC1pi_2020","DIS vbarpNC1pi", novarwgt::kDIS_NC_1pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:36
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:617
const NuTruthSystComponentScale kTauScaleSyst("NuTauScale","#nu_{#tau} Scale", kIsTau_NT &&!kIsNC_NT, 0.6, NuTruthSystComponentScale::kLinear)
100% uncertainty scale on taus
Definition: Systs.h:176
vector< vector< double > > clear
const Cut kNumu2020ND
Definition: NumuCuts2020.h:57
std::map< int, POTLiveTime > fPeriodToPOTLiveTime
keep track of the POT in each period
cmf::SelectionType_t FindSelectionType(caf::SRProxy const &srProxy) const
std::string fCAFRecTreeName
names of the CAF tree with the reco info
Float_t ss
Definition: plot.C:24
const double kNue2020CVNRHCHighEdge
Definition: NueCuts2020.h:53
std::vector< ana::Cut > fNumuFHCQuantCuts
quantile boundaries for the numu FHC data
cmf::EventListColl::iterator FindEventList(cmf::MetaData const &md, cmf::EventListColl &eventListColl)
Definition: Event.cxx:44
enum cmf::det_type DetType_t
float fTrueParentPT
true p_T of neutrino parent
Definition: VarVals.h:52
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
const NOvARwgtSyst kDISvbarnCC0pi_2020("DISvbarnCC0pi_2020","DIS vbarnCC0pi", novarwgt::kDIS_CC_0pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:39
unsigned int run
run number
Definition: SRSpill.h:25
void FillEventId(cmf::EventId &evId, caf::SRProxy const &srProxy) const
enum cmf::sel_type SelectionType_t
const NeutronVisEScaleSyst2018 kNeutronVisEScalePrimariesSyst2018(false)
DEFINE_ART_MODULE(TestTMapFile)
Timing fit.
const Cut kIsFarDet([](const caf::SRProxy *sr){return sr->hdr.det==caf::kFARDET;})
Definition: Cuts.h:94
const DummyAnaSyst kAna2020NormRHC("NormRHC2020","RHC. Norm.")
const HistAxis kNumuCCOptimisedAxis2020("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kNumuE2020)
Definition: HistAxes.h:25
const NOvARwgtSyst khNFSISyst2020_EV3("hNFSI_FateFracEV3_2020","hN FSI fate fraction eigenvector #3", novarwgt::khNFSISyst2020_EV3)
Definition: FSISysts.h:12
std::string find_file(std::string const &filename) const
const Cut kNue2020ND
Definition: NueCuts2020.h:178
const NOvARwgtSyst kDISvbarpNC2pi_2020("DISvbarpNC2pi_2020","DIS vbarpNC2pi", novarwgt::kDIS_NC_2pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:37
const NOvARwgtSyst kDISvbarpNC0pi_2020("DISvbarpNC0pi_2020","DIS vbarpNC0pi", novarwgt::kDIS_NC_0pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:35
const NOvARwgtSyst kDISvbarnNC0pi_2020("DISvbarnNC0pi_2020","DIS vbarnNC0pi", novarwgt::kDIS_NC_0pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:43
float fTrueE
True nu energy.
Definition: VarVals.h:46
float abs(float number)
Definition: d0nt_math.hpp:39
cmf::DetType_t fDetector
which detector are we using
const Var kTruetpT([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:util::pythag(sr->mc.nu[0].beam.tp.X(), sr->mc.nu[0].beam.tp.Y());})
True neutrino ancestor (off-target) pT.
Definition: Vars.h:102
const Cut kNus20QualityCuts
Definition: NusCuts20.h:41
caf::Proxy< unsigned int > run
Definition: SRProxy.h:247
const Var kHitNuc
Definition: TruthVars.h:19
std::vector< cmf::PeriodRun > fPeriodRuns
vector of periods to runs
const NOvARwgtSyst kRadCorrNuebar("radcorrnuebar","Radiative corrections for #bar{#nu}_{e}", novarwgt::kSimpleRadiativeCorrNuebarXsecSystKnob)
Radiative corrections syst (nuebars). See documentation in NOvARwgt.
Definition: XSecSysts.h:67
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
const Cut kNus20NDCuts
Definition: NusCuts20.h:102
cmf::FileType_t fFileType
get from the configuration for now
const NOvARwgtSyst kDISvnCC2pi_2020("DISvnCC2pi_2020","DIS vnCC2pi", novarwgt::kDIS_CC_2pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:25
void reconfigure(fhicl::ParameterSet const &p)
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:342
cmf::EventListColl fMDToEvents
each entry in the vector is for a single slice
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
const NOvARwgtSyst kFormZone_2020("FormZone2020","DIS Formation Zone", novarwgt::kFormZoneSyst2020)
Definition: DISSysts.h:7
caf::Proxy< bool > isFHC
Definition: SRProxy.h:1374
const XML_Char * s
Definition: expat.h:262
static ParameterUtility * Instance()
unsigned int subrun
subrun number
Definition: SRSpill.h:26
static uint8_t VarNameToKey(std::string const &name)
Definition: StaticFuncs.h:385
const double kNue2020CVNFHCHighEdge
Definition: NueCuts2020.h:48
int subrun
Definition: VarVals.h:84
const Cut kNumu2020PID([](const caf::SRProxy *sr){return(sr->sel.remid.pid > 0.30 && sr->sel.cvnloosepreselptp.numuid > 0.80);})
Definition: NumuCuts2020.h:21
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
float fTrueParentPDG
true PDG of neutrino parent
Definition: VarVals.h:51
const Cut kNus20NDFiducialCuts
Definition: NusCuts20.h:88
float fRPACCQE_Weight
To be used for systematic evaluation ONLY.
Definition: VarVals.h:151
std::string fSystType
systematic type
const NOvARwgtSyst kDISvbarpCC3pi_2020("DISvbarpCC3pi_2020","DIS vbarpCC3pi", novarwgt::kDIS_CC_3pluspi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:34
const NOvARwgtSyst kZExpEV1Syst2020("ZExpAxialFFSyst2020_EV1","CCQE z-exp EV shift #1", novarwgt::kZExpEV1Syst2020)
Definition: XSecSysts.h:56
cmf::SelectionType_t selectionType
Definition: Structs.h:116
const Cut sels[kNumSels]
Definition: vars.h:44
const Cut kNue2020NDContain([](const caf::SRProxy *sr){for(unsigned int ix=0;ix< sr->vtx.elastic.fuzzyk.nshwlid;++ix){const caf::SRVector3DProxy &start=sr->vtx.elastic.fuzzyk.png[ix].shwlid.start;const caf::SRVector3DProxy &stop=sr->vtx.elastic.fuzzyk.png[ix].shwlid.stop;if(std::min(start.X(), stop.X())< -150.0) return false;if(std::max(start.X(), stop.X()) > 170.0) return false;if(std::min(start.Y(), stop.Y())< -170.0) return false;if(std::max(start.Y(), stop.Y()) > 150.0) return false;if(std::min(start.Z(), stop.Z())< 100.0) return false;if(std::max(start.Z(), stop.Z()) > 1225.0) return false;}if(sr->sel.contain.nplanestofront< 10) return false;return true;})
Definition: NueCuts2020.h:167
caf::Proxy< short unsigned int > subevt
Definition: SRProxy.h:249
int cycle
Definition: VarVals.h:86
std::set< cmf::SelectionType_t > fSelections
Selections to use.
const Var kTruetpz([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].beam.tp.z);})
True neutrino ancestor (off-target) pz.
Definition: Vars.h:105
const NOvARwgtSyst khNFSISyst2020_EV1("hNFSI_FateFracEV1_2020","hN FSI fate fraction eigenvector #1", novarwgt::khNFSISyst2020_EV1)
Definition: FSISysts.h:10
const Cut kNus20FDCosRejCuts
Definition: NusCuts20.h:171
const Cut kNue2020NDPresel
Definition: NueCuts2020.h:169
const HistAxis kHadEFracAxis2020("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kNumuHadEFrac2020)
Definition: HistAxes.h:31
const NOvARwgtSyst kMECInitStateNPFracSyst2020AntiNu("MECInitStateNPFrac2020AntiNu","MEC initial state np fraction, antineutrinos", novarwgt::kMECInitStateNPFracSyst2020_NubarOnly)
Definition: MECSysts.h:18
const Cut kNumuContainFD2020
Definition: NumuCuts2020.h:42
T get(std::string const &key) const
Definition: ParameterSet.h:231
const NOvARwgtSyst kDISvbarpCC1pi_2020("DISvbarpCC1pi_2020","DIS vbarpCC1pi", novarwgt::kDIS_CC_1pi_nubar_p_SystKnob_2020)
Definition: DISSysts.h:32
void set_val_at(uint8_t const &varkey, float const &val)
Definition: VarVals.cxx:189
std::vector< ana::Cut > fNumuRHCQuantCuts
quantile boundaries for the numu RHC data
const Var kCCE
Definition: NumuVars.h:21
std::vector< std::string > fCAFFileNames
name of the CAF file we are using
const NOvARwgtSyst kDISvnCC0pi_2020("DISvnCC0pi_2020","DIS vnCC0pi", novarwgt::kDIS_CC_0pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:23
unsigned int evt
ART event number, indexes trigger windows.
Definition: SRSpill.h:27
static cmf::DetType_t StringToDetectorType(std::string const &str)
Definition: StaticFuncs.h:275
const NOvARwgtSyst kDISvbarnNC1pi_2020("DISvbarnNC1pi_2020","DIS vbarnNC1pi", novarwgt::kDIS_NC_1pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:44
caf::StandardRecord * sr
caf::Proxy< int > cycle
Definition: SRProxy.h:229
float fXSecCV2020_Weight
For 2020 Ana, store weights seperately.
Definition: VarVals.h:158
bool PassesNueSelections(caf::SRProxy const &proxy) const
int slice
Definition: VarVals.h:87
const NOvARwgtSyst kZExpEV4Syst2020("ZExpAxialFFSyst2020_EV4","CCQE z-exp EV shift #4", novarwgt::kZExpEV4Syst2020)
Definition: XSecSysts.h:59
const ana::Var wgt
const Cut kNumu2020CosRej([](const caf::SRProxy *sr){return(sr->sel.cosrej.numucontpid2020 > 0.45);})
Definition: NumuCuts2020.h:22
const NOvARwgtSyst kRPACCQEEnhSyst2020("RPAShapeenh2020","RPA shape: higher-Q^{2} enhancement (2020)", novarwgt::kRPACCQEEnhSyst2020)
Definition: RPASysts.h:17
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:383
const Cut kNus20NDSelectionCuts
Definition: NusCuts20.h:99
const NOvARwgtSyst kCOHCCScaleSyst2018("COHCCScale2018","Coherent CC Scale", novarwgt::kCOHNormCCSystKnob)
20% uncertainty scale on coherent CC events. See documentation in NOvARwgt
Definition: XSecSysts.h:40
const NOvARwgtSyst kDISvbarnCC3pi_2020("DISvbarnCC3pi_2020","DIS vbarnCC3pi", novarwgt::kDIS_CC_3pluspi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:42
const Var kNMichels([](const caf::SRProxy *sr){int n_me=0;for(int i=0;i< (int) sr->me.nslc;i++) if(sr->me.slc[i].mid > 1. &&sr->me.slc[i].deltat > 1200.) n_me++;for(int i=0;i< (int) sr->me.nkalman;i++) if(sr->me.trkkalman[i].mid > 0. &&sr->me.trkkalman[i].deltat > 800.) n_me++;if(n_me > 2) n_me=2;return n_me;})
Number of SlcME&#39;s assoc with slice.
Definition: Vars.h:85
float fXSecCVPPFX_Weight
Was Tufts weight for SA.
Definition: VarVals.h:150
float fTrueParentPZ
true p_Z of neutrino parent
Definition: VarVals.h:53
const NOvARwgtSyst kRESLowQ2SuppressionSyst2020("LowQ2RESSupp2020","RES low-Q^2 suppression", novarwgt::kRESLowQ2SuppressionSyst2020)
Definition: RESSysts.h:10
Definition: run.py:1
const MichelTaggingSyst2020 kMichelTaggingSyst2020
const Var kHADE_2020([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;const double CVNha_CalE=sr->slc.calE;return std::max(CVNha_CalE-kEME_2020(sr), 0.);})
Definition: NueEnergy2020.h:15
#define LOG_WARNING(category)
std::vector< cmf::SystVar > SystVarColl
Definition: VarVals.h:223
void SerializeEventListColl(std::string const &dirName, cmf::EventListColl const &listColl)
Definition: Event.cxx:117
const NOvARwgtSyst kZExpEV3Syst2020("ZExpAxialFFSyst2020_EV3","CCQE z-exp EV shift #3", novarwgt::kZExpEV3Syst2020)
Definition: XSecSysts.h:58
const NOvARwgtSyst khNFSISyst2020_EV2("hNFSI_FateFracEV2_2020","hN FSI fate fraction eigenvector #2", novarwgt::khNFSISyst2020_EV2)
Definition: FSISysts.h:11
caf::Proxy< unsigned int > evt
Definition: SRProxy.h:236
bool PassesNCSelections(caf::SRProxy const &proxy) const
float livetime
Length of readout [s].
Definition: SRSpill.h:40
std::string ToString() const
Definition: Structs.cxx:133
Module to combine a set of results into a single file currently only does one data product type at a ...
Definition: Event.cxx:24
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2137
const Cut kNue2020RecoQuality([](const caf::SRProxy *sr){if(sr->sel.nuecosrej.hitsperplane >=8) return false;if(!sr->vtx.elastic.IsValid) return false;if(sr->vtx.elastic.fuzzyk.npng==0) return false;return true;})
Definition: NueCuts2020.h:16
std::vector< cmf::EventList > EventListColl
Definition: Event.h:147
The StandardRecord is the primary top-level object in the Common Analysis File trees.
const NOvARwgtSyst kCOHNCScaleSyst2018("COHNCScale2018","Coherent NC Scale", novarwgt::kCOHNormNCSystKnob)
20% uncertainty scale on coherent NC events. See documentation in NOvARwgt
Definition: XSecSysts.h:43
void FillDataVarVals(cmf::DataVarVals &dataVals, caf::SRProxy const &srProxy) const
const NOvARwgtSyst kMECInitStateNPFracSyst2020Nu("MECInitStateNPFrac2020Nu","MEC initial state np fraction, neutrinos", novarwgt::kMECInitStateNPFracSyst2020_NuOnly)
Definition: MECSysts.h:17
const NOvARwgtSyst kMECShapeSyst2020AntiNu("MECShape2020AntiNu","MEC 2020 (q_{0}, |#vec{q}|) response, antineutrinos", novarwgt::kMECQ0Q3RespSyst2020_NubarOnly)
Definition: MECSysts.h:12
const PileupMuESyst2020 kPileupMuESyst2020(0.46, 1.3)
const NOvARwgtSyst kRPACCQESuppSyst2020("RPAShapesupp2020","RPA shape: low-Q^{2} suppression (2020)", novarwgt::kRPACCQESuppSyst2020)
Definition: RPASysts.h:18
const NOvARwgtSyst kMECEnuShapeSyst2020AntiNu("MECEnuShape2020AntiNu","MEC E_{#nu} shape, antineutrinos", novarwgt::kMECEnuShapeSyst2020_NubarOnly)
Definition: MECSysts.h:15
void FillVariables(std::vector< cmf::DataVarVals > &dataVals, std::vector< cmf::MCVarVals > &mcVals, std::vector< cmf::EventId > &evIds, std::vector< cmf::SelectionType_t > &sels)
bool PassesSpillAndBeamCuts(caf::SRProxy const &proxy) const
const NOvARwgtSyst kDISvpCC1pi_2020("DISvpCC1pi_2020","DIS vpCC1pi", novarwgt::kDIS_CC_1pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:16
caf::Proxy< bool > ismc
Definition: SRProxy.h:241
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const CorrMuEScaleSyst2020 kCorrMuEScaleSyst2020(0.0074, 0.0074, 0.0013)
const UnCorrNDMuEScaleSyst2020 kUnCorrNDMuEScaleSyst2020(0.0013)
bool fIsFHC
are we looking at FHC files?
const NOvARwgtSyst kDISvnCC3pi_2020("DISvnCC3pi_2020","DIS vnCC3pi", novarwgt::kDIS_CC_3pluspi_nu_n_SystKnob_2020)
Definition: DISSysts.h:26
std::string fRHCQuantFileName
name of file in numudata ups product with FHC quantiles
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
float spillpot
Definition: SRSpill.h:38
#define LOG_VERBATIM(category)
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void operator+=(POTLiveTime const &o)
const Cut kNumuQuality
Definition: NumuCuts.h:18
const NOvARwgtSyst kDISvnNC0pi_2020("DISvnNC0pi_2020","DIS vnNC0pi", novarwgt::kDIS_NC_0pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:27
const Cut kNue2020FDAllSamples_ML
Float_t e
Definition: plot.C:35
const Cut kNus20FDCuts_ML
const UnCorrMuCatMuESyst2020 kUnCorrMuCatMuESyst2020(0.0048)
const NOvARwgtSyst kDISvnNC1pi_2020("DISvnNC1pi_2020","DIS vnNC1pi", novarwgt::kDIS_NC_1pi_nu_n_SystKnob_2020)
Definition: DISSysts.h:28
unsigned int fNumQuantiles
number of quantiles
float fTrueIntType
true interaction type
Definition: VarVals.h:49
const NOvARwgtSyst * GetGenieKnobSyst(rwgt::ReweightLabel_t knobIdx, std::string altName, std::string altLabel)
Convenience function to get a GENIE knob syst. (Allows using the GENIE knob name & description as the...
Definition: XSecSysts.cxx:119
const NOvARwgtSyst kDISvpNC3pi_2020("DISvpNC3pi_2020","DIS vpNC3pi", novarwgt::kDIS_NC_3pluspi_nu_p_SystKnob_2020)
Definition: DISSysts.h:22
const NOvARwgtSyst kDISvpNC0pi_2020("DISvpNC0pi_2020","DIS vpNC0pi", novarwgt::kDIS_NC_0pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:19
const Cut kNue2020FDPeripheral(kNue2020FDPeripheralFunc)
const Var kCVNe_looseptp
Definition: Vars.cxx:36
const NOvARwgtSyst kRadCorrNue("radcorrnue","Radiative corrections for #nu_{e}", novarwgt::kSimpleRadiativeCorrNueXsecSystKnob)
Radiative corrections syst (nues). See documentation in NOvARwgt.
Definition: XSecSysts.h:64
const Cut kNumuContainND2020([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.nshwlid;++i){const caf::SRVector3DProxy &start=sr->vtx.elastic.fuzzyk.png[i].shwlid.start;const caf::SRVector3DProxy &stop=sr->vtx.elastic.fuzzyk.png[i].shwlid.stop;if(std::min(start.X(), stop.X())< -180.0) return false;if(std::max(start.X(), stop.X()) > 180.0) return false;if(std::min(start.Y(), stop.Y())< -180.0) return false;if(std::max(start.Y(), stop.Y()) > 180.0) return false;if(std::min(start.Z(), stop.Z())< 40.0) return false;if(std::max(start.Z(), stop.Z()) > 1525.0) return false;}if(sr->trk.kalman.ntracks< 1) return false;for(unsigned int i=0;i< sr->trk.kalman.ntracks;++i){if(i==sr->trk.kalman.idxremid) continue;else if(sr->trk.kalman.tracks[i].start.Z() > 1275||sr->trk.kalman.tracks[i].stop.Z() > 1275) return false;}return(sr->trk.kalman.ntracks > sr->trk.kalman.idxremid &&sr->slc.firstplane > 1 &&sr->slc.lastplane< 212 &&sr->trk.kalman.tracks[0].start.Z()< 1100 &&(sr->trk.kalman.tracks[0].stop.Z()< 1275 ||sr->sel.contain.kalyposattrans< 55) &&sr->sel.contain.kalfwdcellnd > 5 &&sr->sel.contain.kalbakcellnd > 10);})
Definition: NumuCuts2020.h:31
const Cut kNumu2020FD_ML
float fTrueIntMode
true interaction mode
Definition: VarVals.h:57
int event
Definition: VarVals.h:85
const NOvARwgtSyst kDISvpNC1pi_2020("DISvpNC1pi_2020","DIS vpNC1pi", novarwgt::kDIS_NC_1pi_nu_p_SystKnob_2020)
Definition: DISSysts.h:20
const Var kEME_2020([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;double CVNem_CalE=0.0;const caf::SRFuzzyKProngProxy &prim_png=sr->vtx.elastic.fuzzyk.png[0];for(const caf::SRFuzzyKProngProxy &png:sr->vtx.elastic.fuzzyk.png){double png_CalE=png.shwlid.calE;double emPID=((double) png.cvnpart.photonid+ (double) png.cvnpart.pizeroid+ (double) png.cvnpart.electronid);double haPID=((double) png.cvnpart.protonid+ (double) png.cvnpart.pionid+ (double) png.cvnpart.neutronid+ (double) png.cvnpart.otherid+ (double) png.cvnpart.muonid);if(emPID< 0) continue;if(emPID >=haPID ) CVNem_CalE+=png_CalE;else continue;}if(kLongestProng(sr) >=500) CVNem_CalE=prim_png.shwlid.calE;return CVNem_CalE;})
Definition: NueEnergy2020.h:14
const Var kNumuMuE2020
Definition: NumuEFxs.h:198
const NOvARwgtSyst kDISvbarnCC1pi_2020("DISvbarnCC1pi_2020","DIS vbarnCC1pi", novarwgt::kDIS_CC_1pi_nubar_n_SystKnob_2020)
Definition: DISSysts.h:40
float fTrueParentTargetPDG
true parent pdg code off the target
Definition: VarVals.h:55
detName
Definition: mkDefs.py:106
const Var kNumuHadE2020
Definition: NumuEFxs.h:199
const Cut kNus20FDMinSliceDistCut
Definition: NusCuts20.h:153
const Var kXSecCVWgt2020
Definition: XsecTunes.h:106
const NOvARwgtSyst kMECEnuShapeSyst2020Nu("MECEnuShape2020Nu","MEC E_{#nu} shape, neutrinos", novarwgt::kMECEnuShapeSyst2020_NuOnly)
Definition: MECSysts.h:14
GeniePCASyst * GetGeniePrincipals2020Small(int PCIdx)
enum cmf::file_type FileType_t
enum BeamMode string