Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Read_bcal_hadronic_eff2.C
Go to the documentation of this file.
1 #define Read_bcal_hadronic_eff2_cxx
2 // The class definition in Read_bcal_hadronic_eff2.h has been generated automatically
3 // by the ROOT utility TTree::MakeSelector(). This class is derived
4 // from the ROOT class TSelector. For more information on the TSelector
5 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
6 
7 // The following methods are defined in this file:
8 // Begin(): called every time a loop on the tree starts,
9 // a convenient place to create your histograms.
10 // SlaveBegin(): called after Begin(), when on PROOF called only on the
11 // slave servers.
12 // Process(): called for each event, in this function you decide what
13 // to read and fill your histograms.
14 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
15 // called only on the slave servers.
16 // Terminate(): called at the end of the loop on the tree,
17 // a convenient place to draw/fit your histograms.
18 //
19 // To use this file, try the following session on your Tree T:
20 //
21 // Root > T->Process("Read_bcal_hadronic_eff2.C")
22 // Root > T->Process("Read_bcal_hadronic_eff2.C","some options")
23 // Root > T->Process("Read_bcal_hadronic_eff2.C+")
24 //
25 // Example:
26 //
27 // Bcal_hadronic_eff>root -l tree_hadronic_eff_010492_apr4.root
28 // root [1] bcal_hadronic_eff->Process("Read_bcal_hadronic_eff2.C","010492_apr4 1") Note: TString option = "010492_apr4 1", encodes "filerun layer". Note filerun should be consistent with input file name.
29 //
30 // Note: script depends on the following parameters, set at the start of the script
31 // layer - layer to be plotted - now taken from option (optional argument)
32 // coinc_cut - difference between tracking position and sector allowed for a match
33 // filerun - run number or designation used for output: output filename = "R"+filerun+"_layer"+TString::Itoa(layer,10)+"_cut"+TString::Itoa(coinc_cut,10); - from option (optional argument)
34 // Output files created in dat, pdf and root subdirectories
35 
37 #include <TH2.h>
38 #include <TStyle.h>
39 #include <TFile.h>
40 #include <TH1.h>
41 #include <vector>
42 #include <TVector3.h>
43 #include <iostream>
44 #include <fstream>
45 
46 
47  char estring[256];
48 
49  // Int_t layer=1 ;
50  Int_t layer; // select layer for efficiencies - get from option
51  Int_t coinc_cut = 3; // nominal is 3
52  Int_t nfiles=1;
53  // TString filerun = "030890-mar23";
54  TString filerun; // get from option
55  TString filename;
56 
57 
58  Int_t ndx = 0;
59  Int_t entry_max=1000000;
60  Int_t rand_offset = -15; // keep offset negative
61  Int_t count_proj = 0;
62  Int_t count_down = 0;
63  Int_t count_up = 0;
64 
65 
66 
67 void Read_bcal_hadronic_eff2::Begin(TTree * /*tree*/)
68 {
69  // The Begin() function is called at the start of the query.
70  // When running with PROOF Begin() is only called on the client.
71  // The tree argument is deprecated (on PROOF 0 is passed).
72 
73  gStyle->SetPalette(1,0);
74  gStyle->SetOptStat(111111);
75  gStyle->SetOptFit(111111);
76  gStyle->SetPadRightMargin(0.15);
77  gStyle->SetPadLeftMargin(0.15);
78  gStyle->SetPadBottomMargin(0.15);
79 
80  TString option = GetOption();
81  // TString filerun = option;
82 
83  TObjArray *tokens = option.Tokenize(" ");
84  Int_t ntokens = tokens->GetEntries();
85  if (ntokens != 2) {
86  cout << "*** Begin: Number of entries=" << ntokens << endl;
87  exit(1);
88  }
89  // Float_t = (((TObjString*)tokens->At(1))->GetString()).Atof();
90  // cout << " token1=" << ((TObjString*)tokens->At(0))->GetString() << " token2=" << ((TObjString*)tokens->At(1))->GetString() << endl;
91  filerun = ((TObjString*)tokens->At(0))->GetString();
92  layer = ((TObjString*)tokens->At(1))->GetString().Atoi();
93  cout << "Begin: filerun=" << filerun << " layer=" << layer << endl;
94 
95  // Define histograms
96  Int_t nbins=100;
97 
98  h1_TrackDeltaPhiToShower = new TH1F("TrackDeltaPhiToShower", "TrackDeltaPhiToShower",nbins, -10,10);
99  h1_TrackDeltaZToShower = new TH1F("TrackDeltaZToShower", "TrackDeltaZToShower", nbins,-20,20);
100  h1_ProjectedBCALSectors_Layer = new TH1F("TProjectedBCALSectors_Layer", "ProjectedBCALSectors_Layer", 2*nbins,0,200);
101  h1_NearestBCALSectors_Layer_Downstream = new TH1F("NearestBCALSectors_Layer_Downstream", "NearestBCALSectors_Layer_Downstream", 2*nbins,0,200);
102  h1_NearestBCALSectors_Layer_Upstream = new TH1F("NearestBCALSectors_Layer_Upstream", "NearestBCALSectors_Layer_Upstream", 2*nbins,0,200);
103  h1_pid_pdg = new TH1F("PID_PDG", "PID_PDG", 2*nbins,-3000,3000);
104 
105  h1_layer_proj = new TH1F("h1_layer_proj","h1_layer_proj",2*nbins,0,200);
106  h1_layer_up = new TH1F("h1_layer_up","h1_layer_up",2*nbins,0,200);
107  h1_layer_down = new TH1F("h1_layer_down","h1_layer_down",2*nbins,0,200);
108  h1_layer_up_rand_left = new TH1F("h1_layer_up_rand_left","h1_layer_up_rand_left",2*nbins,0,200);
109  h1_layer_down_rand_left = new TH1F("h1_layer_down_rand_left","h1_layer_down_rand_left",2*nbins,0,200);
110  h1_layer_up_rand_right = new TH1F("h1_layer_up_rand_right","h1_layer_up_rand_right",2*nbins,0,200);
111  h1_layer_down_rand_right = new TH1F("h1_layer_down_rand_right","h1_layer_down_rand_right",2*nbins,0,200);
112  h1_layer_up_rand = new TH1F("h1_layer_up_rand","h1_layer_up_rand",2*nbins,0,200);
113  h1_layer_down_rand = new TH1F("h1_layer_down_rand","h1_layer_down_rand",2*nbins,0,200);
114 
115  h1_eff_up = new TH1F("h1_eff_up","h1_eff_up",2*nbins,0,200);
116  h1_eff_down = new TH1F("h1_eff_down","h1_eff_down",2*nbins,0,200);
117  h1_eff_up_temp = new TH1F("h1_eff_up_temp","h1_eff_up_temp",2*nbins,0,200);
118  h1_eff_down_temp = new TH1F("h1_eff_down_temp","h1_eff_down_temp",2*nbins,0,200);
119 
120  h1_diff_up = new TH1F("h1_diff_up","h1_diff_up",100,-50,50);
121  h1_diff_down = new TH1F("h1_diff_down","h1_diff_down",100,-50,50);
122  h1_diff_up_rand_left = new TH1F("h1_diff_up_rand_left","h1_diff_up_rand_left",50,-40,10);
123  h1_diff_down_rand_left = new TH1F("h1_diff_down_rand_left","h1_diff_down_rand_left",50,-40,10);
124  h1_diff_up_rand_right = new TH1F("h1_diff_up_rand_right","h1_diff_up_rand_right",50,-10,40);
125  h1_diff_down_rand_right = new TH1F("h1_diff_down_rand_right","h1_diff_down_rand_right",50,-10,40);
126 
127  h1_mom_proj = new TH1F("h1_mom_proj","h1_mom_proj",2*nbins,0,4);
128  h1_mom_up = new TH1F("h1_mom_up","h1_mom_up",2*nbins,0,4);
129  h1_mom_down = new TH1F("h1_mom_down","h1_mom_down",2*nbins,0,4);
130  h1_mom_up_rand_left = new TH1F("h1_mom_up_rand_left","h1_mom_up_rand_left",2*nbins,0,4);
131  h1_mom_down_rand_left = new TH1F("h1_mom_down_rand_left","h1_mom_down_rand_left",2*nbins,0,4);
132  h1_mom_up_rand_right = new TH1F("h1_mom_up_rand_right","h1_mom_up_rand_right",2*nbins,0,4);
133  h1_mom_down_rand_right = new TH1F("h1_mom_down_rand_right","h1_mom_down_rand_right",2*nbins,0,4);
134  h1_mom_up_rand = new TH1F("h1_mom_up_rand","h1_mom_up_rand",2*nbins,0,4);
135  h1_mom_down_rand = new TH1F("h1_mom_down_rand","h1_mom_down_rand",2*nbins,0,4);
136 
137  h1_eff_mom_up = new TH1F("h1_eff_mom_up","h1_eff_mom_up",2*nbins,0,4);
138  h1_eff_mom_down = new TH1F("h1_eff_mom_down","h1_eff_mom_down",2*nbins,0,4);
139  h1_eff_mom_up_temp = new TH1F("h1_eff_mom_up_temp","h1_eff_mom_up_temp",2*nbins,0,4);
140  h1_eff_mom_down_temp = new TH1F("h1_eff_mom__down_temp","h1_eff_mom_down_temp",2*nbins,0,4);
141 
142  h1_z_proj = new TH1F("h1_z_proj","h1_z_proj",2*nbins,0,500);
143  h1_z_up = new TH1F("h1_z_up","h1_z_up",2*nbins,0,500);
144  h1_z_down = new TH1F("h1_z_down","h1_z_down",2*nbins,0,500);
145  h1_z_up_rand_left = new TH1F("h1_z_up_rand_left","h1_z_up_rand_left",2*nbins,0,500);
146  h1_z_down_rand_left = new TH1F("h1_z_down_rand_left","h1_z_down_rand_left",2*nbins,0,500);
147  h1_z_up_rand_right = new TH1F("h1_z_up_rand_right","h1_z_up_rand_right",2*nbins,0,500);
148  h1_z_down_rand_right = new TH1F("h1_z_down_rand_right","h1_z_down_rand_right",2*nbins,0,500);
149  h1_z_up_rand = new TH1F("h1_z_up_rand","h1_z_up_rand",2*nbins,0,500);
150  h1_z_down_rand = new TH1F("h1_z_down_rand","h1_z_down_rand",2*nbins,0,500);
151 
152  h1_eff_z_up = new TH1F("h1_eff_z_up","h1_eff_z_up",2*nbins,0,500);
153  h1_eff_z_down = new TH1F("h1_eff_z_down","h1_eff_z_down",2*nbins,0,500);
154  h1_eff_z_up_temp = new TH1F("h1_eff_z_up_temp","h1_eff_z_up_temp",2*nbins,0,500);
155  h1_eff_z_down_temp = new TH1F("h1_eff_z__down_temp","h1_eff_z_down_temp",2*nbins,0,500);
156 
157  h1_Evis_proj = new TH1F("h1_Evis_proj","h1_Evis_proj",2*nbins,0,0.5);
158  h1_Evis_up = new TH1F("h1_Evis_up","h1_Evis_up",2*nbins,0,0.5);
159  h1_Evis_down = new TH1F("h1_Evis_down","h1_Evis_down",2*nbins,0,0.5);
160  h1_Evis_up_rand_left = new TH1F("h1_Evis_up_rand_left","h1_Evis_up_rand_left",2*nbins,0,0.5);
161  h1_Evis_down_rand_left = new TH1F("h1_Evis_down_rand_left","h1_Evis_down_rand_left",2*nbins,0,0.5);
162  h1_Evis_up_rand_right = new TH1F("h1_Evis_up_rand_right","h1_Evis_up_rand_right",2*nbins,0,0.5);
163  h1_Evis_down_rand_right = new TH1F("h1_Evis_down_rand_right","h1_Evis_down_rand_right",2*nbins,0,0.5);
164  h1_Evis_up_rand = new TH1F("h1_Evis_up_rand","h1_Evis_up_rand",2*nbins,0,0.5);
165  h1_Evis_down_rand = new TH1F("h1_Evis_down_rand","h1_Evis_down_rand",2*nbins,0,0.5);
166 
167  h1_eff_Evis_up = new TH1F("h1_eff_Evis_up","h1_eff_Evis_up",2*nbins,0,0.5);
168  h1_eff_Evis_down = new TH1F("h1_eff_Evis_down","h1_eff_Evis_down",2*nbins,0,0.5);
169  h1_eff_Evis_up_temp = new TH1F("h1_eff_Evis_up_temp","h1_eff_Evis_up_temp",2*nbins,0,0.5);
170  h1_eff_Evis_down_temp = new TH1F("h1_eff_Evis__down_temp","h1_eff_Evis_down_temp",2*nbins,0,0.5);
171 
172  h1_eff_up->Sumw2();
173  h1_layer_up->Sumw2();
174  h1_layer_up_rand_left->Sumw2();
175  h1_layer_up_rand_right->Sumw2();
176  h1_layer_up_rand->Sumw2();
177  h1_eff_down->Sumw2();
178  h1_layer_down->Sumw2();
179  h1_layer_down_rand_left->Sumw2();
180  h1_layer_down_rand_right->Sumw2();
181  h1_layer_down_rand->Sumw2();
182 
183  h1_eff_mom_up->Sumw2();
184  h1_mom_up->Sumw2();
185  h1_mom_up_rand_left->Sumw2();
186  h1_mom_up_rand_right->Sumw2();
187  h1_mom_up_rand->Sumw2();
188  h1_eff_mom_down->Sumw2();
189  h1_mom_down->Sumw2();
190  h1_mom_down_rand_left->Sumw2();
191  h1_mom_down_rand_right->Sumw2();
192  h1_mom_down_rand->Sumw2();
193 
194  h1_eff_z_up->Sumw2();
195  h1_z_up->Sumw2();
196  h1_z_up_rand_left->Sumw2();
197  h1_z_up_rand_right->Sumw2();
198  h1_z_up_rand->Sumw2();
199  h1_eff_z_down->Sumw2();
200  h1_z_down->Sumw2();
201  h1_z_down_rand_left->Sumw2();
202  h1_z_down_rand_right->Sumw2();
203  h1_z_down_rand->Sumw2();
204 
205  h1_eff_Evis_up->Sumw2();
206  h1_Evis_up->Sumw2();
207  h1_Evis_up_rand_left->Sumw2();
208  h1_Evis_up_rand_right->Sumw2();
209  h1_Evis_up_rand->Sumw2();
210  h1_eff_Evis_down->Sumw2();
211  h1_Evis_down->Sumw2();
212  h1_Evis_down_rand_left->Sumw2();
213  h1_Evis_down_rand_right->Sumw2();
214  h1_Evis_down_rand->Sumw2();
215 
216 
217  TString filebase = "/cache/halld/RunPeriod-2016-02/recon/ver01/tree_bcal_hadronic_eff/"+filerun+"/tree_bcal_hadronic_eff_";
218  // TString filebase = "tree_bcal_hadronic_eff_";
219  TFile *file = NULL;
220 
221  // file = new TFile(filebase+filerun+".root","read");
222  // cout << "Opening root file: " << (filebase+filerun+".root").Data() << endl;
223  filename = "R"+filerun+"_layer"+TString::Itoa(layer,10)+"_cut"+TString::Itoa(coinc_cut,10);
224 
225 }
226 
228 {
229  // The SlaveBegin() function is called after the Begin() function.
230  // When running with PROOF SlaveBegin() is called on each slave server.
231  // The tree argument is deprecated (on PROOF 0 is passed).
232 
233  TString option = GetOption();
234 
235 }
236 
237 Bool_t Read_bcal_hadronic_eff2::Process(Long64_t entry)
238 {
239  // The Process() function is called for each entry in the tree (or possibly
240  // keyed object in the case of PROOF) to be processed. The entry argument
241  // specifies which entry in the currently loaded tree is to be processed.
242  // It can be passed to either Read_bcal_hadronic_eff2::GetEntry() or TBranch::GetEntry()
243  // to read either all or the required parts of the data. When processing
244  // keyed objects with PROOF, the object is already loaded and is available
245  // via the fObject pointer.
246  //
247  // This function should contain the "body" of the analysis. It can contain
248  // simple or elaborate selection criteria, run algorithms on the data
249  // of the event and typically fill histograms.
250  //
251  // The processing can be stopped by calling Abort().
252  //
253  // Use fStatus to set the return value of TTree::Process().
254  //
255  // The return value is currently not used.
256 
257 
258  Int_t ProjectedBCALSectors_Layer;
259  Int_t NearestBCALSectors_Layer_Upstream;
260  Int_t NearestBCALSectors_Layer_Downstream;
261 
262 
263  Int_t proj4;
264  Int_t up4;
265  Int_t down4;
266  Double_t updiff4;
267  Double_t downdiff4;
268 
269  fChain->GetEntry(entry);
270 
271  if (entry >= entry_max) {
272  // cout << " Event limit reached =" << entry << endl;
273  return kFALSE;
274  }
275 
276  Float_t Evis;
277  // select layer of interest
278  switch (layer) {
279  case 1:
280  ProjectedBCALSectors_Layer = (Int_t) ProjectedBCALSectors_Layer1;
281  NearestBCALSectors_Layer_Upstream = (Int_t) NearestBCALSectors_Layer1_Upstream;
282  NearestBCALSectors_Layer_Downstream = (Int_t) NearestBCALSectors_Layer1_Downstream;
284  break;
285  case 2:
286  ProjectedBCALSectors_Layer = (Int_t) ProjectedBCALSectors_Layer2;
287  NearestBCALSectors_Layer_Upstream = (Int_t) NearestBCALSectors_Layer2_Upstream;
288  NearestBCALSectors_Layer_Downstream = (Int_t) NearestBCALSectors_Layer2_Downstream;
290  break;
291  case 3:
292  ProjectedBCALSectors_Layer = 0;
293  // check that layer 4 is hit, otherwise set ProjectedBCALSectors_Layer=0, so that this track will be ignored in the layer 3 efficiency
294  proj4 = (Int_t) ProjectedBCALSectors_Layer4;
296  down4 = (Int_t) NearestBCALSectors_Layer4_Downstream;
297  updiff4 = up4 - (proj4-1)%192 -1;
298  downdiff4 = down4 - (proj4-1)%192 -1;
299  if (proj4 && up4 && down4 && fabs(updiff4) <= coinc_cut && fabs(downdiff4) <= coinc_cut) {
300  ProjectedBCALSectors_Layer = (Int_t) ProjectedBCALSectors_Layer3;
301  NearestBCALSectors_Layer_Upstream = (Int_t) NearestBCALSectors_Layer3_Upstream;
302  NearestBCALSectors_Layer_Downstream = (Int_t) NearestBCALSectors_Layer3_Downstream;
304  // cout << endl << " ProjectedBCALSectors_Layer=" << ProjectedBCALSectors_Layer << " NearestBCALSectors_Layer_Upstream=" << NearestBCALSectors_Layer_Upstream << " NearestBCALSectors_Layer_Downstream=" << NearestBCALSectors_Layer_Downstream << endl;
305  // cout << " proj4=" << proj4 << " up4=" << up4 << " down4=" << down4 << endl;
306  }
307  break;
308  case 4:
309  ProjectedBCALSectors_Layer = (Int_t) ProjectedBCALSectors_Layer4;
310  NearestBCALSectors_Layer_Upstream = (Int_t) NearestBCALSectors_Layer4_Upstream;
311  NearestBCALSectors_Layer_Downstream = (Int_t) NearestBCALSectors_Layer4_Downstream;
313  break;
314  default:
315  cout << "*** Read_bcal_hadronic_eff: illegal layer=" << layer << endl;
316  return kFALSE;
317  }
318 
319  // cout << " ProjectedBCALSectors_Layer=" << ProjectedBCALSectors_Layer << " NearestBCALSectors_Layer_Upstream=" << NearestBCALSectors_Layer_Upstream << " NearestBCALSectors_Layer_Downstream=" << NearestBCALSectors_Layer_Downstream << endl;
320 
321 
322  Double_t mom = TrackP3->Mag();
323  Double_t z = ProjectedBCALHitZ;
324  Int_t pid_pdf = PID_PDG;
325 
326  // cout << "TrackP3->Mag()=" << mom << endl;
327 
328 
329  // eff histograms
332  h1_ProjectedBCALSectors_Layer->Fill(ProjectedBCALSectors_Layer);
333  h1_NearestBCALSectors_Layer_Downstream->Fill(NearestBCALSectors_Layer_Downstream);
334  h1_NearestBCALSectors_Layer_Upstream->Fill(NearestBCALSectors_Layer_Upstream);
335  h1_pid_pdg->Fill(pid_pdf);
336 
337  Double_t diff_down = 1000.;
338  Double_t diff_up = 1000.;
339  Double_t diff_down_rand_left = 1000.;
340  Double_t diff_up_rand_left = 1000.;
341  Double_t diff_down_rand_right = 1000.;
342  Double_t diff_up_rand_right = 1000.;
343  Int_t subtr = (ProjectedBCALSectors_Layer-1)%192 +1;
344  Int_t subtr_rand = (ProjectedBCALSectors_Layer+rand_offset-1)%192 +1;
345  if (subtr_rand <=0) subtr_rand += 192;
346 
347  if (ProjectedBCALSectors_Layer && (subtr > 0)) {
348  diff_down = NearestBCALSectors_Layer_Downstream - (ProjectedBCALSectors_Layer-1)%192 -1;
349  diff_up = NearestBCALSectors_Layer_Upstream - (ProjectedBCALSectors_Layer-1)%192 -1;
350 
351  h1_diff_down->Fill(diff_down);
352  h1_diff_up->Fill(diff_up);
353  }
354 
355  if (ProjectedBCALSectors_Layer && (subtr_rand > 0)) {
356  diff_down_rand_left = NearestBCALSectors_Layer_Downstream - (ProjectedBCALSectors_Layer+rand_offset-1)%192 -1;
357  diff_up_rand_left = NearestBCALSectors_Layer_Upstream - (ProjectedBCALSectors_Layer+rand_offset-1)%192 -1 ;
358  diff_down_rand_right = NearestBCALSectors_Layer_Downstream - (ProjectedBCALSectors_Layer-rand_offset-1)%192 -1;
359  diff_up_rand_right = NearestBCALSectors_Layer_Upstream - (ProjectedBCALSectors_Layer-rand_offset-1)%192 -1;
360 
361  h1_diff_down_rand_left->Fill(diff_down_rand_left);
362  h1_diff_up_rand_left->Fill(diff_up_rand_left);
363  h1_diff_down_rand_right->Fill(diff_down_rand_right);
364  h1_diff_up_rand_right->Fill(diff_up_rand_right);
365  }
366 
367 
368  if (ProjectedBCALSectors_Layer && subtr && subtr_rand) {
369  h1_layer_proj->Fill(ProjectedBCALSectors_Layer);
370  h1_mom_proj->Fill(mom);
371  h1_z_proj->Fill(z);
372  h1_Evis_proj->Fill(Evis);
373  count_proj++;
374 
375  if (NearestBCALSectors_Layer_Downstream && ((fabs(diff_down)<=coinc_cut) || fabs(fabs(diff_down)-192)<=coinc_cut) ){
376  // cout << " fabs(diff_down)=" << fabs(diff_down) << endl;
377  h1_layer_down->Fill(ProjectedBCALSectors_Layer);
378  h1_mom_down->Fill(mom);
379  h1_z_down->Fill(z);
380  h1_Evis_down->Fill(Evis);
381  count_down++;
382  }
383  if (NearestBCALSectors_Layer_Downstream && (fabs(diff_down_rand_left)<=coinc_cut || fabs(fabs(diff_down_rand_left)-192)<=coinc_cut) ){
384  // if (ProjectedBCALSectors_Layer < 20) cout << " sector=" <<ProjectedBCALSectors_Layer << " ***fabs(diff_down_rand_left)=" << fabs(diff_down_rand_left) << " coinc_cut=" << coinc_cut << " nearest=" << NearestBCALSectors_Layer_Downstream << endl;
385  h1_layer_down_rand_left->Fill(ProjectedBCALSectors_Layer);
386  h1_mom_down_rand_left->Fill(mom);
387  h1_z_down_rand_left->Fill(z);
388  h1_Evis_down_rand_left->Fill(Evis);
389  }
390  if (NearestBCALSectors_Layer_Downstream && (fabs(diff_down_rand_right)<=coinc_cut || fabs(fabs(diff_down_rand_right)-192)<=coinc_cut) ){
391  // if (ProjectedBCALSectors_Layer < 20) cout << " sector=" << ProjectedBCALSectors_Layer << " ***fabs(diff_down_rand_right)=" << fabs(diff_down_rand_right) << endl;
392  h1_layer_down_rand_right->Fill(ProjectedBCALSectors_Layer);
393  h1_mom_down_rand_right->Fill(mom);
394  h1_z_down_rand_right->Fill(z);
395  h1_Evis_down_rand_right->Fill(Evis);
396  }
397 
398  if (NearestBCALSectors_Layer_Upstream && (fabs(diff_up) <= coinc_cut || fabs(fabs(diff_up)-192)<=coinc_cut) ){
399  // cout << " fabs(diff_up)=" << fabs(diff_up) << endl;
400  h1_layer_up->Fill(ProjectedBCALSectors_Layer);
401  h1_mom_up->Fill(mom);
402  h1_z_up->Fill(z);
403  h1_Evis_up->Fill(Evis);
404  count_up++;
405  }
406  if (NearestBCALSectors_Layer_Upstream && (fabs(diff_up_rand_left) <= coinc_cut || fabs(fabs(diff_up_rand_left)-192)<=coinc_cut) ){
407  // if (ProjectedBCALSectors_Layer < 20) cout << " sector=" <<ProjectedBCALSectors_Layer << " ***fabs(diff_up_rand_left)=" << fabs(diff_up_rand_left) << endl;
408  h1_layer_up_rand_left->Fill(ProjectedBCALSectors_Layer);
409  h1_mom_up_rand_left->Fill(mom);
410  h1_z_up_rand_left->Fill(z);
411  h1_Evis_up_rand_left->Fill(Evis);
412  }
413  if (NearestBCALSectors_Layer_Upstream && (fabs(diff_up_rand_right) <= coinc_cut || fabs(fabs(diff_up_rand_right)-192)<=coinc_cut) ){
414  // if (ProjectedBCALSectors_Layer < 20) cout << " sector=" << ProjectedBCALSectors_Layer << " ***fabs(diff_up_rand_right)=" << fabs(diff_up_rand_right) << endl;
415  h1_layer_up_rand_right->Fill(ProjectedBCALSectors_Layer);
416  h1_mom_up_rand_right->Fill(mom);
417  h1_z_up_rand_right->Fill(z);
418  h1_Evis_up_rand_right->Fill(Evis);
419  }
420 
421  }
422 
423 
424 
425  return kTRUE;
426 }
427 
429 {
430  // The SlaveTerminate() function is called after all entries or objects
431  // have been processed. When running with PROOF SlaveTerminate() is called
432  // on each slave server.
433 
434 }
435 
437 {
438  // The Terminate() function is the last function to be called during
439  // a query. It always runs on the client, it can be used to present
440  // the results graphically or save the results to file.
441 
442 
443  TCanvas *c0 = new TCanvas("c0", "c0",200,10,1000,700);
444 
445  c0->Divide(3,2);
446  c0->cd(1);
447  // gPad->SetLogy();
448  Double_t xmin = 0;
449  Double_t xmax = 2;
450  Double_t ymin = 100;
451  Double_t ymax = 10000;
452 
454  // h1_TrackDeltaPhiToShower->GetXaxis()->SetRangeUser(xmin,xmax);
455  // h1_TrackDeltaPhiToShower->GetYaxis()->SetRangeUser(ymin,ymax);
456  h1_TrackDeltaPhiToShower->GetXaxis()->SetTitleSize(0.05);
457  h1_TrackDeltaPhiToShower->GetYaxis()->SetTitleSize(0.05);
458  h1_TrackDeltaPhiToShower->GetXaxis()->SetTitle("Delta Phi to Shower");
459  h1_TrackDeltaPhiToShower->SetMarkerColor(4);
460  h1_TrackDeltaPhiToShower->Draw();
461 
462  c0->cd(2);
463 
464  h1_TrackDeltaZToShower->SetTitle(filename);
465  // h1_TrackDeltaZToShower->GetXaxis()->SetRangeUser(xmin,xmax);
466  // h1_TrackDeltaZToShower->GetYaxis()->SetRangeUser(ymin,ymax);
467  h1_TrackDeltaZToShower->GetXaxis()->SetTitleSize(0.05);
468  h1_TrackDeltaZToShower->GetYaxis()->SetTitleSize(0.05);
469  h1_TrackDeltaZToShower->GetXaxis()->SetTitle("Delta Z to Shower");
470  h1_TrackDeltaZToShower->SetMarkerColor(4);
471  h1_TrackDeltaZToShower->Draw();
472 
473  c0->cd(3);
474 
476  // h1_ProjectedBCALSectors_Layer->GetXaxis()->SetRangeUser(xmin,xmax);
477  // h1_ProjectedBCALSectors_Layer->GetYaxis()->SetRangeUser(ymin,ymax);
478  h1_ProjectedBCALSectors_Layer->GetXaxis()->SetTitleSize(0.05);
479  h1_ProjectedBCALSectors_Layer->GetYaxis()->SetTitleSize(0.05);
480  h1_ProjectedBCALSectors_Layer->GetXaxis()->SetTitle("ProjectedBCALSectors_Layer");
481  h1_ProjectedBCALSectors_Layer->SetMarkerColor(4);
483 
484  c0->cd(4);
485 
487  // h1_NearestBCALSectors_Layer->GetXaxis()->SetRangeUser(xmin,xmax);
488  // h1_NearestBCALSectors_Layer->GetYaxis()->SetRangeUser(ymin,ymax);
489  h1_NearestBCALSectors_Layer_Downstream->GetXaxis()->SetTitleSize(0.05);
490  h1_NearestBCALSectors_Layer_Downstream->GetYaxis()->SetTitleSize(0.05);
491  h1_NearestBCALSectors_Layer_Downstream->GetXaxis()->SetTitle("NearestBCALSectors_Layer_Downstream");
492  h1_NearestBCALSectors_Layer_Downstream->SetMarkerColor(4);
494 
495  c0->cd(5);
496 
498  // h1_NearestBCALSectors_Layer_Upstream->GetXaxis()->SetRangeUser(xmin,xmax);
499  // h1_NearestBCALSectors_Layer_Upstream->GetYaxis()->SetRangeUser(ymin,ymax);
500  h1_NearestBCALSectors_Layer_Upstream->GetXaxis()->SetTitleSize(0.05);
501  h1_NearestBCALSectors_Layer_Upstream->GetYaxis()->SetTitleSize(0.05);
502  h1_NearestBCALSectors_Layer_Upstream->GetXaxis()->SetTitle("NearestBCALSectors_Layer_Upstream");
503  h1_NearestBCALSectors_Layer_Upstream->SetMarkerColor(4);
505 
506  c0->cd(6);
507 
508  h1_pid_pdg->SetTitle(filename);
509  // h1_pid_pdg->GetXaxis()->SetRangeUser(xmin,xmax);
510  // h1_pid_pdg->GetYaxis()->SetRangeUser(ymin,ymax);
511  h1_pid_pdg->GetXaxis()->SetTitleSize(0.05);
512  h1_pid_pdg->GetYaxis()->SetTitleSize(0.05);
513  h1_pid_pdg->GetXaxis()->SetTitle("PID_PDG");
514  h1_pid_pdg->SetMarkerColor(4);
515  h1_pid_pdg->Draw();
516 
517  TCanvas *c1 = new TCanvas("c1", "c1",200,10,1000,700);
518 
519  c1->Divide(3,2);
520  c1->cd(1);
521  gPad->SetLogy();
522 
523  h1_diff_up->SetTitle(filename);
524  // h1_diff_up->GetXaxis()->SetRangeUser(xmin,xmax);
525  // h1_diff_up->GetYaxis()->SetRangeUser(ymin,ymax);
526  h1_diff_up->GetXaxis()->SetTitleSize(0.05);
527  h1_diff_up->GetYaxis()->SetTitleSize(0.05);
528  h1_diff_up->GetXaxis()->SetTitle("diff_up");
529  h1_diff_up->SetMarkerColor(4);
530  h1_diff_up->Draw();
531 
532  c1->cd(2);
533  gPad->SetLogy();
534 
535  h1_diff_up_rand_left->SetTitle(filename);
536  // h1_diff_up_rand_left->GetXaxis()->SetRangeUser(xmin,xmax);
537  // h1_diff_up_rand_left->GetYaxis()->SetRangeUser(ymin,ymax);
538  h1_diff_up_rand_left->GetXaxis()->SetTitleSize(0.05);
539  h1_diff_up_rand_left->GetYaxis()->SetTitleSize(0.05);
540  h1_diff_up_rand_left->GetXaxis()->SetTitle("diff_up_rand_left");
541  h1_diff_up_rand_left->SetMarkerColor(4);
542  h1_diff_up_rand_left->Draw();
543 
544  c1->cd(3);
545  gPad->SetLogy();
546 
547  h1_diff_up_rand_right->SetTitle(filename);
548  // h1_diff_up_rand_right->GetXaxis()->SetRangeUser(xmin,xmax);
549  // h1_diff_up_rand_right->GetYaxis()->SetRangeUser(ymin,ymax);
550  h1_diff_up_rand_right->GetXaxis()->SetTitleSize(0.05);
551  h1_diff_up_rand_right->GetYaxis()->SetTitleSize(0.05);
552  h1_diff_up_rand_right->GetXaxis()->SetTitle("diff_up_rand_right");
553  h1_diff_up_rand_right->SetMarkerColor(4);
554  h1_diff_up_rand_right->Draw();
555 
556  c1->cd(4);
557  gPad->SetLogy();
558 
559  h1_diff_down->SetTitle(filename);
560  // h1_diff_down->GetXaxis()->SetRangeUser(xmin,xmax);
561  // h1_diff_down->GetYaxis()->SetRangeUser(ymin,ymax);
562  h1_diff_down->GetXaxis()->SetTitleSize(0.05);
563  h1_diff_down->GetYaxis()->SetTitleSize(0.05);
564  h1_diff_down->GetXaxis()->SetTitle("diff_down");
565  h1_diff_down->SetMarkerColor(4);
566  h1_diff_down->Draw();
567 
568 
569  c1->cd(5);
570  gPad->SetLogy();
571 
572  h1_diff_down_rand_left->SetTitle(filename);
573  // h1_diff_down_rand_left->GetXaxis()->SetRangeUser(xmin,xmax);
574  // h1_diff_down_rand_left->GetYaxis()->SetRangeUser(ymin,ymax);
575  h1_diff_down_rand_left->GetXaxis()->SetTitleSize(0.05);
576  h1_diff_down_rand_left->GetYaxis()->SetTitleSize(0.05);
577  h1_diff_down_rand_left->GetXaxis()->SetTitle("diff_down_rand_left");
578  h1_diff_down_rand_left->SetMarkerColor(4);
579  h1_diff_down_rand_left->Draw();
580 
581  c1->cd(6);
582  gPad->SetLogy();
583 
585  // h1_diff_down_rand_right->GetXaxis()->SetRangeUser(xmin,xmax);
586  // h1_diff_down_rand_right->GetYaxis()->SetRangeUser(ymin,ymax);
587  h1_diff_down_rand_right->GetXaxis()->SetTitleSize(0.05);
588  h1_diff_down_rand_right->GetYaxis()->SetTitleSize(0.05);
589  h1_diff_down_rand_right->GetXaxis()->SetTitle("diff_down_rand_right");
590  h1_diff_down_rand_right->SetMarkerColor(4);
591  h1_diff_down_rand_right->Draw();
592 
593  TCanvas *c2 = new TCanvas("c2", "c2",200,10,1000,700);
594 
595  c2->Divide(3,2);
596 
597  c2->cd(1);
598 
599  h1_layer_proj->SetTitle(filename);
600  // h1_layer_proj->GetXaxis()->SetRangeUser(xmin,xmax);
601  // h1_layer_proj->GetYaxis()->SetRangeUser(ymin,ymax);
602  // h1_layer_proj->GetXaxis()->SetTitleSize(0.05);
603  h1_layer_proj->GetYaxis()->SetTitleSize(0.05);
604  h1_layer_proj->GetXaxis()->SetTitle("layer_proj");
605  h1_layer_proj->SetMarkerColor(4);
606  h1_layer_proj->Draw();
607 
608  c2->cd(2);
609  // gPad->SetLogy();
610 
612  Double_t rand_sum_up = h1_layer_up_rand->Integral();
613  Double_t rand_sum_up_left = h1_layer_up_rand_left->Integral();
614  Double_t rand_sum_up_right = h1_layer_up_rand_right->Integral();
615  cout << " ave=" << rand_sum_up << " left=" << rand_sum_up_left << " right=" << rand_sum_up_right << endl;
616 
617  ymin=0.1;
618  ymin=100000;
619  h1_layer_up->SetTitle(filename);
620  // h1_layer_up->GetXaxis()->SetRangeUser(xmin,xmax);
621  // h1_layer_up->GetYaxis()->SetRangeUser(ymin,ymax);
622  h1_layer_up->GetXaxis()->SetTitleSize(0.05);
623  h1_layer_up->GetYaxis()->SetTitleSize(0.05);
624  h1_layer_up->GetXaxis()->SetTitle("layer_up");
625  h1_layer_up->SetMarkerColor(4);
626  h1_layer_up->Draw();
627  h1_layer_up_rand->SetLineColor(2);
628  h1_layer_up_rand->Draw("same");
629 
630  c2->cd(3);
631  // gPad->SetLogy();
632 
634  Double_t rand_sum_down = h1_layer_down_rand->Integral();
635  Double_t rand_sum_down_left = h1_layer_down_rand_left->Integral();
636  Double_t rand_sum_down_right = h1_layer_down_rand_right->Integral();
637  cout << " ave=" << rand_sum_down << " left=" << rand_sum_down_left << " right=" << rand_sum_down_right << endl;
638 
639  h1_layer_down->SetTitle(filename);
640  // h1_layer_down->GetXaxis()->SetRangeUser(xmin,xmax);
641  // h1_layer_down->GetYaxis()->SetRangeUser(ymin,ymax);
642  h1_layer_down->GetXaxis()->SetTitleSize(0.05);
643  h1_layer_down->GetYaxis()->SetTitleSize(0.05);
644  h1_layer_down->GetXaxis()->SetTitle("layer_down");
645  h1_layer_down->SetMarkerColor(4);
646  h1_layer_down->Draw();
647  h1_layer_down_rand->SetLineColor(2);
648  h1_layer_down_rand->Draw("same");
649 
650  c2->cd(4);
651 
653  Double_t up_temp_diff =h1_eff_up_temp->Integral();
654  h1_eff_up->Divide(h1_eff_up_temp,h1_layer_proj,1,1,"B");
655 
656  h1_eff_up->SetTitle(filename);
657  // h1_eff_up->GetXaxis()->SetRangeUser(xmin,xmax);
658  // h1_eff_up->GetYaxis()->SetRangeUser(ymin,ymax);
659  h1_eff_up->GetXaxis()->SetTitleSize(0.05);
660  h1_eff_up->GetYaxis()->SetTitleSize(0.05);
661  h1_eff_up->GetXaxis()->SetTitle("eff_up");
662  h1_eff_up->SetMarkerColor(4);
663  h1_eff_up->Draw();
664 
665  c2->cd(5);
666 
668  Double_t down_temp_diff =h1_eff_up_temp->Integral();
669  h1_eff_down->Divide(h1_eff_down_temp,h1_layer_proj,1,1,"B");
670 
671  h1_eff_down->SetTitle(filename);
672  // h1_eff_down->GetXaxis()->SetRangeUser(xmin,xmax);
673  // h1_eff_down->GetYaxis()->SetRangeUser(ymin,ymax);
674  h1_eff_down->GetXaxis()->SetTitleSize(0.05);
675  h1_eff_down->GetYaxis()->SetTitleSize(0.05);
676  h1_eff_down->GetXaxis()->SetTitle("eff_down");
677  h1_eff_down->SetMarkerColor(4);
678  h1_eff_down->Draw();
679 
680  c2->cd(6);
681 
682  sprintf (estring,"Average Efficiency\n");
683  printf("estring=%s",estring);
684  TLatex *t1 = new TLatex(0.2,0.95,estring); // t1->SetNDC();
685  t1->SetTextSize(0.04);
686  t1->Draw();
687 
688  Double_t count_up_diff = count_up - rand_sum_up;
689  Double_t count_down_diff = count_down - rand_sum_down;
690  cout << " ave=" << rand_sum_up << " left=" << rand_sum_up_left << " right=" << rand_sum_up_right << endl;
691  cout << " ave2=" << rand_sum_down << " left2=" << rand_sum_down_left << " right2=" << rand_sum_down_right << endl;
692  cout << " up_temp_diff=" << up_temp_diff << " down_temp_diff=" << down_temp_diff << endl;
693 
694  cout << endl << endl << endl << "count_proj=" << count_proj << " count_up=" << count_up << " count_down=" << count_down << " count_down_diff=" << count_down_diff << " count_up_diff=" << count_up_diff << " ratio_down=" <<
695  count_down_diff/count_proj << " ratio_up=" << count_up_diff/count_proj << endl << endl;
696 
697 
698  sprintf (estring,"Layer= %d\n",layer);
699  printf("estring=%s",estring);
700  t1->DrawLatex(0.2,0.90,estring);
701  sprintf (estring,"Proj-Hit <= %d\n",coinc_cut);
702  printf("estring=%s",estring);
703  t1->DrawLatex(0.2,0.85,estring);
704  sprintf (estring,"Projected counts= %d\n",count_proj);
705  printf("estring=%s",estring);
706  t1->DrawLatex(0.2,0.75,estring);
707  sprintf (estring,"Upstream counts= %.0f\n",count_up_diff);
708  printf("estring=%s",estring);
709  t1->DrawLatex(0.2,0.70,estring);
710  sprintf (estring,"Downstream counts= %.0f\n",count_down_diff);
711  printf("estring=%s",estring);
712  t1->DrawLatex(0.2,0.65,estring);
713  sprintf (estring,"Upstream efficiency= %.3f\n",count_up_diff/count_proj);
714  printf("estring=%s",estring);
715  t1->DrawLatex(0.2,0.6,estring);
716  sprintf (estring,"Downstream efficiency= %.3f\n",count_down_diff/count_proj);
717  printf("estring=%s",estring);
718  t1->DrawLatex(0.2,0.55,estring);
719 
720 
721  TCanvas *c3 = new TCanvas("c3", "c3",200,10,1000,700);
722 
723  c3->Divide(3,2);
724 
725  c3->cd(1);
726 
727  h1_mom_proj->SetTitle(filename);
728  // h1_mom_proj->GetXaxis()->SetRangeUser(xmin,xmax);
729  // h1_mom_proj->GetYaxis()->SetRangeUser(ymin,ymax);
730  h1_mom_proj->GetXaxis()->SetTitleSize(0.05);
731  h1_mom_proj->GetYaxis()->SetTitleSize(0.05);
732  h1_mom_proj->GetXaxis()->SetTitle("mom_proj (GeV)");
733  h1_mom_proj->SetMarkerColor(4);
734  h1_mom_proj->Draw();
735 
736  c3->cd(2);
737  gPad->SetLogy();
738 
740  Double_t mom_rand_sum_up = h1_mom_up_rand->Integral();
741  Double_t mom_rand_sum_up_left = h1_mom_up_rand_left->Integral();
742  Double_t mom_rand_sum_up_right = h1_mom_up_rand_right->Integral();
743  cout << " ave=" << mom_rand_sum_up << " left=" << mom_rand_sum_up_left << " right=" << mom_rand_sum_up_right << endl;
744 
745 
746  h1_mom_up->SetTitle(filename);
747  // h1_mom_up->GetXaxis()->SetRangeUser(xmin,xmax);
748  // h1_mom_up->GetYaxis()->SetRangeUser(ymin,ymax);
749  h1_mom_up->GetXaxis()->SetTitleSize(0.05);
750  h1_mom_up->GetYaxis()->SetTitleSize(0.05);
751  h1_mom_up->GetXaxis()->SetTitle("mom_up (GeV)");
752  h1_mom_up->SetMarkerColor(4);
753  h1_mom_up->Draw();
754  h1_mom_up_rand->SetLineColor(2);
755  h1_mom_up_rand->Draw("same");
756 
757  c3->cd(3);
758  gPad->SetLogy();
759 
761  Double_t mom_rand_sum_down = h1_mom_down_rand->Integral();
762  Double_t mom_rand_sum_down_left = h1_mom_down_rand_left->Integral();
763  Double_t mom_rand_sum_down_right = h1_mom_down_rand_right->Integral();
764  cout << " ave=" << mom_rand_sum_down << " left=" << mom_rand_sum_down_left << " right=" << mom_rand_sum_down_right << endl;
765 
766  h1_mom_down->SetTitle(filename);
767  // h1_mom_down->GetXaxis()->SetRangeUser(xmin,xmax);
768  // h1_mom_down->GetYaxis()->SetRangeUser(ymin,ymax);
769  h1_mom_down->GetXaxis()->SetTitleSize(0.05);
770  h1_mom_down->GetYaxis()->SetTitleSize(0.05);
771  h1_mom_down->GetXaxis()->SetTitle("mom_down (GeV)");
772  h1_mom_down->SetMarkerColor(4);
773  h1_mom_down->Draw();
774  h1_mom_down_rand->SetLineColor(2);
775  h1_mom_down_rand->Draw("same");
776 
777  c3->cd(4);
778 
781 
782  h1_eff_mom_up->SetTitle(filename);
783  // h1_eff_mom_up->GetXaxis()->SetRangeUser(xmin,xmax);
784  // h1_eff_mom_up->GetYaxis()->SetRangeUser(ymin,ymax);
785  h1_eff_mom_up->GetXaxis()->SetTitleSize(0.05);
786  h1_eff_mom_up->GetYaxis()->SetTitleSize(0.05);
787  h1_eff_mom_up->GetXaxis()->SetTitle("eff_mom_up (GeV)");
788  h1_eff_mom_up->SetMarkerColor(4);
789  h1_eff_mom_up->Draw();
790 
791  c3->cd(5);
792 
795 
796  h1_eff_mom_down->SetTitle(filename);
797  // h1_eff_mom_down->GetXaxis()->SetRangeUser(xmin,xmax);
798  // h1_eff_mom_down->GetYaxis()->SetRangeUser(ymin,ymax);
799  h1_eff_mom_down->GetXaxis()->SetTitleSize(0.05);
800  h1_eff_mom_down->GetYaxis()->SetTitleSize(0.05);
801  h1_eff_mom_down->GetXaxis()->SetTitle("eff_mom_down (GeV)");
802  h1_eff_mom_down->SetMarkerColor(4);
803  h1_eff_mom_down->Draw();
804 
805  c3->cd(6);
806 
807  sprintf (estring,"Average Efficiency\n");
808  printf("estring=%s",estring);
809  t1->DrawLatex(0.2,0.95,estring); // t1->SetNDC();
810  t1->SetTextSize(0.04);
811  t1->Draw();
812 
813  Double_t mom_count_up_diff = count_up - mom_rand_sum_up;
814  Double_t mom_count_down_diff = count_down - mom_rand_sum_down;
815  cout << endl << endl << endl << "count_proj=" << count_proj << " count_up=" << count_up << " count_down=" << count_down << " mom_count_down_diff=" << mom_count_down_diff << " mom_count_up_diff=" << mom_count_up_diff << " ratio_down=" <<
816  mom_count_down_diff/count_proj << " ratio_up=" << mom_count_up_diff/count_proj << endl << endl;
817 
818 
819  sprintf (estring,"Layer= %d\n",layer);
820  printf("estring=%s",estring);
821  t1->DrawLatex(0.2,0.90,estring);
822  sprintf (estring,"Proj-Hit <= %d\n",coinc_cut);
823  printf("estring=%s",estring);
824  t1->DrawLatex(0.2,0.85,estring);
825  sprintf (estring,"Projected counts= %d\n",count_proj);
826  printf("estring=%s",estring);
827  t1->DrawLatex(0.2,0.75,estring);
828  sprintf (estring,"Upstream counts= %.0f\n",mom_count_up_diff);
829  printf("estring=%s",estring);
830  t1->DrawLatex(0.2,0.70,estring);
831  sprintf (estring,"Downstream counts= %.0f\n",mom_count_down_diff);
832  printf("estring=%s",estring);
833  t1->DrawLatex(0.2,0.65,estring);
834  sprintf (estring,"Upstream efficiency= %.3f\n",mom_count_up_diff/count_proj);
835  printf("estring=%s",estring);
836  t1->DrawLatex(0.2,0.6,estring);
837  sprintf (estring,"Downstream efficiency= %.3f\n",mom_count_down_diff/count_proj);
838  printf("estring=%s",estring);
839  t1->DrawLatex(0.2,0.55,estring);
840 
841 
842  TCanvas *c4 = new TCanvas("c4", "c4",200,10,1000,700);
843 
844  c4->Divide(3,2);
845 
846  c4->cd(1);
847 
848  h1_z_proj->SetTitle(filename);
849  // h1_z_proj->GetXaxis()->SetRangeUser(xmin,xmax);
850  // h1_z_proj->GetYaxis()->SetRangeUser(ymin,ymax);
851  h1_z_proj->GetXaxis()->SetTitleSize(0.05);
852  h1_z_proj->GetYaxis()->SetTitleSize(0.05);
853  h1_z_proj->GetXaxis()->SetTitle("z_proj (cm)");
854  h1_z_proj->SetMarkerColor(4);
855  h1_z_proj->Draw();
856 
857  c4->cd(2);
858  gPad->SetLogy();
859 
861  Double_t z_rand_sum_up = h1_z_up_rand->Integral();
862  Double_t z_rand_sum_up_left = h1_z_up_rand_left->Integral();
863  Double_t z_rand_sum_up_right = h1_z_up_rand_right->Integral();
864  cout << " ave=" << z_rand_sum_up << " left=" << z_rand_sum_up_left << " right=" << z_rand_sum_up_right << endl;
865 
866 
867  h1_z_up->SetTitle(filename);
868  // h1_z_up->GetXaxis()->SetRangeUser(xmin,xmax);
869  // h1_z_up->GetYaxis()->SetRangeUser(ymin,ymax);
870  h1_z_up->GetXaxis()->SetTitleSize(0.05);
871  h1_z_up->GetYaxis()->SetTitleSize(0.05);
872  h1_z_up->GetXaxis()->SetTitle("z_up (cm)");
873  h1_z_up->SetMarkerColor(4);
874  h1_z_up->Draw();
875  h1_z_up_rand->SetLineColor(2);
876  h1_z_up_rand->Draw("same");
877 
878  c4->cd(3);
879  gPad->SetLogy();
880 
882  Double_t z_rand_sum_down = h1_z_down_rand->Integral();
883  Double_t z_rand_sum_down_left = h1_z_down_rand_left->Integral();
884  Double_t z_rand_sum_down_right = h1_z_down_rand_right->Integral();
885  cout << " ave=" << z_rand_sum_down << " left=" << z_rand_sum_down_left << " right=" << z_rand_sum_down_right << endl;
886 
887  h1_z_down->SetTitle(filename);
888  // h1_z_down->GetXaxis()->SetRangeUser(xmin,xmax);
889  // h1_z_down->GetYaxis()->SetRangeUser(ymin,ymax);
890  h1_z_down->GetXaxis()->SetTitleSize(0.05);
891  h1_z_down->GetYaxis()->SetTitleSize(0.05);
892  h1_z_down->GetXaxis()->SetTitle("z_down (cm)");
893  h1_z_down->SetMarkerColor(4);
894  h1_z_down->Draw();
895  h1_z_down_rand->SetLineColor(2);
896  h1_z_down_rand->Draw("same");
897 
898  c4->cd(4);
899 
901  h1_eff_z_up->Divide(h1_eff_z_up_temp,h1_z_proj,1,1,"B");
902 
903  h1_eff_z_up->SetTitle(filename);
904  // h1_eff_z_up->GetXaxis()->SetRangeUser(xmin,xmax);
905  // h1_eff_z_up->GetYaxis()->SetRangeUser(ymin,ymax);
906  h1_eff_z_up->GetXaxis()->SetTitleSize(0.05);
907  h1_eff_z_up->GetYaxis()->SetTitleSize(0.05);
908  h1_eff_z_up->GetXaxis()->SetTitle("eff_z_up (cm)");
909  h1_eff_z_up->SetMarkerColor(4);
910  h1_eff_z_up->Draw();
911 
912  c4->cd(5);
913 
915  h1_eff_z_down->Divide(h1_eff_z_down_temp,h1_z_proj,1,1,"B");
916 
917  h1_eff_z_down->SetTitle(filename);
918  // h1_eff_z_down->GetXaxis()->SetRangeUser(xmin,xmax);
919  // h1_eff_z_down->GetYaxis()->SetRangeUser(ymin,ymax);
920  h1_eff_z_down->GetXaxis()->SetTitleSize(0.05);
921  h1_eff_z_down->GetYaxis()->SetTitleSize(0.05);
922  h1_eff_z_down->GetXaxis()->SetTitle("eff_z_down (cm)");
923  h1_eff_z_down->SetMarkerColor(4);
924  h1_eff_z_down->Draw();
925 
926  c4->cd(6);
927 
928  sprintf (estring,"Average Efficiency\n");
929  printf("estring=%s",estring);
930  t1->DrawLatex(0.2,0.95,estring); // t1->SetNDC();
931  t1->SetTextSize(0.04);
932  t1->Draw();
933 
934  Double_t z_count_up_diff = count_up - z_rand_sum_up;
935  Double_t z_count_down_diff = count_down - z_rand_sum_down;
936  cout << endl << endl << endl << "count_proj=" << count_proj << " count_up=" << count_up << " count_down=" << count_down << " z_count_down_diff=" << z_count_down_diff << " z_count_up_diff=" << z_count_up_diff << " ratio_down=" <<
937  z_count_down_diff/count_proj << " ratio_up=" << z_count_up_diff/count_proj << endl << endl;
938 
939 
940  sprintf (estring,"Layer= %d\n",layer);
941  printf("estring=%s",estring);
942  t1->DrawLatex(0.2,0.90,estring);
943  sprintf (estring,"Proj-Hit <= %d\n",coinc_cut);
944  printf("estring=%s",estring);
945  t1->DrawLatex(0.2,0.85,estring);
946  sprintf (estring,"Projected counts= %d\n",count_proj);
947  printf("estring=%s",estring);
948  t1->DrawLatex(0.2,0.75,estring);
949  sprintf (estring,"Upstream counts= %.0f\n",z_count_up_diff);
950  printf("estring=%s",estring);
951  t1->DrawLatex(0.2,0.70,estring);
952  sprintf (estring,"Downstream counts= %.0f\n",z_count_down_diff);
953  printf("estring=%s",estring);
954  t1->DrawLatex(0.2,0.65,estring);
955  sprintf (estring,"Upstream efficiency= %.3f\n",z_count_up_diff/count_proj);
956  printf("estring=%s",estring);
957  t1->DrawLatex(0.2,0.6,estring);
958  sprintf (estring,"Downstream efficiency= %.3f\n",z_count_down_diff/count_proj);
959  printf("estring=%s",estring);
960  t1->DrawLatex(0.2,0.55,estring);
961 
962 
963  TCanvas *c5 = new TCanvas("c5", "c5",200,10,1000,700);
964 
965  c5->Divide(3,2);
966 
967  c5->cd(1);
968 
969  h1_Evis_proj->SetTitle(filename);
970  // h1_Evis_proj->GetXaxis()->SetRangeUser(xmin,xmax);
971  // h1_Evis_proj->GetYaxis()->SetRangeUser(ymin,ymax);
972  h1_Evis_proj->GetXaxis()->SetTitleSize(0.05);
973  h1_Evis_proj->GetYaxis()->SetTitleSize(0.05);
974  h1_Evis_proj->GetXaxis()->SetTitle("Evis (GeV)");
975  h1_Evis_proj->SetMarkerColor(4);
976  h1_Evis_proj->Draw();
977 
978  c5->cd(2);
979  gPad->SetLogy();
980 
982  Double_t Evis_rand_sum_up = h1_Evis_up_rand->Integral();
983  Double_t Evis_rand_sum_up_left = h1_Evis_up_rand_left->Integral();
984  Double_t Evis_rand_sum_up_right = h1_Evis_up_rand_right->Integral();
985  cout << " ave=" << Evis_rand_sum_up << " left=" << Evis_rand_sum_up_left << " right=" << Evis_rand_sum_up_right << endl;
986 
987 
988  h1_Evis_up->SetTitle(filename);
989  // h1_Evis_up->GetXaxis()->SetRangeUser(xmin,xmax);
990  // h1_Evis_up->GetYaxis()->SetRangeUser(ymin,ymax);
991  h1_Evis_up->GetXaxis()->SetTitleSize(0.05);
992  h1_Evis_up->GetYaxis()->SetTitleSize(0.05);
993  h1_Evis_up->GetXaxis()->SetTitle("Evis_up (GeV)");
994  h1_Evis_up->SetMarkerColor(4);
995  h1_Evis_up->Draw();
996  h1_Evis_up_rand->SetLineColor(2);
997  h1_Evis_up_rand->Draw("same");
998 
999  c5->cd(3);
1000  gPad->SetLogy();
1001 
1003  Double_t Evis_rand_sum_down = h1_Evis_down_rand->Integral();
1004  Double_t Evis_rand_sum_down_left = h1_Evis_down_rand_left->Integral();
1005  Double_t Evis_rand_sum_down_right = h1_Evis_down_rand_right->Integral();
1006  cout << " ave=" << Evis_rand_sum_down << " left=" << Evis_rand_sum_down_left << " right=" << Evis_rand_sum_down_right << endl;
1007 
1008  h1_Evis_down->SetTitle(filename);
1009  // h1_Evis_down->GetXaxis()->SetRangeUser(xmin,xmax);
1010  // h1_Evis_down->GetYaxis()->SetRangeUser(ymin,ymax);
1011  h1_Evis_down->GetXaxis()->SetTitleSize(0.05);
1012  h1_Evis_down->GetYaxis()->SetTitleSize(0.05);
1013  h1_Evis_down->GetXaxis()->SetTitle("Evis_down (GeV)");
1014  h1_Evis_down->SetMarkerColor(4);
1015  h1_Evis_down->Draw();
1016  h1_Evis_down_rand->SetLineColor(2);
1017  h1_Evis_down_rand->Draw("same");
1018 
1019  c5->cd(4);
1020 
1023 
1024  h1_eff_Evis_up->SetTitle(filename);
1025  // h1_eff_Evis_up->GetXaxis()->SetRangeUser(xmin,xmax);
1026  // h1_eff_Evis_up->GetYaxis()->SetRangeUser(ymin,ymax);
1027  h1_eff_Evis_up->GetXaxis()->SetTitleSize(0.05);
1028  h1_eff_Evis_up->GetYaxis()->SetTitleSize(0.05);
1029  h1_eff_Evis_up->GetXaxis()->SetTitle("eff_Evis_up (GeV)");
1030  h1_eff_Evis_up->SetMarkerColor(4);
1031  h1_eff_Evis_up->Draw();
1032 
1033  c5->cd(5);
1034 
1037 
1038  h1_eff_Evis_down->SetTitle(filename);
1039  // h1_eff_Evis_down->GetXaxis()->SetRangeUser(xmin,xmax);
1040  // h1_eff_Evis_down->GetYaxis()->SetRangeUser(ymin,ymax);
1041  h1_eff_Evis_down->GetXaxis()->SetTitleSize(0.05);
1042  h1_eff_Evis_down->GetYaxis()->SetTitleSize(0.05);
1043  h1_eff_Evis_down->GetXaxis()->SetTitle("eff_Evis_down (GeV)");
1044  h1_eff_Evis_down->SetMarkerColor(4);
1045  h1_eff_Evis_down->Draw();
1046 
1047  c5->cd(6);
1048 
1049  sprintf (estring,"Average Efficiency\n");
1050  printf("estring=%s",estring);
1051  t1->DrawLatex(0.2,0.95,estring); // t1->SetNDC();
1052  t1->SetTextSize(0.04);
1053  t1->Draw();
1054 
1055  Double_t Evis_count_up_diff = count_up - Evis_rand_sum_up;
1056  Double_t Evis_count_down_diff = count_down - Evis_rand_sum_down;
1057  cout << endl << endl << endl << "count_proj=" << count_proj << " count_up=" << count_up << " count_down=" << count_down << " Evis_count_down_diff=" << Evis_count_down_diff << " Evis_count_up_diff=" << Evis_count_up_diff << " ratio_down=" <<
1058  Evis_count_down_diff/count_proj << " ratio_up=" << Evis_count_up_diff/count_proj << endl << endl;
1059 
1060 
1061  sprintf (estring,"Layer= %d\n",layer);
1062  printf("estring=%s",estring);
1063  t1->DrawLatex(0.2,0.90,estring);
1064  sprintf (estring,"Proj-Hit <= %d\n",coinc_cut);
1065  printf("estring=%s",estring);
1066  t1->DrawLatex(0.2,0.85,estring);
1067  sprintf (estring,"Projected counts= %d\n",count_proj);
1068  printf("estring=%s",estring);
1069  t1->DrawLatex(0.2,0.75,estring);
1070  sprintf (estring,"Upstream counts= %.0f\n",Evis_count_up_diff);
1071  printf("estring=%s",estring);
1072  t1->DrawLatex(0.2,0.70,estring);
1073  sprintf (estring,"Downstream counts= %.0f\n",Evis_count_down_diff);
1074  printf("estring=%s",estring);
1075  t1->DrawLatex(0.2,0.65,estring);
1076  sprintf (estring,"Upstream efficiency= %.3f\n",Evis_count_up_diff/count_proj);
1077  printf("estring=%s",estring);
1078  t1->DrawLatex(0.2,0.6,estring);
1079  sprintf (estring,"Downstream efficiency= %.3f\n",Evis_count_down_diff/count_proj);
1080  printf("estring=%s",estring);
1081  t1->DrawLatex(0.2,0.55,estring);
1082 
1083 
1084  // open output histogram
1085 
1086  TString outhist_name = "root/"+filename+"_out.root";
1087  TFile *outhist = new TFile(outhist_name,"recreate");
1088 
1089  h1_eff_up->Write();
1090  h1_eff_down->Write();
1091  h1_eff_mom_up->Write();
1092  h1_eff_mom_down->Write();
1093  h1_eff_z_up->Write();
1094  h1_eff_z_down->Write();
1095  h1_eff_Evis_up->Write();
1096  h1_eff_Evis_down->Write();
1097  h1_diff_up->Write();
1098  h1_diff_down->Write();
1099  outhist->Close();
1100 
1101  // open file for output
1102 
1103  TString outfile = "dat/"+filename+".dat";
1104  cout << "Opening file: " << outfile.Data() << endl;
1105 
1106  ofstream filedat;
1107  filedat.open (outfile.Data(), ios::out);
1108 
1109  filedat << " run= " << filerun << " layer= " << layer << " coinc_cut= " << coinc_cut << endl;
1110  filedat << " count_proj= " << count_proj << " count_up_diff= " << count_up_diff << " count_down_diff= " << count_down_diff << " eff_up= "
1111  << count_up_diff/count_proj << " eff_down= " << count_down_diff/count_proj << endl;
1112  filedat << " count_proj= " << count_proj << " mom_count_up_diff= " << mom_count_up_diff << " mom_count_down_diff= " << mom_count_down_diff << " mom_eff_up= "
1113  << mom_count_up_diff/count_proj << " eff_down= " << mom_count_down_diff/count_proj << endl;
1114  filedat << " count_proj= " << count_proj << " z_count_up_diff= " << z_count_up_diff << " z_count_down_diff= " << z_count_down_diff << " z_eff_up= "
1115  << z_count_up_diff/count_proj << " eff_down= " << z_count_down_diff/count_proj << endl;
1116  filedat << " count_proj= " << count_proj << " Evis_count_up_diff= " << Evis_count_up_diff << " Evis_count_down_diff= " << Evis_count_down_diff << " Evis_eff_up= "
1117  << Evis_count_up_diff/count_proj << " eff_down= " << Evis_count_down_diff/count_proj << endl;
1118  filedat.close();
1119 
1120  c0->SaveAs("pdf/"+filename+".pdf(");
1121  c1->SaveAs("pdf/"+filename+".pdf");
1122  c2->SaveAs("pdf/"+filename+".pdf");
1123  c3->SaveAs("pdf/"+filename+".pdf");
1124  c4->SaveAs("pdf/"+filename+".pdf");
1125  c5->SaveAs("pdf/"+filename+".pdf)");
1126 
1127 
1128 }
Int_t count_up
virtual Bool_t Process(Long64_t entry)
const Int_t nfiles
Double_t c0[2][NMODULES]
Definition: tw_corr.C:67
TH1F * h1_mom_down_rand
TH1F * h1_z_down
TH1F * h1_z_down_rand_left
Int_t rand_offset
Int_t layer
TH1F * h1_z_up_rand_left
TH1F * h1_mom_down_rand_left
TString filerun
TH1F * h1_diff_down
TH1F * h1_Evis_up_rand
Int_t count_down
sprintf(text,"Post KinFit Cut")
TString filename
TH1F * h1_mom_up_rand_left
TH1F * h1_z_up
TH1F * h1_eff_z_up_temp
TH1F * h1_eff_down_temp
TH1F * h1_Evis_down_rand
TH1F * h1_eff_z_up
TH1F * h1_mom_up_rand_right
TH1F * h1_eff_Evis_down_temp
TH1F * h1_NearestBCALSectors_Layer_Upstream
TH1F * h1_eff_Evis_down
char estring[256]
TH1F * h1_diff_up_rand_right
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
Int_t PID_PDG
pointer to the analyzed TTree or TChain
TH1F * h1_Evis_down_rand_left
TH1F * h1_eff_Evis_up
TH1F * h1_Evis_up
TH1F * h1_layer_up_rand
Double_t c2[2][NMODULES]
Definition: tw_corr.C:69
TH1F * h1_Evis_up_rand_right
TH1F * h1_z_down_rand
TH1F * h1_layer_up
TH1F * h1_mom_proj
TH1F * h1_mom_down_rand_right
TH1F * h1_pid_pdg
TH1F * h1_Evis_proj
virtual void SlaveBegin(TTree *tree)
TH1F * h1_eff_up_temp
Int_t entry_max
TH1F * h1_Evis_down
TH1F * h1_layer_up_rand_right
TH1F * h1_z_proj
TH1F * h1_layer_down
TH1F * h1_z_up_rand_right
TLatex * t1
TFile * outfile
Definition: tw_corr.C:46
TH1F * h1_eff_z_down_temp
TH1F * h1_mom_down
TH1F * h1_eff_Evis_up_temp
Int_t coinc_cut
TH1F * h1_eff_z_down
Int_t count_proj
virtual void Begin(TTree *tree)
TH1F * h1_TrackDeltaPhiToShower
TH1F * h1_eff_mom_up
TH1F * h1_layer_proj
TH1F * h1_eff_down
TH1F * h1_eff_up
TH1F * h1_mom_up_rand
TH1F * h1_NearestBCALSectors_Layer_Downstream
TH1F * h1_ProjectedBCALSectors_Layer
TH1F * h1_layer_down_rand_right
TH1F * h1_z_up_rand
TH1F * h1_diff_down_rand_right
Double_t ymin
Definition: bcal_hist_eff.C:89
TH1F * h1_eff_mom_down_temp
TH1F * h1_layer_down_rand
TH1F * h1_diff_down_rand_left
TCanvas * c4
TH1F * h1_layer_up_rand_left
TH1F * h1_diff_up_rand_left
TH1F * h1_TrackDeltaZToShower
Double_t ymax
Definition: bcal_hist_eff.C:91
TH1F * h1_layer_down_rand_left
TH1F * h1_Evis_up_rand_left
Int_t ndx
TH1F * h1_eff_mom_up_temp
TCanvas * c3
printf("string=%s", string)
TH1F * h1_Evis_down_rand_right
TH1F * h1_diff_up
TH1F * h1_z_down_rand_right
TH1F * h1_eff_mom_down
TH1F * h1_mom_up