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