plot_abstree.C
Go to the documentation of this file.
1 #ifdef __CINT__
2 void plot_abstree(std::string sample, std::string analysis, std::string disk=""){
3  std::cout << "\n Must run in compiled mode \n" << std::endl;
4 }
5 #else
6 
7 #include <vector>
8 #include <ctime>
9 #include <iostream>
10 
11 #include "TFile.h"
12 #include "TChain.h"
13 #include "TTree.h"
14 #include "TProfile.h"
15 #include "TProfile2D.h"
16 
17 bool cut_Track_Window(double x){
18  //return true;
19  return (x<200) && (x>100);
20 }
21 
22 bool cut_cells_per_plane(int ncells,int tree_i){
23  //if(tree_i==1||tree_i==3) return ncells==1;
24  //else return true;
25  return true;
26 }
27 
28 bool cut_W(double w){
29  return true;
30  //return -200 < w && w < 0;
31  //return 0 < w && w < 200;
32 
33  //return -100 < w && w < 100; // nd flatW
34 
35  //return -25 < w && w < 25;
36  //return 200 < w && w < 600;
37  //return -100 < w && w < -50;
38  //return -50 < w && w < 0;
39  //return 0 < w && w < 50;
40  //return 50 < w && w < 100;
41 }
42 
43 
44 bool cut_PE(double pe){
45  return 0 < pe;
46  //return 50 < pe;
47  //return 100 < pe;
48  //return 150 < pe;
49  //return 200 < pe;
50  //return 250 < pe;
51  //return 300 < pe;
52  //return 350 < pe;
53  //return 400 < pe;
54  //return 500 < pe;
55 }
56 
57 bool cut_trueE(double trueE){
58  return true;
59  //return trueE>15;
60 }
61 
62 bool cut_Cell(int c){
63  return true;
64  //return 0 <= c%32 && c%32 <= 6;
65  //return 13 <= c%32 && c%32 <= 18;
66  //return 26 <= c%32 && c%32 <= 31;
67 }
68 
69 void plot_abstree(std::string sample, std::string analysis, std::string disk="/nova/ana/users/talion/"){
70 
71 
72  unsigned int maxEntries = 40e6;
73  //maxEntries = 4e9;
74  //maxEntries = 10e6;
75 
76 
77  int SelectPDG = -1; //-1 for all
78 
79 
80  bool ProtondEdx = false;
82  if (sample.find("/nova/ana/users/sgermani")!=std::string::npos){
83  filepath=sample;
84  if (sample.find("_MC_")!=std::string::npos) sample="remid/nd_mc";
85  if (sample.find("_Cry_")!=std::string::npos) sample="remid/fd_mc_gain100";
86  if (sample.find("_Data_")!=std::string::npos) sample="remid/nd_data_period2";
87  if (sample.find("_CROverlay_")!=std::string::npos) sample="remid/fd_data_epoch2b";
88  //ZoomOnLowerEnergyY = false; // z-going tracks do not bias X/Y views with longer hits
89  if(analysis.find("proton")!=std::string::npos) ProtondEdx = true;
90  } else {
91  filepath = Form("%s/%s/%s/merged.root",
92  disk.c_str(),
93  analysis.c_str(),
94  sample.c_str() );
95 }
96 
97  std::string det="";
98  if (sample.find("nd_")!=std::string::npos) det = "nd";
99  if (sample.find("fd_")!=std::string::npos) det = "fd";
100  bool isMC=false;
101  if (sample.find("_mc")!=std::string::npos) isMC = true;
102  if (sample.find("_MC")!=std::string::npos) isMC = true;
103 
104  if(isMC) std::cout << "\n MC file, plot true values as well \n" << std::endl;
105  else std::cout << "\n Data file, no true values to plot \n" << std::endl;
106 
107  TFile f(filepath.c_str());
108  TFile *outf = new TFile(Form("%s/plot_%s.root",
109  sample.c_str(),
110  analysis.c_str()),"recreate");
111 
112  TTree *t;
113  std::vector< std::string > forest; forest.resize(4);
114  forest[0] = "muondedxana/fTree";
115  forest[1] = "remiddedx/fDedxSample";
116  forest[2] = "assess/tree";
117  forest[3] = "remiddedxfd/fDedxSample";
118  if(ProtondEdx)
119  forest[1] = "remiddedx/fProtonDedxSample";
120  unsigned int tree_i=999;
121  for(unsigned int i=0; i<forest.size(); i++){
122  f.GetObject(forest[i].c_str(),t);
123  tree_i = i;
124  if(t) break;
125  }
126  if(!t) std::cout << "could not find tree" << std::endl;
127  //else std::cout << "Found tree" << std::endl;
128 
129 
130  float PECorr, PE, x, w, true_path, path, trueE, recoGeV;
131  float xDir, yDir, zDir, dcosz, dcosy;
132  float fbBin_fl, cell_fl, plane_fl;
133  int cell, plane, fbBin, view;
134  float xpos, ypos, adc;
135  int pdg, cells_per_plane;
136 
137  if( tree_i==2 ){
138  t->SetBranchAddress( "cell", &cell );
139  t->SetBranchAddress( "plane", &plane );
140  t->SetBranchAddress( "W", &w );
141  t->SetBranchAddress( "view", &view );
142  //t->SetBranchAddress( "path", &path );
143  t->SetBranchAddress( "pecorr", &PECorr );
144  t->SetBranchAddress( "pe", &PE );
145  t->SetBranchAddress( "trueE", &trueE ); // gev
146  t->SetBranchAddress( "fibBrightnessBin",&fbBin);
147  x=0;
148  true_path = 0;
149  path = 0;
150 
151  } else if (tree_i==1 || tree_i==3){
152 
153  if(ProtondEdx){
154  t->SetBranchAddress( "Protoncell", &cell );
155  t->SetBranchAddress( "Protonplane", &plane );
156  t->SetBranchAddress( "ProtondistFromEnd", &x );
157  t->SetBranchAddress( "ProtonxHit", &xpos );
158  t->SetBranchAddress( "ProtonyHit", &ypos );
159  t->SetBranchAddress( "Protonview", &view );
160  t->SetBranchAddress( "ProtonxDir", &xDir );
161  t->SetBranchAddress( "ProtonyDir", &yDir );
162  t->SetBranchAddress( "ProtonzDir", &zDir );
163  t->SetBranchAddress( "Protondx", &path );
164  t->SetBranchAddress( "Protonmcdx", &true_path );
165  t->SetBranchAddress( "Protonpecorr", &PECorr );
166  t->SetBranchAddress( "Protonpe", &PE );
167  t->SetBranchAddress( "Protonmcde", &trueE ); // gev
168  t->SetBranchAddress( "Protonmcdx", &true_path ); // cm
169  t->SetBranchAddress( "ProtonfiberBrightness",&fbBin);
170  t->SetBranchAddress( "Protonpdg", &pdg );
171  t->SetBranchAddress( "Protonde", &recoGeV );
172  t->SetBranchAddress( "Protonadc", &adc );
173  t->SetBranchAddress( "ProtonncellsPerPlane", &cells_per_plane );
174  } else {
175  t->SetBranchAddress( "cell", &cell );
176  t->SetBranchAddress( "plane", &plane );
177  t->SetBranchAddress( "distFromEnd", &x );
178  t->SetBranchAddress( "xHit", &xpos );
179  t->SetBranchAddress( "yHit", &ypos );
180  t->SetBranchAddress( "view", &view );
181  t->SetBranchAddress( "xDir", &xDir );
182  t->SetBranchAddress( "yDir", &yDir );
183  t->SetBranchAddress( "zDir", &zDir );
184  t->SetBranchAddress( "dx", &path );
185  t->SetBranchAddress( "mcdx", &true_path );
186  t->SetBranchAddress( "pecorr", &PECorr );
187  t->SetBranchAddress( "pe", &PE );
188  //t->SetBranchAddress( "trueE", &trueE ); // this was true E of MCParticle (GeV)
189  t->SetBranchAddress( "mcde", &trueE ); // gev
190  t->SetBranchAddress( "mcdx", &true_path ); // cm
191  t->SetBranchAddress( "fiberBrightness",&fbBin);
192  t->SetBranchAddress( "pdg", &pdg );
193  t->SetBranchAddress( "de", &recoGeV );
194  t->SetBranchAddress( "adc", &adc );
195  t->SetBranchAddress( "ncellsPerPlane", &cells_per_plane );
196  }
197 
198  } else {
199  t->SetBranchAddress( "x", &x );
200  t->SetBranchAddress( "pdg", &pdg );
201  t->SetBranchAddress( "w", &w );
202  t->SetBranchAddress( "view", &view );
203  t->SetBranchAddress( "path", &path );
204  t->SetBranchAddress( "truepath", &true_path );
205  t->SetBranchAddress( "cell", &cell_fl );
206  t->SetBranchAddress( "plane", &plane_fl );
207  t->SetBranchAddress( "PECorr", &PECorr );
208  t->SetBranchAddress( "PE", &PE );
209  t->SetBranchAddress( "trueE", &trueE ); // mev
210  t->SetBranchAddress( "fibBrightnessBin",&fbBin_fl);
211  t->SetBranchAddress( "RecoGeV", &recoGeV );
212  t->SetBranchAddress( "dCosZ", &dcosz );
213  t->SetBranchAddress( "dCosY", &dcosy );
214  }
215 
216 
217  ///////////////////////////////////////////////////////////////////
218  ///////////////////////////////////////////////////////////////////
219  ////////////////// //////////////////
220  ////////////////// Set up plot ranges //////////////////
221  ////////////////// //////////////////
222  ///////////////////////////////////////////////////////////////////
223  ///////////////////////////////////////////////////////////////////
224  unsigned int nFBbins = 9;
225  int nCells(0), PlanesPerView(0), tprof_bins(30), dxbins(30);
226  float wrange;
227  float dxmin(3), dxmax(10);
228  float pe_x_min, pe_x_max, pe_y_min, pe_y_max;
229  float track_end_max(500); // for plotting regardless of track window
230  float w_x_cut_min, w_x_cut_max, w_y_cut_min, w_y_cut_max;
231  float flatW_x_min, flatW_x_max, flatW_y_min, flatW_y_max;
232  if(det=="nd"){
233 
234  nCells = 32*3;
235  PlanesPerView = 96;
236  wrange = 200;
237 
238  pe_x_min = 0; pe_x_max = 450;
239  pe_y_min = 0; pe_y_max = 450;
240  w_x_cut_min = -100; w_x_cut_max = 150;
241  w_y_cut_min = -150; w_y_cut_max = 150;
242 
243  flatW_x_min = -100; flatW_x_max = 100;
244  flatW_y_min = -100; flatW_y_max = 100;
245 
246  //if(isMC) wbins = 15;
247 
248  if(ProtondEdx){
249  tprof_bins=15;
250  dxbins=30;
251  pe_y_max = 1300;
252  pe_x_max = 1300;
253  track_end_max = 500;
254  }
255 
256 
257  } else {
258 
259  nCells = 384;
260  PlanesPerView = 448;
261  wrange = 800;
262 
263  pe_x_min = 0; pe_x_max = 450;
264  pe_y_min = 0; pe_y_max = 450;
265  w_x_cut_min = -600; w_x_cut_max = 600;
266  w_y_cut_min = -600; w_y_cut_max = 600;
267 
268  flatW_x_min = 200; flatW_x_max = 600;
269  flatW_y_min = 200; flatW_y_max = 600;
270  }
271 
272 
273  std::cout << "define plots" << std::endl;
274 
275 
276  ///////////////////////////////////////////////////////////////////
277  ///////////////////////////////////////////////////////////////////
278  ////////////////// //////////////////
279  ////////////////// Declare plots with strict //////////////////
280  ////////////////// naming convention: //////////////////
281  /////// ///////
282  /////// "plottype_fillweight_yaxis(-xaxis)_specifiers" ///////
283  /////// ///////
284  /////// root object name is same as ///////
285  /////// identifier, except with "-" becoming "_" ///////
286  /////// ///////
287  ///////////////////////////////////////////////////////////////////
288  ///////////////////////////////////////////////////////////////////
289 
290 
291  TH2D *th2d_nhits_dE_pe_xview = new TH2D("th2d_nhits_dE-pe_xview",
292  "X view;PE;True Deposition (MeV)",
293  tprof_bins,0,300,
294  tprof_bins,0,0.09*1000);
295  TH2D *th2d_nhits_dE_pe_yview = new TH2D("th2d_nhits_dE-pe_yview",
296  "Y view;PE;True Deposition (MeV)",
297  tprof_bins,0,300,
298  tprof_bins,0,0.09*1000);
299 
300 
301  /* # hits
302 
303  th2d_nhits_cell-w_xview
304  th2d_nhits_w-cell_yview
305 
306  */
307 
308 
309  TH1D *th1d_nhits_resp_flatW = new TH1D("th1d_nhits_resp_flatW",";PECorr/cm;# Hits",
310  1000,0,500);
311  TH1D *th1d_nhits_truededx_flatW = new TH1D("th1d_nhits_truededx_flatW",";MeV/cm;# Hits",
312  1000,0,25);
313  TH1D *th1d_nhits_resp_flatW_xview = new TH1D("th1d_nhits_resp_flatW_xview",";PECorr/cm;# Hits",
314  1000,0,500);
315  TH1D *th1d_nhits_resp_flatW_yview = new TH1D("th1d_nhits_resp_flatW_yview",";PECorr/cm;# Hits",
316  1000,0,500);
317  TH1D *th1d_nhits_truededx_flatW_xview = new TH1D("th1d_nhits_truededx_flatW_xview",";True MeV/cm;# Hits",
318  1000,0,25);
319  TH1D *th1d_nhits_truededx_flatW_yview = new TH1D("th1d_nhits_truededx_flatW_yview",";True MeV/cm;# Hits",
320  1000,0,25);
321  TH1D *th1d_nhits_recodedx_flatW_xview = new TH1D("th1d_nhits_recodedx_flatW_xview",";Reco MeV/cm;# Hits",
322  tprof_bins,0,6);
323  TH1D *th1d_nhits_recodedx_flatW_yview = new TH1D("th1d_nhits_recodedx_flatW_yview",";Reco MeV/cm;# Hits",
324  tprof_bins,0,6);
325 
326 
327  TH1D *th1d_nhits_truedx_xview = new TH1D("th1d_nhits_truedx_xview",
328  "X view;True Path Length (cm);# Hits",
329  tprof_bins,0,10);
330  TH1D *th1d_nhits_truedx_yview = new TH1D("th1d_nhits_truedx_yview",
331  "Y view;True Path Length (cm);# Hits",
332  tprof_bins,0,10);
333  TH1D *th1d_nhits_dx_xview = new TH1D("th1d_nhits_dx_xview",
334  "X view;Reconstructed Path Length (cm);# Hits",
335  tprof_bins,0,15);
336  TH1D *th1d_nhits_dx_yview = new TH1D("th1d_nhits_dx_yview",
337  "Y view;Reconstructed Path Length (cm);# Hits",
338  tprof_bins,0,15);
339  TH1D *th1d_nhits_dE_xview = new TH1D("th1d_nhits_dE_xview",
340  "X view;True Energy Deposit (MeV);# Hits",
341  tprof_bins,0,20);
342  TH1D *th1d_nhits_dE_yview = new TH1D("th1d_nhits_dE_yview",
343  "Y view;True Energy Deposit (MeV);# Hits",
344  tprof_bins,0,20);
345 
346 
347  TH1D *th1d_nhits_dcosz_xview = new TH1D("th1d_nhits_dcosz_xview",
348  "X view;Z Direcion Cosine;# Hits",
349  tprof_bins,-1,1);
350  TH1D *th1d_nhits_dcosz_yview = new TH1D("th1d_nhits_dcosz_yview",
351  "Y view;Z Direction Cosine;# Hits",
352  tprof_bins,-1,1);
353  TH1D *th1d_nhits_dcosy_xview = new TH1D("th1d_nhits_dcosy_xview",
354  "X view;Y Direcion Cosine;# Hits",
355  tprof_bins,-1,1);
356  TH1D *th1d_nhits_dcosy_yview = new TH1D("th1d_nhits_dcosy_yview",
357  "Y view;Y Direction Cosine;# Hits",
358  tprof_bins,-1,1);
359 
360 
361  TH2D *th2d_nhits_cell_w_xview = new TH2D("th2d_nhits_cell-w_xview",
362  "X view;X Cell;W (cm)",
363  nCells, 0, nCells,
364  tprof_bins, -wrange, wrange );
365  TH2D *th2d_nhits_w_cell_yview = new TH2D("th2d_nhits_w-cell_yview",
366  "Y view;W (cm);Y Cell",
367  tprof_bins, -wrange, wrange,
368  nCells, 0, nCells );
369 
370  TH2D *th2d_nhits_dx_recodedx_xview = new TH2D("th2d_nhits_dx-recodedx_xview",
371  "X view;Reconstructed Path Length (cm);Reco dE/dx (MeV/cm)",
372  dxbins, 3, 10,
373  tprof_bins, 0, 5 );
374  TH2D *th2d_nhits_dx_recodedx_yview = new TH2D("th2d_nhits_dx-recodedx_yview",
375  "Y view;Reconstructed Path Length (cm);Reco dE/dx (MeV/cm)",
376  dxbins, 3, 10,
377  tprof_bins, 0, 5 );
378  TH2D *th2d_nhits_dx_truededx_xview = new TH2D("th2d_nhits_dx-truededx_xview",
379  "X view;Reconstructed Path Length (cm);True dE/dx (MeV/cm)",
380  dxbins, 3, 10,
381  tprof_bins, 0, 5 );
382  TH2D *th2d_nhits_dx_truededx_yview = new TH2D("th2d_nhits_dx-truededx_yview",
383  "Y view;Reconstructed Path Length (cm);True dE/dx (MeV/cm)",
384  dxbins, 3, 10,
385  tprof_bins, 0, 5 );
386 
387 
388  /* 1D profiles
389 
390  N.B. -- If there exists a fb-split vector for any particular 1d plot, the
391  combined 1d plot is kept at the end of that vector instead of here.
392 
393  tprof_resp_fbbin*
394  tprof_pecm_fbbin*
395  tprof_resp_dx_*
396  tprof_resp_cell_*
397  tprof_resp_plane_*
398  tprof_recotruedx_truedx_*
399  tprof_dxres_truedx_*
400  tprof_dxres_w_*
401 
402  */
403  TProfile *tprof_resp_fbbin = new TProfile("tprof_resp_fbbin",
404  "Response vs Fiber Brightness Bin;Fiber Brightness Bin;PECorr/cm",
405  nFBbins,0,nFBbins);
406  TProfile *tprof_pecm_fbbin = new TProfile("tprof_pecm_fbbin",
407  "Uncorrected Response vs Fiber Brightness Bin;Fiber Brightness Bin;PE/cm",
408  nFBbins,0,nFBbins);
409  TProfile *tprof_resp_fbbin_xview = new TProfile("tprof_resp_fbbin_xview",
410  "X view Response vs FB Bin;Fiber Brightness Bin;PECorr/cm",
411  nFBbins,0,nFBbins);
412  TProfile *tprof_pecm_fbbin_xview = new TProfile("tprof_pecm_fbbin_xview",
413  "X view Uncorrected Response vs FB Bin;Fiber Brightness Bin;PE/cm",
414  nFBbins,0,nFBbins);
415  TProfile *tprof_resp_fbbin_yview = new TProfile("tprof_resp_fbbin_yview",
416  "Y view Response vs FB Bin;Fiber Brightness Bin;PECorr/cm",
417  nFBbins,0,nFBbins);
418  TProfile *tprof_pecm_fbbin_yview = new TProfile("tprof_pecm_fbbin_yview",
419  "Y view Uncorrected Response vs FB Bin;Fiber Brightness Bin;PE/cm",
420  nFBbins,0,nFBbins);
421 
422  TProfile *tprof_resp_dx_xview = new TProfile("tprof_resp_dx_xview",
423  "Mean Response (X view);Path Length (cm);PECorr/cm",
424  dxbins,dxmin,dxmax);
425  TProfile *tprof_resp_dx_yview = new TProfile("tprof_resp_dx_yview",
426  "Mean Response (Y view);Path Length (cm);PECorr/cm",
427  dxbins,dxmin,dxmax);
428 
429  TProfile* tprof_pecm_cell_xview = new TProfile("tprof_pecm_cell_xview",
430  "X view;Cell Number;PE/cm",
431  nCells, 0, nCells);
432  TProfile* tprof_pecm_cell_yview = new TProfile("tprof_pecm_cell_yview",
433  "Y view;Cell Number;PE/cm",
434  nCells, 0, nCells);
435 
436  TProfile* tprof_resp_cell_xview = new TProfile("tprof_resp_cell_xview",
437  "Response vs Cell (X view);Cell Number;Reco Response (PECorr/cm)",
438  nCells, 0, nCells);
439  TProfile* tprof_resp_cell_yview = new TProfile("tprof_resp_cell_yview",
440  "Response vs Cell (Y view);Cell Number;Reco Response (PECorr/cm)",
441  nCells, 0, nCells);
442 
443  TProfile* tprof_resp_plane_xview = new TProfile("tprof_resp_plane_xview",
444  "Response vs Plane (X view);Plane Number;Reco Response (PECorr/cm)",
445  PlanesPerView, 0, 2*PlanesPerView);
446  TProfile* tprof_resp_plane_yview = new TProfile("tprof_resp_plane_yview",
447  "Response vs Plane (Y view);Plane Number;Reco Response (PECorr/cm)",
448  PlanesPerView, 0, 2*PlanesPerView);
449 
450  TProfile* tprof_recotruedx_truedx_xview = new TProfile("tprof_recotruedx_truedx_xview",
451  "Reco/True PCHit Path Length (X View);True Path Length (cm);Reco/True Path Length",
452  tprof_bins,1,10);
453  TProfile* tprof_recotruedx_truedx_yview = new TProfile("tprof_recotruedx_truedx_yview",
454  "Reco/True PCHit Path Length (Y View);True Path Length (cm);Reco/True Path Length",
455  tprof_bins,1,10);
456 
457  TProfile* tprof_dxres_truedx_xview = new TProfile("tprof_dxres_truedx_xview",
458  "Path Length Resolution (X View);True Path Length (cm);(Reco-True) / True Path Length",
459  tprof_bins,1,10);
460  TProfile* tprof_dxres_truedx_yview = new TProfile("tprof_dxres_truedx_yview",
461  "Path Length Resolution (Y View);True Path Length (cm);(Reco-True) / True Path Length",
462  tprof_bins,1,10);
463 
464  TProfile* tprof_dxres_w_xview = new TProfile("tprof_dxres_w_xview",
465  "Path Length Resolution (X View);W (cm);(Reco-True) / True Path Length",
466  tprof_bins,-wrange,wrange);
467  TProfile* tprof_dxres_w_yview = new TProfile("tprof_dxres_w_yview",
468  "Path Length Resolution (Y View);W (cm);(Reco-True) / True Path Length",
469  tprof_bins,-wrange,wrange);
470 
471 
472  TProfile* tprof_pecm_plane_xview = new TProfile("tprof_pecm_plane_xview",
473  "PE/cm vs Plane (X view);Plane;PE/cm",
474  PlanesPerView, 0, 2*PlanesPerView);
475  TProfile* tprof_pecm_plane_yview = new TProfile("tprof_pecm_plane_yview",
476  "PE/cm vs Plane (Y view);Plane;PE/cm",
477  PlanesPerView, 0, 2*PlanesPerView);
478 
479 
480  TProfile* tprof_recodedx_dcosz_xview = new TProfile("tprof_recodedx_dcosz_xview",
481  "X View;Z Direction Cosine;Reco dE/dx (MeV/cm)",
482  tprof_bins,-1,1);
483  TProfile* tprof_recodedx_dcosz_yview = new TProfile("tprof_recodedx_dcosz_yview",
484  "Y View;Z Direction Cosine;Reco dE/dx (MeV/cm)",
485  tprof_bins,-1,1);
486  TProfile* tprof_truededx_dcosz_xview = new TProfile("tprof_truededx_dcosz_xview",
487  "X View;Z Direction Cosine;True dE/dx (MeV/cm)",
488  tprof_bins,-1,1);
489  TProfile* tprof_truededx_dcosz_yview = new TProfile("tprof_truededx_dcosz_yview",
490  "Y View;Z Direction Cosine;True dE/dx (MeV/cm)",
491  tprof_bins,-1,1);
492  TProfile* tprof_recodedx_dcosy_xview = new TProfile("tprof_recodedx_dcosy_xview",
493  "X View;Y Direction Cosine;Reco dE/dx (MeV/cm)",
494  tprof_bins,-1,1);
495  TProfile* tprof_recodedx_dcosy_yview = new TProfile("tprof_recodedx_dcosy_yview",
496  "Y View;Y Direction Cosine;Reco dE/dx (MeV/cm)",
497  tprof_bins,-1,1);
498  TProfile* tprof_truededx_dcosy_xview = new TProfile("tprof_truededx_dcosy_xview",
499  "X View;Y Direction Cosine;True dE/dx (MeV/cm)",
500  tprof_bins,-1,1);
501  TProfile* tprof_truededx_dcosy_yview = new TProfile("tprof_truededx_dcosy_yview",
502  "Y View;Y Direction Cosine;True dE/dx (MeV/cm)",
503  tprof_bins,-1,1);
504  TProfile* tprof_dx_dcosz_xview = new TProfile("tprof_dx_dcosz_xview",
505  "X View;Z Direction Cosine;Reco Path Length (MeV/cm)",
506  tprof_bins,-1,1);
507  TProfile* tprof_dx_dcosz_yview = new TProfile("tprof_dx_dcosz_yview",
508  "Y View;Z Direction Cosine;Reco Path Length (MeV/cm)",
509  tprof_bins,-1,1);
510  TProfile* tprof_dx_dcosy_xview = new TProfile("tprof_dx_dcosy_xview",
511  "X View;Y Direction Cosine;Reco Path Length (MeV/cm)",
512  tprof_bins,-1,1);
513  TProfile* tprof_dx_dcosy_yview = new TProfile("tprof_dx_dcosy_yview",
514  "Y View;Y Direction Cosine;Reco Path Length (MeV/cm)",
515  tprof_bins,-1,1);
516 
517 
518  /* 2D profiles
519 
520  tprof2_resp_cell-w_xview
521  tprof2_resp_w-cell_yview
522  tprof2_resp_cell-plane_*
523  tprof2_pecm_cell-plane_*
524 
525  */
526  TProfile2D *tprof2_resp_w_cell_xview = new TProfile2D("tprof2_resp_w-cell_xview",
527  "Mean Response (X view);X Cell;W (cm)",
528  nCells, 0, nCells,
529  tprof_bins, -wrange, wrange );
530  TProfile2D *tprof2_resp_cell_w_yview = new TProfile2D("tprof2_resp_cell-w_yview",
531  "Mean Response (Y yiew);W (cm);Y Cell",
532  tprof_bins, -wrange, wrange,
533  nCells, 0, nCells );
534 
535  TProfile2D *tprof2_resp_cell_plane_xview = new TProfile2D("tprof2_resp_cell-plane_xview",
536  "Detector Response PECorr/cm (X view);X Plane;Cell",
537  PlanesPerView, 0, 2*PlanesPerView,
538  nCells, 0, nCells);
539  TProfile2D *tprof2_resp_cell_plane_yview = new TProfile2D("tprof2_resp_cell-plane_yview",
540  "Detector Response PECorr/cm (Y view);Y Plane;Cell",
541  PlanesPerView, 0, 2*PlanesPerView,
542  nCells, 0, nCells);
543 
544  TProfile2D *tprof2_pecm_cell_plane_xview = new TProfile2D("tprof2_pecm_cell-plane_xview",
545  "Uncorrected Detector Response PE/cm (X view);X Plane;Cell",
546  PlanesPerView, 0, 2*PlanesPerView,
547  nCells, 0, nCells);
548  TProfile2D *tprof2_pecm_cell_plane_yview = new TProfile2D("tprof2_pecm_cell-plane_yview",
549  "Uncorrected Detector Response PE/cm (Y view);Y Plane;Cell",
550  PlanesPerView, 0, 2*PlanesPerView,
551  nCells, 0, nCells);
552  TProfile2D *tprof2_pecm_cell_plane = new TProfile2D("tprof2_pecm_cell-plane",
553  "Uncorrected Detector Response PE/cm;Plane;Cell",
554  2*PlanesPerView, 0, 2*PlanesPerView,
555  nCells, 0, nCells);
556 
557 
558 
559 
560  /* fb-split
561 
562  N.B. -- all-FB plots kept in nFBbins index
563 
564  */
565  // vs W
566  std::vector< TProfile* > tprof_resp_w_xview_fb; tprof_resp_w_xview_fb.resize(nFBbins+1);
567  std::vector< TProfile* > tprof_resp_w_yview_fb; tprof_resp_w_yview_fb.resize(nFBbins+1);
568  std::vector< TProfile* > tprof_resp_w_xview_edgecells_fb; tprof_resp_w_xview_edgecells_fb.resize(nFBbins+1);
569  std::vector< TProfile* > tprof_resp_w_yview_edgecells_fb; tprof_resp_w_yview_edgecells_fb.resize(nFBbins+1);
570  std::vector< TH1D* > th1d_nhits_w_xview_fb; th1d_nhits_w_xview_fb.resize(nFBbins+1);
571  std::vector< TH1D* > th1d_nhits_w_yview_fb; th1d_nhits_w_yview_fb.resize(nFBbins+1);
572  std::vector< TH2D* > th2d_nhits_truededx_w_xview_fb; th2d_nhits_truededx_w_xview_fb.resize(nFBbins+1);
573  std::vector< TH2D* > th2d_nhits_truededx_w_yview_fb; th2d_nhits_truededx_w_yview_fb.resize(nFBbins+1);
574  std::vector< TH2D* > th2d_nhits_truededx_w_xview_nowindow_fb; th2d_nhits_truededx_w_xview_nowindow_fb.resize(nFBbins+1);
575  std::vector< TH2D* > th2d_nhits_truededx_w_yview_nowindow_fb; th2d_nhits_truededx_w_yview_nowindow_fb.resize(nFBbins+1);
576  std::vector< TProfile* > tprof_pe_w_xview; tprof_pe_w_xview.resize(nFBbins+1);
577  std::vector< TProfile* > tprof_pe_w_yview; tprof_pe_w_yview.resize(nFBbins+1);
578  std::vector< TProfile* > tprof_pecm_w_xview; tprof_pecm_w_xview.resize(nFBbins+1);
579  std::vector< TProfile* > tprof_pecm_w_yview; tprof_pecm_w_yview.resize(nFBbins+1);
580  std::vector< TProfile* > tprof_truededx_w_xview; tprof_truededx_w_xview.resize(nFBbins+1);
581  std::vector< TProfile* > tprof_truededx_w_yview; tprof_truededx_w_yview.resize(nFBbins+1);
582  std::vector< TProfile* > tprof_recodedx_w_xview; tprof_recodedx_w_xview.resize(nFBbins+1);
583  std::vector< TProfile* > tprof_recodedx_w_yview; tprof_recodedx_w_yview.resize(nFBbins+1);
584  std::vector< TProfile* > tprof_dx_w_xview; tprof_dx_w_xview.resize(nFBbins+1);
585  std::vector< TProfile* > tprof_dx_w_yview; tprof_dx_w_yview.resize(nFBbins+1);
586  std::vector< TProfile* > tprof_pecorrpe_w_xview_fb; tprof_pecorrpe_w_xview_fb.resize(nFBbins+1);
587  std::vector< TProfile* > tprof_pecorrpe_w_yview_fb; tprof_pecorrpe_w_yview_fb.resize(nFBbins+1);
588  std::vector< TProfile* > tprof_pecorrmev_w_xview_fb; tprof_pecorrmev_w_xview_fb.resize(nFBbins+1);
589  std::vector< TProfile* > tprof_pecorrmev_w_yview_fb; tprof_pecorrmev_w_yview_fb.resize(nFBbins+1);
590  // vs PE
591  std::vector< TProfile* > tprof_resp_pe_xview_fb; tprof_resp_pe_xview_fb.resize(nFBbins+1);
592  std::vector< TProfile* > tprof_resp_pe_yview_fb; tprof_resp_pe_yview_fb.resize(nFBbins+1);
593  std::vector< TProfile* > tprof_pecorr_pe_xview_fb; tprof_pecorr_pe_xview_fb.resize(nFBbins+1);
594  std::vector< TProfile* > tprof_pecorr_pe_yview_fb; tprof_pecorr_pe_yview_fb.resize(nFBbins+1);
595  std::vector< TProfile* > tprof_pecorrmev_pe_xview_fb; tprof_pecorrmev_pe_xview_fb.resize(nFBbins+1);
596  std::vector< TProfile* > tprof_pecorrmev_pe_yview_fb; tprof_pecorrmev_pe_yview_fb.resize(nFBbins+1);
597  std::vector< TProfile* > tprof_pecorrpe_pe_xview_fb; tprof_pecorrpe_pe_xview_fb.resize(nFBbins+1);
598  std::vector< TProfile* > tprof_pecorrpe_pe_yview_fb; tprof_pecorrpe_pe_yview_fb.resize(nFBbins+1);
599  std::vector< TProfile* > tprof_truededx_pe_xview_fb; tprof_truededx_pe_xview_fb.resize(nFBbins+1);
600  std::vector< TProfile* > tprof_truededx_pe_yview_fb; tprof_truededx_pe_yview_fb.resize(nFBbins+1);
601  std::vector< TProfile* > tprof_recodedx_pe_xview_fb; tprof_recodedx_pe_xview_fb.resize(nFBbins+1);
602  std::vector< TProfile* > tprof_recodedx_pe_yview_fb; tprof_recodedx_pe_yview_fb.resize(nFBbins+1);
603  // vs PECorr
604  std::vector< TProfile* > tprof_pecorrpe_pecorr_xview_fb; tprof_pecorrpe_pecorr_xview_fb.resize(nFBbins+1);
605  std::vector< TProfile* > tprof_pecorrpe_pecorr_yview_fb; tprof_pecorrpe_pecorr_yview_fb.resize(nFBbins+1);
606  std::vector< TProfile* > tprof_truededx_pecorr_xview_fb; tprof_truededx_pecorr_xview_fb.resize(nFBbins+1);
607  std::vector< TProfile* > tprof_truededx_pecorr_yview_fb; tprof_truededx_pecorr_yview_fb.resize(nFBbins+1);
608  std::vector< TProfile* > tprof_recodedx_pecorr_xview_fb; tprof_recodedx_pecorr_xview_fb.resize(nFBbins+1);
609  std::vector< TProfile* > tprof_recodedx_pecorr_yview_fb; tprof_recodedx_pecorr_yview_fb.resize(nFBbins+1);
610  // vs true dE
611  std::vector< TProfile* > tprof_pecorrmev_dE_xview_fb; tprof_pecorrmev_dE_xview_fb.resize(nFBbins+1);
612  std::vector< TProfile* > tprof_pecorrmev_dE_yview_fb; tprof_pecorrmev_dE_yview_fb.resize(nFBbins+1);
613  // vs x (dist from end of track)
614  std::vector< TProfile* > tprof_truededx_x_xview; tprof_truededx_x_xview.resize(nFBbins+1);
615  std::vector< TProfile* > tprof_truededx_x_yview; tprof_truededx_x_yview.resize(nFBbins+1);
616  std::vector< TProfile* > tprof_recodedx_x_xview; tprof_recodedx_x_xview.resize(nFBbins+1);
617  std::vector< TProfile* > tprof_recodedx_x_yview; tprof_recodedx_x_yview.resize(nFBbins+1);
618  // vs pathlength
619  std::vector< TProfile* > tprof_truededx_dx_xview; tprof_truededx_dx_xview.resize(nFBbins+1);
620  std::vector< TProfile* > tprof_truededx_dx_yview; tprof_truededx_dx_yview.resize(nFBbins+1);
621  std::vector< TProfile* > tprof_recodedx_dx_xview; tprof_recodedx_dx_xview.resize(nFBbins+1);
622  std::vector< TProfile* > tprof_recodedx_dx_yview; tprof_recodedx_dx_yview.resize(nFBbins+1);
623  // vs cells per plane
624  std::vector< TProfile* > tprof_truededx_cellpplane_xview; tprof_truededx_cellpplane_xview.resize(nFBbins+1);
625  std::vector< TProfile* > tprof_truededx_cellpplane_yview; tprof_truededx_cellpplane_yview.resize(nFBbins+1);
626  std::vector< TProfile* > tprof_recodedx_cellpplane_xview; tprof_recodedx_cellpplane_xview.resize(nFBbins+1);
627  std::vector< TProfile* > tprof_recodedx_cellpplane_yview; tprof_recodedx_cellpplane_yview.resize(nFBbins+1);
628  // vs FB
629  std::vector< TH1D* > th1d_nhits_resp_xview_fb; th1d_nhits_resp_xview_fb.resize(nFBbins+1);
630  std::vector< TH1D* > th1d_nhits_resp_yview_fb; th1d_nhits_resp_yview_fb.resize(nFBbins+1);
631  std::vector< TH1D* > th1d_nhits_truededx_xview_fb; th1d_nhits_truededx_xview_fb.resize(nFBbins+1);
632  std::vector< TH1D* > th1d_nhits_truededx_yview_fb; th1d_nhits_truededx_yview_fb.resize(nFBbins+1);
633  std::vector< TH1D* > th1d_nhits_truedetruedx_xview_fb; th1d_nhits_truedetruedx_xview_fb.resize(nFBbins+1);
634  std::vector< TH1D* > th1d_nhits_truedetruedx_yview_fb; th1d_nhits_truedetruedx_yview_fb.resize(nFBbins+1);
635  std::vector< TH1D* > th1d_nhits_recodedx_xview_fb; th1d_nhits_recodedx_xview_fb.resize(nFBbins+1);
636  std::vector< TH1D* > th1d_nhits_recodedx_yview_fb; th1d_nhits_recodedx_yview_fb.resize(nFBbins+1);
637  std::vector< TH1D* > th1d_nhits_pe_xview_fb; th1d_nhits_pe_xview_fb.resize(nFBbins+1);
638  std::vector< TH1D* > th1d_nhits_pe_yview_fb; th1d_nhits_pe_yview_fb.resize(nFBbins+1);
639  std::vector< TH1D* > th1d_nhits_pecm_xview_fb; th1d_nhits_pecm_xview_fb.resize(nFBbins+1);
640  std::vector< TH1D* > th1d_nhits_pecm_yview_fb; th1d_nhits_pecm_yview_fb.resize(nFBbins+1);
641  std::vector< TH2D* > th2d_nhits_pecm_w_xview_fb; th2d_nhits_pecm_w_xview_fb.resize(nFBbins+1);
642  std::vector< TH2D* > th2d_nhits_pecm_w_yview_fb; th2d_nhits_pecm_w_yview_fb.resize(nFBbins+1);
643  std::string name, fbtag;
644  //
645  // plotname convention: "plottype_fillweight_axis(-axis)_specifiers"
646  //
647  // Specifiers will usually be view and fb bin, so make name string:
648  // "plottype_fillweight_axis(-axis)"
649  // and handle view/fb with Form()
650  //
651  for(unsigned int i=0; i<nFBbins+1; i++){
652  if( i < nFBbins ) fbtag = Form("-fb%i",i);
653  else fbtag="";
654 
655  name = "tprof_resp_w_";
656  tprof_resp_w_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
657  "Mean Response (X view);W (cm);Response (PECorr/cm)",
658  tprof_bins,-wrange,wrange);
659  tprof_resp_w_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
660  "Mean Response (Y view);W (cm);Response (PECorr/cm)",
661  tprof_bins,-wrange,wrange);
662 
663  name = "tprof_resp_w_edgecells-";
664  tprof_resp_w_xview_edgecells_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
665  "Mean Response in Edge Cells (X view);W (cm);Response (PECorr/cm)",
666  tprof_bins,-wrange,wrange);
667  tprof_resp_w_yview_edgecells_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
668  "Mean Response in Edge Cells (Y view);W (cm);Response (PECorr/cm)",
669  tprof_bins,-wrange,wrange);
670 
671  name = "th1d_nhits_w_";
672  th1d_nhits_w_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
673  "X view;W (cm);# Hits",
674  tprof_bins,-wrange,wrange);
675  th1d_nhits_w_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
676  "Y view;W (cm);# Hits",
677  tprof_bins,-wrange,wrange);
678 
679  name = "th2d_nhits_truededx-w_";
680  th2d_nhits_truededx_w_xview_fb[i] = new TH2D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
681  "X view;W (cm);True Response (MeV/cm)",
682  tprof_bins,-wrange,wrange,
683  tprof_bins,0,10);
684  th2d_nhits_truededx_w_yview_fb[i] = new TH2D(Form("%syview%s",name.c_str(),fbtag.c_str()),
685  "Y view;W (cm);True Response (MeV/cm)",
686  tprof_bins,-wrange,wrange,
687  tprof_bins,0,10);
688 
689  name = "th2d_nhits_truededx-w_nowindow-";
690  th2d_nhits_truededx_w_xview_nowindow_fb[i] = new TH2D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
691  "Hits not in Track Window (X view);W (cm);True Response (MeV/cm)",
692  tprof_bins,-wrange,wrange,
693  tprof_bins,0,10);
694  th2d_nhits_truededx_w_yview_nowindow_fb[i] = new TH2D(Form("%syview%s",name.c_str(),fbtag.c_str()),
695  "Hits not in Track Window (Y view);W (cm);True Response (MeV/cm)",
696  tprof_bins,-wrange,wrange,
697  tprof_bins,0,10);
698  name = "tprof_pe_w_";
699  tprof_pe_w_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
700  "PE vs W (X view);W (cm);PE",
701  tprof_bins,-wrange,wrange);
702  tprof_pe_w_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
703  "PE vs W (Y view);W (cm);PE",
704  tprof_bins,-wrange,wrange);
705 
706 
707  name = "tprof_pecm_w_";
708  tprof_pecm_w_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
709  "Uncorrected Response (X view);W (cm);Uncorrected Response (PE/cm)",
710  tprof_bins,-wrange,wrange);
711  tprof_pecm_w_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
712  "Uncorrected Response (Y view);W (cm);Uncorrected Response (PE/cm)",
713  tprof_bins,-wrange,wrange);
714 
715  name = "tprof_truededx_w_";
716  tprof_truededx_w_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
717  "X view;W (cm);True dE/dx (MeV/cm)",
718  tprof_bins,-wrange,wrange);
719  tprof_truededx_w_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
720  "Y view;W (cm);True dE/dx (MeV/cm)",
721  tprof_bins,-wrange,wrange);
722  name = "tprof_recodedx_w_";
723  tprof_recodedx_w_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
724  "X view;W (cm);Reco dE/dx (MeV/cm)",
725  tprof_bins,-wrange,wrange);
726  tprof_recodedx_w_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
727  "Y view;W (cm);Reco dE/dx (MeV/cm)",
728  tprof_bins,-wrange,wrange);
729 
730  name = "tprof_dx_w_";
731  tprof_dx_w_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
732  "Path Length vs W (X view);W (cm);Path Length (cm)",
733  tprof_bins,-wrange,wrange);
734  tprof_dx_w_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
735  "Path Length vs W (Y view);W (cm);Path Length (cm)",
736  tprof_bins,-wrange,wrange);
737 
738  name = "tprof_pecorrpe_w_";
739  tprof_pecorrpe_w_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
740  "PECorr/PE vs W (X view);W (cm);PECorr/PE",
741  tprof_bins,-wrange,wrange);
742  tprof_pecorrpe_w_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
743  "PECorr/PE vs W (Y view);W (cm);PECorr/PE",
744  tprof_bins,-wrange,wrange);
745 
746  name = "tprof_pecorrmev_w_";
747  tprof_pecorrmev_w_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
748  "PECorr/MeV vs W (X view);W (cm);PECorr/MeV",
749  tprof_bins,-wrange,wrange);
750  tprof_pecorrmev_w_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
751  "PECorr/MeV vs W (Y view);W (cm);PECorr/MeV",
752  tprof_bins,-wrange,wrange);
753 
754  name = "tprof_resp_pe_";
755  tprof_resp_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
756  "Response vs PE (X view);PE;PECorr/cm",
757  tprof_bins,pe_x_min,pe_x_max);
758  tprof_resp_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
759  "Response vs PE (Y view);PE;PECorr/cm",
760  tprof_bins,pe_y_min,pe_y_max);
761 
762  name = "tprof_pecorr_pe_";
763  tprof_pecorr_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
764  "X view;PE;PECorr",
765  tprof_bins,pe_x_min,pe_x_max);
766  tprof_pecorr_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
767  "Y view;PE;PECorr",
768  tprof_bins,pe_y_min,pe_y_max);
769 
770  name = "tprof_pecorrmev_pe_";
771  tprof_pecorrmev_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
772  "PECorr/MeV vs PE (X view);PE;PECorr/MeV",
773  tprof_bins,pe_x_min,pe_x_max);
774  tprof_pecorrmev_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
775  "PECorr/MeV vs PE (Y view);PE;PECorr/MeV",
776  tprof_bins,pe_y_min,pe_y_max);
777 
778  name = "tprof_pecorrpe_pe_";
779  tprof_pecorrpe_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
780  "PECorr/PE vs PE (X view);PE;PECorr/PE",
781  tprof_bins,pe_x_min,pe_x_max);
782  tprof_pecorrpe_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
783  "PECorr/PE vs PE (Y view);PE;PECorr/PE",
784  tprof_bins,pe_y_min,pe_y_max);
785 
786  name = "tprof_truededx_pe_";
787  tprof_truededx_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
788  "X view;PE;True dE/dx (MeV/cm)",
789  tprof_bins,pe_y_min,pe_y_max);
790  tprof_truededx_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
791  "Y view;PE;True dE/dx (MeV/cm)",
792  tprof_bins,pe_y_min,pe_y_max);
793  name = "tprof_recodedx_pe_";
794  tprof_recodedx_pe_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
795  "X view;PE;Reco dE/dx (MeV/cm)",
796  tprof_bins,pe_y_min,pe_y_max);
797  tprof_recodedx_pe_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
798  "Y view;PE;Reco dE/dx (MeV/cm)",
799  tprof_bins,pe_y_min,pe_y_max);
800  name = "tprof_truededx_pecorr_";
801  tprof_truededx_pecorr_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
802  "X view;PECorr;True dE/dx (MeV/cm)",
803  tprof_bins,pe_y_min,pe_y_max);
804  tprof_truededx_pecorr_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
805  "Y view;PECorr;True dE/dx (MeV/cm)",
806  tprof_bins,pe_y_min,pe_y_max);
807  name = "tprof_recodedx_pecorr_";
808  tprof_recodedx_pecorr_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
809  "X view;PECorr;Reco dE/dx (MeV/cm)",
810  tprof_bins,pe_y_min,pe_y_max);
811  tprof_recodedx_pecorr_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
812  "Y view;PECorr;Reco dE/dx (MeV/cm)",
813  tprof_bins,pe_y_min,pe_y_max);
814  name = "tprof_pecorrpe_pecorr_";
815  tprof_pecorrpe_pecorr_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
816  "X view;PECorr;PECorr/PE",
817  tprof_bins,pe_y_min,pe_y_max);
818  tprof_pecorrpe_pecorr_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
819  "Y view;PECorr;PECorr/PE",
820  tprof_bins,pe_y_min,pe_y_max);
821 
822 
823  name = "tprof_truededx_x_";
824  tprof_truededx_x_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
825  "X view;Distance to End of Track;True dE/dx (MeV/cm)",
826  tprof_bins,0,track_end_max);
827  tprof_truededx_x_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
828  "Y view;Distance to End of Track;True dE/dx (MeV/cm)",
829  tprof_bins,0,track_end_max);
830  name = "tprof_recodedx_x_";
831  tprof_recodedx_x_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
832  "X view;Distance to End of Track;Reco dE/dx (MeV/cm)",
833  tprof_bins,0,track_end_max);
834  tprof_recodedx_x_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
835  "Y view;Distance to End of Track;Reco dE/dx (MeV/cm)",
836  tprof_bins,0,track_end_max);
837 
838  name = "tprof_truededx_dx_";
839  tprof_truededx_dx_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
840  "X view;Reco Path Length (cm);True dE/dx (MeV/cm)",
841  dxbins,dxmin,dxmax);
842  tprof_truededx_dx_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
843  "Y view;Reco Path Length (cm);True dE/dx (MeV/cm)",
844  dxbins,dxmin,dxmax);
845  name = "tprof_recodedx_dx_";
846  tprof_recodedx_dx_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
847  "X view;Reco Path Length (cm);Reco dE/dx (MeV/cm)",
848  dxbins,dxmin,dxmax);
849  tprof_recodedx_dx_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
850  "Y view;Reco Path Length (cm);Reco dE/dx (MeV/cm)",
851  dxbins,dxmin,dxmax);
852 
853  name = "tprof_truededx_cellpplane";
854  tprof_truededx_cellpplane_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
855  "X view;# of Cells Per Plane;True dE/dx (MeV/cm)",
856  10,0,10);
857  tprof_truededx_cellpplane_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
858  "Y view;# of Cells Per Plane;True dE/dx (MeV/cm)",
859  10,0,10);
860  name = "tprof_recodedx_cellpplane";
861  tprof_recodedx_cellpplane_xview[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
862  "X view;# of Cells Per Plane;Reco dE/dx (MeV/cm)",
863  10,0,10);
864  tprof_recodedx_cellpplane_yview[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
865  "Y view;# of Cells Per Plane;Reco dE/dx (MeV/cm)",
866  10,0,10);
867 
868  name = "tprof_pecorrmev_dE_";
869  tprof_pecorrmev_dE_xview_fb[i] = new TProfile(Form("%sxview%s",name.c_str(),fbtag.c_str()),
870  "PECorr/MeV vs True Energy Deposit (X view);True Energy Deposit (MeV);PECorr/MeV",
871  tprof_bins,3,25);
872  tprof_pecorrmev_dE_yview_fb[i] = new TProfile(Form("%syview%s",name.c_str(),fbtag.c_str()),
873  "PECorr/MeV vs True Energy Deposit (Y view);True Energy Deposit (MeV);PECorr/MeV",
874  tprof_bins,3,25);
875 
876 
877  name = "th1d_nhits_resp_";
878  th1d_nhits_resp_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
879  "Reconstructed Response (X View);PECorr/cm;",
880  tprof_bins,0,100);
881  th1d_nhits_resp_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
882  "Reconstructed Response (Y View);PECorr/cm;",
883  tprof_bins,0,100);
884 
885  name = "th1d_nhits_truededx_";
886  th1d_nhits_truededx_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
887  "True Response (X View);MeV/cm;",
888  tprof_bins,0,10);
889  th1d_nhits_truededx_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
890  "True Response (Y View);MeV/cm;",
891  tprof_bins,0,10);
892  name = "th1d_nhits_truedetruedx_";
893  th1d_nhits_truedetruedx_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
894  "True Response (X View);true MeV / true cm;",
895  tprof_bins,0,4);
896  th1d_nhits_truedetruedx_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
897  "True Response (Y View);true MeV / true cm;",
898  tprof_bins,0,4);
899  name = "th1d_nhits_recodedx_";
900  th1d_nhits_recodedx_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
901  "X View;Reco dE/dx (MeV/cm);",
902  tprof_bins,0,10);
903  th1d_nhits_recodedx_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
904  "Y View;Reco dE/dx (MeV/cm);",
905  tprof_bins,0,10);
906 
907  name = "th1d_nhits_pe_";
908  th1d_nhits_pe_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
909  "X View;PE;",
910  tprof_bins,0,450);
911  th1d_nhits_pe_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
912  "Y View;PE;",
913  tprof_bins,0,450);
914 
915  name = "th1d_nhits_pecm_";
916  th1d_nhits_pecm_xview_fb[i] = new TH1D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
917  "X View;PE/cm;",
918  tprof_bins,0,100);
919  th1d_nhits_pecm_yview_fb[i] = new TH1D(Form("%syview%s",name.c_str(),fbtag.c_str()),
920  "Y View;PE/cm;",
921  tprof_bins,0,100);
922 
923  name = "th2d_nhits_pecm-w_";
924  th2d_nhits_pecm_w_xview_fb[i] = new TH2D(Form("%sxview%s",name.c_str(),fbtag.c_str()),
925  "Number of X View Hits;Uncorrected Response (PE/cm);W (cm)",
926  tprof_bins, -wrange, wrange,
927  tprof_bins, pe_x_min, pe_x_max );
928  th2d_nhits_pecm_w_yview_fb[i] = new TH2D(Form("%syview%s",name.c_str(),fbtag.c_str()),
929  "Number of Y View Hits;Uncorrected Response (PE/cm);W (cm)",
930  tprof_bins, -wrange, wrange,
931  tprof_bins, pe_y_min, pe_y_max );
932  }
933 
934  std::cout << "...plots declared" << std::endl;
935 
936  const unsigned int nWslices = 8;
937  std::vector<float> minW; minW.resize(nWslices);
938  std::vector<float> maxW; maxW.resize(nWslices);
939  if(det=="nd"){
940  minW[0] = -201;
941  minW[1] = -150;
942  minW[2] = -100;
943  minW[3] = -50;
944  minW[4] = 0;
945  minW[5] = 50;
946  minW[6] = 100;
947  minW[7] = 150;
948  maxW[0] = -150;
949  maxW[1] = -100;
950  maxW[2] = -50;
951  maxW[3] = 0;
952  maxW[4] = 50;
953  maxW[5] = 100;
954  maxW[6] = 150;
955  maxW[7] = 200;
956  }
957  if(det=="fd"){
958  minW[0] = -800;
959  minW[1] = -600;
960  minW[2] = -400;
961  minW[3] = -200;
962  minW[4] = 0;
963  minW[5] = 200;
964  minW[6] = 400;
965  minW[7] = 600;
966  maxW[0] = -600;
967  maxW[1] = -400;
968  maxW[2] = -200;
969  maxW[3] = 0;
970  maxW[4] = 200;
971  maxW[5] = 400;
972  maxW[6] = 600;
973  maxW[7] = 800;
974  }
975 
976  std::vector< TProfile* > tprof_pe_truedE_xview_w; tprof_pe_truedE_xview_w.resize(nWslices);
977  std::vector< TProfile* > tprof_pe_truedE_yview_w; tprof_pe_truedE_yview_w.resize(nWslices);
978  for(unsigned int i=0; i<nWslices; i++){
979 
980  tprof_pe_truedE_xview_w[i] = new TProfile(Form("tprof_pe_truedE_xview_w.%i.%i",(int)(minW[i]),(int)(maxW[i])),
981  Form("Threshold Effect, W = %i to %i;PE;True Deposition (MeV)",
982  (int)(minW[i]),(int)(maxW[i])),
983  tprof_bins,0,40);
984  tprof_pe_truedE_yview_w[i] = new TProfile(Form("tprof_pe_truedE_yview_w.%i.%i",(int)(minW[i]),(int)(maxW[i])),
985  Form("Threshold Effect, W = %i to %i;PE;True Deposition (MeV)",
986  (int)(minW[i]),(int)(maxW[i])),
987  tprof_bins,0,40);
988  }
989 
990 
991  ///////////////////////////////////////////////////////////////////
992  ///////////////////////////////////////////////////////////////////
993  ////////////////// //////////////////
994  ////////////////// Loop through TTree entries //////////////////
995  ////////////////// //////////////////
996  ///////////////////////////////////////////////////////////////////
997  ///////////////////////////////////////////////////////////////////
998  unsigned int n = t->GetEntries();
999  unsigned int n_zero_true_path=0;
1000  unsigned int n_zero_path=0;
1001  unsigned int n_zero_PEc=0;
1002  unsigned int n_neg_PEc=0;
1003  unsigned int n_zero_trueE=0;
1004  unsigned int n_track_window_hits=0;
1005  unsigned int n_nonmuon_hits=0;
1006  //if (n > 10e6) n = 10e6;
1007  if (n > maxEntries) n = maxEntries;
1008  std::cout << "~~~~ looping through "
1009  << n << " TTree entries ~~~~"
1010  << std::endl;
1011  for( unsigned int e=0; e<n; e++ ){
1012  t->GetEntry(e);
1013 
1014  if(tree_i==1||tree_i==3){
1015  if(view==0) w=ypos;
1016  if(view==1) w=xpos;
1017  dcosz = zDir / std::sqrt(xDir*xDir + yDir*yDir + zDir*zDir);
1018  dcosy = yDir / std::sqrt(xDir*xDir + yDir*yDir + zDir*zDir);
1019  }
1020 
1021  if(tree_i==0){
1022  cell = (int)(cell_fl);
1023  plane = (int)(plane_fl);
1024  fbBin = (int)(fbBin_fl);
1025  }
1026 
1027  // gev-->mev
1028  if(tree_i!=0) trueE = 1000*trueE;
1029  float recoMeV = 1000*recoGeV;
1030  // this sample is negative??
1031  //if (sample.find("traj")!=std::string::npos) recoMeV = -1*recoMeV;
1032 
1033  // FD MC real conditions is different??
1034  //recoMeV = -1*recoGeV;
1035 
1036  if(view==0){
1037  th2d_nhits_dE_pe_xview->Fill(PE,trueE);
1038  }else{
1039  th2d_nhits_dE_pe_yview->Fill(PE,trueE);
1040  }
1041 
1042  if(e%1000000==0) std::cout << e << " / " << n << std::endl;
1043 
1044  // be careful -- inside or outside of track window cut
1045  //if( path <= 0 ) std::cout << "path = " << path << std::endl;
1046  //if( PE <= 0 ) std::cout << "PE = " << PE << std::endl;
1047  //if( true_path <= 0 && isMC ) n_zero_true_path++;
1048 
1049  int bin=fbBin;
1050  int all=nFBbins;
1051  if(bin<0||nFBbins-1<(unsigned int)bin) bin=0;
1052 
1053 
1054  // First fill things regardless of track window
1055  // -For very few things. better to just have same cut on all plots for one run
1056  // so it doesn't have to be constantly referenced which has what cut
1057  // -Just fill "nowindow" plots and track window plot
1058  if(view==0){
1059  th2d_nhits_truededx_w_xview_nowindow_fb [bin]->Fill( w, trueE/path );
1060  th2d_nhits_truededx_w_xview_nowindow_fb [all]->Fill( w, trueE/path );
1061  tprof_truededx_x_xview [bin]->Fill( x, trueE/path );
1062  tprof_truededx_x_xview [all]->Fill( x, trueE/path );
1063  tprof_recodedx_x_xview [bin]->Fill( x, recoMeV/path );
1064  tprof_recodedx_x_xview [all]->Fill( x, recoMeV/path );
1065  } else {
1066  th2d_nhits_truededx_w_yview_nowindow_fb [bin]->Fill( w, trueE/path );
1067  th2d_nhits_truededx_w_yview_nowindow_fb [all]->Fill( w, trueE/path );
1068  tprof_truededx_x_yview [bin]->Fill( x, trueE/path );
1069  tprof_truededx_x_yview [all]->Fill( x, trueE/path );
1070  tprof_recodedx_x_yview [bin]->Fill( x, recoMeV/path );
1071  tprof_recodedx_x_yview [all]->Fill( x, recoMeV/path );
1072  }
1073 
1074  bool inTrackWindow = cut_Track_Window(x);
1075  if( inTrackWindow
1076  && PECorr > 0. // Calibrator returns -1 for hits in uncalibrated cells
1077  && cut_W(w)
1078  && cut_PE(PE)
1079  && cut_trueE(trueE)
1080  && cut_Cell(cell)
1081  && cut_cells_per_plane(cells_per_plane,tree_i) ){
1082  n_track_window_hits++;
1083 
1084  if(std::abs(pdg)!=13) n_nonmuon_hits++;
1085 
1086  if(PECorr==0.){
1087  n_zero_PEc++;
1088  }
1089  if(PECorr<=0.){
1090  n_neg_PEc++;
1091  //std::cout << PECorr << std::endl;
1092  }
1093  if(trueE<=0.){
1094  n_zero_trueE++;
1095  }
1096  if(path<=0.){
1097  n_zero_path++;
1098  }
1099 
1100 
1101  // flat W cuts for Absolute Calibration
1102  if( (view==0 && flatW_x_min < w && w < flatW_x_max) ||
1103  (view==1 && flatW_y_min < w && w < flatW_y_max) ){
1104  th1d_nhits_resp_flatW ->Fill(PECorr/path);
1105  th1d_nhits_truededx_flatW->Fill(trueE/path);
1106  }
1107  if(view==0 && flatW_x_min < w && w < flatW_x_max){
1108  th1d_nhits_resp_flatW_xview ->Fill(PECorr/path);
1109  th1d_nhits_truededx_flatW_xview->Fill(trueE/path);
1110  th1d_nhits_recodedx_flatW_xview->Fill(recoMeV/path);
1111  }
1112  if(view==1 && flatW_y_min < w && w < flatW_y_max){
1113  th1d_nhits_resp_flatW_yview ->Fill(PECorr/path);
1114  th1d_nhits_truededx_flatW_yview->Fill(trueE/path);
1115  th1d_nhits_recodedx_flatW_yview->Fill(recoMeV/path);
1116  }
1117 
1118  int wbin=-1;
1119  for(unsigned int j=0; j<nWslices; j++)
1120  if( minW[j]<=w && w<=maxW[j] )
1121  wbin=j;
1122  //if(wbin<0)
1123  //std::cout << "W = " << w << " not in a bin." << std::endl;
1124 
1125 
1126  tprof_resp_fbbin->Fill(bin,PECorr/path);
1127  tprof_pecm_fbbin->Fill(bin,PE/path);
1128 
1129  tprof2_pecm_cell_plane->Fill(plane,cell,PE/path);
1130 
1131  if(view==0){
1132 
1133  th1d_nhits_resp_xview_fb[bin] ->Fill(PECorr/path);
1134  th1d_nhits_resp_xview_fb[all] ->Fill(PECorr/path);
1135  th1d_nhits_truededx_xview_fb[bin] ->Fill(trueE/path);
1136  th1d_nhits_truededx_xview_fb[all] ->Fill(trueE/path);
1137  th1d_nhits_truedetruedx_xview_fb[bin] ->Fill(trueE/true_path);
1138  th1d_nhits_truedetruedx_xview_fb[all] ->Fill(trueE/true_path);
1139  th1d_nhits_recodedx_xview_fb[bin] ->Fill(recoMeV/path);
1140  th1d_nhits_recodedx_xview_fb[all] ->Fill(recoMeV/path);
1141  th1d_nhits_pecm_xview_fb[bin] ->Fill(PE/path);
1142  th1d_nhits_pecm_xview_fb[all] ->Fill(PE/path);
1143  th1d_nhits_pe_xview_fb[bin] ->Fill(PE);
1144  th1d_nhits_pe_xview_fb[all] ->Fill(PE);
1145 
1146  tprof_resp_fbbin_xview->Fill(bin,PECorr/path);
1147  tprof_pecm_fbbin_xview->Fill(bin,PE/path);
1148  tprof_pecm_plane_xview->Fill(plane,PE/path);
1149 
1150  th1d_nhits_dcosz_xview->Fill(dcosz);
1151  th1d_nhits_dcosy_xview->Fill(dcosy);
1152  tprof_recodedx_dcosz_xview->Fill(dcosz,recoMeV/path);
1153  tprof_truededx_dcosz_xview->Fill(dcosz,trueE/path);
1154  tprof_recodedx_dcosy_xview->Fill(dcosy,recoMeV/path);
1155  tprof_truededx_dcosy_xview->Fill(dcosy,trueE/path);
1156  tprof_dx_dcosz_xview->Fill(dcosz,path);
1157  tprof_dx_dcosy_xview->Fill(dcosy,path);
1158 
1159 
1160  tprof2_resp_cell_plane_xview->Fill(plane,cell,PECorr/path);
1161  tprof2_pecm_cell_plane_xview->Fill(plane,cell,PE/path);
1162  th1d_nhits_truedx_xview->Fill(true_path);
1163  th1d_nhits_dx_xview->Fill(path);
1164  th1d_nhits_dE_xview->Fill(trueE);
1165  tprof_pecm_cell_xview ->Fill(cell, PE/path);
1166  tprof_resp_cell_xview ->Fill(cell, PECorr/path);
1167  tprof_resp_plane_xview ->Fill(plane, PECorr/path);
1168  tprof2_resp_w_cell_xview ->Fill(cell,w,PECorr/path);
1169  th2d_nhits_cell_w_xview->Fill(cell,w);
1170  th2d_nhits_dx_recodedx_xview->Fill(path,recoMeV/path);
1171  th2d_nhits_dx_truededx_xview->Fill(path,trueE/path);
1172  tprof_resp_dx_xview->Fill(path,PECorr/path);
1173  if(true_path>0.){
1174  tprof_recotruedx_truedx_xview->Fill(true_path,path/true_path);
1175  tprof_dxres_truedx_xview->Fill(true_path,(path-true_path)/true_path);
1176  tprof_dxres_w_xview->Fill(w,(path-true_path)/true_path);
1177  }
1178 
1179  th1d_nhits_w_xview_fb [bin]->Fill( w );
1180  th1d_nhits_w_xview_fb [all]->Fill( w );
1181  th2d_nhits_truededx_w_xview_fb[bin]->Fill( w, trueE/path );
1182  th2d_nhits_truededx_w_xview_fb[all]->Fill( w, trueE/path );
1183  //th2d_nhits_recodedx_w_xview_fb[bin]->Fill( w, recoMeV/path );
1184  //th2d_nhits_recodedx_w_xview_fb[all]->Fill( w, recoMeV/path );
1185  tprof_resp_w_xview_fb [bin]->Fill( w, PECorr/path );
1186  tprof_resp_w_xview_fb [all]->Fill( w, PECorr/path );
1187  tprof_pecm_w_xview [bin]->Fill( w, PE/path );
1188  tprof_pecm_w_xview [all]->Fill( w, PE/path );
1189  tprof_pe_w_xview [bin]->Fill( w, PE );
1190  tprof_pe_w_xview [all]->Fill( w, PE );
1191  tprof_truededx_w_xview [bin]->Fill( w, trueE/path );
1192  tprof_truededx_w_xview [all]->Fill( w, trueE/path );
1193  tprof_recodedx_w_xview [bin]->Fill( w, recoMeV/path );
1194  tprof_recodedx_w_xview [all]->Fill( w, recoMeV/path );
1195  tprof_dx_w_xview [bin]->Fill( w, path );
1196  tprof_dx_w_xview [all]->Fill( w, path );
1197  tprof_truededx_dx_xview [bin]->Fill( path, trueE/path );
1198  tprof_truededx_dx_xview [all]->Fill( path, trueE/path );
1199  tprof_recodedx_dx_xview [bin]->Fill( path, recoMeV/path );
1200  tprof_recodedx_dx_xview [all]->Fill( path, recoMeV/path );
1201  tprof_truededx_cellpplane_xview[bin]->Fill( cells_per_plane, trueE/path );
1202  tprof_truededx_cellpplane_xview[all]->Fill( cells_per_plane, trueE/path );
1203  tprof_recodedx_cellpplane_xview[bin]->Fill( cells_per_plane, recoMeV/path );
1204  tprof_recodedx_cellpplane_xview[all]->Fill( cells_per_plane, recoMeV/path );
1205  tprof_pecorrpe_w_xview_fb [bin]->Fill( w, PECorr/PE );
1206  tprof_pecorrpe_w_xview_fb [all]->Fill( w, PECorr/PE );
1207  tprof_pecorrmev_w_xview_fb [bin]->Fill( w, PECorr/trueE );
1208  tprof_pecorrmev_w_xview_fb [all]->Fill( w, PECorr/trueE );
1209  th2d_nhits_pecm_w_xview_fb [bin]->Fill( w, PE/path );
1210  th2d_nhits_pecm_w_xview_fb [all]->Fill( w, PE/path );
1211  if( w<w_y_cut_max && w>w_y_cut_min ){
1212  tprof_resp_pe_xview_fb [bin]->Fill( PE, PECorr/path );
1213  tprof_resp_pe_xview_fb [all]->Fill( PE, PECorr/path );
1214  tprof_pecorr_pe_xview_fb [bin]->Fill( PE, PECorr );
1215  tprof_pecorr_pe_xview_fb [all]->Fill( PE, PECorr );
1216  tprof_pecorrmev_pe_xview_fb [bin]->Fill( PE, PECorr/trueE );
1217  tprof_pecorrmev_pe_xview_fb [all]->Fill( PE, PECorr/trueE );
1218  tprof_pecorrmev_dE_xview_fb [bin]->Fill( trueE, PECorr/trueE );
1219  tprof_pecorrmev_dE_xview_fb [all]->Fill( trueE, PECorr/trueE );
1220  tprof_pecorrpe_pe_xview_fb [bin]->Fill( PE, PECorr/PE );
1221  tprof_pecorrpe_pe_xview_fb [all]->Fill( PE, PECorr/PE );
1222  tprof_truededx_pe_xview_fb [bin]->Fill( PE, trueE/path );
1223  tprof_truededx_pe_xview_fb [all]->Fill( PE, trueE/path );
1224  tprof_recodedx_pe_xview_fb [bin]->Fill( PE, recoMeV/path );
1225  tprof_recodedx_pe_xview_fb [all]->Fill( PE, recoMeV/path );
1226  tprof_truededx_pecorr_xview_fb [bin]->Fill( PECorr, trueE/path );
1227  tprof_truededx_pecorr_xview_fb [all]->Fill( PECorr, trueE/path );
1228  tprof_recodedx_pecorr_xview_fb [bin]->Fill( PECorr, recoMeV/path );
1229  tprof_recodedx_pecorr_xview_fb [all]->Fill( PECorr, recoMeV/path );
1230  tprof_pecorrpe_pecorr_xview_fb [bin]->Fill( PECorr, PECorr/PE );
1231  tprof_pecorrpe_pecorr_xview_fb [all]->Fill( PECorr, PECorr/PE );
1232  }
1233  if((cell+1)%16==0 || (cell)%16==0){
1234  tprof_resp_w_xview_edgecells_fb[bin]->Fill( w, PECorr/path );
1235  tprof_resp_w_xview_edgecells_fb[all]->Fill( w, PECorr/path );
1236  }
1237 
1238  if(wbin>=0) tprof_pe_truedE_xview_w[wbin]->Fill(w,PE);
1239 
1240  } else if (view==1) {
1241 
1242 
1243  th1d_nhits_resp_yview_fb[bin] ->Fill(PECorr/path);
1244  th1d_nhits_resp_yview_fb[all] ->Fill(PECorr/path);
1245  th1d_nhits_truededx_yview_fb[bin] ->Fill(trueE/path);
1246  th1d_nhits_truededx_yview_fb[all] ->Fill(trueE/path);
1247  th1d_nhits_truedetruedx_yview_fb[bin] ->Fill(trueE/path);
1248  th1d_nhits_truedetruedx_yview_fb[all] ->Fill(trueE/path);
1249  th1d_nhits_recodedx_yview_fb[bin] ->Fill(recoMeV/path);
1250  th1d_nhits_recodedx_yview_fb[all] ->Fill(recoMeV/path);
1251  th1d_nhits_pecm_yview_fb[bin] ->Fill(PE/path);
1252  th1d_nhits_pecm_yview_fb[all] ->Fill(PE/path);
1253  th1d_nhits_pe_yview_fb[bin] ->Fill(PE);
1254  th1d_nhits_pe_yview_fb[all] ->Fill(PE);
1255 
1256  tprof_resp_fbbin_yview->Fill(bin,PECorr/path);
1257  tprof_pecm_fbbin_yview->Fill(bin,PE/path);
1258  tprof_pecm_plane_yview->Fill(plane,PE/path);
1259 
1260  th1d_nhits_dcosz_yview->Fill(dcosz);
1261  th1d_nhits_dcosy_yview->Fill(dcosy);
1262  tprof_recodedx_dcosz_yview->Fill(dcosz,recoMeV/path);
1263  tprof_truededx_dcosz_yview->Fill(dcosz,trueE/path);
1264  tprof_recodedx_dcosy_yview->Fill(dcosy,recoMeV/path);
1265  tprof_truededx_dcosy_yview->Fill(dcosy,trueE/path);
1266  tprof_dx_dcosz_yview->Fill(dcosz,path);
1267  tprof_dx_dcosy_yview->Fill(dcosy,path);
1268 
1269 
1270  tprof2_resp_cell_plane_yview->Fill(plane,cell,PECorr/path);
1271  tprof2_pecm_cell_plane_yview->Fill(plane,cell,PE/path);
1272  th1d_nhits_truedx_yview->Fill(true_path);
1273  th1d_nhits_dx_yview->Fill(path);
1274  th1d_nhits_dE_yview->Fill(trueE);
1275  tprof_pecm_cell_yview ->Fill(cell, PE/path);
1276  tprof_resp_cell_yview ->Fill(cell, PECorr/path);
1277  tprof_resp_plane_yview ->Fill(plane, PECorr/path);
1278  tprof2_resp_cell_w_yview ->Fill(w,cell,PECorr/path);
1279  th2d_nhits_w_cell_yview ->Fill(w,cell);
1280  th2d_nhits_dx_recodedx_yview->Fill(path,recoMeV/path);
1281  th2d_nhits_dx_truededx_yview->Fill(path,trueE/path);
1282  tprof_resp_dx_yview->Fill(path,PECorr/path);
1283  if(true_path>0.){
1284  tprof_recotruedx_truedx_yview->Fill(true_path,path/true_path);
1285  tprof_dxres_truedx_yview->Fill(true_path,(path-true_path)/true_path);
1286  tprof_dxres_w_yview->Fill(w,(path-true_path)/true_path);
1287  }
1288 
1289  th1d_nhits_w_yview_fb [bin]->Fill( w );
1290  th1d_nhits_w_yview_fb [all]->Fill( w );
1291  th2d_nhits_truededx_w_yview_fb[bin]->Fill( w, trueE/path );
1292  th2d_nhits_truededx_w_yview_fb[all]->Fill( w, trueE/path );
1293  tprof_resp_w_yview_fb [bin]->Fill( w, PECorr/path );
1294  tprof_resp_w_yview_fb [all]->Fill( w, PECorr/path );
1295  tprof_pecm_w_yview [bin]->Fill( w, PE/path );
1296  tprof_pecm_w_yview [all]->Fill( w, PE/path );
1297  tprof_pe_w_yview [bin]->Fill( w, PE );
1298  tprof_pe_w_yview [all]->Fill( w, PE );
1299  tprof_truededx_w_yview [bin]->Fill( w, trueE/path );
1300  tprof_truededx_w_yview [all]->Fill( w, trueE/path );
1301  tprof_recodedx_w_yview [bin]->Fill( w, recoMeV/path );
1302  tprof_recodedx_w_yview [all]->Fill( w, recoMeV/path );
1303  tprof_dx_w_yview [bin]->Fill( w, path );
1304  tprof_dx_w_yview [all]->Fill( w, path );
1305  tprof_truededx_dx_yview [bin]->Fill( path, trueE/path );
1306  tprof_truededx_dx_yview [all]->Fill( path, trueE/path );
1307  tprof_recodedx_dx_yview [bin]->Fill( path, recoMeV/path );
1308  tprof_recodedx_dx_yview [all]->Fill( path, recoMeV/path );
1309  tprof_truededx_cellpplane_yview[bin]->Fill( cells_per_plane, trueE/path );
1310  tprof_truededx_cellpplane_yview[all]->Fill( cells_per_plane, trueE/path );
1311  tprof_recodedx_cellpplane_yview[bin]->Fill( cells_per_plane, recoMeV/path );
1312  tprof_recodedx_cellpplane_yview[all]->Fill( cells_per_plane, recoMeV/path );
1313  tprof_pecorrpe_w_yview_fb [bin]->Fill( w, PECorr/PE );
1314  tprof_pecorrpe_w_yview_fb [all]->Fill( w, PECorr/PE );
1315  tprof_pecorrmev_w_yview_fb [bin]->Fill( w, PECorr/trueE );
1316  tprof_pecorrmev_w_yview_fb [all]->Fill( w, PECorr/trueE );
1317  th2d_nhits_pecm_w_yview_fb [bin]->Fill( w, PE/path );
1318  th2d_nhits_pecm_w_yview_fb [all]->Fill( w, PE/path );
1319  if( w<w_y_cut_max && w>w_y_cut_min ){
1320  tprof_resp_pe_yview_fb [bin]->Fill( PE, PECorr/path );
1321  tprof_resp_pe_yview_fb [all]->Fill( PE, PECorr/path );
1322  tprof_pecorr_pe_yview_fb [bin]->Fill( PE, PECorr );
1323  tprof_pecorr_pe_yview_fb [all]->Fill( PE, PECorr );
1324  tprof_pecorrmev_pe_yview_fb [bin]->Fill( PE, PECorr/trueE );
1325  tprof_pecorrmev_pe_yview_fb [all]->Fill( PE, PECorr/trueE );
1326  tprof_pecorrmev_dE_yview_fb [bin]->Fill( trueE, PECorr/trueE );
1327  tprof_pecorrmev_dE_yview_fb [all]->Fill( trueE, PECorr/trueE );
1328  tprof_pecorrpe_pe_yview_fb [bin]->Fill( PE, PECorr/PE );
1329  tprof_pecorrpe_pe_yview_fb [all]->Fill( PE, PECorr/PE );
1330  tprof_truededx_pe_yview_fb [bin]->Fill( PE, trueE/path );
1331  tprof_truededx_pe_yview_fb [all]->Fill( PE, trueE/path );
1332  tprof_recodedx_pe_yview_fb [bin]->Fill( PE, recoMeV/path );
1333  tprof_recodedx_pe_yview_fb [all]->Fill( PE, recoMeV/path );
1334  tprof_truededx_pecorr_yview_fb [bin]->Fill( PECorr, trueE/path );
1335  tprof_truededx_pecorr_yview_fb [all]->Fill( PECorr, trueE/path );
1336  tprof_recodedx_pecorr_yview_fb [bin]->Fill( PECorr, recoMeV/path );
1337  tprof_recodedx_pecorr_yview_fb [all]->Fill( PECorr, recoMeV/path );
1338  tprof_pecorrpe_pecorr_yview_fb [bin]->Fill( PECorr, PECorr/PE );
1339  tprof_pecorrpe_pecorr_yview_fb [all]->Fill( PECorr, PECorr/PE );
1340  }
1341  if((cell+1)%16==0 || (cell)%16==0){
1342  tprof_resp_w_yview_edgecells_fb[bin]->Fill( w, PECorr/path );
1343  tprof_resp_w_yview_edgecells_fb[all]->Fill( w, PECorr/path );
1344  }
1345 
1346 
1347  if(wbin>=0) tprof_pe_truedE_yview_w[wbin]->Fill(w,PE);
1348  }
1349  else { std::cout << "unknown view" << std::endl; }
1350 
1351  }
1352 
1353  } // ttree loop
1354 
1355  std::cout << "# hits passing track window, w, and cell cuts: " << n_track_window_hits << std::endl;
1356  std::cout << "# hits which were not from muons: " << n_nonmuon_hits << std::endl;
1357 
1358  if(n_zero_true_path!=0)
1359  std::cout << "truepath was nonpositive " << n_zero_true_path << " times" << std::endl;
1360  //if(n_zero_path!=0)
1361  std::cout << "path was nonpositive " << n_zero_path << " times" << std::endl;
1362  //if(n_zero_PEc!=0)
1363  std::cout << "PECorr was zero " << n_zero_PEc << " times" << std::endl;
1364  std::cout << "PECorr was negative " << n_neg_PEc << " times" << std::endl;
1365  //if(n_zero_trueE!=0)
1366  std::cout << "trueE was nonpositive " << n_zero_trueE << " times" << std::endl;
1367 
1368 
1369  th1d_nhits_resp_flatW->Write();
1370  th1d_nhits_resp_flatW_xview->Write();
1371  th1d_nhits_resp_flatW_yview->Write();
1372  th1d_nhits_recodedx_flatW_xview->Write();
1373  th1d_nhits_recodedx_flatW_yview->Write();
1374 
1375  tprof_pecm_plane_xview->Write();
1376  tprof_pecm_plane_yview->Write();
1377 
1378  th1d_nhits_dcosz_xview->Write(); th1d_nhits_dcosz_yview->Write();
1379  th1d_nhits_dcosy_xview->Write(); th1d_nhits_dcosy_yview->Write();
1380  tprof_recodedx_dcosz_xview->Write(); tprof_recodedx_dcosz_yview->Write();
1381  tprof_truededx_dcosz_xview->Write(); tprof_truededx_dcosz_yview->Write();
1382  tprof_recodedx_dcosy_xview->Write(); tprof_recodedx_dcosy_yview->Write();
1383  tprof_truededx_dcosy_xview->Write(); tprof_truededx_dcosy_yview->Write();
1384  tprof_dx_dcosz_xview->Write(); tprof_dx_dcosz_yview->Write();
1385  tprof_dx_dcosy_xview->Write(); tprof_dx_dcosy_yview->Write();
1386 
1387  th1d_nhits_dx_xview->Write();
1388  th1d_nhits_dx_yview->Write();
1389  tprof2_resp_cell_plane_xview->Write();
1390  tprof2_resp_cell_plane_yview->Write();
1391  tprof_pecm_cell_xview->Write();
1392  tprof_pecm_cell_yview->Write();
1393  tprof_resp_cell_xview->Write();
1394  tprof_resp_cell_yview->Write();
1395  tprof_resp_plane_xview->Write();
1396  tprof_resp_plane_yview->Write();
1397  tprof2_resp_w_cell_xview->Write();
1398  tprof2_resp_cell_w_yview->Write();
1399  th2d_nhits_cell_w_xview->Write();
1400  th2d_nhits_w_cell_yview->Write();
1401  th2d_nhits_dx_recodedx_xview->Write();
1402  th2d_nhits_dx_truededx_xview->Write();
1403  th2d_nhits_dx_recodedx_yview->Write();
1404  th2d_nhits_dx_truededx_yview->Write();
1405  tprof2_pecm_cell_plane_xview->Write();
1406  tprof2_pecm_cell_plane_yview->Write();
1407  tprof2_pecm_cell_plane->Write();
1408  tprof_resp_fbbin->Write();
1409  tprof_pecm_fbbin->Write();
1410  tprof_resp_fbbin_xview->Write();
1411  tprof_pecm_fbbin_xview->Write();
1412  tprof_resp_fbbin_yview->Write();
1413  tprof_pecm_fbbin_yview->Write();
1414  tprof_resp_dx_xview->Write();
1415  tprof_resp_dx_yview->Write();
1416 
1417  if(isMC){
1418  th2d_nhits_dE_pe_xview->Write();
1419  th2d_nhits_dE_pe_yview->Write();
1420  th1d_nhits_truedx_xview->Write();
1421  th1d_nhits_truedx_yview->Write();
1422  th1d_nhits_truededx_flatW->Write();
1423  th1d_nhits_truededx_flatW_xview->Write();
1424  th1d_nhits_truededx_flatW_yview->Write();
1425  tprof_recotruedx_truedx_xview->Write();
1426  tprof_recotruedx_truedx_yview->Write();
1427  tprof_dxres_truedx_xview->Write();
1428  tprof_dxres_truedx_yview->Write();
1429  tprof_dxres_w_xview->Write();
1430  tprof_dxres_w_yview->Write();
1431  th1d_nhits_dE_xview->Write();
1432  th1d_nhits_dE_yview->Write();
1433  }
1434 
1435  for(unsigned int b=0; b<nFBbins+1; b++){
1436  // vs W
1437  th1d_nhits_w_xview_fb[b]->Write();
1438  th1d_nhits_w_yview_fb[b]->Write();
1439  tprof_resp_w_xview_edgecells_fb[b]->Write();
1440  tprof_resp_w_yview_edgecells_fb[b]->Write();
1441  tprof_resp_w_xview_fb[b]->Write();
1442  tprof_resp_w_yview_fb[b]->Write();
1443  tprof_pecm_w_xview[b]->Write();
1444  tprof_pecm_w_yview[b]->Write();
1445  tprof_recodedx_w_xview[b]->Write();
1446  tprof_recodedx_w_yview[b]->Write();
1447  tprof_pe_w_xview[b]->Write();
1448  tprof_pe_w_yview[b]->Write();
1449  tprof_dx_w_xview[b]->Write();
1450  tprof_dx_w_yview[b]->Write();
1451  tprof_pecorrpe_w_xview_fb[b]->Write();
1452  tprof_pecorrpe_w_yview_fb[b]->Write();
1453  // vs PE
1454  tprof_resp_pe_xview_fb[b]->Write();
1455  tprof_resp_pe_yview_fb[b]->Write();
1456  tprof_pecorr_pe_xview_fb[b]->Write();
1457  tprof_pecorr_pe_yview_fb[b]->Write();
1458  tprof_pecorrpe_pe_xview_fb[b]->Write();
1459  tprof_pecorrpe_pe_yview_fb[b]->Write();
1460  tprof_recodedx_pe_xview_fb[b]->Write();
1461  tprof_recodedx_pe_yview_fb[b]->Write();
1462  // vs PECor
1463  tprof_recodedx_pecorr_xview_fb[b]->Write();
1464  tprof_recodedx_pecorr_yview_fb[b]->Write();
1465  tprof_pecorrpe_pecorr_xview_fb[b]->Write();
1466  tprof_pecorrpe_pecorr_yview_fb[b]->Write();
1467  // vs x
1468  tprof_recodedx_x_xview[b]->Write();
1469  tprof_recodedx_x_yview[b]->Write();
1470  // vs dx, pathlength
1471  tprof_recodedx_dx_xview[b]->Write();
1472  tprof_recodedx_dx_yview[b]->Write();
1473  // vs cells per plane
1474  tprof_recodedx_cellpplane_xview[b]->Write();
1475  tprof_recodedx_cellpplane_yview[b]->Write();
1476  // vs FB
1477  th1d_nhits_resp_xview_fb[b]->Write();
1478  th1d_nhits_resp_yview_fb[b]->Write();
1479  th1d_nhits_recodedx_xview_fb[b]->Write();
1480  th1d_nhits_recodedx_yview_fb[b]->Write();
1481  th1d_nhits_pecm_xview_fb[b]->Write();
1482  th1d_nhits_pecm_yview_fb[b]->Write();
1483  th1d_nhits_pe_xview_fb[b]->Write();
1484  th1d_nhits_pe_yview_fb[b]->Write();
1485  // Other
1486  th2d_nhits_pecm_w_xview_fb[b]->Write();
1487  th2d_nhits_pecm_w_yview_fb[b]->Write();
1488 
1489  if(isMC){
1490  th2d_nhits_truededx_w_xview_fb[b]->Write();
1491  th2d_nhits_truededx_w_yview_fb[b]->Write();
1492  th2d_nhits_truededx_w_xview_nowindow_fb[b]->Write();
1493  th2d_nhits_truededx_w_yview_nowindow_fb[b]->Write();
1494  tprof_truededx_w_xview[b]->Write();
1495  tprof_truededx_w_yview[b]->Write();
1496  tprof_pecorrmev_w_xview_fb[b]->Write();
1497  tprof_pecorrmev_w_yview_fb[b]->Write();
1498  tprof_pecorrmev_pe_xview_fb[b]->Write();
1499  tprof_pecorrmev_pe_yview_fb[b]->Write();
1500  tprof_truededx_pe_xview_fb[b]->Write();
1501  tprof_truededx_pe_yview_fb[b]->Write();
1502  tprof_truededx_pecorr_xview_fb[b]->Write();
1503  tprof_truededx_pecorr_yview_fb[b]->Write();
1504  tprof_pecorrmev_dE_xview_fb[b]->Write();
1505  tprof_pecorrmev_dE_yview_fb[b]->Write();
1506  tprof_truededx_x_xview[b]->Write();
1507  tprof_truededx_x_yview[b]->Write();
1508  tprof_truededx_dx_xview[b]->Write();
1509  tprof_truededx_dx_yview[b]->Write();
1510  tprof_truededx_cellpplane_xview[b]->Write();
1511  tprof_truededx_cellpplane_yview[b]->Write();
1512  th1d_nhits_truededx_xview_fb[b]->Write();
1513  th1d_nhits_truededx_yview_fb[b]->Write();
1514  th1d_nhits_truedetruedx_xview_fb[b]->Write();
1515  th1d_nhits_truedetruedx_yview_fb[b]->Write();
1516  }
1517  }
1518 
1519  for(unsigned int wb=0; wb<nWslices; wb++){
1520  if(isMC){
1521  tprof_pe_truedE_xview_w[wb]->Write();
1522  tprof_pe_truedE_yview_w[wb]->Write();
1523  }
1524  }
1525 
1526  outf->Close();
1527 }
1528 
1529 #endif
const XML_Char * name
Definition: expat.h:151
bool cut_PE(double pe)
Definition: plot_abstree.C:44
bool cut_Cell(int c)
Definition: plot_abstree.C:62
T sqrt(T number)
Definition: d0nt_math.hpp:156
bool cut_W(double w)
Definition: plot_abstree.C:28
float abs(float number)
Definition: d0nt_math.hpp:39
bool cut_cells_per_plane(int ncells, int tree_i)
Definition: plot_abstree.C:22
void plot_abstree(std::string sample, std::string analysis, std::string disk="/nova/ana/users/talion/")
Definition: plot_abstree.C:69
TFile * outf
Definition: testXsec.C:51
const double j
Definition: BetheBloch.cxx:29
float bin[41]
Definition: plottest35.C:14
bool cut_Track_Window(double x)
Definition: plot_abstree.C:17
OStream cout
Definition: OStream.cxx:6
const std::string path
Definition: plot_BEN.C:43
const hit & b
Definition: hits.cxx:21
int ncells
Definition: geom.C:124
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
bool cut_trueE(double trueE)
Definition: plot_abstree.C:57
enum BeamMode string