RecoJMShowerFilter_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 /// \brief Example to use RecoJMShower
3 /// for particle identification
4 /// \author bianjm@.physics.umn.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <cmath>
8 #include <iostream>
9 #include <fstream>
10 #include <string>
11 #include <vector>
12 
13 // ROOT includes
14 #include "TLorentzVector.h"
15 #include "TVector3.h"
16 
17 // ART includes
25 
26 // NOvA includes
27 #include "Geometry/Geometry.h"
28 #include "RecoJMShower/JMShower.h"
31 
32 
33 namespace jmshower {
34 
36  public:
37  explicit RecoJMShowerFilter(fhicl::ParameterSet const& pset);
38  virtual ~RecoJMShowerFilter();
39  virtual bool filter(art::Event & evt);
40 
41  void beginJob();
42  bool beginSubRun(art::SubRun& sr);
43  void reconfigure(const fhicl::ParameterSet& pset);
44 
45  std::string fPotLabel; ///< Module that produced the POTSum object
46 
47  int fNJMShower;
48  int fEvtNuPdg;
49  int fEvtCCNC;
50 
51  };
52 }
53 
54 
55 namespace jmshower{
56  //_________________________________________________________________________
57 
59  {
60  reconfigure(pset);
61  }
62 
63  //......................................................................
64 
66  {
67  fPotLabel = pset.get< std::string>("PotLabel");
68  fNJMShower = pset.get<int>("NJMShower");
69  fEvtNuPdg = pset.get<int>("EvtNuPdg");
70  fEvtCCNC = pset.get<int>("EvtCCNC");
71  }
72 
73  //......................................................................
74 
76  {
77  }
78 
79  //......................................................................
80 
82  {
83  }
85  // art::Handle< sumdata::POTSum > p;
86  // sr.getByLabel(fPotLabel,p);
87  // std::cout<<"pot = "<<p->totgoodpot<<std::endl;
88  return true;
89  }
90  //......................................................................
92  {
93  //----------------------------------------------------
94  // Run, subrun and event information
95  //----------------------------------------------------
96  // int run = evt.run();
97  // int srun = evt.subRun();
98  // int event = evt.id().event();
100  //------------------------------------------------------------------------
101  // MC true information
102  //----------------------------------------------------------------------
103 
104 
105  //Neutrino MC truth
106 
107  TLorentzVector evtTrueNuP4(0,0,0,0);
108  TVector3 evtTrueNuVtx(0,0,-100);
109  int evtTrueNuCCNC = -1;
110  // int evtTrueNuMode = -1;
111  int evtTrueNuPdg = 0;
112 
113 
114  if(!evt.isRealData()){
116  try {
117  evt.getByLabel("generator", mc);
118  if (mc->size()!=1) return false;
119  }
120  catch (...) {
121  return false;
122  }
123  if ((*mc)[0].NeutrinoSet()) {
124  const simb::MCNeutrino& gen = (*mc)[0].GetNeutrino();
125  const simb::MCParticle& nu = gen.Nu();
126  evtTrueNuP4 = nu.Momentum();
127  evtTrueNuVtx.SetXYZ(nu.EndX(),nu.EndY(),nu.EndZ());
128  evtTrueNuCCNC = gen.CCNC() ;
129  // evtTrueNuMode = gen.Mode() ;
130  evtTrueNuPdg = nu.PdgCode() ;
131  std::cout<<"Nuetrino, Energy "<<nu.PdgCode()<<" "<<evtTrueNuP4.E()<<std::endl;
132  std::cout<<"CCNC, Mode "<<gen.CCNC()<<" "<<gen.Mode()<<std::endl;
133  enum simb::int_type_ outMode = (enum simb::int_type_) gen.Mode();
134 // enum simb::int_type_ outMode1 = (enum simb::int_type_) InteractionType();
135  std::cout<<"Mode enum "<<outMode<<std::endl;
136 // std::cout<<"Type enum "<<outMode1<<std::endl;
137  }
138  if(evtTrueNuPdg!=fEvtNuPdg) return false;
139  if(evtTrueNuCCNC!=fEvtCCNC) return false;
140  }
141 
142  std::cout<<"before veto evtTrueNuPdg,evtTrueNuCCNC,recoshowercol.size "<<evtTrueNuPdg<<" "<<evtTrueNuCCNC<<" "<<std::endl;
143 
144 
145 // if(evtTrueNuMode!=3) return false;
146 
148  evt.getByLabel("recojmshower", showerhandle);
149  std::vector<art::Ptr<jmshower::JMShower> > svcshowercol;
150  for(unsigned int i = 0; i < showerhandle->size(); i++){
151  art::Ptr<jmshower::JMShower> p(showerhandle, i);
152  svcshowercol.push_back(p);
153  }
154 
155  std::cout<<"Pdg, CCNC, size "<<evtTrueNuPdg<<" "<<evtTrueNuCCNC<<" "<<svcshowercol.size()<<std::endl;
156  bool /*seltag0=false,seltag1=false,seltag2=false, seltag3=false,*/seltag4=false;
157  if(svcshowercol.size()>0){
158 
159 
160  double llemu = svcshowercol[0]->DedxLongLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxLongLL(int(jmshower::kMuon));
161  double ltemu = svcshowercol[0]->DedxTransLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxTransLL(int(jmshower::kMuon));
162 
163  double lleproton = svcshowercol[0]->DedxLongLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxLongLL(int(jmshower::kProton));
164  // double lteproton = svcshowercol[0]->DedxTransLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxTransLL(int(jmshower::kProton));
165 
166  double llepion = svcshowercol[0]->DedxLongLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxLongLL(int(jmshower::kPion));
167  // double ltepion = svcshowercol[0]->DedxTransLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxTransLL(int(jmshower::kPion));
168 
169  // double llepi0 = svcshowercol[0]->DedxLongLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxLongLL(int(jmshower::kPi0));
170  // double ltepi0 = svcshowercol[0]->DedxTransLL(int(jmshower::kElectron)) - svcshowercol[0]->DedxTransLL(int(jmshower::kPi0));
171 
172 
173 
174  // if(svcshowercol.size()==1 && lleproton<0 && lteproton<0) seltag1 = true;
175  // if(svcshowercol.size()==1 && llepion<0 && ltepion<0) seltag2 = true;
176  // if(svcshowercol.size()==1 && llepi0<0 && ltepi0<0) seltag3 = true;
177  if(svcshowercol.size()==1 && llemu<0 && ltemu<0) seltag4 = true;
178  std::cout<<"llemu, lleproton, llepion "<<llemu<<" "<<lleproton<<" "<<llepion<<std::endl;
179  }
180  // if(svcshowercol.size()==0) seltag0 = true;
181  return seltag4;
182  }
183 }// end namespace jmshower
184 
185 
186 //......................................................................
187 namespace jmshower
188 {
190 }
int PdgCode() const
Definition: MCParticle.h:211
int CCNC() const
Definition: MCNeutrino.h:148
double EndZ() const
Definition: MCParticle.h:227
const char * p
Definition: xmltok.h:285
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
bool isRealData() const
Definition: Event.h:83
DEFINE_ART_MODULE(TestTMapFile)
double EndY() const
Definition: MCParticle.h:226
TODO.
Definition: FillPIDs.h:12
std::string fPotLabel
Module that produced the POTSum object.
void reconfigure(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
caf::StandardRecord * sr
RecoJMShowerFilter(fhicl::ParameterSet const &pset)
OStream cout
Definition: OStream.cxx:6
virtual bool filter(art::Event &evt)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
int_type_
Neutrino interaction categories.
Definition: MCNeutrino.h:79
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:219
void geom(int which=0)
Definition: geom.C:163
double EndX() const
Definition: MCParticle.h:225
Event generator information.
Definition: MCNeutrino.h:18
int Mode() const
Definition: MCNeutrino.h:149
Definition: fwd.h:28
Encapsulate the geometry of one entire detector (near, far, ndos)
enum BeamMode string