StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
compareDca.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void compareDca(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  TString s=inName;
25  char* trigger = (s.Contains("central")) ? "central" :"minbias";
26  sprintf(name,"~/wrk/assoc/links/P01hi.central.HighpT_piminus_%d.hist/assoc_cut%d.hist.root",(int)extraValue,cut);
27  }
28  else{
29  cout << "Unknown embed file" << endl; return;
30  }
31 
32  embedRoot = new TFile(name);
33  cout << "--------------------------" << endl;
34  cout << "in name=" << inName << endl
35  << "ps dir=" << psDir << endl
36  << "cut=" << cut << endl
37  << "embed name=" << name << endl;
38  cout << "--------------------------" << endl;
39 
40  if(!inRoot){
41  cout << "cannot find the infile" << endl;
42  return;
43  }
44  if(!embedRoot){
45  cout << "cannot find " << name << endl;
46  }
47  TH3* h3[2]; TH2* h2[2];
48  TH1* h1[2]; //real,embed
49 
50  TH3* h3a;
51 
52  h3[0]=(TH3*)inRoot.Get("Minus.h3DcaGlDcaXYGlPtPr");
53  //h3a=(TH3*)inRoot.Get("Plus.h3DcaGlDcaXYGlPtPr");
54  //if(!h3a){cout << "cannot find h3a" << endl; return; }
55  //h3[0]->Add(h3a);
56 
57  h3[1]=(TH3*)embedRoot.Get("Minus.h3DcaGlDcaXYGlPtPr");
58  if(!h3[1]) { cout << "huh" << endl; return; }
59  //h3a=(TH3*)embedRoot.Get("Plus.h3DcaGlDcaXYGlPtPr");
60  //if(!h3a){cout << "cannot find h3a" << endl; return; }
61  //h3[1]->Add(h3a);
62 
63  char* type[] = {"real","embed"}; int npt=4;
64  float ptary[] = {2,3,4,5,6};
65 
66  for(int i=0;i<2;i++){ //real, embed
67  sprintf(name,"%s",type[i]);
68  h2[i]=HistSlice(h3[i],"","",0,0,3,"zy");
69  }
70 
71  TCanvas c1("c1","c1",400,500);
72  TText* t=new TText;
73  gStyle->SetOptStat(0);
74 
75  // Cut::SetCut(cut);
76  // int fitPtsCut=Cut::mFitPts[0];
77  float dcaCutAry[] = { 3,1};
78  char* dcatitle[] = { "Wide","Cut"};
79  int nRebin=4;
80  //-------------------------------------------------------------
81 
82  for(int id=0;id<2;id++){
83 
84  sprintf(title,"dcaXY |dca|<%.f (cut %d)",dcaary[id],cut);
85  Divide(&c1,2,2,title,inName);
86  for(int ipt=0;ipt<npt;ipt++){
87  c1.cd(ipt+1); gPad->SetLogy();
88  for(int i=0;i<2;i++){ // real and mc
89  h1[i]= HistSlice(h2[i],"","",0,ptary[ipt],ptary[ipt+1],"x");
90  SetRange(h1[i]->GetXaxis(),-dcaary[id],dcaary[id]);
91  if(nRebin>1)h1[i]->Rebin(nRebin);
92  h1[i]->Scale(1./h1[i]->Integral());
93  h1[i]->SetMaximum(.40);
94  h1[i]->SetMarkerStyle(4+4*i);
95  if(i==0){
96  h1[i]->SetLineColor(kBlue); h1[i]->Draw("");
97  }
98  else{
99  h1[i]->SetLineColor(kRed); h1[i]->Draw("same");
100  }
101  PrintMeanRms(h1[i],0.15,0.8-.1*i);
102  }
103 
104  if(ipt==0){ // first pad
105  TLegend l(0.15,0.4,0.3,0.5); l.SetFillColor(kWhite);
106  l.SetBorderSize(0);
107  l.AddEntry(h1[0],"real","l"); l.AddEntry(h1[1],"mc","l");
108  l.Draw();
109  }
110  }
111  sprintf(title,"dcaXYGl%s",dcatitle[id]);
112  Print(&c1,psDir,title);
113  }
114 }