9 #include "TProfile2D.h"
11 #include "TGraphErrors.h"
14 #include <TClonesArray.h>
15 #include <TObjArray.h>
18 #include "AliESDEvent.h"
19 #include "AliESDInputHandler.h"
20 #include "AliTrackReference.h"
22 #include "AliAnalysisTask.h"
24 #include "AliTRDtrackerV1.h"
25 #include "AliTRDtrackV1.h"
26 #include "AliTRDcluster.h"
27 #include "AliTRDReconstructor.h"
28 #include "AliCDBManager.h"
29 #include "AliTRDpidUtil.h"
31 #include "AliTRDpidChecker.h"
32 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
34 // calculate pion efficiency at 90% electron efficiency for 11 momentum bins
35 // this task should be used with simulated data only
37 ClassImp(AliTRDpidChecker)
39 //________________________________________________________________________
40 AliTRDpidChecker::AliTRDpidChecker()
41 :AliTRDrecoTask("PID", "PID Checker")
48 // Default constructor
51 fReconstructor = new AliTRDReconstructor();
52 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
54 fUtil = new AliTRDpidUtil();
60 //________________________________________________________________________
61 AliTRDpidChecker::~AliTRDpidChecker()
63 if(fGraph){fGraph->Delete(); delete fGraph;}
64 if(fReconstructor) delete fReconstructor;
65 if(fUtil) delete fUtil;
69 //________________________________________________________________________
70 void AliTRDpidChecker::CreateOutputObjects()
75 OpenFile(0, "RECREATE");
76 fContainer = Histos();
80 //_______________________________________________________
81 TObjArray * AliTRDpidChecker::Histos(){
84 // Create QA histograms
86 if(fContainer) return fContainer;
88 Int_t xBins = AliPID::kSPECIES*AliTRDCalPID::kNMom;
89 fContainer = new TObjArray(); fContainer->Expand(7);
91 const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1)); // get nice histos with bin center at 0 and 1
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);
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);
103 fEfficiency->AddAt(h, kLQ);
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);
111 fEfficiency->AddAt(h, kNN);
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);
119 fEfficiency->AddAt(h, kESD);
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,
127 fContainer->AddAt(h, kdEdx);
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,
135 fContainer->AddAt(h, kdEdxSlice);
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);
143 fContainer->AddAt(h, kPH);
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);
151 fContainer->AddAt(h, kNClus);
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.);
158 fContainer->AddAt(h, kMomentum);
160 if(!(h = (TH1F*)gROOT->FindObject("hMomBin"))){
161 h = new TH1F("hMomBin", "momentum distribution in momentum bins", AliTRDCalPID::kNMom, 0.5, 11.5);
163 fContainer->AddAt(h, kMomentumBin);
170 //________________________________________________________________________
171 Bool_t AliTRDpidChecker::CheckTrackQuality(const AliTRDtrackV1* track)
174 // Check if the track is ok for PID
177 if(track->GetNumberOfTracklets() == AliTRDgeometry::kNlayer) return 1;
185 //________________________________________________________________________
186 Int_t AliTRDpidChecker::CalcPDG(AliTRDtrackV1* track)
189 track -> SetReconstructor(fReconstructor);
191 fReconstructor -> SetOption("nn");
194 if(track -> GetPID(AliPID::kElectron) > track -> GetPID(AliPID::kMuon) + track -> GetPID(AliPID::kPion) + track -> GetPID(AliPID::kKaon) + track -> GetPID(AliPID::kProton)){
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)){
200 else if(track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kMuon) && track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kPion)){
203 else if(track -> GetPID(AliPID::kMuon) > track -> GetPID(AliPID::kPion)){
212 //_______________________________________________________
213 TH1 *AliTRDpidChecker::PlotLQ(const AliTRDtrackV1 *track)
216 // Plot the probabilities for electrons using 2-dim LQ
219 if(track) fTrack = track;
221 AliWarning("No Track defined.");
225 if(!CheckTrackQuality(fTrack)) return 0x0;
227 if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
228 AliWarning("No Histogram defined.");
232 if(!(hPIDLQ = dynamic_cast<TH2F *>(fEfficiency->At(kLQ)))){
233 AliWarning("No Histogram defined.");
237 AliTRDtrackV1 cTrack(*fTrack);
238 cTrack.SetReconstructor(fReconstructor);
241 Float_t momentum = 0.;
244 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
247 //AliWarning("No MC info available!");
248 momentum = cTrack.GetMomentum(0);
249 pdg = CalcPDG(&cTrack);
251 if(momentum < 0.4) return 0x0;;
252 if(momentum > 12.) return 0x0;;
254 fReconstructor -> SetOption("!nn");
256 Int_t iMomBin = fUtil->GetMomentumBin(momentum);
261 hPIDLQ -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
265 hPIDLQ -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
269 hPIDLQ -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
273 hPIDLQ -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, cTrack .GetPID(AliPID::kElectron));
277 hPIDLQ -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
285 //_______________________________________________________
286 TH1 *AliTRDpidChecker::PlotNN(const AliTRDtrackV1 *track)
289 // Plot the probabilities for electrons using 2-dim LQ
292 if(track) fTrack = track;
294 AliWarning("No Track defined.");
298 if(!CheckTrackQuality(fTrack)) return 0x0;
300 if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
301 AliWarning("No Histogram defined.");
305 if(!(hPIDNN = dynamic_cast<TH2F *>(fEfficiency->At(kNN)))){
306 AliWarning("No Histogram defined.");
311 AliTRDtrackV1 cTrack(*fTrack);
312 cTrack.SetReconstructor(fReconstructor);
315 Float_t momentum = 0.;
317 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
320 //AliWarning("No MC info available!");
321 momentum = cTrack.GetMomentum(0);
322 pdg = CalcPDG(&cTrack);
324 if(momentum < 0.4) return 0x0;;
325 if(momentum > 12.) return 0x0;;
327 fReconstructor -> SetOption("nn");
329 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
334 hPIDNN -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
338 hPIDNN -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
342 hPIDNN -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
346 hPIDNN -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
350 hPIDNN -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, cTrack.GetPID(AliPID::kElectron));
357 //_______________________________________________________
358 TH1 *AliTRDpidChecker::PlotESD(const AliTRDtrackV1 *track)
361 // Plot the probabilities for electrons using 2-dim LQ
365 AliWarning("No ESD info available.");
369 if(track) fTrack = track;
371 AliWarning("No Track defined.");
375 if(!CheckTrackQuality(fTrack)) return 0x0;
377 if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
378 AliWarning("No Histogram defined.");
382 if(!(hPIDESD = dynamic_cast<TH2F *>(fEfficiency->At(kESD)))){
383 AliWarning("No Histogram defined.");
389 Float_t momentum = 0.;
391 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
394 //AliWarning("No MC info available!");
395 AliTRDtrackV1 cTrack(*fTrack);
396 cTrack.SetReconstructor(fReconstructor);
397 momentum = cTrack.GetMomentum(0);
398 pdg = CalcPDG(&cTrack);
400 if(momentum < 0.4) return 0x0;;
401 if(momentum > 12.) return 0x0;;
404 Int_t iMomBin = fUtil->GetMomentumBin(momentum);
407 // Double32_t pidESD[AliPID::kSPECIES];
408 const Double32_t *pidESD = fESD->GetResponseIter();
413 hPIDESD -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
417 hPIDESD -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
421 hPIDESD -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
425 hPIDESD -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
429 hPIDESD -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, pidESD[0]);
436 //_______________________________________________________
437 TH1 *AliTRDpidChecker::PlotdEdx(const AliTRDtrackV1 *track)
440 // Plot the probabilities for electrons using 2-dim LQ
443 if(track) fTrack = track;
445 AliWarning("No Track defined.");
449 if(!CheckTrackQuality(fTrack)) return 0x0;
452 if(!(hdEdx = dynamic_cast<TH2F *>(fContainer->At(kdEdx)))){
453 AliWarning("No Histogram defined.");
459 Float_t momentum = 0.;
461 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
464 //AliWarning("No MC info available!");
465 AliTRDtrackV1 cTrack(*fTrack);
466 cTrack.SetReconstructor(fReconstructor);
467 momentum = cTrack.GetMomentum(0);
468 pdg = CalcPDG(&cTrack);
470 if(momentum < 0.4) return 0x0;;
471 if(momentum > 12.) return 0x0;;
473 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
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);
483 Float_t dEdxSlice[AliTRDgeometry::kNlayer][AliTRDReconstructor::kLQslices];
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];
497 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
498 hdEdx -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
502 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
503 hdEdx -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
507 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
508 hdEdx -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
512 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
513 hdEdx -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
517 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
518 hdEdx -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, SumdEdx[iChamb]);
526 //_______________________________________________________
527 TH1 *AliTRDpidChecker::PlotdEdxSlice(const AliTRDtrackV1 *track)
530 // Plot the probabilities for electrons using 2-dim LQ
533 if(track) fTrack = track;
535 AliWarning("No Track defined.");
539 if(!CheckTrackQuality(fTrack)) return 0x0;
542 if(!(hdEdxSlice = dynamic_cast<TH2F *>(fContainer->At(kdEdxSlice)))){
543 AliWarning("No Histogram defined.");
548 Float_t momentum = 0.;
550 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
553 //AliWarning("No MC info available!");
554 AliTRDtrackV1 cTrack(*fTrack);
555 cTrack.SetReconstructor(fReconstructor);
556 momentum = cTrack.GetMomentum(0);
557 pdg = CalcPDG(&cTrack);
559 if(momentum < 0.4) return 0x0;
560 if(momentum > 12.) return 0x0;;
562 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
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);
571 Float_t dEdxSlice[AliTRDgeometry::kNlayer][AliTRDReconstructor::kLQslices];
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];
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]);
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]);
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]);
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]);
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]);
626 //_______________________________________________________
627 TH1 *AliTRDpidChecker::PlotPH(const AliTRDtrackV1 *track)
630 // Plot the probabilities for electrons using 2-dim LQ
633 if(track) fTrack = track;
635 AliWarning("No Track defined.");
639 if(!CheckTrackQuality(fTrack)) return 0x0;
642 if(!(hPH = dynamic_cast<TProfile2D *>(fContainer->At(kPH)))){
643 AliWarning("No Histogram defined.");
648 Float_t momentum = 0.;
650 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
653 //AliWarning("No MC info available!");
654 AliTRDtrackV1 cTrack(*fTrack);
655 cTrack.SetReconstructor(fReconstructor);
656 momentum = cTrack.GetMomentum(0);
657 pdg = CalcPDG(&cTrack);
659 if(momentum < 0.4) return 0x0;;
660 if(momentum > 12.) return 0x0;;
662 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
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);
668 AliTRDcluster *TRDcluster = 0x0;
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)))
677 hPH -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
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)))
687 hPH -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
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)))
697 hPH -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
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)))
707 hPH -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
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)))
717 hPH -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, TRDcluster -> GetLocalTimeBin(), TRDtracklet[iChamb] -> GetdQdl(iClus));
727 //_______________________________________________________
728 TH1 *AliTRDpidChecker::PlotNClus(const AliTRDtrackV1 *track)
731 // Plot the probabilities for electrons using 2-dim LQ
734 if(track) fTrack = track;
736 AliWarning("No Track defined.");
740 if(!CheckTrackQuality(fTrack)) return 0x0;
743 if(!(hNClus = dynamic_cast<TH2F *>(fContainer->At(kNClus)))){
744 AliWarning("No Histogram defined.");
750 Float_t momentum = 0.;
752 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
755 //AliWarning("No MC info available!");
756 AliTRDtrackV1 cTrack(*fTrack);
757 cTrack.SetReconstructor(fReconstructor);
758 momentum = cTrack.GetMomentum(0);
759 pdg = CalcPDG(&cTrack);
761 if(momentum < 0.4) return 0x0;;
762 if(momentum > 12.) return 0x0;;
764 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
767 Int_t iNClus[AliTRDgeometry::kNlayer];
768 memset(iNClus, 0, sizeof(Int_t) * AliTRDgeometry::kNlayer);
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();
780 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
781 hNClus -> Fill(AliPID::kElectron * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
785 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
786 hNClus -> Fill(AliPID::kMuon * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
790 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
791 hNClus -> Fill(AliPID::kPion * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
795 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
796 hNClus -> Fill(AliPID::kKaon * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
800 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++)
801 hNClus -> Fill(AliPID::kProton * AliTRDCalPID::kNMom + iMomBin, iNClus[iChamb]);
809 //_______________________________________________________
810 TH1 *AliTRDpidChecker::PlotMom(const AliTRDtrackV1 *track)
813 // Plot the probabilities for electrons using 2-dim LQ
816 if(track) fTrack = track;
818 AliWarning("No Track defined.");
822 if(!CheckTrackQuality(fTrack)) return 0x0;
825 if(!(hMom = dynamic_cast<TH1F *>(fContainer->At(kMomentum)))){
826 AliWarning("No Histogram defined.");
832 Float_t momentum = 0.;
834 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
837 //AliWarning("No MC info available!");
838 AliTRDtrackV1 cTrack(*fTrack);
839 cTrack.SetReconstructor(fReconstructor);
840 momentum = cTrack.GetMomentum(0);
841 pdg = CalcPDG(&cTrack);
843 if(momentum < 0.4) return 0x0;
844 if(momentum > 12.) return 0x0;;
846 hMom -> Fill(momentum);
851 //_______________________________________________________
852 TH1 *AliTRDpidChecker::PlotMomBin(const AliTRDtrackV1 *track)
855 // Plot the probabilities for electrons using 2-dim LQ
858 if(track) fTrack = track;
860 AliWarning("No Track defined.");
864 if(!CheckTrackQuality(fTrack)) return 0x0;
867 if(!(hMomBin = dynamic_cast<TH1F *>(fContainer->At(kMomentumBin)))){
868 AliWarning("No Histogram defined.");
874 Float_t momentum = 0.;
877 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
880 //AliWarning("No MC info available!");
881 AliTRDtrackV1 cTrack(*fTrack);
882 cTrack.SetReconstructor(fReconstructor);
883 momentum = cTrack.GetMomentum(0);
884 pdg = CalcPDG(&cTrack);
886 if(momentum < 0.4) return 0x0;
887 if(momentum > 12.) return 0x0;;
889 Int_t iMomBin = fUtil -> GetMomentumBin(momentum);
890 hMomBin -> Fill(iMomBin);
895 //________________________________________________________
896 Bool_t AliTRDpidChecker::GetRefFigure(Int_t ifig)
898 Bool_t FIRST = kTRUE;
899 TLegend *leg = new TLegend(.7, .7, .98, .98);
900 leg->SetBorderSize(1);
901 TGraphErrors *g = 0x0;
903 TH1 *h1 = 0x0, *h=0x0;
907 if(!(g = (TGraphErrors*)fGraph->At(kLQ))) break;
908 if(!g->GetN()) break;
909 leg->SetHeader("PID Method");
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;
921 leg->AddEntry(g, "NN", "pl");
922 if(! (g = (TGraphErrors*)fGraph->At(kESD))) break;
924 leg->AddEntry(g, "ESD", "pl");
932 // save 2.0 GeV projection as reference
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");
956 // save 2.0 GeV projection as reference
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));
968 h1->GetXaxis()->SetTitle("tb[1/100 ns^{-1}]");
969 h1->GetYaxis()->SetTitle("<PH> [a.u.]");
971 h = (TH1F*)h1->DrawClone(FIRST ? "c" : "samec");
972 leg->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "pl");
983 // save 2.0 GeV projection as reference
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");
1010 if(!(g = (TGraphErrors*)fGraph->At(kLQ+3))) break;
1011 if(!g->GetN()) break;
1012 leg->SetHeader("PID Method");
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;
1024 leg->AddEntry(g, "NN", "pl");
1025 if(!(g = (TGraphErrors*)fGraph->At(kESD+3))) break;
1027 leg->AddEntry(g, "ESD", "pl");
1034 AliInfo(Form("Reference plot [%d] missing result", ifig));
1038 //________________________________________________________________________
1039 Bool_t AliTRDpidChecker::PostProcess()
1041 // Draw result to the screen
1042 // Called once at the end of the query
1045 Printf("ERROR: list not available");
1048 if(!(fEfficiency = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
1049 AliError("Efficiency container missing.");
1053 fGraph = new TObjArray(6);
1055 EvaluatePionEfficiency(fEfficiency, fGraph, 0.9);
1061 //________________________________________________________________________
1062 void AliTRDpidChecker::EvaluatePionEfficiency(TObjArray *histoContainer, TObjArray *results, Float_t electron_efficiency){
1063 TGraphErrors *g = 0x0;
1064 fUtil->SetElectronEfficiency(electron_efficiency);
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);
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);
1098 TH1D *Histo1=0x0, *Histo2=0x0;
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);
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);
1108 if(!fUtil->CalculatePionEffi(Histo1, Histo2)) continue;
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.);
1117 if(fDebugLevel>=2) Printf("Pion Efficiency for 2-dim LQ is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
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);
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);
1129 if(!fUtil -> CalculatePionEffi(Histo1, Histo2)) continue;
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.);
1138 if(fDebugLevel>=2) Printf("Pion Efficiency for NN is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
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);
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);
1150 if(!fUtil->CalculatePionEffi(Histo1, Histo2)) continue;
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.);
1159 if(fDebugLevel>=2) Printf("Pion Efficiency for ESD is : %f +/- %f\n\n", fUtil->GetPionEfficiency(), fUtil->GetError());
1164 //________________________________________________________________________
1165 void AliTRDpidChecker::Terminate(Option_t *)
1167 // Draw result to the screen
1168 // Called once at the end of the query
1170 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
1172 Printf("ERROR: list not available");