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

Public Types

enum  hit_origin_t { hit_origin_Unknown = -1, hit_origin_Cosmic = 0, hit_origin_NonCosmic = 1 }
 
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 CosmicRemovalAna (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 read access to event More...
 
void beginJob ()
 
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 InitEventTree (int run_number, int event_number)
 
void FillMCInfo (std::vector< recob::Hit > const &hitlist, std::vector< hit_origin_t > &hitOrigins, std::vector< sim::MCHitCollection > const &mchitCollectionVector, std::map< int, const simb::MCTruth * > const &trackIDToTruthMap)
 
void FillTrackInfo (size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &track_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * > > const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
 
void FillClusterInfo (size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &cluster_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * > > const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
 
void FillAllTagsInfo (recob::Hit const &hit, hit_origin_t const &origin)
 

Private Attributes

unsigned int nCosmicTags
 
TTree * tEventTree
 
std::string fHitsModuleLabel
 
std::string fMCModuleLabel
 
std::string fMCHitsModuleLabel
 
std::string fClusterModuleLabel
 
std::string fTrackModuleLabel
 
float fHitCompareCut
 
std::vector< std::string > fCosmicTagAssocLabel
 
std::vector< float > fCosmicScoreThresholds
 
std::vector< float > cTaggedCharge_Cosmic
 
std::vector< float > cTaggedCharge_NonCosmic
 
std::vector< int > cTaggedHits_Cosmic
 
std::vector< int > cTaggedHits_NonCosmic
 

Detailed Description

Definition at line 55 of file CosmicRemovalAna_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

microboone::CosmicRemovalAna::CosmicRemovalAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 181 of file CosmicRemovalAna_module.cc.

181  :
182  EDAnalyzer(pset),
183  fHitsModuleLabel (pset.get< std::string >("HitsModuleLabel") ),
184  fMCModuleLabel (pset.get< std::string >("MCModuleLabel") ),
185  fMCHitsModuleLabel (pset.get< std::string >("MCHitsModuleLabel") ),
186  fClusterModuleLabel (pset.get< std::string >("ClusterModuleLabel") ),
187  fTrackModuleLabel (pset.get< std::string >("TrackModuleLabel") ),
188  fHitCompareCut (pset.get< float >("HitCompareCut") ),
189  fCosmicTagAssocLabel (pset.get<std::vector< std::string > >("CosmicTagAssocLabel") ),
190  fCosmicScoreThresholds (pset.get<std::vector<float> > ("CosmicScoreThresholds") )
191 {
192 }
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::vector< float > fCosmicScoreThresholds
std::vector< std::string > fCosmicTagAssocLabel

Member Function Documentation

void microboone::CosmicRemovalAna::analyze ( const art::Event evt)

read access to event

Definition at line 225 of file CosmicRemovalAna_module.cc.

References art::Event::event(), fClusterModuleLabel, fCosmicTagAssocLabel, fHitsModuleLabel, FillAllTagsInfo(), FillClusterInfo(), FillMCInfo(), FillTrackInfo(), fMCHitsModuleLabel, fMCModuleLabel, fTrackModuleLabel, util::GetAssociatedVectorManyI(), util::GetAssociatedVectorOneP(), art::DataViewImpl::getByLabel(), InitEventTree(), geo::origin(), art::Event::run(), and tEventTree.

226 {
227 
228  InitEventTree(evt.run(), evt.event());
229 
230  // ##################################################################
231  // ### Grabbing ALL HITS in the event to monitor the backtracking ###
232  // ##################################################################
234  evt.getByLabel("daq",rawdigitHandle);
235 
236  art::Handle< std::vector<recob::Hit> > hitListHandle;
237  evt.getByLabel(fHitsModuleLabel,hitListHandle);
238  std::vector<recob::Hit> const& hitVector(*hitListHandle);
239 
240  std::vector<hit_origin_t> hitOrigins(hitVector.size());
241 
242  //get mcHitCollection
244  evt.getByLabel(fMCHitsModuleLabel,mchitListHandle);
245  std::vector<sim::MCHitCollection> const& mchitcolVector(*mchitListHandle);
246 
247  //get mcparticles out of the event
249  evt.getByLabel(fMCModuleLabel,mcParticleHandle);
250  std::vector<simb::MCParticle> const& mcParticleVector(*mcParticleHandle);
251 
252  //get associations of mc particles to mc truth
254  evt.getByLabel(fMCModuleLabel,assnMCParticleTruthHandle);
255 
256  std::vector< const simb::MCTruth* >
257  particle_to_truth = util::GetAssociatedVectorOneP(assnMCParticleTruthHandle,
258  mcParticleHandle);
259 
260  //make trackId to MCTruth map
261  std::map<int,const simb::MCTruth* > trackIDToTruthMap;
262  for(size_t p_iter=0; p_iter<mcParticleVector.size(); p_iter++)
263  trackIDToTruthMap[ mcParticleVector[p_iter].TrackId() ] = particle_to_truth[p_iter];
264 
265  FillMCInfo(hitVector, hitOrigins, mchitcolVector, trackIDToTruthMap);
266 
267  art::Handle< std::vector<recob::Track> > trackListHandle;
268  evt.getByLabel(fTrackModuleLabel,trackListHandle);
269  std::vector<recob::Track> const& trackVector(*trackListHandle);
270 
271  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
272  evt.getByLabel(fClusterModuleLabel,clusterListHandle);
273  std::vector<recob::Cluster> const& clusterVector(*clusterListHandle);
274 
276  evt.getByLabel(fTrackModuleLabel,assnHitTrackHandle);
277  std::vector< std::vector<size_t> >
278  track_indices_per_hit = util::GetAssociatedVectorManyI(assnHitTrackHandle,
279  hitListHandle);
280 
282  evt.getByLabel(fClusterModuleLabel,assnHitClusterHandle);
283  std::vector< std::vector<size_t> >
284  cluster_indices_per_hit = util::GetAssociatedVectorManyI(assnHitClusterHandle,
285  hitListHandle);
286 
287  std::vector< art::Handle< std::vector<anab::CosmicTag> > > cosmicTagHandlesVector(fCosmicTagAssocLabel.size());
288  std::vector< art::Handle< art::Assns<recob::Track,anab::CosmicTag> > > assnTrackTagHandlesVector(fCosmicTagAssocLabel.size());
289  std::vector< std::vector< const anab::CosmicTag* > > tags_per_track(trackVector.size(), std::vector<const anab::CosmicTag*>(fCosmicTagAssocLabel.size()));
290  std::vector< art::Handle< art::Assns<recob::Cluster,anab::CosmicTag> > > assnClusterTagHandlesVector(fCosmicTagAssocLabel.size());
291  std::vector< std::vector< const anab::CosmicTag* > > tags_per_cluster(clusterVector.size(), std::vector<const anab::CosmicTag*>(fCosmicTagAssocLabel.size()));
292 
293  for(size_t label_i=0; label_i<fCosmicTagAssocLabel.size(); label_i++){
294  try{ evt.getByLabel(fCosmicTagAssocLabel[label_i],cosmicTagHandlesVector[label_i]); }
295  catch(...){ continue; }
296  try{
297  evt.getByLabel(fCosmicTagAssocLabel[label_i],assnTrackTagHandlesVector[label_i]);
298  for(auto const& pair : *assnTrackTagHandlesVector[label_i])
299  tags_per_track.at(pair.first.key())[label_i] = &(*(pair.second));
300  }
301  catch(...){}
302  try{
303  evt.getByLabel(fCosmicTagAssocLabel[label_i],assnClusterTagHandlesVector[label_i]);
304  for(auto const& pair : *assnClusterTagHandlesVector[label_i])
305  tags_per_cluster.at(pair.first.key())[label_i] = &(*(pair.second));
306  }
307  catch(...){}
308  }
309 
310  std::vector< std::vector<bool> > hitsAccounted(hitVector.size(),std::vector<bool>(fCosmicTagAssocLabel.size(),false));
311  std::vector<bool> hitsAllTags(hitVector.size(),false);
312 
313  for(size_t hit_iter=0; hit_iter<hitVector.size(); hit_iter++){
314 
315  float charge = hitVector[hit_iter].Integral();
316  hit_origin_t origin = hitOrigins[hit_iter];
317 
318  if(track_indices_per_hit[hit_iter].size()!=0)
319  FillTrackInfo(hit_iter,
320  origin,
321  charge,
322  track_indices_per_hit[hit_iter],
323  tags_per_track,
324  hitsAccounted[hit_iter],
325  hitsAllTags);
326 
327  if(cluster_indices_per_hit[hit_iter].size()!=0)
328  FillClusterInfo(hit_iter,
329  origin,
330  charge,
331  cluster_indices_per_hit[hit_iter],
332  tags_per_cluster,
333  hitsAccounted[hit_iter],
334  hitsAllTags);
335 
336  if(hitsAllTags[hit_iter]) FillAllTagsInfo(hitVector[hit_iter],origin);
337 
338  }//end loop over all the hits
339 
340  tEventTree->Fill();
341 }
void FillMCInfo(std::vector< recob::Hit > const &hitlist, std::vector< hit_origin_t > &hitOrigins, std::vector< sim::MCHitCollection > const &mchitCollectionVector, std::map< int, const simb::MCTruth * > const &trackIDToTruthMap)
void FillAllTagsInfo(recob::Hit const &hit, hit_origin_t const &origin)
void FillClusterInfo(size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &cluster_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * > > const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
void InitEventTree(int run_number, int event_number)
EventNumber_t event() const
Definition: Event.h:67
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
void FillTrackInfo(size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &track_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * > > const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
RunNumber_t run() const
Definition: Event.h:77
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
std::vector< std::string > fCosmicTagAssocLabel
void microboone::CosmicRemovalAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 199 of file CosmicRemovalAna_module.cc.

References cTaggedCharge_Cosmic, cTaggedCharge_NonCosmic, cTaggedHits_Cosmic, cTaggedHits_NonCosmic, fCosmicTagAssocLabel, art::TFileDirectory::make(), nCosmicTags, and tEventTree.

200 {
201 
202  //static cEventProperties_t cEventVals;
203 
209 
211  tEventTree = (TTree*)tfs->make<TTree>("CosmicEventTree","CosmicEventTree");
212 
213  tEventTree->Branch("event", &cEventVals, "runNumber/I:eventNumber/I:nHitsTotal_Unknown/I:nHitsTotal_Cosmic/I:nHitsTotal_NonCosmic/I:qTotal_Unknown/F:qTotal_Cosmic/F:qTotal_NonCosmic/F:nHitsTrack/I:nHitsTrack_Cosmic/I:nHitsTrack_NonCosmic/I:qTrack/F:qTrack_Cosmic/F:qTrack_NonCosmic/F:nHitsCluster/I:nHitsCluster_Cosmic/I:nHitsCluster_NonCosmic/I:qCluster/F:qCluster_Cosmic/F:qCluster_NonCosmic/F:TotalTaggedCharge_Cosmic/F:TotalTaggedCharge_NonCosmic/F:TotalTaggedHits_Cosmic/I:TotalTaggedHits_NonCosmic/I");
214  tEventTree->Branch("TaggedCharge_Cosmic",&cTaggedCharge_Cosmic);
215  tEventTree->Branch("TaggedCharge_NonCosmic",&cTaggedCharge_NonCosmic);
216  tEventTree->Branch("TaggedHits_Cosmic",&cTaggedHits_Cosmic);
217  tEventTree->Branch("TaggedHits_NonCosmic",&cTaggedHits_NonCosmic);
218 
219 }
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
T * make(ARGS...args) const
std::vector< std::string > fCosmicTagAssocLabel
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
void microboone::CosmicRemovalAna::FillAllTagsInfo ( recob::Hit const &  hit,
hit_origin_t const &  origin 
)
private

Definition at line 539 of file CosmicRemovalAna_module.cc.

References DEFINE_ART_MODULE, hit_origin_Cosmic, hit_origin_NonCosmic, recob::Hit::Integral(), cEventProperties_t::TotalTaggedCharge_Cosmic, cEventProperties_t::TotalTaggedCharge_NonCosmic, cEventProperties_t::TotalTaggedHits_Cosmic, and cEventProperties_t::TotalTaggedHits_NonCosmic.

Referenced by analyze().

540  {
544  }
545  else if(origin==hit_origin_NonCosmic){
548  }
549 
550 }
cEventProperties_t cEventVals
Detector simulation of raw signals on wires.
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
void microboone::CosmicRemovalAna::FillClusterInfo ( size_t const &  hit_iter,
hit_origin_t const &  origin,
float const &  charge,
std::vector< size_t > const &  cluster_indices_this_hit,
std::vector< std::vector< const anab::CosmicTag * > > const &  tags_per_cluster,
std::vector< bool > &  hitsAccounted_per_tag,
std::vector< bool > &  hitsAllTags 
)
private

Definition at line 491 of file CosmicRemovalAna_module.cc.

References anab::CosmicTag::CosmicScore(), cTaggedCharge_Cosmic, cTaggedCharge_NonCosmic, cTaggedHits_Cosmic, cTaggedHits_NonCosmic, fCosmicScoreThresholds, fCosmicTagAssocLabel, hit_origin_Cosmic, hit_origin_NonCosmic, cEventProperties_t::nHitsCluster, cEventProperties_t::nHitsCluster_Cosmic, cEventProperties_t::nHitsCluster_NonCosmic, cEventProperties_t::qCluster, cEventProperties_t::qCluster_Cosmic, and cEventProperties_t::qCluster_NonCosmic.

Referenced by analyze().

497  {
498 
500  cEventVals.qCluster += charge;
501 
504  cEventVals.qCluster_Cosmic += charge;
505  }
506  else if(origin==hit_origin_NonCosmic){
508  cEventVals.qCluster_NonCosmic += charge;
509  }
510 
511  for(unsigned int nCT = 0; nCT < fCosmicTagAssocLabel.size(); nCT++){//<---This loops over the vector of cosmicTags in stored in the event
512  if(hitsAccounted_per_tag[nCT]) continue;
513 
514  for(auto const& cluster_index : cluster_indices_this_hit){
515  if(!tags_per_cluster[cluster_index][nCT]) continue;
516  const anab::CosmicTag* currentTag(tags_per_cluster[cluster_index][nCT]);
517  if( currentTag->CosmicScore() > fCosmicScoreThresholds[nCT] ){
518 
519  hitsAccounted_per_tag[nCT] = true;
520  hitsAllTags[hit_iter] = true;
522  cTaggedHits_Cosmic[nCT]++;
523  cTaggedCharge_Cosmic[nCT] += charge;
524  }
525  else if(origin==hit_origin_NonCosmic){
526  cTaggedHits_NonCosmic[nCT]++;
527  cTaggedCharge_NonCosmic[nCT] += charge;
528  }
529  }
530  }
531 
532 
533  }
534 
535 }//end FillClusterInfo
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< float > fCosmicScoreThresholds
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
std::vector< std::string > fCosmicTagAssocLabel
void microboone::CosmicRemovalAna::FillMCInfo ( std::vector< recob::Hit > const &  hitlist,
std::vector< hit_origin_t > &  hitOrigins,
std::vector< sim::MCHitCollection > const &  mchitCollectionVector,
std::map< int, const simb::MCTruth * > const &  trackIDToTruthMap 
)
private

Definition at line 389 of file CosmicRemovalAna_module.cc.

References recob::Hit::Channel(), energy, fHitCompareCut, hit_origin_Cosmic, hit_origin_NonCosmic, hit_origin_Unknown, recob::Hit::Integral(), simb::kBeamNeutrino, cEventProperties_t::nHitsTotal_Cosmic, cEventProperties_t::nHitsTotal_NonCosmic, cEventProperties_t::nHitsTotal_Unknown, geo::origin(), recob::Hit::PeakTime(), cEventProperties_t::qTotal_Cosmic, cEventProperties_t::qTotal_NonCosmic, and cEventProperties_t::qTotal_Unknown.

Referenced by analyze().

392  {
393 
394  auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
395 
396  for(size_t itr=0; itr<hitlist.size(); itr++){
397 
398  recob::Hit const& this_hit = hitlist[itr];
399 
400  std::vector<int> trackIDs;
401  std::vector<double> energy;
402 
403  for( auto const& mchit : mchitCollectionVector[this_hit.Channel()] ){
404  if( std::abs(ts->TPCTDC2Tick(mchit.PeakTime()) - this_hit.PeakTime()) < fHitCompareCut){
405  trackIDs.push_back(mchit.PartTrackId());
406  energy.push_back(mchit.PartEnergy());
407  }
408  }
409 
410  if(trackIDs.size()==0){
411  hitOrigins[itr] = hit_origin_Unknown;
413  cEventVals.qTotal_Unknown += this_hit.Integral();
414  continue;
415  }
416 
417  float cosmic_energy=0;
418  float non_cosmic_energy=0;
419 
420  for(size_t iter=0; iter<trackIDs.size(); iter++){
421  auto map_element = trackIdToTruthMap.find(std::abs(trackIDs[iter]));
422  if(map_element==trackIdToTruthMap.end()) continue;
423  int origin = map_element->second->Origin();
424  if(origin == simb::kBeamNeutrino)
425  non_cosmic_energy += energy[iter];
426  else
427  cosmic_energy += energy[iter];
428  }
429 
430  if(non_cosmic_energy > cosmic_energy){
431  hitOrigins[itr] = hit_origin_NonCosmic;
433  cEventVals.qTotal_NonCosmic += this_hit.Integral();
434  }
435  else{
436  hitOrigins[itr] = hit_origin_Cosmic;
438  cEventVals.qTotal_Cosmic += this_hit.Integral();
439  }
440  }
441 
442 }//end FillMCInfo
cEventProperties_t cEventVals
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:225
double energy
Definition: plottest35.C:25
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
Beam neutrinos.
Definition: MCTruth.h:21
void microboone::CosmicRemovalAna::FillTrackInfo ( size_t const &  hit_iter,
hit_origin_t const &  origin,
float const &  charge,
std::vector< size_t > const &  track_indices_this_hit,
std::vector< std::vector< const anab::CosmicTag * > > const &  tags_per_cluster,
std::vector< bool > &  hitsAccounted_per_tag,
std::vector< bool > &  hitsAllTags 
)
private

Definition at line 445 of file CosmicRemovalAna_module.cc.

References anab::CosmicTag::CosmicScore(), cTaggedCharge_Cosmic, cTaggedCharge_NonCosmic, cTaggedHits_Cosmic, cTaggedHits_NonCosmic, fCosmicScoreThresholds, fCosmicTagAssocLabel, hit_origin_Cosmic, hit_origin_NonCosmic, cEventProperties_t::nHitsTrack, cEventProperties_t::nHitsTrack_Cosmic, cEventProperties_t::nHitsTrack_NonCosmic, cEventProperties_t::qTrack, cEventProperties_t::qTrack_Cosmic, and cEventProperties_t::qTrack_NonCosmic.

Referenced by analyze().

451  {
452 
454  cEventVals.qTrack += charge;
455 
458  cEventVals.qTrack_Cosmic += charge;
459  }
460  else if(origin==hit_origin_NonCosmic){
462  cEventVals.qTrack_NonCosmic += charge;
463  }
464 
465  for(unsigned int nCT = 0; nCT < fCosmicTagAssocLabel.size(); nCT++){//<---This loops over the vector of cosmicTags in stored in the event
466  if(hitsAccounted_per_tag[nCT]) continue;
467 
468  for(auto const& track_index : track_indices_this_hit){
469  if(!tags_per_track[track_index][nCT]) continue;
470  const anab::CosmicTag* currentTag(tags_per_track[track_index][nCT]);
471  if( currentTag->CosmicScore() > fCosmicScoreThresholds[nCT] ){
472 
473  hitsAccounted_per_tag[nCT] = true;
474  hitsAllTags[hit_iter] = true;
476  cTaggedHits_Cosmic[nCT]++;
477  cTaggedCharge_Cosmic[nCT] += charge;
478  }
479  else if(origin==hit_origin_NonCosmic){
480  cTaggedHits_NonCosmic[nCT]++;
481  cTaggedCharge_NonCosmic[nCT] += charge;
482  }
483  }
484  }
485 
486  }
487 
488 }//end FillTrackInfo
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< float > fCosmicScoreThresholds
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
std::vector< std::string > fCosmicTagAssocLabel
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 microboone::CosmicRemovalAna::InitEventTree ( int  run_number,
int  event_number 
)
private

Definition at line 344 of file CosmicRemovalAna_module.cc.

References cTaggedCharge_Cosmic, cTaggedCharge_NonCosmic, cTaggedHits_Cosmic, cTaggedHits_NonCosmic, cEventProperties_t::eventNumber, fCosmicTagAssocLabel, cEventProperties_t::nHitsCluster, cEventProperties_t::nHitsCluster_Cosmic, cEventProperties_t::nHitsCluster_NonCosmic, cEventProperties_t::nHitsTotal_Cosmic, cEventProperties_t::nHitsTotal_NonCosmic, cEventProperties_t::nHitsTotal_Unknown, cEventProperties_t::nHitsTrack, cEventProperties_t::nHitsTrack_Cosmic, cEventProperties_t::nHitsTrack_NonCosmic, cEventProperties_t::qCluster, cEventProperties_t::qCluster_Cosmic, cEventProperties_t::qCluster_NonCosmic, cEventProperties_t::qTotal_Cosmic, cEventProperties_t::qTotal_NonCosmic, cEventProperties_t::qTotal_Unknown, cEventProperties_t::qTrack, cEventProperties_t::qTrack_Cosmic, cEventProperties_t::qTrack_NonCosmic, cEventProperties_t::runNumber, cEventProperties_t::TotalTaggedCharge_Cosmic, cEventProperties_t::TotalTaggedCharge_NonCosmic, cEventProperties_t::TotalTaggedHits_Cosmic, and cEventProperties_t::TotalTaggedHits_NonCosmic.

Referenced by analyze().

344  {
345 
346  cEventVals.runNumber = run_number;//evt.run();
347  cEventVals.eventNumber = event_number;//evt.event();
348 
352 
356 
360 
361  cEventVals.qTrack = 0;
364 
368 
369  cEventVals.qCluster = 0;
372 
377 
378  for(size_t iter=0; iter<fCosmicTagAssocLabel.size(); iter++){
379  cTaggedHits_Cosmic.at(iter) = 0;
380  cTaggedCharge_Cosmic.at(iter) = 0;
381  cTaggedHits_NonCosmic.at(iter) = 0;
382  cTaggedCharge_NonCosmic.at(iter) = 0;
383  }
384 
385 }
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< std::string > fCosmicTagAssocLabel
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

std::vector<float> microboone::CosmicRemovalAna::cTaggedCharge_Cosmic
private
std::vector<float> microboone::CosmicRemovalAna::cTaggedCharge_NonCosmic
private
std::vector<int> microboone::CosmicRemovalAna::cTaggedHits_Cosmic
private
std::vector<int> microboone::CosmicRemovalAna::cTaggedHits_NonCosmic
private
std::string microboone::CosmicRemovalAna::fClusterModuleLabel
private

Definition at line 81 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

std::vector<float> microboone::CosmicRemovalAna::fCosmicScoreThresholds
private

Definition at line 85 of file CosmicRemovalAna_module.cc.

Referenced by FillClusterInfo(), and FillTrackInfo().

std::vector<std::string> microboone::CosmicRemovalAna::fCosmicTagAssocLabel
private
float microboone::CosmicRemovalAna::fHitCompareCut
private

Definition at line 83 of file CosmicRemovalAna_module.cc.

Referenced by FillMCInfo().

std::string microboone::CosmicRemovalAna::fHitsModuleLabel
private

Definition at line 78 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

std::string microboone::CosmicRemovalAna::fMCHitsModuleLabel
private

Definition at line 80 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

std::string microboone::CosmicRemovalAna::fMCModuleLabel
private

Definition at line 79 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

std::string microboone::CosmicRemovalAna::fTrackModuleLabel
private

Definition at line 82 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

unsigned int microboone::CosmicRemovalAna::nCosmicTags
private

Definition at line 73 of file CosmicRemovalAna_module.cc.

Referenced by beginJob().

TTree* microboone::CosmicRemovalAna::tEventTree
private

Definition at line 76 of file CosmicRemovalAna_module.cc.

Referenced by analyze(), and beginJob().


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