DSToFAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 /// \file DSToFAna_module.cc
3 /// \module analyzer
4 /// \brief Simple module to investigate moving around the DS-ToF modules.
5 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
6 /// \date September 2020
7 ////////////////////////////////////////////////////////////////////////////
8 
9 // framework
13 #include "fhiclcpp/ParameterSet.h"
21 
22 // nova
24 #include "RawData/RawBeamline.h"
26 #include "BeamlineRecoBase/ToF.h"
28 
29 // stl
30 
31 // root
32 #include "TGraph.h"
33 #include "TH1F.h"
34 
37 
38 // -----------------------------------------------------------------------
39 namespace tbana {
40 
41  class DSToFAna : public art::EDAnalyzer {
42 
43  public:
44 
45  DSToFAna(const fhicl::ParameterSet& pset);
46 
47  void analyze(const art::Event& evt);
48 
49  private:
50 
51  // methods
52  void AnalyzeDSToF2Location(const std::vector<art::Ptr<brb::WCTrack> >& wcTracks,
53  const std::vector<art::Ptr<brb::ToF> >& tofs);
54  void AnalyzeDSToF2Signals(const std::vector<art::Ptr<brb::BeamlineDigit> >& tofDigits,
55  const std::vector<art::Ptr<rawdata::RawBeamlineDigit> >& tofRawDigits,
57  TVector3 ProjectTrack(const art::Ptr<brb::WCTrack>& track, TVector3 pos);
58 
59  // config
65 
66  // variables
67  unsigned int fSubRun;
68  unsigned int fEvent;
69 
70  // data
71  TGraph* hEndToF;
72  TGraph* hEndNoToF;
73  TGraph* hMiddleToF;
74  TGraph* hMiddleNoToF;
75 
76  // services
79 
80  };
81 
83 
84 }
85 
86 // -----------------------------------------------------------------------
88  fRecoToFLabel = pset.get<std::string>("RecoToFLabel");
89  fRecoWCTrackLabel = pset.get<std::string>("RecoWCTrackLabel");
90  fRawToFDigitLabel = pset.get<std::string>("RawToFDigitLabel");
91  fRecoToFDigitLabel = pset.get<std::string>("RecoToFDigitLabel");
92  fRecoHitToFDigitLabel = pset.get<std::string>("RecoHitToFDigitLabel");
93 
94  hEndToF = fFileService->makeAndRegister<TGraph>("EndToF", ";NOvA Face X (cm);NOvA Face Y (cm);");
95  hEndNoToF = fFileService->makeAndRegister<TGraph>("EndNoToF", ";NOvA Face X (cm);NOvA Face Y (cm);");
96  hMiddleToF = fFileService->makeAndRegister<TGraph>("MiddleToF", ";Center of Beamline X (cm);Center of Beamline Y (cm);");
97  hMiddleNoToF = fFileService->makeAndRegister<TGraph>("MiddleNoToF", ";Center of Beamline X (cm);Center of Beamline Y (cm);");
98 }
99 
100 // -----------------------------------------------------------------------
102 
103  // Get data from art::Event
104 
105  fSubRun = evt.subRun();
106  fEvent = evt.event();
107 
108  // Reco ToF
110  std::vector<art::Ptr<brb::ToF> > tofs;
111  if (evt.getByLabel(fRecoToFLabel, tofHandle))
112  art::fill_ptr_vector(tofs, tofHandle);
113 
114  // Reco WC tracks
116  std::vector<art::Ptr<brb::WCTrack> > wcTracks;
117  if (evt.getByLabel(fRecoWCTrackLabel, wcTrackHandle))
118  art::fill_ptr_vector(wcTracks, wcTrackHandle);
119 
120  // Raw ToF digits
122  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > tofRawDigits;
123  if (evt.getByLabel(fRawToFDigitLabel, tofRawDigitHandle))
124  art::fill_ptr_vector(tofRawDigits, tofRawDigitHandle);
125 
126  // Reco ToF digits
128  std::vector<art::Ptr<brb::BeamlineDigit> > tofDigits;
129  if (evt.getByLabel(fRecoToFDigitLabel, tofDigitHandle))
130  art::fill_ptr_vector(tofDigits, tofDigitHandle);
131 
132  // Associations between raw and reco digits
135 
136  // Look at moving DSToF2 to another location
137  this->AnalyzeDSToF2Location(wcTracks, tofs);
138 
139  // Look at the DS-ToF1 and DS-ToF2 reco signals
140  this->AnalyzeDSToF2Signals(tofDigits, tofRawDigits, fmrd);
141 
142  return;
143 
144 }
145 
146 // -----------------------------------------------------------------------
148  const std::vector<art::Ptr<brb::ToF> >& tofs) {
149 
150  // Find triggers with a reconstructed track
151  if (!wcTracks.size())
152  return;
153 
154  art::Ptr<brb::WCTrack> track = wcTracks[0];
155  bool tof = tofs.size();
156 
157  // Find the location of the track at the end of the beamline
158  TVector3 nova_proj = ProjectTrack(track, fGeo->BeamlineComponentPos(BeamlineComponent::NOvA,
159  BeamlineCoordSystem::Beamline));
160  if (tof)
161  hEndToF->SetPoint(hEndToF->GetN(), nova_proj.X(), nova_proj.Y());
162  else
163  hEndNoToF->SetPoint(hEndNoToF->GetN(), nova_proj.X(), nova_proj.Y());
164 
165  // Find the location of the track at z-location downstream of magnet (1 foot upstream of MWPC3)
166  TVector3 mwpc3 = fGeo->BeamlineComponentPos(BeamlineComponent::WC3,
167  BeamlineCoordSystem::Beamline);
168  TVector3 mwpc3_proj = ProjectTrack(track, TVector3(mwpc3.X(), mwpc3.Y(), mwpc3.Z()-30));
169  if (tof)
170  hMiddleToF->SetPoint(hMiddleToF->GetN(), mwpc3_proj.X(), mwpc3_proj.Y());
171  else
172  hMiddleNoToF->SetPoint(hMiddleNoToF->GetN(), mwpc3_proj.X(), mwpc3_proj.Y());
173 
174  return;
175 
176 }
177 
178 // -----------------------------------------------------------------------
180  const std::vector<art::Ptr<rawdata::RawBeamlineDigit> >& tofRawDigits,
182 
183  // look at the reconstructed hits
184  std::map<std::string, unsigned int> hitCounter;
185  for (std::vector<art::Ptr<brb::BeamlineDigit> >::const_iterator tofDigitIt = tofDigits.begin();
186  tofDigitIt != tofDigits.end(); ++tofDigitIt) {
187 
188  std::cout << "Reconstructed hit on ToF " << (*tofDigitIt)->ChannelID().Detector << ", channel " << (*tofDigitIt)->ChannelID().Channel << std::endl;
189 
190  // draw the associated raw waveforms for hits on DSSiPM
191  if ((*tofDigitIt)->ChannelID().Detector == beamlinegeo::ToFCounter::DSSiPM) {
192  std::string channelName = Form("Spill%dEvent%dDSSiPMChannel%d", fSubRun, fEvent, (*tofDigitIt)->ChannelID().Channel);
193  ++hitCounter[channelName];
194 
195  // find the associated raw waveform
196  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > rawdigit = fmrd.at(tofDigitIt->key());
197 
198  // draw
199  TH1F* waveform = fFileService->make<TH1F>(Form("%sHit%dWaveform", channelName.c_str(), hitCounter[channelName]),";Tick;ADC;",1024,0,1024);
200  const std::vector<uint16_t>& adcs = rawdigit[0]->ADCs();
201  for (unsigned int tick = 0; tick < adcs.size(); ++tick)
202  waveform->Fill(tick, adcs[tick]);
203 
204  }
205 
206  }
207 
208  return;
209 
210 }
211 
212 // -----------------------------------------------------------------------
214 
215  TVector3 start = track->WCHit(3);
216  TVector3 dir = track->Dir();
217 
218  TVector3 normal(0,0,1), point(0,0,pos.Z());
219  float p = (normal*(point-start))/(normal*dir);
220  TVector3 end = start + (p*dir);
221 
222  TVector3 end_relative(end.X()-pos.X(), end.Y()-pos.Y(), end.Z());
223 
224  return end_relative;
225 
226 }
SubRunNumber_t subRun() const
Definition: Event.h:72
art::ServiceHandle< art::TFileService > fFileService
TVector3 ProjectTrack(const art::Ptr< brb::WCTrack > &track, TVector3 pos)
const char * p
Definition: xmltok.h:285
Definition: event.h:19
Definition of the beamline offline geometry. Also implementation of a service to obtain this informat...
DEFINE_ART_MODULE(TestTMapFile)
void AnalyzeDSToF2Signals(const std::vector< art::Ptr< brb::BeamlineDigit > > &tofDigits, const std::vector< art::Ptr< rawdata::RawBeamlineDigit > > &tofRawDigits, const art::FindManyP< rawdata::RawBeamlineDigit > &fmrd)
std::string fRawToFDigitLabel
art::ServiceHandle< beamlinegeo::BeamlineGeometry > fGeo
void analyze(const art::Event &evt)
std::string fRecoToFLabel
std::string fRecoHitToFDigitLabel
TVector3 BeamlineComponentPos(BeamlineComponent component, BeamlineCoordSystem system) const
std::string fRecoWCTrackLabel
unsigned int fEvent
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...
DSToFAna(const fhicl::ParameterSet &pset)
unsigned int fSubRun
TVector3 Dir() const
Definition: WCTrack.cxx:60
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
T * makeAndRegister(char const *name, char const *title, ARGS...args) const
OStream cout
Definition: OStream.cxx:6
std::string fRecoToFDigitLabel
T * make(ARGS...args) const
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void AnalyzeDSToF2Location(const std::vector< art::Ptr< brb::WCTrack > > &wcTracks, const std::vector< art::Ptr< brb::ToF > > &tofs)
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
TVector3 WCHit(unsigned int wc) const
Definition: WCTrack.cxx:65
Definition: fwd.h:28
enum BeamMode string