All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenNuFilter_module.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
4 #include "TGeoManager.h"
5 
6 #include "art/Framework/Core/EDFilter.h"
7 #include "art/Framework/Core/ModuleMacros.h"
8 #include "art/Framework/Principal/Event.h"
9 #include "nusimdata/SimulationBase/MCTruth.h"
10 #include "nusimdata/SimulationBase/MCNeutrino.h"
12 
13 namespace filt{
14 
15  class GenNuFilter : public art::EDFilter {
16  public:
17  explicit GenNuFilter(fhicl::ParameterSet const & pset);
18  virtual bool filter(art::Event& e) override;
19  void reconfigure(fhicl::ParameterSet const& pset);
20  virtual void beginJob() override;
21 
22  private:
23 
24  bool fVtxInTPC;
25  std::vector<int> fLepPDGs;
26  bool fCC;
27  bool fNC;
28 
29  };
30 
31 
32  GenNuFilter::GenNuFilter(fhicl::ParameterSet const & pset)
33  : EDFilter(pset)
34  {
35  this->reconfigure(pset);
36 
37  }
38 
39 
40  void GenNuFilter::reconfigure(fhicl::ParameterSet const& pset){
41  fVtxInTPC = pset.get<bool>("VtxInTPC");
42  fLepPDGs = pset.get<std::vector<int>>("LepPDGs");
43  fCC = pset.get<bool>("CC");
44  fNC = pset.get<bool>("NC");
45  }
46 
47 
48  bool GenNuFilter::filter(art::Event & e){
49  //std::vector< art::Handle< std::vector<simb::MCTruth> > > mclists;
50  //e.getManyByType(mclists);
51  auto mclists = e.getMany< std::vector<simb::MCTruth> >();
52  for (unsigned int i = 0; i < mclists.size() ; i++){
53  for (unsigned int j = 0; j < mclists[i]->size(); j++){
54  //Should have the truth record for the event now
55  const art::Ptr<simb::MCTruth> mc_truth(mclists[i],j);
56  if(mc_truth->Origin() == simb::kBeamNeutrino){
57  simb::MCNeutrino nu = mc_truth->GetNeutrino();
58  // Check vertex in TPC
59  double vtxX = nu.Nu().Vx();
60  double vtxY = nu.Nu().Vy();
61  double vtxZ = nu.Nu().Vz();
62  TVector3 vtx(vtxX, vtxY, vtxZ);
63  if(fVtxInTPC && !RecoUtils::IsInsideTPC(vtx, 0)) continue;
64  // Check if CC or NC specified
65  if(!(fCC && fNC)){
66  if(fCC && nu.CCNC() == simb::kNC) continue;
67  if(fNC && nu.CCNC() == simb::kCC) continue;
68  }
69  // Check which flavour of interaction
70  int lepPdg = nu.Lepton().PdgCode();
71  if(fLepPDGs.size() > 0){
72  if(fLepPDGs[0] != 0){
73  if(std::find(fLepPDGs.begin(), fLepPDGs.end(), lepPdg) == fLepPDGs.end()) continue;
74  }
75  }
76  return true;
77  }
78  }
79  }
80 
81  return false;
82  }
83 
84 
86  }
87 
88 
89  DEFINE_ART_MODULE(GenNuFilter)
90 
91 }
std::vector< int > fLepPDGs
GenNuFilter(fhicl::ParameterSet const &pset)
virtual bool filter(art::Event &e) override
Charged-current interactions.
Definition: IPrediction.h:38
void reconfigure(fhicl::ParameterSet const &pset)
then filt
do i e
Neutral-current interactions.
Definition: IPrediction.h:39
virtual void beginJob() override
BEGIN_PROLOG SN nu
bool IsInsideTPC(TVector3 position, double distance_buffer)