All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
hit::MCHitAnaExample Class Reference
Inheritance diagram for hit::MCHitAnaExample:

Public Member Functions

 MCHitAnaExample (fhicl::ParameterSet const &p)
 
virtual ~MCHitAnaExample ()
 

Private Member Functions

void analyze (art::Event const &e) override
 

Private Attributes

std::string fRecoHitModuleName
 Producer module for recob::Hit. More...
 
std::string fMCHitModuleName
 Producer module for MCHit. More...
 
TStopwatch fAnaWatch
 
TStopwatch fSearchWatch
 
TStopwatch fReadWatch
 
TH1D * hRecoHitReadTime
 Time to read recob::Hit from disk. More...
 
TH1D * hMCHitReadTime
 Time to read MCHit from disk. More...
 
TH1D * hAnalysisTime
 Time to run analyze() function. More...
 
TH1D * hMCHitSearchTime
 Time to search for corresponding MCHit per RecoHit. More...
 
TH1D * hMCHitSearchTimeSum
 Time to search for corresponding MCHit per RecoHit summed over all RecoHits (per event) More...
 
std::vector< TH1D * > hMCHitQ_v
 Histogram (per plane) for all MCHit charge. More...
 
std::vector< TH1D * > hMCHitMult_v
 Histogram (per plane) for MCHit multiplicity in each event. More...
 
std::vector< TH1D * > hRecoHitQ_v
 Histogram (per plane) for RecoHit charge. More...
 
std::vector< TH1D * > hRecoHitMult_v
 Histogram (per plane) for RecoHit multiplicity in each event. More...
 
std::vector< TH2D * > hCorrMult_v
 Histogram (per plane) for # of MCHit vs. # of RecoHit. More...
 
std::vector< TH1D * > hVoidHitQ_v
 Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit. More...
 
std::vector< TH2D * > hCorrQ_v
 Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit. More...
 
std::vector< TH2D * > hCorrQSum_v
 Histogram (per plane) for charge sum of multiple MCHit found within start=>end time of one RecoHit. More...
 
std::vector< TH1D * > hQRatio_v
 Histogram (per plane) for a ratio of RecoHit charge to the closest (in time) RecoHit charge. More...
 
std::vector< TH1D * > hQSumRatio_v
 
std::vector< TH1D * > hDT_v
 Histogram (per plane) for time-diff between one Reco hit and the closest (in time) RecoHit. More...
 
std::vector< TH1D * > hMCHitMultPerRecoHit_v
 Histogram (per plane) for MCHit multiplicity within start=>end time region of RecoHit. More...
 

Detailed Description

Definition at line 30 of file MCHitAnaExample_module.cc.

Constructor & Destructor Documentation

hit::MCHitAnaExample::MCHitAnaExample ( fhicl::ParameterSet const &  p)
explicit

Definition at line 124 of file MCHitAnaExample_module.cc.

124  : EDAnalyzer(p) // ,
125 
126  {
127  fRecoHitModuleName = p.get<std::string>("RecoHitModuleName");
128  fMCHitModuleName = p.get<std::string>("MCHitModuleName");
129 
130  art::ServiceHandle<art::TFileService const> fs;
131 
132  art::ServiceHandle<geo::Geometry const> geo;
133 
134  for (unsigned char plane = 0; plane < geo->Nplanes(); ++plane) {
135 
136  hMCHitQ_v.push_back(
137  fs->make<TH1D>(Form("hMCHitQ_%d", plane),
138  Form("MCHit Charge (Plane %d); Charge [ADC]; # MCHit", plane),
139  250,
140  0,
141  2000));
142 
143  hMCHitMult_v.push_back(
144  fs->make<TH1D>(Form("hMCHitMult_%d", plane),
145  Form("MCHit Multiplicity (Plane %d); Multiplicity; # MCHit", plane),
146  250,
147  0,
148  5000));
149 
150  hRecoHitQ_v.push_back(
151  fs->make<TH1D>(Form("hRecoHitQ_%d", plane),
152  Form("RecoHit Charge (Plane %d); Charge [ADC]; # RecoHits", plane),
153  250,
154  0,
155  2000));
156 
157  hRecoHitMult_v.push_back(
158  fs->make<TH1D>(Form("hRecoHitMult_%d", plane),
159  Form("RecoHit Multiplicity (Plane %d); Multiplicity; # RecoHits", plane),
160  200,
161  0,
162  2000));
163 
164  hCorrMult_v.push_back(
165  fs->make<TH2D>(Form("hCorrMult_%d", plane),
166  Form("# MCHits vs. # RecoHits (Plane %d); # MCHits; # RecoHits", plane),
167  250,
168  0,
169  5000,
170  200,
171  0,
172  2000));
173 
174  hVoidHitQ_v.push_back(fs->make<TH1D>(
175  Form("hVoidHitQ_%d", plane),
176  Form("RecoHit Charge (No Corresponding MCHit)) (Plane %d); Charge [ADC]; # RecoHits",
177  plane),
178  250,
179  0,
180  2000));
181 
182  hCorrQ_v.push_back(fs->make<TH2D>(
183  Form("hCorrQ_%d", plane),
184  Form("RecoHit Q vs. Closest MCHit Q (Plane %d); MCHit Charge [ADC]; RecoHit Charge [ADC]",
185  plane),
186  250,
187  0,
188  2000,
189  250,
190  0,
191  2000));
192 
193  hCorrQSum_v.push_back(
194  fs->make<TH2D>(Form("hCorrQSum_%d", plane),
195  Form("RecoHit Q vs. MCHit QSum Within Start=>End (Plane %d); MCHit Charge "
196  "[ADC]; RecoHit Charge [ADC]",
197  plane),
198  250,
199  0,
200  2000,
201  250,
202  0,
203  2000));
204 
205  hQRatio_v.push_back(
206  fs->make<TH1D>(Form("hQRatio_%d", plane),
207  Form("Reco/MCHit Charge (Plane %d); Ratio; # RecoHits", plane),
208  200,
209  0,
210  2));
211 
212  hQSumRatio_v.push_back(
213  fs->make<TH1D>(Form("hQSumRatio_%d", plane),
214  Form("Reco/MCHit Charge (Plane %d); Ratio; # RecoHits", plane),
215  200,
216  0,
217  2));
218 
219  hDT_v.push_back(fs->make<TH1D>(
220  Form("hDT_%d", plane),
221  Form("#DeltaT btw Reco and Closest MCHit (Plane %d); #DeltaT; # RecoHits", plane),
222  190,
223  -9.5,
224  9.5));
225 
226  hMCHitMultPerRecoHit_v.push_back(fs->make<TH1D>(
227  Form("hMCHitMultPerRecoHit_%d", plane),
228  Form("MCHit Multiplicity per RecoHit (Plane %d); Multiplicity; # RecoHits", plane),
229  21,
230  -1.5,
231  19.5));
232  }
233 
235  fs->make<TH1D>("hRecoHitReadTime",
236  "Real Time to Read recob::Hit From Disk; Real Time [ms]; Events",
237  200,
238  0,
239  1000);
240 
242  fs->make<TH1D>("hMCHitReadTime",
243  "Real Time to Read sim::MCHit From Disk; Real Time [ms]; Events",
244  200,
245  0,
246  1000);
247 
248  hAnalysisTime =
249  fs->make<TH1D>("hAnalysisTime",
250  "Analysis Time to Run analyze() Function; Real Time [ms]; Events",
251  200,
252  0,
253  1000);
254 
256  fs->make<TH1D>("hMCHitSearchTime",
257  "Time to Search Multiple sim::MCHit Per RecoHit; RealTime [us]; # RecoHit",
258  200,
259  0,
260  200);
261 
262  hMCHitSearchTimeSum = fs->make<TH1D>(
263  "hMCHitSearchTimeSum",
264  "Time to Search Multiple sim::MCHit for All RecoHit in Event; RealTime [ms]; # Event",
265  200,
266  0,
267  200);
268  }
TH1D * hMCHitSearchTimeSum
Time to search for corresponding MCHit per RecoHit summed over all RecoHits (per event) ...
pdgs p
Definition: selectors.fcl:22
std::vector< TH1D * > hQRatio_v
Histogram (per plane) for a ratio of RecoHit charge to the closest (in time) RecoHit charge...
std::vector< TH2D * > hCorrMult_v
Histogram (per plane) for # of MCHit vs. # of RecoHit.
TH1D * hMCHitReadTime
Time to read MCHit from disk.
std::vector< TH1D * > hDT_v
Histogram (per plane) for time-diff between one Reco hit and the closest (in time) RecoHit...
std::string fMCHitModuleName
Producer module for MCHit.
std::vector< TH1D * > hRecoHitMult_v
Histogram (per plane) for RecoHit multiplicity in each event.
std::vector< TH1D * > hRecoHitQ_v
Histogram (per plane) for RecoHit charge.
std::string fRecoHitModuleName
Producer module for recob::Hit.
std::vector< TH1D * > hQSumRatio_v
std::vector< TH1D * > hMCHitMultPerRecoHit_v
Histogram (per plane) for MCHit multiplicity within start=&gt;end time region of RecoHit.
std::vector< TH2D * > hCorrQ_v
Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit.
TH1D * hMCHitSearchTime
Time to search for corresponding MCHit per RecoHit.
std::vector< TH1D * > hMCHitQ_v
Histogram (per plane) for all MCHit charge.
TH1D * hRecoHitReadTime
Time to read recob::Hit from disk.
std::vector< TH1D * > hMCHitMult_v
Histogram (per plane) for MCHit multiplicity in each event.
TH1D * hAnalysisTime
Time to run analyze() function.
std::vector< TH2D * > hCorrQSum_v
Histogram (per plane) for charge sum of multiple MCHit found within start=&gt;end time of one RecoHit...
std::vector< TH1D * > hVoidHitQ_v
Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit. ...
hit::MCHitAnaExample::~MCHitAnaExample ( )
virtual

Definition at line 270 of file MCHitAnaExample_module.cc.

270 {}

Member Function Documentation

void hit::MCHitAnaExample::analyze ( art::Event const &  e)
overrideprivate

Definition at line 273 of file MCHitAnaExample_module.cc.

274  {
275  fAnaWatch.Start();
276 
277  art::ServiceHandle<geo::Geometry const> geo;
278  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
279 
280  fReadWatch.Start();
281  auto const& mchits_v = *e.getValidHandle<std::vector<sim::MCHitCollection>>(fMCHitModuleName);
282  hMCHitReadTime->Fill(fReadWatch.RealTime() * 1.e3);
283 
284  fReadWatch.Start();
285  auto const& recohits = *e.getValidHandle<std::vector<recob::Hit>>(fRecoHitModuleName);
286  hRecoHitReadTime->Fill(fReadWatch.RealTime() * 1.e3);
287 
288  //
289  // Work on purely MCHit info
290  //
291  std::vector<size_t> mchit_mult(geo->Nplanes(), 0);
292  for (auto const& mchits : mchits_v) {
293 
294  auto plane = geo->ChannelToWire(mchits.Channel()).at(0).Plane;
295 
296  mchit_mult.at(plane) += mchits.size();
297 
298  for (auto const& mchit : mchits)
299 
300  hMCHitQ_v.at(plane)->Fill(mchit.Charge(true));
301  }
302 
303  std::vector<size_t> recohit_mult(geo->Nplanes(), 0);
304 
305  double search_time_sum = 0;
306 
307  // Loop over RecoHit
308  for (size_t hit_index = 0; hit_index < recohits.size(); ++hit_index) {
309 
310  auto const& hit = recohits.at(hit_index);
311 
312  auto const& wire_id = hit.WireID();
313 
314  // Fill purly RecoHit info
315  hRecoHitQ_v.at(wire_id.Plane)->Fill(hit.PeakAmplitude());
316  recohit_mult.at(wire_id.Plane) += 1;
317 
318  // Figure out channel & retrieve MCHitCollection for this channel
319  auto ch = geo->PlaneWireToChannel(wire_id.Plane, wire_id.Wire, wire_id.TPC, wire_id.Cryostat);
320 
321  if (mchits_v.size() <= ch)
322  throw cet::exception(__PRETTY_FUNCTION__)
323  << "Channel " << ch << " not found in MCHit vector!" << std::endl;
324 
325  // Found MCHitCollection
326  auto const& mchits = mchits_v.at(ch);
327 
328  if (ch != mchits.Channel())
329  throw cet::exception(__PRETTY_FUNCTION__)
330  << "MCHit channel & vector index mismatch: " << mchits.Channel() << " != " << ch
331  << std::endl;
332 
333  // Locate corresponding MCHit(s) to this RecoHit
334  sim::MCHit start_time, end_time, peak_time;
335 
336  start_time.SetTime(clock_data.TPCTick2TDC(hit.PeakTimeMinusRMS()), 0);
337  peak_time.SetTime(clock_data.TPCTick2TDC(hit.PeakTime()), 0);
338  end_time.SetTime(clock_data.TPCTick2TDC(hit.PeakTimePlusRMS()), 0);
339 
340  fSearchWatch.Start();
341  auto start_iter = std::lower_bound(mchits.begin(), mchits.end(), start_time);
342  auto end_iter = std::upper_bound(mchits.begin(), mchits.end(), end_time);
343  search_time_sum += fSearchWatch.RealTime() * 1.e3;
344  hMCHitSearchTime->Fill(fSearchWatch.RealTime() * 1.e6);
345 
346  double reco_q = hit.PeakAmplitude();
347  double mc_qsum = 0;
348  double mc_q = 0;
349  double mult = 0;
350  double dt_min = 0;
351  double abs_dt_min = 1e9;
352 
353  // Loop over MCHit(s) that reside in start=>end time of MCHit
354  while (start_iter != end_iter) {
355  mc_qsum += (*start_iter).Charge(true);
356  ++mult;
357  double dt = (*start_iter).PeakTime() - peak_time.PeakTime();
358  double abs_dt = dt;
359  if (abs_dt < 0) abs_dt *= -1;
360 
361  if (abs_dt < abs_dt_min) {
362  abs_dt_min = abs_dt;
363  dt_min = dt;
364  mc_q = (*start_iter).Charge(true);
365  }
366  ++start_iter;
367  }
368 
369  // Fill histograms
370  hMCHitMultPerRecoHit_v.at(wire_id.Plane)->Fill(mult);
371 
372  if (!mc_qsum)
373  hVoidHitQ_v.at(wire_id.Plane)->Fill(reco_q);
374 
375  else {
376 
377  hRecoHitQ_v.at(wire_id.Plane)->Fill(reco_q);
378  hCorrQ_v.at(wire_id.Plane)->Fill(mc_q, reco_q);
379  hCorrQSum_v.at(wire_id.Plane)->Fill(mc_qsum, reco_q);
380  hQSumRatio_v.at(wire_id.Plane)->Fill(reco_q / mc_qsum);
381  hQRatio_v.at(wire_id.Plane)->Fill(reco_q / mc_q);
382  hDT_v.at(wire_id.Plane)->Fill(dt_min);
383  }
384 
385  } // end looping over hits
386 
387  // Fill purely-MCHit and purely-RecoHit multiplicity histograms
388  for (unsigned char plane = 0; plane < geo->Nplanes(); ++plane) {
389  std::cout << mchit_mult.at(plane) << std::endl;
390  hMCHitMult_v.at(plane)->Fill(mchit_mult.at(plane));
391  hRecoHitMult_v.at(plane)->Fill(recohit_mult.at(plane));
392  hCorrMult_v.at(plane)->Fill(mchit_mult.at(plane), recohit_mult.at(plane));
393  }
394 
395  hAnalysisTime->Fill(fAnaWatch.RealTime() * 1.e3);
396  hMCHitSearchTimeSum->Fill(search_time_sum);
397  }
float PeakTime() const
Getter for start time.
Definition: MCHit.h:75
TH1D * hMCHitSearchTimeSum
Time to search for corresponding MCHit per RecoHit summed over all RecoHits (per event) ...
void SetTime(const float peak, const float width)
Setter function for time.
Definition: MCHit.h:57
std::vector< TH1D * > hQRatio_v
Histogram (per plane) for a ratio of RecoHit charge to the closest (in time) RecoHit charge...
process_name hit
Definition: cheaterreco.fcl:51
std::vector< TH2D * > hCorrMult_v
Histogram (per plane) for # of MCHit vs. # of RecoHit.
TH1D * hMCHitReadTime
Time to read MCHit from disk.
std::vector< TH1D * > hDT_v
Histogram (per plane) for time-diff between one Reco hit and the closest (in time) RecoHit...
std::string fMCHitModuleName
Producer module for MCHit.
std::vector< TH1D * > hRecoHitMult_v
Histogram (per plane) for RecoHit multiplicity in each event.
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production end_time
std::vector< TH1D * > hRecoHitQ_v
Histogram (per plane) for RecoHit charge.
std::string fRecoHitModuleName
Producer module for recob::Hit.
std::vector< TH1D * > hQSumRatio_v
std::vector< TH1D * > hMCHitMultPerRecoHit_v
Histogram (per plane) for MCHit multiplicity within start=&gt;end time region of RecoHit.
std::vector< TH2D * > hCorrQ_v
Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit.
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
TH1D * hMCHitSearchTime
Time to search for corresponding MCHit per RecoHit.
std::vector< TH1D * > hMCHitQ_v
Histogram (per plane) for all MCHit charge.
TH1D * hRecoHitReadTime
Time to read recob::Hit from disk.
do i e
std::vector< TH1D * > hMCHitMult_v
Histogram (per plane) for MCHit multiplicity in each event.
TH1D * hAnalysisTime
Time to run analyze() function.
BEGIN_PROLOG could also be cout
std::vector< TH2D * > hCorrQSum_v
Histogram (per plane) for charge sum of multiple MCHit found within start=&gt;end time of one RecoHit...
std::vector< TH1D * > hVoidHitQ_v
Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit. ...

Member Data Documentation

TStopwatch hit::MCHitAnaExample::fAnaWatch
private

Definition at line 51 of file MCHitAnaExample_module.cc.

std::string hit::MCHitAnaExample::fMCHitModuleName
private

Producer module for MCHit.

Definition at line 46 of file MCHitAnaExample_module.cc.

TStopwatch hit::MCHitAnaExample::fReadWatch
private

Definition at line 51 of file MCHitAnaExample_module.cc.

std::string hit::MCHitAnaExample::fRecoHitModuleName
private

Producer module for recob::Hit.

Definition at line 43 of file MCHitAnaExample_module.cc.

TStopwatch hit::MCHitAnaExample::fSearchWatch
private

Definition at line 51 of file MCHitAnaExample_module.cc.

TH1D* hit::MCHitAnaExample::hAnalysisTime
private

Time to run analyze() function.

Definition at line 64 of file MCHitAnaExample_module.cc.

std::vector<TH2D*> hit::MCHitAnaExample::hCorrMult_v
private

Histogram (per plane) for # of MCHit vs. # of RecoHit.

Definition at line 97 of file MCHitAnaExample_module.cc.

std::vector<TH2D*> hit::MCHitAnaExample::hCorrQ_v
private

Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit.

Definition at line 103 of file MCHitAnaExample_module.cc.

std::vector<TH2D*> hit::MCHitAnaExample::hCorrQSum_v
private

Histogram (per plane) for charge sum of multiple MCHit found within start=>end time of one RecoHit.

Definition at line 106 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hDT_v
private

Histogram (per plane) for time-diff between one Reco hit and the closest (in time) RecoHit.

Definition at line 118 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hMCHitMult_v
private

Histogram (per plane) for MCHit multiplicity in each event.

Definition at line 80 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hMCHitMultPerRecoHit_v
private

Histogram (per plane) for MCHit multiplicity within start=>end time region of RecoHit.

Definition at line 121 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hMCHitQ_v
private

Histogram (per plane) for all MCHit charge.

Definition at line 77 of file MCHitAnaExample_module.cc.

TH1D* hit::MCHitAnaExample::hMCHitReadTime
private

Time to read MCHit from disk.

Definition at line 61 of file MCHitAnaExample_module.cc.

TH1D* hit::MCHitAnaExample::hMCHitSearchTime
private

Time to search for corresponding MCHit per RecoHit.

Definition at line 67 of file MCHitAnaExample_module.cc.

TH1D* hit::MCHitAnaExample::hMCHitSearchTimeSum
private

Time to search for corresponding MCHit per RecoHit summed over all RecoHits (per event)

Definition at line 70 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hQRatio_v
private

Histogram (per plane) for a ratio of RecoHit charge to the closest (in time) RecoHit charge.

Definition at line 109 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hQSumRatio_v
private

Histogram (per plane) for a ratio of charge sum of multiple MCHit to one RecoHit. Multiple MCHits are found within start=>end time of RecoHit.

Definition at line 115 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hRecoHitMult_v
private

Histogram (per plane) for RecoHit multiplicity in each event.

Definition at line 90 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hRecoHitQ_v
private

Histogram (per plane) for RecoHit charge.

Definition at line 87 of file MCHitAnaExample_module.cc.

TH1D* hit::MCHitAnaExample::hRecoHitReadTime
private

Time to read recob::Hit from disk.

Definition at line 58 of file MCHitAnaExample_module.cc.

std::vector<TH1D*> hit::MCHitAnaExample::hVoidHitQ_v
private

Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit.

Definition at line 100 of file MCHitAnaExample_module.cc.


The documentation for this class was generated from the following file: