StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yieldEOverW.C
1 #include "commonmacro/common.h"
2 #include "commonmacro/histutil.h"
3 
4 void yieldEOverW(TString inName=
5  "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
6  const char* psDir="ps",
7  int cut = 1,
8  const char* outDir="./",
9  const char* more = "west",
10  float extraValue = 0)
11 {
12 
13  if(!strstr(inName.Data(),"east")){
14  cout << "input must be east" << endl; return;
15  }
16 
17  TString inName2 = inName;
18  inName2.ReplaceAll("east","west");
19 
20  TFile* inRoot[2];
21  inRoot[0] = new TFile(inName.Data());
22  inRoot[1] = new TFile(inName2.Data());
23 
24  cout << "--------------------------" << endl;
25  cout << "in name east=" << inName << endl
26  << "in name west=" << inName2 << endl
27  << "ps dir=" << psDir << endl
28  << "cut=" << cut << endl;
29  cout << "--------------------------" << endl;
30 
31  if(!inRoot[0]){
32  cout << "cannot find the infile" << endl;
33  return;
34  }
35 
36  TCanvas c1("c1","c1",400,500);
37 
38  TH1* h1[2][2];
39 
40  gStyle->SetOptStat(0); gStyle->SetPadGridX(1); gStyle->SetPadGridY(1);
41 
42  TString sName,sTitle;
43  int j;
44  float minpt=2,maxpt=6;
45  float mindca=-1.5, maxdca=1.5;
46 
47  int n=2;
48  char* baseName[] = { "h3PhiPrDcaXYGlPtPr","h3PhiGlDcaXYGlPtGl"};
49 
50  gStyle->SetPadTickY(1);
51 
52  //-------------------------------------------------------
53 
54  for(int i=0; i<n; i++){
55  TLegend legend(.1,.1,.25,.2);
56  TH3* h3;
57  for(int iew=0; iew<2; iew++){
58  for(int ic=0; ic<2; ic++){
59 
60  // get the 3d histogram
61  sprintf(name,"%s.%s",sPM[ic].Data(),baseName[i]);
62  h3 = (TH3*) inRoot[iew]->Get(name);
63  // cout << name << endl;
64 
65  // project 1d
66  h1[iew][ic] =
67  HistSlice(h3,name,"",
68  0,-165,195,0,mindca,maxdca,
69  "z","e");
70  SetRange(h1[iew][ic]->GetXaxis(),minpt,maxpt);
71 
72  sName=h1[iew][ic]->GetTitle();
73  sName.Prepend(sEW[iew]);
74  h1[iew][ic]->SetTitle(sName.Data());
75 
76  }
77  h1[iew][0]->SetMarkerStyle(4); h1[iew][1]->SetMarkerStyle(8);
78 
79  }
80 
81  // east/west
82  sprintf(name,"yieldV%sew",h3->GetZaxis()->GetTitle());
83  sName=name;
84  sprintf(title,"yield V %s %s (east/west)",h3->GetZaxis()->GetTitle(),
85  h1[0][0]->GetTitle());
86  sTitle=title;
87 
88 
89  Divide(&c1,1,3,title,inName);c1.SetName(sName.Data());
90 
91  int j=0; TLine* line=new TLine;
92  for(int ic=0; ic<2; ic++){
93  h1a = (TH1*)h1[0][ic]->Clone();
94  h1a->Divide(h1[1][ic]);
95  h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
96  ReplaceTitle(h1a,sEW[0].Data(),"");
97  sprintf(title,"%s (east/west)",sPM[ic].Data());
98  h1a->SetXTitle(h1[0][ic]->GetXaxis()->GetTitle());
99  h1a->SetTitle(title);
100  c1.cd(ic+1); h1a->Draw("e");
101 
102  TAxis* axis=h1a->GetXaxis();
103  line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
104  axis->GetBinUpEdge(axis->GetLast()),1);
105  }
106  h1a=(TH1*)h1[0][0]->Clone(); // sum east
107  h1a->Add(h1[0][1]);
108  h1b=(TH1*)h1[1][0]->Clone(); // sum west
109  h1b->Add(h1[1][1]);
110  h1a->Divide(h1b); h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
111  sprintf(title,"plus+minus (east/west)");
112  h1a->SetMinimum(0.8); h1a->SetMaximum(1.2);
113  h1a->SetTitle(title); c1.cd(3); h1a->Draw("e");
114  line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
115  axis->GetBinUpEdge(axis->GetLast()),1);
116  Print(&c1,psDir,c1.GetName());
117 
118  }
119 
120  //--------------------
121  // varying bins
122  for(int iew=0; iew<2; iew++){
123  for(int ic=0; ic<2; ic++){
124  sprintf(name,"%s.%s",sPM[ic].Data(),"RawVarBin");
125  h1[iew][ic]=(TH1*)inRoot[iew]->Get(name);
126  h1[iew][ic]->Sumw2();
127  // cout << h1[iew][ic]->GetBinContent(4) << "\t"
128  // << h1[iew][ic]->GetBinError(4) << endl;
129  h1[iew][ic]->SetAxisRange(minpt,maxpt-.001);
130  dump(h1[iew][ic]);
131  }
132  h1[iew][0]->SetMarkerStyle(4); h1[iew][1]->SetMarkerStyle(8);
133  }
134 
135  // east/west
136  sprintf(name,"yieldVptVarBinew");
137  sprintf(title,"yield V ptPr (var binning) (east/west)");
138 
139  Divide(&c1,1,3,title,inName);c1.SetName(name);
140 
141  int j=0; TLine* line=new TLine;
142  for(int ic=0; ic<2; ic++){
143  h1a = (TH1*)h1[0][ic]->Clone();
144  h1a->Divide(h1[1][ic]);
145  h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
146  ReplaceTitle(h1a,sEW[0].Data(),"");
147  sprintf(title,"%s (east/west)",sPM[ic].Data());
148  h1a->SetXTitle(h1[0][ic]->GetXaxis()->GetTitle());
149  h1a->SetTitle(title);
150  c1.cd(ic+1); h1a->Draw("e");
151 
152  cout << h1a->GetBinContent(4) << "\t" << h1a->GetBinError(4) << endl;
153 
154  TAxis* axis=h1a->GetXaxis();
155  line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
156  axis->GetBinUpEdge(axis->GetLast()),1);
157  }
158  h1a=(TH1*)h1[0][0]->Clone(); // sum east
159  h1a->Add(h1[0][1]);
160  h1b=(TH1*)h1[1][0]->Clone(); // sum west
161  h1b->Add(h1[1][1]);
162  h1a->Divide(h1b); h1a->SetMinimum(0.5); h1a->SetMaximum(1.6);
163  sprintf(title,"plus+minus (east/west)");
164  h1a->SetMinimum(0.8); h1a->SetMaximum(1.2);
165  h1a->SetTitle(title); c1.cd(3); h1a->Draw("e");
166  line->DrawLine(axis->GetBinLowEdge(axis->GetFirst()),1,
167  axis->GetBinUpEdge(axis->GetLast()),1);
168  Print(&c1,psDir,c1.GetName());
169 
170 
171 }