MVAPID_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file MVAPID_module.cc
4 //
5 // m.haigh@warwick.ac.uk
6 //
7 ///////////////////////////////////////////////////////////////////////
8 
9 // ### Generic C++ includes ###
10 
11 // ### Framework includes ###
12 #include "TTree.h"
16 #include "art_root_io/TFileService.h"
17 #include "fhiclcpp/fwd.h"
18 
19 #include "MVAAlg.h"
22 
23 namespace mvapid {
24 
25  class MVAPID : public art::EDProducer {
26 
27  public:
28  explicit MVAPID(fhicl::ParameterSet const& pset);
29  void beginJob();
30  void produce(art::Event& evt);
31 
32  private:
34  std::vector<anab::MVAPIDResult>* fResult;
35  unsigned int fRun, fSubrun, fEvent;
36  TTree* fTree;
37 
38  }; // class MVAPID
39 
40  //------------------------------------------------------------------------------
41  MVAPID::MVAPID(fhicl::ParameterSet const& pset) : EDProducer{pset}, fAlg(pset)
42  {
43  produces<std::vector<anab::MVAPIDResult>>();
44  produces<art::Assns<recob::Track, anab::MVAPIDResult, void>>();
45  produces<art::Assns<recob::Shower, anab::MVAPIDResult, void>>();
46  fResult = new std::vector<anab::MVAPIDResult>;
47  }
48 
49  // ***************** //
50  void
52  {
54  fTree =
55  tfs->make<TTree>("MVAPID", "Results"); /**All-knowing tree with reconstruction information*/
56  fTree->Branch("run", &fRun, "run/I");
57  fTree->Branch("subrun", &fSubrun, "subrun/I");
58  fTree->Branch("event", &fEvent, "event/I");
59  fTree->Branch("MVAResult", &fResult);
62  }
63 
64  // ***************** //
65  void
67  {
68  std::unique_ptr<std::vector<anab::MVAPIDResult>> result(new std::vector<anab::MVAPIDResult>);
69  std::unique_ptr<art::Assns<recob::Track, anab::MVAPIDResult>> trackAssns(
71  std::unique_ptr<art::Assns<recob::Shower, anab::MVAPIDResult>> showerAssns(
73  fRun = evt.id().run();
74  fSubrun = evt.id().subRun();
75  fEvent = evt.id().event();
76  fAlg.RunPID(evt, *result, *trackAssns, *showerAssns);
77  *fResult = *result;
78  fTree->Fill();
79  evt.put(std::move(result));
80  evt.put(std::move(trackAssns));
81  evt.put(std::move(showerAssns));
82  }
83 
85 
86 } //namespace mvapid
MVAPID(fhicl::ParameterSet const &pset)
static QCString result
unsigned int fSubrun
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void RunPID(art::Event &evt, std::vector< anab::MVAPIDResult > &result, art::Assns< recob::Track, anab::MVAPIDResult, void > &trackAssns, art::Assns< recob::Shower, anab::MVAPIDResult, void > &showerAssns)
Definition: MVAAlg.cxx:137
RunNumber_t run() const
Definition: EventID.h:98
Definition: MVAAlg.h:36
unsigned int fRun
void GetDetectorEdges()
Definition: MVAAlg.cxx:81
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
void GetWireNormals()
Definition: MVAAlg.cxx:104
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
unsigned int fEvent
Provides recob::Track data product.
EventNumber_t event() const
Definition: EventID.h:116
void produce(art::Event &evt)
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< anab::MVAPIDResult > * fResult
SubRunNumber_t subRun() const
Definition: EventID.h:110
EventID id() const
Definition: Event.cc:34