BeamlineEventDisplay_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Beamline Event Display
3 // BeamlineEventDisplay_module.cc
4 //
5 // Analyzer module to make event displays of the full beamline
6 // system.
7 // Mike Wallbank, October 2018
8 ////////////////////////////////////////////////////////////////////////
9 
10 // framework
14 #include "fhiclcpp/ParameterSet.h"
21 
22 // nova
23 #include "NovaTimingUtilities/TimingUtilities.h"
25 #include "RawData/RawBeamline.h"
27 #include "BeamlineRecoBase/ToF.h"
30 #include "RecoBase/Track.h"
31 
32 // stl
33 #include <algorithm>
34 #include <cassert>
35 #include <cmath>
36 #include <fstream>
37 #include <iomanip>
38 #include <vector>
39 #include <iostream>
40 
41 // root
42 #include "TMath.h"
43 #include "TFile.h"
44 #include "TCanvas.h"
45 #include "TH3I.h"
46 #include "TStyle.h"
47 #include "TLine.h"
48 #include "TPolyLine3D.h"
49 #include "TPolyMarker3D.h"
50 #include "TMarker3DBox.h"
51 #include "TEveArrow.h"
52 
55 
56 // -----------------------------------------------------------------------
57 namespace testbeam {
59 }
60 
61 // -----------------------------------------------------------------------
63 
64  public:
65 
66  explicit BeamlineEventDisplay(const fhicl::ParameterSet& pset);
67  virtual ~BeamlineEventDisplay() {}
68 
69  virtual void analyze(const art::Event& evt);
70  void reconfigure(const fhicl::ParameterSet& pset);
71  void beginJob();
72  void beginRun(const art::Run& r);
73  void beginSubRun(const art::SubRun& sr);
74  void endJob();
75 
76  // Drawing
77  void DrawAnnotations();
78  void DrawCkov(const std::vector<art::Ptr<brb::Cherenkov> >& ckovs);
79  void DrawMagnet();
80  void DrawNOvA();
81  void DrawNOvATracks(const std::vector<art::Ptr<rb::Track> >& tracks);
82  void DrawNOvATracks(const std::vector<art::Ptr<rb::Prong> >& prongs);
83  void DrawToF(const std::vector<art::Ptr<brb::BeamlineDigit> >& tofDigits);
84  void DrawWC(const std::vector<art::Ptr<rawdata::RawBeamlineWC> >& wcs);
85  void DrawWCTrack(const std::vector<art::Ptr<brb::WCTrack> >& wcTracks);
86 
87  private:
88 
89  // Data labels
98 
99  // Configuration options
100  bool fDrawNOvA;
103  bool fDrawWC;
109 
110  // Options
112 
113  // Services
115 
116  // For drawing and saving
117  TH3I* fFrame;
118  TCanvas* fEVD;
119 
120  TFile* fOutFile;
122 
123 };
124 
125 // -----------------------------------------------------------------------
127  EDAnalyzer(pset){
128  this->reconfigure(pset);
129 }
130 
131 // -----------------------------------------------------------------------
133  fRawToFDigitLabel = pset.get<std::string>("RawToFDigitLabel");
134  fRawCkovDigitLabel = pset.get<std::string>("RawCkovDigitLabel");
135  fRawWCLabel = pset.get<std::string>("RawWCLabel");
136  fRecoToFDigitLabel = pset.get<std::string>("RecoToFDigitLabel");
137  fRecoCkovLabel = pset.get<std::string>("RecoCkovLabel");
138  fRecoWCTrackLabel = pset.get<std::string>("RecoWCTrackLabel");
139  fRecoProngLabel = pset.get<std::string>("RecoProngLabel");
140  fRecoBPTrackLabel = pset.get<std::string>("RecoBPTrackLabel");
141 
142  fDrawNOvA = pset.get<bool>("DrawNOvA");
143  fDrawNOvATracks = pset.get<bool>("DrawNOvATracks");
144  fDrawNOvAProngs = pset.get<bool>("DrawNOvAProngs");
145  fDrawWC = pset.get<bool>("DrawWC");
146  fDrawWCReco = pset.get<bool>("DrawWCReco");
147  fDrawUSToF = pset.get<bool>("DrawUSToF");
148  fDrawDSToF1 = pset.get<bool>("DrawDSToF1");
149  fDrawDSToF2 = pset.get<bool>("DrawDSToF2");
150  fDrawCherenkov = pset.get<bool>("DrawCherenkov");
151 
152  fUseWCHitPosition = pset.get<bool>("UseWCHitPosition");
153 
154  fOutputFileName = pset.get<std::string>("OutputFileName");
155 }
156 
157 // -----------------------------------------------------------------------
159 
160  // set up
161  gStyle->SetOptStat(0);
162 
163  // Open out file (TODO: use TFileService)
164  fOutFile = new TFile(fOutputFileName.c_str(), "RECREATE");
165 
166  // Make frame
167  if (fDrawNOvA)
168  fFrame = new TH3I("frame", "", 1,0,2000, 1,-300,150, 1,-150,150);
169  else
170  fFrame = new TH3I("frame", "", 1,0,1500, 1,-150,10, 1,-50,50);
171  fFrame->GetXaxis()->SetTickLength(0);
172  fFrame->GetXaxis()->SetLabelSize(0);
173  fFrame->GetXaxis()->SetAxisColor(0);
174  fFrame->GetYaxis()->SetTickLength(0);
175  fFrame->GetYaxis()->SetLabelSize(0);
176  fFrame->GetYaxis()->SetAxisColor(0);
177  fFrame->GetZaxis()->SetTickLength(0);
178  fFrame->GetZaxis()->SetLabelSize(0);
179  fFrame->GetZaxis()->SetAxisColor(0);
180  fEVD = new TCanvas("evd", "", 1600, 800);
181 
182  return;
183 
184 }
185 
186 // -----------------------------------------------------------------------
188  delete fEVD;
189  fOutFile->Close();
190  delete fOutFile;
191  return;
192 }
193 
194 // -----------------------------------------------------------------------
196  if (!fOutFile->GetDirectory(Form("Run%d", r.run())))
197  fOutFile->mkdir(Form("Run%d", r.run()));
198  return;
199 }
200 
201 // -----------------------------------------------------------------------
203  if (!fOutFile->GetDirectory(Form("Run%d/Spill%d", sr.run(), sr.subRun())))
204  fOutFile->mkdir(Form("Run%d/Spill%d", sr.run(), sr.subRun()));
205  return;
206 }
207 
208 // -----------------------------------------------------------------------
210 
211  // Get all the data
212  // art::Handle<rawdata::RawBeamlineConfig> blConfigHandle;
213  // rawdata::RawBeamlineConfig blConfig;
214  // if (evt.getByLabel("daq:BeamlineConfig", blConfigHandle))
215  // blConfig = *blConfigHandle;
216  // std::cout << "Beamline run " << blConfig.BeamlineRun() << std::endl;
217 
219  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > tofRawDigits;
220  if (evt.getByLabel(fRawToFDigitLabel, tofRawDigitHandle))
221  art::fill_ptr_vector(tofRawDigits, tofRawDigitHandle);
222 
224  std::vector<art::Ptr<brb::BeamlineDigit> > tofDigits;
225  if (evt.getByLabel(fRecoToFDigitLabel, tofDigitHandle))
226  art::fill_ptr_vector(tofDigits, tofDigitHandle);
227 
229  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > ckovDigits;
230  if (evt.getByLabel(fRawCkovDigitLabel, ckovDigitHandle))
231  art::fill_ptr_vector(ckovDigits, ckovDigitHandle);
232 
234  std::vector<art::Ptr<rawdata::RawBeamlineWC> > wcs;
235  if (evt.getByLabel(fRawWCLabel, wcHandle))
236  art::fill_ptr_vector(wcs, wcHandle);
237 
239  std::vector<art::Ptr<brb::WCTrack> > wcTracks;
240  if (evt.getByLabel(fRecoWCTrackLabel, wcTrackHandle))
241  art::fill_ptr_vector(wcTracks, wcTrackHandle);
242 
244  std::vector<art::Ptr<brb::Cherenkov> > ckovs;
245  if (evt.getByLabel(fRecoCkovLabel, ckovHandle))
246  art::fill_ptr_vector(ckovs, ckovHandle);
247 
249  std::vector<art::Ptr<rb::Prong> > prongs;
250  if (evt.getByLabel(fRecoProngLabel, prongHandle))
251  art::fill_ptr_vector(prongs, prongHandle);
252 
253  art::Handle<std::vector<rb::Track> > bpTrackHandle;
254  std::vector<art::Ptr<rb::Track> > bpTracks;
255  if (evt.getByLabel(fRecoBPTrackLabel, bpTrackHandle))
256  art::fill_ptr_vector(bpTracks, bpTrackHandle);
257 
258  // Clear EVD
259  fEVD->Clear();
260  fFrame->Draw("FBBB");
261 
262  // Draw annotations
263  DrawAnnotations();
264 
265  // Draw wire chambers
266  if (fDrawWC) {
267  DrawWC(wcs);
268  // Draw wire chamber reco
269  if (fDrawWCReco)
270  DrawWCTrack(wcTracks);
271  }
272 
273  // Draw tof
274  DrawToF(tofDigits);
275 
276  // Draw ckov
277  if (fDrawCherenkov)
278  DrawCkov(ckovs);
279 
280  // Draw magnet
281  //DrawMagnet();
282 
283  // Draw nova
284  if (fDrawNOvA) {
285  DrawNOvA();
286  // Draw nova tracks
287  if (fDrawNOvATracks)
288  DrawNOvATracks(bpTracks);
289  if (fDrawNOvAProngs)
290  DrawNOvATracks(prongs);
291  }
292 
293  // Save
294  fOutFile->cd(Form("Run%d/Spill%d", evt.run(), evt.subRun()));
295  fEVD->Write(Form("Event%d", evt.event()));
296 
297  return;
298 
299 }
300 
301 // -----------------------------------------------------------------------
303 
304  fEVD->cd();
305 
306  TPolyLine3D* axis = new TPolyLine3D(2);
307  axis->SetLineWidth(2);
308  axis->SetLineColor(kBlack);
309 
310  axis->SetPoint(0, 100, -150, -100);
311  axis->SetPoint(1, 100, -150, -60);
312  axis->DrawClone();
313 
314  axis->SetPoint(0, 100, -150, -100);
315  axis->SetPoint(1, 100, -120, -100);
316  axis->DrawClone();
317 
318  axis->SetPoint(0, 100, -150, -100);
319  axis->SetPoint(1, 240, -150, -100);
320  axis->DrawClone();
321 
322  return;
323 
324 }
325 
326 // -----------------------------------------------------------------------
328 
329  fEVD->cd();
330 
332  BeamlineCoordSystem::Beamline);
333  TMarker3DBox* ckov = new TMarker3DBox();
334  ckov->SetLineWidth(2);
335  ckov->SetPosition(ckov_pos.Z(), ckov_pos.X(), ckov_pos.Y());
336  ckov->SetSize(150, 10, 10);
337 
338  if (ckovs.size())
339  ckov->SetLineColor(kRed);
340  else
341  ckov->SetLineColor(kGray);
342 
343  ckov->DrawClone();
344 
345  return;
346 
347 }
348 
349 // -----------------------------------------------------------------------
351 
352  fEVD->cd();
353 
354  TVector3 magnet_pos = fGeo->BeamlineComponentPos(BeamlineComponent::Magnet,
355  BeamlineCoordSystem::Beamline);
356  TMarker3DBox* magnet = new TMarker3DBox();
357  magnet->SetLineColor(kBlue);
358  magnet->SetPosition(magnet_pos.Z(), magnet_pos.X(), magnet_pos.Y());
359  magnet->SetSize(100, 50, 50);
360  magnet->SetDirection(8*TMath::DegToRad(), 0);
361  magnet->DrawClone();
362 
363  return;
364 
365 }
366 
367 // -----------------------------------------------------------------------
369 
370  fEVD->cd();
371 
372  TVector3 nova_pos = fGeo->BeamlineComponentPos(BeamlineComponent::NOvA,
373  BeamlineCoordSystem::Beamline);
374  TMarker3DBox* nova = new TMarker3DBox();
375  nova->SetFillColor(kBlack);
376  nova->SetFillStyle(3003);
377  nova->SetPosition(nova_pos.Z()+200, nova_pos.X(), nova_pos.Y());
378  nova->SetSize(200, 140, 140);
379  nova->Draw();
380 
381 }
382 
383 // -----------------------------------------------------------------------
385 
386  fEVD->cd();
387 
388  TPolyLine3D* track = new TPolyLine3D(2);
389  track->SetLineColor(kGreen);
390 
391  for (std::vector<art::Ptr<rb::Track> >::const_iterator trackIt = tracks.begin();
392  trackIt != tracks.end(); ++trackIt) {
393 
394  TVector3 start = (*trackIt)->Start();
395  TVector3 dir = (*trackIt)->Dir().Unit();
396 
397  // don't deal with backward-going tracks right now
398  if (dir.Z() < 0)
399  continue;
400 
401  // find end point at z = 400
402  TVector3 normal(0,0,1), point(0,0,400);
403  float p = (normal*(point-start))/(normal*dir);
404  TVector3 end = start + (p*dir);
405 
406  TVector3 start_bl = fGeo->NOvADetectorToBeamlineCoords(start);
407  TVector3 end_bl = fGeo->NOvADetectorToBeamlineCoords(end);
408 
409  track->SetPoint(0, start_bl.Z(), start_bl.X(), start_bl.Y());
410  track->SetPoint(1, end_bl.Z(), end_bl.X(), end_bl.Y());
411  track->DrawClone();
412 
413  }
414 
415  return;
416 
417 }
418 
419 // -----------------------------------------------------------------------
421 
422  fEVD->cd();
423 
424  TPolyLine3D* track = new TPolyLine3D(2);
425  track->SetLineColor(kGreen);
426 
427  for (std::vector<art::Ptr<rb::Prong> >::const_iterator prongIt = prongs.begin();
428  prongIt != prongs.end(); ++prongIt) {
429 
430  TVector3 start = (*prongIt)->Start();
431  TVector3 dir = (*prongIt)->Dir().Unit();
432 
433  // don't deal with backward-going prongs right now
434  if (dir.Z() < 0)
435  continue;
436 
437  // find end point at z = 400
438  TVector3 normal(0,0,1), point(0,0,400);
439  float p = (normal*(point-start))/(normal*dir);
440  TVector3 end = start + (p*dir);
441 
442  TVector3 start_bl = fGeo->NOvADetectorToBeamlineCoords(start);
443  TVector3 end_bl = fGeo->NOvADetectorToBeamlineCoords(end);
444 
445  track->SetPoint(0, start_bl.Z(), start_bl.X(), start_bl.Y());
446  track->SetPoint(1, end_bl.Z(), end_bl.X(), end_bl.Y());
447  track->DrawClone();
448 
449  }
450 
451  return;
452 
453 }
454 
455 // -----------------------------------------------------------------------
457 
458  fEVD->cd();
459 
460  // Find channels with hits
461  std::vector<std::vector<unsigned int> > tofHits(3, std::vector<unsigned int>(4, 0));
462  for (std::vector<art::Ptr<brb::BeamlineDigit> >::const_iterator tofDigitIt = tofDigits.begin();
463  tofDigitIt != tofDigits.end(); ++tofDigitIt)
464  ++tofHits[(*tofDigitIt)->ChannelID().Detector][(*tofDigitIt)->ChannelID().Channel];
465 
466  TMarker3DBox* tof = new TMarker3DBox();
467  tof->SetLineWidth(2);
468  tof->SetLineColor(kGray);
469  tof->SetSize(4, 3.5, 3.5);
470 
471  // us-tof
472  if (fDrawUSToF) {
473  TVector3 tofus_pos = fGeo->BeamlineComponentPos(BeamlineComponent::ToFUS,
474  BeamlineCoordSystem::Beamline);
475  if (tofHits[0][0] > 0)
476  tof->SetLineColor(kRed);
477  else
478  tof->SetLineColor(kGray);
479  tof->SetPosition(tofus_pos.Z(), tofus_pos.X()+3.5, tofus_pos.Y()+3.5);
480  tof->DrawClone();
481  if (tofHits[0][1] > 0)
482  tof->SetLineColor(kRed);
483  else
484  tof->SetLineColor(kGray);
485  tof->SetPosition(tofus_pos.Z(), tofus_pos.X()-3.5, tofus_pos.Y()+3.5);
486  tof->DrawClone();
487  if (tofHits[0][2] > 0)
488  tof->SetLineColor(kRed);
489  else
490  tof->SetLineColor(kGray);
491  tof->SetPosition(tofus_pos.Z(), tofus_pos.X()+3.5, tofus_pos.Y()-3.5);
492  tof->DrawClone();
493  if (tofHits[0][3] > 0)
494  tof->SetLineColor(kRed);
495  else
496  tof->SetLineColor(kGray);
497  tof->SetPosition(tofus_pos.Z(), tofus_pos.X()-3.5, tofus_pos.Y()-3.5);
498  tof->DrawClone();
499  }
500 
501  // ds-tof-1
502  if (fDrawDSToF1) {
503  TVector3 tofds_pos = fGeo->BeamlineComponentPos(BeamlineComponent::ToFDS,
504  BeamlineCoordSystem::Beamline);
505  if (tofHits[1][0] > 0)
506  tof->SetLineColor(kRed);
507  else
508  tof->SetLineColor(kGray);
509  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()+3.5, tofds_pos.Y()+3.5);
510  tof->DrawClone();
511  if (tofHits[1][1] > 0)
512  tof->SetLineColor(kRed);
513  else
514  tof->SetLineColor(kGray);
515  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()-3.5, tofds_pos.Y()+3.5);
516  tof->DrawClone();
517  if (tofHits[1][2] > 0)
518  tof->SetLineColor(kRed);
519  else
520  tof->SetLineColor(kGray);
521  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()+3.5, tofds_pos.Y()-3.5);
522  tof->DrawClone();
523  if (tofHits[1][3] > 0)
524  tof->SetLineColor(kRed);
525  else
526  tof->SetLineColor(kGray);
527  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()-3.5, tofds_pos.Y()-3.5);
528  tof->DrawClone();
529  }
530 
531  // ds-tof-2
532  if (fDrawDSToF2) {
533  TVector3 tofds_pos = fGeo->BeamlineComponentPos(BeamlineComponent::ToFDSSiPM,
534  BeamlineCoordSystem::Beamline);
535  if (tofHits[2][0] > 0)
536  tof->SetLineColor(kRed);
537  else
538  tof->SetLineColor(kGray);
539  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()+3.5, tofds_pos.Y()+3.5);
540  tof->DrawClone();
541  if (tofHits[2][1] > 0)
542  tof->SetLineColor(kRed);
543  else
544  tof->SetLineColor(kGray);
545  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()-3.5, tofds_pos.Y()+3.5);
546  tof->DrawClone();
547  if (tofHits[2][2] > 0)
548  tof->SetLineColor(kRed);
549  else
550  tof->SetLineColor(kGray);
551  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()+3.5, tofds_pos.Y()-3.5);
552  tof->DrawClone();
553  if (tofHits[2][3] > 0)
554  tof->SetLineColor(kRed);
555  else
556  tof->SetLineColor(kGray);
557  tof->SetPosition(tofds_pos.Z(), tofds_pos.X()-3.5, tofds_pos.Y()-3.5);
558  tof->DrawClone();
559  }
560 
561  return;
562 
563 }
564 
565 // -----------------------------------------------------------------------
567 
568  fEVD->cd();
569 
570  std::vector<TVector3> wc_poss = {fGeo->BeamlineComponentPos(BeamlineComponent::WC1,
571  BeamlineCoordSystem::Beamline),
572  fGeo->BeamlineComponentPos(BeamlineComponent::WC2,
573  BeamlineCoordSystem::Beamline),
574  fGeo->BeamlineComponentPos(BeamlineComponent::WC3,
575  BeamlineCoordSystem::Beamline),
576  fGeo->BeamlineComponentPos(BeamlineComponent::WC4,
577  BeamlineCoordSystem::Beamline)};
578 
579  unsigned int num_wires = fGeo->NumWCPlaneWires();
580  float wire_pitch = fGeo->WCWirePitch();
581  float half_wc = wire_pitch*(float)num_wires/2.;
582 
583  TMarker3DBox* wc = new TMarker3DBox();
584  wc->SetLineWidth(2);
585  wc->SetLineColor(kGray);
586  wc->SetSize(6, 7.5, 7.5);
587 
588  TPolyLine3D* wire = new TPolyLine3D(2);
589  wire->SetLineColor(kRed);
590 
591  TPolyMarker3D* hit = new TPolyMarker3D(1);
592  hit->SetMarkerColor(kRed);
593  hit->SetMarkerStyle(8);
594  hit->SetMarkerSize(1);
595 
596  // draw geometry
597  for (std::vector<TVector3>::const_iterator wcIt = wc_poss.begin(); wcIt != wc_poss.end(); ++wcIt) {
598  wc->SetPosition(wcIt->Z(), wcIt->X(), wcIt->Y());
599  wc->DrawClone();
600  }
601 
602  // draw signals
603  for (std::vector<art::Ptr<rawdata::RawBeamlineWC> >::const_iterator wcIt = wcs.begin();
604  wcIt != wcs.end(); ++wcIt) {
605 
606  TVector3 wc_pos = wc_poss[(*wcIt)->DetectorID().Detector];
607 
608  // Find coincident hits
609  std::vector<std::pair<int, int> > coincidentChannels;
610 
611  // x hits
612  std::vector<rawdata::RawBeamlineWC::WCPulse> x_pulses = (*wcIt)->XPulses();
613  for (std::vector<rawdata::RawBeamlineWC::WCPulse>::const_iterator x_pulseIt = x_pulses.begin();
614  x_pulseIt != x_pulses.end(); ++x_pulseIt) {
615  wire->SetPoint(0, wc_pos.Z(), wc_pos.X()-(x_pulseIt->Channel*wire_pitch)+half_wc, wc_pos.Y()+half_wc);
616  wire->SetPoint(1, wc_pos.Z(), wc_pos.X()-(x_pulseIt->Channel*wire_pitch)+half_wc, wc_pos.Y()-half_wc);
617  wire->DrawClone();
618  }
619 
620  // y hits
621  std::vector<rawdata::RawBeamlineWC::WCPulse> y_pulses = (*wcIt)->YPulses();
622  for (std::vector<rawdata::RawBeamlineWC::WCPulse>::const_iterator y_pulseIt = y_pulses.begin();
623  y_pulseIt != y_pulses.end(); ++y_pulseIt) {
624  wire->SetPoint(0, wc_pos.Z(), wc_pos.X()+half_wc, wc_pos.Y()+half_wc-(y_pulseIt->Channel*wire_pitch));
625  wire->SetPoint(1, wc_pos.Z(), wc_pos.X()-half_wc, wc_pos.Y()+half_wc-(y_pulseIt->Channel*wire_pitch));
626  wire->DrawClone();
627  for (std::vector<rawdata::RawBeamlineWC::WCPulse>::const_iterator x_pulseIt = x_pulses.begin();
628  x_pulseIt != x_pulses.end(); ++x_pulseIt)
629  if (std::abs(x_pulseIt->Time-y_pulseIt->Time) < 10)
630  coincidentChannels.push_back(std::make_pair(x_pulseIt->Channel, y_pulseIt->Channel));
631  }
632 
633  // coincident hits
634  for (std::vector<std::pair<int, int> >::const_iterator coincChannelIt = coincidentChannels.begin();
635  coincChannelIt != coincidentChannels.end(); ++coincChannelIt) {
636  hit->SetPoint(0, wc_pos.Z(),
637  wc_pos.X()-(coincChannelIt->first*wire_pitch)+half_wc,
638  wc_pos.Y()+half_wc-(coincChannelIt->second*wire_pitch));
639  hit->DrawClone();
640  }
641 
642  }
643 
644  return;
645 
646 }
647 
648 // -----------------------------------------------------------------------
650 
651  fEVD->cd();
652 
653  TVector3 wc3_pos = fGeo->BeamlineComponentPos(BeamlineComponent::WC3,
654  BeamlineCoordSystem::Beamline);
655  TVector3 nova_pos = fGeo->BeamlineComponentPos(BeamlineComponent::NOvA,
656  BeamlineCoordSystem::Beamline);
657 
658  TPolyLine3D* track = new TPolyLine3D(2);
659  track->SetLineColor(kBlue);
660 
661  for (std::vector<art::Ptr<brb::WCTrack> >::const_iterator wcTrackIt = wcTracks.begin();
662  wcTrackIt != wcTracks.end(); ++wcTrackIt) {
663 
664  // Upstream
665  if (fUseWCHitPosition) {
666  TVector3 start_us = (*wcTrackIt)->WCHit(0);
667  TVector3 end_us = (*wcTrackIt)->WCHit(1);
668  track->SetPoint(0, start_us.Z(), start_us.X(), start_us.Y());
669  track->SetPoint(1, end_us.Z(), end_us.X(), end_us.Y());
670  track->DrawClone();
671  }
672 
673  // project to front face
674  // NB in order to use WCHitPosition, need recently reconstructed file
675  TVector3 start;
676  if (fUseWCHitPosition)
677  start = (*wcTrackIt)->WCHit(2);
678  else
679  start = wc3_pos;
680  float z_diff = nova_pos.Z()-start.Z();
681  float theta = (*wcTrackIt)->Theta();
682  float phi = (*wcTrackIt)->Phi();
683 
684  // use angles to get projection
685  float x_nova = TMath::Sqrt( TMath::Power(z_diff*TMath::Tan(theta),2) / (1 + TMath::Power(TMath::Tan(phi),2)) );
686  if (phi > TMath::Pi()/2. or phi < TMath::Pi()/-2.)
687  x_nova *= -1.;
688  float y_nova = x_nova * TMath::Tan(phi);
689 
690  track->SetPoint(0, start.Z(), start.X(), start.Y());
691  track->SetPoint(1, nova_pos.Z(), x_nova+start.X(), y_nova+start.Y());
692 
693  track->DrawClone();
694 
695  }
696 
697  return;
698 
699 }
700 
SubRunNumber_t subRun() const
Definition: Event.h:72
SubRunNumber_t subRun() const
Definition: SubRun.h:44
TVector3 NOvADetectorToBeamlineCoords(TVector3 vec) const
const char * p
Definition: xmltok.h:285
void DrawNOvATracks(const std::vector< art::Ptr< rb::Track > > &tracks)
Definition: event.h:19
void DrawToF(const std::vector< art::Ptr< brb::BeamlineDigit > > &tofDigits)
double y_nova[4]
Definition: Xsec_final.C:38
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
void reconfigure(const fhicl::ParameterSet &pset)
Definition of the beamline offline geometry. Also implementation of a service to obtain this informat...
DEFINE_ART_MODULE(TestTMapFile)
RunNumber_t run() const
Definition: Run.h:47
double x_nova[4]
Definition: Xsec_final.C:37
float abs(float number)
Definition: d0nt_math.hpp:39
Definition: Run.h:31
TVector3 BeamlineComponentPos(BeamlineComponent component, BeamlineCoordSystem system) const
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
virtual void analyze(const art::Event &evt)
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...
caf::StandardRecord * sr
EventNumber_t event() const
Definition: Event.h:67
float WCWirePitch() const
Wire chamber wire pitch.
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Hold drift constants from current run.
Definition: DriftCache.h:17
void DrawWC(const std::vector< art::Ptr< rawdata::RawBeamlineWC > > &wcs)
art::ServiceHandle< beamlinegeo::BeamlineGeometry > fGeo
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void DrawWCTrack(const std::vector< art::Ptr< brb::WCTrack > > &wcTracks)
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:326
Definition: structs.h:12
BeamlineEventDisplay(const fhicl::ParameterSet &pset)
unsigned int NumWCPlaneWires() const
Number of wires on each WC plane.
TRandom3 r(0)
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
RunNumber_t run() const
Definition: Event.h:77
Definition: fwd.h:28
void DrawCkov(const std::vector< art::Ptr< brb::Cherenkov > > &ckovs)
RunNumber_t run() const
Definition: SubRun.h:49