]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaRec/AliTRDpidChecker.cxx
Small modifications on the PID checker task in order to be able to
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDpidChecker.cxx
1 #include "TROOT.h"
2 #include "TPDGCode.h"
3 #include "TCanvas.h"
4 #include "TF1.h"
5 #include "TH1F.h"
6 #include "TH1D.h"
7 #include "TH2F.h"
8 #include "TProfile.h"
9 #include "TProfile2D.h"
10 #include "TGraph.h"
11 #include "TGraphErrors.h"
12 #include "TLegend.h"
13
14 #include <TClonesArray.h>
15 #include <TObjArray.h>
16 #include <TList.h>
17
18 #include "AliESDEvent.h"
19 #include "AliESDInputHandler.h"
20 #include "AliTrackReference.h"
21
22 #include "AliAnalysisTask.h"
23
24 #include "AliTRDtrackerV1.h"
25 #include "AliTRDtrackV1.h"
26 #include "AliTRDcluster.h"
27 #include "AliTRDReconstructor.h"
28 #include "AliCDBManager.h"
29 #include "AliTRDpidUtil.h"
30
31 #include "AliTRDpidChecker.h"
32 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
33
34 // calculate pion efficiency at 90% electron efficiency for 11 momentum bins
35 // this task should be used with simulated data only
36
37 ClassImp(AliTRDpidChecker)
38
39 //________________________________________________________________________
40 AliTRDpidChecker::AliTRDpidChecker() 
41   :AliTRDrecoTask("PID", "PID Checker")
42   ,fReconstructor(0x0)
43   ,fUtil(0x0)
44   ,fGraph(0x0)
45   ,fEfficiency(0x0)
46 {
47   //
48   // Default constructor
49   //
50
51   fReconstructor = new AliTRDReconstructor();
52   fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
53
54   fUtil = new AliTRDpidUtil();
55
56   InitFunctorList();
57 }
58
59
60 //________________________________________________________________________
61 AliTRDpidChecker::~AliTRDpidChecker() 
62 {
63  if(fGraph){fGraph->Delete(); delete fGraph;}
64  if(fReconstructor) delete fReconstructor;
65   if(fUtil) delete fUtil;
66 }
67
68
69 //________________________________________________________________________
70 void AliTRDpidChecker::CreateOutputObjects()
71 {
72   // Create histograms
73   // Called once
74
75   OpenFile(0, "RECREATE");
76   fContainer = Histos();
77 }
78
79
80 //_______________________________________________________
81 TObjArray * AliTRDpidChecker::Histos(){
82
83   //
84   // Create QA histograms
85   //
86   if(fContainer) return fContainer;
87
88   Int_t xBins = AliPID::kSPECIES*AliTRDCalPID::kNMom; 
89   fContainer = new TObjArray(); fContainer->Expand(7);
90
91   const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1));     // get nice histos with bin center at 0 and 1
92
93   // histos of the electron probability of all 5 particle species and 11 momenta for the 2-dim LQ method 
94   fEfficiency = new TObjArray(3);
95   fEfficiency->SetOwner(); fEfficiency->SetName("Efficiency");
96   fContainer->AddAt(fEfficiency, kEfficiency);
97   
98   TH1 *h = 0x0;
99   if(!(h = (TH2F*)gROOT->FindObject("PID_LQ"))){
100     h = new TH2F("PID_LQ", "", xBins, -0.5, xBins - 0.5,
101       AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
102   } else h->Reset();
103   fEfficiency->AddAt(h, kLQ);
104
105   // histos of the electron probability of all 5 particle species and 11 momenta for the neural network method
106   if(!(h = (TH2F*)gROOT->FindObject("PID_NN"))){
107     h = new TH2F("PID_NN", "", 
108       xBins, -0.5, xBins - 0.5,
109       AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
110   } else h->Reset();
111   fEfficiency->AddAt(h, kNN);
112
113   // histos of the electron probability of all 5 particle species and 11 momenta for the ESD output
114   if(!(h = (TH2F*)gROOT->FindObject("PID_ESD"))){
115     h = new TH2F("PID_ESD", "", 
116       xBins, -0.5, xBins - 0.5,
117       AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
118   } else h->Reset();
119   fEfficiency->AddAt(h, kESD);
120
121   // histos of the dE/dx distribution for all 5 particle species and 11 momenta 
122   if(!(h = (TH2F*)gROOT->FindObject("dEdx"))){
123     h = new TH2F("dEdx", "", 
124       xBins, -0.5, xBins - 0.5,
125       200, 0, 10000);
126   } else h->Reset();
127   fContainer->AddAt(h, kdEdx);
128
129   // histos of the dE/dx slices for all 5 particle species and 11 momenta 
130   if(!(h = (TH2F*)gROOT->FindObject("dEdxSlice"))){
131     h = new TH2F("dEdxSlice", "", 
132       xBins*AliTRDReconstructor::kLQslices, -0.5, xBins*AliTRDReconstructor::kLQslices - 0.5,
133       200, 0, 5000);
134   } else h->Reset();
135   fContainer->AddAt(h, kdEdxSlice);
136
137   // histos of the pulse height distribution for all 5 particle species and 11 momenta 
138   if(!(h = (TH2F*)gROOT->FindObject("PH"))){
139     h = new TProfile2D("PH", "", 
140       xBins, -0.5, xBins - 0.5,
141       AliTRDtrackerV1::GetNTimeBins(), -0.5, AliTRDtrackerV1::GetNTimeBins() - 0.5);
142   } else h->Reset();
143   fContainer->AddAt(h, kPH);
144
145   // histos of the number of clusters distribution for all 5 particle species and 11 momenta 
146   if(!(h = (TH2F*)gROOT->FindObject("NClus"))){
147     h = new TH2F("NClus", "", 
148       xBins, -0.5, xBins - 0.5,
149       AliTRDtrackerV1::GetNTimeBins(), -0.5, AliTRDtrackerV1::GetNTimeBins() - 0.5);
150   } else h->Reset();
151   fContainer->AddAt(h, kNClus);
152
153
154   // momentum distributions - absolute and in momentum bins
155   if(!(h = (TH1F*)gROOT->FindObject("hMom"))){
156     h = new TH1F("hMom", "momentum distribution", 100, 0., 12.);
157   } else h->Reset();
158   fContainer->AddAt(h, kMomentum);
159   
160   if(!(h = (TH1F*)gROOT->FindObject("hMomBin"))){
161     h = new TH1F("hMomBin", "momentum distribution in momentum bins", AliTRDCalPID::kNMom, 0.5, 11.5);
162   } else h->Reset();
163   fContainer->AddAt(h, kMomentumBin);
164
165
166   return fContainer;
167 }
168
169
170 //________________________________________________________________________
171 Bool_t AliTRDpidChecker::CheckTrackQuality(const AliTRDtrackV1* track) 
172 {
173   //
174   // Check if the track is ok for PID
175   //
176   
177   if(track->GetNumberOfTracklets() == AliTRDgeometry::kNlayer) return 1;
178 //   if(!fESD)
179 //     return 0;
180
181   return 0;
182 }
183
184
185 //________________________________________________________________________
186 Int_t AliTRDpidChecker::CalcPDG(AliTRDtrackV1* track) 
187 {
188
189   track -> SetReconstructor(fReconstructor);
190
191   fReconstructor -> SetOption("nn");
192   track -> CookPID();
193
194   if(track -> GetPID(AliPID::kElectron) > track -> GetPID(AliPID::kMuon) + track -> GetPID(AliPID::kPion)  + track -> GetPID(AliPID::kKaon) + track -> GetPID(AliPID::kProton)){
195     return kElectron;
196   }
197   else if(track -> GetPID(kProton) > track -> GetPID(AliPID::kPion)  && track -> GetPID(AliPID::kProton) > track -> GetPID(AliPID::kKaon)  && track -> GetPID(AliPID::kProton) > track -> GetPID(AliPID::kMuon)){
198     return kProton;
199   }
200   else if(track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kMuon)  && track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kPion)){
201     return kKPlus;
202   }
203   else if(track -> GetPID(AliPID::kMuon) > track -> GetPID(AliPID::kPion)){
204     return kMuonPlus;
205   }
206   else{
207     return kPiPlus;
208   }
209 }
210
211
212 //_______________________________________________________
213 TH1 *AliTRDpidChecker::PlotLQ(const AliTRDtrackV1 *track)
214 {
215   //
216   // Plot the probabilities for electrons using 2-dim LQ
217   //
218
219   if(track) fTrack = track;
220   if(!fTrack){
221     AliWarning("No Track defined.");
222     return 0x0;
223   }
224
225   if(!CheckTrackQuality(fTrack)) return 0x0;
226   
227   if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
228     AliWarning("No Histogram defined.");
229     return 0x0;
230   }
231   TH2F *hPIDLQ = 0x0;
232   if(!(hPIDLQ = dynamic_cast<TH2F *>(fEfficiency->At(kLQ)))){
233     AliWarning("No Histogram defined.");
234     return 0x0;
235   }
236
237   AliTRDtrackV1 cTrack(*fTrack);
238   cTrack.SetReconstructor(fReconstructor);
239
240   Int_t pdg = 0;
241   Float_t momentum = 0.;
242
243   if(fMC){
244     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
245     pdg = fMC->GetPDG();
246   } else{
247     //AliWarning("No MC info available!");
248     momentum = cTrack.GetMomentum(0);
249     pdg = CalcPDG(&cTrack);
250   }
251   if(momentum < 0.4) return 0x0;;
252   if(momentum > 12.) return 0x0;;
253
254   fReconstructor -> SetOption("!nn");
255   cTrack.CookPID();
256   Int_t iMomBin = fUtil->GetMomentumBin(momentum);
257
258   switch(pdg){
259   case kElectron:
260   case kPositron:
261     hPIDLQ -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
262     break;
263   case kMuonPlus:
264   case kMuonMinus:
265     hPIDLQ -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
266     break;
267   case kPiPlus:
268   case kPiMinus:
269     hPIDLQ -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
270     break;
271   case kKPlus:
272   case kKMinus:
273     hPIDLQ -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
274     break;
275   case kProton:
276   case kProtonBar:
277     hPIDLQ -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
278     break;
279   }
280
281   return hPIDLQ;
282 }
283
284
285 //_______________________________________________________
286 TH1 *AliTRDpidChecker::PlotNN(const AliTRDtrackV1 *track)
287 {
288   //
289   // Plot the probabilities for electrons using 2-dim LQ
290   //
291
292   if(track) fTrack = track;
293   if(!fTrack){
294     AliWarning("No Track defined.");
295     return 0x0;
296   }
297   
298   if(!CheckTrackQuality(fTrack)) return 0x0;
299   
300   if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
301     AliWarning("No Histogram defined.");
302     return 0x0;
303   }
304   TH2F *hPIDNN;
305   if(!(hPIDNN = dynamic_cast<TH2F *>(fEfficiency->At(kNN)))){
306     AliWarning("No Histogram defined.");
307     return 0x0;
308   }
309
310
311   AliTRDtrackV1 cTrack(*fTrack);
312   cTrack.SetReconstructor(fReconstructor);
313
314   Int_t pdg = 0;
315   Float_t momentum = 0.;
316   if(fMC){
317     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
318     pdg = fMC->GetPDG();
319   } else {
320     //AliWarning("No MC info available!");
321     momentum = cTrack.GetMomentum(0);
322     pdg = CalcPDG(&cTrack);
323   }
324   if(momentum < 0.4) return 0x0;;
325   if(momentum > 12.) return 0x0;;
326
327   fReconstructor -> SetOption("nn");
328   cTrack.CookPID();
329   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
330
331   switch(pdg){
332   case kElectron:
333   case kPositron:
334     hPIDNN -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
335     break;
336   case kMuonPlus:
337   case kMuonMinus:
338     hPIDNN -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
339     break;
340   case kPiPlus:
341   case kPiMinus:
342     hPIDNN -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
343     break;
344   case kKPlus:
345   case kKMinus:
346     hPIDNN -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
347     break;
348   case kProton:
349   case kProtonBar:
350     hPIDNN -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
351     break;
352   }
353   return hPIDNN;
354 }
355
356
357 //_______________________________________________________
358 TH1 *AliTRDpidChecker::PlotESD(const AliTRDtrackV1 *track)
359 {
360   //
361   // Plot the probabilities for electrons using 2-dim LQ
362   //
363
364   if(!fESD){
365     AliWarning("No ESD info available.");
366     return 0x0;
367   }
368
369   if(track) fTrack = track;
370   if(!fTrack){
371     AliWarning("No Track defined.");
372     return 0x0;
373   }
374   
375   if(!CheckTrackQuality(fTrack)) return 0x0;
376   
377   if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
378     AliWarning("No Histogram defined.");
379     return 0x0;
380   }
381   TH2F *hPIDESD = 0x0;
382   if(!(hPIDESD = dynamic_cast<TH2F *>(fEfficiency->At(kESD)))){
383     AliWarning("No Histogram defined.");
384     return 0x0;
385   }
386
387
388   Int_t pdg = 0;
389   Float_t momentum = 0.;
390   if(fMC){
391     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
392     pdg = fMC->GetPDG();
393   } else {
394     //AliWarning("No MC info available!");
395     AliTRDtrackV1 cTrack(*fTrack);
396     cTrack.SetReconstructor(fReconstructor);
397     momentum = cTrack.GetMomentum(0);
398     pdg = CalcPDG(&cTrack);
399   }
400   if(momentum < 0.4) return 0x0;;
401   if(momentum > 12.) return 0x0;;
402   
403
404   Int_t iMomBin = fUtil->GetMomentumBin(momentum);
405
406
407 //   Double32_t pidESD[AliPID::kSPECIES];
408   const Double32_t *pidESD = fESD->GetResponseIter();
409
410   switch(pdg){
411   case kElectron:
412   case kPositron:
413     hPIDESD -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
414     break;
415   case kMuonPlus:
416   case kMuonMinus:
417     hPIDESD -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
418     break;
419   case kPiPlus:
420   case kPiMinus:
421     hPIDESD -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
422     break;
423   case kKPlus:
424   case kKMinus:
425     hPIDESD -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
426     break;
427   case kProton:
428   case kProtonBar:
429     hPIDESD -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
430     break;
431   }
432   return hPIDESD;
433 }
434
435
436 //_______________________________________________________
437 TH1 *AliTRDpidChecker::PlotdEdx(const AliTRDtrackV1 *track)
438 {
439   //
440   // Plot the probabilities for electrons using 2-dim LQ
441   //
442
443   if(track) fTrack = track;
444   if(!fTrack){
445     AliWarning("No Track defined.");
446     return 0x0;
447   }
448   
449   if(!CheckTrackQuality(fTrack)) return 0x0;
450   
451   TH2F *hdEdx;
452   if(!(hdEdx = dynamic_cast<TH2F *>(fContainer->At(kdEdx)))){
453     AliWarning("No Histogram defined.");
454     return 0x0;
455   }
456
457
458   Int_t pdg = 0;
459   Float_t momentum = 0.;
460   if(fMC){
461     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
462     pdg = fMC->GetPDG();
463   } else {
464     //AliWarning("No MC info available!");
465     AliTRDtrackV1 cTrack(*fTrack);
466     cTrack.SetReconstructor(fReconstructor);
467     momentum = cTrack.GetMomentum(0);
468     pdg = CalcPDG(&cTrack);
469   }
470   if(momentum < 0.4) return 0x0;;
471   if(momentum > 12.) return 0x0;;
472
473   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
474
475
476
477   Float_t SumdEdx[AliTRDgeometry::kNlayer];
478   AliTRDseedV1 *TRDtracklet[AliTRDgeometry::kNlayer];
479   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = 0x0;
480   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = fTrack -> GetTracklet(iChamb);
481
482   Float_t *fdEdx;
483   Float_t dEdxSlice[AliTRDgeometry::kNlayer][AliTRDReconstructor::kLQslices];
484
485   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
486     SumdEdx[iChamb] = 0.;
487     fdEdx = TRDtracklet[iChamb] -> GetdEdx();
488     SumdEdx[iChamb] += fdEdx[0] + fdEdx[1] + fdEdx[2];
489     for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++){
490       dEdxSlice[iChamb][iSlice] = fdEdx[iSlice];
491     }
492   }
493
494   switch(pdg){
495   case kElectron:
496   case kPositron:
497     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
498       hdEdx -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
499     break;
500   case kMuonPlus:
501   case kMuonMinus:
502     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
503       hdEdx -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
504     break;
505   case kPiPlus:
506   case kPiMinus:
507     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
508       hdEdx -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
509     break;
510   case kKPlus:
511   case kKMinus:
512     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
513       hdEdx -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
514     break;
515   case kProton:
516   case kProtonBar:
517     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
518       hdEdx -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
519     break;
520   }
521
522   return hdEdx;
523 }
524
525
526 //_______________________________________________________
527 TH1 *AliTRDpidChecker::PlotdEdxSlice(const AliTRDtrackV1 *track)
528 {
529   //
530   // Plot the probabilities for electrons using 2-dim LQ
531   //
532
533   if(track) fTrack = track;
534   if(!fTrack){
535     AliWarning("No Track defined.");
536     return 0x0;
537   }
538   
539   if(!CheckTrackQuality(fTrack)) return 0x0;
540   
541   TH2F *hdEdxSlice;
542   if(!(hdEdxSlice = dynamic_cast<TH2F *>(fContainer->At(kdEdxSlice)))){
543     AliWarning("No Histogram defined.");
544     return 0x0;
545   }
546
547   Int_t pdg = 0;
548   Float_t momentum = 0.;
549   if(fMC){
550     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
551     pdg = fMC->GetPDG();
552   } else {
553     //AliWarning("No MC info available!");
554     AliTRDtrackV1 cTrack(*fTrack);
555     cTrack.SetReconstructor(fReconstructor);
556     momentum = cTrack.GetMomentum(0);
557     pdg = CalcPDG(&cTrack);
558   }
559   if(momentum < 0.4) return 0x0;
560   if(momentum > 12.) return 0x0;;
561
562   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
563
564
565
566   AliTRDseedV1 *TRDtracklet[AliTRDgeometry::kNlayer];
567   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = 0x0;
568   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = fTrack -> GetTracklet(iChamb);
569
570   Float_t *fdEdx;
571   Float_t dEdxSlice[AliTRDgeometry::kNlayer][AliTRDReconstructor::kLQslices];
572
573   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
574     fdEdx = TRDtracklet[iChamb] -> GetdEdx();
575     for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++){
576       dEdxSlice[iChamb][iSlice] = fdEdx[iSlice];
577     }
578   }
579
580   switch(pdg){
581   case kElectron:
582   case kPositron:
583     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
584       for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++){
585         hdEdxSlice -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom * AliTRDReconstructor::kLQslices + iMomBin * AliTRDReconstructor::kLQslices + iSlice, dEdxSlice[iChamb][iSlice]);
586       }
587     }  
588     break;
589   case kMuonPlus:
590   case kMuonMinus:
591     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
592       for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++){
593         hdEdxSlice -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom * AliTRDReconstructor::kLQslices + iMomBin * AliTRDReconstructor::kLQslices + iSlice,
594         dEdxSlice[iChamb][iSlice]);
595       }
596     }
597     break;
598   case kPiPlus:
599   case kPiMinus:
600     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
601       for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++)
602         hdEdxSlice -> Fill(AliPID::kPion * AliTRDCalPID::kNMom * AliTRDReconstructor::kLQslices + iMomBin * AliTRDReconstructor::kLQslices + iSlice,
603                            dEdxSlice[iChamb][iSlice]);
604     break;
605   case kKPlus:
606   case kKMinus:
607     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
608       for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++)
609         hdEdxSlice -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom * AliTRDReconstructor::kLQslices + iMomBin * AliTRDReconstructor::kLQslices + iSlice,
610                            dEdxSlice[iChamb][iSlice]);
611     break;
612   case kProton:
613   case kProtonBar:
614     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
615       for(Int_t iSlice = 0; iSlice < AliTRDReconstructor::kLQslices; iSlice++)
616         hdEdxSlice -> Fill(AliPID::kProton * AliTRDCalPID::kNMom * AliTRDReconstructor::kLQslices + iMomBin * AliTRDReconstructor::kLQslices + iSlice,
617                            dEdxSlice[iChamb][iSlice]);
618     break;
619   }
620
621   return hdEdxSlice;
622
623 }
624
625
626 //_______________________________________________________
627 TH1 *AliTRDpidChecker::PlotPH(const AliTRDtrackV1 *track)
628 {
629   //
630   // Plot the probabilities for electrons using 2-dim LQ
631   //
632
633   if(track) fTrack = track;
634   if(!fTrack){
635     AliWarning("No Track defined.");
636     return 0x0;
637   }
638   
639   if(!CheckTrackQuality(fTrack)) return 0x0;
640   
641   TProfile2D *hPH;
642   if(!(hPH = dynamic_cast<TProfile2D *>(fContainer->At(kPH)))){
643     AliWarning("No Histogram defined.");
644     return 0x0;
645   }
646
647   Int_t pdg = 0;
648   Float_t momentum = 0.;
649   if(fMC){
650     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
651     pdg = fMC->GetPDG();
652   } else {
653     //AliWarning("No MC info available!");
654     AliTRDtrackV1 cTrack(*fTrack);
655     cTrack.SetReconstructor(fReconstructor);
656     momentum = cTrack.GetMomentum(0);
657     pdg = CalcPDG(&cTrack);
658   }
659   if(momentum < 0.4) return 0x0;;
660   if(momentum > 12.) return 0x0;;
661
662   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
663
664   AliTRDseedV1 *TRDtracklet[AliTRDgeometry::kNlayer];
665   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = 0x0;
666   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = fTrack -> GetTracklet(iChamb);
667
668   AliTRDcluster *TRDcluster = 0x0;
669
670   switch(pdg){
671   case kElectron:
672   case kPositron:
673     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
674       for(Int_t iClus = 0; iClus < AliTRDtrackerV1::GetNTimeBins(); iClus++){
675         if(!(TRDcluster = (AliTRDcluster*)TRDtracklet[iChamb] -> GetClusters(iClus)))
676           continue;
677         hPH -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
678       }
679     }
680     break;
681   case kMuonPlus:
682   case kMuonMinus:
683     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
684       for(Int_t iClus = 0; iClus < AliTRDtrackerV1::GetNTimeBins(); iClus++){
685         if(!(TRDcluster = (AliTRDcluster*)TRDtracklet[iChamb] -> GetClusters(iClus)))
686           continue;
687         hPH -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
688       }
689     }
690     break;
691   case kPiPlus:
692   case kPiMinus:
693     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
694       for(Int_t iClus = 0; iClus < AliTRDtrackerV1::GetNTimeBins(); iClus++){
695         if(!(TRDcluster = (AliTRDcluster*)TRDtracklet[iChamb] -> GetClusters(iClus)))
696           continue;
697         hPH -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
698       }
699     }
700     break;
701   case kKPlus:
702   case kKMinus:
703     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
704       for(Int_t iClus = 0; iClus < AliTRDtrackerV1::GetNTimeBins(); iClus++){
705         if(!(TRDcluster = (AliTRDcluster*)TRDtracklet[iChamb] -> GetClusters(iClus)))
706           continue;
707         hPH -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
708       }
709     }
710     break;
711   case kProton:
712   case kProtonBar:
713     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
714       for(Int_t iClus = 0; iClus < AliTRDtrackerV1::GetNTimeBins(); iClus++){
715         if(!(TRDcluster = (AliTRDcluster*)TRDtracklet[iChamb] -> GetClusters(iClus)))
716           continue;
717         hPH -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
718       }
719     }
720     break; 
721   }
722   
723   return hPH;
724 }
725
726
727 //_______________________________________________________
728 TH1 *AliTRDpidChecker::PlotNClus(const AliTRDtrackV1 *track)
729 {
730   //
731   // Plot the probabilities for electrons using 2-dim LQ
732   //
733
734   if(track) fTrack = track;
735   if(!fTrack){
736     AliWarning("No Track defined.");
737     return 0x0;
738   }
739   
740   if(!CheckTrackQuality(fTrack)) return 0x0;
741   
742   TH2F *hNClus;
743   if(!(hNClus = dynamic_cast<TH2F *>(fContainer->At(kNClus)))){
744     AliWarning("No Histogram defined.");
745     return 0x0;
746   }
747
748
749   Int_t pdg = 0;
750   Float_t momentum = 0.;
751   if(fMC){
752     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
753     pdg = fMC->GetPDG();
754   } else {
755     //AliWarning("No MC info available!");
756     AliTRDtrackV1 cTrack(*fTrack);
757     cTrack.SetReconstructor(fReconstructor);
758     momentum = cTrack.GetMomentum(0);
759     pdg = CalcPDG(&cTrack);
760   }
761   if(momentum < 0.4) return 0x0;;
762   if(momentum > 12.) return 0x0;;
763
764   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
765
766
767   Int_t iNClus[AliTRDgeometry::kNlayer]; 
768   memset(iNClus, 0, sizeof(Int_t) * AliTRDgeometry::kNlayer);
769
770   AliTRDseedV1 *TRDtracklet[AliTRDgeometry::kNlayer];
771   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++) TRDtracklet[iChamb] = 0x0;
772   for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
773     TRDtracklet[iChamb] = fTrack -> GetTracklet(iChamb);
774     iNClus[iChamb] = TRDtracklet[iChamb] -> GetN();
775   }
776
777   switch(pdg){
778   case kElectron:
779   case kPositron:
780     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
781       hNClus -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
782     break;
783   case kMuonPlus:
784   case kMuonMinus:
785     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
786       hNClus -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
787     break;
788   case kPiPlus:
789   case kPiMinus:
790     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
791       hNClus -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
792     break;
793   case kKPlus:
794   case kKMinus:
795     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
796       hNClus -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
797     break;
798   case kProton:
799   case kProtonBar:
800     for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
801       hNClus -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
802     break;
803   }
804
805   return hNClus;
806 }
807
808
809 //_______________________________________________________
810 TH1 *AliTRDpidChecker::PlotMom(const AliTRDtrackV1 *track)
811 {
812   //
813   // Plot the probabilities for electrons using 2-dim LQ
814   //
815
816   if(track) fTrack = track;
817   if(!fTrack){
818     AliWarning("No Track defined.");
819     return 0x0;
820   }
821   
822   if(!CheckTrackQuality(fTrack)) return 0x0;
823   
824   TH1F *hMom;
825   if(!(hMom = dynamic_cast<TH1F *>(fContainer->At(kMomentum)))){
826     AliWarning("No Histogram defined.");
827     return 0x0;
828   }
829
830
831   Int_t pdg = 0;
832   Float_t momentum = 0.;
833   if(fMC){
834     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
835     pdg = fMC->GetPDG();
836   } else {
837     //AliWarning("No MC info available!");
838     AliTRDtrackV1 cTrack(*fTrack);
839     cTrack.SetReconstructor(fReconstructor);
840     momentum = cTrack.GetMomentum(0);
841     pdg = CalcPDG(&cTrack);
842   }
843   if(momentum < 0.4) return 0x0;
844   if(momentum > 12.) return 0x0;;
845
846   hMom -> Fill(momentum);
847   return hMom;
848 }
849
850
851 //_______________________________________________________
852 TH1 *AliTRDpidChecker::PlotMomBin(const AliTRDtrackV1 *track)
853 {
854   //
855   // Plot the probabilities for electrons using 2-dim LQ
856   //
857
858   if(track) fTrack = track;
859   if(!fTrack){
860     AliWarning("No Track defined.");
861     return 0x0;
862   }
863   
864   if(!CheckTrackQuality(fTrack)) return 0x0;
865   
866   TH1F *hMomBin;
867   if(!(hMomBin = dynamic_cast<TH1F *>(fContainer->At(kMomentumBin)))){
868     AliWarning("No Histogram defined.");
869     return 0x0;
870   }
871
872
873   Int_t pdg = 0;
874   Float_t momentum = 0.;
875
876   if(fMC){
877     if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
878     pdg = fMC->GetPDG();
879   } else {
880     //AliWarning("No MC info available!");
881     AliTRDtrackV1 cTrack(*fTrack);
882     cTrack.SetReconstructor(fReconstructor);
883     momentum = cTrack.GetMomentum(0);
884     pdg = CalcPDG(&cTrack);
885   }
886   if(momentum < 0.4) return 0x0;
887   if(momentum > 12.) return 0x0;;
888
889   Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
890   hMomBin -> Fill(iMomBin);
891   return hMomBin;
892 }
893
894
895 //________________________________________________________
896 Bool_t AliTRDpidChecker::GetRefFigure(Int_t ifig)
897 {
898   Bool_t FIRST = kTRUE;
899   TLegend *leg = new TLegend(.7, .7, .98, .98);
900   leg->SetBorderSize(1);
901   TGraphErrors *g = 0x0;
902   TAxis *ax = 0x0;
903   TH1 *h1 = 0x0, *h=0x0;
904   TH2 *h2 = 0x0;
905   switch(ifig){
906   case kEfficiency:
907     if(!(g = (TGraphErrors*)fGraph->At(kLQ))) break;
908     if(!g->GetN()) break;
909     leg->SetHeader("PID Method");
910     g->Draw("apl");
911     ax = g->GetHistogram()->GetXaxis();
912     ax->SetTitle("p [GeV/c]");
913     ax->SetRangeUser(.6, 10.5);
914     ax->SetMoreLogLabels();
915     ax = g->GetHistogram()->GetYaxis();
916     ax->SetTitle("#epsilon_{#pi} [%]");
917     ax->SetRangeUser(1.e-3, 1.e-1);
918     leg->AddEntry(g, "2D LQ", "pl");
919     if(! (g = (TGraphErrors*)fGraph->At(kNN))) break;
920     g->Draw("pl");
921     leg->AddEntry(g, "NN", "pl");
922     if(! (g = (TGraphErrors*)fGraph->At(kESD))) break;
923     g->Draw("p");
924     leg->AddEntry(g, "ESD", "pl");
925     leg->Draw();
926     gPad->SetLogy();
927     gPad->SetLogx();
928     gPad->SetGridy();
929     gPad->SetGridx();
930     return kTRUE;
931   case kdEdx:
932     // save 2.0 GeV projection as reference
933     FIRST = kTRUE;
934     if(!(h2 = (TH2F*)(fContainer->At(kdEdx)))) break;
935     leg->SetHeader("Particle Species");
936     for(Int_t is = AliPID::kSPECIES-1; is>=0; is--){
937       Int_t bin = is*AliTRDCalPID::kNMom+4;
938       h1 = h2->ProjectionY("px", bin, bin);
939       if(!h1->GetEntries()) continue;
940       h1->Scale(1./h1->Integral());
941       h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
942       h = (TH1F*)h1->DrawClone(FIRST ? "c" : "samec");
943       leg->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
944       FIRST = kFALSE;
945     }
946     if(FIRST) break;
947     leg->Draw();
948     gPad->SetLogy();
949     gPad->SetLogx(0);
950     gPad->SetGridy();
951     gPad->SetGridx();
952     return kTRUE;
953   case kdEdxSlice:
954     break;
955   case kPH:
956     // save 2.0 GeV projection as reference
957     FIRST = kTRUE;
958     if(!(h2 = (TH2F*)(fContainer->At(kPH)))) break;;
959     leg->SetHeader("Particle Species");
960     for(Int_t is=0; is<AliPID::kSPECIES; is++){
961       Int_t bin = is*AliTRDCalPID::kNMom+4;
962       h1 = h2->ProjectionY("py", bin, bin);
963       if(!h1->GetEntries()) continue;
964       h1->SetMarkerStyle(24);
965       h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
966       h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
967       if(FIRST){
968         h1->GetXaxis()->SetTitle("tb[1/100 ns^{-1}]");
969         h1->GetYaxis()->SetTitle("<PH> [a.u.]");
970       }
971       h = (TH1F*)h1->DrawClone(FIRST ? "c" : "samec");
972       leg->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "pl");
973       FIRST = kFALSE;
974     }
975     if(FIRST) break;
976     leg->Draw();
977     gPad->SetLogy(0);
978     gPad->SetLogx(0);
979     gPad->SetGridy();
980     gPad->SetGridx();
981     return kTRUE;
982   case kNClus:
983     // save 2.0 GeV projection as reference
984     FIRST = kTRUE;
985     if(!(h2 = (TH2F*)(fContainer->At(kNClus)))) break;
986     leg->SetHeader("Particle Species");
987     for(Int_t is=0; is<AliPID::kSPECIES; is++){
988       Int_t bin = is*AliTRDCalPID::kNMom+4;
989       h1 = h2->ProjectionY("py", bin, bin);
990       if(!h1->GetEntries()) continue;
991       //h1->SetMarkerStyle(24);
992       //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
993       h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
994       if(FIRST) h1->GetXaxis()->SetTitle("N^{cl}/tracklet");
995       h = (TH1F*)h1->DrawClone(FIRST ? "c" : "samec");
996       leg->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
997       FIRST = kFALSE;
998     }
999     if(FIRST) break;
1000     leg->Draw();
1001     gPad->SetLogy();
1002     gPad->SetLogx(0);
1003     gPad->SetGridy();
1004     gPad->SetGridx();
1005     return kTRUE;
1006   case kMomentum:
1007   case kMomentumBin:
1008     break; 
1009   case kThresh:
1010     if(!(g = (TGraphErrors*)fGraph->At(kLQ+3))) break;
1011     if(!g->GetN()) break;
1012     leg->SetHeader("PID Method");
1013     g->Draw("apl");
1014     ax = g->GetHistogram()->GetXaxis();
1015     ax->SetTitle("p [GeV/c]");
1016     ax->SetRangeUser(.6, 10.5);
1017     ax->SetMoreLogLabels();
1018     ax = g->GetHistogram()->GetYaxis();
1019     ax->SetTitle("threshold");
1020     ax->SetRangeUser(5.e-2, 1.);
1021     leg->AddEntry(g, "2D LQ", "pl");
1022     if(!(g = (TGraphErrors*)fGraph->At(kNN+3))) break;
1023     g->Draw("pl");
1024     leg->AddEntry(g, "NN", "pl");
1025     if(!(g = (TGraphErrors*)fGraph->At(kESD+3))) break;
1026     g->Draw("p");
1027     leg->AddEntry(g, "ESD", "pl");
1028     leg->Draw();
1029     gPad->SetLogx();
1030     gPad->SetGridy();
1031     gPad->SetGridx();
1032     return kTRUE;
1033   }
1034   AliInfo(Form("Reference plot [%d] missing result", ifig));
1035   return kFALSE;
1036 }
1037
1038 //________________________________________________________________________
1039 Bool_t AliTRDpidChecker::PostProcess()
1040 {
1041   // Draw result to the screen
1042   // Called once at the end of the query
1043
1044   if (!fContainer) {
1045     Printf("ERROR: list not available");
1046     return kFALSE;
1047   }
1048   if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
1049     AliError("Efficiency container missing.");
1050     return 0x0;
1051   }
1052   if(!fGraph){ 
1053     fGraph = new TObjArray(6);
1054     fGraph->SetOwner();
1055     EvaluatePionEfficiency(fEfficiency, fGraph, 0.9);
1056   }
1057   fNRefFigures = 8;
1058   return kTRUE;
1059 }
1060
1061 //________________________________________________________________________
1062 void AliTRDpidChecker::EvaluatePionEfficiency(TObjArray *histoContainer, TObjArray *results, Float_t electron_efficiency){
1063   TGraphErrors *g = 0x0;
1064   fUtil->SetElectronEfficiency(electron_efficiency);
1065
1066   // efficiency graphs
1067   TObjArray *arr = new TObjArray(3); arr->SetOwner();
1068   results->AddAt(arr, 0);
1069   arr->AddAt(g = new TGraphErrors(), kLQ);
1070   g->SetLineColor(kBlue);
1071   g->SetMarkerColor(kBlue);
1072   g->SetMarkerStyle(7);
1073   arr->AddAt(g = new TGraphErrors(), kNN);
1074   g->SetLineColor(kGreen);
1075   g->SetMarkerColor(kGreen);
1076   g->SetMarkerStyle(7);
1077   arr -> AddAt(g = new TGraphErrors(), kESD);
1078   g->SetLineColor(kRed);
1079   g->SetMarkerColor(kRed);
1080   g->SetMarkerStyle(24);
1081
1082   arr = new TObjArray(3); arr->SetOwner();
1083   results->AddAt(arr, 1);
1084   arr->AddAt(g = new TGraphErrors(), kLQ);
1085   g->SetLineColor(kBlue);
1086   g->SetMarkerColor(kBlue);
1087   g->SetMarkerStyle(7);
1088   arr->AddAt(g = new TGraphErrors(), kNN);
1089   g->SetLineColor(kGreen);
1090   g->SetMarkerColor(kGreen);
1091   g->SetMarkerStyle(7);
1092   arr -> AddAt(g = new TGraphErrors(), kESD);
1093   g->SetLineColor(kRed);
1094   g->SetMarkerColor(kRed);
1095   g->SetMarkerStyle(24);
1096   
1097   Float_t mom = 0.;
1098   TH1D *Histo1=0x0, *Histo2=0x0;
1099
1100   // calculate the pion efficiencies and the errors for 90% electron efficiency (2-dim LQ)
1101   TH2F *hPIDLQ = (TH2F*)histoContainer->At(kLQ);
1102   for(Int_t iMom = 0; iMom < AliTRDCalPID::kNMom; iMom++){
1103     mom = AliTRDCalPID::GetMomentum(iMom);
1104
1105     Histo1 = hPIDLQ -> ProjectionY("LQ_ele",AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1,AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1);
1106     Histo2 = hPIDLQ -> ProjectionY("LQ_pio",AliTRDCalPID::kNMom*AliPID::kPion+iMom+1,AliTRDCalPID::kNMom*AliPID::kPion+iMom+1);
1107
1108     if(!fUtil->CalculatePionEffi(Histo1, Histo2)) continue;
1109
1110     g = (TGraphErrors*)fGraph->At(kLQ);
1111     g->SetPoint(iMom, mom, fUtil->GetPionEfficiency());
1112     g->SetPointError(iMom, 0., fUtil->GetError());
1113     g = (TGraphErrors*)fGraph->At(3 + kLQ);
1114     g->SetPoint(iMom, mom, fUtil->GetThreshold());
1115     g->SetPointError(iMom, 0., 0.);
1116
1117     if(fDebugLevel>=2) Printf("Pion Efficiency for 2-dim LQ is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
1118   }
1119   
1120
1121   // calculate the pion efficiencies and the errors for 90% electron efficiency (NN)
1122   TH2F *hPIDNN = (TH2F*)histoContainer->At(kNN);
1123   for(Int_t iMom = 0; iMom < AliTRDCalPID::kNMom; iMom++){
1124     mom = AliTRDCalPID::GetMomentum(iMom);
1125
1126     Histo1 = hPIDNN -> ProjectionY("NN_ele",AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1,AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1);
1127     Histo2 = hPIDNN -> ProjectionY("NN_pio",AliTRDCalPID::kNMom*AliPID::kPion+iMom+1,AliTRDCalPID::kNMom*AliPID::kPion+iMom+1);
1128
1129     if(!fUtil -> CalculatePionEffi(Histo1, Histo2)) continue;
1130
1131     g = (TGraphErrors*)fGraph->At(kNN);
1132     g->SetPoint(iMom, mom, fUtil->GetPionEfficiency());
1133     g->SetPointError(iMom, 0., fUtil->GetError());
1134     g = (TGraphErrors*)fGraph->At(3+kNN);
1135     g->SetPoint(iMom, mom, fUtil->GetThreshold());
1136     g->SetPointError(iMom, 0., 0.);
1137
1138     if(fDebugLevel>=2) Printf("Pion Efficiency for NN is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
1139   }
1140
1141
1142   // calculate the pion efficiencies and the errors for 90% electron efficiency (ESD)
1143   TH2F *hPIDESD = (TH2F*)histoContainer->At(kESD);
1144   for(Int_t iMom = 0; iMom < AliTRDCalPID::kNMom; iMom++){
1145     mom = AliTRDCalPID::GetMomentum(iMom);
1146
1147     Histo1 = hPIDESD -> ProjectionY("NN_ele",AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1,AliTRDCalPID::kNMom*AliPID::kElectron+iMom+1);
1148     Histo2 = hPIDESD -> ProjectionY("NN_pio",AliTRDCalPID::kNMom*AliPID::kPion+iMom+1,AliTRDCalPID::kNMom*AliPID::kPion+iMom+1);
1149
1150     if(!fUtil->CalculatePionEffi(Histo1, Histo2)) continue;
1151
1152     g = (TGraphErrors*)fGraph->At(kESD);
1153     g->SetPoint(iMom, mom, fUtil->GetPionEfficiency());
1154     g->SetPointError(iMom, 0., fUtil->GetError());
1155     g = (TGraphErrors*)fGraph->At(3+kESD);
1156     g->SetPoint(iMom, mom, fUtil->GetThreshold());
1157     g->SetPointError(iMom, 0., 0.);
1158
1159     if(fDebugLevel>=2) Printf("Pion Efficiency for ESD is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
1160   }
1161
1162 }
1163
1164 //________________________________________________________________________
1165 void AliTRDpidChecker::Terminate(Option_t *) 
1166 {
1167   // Draw result to the screen
1168   // Called once at the end of the query
1169
1170   fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
1171   if (!fContainer) {
1172     Printf("ERROR: list not available");
1173     return;
1174   }
1175 }
1176
1177