CheckAuxDet_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: CheckAuxDet
3 // Module Type: analyzer
4 // File: CheckAuxDet_module.cc
5 //
6 // Generated at Tue Jan 6 22:27:12 2015 by Tingjun Yang using artmod
7 // from cetpkgsupport v1_07_00.
8 ////////////////////////////////////////////////////////////////////////
9 
16 #include "art_root_io/TFileService.h"
18 #include "fhiclcpp/ParameterSet.h"
21 #include "TTree.h"
22 #include <iostream>
23 
24 constexpr unsigned short kMaxAuxDets = 100;
25 constexpr unsigned short kMaxTkIDs = 100;
26 
27 namespace dune {
28  class CheckAuxDet;
29 }
30 
32 public:
33  explicit CheckAuxDet(fhicl::ParameterSet const & p);
34  // The destructor generated by the compiler is fine for classes
35  // without bare pointers or other resource use.
36 
37  // Plugins should not be copied or assigned.
38  CheckAuxDet(CheckAuxDet const &) = delete;
39  CheckAuxDet(CheckAuxDet &&) = delete;
40  CheckAuxDet & operator = (CheckAuxDet const &) = delete;
41  CheckAuxDet & operator = (CheckAuxDet &&) = delete;
42 
43  // Required functions.
44  void analyze(art::Event const & e) override;
45 
46  // Selected optional functions.
47  void beginJob() override;
48  void reconfigure(fhicl::ParameterSet const & p) ;
49 
50 private:
51 
52  // Declare member data here.
54  TTree *fTree;
55  //run information
56  int run;
57  int subrun;
58  int event;
59  int nauxdets;
75 
76  void ResetVars();
77 
78 };
79 
80 
82  :
83  EDAnalyzer(p),
84  fLArG4ModuleLabel(p.get< std::string >("LArGeantModuleLabel", "largeant"))
85 {}
86 
88 {
89  ResetVars();
90 
91  run = evt.run();
92  subrun = evt.subRun();
93  event = evt.id().event();
94 
95  std::vector<const sim::AuxDetSimChannel*> fAuxDetSimChannels;
96  evt.getView(fLArG4ModuleLabel, fAuxDetSimChannels);
97 
98  nauxdets = fAuxDetSimChannels.size();
99 
100  for (size_t i = 0; i<fAuxDetSimChannels.size(); ++i){
101  const sim::AuxDetSimChannel* c = fAuxDetSimChannels[i];
102  auxdetid[i] = c->AuxDetID();
103 
104  const std::vector<sim::AuxDetIDE>& setOfIDEs = c->AuxDetIDEs();
105  ntrkids[i] = setOfIDEs.size();
106 
107  for (size_t j = 0; j<setOfIDEs.size(); ++j){
108  entryx[i][j] = setOfIDEs[j].entryX;
109  entryy[i][j] = setOfIDEs[j].entryY;
110  entryz[i][j] = setOfIDEs[j].entryZ;
111  entryt[i][j] = setOfIDEs[j].entryT;
112  exitx[i][j] = setOfIDEs[j].exitX;
113  exity[i][j] = setOfIDEs[j].exitY;
114  exitz[i][j] = setOfIDEs[j].exitZ;
115  exitt[i][j] = setOfIDEs[j].exitT;
116  exitpx[i][j] = setOfIDEs[j].exitMomentumX;
117  exitpy[i][j] = setOfIDEs[j].exitMomentumY;
118  exitpz[i][j] = setOfIDEs[j].exitMomentumZ;
119  energy[i][j] = setOfIDEs[j].energyDeposited;
120  trackid[i][j] = setOfIDEs[j].trackID;
121  }
122  }
123  fTree->Fill();
124 }
125 
127 {
129  fTree = tfs->make<TTree>("anatree","analysis tree");
130  fTree->Branch("run",&run,"run/I");
131  fTree->Branch("subrun",&subrun,"subrun/I");
132  fTree->Branch("event",&event,"event/I");
133  fTree->Branch("nauxdets",&nauxdets,"nauxdets/I");
134  fTree->Branch("auxdetid",auxdetid,"auxdetid[nauxdets]/I");
135  fTree->Branch("ntrkids",ntrkids,"ntrkids[nauxdets]/I");
136  fTree->Branch("entryx",entryx,"entryx[nauxdets][100]/F");
137  fTree->Branch("entryy",entryy,"entryy[nauxdets][100]/F");
138  fTree->Branch("entryz",entryz,"entryz[nauxdets][100]/F");
139  fTree->Branch("entryt",entryt,"entryt[nauxdets][100]/F");
140  fTree->Branch("exitx",exitx,"exitx[nauxdets][100]/F");
141  fTree->Branch("exity",exity,"exity[nauxdets][100]/F");
142  fTree->Branch("exitz",exitz,"exitz[nauxdets][100]/F");
143  fTree->Branch("exitt",exitt,"exitt[nauxdets][100]/F");
144  fTree->Branch("trackid",trackid,"trackid[nauxdets][100]/I");
145  fTree->Branch("energy",energy,"energy[nauxdets][100]/F");
146 
147 }
148 
150 {
151  // Implementation of optional member function here.
152 }
153 
155 
156  run = -99999;
157  subrun = -99999;
158  event = -99999;
159  for (size_t i = 0; i<kMaxAuxDets; ++i){
160  auxdetid[i] = -99999;
161  ntrkids[i] = -99999;
162  for (size_t j = 0; j<kMaxTkIDs; ++j){
163  entryx[i][j] = -99999;
164  entryy[i][j] = -99999;
165  entryz[i][j] = -99999;
166  entryt[i][j] = -99999;
167  exitx[i][j] = -99999;
168  exity[i][j] = -99999;
169  exitz[i][j] = -99999;
170  exitt[i][j] = -99999;
171  exitpx[i][j] = -99999;
172  exitpy[i][j] = -99999;
173  exitpz[i][j] = -99999;
174  trackid[i][j] = -99999;
175  energy[i][j] = -99999;
176  }
177  }
178 }
179 
constexpr unsigned short kMaxTkIDs
float exitt[kMaxAuxDets][kMaxTkIDs]
float entryt[kMaxAuxDets][kMaxTkIDs]
float entryx[kMaxAuxDets][kMaxTkIDs]
std::string string
Definition: nybbler.cc:12
STL namespace.
std::string fLArG4ModuleLabel
float entryz[kMaxAuxDets][kMaxTkIDs]
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
void analyze(art::Event const &e) override
float exity[kMaxAuxDets][kMaxTkIDs]
float entryy[kMaxAuxDets][kMaxTkIDs]
float exitpy[kMaxAuxDets][kMaxTkIDs]
Collection of particles crossing one auxiliary detector cell.
const double e
uint32_t AuxDetID() const
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
int auxdetid[kMaxAuxDets]
std::vector< sim::AuxDetIDE > const & AuxDetIDEs() const
p
Definition: test.py:223
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
RunNumber_t run() const
Definition: DataViewImpl.cc:71
float exitpz[kMaxAuxDets][kMaxTkIDs]
CheckAuxDet & operator=(CheckAuxDet const &)=delete
float exitpx[kMaxAuxDets][kMaxTkIDs]
void beginJob() override
CheckAuxDet(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &p)
int trackid[kMaxAuxDets][kMaxTkIDs]
EventNumber_t event() const
Definition: EventID.h:116
float energy[kMaxAuxDets][kMaxTkIDs]
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
float exitx[kMaxAuxDets][kMaxTkIDs]
float exitz[kMaxAuxDets][kMaxTkIDs]
int ntrkids[kMaxAuxDets]
EventID id() const
Definition: Event.cc:34
constexpr unsigned short kMaxAuxDets
Event finding and building.