1 //////////////////////////////////////////////////////
3 // PID performance checker of the TRD
5 // Performs checks of ESD information for TRD-PID and recalculate PID based on OCDB information
6 // Also provides performance plots on detector based on the PID information - for the moment only
7 // MC source is used but V0 is also possible. Here is a list of detector performance checks
8 // - Integrated dE/dx per chamber
9 // - <PH> as function of time bin and local radial position
10 // - number of clusters/tracklet
11 // - number of tracklets/track
13 // Author : Alex Wilk <wilka@uni-muenster.de>
14 // Alex Bercuci <A.Bercuci@gsi.de>
15 // Markus Fasel <M.Fasel@gsi.de>
17 ///////////////////////////////////////////////////////
28 #include "TProfile2D.h"
30 #include "TGraphErrors.h"
33 #include <TClonesArray.h>
34 #include <TObjArray.h>
37 #include "AliESDEvent.h"
38 #include "AliESDInputHandler.h"
39 #include "AliTrackReference.h"
41 #include "AliAnalysisTask.h"
43 #include "AliTRDtrackerV1.h"
44 #include "AliTRDtrackV1.h"
45 #include "AliTRDcluster.h"
46 #include "AliTRDReconstructor.h"
47 #include "AliCDBManager.h"
48 #include "AliTRDpidUtil.h"
50 #include "Cal/AliTRDCalPID.h"
51 #include "Cal/AliTRDCalPIDNN.h"
52 #include "AliTRDcheckPID.h"
53 #include "AliTRDinfoGen.h"
54 #include "info/AliTRDtrackInfo.h"
55 #include "info/AliTRDpidInfo.h"
56 #include "info/AliTRDv0Info.h"
58 Char_t const * AliTRDcheckPID::fgMethod[3] = {"LQ", "NN", "ESD"};
60 ClassImp(AliTRDcheckPID)
62 //________________________________________________________________________
63 AliTRDcheckPID::AliTRDcheckPID()
70 ,fMinNTracklets(AliTRDgeometry::kNlayer)
71 ,fMaxNTracklets(AliTRDgeometry::kNlayer)
74 // Default constructor
76 SetNameTitle("TRDcheckPID", "Check TRD PID");
80 //________________________________________________________________________
81 AliTRDcheckPID::AliTRDcheckPID(char* name )
82 :AliTRDrecoTask(name, "Check TRD PID")
88 ,fMinNTracklets(AliTRDgeometry::kNlayer)
89 ,fMaxNTracklets(AliTRDgeometry::kNlayer)
92 // Default constructor
98 DefineInput(3, TObjArray::Class()); // v0 list
99 DefineOutput(2, TObjArray::Class()); // pid info list
103 //________________________________________________________________________
104 void AliTRDcheckPID::LocalInit()
106 // Initialize working data
108 // Initialize momentum axis with default values
109 Double_t defaultMomenta[AliTRDCalPID::kNMom+1];
110 for(Int_t imom = 0; imom < AliTRDCalPID::kNMom+1; imom++)
111 defaultMomenta[imom] = AliTRDCalPID::GetMomentumBinning(imom);
112 SetMomentumBinning(AliTRDCalPID::kNMom, defaultMomenta);
114 memset(fEfficiency, 0, AliPID::kSPECIES*sizeof(TObjArray*));
116 fUtil = new AliTRDpidUtil();
119 //________________________________________________________________________
120 AliTRDcheckPID::~AliTRDcheckPID()
122 if(fPID){fPID->Delete(); delete fPID;}
123 if(fGraph){fGraph->Delete(); delete fGraph;}
124 if(fUtil) delete fUtil;
128 //________________________________________________________________________
129 void AliTRDcheckPID::UserCreateOutputObjects()
134 AliTRDrecoTask::UserCreateOutputObjects();
135 fPID = new TObjArray();
136 fPID->SetOwner(kTRUE);
140 //________________________________________________________
141 void AliTRDcheckPID::UserExec(Option_t *opt)
147 fV0s = dynamic_cast<TObjArray *>(GetInputData(3));
150 AliTRDrecoTask::UserExec(opt);
154 //_______________________________________________________
155 TObjArray * AliTRDcheckPID::Histos(){
158 // Create QA histograms
160 if(fContainer) return fContainer;
162 Int_t xBins = AliPID::kSPECIES*fMomentumAxis->GetNbins();
163 fContainer = new TObjArray(); fContainer->Expand(kNPlots); fContainer->SetOwner(kTRUE);
165 const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1)); // get nice histos with bin center at 0 and 1
168 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
169 // histos with posterior probabilities for all particle species
170 for(Int_t is=AliPID::kSPECIES; is--;){
171 fEfficiency[is] = new TObjArray(kNmethodsPID);
172 fEfficiency[is]->SetOwner();
173 fEfficiency[is]->SetName(Form("Eff_%s", AliPID::ParticleShortName(is)));
174 fContainer->AddAt(fEfficiency[is], is?kEfficiencyMu+is-1:kEfficiency);
175 for(Int_t im=kNmethodsPID; im--;){
176 if(!(h = (TH2F*)gROOT->FindObject(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is))))) {
177 h = new TH2F(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is)), "", xBins, -0.5, xBins - 0.5,
178 AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
180 fEfficiency[is]->AddAt(h, im);
184 // histos of the dE/dx distribution for all 5 particle species and 11 momenta
185 if(!(h = (TH2F*)gROOT->FindObject("dEdx"))){
186 h = new TH2F("dEdx", "",
187 xBins, -0.5, xBins - 0.5,
191 fContainer->AddAt(h, kdEdx);
193 // histos of the dE/dx slices for all 5 particle species and 11 momenta
194 if(!(h = (TH2F*)gROOT->FindObject("dEdxSlice"))){
195 h = new TH2F("dEdxSlice", "",
196 xBins*AliTRDpidUtil::kLQslices, -0.5, xBins*AliTRDpidUtil::kLQslices - 0.5,
199 fContainer->AddAt(h, kdEdxSlice);
201 // histos of the pulse height distribution for all 5 particle species and 11 momenta
202 TObjArray *fPH = new TObjArray(2);
203 fPH->SetOwner(); fPH->SetName("PH");
204 fContainer->AddAt(fPH, kPH);
205 if(!(h = (TProfile2D*)gROOT->FindObject("PHT"))){
206 h = new TProfile2D("PHT", "<PH>(tb);p*species;tb [100*ns];entries",
207 xBins, -0.5, xBins - 0.5,
208 AliTRDseedV1::kNtb, -0.5, AliTRDseedV1::kNtb - 0.5);
211 if(!(h = (TProfile2D*)gROOT->FindObject("PHX"))){
212 h = new TProfile2D("PHX", "<PH>(x);p*species;x_{drift} [cm];entries",
213 xBins, -0.5, xBins - 0.5,
218 // histos of the number of clusters distribution for all 5 particle species and 11 momenta
219 if(!(h = (TH2F*)gROOT->FindObject("NClus"))){
220 h = new TH2F("NClus", "",
221 xBins, -0.5, xBins - 0.5,
224 fContainer->AddAt(h, kNClus);
227 // momentum distributions - absolute and in momentum bins
228 if(!(h = (TH1F*)gROOT->FindObject("hMom"))){
229 h = new TH1F("hMom", "momentum distribution", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
231 fContainer->AddAt(h, kMomentum);
233 if(!(h = (TH1F*)gROOT->FindObject("hMomBin"))){
234 h = new TH1F("hMomBin", "momentum distribution in momentum bins", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
236 fContainer->AddAt(h, kMomentumBin);
238 // Number of tracklets per track
239 if(!(h = (TH2F*)gROOT->FindObject("nTracklets"))){
240 h = new TH2F("nTracklets", "",
241 xBins, -0.5, xBins - 0.5,
242 AliTRDgeometry::kNlayer, 0.5, AliTRDgeometry::kNlayer+.5);
244 fContainer->AddAt(h, kNTracklets);
247 if(!(h = (TH1F*)gROOT->FindObject("nV0"))){
248 h = new TH1F("nV0", "V0s/track;v0/track;entries",
251 fContainer->AddAt(h, kV0);
253 // dQ/dl for 1D-Likelihood
254 if(!(h = (TH1F *)gROOT->FindObject("dQdl"))){
255 h = new TH2F("dQdl", "dQ/dl per layer;p*species;dQ/dl [a.u.]", xBins, -0.5, xBins - 0.5, 800, 0., 40000.);
257 fContainer->AddAt(h, kdQdl);
263 //________________________________________________________________________
264 Bool_t AliTRDcheckPID::CheckTrackQuality(const AliTRDtrackV1* track) const
267 // Check if the track is ok for PID
270 Int_t ntracklets = track->GetNumberOfTracklets();
271 if(ntracklets >= fMinNTracklets && ntracklets <= fMaxNTracklets) return 1;
278 //________________________________________________________________________
279 Int_t AliTRDcheckPID::CalcPDG(AliTRDtrackV1* track)
281 // Documentation to come
283 /* track -> SetReconstructor(AliTRDinfoGen::Reconstructor());
284 (const_cast<AliTRDrecoParam*>(AliTRDinfoGen::Reconstructor()->GetRecoParam()))->SetPIDNeuralNetwork();
285 track -> CookPID();*/
287 if(track -> GetPID(AliPID::kElectron) > track -> GetPID(AliPID::kMuon) + track -> GetPID(AliPID::kPion) + track -> GetPID(AliPID::kKaon) + track -> GetPID(AliPID::kProton)){
290 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)){
293 else if(track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kMuon) && track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kPion)){
296 else if(track -> GetPID(AliPID::kMuon) > track -> GetPID(AliPID::kPion)){
305 //_______________________________________________________
306 TH1 *AliTRDcheckPID::PlotLQ(const AliTRDtrackV1 *track)
309 // Plot the probabilities for electrons using 2-dim LQ
313 AliDebug(2, "No ESD info available.");
317 if(track) fkTrack = track;
319 AliDebug(2, "No Track defined.");
324 status = fkESD -> GetStatus();
325 if(!(status&AliESDtrack::kTRDin)) return NULL;
327 if(!CheckTrackQuality(fkTrack)) return NULL;
329 AliTRDtrackV1 cTrack(*fkTrack);
330 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
333 Float_t momentum = 0.;
336 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
337 pdg = fkMC->GetPDG();
339 //AliWarning("No MC info available!");
340 momentum = cTrack.GetMomentum(0);
341 pdg = CalcPDG(&cTrack);
343 if(!IsInRange(momentum)) return NULL;
345 (const_cast<AliTRDrecoParam*>(AliTRDinfoGen::Reconstructor()->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
347 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
348 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
351 TObjArray *eff(NULL);
352 for(Int_t is=AliPID::kSPECIES; is--;){
353 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
354 AliWarning("No Histogram List defined.");
357 if(!(hPIDLQ = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kLQ)))){
358 AliWarning("No Histogram defined.");
362 hPIDLQ -> Fill(FindBin(species, momentum), cTrack.GetPID(is));
370 //_______________________________________________________
371 TH1 *AliTRDcheckPID::PlotNN(const AliTRDtrackV1 *track)
374 // Plot the probabilities for electrons using 2-dim LQ
378 AliDebug(2, "No ESD info available.");
382 if(track) fkTrack = track;
384 AliDebug(2, "No Track defined.");
389 status = fkESD -> GetStatus();
390 if(!(status&AliESDtrack::kTRDin)) return NULL;
392 if(!CheckTrackQuality(fkTrack)) return NULL;
394 AliTRDtrackV1 cTrack(*fkTrack);
395 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
398 Float_t momentum = 0.;
400 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
401 pdg = fkMC->GetPDG();
403 //AliWarning("No MC info available!");
404 momentum = cTrack.GetMomentum(0);
405 pdg = CalcPDG(&cTrack);
407 if(!IsInRange(momentum)) return NULL;
409 (const_cast<AliTRDrecoParam*>(AliTRDinfoGen::Reconstructor()->GetRecoParam()))->SetPIDNeuralNetwork();
411 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
413 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
417 TObjArray *eff(NULL);
418 for(Int_t is=AliPID::kSPECIES; is--;){
419 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
420 AliWarning("No Histogram List defined.");
423 if(!(hPIDNN = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kNN)))){
424 AliWarning("No Histogram defined.");
428 hPIDNN->Fill(FindBin(species, momentum), cTrack.GetPID(is));
435 //_______________________________________________________
436 TH1 *AliTRDcheckPID::PlotESD(const AliTRDtrackV1 *track)
439 // Plot the probabilities for electrons using 2-dim LQ
443 AliDebug(2, "No ESD info available.");
447 if(track) fkTrack = track;
449 AliDebug(2, "No Track defined.");
454 status = fkESD -> GetStatus();
455 if(!(status&AliESDtrack::kTRDin)) return NULL;
457 if(!CheckTrackQuality(fkTrack)) return NULL;
458 if(fkTrack->GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
461 Float_t momentum = 0.;
463 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
464 pdg = fkMC->GetPDG();
466 //AliWarning("No MC info available!");
467 AliTRDtrackV1 cTrack(*fkTrack);
468 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
469 momentum = cTrack.GetMomentum(0);
470 pdg = CalcPDG(&cTrack);
472 if(!IsInRange(momentum)) return NULL;
474 const Double32_t *pidESD = fkESD->GetResponseIter();
475 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
478 TObjArray *eff(NULL);
479 for(Int_t is=AliPID::kSPECIES; is--;){
480 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
481 AliWarning("No Histogram List defined.");
484 if(!(hPID = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kESD)))){
485 AliWarning("No Histogram defined.");
489 hPID->Fill(FindBin(species, momentum), pidESD[is]);
496 //_______________________________________________________
497 TH1 *AliTRDcheckPID::PlotdQdl(const AliTRDtrackV1 *track){
499 // Plot the total charge for the 1D Likelihood method
501 if(track) fkTrack = track;
503 AliDebug(2, "No Track defined");
506 TH2 *hdQdl = dynamic_cast<TH2F *>(fContainer->At(kdQdl));
508 AliWarning("No Histogram defined");
512 if(!CheckTrackQuality(fkTrack)) return NULL;
515 Float_t momentum = 0.;
516 AliTRDtrackV1 cTrack(*fkTrack);
518 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
519 pdg = fkMC->GetPDG();
521 //AliWarning("No MC info available!");
522 momentum = cTrack.GetMomentum(0);
523 pdg = CalcPDG(&cTrack);
525 if(!IsInRange(momentum)) return NULL;
527 // Init exchange container
528 Int_t s(AliTRDpidUtil::Pdg2Pid(pdg));
529 Int_t ibin = FindBin(s, momentum);
531 AliTRDseedV1 *tracklet = NULL;
532 for(Int_t iseed = 0; iseed < 6; iseed++){
533 if(!((tracklet = fkTrack->GetTracklet(iseed)) && tracklet->IsOK())) continue;
534 hdQdl->Fill(ibin, tracklet->GetdQdl());
539 //_______________________________________________________
540 TH1 *AliTRDcheckPID::PlotdEdx(const AliTRDtrackV1 *track)
543 // Plot the probabilities for electrons using 2-dim LQ
546 if(track) fkTrack = track;
548 AliDebug(2, "No Track defined.");
552 if(!CheckTrackQuality(fkTrack)) return NULL;
555 if(!(hdEdx = dynamic_cast<TH2F *>(fContainer->At(kdEdx)))){
556 AliWarning("No Histogram defined.");
560 AliTRDtrackV1 cTrack(*fkTrack);
561 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
563 Float_t momentum = 0.;
565 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
566 pdg = fkMC->GetPDG();
568 //AliWarning("No MC info available!");
569 momentum = cTrack.GetMomentum(0);
570 pdg = CalcPDG(&cTrack);
572 if(!IsInRange(momentum)) return NULL;
574 // Init exchange container
575 Int_t s(AliTRDpidUtil::Pdg2Pid(pdg));
576 AliTRDpidInfo *pid = new AliTRDpidInfo(s);
578 (const_cast<AliTRDrecoParam*>(AliTRDinfoGen::Reconstructor()->GetRecoParam()))->SetPIDNeuralNetwork(kTRUE);
581 Int_t iBin = FindBin(s, momentum);
582 AliTRDseedV1 *tracklet = NULL;
583 for(Int_t ily = 0; ily < AliTRDgeometry::kNlayer; ily++){
584 tracklet = cTrack.GetTracklet(ily);
585 if(!tracklet) continue;
586 tracklet -> CookdEdx(AliTRDpidUtil::kNNslices);
588 // fill exchange container
589 pid->PushBack(tracklet->GetPlane(),
590 AliTRDpidUtil::GetMomentumBin(tracklet->GetMomentum()), tracklet->GetdEdx());
593 for(Int_t i = AliTRDpidUtil::kNNslices; i--;) sumdEdx += tracklet->GetdEdx()[i];
594 sumdEdx /= AliTRDCalPIDNN::kMLPscale;
595 hdEdx -> Fill(iBin, sumdEdx);
603 //_______________________________________________________
604 TH1 *AliTRDcheckPID::PlotdEdxSlice(const AliTRDtrackV1 *track)
607 // Plot the probabilities for electrons using 2-dim LQ
610 if(track) fkTrack = track;
612 AliDebug(2, "No Track defined.");
616 if(!CheckTrackQuality(fkTrack)) return NULL;
619 if(!(hdEdxSlice = dynamic_cast<TH2F *>(fContainer->At(kdEdxSlice)))){
620 AliWarning("No Histogram defined.");
624 AliTRDtrackV1 cTrack(*fkTrack);
625 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
627 Float_t momentum = 0.;
629 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
630 pdg = fkMC->GetPDG();
632 //AliWarning("No MC info available!");
633 momentum = cTrack.GetMomentum(0);
634 pdg = CalcPDG(&cTrack);
636 if(!IsInRange(momentum)) return NULL;
638 (const_cast<AliTRDrecoParam*>(AliTRDinfoGen::Reconstructor()->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
639 Int_t iMomBin = fMomentumAxis->FindBin(momentum);
640 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
642 AliTRDseedV1 *tracklet = NULL;
643 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
644 tracklet = cTrack.GetTracklet(iChamb);
645 if(!tracklet) continue;
646 tracklet -> CookdEdx(AliTRDpidUtil::kLQslices);
647 fdEdx = const_cast<Float_t *>(tracklet->GetdEdx());
648 for(Int_t iSlice = 0; iSlice < AliTRDpidUtil::kLQslices; iSlice++){
649 hdEdxSlice -> Fill(species * fMomentumAxis->GetNbins() * AliTRDpidUtil::kLQslices + (iMomBin-1) * AliTRDpidUtil::kLQslices + iSlice, fdEdx[iSlice]);
657 //_______________________________________________________
658 TH1 *AliTRDcheckPID::PlotPH(const AliTRDtrackV1 *track)
661 // Plot the probabilities for electrons using 2-dim LQ
664 if(track) fkTrack = track;
666 AliDebug(2, "No Track defined.");
670 if(!CheckTrackQuality(fkTrack)) return NULL;
672 TObjArray *arr = NULL;
673 TProfile2D *hPHX, *hPHT;
674 if(!(arr = dynamic_cast<TObjArray *>(fContainer->At(kPH)))){
675 AliWarning("No Histogram defined.");
678 hPHT = (TProfile2D*)arr->At(0);
679 hPHX = (TProfile2D*)arr->At(1);
682 Float_t momentum = 0.;
684 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
685 pdg = fkMC->GetPDG();
687 //AliWarning("No MC info available!");
688 AliTRDtrackV1 cTrack(*fkTrack);
689 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
690 momentum = cTrack.GetMomentum(0);
691 pdg = CalcPDG(&cTrack);
693 if(!IsInRange(momentum)) return NULL;;
695 AliTRDseedV1 *tracklet = NULL;
696 AliTRDcluster *cluster = NULL;
697 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
698 Int_t iBin = FindBin(species, momentum);
699 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
700 tracklet = fkTrack->GetTracklet(iChamb);
701 if(!tracklet) continue;
702 Float_t x0 = tracklet->GetX0();
703 for(Int_t ic = 0; ic < AliTRDseedV1::kNclusters; ic++){
704 if(!(cluster = tracklet->GetClusters(ic))) continue;
705 hPHT -> Fill(iBin, cluster->GetLocalTimeBin(), TMath::Abs(cluster->GetQ()));
706 if(ic<AliTRDseedV1::kNtb) hPHX -> Fill(iBin, x0 - cluster->GetX(), tracklet->GetdQdl(ic));
713 //_______________________________________________________
714 TH1 *AliTRDcheckPID::PlotNClus(const AliTRDtrackV1 *track)
717 // Plot the probabilities for electrons using 2-dim LQ
720 if(track) fkTrack = track;
722 AliDebug(2, "No Track defined.");
726 if(!CheckTrackQuality(fkTrack)) return NULL;
729 if(!(hNClus = dynamic_cast<TH2F *>(fContainer->At(kNClus)))){
730 AliWarning("No Histogram defined.");
736 Float_t momentum = 0.;
738 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
739 pdg = fkMC->GetPDG();
741 //AliWarning("No MC info available!");
742 AliTRDtrackV1 cTrack(*fkTrack);
743 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
744 momentum = cTrack.GetMomentum(0);
745 pdg = CalcPDG(&cTrack);
747 if(!IsInRange(momentum)) return NULL;
749 Int_t species = AliTRDpidUtil::AliTRDpidUtil::Pdg2Pid(pdg);
750 Int_t iBin = FindBin(species, momentum);
751 AliTRDseedV1 *tracklet = NULL;
752 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
753 tracklet = fkTrack->GetTracklet(iChamb);
754 if(!tracklet) continue;
755 hNClus -> Fill(iBin, tracklet->GetN());
761 //_______________________________________________________
762 TH1 *AliTRDcheckPID::PlotNTracklets(const AliTRDtrackV1 *track)
765 // Plot the probabilities for electrons using 2-dim LQ
768 if(track) fkTrack = track;
770 AliDebug(2, "No Track defined.");
775 if(!(hTracklets = dynamic_cast<TH2F *>(fContainer->At(kNTracklets)))){
776 AliWarning("No Histogram defined.");
780 AliTRDtrackV1 cTrack(*fkTrack);
781 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
783 Float_t momentum = 0.;
785 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
786 pdg = fkMC->GetPDG();
788 //AliWarning("No MC info available!");
789 momentum = cTrack.GetMomentum();
790 pdg = CalcPDG(&cTrack);
792 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
793 if(!IsInRange(momentum)) return NULL;
795 Int_t iBin = FindBin(species, momentum);
796 hTracklets -> Fill(iBin, cTrack.GetNumberOfTracklets());
800 //_______________________________________________________
801 TH1 *AliTRDcheckPID::PlotMom(const AliTRDtrackV1 *track)
804 // Plot the probabilities for electrons using 2-dim LQ
807 if(track) fkTrack = track;
809 AliDebug(2, "No Track defined.");
813 if(!CheckTrackQuality(fkTrack)) return NULL;
816 if(!(hMom = dynamic_cast<TH1F *>(fContainer->At(kMomentum)))){
817 AliWarning("No Histogram defined.");
823 Float_t momentum = 0.;
825 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
826 pdg = fkMC->GetPDG();
828 //AliWarning("No MC info available!");
829 AliTRDtrackV1 cTrack(*fkTrack);
830 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
831 momentum = cTrack.GetMomentum(0);
832 pdg = CalcPDG(&cTrack);
834 if(IsInRange(momentum)) hMom -> Fill(momentum);
839 //_______________________________________________________
840 TH1 *AliTRDcheckPID::PlotMomBin(const AliTRDtrackV1 *track)
843 // Plot the probabilities for electrons using 2-dim LQ
846 if(track) fkTrack = track;
848 AliDebug(2, "No Track defined.");
852 if(!CheckTrackQuality(fkTrack)) return NULL;
855 if(!(hMomBin = dynamic_cast<TH1F *>(fContainer->At(kMomentumBin)))){
856 AliWarning("No Histogram defined.");
862 Float_t momentum = 0.;
865 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
866 pdg = fkMC->GetPDG();
868 //AliWarning("No MC info available!");
869 AliTRDtrackV1 cTrack(*fkTrack);
870 cTrack.SetReconstructor(AliTRDinfoGen::Reconstructor());
871 momentum = cTrack.GetMomentum(0);
873 if(IsInRange(momentum)) hMomBin -> Fill(fMomentumAxis->FindBin(momentum));
877 //_______________________________________________________
878 TH1 *AliTRDcheckPID::PlotV0(const AliTRDtrackV1 *track)
881 // Plot the V0 performance against MC
884 if(track) fkTrack = track;
886 AliDebug(2, "No Track defined.");
889 if(!fkESD->HasV0()) return NULL;
891 AliDebug(1, "No MC defined.");
895 AliWarning("No output container defined.");
898 AliDebug(2, Form("TRACK[%d] species[%s][%d]\n", fkESD->GetId(), fkMC->GetPID()>=0?AliPID::ParticleShortName(fkMC->GetPID()):"none", fkMC->GetPDG()));
901 if(!(h = dynamic_cast<TH1F*>(fContainer->At(kV0)))) return NULL;
902 Int_t sgn(0), n(0); AliTRDv0Info *v0(NULL);
903 for(Int_t iv0(fV0s->GetEntriesFast()); iv0--;){
904 if(!(v0=(AliTRDv0Info*)fV0s->At(iv0))) continue;
905 if(!(sgn = v0->HasTrack(fkESD->GetId()))) continue;
906 //for(Int_t is=AliPID::kSPECIES; is--;) v0->GetPID(is, track);
915 //________________________________________________________
916 Bool_t AliTRDcheckPID::GetRefFigure(Int_t ifig)
918 // Steering function to retrieve performance plots
920 Bool_t kFIRST = kTRUE;
921 TGraphErrors *g = NULL;
923 TObjArray *arr = NULL;
924 TH1 *h1 = NULL, *h=NULL;
926 TList *content = NULL;
929 gPad->Divide(2, 1, 1.e-5, 1.e-5);
930 TList *l=gPad->GetListOfPrimitives();
931 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
932 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
934 TLegend *legEff = new TLegend(.64, .84, .98, .98);
935 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
936 legEff->SetFillColor(0);
937 h=new TH1S("hEff", "", 1, .5, 11.);
938 h->SetLineColor(1);h->SetLineWidth(1);
940 ax->SetTitle("p [GeV/c]");
941 ax->SetRangeUser(.5, 11.);
942 ax->SetMoreLogLabels();
944 ax->SetTitle("#epsilon_{#pi} [%]");
946 ax->SetRangeUser(1.e-2, 10.);
948 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kPion)));
949 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
950 if(!g->GetN()) break;
951 legEff->SetHeader("PID Method [PION]");
952 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
953 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
954 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
955 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
956 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
964 pad = ((TVirtualPad*)l->At(1));pad->cd();
965 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
966 h=new TH1S("hThr", "", 1, .5, 11.);
967 h->SetLineColor(1);h->SetLineWidth(1);
969 ax->SetTitle("p [GeV/c]");
970 ax->SetMoreLogLabels();
972 ax->SetTitle("Threshold [%]");
973 ax->SetRangeUser(5.e-2, 1.);
975 content = (TList *)fGraph->FindObject("Thres");
976 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
977 if(!g->GetN()) break;
979 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
981 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
989 gPad->Divide(2, 1, 1.e-5, 1.e-5);
990 TList *l=gPad->GetListOfPrimitives();
991 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
992 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
994 TLegend *legEff = new TLegend(.64, .84, .98, .98);
995 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
996 legEff->SetFillColor(0);
997 h = (TH1S*)gROOT->FindObject("hEff");
998 h=(TH1S*)h->Clone("hEff_K");
999 h->SetYTitle("#epsilon_{K} [%]");
1000 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
1002 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kKaon)));
1003 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
1004 if(!g->GetN()) break;
1005 legEff->SetHeader("PID Method [KAON]");
1006 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
1007 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
1008 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
1009 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
1010 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
1017 TLegend *legEff2 = new TLegend(.64, .84, .98, .98);
1018 legEff2->SetBorderSize(1);legEff2->SetTextSize(0.03255879);
1019 legEff2->SetFillColor(0);
1020 pad = ((TVirtualPad*)l->At(1));pad->cd();
1021 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1022 h=(TH1S*)h->Clone("hEff_p");
1023 h->SetYTitle("#epsilon_{p} [%]");
1024 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
1026 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kProton)));
1027 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
1028 if(!g->GetN()) break;
1029 legEff2->SetHeader("PID Method [PROTON]");
1030 g->Draw("pc"); legEff2->AddEntry(g, "LQ 2D", "pl");
1031 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
1032 g->Draw("pc"); legEff2->AddEntry(g, "NN", "pl");
1033 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
1034 g->Draw("p"); legEff2->AddEntry(g, "ESD", "pl");
1043 // save 2.0 GeV projection as reference
1044 TLegend *legdEdx = new TLegend(.7, .7, .98, .98);
1045 legdEdx->SetBorderSize(1);
1047 if(!(h2 = (TH2F*)(fContainer->At(kdEdx)))) break;
1048 legdEdx->SetHeader("Particle Species");
1049 gPad->SetMargin(0.1, 0.01, 0.1, 0.01);
1050 for(Int_t is = AliPID::kSPECIES-1; is>=0; is--){
1051 Int_t bin = FindBin(is, 2.);
1052 h1 = h2->ProjectionY(Form("px%d", is), bin, bin);
1053 if(!h1->GetEntries()) continue;
1054 h1->Scale(1./h1->Integral());
1055 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1057 h1->GetXaxis()->SetTitle("dE/dx (a.u.)");
1058 h1->GetYaxis()->SetTitle("<Entries>");
1060 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1061 legdEdx->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1075 gPad->Divide(2, 1, 1.e-5, 1.e-5);
1076 TList *l=gPad->GetListOfPrimitives();
1078 // save 2.0 GeV projection as reference
1079 TLegend *legPH = new TLegend(.4, .7, .68, .98);
1080 legPH->SetBorderSize(1);legPH->SetFillColor(0);
1081 legPH->SetHeader("Particle Species");
1082 if(!(arr = (TObjArray*)(fContainer->At(kPH)))) break;
1083 if(!(h2 = (TProfile2D*)(arr->At(0)))) break;
1085 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
1086 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1088 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1089 Int_t bin = FindBin(is, 2.);
1090 h1 = h2->ProjectionY(Form("pyt%d", is), bin, bin);
1091 if(!h1->GetEntries()) continue;
1092 h1->SetMarkerStyle(24);
1093 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1094 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1096 h1->GetXaxis()->SetTitle("t_{drift} [100*ns]");
1097 h1->GetYaxis()->SetTitle("<dQ/dt> [a.u.]");
1099 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1100 legPH->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "pl");
1104 pad = ((TVirtualPad*)l->At(1));pad->cd();
1105 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1106 if(!(h2 = (TProfile2D*)(arr->At(1)))) break;
1108 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1109 Int_t bin = FindBin(is, 2.);
1110 h1 = h2->ProjectionY(Form("pyx%d", is), bin, bin);
1111 if(!h1->GetEntries()) continue;
1112 h1->SetMarkerStyle(24);
1113 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1114 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1116 h1->GetXaxis()->SetTitle("x_{drift} [cm]");
1117 h1->GetYaxis()->SetTitle("<dQ/dl> [a.u./cm]");
1119 h1->DrawClone(kFIRST ? "c" : "samec");
1132 // save 2.0 GeV projection as reference
1133 TLegend *legNClus = new TLegend(.13, .7, .4, .98);
1134 legNClus->SetBorderSize(1);
1135 legNClus->SetFillColor(0);
1138 if(!(h2 = (TH2F*)(fContainer->At(kNClus)))) break;
1139 legNClus->SetHeader("Particle Species");
1140 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1141 Int_t bin = FindBin(is, 2.);
1142 h1 = h2->ProjectionY(Form("pyNClus%d", is), bin, bin);
1143 if(!h1->GetEntries()) continue;
1144 h1->Scale(100./h1->Integral());
1145 //h1->SetMarkerStyle(24);
1146 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1147 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1149 h1->GetXaxis()->SetTitle("N^{cl}/tracklet");
1150 h1->GetYaxis()->SetTitle("Prob. [%]");
1151 h = (TH1F*)h1->DrawClone("c");
1153 h->GetXaxis()->SetRangeUser(0., 35.);
1155 } else h = (TH1F*)h1->DrawClone("samec");
1157 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1171 TLegend *legNClus = new TLegend(.4, .7, .68, .98);
1172 legNClus->SetBorderSize(1);
1174 if(!(h2 = (TH2F*)(fContainer->At(kNTracklets)))) break;
1175 legNClus->SetHeader("Particle Species");
1176 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1177 Int_t bin = FindBin(is, 2.);
1178 h1 = h2->ProjectionY(Form("pyNTracklets%d", is), bin, bin);
1179 if(!h1->GetEntries()) continue;
1180 h1->Scale(100./h1->Integral());
1181 //h1->SetMarkerStyle(24);
1182 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1183 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1185 h1->GetXaxis()->SetTitle("N^{trklt}/track");
1186 h1->GetXaxis()->SetRangeUser(1.,6.);
1187 h1->GetYaxis()->SetTitle("Prob. [%]");
1189 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1190 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1202 AliInfo(Form("Reference plot [%d] missing result", ifig));
1206 //________________________________________________________________________
1207 Bool_t AliTRDcheckPID::PostProcess()
1209 // Draw result to the screen
1210 // Called once at the end of the query
1213 Printf("ERROR: list not available");
1217 TObjArray *eff(NULL);
1219 fGraph = new TObjArray(2*AliPID::kSPECIES);
1222 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
1223 AliError("Efficiency container for Electrons missing.");
1226 EvaluateEfficiency(eff, fGraph, AliPID::kPion, 0.9);
1227 EvaluateEfficiency(eff, fGraph, AliPID::kKaon, 0.9);
1228 EvaluateEfficiency(eff, fGraph, AliPID::kProton, 0.9);
1234 //________________________________________________________________________
1235 void AliTRDcheckPID::EvaluateEfficiency(const TObjArray * const histoContainer, TObjArray *results, Int_t species, Float_t electronEfficiency){
1236 // Process PID information for pion efficiency
1238 fUtil->SetElectronEfficiency(electronEfficiency);
1241 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
1242 Color_t colors[kNmethodsPID] = {kBlue, kGreen+2, kRed};
1243 Int_t markerStyle[kNmethodsPID] = {7, 7, 24};
1244 // efficiency graphs
1245 TGraphErrors *g(NULL);
1246 TObjArray *eff = new TObjArray(kNmethodsPID); eff->SetOwner(); eff->SetName(Form("Eff_%s", AliTRDCalPID::GetPartName(species)));
1247 results->AddAt(eff, species);
1248 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1249 eff->AddAt(g = new TGraphErrors(), iMethod);
1250 g->SetName(Form("%s", fgMethod[iMethod]));
1251 g->SetLineColor(colors[iMethod]);
1252 g->SetMarkerColor(colors[iMethod]);
1253 g->SetMarkerStyle(markerStyle[iMethod]);
1256 // Threshold graphs if not already
1257 TObjArray *thres(NULL);
1258 if(!(results->At(AliPID::kSPECIES))){
1259 thres = new TObjArray(kNmethodsPID); thres->SetOwner();
1260 thres->SetName("Thres");
1261 results->AddAt(thres, AliPID::kSPECIES);
1262 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1263 thres->AddAt(g = new TGraphErrors(), iMethod);
1264 g->SetName(Form("%s", fgMethod[iMethod]));
1265 g->SetLineColor(colors[iMethod]);
1266 g->SetMarkerColor(colors[iMethod]);
1267 g->SetMarkerStyle(markerStyle[iMethod]);
1271 TH2F *hPtr[kNmethodsPID]={
1272 (TH2F*)histoContainer->At(AliTRDpidUtil::kLQ),
1273 (TH2F*)histoContainer->At(AliTRDpidUtil::kNN),
1274 (TH2F*)histoContainer->At(AliTRDpidUtil::kESD)
1276 for(Int_t iMom = 0; iMom < fMomentumAxis->GetNbins(); iMom++){
1277 Float_t mom(fMomentumAxis->GetBinCenter(iMom+1));
1279 Int_t binEl(fMomentumAxis->GetNbins() * AliPID::kElectron + iMom + 1),
1280 binXX(fMomentumAxis->GetNbins() * species + iMom + 1);
1282 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1283 // Calculate the Species Efficiency at electronEfficiency% electron efficiency for each Method
1285 TH1D *histo1 = hPtr[iMethod] -> ProjectionY(Form("%s_el", fgMethod[iMethod]), binEl, binEl);
1286 TH1D *histo2 = hPtr[iMethod] -> ProjectionY(Form("%s_%s", fgMethod[iMethod], AliTRDCalPID::GetPartName(species)), binXX, binXX);
1288 if(!fUtil->CalculatePionEffi(histo1, histo2)) continue;
1290 g=(TGraphErrors*)eff->At(iMethod);
1291 g->SetPoint(iMom, mom, 1.e2*fUtil->GetPionEfficiency());
1292 g->SetPointError(iMom, 0., 1.e2*fUtil->GetError());
1293 AliDebug(2, Form("%s Efficiency for %s is : %f +/- %f", AliTRDCalPID::GetPartName(species), fgMethod[iMethod], fUtil->GetPionEfficiency(), fUtil->GetError()));
1295 if(!thres) continue;
1296 g=(TGraphErrors*)thres->At(iMethod);
1297 g->SetPoint(iMom, mom, fUtil->GetThreshold());
1298 g->SetPointError(iMom, 0., 0.);