]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/TestAnalisys.C
CMake: Install missing headers for AliPythia6
[u/mrichter/AliRoot.git] / TPC / TestAnalisys.C
1 /// \file TestAnalisys.C
2 ///
3 /// ~~~{.cxx}
4 /// .L AliGenInfo.C+
5 /// .L TestAnalisys.C+
6 /// AddChains(868);    // AddChains(runNumber);
7 ///  Select();          // make default selection of data
8 ///  MakePictures("pic868");
9 /// ~~~
10
11 #include "TFile.h"
12 #include "TTree.h"
13 #include "TChain.h"
14 #include "TString.h"
15 #include "TLegend.h"
16 #include "TStyle.h"
17 #include "TCut.h"
18 #include "TF1.h"
19 #include "TProfile.h"
20 #include "TProfile2D.h"
21 #include "TH1F.h"
22 #include "TH2F.h"
23 #include "TPad.h"
24 #include "TCanvas.h"
25 #include "TSystem.h"
26 #include "TParticle.h"
27 #include "TRandom.h"
28 #include "TEventList.h"
29
30 #include "AliTrackReference.h"
31 #include "AliTPCParam.h"
32 #include "AliDetector.h"
33 #include "AliStack.h" 
34 #include "AliGenInfo.h"
35
36
37
38
39
40
41 void Select();                // make default selection 
42 void SelectLaser();           // make default selection  for laser tracks
43
44 void AddChains(Int_t run);    // add all the trees with selected run number to the chain
45 void MakePictures(char *dirname);           // make default pictures
46
47 void PRFYZ(TCut cut0, TCut cut1,  char * description);  
48 void PRFZZ(TCut cut0, TCut cut1,  char * description);  
49 void P5Z(TCut cut0, TCut cut1,  char * description);  
50 void P3Z(TCut cut0, TCut cut1,  char * description);  
51 void ResYZ(TCut cut0, TCut cut1,  char * description);
52 void SysYX(TCut cut0,  char * description);
53 void SysZX(TCut cut0,  char * description);
54
55 TProfile * ProfileMaxRow(TCut cut0, char *name, Int_t max);
56 TProfile * ProfileMaxPhi(TCut cut0, char *name, Int_t max);
57 TProfile * ProfileMaxZ(TCut cut0, char *name, Int_t max);
58 TProfile * ProfileQRow(TCut cut0, char *name, Int_t max);
59 TProfile * ProfileQPhi(TCut cut0, char *name, Int_t max);
60 TProfile * ProfileQZ(TCut cut0, char *name, Int_t max);
61 TCanvas *  NoiseSector(TCut cut0,  char * description, Int_t maxrow, Int_t maxpad);
62
63 //
64 // global variables
65 //
66 TChain chaincl("Tracks","Tracks");   // tpc tracks and clusters
67 TChain chaincl2("Tracks","Tracks");   // tpc tracks and clusters
68 TChain chainSignal("SignalB","SignalB");   // signals over threshold 50
69
70 TChain chainFit("Fit","Fit");        // fitted signals with fit parameters
71 TChain chainPed("Fit","Fit");        // fitted pedestal with noise
72 TString runDesc="Run ";              // run descriptor
73 //
74 AliComparisonDraw comp;
75 AliComparisonDraw compCl;
76 AliComparisonDraw compF;
77 AliComparisonDraw compP;
78 //
79 //
80 // selection of data for analysis
81 //
82 TEventList * listTracks    = new TEventList("listTracks","listTracks");
83 TEventList * listFitS      = new TEventList("listFitS","listFitS");
84 TEventList * listFitPed    = new TEventList("listFitPed","listFitPed");
85
86
87
88
89 void MakePictures(char *dirname){
90   //
91   //
92   //
93   // Define Uli Style
94   gROOT->SetStyle("Plain");
95   gStyle->SetFillColor(10);
96   gStyle->SetPadColor(10);
97   gStyle->SetCanvasColor(10);
98   gStyle->SetStatColor(10);
99   
100   gStyle->SetPalette(1,0);
101   gStyle->SetNumberContours(50);
102   //
103   const Int_t kMinCl = 200;
104   char chshell[100];
105   sprintf(chshell,"mkdir %s", dirname);
106   gSystem->Exec(chshell); 
107   sprintf(chshell,"cd %s", dirname);
108   gSystem->Exec(chshell);
109   //
110   //
111   //
112   TCanvas c(dirname,dirname);
113   for (Int_t isector=0; isector<36; isector++){
114     char chcut1[100];
115     char chcut2[100];
116     char chdesc[100];
117     TProfile * prof;
118     sprintf(chshell,"Cl.fX>0&&Cl.fDetector==%d",isector);
119     Int_t ncl = comp.fTree->Draw("Cl.fY",chshell);
120     if (ncl<kMinCl) continue;
121     printf("MakePictures sector %d\n",isector);
122     //
123     // charge pictures
124     //
125     //
126     // charge row
127     //
128     c.cd();
129     sprintf(chdesc,"%s Sector %d IROC",runDesc.Data(), isector);
130     sprintf(chcut1,"Cl.fDetector==%d", isector);
131     prof = ProfileQRow(chcut1, chdesc, 70);
132     sprintf(chshell,"%s/qrow_sec%dIROC.eps", dirname,isector);
133     prof->Draw();
134     c.Update();
135     c.Print(chshell);
136     prof = ProfileMaxRow(chcut1, chdesc, 70);
137     sprintf(chshell,"%s/maxrow_sec%dIROC.eps", dirname,isector);
138     prof->Draw();
139     c.Update();
140     c.Print(chshell);
141     //
142     sprintf(chdesc,"%s Sector %d OROC",runDesc.Data(), isector);
143     sprintf(chcut1,"Cl.fDetector==%d", isector+36);
144     prof = ProfileQRow(chcut1, chdesc, 100);
145     sprintf(chshell,"%s/qrow_sec%dOROC.eps", dirname,isector);
146     prof->Draw();
147     c.Update();
148     c.Print(chshell);
149     prof = ProfileMaxRow(chcut1, chdesc, 100);
150     sprintf(chshell,"%s/maxrow_sec%dOROC.eps", dirname,isector);
151     prof->Draw();
152     c.Update();
153     c.Print(chshell);
154     //
155     // charge phi
156     //
157     sprintf(chdesc,"%s Sector %d IROC",runDesc.Data(), isector);
158     sprintf(chcut1,"Cl.fDetector==%d", isector);
159     prof = ProfileMaxPhi(chcut1, chdesc,20);
160     sprintf(chshell,"%s/qphi_sec%dIROC.eps", dirname,isector);
161     prof->Draw();
162     c.Update();
163     c.Print(chshell);
164     //
165     sprintf(chdesc,"%s Sector %d OROC",runDesc.Data(), isector);
166     sprintf(chcut1,"Cl.fDetector==%d", isector+36);
167     prof = ProfileMaxPhi(chcut1, chdesc,20);
168     sprintf(chshell,"%s/qphi_sec%dOROC.eps", dirname,isector);
169     prof->Draw();
170     c.Update();
171     c.Print(chshell);
172     //
173     //   charge z
174     //
175     c.cd();
176     sprintf(chdesc,"%s Sector %d IROC",runDesc.Data(), isector);
177     sprintf(chcut1,"Cl.fDetector==%d", isector);
178     prof = ProfileQZ(chcut1, chdesc,20);
179     sprintf(chshell,"%s/qz_sec%dIROC.eps", dirname,isector);
180     //    prof->Draw();
181     c.Update();
182     c.Print(chshell);
183     //
184     c.cd();
185     sprintf(chdesc,"%s Sector %d OROC",runDesc.Data(), isector);
186     sprintf(chcut1,"Cl.fDetector==%d", isector+36);
187     prof = ProfileQZ(chcut1, chdesc,20);
188     sprintf(chshell,"%s/qz_sec%dOROC.eps", dirname,isector);
189     //prof->Draw();
190     c.Update();
191     c.Print(chshell);
192     //
193     // Picture noise
194     //
195     sprintf(chdesc,"%s Sector %d IROC",runDesc.Data(), isector);
196     sprintf(chcut1,"Sector==%d", isector);
197     TCanvas *cnoise = NoiseSector(chcut1, chdesc,70,70);
198     sprintf(chshell,"%s/noise_sec%dIROC.eps", dirname,isector);
199     cnoise->Print(chshell);
200     sprintf(chdesc,"%s Sector %d OROC",runDesc.Data(), isector);
201     sprintf(chcut1,"Sector==%d", isector+36);
202     cnoise = NoiseSector(chcut1, chdesc,70,70);
203     sprintf(chshell,"%s/noise_sec%dOROC.eps", dirname,isector);
204     cnoise->Print(chshell);
205     //
206     // systematic
207     //
208     c.cd();
209     sprintf(chdesc,"%s Sector %d",runDesc.Data(), isector);
210     sprintf(chcut1,"Cl.fDetector==%d||Cl.fDetector==%d", isector, isector+36);
211     SysYX(chcut1,chdesc);
212     sprintf(chshell,"%s/deltayx_sec%d.eps", dirname,isector);
213     c.Print(chshell);
214     c.cd();
215     SysZX(chcut1,chdesc);
216     sprintf(chshell,"%s/deltazx_sec%d.eps", dirname,isector);
217     c.Print(chshell);
218     
219     //
220     // picture prf
221     //  
222     if (ncl<500) continue;  //not enough statistic
223     //
224     sprintf(chdesc,"%s Sector %d",runDesc.Data(), isector);
225     sprintf(chcut1,"Cl.fDetector==%d", isector);
226     sprintf(chcut2,"Cl.fDetector==%d", isector+36);
227     c.cd();
228     PRFYZ(chcut1, chcut2,chdesc);
229     sprintf(chshell,"%s/prfyz_sec%d.eps", dirname,isector);
230     c.Print(chshell);
231     sprintf(chcut1,"Sector==%d", isector);
232     sprintf(chcut2,"Sector==%d", isector+36);
233     PRFZZ(chcut1, chcut2,chdesc);
234     sprintf(chshell,"%s/prfzz_sec%d.eps", dirname,isector);
235     c.Print(chshell);
236     //
237     // y resolution
238     //
239     sprintf(chdesc,"%s Sector %d",runDesc.Data(), isector);
240     sprintf(chcut1,"Cl.fDetector==%d", isector);
241     sprintf(chcut2,"Cl.fDetector==%d", isector+36);
242     c.cd();
243     ResYZ(chcut1, chcut2,chdesc);
244     sprintf(chshell,"%s/resyz_sec%d.eps", dirname,isector);
245     c.Print(chshell);
246     //
247   }
248 }
249
250
251
252
253
254
255 void AddChains(Int_t run){
256   //
257   // add files to the chains + check consistency
258   //
259   ifstream in0;
260   ifstream in1;
261   ifstream in2;
262   ifstream in3;
263   ifstream in4;
264   TString sfile;
265   char strcl[100];
266   runDesc+=run;
267   // TPC tracks
268   //
269   sprintf(strcl,"ls  *%d*/TPCtracks.root > files.txt", run);
270   gSystem->Exec(strcl);
271   in0.open("files.txt");
272   for (;in0>>sfile;){
273     if (sfile.Length()==0) break;
274     printf("%s\n",sfile.Data());
275     TFile f(sfile.Data());
276     TTree * tree = (TTree*)f.Get("Tracks");
277     if (tree){      
278       f.Close();
279       chaincl.Add(sfile.Data());
280     }
281   }
282   //
283   // Fitted signals
284   sprintf(strcl,"ls  *%d*/FitSignal.root > files.txt", run);
285   gSystem->Exec(strcl);
286   in1.open("files.txt");
287   for (;in1>>sfile;){
288     if (sfile.Length()==0) break;
289     printf("%s\n",sfile.Data()); 
290     TFile f(sfile.Data());
291     TTree * tree =(TTree*)f.Get("Fit");
292     if (tree){      
293       f.Close();
294       chainFit.Add(sfile.Data());
295     }
296   }
297   //
298   // Fitted pedestal
299   sprintf(strcl,"ls  *%d*/TPCsignal.root > files.txt", run);
300   gSystem->Exec(strcl);
301   in2.open("files.txt");
302   for (;in2>>sfile;){
303     if (sfile.Length()==0) break;
304     printf("%s\n",sfile.Data());
305     TFile f(sfile.Data());
306     TTree * tree =(TTree*)f.Get("Fit");
307     if (tree){      
308       f.Close();
309       chainPed.Add(sfile.Data());
310     }
311     //    chainPed.Add(sfile.Data());
312   }
313   //
314   // Random signals
315   sprintf(strcl,"ls  *%d*/TPCsignal.root > files.txt", run);
316   gSystem->Exec(strcl);
317   in4.open("files.txt");
318   for (;in4>>sfile;){
319     if (sfile.Length()==0) break;
320     printf("%s\n",sfile.Data());
321     TFile f(sfile.Data());
322     TTree * tree =(TTree*)f.Get("SignalB");
323     if (tree){      
324       f.Close();
325       chainSignal.Add(sfile.Data());
326     }
327     //    chainPed.Add(sfile.Data());
328   }
329   //
330   // Rec points trees
331   //
332   printf("\n IMPORT REC points");
333   sprintf(strcl,"ls  *%d*/*RecPoints* > files.txt", run);
334   gSystem->Exec(strcl);
335   in3.open("files.txt");
336   for (;in3>>sfile;){
337     if (sfile.Length()==0) break;
338     printf("%s\n",sfile.Data());    
339     TFile fcl(sfile.Data());
340     char tname[100];
341     sprintf(tname,"%s/%s/TreeR",sfile.Data(),fcl.GetListOfKeys()->At(0)->GetName());
342     chaincl2.Add(tname);
343     //    chainPed.Add(sfile.Data());
344   }
345
346   comp.fTree = &chaincl;
347   compF.fTree = &chainFit;
348   compP.fTree = &chainPed;
349 }
350
351 void Select(){
352   //
353   // base cut on the tracks
354   //
355   comp.fTree->Draw(">>listTracks","Etrack.fTPCncls>30&&abs(Etrack.fIp.fP[4])<1");
356   comp.fTree->SetEventList(listTracks);
357   //
358   compF.fTree->Draw(">>listFitS","p2>0&&p2<5&&p1<900&&p0<10000&&p4<1&&p4>0&&p5<p3&&chi2<150");
359   compF.fTree->SetEventList(listFitS);
360 }
361
362 void SelectLaser(){
363   //
364   // base cut on the tracks
365   //
366   comp.fTree->Draw(">>listTracks","Etrack.fTPCncls>20&&abs(Etrack.fIp.fP[4])<1&&abs(Etrack.fIp.fP[3])<0.01");
367   comp.fTree->SetEventList(listTracks);
368   //
369   compF.fTree->Draw(">>listFitS","p2>0&&p2<5&&p1<900&&p0<10000&&p4<1&&p4>0&&p5<p3&&chi2<150");
370   compF.fTree->SetEventList(listFitS);
371   //
372   // make default aliases
373   //
374   //  laser z beam
375   comp.fTree->SetAlias("lz0","abs(Etrack.fIp.fP[1]-20)<5");
376   comp.fTree->SetAlias("lz1","abs(Etrack.fIp.fP[1]-70)<20");
377   comp.fTree->SetAlias("lz2","abs(Etrack.fIp.fP[1]-150)<20");
378   comp.fTree->SetAlias("lz3","abs(Etrack.fIp.fP[1]-210)<20");
379
380 }
381
382
383
384 void PRFYZ(TCut cut0, TCut cut1,  char * description){
385   //
386   // plot Pad response function as funtion of drift z
387   //
388   //
389   TF1 * f1 = new TF1("fdiff","sqrt([0]*[0]+(250-x)*[1]*[1])");
390   f1->SetParameter(1,0.2);
391   f1->SetParameter(0,0.2);
392   comp.DrawXY("abs(Cl.fZ)","sqrt(Cl.fSigmaY2)","abs(Track.fTrackPoints.GetAngleY())<0.05","Track.fTrackPoints.fTX>0"+cut0,5,10,240,-0,1);
393   TH1F * prfInnerY = (TH1F*)comp.fMean->Clone();
394
395   comp.DrawXY("abs(Cl.fZ)","sqrt(Cl.fSigmaY2)","abs(Track.fTrackPoints.GetAngleY())<0.05","Track.fTrackPoints.fTX>0"+cut1,5,10,240,-0,1);
396   TH1F * prfOuterY = (TH1F*)comp.fMean->Clone();
397   //
398   //
399   prfOuterY->SetMinimum(0);
400   prfOuterY->SetMarkerStyle(23);
401   prfInnerY->SetMarkerStyle(24);
402   prfOuterY->SetXTitle("Z position (cm)");
403   prfOuterY->SetYTitle("PRF width (cm)");
404   char chouter[100];
405   char chinner[100];
406   prfOuterY->Fit(f1);
407   sprintf(chouter,"Outer sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
408   prfInnerY->Fit(f1);
409   sprintf(chinner,"Inner sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
410   prfOuterY->Draw();
411   prfInnerY->Draw("same");
412   TString desc = description;
413   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, desc+"\nTPC cluster shape Fit: #sigma = #sqrt{p_{0}^{2}+(z_{d}-z)p_{1}^{2}}");
414   legend->SetBorderSize(1);
415   legend->AddEntry(prfOuterY,chouter);
416   legend->AddEntry(prfInnerY,chinner);
417   legend->Draw();
418 }
419
420
421
422 void PRFZZ(TCut cut0, TCut cut1,  char * description){
423   TF1 * f1 = new TF1("fdiff","sqrt([0]*[0]+x*[1]*[1])");
424   f1->SetParameter(1,0.2);
425   f1->SetParameter(0,0.2);
426   compF.DrawXY("p1*0.285","p2*0.285","p2>0",cut0,8,20,250,-0,2);
427   TH1F * prfInnerY = (TH1F*)compF.fMean->Clone();
428   compF.DrawXY("p1*0.285","p2*0.285","p2>0",cut1,8,20,250,-0,2);
429   TH1F * prfOuterY = (TH1F*)compF.fMean->Clone();
430   //
431   //
432   prfOuterY->SetMinimum(0);
433   prfOuterY->SetMarkerStyle(23);
434   prfInnerY->SetMarkerStyle(24);
435   prfOuterY->SetXTitle("Drift length(cm)");
436   prfOuterY->SetYTitle("Z Sigma (cm)");
437   char chouter[100];
438   char chinner[100];
439   prfOuterY->Fit(f1);
440   sprintf(chouter,"Outer sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
441   prfInnerY->Fit(f1);
442   sprintf(chinner,"Inner sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
443   prfOuterY->Draw();
444   prfInnerY->Draw("same");
445   TString desc = description;
446   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, desc+"TPC signal shape Fit: #sigma = #sqrt{p_{0}^{2}+(z)p_{1}^{2}}");
447   legend->SetBorderSize(1);
448   legend->AddEntry(prfOuterY,chouter);
449   legend->AddEntry(prfInnerY,chinner);
450   legend->Draw();
451 }
452
453
454 void ResYZ(TCut cut0, TCut cut1,  char * description){
455   //
456   // resolution in y coordinate as function of z
457   //
458   TF1 * f1 = new TF1("fdiff","sqrt([0]*[0]+(250-x)*[1]*[1])");
459   f1->SetParameter(1,0.2);
460   f1->SetParameter(0,0.2);
461   comp.DrawXY("abs(Cl.fZ)","Track.fTrackPoints.GetY()-Cl.GetY()","abs(Track.fTrackPoints.GetAngleY())<0.05","Track.fTrackPoints.fTX>0"+cut0,5,10,240,-0.5,0.5);
462   TH1F * prfInnerY = (TH1F*)comp.fRes->Clone();
463
464   comp.DrawXY("abs(Cl.fZ)","Track.fTrackPoints.GetY()-Cl.GetY()","abs(Track.fTrackPoints.GetAngleY())<0.05","Track.fTrackPoints.fTX>0"+cut1,5,10,240,-0.5,0.5);
465   TH1F * prfOuterY = (TH1F*)comp.fRes->Clone();
466   //
467   //
468   prfOuterY->SetMinimum(0);
469   prfOuterY->SetMaximum(0.15);  
470   prfOuterY->SetMarkerStyle(23);
471   prfInnerY->SetMarkerStyle(24);
472   prfOuterY->SetXTitle("Z position (cm)");
473   prfOuterY->SetYTitle("Y resolution (cm)");
474   char chouter[100];
475   char chinner[100];
476   prfOuterY->Fit(f1);
477   sprintf(chouter,"Outer sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
478   prfInnerY->Fit(f1);
479   sprintf(chinner,"Inner sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
480   prfOuterY->Draw();
481   prfInnerY->Draw("same");
482   TString desc = description;
483   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, desc+"TPC cluster resolution: #sigma = #sqrt{p_{0}^{2}+(z_{d}-z)p_{1}^{2}}");
484   legend->SetBorderSize(1);
485   legend->AddEntry(prfOuterY,chouter);
486   legend->AddEntry(prfInnerY,chinner);
487   legend->Draw();
488 }
489
490 void SysYX(TCut cut0,  char * description){
491   //
492   //
493   //
494   TProfile * profA = new TProfile("profY","profY",70,89,250);
495   comp.fTree->Draw("Cl.fY-Track.fTrackPoints.GetY():Track.fTrackPoints.GetX()>>profY","abs(Cl.fY-Track.fTrackPoints.GetY())<1&&Track.fTrackPoints.fTX>10"+cut0,"prof");
496   profA->SetXTitle("Local X (cm)");
497   profA->SetYTitle("Mean #Delta Y (cm)");  
498   TLegend *legend = new TLegend(0.55,0.25,0.85,0.30, description);
499   legend->Draw();
500 }
501
502 void SysZX(TCut cut0,  char * description){
503   //
504   //
505   //
506   TProfile * profA = new TProfile("profZ","profZ",70,89,250);
507   comp.fTree->Draw("abs(Cl.fZ)-abs(Track.fTrackPoints.GetZ()):Track.fTrackPoints.GetX()>>profZ","abs(abs(Cl.fZ)-abs(Track.fTrackPoints.GetZ()))<1&&Track.fTrackPoints.fTX>10"+cut0,"prof");
508   profA->SetXTitle("Local X (cm)");
509   profA->SetYTitle("Mean #Delta Z (cm)");  
510   TLegend *legend = new TLegend(0.55,0.25,0.85,0.30, description);
511   legend->Draw(); 
512 }
513
514 TProfile * ProfileMaxRow(TCut cut0, char *name, Int_t max){ 
515   //
516   // make profile histrogram of amplitudes
517   //
518   TProfile *profA = new TProfile(name,name,max,0,max-1);
519   char expr[100];
520   sprintf(expr,"Cl.fMax:Cl.fRow>>%s",name);
521   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
522   profA->SetXTitle("Pad Row");
523   profA->SetYTitle("Amplitude at maxima (ADC)");
524   return profA;
525 }
526
527 TProfile * ProfileMaxPhi(TCut cut0, char *name, Int_t max){ 
528   //
529   // make profile histrogram of amplitudes
530   //
531   TProfile *profA = new TProfile(name,name,max,-0.14,0.14);
532   char expr[100];
533   sprintf(expr,"Cl.fMax:Cl.fY/Cl.fX>>%s",name);
534   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
535   profA->SetXTitle("Local #phi(rad)");
536   profA->SetYTitle("Amplitude at maxima (ADC)");
537   return profA; 
538 }
539
540 TProfile * ProfileQRow(TCut cut0, char *name, Int_t max){ 
541   //
542   // make profile histrogram of amplitudes
543   //
544   TProfile *profA = new TProfile(name,name,max,0,max-1);
545   char expr[100];
546   sprintf(expr,"Cl.fQ:Cl.fRow>>%s",name);
547   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
548   profA->SetXTitle("Pad Row");
549   profA->SetYTitle("Total charge(ADC)");
550   return profA;
551 }
552
553 TProfile * ProfileQPhi(TCut cut0, char *name, Int_t max){ 
554   //
555   // make profile histrogram of amplitudes
556   //
557   TProfile *profA = new TProfile(name,name,max,-0.14,0.14);
558   char expr[100];
559   sprintf(expr,"Cl.fQ:Cl.fY/Cl.fX>>%s",name);
560   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
561   profA->SetXTitle("Local #phi(rad)");
562   profA->SetYTitle("Total charge (ADC)");
563   return profA;
564 }
565
566 TProfile * ProfileQZ(TCut cut0, char *name, Int_t max){ 
567   //
568   // make profile histrogram of amplitudes
569   // 
570   TF1 * fline = new TF1("fline","[0]+[1]*[0]*(250-x)");
571   TF1 * f1 = new TF1("f1","[0]*exp(-[1]*(250-x))");
572   TProfile *profA = new TProfile(name,name,max,0,250);
573   char expr[100];
574   sprintf(expr,"Cl.fQ:abs(Cl.fZ)>>%s",name);
575   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
576   profA->SetXTitle("Z position (cm)"); 
577   profA->SetYTitle("Amplitude (ADC)");
578   char chc[100];
579   profA->Fit(fline);
580   f1->SetParameter(0,fline->GetParameter(0));
581   f1->SetParameter(1,fline->GetParameter(1));
582   profA->Fit(f1);
583   sprintf(chc,"Exponential fit params: p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
584   printf("%s",chc);
585   TLegend *legend = new TLegend(0.25,0.12,0.85,0.25, chc);
586   legend->Draw();
587   return profA;
588 }
589
590 TProfile * ProfileMaxZ(TCut cut0, char *name, Int_t max){ 
591   //
592   // make profile histrogram of amplitudes
593   // 
594   TF1 * f1 = new TF1("f1","[0]+[1]*[0]*(250-x)");
595   TProfile *profA = new TProfile(name,name,max,0,250);
596   char expr[100];
597   sprintf(expr,"Cl.fMax:abs(Cl.fZ)>>%s",name);
598   comp.fTree->Draw(expr,"abs(Cl.fZ)>0&&Cl.fMax<500"+cut0,"prof");
599   profA->SetXTitle("Z position (cm)"); 
600   profA->SetYTitle("Amplitude at maxima (ADC)");
601   char chc[100];
602   profA->Fit(f1);
603   sprintf(chc,"p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
604   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, chc);
605   legend->Draw();
606   return profA;
607 }
608
609
610 void P3Z(TCut cut0, TCut cut1,  char * description){
611   //
612   // first exponenent as function of z drift
613   //
614   TF1 * f1 = new TF1("fdiff","[0]+[1]/[0]*x");
615   f1->SetParameter(1,0.2);   
616   f1->SetParameter(0,0.2);
617   compF.DrawXY("p1*0.285","p3","Max>250",cut0,5,20,250,-0,2);
618   TH1F * prfInnerY = (TH1F*)compF.fMean->Clone();
619   compF.DrawXY("p1*0.285","p3","Max>250",cut1,5,20,250,-0,2);
620   TH1F * prfOuterY = (TH1F*)compF.fMean->Clone();
621   //
622   //
623   prfOuterY->SetMinimum(0);
624   prfOuterY->SetMaximum(1);
625   prfOuterY->SetMarkerStyle(23);
626   prfInnerY->SetMarkerStyle(24);
627   prfOuterY->SetXTitle("Drift length (cm)");
628   prfOuterY->SetYTitle("Lambda 0 (Time Bin)");
629   char chouter[100];
630   char chinner[100];
631   prfOuterY->Fit(f1);
632   sprintf(chouter,"Outer sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
633   prfInnerY->Fit(f1);
634   sprintf(chinner,"Inner sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
635   prfOuterY->Draw();
636   prfInnerY->Draw("same");
637   TString desc = description;
638   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, desc+"TPC cluster shape fit Parameter Lambda0 - P3:");
639   legend->SetBorderSize(1);
640   legend->AddEntry(prfOuterY,chouter);
641   legend->AddEntry(prfInnerY,chinner);
642   legend->Draw();
643 }
644
645
646 void P5Z(TCut cut0, TCut cut1,  char * description){
647   //
648   // second exponenent as function of z drift
649   //
650   TF1 * f1 = new TF1("fdiff","[0]+[1]/[0]*x");
651   f1->SetParameter(1,0.2);
652   f1->SetParameter(0,0.2);
653   compF.DrawXY("p1*0.285","p5","Max>250",cut0,5,20,250,-0,0.2);
654   TH1F * prfInnerY = (TH1F*)compF.fMean->Clone();
655   compF.DrawXY("p1*0.285","p5","Max>250",cut1,5,20,250,-0,0.2);
656   TH1F * prfOuterY = (TH1F*)compF.fMean->Clone();
657   //
658   //
659   prfOuterY->SetMinimum(0);
660   prfOuterY->SetMaximum(0.15);
661   prfOuterY->SetMarkerStyle(23);
662   prfInnerY->SetMarkerStyle(24);
663   prfOuterY->SetXTitle("Drift length (Time Bin)");
664   prfOuterY->SetYTitle("Lambda1 (Time bin)");
665   char chouter[100];
666   char chinner[100];
667   prfOuterY->Fit(f1);
668   sprintf(chouter,"Outer sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
669   prfInnerY->Fit(f1);
670   sprintf(chinner,"Inner sector : p_{0} = %f  p_{1} = %f",f1->GetParameter(0),f1->GetParameter(1));
671   prfOuterY->Draw();
672   prfInnerY->Draw("same");
673    TString desc = description;
674   TLegend *legend = new TLegend(0.25,0.12,0.85,0.35, desc+"TPC cluster shape fit Parameter Lambda1 - P5");
675   legend->SetBorderSize(1);
676   legend->AddEntry(prfOuterY,chouter);
677   legend->AddEntry(prfInnerY,chinner);
678   legend->Draw();
679 }
680
681 TCanvas *  NoiseSector(TCut cut0,  char * description, Int_t maxrow, Int_t maxpad){
682   //
683   // draw plots of the noise
684   //
685   TCanvas * c = new TCanvas;
686   c->Divide(2,1);
687   c->Draw();
688   c->cd(1);
689   compP.fTree->Draw("GSigma","GSigma<5"+cut0);
690   c->cd(2);
691   Float_t rand  = gRandom->Rndm();
692   char name[100];
693   sprintf(name,"prof%f",rand);
694   TProfile2D * prof= new TProfile2D(name,name,maxrow, 0, maxrow-1, 2*maxpad,-maxpad,maxpad);
695   char expr[100];
696   sprintf(expr,"GSigma:RPad:Row>>%s",name);
697   prof->SetXTitle("Pad row");
698   prof->SetYTitle("Pad number");
699   compP.fTree->Draw(expr,cut0,"profcolz");
700   c->cd(1);
701   TString desc = description;
702   TLegend *legend = new TLegend(0.25,0.30,0.85,0.85, desc+"Noise map");
703   legend->Draw();
704   
705   return c;
706 }
707
708