LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cosmic::CosmicPCAxisTagger Class Reference
Inheritance diagram for cosmic::CosmicPCAxisTagger:
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

 CosmicPCAxisTagger (fhicl::ParameterSet const &p)
 
virtual ~CosmicPCAxisTagger ()
 
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 Types

typedef std::vector< reco::ClusterHit2DHit2DVector
 

Private Member Functions

void RecobToClusterHits (const art::PtrVector< recob::Hit > &recobHitVec, Hit2DVector &clusterHitVec, reco::Hit2DListPtr &hit2DListPtr) const
 

Private Attributes

std::string fPFParticleModuleLabel
 
std::string fPCAxisModuleLabel
 
detinfo::DetectorProperties const * fDetector
 Pointer to the detector properties. More...
 
lar_cluster3d::PrincipalComponentsAlg fPcaAlg
 Principal Components algorithm. More...
 
int fDetectorWidthTicks
 
float fTPCXBoundary
 
float fTPCYBoundary
 
float fTPCZBoundary
 
float fDetHalfHeight
 
float fDetWidth
 
float fDetLength
 

Detailed Description

Definition at line 60 of file CosmicPCAxisTagger_module.cc.

Member Typedef Documentation

Definition at line 73 of file CosmicPCAxisTagger_module.cc.

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::CosmicPCAxisTagger::CosmicPCAxisTagger ( fhicl::ParameterSet const &  p)
explicit

Definition at line 91 of file CosmicPCAxisTagger_module.cc.

References reconfigure().

91  :
92  fDetector(lar::providerFrom<detinfo::DetectorPropertiesService>()),
93  fPcaAlg(p.get<fhicl::ParameterSet>("PrincipalComponentsAlg"))
94 // :
95 // Initialize member data here.
96 {
97  this->reconfigure(p);
98 
99  // Call appropriate Produces<>() functions here.
100  produces< std::vector<anab::CosmicTag> >();
101  produces< art::Assns<recob::PFParticle, anab::CosmicTag> >();
102  produces< art::Assns<recob::PCAxis, anab::CosmicTag> >();
103 }
detinfo::DetectorProperties const * fDetector
Pointer to the detector properties.
void reconfigure(fhicl::ParameterSet const &p)
lar_cluster3d::PrincipalComponentsAlg fPcaAlg
Principal Components algorithm.
cosmic::CosmicPCAxisTagger::~CosmicPCAxisTagger ( )
virtual

Definition at line 105 of file CosmicPCAxisTagger_module.cc.

106 {
107  // Clean up dynamic memory and other resources here.
108 }

Member Function Documentation

void cosmic::CosmicPCAxisTagger::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 394 of file CosmicPCAxisTagger_module.cc.

395 {
396 }
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::CosmicPCAxisTagger::endJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 427 of file CosmicPCAxisTagger_module.cc.

427  {
428  // Implementation of optional member function here.
429 }
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::CosmicPCAxisTagger::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 110 of file CosmicPCAxisTagger_module.cc.

References util::CreateAssn(), fDetectorWidthTicks, fDetHalfHeight, fDetLength, fDetWidth, fPCAxisModuleLabel, fPFParticleModuleLabel, fTPCXBoundary, fTPCYBoundary, fTPCZBoundary, recob::PCAxis::getAvePosition(), art::DataViewImpl::getByLabel(), recob::PCAxis::getEigenValues(), recob::PCAxis::getEigenVectors(), 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, and art::Event::put().

111 {
112  // Instatiate the output
113  std::unique_ptr< std::vector< anab::CosmicTag > > cosmicTagPFParticleVector( new std::vector<anab::CosmicTag> );
114  std::unique_ptr< art::Assns<recob::PCAxis, anab::CosmicTag > > assnOutCosmicTagPCAxis( new art::Assns<recob::PCAxis, anab::CosmicTag>);
115  std::unique_ptr< art::Assns<recob::PFParticle, anab::CosmicTag > > assnOutCosmicTagPFParticle( new art::Assns<recob::PFParticle, anab::CosmicTag>);
116 
117  // Recover handle for PFParticles
119  evt.getByLabel( fPFParticleModuleLabel, pfParticleHandle);
120 
121  if (!pfParticleHandle.isValid())
122  {
123  evt.put( std::move(cosmicTagPFParticleVector) );
124  evt.put( std::move(assnOutCosmicTagPFParticle) );
125  evt.put( std::move(assnOutCosmicTagPCAxis) );
126  return;
127  }
128 
129  // We need a handle to the collection of clusters in the data store so we can
130  // handle associations to hits.
132  evt.getByLabel(fPFParticleModuleLabel, clusterHandle);
133 
134  // Recover the handle for the PCAxes
136  evt.getByLabel( fPCAxisModuleLabel, pcaxisHandle);
137 
138  if (!pcaxisHandle.isValid() || !clusterHandle.isValid())
139  {
140  evt.put( std::move(cosmicTagPFParticleVector) );
141  evt.put( std::move(assnOutCosmicTagPFParticle) );
142  evt.put( std::move(assnOutCosmicTagPCAxis) );
143  return;
144  }
145 
146  // Recover the list of associated PCA axes
147  art::FindManyP<recob::PCAxis> pfPartToPCAxisAssns(pfParticleHandle, evt, fPCAxisModuleLabel);
148 
149  // Add the relations to recover associations cluster hits
150  art::FindManyP<recob::SpacePoint> spacePointAssnVec(pfParticleHandle, evt, fPFParticleModuleLabel);
151 
152  // Recover the collection of associations between PFParticles and clusters, this will
153  // be the mechanism by which we actually deal with clusters
154  art::FindManyP<recob::Cluster> clusterAssns(pfParticleHandle, evt, fPFParticleModuleLabel);
155 
156  // Likewise, recover the collection of associations to hits
157  art::FindManyP<recob::Hit> clusterHitAssns(clusterHandle, evt, fPFParticleModuleLabel);
158 
159  // The outer loop is going to be over PFParticles
160  for(size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++)
161  {
162  art::Ptr<recob::PFParticle> pfParticle(pfParticleHandle, pfPartIdx);
163 
164  // Require the PFParticle be a primary because attached hits will be daughter particles
165  //if (!pfParticle->IsPrimary()) continue;
166  // Oops! Don't do this unless traversing the heirarchy!
167 
168  // Recover the PCAxis vector
169  std::vector<art::Ptr<recob::PCAxis> > pcAxisVec = pfPartToPCAxisAssns.at(pfPartIdx);
170 
171  // Is there an axis associated to this PFParticle?
172  if (pcAxisVec.empty()) continue;
173 
174  // *****************************************************************************************
175  // For what follows below we want the "best" PCAxis object only. However, it can be that
176  // there are two PCAxes for a PFParticle (depending on source) where the "first" axis will
177  // be the "better" one that we want (this statement by fiat, it is defined that way in the
178  // axis producer module).
179  if (pcAxisVec.size() > 1 && pcAxisVec.front()->getID() > pcAxisVec.back()->getID()) std::reverse(pcAxisVec.begin(), pcAxisVec.end());
180  // We need to confirm this!!
181  // *****************************************************************************************
182 
183  // Recover the axis
184  const art::Ptr<recob::PCAxis>& pcAxis = pcAxisVec.front();
185 
186  // Start the tagging process...
187  int isCosmic = 0;
189 
190  // There are two sections to the tagging, in the first we are going to check for hits that are
191  // "out of time" and for this we only need the hit vector. If no hits are out of time then
192  // we need to do a more thorough check of the positions of the hits.
193  // If we find hits that are out of time we'll set the "end points" of our trajectory to
194  // a scale factor past the principle eigen value
195  double eigenVal0 = sqrt(pcAxis->getEigenValues()[0]);
196  double maxArcLen = 3. * eigenVal0;
197 
198  // Recover PCA end points
199  TVector3 vertexPosition(pcAxis->getAvePosition()[0],pcAxis->getAvePosition()[1],pcAxis->getAvePosition()[2]);
200  TVector3 vertexDirection(pcAxis->getEigenVectors()[0][0],pcAxis->getEigenVectors()[0][1],pcAxis->getEigenVectors()[0][2]);
201 
202  TVector3 pcAxisStart = vertexPosition - maxArcLen * vertexDirection;
203  TVector3 pcAxisEnd = vertexPosition + maxArcLen * vertexDirection;
204 
205  // "Track" end points in easily readable form
206  float trackEndPt1_X = pcAxisStart [0];
207  float trackEndPt1_Y = pcAxisStart [1];
208  float trackEndPt1_Z = pcAxisStart [2];
209  float trackEndPt2_X = pcAxisEnd[0];
210  float trackEndPt2_Y = pcAxisEnd[1];
211  float trackEndPt2_Z = pcAxisEnd[2];
212 
213  // Now we get the 2D clusters associated to this PFParticle
214  std::vector<art::Ptr<recob::Cluster> > clusterVec = clusterAssns.at(pfParticle.key());
215 
216  bool dumpMe(false);
217 
218  // Once we have the clusters then we can loop over them to find the associated hits
219  for(const auto& cluster : clusterVec)
220  {
221  // Recover the 2D hits associated to a given cluster
222  std::vector<art::Ptr<recob::Hit> > hitVec = clusterHitAssns.at(cluster->ID());
223 
224  // Once we have the hits the first thing we should do is to check if any are "out of time"
225  // If there are out of time hits then we are going to reject the cluster so no need to do
226  // any further processing.
228  // Check that all hits on particle are "in time"
230  for(const auto& hit : hitVec)
231  {
232  if (dumpMe)
233  {
234  std::cout << "***>> Hit key: " << hit.key() << ", peak - RMS: " << hit->PeakTimeMinusRMS() << ", peak + RMS: " << hit->PeakTimePlusRMS() << ", det width: " << fDetectorWidthTicks << std::endl;
235  }
236  //if( hit->StartTick() < fDetectorWidthTicks || hit->EndTick() > 2.*fDetectorWidthTicks)
237  if( hit->PeakTimeMinusRMS() < fDetectorWidthTicks || hit->PeakTimePlusRMS() > 2.*fDetectorWidthTicks)
238  {
239  isCosmic = 1;
241  break; // If one hit is out of time it must be a cosmic ray
242  }
243  }
244  }
245 
246  // Recover the space points associated to this PFParticle.
247  std::vector<art::Ptr<recob::SpacePoint> > spacePointVec = spacePointAssnVec.at(pfParticle.key());
248 
250  // Now check the TPC boundaries:
252  if(isCosmic==0 && !spacePointVec.empty())
253  {
254  // Do a check on the transverse components of the PCA axes to make sure we are looking at long straight
255  // tracks and not the kind of events we might want to keep
256  double transRMS = sqrt(std::pow(pcAxis->getEigenValues()[1],2) + std::pow(pcAxis->getEigenValues()[1],2));
257 
258  //if (eigenVal0 > 10. && transRMS < 10. && transRMS / eigenVal0 < 0.1)
259  if (eigenVal0 > 0. && transRMS > 0.)
260  {
261  // The idea is to find the maximum extents of this PFParticle using the PCA axis which we
262  // can then use to determine proximity to a TPC boundary.
263  // We implement this by recovering the 3D Space Points and then make a pass through them to
264  // find the space points at the extremes of the distance along the principle axis.
265  // We'll loop through the space points looking for those which have the largest arc lengths along
266  // the principle axis. Set up to do that
267  double arcLengthToFirstHit(9999.);
268  double arcLengthToLastHit(-9999.);
269 
270  for(const auto spacePoint : spacePointVec)
271  {
272  TVector3 spacePointPos(spacePoint->XYZ()[0],spacePoint->XYZ()[1],spacePoint->XYZ()[2]);
273  TVector3 deltaPos = spacePointPos - vertexPosition;
274  double arcLenToHit = deltaPos.Dot(vertexDirection);
275 
276  if (arcLenToHit < arcLengthToFirstHit)
277  {
278  arcLengthToFirstHit = arcLenToHit;
279  pcAxisStart = spacePointPos;
280  }
281 
282  if (arcLenToHit > arcLengthToLastHit)
283  {
284  arcLengthToLastHit = arcLenToHit;
285  pcAxisEnd = spacePointPos;
286  }
287  }
288 
289  // "Track" end points in easily readable form
290  trackEndPt1_X = pcAxisStart [0];
291  trackEndPt1_Y = pcAxisStart [1];
292  trackEndPt1_Z = pcAxisStart [2];
293  trackEndPt2_X = pcAxisEnd[0];
294  trackEndPt2_Y = pcAxisEnd[1];
295  trackEndPt2_Z = pcAxisEnd[2];
296 
297  // In below we check entry and exit points. Note that a special case of a particle entering
298  // and exiting the same surface is considered to be running parallel to the surface and NOT
299  // entering and exiting.
300  // Also, in what follows we make no assumptions on which end point is the "start" or
301  // "end" of the track being considered.
302  bool nBdX[] = {false,false};
303  bool nBdY[] = {false,false};
304  bool nBdZ[] = {false,false};
305 
306  // Check x extents - note that uboone coordinaes system has x=0 at edge
307  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
308  // Also note that, in theory, any cosmic ray entering or exiting the X surfaces will have presumably
309  // been removed already by the checking of "out of time" hits... but this will at least label
310  // neutrino interaction tracks which exit through the X surfaces of the TPC
311  if (fDetWidth - trackEndPt1_X < fTPCXBoundary || trackEndPt1_X < fTPCXBoundary) nBdX[0] = true;
312  if (fDetWidth - trackEndPt2_X < fTPCXBoundary || trackEndPt2_X < fTPCXBoundary) nBdX[1] = true;
313 
314  // Check y extents (note coordinate system change)
315  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
316  if (fDetHalfHeight - trackEndPt1_Y < fTPCYBoundary || fDetHalfHeight + trackEndPt1_Y < fTPCYBoundary) nBdY[0] = true; // one end of track exits out top
317  if (fDetHalfHeight - trackEndPt2_Y < fTPCYBoundary || fDetHalfHeight + trackEndPt2_Y < fTPCYBoundary) nBdY[1] = true; // one end of track exist out bottom
318 
319  // Check z extents
320  // Note this counts the case where the track enters and exits the same surface as a "1", not a "2"
321  if (fDetLength - trackEndPt1_Z < fTPCZBoundary || trackEndPt1_Z < fTPCZBoundary ) nBdZ[0] = true;
322  if (fDetLength - trackEndPt2_Z < fTPCZBoundary || trackEndPt2_Z < fTPCZBoundary ) nBdZ[1] = true;
323 
324  // Endpoints exiting?
325  bool exitEnd1 = nBdX[0] || nBdY[0]; // end point 1 enters/exits top/bottom or x sides
326  bool exitEnd2 = nBdX[1] || nBdY[1]; // end point 2 enters/exits top/bottom or x sides
327  bool exitEndZ1 = exitEnd1 && nBdZ[1]; // end point 1 enters/exits top/bottom and exits/enters z
328  bool exitEndZ2 = exitEnd1 && nBdZ[0]; // end point 2 enters/exits top/bottom and exits/enters z
329 
330  // This should check for the case of a track which is both entering and exiting
331  // but we consider entering and exiting the z boundaries to be a special case (should it be?)
332  if((exitEnd1 && exitEnd2) || exitEndZ1 || exitEndZ2)
333  {
334  isCosmic = 2;
335  if (nBdX[0] && nBdX[1]) tag_id = anab::CosmicTagID_t::kGeometry_XX;
336  else if (nBdY[0] && nBdY[1]) tag_id = anab::CosmicTagID_t::kGeometry_YY;
337  else if ((nBdX[0] || nBdX[1]) && (nBdY[0] || nBdY[1])) tag_id = anab::CosmicTagID_t::kGeometry_XY;
338  else if ((nBdX[0] || nBdX[1]) && (nBdZ[0] || nBdZ[1])) tag_id = anab::CosmicTagID_t::kGeometry_XZ;
339  else tag_id = anab::CosmicTagID_t::kGeometry_YZ;
340  }
341  // This is the special case of track which appears to enter/exit z boundaries
342  else if ( nBdZ[0] && nBdZ[1])
343  {
344  isCosmic = 3;
346  }
347  // This looks for track which enters/exits a boundary but has other endpoint in TPC
348  else if ( (nBdX[0] || nBdY[0] || nBdZ[0]) != (nBdX[1] || nBdY[1] || nBdZ[1]))
349  {
350  isCosmic = 4 ;
351  if (nBdX[0] || nBdX[1]) tag_id = anab::CosmicTagID_t::kGeometry_X;
352  else if (nBdY[0] || nBdY[1]) tag_id = anab::CosmicTagID_t::kGeometry_Y;
353  else if (nBdZ[0] || nBdZ[1]) tag_id = anab::CosmicTagID_t::kGeometry_Z;
354  }
355  }
356  }
357 
358  std::vector<float> endPt1;
359  std::vector<float> endPt2;
360  endPt1.push_back( trackEndPt1_X );
361  endPt1.push_back( trackEndPt1_Y );
362  endPt1.push_back( trackEndPt1_Z );
363  endPt2.push_back( trackEndPt2_X );
364  endPt2.push_back( trackEndPt2_Y );
365  endPt2.push_back( trackEndPt2_Z );
366 
367  float cosmicScore = isCosmic > 0 ? 1. : 0.;
368 
369  // Handle special cases
370  if (isCosmic == 3) cosmicScore = 0.4; // Enter/Exit at opposite Z boundaries
371  else if (isCosmic == 4) cosmicScore = 0.5; // Enter or Exit but not both
372 
373  // Create the tag object for this PFParticle and make the corresponding association
374  cosmicTagPFParticleVector->emplace_back( endPt1, endPt2, cosmicScore, tag_id);
375 
376  util::CreateAssn(*this, evt, *cosmicTagPFParticleVector, pfParticle, *assnOutCosmicTagPFParticle );
377 
378  // Loop through the tracks resulting from this PFParticle and mark them
379  for(const auto& axis : pcAxisVec)
380  {
381  util::CreateAssn(*this, evt, *cosmicTagPFParticleVector, axis, *assnOutCosmicTagPCAxis );
382  }
383  }
384 
385  evt.put( std::move(cosmicTagPFParticleVector) );
386  evt.put( std::move(assnOutCosmicTagPFParticle) );
387  evt.put( std::move(assnOutCosmicTagPCAxis) );
388 
389  return;
390 
391 } // end of produce
const EigenVectors & getEigenVectors() const
Definition: PCAxis.h:66
const double * getEigenValues() const
Definition: PCAxis.h:65
enum anab::cosmic_tag_id CosmicTagID_t
Cluster finding and building.
bool isValid() const
Definition: Handle.h:190
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.
Detector simulation of raw signals on wires.
const double * getAvePosition() const
Definition: PCAxis.h:67
TCEvent evt
Definition: DataStructs.cxx:5
void cosmic::CosmicPCAxisTagger::RecobToClusterHits ( const art::PtrVector< recob::Hit > &  recobHitVec,
Hit2DVector clusterHitVec,
reco::Hit2DListPtr hit2DListPtr 
) const
private

Takes the input vector of recob::Hits and returns a vector of Cluster2D hits

Definition at line 432 of file CosmicPCAxisTagger_module.cc.

References detinfo::DetectorProperties::ConvertTicksToX(), DEFINE_ART_MODULE, fDetector, detinfo::DetectorProperties::GetXTicksOffset(), geo::kU, geo::kV, geo::kW, art::PtrVector< T >::size(), and detinfo::DetectorProperties::TriggerOffset().

435 {
441  // We'll need the offsets for each plane
442  std::map<geo::View_t, double> viewOffsetMap;
443 
444  viewOffsetMap[geo::kU] = fDetector->GetXTicksOffset(geo::kU, 0, 0)-fDetector->TriggerOffset();
445  viewOffsetMap[geo::kV] = fDetector->GetXTicksOffset(geo::kV, 0, 0)-fDetector->TriggerOffset();
446  viewOffsetMap[geo::kW] = fDetector->GetXTicksOffset(geo::kW, 0, 0)-fDetector->TriggerOffset();
447 
448  // Reserve memory for the hit vector - this is the container of the actual hits
449  clusterHitVec.reserve(recobHitVec.size());
450 
451  // Reserve memory for the list of pointers to these hits - what we'll operate on
452 
453  // Cycle through the recob hits to build ClusterHit2D objects and insert
454  // them into the map
455  for(const auto& recobHit : recobHitVec)
456  {
457  const geo::WireID& hitWireID(recobHit->WireID());
458 
459  double hitPeakTime(recobHit->PeakTime() - viewOffsetMap[recobHit->View()]);
460  double xPosition(fDetector->ConvertTicksToX(recobHit->PeakTime(), hitWireID.Plane, hitWireID.TPC, hitWireID.Cryostat));
461 
462  clusterHitVec.emplace_back(reco::ClusterHit2D(0, 0., 0., xPosition, hitPeakTime, *recobHit));
463  hit2DListPtr.emplace_back(&clusterHitVec.back());
464  }
465 
466  return;
467 }
virtual int TriggerOffset() const =0
detinfo::DetectorProperties const * fDetector
Pointer to the detector properties.
Planes which measure V.
Definition: geo_types.h:77
Planes which measure U.
Definition: geo_types.h:76
size_type size() const
Definition: PtrVector.h:308
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:78
virtual double GetXTicksOffset(int p, int t, int c) const =0
void cosmic::CosmicPCAxisTagger::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 398 of file CosmicPCAxisTagger_module.cc.

References detinfo::DetectorProperties::DriftVelocity(), detinfo::DetectorProperties::Efield(), fDetector, fDetectorWidthTicks, fDetHalfHeight, fDetLength, fDetWidth, fPcaAlg, fPCAxisModuleLabel, fPFParticleModuleLabel, fTPCXBoundary, fTPCYBoundary, fTPCZBoundary, fhicl::ParameterSet::get(), lar_cluster3d::PrincipalComponentsAlg::reconfigure(), detinfo::DetectorProperties::SamplingRate(), and detinfo::DetectorProperties::Temperature().

Referenced by CosmicPCAxisTagger().

399 {
400  // Implementation of optional member function here.
401 
403  fDetector = lar::providerFrom<detinfo::DetectorPropertiesService>();
405 
406  fDetHalfHeight = geo->DetHalfHeight();
407  fDetWidth = 2.*geo->DetHalfWidth();
408  fDetLength = geo->DetLength();
409 
410  float fSamplingRate = fDetector->SamplingRate();
411 
412  fPFParticleModuleLabel = p.get<std::string >("PFParticleModuleLabel");
413  fPCAxisModuleLabel = p.get< std::string >("PCAxisModuleLabel");
414 
415  fPcaAlg.reconfigure(p.get<fhicl::ParameterSet>("PrincipalComponentsAlg"));
416 
417  fTPCXBoundary = p.get< float >("TPCXBoundary", 5);
418  fTPCYBoundary = p.get< float >("TPCYBoundary", 5);
419  fTPCZBoundary = p.get< float >("TPCZBoundary", 5);
420 
421  const double driftVelocity = fDetector->DriftVelocity( fDetector->Efield(), fDetector->Temperature() ); // cm/us
422 
423  //std::cerr << "Drift velocity is " << driftVelocity << " cm/us. Sampling rate is: "<< fSamplingRate << " detector width: " << 2*geo->DetHalfWidth() << std::endl;
424  fDetectorWidthTicks = 2*geo->DetHalfWidth()/(driftVelocity*fSamplingRate/1000); // ~3200 for uB
425 }
detinfo::DetectorProperties const * fDetector
Pointer to the detector properties.
void reconfigure(fhicl::ParameterSet const &pset)
a handler for the case where the algorithm control parameters are to be reset
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
virtual double Temperature() const =0
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
lar_cluster3d::PrincipalComponentsAlg fPcaAlg
Principal Components algorithm.
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
Namespace collecting geometry-related classes utilities.
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

detinfo::DetectorProperties const* cosmic::CosmicPCAxisTagger::fDetector
private

Pointer to the detector properties.

Definition at line 82 of file CosmicPCAxisTagger_module.cc.

Referenced by RecobToClusterHits(), and reconfigure().

int cosmic::CosmicPCAxisTagger::fDetectorWidthTicks
private

Definition at line 85 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fDetHalfHeight
private

Definition at line 87 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fDetLength
private

Definition at line 87 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fDetWidth
private

Definition at line 87 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

lar_cluster3d::PrincipalComponentsAlg cosmic::CosmicPCAxisTagger::fPcaAlg
private

Principal Components algorithm.

Definition at line 83 of file CosmicPCAxisTagger_module.cc.

Referenced by reconfigure().

std::string cosmic::CosmicPCAxisTagger::fPCAxisModuleLabel
private

Definition at line 80 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

std::string cosmic::CosmicPCAxisTagger::fPFParticleModuleLabel
private

Definition at line 79 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fTPCXBoundary
private

Definition at line 86 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fTPCYBoundary
private

Definition at line 86 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().

float cosmic::CosmicPCAxisTagger::fTPCZBoundary
private

Definition at line 86 of file CosmicPCAxisTagger_module.cc.

Referenced by produce(), and reconfigure().


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