ToFRecoAnalysis_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file ToFRecoAnalysis_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 /// \date March 2019
8 ////////////////////////////////////////////////////////////////////////////
9 
10 // framework
14 #include "fhiclcpp/ParameterSet.h"
23 
24 // nova
25 #include "RawData/RawBeamline.h"
28 #include "BeamlineRecoBase/ToF.h"
30 
31 // ROOT
32 #include "TH1D.h"
33 #include "TH2D.h"
34 
35 // stl
36 #include <iostream>
37 
38 // -----------------------------------------------------------------------
39 namespace beamlinereco {
41 
42  public:
43 
45 
46  void reconfigure(const fhicl::ParameterSet& pset);
47  void beginJob() override;
48  void analyze(const art::Event& evt);
49 
50  private:
51 
57  unsigned int fTriggerBitTOFPrompt;
58  unsigned int fTriggerBitTOFSlow;
59  unsigned int fTriggerBitWCHDWR;
61 
63 
64  TH1D *hToF_all;
65  TH1D *hToF_any;
68  TH1D *hToF_TOFSlow;
69  TH1D *hToF_WCHDWR;
71 
72  TH1D *hMomentum;
74 
75  TH1D *hBeta;
76  TH1D *hMass;
77  };
78 
80 
81 }
82 
83 // -----------------------------------------------------------------------
85  this->reconfigure(pset);
86 }
87 
88 // -----------------------------------------------------------------------
90  fTriggerLabel = pset.get<art::InputTag>("TriggerLabel");
91  fRecoToFLabel = pset.get<art::InputTag>("RecoToFLabel");
92  fToFDigitLabel = pset.get<art::InputTag>("ToFDigitLabel");
93  fRecoWCLabel = pset.get<art::InputTag>("RecoWCLabel", "wctrackreco");
94  fRecoCherenkovLabel = pset.get<art::InputTag>("RecoCherenkovDigitLabel");
95  fSamplingInterval = pset.get<double>("TimeSamplingInterval");
96  fTriggerBitTOFPrompt = pset.get<unsigned int>("TriggerBitTOFPrompt");
97  fTriggerBitTOFSlow = pset.get<unsigned int>("TriggerBitTOFSlow");
98  fTriggerBitWCHDWR = pset.get<unsigned int>("TriggerBitWCHDWR");
99 }
100 
101 // -----------------------------------------------------------------------
103  double endtime = 1024.*fSamplingInterval;
104 
105  this->hToF_all = tfs->make<TH1D>("hToF_all", "Time of Flight (TOFPrompt & TOFSlow & WCHDWR)", 2*int(endtime), 0., int(endtime));
106  this->hToF_any = tfs->make<TH1D>("hToF_any", "Time of Flight (TOFPrompt | TOFSlow | WCHDWR)", 4*280, 30, 100);
107  this->hToF_any_cherenkov = tfs->make<TH1D>("hToF_any_cherenkov", "Time of Flight (any & Cherenkov)", 2*int(endtime), 0., int(endtime));
108  this->hToF_TOFPrompt = tfs->make<TH1D>("hToF_TOFPrompt", "Time of Flight (TOFPrompt)", 2*int(endtime), 0., int(endtime));
109  this->hToF_TOFSlow = tfs->make<TH1D>("hToF_TOFSlow", "Time of Flight (TOFSlow)", 2*int(endtime), 0., int(endtime));
110  this->hToF_WCHDWR = tfs->make<TH1D>("hToF_WCHDWR", "Time of Flight (WCHDWR)", 2*int(endtime), 0., int(endtime));
111  this->hToF_with_MWPC = tfs->make<TH1D>("hToF_with_MWPC", "Time of Flight with associated momentum", 4*280, 30, 100);
112 
113  this->hMomentum = tfs->make<TH1D>("hMomentum", "Momentum", 125, 0, 2500);
114  this->hTof_vs_momentum = tfs->make<TH2D>("hToFvsMomentum", "ToF vs. Momentum", 80, 0, 2500, 80, 0, 200);
115 
116  this->hBeta = tfs->make<TH1D>("hBeta", "Beta", 500, 0, 2);
117  this->hMass = tfs->make<TH1D>("hMass", "Mass", 500, 0, 2000);
118 }
119 
120 // -----------------------------------------------------------------------
122  // Trigger bits
124  std::vector<art::Ptr<rawdata::RawBeamlineTrigger>> triggers;
125  if (e.getByLabel(fTriggerLabel, triggerHandle))
126  art::fill_ptr_vector(triggers, triggerHandle);
127 
128  bool isTOFPromptTrig = false;
129  bool isTOFSlowTrig = false;
130  bool isWCHDWRTrig = false;
131 
132  //if (triggers.size() != 1) {
133  //std::cerr << "WARNING: Got " << triggers.size() << " triggers instead of 1" << std::endl;
134  //}
135  for (auto trig : triggers) {
136  unsigned int pattern = trig->Pattern();
137  isTOFPromptTrig = bool(pattern & (1 << fTriggerBitTOFPrompt));
138  isTOFSlowTrig = bool(pattern & (1 << fTriggerBitTOFSlow));
139  isWCHDWRTrig = bool(pattern & (1 << fTriggerBitWCHDWR));
140  }
141  /*if (triggers.size() == 0) {
142  std::cout << "No triggers" << std::endl;
143  } else {
144  std::cout << "Event " << e.event() << " has trigger bits:";
145  std::cout << " " << std::bitset<32>(triggers[0]->Pattern());
146  if (isTOFPromptTrig) std::cout << " TOFPrompt";
147  if (isTOFSlowTrig) std::cout << " TOFSlow";
148  if (isWCHDWRTrig) std::cout << " WCHDWR";
149  std::cout << std::endl;
150  }*/
151 
152  // Get ToFs
154  std::vector<art::Ptr<brb::ToF>> tofs;
155  if (e.getByLabel(fRecoToFLabel, tofHandle))
156  art::fill_ptr_vector(tofs, tofHandle);
157 
159  std::vector<art::Ptr<brb::BeamlineDigit>> tofDigits;
160  if (e.getByLabel(fToFDigitLabel, tofDigitHandle))
161  art::fill_ptr_vector(tofDigits, tofDigitHandle);
162 
163  // Cherenkov
165  std::vector<art::Ptr<brb::BeamlineDigit>> cherenkovs;
166  if (e.getByLabel(fRecoCherenkovLabel, cherenkovHandle))
167  art::fill_ptr_vector(cherenkovs, cherenkovHandle);
168 
169  // Retrieve BeamlineDigits for tof reco
171 
172  // Get WC reco (for momentum)
174  std::vector<art::Ptr<brb::WCTrack>> wcs;
175  if (e.getByLabel(fRecoWCLabel, wcHandle))
176  art::fill_ptr_vector(wcs, wcHandle);
177 
178  // Cherenkov
179  /*for (auto d : cherenkovs) {
180  if (channelMap[d->Channel()] == "Cherenkov") {
181  hPeakADC_AllHits_channel[d->Channel()]->Fill(d->PeakADC());
182  hStartTime_AllHits_channel[d->Channel()]->Fill(d->StartTimeInNanoSec());
183  }
184  }*/
185  bool hasCherenkov = (cherenkovs.size() > 0);
186  /*double cherenkovTime = -999;
187  if (hasCherenkov) {
188  cherenkovTime = cherenkovs[cherenkovs.size() - 1]->StartTimeInNanoSec();
189  }*/
190 
191  //if (tofs.size() > 1) return;
192 
193  //std::cout << "----- " << e.run() << "-" << e.subRun() << "-" << e.event() << std::endl;
194 
195  for (auto wc : wcs) {
196  hMomentum->Fill(wc->Momentum());
197  }
198 
199  for (auto tof : tofs) {
200  // Get associated reco digits
201  const std::vector<art::Ptr<brb::BeamlineDigit>> tofdigits = fmbd.at(tof.key());
202 
203  // fill
204  double t = tof->Time();
205 
206  if (hasCherenkov) {
207  hToF_any_cherenkov->Fill(t);
208  hToF_any->Fill(t);
209  } else {
210  hToF_any->Fill(t);
211  }
212 
213  if (isTOFPromptTrig) {
214  hToF_TOFPrompt->Fill(t);
215  }
216  if (isTOFSlowTrig) {
217  hToF_TOFSlow->Fill(t);
218  }
219  if (isWCHDWRTrig) {
220  hToF_WCHDWR->Fill(t);
221  }
222  if (isTOFPromptTrig && isTOFSlowTrig && isWCHDWRTrig) {
223  hToF_all->Fill(t);
224  }
225 
226  for (auto wc : wcs) {
227  hTof_vs_momentum->Fill(wc->Momentum(), t);
228  hToF_with_MWPC->Fill(t);
229 
230  double p = wc->Momentum();
231  //double t0 = t;
232  double t_s = t * 1e-9; // to seconds
233  double c = 299792458.0;
234  double l = 13.2; // m
235  double m = p*sqrt(c*c*(t_s/l)*(t_s/l) - 1.);
236  double beta = (l/t_s) / c;
237  //std::cout << "t0 = " << t0 << " p = " << p << " m = " << m << " beta = " << beta << std::endl;
238  hBeta->Fill(beta);
239  hMass->Fill(m);
240  }
241  }
242 }
const char * p
Definition: xmltok.h:285
T sqrt(T number)
Definition: d0nt_math.hpp:156
Double_t beta
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 ...
Encapsulation of reconstructed Wire Chamber track. Part of beamline reconstruction for NOvA test beam...
void reconfigure(const fhicl::ParameterSet &pset)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void analyze(const art::Event &evt)
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
art::ServiceHandle< art::TFileService > tfs
Raw data definitions for beamline data used in NOvA test beam experiment.
ToFRecoAnalysis(const fhicl::ParameterSet &pset)
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.
Float_t e
Definition: plot.C:35