LArSoft  v10_04_05
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  auto const& tpc = lar::providerFrom<geo::Geometry>()->TPC({0, 0});
59  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
60  auto const detp =
62 
63  fDetHalfHeight = tpc.HalfHeight();
64  fDetWidth = 2. * tpc.HalfWidth();
65  fDetLength = tpc.Length();
66 
67  float fSamplingRate = sampling_rate(clock_data);
68 
69  fPFParticleModuleLabel = p.get<std::string>("PFParticleModuleLabel");
70  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel", "track");
71  fEndTickPadding = p.get<int>("EndTickPadding", 50); // Fudge the TPC edge in ticks...
72  fMaxOutOfTime = p.get<int>("MaxOutOfTime", 4);
73 
74  fTPCXBoundary = p.get<float>("TPCXBoundary", 5);
75  fTPCYBoundary = p.get<float>("TPCYBoundary", 5);
76  fTPCZBoundary = p.get<float>("TPCZBoundary", 5);
77 
78  const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature()); // cm/us
79 
81  2 * tpc.HalfWidth() / (driftVelocity * fSamplingRate / 1000); // ~3200 for uB
82  fMinTickDrift = clock_data.Time2Tick(clock_data.TriggerTime());
84 
85  produces<std::vector<anab::CosmicTag>>();
86  produces<art::Assns<anab::CosmicTag, recob::Track>>();
87  produces<art::Assns<recob::PFParticle, anab::CosmicTag>>();
88 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
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 90 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.

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