StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fitPts.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void fitPts(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 = "west",
11  float extraValue = 0)
12 {
13  cout << "--------------------------" << endl;
14  cout << "in name=" << inName << endl
15  << "ps dir=" << psDir << endl
16  << "cut=" << cut << endl;
17  cout << "--------------------------" << endl;
18 
19  inRoot = new TFile(inName);
20 
21  gSystem->Load("StHiMicroEvent");
22  gSystem->Load("StHiMicroAnalysis");
23  Cut::SetCut(cut);
24  Cut::ShowCuts();
25 
26  if(!inRoot){
27  cout << "cannot find the infile" << endl;
28  return;
29  }
30  TText* t = new TText;
31  float ptAry[] = {2,3,4,5,6};
32  char* ptType[] = { "PtPr","PtGl"};
33  char* chargeType[]= { "Pos","Neg","PosPlusNeg"};
34  TH1 *ha, *hb;
35  TCanvas c1("c1","c1",400,500);
36  TH3* h3[2][3]; // ptType; plus,minus,plus+minus
37  TH2* h2a, *h2b; TH1* h1a, *h1b;
38  float ptmin=1.5,ptmax=4.0;
39  char cname[100],ctitle[100];
40  int nc=2;
41  int nptType=1;
42 
43  int fitPtsCut=Cut::mFitPts[0];
44  float fitptsary[] = { 3,fitPtsCut};
45  char* fitptstitle[] = { "Wide","Cut"};
46 
47  gStyle->SetOptStat(0);
48  //-------------------------------------------------------------------
49  //
50  // plus,minus,plus+minus
51 
52  for(int iptType=0;iptType<nptType;iptType++){
53  //plus
54  sprintf(name,"Minus.h3PhiPrFitPts%s",ptType[iptType]);
55  cout << name << endl;
56  h3[iptType][0]=(TH3*)inRoot.Get(name);
57  // minus
58  sprintf(name,"Plus.h3PhiPrFitPts%s",ptType[iptType]);
59  h3[iptType][1]=(TH3*)inRoot.Get(name);
60  // plus+minus
61  h3[iptType][2]=(TH3*)h3[iptType][0]->Clone();
62  sprintf(name,"PlusPlusMinus.h3PhiPrFitPts");
63  h3[iptType][2]->SetName(name); h3[iptType][2]->SetTitle(name);
64  h3[iptType][2]->Add(h3[iptType][1]);
65  }
66  //---------------------------------------------------------------
67  for(int if=0;if<2; if++){
68  for(int iptType=0;iptType<nptType;iptType++){
69 
70  //**** fit pts, Pos and Neg on same plot
71  sprintf(cname,"fitPts%s%s",ptType[iptType],
72  fitptstitle[if]);
73  sprintf(ctitle,"fit pts, %s slices %d-45 (cut %d)",
74  ptType[iptType],fitptsary[if],cut);
75  Divide(&c1,2,2,ctitle,inName);
76 
77  for(int j=0;j<4;j++){
78  c1.cd(j+1);
79  if(j==0){
80  TLegend l(0.1,0.4,0.3,0.5); l.SetBorderSize(0);
81  l.SetFillColor(0);
82  }
83  for(int ic=0;ic<nc;ic++){
84  h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
85  ptAry[j],ptAry[j+1],"xy");
86  h1a=HistSlice(h2a,"",h2a->GetTitle(),0,0,0,"x");
87  SetRange(h1a->GetXaxis(),fitptsary[if],46);
88  h1a->SetMarkerSize(0.6);
89  if(ic<1){
90  SetMinMax(h1a,0,h1a->GetMaximum()*2.5);
91  h1a->SetMarkerStyle(4);
92  h1a->Draw("p");
93  PrintMeanRms(h1a,0.1,.8);
94 
95  }
96  else if (ic==1){
97  h1a->SetMarkerStyle(8);
98  h1a->Draw("psame");
99  PrintMeanRms(h1a,0.1,.7);
100  }
101  else if (ic==2){
102  h1a->SetMarkerStyle(12);
103  h1a->Draw("psame");
104  PrintMeanRms(h1a,0.1,.6);
105  }
106  if(j==0) l.AddEntry(h1a,chargeType[ic],"p");
107  }
108  if(j==0) l.Draw();
109  } // pt loop
110  Print(&c1,psDir,cname);
111 
112  //*** fit pts distribution, phi slices
113  // combine pt 1.5-4
114  // one plot for each charge type
115 
116  for(int ic=0;ic<nc;ic++){
117  sprintf(cname,"fitPts%s%sPhiSlices%s",
118  ptType[iptType],chargeType[ic],fitptstitle[if]);
119  sprintf(ctitle,"fit pts %d-45, phi slices (%.1f<%s<%.1f) %s (cut %d)",
120  fitptsary[if],ptmin,ptType[iptType],ptmax,chargeType[ic],cut);
121  Divide(&c1,3,4,ctitle,inName);
122 
123  h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
124  ptmin,ptmax,"xy");
125  for(int iPhi=1; iPhi<=h2a->GetNbinsY(); iPhi++){
126  c1.cd(iPhi);
127  TAxis *axis = h2a->GetYaxis();
128  sprintf(title,"%d<phi<%d",
129  axis->GetBinLowEdge(iPhi),axis->GetBinUpEdge(iPhi));
130  sprintf(name,"%s%s%s%s",
131  chargeType[ic],ptType[iptType],fitptstitle[if],title);
132 
133  h1a = h2a->ProjectionX(name,iPhi,iPhi);
134  h1a->SetMarkerStyle(8); h1a->SetMarkerSize(0.6);
135  h1a->SetTitle(title); SetRange(h1a->GetXaxis(),fitptsary[if],45.5);
136  h1a->Draw("p");
137  PrintMeanRms(h1a,0.1,0.6,0.08);
138  }
139  Print(&c1,psDir,cname);
140 
141  } // ic
142 
143  //** mean fit, profile vs phi
144  for(int ic=0;ic<nc;ic++){
145  sprintf(cname,"fitPtsMeanVPhi%s%s%s",
146  ptType[iptType],chargeType[ic],fitptstitle[if]);
147  sprintf(ctitle,"mean fit pts V phi %d-45 (%.1f<%s<%.1f) %s (cut %d)",
148  fitptsary[if],ptmin,ptType[iptType],ptmax,chargeType[ic],cut);
149  Divide(&c1,1,1,ctitle,inName);
150  c1.cd(1); gPad->SetGridx(); gPad->SetGridy();
151  h2a=(TH2*)HistSlice(h3[iptType][ic],"","",0,
152  ptmin,ptmax,"xy");
153  int low=h2a->GetXaxis()->FindBin(fitptsary[if]);
154  sprintf(name,"meanVphi%s%s%s",
155  chargeType[ic],ptType[iptType],fitptstitle[if]);
156  TProfile *p=h2a->ProfileY(name,low,9999); p->SetTitle("");
157  SetMinMax(p,30,40);
158  p->SetMarkerStyle(8);
159  p->Draw();
160 
161  Print(&c1,psDir,cname);
162 
163  } // ic
164 
165  }
166  }
167 }
168 
169