WCTrackRecoAnalysis_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file WCTrackRecoAnalysis_module.cc
3 /// \module analyzer
4 /// \brief Analyze and benchmark various reconstructions for the
5 /// ToF reconstruction.
6 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
7 /// David Duenas (University of Cincinnati)
8 /// \date May 2019
9 ////////////////////////////////////////////////////////////////////////////
10 
11 // framework
15 #include "fhiclcpp/ParameterSet.h"
23 
24 // nova
25 #include "RawData/RawBeamline.h"
29 #include "BeamlineRecoBase/ToF.h"
32 
33 // root
34 #include "TH1F.h"
35 
36 // stl
37 #include <iostream>
38 
39 // -----------------------------------------------------------------------
40 namespace beamlinerecoana {
41 
43 
44  public:
45 
47 
48  void reconfigure(const fhicl::ParameterSet& pset);
49  void analyze(const art::Event& evt);
50 
51  private:
52 
55 
57 
59 
60  };
61 
63 
64 }
65 
66 // -----------------------------------------------------------------------
68  this->reconfigure(pset);
69  hRecoMomentum = tfs->make<TH1F>("RecoMomentum", ";Reconstructed WC Momentum (MeV);", 100, 0, 2000);
70 }
71 
72 // -----------------------------------------------------------------------
74  fWCTrackModuleLabel = pset.get<std::string>("WCTrackModuleLabel");
75  fMCTruthModuleLabel = pset.get<std::string>("fMCTruthModuleLabel");
76 }
77 
78 // -----------------------------------------------------------------------
80 
81  std::cout << "Processing Event " << evt.event() << std::endl;
82 
83  // get the wc tracks from the event
85  std::vector<art::Ptr<brb::WCTrack> > wcTracks;
86  if (evt.getByLabel(fWCTrackModuleLabel, wcTrackHandle))
87  art::fill_ptr_vector(wcTracks, wcTrackHandle);
88 
89  // print stuff
90  std::cout << "There are " << wcTracks.size() << " WC tracks in this event" << std::endl;
91 
92  if (wcTracks.size()) {
93  std::cout << "Track momentum is " << wcTracks[0]->Momentum() << std::endl;
94  hRecoMomentum->Fill(wcTracks[0]->Momentum());
95  }
96 
97  // get the generator-level information from the event
99  std::vector<art::Ptr<simb::MCTruth> > mcTruths;
100  if (evt.getByLabel(fMCTruthModuleLabel, mcTruthHandle))
101  art::fill_ptr_vector(mcTruths, mcTruthHandle);
102 
103  // print more stuff
104  std::cout << "Thers is " << mcTruths.size() << " MCTruth simulation-level objects in this event" << std::endl;
105 
106  if (mcTruths.size()) {
107  std::cout << "There are " << mcTruths[0]->NParticles() << " particles in this simulation" << std::endl;
108  if (mcTruths[0]->NParticles()) {
109  const simb::MCParticle& particle = mcTruths[0]->GetParticle(0);
110  std::cout << "Particle momentum " << particle.Momentum().Vect().Mag() << std::endl;
111  std::cout << "Particle momentum " << particle.P() << std::endl;
112  }
113  }
114 
115  // make plots -- 2D reco vs true momentum, any others?
116  // be aware there are sometimes multiple particles in the event (there will (I think) always be one MCTruth, but it may have NParticles() == 2)
117 
118  return;
119 
120 }
void reconfigure(const fhicl::ParameterSet &pset)
DEFINE_ART_MODULE(TestTMapFile)
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
double P(const int i=0) const
Definition: MCParticle.h:233
T get(std::string const &key) const
Definition: ParameterSet.h:231
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
int evt
Encapsulation of reconstructed Wire Chamber track. Part of beamline reconstruction for NOvA test beam...
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
WCTrackRecoAnalysis(const fhicl::ParameterSet &pset)
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:219
art::ServiceHandle< art::TFileService > tfs
Raw data definitions for beamline data used in NOvA test beam experiment.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Encapsulation of reconstructed PID information from detectors in the beamline (ToF, WCs, Cherenkov). Part of beamline reconstruction for NOvA test beam.
int NParticles(int pdg_code, const TClonesArray *const particle_list)
Encapsulation of reconstructed track in the muon stack downstream of test beam detector. Part of beamline reconstruction for NOvA test beam.
enum BeamMode string