VertexEva_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief TODO
3 /// \author ricken@fnal.gov
4 /// \date Sept. 2012
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <cmath>
8 #include <vector>
9 #include <string>
10 
11 // NOvA includes
12 #include "Calibrator/Calibrator.h"
13 #include "RecoBase/Vertex.h"
14 #include "MCCheater/BackTracker.h"
15 #include "Simulation/Particle.h"
17 
18 // Framework includes
25 
26 #include "TNtuple.h"
27 
28 
29 namespace ve {
30  class VertexEva : public art::EDAnalyzer {
31  public:
32  explicit VertexEva(fhicl::ParameterSet const& pset);
33  virtual ~VertexEva();
34 
35  void beginJob();
36  void analyze(const art::Event& evt);
37  void reconfigure(const fhicl::ParameterSet& p);
38 
39  private:
40  std::string fVertexInput; ///< Input folder from cluster reco
41 
42  TNtuple* displacement;
43 
44  };
45 }
46 
47 
48 namespace ve{
49 
50  //......................................................................
52  : EDAnalyzer(pset)
53  {
54  reconfigure(pset);
55  }
56 
57  //......................................................................
59  {
60  }
61 
62  //......................................................................
64  {
65  fVertexInput = pset.get< std::string >("VertexInput") ;
66  }
67 
68  //......................................................................
70  {
72 
73 
74  displacement = tfs->make<TNtuple>("displacement","delta",
75  "deltaX:deltaY:deltaZ:deltaT");
76  }
77 
78 
79  //......................................................................
80  ///
81  /// In this analysis, the input file should only be single muon events
82  /// for simplicity
83  ///
84  ///
86  {
87 
88  double mcT, mcX, mcY, mcZ;
89  mcT=0;
90  mcX=0;
91  mcY=0;
92  mcZ=0;
93 
95  const sim::ParticleNavigator& pnav = bt->ParticleNavigator();
96 
97  for (sim::ParticleNavigator::const_iterator k = pnav.begin(); k != pnav.end(); ++k){
98  const sim::Particle* p = (*k).second;
99  if (p->PdgCode() == 2212) {
100  mcT = p->T();
101  mcX = p->Vx();
102  mcY = p->Vy();
103  mcZ = p->Vz();
104  break;
105  }
106  }
107 
109  evt.getByLabel(fVertexInput, vertexhandle);
110 
111  art::Ptr<rb::Vertex> vertex(vertexhandle,0); //It is supposed to have only 1 vertex /evt
112 
113  double rbT, rbX, rbY, rbZ;
114 
115  rbT = vertex->GetT();
116  rbX = vertex->GetX();
117  rbY = vertex->GetY();
118  rbZ = vertex->GetZ();
119 
120 
121  displacement->Fill(rbX-mcX,
122  rbY-mcY,
123  rbZ-mcZ,
124  rbT-mcT);
125 
126  return;
127 
128  } //end analyze
129 
131 
132 }//end namespace
back track the reconstruction to the simulation
int PdgCode() const
Definition: MCParticle.h:211
Definition: event.h:34
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
double GetX() const
Definition: Vertex.h:23
const char * p
Definition: xmltok.h:285
list_type::const_iterator const_iterator
TODO.
virtual ~VertexEva()
double GetY() const
Definition: Vertex.h:24
DEFINE_ART_MODULE(TestTMapFile)
double GetZ() const
Definition: Vertex.h:25
TNtuple * displacement
void reconfigure(const fhicl::ParameterSet &p)
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
double T(const int i=0) const
Definition: MCParticle.h:223
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Vertex location in position and time.
double Vx(const int i=0) const
Definition: MCParticle.h:220
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double Vz(const int i=0) const
Definition: MCParticle.h:222
VertexEva(fhicl::ParameterSet const &pset)
double GetT() const
Definition: Vertex.h:26
std::string fVertexInput
Input folder from cluster reco.
Definition: fwd.h:28
double Vy(const int i=0) const
Definition: MCParticle.h:221
void analyze(const art::Event &evt)
enum BeamMode string