protoDUNE_dEdx_calib.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////
2 // This class has been automatically generated on
3 // Thu Sep 17 22:06:49 2020 by ROOT version 6.18/04
4 // from TTree Event/Event Tree from Reco
5 // found on file: /dune/data2/users/apaudel/RITcalibration/RITcalib.root
6 //////////////////////////////////////////////////////////
7 
8 #ifndef protoDUNE_dEdx_calib_h
9 #define protoDUNE_dEdx_calib_h
10 
11 #include <TROOT.h>
12 #include <TChain.h>
13 #include <TFile.h>
14 #include <TH3F.h>
15 #include "fhiclcpp/ParameterSet.h"
16 
17 // Header file for the classes stored in the TTree if any.
18 
20  public :
21  TTree *fChain; //!pointer to the analyzed TTree or TChain
22  Int_t fCurrent; //!current Tree number in a TChain
23 
24  // Fixed size dimensions of array or collections stored in the TTree if any.
25 
26  // Declaration of leaf types
27  Int_t event;
28  Double_t evttime;
29  Int_t run;
30  Int_t subrun;
32  Int_t hour_min_sec;
33  Int_t cross_trks;
35  Int_t all_trks;
37  Float_t trackthetaxz[30]; //[cross_trks]
38  Float_t trackthetayz[30]; //[cross_trks]
39  Float_t trkstartx[30]; //[cross_trks]
40  Float_t trkstarty[30]; //[cross_trks]
41  Float_t trkstartz[30]; //[cross_trks]
42  Float_t trkendx[30]; //[cross_trks]
43  Float_t trkendy[30]; //[cross_trks]
44  Float_t trkendz[30]; //[cross_trks]
45  Float_t trklen[30]; //[cross_trks]
46  Float_t peakT_max[30]; //[cross_trks]
47  Float_t peakT_min[30]; //[cross_trks]
48  Int_t TrkID[30]; //[cross_trks]
49  Float_t trkstartcosxyz[30][3]; //[cross_trks]
50  Float_t trkendcosxyz[30][3]; //[cross_trks]
51  Int_t ntrkhits[30][3]; //[cross_trks]
52  Float_t trkdqdx[30][3][3000]; //[cross_trks]
53  Float_t trkdedx[30][3][3000]; //[cross_trks]
54  Float_t trkresrange[30][3][3000]; //[cross_trks]
55  Float_t trkhitx[30][3][3000]; //[cross_trks]
56  Float_t trkhity[30][3][3000]; //[cross_trks]
57  Float_t trkhitz[30][3][3000]; //[cross_trks]
58  Float_t trkpitch[30][3][3000]; //[cross_trks]
59  Float_t dist_min[30]; //[cross_trks]
60  Int_t adjacent_hits[30]; //[cross_trks]
61  Int_t lastwire[30]; //[cross_trks]
62  Float_t lastpeakt[30]; //[cross_trks]
63  Int_t endtpc[30]; //[cross_trks]
64 
65  // List of branches
66  TBranch *b_event; //!
67  TBranch *b_evttime; //!
68  TBranch *b_run; //!
69  TBranch *b_surbrun; //!
70  TBranch *b_year_month_date; //!
71  TBranch *b_hour_min_sec; //!
72  TBranch *b_cross_trks; //!
73  TBranch *b_stopping_trks; //!
74  TBranch *b_all_trks; //!
75  TBranch *b_unbroken_trks; //!
76  TBranch *b_trackthetaxz; //!
77  TBranch *b_trackthetayz; //!
78  TBranch *b_trkstartx; //!
79  TBranch *b_trkstarty; //!
80  TBranch *b_trkstartz; //!
81  TBranch *b_trkendx; //!
82  TBranch *b_trkendy; //!
83  TBranch *b_trkendz; //!
84  TBranch *b_trklen; //!
85  TBranch *b_peakT_max; //!
86  TBranch *b_peakT_min; //!
87  TBranch *b_TrkID; //!
88  TBranch *b_trkstartcosxyz; //!
89  TBranch *b_trkendcosxyz; //!
90  TBranch *b_ntrkhits; //!
91  TBranch *b_trkdqdx; //!
92  TBranch *b_trkdedx; //!
93  TBranch *b_trkresrange; //!
94  TBranch *b_trkhitx; //!
95  TBranch *b_trkhity; //!
96  TBranch *b_trkhitz; //!
97  TBranch *b_trkpitch; //!
98  TBranch *b_dist_min; //!
99  TBranch *b_adjacent_hits; //!
100  TBranch *b_lastwire; //!
101  TBranch *b_lastpeakt; //!
102  TBranch *b_endtpc; //!
103 
104  protoDUNE_dEdx_calib(TTree *tree=0);
105  virtual ~protoDUNE_dEdx_calib();
106  virtual Int_t Cut(Long64_t entry);
107  virtual Int_t GetEntry(Long64_t entry);
108  virtual Long64_t LoadTree(Long64_t entry);
109  virtual void Init(TTree *tree);
110  virtual void Loop(int hitplane, double norm_factor, double calib_factor);
111  void LoopLite(std::vector<double> & norm_factors,
112  std::vector<std::vector<double>> & calib_factors,
113  TFile & outfile);
114  void LoopMIP(std::vector<double> & norm_factors,
115  std::vector<std::vector<double>> & calib_factors,
116  TFile & outfile);
117  virtual Bool_t Notify();
118  virtual void Show(Long64_t entry = -1);
119 
120  void GetEFMaps(TFile * ef);
121  void SetCaloMaps(const fhicl::ParameterSet & pset) {
122  std::string x_filename = pset.get<std::string>("XCaloFile");
123  fXFile = new TFile(x_filename.c_str(), "OPEN");
124  std::string yz_filename = pset.get<std::string>("YZCaloFile");
125  fYZFile = new TFile(yz_filename.c_str(), "OPEN");
126  };
127 
128  private:
129  //TFile * ef;
130  TH3F *xneg;
131  TH3F *yneg;
132  TH3F *zneg;
133  TH3F *xpos;
134  TH3F *ypos;
135  TH3F *zpos;
136  TFile * fXFile, * fYZFile;
137 
138  std::vector<TH3F*> pos_hists, neg_hists;
139 
140  float tot_Ef(float xval,float yval,float zval);
141 };
142 
143 #endif
144 
145 #ifdef protoDUNE_dEdx_calib_cxx
147 {
148  // if parameter tree is not specified (or zero), connect the file
149  // used to generate this class and read the Tree.
150  if (tree == 0) {
151 #ifdef SINGLE_TREE
152  // The following code should be used if you want this class to access
153  // a single tree instead of a chain
154  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("Memory Directory");
155  if (!f || !f->IsOpen()) {
156  f = new TFile("Memory Directory");
157  }
158  f->GetObject("michelremoving2/Event",tree);
159 
160 #else // SINGLE_TREE
161 
162  // The following code should be used if you want this class to access a chain
163  // of trees.
164  TChain * chain = new TChain("michelremoving2/Event","");
165 
166  chain->Add("/cshare/vol1/data/protodune/calib_files/sceon_files.root/michelremoving2/Event");
167 
168  tree = chain;
169 #endif // SINGLE_TREE
170 
171  }
172  Init(tree);
173 }
174 
175 
177 {
178  if (!fChain) return;
179  delete fChain->GetCurrentFile();
180 }
181 
183 {
184  // Read contents of entry.
185  if (!fChain) return 0;
186  return fChain->GetEntry(entry);
187 }
188 Long64_t protoDUNE_dEdx_calib::LoadTree(Long64_t entry)
189 {
190  // Set the environment to read one entry
191  if (!fChain) return -5;
192  Long64_t centry = fChain->LoadTree(entry);
193  if (centry < 0) return centry;
194  if (fChain->GetTreeNumber() != fCurrent) {
195  fCurrent = fChain->GetTreeNumber();
196  Notify();
197  }
198  return centry;
199 }
200 
201 void protoDUNE_dEdx_calib::Init(TTree *tree)
202 {
203  // The Init() function is called when the selector needs to initialize
204  // a new tree or chain. Typically here the branch addresses and branch
205  // pointers of the tree will be set.
206  // It is normally not necessary to make changes to the generated
207  // code, but the routine can be extended by the user if needed.
208  // Init() will be called many times when running on PROOF
209  // (once per file to be processed).
210 
211  // Set branch addresses and branch pointers
212  if (!tree) return;
213  fChain = tree;
214  fCurrent = -1;
215  fChain->SetMakeClass(1);
216 
217  fChain->SetBranchAddress("event", &event, &b_event);
218  fChain->SetBranchAddress("evttime", &evttime, &b_evttime);
219  fChain->SetBranchAddress("run", &run, &b_run);
220  fChain->SetBranchAddress("subrun", &subrun, &b_surbrun);
221  fChain->SetBranchAddress("year_month_date", &year_month_date, &b_year_month_date);
222  fChain->SetBranchAddress("hour_min_sec", &hour_min_sec, &b_hour_min_sec);
223  fChain->SetBranchAddress("cross_trks", &cross_trks, &b_cross_trks);
224  fChain->SetBranchAddress("stopping_trks", &stopping_trks, &b_stopping_trks);
225  fChain->SetBranchAddress("all_trks", &all_trks, &b_all_trks);
226  fChain->SetBranchAddress("unbroken_trks", &unbroken_trks, &b_unbroken_trks);
227  fChain->SetBranchAddress("trackthetaxz", trackthetaxz, &b_trackthetaxz);
228  fChain->SetBranchAddress("trackthetayz", trackthetayz, &b_trackthetayz);
229  fChain->SetBranchAddress("trkstartx", trkstartx, &b_trkstartx);
230  fChain->SetBranchAddress("trkstarty", trkstarty, &b_trkstarty);
231  fChain->SetBranchAddress("trkstartz", trkstartz, &b_trkstartz);
232  fChain->SetBranchAddress("trkendx", trkendx, &b_trkendx);
233  fChain->SetBranchAddress("trkendy", trkendy, &b_trkendy);
234  fChain->SetBranchAddress("trkendz", trkendz, &b_trkendz);
235  fChain->SetBranchAddress("trklen", trklen, &b_trklen);
236  fChain->SetBranchAddress("peakT_max", peakT_max, &b_peakT_max);
237  fChain->SetBranchAddress("peakT_min", peakT_min, &b_peakT_min);
238  fChain->SetBranchAddress("TrkID", TrkID, &b_TrkID);
239  fChain->SetBranchAddress("trkstartcosxyz", trkstartcosxyz, &b_trkstartcosxyz);
240  fChain->SetBranchAddress("trkendcosxyz", trkendcosxyz, &b_trkendcosxyz);
241  fChain->SetBranchAddress("ntrkhits", ntrkhits, &b_ntrkhits);
242  fChain->SetBranchAddress("trkdqdx", trkdqdx, &b_trkdqdx);
243  fChain->SetBranchAddress("trkdedx", trkdedx, &b_trkdedx);
244  fChain->SetBranchAddress("trkresrange", trkresrange, &b_trkresrange);
245  fChain->SetBranchAddress("trkhitx", trkhitx, &b_trkhitx);
246  fChain->SetBranchAddress("trkhity", trkhity, &b_trkhity);
247  fChain->SetBranchAddress("trkhitz", trkhitz, &b_trkhitz);
248  fChain->SetBranchAddress("trkpitch", trkpitch, &b_trkpitch);
249  fChain->SetBranchAddress("dist_min", dist_min, &b_dist_min);
250  fChain->SetBranchAddress("adjacent_hits", adjacent_hits, &b_adjacent_hits);
251  fChain->SetBranchAddress("lastwire", lastwire, &b_lastwire);
252  fChain->SetBranchAddress("lastpeakt", lastpeakt, &b_lastpeakt);
253  fChain->SetBranchAddress("endtpc", endtpc, &b_endtpc);
254  Notify();
255 }
256 
258 {
259  // The Notify() function is called when a new file is opened. This
260  // can be either for a new TTree in a TChain or when when a new TTree
261  // is started when using PROOF. It is normally not necessary to make changes
262  // to the generated code, but the routine can be extended by the
263  // user if needed. The return value is currently not used.
264 
265  return kTRUE;
266 }
267 
268 void protoDUNE_dEdx_calib::GetEFMaps(TFile * ef) {
269  xneg = (TH3F*)ef->Get("Reco_ElecField_X_Neg");
270  yneg = (TH3F*)ef->Get("Reco_ElecField_Y_Neg");
271  zneg = (TH3F*)ef->Get("Reco_ElecField_Z_Neg");
272  xpos = (TH3F*)ef->Get("Reco_ElecField_X_Pos");
273  ypos = (TH3F*)ef->Get("Reco_ElecField_Y_Pos");
274  zpos = (TH3F*)ef->Get("Reco_ElecField_Z_Pos");
275 
276  pos_hists = {xpos, ypos, zpos};
277  neg_hists = {xneg, yneg, zneg};
278 }
279 
280 void protoDUNE_dEdx_calib::Show(Long64_t entry)
281 {
282  // Print contents of entry.
283  // If entry is not specified, print current entry
284  if (!fChain) return;
285  fChain->Show(entry);
286 }
287 Int_t protoDUNE_dEdx_calib::Cut(Long64_t entry)
288 {
289  // This function may be called from Loop.
290  // returns 1 if entry is accepted.
291  // returns -1 otherwise.
292  return 1;
293 }
294 #endif // #ifdef protoDUNE_dEdx_calib_cxx
void GetEFMaps(TFile *ef)
QList< Entry > entry
virtual void Loop(int hitplane, double norm_factor, double calib_factor)
std::string string
Definition: nybbler.cc:12
protoDUNE_dEdx_calib(TTree *tree=0)
Float_t trkhitz[30][3][3000]
std::vector< TH3F * > neg_hists
struct vector vector
virtual Bool_t Notify()
Int_t fCurrent
pointer to the analyzed TTree or TChain
Float_t trkdqdx[30][3][3000]
virtual Int_t GetEntry(Long64_t entry)
virtual void Init(TTree *tree)
void LoopMIP(std::vector< double > &norm_factors, std::vector< std::vector< double >> &calib_factors, TFile &outfile)
Float_t trkresrange[30][3][3000]
Float_t trkdedx[30][3][3000]
T get(std::string const &key) const
Definition: ParameterSet.h:271
virtual void Show(Long64_t entry=-1)
virtual ~protoDUNE_dEdx_calib()
double calib_factor
Definition: doAna.cpp:18
Int_t event
current Tree number in a TChain
std::vector< TH3F * > pos_hists
virtual Long64_t LoadTree(Long64_t entry)
Float_t trkpitch[30][3][3000]
Float_t trkstartcosxyz[30][3]
virtual Int_t Cut(Long64_t entry)
Float_t trkhity[30][3][3000]
float tot_Ef(float xval, float yval, float zval)
void SetCaloMaps(const fhicl::ParameterSet &pset)
Float_t trkhitx[30][3][3000]
void LoopLite(std::vector< double > &norm_factors, std::vector< std::vector< double >> &calib_factors, TFile &outfile)
Event finding and building.
TFile * ef
Definition: doAna.cpp:25