StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yieldVphiEW.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void yieldVphiEW(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 {
14 
15  cout << "--------------------------" << endl;
16  cout << "in name=" << inName << endl
17  << "ps dir=" << psDir << endl
18  << "cut=" << cut << endl;
19  cout << "--------------------------" << endl;
20 
21  TString side;
22  if(strstr(inName,"west")){ side="west"; }
23  else if(strstr(inName,"east")){ side="east"; }
24  else {side =more; }
25 
26  inRoot = new TFile(inName);
27 
28  if(!inRoot){
29  cout << "cannot find the infile" << endl;
30  return;
31  }
32  TCanvas c1("c1","c1",400,500);
33  TH1* ha, *hb;
34  float dcaMin=-1.5,dcaMax=1.5;
35 
36 
37  gStyle->SetOptStat(0);
38 
39  Int_t nBase = 2;
40 
41  char* baseName[] = {
42  "h3PhiPrDcaXYGlPtPr",
43  "h3PhiGlDcaXYGlPtGl"
44  };
45  const int nPt=4;
46  float ptary[]={1.5,2,3,4,6};
47 
48  //--------------------------------------------------------------
49  // type b : slices
50 
51  // pr pt and gl pt cut
52  for(int i=0; i<nBase; i++){
53  cout << border << endl;
54 
55  TH1D* h1[2][nPt];
56  TH3* h3; TH2* h2;
57  TLegend legend(.1,.1,.25,.2);
58  legend.SetFillColor(kWhite); legend.SetBorderSize(0);
59 
60  for(int ic=0; ic<2; ic++){
61  // get the 3d histogram
62  setName(name,baseName[i],sPM[ic].Data());
63  h3 = (TH3D*) inRoot.Get(name);
64 
65  // project 2d
66  h2 =
67  HistSlice(h3,"dummy2d","",0,dcaMin,dcaMax,"zx","e");
68 
69  // slices 1d
70  for(int is=0; is<nPt; is++){
71  h1[ic][is]=HistSlice(h2,"dummy1d","",0,
72  ptary[is],ptary[is+1],"x","e");
73  }
74  }// ic
75  float min,max;
76  // canvas names
77  sprintf(title,"yield v phi %s %s slices (%s) (cut %d)",
78  h2->GetTitle(),h3->GetZaxis()->GetTitle(),side.Data(),cut);
79  sTitle=title;
80  sprintf(name,"yieldVphi%s%s",h3->GetZaxis()->GetTitle(),side.Data());
81  sName=name;
82 
83  Divide(&c1,2,2,sTitle.Data(),inName);
84  for(int iSlice=0; iSlice<nPt;iSlice++){
85  ha=h1[0][iSlice]; //pos
86  hb=h1[1][iSlice]; //neg
87  ha->SetMarkerStyle(4);
88  hb->SetMarkerStyle(8);
89 
90  max = FindMax(ha,hb);
91  min = FindMin(ha,hb);
92  SetMinMax(ha,min*0.5,max*1.2);
93 
94  c1.cd(iSlice+1); ha->Draw("e");
95  hb->Draw("esame");
96  gPad->SetGridx(); gPad->SetGridy();
97 
98  if(iSlice==0){
99  legend.AddEntry(h1[0][0],"plus","p");
100  legend.AddEntry(h1[1][0],"minus","p");
101  legend.Draw();
102  }
103  }
104  Print(&c1,psDir,sName.Data());
105 
106  // plus+minus
107  sName += "_sum"; sTitle += "sum";
108  Divide(&c1,2,2,sTitle.Data(),inName);
109  for(int iSlice=0; iSlice<nPt;iSlice++){
110  TH1* ha = (TH1*)h1[0][iSlice]->Clone();
111  ha->Add(h1[1][iSlice]);
112 
113  SetMinMax(ha,ha->GetMinimum()*0.5,ha->GetMaximum()*2.2);
114 
115  c1.cd(iSlice+1); ha->Draw("e");
116  // PrintMeanRmsYield(ha,0.2,0.8,0.04);
117  gPad->SetGridx(); gPad->SetGridy();
118 
119  }
120  Print(&c1,psDir,sName.Data());
121 
122 
123  // delete[][] h1;
124 
125 
126  }
127 
128 
129 }