52 if (used_hits.
size() > 0) {
54 std::stable_sort(hits.
begin(), hits.
end());
55 std::stable_sort(used_hits.
begin(), used_hits.
end());
81 const art::Handle<std::vector<recob::PFParticle>>& pfParticleHandle,
84 std::set<const recob::PFParticle*>& taggedParticles,
116 produces<std::vector<recob::Hit>>();
119 mf::LogInfo(
"CRHitRemovalByPCA") <<
"CRHitRemovalByPCA configured\n";
144 if (!hitHandle.
isValid())
return;
148 std::unique_ptr<std::vector<recob::Hit>> outputHits(
new std::vector<recob::Hit>);
151 *outputHits = *hitHandle;
158 if (!pfParticleHandle.
isValid()) {
159 evt.
put(std::move(outputHits));
169 if (!clusterHandle.
isValid()) {
170 evt.
put(std::move(outputHits));
179 if (!cosmicTagHandle.
isValid() || cosmicTagHandle->empty()) {
180 evt.
put(std::move(outputHits));
199 std::set<const recob::PFParticle*> taggedSet;
203 for (
size_t crIdx = 0; crIdx != cosmicTagHandle->size(); crIdx++) {
209 std::vector<art::Ptr<recob::PFParticle>> pfPartVec = cosmicTagToPFPartAssns.at(crIdx);
211 if (pfPartVec.empty())
continue;
216 if (!pfParticle)
continue;
222 if (taggedSet.find(pfParticle.
get()) != taggedSet.end())
continue;
226 pfParticle.
get(), pfParticleHandle, clusterAssns, clusterHitAssns, taggedSet, taggedHits);
231 if (!taggedHits.
empty()) {
237 for (
const auto& pfParticle : *pfParticleHandle) {
238 if (taggedSet.find(&pfParticle) != taggedSet.end())
continue;
241 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(pfParticle.Self());
244 for (
const auto&
cluster : clusterVec) {
245 std::vector<art::Ptr<recob::Hit>> clusHitVec = clusterHitAssns.at(
cluster->ID());
246 untaggedHits.
insert(untaggedHits.
end(), clusHitVec.begin(), clusHitVec.end());
251 FilterHits(taggedHits, untaggedHits);
259 for (
size_t hitIdx = 0; hitIdx != hitHandle->size(); hitIdx++) {
266 FilterHits(originalHits, taggedHits);
272 for (
const auto&
hit : originalHits) {
274 if (
hit->StartTick() > 6400 ||
hit->EndTick() < 3200)
continue;
276 outputHits->emplace_back(*
hit);
281 evt.
put(std::move(outputHits));
301 const art::Handle<std::vector<recob::PFParticle>>& pfParticleHandle,
304 std::set<const recob::PFParticle*>& taggedParticles,
308 std::vector<art::Ptr<recob::Cluster>> clusterVec = partToClusAssns.at(pfParticle->
Self());
311 taggedParticles.insert(pfParticle);
314 for (
const auto&
cluster : clusterVec) {
315 std::vector<art::Ptr<recob::Hit>> clusHitVec = clusToHitAssns.at(
cluster->ID());
316 hitVec.
insert(hitVec.
end(), clusHitVec.begin(), clusHitVec.end());
320 for (
const auto& daughterId : pfParticle->
Daughters()) {
324 daughter.
get(), pfParticleHandle, partToClusAssns, clusToHitAssns, taggedParticles, hitVec);
336 mf::LogInfo(
"CRHitRemovalByPCA") <<
"CRHitRemovalByPCA statistics:\n" 337 <<
" Number of events = " <<
fNumEvent <<
"\n" 338 <<
" Number of Cosmic Rays found = " <<
fNumCRRejects <<
", " 339 << aveCRPerEvent <<
" average/event";
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)
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
Declaration of signal hit object.
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
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
int fNumEvent
Number of events seen.
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
virtual void produce(art::Event &e)
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Declaration of cluster object.
Detector simulation of raw signals on wires.
double fCosmicTagThreshold
Thresholds for tagging.
iterator insert(iterator position, Ptr< U > const &p)
Hierarchical representation of particle flow.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::string fHitProducerLabel
The full collection of hits.