LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
9 extern "C" {
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 }
13 #include <iostream>
14 
19 
20 // ROOT includes
21 #include "TFile.h"
22 #include "TProfile.h"
23 
24 // Framework includes
29 #include "fhiclcpp/ParameterSet.h"
37 
38 #ifndef PID_CHI2PARTICLEID_H
39 #define PID_CHI2PARTICLEID_H
40 
41 namespace pid {
42  class Chi2ParticleID;
43 }
44 
46 public:
47  explicit Chi2ParticleID(fhicl::ParameterSet const & p);
48  virtual ~Chi2ParticleID();
49 
50  void reconfigure(fhicl::ParameterSet const& p);
51 
52  virtual void produce(art::Event & e);
53 
54 private:
55 
56  std::string fTrackModuleLabel;
58 
60 
61 };
62 #endif /* PID_CHI2PARTICLEID_H */
63 
65  : fChiAlg(p.get< fhicl::ParameterSet >("Chi2PIDAlg"))
66 {
67  this->reconfigure(p);
68  produces< std::vector<anab::ParticleID> >();
69  produces< art::Assns<recob::Track, anab::ParticleID> >();
70 }
71 
73 {
74 }
75 
77 {
78  fTrackModuleLabel = p.get< std::string >("TrackModuleLabel");
79  fCalorimetryModuleLabel = p.get< std::string >("CalorimetryModuleLabel");
80  fChiAlg.reconfigure(p.get< fhicl::ParameterSet >("Chi2PIDAlg"));
81 }
82 
84 {
86  evt.getByLabel(fTrackModuleLabel,trackListHandle);
87 
88  std::vector<art::Ptr<recob::Track> > tracklist;
89  art::fill_ptr_vector(tracklist, trackListHandle);
90 
92 
93  //if (!fmcal.isValid()) return;
94 
95  std::unique_ptr< std::vector<anab::ParticleID> > particleidcol(new std::vector<anab::ParticleID>);
96  std::unique_ptr< art::Assns<recob::Track, anab::ParticleID> > assn(new art::Assns<recob::Track, anab::ParticleID>);
97 
98  if (fmcal.isValid()) {
99  for (size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter){
100  for (size_t i = 0; i<fmcal.at(trkIter).size(); ++i){
101  anab::ParticleID pidout;
102  fChiAlg.DoParticleID(fmcal.at(trkIter)[i],pidout);
103  particleidcol->push_back(pidout);
104  util::CreateAssn(*this, evt, *particleidcol, tracklist[trkIter], *assn);
105  }
106  }
107  }
108  evt.put(std::move(particleidcol));
109  evt.put(std::move(assn));
110 
111  return;
112 
113 }
114 
116 // Class: Chi2ParticleID
117 // Module Type: producer
118 // File: Chi2ParticleID_module.cc
119 //
120 // Generated at Fri Jul 13 16:06:02 2012 by Tingjun Yang using artmod
121 // from art v1_00_11.
123 
124 
Chi2ParticleID(fhicl::ParameterSet const &p)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void reconfigure(fhicl::ParameterSet const &p)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
void reconfigure(fhicl::ParameterSet const &pset)
Definition: Chi2PIDAlg.cxx:46
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TCEvent evt
Definition: DataStructs.cxx:5
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:34
virtual void produce(art::Event &e)
void DoParticleID(art::Ptr< anab::Calorimetry > calo, anab::ParticleID &pidOut)
Definition: Chi2PIDAlg.cxx:73