TimeDist_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TimeDist
3 // Module Type: analyzer
4 // File: TimeDist_module.cc
5 //
6 // Calculate differences between flash times and hit times
7 //
8 // Celio Moura camj@fnal.gov celio.moura@ufabc.edu.br
9 //
10 ////////////////////////////////////////////////////////////////////////
11 
12 #ifndef TimeDist_Module
13 #define TimeDist_Module
14 
15 // LArSoft includes
20 
21 // Framework includes
26 #include "art_root_io/TFileService.h"
28 #include "fhiclcpp/ParameterSet.h"
29 
30 // ROOT includes
31 #include "TH1.h"
32 //#include "TH2.h"
33 #include "TTree.h"
34 #include "TVector3.h"
35 
36 // C++ Includes
37 #include <vector>
38 #include <string>
39 
40 namespace TimeDist {
41 
42  class TimeDist : public art::EDAnalyzer
43  {
44  public:
45 
46  explicit TimeDist(fhicl::ParameterSet const& parameterSet);
47 
48  virtual void beginJob() override;
49  virtual void reconfigure(fhicl::ParameterSet const& parameterSet) ;
50  virtual void analyze (const art::Event& event) override;
51 
52  private:
53 
54  std::string fHitProducerLabel; ///< The name of the producer that created hits
55  std::string fFlashProducerLabel; ///< The name of the producer that created flashes
56  TH1D* fTimeHist; ///< Hit time of all particles
57  TH1D* fFlashHist; ///< Flash time of all particles
58  TH1D* fTmFshHist; ///< Hit times minus Flash times
59  TH1D* fTmFshHistU; ///< Hit times minus Flash times
60  TH1D* fTmFshHistV; ///< Hit times minus Flash times
61  TH1D* fTmFshHistW; ///< Hit times minus Flash times
62 
63  double frequency;
64  double hittime;
65 
66  }; // class TimeDist
67 
69  : EDAnalyzer(parameterSet)
70  {
71  reconfigure(parameterSet);
72  }
73 
74  //-----------------------------------------------------------------------
76  {
78 
79  fTimeHist = tfs->make<TH1D>("timehist",";Histogram of Hit Times;",4500, -1000, 17000);
80  fFlashHist = tfs->make<TH1D>("flashhist",";Histogram of Flash Times;",180, -1000, 17000);
81  fTmFshHist = tfs->make<TH1D>("hit-flash_Times" ,";Histogram of Hit-Flash Times;",7000, -3000, 4000);
82  fTmFshHistU = tfs->make<TH1D>("hit-flash_Times_U",";Histogram of Hit-Flash Times;",7000, -3000, 4000);
83  fTmFshHistV = tfs->make<TH1D>("hit-flash_Times_V",";Histogram of Hit-Flash Times;",7000, -3000, 4000);
84  fTmFshHistW = tfs->make<TH1D>("hit-flash_Times_W",";Histogram of Hit-Flash Times;",7000, -3000, 4000);
85  }
86 
87  //-----------------------------------------------------------------------
88  void TimeDist::reconfigure(fhicl::ParameterSet const& parameterSet)
89  {
90  fHitProducerLabel = parameterSet.get< std::string >("HitLabel");
91  fFlashProducerLabel = parameterSet.get< std::string >("FlashLabel");
92  }
93 
94  //-----------------------------------------------------------------------
96  {
97  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
98 
99  auto hitHandle = event.getHandle< std::vector<recob::Hit> >(fHitProducerLabel);
100 
101  // For every Hit:
102  for ( auto const& hit : (*hitHandle) )
103  {
104  frequency = clockData.TPCClock().Frequency();
105  hittime = hit.PeakTime()/frequency;
106 
107  fTimeHist->Fill(hittime); // filling the historgram with hit times
108 
109  } // for each Hit
110 
111  auto flashHandle = event.getHandle< std::vector<recob::OpFlash> >(fFlashProducerLabel);
112 
113  // For every Flash:
114  for ( auto const& opflash : (*flashHandle) )
115  {
116  // The channel associated with this flash.
117  fFlashHist->Fill(opflash.Time());
118  } // for each Flash
119 
120  for ( auto const& hit : (*hitHandle) )
121  {
122  double frequency = clockData.TPCClock().Frequency();
123  double hittime = hit.PeakTime()/frequency;
124  for ( auto const& opflash : (*flashHandle) )
125  {
126  fTmFshHist->Fill(hittime-opflash.Time());
127  }
128  if (hit.View()==geo::kU)
129  {
130  for ( auto const& opflash : (*flashHandle) )
131  {
132  fTmFshHistU->Fill(hittime-opflash.Time());
133  }
134  }
135  else if (hit.View()==geo::kV)
136  {
137  for ( auto const& opflash : (*flashHandle) )
138  {
139  fTmFshHistV->Fill(hittime-opflash.Time());
140  }
141  }
142  else
143  {
144  for ( auto const& opflash : (*flashHandle) )
145  {
146  fTmFshHistW->Fill(hittime-opflash.Time());
147  }
148  }
149  } // hit for
150  } // TimeDist::analyze()
151 
153 
154 } // namespace TimeDist
155 
156 #endif // TimeDist_Module
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
TH1D * fTimeHist
Hit time of all particles.
TH1D * fFlashHist
Flash time of all particles.
std::string string
Definition: nybbler.cc:12
Planes which measure V.
Definition: geo_types.h:130
TH1D * fTmFshHist
Hit times minus Flash times.
TH1D * fTmFshHistW
Hit times minus Flash times.
TH1D * fTmFshHistU
Hit times minus Flash times.
Planes which measure U.
Definition: geo_types.h:129
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::string fFlashProducerLabel
The name of the producer that created flashes.
void beginJob()
Definition: Breakpoints.cc:14
virtual void reconfigure(fhicl::ParameterSet const &pset)
TH1D * fTmFshHistV
Hit times minus Flash times.
T get(std::string const &key) const
Definition: ParameterSet.h:271
Detector simulation of raw signals on wires.
Declaration of signal hit object.
std::string fHitProducerLabel
The name of the producer that created hits.
Event finding and building.