All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
truth::AssociationsTruth Class Reference
Inheritance diagram for truth::AssociationsTruth:
truth::IMCTruthMatching

Public Member Functions

 AssociationsTruth (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~AssociationsTruth ()
 Destructor. More...
 
void reconfigure (fhicl::ParameterSet const &pset) override
 
void Rebuild (const art::Event &evt) override
 This rebuilds the internal maps. More...
 
const sim::ParticleList & ParticleList () const override
 Get a reference to the ParticleList. More...
 
const simb::MCParticle * TrackIDToParticle (int const id) const override
 
const simb::MCParticle * TrackIDToMotherParticle (int const id) const override
 
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth (int id) const override
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth (const simb::MCParticle *p) const override
 
std::vector< const
simb::MCParticle * > 
MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const override
 
const std::vector< art::Ptr
< simb::MCTruth > > & 
MCTruthVector () const override
 
std::vector< sim::TrackIDEHitToTrackID (detinfo::DetectorClocksData const &, recob::Hit const &hit) const override
 
std::vector< sim::TrackIDEHitToTrackID (detinfo::DetectorClocksData const &, art::Ptr< recob::Hit > const &hit) 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
 
std::vector< sim::TrackIDEHitToEveID (detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit) const override
 
std::vector< double > HitToXYZ (detinfo::DetectorClocksData const &, art::Ptr< recob::Hit > const &hit) const override
 
std::vector< double > SpacePointToXYZ (detinfo::DetectorClocksData const &clockData, art::Ptr< recob::SpacePoint > const &spt, art::Event const &evt, std::string const &label) const override
 
std::vector< double > SpacePointHitsToXYZ (detinfo::DetectorClocksData const &clockData, art::PtrVector< recob::Hit > const &hits) const override
 
double HitCollectionPurity (detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const override
 
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
 
double HitChargeCollectionPurity (detinfo::DetectorClocksData const &, std::set< int > const &trackIDs, std::vector< art::Ptr< recob::Hit > > const &hits) const override
 
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
 
std::set< int > GetSetOfEveIDs () const override
 
std::set< int > GetSetOfTrackIDs () const override
 
std::set< int > GetSetOfEveIDs (detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit > > const &hits) const override
 
std::set< int > GetSetOfTrackIDs (detinfo::DetectorClocksData const &, std::vector< art::Ptr< recob::Hit > > const &hits) const override
 
- Public Member Functions inherited from truth::IMCTruthMatching
virtual ~IMCTruthMatching () noexcept=default
 Virtual Destructor. More...
 

Private Attributes

std::vector< art::InputTag > fAssnsProducerLabels
 tag for finding the tracks More...
 
art::InputTag fG4ProducerLabel
 Input tag for G4 producer (MCParticle/MCTruth) More...
 
MCTruthAssociations fMCTruthAssociations
 The class that does the work. More...
 
sim::ParticleList fParticleList
 
const geo::GeometryCorefGeometry
 pointer to Geometry service More...
 

Detailed Description

Definition at line 47 of file AssociationsTruth_tool.cc.

Constructor & Destructor Documentation

truth::AssociationsTruth::AssociationsTruth ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Parameters
psetConstructor.

Arguments:

pset - Fcl parameters.

Definition at line 183 of file AssociationsTruth_tool.cc.

183  :
184  fMCTruthAssociations(pset.get<fhicl::ParameterSet>("MCTruthAssociations"))
185 {
186  fGeometry = lar::providerFrom<geo::Geometry>();
187 
188  reconfigure(pset);
189 
190  // Report.
191  mf::LogInfo("AssociationsTruth") << "AssociationsTruth configured\n";
192 }
const geo::GeometryCore * fGeometry
pointer to Geometry service
MCTruthAssociations fMCTruthAssociations
The class that does the work.
void reconfigure(fhicl::ParameterSet const &pset) override
truth::AssociationsTruth::~AssociationsTruth ( )

Destructor.

Definition at line 196 of file AssociationsTruth_tool.cc.

197 {}

Member Function Documentation

std::set< int > truth::AssociationsTruth::GetSetOfEveIDs ( ) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 346 of file AssociationsTruth_tool.cc.

347 {
349 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::set< int > GetSetOfEveIDs() const
std::set< int > truth::AssociationsTruth::GetSetOfEveIDs ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 358 of file AssociationsTruth_tool.cc.

360 {
362 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::set< int > GetSetOfEveIDs() const
std::set< int > truth::AssociationsTruth::GetSetOfTrackIDs ( ) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 352 of file AssociationsTruth_tool.cc.

353 {
355 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::set< int > GetSetOfTrackIDs() const
std::set< int > truth::AssociationsTruth::GetSetOfTrackIDs ( detinfo::DetectorClocksData const &  ,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 365 of file AssociationsTruth_tool.cc.

367 {
369 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::set< int > GetSetOfTrackIDs() const
double truth::AssociationsTruth::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
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 399 of file AssociationsTruth_tool.cc.

404 {
405  return fMCTruthAssociations.HitChargeCollectionEfficiency(trackIDs, hits, allhits, view);
406 }
double HitChargeCollectionEfficiency(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &, std::vector< art::Ptr< recob::Hit > > const &, geo::View_t const &) const
MCTruthAssociations fMCTruthAssociations
The class that does the work.
double truth::AssociationsTruth::HitChargeCollectionPurity ( detinfo::DetectorClocksData const &  ,
std::set< int > const &  trackIDs,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 380 of file AssociationsTruth_tool.cc.

383 {
384  return fMCTruthAssociations.HitChargeCollectionPurity(trackIDs, hits);
385 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
double HitChargeCollectionPurity(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &) const
double truth::AssociationsTruth::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
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 389 of file AssociationsTruth_tool.cc.

394 {
395  return fMCTruthAssociations.HitCollectionEfficiency(trackIDs, hits, allhits, view);
396 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
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 truth::AssociationsTruth::HitCollectionPurity ( detinfo::DetectorClocksData const &  ,
std::set< int > const &  trackIDs,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 372 of file AssociationsTruth_tool.cc.

375 {
376  return fMCTruthAssociations.HitCollectionPurity(trackIDs, hits);
377 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
double HitCollectionPurity(std::set< int >, std::vector< art::Ptr< recob::Hit > > const &) const
std::vector< sim::TrackIDE > truth::AssociationsTruth::HitToEveID ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::Hit > const &  hit 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 332 of file AssociationsTruth_tool.cc.

334 {
335  std::vector<truth::TrackIDE> locTrackIDEVec = fMCTruthAssociations.HitToEveID(hit);
336  std::vector<sim::TrackIDE> outputVec;
337 
338  outputVec.reserve(locTrackIDEVec.size());
339 
340  for(const auto& trackIDE : locTrackIDEVec) outputVec.emplace_back(trackIDE.trackID,trackIDE.energyFrac,trackIDE.energy,trackIDE.numElectrons);
341 
342  return outputVec;
343 }
std::vector< TrackIDE > HitToEveID(art::Ptr< recob::Hit > const &hit) const
process_name hit
Definition: cheaterreco.fcl:51
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::vector< sim::TrackIDE > truth::AssociationsTruth::HitToTrackID ( detinfo::DetectorClocksData const &  ,
recob::Hit const &  hit 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 300 of file AssociationsTruth_tool.cc.

302 {
303  std::vector<truth::TrackIDE> locTrackIDEVec = fMCTruthAssociations.HitToTrackID(&hit);
304  std::vector<sim::TrackIDE> outputVec;
305 
306  outputVec.reserve(locTrackIDEVec.size());
307 
308  for(const auto& trackIDE : locTrackIDEVec) outputVec.emplace_back(trackIDE.trackID,trackIDE.energyFrac,trackIDE.energy,trackIDE.numElectrons);
309 
310  return outputVec;
311 }
process_name hit
Definition: cheaterreco.fcl:51
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::vector< TrackIDE > HitToTrackID(const recob::Hit *) const
std::vector< sim::TrackIDE > truth::AssociationsTruth::HitToTrackID ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::Hit > const &  hit 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 314 of file AssociationsTruth_tool.cc.

316 {
317  return HitToTrackID(clockData, *hit);
318 }
process_name hit
Definition: cheaterreco.fcl:51
std::vector< sim::TrackIDE > HitToTrackID(detinfo::DetectorClocksData const &, recob::Hit const &hit) const override
std::vector< double > truth::AssociationsTruth::HitToXYZ ( detinfo::DetectorClocksData const &  ,
art::Ptr< recob::Hit > const &  hit 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 409 of file AssociationsTruth_tool.cc.

411 {
413 }
process_name hit
Definition: cheaterreco.fcl:51
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::vector< double > HitToXYZ(art::Ptr< recob::Hit > const &hit) const
std::vector< const simb::MCParticle * > truth::AssociationsTruth::MCTruthToParticles ( art::Ptr< simb::MCTruth > const &  mct) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 288 of file AssociationsTruth_tool.cc.

289 {
291 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::vector< const simb::MCParticle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
const std::vector< art::Ptr< simb::MCTruth > > & truth::AssociationsTruth::MCTruthVector ( ) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 294 of file AssociationsTruth_tool.cc.

295 {
297 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
const MCTruthTruthVec & MCTruthVector() const
const sim::ParticleList & truth::AssociationsTruth::ParticleList ( ) const
overridevirtual

Get a reference to the ParticleList.

Implements truth::IMCTruthMatching.

Definition at line 269 of file AssociationsTruth_tool.cc.

270 {
271  // Unfortunately, this requires special handling at the moment...
272  return fParticleList;
273 }
const art::Ptr< simb::MCTruth > & truth::AssociationsTruth::ParticleToMCTruth ( const simb::MCParticle *  p) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 282 of file AssociationsTruth_tool.cc.

283 {
285 }
pdgs p
Definition: selectors.fcl:22
MCTruthAssociations fMCTruthAssociations
The class that does the work.
const art::Ptr< simb::MCTruth > & ParticleToMCTruth(const simb::MCParticle *p) const
void truth::AssociationsTruth::Rebuild ( const art::Event &  evt)
overridevirtual

This rebuilds the internal maps.

Rebuild method -> rebuild the basic maps to get truth information

Arguments:

event - the art event used to extract all information

Implements truth::IMCTruthMatching.

Definition at line 219 of file AssociationsTruth_tool.cc.

220 {
221  // Create a container for testing
222  HitParticleAssociationsVec partHitAssnsVec;
223 
224  // Get a handle for the associations...
225  art::Handle<art::Assns<simb::MCParticle, recob::Hit, anab::BackTrackerHitMatchingData>> partHitAssnsHandle;
226 
227  for(const auto& assnsProducerLabel : fAssnsProducerLabels)
228  {
229  evt.getByLabel(assnsProducerLabel, partHitAssnsHandle);
230 
231  if (!partHitAssnsHandle.isValid())
232  {
233  throw cet::exception("AssociationsTruth") << "===>> NO MCParticle <--> Hit associations found for run/subrun/event: " << evt.run() << "/" << evt.subRun() << "/" << evt.id().event() << std::endl;
234  }
235 
236  partHitAssnsVec.emplace_back(&*partHitAssnsHandle);
237  }
238 
239  // Recover the associations between MCTruth and MCParticles
240  art::Handle<std::vector<simb::MCParticle>> mcParticleHandle;
241  evt.getByLabel(fG4ProducerLabel, mcParticleHandle);
242 
243  std::vector<art::Ptr<simb::MCParticle>> mcParticlePtrVec;
244  art::fill_ptr_vector(mcParticlePtrVec, mcParticleHandle);
245 
246  MCTruthAssns mcTruthAssns(mcParticleHandle, evt, fG4ProducerLabel);
247 
248  // Pass this to the truth associations code
249  fMCTruthAssociations.setup(partHitAssnsVec, mcParticlePtrVec, mcTruthAssns, *fGeometry);
250 
251  // Ugliness to follow! Basically, we need to build the "particle list" and the current implementation of
252  // that code requires a copy...
253  const MCTruthParticleList& locParticleList = fMCTruthAssociations.getParticleList();
254 
255  // Clear the current container
256  fParticleList.clear();
257 
258  // Now we add particles back in one at a time...
259  for(const auto& element : locParticleList)
260  {
261  fParticleList.Add(new simb::MCParticle(*(element.second)));
262  }
263 
264  // Just to be consistent with the backtracker...
265  fParticleList.AdoptEveIdCalculator(new sim::EmEveIdCalculator);
266 }
unsigned int event
Definition: DataStructs.h:634
unsigned int run
Definition: DataStructs.h:635
const geo::GeometryCore * fGeometry
pointer to Geometry service
MCTruthAssociations fMCTruthAssociations
The class that does the work.
art::FindOneP< simb::MCTruth > MCTruthAssns
std::vector< art::InputTag > fAssnsProducerLabels
tag for finding the tracks
const MCTruthParticleList & getParticleList() const
std::vector< const HitParticleAssociations * > HitParticleAssociationsVec
unsigned int subRun
Definition: DataStructs.h:636
art::InputTag fG4ProducerLabel
Input tag for G4 producer (MCParticle/MCTruth)
TCEvent evt
Definition: DataStructs.cxx:8
void setup(const HitParticleAssociationsVec &, const MCParticleVec &, const MCTruthAssns &, const geo::GeometryCore &)
void truth::AssociationsTruth::reconfigure ( fhicl::ParameterSet const &  pset)
overridevirtual

Reconfigure method.

Arguments:

pset - Fcl parameter set.

Implements truth::IMCTruthMatching.

Definition at line 206 of file AssociationsTruth_tool.cc.

207 {
208  fAssnsProducerLabels = pset.get<std::vector<art::InputTag>>("AssnsProducerLabels");
209  fG4ProducerLabel = pset.get<art::InputTag> ("G4ProducerLabel");
210 }
std::vector< art::InputTag > fAssnsProducerLabels
tag for finding the tracks
art::InputTag fG4ProducerLabel
Input tag for G4 producer (MCParticle/MCTruth)
std::vector< double > truth::AssociationsTruth::SpacePointHitsToXYZ ( detinfo::DetectorClocksData const &  clockData,
art::PtrVector< recob::Hit > const &  hits 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 435 of file AssociationsTruth_tool.cc.

437 {
439 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
std::vector< double > SpacePointHitsToXYZ(art::PtrVector< recob::Hit > const &hits) const
std::vector< double > truth::AssociationsTruth::SpacePointToXYZ ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::SpacePoint > const &  spt,
art::Event const &  evt,
std::string const &  label 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 416 of file AssociationsTruth_tool.cc.

420 {
421  // Get hits that make up this space point.
422  art::PtrVector<recob::SpacePoint> spv;
423  spv.push_back(spt);
424  art::FindManyP<recob::Hit> fmh(spv, evt, label);
425  std::vector< art::Ptr<recob::Hit> > hitv = fmh.at(0);
426 
427  // make a PtrVector
428  art::PtrVector<recob::Hit> hits;
429  for(size_t h = 0; h < hitv.size(); ++h) hits.push_back(hitv[h]);
430 
431  return this->SpacePointHitsToXYZ(clockData, hits);
432 }
while getopts h
TCEvent evt
Definition: DataStructs.cxx:8
std::vector< double > SpacePointHitsToXYZ(detinfo::DetectorClocksData const &clockData, art::PtrVector< recob::Hit > const &hits) const override
std::vector< std::vector< art::Ptr< recob::Hit > > > truth::AssociationsTruth::TrackIDsToHits ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit >> const &  allhits,
std::vector< int > const &  tkIDs 
) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 321 of file AssociationsTruth_tool.cc.

324 {
325  return fMCTruthAssociations.TrackIDsToHits(allhits,tkIDs);
326 }
const std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIDsToHits(std::vector< art::Ptr< recob::Hit >> const &, std::vector< int > const &) const
MCTruthAssociations fMCTruthAssociations
The class that does the work.
const art::Ptr< simb::MCTruth > & truth::AssociationsTruth::TrackIDToMCTruth ( int  id) const
overridevirtual

Implements truth::IMCTruthMatching.

Definition at line 276 of file AssociationsTruth_tool.cc.

277 {
279 }
MCTruthAssociations fMCTruthAssociations
The class that does the work.
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
const simb::MCParticle* truth::AssociationsTruth::TrackIDToMotherParticle ( int const  id) const
inlineoverridevirtual

Implements truth::IMCTruthMatching.

Definition at line 81 of file AssociationsTruth_tool.cc.

MCTruthAssociations fMCTruthAssociations
The class that does the work.
const simb::MCParticle * TrackIDToMotherParticle(int const &id) const
const simb::MCParticle* truth::AssociationsTruth::TrackIDToParticle ( int const  id) const
inlineoverridevirtual

Implements truth::IMCTruthMatching.

Definition at line 80 of file AssociationsTruth_tool.cc.

MCTruthAssociations fMCTruthAssociations
The class that does the work.
const simb::MCParticle * TrackIDToParticle(int const &id) const

Member Data Documentation

std::vector<art::InputTag> truth::AssociationsTruth::fAssnsProducerLabels
private

tag for finding the tracks

Definition at line 163 of file AssociationsTruth_tool.cc.

art::InputTag truth::AssociationsTruth::fG4ProducerLabel
private

Input tag for G4 producer (MCParticle/MCTruth)

Definition at line 164 of file AssociationsTruth_tool.cc.

const geo::GeometryCore* truth::AssociationsTruth::fGeometry
private

pointer to Geometry service

Definition at line 173 of file AssociationsTruth_tool.cc.

MCTruthAssociations truth::AssociationsTruth::fMCTruthAssociations
private

The class that does the work.

Definition at line 167 of file AssociationsTruth_tool.cc.

sim::ParticleList truth::AssociationsTruth::fParticleList
private

Definition at line 170 of file AssociationsTruth_tool.cc.


The documentation for this class was generated from the following file: