StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
compSelection.C
1 const int mxGr=3;
2 TGraphErrors * grL[mxGr];
3 
4 const int nObs=3;
5 char *obsL[nObs]={ "A_n", "A_s", "A_d"};
6 
7 
8 compSelection() {
9  gStyle->SetOptStat(0);
10  gStyle->SetOptFit(0);
11 
12  TString wrkDir="final/";
13  const int nSel=11;
14  char *selL[nSel]={ "defaultB-H/", "default-H/", "maxEta1.4-H/", "highPol-H/", "nPrim5_20-H/","zVert50-H/", "pT1_3-H/", "posCharge-H/","shiftPatt-H/","swapPatt-H/","randPatt-H/" };
15 
16  createTgr();
17 
18  int isel;
19  for (isel=0;isel<nSel;isel++) {
20  TString fname=wrkDir+selL[isel]+"endVer1.hist.root";
21  // printf("ii=%d %s %s\n",isel, selL[isel], fname.Data());
22  TFile *inpH=new TFile(fname);
23  assert(inpH->IsOpen());
24  inpH->ls();
25  int io;
26  for (io=0;io<nObs;io++) {
27  char name[100];
28  sprintf(name,"%s*EtaBF",obsL[io]);
29  TGraphErrors *gr =(TGraphErrors *) inpH->Get(name);
30  assert(gr);
31  gr->Print();
32  sprintf(name,"avr%s*EtaBF",obsL[io]);
33  TF1 *ff=gr->GetFunction(name);
34  if(ff==0) continue; // no fit was made
35  float val=ff->GetParameter(0);
36  float err=ff->GetParError(0);
37  printf("pol0= %f +/- %f\n",val,err);
38  TGraphErrors * grOut=grL[io];
39  int n=grOut->GetN();
40  float x=isel+1;
41  grOut->SetPoint(n,x,val);
42  grOut->SetPointError(n,0,err);
43  }
44  }
45 
46  grL[0]->Print();
47 
48 
49  c=new TCanvas("aa","aa" ,800,800);
50  c->Divide(3,1);
51  TLine *ln0=new TLine(0,0.,12,0.);
52 
53  int it;
54  for (it=0;it<mxGr;it++) {
55  TGraphErrors * gr=grL[it];
56  int n=gr->GetN();
57  printf("\nit=%d name='%s', N=%d\n",it,gr->GetName(),n);
58  // gr->Print();
59  if(n<=0) continue;
60  c->cd(1+it);
61  gr->Draw("AP");
62  // gr->Fit("pol0");
63 
64  TAxis *ax=gr->GetXaxis();
65  ax->SetTitle("choice of event selection");
66  ln0->Draw();
67  ln0->SetLineStyle(3);
68  }
69 
70  // save Tgraph
71  TString fname=wrkDir+"compCuts.hist.root";
72  TFile *outH=new TFile(fname,"RECREATE");
73  assert(outH->IsOpen());
74  printf("save outH -->%s\n", fname.Data());
75  outH->cd();
76  for (it=0;it<mxGr;it++) {
77  grL[it]->Write();
78  }
79 
80  outH->ls();
81  outH->Write();
82 }
83 
84 
85 //==========================================
86 //==========================================
87 void createTgr() {
88  char *obsT[nObs]={ "An", "A#Sigma", "A#Delta"};
89  // int ampCol[mxAmp]={kBlue, kYellow, kGreen, kMagenta};
90 
91  int io;
92  for (io=0;io<nObs;io++) {
93  char name[100];
94  sprintf(name,"%s",obsL[io]);
95  //printf("ic=%d iam=%d name=%s=\n",ic,iam,name);
96  TGraphErrors *gr =new TGraphErrors;
97  gr->SetName(name);
98  gr->SetTitle(obsT[io]);
99  //gr->SetMarkerColor(ampCol[iam]);
100  gr->SetMarkerSize(0.8);
101  gr->SetMarkerStyle(21);
102  grL[io]=gr;
103  }
104 }
105 
106