// Class for HF corrections as a function of many variables
// 6 Steps introduced: MC, MC Acc, Reco, Reco Acc, Reco Acc + ITS Cl,
// Reco Acc + ITS Cl + PPR cuts
-// 12 variables used: pt, y, cosThetaStar, ptPi, ptK, ct,
-// dca, d0Pi, d0K, d0Pixd0K, cosPointingAngle, phi
+// 13 variables used: pt, y, cosThetaStar, ptPi, ptK, ct,
+// dca, d0Pi, d0K, d0Pixd0K, cosPointingAngle, phi, z
//
//-----------------------------------------------------------------------
// Author : C. Zampolli, CERN
#include "AliCFManager.h"
#include "AliCFContainer.h"
#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliAODHandler.h"
#include "AliAODEvent.h"
#include "AliAODRecoDecay.h"
#include "AliAODRecoDecayHF.h"
#include "AliAODRecoDecayHF2Prong.h"
#include "AliAODMCParticle.h"
+#include "AliAODMCHeader.h"
#include "AliESDtrack.h"
+#include "AliRDHFCutsD0toKpi.h"
#include "TChain.h"
#include "THnSparse.h"
#include "TH2D.h"
+
//__________________________________________________________________________
AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep() :
AliAnalysisTaskSE(),
fCountRecoAcc(0),
fCountRecoITSClusters(0),
fCountRecoPPR(0),
+ fCountRecoPID(0),
fEvents(0),
fFillFromGenerated(kFALSE),
fMinITSClusters(5),
- fAcceptanceUnf(kTRUE)
+ fAcceptanceUnf(kTRUE),
+ fKeepD0fromB(kFALSE),
+ fCuts(0)
{
//
//Default ctor
//
}
//___________________________________________________________________________
-AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const Char_t* name) :
+AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const Char_t* name, AliRDHFCutsD0toKpi* cuts) :
AliAnalysisTaskSE(name),
fPDG(0),
fCFManager(0x0),
fCountRecoAcc(0),
fCountRecoITSClusters(0),
fCountRecoPPR(0),
+ fCountRecoPID(0),
fEvents(0),
fFillFromGenerated(kFALSE),
fMinITSClusters(5),
- fAcceptanceUnf(kTRUE)
+ fAcceptanceUnf(kTRUE),
+ fKeepD0fromB(kFALSE),
+ fCuts(cuts)
{
//
// Constructor. Initialization of Inputs and Outputs
DefineOutput(1,TH1I::Class());
DefineOutput(2,AliCFContainer::Class());
DefineOutput(3,THnSparseD::Class());
+
+ fCuts->PrintAll();
}
//___________________________________________________________________________
fPDG = c.fPDG;
fCFManager = c.fCFManager;
fHistEventsProcessed = c.fHistEventsProcessed;
+ fCuts = c.fCuts;
}
return *this;
}
fCountRecoAcc(c.fCountRecoAcc),
fCountRecoITSClusters(c.fCountRecoITSClusters),
fCountRecoPPR(c.fCountRecoPPR),
+ fCountRecoPID(c.fCountRecoPID),
fEvents(c.fEvents),
fFillFromGenerated(c.fFillFromGenerated),
fMinITSClusters(c.fMinITSClusters),
- fAcceptanceUnf(c.fAcceptanceUnf)
+ fAcceptanceUnf(c.fAcceptanceUnf),
+ fKeepD0fromB(c.fKeepD0fromB),
+ fCuts(c.fCuts)
{
//
// Copy Constructor
if (fCFManager) delete fCFManager ;
if (fHistEventsProcessed) delete fHistEventsProcessed ;
if (fCorrelation) delete fCorrelation ;
+ if (fCuts) delete fCuts ;
}
//_________________________________________________
// Main loop function
//
+ PostData(1,fHistEventsProcessed) ;
+ PostData(2,fCFManager->GetParticleContainer()) ;
+ PostData(3,fCorrelation) ;
+
+ AliESDtrackCuts* trackCuts = fCuts->GetTrackCuts(); // track cuts
+
if (fFillFromGenerated){
AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
}
}
fEvents++;
- if (fEvents%10000 ==0) AliInfo(Form("Event %d",fEvents));
+ if (fEvents%10000 ==0) AliDebug(2,Form("Event %d",fEvents));
AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
- fCFManager->SetEventInfo(aodEvent);
+
+ TClonesArray *arrayD0toKpi=0;
+
+ if(!aodEvent && AODEvent() && IsStandardAOD()) {
+ // In case there is an AOD handler writing a standard AOD, use the AOD
+ // event in memory rather than the input (ESD) event.
+ aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
+ // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
+ // have to taken from the AOD event hold by the AliAODExtension
+ AliAODHandler* aodHandler = (AliAODHandler*)
+ ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+ if(aodHandler->GetExtensions()) {
+ AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
+ AliAODEvent *aodFromExt = ext->GetAOD();
+ arrayD0toKpi=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
+ }
+ } else {
+ arrayD0toKpi=(TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
+ }
+
+
+ if (!arrayD0toKpi) {
+ AliError("Could not find array of HF vertices");
+ return;
+ }
+
+
+ fCFManager->SetRecEventInfo(aodEvent);
+ fCFManager->SetMCEventInfo(aodEvent);
// MC-event selection
- Double_t containerInput[12] ;
- Double_t containerInputMC[12] ;
+ Double_t containerInput[13] ;
+ Double_t containerInputMC[13] ;
//loop on the MC event
TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
- if (!mcArray) AliError("Could not find Monte-Carlo in AOD");
+ if (!mcArray) {
+ AliError("Could not find Monte-Carlo in AOD");
+ return;
+ }
Int_t icountMC = 0;
Int_t icountAcc = 0;
Int_t icountReco = 0;
Int_t icountRecoAcc = 0;
Int_t icountRecoITSClusters = 0;
Int_t icountRecoPPR = 0;
+ Int_t icountRecoPID = 0;
+ AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
+ if (!mcHeader) {
+ AliError("Could not find MC Header in AOD");
+ return;
+ }
+
Int_t cquarks = 0;
// AOD primary vertex
AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
+ Double_t zPrimVertex = vtx1->GetZ();
+ Double_t zMCVertex = mcHeader->GetVtxZ();
Bool_t vtxFlag = kTRUE;
TString title=vtx1->GetTitle();
if(!title.Contains("VertexerTracks")) vtxFlag=kFALSE;
Int_t abspdgGranma = TMath::Abs(pdgGranma);
if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
- continue; // skipping particles that don't come from c quark
+ if (!fKeepD0fromB) continue; // skipping particles that don't come from c quark
}
// if (TMath::Abs(pdgGranma)!=4) {
containerInputMC[9] = -100000.; // dummy value, meaningless in MC, in micron^2
containerInputMC[10] = 1.01; // dummy value, meaningless in MC
containerInputMC[11] = vectorMC[6]; // dummy value, meaningless in MC
+ containerInputMC[12] = zMCVertex; // z of reconstructed of primary vertex
+ if (TMath::Abs(vectorMC[1]) < 0.5) {
+ fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc);
+ }
fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGenerated);
icountMC++;
// checking whether the cuts implemented in the CF are equivalent - simply a cross-check
AliDebug(2, "Daughter particles in acceptance");
if (!fCFManager->CheckParticleCuts(1, mcPartDaughter0)) {
- AliInfo("Inconsistency with CF cut for daughter 0!");
+ AliDebug(2,"Inconsistency with CF cut for daughter 0!");
}
if (!fCFManager->CheckParticleCuts(1, mcPartDaughter1)) {
- AliInfo("Inconsistency with CF cut for daughter 1!");
+ AliDebug(2,"Inconsistency with CF cut for daughter 1!");
}
fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance);
icountAcc++;
// check on the vertex
- if (vtxFlag){
- printf("Vertex cut passed\n");
+ if (fCuts->IsEventSelected(aodEvent)){
+ AliDebug(2,"Vertex cut passed\n");
// filling the container if the vertex is ok
fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex) ;
- printf("Vertex cut passed 2\n");
icountVertex++;
// check on the kTPCrefit and kITSrefit conditions of the daughters
- Bool_t refitFlag = kFALSE;
- for (Int_t iaod =0; iaod<aodEvent->GetNumberOfTracks(); iaod++){
- AliAODTrack *track = (AliAODTrack*)aodEvent->GetTrack(iaod);
- if ((track->GetLabel() == daughter0) || (track->GetLabel() == daughter1) && (((track->GetStatus()&AliESDtrack::kTPCrefit)==AliESDtrack::kTPCrefit) && ((track->GetStatus()&AliESDtrack::kITSrefit)==AliESDtrack::kITSrefit))){
- refitFlag = kTRUE;
+ Bool_t refitFlag = kTRUE;
+ if (trackCuts->GetRequireTPCRefit() || trackCuts->GetRequireITSRefit()){
+ Int_t foundDaughters = 0;
+ for (Int_t iaod =0; iaod<aodEvent->GetNumberOfTracks(); iaod++){
+ AliAODTrack *track = (AliAODTrack*)aodEvent->GetTrack(iaod);
+ if ((track->GetLabel() == daughter0) || (track->GetLabel() == daughter1)) {
+ foundDaughters++;
+ if (trackCuts->GetRequireTPCRefit()) {
+ if(!(track->GetStatus()&AliESDtrack::kTPCrefit)){
+ refitFlag = kFALSE;
+ break;
+ }
+ }
+ if (trackCuts->GetRequireITSRefit()) {
+ if(!(track->GetStatus()&AliESDtrack::kITSrefit)){
+ refitFlag = kFALSE;
+ break;
+ }
+ }
+ }
+ if (foundDaughters == 2){ // both daughters have been checked
+ break;
+ }
}
}
if (refitFlag){
if (cquarks<2) AliDebug(2,Form("Event found with %d c-quarks", cquarks));
- AliInfo(Form("Found %i MC particles that are D0!!",icountMC));
- AliInfo(Form("Found %i MC particles that are D0 and satisfy Acc cuts!!",icountAcc));
- AliInfo(Form("Found %i MC particles that are D0 and satisfy Vertex cuts!!",icountVertex));
- AliInfo(Form("Found %i MC particles that are D0 and satisfy Refit cuts!!",icountRefit));
+ AliDebug(2,Form("Found %i MC particles that are D0!!",icountMC));
+ AliDebug(2,Form("Found %i MC particles that are D0 and satisfy Acc cuts!!",icountAcc));
+ AliDebug(2,Form("Found %i MC particles that are D0 and satisfy Vertex cuts!!",icountVertex));
+ AliDebug(2,Form("Found %i MC particles that are D0 and satisfy Refit cuts!!",icountRefit));
// Now go to rec level
fCountMC += icountMC;
fCountAcc += icountAcc;
- // load heavy flavour vertices
- TClonesArray *arrayD0toKpi = (TClonesArray*)((aodEvent->GetList())->FindObject("D0toKpi"));
- if (!arrayD0toKpi) AliError("Could not find array of HF vertices");
AliDebug(2, Form("Found %d vertices",arrayD0toKpi->GetEntriesFast()));
Int_t pdgDgD0toKpi[2]={321,211};
// check whether the daughters have kTPCrefit and kITSrefit set
AliAODTrack *track0 = (AliAODTrack*)d0tokpi->GetDaughter(0);
AliAODTrack *track1 = (AliAODTrack*)d0tokpi->GetDaughter(1);
- if((!(track0->GetStatus()&AliESDtrack::kTPCrefit)) || (!(track1->GetStatus()&AliESDtrack::kTPCrefit)) || (!(track0->GetStatus()&AliESDtrack::kITSrefit)) || (!(track1->GetStatus()&AliESDtrack::kITSrefit))) {
- // skipping if at least one daughter does not have kTPCrefit or kITSrefit
+ if ((trackCuts->GetRequireTPCRefit() && (!(track0->GetStatus()&AliESDtrack::kTPCrefit) || !(track1->GetStatus()&AliESDtrack::kTPCrefit))) ||
+ (trackCuts->GetRequireITSRefit() && (!(track0->GetStatus()&AliESDtrack::kITSrefit) || !(track1->GetStatus()&AliESDtrack::kITSrefit)))){
+ // skipping if at least one daughter does not have kTPCrefit or kITSrefit, if they were required
continue;
}
// check on the vertex -- could be moved outside the loop on the reconstructed D0...
- if(!vtxFlag) {
+ if(!fCuts->IsEventSelected(aodEvent)) {
// skipping cause vertex is not ok
continue;
}
Int_t abspdgGranma = TMath::Abs(pdgGranma);
if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
AliDebug(2,Form("At Reco level, from MC info: Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
- continue; // skipping particles that don't come from c quark
+ if (!fKeepD0fromB) continue; // skipping particles that don't come from c quark
}
// fill the container...
Double_t pt = d0tokpi->Pt();
Double_t rapidity = d0tokpi->YD0();
-
+ Double_t invMass=0.;
Double_t cosThetaStar = 9999.;
Double_t pTpi = 0.;
Double_t pTK = 0.;
pTK = d0tokpi->PtProng(1);
d0pi = d0tokpi->Getd0Prong(0);
d0K = d0tokpi->Getd0Prong(1);
+ invMass=d0tokpi->InvMassD0();
}
else {
cosThetaStar = d0tokpi->CosThetaStarD0bar();
pTK = d0tokpi->PtProng(0);
d0pi = d0tokpi->Getd0Prong(1);
d0K = d0tokpi->Getd0Prong(0);
+ invMass=d0tokpi->InvMassD0bar();
}
Double_t cT = d0tokpi->CtD0();
containerInput[9] = d0xd0*1.E8; // in micron^2
containerInput[10] = cosPointingAngle; // in micron
containerInput[11] = phi;
+ containerInput[12] = zPrimVertex; // z of reconstructed of primary vertex
}
else {
// ... or with generated values
containerInput[9] = 100000.; // dummy value, meaningless in MC, in micron^2
containerInput[10] = 1.01; // dummy value, meaningless in MC
containerInput[11] = vectorMC[6];
+ containerInput[12] = zMCVertex; // z of reconstructed of primary vertex
}
else {
AliDebug(3,"Problems in filling the container");
continue;
}
}
+
AliDebug(2, Form("Filling the container with pt = %f, rapidity = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, cT = %f", containerInput[0], containerInput[1], containerInput[2], containerInput[3], containerInput[4], containerInput[5]));
icountReco++;
+ printf("%d: filling RECO step\n",iD0toKpi);
fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
// cut in acceptance
- Bool_t acceptanceProng0 = (TMath::Abs(d0tokpi->EtaProng(0))< 0.9 && d0tokpi->PtProng(0) > 0.1);
- Bool_t acceptanceProng1 = (TMath::Abs(d0tokpi->EtaProng(1))< 0.9 && d0tokpi->PtProng(1) > 0.1);
+ Float_t etaCutMin, etaCutMax, ptCutMin, ptCutMax;
+ trackCuts->GetEtaRange(etaCutMin,etaCutMax);
+ trackCuts->GetPtRange(ptCutMin,ptCutMax);
+ Bool_t acceptanceProng0 = (d0tokpi->EtaProng(0)>etaCutMin && d0tokpi->EtaProng(0)<etaCutMax && d0tokpi->PtProng(0) > ptCutMin && d0tokpi->PtProng(0) < ptCutMax);
+ Bool_t acceptanceProng1 = (d0tokpi->EtaProng(1)>etaCutMin && d0tokpi->EtaProng(1)<etaCutMax && d0tokpi->PtProng(1) > ptCutMin && d0tokpi->PtProng(1) < ptCutMax);
if (acceptanceProng0 && acceptanceProng1) {
AliDebug(2,"D0 reco daughters in acceptance");
fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance) ;
}
// cut on the min n. of clusters in ITS
- Int_t ncls0=0;
- for(Int_t l=0;l<6;l++) if(TESTBIT(d0tokpi->GetITSClusterMap(),l)) ncls0++;
- AliDebug(2, Form("n clusters = %d", ncls0));
- if (ncls0 >= fMinITSClusters){
+ if (fCuts->IsSelected(d0tokpi,AliRDHFCuts::kTracks)){
fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters) ;
icountRecoITSClusters++;
AliDebug(2,Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi*1E4, d0K*1E4, d0xd0*1E8, cosPointingAngle));
-
- // PPR cuts
- Double_t cuts[6] = {9999999., 1.1, 0., 9999999., 9999999., 0.};
- if (pt <= 1){
- cuts[0] = 400;
- cuts[1] = 0.8;
- cuts[2] = 0.5;
- cuts[3] = 500;
- cuts[4] = -20000;
- cuts[5] = 0.5;
- }
- else if (pt > 1 && pt <= 2){
- cuts[0] = 300;
- cuts[1] = 0.8;
- cuts[2] = 0.6;
- cuts[3] = 500;
- cuts[4] = -20000;
- cuts[5] = 0.6;
- }
- else if (pt > 2 && pt <= 3){
- cuts[0] = 200;
- cuts[1] = 0.8;
- cuts[2] = 0.7;
- cuts[3] = 500;
- cuts[4] = -20000;
- cuts[5] = 0.8;
- }
- else if (pt > 3 && pt <= 5){
- cuts[0] = 200;
- cuts[1] = 0.8;
- cuts[2] = 0.7;
- cuts[3] = 500;
- cuts[4] = -10000;
- cuts[5] = 0.8;
- }
- else if (pt > 5){
- cuts[0] = 200;
- cuts[1] = 0.8;
- cuts[2] = 0.7;
- cuts[3] = 500;
- cuts[4] = -5000;
- cuts[5] = 0.8;
- }
- if (dca*1E4 < cuts[0]
- && TMath::Abs(cosThetaStar) < cuts[1]
- && pTpi > cuts[2]
- && pTK > cuts[2]
- && TMath::Abs(d0pi*1E4) < cuts[3]
- && TMath::Abs(d0K*1E4) < cuts[3]
- && d0xd0*1E8 < cuts[4]
- && cosPointingAngle > cuts[5]
- ){
-
- AliDebug(2,"Particle passed PPR cuts");
+ AliInfo(Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi, d0K, d0xd0, cosPointingAngle));
+
+
+ if (fCuts->IsSelected(d0tokpi,AliRDHFCuts::kCandidate)>0){
+ AliInfo(Form("Particle passed PPR cuts (actually cuts for D0 analysis!) with pt = %f",containerInput[0]));
+ AliDebug(2,"Particle passed PPR cuts (actually cuts for D0 analysis!)");
fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR) ;
icountRecoPPR++;
fCorrelation->Fill(fill);
}
- }
- else{
- AliDebug(2,"Particle skipped due to PPR cuts");
- if (dca*1E4 > cuts[0]){
- AliDebug(2,"Problems with dca");
- }
- if ( TMath::Abs(cosThetaStar) > cuts[1]){
- AliDebug(2,"Problems with cosThetaStar");
- }
- if (pTpi < cuts[2]){
- AliDebug(2,"Problems with pTpi");
- }
- if (pTK < cuts[2]){
- AliDebug(2,"Problems with pTK");
- }
- if (TMath::Abs(d0pi*1E4) > cuts[3]){
- AliDebug(2,"Problems with d0pi");
- }
- if (TMath::Abs(d0K*1E4) > cuts[3]){
- AliDebug(2,"Problems with d0K");
- }
- if (d0xd0*1E8 > cuts[4]){
- AliDebug(2,"Problems with d0xd0");
- }
- if (cosPointingAngle < cuts[5]){
- AliDebug(2,"Problems with cosPointingAngle");
+ if (fCuts->IsSelected(d0tokpi,AliRDHFCuts::kPID)>0){
+ AliInfo(Form("Particle passed PID cuts with pt = %f",containerInput[0]));
+ AliDebug(2,"Particle passed PID cuts");
+ fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPID) ;
+ icountRecoPID++;
}
}
}
fCountRecoAcc+= icountRecoAcc;
fCountRecoITSClusters+= icountRecoITSClusters;
fCountRecoPPR+= icountRecoPPR;
+ fCountRecoPID+= icountRecoPID;
fHistEventsProcessed->Fill(0);
/* PostData(0) is taken care of by AliAnalysisTaskSE */
- PostData(1,fHistEventsProcessed) ;
- PostData(2,fCFManager->GetParticleContainer()) ;
- PostData(3,fCorrelation) ;
+ //PostData(1,fHistEventsProcessed) ;
+ //PostData(2,fCFManager->GetParticleContainer()) ;
+ //PostData(3,fCorrelation) ;
}
// draw some example plots....
+ // AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
if(!cont) {
printf("CONTAINER NOT FOUND\n");
corr2->Draw("text");
- TFile* file_projection = new TFile("file_projection.root","RECREATE");
+ TFile* file_projection = new TFile("CFtaskHFprojection.root","RECREATE");
corr1->Write();
corr2->Write();
c2->SaveAs("Plots/pTpi_pTK_cT.gif");
c3->SaveAs("Plots/dca_d0pi_d0TK.gif");
c4->SaveAs("Plots/d0xd0_cosPointingAngle.gif");
- */
+ */
}
//___________________________________________________________________________
//slot #1
OpenFile(1);
- fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
+ fHistEventsProcessed = new TH1I("CFHFchist0","",1,0,1) ;
}
//___________________________________________________________________________
}
return pdgGranma;
}
-