29 #include "canvas/Persistency/Common/FindManyP.h" 53 if(used_hits.
size() > 0)
56 std::stable_sort(hits.
begin(), hits.
end());
57 std::stable_sort(used_hits.
begin(), used_hits.
end());
84 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
85 const art::FindManyP<recob::Cluster>& partToClusAssns,
86 const art::FindManyP<recob::Hit>& clusToHitAssns,
87 std::set<const recob::PFParticle*>& taggedParticles,
121 produces<std::vector<recob::Hit> >();
124 mf::LogInfo(
"CRHitRemovalByPCA") <<
"CRHitRemovalByPCA configured\n";
149 if (!hitHandle.
isValid())
return;
153 std::unique_ptr<std::vector<recob::Hit> > outputHits(
new std::vector<recob::Hit>);
156 *outputHits = *hitHandle;
163 if (!pfParticleHandle.
isValid())
186 if (!cosmicTagHandle.
isValid() || cosmicTagHandle->empty())
194 art::FindManyP<recob::PFParticle> cosmicTagToPFPartAssns(cosmicTagHandle, evt,
fCosmicProducerLabel);
206 std::set<const recob::PFParticle*> taggedSet;
210 for(
size_t crIdx = 0; crIdx != cosmicTagHandle->size(); crIdx++)
218 std::vector<art::Ptr<recob::PFParticle> > pfPartVec = cosmicTagToPFPartAssns.at(crIdx);
220 if (pfPartVec.empty())
continue;
225 if (!pfParticle)
continue;
231 if (taggedSet.find(pfParticle.
get()) != taggedSet.end())
continue;
234 removeTaggedHits(pfParticle.
get(), pfParticleHandle, clusterAssns, clusterHitAssns, taggedSet, taggedHits);
239 if (!taggedHits.
empty())
246 for(
const auto& pfParticle : *pfParticleHandle)
248 if (taggedSet.find(&pfParticle) != taggedSet.end())
continue;
251 std::vector<art::Ptr<recob::Cluster> > clusterVec = clusterAssns.
at(pfParticle.Self());
254 for(
const auto&
cluster : clusterVec)
256 std::vector<art::Ptr<recob::Hit> > clusHitVec = clusterHitAssns.at(
cluster->ID());
257 untaggedHits.
insert(untaggedHits.
end(), clusHitVec.begin(), clusHitVec.end());
262 FilterHits(taggedHits, untaggedHits);
270 for(
size_t hitIdx = 0; hitIdx != hitHandle->size(); hitIdx++)
278 FilterHits(originalHits, taggedHits);
284 for (
const auto&
hit : originalHits)
287 if (
hit->StartTick() > 6400 ||
hit->EndTick() < 3200)
continue;
289 outputHits->emplace_back(*
hit);
313 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
314 const art::FindManyP<recob::Cluster>& partToClusAssns,
315 const art::FindManyP<recob::Hit>& clusToHitAssns,
316 std::set<const recob::PFParticle*>& taggedParticles,
320 std::vector<art::Ptr<recob::Cluster> > clusterVec = partToClusAssns.at(pfParticle->
Self());
323 taggedParticles.insert(pfParticle);
326 for(
const auto&
cluster : clusterVec)
328 std::vector<art::Ptr<recob::Hit> > clusHitVec = clusToHitAssns.at(
cluster->ID());
329 hitVec.
insert(hitVec.
end(), clusHitVec.begin(), clusHitVec.end());
333 for(
const auto& daughterId : pfParticle->
Daughters())
337 removeTaggedHits(daughter.
get(), pfParticleHandle, partToClusAssns, clusToHitAssns, taggedParticles, hitVec);
351 <<
"CRHitRemovalByPCA statistics:\n" 352 <<
" Number of events = " <<
fNumEvent <<
"\n" 354 <<
", " << aveCRPerEvent <<
" average/event";
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
typename data_t::iterator iterator
virtual void endJob()
End job method.
size_t Self() const
Returns the index of this particle.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
iterator erase(iterator position)
std::string fCosmicProducerLabel
Module that produced the PCA based cosmic tags.
CRHitRemovalByPCA(fhicl::ParameterSet const &pset)
Cluster finding and building.
std::string fPFParticleProducerLabel
PFParticle producer.
int fNumCRRejects
Number of tracks produced.
bool isValid() const noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
int fNumEvent
Number of events seen.
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
virtual void produce(art::Event &e)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool IsPrimary() const
Returns whether the particle is the root of the flow.
reference at(size_type n)
Detector simulation of raw signals on wires.
double fCosmicTagThreshold
Thresholds for tagging.
iterator insert(iterator position, Ptr< U > const &p)
Declaration of signal hit object.
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.
std::string fHitProducerLabel
The full collection of hits.