AnalysisModule_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: AnalysisModule
3 // Module Type: analyzer
4 // File: AnalysisModule_module.cc
5 //
6 // Generated at Tue Jun 6 14:10:23 2017 by Justin Vasel using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 
10 // Framework includes
19 #include "fhiclcpp/ParameterSet.h"
21 
22 // NOvASoft includes
23 #include "RawData/RawDigit.h"
24 
25 // ROOT includes
26 #include <TTree.h>
27 
28 
29 namespace tut {
30  namespace yn2017 {
31  class AnalysisModule;
32  }
33 }
34 
36 public:
37  explicit AnalysisModule(fhicl::ParameterSet const & p);
38 
39  AnalysisModule(AnalysisModule const &) = delete;
40  AnalysisModule(AnalysisModule &&) = delete;
41  AnalysisModule & operator = (AnalysisModule const &) = delete;
43 
44  // Required functions.
45  void analyze(art::Event const & e) override;
46 
47  // Selected optional functions.
48  void beginJob() override;
49  void endJob() override;
50 
51 private:
52  unsigned int fRun; ///< Run number
53  unsigned int fSubRun; ///< Subrun number
54  unsigned int fEvent; ///< Event number
55 
56  unsigned int fRawADC; ///< Raw ADC value to be written into TTree
57 
58  std::string fRawDataLabel; ///< ART module label for Raw Data
59 
60  // This ART Service allows us to interact with TFiles on disk.
62  TTree* fRawDigitTree;
63 };
64 
65 
67  :
68  EDAnalyzer(p),
69  fRun(0),
70  fSubRun(0),
71  fEvent(0),
72  fRawADC(0),
73  fRawDataLabel(p.get<std::string>("RawDataLabel"))
74 {}
75 
77 {
78  // ART gives us access to some basic information from the event, like
79  // the run, subrun, and event numbers. Let's grab those:
80  fRun = e.run();
81  fSubRun = e.subRun();
82  fEvent = e.event();
83 
84  // Get the RawDigits from the event
86  e.getByLabel(fRawDataLabel, rawHits);
87 
88  // How many are there in this event?
89  std::cout << rawHits->size() << " RawDigits in this event." << std::endl;
90 
91  // Now I have a rawdata::RawDigit vector and I can do whatever I want with it.
92  // let's loop over them all and get the ADC.
93  for (rawdata::RawDigit aDigit : *rawHits) {
94  fRawADC = aDigit.ADC();
95 
96  // Now I could print out the value, or I could write it into a TTree or
97  // something
98  std::cout << "ADC = " << fRawADC << std::endl;
99  fRawDigitTree->Fill();
100  }
101 }
102 
104 {
105  fRawDigitTree = tfs->make<TTree>("RawDigits", "Raw Digits");
106 
107  fRawDigitTree->Branch("Run", &fRun);
108  fRawDigitTree->Branch("SubRun", &fSubRun);
109  fRawDigitTree->Branch("Event", &fEvent);
110  fRawDigitTree->Branch("ADC", &fRawADC);
111 }
112 
114 {
115  // Implementation of optional member function here.
116 }
117 
118 // Here be dragons...
SubRunNumber_t subRun() const
Definition: Event.h:72
art::ServiceHandle< art::TFileService > tfs
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
unsigned int fEvent
Event number.
std::string fRawDataLabel
ART module label for Raw Data.
AnalysisModule & operator=(AnalysisModule const &)=delete
AnalysisModule(fhicl::ParameterSet const &p)
unsigned int fSubRun
Subrun number.
void analyze(art::Event const &e) override
TODO.
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
unsigned int fRawADC
Raw ADC value to be written into TTree.
unsigned int fRun
Run number.
enum BeamMode string