CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
comparisonPlots.cc
Go to the documentation of this file.
1 #include "comparisonPlots.h"
2 #include <string>
3 #include <sstream>
4 
5 #include "TProfile.h"
6 #include "TList.h"
7 #include "TNtuple.h"
8 #include "TString.h"
9 #include <iostream>
10 #include "TStyle.h"
11 #include "TGraph.h"
12 #include "TMultiGraph.h"
13 #include "THStack.h"
14 
15 
17 {
18 
20 
21  fin = new TFile(filename.c_str());
22  fin->cd();
23 
24  output = new TFile((outputDir+outputFilename).c_str(),"recreate");
25  output->cd();
26 
27  readTree();
28 
29 }
30 
32 
33  data = (TTree*)fin->Get("alignTree");
34  data->SetBranchAddress("id",&id_);
35  data->SetBranchAddress("mid",&mid_);
36  data->SetBranchAddress("level",&level_);
37  data->SetBranchAddress("mlevel",&mlevel_);
38  data->SetBranchAddress("sublevel",&sublevel_);
39  data->SetBranchAddress("x",&x_);
40  data->SetBranchAddress("y",&y_);
41  data->SetBranchAddress("z",&z_);
42  data->SetBranchAddress("alpha",&alpha_);
43  data->SetBranchAddress("beta",&beta_);
44  data->SetBranchAddress("gamma",&gamma_);
45  data->SetBranchAddress("phi",&phi_);
46  data->SetBranchAddress("eta",&eta_);
47  data->SetBranchAddress("r",&r_);
48  data->SetBranchAddress("dx",&dx_);
49  data->SetBranchAddress("dy",&dy_);
50  data->SetBranchAddress("dz",&dz_);
51  data->SetBranchAddress("dphi",&dphi_);
52  data->SetBranchAddress("dr",&dr_);
53  data->SetBranchAddress("dalpha",&dalpha_);
54  data->SetBranchAddress("dbeta",&dbeta_);
55  data->SetBranchAddress("dgamma",&dgamma_);
56  data->SetBranchAddress("useDetId",&useDetId_);
57  data->SetBranchAddress("detDim",&detDim_);
58 }
59 
60 void comparisonPlots::plotTwist(TCut Cut, char* dirName, bool savePlot, std::string plotName, bool autolimits,int ColorCode)
61 {
62  gStyle->SetTitleAlign(22);
63  gStyle->SetTitleX(0.5);
64  gStyle->SetTitleY(0.97);
65  gStyle->SetTitleFont(62);
66 
67  TDirectory* plotDir = output->mkdir( dirName );
68 
69  double minimum, maximum;
70 
71  if (autolimits)
72  {
73  TH1F* phdphi = new TH1F("phdphi", "phdphi", 200, -10, 10);
74  data->Project("phdphi","dphi",Cut);
75  getHistMaxMin(phdphi, maximum, minimum, 1);
76  delete phdphi;
77  }
78  else
79  {
80  minimum = -0.0004, maximum = 0.0004;
81  }
82 
83 
84  TH2F* h_dphiVz = new TH2F("h_dphiVz","#Delta #phi vs. z", 200,minimum,maximum, 200,minimum,maximum);
85  h_dphiVz->SetMarkerStyle(6);
86 
87  int j = 2;
88  TCut zCut[6];
89  zCut[0] = "z < 0";
90  zCut[1] = "z >= 0";
91 
92 
93  if (ColorCode == 1) {
94  j = 6;
95  // zCut[6];
96  zCut[0] = "sublevel==1";
97  zCut[1] = "sublevel==2";
98  zCut[2] = "sublevel==3";
99  zCut[3] = "sublevel==4";
100  zCut[4] = "sublevel==5";
101  zCut[5] = "sublevel==6";
102  }
103 
104  std::stringstream st;
105  st << "dphi > " << minimum << " && dphi < " << maximum;
106 
107  TCut minmaxCut(st.str().c_str());
108 
109  data->Project("h_dphiVz", "dphi:z",Cut+minmaxCut);
110  TGraph* gr_dphiVz_Array[j];
111  TMultiGraph* mgr_dphiVz=new TMultiGraph();
112  for ( int i = 0; i < j; i++) {
113  data->Draw("dphi:z",Cut+zCut[i]+minmaxCut);
114  gr_dphiVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
115  gr_dphiVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
116  gr_dphiVz_Array[i]->SetMarkerStyle(6);
117  gr_dphiVz_Array[i]->SetMaximum(maximum);
118  gr_dphiVz_Array[i]->SetMinimum(minimum);
119  mgr_dphiVz->Add(gr_dphiVz_Array[i],"p");
120  }
121 
122 
123 
124  // --------- draw histograms ---------
125  TCanvas* c = new TCanvas("c_twist", "c_twist", 200, 10, 600, 600);
126  c->SetFillColor(0);
127  data->SetMarkerSize(0.5);
128  data->SetMarkerStyle(6);
129  c->Divide(1,1);
130 
131  mgr_dphiVz->SetTitle("#Delta #phi vs. z");
132  // if (!autolimits)
133  // h_dphiVz->Draw();
134  // else
135  mgr_dphiVz->SetMaximum(maximum);
136  mgr_dphiVz->SetMinimum(minimum);
137  mgr_dphiVz->Draw("a");
138 
139  c->Update();
140  plotDir->cd();
141 
142  //h_dphiVz->Write();
143  if (savePlot) c->Print((_outputDir+"plotTwist_"+plotName).c_str());
144 
145  delete c;
146  delete h_dphiVz;
147 }
148 
149 void comparisonPlots::plot3x3Rot(TCut Cut, char* dirName, bool savePlot, std::string plotName, bool autolimits, int ColorCode ){
150 
151  gStyle->SetTitleFont(62);
152  gStyle->SetOptTitle(0);
153 
154  gStyle->SetFrameBorderMode(0);
155  gStyle->SetCanvasBorderMode(0);
156  gStyle->SetPadBorderMode(0);
157  gStyle->SetPadColor(0);
158  gStyle->SetCanvasColor(0);
159  gStyle->SetTitleColor(1);
160  gStyle->SetStatColor(0);
161  gStyle->SetStatBorderSize(1);
162  gStyle->SetFrameFillColor(0);
163 
164  gStyle->SetTextFont(132);
165  gStyle->SetTextSize(0.08);
166  gStyle->SetLabelFont(132,"x");
167  gStyle->SetLabelFont(132,"y");
168  gStyle->SetLabelFont(132,"z");
169  gStyle->SetTitleSize(0.08,"x");
170  gStyle->SetTitleSize(0.08,"y");
171  gStyle->SetTitleSize(0.08,"z");
172  gStyle->SetLabelSize(0.08,"x");
173  gStyle->SetLabelSize(0.08,"y");
174  gStyle->SetLabelSize(0.08,"z");
175 
176  gStyle->SetMarkerStyle(8);
177  gStyle->SetHistLineWidth(1.85);
178  gStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
179 
180  gStyle->SetPadTickX(1);
181  gStyle->SetPadTickY(1);
182 
183  TDirectory* plotDir = output->mkdir( dirName );
184 
185  double minimumR, maximumR;
186  double minimumZ, maximumZ;
187  double minimumPhi, maximumPhi;
188  double minimumDalpha, maximumDalpha;
189  double minimumDbeta, maximumDbeta;
190  double minimumDgamma, maximumDgamma;
191 
192  if (autolimits){
193  // --------- get right limits for histogram ---------
194  TH1F* phr = new TH1F("phr", "phr", 200, 0, 200);
195  TH1F* phz = new TH1F("phz", "phz", 400, -300, 300);
196  TH1F* phphi = new TH1F("phphi", "phphi", 200, -3.15, 3.15);
197  TH1F* phdalpha = new TH1F("phdalpha", "phdalpha", 2000, -10, 10);
198  TH1F* phdbeta = new TH1F("phdbeta", "phdbeta", 2000, -10, 10);
199  TH1F* phdgamma = new TH1F("phdgamma", "phdgamma", 200, -10, 10);
200  data->Project("phr","r",Cut);
201  data->Project("phz","z",Cut);
202  data->Project("phphi","phi",Cut);
203  data->Project("phdalpha","dalpha",Cut);
204  data->Project("phdbeta","dbeta",Cut);
205  data->Project("phdgamma","dgamma",Cut);
206  getHistMaxMin(phr, maximumR, minimumR, 0);
207  getHistMaxMin(phz, maximumZ, minimumZ, 0);
208  getHistMaxMin(phphi, maximumPhi, minimumPhi, 0);
209  getHistMaxMin(phdalpha, maximumDalpha, minimumDalpha, 1);
210  getHistMaxMin(phdbeta, maximumDbeta, minimumDbeta, 1);
211  getHistMaxMin(phdgamma, maximumDgamma, minimumDgamma, 1);
212  }
213  else{
214  minimumR = 0., maximumR = 200.;
215  minimumZ = -300., maximumZ = 300.;
216  minimumPhi = -3.15, maximumPhi = 3.15;
217  minimumDalpha = -1, maximumDalpha = 1;
218  minimumDbeta = -1, maximumDbeta = 1;
219  minimumDgamma = -1, maximumDgamma = 1;
220  }
221 
222  // --------- declare histograms ---------
223  TH2F* h_dalphaVr = new TH2F("h_dalphaVr","#Delta #alpha vs. r",200,minimumR,maximumR,200,minimumDalpha,maximumDalpha);
224  TH2F* h_dbetaVr = new TH2F("h_dbetaVr", "#Delta #beta vs. r", 200,minimumR,maximumR,200,minimumDbeta, maximumDbeta);
225  TH2F* h_dgammaVr = new TH2F("h_dgammaVr","#Delta #gamma vs. r",200,minimumR,maximumR,200,minimumDgamma,maximumDgamma);
226 
227  TH2F* h_dalphaVz = new TH2F("h_dalphaVz","#Delta #alpha vs. z", 200,minimumZ,maximumZ, 200,minimumDalpha,maximumDalpha);
228  TH2F* h_dbetaVz = new TH2F("h_dbetaVz", "#Delta #beta vs. z", 200,minimumZ,maximumZ, 200,minimumDbeta, maximumDbeta);
229  TH2F* h_dgammaVz = new TH2F("h_dgammaVz","#Delta #gama vs. z", 200,minimumZ,maximumZ, 200,minimumDgamma,maximumDgamma);
230 
231  TH2F* h_dalphaVphi = new TH2F("h_dalphaVphi","#Delta #alpha vs. #phi", 200,minimumPhi,maximumPhi,200,minimumDalpha,maximumDalpha);
232  TH2F* h_dbetaVphi = new TH2F("h_dbetaVphi", "#Delta #beta vs. #phi", 200,minimumPhi,maximumPhi,200,minimumDbeta, maximumDbeta);
233  TH2F* h_dgammaVphi = new TH2F("h_dgammaVphi","#Delta #gamma vs. #phi", 200,minimumPhi,maximumPhi,200,minimumDgamma,maximumDgamma);
234 
235  h_dalphaVr ->SetMarkerStyle(6) ;
236  h_dbetaVr ->SetMarkerStyle(6) ;
237  h_dgammaVr ->SetMarkerStyle(6) ;
238 
239  h_dalphaVz ->SetMarkerStyle(6) ;
240  h_dbetaVz ->SetMarkerStyle(6) ;
241  h_dgammaVz ->SetMarkerStyle(6) ;
242 
243  h_dalphaVphi ->SetMarkerStyle(6) ;
244  h_dbetaVphi ->SetMarkerStyle(6) ;
245  h_dgammaVphi ->SetMarkerStyle(6) ;
246 
247  int j = 2;
248  TCut zCut[6];
249  zCut[0] = "z < 0";
250  zCut[1] = "z >= 0";
251 
252  if (ColorCode == 1) {
253  j = 6;
254  // zCut[6];
255  zCut[0] = "sublevel==1";
256  zCut[1] = "sublevel==2";
257  zCut[2] = "sublevel==3";
258  zCut[3] = "sublevel==4";
259  zCut[4] = "sublevel==5";
260  zCut[5] = "sublevel==6";
261  }
262 
263  data->Project("h_dalphaVr", "dalpha*1000:r",Cut);
264  TGraph* gr_dalphaVr_Array[j];
265  TMultiGraph* mgr_dalphaVr=new TMultiGraph();
266  for ( int i = 0; i < j; i++) {
267  data->Draw("dalpha*1000:r",Cut+zCut[i]);
268  gr_dalphaVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
269  gr_dalphaVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
270  gr_dalphaVr_Array[i]->SetMarkerStyle(6);
271  mgr_dalphaVr->Add(gr_dalphaVr_Array[i],"p");
272  }
273 
274  data->Project("h_dbetaVr", "dbeta*1000:r",Cut);
275  TGraph* gr_dbetaVr_Array[j];
276  TMultiGraph* mgr_dbetaVr=new TMultiGraph();
277  for ( int i = 0; i < j; i++) {
278  data->Draw("dbeta*1000:r",Cut+zCut[i]);
279  gr_dbetaVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
280  gr_dbetaVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
281  gr_dbetaVr_Array[i]->SetMarkerStyle(6);
282  mgr_dbetaVr->Add(gr_dbetaVr_Array[i],"p");
283  }
284 
285  data->Project("h_dgammaVr", "dgamma*1000:r",Cut);
286  TGraph* gr_dgammaVr_Array[j];
287  TMultiGraph* mgr_dgammaVr=new TMultiGraph();
288  for ( int i = 0; i < j; i++) {
289  data->Draw("dgamma*1000:r",Cut+zCut[i]);
290  gr_dgammaVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
291  gr_dgammaVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
292  gr_dgammaVr_Array[i]->SetMarkerStyle(6);
293  mgr_dgammaVr->Add(gr_dgammaVr_Array[i],"p");
294  }
295 
296  data->Project("h_dalphaVz", "dalpha*1000:z",Cut);
297  TGraph* gr_dalphaVz_Array[j];
298  TMultiGraph* mgr_dalphaVz=new TMultiGraph();
299  for ( int i = 0; i < j; i++) {
300  data->Draw("dalpha*1000:z",Cut+zCut[i]);
301  gr_dalphaVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
302  gr_dalphaVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
303  gr_dalphaVz_Array[i]->SetMarkerStyle(6);
304  mgr_dalphaVz->Add(gr_dalphaVz_Array[i],"p");
305  }
306 
307  data->Project("h_dbetaVz", "dbeta*1000:z",Cut);
308  TGraph* gr_dbetaVz_Array[j];
309  TMultiGraph* mgr_dbetaVz=new TMultiGraph();
310  for ( int i = 0; i < j; i++) {
311  data->Draw("dbeta*1000:z",Cut+zCut[i]);
312  gr_dbetaVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
313  gr_dbetaVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
314  gr_dbetaVz_Array[i]->SetMarkerStyle(6);
315  mgr_dbetaVz->Add(gr_dbetaVz_Array[i],"p");
316  }
317 
318  data->Project("h_dgammaVz", "dgamma*1000:z",Cut);
319  TGraph* gr_dgammaVz_Array[j];
320  TMultiGraph* mgr_dgammaVz=new TMultiGraph();
321  for ( int i = 0; i < j; i++) {
322  data->Draw("dgamma*1000:z",Cut+zCut[i]);
323  gr_dgammaVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
324  gr_dgammaVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
325  gr_dgammaVz_Array[i]->SetMarkerStyle(6);
326  mgr_dgammaVz->Add(gr_dgammaVz_Array[i],"p");
327  }
328 
329  data->Project("h_dalphaVphi", "dalpha*1000:phi",Cut);
330  TGraph* gr_dalphaVphi_Array[j];
331  TMultiGraph* mgr_dalphaVphi=new TMultiGraph();
332  for ( int i = 0; i < j; i++) {
333  data->Draw("dalpha*1000:phi",Cut+zCut[i]);
334  gr_dalphaVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
335  gr_dalphaVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
336  gr_dalphaVphi_Array[i]->SetMarkerStyle(6);
337  mgr_dalphaVphi->Add(gr_dalphaVphi_Array[i],"p");
338  }
339 
340  data->Project("h_dbetaVphi", "dbeta*1000:phi",Cut);
341  TGraph* gr_dbetaVphi_Array[j];
342  TMultiGraph* mgr_dbetaVphi=new TMultiGraph();
343  for ( int i = 0; i < j; i++) {
344  data->Draw("dbeta*1000:phi",Cut+zCut[i]);
345  gr_dbetaVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
346  gr_dbetaVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
347  gr_dbetaVphi_Array[i]->SetMarkerStyle(6);
348  mgr_dbetaVphi->Add(gr_dbetaVphi_Array[i],"p");
349  }
350 
351  data->Project("h_dgammaVphi", "dgamma*1000:phi",Cut);
352  TGraph* gr_dgammaVphi_Array[j];
353  TMultiGraph* mgr_dgammaVphi=new TMultiGraph();
354  for ( int i = 0; i < j; i++) {
355  data->Draw("dgamma*1000:phi",Cut+zCut[i]);
356  gr_dgammaVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
357  gr_dgammaVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
358  gr_dgammaVphi_Array[i]->SetMarkerStyle(6);
359  mgr_dgammaVphi->Add(gr_dgammaVphi_Array[i],"p");
360  }
361 
362  // --------- draw histograms ---------
363  TCanvas* c = new TCanvas("c", "c", 200, 10, 1200, 700);
364  c->SetFillColor(0);
365  data->SetMarkerSize(0.5);
366  data->SetMarkerStyle(6);
367  c->Divide(3,3);
368  c->cd(1);
369  if (!autolimits) h_dalphaVr->Draw();
370  if (autolimits) mgr_dalphaVr->Draw("a");
371  c->Update();
372  c->cd(2);
373  if (!autolimits) h_dbetaVr->Draw();
374  if (autolimits) mgr_dbetaVr->Draw("a");
375  c->Update();
376  c->cd(3);
377  if (!autolimits) h_dgammaVr->Draw();
378  if (autolimits) mgr_dgammaVr->Draw("a");
379  c->cd(4);
380  if (!autolimits) h_dalphaVz->Draw();
381  if (autolimits) mgr_dalphaVz->Draw("a");
382  c->cd(5);
383  if (!autolimits) h_dbetaVz->Draw();
384  if (autolimits) mgr_dbetaVz->Draw("a");
385  c->cd(6);
386  if (!autolimits) h_dgammaVz->Draw();
387  if (autolimits) mgr_dgammaVz->Draw("a");
388  c->cd(7);
389  if (!autolimits) h_dalphaVphi->Draw();
390  if (autolimits) mgr_dalphaVphi->Draw("a");
391  c->cd(8);
392  if (!autolimits) h_dbetaVphi->Draw();
393  if (autolimits) mgr_dbetaVphi->Draw("a");
394  c->cd(9);
395  if (!autolimits) h_dgammaVphi->Draw();
396  if (autolimits) mgr_dgammaVphi->Draw("a");
397 
398  mgr_dalphaVr->GetXaxis() ->SetTitle("r (cm)");
399  mgr_dbetaVr->GetXaxis() ->SetTitle("r (cm)");
400  mgr_dgammaVr->GetXaxis() ->SetTitle("r (cm)");
401  mgr_dalphaVz->GetXaxis() ->SetTitle("z (cm)");
402  mgr_dbetaVz->GetXaxis() ->SetTitle("z (cm)");
403  mgr_dgammaVz->GetXaxis() ->SetTitle("z (cm)");
404  mgr_dalphaVphi->GetXaxis()->SetTitle("#phi");
405  mgr_dbetaVphi->GetXaxis() ->SetTitle("#phi");
406  mgr_dgammaVphi->GetXaxis()->SetTitle("#phi");
407 
408  mgr_dalphaVr->GetYaxis() ->SetTitle("#Delta #alpha (mrad)");
409  mgr_dbetaVr->GetYaxis() ->SetTitle("#Delta #beta (mrad)");
410  mgr_dgammaVr->GetYaxis() ->SetTitle("#Delta #gamma (mrad)");
411  mgr_dalphaVz->GetYaxis() ->SetTitle("#Delta #alpha (mrad)");
412  mgr_dbetaVz->GetYaxis() ->SetTitle("#Delta #beta (mrad)");
413  mgr_dgammaVz->GetYaxis() ->SetTitle("#Delta #gamma (mrad)");
414  mgr_dalphaVphi->GetYaxis()->SetTitle("#Delta #alpha (mrad)");
415  mgr_dbetaVphi->GetYaxis() ->SetTitle("#Delta #beta (mrad)");
416  mgr_dgammaVphi->GetYaxis()->SetTitle("#Delta #gamma (mrad)");
417 
418  c->Update();
419 
420  // // --------- set output directory for histograms ---------
421  // plotDir->cd();
422  // h_dalphaVr->Write(); h_dbetaVr->Write(); h_dgammaVr->Write();
423  // h_dalphaVz->Write(); h_dbetaVz->Write(); h_dgammaVz->Write();
424  // h_dalphaVphi->Write(); h_dbetaVphi->Write(); h_dgammaVphi->Write();
425 
426  if (savePlot) c->Print((_outputDir+"plot3x3Rot_"+plotName).c_str());
427 
428 }
429 
430 void comparisonPlots::plot3x5(TCut Cut, char* dirName, bool savePlot, std::string plotName, bool autolimits, int ColorCode ){
431 
432  //int ColorCodeHalfBarrels = 1;
433  //color seperation of moodules corresponding to the different subdets
434  //if you want to seperate corresponding to the halfbarrels (+z or -z) set colorcode !=1
435 
436  gStyle->SetTitleFont(62);
437  gStyle->SetOptTitle(0);
438 
439  gStyle->SetFrameBorderMode(0);
440  gStyle->SetCanvasBorderMode(0);
441  gStyle->SetPadBorderMode(0);
442  gStyle->SetPadColor(0);
443  gStyle->SetCanvasColor(0);
444  gStyle->SetTitleColor(1);
445  gStyle->SetStatColor(0);
446  gStyle->SetStatBorderSize(1);
447  gStyle->SetFrameFillColor(0);
448 
449  gStyle->SetTextFont(132);
450  gStyle->SetTextSize(0.08);
451  gStyle->SetLabelFont(132,"x");
452  gStyle->SetLabelFont(132,"y");
453  gStyle->SetLabelFont(132,"z");
454  gStyle->SetTitleSize(0.08,"x");
455  gStyle->SetTitleSize(0.08,"y");
456  gStyle->SetTitleSize(0.08,"z");
457  gStyle->SetLabelSize(0.08,"x");
458  gStyle->SetLabelSize(0.08,"y");
459  gStyle->SetLabelSize(0.08,"z");
460 
461  gStyle->SetMarkerStyle(8);
462  gStyle->SetHistLineWidth(1.85);
463  gStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
464 
465  gStyle->SetTitleAlign(22);
466  gStyle->SetTitleX(0.5);
467  gStyle->SetTitleY(0.97);
468  gStyle->SetTitleFont(62);
469 
470  gStyle->SetPadTickX(1);
471  gStyle->SetPadTickY(1);
472 
473  gStyle->SetPadTopMargin(0.1);
474  gStyle->SetPadRightMargin(0.05);
475  gStyle->SetPadBottomMargin(0.16);
476  gStyle->SetPadLeftMargin(0.18);
477 
478  // --------- create directory for histograms ---------
479  //const char* dirName = Cut;
480  TDirectory* plotDir = output->mkdir( dirName );
481 
482  // --------- get right limits for histogram ---------
483  double minimumR, maximumR;
484  double minimumZ, maximumZ;
485  double minimumPhi, maximumPhi;
486  double minimumDR, maximumDR;
487  double minimumDZ, maximumDZ;
488  double minimumRDPhi, maximumRDPhi;
489  double minimumDX, maximumDX;
490  double minimumDY, maximumDY;
491  if (autolimits){
492  // --------- get right limits for histogram ---------
493  TH1F* phr = new TH1F("phr", "phr", 200, 0, 200 );
494  TH1F* phz = new TH1F("phz", "phz", 400, -300, 300 );
495  TH1F* phphi = new TH1F("phphi", "phphi", 200, -3.15, 3.15);
496  TH1F* phdr = new TH1F("phdr", "phdr", 20000,-1000, 1000 );
497  TH1F* phdz = new TH1F("phdz", "phdz", 20000,-1000, 1000 );
498  TH1F* phrdphi = new TH1F("phrdphi", "phrdphi", 20000,-1000, 1000 );
499  TH1F* phdx = new TH1F("phdx", "phy", 20000,-1000, 1000 );
500  TH1F* phdy = new TH1F("phdy", "phy", 20000,-1000, 1000 );
501  data->Project("phr","r",Cut);
502  data->Project("phz","z",Cut);
503  data->Project("phphi","phi",Cut);
504  data->Project("phdr","dr*10000",Cut);
505  data->Project("phdz","dz*10000",Cut);
506  data->Project("phrdphi","r*dphi*10000",Cut);
507  data->Project("phdx","dx*10000",Cut);
508  data->Project("phdy","dy*10000",Cut);
509  getHistMaxMin(phr, maximumR, minimumR, 0);
510  getHistMaxMin(phz, maximumZ, minimumZ, 0);
511  getHistMaxMin(phphi, maximumPhi, minimumPhi, 0);
512  getHistMaxMin(phdr, maximumDR, minimumDR, 1);
513  getHistMaxMin(phdz, maximumDZ, minimumDZ, 1);
514  getHistMaxMin(phrdphi, maximumRDPhi, minimumRDPhi, 1);
515  getHistMaxMin(phdx, maximumDX, minimumDX, 1);
516  getHistMaxMin(phdy, maximumDY, minimumDY, 1);
517  }
518  else{
519  minimumR = 0., maximumR = 200.;
520  minimumZ = -300., maximumZ = 300.;
521  minimumPhi = -3.15, maximumPhi = 3.15;
522  minimumDR = -1, maximumDR = 1;
523  minimumDZ = -1, maximumDZ = 1;
524  minimumRDPhi = -1, maximumRDPhi = 1;
525  minimumDX = -1, maximumDX = 1;
526  minimumDY = -1, maximumDY = 1;
527  }
528 
529 
530  // --------- declare histograms ---------
531  TH1F* h_dr = new TH1F("h_dr", "#Delta r", 2000, minimumDR, maximumDR);
532  TH1F* h_dz = new TH1F("h_dz", "#Delta z", 2000, minimumDZ, maximumDZ);
533  TH1F* h_rdphi = new TH1F("h_rdphi", "r* #Delta #phi", 2000, minimumRDPhi, maximumRDPhi);
534  TH2F* h_drVr = new TH2F("h_drVr","#Delta r vs. r",200,minimumR,maximumR,200,minimumDR,maximumDR);
535  TH2F* h_dzVr = new TH2F("h_dzVr","#Delta z vs. r",200,minimumR,maximumR,200,minimumDZ,maximumDZ);
536  TH2F* h_rdphiVr = new TH2F("h_rdphiVr","r#Delta #phi vs. r",200,minimumR,maximumR,200,minimumRDPhi,maximumRDPhi);
537  TH2F* h_dxVr = new TH2F("h_dxVr","#Delta x vs. r", 200,minimumR,maximumR, 200,minimumDX,maximumDX);
538  TH2F* h_dyVr = new TH2F("h_dyVr","#Delta y vs. r", 200,minimumR,maximumR, 200,minimumDY,maximumDY);
539  TH2F* h_drVz = new TH2F("h_drVz","#Delta r vs. z", 200,minimumZ,maximumZ, 200,minimumDR,maximumDR);
540  TH2F* h_dzVz = new TH2F("h_dzVz","#Delta z vs. z", 200,minimumZ,maximumZ, 200,minimumDZ,maximumDZ);
541  TH2F* h_rdphiVz = new TH2F("h_rdphiVz","r#Delta #phi vs. z", 200,minimumZ,maximumZ, 200,minimumRDPhi,maximumRDPhi);
542  TH2F* h_dxVz = new TH2F("h_dxVz","#Delta x vs. z", 200,minimumZ,maximumZ, 200,minimumDX,maximumDX);
543  TH2F* h_dyVz = new TH2F("h_dyVz","#Delta y vs. z", 200,minimumZ,maximumZ, 200,minimumDY,maximumDY);
544  TH2F* h_drVphi = new TH2F("h_drVphi","#Delta r vs. #phi", 200,minimumPhi,maximumPhi,200,minimumDR,maximumDR);
545  TH2F* h_dzVphi = new TH2F("h_dzVphi","#Delta z vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDZ,maximumDZ);
546  TH2F* h_rdphiVphi = new TH2F("h_rdphiVphi","r#Delta #phi vs. #phi", 200,minimumPhi,maximumPhi,200,minimumRDPhi,maximumRDPhi);
547  TH2F* h_dxVphi = new TH2F("h_dxVphi","#Delta x vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDX,maximumDX);
548  TH2F* h_dyVphi = new TH2F("h_dyVphi","#Delta y vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDY,maximumDY);
549 
550  h_drVr->SetMarkerStyle(6);
551  h_dzVr->SetMarkerStyle(6);
552  h_rdphiVr->SetMarkerStyle(6);
553  h_dxVr->SetMarkerStyle(6);
554  h_dyVr->SetMarkerStyle(6);
555  h_drVz->SetMarkerStyle(6);
556  h_dzVz->SetMarkerStyle(6);
557  h_rdphiVz->SetMarkerStyle(6);
558  h_dxVz->SetMarkerStyle(6);
559  h_dyVz->SetMarkerStyle(6);
560  h_drVphi->SetMarkerStyle(6);
561  h_dzVphi->SetMarkerStyle(6);
562  h_rdphiVphi->SetMarkerStyle(6);
563  h_dxVphi->SetMarkerStyle(6);
564  h_dyVphi->SetMarkerStyle(6);
565 
566 
567  int j = 2;
568  TCut zCut[6];
569  zCut[0] = "z < 0";
570  zCut[1] = "z >= 0";
571 
572 
573  if (ColorCode == 1) {
574  j = 6;
575  // zCut[6];
576  zCut[0] = "sublevel==1";
577  zCut[1] = "sublevel==2";
578  zCut[2] = "sublevel==3";
579  zCut[3] = "sublevel==4";
580  zCut[4] = "sublevel==5";
581  zCut[5] = "sublevel==6";
582  }
583 
584  // --------- project tree onto histograms ---------
585  data->Project("h_dr","dr*10000",Cut);
586  data->Project("h_dz","dz*10000",Cut);
587  data->Project("h_rdphi","r*dphi*10000",Cut);
588 
589 
590  data->Project("h_drVr", "dr*10000:r",Cut);
591  TGraph* gr_drVr_Array[j];
592  TMultiGraph* mgr_drVr=new TMultiGraph();
593  for ( int i = 0; i < j; i++) {
594  data->Draw("dr*10000:r",Cut+zCut[i]);
595  gr_drVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
596  gr_drVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
597  gr_drVr_Array[i]->SetMarkerStyle(6);
598  mgr_drVr->Add(gr_drVr_Array[i],"p");
599  }
600 
601  data->Project("h_dzVr", "dz*10000:r",Cut);
602  TGraph* gr_dzVr_Array[j];
603  TMultiGraph* mgr_dzVr=new TMultiGraph();
604  for ( int i = 0; i < j; i++) {
605  data->Draw("dz*10000:r",Cut+zCut[i]);
606  gr_dzVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
607  gr_dzVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
608  gr_dzVr_Array[i]->SetMarkerStyle(6);
609  mgr_dzVr->Add(gr_dzVr_Array[i],"p");
610  }
611 
612  data->Project("h_rdphiVr", "r*dphi*10000:r",Cut);
613  TGraph* gr_rdphiVr_Array[j];
614  TMultiGraph* mgr_rdphiVr=new TMultiGraph();
615  for ( int i = 0; i < j; i++) {
616  data->Draw("r*dphi*10000:r",Cut+zCut[i]);
617  gr_rdphiVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
618  gr_rdphiVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
619  gr_rdphiVr_Array[i]->SetMarkerStyle(6);
620  mgr_rdphiVr->Add(gr_rdphiVr_Array[i],"p");
621  }
622 
623  data->Project("h_dxVr", "dx*10000:r",Cut);
624  TGraph* gr_dxVr_Array[j];
625  TMultiGraph* mgr_dxVr=new TMultiGraph();
626  for ( int i = 0; i < j; i++) {
627  data->Draw("dx*10000:r",Cut+zCut[i]);
628  gr_dxVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
629  gr_dxVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
630  gr_dxVr_Array[i]->SetMarkerStyle(6);
631  mgr_dxVr->Add(gr_dxVr_Array[i],"p");
632  }
633 
634  data->Project("h_dyVr", "dy*10000:r",Cut);
635  TGraph* gr_dyVr_Array[j];
636  TMultiGraph* mgr_dyVr=new TMultiGraph();
637  for ( int i = 0; i < j; i++) {
638  data->Draw("dy*10000:r",Cut+zCut[i]);
639  gr_dyVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
640  gr_dyVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
641  gr_dyVr_Array[i]->SetMarkerStyle(6);
642  mgr_dyVr->Add(gr_dyVr_Array[i],"p");
643  }
644 
645  data->Project("h_drVz", "dr*10000:z",Cut);
646  TGraph* gr_drVz_Array[j];
647  TMultiGraph* mgr_drVz=new TMultiGraph();
648  for ( int i = 0; i < j; i++) {
649  data->Draw("dr*10000:z",Cut+zCut[i]);
650  gr_drVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
651  gr_drVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
652  gr_drVz_Array[i]->SetMarkerStyle(6);
653  mgr_drVz->Add(gr_drVz_Array[i],"p");
654  }
655 
656  data->Project("h_dzVz", "dz*10000:z",Cut);
657  TGraph* gr_dzVz_Array[j];
658  TMultiGraph* mgr_dzVz=new TMultiGraph();
659  for ( int i = 0; i < j; i++) {
660  data->Draw("dz*10000:z",Cut+zCut[i]);
661  gr_dzVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
662  gr_dzVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
663  gr_dzVz_Array[i]->SetMarkerStyle(6);
664  mgr_dzVz->Add(gr_dzVz_Array[i],"p");
665  }
666 
667  data->Project("h_rdphiVz", "r*dphi*10000:z",Cut);
668  TGraph* gr_rdphiVz_Array[j];
669  TMultiGraph* mgr_rdphiVz=new TMultiGraph();
670  for ( int i = 0; i < j; i++) {
671  data->Draw("r*dphi*10000:z",Cut+zCut[i]);
672  gr_rdphiVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
673  gr_rdphiVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
674  gr_rdphiVz_Array[i]->SetMarkerStyle(6);
675  mgr_rdphiVz->Add(gr_rdphiVz_Array[i],"p");
676  }
677 
678  data->Project("h_dxVz", "dx*10000:z",Cut);
679  TGraph* gr_dxVz_Array[j];
680  TMultiGraph* mgr_dxVz=new TMultiGraph();
681  for ( int i = 0; i < j; i++) {
682  data->Draw("dx*10000:z",Cut+zCut[i]);
683  gr_dxVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
684  gr_dxVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
685  gr_dxVz_Array[i]->SetMarkerStyle(6);
686  mgr_dxVz->Add(gr_dxVz_Array[i],"p");
687  }
688 
689  data->Project("h_dyVz", "dy*10000:z",Cut);
690  TGraph* gr_dyVz_Array[j];
691  TMultiGraph* mgr_dyVz=new TMultiGraph();
692  for ( int i = 0; i < j; i++) {
693  data->Draw("dy*10000:z",Cut+zCut[i]);
694  gr_dyVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
695  gr_dyVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
696  gr_dyVz_Array[i]->SetMarkerStyle(6);
697  mgr_dyVz->Add(gr_dyVz_Array[i],"p");
698  }
699 
700  data->Project("h_drVphi", "dr*10000:phi",Cut);
701  TGraph* gr_drVphi_Array[j];
702  TMultiGraph* mgr_drVphi=new TMultiGraph();
703  for ( int i = 0; i < j; i++) {
704  data->Draw("dr*10000:phi",Cut+zCut[i]);
705  gr_drVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
706  gr_drVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
707  gr_drVphi_Array[i]->SetMarkerStyle(6);
708  mgr_drVphi->Add(gr_drVphi_Array[i],"p");
709  }
710 
711  data->Project("h_dzVphi", "dz*10000:phi",Cut);
712  TGraph* gr_dzVphi_Array[j];
713  TMultiGraph* mgr_dzVphi=new TMultiGraph();
714  for ( int i = 0; i < j; i++) {
715  data->Draw("dz*10000:phi",Cut+zCut[i]);
716  gr_dzVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
717  gr_dzVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
718  gr_dzVphi_Array[i]->SetMarkerStyle(6);
719  mgr_dzVphi->Add(gr_dzVphi_Array[i],"p");
720  }
721 
722  data->Project("h_rdphiVphi", "r*dphi*10000:phi",Cut);
723  TGraph* gr_rdphiVphi_Array[j];
724  TMultiGraph* mgr_rdphiVphi=new TMultiGraph();
725  for ( int i = 0; i < j; i++) {
726  data->Draw("r*dphi*10000:phi",Cut+zCut[i]);
727  gr_rdphiVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
728  gr_rdphiVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
729  gr_rdphiVphi_Array[i]->SetMarkerStyle(6);
730  mgr_rdphiVphi->Add(gr_rdphiVphi_Array[i],"p");
731  }
732 
733  data->Project("h_dxVphi", "dx*10000:phi",Cut);
734  TGraph* gr_dxVphi_Array[j];
735  TMultiGraph* mgr_dxVphi=new TMultiGraph();
736  for ( int i = 0; i < j; i++) {
737  data->Draw("dx*10000:phi",Cut+zCut[i]);
738  gr_dxVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
739  gr_dxVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
740  gr_dxVphi_Array[i]->SetMarkerStyle(6);
741  mgr_dxVphi->Add(gr_dxVphi_Array[i],"p");
742  }
743 
744  data->Project("h_dyVphi", "dy*10000:phi",Cut);
745  TGraph* gr_dyVphi_Array[j];
746  TMultiGraph* mgr_dyVphi=new TMultiGraph();
747  for ( int i = 0; i < j; i++) {
748  data->Draw("dy*10000:phi",Cut+zCut[i]);
749  gr_dyVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
750  gr_dyVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
751  gr_dyVphi_Array[i]->SetMarkerStyle(6);
752  mgr_dyVphi->Add(gr_dyVphi_Array[i],"p");
753  }
754 
755 
756 
757  // --------- draw histograms ---------
758  TCanvas* c0 = new TCanvas("c0", "c0", 200, 10, 900, 300);
759  c0->SetFillColor(0);
760  c0->Divide(3,1);
761  c0->cd(1);
762  h_dr->Draw();
763  c0->cd(2);
764  h_dz->Draw();
765  c0->cd(3);
766  h_rdphi->Draw();
767  if (savePlot) c0->Print((_outputDir+"plot3x1_"+plotName).c_str());
768 
769  //TStyle::SetTitleAlign(23)
770  mgr_drVr->SetTitle("#Delta r vs. r");
771  mgr_dzVr->SetTitle("#Delta z vs. r");
772  mgr_rdphiVr->SetTitle("r#Delta #phi vs. r");
773  mgr_dxVr->SetTitle("#Delta x vs. r");
774  mgr_dyVr->SetTitle("#Delta y vs. r");
775  mgr_drVz->SetTitle("#Delta r vs. z");
776  mgr_dzVz->SetTitle("#Delta z vs. z");
777  mgr_rdphiVz->SetTitle("r#Delta #phi vs. z");
778  mgr_dxVz->SetTitle("#Delta x vs. z");
779  mgr_dyVz->SetTitle("#Delta y vs. z");
780  mgr_drVphi->SetTitle("#Delta r vs. #phi");
781  mgr_dzVphi->SetTitle("#Delta z vs. #phi");
782  mgr_rdphiVphi->SetTitle("r#Delta #phi vs. #phi");
783  mgr_dxVphi->SetTitle("#Delta x vs. #phi");
784  mgr_dyVphi->SetTitle("#Delta y vs. #phi");
785 
786  // --------- draw histograms ---------
787  TCanvas* c = new TCanvas("c", "c", 200, 10, 1200, 700);
788  c->SetFillColor(0);
789  data->SetMarkerSize(0.5);
790  data->SetMarkerStyle(6);
791  c->Divide(5,3);
792  c->cd(1);
793  if (!autolimits) h_drVr->Draw();
794  if (autolimits) mgr_drVr->Draw("a");
795  c->Update();
796  c->cd(2);
797  if (!autolimits) h_dzVr->Draw();
798  if (autolimits) mgr_dzVr->Draw("a");
799  c->Update();
800  c->cd(3);
801  if (!autolimits) h_rdphiVr->Draw();
802  if (autolimits) mgr_rdphiVr->Draw("a");
803  c->cd(4);
804  if (!autolimits) h_dxVr->Draw();
805  if (autolimits) mgr_dxVr->Draw("a");
806  c->cd(5);
807  if (!autolimits) h_dyVr->Draw();
808  if (autolimits) mgr_dyVr->Draw("a");
809  c->cd(6);
810  if (!autolimits) h_drVz->Draw();
811  if (autolimits) mgr_drVz->Draw("a");
812  c->cd(7);
813  if (!autolimits) h_dzVz->Draw();
814  if (autolimits) mgr_dzVz->Draw("a");
815  c->cd(8);
816  if (!autolimits) h_rdphiVz->Draw();
817  if (autolimits) mgr_rdphiVz->Draw("a");
818  c->cd(9);
819  if (!autolimits) h_dxVz->Draw();
820  if (autolimits) mgr_dxVz->Draw("a");
821  c->cd(10);
822  if (!autolimits) h_dyVz->Draw();
823  if (autolimits) mgr_dyVz->Draw("a");
824  c->cd(11);
825  if (!autolimits) h_drVphi->Draw();
826  if (autolimits) mgr_drVphi->Draw("a");
827  c->cd(12);
828  if (!autolimits) h_dzVphi->Draw();
829  if (autolimits) mgr_dzVphi->Draw("a");
830  c->cd(13);
831  if (!autolimits) h_rdphiVphi->Draw();
832  if (autolimits) mgr_rdphiVphi->Draw("a");
833  c->cd(14);
834  if (!autolimits) h_dxVphi->Draw();
835  if (autolimits) mgr_dxVphi->Draw("a");
836  c->cd(15);
837  if (!autolimits) h_dyVphi->Draw();
838  if (autolimits) mgr_dyVphi->Draw("a");
839 
840  mgr_drVr->GetXaxis()->SetTitle("r (cm)");
841  mgr_dzVr->GetXaxis()->SetTitle("r (cm)");
842  mgr_rdphiVr->GetXaxis()->SetTitle("r (cm)");
843  mgr_dxVr->GetXaxis()->SetTitle("r (cm)");
844  mgr_dyVr->GetXaxis()->SetTitle("r (cm)");
845  mgr_drVz->GetXaxis()->SetTitle("z (cm)");
846  mgr_dzVz->GetXaxis()->SetTitle("z (cm)");
847  mgr_rdphiVz->GetXaxis()->SetTitle("z (cm)");
848  mgr_dxVz->GetXaxis()->SetTitle("z (cm)");
849  mgr_dyVz->GetXaxis()->SetTitle("z (cm)");
850  mgr_drVphi->GetXaxis()->SetTitle("#phi");
851  mgr_dzVphi->GetXaxis()->SetTitle("#phi");
852  mgr_rdphiVphi->GetXaxis()->SetTitle("#phi");
853  mgr_dxVphi->GetXaxis()->SetTitle("#phi");
854  mgr_dyVphi->GetXaxis()->SetTitle("#phi");
855 
856  mgr_drVr->GetYaxis()->SetTitle("#Delta r (#mum)");
857  mgr_dzVr->GetYaxis()->SetTitle("#Delta z (#mum)");
858  mgr_rdphiVr->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
859  mgr_dxVr->GetYaxis()->SetTitle("#Delta x (#mum)");
860  mgr_dyVr->GetYaxis()->SetTitle("#Delta y (#mum)");
861  mgr_drVz->GetYaxis()->SetTitle("#Delta r (#mum)");
862  mgr_dzVz->GetYaxis()->SetTitle("#Delta z (#mum)");
863  mgr_rdphiVz->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
864  mgr_dxVz->GetYaxis()->SetTitle("#Delta x (#mum)");
865  mgr_dyVz->GetYaxis()->SetTitle("#Delta y (#mum)");
866  mgr_drVphi->GetYaxis()->SetTitle("#Delta r (#mum)");
867  mgr_dzVphi->GetYaxis()->SetTitle("#Delta z (#mum)");
868  mgr_rdphiVphi->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
869  mgr_dxVphi->GetYaxis()->SetTitle("#Delta x (#mum)");
870  mgr_dyVphi->GetYaxis()->SetTitle("#Delta y (#mum)");
871 
872  mgr_drVr->GetYaxis()->SetTitleOffset(1.15);
873  mgr_dzVr->GetYaxis()->SetTitleOffset(1.15);
874  mgr_rdphiVr->GetYaxis()->SetTitleOffset(1.15);
875  mgr_dxVr->GetYaxis()->SetTitleOffset(1.15);
876  mgr_dyVr->GetYaxis()->SetTitleOffset(1.15);
877  mgr_drVz->GetYaxis()->SetTitleOffset(1.15);
878  mgr_dzVz->GetYaxis()->SetTitleOffset(1.15);
879  mgr_rdphiVz->GetYaxis()->SetTitleOffset(1.15);
880  mgr_dxVz->GetYaxis()->SetTitleOffset(1.15);
881  mgr_dyVz->GetYaxis()->SetTitleOffset(1.15);
882  mgr_drVphi->GetYaxis()->SetTitleOffset(1.15);
883  mgr_dzVphi->GetYaxis()->SetTitleOffset(1.15);
884  mgr_rdphiVphi->GetYaxis()->SetTitleOffset(1.15);
885  mgr_dxVphi->GetYaxis()->SetTitleOffset(1.15);
886  mgr_dyVphi->GetYaxis()->SetTitleOffset(1.15);
887 
888  c->Update();
889 
890  // --------- set output directory for histograms ---------
891  plotDir->cd();
892  h_dr->Write(); h_dz->Write(); h_rdphi->Write();
893  h_drVr->Write(); h_dzVr->Write(); h_rdphiVr->Write(); h_dxVr->Write(); h_dyVr->Write();
894  h_drVz->Write(); h_dzVz->Write(); h_rdphiVz->Write(); h_dxVz->Write(); h_dyVz->Write();
895  h_drVphi->Write(); h_dzVphi->Write(); h_rdphiVphi->Write(); h_dxVphi->Write(); h_dyVphi->Write();
896 
897  if (savePlot) c->Print((_outputDir+"plot3x5_"+plotName).c_str());
898 
899 }
900 
901 void comparisonPlots::plot3x5Profile(TCut Cut, char* dirName, int nBins, bool savePlot, std::string plotName, bool autolimits,int ColorCode ){
902 
903  //int ColorCodeHalfBarrels = 1;
904  //color seperation of moodules corresponding to the different subdets
905  //if you want to seperate corresponding to the halfbarrels (+z or -z) set colorcode !=1
906 
907  //for all histograms set the title centered
908  gStyle->SetTitleFont(62);
909  gStyle->SetOptTitle(0);
910 
911  gStyle->SetFrameBorderMode(0);
912  gStyle->SetCanvasBorderMode(0);
913  gStyle->SetPadBorderMode(0);
914  gStyle->SetPadColor(0);
915  gStyle->SetCanvasColor(0);
916  gStyle->SetTitleColor(1);
917  gStyle->SetStatColor(0);
918  gStyle->SetStatBorderSize(1);
919  gStyle->SetFrameFillColor(0);
920 
921  gStyle->SetTextFont(132);
922  gStyle->SetTextSize(0.08);
923  gStyle->SetLabelFont(132,"x");
924  gStyle->SetLabelFont(132,"y");
925  gStyle->SetLabelFont(132,"z");
926  gStyle->SetTitleSize(0.08,"x");
927  gStyle->SetTitleSize(0.08,"y");
928  gStyle->SetTitleSize(0.08,"z");
929  gStyle->SetLabelSize(0.08,"x");
930  gStyle->SetLabelSize(0.08,"y");
931  gStyle->SetLabelSize(0.08,"z");
932 
933  gStyle->SetTitleAlign(22);
934  gStyle->SetTitleX(0.5);
935  gStyle->SetTitleY(0.97);
936  gStyle->SetTitleFont(62);
937 
938  gStyle->SetPadTickX(1);
939  gStyle->SetPadTickY(1);
940 
941  gStyle->SetPadTopMargin(0.1);
942  gStyle->SetPadRightMargin(0.05);
943  gStyle->SetPadBottomMargin(0.16);
944  gStyle->SetPadLeftMargin(0.18);
945 
946  // --------- create directory for histograms ---------
947  //const char* dirName = Cut;
948  string s;// = "profile";
949  s = s + dirName;
950  s.append("_profile");
951  TDirectory* plotDir = output->mkdir( s.data() );
952 
953 
954  int j = 2;
955  TCut zCut[6];
956  zCut[0] = "z < 0";
957  zCut[1] = "z >= 0";
958 
959 
960  if (ColorCode == 1) {
961  j = 6;
962  // zCut[6];
963  zCut[0] = "sublevel==1";
964  zCut[1] = "sublevel==2";
965  zCut[2] = "sublevel==3";
966  zCut[3] = "sublevel==4";
967  zCut[4] = "sublevel==5";
968  zCut[5] = "sublevel==6";
969 
970  }
971 
972  double minimumR, maximumR;
973  double minimumZ, maximumZ;
974  double minimumPhi, maximumPhi;
975  double minimumDR, maximumDR;
976  double minimumDZ, maximumDZ;
977  double minimumRDPhi, maximumRDPhi;
978  double minimumDX, maximumDX;
979  double minimumDY, maximumDY;
980  if (autolimits){
981  // --------- get right limits for histogram ---------
982  TH1F* phr = new TH1F("phr", "phr", 200, 0, 200 );
983  TH1F* phz = new TH1F("phz", "phz", 400, -300, 300 );
984  TH1F* phphi = new TH1F("phphi", "phphi", 200, -3.15, 3.15);
985  TH1F* phdr = new TH1F("phdr", "phdr", 20000,-1000, 1000 );
986  TH1F* phdz = new TH1F("phdz", "phdz", 20000,-1000, 1000 );
987  TH1F* phrdphi = new TH1F("phrdphi", "phrdphi", 20000,-1000, 1000 );
988  TH1F* phdx = new TH1F("phdx", "phy", 20000,-1000, 1000 );
989  TH1F* phdy = new TH1F("phdy", "phy", 20000,-1000, 1000 );
990  data->Project("phr","r",Cut);
991  data->Project("phz","z",Cut);
992  data->Project("phphi","phi",Cut);
993  data->Project("phdr","dr*10000",Cut);
994  data->Project("phdz","dz*10000",Cut);
995  data->Project("phrdphi","r*dphi*10000",Cut );
996  data->Project("phdx","dx*10000",Cut );
997  data->Project("phdy","dy*10000",Cut );
998  getHistMaxMin(phr, maximumR, minimumR, 0);
999  getHistMaxMin(phz, maximumZ, minimumZ, 0);
1000  getHistMaxMin(phphi, maximumPhi, minimumPhi, 0);
1001  getHistMaxMin(phdr, maximumDR, minimumDR, 1);
1002  getHistMaxMin(phdz, maximumDZ, minimumDZ, 1);
1003  getHistMaxMin(phrdphi, maximumRDPhi, minimumRDPhi, 1);
1004  getHistMaxMin(phdx, maximumDX, minimumDX, 1);
1005  getHistMaxMin(phdy, maximumDY, minimumDY, 1);
1006  }
1007  else{
1008  minimumR = 0., maximumR = 200.;
1009  minimumZ = -300., maximumZ = 300.;
1010  minimumPhi = -3.15, maximumPhi = 3.15;
1011  minimumDR = -1, maximumDR = 1;
1012  minimumDZ = -1, maximumDZ = 1;
1013  minimumRDPhi = -1, maximumRDPhi = 1;
1014  minimumDX = -1, maximumDX = 1;
1015  minimumDY = -1, maximumDY = 1;
1016  }
1017 
1018  // --------- declare histograms ---------
1019  TProfile* hprof_drVr = new TProfile("hprof_drVr","#Delta r vs. r",nBins,minimumR,maximumR,minimumDR,maximumDR);
1020  TProfile* hprof_dzVr = new TProfile("hprof_dzVr","#Delta z vs. r",nBins,minimumR,maximumR,minimumDZ,maximumDZ);
1021  TProfile* hprof_rdphiVr = new TProfile("hprof_rdphiVr","r#Delta #phi vs. r",nBins,minimumR,maximumR,minimumRDPhi,maximumRDPhi);
1022  TProfile* hprof_dxVr = new TProfile("hprof_dxVr","#Delta x vs. r", nBins,minimumR,maximumR,minimumDX,maximumDX);
1023  TProfile* hprof_dyVr = new TProfile("hprof_dyVr","#Delta y vs. r", nBins,minimumR,maximumR,minimumDY,maximumDY);
1024  TProfile* hprof_drVz = new TProfile("hprof_drVz","#Delta r vs. z", nBins,minimumZ,maximumZ,minimumDR,maximumDR);
1025  TProfile* hprof_dzVz = new TProfile("hprof_dzVz","#Delta z vs. z", nBins,minimumZ,maximumZ,minimumDZ,maximumDZ);
1026  TProfile* hprof_rdphiVz = new TProfile("hprof_rdphiVz","r#Delta #phi vs. z", nBins,minimumZ,maximumZ,minimumRDPhi,maximumRDPhi);
1027  TProfile* hprof_dxVz = new TProfile("hprof_dxVz","#Delta x vs. z", nBins,minimumZ,maximumZ,minimumDX,maximumDX);
1028  TProfile* hprof_dyVz = new TProfile("hprof_dyVz","#Delta y vs. z", nBins,minimumZ,maximumZ,minimumDY,maximumDY);
1029  TProfile* hprof_drVphi = new TProfile("hprof_drVphi","#Delta r vs. #phi", nBins,minimumPhi,maximumPhi,minimumDR,maximumDR);
1030  TProfile* hprof_dzVphi = new TProfile("hprof_dzVphi","#Delta z vs. #phi", nBins,minimumPhi,maximumPhi,minimumDZ,maximumDZ);
1031  TProfile* hprof_rdphiVphi = new TProfile("hprof_rdphiVphi","r#Delta #phi vs. #phi", nBins,minimumPhi,maximumPhi,minimumRDPhi,maximumRDPhi);
1032  TProfile* hprof_dxVphi = new TProfile("hprof_dxVphi","#Delta x vs. #phi", nBins,minimumPhi,maximumPhi,minimumDX,maximumDX);
1033  TProfile* hprof_dyVphi = new TProfile("hprof_dyVphi","#Delta y vs. #phi", nBins,minimumPhi,maximumPhi,minimumDY,maximumDY);
1034 
1035  TProfile* gr_drVr_Array[j];
1036  THStack* mgr_drVr=new THStack("mgr_drVr","");
1037 
1038  for ( int i = 0; i < j; i++) {
1039  data->Draw("dr*10000:r>>hprof_drVr",Cut+zCut[i],"prof");
1040  if (hprof_drVr->GetEntries()>0){
1041  gr_drVr_Array[i] =(TProfile*)hprof_drVr->Clone() ;//data->Draw("dr:r",Cut+zCut[i],"prof");
1042  gr_drVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
1043  gr_drVr_Array[i]->SetLineColor(int(i/4)+i+1);
1044  mgr_drVr->Add(gr_drVr_Array[i]);
1045  }
1046  }
1047  //y-axis scaled 2 times the max value for values >5 micron
1048  //for max values<5 micron set fixed range to 10 micron
1049  if ( (mgr_drVr->GetMaximum("nostack")>0.0005*10000)||(mgr_drVr->GetMinimum("nostack")<-0.0005*10000) ){
1050  mgr_drVr->SetMaximum( 2.*mgr_drVr->GetMaximum("nostack") );
1051  mgr_drVr->SetMinimum( 2.*mgr_drVr->GetMinimum("nostack") );
1052  }
1053  else{
1054  mgr_drVr->SetMaximum(10.);
1055  mgr_drVr->SetMinimum( -10.);
1056  }
1057 
1058  //data->Project("hprof_dzVr", "dz:r",Cut,"prof");
1059  TProfile* gr_dzVr_Array[j];
1060  THStack* mgr_dzVr=new THStack("mgr_dzVr","");
1061  for ( int i = 0; i < j; i++) {
1062  data->Draw("dz*10000:r>>hprof_dzVr",Cut+zCut[i],"prof");
1063  if (hprof_dzVr->GetEntries()>0){
1064  gr_dzVr_Array[i] =(TProfile*)hprof_dzVr->Clone() ;
1065  gr_dzVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
1066  gr_dzVr_Array[i]->SetLineColor(int(i/4)+i+1);
1067  mgr_dzVr->Add(gr_dzVr_Array[i]);
1068  }
1069  }
1070  if ( (mgr_dzVr->GetMaximum("nostack")>0.0005*10000)||(mgr_dzVr->GetMinimum("nostack")<-0.0005*10000) ){
1071  mgr_dzVr->SetMaximum( 2.*mgr_dzVr->GetMaximum("nostack") );
1072  mgr_dzVr->SetMinimum( 2.*mgr_dzVr->GetMinimum("nostack") );
1073  }
1074  else{
1075  mgr_dzVr->SetMaximum( 10.);
1076  mgr_dzVr->SetMinimum( -10.);
1077  }
1078 
1079  //data->Project("hprof_rdphiVr", "r*dphi:r",Cut,"prof");
1080  TProfile* gr_rdphiVr_Array[j];
1081  THStack* mgr_rdphiVr=new THStack();
1082  for ( int i = 0; i < j; i++) {
1083  data->Draw("r*dphi*10000:r>>hprof_rdphiVr",Cut+zCut[i],"prof");
1084  if (hprof_rdphiVr->GetEntries()>0){
1085  gr_rdphiVr_Array[i] = (TProfile*)hprof_rdphiVr->Clone() ;
1086  gr_rdphiVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
1087  gr_rdphiVr_Array[i]->SetLineColor(int(i/4)+i+1);
1088  mgr_rdphiVr->Add(gr_rdphiVr_Array[i]);
1089  }
1090  }
1091  if ( (mgr_rdphiVr->GetMaximum("nostack")>0.0005*10000)||(mgr_rdphiVr->GetMinimum("nostack")<-0.0005*10000) ){
1092  mgr_rdphiVr->SetMaximum( 2.*mgr_rdphiVr->GetMaximum("nostack") );
1093  mgr_rdphiVr->SetMinimum( 2.*mgr_rdphiVr->GetMinimum("nostack") );
1094  }
1095  else{
1096  mgr_rdphiVr->SetMaximum( 10.);
1097  mgr_rdphiVr->SetMinimum( -10.);
1098  }
1099 
1100  //data->Project("hprof_dxVr", "dx:r",Cut,"prof");
1101  TProfile* gr_dxVr_Array[j];
1102  THStack* mgr_dxVr=new THStack();
1103  for ( int i = 0; i < j; i++) {
1104  data->Draw("dx*10000:r>>hprof_dxVr",Cut+zCut[i],"prof");
1105  if (hprof_dxVr->GetEntries()>0){
1106  gr_dxVr_Array[i] = (TProfile*)hprof_dxVr->Clone() ;
1107  gr_dxVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
1108  gr_dxVr_Array[i]->SetLineColor(int(i/4)+i+1);
1109  mgr_dxVr->Add(gr_dxVr_Array[i]);
1110  }
1111  }
1112  if ( (mgr_dxVr->GetMaximum("nostack")>0.0005*10000)||(mgr_dxVr->GetMinimum("nostack")<-0.0005*10000) ){
1113  mgr_dxVr->SetMaximum( 2.*mgr_dxVr->GetMaximum("nostack") );
1114  mgr_dxVr->SetMinimum( 2.*mgr_dxVr->GetMinimum("nostack") );
1115  }
1116  else{
1117  mgr_dxVr->SetMaximum( 10.);
1118  mgr_dxVr->SetMinimum( -10.);
1119  }
1120 
1121  //data->Project("hprof_dyVr", "dy:r",Cut,"prof");
1122  TProfile* gr_dyVr_Array[j];
1123  THStack* mgr_dyVr=new THStack();
1124  for ( int i = 0; i < j; i++) {
1125  data->Draw("dy*1000:r>>hprof_dyVr",Cut+zCut[i],"prof");
1126  if (hprof_dyVr->GetEntries()>0){
1127  gr_dyVr_Array[i] = (TProfile*)hprof_dyVr->Clone() ;
1128  gr_dyVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
1129  gr_dyVr_Array[i]->SetLineColor(int(i/4)+i+1);
1130  mgr_dyVr->Add(gr_dyVr_Array[i]);
1131  }
1132  }
1133  if ( (mgr_dyVr->GetMaximum("nostack")>0.0005*10000)||(mgr_dyVr->GetMinimum("nostack")<-0.0005*10000) ){
1134  mgr_dyVr->SetMaximum( 2.*mgr_dyVr->GetMaximum("nostack") );
1135  mgr_dyVr->SetMinimum( 2.*mgr_dyVr->GetMinimum("nostack") );
1136  }
1137  else{
1138  mgr_dyVr->SetMaximum( 10.);
1139  mgr_dyVr->SetMinimum( -10.);
1140  }
1141 
1142  //data->Project("hprof_drVz", "dr:z",Cut,"prof");
1143  TProfile* gr_drVz_Array[j];
1144  THStack* mgr_drVz=new THStack();
1145  for ( int i = 0; i < j; i++) {
1146  data->Draw("dr*10000:z>>hprof_drVz",Cut+zCut[i],"prof");
1147  if (hprof_drVz->GetEntries()>0){
1148  gr_drVz_Array[i] = (TProfile*)hprof_drVz->Clone() ;
1149  gr_drVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
1150  gr_drVz_Array[i]->SetLineColor(int(i/4)+i+1);
1151  mgr_drVz->Add(gr_drVz_Array[i]);
1152  }
1153  }
1154  if ( (mgr_drVz->GetMaximum("nostack")>0.0005*10000)||(mgr_drVz->GetMinimum("nostack")<-0.0005*10000) ){
1155  mgr_drVz->SetMaximum( 2.*mgr_drVz->GetMaximum("nostack") );
1156  mgr_drVz->SetMinimum( 2.*mgr_drVz->GetMinimum("nostack") );
1157  }
1158  else{
1159  mgr_drVz->SetMaximum( 10.);
1160  mgr_drVz->SetMinimum( -10.);
1161  }
1162 
1163  //data->Project("hprof_dzVz", "dz:z",Cut,"prof");
1164  TProfile* gr_dzVz_Array[j];
1165  THStack* mgr_dzVz=new THStack();
1166  for ( int i = 0; i < j; i++) {
1167  data->Draw("dz*10000:z>>hprof_dzVz",Cut+zCut[i],"prof");
1168  if (hprof_dzVz->GetEntries()>0){
1169  gr_dzVz_Array[i] = (TProfile*)hprof_dzVz->Clone() ;
1170  gr_dzVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
1171  gr_dzVz_Array[i]->SetLineColor(int(i/4)+i+1);
1172  mgr_dzVz->Add(gr_dzVz_Array[i]);
1173  }
1174  }
1175  if ( (mgr_dzVz->GetMaximum("nostack")>0.0005*10000)||(mgr_dzVz->GetMinimum("nostack")<-0.0005*10000) ){
1176  mgr_dzVz->SetMaximum( 2.*mgr_dzVz->GetMaximum("nostack") );
1177  mgr_dzVz->SetMinimum( 2.*mgr_dzVz->GetMinimum("nostack") );
1178  }
1179  else{
1180  mgr_dzVz->SetMaximum( 10.);
1181  mgr_dzVz->SetMinimum( -10.);
1182  }
1183 
1184  //data->Project("hprof_rdphiVz", "r*dphi:z",Cut,"prof");
1185  TProfile* gr_rdphiVz_Array[j];
1186  THStack* mgr_rdphiVz=new THStack();
1187  for ( int i = 0; i < j; i++) {
1188  data->Draw("r*dphi*10000:z>>hprof_rdphiVz",Cut+zCut[i],"prof");
1189  if (hprof_rdphiVz->GetEntries()>0){
1190  gr_rdphiVz_Array[i] = (TProfile*)hprof_rdphiVz->Clone() ;
1191  gr_rdphiVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
1192  gr_rdphiVz_Array[i]->SetLineColor(int(i/4)+i+1);
1193  mgr_rdphiVz->Add(gr_rdphiVz_Array[i]);
1194  }
1195  }
1196  if ( (mgr_rdphiVz->GetMaximum("nostack")>0.0005*10000)||(mgr_rdphiVz->GetMinimum("nostack")<-0.0005*10000) ){
1197  mgr_rdphiVz->SetMaximum( 2.*mgr_rdphiVz->GetMaximum("nostack") );
1198  mgr_rdphiVz->SetMinimum( 2.*mgr_rdphiVz->GetMinimum("nostack") );
1199  }
1200  else{
1201  mgr_rdphiVz->SetMaximum( 10.);
1202  mgr_rdphiVz->SetMinimum( -10.);
1203  }
1204 
1205  //data->Project("hprof_dxVz", "dx:z",Cut,"prof");
1206  TProfile* gr_dxVz_Array[j];
1207  THStack* mgr_dxVz=new THStack();
1208  for ( int i = 0; i < j; i++) {
1209  data->Draw("dx*10000:z>>hprof_dxVz",Cut+zCut[i],"prof");
1210  if (hprof_dxVz->GetEntries()>0){
1211  gr_dxVz_Array[i] = (TProfile*)hprof_dxVz->Clone() ;
1212  gr_dxVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
1213  gr_dxVz_Array[i]->SetLineColor(int(i/4)+i+1);
1214  mgr_dxVz->Add(gr_dxVz_Array[i]);
1215  }
1216  }
1217  if ( (mgr_dxVz->GetMaximum("nostack")>0.0005*10000)||(mgr_dxVz->GetMinimum("nostack")<-0.0005*10000) ){
1218  mgr_dxVz->SetMaximum( 2.*mgr_dxVz->GetMaximum("nostack") );
1219  mgr_dxVz->SetMinimum( 2.*mgr_dxVz->GetMinimum("nostack") );
1220  }
1221  else{
1222  mgr_dxVz->SetMaximum( 10.);
1223  mgr_dxVz->SetMinimum( -10.);
1224  }
1225 
1226  //data->Project("hprof_dyVz", "dy:z",Cut,"prof");
1227  TProfile* gr_dyVz_Array[j];
1228  THStack* mgr_dyVz=new THStack();
1229  for ( int i = 0; i < j; i++) {
1230  data->Draw("dy*10000:z>>hprof_dyVz",Cut+zCut[i],"prof");
1231  if (hprof_dyVz->GetEntries()>0){
1232  gr_dyVz_Array[i] = (TProfile*)hprof_dyVz->Clone() ;
1233  gr_dyVz_Array[i]->SetMarkerColor(int(i/4)+i+1);
1234  gr_dyVz_Array[i]->SetLineColor(int(i/4)+i+1);
1235  mgr_dyVz->Add(gr_dyVz_Array[i],"p");
1236  }
1237  }
1238  if ( (mgr_dyVz->GetMaximum("nostack")>0.0005*10000)||(mgr_dyVz->GetMinimum("nostack")<-0.0005*10000) ){
1239  mgr_dyVz->SetMaximum( 2.*mgr_dyVz->GetMaximum("nostack") );
1240  mgr_dyVz->SetMinimum( 2.*mgr_dyVz->GetMinimum("nostack") );
1241  }
1242  else{
1243  mgr_dyVz->SetMaximum( 10.);
1244  mgr_dyVz->SetMinimum( -10.);
1245  }
1246 
1247  //data->Project("hprof_drVphi", "dr:phi",Cut,"prof");
1248  TProfile* gr_drVphi_Array[j];
1249  THStack* mgr_drVphi=new THStack();
1250  for ( int i = 0; i < j; i++) {
1251  data->Draw("dr*10000:phi>>hprof_drVphi",Cut+zCut[i],"prof");
1252  if (hprof_drVphi->GetEntries()>0){
1253  gr_drVphi_Array[i] = (TProfile*)hprof_drVphi->Clone() ;
1254  gr_drVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
1255  gr_drVphi_Array[i]->SetLineColor(int(i/4)+i+1);
1256  mgr_drVphi->Add(gr_drVphi_Array[i],"p");
1257  }
1258  }
1259  if ( (mgr_drVphi->GetMaximum("nostack")>0.0005*10000)||(mgr_drVphi->GetMinimum("nostack")<-0.0005*10000) ){
1260  mgr_drVphi->SetMaximum( 2.*mgr_drVphi->GetMaximum("nostack") );
1261  mgr_drVphi->SetMinimum( 2.*mgr_drVphi->GetMinimum("nostack") );
1262  }
1263  else{
1264  mgr_drVphi->SetMaximum( 10.);
1265  mgr_drVphi->SetMinimum( -10.);
1266  }
1267 
1268  //data->Project("hprof_dzVphi", "dz:phi",Cut,"prof");
1269  TProfile* gr_dzVphi_Array[j];
1270  THStack* mgr_dzVphi=new THStack();
1271  for ( int i = 0; i < j; i++) {
1272  data->Draw("dz*10000:phi>>hprof_dzVphi",Cut+zCut[i],"prof");
1273  if (hprof_dzVphi->GetEntries()>0){
1274  gr_dzVphi_Array[i] = (TProfile*)hprof_dzVphi->Clone() ;
1275  gr_dzVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
1276  gr_dzVphi_Array[i]->SetLineColor(int(i/4)+i+1);
1277  mgr_dzVphi->Add(gr_dzVphi_Array[i],"p");
1278  }
1279  }
1280  if ( (mgr_dzVphi->GetMaximum("nostack")>0.0005*10000)||(mgr_dzVphi->GetMinimum("nostack")<-0.0005*10000) ){
1281  mgr_dzVphi->SetMaximum( 2.*mgr_dzVphi->GetMaximum("nostack") );
1282  mgr_dzVphi->SetMinimum( 2.*mgr_dzVphi->GetMinimum("nostack") );
1283  }
1284  else{
1285  mgr_dzVphi->SetMaximum( 10.);
1286  mgr_dzVphi->SetMinimum( -10.);
1287  }
1288 
1289  //data->Project("hprof_rdphiVphi", "r*dphi:phi",Cut,"prof");
1290  TProfile* gr_rdphiVphi_Array[j];
1291  THStack* mgr_rdphiVphi=new THStack();
1292  for ( int i = 0; i < j; i++) {
1293  data->Draw("r*dphi*10000:phi>>hprof_rdphiVphi",Cut+zCut[i],"prof");
1294  if (hprof_rdphiVphi->GetEntries()>0){
1295  gr_rdphiVphi_Array[i] = (TProfile*)hprof_rdphiVphi->Clone() ;
1296  gr_rdphiVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
1297  gr_rdphiVphi_Array[i]->SetLineColor(int(i/4)+i+1);
1298  mgr_rdphiVphi->Add(gr_rdphiVphi_Array[i],"p");
1299  }
1300  }
1301  if ( (mgr_rdphiVphi->GetMaximum("nostack")>0.0005*10000)||(mgr_rdphiVphi->GetMinimum("nostack")<-0.0005*10000) ){
1302  mgr_rdphiVphi->SetMaximum( 2.*mgr_rdphiVphi->GetMaximum("nostack") );
1303  mgr_rdphiVphi->SetMinimum( 2.*mgr_rdphiVphi->GetMinimum("nostack") );
1304  }
1305  else{
1306  mgr_rdphiVphi->SetMaximum( 10.);
1307  mgr_rdphiVphi->SetMinimum( -10.);
1308  }
1309 
1310  //data->Project("hprof_dxVphi", "dx:phi",Cut,"prof");
1311  TProfile* gr_dxVphi_Array[j];
1312  THStack* mgr_dxVphi=new THStack();
1313  for ( int i = 0; i < j; i++) {
1314  data->Draw("dx*10000:phi>>hprof_dxVphi",Cut+zCut[i],"prof");
1315  if (hprof_dxVphi->GetEntries()>0){
1316  gr_dxVphi_Array[i] = (TProfile*)hprof_dxVphi->Clone() ;
1317  gr_dxVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
1318  gr_dxVphi_Array[i]->SetLineColor(int(i/4)+i+1);
1319  mgr_dxVphi->Add(gr_dxVphi_Array[i],"p");
1320  }
1321  }
1322  if ( (mgr_dxVphi->GetMaximum("nostack")>0.0005*10000)||(mgr_dxVphi->GetMinimum("nostack")<-0.0005*10000) ){
1323  mgr_dxVphi->SetMaximum( 2.*mgr_dxVphi->GetMaximum("nostack") );
1324  mgr_dxVphi->SetMinimum( 2.*mgr_dxVphi->GetMinimum("nostack") );
1325  }
1326  else{
1327  mgr_dxVphi->SetMaximum( 10.);
1328  mgr_dxVphi->SetMinimum( -10.);
1329  }
1330 
1331  //data->Project("hprof_dyVphi", "dy:phi",Cut,"prof");
1332  TProfile* gr_dyVphi_Array[j];
1333  THStack* mgr_dyVphi=new THStack();
1334  for ( int i = 0; i < j; i++) {
1335  data->Draw("dy*10000:phi>>hprof_dyVphi",Cut+zCut[i],"prof");
1336  if (hprof_dyVphi->GetEntries()>0){
1337  gr_dyVphi_Array[i] = (TProfile*)hprof_dyVphi->Clone() ;
1338  gr_dyVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);
1339  gr_dyVphi_Array[i]->SetLineColor(int(i/4)+i+1);
1340  mgr_dyVphi->Add(gr_dyVphi_Array[i],"p");
1341  }
1342  }
1343  if ( (mgr_dyVphi->GetMaximum("nostack")>0.0005*10000)||(mgr_dyVphi->GetMinimum("nostack")<-0.0005*10000) ){
1344  mgr_dyVphi->SetMaximum( 2.*mgr_dyVphi->GetMaximum("nostack") );
1345  mgr_dyVphi->SetMinimum( 2.*mgr_dyVphi->GetMinimum("nostack") );
1346  }
1347  else{
1348  mgr_dyVphi->SetMaximum( 10.);
1349  mgr_dyVphi->SetMinimum( -10.);
1350  }
1351 
1352  mgr_drVr->SetTitle("#Delta r vs. r");
1353  mgr_dzVr->SetTitle("#Delta z vs. r");
1354  mgr_rdphiVr->SetTitle("r#Delta #phi vs. r");
1355  mgr_dxVr->SetTitle("#Delta x vs. r");
1356  mgr_dyVr->SetTitle("#Delta y vs. r");
1357  mgr_drVz->SetTitle("#Delta r vs. z");
1358  mgr_dzVz->SetTitle("#Delta z vs. z");
1359  mgr_rdphiVz->SetTitle("r#Delta #phi vs. z");
1360  mgr_dxVz->SetTitle("#Delta x vs. z");
1361  mgr_dyVz->SetTitle("#Delta y vs. z");
1362  mgr_drVphi->SetTitle("#Delta r vs. #phi");
1363  mgr_dzVphi->SetTitle("#Delta z vs. #phi");
1364  mgr_rdphiVphi->SetTitle("r#Delta #phi vs. #phi");
1365  mgr_dxVphi->SetTitle("#Delta x vs. #phi");
1366  mgr_dyVphi->SetTitle("#Delta y vs. #phi");
1367 
1368  // --------- draw histograms ---------
1369  TCanvas* c = new TCanvas("c", "c", 200, 10, 1200, 700);
1370  c->SetFillColor(0);
1371  data->SetMarkerSize(0.5);
1372  data->SetMarkerStyle(6);
1373  c->Divide(5,3);
1374  c->cd(1);
1375  if (!autolimits) mgr_drVr->Draw("nostack");
1376  if (autolimits) mgr_drVr->Draw("nostack");
1377  c->Update();
1378  c->cd(2);
1379  if (!autolimits) mgr_dzVr->Draw("nostack");
1380  if (autolimits) mgr_dzVr->Draw("nostack");
1381  c->Update();
1382  c->cd(3);
1383  if (!autolimits) mgr_rdphiVr->Draw("nostack");
1384  if (autolimits) mgr_rdphiVr->Draw("nostack");
1385  c->cd(4);
1386  if (!autolimits) mgr_dxVr->Draw("nostack");
1387  if (autolimits) mgr_dxVr->Draw("nostack");
1388  c->cd(5);
1389  if (!autolimits) mgr_dyVr->Draw("nostack");
1390  if (autolimits) mgr_dyVr->Draw("nostack");
1391  c->cd(6);
1392  if (!autolimits) mgr_drVz->Draw("nostack");
1393  if (autolimits) mgr_drVz->Draw("nostack");
1394  c->cd(7);
1395  if (!autolimits) mgr_dzVz->Draw("nostack");
1396  if (autolimits) mgr_dzVz->Draw("nostack");
1397  c->cd(8);
1398  if (!autolimits) mgr_rdphiVz->Draw("nostack");
1399  if (autolimits) mgr_rdphiVz->Draw("nostack");
1400  c->cd(9);
1401  if (!autolimits) mgr_dxVz->Draw("nostack");
1402  if (autolimits) mgr_dxVz->Draw("nostack");
1403  c->cd(10);
1404  if (!autolimits) mgr_dyVz->Draw("nostack");
1405  if (autolimits) mgr_dyVz->Draw("nostack");
1406  c->cd(11);
1407  if (!autolimits) mgr_drVphi->Draw("nostack");
1408  if (autolimits) mgr_drVphi->Draw("nostack");
1409  c->cd(12);
1410  if (!autolimits) mgr_dzVphi->Draw("nostack");
1411  if (autolimits) mgr_dzVphi->Draw("nostack");
1412  c->cd(13);
1413  if (!autolimits) mgr_rdphiVphi->Draw("nostack");
1414  if (autolimits) mgr_rdphiVphi->Draw("nostack");
1415  c->cd(14);
1416  if (!autolimits) mgr_dxVphi->Draw("nostack");
1417  if (autolimits) mgr_dxVphi->Draw("nostack");
1418  c->cd(15);
1419  if (!autolimits) mgr_dyVphi->Draw("nostack");
1420  if (autolimits) mgr_dyVphi->Draw("nostack");
1421 
1422  mgr_drVr->GetXaxis()->SetTitle("r (cm)");
1423  mgr_dzVr->GetXaxis()->SetTitle("r (cm)");
1424  mgr_rdphiVr->GetXaxis()->SetTitle("r (cm)");
1425  mgr_dxVr->GetXaxis()->SetTitle("r (cm)");
1426  mgr_dyVr->GetXaxis()->SetTitle("r (cm)");
1427  mgr_drVz->GetXaxis()->SetTitle("z (cm)");
1428  mgr_dzVz->GetXaxis()->SetTitle("z (cm)");
1429  mgr_rdphiVz->GetXaxis()->SetTitle("z (cm)");
1430  mgr_dxVz->GetXaxis()->SetTitle("z (cm)");
1431  mgr_dyVz->GetXaxis()->SetTitle("z (cm)");
1432  mgr_drVphi->GetXaxis()->SetTitle("#phi");
1433  mgr_dzVphi->GetXaxis()->SetTitle("#phi");
1434  mgr_rdphiVphi->GetXaxis()->SetTitle("#phi");
1435  mgr_dxVphi->GetXaxis()->SetTitle("#phi");
1436  mgr_dyVphi->GetXaxis()->SetTitle("#phi");
1437 
1438  mgr_drVr->GetYaxis()->SetTitle("#Delta r (#mum)");
1439  mgr_dzVr->GetYaxis()->SetTitle("#Delta z (#mum)");
1440  mgr_rdphiVr->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
1441  mgr_dxVr->GetYaxis()->SetTitle("#Delta x (#mum)");
1442  mgr_dyVr->GetYaxis()->SetTitle("#Delta y (#mum)");
1443  mgr_drVz->GetYaxis()->SetTitle("#Delta r (#mum)");
1444  mgr_dzVz->GetYaxis()->SetTitle("#Delta z (#mum)");
1445  mgr_rdphiVz->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
1446  mgr_dxVz->GetYaxis()->SetTitle("#Delta x (#mum)");
1447  mgr_dyVz->GetYaxis()->SetTitle("#Delta y (#mum)");
1448  mgr_drVphi->GetYaxis()->SetTitle("#Delta r (#mum)");
1449  mgr_dzVphi->GetYaxis()->SetTitle("#Delta z (#mum)");
1450  mgr_rdphiVphi->GetYaxis()->SetTitle("r#Delta #phi (#mum)");
1451  mgr_dxVphi->GetYaxis()->SetTitle("#Delta x (#mum)");
1452  mgr_dyVphi->GetYaxis()->SetTitle("#Delta y (#mum)");
1453 
1454  mgr_drVr->GetYaxis()->SetTitleOffset(1.15);
1455  mgr_dzVr->GetYaxis()->SetTitleOffset(1.15);
1456  mgr_rdphiVr->GetYaxis()->SetTitleOffset(1.15);
1457  mgr_dxVr->GetYaxis()->SetTitleOffset(1.15);
1458  mgr_dyVr->GetYaxis()->SetTitleOffset(1.15);
1459  mgr_drVz->GetYaxis()->SetTitleOffset(1.15);
1460  mgr_dzVz->GetYaxis()->SetTitleOffset(1.15);
1461  mgr_rdphiVz->GetYaxis()->SetTitleOffset(1.15);
1462  mgr_dxVz->GetYaxis()->SetTitleOffset(1.15);
1463  mgr_dyVz->GetYaxis()->SetTitleOffset(1.15);
1464  mgr_drVphi->GetYaxis()->SetTitleOffset(1.15);
1465  mgr_dzVphi->GetYaxis()->SetTitleOffset(1.15);
1466  mgr_rdphiVphi->GetYaxis()->SetTitleOffset(1.15);
1467  mgr_dxVphi->GetYaxis()->SetTitleOffset(1.15);
1468  mgr_dyVphi->GetYaxis()->SetTitleOffset(1.15);
1469 
1470  c->Update();
1471 
1472  // --------- set output directory for histograms ---------
1473  plotDir->cd();
1474 
1475  hprof_drVr->Write(); hprof_dzVr->Write(); hprof_rdphiVr->Write(); hprof_dxVr->Write(); hprof_dyVr->Write();
1476  hprof_drVz->Write(); hprof_dzVz->Write(); hprof_rdphiVz->Write(); hprof_dxVz->Write(); hprof_dyVz->Write();
1477  hprof_drVphi->Write(); hprof_dzVphi->Write(); hprof_rdphiVphi->Write(); hprof_dxVphi->Write(); hprof_dyVphi->Write();
1478 
1479  /*
1480  // --------- project tree onto histograms ---------
1481  data->Project("hprof_drVr", "dr:r",Cut ,"prof");
1482  data->Project("hprof_dzVr", "dz:r",Cut ,"prof");
1483  data->Project("hprof_rdphiVr", "r*dphi:r",Cut ,"prof");
1484  data->Project("hprof_dxVr", "dx:r",Cut ,"prof");
1485  data->Project("hprof_dyVr", "dy:r",Cut ,"prof");
1486  data->Project("hprof_drVz", "dr:z",Cut ,"prof");
1487  data->Project("hprof_dzVz", "dz:z",Cut ,"prof");
1488  data->Project("hprof_rdphiVz", "r*dphi:z",Cut ,"prof");
1489  data->Project("hprof_dxVz", "dx:z",Cut ,"prof");
1490  data->Project("hprof_dyVz", "dy:z",Cut ,"prof");
1491  data->Project("hprof_drVphi", "dr:phi",Cut ,"prof");
1492  data->Project("hprof_dzVphi", "dz:phi",Cut ,"prof");
1493  data->Project("hprof_rdphiVphi", "r*dphi:phi",Cut ,"prof");
1494  data->Project("hprof_dxVphi", "dx:phi",Cut ,"prof");
1495  data->Project("hprof_dyVphi", "dy:phi",Cut ,"prof");
1496 
1497  // --------- draw histograms ---------
1498  TCanvas* cp = new TCanvas("cp", "cp", 200, 10, 1200, 700);
1499  cp->SetFillColor(0);
1500  data->SetMarkerSize(0.5);
1501  data->SetMarkerStyle(6);
1502  cp->Divide(5,3);
1503  cp->cd(1);
1504  hprof_drVr->Draw();
1505  cp->cd(2);
1506  hprof_dzVr->Draw();
1507  cp->cd(3);
1508  hprof_rdphiVr->Draw();
1509  cp->cd(4);
1510  hprof_dxVr->Draw();
1511  cp->cd(5);
1512  hprof_dyVr->Draw();
1513  cp->cd(6);
1514  hprof_drVz->Draw();
1515  cp->cd(7);
1516  hprof_dzVz->Draw();
1517  cp->cd(8);
1518  hprof_rdphiVz->Draw();
1519  cp->cd(9);
1520  hprof_dxVz->Draw();
1521  cp->cd(10);
1522  hprof_dyVz->Draw();
1523  cp->cd(11);
1524  hprof_drVphi->Draw();
1525  cp->cd(12);
1526  hprof_dzVphi->Draw();
1527  cp->cd(13);
1528  hprof_rdphiVphi->Draw();
1529  cp->cd(14);
1530  hprof_dxVphi->Draw();
1531  cp->cd(15);
1532  hprof_dyVphi->Draw();
1533 
1534  // --------- set output directory for histograms ---------
1535  plotDir->cd();
1536  hprof_drVr->Write(); hprof_dzVr->Write(); hprof_rdphiVr->Write(); hprof_dxVr->Write(); hprof_dyVr->Write();
1537  hprof_drVz->Write(); hprof_dzVz->Write(); hprof_rdphiVz->Write(); hprof_dxVz->Write(); hprof_dyVz->Write();
1538  hprof_drVphi->Write(); hprof_dzVphi->Write(); hprof_rdphiVphi->Write(); hprof_dxVphi->Write(); hprof_dyVphi->Write();
1539  */
1540  if (savePlot) c->Print((_outputDir+"plot3x5Prof_"+plotName).c_str());
1541 }
1542 
1543 
1545 
1546  data->GetEntry(0);
1547  minR = r_; maxR = r_;
1548  minZ = z_; maxZ = z_;
1549  minPhi = phi_; maxPhi = phi_;
1550  minDR = dr_; maxDR = dr_;
1551  minDZ = dz_; maxDZ = dz_;
1553  minDX = dx_; maxDX = dx_;
1554  minDY = dy_; maxDY = dy_;
1555 
1556  int nEntries = data->GetEntries();
1557  for (int i = 1; i < nEntries; ++i){
1558  data->GetEntry(i);
1559 
1560  if (r_ < minR) minR = r_;
1561  if (r_ > maxR) maxR = r_;
1562  if (z_ < minZ) minZ = z_;
1563  if (z_ > maxZ) maxZ = z_;
1564  if (phi_ < minPhi) minPhi = phi_;
1565  if (phi_ > maxPhi) maxPhi = phi_;
1566  if (dr_ < minDR) minDR = dr_;
1567  if (dr_ > maxDR) maxDR = dr_;
1568  if (dz_ < minDZ) minDZ = dz_;
1569  if (dz_ > maxDZ) maxDZ = dz_;
1570  if (r_*dphi_ < minRDPhi) minRDPhi = r_*dphi_;
1571  if (r_*dphi_ > maxRDPhi) maxRDPhi = r_*dphi_;
1572  if (dx_ < minDX) minDX = dx_;
1573  if (dx_ > maxDX) maxDX = dx_;
1574  if (dy_ < minDY) minDY = dy_;
1575  if (dy_ > maxDY) maxDY = dy_;
1576  }
1577 }
1578 
1579 
1580 void comparisonPlots::getHistMaxMin(TH1* hist, double &max, double &min, int flag){
1581 
1582  int nBins = hist->GetNbinsX();
1583  for (int i = 0; i < nBins; ++i){
1584  double binContent = hist->GetBinContent(i);
1585  if (binContent > 0){
1586  //double binWidth = hist->GetBinLowEdge(i) - hist->GetBinLowEdge(i-1);
1587  //std::cout << "bin width1: " << hist->GetBinWidth(i) << ", bin width2: " << binWidth << std::endl;
1588  if (flag == 0) max = hist->GetBinLowEdge(i) + 2.*hist->GetBinWidth(i) + 0.1*hist->GetBinLowEdge(i);
1589  if (flag == 1) max = hist->GetBinLowEdge(i) + hist->GetBinWidth(i) + 0.1*hist->GetBinLowEdge(i);
1590  }
1591  }
1592  for (int i = (nBins-1); i >= 0; i--){
1593  double binContent = hist->GetBinContent(i);
1594  if (binContent > 0) min = hist->GetBinLowEdge(i) - 0.1*hist->GetBinLowEdge(i);
1595  }
1596  //std::cout << "max: " << max << ", min: " << min << std::endl;
1597 }
1598 
1600 {
1601  output->Write();
1602 }
1603 
1604 
int i
Definition: DBlmapReader.cc:9
void plotTwist(TCut Cut, char *dirName, bool savePlot=false, std::string plotName="plot3x5.eps", bool autolimits=false, int ColorCode=1)
void getHistMaxMin(TH1 *hist, double &max, double &min, int flag)
comparisonPlots(std::string filename, std::string outputDir, std::string outputFilename="OUTPUT_comparison.root")
int j
Definition: DBlmapReader.cc:9
T min(T a, T b)
Definition: MathUtil.h:58
void plot3x5(TCut Cut, char *dirName, bool savePlot=false, std::string plotName="plot3x5.eps", bool autolimits=false, int ColorCode=1)
void plot3x5Profile(TCut Cut, char *dirName, int nBins, bool savePlot=false, std::string plotName="plot3x5Profile.eps", bool autolimits=false, int ColorCode=1)
tuple filename
Definition: lut2db_cfg.py:20
void plot3x3Rot(TCut Cut, char *dirName, bool savePlot=false, std::string plotName="plot3x5.eps", bool autolimits=false, int ColorCode=1)
std::string _outputDir