HitAnaPDSP_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: HitAnaPDSP
3 // Plugin Type: analyzer (art v3_02_06)
4 // File: HitAnaPDSP_module.cc
5 //
6 // Generated at Tue Aug 20 16:19:40 2019 by Tingjun Yang using cetskelgen
7 // from cetlib version v3_07_02.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 #include "art_root_io/TFileService.h"
20 
22 
23 #include "TTree.h"
24 
25 namespace pdsp {
26  class HitAnaPDSP;
27 }
28 
30 public:
31  explicit HitAnaPDSP(fhicl::ParameterSet const& p);
32  // The compiler-generated destructor is fine for non-base
33  // classes without bare pointers or other resource use.
34 
35  // Plugins should not be copied or assigned.
36  HitAnaPDSP(HitAnaPDSP const&) = delete;
37  HitAnaPDSP(HitAnaPDSP&&) = delete;
38  HitAnaPDSP& operator=(HitAnaPDSP const&) = delete;
39  HitAnaPDSP& operator=(HitAnaPDSP&&) = delete;
40 
41  // Required functions.
42  void analyze(art::Event const& e) override;
43 
44  // Selected optional functions.
45  void beginJob() override;
46 
47 private:
48 
50 
51  TTree *ftree;
52  int run;
53  int subrun;
54  int event;
55  std::vector<short> channel;
56  std::vector<short> tpc;
57  std::vector<short> plane;
58  std::vector<short> wire;
59  std::vector<double> charge;
60  std::vector<double> peakt;
61  std::vector<double> rms;
62  std::vector<double> startt;
63  std::vector<double> endt;
64  std::vector<short> origin;
65  std::vector<int> pdg;
66 };
67 
68 
70  : EDAnalyzer{p} ,
71  fHitModuleLabel(p.get< art::InputTag >("HitModuleLabel"))
72 {
73  // Call appropriate consumes<>() for any products to be retrieved by this module.
74 }
75 
77 {
78  run = e.run();
79  subrun = e.subRun();
80  event = e.id().event();
81  channel.clear();
82  tpc.clear();
83  plane.clear();
84  wire.clear();
85  charge.clear();
86  peakt.clear();
87  rms.clear();
88  startt.clear();
89  endt.clear();
90  origin.clear();
91  pdg.clear();
92 
93  // Reconstruciton information
94  std::vector < art::Ptr < recob::Hit > > hitList;
95  auto hitListHandle = e.getHandle < std::vector < recob::Hit > >(fHitModuleLabel);
96  if (hitListHandle) {
97  art::fill_ptr_vector(hitList, hitListHandle);
98  }
99  else return;
100 
101  for (auto const & hit : hitList){
102  channel.push_back(hit->Channel());
103  tpc.push_back(hit->WireID().TPC);
104  plane.push_back(hit->WireID().Plane);
105  wire.push_back(hit->WireID().Wire);
106  charge.push_back(hit->Integral());
107  peakt.push_back(hit->PeakTime());
108  rms.push_back(hit->RMS());
109  startt.push_back(hit->StartTick());
110  endt.push_back(hit->EndTick());
111  }
112 
113  if (!channel.empty()) ftree->Fill();
114 
115 }
116 
118 {
119  art::ServiceHandle<art::TFileService> fileServiceHandle;
120  ftree = fileServiceHandle->make<TTree>("ftree", "hit info");
121  ftree->Branch("run", &run, "run/I");
122  ftree->Branch("event", &event, "event/I");
123  ftree->Branch("channel", &channel);
124  ftree->Branch("tpc", &tpc);
125  ftree->Branch("plane", &plane);
126  ftree->Branch("wire", &wire);
127  ftree->Branch("charge", &charge);
128  ftree->Branch("peakt", &peakt);
129  ftree->Branch("rms", &rms);
130  ftree->Branch("startt", &startt);
131  ftree->Branch("endt", &endt);
132  ftree->Branch("origin", &origin);
133  ftree->Branch("pdf", &pdg);
134 }
135 
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::vector< double > startt
std::vector< short > plane
HitAnaPDSP & operator=(HitAnaPDSP const &)=delete
HitAnaPDSP(fhicl::ParameterSet const &p)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::vector< short > channel
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::vector< short > tpc
p
Definition: test.py:223
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
std::vector< int > pdg
std::vector< double > charge
RunNumber_t run() const
Definition: DataViewImpl.cc:71
Detector simulation of raw signals on wires.
void analyze(art::Event const &e) override
Declaration of signal hit object.
std::vector< double > rms
EventNumber_t event() const
Definition: EventID.h:116
std::vector< short > origin
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
art::InputTag fHitModuleLabel
std::vector< short > wire
std::vector< double > peakt
EventID id() const
Definition: Event.cc:34
std::vector< double > endt
Event finding and building.
void beginJob() override