LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
opreco::OpticalRecoAna Class Reference

#include "OpticalRecoAna.h"

Inheritance diagram for opreco::OpticalRecoAna:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 OpticalRecoAna (const fhicl::ParameterSet &)
 
virtual ~OpticalRecoAna ()
 
void beginJob ()
 
void analyze (const art::Event &)
 
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 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 compare_track_and_flash (recob::Track const &, recob::OpFlash const &, bool &)
 
void match_flashes_to_particles (std::vector< recob::OpFlash > const &, std::vector< simb::MCParticle > const &, float const &, geo::Geometry const &)
 
void compare_particle_and_flash (simb::MCParticle const &, recob::OpFlash const &, bool &, float const &, geo::Geometry const &)
 
void match_flashes_to_particles (std::vector< recob::Track > const &, std::vector< simb::MCParticle > const &, geo::Geometry const &)
 
void compare_particle_and_track (simb::MCParticle const &, recob::Track const &, bool &, geo::Geometry const &)
 
void FillMatchTree_PF (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 42 of file OpticalRecoAna.h.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file OpticalRecoAna_module.cc.

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

28  : EDAnalyzer(pset)
29 {
30 
31  // Indicate that the Input Module comes from .fcl
32  fFlashModuleLabel = pset.get<std::string>("FlashModule");
33  fTrackModuleLabel = pset.get<std::string>("TrackModule");
34  fKineticEnergyMin = pset.get<float>("KineticEnergyMin");
35  fPEMin = pset.get<float>("PEMin");
36  fTimeMatchMax = pset.get<float>("TimeMatchMax");
37 
38  fFlash_match_vector.clear();
39  fTrack_match_vector.clear();
40  fParticle_match_vector.clear();
41 }
std::string fFlashModuleLabel
std::vector< flash_match > fFlash_match_vector
std::string fTrackModuleLabel
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::vector< particle_match > fParticle_match_vector
std::vector< track_match > fTrack_match_vector
opreco::OpticalRecoAna::~OpticalRecoAna ( )
virtual

Definition at line 46 of file OpticalRecoAna_module.cc.

47 {}

Member Function Documentation

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

Definition at line 106 of file OpticalRecoAna_module.cc.

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

107 {
108 
109  //get flag for MC
110  const bool is_MC= !(evt.isRealData());
111 
112  fRun = evt.id().run();
113  fEvent = evt.id().event();
114 
115  //first get out track, flash, and particle list handles
117  evt.getByLabel(fFlashModuleLabel, flash_handle);
118  std::vector<recob::OpFlash> const& flash_vector(*flash_handle);
119  fFlash_match_vector.resize(flash_vector.size());
120 
121  LOG_INFO ("OpticalRecoAna")
122  << "Number of flashes is " << flash_vector.size() << std::flush;
123 
124  //art::Handle< std::vector<recob::Track> > track_handle;
125  //evt.getByLabel(fTrackModuleLabel, track_handle);
126  //std::vector<recob::Track> const& track_vector(*track_handle);
127  //fTrack_match_vector.resize(track_vector.size());
128 
129  //LOG_INFO ("OpticalRecoAna")
130  //<< "Number of tracks is " << track_vector.size() << std::flush;
131 
132  //match_flashes_to_tracks(flash_vector, track_vector);
133 
134  //all this for the MC matching
135  if(is_MC){
136 
138  std::vector<simb::MCParticle> particle_list;
139  get_MC_particle_list(pi_serv->ParticleList(),particle_list);
140  fParticle_match_vector.resize(particle_list.size());
141 
142  mf::LogInfo("OpticalRecoAna")
143  << "Number of MC particles is " << particle_list.size();
144 
145 
147  const float ns_per_PMT_tick = 1e3;// already converted to microseconds//( 1e3 / odp->SampleFreq()) ; //SampleFreq is in MHz
148  art::ServiceHandle<geo::Geometry> geometry_handle;
149 
150  match_flashes_to_particles(flash_vector,
151  particle_list,
152  ns_per_PMT_tick,
153  *geometry_handle);
154  /*
155  FillMatchTree_PF(flash_vector,
156  particle_list,
157  ns_per_PMT_tick,
158  *geometry_handle);
159  */
160  int n_flashes = 0;
161  for(auto const& my_flash : flash_vector){
162  if(my_flash.OnBeamTime()==1) n_flashes++;
163  }
164  fNBeamFlashes->Fill(n_flashes);
165 
166  //check_flash_matches();
167 
168  //match_tracks_to_particles(track_handle,particle_list);
169 
170  }
171 
172 }
void match_flashes_to_particles(std::vector< recob::OpFlash > const &, std::vector< simb::MCParticle > const &, float const &, geo::Geometry const &)
#define LOG_INFO(category)
std::string fFlashModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< flash_match > fFlash_match_vector
bool isRealData() const
Definition: Event.h:83
RunNumber_t run() const
Definition: EventID.h:99
std::vector< particle_match > fParticle_match_vector
void get_MC_particle_list(sim::ParticleList const &, std::vector< simb::MCParticle > &)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
EventNumber_t event() const
Definition: EventID.h:117
EventID id() const
Definition: Event.h:56
void opreco::OpticalRecoAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 52 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, fTimeDiff_fine, and art::TFileDirectory::make().

53 {
55  fTimeDiff = tfs->make<TH1F>("htdiff","Time difference between particles and flashes; t_diff (ns); flash/particle pairs",1e3,-5e6,5e6);
56  fTimeDiff_fine = tfs->make<TH1F>("htdiff_fine","Time difference between particles and flashes; t_diff (ns); flash/particle pairs",100,-1000,1000);
57  fNBeamFlashes = tfs->make<TH1I>("hNBeamFlashes","Number of flashes OnBeamTime per event; N_{Flashes}; Events",5,0,5);
58 
59  fMatchTree_PF = tfs->make<TTree>("MatchTree_PF","MatchTree_PF");
60  fMatchTree_PF->Branch("Run",&fRun,"Run/I");
61  fMatchTree_PF->Branch("Event",&fEvent,"Event/I");
62  fMatchTree_PF->Branch("p_id",&fParticleID,"p_id/I");
63  fMatchTree_PF->Branch("p_time",&fParticleTime,"p_time/F");
64  fMatchTree_PF->Branch("p_vx",&fParticleVx,"p_vx/F");
65  fMatchTree_PF->Branch("p_vy",&fParticleVy,"p_vy/F");
66  fMatchTree_PF->Branch("p_vz",&fParticleVz,"p_vz/F");
67  fMatchTree_PF->Branch("p_mid",&fParticleMother,"p_mid/I");
68  fMatchTree_PF->Branch("p_trackid",&fParticleTrackID,"p_trackid/I");
69  fMatchTree_PF->Branch("FlashID",&fFlashID,"flash_id/I");
70  fMatchTree_PF->Branch("f_time",&fFlashTime,"f_time/F");
71  fMatchTree_PF->Branch("f_timewidth",&fFlashTimeWidth,"f_timewidth/F");
72  fMatchTree_PF->Branch("f_y",&fFlashY,"f_y/F");
73  fMatchTree_PF->Branch("f_z",&fFlashZ,"f_z/F");
74  fMatchTree_PF->Branch("f_ywidth",&fFlashYWidth,"f_ywidth/F");
75  fMatchTree_PF->Branch("f_zwidth",&fFlashYWidth,"f_zwidth/F");
76  fMatchTree_PF->Branch("f_onbeamtime",&fFlashOnBeamTime,"f_onbeamtime/I");
77  fMatchTree_PF->Branch("f_pe",&fFlashPE,"f_pe/F");
78  fMatchTree_PF->Branch("matchIndex",&fMatchIndex,"matchIndex/I");
79 
80  fMatchTree_PF_NotNu = tfs->make<TTree>("MatchTree_PF_NotNu","MatchTree_PF_NotNu");
81  fMatchTree_PF_NotNu->Branch("Run",&fRun,"Run/I");
82  fMatchTree_PF_NotNu->Branch("Event",&fEvent,"Event/I");
83  fMatchTree_PF_NotNu->Branch("p_id",&fParticleID,"p_id/I");
84  fMatchTree_PF_NotNu->Branch("p_time",&fParticleTime,"p_time/F");
85  fMatchTree_PF_NotNu->Branch("p_vx",&fParticleVx,"p_vx/F");
86  fMatchTree_PF_NotNu->Branch("p_vy",&fParticleVy,"p_vy/F");
87  fMatchTree_PF_NotNu->Branch("p_vz",&fParticleVz,"p_vz/F");
88  fMatchTree_PF_NotNu->Branch("p_mid",&fParticleMother,"p_mid/I");
89  fMatchTree_PF_NotNu->Branch("p_trackid",&fParticleTrackID,"p_trackid/I");
90  fMatchTree_PF_NotNu->Branch("FlashID",&fFlashID,"flash_id/I");
91  fMatchTree_PF_NotNu->Branch("f_time",&fFlashTime,"f_time/F");
92  fMatchTree_PF_NotNu->Branch("f_timewidth",&fFlashTimeWidth,"f_timewidth/F");
93  fMatchTree_PF_NotNu->Branch("f_y",&fFlashY,"f_y/F");
94  fMatchTree_PF_NotNu->Branch("f_z",&fFlashZ,"f_z/F");
95  fMatchTree_PF_NotNu->Branch("f_ywidth",&fFlashYWidth,"f_ywidth/F");
96  fMatchTree_PF_NotNu->Branch("f_zwidth",&fFlashYWidth,"f_zwidth/F");
97  fMatchTree_PF_NotNu->Branch("f_onbeamtime",&fFlashOnBeamTime,"f_onbeamtime/I");
98  fMatchTree_PF_NotNu->Branch("f_pe",&fFlashPE,"f_pe/F");
99  fMatchTree_PF_NotNu->Branch("matchIndex",&fMatchIndex_NotNu,"matchIndex/I");
100 
101 }
T * make(ARGS...args) const
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_
void opreco::OpticalRecoAna::compare_particle_and_flash ( simb::MCParticle const &  particle,
recob::OpFlash const &  flash,
bool &  matching,
float const &  ns_per_PMT_tick,
geo::Geometry const &  geometry 
)
private

Definition at line 399 of file OpticalRecoAna_module.cc.

403  {
404 }
void opreco::OpticalRecoAna::compare_particle_and_track ( simb::MCParticle const &  particle,
recob::Track const &  track,
bool &  matching,
geo::Geometry const &  geometry 
)
private

Definition at line 432 of file OpticalRecoAna_module.cc.

Referenced by match_flashes_to_particles().

435  {
436 }
void opreco::OpticalRecoAna::compare_track_and_flash ( recob::Track const &  track,
recob::OpFlash const &  flash,
bool &  matching 
)
private

Definition at line 271 of file OpticalRecoAna_module.cc.

Referenced by match_flashes_to_tracks().

273  {
274 }
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
void opreco::OpticalRecoAna::FillMatchTree_PF ( 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 357 of file OpticalRecoAna_module.cc.

References fFlash_match_vector, fFlashID, fFlashTime, fFlashY, fFlashYWidth, fFlashZ, fFlashZWidth, fMatchTree_PF, fParticleID, fParticleTime, fParticleVx, fParticleVy, fParticleVz, recob::OpFlash::Time(), and update_MC_particle_time().

360  {
361 
362  for(size_t i_flash=0; i_flash < flash_vector.size(); i_flash++){
363 
364  recob::OpFlash const& my_flash( flash_vector.at(i_flash) );
365  const float flash_time = my_flash.Time()*ns_per_PMT_tick;
366 
367  for(auto i_particle : fFlash_match_vector.at(i_flash).particle_indices){
368 
369  simb::MCParticle const& my_particle( particle_vector.at(i_particle) );
370  bool pass_check = false;
371  const float particle_time = update_MC_particle_time(my_particle,pass_check,geometry);
372 
373  if(my_particle.Mother()==0 && my_particle.TrackId()>1e4){
374 
375  fParticleID = i_particle;
376  fParticleTime = particle_time;
377  fParticleVx = my_particle.Vx(0);
378  fParticleVy = my_particle.Vy(0);
379  fParticleVz = my_particle.Vz(0);
380  fFlashID = i_flash;
381  fFlashTime = flash_time;
382  fFlashY = my_flash.YCenter();
383  fFlashZ = my_flash.ZCenter();
384  fFlashYWidth = my_flash.YWidth();
385  fFlashZWidth = my_flash.ZWidth();
386 
387  fMatchTree_PF->Fill();
388 
389  return;
390  }
391 
392  }
393 
394  }
395 
396 }
std::vector< flash_match > fFlash_match_vector
double Time() const
Definition: OpFlash.h:83
float update_MC_particle_time(simb::MCParticle const &, bool &, geo::Geometry const &)
void opreco::OpticalRecoAna::get_MC_particle_list ( sim::ParticleList const &  plist,
std::vector< simb::MCParticle > &  particle_vector 
)
private

Definition at line 179 of file OpticalRecoAna_module.cc.

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

Referenced by analyze().

179  {
180 
181  for(sim::ParticleList::const_iterator ipart = plist.begin(); ipart != plist.end(); ++ipart) {
182 
183  const simb::MCParticle* particle = (*ipart).second;
184  /*
185  std::cout << "Particle " << particle_vector.size() << " (" << (*ipart).first << ") is " << particle->PdgCode() << " (mother=" << particle->Mother()
186  << ") with K_energy " << particle->E()-0.001*particle->Mass() << std::endl;
187  std::cout << "\t(X,Y,Z,T)=(" << particle->Vx() << "," << particle->Vy() << "," << particle->Vz() << "," << particle->T() << ")" << std::endl;
188  */
189  //do not store if it's below our energy cut
190  if( particle->E() < 0.001*particle->Mass() + fKineticEnergyMin ) continue;
191 
192  //check to see if it's a charged particle we expect to leave ionization
193  const int pdg = std::abs(particle->PdgCode());
194  if( pdg==11 // electron
195  || pdg==13 //muon
196  || pdg==15 //tau
197  || pdg==211 //charged pion
198  || pdg==321 //charged kaon
199  || pdg==2212 //proton
200  || pdg==2214 //delta
201  || pdg==2224 //delta
202  || pdg==3222 //sigma
203  || pdg==3112 //sigma
204  || pdg==3312 //xi
205  || pdg==3334 //omega
206  ) {
207  particle_vector.emplace_back(*particle);
208  //std::cout << "Particle " << particle_vector.size() << " (" << (*ipart).first << ") is " << pdg << " (status=" << particle->StatusCode()
209  // << ") with K_energy " << particle->E()-0.001*particle->Mass() << std::endl;
210  //std::cout << "\t(X,Y,Z,T)=(" << particle->Vx() << "," << particle->Vy() << "," << particle->Vz() << "," << particle->T() << ")" << std::endl;
211  }
212  }
213 
214 }
double E(const int i=0) const
Definition: MCParticle.h:237
int PdgCode() const
Definition: MCParticle.h:216
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
double Mass() const
Definition: MCParticle.h:243
Int_t ipart
Definition: Style.C:10
simb::Origin_t opreco::OpticalRecoAna::get_MC_particle_origin ( simb::MCParticle const &  particle)
private

Definition at line 174 of file OpticalRecoAna_module.cc.

References simb::MCParticle::TrackId(), and cheat::ParticleInventoryService::TrackIdToMCTruth_P().

Referenced by match_flashes_to_particles().

174  {
176  return (pi_serv->TrackIdToMCTruth_P(particle.TrackId()))->Origin();
177 }
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id)
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
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 276 of file OpticalRecoAna_module.cc.

References 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().

279  {
280 
281  fMatchIndex=0;
283  int lastFlashID = -1;
284 
285  for(size_t i_particle=0; i_particle < particle_vector.size(); i_particle++){
286 
287  simb::MCParticle const& my_particle( particle_vector.at(i_particle) );
288  bool pass_check = false;
289  const float particle_time = update_MC_particle_time(my_particle,pass_check,geometry);
290  if(!pass_check) continue;
291 
292  //std::cout << "Particle " << i_particle << " (" << my_particle.PdgCode() << ")" << particle_time << std::endl;
293 
294  for(size_t i_flash=0; i_flash < flash_vector.size(); i_flash++){
295 
296  recob::OpFlash const& my_flash( flash_vector.at(i_flash) );
297  if(my_flash.TotalPE() < fPEMin) continue;
298 
299  const float flash_time = my_flash.Time()*ns_per_PMT_tick;
300 
301  //if(my_flash.OnBeamTime())
302  //std::cout << "\tFlash " << i_flash << " time is " << flash_time << std::endl;
303 
304  fTimeDiff->Fill(particle_time-flash_time);
305  fTimeDiff_fine->Fill(particle_time-flash_time);
306 
307  fParticleID = i_particle;
308  fParticleTime = particle_time;
309  fParticleVx = my_particle.Vx(0);
310  fParticleVy = my_particle.Vy(0);
311  fParticleVz = my_particle.Vz(0);
312  fParticleMother = my_particle.Mother();
313  fParticleTrackID = my_particle.TrackId();
314  fFlashID = i_flash;
315  fFlashTime = flash_time;
316  fFlashTimeWidth = my_flash.TimeWidth()*ns_per_PMT_tick;
317  fFlashY = my_flash.YCenter();
318  fFlashZ = my_flash.ZCenter();
319  fFlashYWidth = my_flash.YWidth();
320  fFlashZWidth = my_flash.ZWidth();
321  fFlashPE = my_flash.TotalPE();
322  fFlashOnBeamTime = my_flash.OnBeamTime();
323 
324  bool beam_match = ((std::abs(particle_time - flash_time )/fFlashTimeWidth)<fTimeMatchMax &&
326  bool nonbeam_match = ((std::abs(particle_time - flash_time )/fFlashTimeWidth)<fTimeMatchMax &&
328 
329  if( beam_match ){
330  fMatchTree_PF->Fill();
331  fMatchIndex++;
332 
333  //std::cout << "\t\tParticle (x,y,z)=(" << my_particle.Vx() << "," << my_particle.Vy() << "," << my_particle.Vz() << std::endl;
334  //std::cout << "\t\tParticle PDG = " << my_particle.PdgCode() << " mother=" << my_particle.Mother() << std::endl;
335  //std::cout << "\t\tFlash (y,z) = ("
336  // << my_flash.YCenter() << " +/- " << my_flash.YWidth() << ","
337  // << my_flash.ZCenter() << " +/- " << my_flash.ZWidth() << std::endl;
338 
339  fFlash_match_vector.at(i_flash).particle_indices.push_back(i_particle);
340  fParticle_match_vector.at(i_particle).flash_indices.push_back(i_flash);
341  }
342  else if( nonbeam_match ){
343  if(lastFlashID!=fFlashID){
344  fMatchTree_PF_NotNu->Fill();
346  lastFlashID = fFlashID;
347  }
348  }
349 
350 
351  }//end inner loop over particles
352 
353  }//end loop over flashes
354 
355 }//end match_flashes_to_particles
std::vector< flash_match > fFlash_match_vector
simb::Origin_t get_MC_particle_origin(simb::MCParticle const &)
double Time() const
Definition: OpFlash.h:83
std::vector< particle_match > fParticle_match_vector
float update_MC_particle_time(simb::MCParticle const &, bool &, geo::Geometry const &)
Beam neutrinos.
Definition: MCTruth.h:21
void opreco::OpticalRecoAna::match_flashes_to_particles ( std::vector< recob::Track > const &  track_vector,
std::vector< simb::MCParticle > const &  particle_vector,
geo::Geometry const &  geometry 
)
private

Definition at line 406 of file OpticalRecoAna_module.cc.

References compare_particle_and_track(), fParticle_match_vector, and fTrack_match_vector.

408  {
409  bool matching=false;
410 
411  for(size_t i_track=0; i_track < track_vector.size(); i_track++){
412 
413  recob::Track const& my_track( track_vector.at(i_track) );
414 
415  for(size_t i_particle=0; i_particle < particle_vector.size(); i_particle++){
416 
417  simb::MCParticle const& my_particle( particle_vector.at(i_particle) );
418 
419  matching=false;
420  compare_particle_and_track(my_particle,my_track,matching,geometry);
421  if(matching){
422  fTrack_match_vector.at(i_track).particle_indices.push_back(i_track);
423  fParticle_match_vector.at(i_particle).track_indices.push_back(i_track);
424  }
425 
426  }//end inner loop over particles
427 
428  }//end loop over tracks
429 
430 }//end match_tracks_to_particles
std::vector< particle_match > fParticle_match_vector
void compare_particle_and_track(simb::MCParticle const &, recob::Track const &, bool &, geo::Geometry const &)
std::vector< track_match > fTrack_match_vector
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:52
void opreco::OpticalRecoAna::match_flashes_to_tracks ( std::vector< recob::OpFlash > const &  flash_vector,
std::vector< recob::Track > const &  track_vector 
)
private

Definition at line 245 of file OpticalRecoAna_module.cc.

References compare_track_and_flash(), fFlash_match_vector, fPEMin, and fTrack_match_vector.

246  {
247  bool matching=false;
248 
249  for(size_t i_flash=0; i_flash < flash_vector.size(); i_flash++){
250 
251  recob::OpFlash const& my_flash( flash_vector.at(i_flash) );
252  if(my_flash.TotalPE() < fPEMin) continue;
253 
254  for(size_t i_track=0; i_track < track_vector.size(); i_track++){
255 
256  recob::Track const& my_track( track_vector.at(i_track) );
257 
258  matching=false;
259  compare_track_and_flash(my_track,my_flash,matching);
260  if(matching){
261  fFlash_match_vector.at(i_flash).track_indices.push_back(i_track);
262  fTrack_match_vector.at(i_track).flash_indices.push_back(i_flash);
263  }
264 
265  }//end inner loop over tracks
266 
267  }//end loop over flashes
268 
269 }//end match_flashes_to_tracks
void compare_track_and_flash(recob::Track const &, recob::OpFlash const &, bool &)
std::vector< flash_match > fFlash_match_vector
std::vector< track_match > fTrack_match_vector
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:52
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
float opreco::OpticalRecoAna::update_MC_particle_time ( simb::MCParticle const &  particle,
bool &  pass_check,
geo::Geometry const &  geometry 
)
private

Definition at line 216 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 FillMatchTree_PF(), and match_flashes_to_particles().

216  {
217 
218  pass_check = false;
219 
220  unsigned int tpc = 0;
221  unsigned int cstat = 0;
222 
223  const size_t numtraj = particle.NumberTrajectoryPoints();
224  size_t t_iter = 0;
225  while(t_iter < numtraj){
226  try{
227  // check if the particle is inside a TPC
228  double pos[3] = {particle.Vx(t_iter), particle.Vy(t_iter), particle.Vz(t_iter)};
229  geometry.PositionToTPC(pos, tpc, cstat);
230  }
231  catch(cet::exception &e){
232  t_iter++;
233  continue;
234  }
235  break;
236  }
237 
238  if(t_iter == numtraj)
239  return 0;
240 
241  pass_check = true;
242  return particle.T(t_iter);
243 }
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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

int opreco::OpticalRecoAna::fEvent
private

Definition at line 106 of file OpticalRecoAna.h.

Referenced by analyze(), and beginJob().

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

Definition at line 114 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

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

Definition at line 54 of file OpticalRecoAna.h.

Referenced by analyze(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fFlashOnBeamTime
private

Definition at line 122 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashPE
private

Definition at line 121 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashTime
private

Definition at line 115 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashTimeWidth
private

Definition at line 116 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashY
private

Definition at line 117 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashYWidth
private

Definition at line 119 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashZ
private

Definition at line 118 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fFlashZWidth
private

Definition at line 120 of file OpticalRecoAna.h.

Referenced by FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fKineticEnergyMin
private

Definition at line 56 of file OpticalRecoAna.h.

Referenced by get_MC_particle_list(), and OpticalRecoAna().

int opreco::OpticalRecoAna::fMatchIndex
private

Definition at line 123 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fMatchIndex_NotNu
private

Definition at line 124 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

TTree* opreco::OpticalRecoAna::fMatchTree_PF
private

Definition at line 103 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

TTree* opreco::OpticalRecoAna::fMatchTree_PF_NotNu
private

Definition at line 104 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

TH1I* opreco::OpticalRecoAna::fNBeamFlashes
private

Definition at line 101 of file OpticalRecoAna.h.

Referenced by analyze(), and beginJob().

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

Definition at line 62 of file OpticalRecoAna.h.

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

int opreco::OpticalRecoAna::fParticleID
private

Definition at line 107 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fParticleMother
private

Definition at line 108 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleTime
private

Definition at line 110 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

int opreco::OpticalRecoAna::fParticleTrackID
private

Definition at line 109 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVx
private

Definition at line 111 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVy
private

Definition at line 112 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fParticleVz
private

Definition at line 113 of file OpticalRecoAna.h.

Referenced by beginJob(), FillMatchTree_PF(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fPEMin
private
int opreco::OpticalRecoAna::fRun
private

Definition at line 105 of file OpticalRecoAna.h.

Referenced by analyze(), and beginJob().

TH1F* opreco::OpticalRecoAna::fTimeDiff
private

Definition at line 99 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

TH1F* opreco::OpticalRecoAna::fTimeDiff_fine
private

Definition at line 100 of file OpticalRecoAna.h.

Referenced by beginJob(), and match_flashes_to_particles().

float opreco::OpticalRecoAna::fTimeMatchMax
private

Definition at line 58 of file OpticalRecoAna.h.

Referenced by match_flashes_to_particles(), and OpticalRecoAna().

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

Definition at line 55 of file OpticalRecoAna.h.

Referenced by OpticalRecoAna().


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