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"
55 #include "info/AliTRDv0Info.h"
57 Char_t const * AliTRDcheckPID::fgMethod[3] = {"LQ", "NN", "ESD"};
59 ClassImp(AliTRDcheckPID)
61 //________________________________________________________________________
62 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")
89 ,fMinNTracklets(AliTRDgeometry::kNlayer)
90 ,fMaxNTracklets(AliTRDgeometry::kNlayer)
93 // Default constructor
99 DefineInput(2, TObjArray::Class()); // v0 list
100 DefineOutput(2, TObjArray::Class()); // pid info list
104 //________________________________________________________________________
105 void AliTRDcheckPID::LocalInit()
107 // Initialize working data
108 fReconstructor = new AliTRDReconstructor();
109 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
111 // Initialize momentum axis with default values
112 Double_t defaultMomenta[AliTRDCalPID::kNMom+1];
113 for(Int_t imom = 0; imom < AliTRDCalPID::kNMom+1; imom++)
114 defaultMomenta[imom] = AliTRDCalPID::GetMomentumBinning(imom);
115 SetMomentumBinning(AliTRDCalPID::kNMom, defaultMomenta);
117 memset(fEfficiency, 0, AliPID::kSPECIES*sizeof(TObjArray*));
119 fUtil = new AliTRDpidUtil();
122 //________________________________________________________________________
123 AliTRDcheckPID::~AliTRDcheckPID()
125 if(fPID){fPID->Delete(); delete fPID;}
126 if(fGraph){fGraph->Delete(); delete fGraph;}
127 if(fReconstructor) delete fReconstructor;
128 if(fUtil) delete fUtil;
132 //________________________________________________________________________
133 void AliTRDcheckPID::UserCreateOutputObjects()
138 AliTRDrecoTask::UserCreateOutputObjects();
139 fPID = new TObjArray();
140 fPID->SetOwner(kTRUE);
144 //________________________________________________________
145 void AliTRDcheckPID::UserExec(Option_t *opt)
151 fV0s = dynamic_cast<TObjArray *>(GetInputData(2));
154 AliTRDrecoTask::UserExec(opt);
158 //_______________________________________________________
159 TObjArray * AliTRDcheckPID::Histos(){
162 // Create QA histograms
164 if(fContainer) return fContainer;
166 Int_t xBins = AliPID::kSPECIES*fMomentumAxis->GetNbins();
167 fContainer = new TObjArray(); fContainer->Expand(kNPlots);
169 const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1)); // get nice histos with bin center at 0 and 1
172 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
173 // histos with posterior probabilities for all particle species
174 for(Int_t is=AliPID::kSPECIES; is--;){
175 fEfficiency[is] = new TObjArray(kNmethodsPID);
176 fEfficiency[is]->SetOwner();
177 fEfficiency[is]->SetName(Form("Eff_%s", AliPID::ParticleShortName(is)));
178 fContainer->AddAt(fEfficiency[is], is?kEfficiencyMu+is-1:kEfficiency);
179 for(Int_t im=kNmethodsPID; im--;){
180 if(!(h = (TH2F*)gROOT->FindObject(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is))))) {
181 h = new TH2F(Form("PID_%s_%s", fgMethod[im], AliPID::ParticleShortName(is)), "", xBins, -0.5, xBins - 0.5,
182 AliTRDpidUtil::kBins, 0.-epsilon, 1.+epsilon);
184 fEfficiency[is]->AddAt(h, im);
188 // histos of the dE/dx distribution for all 5 particle species and 11 momenta
189 if(!(h = (TH2F*)gROOT->FindObject("dEdx"))){
190 h = new TH2F("dEdx", "",
191 xBins, -0.5, xBins - 0.5,
195 fContainer->AddAt(h, kdEdx);
197 // histos of the dE/dx slices for all 5 particle species and 11 momenta
198 if(!(h = (TH2F*)gROOT->FindObject("dEdxSlice"))){
199 h = new TH2F("dEdxSlice", "",
200 xBins*AliTRDpidUtil::kLQslices, -0.5, xBins*AliTRDpidUtil::kLQslices - 0.5,
203 fContainer->AddAt(h, kdEdxSlice);
205 // histos of the pulse height distribution for all 5 particle species and 11 momenta
206 TObjArray *fPH = new TObjArray(2);
207 fPH->SetOwner(); fPH->SetName("PH");
208 fContainer->AddAt(fPH, kPH);
209 if(!(h = (TProfile2D*)gROOT->FindObject("PHT"))){
210 h = new TProfile2D("PHT", "",
211 xBins, -0.5, xBins - 0.5,
212 AliTRDtrackerV1::GetNTimeBins(), -0.5, AliTRDtrackerV1::GetNTimeBins() - 0.5);
215 if(!(h = (TProfile2D*)gROOT->FindObject("PHX"))){
216 h = new TProfile2D("PHX", "",
217 xBins, -0.5, xBins - 0.5,
218 AliTRDtrackerV1::GetNTimeBins(), 0., .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght());
222 // histos of the number of clusters distribution for all 5 particle species and 11 momenta
223 if(!(h = (TH2F*)gROOT->FindObject("NClus"))){
224 h = new TH2F("NClus", "",
225 xBins, -0.5, xBins - 0.5,
228 fContainer->AddAt(h, kNClus);
231 // momentum distributions - absolute and in momentum bins
232 if(!(h = (TH1F*)gROOT->FindObject("hMom"))){
233 h = new TH1F("hMom", "momentum distribution", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
235 fContainer->AddAt(h, kMomentum);
237 if(!(h = (TH1F*)gROOT->FindObject("hMomBin"))){
238 h = new TH1F("hMomBin", "momentum distribution in momentum bins", fMomentumAxis->GetNbins(), fMomentumAxis->GetXmin(), fMomentumAxis->GetXmax());
240 fContainer->AddAt(h, kMomentumBin);
242 // Number of tracklets per track
243 if(!(h = (TH2F*)gROOT->FindObject("nTracklets"))){
244 h = new TH2F("nTracklets", "",
245 xBins, -0.5, xBins - 0.5,
246 AliTRDgeometry::kNlayer, 0.5, AliTRDgeometry::kNlayer+.5);
248 fContainer->AddAt(h, kNTracklets);
251 if(!(h = (TH1F*)gROOT->FindObject("nV0"))){
252 h = new TH1F("nV0", "V0s/track;v0/track;entries",
255 fContainer->AddAt(h, kV0);
261 //________________________________________________________________________
262 Bool_t AliTRDcheckPID::CheckTrackQuality(const AliTRDtrackV1* track) const
265 // Check if the track is ok for PID
268 Int_t ntracklets = track->GetNumberOfTracklets();
269 if(ntracklets >= fMinNTracklets && ntracklets <= fMaxNTracklets) return 1;
276 //________________________________________________________________________
277 Int_t AliTRDcheckPID::CalcPDG(AliTRDtrackV1* track)
279 // Documentation to come
281 track -> SetReconstructor(fReconstructor);
282 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork();
285 if(track -> GetPID(AliPID::kElectron) > track -> GetPID(AliPID::kMuon) + track -> GetPID(AliPID::kPion) + track -> GetPID(AliPID::kKaon) + track -> GetPID(AliPID::kProton)){
288 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)){
291 else if(track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kMuon) && track -> GetPID(AliPID::kKaon) > track -> GetPID(AliPID::kPion)){
294 else if(track -> GetPID(AliPID::kMuon) > track -> GetPID(AliPID::kPion)){
303 //_______________________________________________________
304 TH1 *AliTRDcheckPID::PlotLQ(const AliTRDtrackV1 *track)
307 // Plot the probabilities for electrons using 2-dim LQ
311 AliDebug(2, "No ESD info available.");
315 if(track) fkTrack = track;
317 AliDebug(2, "No Track defined.");
322 status = fkESD -> GetStatus();
323 if(!(status&AliESDtrack::kTRDin)) return NULL;
325 if(!CheckTrackQuality(fkTrack)) return NULL;
327 AliTRDtrackV1 cTrack(*fkTrack);
328 cTrack.SetReconstructor(fReconstructor);
331 Float_t momentum = 0.;
334 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
335 pdg = fkMC->GetPDG();
337 //AliWarning("No MC info available!");
338 momentum = cTrack.GetMomentum(0);
339 pdg = CalcPDG(&cTrack);
341 if(!IsInRange(momentum)) return NULL;
343 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
345 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
346 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
349 TObjArray *eff(NULL);
350 for(Int_t is=AliPID::kSPECIES; is--;){
351 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
352 AliWarning("No Histogram List defined.");
355 if(!(hPIDLQ = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kLQ)))){
356 AliWarning("No Histogram defined.");
360 hPIDLQ -> Fill(FindBin(species, momentum), cTrack.GetPID(is));
368 //_______________________________________________________
369 TH1 *AliTRDcheckPID::PlotNN(const AliTRDtrackV1 *track)
372 // Plot the probabilities for electrons using 2-dim LQ
376 AliDebug(2, "No ESD info available.");
380 if(track) fkTrack = track;
382 AliDebug(2, "No Track defined.");
387 status = fkESD -> GetStatus();
388 if(!(status&AliESDtrack::kTRDin)) return NULL;
390 if(!CheckTrackQuality(fkTrack)) return NULL;
392 AliTRDtrackV1 cTrack(*fkTrack);
393 cTrack.SetReconstructor(fReconstructor);
396 Float_t momentum = 0.;
398 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
399 pdg = fkMC->GetPDG();
401 //AliWarning("No MC info available!");
402 momentum = cTrack.GetMomentum(0);
403 pdg = CalcPDG(&cTrack);
405 if(!IsInRange(momentum)) return NULL;
407 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork();
409 if(cTrack.GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
411 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
415 TObjArray *eff(NULL);
416 for(Int_t is=AliPID::kSPECIES; is--;){
417 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
418 AliWarning("No Histogram List defined.");
421 if(!(hPIDNN = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kNN)))){
422 AliWarning("No Histogram defined.");
426 hPIDNN->Fill(FindBin(species, momentum), cTrack.GetPID(is));
433 //_______________________________________________________
434 TH1 *AliTRDcheckPID::PlotESD(const AliTRDtrackV1 *track)
437 // Plot the probabilities for electrons using 2-dim LQ
441 AliDebug(2, "No ESD info available.");
445 if(track) fkTrack = track;
447 AliDebug(2, "No Track defined.");
452 status = fkESD -> GetStatus();
453 if(!(status&AliESDtrack::kTRDin)) return NULL;
455 if(!CheckTrackQuality(fkTrack)) return NULL;
456 if(fkTrack->GetNumberOfTrackletsPID() < fMinNTracklets) return NULL;
459 Float_t momentum = 0.;
461 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
462 pdg = fkMC->GetPDG();
464 //AliWarning("No MC info available!");
465 AliTRDtrackV1 cTrack(*fkTrack);
466 cTrack.SetReconstructor(fReconstructor);
467 momentum = cTrack.GetMomentum(0);
468 pdg = CalcPDG(&cTrack);
470 if(!IsInRange(momentum)) return NULL;
472 const Double32_t *pidESD = fkESD->GetResponseIter();
473 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
476 TObjArray *eff(NULL);
477 for(Int_t is=AliPID::kSPECIES; is--;){
478 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(is?kEfficiencyMu+is-1:kEfficiency)))){
479 AliWarning("No Histogram List defined.");
482 if(!(hPID = dynamic_cast<TH2F *>(eff->At(AliTRDpidUtil::kESD)))){
483 AliWarning("No Histogram defined.");
487 hPID->Fill(FindBin(species, momentum), pidESD[is]);
494 //_______________________________________________________
495 TH1 *AliTRDcheckPID::PlotdEdx(const AliTRDtrackV1 *track)
498 // Plot the probabilities for electrons using 2-dim LQ
501 if(track) fkTrack = track;
503 AliDebug(2, "No Track defined.");
507 if(!CheckTrackQuality(fkTrack)) return NULL;
510 if(!(hdEdx = dynamic_cast<TH2F *>(fContainer->At(kdEdx)))){
511 AliWarning("No Histogram defined.");
515 AliTRDtrackV1 cTrack(*fkTrack);
516 cTrack.SetReconstructor(fReconstructor);
518 Float_t momentum = 0.;
520 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
521 pdg = fkMC->GetPDG();
523 //AliWarning("No MC info available!");
524 momentum = cTrack.GetMomentum(0);
525 pdg = CalcPDG(&cTrack);
527 if(!IsInRange(momentum)) return NULL;
529 // Init exchange container
530 Int_t s(AliTRDpidUtil::Pdg2Pid(pdg));
531 AliTRDpidInfo *pid = new AliTRDpidInfo(s);
533 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kTRUE);
536 Int_t iBin = FindBin(s, momentum);
537 AliTRDseedV1 *tracklet = NULL;
538 for(Int_t ily = 0; ily < AliTRDgeometry::kNlayer; ily++){
539 tracklet = cTrack.GetTracklet(ily);
540 if(!tracklet) continue;
541 tracklet -> CookdEdx(AliTRDpidUtil::kNNslices);
543 // fill exchange container
544 pid->PushBack(tracklet->GetPlane(),
545 AliTRDpidUtil::GetMomentumBin(tracklet->GetMomentum()), tracklet->GetdEdx());
548 for(Int_t i = AliTRDpidUtil::kNNslices; i--;) sumdEdx += tracklet->GetdEdx()[i];
549 sumdEdx /= AliTRDCalPIDNN::kMLPscale;
550 hdEdx -> Fill(iBin, sumdEdx);
558 //_______________________________________________________
559 TH1 *AliTRDcheckPID::PlotdEdxSlice(const AliTRDtrackV1 *track)
562 // Plot the probabilities for electrons using 2-dim LQ
565 if(track) fkTrack = track;
567 AliDebug(2, "No Track defined.");
571 if(!CheckTrackQuality(fkTrack)) return NULL;
574 if(!(hdEdxSlice = dynamic_cast<TH2F *>(fContainer->At(kdEdxSlice)))){
575 AliWarning("No Histogram defined.");
579 AliTRDtrackV1 cTrack(*fkTrack);
580 cTrack.SetReconstructor(fReconstructor);
582 Float_t momentum = 0.;
584 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
585 pdg = fkMC->GetPDG();
587 //AliWarning("No MC info available!");
588 momentum = cTrack.GetMomentum(0);
589 pdg = CalcPDG(&cTrack);
591 if(!IsInRange(momentum)) return NULL;
593 (const_cast<AliTRDrecoParam*>(fReconstructor->GetRecoParam()))->SetPIDNeuralNetwork(kFALSE);
594 Int_t iMomBin = fMomentumAxis->FindBin(momentum);
595 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
597 AliTRDseedV1 *tracklet = NULL;
598 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
599 tracklet = cTrack.GetTracklet(iChamb);
600 if(!tracklet) continue;
601 tracklet -> CookdEdx(AliTRDpidUtil::kLQslices);
602 fdEdx = const_cast<Float_t *>(tracklet->GetdEdx());
603 for(Int_t iSlice = 0; iSlice < AliTRDpidUtil::kLQslices; iSlice++){
604 hdEdxSlice -> Fill(species * fMomentumAxis->GetNbins() * AliTRDpidUtil::kLQslices + (iMomBin-1) * AliTRDpidUtil::kLQslices + iSlice, fdEdx[iSlice]);
612 //_______________________________________________________
613 TH1 *AliTRDcheckPID::PlotPH(const AliTRDtrackV1 *track)
616 // Plot the probabilities for electrons using 2-dim LQ
619 if(track) fkTrack = track;
621 AliDebug(2, "No Track defined.");
625 if(!CheckTrackQuality(fkTrack)) return NULL;
627 TObjArray *arr = NULL;
628 TProfile2D *hPHX, *hPHT;
629 if(!(arr = dynamic_cast<TObjArray *>(fContainer->At(kPH)))){
630 AliWarning("No Histogram defined.");
633 hPHT = (TProfile2D*)arr->At(0);
634 hPHX = (TProfile2D*)arr->At(1);
637 Float_t momentum = 0.;
639 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
640 pdg = fkMC->GetPDG();
642 //AliWarning("No MC info available!");
643 AliTRDtrackV1 cTrack(*fkTrack);
644 cTrack.SetReconstructor(fReconstructor);
645 momentum = cTrack.GetMomentum(0);
646 pdg = CalcPDG(&cTrack);
648 if(!IsInRange(momentum)) return NULL;;
650 AliTRDseedV1 *tracklet = NULL;
651 AliTRDcluster *cluster = NULL;
652 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
653 Int_t iBin = FindBin(species, momentum);
654 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
655 tracklet = fkTrack->GetTracklet(iChamb);
656 if(!tracklet) continue;
657 Float_t x0 = tracklet->GetX0();
658 for(Int_t ic = 0; ic < AliTRDtrackerV1::GetNTimeBins(); ic++){
659 if(!(cluster = tracklet->GetClusters(ic))) continue;
660 hPHT -> Fill(iBin, cluster->GetLocalTimeBin(), TMath::Abs(cluster->GetQ()));
661 hPHX -> Fill(iBin, x0 - cluster->GetX(), tracklet->GetdQdl(ic));
668 //_______________________________________________________
669 TH1 *AliTRDcheckPID::PlotNClus(const AliTRDtrackV1 *track)
672 // Plot the probabilities for electrons using 2-dim LQ
675 if(track) fkTrack = track;
677 AliDebug(2, "No Track defined.");
681 if(!CheckTrackQuality(fkTrack)) return NULL;
684 if(!(hNClus = dynamic_cast<TH2F *>(fContainer->At(kNClus)))){
685 AliWarning("No Histogram defined.");
691 Float_t momentum = 0.;
693 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
694 pdg = fkMC->GetPDG();
696 //AliWarning("No MC info available!");
697 AliTRDtrackV1 cTrack(*fkTrack);
698 cTrack.SetReconstructor(fReconstructor);
699 momentum = cTrack.GetMomentum(0);
700 pdg = CalcPDG(&cTrack);
702 if(!IsInRange(momentum)) return NULL;
704 Int_t species = AliTRDpidUtil::AliTRDpidUtil::Pdg2Pid(pdg);
705 Int_t iBin = FindBin(species, momentum);
706 AliTRDseedV1 *tracklet = NULL;
707 for(Int_t iChamb = 0; iChamb < AliTRDgeometry::kNlayer; iChamb++){
708 tracklet = fkTrack->GetTracklet(iChamb);
709 if(!tracklet) continue;
710 hNClus -> Fill(iBin, tracklet->GetN());
716 //_______________________________________________________
717 TH1 *AliTRDcheckPID::PlotNTracklets(const AliTRDtrackV1 *track)
720 // Plot the probabilities for electrons using 2-dim LQ
723 if(track) fkTrack = track;
725 AliDebug(2, "No Track defined.");
730 if(!(hTracklets = dynamic_cast<TH2F *>(fContainer->At(kNTracklets)))){
731 AliWarning("No Histogram defined.");
735 AliTRDtrackV1 cTrack(*fkTrack);
736 cTrack.SetReconstructor(fReconstructor);
738 Float_t momentum = 0.;
740 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
741 pdg = fkMC->GetPDG();
743 //AliWarning("No MC info available!");
744 momentum = cTrack.GetMomentum();
745 pdg = CalcPDG(&cTrack);
747 Int_t species = AliTRDpidUtil::Pdg2Pid(pdg);
748 if(!IsInRange(momentum)) return NULL;
750 Int_t iBin = FindBin(species, momentum);
751 hTracklets -> Fill(iBin, cTrack.GetNumberOfTracklets());
755 //_______________________________________________________
756 TH1 *AliTRDcheckPID::PlotMom(const AliTRDtrackV1 *track)
759 // Plot the probabilities for electrons using 2-dim LQ
762 if(track) fkTrack = track;
764 AliDebug(2, "No Track defined.");
768 if(!CheckTrackQuality(fkTrack)) return NULL;
771 if(!(hMom = dynamic_cast<TH1F *>(fContainer->At(kMomentum)))){
772 AliWarning("No Histogram defined.");
778 Float_t momentum = 0.;
780 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
781 pdg = fkMC->GetPDG();
783 //AliWarning("No MC info available!");
784 AliTRDtrackV1 cTrack(*fkTrack);
785 cTrack.SetReconstructor(fReconstructor);
786 momentum = cTrack.GetMomentum(0);
787 pdg = CalcPDG(&cTrack);
789 if(IsInRange(momentum)) hMom -> Fill(momentum);
794 //_______________________________________________________
795 TH1 *AliTRDcheckPID::PlotMomBin(const AliTRDtrackV1 *track)
798 // Plot the probabilities for electrons using 2-dim LQ
801 if(track) fkTrack = track;
803 AliDebug(2, "No Track defined.");
807 if(!CheckTrackQuality(fkTrack)) return NULL;
810 if(!(hMomBin = dynamic_cast<TH1F *>(fContainer->At(kMomentumBin)))){
811 AliWarning("No Histogram defined.");
817 Float_t momentum = 0.;
820 if(fkMC->GetTrackRef()) momentum = fkMC->GetTrackRef()->P();
821 pdg = fkMC->GetPDG();
823 //AliWarning("No MC info available!");
824 AliTRDtrackV1 cTrack(*fkTrack);
825 cTrack.SetReconstructor(fReconstructor);
826 momentum = cTrack.GetMomentum(0);
828 if(IsInRange(momentum)) hMomBin -> Fill(fMomentumAxis->FindBin(momentum));
832 //_______________________________________________________
833 TH1 *AliTRDcheckPID::PlotV0(const AliTRDtrackV1 *track)
836 // Plot the V0 performance against MC
839 if(track) fkTrack = track;
841 AliDebug(2, "No Track defined.");
844 if(!fkESD->HasV0()) return NULL;
846 AliDebug(1, "No MC defined.");
850 AliWarning("No output container defined.");
853 AliDebug(2, Form("TRACK[%d] species[%s][%d]\n", fkESD->GetId(), AliPID::ParticleShortName(fkMC->GetPID()), fkMC->GetPDG()));
855 TH1 *h=dynamic_cast<TH1F*>(fContainer->At(kV0));
856 Int_t sgn(0), n(0); AliTRDv0Info *v0(NULL);
857 for(Int_t iv0(fV0s->GetEntriesFast()); iv0--;){
858 if(!(v0=(AliTRDv0Info*)fV0s->At(iv0))) continue;
859 if(!(sgn = v0->HasTrack(fkESD->GetId()))) continue;
860 //for(Int_t is=AliPID::kSPECIES; is--;) v0->GetPID(is, track);
869 //________________________________________________________
870 Bool_t AliTRDcheckPID::GetRefFigure(Int_t ifig)
872 // Steering function to retrieve performance plots
874 Bool_t kFIRST = kTRUE;
875 TGraphErrors *g = NULL;
877 TObjArray *arr = NULL;
878 TH1 *h1 = NULL, *h=NULL;
880 TList *content = NULL;
883 gPad->Divide(2, 1, 1.e-5, 1.e-5);
884 TList *l=gPad->GetListOfPrimitives();
885 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
886 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
888 TLegend *legEff = new TLegend(.64, .84, .98, .98);
889 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
890 legEff->SetFillColor(0);
891 h=new TH1S("hEff", "", 1, .5, 11.);
892 h->SetLineColor(1);h->SetLineWidth(1);
894 ax->SetTitle("p [GeV/c]");
895 ax->SetRangeUser(.5, 11.);
896 ax->SetMoreLogLabels();
898 ax->SetTitle("#epsilon_{#pi} [%]");
900 ax->SetRangeUser(1.e-2, 10.);
902 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kPion)));
903 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
904 if(!g->GetN()) break;
905 legEff->SetHeader("PID Method [PION]");
906 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
907 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
908 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
909 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
910 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
918 pad = ((TVirtualPad*)l->At(1));pad->cd();
919 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
920 h=new TH1S("hThr", "", 1, .5, 11.);
921 h->SetLineColor(1);h->SetLineWidth(1);
923 ax->SetTitle("p [GeV/c]");
924 ax->SetMoreLogLabels();
926 ax->SetTitle("Threshold [%]");
927 ax->SetRangeUser(5.e-2, 1.);
929 content = (TList *)fGraph->FindObject("Thres");
930 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
931 if(!g->GetN()) break;
933 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
935 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
943 gPad->Divide(2, 1, 1.e-5, 1.e-5);
944 TList *l=gPad->GetListOfPrimitives();
945 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
946 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
948 TLegend *legEff = new TLegend(.64, .84, .98, .98);
949 legEff->SetBorderSize(1);legEff->SetTextSize(0.03255879);
950 legEff->SetFillColor(0);
951 h = (TH1S*)gROOT->FindObject("hEff");
952 h=(TH1S*)h->Clone("hEff_K");
953 h->SetYTitle("#epsilon_{K} [%]");
954 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
956 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kKaon)));
957 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
958 if(!g->GetN()) break;
959 legEff->SetHeader("PID Method [KAON]");
960 g->Draw("pc"); legEff->AddEntry(g, "LQ 2D", "pl");
961 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
962 g->Draw("pc"); legEff->AddEntry(g, "NN", "pl");
963 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
964 g->Draw("p"); legEff->AddEntry(g, "ESD", "pl");
971 TLegend *legEff2 = new TLegend(.64, .84, .98, .98);
972 legEff2->SetBorderSize(1);legEff2->SetTextSize(0.03255879);
973 legEff2->SetFillColor(0);
974 pad = ((TVirtualPad*)l->At(1));pad->cd();
975 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
976 h=(TH1S*)h->Clone("hEff_p");
977 h->SetYTitle("#epsilon_{p} [%]");
978 h->GetYaxis()->SetRangeUser(1.e-2, 1.e2);
980 content = (TList *)fGraph->FindObject(Form("Eff_%s", AliTRDCalPID::GetPartName(AliPID::kProton)));
981 if(!(g = (TGraphErrors*)content->At(AliTRDpidUtil::kLQ))) break;
982 if(!g->GetN()) break;
983 legEff2->SetHeader("PID Method [PROTON]");
984 g->Draw("pc"); legEff2->AddEntry(g, "LQ 2D", "pl");
985 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kNN))) break;
986 g->Draw("pc"); legEff2->AddEntry(g, "NN", "pl");
987 if(! (g = (TGraphErrors*)content->At(AliTRDpidUtil::kESD))) break;
988 g->Draw("p"); legEff2->AddEntry(g, "ESD", "pl");
997 // save 2.0 GeV projection as reference
998 TLegend *legdEdx = new TLegend(.7, .7, .98, .98);
999 legdEdx->SetBorderSize(1);
1001 if(!(h2 = (TH2F*)(fContainer->At(kdEdx)))) break;
1002 legdEdx->SetHeader("Particle Species");
1003 gPad->SetMargin(0.1, 0.01, 0.1, 0.01);
1004 for(Int_t is = AliPID::kSPECIES-1; is>=0; is--){
1005 Int_t bin = FindBin(is, 2.);
1006 h1 = h2->ProjectionY(Form("px%d", is), bin, bin);
1007 if(!h1->GetEntries()) continue;
1008 h1->Scale(1./h1->Integral());
1009 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1011 h1->GetXaxis()->SetTitle("dE/dx (a.u.)");
1012 h1->GetYaxis()->SetTitle("<Entries>");
1014 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1015 legdEdx->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1029 gPad->Divide(2, 1, 1.e-5, 1.e-5);
1030 TList *l=gPad->GetListOfPrimitives();
1032 // save 2.0 GeV projection as reference
1033 TLegend *legPH = new TLegend(.4, .7, .68, .98);
1034 legPH->SetBorderSize(1);legPH->SetFillColor(0);
1035 legPH->SetHeader("Particle Species");
1036 if(!(arr = (TObjArray*)(fContainer->At(kPH)))) break;
1037 if(!(h2 = (TProfile2D*)(arr->At(0)))) break;
1039 TVirtualPad *pad = ((TVirtualPad*)l->At(0));pad->cd();
1040 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1042 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1043 Int_t bin = FindBin(is, 2.);
1044 h1 = h2->ProjectionY(Form("pyt%d", is), bin, bin);
1045 if(!h1->GetEntries()) continue;
1046 h1->SetMarkerStyle(24);
1047 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1048 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1050 h1->GetXaxis()->SetTitle("t_{drift} [100*ns]");
1051 h1->GetYaxis()->SetTitle("<dQ/dt> [a.u.]");
1053 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1054 legPH->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "pl");
1058 pad = ((TVirtualPad*)l->At(1));pad->cd();
1059 pad->SetMargin(0.1, 0.01, 0.1, 0.01);
1060 if(!(h2 = (TProfile2D*)(arr->At(1)))) break;
1062 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1063 Int_t bin = FindBin(is, 2.);
1064 h1 = h2->ProjectionY(Form("pyx%d", is), bin, bin);
1065 if(!h1->GetEntries()) continue;
1066 h1->SetMarkerStyle(24);
1067 h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1068 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1070 h1->GetXaxis()->SetTitle("x_{drift} [cm]");
1071 h1->GetYaxis()->SetTitle("<dQ/dl> [a.u./cm]");
1073 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1086 // save 2.0 GeV projection as reference
1087 TLegend *legNClus = new TLegend(.13, .7, .4, .98);
1088 legNClus->SetBorderSize(1);
1089 legNClus->SetFillColor(0);
1092 if(!(h2 = (TH2F*)(fContainer->At(kNClus)))) break;
1093 legNClus->SetHeader("Particle Species");
1094 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1095 Int_t bin = FindBin(is, 2.);
1096 h1 = h2->ProjectionY(Form("pyNClus%d", is), bin, bin);
1097 if(!h1->GetEntries()) continue;
1098 h1->Scale(100./h1->Integral());
1099 //h1->SetMarkerStyle(24);
1100 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1101 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1103 h1->GetXaxis()->SetTitle("N^{cl}/tracklet");
1104 h1->GetYaxis()->SetTitle("Prob. [%]");
1105 h = (TH1F*)h1->DrawClone("c");
1107 h->GetXaxis()->SetRangeUser(0., 35.);
1109 } else h = (TH1F*)h1->DrawClone("samec");
1111 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1125 TLegend *legNClus = new TLegend(.4, .7, .68, .98);
1126 legNClus->SetBorderSize(1);
1128 if(!(h2 = (TH2F*)(fContainer->At(kNTracklets)))) break;
1129 legNClus->SetHeader("Particle Species");
1130 for(Int_t is=0; is<AliPID::kSPECIES; is++){
1131 Int_t bin = FindBin(is, 2.);
1132 h1 = h2->ProjectionY(Form("pyNTracklets%d", is), bin, bin);
1133 if(!h1->GetEntries()) continue;
1134 h1->Scale(100./h1->Integral());
1135 //h1->SetMarkerStyle(24);
1136 //h1->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
1137 h1->SetLineColor(AliTRDCalPID::GetPartColor(is));
1139 h1->GetXaxis()->SetTitle("N^{trklt}/track");
1140 h1->GetXaxis()->SetRangeUser(1.,6.);
1141 h1->GetYaxis()->SetTitle("Prob. [%]");
1143 h = (TH1F*)h1->DrawClone(kFIRST ? "c" : "samec");
1144 legNClus->AddEntry(h, Form("%s", AliTRDCalPID::GetPartName(is)), "l");
1156 AliInfo(Form("Reference plot [%d] missing result", ifig));
1160 //________________________________________________________________________
1161 Bool_t AliTRDcheckPID::PostProcess()
1163 // Draw result to the screen
1164 // Called once at the end of the query
1167 Printf("ERROR: list not available");
1171 TObjArray *eff(NULL);
1173 fGraph = new TObjArray(2*AliPID::kSPECIES);
1176 if(!(eff = dynamic_cast<TObjArray *>(fContainer->At(kEfficiency)))){
1177 AliError("Efficiency container for Electrons missing.");
1180 EvaluateEfficiency(eff, fGraph, AliPID::kPion, 0.9);
1181 EvaluateEfficiency(eff, fGraph, AliPID::kKaon, 0.9);
1182 EvaluateEfficiency(eff, fGraph, AliPID::kProton, 0.9);
1188 //________________________________________________________________________
1189 void AliTRDcheckPID::EvaluateEfficiency(TObjArray * const histoContainer, TObjArray *results, Int_t species, Float_t electronEfficiency){
1190 // Process PID information for pion efficiency
1192 fUtil->SetElectronEfficiency(electronEfficiency);
1195 const Int_t kNmethodsPID=Int_t(sizeof(fgMethod)/sizeof(Char_t*));
1196 Color_t colors[kNmethodsPID] = {kBlue, kGreen+2, kRed};
1197 Int_t markerStyle[kNmethodsPID] = {7, 7, 24};
1198 // efficiency graphs
1199 TGraphErrors *g(NULL);
1200 TObjArray *eff = new TObjArray(kNmethodsPID); eff->SetOwner(); eff->SetName(Form("Eff_%s", AliTRDCalPID::GetPartName(species)));
1201 results->AddAt(eff, species);
1202 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1203 eff->AddAt(g = new TGraphErrors(), iMethod);
1204 g->SetName(Form("%s", fgMethod[iMethod]));
1205 g->SetLineColor(colors[iMethod]);
1206 g->SetMarkerColor(colors[iMethod]);
1207 g->SetMarkerStyle(markerStyle[iMethod]);
1210 // Threshold graphs if not already
1211 TObjArray *thres(NULL);
1212 if(!(results->At(AliPID::kSPECIES))){
1213 thres = new TObjArray(kNmethodsPID); thres->SetOwner();
1214 thres->SetName("Thres");
1215 results->AddAt(thres, AliPID::kSPECIES);
1216 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1217 thres->AddAt(g = new TGraphErrors(), iMethod);
1218 g->SetName(Form("%s", fgMethod[iMethod]));
1219 g->SetLineColor(colors[iMethod]);
1220 g->SetMarkerColor(colors[iMethod]);
1221 g->SetMarkerStyle(markerStyle[iMethod]);
1225 TH2F *hPtr[kNmethodsPID]={
1226 (TH2F*)histoContainer->At(AliTRDpidUtil::kLQ),
1227 (TH2F*)histoContainer->At(AliTRDpidUtil::kNN),
1228 (TH2F*)histoContainer->At(AliTRDpidUtil::kESD)
1230 for(Int_t iMom = 0; iMom < fMomentumAxis->GetNbins(); iMom++){
1231 Float_t mom(fMomentumAxis->GetBinCenter(iMom+1));
1233 Int_t binEl(fMomentumAxis->GetNbins() * AliPID::kElectron + iMom + 1),
1234 binXX(fMomentumAxis->GetNbins() * species + iMom + 1);
1236 for(Int_t iMethod = 0; iMethod < kNmethodsPID; iMethod++){
1237 // Calculate the Species Efficiency at electronEfficiency% electron efficiency for each Method
1239 TH1D *histo1 = hPtr[iMethod] -> ProjectionY(Form("%s_el", fgMethod[iMethod]), binEl, binEl);
1240 TH1D *histo2 = hPtr[iMethod] -> ProjectionY(Form("%s_%s", fgMethod[iMethod], AliTRDCalPID::GetPartName(species)), binXX, binXX);
1242 if(!fUtil->CalculatePionEffi(histo1, histo2)) continue;
1244 g=(TGraphErrors*)eff->At(iMethod);
1245 g->SetPoint(iMom, mom, 1.e2*fUtil->GetPionEfficiency());
1246 g->SetPointError(iMom, 0., 1.e2*fUtil->GetError());
1247 AliDebug(2, Form("%s Efficiency for %s is : %f +/- %f", AliTRDCalPID::GetPartName(species), fgMethod[iMethod], fUtil->GetPionEfficiency(), fUtil->GetError()));
1249 if(!thres) continue;
1250 g=(TGraphErrors*)thres->At(iMethod);
1251 g->SetPoint(iMom, mom, fUtil->GetThreshold());
1252 g->SetPointError(iMom, 0., 0.);