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 "info/AliTRDtrackInfo.h"
54 #include "info/AliTRDpidInfo.h"
56 Char_t const * AliTRDcheckPID::fgMethod[3] = {"LQ", "NN", "ESD"};
58 ClassImp(AliTRDcheckPID)
60 //________________________________________________________________________
61 AliTRDcheckPID::AliTRDcheckPID()
68 ,fMinNTracklets(AliTRDgeometry::kNlayer)
69 ,fMaxNTracklets(AliTRDgeometry::kNlayer)
72 // Default constructor
74 SetNameTitle("checkPID", "Check TRD PID");
77 //________________________________________________________________________
78 AliTRDcheckPID::AliTRDcheckPID(char* name )
79 :AliTRDrecoTask(name, "Check TRD PID")
85 ,fMinNTracklets(AliTRDgeometry::kNlayer)
86 ,fMaxNTracklets(AliTRDgeometry::kNlayer)
89 // Default constructor
92 fReconstructor = new AliTRDReconstructor();
93 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
95 // Initialize momentum axis with default values
96 Double_t defaultMomenta[AliTRDCalPID::kNMom+1];
97 for(Int_t imom = 0; imom < AliTRDCalPID::kNMom+1; imom++)
98 defaultMomenta[imom] = AliTRDCalPID::GetMomentumBinning(imom);
99 SetMomentumBinning(AliTRDCalPID::kNMom, defaultMomenta);
101 memset(fEfficiency, 0, AliPID::kSPECIES*sizeof(TObjArray*));
103 fUtil = new AliTRDpidUtil();
106 DefineInput(2, TObjArray::Class()); // v0 list
107 DefineOutput(2, TObjArray::Class()); // pid info list
111 //________________________________________________________________________
112 AliTRDcheckPID::~AliTRDcheckPID()
114 if(fPID){fPID->Delete(); delete fPID;}
115 if(fGraph){fGraph->Delete(); delete fGraph;}
116 if(fReconstructor) delete fReconstructor;
117 if(fUtil) delete fUtil;
121 //________________________________________________________________________
122 void AliTRDcheckPID::UserCreateOutputObjects()
127 OpenFile(1, "RECREATE");
128 fContainer = Histos();
130 fPID = new TObjArray();
131 fPID->SetOwner(kTRUE);
134 //________________________________________________________
135 void AliTRDcheckPID::UserExec(Option_t *opt)
143 AliTRDrecoTask::UserExec(opt);
149 //_______________________________________________________
150 TObjArray * AliTRDcheckPID::Histos(){
153 // Create QA histograms
155 if(fContainer) return fContainer;
157 Int_t xBins = AliPID::kSPECIES*fMomentumAxis->GetNbins();
158 fContainer = new TObjArray(); fContainer->Expand(kNPlots);
160 const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1)); // get nice histos with bin center at 0 and 1
163 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
164 // histos with posterior probabilities for all particle species
165 for(Int_t is=AliPID::kSPECIES; is--;){
166 fEfficiency[is] = new TObjArray(kNmethodsPID);
167 fEfficiency[is]->SetOwner();
168 fEfficiency[is]->SetName(Form("Eff_%s", AliPID::ParticleShortName(is)));
169 fContainer->AddAt(fEfficiency[is], is?kEfficiencyMu+is-1:kEfficiency);
170 for(Int_t im=kNmethodsPID; im--;){
171 if(!(h = (TH2F*)gROOT->FindObject(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is))))) {
172 h = new TH2F(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is)), "", xBins, -0.5, xBins - 0.5,
173 AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
175 fEfficiency[is]->AddAt(h, im);
179 // histos of the dE/dx distribution for all 5 particle species and 11 momenta
180 if(!(h = (TH2F*)gROOT->FindObject("dEdx"))){
181 h = new TH2F("dEdx", "",
182 xBins, -0.5, xBins - 0.5,
186 fContainer->AddAt(h, kdEdx);
188 // histos of the dE/dx slices for all 5 particle species and 11 momenta
189 if(!(h = (TH2F*)gROOT->FindObject("dEdxSlice"))){
190 h = new TH2F("dEdxSlice", "",
191 xBins*AliTRDpidUtil::kLQslices, -0.5, xBins*AliTRDpidUtil::kLQslices - 0.5,
194 fContainer->AddAt(h, kdEdxSlice);
196 // histos of the pulse height distribution for all 5 particle species and 11 momenta
197 TObjArray *fPH = new TObjArray(2);
198 fPH->SetOwner(); fPH->SetName("PH");
199 fContainer->AddAt(fPH, kPH);
200 if(!(h = (TProfile2D*)gROOT->FindObject("PHT"))){
201 h = new TProfile2D("PHT", "",
202 xBins, -0.5, xBins - 0.5,
203 AliTRDtrackerV1::GetNTimeBins(), -0.5, AliTRDtrackerV1::GetNTimeBins() - 0.5);
206 if(!(h = (TProfile2D*)gROOT->FindObject("PHX"))){
207 h = new TProfile2D("PHX", "",
208 xBins, -0.5, xBins - 0.5,
209 AliTRDtrackerV1::GetNTimeBins(), 0., .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght());
213 // histos of the number of clusters distribution for all 5 particle species and 11 momenta
214 if(!(h = (TH2F*)gROOT->FindObject("NClus"))){
215 h = new TH2F("NClus", "",
216 xBins, -0.5, xBins - 0.5,
219 fContainer->AddAt(h, kNClus);
222 // momentum distributions - absolute and in momentum bins
223 if(!(h = (TH1F*)gROOT->FindObject("hMom"))){
224 h = new TH1F("hMom", "momentum distribution", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
226 fContainer->AddAt(h, kMomentum);
228 if(!(h = (TH1F*)gROOT->FindObject("hMomBin"))){
229 h = new TH1F("hMomBin", "momentum distribution in momentum bins", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
231 fContainer->AddAt(h, kMomentumBin);
233 // Number of tracklets per track
234 if(!(h = (TH2F*)gROOT->FindObject("nTracklets"))){
235 h = new TH2F("nTracklets", "",
236 xBins, -0.5, xBins - 0.5,
237 AliTRDgeometry::kNlayer, 0.5, AliTRDgeometry::kNlayer+.5);
239 fContainer->AddAt(h, kNTracklets);
245 //________________________________________________________________________
246 Bool_t AliTRDcheckPID::CheckTrackQuality(const AliTRDtrackV1* track) const
249 // Check if the track is ok for PID
252 Int_t ntracklets = track->GetNumberOfTracklets();
253 if(ntracklets >= fMinNTracklets && ntracklets <= fMaxNTracklets) return 1;
260 //________________________________________________________________________
261 Int_t AliTRDcheckPID::CalcPDG(AliTRDtrackV1* track)
263 // Documentation to come
265 track -> SetReconstructor(fReconstructor);
266 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork();
269 if(track -> GetPID(AliPID::kElectron) > track -> GetPID(AliPID::kMuon) + track -> GetPID(AliPID::kPion) + track -> GetPID(AliPID::kKaon) + track -> GetPID(AliPID::kProton)){
272 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)){
275 else if(track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kMuon) && track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kPion)){
278 else if(track -> GetPID(AliPID::kMuon) > track -> GetPID(AliPID::kPion)){
287 //_______________________________________________________
288 TH1 *AliTRDcheckPID::PlotLQ(const AliTRDtrackV1 *track)
291 // Plot the probabilities for electrons using 2-dim LQ
295 AliDebug(2, "No ESD info available.");
299 if(track) fkTrack = track;
301 AliDebug(2, "No Track defined.");
306 status = fkESD -> GetStatus();
307 if(!(status&AliESDtrack::kTRDin)) return NULL;
309 if(!CheckTrackQuality(fkTrack)) return NULL;
311 AliTRDtrackV1 cTrack(*fkTrack);
312 cTrack.SetReconstructor(fReconstructor);
315 Float_t momentum = 0.;
318 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
319 pdg = fkMC->GetPDG();
321 //AliWarning("No MC info available!");
322 momentum = cTrack.GetMomentum(0);
323 pdg = CalcPDG(&cTrack);
325 if(!IsInRange(momentum)) return NULL;
327 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
329 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
330 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
333 TObjArray *eff(NULL);
334 for(Int_t is=AliPID::kSPECIES; is--;){
335 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
336 AliWarning("No Histogram List defined.");
339 if(!(hPIDLQ = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kLQ)))){
340 AliWarning("No Histogram defined.");
344 hPIDLQ -> Fill(FindBin(species, momentum), cTrack.GetPID(is));
352 //_______________________________________________________
353 TH1 *AliTRDcheckPID::PlotNN(const AliTRDtrackV1 *track)
356 // Plot the probabilities for electrons using 2-dim LQ
360 AliDebug(2, "No ESD info available.");
364 if(track) fkTrack = track;
366 AliDebug(2, "No Track defined.");
371 status = fkESD -> GetStatus();
372 if(!(status&AliESDtrack::kTRDin)) return NULL;
374 if(!CheckTrackQuality(fkTrack)) return NULL;
376 AliTRDtrackV1 cTrack(*fkTrack);
377 cTrack.SetReconstructor(fReconstructor);
380 Float_t momentum = 0.;
382 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
383 pdg = fkMC->GetPDG();
385 //AliWarning("No MC info available!");
386 momentum = cTrack.GetMomentum(0);
387 pdg = CalcPDG(&cTrack);
389 if(!IsInRange(momentum)) return NULL;
391 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork();
393 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
395 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
399 TObjArray *eff(NULL);
400 for(Int_t is=AliPID::kSPECIES; is--;){
401 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
402 AliWarning("No Histogram List defined.");
405 if(!(hPIDNN = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kNN)))){
406 AliWarning("No Histogram defined.");
410 hPIDNN->Fill(FindBin(species, momentum), cTrack.GetPID(is));
417 //_______________________________________________________
418 TH1 *AliTRDcheckPID::PlotESD(const AliTRDtrackV1 *track)
421 // Plot the probabilities for electrons using 2-dim LQ
425 AliDebug(2, "No ESD info available.");
429 if(track) fkTrack = track;
431 AliDebug(2, "No Track defined.");
436 status = fkESD -> GetStatus();
437 if(!(status&AliESDtrack::kTRDin)) return NULL;
439 if(!CheckTrackQuality(fkTrack)) return NULL;
440 if(fkTrack->GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
443 Float_t momentum = 0.;
445 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
446 pdg = fkMC->GetPDG();
448 //AliWarning("No MC info available!");
449 AliTRDtrackV1 cTrack(*fkTrack);
450 cTrack.SetReconstructor(fReconstructor);
451 momentum = cTrack.GetMomentum(0);
452 pdg = CalcPDG(&cTrack);
454 if(!IsInRange(momentum)) return NULL;
456 const Double32_t *pidESD = fkESD->GetResponseIter();
457 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
460 TObjArray *eff(NULL);
461 for(Int_t is=AliPID::kSPECIES; is--;){
462 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
463 AliWarning("No Histogram List defined.");
466 if(!(hPID = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kESD)))){
467 AliWarning("No Histogram defined.");
471 AliTRDpidInfo *pid = new AliTRDpidInfo();
473 hPID->Fill(FindBin(species, momentum), pidESD[is]);
480 //_______________________________________________________
481 TH1 *AliTRDcheckPID::PlotdEdx(const AliTRDtrackV1 *track)
484 // Plot the probabilities for electrons using 2-dim LQ
487 if(track) fkTrack = track;
489 AliDebug(2, "No Track defined.");
493 if(!CheckTrackQuality(fkTrack)) return NULL;
496 if(!(hdEdx = dynamic_cast<TH2F *>(fContainer->At(kdEdx)))){
497 AliWarning("No Histogram defined.");
501 AliTRDtrackV1 cTrack(*fkTrack);
502 cTrack.SetReconstructor(fReconstructor);
504 Float_t momentum = 0.;
506 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
507 pdg = fkMC->GetPDG();
509 //AliWarning("No MC info available!");
510 momentum = cTrack.GetMomentum(0);
511 pdg = CalcPDG(&cTrack);
513 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
514 if(!IsInRange(momentum)) return NULL;
516 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kTRUE);
517 // (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
519 Int_t iBin = FindBin(species, momentum);
520 AliTRDseedV1 *tracklet = NULL;
521 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
523 tracklet = cTrack.GetTracklet(iChamb);
524 if(!tracklet) continue;
525 tracklet -> CookdEdx(AliTRDpidUtil::kNNslices);
526 for(Int_t i = AliTRDpidUtil::kNNslices; i--;) sumdEdx += tracklet->GetdEdx()[i];
527 // tracklet -> CookdEdx(AliTRDpidUtil::kLQslices);
528 // for(Int_t i = 3; i--;) sumdEdx += tracklet->GetdEdx()[i];
529 sumdEdx /= AliTRDCalPIDNN::kMLPscale;
530 hdEdx -> Fill(iBin, sumdEdx);
536 //_______________________________________________________
537 TH1 *AliTRDcheckPID::PlotdEdxSlice(const AliTRDtrackV1 *track)
540 // Plot the probabilities for electrons using 2-dim LQ
543 if(track) fkTrack = track;
545 AliDebug(2, "No Track defined.");
549 if(!CheckTrackQuality(fkTrack)) return NULL;
552 if(!(hdEdxSlice = dynamic_cast<TH2F *>(fContainer->At(kdEdxSlice)))){
553 AliWarning("No Histogram defined.");
557 AliTRDtrackV1 cTrack(*fkTrack);
558 cTrack.SetReconstructor(fReconstructor);
560 Float_t momentum = 0.;
562 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
563 pdg = fkMC->GetPDG();
565 //AliWarning("No MC info available!");
566 momentum = cTrack.GetMomentum(0);
567 pdg = CalcPDG(&cTrack);
569 if(!IsInRange(momentum)) return NULL;
571 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
572 Int_t iMomBin = fMomentumAxis->FindBin(momentum);
573 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
575 AliTRDseedV1 *tracklet = NULL;
576 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
577 tracklet = cTrack.GetTracklet(iChamb);
578 if(!tracklet) continue;
579 tracklet -> CookdEdx(AliTRDpidUtil::kLQslices);
580 fdEdx = const_cast<Float_t *>(tracklet->GetdEdx());
581 for(Int_t iSlice = 0; iSlice < AliTRDpidUtil::kLQslices; iSlice++){
582 hdEdxSlice -> Fill(species * fMomentumAxis->GetNbins() * AliTRDpidUtil::kLQslices + (iMomBin-1) * AliTRDpidUtil::kLQslices + iSlice, fdEdx[iSlice]);
590 //_______________________________________________________
591 TH1 *AliTRDcheckPID::PlotPH(const AliTRDtrackV1 *track)
594 // Plot the probabilities for electrons using 2-dim LQ
597 if(track) fkTrack = track;
599 AliDebug(2, "No Track defined.");
603 if(!CheckTrackQuality(fkTrack)) return NULL;
605 TObjArray *arr = NULL;
606 TProfile2D *hPHX, *hPHT;
607 if(!(arr = dynamic_cast<TObjArray *>(fContainer->At(kPH)))){
608 AliWarning("No Histogram defined.");
611 hPHT = (TProfile2D*)arr->At(0);
612 hPHX = (TProfile2D*)arr->At(1);
615 Float_t momentum = 0.;
617 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
618 pdg = fkMC->GetPDG();
620 //AliWarning("No MC info available!");
621 AliTRDtrackV1 cTrack(*fkTrack);
622 cTrack.SetReconstructor(fReconstructor);
623 momentum = cTrack.GetMomentum(0);
624 pdg = CalcPDG(&cTrack);
626 if(!IsInRange(momentum)) return NULL;;
628 AliTRDseedV1 *tracklet = NULL;
629 AliTRDcluster *cluster = NULL;
630 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
631 Int_t iBin = FindBin(species, momentum);
632 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
633 tracklet = fkTrack->GetTracklet(iChamb);
634 if(!tracklet) continue;
635 Float_t x0 = tracklet->GetX0();
636 for(Int_t ic = 0; ic < AliTRDtrackerV1::GetNTimeBins(); ic++){
637 if(!(cluster = tracklet->GetClusters(ic))) continue;
638 hPHT -> Fill(iBin, cluster->GetLocalTimeBin(), TMath::Abs(cluster->GetQ()));
639 hPHX -> Fill(iBin, x0 - cluster->GetX(), tracklet->GetdQdl(ic));
646 //_______________________________________________________
647 TH1 *AliTRDcheckPID::PlotNClus(const AliTRDtrackV1 *track)
650 // Plot the probabilities for electrons using 2-dim LQ
653 if(track) fkTrack = track;
655 AliDebug(2, "No Track defined.");
659 if(!CheckTrackQuality(fkTrack)) return NULL;
662 if(!(hNClus = dynamic_cast<TH2F *>(fContainer->At(kNClus)))){
663 AliWarning("No Histogram defined.");
669 Float_t momentum = 0.;
671 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
672 pdg = fkMC->GetPDG();
674 //AliWarning("No MC info available!");
675 AliTRDtrackV1 cTrack(*fkTrack);
676 cTrack.SetReconstructor(fReconstructor);
677 momentum = cTrack.GetMomentum(0);
678 pdg = CalcPDG(&cTrack);
680 if(!IsInRange(momentum)) return NULL;
682 Int_t species = AliTRDpidUtil::AliTRDpidUtil::Pdg2Pid(pdg);
683 Int_t iBin = FindBin(species, momentum);
684 AliTRDseedV1 *tracklet = NULL;
685 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
686 tracklet = fkTrack->GetTracklet(iChamb);
687 if(!tracklet) continue;
688 hNClus -> Fill(iBin, tracklet->GetN());
694 //_______________________________________________________
695 TH1 *AliTRDcheckPID::PlotNTracklets(const AliTRDtrackV1 *track)
698 // Plot the probabilities for electrons using 2-dim LQ
701 if(track) fkTrack = track;
703 AliDebug(2, "No Track defined.");
708 if(!(hTracklets = dynamic_cast<TH2F *>(fContainer->At(kNTracklets)))){
709 AliWarning("No Histogram defined.");
713 AliTRDtrackV1 cTrack(*fkTrack);
714 cTrack.SetReconstructor(fReconstructor);
716 Float_t momentum = 0.;
718 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
719 pdg = fkMC->GetPDG();
721 //AliWarning("No MC info available!");
722 momentum = cTrack.GetMomentum(0);
723 pdg = CalcPDG(&cTrack);
725 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
726 if(!IsInRange(momentum)) return NULL;
728 Int_t iBin = FindBin(species, momentum);
729 hTracklets -> Fill(iBin, cTrack.GetNumberOfTracklets());
733 //_______________________________________________________
734 TH1 *AliTRDcheckPID::PlotMom(const AliTRDtrackV1 *track)
737 // Plot the probabilities for electrons using 2-dim LQ
740 if(track) fkTrack = track;
742 AliDebug(2, "No Track defined.");
746 if(!CheckTrackQuality(fkTrack)) return NULL;
749 if(!(hMom = dynamic_cast<TH1F *>(fContainer->At(kMomentum)))){
750 AliWarning("No Histogram defined.");
756 Float_t momentum = 0.;
758 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
759 pdg = fkMC->GetPDG();
761 //AliWarning("No MC info available!");
762 AliTRDtrackV1 cTrack(*fkTrack);
763 cTrack.SetReconstructor(fReconstructor);
764 momentum = cTrack.GetMomentum(0);
765 pdg = CalcPDG(&cTrack);
767 if(IsInRange(momentum)) hMom -> Fill(momentum);
772 //_______________________________________________________
773 TH1 *AliTRDcheckPID::PlotMomBin(const AliTRDtrackV1 *track)
776 // Plot the probabilities for electrons using 2-dim LQ
779 if(track) fkTrack = track;
781 AliDebug(2, "No Track defined.");
785 if(!CheckTrackQuality(fkTrack)) return NULL;
788 if(!(hMomBin = dynamic_cast<TH1F *>(fContainer->At(kMomentumBin)))){
789 AliWarning("No Histogram defined.");
795 Float_t momentum = 0.;
798 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
799 pdg = fkMC->GetPDG();
801 //AliWarning("No MC info available!");
802 AliTRDtrackV1 cTrack(*fkTrack);
803 cTrack.SetReconstructor(fReconstructor);
804 momentum = cTrack.GetMomentum(0);
806 if(IsInRange(momentum)) hMomBin -> Fill(fMomentumAxis->FindBin(momentum));
811 //________________________________________________________
812 Bool_t AliTRDcheckPID::GetRefFigure(Int_t ifig)
814 // Steering function to retrieve performance plots
816 Bool_t kFIRST = kTRUE;
817 TGraphErrors *g = NULL;
819 TObjArray *arr = NULL;
820 TH1 *h1 = NULL, *h=NULL;
822 TList *content = NULL;
825 gPad->Divide(2, 1, 1.e-5, 1.e-5);
826 TList *l=gPad->GetListOfPrimitives();
827 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
828 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
830 TLegend *legEff = new TLegend(.64, .84, .98, .98);
831 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
832 legEff->SetFillColor(0);
833 h=new TH1S("hEff", "", 1, .5, 11.);
834 h->SetLineColor(1);h->SetLineWidth(1);
836 ax->SetTitle("p [GeV/c]");
837 ax->SetRangeUser(.5, 11.);
838 ax->SetMoreLogLabels();
840 ax->SetTitle("#epsilon_{#pi} [%]");
842 ax->SetRangeUser(1.e-2, 10.);
844 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kPion)));
845 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
846 if(!g->GetN()) break;
847 legEff->SetHeader("PID Method [PION]");
848 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
849 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
850 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
851 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
852 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
860 pad = ((TVirtualPad*)l->At(1));pad->cd();
861 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
862 h=new TH1S("hThr", "", 1, .5, 11.);
863 h->SetLineColor(1);h->SetLineWidth(1);
865 ax->SetTitle("p [GeV/c]");
866 ax->SetMoreLogLabels();
868 ax->SetTitle("Threshold [%]");
869 ax->SetRangeUser(5.e-2, 1.);
871 content = (TList *)fGraph->FindObject("Thres");
872 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
873 if(!g->GetN()) break;
875 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
877 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
885 gPad->Divide(2, 1, 1.e-5, 1.e-5);
886 TList *l=gPad->GetListOfPrimitives();
887 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
888 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
890 TLegend *legEff = new TLegend(.64, .84, .98, .98);
891 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
892 legEff->SetFillColor(0);
893 h = (TH1S*)gROOT->FindObject("hEff");
894 h=(TH1S*)h->Clone("hEff_K");
895 h->SetYTitle("#epsilon_{K} [%]");
896 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
898 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kKaon)));
899 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
900 if(!g->GetN()) break;
901 legEff->SetHeader("PID Method [KAON]");
902 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
903 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
904 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
905 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
906 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
913 TLegend *legEff2 = new TLegend(.64, .84, .98, .98);
914 legEff2->SetBorderSize(1);legEff2->SetTextSize(0.03255879);
915 legEff2->SetFillColor(0);
916 pad = ((TVirtualPad*)l->At(1));pad->cd();
917 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
918 h=(TH1S*)h->Clone("hEff_p");
919 h->SetYTitle("#epsilon_{p} [%]");
920 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
922 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kProton)));
923 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
924 if(!g->GetN()) break;
925 legEff2->SetHeader("PID Method [PROTON]");
926 g->Draw("pc"); legEff2->AddEntry(g, "LQ 2D", "pl");
927 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
928 g->Draw("pc"); legEff2->AddEntry(g, "NN", "pl");
929 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
930 g->Draw("p"); legEff2->AddEntry(g, "ESD", "pl");
939 // save 2.0 GeV projection as reference
940 TLegend *legdEdx = new TLegend(.7, .7, .98, .98);
941 legdEdx->SetBorderSize(1);
943 if(!(h2 = (TH2F*)(fContainer->At(kdEdx)))) break;
944 legdEdx->SetHeader("Particle Species");
945 gPad->SetMargin(0.1, 0.01, 0.1, 0.01);
946 for(Int_t is = AliPID::kSPECIES-1; is>=0; is--){
947 Int_t bin = FindBin(is, 2.);
948 h1 = h2->ProjectionY(Form("px%d", is), bin, bin);
949 if(!h1->GetEntries()) continue;
950 h1->Scale(1./h1->Integral());
951 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
953 h1->GetXaxis()->SetTitle("dE/dx (a.u.)");
954 h1->GetYaxis()->SetTitle("<Entries>");
956 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
957 legdEdx->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
971 gPad->Divide(2, 1, 1.e-5, 1.e-5);
972 TList *l=gPad->GetListOfPrimitives();
974 // save 2.0 GeV projection as reference
975 TLegend *legPH = new TLegend(.4, .7, .68, .98);
976 legPH->SetBorderSize(1);legPH->SetFillColor(0);
977 legPH->SetHeader("Particle Species");
978 if(!(arr = (TObjArray*)(fContainer->At(kPH)))) break;
979 if(!(h2 = (TProfile2D*)(arr->At(0)))) break;
981 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
982 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
984 for(Int_t is=0; is<AliPID::kSPECIES; is++){
985 Int_t bin = FindBin(is, 2.);
986 h1 = h2->ProjectionY(Form("pyt%d", is), bin, bin);
987 if(!h1->GetEntries()) continue;
988 h1->SetMarkerStyle(24);
989 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
990 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
992 h1->GetXaxis()->SetTitle("t_{drift} [100*ns]");
993 h1->GetYaxis()->SetTitle("<dQ/dt> [a.u.]");
995 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
996 legPH->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "pl");
1000 pad = ((TVirtualPad*)l->At(1));pad->cd();
1001 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1002 if(!(h2 = (TProfile2D*)(arr->At(1)))) break;
1004 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1005 Int_t bin = FindBin(is, 2.);
1006 h1 = h2->ProjectionY(Form("pyx%d", is), bin, bin);
1007 if(!h1->GetEntries()) continue;
1008 h1->SetMarkerStyle(24);
1009 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1010 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1012 h1->GetXaxis()->SetTitle("x_{drift} [cm]");
1013 h1->GetYaxis()->SetTitle("<dQ/dl> [a.u./cm]");
1015 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1028 // save 2.0 GeV projection as reference
1029 TLegend *legNClus = new TLegend(.13, .7, .4, .98);
1030 legNClus->SetBorderSize(1);
1031 legNClus->SetFillColor(0);
1034 if(!(h2 = (TH2F*)(fContainer->At(kNClus)))) break;
1035 legNClus->SetHeader("Particle Species");
1036 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1037 Int_t bin = FindBin(is, 2.);
1038 h1 = h2->ProjectionY(Form("pyNClus%d", is), bin, bin);
1039 if(!h1->GetEntries()) continue;
1040 h1->Scale(100./h1->Integral());
1041 //h1->SetMarkerStyle(24);
1042 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1043 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1045 h1->GetXaxis()->SetTitle("N^{cl}/tracklet");
1046 h1->GetYaxis()->SetTitle("Prob. [%]");
1047 h = (TH1F*)h1->DrawClone("c");
1049 h->GetXaxis()->SetRangeUser(0., 35.);
1051 } else h = (TH1F*)h1->DrawClone("samec");
1053 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1067 TLegend *legNClus = new TLegend(.4, .7, .68, .98);
1068 legNClus->SetBorderSize(1);
1070 if(!(h2 = (TH2F*)(fContainer->At(kNTracklets)))) break;
1071 legNClus->SetHeader("Particle Species");
1072 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1073 Int_t bin = FindBin(is, 2.);
1074 h1 = h2->ProjectionY(Form("pyNTracklets%d", is), bin, bin);
1075 if(!h1->GetEntries()) continue;
1076 h1->Scale(100./h1->Integral());
1077 //h1->SetMarkerStyle(24);
1078 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1079 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1081 h1->GetXaxis()->SetTitle("N^{trklt}/track");
1082 h1->GetXaxis()->SetRangeUser(1.,6.);
1083 h1->GetYaxis()->SetTitle("Prob. [%]");
1085 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1086 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1098 AliInfo(Form("Reference plot [%d] missing result", ifig));
1102 //________________________________________________________________________
1103 Bool_t AliTRDcheckPID::PostProcess()
1105 // Draw result to the screen
1106 // Called once at the end of the query
1109 Printf("ERROR: list not available");
1113 TObjArray *eff(NULL);
1115 fGraph = new TObjArray(2*AliPID::kSPECIES);
1118 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
1119 AliError("Efficiency container for Electrons missing.");
1122 EvaluateEfficiency(eff, fGraph, AliPID::kPion, 0.9);
1123 EvaluateEfficiency(eff, fGraph, AliPID::kKaon, 0.9);
1124 EvaluateEfficiency(eff, fGraph, AliPID::kProton, 0.9);
1130 //________________________________________________________________________
1131 void AliTRDcheckPID::EvaluateEfficiency(TObjArray * const histoContainer, TObjArray *results, Int_t species, Float_t electronEfficiency){
1132 // Process PID information for pion efficiency
1134 fUtil->SetElectronEfficiency(electronEfficiency);
1137 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
1138 Color_t colors[kNmethodsPID] = {kBlue, kGreen+2, kRed};
1139 Int_t markerStyle[kNmethodsPID] = {7, 7, 24};
1140 // efficiency graphs
1141 TGraphErrors *g(NULL);
1142 TObjArray *eff = new TObjArray(kNmethodsPID); eff->SetOwner(); eff->SetName(Form("Eff_%s", AliTRDCalPID::GetPartName(species)));
1143 results->AddAt(eff, species);
1144 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1145 eff->AddAt(g = new TGraphErrors(), iMethod);
1146 g->SetName(Form("%s", fgMethod[iMethod]));
1147 g->SetLineColor(colors[iMethod]);
1148 g->SetMarkerColor(colors[iMethod]);
1149 g->SetMarkerStyle(markerStyle[iMethod]);
1152 // Threshold graphs if not already
1153 TObjArray *thres(NULL);
1154 if(!(results->At(AliPID::kSPECIES))){
1155 thres = new TObjArray(kNmethodsPID); thres->SetOwner();
1156 thres->SetName("Thres");
1157 results->AddAt(thres, AliPID::kSPECIES);
1158 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1159 thres->AddAt(g = new TGraphErrors(), iMethod);
1160 g->SetName(Form("%s", fgMethod[iMethod]));
1161 g->SetLineColor(colors[iMethod]);
1162 g->SetMarkerColor(colors[iMethod]);
1163 g->SetMarkerStyle(markerStyle[iMethod]);
1167 TH2F *hPtr[kNmethodsPID]={
1168 (TH2F*)histoContainer->At(AliTRDpidUtil::kLQ),
1169 (TH2F*)histoContainer->At(AliTRDpidUtil::kNN),
1170 (TH2F*)histoContainer->At(AliTRDpidUtil::kESD)
1172 for(Int_t iMom = 0; iMom < fMomentumAxis->GetNbins(); iMom++){
1173 Float_t mom(fMomentumAxis->GetBinCenter(iMom+1));
1175 Int_t binEl(fMomentumAxis->GetNbins() * AliPID::kElectron + iMom + 1),
1176 binXX(fMomentumAxis->GetNbins() * species + iMom + 1);
1178 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1179 // Calculate the Species Efficiency at electronEfficiency% electron efficiency for each Method
1181 TH1D *histo1 = hPtr[iMethod] -> ProjectionY(Form("%s_el", fgMethod[iMethod]), binEl, binEl);
1182 TH1D *histo2 = hPtr[iMethod] -> ProjectionY(Form("%s_%s", fgMethod[iMethod], AliTRDCalPID::GetPartName(species)), binXX, binXX);
1184 if(!fUtil->CalculatePionEffi(histo1, histo2)) continue;
1186 g=(TGraphErrors*)eff->At(iMethod);
1187 g->SetPoint(iMom, mom, 1.e2*fUtil->GetPionEfficiency());
1188 g->SetPointError(iMom, 0., 1.e2*fUtil->GetError());
1189 AliDebug(2, Form("%s Efficiency for %s is : %f +/- %f", AliTRDCalPID::GetPartName(species), fgMethod[iMethod], fUtil->GetPionEfficiency(), fUtil->GetError()));
1191 if(!thres) continue;
1192 g=(TGraphErrors*)thres->At(iMethod);
1193 g->SetPoint(iMom, mom, fUtil->GetThreshold());
1194 g->SetPointError(iMom, 0., 0.);