5 #include "fhiclcpp/ParameterSet.h"
6 #include "art/Utilities/ToolMacros.h"
7 #include "art/Framework/Services/Registry/ServiceHandle.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Principal/Handle.h"
10 #include "canvas/Utilities/InputTag.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "canvas/Persistency/Common/FindManyP.h"
19 #include "nusimdata/SimulationBase/MCTruth.h"
20 #include "nusimdata/SimulationBase/MCParticle.h"
22 #include "nug4/ParticleNavigation/ParticleList.h"
23 #include "nug4/ParticleNavigation/EmEveIdCalculator.h"
63 void reconfigure(fhicl::ParameterSet
const & pset)
override;
85 const art::Ptr<simb::MCTruth>&
ParticleToMCTruth(
const simb::MCParticle*
p)
const override;
86 std::vector<const simb::MCParticle*>
MCTruthToParticles(art::Ptr<simb::MCTruth>
const& mct)
const override;
87 const std::vector< art::Ptr<simb::MCTruth> >&
MCTruthVector()
const override;
94 art::Ptr<recob::Hit>
const&
hit)
const override;
99 std::vector<int>
const& tkIDs)
const override;
104 art::Ptr<recob::Hit>
const&
hit)
const override;
108 art::Ptr<recob::Hit>
const&
hit)
const override;
112 art::Ptr<recob::SpacePoint>
const& spt,
113 art::Event
const& evt,
114 std::string
const& label)
const override;
118 art::PtrVector<recob::Hit>
const& hits)
const override;
122 std::set<int>
const& trackIDs,
123 std::vector< art::Ptr<recob::Hit> >
const& hits)
const override;
128 std::set<int>
const& trackIDs,
130 std::vector< art::Ptr<recob::Hit> >
const& allhits,
135 std::set<int>
const& trackIDs,
136 std::vector< art::Ptr<recob::Hit> >
const& hits)
const override;
141 std::set<int>
const& trackIDs,
143 std::vector< art::Ptr<recob::Hit> >
const& allhits,
154 std::vector< art::Ptr<recob::Hit> >
const& hits)
const override;
158 std::vector< art::Ptr<recob::Hit> >
const& hits)
const override;
184 fMCTruthAssociations(pset.
get<fhicl::ParameterSet>(
"MCTruthAssociations"))
186 fGeometry = lar::providerFrom<geo::Geometry>();
191 mf::LogInfo(
"AssociationsTruth") <<
"AssociationsTruth configured\n";
225 art::Handle<art::Assns<simb::MCParticle, recob::Hit, anab::BackTrackerHitMatchingData>> partHitAssnsHandle;
229 evt.getByLabel(assnsProducerLabel, partHitAssnsHandle);
231 if (!partHitAssnsHandle.isValid())
233 throw cet::exception(
"AssociationsTruth") <<
"===>> NO MCParticle <--> Hit associations found for run/subrun/event: " << evt.run() <<
"/" << evt.subRun() <<
"/" << evt.id().event() << std::endl;
236 partHitAssnsVec.emplace_back(&*partHitAssnsHandle);
240 art::Handle<std::vector<simb::MCParticle>> mcParticleHandle;
243 std::vector<art::Ptr<simb::MCParticle>> mcParticlePtrVec;
244 art::fill_ptr_vector(mcParticlePtrVec, mcParticleHandle);
259 for(
const auto&
element : locParticleList)
265 fParticleList.AdoptEveIdCalculator(
new sim::EmEveIdCalculator);
304 std::vector<sim::TrackIDE> outputVec;
306 outputVec.reserve(locTrackIDEVec.size());
308 for(
const auto& trackIDE : locTrackIDEVec) outputVec.emplace_back(trackIDE.trackID,trackIDE.energyFrac,trackIDE.energy,trackIDE.numElectrons);
315 art::Ptr<recob::Hit>
const&
hit)
const
323 std::vector<int>
const& tkIDs)
const
333 art::Ptr<recob::Hit>
const&
hit)
const
336 std::vector<sim::TrackIDE> outputVec;
338 outputVec.reserve(locTrackIDEVec.size());
340 for(
const auto& trackIDE : locTrackIDEVec) outputVec.emplace_back(trackIDE.trackID,trackIDE.energyFrac,trackIDE.energy,trackIDE.numElectrons);
359 std::vector< art::Ptr<recob::Hit> >
const& hits)
const
366 std::vector< art::Ptr<recob::Hit> >
const& hits)
const
373 std::set<int>
const& trackIDs,
374 std::vector< art::Ptr<recob::Hit> >
const& hits)
const
381 std::set<int>
const& trackIDs,
382 std::vector< art::Ptr<recob::Hit> >
const& hits)
const
390 std::set<int>
const& trackIDs,
392 std::vector< art::Ptr<recob::Hit> >
const& allhits,
400 std::set<int>
const& trackIDs,
402 std::vector< art::Ptr<recob::Hit> >
const& allhits,
410 art::Ptr<recob::Hit>
const&
hit)
const
417 art::Ptr<recob::SpacePoint>
const& spt,
418 art::Event
const&
evt,
419 std::string
const& label)
const
422 art::PtrVector<recob::SpacePoint> spv;
424 art::FindManyP<recob::Hit> fmh(spv, evt, label);
425 std::vector< art::Ptr<recob::Hit> > hitv = fmh.at(0);
428 art::PtrVector<recob::Hit> hits;
429 for(
size_t h = 0;
h < hitv.size(); ++
h) hits.push_back(hitv[
h]);
436 art::PtrVector<recob::Hit>
const& hits)
const
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int id) const override
Utilities related to art service access.
double HitChargeCollectionEfficiency(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &, std::vector< art::Ptr< recob::Hit > > const &, geo::View_t const &) const
double HitCollectionEfficiency(detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const view) const override
const std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIDsToHits(std::vector< art::Ptr< recob::Hit >> const &, std::vector< int > const &) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
sim::ParticleList fParticleList
const simb::MCParticle * TrackIDToParticle(int const id) const override
This provides an interface which defines truth matching functions made available to downstream analys...
double HitChargeCollectionPurity(detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const override
std::vector< TrackIDE > HitToEveID(art::Ptr< recob::Hit > const &hit) const
const geo::GeometryCore * fGeometry
pointer to Geometry service
double HitCollectionPurity(detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const override
std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIDsToHits(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< int > const &tkIDs) const override
AssociationsTruth(fhicl::ParameterSet const &pset)
Constructor.
void Rebuild(const art::Event &evt) override
This rebuilds the internal maps.
MCTruthAssociations fMCTruthAssociations
The class that does the work.
art::FindOneP< simb::MCTruth > MCTruthAssns
std::vector< art::InputTag > fAssnsProducerLabels
tag for finding the tracks
const simb::MCParticle * TrackIDToMotherParticle(int const &id) const
std::vector< TrackIDE > HitToTrackID(const recob::Hit *) const
std::vector< sim::TrackIDE > HitToTrackID(detinfo::DetectorClocksData const &, recob::Hit const &hit) const override
const sim::ParticleList & ParticleList() const override
Get a reference to the ParticleList.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector() const override
const art::Ptr< simb::MCTruth > & ParticleToMCTruth(const simb::MCParticle *p) const override
std::set< int > GetSetOfTrackIDs() const
This algorithm attempts to decode Track and Hit <–> MCParticle assocations.
std::set< int > GetSetOfEveIDs() const
void reconfigure(fhicl::ParameterSet const &pset) override
Obtains truth matching by using hit <–> MCParticle associations.
const simb::MCParticle * TrackIDToMotherParticle(int const id) const override
double HitCollectionPurity(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &) const
std::vector< double > HitToXYZ(detinfo::DetectorClocksData const &, art::Ptr< recob::Hit > const &hit) const override
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
std::vector< sim::TrackIDE > HitToEveID(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit) const override
double HitCollectionEfficiency(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &, std::vector< art::Ptr< recob::Hit > > const &, geo::View_t const &) const
double HitChargeCollectionEfficiency(detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const view) const override
double HitChargeCollectionPurity(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &) const
const simb::MCParticle * TrackIDToParticle(int const &id) const
Description of geometry of one entire detector.
const art::Ptr< simb::MCTruth > & ParticleToMCTruth(const simb::MCParticle *p) const
std::set< int > GetSetOfEveIDs() const override
const MCTruthParticleList & getParticleList() const
~AssociationsTruth()
Destructor.
Contains all timing reference information for the detector.
std::set< int > GetSetOfTrackIDs() const override
std::vector< const HitParticleAssociations * > HitParticleAssociationsVec
std::vector< double > HitToXYZ(art::Ptr< recob::Hit > const &hit) const
std::vector< double > SpacePointHitsToXYZ(art::PtrVector< recob::Hit > const &hits) const
2D representation of charge deposited in the TDC/wire plane
std::vector< double > SpacePointToXYZ(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::SpacePoint > const &spt, art::Event const &evt, std::string const &label) const override
art::InputTag fG4ProducerLabel
Input tag for G4 producer (MCParticle/MCTruth)
std::vector< const simb::MCParticle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const override
std::vector< const simb::MCParticle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
std::vector< double > SpacePointHitsToXYZ(detinfo::DetectorClocksData const &clockData, art::PtrVector< recob::Hit > const &hits) const override
void setup(const HitParticleAssociationsVec &, const MCParticleVec &, const MCTruthAssns &, const geo::GeometryCore &)
art framework interface to geometry description
const MCTruthTruthVec & MCTruthVector() const