65 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
124 mf::LogInfo(
"CRHitRemoval") <<
"CRHitRemoval configured\n";
155 auto const* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
156 auto const*
geo = lar::providerFrom<geo::Geometry>();
157 auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
159 float samplingRate = detp->SamplingRate();
160 float driftVelocity = detp->DriftVelocity( detp->Efield(), detp->Temperature() );
194 if (!hitHandle.
isValid())
return;
203 ChannelHitWires.isValid(),
204 ChannelHitRawDigits.isValid()
214 if (!pfParticleHandle.isValid())
216 copyAllHits(ChHits, ChannelHitRawDigits, ChannelHitWires, hcol);
232 copyAllHits(ChHits, ChannelHitRawDigits, ChannelHitWires, hcol);
241 std::vector<art::Handle<std::vector<anab::CosmicTag>>> cosmicHandleVec;
242 std::vector<std::map<int,std::vector<art::Ptr<recob::Track>>>> cosmicToTrackVecMapVec;
243 std::vector<std::map<int,std::vector<art::Ptr<recob::PFParticle>>>> trackToPFParticleVecMapVec;
244 std::vector<double> thresholdVec;
265 std::map<int,std::vector<art::Ptr<recob::Track>>> cosmicToTrackVecMap;
266 std::map<int, std::vector<art::Ptr<recob::PFParticle>>> trackToPFParticleVecMap;
269 for(
size_t cosmicIdx = 0; cosmicIdx < cosmicHandle->size(); cosmicIdx++)
273 std::vector<art::Ptr<recob::Track>> cosmicToTrackVec = cosmicTrackAssns.at(cosmicTag.
key());
275 cosmicToTrackVecMap[cosmicTag.
key()] = cosmicToTrackVec;
279 for(
auto&
track : cosmicToTrackVec)
281 std::vector<art::Ptr<recob::PFParticle>> trackToPFParticleVec = trackPFParticleAssns.at(
track.key());
283 for(
auto& pfParticle : trackToPFParticleVec)
284 trackToPFParticleVecMap[
track.key()].push_back(pfParticle);
289 cosmicHandleVec.emplace_back(cosmicHandle);
290 cosmicToTrackVecMapVec.emplace_back(cosmicToTrackVecMap);
291 trackToPFParticleVecMapVec.emplace_back(trackToPFParticleVecMap);
298 if (cosmicHandleVec.empty())
300 copyAllHits(ChHits, ChannelHitRawDigits, ChannelHitWires, hcol);
317 std::set<const recob::PFParticle*> taggedSet;
321 for(
size_t idx = 0; idx != cosmicHandleVec.size(); idx++)
325 const std::map<int,std::vector<art::Ptr<recob::Track>>>& crTagTrackVec(cosmicToTrackVecMapVec[idx]);
326 const std::map<int,std::vector<art::Ptr<recob::PFParticle>>>& trackToPFParticleVecMap(trackToPFParticleVecMapVec[idx]);
328 for(
size_t crIdx = 0; crIdx != cosmicHandle->size(); crIdx++)
336 std::vector<art::Ptr<recob::Track>> trackVec(crTagTrackVec.at(cosmicTag.
key()));
339 for(
const auto&
track : trackVec)
341 std::map<int,std::vector<art::Ptr<recob::PFParticle>>>
::const_iterator trackToPFParticleVecItr = trackToPFParticleVecMap.find(
track.key());
343 if (trackToPFParticleVecItr != trackToPFParticleVecMap.end())
346 for(
const auto& pfParticlePtr : trackToPFParticleVecItr->second)
355 taggedSet.insert(pfParticle);
364 if (!taggedSet.empty())
380 for(
const auto& pfParticle : *pfParticleHandle)
383 if (!pfParticle.IsPrimary())
continue;
395 if (taggedSet.find(&pfParticle) != taggedSet.end()) goodHits =
false;
401 for(
const auto&
hit : tempHits)
414 if (goodHits) std::copy(tempHits.begin(),tempHits.end(),std::back_inserter(untaggedHits));
415 else std::copy(tempHits.begin(),tempHits.end(),std::back_inserter(taggedHits));
426 copyInTimeHits(ChHits, ChannelHitRawDigits, ChannelHitWires, hcol);
449 const art::Handle<std::vector<recob::PFParticle> >& pfParticleHandle,
455 std::vector<art::Ptr<recob::Cluster> > clusterVec = partToClusAssns.at(pfParticle->
Self());
461 for(
const auto&
cluster : clusterVec)
463 std::vector<art::Ptr<recob::Hit> > clusHitVec = clusToHitAssns.at(
cluster.key());
464 hitVec.insert(hitVec.end(), clusHitVec.begin(), clusHitVec.end());
466 int minHitTick = (*std::min_element(clusHitVec.begin(),clusHitVec.end(),[](
const auto&
hit,
const auto&
min){
return hit->PeakTimeMinusRMS() <
min->PeakTimeMinusRMS();}))->PeakTimeMinusRMS();
467 int maxHitTick = (*std::max_element(clusHitVec.begin(),clusHitVec.end(),[](
const auto&
hit,
const auto&
max){
return hit->PeakTimePlusRMS() >
max->PeakTimePlusRMS();}))->PeakTimePlusRMS();
469 if (minHitTick < minTick) minTick = minHitTick;
470 if (maxHitTick < maxTick) maxTick = maxHitTick;
474 for(
const auto& daughterId : pfParticle->
Daughters())
489 for(
const auto& hitPtr : inputHits)
495 newHitCollection.
emplace_back(*hitPtr, wire, rawdigits);
506 for(
const auto& hitPtr : inputHits)
515 newHitCollection.
emplace_back(*hitPtr, wire, rawdigits);
532 if(used_hits.size() > 0)
535 std::stable_sort(hits.begin(), hits.end());
536 std::stable_sort(used_hits.begin(), used_hits.end());
539 std::vector<art::Ptr<recob::Hit>>
::iterator it
540 = std::set_difference(hits.begin(), hits.end(), used_hits.begin(), used_hits.end(), hits.begin());
543 hits.erase(it, hits.end());
555 <<
"CRHitRemoval statistics:\n" 556 <<
" Number of events = " <<
fNumEvent <<
"\n" 558 <<
", " << aveCRPerEvent <<
" average/event";
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
virtual void reconfigure(fhicl::ParameterSet const &pset)
std::string fPFParticleProducerLabel
PFParticle producer.
size_t Self() const
Returns the index of this particle.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
int fEndTickPadding
Padding the end tick.
void copyInTimeHits(std::vector< art::Ptr< recob::Hit >> &, art::FindOneP< raw::RawDigit > &, art::FindOneP< recob::Wire > &, recob::HitCollectionCreator &)
Cluster finding and building.
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
int fNumCRRejects
Number of tracks produced.
void collectPFParticleHits(const recob::PFParticle *pfParticle, const art::Handle< std::vector< recob::PFParticle > > &pfParticleHandle, const art::FindManyP< recob::Cluster > &partToClusAssns, const art::FindManyP< recob::Hit > &clusToHitAssns, HitPtrVector &hitVec)
virtual ~CRHitRemoval()
Destructor.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Helper functions to create a hit.
A class handling a collection of hits and its associations.
std::vector< std::string > fAssnProducerLabels
Track to PFParticle assns producer.
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
std::vector< art::Ptr< recob::Hit >> HitPtrVector
std::string fHitProducerLabel
The full collection of hits.
T get(std::string const &key) const
int fMaxTickDrift
Ending tick.
bool IsPrimary() const
Returns whether the particle is the root of the flow.
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
virtual void endJob()
End job method.
std::vector< double > fCosmicTagThresholds
Thresholds for tagging.
Declaration of cluster object.
Detector simulation of raw signals on wires.
virtual void produce(art::Event &e)
Hierarchical representation of particle flow.
Utility object to perform functions of association.
int fMaxOutOfTime
Max hits that can be out of time before rejecting.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
CRHitRemoval(fhicl::ParameterSet const &pset)
int fDetectorWidthTicks
Effective drift time in ticks.
std::vector< std::string > fTrackProducerLabels
Track producer.
int fNumEvent
Number of events seen.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Namespace collecting geometry-related classes utilities.
int fMinTickDrift
Starting tick.
void FilterHits(HitPtrVector &hits, HitPtrVector &used_hits)
virtual void beginJob()
Begin job method.
art framework interface to geometry description
void copyAllHits(std::vector< art::Ptr< recob::Hit >> &, art::FindOneP< raw::RawDigit > &, art::FindOneP< recob::Wire > &, recob::HitCollectionCreator &)
std::vector< std::string > fCosmicProducerLabels
List of cosmic tagger producers.