StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dca.C
1 #include "commonmacro/common.h"
2 #include "common/Name.cc"
3 #include "commonmacro/histutil.h"
4 
5 void dca(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 = 1)
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  if(!inRoot){
22  cout << "cannot find the infile" << endl;
23  return;
24  }
25  TText* t = new TText;
26  float ptAry[] = {2,3,4,5,6};
27  char* ptType[] = { "PtPr","PtGl"};
28  char* chargeType[]= { "Pos","Neg","PosPlusNeg"};
29  TH1 *ha, *hb;
30  TCanvas c1("c1","c1",400,500);
31  TH3* h3[2][3]; // ptType; plus,minus,plus+minus
32  TH2* h2a, *h2b; TH1* h1a, *h1b;
33  float dcaCut[]={0,1}; float dcaXYCut[]={-1,1};
34  char cname[100],ctitle[100];
35  int nc=2;
36  int npt=2;
37  float maxDcaPlot=.2; float maxDcaXYPlot=.1;
38  int nRebin=4;
39  if(nRebin>1){cout << ">>Rebinning " << nRebin << endl;}
40 
41  gStyle->SetOptStat(0);
42  //-------------------------------------------------------------------
43  //
44  // plus,minus,plus+minus
45 
46  for(int ipt=0;ipt<npt;ipt++){
47  //plus
48  sprintf(name,"Plus.h3DcaGlDcaXYGl%s",ptType[ipt]);
49  cout << name << endl;
50  h3[ipt][0]=(TH3*)inRoot.Get(name);
51  // minus
52  sprintf(name,"Minus.h3DcaGlDcaXYGl%s",ptType[ipt]);
53  cout << name << endl;
54  h3[ipt][1]=(TH3*)inRoot.Get(name);
55  // plus+minus
56  h3[ipt][2]=(TH3*)h3[ipt][0]->Clone();
57  sprintf(name,"PlusPlusMinus.h3DcaGlDcaXYGl%s",ptType[ipt]);
58  h3[ipt][2]->SetName(name); h3[ipt][2]->SetTitle(name);
59  h3[ipt][2]->Add(h3[ipt][1]);
60  }
61  //---------------------------------------------------------------
62  // plot
63  for(int ipt=0;ipt<npt;ipt++){ // pt type
64  cout << "***** " << ipt << "****** " << endl;
65  for(int ic=0;ic<nc;ic++){ // charge type
66  cout << "\t****" << ic <<"*****" << endl;
67 
68  //**** dca3d vs dca xy
69  sprintf(cname,"DcaVDcaXY%s%s",chargeType[ic],ptType[ipt]);
70  sprintf(ctitle,"dca3d vs dca xy, %s slices (%s) (cut %d)",
71  ptType[ipt],chargeType[ic],cut);
72  Divide(&c1,2,2,ctitle,inName);
73 
74  for(int j=0;j<4;j++){
75  c1.cd(j+1);
76  h2a=(TH2*)HistSlice(h3[ipt][ic],"","",0,
77  ptAry[j],ptAry[j+1],"xy");
78  h2a->Draw("box");
79  }
80  Print(&c1,psDir,cname);
81 
82  //**** dca3d
83  sprintf(cname,"Dca%s%s",chargeType[ic],ptType[ipt]);
84  sprintf(ctitle,"dca 3d, %s slices, (%s) (cut %d)",
85  ptType[ipt],chargeType[ic],cut);
86  Divide(&c1,2,2,ctitle,inName);
87 
88  for(int j=0;j<4;j++){
89  c1.cd(j+1); gPad->SetLogy(1);
90  h2a=(TH2*)HistSlice(h3[ipt][ic],"","",0,
91  ptAry[j],ptAry[j+1],"yx");
92  h1a=HistSlice(h2a,"",h2a->GetTitle(),0,0,0,"x");
93  h1b=HistSlice(h2a,"",h2a->GetTitle(),0,
94  dcaXYCut[0],dcaXYCut[1],"x");
95  // cout << h1b->GetTitle() << endl;
96 
97  //h1a->Scale(1./h1a->Integral()); h1b->Scale(1./h1b->Integral());
98  h1b->SetLineStyle(2);
99  //SetMinMax(h1a);
100  if(nRebin>1){h1a->Rebin(nRebin); h1b->Rebin(nRebin); }
101  h1a->Draw(); h1b->Draw("same");
102 
103  PrintMeanRms(h1a,0.6,0.8);
104  PrintMeanRms(h1b,0.6,0.6);
105 
106 
107  }
108  Print(&c1,psDir,cname);
109 
110  //**** dca xy
111  sprintf(cname,"DcaXY%s%s",chargeType[ic],ptType[ipt]);
112  sprintf(ctitle,"dca xy, %s slices, (%s) (cut %d)",
113  ptType[ipt],chargeType[ic],cut);
114  Divide(&c1,2,2,ctitle,inName);
115 
116  for(int j=0;j<4;j++){
117  c1.cd(j+1); gPad->SetLogy(1);
118  h2a=(TH2*)HistSlice(h3[ipt][ic],"","",0,
119  ptAry[j],ptAry[j+1],"xy");
120  h1a=HistSlice(h2a,"",h2a->GetTitle(),0,0,0,"x");
121  h1b=HistSlice(h2a,"",h2a->GetTitle(),0,
122  dcaCut[0],dcaCut[1],"x");
123 
124  //h1a->Scale(1./h1a->Integral()); h1b->Scale(1./h1b->Integral());
125  h1b->SetLineStyle(2);
126  //SetMinMax(h1a);
127  if(nRebin>1){h1a->Rebin(nRebin); h1b->Rebin(nRebin); }
128  h1a->Draw(); h1b->Draw("same");
129  PrintMeanRms(h1a,0.6,0.8);
130  PrintMeanRms(h1b,0.6,0.6);
131  }
132  Print(&c1,psDir,cname);
133 
134  }
135  }
136 }
137 
138