Chi2ParticleID_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // \brief A chisq-test based particle identification method using calorimetry information
4 //
5 // \author tjyang@fnal.gov
6 //
7 ////////////////////////////////////////////////////////////////////////////
8 
13 
14 // Framework includes
20 #include "canvas/Persistency/Common/FindManyP.h"
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 
38 
40 
41 };
42 
44  : EDProducer{p}
45  , fChiAlg(p.get< fhicl::ParameterSet >("Chi2PIDAlg"))
46 {
47  fTrackModuleLabel = p.get< std::string >("TrackModuleLabel");
48  fCalorimetryModuleLabel = p.get< std::string >("CalorimetryModuleLabel");
49 
50  produces< std::vector<anab::ParticleID> >();
51  produces< art::Assns<recob::Track, anab::ParticleID> >();
52 }
53 
55 {
57  evt.getByLabel(fTrackModuleLabel,trackListHandle);
58 
59  std::vector<art::Ptr<recob::Track> > tracklist;
60  art::fill_ptr_vector(tracklist, trackListHandle);
61 
62  art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
63 
64  //if (!fmcal.isValid()) return;
65 
66  std::unique_ptr< std::vector<anab::ParticleID> > particleidcol(new std::vector<anab::ParticleID>);
67  std::unique_ptr< art::Assns<recob::Track, anab::ParticleID> > assn(new art::Assns<recob::Track, anab::ParticleID>);
68 
69  if (fmcal.isValid()) {
70  std::vector<art::Ptr<anab::Calorimetry>> calovec(1, art::Ptr<anab::Calorimetry>());
71  for (size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter){
72  for (size_t i = 0; i<fmcal.at(trkIter).size(); ++i){
73  calovec[0] = fmcal.at(trkIter)[i];
74  anab::ParticleID pidout = fChiAlg.DoParticleID(calovec);
75  particleidcol->push_back(pidout);
76  util::CreateAssn(*this, evt, *particleidcol, tracklist[trkIter], *assn);
77  }
78  }
79  }
80  evt.put(std::move(particleidcol));
81  evt.put(std::move(assn));
82 
83  return;
84 
85 }
86 
87 ////////////////////////////////////////////////////////////////////////
88 // Class: Chi2ParticleID
89 // Module Type: producer
90 // File: Chi2ParticleID_module.cc
91 //
92 // Generated at Fri Jul 13 16:06:02 2012 by Tingjun Yang using artmod
93 // from art v1_00_11.
94 ////////////////////////////////////////////////////////////////////////
95 
96 
Chi2ParticleID(fhicl::ParameterSet const &p)
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
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
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.
anab::ParticleID DoParticleID(const std::vector< art::Ptr< anab::Calorimetry >> &calo)
Definition: Chi2PIDAlg.cxx:61
Provides recob::Track data product.
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
virtual void produce(art::Event &e)
Definition: fwd.h:31