All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCSFitAllPID_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: MCSFitAllPID
3 // Plugin Type: producer (art v3_02_06)
4 // File: MCSFitAllPID_module.cc
5 //
6 // Generated at Wed Feb 19 17:38:15 2020 by Gray Putnam using cetskelgen
7 // from cetlib version v3_07_02.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
20 
21 #include "LArReco/TrajectoryMCSFitter.h"
22 
23 #include <memory>
24 
25 namespace sbn {
26  class MCSFitAllPID;
27 }
28 
29 
30 class sbn::MCSFitAllPID : public art::EDProducer {
31 public:
32  explicit MCSFitAllPID(fhicl::ParameterSet const& p);
33  // The compiler-generated destructor is fine for non-base
34  // classes without bare pointers or other resource use.
35 
36  // Plugins should not be copied or assigned.
37  MCSFitAllPID(MCSFitAllPID const&) = delete;
38  MCSFitAllPID(MCSFitAllPID&&) = delete;
39  MCSFitAllPID& operator=(MCSFitAllPID const&) = delete;
40  MCSFitAllPID& operator=(MCSFitAllPID&&) = delete;
41 
42  // Required functions.
43  void produce(art::Event& e) override;
44 
45 private:
46 
48  art::InputTag fTrackLabel;
50 };
51 
52 const static std::vector<int> PIDs {13, 211, 321, 2212};
53 const static std::vector<std::string> names {"muon", "pion", "kaon", "proton"};
54 
55 sbn::MCSFitAllPID::MCSFitAllPID(fhicl::ParameterSet const& p)
56  : EDProducer{p},
57  // fMCSCalculator(p.get<fhicl::Table<trkf::TrajectoryMCSFitter::Config>>("MCS")),
58  fMCSCalculator(p.get<fhicl::ParameterSet>("MCS")),
59  fTrackLabel(p.get<art::InputTag>("TrackLabel", "pandoraTrack")),
60  fMinTrackLength(p.get<float>("MinTrackLength", 10.))
61 {
62  for (unsigned i = 0; i < names.size(); i++) {
63  produces<std::vector<recob::MCSFitResult>>(names[i]);
64  produces<art::Assns<recob::Track, recob::MCSFitResult>>(names[i]);
65  }
66 }
67 
68 void sbn::MCSFitAllPID::produce(art::Event& e)
69 {
70 
71  // Implementation of required member function here.
72  art::Handle<std::vector<recob::Track>> track_handle;
73  e.getByLabel(fTrackLabel, track_handle);
74 
75  std::vector<art::Ptr<recob::Track>> tracks;
76  art::fill_ptr_vector(tracks, track_handle);
77 
78  for (unsigned i = 0; i < PIDs.size(); i++) {
79  std::unique_ptr<std::vector<recob::MCSFitResult>> mcscol(new std::vector<recob::MCSFitResult>);
80  std::unique_ptr<art::Assns<recob::Track, recob::MCSFitResult>> assn(new art::Assns<recob::Track, recob::MCSFitResult>);
81 
82  for (const art::Ptr<recob::Track> track: tracks) {
83  if (fMinTrackLength > 0. && track->Length() < fMinTrackLength) continue;
84 
85  mcscol->push_back(fMCSCalculator.fitMcs(*track, PIDs[i]));
86  util::CreateAssn(*this, e, *mcscol, track, *assn, names[i]);
87  }
88 
89  e.put(std::move(mcscol), names[i]);
90  e.put(std::move(assn), names[i]);
91  }
92 
93 }
94 
95 DEFINE_ART_MODULE(sbn::MCSFitAllPID)
ClusterModuleLabel join with tracks
pdgs p
Definition: selectors.fcl:22
trkf::sbn::TrajectoryMCSFitter fMCSCalculator
process_name use argoneut_mc_hitfinder track
MCSFitAllPID(fhicl::ParameterSet const &p)
static const std::vector< int > PIDs
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.
static const std::vector< std::string > names
void produce(art::Event &e) override
art::InputTag fTrackLabel
do i e
MCSFitAllPID & operator=(MCSFitAllPID const &)=delete