StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
instrAsy.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 instrAsy() {
9  gStyle->SetOptStat(0);
10  gStyle->SetOptFit(0);
11 
12  TGraphErrors *gr =new TGraphErrors;
13  gr->SetName("insyAsy");
14  gr->SetTitle("Instrumental Asymmetries");
15  //gr->SetMarkerColor(ampCol[iam]);
16  gr->SetMarkerSize(0.8);
17  gr->SetMarkerStyle(21);
18  TGraphErrors *gr1=gr;
19 
20 
21  TString wrkDir="final/";
22  TString fname=wrkDir+"defaultB-H/asyVer1.hist.root";
23  TFile *inpH=new TFile(fname);
24  assert(inpH->IsOpen());
25  //inpH->ls();
26  const int nSel=5;
27  char *selL[nSel]={ "a0*All","b0*All","a2*All","b2*All","c1*All"};
28  int isel;
29  for (isel=0;isel<nSel;isel++) {
30  TGraphErrors *gr =(TGraphErrors *) inpH->Get(selL[isel]);
31  assert(gr);
32  //gr->Print();
33  //gr->Draw("AP");
34  float x1=0;
35  if(isel<2) x1=2189;
36  gr->Fit("pol0","","",x1,3000);
37  TF1 *ff=gr->GetFunction("pol0");
38  if(ff==0) continue; // no fit was made
39  float val=ff->GetParameter(0);
40  float err=ff->GetParError(0);
41  printf("pol0= %f +/- %f\n",val,err);
42  int n=gr1->GetN();
43  float x=isel+1;
44  gr1->SetPoint(n,x,val);
45  gr1->SetPointError(n,0,err);
46  }
47 
48 
49  gr1->Print();
50 
51  // return;
52  gr1->Draw("AP");
53 
54  // save Tgraph
55  TString fname=wrkDir+"instAsy.hist.root";
56  TFile *outH=new TFile(fname,"RECREATE");
57  assert(outH->IsOpen());
58  printf("save outH -->%s\n", fname.Data());
59  gr1->Write();
60  outH->ls();
61  outH->Write();
62 
63 
64  return;
65 }
66 #if 0
67 
68  createTgr();
69 
70  int isel;
71  for (isel=0;isel<nSel;isel++) {
72  TString fname=wrkDir+selL[isel]+"endVer1.hist.root";
73  // printf("ii=%d %s %s\n",isel, selL[isel], fname.Data());
74  TFile *inpH=new TFile(fname);
75  assert(inpH->IsOpen());
76  inpH->ls();
77  int io;
78  for (io=0;io<nObs;io++) {
79  char name[100];
80  sprintf(name,"%s*EtaBF",obsL[io]);
81  TGraphErrors *gr =(TGraphErrors *) inpH->Get(name);
82  assert(gr);
83  gr->Print();
84  sprintf(name,"avr%s*EtaBF",obsL[io]);
85  TF1 *ff=gr->GetFunction(name);
86  if(ff==0) continue; // no fit was made
87  float val=ff->GetParameter(0);
88  float err=ff->GetParError(0);
89  printf("pol0= %f +/- %f\n",val,err);
90  TGraphErrors * grOut=grL[io];
91  int n=grOut->GetN();
92  float x=isel+1;
93  grOut->SetPoint(n,x,val);
94  grOut->SetPointError(n,0,err);
95  }
96  }
97 
98  grL[0]->Print();
99 
100 
101  c=new TCanvas("aa","aa" ,800,800);
102  c->Divide(3,1);
103  TLine *ln0=new TLine(0,0.,12,0.);
104 
105  int it;
106  for (it=0;it<mxGr;it++) {
107  TGraphErrors * gr=grL[it];
108  int n=gr->GetN();
109  printf("\nit=%d name='%s', N=%d\n",it,gr->GetName(),n);
110  // gr->Print();
111  if(n<=0) continue;
112  c->cd(1+it);
113  gr->Draw("AP");
114  // gr->Fit("pol0");
115 
116  TAxis *ax=gr->GetXaxis();
117  ax->SetTitle("choice of event selection");
118  ln0->Draw();
119  ln0->SetLineStyle(3);
120  }
121 
122  // save Tgraph
123  TString fname=wrkDir+"compCuts.hist.root";
124  TFile *outH=new TFile(fname,"RECREATE");
125  assert(outH->IsOpen());
126  printf("save outH -->%s\n", fname.Data());
127  outH->cd();
128  for (it=0;it<mxGr;it++) {
129  grL[it]->Write();
130  }
131 
132  outH->ls();
133  outH->Write();
134 }
135 
136 
137 //==========================================
138 //==========================================
139 void createTgr() {
140  char *obsT[nObs]={ "An", "A#Sigma", "A#Delta"};
141  // int ampCol[mxAmp]={kBlue, kYellow, kGreen, kMagenta};
142 
143  int io;
144  for (io=0;io<nObs;io++) {
145  char name[100];
146  sprintf(name,"%s",obsL[io]);
147  //printf("ic=%d iam=%d name=%s=\n",ic,iam,name);
148  TGraphErrors *gr =new TGraphErrors;
149  gr->SetName(name);
150  gr->SetTitle(obsT[io]);
151  //gr->SetMarkerColor(ampCol[iam]);
152  gr->SetMarkerSize(0.8);
153  gr->SetMarkerStyle(21);
154  grL[io]=gr;
155  }
156 }
157 
158 #endif