LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cosmic::CosmicPFParticleTagger Class Reference
Inheritance diagram for cosmic::CosmicPFParticleTagger:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 CosmicPFParticleTagger (fhicl::ParameterSet const &p)
 
void produce (art::Event &e) override
 
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)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
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

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 Attributes

std::string fPFParticleModuleLabel
 
std::string fTrackModuleLabel
 
int fEndTickPadding
 
int fDetectorWidthTicks
 
int fMinTickDrift
 
int fMaxTickDrift
 
int fMaxOutOfTime
 Max hits that can be out of time before rejecting. More...
 
float fTPCXBoundary
 
float fTPCYBoundary
 
float fTPCZBoundary
 
float fDetHalfHeight
 
float fDetWidth
 
float fDetLength
 

Detailed Description

Definition at line 39 of file CosmicPFParticleTagger_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

cosmic::CosmicPFParticleTagger::CosmicPFParticleTagger ( fhicl::ParameterSet const &  p)
explicit

Definition at line 56 of file CosmicPFParticleTagger_module.cc.

References fDetectorWidthTicks, fDetHalfHeight, fDetLength, fDetWidth, fEndTickPadding, fMaxOutOfTime, fMaxTickDrift, fMinTickDrift, fPFParticleModuleLabel, fTPCXBoundary, fTPCYBoundary, fTPCZBoundary, fTrackModuleLabel, and detinfo::sampling_rate().

56  : EDProducer{p}
57 {
58 
60  auto const* geo = lar::providerFrom<geo::Geometry>();
61  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
62  auto const detp =
64 
65  fDetHalfHeight = geo->DetHalfHeight();
66  fDetWidth = 2. * geo->DetHalfWidth();
67  fDetLength = geo->DetLength();
68 
69  float fSamplingRate = sampling_rate(clock_data);
70 
71  fPFParticleModuleLabel = p.get<std::string>("PFParticleModuleLabel");
72  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel", "track");
73  fEndTickPadding = p.get<int>("EndTickPadding", 50); // Fudge the TPC edge in ticks...
74  fMaxOutOfTime = p.get<int>("MaxOutOfTime", 4);
75 
76  fTPCXBoundary = p.get<float>("TPCXBoundary", 5);
77  fTPCYBoundary = p.get<float>("TPCYBoundary", 5);
78  fTPCZBoundary = p.get<float>("TPCZBoundary", 5);
79 
80  const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature()); // cm/us
81 
83  2 * geo->DetHalfWidth() / (driftVelocity * fSamplingRate / 1000); // ~3200 for uB
84  fMinTickDrift = clock_data.Time2Tick(clock_data.TriggerTime());
86 
87  produces<std::vector<anab::CosmicTag>>();
88  produces<art::Assns<anab::CosmicTag, recob::Track>>();
89  produces<art::Assns<recob::PFParticle, anab::CosmicTag>>();
90 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Namespace collecting geometry-related classes utilities.
int fMaxOutOfTime
Max hits that can be out of time before rejecting.

Member Function Documentation

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::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::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 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

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

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

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

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

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

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
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
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
void cosmic::CosmicPFParticleTagger::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 92 of file CosmicPFParticleTagger_module.cc.

References util::begin(), util::CreateAssn(), DEFINE_ART_MODULE, util::end(), recob::Track::End(), fDetHalfHeight, fDetLength, fDetWidth, fMaxOutOfTime, fMaxTickDrift, fPFParticleModuleLabel, fTPCXBoundary, fTPCYBoundary, fTPCZBoundary, fTrackModuleLabel, art::ProductRetriever::getByLabel(), art::Handle< T >::isValid(), art::Ptr< T >::key(), anab::kGeometry_X, anab::kGeometry_XX, anab::kGeometry_XY, anab::kGeometry_XZ, anab::kGeometry_Y, anab::kGeometry_YY, anab::kGeometry_YZ, anab::kGeometry_Z, anab::kGeometry_ZZ, anab::kNotTagged, anab::kOutsideDrift_Partial, art::Event::put(), track, recob::Track::Vertex(), recob::Track::VertexDirection(), x1, and x3.

93 {
94  // Instatiate the output
95  std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagTrackVector(
96  new std::vector<anab::CosmicTag>);
97  std::unique_ptr<art::Assns<anab::CosmicTag, recob::Track>> assnOutCosmicTagTrack(
99  std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> assnOutCosmicTagPFParticle(
101 
102  // Recover handle for PFParticles
104  evt.getByLabel(fPFParticleModuleLabel, pfParticleHandle);
105 
106  if (!pfParticleHandle.isValid()) {
107  evt.put(std::move(cosmicTagTrackVector));
108  evt.put(std::move(assnOutCosmicTagTrack));
109  return;
110  }
111 
112  // Recover the handle for the tracks
114  evt.getByLabel(fTrackModuleLabel, trackHandle);
115 
116  if (!trackHandle.isValid()) {
117  evt.put(std::move(cosmicTagTrackVector));
118  evt.put(std::move(assnOutCosmicTagTrack));
119  return;
120  }
121 
122  // Recover handle for track <--> PFParticle associations
124  evt.getByLabel(fTrackModuleLabel, pfPartToTrackHandle);
125 
126  // Recover the list of associated tracks
127  art::FindManyP<recob::Track> pfPartToTrackAssns(pfParticleHandle, evt, fTrackModuleLabel);
128 
129  // and the hits
130  art::FindManyP<recob::Hit> hitsSpill(trackHandle, evt, fTrackModuleLabel);
131 
132  // The outer loop is going to be over PFParticles
133  for (size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++) {
134  art::Ptr<recob::PFParticle> pfParticle(pfParticleHandle, pfPartIdx);
135 
136  // Recover the track vector
137  std::vector<art::Ptr<recob::Track>> trackVec = pfPartToTrackAssns.at(pfPartIdx);
138 
139  // Is there a track associated to this PFParticle?
140  if (trackVec.empty()) {
141  // We need to make a null CosmicTag to store with this PFParticle to keep sequencing correct
142  std::vector<float> tempPt1, tempPt2;
143  tempPt1.push_back(-999);
144  tempPt1.push_back(-999);
145  tempPt1.push_back(-999);
146  tempPt2.push_back(-999);
147  tempPt2.push_back(-999);
148  tempPt2.push_back(-999);
149  cosmicTagTrackVector->emplace_back(tempPt1, tempPt2, 0., anab::CosmicTagID_t::kNotTagged);
150  util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
151  continue;
152  }
153 
154  // Start the tagging process...
155  int isCosmic = 0;
157  art::Ptr<recob::Track> track1 = trackVec.front();
158 
159  std::vector<art::Ptr<recob::Hit>> hitVec = hitsSpill.at(track1.key());
160 
161  // Recover track end points
162  auto vertexPosition = track1->Vertex();
163  auto vertexDirection = track1->VertexDirection();
164  auto endPosition = track1->End();
165 
166  // In principle there is one track associated to a PFParticle... but with current
167  // technology it can happen that a PFParticle is broken into multiple tracks. Our
168  // aim here is to find the maximum extents of all the tracks which have been
169  // associated to the single PFParticle
170  if (trackVec.size() > 1) {
171  for (size_t trackIdx = 1; trackIdx < trackVec.size(); trackIdx++) {
172  art::Ptr<recob::Track> track(trackVec[trackIdx]);
173 
174  auto trackStart = track->Vertex();
175  auto trackEnd = track->End();
176 
177  // Arc length possibilities for start of track
178  double arcLStartToStart = (trackStart - vertexPosition).Dot(vertexDirection);
179  double arcLStartToEnd = (trackEnd - vertexPosition).Dot(vertexDirection);
180 
181  if (arcLStartToStart < 0. || arcLStartToEnd < 0.) {
182  if (arcLStartToStart < arcLStartToEnd)
183  vertexPosition = trackStart;
184  else
185  vertexPosition = trackEnd;
186  }
187 
188  // Arc length possibilities for end of track
189  double arcLEndToStart = (trackStart - endPosition).Dot(vertexDirection);
190  double arcLEndToEnd = (trackEnd - endPosition).Dot(vertexDirection);
191 
192  if (arcLEndToStart > 0. || arcLEndToEnd > 0.) {
193  if (arcLEndToStart > arcLEndToEnd)
194  endPosition = trackStart;
195  else
196  endPosition = trackEnd;
197  }
198 
199  // add the hits from this track to the collection
200  hitVec.insert(
201  hitVec.end(), hitsSpill.at(track.key()).begin(), hitsSpill.at(track.key()).end());
202  }
203  }
204 
205  // "Track" end points in easily readable form
206  float trackEndPt1_X = vertexPosition.X();
207  float trackEndPt1_Y = vertexPosition.Y();
208  float trackEndPt1_Z = vertexPosition.Z();
209  float trackEndPt2_X = endPosition.X();
210  float trackEndPt2_Y = endPosition.Y();
211  float trackEndPt2_Z = endPosition.Z();
212 
214  // Check that all hits on particle are "in time"
216  int nOutOfTime(0);
217 
218  for (unsigned int p = 0; p < hitVec.size(); p++) {
219  int peakLessRms = hitVec[p]->PeakTimeMinusRMS();
220  int peakPlusRms = hitVec[p]->PeakTimePlusRMS();
221 
222  if (peakLessRms < fMinTickDrift || peakPlusRms > fMaxTickDrift) {
223  if (++nOutOfTime > fMaxOutOfTime) {
224  isCosmic = 1;
226  break; // If one hit is out of time it must be a cosmic ray
227  }
228  }
229  }
230 
232  // Now check the TPC boundaries:
234  if (isCosmic == 0) {
235  // In below we check entry and exit points. Note that a special case of a particle entering
236  // and exiting the same surface is considered to be running parallel to the surface and NOT
237  // entering and exiting.
238  // Also, in what follows we make no assumptions on which end point is the "start" or
239  // "end" of the track being considered.
240  unsigned boundaryMask[] = {0, 0};
241 
242  // Check x extents - note that uboone coordinaes system has x=0 at edge
243  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
244  // Also note that, in theory, any cosmic ray entering or exiting the X surfaces will have presumably
245  // been removed already by the checking of "out of time" hits... but this will at least label
246  // neutrino interaction tracks which exit through the X surfaces of the TPC
247  if (fDetWidth - trackEndPt1_X < fTPCXBoundary)
248  boundaryMask[0] = 0x1;
249  else if (trackEndPt1_X < fTPCXBoundary)
250  boundaryMask[0] = 0x2;
251 
252  if (fDetWidth - trackEndPt2_X < fTPCXBoundary)
253  boundaryMask[1] = 0x1;
254  else if (trackEndPt2_X < fTPCXBoundary)
255  boundaryMask[1] = 0x2;
256 
257  // Check y extents (note coordinate system change)
258  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
259  if (fDetHalfHeight - trackEndPt1_Y < fTPCYBoundary)
260  boundaryMask[0] = 0x10;
261  else if (fDetHalfHeight + trackEndPt1_Y < fTPCYBoundary)
262  boundaryMask[0] = 0x20;
263 
264  if (fDetHalfHeight - trackEndPt2_Y < fTPCYBoundary)
265  boundaryMask[1] = 0x10;
266  else if (fDetHalfHeight + trackEndPt2_Y < fTPCYBoundary)
267  boundaryMask[1] = 0x20;
268 
269  // Check z extents
270  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
271  if (fDetLength - trackEndPt1_Z < fTPCZBoundary)
272  boundaryMask[0] = 0x100;
273  else if (trackEndPt1_Z < fTPCZBoundary)
274  boundaryMask[0] = 0x200;
275 
276  if (fDetLength - trackEndPt2_Z < fTPCZBoundary)
277  boundaryMask[1] = 0x100;
278  else if (trackEndPt2_Z < fTPCZBoundary)
279  boundaryMask[1] = 0x200;
280 
281  unsigned trackMask = boundaryMask[0] | boundaryMask[1];
282  int nBitsSet(0);
283 
284  for (int idx = 0; idx < 12; idx++)
285  if (trackMask & (0x1 << idx)) nBitsSet++;
286 
287  // This should check for the case of a track which is both entering and exiting
288  // but we consider entering and exiting the z boundaries to be a special case (should it be?)
289  if (nBitsSet > 1) {
290  if ((trackMask & 0x300) != 0x300) {
291  isCosmic = 2;
292  if ((trackMask & 0x3) == 0x3)
294  else if ((trackMask & 0x30) == 0x30)
296  else if ((trackMask & 0x3) && (trackMask & 0x30))
298  else if ((trackMask & 0x3) && (trackMask & 0x300))
300  else
302  }
303  // This is the special case of track which appears to enter/exit z boundaries
304  else {
305  isCosmic = 3;
307  }
308  }
309  // This looks for track which enters/exits a boundary but has other endpoint in TPC
310  else if (nBitsSet > 0) {
311  isCosmic = 4;
312  if (trackMask & 0x3)
314  else if (trackMask & 0x30)
316  else if (trackMask & 0x300)
318  }
319  }
320 
321  std::vector<float> endPt1;
322  std::vector<float> endPt2;
323  endPt1.push_back(trackEndPt1_X);
324  endPt1.push_back(trackEndPt1_Y);
325  endPt1.push_back(trackEndPt1_Z);
326  endPt2.push_back(trackEndPt2_X);
327  endPt2.push_back(trackEndPt2_Y);
328  endPt2.push_back(trackEndPt2_Z);
329 
330  float cosmicScore = isCosmic > 0 ? 1. : 0.;
331 
332  // Handle special cases
333  if (isCosmic == 3)
334  cosmicScore = 0.4; // Enter/Exit at opposite Z boundaries
335  else if (isCosmic == 4)
336  cosmicScore = 0.5; // Enter or Exit but not both
337 
338  // Loop through the tracks resulting from this PFParticle and mark them
339  cosmicTagTrackVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
340 
341  util::CreateAssn(evt, *cosmicTagTrackVector, trackVec, *assnOutCosmicTagTrack);
342 
343  // Don't forget the association to the PFParticle
344  util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
345  }
346 
347  evt.put(std::move(cosmicTagTrackVector));
348  evt.put(std::move(assnOutCosmicTagTrack));
349  evt.put(std::move(assnOutCosmicTagPFParticle));
350 
351 } // end of produce
Float_t x1[n_points_granero]
Definition: compare.C:5
enum anab::cosmic_tag_id CosmicTagID_t
Float_t x3[n_points_geant4]
Vector_t VertexDirection() const
Access to track direction at different points.
Definition: Track.h:166
bool isValid() const noexcept
Definition: Handle.h:203
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
key_type key() const noexcept
Definition: Ptr.h:166
Point_t const & Vertex() const
Access to track position at different points.
Definition: Track.h:158
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
Point_t const & End() const
Access to track position at different points.
Definition: Track.h:159
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
TCEvent evt
Definition: DataStructs.cxx:8
Float_t track
Definition: plot.C:35
int fMaxOutOfTime
Max hits that can be out of time before rejecting.
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
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)

Member Data Documentation

int cosmic::CosmicPFParticleTagger::fDetectorWidthTicks
private

Definition at line 49 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger().

float cosmic::CosmicPFParticleTagger::fDetHalfHeight
private

Definition at line 53 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

float cosmic::CosmicPFParticleTagger::fDetLength
private

Definition at line 53 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

float cosmic::CosmicPFParticleTagger::fDetWidth
private

Definition at line 53 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

int cosmic::CosmicPFParticleTagger::fEndTickPadding
private

Definition at line 48 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger().

int cosmic::CosmicPFParticleTagger::fMaxOutOfTime
private

Max hits that can be out of time before rejecting.

Definition at line 51 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

int cosmic::CosmicPFParticleTagger::fMaxTickDrift
private

Definition at line 50 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

int cosmic::CosmicPFParticleTagger::fMinTickDrift
private

Definition at line 50 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger().

std::string cosmic::CosmicPFParticleTagger::fPFParticleModuleLabel
private

Definition at line 46 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

float cosmic::CosmicPFParticleTagger::fTPCXBoundary
private

Definition at line 52 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

float cosmic::CosmicPFParticleTagger::fTPCYBoundary
private

Definition at line 52 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

float cosmic::CosmicPFParticleTagger::fTPCZBoundary
private

Definition at line 52 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().

std::string cosmic::CosmicPFParticleTagger::fTrackModuleLabel
private

Definition at line 47 of file CosmicPFParticleTagger_module.cc.

Referenced by CosmicPFParticleTagger(), and produce().


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