MCParticleHitMatching_module.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 /// Class: MCParticleHitMatching
3 /// Module Type: producer
4 /// File: MCParticleHitMatching_module.cc
5 ///
6 /// Author: Wesley Ketchum and Yun-Tse Tsai
7 /// E-mail address: wketchum@fnal.gov and yuntse@stanford.edu
8 ///
9 /// This module uses the larsoft backtracker to match hits to truth-level
10 /// MCParticles (from LArG4 output). It originated from MCTruthT0Matching
11 /// module, and follows a similar strategy. All MCParticles matching the hit
12 /// are associated, with information on the amount of contributing energy and
13 /// number of electrons stored in assn metadata.
14 ///
15 /// Input: MCParticles (via Backtracker) and recob::Hit collection
16 /// Output: recob::Hit/simb::MCParticle assns, with BackTrackerHitMatchingData.
17 ///
18 /////////////////////////////////////////////////////////////////////////////
19 
20 // Framework includes
25 #include "fhiclcpp/ParameterSet.h"
26 
27 #include <memory>
28 
29 // LArSoft
31 
32 namespace t0 {
33  class MCParticleHitMatching;
34 
36 {
37 public:
39  // The destructor generated by the compiler is fine for classes
40  // without bare pointers or other resource use.
41 
42  // Plugins should not be copied or assigned.
47 
48 private:
49  // Required functions.
50  void produce(art::Event & e) override;
51 
52  // For keeping track of the replacement backtracker
53  std::unique_ptr<IHitParticleAssociations> fHitParticleAssociations;
54  bool fOverrideRealData; ///< if real data, tell it to run anyway (=0)
55 };
56 
57 
59  : EDProducer{pset}
60 {
61  // Get the tool for MC Truth matching
62  //const fhicl::ParameterSet& hitPartAssnsParams = pset.get<fhicl::ParameterSet>("HitParticleAssociations"); // unused
63 
64  fOverrideRealData = pset.get<bool>("OverrideRealData", false);
65 
66  // Get the tool for MC Truth matching
67  fHitParticleAssociations = art::make_tool<IHitParticleAssociations>(pset.get<fhicl::ParameterSet>("HitParticleAssociations"));
68 
69  produces<HitParticleAssociations> ();
70 }
71 
73 {
74  if(evt.isRealData() && !fOverrideRealData) return;
75 
76  std::unique_ptr<HitParticleAssociations> MCPartHitassn( new HitParticleAssociations);
77 
78  fHitParticleAssociations->CreateHitParticleAssociations(evt, MCPartHitassn.get());
79 
80  evt.put(std::move(MCPartHitassn));
81 } // Produce
82 
84 } // end namespace
MCParticleHitMatching(fhicl::ParameterSet const &p)
code to link reconstructed objects back to the MC truth information
MCParticleHitMatching & operator=(MCParticleHitMatching const &)=delete
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
bool fOverrideRealData
if real data, tell it to run anyway (=0)
void produce(art::Event &e) override
bool isRealData() const
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::unique_ptr< IHitParticleAssociations > fHitParticleAssociations
TCEvent evt
Definition: DataStructs.cxx:7