LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
opreco::OpticalRecoAna Class Reference
Inheritance diagram for opreco::OpticalRecoAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Types

using ModuleType = EDAnalyzer
 

Public Member Functions

 OpticalRecoAna (const fhicl::ParameterSet &)
 
void beginJob ()
 
void analyze (const art::Event &)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void get_MC_particle_list (sim::ParticleList const &, std::vector< simb::MCParticle > &)
 
simb::Origin_t get_MC_particle_origin (simb::MCParticle const &)
 
float update_MC_particle_time (simb::MCParticle const &, bool &, geo::Geometry const &)
 
void match_flashes_to_tracks (std::vector< recob::OpFlash > const &, std::vector< recob::Track > const &)
 
void match_flashes_to_particles (std::vector< recob::OpFlash > const &, std::vector< simb::MCParticle > const &, float const &, geo::Geometry const &)
 

Private Attributes

std::string fFlashModuleLabel
 
std::string fTrackModuleLabel
 
float fKineticEnergyMin
 
float fPEMin
 
float fTimeMatchMax
 
std::vector< flash_matchfFlash_match_vector
 
std::vector< track_matchfTrack_match_vector
 
std::vector< particle_matchfParticle_match_vector
 
TH1F * fTimeDiff
 
TH1F * fTimeDiff_fine
 
TH1I * fNBeamFlashes
 
TTree * fMatchTree_PF
 
TTree * fMatchTree_PF_NotNu
 
int fRun
 
int fEvent
 
int fParticleID
 
int fParticleMother
 
int fParticleTrackID
 
float fParticleTime
 
float fParticleVx
 
float fParticleVy
 
float fParticleVz
 
int fFlashID
 
float fFlashTime
 
float fFlashTimeWidth
 
float fFlashY
 
float fFlashZ
 
float fFlashYWidth
 
float fFlashZWidth
 
float fFlashPE
 
int fFlashOnBeamTime
 
int fMatchIndex
 
int fMatchIndex_NotNu
 

Detailed Description

Definition at line 44 of file OpticalRecoAna_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Constructor & Destructor Documentation

opreco::OpticalRecoAna::OpticalRecoAna ( const fhicl::ParameterSet )

Definition at line 111 of file OpticalRecoAna_module.cc.

References fFlash_match_vector, fFlashModuleLabel, fKineticEnergyMin, fParticle_match_vector, fPEMin, fTimeMatchMax, fTrack_match_vector, fTrackModuleLabel, and fhicl::ParameterSet::get().

111  : EDAnalyzer(pset)
112 {
113 
114  // Indicate that the Input Module comes from .fcl
115  fFlashModuleLabel = pset.get<std::string>("FlashModule");
116  fTrackModuleLabel = pset.get<std::string>("TrackModule");
117  fKineticEnergyMin = pset.get<float>("KineticEnergyMin");
118  fPEMin = pset.get<float>("PEMin");
119  fTimeMatchMax = pset.get<float>("TimeMatchMax");
120 
121  fFlash_match_vector.clear();
122  fTrack_match_vector.clear();
123  fParticle_match_vector.clear();
124 }
std::vector< flash_match > fFlash_match_vector
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
std::vector< particle_match > fParticle_match_vector
std::vector< track_match > fTrack_match_vector

Member Function Documentation

void opreco::OpticalRecoAna::analyze ( const art::Event evt)

Definition at line 189 of file OpticalRecoAna_module.cc.

References art::EventID::event(), fEvent, fFlash_match_vector, fFlashModuleLabel, fNBeamFlashes, fParticle_match_vector, fRun, get_MC_particle_list(), art::ProductRetriever::getByLabel(), art::Event::id(), art::Event::isRealData(), match_flashes_to_particles(), MF_LOG_INFO, cheat::ParticleInventoryService::ParticleList(), and art::EventID::run().

190 {
191 
192  //get flag for MC
193  const bool is_MC = !(evt.isRealData());
194 
195  fRun = evt.id().run();
196  fEvent = evt.id().event();
197 
198  //first get out track, flash, and particle list handles
200  evt.getByLabel(fFlashModuleLabel, flash_handle);
201  std::vector<recob::OpFlash> const& flash_vector(*flash_handle);
202  fFlash_match_vector.resize(flash_vector.size());
203 
204  MF_LOG_INFO("OpticalRecoAna") << "Number of flashes is " << flash_vector.size() << std::flush;
205 
206  //all this for the MC matching
207  if (is_MC) {
208 
210  std::vector<simb::MCParticle> particle_list;
211  get_MC_particle_list(pi_serv->ParticleList(), particle_list);
212  fParticle_match_vector.resize(particle_list.size());
213 
214  mf::LogInfo("OpticalRecoAna") << "Number of MC particles is " << particle_list.size();
215 
217  const float ns_per_PMT_tick =
218  1e3; // already converted to microseconds//( 1e3 / odp->SampleFreq()) ; //SampleFreq is in MHz
220 
221  match_flashes_to_particles(flash_vector, particle_list, ns_per_PMT_tick, *geometry_handle);
222  int n_flashes = 0;
223  for (auto const& my_flash : flash_vector) {
224  if (my_flash.OnBeamTime() == 1) n_flashes++;
225  }
226  fNBeamFlashes->Fill(n_flashes);
227  }
228 }
void match_flashes_to_particles(std::vector< recob::OpFlash > const &, std::vector< simb::MCParticle > const &, float const &, geo::Geometry const &)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< flash_match > fFlash_match_vector
bool isRealData() const
Definition: Event.cc:53
RunNumber_t run() const
Definition: EventID.h:98
#define MF_LOG_INFO(category)
const sim::ParticleList & ParticleList() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::vector< particle_match > fParticle_match_vector
void get_MC_particle_list(sim::ParticleList const &, std::vector< simb::MCParticle > &)
EventNumber_t event() const
Definition: EventID.h:116
EventID id() const
Definition: Event.cc:23
void opreco::OpticalRecoAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 127 of file OpticalRecoAna_module.cc.

References fEvent, fFlashID, fFlashOnBeamTime, fFlashPE, fFlashTime, fFlashTimeWidth, fFlashY, fFlashYWidth, fFlashZ, fMatchIndex, fMatchIndex_NotNu, fMatchTree_PF, fMatchTree_PF_NotNu, fNBeamFlashes, fParticleID, fParticleMother, fParticleTime, fParticleTrackID, fParticleVx, fParticleVy, fParticleVz, fRun, fTimeDiff, and fTimeDiff_fine.

128 {
130  fTimeDiff = tfs->make<TH1F>(
131  "htdiff",
132  "Time difference between particles and flashes; t_diff (ns); flash/particle pairs",
133  1e3,
134  -5e6,
135  5e6);
136  fTimeDiff_fine = tfs->make<TH1F>(
137  "htdiff_fine",
138  "Time difference between particles and flashes; t_diff (ns); flash/particle pairs",
139  100,
140  -1000,
141  1000);
142  fNBeamFlashes = tfs->make<TH1I>(
143  "hNBeamFlashes", "Number of flashes OnBeamTime per event; N_{Flashes}; Events", 5, 0, 5);
144 
145  fMatchTree_PF = tfs->make<TTree>("MatchTree_PF", "MatchTree_PF");
146  fMatchTree_PF->Branch("Run", &fRun, "Run/I");
147  fMatchTree_PF->Branch("Event", &fEvent, "Event/I");
148  fMatchTree_PF->Branch("p_id", &fParticleID, "p_id/I");
149  fMatchTree_PF->Branch("p_time", &fParticleTime, "p_time/F");
150  fMatchTree_PF->Branch("p_vx", &fParticleVx, "p_vx/F");
151  fMatchTree_PF->Branch("p_vy", &fParticleVy, "p_vy/F");
152  fMatchTree_PF->Branch("p_vz", &fParticleVz, "p_vz/F");
153  fMatchTree_PF->Branch("p_mid", &fParticleMother, "p_mid/I");
154  fMatchTree_PF->Branch("p_trackid", &fParticleTrackID, "p_trackid/I");
155  fMatchTree_PF->Branch("FlashID", &fFlashID, "flash_id/I");
156  fMatchTree_PF->Branch("f_time", &fFlashTime, "f_time/F");
157  fMatchTree_PF->Branch("f_timewidth", &fFlashTimeWidth, "f_timewidth/F");
158  fMatchTree_PF->Branch("f_y", &fFlashY, "f_y/F");
159  fMatchTree_PF->Branch("f_z", &fFlashZ, "f_z/F");
160  fMatchTree_PF->Branch("f_ywidth", &fFlashYWidth, "f_ywidth/F");
161  fMatchTree_PF->Branch("f_zwidth", &fFlashYWidth, "f_zwidth/F");
162  fMatchTree_PF->Branch("f_onbeamtime", &fFlashOnBeamTime, "f_onbeamtime/I");
163  fMatchTree_PF->Branch("f_pe", &fFlashPE, "f_pe/F");
164  fMatchTree_PF->Branch("matchIndex", &fMatchIndex, "matchIndex/I");
165 
166  fMatchTree_PF_NotNu = tfs->make<TTree>("MatchTree_PF_NotNu", "MatchTree_PF_NotNu");
167  fMatchTree_PF_NotNu->Branch("Run", &fRun, "Run/I");
168  fMatchTree_PF_NotNu->Branch("Event", &fEvent, "Event/I");
169  fMatchTree_PF_NotNu->Branch("p_id", &fParticleID, "p_id/I");
170  fMatchTree_PF_NotNu->Branch("p_time", &fParticleTime, "p_time/F");
171  fMatchTree_PF_NotNu->Branch("p_vx", &fParticleVx, "p_vx/F");
172  fMatchTree_PF_NotNu->Branch("p_vy", &fParticleVy, "p_vy/F");
173  fMatchTree_PF_NotNu->Branch("p_vz", &fParticleVz, "p_vz/F");
174  fMatchTree_PF_NotNu->Branch("p_mid", &fParticleMother, "p_mid/I");
175  fMatchTree_PF_NotNu->Branch("p_trackid", &fParticleTrackID, "p_trackid/I");
176  fMatchTree_PF_NotNu->Branch("FlashID", &fFlashID, "flash_id/I");
177  fMatchTree_PF_NotNu->Branch("f_time", &fFlashTime, "f_time/F");
178  fMatchTree_PF_NotNu->Branch("f_timewidth", &fFlashTimeWidth, "f_timewidth/F");
179  fMatchTree_PF_NotNu->Branch("f_y", &fFlashY, "f_y/F");
180  fMatchTree_PF_NotNu->Branch("f_z", &fFlashZ, "f_z/F");
181  fMatchTree_PF_NotNu->Branch("f_ywidth", &fFlashYWidth, "f_ywidth/F");
182  fMatchTree_PF_NotNu->Branch("f_zwidth", &fFlashYWidth, "f_zwidth/F");
183  fMatchTree_PF_NotNu->Branch("f_onbeamtime", &fFlashOnBeamTime, "f_onbeamtime/I");
184  fMatchTree_PF_NotNu->Branch("f_pe", &fFlashPE, "f_pe/F");
185  fMatchTree_PF_NotNu->Branch("matchIndex", &fMatchIndex_NotNu, "matchIndex/I");
186 }
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void opreco::OpticalRecoAna::get_MC_particle_list ( sim::ParticleList const &  plist,
std::vector< simb::MCParticle > &  particle_vector 
)
private

Definition at line 236 of file OpticalRecoAna_module.cc.

References util::abs(), sim::ParticleList::begin(), simb::MCParticle::E(), sim::ParticleList::end(), fKineticEnergyMin, ipart, simb::MCParticle::Mass(), and simb::MCParticle::PdgCode().

Referenced by analyze().

238 {
239 
240  for (sim::ParticleList::const_iterator ipart = plist.begin(); ipart != plist.end(); ++ipart) {
241 
242  const simb::MCParticle* particle = (*ipart).second;
243  //do not store if it's below our energy cut
244  if (particle->E() < 0.001 * particle->Mass() + fKineticEnergyMin) continue;
245 
246  //check to see if it's a charged particle we expect to leave ionization
247  const int pdg = std::abs(particle->PdgCode());
248  if (pdg == 11 // electron
249  || pdg == 13 //muon
250  || pdg == 15 //tau
251  || pdg == 211 //charged pion
252  || pdg == 321 //charged kaon
253  || pdg == 2212 //proton
254  || pdg == 2214 //delta
255  || pdg == 2224 //delta
256  || pdg == 3222 //sigma
257  || pdg == 3112 //sigma
258  || pdg == 3312 //xi
259  || pdg == 3334 //omega
260  ) {
261  particle_vector.emplace_back(*particle);
262  }
263  }
264 }
double E(const int i=0) const
Definition: MCParticle.h:234
int PdgCode() const
Definition: MCParticle.h:213
Int_t ipart
Definition: Style.C:10
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
double Mass() const
Definition: MCParticle.h:240
constexpr auto abs(T v)
Returns the absolute value of the argument.
simb::Origin_t opreco::OpticalRecoAna::get_MC_particle_origin ( simb::MCParticle const &  particle)
private
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
void opreco::OpticalRecoAna::match_flashes_to_particles ( std::vector< recob::OpFlash > const &  flash_vector,
std::vector< simb::MCParticle > const &  particle_vector,
float const &  ns_per_PMT_tick,
geo::Geometry const &  geometry 
)
private

Definition at line 294 of file OpticalRecoAna_module.cc.

References util::abs(), fFlash_match_vector, fFlashID, fFlashOnBeamTime, fFlashPE, fFlashTime, fFlashTimeWidth, fFlashY, fFlashYWidth, fFlashZ, fFlashZWidth, fMatchIndex, fMatchIndex_NotNu, fMatchTree_PF, fMatchTree_PF_NotNu, fParticle_match_vector, fParticleID, fParticleMother, fParticleTime, fParticleTrackID, fParticleVx, fParticleVy, fParticleVz, fPEMin, fTimeDiff, fTimeDiff_fine, fTimeMatchMax, get_MC_particle_origin(), simb::kBeamNeutrino, recob::OpFlash::Time(), and update_MC_particle_time().

Referenced by analyze().

299 {
300  fMatchIndex = 0;
301  fMatchIndex_NotNu = 0;
302  int lastFlashID = -1;
303 
304  for (size_t i_particle = 0; i_particle < particle_vector.size(); i_particle++) {
305 
306  simb::MCParticle const& my_particle(particle_vector.at(i_particle));
307  bool pass_check = false;
308  const float particle_time = update_MC_particle_time(my_particle, pass_check, geometry);
309  if (!pass_check) continue;
310 
311  for (size_t i_flash = 0; i_flash < flash_vector.size(); i_flash++) {
312 
313  recob::OpFlash const& my_flash(flash_vector.at(i_flash));
314  if (my_flash.TotalPE() < fPEMin) continue;
315 
316  const float flash_time = my_flash.Time() * ns_per_PMT_tick;
317 
318  fTimeDiff->Fill(particle_time - flash_time);
319  fTimeDiff_fine->Fill(particle_time - flash_time);
320 
321  fParticleID = i_particle;
322  fParticleTime = particle_time;
323  fParticleVx = my_particle.Vx(0);
324  fParticleVy = my_particle.Vy(0);
325  fParticleVz = my_particle.Vz(0);
326  fParticleMother = my_particle.Mother();
327  fParticleTrackID = my_particle.TrackId();
328  fFlashID = i_flash;
329  fFlashTime = flash_time;
330  fFlashTimeWidth = my_flash.TimeWidth() * ns_per_PMT_tick;
331  fFlashY = my_flash.YCenter();
332  fFlashZ = my_flash.ZCenter();
333  fFlashYWidth = my_flash.YWidth();
334  fFlashZWidth = my_flash.ZWidth();
335  fFlashPE = my_flash.TotalPE();
336  fFlashOnBeamTime = my_flash.OnBeamTime();
337 
338  bool beam_match = ((std::abs(particle_time - flash_time) / fFlashTimeWidth) < fTimeMatchMax &&
340  bool nonbeam_match =
341  ((std::abs(particle_time - flash_time) / fFlashTimeWidth) < fTimeMatchMax &&
343 
344  if (beam_match) {
345  fMatchTree_PF->Fill();
346  fMatchIndex++;
347 
348  fFlash_match_vector.at(i_flash).particle_indices.push_back(i_particle);
349  fParticle_match_vector.at(i_particle).flash_indices.push_back(i_flash);
350  }
351  else if (nonbeam_match) {
352  if (lastFlashID != fFlashID) {
353  fMatchTree_PF_NotNu->Fill();
355  lastFlashID = fFlashID;
356  }
357  }
358 
359  } //end inner loop over particles
360 
361  } //end loop over flashes
362 
363 } //end match_flashes_to_particles
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::vector< flash_match > fFlash_match_vector
simb::Origin_t get_MC_particle_origin(simb::MCParticle const &)
double Time() const
Definition: OpFlash.h:118
std::vector< particle_match > fParticle_match_vector
float update_MC_particle_time(simb::MCParticle const &, bool &, geo::Geometry const &)
Beam neutrinos.
Definition: MCTruth.h:23
void opreco::OpticalRecoAna::match_flashes_to_tracks ( std::vector< recob::OpFlash > const &  ,
std::vector< recob::Track > const &   
)
private
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
float opreco::OpticalRecoAna::update_MC_particle_time ( simb::MCParticle const &  particle,
bool &  pass_check,
geo::Geometry const &  geometry 
)
private

Definition at line 266 of file OpticalRecoAna_module.cc.

References e, simb::MCParticle::NumberTrajectoryPoints(), geo::GeometryCore::PositionToTPC(), simb::MCParticle::T(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

Referenced by match_flashes_to_particles().

269 {
270 
271  pass_check = false;
272 
273  const size_t numtraj = particle.NumberTrajectoryPoints();
274  size_t t_iter = 0;
275  while (t_iter < numtraj) {
276  try {
277  // check if the particle is inside a TPC
278  geo::Point_t const pos{particle.Vx(t_iter), particle.Vy(t_iter), particle.Vz(t_iter)};
279  geometry.PositionToTPC(pos);
280  }
281  catch (cet::exception& e) {
282  ++t_iter;
283  continue;
284  }
285  break;
286  }
287 
288  if (t_iter == numtraj) return 0;
289 
290  pass_check = true;
291  return particle.T(t_iter);
292 }
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

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

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79

Member Data Documentation

int opreco::OpticalRecoAna::fEvent
private

Definition at line 83 of file OpticalRecoAna_module.cc.

Referenced by analyze(), and beginJob().

std::vector<flash_match> opreco::OpticalRecoAna::fFlash_match_vector
private

Definition at line 59 of file OpticalRecoAna_module.cc.

Referenced by analyze(), match_flashes_to_particles(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fFlashID
private

Definition at line 91 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

std::string opreco::OpticalRecoAna::fFlashModuleLabel
private

Definition at line 53 of file OpticalRecoAna_module.cc.

Referenced by analyze(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fFlashOnBeamTime
private

Definition at line 99 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashPE
private

Definition at line 98 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashTime
private

Definition at line 92 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashTimeWidth
private

Definition at line 93 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashY
private

Definition at line 94 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashYWidth
private

Definition at line 96 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashZ
private

Definition at line 95 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashZWidth
private

Definition at line 97 of file OpticalRecoAna_module.cc.

Referenced by match_flashes_to_particles().

float opreco::OpticalRecoAna::fKineticEnergyMin
private

Definition at line 55 of file OpticalRecoAna_module.cc.

Referenced by get_MC_particle_list(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fMatchIndex
private

Definition at line 100 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fMatchIndex_NotNu
private

Definition at line 101 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

TTree* opreco::OpticalRecoAna::fMatchTree_PF
private

Definition at line 80 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

TTree* opreco::OpticalRecoAna::fMatchTree_PF_NotNu
private

Definition at line 81 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

TH1I* opreco::OpticalRecoAna::fNBeamFlashes
private

Definition at line 78 of file OpticalRecoAna_module.cc.

Referenced by analyze(), and beginJob().

std::vector<particle_match> opreco::OpticalRecoAna::fParticle_match_vector
private

Definition at line 61 of file OpticalRecoAna_module.cc.

Referenced by analyze(), match_flashes_to_particles(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fParticleID
private

Definition at line 84 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fParticleMother
private

Definition at line 85 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleTime
private

Definition at line 87 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fParticleTrackID
private

Definition at line 86 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVx
private

Definition at line 88 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVy
private

Definition at line 89 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVz
private

Definition at line 90 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fPEMin
private

Definition at line 56 of file OpticalRecoAna_module.cc.

Referenced by match_flashes_to_particles(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fRun
private

Definition at line 82 of file OpticalRecoAna_module.cc.

Referenced by analyze(), and beginJob().

TH1F* opreco::OpticalRecoAna::fTimeDiff
private

Definition at line 76 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

TH1F* opreco::OpticalRecoAna::fTimeDiff_fine
private

Definition at line 77 of file OpticalRecoAna_module.cc.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fTimeMatchMax
private

Definition at line 57 of file OpticalRecoAna_module.cc.

Referenced by match_flashes_to_particles(), and OpticalRecoAna().

std::vector<track_match> opreco::OpticalRecoAna::fTrack_match_vector
private

Definition at line 60 of file OpticalRecoAna_module.cc.

Referenced by OpticalRecoAna().

std::string opreco::OpticalRecoAna::fTrackModuleLabel
private

Definition at line 54 of file OpticalRecoAna_module.cc.

Referenced by OpticalRecoAna().


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