StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
compareFitPtsVeta.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void compareFitPtsVeta(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  if(more){
20  strcpy(name,more);
21  }
22  else if(extraValue>0){
23  // attempt to find the embed file
24  char* trigger = (strstr(inName,"central")) ? "central" :"minbias";
25  sprintf(name,"~/wrk/assoc/links/P01hi.central.HighpT_piminus_%d.hist/assoc_cut%d.hist.root",(int)extraValue,cut);
26  }
27  else{
28  cout << "Unknown embed file" << endl; return;
29  }
30 
31  TString half = "";
32  if(strstr(inName,"east")){ half="east"; }
33  if(strstr(inName,"west")){ half="west"; }
34 
35  embedRoot = new TFile(name);
36  cout << "--------------------------" << endl;
37  cout << "in name=" << inName << endl
38  << "ps dir=" << psDir << endl
39  << "cut=" << cut << endl
40  << "embed name=" << name << endl
41  << "half = " << half << endl;
42  cout << "--------------------------" << endl;
43 
44  if(!inRoot){
45  cout << "cannot find the infile" << endl;
46  return;
47  }
48  if(!embedRoot){
49  cout << "cannot find " << name << endl;
50  }
51  TH3* h3[2]; TH2* h2[2];
52  TH1* h1[2]; //real,embed
53  TProfile* p[2];
54 
55  TH3* h3a; TH2* h2a;
56 
57  h3[0]=(TH3*)inRoot.Get("Minus.h3VtxZFitPtsEtaPr");
58  h3a=(TH3*)inRoot.Get("Plus.h3VtxZFitPtsEtaPr");
59  if(!h3a){cout << "cannot find h3a" << endl; return; }
60  h3[0]->Add(h3a);
61  h3[1]=(TH3*)embedRoot.Get("Minus.h3VtxZFitPtsEtaPr");
62  h3a=(TH3*)embedRoot.Get("Plus.h3VtxZFitPtsEtaPr");
63  h3[1]->Add(h3a);
64 
65  char* type[] = {"real","mc"}; int npt=4;
66  int marker[] = {4,8};
67  char* opt[] = { "p","psame"};
68  char* optp[] = {"e","esame"};
69  char ctitle[100],cname[100];
70 
71  TCanvas c1("c1","c1",400,500);
72  TText* t=new TText;
73  gStyle->SetOptStat(0);
74 
75  Cut::SetCut(cut);
76  float fitPtsCut=20;
77 
78  float vtxAry[]= {-150,-125,-100,-75,-50,-25,0,25,50,75,100,125,150};
79  int nVtx = 12;
80  float etaAry[][2] = { { .1,.3 }, {.5,.7}, {-.3,-.1}, {-.7,-.5}};
81  int nEta = 4;
82 
83  //-------------------------------------------------------------
84 
85 
86  for(int iEta=0; iEta<nEta; iEta++){
87  //*** vtx z slices
88 
89  sprintf(title,"fitpts (range %d-45), vtx z slices (%.1f < eta < %.1f) (cut %d)",
90  fitPtsCut,etaAry[iEta][0],etaAry[iEta][1],cut);
91  Divide(&c1,3,4,title,inName);
92 
93 
94  for(int iVtx=0;iVtx<nVtx; iVtx++){
95  c1.cd(iVtx+1);
96  for(int i=0; i<2; i++){
97  h2[i]=(TH2*)HistSlice(h3[i],"","",0,etaAry[iEta][0],etaAry[iEta][1],"xy");
98  h1[i]=(TH1*)HistSlice(h2[i],"",h2[i]->GetTitle(),0,
99  vtxAry[iVtx],vtxAry[iVtx+1],"x");
100  SetRange(h1[i]->GetXaxis(),fitPtsCut,46);
101  if(h1[i]->Integral()) h1[i]->Scale(1./h1[i]->Integral());
102  h1[i]->SetMarkerSize(0.5); SetMinMax(h1[i],0.001,.12);
103  h1[i]->SetMarkerStyle(marker[i]); h1[i]->Draw(opt[i]);
104  PrintMeanRms(h1[i],0.1,0.8-.2*i,0.06);
105  }
106  }
107  sprintf(name,"fitPtsVtxZSlicesEtaBin%d",iEta);
108  Print(&c1,psDir,name);
109  }
110  //*** mean fit pts V vtx
111 
112  sprintf(title,"mean fit pts (range %d-45) V vtx z (cut %d)",
113  fitPtsCut,cut);
114  Divide(&c1,2,2,title,inName);
115 
116  for(int iEta=0; iEta<nEta; iEta++){
117  c1.cd(iEta+1); gPad->SetGridx(); gPad->SetGridy();
118  TLegend* l=new TLegend(0.1,0.1,0.3,0.2);
119  for(int i=0; i<2; i++){
120  h2[i]=(TH2*)HistSlice(h3[i],"","",0,etaAry[iEta][0],etaAry[iEta][1],"xy","e");
121  p[i]=Profile(h2[i],"",h2[i]->GetTitle(),0,fitPtsCut,46,"y","e");
122  SetMinMax(p[i],30,40);
123  SetRange(p[i]->GetXaxis(),vtxAry[0],vtxAry[nVtx]);
124  p[i]->SetMarkerStyle(marker[i]); p[i]->Draw(optp[i]);
125  if(iEta==0){
126  l->AddEntry(p[i],type[i],"p");
127  }
128 
129  }
130  }
131  sprintf(title,"fitPtsMeanVz");
132  Print(&c1,psDir,title);
133 
134 }
135