15 #include "art_root_io/TFileService.h" 24 #include <TStopwatch.h> 131 for (
unsigned char plane = 0; plane < wireReadoutGeom.Nplanes(); ++plane) {
134 fs->make<TH1D>(Form(
"hMCHitQ_%d", plane),
135 Form(
"MCHit Charge (Plane %d); Charge [ADC]; # MCHit", plane),
141 fs->make<TH1D>(Form(
"hMCHitMult_%d", plane),
142 Form(
"MCHit Multiplicity (Plane %d); Multiplicity; # MCHit", plane),
148 fs->make<TH1D>(Form(
"hRecoHitQ_%d", plane),
149 Form(
"RecoHit Charge (Plane %d); Charge [ADC]; # RecoHits", plane),
155 fs->make<TH1D>(Form(
"hRecoHitMult_%d", plane),
156 Form(
"RecoHit Multiplicity (Plane %d); Multiplicity; # RecoHits", plane),
162 fs->make<TH2D>(Form(
"hCorrMult_%d", plane),
163 Form(
"# MCHits vs. # RecoHits (Plane %d); # MCHits; # RecoHits", plane),
172 Form(
"hVoidHitQ_%d", plane),
173 Form(
"RecoHit Charge (No Corresponding MCHit)) (Plane %d); Charge [ADC]; # RecoHits",
180 Form(
"hCorrQ_%d", plane),
181 Form(
"RecoHit Q vs. Closest MCHit Q (Plane %d); MCHit Charge [ADC]; RecoHit Charge [ADC]",
191 fs->make<TH2D>(Form(
"hCorrQSum_%d", plane),
192 Form(
"RecoHit Q vs. MCHit QSum Within Start=>End (Plane %d); MCHit Charge " 193 "[ADC]; RecoHit Charge [ADC]",
203 fs->make<TH1D>(Form(
"hQRatio_%d", plane),
204 Form(
"Reco/MCHit Charge (Plane %d); Ratio; # RecoHits", plane),
210 fs->make<TH1D>(Form(
"hQSumRatio_%d", plane),
211 Form(
"Reco/MCHit Charge (Plane %d); Ratio; # RecoHits", plane),
216 hDT_v.push_back(fs->make<TH1D>(
217 Form(
"hDT_%d", plane),
218 Form(
"#DeltaT btw Reco and Closest MCHit (Plane %d); #DeltaT; # RecoHits", plane),
224 Form(
"hMCHitMultPerRecoHit_%d", plane),
225 Form(
"MCHit Multiplicity per RecoHit (Plane %d); Multiplicity; # RecoHits", plane),
232 fs->make<TH1D>(
"hRecoHitReadTime",
233 "Real Time to Read recob::Hit From Disk; Real Time [ms]; Events",
239 fs->make<TH1D>(
"hMCHitReadTime",
240 "Real Time to Read sim::MCHit From Disk; Real Time [ms]; Events",
246 fs->make<TH1D>(
"hAnalysisTime",
247 "Analysis Time to Run analyze() Function; Real Time [ms]; Events",
253 fs->make<TH1D>(
"hMCHitSearchTime",
254 "Time to Search Multiple sim::MCHit Per RecoHit; RealTime [us]; # RecoHit",
260 "hMCHitSearchTimeSum",
261 "Time to Search Multiple sim::MCHit for All RecoHit in Event; RealTime [ms]; # Event",
285 std::vector<size_t> mchit_mult(wireReadoutGeom.Nplanes(), 0);
286 for (
auto const& mchits : mchits_v) {
287 auto plane = wireReadoutGeom.ChannelToWire(mchits.Channel()).at(0).Plane;
288 mchit_mult.at(plane) += mchits.size();
290 for (
auto const& mchit : mchits)
291 hMCHitQ_v.at(plane)->Fill(mchit.Charge(
true));
294 std::vector<size_t> recohit_mult(wireReadoutGeom.Nplanes(), 0);
296 double search_time_sum = 0;
299 for (
size_t hit_index = 0; hit_index < recohits.size(); ++hit_index) {
300 auto const&
hit = recohits.at(hit_index);
302 auto const& wire_id =
hit.WireID();
306 recohit_mult.at(wire_id.Plane) += 1;
309 auto ch = wireReadoutGeom.PlaneWireToChannel(wire_id);
311 if (mchits_v.size() <= ch)
313 <<
"Channel " << ch <<
" not found in MCHit vector!" << std::endl;
316 auto const& mchits = mchits_v.at(ch);
318 if (ch != mchits.Channel())
320 <<
"MCHit channel & vector index mismatch: " << mchits.Channel() <<
" != " << ch
326 start_time.
SetTime(clock_data.TPCTick2TDC(
hit.PeakTimeMinusRMS()), 0);
327 peak_time.
SetTime(clock_data.TPCTick2TDC(
hit.PeakTime()), 0);
328 end_time.
SetTime(clock_data.TPCTick2TDC(
hit.PeakTimePlusRMS()), 0);
331 auto start_iter = std::lower_bound(mchits.begin(), mchits.end(), start_time);
332 auto end_iter = std::upper_bound(mchits.begin(), mchits.end(), end_time);
336 double reco_q =
hit.PeakAmplitude();
341 double abs_dt_min = 1e9;
344 while (start_iter != end_iter) {
345 mc_qsum += (*start_iter).Charge(
true);
347 double dt = (*start_iter).PeakTime() - peak_time.
PeakTime();
349 if (abs_dt < 0) abs_dt *= -1;
351 if (abs_dt < abs_dt_min) {
354 mc_q = (*start_iter).Charge(
true);
368 hCorrQ_v.at(wire_id.Plane)->Fill(mc_q, reco_q);
369 hCorrQSum_v.at(wire_id.Plane)->Fill(mc_qsum, reco_q);
371 hQRatio_v.at(wire_id.Plane)->Fill(reco_q / mc_q);
372 hDT_v.at(wire_id.Plane)->Fill(dt_min);
378 for (
unsigned char plane = 0; plane < wireReadoutGeom.Nplanes(); ++plane) {
379 std::cout << mchit_mult.at(plane) << std::endl;
382 hCorrMult_v.at(plane)->Fill(mchit_mult.at(plane), recohit_mult.at(plane));
float PeakTime() const
Getter for start time.
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.
void analyze(art::Event const &e) override
Declaration of signal hit object.
MCHitAnaExample(fhicl::ParameterSet const &p)
std::vector< TH1D * > hQRatio_v
Histogram (per plane) for a ratio of RecoHit charge to the closest (in time) RecoHit charge...
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
std::vector< TH2D * > hCorrMult_v
Histogram (per plane) for # of MCHit vs. # of RecoHit.
EDAnalyzer(fhicl::ParameterSet const &pset)
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.
#define DEFINE_ART_MODULE(klass)
std::vector< TH1D * > hRecoHitQ_v
Histogram (per plane) for RecoHit charge.
std::string fRecoHitModuleName
Producer module for recob::Hit.
T get(std::string const &key) const
std::vector< TH1D * > hQSumRatio_v
std::vector< TH1D * > hMCHitMultPerRecoHit_v
Histogram (per plane) for MCHit multiplicity within start=>end time region of RecoHit.
Detector simulation of raw signals on wires.
std::vector< TH2D * > hCorrQ_v
Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
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=>end time of one RecoHit...
cet::coded_exception< error, detail::translate > exception
std::vector< TH1D * > hVoidHitQ_v
Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit. ...