BeamlineRecoValidation_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file BeamlineRecoValidation_module.cc
3 /// \module analyzer
4 /// \brief Analysis of the performance of the beamline reconstruction
5 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
6 /// \date September 2019
7 ////////////////////////////////////////////////////////////////////////////
8 
9 // framework
13 #include "fhiclcpp/ParameterSet.h"
21 
22 // nova
23 #include "RawData/RawBeamline.h"
27 #include "BeamlineRecoBase/ToF.h"
29 
30 // stl
31 #include <iostream>
32 
33 // root
34 #include "TH1D.h"
35 #include "TH2D.h"
36 
37 // -----------------------------------------------------------------------
38 namespace testbeam {
39 
41 
42  public:
43 
45 
46  void reconfigure(const fhicl::ParameterSet& pset);
47  void analyze(const art::Event& evt);
48 
49  private:
50 
51  // configuration labels
57 
58  // methods
59  void initializeHists();
60 
61  // data products
62  TH1D* hNumToF;
63  TH1D* hNumWCTrack;
64  TH2D* hAverageADC;
66  TH1D* hToF;
67  TH1D* hMomentum;
68  TH2D* hPID;
69 
70  // services
72 
73  };
74 
76 
77 }
78 
79 // -----------------------------------------------------------------------
81  this->reconfigure(pset);
82  this->initializeHists();
83 }
84 
85 // -----------------------------------------------------------------------
87  fToFRawDigitLabel = pset.get<art::InputTag>("ToFRawDigitLabel");
88  fToFRecoDigitLabel = pset.get<art::InputTag>("ToFRecoDigitLabel");
89  fRecoCherenkovLabel = pset.get<art::InputTag>("RecoCherenkovLabel");
90  fRecoToFLabel = pset.get<art::InputTag>("RecoToFLabel");
91  fRecoWCTrackLabel = pset.get<art::InputTag>("RecoWCTrackLabel");
92 }
93 
94 // -----------------------------------------------------------------------
96  hNumToF = tfs->make<TH1D>("NumToF", ";Number of ToF per trigger;", 100, 0, 100);
97  hNumWCTrack = tfs->make<TH1D>("NumWCTracks", ";Number of WC tracks;", 100, 0, 100);
98  hAverageADC = tfs->make<TH2D>("AverageADC", ";Average ADC;", 12, 0, 12, 100, 0, 5000);
99  hRecoStartTime = tfs->make<TH1D>("RecoStartTime", ";Start Time (ns);", 100, 0, 200);
100  hToF = tfs->make<TH1D>("ToF", ";Time-of-flight (ns);", 100, 0, 1000);
101  hMomentum = tfs->make<TH1D>("Momentum", ";Momentum (MeV);", 100, 0, 5000);
102  hPID = tfs->make<TH2D>("PID", ";Momentum (MeV);Time-of-flight (ns);", 100, 0, 5000, 100, 0, 1000);
103 }
104 
105 // -----------------------------------------------------------------------
107 
108  std::cout << std::endl << "Event " << evt.event() << std::endl;
109 
110  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > rawDigits;
112  if (evt.getByLabel(fToFRawDigitLabel, rawDigitHandle))
113  art::fill_ptr_vector(rawDigits, rawDigitHandle);
114 
115  std::vector<art::Ptr<brb::BeamlineDigit> > recoDigits;
117  if (evt.getByLabel(fToFRecoDigitLabel, recoDigitHandle))
118  art::fill_ptr_vector(recoDigits, recoDigitHandle);
119 
120  std::vector<art::Ptr<brb::Cherenkov> > cherenkovs;
121  art::Handle<std::vector<brb::Cherenkov> > cherenkovHandle;
122  if (evt.getByLabel(fRecoCherenkovLabel, cherenkovHandle))
123  art::fill_ptr_vector(cherenkovs, cherenkovHandle);
124 
125  std::vector<art::Ptr<brb::ToF> > tofs;
127  if (evt.getByLabel(fRecoToFLabel, tofHandle))
128  art::fill_ptr_vector(tofs, tofHandle);
129 
130  std::vector<art::Ptr<brb::WCTrack> > wcTracks;
132  if (evt.getByLabel(fRecoWCTrackLabel, wcTrackHandle))
133  art::fill_ptr_vector(wcTracks, wcTrackHandle);
134 
135  hNumToF->Fill(tofs.size());
136  hNumWCTrack->Fill(wcTracks.size());
137  for (std::vector<art::Ptr<rawdata::RawBeamlineDigit> >::const_iterator digitIt = rawDigits.begin();
138  digitIt != rawDigits.end(); ++digitIt) {
139  std::vector<uint16_t> adcs = (*digitIt)->ADCs();
140  hAverageADC->Fill((*digitIt)->ChannelID().Channel, TMath::Mean(adcs.begin(), adcs.end()));
141  }
142  for (std::vector<art::Ptr<brb::BeamlineDigit> >::const_iterator digitIt = recoDigits.begin();
143  digitIt != recoDigits.end(); ++digitIt) {
144  std::cout << "reco start time " << (*digitIt)->StartTimeInNanoSec() << std::endl;
145  hRecoStartTime->Fill((*digitIt)->StartTimeInNanoSec());
146  }
147  for (std::vector<art::Ptr<brb::ToF> >::const_iterator tofIt = tofs.begin();
148  tofIt != tofs.end(); ++tofIt)
149  hToF->Fill((*tofIt)->Time());
150  for (std::vector<art::Ptr<brb::WCTrack> >::const_iterator wcTrackIt = wcTracks.begin();
151  wcTrackIt != wcTracks.end(); ++wcTrackIt)
152  hMomentum->Fill((*wcTrackIt)->Momentum());
153  if (tofs.size() and wcTracks.size())
154  hPID->Fill(wcTracks[0]->Momentum(), tofs[0]->Time());
155 
156  return;
157 
158 }
art::ServiceHandle< art::TFileService > tfs
BeamlineRecoValidation(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 ...
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
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Raw data definitions for beamline data used in NOvA test beam experiment.
Encapsulation of &#39;reconstructed&#39; Cherenkov information. Part of beamline reconstruction for NOvA test...
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.
Definition: fwd.h:28
void reconfigure(const fhicl::ParameterSet &pset)