LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cosmic::CosmicPFParticleTagger Class Reference
Inheritance diagram for cosmic::CosmicPFParticleTagger:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 CosmicPFParticleTagger (fhicl::ParameterSet const &p)
 
virtual ~CosmicPFParticleTagger ()
 
void produce (art::Event &e) override
 
void beginJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void endJob () override
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

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 57 of file CosmicPFParticleTagger_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 81 of file CosmicPFParticleTagger_module.cc.

References reconfigure().

84 {
85  this->reconfigure(p);
86 
87  // Call appropriate Produces<>() functions here.
88  produces< std::vector<anab::CosmicTag>>();
89  produces< art::Assns<anab::CosmicTag, recob::Track>>();
90  produces< art::Assns<recob::PFParticle, anab::CosmicTag>>();
91 }
void reconfigure(fhicl::ParameterSet const &p)
cosmic::CosmicPFParticleTagger::~CosmicPFParticleTagger ( )
virtual

Definition at line 93 of file CosmicPFParticleTagger_module.cc.

94 {
95  // Clean up dynamic memory and other resources here.
96 }

Member Function Documentation

void cosmic::CosmicPFParticleTagger::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 348 of file CosmicPFParticleTagger_module.cc.

349 {
350 }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void cosmic::CosmicPFParticleTagger::endJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 384 of file CosmicPFParticleTagger_module.cc.

References DEFINE_ART_MODULE.

384  {
385  // Implementation of optional member function here.
386 }
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void cosmic::CosmicPFParticleTagger::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 98 of file CosmicPFParticleTagger_module.cc.

References evd::details::begin(), util::CreateAssn(), recob::Track::End(), evd::details::end(), fDetHalfHeight, fDetLength, fDetWidth, fMaxOutOfTime, fMaxTickDrift, fPFParticleModuleLabel, fTPCXBoundary, fTPCYBoundary, fTPCZBoundary, fTrackModuleLabel, art::DataViewImpl::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(), and x1.

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

Definition at line 352 of file CosmicPFParticleTagger_module.cc.

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

Referenced by CosmicPFParticleTagger().

353 {
354  // Implementation of optional member function here.
355 
357  auto const* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
358  auto const* geo = lar::providerFrom<geo::Geometry>();
359  auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
360 
361  fDetHalfHeight = geo->DetHalfHeight();
362  fDetWidth = 2.*geo->DetHalfWidth();
363  fDetLength = geo->DetLength();
364 
365  float fSamplingRate = detp->SamplingRate();
366 
367  fPFParticleModuleLabel = p.get< std::string >("PFParticleModuleLabel");
368  fTrackModuleLabel = p.get< std::string >("TrackModuleLabel", "track");
369  fEndTickPadding = p.get< int >("EndTickPadding", 50); // Fudge the TPC edge in ticks...
370  fMaxOutOfTime = p.get< int >("MaxOutOfTime", 4);
371 
372  fTPCXBoundary = p.get< float >("TPCXBoundary", 5);
373  fTPCYBoundary = p.get< float >("TPCYBoundary", 5);
374  fTPCZBoundary = p.get< float >("TPCZBoundary", 5);
375 
376  const double driftVelocity = detp->DriftVelocity( detp->Efield(), detp->Temperature() ); // cm/us
377 
378  //std::cerr << "Drift velocity is " << driftVelocity << " cm/us. Sampling rate is: "<< fSamplingRate << " detector width: " << 2*geo->DetHalfWidth() << std::endl;
379  fDetectorWidthTicks = 2*geo->DetHalfWidth()/(driftVelocity*fSamplingRate/1000); // ~3200 for uB
380  fMinTickDrift = ts->Time2Tick(ts->TriggerTime());
382 }
Namespace collecting geometry-related classes utilities.
int fMaxOutOfTime
Max hits that can be out of time before rejecting.
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

int cosmic::CosmicPFParticleTagger::fDetectorWidthTicks
private

Definition at line 73 of file CosmicPFParticleTagger_module.cc.

Referenced by reconfigure().

float cosmic::CosmicPFParticleTagger::fDetHalfHeight
private

Definition at line 77 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPFParticleTagger::fDetLength
private

Definition at line 77 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPFParticleTagger::fDetWidth
private

Definition at line 77 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

int cosmic::CosmicPFParticleTagger::fEndTickPadding
private

Definition at line 72 of file CosmicPFParticleTagger_module.cc.

Referenced by reconfigure().

int cosmic::CosmicPFParticleTagger::fMaxOutOfTime
private

Max hits that can be out of time before rejecting.

Definition at line 75 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

int cosmic::CosmicPFParticleTagger::fMaxTickDrift
private

Definition at line 74 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

int cosmic::CosmicPFParticleTagger::fMinTickDrift
private

Definition at line 74 of file CosmicPFParticleTagger_module.cc.

Referenced by reconfigure().

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

Definition at line 70 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPFParticleTagger::fTPCXBoundary
private

Definition at line 76 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPFParticleTagger::fTPCYBoundary
private

Definition at line 76 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPFParticleTagger::fTPCZBoundary
private

Definition at line 76 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().

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

Definition at line 71 of file CosmicPFParticleTagger_module.cc.

Referenced by produce(), and reconfigure().


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