All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NueSelection.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <TH2D.h>
4 #include "fhiclcpp/ParameterSet.h"
5 #include "gallery/ValidHandle.h"
6 #include "canvas/Utilities/InputTag.h"
7 #include "nusimdata/SimulationBase/MCTruth.h"
8 #include "nusimdata/SimulationBase/MCNeutrino.h"
9 #include "core/Event.hh"
10 #include "NueSelection.h"
11 #include "Utilities.h"
12 
13 namespace ana {
14  namespace SBNOsc {
15 
16 NueSelection::NueSelection() : SelectionBase(), fEventCounter(0), fNuCount(0) {}
17 
18 
19 void NueSelection::Initialize(fhicl::ParameterSet* config) {
20  // Load configuration parameters
21  fTruthTag = { "generator" };
22 
23  fhicl::ParameterSet pconfig = config->get<fhicl::ParameterSet>("SBNOsc");
24 
25  if (config) {
26  fTruthTag = { pconfig.get<std::string>("MCTruthTag", "generator") };
27  }
28 
29  hello();
30 }
31 
32 
34 
35 
36 bool NueSelection::ProcessEvent(const gallery::Event& ev, const std::vector<event::Interaction> &truth, std::vector<event::RecoInteraction>& reco) {
37  if (fEventCounter % 10 == 0) {
38  std::cout << "NueSelection: Processing event " << fEventCounter << " "
39  << "(" << fNuCount << " neutrinos selected)"
40  << std::endl;
41  }
42  fEventCounter++;
43 
44  // Grab a data product from the event
45  auto const& mctruths = \
46  *ev.getValidHandle<std::vector<simb::MCTruth> >(fTruthTag);
47 
48  // Iterate through the neutrinos
49  for (size_t i=0; i<mctruths.size(); i++) {
50  auto const& mctruth = mctruths.at(i);
51  const simb::MCNeutrino& nu = mctruth.GetNeutrino();
52 
53  if (nu.CCNC() == simb::kCC && nu.Mode() == 0 && nu.Nu().PdgCode() == 12) {
54  event::RecoInteraction interaction(i);
55  reco.push_back(interaction);
56  }
57  }
58 
59  bool selected = !reco.empty();
60 
61  if (selected) {
62  fNuCount++;
63  }
64 
65  return selected;
66 }
67 
68  } // namespace SBNOsc
69 } // namespace ana
70 
71 
73 
void Initialize(fhicl::ParameterSet *config=NULL)
unsigned fNuCount
Count selected events.
Definition: NueSelection.h:52
process_name opflashCryoW ana
Charged-current interactions.
Definition: IPrediction.h:38
Contains truth level information and additional fields for selection-defined reconstruction informati...
Definition: Event.hh:178
process_name standard_reco_uboone reco
unsigned fEventCounter
Count processed events.
Definition: NueSelection.h:51
#define DECLARE_SBN_PROCESSOR(classname)
Electron neutrino event selection.
Definition: NueSelection.h:26
bool ProcessEvent(const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
art::InputTag fTruthTag
art tag for MCTruth information
Definition: NueSelection.h:55
BEGIN_PROLOG SN nu
BEGIN_PROLOG could also be cout