LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Chi2ParticleID_module.cc
Go to the documentation of this file.
1 //
3 // \brief A chisq-test based particle identification method using calorimetry information
4 //
5 // \author tjyang@fnal.gov
6 //
8 
13 
14 // Framework includes
22 #include "fhiclcpp/ParameterSet.h"
23 
24 namespace pid {
25  class Chi2ParticleID;
26 }
27 
29 public:
30  explicit Chi2ParticleID(fhicl::ParameterSet const& p);
31 
32  virtual void produce(art::Event& e);
33 
34 private:
35  std::string fTrackModuleLabel;
37 
39 };
40 
42  : EDProducer{p}, fChiAlg(p.get<fhicl::ParameterSet>("Chi2PIDAlg"))
43 {
44  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
45  fCalorimetryModuleLabel = p.get<std::string>("CalorimetryModuleLabel");
46 
47  produces<std::vector<anab::ParticleID>>();
48  produces<art::Assns<recob::Track, anab::ParticleID>>();
49 }
50 
52 {
54  evt.getByLabel(fTrackModuleLabel, trackListHandle);
55 
56  std::vector<art::Ptr<recob::Track>> tracklist;
57  art::fill_ptr_vector(tracklist, trackListHandle);
58 
60 
61  //if (!fmcal.isValid()) return;
62 
63  std::unique_ptr<std::vector<anab::ParticleID>> particleidcol(new std::vector<anab::ParticleID>);
64  std::unique_ptr<art::Assns<recob::Track, anab::ParticleID>> assn(
66 
67  if (fmcal.isValid()) {
68  std::vector<art::Ptr<anab::Calorimetry>> calovec(1, art::Ptr<anab::Calorimetry>());
69  for (size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter) {
70  for (size_t i = 0; i < fmcal.at(trkIter).size(); ++i) {
71  calovec[0] = fmcal.at(trkIter)[i];
72  anab::ParticleID pidout = fChiAlg.DoParticleID(calovec);
73  particleidcol->push_back(pidout);
74  util::CreateAssn(evt, *particleidcol, tracklist[trkIter], *assn);
75  }
76  }
77  }
78  evt.put(std::move(particleidcol));
79  evt.put(std::move(assn));
80 
81  return;
82 }
83 
85 // Class: Chi2ParticleID
86 // Module Type: producer
87 // File: Chi2ParticleID_module.cc
88 //
89 // Generated at Fri Jul 13 16:06:02 2012 by Tingjun Yang using artmod
90 // from art v1_00_11.
92 
Chi2ParticleID(fhicl::ParameterSet const &p)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
Provides recob::Track data product.
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
anab::ParticleID DoParticleID(const std::vector< art::Ptr< anab::Calorimetry >> &calo)
Definition: Chi2PIDAlg.cxx:62
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
Float_t e
Definition: plot.C:35
virtual void produce(art::Event &e)
Definition: fwd.h:26