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

 CRHitRemovalByPCA (fhicl::ParameterSet const &pset)
 
virtual ~CRHitRemovalByPCA ()
 Destructor. More...
 
virtual void reconfigure (fhicl::ParameterSet const &pset)
 
virtual void produce (art::Event &e)
 
virtual void beginJob ()
 Begin job method. More...
 
virtual void endJob ()
 End job method. More...
 
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 Member Functions

void removeTaggedHits (const recob::PFParticle *pfParticle, const art::Handle< std::vector< recob::PFParticle > > &pfParticleHandle, const art::FindManyP< recob::Cluster > &partToClusAssns, const art::FindManyP< recob::Hit > &clusToHitAssns, std::set< const recob::PFParticle * > &taggedParticles, art::PtrVector< recob::Hit > &hitVec)
 

Private Attributes

std::string fCosmicProducerLabel
 Module that produced the PCA based cosmic tags. More...
 
std::string fHitProducerLabel
 The full collection of hits. More...
 
std::string fPFParticleProducerLabel
 PFParticle producer. More...
 
double fCosmicTagThreshold
 Thresholds for tagging. More...
 
int fNumEvent
 Number of events seen. More...
 
int fNumCRRejects
 Number of tracks produced. More...
 

Detailed Description

Definition at line 70 of file CRHitRemovalByPCA_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

CRHitRemovalByPCA::CRHitRemovalByPCA ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Arguments:

pset - Fcl parameters.

Definition at line 114 of file CRHitRemovalByPCA_module.cc.

References reconfigure().

114  :
115  fNumEvent(0),
116  fNumCRRejects(0)
117 {
118  reconfigure(pset);
119  produces<std::vector<recob::Hit> >();
120 
121  // Report.
122  mf::LogInfo("CRHitRemovalByPCA") << "CRHitRemovalByPCA configured\n";
123 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
virtual void reconfigure(fhicl::ParameterSet const &pset)
int fNumCRRejects
Number of tracks produced.
int fNumEvent
Number of events seen.
CRHitRemovalByPCA::~CRHitRemovalByPCA ( )
virtual

Destructor.

Definition at line 127 of file CRHitRemovalByPCA_module.cc.

128 {}

Member Function Documentation

void CRHitRemovalByPCA::beginJob ( )
virtual

Begin job method.

Reimplemented from art::EDProducer.

Definition at line 147 of file CRHitRemovalByPCA_module.cc.

148 {
149 }
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 CRHitRemovalByPCA::endJob ( )
virtual

End job method.

Reimplemented from art::EDProducer.

Definition at line 370 of file CRHitRemovalByPCA_module.cc.

References fNumCRRejects, and fNumEvent.

371 {
372  double aveCRPerEvent = fNumEvent > 0 ? double(fNumCRRejects) / double(fNumEvent) : 0.;
373 
374  mf::LogInfo("CRHitRemovalByPCA")
375  << "CRHitRemovalByPCA statistics:\n"
376  << " Number of events = " << fNumEvent << "\n"
377  << " Number of Cosmic Rays found = " << fNumCRRejects
378  << ", " << aveCRPerEvent << " average/event";
379 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fNumCRRejects
Number of tracks produced.
int fNumEvent
Number of events seen.
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 CRHitRemovalByPCA::produce ( art::Event evt)
virtual

Produce method.

Arguments:

evt - Art event.

This is the primary method. The goal is to produce a list of recob::Hit objects which are a "clean" subset of all hits and which are believed to be due to a neutrino interaction. It does this by considering input CosmicTag objects, relating them to PFParticles/Tracks and removing the hits associated to those objects which are believed to be Cosmic Rays.

Implements art::EDProducer.

Definition at line 164 of file CRHitRemovalByPCA_module.cc.

References anab::CosmicTag::CosmicScore(), art::PtrVector< T >::empty(), art::PtrVector< T >::end(), fCosmicProducerLabel, fCosmicTagThreshold, fHitProducerLabel, fNumEvent, fPFParticleProducerLabel, art::Ptr< T >::get(), art::DataViewImpl::getByLabel(), art::PtrVector< T >::insert(), recob::PFParticle::IsPrimary(), art::Handle< T >::isValid(), art::PtrVector< T >::push_back(), art::Event::put(), and removeTaggedHits().

165 {
166  ++fNumEvent;
167 
168  // Start by looking up the original hits
170  evt.getByLabel(fHitProducerLabel, hitHandle);
171 
172  // If there are no hits then there should be no output
173  if (!hitHandle.isValid()) return;
174 
175  // If there are hits then we are going to output something so get a new
176  // output hit vector
177  std::unique_ptr<std::vector<recob::Hit> > outputHits(new std::vector<recob::Hit>);
178 
179  // And fill it with the complete original list of hits
180  *outputHits = *hitHandle;
181 
182  // Recover the PFParticles that are responsible for making the tracks
184  evt.getByLabel(fPFParticleProducerLabel, pfParticleHandle);
185 
186  // Without a valid collection of PFParticles we can't do the hit removal
187  if (!pfParticleHandle.isValid())
188  {
189  evt.put(std::move(outputHits));
190  return;
191  }
192 
193  // Recover the clusters so we can do associations to the hits
194  // In theory the clusters come from the same producer as the PFParticles
196  evt.getByLabel(fPFParticleProducerLabel, clusterHandle);
197 
198  // If there are no clusters then something is really wrong
199  if (!clusterHandle.isValid())
200  {
201  evt.put(std::move(outputHits));
202  return;
203  }
204 
205  // Recover the list of cosmic tags
207  evt.getByLabel(fCosmicProducerLabel, cosmicTagHandle);
208 
209  // No cosmic tags then nothing to do here
210  if (!cosmicTagHandle.isValid() || cosmicTagHandle->empty())
211  {
212  evt.put(std::move(outputHits));
213  return;
214  }
215 
216  // Start recovering the necessary associations
217  // Start by finding the associations going from cosmic tags to PFParticles
218  art::FindManyP<recob::PFParticle> cosmicTagToPFPartAssns(cosmicTagHandle, evt, fCosmicProducerLabel);
219 
220  // From PFParticles we go to clusters
221  art::FindManyP<recob::Cluster> clusterAssns(pfParticleHandle, evt, fPFParticleProducerLabel);
222 
223  // Likewise, recover the collection of associations to hits
224  art::FindManyP<recob::Hit> clusterHitAssns(clusterHandle, evt, fPFParticleProducerLabel);
225 
226  // Container to contain the "bad" hits...
227  art::PtrVector<recob::Hit> taggedHits;
228 
229  // No point double counting hits
230  std::set<const recob::PFParticle*> taggedSet;
231 
232  // Start the identification of hits to remove. The outer loop is over the various producers of
233  // the CosmicTag objects we're examininig
234  for(size_t crIdx = 0; crIdx != cosmicTagHandle->size(); crIdx++)
235  {
236  art::Ptr<anab::CosmicTag> cosmicTag(cosmicTagHandle, crIdx);
237 
238  // If this was tagged as a CR muon then we have work to do!
239  if (cosmicTag->CosmicScore() > fCosmicTagThreshold)
240  {
241  // Recover the associated PFParticle
242  std::vector<art::Ptr<recob::PFParticle> > pfPartVec = cosmicTagToPFPartAssns.at(crIdx);
243 
244  if (pfPartVec.empty()) continue;
245 
246  art::Ptr<recob::PFParticle> pfParticle = pfPartVec.front();
247 
248  // Again, most likely needless
249  if (!pfParticle) continue;
250 
251  // A cosmic ray must be a primary (by fiat)
252  if (!pfParticle->IsPrimary()) continue;
253 
254  // Avoid double counting if more than one tagger running
255  if (taggedSet.find(pfParticle.get()) != taggedSet.end()) continue;
256 
257  // Remove all hits associated to this particle and its daughters
258  removeTaggedHits(pfParticle.get(), pfParticleHandle, clusterAssns, clusterHitAssns, taggedSet, taggedHits);
259  }
260  }
261 
262  // Are there any tagged hits?
263  if (!taggedHits.empty())
264  {
265  // First order of business is to attempt to restore any hits which are shared between a tagged
266  // CR PFParticle and an untagged one. We can do this by going through the PFParticles and
267  // "removing" hits which are in the not tagged set.
268  art::PtrVector<recob::Hit> untaggedHits;
269 
270  for(const auto& pfParticle : *pfParticleHandle)
271  {
272  if (taggedSet.find(&pfParticle) != taggedSet.end()) continue;
273 
274  // Recover the clusters associated to the input PFParticle
275  std::vector<art::Ptr<recob::Cluster> > clusterVec = clusterAssns.at(pfParticle.Self());
276 
277  // Loop over the clusters and grab the associated hits
278  for(const auto& cluster : clusterVec)
279  {
280  std::vector<art::Ptr<recob::Hit> > clusHitVec = clusterHitAssns.at(cluster->ID());
281  untaggedHits.insert(untaggedHits.end(), clusHitVec.begin(), clusHitVec.end());
282  }
283  }
284 
285  // Filter out the hits we want to save
286  FilterHits(taggedHits, untaggedHits);
287 
288  // The below is rather ugly but there is an interplay between art::Ptr's and the
289  // actual pointers to objects that I might be missing and this is what I see how to do
290  // First move all the original art::Ptr hits into a local art::PtrVector
291  art::PtrVector<recob::Hit> originalHits;
292 
293  // Fill this one hit at a time...
294  for(size_t hitIdx = 0; hitIdx != hitHandle->size(); hitIdx++)
295  {
296  art::Ptr<recob::Hit> hit(hitHandle, hitIdx);
297 
298  originalHits.push_back(hit);
299  }
300 
301  // Remove the cosmic ray tagged hits
302  FilterHits(originalHits, taggedHits);
303 
304  // Clear the current outputHits vector since we're going to refill...
305  outputHits->clear();
306 
307  // Now make the new list of output hits
308  for (const auto& hit : originalHits)
309  {
310  // Kludge to remove out of time hits
311  if (hit->StartTick() > 6400 || hit->EndTick() < 3200) continue;
312 
313  outputHits->emplace_back(*hit);
314  }
315  }
316 
317  // Add tracks and associations to event.
318  evt.put(std::move(outputHits));
319 }
std::string fCosmicProducerLabel
Module that produced the PCA based cosmic tags.
Cluster finding and building.
std::string fPFParticleProducerLabel
PFParticle producer.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool isValid() const
Definition: Handle.h:190
int fNumEvent
Number of events seen.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
iterator end()
Definition: PtrVector.h:237
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
reference at(size_type n)
Definition: PtrVector.h:365
bool empty() const
Definition: PtrVector.h:336
Detector simulation of raw signals on wires.
double fCosmicTagThreshold
Thresholds for tagging.
iterator insert(iterator position, Ptr< U > const &p)
void removeTaggedHits(const recob::PFParticle *pfParticle, const art::Handle< std::vector< recob::PFParticle > > &pfParticleHandle, const art::FindManyP< recob::Cluster > &partToClusAssns, const art::FindManyP< recob::Hit > &clusToHitAssns, std::set< const recob::PFParticle * > &taggedParticles, art::PtrVector< recob::Hit > &hitVec)
T const * get() const
Definition: Ptr.h:321
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string fHitProducerLabel
The full collection of hits.
Definition: fwd.h:25
void CRHitRemovalByPCA::reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Reconfigure method.

Arguments:

pset - Fcl parameter set.

Definition at line 137 of file CRHitRemovalByPCA_module.cc.

References fCosmicProducerLabel, fCosmicTagThreshold, fHitProducerLabel, fPFParticleProducerLabel, and fhicl::ParameterSet::get().

Referenced by CRHitRemovalByPCA().

138 {
139  fCosmicProducerLabel = pset.get<std::string>("CosmicProducerLabel");
140  fHitProducerLabel = pset.get<std::string>("HitProducerLabel");
141  fPFParticleProducerLabel = pset.get<std::string>("PFParticleProducerLabel");
142  fCosmicTagThreshold = pset.get<double> ("CosmicTagThreshold");
143 }
std::string fCosmicProducerLabel
Module that produced the PCA based cosmic tags.
std::string fPFParticleProducerLabel
PFParticle producer.
double fCosmicTagThreshold
Thresholds for tagging.
std::string fHitProducerLabel
The full collection of hits.
void CRHitRemovalByPCA::removeTaggedHits ( const recob::PFParticle pfParticle,
const art::Handle< std::vector< recob::PFParticle > > &  pfParticleHandle,
const art::FindManyP< recob::Cluster > &  partToClusAssns,
const art::FindManyP< recob::Hit > &  clusToHitAssns,
std::set< const recob::PFParticle * > &  taggedParticles,
art::PtrVector< recob::Hit > &  hitVec 
)
private

Hit removal method

Arguments:

pfParticle - the top level PFParticle to have hits removed pfParticleHandle - handle to the PFParticle objects partToClusAssns - list of PFParticle to Cluster associations clusToHitAssns - list of Cluster to Hit associations hitVec - the current list of hits

This recursively called method will remove all hits associated to an input PFParticle and, in addition, will call itself for all daughters of the input PFParticle

Definition at line 336 of file CRHitRemovalByPCA_module.cc.

References recob::PFParticle::Daughters(), art::PtrVector< T >::end(), art::Ptr< T >::get(), art::PtrVector< T >::insert(), and recob::PFParticle::Self().

Referenced by produce().

342 {
343  // Recover the clusters associated to the input PFParticle
344  std::vector<art::Ptr<recob::Cluster> > clusterVec = partToClusAssns.at(pfParticle->Self());
345 
346  // Record this PFParticle as tagged
347  taggedParticles.insert(pfParticle);
348 
349  // Loop over the clusters and grab the associated hits
350  for(const auto& cluster : clusterVec)
351  {
352  std::vector<art::Ptr<recob::Hit> > clusHitVec = clusToHitAssns.at(cluster->ID());
353  hitVec.insert(hitVec.end(), clusHitVec.begin(), clusHitVec.end());
354  }
355 
356  // Loop over the daughters of this particle and remove their hits as well
357  for(const auto& daughterId : pfParticle->Daughters())
358  {
359  art::Ptr<recob::PFParticle> daughter(pfParticleHandle, daughterId);
360 
361  removeTaggedHits(daughter.get(), pfParticleHandle, partToClusAssns, clusToHitAssns, taggedParticles, hitVec);
362  }
363 
364  return;
365 }
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
Definition: PFParticle.h:114
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
Cluster finding and building.
iterator end()
Definition: PtrVector.h:237
iterator insert(iterator position, Ptr< U > const &p)
void removeTaggedHits(const recob::PFParticle *pfParticle, const art::Handle< std::vector< recob::PFParticle > > &pfParticleHandle, const art::FindManyP< recob::Cluster > &partToClusAssns, const art::FindManyP< recob::Hit > &clusToHitAssns, std::set< const recob::PFParticle * > &taggedParticles, art::PtrVector< recob::Hit > &hitVec)
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

std::string CRHitRemovalByPCA::fCosmicProducerLabel
private

Module that produced the PCA based cosmic tags.

Definition at line 94 of file CRHitRemovalByPCA_module.cc.

Referenced by produce(), and reconfigure().

double CRHitRemovalByPCA::fCosmicTagThreshold
private

Thresholds for tagging.

Definition at line 98 of file CRHitRemovalByPCA_module.cc.

Referenced by produce(), and reconfigure().

std::string CRHitRemovalByPCA::fHitProducerLabel
private

The full collection of hits.

Definition at line 95 of file CRHitRemovalByPCA_module.cc.

Referenced by produce(), and reconfigure().

int CRHitRemovalByPCA::fNumCRRejects
private

Number of tracks produced.

Definition at line 102 of file CRHitRemovalByPCA_module.cc.

Referenced by endJob().

int CRHitRemovalByPCA::fNumEvent
private

Number of events seen.

Definition at line 101 of file CRHitRemovalByPCA_module.cc.

Referenced by endJob(), and produce().

std::string CRHitRemovalByPCA::fPFParticleProducerLabel
private

PFParticle producer.

Definition at line 96 of file CRHitRemovalByPCA_module.cc.

Referenced by produce(), and reconfigure().


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