StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plTw.C
1 plTw( int pid=14, char *name="deT+S") { //type of particles, histo name
2 
3  const int ng=4;
4  TGraphErrors *hg[ng];
5  int nH=InitGraph(hg,ng);
6  printf("%d graphs initialized\n",nH);
7  int i;
8  for(i=0;i<ng;i++) printf("i=%d, add=%0x\n",i,hg[i]);
9 
10  gStyle->SetOptStat(111111);
11  gStyle->SetOptFit(111111);
12 
13  //pt bins
14  float pt[]={0.5,1,2,3,4,5,10,20,30,40,50}; int npt=11;
15  //float pt[]={0.5,1,10,50}; int npt=4;
16 
17  //eta bins
18  float eta[]={1.2,1.75};
19  int neta=2;
20 
21  int i=0,k=0;
22 
23  for(i=0;i<npt;i++)
24  for(k=0;k<neta;k++)
25  {
26  float Etot=pt[i]*cosh(eta[k]); // approximate, mass ignored
27  char fname[1000];
28  sprintf(fname,"/star/data22/MC/balewski/eemc/sim2002/f/mc_pid%d_pt%.1f_eta%4.2f",pid,pt[i],eta[k]);
29  // printf( "file%s Etot=%f eta=%f\n",fname,Etot,eta[k]);// continue;
30  // E=pT/sin(theta)
31  doJob(fname,hg,Etot,k,pid,name);
32  // if(i>1) break;
33  // return;
34  }
35 
36  //hg[0]->Print();
37  // hg[2]->Print();
38  // return;
39  char tit[100];
40  sprintf(tit,"%s-pid%d",name,pid);
41 
42  int kkk=0;
43  if (pid<4) kkk=1;
44  TCanvas *can = new TCanvas(tit,tit,600,400+400*kkk);
45  if(kkk) { can->Divide(1,2); can->cd(1);}
46  hgDrawE(hg,pid,name);
47 
48  if(kkk) { can->cd(2);
49  hgDrawSE(hg+2,pid,name);
50  }
51  can->Print();
52 
53 }
54 
55 //--------------------------------------------
56 //--------------------------------------------
57 //--------------------------------------------
58 
59 void doJob(char *fname0,TGraphErrors **hg, float Etot, int ieta,int pid,char *hname) {
60  printf("job--> %s Etot=%f ieta=%d hist=%s\n",fname0,Etot,ieta,hname);
61  assert(ieta>=0 && ieta<=1);
62 
63  TString fname=fname0;
64  TFile *dir=new TFile(fname+".hist.root");
65  // dir->ls();
66 
67  if(!dir->IsOpen()){ printf("Open failed, take next\n"); return;}
68 
69  TH1F* h1=0;
70  double x,y,ey;
71  int n=-1;
72 
73  h1=(TH1F*) dir->Get(hname);
74  assert(h1);
75 
76  TF1 *ff=h1->GetFunction("gaus"); assert(ff);
77 
78  // total energy ........................
79  x=Etot;
80 
81  if(pid<4) { // use relative energy for gam & ele
82  y=ff->GetParameter(1)/Etot;
83  ey=ff->GetParError(1)/Etot;
84  }
85 
86  if(pid>4) { // use relative MEAN & RMS for others
87  y=h1->GetMean();
88  ey=h1->GetRMS();
89  }
90 
91 
92  TGraphErrors *gr=hg[0+ieta];
93  n=gr->GetN();
94  gr->SetPoint(n,x,y);
95  gr->SetPointError(n,0.,ey);
96 
97  if(pid>4) return;
98 
99  // energy resolution ........................
100  x=1/sqrt(Etot);
101  y=ff->GetParameter(2)/Etot;
102  ey=ff->GetParError(2)/Etot;
103  printf("Etot=%f x=%f y=%f ey=%g\n",Etot,x,y);
104 
105  TGraphErrors *gr=hg[2+ieta];
106  n=gr->GetN();
107  gr->SetPoint(n,x,y);
108  gr->SetPointError(n,0.,ey);
109 
110 }
111 
112 
113 //------------------------------------------------
114 //------------------------------------------------
115 //------------------------------------------------
116 
117 int InitGraph( TGraphErrors **hg,int ng){
118  char *name[]={"reco E or E/E, eta=1.20"
119  ,"reco E or E/E, eta=1.75"
120  ,"reco sigE , eta=1.20"
121  ,"reco sigE , eta=1.75"
122  }
123 
124  int j;
125 
126  {int j; for(j=0;j<ng;j++) hg[j]=0; }
127 
128  int kk=0;
129  for(j=0;j<ng;j++) {
130  int i=j; // tmp
131  TGraphErrors *gr=new TGraphErrors();
132  hg[kk]=gr;
133  gr->SetMarkerStyle(28);
134  gr->SetMarkerColor(kGreen);
135  gr->SetName(name[i]);
136  int icol=kBlue, isym=28;
137  if(j%2==0 )isym=25;
138  if(j%2==1 )isym=24;
139 
140  if(j%2==0) icol=kRed;
141  if(j%2==1) icol=kGreen;
142 
143  gr->SetMarkerStyle(isym);
144  gr->SetMarkerColor(icol);
145  gr->SetLineColor(icol);
146  kk++;
147  }
148  printf("Initialized %d Graphs\n",kk);
149  return kk;
150 }
151 
152 
153 //------------------------------------------------
154 //------------------------------------------------
155 //------------------------------------------------
156 
157 
158 hgDrawE(TGraphErrors **hg, int pid, char *name) { //type of particles, histo name
159  char *pname[]={"gamma","xx","electron","xx","xx","muon","xx","xx","pion-","xx","xx","xx","xx","proton"};
160 
161  TGraphErrors *gr=0;
162  gr=hg[0];
163  gr->Draw("AP");
164  TString titHead;
165 
166  if(pid>4 && strstr(name,"deT+S")){
167  titHead="mean #pm RMS E_{TOWER+SMD} (GeV)";
168  gr->SetMinimum( -0.2);
169  }
170  if(pid>4 && strstr(name,"deTw")){
171  titHead="mean #pm RMS E_{TOWER only} (GeV)";
172  gr->SetMinimum( -0.2);
173  }
174 
175  if(pid<4 && strstr(name,"deT+S")) {
176  gr->SetMaximum( 0.054); gr->SetMinimum( 0.048);
177  titHead="Gauss E_{REC}/E_{INC} #pm #sigma/E_{INC} for TOWER+SMD ";
178  }
179  if(pid<4 && strstr(name,"deTw")) {
180  gr->SetMaximum( 0.042); gr->SetMinimum( 0.037);
181  titHead="Gauss E_{REC}/E_{INC} #pm #sigma/E_{INC} for TOWER only ";
182  }
183 
184  gPad->SetLogx();
185  gr->GetXaxis()->SetLimits(0.7,170.);
186  gr->GetXaxis()->SetTitle("Incident Energy (GeV)");
187 
188  char tit[1000];
189  sprintf(tit," %s; PID=%d\n",titHead.Data(),pid);
190  gr->SetTitle(tit);
191  hg[1]->Draw("P");
192 
193  lg=new TLegend(0.3,0.65,0.55,0.8);
194  TString head="Incident ";
195  head+=pname[pid-1];
196  lg->SetHeader(head);
197  lg->AddEntry(hg[0]," #eta=1.20","LP");
198  lg->AddEntry(hg[1]," #eta=1.75","LP");
199  lg->Draw();
200 
201 
202 
203 }
204 
205 
206 
207 
208 hgDrawSE(TGraphErrors **hg, int pid, char *name) { //type of particles
209  char *pname[]={"gamma","xx","electron","xx","xx","muon","xx","xx","pion-","xx","xx","xx","xx","proton"};
210 
211  TGraphErrors *gr=0;
212  gr=hg[0];
213  gr->Draw("AP");
214  gr->Fit("pol1");
215 
216  TString titHead;
217  if(strstr(name,"deT+S")) titHead=" #sigma/ E_{INC} for TOWER+SMD";
218  if(strstr(name,"deTw")) titHead=" #sigma/ E_{INC} for TOWER only";
219 
220  gr->SetMinimum( 0.0);
221 
222  if(pid>4){
223  gr->SetMaximum( 0.004);
224  }
225 
226  if(pid<4){
227  gr->SetMaximum( 0.01);
228  }
229 
230  gr->GetXaxis()->SetTitle("1 / #sqrt{E_{INC}/GeV}");
231 
232  char tit[1000];
233  sprintf(tit,"Gauss %s; PID=%d\n",titHead.Data(),pid);
234  gr->SetTitle(tit);
235 
236 
237  hg[1]->Draw("P");
238 
239  lg=new TLegend(0.6,0.15,0.85,0.3);
240  TString head="Incident ";
241  head+=pname[pid-1];
242  lg->SetHeader(head);
243  lg->AddEntry(hg[0]," #eta=1.20 +FIT","LP");
244  lg->AddEntry(hg[1]," #eta=1.75","LP");
245  lg->Draw();
246 
247 
248 
249 }
250 
251 
252