LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
hit::MCHitAnaExample Class Reference
Inheritance diagram for hit::MCHitAnaExample:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 MCHitAnaExample (fhicl::ParameterSet const &p)
 
virtual ~MCHitAnaExample ()
 
void analyze (art::Event const &e) override
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

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 32 of file MCHitAnaExample_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 130 of file MCHitAnaExample_module.cc.

References fMCHitModuleName, fRecoHitModuleName, fhicl::ParameterSet::get(), hAnalysisTime, hCorrMult_v, hCorrQ_v, hCorrQSum_v, hDT_v, hMCHitMult_v, hMCHitMultPerRecoHit_v, hMCHitQ_v, hMCHitReadTime, hMCHitSearchTime, hMCHitSearchTimeSum, hQRatio_v, hQSumRatio_v, hRecoHitMult_v, hRecoHitQ_v, hRecoHitReadTime, hVoidHitQ_v, and geo::GeometryCore::Nplanes().

131  :
132  EDAnalyzer(p) // ,
133 
134  {
135  fRecoHitModuleName = p.get<std::string>( "RecoHitModuleName" );
136  fMCHitModuleName = p.get<std::string>( "MCHitModuleName" );
137 
139 
141 
142  for(unsigned char plane=0; plane < geo->Nplanes(); ++plane) {
143 
144  hMCHitQ_v.push_back(fs->make<TH1D>(Form("hMCHitQ_%d",plane),
145  Form("MCHit Charge (Plane %d); Charge [ADC]; # MCHit",plane),
146  250,0,2000));
147 
148  hMCHitMult_v.push_back(fs->make<TH1D>(Form("hMCHitMult_%d",plane),
149  Form("MCHit Multiplicity (Plane %d); Multiplicity; # MCHit",plane),
150  250,0,5000));
151 
152  hRecoHitQ_v.push_back(fs->make<TH1D>(Form("hRecoHitQ_%d",plane),
153  Form("RecoHit Charge (Plane %d); Charge [ADC]; # RecoHits",plane),
154  250,0,2000));
155 
156  hRecoHitMult_v.push_back(fs->make<TH1D>(Form("hRecoHitMult_%d",plane),
157  Form("RecoHit Multiplicity (Plane %d); Multiplicity; # RecoHits",plane),
158  200,0,2000));
159 
160  hCorrMult_v.push_back(fs->make<TH2D>(Form("hCorrMult_%d",plane),
161  Form("# MCHits vs. # RecoHits (Plane %d); # MCHits; # RecoHits",plane),
162  250,0,5000,
163  200,0,2000));
164 
165  hVoidHitQ_v.push_back(fs->make<TH1D>(Form("hVoidHitQ_%d",plane),
166  Form("RecoHit Charge (No Corresponding MCHit)) (Plane %d); Charge [ADC]; # RecoHits",plane),
167  250,0,2000));
168 
169  hCorrQ_v.push_back(fs->make<TH2D>(Form("hCorrQ_%d",plane),
170  Form("RecoHit Q vs. Closest MCHit Q (Plane %d); MCHit Charge [ADC]; RecoHit Charge [ADC]",plane),
171  250,0,2000,
172  250,0,2000));
173 
174  hCorrQSum_v.push_back(fs->make<TH2D>(Form("hCorrQSum_%d",plane),
175  Form("RecoHit Q vs. MCHit QSum Within Start=>End (Plane %d); MCHit Charge [ADC]; RecoHit Charge [ADC]",plane),
176  250,0,2000,
177  250,0,2000));
178 
179  hQRatio_v.push_back(fs->make<TH1D>(Form("hQRatio_%d",plane),
180  Form("Reco/MCHit Charge (Plane %d); Ratio; # RecoHits",plane),
181  200, 0, 2));
182 
183  hQSumRatio_v.push_back(fs->make<TH1D>(Form("hQSumRatio_%d",plane),
184  Form("Reco/MCHit Charge (Plane %d); Ratio; # RecoHits",plane),
185  200, 0, 2));
186 
187  hDT_v.push_back(fs->make<TH1D>(Form("hDT_%d",plane),
188  Form("#DeltaT btw Reco and Closest MCHit (Plane %d); #DeltaT; # RecoHits",plane),
189  190,-9.5,9.5));
190 
191  hMCHitMultPerRecoHit_v.push_back(fs->make<TH1D>(Form("hMCHitMultPerRecoHit_%d",plane),
192  Form("MCHit Multiplicity per RecoHit (Plane %d); Multiplicity; # RecoHits",plane),
193  21,-1.5,19.5));
194  }
195 
196  hRecoHitReadTime = fs->make<TH1D>("hRecoHitReadTime",
197  "Real Time to Read recob::Hit From Disk; Real Time [ms]; Events",
198  200,0,1000);
199 
200  hMCHitReadTime = fs->make<TH1D>("hMCHitReadTime",
201  "Real Time to Read sim::MCHit From Disk; Real Time [ms]; Events",
202  200,0,1000);
203 
204  hAnalysisTime = fs->make<TH1D>("hAnalysisTime",
205  "Analysis Time to Run analyze() Function; Real Time [ms]; Events",
206  200,0,1000);
207 
208  hMCHitSearchTime = fs->make<TH1D>("hMCHitSearchTime",
209  "Time to Search Multiple sim::MCHit Per RecoHit; RealTime [us]; # RecoHit",
210  200,0,200);
211 
212  hMCHitSearchTimeSum = fs->make<TH1D>("hMCHitSearchTimeSum",
213  "Time to Search Multiple sim::MCHit for All RecoHit in Event; RealTime [ms]; # Event",
214  200,0,200);
215 
216  }
TH1D * hMCHitSearchTimeSum
Time to search for corresponding MCHit per RecoHit summed over all RecoHits (per event) ...
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.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< TH1D * > hRecoHitQ_v
Histogram (per plane) for RecoHit charge.
std::string fRecoHitModuleName
Producer module for recob::Hit.
std::vector< TH1D * > hQSumRatio_v
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::vector< TH1D * > hMCHitMultPerRecoHit_v
Histogram (per plane) for MCHit multiplicity within start=>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.
Namespace collecting geometry-related classes utilities.
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...
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 218 of file MCHitAnaExample_module.cc.

219  {}

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 221 of file MCHitAnaExample_module.cc.

References geo::GeometryCore::ChannelToWire(), DEFINE_ART_MODULE, fAnaWatch, Fill(), fMCHitModuleName, fReadWatch, fRecoHitModuleName, fSearchWatch, art::DataViewImpl::getByLabel(), hAnalysisTime, hCorrMult_v, hCorrQ_v, hCorrQSum_v, hDT_v, hMCHitMult_v, hMCHitMultPerRecoHit_v, hMCHitQ_v, hMCHitReadTime, hMCHitSearchTime, hMCHitSearchTimeSum, hQRatio_v, hQSumRatio_v, hRecoHitMult_v, hRecoHitQ_v, hRecoHitReadTime, hVoidHitQ_v, art::Handle< T >::isValid(), geo::GeometryCore::Nplanes(), sim::MCHit::PeakTime(), geo::GeometryCore::PlaneWireToChannel(), sim::MCHit::SetTime(), and detinfo::DetectorClocks::TPCTick2TDC().

222  {
223  fAnaWatch.Start();
224 
226  const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
227 
228  fReadWatch.Start();
230  e.getByLabel(fMCHitModuleName,mcHandle);
231  if(!mcHandle.isValid()) throw cet::exception(__PRETTY_FUNCTION__) << "MCHit not found!" <<std::endl;
232  hMCHitReadTime->Fill(fReadWatch.RealTime() * 1.e3);
233  const std::vector<sim::MCHitCollection> &mchits_v = *mcHandle;
234 
235  fReadWatch.Start();
237  e.getByLabel(fRecoHitModuleName,recoHandle);
238  if(!recoHandle.isValid()) throw cet::exception(__PRETTY_FUNCTION__) << "RecoHit not found!" << std::endl;
239  hRecoHitReadTime->Fill(fReadWatch.RealTime() * 1.e3);
240  const std::vector<recob::Hit> &recohits = *recoHandle;
241 
242  //
243  // Work on purely MCHit info
244  //
245  std::vector<size_t> mchit_mult(geo->Nplanes(),0);
246  for(auto const& mchits : mchits_v) {
247 
248  auto plane = geo->ChannelToWire(mchits.Channel()).at(0).Plane;
249 
250  mchit_mult.at(plane) += mchits.size();
251 
252  for(auto const& mchit : mchits)
253 
254  hMCHitQ_v.at(plane)->Fill(mchit.Charge(true));
255 
256  }
257 
258  std::vector<size_t> recohit_mult(geo->Nplanes(),0);
259 
260  double search_time_sum = 0;
261 
262  // Loop over RecoHit
263  for(size_t hit_index=0; hit_index<recohits.size(); ++hit_index) {
264 
265  auto const &hit = recohits.at(hit_index);
266 
267  auto const &wire_id = hit.WireID();
268 
269  // Fill purly RecoHit info
270  hRecoHitQ_v.at(wire_id.Plane)->Fill(hit.PeakAmplitude());
271  recohit_mult.at(wire_id.Plane) += 1;
272 
273  // Figure out channel & retrieve MCHitCollection for this channel
274  auto ch = geo->PlaneWireToChannel(wire_id.Plane,
275  wire_id.Wire,
276  wire_id.TPC,
277  wire_id.Cryostat);
278 
279  if(mchits_v.size() <= ch )
280  throw cet::exception(__PRETTY_FUNCTION__)
281  << "Channel "<<ch<<" not found in MCHit vector!"<<std::endl;
282 
283  // Found MCHitCollection
284  auto const& mchits = mchits_v.at(ch);
285 
286  if( ch != mchits.Channel() )
287  throw cet::exception(__PRETTY_FUNCTION__)
288  << "MCHit channel & vector index mismatch: "
289  << mchits.Channel() << " != " << ch << std::endl;
290 
291  // Locate corresponding MCHit(s) to this RecoHit
292  sim::MCHit start_time, end_time, peak_time;
293 
294  start_time.SetTime ( ts->TPCTick2TDC( hit.PeakTimeMinusRMS() ), 0 );
295  peak_time.SetTime ( ts->TPCTick2TDC( hit.PeakTime() ), 0 );
296  end_time.SetTime ( ts->TPCTick2TDC( hit.PeakTimePlusRMS() ), 0 );
297 
298  fSearchWatch.Start();
299  auto start_iter = std::lower_bound ( mchits.begin(), mchits.end(), start_time );
300  auto end_iter = std::upper_bound ( mchits.begin(), mchits.end(), end_time );
301  search_time_sum += fSearchWatch.RealTime() * 1.e3;
302  hMCHitSearchTime->Fill(fSearchWatch.RealTime() * 1.e6);
303 
304  double reco_q = hit.PeakAmplitude();
305  double mc_qsum = 0;
306  double mc_q = 0;
307  double mult = 0;
308  double dt_min = 0;
309  double abs_dt_min = 1e9;
310 
311  // Loop over MCHit(s) that reside in start=>end time of MCHit
312  while(start_iter != end_iter) {
313  mc_qsum += (*start_iter).Charge(true);
314  ++mult;
315  double dt = (*start_iter).PeakTime() - peak_time.PeakTime();
316  double abs_dt = dt;
317  if(abs_dt<0) abs_dt *= -1;
318 
319  if(abs_dt < abs_dt_min) {
320  abs_dt_min = abs_dt;
321  dt_min = dt;
322  mc_q = (*start_iter).Charge(true);
323  }
324  ++start_iter;
325  }
326 
327  // Fill histograms
328  hMCHitMultPerRecoHit_v.at (wire_id.Plane) -> Fill( mult );
329 
330  if(!mc_qsum) hVoidHitQ_v.at (wire_id.Plane) -> Fill( reco_q );
331 
332  else {
333 
334  hRecoHitQ_v.at (wire_id.Plane) -> Fill ( reco_q );
335  hCorrQ_v.at (wire_id.Plane) -> Fill ( mc_q, reco_q );
336  hCorrQSum_v.at (wire_id.Plane) -> Fill ( mc_qsum, reco_q );
337  hQSumRatio_v.at (wire_id.Plane) -> Fill ( reco_q / mc_qsum );
338  hQRatio_v.at (wire_id.Plane) -> Fill ( reco_q / mc_q );
339  hDT_v.at (wire_id.Plane) -> Fill ( dt_min );
340  }
341 
342  } // end looping over hits
343 
344  // Fill purely-MCHit and purely-RecoHit multiplicity histograms
345  for(unsigned char plane=0; plane<geo->Nplanes(); ++plane) {
346  std::cout<<mchit_mult.at(plane)<<std::endl;
347  hMCHitMult_v.at (plane) -> Fill( mchit_mult.at (plane) );
348  hRecoHitMult_v.at (plane) -> Fill( recohit_mult.at (plane) );
349  hCorrMult_v.at (plane) -> Fill( mchit_mult.at (plane), recohit_mult.at (plane) );
350  }
351 
352  hAnalysisTime->Fill(fAnaWatch.RealTime() * 1.e3);
353  hMCHitSearchTimeSum->Fill(search_time_sum);
354 
355  }
float PeakTime() const
Getter for start time.
Definition: MCHit.h:79
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:61
TNtupleSim Fill(f1, f2, f3, f4)
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
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...
bool isValid() const
Definition: Handle.h:190
std::string fMCHitModuleName
Producer module for MCHit.
std::vector< TH1D * > hRecoHitMult_v
Histogram (per plane) for RecoHit multiplicity in each event.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
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=>end time region of RecoHit.
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
std::vector< TH2D * > hCorrQ_v
Histogram (per plane) for charge of one MCHit that is closest (in time) to one RecoHit.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
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.
Float_t e
Definition: plot.C:34
std::vector< TH1D * > hMCHitMult_v
Histogram (per plane) for MCHit multiplicity in each event.
Namespace collecting geometry-related classes utilities.
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
Definition: exception.h:33
std::vector< TH1D * > hVoidHitQ_v
Histogram (per plane) for charge of some RecoHit that has no corresponding MCHit. ...
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

Referenced by art::EDAnalyzer::doEvent(), and art::OutputModule::doWriteEvent().

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDAnalyzer::currentContext ( ) const
protectedinherited

Definition at line 114 of file EDAnalyzer.cc.

References art::EDAnalyzer::current_context_.

Referenced by art::EDAnalyzer::workerType().

115  {
116  return current_context_.get();
117  }
CPC_exempt_ptr current_context_
Definition: EDAnalyzer.h:179
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

Referenced by art::OutputModule::doWriteEvent().

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:34
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

Referenced by art::RootOutputFile::writeOne().

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

TStopwatch hit::MCHitAnaExample::fAnaWatch
private

Definition at line 55 of file MCHitAnaExample_module.cc.

Referenced by analyze().

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

Producer module for MCHit.

Definition at line 50 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TStopwatch hit::MCHitAnaExample::fReadWatch
private

Definition at line 55 of file MCHitAnaExample_module.cc.

Referenced by analyze().

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

Producer module for recob::Hit.

Definition at line 47 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TStopwatch hit::MCHitAnaExample::fSearchWatch
private

Definition at line 55 of file MCHitAnaExample_module.cc.

Referenced by analyze().

TH1D* hit::MCHitAnaExample::hAnalysisTime
private

Time to run analyze() function.

Definition at line 68 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

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

Definition at line 101 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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 107 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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 110 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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 122 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

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

Definition at line 84 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

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

Definition at line 125 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

Histogram (per plane) for all MCHit charge.

Definition at line 81 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TH1D* hit::MCHitAnaExample::hMCHitReadTime
private

Time to read MCHit from disk.

Definition at line 65 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TH1D* hit::MCHitAnaExample::hMCHitSearchTime
private

Time to search for corresponding MCHit per RecoHit.

Definition at line 71 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TH1D* hit::MCHitAnaExample::hMCHitSearchTimeSum
private

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

Definition at line 74 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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 113 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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 119 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

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

Definition at line 94 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

Histogram (per plane) for RecoHit charge.

Definition at line 91 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

TH1D* hit::MCHitAnaExample::hRecoHitReadTime
private

Time to read recob::Hit from disk.

Definition at line 62 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().

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

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

Definition at line 104 of file MCHitAnaExample_module.cc.

Referenced by analyze(), and MCHitAnaExample().


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