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

Public Types

enum  hit_origin_t { hit_origin_Unknown = -1, hit_origin_Cosmic = 0, hit_origin_NonCosmic = 1 }
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 CosmicRemovalAna (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 read access to event More...
 
void beginJob ()
 
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 InitEventTree (int run_number, int event_number)
 
void FillMCInfo (art::Event const &e, 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 40 of file CosmicRemovalAna_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 159 of file CosmicRemovalAna_module.cc.

160  : EDAnalyzer(pset)
161  , fHitsModuleLabel(pset.get<std::string>("HitsModuleLabel"))
162  , fMCModuleLabel(pset.get<std::string>("MCModuleLabel"))
163  , fMCHitsModuleLabel(pset.get<std::string>("MCHitsModuleLabel"))
164  , fClusterModuleLabel(pset.get<std::string>("ClusterModuleLabel"))
165  , fTrackModuleLabel(pset.get<std::string>("TrackModuleLabel"))
166  , fHitCompareCut(pset.get<float>("HitCompareCut"))
167  , fCosmicTagAssocLabel(pset.get<std::vector<std::string>>("CosmicTagAssocLabel"))
168  , fCosmicScoreThresholds(pset.get<std::vector<float>>("CosmicScoreThresholds"))
169 {}
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
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 207 of file CosmicRemovalAna_module.cc.

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

208 {
209 
210  InitEventTree(evt.run(), evt.event());
211 
212  // ##################################################################
213  // ### Grabbing ALL HITS in the event to monitor the backtracking ###
214  // ##################################################################
216  evt.getByLabel(fHitsModuleLabel, hitListHandle);
217  std::vector<recob::Hit> const& hitVector(*hitListHandle);
218 
219  std::vector<hit_origin_t> hitOrigins(hitVector.size());
220 
221  //get mcHitCollection
223  evt.getByLabel(fMCHitsModuleLabel, mchitListHandle);
224  std::vector<sim::MCHitCollection> const& mchitcolVector(*mchitListHandle);
225 
226  //get mcparticles out of the event
228  evt.getByLabel(fMCModuleLabel, mcParticleHandle);
229  std::vector<simb::MCParticle> const& mcParticleVector(*mcParticleHandle);
230 
231  //get associations of mc particles to mc truth
233  evt.getByLabel(fMCModuleLabel, assnMCParticleTruthHandle);
234 
235  std::vector<const simb::MCTruth*> particle_to_truth =
236  util::GetAssociatedVectorOneP(assnMCParticleTruthHandle, mcParticleHandle);
237 
238  //make trackId to MCTruth map
239  std::map<int, const simb::MCTruth*> trackIDToTruthMap;
240  for (size_t p_iter = 0; p_iter < mcParticleVector.size(); p_iter++)
241  trackIDToTruthMap[mcParticleVector[p_iter].TrackId()] = particle_to_truth[p_iter];
242 
243  FillMCInfo(evt, hitVector, hitOrigins, mchitcolVector, trackIDToTruthMap);
244 
245  art::Handle<std::vector<recob::Track>> trackListHandle;
246  evt.getByLabel(fTrackModuleLabel, trackListHandle);
247  std::vector<recob::Track> const& trackVector(*trackListHandle);
248 
249  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
250  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
251  std::vector<recob::Cluster> const& clusterVector(*clusterListHandle);
252 
254  evt.getByLabel(fTrackModuleLabel, assnHitTrackHandle);
255  std::vector<std::vector<size_t>> track_indices_per_hit =
256  util::GetAssociatedVectorManyI(assnHitTrackHandle, hitListHandle);
257 
259  evt.getByLabel(fClusterModuleLabel, assnHitClusterHandle);
260  std::vector<std::vector<size_t>> cluster_indices_per_hit =
261  util::GetAssociatedVectorManyI(assnHitClusterHandle, hitListHandle);
262 
263  std::vector<art::Handle<std::vector<anab::CosmicTag>>> cosmicTagHandlesVector(
264  fCosmicTagAssocLabel.size());
265  std::vector<art::Handle<art::Assns<recob::Track, anab::CosmicTag>>> assnTrackTagHandlesVector(
266  fCosmicTagAssocLabel.size());
267  std::vector<std::vector<const anab::CosmicTag*>> tags_per_track(
268  trackVector.size(), std::vector<const anab::CosmicTag*>(fCosmicTagAssocLabel.size()));
269  std::vector<art::Handle<art::Assns<recob::Cluster, anab::CosmicTag>>> assnClusterTagHandlesVector(
270  fCosmicTagAssocLabel.size());
271  std::vector<std::vector<const anab::CosmicTag*>> tags_per_cluster(
272  clusterVector.size(), std::vector<const anab::CosmicTag*>(fCosmicTagAssocLabel.size()));
273 
274  for (size_t label_i = 0; label_i < fCosmicTagAssocLabel.size(); label_i++) {
275  try {
276  evt.getByLabel(fCosmicTagAssocLabel[label_i], cosmicTagHandlesVector[label_i]);
277  }
278  catch (...) {
279  continue;
280  }
281  try {
282  evt.getByLabel(fCosmicTagAssocLabel[label_i], assnTrackTagHandlesVector[label_i]);
283  for (auto const& pair : *assnTrackTagHandlesVector[label_i])
284  tags_per_track.at(pair.first.key())[label_i] = &(*(pair.second));
285  }
286  catch (...) {
287  }
288  try {
289  evt.getByLabel(fCosmicTagAssocLabel[label_i], assnClusterTagHandlesVector[label_i]);
290  for (auto const& pair : *assnClusterTagHandlesVector[label_i])
291  tags_per_cluster.at(pair.first.key())[label_i] = &(*(pair.second));
292  }
293  catch (...) {
294  }
295  }
296 
297  std::vector<std::vector<bool>> hitsAccounted(
298  hitVector.size(), std::vector<bool>(fCosmicTagAssocLabel.size(), false));
299  std::vector<bool> hitsAllTags(hitVector.size(), false);
300 
301  for (size_t hit_iter = 0; hit_iter < hitVector.size(); hit_iter++) {
302 
303  float charge = hitVector[hit_iter].Integral();
304  hit_origin_t origin = hitOrigins[hit_iter];
305 
306  if (track_indices_per_hit[hit_iter].size() != 0)
307  FillTrackInfo(hit_iter,
308  origin,
309  charge,
310  track_indices_per_hit[hit_iter],
311  tags_per_track,
312  hitsAccounted[hit_iter],
313  hitsAllTags);
314 
315  if (cluster_indices_per_hit[hit_iter].size() != 0)
316  FillClusterInfo(hit_iter,
317  origin,
318  charge,
319  cluster_indices_per_hit[hit_iter],
320  tags_per_cluster,
321  hitsAccounted[hit_iter],
322  hitsAllTags);
323 
324  if (hitsAllTags[hit_iter]) FillAllTagsInfo(hitVector[hit_iter], origin);
325 
326  } //end loop over all the hits
327 
328  tEventTree->Fill();
329 }
void FillAllTagsInfo(recob::Hit const &hit, hit_origin_t const &origin)
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)
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U >> h, art::Handle< std::vector< T >> index_p)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void FillMCInfo(art::Event const &e, 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 InitEventTree(int run_number, int event_number)
EventNumber_t event() const
Definition: Event.cc:41
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
RunNumber_t run() const
Definition: Event.cc:29
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U >> h, art::Handle< std::vector< T >> index_p)
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
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< std::string > fCosmicTagAssocLabel
void microboone::CosmicRemovalAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 175 of file CosmicRemovalAna_module.cc.

References cTaggedCharge_Cosmic, cTaggedCharge_NonCosmic, cTaggedHits_Cosmic, cTaggedHits_NonCosmic, fCosmicTagAssocLabel, nCosmicTags, and tEventTree.

176 {
177 
178  //static cEventProperties_t cEventVals;
179 
185 
187  tEventTree = (TTree*)tfs->make<TTree>("CosmicEventTree", "CosmicEventTree");
188 
189  tEventTree->Branch(
190  "event",
191  &cEventVals,
192  "runNumber/I:eventNumber/I:nHitsTotal_Unknown/I:nHitsTotal_Cosmic/I:nHitsTotal_NonCosmic/"
193  "I:qTotal_Unknown/F:qTotal_Cosmic/F:qTotal_NonCosmic/F:nHitsTrack/I:nHitsTrack_Cosmic/"
194  "I:nHitsTrack_NonCosmic/I:qTrack/F:qTrack_Cosmic/F:qTrack_NonCosmic/F:nHitsCluster/"
195  "I:nHitsCluster_Cosmic/I:nHitsCluster_NonCosmic/I:qCluster/F:qCluster_Cosmic/"
196  "F:qCluster_NonCosmic/F:TotalTaggedCharge_Cosmic/F:TotalTaggedCharge_NonCosmic/"
197  "F:TotalTaggedHits_Cosmic/I:TotalTaggedHits_NonCosmic/I");
198  tEventTree->Branch("TaggedCharge_Cosmic", &cTaggedCharge_Cosmic);
199  tEventTree->Branch("TaggedCharge_NonCosmic", &cTaggedCharge_NonCosmic);
200  tEventTree->Branch("TaggedHits_Cosmic", &cTaggedHits_Cosmic);
201  tEventTree->Branch("TaggedHits_NonCosmic", &cTaggedHits_NonCosmic);
202 }
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< float > cTaggedCharge_Cosmic
std::vector< std::string > fCosmicTagAssocLabel
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 microboone::CosmicRemovalAna::FillAllTagsInfo ( recob::Hit const &  hit,
hit_origin_t const &  origin 
)
private

Definition at line 532 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().

534 {
535  if (origin == hit_origin_Cosmic) {
538  }
539  else if (origin == hit_origin_NonCosmic) {
542  }
543 }
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:229
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 484 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().

492 {
493 
495  cEventVals.qCluster += charge;
496 
497  if (origin == hit_origin_Cosmic) {
499  cEventVals.qCluster_Cosmic += charge;
500  }
501  else if (origin == hit_origin_NonCosmic) {
503  cEventVals.qCluster_NonCosmic += charge;
504  }
505 
506  for (unsigned int nCT = 0; nCT < fCosmicTagAssocLabel.size();
507  nCT++) { //<---This loops over the vector of cosmicTags in stored in the event
508  if (hitsAccounted_per_tag[nCT]) continue;
509 
510  for (auto const& cluster_index : cluster_indices_this_hit) {
511  if (!tags_per_cluster[cluster_index][nCT]) continue;
512  const anab::CosmicTag* currentTag(tags_per_cluster[cluster_index][nCT]);
513  if (currentTag->CosmicScore() > fCosmicScoreThresholds[nCT]) {
514 
515  hitsAccounted_per_tag[nCT] = true;
516  hitsAllTags[hit_iter] = true;
517  if (origin == hit_origin_Cosmic) {
518  cTaggedHits_Cosmic[nCT]++;
519  cTaggedCharge_Cosmic[nCT] += charge;
520  }
521  else if (origin == hit_origin_NonCosmic) {
522  cTaggedHits_NonCosmic[nCT]++;
523  cTaggedCharge_NonCosmic[nCT] += charge;
524  }
525  }
526  }
527  }
528 
529 } //end FillClusterInfo
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< float > fCosmicScoreThresholds
std::vector< float > cTaggedCharge_Cosmic
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
std::vector< std::string > fCosmicTagAssocLabel
void microboone::CosmicRemovalAna::FillMCInfo ( art::Event const &  e,
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 377 of file CosmicRemovalAna_module.cc.

References util::abs(), 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().

383 {
384  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
385 
386  for (size_t itr = 0; itr < hitlist.size(); itr++) {
387 
388  recob::Hit const& this_hit = hitlist[itr];
389 
390  std::vector<int> trackIDs;
391  std::vector<double> energy;
392 
393  for (auto const& mchit : mchitCollectionVector[this_hit.Channel()]) {
394  if (std::abs(clock_data.TPCTDC2Tick(mchit.PeakTime()) - this_hit.PeakTime()) <
395  fHitCompareCut) {
396  trackIDs.push_back(mchit.PartTrackId());
397  energy.push_back(mchit.PartEnergy());
398  }
399  }
400 
401  if (trackIDs.size() == 0) {
402  hitOrigins[itr] = hit_origin_Unknown;
404  cEventVals.qTotal_Unknown += this_hit.Integral();
405  continue;
406  }
407 
408  float cosmic_energy = 0;
409  float non_cosmic_energy = 0;
410 
411  for (size_t iter = 0; iter < trackIDs.size(); iter++) {
412  auto map_element = trackIdToTruthMap.find(std::abs(trackIDs[iter]));
413  if (map_element == trackIdToTruthMap.end()) continue;
414  int origin = map_element->second->Origin();
415  if (origin == simb::kBeamNeutrino)
416  non_cosmic_energy += energy[iter];
417  else
418  cosmic_energy += energy[iter];
419  }
420 
421  if (non_cosmic_energy > cosmic_energy) {
422  hitOrigins[itr] = hit_origin_NonCosmic;
424  cEventVals.qTotal_NonCosmic += this_hit.Integral();
425  }
426  else {
427  hitOrigins[itr] = hit_origin_Cosmic;
429  cEventVals.qTotal_Cosmic += this_hit.Integral();
430  }
431  }
432 
433 } //end FillMCInfo
cEventProperties_t cEventVals
constexpr auto abs(T v)
Returns the absolute value of the argument.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:244
double energy
Definition: plottest35.C:25
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
Float_t e
Definition: plot.C:35
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:268
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
Beam neutrinos.
Definition: MCTruth.h:23
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 436 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().

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

Definition at line 332 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().

333 {
334 
335  cEventVals.runNumber = run_number; //evt.run();
336  cEventVals.eventNumber = event_number; //evt.event();
337 
341 
345 
349 
350  cEventVals.qTrack = 0;
353 
357 
358  cEventVals.qCluster = 0;
361 
366 
367  for (size_t iter = 0; iter < fCosmicTagAssocLabel.size(); iter++) {
368  cTaggedHits_Cosmic.at(iter) = 0;
369  cTaggedCharge_Cosmic.at(iter) = 0;
370  cTaggedHits_NonCosmic.at(iter) = 0;
371  cTaggedCharge_NonCosmic.at(iter) = 0;
372  }
373 }
cEventProperties_t cEventVals
std::vector< float > cTaggedCharge_NonCosmic
std::vector< float > cTaggedCharge_Cosmic
std::vector< std::string > fCosmicTagAssocLabel
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
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)
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

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

Definition at line 92 of file CosmicRemovalAna_module.cc.

Referenced by beginJob(), FillClusterInfo(), FillTrackInfo(), and InitEventTree().

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

Definition at line 93 of file CosmicRemovalAna_module.cc.

Referenced by beginJob(), FillClusterInfo(), FillTrackInfo(), and InitEventTree().

std::vector<int> microboone::CosmicRemovalAna::cTaggedHits_Cosmic
private

Definition at line 94 of file CosmicRemovalAna_module.cc.

Referenced by beginJob(), FillClusterInfo(), FillTrackInfo(), and InitEventTree().

std::vector<int> microboone::CosmicRemovalAna::cTaggedHits_NonCosmic
private

Definition at line 95 of file CosmicRemovalAna_module.cc.

Referenced by beginJob(), FillClusterInfo(), FillTrackInfo(), and InitEventTree().

std::string microboone::CosmicRemovalAna::fClusterModuleLabel
private

Definition at line 60 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

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

Definition at line 64 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 62 of file CosmicRemovalAna_module.cc.

Referenced by FillMCInfo().

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

Definition at line 57 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

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

Definition at line 59 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

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

Definition at line 58 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

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

Definition at line 61 of file CosmicRemovalAna_module.cc.

Referenced by analyze().

unsigned int microboone::CosmicRemovalAna::nCosmicTags
private

Definition at line 52 of file CosmicRemovalAna_module.cc.

Referenced by beginJob().

TTree* microboone::CosmicRemovalAna::tEventTree
private

Definition at line 55 of file CosmicRemovalAna_module.cc.

Referenced by analyze(), and beginJob().


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