15ca3904f9524e0f2e47b202d915487a1c38626f
[u/mrichter/AliRoot.git] / TOF / AliTOFPID.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 //_________________________________________________________________________
17 // TTask class for TOF PID.
18 // Use case: start root and execute the following macro
19 /*
20 {
21   // Dynamically link some shared libs
22   if (gClassTable->GetID("AliRun") < 0) {
23     gROOT->LoadMacro("loadlibs.C");
24     loadlibs();
25   }
26   // create an instance of the AliTOFPID class
27   // You have to pass the ntuple and cuts filenames
28  AliTOFPID* tofpid=new AliTOFPID("ntuple.root","cuts.root");
29
30  // option "pp" for pp events (it includes also electron in the analysis)
31  // option "visual" to shows interactively histos
32  // option "asC" or "asEPS" to save canvas in the current dir in .C or .eps format
33
34  // make a choice: uncomment one of these lines
35  // tofpid->Exec("pp","visual","asC");
36  // tofpid->Exec("pp","novisual","asC");
37  // tofpid->Exec("Pb-Pb","visual","asC");
38  // tofpid->Exec("pp","visual","asC");
39  // tofpid->Exec("pp","novisual","asEPS");
40 }
41 */
42 //
43 //
44 //
45 //
46 //
47 //
48 // 
49 //
50 //-- Authors: B. Zagreev , F. Pierella
51 //////////////////////////////////////////////////////////////////////////////
52
53 #include "TStyle.h"
54 #include "TTask.h"
55 #include "TTree.h"
56 #include "TSystem.h"
57 #include "TFile.h"
58 #include "TCanvas.h"
59 #include "TPad.h"
60 #include "TText.h"
61 #include "TLine.h"
62 #include "TPaveLabel.h"
63 #include "TPaveText.h"
64 #include "TFile.h"
65 #include <TF1.h>
66 #include <TF2.h>
67 #include "TTask.h"
68 #include "TTree.h"
69 #include "TSystem.h"
70 #include "TROOT.h"
71 #include "TFolder.h"
72 #include "TNtuple.h"
73 #include "TLeaf.h"
74
75 #include "AliConst.h"
76 #include "AliTOFConstants.h"
77 #include "AliTOFPID.h"
78
79 #include <stdlib.h>
80 #include <Riostream.h>
81 #include <Riostream.h>
82
83 ClassImp(AliTOFPID)
84
85 //____________________________________________________________________________ 
86   AliTOFPID::AliTOFPID():TTask("AliTOFPID","") 
87 {
88   // default ctor - set the pointer member vars to zero
89   felectron = 0;
90   fpion     = 0;
91   fkaon     = 0;
92   fproton   = 0;
93   fcut      = 0;
94   fhfile    = 0;
95   fNtuple   = 0;
96   fgen      = 0;
97   foutfileName  = 0;
98 }
99            
100 //____________________________________________________________________________ 
101   AliTOFPID::AliTOFPID(char* headerFile, char *cutsFile, const Option_t* opt):TTask("AliTOFPID","") 
102 {
103   felectron = 0;
104   fpion     = 0;
105   fkaon     = 0;
106   fproton   = 0;
107   fhfile = TFile::Open(headerFile); // connect file with ntuple
108   fcut = TFile::Open(cutsFile); // connect file for cuts
109   foutfileName=headerFile;
110   fNtuple   = 0;
111   fgen      = 0;
112
113   Init(opt);
114   // add Task to //root/Tasks folder
115   TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; 
116   roottasks->Add(this) ; 
117 }
118 //____________________________________________________________________________ 
119 void AliTOFPID::Init(const Option_t* opt)
120 {
121   if(strstr(opt,"pp")){ 
122     if(fcut->GetKey("electron")) felectron = (TCutG*)fcut->Get("electron");
123     fcut->Print();
124     if(fcut->GetKey("pion")) fpion = (TCutG*)fcut->Get("pion");
125     fcut->Print();
126   }
127   if(fcut->GetKey("kaon")) fkaon = (TCutG*)fcut->Get("kaon");
128   fcut->Print();
129   if(fcut->GetKey("proton")) fproton = (TCutG*)fcut->Get("proton");
130
131   gFile->ls();
132   fNtuple= (TNtuple*)fhfile->Get("Ntuple"); // get ntuple from file
133   Int_t nvar = fNtuple->GetNvar(); cout <<"N of var.="<< nvar << endl;
134   fNtuple->GetEvent(0);
135
136 }
137
138 //____________________________________________________________________________ 
139   AliTOFPID::~AliTOFPID()
140 {
141   //
142   // dtor (free used memory)
143   //
144
145   if (felectron)
146     {
147       delete felectron;
148       felectron = 0;
149     }
150
151   if (fpion)
152     {
153       delete fpion;
154       fpion = 0;
155     }
156
157   if (fkaon)
158     {
159       delete fkaon;
160       fkaon = 0;
161     }
162
163   if (fproton)
164     {
165       delete fproton;
166       fproton = 0;
167     }
168
169   if (fcut)
170     {
171       delete fcut;
172       fcut = 0;
173     }
174
175
176   if (fhfile)
177     {
178       delete fhfile;
179       fhfile = 0;
180     }
181
182
183   if (fNtuple)
184     {
185       delete fNtuple;
186       fNtuple = 0;
187     }
188
189   if (fgen)
190     {
191       delete fgen;
192       fgen = 0;
193     }
194
195   if (foutfileName)
196     {
197       delete foutfileName;
198       foutfileName = 0;
199     }
200 }
201
202
203 //____________________________________________________________________________
204 void AliTOFPID::Exec(const Option_t *eventType, const Option_t *outputmode, const Option_t *outputsavemode) 
205
206   //
207   // Performs PID for TOF detector
208   // 
209
210   fTask=1;
211   TAxis *xaxis;
212   ////////// Create histograms /////////////////
213   // for electron only in pp case
214   TH1F* eleff=0;
215   TH1F* eleffls=0;
216   TH1F *elcon=0;
217   TH1F *elid=0;
218   TH1F *elmatch=0;
219   TH1F *elall=0;
220
221   if(strstr(eventType,"pp")){
222     eleff = new TH1F("eleff","",10,0,0.6);
223     xaxis=eleff->GetYaxis();
224     xaxis->SetLabelSize(.08);
225     eleffls = new TH1F("eleffls","",10,0,0.6);
226     xaxis=eleffls->GetYaxis();
227     xaxis->SetLabelSize(.08);
228     elcon = new TH1F("elcon","",10,0,0.6);
229     xaxis=elcon->GetXaxis();
230     xaxis->SetLabelSize(.09);
231     xaxis=elcon->GetYaxis();
232     xaxis->SetLabelSize(.08);
233     elid = new TH1F("elid","Identified electrons",10,0,0.6);
234     elmatch = new TH1F("elmatch","N(e)",10,0,0.6);
235     elall = new TH1F("elall","Electrons",10,0,0.6);
236   }
237
238   // pions
239   TH1F *pit  = new TH1F("pit","",15,0,2.5); //part. with tracks
240   TH1F *pig  = new TH1F("pig","",15,0,2.5); //part. in geometry acceptance
241   TH1F *pieff = new TH1F("pieff","",15,0,2.5); //efficiency
242   TH1F *pieffls = new TH1F("pieffls","",15,0,2.5); //efficiency (last step)
243   xaxis=pieff->GetYaxis();
244   xaxis->SetLabelSize(.08);
245   xaxis=pieffls->GetYaxis();
246   xaxis->SetLabelSize(.08);
247   TH1F *picon = new TH1F("picon","",15,0,2.5); //contamination
248   xaxis=picon->GetXaxis();
249   xaxis->SetLabelSize(.09);
250   xaxis=picon->GetYaxis();
251   xaxis->SetLabelSize(.08);
252   TH1F *piid  = new TH1F("piid","Identified pions",15,0,2.5);
253   TH1F *piall = new TH1F("piall","Pions",15,0,2.5);
254   TH1F *pimatch = new TH1F("pimatch","N(Pions)",15,0,2.5);
255   TH1F *pigen = new TH1F("pigen","Pions",15,0,2.5);
256   xaxis=pigen->GetXaxis();
257   xaxis->SetLabelSize(.09);
258   pigen->SetXTitle("P?t! (GeV/c)");
259   xaxis->SetTitleSize(.09);
260   xaxis=pigen->GetYaxis();
261   xaxis->SetLabelSize(.08);
262   //pigen->SetYTitle("1/P?t!dN/dP?t! (GeV/c)^-2!");
263   xaxis->SetTitleSize(.09);
264
265   // kaons
266   TH1F *kat  = new TH1F("kat","",15,0,2.5);
267   TH1F *kag  = new TH1F("kag","",15,0,2.5);
268   TH1F *kaeff = new TH1F("kaeff","",15,0,2.5);
269   xaxis=kaeff->GetYaxis();
270   xaxis->SetLabelSize(.08);
271   TH1F *kaeffls = new TH1F("kaeffls","",15,0,2.5);
272   xaxis=kaeffls->GetYaxis();
273   xaxis->SetLabelSize(.08);
274   TH1F *kacon = new TH1F("kacon","",15,0,2.5);
275   xaxis=kacon->GetXaxis();
276   xaxis->SetLabelSize(.09);
277   xaxis=kacon->GetYaxis();
278   xaxis->SetLabelSize(.08);
279   TH1F *kaid  = new TH1F("kaid","Identified kaons",15,0,2.5);
280   TH1F *kamatch  = new TH1F("kamatch","N(K)",15,0,2.5);
281   TH1F *kaall = new TH1F("kaall","Kaons",15,0,2.5);
282   TH1F *kagen = new TH1F("kagen","Kaons",15,0,2.5);
283   xaxis=kagen->GetXaxis();
284   xaxis->SetLabelSize(.09);
285   kagen->SetXTitle("P?t! (GeV/c)");
286   xaxis->SetTitleSize(.09);
287   xaxis=kagen->GetYaxis();
288   xaxis->SetLabelSize(.08);
289   //kagen->SetYTitle("1/P?t!dN/dP?t! (GeV/c)^-2!");
290   xaxis->SetTitleSize(.09);
291
292   // protons
293   TH1F *prt  = new TH1F("prt","",15,0,4.4);
294   TH1F *prg  = new TH1F("prg","",15,0,4.4);
295   TH1F *preff = new TH1F("preff","",15,0,4.4);
296   xaxis=preff->GetYaxis();
297   xaxis->SetLabelSize(.08);
298   TH1F *preffls = new TH1F("preffls","",15,0,4.4);
299   xaxis=preffls->GetYaxis();
300   xaxis->SetLabelSize(.08);
301   TH1F *prcon = new TH1F("prcon","",15,0,4.4);
302   xaxis=prcon->GetXaxis();
303   xaxis->SetLabelSize(.09);
304   xaxis=prcon->GetYaxis();
305   xaxis->SetLabelSize(.08);
306   TH1F *prid  = new TH1F("prid","Identified protons",15,0,4.4);
307   TH1F *prmatch  = new TH1F("prmatch","N(p)",15,0,4.4);
308   TH1F *prall = new TH1F("prall","Protons",15,0,4.4);
309   TH1F *prgen = new TH1F("prgen","Protons",15,0,4.4);
310   xaxis=prgen->GetXaxis();
311   xaxis->SetLabelSize(.09);
312   prgen->SetXTitle("P?t! (GeV/c)");
313   xaxis->SetTitleSize(.09);
314   xaxis=prgen->GetYaxis();
315   xaxis->SetLabelSize(.08);
316   //prgen->SetYTitle("1/P?t!dN/dP?t! (GeV/c)^-2!");
317   xaxis->SetTitleSize(.09);
318
319   // 2-D histos (extrapolated mass vs momentum)
320   TH2F* hel=0;
321   if(strstr(eventType,"pp")){
322     hel = new TH2F("hel","",1000,-.2,1.2,1000,-4.2,0.);
323     hel->SetXTitle("Mass (GeV/c^{2})");
324     hel->SetYTitle("Momentum (GeV/c)");
325   }
326   TH2F *hpi = new TH2F("hpi","",1000,-.2,1.2,1000,-4.2,0.);
327   hpi->SetXTitle("Mass (GeV/c^{2})");
328   hpi->SetYTitle("Momentum (GeV/c)");
329   TH2F *hka = new TH2F("hka","",1000,-.2,1.2,1000,-4.2,0.);
330   hka->SetXTitle("Mass (GeV/c^{2})");
331   hka->SetYTitle("Momentum (GeV/c)");
332   TH2F *hpr = new TH2F("hpr","",1000,-.2,1.2,1000,-4.2,0.);
333   hpr->SetXTitle("Mass (GeV/c^{2})");
334   hpr->SetYTitle("Momentum (GeV/c)");
335   
336
337   fhfile->cd();
338   Int_t nparticles = (Int_t)fNtuple->GetEntries();
339   cout << " Number of nparticles =" << nparticles << endl;
340   if (nparticles <= 0) return;
341
342   Float_t ka=0, pi=0, pr=0, kaal=0, pial=0, pral=0;
343   Float_t pitrack=0, pimag=0, pigeom=0;
344   Float_t katrack=0, kamag=0, kageom=0;
345   Float_t prtrack=0, prmag=0, prgeom=0;
346   Float_t pif=0, kaf=0, prf=0, pin=0, kan=0, prn=0;
347   Float_t px, py, pz, x, y, z, mass;
348   Int_t event, matc, imam, pdgcode;
349   Int_t indexOfFile=0, numfile=0;
350   //////// Loop over tracks (particles)///////////////////////
351   
352   for (Int_t i=0; i < nparticles; i++) {
353     fNtuple->GetEvent(i);
354     event=(Int_t)(fNtuple->GetLeaf("event")->GetValue());
355     pdgcode=(Int_t)(fNtuple->GetLeaf("ipart")->GetValue());
356     mass=fNtuple->GetLeaf("mext")->GetValue(0);
357     matc=(Int_t)(fNtuple->GetLeaf("matc")->GetValue(0));
358     imam=(Int_t)(fNtuple->GetLeaf("imam")->GetValue(0));
359     px=fNtuple->GetLeaf("pxvtx")->GetValue(0);
360     py=fNtuple->GetLeaf("pyvtx")->GetValue(0);
361     pz=fNtuple->GetLeaf("pzvtx")->GetValue(0);
362     x=fNtuple->GetLeaf("xvtx")->GetValue(0);
363     y=fNtuple->GetLeaf("yvtx")->GetValue(0);
364     z=fNtuple->GetLeaf("zvtx")->GetValue(0);
365     Float_t pvtx=TMath::Sqrt(px*px+py*py+pz*pz);
366     Float_t ptvtx=TMath::Sqrt(px*px+py*py);
367     Float_t mt=0.;
368     Bool_t isSelected=(imam == 0 && pz !=0 && TMath::ATan(TMath::Abs(ptvtx/pz))>TMath::Pi()*45./180.);
369     Int_t abspdgcode=TMath::Abs(pdgcode);
370     switch(abspdgcode){
371     case 321:
372       if(isSelected && (matc==3 || matc==4)) kamatch->Fill(pvtx);
373       mt=TMath::Sqrt(AliTOFConstants::fgkKaonMass*AliTOFConstants::fgkKaonMass+px*px+py*py);
374       break;
375     case 2212:
376       if(isSelected && (matc==2 || matc==3 || matc==4)) prmatch->Fill(pvtx);
377       mt=TMath::Sqrt(AliTOFConstants::fgkProtonMass*AliTOFConstants::fgkProtonMass+px*px+py*py);
378       break;
379     case 11:
380       if(strstr(eventType,"pp") && (matc==3 || matc==4)) elmatch->Fill(pvtx); //  as in kaon case
381       mt=TMath::Sqrt(AliTOFConstants::fgkElectronMass*AliTOFConstants::fgkElectronMass+px*px+py*py);
382       break;
383     default:
384       if(isSelected && matc>0) pimatch->Fill(pvtx);
385       mt=TMath::Sqrt(AliTOFConstants::fgkPionMass*AliTOFConstants::fgkPionMass+px*px+py*py);
386       break;
387     }
388
389     if (isSelected)
390       {//only primary +/-45  
391         if (fkaon->IsInside(mass,-pvtx) && matc>2) {
392           ka++;
393           if (fTask!=2) kaid->Fill(pvtx); else {kaid->Fill(ptvtx);}
394           if (TMath::Abs(pdgcode)==321) {kaf++; kaeff->Fill(pvtx); kaeffls->Fill(pvtx);} else {kan++; kacon->Fill(pvtx);}
395         } else if (fproton->IsInside(mass,-pvtx) && matc>1) {
396           pr++;
397           if (fTask!=2) prid->Fill(pvtx); else 
398             {prid->Fill(ptvtx);}
399           if (TMath::Abs(pdgcode)==2212) {prf++; preff->Fill(pvtx); preffls->Fill(pvtx);} else {prn++; prcon->Fill(pvtx);}
400         } else  if (strstr(eventType,"pp") && felectron->IsInside(mass,-pvtx) && matc>2) {elid->Fill(pvtx);
401         if (strstr(eventType,"pp") && TMath::Abs(pdgcode)==11) {eleff->Fill(pvtx); eleffls->Fill(pvtx);} else {elcon->Fill(pvtx);}
402         } else if (matc>0) {
403           //||matc==-4&&fpion->IsInside(mass,-pvtx)
404           pi++;
405           if (fTask!=2) piid->Fill(pvtx); else {piid->Fill(ptvtx);}
406           if (TMath::Abs(pdgcode)==211) {pif++; pieff->Fill(pvtx); pieffls->Fill(pvtx);} else {pin++; picon->Fill(pvtx);}
407         }
408
409         //////////////// Normalization histograms ////////////////////
410         if (strstr(eventType,"pp") && TMath::Abs(pdgcode)==11) {
411           if (fTask!=2) elall->Fill(pvtx); else elall->Fill(ptvtx);
412           if (fTask==1) hel->Fill(mass,-pvtx);
413           
414         } else if (TMath::Abs(pdgcode)==211) {
415           pial++;
416           if (matc!=0) {
417             pitrack++; 
418             pit->Fill(pvtx);
419             if (matc!=-1) {
420               pimag++;
421               if (matc>-2 || matc==-4) {
422                 pigeom++;
423                 pig->Fill(pvtx);
424               }
425             }
426           }
427           if (fTask!=2) piall->Fill(pvtx); 
428           else {
429             piall->Fill(ptvtx,1/ptvtx);
430           }
431           if (fTask==1) hpi->Fill(mass,-pvtx); 
432           
433         } else if (TMath::Abs(pdgcode)==321) {
434           kaal++;
435           if (matc!=0) {
436             katrack++;
437             kat->Fill(pvtx);
438             if (matc!=-1) {
439               kamag++;
440               if (matc>-2 || matc==-4) {
441                 kageom++;
442                 kag->Fill(pvtx);
443               }
444             }
445           }
446           if (fTask!=2) kaall->Fill(pvtx); 
447           else {
448             kaall->Fill(ptvtx,1/ptvtx);
449           }
450           if (fTask==1) hka->Fill(mass,-pvtx);
451           
452         } else if (TMath::Abs(pdgcode)==2212) {
453           pral++;
454           if (matc!=0) {
455             prtrack++;
456             prt->Fill(pvtx);
457             if (matc!=-1) {
458               prmag++;
459               if (matc>-2 || matc==-4) {
460                 prgeom++;
461                 prg->Fill(pvtx);
462               }
463             }
464           }
465           if (fTask!=2) prall->Fill(pvtx); 
466           else {
467             prall->Fill(ptvtx,1/ptvtx);
468           }
469           if (fTask==1) hpr->Fill(mass,-pvtx);}
470         
471       }// End of cuts appling
472   }// End of loop over particles
473
474   // display results
475   cout<< "Pions in 45-135 deg.     "<< pial <<" (100%)"<< endl;
476   cout<< "Pions that have track    "<< pitrack/pial*100 <<" %"<<endl;
477   cout<< "Magnetic field           "<< pimag/pial*100 <<" %"<<endl;
478   cout<< "Geometry efficiency      "<< pigeom/pial*100 <<" %"<<endl;
479   cout<< "PID procedure            "<< pif/pial*100 <<" %"<<endl;
480   cout<< "Contamination            "<< pin/pi*100 <<" %"<<endl;
481   cout<<endl;
482   cout<< "Kaons in 45-135 deg.     "<< kaal <<" (100%)"<< endl;
483   cout<< "Kaons that have track    "<< katrack/kaal*100 <<" %"<<endl;
484   cout<< "Magnetic field           "<< kamag/kaal*100 <<" %"<<endl;
485   cout<< "Geometry efficiency      "<< kageom/kaal*100 <<" %"<<endl;
486   cout<< "PID procedure(+decays)   "<< kaf/kaal*100 <<" %"<<endl;
487   cout<< "Contamination            "<< kan/ka*100 <<" %"<<endl;
488   cout<<endl;
489   cout<< "Protons in 45-135 deg.   "<< pral <<" (100%)"<< endl;
490   cout<< "Protons that have track  "<< prtrack/pral*100 <<" %"<<endl;
491   cout<< "Magnetic field           "<< prmag/pral*100 <<" %"<<endl;
492   cout<< "Geometry efficiency      "<< prgeom/pral*100 <<" %"<<endl;
493   cout<< "PID procedure            "<< prf/pral*100 <<" %"<<endl;
494   cout<< "Contamination            "<< prn/pr*100 <<" %"<<endl;
495   cout<<endl;
496   cout<< "All part. in 45-135 deg.  "<< pial+kaal+pral <<" (100%)"<< endl;
497   cout<< "All part. that have track "<< (pitrack+katrack+prtrack)/(pial+kaal+pral)*100 <<" %"<<endl;
498   cout<< "Magnetic field            "<< (pimag+kamag+prmag)/(pial+kaal+pral)*100 <<" %"<<endl;
499   cout<< "Geometry efficiency       "<< (pigeom+kageom+prgeom)/(pial+kaal+pral)*100 <<" %"<<endl;
500   cout<< "PID procedure             "<< (pif+kaf+prf)/(pial+kaal+pral)*100 <<" %"<<endl;
501   cout<< "Contamination             "<< (pin+kan+prn)/(pi+ka+pr)*100 <<" %"<<endl;
502   cout<<endl;
503   
504   TCanvas *pidCanvas=0;   // overall
505   TCanvas *pidCanvasls=0; // last step of PID
506   TCanvas *momvsmassCanvas=0;
507   // overall Efficiency
508   TPad  *tp=0;
509   TPad  *pad1=0;
510   TPad  *pad2=0;
511   TPad  *pad3=0;
512   TPad  *pad4=0;
513   TPad  *pad5=0;
514   TPad  *pad6=0;
515   TPad  *pad7=0;
516   TPad  *pad8=0;
517
518   // last step Efficiency
519   TPad  *tpls=0;
520   TPad  *pad1ls=0;
521   TPad  *pad2ls=0;
522   TPad  *pad3ls=0;
523   TPad  *pad4ls=0;
524   TPad  *pad5ls=0;
525   TPad  *pad6ls=0;
526   TPad  *pad7ls=0;
527   TPad  *pad8ls=0;
528
529   //////////////////////// For fTask 1 ///////////////////////////
530   if (fTask==1) {
531     if (strstr(eventType,"pp")){
532       eleff->Divide(elall);
533       eleffls->Divide(elmatch);
534     }
535     // overall efficiency
536     pieff->Divide(piall);
537     kaeff->Divide(kaall);
538     preff->Divide(prall);
539
540     // last step efficiency
541     pieffls->Divide(pimatch);
542     kaeffls->Divide(kamatch);
543     preffls->Divide(prmatch);
544
545     pit->Divide(piall);
546     kat->Divide(kaall);
547     prt->Divide(prall);
548     pig->Divide(piall);
549     kag->Divide(kaall);
550     prg->Divide(prall);
551     if (strstr(eventType,"pp")){
552       elcon->Divide(elid);
553     }
554     // contamination
555     picon->Divide(piid);
556     kacon->Divide(kaid);
557     prcon->Divide(prid);
558
559     //Create a canvas, set the view range, show histograms
560     // for overall PID
561     if (indexOfFile==0) {
562       // overall Efficiency canvas
563       pidCanvas = new TCanvas("pidCanvas","PID (Overall)",10,100,800,500);
564       pidCanvas->SetBorderMode(0);
565       pidCanvas->SetBorderSize(0);
566       pidCanvas->SetFillColor(0);
567       pidCanvas->SetFillStyle(0);
568
569       // last step Efficiency canvas
570       pidCanvasls = new TCanvas("pidCanvasls","PID (Last Step)",10,100,800,500);
571       pidCanvasls->SetBorderMode(0);
572       pidCanvasls->SetBorderSize(0);
573       pidCanvasls->SetFillColor(0);
574       pidCanvasls->SetFillStyle(0);
575
576       if (strstr(outputmode,"visual")) {
577         pidCanvas->Draw();
578         pidCanvasls->Draw();
579       }
580
581       Float_t pxs=0.25+0.125; //X size of pad
582       Float_t pys=0.5+0.055;  //y size of pad
583       // overall
584       tp   = new TPad("histo","Histograms",.1,.1,.9,.9);
585       // last step
586       tpls = new TPad("histo","Histograms",.1,.1,.9,.9);
587
588       if (strstr(eventType,"Pb-Pb")){
589         // overall efficiency
590         //pad1 = new TPad("pad1","electron efficiency",0.,.5-.055,0.+pxs,.5-.055+pys-.00001,0,0,0);
591         pad2 = new TPad("pad2","pion efficiency",0.,0.5-.055,0.+pxs,0.5-.055+pys-.00001,0,0,0);
592         pad3 = new TPad("pad3","kaon efficiency",0.3,0.5-.055,0.3+pxs,0.5-.055+pys-.00001,0,0,0);
593         pad4 = new TPad("pad4","proton efficiency",0.6,0.5-.055,0.6+pxs,0.5-.055+pys-.00001,0,0,0);
594
595         // contamination
596         //pad5 = new TPad("pad5","electron contamination",0.,0.,0.+pxs,0.+pys,0,0,0);
597         pad6 = new TPad("pad6","pion contamination",0.,0.,0.+pxs,0.+pys,0,0,0);
598         pad7 = new TPad("pad7","kaon contamination",.3,0.,0.3+pxs,0.+pys,0,0,0);
599         pad8 = new TPad("pad8","proton contamination",.6,0.,0.6+pxs,0.+pys,0,0,0);
600
601         // we repeat the same for the last step of PID
602         //pad1ls = new TPad("pad1ls","electron efficiency",0.,.5-.055,0.+pxs,.5-.055+pys-.00001,0,0,0);
603         pad2ls = new TPad("pad2ls","pion efficiency",0.,0.5-.055,0.+pxs,0.5-.055+pys-.00001,0,0,0);
604         pad3ls = new TPad("pad3ls","kaon efficiency",0.3,0.5-.055,0.3+pxs,0.5-.055+pys-.00001,0,0,0);
605         pad4ls = new TPad("pad4ls","proton efficiency",0.6,0.5-.055,0.6+pxs,0.5-.055+pys-.00001,0,0,0);
606
607         // contamination
608         //pad5 = new TPad("pad5","electron contamination",0.,0.,0.+pxs,0.+pys,0,0,0);
609         pad6ls = new TPad("pad6ls","pion contamination",0.,0.,0.+pxs,0.+pys,0,0,0);
610         pad7ls = new TPad("pad7ls","kaon contamination",.3,0.,0.3+pxs,0.+pys,0,0,0);
611         pad8ls = new TPad("pad8ls","proton contamination",.6,0.,0.6+pxs,0.+pys,0,0,0);
612
613       }
614
615       if (strstr(eventType,"pp")){
616         // overall Efficiency
617         pad1 = new TPad("pad1","electron efficiency",0.,.5-.055,0.25+0.045,1.,0,0,0);
618         pad2 = new TPad("pad2","pion efficiency",0.25-0.015,0.5-.055,0.5+0.03,1.,0,0,0);
619         pad3 = new TPad("pad3","kaon efficiency",0.5-0.03,0.5-.055,0.75+0.015,1.,0,0,0);
620         pad4 = new TPad("pad4","proton efficiency",0.75-0.045,0.5-.055,1.,1.,0,0,0);
621
622         // contamination
623         pad5 = new TPad("pad5","electron contamination",0.,0.,.25+.045,.5+.055,0,0,0);
624         pad6 = new TPad("pad6","pion contamination",.25-.015,0.,.5+.03,.5+.055,0,0,0);
625         pad7 = new TPad("pad7","kaon contamination",.5-.03,0.,.75+.015,.5+.055,0,0,0);
626         pad8 = new TPad("pad8","proton contamination",.75-.045,0.,1.,.5+.055,0,0,0);
627
628
629         // we repeat the same for the last step of PID
630         pad1ls = new TPad("pad1ls","electron efficiency",0.,.5-.055,0.25+0.045,1.,0,0,0);
631         pad2ls = new TPad("pad2ls","pion efficiency",0.25-0.015,0.5-.055,0.5+0.03,1.,0,0,0);
632         pad3ls = new TPad("pad3ls","kaon efficiency",0.5-0.03,0.5-.055,0.75+0.015,1.,0,0,0);
633         pad4ls = new TPad("pad4ls","proton efficiency",0.75-0.045,0.5-.055,1.,1.,0,0,0);
634
635         // contamination
636         pad5ls = new TPad("pad5ls","electron contamination",0.,0.,.25+.045,.5+.055,0,0,0);
637         pad6ls = new TPad("pad6ls","pion contamination",.25-.015,0.,.5+.03,.5+.055,0,0,0);
638         pad7ls = new TPad("pad7ls","kaon contamination",.5-.03,0.,.75+.015,.5+.055,0,0,0);
639         pad8ls = new TPad("pad8ls","proton contamination",.75-.045,0.,1.,.5+.055,0,0,0);
640
641
642       }
643
644       // last step of PID
645       gStyle->SetOptStat(0);
646       tpls->SetFillStyle(0);
647       tpls->SetFillColor(0);
648       tpls->SetBorderSize(0);
649       pidCanvasls->cd();
650       TText *text1ls= new TText(.1,.2,"Contamination              Efficiency"); 
651       text1ls->SetTextAngle(90);
652       if (strstr(outputmode,"visual")) text1ls->Draw();
653       //tp->DrawText(.3,.0,"p (GeV/c");
654       pidCanvasls->cd();
655       TText *text2ls= new TText(.8,.0,"p (GeV/c)"); 
656       if (strstr(outputmode,"visual")) {
657         text2ls->Draw();
658         tpls->Draw();
659       }
660
661       // overall
662       gStyle->SetOptStat(0);
663       tp->SetFillStyle(0);
664       tp->SetFillColor(0);
665       tp->SetBorderSize(0);
666       pidCanvas->cd();
667       TText *text1= new TText(.1,.2,"Contamination              Efficiency"); 
668       text1->SetTextAngle(90);
669       if (strstr(outputmode,"visual")) text1->Draw();
670       //tp->DrawText(.3,.0,"p (GeV/c");
671       pidCanvas->cd();
672       TText *text2= new TText(.8,.0,"p (GeV/c)"); 
673       if (strstr(outputmode,"visual")) {
674         text2->Draw();
675         tp->Draw();
676       }
677
678     }
679
680
681     // drawing histos for overall case
682     if (strstr(eventType,"pp")){
683       pad1->SetFillStyle(0);
684       pad1->SetFillColor(10);
685       tp->cd();
686       if (strstr(outputmode,"visual")) pad1->Draw();
687       pad1->cd();
688       //eleff->SetLineWidth(15);
689       eleff->SetLineWidth(3);
690       eleff->SetMaximum(1.);
691       if (indexOfFile==0) {
692         //eleff->SetFillColor(33);
693         //eleff->SetFillColor(30);
694         //eleff->SetFillColor(0);
695         //eleff->SetLineColor(4);
696         eleff->SetLineColor(1);
697         if (strstr(outputmode,"visual")) eleff->Draw();
698       } else {
699         eleff->SetFillStyle(0);
700         eleff->SetFillColor(30);
701         if (indexOfFile==2) {
702           eleff->SetLineColor(3);
703           eleff->SetLineWidth(3);
704         } else {
705           //eleff->SetLineColor(2);
706           eleff->SetLineColor(1);
707           eleff->SetLineStyle(2);}
708         if (strstr(outputmode,"visual")) eleff->Draw("same");
709       }
710       //   eleff->Fit("pol1");
711       TPaveLabel *ellab = new TPaveLabel(.42,.85,.52,1.05,"e");
712       if (strstr(outputmode,"visual")) ellab->Draw();
713     }
714     
715     pad2->SetFillStyle(0);
716     pad2->SetFillColor(10);
717     tp->cd();
718     if (strstr(outputmode,"visual")) pad2->Draw();
719     pad2->cd();
720     pieff->SetLineWidth(3);
721     pieff->SetMaximum(1.);
722     if (indexOfFile==0) {
723       pieff->SetLineColor(1);
724       if (strstr(outputmode,"visual")) pieff->Draw();
725     } else {
726       pieff->SetFillStyle(0);
727       pieff->SetFillColor(30);
728       if (indexOfFile==1) {
729         pieff->SetLineStyle(2);
730       } else if (indexOfFile==2) {
731         pieff->SetLineStyle(3);
732       } else {
733         pieff->SetLineStyle(4);}
734       if (strstr(outputmode,"visual")) pieff->Draw("same");
735     }
736     TPaveLabel *pilab = new TPaveLabel(1.7,.85,2.2,1.05,"#pi");
737     if (strstr(outputmode,"visual")) pilab->Draw();
738     
739     pad3->SetFillStyle(0);
740     pad3->SetFillColor(10);
741     tp->cd();
742     if (strstr(outputmode,"visual")) pad3->Draw();
743     pad3->cd();
744     kaeff->SetLineWidth(3);
745     kaeff->SetMaximum(1.);
746     if (indexOfFile==0) {
747       kaeff->SetLineColor(1);
748       if (strstr(outputmode,"visual")) kaeff->Draw();
749     } else {
750       kaeff->SetFillStyle(0);
751       kaeff->SetFillColor(30);
752       if (indexOfFile==1) { 
753         kaeff->SetLineStyle(2);
754       } else if (indexOfFile==2) {
755         kaeff->SetLineStyle(3);
756       } else {
757         kaeff->SetLineStyle(4);}
758       if (strstr(outputmode,"visual")) kaeff->Draw("same");
759     }
760     TPaveLabel *kalab = new TPaveLabel(1.7,.85,2.2,1.05,"K");
761     if (strstr(outputmode,"visual")) kalab->Draw();
762     
763     pad4->SetFillStyle(0);
764     pad4->SetFillColor(10);
765     tp->cd();
766     if (strstr(outputmode,"visual")) pad4->Draw();
767     pad4->cd();
768     preff->SetLineWidth(3);
769     preff->SetMaximum(1.);
770     if (indexOfFile==0) {
771       preff->SetLineColor(1);
772       if (strstr(outputmode,"visual")) preff->Draw();
773     } else {
774       preff->SetFillStyle(0);
775       preff->SetFillColor(30);
776       if (indexOfFile==1) {
777         preff->SetLineStyle(2);
778       } else if (indexOfFile==2) {
779         preff->SetLineStyle(3);
780       } else {
781         preff->SetLineStyle(4);}
782       if (strstr(outputmode,"visual")) preff->Draw("same");
783     }
784     TPaveLabel *prlab = new TPaveLabel(3.2,.85,4.1,1.05,"p");
785     if (strstr(outputmode,"visual")) prlab->Draw();
786
787     if (strstr(eventType,"pp")){
788       pad5->SetFillStyle(0);
789       pad5->SetFillColor(10);
790       tp->cd();
791       if (strstr(outputmode,"visual")) pad5->Draw();
792       pad5->cd();
793       //elcon->SetLineWidth(5);
794       elcon->SetLineWidth(3);
795       elcon->SetMaximum(1.);
796       if (indexOfFile==0) {
797         //elcon->SetFillColor(33);
798         //elcon->SetFillColor(30);
799         //elcon->SetLineColor(4);
800         elcon->SetLineColor(1);
801         if (strstr(outputmode,"visual")) elcon->Draw();
802       } else {
803         elcon->SetFillStyle(4000);
804         elcon->SetFillColor(30);
805         if (indexOfFile==2) {
806           elcon->SetLineColor(3);
807           elcon->SetLineWidth(3);
808         } else {
809           elcon->SetLineColor(2);
810           elcon->SetLineStyle(2);}
811         if (strstr(outputmode,"visual")) elcon->Draw("same");
812       }
813     }
814
815
816     pad6->SetFillStyle(0);
817     pad6->SetFillColor(10);
818     tp->cd();
819     if (strstr(outputmode,"visual")) pad6->Draw();
820     pad6->cd();
821     picon->SetLineWidth(3);
822     picon->SetMaximum(1.);
823     if (indexOfFile==0) {
824       picon->SetLineColor(1);
825       if (strstr(outputmode,"visual")) picon->Draw();
826     } else {
827       picon->SetFillStyle(0);
828       picon->SetFillColor(30);
829       if (indexOfFile==1) { 
830         picon->SetLineStyle(2);
831       } else if (indexOfFile==2) {
832         picon->SetLineStyle(3);
833       } else {
834         picon->SetLineStyle(4);
835         TLine* line;
836         line = new TLine(0.2,0.85,0.9,0.85);
837         line->SetLineStyle(2);
838         line->SetLineWidth(1);
839         if (strstr(outputmode,"visual")) line->Draw();
840         line = new TLine(0.2,0.65,0.9,0.65);
841         line->SetLineWidth(2);
842         if (strstr(outputmode,"visual")) line->Draw();
843         line = new TLine(0.2,0.45,0.9,0.45);
844         line->SetLineStyle(3);
845         line->SetLineWidth(1);
846         if (strstr(outputmode,"visual")) line->Draw();
847         line = new TLine(0.2,0.25,0.9,0.25);
848         line->SetLineStyle(4);
849         line->SetLineWidth(1);
850         if (strstr(outputmode,"visual")) line->Draw();
851         TPaveLabel *pl = new TPaveLabel(1.1,0.8,1.9,0.9,"100 ps","br");
852         pl->SetFillColor(18);
853         pl->SetTextSize(0.99);
854         if (strstr(outputmode,"visual")) pl->Draw();
855         pl = new TPaveLabel(1.1,0.6,1.9,0.7,"150 ps","br");
856         pl->SetFillColor(18);
857         pl->SetTextSize(0.99);
858         if (strstr(outputmode,"visual")) pl->Draw();
859         pl = new TPaveLabel(1.1,0.4,1.9,0.5,"200 ps","br");
860         pl->SetFillColor(18);
861         pl->SetTextSize(0.99);
862         if (strstr(outputmode,"visual")) pl->Draw();
863         pl = new TPaveLabel(1.1,0.2,1.9,0.3,"300 ps","br");
864         pl->SetFillColor(18);
865         pl->SetTextSize(0.99);
866         if (strstr(outputmode,"visual")) pl->Draw();
867       }
868       if (strstr(outputmode,"visual")) picon->Draw("same");
869     }
870     
871     pad7->SetFillStyle(0);
872     pad7->SetFillColor(10);
873     tp->cd();
874     if (strstr(outputmode,"visual")) pad7->Draw();
875     pad7->cd();
876     kacon->SetLineWidth(3);
877     kacon->SetMaximum(1.);
878     if (indexOfFile==0) {
879       kacon->SetLineColor(1);
880       if (strstr(outputmode,"visual")) kacon->Draw();
881     } else {
882       kacon->SetFillStyle(0);
883       kacon->SetFillColor(30);
884       if (indexOfFile==1) {
885         kacon->SetLineStyle(2);
886       } else if (indexOfFile==2) {
887         kacon->SetLineStyle(3);
888       } else {
889         kacon->SetLineStyle(4);}
890       if (strstr(outputmode,"visual")) kacon->Draw("same");
891     }
892     
893     pad8->SetFillStyle(0);
894     pad8->SetFillColor(10);
895     tp->cd();
896     if (strstr(outputmode,"visual")) pad8->Draw();
897     pad8->cd();
898     prcon->SetLineWidth(3);
899     prcon->SetMaximum(1.);
900     if (indexOfFile==0) {
901       prcon->SetLineColor(1);
902       if (strstr(outputmode,"visual")) prcon->Draw();
903     } else {
904       prcon->SetFillStyle(0);
905       prcon->SetFillColor(30);
906       if (indexOfFile==1) {
907         prcon->SetLineStyle(2);
908       } else if (indexOfFile==2) {
909         prcon->SetLineStyle(3);
910       } else {
911         prcon->SetLineStyle(4);}
912       if (strstr(outputmode,"visual")) prcon->Draw("same");
913     }
914
915
916
917     // last step case (it is just a copy of the previous lines)
918     // moving to pidCanvasls canvas
919     pidCanvasls->cd();
920     // drawing histos for overall case
921     if (strstr(eventType,"pp")){
922       pad1ls->SetFillStyle(0);
923       pad1ls->SetFillColor(10);
924       tpls->cd();
925       if (strstr(outputmode,"visual")) pad1ls->Draw();
926       pad1ls->cd();
927       //eleff->SetLineWidth(15);
928       eleffls->SetLineWidth(3);
929       eleffls->SetMaximum(1.);
930       if (indexOfFile==0) {
931         //eleff->SetFillColor(33);
932         //eleff->SetFillColor(30);
933         //eleff->SetFillColor(0);
934         //eleff->SetLineColor(4);
935         eleffls->SetLineColor(1);
936         if (strstr(outputmode,"visual")) eleffls->Draw();
937       } else {
938         eleffls->SetFillStyle(0);
939         eleffls->SetFillColor(30);
940         if (indexOfFile==2) {
941           eleffls->SetLineColor(3);
942           eleffls->SetLineWidth(3);
943         } else {
944           //eleff->SetLineColor(2);
945           eleffls->SetLineColor(1);
946           eleffls->SetLineStyle(2);}
947         if (strstr(outputmode,"visual")) eleffls->Draw("same");
948       }
949       //   eleff->Fit("pol1");
950       TPaveLabel *ellabls = new TPaveLabel(.42,.85,.52,1.05,"e");
951       if (strstr(outputmode,"visual")) ellabls->Draw();
952     }
953     
954     pad2ls->SetFillStyle(0);
955     pad2ls->SetFillColor(10);
956     tpls->cd();
957     if (strstr(outputmode,"visual")) pad2ls->Draw();
958     pad2ls->cd();
959     pieffls->SetLineWidth(3);
960     pieffls->SetMaximum(1.);
961     if (indexOfFile==0) {
962       pieffls->SetLineColor(1);
963       if (strstr(outputmode,"visual")) pieffls->Draw();
964     } else {
965       pieffls->SetFillStyle(0);
966       pieffls->SetFillColor(30);
967       if (indexOfFile==1) {
968         pieffls->SetLineStyle(2);
969       } else if (indexOfFile==2) {
970         pieffls->SetLineStyle(3);
971       } else {
972         pieffls->SetLineStyle(4);}
973       if (strstr(outputmode,"visual")) pieffls->Draw("same");
974     }
975     TPaveLabel *pilabls = new TPaveLabel(1.7,.85,2.2,1.05,"#pi");
976     if (strstr(outputmode,"visual")) pilabls->Draw();
977     
978     pad3ls->SetFillStyle(0);
979     pad3ls->SetFillColor(10);
980     tpls->cd();
981     if (strstr(outputmode,"visual")) pad3ls->Draw();
982     pad3ls->cd();
983     kaeffls->SetLineWidth(3);
984     kaeffls->SetMaximum(1.);
985     if (indexOfFile==0) {
986       kaeffls->SetLineColor(1);
987       if (strstr(outputmode,"visual")) kaeffls->Draw();
988     } else {
989       kaeffls->SetFillStyle(0);
990       kaeffls->SetFillColor(30);
991       if (indexOfFile==1) { 
992         kaeffls->SetLineStyle(2);
993       } else if (indexOfFile==2) {
994         kaeffls->SetLineStyle(3);
995       } else {
996         kaeffls->SetLineStyle(4);}
997       if (strstr(outputmode,"visual")) kaeffls->Draw("same");
998     }
999     TPaveLabel *kalabls = new TPaveLabel(1.7,.85,2.2,1.05,"K");
1000     if (strstr(outputmode,"visual")) kalabls->Draw();
1001     
1002     pad4ls->SetFillStyle(0);
1003     pad4ls->SetFillColor(10);
1004     tpls->cd();
1005     if (strstr(outputmode,"visual")) pad4ls->Draw();
1006     pad4ls->cd();
1007     preffls->SetLineWidth(3);
1008     preffls->SetMaximum(1.);
1009     if (indexOfFile==0) {
1010       preffls->SetLineColor(1);
1011       if (strstr(outputmode,"visual")) preffls->Draw();
1012     } else {
1013       preffls->SetFillStyle(0);
1014       preffls->SetFillColor(30);
1015       if (indexOfFile==1) {
1016         preffls->SetLineStyle(2);
1017       } else if (indexOfFile==2) {
1018         preffls->SetLineStyle(3);
1019       } else {
1020         preffls->SetLineStyle(4);}
1021       if (strstr(outputmode,"visual")) preffls->Draw("same");
1022     }
1023     TPaveLabel *prlabls = new TPaveLabel(3.2,.85,4.1,1.05,"p");
1024     if (strstr(outputmode,"visual")) prlabls->Draw();
1025
1026     if (strstr(eventType,"pp")){
1027       pad5ls->SetFillStyle(0);
1028       pad5ls->SetFillColor(10);
1029       tpls->cd();
1030       if (strstr(outputmode,"visual")) pad5ls->Draw();
1031       pad5ls->cd();
1032       //elcon->SetLineWidth(5);
1033       elcon->SetLineWidth(3);
1034       elcon->SetMaximum(1.);
1035       if (indexOfFile==0) {
1036         //elcon->SetFillColor(33);
1037         //elcon->SetFillColor(30);
1038         //elcon->SetLineColor(4);
1039         elcon->SetLineColor(1);
1040         if (strstr(outputmode,"visual")) elcon->Draw();
1041       } else {
1042         elcon->SetFillStyle(4000);
1043         elcon->SetFillColor(30);
1044         if (indexOfFile==2) {
1045           elcon->SetLineColor(3);
1046           elcon->SetLineWidth(3);
1047         } else {
1048           elcon->SetLineColor(2);
1049           elcon->SetLineStyle(2);}
1050         if (strstr(outputmode,"visual")) elcon->Draw("same");
1051       }
1052     }
1053
1054
1055     pad6ls->SetFillStyle(0);
1056     pad6ls->SetFillColor(10);
1057     tpls->cd();
1058     if (strstr(outputmode,"visual")) pad6ls->Draw();
1059     pad6ls->cd();
1060     picon->SetLineWidth(3);
1061     picon->SetMaximum(1.);
1062     if (indexOfFile==0) {
1063       picon->SetLineColor(1);
1064       if (strstr(outputmode,"visual")) picon->Draw();
1065     } else {
1066       picon->SetFillStyle(0);
1067       picon->SetFillColor(30);
1068       if (indexOfFile==1) { 
1069         picon->SetLineStyle(2);
1070       } else if (indexOfFile==2) {
1071         picon->SetLineStyle(3);
1072       } else {
1073         picon->SetLineStyle(4);
1074         TLine* line;
1075         line = new TLine(0.2,0.85,0.9,0.85);
1076         line->SetLineStyle(2);
1077         line->SetLineWidth(1);
1078         if (strstr(outputmode,"visual")) line->Draw();
1079         line = new TLine(0.2,0.65,0.9,0.65);
1080         line->SetLineWidth(2);
1081         if (strstr(outputmode,"visual")) line->Draw();
1082         line = new TLine(0.2,0.45,0.9,0.45);
1083         line->SetLineStyle(3);
1084         line->SetLineWidth(1);
1085         if (strstr(outputmode,"visual")) line->Draw();
1086         line = new TLine(0.2,0.25,0.9,0.25);
1087         line->SetLineStyle(4);
1088         line->SetLineWidth(1);
1089         if (strstr(outputmode,"visual")) line->Draw();
1090         TPaveLabel *pl = new TPaveLabel(1.1,0.8,1.9,0.9,"100 ps","br");
1091         pl->SetFillColor(18);
1092         pl->SetTextSize(0.99);
1093         if (strstr(outputmode,"visual")) pl->Draw();
1094         pl = new TPaveLabel(1.1,0.6,1.9,0.7,"150 ps","br");
1095         pl->SetFillColor(18);
1096         pl->SetTextSize(0.99);
1097         if (strstr(outputmode,"visual")) pl->Draw();
1098         pl = new TPaveLabel(1.1,0.4,1.9,0.5,"200 ps","br");
1099         pl->SetFillColor(18);
1100         pl->SetTextSize(0.99);
1101         if (strstr(outputmode,"visual")) pl->Draw();
1102         pl = new TPaveLabel(1.1,0.2,1.9,0.3,"300 ps","br");
1103         pl->SetFillColor(18);
1104         pl->SetTextSize(0.99);
1105         if (strstr(outputmode,"visual")) pl->Draw();
1106       }
1107       if (strstr(outputmode,"visual")) picon->Draw("same");
1108     }
1109     
1110     pad7ls->SetFillStyle(0);
1111     pad7ls->SetFillColor(10);
1112     tpls->cd();
1113     if (strstr(outputmode,"visual")) pad7ls->Draw();
1114     pad7ls->cd();
1115     kacon->SetLineWidth(3);
1116     kacon->SetMaximum(1.);
1117     if (indexOfFile==0) {
1118       kacon->SetLineColor(1);
1119       if (strstr(outputmode,"visual")) kacon->Draw();
1120     } else {
1121       kacon->SetFillStyle(0);
1122       kacon->SetFillColor(30);
1123       if (indexOfFile==1) {
1124         kacon->SetLineStyle(2);
1125       } else if (indexOfFile==2) {
1126         kacon->SetLineStyle(3);
1127       } else {
1128         kacon->SetLineStyle(4);}
1129       if (strstr(outputmode,"visual")) kacon->Draw("same");
1130     }
1131     
1132     pad8ls->SetFillStyle(0);
1133     pad8ls->SetFillColor(10);
1134     tpls->cd();
1135     if (strstr(outputmode,"visual")) pad8ls->Draw();
1136     pad8ls->cd();
1137     prcon->SetLineWidth(3);
1138     prcon->SetMaximum(1.);
1139     if (indexOfFile==0) {
1140       prcon->SetLineColor(1);
1141       if (strstr(outputmode,"visual")) prcon->Draw();
1142     } else {
1143       prcon->SetFillStyle(0);
1144       prcon->SetFillColor(30);
1145       if (indexOfFile==1) {
1146         prcon->SetLineStyle(2);
1147       } else if (indexOfFile==2) {
1148         prcon->SetLineStyle(3);
1149       } else {
1150         prcon->SetLineStyle(4);}
1151       if (strstr(outputmode,"visual")) prcon->Draw("same");
1152     }
1153
1154
1155
1156
1157
1158
1159
1160     // momentum vs mass 2-D histos
1161
1162     if (indexOfFile==0) {
1163       momvsmassCanvas = new TCanvas("momvsmassCanvas","Momentum vs mass disribution",500,10,700,700);
1164       momvsmassCanvas->SetFillColor(0);
1165       momvsmassCanvas->SetBorderMode(0);
1166       gPad->SetFillStyle(0);
1167       gPad->SetBorderMode(0);
1168       gPad->SetFillColor(0);
1169       //   gStyle->SetOptStat(11);
1170       if (numfile==4) momvsmassCanvas->Divide(1,2,0,0); 
1171     } else if (indexOfFile==1 && numfile == 4) {
1172       momvsmassCanvas->cd(1);
1173       TPaveLabel *pl = new TPaveLabel(-0.0376218,-3.03586,0.0979277,-2.70158,"100 ps","br");
1174       pl->SetFillColor(18);
1175       pl->SetTextSize(0.99);
1176       if (strstr(outputmode,"visual")) pl->Draw();
1177     } else if (indexOfFile==3 && numfile == 4) {
1178       momvsmassCanvas->cd(2);
1179       TPaveLabel *pl = new TPaveLabel(-0.0591866,-3.17077,0.076363,-2.86857,"300 ps","br");
1180       pl->SetFillColor(18);
1181       pl->SetTextSize(0.99);
1182       if (strstr(outputmode,"visual")) pl->Draw();
1183     }
1184     if (numfile !=4) momvsmassCanvas->cd();
1185     if (numfile !=4 || indexOfFile==1 || indexOfFile==3) {
1186       //   hpi->PaintStat2(01);
1187       hpi->SetMarkerColor(5);
1188       if (strstr(outputmode,"visual")) hpi->Draw();
1189       if(strstr(eventType,"pp")){
1190         hel->SetMarkerColor(2);
1191         if (strstr(outputmode,"visual")) hel->Draw("same");
1192       }
1193       hka->SetMarkerColor(4);
1194       if (strstr(outputmode,"visual")) hka->Draw("same");
1195       hpr->SetMarkerColor(3);
1196       if (strstr(outputmode,"visual")) hpr->Draw("same");
1197       if (strstr(outputmode,"visual")) {
1198         fkaon->Draw();
1199         fproton->Draw();
1200         if(strstr(eventType,"pp")){
1201           felectron->Draw();
1202           fpion->Draw();
1203         }
1204       }
1205       if(strstr(eventType,"pp")){
1206         //TPaveText *ep = new TPaveText(-0.05,-0.5,0.05,-0.3);
1207         //ep->AddText("e");
1208         TPaveLabel *ep = new TPaveLabel(.42,.85,.52,1.05,"e");
1209         if (strstr(outputmode,"visual")) ep->Draw();
1210       }
1211
1212       TPaveText *pip = new TPaveText(0.15,-1.0,0.25,-0.8);
1213       pip->AddText("#pi");
1214       if (strstr(outputmode,"visual")) pip->Draw();
1215       TPaveText *kp = new TPaveText(0.5,-2.0,0.6,-1.8);
1216       kp->AddText("K");
1217       if (strstr(outputmode,"visual")) kp->Draw();
1218       TPaveText *prp = new TPaveText(0.9,-2.7,1.0,-2.5);
1219       prp->AddText("p");
1220       if (strstr(outputmode,"visual")) prp->Draw();
1221       //   TText *text2= new TText(.59,.06,"Momentum"); 
1222       //   text1->SetTextAngle(90);
1223       //   text1->Draw();
1224       //pidCanvas->DrawText(.1,.2,"Contamination               Efficiency");
1225       momvsmassCanvas->Update();
1226       if(strstr(outputsavemode,"asC")) momvsmassCanvas->Print("momvsmassCanvas.C");
1227       if(strstr(outputsavemode,"asEPS")) momvsmassCanvas->Print("momvsmassCanvas.eps");
1228       pidCanvas->cd();
1229       pidCanvas->Update();
1230       if(strstr(outputsavemode,"asC")) pidCanvas->Print("pidCanvas.C");
1231       if(strstr(outputsavemode,"asEPS")) pidCanvas->Print("pidCanvas.eps");
1232       char outFileName[100];
1233       strcpy(outFileName,"histos");
1234       strcat(outFileName,foutfileName);
1235       TFile *houtfile = new TFile(outFileName,"recreate");
1236       houtfile->cd();
1237       // saving canvas
1238       pidCanvas->Write(0,TObject::kOverwrite);
1239       momvsmassCanvas->Write(0,TObject::kOverwrite);
1240       // saving 1-D histos
1241       pit->Write(0,TObject::kOverwrite);
1242       pig->Write(0,TObject::kOverwrite);
1243       pieff->Write(0,TObject::kOverwrite);
1244       pieffls->Write(0,TObject::kOverwrite);
1245       picon->Write(0,TObject::kOverwrite);
1246       piid->Write(0,TObject::kOverwrite);
1247       pimatch->Write(0,TObject::kOverwrite);
1248       piall->Write(0,TObject::kOverwrite);
1249       pigen->Write(0,TObject::kOverwrite);
1250       kat->Write(0,TObject::kOverwrite);
1251       kag->Write(0,TObject::kOverwrite);
1252       kaeff->Write(0,TObject::kOverwrite);
1253       kaeffls->Write(0,TObject::kOverwrite);
1254       kaid->Write(0,TObject::kOverwrite);
1255       kamatch->Write(0,TObject::kOverwrite);
1256       kaall->Write(0,TObject::kOverwrite);
1257       kagen->Write(0,TObject::kOverwrite);
1258       kacon->Write(0,TObject::kOverwrite);
1259       prt->Write(0,TObject::kOverwrite);
1260       prg->Write(0,TObject::kOverwrite);
1261       preff->Write(0,TObject::kOverwrite);
1262       preffls->Write(0,TObject::kOverwrite);
1263       prcon->Write(0,TObject::kOverwrite);
1264       prid->Write(0,TObject::kOverwrite);
1265       prmatch->Write(0,TObject::kOverwrite);
1266       prall->Write(0,TObject::kOverwrite);
1267       prgen->Write(0,TObject::kOverwrite);
1268       // saving 2-D histos
1269       hpi->Write(0,TObject::kOverwrite);
1270       hka->Write(0,TObject::kOverwrite);
1271       hpr->Write(0,TObject::kOverwrite);
1272       // electron histos
1273       if (hel && eleff && elcon && elid && elall){
1274         hel->Write(0,TObject::kOverwrite);
1275         eleff->Write(0,TObject::kOverwrite);
1276         elcon->Write(0,TObject::kOverwrite);
1277         elid->Write(0,TObject::kOverwrite);
1278         elmatch->Write(0,TObject::kOverwrite);
1279         elall->Write(0,TObject::kOverwrite);
1280       }
1281       cout << "file " << houtfile << " has been created" << endl;
1282       cout << "it contains PID histos and canvas" << endl;
1283       houtfile->Close();
1284       houtfile->Write(0,TObject::kOverwrite);
1285     }
1286   }
1287
1288   if (strstr(outputmode,"novisual")){
1289     // free used memory
1290     delete pit  ; pit=0;
1291     delete pig  ; pig=0;
1292     delete pieff; pieff=0;
1293     delete pieffls; pieffls=0;
1294     delete picon; picon=0;
1295     delete piid ; piid=0;
1296     delete pimatch; pimatch=0;
1297     delete piall; piall=0;
1298     delete pigen; pigen=0;
1299     delete kat  ; kat=0;
1300     delete kag  ; kag=0;
1301     delete kaeff; kaeff=0;
1302     delete kaeffls; kaeffls=0;
1303     delete kaid;  kaid=0;
1304     delete kamatch; kamatch=0;
1305     delete kaall; kaall=0;
1306     delete kagen; kagen=0;
1307     delete kacon; kacon=0;
1308     delete prt;   prt=0;
1309     delete prg;   prg=0;
1310     delete preff; preff=0;
1311     delete preffls; preffls=0;
1312     delete prcon; prcon=0;
1313     delete prid;  prid=0;
1314     delete prmatch; prmatch=0;
1315     delete prall; prall=0;
1316     delete prgen; prgen=0;
1317     // 2-D
1318     delete hpi; hpi=0;
1319     delete hka; hka=0;
1320     delete hpr; hpr=0;
1321     if (hel){ 
1322       delete hel;
1323       hel=0;
1324     }
1325     if (eleff){ 
1326       delete eleff;
1327       eleff=0;
1328     }
1329     if (eleffls){ 
1330       delete eleffls;
1331       eleffls=0;
1332     }
1333     if (elcon){ 
1334       delete elcon;
1335       elcon=0;
1336     }
1337     if (elid){ 
1338       delete elid;
1339       elid=0;
1340     }
1341     if (elmatch){ 
1342       delete elmatch;
1343       elmatch=0;
1344     }
1345     if (elall){ 
1346       delete elall;
1347       elall=0;
1348     }
1349   }
1350 }
1351
1352
1353 //__________________________________________________________________
1354 Bool_t AliTOFPID::operator==( AliTOFPID const & /*tofrec*/)const
1355 {
1356   // dummy version of Equal operator.
1357   // requested by coding conventions
1358   return kTRUE;
1359
1360 }