#include "TIterator.h"
#include "AliVParticle.h"
#include "AliESDtrack.h"
#include "AliMCParticle.h"
#include "AliMCEvent.h"
#include "AliHFEcollection.h"
#include "AliHFEV0pidMC.h"
ClassImp(AliHFEV0pidMC)
AliHFEV0pidMC::AliHFEV0pidMC():
fMC(0x0)
, fColl(NULL)
, fDestBits(0)
{
}
AliHFEV0pidMC::~AliHFEV0pidMC(){
if (fColl) delete fColl;
}
void AliHFEV0pidMC::Init(){
memset(&fDestBits, 0, sizeof(UInt_t));
SETBIT(fDestBits, 1);
fColl = new AliHFEcollection("V0pidMC", "MC based V0 benchmarking");
fColl->CreateTH1F("h_QA_nParticles", "QA on track processing", 10, -0.5, 9.5);
const Int_t nBins = 20;
const Float_t pMin = 0.1;
const Float_t pMax = 10.;
fColl->CreateTH1F("h_Electron", "all electron candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_PionK0", "all K0 pion candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_PionL", "all Lambda pion candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_Kaon", "all Kaon candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_Proton", "all Lambda proton candidates (no MC); p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_mis_Electron", "all NON electron candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_mis_PionK0", "all NON K0 pion candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_mis_PionL", "all NON Lambda pion candidates MC tagged ; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_mis_Kaon", "all NON Kaon candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1F("h_mis_Proton", "all NON Lambda proton candidates MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1Fvector1(5, "h_tag_Electron", "electron candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1Fvector1(5, "h_tag_PionK0", "K0 pion candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1Fvector1(5, "h_tag_PionL", "Lambda pion candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1Fvector1(5, "h_tag_Kaon", "kaon candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
fColl->CreateTH1Fvector1(5, "h_tag_Proton", "Lambda proton candidate MC tagged; p (GeV/c); counts", nBins, pMin, pMax, 0);
}
Bool_t AliHFEV0pidMC::Process(TObjArray * const particles, Int_t type){
TString hname;
const TString typeName[5] = {"Electron", "PionK0", "PionL", "Kaon", "Proton"};
const Int_t typePID[5] = {0, 2, 2, 3, 4};
if(!fMC) return kFALSE;
if(!particles) return kFALSE;
AliVParticle *recTrack = NULL;
TIterator *trackIter = particles->MakeIterator();
while((recTrack = dynamic_cast<AliVParticle *>(trackIter->Next()))){
fColl->Fill("h_QA_nParticles", 0);
AliESDtrack *track = dynamic_cast<AliESDtrack *>(recTrack);
if(!track) continue;
const AliExternalTrackParam *ext = track->GetOuterParam();
if(!ext) continue;
Int_t label = track->GetLabel();
if(label <0){
fColl->Fill("h_QA_nParticles", 1);
continue;
}
AliMCParticle *mcpD = dynamic_cast<AliMCParticle*>(fMC->GetTrack(label));
if(!mcpD){
fColl->Fill("h_QA_nParticles", 2);
continue;
}
Float_t p = ext->P();
Int_t pdgD = mcpD->PdgCode();
AliMCParticle *mcpM = dynamic_cast<AliMCParticle*>(fMC->GetTrack(mcpD->GetMother()));
if(!mcpM){
fColl->Fill("h_QA_nParticles", 3);
continue;
}
hname = "h_" + typeName[type];
fColl->Fill(hname, p);
Int_t pidD = PDGtoPIDdaughter(pdgD);
hname = "h_mis_" + typeName[type];
if(typePID[type] != pidD){
fColl->Fill(hname, p);
}
hname = "h_tag_" + typeName[type];
Int_t aliPID = PDGtoAliPID(pdgD);
fColl->Fill(hname, aliPID, p);
}
return kTRUE;
}
Int_t AliHFEV0pidMC::PDGtoPIDdaughter(Int_t pdg) const {
switch (TMath::Abs(pdg)){
case 11:
return 0;
case 211:
return 2;
case 321:
return 3;
case 2212:
return 4;
default:
return -1;
};
return -1;
}
Int_t AliHFEV0pidMC::PDGtoPIDmother(Int_t pdg) const {
switch (TMath::Abs(pdg)){
case 22:
return 0;
case 310:
return 1;
case 333:
return 2;
case 3122:
return 3;
default:
return -1;
};
return -1;
}
Int_t AliHFEV0pidMC::PDGtoAliPID(Int_t pdg) const {
switch (TMath::Abs(pdg)){
case 11:
return 0;
case 13:
return 1;
case 211:
return 2;
case 321:
return 3;
case 2212:
return 4;
default:
return -1;
};
return -1;
}
TList *AliHFEV0pidMC::GetListOfQAhistograms(){
CLRBIT(fDestBits, 1);
if(fColl)
return fColl->GetList();
return NULL;
}