StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yieldVvtxZ.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void yieldVvtxZ(const char* inName=
6  "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
7  const char* psDir="ps",
8  int cut = 1,
9  const char* outDir="./",
10  const char* more = "embeddingfile",
11  float extraValue = 0)
12 {
13 
14  gSystem->Load("StHiMicroAnalysis");
15 
16  Cut::SetCut(cut);
17  Cut::ShowCuts();
18 
19  TFile* inRoot = new TFile(inName);
20  TFile* embedRoot;
21  if(more){
22  strcpy(name,more);
23  }
24  else if(extraValue>0){
25  // attempt to find the embed file
26  char* trigger = (strstr(inName,"central")) ? "central" :"minbias";
27  sprintf(name,"~/wrk/assoc/links/P01hi.%s.HighpT_piminus_%d.hist/efficiency_cut%d.hist.root",trigger,(int)extraValue,cut);
28  }
29  else{
30  cout << "Unknown embed file" << endl; return;
31  }
32 
33  TString half = "";
34  if(strstr(inName,"east")){ half="east"; }
35  if(strstr(inName,"west")){ half="west"; }
36 
37  embedRoot = new TFile(name);
38  cout << "--------------------------" << endl;
39  cout << "in name=" << inName << endl
40  << "ps dir=" << psDir << endl
41  << "cut=" << cut << endl
42  << "embed name=" << name << endl
43  << "half = " << half << endl;
44  cout << "--------------------------" << endl;
45 
46  if(!inRoot){
47  cout << "cannot find the infile" << endl;
48  return;
49  }
50  if(!embedRoot){
51  cout << "cannot find " << name << endl;
52  }
53  float minRealPt=2,maxRealPt=3;
54  float minMcPt=2,maxMcPt=8;
55 
56  float minVtxZ=-160,maxVtxZ=160;
57  float etaAry[][2] = { { .0,.1}, {.2,.3}, {.4,.5}, {.6,.7},
58  {-.1,0}, {-.3,-.2},{-.5,-.4},{-.7,-.6} };
59  const int nEta = 8; int nx=2; int ny=4;
60  int nRebin=2;
61  int nMcRebin=4;
62 
63 
64  TH3* h3;
65  TH3* h3Real; // 10 cm bins,
66  TH3* h3Mc[2]; // 5 cm bins
67 
68  TH2* h2Real,*h2Mc[2];
69  TH1* h1Real[2]; // raw and corrected
70  TH1* h1Mc[2][nEta]; // raw,matched
71  TH1* h1VtxZ,*h1;
72 
73  // real stuff
74  h3Real=(TH3*)inRoot.Get("Minus.h3VtxZEtaPrPtPr");
75  h3 = (TH3*)inRoot.Get("Plus.h3VtxZEtaPrPtPr");
76  h3Real->Add(h3);
77  //slice off pt
78  h2Real=HistSlice(h3Real,"","",0,minRealPt,maxRealPt,"yx","e");
79 
80  // mc stuff
81  h3Mc[0]=(TH3*)embedRoot.Get("h3McRawVtxZEtaPt");
82  h3Mc[1]=(TH3*)embedRoot.Get("h3MatchedVtxZEtaPt");
83 
84  h2Mc[0]=HistSlice(h3Mc[0],"","",0,minMcPt,maxMcPt,"yx","e");
85  h2Mc[1]=HistSlice(h3Mc[1],"","",0,minMcPt,maxMcPt,"yx","e");
86 
87  h3=(TH3*)inRoot.Get("h3VtxXYZ");
88  h1VtxZ=(TH3*)h3->Project3D("ze"); h1VtxZ->Rebin(nMcRebin);
89 
90  char* type[] = {"real","mc"};
91  int marker[] = {4,8};
92  char* opt[] = { "p","psame"};
93  char* opte[] = {"e","esame"};
94  float markerSize = 0.4;
95 
96 
97  TCanvas c1("c1","c1",400,500);
98  TText* t=new TText;
99  gStyle->SetOptStat(0);
100 
101  Cut::SetCut(cut);
102 
103  //-------------------------------------------------------------
104  // see what the eta slices look like
105  TH1* hSlice = new TH1D("hSlice","hSlice",20,-200,200);
106  SetRange(hSlice->GetXaxis(),minVtxZ,maxVtxZ);
107  hSlice->SetMinimum(0); hSlice->SetMaximum(200);
108 
109  sprintf(title,"eta range(cut %d)",cut);
110  TLine line;
111  Divide(&c1,nx,ny,title,inName);
112  for(int iEta=0;iEta<nEta;iEta++){
113  c1.cd(iEta+1);
114 
115  sprintf(title,"%.1f<eta<%.1f",etaAry[iEta][0],etaAry[iEta][1]);
116  h1=(TH1*)hSlice->Clone();
117  h1->SetTitle(title);
118  h1->Draw(); TAxis* axis=h1->GetXaxis();
119 
120  for(int i=axis->GetFirst();i<=axis->GetLast();i++){
121  float dip1 = 3.14159/2.-2.*atan(TMath::Exp(-etaAry[iEta][0]));
122  float dip2 = 3.14159/2.-2.*atan(TMath::Exp(-etaAry[iEta][1]));
123 
124  //cout << "dip1=" << dip1*180./3.14159
125  // << ",dip2="<<dip2*180./3.14159 << endl;
126 
127  cout << "eta="<< etaAry[iEta][1] << ",z=" << 192*tan(dip2) << endl;
128 
129  float xmax1 = 200*tan(dip2) + axis->GetBinLowEdge(i);
130  float xmax2 = 200*tan(dip1) + axis->GetBinLowEdge(i);
131 
132  float xmin = axis->GetBinLowEdge(i);
133  line.SetLineStyle(2);
134  line.SetLineColor(kBlue);
135  line.DrawLine(xmin,0,xmax1,200);
136  line.SetLineStyle(1);
137  line.SetLineColor(kRed);
138  line.DrawLine(xmin,0,xmax2,200);
139  }
140  line.SetLineStyle(1);
141  line.SetLineColor(kBlack);
142  line.DrawLine(0,0,0,200);
143 
144  line.DrawLine(minVtxZ,60,maxVtxZ,60);
145 
146  }
147  sprintf(name,"etaRange");
148  Print(&c1,psDir,name);
149 
150  // return;
151  // look at raw and matched counts
152 
153  sprintf(title,"raw and matched yield V vtxZ (eta slices) (cut %d)",cut);
154  Divide(&c1,nx,ny,title,inName);
155  for(int iEta=0;iEta<nEta;iEta++){
156  c1.cd(iEta+1);
157  for(int i=0; i<2; i++){
158  h1Mc[i][iEta]=HistSlice(h2Mc[i],"",h2Mc[i]->GetTitle(),0,
159  etaAry[iEta][0],etaAry[iEta][1],"x","e");
160  h1Mc[i][iEta]->SetMarkerStyle(marker[i]);
161  if(nMcRebin>1)h1Mc[i][iEta]->Rebin(nMcRebin);
162  if(i==0)SetMinMax(h1Mc[i][iEta],h1Mc[i][iEta]->GetMinimum()*0.2,
163  h1Mc[i][iEta]->GetMaximum()*1.2);
164  SetRange(h1Mc[i][iEta]->GetXaxis(),minVtxZ,maxVtxZ);
165  h1Mc[i][iEta]->SetMarkerSize(markerSize);
166  h1Mc[i][iEta]->Draw(opt[i]);
167  }
168  }
169  sprintf(name,"mcYieldVvtxZEtaSlices");
170  Print(&c1,psDir,name);
171 
172  // look at efficiency*acceptance
173  sprintf(title,"efficiency*acceptance V vtxZ (eta slices) (cut %d)",cut);
174  Divide(&c1,nx,ny,title,inName);
175  for(int iEta=0;iEta<nEta;iEta++){
176  c1.cd(iEta+1); gPad->SetGridx(); gPad->SetGridy();
177  h1Mc[1][iEta]->Divide(h1Mc[0][iEta]); SetMinMax(h1Mc[1][iEta],0,1);
178  h1Mc[1][iEta]->SetXTitle("vtxZ");
179  h1Mc[1][iEta]->Draw("e");
180 
181  }
182  sprintf(name,"efficiencyVvtxZEtaSlices");
183  Print(&c1,psDir,name);
184 
185  // look at raw and uncorrected real yields V vtx Z
186  sprintf(title,"raw and corrected yield/Nevent V vtxZ (eta slices) (cut %d)",cut);
187  Divide(&c1,nx,ny,title,inName);
188  for(int iEta=0;iEta<nEta;iEta++){
189  c1.cd(iEta+1); gPad->SetGridx(); gPad->SetGridy();
190  h1Real[0]=HistSlice(h2Real,"",h2Real->GetTitle(),0,
191  etaAry[iEta][0],etaAry[iEta][1],"x","e");
192  h1Real[0]->Rebin(nRebin);
193  h1Real[0]->Divide(h1VtxZ); // uncorrected
194  h1Real[1]=(TH1*)h1Real[0]->Clone(); // corrected
195  h1Real[1]->Divide(h1Mc[1][iEta]);
196 
197 
198  for(int i=0; i<2; i++){
199  h1Real[i]->SetMarkerStyle(marker[i]);
200  if(i==0)SetMinMax(h1Real[i],0,.5);
201  SetRange(h1Mc[i][iEta]->GetXaxis(),minVtxZ,maxVtxZ);
202  h1Real[i]->SetMarkerSize(markerSize);
203  h1Real[i]->SetXTitle("vtxZ");
204  h1Real[i]->Draw(opte[i]);
205  }
206  }
207  Print(&c1,psDir,"yieldVvtxZEtaSlices");
208 
209 }
210 
211 
212 
213 
214 
215 
216