All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
13 #include "art/Framework/Core/EDProducer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 #include "art_root_io/TFileService.h"
18 
19 #include "MVAAlg.h"
23 
24 namespace mvapid {
25 
26  class MVAPID : public art::EDProducer {
27 
28  public:
29  explicit MVAPID(fhicl::ParameterSet const& pset);
30  void beginJob();
31  void produce(art::Event& evt);
32 
33  private:
35  std::vector<anab::MVAPIDResult>* fResult;
36  unsigned int fRun, fSubrun, fEvent;
37  TTree* fTree;
38 
39  }; // class MVAPID
40 
41  //------------------------------------------------------------------------------
42  MVAPID::MVAPID(fhicl::ParameterSet const& pset) : EDProducer{pset}, fAlg(pset)
43  {
44  produces<std::vector<anab::MVAPIDResult>>();
45  produces<art::Assns<recob::Track, anab::MVAPIDResult, void>>();
46  produces<art::Assns<recob::Shower, anab::MVAPIDResult, void>>();
47  fResult = new std::vector<anab::MVAPIDResult>;
48  }
49 
50  // ***************** //
51  void
53  {
54  art::ServiceHandle<art::TFileService const> tfs;
55  fTree =
56  tfs->make<TTree>("MVAPID", "Results"); /**All-knowing tree with reconstruction information*/
57  fTree->Branch("run", &fRun, "run/I");
58  fTree->Branch("subrun", &fSubrun, "subrun/I");
59  fTree->Branch("event", &fEvent, "event/I");
60  fTree->Branch("MVAResult", &fResult);
63  }
64 
65  // ***************** //
66  void
67  MVAPID::produce(art::Event& evt)
68  {
69  std::unique_ptr<std::vector<anab::MVAPIDResult>> result(new std::vector<anab::MVAPIDResult>);
70  std::unique_ptr<art::Assns<recob::Track, anab::MVAPIDResult>> trackAssns(
71  new art::Assns<recob::Track, anab::MVAPIDResult>);
72  std::unique_ptr<art::Assns<recob::Shower, anab::MVAPIDResult>> showerAssns(
73  new art::Assns<recob::Shower, anab::MVAPIDResult>);
74  fRun = evt.id().run();
75  fSubrun = evt.id().subRun();
76  fEvent = evt.id().event();
77  fAlg.RunPID(evt, *result, *trackAssns, *showerAssns);
78  *fResult = *result;
79  fTree->Fill();
80  evt.put(std::move(result));
81  evt.put(std::move(trackAssns));
82  evt.put(std::move(showerAssns));
83  }
84 
85  DEFINE_ART_MODULE(MVAPID)
86 
87 } //namespace mvapid
MVAPID(fhicl::ParameterSet const &pset)
unsigned int fSubrun
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:147
unsigned int fRun
void GetDetectorEdges()
Definition: MVAAlg.cxx:91
void GetWireNormals()
Definition: MVAAlg.cxx:114
Provides recob::Track data product.
unsigned int fEvent
void produce(art::Event &evt)
art::ServiceHandle< art::TFileService > tfs
TCEvent evt
Definition: DataStructs.cxx:8
std::vector< anab::MVAPIDResult > * fResult