StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yieldVptEW.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void yieldVptEW(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  TString side;
20  if(strstr(inName,"west")){ side="west"; }
21  else if(strstr(inName,"east")){ side="east"; }
22  else {side =more; }
23 
24  inRoot = new TFile(inName);
25 
26  if(!inRoot){
27  cout << "cannot find the infile" << endl;
28  return;
29  }
30 
31 
32  TText* t = new TText;
33 
34  Stat_t max1, max, max2, min,min1,min2,maxary[2],minary[2];
35  Stat_t dcaCut = 1.2;
36 
37  TH1 *ha, *hb;
38  TCanvas c1("c1","c1",400,500);
39  float dcaXYMin=-1.5,dcaXYMax=1.5;
40  float phiMin=-165,phiMax=195;
41  float ptMin=1.5,ptMax=6;
42  gStyle->SetPadGridX(1); gStyle->SetPadGridY(1);
43  gStyle->SetOptStat(0);
44 
45  const Int_t nBase = 2;
46 
47  // these are the histograms to get from the root file
48  //
49  char* baseName[] = {
50  "h3PhiGlDcaXYGlPtGl","h3PhiPrDcaXYGlPtPr"
51  };
52  TH1* h1[nBase][2]; // pt/ plus,minus
53  //-------------------------------------------------------------------
54  //
55  // type a :2 pads. east on top, west on bottom. plus, minus on same pad.
56 
57 
58  for(int i=0;i<nBase;i++){
59 
60  TH3* h3; TH2* h2;
61  for(int ic=0; ic<2; ic++){
62 
63  // get the 3d histogram
64  setName(name,baseName[i],sPM[ic].Data());
65  h3 = (TH3*) inRoot.Get(name);
66  //cout << name << endl;
67 
68  // project 2d
69  h2 = HistSlice(h3,"dummy2d","",0,
70  phiMin,phiMax,"yz","e");
71  // cout << h2->GetTitle() << endl;
72 
73  // project 1d
74  h1[i][ic] =
75  HistSlice(h2,"dummy1d","",0,
76  dcaXYMin,dcaXYMax,"x","e");
77  }
78 
79  h1[i][0]->SetMarkerStyle(4); h1[i][1]->SetMarkerStyle(8);
80 
81  max = FindMax(h1[i][0],h1[i][1]);
82  min = FindMin(h1[i][0],h1[i][1]);
83 
84  //
85  // yields
86  //
87  sprintf(title,"yield v %s %s (%s) (cut %d)",
88  h3->GetZaxis()->GetTitle(),h2->GetTitle(),side.Data(),cut);
89 
90 
91  Divide(&c1,1,2,title,inName);
92  TLegend legend(.1,.1,.25,.2);
93 
94  //SetMinMax(h1[0],min*0.5,max*1.2);
95  sprintf(title,"%s (%s)",h1[i][0]->GetTitle(),side.Data());
96  h1[i][0]->SetTitle(title);
97  c1.cd(1);h1[i][0]->Draw("e1"); h1[i][1]->Draw("e1same");
98  SetRange(h1[i][0]->GetXaxis(),ptMin,ptMax);
99  gPad->SetLogy();
100 
101  legend.AddEntry(h1[i][0],"plus","p");
102  legend.AddEntry(h1[i][1],"minus","p");
103  legend.SetFillColor(kWhite);
104  legend.Draw();
105 
106  // sum plus and minus
107  ha=(TH1*)h1[i][0]->Clone();
108  ha->Add(h1[i][1]);
109  //SetMinMax(ha,min,max*2);
110  sprintf(title,"plus+minus %s",side.Data());
111  ha->SetTitle(title);
112  SetRange(ha->GetXaxis(),ptMin,ptMax);
113  c1.cd(2);ha->Draw("e1");
114  gPad->SetLogy();
115 
116  sprintf(name,"yieldV%s%s",h3->GetZaxis()->GetTitle(),side.Data());
117  Print(&c1,psDir,name);
118  }
119 
120  //
121  // minus/plus
122  //
123  sprintf(title,"yield neg/pos v pT %s (%s)(cut %d)",
124  h2->GetTitle(),side.Data(),cut);
125 
126  Divide(&c1,1,2,title,inName);
127 
128  for(int iBase=0; iBase<2; iBase++){
129  ha = (TH1*)h1[iBase][1]->Clone();
130  ha->Divide(h1[iBase][0]);
131  ha->SetMinimum(0.5); ha->SetMaximum(1.5);
132  sprintf(title,"neg/pos V %s",h1[iBase][0]->GetXaxis()->GetTitle());
133  ha->SetTitle(title);
134  SetRange(ha->GetXaxis(),ptMin,ptMax);
135  c1.cd(iBase+1);ha->Draw("e1");
136  TLine* line=new TLine;
137  line->DrawLine(ha->GetXaxis()->GetBinLowEdge(ha->GetXaxis()->GetFirst()),1,
138  ha->GetXaxis()->GetBinUpEdge(ha->GetXaxis()->GetLast()),1);
139  sprintf(name,"yieldNegOverPosVpt%s",side.Data());
140  }
141  Print(&c1,psDir,name);
142 
143 
144 
145 }