StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
compareFitPts.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void compareFitPts(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("StHiMicroEvent");
15  gSystem->Load("StHiMicroAnalysis");
16 
17  TFile* inRoot = new TFile(inName);
18  TFile* embedRoot;
19  char trigger[100];
20  if(strstr(inName,"central")){
21  strcpy(trigger,"central");
22  }
23  else{
24  strcpy(trigger,"minbias");
25  }
26 
27  if(more){
28  strcpy(name,more);
29  }
30  else if(extraValue>0){
31  // attempt to find the embed file
32  sprintf(name,"~/wrk/assoc/links/P01hi.%s.HighpT_piminus_%d.hist/assoc_cut%d.hist.root",trigger,(int)extraValue,cut);
33  }
34  else{
35  cout << "Unknown embed file" << endl; return;
36  }
37 
38  TString half = "";
39  if(strstr(inName,"east")){ half="east"; }
40  if(strstr(inName,"west")){ half="west"; }
41 
42 
43  inRoot2 = new TFile(name);
44  cout << "--------------------------" << endl;
45  cout << "in name=" << inName << endl
46  << "ps dir=" << psDir << endl
47  << "cut=" << cut << endl
48  << "embed name=" << name << endl
49  << "half = " << half << endl;
50  cout << "--------------------------" << endl;
51 
52  if(!inRoot){
53  cout << "cannot find the infile" << endl;
54  return;
55  }
56  if(!inRoot2){
57  cout << "cannot find " << name << endl;
58  }
59  TH3* h3[2]; TH2* h2[2];
60  TH1* h1[2]; //real,embed
61 
62  TH3* h3a; TH2* h2a;
63 
64  //real
65  h3[0]=(TH3*)inRoot.Get("Minus.h3PhiPrFitPtsPtPr");
66  h3a=(TH3*)inRoot.Get("Plus.h3PhiPrFitPtsPtPr");
67  if(!h3a){cout << "cannot find h3a" << endl; return; }
68  h3[0]->Add(h3a);
69 
70  //--- check if the second file is real data
71  bool isReal=false;
72  if(!strstr(name,"HighpT")) {
73  cout << "###Second file is real" << endl;
74  isReal=true;
75  }
76  h3[1]=(TH3*)inRoot2.Get("Minus.h3PhiPrFitPtsPtPr");
77  if(1){ // always do plus+minus
78  h3a=(TH3*)inRoot2.Get("Plus.h3PhiPrFitPtsPtPr");
79  h3[1]->Add(h3a);
80  }
81  char* real2="P00hm";
82  //----
83 
84  char* type[] = {"P01hi","mc"};
85  int marker[] = {4,8};
86  char* opt[] = { "e","esame"};
87 
88  if(isReal) type[1]=real2;
89 
90  int npt=4;
91  float ptary[] = {2,3,4,5,6};
92  char ctitle[100],cname[100];
93 
94  float maxFitPts=0;
95  float minMean=0,maxMean=0;
96 
97  if(strcmp(trigger,"central")==0){
98  maxFitPts=.14; minMean=30; maxMean=40;
99  }
100  else{
101  maxFitPts=.24; minMean=35; maxMean=45;
102  }
103 
104 
105  TCanvas c1("c1","c1",400,500);
106  TText* t=new TText;
107  gStyle->SetOptStat(0);
108 
109  Cut::SetCut(cut);
110  int fitPtsCut=Cut::mFitPts[0];
111  float ptmin=2, ptmax=4;
112  float fitptsary[] = { 3,fitPtsCut};
113  char* fitptstitle[] = { "Wide","Cut"};
114  //-------------------------------------------------------------
115 
116  for(int if=0;if<2;if++){
117  // *** fit pts summed over phi
118  for(int i=0;i<2;i++){ //real, embed
119  sprintf(name,"%s",type[i]);
120  h2[i]=HistSlice(h3[i],name,"",0,-165,195,"zy","e");
121  }
122 
123  sprintf(title,"fit pts range %d-45 (cut %d) %s",
124  fitptsary[if],cut,half.Data());
125  Divide(&c1,2,2,title,inName);
126  for(int ipt=0;ipt<npt;ipt++){
127  c1.cd(ipt+1);
128  for(int i=0;i<2;i++){
129 
130  h1[i]= HistSlice(h2[i],"","",0,ptary[ipt],ptary[ipt+1],"x","e");
131  SetRange(h1[i]->GetXaxis(),fitptsary[if],45.5);
132  h1[i]->Scale(1./h1[i]->Integral());
133  if(i==0)SetMinMax(h1[i],0,maxFitPts);
134  h1[i]->SetMarkerSize(0.6);
135  h1[i]->SetMarkerStyle(marker[i]); h1[i]->Draw(opt[i]);
136 
137  PrintMeanRms(h1[i],0.15,0.8-.1*i);
138  }
139  if(ipt==0){
140  TLegend l(0.15,0.4,0.3,0.5); l.SetFillColor(kWhite);
141  l.SetBorderSize(0);
142  l.AddEntry(h1[0],type[0],"p"); l.AddEntry(h1[1],type[1],"p");
143  l.Draw();
144  }
145  }
146  sprintf(title,"fitPts%sC%s",fitptstitle[if],type[1]);
147  Print(&c1,psDir,title);
148 
149  //*** fit pts distribution, phi slices
150  // combine pt 1.5-4
151  // one plot for each charge type
152 
153  /*
154  sprintf(cname,"fitPtsPhiSlices%sC%s",fitptstitle[if],type[1]);
155  sprintf(ctitle,"fit pts range %d-45, phi slices (%.1f<ptPr<%.1f)%s (cut %d)",
156  fitptsary[if],ptmin,ptmax,half.Data(),cut);
157  Divide(&c1,3,4,ctitle,inName);
158 
159  h2[0]=(TH2*)HistSlice(h3[0],"","",0,ptmin,ptmax,"xy");
160  h2[1]=(TH2*)HistSlice(h3[1],"","",0,ptmin,ptmax,"xy");
161  for(int iPhi=1; iPhi<=h2[0]->GetNbinsY(); iPhi++){
162  c1.cd(iPhi);
163  TAxis *axis = h2[0]->GetYaxis();
164  for(int i=0;i<2;i++){
165  sprintf(title,"%d<phi<%d",
166  axis->GetBinLowEdge(iPhi),axis->GetBinUpEdge(iPhi));
167  sprintf(name,"%s%s%s",fitptstitle[if],type[i],title);
168  SetRange(h2[i]->GetYaxis(),fitptsary[if],46);
169  h1[i] = h2[i]->ProjectionX(name,iPhi,iPhi);
170  h1[i]->Scale(1./h1[i]->Integral());
171  h1[i]->SetMarkerSize(0.5);
172  SetRange(h1[i]->GetXaxis(),fitptsary[if],45.5);
173  SetMinMax(h1[i],0,maxFitPts);
174  h1[i]->SetTitle(title);
175  h1[i]->SetMarkerStyle(marker[i]); h1[i]->Draw(opt[i]);
176 
177 
178  PrintMeanRms(h1[i],0.1,0.8-.2*i,0.08);
179  }
180  }
181  Print(&c1,psDir,cname);
182  */
183 
184  // profile
185  sprintf(cname,"fitPtsMeanVPhi%sC%s",fitptstitle[if],type[1]);
186  sprintf(ctitle,"mean fit pts V phi (%.1f<ptPr<%.1f) %s %d-45 (cut %d)",
187  ptmin,ptmax,half.Data(),fitptsary[if],cut);
188  Divide(&c1,1,1,ctitle,inName);
189  c1.cd(1); gPad->SetGridx(); gPad->SetGridy();
190  for(int i=0;i<2;i++){
191  h2a=(TH2*)HistSlice(h3[i],"","",0,ptmin,ptmax,"xy");
192  sprintf(name,"meanVphi%s%s",type[i],fitptstitle[if]);
193  int low=h2a->GetXaxis()->FindBin(fitptsary[if]);
194  TProfile *p=h2a->ProfileY(name,low,9999); p->SetTitle("");
195  SetMinMax(p,minMean,maxMean);
196 
197  p->SetMarkerStyle(marker[i]); p->Draw(opt[i]);
198 
199 
200  }
201  Print(&c1,psDir,cname);
202 
203  } // fit pts type
204 }
205 
206 
207 
208 
209 
210 
211