LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
MCParticleHitMatching_module.cc
Go to the documentation of this file.
1 
20 // Framework includes
26 
28 #include "fhiclcpp/ParameterSet.h"
30 
31 #include <memory>
32 #include <iostream>
33 #include <map>
34 #include <iterator>
35 
36 // LArSoft
38 
39 namespace t0 {
40  class MCParticleHitMatching;
41 
43 {
44 public:
45  explicit MCParticleHitMatching(fhicl::ParameterSet const & p);
46  // The destructor generated by the compiler is fine for classes
47  // without bare pointers or other resource use.
48 
49  // Plugins should not be copied or assigned.
54 
55  // Required functions.
56  void produce(art::Event & e) override;
57 
58  // Selected optional functions.
59  void beginJob() override;
60  void reconfigure(fhicl::ParameterSet const & p) ;
61 
62 private:
63 
64  // For keeping track of the replacement backtracker
65  std::unique_ptr<IHitParticleAssociations> fHitParticleAssociations;
67 };
68 
69 
71 {
72  reconfigure(pset);
73  produces<HitParticleAssociations> ();
74 }
75 
77 {
78  // Get the tool for MC Truth matching
79  //const fhicl::ParameterSet& hitPartAssnsParams = pset.get<fhicl::ParameterSet>("HitParticleAssociations"); // unused
80 
81  fOverrideRealData = pset.get<bool>("OverrideRealData", false);
82 
83  // Get the tool for MC Truth matching
84  fHitParticleAssociations = art::make_tool<IHitParticleAssociations>(pset.get<fhicl::ParameterSet>("HitParticleAssociations"));
85 }
86 
88 {
89 }
90 
92 {
93  if(evt.isRealData() && !fOverrideRealData) return;
94 
95  std::unique_ptr<HitParticleAssociations> MCPartHitassn( new HitParticleAssociations);
96 
97  fHitParticleAssociations->CreateHitParticleAssociations(evt, MCPartHitassn.get());
98 
99  evt.put(std::move(MCPartHitassn));
100 } // Produce
101 
103 } // end namespace
104 
MCParticleHitMatching(fhicl::ParameterSet const &p)
code to link reconstructed objects back to the MC truth information
MCParticleHitMatching & operator=(MCParticleHitMatching const &)=delete
bool isRealData() const
Definition: Event.h:83
bool fOverrideRealData
if real data, tell it to run anyway (=0)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void produce(art::Event &e) override
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::unique_ptr< IHitParticleAssociations > fHitParticleAssociations
TCEvent evt
Definition: DataStructs.cxx:5
Float_t e
Definition: plot.C:34
void reconfigure(fhicl::ParameterSet const &p)