53 if(used_hits.
size() > 0)
56 std::stable_sort(hits.
begin(), hits.
end());
57 std::stable_sort(used_hits.
begin(), used_hits.
end());
87 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
90 std::set<const recob::PFParticle*>& taggedParticles,
119 produces<std::vector<recob::Hit> >();
122 mf::LogInfo(
"CRHitRemovalByPCA") <<
"CRHitRemovalByPCA configured\n";
173 if (!hitHandle.
isValid())
return;
177 std::unique_ptr<std::vector<recob::Hit> > outputHits(
new std::vector<recob::Hit>);
180 *outputHits = *hitHandle;
187 if (!pfParticleHandle.
isValid())
189 evt.
put(std::move(outputHits));
201 evt.
put(std::move(outputHits));
210 if (!cosmicTagHandle.
isValid() || cosmicTagHandle->empty())
212 evt.
put(std::move(outputHits));
230 std::set<const recob::PFParticle*> taggedSet;
234 for(
size_t crIdx = 0; crIdx != cosmicTagHandle->size(); crIdx++)
242 std::vector<art::Ptr<recob::PFParticle> > pfPartVec = cosmicTagToPFPartAssns.at(crIdx);
244 if (pfPartVec.empty())
continue;
249 if (!pfParticle)
continue;
255 if (taggedSet.find(pfParticle.
get()) != taggedSet.end())
continue;
258 removeTaggedHits(pfParticle.
get(), pfParticleHandle, clusterAssns, clusterHitAssns, taggedSet, taggedHits);
263 if (!taggedHits.
empty())
270 for(
const auto& pfParticle : *pfParticleHandle)
272 if (taggedSet.find(&pfParticle) != taggedSet.end())
continue;
275 std::vector<art::Ptr<recob::Cluster> > clusterVec = clusterAssns.at(pfParticle.Self());
278 for(
const auto&
cluster : clusterVec)
280 std::vector<art::Ptr<recob::Hit> > clusHitVec = clusterHitAssns.at(
cluster->ID());
281 untaggedHits.
insert(untaggedHits.
end(), clusHitVec.begin(), clusHitVec.end());
286 FilterHits(taggedHits, untaggedHits);
294 for(
size_t hitIdx = 0; hitIdx != hitHandle->size(); hitIdx++)
302 FilterHits(originalHits, taggedHits);
308 for (
const auto&
hit : originalHits)
311 if (
hit->StartTick() > 6400 ||
hit->EndTick() < 3200)
continue;
313 outputHits->emplace_back(*
hit);
318 evt.
put(std::move(outputHits));
337 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
340 std::set<const recob::PFParticle*>& taggedParticles,
344 std::vector<art::Ptr<recob::Cluster> > clusterVec = partToClusAssns.at(pfParticle->
Self());
347 taggedParticles.insert(pfParticle);
350 for(
const auto&
cluster : clusterVec)
352 std::vector<art::Ptr<recob::Hit> > clusHitVec = clusToHitAssns.at(
cluster->ID());
353 hitVec.
insert(hitVec.
end(), clusHitVec.begin(), clusHitVec.end());
357 for(
const auto& daughterId : pfParticle->
Daughters())
361 removeTaggedHits(daughter.
get(), pfParticleHandle, partToClusAssns, clusToHitAssns, taggedParticles, hitVec);
375 <<
"CRHitRemovalByPCA statistics:\n" 376 <<
" Number of events = " <<
fNumEvent <<
"\n" 378 <<
", " << aveCRPerEvent <<
" average/event";
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
virtual void endJob()
End job method.
size_t Self() const
Returns the index of this particle.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
iterator erase(iterator position)
std::string fCosmicProducerLabel
Module that produced the PCA based cosmic tags.
virtual void beginJob()
Begin job method.
virtual void reconfigure(fhicl::ParameterSet const &pset)
CRHitRemovalByPCA(fhicl::ParameterSet const &pset)
Cluster finding and building.
std::string fPFParticleProducerLabel
PFParticle producer.
int fNumCRRejects
Number of tracks produced.
ProductID put(std::unique_ptr< PROD > &&product)
int fNumEvent
Number of events seen.
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
virtual void produce(art::Event &e)
T get(std::string const &key) const
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Declaration of cluster object.
Provides recob::Track data product.
data_t::iterator iterator
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)
Hierarchical representation of particle flow.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
std::string fHitProducerLabel
The full collection of hits.
virtual ~CRHitRemovalByPCA()
Destructor.
art framework interface to geometry description