From 896d320003baa3ecdb222ca8882ca5eee828af5c Mon Sep 17 00:00:00 2001 From: hristov Date: Wed, 15 Jan 2014 18:45:35 +0100 Subject: [PATCH] Corrected end-of-line behavior --- ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C | 986 +- .../TenderSupplies/AliTRDTenderSupply.cxx | 6 +- HLT/CALO/AliHLTCaloDigitMaker.cxx | 670 +- ITS/UPGRADE/AliITSUClusterizer.h | 466 +- OADB/AliOADBCentrality.h | 346 +- PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.cxx | 3076 ++-- PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.h | 170 +- PWG/muon/AliAnalysisTaskESDMuonFilter.h | 114 +- PWG/muon/AliUtilityMuonAncestor.cxx | 590 +- PWG/muon/AliUtilityMuonAncestor.h | 136 +- .../DPhi/AliAnalysisTaskMinijet.h | 398 +- .../DPhi/TriggerPID/AliAnalysisTaskPIDCORR.h | 2 +- .../DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx | 5458 +++---- .../macros/dphicorrelations/AddTaskContMC.C | 84 +- .../macros/fd/AddTaskPicoTracksDhc.C | 72 +- .../Correlations/macros/minijet/analyse_pA.C | 1462 +- .../BalanceFunctions/AliAnalysisTaskBFPsi.cxx | 4718 +++--- .../BalanceFunctions/AliAnalysisTaskBFPsi.h | 756 +- .../AliAnalysisTaskEventMixingBF.cxx | 1384 +- PWGCF/EBYE/LRC/AliAnalysisTaskLRC.h | 816 +- PWGCF/EBYE/LRC/AliLRCProcess.cxx | 2862 ++-- .../AliEbyEParticleRatioFluctuationTask.cxx | 710 +- .../macros/AddTaskBalancePsiCentralityTrain.C | 538 +- .../macros/configBalanceFunctionPsiAnalysis.C | 160 +- PWGCF/EBYE/macros/runBalanceFunctionPsi.C | 1020 +- .../Kch_Eta05Pt01415/ConfigFemtoAnalysis.C | 668 +- PWGCF/FLOW/macros/AddTaskFlowCascade.C | 444 +- .../FLOW/macros/AddTaskFlowHigherOrdersPID.C | 1364 +- .../macros/runTaskFlowHigherOrdersAllPID.C | 1040 +- PWGDQ/dielectron/AliDielectronBtoJPSItoEle.h | 94 +- .../AliDielectronBtoJPSItoEleCDFfitFCN.h | 566 +- .../AliDielectronBtoJPSItoEleCDFfitHandler.h | 160 +- .../macrosLMEE/AddTask_oezdemir_pp2012.C | 180 +- .../dielectron/macrosLMEE/AddTask_shin_pPb.C | 158 +- .../macrosLMEE/AddTask_shin_pPbTRD.C | 182 +- .../macrosLMEE/Config_shin_pPbTRD.C | 1032 +- .../macrosLMEE/Configpp2012Oezdemir.C | 992 +- PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhoton.h | 584 +- PWGGA/GammaConv/AliAnaConvCorrBase.h | 218 +- PWGGA/GammaConv/AliAnaConvCorrPion.h | 88 +- PWGGA/GammaConv/AliDalitzElectronCuts.cxx | 3604 ++--- .../PHOS_pp_pi0/AliAnalysisTaskPi0.h | 156 +- .../PHOS_pp_pi0/macros/MakeFinalSpectrum.C | 768 +- .../PHOS_pp_pi0/macros/makeMmixPU_CB.C | 968 +- .../PHOS_pp_pi0/macros/makeMmixPU_GS.C | 842 +- .../AliHFAssociatedTrackCuts.cxx | 1436 +- .../correlationHF/AliHFAssociatedTrackCuts.h | 418 +- PWGHF/correlationHF/AliHFCorrelator.cxx | 1044 +- PWGHF/correlationHF/AliHFCorrelator.h | 324 +- .../macros/AddTaskDStarCorrelations.C | 750 +- PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.cxx | 5770 +++---- PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.h | 628 +- PWGHF/hfe/AliAnalysisTaskHFEQA.cxx | 1288 +- PWGHF/hfe/AliAnalysisTaskHFEQA.h | 294 +- PWGHF/hfe/macros/AddTaskFlowITSTPCTOFQCSP.C | 696 +- PWGHF/hfe/macros/AddTaskFlowTPCEMCalQCSP.C | 740 +- PWGHF/hfe/macros/AddTaskHFEnpePbPb.C | 334 +- PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C | 172 +- .../AliAnalysisTaskSECharmFraction.h | 358 +- .../AliAnalysisTaskFlavourJetCorrelations.h | 252 +- .../AliAnalysisTaskSEDmesonsFilterCJ.cxx | 1126 +- .../AliAnalysisTaskSEDmesonsFilterCJ.h | 204 +- .../macros/AddTaskFlavourJetCorrelations.C | 200 +- .../macros/AddTaskSEDmesonsFilterCJ.C | 188 +- PWGJE/macros/PID/AddUpSystematicErrors.C | 556 +- PWGJE/macros/PID/PID.C | 12506 ++++++++-------- PWGJE/macros/PID/SystematicErrorEstimation.C | 1034 +- PWGLF/QATasks/AliAnalysisTaskQAHighPtDeDx.cxx | 4080 ++--- PWGLF/QATasks/macros/AddTaskQAHighPtDeDx.C | 174 +- PWGLF/QATasks/post/multistrangeQA.C | 974 +- .../lego_train/AddRsnDaughterCutsPhiNsigma.C | 512 +- .../B2/macros/Config_Deuteron_TOF_LHC10x.C | 322 +- .../B2/macros/Config_Deuteron_TPC_LHC10x.C | 256 +- .../Nuclei/B2/macros/Config_He3_TPC_LHC10x.C | 252 +- PWGLF/SPECTRA/Nuclei/B2/macros/LHC10bcde.C | 316 +- .../SPECTRA/PiKaPr/TPCTOFpA/AddTaskTPCTOFpA.C | 186 +- .../PiKaPr/TestAOD/AddTaskSpectraAOD.C | 208 +- .../PiKaPr/TestAOD/AddTaskSpectraAllChAOD.C | 202 +- .../PiKaPr/TestAOD/AddTaskSpectraBoth.C | 242 +- .../TestAOD/AliAnalysisTaskSpectraAOD.cxx | 498 +- .../AliAnalysisTaskSpectraAllChAOD.cxx | 570 +- .../TestAOD/AliAnalysisTaskSpectraAllChAOD.h | 170 +- .../TestAOD/AliAnalysisTaskSpectraBoth.cxx | 866 +- .../AliAnalysisTaskCheckCascadepp276.cxx | 4414 +++--- ...alysisTaskCheckPerformanceCascadepp276.cxx | 6536 ++++---- .../macros/runGridLambdaOverK0sJets.C | 328 +- .../AliAnalysisTaskHdibaryonLPpi.cxx | 3116 ++-- .../AliAnalysisTaskHdibaryonLPpi.h | 352 +- .../Hypernuclei/AliAnalysisTaskHelium3Pi.cxx | 1910 +-- .../AliAnalysisTaskHelium3PiMC.cxx | 2644 ++-- PWGLF/totEt/AliAnalysisTaskHadEt.h | 96 +- PWGLF/totEt/AliAnalysisTaskTotEt.h | 94 +- PWGPP/AliAnalysisTaskFilteredTree.cxx | 5330 +++---- STARLIGHT/starlight/Readme | 260 +- STARLIGHT/starlight/config/my.input | 90 +- STARLIGHT/starlight/dpmjet/dpmjetint.f | 310 +- 96 files changed, 53367 insertions(+), 53367 deletions(-) diff --git a/ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C b/ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C index 2fbdd73ceaa..f9ea353b125 100644 --- a/ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C +++ b/ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C @@ -1,493 +1,493 @@ - -Bool_t AddTrackCutsLHC10bcde(AliAnalysisTaskESDfilter* esdFilter); -Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdFilter); -Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdFilter); -Bool_t enableTPCOnlyAODTracksLocalFlag=kFALSE; - - -AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE, - Bool_t writeMuonAOD=kFALSE, - Bool_t writeDimuonAOD=kFALSE, - Bool_t usePhysicsSelection=kFALSE, - Bool_t useCentralityTask=kFALSE, /*obsolete*/ - Bool_t enableTPCOnlyAODTracks=kFALSE, - Bool_t disableCascades=kFALSE, - Bool_t disableKinks=kFALSE, - Int_t runFlag = 1100, - Int_t muonMCMode = 2, - Bool_t useV0Filter=kTRUE) -{ - // Creates a filter task and adds it to the analysis manager. - // Get the pointer to the existing analysis manager via the static access method. - //============================================================================== - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - ::Error("AddTaskESDFilter", "No analysis manager to connect to."); - return NULL; - } - - // This task requires an ESD input handler and an AOD output handler. - // Check this using the analysis manager. - //=============================================================================== - TString type = mgr->GetInputEventHandler()->GetDataType(); - if (!type.Contains("ESD")) { - ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler."); - return NULL; - } - // Check if AOD output handler exist. - AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler(); - if (!aod_h) { - ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler."); - return NULL; - } - // Check if MC handler is connected in case kine filter requested - AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler(); - if (!mcH && useKineFilter) { - ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested"); - return NULL; - } - - // Create the task, add it to the manager and configure it. - //=========================================================================== - // Barrel tracks filter - AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter"); - if (disableCascades) esdfilter->DisableCascades(); - if (disableKinks) esdfilter->DisableKinks(); - - mgr->AddTask(esdfilter); - - // Muons - Bool_t onlyMuon=kTRUE; - Bool_t keepAllEvents=kTRUE; - Int_t mcMode= useKineFilter ? muonMCMode : 0; // use 1 instead of 2 to get all MC information instead of just ancestors of mu tracks - AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter",onlyMuon,keepAllEvents,mcMode); - mgr->AddTask(esdmuonfilter); - if(usePhysicsSelection){ - esdfilter->SelectCollisionCandidates(AliVEvent::kAny); - esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny); - } - - // Filtering of MC particles (decays conversions etc) - // this task has to go AFTER all other filter tasks - // since it fills the AODMC array with all - // selected MC Particles, only this way we have the - // AODMCparticle information available for following tasks - AliAnalysisTaskMCParticleFilter *kinefilter = 0; - if (useKineFilter) { - kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter"); - mgr->AddTask(kinefilter); - } - - enableTPCOnlyAODTracksLocalFlag = enableTPCOnlyAODTracks; - if((runFlag/100)==10){ - if((runFlag%100)==0) AddTrackCutsLHC10bcde(esdfilter); - else AddTrackCutsLHC10h(esdfilter); - } - else { - // default 11h - AddTrackCutsLHC11h(esdfilter); - } - - // Filter with cuts on V0s - if (useV0Filter) { - AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts"); - esdV0Cuts->SetMinRadius(0.2); - esdV0Cuts->SetMaxRadius(200); - esdV0Cuts->SetMinDcaPosToVertex(0.05); - esdV0Cuts->SetMinDcaNegToVertex(0.05); - esdV0Cuts->SetMaxDcaV0Daughters(1.5); - esdV0Cuts->SetMinCosinePointingAngle(0.99); - AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter"); - v0Filter->AddCuts(esdV0Cuts); - - esdfilter->SetV0Filter(v0Filter); - } - - // Enable writing of Muon AODs - esdmuonfilter->SetWriteMuonAOD(writeMuonAOD); - - // Enable writing of Dimuon AODs - esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD); - - // Create ONLY the output containers for the data produced by the task. - // Get and connect other common input/output containers via the manager as below - //============================================================================== - mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer()); - mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer()); - if (useKineFilter) { - mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer()); - AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(), - AliAnalysisManager::kOutputContainer,"pyxsec_hists.root"); - mgr->ConnectOutput (kinefilter, 1,coutputEx); - } - return esdfilter; -} - - - - -Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdfilter){ - - Printf("%s%d: Creating Track Cuts for LHC10h",(char*)__FILE__,__LINE__); - - // Cuts on primary tracks - AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - - // ITS stand-alone tracks - AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); - esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); - - // Pixel OR necessary for the electrons - AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); - itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - - - // PID for the electrons - AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); - electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); - - // tighter cuts on primary particles for high pT tracks - // take the standard cuts, which include already - // ITSrefit and use only primaries... - - // ITS cuts for new jet analysis - // gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C"); - // AliESDtrackCuts* esdTrackCutsHG0 = CreateTrackCutsPWGJE(10001006); - - AliESDtrackCuts *jetCuts1006 = new AliESDtrackCuts("AliESDtrackCuts"); - - TFormula *f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x"); - jetCuts1006->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.); - jetCuts1006->SetMinNClustersTPC(70); - jetCuts1006->SetMaxChi2PerClusterTPC(4); - jetCuts1006->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1 - jetCuts1006->SetAcceptKinkDaughters(kFALSE); - jetCuts1006->SetRequireTPCRefit(kTRUE); - jetCuts1006->SetMaxFractionSharedTPCClusters(0.4); - // ITS - jetCuts1006->SetRequireITSRefit(kTRUE); - //accept secondaries - jetCuts1006->SetMaxDCAToVertexXY(2.4); - jetCuts1006->SetMaxDCAToVertexZ(3.2); - jetCuts1006->SetDCAToVertex2D(kTRUE); - //reject fakes - jetCuts1006->SetMaxChi2PerClusterITS(36); - jetCuts1006->SetMaxChi2TPCConstrainedGlobal(36); - - jetCuts1006->SetRequireSigmaToVertex(kFALSE); - - jetCuts1006->SetEtaRange(-0.9,0.9); - jetCuts1006->SetPtRange(0.15, 1E+15.); - - AliESDtrackCuts* esdTrackCutsHG0 = jetCuts1006->Clone("JetCuts10001006"); - esdTrackCutsHG0->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - - - // throw out tracks with too low number of clusters in - // the first pass (be consistent with TPC only tracks) - // N.B. the number off crossed rows still acts on the tracks after - // all iterations if we require tpc standalone, number of clusters - // and chi2 TPC cuts act on track after the first iteration - // esdTrackCutsH0->SetRequireTPCStandAlone(kTRUE); - // esdTrackCutsH0->SetMinNClustersTPC(80); // <--- first pass - - - // the complement to the one with SPD requirement - // AliESDtrackCuts* esdTrackCutsHG1 = CreateTrackCutsPWGJE(10011006); - AliESDtrackCuts* esdTrackCutsHG1 = jetCuts1006->Clone("JetCuts10011006"); - esdTrackCutsHG1->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); - - // the tracks that must not be taken pass this cut and - // non HGC1 and HG - // AliESDtrackCuts* esdTrackCutsHG2 = CreateTrackCutsPWGJE(10021006); - AliESDtrackCuts* esdTrackCutsHG2 = jetCuts1006->Clone("JetCuts10021006"); - esdTrackCutsHG2->SetMaxChi2PerClusterITS(1E10); - - - // standard cuts also used in R_AA analysis - // "Global track RAA analysis QM2011 + Chi2ITS<36"; - // AliESDtrackCuts* esdTrackCutsH2 = CreateTrackCutsPWGJE(1000); - AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1); - esdTrackCutsH2->SetMinNCrossedRowsTPC(120); - esdTrackCutsH2->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); - esdTrackCutsH2->SetMaxChi2PerClusterITS(36); - esdTrackCutsH2->SetMaxFractionSharedTPCClusters(0.4); - esdTrackCutsH2->SetMaxChi2TPCConstrainedGlobal(36); - - esdTrackCutsH2->SetEtaRange(-0.9,0.9); - esdTrackCutsH2->SetPtRange(0.15, 1e10); - - - // AliESDtrackCuts* esdTrackCutsGCOnly = CreateTrackCutsPWGJE(10041006); - AliESDtrackCuts* esdTrackCutsGCOnly = jetCuts1006->Clone("JetCuts10041006"); - esdTrackCutsGCOnly->SetRequireITSRefit(kFALSE); - - // TPC only tracks - AliESDtrackCuts* esdTrackCutsTPCCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - esdTrackCutsTPCCOnly->SetMinNClustersTPC(70); - - // Compose the filter - AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); - // 1, 1<<0 - trackFilter->AddCuts(esdTrackCutsL); - // 2 1<<1 - trackFilter->AddCuts(esdTrackCutsITSsa); - // 4 1<<2 - trackFilter->AddCuts(itsStrong); - itsStrong->SetFilterMask(1); // AND with Standard track cuts - // 8 1<<3 - trackFilter->AddCuts(electronID); - electronID->SetFilterMask(4); // AND with Pixel Cuts - // 16 1<<4 - trackFilter->AddCuts(esdTrackCutsHG0); - // 32 1<<5 - trackFilter->AddCuts(esdTrackCutsHG1); - // 64 1<<6 - trackFilter->AddCuts(esdTrackCutsHG2); - // 128 1<<7 - trackFilter->AddCuts(esdTrackCutsTPCCOnly); // add QM TPC only track cuts - if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); - // 256 1<<8 - trackFilter->AddCuts(esdTrackCutsGCOnly); - // 512 1<<9 - AliESDtrackCuts* esdTrackCutsHG1_tmp = new AliESDtrackCuts(*esdTrackCutsHG1); // avoid double delete - trackFilter->AddCuts(esdTrackCutsHG1_tmp); // add once more for tpc only tracks - // 1024 1<<10 - trackFilter->AddCuts(esdTrackCutsH2); // add r_aa cuts - - - - esdfilter->SetGlobalConstrainedFilterMask(1<<8|1<<9); // these tracks are written out as global constrained tracks - esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<4)); // these normal global tracks will be marked as hybrid - esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement - // esdfilter->SetTPCConstrainedFilterMask(1<<11); // these tracks are written out as tpc constrained tracks - - esdfilter->SetTrackFilter(trackFilter); - return kTRUE; - -} - - -Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdfilter){ - - - Printf("%s%d: Creating Track Cuts LHC11h",(char*)__FILE__,__LINE__); - - // Cuts on primary tracks - AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - - // ITS stand-alone tracks - AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); - esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); - - // Pixel OR necessary for the electrons - AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); - itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - - - // PID for the electrons - AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); - electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); - - // standard cuts with very loose DCA - AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE); - esdTrackCutsH->SetMaxDCAToVertexXY(2.4); - esdTrackCutsH->SetMaxDCAToVertexZ(3.2); - esdTrackCutsH->SetDCAToVertex2D(kTRUE); - - // standard cuts with tight DCA cut - AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(); - - // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster - // tracks selected by this cut are exclusive to those selected by the previous cut - AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(); - esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); - esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst); - - // TPC only tracks: Optionally enable the writing of TPConly information - // constrained to SPD vertex in the filter below - AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb - //esdTrackCutsTPCOnly->SetMinNClustersTPC(70); - - // Extra cuts for hybrids - // first the global tracks we want to take - AliESDtrackCuts* esdTrackCutsHTG = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE); - esdTrackCutsHTG->SetName("Global Hybrid tracks, loose DCA"); - esdTrackCutsHTG->SetMaxDCAToVertexXY(2.4); - esdTrackCutsHTG->SetMaxDCAToVertexZ(3.2); - esdTrackCutsHTG->SetDCAToVertex2D(kTRUE); - esdTrackCutsHTG->SetMaxChi2TPCConstrainedGlobal(36); - esdTrackCutsHTG->SetMaxFractionSharedTPCClusters(0.4); - - - // Than the complementary tracks which will be stored as global - // constraint, complement is done in the ESDFilter task - AliESDtrackCuts* esdTrackCutsHTGC = new AliESDtrackCuts(*esdTrackCutsHTG); - esdTrackCutsHTGC->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement"); - esdTrackCutsHTGC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff); - esdTrackCutsHTGC->SetRequireITSRefit(kTRUE); - - // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default) - AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, 0); - - // Compose the filter - AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); - // 1, 1<<0 - trackFilter->AddCuts(esdTrackCutsL); - // 2, 1<<1 - trackFilter->AddCuts(esdTrackCutsITSsa); - // 4, 1<<2 - trackFilter->AddCuts(itsStrong); - itsStrong->SetFilterMask(1); // AND with Standard track cuts - // 8, 1<<3 - trackFilter->AddCuts(electronID); - electronID->SetFilterMask(4); // AND with Pixel Cuts - // 16, 1<<4 - trackFilter->AddCuts(esdTrackCutsH); - // 32, 1<<5 - trackFilter->AddCuts(esdTrackCutsH2); - // 64, 1<<6 - trackFilter->AddCuts(esdTrackCutsH3); - // 128 , 1 << 7 - trackFilter->AddCuts(esdTrackCutsTPCOnly); - if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); - // 256, 1 << 8 Global Hybrids - trackFilter->AddCuts(esdTrackCutsHTG); - esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid - // 512, 1<< 9 GlobalConstraint Hybrids - trackFilter->AddCuts(esdTrackCutsHTGC); - esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks - esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement - // 1024, 1<< 10 // tight DCA cuts - trackFilter->AddCuts(esdTrackCutsH2Cluster); - esdfilter->SetTrackFilter(trackFilter); - - return kTRUE; - -} - -Bool_t AddTrackCutsLHC10bcde(AliAnalysisTaskESDfilter* esdfilter){ - - - Printf("%s%d: Creating Track Cuts LHC10bcde",(char*)__FILE__,__LINE__); - - // Cuts on primary tracks - AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - - // ITS stand-alone tracks - AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); - esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); - - // Pixel OR necessary for the electrons - AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); - itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - - - // PID for the electrons - AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); - electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); - - // standard cuts with very loose DCA - AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE); - esdTrackCutsH->SetMaxDCAToVertexXY(2.4); - esdTrackCutsH->SetMaxDCAToVertexZ(3.2); - esdTrackCutsH->SetDCAToVertex2D(kTRUE); - - // standard cuts with tight DCA cut - AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); - - // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster - // tracks selected by this cut are exclusive to those selected by the previous cut - AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); - esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); - esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst); - - // TPC only tracks: Optionally enable the writing of TPConly information - // constrained to SPD vertex in the filter below - AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb - esdTrackCutsTPCOnly->SetMinNClustersTPC(70); - - // Extra cuts for hybrids - // first the global tracks we want to take - // take the HTGs from 10h - - // gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C"); - // AliESDtrackCuts* esdTrackCutsHG0 = CreateTrackCutsPWGJE(10001006); - - AliESDtrackCuts *jetCuts1006 = new AliESDtrackCuts("AliESDtrackCuts"); - - TFormula *f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x"); - jetCuts1006->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.); - jetCuts1006->SetMinNClustersTPC(70); - jetCuts1006->SetMaxChi2PerClusterTPC(4); - jetCuts1006->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1 - jetCuts1006->SetAcceptKinkDaughters(kFALSE); - jetCuts1006->SetRequireTPCRefit(kTRUE); - jetCuts1006->SetMaxFractionSharedTPCClusters(0.4); - // ITS - jetCuts1006->SetRequireITSRefit(kTRUE); - //accept secondaries - jetCuts1006->SetMaxDCAToVertexXY(2.4); - jetCuts1006->SetMaxDCAToVertexZ(3.2); - jetCuts1006->SetDCAToVertex2D(kTRUE); - //reject fakes - jetCuts1006->SetMaxChi2PerClusterITS(36); - jetCuts1006->SetMaxChi2TPCConstrainedGlobal(36); - - jetCuts1006->SetRequireSigmaToVertex(kFALSE); - - jetCuts1006->SetEtaRange(-0.9,0.9); - jetCuts1006->SetPtRange(0.15, 1E+15.); - - AliESDtrackCuts* esdTrackCutsHTG = jetCuts1006->Clone("JetCuts10001006"); - esdTrackCutsHTG->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - - // Than the complementary tracks which will be stored as global - // constraint, complement is done in the ESDFilter task - // HGC from 10h - - AliESDtrackCuts* esdTrackCutsHTGC = jetCuts1006->Clone("JetCuts10041006"); - esdTrackCutsHTGC->SetRequireITSRefit(kFALSE); - - // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default) - AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE, 0); - - // Compose the filter - AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); - // 1, 1<<0 - trackFilter->AddCuts(esdTrackCutsL); - // 2, 1<<1 - trackFilter->AddCuts(esdTrackCutsITSsa); - // 4, 1<<2 - trackFilter->AddCuts(itsStrong); - itsStrong->SetFilterMask(1); // AND with Standard track cuts - // 8, 1<<3 - trackFilter->AddCuts(electronID); - electronID->SetFilterMask(4); // AND with Pixel Cuts - // 16, 1<<4 - trackFilter->AddCuts(esdTrackCutsH); - // 32, 1<<5 - trackFilter->AddCuts(esdTrackCutsH2); - // 64, 1<<6 - trackFilter->AddCuts(esdTrackCutsH3); - // 128 , 1 << 7 - trackFilter->AddCuts(esdTrackCutsTPCOnly); - if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); - // 256, 1 << 8 Global Hybrids - trackFilter->AddCuts(esdTrackCutsHTG); - esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid - // 512, 1<< 9 GlobalConstraint Hybrids - trackFilter->AddCuts(esdTrackCutsHTGC); - esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks - esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement - // 1024, 1<< 10 // tight DCA cuts - trackFilter->AddCuts(esdTrackCutsH2Cluster); - esdfilter->SetTrackFilter(trackFilter); - - return kTRUE; - -} + +Bool_t AddTrackCutsLHC10bcde(AliAnalysisTaskESDfilter* esdFilter); +Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdFilter); +Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdFilter); +Bool_t enableTPCOnlyAODTracksLocalFlag=kFALSE; + + +AliAnalysisTaskESDfilter *AddTaskESDFilter(Bool_t useKineFilter=kTRUE, + Bool_t writeMuonAOD=kFALSE, + Bool_t writeDimuonAOD=kFALSE, + Bool_t usePhysicsSelection=kFALSE, + Bool_t useCentralityTask=kFALSE, /*obsolete*/ + Bool_t enableTPCOnlyAODTracks=kFALSE, + Bool_t disableCascades=kFALSE, + Bool_t disableKinks=kFALSE, + Int_t runFlag = 1100, + Int_t muonMCMode = 2, + Bool_t useV0Filter=kTRUE) +{ + // Creates a filter task and adds it to the analysis manager. + // Get the pointer to the existing analysis manager via the static access method. + //============================================================================== + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error("AddTaskESDFilter", "No analysis manager to connect to."); + return NULL; + } + + // This task requires an ESD input handler and an AOD output handler. + // Check this using the analysis manager. + //=============================================================================== + TString type = mgr->GetInputEventHandler()->GetDataType(); + if (!type.Contains("ESD")) { + ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an ESD input handler."); + return NULL; + } + // Check if AOD output handler exist. + AliAODHandler *aod_h = (AliAODHandler*)mgr->GetOutputEventHandler(); + if (!aod_h) { + ::Error("AddTaskESDFilter", "ESD filtering task needs the manager to have an AOD output handler."); + return NULL; + } + // Check if MC handler is connected in case kine filter requested + AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler(); + if (!mcH && useKineFilter) { + ::Error("AddTaskESDFilter", "No MC handler connected while kine filtering requested"); + return NULL; + } + + // Create the task, add it to the manager and configure it. + //=========================================================================== + // Barrel tracks filter + AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter"); + if (disableCascades) esdfilter->DisableCascades(); + if (disableKinks) esdfilter->DisableKinks(); + + mgr->AddTask(esdfilter); + + // Muons + Bool_t onlyMuon=kTRUE; + Bool_t keepAllEvents=kTRUE; + Int_t mcMode= useKineFilter ? muonMCMode : 0; // use 1 instead of 2 to get all MC information instead of just ancestors of mu tracks + AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter",onlyMuon,keepAllEvents,mcMode); + mgr->AddTask(esdmuonfilter); + if(usePhysicsSelection){ + esdfilter->SelectCollisionCandidates(AliVEvent::kAny); + esdmuonfilter->SelectCollisionCandidates(AliVEvent::kAny); + } + + // Filtering of MC particles (decays conversions etc) + // this task has to go AFTER all other filter tasks + // since it fills the AODMC array with all + // selected MC Particles, only this way we have the + // AODMCparticle information available for following tasks + AliAnalysisTaskMCParticleFilter *kinefilter = 0; + if (useKineFilter) { + kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Kine Filter"); + mgr->AddTask(kinefilter); + } + + enableTPCOnlyAODTracksLocalFlag = enableTPCOnlyAODTracks; + if((runFlag/100)==10){ + if((runFlag%100)==0) AddTrackCutsLHC10bcde(esdfilter); + else AddTrackCutsLHC10h(esdfilter); + } + else { + // default 11h + AddTrackCutsLHC11h(esdfilter); + } + + // Filter with cuts on V0s + if (useV0Filter) { + AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("Standard V0 Cuts pp", "ESD V0 Cuts"); + esdV0Cuts->SetMinRadius(0.2); + esdV0Cuts->SetMaxRadius(200); + esdV0Cuts->SetMinDcaPosToVertex(0.05); + esdV0Cuts->SetMinDcaNegToVertex(0.05); + esdV0Cuts->SetMaxDcaV0Daughters(1.5); + esdV0Cuts->SetMinCosinePointingAngle(0.99); + AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter"); + v0Filter->AddCuts(esdV0Cuts); + + esdfilter->SetV0Filter(v0Filter); + } + + // Enable writing of Muon AODs + esdmuonfilter->SetWriteMuonAOD(writeMuonAOD); + + // Enable writing of Dimuon AODs + esdmuonfilter->SetWriteDimuonAOD(writeDimuonAOD); + + // Create ONLY the output containers for the data produced by the task. + // Get and connect other common input/output containers via the manager as below + //============================================================================== + mgr->ConnectInput (esdfilter, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput (esdfilter, 0, mgr->GetCommonOutputContainer()); + mgr->ConnectInput (esdmuonfilter, 0, mgr->GetCommonInputContainer()); + if (useKineFilter) { + mgr->ConnectInput (kinefilter, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput (kinefilter, 0, mgr->GetCommonOutputContainer()); + AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(), + AliAnalysisManager::kOutputContainer,"pyxsec_hists.root"); + mgr->ConnectOutput (kinefilter, 1,coutputEx); + } + return esdfilter; +} + + + + +Bool_t AddTrackCutsLHC10h(AliAnalysisTaskESDfilter* esdfilter){ + + Printf("%s%d: Creating Track Cuts for LHC10h",(char*)__FILE__,__LINE__); + + // Cuts on primary tracks + AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + + // ITS stand-alone tracks + AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); + esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); + + // Pixel OR necessary for the electrons + AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); + itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + + + // PID for the electrons + AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); + electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); + + // tighter cuts on primary particles for high pT tracks + // take the standard cuts, which include already + // ITSrefit and use only primaries... + + // ITS cuts for new jet analysis + // gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C"); + // AliESDtrackCuts* esdTrackCutsHG0 = CreateTrackCutsPWGJE(10001006); + + AliESDtrackCuts *jetCuts1006 = new AliESDtrackCuts("AliESDtrackCuts"); + + TFormula *f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x"); + jetCuts1006->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.); + jetCuts1006->SetMinNClustersTPC(70); + jetCuts1006->SetMaxChi2PerClusterTPC(4); + jetCuts1006->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1 + jetCuts1006->SetAcceptKinkDaughters(kFALSE); + jetCuts1006->SetRequireTPCRefit(kTRUE); + jetCuts1006->SetMaxFractionSharedTPCClusters(0.4); + // ITS + jetCuts1006->SetRequireITSRefit(kTRUE); + //accept secondaries + jetCuts1006->SetMaxDCAToVertexXY(2.4); + jetCuts1006->SetMaxDCAToVertexZ(3.2); + jetCuts1006->SetDCAToVertex2D(kTRUE); + //reject fakes + jetCuts1006->SetMaxChi2PerClusterITS(36); + jetCuts1006->SetMaxChi2TPCConstrainedGlobal(36); + + jetCuts1006->SetRequireSigmaToVertex(kFALSE); + + jetCuts1006->SetEtaRange(-0.9,0.9); + jetCuts1006->SetPtRange(0.15, 1E+15.); + + AliESDtrackCuts* esdTrackCutsHG0 = jetCuts1006->Clone("JetCuts10001006"); + esdTrackCutsHG0->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + + + // throw out tracks with too low number of clusters in + // the first pass (be consistent with TPC only tracks) + // N.B. the number off crossed rows still acts on the tracks after + // all iterations if we require tpc standalone, number of clusters + // and chi2 TPC cuts act on track after the first iteration + // esdTrackCutsH0->SetRequireTPCStandAlone(kTRUE); + // esdTrackCutsH0->SetMinNClustersTPC(80); // <--- first pass + + + // the complement to the one with SPD requirement + // AliESDtrackCuts* esdTrackCutsHG1 = CreateTrackCutsPWGJE(10011006); + AliESDtrackCuts* esdTrackCutsHG1 = jetCuts1006->Clone("JetCuts10011006"); + esdTrackCutsHG1->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); + + // the tracks that must not be taken pass this cut and + // non HGC1 and HG + // AliESDtrackCuts* esdTrackCutsHG2 = CreateTrackCutsPWGJE(10021006); + AliESDtrackCuts* esdTrackCutsHG2 = jetCuts1006->Clone("JetCuts10021006"); + esdTrackCutsHG2->SetMaxChi2PerClusterITS(1E10); + + + // standard cuts also used in R_AA analysis + // "Global track RAA analysis QM2011 + Chi2ITS<36"; + // AliESDtrackCuts* esdTrackCutsH2 = CreateTrackCutsPWGJE(1000); + AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1); + esdTrackCutsH2->SetMinNCrossedRowsTPC(120); + esdTrackCutsH2->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); + esdTrackCutsH2->SetMaxChi2PerClusterITS(36); + esdTrackCutsH2->SetMaxFractionSharedTPCClusters(0.4); + esdTrackCutsH2->SetMaxChi2TPCConstrainedGlobal(36); + + esdTrackCutsH2->SetEtaRange(-0.9,0.9); + esdTrackCutsH2->SetPtRange(0.15, 1e10); + + + // AliESDtrackCuts* esdTrackCutsGCOnly = CreateTrackCutsPWGJE(10041006); + AliESDtrackCuts* esdTrackCutsGCOnly = jetCuts1006->Clone("JetCuts10041006"); + esdTrackCutsGCOnly->SetRequireITSRefit(kFALSE); + + // TPC only tracks + AliESDtrackCuts* esdTrackCutsTPCCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + esdTrackCutsTPCCOnly->SetMinNClustersTPC(70); + + // Compose the filter + AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); + // 1, 1<<0 + trackFilter->AddCuts(esdTrackCutsL); + // 2 1<<1 + trackFilter->AddCuts(esdTrackCutsITSsa); + // 4 1<<2 + trackFilter->AddCuts(itsStrong); + itsStrong->SetFilterMask(1); // AND with Standard track cuts + // 8 1<<3 + trackFilter->AddCuts(electronID); + electronID->SetFilterMask(4); // AND with Pixel Cuts + // 16 1<<4 + trackFilter->AddCuts(esdTrackCutsHG0); + // 32 1<<5 + trackFilter->AddCuts(esdTrackCutsHG1); + // 64 1<<6 + trackFilter->AddCuts(esdTrackCutsHG2); + // 128 1<<7 + trackFilter->AddCuts(esdTrackCutsTPCCOnly); // add QM TPC only track cuts + if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); + // 256 1<<8 + trackFilter->AddCuts(esdTrackCutsGCOnly); + // 512 1<<9 + AliESDtrackCuts* esdTrackCutsHG1_tmp = new AliESDtrackCuts(*esdTrackCutsHG1); // avoid double delete + trackFilter->AddCuts(esdTrackCutsHG1_tmp); // add once more for tpc only tracks + // 1024 1<<10 + trackFilter->AddCuts(esdTrackCutsH2); // add r_aa cuts + + + + esdfilter->SetGlobalConstrainedFilterMask(1<<8|1<<9); // these tracks are written out as global constrained tracks + esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<4)); // these normal global tracks will be marked as hybrid + esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement + // esdfilter->SetTPCConstrainedFilterMask(1<<11); // these tracks are written out as tpc constrained tracks + + esdfilter->SetTrackFilter(trackFilter); + return kTRUE; + +} + + +Bool_t AddTrackCutsLHC11h(AliAnalysisTaskESDfilter* esdfilter){ + + + Printf("%s%d: Creating Track Cuts LHC11h",(char*)__FILE__,__LINE__); + + // Cuts on primary tracks + AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + + // ITS stand-alone tracks + AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); + esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); + + // Pixel OR necessary for the electrons + AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); + itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + + + // PID for the electrons + AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); + electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); + + // standard cuts with very loose DCA + AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE); + esdTrackCutsH->SetMaxDCAToVertexXY(2.4); + esdTrackCutsH->SetMaxDCAToVertexZ(3.2); + esdTrackCutsH->SetDCAToVertex2D(kTRUE); + + // standard cuts with tight DCA cut + AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(); + + // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster + // tracks selected by this cut are exclusive to those selected by the previous cut + AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(); + esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); + esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst); + + // TPC only tracks: Optionally enable the writing of TPConly information + // constrained to SPD vertex in the filter below + AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb + //esdTrackCutsTPCOnly->SetMinNClustersTPC(70); + + // Extra cuts for hybrids + // first the global tracks we want to take + AliESDtrackCuts* esdTrackCutsHTG = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE); + esdTrackCutsHTG->SetName("Global Hybrid tracks, loose DCA"); + esdTrackCutsHTG->SetMaxDCAToVertexXY(2.4); + esdTrackCutsHTG->SetMaxDCAToVertexZ(3.2); + esdTrackCutsHTG->SetDCAToVertex2D(kTRUE); + esdTrackCutsHTG->SetMaxChi2TPCConstrainedGlobal(36); + esdTrackCutsHTG->SetMaxFractionSharedTPCClusters(0.4); + + + // Than the complementary tracks which will be stored as global + // constraint, complement is done in the ESDFilter task + AliESDtrackCuts* esdTrackCutsHTGC = new AliESDtrackCuts(*esdTrackCutsHTG); + esdTrackCutsHTGC->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement"); + esdTrackCutsHTGC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff); + esdTrackCutsHTGC->SetRequireITSRefit(kTRUE); + + // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default) + AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, 0); + + // Compose the filter + AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); + // 1, 1<<0 + trackFilter->AddCuts(esdTrackCutsL); + // 2, 1<<1 + trackFilter->AddCuts(esdTrackCutsITSsa); + // 4, 1<<2 + trackFilter->AddCuts(itsStrong); + itsStrong->SetFilterMask(1); // AND with Standard track cuts + // 8, 1<<3 + trackFilter->AddCuts(electronID); + electronID->SetFilterMask(4); // AND with Pixel Cuts + // 16, 1<<4 + trackFilter->AddCuts(esdTrackCutsH); + // 32, 1<<5 + trackFilter->AddCuts(esdTrackCutsH2); + // 64, 1<<6 + trackFilter->AddCuts(esdTrackCutsH3); + // 128 , 1 << 7 + trackFilter->AddCuts(esdTrackCutsTPCOnly); + if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); + // 256, 1 << 8 Global Hybrids + trackFilter->AddCuts(esdTrackCutsHTG); + esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid + // 512, 1<< 9 GlobalConstraint Hybrids + trackFilter->AddCuts(esdTrackCutsHTGC); + esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks + esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement + // 1024, 1<< 10 // tight DCA cuts + trackFilter->AddCuts(esdTrackCutsH2Cluster); + esdfilter->SetTrackFilter(trackFilter); + + return kTRUE; + +} + +Bool_t AddTrackCutsLHC10bcde(AliAnalysisTaskESDfilter* esdfilter){ + + + Printf("%s%d: Creating Track Cuts LHC10bcde",(char*)__FILE__,__LINE__); + + // Cuts on primary tracks + AliESDtrackCuts* esdTrackCutsL = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + + // ITS stand-alone tracks + AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("ITS stand-alone Track Cuts", "ESD Track Cuts"); + esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE); + + // Pixel OR necessary for the electrons + AliESDtrackCuts *itsStrong = new AliESDtrackCuts("ITSorSPD", "pixel requirement for ITS"); + itsStrong->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + + + // PID for the electrons + AliESDpidCuts *electronID = new AliESDpidCuts("Electrons", "Electron PID cuts"); + electronID->SetTPCnSigmaCut(AliPID::kElectron, 3.5); + + // standard cuts with very loose DCA + AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE); + esdTrackCutsH->SetMaxDCAToVertexXY(2.4); + esdTrackCutsH->SetMaxDCAToVertexZ(3.2); + esdTrackCutsH->SetDCAToVertex2D(kTRUE); + + // standard cuts with tight DCA cut + AliESDtrackCuts* esdTrackCutsH2 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); + + // standard cuts with tight DCA but with requiring the first SDD cluster instead of an SPD cluster + // tracks selected by this cut are exclusive to those selected by the previous cut + AliESDtrackCuts* esdTrackCutsH3 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); + esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone); + esdTrackCutsH3->SetClusterRequirementITS(AliESDtrackCuts::kSDD, AliESDtrackCuts::kFirst); + + // TPC only tracks: Optionally enable the writing of TPConly information + // constrained to SPD vertex in the filter below + AliESDtrackCuts* esdTrackCutsTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + // The following line is needed for 2010 PbPb reprocessing and pp, but not for 2011 PbPb + esdTrackCutsTPCOnly->SetMinNClustersTPC(70); + + // Extra cuts for hybrids + // first the global tracks we want to take + // take the HTGs from 10h + + // gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C"); + // AliESDtrackCuts* esdTrackCutsHG0 = CreateTrackCutsPWGJE(10001006); + + AliESDtrackCuts *jetCuts1006 = new AliESDtrackCuts("AliESDtrackCuts"); + + TFormula *f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x"); + jetCuts1006->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.); + jetCuts1006->SetMinNClustersTPC(70); + jetCuts1006->SetMaxChi2PerClusterTPC(4); + jetCuts1006->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1 + jetCuts1006->SetAcceptKinkDaughters(kFALSE); + jetCuts1006->SetRequireTPCRefit(kTRUE); + jetCuts1006->SetMaxFractionSharedTPCClusters(0.4); + // ITS + jetCuts1006->SetRequireITSRefit(kTRUE); + //accept secondaries + jetCuts1006->SetMaxDCAToVertexXY(2.4); + jetCuts1006->SetMaxDCAToVertexZ(3.2); + jetCuts1006->SetDCAToVertex2D(kTRUE); + //reject fakes + jetCuts1006->SetMaxChi2PerClusterITS(36); + jetCuts1006->SetMaxChi2TPCConstrainedGlobal(36); + + jetCuts1006->SetRequireSigmaToVertex(kFALSE); + + jetCuts1006->SetEtaRange(-0.9,0.9); + jetCuts1006->SetPtRange(0.15, 1E+15.); + + AliESDtrackCuts* esdTrackCutsHTG = jetCuts1006->Clone("JetCuts10001006"); + esdTrackCutsHTG->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + + // Than the complementary tracks which will be stored as global + // constraint, complement is done in the ESDFilter task + // HGC from 10h + + AliESDtrackCuts* esdTrackCutsHTGC = jetCuts1006->Clone("JetCuts10041006"); + esdTrackCutsHTGC->SetRequireITSRefit(kFALSE); + + // standard cuts with tight DCA cut, using cluster cut instead of crossed rows (a la 2010 default) + AliESDtrackCuts* esdTrackCutsH2Cluster = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE, 0); + + // Compose the filter + AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); + // 1, 1<<0 + trackFilter->AddCuts(esdTrackCutsL); + // 2, 1<<1 + trackFilter->AddCuts(esdTrackCutsITSsa); + // 4, 1<<2 + trackFilter->AddCuts(itsStrong); + itsStrong->SetFilterMask(1); // AND with Standard track cuts + // 8, 1<<3 + trackFilter->AddCuts(electronID); + electronID->SetFilterMask(4); // AND with Pixel Cuts + // 16, 1<<4 + trackFilter->AddCuts(esdTrackCutsH); + // 32, 1<<5 + trackFilter->AddCuts(esdTrackCutsH2); + // 64, 1<<6 + trackFilter->AddCuts(esdTrackCutsH3); + // 128 , 1 << 7 + trackFilter->AddCuts(esdTrackCutsTPCOnly); + if(enableTPCOnlyAODTracksLocalFlag)esdfilter->SetTPCOnlyFilterMask(128); + // 256, 1 << 8 Global Hybrids + trackFilter->AddCuts(esdTrackCutsHTG); + esdfilter->SetHybridFilterMaskGlobalConstrainedGlobal((1<<8)); // these normal global tracks will be marked as hybrid + // 512, 1<< 9 GlobalConstraint Hybrids + trackFilter->AddCuts(esdTrackCutsHTGC); + esdfilter->SetGlobalConstrainedFilterMask(1<<9); // these tracks are written out as global constrained tracks + esdfilter->SetWriteHybridGlobalConstrainedOnly(kTRUE); // write only the complement + // 1024, 1<< 10 // tight DCA cuts + trackFilter->AddCuts(esdTrackCutsH2Cluster); + esdfilter->SetTrackFilter(trackFilter); + + return kTRUE; + +} diff --git a/ANALYSIS/TenderSupplies/AliTRDTenderSupply.cxx b/ANALYSIS/TenderSupplies/AliTRDTenderSupply.cxx index 8b83a53edd8..dff80e8c74f 100644 --- a/ANALYSIS/TenderSupplies/AliTRDTenderSupply.cxx +++ b/ANALYSIS/TenderSupplies/AliTRDTenderSupply.cxx @@ -195,7 +195,7 @@ void AliTRDTenderSupply::ProcessEvent() fESD = fTender->GetEvent(); if (!fESD) return; - if(fNormalizationFactorArray) fNormalizationFactor = GetNormalizationFactor(fESD->GetRunNumber()); + if(fNormalizationFactorArray) fNormalizationFactor = GetNormalizationFactor(fESD->GetRunNumber()); Int_t ntracks=fESD->GetNumberOfTracks(); @@ -490,7 +490,7 @@ void AliTRDTenderSupply::ApplyRunByRunCorrection(AliESDtrack *const track) { TVectorD *corrfactor = dynamic_cast(fRunByRunCorrection->GetObject(fTender->GetRun())); if(!corrfactor){ - // No correction available - simply return + // No correction available - simply return AliDebug(2, "Couldn't derive gain correction factor from OADB"); return; } @@ -524,7 +524,7 @@ void AliTRDTenderSupply::SetNormalizationFactor(Double_t norm, Int_t runMin, Int //_____________________________________________________ Double_t AliTRDTenderSupply::GetNormalizationFactor(Int_t runnumber){ // - // Load the normalization factor + // Load the normalization factor // Double_t norm = 1.; if(fNormalizationFactorArray){ diff --git a/HLT/CALO/AliHLTCaloDigitMaker.cxx b/HLT/CALO/AliHLTCaloDigitMaker.cxx index eaa94b590d0..da5e8759b7d 100644 --- a/HLT/CALO/AliHLTCaloDigitMaker.cxx +++ b/HLT/CALO/AliHLTCaloDigitMaker.cxx @@ -1,335 +1,335 @@ -// $Id$ - -/************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * All rights reserved. * - * * - * Primary Authors: Oystein Djuvsland * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - /** - * @file AliHLTCaloDigitMaker.cxx - * @author Oystein Djuvsland - * @date - * @brief Digit maker for CALO HLT - */ - - -// see header file for class documentation -// or -// refer to README to build package -// or -// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - -#include "AliHLTCaloDigitMaker.h" -#include "AliHLTCaloConstantsHandler.h" -#include "AliHLTCaloMapper.h" -#include "AliHLTCaloChannelDataStruct.h" -#include "AliHLTCaloChannelDataHeaderStruct.h" -#include "AliHLTCaloDigitDataStruct.h" -#include "AliHLTCaloCoordinate.h" -#include "AliHLTCaloSharedMemoryInterfacev2.h" // added by PTH -//#include "AliPHOSEMCAGeometry.h" -#include "TH2F.h" -#include "AliHLTCaloConstants.h" -#include "AliHLTLogging.h" - -ClassImp(AliHLTCaloDigitMaker); - -//using namespace CaloHLTConst; - -AliHLTCaloDigitMaker::AliHLTCaloDigitMaker(TString det) : - AliHLTCaloConstantsHandler(det), - AliHLTLogging(), - fShmPtr(0), - fDigitStructPtr(0), - fDigitCount(0), - fMapperPtr(0), - fHighGainFactors(0), - fLowGainFactors(0), - fBadChannelMask(0), - fChannelBook(0), - fMaxEnergy(900), - fMinTime(0.0), - fMaxTime(1008.0) -{ - // See header file for documentation - - fShmPtr = new AliHLTCaloSharedMemoryInterfacev2(det); - - fHighGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()]; - fLowGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()]; - - fBadChannelMask = new Bool_t**[fCaloConstants->GetNXCOLUMNSMOD()]; - - fChannelBook= new AliHLTCaloDigitDataStruct**[fCaloConstants->GetNXCOLUMNSMOD()]; - - for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) - { - fHighGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()]; - fLowGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()]; - - fBadChannelMask[x] = new Bool_t*[fCaloConstants->GetNZROWSMOD()]; - - fChannelBook[x] = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNZROWSMOD()]; - - for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) - { - - fHighGainFactors[x][z] = 0.0153; - fLowGainFactors[x][z] = 0.245; - - fBadChannelMask[x][z] = new Bool_t[fCaloConstants->GetNGAINS()]; - fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false; - fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; - - fChannelBook[x][z] = 0; - - } - } -} - -AliHLTCaloDigitMaker::~AliHLTCaloDigitMaker() -{ - //See header file for documentation - delete [] fHighGainFactors; - delete [] fLowGainFactors; - delete [] fBadChannelMask; - delete [] fChannelBook; - delete fShmPtr; - -} - -Int_t -AliHLTCaloDigitMaker::MakeDigits(AliHLTCaloChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize) -{ - //See header file for documentation - - Reset(); - - UInt_t totSize = sizeof(AliHLTCaloDigitDataStruct); - -// Int_t xMod = -1; -// Int_t zMod = -1; - - - AliHLTCaloCoordinate coord; - - - AliHLTCaloChannelDataStruct* currentchannel = 0; - - fShmPtr->SetMemory(channelDataHeader); - currentchannel = fShmPtr->NextChannel(); - - while(currentchannel != 0) - { - if(availableSize < totSize) return -1; - - fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord); - - // fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord); - if(UseDigit(coord, currentchannel)) - { - AddDigit(currentchannel, coord); - // j++; - totSize += sizeof(AliHLTCaloDigitDataStruct); - } - currentchannel = fShmPtr->NextChannel(); // Get the next channel - } -// if(currentchannel) -// { -// fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord); -// if(UseDigit(coord1, currentchannel)) -// { -// AddDigit(currentchannel, coord1, locCoord); -// j++; -// totSize += sizeof(AliHLTCaloDigitDataStruct); -// } -// currentchannel = fShmPtr->NextChannel(); // Get the next channel -// } -// } - -// fDigitCount += j; - return fDigitCount; -} - -void -AliHLTCaloDigitMaker::SetGlobalHighGainFactor(Float_t factor) -{ - //See header file for documentation - for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) - { - for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) - { - fHighGainFactors[x][z] = factor; - } - } -} - - -void -AliHLTCaloDigitMaker::SetGlobalLowGainFactor(Float_t factor) -{ - //See header file for documentation - for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) - { - for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) - { - fLowGainFactors[x][z] = factor; - } - } -} - - -void -AliHLTCaloDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut) -{ - for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) - { - for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) - { - if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0) - { - fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = true; - } - else - { - fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false; - } - if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0) - { - fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; - } - else - { - fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; - } - } - } -} - -void -AliHLTCaloDigitMaker::Reset() -{ - fDigitCount = 0; - for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) - { - for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) - { - fChannelBook[x][z] = 0; - } - } - -} - - -void AliHLTCaloDigitMaker::AddDigit(AliHLTCaloChannelDataStruct* channelData, AliHLTCaloCoordinate &coord) -{ - - // Some book keeping of the pointers - AliHLTCaloDigitDataStruct *tmpDigit = fDigitStructPtr + 1; - - // Check if we already have a digit in this position, and correct the book keeping correspondently - if(fChannelBook[coord.fX][coord.fZ]) - { - tmpDigit = fDigitStructPtr; - fDigitStructPtr = fChannelBook[coord.fX][coord.fZ]; - fDigitCount--; - // printf("Going to overwrite digit: x = %d, z = %d, gain = %d, energy = %f\n", fDigitStructPtr->fX, fDigitStructPtr->fZ, fDigitStructPtr->fGain, fDigitStructPtr->fEnergy); - } - - fChannelBook[coord.fX][coord.fZ] = fDigitStructPtr; - - fDigitStructPtr->fX = coord.fX; - fDigitStructPtr->fZ = coord.fZ; - fDigitStructPtr->fGain = coord.fGain; - fDigitStructPtr->fOverflow = false; - fDigitStructPtr->fAssociatedCluster = -1; - - fDigitStructPtr->fID = fDigitStructPtr->fZ * fCaloConstants->GetNXCOLUMNSMOD() + fDigitStructPtr->fX; - - if(coord.fGain == fCaloConstants->GetHIGHGAIN() ) - { - fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[coord.fX][coord.fZ]; - fDigitStructPtr->fHgPresent = true; - if(channelData->fEnergy >= fMaxEnergy) - { - fDigitStructPtr->fOverflow = true; - } - - HLTDebug("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", - coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); - } - else - { - fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[coord.fX][coord.fZ]; - if(channelData->fEnergy >= fMaxEnergy) - { - fDigitStructPtr->fOverflow = true; - } - HLTDebug("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); - } - fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO - fDigitStructPtr->fCrazyness = channelData->fCrazyness; - fDigitStructPtr->fModule = coord.fModuleId; - fDigitStructPtr = tmpDigit; - // fDigitStructPtr++; - fDigitCount++; -} - -bool AliHLTCaloDigitMaker::UseDigit(AliHLTCaloCoordinate &channelCoordinates, AliHLTCaloChannelDataStruct *channel) -{ - - if(fBadChannelMask[channelCoordinates.fX][channelCoordinates.fZ][0] == true) return false; - if(channel->fTime < fMinTime || channel->fTime > fMaxTime) return false; - - AliHLTCaloDigitDataStruct *tmpDigit = fChannelBook[channelCoordinates.fX][channelCoordinates.fZ]; - //printf("UseDigit: Got digit, x: %d, z: %d, gain: %d, amp: %f\n", channelCoordinates.fX, channelCoordinates.fZ, channelCoordinates.fGain, channel->fEnergy); - if(tmpDigit) - { - if(channelCoordinates.fGain == fCaloConstants->GetLOWGAIN()) - { - //printf("UseDigit: Already have digit with, x: %d, z: %d, with high gain \n", channelCoordinates.fX, channelCoordinates.fZ); - if(tmpDigit->fOverflow) - { - // printf("But it was in overflow! Let's use this low gain!\n"); - return true; - } - return false; - } - else - { - //printf("UseDigit: Already have digit with, x: %d, z: %d, with low gain: %d\n", channelCoordinates.fX, channelCoordinates.fZ); - if(channel->fEnergy > fMaxEnergy ) - { - tmpDigit->fHgPresent = true; - return false; - } - return true; - } - } - return true; -} - -void AliHLTCaloDigitMaker::SetBadChannel(Int_t x, Int_t z, Bool_t bad) -{ - // See header file for class documentation - fBadChannelMask[x][z][0] = bad; - fBadChannelMask[x][z][1] = bad; -} - -void AliHLTCaloDigitMaker::SetGain(Int_t x, Int_t z, Float_t ratio, Float_t gain) -{ - // See header file for class documentation - HLTDebug("Applying gain: %f for channel x: %d, z: %d", gain, x, z); - fHighGainFactors[x][z] = gain; - fLowGainFactors[x][z] = gain * ratio; - -} +// $Id$ + +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * All rights reserved. * + * * + * Primary Authors: Oystein Djuvsland * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + /** + * @file AliHLTCaloDigitMaker.cxx + * @author Oystein Djuvsland + * @date + * @brief Digit maker for CALO HLT + */ + + +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#include "AliHLTCaloDigitMaker.h" +#include "AliHLTCaloConstantsHandler.h" +#include "AliHLTCaloMapper.h" +#include "AliHLTCaloChannelDataStruct.h" +#include "AliHLTCaloChannelDataHeaderStruct.h" +#include "AliHLTCaloDigitDataStruct.h" +#include "AliHLTCaloCoordinate.h" +#include "AliHLTCaloSharedMemoryInterfacev2.h" // added by PTH +//#include "AliPHOSEMCAGeometry.h" +#include "TH2F.h" +#include "AliHLTCaloConstants.h" +#include "AliHLTLogging.h" + +ClassImp(AliHLTCaloDigitMaker); + +//using namespace CaloHLTConst; + +AliHLTCaloDigitMaker::AliHLTCaloDigitMaker(TString det) : + AliHLTCaloConstantsHandler(det), + AliHLTLogging(), + fShmPtr(0), + fDigitStructPtr(0), + fDigitCount(0), + fMapperPtr(0), + fHighGainFactors(0), + fLowGainFactors(0), + fBadChannelMask(0), + fChannelBook(0), + fMaxEnergy(900), + fMinTime(0.0), + fMaxTime(1008.0) +{ + // See header file for documentation + + fShmPtr = new AliHLTCaloSharedMemoryInterfacev2(det); + + fHighGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()]; + fLowGainFactors = new Float_t*[fCaloConstants->GetNXCOLUMNSMOD()]; + + fBadChannelMask = new Bool_t**[fCaloConstants->GetNXCOLUMNSMOD()]; + + fChannelBook= new AliHLTCaloDigitDataStruct**[fCaloConstants->GetNXCOLUMNSMOD()]; + + for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) + { + fHighGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()]; + fLowGainFactors[x] = new Float_t[fCaloConstants->GetNZROWSMOD()]; + + fBadChannelMask[x] = new Bool_t*[fCaloConstants->GetNZROWSMOD()]; + + fChannelBook[x] = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNZROWSMOD()]; + + for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) + { + + fHighGainFactors[x][z] = 0.0153; + fLowGainFactors[x][z] = 0.245; + + fBadChannelMask[x][z] = new Bool_t[fCaloConstants->GetNGAINS()]; + fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false; + fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; + + fChannelBook[x][z] = 0; + + } + } +} + +AliHLTCaloDigitMaker::~AliHLTCaloDigitMaker() +{ + //See header file for documentation + delete [] fHighGainFactors; + delete [] fLowGainFactors; + delete [] fBadChannelMask; + delete [] fChannelBook; + delete fShmPtr; + +} + +Int_t +AliHLTCaloDigitMaker::MakeDigits(AliHLTCaloChannelDataHeaderStruct* channelDataHeader, AliHLTUInt32_t availableSize) +{ + //See header file for documentation + + Reset(); + + UInt_t totSize = sizeof(AliHLTCaloDigitDataStruct); + +// Int_t xMod = -1; +// Int_t zMod = -1; + + + AliHLTCaloCoordinate coord; + + + AliHLTCaloChannelDataStruct* currentchannel = 0; + + fShmPtr->SetMemory(channelDataHeader); + currentchannel = fShmPtr->NextChannel(); + + while(currentchannel != 0) + { + if(availableSize < totSize) return -1; + + fMapperPtr->ChannelId2Coordinate(currentchannel->fChannelID, coord); + + // fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord); + if(UseDigit(coord, currentchannel)) + { + AddDigit(currentchannel, coord); + // j++; + totSize += sizeof(AliHLTCaloDigitDataStruct); + } + currentchannel = fShmPtr->NextChannel(); // Get the next channel + } +// if(currentchannel) +// { +// fMapperPtr->GetLocalCoord(currentchannel->fChannelID, locCoord); +// if(UseDigit(coord1, currentchannel)) +// { +// AddDigit(currentchannel, coord1, locCoord); +// j++; +// totSize += sizeof(AliHLTCaloDigitDataStruct); +// } +// currentchannel = fShmPtr->NextChannel(); // Get the next channel +// } +// } + +// fDigitCount += j; + return fDigitCount; +} + +void +AliHLTCaloDigitMaker::SetGlobalHighGainFactor(Float_t factor) +{ + //See header file for documentation + for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) + { + for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) + { + fHighGainFactors[x][z] = factor; + } + } +} + + +void +AliHLTCaloDigitMaker::SetGlobalLowGainFactor(Float_t factor) +{ + //See header file for documentation + for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) + { + for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) + { + fLowGainFactors[x][z] = factor; + } + } +} + + +void +AliHLTCaloDigitMaker::SetBadChannelMask(TH2F* badChannelHGHist, TH2F* badChannelLGHist, Float_t qCut) +{ + for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) + { + for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) + { + if(badChannelHGHist->GetBinContent(x, z) < qCut && badChannelHGHist->GetBinContent(x, z) > 0) + { + fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = true; + } + else + { + fBadChannelMask[x][z][fCaloConstants->GetHIGHGAIN()] = false; + } + if(badChannelLGHist->GetBinContent(x, z) < qCut && badChannelLGHist->GetBinContent(x, z) > 0) + { + fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; + } + else + { + fBadChannelMask[x][z][fCaloConstants->GetLOWGAIN()] = false; + } + } + } +} + +void +AliHLTCaloDigitMaker::Reset() +{ + fDigitCount = 0; + for(int x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++) + { + for(int z = 0; z < fCaloConstants->GetNZROWSMOD(); z++) + { + fChannelBook[x][z] = 0; + } + } + +} + + +void AliHLTCaloDigitMaker::AddDigit(AliHLTCaloChannelDataStruct* channelData, AliHLTCaloCoordinate &coord) +{ + + // Some book keeping of the pointers + AliHLTCaloDigitDataStruct *tmpDigit = fDigitStructPtr + 1; + + // Check if we already have a digit in this position, and correct the book keeping correspondently + if(fChannelBook[coord.fX][coord.fZ]) + { + tmpDigit = fDigitStructPtr; + fDigitStructPtr = fChannelBook[coord.fX][coord.fZ]; + fDigitCount--; + // printf("Going to overwrite digit: x = %d, z = %d, gain = %d, energy = %f\n", fDigitStructPtr->fX, fDigitStructPtr->fZ, fDigitStructPtr->fGain, fDigitStructPtr->fEnergy); + } + + fChannelBook[coord.fX][coord.fZ] = fDigitStructPtr; + + fDigitStructPtr->fX = coord.fX; + fDigitStructPtr->fZ = coord.fZ; + fDigitStructPtr->fGain = coord.fGain; + fDigitStructPtr->fOverflow = false; + fDigitStructPtr->fAssociatedCluster = -1; + + fDigitStructPtr->fID = fDigitStructPtr->fZ * fCaloConstants->GetNXCOLUMNSMOD() + fDigitStructPtr->fX; + + if(coord.fGain == fCaloConstants->GetHIGHGAIN() ) + { + fDigitStructPtr->fEnergy = channelData->fEnergy*fHighGainFactors[coord.fX][coord.fZ]; + fDigitStructPtr->fHgPresent = true; + if(channelData->fEnergy >= fMaxEnergy) + { + fDigitStructPtr->fOverflow = true; + } + + HLTDebug("HG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f \n", + coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); + } + else + { + fDigitStructPtr->fEnergy = channelData->fEnergy*fLowGainFactors[coord.fX][coord.fZ]; + if(channelData->fEnergy >= fMaxEnergy) + { + fDigitStructPtr->fOverflow = true; + } + HLTDebug("LG channel (x = %d, z = %d) with amplitude: %f --> Digit with energy: %f\n", coord.fX, coord.fZ, channelData->fEnergy, fDigitStructPtr->fEnergy); + } + fDigitStructPtr->fTime = channelData->fTime * 0.0000001; //TODO + fDigitStructPtr->fCrazyness = channelData->fCrazyness; + fDigitStructPtr->fModule = coord.fModuleId; + fDigitStructPtr = tmpDigit; + // fDigitStructPtr++; + fDigitCount++; +} + +bool AliHLTCaloDigitMaker::UseDigit(AliHLTCaloCoordinate &channelCoordinates, AliHLTCaloChannelDataStruct *channel) +{ + + if(fBadChannelMask[channelCoordinates.fX][channelCoordinates.fZ][0] == true) return false; + if(channel->fTime < fMinTime || channel->fTime > fMaxTime) return false; + + AliHLTCaloDigitDataStruct *tmpDigit = fChannelBook[channelCoordinates.fX][channelCoordinates.fZ]; + //printf("UseDigit: Got digit, x: %d, z: %d, gain: %d, amp: %f\n", channelCoordinates.fX, channelCoordinates.fZ, channelCoordinates.fGain, channel->fEnergy); + if(tmpDigit) + { + if(channelCoordinates.fGain == fCaloConstants->GetLOWGAIN()) + { + //printf("UseDigit: Already have digit with, x: %d, z: %d, with high gain \n", channelCoordinates.fX, channelCoordinates.fZ); + if(tmpDigit->fOverflow) + { + // printf("But it was in overflow! Let's use this low gain!\n"); + return true; + } + return false; + } + else + { + //printf("UseDigit: Already have digit with, x: %d, z: %d, with low gain: %d\n", channelCoordinates.fX, channelCoordinates.fZ); + if(channel->fEnergy > fMaxEnergy ) + { + tmpDigit->fHgPresent = true; + return false; + } + return true; + } + } + return true; +} + +void AliHLTCaloDigitMaker::SetBadChannel(Int_t x, Int_t z, Bool_t bad) +{ + // See header file for class documentation + fBadChannelMask[x][z][0] = bad; + fBadChannelMask[x][z][1] = bad; +} + +void AliHLTCaloDigitMaker::SetGain(Int_t x, Int_t z, Float_t ratio, Float_t gain) +{ + // See header file for class documentation + HLTDebug("Applying gain: %f for channel x: %d, z: %d", gain, x, z); + fHighGainFactors[x][z] = gain; + fLowGainFactors[x][z] = gain * ratio; + +} diff --git a/ITS/UPGRADE/AliITSUClusterizer.h b/ITS/UPGRADE/AliITSUClusterizer.h index 42ec7d3d971..249b7276dbc 100644 --- a/ITS/UPGRADE/AliITSUClusterizer.h +++ b/ITS/UPGRADE/AliITSUClusterizer.h @@ -1,233 +1,233 @@ -#ifndef ALIITSUCLUSTERIZER_H -#define ALIITSUCLUSTERIZER_H - -#include - -//#define _ClusterTopology_ // uncomment this to produce the tree with cluster topology - -class TTree; -class TObjAray; -class AliITSUSegmentationPix; -class AliITSdigit; -class AliCluster; -class AliITSUClusterPix; -class AliITSURecoParam; -// -#ifdef _ClusterTopology_ -#include -class TFile; -#endif //_ClusterTopology_ - - -class AliITSUClusterizer : public TObject -{ - // - public: - enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3}; - // - AliITSUClusterizer(Int_t nrowInit=0); - virtual ~AliITSUClusterizer(); - void SetRawData(Bool_t v=kTRUE) {fRawData = v;} - void Clusterize(); - void SetSegmentation(const AliITSUSegmentationPix *segm); - void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;} - void SetLayerID(Int_t id) {fLayerID = id;} - void SetVolID(Int_t id) {fVolID = id;} - void SetNRow(Int_t nrow); - void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;} - void PrepareLorentzAngleCorrection(Double_t bz); - // - // interface methods - void MakeRecPointBranch(TTree */*treeR*/) {}; - void SetRecPointTreeAddress(TTree */*treeR*/) {}; - void DigitsToRecPoints(const TObjArray */*digList*/) {}; - - void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;} - void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;} - // - // labeling methods - void AddLabel(int label); - void CheckLabels(); - // - protected: // transient data types - struct AliITSUClusterizerClusterDigit { - AliITSUClusterizerClusterDigit *fNext; - AliITSdigit *fDigit; - }; - - struct AliITSUClusterizerClusterCand; - struct AliITSUClusterizerClusterPart { - AliITSUClusterizerClusterPart *fNextInRow; - AliITSUClusterizerClusterPart *fPrevInCluster; - AliITSUClusterizerClusterPart *fNextInCluster; - AliITSUClusterizerClusterCand *fParent; - Int_t fUBegin; - Int_t fUEnd; - }; - - struct AliITSUClusterizerClusterCand { - AliITSUClusterizerClusterCand *fNext; // only used for memory management - AliITSUClusterizerClusterPart *fFirstPart; - AliITSUClusterizerClusterDigit *fFirstDigit; - AliITSUClusterizerClusterDigit *fLastDigit ; - }; - - protected: - // - // allocation and deallocation - AliITSUClusterizerClusterDigit* AllocDigitFreelist(); - AliITSUClusterizerClusterCand* AllocCand(); - void DeallocCand(AliITSUClusterizerClusterCand *cand); - AliITSUClusterizerClusterPart* AllocPart(); - void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); } - void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last); - AliITSUClusterizerClusterDigit* AllocDigit(); - void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);} - void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last); - - // input "iterator" - AliITSUClusterizerClusterDigit* NextDigit(); - // output "iterator" - AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());} - - // modifiers - void SetAllowDiagonalClusterization(); - - void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit); - void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part); - void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part); - void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b); - void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand); - void CloseCand(AliITSUClusterizerClusterCand *cand); - void ClosePart(AliITSUClusterizerClusterPart *part); - - void CloseRemainingParts(AliITSUClusterizerClusterPart *part); - // - protected: - // - Int_t fVolID; // Volume id (module index) - Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only - const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc. - const AliITSURecoParam* fRecoParam; // reco params - // - // Digit Input - const TClonesArray *fInputDigits; // supplied digits - Int_t fInputDigitsReadIndex; // digits counter - Int_t fLayerID; // current layer id - // - Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster - Int_t fNLabels; // number of collected labels - Bool_t fRawData; // is raw data processed? - // - Double_t fLorAngCorrection; // Lorentz Angle correction for current layer - // Cluster Output - TClonesArray *fOutputClusters; // external container to store clusters - // - // temporary variables - AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits - AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters - AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters - AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool - AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool - AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool - AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool - // -#ifdef _ClusterTopology_ - TTree* fTreeTopology; // output tree for the cluster topology in the special mode - TFile* fFileTopology; // output file for the cluster topology in the special mode - TBits fTopology; // container for the clusters topology pattern - UShort_t fMinCol; // min col number - UShort_t fMinRow; // min row number - void InitTopologyTree(); - void SaveTopologyTree(); - void FillClusterTopology(AliITSUClusterizerClusterCand *cand); -#endif //_ClusterTopology_ - private: - AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented - AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented - // - ClassDef(AliITSUClusterizer,0) -}; - - -//_______________________________________________________________________________ -inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand) -{ - // free candidate - cand->fNext=fCandFreelist; - fCandFreelist=cand; -} - -//_______________________________________________________________________________ -inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last) -{ - // free cluster part - last->fNextInRow=fPartFreelist; - fPartFreelist=first; -} - -//_______________________________________________________________________________ -inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit() -{ - // allocate digits - if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist(); - AliITSUClusterizerClusterDigit *digit = fDigitFreelist; - fDigitFreelist = fDigitFreelist->fNext; - return digit; -} - -//_______________________________________________________________________________ -inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart() -{ - // allocate cluster part - AliITSUClusterizerClusterPart *part=fPartFreelist; - fPartFreelist=fPartFreelist->fNextInRow; - return part; -} - -//_______________________________________________________________________________ -inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand() -{ - // allocate cluster - AliITSUClusterizerClusterCand *cand=fCandFreelist; - fCandFreelist=fCandFreelist->fNext; - return cand; -} - -//_______________________________________________________________________________ -inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last) -{ - // free digit - last->fNext = fDigitFreelist; - fDigitFreelist = first; -} - -//_______________________________________________________________________________ -inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit) -{ - // attach digit - digit->fNext = cand->fFirstDigit; - cand->fFirstDigit = digit; -} - -//_______________________________________________________________________________ -inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part) -{ - // remove cluster part - if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster; - else cand->fFirstPart=part->fNextInCluster; - if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster; -} - -//______________________________________________________________________________ -inline void AliITSUClusterizer::AddLabel(int label) -{ - // add new label - if (fNLabels==kMaxLabels) return; - for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return; - fCurrLabels[fNLabels++] = label; -} - - -#endif - +#ifndef ALIITSUCLUSTERIZER_H +#define ALIITSUCLUSTERIZER_H + +#include + +//#define _ClusterTopology_ // uncomment this to produce the tree with cluster topology + +class TTree; +class TObjAray; +class AliITSUSegmentationPix; +class AliITSdigit; +class AliCluster; +class AliITSUClusterPix; +class AliITSURecoParam; +// +#ifdef _ClusterTopology_ +#include +class TFile; +#endif //_ClusterTopology_ + + +class AliITSUClusterizer : public TObject +{ + // + public: + enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3}; + // + AliITSUClusterizer(Int_t nrowInit=0); + virtual ~AliITSUClusterizer(); + void SetRawData(Bool_t v=kTRUE) {fRawData = v;} + void Clusterize(); + void SetSegmentation(const AliITSUSegmentationPix *segm); + void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;} + void SetLayerID(Int_t id) {fLayerID = id;} + void SetVolID(Int_t id) {fVolID = id;} + void SetNRow(Int_t nrow); + void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;} + void PrepareLorentzAngleCorrection(Double_t bz); + // + // interface methods + void MakeRecPointBranch(TTree */*treeR*/) {}; + void SetRecPointTreeAddress(TTree */*treeR*/) {}; + void DigitsToRecPoints(const TObjArray */*digList*/) {}; + + void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;} + void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;} + // + // labeling methods + void AddLabel(int label); + void CheckLabels(); + // + protected: // transient data types + struct AliITSUClusterizerClusterDigit { + AliITSUClusterizerClusterDigit *fNext; + AliITSdigit *fDigit; + }; + + struct AliITSUClusterizerClusterCand; + struct AliITSUClusterizerClusterPart { + AliITSUClusterizerClusterPart *fNextInRow; + AliITSUClusterizerClusterPart *fPrevInCluster; + AliITSUClusterizerClusterPart *fNextInCluster; + AliITSUClusterizerClusterCand *fParent; + Int_t fUBegin; + Int_t fUEnd; + }; + + struct AliITSUClusterizerClusterCand { + AliITSUClusterizerClusterCand *fNext; // only used for memory management + AliITSUClusterizerClusterPart *fFirstPart; + AliITSUClusterizerClusterDigit *fFirstDigit; + AliITSUClusterizerClusterDigit *fLastDigit ; + }; + + protected: + // + // allocation and deallocation + AliITSUClusterizerClusterDigit* AllocDigitFreelist(); + AliITSUClusterizerClusterCand* AllocCand(); + void DeallocCand(AliITSUClusterizerClusterCand *cand); + AliITSUClusterizerClusterPart* AllocPart(); + void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); } + void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last); + AliITSUClusterizerClusterDigit* AllocDigit(); + void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);} + void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last); + + // input "iterator" + AliITSUClusterizerClusterDigit* NextDigit(); + // output "iterator" + AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());} + + // modifiers + void SetAllowDiagonalClusterization(); + + void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit); + void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part); + void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part); + void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b); + void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand); + void CloseCand(AliITSUClusterizerClusterCand *cand); + void ClosePart(AliITSUClusterizerClusterPart *part); + + void CloseRemainingParts(AliITSUClusterizerClusterPart *part); + // + protected: + // + Int_t fVolID; // Volume id (module index) + Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only + const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc. + const AliITSURecoParam* fRecoParam; // reco params + // + // Digit Input + const TClonesArray *fInputDigits; // supplied digits + Int_t fInputDigitsReadIndex; // digits counter + Int_t fLayerID; // current layer id + // + Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster + Int_t fNLabels; // number of collected labels + Bool_t fRawData; // is raw data processed? + // + Double_t fLorAngCorrection; // Lorentz Angle correction for current layer + // Cluster Output + TClonesArray *fOutputClusters; // external container to store clusters + // + // temporary variables + AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits + AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters + AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters + AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool + AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool + AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool + AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool + // +#ifdef _ClusterTopology_ + TTree* fTreeTopology; // output tree for the cluster topology in the special mode + TFile* fFileTopology; // output file for the cluster topology in the special mode + TBits fTopology; // container for the clusters topology pattern + UShort_t fMinCol; // min col number + UShort_t fMinRow; // min row number + void InitTopologyTree(); + void SaveTopologyTree(); + void FillClusterTopology(AliITSUClusterizerClusterCand *cand); +#endif //_ClusterTopology_ + private: + AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented + AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented + // + ClassDef(AliITSUClusterizer,0) +}; + + +//_______________________________________________________________________________ +inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand) +{ + // free candidate + cand->fNext=fCandFreelist; + fCandFreelist=cand; +} + +//_______________________________________________________________________________ +inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last) +{ + // free cluster part + last->fNextInRow=fPartFreelist; + fPartFreelist=first; +} + +//_______________________________________________________________________________ +inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit() +{ + // allocate digits + if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist(); + AliITSUClusterizerClusterDigit *digit = fDigitFreelist; + fDigitFreelist = fDigitFreelist->fNext; + return digit; +} + +//_______________________________________________________________________________ +inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart() +{ + // allocate cluster part + AliITSUClusterizerClusterPart *part=fPartFreelist; + fPartFreelist=fPartFreelist->fNextInRow; + return part; +} + +//_______________________________________________________________________________ +inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand() +{ + // allocate cluster + AliITSUClusterizerClusterCand *cand=fCandFreelist; + fCandFreelist=fCandFreelist->fNext; + return cand; +} + +//_______________________________________________________________________________ +inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last) +{ + // free digit + last->fNext = fDigitFreelist; + fDigitFreelist = first; +} + +//_______________________________________________________________________________ +inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit) +{ + // attach digit + digit->fNext = cand->fFirstDigit; + cand->fFirstDigit = digit; +} + +//_______________________________________________________________________________ +inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part) +{ + // remove cluster part + if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster; + else cand->fFirstPart=part->fNextInCluster; + if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster; +} + +//______________________________________________________________________________ +inline void AliITSUClusterizer::AddLabel(int label) +{ + // add new label + if (fNLabels==kMaxLabels) return; + for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return; + fCurrLabels[fNLabels++] = label; +} + + +#endif + diff --git a/OADB/AliOADBCentrality.h b/OADB/AliOADBCentrality.h index 21965d5b65c..210ae96d9ea 100644 --- a/OADB/AliOADBCentrality.h +++ b/OADB/AliOADBCentrality.h @@ -1,173 +1,173 @@ -#ifndef AliOADBCentrality_H -#define AliOADBCentrality_H -/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -//------------------------------------------------------------------------- -// OADB class for run dependent centrality scaling factors and -// data for centrality determination -// Author: Andreas Morsch, CERN -//------------------------------------------------------------------------- - -#include -#include -#include -#include - - -class AliOADBCentrality : public TNamed { - - public : - AliOADBCentrality(); - AliOADBCentrality(char* name); - virtual ~AliOADBCentrality(); - Float_t V0MScaleFactor() const {return fV0MScaleFactor;} - Float_t SPDScaleFactor() const {return fSPDScaleFactor;} - Float_t TPCScaleFactor() const {return fTPCScaleFactor;} - Float_t V0MScaleFactorMC() const {return fV0MScaleFactorMC;} - - Float_t V0MSPDOutlierPar0() const {return fV0MSPDOutlierPar0 ;} - Float_t V0MSPDOutlierPar1() const {return fV0MSPDOutlierPar1 ;} - Float_t V0MTPCOutlierPar0() const {return fV0MTPCOutlierPar0 ;} - Float_t V0MTPCOutlierPar1() const {return fV0MTPCOutlierPar1 ;} - - Float_t V0MSPDSigmaOutlierPar0() const {return fV0MSPDSigmaOutlierPar0 ;} - Float_t V0MSPDSigmaOutlierPar1() const {return fV0MSPDSigmaOutlierPar1 ;} - Float_t V0MSPDSigmaOutlierPar2() const {return fV0MSPDSigmaOutlierPar2 ;} - Float_t V0MTPCSigmaOutlierPar0() const {return fV0MTPCSigmaOutlierPar0 ;} - Float_t V0MTPCSigmaOutlierPar1() const {return fV0MTPCSigmaOutlierPar1 ;} - Float_t V0MTPCSigmaOutlierPar2() const {return fV0MTPCSigmaOutlierPar2 ;} - - Float_t V0MZDCOutlierPar0() const {return fV0MZDCOutlierPar0 ;} - Float_t V0MZDCOutlierPar1() const {return fV0MZDCOutlierPar1 ;} - Float_t V0MZDCEcalOutlierPar0() const {return fV0MZDCEcalOutlierPar0 ;} - Float_t V0MZDCEcalOutlierPar1() const {return fV0MZDCEcalOutlierPar1 ;} - - Float_t ZVCut() const {return fZVCut;} - Float_t OutliersCut() const {return fOutliersCut;} - Bool_t UseScaling() const {return fUseScaling;} - Bool_t UseCleaning() const {return fUseCleaning;} - - TH1F* V0hist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0M_percentile")));} - TH1F* V0Ahist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0A_percentile")));} - TH1F* V0A123hist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0A123_percentile")));} - TH1F* V0Chist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0C_percentile")));} - TH1F* V0Eqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEq_percentile")));} - TH1F* V0AEqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEq_percentile")));} - TH1F* V0CEqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEq_percentile")));} - TH1F* TPChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRK_percentile")));} - TH1F* CNDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCND_percentile")));} - TH1F* SPDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1_percentile")));} - TH1F* FMDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMD_percentile")));} - TH1F* ZNAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNA_percentile")));} - TH1F* ZNChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNC_percentile")));} - TH1F* ZPAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPA_percentile")));} - TH1F* ZPChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPC_percentile")));} - TH2F* ZEMvsZDChist() const {return ((TH2F*) (Hists2D()->FindObject("fHOutMultZEMvsZDC")));} - - TH1F* NPAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultNPA_percentile")));} - TH1F* NPAhistDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultNPADPM_percentile")));} - - TH1F* V0histtrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Mtrue_percentile")));} - TH1F* V0Ahisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Atrue_percentile")));} - TH1F* V0Chisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Ctrue_percentile")));} - TH1F* V0Eqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEqtrue_percentile")));} - TH1F* V0AEqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEqtrue_percentile")));} - TH1F* V0CEqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEqtrue_percentile")));} - TH1F* TPChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRKtrue_percentile")));} - TH1F* CNDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCNDtrue_percentile")));} - TH1F* SPDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1true_percentile")));} - TH1F* FMDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMDtrue_percentile")));} - TH1F* ZNAhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNAtrue_percentile")));} - TH1F* ZNChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNCtrue_percentile")));} - TH1F* ZPAhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPAtrue_percentile")));} - TH1F* ZPChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPCtrue_percentile")));} - - TH1F* V0histtrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MtrueDPM_percentile")));} - TH1F* V0AhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AtrueDPM_percentile")));} - TH1F* V0ChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CtrueDPM_percentile")));} - TH1F* V0EqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEqtrueDPM_percentile")));} - TH1F* V0AEqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEqtrueDPM_percentile")));} - TH1F* V0CEqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEqtrueDPM_percentile")));} - TH1F* TPChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRKtrueDPM_percentile")));} - TH1F* CNDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCNDtrueDPM_percentile")));} - TH1F* SPDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1trueDPM_percentile")));} - TH1F* FMDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMDtrueDPM_percentile")));} - TH1F* ZNAhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNAtrueDPM_percentile")));} - TH1F* ZNChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNCtrueDPM_percentile")));} - TH1F* ZPAhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPAtrueDPM_percentile")));} - TH1F* ZPChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPCtrueDPM_percentile")));} - TList* Hists1D() const {return f1DHistos;} - TList* Hists2D() const {return f2DHistos;} - - void SetScaleFactors(Float_t v0m, Float_t spd, Float_t tpc, Float_t v0mMC) - {fV0MScaleFactor = v0m; fSPDScaleFactor = spd; fTPCScaleFactor = tpc; fV0MScaleFactorMC = v0mMC;} - - void SetOutlierV0MSPDFactors(Float_t a1, Float_t a2, Float_t a3, Float_t a4, Float_t a5) - {fV0MSPDOutlierPar0=a1;fV0MSPDOutlierPar1=a2;fV0MSPDSigmaOutlierPar0=a3;fV0MSPDSigmaOutlierPar1=a4;fV0MSPDSigmaOutlierPar2=a5;} - - void SetOutlierV0MTPCFactors(Float_t a1, Float_t a2, Float_t a3, Float_t a4, Float_t a5) - {fV0MTPCOutlierPar0=a1;fV0MTPCOutlierPar1=a2;fV0MTPCSigmaOutlierPar0=a3;fV0MTPCSigmaOutlierPar1=a4;fV0MTPCSigmaOutlierPar2=a5;} - - void SetOutlierV0MZDCFactors(Float_t a1, Float_t a2) - {fV0MZDCOutlierPar0=a1;fV0MZDCOutlierPar1=a2;} - - void SetOutlierV0MZDCEcalFactors(Float_t a1, Float_t a2) - {fV0MZDCEcalOutlierPar0=a1;fV0MZDCEcalOutlierPar1=a2;} - - void SetHistReferences(TList* l1, TList* l2) - {f1DHistos = l1; f2DHistos = l2;} - - void SetZVCut(Float_t z) - {fZVCut=z;} - - void SetOutliersCut(Float_t o) - {fOutliersCut=o;} - - void SetUseScaling(Bool_t x) - {fUseScaling=x;} - - void SetUseCleaning(Bool_t x) - {fUseCleaning=x;} - - - private: - AliOADBCentrality(const AliOADBCentrality& cont); - AliOADBCentrality& operator=(const AliOADBCentrality& cont); - - private: - Float_t fV0MScaleFactor; // V0 scale factor - Float_t fSPDScaleFactor; // SPD scale factor - Float_t fTPCScaleFactor; // TPC scale factor - Float_t fV0MScaleFactorMC; // V0 scale factor for MC - - Float_t fV0MSPDOutlierPar0; // V0-SPD outlier parameterisation Par0 - Float_t fV0MSPDOutlierPar1; // Par1 - Float_t fV0MTPCOutlierPar0; // Par2 - Float_t fV0MTPCOutlierPar1; // Par3 - - Float_t fV0MSPDSigmaOutlierPar0; // V0-SPD Sigma outlier parameterisation Par0 - Float_t fV0MSPDSigmaOutlierPar1; // Par1 - Float_t fV0MSPDSigmaOutlierPar2; // Par2 - Float_t fV0MTPCSigmaOutlierPar0; // Par3 - Float_t fV0MTPCSigmaOutlierPar1; // Par4 - Float_t fV0MTPCSigmaOutlierPar2; // Par5 - - Float_t fV0MZDCOutlierPar0; // V0-ZDC outlier parameterisation Par0 - Float_t fV0MZDCOutlierPar1; // Par1 - Float_t fV0MZDCEcalOutlierPar0; // Par2 - Float_t fV0MZDCEcalOutlierPar1; // Par3 - - Float_t fZVCut; // zV-cut - Float_t fOutliersCut; // outlier cuts - Bool_t fUseScaling; // Flag for scaling - Bool_t fUseCleaning; // Flag for cleaning - - TList* f1DHistos; // Reference to list of 1D Centrality histos - TList* f2DHistos; // Reference to list of 2D Centrality histos - ClassDef(AliOADBCentrality, 3); -}; - -#endif +#ifndef AliOADBCentrality_H +#define AliOADBCentrality_H +/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//------------------------------------------------------------------------- +// OADB class for run dependent centrality scaling factors and +// data for centrality determination +// Author: Andreas Morsch, CERN +//------------------------------------------------------------------------- + +#include +#include +#include +#include + + +class AliOADBCentrality : public TNamed { + + public : + AliOADBCentrality(); + AliOADBCentrality(char* name); + virtual ~AliOADBCentrality(); + Float_t V0MScaleFactor() const {return fV0MScaleFactor;} + Float_t SPDScaleFactor() const {return fSPDScaleFactor;} + Float_t TPCScaleFactor() const {return fTPCScaleFactor;} + Float_t V0MScaleFactorMC() const {return fV0MScaleFactorMC;} + + Float_t V0MSPDOutlierPar0() const {return fV0MSPDOutlierPar0 ;} + Float_t V0MSPDOutlierPar1() const {return fV0MSPDOutlierPar1 ;} + Float_t V0MTPCOutlierPar0() const {return fV0MTPCOutlierPar0 ;} + Float_t V0MTPCOutlierPar1() const {return fV0MTPCOutlierPar1 ;} + + Float_t V0MSPDSigmaOutlierPar0() const {return fV0MSPDSigmaOutlierPar0 ;} + Float_t V0MSPDSigmaOutlierPar1() const {return fV0MSPDSigmaOutlierPar1 ;} + Float_t V0MSPDSigmaOutlierPar2() const {return fV0MSPDSigmaOutlierPar2 ;} + Float_t V0MTPCSigmaOutlierPar0() const {return fV0MTPCSigmaOutlierPar0 ;} + Float_t V0MTPCSigmaOutlierPar1() const {return fV0MTPCSigmaOutlierPar1 ;} + Float_t V0MTPCSigmaOutlierPar2() const {return fV0MTPCSigmaOutlierPar2 ;} + + Float_t V0MZDCOutlierPar0() const {return fV0MZDCOutlierPar0 ;} + Float_t V0MZDCOutlierPar1() const {return fV0MZDCOutlierPar1 ;} + Float_t V0MZDCEcalOutlierPar0() const {return fV0MZDCEcalOutlierPar0 ;} + Float_t V0MZDCEcalOutlierPar1() const {return fV0MZDCEcalOutlierPar1 ;} + + Float_t ZVCut() const {return fZVCut;} + Float_t OutliersCut() const {return fOutliersCut;} + Bool_t UseScaling() const {return fUseScaling;} + Bool_t UseCleaning() const {return fUseCleaning;} + + TH1F* V0hist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0M_percentile")));} + TH1F* V0Ahist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0A_percentile")));} + TH1F* V0A123hist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0A123_percentile")));} + TH1F* V0Chist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0C_percentile")));} + TH1F* V0Eqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEq_percentile")));} + TH1F* V0AEqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEq_percentile")));} + TH1F* V0CEqhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEq_percentile")));} + TH1F* TPChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRK_percentile")));} + TH1F* CNDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCND_percentile")));} + TH1F* SPDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1_percentile")));} + TH1F* FMDhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMD_percentile")));} + TH1F* ZNAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNA_percentile")));} + TH1F* ZNChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNC_percentile")));} + TH1F* ZPAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPA_percentile")));} + TH1F* ZPChist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPC_percentile")));} + TH2F* ZEMvsZDChist() const {return ((TH2F*) (Hists2D()->FindObject("fHOutMultZEMvsZDC")));} + + TH1F* NPAhist() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultNPA_percentile")));} + TH1F* NPAhistDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultNPADPM_percentile")));} + + TH1F* V0histtrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Mtrue_percentile")));} + TH1F* V0Ahisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Atrue_percentile")));} + TH1F* V0Chisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0Ctrue_percentile")));} + TH1F* V0Eqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEqtrue_percentile")));} + TH1F* V0AEqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEqtrue_percentile")));} + TH1F* V0CEqhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEqtrue_percentile")));} + TH1F* TPChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRKtrue_percentile")));} + TH1F* CNDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCNDtrue_percentile")));} + TH1F* SPDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1true_percentile")));} + TH1F* FMDhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMDtrue_percentile")));} + TH1F* ZNAhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNAtrue_percentile")));} + TH1F* ZNChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNCtrue_percentile")));} + TH1F* ZPAhisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPAtrue_percentile")));} + TH1F* ZPChisttrue() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPCtrue_percentile")));} + + TH1F* V0histtrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MtrueDPM_percentile")));} + TH1F* V0AhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AtrueDPM_percentile")));} + TH1F* V0ChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CtrueDPM_percentile")));} + TH1F* V0EqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0MEqtrueDPM_percentile")));} + TH1F* V0AEqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0AEqtrueDPM_percentile")));} + TH1F* V0CEqhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultV0CEqtrueDPM_percentile")));} + TH1F* TPChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultTRKtrueDPM_percentile")));} + TH1F* CNDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCNDtrueDPM_percentile")));} + TH1F* SPDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultCL1trueDPM_percentile")));} + TH1F* FMDhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultFMDtrueDPM_percentile")));} + TH1F* ZNAhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNAtrueDPM_percentile")));} + TH1F* ZNChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZNCtrueDPM_percentile")));} + TH1F* ZPAhisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPAtrueDPM_percentile")));} + TH1F* ZPChisttrueDPM() const {return ((TH1F*) (Hists1D()->FindObject("fHOutMultZPCtrueDPM_percentile")));} + TList* Hists1D() const {return f1DHistos;} + TList* Hists2D() const {return f2DHistos;} + + void SetScaleFactors(Float_t v0m, Float_t spd, Float_t tpc, Float_t v0mMC) + {fV0MScaleFactor = v0m; fSPDScaleFactor = spd; fTPCScaleFactor = tpc; fV0MScaleFactorMC = v0mMC;} + + void SetOutlierV0MSPDFactors(Float_t a1, Float_t a2, Float_t a3, Float_t a4, Float_t a5) + {fV0MSPDOutlierPar0=a1;fV0MSPDOutlierPar1=a2;fV0MSPDSigmaOutlierPar0=a3;fV0MSPDSigmaOutlierPar1=a4;fV0MSPDSigmaOutlierPar2=a5;} + + void SetOutlierV0MTPCFactors(Float_t a1, Float_t a2, Float_t a3, Float_t a4, Float_t a5) + {fV0MTPCOutlierPar0=a1;fV0MTPCOutlierPar1=a2;fV0MTPCSigmaOutlierPar0=a3;fV0MTPCSigmaOutlierPar1=a4;fV0MTPCSigmaOutlierPar2=a5;} + + void SetOutlierV0MZDCFactors(Float_t a1, Float_t a2) + {fV0MZDCOutlierPar0=a1;fV0MZDCOutlierPar1=a2;} + + void SetOutlierV0MZDCEcalFactors(Float_t a1, Float_t a2) + {fV0MZDCEcalOutlierPar0=a1;fV0MZDCEcalOutlierPar1=a2;} + + void SetHistReferences(TList* l1, TList* l2) + {f1DHistos = l1; f2DHistos = l2;} + + void SetZVCut(Float_t z) + {fZVCut=z;} + + void SetOutliersCut(Float_t o) + {fOutliersCut=o;} + + void SetUseScaling(Bool_t x) + {fUseScaling=x;} + + void SetUseCleaning(Bool_t x) + {fUseCleaning=x;} + + + private: + AliOADBCentrality(const AliOADBCentrality& cont); + AliOADBCentrality& operator=(const AliOADBCentrality& cont); + + private: + Float_t fV0MScaleFactor; // V0 scale factor + Float_t fSPDScaleFactor; // SPD scale factor + Float_t fTPCScaleFactor; // TPC scale factor + Float_t fV0MScaleFactorMC; // V0 scale factor for MC + + Float_t fV0MSPDOutlierPar0; // V0-SPD outlier parameterisation Par0 + Float_t fV0MSPDOutlierPar1; // Par1 + Float_t fV0MTPCOutlierPar0; // Par2 + Float_t fV0MTPCOutlierPar1; // Par3 + + Float_t fV0MSPDSigmaOutlierPar0; // V0-SPD Sigma outlier parameterisation Par0 + Float_t fV0MSPDSigmaOutlierPar1; // Par1 + Float_t fV0MSPDSigmaOutlierPar2; // Par2 + Float_t fV0MTPCSigmaOutlierPar0; // Par3 + Float_t fV0MTPCSigmaOutlierPar1; // Par4 + Float_t fV0MTPCSigmaOutlierPar2; // Par5 + + Float_t fV0MZDCOutlierPar0; // V0-ZDC outlier parameterisation Par0 + Float_t fV0MZDCOutlierPar1; // Par1 + Float_t fV0MZDCEcalOutlierPar0; // Par2 + Float_t fV0MZDCEcalOutlierPar1; // Par3 + + Float_t fZVCut; // zV-cut + Float_t fOutliersCut; // outlier cuts + Bool_t fUseScaling; // Flag for scaling + Bool_t fUseCleaning; // Flag for cleaning + + TList* f1DHistos; // Reference to list of 1D Centrality histos + TList* f2DHistos; // Reference to list of 2D Centrality histos + ClassDef(AliOADBCentrality, 3); +}; + +#endif diff --git a/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.cxx b/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.cxx index 4f5c8d52b09..8729779b3e6 100644 --- a/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.cxx +++ b/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.cxx @@ -1,1538 +1,1538 @@ -/************************************************************************** -* Copyright(c) 1998-2008,ALICE Experiment at CERN,All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use,copy,modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee,provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ - -///////////////////////////////////////////////////// -// AliAnalysisTaskFlowCascade: -// Analysis task to select Xi and Omega candidates for flow analysis. -// -// Author: Zhong-Bao.Yin@cern.ch -////////////////////////////////////////////////////// - -#include "TChain.h" -#include "TList.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TH3D.h" -#include "TProfile.h" -#include "TVector3.h" - -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" - -#include "AliVParticle.h" -#include "AliESDEvent.h" -#include "AliESDInputHandler.h" -#include "AliESDv0.h" -#include "AliESDcascade.h" -#include "AliESDtrack.h" -#include "AliESDtrackCuts.h" -#include "AliCentrality.h" -#include "AliVVertex.h" -#include "AliESDVZERO.h" -#include "AliESDUtils.h" - -#include "AliTPCPIDResponse.h" -#include "AliTOFPIDResponse.h" -#include "AliPIDResponse.h" - -#include "AliAODEvent.h" -#include "AliAODInputHandler.h" -#include "AliAODTrack.h" -#include "AliAODVZERO.h" -#include "AliAODcascade.h" - -#include "TMath.h" -#include "TObjArray.h" -#include "AliFlowCandidateTrack.h" - -#include "AliFlowTrackCuts.h" -#include "AliFlowEventCuts.h" -#include "AliFlowEvent.h" -#include "AliFlowCommonConstants.h" - -#include "AliAnalysisTaskFlowCascade.h" - -ClassImp(AliAnalysisTaskFlowCascade) - -//_____________________________________________________________________________ - AliAnalysisTaskFlowCascade::AliAnalysisTaskFlowCascade() : - AliAnalysisTaskSE(), - // fMinCent(0), fMaxCent(0), - fSpecie(0), - fMassBins(0), - fMinMass(0.0), - fMaxMass(0.0), - fCutsEvent(NULL), - fCutsRPTPC(NULL), - fCutsRPVZE(NULL), - fCutsPOI(NULL), - fCutsDau(NULL), - fPIDResponse(NULL), - fFlowEventTPC(NULL), - fFlowEventVZE(NULL), - fCandidates(NULL), - fQAList(NULL) -{ - //ctor - for (Int_t i=0; i!=8; ++i) - fCascadeCuts[i] = 0; - -} - -//_____________________________________________________________________________ -AliAnalysisTaskFlowCascade -::AliAnalysisTaskFlowCascade(const char *name, - AliFlowEventCuts *cutsEvent, - AliFlowTrackCuts *cutsRPTPC, - AliFlowTrackCuts *cutsRPVZE, - /* AliESDtrackCuts */ AliFlowTrackCuts *cutsDau ) : - AliAnalysisTaskSE(name), - //fMinCent(minCent), fMaxCent(maxCent), - fSpecie(0), - fMassBins(0), - fMinMass(0.0), - fMaxMass(0.0), - fCutsEvent(cutsEvent), - fCutsRPTPC(cutsRPTPC), - fCutsRPVZE(cutsRPVZE), - fCutsPOI(NULL), - fCutsDau(cutsDau), - fPIDResponse(NULL), - fFlowEventTPC(NULL), - fFlowEventVZE(NULL), - fCandidates(NULL), - fQAList(NULL) -{ - //ctor - for (Int_t i=0; i!=8; ++i) - fCascadeCuts[i] = 0; - - DefineInput( 0,TChain::Class()); - DefineOutput(1,AliFlowEventSimple::Class()); // TPC object - DefineOutput(2,AliFlowEventSimple::Class()); // VZE object - DefineOutput(3,TList::Class()); -} - -//_____________________________________________________________________________ -AliAnalysisTaskFlowCascade::~AliAnalysisTaskFlowCascade() -{ - if(fQAList) delete fQAList; - if (fFlowEventTPC) delete fFlowEventTPC; - if (fFlowEventVZE) delete fFlowEventVZE; - if (fCandidates) delete fCandidates; - if (fCutsDau) delete fCutsDau; - if (fCutsPOI) delete fCutsPOI; - if (fCutsRPTPC) delete fCutsRPTPC; - if (fCutsRPVZE) delete fCutsRPVZE; -} - -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::UserCreateOutputObjects() -{ - - AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); - AliInputEventHandler* inputHandler - = (AliInputEventHandler*) (man->GetInputEventHandler()); - fPIDResponse = inputHandler->GetPIDResponse(); - - fQAList = new TList(); - fQAList->SetOwner(); - AddQAEvents(); - AddQACandidates(); - // PostData(3,fQAList); - - AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster(); - cc->SetNbinsMult(1); - cc->SetMultMin(0); - cc->SetMultMax(1); - - cc->SetNbinsPt(20); - cc->SetPtMin(0.0); - cc->SetPtMax(10.0); - - cc->SetNbinsPhi(1); - cc->SetPhiMin(0.0); - cc->SetPhiMax(TMath::TwoPi()); - - cc->SetNbinsEta(1); - cc->SetEtaMin(-2.0); - cc->SetEtaMax(+2.0); - - cc->SetNbinsQ(3); - cc->SetQMin(0.0); - cc->SetQMax(3.0); - - cc->SetNbinsMass(fMassBins); - cc->SetMassMin(fMinMass); - cc->SetMassMax(fMaxMass); - - fCutsPOI = new AliFlowTrackCuts("null_cuts"); - fCutsPOI->SetParamType(fCutsRPTPC->GetParamType()); - fCutsPOI->SetPtRange(+1,-1); // select nothing QUICK - fCutsPOI->SetEtaRange(+1,-1); // select nothing VZERO - - fFlowEventTPC = new AliFlowEvent(3000); - fFlowEventVZE = new AliFlowEvent(1000); - fCandidates = new TObjArray(100); - fCandidates->SetOwner(); - - PostData(1,fFlowEventTPC); - PostData(2,fFlowEventVZE); - PostData(3,fQAList); -} - -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::AddQAEvents() -{ - TList *tQAEvents = new TList(); - tQAEvents->SetName("Events"); - tQAEvents->SetOwner(); - TH1I* tEvent = new TH1I("Event","Number of Events", 3,0,3); - tQAEvents->Add(tEvent); - - TH1D *tTPCRFP = new TH1D("RFPTPC", - "TPC Reference Flow Particles;multiplicity", - 100, 0, 3000); - tQAEvents->Add(tTPCRFP); - TH1D *tVZERFP = new TH1D("RFPVZE", - "VZERO Reference Flow Particles;multiplicity", - 100, 0, 30000); - tQAEvents->Add(tVZERFP); - - TProfile *tCuts = new TProfile("Cuts","Analysis Cuts",10,0,10); - tCuts->Fill(0.5,fCascadeCuts[0],1); - tCuts->GetXaxis()->SetBinLabel(1,"dcaXiDau"); - tCuts->Fill(1.5,fCascadeCuts[1],1); - tCuts->GetXaxis()->SetBinLabel(2,"XiCPA"); - tCuts->Fill(2.5,fCascadeCuts[2],1); - tCuts->GetXaxis()->SetBinLabel(3,"dcaV0Vtx"); - tCuts->Fill(3.5,fCascadeCuts[3],1); - tCuts->GetXaxis()->SetBinLabel(4,"dcaBachVtx"); - tCuts->Fill(4.5,fCascadeCuts[4],1); - tCuts->GetXaxis()->SetBinLabel(5,"dcaV0Dau"); - tCuts->Fill(5.5,fCascadeCuts[5],1); - tCuts->GetXaxis()->SetBinLabel(6,"V0CPA"); - tCuts->Fill(6.5,fCascadeCuts[6],1); - tCuts->GetXaxis()->SetBinLabel(7,"dcaV0DauVtx"); - tCuts->Fill(7.5,fCascadeCuts[7],1); - tCuts->GetXaxis()->SetBinLabel(8,"V0Mass"); - tQAEvents->Add(tCuts); - - fQAList->Add(tQAEvents); -} - -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::AddQACandidates() -{ - TList *tQACandidates; - - tQACandidates = new TList(); - tQACandidates->SetOwner(); - tQACandidates->SetName("Candidates"); - - TH1F* tChi2Xi = new TH1F("Chi2Xi", - "Cascade #chi^{2}; #chi^{2}; Number of Cascades", - 160, 0, 160); - tQACandidates->Add(tChi2Xi); - - TH1F* tDCAXiDaughters - = new TH1F( "DcaXiDaughters", - "DCA between Xi Daughters; DCA (cm); Number of Cascades", - 100, 0., 0.5); - tQACandidates->Add(tDCAXiDaughters); - - TH1F * tDCABachToPrimVertex - = new TH1F("DcaBachToPrimVertex", - "DCA of Bach. to Prim. Vertex; DCA (cm);Number of Cascades", - 250, 0., 2.5); - tQACandidates->Add(tDCABachToPrimVertex); - - TH1F * tXiCosOfPointingAngle - = new TH1F("XiCosOfPointingAngle", - "Cos of Xi Pointing Angle; Cos (Xi Point.Angl);Number of Xis", - 200, 0.99, 1.0); - tQACandidates->Add(tXiCosOfPointingAngle); - - TH1F * tXiRadius = new TH1F("XiRadius", - "Casc. decay transv. radius; r (cm); Counts" , - 1050, 0., 105.0 ); - tQACandidates->Add(tXiRadius); - - TH1F *tMassLambda - = new TH1F("MassLambdaAsCascDghter", - "#Lambda assoc. to Casc. candidates; Eff. Mass (GeV/c^{2}); Counts", - 300,1.00,1.3); - tQACandidates->Add(tMassLambda); - - TH1F *tV0Chi2 = new TH1F("V0Chi2Xi", - "V0 #chi^{2}, in cascade; #chi^{2};Counts", - 160, 0, 40); - tQACandidates->Add(tV0Chi2); - - TH1F * tV0CosOfPointingAngle - = new TH1F("V0CosOfPointingAngleXi", - "Cos of V0 Pointing Angle, in cascade;Cos(V0 Point. Angl); Counts", - 200, 0.98, 1.0); - tQACandidates->Add(tV0CosOfPointingAngle); - - TH1F *tV0Radius = new TH1F("V0RadiusXi", - "V0 decay radius, in cascade; radius (cm); Counts", - 1050, 0., 105.0); - tQACandidates->Add(tV0Radius); - - TH1F * tDcaV0DaughtersXi - = new TH1F("DcaV0DaughtersXi", - "DCA between V0 daughters, in cascade;DCA (cm);Number of V0s", - 120, 0., 0.6); - tQACandidates->Add(tDcaV0DaughtersXi); - - TH1F * tDcaV0ToPrimVertex - = new TH1F("DcaV0ToPrimVertexXi", - "DCA of V0 to Prim. Vertex, in cascade;DCA (cm);Number of Cascades", 200, 0., 1.); - tQACandidates->Add(tDcaV0ToPrimVertex); - - TH1F * tDCAPosToPrimVertex = - new TH1F("DcaPosToPrimVertexXi", - "DCA of V0 pos daughter to Prim. Vertex;DCA (cm);Counts", - 300, 0, 3); - tQACandidates->Add(tDCAPosToPrimVertex); - - TH1F * tDCANegToPrimVertex - = new TH1F("DcaNegToPrimVertexXi", - "DCA of V0 neg daughter to Prim. Vertex;DCA (cm);Counts", - 300, 0, 3); - tQACandidates->Add(tDCANegToPrimVertex); - - TH1F *tV0toXiCosOfPointingAngle - = new TH1F("V0toXiCosOfPointingAngle", - "Cos. of V0 Ptng Angl Xi vtx; Cos(V0 Point. Angl / Xi vtx); Counts", - 100, 0.99, 1.0); - tQACandidates->Add(tV0toXiCosOfPointingAngle); - - TH2F *th2Armenteros - = new TH2F("Armenteros", - "#alpha_{Arm}(casc. cand.) Vs Pt_{Arm}(casc. cand.); #alpha_{Arm} ; Pt_{Arm} (GeV/c)", - 140, -1.2, 1.2, 300, 0., 0.3); - tQACandidates->Add(th2Armenteros); - - TH2F *th2TPCdEdxOfCascDghters - = new TH2F( "TPCdEdxOfCascDghters", - "TPC dE/dx of the cascade daughters; charge x || #vec{p}_{TPC inner wall}(Casc. daughter) || (GeV/c); TPC signal (ADC) ", - 200, -10.0, 10.0, 450, 0., 900.); - tQACandidates->Add(th2TPCdEdxOfCascDghters); - - TH2F *th2MassVsPtAll - = new TH2F("MassVsPtAll", - "M_{candidates} vs Pt; Pt (GeV/c); M (GeV/c^{2})", - 100, 0., 10., fMassBins, fMinMass, fMaxMass); - tQACandidates->Add(th2MassVsPtAll); - - TH1F *tDistToVtxZAfter - = new TH1F("DistToVtxZAfter", - "Distance to vtx z after propagation to vtx; z [cm]", - 100, -5., 5.); - tQACandidates->Add(tDistToVtxZAfter); - - TH1F * tDistToVtxXYAfter - = new TH1F("DistToVtxXYAfter", - "Distance to vtx xy after propagation to vtx", - 500, 0., 50.); - tQACandidates->Add(tDistToVtxXYAfter); - - TH2F *th2DistToVtxZBeforeVsAfter - = new TH2F("DistToVtxZBeforeVsAfter", - "Distance to vtx z before vs after propagation; Distance before [cm]; Distance after [cm]", - 500, -50., 50., 100, -5., 5.); - tQACandidates->Add(th2DistToVtxZBeforeVsAfter); - - TH2F *th2DistToVtxXYBeforeVsAfter - = new TH2F("DistToVtxXYBeforeVsAfter", - "Distance to vtx xy before vs after propagation; Distance before [cm]; Distance after [cm]", - 500, 0., 50, 500, 0., 50); - tQACandidates->Add(th2DistToVtxXYBeforeVsAfter); - - TH2F * th2PxBeforeVsAfter - = new TH2F("PxBeforeVsAfter", - "Px before vs after propagation; Px [GeV/c]; Px' [GeV/c]", - 200, -10., 10, 200, -10., 10.); - tQACandidates->Add(th2PxBeforeVsAfter); - - TH2F * th2PyBeforeVsAfter - = new TH2F("PyBeforeVsAfter", - "Py before vs after propagation; Py [GeV/c]; Py' [GeV/c]", - 200, -10., 10, 200, -10., 10.); - tQACandidates->Add(th2PyBeforeVsAfter); - - TH2F * th2PhiPosBeforeVsAfter - = new TH2F("PhiPosBeforeVsAfter", - "Phi for positively charged candidates before vs after propagation; #phi; #phi'", - 360, 0., 2.0*TMath::Pi(), 360, 0., 2.0*TMath::Pi()); - tQACandidates->Add(th2PhiPosBeforeVsAfter); - - TH2F *th2PhiNegBeforeVsAfter - = new TH2F("PhiNegBeforeVsAfter", - "Phi for negatively charged candidates before vs after propagation; #phi; #phi'", - 360, 0., 2.0*TMath::Pi(), 360, 0., 2.0*TMath::Pi()); - tQACandidates->Add(th2PhiNegBeforeVsAfter); - - fQAList->Add(tQACandidates); -} - -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::NotifyRun() -{ -} -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::UserExec(Option_t *) -{ - AliESDEvent *fESD = dynamic_cast(InputEvent()); - AliAODEvent *fAOD = dynamic_cast(InputEvent()); - Bool_t acceptEvent=kFALSE; - fCandidates->SetLast(-1); - - if(fESD) { - // recorrecting VZERO (for pass 1 only) - /* - Float_t *vChCorr = new Float_t[64]; - Float_t dummy; - AliESDUtils::GetCorrV0(fESD,dummy,NULL,vChCorr); - AliESDVZERO *vzero = (AliESDVZERO*) fESD->GetVZEROData(); - vzero->SetMultiplicity( vChCorr ); - delete [] vChCorr; - */ - // - - ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(0); - - const AliVVertex *vtxGlb = fESD->GetPrimaryVertexTracks(); - const AliVVertex *vtxSPD = fESD->GetPrimaryVertexSPD(); - if(!vtxGlb || !vtxSPD) return; - if( fCutsEvent->IsSelected(fESD, 0) && (TMath::Abs(vtxSPD->GetZ()-vtxGlb->GetZ()) <= 0.5) ) { - acceptEvent = kTRUE; - ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); - ReadFromESDv0(fESD); - } - } else if(fAOD) { - const AliVVertex *vtxGlb = fAOD->GetPrimaryVertex(); - const AliVVertex *vtxSPD = fAOD->GetPrimaryVertexSPD(); - if(!vtxGlb || !vtxSPD) return; - - ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(0); - - if(fCutsEvent->IsSelected(fAOD, 0) && (TMath::Abs(vtxSPD->GetZ()-vtxGlb->GetZ()) <= 0.5) ) { - acceptEvent = kTRUE; - ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); - ReadFromAODv0(fAOD); - } - - - /* - - AliAODHeader *aodHeader = fAOD->GetHeader(); - if(!aodHeader) return; - AliCentrality *centrality = aodHeader->GetCentralityP(); - if(!centrality) return; - Double_t cent = centrality->GetCentralityPercentile("V0M" ); - Double_t cent1 = centrality->GetCentralityPercentile("TRK" ); - if(TMath::Abs(cent-cent1) >= 5.) return; - - if(cent=fMaxCent) return; //centrality cut - - Double_t zvtx = fAOD->GetPrimaryVertex()->GetZ(); - if(TMath::Abs(zvtx)>10.) return; //vertex cut - - ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); - ReadFromAODv0(fAOD); - */ - } - - if(!acceptEvent) return; - - ((TH1D*)((TList*)fQAList->FindObject("Events"))->FindObject("RFPTPC")) - ->Fill(fFlowEventTPC->GetNumberOfRPs() ); - Double_t mult=0; - for(Int_t i=0; i != fFlowEventVZE->GetNumberOfRPs(); ++i) { - AliFlowTrackSimple *pTrack = fFlowEventVZE->GetTrack(i); - mult += pTrack->Weight(); - } - ((TH1D*)((TList*)fQAList->FindObject("Events"))->FindObject("RFPVZE")) - ->Fill( mult ); - - // if(fDebug) printf("TPCevent %d | VZEevent %d\n", - // fFlowEventTPC->NumberOfTracks(), - // fFlowEventVZE->NumberOfTracks() ); - AddCandidates(); - - PostData(1,fFlowEventTPC); - PostData(2,fFlowEventVZE); - PostData(3,fQAList); - - return; -} - -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::AddCandidates(){ - - // if(fDebug) printf("I received %d candidates\n", - // fCandidates->GetEntriesFast()); - for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) { - AliFlowCandidateTrack *cand - = dynamic_cast(fCandidates->At(iCand)); - if(!cand) continue; - // if(fDebug) - // printf(" >Checking at candidate %d with %d daughters: mass %f\n", - // iCand, cand->GetNDaughters(), cand->Mass()); - - // untagging ===> - for(int iDau=0; iDau != cand->GetNDaughters(); ++iDau) { - // if(fDebug) - // printf(" >Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau)); - for(int iRPs=0; iRPs != fFlowEventTPC->NumberOfTracks(); ++iRPs ) { - AliFlowTrack *iRP - = dynamic_cast(fFlowEventTPC->GetTrack( iRPs )); - if (!iRP) continue; - if( !iRP->InRPSelection() ) continue; - if( cand->GetIDDaughter(iDau) == iRP->GetID() ) { - //if(fDebug) printf(" was in RP set"); - iRP->SetForRPSelection(kFALSE); - fFlowEventTPC->SetNumberOfRPs( fFlowEventTPC->GetNumberOfRPs() -1 ); - } - } - //if(fDebug) printf("\n"); - } - // <=== untagging - cand->SetForPOISelection(kTRUE); - fFlowEventTPC->InsertTrack( ((AliFlowTrack*) cand) ); - fFlowEventVZE->InsertTrack( ((AliFlowTrack*) cand) ); - } - - // if(fDebug) printf("TPCevent %d | VZEevent %d\n", - // fFlowEventTPC->NumberOfTracks(), - // fFlowEventVZE->NumberOfTracks() ); - -} - -//______________________________________________________________________________ -void AliAnalysisTaskFlowCascade::ReadFromESDv0(AliESDEvent *fESD) -{ - //AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("null_cuts"); - //cutsPOI->SetParamType( fCutsRP->GetParamType() ); - //cutsPOI->SetParamType( AliFlowTrackCuts::kGlobal ); - // cutsPOI->SetPtRange(+1,-1); // select nothing - //cutsPOI->SetEtaRange(+1,-1); // select nothing VZERO - - fCutsRPTPC->SetEvent(fESD,MCEvent()); - fCutsRPVZE->SetEvent(fESD,MCEvent()); - - fCutsPOI->SetEvent(fESD,MCEvent()); - - fFlowEventTPC->Fill(fCutsRPTPC,fCutsPOI); - fFlowEventVZE->Fill(fCutsRPVZE,fCutsPOI); - - Double_t trkPrimaryVtxPos[3] = {-100., -100., -100.}; - Double_t bestPrimaryVtxPos[3] = {-100., -100., -100.}; - int nCascades=fESD->GetNumberOfCascades(); - - const AliESDVertex *primaryTrackingESDVtx = fESD->GetPrimaryVertexTracks(); - primaryTrackingESDVtx->GetXYZ(trkPrimaryVtxPos); - - const AliESDVertex *primaryBestESDVtx = fESD->GetPrimaryVertex(); - primaryBestESDVtx->GetXYZ(bestPrimaryVtxPos); - - Double_t b = fESD->GetMagneticField(); - - for(int i = 0; i != nCascades; ++i) { - - // Double_t trkPrimaryVtxRadius3D = -500.; - // Double_t bestPrimaryVtxRadius3D = -500.; - Double_t effMassXi = 0.; - Double_t chi2Xi = -1.; - Double_t dcaXiDaughters = -1.; - Double_t XiCosOfPointingAngle = -1.; - Double_t posXi[3] = {-1000., -1000., -1000.}; - Double_t XiRadius = -1000.; - - // Double_t innerWallMomCascDghters[3] = {-100., -100., -100.}; - //Double_t tpcSignalCascDghters[3] = {-100., -100., -100.}; - - Double_t invMassLambdaAsCascDghter = 0.; - Double_t V0Chi2Xi = -1.; - Double_t dcaV0DaughtersXi = -1.; - - Double_t dcaBachToPrimaryVtxXi = -1.; - Double_t dcaV0ToPrimaryVtxXi = -1.; - Double_t dcaPosToPrimaryVtxXi = -1.; - Double_t dcaNegToPrimaryVtxXi = -1.; - Double_t V0CosOfPointingAngleXi = -1.; - Double_t posV0Xi[3] = {-1000., -1000., -1000.}; - Double_t V0RadiusXi = -1000.; - Double_t V0quality = 0.; - - Double_t invMassXiMinus = 0.; - Double_t invMassXiPlus = 0.; - Double_t invMassOmegaMinus = 0.; - Double_t invMassOmegaPlus = 0.; - - /* - Bool_t isPosInXiProton = kFALSE; - Bool_t isPosInXiPion = kFALSE; - Bool_t isPosInOmegaProton = kFALSE; - Bool_t isPosInOmegaPion = kFALSE; - - Bool_t isNegInXiProton = kFALSE; - Bool_t isNegInXiPion = kFALSE; - Bool_t isNegInOmegaProton = kFALSE; - Bool_t isNegInOmegaPion = kFALSE; - - Bool_t isBachelorKaon = kFALSE; - Bool_t isBachelorPion = kFALSE; - */ - - Bool_t isBachelorKaonForTPC = kFALSE; - Bool_t isBachelorPionForTPC = kFALSE; - Bool_t isNegPionForTPC = kFALSE; - Bool_t isPosPionForTPC = kFALSE; - Bool_t isNegProtonForTPC = kFALSE; - Bool_t isPosProtonForTPC = kFALSE; - - Double_t XiPx = 0., XiPy = 0., XiPz = 0.; - Double_t XiPt = 0.; - Double_t XiPtot = 0.; - - Double_t bachPx = 0., bachPy = 0., bachPz = 0.; - Double_t bachPt = 0.; - Double_t bachPtot = 0.; - - //Short_t chargeXi = -2; - Double_t V0toXiCosOfPointingAngle = 0.; - - Double_t rapXi = -20.; - Double_t rapOmega = -20.; - Double_t phi = 6.3; - Double_t alphaXi = -200.; - Double_t ptArmXi = -200.; - // TLorentzVector lv1, lv2, lv3, lv12, lvXi; - - Double_t distToVtxZBefore = -999.; - Double_t distToVtxZAfter = -999.; - Double_t distToVtxXYBefore = -999.; - Double_t distToVtxXYAfter = -999.; - Double_t XiPAfter[3] = {-999., -999., -999.}; - Double_t phiAfter = -999.; - - AliESDcascade *xi = fESD->GetCascade(i); - if(!xi) continue; - - if(xi->Charge()<0) - xi->ChangeMassHypothesis(V0quality, 3312); // Xi- hypothesis - else if(xi->Charge() > 0) - xi->ChangeMassHypothesis(V0quality, -3312); - else continue; - - effMassXi = xi->GetEffMassXi(); - chi2Xi = xi->GetChi2Xi(); - dcaXiDaughters = xi->GetDcaXiDaughters(); - XiCosOfPointingAngle - = xi->GetCascadeCosineOfPointingAngle(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2]); - xi->GetXYZcascade(posXi[0], posXi[1], posXi[2]); - XiRadius = TMath::Sqrt(posXi[0]*posXi[0] - +posXi[1]*posXi[1] - +posXi[2]*posXi[2]); - - UInt_t idxPosXi = (UInt_t)TMath::Abs(xi->GetPindex()); - UInt_t idxNegXi = (UInt_t)TMath::Abs(xi->GetNindex()); - UInt_t idxBach = (UInt_t)TMath::Abs(xi->GetBindex()); - - if(idxBach == idxPosXi || idxBach == idxNegXi) continue; - - AliESDtrack *pTrkXi = fESD->GetTrack(idxPosXi); - AliESDtrack *nTrkXi = fESD->GetTrack(idxNegXi); - AliESDtrack *bTrkXi = fESD->GetTrack(idxBach); - - if( !pTrkXi || !nTrkXi || !bTrkXi ) continue; - - if( !fCutsDau->IsSelected(pTrkXi) - || !fCutsDau->IsSelected(nTrkXi) - || !fCutsDau->IsSelected(bTrkXi) ) continue; - - const AliExternalTrackParam *pExtTrk = pTrkXi->GetInnerParam(); - const AliExternalTrackParam *nExtTrk = nTrkXi->GetInnerParam(); - const AliExternalTrackParam *bExtTrk = bTrkXi->GetInnerParam(); - - if(pExtTrk && pTrkXi->IsOn(AliESDtrack::kTPCin)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(pExtTrk->GetP()*pExtTrk->Charge(), pTrkXi->GetTPCsignal()); - } - if(nExtTrk && nTrkXi->IsOn(AliESDtrack::kTPCin)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(nExtTrk->GetP()*nExtTrk->Charge(), nTrkXi->GetTPCsignal()); - } - if(bExtTrk && bTrkXi->IsOn(AliESDtrack::kTPCin)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(bExtTrk->GetP()*bExtTrk->Charge(), bTrkXi->GetTPCsignal()); - } - - invMassLambdaAsCascDghter = xi->GetEffMass(); // from V0 - dcaV0DaughtersXi = xi->GetDcaV0Daughters(); - V0Chi2Xi = xi->GetChi2V0(); - V0CosOfPointingAngleXi - = xi->GetV0CosineOfPointingAngle(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2]); - dcaV0ToPrimaryVtxXi = xi->GetD(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2]); - dcaBachToPrimaryVtxXi = TMath::Abs(bTrkXi->GetD(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2])); - - //V0 - xi->GetXYZ(posV0Xi[0], posV0Xi[1], posV0Xi[2]); - V0RadiusXi = TMath::Sqrt(posV0Xi[0]*posV0Xi[0] - +posV0Xi[1]*posV0Xi[1] - +posV0Xi[2]*posV0Xi[2]); - dcaPosToPrimaryVtxXi = TMath::Abs(pTrkXi->GetD(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2])); - dcaNegToPrimaryVtxXi = TMath::Abs(nTrkXi->GetD(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2])); - - //apply cuts - //if(XiRadius < 0.9 || XiRadius > 100.) continue; - //if(dcaXiDaughters > 0.2) continue; - //if(XiCosOfPointingAngle < 0.99) continue; - //if(dcaV0ToPrimaryVtxXi < 0.03) continue; - //if(dcaBachToPrimaryVtxXi < 0.01) continue; - - if(dcaXiDaughters > fCascadeCuts[0]) continue; - if(XiCosOfPointingAngle < fCascadeCuts[1]) continue; - if(dcaV0ToPrimaryVtxXi < fCascadeCuts[2]) continue; - if(dcaBachToPrimaryVtxXi < fCascadeCuts[3]) continue; - - //V0 mass cut? - // if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > 0.01) continue; - if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > fCascadeCuts[7]) - continue; - - //if(dcaV0DaughtersXi > 1.) continue; - //if(V0CosOfPointingAngleXi > 0.9999) continue; - //if(dcaPosToPrimaryVtxXi < 0.1) continue; - //if(dcaNegToPrimaryVtxXi < 0.1) continue; - - if(dcaV0DaughtersXi > fCascadeCuts[4]) continue; - if(V0CosOfPointingAngleXi > fCascadeCuts[5]) continue; - if(dcaPosToPrimaryVtxXi < fCascadeCuts[6]) continue; - if(dcaNegToPrimaryVtxXi < fCascadeCuts[6]) continue; - - //if(V0RadiusXi < 1.0 || V0RadiusXi > 100) continue; - - //other cuts? - // change mass hypothesis to cover all the possibilities - if(bTrkXi->Charge()<0){ - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, 3312); //Xi- hyp. - invMassXiMinus = xi->GetEffMassXi(); - - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, 3334); //Omega- hyp. - invMassOmegaMinus = xi->GetEffMassXi(); - - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, 3312); //back to default hyp. - } - - if(bTrkXi->Charge() > 0){ - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, -3312); //anti-Xi- hyp. - invMassXiPlus = xi->GetEffMassXi(); - - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, -3334); //anti-Omega- hyp. - invMassOmegaPlus = xi->GetEffMassXi(); - - V0quality = 0.; - xi->ChangeMassHypothesis(V0quality, -3312); //back to default hyp. - } - - //PID on the daughter tracks - /* - //A - Combined PID - //Resonable guess the priors for the cascade track sample - //(e, mu, pi, K, p) - Double_t priorsGuessXi[5] = {0, 0, 2, 0, 1}; - Double_t priorsGuessOmega[5] = {0, 0, 1, 1, 1}; - - //Combined bachelor-daughter PID - AliPID pidXi; - pidXi.SetPriors(priorsGuessXi); - AliPID pidOmega; - pidOmega.SetPriors(priorsGuessOmega); - - if(pTrkXi->IsOn(AliESDtrack::kESDpid)){// combined PID exists - Double_t r[10] = {0.}; - pTrkXi->GetESDpid(r); - pidXi.SetProbabilities(r); - pidOmega.SetProbabilities(r); - - //Check if the V0 postive track is proton (case for Xi-) - Double_t pProton = pidXi.GetProbability(AliPID::kProton); - if(pProton > pidXi.GetProbability(AliPID::kElectron) - && pProton > pidXi.GetProbability(AliPID::kMuon) - && pProton > pidXi.GetProbability(AliPID::kPion) - && pProton > pidXi.GetProbability(AliPID::kKaon)) - isPosInXiProton = kTRUE; - - //Check if the V0 postive track is a pi+ (case for Xi+) - Double_t pPion = pidXi.GetProbability(AliPID::kPion); - if(pPion > pidXi.GetProbability(AliPID::kElectron) - && pPion > pidXi.GetProbability(AliPID::kMuon) - && pPion > pidXi.GetProbability(AliPID::kKaon) - && pPion > pidXi.GetProbability(AliPID::kProton)) - isPosInXiPion = kTRUE; - // Check if the V0 positive track is a proton (case for Omega-) - pProton = pidOmega.GetProbability(AliPID::kProton); - if(pProton > pidOmega.GetProbability(AliPID::kElectron) - && pProton > pidOmega.GetProbability(AliPID::kMuon) - && pProton > pidOmega.GetProbability(AliPID::kPion) - && pProton > pidOmega.GetProbability(AliPID::kKaon)) - isPosInOmegaProton = kTRUE; - - // Check if the V0 positive track is a pi+ (case for Omega+) - pPion = pidOmega.GetProbability(AliPID::kPion); - if(pPion > pidOmega.GetProbability(AliPID::kElectron) - && pPion > pidOmega.GetProbability(AliPID::kMuon) - && pPion > pidOmega.GetProbability(AliPID::kKaon) - && pPion > pidOmega.GetProbability(AliPID::kProton)) - isPosInOmegaPion = kTRUE; - } - - //Combined V0-negative-daughter PID - pidXi.SetPriors(priorsGuessXi); - pidOmega.SetPriors(priorsGuessOmega); - if(nTrkXi->IsOn(AliESDtrack::kESDpid)){ - Double_t r[10] = {0.}; - nTrkXi->GetESDpid(r); - pidXi.SetProbabilities(r); - pidOmega.SetProbabilities(r); - - // Check if the V0 negative track is a pi- (case for Xi-) - Double_t pPion = pidXi.GetProbability(AliPID::kPion); - if(pPion > pidXi.GetProbability(AliPID::kElectron) - && pPion > pidXi.GetProbability(AliPID::kMuon) - && pPion > pidXi.GetProbability(AliPID::kKaon) - && pPion > pidXi.GetProbability(AliPID::kProton)) - isNegInXiPion = kTRUE; - - // Check if the V0 negative track is an anti-proton (case for Xi+) - Double_t pProton = pidXi.GetProbability(AliPID::kProton); - if(pProton > pidXi.GetProbability(AliPID::kElectron) - && pProton > pidXi.GetProbability(AliPID::kMuon) - && pProton > pidXi.GetProbability(AliPID::kPion) - && pProton > pidXi.GetProbability(AliPID::kKaon)) - isNegInXiProton = kTRUE; - - // Check if the V0 negative track is a pi- (case for Omega-) - pPion = pidOmega.GetProbability(AliPID::kPion); - if(pPion > pidOmega.GetProbability(AliPID::kElectron) - && pPion > pidOmega.GetProbability(AliPID::kMuon) - && pPion > pidOmega.GetProbability(AliPID::kKaon) - && pPion > pidOmega.GetProbability(AliPID::kProton)) - isNegInOmegaPion = kTRUE; - - // Check if the V0 negative track is an anti-proton (case for Omega+) - pProton = pidOmega.GetProbability(AliPID::kProton); - if(pProton > pidOmega.GetProbability(AliPID::kElectron) - && pProton > pidOmega.GetProbability(AliPID::kMuon) - && pProton > pidOmega.GetProbability(AliPID::kPion) - && pProton > pidOmega.GetProbability(AliPID::kKaon)) - isNegInOmegaProton = kTRUE; - - } - - // Combined bachelor PID - pidXi.SetPriors(priorsGuessXi); - pidOmega.SetPriors(priorsGuessOmega); - if(bTrkXi->IsOn(AliESDtrack::kESDpid)){//Combined PID exists - Double_t r[10] = {0.}; - bTrkXi->GetESDpid(r); - pidXi.SetProbabilities(r); - pidOmega.SetProbabilities(r); - - //Check if the bachelor track is a pion - Double_t pPion = pidXi.GetProbability(AliPID::kPion); - if(pPion > pidXi.GetProbability(AliPID::kElectron) - && pPion > pidXi.GetProbability(AliPID::kMuon) - && pPion > pidXi.GetProbability(AliPID::kKaon) - && pPion > pidXi.GetProbability(AliPID::kProton)) - isBachelorPion = kTRUE; - - // Check if the bachelor track is a kaon - Double_t pKaon = pidOmega.GetProbability(AliPID::kKaon); - if(pKaon > pidOmega.GetProbability(AliPID::kElectron) - && pKaon > pidOmega.GetProbability(AliPID::kMuon) - && pKaon > pidOmega.GetProbability(AliPID::kPion) - && pKaon > pidOmega.GetProbability(AliPID::kProton)) - isBachelorKaon = kTRUE; - } - */ - - - //B - TPC PID: 3-sigma bands on Bethe-Bloch curve - //Bachelor - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kKaon))<3.) - isBachelorKaonForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kPion))<3.) - isBachelorPionForTPC = kTRUE; - - //Negative V0 daughter - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kPion))<3.) - isNegPionForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kProton))<3.) - isNegProtonForTPC = kTRUE; - - //Positive V0 daughter - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kPion))<3.) - isPosPionForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kProton))<3.) - isPosProtonForTPC = kTRUE; - - - //Extra QA information - xi->GetPxPyPz(XiPx, XiPy, XiPz); - XiPt = TMath::Sqrt(XiPx*XiPx + XiPy*XiPy); - XiPtot= TMath::Sqrt(XiPx*XiPx + XiPy*XiPy + XiPz*XiPz); - - XiPAfter[0] = XiPx; - XiPAfter[1] = XiPy; - XiPAfter[2] = XiPz; - - xi->GetBPxPyPz(bachPx, bachPy, bachPz); - bachPt = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy); - bachPtot = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy + bachPz*bachPz); - - //chargeXi = xi->Charge(); - - V0toXiCosOfPointingAngle - = xi->GetV0CosineOfPointingAngle(posXi[0], posXi[1], posXi[2]); - rapXi = xi->RapXi(); - rapOmega = xi->RapOmega(); - phi = xi->Phi(); - alphaXi = xi->AlphaXi(); - ptArmXi = xi->PtArmXi(); - - distToVtxZBefore = posXi[2]-bestPrimaryVtxPos[2]; - distToVtxXYBefore - = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) - *(posXi[0] - bestPrimaryVtxPos[0]) - +(posXi[1] - bestPrimaryVtxPos[1]) - *(posXi[1] - bestPrimaryVtxPos[1])); - - //propagation to the best primary vertex to determine the momentum - Propagate(bestPrimaryVtxPos, posXi, XiPAfter, b, xi->Charge()); - distToVtxZAfter = posXi[2] - bestPrimaryVtxPos[2]; - distToVtxXYAfter = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) - *(posXi[0] - bestPrimaryVtxPos[0]) - +(posXi[1] - bestPrimaryVtxPos[1]) - *(posXi[1] - bestPrimaryVtxPos[1])); - phiAfter = TMath::Pi() + TMath::ATan2(-XiPAfter[1],-XiPAfter[0]); - - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZAfter"))->Fill(distToVtxZAfter); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYAfter"))->Fill(distToVtxXYAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZBeforeVsAfter"))->Fill(distToVtxZBefore, distToVtxZAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYBeforeVsAfter"))->Fill(distToVtxXYBefore, distToVtxXYAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PxBeforeVsAfter"))->Fill(XiPx, XiPAfter[0]); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PyBeforeVsAfter"))->Fill(XiPy, XiPAfter[1]); - if(xi->Charge()>0) - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiPosBeforeVsAfter"))->Fill(phi, phiAfter); - else if(xi->Charge()<0) - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiNegBeforeVsAfter"))->Fill(phi, phiAfter); - - - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Chi2Xi"))->Fill(chi2Xi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaXiDaughters"))->Fill(dcaXiDaughters); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaBachToPrimVertex"))->Fill(dcaBachToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiCosOfPointingAngle"))->Fill(XiCosOfPointingAngle); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiRadius"))->Fill(XiRadius); - - //V0 - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassLambdaAsCascDghter"))->Fill(invMassLambdaAsCascDghter); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0Chi2Xi"))->Fill(V0Chi2Xi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0DaughtersXi"))->Fill(dcaV0DaughtersXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0CosOfPointingAngleXi"))->Fill(V0CosOfPointingAngleXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0RadiusXi"))->Fill(V0RadiusXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0ToPrimVertexXi"))->Fill(dcaV0ToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaPosToPrimVertexXi"))->Fill(dcaPosToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaNegToPrimVertexXi"))->Fill(dcaNegToPrimaryVtxXi); - - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0toXiCosOfPointingAngle"))->Fill(V0toXiCosOfPointingAngle); - - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Armenteros"))->Fill(alphaXi, ptArmXi); - - //PID cuts with TPC cuts - if(xi->Charge() < 0){ - if(isPosProtonForTPC - && isNegPionForTPC){ - - switch(fSpecie) { - case 0: - if(isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiMinus); - - //candidate inserting - MakeTrack(invMassXiMinus, XiPt, /*xi->Phi()*/ - phiAfter, xi->Eta(), pTrkXi->GetID(), - nTrkXi->GetID(), bTrkXi->GetID()); - } - break; - - case 1: - if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaMinus); - MakeTrack(invMassOmegaMinus, XiPt, /*xi->Phi()*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - } - break; - } - } - } - - if(xi->Charge() > 0){ - if(isNegProtonForTPC - && isPosPionForTPC){ - - switch (fSpecie){ - case 0: - if(isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiPlus); - - //candidate inserting - MakeTrack(invMassXiPlus, XiPt, /*xi->Phi()*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - } - break; - - case 1: - if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaPlus); - MakeTrack(invMassOmegaPlus, XiPt, /*xi->Phi()*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - } - break; - } - } - } - - } - - return; -} - -//______________________________________________________________________________ -void AliAnalysisTaskFlowCascade::ReadFromAODv0(AliAODEvent *fAOD) -{ - - fCutsRPTPC->SetEvent(fAOD, MCEvent()); - fCutsRPVZE->SetEvent(fAOD, MCEvent()); - fCutsPOI->SetEvent(fAOD, MCEvent()); - fFlowEventTPC->Fill(fCutsRPTPC, fCutsPOI); - fFlowEventVZE->Fill(fCutsRPVZE, fCutsPOI); - - // Double_t trkPrimaryVtxPos[3] = {-100., -100., -100.}; - Double_t bestPrimaryVtxPos[3] = {-100., -100., -100.}; - - Double_t b = fAOD->GetMagneticField(); - - int nCascades=fAOD->GetNumberOfCascades(); - const AliAODVertex *primaryBestAODVtx = fAOD->GetPrimaryVertex(); - primaryBestAODVtx->GetXYZ(bestPrimaryVtxPos); - - // calculation part dedicated to Xi vertices - for(Int_t iXi = 0; iXi < nCascades; iXi++){ - Double_t effMassXi = 0.; - Double_t chi2Xi = -1.; - Double_t dcaXiDaughters = -1.; - Double_t XiCosOfPointingAngle = -1.; - Double_t posXi[3] = {-1000., -1000., -1000.}; - Double_t XiRadius = -1000.; - - Double_t invMassLambdaAsCascDghter = 0.; - Double_t V0Chi2Xi = -1.; - Double_t dcaV0DaughtersXi = -1.; - - Double_t dcaBachToPrimaryVtxXi = -1.; - Double_t dcaV0ToPrimaryVtxXi = -1.; - Double_t dcaPosToPrimaryVtxXi = -1.; - Double_t dcaNegToPrimaryVtxXi = -1.; - Double_t V0CosOfPointingAngleXi = -1.; - Double_t posV0Xi[3] = {-1000., -1000., -1000.}; - Double_t V0RadiusXi = -1000.; - // Double_t V0quality = 0.; - - Double_t invMassXiMinus = 0.; - Double_t invMassXiPlus = 0.; - Double_t invMassOmegaMinus = 0.; - Double_t invMassOmegaPlus = 0.; - - /* - Bool_t isPosInXiProton = kFALSE; - Bool_t isPosInXiPion = kFALSE; - Bool_t isPosInOmegaProton = kFALSE; - Bool_t isPosInOmegaPion = kFALSE; - - Bool_t isNegInXiProton = kFALSE; - Bool_t isNegInXiPion = kFALSE; - Bool_t isNegInOmegaProton = kFALSE; - Bool_t isNegInOmegaPion = kFALSE; - - Bool_t isBachelorKaon = kFALSE; - Bool_t isBachelorPion = kFALSE; - */ - - - Bool_t isBachelorKaonForTPC = kFALSE; - Bool_t isBachelorPionForTPC = kFALSE; - Bool_t isNegPionForTPC = kFALSE; - Bool_t isPosPionForTPC = kFALSE; - Bool_t isNegProtonForTPC = kFALSE; - Bool_t isPosProtonForTPC = kFALSE; - - Double_t XiPx = 0., XiPy = 0., XiPz = 0.; - Double_t XiPt = 0.; - Double_t XiPtot = 0.; - - Double_t bachPx = 0., bachPy = 0., bachPz = 0.; - Double_t bachPt = 0.; - Double_t bachPtot = 0.; - - //Short_t chargeXi = -2; - Double_t V0toXiCosOfPointingAngle = 0.; - - Double_t rapXi = -20.; - Double_t rapOmega = -20.; - Double_t phi = 6.3; - Double_t alphaXi = -200.; - Double_t ptArmXi = -200.; - - Double_t distToVtxZBefore = -999.; - Double_t distToVtxZAfter = -999.; - Double_t distToVtxXYBefore = -999.; - Double_t distToVtxXYAfter = -999.; - Double_t XiPAfter[3] = {-999., -999., -999.}; - Double_t phiAfter = -999.; - - const AliAODcascade *xi = fAOD->GetCascade(iXi); - if (!xi) continue; - - effMassXi = xi->MassXi(); //default working hypothesis: Xi- decay - chi2Xi = xi->Chi2Xi(); - dcaXiDaughters = xi->DcaXiDaughters(); - XiCosOfPointingAngle = xi->CosPointingAngleXi(bestPrimaryVtxPos[0], - bestPrimaryVtxPos[1], - bestPrimaryVtxPos[2]); - posXi[0] = xi->DecayVertexXiX(); - posXi[1] = xi->DecayVertexXiY(); - posXi[2] = xi->DecayVertexXiZ(); - XiRadius = TMath::Sqrt(posXi[0]*posXi[0] - +posXi[1]*posXi[1] - +posXi[2]*posXi[2]); - - AliAODTrack *pTrkXi = dynamic_cast( xi->GetDaughter(0) ); - AliAODTrack *nTrkXi = dynamic_cast( xi->GetDaughter(1) ); - AliAODTrack *bTrkXi - = dynamic_cast( xi->GetDecayVertexXi()->GetDaughter(0) ); - - if(!pTrkXi || !nTrkXi || !bTrkXi) continue; - - UInt_t idxPosXi = (UInt_t) TMath::Abs( pTrkXi->GetID() ); - UInt_t idxNegXi = (UInt_t) TMath::Abs( nTrkXi->GetID() ); - UInt_t idxBach = (UInt_t) TMath::Abs( bTrkXi->GetID() ); - - if(idxBach == idxNegXi || idxBach == idxPosXi) continue; - - if( !fCutsDau->IsSelected(pTrkXi) - || !fCutsDau->IsSelected(nTrkXi) - || !fCutsDau->IsSelected(bTrkXi) ) continue; - - - if(pTrkXi->IsOn(AliESDtrack::kTPCin)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(pTrkXi->P()*pTrkXi->Charge(), pTrkXi->GetTPCsignal()); - } - if( nTrkXi->IsOn(AliESDtrack::kTPCin) ){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(nTrkXi->P()*nTrkXi->Charge(), nTrkXi->GetTPCsignal()); - } - if(bTrkXi->IsOn(AliESDtrack::kTPCin)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(bTrkXi->P()*bTrkXi->Charge(), bTrkXi->GetTPCsignal()); - } - - if(xi->ChargeXi() < 0) - invMassLambdaAsCascDghter = xi->MassLambda(); - else - invMassLambdaAsCascDghter = xi->MassAntiLambda(); - - dcaV0DaughtersXi = xi->DcaV0Daughters(); - V0Chi2Xi = xi->Chi2V0(); - V0CosOfPointingAngleXi - = xi->CosPointingAngle(bestPrimaryVtxPos); - dcaV0ToPrimaryVtxXi = xi->DcaV0ToPrimVertex(); - dcaBachToPrimaryVtxXi = xi->DcaBachToPrimVertex(); - - //V0 - posV0Xi[0] = xi->DecayVertexV0X(); - posV0Xi[1] = xi->DecayVertexV0Y(); - posV0Xi[2] = xi->DecayVertexV0Z(); - V0RadiusXi = TMath::Sqrt(posV0Xi[0]*posV0Xi[0] - +posV0Xi[1]*posV0Xi[1] - +posV0Xi[2]*posV0Xi[2]); - dcaPosToPrimaryVtxXi = xi->DcaPosToPrimVertex(); - dcaNegToPrimaryVtxXi = xi->DcaNegToPrimVertex(); - - //apply cuts ? - // if(XiRadius < 1. || XiRadius > 100.) continue; - //if(dcaXiDaughters > 0.1) continue; - //if(XiCosOfPointingAngle < 0.999) continue; - //if(dcaV0ToPrimaryVtxXi < 0.05) continue; - //if(dcaBachToPrimaryVtxXi < 0.03) continue; - - if(dcaXiDaughters > fCascadeCuts[0]) continue; - if(XiCosOfPointingAngle < fCascadeCuts[1]) continue; - if(dcaV0ToPrimaryVtxXi < fCascadeCuts[2]) continue; - if(dcaBachToPrimaryVtxXi < fCascadeCuts[3]) continue; - - //V0 mass cut? - //if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > 0.006) continue; - if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > fCascadeCuts[7]) - continue; - - //if(dcaV0DaughtersXi > 1.) continue; - //if(V0CosOfPointingAngleXi > 0.9999) continue; - //if(dcaPosToPrimaryVtxXi < 0.1) continue; - //if(dcaNegToPrimaryVtxXi < 0.1) continue; - if(dcaV0DaughtersXi > fCascadeCuts[4]) continue; - if(V0CosOfPointingAngleXi > fCascadeCuts[5]) continue; - if(dcaPosToPrimaryVtxXi < fCascadeCuts[6]) continue; - if(dcaNegToPrimaryVtxXi < fCascadeCuts[6]) continue; - - // if(V0RadiusXi < 1.0 || V0RadiusXi > 100) continue; - - //other cuts? - - - //??? - if(xi->ChargeXi()<0){ - invMassXiMinus = xi->MassXi(); - invMassOmegaMinus = xi->MassOmega(); - }else{ - invMassXiPlus = xi->MassXi(); - invMassOmegaPlus = xi->MassOmega(); - } - - /* - if(pTrkXi->GetMostProbablePID() == AliAODTrack::kProton) { - isPosInXiProton = kTRUE; - isPosInOmegaProton = kTRUE; - } - if(pTrkXi->GetMostProbablePID() == AliAODTrack::kPion){ - isPosInXiPion = kTRUE; - isPosInOmegaPion = kTRUE; - } - - if(nTrkXi->GetMostProbablePID() == AliAODTrack::kPion){ - isNegInXiPion = kTRUE; - isNegInOmegaPion = kTRUE; - } - if(nTrkXi->GetMostProbablePID() == AliAODTrack::kProton){ - isNegInXiProton = kTRUE; - isNegInOmegaProton = kTRUE; - } - - if(bTrkXi->GetMostProbablePID() == AliAODTrack::kPion) - isBachelorPion = kTRUE; - if(bTrkXi->GetMostProbablePID() == AliAODTrack::kKaon) - isBachelorKaon = kTRUE; - */ - - //PID with TPC only: - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kKaon))<3.) - isBachelorKaonForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kPion))<3.) - isBachelorPionForTPC = kTRUE; - - //Negative V0 daughter - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kPion))<3.) - isNegPionForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kProton))<3.) - isNegProtonForTPC = kTRUE; - - //Positive V0 daughter - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kPion))<3.) - isPosPionForTPC = kTRUE; - if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kProton))<3.) - isPosProtonForTPC = kTRUE; - - //Extra QA information - XiPx = xi->MomXiX(); - XiPy = xi->MomXiY(); - XiPz = xi->MomXiZ(); - XiPt = TMath::Sqrt(XiPx*XiPx + XiPy*XiPy); - XiPtot= TMath::Sqrt(XiPx*XiPx + XiPy*XiPy + XiPz*XiPz); - - bachPx = xi->MomBachX(); - bachPy = xi->MomBachY(); - bachPz = xi->MomBachZ(); - - bachPt = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy); - bachPtot = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy + bachPz*bachPz); - - V0toXiCosOfPointingAngle = xi->CosPointingAngle( xi->GetDecayVertexXi() ); - - rapXi = xi->RapXi(); - rapOmega = xi->RapOmega(); - phi = xi->Phi(); - alphaXi = xi->AlphaXi(); - ptArmXi = xi->PtArmXi(); - - distToVtxZBefore = posXi[2]-bestPrimaryVtxPos[2]; - distToVtxXYBefore - = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) - *(posXi[0] - bestPrimaryVtxPos[0]) - +(posXi[1] - bestPrimaryVtxPos[1]) - *(posXi[1] - bestPrimaryVtxPos[1])); - - - XiPAfter[0] = XiPx; - XiPAfter[1] = XiPy; - XiPAfter[2] = XiPz; - //propagation to the best primary vertex to determine the momentum - Propagate(bestPrimaryVtxPos, posXi, XiPAfter, b, xi->ChargeXi()); - distToVtxZAfter = posXi[2] - bestPrimaryVtxPos[2]; - distToVtxXYAfter = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) - *(posXi[0] - bestPrimaryVtxPos[0]) - +(posXi[1] - bestPrimaryVtxPos[1]) - *(posXi[1] - bestPrimaryVtxPos[1])); - phiAfter = TMath::Pi() + TMath::ATan2(-XiPAfter[1],-XiPAfter[0]); - - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZAfter"))->Fill(distToVtxZAfter); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYAfter"))->Fill(distToVtxXYAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZBeforeVsAfter"))->Fill(distToVtxZBefore, distToVtxZAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYBeforeVsAfter"))->Fill(distToVtxXYBefore, distToVtxXYAfter); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PxBeforeVsAfter"))->Fill(XiPx, XiPAfter[0]); - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PyBeforeVsAfter"))->Fill(XiPy, XiPAfter[1]); - if(xi->ChargeXi()>0) - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiPosBeforeVsAfter"))->Fill(phi, phiAfter); - else if(xi->ChargeXi()<0) - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiNegBeforeVsAfter"))->Fill(phi, phiAfter); - - //for default hypothesis - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Chi2Xi"))->Fill(chi2Xi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaXiDaughters"))->Fill(dcaXiDaughters); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaBachToPrimVertex"))->Fill(dcaBachToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiCosOfPointingAngle"))->Fill(XiCosOfPointingAngle); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiRadius"))->Fill(XiRadius); - - //V0 - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassLambdaAsCascDghter"))->Fill(invMassLambdaAsCascDghter); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0Chi2Xi"))->Fill(V0Chi2Xi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0DaughtersXi"))->Fill(dcaV0DaughtersXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0CosOfPointingAngleXi"))->Fill(V0CosOfPointingAngleXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0RadiusXi"))->Fill(V0RadiusXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0ToPrimVertexXi"))->Fill(dcaV0ToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaPosToPrimVertexXi"))->Fill(dcaPosToPrimaryVtxXi); - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaNegToPrimVertexXi"))->Fill(dcaNegToPrimaryVtxXi); - - ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0toXiCosOfPointingAngle"))->Fill(V0toXiCosOfPointingAngle); - - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Armenteros"))->Fill(alphaXi, ptArmXi); - - //with PID cuts - if(xi->ChargeXi()<0){ - if(isPosProtonForTPC && isNegPionForTPC){ - switch (fSpecie){ - case 0: - if( isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiMinus); - MakeTrack(invMassXiMinus, XiPt, /*xi->Phi(),*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - }// endif - - break; - - case 1: - if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8 - && (invMassXiMinus > 1.32486 || invMassXiMinus < 1.30486)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaMinus); - - MakeTrack(invMassOmegaMinus, XiPt, /* xi->Phi(),*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - }//endif - break; - } - } - }//end if ChargeXi()<0 - - if(xi->ChargeXi() > 0){ - if(isNegProtonForTPC && isPosPionForTPC){ - switch(fSpecie){ - case 0: - if (isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiPlus); - - //candidate inserting - MakeTrack(invMassXiPlus, XiPt, /* xi->Phi(),*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - }//endif particle id - break; - - case 1: - if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8 - && (invMassXiPlus > 1.32486 || invMassXiPlus < 1.30486)){ - ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaPlus); - MakeTrack(invMassOmegaPlus, XiPt, /* xi->Phi(),*/ - phiAfter, xi->Eta(), - pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); - }//endif particle id - } - } - }//endif ChargeXi()>0 - }//for Xi candidate loop - - return; - -} - - -void AliAnalysisTaskFlowCascade::MakeTrack( double mass, - double pt, - double phi, - double eta, - int iid, - int jid, - int kid) { - // create track for flow tasks - if(fCandidates->GetLast()+1>=fCandidates->GetSize()) { - fCandidates->Expand( 2*fCandidates->GetSize() ); - } - Bool_t overwrite = kTRUE; - - AliFlowCandidateTrack *sTrack - = (static_cast (fCandidates->At( fCandidates->GetLast()+1 ))); - if( !sTrack ) { // creates new - sTrack = new AliFlowCandidateTrack(); - overwrite = kFALSE; - } else { // overwrites - sTrack->ClearMe(); - } - - - sTrack->SetMass(mass); - sTrack->SetPt(pt); - sTrack->SetPhi(phi); - sTrack->SetEta(eta); - sTrack->AddDaughter(iid); - sTrack->AddDaughter(jid); - sTrack->AddDaughter(kid); - sTrack->SetForPOISelection(kTRUE); - sTrack->SetForRPSelection(kFALSE); - - if(overwrite) { - fCandidates->SetLast( fCandidates->GetLast()+1 ); - } else { - fCandidates->AddLast(sTrack); - } - - return; -} -//_____________________________________________________________________________ -void AliAnalysisTaskFlowCascade::Terminate(Option_t *) -{ - -} - -void AliAnalysisTaskFlowCascade::Propagate(Double_t vv[3], - Double_t x[3], - Double_t p[3], - Double_t bz, - Short_t sign){ - //Propagation to the primary vertex to determine the px and py - //x, p are the position and momentum as input and output - //bz is the magnetic field along z direction - //sign is the charge of particle for propagation - - Double_t pp = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]); - Double_t len = (vv[2]-x[2])*pp/p[2]; - Double_t a = -kB2C*bz*sign; - - Double_t rho = a/pp; - x[0] += p[0]*TMath::Sin(rho*len)/a - p[1]*(1-TMath::Cos(rho*len))/a; - x[1] += p[1]*TMath::Sin(rho*len)/a + p[0]*(1-TMath::Cos(rho*len))/a; - x[2] += p[2]*len/pp; - - Double_t p0=p[0]; - p[0] = p0 *TMath::Cos(rho*len) - p[1]*TMath::Sin(rho*len); - p[1] = p[1]*TMath::Cos(rho*len) + p0 *TMath::Sin(rho*len); -} - - -//===================================================================== -void AliAnalysisTaskFlowCascade::SetCommonConstants(Int_t massBins, - Double_t minMass, - Double_t maxMass) -{ - // setter for mass bins - - fMassBins = massBins; - fMinMass = minMass; - fMaxMass = maxMass; -} - - -//==================================================================== -void AliAnalysisTaskFlowCascade::SetCuts2010(int set) { - - // fCascadeCuts[0]: DcaXiDaughter; fCascadeCuts[1]: XiCosOfPointingAngle - // fCascadeCuts[2]: DcaV0ToPrimaryVtxXi; fCascadeCuts[3]: DcaBachToPrimaryVtxXi - // fCascadeCuts[4]: DcaV0DaughersXi; fCascadeCuts[5]: V0CosOfPointingAngleXi - // fCascadeCuts[6]: DcaV0DaughterToPrimaryVtxXi; fCascadeCuts[7]: V0MassWidth - - switch(set){ - - case 0: //tighter - fCascadeCuts[0] = 0.2; fCascadeCuts[1] = 0.999; - fCascadeCuts[2] = 0.03; fCascadeCuts[3] = 0.05; - fCascadeCuts[4] = .5; fCascadeCuts[5] = 0.9998; - fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.006; - break; - - case 1: //middle - fCascadeCuts[0] = 0.3; fCascadeCuts[1] = 0.99; - fCascadeCuts[2] = 0.01; fCascadeCuts[3] = 0.03; - fCascadeCuts[4] = .6; fCascadeCuts[5] = 0.9999; - fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.008; - break; - - case 2: //looser - fCascadeCuts[0] = 0.3; fCascadeCuts[1] = 0.99; - fCascadeCuts[2] = 0.01; fCascadeCuts[3] = 0.03; - fCascadeCuts[4] = 1.; fCascadeCuts[5] = 1.; - fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.01; - break; - } - -} +/************************************************************************** +* Copyright(c) 1998-2008,ALICE Experiment at CERN,All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use,copy,modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee,provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +///////////////////////////////////////////////////// +// AliAnalysisTaskFlowCascade: +// Analysis task to select Xi and Omega candidates for flow analysis. +// +// Author: Zhong-Bao.Yin@cern.ch +////////////////////////////////////////////////////// + +#include "TChain.h" +#include "TList.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TH3D.h" +#include "TProfile.h" +#include "TVector3.h" + +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" + +#include "AliVParticle.h" +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" +#include "AliESDv0.h" +#include "AliESDcascade.h" +#include "AliESDtrack.h" +#include "AliESDtrackCuts.h" +#include "AliCentrality.h" +#include "AliVVertex.h" +#include "AliESDVZERO.h" +#include "AliESDUtils.h" + +#include "AliTPCPIDResponse.h" +#include "AliTOFPIDResponse.h" +#include "AliPIDResponse.h" + +#include "AliAODEvent.h" +#include "AliAODInputHandler.h" +#include "AliAODTrack.h" +#include "AliAODVZERO.h" +#include "AliAODcascade.h" + +#include "TMath.h" +#include "TObjArray.h" +#include "AliFlowCandidateTrack.h" + +#include "AliFlowTrackCuts.h" +#include "AliFlowEventCuts.h" +#include "AliFlowEvent.h" +#include "AliFlowCommonConstants.h" + +#include "AliAnalysisTaskFlowCascade.h" + +ClassImp(AliAnalysisTaskFlowCascade) + +//_____________________________________________________________________________ + AliAnalysisTaskFlowCascade::AliAnalysisTaskFlowCascade() : + AliAnalysisTaskSE(), + // fMinCent(0), fMaxCent(0), + fSpecie(0), + fMassBins(0), + fMinMass(0.0), + fMaxMass(0.0), + fCutsEvent(NULL), + fCutsRPTPC(NULL), + fCutsRPVZE(NULL), + fCutsPOI(NULL), + fCutsDau(NULL), + fPIDResponse(NULL), + fFlowEventTPC(NULL), + fFlowEventVZE(NULL), + fCandidates(NULL), + fQAList(NULL) +{ + //ctor + for (Int_t i=0; i!=8; ++i) + fCascadeCuts[i] = 0; + +} + +//_____________________________________________________________________________ +AliAnalysisTaskFlowCascade +::AliAnalysisTaskFlowCascade(const char *name, + AliFlowEventCuts *cutsEvent, + AliFlowTrackCuts *cutsRPTPC, + AliFlowTrackCuts *cutsRPVZE, + /* AliESDtrackCuts */ AliFlowTrackCuts *cutsDau ) : + AliAnalysisTaskSE(name), + //fMinCent(minCent), fMaxCent(maxCent), + fSpecie(0), + fMassBins(0), + fMinMass(0.0), + fMaxMass(0.0), + fCutsEvent(cutsEvent), + fCutsRPTPC(cutsRPTPC), + fCutsRPVZE(cutsRPVZE), + fCutsPOI(NULL), + fCutsDau(cutsDau), + fPIDResponse(NULL), + fFlowEventTPC(NULL), + fFlowEventVZE(NULL), + fCandidates(NULL), + fQAList(NULL) +{ + //ctor + for (Int_t i=0; i!=8; ++i) + fCascadeCuts[i] = 0; + + DefineInput( 0,TChain::Class()); + DefineOutput(1,AliFlowEventSimple::Class()); // TPC object + DefineOutput(2,AliFlowEventSimple::Class()); // VZE object + DefineOutput(3,TList::Class()); +} + +//_____________________________________________________________________________ +AliAnalysisTaskFlowCascade::~AliAnalysisTaskFlowCascade() +{ + if(fQAList) delete fQAList; + if (fFlowEventTPC) delete fFlowEventTPC; + if (fFlowEventVZE) delete fFlowEventVZE; + if (fCandidates) delete fCandidates; + if (fCutsDau) delete fCutsDau; + if (fCutsPOI) delete fCutsPOI; + if (fCutsRPTPC) delete fCutsRPTPC; + if (fCutsRPVZE) delete fCutsRPVZE; +} + +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::UserCreateOutputObjects() +{ + + AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); + AliInputEventHandler* inputHandler + = (AliInputEventHandler*) (man->GetInputEventHandler()); + fPIDResponse = inputHandler->GetPIDResponse(); + + fQAList = new TList(); + fQAList->SetOwner(); + AddQAEvents(); + AddQACandidates(); + // PostData(3,fQAList); + + AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster(); + cc->SetNbinsMult(1); + cc->SetMultMin(0); + cc->SetMultMax(1); + + cc->SetNbinsPt(20); + cc->SetPtMin(0.0); + cc->SetPtMax(10.0); + + cc->SetNbinsPhi(1); + cc->SetPhiMin(0.0); + cc->SetPhiMax(TMath::TwoPi()); + + cc->SetNbinsEta(1); + cc->SetEtaMin(-2.0); + cc->SetEtaMax(+2.0); + + cc->SetNbinsQ(3); + cc->SetQMin(0.0); + cc->SetQMax(3.0); + + cc->SetNbinsMass(fMassBins); + cc->SetMassMin(fMinMass); + cc->SetMassMax(fMaxMass); + + fCutsPOI = new AliFlowTrackCuts("null_cuts"); + fCutsPOI->SetParamType(fCutsRPTPC->GetParamType()); + fCutsPOI->SetPtRange(+1,-1); // select nothing QUICK + fCutsPOI->SetEtaRange(+1,-1); // select nothing VZERO + + fFlowEventTPC = new AliFlowEvent(3000); + fFlowEventVZE = new AliFlowEvent(1000); + fCandidates = new TObjArray(100); + fCandidates->SetOwner(); + + PostData(1,fFlowEventTPC); + PostData(2,fFlowEventVZE); + PostData(3,fQAList); +} + +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::AddQAEvents() +{ + TList *tQAEvents = new TList(); + tQAEvents->SetName("Events"); + tQAEvents->SetOwner(); + TH1I* tEvent = new TH1I("Event","Number of Events", 3,0,3); + tQAEvents->Add(tEvent); + + TH1D *tTPCRFP = new TH1D("RFPTPC", + "TPC Reference Flow Particles;multiplicity", + 100, 0, 3000); + tQAEvents->Add(tTPCRFP); + TH1D *tVZERFP = new TH1D("RFPVZE", + "VZERO Reference Flow Particles;multiplicity", + 100, 0, 30000); + tQAEvents->Add(tVZERFP); + + TProfile *tCuts = new TProfile("Cuts","Analysis Cuts",10,0,10); + tCuts->Fill(0.5,fCascadeCuts[0],1); + tCuts->GetXaxis()->SetBinLabel(1,"dcaXiDau"); + tCuts->Fill(1.5,fCascadeCuts[1],1); + tCuts->GetXaxis()->SetBinLabel(2,"XiCPA"); + tCuts->Fill(2.5,fCascadeCuts[2],1); + tCuts->GetXaxis()->SetBinLabel(3,"dcaV0Vtx"); + tCuts->Fill(3.5,fCascadeCuts[3],1); + tCuts->GetXaxis()->SetBinLabel(4,"dcaBachVtx"); + tCuts->Fill(4.5,fCascadeCuts[4],1); + tCuts->GetXaxis()->SetBinLabel(5,"dcaV0Dau"); + tCuts->Fill(5.5,fCascadeCuts[5],1); + tCuts->GetXaxis()->SetBinLabel(6,"V0CPA"); + tCuts->Fill(6.5,fCascadeCuts[6],1); + tCuts->GetXaxis()->SetBinLabel(7,"dcaV0DauVtx"); + tCuts->Fill(7.5,fCascadeCuts[7],1); + tCuts->GetXaxis()->SetBinLabel(8,"V0Mass"); + tQAEvents->Add(tCuts); + + fQAList->Add(tQAEvents); +} + +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::AddQACandidates() +{ + TList *tQACandidates; + + tQACandidates = new TList(); + tQACandidates->SetOwner(); + tQACandidates->SetName("Candidates"); + + TH1F* tChi2Xi = new TH1F("Chi2Xi", + "Cascade #chi^{2}; #chi^{2}; Number of Cascades", + 160, 0, 160); + tQACandidates->Add(tChi2Xi); + + TH1F* tDCAXiDaughters + = new TH1F( "DcaXiDaughters", + "DCA between Xi Daughters; DCA (cm); Number of Cascades", + 100, 0., 0.5); + tQACandidates->Add(tDCAXiDaughters); + + TH1F * tDCABachToPrimVertex + = new TH1F("DcaBachToPrimVertex", + "DCA of Bach. to Prim. Vertex; DCA (cm);Number of Cascades", + 250, 0., 2.5); + tQACandidates->Add(tDCABachToPrimVertex); + + TH1F * tXiCosOfPointingAngle + = new TH1F("XiCosOfPointingAngle", + "Cos of Xi Pointing Angle; Cos (Xi Point.Angl);Number of Xis", + 200, 0.99, 1.0); + tQACandidates->Add(tXiCosOfPointingAngle); + + TH1F * tXiRadius = new TH1F("XiRadius", + "Casc. decay transv. radius; r (cm); Counts" , + 1050, 0., 105.0 ); + tQACandidates->Add(tXiRadius); + + TH1F *tMassLambda + = new TH1F("MassLambdaAsCascDghter", + "#Lambda assoc. to Casc. candidates; Eff. Mass (GeV/c^{2}); Counts", + 300,1.00,1.3); + tQACandidates->Add(tMassLambda); + + TH1F *tV0Chi2 = new TH1F("V0Chi2Xi", + "V0 #chi^{2}, in cascade; #chi^{2};Counts", + 160, 0, 40); + tQACandidates->Add(tV0Chi2); + + TH1F * tV0CosOfPointingAngle + = new TH1F("V0CosOfPointingAngleXi", + "Cos of V0 Pointing Angle, in cascade;Cos(V0 Point. Angl); Counts", + 200, 0.98, 1.0); + tQACandidates->Add(tV0CosOfPointingAngle); + + TH1F *tV0Radius = new TH1F("V0RadiusXi", + "V0 decay radius, in cascade; radius (cm); Counts", + 1050, 0., 105.0); + tQACandidates->Add(tV0Radius); + + TH1F * tDcaV0DaughtersXi + = new TH1F("DcaV0DaughtersXi", + "DCA between V0 daughters, in cascade;DCA (cm);Number of V0s", + 120, 0., 0.6); + tQACandidates->Add(tDcaV0DaughtersXi); + + TH1F * tDcaV0ToPrimVertex + = new TH1F("DcaV0ToPrimVertexXi", + "DCA of V0 to Prim. Vertex, in cascade;DCA (cm);Number of Cascades", 200, 0., 1.); + tQACandidates->Add(tDcaV0ToPrimVertex); + + TH1F * tDCAPosToPrimVertex = + new TH1F("DcaPosToPrimVertexXi", + "DCA of V0 pos daughter to Prim. Vertex;DCA (cm);Counts", + 300, 0, 3); + tQACandidates->Add(tDCAPosToPrimVertex); + + TH1F * tDCANegToPrimVertex + = new TH1F("DcaNegToPrimVertexXi", + "DCA of V0 neg daughter to Prim. Vertex;DCA (cm);Counts", + 300, 0, 3); + tQACandidates->Add(tDCANegToPrimVertex); + + TH1F *tV0toXiCosOfPointingAngle + = new TH1F("V0toXiCosOfPointingAngle", + "Cos. of V0 Ptng Angl Xi vtx; Cos(V0 Point. Angl / Xi vtx); Counts", + 100, 0.99, 1.0); + tQACandidates->Add(tV0toXiCosOfPointingAngle); + + TH2F *th2Armenteros + = new TH2F("Armenteros", + "#alpha_{Arm}(casc. cand.) Vs Pt_{Arm}(casc. cand.); #alpha_{Arm} ; Pt_{Arm} (GeV/c)", + 140, -1.2, 1.2, 300, 0., 0.3); + tQACandidates->Add(th2Armenteros); + + TH2F *th2TPCdEdxOfCascDghters + = new TH2F( "TPCdEdxOfCascDghters", + "TPC dE/dx of the cascade daughters; charge x || #vec{p}_{TPC inner wall}(Casc. daughter) || (GeV/c); TPC signal (ADC) ", + 200, -10.0, 10.0, 450, 0., 900.); + tQACandidates->Add(th2TPCdEdxOfCascDghters); + + TH2F *th2MassVsPtAll + = new TH2F("MassVsPtAll", + "M_{candidates} vs Pt; Pt (GeV/c); M (GeV/c^{2})", + 100, 0., 10., fMassBins, fMinMass, fMaxMass); + tQACandidates->Add(th2MassVsPtAll); + + TH1F *tDistToVtxZAfter + = new TH1F("DistToVtxZAfter", + "Distance to vtx z after propagation to vtx; z [cm]", + 100, -5., 5.); + tQACandidates->Add(tDistToVtxZAfter); + + TH1F * tDistToVtxXYAfter + = new TH1F("DistToVtxXYAfter", + "Distance to vtx xy after propagation to vtx", + 500, 0., 50.); + tQACandidates->Add(tDistToVtxXYAfter); + + TH2F *th2DistToVtxZBeforeVsAfter + = new TH2F("DistToVtxZBeforeVsAfter", + "Distance to vtx z before vs after propagation; Distance before [cm]; Distance after [cm]", + 500, -50., 50., 100, -5., 5.); + tQACandidates->Add(th2DistToVtxZBeforeVsAfter); + + TH2F *th2DistToVtxXYBeforeVsAfter + = new TH2F("DistToVtxXYBeforeVsAfter", + "Distance to vtx xy before vs after propagation; Distance before [cm]; Distance after [cm]", + 500, 0., 50, 500, 0., 50); + tQACandidates->Add(th2DistToVtxXYBeforeVsAfter); + + TH2F * th2PxBeforeVsAfter + = new TH2F("PxBeforeVsAfter", + "Px before vs after propagation; Px [GeV/c]; Px' [GeV/c]", + 200, -10., 10, 200, -10., 10.); + tQACandidates->Add(th2PxBeforeVsAfter); + + TH2F * th2PyBeforeVsAfter + = new TH2F("PyBeforeVsAfter", + "Py before vs after propagation; Py [GeV/c]; Py' [GeV/c]", + 200, -10., 10, 200, -10., 10.); + tQACandidates->Add(th2PyBeforeVsAfter); + + TH2F * th2PhiPosBeforeVsAfter + = new TH2F("PhiPosBeforeVsAfter", + "Phi for positively charged candidates before vs after propagation; #phi; #phi'", + 360, 0., 2.0*TMath::Pi(), 360, 0., 2.0*TMath::Pi()); + tQACandidates->Add(th2PhiPosBeforeVsAfter); + + TH2F *th2PhiNegBeforeVsAfter + = new TH2F("PhiNegBeforeVsAfter", + "Phi for negatively charged candidates before vs after propagation; #phi; #phi'", + 360, 0., 2.0*TMath::Pi(), 360, 0., 2.0*TMath::Pi()); + tQACandidates->Add(th2PhiNegBeforeVsAfter); + + fQAList->Add(tQACandidates); +} + +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::NotifyRun() +{ +} +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::UserExec(Option_t *) +{ + AliESDEvent *fESD = dynamic_cast(InputEvent()); + AliAODEvent *fAOD = dynamic_cast(InputEvent()); + Bool_t acceptEvent=kFALSE; + fCandidates->SetLast(-1); + + if(fESD) { + // recorrecting VZERO (for pass 1 only) + /* + Float_t *vChCorr = new Float_t[64]; + Float_t dummy; + AliESDUtils::GetCorrV0(fESD,dummy,NULL,vChCorr); + AliESDVZERO *vzero = (AliESDVZERO*) fESD->GetVZEROData(); + vzero->SetMultiplicity( vChCorr ); + delete [] vChCorr; + */ + // + + ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(0); + + const AliVVertex *vtxGlb = fESD->GetPrimaryVertexTracks(); + const AliVVertex *vtxSPD = fESD->GetPrimaryVertexSPD(); + if(!vtxGlb || !vtxSPD) return; + if( fCutsEvent->IsSelected(fESD, 0) && (TMath::Abs(vtxSPD->GetZ()-vtxGlb->GetZ()) <= 0.5) ) { + acceptEvent = kTRUE; + ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); + ReadFromESDv0(fESD); + } + } else if(fAOD) { + const AliVVertex *vtxGlb = fAOD->GetPrimaryVertex(); + const AliVVertex *vtxSPD = fAOD->GetPrimaryVertexSPD(); + if(!vtxGlb || !vtxSPD) return; + + ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(0); + + if(fCutsEvent->IsSelected(fAOD, 0) && (TMath::Abs(vtxSPD->GetZ()-vtxGlb->GetZ()) <= 0.5) ) { + acceptEvent = kTRUE; + ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); + ReadFromAODv0(fAOD); + } + + + /* + + AliAODHeader *aodHeader = fAOD->GetHeader(); + if(!aodHeader) return; + AliCentrality *centrality = aodHeader->GetCentralityP(); + if(!centrality) return; + Double_t cent = centrality->GetCentralityPercentile("V0M" ); + Double_t cent1 = centrality->GetCentralityPercentile("TRK" ); + if(TMath::Abs(cent-cent1) >= 5.) return; + + if(cent=fMaxCent) return; //centrality cut + + Double_t zvtx = fAOD->GetPrimaryVertex()->GetZ(); + if(TMath::Abs(zvtx)>10.) return; //vertex cut + + ((TH1I*)((TList*)fQAList->FindObject("Events"))->FindObject("Event"))->Fill(2); + ReadFromAODv0(fAOD); + */ + } + + if(!acceptEvent) return; + + ((TH1D*)((TList*)fQAList->FindObject("Events"))->FindObject("RFPTPC")) + ->Fill(fFlowEventTPC->GetNumberOfRPs() ); + Double_t mult=0; + for(Int_t i=0; i != fFlowEventVZE->GetNumberOfRPs(); ++i) { + AliFlowTrackSimple *pTrack = fFlowEventVZE->GetTrack(i); + mult += pTrack->Weight(); + } + ((TH1D*)((TList*)fQAList->FindObject("Events"))->FindObject("RFPVZE")) + ->Fill( mult ); + + // if(fDebug) printf("TPCevent %d | VZEevent %d\n", + // fFlowEventTPC->NumberOfTracks(), + // fFlowEventVZE->NumberOfTracks() ); + AddCandidates(); + + PostData(1,fFlowEventTPC); + PostData(2,fFlowEventVZE); + PostData(3,fQAList); + + return; +} + +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::AddCandidates(){ + + // if(fDebug) printf("I received %d candidates\n", + // fCandidates->GetEntriesFast()); + for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) { + AliFlowCandidateTrack *cand + = dynamic_cast(fCandidates->At(iCand)); + if(!cand) continue; + // if(fDebug) + // printf(" >Checking at candidate %d with %d daughters: mass %f\n", + // iCand, cand->GetNDaughters(), cand->Mass()); + + // untagging ===> + for(int iDau=0; iDau != cand->GetNDaughters(); ++iDau) { + // if(fDebug) + // printf(" >Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau)); + for(int iRPs=0; iRPs != fFlowEventTPC->NumberOfTracks(); ++iRPs ) { + AliFlowTrack *iRP + = dynamic_cast(fFlowEventTPC->GetTrack( iRPs )); + if (!iRP) continue; + if( !iRP->InRPSelection() ) continue; + if( cand->GetIDDaughter(iDau) == iRP->GetID() ) { + //if(fDebug) printf(" was in RP set"); + iRP->SetForRPSelection(kFALSE); + fFlowEventTPC->SetNumberOfRPs( fFlowEventTPC->GetNumberOfRPs() -1 ); + } + } + //if(fDebug) printf("\n"); + } + // <=== untagging + cand->SetForPOISelection(kTRUE); + fFlowEventTPC->InsertTrack( ((AliFlowTrack*) cand) ); + fFlowEventVZE->InsertTrack( ((AliFlowTrack*) cand) ); + } + + // if(fDebug) printf("TPCevent %d | VZEevent %d\n", + // fFlowEventTPC->NumberOfTracks(), + // fFlowEventVZE->NumberOfTracks() ); + +} + +//______________________________________________________________________________ +void AliAnalysisTaskFlowCascade::ReadFromESDv0(AliESDEvent *fESD) +{ + //AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("null_cuts"); + //cutsPOI->SetParamType( fCutsRP->GetParamType() ); + //cutsPOI->SetParamType( AliFlowTrackCuts::kGlobal ); + // cutsPOI->SetPtRange(+1,-1); // select nothing + //cutsPOI->SetEtaRange(+1,-1); // select nothing VZERO + + fCutsRPTPC->SetEvent(fESD,MCEvent()); + fCutsRPVZE->SetEvent(fESD,MCEvent()); + + fCutsPOI->SetEvent(fESD,MCEvent()); + + fFlowEventTPC->Fill(fCutsRPTPC,fCutsPOI); + fFlowEventVZE->Fill(fCutsRPVZE,fCutsPOI); + + Double_t trkPrimaryVtxPos[3] = {-100., -100., -100.}; + Double_t bestPrimaryVtxPos[3] = {-100., -100., -100.}; + int nCascades=fESD->GetNumberOfCascades(); + + const AliESDVertex *primaryTrackingESDVtx = fESD->GetPrimaryVertexTracks(); + primaryTrackingESDVtx->GetXYZ(trkPrimaryVtxPos); + + const AliESDVertex *primaryBestESDVtx = fESD->GetPrimaryVertex(); + primaryBestESDVtx->GetXYZ(bestPrimaryVtxPos); + + Double_t b = fESD->GetMagneticField(); + + for(int i = 0; i != nCascades; ++i) { + + // Double_t trkPrimaryVtxRadius3D = -500.; + // Double_t bestPrimaryVtxRadius3D = -500.; + Double_t effMassXi = 0.; + Double_t chi2Xi = -1.; + Double_t dcaXiDaughters = -1.; + Double_t XiCosOfPointingAngle = -1.; + Double_t posXi[3] = {-1000., -1000., -1000.}; + Double_t XiRadius = -1000.; + + // Double_t innerWallMomCascDghters[3] = {-100., -100., -100.}; + //Double_t tpcSignalCascDghters[3] = {-100., -100., -100.}; + + Double_t invMassLambdaAsCascDghter = 0.; + Double_t V0Chi2Xi = -1.; + Double_t dcaV0DaughtersXi = -1.; + + Double_t dcaBachToPrimaryVtxXi = -1.; + Double_t dcaV0ToPrimaryVtxXi = -1.; + Double_t dcaPosToPrimaryVtxXi = -1.; + Double_t dcaNegToPrimaryVtxXi = -1.; + Double_t V0CosOfPointingAngleXi = -1.; + Double_t posV0Xi[3] = {-1000., -1000., -1000.}; + Double_t V0RadiusXi = -1000.; + Double_t V0quality = 0.; + + Double_t invMassXiMinus = 0.; + Double_t invMassXiPlus = 0.; + Double_t invMassOmegaMinus = 0.; + Double_t invMassOmegaPlus = 0.; + + /* + Bool_t isPosInXiProton = kFALSE; + Bool_t isPosInXiPion = kFALSE; + Bool_t isPosInOmegaProton = kFALSE; + Bool_t isPosInOmegaPion = kFALSE; + + Bool_t isNegInXiProton = kFALSE; + Bool_t isNegInXiPion = kFALSE; + Bool_t isNegInOmegaProton = kFALSE; + Bool_t isNegInOmegaPion = kFALSE; + + Bool_t isBachelorKaon = kFALSE; + Bool_t isBachelorPion = kFALSE; + */ + + Bool_t isBachelorKaonForTPC = kFALSE; + Bool_t isBachelorPionForTPC = kFALSE; + Bool_t isNegPionForTPC = kFALSE; + Bool_t isPosPionForTPC = kFALSE; + Bool_t isNegProtonForTPC = kFALSE; + Bool_t isPosProtonForTPC = kFALSE; + + Double_t XiPx = 0., XiPy = 0., XiPz = 0.; + Double_t XiPt = 0.; + Double_t XiPtot = 0.; + + Double_t bachPx = 0., bachPy = 0., bachPz = 0.; + Double_t bachPt = 0.; + Double_t bachPtot = 0.; + + //Short_t chargeXi = -2; + Double_t V0toXiCosOfPointingAngle = 0.; + + Double_t rapXi = -20.; + Double_t rapOmega = -20.; + Double_t phi = 6.3; + Double_t alphaXi = -200.; + Double_t ptArmXi = -200.; + // TLorentzVector lv1, lv2, lv3, lv12, lvXi; + + Double_t distToVtxZBefore = -999.; + Double_t distToVtxZAfter = -999.; + Double_t distToVtxXYBefore = -999.; + Double_t distToVtxXYAfter = -999.; + Double_t XiPAfter[3] = {-999., -999., -999.}; + Double_t phiAfter = -999.; + + AliESDcascade *xi = fESD->GetCascade(i); + if(!xi) continue; + + if(xi->Charge()<0) + xi->ChangeMassHypothesis(V0quality, 3312); // Xi- hypothesis + else if(xi->Charge() > 0) + xi->ChangeMassHypothesis(V0quality, -3312); + else continue; + + effMassXi = xi->GetEffMassXi(); + chi2Xi = xi->GetChi2Xi(); + dcaXiDaughters = xi->GetDcaXiDaughters(); + XiCosOfPointingAngle + = xi->GetCascadeCosineOfPointingAngle(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2]); + xi->GetXYZcascade(posXi[0], posXi[1], posXi[2]); + XiRadius = TMath::Sqrt(posXi[0]*posXi[0] + +posXi[1]*posXi[1] + +posXi[2]*posXi[2]); + + UInt_t idxPosXi = (UInt_t)TMath::Abs(xi->GetPindex()); + UInt_t idxNegXi = (UInt_t)TMath::Abs(xi->GetNindex()); + UInt_t idxBach = (UInt_t)TMath::Abs(xi->GetBindex()); + + if(idxBach == idxPosXi || idxBach == idxNegXi) continue; + + AliESDtrack *pTrkXi = fESD->GetTrack(idxPosXi); + AliESDtrack *nTrkXi = fESD->GetTrack(idxNegXi); + AliESDtrack *bTrkXi = fESD->GetTrack(idxBach); + + if( !pTrkXi || !nTrkXi || !bTrkXi ) continue; + + if( !fCutsDau->IsSelected(pTrkXi) + || !fCutsDau->IsSelected(nTrkXi) + || !fCutsDau->IsSelected(bTrkXi) ) continue; + + const AliExternalTrackParam *pExtTrk = pTrkXi->GetInnerParam(); + const AliExternalTrackParam *nExtTrk = nTrkXi->GetInnerParam(); + const AliExternalTrackParam *bExtTrk = bTrkXi->GetInnerParam(); + + if(pExtTrk && pTrkXi->IsOn(AliESDtrack::kTPCin)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(pExtTrk->GetP()*pExtTrk->Charge(), pTrkXi->GetTPCsignal()); + } + if(nExtTrk && nTrkXi->IsOn(AliESDtrack::kTPCin)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(nExtTrk->GetP()*nExtTrk->Charge(), nTrkXi->GetTPCsignal()); + } + if(bExtTrk && bTrkXi->IsOn(AliESDtrack::kTPCin)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(bExtTrk->GetP()*bExtTrk->Charge(), bTrkXi->GetTPCsignal()); + } + + invMassLambdaAsCascDghter = xi->GetEffMass(); // from V0 + dcaV0DaughtersXi = xi->GetDcaV0Daughters(); + V0Chi2Xi = xi->GetChi2V0(); + V0CosOfPointingAngleXi + = xi->GetV0CosineOfPointingAngle(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2]); + dcaV0ToPrimaryVtxXi = xi->GetD(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2]); + dcaBachToPrimaryVtxXi = TMath::Abs(bTrkXi->GetD(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2])); + + //V0 + xi->GetXYZ(posV0Xi[0], posV0Xi[1], posV0Xi[2]); + V0RadiusXi = TMath::Sqrt(posV0Xi[0]*posV0Xi[0] + +posV0Xi[1]*posV0Xi[1] + +posV0Xi[2]*posV0Xi[2]); + dcaPosToPrimaryVtxXi = TMath::Abs(pTrkXi->GetD(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2])); + dcaNegToPrimaryVtxXi = TMath::Abs(nTrkXi->GetD(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2])); + + //apply cuts + //if(XiRadius < 0.9 || XiRadius > 100.) continue; + //if(dcaXiDaughters > 0.2) continue; + //if(XiCosOfPointingAngle < 0.99) continue; + //if(dcaV0ToPrimaryVtxXi < 0.03) continue; + //if(dcaBachToPrimaryVtxXi < 0.01) continue; + + if(dcaXiDaughters > fCascadeCuts[0]) continue; + if(XiCosOfPointingAngle < fCascadeCuts[1]) continue; + if(dcaV0ToPrimaryVtxXi < fCascadeCuts[2]) continue; + if(dcaBachToPrimaryVtxXi < fCascadeCuts[3]) continue; + + //V0 mass cut? + // if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > 0.01) continue; + if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > fCascadeCuts[7]) + continue; + + //if(dcaV0DaughtersXi > 1.) continue; + //if(V0CosOfPointingAngleXi > 0.9999) continue; + //if(dcaPosToPrimaryVtxXi < 0.1) continue; + //if(dcaNegToPrimaryVtxXi < 0.1) continue; + + if(dcaV0DaughtersXi > fCascadeCuts[4]) continue; + if(V0CosOfPointingAngleXi > fCascadeCuts[5]) continue; + if(dcaPosToPrimaryVtxXi < fCascadeCuts[6]) continue; + if(dcaNegToPrimaryVtxXi < fCascadeCuts[6]) continue; + + //if(V0RadiusXi < 1.0 || V0RadiusXi > 100) continue; + + //other cuts? + // change mass hypothesis to cover all the possibilities + if(bTrkXi->Charge()<0){ + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, 3312); //Xi- hyp. + invMassXiMinus = xi->GetEffMassXi(); + + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, 3334); //Omega- hyp. + invMassOmegaMinus = xi->GetEffMassXi(); + + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, 3312); //back to default hyp. + } + + if(bTrkXi->Charge() > 0){ + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, -3312); //anti-Xi- hyp. + invMassXiPlus = xi->GetEffMassXi(); + + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, -3334); //anti-Omega- hyp. + invMassOmegaPlus = xi->GetEffMassXi(); + + V0quality = 0.; + xi->ChangeMassHypothesis(V0quality, -3312); //back to default hyp. + } + + //PID on the daughter tracks + /* + //A - Combined PID + //Resonable guess the priors for the cascade track sample + //(e, mu, pi, K, p) + Double_t priorsGuessXi[5] = {0, 0, 2, 0, 1}; + Double_t priorsGuessOmega[5] = {0, 0, 1, 1, 1}; + + //Combined bachelor-daughter PID + AliPID pidXi; + pidXi.SetPriors(priorsGuessXi); + AliPID pidOmega; + pidOmega.SetPriors(priorsGuessOmega); + + if(pTrkXi->IsOn(AliESDtrack::kESDpid)){// combined PID exists + Double_t r[10] = {0.}; + pTrkXi->GetESDpid(r); + pidXi.SetProbabilities(r); + pidOmega.SetProbabilities(r); + + //Check if the V0 postive track is proton (case for Xi-) + Double_t pProton = pidXi.GetProbability(AliPID::kProton); + if(pProton > pidXi.GetProbability(AliPID::kElectron) + && pProton > pidXi.GetProbability(AliPID::kMuon) + && pProton > pidXi.GetProbability(AliPID::kPion) + && pProton > pidXi.GetProbability(AliPID::kKaon)) + isPosInXiProton = kTRUE; + + //Check if the V0 postive track is a pi+ (case for Xi+) + Double_t pPion = pidXi.GetProbability(AliPID::kPion); + if(pPion > pidXi.GetProbability(AliPID::kElectron) + && pPion > pidXi.GetProbability(AliPID::kMuon) + && pPion > pidXi.GetProbability(AliPID::kKaon) + && pPion > pidXi.GetProbability(AliPID::kProton)) + isPosInXiPion = kTRUE; + // Check if the V0 positive track is a proton (case for Omega-) + pProton = pidOmega.GetProbability(AliPID::kProton); + if(pProton > pidOmega.GetProbability(AliPID::kElectron) + && pProton > pidOmega.GetProbability(AliPID::kMuon) + && pProton > pidOmega.GetProbability(AliPID::kPion) + && pProton > pidOmega.GetProbability(AliPID::kKaon)) + isPosInOmegaProton = kTRUE; + + // Check if the V0 positive track is a pi+ (case for Omega+) + pPion = pidOmega.GetProbability(AliPID::kPion); + if(pPion > pidOmega.GetProbability(AliPID::kElectron) + && pPion > pidOmega.GetProbability(AliPID::kMuon) + && pPion > pidOmega.GetProbability(AliPID::kKaon) + && pPion > pidOmega.GetProbability(AliPID::kProton)) + isPosInOmegaPion = kTRUE; + } + + //Combined V0-negative-daughter PID + pidXi.SetPriors(priorsGuessXi); + pidOmega.SetPriors(priorsGuessOmega); + if(nTrkXi->IsOn(AliESDtrack::kESDpid)){ + Double_t r[10] = {0.}; + nTrkXi->GetESDpid(r); + pidXi.SetProbabilities(r); + pidOmega.SetProbabilities(r); + + // Check if the V0 negative track is a pi- (case for Xi-) + Double_t pPion = pidXi.GetProbability(AliPID::kPion); + if(pPion > pidXi.GetProbability(AliPID::kElectron) + && pPion > pidXi.GetProbability(AliPID::kMuon) + && pPion > pidXi.GetProbability(AliPID::kKaon) + && pPion > pidXi.GetProbability(AliPID::kProton)) + isNegInXiPion = kTRUE; + + // Check if the V0 negative track is an anti-proton (case for Xi+) + Double_t pProton = pidXi.GetProbability(AliPID::kProton); + if(pProton > pidXi.GetProbability(AliPID::kElectron) + && pProton > pidXi.GetProbability(AliPID::kMuon) + && pProton > pidXi.GetProbability(AliPID::kPion) + && pProton > pidXi.GetProbability(AliPID::kKaon)) + isNegInXiProton = kTRUE; + + // Check if the V0 negative track is a pi- (case for Omega-) + pPion = pidOmega.GetProbability(AliPID::kPion); + if(pPion > pidOmega.GetProbability(AliPID::kElectron) + && pPion > pidOmega.GetProbability(AliPID::kMuon) + && pPion > pidOmega.GetProbability(AliPID::kKaon) + && pPion > pidOmega.GetProbability(AliPID::kProton)) + isNegInOmegaPion = kTRUE; + + // Check if the V0 negative track is an anti-proton (case for Omega+) + pProton = pidOmega.GetProbability(AliPID::kProton); + if(pProton > pidOmega.GetProbability(AliPID::kElectron) + && pProton > pidOmega.GetProbability(AliPID::kMuon) + && pProton > pidOmega.GetProbability(AliPID::kPion) + && pProton > pidOmega.GetProbability(AliPID::kKaon)) + isNegInOmegaProton = kTRUE; + + } + + // Combined bachelor PID + pidXi.SetPriors(priorsGuessXi); + pidOmega.SetPriors(priorsGuessOmega); + if(bTrkXi->IsOn(AliESDtrack::kESDpid)){//Combined PID exists + Double_t r[10] = {0.}; + bTrkXi->GetESDpid(r); + pidXi.SetProbabilities(r); + pidOmega.SetProbabilities(r); + + //Check if the bachelor track is a pion + Double_t pPion = pidXi.GetProbability(AliPID::kPion); + if(pPion > pidXi.GetProbability(AliPID::kElectron) + && pPion > pidXi.GetProbability(AliPID::kMuon) + && pPion > pidXi.GetProbability(AliPID::kKaon) + && pPion > pidXi.GetProbability(AliPID::kProton)) + isBachelorPion = kTRUE; + + // Check if the bachelor track is a kaon + Double_t pKaon = pidOmega.GetProbability(AliPID::kKaon); + if(pKaon > pidOmega.GetProbability(AliPID::kElectron) + && pKaon > pidOmega.GetProbability(AliPID::kMuon) + && pKaon > pidOmega.GetProbability(AliPID::kPion) + && pKaon > pidOmega.GetProbability(AliPID::kProton)) + isBachelorKaon = kTRUE; + } + */ + + + //B - TPC PID: 3-sigma bands on Bethe-Bloch curve + //Bachelor + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kKaon))<3.) + isBachelorKaonForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kPion))<3.) + isBachelorPionForTPC = kTRUE; + + //Negative V0 daughter + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kPion))<3.) + isNegPionForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kProton))<3.) + isNegProtonForTPC = kTRUE; + + //Positive V0 daughter + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kPion))<3.) + isPosPionForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kProton))<3.) + isPosProtonForTPC = kTRUE; + + + //Extra QA information + xi->GetPxPyPz(XiPx, XiPy, XiPz); + XiPt = TMath::Sqrt(XiPx*XiPx + XiPy*XiPy); + XiPtot= TMath::Sqrt(XiPx*XiPx + XiPy*XiPy + XiPz*XiPz); + + XiPAfter[0] = XiPx; + XiPAfter[1] = XiPy; + XiPAfter[2] = XiPz; + + xi->GetBPxPyPz(bachPx, bachPy, bachPz); + bachPt = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy); + bachPtot = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy + bachPz*bachPz); + + //chargeXi = xi->Charge(); + + V0toXiCosOfPointingAngle + = xi->GetV0CosineOfPointingAngle(posXi[0], posXi[1], posXi[2]); + rapXi = xi->RapXi(); + rapOmega = xi->RapOmega(); + phi = xi->Phi(); + alphaXi = xi->AlphaXi(); + ptArmXi = xi->PtArmXi(); + + distToVtxZBefore = posXi[2]-bestPrimaryVtxPos[2]; + distToVtxXYBefore + = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) + *(posXi[0] - bestPrimaryVtxPos[0]) + +(posXi[1] - bestPrimaryVtxPos[1]) + *(posXi[1] - bestPrimaryVtxPos[1])); + + //propagation to the best primary vertex to determine the momentum + Propagate(bestPrimaryVtxPos, posXi, XiPAfter, b, xi->Charge()); + distToVtxZAfter = posXi[2] - bestPrimaryVtxPos[2]; + distToVtxXYAfter = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) + *(posXi[0] - bestPrimaryVtxPos[0]) + +(posXi[1] - bestPrimaryVtxPos[1]) + *(posXi[1] - bestPrimaryVtxPos[1])); + phiAfter = TMath::Pi() + TMath::ATan2(-XiPAfter[1],-XiPAfter[0]); + + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZAfter"))->Fill(distToVtxZAfter); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYAfter"))->Fill(distToVtxXYAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZBeforeVsAfter"))->Fill(distToVtxZBefore, distToVtxZAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYBeforeVsAfter"))->Fill(distToVtxXYBefore, distToVtxXYAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PxBeforeVsAfter"))->Fill(XiPx, XiPAfter[0]); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PyBeforeVsAfter"))->Fill(XiPy, XiPAfter[1]); + if(xi->Charge()>0) + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiPosBeforeVsAfter"))->Fill(phi, phiAfter); + else if(xi->Charge()<0) + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiNegBeforeVsAfter"))->Fill(phi, phiAfter); + + + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Chi2Xi"))->Fill(chi2Xi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaXiDaughters"))->Fill(dcaXiDaughters); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaBachToPrimVertex"))->Fill(dcaBachToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiCosOfPointingAngle"))->Fill(XiCosOfPointingAngle); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiRadius"))->Fill(XiRadius); + + //V0 + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassLambdaAsCascDghter"))->Fill(invMassLambdaAsCascDghter); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0Chi2Xi"))->Fill(V0Chi2Xi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0DaughtersXi"))->Fill(dcaV0DaughtersXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0CosOfPointingAngleXi"))->Fill(V0CosOfPointingAngleXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0RadiusXi"))->Fill(V0RadiusXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0ToPrimVertexXi"))->Fill(dcaV0ToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaPosToPrimVertexXi"))->Fill(dcaPosToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaNegToPrimVertexXi"))->Fill(dcaNegToPrimaryVtxXi); + + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0toXiCosOfPointingAngle"))->Fill(V0toXiCosOfPointingAngle); + + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Armenteros"))->Fill(alphaXi, ptArmXi); + + //PID cuts with TPC cuts + if(xi->Charge() < 0){ + if(isPosProtonForTPC + && isNegPionForTPC){ + + switch(fSpecie) { + case 0: + if(isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiMinus); + + //candidate inserting + MakeTrack(invMassXiMinus, XiPt, /*xi->Phi()*/ + phiAfter, xi->Eta(), pTrkXi->GetID(), + nTrkXi->GetID(), bTrkXi->GetID()); + } + break; + + case 1: + if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaMinus); + MakeTrack(invMassOmegaMinus, XiPt, /*xi->Phi()*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + } + break; + } + } + } + + if(xi->Charge() > 0){ + if(isNegProtonForTPC + && isPosPionForTPC){ + + switch (fSpecie){ + case 0: + if(isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiPlus); + + //candidate inserting + MakeTrack(invMassXiPlus, XiPt, /*xi->Phi()*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + } + break; + + case 1: + if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaPlus); + MakeTrack(invMassOmegaPlus, XiPt, /*xi->Phi()*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + } + break; + } + } + } + + } + + return; +} + +//______________________________________________________________________________ +void AliAnalysisTaskFlowCascade::ReadFromAODv0(AliAODEvent *fAOD) +{ + + fCutsRPTPC->SetEvent(fAOD, MCEvent()); + fCutsRPVZE->SetEvent(fAOD, MCEvent()); + fCutsPOI->SetEvent(fAOD, MCEvent()); + fFlowEventTPC->Fill(fCutsRPTPC, fCutsPOI); + fFlowEventVZE->Fill(fCutsRPVZE, fCutsPOI); + + // Double_t trkPrimaryVtxPos[3] = {-100., -100., -100.}; + Double_t bestPrimaryVtxPos[3] = {-100., -100., -100.}; + + Double_t b = fAOD->GetMagneticField(); + + int nCascades=fAOD->GetNumberOfCascades(); + const AliAODVertex *primaryBestAODVtx = fAOD->GetPrimaryVertex(); + primaryBestAODVtx->GetXYZ(bestPrimaryVtxPos); + + // calculation part dedicated to Xi vertices + for(Int_t iXi = 0; iXi < nCascades; iXi++){ + Double_t effMassXi = 0.; + Double_t chi2Xi = -1.; + Double_t dcaXiDaughters = -1.; + Double_t XiCosOfPointingAngle = -1.; + Double_t posXi[3] = {-1000., -1000., -1000.}; + Double_t XiRadius = -1000.; + + Double_t invMassLambdaAsCascDghter = 0.; + Double_t V0Chi2Xi = -1.; + Double_t dcaV0DaughtersXi = -1.; + + Double_t dcaBachToPrimaryVtxXi = -1.; + Double_t dcaV0ToPrimaryVtxXi = -1.; + Double_t dcaPosToPrimaryVtxXi = -1.; + Double_t dcaNegToPrimaryVtxXi = -1.; + Double_t V0CosOfPointingAngleXi = -1.; + Double_t posV0Xi[3] = {-1000., -1000., -1000.}; + Double_t V0RadiusXi = -1000.; + // Double_t V0quality = 0.; + + Double_t invMassXiMinus = 0.; + Double_t invMassXiPlus = 0.; + Double_t invMassOmegaMinus = 0.; + Double_t invMassOmegaPlus = 0.; + + /* + Bool_t isPosInXiProton = kFALSE; + Bool_t isPosInXiPion = kFALSE; + Bool_t isPosInOmegaProton = kFALSE; + Bool_t isPosInOmegaPion = kFALSE; + + Bool_t isNegInXiProton = kFALSE; + Bool_t isNegInXiPion = kFALSE; + Bool_t isNegInOmegaProton = kFALSE; + Bool_t isNegInOmegaPion = kFALSE; + + Bool_t isBachelorKaon = kFALSE; + Bool_t isBachelorPion = kFALSE; + */ + + + Bool_t isBachelorKaonForTPC = kFALSE; + Bool_t isBachelorPionForTPC = kFALSE; + Bool_t isNegPionForTPC = kFALSE; + Bool_t isPosPionForTPC = kFALSE; + Bool_t isNegProtonForTPC = kFALSE; + Bool_t isPosProtonForTPC = kFALSE; + + Double_t XiPx = 0., XiPy = 0., XiPz = 0.; + Double_t XiPt = 0.; + Double_t XiPtot = 0.; + + Double_t bachPx = 0., bachPy = 0., bachPz = 0.; + Double_t bachPt = 0.; + Double_t bachPtot = 0.; + + //Short_t chargeXi = -2; + Double_t V0toXiCosOfPointingAngle = 0.; + + Double_t rapXi = -20.; + Double_t rapOmega = -20.; + Double_t phi = 6.3; + Double_t alphaXi = -200.; + Double_t ptArmXi = -200.; + + Double_t distToVtxZBefore = -999.; + Double_t distToVtxZAfter = -999.; + Double_t distToVtxXYBefore = -999.; + Double_t distToVtxXYAfter = -999.; + Double_t XiPAfter[3] = {-999., -999., -999.}; + Double_t phiAfter = -999.; + + const AliAODcascade *xi = fAOD->GetCascade(iXi); + if (!xi) continue; + + effMassXi = xi->MassXi(); //default working hypothesis: Xi- decay + chi2Xi = xi->Chi2Xi(); + dcaXiDaughters = xi->DcaXiDaughters(); + XiCosOfPointingAngle = xi->CosPointingAngleXi(bestPrimaryVtxPos[0], + bestPrimaryVtxPos[1], + bestPrimaryVtxPos[2]); + posXi[0] = xi->DecayVertexXiX(); + posXi[1] = xi->DecayVertexXiY(); + posXi[2] = xi->DecayVertexXiZ(); + XiRadius = TMath::Sqrt(posXi[0]*posXi[0] + +posXi[1]*posXi[1] + +posXi[2]*posXi[2]); + + AliAODTrack *pTrkXi = dynamic_cast( xi->GetDaughter(0) ); + AliAODTrack *nTrkXi = dynamic_cast( xi->GetDaughter(1) ); + AliAODTrack *bTrkXi + = dynamic_cast( xi->GetDecayVertexXi()->GetDaughter(0) ); + + if(!pTrkXi || !nTrkXi || !bTrkXi) continue; + + UInt_t idxPosXi = (UInt_t) TMath::Abs( pTrkXi->GetID() ); + UInt_t idxNegXi = (UInt_t) TMath::Abs( nTrkXi->GetID() ); + UInt_t idxBach = (UInt_t) TMath::Abs( bTrkXi->GetID() ); + + if(idxBach == idxNegXi || idxBach == idxPosXi) continue; + + if( !fCutsDau->IsSelected(pTrkXi) + || !fCutsDau->IsSelected(nTrkXi) + || !fCutsDau->IsSelected(bTrkXi) ) continue; + + + if(pTrkXi->IsOn(AliESDtrack::kTPCin)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(pTrkXi->P()*pTrkXi->Charge(), pTrkXi->GetTPCsignal()); + } + if( nTrkXi->IsOn(AliESDtrack::kTPCin) ){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(nTrkXi->P()*nTrkXi->Charge(), nTrkXi->GetTPCsignal()); + } + if(bTrkXi->IsOn(AliESDtrack::kTPCin)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("TPCdEdxOfCascDghters"))->Fill(bTrkXi->P()*bTrkXi->Charge(), bTrkXi->GetTPCsignal()); + } + + if(xi->ChargeXi() < 0) + invMassLambdaAsCascDghter = xi->MassLambda(); + else + invMassLambdaAsCascDghter = xi->MassAntiLambda(); + + dcaV0DaughtersXi = xi->DcaV0Daughters(); + V0Chi2Xi = xi->Chi2V0(); + V0CosOfPointingAngleXi + = xi->CosPointingAngle(bestPrimaryVtxPos); + dcaV0ToPrimaryVtxXi = xi->DcaV0ToPrimVertex(); + dcaBachToPrimaryVtxXi = xi->DcaBachToPrimVertex(); + + //V0 + posV0Xi[0] = xi->DecayVertexV0X(); + posV0Xi[1] = xi->DecayVertexV0Y(); + posV0Xi[2] = xi->DecayVertexV0Z(); + V0RadiusXi = TMath::Sqrt(posV0Xi[0]*posV0Xi[0] + +posV0Xi[1]*posV0Xi[1] + +posV0Xi[2]*posV0Xi[2]); + dcaPosToPrimaryVtxXi = xi->DcaPosToPrimVertex(); + dcaNegToPrimaryVtxXi = xi->DcaNegToPrimVertex(); + + //apply cuts ? + // if(XiRadius < 1. || XiRadius > 100.) continue; + //if(dcaXiDaughters > 0.1) continue; + //if(XiCosOfPointingAngle < 0.999) continue; + //if(dcaV0ToPrimaryVtxXi < 0.05) continue; + //if(dcaBachToPrimaryVtxXi < 0.03) continue; + + if(dcaXiDaughters > fCascadeCuts[0]) continue; + if(XiCosOfPointingAngle < fCascadeCuts[1]) continue; + if(dcaV0ToPrimaryVtxXi < fCascadeCuts[2]) continue; + if(dcaBachToPrimaryVtxXi < fCascadeCuts[3]) continue; + + //V0 mass cut? + //if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > 0.006) continue; + if(TMath::Abs(invMassLambdaAsCascDghter-1.11568) > fCascadeCuts[7]) + continue; + + //if(dcaV0DaughtersXi > 1.) continue; + //if(V0CosOfPointingAngleXi > 0.9999) continue; + //if(dcaPosToPrimaryVtxXi < 0.1) continue; + //if(dcaNegToPrimaryVtxXi < 0.1) continue; + if(dcaV0DaughtersXi > fCascadeCuts[4]) continue; + if(V0CosOfPointingAngleXi > fCascadeCuts[5]) continue; + if(dcaPosToPrimaryVtxXi < fCascadeCuts[6]) continue; + if(dcaNegToPrimaryVtxXi < fCascadeCuts[6]) continue; + + // if(V0RadiusXi < 1.0 || V0RadiusXi > 100) continue; + + //other cuts? + + + //??? + if(xi->ChargeXi()<0){ + invMassXiMinus = xi->MassXi(); + invMassOmegaMinus = xi->MassOmega(); + }else{ + invMassXiPlus = xi->MassXi(); + invMassOmegaPlus = xi->MassOmega(); + } + + /* + if(pTrkXi->GetMostProbablePID() == AliAODTrack::kProton) { + isPosInXiProton = kTRUE; + isPosInOmegaProton = kTRUE; + } + if(pTrkXi->GetMostProbablePID() == AliAODTrack::kPion){ + isPosInXiPion = kTRUE; + isPosInOmegaPion = kTRUE; + } + + if(nTrkXi->GetMostProbablePID() == AliAODTrack::kPion){ + isNegInXiPion = kTRUE; + isNegInOmegaPion = kTRUE; + } + if(nTrkXi->GetMostProbablePID() == AliAODTrack::kProton){ + isNegInXiProton = kTRUE; + isNegInOmegaProton = kTRUE; + } + + if(bTrkXi->GetMostProbablePID() == AliAODTrack::kPion) + isBachelorPion = kTRUE; + if(bTrkXi->GetMostProbablePID() == AliAODTrack::kKaon) + isBachelorKaon = kTRUE; + */ + + //PID with TPC only: + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kKaon))<3.) + isBachelorKaonForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(bTrkXi, AliPID::kPion))<3.) + isBachelorPionForTPC = kTRUE; + + //Negative V0 daughter + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kPion))<3.) + isNegPionForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(nTrkXi, AliPID::kProton))<3.) + isNegProtonForTPC = kTRUE; + + //Positive V0 daughter + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kPion))<3.) + isPosPionForTPC = kTRUE; + if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(pTrkXi, AliPID::kProton))<3.) + isPosProtonForTPC = kTRUE; + + //Extra QA information + XiPx = xi->MomXiX(); + XiPy = xi->MomXiY(); + XiPz = xi->MomXiZ(); + XiPt = TMath::Sqrt(XiPx*XiPx + XiPy*XiPy); + XiPtot= TMath::Sqrt(XiPx*XiPx + XiPy*XiPy + XiPz*XiPz); + + bachPx = xi->MomBachX(); + bachPy = xi->MomBachY(); + bachPz = xi->MomBachZ(); + + bachPt = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy); + bachPtot = TMath::Sqrt(bachPx*bachPx + bachPy*bachPy + bachPz*bachPz); + + V0toXiCosOfPointingAngle = xi->CosPointingAngle( xi->GetDecayVertexXi() ); + + rapXi = xi->RapXi(); + rapOmega = xi->RapOmega(); + phi = xi->Phi(); + alphaXi = xi->AlphaXi(); + ptArmXi = xi->PtArmXi(); + + distToVtxZBefore = posXi[2]-bestPrimaryVtxPos[2]; + distToVtxXYBefore + = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) + *(posXi[0] - bestPrimaryVtxPos[0]) + +(posXi[1] - bestPrimaryVtxPos[1]) + *(posXi[1] - bestPrimaryVtxPos[1])); + + + XiPAfter[0] = XiPx; + XiPAfter[1] = XiPy; + XiPAfter[2] = XiPz; + //propagation to the best primary vertex to determine the momentum + Propagate(bestPrimaryVtxPos, posXi, XiPAfter, b, xi->ChargeXi()); + distToVtxZAfter = posXi[2] - bestPrimaryVtxPos[2]; + distToVtxXYAfter = TMath::Sqrt((posXi[0] - bestPrimaryVtxPos[0]) + *(posXi[0] - bestPrimaryVtxPos[0]) + +(posXi[1] - bestPrimaryVtxPos[1]) + *(posXi[1] - bestPrimaryVtxPos[1])); + phiAfter = TMath::Pi() + TMath::ATan2(-XiPAfter[1],-XiPAfter[0]); + + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZAfter"))->Fill(distToVtxZAfter); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYAfter"))->Fill(distToVtxXYAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxZBeforeVsAfter"))->Fill(distToVtxZBefore, distToVtxZAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DistToVtxXYBeforeVsAfter"))->Fill(distToVtxXYBefore, distToVtxXYAfter); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PxBeforeVsAfter"))->Fill(XiPx, XiPAfter[0]); + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PyBeforeVsAfter"))->Fill(XiPy, XiPAfter[1]); + if(xi->ChargeXi()>0) + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiPosBeforeVsAfter"))->Fill(phi, phiAfter); + else if(xi->ChargeXi()<0) + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("PhiNegBeforeVsAfter"))->Fill(phi, phiAfter); + + //for default hypothesis + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Chi2Xi"))->Fill(chi2Xi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaXiDaughters"))->Fill(dcaXiDaughters); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaBachToPrimVertex"))->Fill(dcaBachToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiCosOfPointingAngle"))->Fill(XiCosOfPointingAngle); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("XiRadius"))->Fill(XiRadius); + + //V0 + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassLambdaAsCascDghter"))->Fill(invMassLambdaAsCascDghter); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0Chi2Xi"))->Fill(V0Chi2Xi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0DaughtersXi"))->Fill(dcaV0DaughtersXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0CosOfPointingAngleXi"))->Fill(V0CosOfPointingAngleXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0RadiusXi"))->Fill(V0RadiusXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaV0ToPrimVertexXi"))->Fill(dcaV0ToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaPosToPrimVertexXi"))->Fill(dcaPosToPrimaryVtxXi); + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("DcaNegToPrimVertexXi"))->Fill(dcaNegToPrimaryVtxXi); + + ((TH1F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("V0toXiCosOfPointingAngle"))->Fill(V0toXiCosOfPointingAngle); + + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("Armenteros"))->Fill(alphaXi, ptArmXi); + + //with PID cuts + if(xi->ChargeXi()<0){ + if(isPosProtonForTPC && isNegPionForTPC){ + switch (fSpecie){ + case 0: + if( isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiMinus); + MakeTrack(invMassXiMinus, XiPt, /*xi->Phi(),*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + }// endif + + break; + + case 1: + if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8 + && (invMassXiMinus > 1.32486 || invMassXiMinus < 1.30486)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaMinus); + + MakeTrack(invMassOmegaMinus, XiPt, /* xi->Phi(),*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + }//endif + break; + } + } + }//end if ChargeXi()<0 + + if(xi->ChargeXi() > 0){ + if(isNegProtonForTPC && isPosPionForTPC){ + switch(fSpecie){ + case 0: + if (isBachelorPionForTPC && TMath::Abs(rapXi) < 0.8){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassXiPlus); + + //candidate inserting + MakeTrack(invMassXiPlus, XiPt, /* xi->Phi(),*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + }//endif particle id + break; + + case 1: + if(isBachelorKaonForTPC && TMath::Abs(rapOmega) < 0.8 + && (invMassXiPlus > 1.32486 || invMassXiPlus < 1.30486)){ + ((TH2F*)((TList*)fQAList->FindObject("Candidates"))->FindObject("MassVsPtAll"))->Fill(XiPt, invMassOmegaPlus); + MakeTrack(invMassOmegaPlus, XiPt, /* xi->Phi(),*/ + phiAfter, xi->Eta(), + pTrkXi->GetID(), nTrkXi->GetID(), bTrkXi->GetID()); + }//endif particle id + } + } + }//endif ChargeXi()>0 + }//for Xi candidate loop + + return; + +} + + +void AliAnalysisTaskFlowCascade::MakeTrack( double mass, + double pt, + double phi, + double eta, + int iid, + int jid, + int kid) { + // create track for flow tasks + if(fCandidates->GetLast()+1>=fCandidates->GetSize()) { + fCandidates->Expand( 2*fCandidates->GetSize() ); + } + Bool_t overwrite = kTRUE; + + AliFlowCandidateTrack *sTrack + = (static_cast (fCandidates->At( fCandidates->GetLast()+1 ))); + if( !sTrack ) { // creates new + sTrack = new AliFlowCandidateTrack(); + overwrite = kFALSE; + } else { // overwrites + sTrack->ClearMe(); + } + + + sTrack->SetMass(mass); + sTrack->SetPt(pt); + sTrack->SetPhi(phi); + sTrack->SetEta(eta); + sTrack->AddDaughter(iid); + sTrack->AddDaughter(jid); + sTrack->AddDaughter(kid); + sTrack->SetForPOISelection(kTRUE); + sTrack->SetForRPSelection(kFALSE); + + if(overwrite) { + fCandidates->SetLast( fCandidates->GetLast()+1 ); + } else { + fCandidates->AddLast(sTrack); + } + + return; +} +//_____________________________________________________________________________ +void AliAnalysisTaskFlowCascade::Terminate(Option_t *) +{ + +} + +void AliAnalysisTaskFlowCascade::Propagate(Double_t vv[3], + Double_t x[3], + Double_t p[3], + Double_t bz, + Short_t sign){ + //Propagation to the primary vertex to determine the px and py + //x, p are the position and momentum as input and output + //bz is the magnetic field along z direction + //sign is the charge of particle for propagation + + Double_t pp = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]); + Double_t len = (vv[2]-x[2])*pp/p[2]; + Double_t a = -kB2C*bz*sign; + + Double_t rho = a/pp; + x[0] += p[0]*TMath::Sin(rho*len)/a - p[1]*(1-TMath::Cos(rho*len))/a; + x[1] += p[1]*TMath::Sin(rho*len)/a + p[0]*(1-TMath::Cos(rho*len))/a; + x[2] += p[2]*len/pp; + + Double_t p0=p[0]; + p[0] = p0 *TMath::Cos(rho*len) - p[1]*TMath::Sin(rho*len); + p[1] = p[1]*TMath::Cos(rho*len) + p0 *TMath::Sin(rho*len); +} + + +//===================================================================== +void AliAnalysisTaskFlowCascade::SetCommonConstants(Int_t massBins, + Double_t minMass, + Double_t maxMass) +{ + // setter for mass bins + + fMassBins = massBins; + fMinMass = minMass; + fMaxMass = maxMass; +} + + +//==================================================================== +void AliAnalysisTaskFlowCascade::SetCuts2010(int set) { + + // fCascadeCuts[0]: DcaXiDaughter; fCascadeCuts[1]: XiCosOfPointingAngle + // fCascadeCuts[2]: DcaV0ToPrimaryVtxXi; fCascadeCuts[3]: DcaBachToPrimaryVtxXi + // fCascadeCuts[4]: DcaV0DaughersXi; fCascadeCuts[5]: V0CosOfPointingAngleXi + // fCascadeCuts[6]: DcaV0DaughterToPrimaryVtxXi; fCascadeCuts[7]: V0MassWidth + + switch(set){ + + case 0: //tighter + fCascadeCuts[0] = 0.2; fCascadeCuts[1] = 0.999; + fCascadeCuts[2] = 0.03; fCascadeCuts[3] = 0.05; + fCascadeCuts[4] = .5; fCascadeCuts[5] = 0.9998; + fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.006; + break; + + case 1: //middle + fCascadeCuts[0] = 0.3; fCascadeCuts[1] = 0.99; + fCascadeCuts[2] = 0.01; fCascadeCuts[3] = 0.03; + fCascadeCuts[4] = .6; fCascadeCuts[5] = 0.9999; + fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.008; + break; + + case 2: //looser + fCascadeCuts[0] = 0.3; fCascadeCuts[1] = 0.99; + fCascadeCuts[2] = 0.01; fCascadeCuts[3] = 0.03; + fCascadeCuts[4] = 1.; fCascadeCuts[5] = 1.; + fCascadeCuts[6] = 0.1; fCascadeCuts[7] = 0.01; + break; + } + +} diff --git a/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.h b/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.h index cd24925805b..1ce481d4ebb 100644 --- a/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.h +++ b/PWG/FLOW/Tasks/AliAnalysisTaskFlowCascade.h @@ -1,85 +1,85 @@ -///////////////////////////////////////////////////// -// AliAnalysisTaskFlowCascade: -// Analysis task to select Xi and Omega candidates for flow analysis. -// Author: -////////////////////////////////////////////////////// - -/* Copyright(c) 1998-1999, ALICExperiment at CERN, All rights reserved. * -* See cxx source for full Copyright notice */ -/* $Id: $ */ - -#ifndef AliAnalysisTaskFlowCascade_H -#define AliAnalysisTaskFlowCascade_H - -#include "AliAnalysisTaskSE.h" - -class AliESDtrackCuts; -class AliFlowEventCuts; -class TList; -class TH1D; -class TH2D; -class TH3D; -class AliFlowCandidateTrack; -class TVector3; -class AliPIDResponse; -class AliFlowEvent; -class AliAnalysisTaskFlowCascade : public AliAnalysisTaskSE { - private: - AliAnalysisTaskFlowCascade(const AliAnalysisTaskFlowCascade& analysisTask); - AliAnalysisTaskFlowCascade& - operator=(const AliAnalysisTaskFlowCascade& analysisTask); - - //Progate to the primary vertex - void Propagate(Double_t vv[3], Double_t x[3], Double_t p[3], Double_t bz, - Short_t sign); - - void AddQAEvents(); - void AddQACandidates(); - void ReadFromESDv0(AliESDEvent *fESD); - void ReadFromAODv0(AliAODEvent *fAOD); - - void AddCandidates(); - - void MakeTrack( double mass, double pt, - double phi, double eta, - int iid, int jid, int kid ); - - // double fMinCent, fMaxCent; // - Int_t fSpecie; //0 for Xi and 1 for Omega - Double_t fCascadeCuts[8]; // cuts for cascade selection - Int_t fMassBins; // to configure FLOWCOMMON - Double_t fMinMass; // to configure FLOWCOMMON - Double_t fMaxMass; // to configure FLOWCOMMON - - AliFlowEventCuts *fCutsEvent; // event cuts - AliFlowTrackCuts *fCutsRPTPC; // cuts for RPs - AliFlowTrackCuts *fCutsRPVZE; // cuts for RPs - AliFlowTrackCuts *fCutsPOI; // null cuts for POI - AliFlowTrackCuts *fCutsDau; // cuts for daughters - AliPIDResponse *fPIDResponse; - AliFlowEvent *fFlowEventTPC; //flow event TPC - AliFlowEvent *fFlowEventVZE; //flow event VZE - TObjArray *fCandidates; // Array of selected candidates - TList *fQAList; //! list for QA histos - - public: - AliAnalysisTaskFlowCascade(); - AliAnalysisTaskFlowCascade(const char *name, - AliFlowEventCuts *cutsEvent, - AliFlowTrackCuts *cutsRPTPC, - AliFlowTrackCuts *cutsRPVZE, - /* AliESDtrackCuts */AliFlowTrackCuts *cutsDau); - //void SetDebug() {fDebug = true;} - void SetSpecie(int specie){fSpecie = specie;} - void SetCommonConstants(Int_t massBins, Double_t minMass, Double_t maxMass); - void SetCuts2010(int setOfCuts); - virtual ~AliAnalysisTaskFlowCascade(); - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *); - virtual void Terminate(Option_t *); - virtual void NotifyRun(); - - ClassDef(AliAnalysisTaskFlowCascade, 2); -}; - -#endif +///////////////////////////////////////////////////// +// AliAnalysisTaskFlowCascade: +// Analysis task to select Xi and Omega candidates for flow analysis. +// Author: +////////////////////////////////////////////////////// + +/* Copyright(c) 1998-1999, ALICExperiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ +/* $Id: $ */ + +#ifndef AliAnalysisTaskFlowCascade_H +#define AliAnalysisTaskFlowCascade_H + +#include "AliAnalysisTaskSE.h" + +class AliESDtrackCuts; +class AliFlowEventCuts; +class TList; +class TH1D; +class TH2D; +class TH3D; +class AliFlowCandidateTrack; +class TVector3; +class AliPIDResponse; +class AliFlowEvent; +class AliAnalysisTaskFlowCascade : public AliAnalysisTaskSE { + private: + AliAnalysisTaskFlowCascade(const AliAnalysisTaskFlowCascade& analysisTask); + AliAnalysisTaskFlowCascade& + operator=(const AliAnalysisTaskFlowCascade& analysisTask); + + //Progate to the primary vertex + void Propagate(Double_t vv[3], Double_t x[3], Double_t p[3], Double_t bz, + Short_t sign); + + void AddQAEvents(); + void AddQACandidates(); + void ReadFromESDv0(AliESDEvent *fESD); + void ReadFromAODv0(AliAODEvent *fAOD); + + void AddCandidates(); + + void MakeTrack( double mass, double pt, + double phi, double eta, + int iid, int jid, int kid ); + + // double fMinCent, fMaxCent; // + Int_t fSpecie; //0 for Xi and 1 for Omega + Double_t fCascadeCuts[8]; // cuts for cascade selection + Int_t fMassBins; // to configure FLOWCOMMON + Double_t fMinMass; // to configure FLOWCOMMON + Double_t fMaxMass; // to configure FLOWCOMMON + + AliFlowEventCuts *fCutsEvent; // event cuts + AliFlowTrackCuts *fCutsRPTPC; // cuts for RPs + AliFlowTrackCuts *fCutsRPVZE; // cuts for RPs + AliFlowTrackCuts *fCutsPOI; // null cuts for POI + AliFlowTrackCuts *fCutsDau; // cuts for daughters + AliPIDResponse *fPIDResponse; + AliFlowEvent *fFlowEventTPC; //flow event TPC + AliFlowEvent *fFlowEventVZE; //flow event VZE + TObjArray *fCandidates; // Array of selected candidates + TList *fQAList; //! list for QA histos + + public: + AliAnalysisTaskFlowCascade(); + AliAnalysisTaskFlowCascade(const char *name, + AliFlowEventCuts *cutsEvent, + AliFlowTrackCuts *cutsRPTPC, + AliFlowTrackCuts *cutsRPVZE, + /* AliESDtrackCuts */AliFlowTrackCuts *cutsDau); + //void SetDebug() {fDebug = true;} + void SetSpecie(int specie){fSpecie = specie;} + void SetCommonConstants(Int_t massBins, Double_t minMass, Double_t maxMass); + void SetCuts2010(int setOfCuts); + virtual ~AliAnalysisTaskFlowCascade(); + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *); + virtual void Terminate(Option_t *); + virtual void NotifyRun(); + + ClassDef(AliAnalysisTaskFlowCascade, 2); +}; + +#endif diff --git a/PWG/muon/AliAnalysisTaskESDMuonFilter.h b/PWG/muon/AliAnalysisTaskESDMuonFilter.h index 91cd3337b6f..295cb0ec3ca 100644 --- a/PWG/muon/AliAnalysisTaskESDMuonFilter.h +++ b/PWG/muon/AliAnalysisTaskESDMuonFilter.h @@ -1,57 +1,57 @@ -#ifndef ALIANALYSISTASKESDMUONFILTER_H -#define ALIANALYSISTASKESDMUONFILTER_H - -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// \brief Add the muon tracks to the generic AOD track branch during the -/// filtering of the ESD. -/// -/// \author R. Arnaldi 5/5/08 and L. Aphecetche January 2011 - -#ifndef ALIANALYSISTASKSE_H -# include "AliAnalysisTaskSE.h" -#endif - -class AliAnalysisFilter; - -class AliAnalysisTaskESDMuonFilter : public AliAnalysisTaskSE -{ -public: - AliAnalysisTaskESDMuonFilter(Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Bool_t withSPDtracklets=kFALSE); - AliAnalysisTaskESDMuonFilter(const char* name, Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Bool_t withSPDtracklets=kFALSE); - virtual ~AliAnalysisTaskESDMuonFilter() {;} - - virtual void UserCreateOutputObjects(); - virtual void Init(); - virtual void LocalInit() {Init();} - virtual void UserExec(Option_t *option); - - virtual void ConvertESDtoAOD(); - - virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;} - void SetWriteMuonAOD(Bool_t enableMuonAOD){fEnableMuonAOD = enableMuonAOD;} - void SetWriteDimuonAOD(Bool_t enableDimuonAOD){fEnableDimuonAOD = enableDimuonAOD;} - - void PrintTask(Option_t *option="", Int_t indent=0) const; - -private: - AliAnalysisTaskESDMuonFilter(const AliAnalysisTaskESDMuonFilter&); - AliAnalysisTaskESDMuonFilter& operator=(const AliAnalysisTaskESDMuonFilter&); - void AddFilteredAOD(const char* aodfilename, const char* title); - - AliAnalysisFilter* fTrackFilter; ///< Track Filter - Bool_t fEnableMuonAOD; ///< flag for enabling Muon AOD production - Bool_t fEnableDimuonAOD; ///< flag for enabling Dimuon AOD production - Bool_t fOnlyMuon; ///< flag for disabling branches irrelevant for (most) muon analyses - Bool_t fKeepAllEvents; ///< keep even events where there's no muons (to get e.g. unbiased vertex distribution) - Int_t fMCMode; ///< whether and how we're filtering MC data - Bool_t fWithSPDTracklets; ///< whether or not we keep SPD tracklets - - ClassDef(AliAnalysisTaskESDMuonFilter, 6); // Analysis task for standard ESD filtering -}; - -#endif +#ifndef ALIANALYSISTASKESDMUONFILTER_H +#define ALIANALYSISTASKESDMUONFILTER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// \brief Add the muon tracks to the generic AOD track branch during the +/// filtering of the ESD. +/// +/// \author R. Arnaldi 5/5/08 and L. Aphecetche January 2011 + +#ifndef ALIANALYSISTASKSE_H +# include "AliAnalysisTaskSE.h" +#endif + +class AliAnalysisFilter; + +class AliAnalysisTaskESDMuonFilter : public AliAnalysisTaskSE +{ +public: + AliAnalysisTaskESDMuonFilter(Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Bool_t withSPDtracklets=kFALSE); + AliAnalysisTaskESDMuonFilter(const char* name, Bool_t onlyMuon=kTRUE, Bool_t keepAllEvents=kTRUE, Int_t mcMode=0, Bool_t withSPDtracklets=kFALSE); + virtual ~AliAnalysisTaskESDMuonFilter() {;} + + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void UserExec(Option_t *option); + + virtual void ConvertESDtoAOD(); + + virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;} + void SetWriteMuonAOD(Bool_t enableMuonAOD){fEnableMuonAOD = enableMuonAOD;} + void SetWriteDimuonAOD(Bool_t enableDimuonAOD){fEnableDimuonAOD = enableDimuonAOD;} + + void PrintTask(Option_t *option="", Int_t indent=0) const; + +private: + AliAnalysisTaskESDMuonFilter(const AliAnalysisTaskESDMuonFilter&); + AliAnalysisTaskESDMuonFilter& operator=(const AliAnalysisTaskESDMuonFilter&); + void AddFilteredAOD(const char* aodfilename, const char* title); + + AliAnalysisFilter* fTrackFilter; ///< Track Filter + Bool_t fEnableMuonAOD; ///< flag for enabling Muon AOD production + Bool_t fEnableDimuonAOD; ///< flag for enabling Dimuon AOD production + Bool_t fOnlyMuon; ///< flag for disabling branches irrelevant for (most) muon analyses + Bool_t fKeepAllEvents; ///< keep even events where there's no muons (to get e.g. unbiased vertex distribution) + Int_t fMCMode; ///< whether and how we're filtering MC data + Bool_t fWithSPDTracklets; ///< whether or not we keep SPD tracklets + + ClassDef(AliAnalysisTaskESDMuonFilter, 6); // Analysis task for standard ESD filtering +}; + +#endif diff --git a/PWG/muon/AliUtilityMuonAncestor.cxx b/PWG/muon/AliUtilityMuonAncestor.cxx index 968a10a3464..eea875b3457 100644 --- a/PWG/muon/AliUtilityMuonAncestor.cxx +++ b/PWG/muon/AliUtilityMuonAncestor.cxx @@ -1,295 +1,295 @@ -/************************************************************************** - * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* $Id: AliUtilityMuonAncestor.cxx 47782 2011-02-24 18:37:31Z martinez $ */ - -//----------------------------------------------------------------------------- -/// \class AliUtilityMuonAncestor -/// Static utilities to get the muon ancestor in MC -/// -/// \author Diego Stocco -//----------------------------------------------------------------------------- - -#include "AliUtilityMuonAncestor.h" - -// ROOT includes -#include "TDatabasePDG.h" -#include "TParticlePDG.h" -#include "TPDGCode.h" -#include "TMCProcess.h" -#include "TMath.h" - -// STEER includes -#include "AliMCEvent.h" -#include "AliVParticle.h" -#include "AliMCParticle.h" -#include "AliAODMCParticle.h" -#include "AliLog.h" - -// PWGmuon includes -#include "AliAnalysisMuonUtility.h" - -/// \cond CLASSIMP -ClassImp(AliUtilityMuonAncestor) // Class implementation in ROOT context -/// \endcond - -//_________________________________________________________ -AliUtilityMuonAncestor::AliUtilityMuonAncestor() : -TObject(), -fPx(0.), -fPy(0.), -fPz(0.), -fMask(0), -fAncestor(-999) -{ - /// Default constructor -} - - -//_________________________________________________________ -AliUtilityMuonAncestor::~AliUtilityMuonAncestor() -{ - /// Default destructor -} - -//_________________________________________________________ -AliUtilityMuonAncestor::AliUtilityMuonAncestor(const AliUtilityMuonAncestor& obj) : -TObject(obj), -fPx(obj.fPx), -fPy(obj.fPy), -fPz(obj.fPz), -fMask(obj.fMask), -fAncestor(obj.fAncestor) -{ - /// Copy constructor -} - -//_________________________________________________________ -AliUtilityMuonAncestor& AliUtilityMuonAncestor::operator=(const AliUtilityMuonAncestor& obj) -{ - /// Copy operator - if ( this != &obj ) { - TObject::operator=(obj); - fPx = obj.fPx; - fPy = obj.fPy; - fPz = obj.fPz; - fMask = obj.fMask; - fAncestor = obj.fAncestor; - } - return *this; -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::BuildAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Build ancestor - - // If track is the same as the one in memory, do not re-build the track ancestor - if ( track->Px() == fPx && track->Py() == fPy && track->Pz() == fPz ) return kTRUE; - fPx = track->Px(); - fPy = track->Py(); - fPz = track->Pz(); - fMask = 0; - fAncestor = -999; - if ( ! mcEvent ) return kFALSE; - - AliVParticle* mcParticle = 0x0; - - if ( AliAnalysisMuonUtility::IsMCTrack(track) ) mcParticle = track; - else { - Int_t trackLabel = track->GetLabel(); - if ( trackLabel < 0 ) return kFALSE; - mcParticle = mcEvent->GetTrack(trackLabel); - } - - // Track is MC (or matches a MC track) - SETBIT(fMask,kIsID); - - Int_t recoPdg = mcParticle->PdgCode(); - - // Track is not a muon - if ( TMath::Abs(recoPdg) == 13 ) SETBIT(fMask,kIsMuon); - - Int_t imother = AliAnalysisMuonUtility::GetMotherIndex(mcParticle); - - while ( imother >= 0 ) { - AliVParticle* part = mcEvent->GetTrack(imother); - - Int_t absPdg = TMath::Abs(part->PdgCode()); - - // This is a quark - if ( absPdg < 10 ) return kTRUE; - - fAncestor = imother; - Bool_t isPrimary = AliAnalysisMuonUtility::IsPrimary(part, mcEvent); - - if ( isPrimary ) { - Int_t mpdg = absPdg%100000; - if ( mpdg >= 100 && mpdg < 10000 ) { - Int_t flv = Int_t ( mpdg / TMath::Power(10, Int_t(TMath::Log10(mpdg) ))); - if ( flv < 4 ) SETBIT(fMask,kHasLightParent); - else if ( flv >= 6 ) continue; - else { - TParticlePDG* partPdg = TDatabasePDG::Instance()->GetParticle(part->PdgCode()); - if ( partPdg && ! partPdg->AntiParticle() ) SETBIT(fMask,kHasQuarkoniumParent); - else if ( flv == 4 ) SETBIT(fMask,kHasCharmParent); - else SETBIT(fMask,kHasBeautyParent); - } - } // absPdg within 100 and 10000 - } // is primary - else { - UInt_t mcProcess = AliAnalysisMuonUtility::GetMCProcess(part); - if ( mcProcess == kPHadronic || - ( mcProcess == 0 && part->Zv() < -90. ) ) { - // The MC process is not well computed in the AODs of old MC productions - // In this case, declare the particle as "secondary" if it is produced inside the front absorber - SETBIT(fMask,kIsSecondary); -// return kTRUE; - } - } // is secondary - - imother = AliAnalysisMuonUtility::GetMotherIndex(part); - - } // loop on mothers - return kTRUE; -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::CheckAncestor ( AliVParticle* track, const AliMCEvent* mcEvent, Int_t ancestorPdg, Bool_t matchAbsPdg ) -{ - /// Check ancestor - Int_t pdgCode = GetAncestorPdg(track, mcEvent); - if ( matchAbsPdg ) { - pdgCode = TMath::Abs(pdgCode); - ancestorPdg = TMath::Abs(ancestorPdg); - } - return ( pdgCode == ancestorPdg ); -} - -//_________________________________________________________ -Int_t AliUtilityMuonAncestor::GetAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Return ancestor (compute it if necessary) - BuildAncestor(track,mcEvent); - return fAncestor; -} - -//_________________________________________________________ -Int_t AliUtilityMuonAncestor::GetAncestorPdg ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Return ancestor Pdg - if ( BuildAncestor(track,mcEvent) ) { - if ( fAncestor >= 0 ) return mcEvent->GetTrack(fAncestor)->PdgCode(); - } - return 0; -} - -//_________________________________________________________ -Long64_t AliUtilityMuonAncestor::GetMask ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Return mask - BuildAncestor(track,mcEvent); - return fMask; -} - - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsBeautyMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from beauty decays - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasBeautyParent) & ! TESTBIT(mask,kHasLightParent) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsBJpsiMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon B->J/psi decays - if ( IsBeautyMu(track,mcEvent) ) { - Int_t imother = AliAnalysisMuonUtility::GetMotherIndex(track); - if ( imother >= 0 ) return ( mcEvent->GetTrack(imother)->PdgCode() == 443 ); - } - return kFALSE; -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsCharmMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from charm decays - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasCharmParent) && ! TESTBIT(mask,kHasBeautyParent) && ! TESTBIT(mask,kHasLightParent) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsDecayMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from light hadron decays - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasLightParent) && ! TESTBIT(mask,kIsSecondary) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsHadron ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Reconstructed hadron - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && ! TESTBIT(mask,kIsMuon) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsMuon ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Track is muon - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsQuarkoniumMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Mu from quarkonium decay - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasQuarkoniumParent) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsSecondaryMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from secondary decays in absorber - Long64_t mask = GetMask(track,mcEvent); - return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kIsSecondary) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsUnidentified ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Unidentified muon - Long64_t mask = GetMask(track,mcEvent); - return ( ! TESTBIT(mask,kIsID) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsWBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from W boson decays - return ( IsMuon(track,mcEvent) && CheckAncestor(track,mcEvent,24) ); -} - -//_________________________________________________________ -Bool_t AliUtilityMuonAncestor::IsZBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ) -{ - /// Muon from Z boson decays - return ( IsMuon(track,mcEvent) && CheckAncestor(track,mcEvent,kZ0) ); -} +/************************************************************************** + * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliUtilityMuonAncestor.cxx 47782 2011-02-24 18:37:31Z martinez $ */ + +//----------------------------------------------------------------------------- +/// \class AliUtilityMuonAncestor +/// Static utilities to get the muon ancestor in MC +/// +/// \author Diego Stocco +//----------------------------------------------------------------------------- + +#include "AliUtilityMuonAncestor.h" + +// ROOT includes +#include "TDatabasePDG.h" +#include "TParticlePDG.h" +#include "TPDGCode.h" +#include "TMCProcess.h" +#include "TMath.h" + +// STEER includes +#include "AliMCEvent.h" +#include "AliVParticle.h" +#include "AliMCParticle.h" +#include "AliAODMCParticle.h" +#include "AliLog.h" + +// PWGmuon includes +#include "AliAnalysisMuonUtility.h" + +/// \cond CLASSIMP +ClassImp(AliUtilityMuonAncestor) // Class implementation in ROOT context +/// \endcond + +//_________________________________________________________ +AliUtilityMuonAncestor::AliUtilityMuonAncestor() : +TObject(), +fPx(0.), +fPy(0.), +fPz(0.), +fMask(0), +fAncestor(-999) +{ + /// Default constructor +} + + +//_________________________________________________________ +AliUtilityMuonAncestor::~AliUtilityMuonAncestor() +{ + /// Default destructor +} + +//_________________________________________________________ +AliUtilityMuonAncestor::AliUtilityMuonAncestor(const AliUtilityMuonAncestor& obj) : +TObject(obj), +fPx(obj.fPx), +fPy(obj.fPy), +fPz(obj.fPz), +fMask(obj.fMask), +fAncestor(obj.fAncestor) +{ + /// Copy constructor +} + +//_________________________________________________________ +AliUtilityMuonAncestor& AliUtilityMuonAncestor::operator=(const AliUtilityMuonAncestor& obj) +{ + /// Copy operator + if ( this != &obj ) { + TObject::operator=(obj); + fPx = obj.fPx; + fPy = obj.fPy; + fPz = obj.fPz; + fMask = obj.fMask; + fAncestor = obj.fAncestor; + } + return *this; +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::BuildAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Build ancestor + + // If track is the same as the one in memory, do not re-build the track ancestor + if ( track->Px() == fPx && track->Py() == fPy && track->Pz() == fPz ) return kTRUE; + fPx = track->Px(); + fPy = track->Py(); + fPz = track->Pz(); + fMask = 0; + fAncestor = -999; + if ( ! mcEvent ) return kFALSE; + + AliVParticle* mcParticle = 0x0; + + if ( AliAnalysisMuonUtility::IsMCTrack(track) ) mcParticle = track; + else { + Int_t trackLabel = track->GetLabel(); + if ( trackLabel < 0 ) return kFALSE; + mcParticle = mcEvent->GetTrack(trackLabel); + } + + // Track is MC (or matches a MC track) + SETBIT(fMask,kIsID); + + Int_t recoPdg = mcParticle->PdgCode(); + + // Track is not a muon + if ( TMath::Abs(recoPdg) == 13 ) SETBIT(fMask,kIsMuon); + + Int_t imother = AliAnalysisMuonUtility::GetMotherIndex(mcParticle); + + while ( imother >= 0 ) { + AliVParticle* part = mcEvent->GetTrack(imother); + + Int_t absPdg = TMath::Abs(part->PdgCode()); + + // This is a quark + if ( absPdg < 10 ) return kTRUE; + + fAncestor = imother; + Bool_t isPrimary = AliAnalysisMuonUtility::IsPrimary(part, mcEvent); + + if ( isPrimary ) { + Int_t mpdg = absPdg%100000; + if ( mpdg >= 100 && mpdg < 10000 ) { + Int_t flv = Int_t ( mpdg / TMath::Power(10, Int_t(TMath::Log10(mpdg) ))); + if ( flv < 4 ) SETBIT(fMask,kHasLightParent); + else if ( flv >= 6 ) continue; + else { + TParticlePDG* partPdg = TDatabasePDG::Instance()->GetParticle(part->PdgCode()); + if ( partPdg && ! partPdg->AntiParticle() ) SETBIT(fMask,kHasQuarkoniumParent); + else if ( flv == 4 ) SETBIT(fMask,kHasCharmParent); + else SETBIT(fMask,kHasBeautyParent); + } + } // absPdg within 100 and 10000 + } // is primary + else { + UInt_t mcProcess = AliAnalysisMuonUtility::GetMCProcess(part); + if ( mcProcess == kPHadronic || + ( mcProcess == 0 && part->Zv() < -90. ) ) { + // The MC process is not well computed in the AODs of old MC productions + // In this case, declare the particle as "secondary" if it is produced inside the front absorber + SETBIT(fMask,kIsSecondary); +// return kTRUE; + } + } // is secondary + + imother = AliAnalysisMuonUtility::GetMotherIndex(part); + + } // loop on mothers + return kTRUE; +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::CheckAncestor ( AliVParticle* track, const AliMCEvent* mcEvent, Int_t ancestorPdg, Bool_t matchAbsPdg ) +{ + /// Check ancestor + Int_t pdgCode = GetAncestorPdg(track, mcEvent); + if ( matchAbsPdg ) { + pdgCode = TMath::Abs(pdgCode); + ancestorPdg = TMath::Abs(ancestorPdg); + } + return ( pdgCode == ancestorPdg ); +} + +//_________________________________________________________ +Int_t AliUtilityMuonAncestor::GetAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Return ancestor (compute it if necessary) + BuildAncestor(track,mcEvent); + return fAncestor; +} + +//_________________________________________________________ +Int_t AliUtilityMuonAncestor::GetAncestorPdg ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Return ancestor Pdg + if ( BuildAncestor(track,mcEvent) ) { + if ( fAncestor >= 0 ) return mcEvent->GetTrack(fAncestor)->PdgCode(); + } + return 0; +} + +//_________________________________________________________ +Long64_t AliUtilityMuonAncestor::GetMask ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Return mask + BuildAncestor(track,mcEvent); + return fMask; +} + + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsBeautyMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from beauty decays + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasBeautyParent) & ! TESTBIT(mask,kHasLightParent) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsBJpsiMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon B->J/psi decays + if ( IsBeautyMu(track,mcEvent) ) { + Int_t imother = AliAnalysisMuonUtility::GetMotherIndex(track); + if ( imother >= 0 ) return ( mcEvent->GetTrack(imother)->PdgCode() == 443 ); + } + return kFALSE; +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsCharmMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from charm decays + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasCharmParent) && ! TESTBIT(mask,kHasBeautyParent) && ! TESTBIT(mask,kHasLightParent) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsDecayMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from light hadron decays + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasLightParent) && ! TESTBIT(mask,kIsSecondary) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsHadron ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Reconstructed hadron + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && ! TESTBIT(mask,kIsMuon) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsMuon ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Track is muon + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsQuarkoniumMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Mu from quarkonium decay + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kHasQuarkoniumParent) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsSecondaryMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from secondary decays in absorber + Long64_t mask = GetMask(track,mcEvent); + return ( TESTBIT(mask,kIsID) && TESTBIT(mask,kIsMuon) && TESTBIT(mask,kIsSecondary) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsUnidentified ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Unidentified muon + Long64_t mask = GetMask(track,mcEvent); + return ( ! TESTBIT(mask,kIsID) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsWBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from W boson decays + return ( IsMuon(track,mcEvent) && CheckAncestor(track,mcEvent,24) ); +} + +//_________________________________________________________ +Bool_t AliUtilityMuonAncestor::IsZBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ) +{ + /// Muon from Z boson decays + return ( IsMuon(track,mcEvent) && CheckAncestor(track,mcEvent,kZ0) ); +} diff --git a/PWG/muon/AliUtilityMuonAncestor.h b/PWG/muon/AliUtilityMuonAncestor.h index f007aa37d74..7389ca0978c 100644 --- a/PWG/muon/AliUtilityMuonAncestor.h +++ b/PWG/muon/AliUtilityMuonAncestor.h @@ -1,68 +1,68 @@ -#ifndef ALIUTILITYMUONANCESTOR_H -#define ALIUTILITYMUONANCESTOR_H - -/* $Id: AliUtilityMuonAncestor.h 47782 2011-02-24 18:37:31Z martinez $ */ - -// -// MC utility to classify single muons -// -// Author: Diego Stocco -// - -#include "TObject.h" - -class AliMCEvent; -class AliVParticle; - -class AliUtilityMuonAncestor : public TObject { -public: - - AliUtilityMuonAncestor(); - ~AliUtilityMuonAncestor(); - AliUtilityMuonAncestor(const AliUtilityMuonAncestor& obj); - AliUtilityMuonAncestor& operator=(const AliUtilityMuonAncestor& obj); - - enum { - kIsID, - kIsMuon, - kIsSecondary, - kHasLightParent, - kHasCharmParent, - kHasBeautyParent, - kHasQuarkoniumParent - }; - - Bool_t CheckAncestor ( AliVParticle* track, const AliMCEvent* mcEvent, Int_t ancestorPdg, Bool_t matchAbsPdg = kTRUE ); - - Int_t GetAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ); - Int_t GetAncestorPdg ( AliVParticle* track, const AliMCEvent* mcEvent ); - Long64_t GetMask ( AliVParticle* track, const AliMCEvent* mcEvent ); - - Bool_t IsBeautyMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsBJpsiMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsCharmMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsDecayMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsHadron ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsMuon ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsQuarkoniumMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsSecondaryMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsUnidentified ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsWBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - Bool_t IsZBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ); - - -private: - Bool_t BuildAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ); - - - - Double_t fPx; ///< Particle px - Double_t fPy; ///< Particle py - Double_t fPz; ///< Particle pz - Long64_t fMask; ///< Mask - Int_t fAncestor; ///< Ancestor position in stack - - ClassDef(AliUtilityMuonAncestor, 0); -}; - -#endif +#ifndef ALIUTILITYMUONANCESTOR_H +#define ALIUTILITYMUONANCESTOR_H + +/* $Id: AliUtilityMuonAncestor.h 47782 2011-02-24 18:37:31Z martinez $ */ + +// +// MC utility to classify single muons +// +// Author: Diego Stocco +// + +#include "TObject.h" + +class AliMCEvent; +class AliVParticle; + +class AliUtilityMuonAncestor : public TObject { +public: + + AliUtilityMuonAncestor(); + ~AliUtilityMuonAncestor(); + AliUtilityMuonAncestor(const AliUtilityMuonAncestor& obj); + AliUtilityMuonAncestor& operator=(const AliUtilityMuonAncestor& obj); + + enum { + kIsID, + kIsMuon, + kIsSecondary, + kHasLightParent, + kHasCharmParent, + kHasBeautyParent, + kHasQuarkoniumParent + }; + + Bool_t CheckAncestor ( AliVParticle* track, const AliMCEvent* mcEvent, Int_t ancestorPdg, Bool_t matchAbsPdg = kTRUE ); + + Int_t GetAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ); + Int_t GetAncestorPdg ( AliVParticle* track, const AliMCEvent* mcEvent ); + Long64_t GetMask ( AliVParticle* track, const AliMCEvent* mcEvent ); + + Bool_t IsBeautyMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsBJpsiMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsCharmMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsDecayMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsHadron ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsMuon ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsQuarkoniumMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsSecondaryMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsUnidentified ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsWBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + Bool_t IsZBosonMu ( AliVParticle* track, const AliMCEvent* mcEvent ); + + +private: + Bool_t BuildAncestor ( AliVParticle* track, const AliMCEvent* mcEvent ); + + + + Double_t fPx; ///< Particle px + Double_t fPy; ///< Particle py + Double_t fPz; ///< Particle pz + Long64_t fMask; ///< Mask + Int_t fAncestor; ///< Ancestor position in stack + + ClassDef(AliUtilityMuonAncestor, 0); +}; + +#endif diff --git a/PWGCF/Correlations/DPhi/AliAnalysisTaskMinijet.h b/PWGCF/Correlations/DPhi/AliAnalysisTaskMinijet.h index 7fa97ab7b2c..85a3a1c92e9 100644 --- a/PWGCF/Correlations/DPhi/AliAnalysisTaskMinijet.h +++ b/PWGCF/Correlations/DPhi/AliAnalysisTaskMinijet.h @@ -1,199 +1,199 @@ -#ifndef ALIANALYSISTASKMINIJET_H -#define ALIANALYSISTASKMINIJET_H - -// Two-particle correlations using all particles over pt threshold -// Extract mini-jet yield and fragmentation properties via Delta-Phi histograms -// Can use ESD or AOD, reconstructed and Monte Carlo data as input -// Author: eva.sicking@cern.ch - -class TList; -class TH1F; -class TH2F; -class TProfile; -class THnSparse; -class AliESDtrackCuts; - -#include "AliAnalysisTaskSE.h" -#include - -class AliAnalysisTaskMinijet : public AliAnalysisTaskSE { - public: - AliAnalysisTaskMinijet(const char *name=""); - virtual ~AliAnalysisTaskMinijet(); - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t* option); - virtual void Terminate(Option_t *); - virtual void SetCuts(AliESDtrackCuts* cuts){fCuts = cuts;} - - void SetUseMC(Bool_t useMC=kTRUE, Bool_t mcOnly=kFALSE) {fUseMC = useMC; fMcOnly=mcOnly;} - void SetAnalyseOnlyPrimaries(Bool_t analysePrimOnly) {fAnalysePrimOnly = analysePrimOnly;} // not used anymore - void SetPtRange(Float_t ptMin, Float_t ptMax) {fPtMin = ptMin; fPtMax = ptMax; } - void SetTriggerPtCut(Float_t triggerPtCut) {fTriggerPtCut = triggerPtCut;} - void SetAssociatePtCut(Float_t associatePtCut) {fAssociatePtCut = associatePtCut;} - void SetModeEsdAod(Int_t mode) {fMode = mode;} - void SetTriggerMask(Int_t triggerType) {fTriggerType = triggerType;} - void SetFilterBit(Int_t filterBit) {fFilterBit = filterBit;} - void SetMaxVertexZ(Float_t vertexZCut) {fVertexZCut = vertexZCut;} - void SetMaxEta(Float_t etaCut) {fEtaCut = etaCut;} - void SetMaxEtaSeed(Float_t etaCutSeed) {fEtaCutSeed = etaCutSeed;} - void SetSelectParticles(Int_t selectParticles) {fSelectParticles = selectParticles;} - void SetSelectParticlesAssoc(Int_t selectParticlesAssoc) {fSelectParticlesAssoc = selectParticlesAssoc;} - void SetCheckSDD(Bool_t checkSDD, Int_t selOption) {fCheckSDD = checkSDD; fSelOption = selOption;} - void SetCorrStrangeness(Bool_t corrStrangeness) {fCorrStrangeness = corrStrangeness;} - void SetThreeParticleCorrelation(Bool_t threeParticleCorr) {fThreeParticleCorr = threeParticleCorr;} - void SetRejectCorrupted(Bool_t rejectChunks, Int_t nTPC) {fRejectChunks = rejectChunks; fNTPC = nTPC;} - - void SetCentralityMethod(TString centralityMethod) {fCentralityMethod = centralityMethod;} - - - private: - - Double_t ReadEventESD (std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - Double_t ReadEventESDRecMcProp(std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - Double_t ReadEventESDMC (std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - - Double_t ReadEventAOD (std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - Double_t ReadEventAODRecMcProp(std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - Double_t ReadEventAODMC (std::vector &pt, std::vector &eta, - std::vector &phi, std::vector &charge, - std::vector &strangnessWeight, - std::vector &nTracksTracklets, const Int_t step); - - void Analyse (const std::vector &pt, - const std::vector &eta, - const std::vector &phi, - const std::vector &charge, - const std::vector &strangnessWeight, - const Double_t ntacks, const Int_t ntacklets=0, - const Int_t nAll=0, const Int_t step=0); - - Bool_t SelectParticlePlusCharged(const Short_t charge, const Int_t pdg, const Bool_t prim); - Bool_t SelectParticle(const Short_t charge, const Int_t pdg, const Bool_t prim); - Bool_t CheckEvent(const Bool_t recVertex); - const Double_t* CreateLogAxis(const Int_t nbins, const Double_t xmin, const Double_t xmax); - Bool_t CheckLikeSign(const Short_t chargeEventAxis, const Short_t chargeOthers); - - - Bool_t fUseMC; // flag for Monte Carlo usages - Bool_t fMcOnly; // flag defines, if only MC data is used in analysis or also reconstructed data - Double_t fBSign; // magnetic field - Bool_t fAnalysePrimOnly; // flag for analysis of primaries only (also in reconstructed data) - Float_t fPtMin; // set lower limit for pt acceptance for mutliplicity defintion - Float_t fPtMax; // set upper limit for pt acceptance for mutliplicity defintion - AliESDtrackCuts* fCuts; // List of cuts for ESDs - Float_t fTriggerPtCut; // cut on particle pt used as event axis - Float_t fAssociatePtCut; // cut on particle pt used for correlations - Int_t fMode; // ESD(=0) of AOD(=1) reading - Int_t fTriggerType; // sets trigger -> AliVEvent::kMB, AliVEvent::kHighMult - Int_t fFilterBit; // Filter bit written in ESD filter, select track type - Float_t fVertexZCut; // vertex cut - Float_t fEtaCut; // eta acceptance cut - Float_t fEtaCutSeed; // eta acceptance cut for seed - Int_t fSelectParticles; // only in cas of MC: use also neutral particles or not - Int_t fSelectParticlesAssoc; // only in cas of MC: use also neutral particles or not - Bool_t fCheckSDD; // check if SDD was in read out partition (needed for LHC11a) - Int_t fSelOption; // 0 = use hit in SDD for event selection, 1 = use trigger for event selection - Bool_t fCorrStrangeness; // for data correction -> Pythia simulations underestimate contamination from strangness - Bool_t fThreeParticleCorr; // perform three particle correlation - Bool_t fRejectChunks; // rejection of chunks in which no ITS tracks are reconstructed - Int_t fNTPC; // track number limit for rejection decision. - - AliESDEvent *fESDEvent; //! esd event - AliAODEvent *fAODEvent; //! aod event - Double_t fNMcPrimAccept; // global variable for mc multiplucity - Double_t fNRecAccept; // global variable for rec multiplucity - Float_t fNRecAcceptStrangeCorr; // global variable for rec multiplucity - Double_t fNMcPrimAcceptTracklet; // global variable for mc multiplucity - Double_t fNRecAcceptTracklet; // global variable for rec multiplucity - Float_t fVzEvent; // global variable for rec vertex position - Double_t fMeanPtRec; // global variable for rec mean pt - Double_t fLeadingPtRec; // global variable for rec mean pt - - TList *fHists; // output list - TH1F *fStep; // how many events have passed which correction step - TH1F *fEventStat; // how many events are accepted by trigger, vertex selection, 1 track in acceptance (for real data) - TH1F *fHistPt; // Pt spectrum ESD - TH1F *fHistPtMC; // Pt spectrum MC - TH2F *fNContrNtracklets; // control histogram for vertex->nContributers and number of tracklets - TH2F *fNContrNtracks; // control histogram for vertex->nContributers and number of tracks - TH2F *fCorruptedChunks; // control histogram: TPC tracks versus ITS-TPC-tracks - TH2F *fCorruptedChunksAfter; // control histogram: TPC tracks versus ITS-TPC-tracks - - TH2F *fNmcNch; // N mc - N ch rec - TProfile *fPNmcNch; // N mc - N ch rec - TH2F *fNmcNchVtx; // N mc - N ch rec for events with reconstructed vertex - TH2F *fNmcNchVtxStrangeCorr; // N mc - N ch rec for events with reconstructed vertex + strangeness correction - TProfile *fPNmcNchVtx; // N mc - N ch rec for events with reconstructed vertex - TH2F *fNmcNchTracklet; // N mc - N ch rec - TProfile *fPNmcNchTracklet; // N mc - N ch rec - TH2F *fNmcNchVtxTracklet; // N mc - N ch rec for events with reconstructed vertex - TProfile *fPNmcNchVtxTracklet; // N mc - N ch rec for events with reconstructed vertex - TH2F *fChargedPi0; // charged versus charged+Pi0 - TH1F *fVertexCheck; // check which fraction of events has vtx_rec but no good vtx_mc - TH1F *fPropagateDca; // check of AliAODtrack::PropagateToDca - - THnSparse *fMapSingleTrig[8]; //! multi-dim histo for trigger track properties - THnSparse *fMapPair[8]; //! multi-dim histo for pair properties - THnSparse *fMapEvent[8]; //! multi-dim histo for event properties - THnSparse *fMapAll[8]; //! multi-dim histo for properties of all analysed tracks - THnSparse *fMapThree[8]; //! multi-dim histo for properties of three particle correlations - - TH1F * fVertexZ[8]; // z of vertex - TH1F * fNcharge[8]; // pt - TH1F * fPt[8]; // pt - TH1F * fEta[8]; // eta - TH1F * fPhi[8]; // phi - TH1F * fDcaXY[8]; // dca xy direction - TH1F * fDcaZ[8]; // dca z direction - - TH1F * fPtSeed[8]; // pt of seed (event axis) - TH1F * fEtaSeed[8]; // eta of seed - TH1F * fPhiSeed[8]; // phi of seed - - TH1F * fPtOthers[8]; // pt of all other particels used in dEtadPhi - TH1F * fEtaOthers[8]; // eta of all other particels used in dEtadPhi - TH1F * fPhiOthers[8]; // phi of all other particels used in dEtadPhi - TH2F * fPtEtaOthers[8]; // pt-eta of all other particels used in dEtadPhi - - - TH2F * fPhiEta[8]; // eta - phi - TH2F * fDPhiDEtaEventAxis[8]; // correlation dEta-dPhi towards event axis - TH2F * fDPhiDEtaEventAxisSeeds[8]; // correlation dEta-dPhi towards event axis of trigger particles - TH1F * fTriggerNch[8]; // number of triggers with accepted-track number - TH2F * fTriggerNchSeeds[8]; // number of triggers with accepted-track number - TH1F * fTriggerTracklet[8]; // number of triggers with accepted-tracklet number - TH2F * fNch07Nch[8]; // nCharged with pT>fTriggerPtCut vs nCharged - TProfile * fPNch07Nch[8]; // nCharged with pT>fTriggerPtCut vs nCharged - - TH2F * fNch07Tracklet[8]; // nCharged with pT>fTriggerPtCut vs nTracklet - TH2F * fNchTracklet[8]; // nCharged vs nTracklet - TProfile * fPNch07Tracklet[8]; // nCharged with pT>fTriggerPtCut vs nTracklet - - TH1F * fDPhiEventAxis[8]; // delta phi of associate tracks to event axis - TH2F * fDPhi1DPhi2[8]; // dPhi1 versus dPhi2: three particle correlation test - - TString fCentralityMethod; //centrality pA - - AliAnalysisTaskMinijet(const AliAnalysisTaskMinijet&); // not implemented - AliAnalysisTaskMinijet& operator=(const AliAnalysisTaskMinijet&); // not implemented - - ClassDef(AliAnalysisTaskMinijet, 2); // mini jet analysis with two particle correlations -}; - -#endif +#ifndef ALIANALYSISTASKMINIJET_H +#define ALIANALYSISTASKMINIJET_H + +// Two-particle correlations using all particles over pt threshold +// Extract mini-jet yield and fragmentation properties via Delta-Phi histograms +// Can use ESD or AOD, reconstructed and Monte Carlo data as input +// Author: eva.sicking@cern.ch + +class TList; +class TH1F; +class TH2F; +class TProfile; +class THnSparse; +class AliESDtrackCuts; + +#include "AliAnalysisTaskSE.h" +#include + +class AliAnalysisTaskMinijet : public AliAnalysisTaskSE { + public: + AliAnalysisTaskMinijet(const char *name=""); + virtual ~AliAnalysisTaskMinijet(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t* option); + virtual void Terminate(Option_t *); + virtual void SetCuts(AliESDtrackCuts* cuts){fCuts = cuts;} + + void SetUseMC(Bool_t useMC=kTRUE, Bool_t mcOnly=kFALSE) {fUseMC = useMC; fMcOnly=mcOnly;} + void SetAnalyseOnlyPrimaries(Bool_t analysePrimOnly) {fAnalysePrimOnly = analysePrimOnly;} // not used anymore + void SetPtRange(Float_t ptMin, Float_t ptMax) {fPtMin = ptMin; fPtMax = ptMax; } + void SetTriggerPtCut(Float_t triggerPtCut) {fTriggerPtCut = triggerPtCut;} + void SetAssociatePtCut(Float_t associatePtCut) {fAssociatePtCut = associatePtCut;} + void SetModeEsdAod(Int_t mode) {fMode = mode;} + void SetTriggerMask(Int_t triggerType) {fTriggerType = triggerType;} + void SetFilterBit(Int_t filterBit) {fFilterBit = filterBit;} + void SetMaxVertexZ(Float_t vertexZCut) {fVertexZCut = vertexZCut;} + void SetMaxEta(Float_t etaCut) {fEtaCut = etaCut;} + void SetMaxEtaSeed(Float_t etaCutSeed) {fEtaCutSeed = etaCutSeed;} + void SetSelectParticles(Int_t selectParticles) {fSelectParticles = selectParticles;} + void SetSelectParticlesAssoc(Int_t selectParticlesAssoc) {fSelectParticlesAssoc = selectParticlesAssoc;} + void SetCheckSDD(Bool_t checkSDD, Int_t selOption) {fCheckSDD = checkSDD; fSelOption = selOption;} + void SetCorrStrangeness(Bool_t corrStrangeness) {fCorrStrangeness = corrStrangeness;} + void SetThreeParticleCorrelation(Bool_t threeParticleCorr) {fThreeParticleCorr = threeParticleCorr;} + void SetRejectCorrupted(Bool_t rejectChunks, Int_t nTPC) {fRejectChunks = rejectChunks; fNTPC = nTPC;} + + void SetCentralityMethod(TString centralityMethod) {fCentralityMethod = centralityMethod;} + + + private: + + Double_t ReadEventESD (std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + Double_t ReadEventESDRecMcProp(std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + Double_t ReadEventESDMC (std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + + Double_t ReadEventAOD (std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + Double_t ReadEventAODRecMcProp(std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + Double_t ReadEventAODMC (std::vector &pt, std::vector &eta, + std::vector &phi, std::vector &charge, + std::vector &strangnessWeight, + std::vector &nTracksTracklets, const Int_t step); + + void Analyse (const std::vector &pt, + const std::vector &eta, + const std::vector &phi, + const std::vector &charge, + const std::vector &strangnessWeight, + const Double_t ntacks, const Int_t ntacklets=0, + const Int_t nAll=0, const Int_t step=0); + + Bool_t SelectParticlePlusCharged(const Short_t charge, const Int_t pdg, const Bool_t prim); + Bool_t SelectParticle(const Short_t charge, const Int_t pdg, const Bool_t prim); + Bool_t CheckEvent(const Bool_t recVertex); + const Double_t* CreateLogAxis(const Int_t nbins, const Double_t xmin, const Double_t xmax); + Bool_t CheckLikeSign(const Short_t chargeEventAxis, const Short_t chargeOthers); + + + Bool_t fUseMC; // flag for Monte Carlo usages + Bool_t fMcOnly; // flag defines, if only MC data is used in analysis or also reconstructed data + Double_t fBSign; // magnetic field + Bool_t fAnalysePrimOnly; // flag for analysis of primaries only (also in reconstructed data) + Float_t fPtMin; // set lower limit for pt acceptance for mutliplicity defintion + Float_t fPtMax; // set upper limit for pt acceptance for mutliplicity defintion + AliESDtrackCuts* fCuts; // List of cuts for ESDs + Float_t fTriggerPtCut; // cut on particle pt used as event axis + Float_t fAssociatePtCut; // cut on particle pt used for correlations + Int_t fMode; // ESD(=0) of AOD(=1) reading + Int_t fTriggerType; // sets trigger -> AliVEvent::kMB, AliVEvent::kHighMult + Int_t fFilterBit; // Filter bit written in ESD filter, select track type + Float_t fVertexZCut; // vertex cut + Float_t fEtaCut; // eta acceptance cut + Float_t fEtaCutSeed; // eta acceptance cut for seed + Int_t fSelectParticles; // only in cas of MC: use also neutral particles or not + Int_t fSelectParticlesAssoc; // only in cas of MC: use also neutral particles or not + Bool_t fCheckSDD; // check if SDD was in read out partition (needed for LHC11a) + Int_t fSelOption; // 0 = use hit in SDD for event selection, 1 = use trigger for event selection + Bool_t fCorrStrangeness; // for data correction -> Pythia simulations underestimate contamination from strangness + Bool_t fThreeParticleCorr; // perform three particle correlation + Bool_t fRejectChunks; // rejection of chunks in which no ITS tracks are reconstructed + Int_t fNTPC; // track number limit for rejection decision. + + AliESDEvent *fESDEvent; //! esd event + AliAODEvent *fAODEvent; //! aod event + Double_t fNMcPrimAccept; // global variable for mc multiplucity + Double_t fNRecAccept; // global variable for rec multiplucity + Float_t fNRecAcceptStrangeCorr; // global variable for rec multiplucity + Double_t fNMcPrimAcceptTracklet; // global variable for mc multiplucity + Double_t fNRecAcceptTracklet; // global variable for rec multiplucity + Float_t fVzEvent; // global variable for rec vertex position + Double_t fMeanPtRec; // global variable for rec mean pt + Double_t fLeadingPtRec; // global variable for rec mean pt + + TList *fHists; // output list + TH1F *fStep; // how many events have passed which correction step + TH1F *fEventStat; // how many events are accepted by trigger, vertex selection, 1 track in acceptance (for real data) + TH1F *fHistPt; // Pt spectrum ESD + TH1F *fHistPtMC; // Pt spectrum MC + TH2F *fNContrNtracklets; // control histogram for vertex->nContributers and number of tracklets + TH2F *fNContrNtracks; // control histogram for vertex->nContributers and number of tracks + TH2F *fCorruptedChunks; // control histogram: TPC tracks versus ITS-TPC-tracks + TH2F *fCorruptedChunksAfter; // control histogram: TPC tracks versus ITS-TPC-tracks + + TH2F *fNmcNch; // N mc - N ch rec + TProfile *fPNmcNch; // N mc - N ch rec + TH2F *fNmcNchVtx; // N mc - N ch rec for events with reconstructed vertex + TH2F *fNmcNchVtxStrangeCorr; // N mc - N ch rec for events with reconstructed vertex + strangeness correction + TProfile *fPNmcNchVtx; // N mc - N ch rec for events with reconstructed vertex + TH2F *fNmcNchTracklet; // N mc - N ch rec + TProfile *fPNmcNchTracklet; // N mc - N ch rec + TH2F *fNmcNchVtxTracklet; // N mc - N ch rec for events with reconstructed vertex + TProfile *fPNmcNchVtxTracklet; // N mc - N ch rec for events with reconstructed vertex + TH2F *fChargedPi0; // charged versus charged+Pi0 + TH1F *fVertexCheck; // check which fraction of events has vtx_rec but no good vtx_mc + TH1F *fPropagateDca; // check of AliAODtrack::PropagateToDca + + THnSparse *fMapSingleTrig[8]; //! multi-dim histo for trigger track properties + THnSparse *fMapPair[8]; //! multi-dim histo for pair properties + THnSparse *fMapEvent[8]; //! multi-dim histo for event properties + THnSparse *fMapAll[8]; //! multi-dim histo for properties of all analysed tracks + THnSparse *fMapThree[8]; //! multi-dim histo for properties of three particle correlations + + TH1F * fVertexZ[8]; // z of vertex + TH1F * fNcharge[8]; // pt + TH1F * fPt[8]; // pt + TH1F * fEta[8]; // eta + TH1F * fPhi[8]; // phi + TH1F * fDcaXY[8]; // dca xy direction + TH1F * fDcaZ[8]; // dca z direction + + TH1F * fPtSeed[8]; // pt of seed (event axis) + TH1F * fEtaSeed[8]; // eta of seed + TH1F * fPhiSeed[8]; // phi of seed + + TH1F * fPtOthers[8]; // pt of all other particels used in dEtadPhi + TH1F * fEtaOthers[8]; // eta of all other particels used in dEtadPhi + TH1F * fPhiOthers[8]; // phi of all other particels used in dEtadPhi + TH2F * fPtEtaOthers[8]; // pt-eta of all other particels used in dEtadPhi + + + TH2F * fPhiEta[8]; // eta - phi + TH2F * fDPhiDEtaEventAxis[8]; // correlation dEta-dPhi towards event axis + TH2F * fDPhiDEtaEventAxisSeeds[8]; // correlation dEta-dPhi towards event axis of trigger particles + TH1F * fTriggerNch[8]; // number of triggers with accepted-track number + TH2F * fTriggerNchSeeds[8]; // number of triggers with accepted-track number + TH1F * fTriggerTracklet[8]; // number of triggers with accepted-tracklet number + TH2F * fNch07Nch[8]; // nCharged with pT>fTriggerPtCut vs nCharged + TProfile * fPNch07Nch[8]; // nCharged with pT>fTriggerPtCut vs nCharged + + TH2F * fNch07Tracklet[8]; // nCharged with pT>fTriggerPtCut vs nTracklet + TH2F * fNchTracklet[8]; // nCharged vs nTracklet + TProfile * fPNch07Tracklet[8]; // nCharged with pT>fTriggerPtCut vs nTracklet + + TH1F * fDPhiEventAxis[8]; // delta phi of associate tracks to event axis + TH2F * fDPhi1DPhi2[8]; // dPhi1 versus dPhi2: three particle correlation test + + TString fCentralityMethod; //centrality pA + + AliAnalysisTaskMinijet(const AliAnalysisTaskMinijet&); // not implemented + AliAnalysisTaskMinijet& operator=(const AliAnalysisTaskMinijet&); // not implemented + + ClassDef(AliAnalysisTaskMinijet, 2); // mini jet analysis with two particle correlations +}; + +#endif diff --git a/PWGCF/Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.h b/PWGCF/Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.h index 5d59f51bd73..e6bc79044b2 100644 --- a/PWGCF/Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.h +++ b/PWGCF/Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.h @@ -156,7 +156,7 @@ private: ClassDef( AliPIDCorrParticle, 1); // class which contains only quantities requires for this analysis to reduce memory consumption for event mixing }; - + #endif diff --git a/PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx b/PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx index f55cb1fdf66..5992aadac17 100644 --- a/PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx +++ b/PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx @@ -1,2729 +1,2729 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -#include "AliTwoParticlePIDCorr.h" -#include "AliVParticle.h" -#include "TFormula.h" -#include "TAxis.h" -#include "TChain.h" -#include "TTree.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TH3F.h" -#include "TList.h" -#include "TFile.h" - -#include "AliCentrality.h" -#include "Riostream.h" - -#include -#include -#include "AliESDpid.h" -#include "AliAODpidUtil.h" -#include - -#include -#include -#include "AliAODInputHandler.h" - -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" -#include "AliCentrality.h" - -#include "AliVEvent.h" -#include "AliAODEvent.h" -#include "AliAODTrack.h" -#include "AliVTrack.h" - -#include "THnSparse.h" - -#include "AliAODMCHeader.h" -#include "AliAODMCParticle.h" -#include "AliMCEventHandler.h" -#include "AliMCEvent.h" -#include "AliMCParticle.h" -#include "TParticle.h" -#include -#include - -#include "AliGenCocktailEventHeader.h" -#include "AliGenEventHeader.h" - -#include "AliEventPoolManager.h" -//#include "AliAnalysisUtils.h" -using namespace AliPIDNameSpace; -using namespace std; - -ClassImp(AliTwoParticlePIDCorr) -ClassImp(LRCParticlePID) -//________________________________________________________________________ -AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be initialised here -:AliAnalysisTaskSE(), - fOutput(0), - fCentralityMethod("V0A"), - fSampleType("pPb"), -fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default) - trkVtx(0), - zvtx(0), - fFilterBit(768), - fzvtxcut(10.0), - ffilltrigassoUNID(kFALSE), - ffilltrigUNIDassoID(kFALSE), - ffilltrigIDassoUNID(kTRUE), - ffilltrigIDassoID(kFALSE), - ffilltrigIDassoIDMCTRUTH(kFALSE), - fPtOrderMCTruth(kFALSE), - fTriggerSpeciesSelection(kFALSE), - fAssociatedSpeciesSelection(kFALSE), - fTriggerSpecies(SpPion), - fAssociatedSpecies(SpPion), - fCustomBinning(""), - fBinningString(""), - fcontainPIDtrig(kTRUE), - fcontainPIDasso(kFALSE), -//frejectPileUp(kFALSE), - fminPt(0.2), - fmaxPt(10.0), - fmineta(-0.8), - fmaxeta(0.8), - fminprotonsigmacut(-6.0), - fmaxprotonsigmacut(-3.0), - fminpionsigmacut(0.0), - fmaxpionsigmacut(4.0), - fselectprimaryTruth(kTRUE), - fonlyprimarydatareco(kFALSE), - fdcacut(kFALSE), - fdcacutvalue(3.0), - ffillhistQAReco(kFALSE), - ffillhistQATruth(kFALSE), - kTrackVariablesPair(0), - fminPtTrig(0), - fmaxPtTrig(0), - fminPtComboeff(2.0), - fmaxPtComboeff(4.0), - fminPtAsso(0), - fmaxPtAsso(0), - fhistcentrality(0), - fEventCounter(0), - fEtaSpectrasso(0), - fphiSpectraasso(0), - MCtruthpt(0), - MCtrutheta(0), - MCtruthphi(0), - MCtruthpionpt(0), - MCtruthpioneta(0), - MCtruthpionphi(0), - MCtruthkaonpt(0), - MCtruthkaoneta(0), - MCtruthkaonphi(0), - MCtruthprotonpt(0), - MCtruthprotoneta(0), - MCtruthprotonphi(0), - fPioncont(0), - fKaoncont(0), - fProtoncont(0), - fCentralityCorrelation(0x0), - fHistoTPCdEdx(0x0), - fHistoTOFbeta(0x0), - fTPCTOFPion3d(0), - fTPCTOFKaon3d(0), - fTPCTOFProton3d(0), - fPionPt(0), - fPionEta(0), - fPionPhi(0), - fKaonPt(0), - fKaonEta(0), - fKaonPhi(0), - fProtonPt(0), - fProtonEta(0), - fProtonPhi(0), - fCorrelatonTruthPrimary(0), - fCorrelatonTruthPrimarymix(0), - fTHnCorrUNID(0), - fTHnCorrUNIDmix(0), - fTHnCorrID(0), - fTHnCorrIDmix(0), - fTHnCorrIDUNID(0), - fTHnCorrIDUNIDmix(0), - fTHnTrigcount(0), - fTHnTrigcountMCTruthPrim(0), - fPoolMgr(0x0), - fArrayMC(0), - fAnalysisType("MCAOD"), - fefffilename(""), - twoTrackEfficiencyCutValue(0.02), -//fControlConvResoncances(0), - fPID(NULL), - eventno(0), - fPtTOFPIDmin(0.6), - fPtTOFPIDmax(4.0), - fRequestTOFPID(kTRUE), - fPIDType(NSigmaTPCTOF), - fNSigmaPID(3), - fUseExclusiveNSigma(kFALSE), - fRemoveTracksT0Fill(kFALSE), -fSelectCharge(0), -fTriggerSelectCharge(0), -fAssociatedSelectCharge(0), -fTriggerRestrictEta(-1), -fEtaOrdering(kFALSE), -fCutConversions(kFALSE), -fCutResonances(kFALSE), -fRejectResonanceDaughters(-1), - fOnlyOneEtaSide(0), -fInjectedSignals(kFALSE), - fRemoveWeakDecays(kFALSE), -fRemoveDuplicates(kFALSE), - fapplyTrigefficiency(kFALSE), - fapplyAssoefficiency(kFALSE), - ffillefficiency(kFALSE), - fmesoneffrequired(kFALSE), - fkaonprotoneffrequired(kFALSE), -//fAnalysisUtils(0x0), - fDCAXYCut(0) - -{ - for ( Int_t i = 0; i < 16; i++) { - fHistQA[i] = NULL; - } - - for ( Int_t i = 0; i < 6; i++ ){ - fTHnrecomatchedallPid[i] = NULL; - fTHngenprimPidTruth[i] = NULL; - effcorection[i]=NULL; - //effmap[i]=NULL; - - } - - for(Int_t ipart=0;ipartIsProofMode()) { - delete fOutput; - - } - if (fPID) delete fPID; - - } -//________________________________________________________________________ -Float_t AliTwoParticlePIDCorr::PhiRange(Float_t DPhi) - -{ - // - // Puts the argument in the range [-pi/2,3 pi/2]. - // - - if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi(); - if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi(); - - return DPhi; - -} -//________________________________________________________________________ -void AliTwoParticlePIDCorr::UserCreateOutputObjects() -{ - // Create histograms - // Called once (on the worker node) - AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); - AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); - fPID = inputHandler->GetPIDResponse(); - - //AliAnalysisUtils *fUtils = new AliAnalysisUtils(); - -//get the efficiency correction map - - - fOutput = new TList(); - fOutput->SetOwner(); // IMPORTANT! - - Int_t centmultbins=10; - Double_t centmultmin=0.0; - Double_t centmultmax=100.0; - if(fSampleType=="pPb" || fSampleType=="PbPb") - { - centmultbins=10; - centmultmin=0.0; - centmultmax=100.0; - } - if(fSampleType=="pp") - { - centmultbins=10; - centmultmin=0.0; - centmultmax=200.0; - } - -fhistcentrality=new TH1F("fhistcentrality","fhistcentrality",centmultbins*4,centmultmin,centmultmax); -fOutput->Add(fhistcentrality); - - fEventCounter = new TH1F("fEventCounter","EventCounter", 10, 0.5,10.5); - fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed"); - fEventCounter->GetXaxis()->SetBinLabel(2,"Have a vertex"); - fEventCounter->GetXaxis()->SetBinLabel(5,"After vertex Cut"); - fEventCounter->GetXaxis()->SetBinLabel(6,"Within 0-100% centrality"); - fEventCounter->GetXaxis()->SetBinLabel(7,"Event Analyzed"); - //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished"); - fOutput->Add(fEventCounter); - -fEtaSpectrasso=new TH2F("fEtaSpectraasso","fEtaSpectraasso",180,-0.9,0.9,100,0.,20. ); -fOutput->Add(fEtaSpectrasso); - -fphiSpectraasso=new TH2F("fphiSpectraasso","fphiSpectraasso",72,0,2*TMath::Pi(),100,0.,20.); -fOutput->Add(fphiSpectraasso); - - - if(fSampleType=="pPb" || fSampleType=="PbPb"){ fCentralityCorrelation = new TH2D("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 20000, 0,40000); - fOutput->Add(fCentralityCorrelation); - } - -fHistoTPCdEdx = new TH2F("hHistoTPCdEdx", ";p_{T} (GeV/c);dE/dx (au.)",200,0.0,10.0,500, 0., 500.); -fOutput->Add(fHistoTPCdEdx); -fHistoTOFbeta = new TH2F(Form("hHistoTOFbeta"), ";p_{T} (GeV/c);v/c",70, 0., 7., 500, 0.1, 1.1); - fOutput->Add(fHistoTOFbeta); - - fTPCTOFPion3d=new TH3F ("fTPCTOFpion3d", "fTPCTOFpion3d",100,0., 10., 120,-60.,60.,120,-60.,60); - fOutput->Add(fTPCTOFPion3d); - - fTPCTOFKaon3d=new TH3F ("fTPCTOFKaon3d", "fTPCTOFKaon3d",100,0., 10., 120,-60.,60.,120,-60.,60); - fOutput->Add(fTPCTOFKaon3d); - - fTPCTOFProton3d=new TH3F ("fTPCTOFProton3d", "fTPCTOFProton3d",100,0., 10., 120,-60.,60.,120,-60.,60); - fOutput->Add(fTPCTOFProton3d); - -if(ffillhistQAReco) - { - fPionPt = new TH1F("fHistQAPionPt","p_{T} distribution",200,0.,10.); - fOutput->Add(fPionPt); - fPionEta= new TH1F("fHistQAPionEta","#eta distribution",360,-1.8,1.8); - fOutput->Add(fPionEta); - fPionPhi = new TH1F("fHistQAPionPhi","#phi distribution",340,0,6.8); - fOutput->Add(fPionPhi); - - fKaonPt = new TH1F("fHistQAKaonPt","p_{T} distribution",200,0.,10.); - fOutput->Add(fKaonPt); - fKaonEta= new TH1F("fHistQAKaonEta","#eta distribution",360,-1.8,1.8); - fOutput->Add(fKaonEta); - fKaonPhi = new TH1F("fHistQAKaonPhi","#phi distribution",340,0,6.8); - fOutput->Add(fKaonPhi); - - fProtonPt = new TH1F("fHistQAProtonPt","p_{T} distribution",200,0.,10.); - fOutput->Add(fProtonPt); - fProtonEta= new TH1F("fHistQAProtonEta","#eta distribution",360,-1.8,1.8); - fOutput->Add(fProtonEta); - fProtonPhi= new TH1F("fHistQAProtonPhi","#phi distribution",340,0,6.8); - fOutput->Add(fProtonPhi); - } - - fHistQA[0] = new TH1F("fHistQAvx", "Histo Vx All ", 50, -5., 5.); - fHistQA[1] = new TH1F("fHistQAvy", "Histo Vy All", 50, -5., 5.); - fHistQA[2] = new TH1F("fHistQAvz", "Histo Vz All", 50, -25., 25.); - fHistQA[3] = new TH1F("fHistQAvxA", "Histo Vx After Cut ", 50, -5., 5.); - fHistQA[4] = new TH1F("fHistQAvyA", "Histo Vy After Cut", 50, -5., 5.); - fHistQA[5] = new TH1F("fHistQAvzA", "Histo Vz After Cut", 50, -25., 25.); - fHistQA[6] = new TH1F("fHistQADcaXyC", "Histo DCAxy after cut", 50, -5., 5.); - fHistQA[7] = new TH1F("fHistQADcaZC", "Histo DCAz after cut", 50, -5., 5.); - fHistQA[8] = new TH1F("fHistQAPt","p_{T} distribution",200,0.,10.); - fHistQA[9] = new TH1F("fHistQAEta","#eta distribution",360,-1.8,1.8); - fHistQA[10] = new TH1F("fHistQAPhi","#phi distribution",340,0,6.8); - fHistQA[11] = new TH1F("fHistQANCls","Number of TPC cluster",200,0,200); - fHistQA[13] = new TH1F("fHistQAChi2","Chi2 per NDF",100,0,10); - fHistQA[12] = new TH1F("fHistQANCls1","Number of TPC cluster1",200,0,200); - fHistQA[14] = new TH1F("nCrossedRowsTPC","Number of TPC ccrossed rows",200,0,200); - fHistQA[15] = new TH1F("ratioCrossedRowsOverFindableClustersTPC","Number of TPC ccrossed rows find clusters",200,0,2); - -for(Int_t i = 0; i < 16; i++) - { - fOutput->Add(fHistQA[i]); - } - - kTrackVariablesPair=6 ; - - if(fcontainPIDtrig && !fcontainPIDasso) kTrackVariablesPair=7; - - if(!fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=7; - - if(fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=8; - - -// two particle histograms - Int_t iBinPair[kTrackVariablesPair]; // binning for track variables - Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables - TString* axisTitlePair; // axis titles for track variables - axisTitlePair=new TString[kTrackVariablesPair]; - - TString defaultBinningStr; - defaultBinningStr = "eta: -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0\n" - "p_t_assoc: 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 8.0,10.0\n" - "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0,10.0\n" - "p_t_eff:0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0,5.5, 6.0, 7.0, 8.0,9.0,10.0\n" - "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n" - "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, 0.0, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n" // this binning starts at -pi/2 and is modulo 3 - "delta_eta: -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,2.1, 2.2, 2.3, 2.4\n" - "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n"; - - if(fcontainPIDtrig){ - defaultBinningStr += "PIDTrig: -0.5,0.5,1.5,2.5,3.5\n"; // course - } - if(fcontainPIDasso){ - defaultBinningStr += "PIDAsso: -0.5,0.5,1.5,2.5,3.5\n"; // course - } - // ========================================================= - // Customization (adopted from AliUEHistograms) - // ========================================================= - - TObjArray* lines = defaultBinningStr.Tokenize("\n"); - for (Int_t i=0; iGetEntriesFast(); i++) - { - TString line(lines->At(i)->GetName()); - TString tag = line(0, line.Index(":")+1); - if (!fCustomBinning.BeginsWith(tag) && !fCustomBinning.Contains(TString("\n") + tag)) - fBinningString += line + "\n"; - else - AliInfo(Form("Using custom binning for %s", tag.Data())); - } - delete lines; - fBinningString += fCustomBinning; - - AliInfo(Form("Used THn Binning:\n%s",fBinningString.Data())); - - // ========================================================= - // Now set the bins - // ========================================================= - - dBinsPair[0] = GetBinning(fBinningString, "multiplicity", iBinPair[0]); - axisTitlePair[0] = " multiplicity"; - - dBinsPair[1] = GetBinning(fBinningString, "vertex", iBinPair[1]); - axisTitlePair[1] = "v_{Z} (cm)"; - - dBinsPair[2] = GetBinning(fBinningString, "p_t_leading_course", iBinPair[2]); - axisTitlePair[2] = "p_{T,trig.} (GeV/c)"; - - dBinsPair[3] = GetBinning(fBinningString, "p_t_assoc", iBinPair[3]); - axisTitlePair[3] = "p_{T,assoc.} (GeV/c)"; - - dBinsPair[4] = GetBinning(fBinningString, "delta_eta", iBinPair[4]); - axisTitlePair[4] = "#Delta#eta"; - - dBinsPair[5] = GetBinning(fBinningString, "delta_phi", iBinPair[5]); - axisTitlePair[5] = "#Delta#varphi (rad)"; - - if(fcontainPIDtrig && !fcontainPIDasso){ - dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]); - axisTitlePair[6] = "PIDTrig"; - } - - if(!fcontainPIDtrig && fcontainPIDasso){ - dBinsPair[6] = GetBinning(fBinningString, "PIDAsso", iBinPair[6]); - axisTitlePair[6] = "PIDAsso"; - } - -if(fcontainPIDtrig && fcontainPIDasso){ - - dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]); - axisTitlePair[6] = "PIDTrig"; - - dBinsPair[7] = GetBinning(fBinningString, "PIDAsso", iBinPair[7]); - axisTitlePair[7] = "PIDAsso"; - } - - Int_t nEtaBin = -1; - Double_t* EtaBin = GetBinning(fBinningString, "eta", nEtaBin); - - Int_t nPteffbin = -1; - Double_t* Pteff = GetBinning(fBinningString, "p_t_eff", nPteffbin); - - - fminPtTrig=dBinsPair[2][0]; - fmaxPtTrig=dBinsPair[2][iBinPair[2]]; - fminPtAsso=dBinsPair[3][0]; - fmaxPtAsso=dBinsPair[3][iBinPair[3]]; - - //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value - //fmaxPtComboeff=fmaxPtTrig; -//THnSparses for calculation of efficiency - - if((fAnalysisType =="MCAOD") && ffillefficiency) { - const Int_t nDim = 4;// cent zvtx pt eta - Int_t fBinsCh[nDim] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//**********************change it - Double_t fMinCh[nDim] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] }; - Double_t fMaxCh[nDim] = { dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]}; - -TString Histrename; -for(Int_t jj=0;jj<6;jj++)//PID type binning - { - Histrename="fTHnrecomatchedallPid";Histrename+=jj; - fTHnrecomatchedallPid[jj] = new THnSparseF(Histrename.Data(),"cent:zvtx::Pt:eta", nDim, fBinsCh, fMinCh, fMaxCh); - fTHnrecomatchedallPid[jj]->Sumw2(); - fTHnrecomatchedallPid[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]); - fTHnrecomatchedallPid[jj]->GetAxis(0)->SetTitle("Centrality"); - fTHnrecomatchedallPid[jj]->GetAxis(1)->Set(iBinPair[1],dBinsPair[1]); - fTHnrecomatchedallPid[jj]->GetAxis(1)->SetTitle("zvtx"); - fTHnrecomatchedallPid[jj]->GetAxis(2)->Set(nPteffbin, Pteff); - fTHnrecomatchedallPid[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); - fTHnrecomatchedallPid[jj]->GetAxis(3)->Set(nEtaBin,EtaBin); - fTHnrecomatchedallPid[jj]->GetAxis(3)->SetTitle("#eta"); - fOutput->Add(fTHnrecomatchedallPid[jj]); - -Histrename="fTHngenprimPidTruth";Histrename+=jj; - fTHngenprimPidTruth[jj] = new THnSparseF(Histrename.Data(),"cent:zvtx::Pt:eta", nDim, fBinsCh, fMinCh, fMaxCh); - fTHngenprimPidTruth[jj]->Sumw2(); - fTHngenprimPidTruth[jj]->GetAxis(0)->Set(iBinPair[0],dBinsPair[0]); - fTHngenprimPidTruth[jj]->GetAxis(0)->SetTitle("Centrality"); - fTHngenprimPidTruth[jj]->GetAxis(1)->Set(iBinPair[1], dBinsPair[1]); - fTHngenprimPidTruth[jj]->GetAxis(1)->SetTitle("zvtx"); - fTHngenprimPidTruth[jj]->GetAxis(2)->Set(nPteffbin, Pteff); - fTHngenprimPidTruth[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); - fTHngenprimPidTruth[jj]->GetAxis(3)->Set(nEtaBin, EtaBin); - fTHngenprimPidTruth[jj]->GetAxis(3)->SetTitle("#eta"); - fOutput->Add(fTHngenprimPidTruth[jj]); - } - } - - Int_t fBins[kTrackVariablesPair]; - Double_t fMin[kTrackVariablesPair]; - Double_t fMax[kTrackVariablesPair]; - -//ThnSparses for Correlation plots(data & MC) - for(Int_t i=0;iSumw2(); - for(Int_t i=0; iAdd(fTHnCorrUNID); - -fTHnCorrUNIDmix = new THnSparseF("fTHnCorrUNIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fTHnCorrUNIDmix->Sumw2(); -for(Int_t i=0; iAdd(fTHnCorrUNIDmix); - } - - if(ffilltrigIDassoID) - { - fTHnCorrID = new THnSparseF("fTHnCorrID","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fTHnCorrID->Sumw2(); -for(Int_t i=0; iAdd(fTHnCorrID); - -fTHnCorrIDmix = new THnSparseF("fTHnCorrIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fTHnCorrIDmix->Sumw2(); -for(Int_t i=0; iAdd(fTHnCorrIDmix); - } - - if(ffilltrigUNIDassoID || ffilltrigIDassoUNID)//***********a bit tricky, be careful - { - fTHnCorrIDUNID = new THnSparseF("fTHnCorrIDUNID","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fTHnCorrIDUNID->Sumw2(); -for(Int_t i=0; iAdd(fTHnCorrIDUNID); - - fTHnCorrIDUNIDmix = new THnSparseF("fTHnCorrIDUNIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fTHnCorrIDUNIDmix->Sumw2(); -for(Int_t i=0; iAdd(fTHnCorrIDUNIDmix); - } - - - - //ThnSparse for Correlation plots(truth MC) - if((fAnalysisType == "MCAOD") && ffilltrigIDassoIDMCTRUTH) {//remember that in this case uidentified means other than pions, kaons, protons - fCorrelatonTruthPrimary = new THnSparseF("fCorrelatonTruthPrimary","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fCorrelatonTruthPrimary->Sumw2(); -for(Int_t i=0; iAdd(fCorrelatonTruthPrimary); - - fCorrelatonTruthPrimarymix = new THnSparseF("fCorrelatonTruthPrimarymix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); - fCorrelatonTruthPrimarymix->Sumw2(); -for(Int_t i=0; iAdd(fCorrelatonTruthPrimarymix); - } - - - //binning for trigger no. counting - - Double_t* fMint; - Double_t* fMaxt; - Int_t* fBinst; - Int_t dims=3; - if(fcontainPIDtrig) dims=4; - fMint= new Double_t[dims]; - fMaxt= new Double_t[dims]; - fBinst= new Int_t[dims]; - for(Int_t i=0; i<3;i++) - { - fBinst[i]=iBinPair[i]; - fMint[i]=dBinsPair[i][0]; - fMaxt[i]=dBinsPair[i][iBinPair[i]]; - } - if(fcontainPIDtrig){ - fBinst[3]=iBinPair[6]; - fMint[3]=dBinsPair[6][0]; - fMaxt[3]=dBinsPair[6][iBinPair[6]]; - } - - //ThSparse for trigger counting(data & reco MC) - if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID) - { - fTHnTrigcount = new THnSparseF("fTHnTrigcount","cent:zvtx:pt", dims, fBinst, fMint, fMaxt); - fTHnTrigcount->Sumw2(); -for(Int_t i=0; i<3;i++){ - SetAsymmetricBin(fTHnTrigcount,i,dBinsPair[i],iBinPair[i],axisTitlePair[i]); - } - if(fcontainPIDtrig) SetAsymmetricBin(fTHnTrigcount,3,dBinsPair[6],iBinPair[6],axisTitlePair[6]); - fOutput->Add(fTHnTrigcount); - } - - if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) { - //ThSparse for trigger counting(truth MC) -fTHnTrigcountMCTruthPrim = new THnSparseF("fTHnTrigcountMCTruthPrim","cent:zvtx:pt", dims, fBinst, fMint, fMaxt); - fTHnTrigcountMCTruthPrim->Sumw2(); -for(Int_t i=0; i<3;i++){ - SetAsymmetricBin(fTHnTrigcountMCTruthPrim,i,dBinsPair[i],iBinPair[i],axisTitlePair[i]); - } -if(fcontainPIDtrig) SetAsymmetricBin(fTHnTrigcountMCTruthPrim,3,dBinsPair[6],iBinPair[6],axisTitlePair[6]); - fOutput->Add(fTHnTrigcountMCTruthPrim); - } - -if(fAnalysisType=="MCAOD"){ - if(ffillhistQATruth) - { - MCtruthpt=new TH1F ("MCtruthpt","ptdistributiontruthprim",100,0.,10.); - fOutput->Add(MCtruthpt); - - MCtrutheta=new TH1F ("MCtrutheta","etadistributiontruthprim",360,-1.8,1.8); - fOutput->Add(MCtrutheta); - - MCtruthphi=new TH1F ("MCtruthphi","phidisttruthprim",340,0,6.8); - fOutput->Add(MCtruthphi); - - MCtruthpionpt=new TH1F ("MCtruthpionpt","MCtruthpionpt",100,0.,10.); - fOutput->Add(MCtruthpionpt); - - MCtruthpioneta=new TH1F ("MCtruthpioneta","MCtruthpioneta",360,-1.8,1.8); - fOutput->Add(MCtruthpioneta); - - MCtruthpionphi=new TH1F ("MCtruthpionphi","MCtruthpionphi",340,0,6.8); - fOutput->Add(MCtruthpionphi); - - MCtruthkaonpt=new TH1F ("MCtruthkaonpt","MCtruthkaonpt",100,0.,10.); - fOutput->Add(MCtruthkaonpt); - - MCtruthkaoneta=new TH1F ("MCtruthkaoneta","MCtruthkaoneta",360,-1.8,1.8); - fOutput->Add(MCtruthkaoneta); - - MCtruthkaonphi=new TH1F ("MCtruthkaonphi","MCtruthkaonphi",340,0,6.8); - fOutput->Add(MCtruthkaonphi); - - MCtruthprotonpt=new TH1F ("MCtruthprotonpt","MCtruthprotonpt",100,0.,10.); - fOutput->Add(MCtruthprotonpt); - - MCtruthprotoneta=new TH1F ("MCtruthprotoneta","MCtruthprotoneta",360,-1.8,1.8); - fOutput->Add(MCtruthprotoneta); - - MCtruthprotonphi=new TH1F ("MCtruthprotonphi","MCtruthprotonphi",340,0,6.8); - fOutput->Add(MCtruthprotonphi); - } - fPioncont=new TH2F("fPioncont", "fPioncont",10,-0.5,9.5,100,0.,10.); - fOutput->Add(fPioncont); - - fKaoncont=new TH2F("fKaoncont","fKaoncont",10,-0.5,9.5,100,0.,10.); - fOutput->Add(fKaoncont); - - fProtoncont=new TH2F("fProtoncont","fProtoncont",10,-0.5,9.5,100,0.,10.); - fOutput->Add(fProtoncont); - } - -//Mixing -DefineEventPool(); - - if(fapplyTrigefficiency || fapplyAssoefficiency) - { - const Int_t nDimt = 4;// cent zvtx pt eta - Int_t fBinsCht[nDimt] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//*************change it - Double_t fMinCht[nDimt] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] }; - Double_t fMaxCht[nDimt] = {dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]}; - - TString Histrexname; -for(Int_t jj=0;jj<6;jj++)// PID type binning - { - Histrexname="effcorection";Histrexname+=jj; - effcorection[jj] = new THnSparseF(Histrexname.Data(),"cent:zvtx::Pt:eta", nDimt, fBinsCht, fMinCht, fMaxCht); - effcorection[jj]->Sumw2(); - effcorection[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]); - effcorection[jj]->GetAxis(0)->SetTitle("Centrality"); - effcorection[jj]->GetAxis(1)->Set( iBinPair[1],dBinsPair[1]); - effcorection[jj]->GetAxis(1)->SetTitle("zvtx"); - effcorection[jj]->GetAxis(2)->Set(nPteffbin, Pteff); - effcorection[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); - effcorection[jj]->GetAxis(3)->Set( nEtaBin,EtaBin); - effcorection[jj]->GetAxis(3)->SetTitle("#eta"); - fOutput->Add(effcorection[jj]); - } -// TFile *fsifile = new TFile(fefffilename,"READ"); - TFile *fileT=TFile::Open(fefffilename); - TString Nameg; -for(Int_t jj=0;jj<6;jj++)//type binning - { -Nameg="effmap";Nameg+=jj; -//effcorection[jj] = (THnSparseF*)fsifile->Get(Nameg.Data()); -effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data()); - -//effcorection[jj]->SetDirectory(0);//****************************not present in case oh THnF - } -//fsifile->Close(); -fileT->Close(); - - } - -//fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1); -// fOutput->Add(fControlConvResoncances); - - - PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram -} -//------------------------------------------------------------------------------- -void AliTwoParticlePIDCorr::UserExec( Option_t * ){ - - - if(fAnalysisType == "AOD") { - - doAODevent(); - - }//AOD--analysis----- - - else if(fAnalysisType == "MCAOD") { - - doMCAODevent(); - - } - - else return; - -} -//------------------------------------------------------------------------- -void AliTwoParticlePIDCorr::doMCAODevent() -{ - AliVEvent *event = InputEvent(); - if (!event) { Printf("ERROR: Could not retrieve event"); return; } - AliAODEvent* aod = dynamic_cast(event); - if (!aod) { - AliError("Cannot get the AOD event"); - return; - } - -// count all events(physics triggered) - fEventCounter->Fill(1); - - // get centrality object and check quality(valid for p-Pb and Pb-Pb) - Double_t cent_v0=0.0; - - if(fSampleType=="pPb" || fSampleType=="PbPb") - { - AliCentrality *centrality=0; - if(aod) - centrality = aod->GetHeader()->GetCentralityP(); - // if (centrality->GetQuality() != 0) return ; - - if(centrality) - { - cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod); - } - else - { - cent_v0= -1; - } - } - -//check the PIDResponse handler - if (!fPID) return; - -// get mag. field required for twotrack efficiency cut - Float_t bSign = 0; - bSign = (aod->GetMagneticField() > 0) ? 1 : -1; - - //check for TClonesArray(truth track MC information) -fArrayMC = dynamic_cast(aod->FindListObject(AliAODMCParticle::StdBranchName())); - if (!fArrayMC) { - AliFatal("Error: MC particles branch not found!\n"); - return; - } - - //check for AliAODMCHeader(truth event MC information) - AliAODMCHeader *header=NULL; - header=(AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()); - if(!header) { - printf("MC header branch not found!\n"); - return; - } - -//Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex -Float_t zVtxmc =header->GetVtxZ(); - if(TMath::Abs(zVtxmc)>fzvtxcut) return; - - // For productions with injected signals, figure out above which label to skip particles/tracks - Int_t skipParticlesAbove = 0; - - if (fInjectedSignals) - { - AliGenEventHeader* eventHeader = 0; - Int_t headers = 0; - -// AOD - if (!header) - AliFatal("fInjectedSignals set but no MC header found"); - - headers = header->GetNCocktailHeaders(); - eventHeader = header->GetCocktailHeader(0); - - if (!eventHeader) - { - // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing - // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events - AliError("First event header not found. Skipping this event."); - //fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology); - return; - } -skipParticlesAbove = eventHeader->NProduced(); - AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove)); - } - - //vertex selection(is it fine for PP?) - if ( fSampleType=="pPb"){ - trkVtx = aod->GetPrimaryVertex(); - if (!trkVtx || trkVtx->GetNContributors()<=0) return; - TString vtxTtl = trkVtx->GetTitle(); - if (!vtxTtl.Contains("VertexerTracks")) return; - zvtx = trkVtx->GetZ(); - const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD(); - if (!spdVtx || spdVtx->GetNContributors()<=0) return; - TString vtxTyp = spdVtx->GetTitle(); - Double_t cov[6]={0}; - spdVtx->GetCovarianceMatrix(cov); - Double_t zRes = TMath::Sqrt(cov[5]); - if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return; - if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return; - } - else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case - Int_t nVertex = aod->GetNumberOfVertices(); - if( nVertex > 0 ) { - trkVtx = aod->GetPrimaryVertex(); - Int_t nTracksPrim = trkVtx->GetNContributors(); - zvtx = trkVtx->GetZ(); - //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName())); - // Reject TPC only vertex - TString name(trkVtx->GetName()); - if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return; - - // Select a quality vertex by number of tracks? - if( nTracksPrim < fnTracksVertex ) { - //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ..."); - return ; - } - // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present - //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02) - // return kFALSE; - // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED..."); - } - else return; - - } - else return;//as there is no proper sample type - - - fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm - - //count events having a proper vertex - fEventCounter->Fill(2); - - if (TMath::Abs(zvtx) > fzvtxcut) return; - -fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut for trkVtx only - -//now we have events passed physics trigger, centrality,eventzvtx cut - -//count events after vertex cut - fEventCounter->Fill(5); - -if(!aod) return; //for safety - -if (fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity - - Double_t nooftrackstruth=0.0;//in case of pp this will give the multiplicity(for truth case) after the track loop(only for unidentified particles that pass kinematic cuts) - - Double_t cent_v0_truth=0.0; - - //TObjArray* tracksMCtruth=0; -TObjArray* tracksMCtruth=new TObjArray;//for truth MC particles with PID,here unidentified means any particle other than pion, kaon or proton(Basicaly Spundefined of AliHelperPID)******WARNING::different from data and reco MC - tracksMCtruth->SetOwner(kTRUE); //***********************************IMPORTANT! - - eventno++; - - //There is a small difference between zvtx and zVtxmc?????? - //cout<<"***********************************************zVtxmc="<Charge() == 0) continue; - -//consider only primary particles; neglect all secondary particles including from weak decays - if(fselectprimaryTruth && !partMC->IsPhysicalPrimary()) continue; - - -//remove injected signals(primaries above ) - if (fInjectedSignals && partMC->GetLabel() >= skipParticlesAbove) continue; - -//remove duplicates - Bool_t isduplicate=kFALSE; - if (fRemoveDuplicates) - { - for (Int_t j=iMC+1; jAt(j); - if(!partMC2){ - AliError(Form("ERROR: Could not retrieve AODMCtrack %d",j)); - continue; - } - if (partMC->GetLabel() == partMC2->GetLabel()) - { -isduplicate=kTRUE; - break; - } - }//2nd truth loop ends - } - if(fRemoveDuplicates && isduplicate) continue;//remove duplicates - -//give only kinematic cuts at the truth level - if (partMC->Eta() < fmineta || partMC->Eta() > fmaxeta) continue; - if (partMC->Pt() < fminPt || partMC->Pt() > fmaxPt) continue; - - if(!partMC) continue;//for safety - - //To determine multiplicity in case of PP - nooftrackstruth++; - //cout<<"**************************************"<GetLabel())<Fill(partMC->Pt()); - MCtrutheta->Fill(partMC->Eta()); - MCtruthphi->Fill(partMC->Phi()); - } - //get particle ID -Int_t pdgtruth=((AliAODMCParticle*)partMC)->GetPdgCode(); -Int_t particletypeTruth=-999; - if (TMath::Abs(pdgtruth)==211) - { - particletypeTruth=SpPion; -if(ffillhistQATruth) - { - MCtruthpionpt->Fill(partMC->Pt()); - MCtruthpioneta->Fill(partMC->Eta()); - MCtruthpionphi->Fill(partMC->Phi()); - } - } - if (TMath::Abs(pdgtruth)==321) - { - particletypeTruth=SpKaon; -if(ffillhistQATruth) - { - MCtruthkaonpt->Fill(partMC->Pt()); - MCtruthkaoneta->Fill(partMC->Eta()); - MCtruthkaonphi->Fill(partMC->Phi()); - } - } -if(TMath::Abs(pdgtruth)==2212) - { - particletypeTruth=SpProton; -if(ffillhistQATruth) - { - MCtruthprotonpt->Fill(partMC->Pt()); - MCtruthprotoneta->Fill(partMC->Eta()); - MCtruthprotonphi->Fill(partMC->Phi()); - } - } - if(TMath::Abs(pdgtruth)!=211 && TMath::Abs(pdgtruth)!=321 && TMath::Abs(pdgtruth)!=2212) particletypeTruth=unidentified;//*********************WARNING:: situation is different from reco MC and data case(here we don't have SpUndefined particles,because here unidentified=SpUndefined) - - // -- Fill THnSparse for efficiency and contamination calculation - if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicity i.e. multiplicity intregated out )**************Important - - Double_t primmctruth[4] = {cent_v0, zVtxmc,partMC->Pt(), partMC->Eta()}; - if(ffillefficiency) - { - fTHngenprimPidTruth[5]->Fill(primmctruth);//for all primary truth particles(4) -if (TMath::Abs(pdgtruth)==211 || TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[3]->Fill(primmctruth);//for primary truth mesons(3) -if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[4]->Fill(primmctruth);//for primary truth kaons+protons(4) - if (TMath::Abs(pdgtruth)==211) fTHngenprimPidTruth[0]->Fill(primmctruth);//for pions - if (TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[1]->Fill(primmctruth);//for kaons - if(TMath::Abs(pdgtruth)==2212) fTHngenprimPidTruth[2]->Fill(primmctruth);//for protons - } - - Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0 -if(partMC->Pt()>=fminPtAsso || partMC->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool - { -LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth); -//copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel())); - copy6->SetUniqueID(eventno * 100000 + (Int_t)nooftrackstruth); - tracksMCtruth->Add(copy6);//************** TObjArray used for truth correlation function calculation - } - }//MC truth track loop ends - -//*********************still in event loop - - if (fSampleType=="pp") cent_v0_truth=nooftrackstruth; - else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case - - //now cent_v0_truth should be used for all correlation function calculation - -if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH) - { - //Fill Correlations for MC truth particles(same event) -if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation - Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case - -//start mixing -AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200); -if (pool2 && pool2->IsReady()) - {//start mixing only when pool->IsReady -if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0) - {//proceed only when no. of trigger particles >0 in current event -for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) - { //pool event loop start - TObjArray* bgTracks6 = pool2->GetEvent(jMix); - if(!bgTracks6) continue; - Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case - - }// pool event loop ends mixing case - }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case -} //if pool->IsReady() condition ends mixing case - - //still in main event loop - - if(tracksMCtruth){ -if(pool2) pool2->UpdatePool(CloneAndReduceTrackList(tracksMCtruth));//ownership of tracksasso is with pool now, don't delete it - } - } - - //still in main event loop - -if(tracksMCtruth) delete tracksMCtruth; - -//now deal with reco tracks - //TObjArray* tracksUNID=0; - TObjArray* tracksUNID = new TObjArray; - tracksUNID->SetOwner(kTRUE); - - //TObjArray* tracksID=0; - TObjArray* tracksID = new TObjArray; - tracksID->SetOwner(kTRUE); - - - Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//used for reconstructed track dca cut - - Double_t trackscount=0.0; - -// loop over reconstructed tracks - for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++) -{ // reconstructed track loop starts - AliAODTrack* track = dynamic_cast(aod->GetTrack(itrk)); - if (!track) continue; - //get the corresponding MC track at the truth level (doing reco matching) - AliAODMCParticle* recomatched = static_cast(fArrayMC->At(TMath::Abs(track->GetLabel()))); - if(!recomatched) continue;//if a reco track doesn't have corresponding truth track at generated level is a fake track(label==0), ignore it - -//remove injected signals - if(fInjectedSignals) - { - AliAODMCParticle* mother = recomatched; - - while (!mother->IsPhysicalPrimary()) - {// find the primary mother;the first stable mother is searched and checked if it is <= - if (mother->GetMother() < 0) - { - mother = 0; - break; - } - - mother =(AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother()); - if (!mother) - break; - } - if (!mother) - { - Printf("WARNING: No mother found for particle %d:", recomatched->GetLabel()); - continue; - } - if (mother->GetLabel() >= skipParticlesAbove) continue;//remove injected signals(primaries above ) - }//remove injected signals - - if (fRemoveWeakDecays && ((AliAODMCParticle*) recomatched)->IsSecondaryFromWeakDecay()) continue;//remove weak decays - - Bool_t isduplicate2=kFALSE; -if (fRemoveDuplicates) - { - for (Int_t j =itrk+1; j < aod->GetNumberOfTracks(); j++) - {//2nd loop starts - AliAODTrack* track2 = dynamic_cast(aod->GetTrack(j)); - if (!track2) continue; - AliAODMCParticle* recomatched2 = static_cast(fArrayMC->At(TMath::Abs(track2->GetLabel()))); -if(!recomatched2) continue; - -if (track->GetLabel() == track2->GetLabel()) - { -isduplicate2=kTRUE; - break; - } - }//2nd loop ends - } - if(fRemoveDuplicates && isduplicate2) continue;//remove duplicates - - fHistQA[11]->Fill(track->GetTPCNcls()); - Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE - - if(tracktype==0) continue; - if(tracktype==1)//tracks "not" passed AliAODTrack::kPrimary at reconstructed level & have proper TPC PID response(?) -{ - if(!track) continue;//for safety - //accepted all(primaries+secondary) reconstructed tracks(pt 0.2 to 10.0,,eta -0.8 to 0.8) - trackscount++; - -//check for eta , phi holes - fEtaSpectrasso->Fill(track->Eta(),track->Pt()); - fphiSpectraasso->Fill(track->Phi(),track->Pt()); - - Int_t particletypeMC=-9999; - -//tag all particles as unidentified - particletypeMC=unidentified; - - Float_t effmatrix=1.; - -// -- Fill THnSparse for efficiency calculation - if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important - //NOTE:: this will be used for fillinfg THnSparse of efficiency & also to get the the track by track eff. factor on the fly(only in case of pp) - - //Clone & Reduce track list(TObjArray) for unidentified particles -if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool - { - if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles - effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC); - LRCParticlePID* copy = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); - copy->SetUniqueID(eventno * 100000 +(Int_t)trackscount); - tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only) - } - Double_t allrecomatchedpid[4] = {cent_v0, zVtxmc,recomatched->Pt(), recomatched->Eta()}; -if(ffillefficiency) fTHnrecomatchedallPid[5]->Fill(allrecomatchedpid);//for all - - //now start the particle identification process:) - -//get the pdg code of the corresponding truth particle - Int_t pdgCode = ((AliAODMCParticle*)recomatched)->GetPdgCode(); - -Float_t dEdx = track->GetTPCsignal(); - fHistoTPCdEdx->Fill(track->Pt(), dEdx); - - if(HasTOFPID(track)) -{ -Float_t beta = GetBeta(track); -fHistoTOFbeta->Fill(track->Pt(), beta); - } - - //do track identification(nsigma method) - particletypeMC=GetParticle(track);//******************************problem is here - -//2-d TPCTOF map(for each Pt interval) - if(HasTOFPID(track)){ - fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]); - fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]); - fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]); - } - if(particletypeMC==SpUndefined) continue; - - //Pt, Eta , Phi distribution of the reconstructed identified particles -if(ffillhistQAReco) - { -if (particletypeMC==SpPion) - { - fPionPt->Fill(track->Pt()); - fPionEta->Fill(track->Eta()); - fPionPhi->Fill(track->Phi()); - } -if (particletypeMC==SpKaon) - { - fKaonPt->Fill(track->Pt()); - fKaonEta->Fill(track->Eta()); - fKaonPhi->Fill(track->Phi()); - } -if (particletypeMC==SpProton) - { - fProtonPt->Fill(track->Pt()); - fProtonEta->Fill(track->Eta()); - fProtonPhi->Fill(track->Phi()); - } - } - - //for misidentification fraction calculation(do it with tuneonPID) - if(particletypeMC==SpPion ) - { - if(TMath::Abs(pdgCode)==211) fPioncont->Fill(1.,track->Pt()); - if(TMath::Abs(pdgCode)==321) fPioncont->Fill(3.,track->Pt()); - if(TMath::Abs(pdgCode)==2212) fPioncont->Fill(5.,track->Pt()); - if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fPioncont->Fill(7.,track->Pt()); - } -if(particletypeMC==SpKaon ) - { - if(TMath::Abs(pdgCode)==211) fKaoncont->Fill(1.,track->Pt()); - if(TMath::Abs(pdgCode)==321) fKaoncont->Fill(3.,track->Pt()); - if(TMath::Abs(pdgCode)==2212) fKaoncont->Fill(5.,track->Pt()); - if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fKaoncont->Fill(7.,track->Pt()); - } - if(particletypeMC==SpProton ) - { - if(TMath::Abs(pdgCode)==211) fProtoncont->Fill(1.,track->Pt()); - if(TMath::Abs(pdgCode)==321) fProtoncont->Fill(3.,track->Pt()); - if(TMath::Abs(pdgCode)==2212) fProtoncont->Fill(5.,track->Pt()); - if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fProtoncont->Fill(7.,track->Pt()); - } - - //fill tracking efficiency - if(ffillefficiency) - { - if(particletypeMC==SpPion || particletypeMC==SpKaon) - { -if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTHnrecomatchedallPid[3]->Fill(allrecomatchedpid);//for mesons - } - if(particletypeMC==SpKaon || particletypeMC==SpProton) - { -if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTHnrecomatchedallPid[4]->Fill(allrecomatchedpid);//for kaons+protons - } - if(particletypeMC==SpPion && TMath::Abs(pdgCode)==211) fTHnrecomatchedallPid[0]->Fill(allrecomatchedpid);//for pions - if(particletypeMC==SpKaon && TMath::Abs(pdgCode)==321) fTHnrecomatchedallPid[1]->Fill(allrecomatchedpid);//for kaons - if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212) fTHnrecomatchedallPid[2]->Fill(allrecomatchedpid);//for protons - } - -if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool - { -if (fapplyTrigefficiency || fapplyAssoefficiency) - effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles - LRCParticlePID* copy1 = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); - copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount); - tracksID->Add(copy1); - } - }// if(tracktype==1) condition structure ands - -}//reco track loop ends - - //*************************************************************still in event loop - -//same event delta-eta-deltaphi plot -if(fSampleType=="pp") cent_v0=trackscount;//multiplicity - -if(trackscount>0.0) - { -//fill the centrality/multiplicity distribution of the selected events - fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case - - if (fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers?????? - -//count selected events having centrality betn 0-100% - fEventCounter->Fill(6); - - //same event delte-eta, delta-phi plot -if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation - {//same event calculation starts - if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation) - if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation) - } - -if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation - {//same event calculation starts - if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation) - if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation) - } - -//still in main event loop -//start mixing - if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles -AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified) -if (pool && pool->IsReady()) - {//start mixing only when pool->IsReady - for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) - { //pool event loop start - TObjArray* bgTracks = pool->GetEvent(jMix); - if(!bgTracks) continue; - if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing - Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE - if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing - Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE - }// pool event loop ends mixing case - -} //if pool->IsReady() condition ends mixing case - if(tracksUNID) { -if(pool) - pool->UpdatePool(CloneAndReduceTrackList(tracksUNID)); - } - }//mixing with unidentified particles - - if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles -AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified) -if (pool1 && pool1->IsReady()) - {//start mixing only when pool->IsReady -for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) - { //pool event loop start - TObjArray* bgTracks2 = pool1->GetEvent(jMix); - if(!bgTracks2) continue; -if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0) - Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE -if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0) - Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE - - }// pool event loop ends mixing case -} //if pool1->IsReady() condition ends mixing case - -if(tracksID) { -if(pool1) - pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool) - } - }//mixing with identified particles - - //no. of events analyzed -fEventCounter->Fill(7); - } - -if(tracksUNID) delete tracksUNID; - -if(tracksID) delete tracksID; - - -PostData(1, fOutput); - -} -//________________________________________________________________________ -void AliTwoParticlePIDCorr::doAODevent() -{ - - //get AOD - AliVEvent *event = InputEvent(); - if (!event) { Printf("ERROR: Could not retrieve event"); return; } - AliAODEvent* aod = dynamic_cast(event); - if (!aod) { - AliError("Cannot get the AOD event"); - return; - } - -// count all events - fEventCounter->Fill(1); - - // get centrality object and check quality - Double_t cent_v0=0; - - if(fSampleType=="pPb" || fSampleType=="PbPb") - { - AliCentrality *centrality=0; - if(aod) - centrality = aod->GetHeader()->GetCentralityP(); - // if (centrality->GetQuality() != 0) return ; - - if(centrality) - { - cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod); - } - else - { - cent_v0= -1; - } - } - - Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation - Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop - -// Pileup selection ************************************************ -// if(frejectPileUp) //applicable only for TPC only tracks,not for hybrid tracks?. - // { - //if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return; - // } - - if (!fPID) return;//this should be available with each event even if we don't do PID selection - - //vertex selection(is it fine for PP?) - if ( fSampleType=="pPb"){ - trkVtx = aod->GetPrimaryVertex(); - if (!trkVtx || trkVtx->GetNContributors()<=0) return; - TString vtxTtl = trkVtx->GetTitle(); - if (!vtxTtl.Contains("VertexerTracks")) return; - zvtx = trkVtx->GetZ(); - const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD(); - if (!spdVtx || spdVtx->GetNContributors()<=0) return; - TString vtxTyp = spdVtx->GetTitle(); - Double_t cov[6]={0}; - spdVtx->GetCovarianceMatrix(cov); - Double_t zRes = TMath::Sqrt(cov[5]); - if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return; - if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return; - } - else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case - Int_t nVertex = aod->GetNumberOfVertices(); - if( nVertex > 0 ) { - trkVtx = aod->GetPrimaryVertex(); - Int_t nTracksPrim = trkVtx->GetNContributors(); - zvtx = trkVtx->GetZ(); - //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName())); - // Reject TPC only vertex - TString name(trkVtx->GetName()); - if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return; - - // Select a quality vertex by number of tracks? - if( nTracksPrim < fnTracksVertex ) { - //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ..."); - return ; - } - // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present - //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02) - // return kFALSE; - // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED..."); - } - else return; - - } - else return;//as there is no proper sample type - - - fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm - -//count events having a proper vertex - fEventCounter->Fill(2); - - if (TMath::Abs(zvtx) > fzvtxcut) return; - -//count events after vertex cut - fEventCounter->Fill(5); - - - //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return; - - fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only - - - if(!aod) return; //for safety - -if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity - - TObjArray* tracksUNID= new TObjArray;//track info before doing PID - tracksUNID->SetOwner(kTRUE); // IMPORTANT! - - TObjArray* tracksID= new TObjArray;//only pions, kaons,protonsi.e. after doing the PID selection - tracksID->SetOwner(kTRUE); // IMPORTANT! - - Double_t trackscount=0.0;//in case of pp this will give the multiplicity after the track loop(only for unidentified particles that pass the filterbit and kinematic cuts) - - eventno++; - - for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++) -{ //track loop starts for TObjArray(containing track and event information) filling; used for correlation function calculation - AliAODTrack* track = dynamic_cast(aod->GetTrack(itrk)); - if (!track) continue; - fHistQA[11]->Fill(track->GetTPCNcls()); - Int_t particletype=-9999;//required for PID filling - Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE - if(tracktype!=1) continue; - - if(!track) continue;//for safety - -//check for eta , phi holes - fEtaSpectrasso->Fill(track->Eta(),track->Pt()); - fphiSpectraasso->Fill(track->Phi(),track->Pt()); - - trackscount++; - - //if no applyefficiency , set the eff factor=1.0 - Float_t effmatrix=1.0; - - //tag all particles as unidentified that passed filterbit & kinematic cuts - particletype=unidentified; - - - if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity [i.e each track has multiplicity 15.0](so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important for efficiency related issues - - - //to reduce memory consumption in pool - if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig) - { - //Clone & Reduce track list(TObjArray) for unidentified particles - if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles - effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype); - LRCParticlePID* copy = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); - copy->SetUniqueID(eventno * 100000 + (Int_t)trackscount); - tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only) - } - -//now start the particle identificaion process:) - -//track passing filterbit 768 have proper TPC response,or need to be checked explicitly before doing PID???? - - Float_t dEdx = track->GetTPCsignal(); - fHistoTPCdEdx->Fill(track->Pt(), dEdx); - - //fill beta vs Pt plots only for tracks having proper TOF response(much less tracks compared to the no. that pass the filterbit & kinematic cuts) - if(HasTOFPID(track)) -{ - Float_t beta = GetBeta(track); - fHistoTOFbeta->Fill(track->Pt(), beta); - } - - -//track identification(using nsigma method) - particletype=GetParticle(track);//*******************************change may be required(It should return only pion,kaon, proton and Spundefined; NOT unidentifed***************be careful) - - -//2-d TPCTOF map(for each Pt interval) - if(HasTOFPID(track)){ - fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]); - fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]); - fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]); - } - -//ignore the Spundefined particles as they also contain pion, kaon, proton outside the nsigma cut(also if tracks don't have proper TOF PID in a certain Pt interval) & these tracks are actually counted when we do the the efficiency correction, so considering them as unidentified particles & doing the efficiency correction(i.e defining unidentified=pion+Kaon+proton+SpUndefined is right only without efficiency correction) for them will be two times wrong!!!!! - if (particletype==SpUndefined) continue;//this condition creating a modulated structure in delphi projection in mixed event case(only when we are dealing with identified particles i.e. tracksID)!!!!!!!!!!! - - //Pt, Eta , Phi distribution of the reconstructed identified particles -if(ffillhistQAReco) - { -if (particletype==SpPion) - { - fPionPt->Fill(track->Pt()); - fPionEta->Fill(track->Eta()); - fPionPhi->Fill(track->Phi()); - } -if (particletype==SpKaon) - { - fKaonPt->Fill(track->Pt()); - fKaonEta->Fill(track->Eta()); - fKaonPhi->Fill(track->Phi()); - } -if (particletype==SpProton) - { - fProtonPt->Fill(track->Pt()); - fProtonEta->Fill(track->Eta()); - fProtonPhi->Fill(track->Phi()); - } - } - -if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig) - { -if (fapplyTrigefficiency || fapplyAssoefficiency) - effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles; Bool_t mesoneffrequired=kFALSE - LRCParticlePID* copy1 = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); - copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount); - tracksID->Add(copy1); - } -} //track loop ends but still in event loop - -if(trackscount<1.0){ - if(tracksUNID) delete tracksUNID; - if(tracksID) delete tracksID; - return; - } - -// cout<Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case - -if(fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers?????? - -//count selected events having centrality betn 0-100% - fEventCounter->Fill(6); - -//same event delta-eta-deltaphi plot - -if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation - {//same event calculation starts - if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation) - if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation) - } - -if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation - {//same event calculation starts - if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation) - if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation) - } - -//still in main event loop - - -//start mixing - if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles -AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified) -if (pool && pool->IsReady()) - {//start mixing only when pool->IsReady - for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) - { //pool event loop start - TObjArray* bgTracks = pool->GetEvent(jMix); - if(!bgTracks) continue; - if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing - Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE - if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing - Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE - }// pool event loop ends mixing case - -} //if pool->IsReady() condition ends mixing case - if(tracksUNID) { -if(pool) - pool->UpdatePool(CloneAndReduceTrackList(tracksUNID)); - } - }//mixing with unidentified particles - - - if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles -AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified) -if (pool1 && pool1->IsReady()) - {//start mixing only when pool->IsReady -for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) - { //pool event loop start - TObjArray* bgTracks2 = pool1->GetEvent(jMix); - if(!bgTracks2) continue; -if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0) - Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE -if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0) - Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE - - }// pool event loop ends mixing case -} //if pool1->IsReady() condition ends mixing case - -if(tracksID) { -if(pool1) - pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool) - } - }//mixing with identified particles - - - //no. of events analyzed -fEventCounter->Fill(7); - -//still in main event loop - - -if(tracksUNID) delete tracksUNID; - -if(tracksID) delete tracksID; - - -PostData(1, fOutput); - -} // *************************event loop ends******************************************//_______________________________________________________________________ -TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks) -{ - // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing) - - TObjArray* tracksClone = new TObjArray; - tracksClone->SetOwner(kTRUE); - - for (Int_t i=0; iGetEntriesFast(); i++) - { - LRCParticlePID* particle = (LRCParticlePID*) tracks->UncheckedAt(i); - LRCParticlePID* copy100 = new LRCParticlePID(particle->getparticle(),particle->Charge(), particle->Pt(),particle->Eta(), particle->Phi(), particle->geteffcorrectionval()); - copy100->SetUniqueID(particle->GetUniqueID()); - tracksClone->Add(copy100); - } - - return tracksClone; -} - -//-------------------------------------------------------------------------------- -void AliTwoParticlePIDCorr::Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup) -{ - - //before calling this function check that either trackstrig & tracksasso are available - - // Eta() is extremely time consuming, therefore cache it for the inner loop here: - TObjArray* input = (tracksasso) ? tracksasso : trackstrig; - TArrayF eta(input->GetEntriesFast()); - for (Int_t i=0; iGetEntriesFast(); i++) - eta[i] = ((LRCParticlePID*) input->UncheckedAt(i))->Eta(); - - //if(trackstrig) - Int_t jmax=trackstrig->GetEntriesFast(); - if(tracksasso) - jmax=tracksasso->GetEntriesFast(); - -// identify K, Lambda candidates and flag those particles - // a TObject bit is used for this -const UInt_t kResonanceDaughterFlag = 1 << 14; - if (fRejectResonanceDaughters > 0) - { - Double_t resonanceMass = -1; - Double_t massDaughter1 = -1; - Double_t massDaughter2 = -1; - const Double_t interval = 0.02; - switch (fRejectResonanceDaughters) - { - case 1: resonanceMass = 0.9; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // method test - case 2: resonanceMass = 0.4976; massDaughter1 = 0.1396; massDaughter2 = massDaughter1; break; // k0 - case 3: resonanceMass = 1.115; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // lambda - default: AliFatal(Form("Invalid setting %d", fRejectResonanceDaughters)); - } - -for (Int_t i=0; iGetEntriesFast(); i++) - trackstrig->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag); - for (Int_t i=0; tracksasso->GetEntriesFast(); i++) - tracksasso->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag); - - for (Int_t i=0; iGetEntriesFast(); i++) - { - LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i)); -for (Int_t j=0; tracksasso->GetEntriesFast(); j++) - { - LRCParticlePID *asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j)); - - // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event) -if (trig->IsEqual(asso)) continue; - -if (trig->Charge() * asso->Charge() > 0) continue; - - Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2); - -if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5) - { - mass = GetInvMassSquared(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2); - - if (mass > (resonanceMass-interval)*(resonanceMass-interval) && mass < (resonanceMass+interval)*(resonanceMass+interval)) - { - trig->SetBit(kResonanceDaughterFlag); - asso->SetBit(kResonanceDaughterFlag); - -// Printf("Flagged %d %d %f", i, j, TMath::Sqrt(mass)); - } - } - } - } - } - - //two particle correlation filling - -for(Int_t i=0;iGetEntriesFast();i++) - { //trigger loop starts - LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i)); - if(!trig) continue; - Float_t trigpt=trig->Pt(); - //to avoid overflow qnd underflow - if(trigptfmaxPtTrig) continue; - Int_t particlepidtrig=trig->getparticle(); - if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;} - - Float_t trigeta=trig->Eta(); - - // some optimization - if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta) - continue; - -if (fOnlyOneEtaSide != 0) - { - if (fOnlyOneEtaSide * trigeta < 0) - continue; - } - if (fTriggerSelectCharge != 0) - if (trig->Charge() * fTriggerSelectCharge < 0) - continue; - - if (fRejectResonanceDaughters > 0) - if (trig->TestBit(kResonanceDaughterFlag)) continue; - - Float_t trigphi=trig->Phi(); - Float_t trackefftrig=1.0; - if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval(); - // cout<<"*******************trackefftrig="<Fill(trigval,1.0/trackefftrig); - } - if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kFALSE){ - if(fillup=="trigassoUNID" ) fTHnTrigcount->Fill(trigval,1.0/trackefftrig); - } -if(ffilltrigassoUNID==kFALSE && ffilltrigUNIDassoID==kTRUE){ - if(fillup=="trigUNIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); - } - //ensure that trigIDassoID , trigassoUNID, trigIDassoUNID & trigUNIDassoID case FillCorrelation called only once in the event loop for same event correlation function calculation, otherwise there will be multiple counting of pion, kaon,proton,unidentified -if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kTRUE){ - if(fillup=="trigIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); - } - if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kFALSE){ - if(fillup=="trigIDassoUNID" ) fTHnTrigcount->Fill(trigval,1.0/trackefftrig); - } -if(ffilltrigIDassoUNID==kFALSE && ffilltrigIDassoID==kTRUE){ - if(fillup=="trigIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); - } - - if(fillup=="trigIDassoIDMCTRUTH") fTHnTrigcountMCTruthPrim->Fill(trigval,1.0/trackefftrig); //In truth MC case "Unidentified" means any particle other than pion,kaon or proton and no efficiency correction(default value 1.0)************************be careful!!!! - } - - //asso loop starts within trigger loop - for(Int_t j=0;jUncheckedAt(j)); - else - asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j)); - - if(!asso) continue; - - //to avoid overflow qnd underflow - if(asso->Pt()Pt()>fmaxPtAsso) continue;//***********************Important - - if(fmaxPtAsso==fminPtTrig) {if(asso->Pt()==fminPtTrig) continue;}//******************Think about it! - - if(!tracksasso && i==j) continue; - - // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event) - // if (tracksasso && trig->IsEqual(asso)) continue; - - if (tracksasso && (trig->GetUniqueID()==asso->GetUniqueID())) continue; - - if (fPtOrder) - if (asso->Pt() >= trig->Pt()) continue; - - Int_t particlepidasso=asso->getparticle(); - if(fAssociatedSpeciesSelection){ if (particlepidasso!=fAssociatedSpecies) continue;} - - -if (fAssociatedSelectCharge != 0) -if (asso->Charge() * fAssociatedSelectCharge < 0) continue; - - if (fSelectCharge > 0) - { - // skip like sign - if (fSelectCharge == 1 && asso->Charge() * trig->Charge() > 0) - continue; - - // skip unlike sign - if (fSelectCharge == 2 && asso->Charge() * trig->Charge() < 0) - continue; - } - -if (fEtaOrdering) - { - if (trigeta < 0 && asso->Eta() < trigeta) - continue; - if (trigeta > 0 && asso->Eta() > trigeta) - continue; - } - -if (fRejectResonanceDaughters > 0) - if (asso->TestBit(kResonanceDaughterFlag)) - { -// Printf("Skipped j=%d", j); - continue; - } - - // conversions - if (fCutConversions && asso->Charge() * trig->Charge() < 0) - { - Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.510e-3, 0.510e-3); - - if (mass < 0.1) - { - mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.510e-3, 0.510e-3); - - //fControlConvResoncances->Fill(0.0, mass); - - if (mass < 0.04*0.04) - continue; - } - } - - // K0s - if (fCutResonances && asso->Charge() * trig->Charge() < 0) - { - Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.1396); - - const Float_t kK0smass = 0.4976; - - if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1) - { - mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.1396); - - //fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass); - - if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02)) - continue; - } - } - - // Lambda - if (fCutResonances && asso->Charge() * trig->Charge() < 0) - { - Float_t mass1 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.9383); - Float_t mass2 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396); - - const Float_t kLambdaMass = 1.115; - - if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1) - { - mass1 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.9383); - - //fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass); - - if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02)) - continue; - } - if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1) - { - mass2 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396); - - //fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass); - - if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02)) - continue; - } - } - - if (twoTrackEfficiencyCut) - { - // the variables & cuthave been developed by the HBT group - // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700 - Float_t phi1 = trig->Phi(); - Float_t pt1 = trig->Pt(); - Float_t charge1 = trig->Charge(); - Float_t phi2 = asso->Phi(); - Float_t pt2 = asso->Pt(); - Float_t charge2 = asso->Charge(); - - Float_t deta= trigeta - eta[j]; - - // optimization - if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3) - { - - // check first boundaries to see if is worth to loop and find the minimum - Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign); - Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign); - - const Float_t kLimit = twoTrackEfficiencyCutValue * 3; - - Float_t dphistarminabs = 1e5; - Float_t dphistarmin = 1e5; - - if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0) - { - for (Double_t rad=0.8; rad<2.51; rad+=0.01) - { - Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign); - - Float_t dphistarabs = TMath::Abs(dphistar); - - if (dphistarabs < dphistarminabs) - { - dphistarmin = dphistar; - dphistarminabs = dphistarabs; - } - } - -if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue) - { -// Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign); - continue; - } -//fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2)); - - } - } - } - - Float_t trackeffasso=1.0; - if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval(); - //cout<<"*******************trackeffasso="<Phi()); - - //here get the two particle efficiency correction factor - Float_t effweight=trackefftrig*trackeffasso; - //cout<<"*******************effweight="<Pt(); - vars[4]=deleta; - vars[5]=delphi; -if(fcontainPIDtrig && !fcontainPIDasso) vars[6]=particlepidtrig; -if(!fcontainPIDtrig && fcontainPIDasso) vars[6]=particlepidasso; - if(fcontainPIDtrig && fcontainPIDasso){ - vars[6]=particlepidtrig; - vars[7]=particlepidasso; - } - - //Fill Correlation ThnSparses - if(fillup=="trigassoUNID") - { - if(mixcase==kFALSE) fTHnCorrUNID->Fill(vars,1.0/effweight); - if(mixcase==kTRUE) fTHnCorrUNIDmix->Fill(vars,1.0/effweight); - } - if(fillup=="trigIDassoID") - { - if(mixcase==kFALSE) fTHnCorrID->Fill(vars,1.0/effweight); - if(mixcase==kTRUE) fTHnCorrIDmix->Fill(vars,1.0/effweight); - } - if(fillup=="trigIDassoIDMCTRUTH")//******************************************for TRUTH MC particles - {//in this case effweight should be 1 always - if(mixcase==kFALSE) fCorrelatonTruthPrimary->Fill(vars,1.0/effweight); - if(mixcase==kTRUE) fCorrelatonTruthPrimarymix->Fill(vars,1.0/effweight); - } - if(fillup=="trigIDassoUNID" || fillup=="trigUNIDassoID")//****************************be careful - { - if(mixcase==kFALSE) fTHnCorrIDUNID->Fill(vars,1.0/effweight); - if(mixcase==kTRUE) fTHnCorrIDUNIDmix->Fill(vars,1.0/effweight); - } - -delete[] vars; - }//asso loop ends -delete[] trigval; - }//trigger loop ends - -} - -//-------------------------------------------------------------------------------- -Float_t AliTwoParticlePIDCorr::GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid) -{ - //This function is called only when applyefficiency=kTRUE; also ensure that "track" is present before calling that function - Int_t effVars[4]; - Float_t effvalue=1.; - - if(parpid==unidentified) - { - effVars[0] = effcorection[5]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[5]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[5]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[5]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[5]->GetBinContent(effVars); - } -if(parpid==SpPion || parpid==SpKaon) - { - if(fmesoneffrequired && !fkaonprotoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff) - { - effVars[0] = effcorection[3]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[3]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[3]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[3]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[3]->GetBinContent(effVars); - } - else{ - if(parpid==SpPion) - { - effVars[0] = effcorection[0]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[0]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[0]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[0]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[0]->GetBinContent(effVars); - } - - if(parpid==SpKaon) - { - effVars[0] = effcorection[1]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[1]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[1]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[1]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[1]->GetBinContent(effVars); - } - } - } - - if(parpid==SpProton) - { - effVars[0] = effcorection[2]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[2]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[2]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[2]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[2]->GetBinContent(effVars); - } - - if(fkaonprotoneffrequired && !fmesoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff) - { - if(parpid==SpProton || parpid==SpKaon) - { - effVars[0] = effcorection[4]->GetAxis(0)->FindBin(cent); - effVars[1] = effcorection[4]->GetAxis(1)->FindBin(evzvtx); - effVars[2] = effcorection[4]->GetAxis(2)->FindBin(track->Pt()); - effVars[3] = effcorection[4]->GetAxis(3)->FindBin(track->Eta()); - effvalue=effcorection[4]->GetBinContent(effVars); - } - } - // Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars)); - if(effvalue==0.) effvalue=1.; - - return effvalue; - -} -//----------------------------------------------------------------------- - -Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vertex,Float_t magfield) -{ - - if(!track) return 0; - Bool_t trackOK = track->TestFilterBit(fFilterBit); - if(!trackOK) return 0; - //select only primary traks(for data & reco MC tracks) - if(fonlyprimarydatareco && track->GetType()!=AliAODTrack::kPrimary) return 0; - if(track->Charge()==0) return 0; - fHistQA[12]->Fill(track->GetTPCNcls()); - Float_t dxy, dz; - dxy = track->DCA(); - dz = track->ZAtDCA(); - fHistQA[6]->Fill(dxy); - fHistQA[7]->Fill(dz); - Float_t chi2ndf = track->Chi2perNDF(); - fHistQA[13]->Fill(chi2ndf); - Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1); - fHistQA[14]->Fill(nCrossedRowsTPC); - //Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0; - if (track->GetTPCNclsF()>0) { - Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF(); - fHistQA[15]->Fill(ratioCrossedRowsOverFindableClustersTPC); - } -//accepted tracks - Float_t pt=track->Pt(); - if(pt< fminPt || pt> fmaxPt) return 0; - if(TMath::Abs(track->Eta())> fmaxeta) return 0; - if(track->Phi()<0. || track->Phi()>2*TMath::Pi()) return 0; - //if (!HasTPCPID(track)) return 0;//trigger & associated particles must have TPC PID,Is it required -// DCA XY - if (fdcacut && fDCAXYCut) - { - if (!vertex) - return 0; - - Double_t pos[2]; - Double_t covar[3]; - AliAODTrack* clone =(AliAODTrack*) track->Clone(); - Bool_t success = clone->PropagateToDCA(vertex, magfield, fdcacutvalue, pos, covar); - delete clone; - if (!success) - return 0; - -// Printf("%f", ((AliAODTrack*)part)->DCA()); -// Printf("%f", pos[0]); - if (TMath::Abs(pos[0]) > fDCAXYCut->Eval(track->Pt())) - return 0; - } - - fHistQA[8]->Fill(pt); - fHistQA[9]->Fill(track->Eta()); - fHistQA[10]->Fill(track->Phi()); - return 1; - } - //________________________________________________________________________________ -void AliTwoParticlePIDCorr::CalculateNSigmas(AliAODTrack *track) -{ -//This function is called within the func GetParticle() for accepted tracks only i.e.after call of Classifytrack() & for those tracks which have proper TPC PID response . combined nsigma(circular) cut only for particles having pt upto 4.0 Gev/c and beyond that use the asymmetric nsigma cut around pion's mean position in TPC ( while filling the TObjArray for trig & asso ) -Float_t pt=track->Pt(); - -//it is assumed that every track that passed the filterbit have proper TPC response(!!) -Float_t nsigmaTPCkPion =fPID->NumberOfSigmasTPC(track, AliPID::kPion); -Float_t nsigmaTPCkKaon =fPID->NumberOfSigmasTPC(track, AliPID::kKaon); -Float_t nsigmaTPCkProton =fPID->NumberOfSigmasTPC(track, AliPID::kProton); - -Float_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.; -Float_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.; - - if(HasTOFPID(track) && pt>fPtTOFPIDmin) - { - -nsigmaTOFkPion =fPID->NumberOfSigmasTOF(track, AliPID::kPion); -nsigmaTOFkKaon =fPID->NumberOfSigmasTOF(track, AliPID::kKaon); -nsigmaTOFkProton =fPID->NumberOfSigmasTOF(track, AliPID::kProton); -//---combined -nsigmaTPCTOFkPion = TMath::Sqrt(nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion); -nsigmaTPCTOFkKaon = TMath::Sqrt(nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon); -nsigmaTPCTOFkProton = TMath::Sqrt(nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton); - - - } -else{ - // --- combined - // if TOF is missing and below fPtTOFPID only the TPC information is used - nsigmaTPCTOFkProton = TMath::Abs(nsigmaTPCkProton); - nsigmaTPCTOFkKaon = TMath::Abs(nsigmaTPCkKaon); - nsigmaTPCTOFkPion = TMath::Abs(nsigmaTPCkPion); - - } - -//set data member fnsigmas - fnsigmas[SpPion][NSigmaTPC]=nsigmaTPCkPion; - fnsigmas[SpKaon][NSigmaTPC]=nsigmaTPCkKaon; - fnsigmas[SpProton][NSigmaTPC]=nsigmaTPCkProton; - - //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TOF nsigma values will be 999. - fnsigmas[SpPion][NSigmaTOF]=nsigmaTOFkPion; - fnsigmas[SpKaon][NSigmaTOF]=nsigmaTOFkKaon; - fnsigmas[SpProton][NSigmaTOF]=nsigmaTOFkProton; - - //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TPCTOF nsigma values will be TMath::Abs(TPC only nsigma) - fnsigmas[SpPion][NSigmaTPCTOF]=nsigmaTPCTOFkPion; - fnsigmas[SpKaon][NSigmaTPCTOF]=nsigmaTPCTOFkKaon; - fnsigmas[SpProton][NSigmaTPCTOF]=nsigmaTPCTOFkProton; - - -} -//---------------------------------------------------------------------------- -Int_t AliTwoParticlePIDCorr::FindMinNSigma(AliAODTrack *track) -{ - //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track) -if(fRequestTOFPID && track->Pt()>fPtTOFPIDmin && track->Pt()<=fPtTOFPIDmax && (!HasTOFPID(track)) )return SpUndefined;//so any track having Pt>0.6 && Pt<=4.0 Gev withot having proper TOF response will be defined as SpUndefined -//get the identity of the particle with the minimum Nsigma - Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.; - switch (fPIDType){ - case NSigmaTPC: - nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]); - nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ; - nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ; - break; - case NSigmaTOF: - nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]); - nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ; - nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ; - break; - case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one - nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]); - nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ; - nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ; - break; - } - - if(track->Pt()<=fPtTOFPIDmax) { - // guess the particle based on the smaller nsigma (within fNSigmaPID) - if( ( nsigmaKaon==nsigmaPion ) && ( nsigmaKaon==nsigmaProton )) return SpUndefined;//it is the default value for the three -if( ( nsigmaKaon < nsigmaPion ) && ( nsigmaKaon < nsigmaProton ) && (nsigmaKaon < fNSigmaPID)) return SpKaon; -if( ( nsigmaPion < nsigmaKaon ) && ( nsigmaPion < nsigmaProton ) && (nsigmaPion < fNSigmaPID)) return SpPion; -if( ( nsigmaProton < nsigmaKaon ) && ( nsigmaProton < nsigmaPion ) && (nsigmaProton < fNSigmaPID)) return SpProton; - -// else, return undefined - return SpUndefined; - } - else {//asymmetric nsigma cut around pion's mean position for tracks having Pt>4.0 Gev - if(fminprotonsigmacutPt()<=4.0){ - if(nsigmaPionCheckPIDStatus(AliPIDResponse::kTPC,track); - if(statustpc!=AliPIDResponse::kDetPidOk) return kFALSE; - //ULong_t status=track->GetStatus(); - //if (!( (status & AliAODTrack::kTPCpid ) == AliAODTrack::kTPCpid )) return kFALSE;//remove light nuclei - //if (track->GetTPCsignal() <= 0.) return kFALSE; - // if(track->GetTPCsignalN() < 60) return kFALSE;//tracks with TPCsignalN< 60 have questionable dEdx,cutting on TPCsignalN > 70 or > 60 shouldn't make too much difference in statistics,also it is IMO safe to use TPC also for MIPs. - - return kTRUE; -} -//___________________________________________________________ - -Bool_t -AliTwoParticlePIDCorr::HasTOFPID(AliAODTrack *track) const -{ - // check TOF matched track - //ULong_t status=track->GetStatus(); - //if (!( (status & AliAODTrack::kITSin ) == AliAODTrack::kITSin )) return kFALSE; - AliPIDResponse::EDetPidStatus statustof = fPID->CheckPIDStatus(AliPIDResponse::kTOF,track); - if(statustof!= AliPIDResponse::kDetPidOk) return kFALSE; - if(track->Pt()<=fPtTOFPIDmin) return kFALSE; - //if(!((status & AliAODTrack::kTOFpid ) == AliAODTrack::kTOFpid )) return kFALSE; - //Float_t probMis = fPIDresponse->GetTOFMismatchProbability(track); - // if (probMis > 0.01) return kFALSE; -if(fRemoveTracksT0Fill) - { -Int_t startTimeMask = fPID->GetTOFResponse().GetStartTimeMask(track->P()); - if (startTimeMask < 0)return kFALSE; - } - return kTRUE; -} - -//________________________________________________________________________ -Float_t AliTwoParticlePIDCorr :: GetBeta(AliAODTrack *track) -{ - //it is called only when TOF PID is available - Double_t p = track->P(); - Double_t time=track->GetTOFsignal()-fPID->GetTOFResponse().GetStartTime(p); - Double_t timei[5]; - track->GetIntegratedTimes(timei); - return timei[0]/time; -} -//------------------------------------------------------------------------------------------------------ - -Float_t AliTwoParticlePIDCorr::GetInvMassSquared(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2) -{ - // calculate inv mass squared - // same can be achieved, but with more computing time with - /*TLorentzVector photon, p1, p2; - p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3); - p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3); - photon = p1+p2; - photon.M()*/ - - Float_t tantheta1 = 1e10; - - if (eta1 < -1e-10 || eta1 > 1e-10) - tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1)); - - Float_t tantheta2 = 1e10; - if (eta2 < -1e-10 || eta2 > 1e-10) - tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2)); - - Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1); - Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2); - - Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( TMath::Cos(phi1 - phi2) + 1.0 / tantheta1 / tantheta2 ) ) ); - - return mass2; -} -//--------------------------------------------------------------------------------- - -Float_t AliTwoParticlePIDCorr::GetInvMassSquaredCheap(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2) -{ - // calculate inv mass squared approximately - - Float_t tantheta1 = 1e10; - - if (eta1 < -1e-10 || eta1 > 1e-10) - { - Float_t expTmp = 1.0-eta1+eta1*eta1/2-eta1*eta1*eta1/6+eta1*eta1*eta1*eta1/24; - tantheta1 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp); - } - - Float_t tantheta2 = 1e10; - if (eta2 < -1e-10 || eta2 > 1e-10) - { - Float_t expTmp = 1.0-eta2+eta2*eta2/2-eta2*eta2*eta2/6+eta2*eta2*eta2*eta2/24; - tantheta2 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp); - } - - Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1); - Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2); - - // fold onto 0...pi - Float_t deltaPhi = TMath::Abs(phi1 - phi2); - while (deltaPhi > TMath::TwoPi()) - deltaPhi -= TMath::TwoPi(); - if (deltaPhi > TMath::Pi()) - deltaPhi = TMath::TwoPi() - deltaPhi; - - Float_t cosDeltaPhi = 0; - if (deltaPhi < TMath::Pi()/3) - cosDeltaPhi = 1.0 - deltaPhi*deltaPhi/2 + deltaPhi*deltaPhi*deltaPhi*deltaPhi/24; - else if (deltaPhi < 2*TMath::Pi()/3) - cosDeltaPhi = -(deltaPhi - TMath::Pi()/2) + 1.0/6 * TMath::Power((deltaPhi - TMath::Pi()/2), 3); - else - cosDeltaPhi = -1.0 + 1.0/2.0*(deltaPhi - TMath::Pi())*(deltaPhi - TMath::Pi()) - 1.0/24.0 * TMath::Power(deltaPhi - TMath::Pi(), 4); - - Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( cosDeltaPhi + 1.0 / tantheta1 / tantheta2 ) ) ); - -// Printf(Form("%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2)); - - return mass2; -} -//-------------------------------------------------------------------------------- -Float_t AliTwoParticlePIDCorr::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign) -{ - // - // calculates dphistar - // - - Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2); - - static const Double_t kPi = TMath::Pi(); - - // circularity -// if (dphistar > 2 * kPi) -// dphistar -= 2 * kPi; -// if (dphistar < -2 * kPi) -// dphistar += 2 * kPi; - - if (dphistar > kPi) - dphistar = kPi * 2 - dphistar; - if (dphistar < -kPi) - dphistar = -kPi * 2 - dphistar; - if (dphistar > kPi) // might look funny but is needed - dphistar = kPi * 2 - dphistar; - - return dphistar; -} -//_________________________________________________________________________ -void AliTwoParticlePIDCorr ::DefineEventPool() -{ -const Int_t MaxNofEvents=1000; -const Int_t MaxNofTracks=50000; -const Int_t NofVrtxBins=10+(1+10)*2; -Double_t ZvrtxBins[NofVrtxBins+1]={ -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, - 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, - 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210 - }; - if (fSampleType=="pp"){ -const Int_t NofCentBins=5; -Double_t CentralityBins[NofCentBins+1]={0.,10., 20., 40.,80.,200.1}; -fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins); - } -if (fSampleType=="pPb" || fSampleType=="PbPb") - { -const Int_t NofCentBins=15; -Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 }; -fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins); - } -fPoolMgr->SetTargetValues(MaxNofTracks, 0.1, 5); - -//if(!fPoolMgr) return kFALSE; -//return kTRUE; - -} -//------------------------------------------------------------------------ -Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins) -{ - // This method is a copy from AliUEHist::GetBinning - // takes the binning from identified by - // configuration syntax example: - // eta: 2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4 - // phi: ..... - // - // returns bin edges which have to be deleted by the caller - - TString config(configuration); - TObjArray* lines = config.Tokenize("\n"); - for (Int_t i=0; iGetEntriesFast(); i++) - { - TString line(lines->At(i)->GetName()); - if (line.BeginsWith(TString(tag) + ":")) - { - line.Remove(0, strlen(tag) + 1); - line.ReplaceAll(" ", ""); - TObjArray* binning = line.Tokenize(","); - Double_t* bins = new Double_t[binning->GetEntriesFast()]; - for (Int_t j=0; jGetEntriesFast(); j++) - bins[j] = TString(binning->At(j)->GetName()).Atof(); - - nBins = binning->GetEntriesFast() - 1; - - delete binning; - delete lines; - return bins; - } - } - - delete lines; - AliFatal(Form("Tag %s not found in %s", tag, configuration)); - return 0; -} -//_______________________________________________________________________________ -void AliTwoParticlePIDCorr::SetAsymmetricBin(THnSparse *h,Int_t dim,Double_t *arraybin,Int_t arraybinsize,TString axisTitle) -{ - TAxis *axis = 0x0; - axis = h->GetAxis(dim); - axis->Set(arraybinsize,arraybin); - axis->SetTitle(axisTitle); -} - -//________________________________________________________________________ -void AliTwoParticlePIDCorr::Terminate(Option_t *) -{ - // Draw result to screen, or perform fitting, normalizations - // Called once at the end of the query - fOutput = dynamic_cast (GetOutputData(1)); - if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; } - - -} -//------------------------------------------------------------------ - +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +#include "AliTwoParticlePIDCorr.h" +#include "AliVParticle.h" +#include "TFormula.h" +#include "TAxis.h" +#include "TChain.h" +#include "TTree.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TH3F.h" +#include "TList.h" +#include "TFile.h" + +#include "AliCentrality.h" +#include "Riostream.h" + +#include +#include +#include "AliESDpid.h" +#include "AliAODpidUtil.h" +#include + +#include +#include +#include "AliAODInputHandler.h" + +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" +#include "AliCentrality.h" + +#include "AliVEvent.h" +#include "AliAODEvent.h" +#include "AliAODTrack.h" +#include "AliVTrack.h" + +#include "THnSparse.h" + +#include "AliAODMCHeader.h" +#include "AliAODMCParticle.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" +#include "AliMCParticle.h" +#include "TParticle.h" +#include +#include + +#include "AliGenCocktailEventHeader.h" +#include "AliGenEventHeader.h" + +#include "AliEventPoolManager.h" +//#include "AliAnalysisUtils.h" +using namespace AliPIDNameSpace; +using namespace std; + +ClassImp(AliTwoParticlePIDCorr) +ClassImp(LRCParticlePID) +//________________________________________________________________________ +AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be initialised here +:AliAnalysisTaskSE(), + fOutput(0), + fCentralityMethod("V0A"), + fSampleType("pPb"), +fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default) + trkVtx(0), + zvtx(0), + fFilterBit(768), + fzvtxcut(10.0), + ffilltrigassoUNID(kFALSE), + ffilltrigUNIDassoID(kFALSE), + ffilltrigIDassoUNID(kTRUE), + ffilltrigIDassoID(kFALSE), + ffilltrigIDassoIDMCTRUTH(kFALSE), + fPtOrderMCTruth(kFALSE), + fTriggerSpeciesSelection(kFALSE), + fAssociatedSpeciesSelection(kFALSE), + fTriggerSpecies(SpPion), + fAssociatedSpecies(SpPion), + fCustomBinning(""), + fBinningString(""), + fcontainPIDtrig(kTRUE), + fcontainPIDasso(kFALSE), +//frejectPileUp(kFALSE), + fminPt(0.2), + fmaxPt(10.0), + fmineta(-0.8), + fmaxeta(0.8), + fminprotonsigmacut(-6.0), + fmaxprotonsigmacut(-3.0), + fminpionsigmacut(0.0), + fmaxpionsigmacut(4.0), + fselectprimaryTruth(kTRUE), + fonlyprimarydatareco(kFALSE), + fdcacut(kFALSE), + fdcacutvalue(3.0), + ffillhistQAReco(kFALSE), + ffillhistQATruth(kFALSE), + kTrackVariablesPair(0), + fminPtTrig(0), + fmaxPtTrig(0), + fminPtComboeff(2.0), + fmaxPtComboeff(4.0), + fminPtAsso(0), + fmaxPtAsso(0), + fhistcentrality(0), + fEventCounter(0), + fEtaSpectrasso(0), + fphiSpectraasso(0), + MCtruthpt(0), + MCtrutheta(0), + MCtruthphi(0), + MCtruthpionpt(0), + MCtruthpioneta(0), + MCtruthpionphi(0), + MCtruthkaonpt(0), + MCtruthkaoneta(0), + MCtruthkaonphi(0), + MCtruthprotonpt(0), + MCtruthprotoneta(0), + MCtruthprotonphi(0), + fPioncont(0), + fKaoncont(0), + fProtoncont(0), + fCentralityCorrelation(0x0), + fHistoTPCdEdx(0x0), + fHistoTOFbeta(0x0), + fTPCTOFPion3d(0), + fTPCTOFKaon3d(0), + fTPCTOFProton3d(0), + fPionPt(0), + fPionEta(0), + fPionPhi(0), + fKaonPt(0), + fKaonEta(0), + fKaonPhi(0), + fProtonPt(0), + fProtonEta(0), + fProtonPhi(0), + fCorrelatonTruthPrimary(0), + fCorrelatonTruthPrimarymix(0), + fTHnCorrUNID(0), + fTHnCorrUNIDmix(0), + fTHnCorrID(0), + fTHnCorrIDmix(0), + fTHnCorrIDUNID(0), + fTHnCorrIDUNIDmix(0), + fTHnTrigcount(0), + fTHnTrigcountMCTruthPrim(0), + fPoolMgr(0x0), + fArrayMC(0), + fAnalysisType("MCAOD"), + fefffilename(""), + twoTrackEfficiencyCutValue(0.02), +//fControlConvResoncances(0), + fPID(NULL), + eventno(0), + fPtTOFPIDmin(0.6), + fPtTOFPIDmax(4.0), + fRequestTOFPID(kTRUE), + fPIDType(NSigmaTPCTOF), + fNSigmaPID(3), + fUseExclusiveNSigma(kFALSE), + fRemoveTracksT0Fill(kFALSE), +fSelectCharge(0), +fTriggerSelectCharge(0), +fAssociatedSelectCharge(0), +fTriggerRestrictEta(-1), +fEtaOrdering(kFALSE), +fCutConversions(kFALSE), +fCutResonances(kFALSE), +fRejectResonanceDaughters(-1), + fOnlyOneEtaSide(0), +fInjectedSignals(kFALSE), + fRemoveWeakDecays(kFALSE), +fRemoveDuplicates(kFALSE), + fapplyTrigefficiency(kFALSE), + fapplyAssoefficiency(kFALSE), + ffillefficiency(kFALSE), + fmesoneffrequired(kFALSE), + fkaonprotoneffrequired(kFALSE), +//fAnalysisUtils(0x0), + fDCAXYCut(0) + +{ + for ( Int_t i = 0; i < 16; i++) { + fHistQA[i] = NULL; + } + + for ( Int_t i = 0; i < 6; i++ ){ + fTHnrecomatchedallPid[i] = NULL; + fTHngenprimPidTruth[i] = NULL; + effcorection[i]=NULL; + //effmap[i]=NULL; + + } + + for(Int_t ipart=0;ipartIsProofMode()) { + delete fOutput; + + } + if (fPID) delete fPID; + + } +//________________________________________________________________________ +Float_t AliTwoParticlePIDCorr::PhiRange(Float_t DPhi) + +{ + // + // Puts the argument in the range [-pi/2,3 pi/2]. + // + + if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi(); + if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi(); + + return DPhi; + +} +//________________________________________________________________________ +void AliTwoParticlePIDCorr::UserCreateOutputObjects() +{ + // Create histograms + // Called once (on the worker node) + AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); + AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); + fPID = inputHandler->GetPIDResponse(); + + //AliAnalysisUtils *fUtils = new AliAnalysisUtils(); + +//get the efficiency correction map + + + fOutput = new TList(); + fOutput->SetOwner(); // IMPORTANT! + + Int_t centmultbins=10; + Double_t centmultmin=0.0; + Double_t centmultmax=100.0; + if(fSampleType=="pPb" || fSampleType=="PbPb") + { + centmultbins=10; + centmultmin=0.0; + centmultmax=100.0; + } + if(fSampleType=="pp") + { + centmultbins=10; + centmultmin=0.0; + centmultmax=200.0; + } + +fhistcentrality=new TH1F("fhistcentrality","fhistcentrality",centmultbins*4,centmultmin,centmultmax); +fOutput->Add(fhistcentrality); + + fEventCounter = new TH1F("fEventCounter","EventCounter", 10, 0.5,10.5); + fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed"); + fEventCounter->GetXaxis()->SetBinLabel(2,"Have a vertex"); + fEventCounter->GetXaxis()->SetBinLabel(5,"After vertex Cut"); + fEventCounter->GetXaxis()->SetBinLabel(6,"Within 0-100% centrality"); + fEventCounter->GetXaxis()->SetBinLabel(7,"Event Analyzed"); + //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished"); + fOutput->Add(fEventCounter); + +fEtaSpectrasso=new TH2F("fEtaSpectraasso","fEtaSpectraasso",180,-0.9,0.9,100,0.,20. ); +fOutput->Add(fEtaSpectrasso); + +fphiSpectraasso=new TH2F("fphiSpectraasso","fphiSpectraasso",72,0,2*TMath::Pi(),100,0.,20.); +fOutput->Add(fphiSpectraasso); + + + if(fSampleType=="pPb" || fSampleType=="PbPb"){ fCentralityCorrelation = new TH2D("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 20000, 0,40000); + fOutput->Add(fCentralityCorrelation); + } + +fHistoTPCdEdx = new TH2F("hHistoTPCdEdx", ";p_{T} (GeV/c);dE/dx (au.)",200,0.0,10.0,500, 0., 500.); +fOutput->Add(fHistoTPCdEdx); +fHistoTOFbeta = new TH2F(Form("hHistoTOFbeta"), ";p_{T} (GeV/c);v/c",70, 0., 7., 500, 0.1, 1.1); + fOutput->Add(fHistoTOFbeta); + + fTPCTOFPion3d=new TH3F ("fTPCTOFpion3d", "fTPCTOFpion3d",100,0., 10., 120,-60.,60.,120,-60.,60); + fOutput->Add(fTPCTOFPion3d); + + fTPCTOFKaon3d=new TH3F ("fTPCTOFKaon3d", "fTPCTOFKaon3d",100,0., 10., 120,-60.,60.,120,-60.,60); + fOutput->Add(fTPCTOFKaon3d); + + fTPCTOFProton3d=new TH3F ("fTPCTOFProton3d", "fTPCTOFProton3d",100,0., 10., 120,-60.,60.,120,-60.,60); + fOutput->Add(fTPCTOFProton3d); + +if(ffillhistQAReco) + { + fPionPt = new TH1F("fHistQAPionPt","p_{T} distribution",200,0.,10.); + fOutput->Add(fPionPt); + fPionEta= new TH1F("fHistQAPionEta","#eta distribution",360,-1.8,1.8); + fOutput->Add(fPionEta); + fPionPhi = new TH1F("fHistQAPionPhi","#phi distribution",340,0,6.8); + fOutput->Add(fPionPhi); + + fKaonPt = new TH1F("fHistQAKaonPt","p_{T} distribution",200,0.,10.); + fOutput->Add(fKaonPt); + fKaonEta= new TH1F("fHistQAKaonEta","#eta distribution",360,-1.8,1.8); + fOutput->Add(fKaonEta); + fKaonPhi = new TH1F("fHistQAKaonPhi","#phi distribution",340,0,6.8); + fOutput->Add(fKaonPhi); + + fProtonPt = new TH1F("fHistQAProtonPt","p_{T} distribution",200,0.,10.); + fOutput->Add(fProtonPt); + fProtonEta= new TH1F("fHistQAProtonEta","#eta distribution",360,-1.8,1.8); + fOutput->Add(fProtonEta); + fProtonPhi= new TH1F("fHistQAProtonPhi","#phi distribution",340,0,6.8); + fOutput->Add(fProtonPhi); + } + + fHistQA[0] = new TH1F("fHistQAvx", "Histo Vx All ", 50, -5., 5.); + fHistQA[1] = new TH1F("fHistQAvy", "Histo Vy All", 50, -5., 5.); + fHistQA[2] = new TH1F("fHistQAvz", "Histo Vz All", 50, -25., 25.); + fHistQA[3] = new TH1F("fHistQAvxA", "Histo Vx After Cut ", 50, -5., 5.); + fHistQA[4] = new TH1F("fHistQAvyA", "Histo Vy After Cut", 50, -5., 5.); + fHistQA[5] = new TH1F("fHistQAvzA", "Histo Vz After Cut", 50, -25., 25.); + fHistQA[6] = new TH1F("fHistQADcaXyC", "Histo DCAxy after cut", 50, -5., 5.); + fHistQA[7] = new TH1F("fHistQADcaZC", "Histo DCAz after cut", 50, -5., 5.); + fHistQA[8] = new TH1F("fHistQAPt","p_{T} distribution",200,0.,10.); + fHistQA[9] = new TH1F("fHistQAEta","#eta distribution",360,-1.8,1.8); + fHistQA[10] = new TH1F("fHistQAPhi","#phi distribution",340,0,6.8); + fHistQA[11] = new TH1F("fHistQANCls","Number of TPC cluster",200,0,200); + fHistQA[13] = new TH1F("fHistQAChi2","Chi2 per NDF",100,0,10); + fHistQA[12] = new TH1F("fHistQANCls1","Number of TPC cluster1",200,0,200); + fHistQA[14] = new TH1F("nCrossedRowsTPC","Number of TPC ccrossed rows",200,0,200); + fHistQA[15] = new TH1F("ratioCrossedRowsOverFindableClustersTPC","Number of TPC ccrossed rows find clusters",200,0,2); + +for(Int_t i = 0; i < 16; i++) + { + fOutput->Add(fHistQA[i]); + } + + kTrackVariablesPair=6 ; + + if(fcontainPIDtrig && !fcontainPIDasso) kTrackVariablesPair=7; + + if(!fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=7; + + if(fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=8; + + +// two particle histograms + Int_t iBinPair[kTrackVariablesPair]; // binning for track variables + Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables + TString* axisTitlePair; // axis titles for track variables + axisTitlePair=new TString[kTrackVariablesPair]; + + TString defaultBinningStr; + defaultBinningStr = "eta: -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0\n" + "p_t_assoc: 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 8.0,10.0\n" + "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0,10.0\n" + "p_t_eff:0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0,5.5, 6.0, 7.0, 8.0,9.0,10.0\n" + "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n" + "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, 0.0, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n" // this binning starts at -pi/2 and is modulo 3 + "delta_eta: -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,2.1, 2.2, 2.3, 2.4\n" + "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n"; + + if(fcontainPIDtrig){ + defaultBinningStr += "PIDTrig: -0.5,0.5,1.5,2.5,3.5\n"; // course + } + if(fcontainPIDasso){ + defaultBinningStr += "PIDAsso: -0.5,0.5,1.5,2.5,3.5\n"; // course + } + // ========================================================= + // Customization (adopted from AliUEHistograms) + // ========================================================= + + TObjArray* lines = defaultBinningStr.Tokenize("\n"); + for (Int_t i=0; iGetEntriesFast(); i++) + { + TString line(lines->At(i)->GetName()); + TString tag = line(0, line.Index(":")+1); + if (!fCustomBinning.BeginsWith(tag) && !fCustomBinning.Contains(TString("\n") + tag)) + fBinningString += line + "\n"; + else + AliInfo(Form("Using custom binning for %s", tag.Data())); + } + delete lines; + fBinningString += fCustomBinning; + + AliInfo(Form("Used THn Binning:\n%s",fBinningString.Data())); + + // ========================================================= + // Now set the bins + // ========================================================= + + dBinsPair[0] = GetBinning(fBinningString, "multiplicity", iBinPair[0]); + axisTitlePair[0] = " multiplicity"; + + dBinsPair[1] = GetBinning(fBinningString, "vertex", iBinPair[1]); + axisTitlePair[1] = "v_{Z} (cm)"; + + dBinsPair[2] = GetBinning(fBinningString, "p_t_leading_course", iBinPair[2]); + axisTitlePair[2] = "p_{T,trig.} (GeV/c)"; + + dBinsPair[3] = GetBinning(fBinningString, "p_t_assoc", iBinPair[3]); + axisTitlePair[3] = "p_{T,assoc.} (GeV/c)"; + + dBinsPair[4] = GetBinning(fBinningString, "delta_eta", iBinPair[4]); + axisTitlePair[4] = "#Delta#eta"; + + dBinsPair[5] = GetBinning(fBinningString, "delta_phi", iBinPair[5]); + axisTitlePair[5] = "#Delta#varphi (rad)"; + + if(fcontainPIDtrig && !fcontainPIDasso){ + dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]); + axisTitlePair[6] = "PIDTrig"; + } + + if(!fcontainPIDtrig && fcontainPIDasso){ + dBinsPair[6] = GetBinning(fBinningString, "PIDAsso", iBinPair[6]); + axisTitlePair[6] = "PIDAsso"; + } + +if(fcontainPIDtrig && fcontainPIDasso){ + + dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]); + axisTitlePair[6] = "PIDTrig"; + + dBinsPair[7] = GetBinning(fBinningString, "PIDAsso", iBinPair[7]); + axisTitlePair[7] = "PIDAsso"; + } + + Int_t nEtaBin = -1; + Double_t* EtaBin = GetBinning(fBinningString, "eta", nEtaBin); + + Int_t nPteffbin = -1; + Double_t* Pteff = GetBinning(fBinningString, "p_t_eff", nPteffbin); + + + fminPtTrig=dBinsPair[2][0]; + fmaxPtTrig=dBinsPair[2][iBinPair[2]]; + fminPtAsso=dBinsPair[3][0]; + fmaxPtAsso=dBinsPair[3][iBinPair[3]]; + + //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value + //fmaxPtComboeff=fmaxPtTrig; +//THnSparses for calculation of efficiency + + if((fAnalysisType =="MCAOD") && ffillefficiency) { + const Int_t nDim = 4;// cent zvtx pt eta + Int_t fBinsCh[nDim] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//**********************change it + Double_t fMinCh[nDim] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] }; + Double_t fMaxCh[nDim] = { dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]}; + +TString Histrename; +for(Int_t jj=0;jj<6;jj++)//PID type binning + { + Histrename="fTHnrecomatchedallPid";Histrename+=jj; + fTHnrecomatchedallPid[jj] = new THnSparseF(Histrename.Data(),"cent:zvtx::Pt:eta", nDim, fBinsCh, fMinCh, fMaxCh); + fTHnrecomatchedallPid[jj]->Sumw2(); + fTHnrecomatchedallPid[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]); + fTHnrecomatchedallPid[jj]->GetAxis(0)->SetTitle("Centrality"); + fTHnrecomatchedallPid[jj]->GetAxis(1)->Set(iBinPair[1],dBinsPair[1]); + fTHnrecomatchedallPid[jj]->GetAxis(1)->SetTitle("zvtx"); + fTHnrecomatchedallPid[jj]->GetAxis(2)->Set(nPteffbin, Pteff); + fTHnrecomatchedallPid[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); + fTHnrecomatchedallPid[jj]->GetAxis(3)->Set(nEtaBin,EtaBin); + fTHnrecomatchedallPid[jj]->GetAxis(3)->SetTitle("#eta"); + fOutput->Add(fTHnrecomatchedallPid[jj]); + +Histrename="fTHngenprimPidTruth";Histrename+=jj; + fTHngenprimPidTruth[jj] = new THnSparseF(Histrename.Data(),"cent:zvtx::Pt:eta", nDim, fBinsCh, fMinCh, fMaxCh); + fTHngenprimPidTruth[jj]->Sumw2(); + fTHngenprimPidTruth[jj]->GetAxis(0)->Set(iBinPair[0],dBinsPair[0]); + fTHngenprimPidTruth[jj]->GetAxis(0)->SetTitle("Centrality"); + fTHngenprimPidTruth[jj]->GetAxis(1)->Set(iBinPair[1], dBinsPair[1]); + fTHngenprimPidTruth[jj]->GetAxis(1)->SetTitle("zvtx"); + fTHngenprimPidTruth[jj]->GetAxis(2)->Set(nPteffbin, Pteff); + fTHngenprimPidTruth[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); + fTHngenprimPidTruth[jj]->GetAxis(3)->Set(nEtaBin, EtaBin); + fTHngenprimPidTruth[jj]->GetAxis(3)->SetTitle("#eta"); + fOutput->Add(fTHngenprimPidTruth[jj]); + } + } + + Int_t fBins[kTrackVariablesPair]; + Double_t fMin[kTrackVariablesPair]; + Double_t fMax[kTrackVariablesPair]; + +//ThnSparses for Correlation plots(data & MC) + for(Int_t i=0;iSumw2(); + for(Int_t i=0; iAdd(fTHnCorrUNID); + +fTHnCorrUNIDmix = new THnSparseF("fTHnCorrUNIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fTHnCorrUNIDmix->Sumw2(); +for(Int_t i=0; iAdd(fTHnCorrUNIDmix); + } + + if(ffilltrigIDassoID) + { + fTHnCorrID = new THnSparseF("fTHnCorrID","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fTHnCorrID->Sumw2(); +for(Int_t i=0; iAdd(fTHnCorrID); + +fTHnCorrIDmix = new THnSparseF("fTHnCorrIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fTHnCorrIDmix->Sumw2(); +for(Int_t i=0; iAdd(fTHnCorrIDmix); + } + + if(ffilltrigUNIDassoID || ffilltrigIDassoUNID)//***********a bit tricky, be careful + { + fTHnCorrIDUNID = new THnSparseF("fTHnCorrIDUNID","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fTHnCorrIDUNID->Sumw2(); +for(Int_t i=0; iAdd(fTHnCorrIDUNID); + + fTHnCorrIDUNIDmix = new THnSparseF("fTHnCorrIDUNIDmix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fTHnCorrIDUNIDmix->Sumw2(); +for(Int_t i=0; iAdd(fTHnCorrIDUNIDmix); + } + + + + //ThnSparse for Correlation plots(truth MC) + if((fAnalysisType == "MCAOD") && ffilltrigIDassoIDMCTRUTH) {//remember that in this case uidentified means other than pions, kaons, protons + fCorrelatonTruthPrimary = new THnSparseF("fCorrelatonTruthPrimary","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fCorrelatonTruthPrimary->Sumw2(); +for(Int_t i=0; iAdd(fCorrelatonTruthPrimary); + + fCorrelatonTruthPrimarymix = new THnSparseF("fCorrelatonTruthPrimarymix","cent:zvtx:pttrig:ptasso:deltaeta:deltaphi", kTrackVariablesPair, fBins, fMin, fMax); + fCorrelatonTruthPrimarymix->Sumw2(); +for(Int_t i=0; iAdd(fCorrelatonTruthPrimarymix); + } + + + //binning for trigger no. counting + + Double_t* fMint; + Double_t* fMaxt; + Int_t* fBinst; + Int_t dims=3; + if(fcontainPIDtrig) dims=4; + fMint= new Double_t[dims]; + fMaxt= new Double_t[dims]; + fBinst= new Int_t[dims]; + for(Int_t i=0; i<3;i++) + { + fBinst[i]=iBinPair[i]; + fMint[i]=dBinsPair[i][0]; + fMaxt[i]=dBinsPair[i][iBinPair[i]]; + } + if(fcontainPIDtrig){ + fBinst[3]=iBinPair[6]; + fMint[3]=dBinsPair[6][0]; + fMaxt[3]=dBinsPair[6][iBinPair[6]]; + } + + //ThSparse for trigger counting(data & reco MC) + if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID) + { + fTHnTrigcount = new THnSparseF("fTHnTrigcount","cent:zvtx:pt", dims, fBinst, fMint, fMaxt); + fTHnTrigcount->Sumw2(); +for(Int_t i=0; i<3;i++){ + SetAsymmetricBin(fTHnTrigcount,i,dBinsPair[i],iBinPair[i],axisTitlePair[i]); + } + if(fcontainPIDtrig) SetAsymmetricBin(fTHnTrigcount,3,dBinsPair[6],iBinPair[6],axisTitlePair[6]); + fOutput->Add(fTHnTrigcount); + } + + if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) { + //ThSparse for trigger counting(truth MC) +fTHnTrigcountMCTruthPrim = new THnSparseF("fTHnTrigcountMCTruthPrim","cent:zvtx:pt", dims, fBinst, fMint, fMaxt); + fTHnTrigcountMCTruthPrim->Sumw2(); +for(Int_t i=0; i<3;i++){ + SetAsymmetricBin(fTHnTrigcountMCTruthPrim,i,dBinsPair[i],iBinPair[i],axisTitlePair[i]); + } +if(fcontainPIDtrig) SetAsymmetricBin(fTHnTrigcountMCTruthPrim,3,dBinsPair[6],iBinPair[6],axisTitlePair[6]); + fOutput->Add(fTHnTrigcountMCTruthPrim); + } + +if(fAnalysisType=="MCAOD"){ + if(ffillhistQATruth) + { + MCtruthpt=new TH1F ("MCtruthpt","ptdistributiontruthprim",100,0.,10.); + fOutput->Add(MCtruthpt); + + MCtrutheta=new TH1F ("MCtrutheta","etadistributiontruthprim",360,-1.8,1.8); + fOutput->Add(MCtrutheta); + + MCtruthphi=new TH1F ("MCtruthphi","phidisttruthprim",340,0,6.8); + fOutput->Add(MCtruthphi); + + MCtruthpionpt=new TH1F ("MCtruthpionpt","MCtruthpionpt",100,0.,10.); + fOutput->Add(MCtruthpionpt); + + MCtruthpioneta=new TH1F ("MCtruthpioneta","MCtruthpioneta",360,-1.8,1.8); + fOutput->Add(MCtruthpioneta); + + MCtruthpionphi=new TH1F ("MCtruthpionphi","MCtruthpionphi",340,0,6.8); + fOutput->Add(MCtruthpionphi); + + MCtruthkaonpt=new TH1F ("MCtruthkaonpt","MCtruthkaonpt",100,0.,10.); + fOutput->Add(MCtruthkaonpt); + + MCtruthkaoneta=new TH1F ("MCtruthkaoneta","MCtruthkaoneta",360,-1.8,1.8); + fOutput->Add(MCtruthkaoneta); + + MCtruthkaonphi=new TH1F ("MCtruthkaonphi","MCtruthkaonphi",340,0,6.8); + fOutput->Add(MCtruthkaonphi); + + MCtruthprotonpt=new TH1F ("MCtruthprotonpt","MCtruthprotonpt",100,0.,10.); + fOutput->Add(MCtruthprotonpt); + + MCtruthprotoneta=new TH1F ("MCtruthprotoneta","MCtruthprotoneta",360,-1.8,1.8); + fOutput->Add(MCtruthprotoneta); + + MCtruthprotonphi=new TH1F ("MCtruthprotonphi","MCtruthprotonphi",340,0,6.8); + fOutput->Add(MCtruthprotonphi); + } + fPioncont=new TH2F("fPioncont", "fPioncont",10,-0.5,9.5,100,0.,10.); + fOutput->Add(fPioncont); + + fKaoncont=new TH2F("fKaoncont","fKaoncont",10,-0.5,9.5,100,0.,10.); + fOutput->Add(fKaoncont); + + fProtoncont=new TH2F("fProtoncont","fProtoncont",10,-0.5,9.5,100,0.,10.); + fOutput->Add(fProtoncont); + } + +//Mixing +DefineEventPool(); + + if(fapplyTrigefficiency || fapplyAssoefficiency) + { + const Int_t nDimt = 4;// cent zvtx pt eta + Int_t fBinsCht[nDimt] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//*************change it + Double_t fMinCht[nDimt] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] }; + Double_t fMaxCht[nDimt] = {dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]}; + + TString Histrexname; +for(Int_t jj=0;jj<6;jj++)// PID type binning + { + Histrexname="effcorection";Histrexname+=jj; + effcorection[jj] = new THnSparseF(Histrexname.Data(),"cent:zvtx::Pt:eta", nDimt, fBinsCht, fMinCht, fMaxCht); + effcorection[jj]->Sumw2(); + effcorection[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]); + effcorection[jj]->GetAxis(0)->SetTitle("Centrality"); + effcorection[jj]->GetAxis(1)->Set( iBinPair[1],dBinsPair[1]); + effcorection[jj]->GetAxis(1)->SetTitle("zvtx"); + effcorection[jj]->GetAxis(2)->Set(nPteffbin, Pteff); + effcorection[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)"); + effcorection[jj]->GetAxis(3)->Set( nEtaBin,EtaBin); + effcorection[jj]->GetAxis(3)->SetTitle("#eta"); + fOutput->Add(effcorection[jj]); + } +// TFile *fsifile = new TFile(fefffilename,"READ"); + TFile *fileT=TFile::Open(fefffilename); + TString Nameg; +for(Int_t jj=0;jj<6;jj++)//type binning + { +Nameg="effmap";Nameg+=jj; +//effcorection[jj] = (THnSparseF*)fsifile->Get(Nameg.Data()); +effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data()); + +//effcorection[jj]->SetDirectory(0);//****************************not present in case oh THnF + } +//fsifile->Close(); +fileT->Close(); + + } + +//fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1); +// fOutput->Add(fControlConvResoncances); + + + PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram +} +//------------------------------------------------------------------------------- +void AliTwoParticlePIDCorr::UserExec( Option_t * ){ + + + if(fAnalysisType == "AOD") { + + doAODevent(); + + }//AOD--analysis----- + + else if(fAnalysisType == "MCAOD") { + + doMCAODevent(); + + } + + else return; + +} +//------------------------------------------------------------------------- +void AliTwoParticlePIDCorr::doMCAODevent() +{ + AliVEvent *event = InputEvent(); + if (!event) { Printf("ERROR: Could not retrieve event"); return; } + AliAODEvent* aod = dynamic_cast(event); + if (!aod) { + AliError("Cannot get the AOD event"); + return; + } + +// count all events(physics triggered) + fEventCounter->Fill(1); + + // get centrality object and check quality(valid for p-Pb and Pb-Pb) + Double_t cent_v0=0.0; + + if(fSampleType=="pPb" || fSampleType=="PbPb") + { + AliCentrality *centrality=0; + if(aod) + centrality = aod->GetHeader()->GetCentralityP(); + // if (centrality->GetQuality() != 0) return ; + + if(centrality) + { + cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod); + } + else + { + cent_v0= -1; + } + } + +//check the PIDResponse handler + if (!fPID) return; + +// get mag. field required for twotrack efficiency cut + Float_t bSign = 0; + bSign = (aod->GetMagneticField() > 0) ? 1 : -1; + + //check for TClonesArray(truth track MC information) +fArrayMC = dynamic_cast(aod->FindListObject(AliAODMCParticle::StdBranchName())); + if (!fArrayMC) { + AliFatal("Error: MC particles branch not found!\n"); + return; + } + + //check for AliAODMCHeader(truth event MC information) + AliAODMCHeader *header=NULL; + header=(AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()); + if(!header) { + printf("MC header branch not found!\n"); + return; + } + +//Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex +Float_t zVtxmc =header->GetVtxZ(); + if(TMath::Abs(zVtxmc)>fzvtxcut) return; + + // For productions with injected signals, figure out above which label to skip particles/tracks + Int_t skipParticlesAbove = 0; + + if (fInjectedSignals) + { + AliGenEventHeader* eventHeader = 0; + Int_t headers = 0; + +// AOD + if (!header) + AliFatal("fInjectedSignals set but no MC header found"); + + headers = header->GetNCocktailHeaders(); + eventHeader = header->GetCocktailHeader(0); + + if (!eventHeader) + { + // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing + // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events + AliError("First event header not found. Skipping this event."); + //fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology); + return; + } +skipParticlesAbove = eventHeader->NProduced(); + AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove)); + } + + //vertex selection(is it fine for PP?) + if ( fSampleType=="pPb"){ + trkVtx = aod->GetPrimaryVertex(); + if (!trkVtx || trkVtx->GetNContributors()<=0) return; + TString vtxTtl = trkVtx->GetTitle(); + if (!vtxTtl.Contains("VertexerTracks")) return; + zvtx = trkVtx->GetZ(); + const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD(); + if (!spdVtx || spdVtx->GetNContributors()<=0) return; + TString vtxTyp = spdVtx->GetTitle(); + Double_t cov[6]={0}; + spdVtx->GetCovarianceMatrix(cov); + Double_t zRes = TMath::Sqrt(cov[5]); + if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return; + if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return; + } + else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case + Int_t nVertex = aod->GetNumberOfVertices(); + if( nVertex > 0 ) { + trkVtx = aod->GetPrimaryVertex(); + Int_t nTracksPrim = trkVtx->GetNContributors(); + zvtx = trkVtx->GetZ(); + //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName())); + // Reject TPC only vertex + TString name(trkVtx->GetName()); + if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return; + + // Select a quality vertex by number of tracks? + if( nTracksPrim < fnTracksVertex ) { + //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ..."); + return ; + } + // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present + //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02) + // return kFALSE; + // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED..."); + } + else return; + + } + else return;//as there is no proper sample type + + + fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm + + //count events having a proper vertex + fEventCounter->Fill(2); + + if (TMath::Abs(zvtx) > fzvtxcut) return; + +fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut for trkVtx only + +//now we have events passed physics trigger, centrality,eventzvtx cut + +//count events after vertex cut + fEventCounter->Fill(5); + +if(!aod) return; //for safety + +if (fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity + + Double_t nooftrackstruth=0.0;//in case of pp this will give the multiplicity(for truth case) after the track loop(only for unidentified particles that pass kinematic cuts) + + Double_t cent_v0_truth=0.0; + + //TObjArray* tracksMCtruth=0; +TObjArray* tracksMCtruth=new TObjArray;//for truth MC particles with PID,here unidentified means any particle other than pion, kaon or proton(Basicaly Spundefined of AliHelperPID)******WARNING::different from data and reco MC + tracksMCtruth->SetOwner(kTRUE); //***********************************IMPORTANT! + + eventno++; + + //There is a small difference between zvtx and zVtxmc?????? + //cout<<"***********************************************zVtxmc="<Charge() == 0) continue; + +//consider only primary particles; neglect all secondary particles including from weak decays + if(fselectprimaryTruth && !partMC->IsPhysicalPrimary()) continue; + + +//remove injected signals(primaries above ) + if (fInjectedSignals && partMC->GetLabel() >= skipParticlesAbove) continue; + +//remove duplicates + Bool_t isduplicate=kFALSE; + if (fRemoveDuplicates) + { + for (Int_t j=iMC+1; jAt(j); + if(!partMC2){ + AliError(Form("ERROR: Could not retrieve AODMCtrack %d",j)); + continue; + } + if (partMC->GetLabel() == partMC2->GetLabel()) + { +isduplicate=kTRUE; + break; + } + }//2nd truth loop ends + } + if(fRemoveDuplicates && isduplicate) continue;//remove duplicates + +//give only kinematic cuts at the truth level + if (partMC->Eta() < fmineta || partMC->Eta() > fmaxeta) continue; + if (partMC->Pt() < fminPt || partMC->Pt() > fmaxPt) continue; + + if(!partMC) continue;//for safety + + //To determine multiplicity in case of PP + nooftrackstruth++; + //cout<<"**************************************"<GetLabel())<Fill(partMC->Pt()); + MCtrutheta->Fill(partMC->Eta()); + MCtruthphi->Fill(partMC->Phi()); + } + //get particle ID +Int_t pdgtruth=((AliAODMCParticle*)partMC)->GetPdgCode(); +Int_t particletypeTruth=-999; + if (TMath::Abs(pdgtruth)==211) + { + particletypeTruth=SpPion; +if(ffillhistQATruth) + { + MCtruthpionpt->Fill(partMC->Pt()); + MCtruthpioneta->Fill(partMC->Eta()); + MCtruthpionphi->Fill(partMC->Phi()); + } + } + if (TMath::Abs(pdgtruth)==321) + { + particletypeTruth=SpKaon; +if(ffillhistQATruth) + { + MCtruthkaonpt->Fill(partMC->Pt()); + MCtruthkaoneta->Fill(partMC->Eta()); + MCtruthkaonphi->Fill(partMC->Phi()); + } + } +if(TMath::Abs(pdgtruth)==2212) + { + particletypeTruth=SpProton; +if(ffillhistQATruth) + { + MCtruthprotonpt->Fill(partMC->Pt()); + MCtruthprotoneta->Fill(partMC->Eta()); + MCtruthprotonphi->Fill(partMC->Phi()); + } + } + if(TMath::Abs(pdgtruth)!=211 && TMath::Abs(pdgtruth)!=321 && TMath::Abs(pdgtruth)!=2212) particletypeTruth=unidentified;//*********************WARNING:: situation is different from reco MC and data case(here we don't have SpUndefined particles,because here unidentified=SpUndefined) + + // -- Fill THnSparse for efficiency and contamination calculation + if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicity i.e. multiplicity intregated out )**************Important + + Double_t primmctruth[4] = {cent_v0, zVtxmc,partMC->Pt(), partMC->Eta()}; + if(ffillefficiency) + { + fTHngenprimPidTruth[5]->Fill(primmctruth);//for all primary truth particles(4) +if (TMath::Abs(pdgtruth)==211 || TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[3]->Fill(primmctruth);//for primary truth mesons(3) +if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[4]->Fill(primmctruth);//for primary truth kaons+protons(4) + if (TMath::Abs(pdgtruth)==211) fTHngenprimPidTruth[0]->Fill(primmctruth);//for pions + if (TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth[1]->Fill(primmctruth);//for kaons + if(TMath::Abs(pdgtruth)==2212) fTHngenprimPidTruth[2]->Fill(primmctruth);//for protons + } + + Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0 +if(partMC->Pt()>=fminPtAsso || partMC->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool + { +LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth); +//copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel())); + copy6->SetUniqueID(eventno * 100000 + (Int_t)nooftrackstruth); + tracksMCtruth->Add(copy6);//************** TObjArray used for truth correlation function calculation + } + }//MC truth track loop ends + +//*********************still in event loop + + if (fSampleType=="pp") cent_v0_truth=nooftrackstruth; + else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case + + //now cent_v0_truth should be used for all correlation function calculation + +if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH) + { + //Fill Correlations for MC truth particles(same event) +if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation + Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case + +//start mixing +AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200); +if (pool2 && pool2->IsReady()) + {//start mixing only when pool->IsReady +if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0) + {//proceed only when no. of trigger particles >0 in current event +for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) + { //pool event loop start + TObjArray* bgTracks6 = pool2->GetEvent(jMix); + if(!bgTracks6) continue; + Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case + + }// pool event loop ends mixing case + }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case +} //if pool->IsReady() condition ends mixing case + + //still in main event loop + + if(tracksMCtruth){ +if(pool2) pool2->UpdatePool(CloneAndReduceTrackList(tracksMCtruth));//ownership of tracksasso is with pool now, don't delete it + } + } + + //still in main event loop + +if(tracksMCtruth) delete tracksMCtruth; + +//now deal with reco tracks + //TObjArray* tracksUNID=0; + TObjArray* tracksUNID = new TObjArray; + tracksUNID->SetOwner(kTRUE); + + //TObjArray* tracksID=0; + TObjArray* tracksID = new TObjArray; + tracksID->SetOwner(kTRUE); + + + Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//used for reconstructed track dca cut + + Double_t trackscount=0.0; + +// loop over reconstructed tracks + for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++) +{ // reconstructed track loop starts + AliAODTrack* track = dynamic_cast(aod->GetTrack(itrk)); + if (!track) continue; + //get the corresponding MC track at the truth level (doing reco matching) + AliAODMCParticle* recomatched = static_cast(fArrayMC->At(TMath::Abs(track->GetLabel()))); + if(!recomatched) continue;//if a reco track doesn't have corresponding truth track at generated level is a fake track(label==0), ignore it + +//remove injected signals + if(fInjectedSignals) + { + AliAODMCParticle* mother = recomatched; + + while (!mother->IsPhysicalPrimary()) + {// find the primary mother;the first stable mother is searched and checked if it is <= + if (mother->GetMother() < 0) + { + mother = 0; + break; + } + + mother =(AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother()); + if (!mother) + break; + } + if (!mother) + { + Printf("WARNING: No mother found for particle %d:", recomatched->GetLabel()); + continue; + } + if (mother->GetLabel() >= skipParticlesAbove) continue;//remove injected signals(primaries above ) + }//remove injected signals + + if (fRemoveWeakDecays && ((AliAODMCParticle*) recomatched)->IsSecondaryFromWeakDecay()) continue;//remove weak decays + + Bool_t isduplicate2=kFALSE; +if (fRemoveDuplicates) + { + for (Int_t j =itrk+1; j < aod->GetNumberOfTracks(); j++) + {//2nd loop starts + AliAODTrack* track2 = dynamic_cast(aod->GetTrack(j)); + if (!track2) continue; + AliAODMCParticle* recomatched2 = static_cast(fArrayMC->At(TMath::Abs(track2->GetLabel()))); +if(!recomatched2) continue; + +if (track->GetLabel() == track2->GetLabel()) + { +isduplicate2=kTRUE; + break; + } + }//2nd loop ends + } + if(fRemoveDuplicates && isduplicate2) continue;//remove duplicates + + fHistQA[11]->Fill(track->GetTPCNcls()); + Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE + + if(tracktype==0) continue; + if(tracktype==1)//tracks "not" passed AliAODTrack::kPrimary at reconstructed level & have proper TPC PID response(?) +{ + if(!track) continue;//for safety + //accepted all(primaries+secondary) reconstructed tracks(pt 0.2 to 10.0,,eta -0.8 to 0.8) + trackscount++; + +//check for eta , phi holes + fEtaSpectrasso->Fill(track->Eta(),track->Pt()); + fphiSpectraasso->Fill(track->Phi(),track->Pt()); + + Int_t particletypeMC=-9999; + +//tag all particles as unidentified + particletypeMC=unidentified; + + Float_t effmatrix=1.; + +// -- Fill THnSparse for efficiency calculation + if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important + //NOTE:: this will be used for fillinfg THnSparse of efficiency & also to get the the track by track eff. factor on the fly(only in case of pp) + + //Clone & Reduce track list(TObjArray) for unidentified particles +if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool + { + if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles + effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC); + LRCParticlePID* copy = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); + copy->SetUniqueID(eventno * 100000 +(Int_t)trackscount); + tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only) + } + Double_t allrecomatchedpid[4] = {cent_v0, zVtxmc,recomatched->Pt(), recomatched->Eta()}; +if(ffillefficiency) fTHnrecomatchedallPid[5]->Fill(allrecomatchedpid);//for all + + //now start the particle identification process:) + +//get the pdg code of the corresponding truth particle + Int_t pdgCode = ((AliAODMCParticle*)recomatched)->GetPdgCode(); + +Float_t dEdx = track->GetTPCsignal(); + fHistoTPCdEdx->Fill(track->Pt(), dEdx); + + if(HasTOFPID(track)) +{ +Float_t beta = GetBeta(track); +fHistoTOFbeta->Fill(track->Pt(), beta); + } + + //do track identification(nsigma method) + particletypeMC=GetParticle(track);//******************************problem is here + +//2-d TPCTOF map(for each Pt interval) + if(HasTOFPID(track)){ + fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]); + fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]); + fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]); + } + if(particletypeMC==SpUndefined) continue; + + //Pt, Eta , Phi distribution of the reconstructed identified particles +if(ffillhistQAReco) + { +if (particletypeMC==SpPion) + { + fPionPt->Fill(track->Pt()); + fPionEta->Fill(track->Eta()); + fPionPhi->Fill(track->Phi()); + } +if (particletypeMC==SpKaon) + { + fKaonPt->Fill(track->Pt()); + fKaonEta->Fill(track->Eta()); + fKaonPhi->Fill(track->Phi()); + } +if (particletypeMC==SpProton) + { + fProtonPt->Fill(track->Pt()); + fProtonEta->Fill(track->Eta()); + fProtonPhi->Fill(track->Phi()); + } + } + + //for misidentification fraction calculation(do it with tuneonPID) + if(particletypeMC==SpPion ) + { + if(TMath::Abs(pdgCode)==211) fPioncont->Fill(1.,track->Pt()); + if(TMath::Abs(pdgCode)==321) fPioncont->Fill(3.,track->Pt()); + if(TMath::Abs(pdgCode)==2212) fPioncont->Fill(5.,track->Pt()); + if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fPioncont->Fill(7.,track->Pt()); + } +if(particletypeMC==SpKaon ) + { + if(TMath::Abs(pdgCode)==211) fKaoncont->Fill(1.,track->Pt()); + if(TMath::Abs(pdgCode)==321) fKaoncont->Fill(3.,track->Pt()); + if(TMath::Abs(pdgCode)==2212) fKaoncont->Fill(5.,track->Pt()); + if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fKaoncont->Fill(7.,track->Pt()); + } + if(particletypeMC==SpProton ) + { + if(TMath::Abs(pdgCode)==211) fProtoncont->Fill(1.,track->Pt()); + if(TMath::Abs(pdgCode)==321) fProtoncont->Fill(3.,track->Pt()); + if(TMath::Abs(pdgCode)==2212) fProtoncont->Fill(5.,track->Pt()); + if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fProtoncont->Fill(7.,track->Pt()); + } + + //fill tracking efficiency + if(ffillefficiency) + { + if(particletypeMC==SpPion || particletypeMC==SpKaon) + { +if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTHnrecomatchedallPid[3]->Fill(allrecomatchedpid);//for mesons + } + if(particletypeMC==SpKaon || particletypeMC==SpProton) + { +if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTHnrecomatchedallPid[4]->Fill(allrecomatchedpid);//for kaons+protons + } + if(particletypeMC==SpPion && TMath::Abs(pdgCode)==211) fTHnrecomatchedallPid[0]->Fill(allrecomatchedpid);//for pions + if(particletypeMC==SpKaon && TMath::Abs(pdgCode)==321) fTHnrecomatchedallPid[1]->Fill(allrecomatchedpid);//for kaons + if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212) fTHnrecomatchedallPid[2]->Fill(allrecomatchedpid);//for protons + } + +if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool + { +if (fapplyTrigefficiency || fapplyAssoefficiency) + effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles + LRCParticlePID* copy1 = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); + copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount); + tracksID->Add(copy1); + } + }// if(tracktype==1) condition structure ands + +}//reco track loop ends + + //*************************************************************still in event loop + +//same event delta-eta-deltaphi plot +if(fSampleType=="pp") cent_v0=trackscount;//multiplicity + +if(trackscount>0.0) + { +//fill the centrality/multiplicity distribution of the selected events + fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case + + if (fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers?????? + +//count selected events having centrality betn 0-100% + fEventCounter->Fill(6); + + //same event delte-eta, delta-phi plot +if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation + {//same event calculation starts + if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation) + if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation) + } + +if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation + {//same event calculation starts + if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation) + if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation) + } + +//still in main event loop +//start mixing + if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles +AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified) +if (pool && pool->IsReady()) + {//start mixing only when pool->IsReady + for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) + { //pool event loop start + TObjArray* bgTracks = pool->GetEvent(jMix); + if(!bgTracks) continue; + if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing + Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE + if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing + Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE + }// pool event loop ends mixing case + +} //if pool->IsReady() condition ends mixing case + if(tracksUNID) { +if(pool) + pool->UpdatePool(CloneAndReduceTrackList(tracksUNID)); + } + }//mixing with unidentified particles + + if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles +AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified) +if (pool1 && pool1->IsReady()) + {//start mixing only when pool->IsReady +for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) + { //pool event loop start + TObjArray* bgTracks2 = pool1->GetEvent(jMix); + if(!bgTracks2) continue; +if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0) + Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE +if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0) + Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE + + }// pool event loop ends mixing case +} //if pool1->IsReady() condition ends mixing case + +if(tracksID) { +if(pool1) + pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool) + } + }//mixing with identified particles + + //no. of events analyzed +fEventCounter->Fill(7); + } + +if(tracksUNID) delete tracksUNID; + +if(tracksID) delete tracksID; + + +PostData(1, fOutput); + +} +//________________________________________________________________________ +void AliTwoParticlePIDCorr::doAODevent() +{ + + //get AOD + AliVEvent *event = InputEvent(); + if (!event) { Printf("ERROR: Could not retrieve event"); return; } + AliAODEvent* aod = dynamic_cast(event); + if (!aod) { + AliError("Cannot get the AOD event"); + return; + } + +// count all events + fEventCounter->Fill(1); + + // get centrality object and check quality + Double_t cent_v0=0; + + if(fSampleType=="pPb" || fSampleType=="PbPb") + { + AliCentrality *centrality=0; + if(aod) + centrality = aod->GetHeader()->GetCentralityP(); + // if (centrality->GetQuality() != 0) return ; + + if(centrality) + { + cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod); + } + else + { + cent_v0= -1; + } + } + + Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation + Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop + +// Pileup selection ************************************************ +// if(frejectPileUp) //applicable only for TPC only tracks,not for hybrid tracks?. + // { + //if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return; + // } + + if (!fPID) return;//this should be available with each event even if we don't do PID selection + + //vertex selection(is it fine for PP?) + if ( fSampleType=="pPb"){ + trkVtx = aod->GetPrimaryVertex(); + if (!trkVtx || trkVtx->GetNContributors()<=0) return; + TString vtxTtl = trkVtx->GetTitle(); + if (!vtxTtl.Contains("VertexerTracks")) return; + zvtx = trkVtx->GetZ(); + const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD(); + if (!spdVtx || spdVtx->GetNContributors()<=0) return; + TString vtxTyp = spdVtx->GetTitle(); + Double_t cov[6]={0}; + spdVtx->GetCovarianceMatrix(cov); + Double_t zRes = TMath::Sqrt(cov[5]); + if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return; + if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return; + } + else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case + Int_t nVertex = aod->GetNumberOfVertices(); + if( nVertex > 0 ) { + trkVtx = aod->GetPrimaryVertex(); + Int_t nTracksPrim = trkVtx->GetNContributors(); + zvtx = trkVtx->GetZ(); + //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName())); + // Reject TPC only vertex + TString name(trkVtx->GetName()); + if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return; + + // Select a quality vertex by number of tracks? + if( nTracksPrim < fnTracksVertex ) { + //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ..."); + return ; + } + // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present + //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02) + // return kFALSE; + // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED..."); + } + else return; + + } + else return;//as there is no proper sample type + + + fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm + +//count events having a proper vertex + fEventCounter->Fill(2); + + if (TMath::Abs(zvtx) > fzvtxcut) return; + +//count events after vertex cut + fEventCounter->Fill(5); + + + //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return; + + fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only + + + if(!aod) return; //for safety + +if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity + + TObjArray* tracksUNID= new TObjArray;//track info before doing PID + tracksUNID->SetOwner(kTRUE); // IMPORTANT! + + TObjArray* tracksID= new TObjArray;//only pions, kaons,protonsi.e. after doing the PID selection + tracksID->SetOwner(kTRUE); // IMPORTANT! + + Double_t trackscount=0.0;//in case of pp this will give the multiplicity after the track loop(only for unidentified particles that pass the filterbit and kinematic cuts) + + eventno++; + + for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++) +{ //track loop starts for TObjArray(containing track and event information) filling; used for correlation function calculation + AliAODTrack* track = dynamic_cast(aod->GetTrack(itrk)); + if (!track) continue; + fHistQA[11]->Fill(track->GetTPCNcls()); + Int_t particletype=-9999;//required for PID filling + Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE + if(tracktype!=1) continue; + + if(!track) continue;//for safety + +//check for eta , phi holes + fEtaSpectrasso->Fill(track->Eta(),track->Pt()); + fphiSpectraasso->Fill(track->Phi(),track->Pt()); + + trackscount++; + + //if no applyefficiency , set the eff factor=1.0 + Float_t effmatrix=1.0; + + //tag all particles as unidentified that passed filterbit & kinematic cuts + particletype=unidentified; + + + if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity [i.e each track has multiplicity 15.0](so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important for efficiency related issues + + + //to reduce memory consumption in pool + if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig) + { + //Clone & Reduce track list(TObjArray) for unidentified particles + if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles + effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype); + LRCParticlePID* copy = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); + copy->SetUniqueID(eventno * 100000 + (Int_t)trackscount); + tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only) + } + +//now start the particle identificaion process:) + +//track passing filterbit 768 have proper TPC response,or need to be checked explicitly before doing PID???? + + Float_t dEdx = track->GetTPCsignal(); + fHistoTPCdEdx->Fill(track->Pt(), dEdx); + + //fill beta vs Pt plots only for tracks having proper TOF response(much less tracks compared to the no. that pass the filterbit & kinematic cuts) + if(HasTOFPID(track)) +{ + Float_t beta = GetBeta(track); + fHistoTOFbeta->Fill(track->Pt(), beta); + } + + +//track identification(using nsigma method) + particletype=GetParticle(track);//*******************************change may be required(It should return only pion,kaon, proton and Spundefined; NOT unidentifed***************be careful) + + +//2-d TPCTOF map(for each Pt interval) + if(HasTOFPID(track)){ + fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]); + fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]); + fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]); + } + +//ignore the Spundefined particles as they also contain pion, kaon, proton outside the nsigma cut(also if tracks don't have proper TOF PID in a certain Pt interval) & these tracks are actually counted when we do the the efficiency correction, so considering them as unidentified particles & doing the efficiency correction(i.e defining unidentified=pion+Kaon+proton+SpUndefined is right only without efficiency correction) for them will be two times wrong!!!!! + if (particletype==SpUndefined) continue;//this condition creating a modulated structure in delphi projection in mixed event case(only when we are dealing with identified particles i.e. tracksID)!!!!!!!!!!! + + //Pt, Eta , Phi distribution of the reconstructed identified particles +if(ffillhistQAReco) + { +if (particletype==SpPion) + { + fPionPt->Fill(track->Pt()); + fPionEta->Fill(track->Eta()); + fPionPhi->Fill(track->Phi()); + } +if (particletype==SpKaon) + { + fKaonPt->Fill(track->Pt()); + fKaonEta->Fill(track->Eta()); + fKaonPhi->Fill(track->Phi()); + } +if (particletype==SpProton) + { + fProtonPt->Fill(track->Pt()); + fProtonEta->Fill(track->Eta()); + fProtonPhi->Fill(track->Phi()); + } + } + +if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig) + { +if (fapplyTrigefficiency || fapplyAssoefficiency) + effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles; Bool_t mesoneffrequired=kFALSE + LRCParticlePID* copy1 = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix); + copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount); + tracksID->Add(copy1); + } +} //track loop ends but still in event loop + +if(trackscount<1.0){ + if(tracksUNID) delete tracksUNID; + if(tracksID) delete tracksID; + return; + } + +// cout<Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case + +if(fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers?????? + +//count selected events having centrality betn 0-100% + fEventCounter->Fill(6); + +//same event delta-eta-deltaphi plot + +if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation + {//same event calculation starts + if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation) + if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation) + } + +if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation + {//same event calculation starts + if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation) + if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation) + } + +//still in main event loop + + +//start mixing + if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles +AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified) +if (pool && pool->IsReady()) + {//start mixing only when pool->IsReady + for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) + { //pool event loop start + TObjArray* bgTracks = pool->GetEvent(jMix); + if(!bgTracks) continue; + if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing + Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE + if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing + Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE + }// pool event loop ends mixing case + +} //if pool->IsReady() condition ends mixing case + if(tracksUNID) { +if(pool) + pool->UpdatePool(CloneAndReduceTrackList(tracksUNID)); + } + }//mixing with unidentified particles + + + if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles +AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified) +if (pool1 && pool1->IsReady()) + {//start mixing only when pool->IsReady +for (Int_t jMix=0; jMixGetCurrentNEvents(); jMix++) + { //pool event loop start + TObjArray* bgTracks2 = pool1->GetEvent(jMix); + if(!bgTracks2) continue; +if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0) + Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE +if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0) + Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE + + }// pool event loop ends mixing case +} //if pool1->IsReady() condition ends mixing case + +if(tracksID) { +if(pool1) + pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool) + } + }//mixing with identified particles + + + //no. of events analyzed +fEventCounter->Fill(7); + +//still in main event loop + + +if(tracksUNID) delete tracksUNID; + +if(tracksID) delete tracksID; + + +PostData(1, fOutput); + +} // *************************event loop ends******************************************//_______________________________________________________________________ +TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks) +{ + // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing) + + TObjArray* tracksClone = new TObjArray; + tracksClone->SetOwner(kTRUE); + + for (Int_t i=0; iGetEntriesFast(); i++) + { + LRCParticlePID* particle = (LRCParticlePID*) tracks->UncheckedAt(i); + LRCParticlePID* copy100 = new LRCParticlePID(particle->getparticle(),particle->Charge(), particle->Pt(),particle->Eta(), particle->Phi(), particle->geteffcorrectionval()); + copy100->SetUniqueID(particle->GetUniqueID()); + tracksClone->Add(copy100); + } + + return tracksClone; +} + +//-------------------------------------------------------------------------------- +void AliTwoParticlePIDCorr::Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup) +{ + + //before calling this function check that either trackstrig & tracksasso are available + + // Eta() is extremely time consuming, therefore cache it for the inner loop here: + TObjArray* input = (tracksasso) ? tracksasso : trackstrig; + TArrayF eta(input->GetEntriesFast()); + for (Int_t i=0; iGetEntriesFast(); i++) + eta[i] = ((LRCParticlePID*) input->UncheckedAt(i))->Eta(); + + //if(trackstrig) + Int_t jmax=trackstrig->GetEntriesFast(); + if(tracksasso) + jmax=tracksasso->GetEntriesFast(); + +// identify K, Lambda candidates and flag those particles + // a TObject bit is used for this +const UInt_t kResonanceDaughterFlag = 1 << 14; + if (fRejectResonanceDaughters > 0) + { + Double_t resonanceMass = -1; + Double_t massDaughter1 = -1; + Double_t massDaughter2 = -1; + const Double_t interval = 0.02; + switch (fRejectResonanceDaughters) + { + case 1: resonanceMass = 0.9; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // method test + case 2: resonanceMass = 0.4976; massDaughter1 = 0.1396; massDaughter2 = massDaughter1; break; // k0 + case 3: resonanceMass = 1.115; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // lambda + default: AliFatal(Form("Invalid setting %d", fRejectResonanceDaughters)); + } + +for (Int_t i=0; iGetEntriesFast(); i++) + trackstrig->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag); + for (Int_t i=0; tracksasso->GetEntriesFast(); i++) + tracksasso->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag); + + for (Int_t i=0; iGetEntriesFast(); i++) + { + LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i)); +for (Int_t j=0; tracksasso->GetEntriesFast(); j++) + { + LRCParticlePID *asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j)); + + // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event) +if (trig->IsEqual(asso)) continue; + +if (trig->Charge() * asso->Charge() > 0) continue; + + Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2); + +if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5) + { + mass = GetInvMassSquared(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2); + + if (mass > (resonanceMass-interval)*(resonanceMass-interval) && mass < (resonanceMass+interval)*(resonanceMass+interval)) + { + trig->SetBit(kResonanceDaughterFlag); + asso->SetBit(kResonanceDaughterFlag); + +// Printf("Flagged %d %d %f", i, j, TMath::Sqrt(mass)); + } + } + } + } + } + + //two particle correlation filling + +for(Int_t i=0;iGetEntriesFast();i++) + { //trigger loop starts + LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i)); + if(!trig) continue; + Float_t trigpt=trig->Pt(); + //to avoid overflow qnd underflow + if(trigptfmaxPtTrig) continue; + Int_t particlepidtrig=trig->getparticle(); + if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;} + + Float_t trigeta=trig->Eta(); + + // some optimization + if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta) + continue; + +if (fOnlyOneEtaSide != 0) + { + if (fOnlyOneEtaSide * trigeta < 0) + continue; + } + if (fTriggerSelectCharge != 0) + if (trig->Charge() * fTriggerSelectCharge < 0) + continue; + + if (fRejectResonanceDaughters > 0) + if (trig->TestBit(kResonanceDaughterFlag)) continue; + + Float_t trigphi=trig->Phi(); + Float_t trackefftrig=1.0; + if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval(); + // cout<<"*******************trackefftrig="<Fill(trigval,1.0/trackefftrig); + } + if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kFALSE){ + if(fillup=="trigassoUNID" ) fTHnTrigcount->Fill(trigval,1.0/trackefftrig); + } +if(ffilltrigassoUNID==kFALSE && ffilltrigUNIDassoID==kTRUE){ + if(fillup=="trigUNIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); + } + //ensure that trigIDassoID , trigassoUNID, trigIDassoUNID & trigUNIDassoID case FillCorrelation called only once in the event loop for same event correlation function calculation, otherwise there will be multiple counting of pion, kaon,proton,unidentified +if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kTRUE){ + if(fillup=="trigIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); + } + if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kFALSE){ + if(fillup=="trigIDassoUNID" ) fTHnTrigcount->Fill(trigval,1.0/trackefftrig); + } +if(ffilltrigIDassoUNID==kFALSE && ffilltrigIDassoID==kTRUE){ + if(fillup=="trigIDassoID") fTHnTrigcount->Fill(trigval,1.0/trackefftrig); + } + + if(fillup=="trigIDassoIDMCTRUTH") fTHnTrigcountMCTruthPrim->Fill(trigval,1.0/trackefftrig); //In truth MC case "Unidentified" means any particle other than pion,kaon or proton and no efficiency correction(default value 1.0)************************be careful!!!! + } + + //asso loop starts within trigger loop + for(Int_t j=0;jUncheckedAt(j)); + else + asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j)); + + if(!asso) continue; + + //to avoid overflow qnd underflow + if(asso->Pt()Pt()>fmaxPtAsso) continue;//***********************Important + + if(fmaxPtAsso==fminPtTrig) {if(asso->Pt()==fminPtTrig) continue;}//******************Think about it! + + if(!tracksasso && i==j) continue; + + // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event) + // if (tracksasso && trig->IsEqual(asso)) continue; + + if (tracksasso && (trig->GetUniqueID()==asso->GetUniqueID())) continue; + + if (fPtOrder) + if (asso->Pt() >= trig->Pt()) continue; + + Int_t particlepidasso=asso->getparticle(); + if(fAssociatedSpeciesSelection){ if (particlepidasso!=fAssociatedSpecies) continue;} + + +if (fAssociatedSelectCharge != 0) +if (asso->Charge() * fAssociatedSelectCharge < 0) continue; + + if (fSelectCharge > 0) + { + // skip like sign + if (fSelectCharge == 1 && asso->Charge() * trig->Charge() > 0) + continue; + + // skip unlike sign + if (fSelectCharge == 2 && asso->Charge() * trig->Charge() < 0) + continue; + } + +if (fEtaOrdering) + { + if (trigeta < 0 && asso->Eta() < trigeta) + continue; + if (trigeta > 0 && asso->Eta() > trigeta) + continue; + } + +if (fRejectResonanceDaughters > 0) + if (asso->TestBit(kResonanceDaughterFlag)) + { +// Printf("Skipped j=%d", j); + continue; + } + + // conversions + if (fCutConversions && asso->Charge() * trig->Charge() < 0) + { + Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.510e-3, 0.510e-3); + + if (mass < 0.1) + { + mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.510e-3, 0.510e-3); + + //fControlConvResoncances->Fill(0.0, mass); + + if (mass < 0.04*0.04) + continue; + } + } + + // K0s + if (fCutResonances && asso->Charge() * trig->Charge() < 0) + { + Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.1396); + + const Float_t kK0smass = 0.4976; + + if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1) + { + mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.1396); + + //fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass); + + if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02)) + continue; + } + } + + // Lambda + if (fCutResonances && asso->Charge() * trig->Charge() < 0) + { + Float_t mass1 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.9383); + Float_t mass2 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396); + + const Float_t kLambdaMass = 1.115; + + if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1) + { + mass1 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.9383); + + //fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass); + + if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02)) + continue; + } + if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1) + { + mass2 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396); + + //fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass); + + if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02)) + continue; + } + } + + if (twoTrackEfficiencyCut) + { + // the variables & cuthave been developed by the HBT group + // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700 + Float_t phi1 = trig->Phi(); + Float_t pt1 = trig->Pt(); + Float_t charge1 = trig->Charge(); + Float_t phi2 = asso->Phi(); + Float_t pt2 = asso->Pt(); + Float_t charge2 = asso->Charge(); + + Float_t deta= trigeta - eta[j]; + + // optimization + if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3) + { + + // check first boundaries to see if is worth to loop and find the minimum + Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign); + Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign); + + const Float_t kLimit = twoTrackEfficiencyCutValue * 3; + + Float_t dphistarminabs = 1e5; + Float_t dphistarmin = 1e5; + + if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0) + { + for (Double_t rad=0.8; rad<2.51; rad+=0.01) + { + Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign); + + Float_t dphistarabs = TMath::Abs(dphistar); + + if (dphistarabs < dphistarminabs) + { + dphistarmin = dphistar; + dphistarminabs = dphistarabs; + } + } + +if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue) + { +// Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign); + continue; + } +//fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2)); + + } + } + } + + Float_t trackeffasso=1.0; + if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval(); + //cout<<"*******************trackeffasso="<Phi()); + + //here get the two particle efficiency correction factor + Float_t effweight=trackefftrig*trackeffasso; + //cout<<"*******************effweight="<Pt(); + vars[4]=deleta; + vars[5]=delphi; +if(fcontainPIDtrig && !fcontainPIDasso) vars[6]=particlepidtrig; +if(!fcontainPIDtrig && fcontainPIDasso) vars[6]=particlepidasso; + if(fcontainPIDtrig && fcontainPIDasso){ + vars[6]=particlepidtrig; + vars[7]=particlepidasso; + } + + //Fill Correlation ThnSparses + if(fillup=="trigassoUNID") + { + if(mixcase==kFALSE) fTHnCorrUNID->Fill(vars,1.0/effweight); + if(mixcase==kTRUE) fTHnCorrUNIDmix->Fill(vars,1.0/effweight); + } + if(fillup=="trigIDassoID") + { + if(mixcase==kFALSE) fTHnCorrID->Fill(vars,1.0/effweight); + if(mixcase==kTRUE) fTHnCorrIDmix->Fill(vars,1.0/effweight); + } + if(fillup=="trigIDassoIDMCTRUTH")//******************************************for TRUTH MC particles + {//in this case effweight should be 1 always + if(mixcase==kFALSE) fCorrelatonTruthPrimary->Fill(vars,1.0/effweight); + if(mixcase==kTRUE) fCorrelatonTruthPrimarymix->Fill(vars,1.0/effweight); + } + if(fillup=="trigIDassoUNID" || fillup=="trigUNIDassoID")//****************************be careful + { + if(mixcase==kFALSE) fTHnCorrIDUNID->Fill(vars,1.0/effweight); + if(mixcase==kTRUE) fTHnCorrIDUNIDmix->Fill(vars,1.0/effweight); + } + +delete[] vars; + }//asso loop ends +delete[] trigval; + }//trigger loop ends + +} + +//-------------------------------------------------------------------------------- +Float_t AliTwoParticlePIDCorr::GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid) +{ + //This function is called only when applyefficiency=kTRUE; also ensure that "track" is present before calling that function + Int_t effVars[4]; + Float_t effvalue=1.; + + if(parpid==unidentified) + { + effVars[0] = effcorection[5]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[5]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[5]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[5]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[5]->GetBinContent(effVars); + } +if(parpid==SpPion || parpid==SpKaon) + { + if(fmesoneffrequired && !fkaonprotoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff) + { + effVars[0] = effcorection[3]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[3]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[3]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[3]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[3]->GetBinContent(effVars); + } + else{ + if(parpid==SpPion) + { + effVars[0] = effcorection[0]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[0]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[0]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[0]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[0]->GetBinContent(effVars); + } + + if(parpid==SpKaon) + { + effVars[0] = effcorection[1]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[1]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[1]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[1]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[1]->GetBinContent(effVars); + } + } + } + + if(parpid==SpProton) + { + effVars[0] = effcorection[2]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[2]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[2]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[2]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[2]->GetBinContent(effVars); + } + + if(fkaonprotoneffrequired && !fmesoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff) + { + if(parpid==SpProton || parpid==SpKaon) + { + effVars[0] = effcorection[4]->GetAxis(0)->FindBin(cent); + effVars[1] = effcorection[4]->GetAxis(1)->FindBin(evzvtx); + effVars[2] = effcorection[4]->GetAxis(2)->FindBin(track->Pt()); + effVars[3] = effcorection[4]->GetAxis(3)->FindBin(track->Eta()); + effvalue=effcorection[4]->GetBinContent(effVars); + } + } + // Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars)); + if(effvalue==0.) effvalue=1.; + + return effvalue; + +} +//----------------------------------------------------------------------- + +Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vertex,Float_t magfield) +{ + + if(!track) return 0; + Bool_t trackOK = track->TestFilterBit(fFilterBit); + if(!trackOK) return 0; + //select only primary traks(for data & reco MC tracks) + if(fonlyprimarydatareco && track->GetType()!=AliAODTrack::kPrimary) return 0; + if(track->Charge()==0) return 0; + fHistQA[12]->Fill(track->GetTPCNcls()); + Float_t dxy, dz; + dxy = track->DCA(); + dz = track->ZAtDCA(); + fHistQA[6]->Fill(dxy); + fHistQA[7]->Fill(dz); + Float_t chi2ndf = track->Chi2perNDF(); + fHistQA[13]->Fill(chi2ndf); + Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1); + fHistQA[14]->Fill(nCrossedRowsTPC); + //Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0; + if (track->GetTPCNclsF()>0) { + Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF(); + fHistQA[15]->Fill(ratioCrossedRowsOverFindableClustersTPC); + } +//accepted tracks + Float_t pt=track->Pt(); + if(pt< fminPt || pt> fmaxPt) return 0; + if(TMath::Abs(track->Eta())> fmaxeta) return 0; + if(track->Phi()<0. || track->Phi()>2*TMath::Pi()) return 0; + //if (!HasTPCPID(track)) return 0;//trigger & associated particles must have TPC PID,Is it required +// DCA XY + if (fdcacut && fDCAXYCut) + { + if (!vertex) + return 0; + + Double_t pos[2]; + Double_t covar[3]; + AliAODTrack* clone =(AliAODTrack*) track->Clone(); + Bool_t success = clone->PropagateToDCA(vertex, magfield, fdcacutvalue, pos, covar); + delete clone; + if (!success) + return 0; + +// Printf("%f", ((AliAODTrack*)part)->DCA()); +// Printf("%f", pos[0]); + if (TMath::Abs(pos[0]) > fDCAXYCut->Eval(track->Pt())) + return 0; + } + + fHistQA[8]->Fill(pt); + fHistQA[9]->Fill(track->Eta()); + fHistQA[10]->Fill(track->Phi()); + return 1; + } + //________________________________________________________________________________ +void AliTwoParticlePIDCorr::CalculateNSigmas(AliAODTrack *track) +{ +//This function is called within the func GetParticle() for accepted tracks only i.e.after call of Classifytrack() & for those tracks which have proper TPC PID response . combined nsigma(circular) cut only for particles having pt upto 4.0 Gev/c and beyond that use the asymmetric nsigma cut around pion's mean position in TPC ( while filling the TObjArray for trig & asso ) +Float_t pt=track->Pt(); + +//it is assumed that every track that passed the filterbit have proper TPC response(!!) +Float_t nsigmaTPCkPion =fPID->NumberOfSigmasTPC(track, AliPID::kPion); +Float_t nsigmaTPCkKaon =fPID->NumberOfSigmasTPC(track, AliPID::kKaon); +Float_t nsigmaTPCkProton =fPID->NumberOfSigmasTPC(track, AliPID::kProton); + +Float_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.; +Float_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.; + + if(HasTOFPID(track) && pt>fPtTOFPIDmin) + { + +nsigmaTOFkPion =fPID->NumberOfSigmasTOF(track, AliPID::kPion); +nsigmaTOFkKaon =fPID->NumberOfSigmasTOF(track, AliPID::kKaon); +nsigmaTOFkProton =fPID->NumberOfSigmasTOF(track, AliPID::kProton); +//---combined +nsigmaTPCTOFkPion = TMath::Sqrt(nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion); +nsigmaTPCTOFkKaon = TMath::Sqrt(nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon); +nsigmaTPCTOFkProton = TMath::Sqrt(nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton); + + + } +else{ + // --- combined + // if TOF is missing and below fPtTOFPID only the TPC information is used + nsigmaTPCTOFkProton = TMath::Abs(nsigmaTPCkProton); + nsigmaTPCTOFkKaon = TMath::Abs(nsigmaTPCkKaon); + nsigmaTPCTOFkPion = TMath::Abs(nsigmaTPCkPion); + + } + +//set data member fnsigmas + fnsigmas[SpPion][NSigmaTPC]=nsigmaTPCkPion; + fnsigmas[SpKaon][NSigmaTPC]=nsigmaTPCkKaon; + fnsigmas[SpProton][NSigmaTPC]=nsigmaTPCkProton; + + //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TOF nsigma values will be 999. + fnsigmas[SpPion][NSigmaTOF]=nsigmaTOFkPion; + fnsigmas[SpKaon][NSigmaTOF]=nsigmaTOFkKaon; + fnsigmas[SpProton][NSigmaTOF]=nsigmaTOFkProton; + + //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TPCTOF nsigma values will be TMath::Abs(TPC only nsigma) + fnsigmas[SpPion][NSigmaTPCTOF]=nsigmaTPCTOFkPion; + fnsigmas[SpKaon][NSigmaTPCTOF]=nsigmaTPCTOFkKaon; + fnsigmas[SpProton][NSigmaTPCTOF]=nsigmaTPCTOFkProton; + + +} +//---------------------------------------------------------------------------- +Int_t AliTwoParticlePIDCorr::FindMinNSigma(AliAODTrack *track) +{ + //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track) +if(fRequestTOFPID && track->Pt()>fPtTOFPIDmin && track->Pt()<=fPtTOFPIDmax && (!HasTOFPID(track)) )return SpUndefined;//so any track having Pt>0.6 && Pt<=4.0 Gev withot having proper TOF response will be defined as SpUndefined +//get the identity of the particle with the minimum Nsigma + Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.; + switch (fPIDType){ + case NSigmaTPC: + nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]); + nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ; + nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ; + break; + case NSigmaTOF: + nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]); + nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ; + nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ; + break; + case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one + nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]); + nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ; + nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ; + break; + } + + if(track->Pt()<=fPtTOFPIDmax) { + // guess the particle based on the smaller nsigma (within fNSigmaPID) + if( ( nsigmaKaon==nsigmaPion ) && ( nsigmaKaon==nsigmaProton )) return SpUndefined;//it is the default value for the three +if( ( nsigmaKaon < nsigmaPion ) && ( nsigmaKaon < nsigmaProton ) && (nsigmaKaon < fNSigmaPID)) return SpKaon; +if( ( nsigmaPion < nsigmaKaon ) && ( nsigmaPion < nsigmaProton ) && (nsigmaPion < fNSigmaPID)) return SpPion; +if( ( nsigmaProton < nsigmaKaon ) && ( nsigmaProton < nsigmaPion ) && (nsigmaProton < fNSigmaPID)) return SpProton; + +// else, return undefined + return SpUndefined; + } + else {//asymmetric nsigma cut around pion's mean position for tracks having Pt>4.0 Gev + if(fminprotonsigmacutPt()<=4.0){ + if(nsigmaPionCheckPIDStatus(AliPIDResponse::kTPC,track); + if(statustpc!=AliPIDResponse::kDetPidOk) return kFALSE; + //ULong_t status=track->GetStatus(); + //if (!( (status & AliAODTrack::kTPCpid ) == AliAODTrack::kTPCpid )) return kFALSE;//remove light nuclei + //if (track->GetTPCsignal() <= 0.) return kFALSE; + // if(track->GetTPCsignalN() < 60) return kFALSE;//tracks with TPCsignalN< 60 have questionable dEdx,cutting on TPCsignalN > 70 or > 60 shouldn't make too much difference in statistics,also it is IMO safe to use TPC also for MIPs. + + return kTRUE; +} +//___________________________________________________________ + +Bool_t +AliTwoParticlePIDCorr::HasTOFPID(AliAODTrack *track) const +{ + // check TOF matched track + //ULong_t status=track->GetStatus(); + //if (!( (status & AliAODTrack::kITSin ) == AliAODTrack::kITSin )) return kFALSE; + AliPIDResponse::EDetPidStatus statustof = fPID->CheckPIDStatus(AliPIDResponse::kTOF,track); + if(statustof!= AliPIDResponse::kDetPidOk) return kFALSE; + if(track->Pt()<=fPtTOFPIDmin) return kFALSE; + //if(!((status & AliAODTrack::kTOFpid ) == AliAODTrack::kTOFpid )) return kFALSE; + //Float_t probMis = fPIDresponse->GetTOFMismatchProbability(track); + // if (probMis > 0.01) return kFALSE; +if(fRemoveTracksT0Fill) + { +Int_t startTimeMask = fPID->GetTOFResponse().GetStartTimeMask(track->P()); + if (startTimeMask < 0)return kFALSE; + } + return kTRUE; +} + +//________________________________________________________________________ +Float_t AliTwoParticlePIDCorr :: GetBeta(AliAODTrack *track) +{ + //it is called only when TOF PID is available + Double_t p = track->P(); + Double_t time=track->GetTOFsignal()-fPID->GetTOFResponse().GetStartTime(p); + Double_t timei[5]; + track->GetIntegratedTimes(timei); + return timei[0]/time; +} +//------------------------------------------------------------------------------------------------------ + +Float_t AliTwoParticlePIDCorr::GetInvMassSquared(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2) +{ + // calculate inv mass squared + // same can be achieved, but with more computing time with + /*TLorentzVector photon, p1, p2; + p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3); + p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3); + photon = p1+p2; + photon.M()*/ + + Float_t tantheta1 = 1e10; + + if (eta1 < -1e-10 || eta1 > 1e-10) + tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1)); + + Float_t tantheta2 = 1e10; + if (eta2 < -1e-10 || eta2 > 1e-10) + tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2)); + + Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1); + Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2); + + Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( TMath::Cos(phi1 - phi2) + 1.0 / tantheta1 / tantheta2 ) ) ); + + return mass2; +} +//--------------------------------------------------------------------------------- + +Float_t AliTwoParticlePIDCorr::GetInvMassSquaredCheap(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2) +{ + // calculate inv mass squared approximately + + Float_t tantheta1 = 1e10; + + if (eta1 < -1e-10 || eta1 > 1e-10) + { + Float_t expTmp = 1.0-eta1+eta1*eta1/2-eta1*eta1*eta1/6+eta1*eta1*eta1*eta1/24; + tantheta1 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp); + } + + Float_t tantheta2 = 1e10; + if (eta2 < -1e-10 || eta2 > 1e-10) + { + Float_t expTmp = 1.0-eta2+eta2*eta2/2-eta2*eta2*eta2/6+eta2*eta2*eta2*eta2/24; + tantheta2 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp); + } + + Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1); + Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2); + + // fold onto 0...pi + Float_t deltaPhi = TMath::Abs(phi1 - phi2); + while (deltaPhi > TMath::TwoPi()) + deltaPhi -= TMath::TwoPi(); + if (deltaPhi > TMath::Pi()) + deltaPhi = TMath::TwoPi() - deltaPhi; + + Float_t cosDeltaPhi = 0; + if (deltaPhi < TMath::Pi()/3) + cosDeltaPhi = 1.0 - deltaPhi*deltaPhi/2 + deltaPhi*deltaPhi*deltaPhi*deltaPhi/24; + else if (deltaPhi < 2*TMath::Pi()/3) + cosDeltaPhi = -(deltaPhi - TMath::Pi()/2) + 1.0/6 * TMath::Power((deltaPhi - TMath::Pi()/2), 3); + else + cosDeltaPhi = -1.0 + 1.0/2.0*(deltaPhi - TMath::Pi())*(deltaPhi - TMath::Pi()) - 1.0/24.0 * TMath::Power(deltaPhi - TMath::Pi(), 4); + + Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( cosDeltaPhi + 1.0 / tantheta1 / tantheta2 ) ) ); + +// Printf(Form("%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2)); + + return mass2; +} +//-------------------------------------------------------------------------------- +Float_t AliTwoParticlePIDCorr::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign) +{ + // + // calculates dphistar + // + + Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2); + + static const Double_t kPi = TMath::Pi(); + + // circularity +// if (dphistar > 2 * kPi) +// dphistar -= 2 * kPi; +// if (dphistar < -2 * kPi) +// dphistar += 2 * kPi; + + if (dphistar > kPi) + dphistar = kPi * 2 - dphistar; + if (dphistar < -kPi) + dphistar = -kPi * 2 - dphistar; + if (dphistar > kPi) // might look funny but is needed + dphistar = kPi * 2 - dphistar; + + return dphistar; +} +//_________________________________________________________________________ +void AliTwoParticlePIDCorr ::DefineEventPool() +{ +const Int_t MaxNofEvents=1000; +const Int_t MaxNofTracks=50000; +const Int_t NofVrtxBins=10+(1+10)*2; +Double_t ZvrtxBins[NofVrtxBins+1]={ -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, + 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, + 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210 + }; + if (fSampleType=="pp"){ +const Int_t NofCentBins=5; +Double_t CentralityBins[NofCentBins+1]={0.,10., 20., 40.,80.,200.1}; +fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins); + } +if (fSampleType=="pPb" || fSampleType=="PbPb") + { +const Int_t NofCentBins=15; +Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 }; +fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins); + } +fPoolMgr->SetTargetValues(MaxNofTracks, 0.1, 5); + +//if(!fPoolMgr) return kFALSE; +//return kTRUE; + +} +//------------------------------------------------------------------------ +Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins) +{ + // This method is a copy from AliUEHist::GetBinning + // takes the binning from identified by + // configuration syntax example: + // eta: 2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4 + // phi: ..... + // + // returns bin edges which have to be deleted by the caller + + TString config(configuration); + TObjArray* lines = config.Tokenize("\n"); + for (Int_t i=0; iGetEntriesFast(); i++) + { + TString line(lines->At(i)->GetName()); + if (line.BeginsWith(TString(tag) + ":")) + { + line.Remove(0, strlen(tag) + 1); + line.ReplaceAll(" ", ""); + TObjArray* binning = line.Tokenize(","); + Double_t* bins = new Double_t[binning->GetEntriesFast()]; + for (Int_t j=0; jGetEntriesFast(); j++) + bins[j] = TString(binning->At(j)->GetName()).Atof(); + + nBins = binning->GetEntriesFast() - 1; + + delete binning; + delete lines; + return bins; + } + } + + delete lines; + AliFatal(Form("Tag %s not found in %s", tag, configuration)); + return 0; +} +//_______________________________________________________________________________ +void AliTwoParticlePIDCorr::SetAsymmetricBin(THnSparse *h,Int_t dim,Double_t *arraybin,Int_t arraybinsize,TString axisTitle) +{ + TAxis *axis = 0x0; + axis = h->GetAxis(dim); + axis->Set(arraybinsize,arraybin); + axis->SetTitle(axisTitle); +} + +//________________________________________________________________________ +void AliTwoParticlePIDCorr::Terminate(Option_t *) +{ + // Draw result to screen, or perform fitting, normalizations + // Called once at the end of the query + fOutput = dynamic_cast (GetOutputData(1)); + if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; } + + +} +//------------------------------------------------------------------ + diff --git a/PWGCF/Correlations/macros/dphicorrelations/AddTaskContMC.C b/PWGCF/Correlations/macros/dphicorrelations/AddTaskContMC.C index c768a567550..81beb38ef04 100644 --- a/PWGCF/Correlations/macros/dphicorrelations/AddTaskContMC.C +++ b/PWGCF/Correlations/macros/dphicorrelations/AddTaskContMC.C @@ -1,42 +1,42 @@ -using namespace AliHelperPIDNameSpace; - -AliAnalysisTaskContMC* AddTaskContMC(Bool_t mc=kFALSE){ - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) - { - ::Error("AddAliAnalysisTaskContMC", "No analysis manager to connect to."); - return NULL; - } - - // Check the analysis type using the event handlers connected to the analysis manager. - //============================================================================== - if (!mgr->GetInputEventHandler()) - { - ::Error("AddTaskITSsaTracks", "This task requires an input event handler"); - return NULL; - } - - TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" - if(type.Contains("ESD")) - { - ::Error("AddTaskITSsaTracks", "This task requires to run on AOD"); - return NULL; - } - - - AliAnalysisTaskContMC *task = new AliAnalysisTaskContMC("ContMC"); - task->SetIsMC(mc); - mgr->AddTask(task); - - TString outputFileName = AliAnalysisManager::GetCommonFileName(); - cout<<"-------------- outputFileName: "<GetCommonInputContainer(); - AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer("fOutput", TList::Class(), AliAnalysisManager::kOutputContainer,outputFileName); - - //connect containers - mgr->ConnectInput(task, 0, cinput); - mgr->ConnectOutput(task, 1, coutputpt2); - return task; -} +using namespace AliHelperPIDNameSpace; + +AliAnalysisTaskContMC* AddTaskContMC(Bool_t mc=kFALSE){ + + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) + { + ::Error("AddAliAnalysisTaskContMC", "No analysis manager to connect to."); + return NULL; + } + + // Check the analysis type using the event handlers connected to the analysis manager. + //============================================================================== + if (!mgr->GetInputEventHandler()) + { + ::Error("AddTaskITSsaTracks", "This task requires an input event handler"); + return NULL; + } + + TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" + if(type.Contains("ESD")) + { + ::Error("AddTaskITSsaTracks", "This task requires to run on AOD"); + return NULL; + } + + + AliAnalysisTaskContMC *task = new AliAnalysisTaskContMC("ContMC"); + task->SetIsMC(mc); + mgr->AddTask(task); + + TString outputFileName = AliAnalysisManager::GetCommonFileName(); + cout<<"-------------- outputFileName: "<GetCommonInputContainer(); + AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer("fOutput", TList::Class(), AliAnalysisManager::kOutputContainer,outputFileName); + + //connect containers + mgr->ConnectInput(task, 0, cinput); + mgr->ConnectOutput(task, 1, coutputpt2); + return task; +} diff --git a/PWGCF/Correlations/macros/fd/AddTaskPicoTracksDhc.C b/PWGCF/Correlations/macros/fd/AddTaskPicoTracksDhc.C index 1695de4987d..7bf63dd2014 100644 --- a/PWGCF/Correlations/macros/fd/AddTaskPicoTracksDhc.C +++ b/PWGCF/Correlations/macros/fd/AddTaskPicoTracksDhc.C @@ -1,36 +1,36 @@ -// $Id$ - -void AddTaskPicoTracksDhc( - TString chNOutTracks = "PicoTracks", - TString period = "LHC11h" -) -{ - // Get the analysis manager - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - Error("AddTaskPicoTracksDhc", "No analysis manager found."); - return; - } - gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C"); - - // ESD or AOD? Create track cuts with pico track maker - AliEmcalPicoTrackMaker *pTrackTask = 0x0; - TString chIsESD("ESD"); - - if (chIsESD.EqualTo(mgr->GetInputEventHandler()->GetDataType())) { - TString cuts("Hybrid_"); - cuts += period; - Info("AddTaskPicoTracksDhc","adding ESD track selection task ..."); - // ESD Track Cuts - gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalEsdTpcTrack.C"); - AliEmcalEsdTpcTrackTask *hybTask = AddTaskEmcalEsdTpcTrack("HybridTracks", cuts.Data()); - hybTask->SelectCollisionCandidates(AliVEvent::kAny); - // Pico Tracks - pTrackTask = AddTaskEmcalPicoTrackMaker(chNOutTracks.Data(), "HybridTracks", period); - pTrackTask->SelectCollisionCandidates(AliVEvent::kAny); - } else { - Info("AddTaskPicoTracksDhc","AOD analysis, adding PicoTrack maker ..."); - pTrackTask = AddTaskEmcalPicoTrackMaker(chNOutTracks.Data(),"tracks", period); - pTrackTask->SelectCollisionCandidates(AliVEvent::kAny); - } -} +// $Id$ + +void AddTaskPicoTracksDhc( + TString chNOutTracks = "PicoTracks", + TString period = "LHC11h" +) +{ + // Get the analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + Error("AddTaskPicoTracksDhc", "No analysis manager found."); + return; + } + gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C"); + + // ESD or AOD? Create track cuts with pico track maker + AliEmcalPicoTrackMaker *pTrackTask = 0x0; + TString chIsESD("ESD"); + + if (chIsESD.EqualTo(mgr->GetInputEventHandler()->GetDataType())) { + TString cuts("Hybrid_"); + cuts += period; + Info("AddTaskPicoTracksDhc","adding ESD track selection task ..."); + // ESD Track Cuts + gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalEsdTpcTrack.C"); + AliEmcalEsdTpcTrackTask *hybTask = AddTaskEmcalEsdTpcTrack("HybridTracks", cuts.Data()); + hybTask->SelectCollisionCandidates(AliVEvent::kAny); + // Pico Tracks + pTrackTask = AddTaskEmcalPicoTrackMaker(chNOutTracks.Data(), "HybridTracks", period); + pTrackTask->SelectCollisionCandidates(AliVEvent::kAny); + } else { + Info("AddTaskPicoTracksDhc","AOD analysis, adding PicoTrack maker ..."); + pTrackTask = AddTaskEmcalPicoTrackMaker(chNOutTracks.Data(),"tracks", period); + pTrackTask->SelectCollisionCandidates(AliVEvent::kAny); + } +} diff --git a/PWGCF/Correlations/macros/minijet/analyse_pA.C b/PWGCF/Correlations/macros/minijet/analyse_pA.C index 5b1e6b649ff..e255257a170 100644 --- a/PWGCF/Correlations/macros/minijet/analyse_pA.C +++ b/PWGCF/Correlations/macros/minijet/analyse_pA.C @@ -1,731 +1,731 @@ -/* $Id: $ */ -//-------------------------------------------------- -// -// macro to do the final analysis step -// uses input of analysis class AliAnalysisTaskPhiCorrelation -// -// Author : Emilia Leogrande (University of Utrecht) -// -//------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TRandom.h" -#include "TGraphErrors.h" -#include "TFile.h" -#include "TF1.h" -#include "TMath.h" -#include "TDirectory.h" -#include "TStyle.h" -#include "TROOT.h" -#include "TColor.h" - -#include -using namespace std; - -void analyseEmy2(Bool_t zyam = kTRUE); // if zyam = kFALSE, fit is used -Double_t fitFunction(Double_t *x ,Double_t *par); // fit function using constant + 3 gaussians -Double_t fitFunction2Gaus(Double_t *x ,Double_t *par); // fit function using constant + 2 gaussians - -//input file and mixed event removed file -TFile *fileData=0x0; -TFile *fileDataEMremoved = 0x0; - -const int multclass = 20; - -TH1D *fDeltaPhiNch[multclass]; -TH1D *fDeltaEtaNch[multclass]; -TH1D *fSignalDPhi[multclass]; -TH1D *fSignalNSDPhi[multclass]; -TH1D *fSignalASDPhi[multclass]; -TH1D *fRidge1DPhi[multclass]; -TH1D *fRidge2DPhi[multclass]; -TH1D *fRidgeDPhi[multclass]; -TH1D *fSymmRidgeNotScaled[multclass]; -TH1D *fSymmRidge[multclass]; -TH1D *fFinal1DPhi[multclass]; -TH1D *fFinalDPhi[multclass]; - -TString flag = "R"; -TF1 *fTotal2Gaus[multclass]; // fit with 2 gaussians + const -TF1 *fTotal[multclass]; // fit with 3 gaussians + const - -//properties of histogram -const int bins = 72; // -Double_t binWidth=2*TMath::Pi()/bins; - -const int binsDeta = 48; - - -Double_t max_bin_for_etagap = 1.2; -Double_t min_bin_for_etagap = -1.2; -Double_t max_eta = 1.8; -Double_t min_eta = -1.8; - -//________________________________________________________________________________________________________________ -// -Double_t fitFunction(Double_t *x ,Double_t *par) -{ - // fit function for 3 gaus + constant - - // parameters for Gaussian - Double_t A1 = par[0]; - Double_t sigma1 = par[1]; - Double_t A2 = par[2]; - Double_t sigma2 = par[3]; - Double_t A3 = par[4]; - Double_t sigma3 = par[5]; - Double_t integral = par[6]; - - Double_t constante = (integral- - TMath::Sqrt(TMath::Pi()*2)/ binWidth* - (A1 * sigma1 + A2 * sigma2 + A3*sigma3))/bins; - Double_t q = x[0]; - - //fit value - Double_t fitval = constante + - (q>-0.5*TMath::Pi()&&q<0.5*TMath::Pi())*( - A1 * exp(- q * q / (2 * sigma1 *sigma1)) + - A1 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma1 * sigma1)) - ) - + - (q>-0.2*TMath::Pi()&&q<0.2*TMath::Pi())*( - A2 * exp(- q * q / (2 * sigma2 *sigma2)) + - A2 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma2 * sigma2)) - ) - + - (q>0.5*TMath::Pi()&&q<1.5*TMath::Pi())*( - A3 * exp(-((q - TMath::Pi())) * ((q - TMath::Pi())) / ( 2 * sigma3 * sigma3)) + - A3 * exp(-((q + TMath::Pi())) * ((q + TMath::Pi())) / (2 * sigma3 * sigma3)) - ); - return fitval; -} - -//________________________________________________________________________________________________________________ -// -Double_t fitFunction2Gaus(Double_t *x ,Double_t *par) -{ - // fit function for 2 gaus + constant - - // parameters for Gaussian - Double_t A1 = par[0]; - Double_t sigma1 = par[1]; - Double_t A3 = par[2]; - Double_t sigma3 = par[3]; - Double_t integral = par[4]; - - Double_t constante = (integral - - TMath::Sqrt(TMath::Pi()*2)/ binWidth* - (A1 * sigma1 + A3*sigma3))/bins; - Double_t q = x[0]; - - //fit value - Double_t fitval = constante + - (q>-0.5*TMath::Pi()&&q<0.5*TMath::Pi())*( - A1 * exp(- q * q / (2 * sigma1 *sigma1)) + - A1 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma1 * sigma1)) - ) - + - (q>0.5*TMath::Pi()&&q<1.5*TMath::Pi())*( - A3 * exp(-((q - TMath::Pi())) * ((q - TMath::Pi())) / ( 2 * sigma3 * sigma3)) + - A3 * exp(-((q + TMath::Pi())) * ((q + TMath::Pi())) / (2 * sigma3 * sigma3)) - ); - return fitval; -} - -//_______________________________________________________________________________________________________________ -// -Double_t fline(Double_t *x, Double_t *par){ - - if(x[0]>-1.8 && x[0]<=0){ - return par[0]+par[1]*x[0]; - } - else if(x[0]>0 && x[0]<1.8){ - return par[2]+par[3]*x[0]; - } - else - return 0; -} - - -//________________________________________________________________________________________________________________ -// -void analyseEmy2(Bool_t zyam){ - - - // plot style - gStyle->SetOptStat(0); - const Int_t NRGBs = 5; - const Int_t NCont = 500; - Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; - Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; - Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; - Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; - TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); - gStyle->SetNumberContours(NCont); - - //style - gROOT->SetStyle("Plain"); - gStyle->SetOptStat(0); - gStyle->SetPalette(1); - - //-------------- TRIGGERS AND EVENTS - - TH2D *dphideta[multclass]; - TH1D * trigger = 0x0; - TH1D * event = 0x0; - - fileData = TFile::Open("dphi_corr.root"); - trigger = (TH1D*)fileData->Get("triggers_0"); - event = (TH1D*)fileData->Get("events"); - - // get average trigger particles per event - TProfile *p0 = (TProfile*)trigger->Clone(); - TProfile *p1 = (TProfile*)event->Clone(); - p0->Sumw2(); - p1->Sumw2(); - p0->Divide(p0,p1,1,1,"B"); - - // copy triggers and events in the new dphi_corr with the Mixed Event removed - TH1D *triggerCopy = 0x0; - TH1D *eventCopy = 0x0; - - triggerCopy = (TH1D*)trigger->Clone(); - eventCopy = (TH1D*)event->Clone(); - - fileDataEMremoved = TFile::Open("dphi_corr_MEremoved.root","RECREATE"); - triggerCopy->SetName("triggers_0"); - triggerCopy->Write(); - eventCopy->SetName("events"); - eventCopy->Write(); - fileDataEMremoved->Close(); - - - //-------------- MIXED EVENT REMOVAL: restores the right number of particles in the detector acceptance but keeps the detector azimuthal unefficiencies corrections and cures the dip in (0,0) from two-trak cuts - // Removing the event mixing: S/M (from dphi_corr) * M (from the triangle) - - Double_t triangle_factor[binsDeta]={0}; - - TH2D *s_over_m[multclass]; - TH1D *s_m_deta[multclass]; - TH2D *s_over_m_x_m[multclass]; - - for(Int_t i=0;iGet(Form("dphi_0_0_%d",i)); - s_m_deta[i] = (TH1D*)s_over_m[i]->ProjectionY()->Clone(); - s_over_m_x_m[i] = (TH2D*)s_over_m[i]->Clone(); - s_over_m_x_m[i]->Reset(); - } - - - TF1 *f2 = new TF1("f2",fline,min_eta,max_eta,4); - - f2->FixParameter(0,1); - f2->FixParameter(1,1/max_eta); - f2->FixParameter(2,1); - f2->FixParameter(3,-1/max_eta); - - for(Int_t i=0;iEval(s_m_deta[0]->GetBinCenter(i+1)); - - } - - - - //--scale each deta bin of the old TH2 with the triangle_factor[deta] - - for(Int_t i=0;i SetBinContent(k+1,j+1,(s_over_m[i]->GetBinContent(k+1,j+1))*triangle_factor[j]); - s_over_m_x_m[i]->SetBinError(k+1,j+1,(s_over_m[i]->GetBinError(k+1,j+1))*triangle_factor[j]); - } - } - } - - fileDataEMremoved = TFile::Open("dphi_corr_MEremoved.root","UPDATE"); - - for(Int_t i=0;iSetName(Form("dphiNoMixed_%d",i)); - s_over_m_x_m[i]->Write(); - - } - - - - //-------------- DOUBLE RIDGE SUBTRACTION: gets rid of no-jet related components (v3 is still kept => effect added to the systematics) - - // the ridge, estimated via an etagap, has to be scaled since it sits on the triangle - Double_t scale_for_ridge_NS = 0, scale_for_ridge_AS = 0; - - - scale_for_ridge_NS = f2->Integral(min_bin_for_etagap,max_bin_for_etagap)/(f2->Integral(min_eta,min_bin_for_etagap)+f2->Integral(max_bin_for_etagap,max_eta)); //there is etagap in the NS - cout<<"scaling NS:"<Integral(min_eta,max_eta)/(f2->Integral(min_eta,min_bin_for_etagap)+f2->Integral(max_bin_for_etagap,max_eta)); // there is no etagap in the AS - cout<<"scaling AS:"<Divide(5,4); - - for(Int_t i=0;icd(i+1); - - - dphideta[i] = (TH2D*)fileDataEMremoved->Get(Form("dphiNoMixed_%d",i)); - - - // phi and eta projections - fDeltaPhiNch[i] = (TH1D*)dphideta[i]->ProjectionX()->Clone(); - if(!zyam) - fDeltaPhiNch[i]->Scale(binWidth); //gaussians include the binwidth, so when using the fit, the histograms must be scaled first - fDeltaPhiNch[i]->Draw(); - - fDeltaEtaNch[i] = (TH1D*)dphideta[i]->ProjectionY()->Clone(); - - // signal NS: |DEta|ProjectionX(Form("|DEta|<%f",max_bin_for_etagap),fDeltaEtaNch[i]->FindBin(min_bin_for_etagap+0.0001),fDeltaEtaNch[i]->FindBin(max_bin_for_etagap-0.0001))->Clone(); - fSignalASDPhi[i] = (TH1D*)dphideta[i]->ProjectionX(Form("|DEta|<%f",max_eta))->Clone(); - - fSignalDPhi[i] = (TH1D*)fSignalASDPhi[i]->Clone(); - fSignalDPhi[i]->Reset(); - fSignalDPhi[i]->Sumw2(); - - for(Int_t k=0;kSetBinContent(k+1,fSignalNSDPhi[i]->GetBinContent(k+1)); - fSignalDPhi[i]->SetBinError(k+1, fSignalNSDPhi[i]->GetBinError(k+1)); - } - for(Int_t k=bins/2;kSetBinContent(k+1,fSignalASDPhi[i]->GetBinContent(k+1)); - fSignalDPhi[i]->SetBinError(k+1, fSignalASDPhi[i]->GetBinError(k+1)); - } - if(!zyam) - fSignalDPhi[i]->Scale(binWidth); - - // ridge1 DEtaProjectionX(Form("DEta<%f",min_bin_for_etagap),1,fDeltaEtaNch[i]->FindBin(min_bin_for_etagap-0.0001))->Clone(); - if(!zyam) - fRidge1DPhi[i]->Scale(binWidth); - fRidge1DPhi[i]->SetMarkerColor(kRed); - - // ridge2 DEta>max_bin_for_etagap - fRidge2DPhi[i] = (TH1D*)dphideta[i]->ProjectionX(Form("DEta>%f",max_bin_for_etagap),fDeltaEtaNch[i]->FindBin(max_bin_for_etagap+0.0001),fDeltaEtaNch[i]->GetNbinsX())->Clone(); - if(!zyam) - fRidge2DPhi[i]->Scale(binWidth); - fRidge2DPhi[i]->SetMarkerColor(kBlue); - - // ridge = ridge1 + ridge2 - fRidgeDPhi[i] = (TH1D*)fRidge1DPhi[i]->Clone("fRidge"); - fRidgeDPhi[i]->Reset(); - fRidgeDPhi[i]->Sumw2(); - fRidgeDPhi[i]->Add(fRidge1DPhi[i],fRidge2DPhi[i],1,1); - //fRidgeDPhi[i]->Scale(scale_for_ridge); - - // symmetrize NS ridge in the AS - fSymmRidgeNotScaled[i] = (TH1D*)fRidgeDPhi[i]->Clone("fSymmRidgeNotScaled"); - - for(Int_t k=fSymmRidgeNotScaled[i]->GetNbinsX()/2+1;k<=fSymmRidgeNotScaled[i]->GetNbinsX();k++){ - - fSymmRidgeNotScaled[i]->SetBinContent(k,fSymmRidgeNotScaled[i]->GetBinContent(fSymmRidgeNotScaled[i]->GetNbinsX()+1-k)); - - } - - // scale the symmetrized ridge according to NS or AS - fSymmRidge[i] = (TH1D*)fSymmRidgeNotScaled[i]->Clone("fSymmRidge"); - - for(Int_t k=0;kSetBinContent(k+1,(fSymmRidgeNotScaled[i]->GetBinContent(k+1))*scale_for_ridge_NS); - } - for(Int_t k=bins/2;kSetBinContent(k+1,(fSymmRidgeNotScaled[i]->GetBinContent(k+1))*scale_for_ridge_AS); - } - - - // signal - symmetric ridge - - if(zyam){ - fFinal1DPhi[i] = new TH1D(Form("fFinal1DPhi[%d]",i),Form("fFinal1DPhi[%d]",i),bins,-0.5*TMath::Pi(),1.5*TMath::Pi()); - fFinal1DPhi[i]->Add(fSignalDPhi[i],fSymmRidge[i],1,-1); - fFinal1DPhi[i]->Sumw2(); - fFinalDPhi[i] = (TH1D*)fFinal1DPhi[i]->Clone("fFinal"); // zyam: average between the two min values => sum first half of NS in the second half and second half of AS in the first half, so zyam = min/2 - fFinalDPhi[i]->Reset(); - fFinalDPhi[i]->Sumw2(); - - for(Int_t k=1;k<=bins/4;k++){ - fFinalDPhi[i]->SetBinContent(k,0.); - fFinalDPhi[i]->SetBinContent(k+bins/4,fFinal1DPhi[i]->GetBinContent(k+bins/4)+fFinal1DPhi[i]->GetBinContent(bins/4+1-k)); - fFinalDPhi[i]->SetBinError(k+bins/4,TMath::Sqrt(pow(fFinal1DPhi[i]->GetBinError(k+bins/4),2)+pow(fFinal1DPhi[i]->GetBinError(bins/4+1-k),2))); - fFinalDPhi[i]->SetBinContent(k+bins/2,fFinal1DPhi[i]->GetBinContent(k+bins/2)+fFinal1DPhi[i]->GetBinContent(bins+1-k)); - fFinalDPhi[i]->SetBinError(k+bins/2,TMath::Sqrt(pow(fFinal1DPhi[i]->GetBinError(k+bins/2),2)+pow(fFinal1DPhi[i]->GetBinError(bins+1-k),2))); - fFinalDPhi[i]->SetBinContent(k+bins/4*3,0.); - - } - } - - else{ - - fFinalDPhi[i] = (TH1D*)fSignalDPhi[i]->Clone(); - fFinalDPhi[i]->Reset(); - fFinalDPhi[i]->Sumw2(); - fFinalDPhi[i]->Add(fSignalDPhi[i],fSymmRidge[i],1,-1); - } - - } - - // store the pair yields in a file (the yields are *not* normalized to the Ntriggers) - - TFile* file_yields = 0x0; - if(zyam) - file_yields = TFile::Open("PairYields_zyam.root","RECREATE"); - else - file_yields = TFile::Open("PairYields_fit.root","RECREATE"); - - - for(Int_t i=0;iSetName(Form("DeltaEta_0_0_%d",i)); - fDeltaEtaNch[i]->Write(); - fDeltaPhiNch[i]->SetName(Form("Correlation bin %d in dphi",i)); - fDeltaPhiNch[i]->Write(); - fSignalDPhi[i]->SetName(Form("Signal_0_0_%d",i)); - fSignalDPhi[i]->Write(); - fRidgeDPhi[i]->SetName(Form("Ridge_0_0_%d",i)); - fRidgeDPhi[i]->Write(); - fSymmRidgeNotScaled[i]->SetName(Form("Symmetric_Ridge_NotScaled_0_0_%d",i)); - fSymmRidgeNotScaled[i]->Write(); - fSymmRidge[i]->SetName(Form("Symmetric_Ridge_0_0_%d",i)); - fSymmRidge[i]->Write(); - fFinalDPhi[i]->SetName(Form("Pure_Signal_0_0_%d",i)); - fFinalDPhi[i]->Write(); - } - file_yields->Close(); - - //-------------- CORRELATION OBSERVABLES: per-trigger yields, triggers and uncorrelated seeds - - Float_t baseline[multclass]={0}; - - TGraphErrors *fNearSideIntegral = new TGraphErrors(); - fNearSideIntegral->SetName("fNearSideIntegral"); - fNearSideIntegral->SetMarkerColor(kGreen+2); - fNearSideIntegral->SetLineColor(kGreen+2); - fNearSideIntegral->SetLineWidth(1); - fNearSideIntegral->SetMarkerStyle(4); - - TGraphErrors *fAwaySideIntegral = new TGraphErrors(); - fAwaySideIntegral->SetName("fAwaySideIntegral"); - fAwaySideIntegral->SetMarkerColor(kBlue); - fAwaySideIntegral->SetLineColor(kBlue); - fAwaySideIntegral->SetLineWidth(1); - fAwaySideIntegral->SetMarkerStyle(4); - - TGraphErrors *fBothSideIntegral = new TGraphErrors(); - fBothSideIntegral->SetName("fBothSideIntegral"); - fBothSideIntegral->SetMarkerColor(kMagenta); - fBothSideIntegral->SetLineColor(kMagenta); - fBothSideIntegral->SetLineWidth(1); - fBothSideIntegral->SetMarkerStyle(4); - - - TGraphErrors *fNjets = new TGraphErrors(); - fNjets->SetName("fNjets"); - fNjets->SetMarkerColor(kCyan+2); - fNjets->SetLineColor(kCyan+2); - fNjets->SetLineWidth(1); - fNjets->SetMarkerStyle(4); - - TGraphErrors *fTriggerAverage = new TGraphErrors(); - fTriggerAverage->SetName("fTriggerAverage"); - fTriggerAverage->SetMarkerColor(kBlack); - fTriggerAverage->SetLineColor(kBlack); - fTriggerAverage->SetLineWidth(1); - fTriggerAverage->SetMarkerStyle(4); - - Int_t points=0; - Double_t minbin[multclass] = {0}; - - // extract information out of dphi histograms - TCanvas * cYields= new TCanvas("cYields", "cYields", 150, 150, 820, 620); - cYields->Divide(5,4); - - for(Int_t i=0;icd(i+1); - - - if(zyam) { - - if(fFinalDPhi[i]->Integral()>0){ - fFinalDPhi[i]->GetXaxis()->SetRange(bins/4+1,bins/4*3); - baseline[i]=fFinalDPhi[i]->GetMinimum()/2; - minbin[i] = fFinalDPhi[i]->GetMinimumBin(); - fFinalDPhi[i]->GetXaxis()->UnZoom(); - - for(Int_t k=0;kGetBinContent(k+1)!=0) - fFinalDPhi[i]->SetBinContent(k+1,fFinalDPhi[i]->GetBinContent(k+1)-baseline[i]); - else - fFinalDPhi[i]->SetBinContent(k+1,0.); - } - - fFinalDPhi[i]->DrawClone(""); - - fFinalDPhi[i]->SetTitle(Form("0.7SetTitle("1/N_{trig} dN_{assoc}/d#Delta#varphi (rad^{-1})"); - //- - Double_t errorNS = 0; - Double_t nearSideResult = (fFinalDPhi[i]->IntegralAndError(0,minbin[i],errorNS,"width"))/trigger->GetBinContent(i+1); - Double_t nearSideError = errorNS/trigger->GetBinContent(i+1); - fNearSideIntegral->SetPoint(points,i, nearSideResult); - fNearSideIntegral->SetPointError(points,0.5,errorNS/trigger->GetBinContent(i+1)); - //- - - //-- - Double_t errorAS = 0; - Double_t awaySideResult = (fFinalDPhi[i]->IntegralAndError(minbin[i],bins,errorAS,"width"))/trigger->GetBinContent(i+1); - Double_t awaySideError = errorAS/trigger->GetBinContent(i+1); - fAwaySideIntegral->SetPoint(points,i, awaySideResult ); - fAwaySideIntegral->SetPointError(points,0.5, errorAS/trigger->GetBinContent(i+1)); - //-- - - //--- - Double_t bothSideResult = nearSideResult + awaySideResult; - Double_t bothSideError = bothSideResult * TMath::Sqrt(pow(errorNS,2)+pow(errorAS,2))/trigger->GetBinContent(i+1); - fBothSideIntegral->SetPoint(points,i, bothSideResult ); - fBothSideIntegral->SetPointError(points,0.5, bothSideError ); - //--- - - - - } - else{ - fNearSideIntegral->SetPoint(points,i, 0); - fAwaySideIntegral->SetPoint(points,i, 0); - fBothSideIntegral->SetPoint(points,i,0); - } - Double_t p0BinContent=p0->GetBinContent(i+1); - Double_t p0BinError=p0->GetBinError(i+1); - - //-------- - Double_t njets = p0BinContent/(1+bothSideResult); - Double_t njetsError = njets*TMath::Sqrt(bothSideError*bothSideError/(1+bothSideResult)/(1+bothSideResult)+p0BinError*p0BinError/p0BinContent/p0BinContent); - fNjets->SetPoint(points,i, njets ); - fNjets->SetPointError(points,0.5,njetsError ); - - //------- - - fTriggerAverage->SetPoint(points,i, p0BinContent); - fTriggerAverage->SetPointError(points,0.5, p0BinError); - - } - - else if (!zyam){ - - if(fFinalDPhi[i]->Integral()>0){ - - //first fit function: 2 gauss + const - fTotal2Gaus[i] = new TF1(Form("gaus3and2_%d",i), fitFunction2Gaus , -0.5*TMath::Pi(), 1.5*TMath::Pi(), 5); - fTotal2Gaus[i]->SetName(Form("gaus3_%d",i)); - fTotal2Gaus[i]->SetParNames ("A1","sigma1","A3", "sigma3"); - fTotal2Gaus[i]->SetLineColor(kRed); - fTotal2Gaus[i]->SetLineWidth(2); - - baseline[i]=fFinalDPhi[i]->GetMinimum(); - Double_t integr_for_const_2 = fFinalDPhi[i]->Integral(); - - fTotal2Gaus[i]->FixParameter(4,integr_for_const_2); - fTotal2Gaus[i]->SetParameters( fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0)) - baseline[i] , 0.6 , fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i] , 0.6); - - fTotal2Gaus[i]->SetParLimits(0, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); - fTotal2Gaus[i]->SetParLimits(1, 0.01, 10); - fTotal2Gaus[i]->SetParLimits(2, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i])*2); - fTotal2Gaus[i]->SetParLimits(3, 0.01, 10); - - fTotal2Gaus[i]->SetLineColor(kRed); - fTotal2Gaus[i]->SetLineWidth(2); - - fFinalDPhi[i]->Fit(fTotal2Gaus[i],flag); - fFinalDPhi[i]->SetMinimum(0); - fFinalDPhi[i]->DrawClone(""); - fTotal2Gaus[i] ->DrawClone("same"); - - Double_t A11 = fTotal2Gaus[i]->GetParameter(0); - Double_t sigma11 = fTotal2Gaus[i]->GetParameter(1); - Double_t A31 = fTotal2Gaus[i]->GetParameter(2); - Double_t sigma31 = fTotal2Gaus[i]->GetParameter(3); - - Double_t a1e1 = fTotal2Gaus[i]->GetParError(0); - Double_t s1e1 = fTotal2Gaus[i]->GetParError(1); - Double_t a3e1 = fTotal2Gaus[i]->GetParError(2); - Double_t s3e1 = fTotal2Gaus[i]->GetParError(3); - - - Double_t T11 = A11*sigma11; - Double_t T31 = A31*sigma31; - Double_t t11 = T11*TMath::Sqrt(a1e1*a1e1/A11/A11 + s1e1*s1e1/sigma11/sigma11); - Double_t t31 = T31*TMath::Sqrt(a3e1*a3e1/A31/A31 + s3e1*s3e1/sigma31/sigma31); - - - //second fit: 3 gauss + const - fTotal[i] = new TF1(Form("gaus3_%d",i), fitFunction , -0.5*TMath::Pi(), 1.5*TMath::Pi(), 7); - fTotal[i]->SetName(Form("gaus3_%d",i)); - fTotal[i]->SetParNames ("A1","sigma1","A2","sigma2", "A3", "sigma3","integral"); - fTotal[i]->SetLineColor(kRed); - fTotal[i]->SetLineWidth(2); - - Double_t integr_for_const = fFinalDPhi[i]->Integral(); - - - fTotal[i]->FixParameter(0,A11); - fTotal[i]->FixParameter(1,sigma11*1.2); - fTotal[i]->FixParameter(2,A11); - fTotal[i]->FixParameter(3,sigma11*0.7); - fTotal[i]->FixParameter(4,A31); - fTotal[i]->FixParameter(5,sigma31); - fTotal[i]->FixParameter(6,integr_for_const); - - fTotal[i]->SetParLimits(0, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); - fTotal[i]->SetParLimits(1, 0.3, 10); - fTotal[i]->SetParLimits(2, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); - fTotal[i]->SetParLimits(3, 0.12, 0.4); - fTotal[i]->SetParLimits(4, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]-> - GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i])*2); - fTotal[i]->SetParLimits(5, 0.01, 10); - - fTotal[i]->SetLineColor(kRed); - fTotal[i]->SetLineWidth(2); - - - fFinalDPhi[i]->Fit(fTotal[i],flag); - fFinalDPhi[i]->SetMinimum(0); - fFinalDPhi[i]->DrawClone(""); - fFinalDPhi[i]->SetTitle(Form("0.7SetTitle("1/N_{trig} dN_{assoc}/d#Delta#varphi (rad^{-1})"); - fTotal[i]->DrawClone("same"); - - Double_t A1 = fTotal[i]->GetParameter(0); - Double_t sigma1 = fTotal[i]->GetParameter(1); - Double_t A2 = fTotal[i]->GetParameter(2); - Double_t sigma2 = fTotal[i]->GetParameter(3); - Double_t A3 = fTotal[i]->GetParameter(4); - Double_t sigma3 = fTotal[i]->GetParameter(5); - - - //define each gaussian and constant to be drawn with different colors on top of each other - - TF1 * fConstant = new TF1("konst", "pol0(0)",-0.5*TMath::Pi(), 1.5*TMath::Pi()); - fConstant->SetParameter(0,(integr_for_const - TMath::Sqrt(TMath::Pi()*2)/binWidth*(A1*sigma1+A2*sigma2+A3*sigma3))/bins); - fConstant->SetLineColor(kBlue); - fConstant->Draw("same"); - - //gaus 1 NS - TF1 * fGaussian1 = new TF1("fGaussian1", "[0]*exp(-x*x/(2*[1]*[1])) +[0] * exp(-(x-TMath::TwoPi())*(x-TMath::TwoPi())/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); - fGaussian1->SetParameters(fTotal[i]->GetParameter(0),fTotal[i]->GetParameter(1)); - fGaussian1->SetLineColor(kMagenta); - fGaussian1->SetLineStyle(1); - fGaussian1->Draw("same"); - - //gaus 2 NS - TF1 * fGaussian2 = new TF1("fGaussian2", "[0]*exp(-x*x/(2*[1]*[1])) +[0] * exp(-(x-TMath::TwoPi())*(x-TMath::TwoPi())/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); - fGaussian2->SetLineColor(kGreen+2); - fGaussian2->SetParameters(fTotal[i]->GetParameter(2),fTotal[i]->GetParameter(3)); - fGaussian2->Draw("same"); - - //gaus 3 AS - TF1 * fGaussian3 = new TF1("fGaussian3", "[0] * exp(-((x-TMath::Pi()))*((x-TMath::Pi()))/(2*[1]*[1]))+[0] * exp(-((x+TMath::Pi()))*((x+TMath::Pi()))/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); - fGaussian3->SetLineColor(kCyan); - fGaussian3->SetParameters(fTotal[i]->GetParameter(4), fTotal[i]->GetParameter(5)); - fGaussian3->Draw("same"); - - - Double_t a1e = fTotal[i]->GetParError(0); - Double_t s1e = fTotal[i]->GetParError(1); - Double_t a2e = fTotal[i]->GetParError(2); - Double_t s2e = fTotal[i]->GetParError(3); - Double_t a3e = fTotal[i]->GetParError(4); - Double_t s3e = fTotal[i]->GetParError(5); - - Double_t T1 = A1*sigma1; - Double_t T2 = A2*sigma2; - Double_t T3 = A3*sigma3; - Double_t t1 = T1*TMath::Sqrt(a1e*a1e/A1/A1 + s1e*s1e/sigma1/sigma1); - Double_t t2 = T2*TMath::Sqrt(a2e*a2e/A2/A2 + s2e*s2e/sigma2/sigma2); - Double_t t3 = T3*TMath::Sqrt(a3e*a3e/A3/A3 + s3e*s3e/sigma3/sigma3); - - //- - Double_t nearSideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* (A1 * sigma1 + A2 * sigma2)/trigger->GetBinContent(i+1); - Double_t nearSideError = nearSideResult * TMath::Sqrt((t1*t1 + t2*t2)/(T1+T2)/(T1+T2)+ 1./trigger->GetBinContent(i+1)); - fNearSideIntegral->SetPoint(points,i, nearSideResult); - fNearSideIntegral->SetPointError(points,0.5,nearSideError); - - //- - - //-- - Double_t awaySideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* - (A3 * sigma3)/trigger->GetBinContent(i+1); - Double_t awaySideError = awaySideResult*TMath::Sqrt(a3e*a3e/A3/A3 + s3e*s3e/sigma3/sigma3 + 1/trigger->GetBinContent(i+1)); - fAwaySideIntegral->SetPoint(points,i, awaySideResult ); - fAwaySideIntegral->SetPointError(points,0.5, awaySideError ); - //-- - - //--- - bothSideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* (A1 * sigma1 + A2 * sigma2 + A3 * sigma3 )/trigger->GetBinContent(i+1); - bothSideError = nearSideResult * TMath::Sqrt((t1*t1 + t2*t2 + t3*t3)/(T1+T2+T3)/(T1+T2+T3)+ 1./trigger->GetBinContent(i+1)); - fBothSideIntegral->SetPoint(points,i, bothSideResult ); - fBothSideIntegral->SetPointError(points,0.5, bothSideError ); - //--- - - } - else{ - - fNearSideIntegral->SetPoint(points,i, 0); - fAwaySideIntegral->SetPoint(points,i, 0); - fBothSideIntegral->SetPoint(points,i,0); - - } - Double_t p0BinContent=p0->GetBinContent(i+1); - Double_t p0BinError=p0->GetBinError(i+1); - - //-------- - Double_t njets = p0BinContent/(1+bothSideResult); - Double_t njetsError = njets*TMath::Sqrt(bothSideError*bothSideError/(1+bothSideResult)/(1+bothSideResult) + p0BinError*p0BinError/p0BinContent/p0BinContent); - fNjets->SetPoint(points,i, njets ); - fNjets->SetPointError(points,0.5,njetsError ); - //------- - - fTriggerAverage->SetPoint(points,i, p0BinContent); - fTriggerAverage->SetPointError(points,0.5, p0BinError); - - - } - points++; - } - - - TFile* file = 0x0; - if(zyam) - file = TFile::Open("njet_zyam.root","RECREATE"); - else - file = TFile::Open("njet_fit.root","RECREATE"); - - fNearSideIntegral->Write(); - fAwaySideIntegral->Write(); - fBothSideIntegral->Write(); - fNjets->Write(); - fTriggerAverage->Write(); - - file->Close(); - - - -} - - +/* $Id: $ */ +//-------------------------------------------------- +// +// macro to do the final analysis step +// uses input of analysis class AliAnalysisTaskPhiCorrelation +// +// Author : Emilia Leogrande (University of Utrecht) +// +//------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TRandom.h" +#include "TGraphErrors.h" +#include "TFile.h" +#include "TF1.h" +#include "TMath.h" +#include "TDirectory.h" +#include "TStyle.h" +#include "TROOT.h" +#include "TColor.h" + +#include +using namespace std; + +void analyseEmy2(Bool_t zyam = kTRUE); // if zyam = kFALSE, fit is used +Double_t fitFunction(Double_t *x ,Double_t *par); // fit function using constant + 3 gaussians +Double_t fitFunction2Gaus(Double_t *x ,Double_t *par); // fit function using constant + 2 gaussians + +//input file and mixed event removed file +TFile *fileData=0x0; +TFile *fileDataEMremoved = 0x0; + +const int multclass = 20; + +TH1D *fDeltaPhiNch[multclass]; +TH1D *fDeltaEtaNch[multclass]; +TH1D *fSignalDPhi[multclass]; +TH1D *fSignalNSDPhi[multclass]; +TH1D *fSignalASDPhi[multclass]; +TH1D *fRidge1DPhi[multclass]; +TH1D *fRidge2DPhi[multclass]; +TH1D *fRidgeDPhi[multclass]; +TH1D *fSymmRidgeNotScaled[multclass]; +TH1D *fSymmRidge[multclass]; +TH1D *fFinal1DPhi[multclass]; +TH1D *fFinalDPhi[multclass]; + +TString flag = "R"; +TF1 *fTotal2Gaus[multclass]; // fit with 2 gaussians + const +TF1 *fTotal[multclass]; // fit with 3 gaussians + const + +//properties of histogram +const int bins = 72; // +Double_t binWidth=2*TMath::Pi()/bins; + +const int binsDeta = 48; + + +Double_t max_bin_for_etagap = 1.2; +Double_t min_bin_for_etagap = -1.2; +Double_t max_eta = 1.8; +Double_t min_eta = -1.8; + +//________________________________________________________________________________________________________________ +// +Double_t fitFunction(Double_t *x ,Double_t *par) +{ + // fit function for 3 gaus + constant + + // parameters for Gaussian + Double_t A1 = par[0]; + Double_t sigma1 = par[1]; + Double_t A2 = par[2]; + Double_t sigma2 = par[3]; + Double_t A3 = par[4]; + Double_t sigma3 = par[5]; + Double_t integral = par[6]; + + Double_t constante = (integral- + TMath::Sqrt(TMath::Pi()*2)/ binWidth* + (A1 * sigma1 + A2 * sigma2 + A3*sigma3))/bins; + Double_t q = x[0]; + + //fit value + Double_t fitval = constante + + (q>-0.5*TMath::Pi()&&q<0.5*TMath::Pi())*( + A1 * exp(- q * q / (2 * sigma1 *sigma1)) + + A1 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma1 * sigma1)) + ) + + + (q>-0.2*TMath::Pi()&&q<0.2*TMath::Pi())*( + A2 * exp(- q * q / (2 * sigma2 *sigma2)) + + A2 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma2 * sigma2)) + ) + + + (q>0.5*TMath::Pi()&&q<1.5*TMath::Pi())*( + A3 * exp(-((q - TMath::Pi())) * ((q - TMath::Pi())) / ( 2 * sigma3 * sigma3)) + + A3 * exp(-((q + TMath::Pi())) * ((q + TMath::Pi())) / (2 * sigma3 * sigma3)) + ); + return fitval; +} + +//________________________________________________________________________________________________________________ +// +Double_t fitFunction2Gaus(Double_t *x ,Double_t *par) +{ + // fit function for 2 gaus + constant + + // parameters for Gaussian + Double_t A1 = par[0]; + Double_t sigma1 = par[1]; + Double_t A3 = par[2]; + Double_t sigma3 = par[3]; + Double_t integral = par[4]; + + Double_t constante = (integral - + TMath::Sqrt(TMath::Pi()*2)/ binWidth* + (A1 * sigma1 + A3*sigma3))/bins; + Double_t q = x[0]; + + //fit value + Double_t fitval = constante + + (q>-0.5*TMath::Pi()&&q<0.5*TMath::Pi())*( + A1 * exp(- q * q / (2 * sigma1 *sigma1)) + + A1 * exp(-((q - TMath::TwoPi())) * ((q - TMath::TwoPi())) / ( 2 * sigma1 * sigma1)) + ) + + + (q>0.5*TMath::Pi()&&q<1.5*TMath::Pi())*( + A3 * exp(-((q - TMath::Pi())) * ((q - TMath::Pi())) / ( 2 * sigma3 * sigma3)) + + A3 * exp(-((q + TMath::Pi())) * ((q + TMath::Pi())) / (2 * sigma3 * sigma3)) + ); + return fitval; +} + +//_______________________________________________________________________________________________________________ +// +Double_t fline(Double_t *x, Double_t *par){ + + if(x[0]>-1.8 && x[0]<=0){ + return par[0]+par[1]*x[0]; + } + else if(x[0]>0 && x[0]<1.8){ + return par[2]+par[3]*x[0]; + } + else + return 0; +} + + +//________________________________________________________________________________________________________________ +// +void analyseEmy2(Bool_t zyam){ + + + // plot style + gStyle->SetOptStat(0); + const Int_t NRGBs = 5; + const Int_t NCont = 500; + Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; + Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; + Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; + Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; + TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); + gStyle->SetNumberContours(NCont); + + //style + gROOT->SetStyle("Plain"); + gStyle->SetOptStat(0); + gStyle->SetPalette(1); + + //-------------- TRIGGERS AND EVENTS + + TH2D *dphideta[multclass]; + TH1D * trigger = 0x0; + TH1D * event = 0x0; + + fileData = TFile::Open("dphi_corr.root"); + trigger = (TH1D*)fileData->Get("triggers_0"); + event = (TH1D*)fileData->Get("events"); + + // get average trigger particles per event + TProfile *p0 = (TProfile*)trigger->Clone(); + TProfile *p1 = (TProfile*)event->Clone(); + p0->Sumw2(); + p1->Sumw2(); + p0->Divide(p0,p1,1,1,"B"); + + // copy triggers and events in the new dphi_corr with the Mixed Event removed + TH1D *triggerCopy = 0x0; + TH1D *eventCopy = 0x0; + + triggerCopy = (TH1D*)trigger->Clone(); + eventCopy = (TH1D*)event->Clone(); + + fileDataEMremoved = TFile::Open("dphi_corr_MEremoved.root","RECREATE"); + triggerCopy->SetName("triggers_0"); + triggerCopy->Write(); + eventCopy->SetName("events"); + eventCopy->Write(); + fileDataEMremoved->Close(); + + + //-------------- MIXED EVENT REMOVAL: restores the right number of particles in the detector acceptance but keeps the detector azimuthal unefficiencies corrections and cures the dip in (0,0) from two-trak cuts + // Removing the event mixing: S/M (from dphi_corr) * M (from the triangle) + + Double_t triangle_factor[binsDeta]={0}; + + TH2D *s_over_m[multclass]; + TH1D *s_m_deta[multclass]; + TH2D *s_over_m_x_m[multclass]; + + for(Int_t i=0;iGet(Form("dphi_0_0_%d",i)); + s_m_deta[i] = (TH1D*)s_over_m[i]->ProjectionY()->Clone(); + s_over_m_x_m[i] = (TH2D*)s_over_m[i]->Clone(); + s_over_m_x_m[i]->Reset(); + } + + + TF1 *f2 = new TF1("f2",fline,min_eta,max_eta,4); + + f2->FixParameter(0,1); + f2->FixParameter(1,1/max_eta); + f2->FixParameter(2,1); + f2->FixParameter(3,-1/max_eta); + + for(Int_t i=0;iEval(s_m_deta[0]->GetBinCenter(i+1)); + + } + + + + //--scale each deta bin of the old TH2 with the triangle_factor[deta] + + for(Int_t i=0;i SetBinContent(k+1,j+1,(s_over_m[i]->GetBinContent(k+1,j+1))*triangle_factor[j]); + s_over_m_x_m[i]->SetBinError(k+1,j+1,(s_over_m[i]->GetBinError(k+1,j+1))*triangle_factor[j]); + } + } + } + + fileDataEMremoved = TFile::Open("dphi_corr_MEremoved.root","UPDATE"); + + for(Int_t i=0;iSetName(Form("dphiNoMixed_%d",i)); + s_over_m_x_m[i]->Write(); + + } + + + + //-------------- DOUBLE RIDGE SUBTRACTION: gets rid of no-jet related components (v3 is still kept => effect added to the systematics) + + // the ridge, estimated via an etagap, has to be scaled since it sits on the triangle + Double_t scale_for_ridge_NS = 0, scale_for_ridge_AS = 0; + + + scale_for_ridge_NS = f2->Integral(min_bin_for_etagap,max_bin_for_etagap)/(f2->Integral(min_eta,min_bin_for_etagap)+f2->Integral(max_bin_for_etagap,max_eta)); //there is etagap in the NS + cout<<"scaling NS:"<Integral(min_eta,max_eta)/(f2->Integral(min_eta,min_bin_for_etagap)+f2->Integral(max_bin_for_etagap,max_eta)); // there is no etagap in the AS + cout<<"scaling AS:"<Divide(5,4); + + for(Int_t i=0;icd(i+1); + + + dphideta[i] = (TH2D*)fileDataEMremoved->Get(Form("dphiNoMixed_%d",i)); + + + // phi and eta projections + fDeltaPhiNch[i] = (TH1D*)dphideta[i]->ProjectionX()->Clone(); + if(!zyam) + fDeltaPhiNch[i]->Scale(binWidth); //gaussians include the binwidth, so when using the fit, the histograms must be scaled first + fDeltaPhiNch[i]->Draw(); + + fDeltaEtaNch[i] = (TH1D*)dphideta[i]->ProjectionY()->Clone(); + + // signal NS: |DEta|ProjectionX(Form("|DEta|<%f",max_bin_for_etagap),fDeltaEtaNch[i]->FindBin(min_bin_for_etagap+0.0001),fDeltaEtaNch[i]->FindBin(max_bin_for_etagap-0.0001))->Clone(); + fSignalASDPhi[i] = (TH1D*)dphideta[i]->ProjectionX(Form("|DEta|<%f",max_eta))->Clone(); + + fSignalDPhi[i] = (TH1D*)fSignalASDPhi[i]->Clone(); + fSignalDPhi[i]->Reset(); + fSignalDPhi[i]->Sumw2(); + + for(Int_t k=0;kSetBinContent(k+1,fSignalNSDPhi[i]->GetBinContent(k+1)); + fSignalDPhi[i]->SetBinError(k+1, fSignalNSDPhi[i]->GetBinError(k+1)); + } + for(Int_t k=bins/2;kSetBinContent(k+1,fSignalASDPhi[i]->GetBinContent(k+1)); + fSignalDPhi[i]->SetBinError(k+1, fSignalASDPhi[i]->GetBinError(k+1)); + } + if(!zyam) + fSignalDPhi[i]->Scale(binWidth); + + // ridge1 DEtaProjectionX(Form("DEta<%f",min_bin_for_etagap),1,fDeltaEtaNch[i]->FindBin(min_bin_for_etagap-0.0001))->Clone(); + if(!zyam) + fRidge1DPhi[i]->Scale(binWidth); + fRidge1DPhi[i]->SetMarkerColor(kRed); + + // ridge2 DEta>max_bin_for_etagap + fRidge2DPhi[i] = (TH1D*)dphideta[i]->ProjectionX(Form("DEta>%f",max_bin_for_etagap),fDeltaEtaNch[i]->FindBin(max_bin_for_etagap+0.0001),fDeltaEtaNch[i]->GetNbinsX())->Clone(); + if(!zyam) + fRidge2DPhi[i]->Scale(binWidth); + fRidge2DPhi[i]->SetMarkerColor(kBlue); + + // ridge = ridge1 + ridge2 + fRidgeDPhi[i] = (TH1D*)fRidge1DPhi[i]->Clone("fRidge"); + fRidgeDPhi[i]->Reset(); + fRidgeDPhi[i]->Sumw2(); + fRidgeDPhi[i]->Add(fRidge1DPhi[i],fRidge2DPhi[i],1,1); + //fRidgeDPhi[i]->Scale(scale_for_ridge); + + // symmetrize NS ridge in the AS + fSymmRidgeNotScaled[i] = (TH1D*)fRidgeDPhi[i]->Clone("fSymmRidgeNotScaled"); + + for(Int_t k=fSymmRidgeNotScaled[i]->GetNbinsX()/2+1;k<=fSymmRidgeNotScaled[i]->GetNbinsX();k++){ + + fSymmRidgeNotScaled[i]->SetBinContent(k,fSymmRidgeNotScaled[i]->GetBinContent(fSymmRidgeNotScaled[i]->GetNbinsX()+1-k)); + + } + + // scale the symmetrized ridge according to NS or AS + fSymmRidge[i] = (TH1D*)fSymmRidgeNotScaled[i]->Clone("fSymmRidge"); + + for(Int_t k=0;kSetBinContent(k+1,(fSymmRidgeNotScaled[i]->GetBinContent(k+1))*scale_for_ridge_NS); + } + for(Int_t k=bins/2;kSetBinContent(k+1,(fSymmRidgeNotScaled[i]->GetBinContent(k+1))*scale_for_ridge_AS); + } + + + // signal - symmetric ridge + + if(zyam){ + fFinal1DPhi[i] = new TH1D(Form("fFinal1DPhi[%d]",i),Form("fFinal1DPhi[%d]",i),bins,-0.5*TMath::Pi(),1.5*TMath::Pi()); + fFinal1DPhi[i]->Add(fSignalDPhi[i],fSymmRidge[i],1,-1); + fFinal1DPhi[i]->Sumw2(); + fFinalDPhi[i] = (TH1D*)fFinal1DPhi[i]->Clone("fFinal"); // zyam: average between the two min values => sum first half of NS in the second half and second half of AS in the first half, so zyam = min/2 + fFinalDPhi[i]->Reset(); + fFinalDPhi[i]->Sumw2(); + + for(Int_t k=1;k<=bins/4;k++){ + fFinalDPhi[i]->SetBinContent(k,0.); + fFinalDPhi[i]->SetBinContent(k+bins/4,fFinal1DPhi[i]->GetBinContent(k+bins/4)+fFinal1DPhi[i]->GetBinContent(bins/4+1-k)); + fFinalDPhi[i]->SetBinError(k+bins/4,TMath::Sqrt(pow(fFinal1DPhi[i]->GetBinError(k+bins/4),2)+pow(fFinal1DPhi[i]->GetBinError(bins/4+1-k),2))); + fFinalDPhi[i]->SetBinContent(k+bins/2,fFinal1DPhi[i]->GetBinContent(k+bins/2)+fFinal1DPhi[i]->GetBinContent(bins+1-k)); + fFinalDPhi[i]->SetBinError(k+bins/2,TMath::Sqrt(pow(fFinal1DPhi[i]->GetBinError(k+bins/2),2)+pow(fFinal1DPhi[i]->GetBinError(bins+1-k),2))); + fFinalDPhi[i]->SetBinContent(k+bins/4*3,0.); + + } + } + + else{ + + fFinalDPhi[i] = (TH1D*)fSignalDPhi[i]->Clone(); + fFinalDPhi[i]->Reset(); + fFinalDPhi[i]->Sumw2(); + fFinalDPhi[i]->Add(fSignalDPhi[i],fSymmRidge[i],1,-1); + } + + } + + // store the pair yields in a file (the yields are *not* normalized to the Ntriggers) + + TFile* file_yields = 0x0; + if(zyam) + file_yields = TFile::Open("PairYields_zyam.root","RECREATE"); + else + file_yields = TFile::Open("PairYields_fit.root","RECREATE"); + + + for(Int_t i=0;iSetName(Form("DeltaEta_0_0_%d",i)); + fDeltaEtaNch[i]->Write(); + fDeltaPhiNch[i]->SetName(Form("Correlation bin %d in dphi",i)); + fDeltaPhiNch[i]->Write(); + fSignalDPhi[i]->SetName(Form("Signal_0_0_%d",i)); + fSignalDPhi[i]->Write(); + fRidgeDPhi[i]->SetName(Form("Ridge_0_0_%d",i)); + fRidgeDPhi[i]->Write(); + fSymmRidgeNotScaled[i]->SetName(Form("Symmetric_Ridge_NotScaled_0_0_%d",i)); + fSymmRidgeNotScaled[i]->Write(); + fSymmRidge[i]->SetName(Form("Symmetric_Ridge_0_0_%d",i)); + fSymmRidge[i]->Write(); + fFinalDPhi[i]->SetName(Form("Pure_Signal_0_0_%d",i)); + fFinalDPhi[i]->Write(); + } + file_yields->Close(); + + //-------------- CORRELATION OBSERVABLES: per-trigger yields, triggers and uncorrelated seeds + + Float_t baseline[multclass]={0}; + + TGraphErrors *fNearSideIntegral = new TGraphErrors(); + fNearSideIntegral->SetName("fNearSideIntegral"); + fNearSideIntegral->SetMarkerColor(kGreen+2); + fNearSideIntegral->SetLineColor(kGreen+2); + fNearSideIntegral->SetLineWidth(1); + fNearSideIntegral->SetMarkerStyle(4); + + TGraphErrors *fAwaySideIntegral = new TGraphErrors(); + fAwaySideIntegral->SetName("fAwaySideIntegral"); + fAwaySideIntegral->SetMarkerColor(kBlue); + fAwaySideIntegral->SetLineColor(kBlue); + fAwaySideIntegral->SetLineWidth(1); + fAwaySideIntegral->SetMarkerStyle(4); + + TGraphErrors *fBothSideIntegral = new TGraphErrors(); + fBothSideIntegral->SetName("fBothSideIntegral"); + fBothSideIntegral->SetMarkerColor(kMagenta); + fBothSideIntegral->SetLineColor(kMagenta); + fBothSideIntegral->SetLineWidth(1); + fBothSideIntegral->SetMarkerStyle(4); + + + TGraphErrors *fNjets = new TGraphErrors(); + fNjets->SetName("fNjets"); + fNjets->SetMarkerColor(kCyan+2); + fNjets->SetLineColor(kCyan+2); + fNjets->SetLineWidth(1); + fNjets->SetMarkerStyle(4); + + TGraphErrors *fTriggerAverage = new TGraphErrors(); + fTriggerAverage->SetName("fTriggerAverage"); + fTriggerAverage->SetMarkerColor(kBlack); + fTriggerAverage->SetLineColor(kBlack); + fTriggerAverage->SetLineWidth(1); + fTriggerAverage->SetMarkerStyle(4); + + Int_t points=0; + Double_t minbin[multclass] = {0}; + + // extract information out of dphi histograms + TCanvas * cYields= new TCanvas("cYields", "cYields", 150, 150, 820, 620); + cYields->Divide(5,4); + + for(Int_t i=0;icd(i+1); + + + if(zyam) { + + if(fFinalDPhi[i]->Integral()>0){ + fFinalDPhi[i]->GetXaxis()->SetRange(bins/4+1,bins/4*3); + baseline[i]=fFinalDPhi[i]->GetMinimum()/2; + minbin[i] = fFinalDPhi[i]->GetMinimumBin(); + fFinalDPhi[i]->GetXaxis()->UnZoom(); + + for(Int_t k=0;kGetBinContent(k+1)!=0) + fFinalDPhi[i]->SetBinContent(k+1,fFinalDPhi[i]->GetBinContent(k+1)-baseline[i]); + else + fFinalDPhi[i]->SetBinContent(k+1,0.); + } + + fFinalDPhi[i]->DrawClone(""); + + fFinalDPhi[i]->SetTitle(Form("0.7SetTitle("1/N_{trig} dN_{assoc}/d#Delta#varphi (rad^{-1})"); + //- + Double_t errorNS = 0; + Double_t nearSideResult = (fFinalDPhi[i]->IntegralAndError(0,minbin[i],errorNS,"width"))/trigger->GetBinContent(i+1); + Double_t nearSideError = errorNS/trigger->GetBinContent(i+1); + fNearSideIntegral->SetPoint(points,i, nearSideResult); + fNearSideIntegral->SetPointError(points,0.5,errorNS/trigger->GetBinContent(i+1)); + //- + + //-- + Double_t errorAS = 0; + Double_t awaySideResult = (fFinalDPhi[i]->IntegralAndError(minbin[i],bins,errorAS,"width"))/trigger->GetBinContent(i+1); + Double_t awaySideError = errorAS/trigger->GetBinContent(i+1); + fAwaySideIntegral->SetPoint(points,i, awaySideResult ); + fAwaySideIntegral->SetPointError(points,0.5, errorAS/trigger->GetBinContent(i+1)); + //-- + + //--- + Double_t bothSideResult = nearSideResult + awaySideResult; + Double_t bothSideError = bothSideResult * TMath::Sqrt(pow(errorNS,2)+pow(errorAS,2))/trigger->GetBinContent(i+1); + fBothSideIntegral->SetPoint(points,i, bothSideResult ); + fBothSideIntegral->SetPointError(points,0.5, bothSideError ); + //--- + + + + } + else{ + fNearSideIntegral->SetPoint(points,i, 0); + fAwaySideIntegral->SetPoint(points,i, 0); + fBothSideIntegral->SetPoint(points,i,0); + } + Double_t p0BinContent=p0->GetBinContent(i+1); + Double_t p0BinError=p0->GetBinError(i+1); + + //-------- + Double_t njets = p0BinContent/(1+bothSideResult); + Double_t njetsError = njets*TMath::Sqrt(bothSideError*bothSideError/(1+bothSideResult)/(1+bothSideResult)+p0BinError*p0BinError/p0BinContent/p0BinContent); + fNjets->SetPoint(points,i, njets ); + fNjets->SetPointError(points,0.5,njetsError ); + + //------- + + fTriggerAverage->SetPoint(points,i, p0BinContent); + fTriggerAverage->SetPointError(points,0.5, p0BinError); + + } + + else if (!zyam){ + + if(fFinalDPhi[i]->Integral()>0){ + + //first fit function: 2 gauss + const + fTotal2Gaus[i] = new TF1(Form("gaus3and2_%d",i), fitFunction2Gaus , -0.5*TMath::Pi(), 1.5*TMath::Pi(), 5); + fTotal2Gaus[i]->SetName(Form("gaus3_%d",i)); + fTotal2Gaus[i]->SetParNames ("A1","sigma1","A3", "sigma3"); + fTotal2Gaus[i]->SetLineColor(kRed); + fTotal2Gaus[i]->SetLineWidth(2); + + baseline[i]=fFinalDPhi[i]->GetMinimum(); + Double_t integr_for_const_2 = fFinalDPhi[i]->Integral(); + + fTotal2Gaus[i]->FixParameter(4,integr_for_const_2); + fTotal2Gaus[i]->SetParameters( fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0)) - baseline[i] , 0.6 , fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i] , 0.6); + + fTotal2Gaus[i]->SetParLimits(0, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); + fTotal2Gaus[i]->SetParLimits(1, 0.01, 10); + fTotal2Gaus[i]->SetParLimits(2, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i])*2); + fTotal2Gaus[i]->SetParLimits(3, 0.01, 10); + + fTotal2Gaus[i]->SetLineColor(kRed); + fTotal2Gaus[i]->SetLineWidth(2); + + fFinalDPhi[i]->Fit(fTotal2Gaus[i],flag); + fFinalDPhi[i]->SetMinimum(0); + fFinalDPhi[i]->DrawClone(""); + fTotal2Gaus[i] ->DrawClone("same"); + + Double_t A11 = fTotal2Gaus[i]->GetParameter(0); + Double_t sigma11 = fTotal2Gaus[i]->GetParameter(1); + Double_t A31 = fTotal2Gaus[i]->GetParameter(2); + Double_t sigma31 = fTotal2Gaus[i]->GetParameter(3); + + Double_t a1e1 = fTotal2Gaus[i]->GetParError(0); + Double_t s1e1 = fTotal2Gaus[i]->GetParError(1); + Double_t a3e1 = fTotal2Gaus[i]->GetParError(2); + Double_t s3e1 = fTotal2Gaus[i]->GetParError(3); + + + Double_t T11 = A11*sigma11; + Double_t T31 = A31*sigma31; + Double_t t11 = T11*TMath::Sqrt(a1e1*a1e1/A11/A11 + s1e1*s1e1/sigma11/sigma11); + Double_t t31 = T31*TMath::Sqrt(a3e1*a3e1/A31/A31 + s3e1*s3e1/sigma31/sigma31); + + + //second fit: 3 gauss + const + fTotal[i] = new TF1(Form("gaus3_%d",i), fitFunction , -0.5*TMath::Pi(), 1.5*TMath::Pi(), 7); + fTotal[i]->SetName(Form("gaus3_%d",i)); + fTotal[i]->SetParNames ("A1","sigma1","A2","sigma2", "A3", "sigma3","integral"); + fTotal[i]->SetLineColor(kRed); + fTotal[i]->SetLineWidth(2); + + Double_t integr_for_const = fFinalDPhi[i]->Integral(); + + + fTotal[i]->FixParameter(0,A11); + fTotal[i]->FixParameter(1,sigma11*1.2); + fTotal[i]->FixParameter(2,A11); + fTotal[i]->FixParameter(3,sigma11*0.7); + fTotal[i]->FixParameter(4,A31); + fTotal[i]->FixParameter(5,sigma31); + fTotal[i]->FixParameter(6,integr_for_const); + + fTotal[i]->SetParLimits(0, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); + fTotal[i]->SetParLimits(1, 0.3, 10); + fTotal[i]->SetParLimits(2, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]->GetXaxis()->FindFixBin(0))-baseline[i])*2); + fTotal[i]->SetParLimits(3, 0.12, 0.4); + fTotal[i]->SetParLimits(4, 0, (fFinalDPhi[i]->GetBinContent(fFinalDPhi[i]-> + GetXaxis()->FindFixBin(TMath::Pi()))-baseline[i])*2); + fTotal[i]->SetParLimits(5, 0.01, 10); + + fTotal[i]->SetLineColor(kRed); + fTotal[i]->SetLineWidth(2); + + + fFinalDPhi[i]->Fit(fTotal[i],flag); + fFinalDPhi[i]->SetMinimum(0); + fFinalDPhi[i]->DrawClone(""); + fFinalDPhi[i]->SetTitle(Form("0.7SetTitle("1/N_{trig} dN_{assoc}/d#Delta#varphi (rad^{-1})"); + fTotal[i]->DrawClone("same"); + + Double_t A1 = fTotal[i]->GetParameter(0); + Double_t sigma1 = fTotal[i]->GetParameter(1); + Double_t A2 = fTotal[i]->GetParameter(2); + Double_t sigma2 = fTotal[i]->GetParameter(3); + Double_t A3 = fTotal[i]->GetParameter(4); + Double_t sigma3 = fTotal[i]->GetParameter(5); + + + //define each gaussian and constant to be drawn with different colors on top of each other + + TF1 * fConstant = new TF1("konst", "pol0(0)",-0.5*TMath::Pi(), 1.5*TMath::Pi()); + fConstant->SetParameter(0,(integr_for_const - TMath::Sqrt(TMath::Pi()*2)/binWidth*(A1*sigma1+A2*sigma2+A3*sigma3))/bins); + fConstant->SetLineColor(kBlue); + fConstant->Draw("same"); + + //gaus 1 NS + TF1 * fGaussian1 = new TF1("fGaussian1", "[0]*exp(-x*x/(2*[1]*[1])) +[0] * exp(-(x-TMath::TwoPi())*(x-TMath::TwoPi())/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); + fGaussian1->SetParameters(fTotal[i]->GetParameter(0),fTotal[i]->GetParameter(1)); + fGaussian1->SetLineColor(kMagenta); + fGaussian1->SetLineStyle(1); + fGaussian1->Draw("same"); + + //gaus 2 NS + TF1 * fGaussian2 = new TF1("fGaussian2", "[0]*exp(-x*x/(2*[1]*[1])) +[0] * exp(-(x-TMath::TwoPi())*(x-TMath::TwoPi())/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); + fGaussian2->SetLineColor(kGreen+2); + fGaussian2->SetParameters(fTotal[i]->GetParameter(2),fTotal[i]->GetParameter(3)); + fGaussian2->Draw("same"); + + //gaus 3 AS + TF1 * fGaussian3 = new TF1("fGaussian3", "[0] * exp(-((x-TMath::Pi()))*((x-TMath::Pi()))/(2*[1]*[1]))+[0] * exp(-((x+TMath::Pi()))*((x+TMath::Pi()))/(2*[1]*[1]))",-0.5*TMath::Pi(), 1.5*TMath::Pi()); + fGaussian3->SetLineColor(kCyan); + fGaussian3->SetParameters(fTotal[i]->GetParameter(4), fTotal[i]->GetParameter(5)); + fGaussian3->Draw("same"); + + + Double_t a1e = fTotal[i]->GetParError(0); + Double_t s1e = fTotal[i]->GetParError(1); + Double_t a2e = fTotal[i]->GetParError(2); + Double_t s2e = fTotal[i]->GetParError(3); + Double_t a3e = fTotal[i]->GetParError(4); + Double_t s3e = fTotal[i]->GetParError(5); + + Double_t T1 = A1*sigma1; + Double_t T2 = A2*sigma2; + Double_t T3 = A3*sigma3; + Double_t t1 = T1*TMath::Sqrt(a1e*a1e/A1/A1 + s1e*s1e/sigma1/sigma1); + Double_t t2 = T2*TMath::Sqrt(a2e*a2e/A2/A2 + s2e*s2e/sigma2/sigma2); + Double_t t3 = T3*TMath::Sqrt(a3e*a3e/A3/A3 + s3e*s3e/sigma3/sigma3); + + //- + Double_t nearSideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* (A1 * sigma1 + A2 * sigma2)/trigger->GetBinContent(i+1); + Double_t nearSideError = nearSideResult * TMath::Sqrt((t1*t1 + t2*t2)/(T1+T2)/(T1+T2)+ 1./trigger->GetBinContent(i+1)); + fNearSideIntegral->SetPoint(points,i, nearSideResult); + fNearSideIntegral->SetPointError(points,0.5,nearSideError); + + //- + + //-- + Double_t awaySideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* + (A3 * sigma3)/trigger->GetBinContent(i+1); + Double_t awaySideError = awaySideResult*TMath::Sqrt(a3e*a3e/A3/A3 + s3e*s3e/sigma3/sigma3 + 1/trigger->GetBinContent(i+1)); + fAwaySideIntegral->SetPoint(points,i, awaySideResult ); + fAwaySideIntegral->SetPointError(points,0.5, awaySideError ); + //-- + + //--- + bothSideResult = TMath::Sqrt(TMath::Pi()*2)/ binWidth* (A1 * sigma1 + A2 * sigma2 + A3 * sigma3 )/trigger->GetBinContent(i+1); + bothSideError = nearSideResult * TMath::Sqrt((t1*t1 + t2*t2 + t3*t3)/(T1+T2+T3)/(T1+T2+T3)+ 1./trigger->GetBinContent(i+1)); + fBothSideIntegral->SetPoint(points,i, bothSideResult ); + fBothSideIntegral->SetPointError(points,0.5, bothSideError ); + //--- + + } + else{ + + fNearSideIntegral->SetPoint(points,i, 0); + fAwaySideIntegral->SetPoint(points,i, 0); + fBothSideIntegral->SetPoint(points,i,0); + + } + Double_t p0BinContent=p0->GetBinContent(i+1); + Double_t p0BinError=p0->GetBinError(i+1); + + //-------- + Double_t njets = p0BinContent/(1+bothSideResult); + Double_t njetsError = njets*TMath::Sqrt(bothSideError*bothSideError/(1+bothSideResult)/(1+bothSideResult) + p0BinError*p0BinError/p0BinContent/p0BinContent); + fNjets->SetPoint(points,i, njets ); + fNjets->SetPointError(points,0.5,njetsError ); + //------- + + fTriggerAverage->SetPoint(points,i, p0BinContent); + fTriggerAverage->SetPointError(points,0.5, p0BinError); + + + } + points++; + } + + + TFile* file = 0x0; + if(zyam) + file = TFile::Open("njet_zyam.root","RECREATE"); + else + file = TFile::Open("njet_fit.root","RECREATE"); + + fNearSideIntegral->Write(); + fAwaySideIntegral->Write(); + fBothSideIntegral->Write(); + fNjets->Write(); + fTriggerAverage->Write(); + + file->Close(); + + + +} + + diff --git a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx index cb077fcbd8b..d92f6b4664d 100755 --- a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx +++ b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx @@ -1,2359 +1,2359 @@ -#include "TChain.h" -#include "TList.h" -#include "TCanvas.h" -#include "TLorentzVector.h" -#include "TGraphErrors.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TH3F.h" -#include "TH2D.h" -#include "TH3D.h" -#include "TArrayF.h" -#include "TF1.h" -#include "TRandom.h" - -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" - -#include "AliESDVertex.h" -#include "AliESDEvent.h" -#include "AliESDInputHandler.h" -#include "AliAODEvent.h" -#include "AliAODTrack.h" -#include "AliAODInputHandler.h" -#include "AliAODMCParticle.h" -#include "AliCollisionGeometry.h" -#include "AliGenEventHeader.h" -#include "AliMCEventHandler.h" -#include "AliMCEvent.h" -#include "AliStack.h" -#include "AliESDtrackCuts.h" -#include "AliEventplane.h" -#include "AliTHn.h" -#include "AliLog.h" -#include "AliAnalysisUtils.h" - -#include "AliEventPoolManager.h" - -#include "AliPID.h" -#include "AliPIDResponse.h" -#include "AliPIDCombined.h" - -#include "AliAnalysisTaskBFPsi.h" -#include "AliBalancePsi.h" -#include "AliAnalysisTaskTriggeredBF.h" - - -// Analysis task for the BF vs Psi code -// Authors: Panos.Christakoglou@nikhef.nl - -using std::cout; -using std::endl; - -ClassImp(AliAnalysisTaskBFPsi) - -//________________________________________________________________________ -AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name) -: AliAnalysisTaskSE(name), - fDebugLevel(kFALSE), - fArrayMC(0), //+++++++++++++ - fBalance(0), - fRunShuffling(kFALSE), - fShuffledBalance(0), - fRunMixing(kFALSE), - fRunMixingEventPlane(kFALSE), - fMixingTracks(50000), - fMixedBalance(0), - fPoolMgr(0), - fList(0), - fListBF(0), - fListBFS(0), - fListBFM(0), - fHistListPIDQA(0), - fHistEventStats(0), - fHistCentStats(0), - fHistCentStatsUsed(0), - fHistTriggerStats(0), - fHistTrackStats(0), - fHistVx(0), - fHistVy(0), - fHistVz(0), - fHistTPCvsVZEROMultiplicity(0), - fHistVZEROSignal(0), - fHistEventPlane(0), - fHistClus(0), - fHistDCA(0), - fHistChi2(0), - fHistPt(0), - fHistEta(0), - fHistRapidity(0), - fHistPhi(0), - fHistEtaPhiPos(0), - fHistEtaPhiNeg(0), - fHistPhiBefore(0), - fHistPhiAfter(0), - fHistPhiPos(0), - fHistPhiNeg(0), - fHistV0M(0), - fHistRefTracks(0), - fHistdEdxVsPTPCbeforePID(NULL), - fHistBetavsPTOFbeforePID(NULL), - fHistProbTPCvsPtbeforePID(NULL), - fHistProbTOFvsPtbeforePID(NULL), - fHistProbTPCTOFvsPtbeforePID(NULL), - fHistNSigmaTPCvsPtbeforePID(NULL), - fHistNSigmaTOFvsPtbeforePID(NULL), - fHistBetaVsdEdXbeforePID(NULL), //+++++++ - fHistNSigmaTPCTOFvsPtbeforePID(NULL), //++++++ - fHistdEdxVsPTPCafterPID(NULL), - fHistBetavsPTOFafterPID(NULL), - fHistProbTPCvsPtafterPID(NULL), - fHistProbTOFvsPtafterPID(NULL), - fHistProbTPCTOFvsPtafterPID(NULL), - fHistNSigmaTPCvsPtafterPID(NULL), - fHistNSigmaTOFvsPtafterPID(NULL), - fHistBetaVsdEdXafterPID(NULL), //+++++++ - fHistNSigmaTPCTOFvsPtafterPID(NULL), //+++++++ - fHistdEdxVsPTPCbeforePIDelectron(NULL), //+++++++ - fHistNSigmaTPCvsPtbeforePIDelectron(NULL), //+++++++ - fHistdEdxVsPTPCafterPIDelectron(NULL), //+++++++ - fHistNSigmaTPCvsPtafterPIDelectron(NULL), //+++++++ - fCentralityArrayBinsForCorrections(kCENTRALITY), - fCentralityWeights(0x0), - fPIDResponse(0x0), - fPIDCombined(0x0), - fParticleOfInterest(kPion), - fPidDetectorConfig(kTPCTOF), - fUsePID(kFALSE), - fUsePIDnSigma(kTRUE), - fUsePIDPropabilities(kFALSE), - fPIDNSigma(3.), - fMinAcceptedPIDProbability(0.8), - fElectronRejection(kFALSE), - fElectronOnlyRejection(kFALSE), - fElectronRejectionNSigma(-1.), - fElectronRejectionMinPt(0.), - fElectronRejectionMaxPt(1000.), - fESDtrackCuts(0), - fCentralityEstimator("V0M"), - fUseCentrality(kFALSE), - fCentralityPercentileMin(0.), - fCentralityPercentileMax(5.), - fImpactParameterMin(0.), - fImpactParameterMax(20.), - fMultiplicityEstimator("V0A"), - fUseMultiplicity(kFALSE), - fNumberOfAcceptedTracksMin(0), - fNumberOfAcceptedTracksMax(10000), - fHistNumberOfAcceptedTracks(0), - fHistMultiplicity(0), - fUseOfflineTrigger(kFALSE), - fCheckFirstEventInChunk(kFALSE), - fCheckPileUp(kFALSE), - fCheckPrimaryFlagAOD(kFALSE), - fUseMCforKinematics(kFALSE), - fVxMax(0.3), - fVyMax(0.3), - fVzMax(10.), - fnAODtrackCutBit(128), - fPtMin(0.3), - fPtMax(1.5), - fPtMinForCorrections(0.3),//=================================correction - fPtMaxForCorrections(1.5),//=================================correction - fPtBinForCorrections(36), //=================================correction - fEtaMin(-0.8), - fEtaMax(-0.8), - fEtaMinForCorrections(-0.8),//=================================correction - fEtaMaxForCorrections(0.8),//=================================correction - fEtaBinForCorrections(16), //=================================correction - fPhiMin(0.), - fPhiMax(360.), - fPhiMinForCorrections(0.),//=================================correction - fPhiMaxForCorrections(360.),//=================================correction - fPhiBinForCorrections(100), //=================================correction - fDCAxyCut(-1), - fDCAzCut(-1), - fTPCchi2Cut(-1), - fNClustersTPCCut(-1), - fAcceptanceParameterization(0), - fDifferentialV2(0), - fUseFlowAfterBurner(kFALSE), - fExcludeResonancesInMC(kFALSE), - fExcludeElectronsInMC(kFALSE), - fUseMCPdgCode(kFALSE), - fPDGCodeToBeAnalyzed(-1), - fEventClass("EventPlane"), - fCustomBinning(""), - fHistVZEROAGainEqualizationMap(0), - fHistVZEROCGainEqualizationMap(0), - fHistVZEROChannelGainEqualizationMap(0) { - // Constructor - // Define input and output slots here - // Input slot #0 works with a TChain - - //======================================================correction - for (Int_t i=0; iSetAnalysisLevel("ESD"); - fBalance->SetEventClass(fEventClass); - //fBalance->SetNumberOfBins(-1,16); - //fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.); - } - if(fRunShuffling) { - if(!fShuffledBalance) { - fShuffledBalance = new AliBalancePsi(); - fShuffledBalance->SetAnalysisLevel("ESD"); - fShuffledBalance->SetEventClass(fEventClass); - //fShuffledBalance->SetNumberOfBins(-1,16); - //fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.); - } - } - if(fRunMixing) { - if(!fMixedBalance) { - fMixedBalance = new AliBalancePsi(); - fMixedBalance->SetAnalysisLevel("ESD"); - fMixedBalance->SetEventClass(fEventClass); - } - } - - //QA list - fList = new TList(); - fList->SetName("listQA"); - fList->SetOwner(); - - //Balance Function list - fListBF = new TList(); - fListBF->SetName("listBF"); - fListBF->SetOwner(); - - if(fRunShuffling) { - fListBFS = new TList(); - fListBFS->SetName("listBFShuffled"); - fListBFS->SetOwner(); - } - - if(fRunMixing) { - fListBFM = new TList(); - fListBFM->SetName("listTriggeredBFMixed"); - fListBFM->SetOwner(); - } - - //PID QA list - if(fUsePID || fElectronRejection) { - fHistListPIDQA = new TList(); - fHistListPIDQA->SetName("listQAPID"); - fHistListPIDQA->SetOwner(); - } - - //Event stats. - TString gCutName[7] = {"Total","Offline trigger", - "Vertex","Analyzed","sel. Centrality","Not1stEvInChunk","No Pile-Up"}; - fHistEventStats = new TH2F("fHistEventStats", - "Event statistics;;Centrality percentile;N_{events}", - 7,0.5,7.5,220,-5,105); - for(Int_t i = 1; i <= 7; i++) - fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); - fList->Add(fHistEventStats); - - TString gCentName[13] = {"V0M","V0A","V0C","FMD","TRK","TKL","CL0","CL1","ZNA","ZPA","V0MvsFMD","TKLvsV0M","ZEMvsZDC"}; - fHistCentStats = new TH2F("fHistCentStats", - "Centrality statistics;;Cent percentile", - 13,-0.5,12.5,220,-5,105); - for(Int_t i = 1; i <= 13; i++){ - fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); - //fHistCentStatsUsed->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); - } - fList->Add(fHistCentStats); - - fHistCentStatsUsed = new TH2F("fHistCentStatsUsed","Centrality statistics;;Cent percentile", 1,-0.5,0.5,220,-5,105); - fHistCentStatsUsed->GetXaxis()->SetBinLabel(1,fCentralityEstimator.Data()); - fList->Add(fHistCentStatsUsed); - - fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",1025,0,1025); - fList->Add(fHistTriggerStats); - - fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",16,0,16); - fList->Add(fHistTrackStats); - - fHistNumberOfAcceptedTracks = new TH2F("fHistNumberOfAcceptedTracks",";N_{acc.};Centrality percentile;Entries",4001,-0.5,4000.5,220,-5,105); - fList->Add(fHistNumberOfAcceptedTracks); - - fHistMultiplicity = new TH1F("fHistMultiplicity",";N_{ch.};Entries",30001,-0.5,30000.5); - fList->Add(fHistMultiplicity); - - // Vertex distributions - fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5); - fList->Add(fHistVx); - fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5); - fList->Add(fHistVy); - fHistVz = new TH2F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Centrality percentile;Entries",100,-20.,20.,220,-5,105); - fList->Add(fHistVz); - - //TPC vs VZERO multiplicity - fHistTPCvsVZEROMultiplicity = new TH2F("fHistTPCvsVZEROMultiplicity","VZERO vs TPC multiplicity",10001,-0.5,10000.5,4001,-0.5,4000.5); - if(fMultiplicityEstimator == "V0A") - fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-A multiplicity (a.u.)"); - else if(fMultiplicityEstimator == "V0C") - fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-C multiplicity (a.u.)"); - else - fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO multiplicity (a.u.)"); - fList->Add(fHistTPCvsVZEROMultiplicity); - - fHistVZEROSignal = new TH2F("fHistVZEROSignal","VZERO signal vs VZERO channel;VZERO channel; Signal (a.u.)",64,0.5,64.5,3001,-0.5,30000.5); - fList->Add(fHistVZEROSignal); - - //Event plane - fHistEventPlane = new TH2F("fHistEventPlane",";#Psi_{2} [deg.];Centrality percentile;Counts",100,0,360.,220,-5,105); - fList->Add(fHistEventPlane); - - // QA histograms - fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200); - fList->Add(fHistClus); - fHistChi2 = new TH2F("fHistChi2","Chi2/NDF distribution;#chi^{2}/ndf;Centrality percentile",200,0,10,220,-5,105); - fList->Add(fHistChi2); - fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5); - fList->Add(fHistDCA); - fHistPt = new TH2F("fHistPt","p_{T} distribution;p_{T} (GeV/c);Centrality percentile",200,0,10,220,-5,105); - fList->Add(fHistPt); - fHistEta = new TH2F("fHistEta","#eta distribution;#eta;Centrality percentile",200,-2,2,220,-5,105); - fList->Add(fHistEta); - fHistRapidity = new TH2F("fHistRapidity","y distribution;y;Centrality percentile",200,-2,2,220,-5,105); - fList->Add(fHistRapidity); - fHistPhi = new TH2F("fHistPhi","#phi distribution;#phi (rad);Centrality percentile",200,0.0,2.*TMath::Pi(),220,-5,105); - fList->Add(fHistPhi); - fHistEtaPhiPos = new TH3F("fHistEtaPhiPos","#eta-#phi distribution (+);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105); - fList->Add(fHistEtaPhiPos); - fHistEtaPhiNeg = new TH3F("fHistEtaPhiNeg","#eta-#phi distribution (-);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105); - fList->Add(fHistEtaPhiNeg); - fHistPhiBefore = new TH2F("fHistPhiBefore","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); - fList->Add(fHistPhiBefore); - fHistPhiAfter = new TH2F("fHistPhiAfter","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); - fList->Add(fHistPhiAfter); - fHistPhiPos = new TH2F("fHistPhiPos","#phi distribution for positive particles;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); - fList->Add(fHistPhiPos); - fHistPhiNeg = new TH2F("fHistPhiNeg","#phi distribution for negative particles;#phi;Centrality percentile",200,0.,2.*TMath::Pi(),220,-5,105); - fList->Add(fHistPhiNeg); - fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000); - fList->Add(fHistV0M); - TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"}; - fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000); - for(Int_t i = 1; i <= 6; i++) - fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data()); - fList->Add(fHistRefTracks); - - // Balance function histograms - // Initialize histograms if not done yet (including the custom binning) - if(!fBalance->GetHistNp()){ - AliInfo("Histograms not yet initialized! --> Will be done now"); - fBalance->SetCustomBinning(fCustomBinning); - fBalance->InitHistograms(); - } - - if(fRunShuffling) { - if(!fShuffledBalance->GetHistNp()) { - AliInfo("Histograms (shuffling) not yet initialized! --> Will be done now"); - fShuffledBalance->SetCustomBinning(fCustomBinning); - fShuffledBalance->InitHistograms(); - } - } - - if(fRunMixing) { - if(!fMixedBalance->GetHistNp()) { - AliInfo("Histograms (mixing) not yet initialized! --> Will be done now"); - fMixedBalance->SetCustomBinning(fCustomBinning); - fMixedBalance->InitHistograms(); - } - } - - // QA histograms for different cuts - fList->Add(fBalance->GetQAHistHBTbefore()); - fList->Add(fBalance->GetQAHistHBTafter()); - fList->Add(fBalance->GetQAHistConversionbefore()); - fList->Add(fBalance->GetQAHistConversionafter()); - fList->Add(fBalance->GetQAHistPsiMinusPhi()); - fList->Add(fBalance->GetQAHistResonancesBefore()); - fList->Add(fBalance->GetQAHistResonancesRho()); - fList->Add(fBalance->GetQAHistResonancesK0()); - fList->Add(fBalance->GetQAHistResonancesLambda()); - fList->Add(fBalance->GetQAHistQbefore()); - fList->Add(fBalance->GetQAHistQafter()); - - //for(Int_t a = 0; a < ANALYSIS_TYPES; a++){ - fListBF->Add(fBalance->GetHistNp()); - fListBF->Add(fBalance->GetHistNn()); - fListBF->Add(fBalance->GetHistNpn()); - fListBF->Add(fBalance->GetHistNnn()); - fListBF->Add(fBalance->GetHistNpp()); - fListBF->Add(fBalance->GetHistNnp()); - - if(fRunShuffling) { - fListBFS->Add(fShuffledBalance->GetHistNp()); - fListBFS->Add(fShuffledBalance->GetHistNn()); - fListBFS->Add(fShuffledBalance->GetHistNpn()); - fListBFS->Add(fShuffledBalance->GetHistNnn()); - fListBFS->Add(fShuffledBalance->GetHistNpp()); - fListBFS->Add(fShuffledBalance->GetHistNnp()); - } - - if(fRunMixing) { - fListBFM->Add(fMixedBalance->GetHistNp()); - fListBFM->Add(fMixedBalance->GetHistNn()); - fListBFM->Add(fMixedBalance->GetHistNpn()); - fListBFM->Add(fMixedBalance->GetHistNnn()); - fListBFM->Add(fMixedBalance->GetHistNpp()); - fListBFM->Add(fMixedBalance->GetHistNnp()); - } - //} - - - // Event Mixing - if(fRunMixing){ - Int_t trackDepth = fMixingTracks; - Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager - - // centrality bins - Double_t* centbins = NULL; - Int_t nCentralityBins; - if(fBalance->IsUseVertexBinning()){ - centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centralityVertex", nCentralityBins); - } - else{ - centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centrality", nCentralityBins); - } - - // multiplicity bins - Double_t* multbins = NULL; - Int_t nMultiplicityBins; - multbins = fBalance->GetBinning(fBalance->GetBinningString(), "multiplicity", nMultiplicityBins); - - // Zvtx bins - Double_t* vtxbins = NULL; - Int_t nVertexBins; - if(fBalance->IsUseVertexBinning()){ - vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertexVertex", nVertexBins); - } - else{ - vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertex", nVertexBins); - } - - // Event plane angle (Psi) bins - Double_t* psibins = NULL; - Int_t nPsiBins; - psibins = fBalance->GetBinning(fBalance->GetBinningString(), "eventPlane", nPsiBins); - - - // run the event mixing also in bins of event plane (statistics!) - if(fRunMixingEventPlane){ - if(fEventClass=="Multiplicity"){ - if(multbins && vtxbins && psibins){ - fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins, nPsiBins, psibins); - } - } - else{ - if(centbins && vtxbins && psibins){ - fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins, nPsiBins, psibins); - } - } - } - else{ - if(fEventClass=="Multiplicity"){ - if(multbins && vtxbins){ - fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins); - } - } - else{ - if(centbins && vtxbins){ - fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins); - } - } - } - - // check pool manager - if(!fPoolMgr){ - AliError("Event Mixing required, but Pool Manager not initialized..."); - return; - } - } - - if(fESDtrackCuts) fList->Add(fESDtrackCuts); - - //====================PID========================// - if(fUsePID) { - fPIDCombined = new AliPIDCombined(); - fPIDCombined->SetDefaultTPCPriors(); - - fHistdEdxVsPTPCbeforePID = new TH2D ("dEdxVsPTPCbefore","dEdxVsPTPCbefore", 1000, -10.0, 10.0, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePID); - - fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetavsPTOFbeforePID); - - fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID); - - fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID); - - fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID); - - fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID); - - fHistNSigmaTOFvsPtbeforePID = new TH2D ("NSigmaTOFvsPtbefore","NSigmaTOFvsPtbefore", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTOFvsPtbeforePID); - - fHistBetaVsdEdXbeforePID = new TH2D ("BetaVsdEdXbefore","BetaVsdEdXbefore", 1000, 0., 1000, 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetaVsdEdXbeforePID); //++++++++ - - fHistNSigmaTPCTOFvsPtbeforePID = new TH2D ("NSigmaTPCTOFvsPtbefore","NSigmaTPCTOFvsPtbefore", 1000, -10., 10., 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtbeforePID); //++++++++ - - fHistdEdxVsPTPCafterPID = new TH2D ("dEdxVsPTPCafter","dEdxVsPTPCafter", 1000, -10, 10, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCafterPID); - - fHistBetavsPTOFafterPID = new TH2D ("BetavsPTOFafter","BetavsPTOFafter", 1000, -10, 10, 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetavsPTOFafterPID); - - fHistProbTPCvsPtafterPID = new TH2D ("ProbTPCvsPtafter","ProbTPCvsPtafter", 1000, -10, 10, 1000, 0, 2); - fHistListPIDQA->Add(fHistProbTPCvsPtafterPID); - - fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000, -10, 10, 1000, 0, 2); - fHistListPIDQA->Add(fHistProbTOFvsPtafterPID); - - fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID); - - fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID); - - fHistNSigmaTOFvsPtafterPID = new TH2D ("NSigmaTOFvsPtafter","NSigmaTOFvsPtafter", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTOFvsPtafterPID); - - fHistBetaVsdEdXafterPID = new TH2D ("BetaVsdEdXafter","BetaVsdEdXafter", 1000, 0., 1000, 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetaVsdEdXafterPID); //++++++++ - - fHistNSigmaTPCTOFvsPtafterPID = new TH2D ("NSigmaTPCTOFvsPtafter","NSigmaTPCTOFvsPtafter", 1000, -10., 10., 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtafterPID); //++++++++ - } - - // for electron rejection only TPC nsigma histograms - if(fElectronRejection) { - - fHistdEdxVsPTPCbeforePIDelectron = new TH2D ("dEdxVsPTPCbeforeelectron","dEdxVsPTPCbeforeelectron", 1000, -10.0, 10.0, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePIDelectron); - - fHistNSigmaTPCvsPtbeforePIDelectron = new TH2D ("NSigmaTPCvsPtbeforeelectron","NSigmaTPCvsPtbeforeelectron", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePIDelectron); - - fHistdEdxVsPTPCafterPIDelectron = new TH2D ("dEdxVsPTPCafterelectron","dEdxVsPTPCafterelectron", 1000, -10, 10, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCafterPIDelectron); - - fHistNSigmaTPCvsPtafterPIDelectron = new TH2D ("NSigmaTPCvsPtafterelectron","NSigmaTPCvsPtafterelectron", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPIDelectron); - } - //====================PID========================// - - // Post output data. - PostData(1, fList); - PostData(2, fListBF); - if(fRunShuffling) PostData(3, fListBFS); - if(fRunMixing) PostData(4, fListBFM); - if(fUsePID || fElectronRejection) PostData(5, fHistListPIDQA); //PID - - AliInfo("Finished setting up the Output"); - - TH1::AddDirectory(oldStatus); -} - - -//________________________________________________________________________ -void AliAnalysisTaskBFPsi::SetInputCorrection(TString filename, - Int_t nCentralityBins, - Double_t *centralityArrayForCorrections) { - //Open files that will be used for correction - fCentralityArrayBinsForCorrections = nCentralityBins; - for (Int_t i=0; i run without corrections - if(!filename.Contains(".root")) { - AliInfo(Form("No correction file specified (= %s) --> run without corrections",filename.Data())); - return; - } - - //Open the input file - TFile *f = TFile::Open(filename); - if(!f->IsOpen()) { - AliInfo(Form("File %s not found --> run without corrections",filename.Data())); - return; - } - - //TString listEffName = ""; - for (Int_t iCent = 0; iCent < fCentralityArrayBinsForCorrections-1; iCent++) { - //Printf("iCent %d:",iCent); - TString histoName = "fHistCorrectionPlus"; - histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1])); - fHistCorrectionPlus[iCent]= dynamic_cast(f->Get(histoName.Data())); - if(!fHistCorrectionPlus[iCent]) { - AliError(Form("fHist %s not found!!!",histoName.Data())); - return; - } - - histoName = "fHistCorrectionMinus"; - histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1])); - fHistCorrectionMinus[iCent] = dynamic_cast(f->Get(histoName.Data())); - if(!fHistCorrectionMinus[iCent]) { - AliError(Form("fHist %s not found!!!",histoName.Data())); - return; - } - }//loop over centralities: ONLY the PbPb case is covered - - if(fHistCorrectionPlus[0]){ - fEtaMinForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmin(); - fEtaMaxForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmax(); - fEtaBinForCorrections = fHistCorrectionPlus[0]->GetNbinsX(); - - fPtMinForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmin(); - fPtMaxForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmax(); - fPtBinForCorrections = fHistCorrectionPlus[0]->GetNbinsY(); - - fPhiMinForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmin(); - fPhiMaxForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmax(); - fPhiBinForCorrections = fHistCorrectionPlus[0]->GetNbinsZ(); - } -} - -//________________________________________________________________________ -void AliAnalysisTaskBFPsi::UserExec(Option_t *) { - // Main loop - // Called for each event - - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - Int_t gNumberOfAcceptedTracks = 0; - Double_t lMultiplicityVar = -999.; //-1 - Double_t gReactionPlane = -1.; - Float_t bSign = 0.; - - // get the event (for generator level: MCEvent()) - AliVEvent* eventMain = NULL; - if(gAnalysisLevel == "MC") { - eventMain = dynamic_cast(MCEvent()); - } - else{ - eventMain = dynamic_cast(InputEvent()); - // for HBT like cuts need magnetic field sign - bSign = (eventMain->GetMagneticField() > 0) ? 1 : -1; - } - if(!eventMain) { - AliError("eventMain not available"); - return; - } - - // PID Response task active? - if(fUsePID || fElectronRejection) { - fPIDResponse = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetPIDResponse(); - if (!fPIDResponse) AliFatal("This Task needs the PID response attached to the inputHandler"); - } - - // check event cuts and fill event histograms - if((lMultiplicityVar = IsEventAccepted(eventMain)) < 0){ - return; - } - // get the reaction plane - if(fEventClass != "Multiplicity") { - gReactionPlane = GetEventPlane(eventMain); - fHistEventPlane->Fill(gReactionPlane,lMultiplicityVar); - if(gReactionPlane < 0){ - return; - } - } - - // get the accepted tracks in main event - TObjArray *tracksMain = GetAcceptedTracks(eventMain,lMultiplicityVar,gReactionPlane); - gNumberOfAcceptedTracks = tracksMain->GetEntriesFast(); - - //multiplicity cut (used in pp) - fHistNumberOfAcceptedTracks->Fill(gNumberOfAcceptedTracks,lMultiplicityVar); - - // store charges of all accepted tracks,shuffle and reassign(two extra loops) - TObjArray* tracksShuffled = NULL; - if(fRunShuffling){ - tracksShuffled = GetShuffledTracks(tracksMain,lMultiplicityVar); - } - - // Event mixing - if (fRunMixing) - { - // 1. First get an event pool corresponding in mult (cent) and - // zvertex to the current event. Once initialized, the pool - // should contain nMix (reduced) events. This routine does not - // pre-scan the chain. The first several events of every chain - // will be skipped until the needed pools are filled to the - // specified depth. If the pool categories are not too rare, this - // should not be a problem. If they are rare, you could lose` - // statistics. - - // 2. Collect the whole pool's content of tracks into one TObjArray - // (bgTracks), which is effectively a single background super-event. - - // 3. The reduced and bgTracks arrays must both be passed into - // FillCorrelations(). Also nMix should be passed in, so a weight - // of 1./nMix can be applied. - - AliEventPool* pool = fPoolMgr->GetEventPool(lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane); - - if (!pool){ - AliFatal(Form("No pool found for centrality = %f, zVtx = %f, psi = %f", lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane)); - } - else{ - - //pool->SetDebug(1); - - if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5){ - - - Int_t nMix = pool->GetCurrentNEvents(); - //cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl; - - //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2); - //((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool()); - //if (pool->IsReady()) - //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3); - - // Fill mixed-event histos here - for (Int_t jMix=0; jMixGetEvent(jMix); - fMixedBalance->CalculateBalance(gReactionPlane,tracksMain,tracksMixed,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); - } - } - - // Update the Event pool - pool->UpdatePool(tracksMain); - //pool->PrintInfo(); - - }//pool NULL check - }//run mixing - - // calculate balance function - fBalance->CalculateBalance(gReactionPlane,tracksMain,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); - - // calculate shuffled balance function - if(fRunShuffling && tracksShuffled != NULL) { - fShuffledBalance->CalculateBalance(gReactionPlane,tracksShuffled,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); - } -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::IsEventAccepted(AliVEvent *event){ - // Checks the Event cuts - // Fills Event statistics histograms - - Bool_t isSelectedMain = kTRUE; - Float_t gRefMultiplicity = -1.; - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - - AliMCEvent *mcevent = dynamic_cast(event); - - fHistEventStats->Fill(1,gRefMultiplicity); //all events - - // check first event in chunk (is not needed for new reconstructions) - if(fCheckFirstEventInChunk){ - AliAnalysisUtils ut; - if(ut.IsFirstEventInChunk(event)) - return -1.; - fHistEventStats->Fill(6,gRefMultiplicity); - } - // check for pile-up event - if(fCheckPileUp){ - AliAnalysisUtils ut; - ut.SetUseMVPlpSelection(kTRUE); - ut.SetUseOutOfBunchPileUp(kTRUE); - if(ut.IsPileUpEvent(event)) - return -1.; - fHistEventStats->Fill(7,gRefMultiplicity); - } - - // Event trigger bits - fHistTriggerStats->Fill(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()); - if(fUseOfflineTrigger) - isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); - - if(isSelectedMain) { - fHistEventStats->Fill(2,gRefMultiplicity); //triggered events - - // Event Vertex MC - if(gAnalysisLevel == "MC") { - if(!event) { - AliError("mcEvent not available"); - return 0x0; - } - - if(mcevent){ - AliGenEventHeader *header = dynamic_cast(mcevent->GenEventHeader()); - if(header){ - TArrayF gVertexArray; - header->PrimaryVertex(gVertexArray); - //Printf("Vertex: %lf (x) - %lf (y) - %lf (z)", - //gVertexArray.At(0), - //gVertexArray.At(1), - //gVertexArray.At(2)); - fHistEventStats->Fill(3,gRefMultiplicity); //events with a proper vertex - if(TMath::Abs(gVertexArray.At(0)) < fVxMax) { - if(TMath::Abs(gVertexArray.At(1)) < fVyMax) { - if(TMath::Abs(gVertexArray.At(2)) < fVzMax) { - fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events - - // get the reference multiplicty or centrality - gRefMultiplicity = GetRefMultiOrCentrality(event); - - fHistVx->Fill(gVertexArray.At(0)); - fHistVy->Fill(gVertexArray.At(1)); - fHistVz->Fill(gVertexArray.At(2),gRefMultiplicity); - - // take only events inside centrality class - if(fUseCentrality) { - if((fImpactParameterMin < gRefMultiplicity) && (fImpactParameterMax > gRefMultiplicity)){ - fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality - return gRefMultiplicity; - }//centrality class - } - // take events only within the same multiplicity class - else if(fUseMultiplicity) { - if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) { - fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity - return gRefMultiplicity; - } - }//multiplicity range - }//Vz cut - }//Vy cut - }//Vx cut - }//header - }//MC event object - }//MC - - // Event Vertex AOD, ESD, ESDMC - else{ - const AliVVertex *vertex = event->GetPrimaryVertex(); - - if(vertex) { - Double32_t fCov[6]; - vertex->GetCovarianceMatrix(fCov); - if(vertex->GetNContributors() > 0) { - if(fCov[5] != 0) { - fHistEventStats->Fill(3,gRefMultiplicity); //proper vertex - if(TMath::Abs(vertex->GetX()) < fVxMax) { - if(TMath::Abs(vertex->GetY()) < fVyMax) { - if(TMath::Abs(vertex->GetZ()) < fVzMax) { - fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events - - // get the reference multiplicty or centrality - gRefMultiplicity = GetRefMultiOrCentrality(event); - - fHistVx->Fill(vertex->GetX()); - fHistVy->Fill(vertex->GetY()); - fHistVz->Fill(vertex->GetZ(),gRefMultiplicity); - - // take only events inside centrality class - if(fUseCentrality) { - if((gRefMultiplicity > fCentralityPercentileMin) && (gRefMultiplicity < fCentralityPercentileMax)){ - - // centrality weighting (optional for 2011 if central and semicentral triggers are used) - if (fCentralityWeights && !AcceptEventCentralityWeight(gRefMultiplicity)){ - AliInfo(Form("Rejecting event because of centrality weighting: %f", gRefMultiplicity)); - return -1; - } - - fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality - return gRefMultiplicity; - }//centrality class - } - // take events only within the same multiplicity class - else if(fUseMultiplicity) { - //if(fDebugLevel) - //Printf("N(min): %.0f, N(max): %.0f - N(ref): %.0f",fNumberOfAcceptedTracksMin, - //fNumberOfAcceptedTracksMax,gRefMultiplicity); - - if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) { - fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity - return gRefMultiplicity; - } - }//multiplicity range - }//Vz cut - }//Vy cut - }//Vx cut - }//proper vertex resolution - }//proper number of contributors - }//vertex object valid - }//triggered event - }//AOD,ESD,ESDMC - - // in all other cases return -1 (event not accepted) - return -1; -} - - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetRefMultiOrCentrality(AliVEvent *event){ - // Checks the Event cuts - // Fills Event statistics histograms - - Float_t gCentrality = -1.; - Double_t gMultiplicity = -1.; - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - - - // calculate centrality always (not only in centrality mode) - if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ) { //centrality in AOD header //++++++++++++++ - AliAODHeader *header = (AliAODHeader*) event->GetHeader(); - if(header){ - gCentrality = header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); - - // QA for centrality estimators - fHistCentStats->Fill(0.,header->GetCentralityP()->GetCentralityPercentile("V0M")); - fHistCentStats->Fill(1.,header->GetCentralityP()->GetCentralityPercentile("V0A")); - fHistCentStats->Fill(2.,header->GetCentralityP()->GetCentralityPercentile("V0C")); - fHistCentStats->Fill(3.,header->GetCentralityP()->GetCentralityPercentile("FMD")); - fHistCentStats->Fill(4.,header->GetCentralityP()->GetCentralityPercentile("TRK")); - fHistCentStats->Fill(5.,header->GetCentralityP()->GetCentralityPercentile("TKL")); - fHistCentStats->Fill(6.,header->GetCentralityP()->GetCentralityPercentile("CL0")); - fHistCentStats->Fill(7.,header->GetCentralityP()->GetCentralityPercentile("CL1")); - fHistCentStats->Fill(8.,header->GetCentralityP()->GetCentralityPercentile("ZNA")); - fHistCentStats->Fill(9.,header->GetCentralityP()->GetCentralityPercentile("ZPA")); - fHistCentStats->Fill(10.,header->GetCentralityP()->GetCentralityPercentile("V0MvsFMD")); - fHistCentStats->Fill(11.,header->GetCentralityP()->GetCentralityPercentile("TKLvsV0M")); - fHistCentStats->Fill(12.,header->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC")); - - // Centrality estimator USED ++++++++++++++++++++++++++++++ - fHistCentStatsUsed->Fill(0.,header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data())); - - // centrality QA (V0M) - fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C()); - - // centrality QA (reference tracks) - fHistRefTracks->Fill(0.,header->GetRefMultiplicity()); - fHistRefTracks->Fill(1.,header->GetRefMultiplicityPos()); - fHistRefTracks->Fill(2.,header->GetRefMultiplicityNeg()); - fHistRefTracks->Fill(3.,header->GetTPConlyRefMultiplicity()); - fHistRefTracks->Fill(4.,header->GetNumberOfITSClusters(0)); - fHistRefTracks->Fill(5.,header->GetNumberOfITSClusters(1)); - fHistRefTracks->Fill(6.,header->GetNumberOfITSClusters(2)); - fHistRefTracks->Fill(7.,header->GetNumberOfITSClusters(3)); - fHistRefTracks->Fill(8.,header->GetNumberOfITSClusters(4)); - - }//AOD header - }//AOD - - else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){ // centrality class for ESDs or MC-ESDs - AliCentrality *centrality = event->GetCentrality(); - gCentrality = centrality->GetCentralityPercentile(fCentralityEstimator.Data()); - - // QA for centrality estimators - fHistCentStats->Fill(0.,centrality->GetCentralityPercentile("V0M")); - fHistCentStats->Fill(1.,centrality->GetCentralityPercentile("V0A")); - fHistCentStats->Fill(2.,centrality->GetCentralityPercentile("V0C")); - fHistCentStats->Fill(3.,centrality->GetCentralityPercentile("FMD")); - fHistCentStats->Fill(4.,centrality->GetCentralityPercentile("TRK")); - fHistCentStats->Fill(5.,centrality->GetCentralityPercentile("TKL")); - fHistCentStats->Fill(6.,centrality->GetCentralityPercentile("CL0")); - fHistCentStats->Fill(7.,centrality->GetCentralityPercentile("CL1")); - fHistCentStats->Fill(8.,centrality->GetCentralityPercentile("ZNA")); - fHistCentStats->Fill(9.,centrality->GetCentralityPercentile("ZPA")); - fHistCentStats->Fill(10.,centrality->GetCentralityPercentile("V0MvsFMD")); - fHistCentStats->Fill(11.,centrality->GetCentralityPercentile("TKLvsV0M")); - fHistCentStats->Fill(12.,centrality->GetCentralityPercentile("ZEMvsZDC")); - - // Centrality estimator USED ++++++++++++++++++++++++++++++ - fHistCentStatsUsed->Fill(0.,centrality->GetCentralityPercentile(fCentralityEstimator.Data())); - - // centrality QA (V0M) - fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C()); - }//ESD - - else if(gAnalysisLevel == "MC"){ - Double_t gImpactParameter = 0.; - AliMCEvent *gMCEvent = dynamic_cast(event); - if(gMCEvent){ - AliCollisionGeometry* headerH = dynamic_cast(gMCEvent->GenEventHeader()); - if(headerH){ - gImpactParameter = headerH->ImpactParameter(); - gCentrality = gImpactParameter; - }//MC header - }//MC event cast - }//MC - - else{ - gCentrality = -1.; - } - - // calculate reference multiplicity always (not only in multiplicity mode) - if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){ - AliESDEvent* gESDEvent = dynamic_cast(event); - if(gESDEvent){ - gMultiplicity = fESDtrackCuts->GetReferenceMultiplicity(gESDEvent, AliESDtrackCuts::kTrackletsITSTPC,0.5); - fHistMultiplicity->Fill(gMultiplicity); - }//AliESDevent cast - }//ESD mode - - else if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ){ - AliAODHeader *header = (AliAODHeader*) event->GetHeader(); - if ((fMultiplicityEstimator == "V0M")|| - (fMultiplicityEstimator == "V0A")|| - (fMultiplicityEstimator == "V0C") || - (fMultiplicityEstimator == "TPC")) { - gMultiplicity = GetReferenceMultiplicityFromAOD(event); - if(fDebugLevel) Printf("Reference multiplicity (calculated): %.0f",gMultiplicity); - } - else { - if(header) - gMultiplicity = header->GetRefMultiplicity(); - if(fDebugLevel) Printf("Reference multiplicity (AOD header): %.0f",gMultiplicity); - } - fHistMultiplicity->Fill(gMultiplicity); - }//AOD mode - else if(gAnalysisLevel == "MC") { - AliMCEvent* gMCEvent = dynamic_cast(event); - //Calculating the multiplicity as the number of charged primaries - //within \pm 0.8 in eta and pT > 0.1 GeV/c - for(Int_t iParticle = 0; iParticle < gMCEvent->GetNumberOfPrimaries(); iParticle++) { - AliMCParticle* track = dynamic_cast(gMCEvent->GetTrack(iParticle)); - if (!track) { - AliError(Form("Could not receive particle %d", iParticle)); - continue; - } - - //exclude non stable particles - if(!(gMCEvent->IsPhysicalPrimary(iParticle))) continue; - - //++++++++++++++++ - if (fMultiplicityEstimator == "V0M") { - if((track->Eta() > 5.1 || track->Eta() < 2.8)&&(track->Eta() < -3.7 || track->Eta() > -1.7)) - continue;} - else if (fMultiplicityEstimator == "V0A") { - if(track->Eta() > 5.1 || track->Eta() < 2.8) continue;} - else if (fMultiplicityEstimator == "V0C") { - if(track->Eta() > -1.7 || track->Eta() < -3.7) continue;} - else if (fMultiplicityEstimator == "TPC") { - if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue; - if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue; - } - else{ - if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue; - if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue; - } - //++++++++++++++++ - - if(track->Charge() == 0) continue; - - gMultiplicity += 1; - }//loop over primaries - fHistMultiplicity->Fill(gMultiplicity); - }//MC mode - else{ - gMultiplicity = -1; - } - - - // decide what should be returned only here - Double_t lReturnVal = -100; - if(fEventClass=="Multiplicity"){ - lReturnVal = gMultiplicity; - }else if(fEventClass=="Centrality"){ - lReturnVal = gCentrality; - } - return lReturnVal; -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event){ - //Function that returns the reference multiplicity from AODs (data or reco MC) - //Different ref. mult. implemented: V0M, V0A, V0C, TPC - Double_t gRefMultiplicity = 0., gRefMultiplicityTPC = 0.; - Double_t gRefMultiplicityVZERO = 0., gRefMultiplicityVZEROA = 0., gRefMultiplicityVZEROC = 0.; - - AliAODHeader *header = dynamic_cast(event->GetHeader()); - if(!header) { - Printf("ERROR: AOD header not available"); - return -999; - } - Int_t gRunNumber = header->GetRunNumber(); - - // Loop over tracks in event - for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { - AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); - if (!aodTrack) { - AliError(Form("Could not receive track %d", iTracks)); - continue; - } - - // AOD track cuts - if(!aodTrack->TestFilterBit(fnAODtrackCutBit)) continue; - - if(aodTrack->Charge() == 0) continue; - // Kinematics cuts from ESD track cuts - if( aodTrack->Pt() < fPtMin || aodTrack->Pt() > fPtMax) continue; - if( aodTrack->Eta() < fEtaMin || aodTrack->Eta() > fEtaMax) continue; - - //=================PID (so far only for electron rejection)==========================// - if(fElectronRejection) { - // get the electron nsigma - Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); - - // check only for given momentum range - if( aodTrack->Pt() > fElectronRejectionMinPt && aodTrack->Pt() < fElectronRejectionMaxPt ){ - //look only at electron nsigma - if(!fElectronOnlyRejection) { - //Make the decision based on the n-sigma of electrons - if(nSigma < fElectronRejectionNSigma) continue; - } - else { - Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); - Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); - Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); - - //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) - if(nSigma < fElectronRejectionNSigma - && nSigmaPions > fElectronRejectionNSigma - && nSigmaKaons > fElectronRejectionNSigma - && nSigmaProtons > fElectronRejectionNSigma ) continue; - } - } - }//electron rejection - - gRefMultiplicityTPC += 1.0; - }// track loop - - //VZERO segmentation in two detectors (0-31: VZERO-C, 32-63: VZERO-A) - for(Int_t iChannel = 0; iChannel < 64; iChannel++) { - fHistVZEROSignal->Fill(iChannel,event->GetVZEROEqMultiplicity(iChannel)); - - if(iChannel < 32) - gRefMultiplicityVZEROC += event->GetVZEROEqMultiplicity(iChannel); - else if(iChannel >= 32) - gRefMultiplicityVZEROA += event->GetVZEROEqMultiplicity(iChannel); - }//loop over PMTs - - //Equalization of gain - Double_t gFactorA = GetEqualizationFactor(gRunNumber,"A"); - if(gFactorA != 0) - gRefMultiplicityVZEROA /= gFactorA; - Double_t gFactorC = GetEqualizationFactor(gRunNumber,"C"); - if(gFactorC != 0) - gRefMultiplicityVZEROC /= gFactorC; - if((gFactorA != 0)&&(gFactorC != 0)) - gRefMultiplicityVZERO = (gRefMultiplicityVZEROA/gFactorA)+(gRefMultiplicityVZEROC/gFactorC); - - if(fDebugLevel) - Printf("VZERO multiplicity: %.0f - TPC multiplicity: %.0f",gRefMultiplicityVZERO,gRefMultiplicityTPC); - - fHistTPCvsVZEROMultiplicity->Fill(gRefMultiplicityVZERO,gRefMultiplicityTPC); - - if(fMultiplicityEstimator == "TPC") - gRefMultiplicity = gRefMultiplicityTPC; - else if(fMultiplicityEstimator == "V0M") - gRefMultiplicity = gRefMultiplicityVZERO; - else if(fMultiplicityEstimator == "V0A") - gRefMultiplicity = gRefMultiplicityVZEROA; - else if(fMultiplicityEstimator == "V0C") - gRefMultiplicity = gRefMultiplicityVZEROC; - - return gRefMultiplicity; -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetEventPlane(AliVEvent *event){ - // Get the event plane - - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - - Float_t gVZEROEventPlane = -10.; - Float_t gReactionPlane = -10.; - Double_t qxTot = 0.0, qyTot = 0.0; - - //MC: from reaction plane - if(gAnalysisLevel == "MC"){ - if(!event) { - AliError("mcEvent not available"); - return 0x0; - } - - AliMCEvent *gMCEvent = dynamic_cast(event); - if(gMCEvent){ - AliCollisionGeometry* headerH = dynamic_cast(gMCEvent->GenEventHeader()); - if (headerH) { - gReactionPlane = headerH->ReactionPlaneAngle(); - //gReactionPlane *= TMath::RadToDeg(); - }//MC header - }//MC event cast - }//MC - - // AOD,ESD,ESDMC: from VZERO Event Plane - else{ - - AliEventplane *ep = event->GetEventplane(); - if(ep){ - gVZEROEventPlane = ep->CalculateVZEROEventPlane(event,10,2,qxTot,qyTot); - if(gVZEROEventPlane < 0.) gVZEROEventPlane += TMath::Pi(); - //gReactionPlane = gVZEROEventPlane*TMath::RadToDeg(); - gReactionPlane = gVZEROEventPlane; - } - }//AOD,ESD,ESDMC - - return gReactionPlane; -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetTrackbyTrackCorrectionMatrix( Double_t vEta, - Double_t vPhi, - Double_t vPt, - Short_t vCharge, - Double_t gCentrality) { - // -- Get efficiency correction of particle dependent on (eta, phi, pt, charge, centrality) - - Double_t correction = 1.; - Int_t binEta = 0, binPt = 0, binPhi = 0; - - //Printf("EtaMAx: %lf - EtaMin: %lf - EtaBin: %lf", fEtaMaxForCorrections,fEtaMinForCorrections,fEtaBinForCorrections); - if(fEtaBinForCorrections != 0) { - Double_t widthEta = (fEtaMaxForCorrections - fEtaMinForCorrections)/fEtaBinForCorrections; - if(fEtaMaxForCorrections != fEtaMinForCorrections) - binEta = (Int_t)((vEta-fEtaMinForCorrections)/widthEta)+1; - } - - if(fPtBinForCorrections != 0) { - Double_t widthPt = (fPtMaxForCorrections - fPtMinForCorrections)/fPtBinForCorrections; - if(fPtMaxForCorrections != fPtMinForCorrections) - binPt = (Int_t)((vPt-fPtMinForCorrections)/widthPt) + 1; - } - - if(fPhiBinForCorrections != 0) { - Double_t widthPhi = (fPhiMaxForCorrections - fPhiMinForCorrections)/fPhiBinForCorrections; - if(fPhiMaxForCorrections != fPhiMinForCorrections) - binPhi = (Int_t)((vPhi-fPhiMinForCorrections)/widthPhi)+ 1; - } - - Int_t gCentralityInt = -1; - for (Int_t i=0; i no correction - if(gCentralityInt < 0){ - correction = 1.; - } - else{ - - //Printf("//=============CENTRALITY=============// %d:",gCentralityInt); - - if(fHistCorrectionPlus[gCentralityInt]){ - if (vCharge > 0) { - correction = fHistCorrectionPlus[gCentralityInt]->GetBinContent(fHistCorrectionPlus[gCentralityInt]->GetBin(binEta, binPt, binPhi)); - //Printf("CORRECTIONplus: %.2f | Centrality %d",correction,gCentralityInt); - } - if (vCharge < 0) { - correction = fHistCorrectionMinus[gCentralityInt]->GetBinContent(fHistCorrectionMinus[gCentralityInt]->GetBin(binEta, binPt, binPhi)); - //Printf("CORRECTIONminus: %.2f | Centrality %d",correction,gCentralityInt); - } - } - else { - correction = 1.; - } - }//centrality in array - - if (correction == 0.) { - AliError(Form("Should not happen : bin content = 0. >> eta: %.2f | phi : %.2f | pt : %.2f | cent %d",vEta, vPhi, vPt, gCentralityInt)); - correction = 1.; - } - - return correction; -} - -//________________________________________________________________________ -TObjArray* AliAnalysisTaskBFPsi::GetAcceptedTracks(AliVEvent *event, Double_t gCentrality, Double_t gReactionPlane){ - // Returns TObjArray with tracks after all track cuts (only for AOD!) - // Fills QA histograms - - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - - //output TObjArray holding all good tracks - TObjArray* tracksAccepted = new TObjArray; - tracksAccepted->SetOwner(kTRUE); - - Short_t vCharge; - Double_t vEta; - Double_t vY; - Double_t vPhi; - Double_t vPt; - - - if(gAnalysisLevel == "AOD") { // handling of TPC only tracks different in AOD and ESD - // Loop over tracks in event - - for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { - AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); - if (!aodTrack) { - AliError(Form("Could not receive track %d", iTracks)); - continue; - } - - // AOD track cuts - - // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C - // take only TPC only tracks - //fHistTrackStats->Fill(aodTrack->GetFilterMap()); - for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){ - fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<TestFilterBit(fnAODtrackCutBit)) continue; - - - // additional check on kPrimary flag - if(fCheckPrimaryFlagAOD){ - if(aodTrack->GetType() != AliAODTrack::kPrimary) - continue; - } - - - vCharge = aodTrack->Charge(); - vEta = aodTrack->Eta(); - vY = aodTrack->Y(); - vPhi = aodTrack->Phi();// * TMath::RadToDeg(); - vPt = aodTrack->Pt(); - - //===========================PID (so far only for electron rejection)===============================// - if(fElectronRejection) { - - // get the electron nsigma - Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); - - //Fill QA before the PID - fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); - //end of QA-before pid - - // check only for given momentum range - if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){ - - //look only at electron nsigma - if(!fElectronOnlyRejection){ - - //Make the decision based on the n-sigma of electrons - if(nSigma < fElectronRejectionNSigma) continue; - } - else{ - - Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); - Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); - Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); - - //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) - if(nSigma < fElectronRejectionNSigma - && nSigmaPions > fElectronRejectionNSigma - && nSigmaKaons > fElectronRejectionNSigma - && nSigmaProtons > fElectronRejectionNSigma ) continue; - } - } - - //Fill QA after the PID - fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); - - } - //===========================end of PID (so far only for electron rejection)===============================// - - //+++++++++++++++++++++++++++++// - //===========================PID===============================// - if(fUsePID) { - Double_t prob[AliPID::kSPECIES]={0.}; - Double_t probTPC[AliPID::kSPECIES]={0.}; - Double_t probTOF[AliPID::kSPECIES]={0.}; - Double_t probTPCTOF[AliPID::kSPECIES]={0.}; - - Double_t nSigma = 0.; - Double_t nSigmaTPC = 0.; //++++ - Double_t nSigmaTOF = 0.; //++++ - Double_t nSigmaTPCTOF = 0.; //++++ - UInt_t detUsedTPC = 0; - UInt_t detUsedTOF = 0; - UInt_t detUsedTPCTOF = 0; - - nSigmaTPC = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)fParticleOfInterest)); - nSigmaTOF = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(aodTrack,(AliPID::EParticleType)fParticleOfInterest)); - nSigmaTPCTOF = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF); - - //Decide what detector configuration we want to use - switch(fPidDetectorConfig) { - case kTPCpid: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC); - nSigma = nSigmaTPC; - detUsedTPC = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPC); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTPC[iSpecies]; - break; - case kTOFpid: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF); - nSigma = nSigmaTOF; - detUsedTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTOF); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTOF[iSpecies]; - break; - case kTPCTOF: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC); - nSigma = nSigmaTPCTOF; - detUsedTPCTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPCTOF); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTPCTOF[iSpecies]; - break; - default: - break; - }//end switch: define detector mask - - //Filling the PID QA - Double_t tofTime = -999., length = 999., tof = -999.; - Double_t c = TMath::C()*1.E-9;// m/ns - Double_t beta = -999.; - if ( (aodTrack->IsOn(AliAODTrack::kTOFin)) && - (aodTrack->IsOn(AliAODTrack::kTIME)) ) { - tofTime = aodTrack->GetTOFsignal();//in ps - length = aodTrack->GetIntegratedLength(); - tof = tofTime*1E-3; // ns - - if (tof <= 0) { - //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n"); - continue; - } - if (length <= 0){ - //printf("WARNING: track with negative length found!Skipping this track for PID checks\n"); - continue; - } - - length = length*0.01; // in meters - tof = tof*c; - beta = length/tof; - - fHistBetavsPTOFbeforePID ->Fill(aodTrack->P()*aodTrack->Charge(),beta); - fHistProbTOFvsPtbeforePID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]); - fHistNSigmaTOFvsPtbeforePID ->Fill(aodTrack->Pt(),nSigmaTOF); - }//TOF signal - - fHistdEdxVsPTPCbeforePID -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistProbTPCvsPtbeforePID -> Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]); - fHistNSigmaTPCvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPC); - - fHistProbTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]); - - //combined TPC&TOF - fHistBetaVsdEdXbeforePID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++ - fHistNSigmaTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPCTOF); - Printf("NSIGMA: %lf - nSigmaTOF: %lf - nSigmaTPC: %lf - nSigmaTPCTOF: %lf",nSigma,nSigmaTOF,nSigmaTPC,nSigmaTPCTOF); - - //end of QA-before pid - - if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) { - //Make the decision based on the n-sigma - if(fUsePIDnSigma) { - if(nSigma > fPIDNSigma) continue; - - fHistNSigmaTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTOF); - fHistNSigmaTPCvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPC); - fHistNSigmaTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPCTOF); - } - //Make the decision based on the bayesian - else if(fUsePIDPropabilities) { - if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue; - if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue; - - fHistProbTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]); - fHistProbTPCvsPtafterPID ->Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]); - fHistProbTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]); - - } - - //Fill QA after the PID - fHistBetavsPTOFafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),beta); - fHistdEdxVsPTPCafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistBetaVsdEdXafterPID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++ - } - } - //===========================PID===============================// - //+++++++++++++++++++++++++++++// - - - Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on) - Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) - - - // Kinematics cuts from ESD track cuts - if( vPt < fPtMin || vPt > fPtMax) continue; - if( vEta < fEtaMin || vEta > fEtaMax) continue; - - // Extra DCA cuts (for systematic studies [!= -1]) - if( fDCAxyCut != -1 && fDCAzCut != -1){ - if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){ - continue; // 2D cut - } - } - - // Extra TPC cuts (for systematic studies [!= -1]) - if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){ - continue; - } - if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){ - continue; - } - - // fill QA histograms - fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls()); - fHistDCA->Fill(dcaZ,dcaXY); - fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality); - fHistPt->Fill(vPt,gCentrality); - fHistEta->Fill(vEta,gCentrality); - fHistRapidity->Fill(vY,gCentrality); - if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); - else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); - fHistPhi->Fill(vPhi,gCentrality); - if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); - else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); - - //=======================================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - - // add the track to the TObjArray - tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); - }//track loop - }// AOD analysis - - //============================================================================================================== - else if(gAnalysisLevel == "MCAOD") { - - AliMCEvent* mcEvent = MCEvent(); - if (!mcEvent) { - AliError("ERROR: Could not retrieve MC event"); - } - else{ - - for (Int_t iTracks = 0; iTracks < mcEvent->GetNumberOfTracks(); iTracks++) { - AliAODMCParticle *aodTrack = (AliAODMCParticle*) mcEvent->GetTrack(iTracks); - if (!aodTrack) { - AliError(Form("ERROR: Could not receive track %d (mc loop)", iTracks)); - continue; - } - - if(!aodTrack->IsPhysicalPrimary()) continue; - - vCharge = aodTrack->Charge(); - vEta = aodTrack->Eta(); - vY = aodTrack->Y(); - vPhi = aodTrack->Phi();// * TMath::RadToDeg(); - vPt = aodTrack->Pt(); - - // Kinematics cuts from ESD track cuts - if( vPt < fPtMin || vPt > fPtMax) continue; - if( vEta < fEtaMin || vEta > fEtaMax) continue; - - // Remove neutral tracks - if( vCharge == 0 ) continue; - - //Exclude resonances - if(fExcludeResonancesInMC) { - - Bool_t kExcludeParticle = kFALSE; - Int_t gMotherIndex = aodTrack->GetMother(); - if(gMotherIndex != -1) { - AliAODMCParticle* motherTrack = dynamic_cast(mcEvent->GetTrack(gMotherIndex)); - if(motherTrack) { - Int_t pdgCodeOfMother = motherTrack->GetPdgCode(); - //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) { - //if(pdgCodeOfMother == 113) { - if(pdgCodeOfMother == 113 // rho0 - || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ - // || pdgCodeOfMother == 221 // eta - // || pdgCodeOfMother == 331 // eta' - // || pdgCodeOfMother == 223 // omega - // || pdgCodeOfMother == 333 // phi - || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 - // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* - // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* - || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda - || pdgCodeOfMother == 111 // pi0 Dalitz - || pdgCodeOfMother == 22 // photon - ) { - kExcludeParticle = kTRUE; - } - } - } - - //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi - if(kExcludeParticle) continue; - } - - //Exclude electrons with PDG - if(fExcludeElectronsInMC) { - - if(TMath::Abs(aodTrack->GetPdgCode()) == 11) continue; - - } - - // fill QA histograms - fHistPt->Fill(vPt,gCentrality); - fHistEta->Fill(vEta,gCentrality); - fHistRapidity->Fill(vY,gCentrality); - if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); - else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); - fHistPhi->Fill(vPhi,gCentrality); - if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); - else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); - - //=======================================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - - // add the track to the TObjArray - tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); - }//aodTracks - }//MC event - }//MCAOD - //============================================================================================================== - - //============================================================================================================== - else if(gAnalysisLevel == "MCAODrec") { - - /* fAOD = dynamic_cast(InputEvent()); - if (!fAOD) { - printf("ERROR: fAOD not available\n"); - return; - }*/ - - fArrayMC = dynamic_cast(event->FindListObject(AliAODMCParticle::StdBranchName())); - if (!fArrayMC) { - AliError("No array of MC particles found !!!"); - } - - AliMCEvent* mcEvent = MCEvent(); - if (!mcEvent) { - AliError("ERROR: Could not retrieve MC event"); - return tracksAccepted; - } - - for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { - AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); - if (!aodTrack) { - AliError(Form("Could not receive track %d", iTracks)); - continue; - } - - for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){ - fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<TestFilterBit(fnAODtrackCutBit)) continue; - - vCharge = aodTrack->Charge(); - vEta = aodTrack->Eta(); - vY = aodTrack->Y(); - vPhi = aodTrack->Phi();// * TMath::RadToDeg(); - vPt = aodTrack->Pt(); - - //===========================use MC information for Kinematics===============================// - if(fUseMCforKinematics){ - - Int_t label = TMath::Abs(aodTrack->GetLabel()); - AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); - - if(AODmcTrack){ - vCharge = AODmcTrack->Charge(); - vEta = AODmcTrack->Eta(); - vY = AODmcTrack->Y(); - vPhi = AODmcTrack->Phi();// * TMath::RadToDeg(); - vPt = AODmcTrack->Pt(); - } - else{ - AliDebug(1, "no MC particle for this track"); - continue; - } - } - //===========================end of use MC information for Kinematics========================// - - - //===========================PID (so far only for electron rejection)===============================// - if(fElectronRejection) { - - // get the electron nsigma - Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); - - //Fill QA before the PID - fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); - //end of QA-before pid - - // check only for given momentum range - if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){ - - //look only at electron nsigma - if(!fElectronOnlyRejection){ - - //Make the decision based on the n-sigma of electrons - if(nSigma < fElectronRejectionNSigma) continue; - } - else{ - - Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); - Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); - Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); - - //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) - if(nSigma < fElectronRejectionNSigma - && nSigmaPions > fElectronRejectionNSigma - && nSigmaKaons > fElectronRejectionNSigma - && nSigmaProtons > fElectronRejectionNSigma ) continue; - } - } - - //Fill QA after the PID - fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); - fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); - - } - //===========================end of PID (so far only for electron rejection)===============================// - - Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on) - Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) - - // Kinematics cuts from ESD track cuts - if( vPt < fPtMin || vPt > fPtMax) continue; - if( vEta < fEtaMin || vEta > fEtaMax) continue; - - // Extra DCA cuts (for systematic studies [!= -1]) - if( fDCAxyCut != -1 && fDCAzCut != -1){ - if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){ - continue; // 2D cut - } - } - - // Extra TPC cuts (for systematic studies [!= -1]) - if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){ - continue; - } - if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){ - continue; - } - - //Exclude resonances - if(fExcludeResonancesInMC) { - - Bool_t kExcludeParticle = kFALSE; - - Int_t label = TMath::Abs(aodTrack->GetLabel()); - AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); - - if (AODmcTrack){ - //if (AODmcTrack->IsPhysicalPrimary()){ - - Int_t gMotherIndex = AODmcTrack->GetMother(); - if(gMotherIndex != -1) { - AliAODMCParticle* motherTrack = dynamic_cast(mcEvent->GetTrack(gMotherIndex)); - if(motherTrack) { - Int_t pdgCodeOfMother = motherTrack->GetPdgCode(); - if(pdgCodeOfMother == 113 // rho0 - || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ - // || pdgCodeOfMother == 221 // eta - // || pdgCodeOfMother == 331 // eta' - // || pdgCodeOfMother == 223 // omega - // || pdgCodeOfMother == 333 // phi - || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 - // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* - // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* - || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda - || pdgCodeOfMother == 111 // pi0 Dalitz - || pdgCodeOfMother == 22 // photon - ) { - kExcludeParticle = kTRUE; - } - } - } - } - //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi - if(kExcludeParticle) continue; - } - - //Exclude electrons with PDG - if(fExcludeElectronsInMC) { - - Int_t label = TMath::Abs(aodTrack->GetLabel()); - AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); - - if (AODmcTrack){ - if(TMath::Abs(AODmcTrack->GetPdgCode()) == 11) continue; - } - } - - // fill QA histograms - fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls()); - fHistDCA->Fill(dcaZ,dcaXY); - fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality); - fHistPt->Fill(vPt,gCentrality); - fHistEta->Fill(vEta,gCentrality); - fHistRapidity->Fill(vY,gCentrality); - if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); - else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); - fHistPhi->Fill(vPhi,gCentrality); - if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); - else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); - - //=======================================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - - // add the track to the TObjArray - tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); - }//track loop - }//MCAODrec - //============================================================================================================== - - else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD") { // handling of TPC only tracks different in AOD and ESD - - AliESDtrack *trackTPC = NULL; - AliMCParticle *mcTrack = NULL; - - AliMCEvent* mcEvent = NULL; - - // for MC ESDs use also MC information - if(gAnalysisLevel == "MCESD"){ - mcEvent = MCEvent(); - if (!mcEvent) { - AliError("mcEvent not available"); - return tracksAccepted; - } - } - - // Loop over tracks in event - for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { - AliESDtrack* track = dynamic_cast(event->GetTrack(iTracks)); - if (!track) { - AliError(Form("Could not receive track %d", iTracks)); - continue; - } - - // for MC ESDs use also MC information --> MC track not used further??? - if(gAnalysisLevel == "MCESD"){ - Int_t label = TMath::Abs(track->GetLabel()); - if(label > mcEvent->GetNumberOfTracks()) continue; - if(label > mcEvent->GetNumberOfPrimaries()) continue; - - mcTrack = dynamic_cast(mcEvent->GetTrack(label)); - if(!mcTrack) continue; - } - - // take only TPC only tracks - trackTPC = new AliESDtrack(); - if(!track->FillTPCOnlyTrack(*trackTPC)) continue; - - //ESD track cuts - if(fESDtrackCuts) - if(!fESDtrackCuts->AcceptTrack(trackTPC)) continue; - - // fill QA histograms - Float_t b[2]; - Float_t bCov[3]; - trackTPC->GetImpactParameters(b,bCov); - if (bCov[0]<=0 || bCov[2]<=0) { - AliDebug(1, "Estimated b resolution lower or equal zero!"); - bCov[0]=0; bCov[2]=0; - } - - Int_t nClustersTPC = -1; - nClustersTPC = trackTPC->GetTPCNclsIter1(); // TPC standalone - //nClustersTPC = track->GetTPCclusters(0); // global track - Float_t chi2PerClusterTPC = -1; - if (nClustersTPC!=0) { - chi2PerClusterTPC = trackTPC->GetTPCchi2Iter1()/Float_t(nClustersTPC); // TPC standalone - //chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC); // global track - } - - //===========================PID===============================// - if(fUsePID) { - Double_t prob[AliPID::kSPECIES]={0.}; - Double_t probTPC[AliPID::kSPECIES]={0.}; - Double_t probTOF[AliPID::kSPECIES]={0.}; - Double_t probTPCTOF[AliPID::kSPECIES]={0.}; - - Double_t nSigma = 0.; - UInt_t detUsedTPC = 0; - UInt_t detUsedTOF = 0; - UInt_t detUsedTPCTOF = 0; - - //Decide what detector configuration we want to use - switch(fPidDetectorConfig) { - case kTPCpid: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC); - nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest)); - detUsedTPC = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPC); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTPC[iSpecies]; - break; - case kTOFpid: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF); - nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest)); - detUsedTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTOF); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTOF[iSpecies]; - break; - case kTPCTOF: - fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC); - detUsedTPCTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPCTOF); - for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) - prob[iSpecies] = probTPCTOF[iSpecies]; - break; - default: - break; - }//end switch: define detector mask - - //Filling the PID QA - Double_t tofTime = -999., length = 999., tof = -999.; - Double_t c = TMath::C()*1.E-9;// m/ns - Double_t beta = -999.; - Double_t nSigmaTOFForParticleOfInterest = -999.; - if ( (track->IsOn(AliESDtrack::kTOFin)) && - (track->IsOn(AliESDtrack::kTIME)) ) { - tofTime = track->GetTOFsignal();//in ps - length = track->GetIntegratedLength(); - tof = tofTime*1E-3; // ns - - if (tof <= 0) { - //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n"); - continue; - } - if (length <= 0){ - //printf("WARNING: track with negative length found!Skipping this track for PID checks\n"); - continue; - } - - length = length*0.01; // in meters - tof = tof*c; - beta = length/tof; - - nSigmaTOFForParticleOfInterest = fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest); - fHistBetavsPTOFbeforePID ->Fill(track->P()*track->Charge(),beta); - fHistProbTOFvsPtbeforePID ->Fill(track->Pt(),probTOF[fParticleOfInterest]); - fHistNSigmaTOFvsPtbeforePID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest); - }//TOF signal - - - Double_t nSigmaTPCForParticleOfInterest = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest); - fHistdEdxVsPTPCbeforePID -> Fill(track->P()*track->Charge(),track->GetTPCsignal()); - fHistProbTPCvsPtbeforePID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); - fHistNSigmaTPCvsPtbeforePID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); - fHistProbTPCTOFvsPtbeforePID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]); - //end of QA-before pid - - if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) { - //Make the decision based on the n-sigma - if(fUsePIDnSigma) { - if(nSigma > fPIDNSigma) continue;} - - //Make the decision based on the bayesian - else if(fUsePIDPropabilities) { - if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue; - if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue; - } - - //Fill QA after the PID - fHistBetavsPTOFafterPID ->Fill(track->P()*track->Charge(),beta); - fHistProbTOFvsPtafterPID ->Fill(track->Pt(),probTOF[fParticleOfInterest]); - fHistNSigmaTOFvsPtafterPID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest); - - fHistdEdxVsPTPCafterPID -> Fill(track->P()*track->Charge(),track->GetTPCsignal()); - fHistProbTPCvsPtafterPID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); - fHistProbTPCTOFvsPtafterPID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]); - fHistNSigmaTPCvsPtafterPID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); - } - } - //===========================PID===============================// - vCharge = trackTPC->Charge(); - vY = trackTPC->Y(); - vEta = trackTPC->Eta(); - vPhi = trackTPC->Phi();// * TMath::RadToDeg(); - vPt = trackTPC->Pt(); - fHistClus->Fill(trackTPC->GetITSclusters(0),nClustersTPC); - fHistDCA->Fill(b[1],b[0]); - fHistChi2->Fill(chi2PerClusterTPC,gCentrality); - fHistPt->Fill(vPt,gCentrality); - fHistEta->Fill(vEta,gCentrality); - fHistPhi->Fill(vPhi,gCentrality); - if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); - else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); - fHistRapidity->Fill(vY,gCentrality); - if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); - else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); - - //=======================================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - - // add the track to the TObjArray - tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); - - delete trackTPC; - }//track loop - }// ESD analysis - - else if(gAnalysisLevel == "MC"){ - if(!event) { - AliError("mcEvent not available"); - return 0x0; - } - - AliMCEvent *gMCEvent = dynamic_cast(event); - if(gMCEvent) { - // Loop over tracks in event - for (Int_t iTracks = 0; iTracks < gMCEvent->GetNumberOfPrimaries(); iTracks++) { - AliMCParticle* track = dynamic_cast(gMCEvent->GetTrack(iTracks)); - if (!track) { - AliError(Form("Could not receive particle %d", iTracks)); - continue; - } - - //exclude non stable particles - if(!(gMCEvent->IsPhysicalPrimary(iTracks))) continue; - - vCharge = track->Charge(); - vEta = track->Eta(); - vPt = track->Pt(); - vY = track->Y(); - - if( vPt < fPtMin || vPt > fPtMax) - continue; - if (!fUsePID) { - if( vEta < fEtaMin || vEta > fEtaMax) continue; - } - else if (fUsePID){ - if( vY < fEtaMin || vY > fEtaMax) continue; - } - - // Remove neutral tracks - if( vCharge == 0 ) continue; - - //analyze one set of particles - if(fUseMCPdgCode) { - TParticle *particle = track->Particle(); - if(!particle) continue; - - Int_t gPdgCode = particle->GetPdgCode(); - if(TMath::Abs(fPDGCodeToBeAnalyzed) != TMath::Abs(gPdgCode)) - continue; - } - - //Use the acceptance parameterization - if(fAcceptanceParameterization) { - Double_t gRandomNumber = gRandom->Rndm(); - if(gRandomNumber > fAcceptanceParameterization->Eval(track->Pt())) - continue; - } - - //Exclude resonances - if(fExcludeResonancesInMC) { - TParticle *particle = track->Particle(); - if(!particle) continue; - - Bool_t kExcludeParticle = kFALSE; - Int_t gMotherIndex = particle->GetFirstMother(); - if(gMotherIndex != -1) { - AliMCParticle* motherTrack = dynamic_cast(event->GetTrack(gMotherIndex)); - if(motherTrack) { - TParticle *motherParticle = motherTrack->Particle(); - if(motherParticle) { - Int_t pdgCodeOfMother = motherParticle->GetPdgCode(); - //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) { - if(pdgCodeOfMother == 113 // rho0 - || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ - // || pdgCodeOfMother == 221 // eta - // || pdgCodeOfMother == 331 // eta' - // || pdgCodeOfMother == 223 // omega - // || pdgCodeOfMother == 333 // phi - || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 - // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* - // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* - || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda - || pdgCodeOfMother == 111 // pi0 Dalitz - ) { - kExcludeParticle = kTRUE; - } - } - } - } - - //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi - if(kExcludeParticle) continue; - } - - //Exclude electrons with PDG - if(fExcludeElectronsInMC) { - - TParticle *particle = track->Particle(); - - if (particle){ - if(TMath::Abs(particle->GetPdgCode()) == 11) continue; - } - } - - vPhi = track->Phi(); - //Printf("phi (before): %lf",vPhi); - - fHistPt->Fill(vPt,gCentrality); - fHistEta->Fill(vEta,gCentrality); - fHistPhi->Fill(vPhi,gCentrality); - if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); - else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); - //fHistPhi->Fill(vPhi*TMath::RadToDeg(),gCentrality); - fHistRapidity->Fill(vY,gCentrality); - //if(vCharge > 0) fHistPhiPos->Fill(vPhi*TMath::RadToDeg(),gCentrality); - //else if(vCharge < 0) fHistPhiNeg->Fill(vPhi*TMath::RadToDeg(),gCentrality); - if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); - else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); - - //Flow after burner - if(fUseFlowAfterBurner) { - Double_t precisionPhi = 0.001; - Int_t maxNumberOfIterations = 100; - - Double_t phi0 = vPhi; - Double_t gV2 = fDifferentialV2->Eval(vPt); - - for (Int_t j = 0; j < maxNumberOfIterations; j++) { - Double_t phiprev = vPhi; - Double_t fl = vPhi - phi0 + gV2*TMath::Sin(2.*(vPhi - gReactionPlane*TMath::DegToRad())); - Double_t fp = 1.0 + 2.0*gV2*TMath::Cos(2.*(vPhi - gReactionPlane*TMath::DegToRad())); - vPhi -= fl/fp; - if (TMath::AreEqualAbs(phiprev,vPhi,precisionPhi)) break; - } - //Printf("phi (after): %lf\n",vPhi); - Double_t vDeltaphiBefore = phi0 - gReactionPlane*TMath::DegToRad(); - if(vDeltaphiBefore < 0) vDeltaphiBefore += 2*TMath::Pi(); - fHistPhiBefore->Fill(vDeltaphiBefore,gCentrality); - - Double_t vDeltaphiAfter = vPhi - gReactionPlane*TMath::DegToRad(); - if(vDeltaphiAfter < 0) vDeltaphiAfter += 2*TMath::Pi(); - fHistPhiAfter->Fill(vDeltaphiAfter,gCentrality); - - } - - //vPhi *= TMath::RadToDeg(); - - //=======================================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - - tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); - } //track loop - }//MC event object - }//MC - - return tracksAccepted; -} - -//________________________________________________________________________ -TObjArray* AliAnalysisTaskBFPsi::GetShuffledTracks(TObjArray *tracks, Double_t gCentrality){ - // Clones TObjArray and returns it with tracks after shuffling the charges - - TObjArray* tracksShuffled = new TObjArray; - tracksShuffled->SetOwner(kTRUE); - - vector *chargeVector = new vector; //original charge of accepted tracks - - for (Int_t i=0; iGetEntriesFast(); i++) - { - AliVParticle* track = (AliVParticle*) tracks->At(i); - chargeVector->push_back(track->Charge()); - } - - random_shuffle(chargeVector->begin(), chargeVector->end()); - - for(Int_t i = 0; i < tracks->GetEntriesFast(); i++){ - AliVParticle* track = (AliVParticle*) tracks->At(i); - //==============================correction - Double_t correction = GetTrackbyTrackCorrectionMatrix(track->Eta(), track->Phi(),track->Pt(), chargeVector->at(i), gCentrality); - //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); - tracksShuffled->Add(new AliBFBasicParticle(track->Eta(), track->Phi(), track->Pt(),chargeVector->at(i), correction)); - } - - delete chargeVector; - - return tracksShuffled; -} - -//________________________________________________________________________ -void AliAnalysisTaskBFPsi::SetVZEROCalibrationFile(const char* filename, - const char* lhcPeriod) { - //Function to setup the VZERO gain equalization - //============Get the equilization map============// - TFile *calibrationFile = TFile::Open(filename); - if((!calibrationFile)||(!calibrationFile->IsOpen())) { - Printf("No calibration file found!!!"); - return; - } - - TList *list = dynamic_cast(calibrationFile->Get(lhcPeriod)); - if(!list) { - Printf("Calibration TList not found!!!"); - return; - } - - fHistVZEROAGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROAGainEqualizationMap")); - if(!fHistVZEROAGainEqualizationMap) { - Printf("VZERO-A calibration object not found!!!"); - return; - } - fHistVZEROCGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROCGainEqualizationMap")); - if(!fHistVZEROCGainEqualizationMap) { - Printf("VZERO-C calibration object not found!!!"); - return; - } - - fHistVZEROChannelGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROChannelGainEqualizationMap")); - if(!fHistVZEROChannelGainEqualizationMap) { - Printf("VZERO channel calibration object not found!!!"); - return; - } -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetChannelEqualizationFactor(Int_t run, - Int_t channel) { - // - if(!fHistVZEROAGainEqualizationMap) return 1.0; - - for(Int_t iBinX = 1; iBinX <= fHistVZEROChannelGainEqualizationMap->GetNbinsX(); iBinX++) { - Int_t gRunNumber = atoi(fHistVZEROChannelGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX)); - if(gRunNumber == run) - return fHistVZEROChannelGainEqualizationMap->GetBinContent(iBinX,channel+1); - } - - return 1.0; -} - -//________________________________________________________________________ -Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run, - const char* side) { - // - if(!fHistVZEROAGainEqualizationMap) return 1.0; - - TString gVZEROSide = side; - for(Int_t iBinX = 1; iBinX < fHistVZEROAGainEqualizationMap->GetNbinsX(); iBinX++) { - Int_t gRunNumber = atoi(fHistVZEROAGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX)); - //cout<<"Looking for run "<GetBinContent(iBinX); - else if(gVZEROSide == "C") - return fHistVZEROCGainEqualizationMap->GetBinContent(iBinX); - } - } - - return 1.0; -} - -//____________________________________________________________________ -Bool_t AliAnalysisTaskBFPsi::AcceptEventCentralityWeight(Double_t centrality) -{ - // copied from AliAnalysisTaskPhiCorrelations - // - // rejects "randomly" events such that the centrality gets flat - // uses fCentralityWeights histogram - - // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening - - Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality)); - Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.); - - Bool_t result = kFALSE; - if (centralityDigits < weight) - result = kTRUE; - - AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result)); - - return result; -} - -//________________________________________________________________________ -void AliAnalysisTaskBFPsi::FinishTaskOutput(){ - //Printf("END BF"); - - if (!fBalance) { - AliError("fBalance not available"); - return; - } - if(fRunShuffling) { - if (!fShuffledBalance) { - AliError("fShuffledBalance not available"); - return; - } - } - -} - -//________________________________________________________________________ -void AliAnalysisTaskBFPsi::Terminate(Option_t *) { - // Draw result to the screen - // Called once at the end of the query - - // not implemented ... - -} - +#include "TChain.h" +#include "TList.h" +#include "TCanvas.h" +#include "TLorentzVector.h" +#include "TGraphErrors.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TH3F.h" +#include "TH2D.h" +#include "TH3D.h" +#include "TArrayF.h" +#include "TF1.h" +#include "TRandom.h" + +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" + +#include "AliESDVertex.h" +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" +#include "AliAODEvent.h" +#include "AliAODTrack.h" +#include "AliAODInputHandler.h" +#include "AliAODMCParticle.h" +#include "AliCollisionGeometry.h" +#include "AliGenEventHeader.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" +#include "AliStack.h" +#include "AliESDtrackCuts.h" +#include "AliEventplane.h" +#include "AliTHn.h" +#include "AliLog.h" +#include "AliAnalysisUtils.h" + +#include "AliEventPoolManager.h" + +#include "AliPID.h" +#include "AliPIDResponse.h" +#include "AliPIDCombined.h" + +#include "AliAnalysisTaskBFPsi.h" +#include "AliBalancePsi.h" +#include "AliAnalysisTaskTriggeredBF.h" + + +// Analysis task for the BF vs Psi code +// Authors: Panos.Christakoglou@nikhef.nl + +using std::cout; +using std::endl; + +ClassImp(AliAnalysisTaskBFPsi) + +//________________________________________________________________________ +AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name) +: AliAnalysisTaskSE(name), + fDebugLevel(kFALSE), + fArrayMC(0), //+++++++++++++ + fBalance(0), + fRunShuffling(kFALSE), + fShuffledBalance(0), + fRunMixing(kFALSE), + fRunMixingEventPlane(kFALSE), + fMixingTracks(50000), + fMixedBalance(0), + fPoolMgr(0), + fList(0), + fListBF(0), + fListBFS(0), + fListBFM(0), + fHistListPIDQA(0), + fHistEventStats(0), + fHistCentStats(0), + fHistCentStatsUsed(0), + fHistTriggerStats(0), + fHistTrackStats(0), + fHistVx(0), + fHistVy(0), + fHistVz(0), + fHistTPCvsVZEROMultiplicity(0), + fHistVZEROSignal(0), + fHistEventPlane(0), + fHistClus(0), + fHistDCA(0), + fHistChi2(0), + fHistPt(0), + fHistEta(0), + fHistRapidity(0), + fHistPhi(0), + fHistEtaPhiPos(0), + fHistEtaPhiNeg(0), + fHistPhiBefore(0), + fHistPhiAfter(0), + fHistPhiPos(0), + fHistPhiNeg(0), + fHistV0M(0), + fHistRefTracks(0), + fHistdEdxVsPTPCbeforePID(NULL), + fHistBetavsPTOFbeforePID(NULL), + fHistProbTPCvsPtbeforePID(NULL), + fHistProbTOFvsPtbeforePID(NULL), + fHistProbTPCTOFvsPtbeforePID(NULL), + fHistNSigmaTPCvsPtbeforePID(NULL), + fHistNSigmaTOFvsPtbeforePID(NULL), + fHistBetaVsdEdXbeforePID(NULL), //+++++++ + fHistNSigmaTPCTOFvsPtbeforePID(NULL), //++++++ + fHistdEdxVsPTPCafterPID(NULL), + fHistBetavsPTOFafterPID(NULL), + fHistProbTPCvsPtafterPID(NULL), + fHistProbTOFvsPtafterPID(NULL), + fHistProbTPCTOFvsPtafterPID(NULL), + fHistNSigmaTPCvsPtafterPID(NULL), + fHistNSigmaTOFvsPtafterPID(NULL), + fHistBetaVsdEdXafterPID(NULL), //+++++++ + fHistNSigmaTPCTOFvsPtafterPID(NULL), //+++++++ + fHistdEdxVsPTPCbeforePIDelectron(NULL), //+++++++ + fHistNSigmaTPCvsPtbeforePIDelectron(NULL), //+++++++ + fHistdEdxVsPTPCafterPIDelectron(NULL), //+++++++ + fHistNSigmaTPCvsPtafterPIDelectron(NULL), //+++++++ + fCentralityArrayBinsForCorrections(kCENTRALITY), + fCentralityWeights(0x0), + fPIDResponse(0x0), + fPIDCombined(0x0), + fParticleOfInterest(kPion), + fPidDetectorConfig(kTPCTOF), + fUsePID(kFALSE), + fUsePIDnSigma(kTRUE), + fUsePIDPropabilities(kFALSE), + fPIDNSigma(3.), + fMinAcceptedPIDProbability(0.8), + fElectronRejection(kFALSE), + fElectronOnlyRejection(kFALSE), + fElectronRejectionNSigma(-1.), + fElectronRejectionMinPt(0.), + fElectronRejectionMaxPt(1000.), + fESDtrackCuts(0), + fCentralityEstimator("V0M"), + fUseCentrality(kFALSE), + fCentralityPercentileMin(0.), + fCentralityPercentileMax(5.), + fImpactParameterMin(0.), + fImpactParameterMax(20.), + fMultiplicityEstimator("V0A"), + fUseMultiplicity(kFALSE), + fNumberOfAcceptedTracksMin(0), + fNumberOfAcceptedTracksMax(10000), + fHistNumberOfAcceptedTracks(0), + fHistMultiplicity(0), + fUseOfflineTrigger(kFALSE), + fCheckFirstEventInChunk(kFALSE), + fCheckPileUp(kFALSE), + fCheckPrimaryFlagAOD(kFALSE), + fUseMCforKinematics(kFALSE), + fVxMax(0.3), + fVyMax(0.3), + fVzMax(10.), + fnAODtrackCutBit(128), + fPtMin(0.3), + fPtMax(1.5), + fPtMinForCorrections(0.3),//=================================correction + fPtMaxForCorrections(1.5),//=================================correction + fPtBinForCorrections(36), //=================================correction + fEtaMin(-0.8), + fEtaMax(-0.8), + fEtaMinForCorrections(-0.8),//=================================correction + fEtaMaxForCorrections(0.8),//=================================correction + fEtaBinForCorrections(16), //=================================correction + fPhiMin(0.), + fPhiMax(360.), + fPhiMinForCorrections(0.),//=================================correction + fPhiMaxForCorrections(360.),//=================================correction + fPhiBinForCorrections(100), //=================================correction + fDCAxyCut(-1), + fDCAzCut(-1), + fTPCchi2Cut(-1), + fNClustersTPCCut(-1), + fAcceptanceParameterization(0), + fDifferentialV2(0), + fUseFlowAfterBurner(kFALSE), + fExcludeResonancesInMC(kFALSE), + fExcludeElectronsInMC(kFALSE), + fUseMCPdgCode(kFALSE), + fPDGCodeToBeAnalyzed(-1), + fEventClass("EventPlane"), + fCustomBinning(""), + fHistVZEROAGainEqualizationMap(0), + fHistVZEROCGainEqualizationMap(0), + fHistVZEROChannelGainEqualizationMap(0) { + // Constructor + // Define input and output slots here + // Input slot #0 works with a TChain + + //======================================================correction + for (Int_t i=0; iSetAnalysisLevel("ESD"); + fBalance->SetEventClass(fEventClass); + //fBalance->SetNumberOfBins(-1,16); + //fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.); + } + if(fRunShuffling) { + if(!fShuffledBalance) { + fShuffledBalance = new AliBalancePsi(); + fShuffledBalance->SetAnalysisLevel("ESD"); + fShuffledBalance->SetEventClass(fEventClass); + //fShuffledBalance->SetNumberOfBins(-1,16); + //fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.); + } + } + if(fRunMixing) { + if(!fMixedBalance) { + fMixedBalance = new AliBalancePsi(); + fMixedBalance->SetAnalysisLevel("ESD"); + fMixedBalance->SetEventClass(fEventClass); + } + } + + //QA list + fList = new TList(); + fList->SetName("listQA"); + fList->SetOwner(); + + //Balance Function list + fListBF = new TList(); + fListBF->SetName("listBF"); + fListBF->SetOwner(); + + if(fRunShuffling) { + fListBFS = new TList(); + fListBFS->SetName("listBFShuffled"); + fListBFS->SetOwner(); + } + + if(fRunMixing) { + fListBFM = new TList(); + fListBFM->SetName("listTriggeredBFMixed"); + fListBFM->SetOwner(); + } + + //PID QA list + if(fUsePID || fElectronRejection) { + fHistListPIDQA = new TList(); + fHistListPIDQA->SetName("listQAPID"); + fHistListPIDQA->SetOwner(); + } + + //Event stats. + TString gCutName[7] = {"Total","Offline trigger", + "Vertex","Analyzed","sel. Centrality","Not1stEvInChunk","No Pile-Up"}; + fHistEventStats = new TH2F("fHistEventStats", + "Event statistics;;Centrality percentile;N_{events}", + 7,0.5,7.5,220,-5,105); + for(Int_t i = 1; i <= 7; i++) + fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); + fList->Add(fHistEventStats); + + TString gCentName[13] = {"V0M","V0A","V0C","FMD","TRK","TKL","CL0","CL1","ZNA","ZPA","V0MvsFMD","TKLvsV0M","ZEMvsZDC"}; + fHistCentStats = new TH2F("fHistCentStats", + "Centrality statistics;;Cent percentile", + 13,-0.5,12.5,220,-5,105); + for(Int_t i = 1; i <= 13; i++){ + fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); + //fHistCentStatsUsed->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); + } + fList->Add(fHistCentStats); + + fHistCentStatsUsed = new TH2F("fHistCentStatsUsed","Centrality statistics;;Cent percentile", 1,-0.5,0.5,220,-5,105); + fHistCentStatsUsed->GetXaxis()->SetBinLabel(1,fCentralityEstimator.Data()); + fList->Add(fHistCentStatsUsed); + + fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",1025,0,1025); + fList->Add(fHistTriggerStats); + + fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",16,0,16); + fList->Add(fHistTrackStats); + + fHistNumberOfAcceptedTracks = new TH2F("fHistNumberOfAcceptedTracks",";N_{acc.};Centrality percentile;Entries",4001,-0.5,4000.5,220,-5,105); + fList->Add(fHistNumberOfAcceptedTracks); + + fHistMultiplicity = new TH1F("fHistMultiplicity",";N_{ch.};Entries",30001,-0.5,30000.5); + fList->Add(fHistMultiplicity); + + // Vertex distributions + fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5); + fList->Add(fHistVx); + fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5); + fList->Add(fHistVy); + fHistVz = new TH2F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Centrality percentile;Entries",100,-20.,20.,220,-5,105); + fList->Add(fHistVz); + + //TPC vs VZERO multiplicity + fHistTPCvsVZEROMultiplicity = new TH2F("fHistTPCvsVZEROMultiplicity","VZERO vs TPC multiplicity",10001,-0.5,10000.5,4001,-0.5,4000.5); + if(fMultiplicityEstimator == "V0A") + fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-A multiplicity (a.u.)"); + else if(fMultiplicityEstimator == "V0C") + fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-C multiplicity (a.u.)"); + else + fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO multiplicity (a.u.)"); + fList->Add(fHistTPCvsVZEROMultiplicity); + + fHistVZEROSignal = new TH2F("fHistVZEROSignal","VZERO signal vs VZERO channel;VZERO channel; Signal (a.u.)",64,0.5,64.5,3001,-0.5,30000.5); + fList->Add(fHistVZEROSignal); + + //Event plane + fHistEventPlane = new TH2F("fHistEventPlane",";#Psi_{2} [deg.];Centrality percentile;Counts",100,0,360.,220,-5,105); + fList->Add(fHistEventPlane); + + // QA histograms + fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200); + fList->Add(fHistClus); + fHistChi2 = new TH2F("fHistChi2","Chi2/NDF distribution;#chi^{2}/ndf;Centrality percentile",200,0,10,220,-5,105); + fList->Add(fHistChi2); + fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5); + fList->Add(fHistDCA); + fHistPt = new TH2F("fHistPt","p_{T} distribution;p_{T} (GeV/c);Centrality percentile",200,0,10,220,-5,105); + fList->Add(fHistPt); + fHistEta = new TH2F("fHistEta","#eta distribution;#eta;Centrality percentile",200,-2,2,220,-5,105); + fList->Add(fHistEta); + fHistRapidity = new TH2F("fHistRapidity","y distribution;y;Centrality percentile",200,-2,2,220,-5,105); + fList->Add(fHistRapidity); + fHistPhi = new TH2F("fHistPhi","#phi distribution;#phi (rad);Centrality percentile",200,0.0,2.*TMath::Pi(),220,-5,105); + fList->Add(fHistPhi); + fHistEtaPhiPos = new TH3F("fHistEtaPhiPos","#eta-#phi distribution (+);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105); + fList->Add(fHistEtaPhiPos); + fHistEtaPhiNeg = new TH3F("fHistEtaPhiNeg","#eta-#phi distribution (-);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105); + fList->Add(fHistEtaPhiNeg); + fHistPhiBefore = new TH2F("fHistPhiBefore","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); + fList->Add(fHistPhiBefore); + fHistPhiAfter = new TH2F("fHistPhiAfter","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); + fList->Add(fHistPhiAfter); + fHistPhiPos = new TH2F("fHistPhiPos","#phi distribution for positive particles;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105); + fList->Add(fHistPhiPos); + fHistPhiNeg = new TH2F("fHistPhiNeg","#phi distribution for negative particles;#phi;Centrality percentile",200,0.,2.*TMath::Pi(),220,-5,105); + fList->Add(fHistPhiNeg); + fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000); + fList->Add(fHistV0M); + TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"}; + fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000); + for(Int_t i = 1; i <= 6; i++) + fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data()); + fList->Add(fHistRefTracks); + + // Balance function histograms + // Initialize histograms if not done yet (including the custom binning) + if(!fBalance->GetHistNp()){ + AliInfo("Histograms not yet initialized! --> Will be done now"); + fBalance->SetCustomBinning(fCustomBinning); + fBalance->InitHistograms(); + } + + if(fRunShuffling) { + if(!fShuffledBalance->GetHistNp()) { + AliInfo("Histograms (shuffling) not yet initialized! --> Will be done now"); + fShuffledBalance->SetCustomBinning(fCustomBinning); + fShuffledBalance->InitHistograms(); + } + } + + if(fRunMixing) { + if(!fMixedBalance->GetHistNp()) { + AliInfo("Histograms (mixing) not yet initialized! --> Will be done now"); + fMixedBalance->SetCustomBinning(fCustomBinning); + fMixedBalance->InitHistograms(); + } + } + + // QA histograms for different cuts + fList->Add(fBalance->GetQAHistHBTbefore()); + fList->Add(fBalance->GetQAHistHBTafter()); + fList->Add(fBalance->GetQAHistConversionbefore()); + fList->Add(fBalance->GetQAHistConversionafter()); + fList->Add(fBalance->GetQAHistPsiMinusPhi()); + fList->Add(fBalance->GetQAHistResonancesBefore()); + fList->Add(fBalance->GetQAHistResonancesRho()); + fList->Add(fBalance->GetQAHistResonancesK0()); + fList->Add(fBalance->GetQAHistResonancesLambda()); + fList->Add(fBalance->GetQAHistQbefore()); + fList->Add(fBalance->GetQAHistQafter()); + + //for(Int_t a = 0; a < ANALYSIS_TYPES; a++){ + fListBF->Add(fBalance->GetHistNp()); + fListBF->Add(fBalance->GetHistNn()); + fListBF->Add(fBalance->GetHistNpn()); + fListBF->Add(fBalance->GetHistNnn()); + fListBF->Add(fBalance->GetHistNpp()); + fListBF->Add(fBalance->GetHistNnp()); + + if(fRunShuffling) { + fListBFS->Add(fShuffledBalance->GetHistNp()); + fListBFS->Add(fShuffledBalance->GetHistNn()); + fListBFS->Add(fShuffledBalance->GetHistNpn()); + fListBFS->Add(fShuffledBalance->GetHistNnn()); + fListBFS->Add(fShuffledBalance->GetHistNpp()); + fListBFS->Add(fShuffledBalance->GetHistNnp()); + } + + if(fRunMixing) { + fListBFM->Add(fMixedBalance->GetHistNp()); + fListBFM->Add(fMixedBalance->GetHistNn()); + fListBFM->Add(fMixedBalance->GetHistNpn()); + fListBFM->Add(fMixedBalance->GetHistNnn()); + fListBFM->Add(fMixedBalance->GetHistNpp()); + fListBFM->Add(fMixedBalance->GetHistNnp()); + } + //} + + + // Event Mixing + if(fRunMixing){ + Int_t trackDepth = fMixingTracks; + Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager + + // centrality bins + Double_t* centbins = NULL; + Int_t nCentralityBins; + if(fBalance->IsUseVertexBinning()){ + centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centralityVertex", nCentralityBins); + } + else{ + centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centrality", nCentralityBins); + } + + // multiplicity bins + Double_t* multbins = NULL; + Int_t nMultiplicityBins; + multbins = fBalance->GetBinning(fBalance->GetBinningString(), "multiplicity", nMultiplicityBins); + + // Zvtx bins + Double_t* vtxbins = NULL; + Int_t nVertexBins; + if(fBalance->IsUseVertexBinning()){ + vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertexVertex", nVertexBins); + } + else{ + vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertex", nVertexBins); + } + + // Event plane angle (Psi) bins + Double_t* psibins = NULL; + Int_t nPsiBins; + psibins = fBalance->GetBinning(fBalance->GetBinningString(), "eventPlane", nPsiBins); + + + // run the event mixing also in bins of event plane (statistics!) + if(fRunMixingEventPlane){ + if(fEventClass=="Multiplicity"){ + if(multbins && vtxbins && psibins){ + fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins, nPsiBins, psibins); + } + } + else{ + if(centbins && vtxbins && psibins){ + fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins, nPsiBins, psibins); + } + } + } + else{ + if(fEventClass=="Multiplicity"){ + if(multbins && vtxbins){ + fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins); + } + } + else{ + if(centbins && vtxbins){ + fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins); + } + } + } + + // check pool manager + if(!fPoolMgr){ + AliError("Event Mixing required, but Pool Manager not initialized..."); + return; + } + } + + if(fESDtrackCuts) fList->Add(fESDtrackCuts); + + //====================PID========================// + if(fUsePID) { + fPIDCombined = new AliPIDCombined(); + fPIDCombined->SetDefaultTPCPriors(); + + fHistdEdxVsPTPCbeforePID = new TH2D ("dEdxVsPTPCbefore","dEdxVsPTPCbefore", 1000, -10.0, 10.0, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePID); + + fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetavsPTOFbeforePID); + + fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID); + + fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID); + + fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID); + + fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID); + + fHistNSigmaTOFvsPtbeforePID = new TH2D ("NSigmaTOFvsPtbefore","NSigmaTOFvsPtbefore", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTOFvsPtbeforePID); + + fHistBetaVsdEdXbeforePID = new TH2D ("BetaVsdEdXbefore","BetaVsdEdXbefore", 1000, 0., 1000, 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetaVsdEdXbeforePID); //++++++++ + + fHistNSigmaTPCTOFvsPtbeforePID = new TH2D ("NSigmaTPCTOFvsPtbefore","NSigmaTPCTOFvsPtbefore", 1000, -10., 10., 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtbeforePID); //++++++++ + + fHistdEdxVsPTPCafterPID = new TH2D ("dEdxVsPTPCafter","dEdxVsPTPCafter", 1000, -10, 10, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCafterPID); + + fHistBetavsPTOFafterPID = new TH2D ("BetavsPTOFafter","BetavsPTOFafter", 1000, -10, 10, 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetavsPTOFafterPID); + + fHistProbTPCvsPtafterPID = new TH2D ("ProbTPCvsPtafter","ProbTPCvsPtafter", 1000, -10, 10, 1000, 0, 2); + fHistListPIDQA->Add(fHistProbTPCvsPtafterPID); + + fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000, -10, 10, 1000, 0, 2); + fHistListPIDQA->Add(fHistProbTOFvsPtafterPID); + + fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID); + + fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID); + + fHistNSigmaTOFvsPtafterPID = new TH2D ("NSigmaTOFvsPtafter","NSigmaTOFvsPtafter", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTOFvsPtafterPID); + + fHistBetaVsdEdXafterPID = new TH2D ("BetaVsdEdXafter","BetaVsdEdXafter", 1000, 0., 1000, 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetaVsdEdXafterPID); //++++++++ + + fHistNSigmaTPCTOFvsPtafterPID = new TH2D ("NSigmaTPCTOFvsPtafter","NSigmaTPCTOFvsPtafter", 1000, -10., 10., 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtafterPID); //++++++++ + } + + // for electron rejection only TPC nsigma histograms + if(fElectronRejection) { + + fHistdEdxVsPTPCbeforePIDelectron = new TH2D ("dEdxVsPTPCbeforeelectron","dEdxVsPTPCbeforeelectron", 1000, -10.0, 10.0, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePIDelectron); + + fHistNSigmaTPCvsPtbeforePIDelectron = new TH2D ("NSigmaTPCvsPtbeforeelectron","NSigmaTPCvsPtbeforeelectron", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePIDelectron); + + fHistdEdxVsPTPCafterPIDelectron = new TH2D ("dEdxVsPTPCafterelectron","dEdxVsPTPCafterelectron", 1000, -10, 10, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCafterPIDelectron); + + fHistNSigmaTPCvsPtafterPIDelectron = new TH2D ("NSigmaTPCvsPtafterelectron","NSigmaTPCvsPtafterelectron", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPIDelectron); + } + //====================PID========================// + + // Post output data. + PostData(1, fList); + PostData(2, fListBF); + if(fRunShuffling) PostData(3, fListBFS); + if(fRunMixing) PostData(4, fListBFM); + if(fUsePID || fElectronRejection) PostData(5, fHistListPIDQA); //PID + + AliInfo("Finished setting up the Output"); + + TH1::AddDirectory(oldStatus); +} + + +//________________________________________________________________________ +void AliAnalysisTaskBFPsi::SetInputCorrection(TString filename, + Int_t nCentralityBins, + Double_t *centralityArrayForCorrections) { + //Open files that will be used for correction + fCentralityArrayBinsForCorrections = nCentralityBins; + for (Int_t i=0; i run without corrections + if(!filename.Contains(".root")) { + AliInfo(Form("No correction file specified (= %s) --> run without corrections",filename.Data())); + return; + } + + //Open the input file + TFile *f = TFile::Open(filename); + if(!f->IsOpen()) { + AliInfo(Form("File %s not found --> run without corrections",filename.Data())); + return; + } + + //TString listEffName = ""; + for (Int_t iCent = 0; iCent < fCentralityArrayBinsForCorrections-1; iCent++) { + //Printf("iCent %d:",iCent); + TString histoName = "fHistCorrectionPlus"; + histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1])); + fHistCorrectionPlus[iCent]= dynamic_cast(f->Get(histoName.Data())); + if(!fHistCorrectionPlus[iCent]) { + AliError(Form("fHist %s not found!!!",histoName.Data())); + return; + } + + histoName = "fHistCorrectionMinus"; + histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1])); + fHistCorrectionMinus[iCent] = dynamic_cast(f->Get(histoName.Data())); + if(!fHistCorrectionMinus[iCent]) { + AliError(Form("fHist %s not found!!!",histoName.Data())); + return; + } + }//loop over centralities: ONLY the PbPb case is covered + + if(fHistCorrectionPlus[0]){ + fEtaMinForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmin(); + fEtaMaxForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmax(); + fEtaBinForCorrections = fHistCorrectionPlus[0]->GetNbinsX(); + + fPtMinForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmin(); + fPtMaxForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmax(); + fPtBinForCorrections = fHistCorrectionPlus[0]->GetNbinsY(); + + fPhiMinForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmin(); + fPhiMaxForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmax(); + fPhiBinForCorrections = fHistCorrectionPlus[0]->GetNbinsZ(); + } +} + +//________________________________________________________________________ +void AliAnalysisTaskBFPsi::UserExec(Option_t *) { + // Main loop + // Called for each event + + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + Int_t gNumberOfAcceptedTracks = 0; + Double_t lMultiplicityVar = -999.; //-1 + Double_t gReactionPlane = -1.; + Float_t bSign = 0.; + + // get the event (for generator level: MCEvent()) + AliVEvent* eventMain = NULL; + if(gAnalysisLevel == "MC") { + eventMain = dynamic_cast(MCEvent()); + } + else{ + eventMain = dynamic_cast(InputEvent()); + // for HBT like cuts need magnetic field sign + bSign = (eventMain->GetMagneticField() > 0) ? 1 : -1; + } + if(!eventMain) { + AliError("eventMain not available"); + return; + } + + // PID Response task active? + if(fUsePID || fElectronRejection) { + fPIDResponse = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetPIDResponse(); + if (!fPIDResponse) AliFatal("This Task needs the PID response attached to the inputHandler"); + } + + // check event cuts and fill event histograms + if((lMultiplicityVar = IsEventAccepted(eventMain)) < 0){ + return; + } + // get the reaction plane + if(fEventClass != "Multiplicity") { + gReactionPlane = GetEventPlane(eventMain); + fHistEventPlane->Fill(gReactionPlane,lMultiplicityVar); + if(gReactionPlane < 0){ + return; + } + } + + // get the accepted tracks in main event + TObjArray *tracksMain = GetAcceptedTracks(eventMain,lMultiplicityVar,gReactionPlane); + gNumberOfAcceptedTracks = tracksMain->GetEntriesFast(); + + //multiplicity cut (used in pp) + fHistNumberOfAcceptedTracks->Fill(gNumberOfAcceptedTracks,lMultiplicityVar); + + // store charges of all accepted tracks,shuffle and reassign(two extra loops) + TObjArray* tracksShuffled = NULL; + if(fRunShuffling){ + tracksShuffled = GetShuffledTracks(tracksMain,lMultiplicityVar); + } + + // Event mixing + if (fRunMixing) + { + // 1. First get an event pool corresponding in mult (cent) and + // zvertex to the current event. Once initialized, the pool + // should contain nMix (reduced) events. This routine does not + // pre-scan the chain. The first several events of every chain + // will be skipped until the needed pools are filled to the + // specified depth. If the pool categories are not too rare, this + // should not be a problem. If they are rare, you could lose` + // statistics. + + // 2. Collect the whole pool's content of tracks into one TObjArray + // (bgTracks), which is effectively a single background super-event. + + // 3. The reduced and bgTracks arrays must both be passed into + // FillCorrelations(). Also nMix should be passed in, so a weight + // of 1./nMix can be applied. + + AliEventPool* pool = fPoolMgr->GetEventPool(lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane); + + if (!pool){ + AliFatal(Form("No pool found for centrality = %f, zVtx = %f, psi = %f", lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane)); + } + else{ + + //pool->SetDebug(1); + + if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5){ + + + Int_t nMix = pool->GetCurrentNEvents(); + //cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl; + + //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2); + //((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool()); + //if (pool->IsReady()) + //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3); + + // Fill mixed-event histos here + for (Int_t jMix=0; jMixGetEvent(jMix); + fMixedBalance->CalculateBalance(gReactionPlane,tracksMain,tracksMixed,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); + } + } + + // Update the Event pool + pool->UpdatePool(tracksMain); + //pool->PrintInfo(); + + }//pool NULL check + }//run mixing + + // calculate balance function + fBalance->CalculateBalance(gReactionPlane,tracksMain,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); + + // calculate shuffled balance function + if(fRunShuffling && tracksShuffled != NULL) { + fShuffledBalance->CalculateBalance(gReactionPlane,tracksShuffled,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ()); + } +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::IsEventAccepted(AliVEvent *event){ + // Checks the Event cuts + // Fills Event statistics histograms + + Bool_t isSelectedMain = kTRUE; + Float_t gRefMultiplicity = -1.; + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + + AliMCEvent *mcevent = dynamic_cast(event); + + fHistEventStats->Fill(1,gRefMultiplicity); //all events + + // check first event in chunk (is not needed for new reconstructions) + if(fCheckFirstEventInChunk){ + AliAnalysisUtils ut; + if(ut.IsFirstEventInChunk(event)) + return -1.; + fHistEventStats->Fill(6,gRefMultiplicity); + } + // check for pile-up event + if(fCheckPileUp){ + AliAnalysisUtils ut; + ut.SetUseMVPlpSelection(kTRUE); + ut.SetUseOutOfBunchPileUp(kTRUE); + if(ut.IsPileUpEvent(event)) + return -1.; + fHistEventStats->Fill(7,gRefMultiplicity); + } + + // Event trigger bits + fHistTriggerStats->Fill(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()); + if(fUseOfflineTrigger) + isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); + + if(isSelectedMain) { + fHistEventStats->Fill(2,gRefMultiplicity); //triggered events + + // Event Vertex MC + if(gAnalysisLevel == "MC") { + if(!event) { + AliError("mcEvent not available"); + return 0x0; + } + + if(mcevent){ + AliGenEventHeader *header = dynamic_cast(mcevent->GenEventHeader()); + if(header){ + TArrayF gVertexArray; + header->PrimaryVertex(gVertexArray); + //Printf("Vertex: %lf (x) - %lf (y) - %lf (z)", + //gVertexArray.At(0), + //gVertexArray.At(1), + //gVertexArray.At(2)); + fHistEventStats->Fill(3,gRefMultiplicity); //events with a proper vertex + if(TMath::Abs(gVertexArray.At(0)) < fVxMax) { + if(TMath::Abs(gVertexArray.At(1)) < fVyMax) { + if(TMath::Abs(gVertexArray.At(2)) < fVzMax) { + fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events + + // get the reference multiplicty or centrality + gRefMultiplicity = GetRefMultiOrCentrality(event); + + fHistVx->Fill(gVertexArray.At(0)); + fHistVy->Fill(gVertexArray.At(1)); + fHistVz->Fill(gVertexArray.At(2),gRefMultiplicity); + + // take only events inside centrality class + if(fUseCentrality) { + if((fImpactParameterMin < gRefMultiplicity) && (fImpactParameterMax > gRefMultiplicity)){ + fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality + return gRefMultiplicity; + }//centrality class + } + // take events only within the same multiplicity class + else if(fUseMultiplicity) { + if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) { + fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity + return gRefMultiplicity; + } + }//multiplicity range + }//Vz cut + }//Vy cut + }//Vx cut + }//header + }//MC event object + }//MC + + // Event Vertex AOD, ESD, ESDMC + else{ + const AliVVertex *vertex = event->GetPrimaryVertex(); + + if(vertex) { + Double32_t fCov[6]; + vertex->GetCovarianceMatrix(fCov); + if(vertex->GetNContributors() > 0) { + if(fCov[5] != 0) { + fHistEventStats->Fill(3,gRefMultiplicity); //proper vertex + if(TMath::Abs(vertex->GetX()) < fVxMax) { + if(TMath::Abs(vertex->GetY()) < fVyMax) { + if(TMath::Abs(vertex->GetZ()) < fVzMax) { + fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events + + // get the reference multiplicty or centrality + gRefMultiplicity = GetRefMultiOrCentrality(event); + + fHistVx->Fill(vertex->GetX()); + fHistVy->Fill(vertex->GetY()); + fHistVz->Fill(vertex->GetZ(),gRefMultiplicity); + + // take only events inside centrality class + if(fUseCentrality) { + if((gRefMultiplicity > fCentralityPercentileMin) && (gRefMultiplicity < fCentralityPercentileMax)){ + + // centrality weighting (optional for 2011 if central and semicentral triggers are used) + if (fCentralityWeights && !AcceptEventCentralityWeight(gRefMultiplicity)){ + AliInfo(Form("Rejecting event because of centrality weighting: %f", gRefMultiplicity)); + return -1; + } + + fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality + return gRefMultiplicity; + }//centrality class + } + // take events only within the same multiplicity class + else if(fUseMultiplicity) { + //if(fDebugLevel) + //Printf("N(min): %.0f, N(max): %.0f - N(ref): %.0f",fNumberOfAcceptedTracksMin, + //fNumberOfAcceptedTracksMax,gRefMultiplicity); + + if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) { + fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity + return gRefMultiplicity; + } + }//multiplicity range + }//Vz cut + }//Vy cut + }//Vx cut + }//proper vertex resolution + }//proper number of contributors + }//vertex object valid + }//triggered event + }//AOD,ESD,ESDMC + + // in all other cases return -1 (event not accepted) + return -1; +} + + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetRefMultiOrCentrality(AliVEvent *event){ + // Checks the Event cuts + // Fills Event statistics histograms + + Float_t gCentrality = -1.; + Double_t gMultiplicity = -1.; + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + + + // calculate centrality always (not only in centrality mode) + if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ) { //centrality in AOD header //++++++++++++++ + AliAODHeader *header = (AliAODHeader*) event->GetHeader(); + if(header){ + gCentrality = header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); + + // QA for centrality estimators + fHistCentStats->Fill(0.,header->GetCentralityP()->GetCentralityPercentile("V0M")); + fHistCentStats->Fill(1.,header->GetCentralityP()->GetCentralityPercentile("V0A")); + fHistCentStats->Fill(2.,header->GetCentralityP()->GetCentralityPercentile("V0C")); + fHistCentStats->Fill(3.,header->GetCentralityP()->GetCentralityPercentile("FMD")); + fHistCentStats->Fill(4.,header->GetCentralityP()->GetCentralityPercentile("TRK")); + fHistCentStats->Fill(5.,header->GetCentralityP()->GetCentralityPercentile("TKL")); + fHistCentStats->Fill(6.,header->GetCentralityP()->GetCentralityPercentile("CL0")); + fHistCentStats->Fill(7.,header->GetCentralityP()->GetCentralityPercentile("CL1")); + fHistCentStats->Fill(8.,header->GetCentralityP()->GetCentralityPercentile("ZNA")); + fHistCentStats->Fill(9.,header->GetCentralityP()->GetCentralityPercentile("ZPA")); + fHistCentStats->Fill(10.,header->GetCentralityP()->GetCentralityPercentile("V0MvsFMD")); + fHistCentStats->Fill(11.,header->GetCentralityP()->GetCentralityPercentile("TKLvsV0M")); + fHistCentStats->Fill(12.,header->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC")); + + // Centrality estimator USED ++++++++++++++++++++++++++++++ + fHistCentStatsUsed->Fill(0.,header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data())); + + // centrality QA (V0M) + fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C()); + + // centrality QA (reference tracks) + fHistRefTracks->Fill(0.,header->GetRefMultiplicity()); + fHistRefTracks->Fill(1.,header->GetRefMultiplicityPos()); + fHistRefTracks->Fill(2.,header->GetRefMultiplicityNeg()); + fHistRefTracks->Fill(3.,header->GetTPConlyRefMultiplicity()); + fHistRefTracks->Fill(4.,header->GetNumberOfITSClusters(0)); + fHistRefTracks->Fill(5.,header->GetNumberOfITSClusters(1)); + fHistRefTracks->Fill(6.,header->GetNumberOfITSClusters(2)); + fHistRefTracks->Fill(7.,header->GetNumberOfITSClusters(3)); + fHistRefTracks->Fill(8.,header->GetNumberOfITSClusters(4)); + + }//AOD header + }//AOD + + else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){ // centrality class for ESDs or MC-ESDs + AliCentrality *centrality = event->GetCentrality(); + gCentrality = centrality->GetCentralityPercentile(fCentralityEstimator.Data()); + + // QA for centrality estimators + fHistCentStats->Fill(0.,centrality->GetCentralityPercentile("V0M")); + fHistCentStats->Fill(1.,centrality->GetCentralityPercentile("V0A")); + fHistCentStats->Fill(2.,centrality->GetCentralityPercentile("V0C")); + fHistCentStats->Fill(3.,centrality->GetCentralityPercentile("FMD")); + fHistCentStats->Fill(4.,centrality->GetCentralityPercentile("TRK")); + fHistCentStats->Fill(5.,centrality->GetCentralityPercentile("TKL")); + fHistCentStats->Fill(6.,centrality->GetCentralityPercentile("CL0")); + fHistCentStats->Fill(7.,centrality->GetCentralityPercentile("CL1")); + fHistCentStats->Fill(8.,centrality->GetCentralityPercentile("ZNA")); + fHistCentStats->Fill(9.,centrality->GetCentralityPercentile("ZPA")); + fHistCentStats->Fill(10.,centrality->GetCentralityPercentile("V0MvsFMD")); + fHistCentStats->Fill(11.,centrality->GetCentralityPercentile("TKLvsV0M")); + fHistCentStats->Fill(12.,centrality->GetCentralityPercentile("ZEMvsZDC")); + + // Centrality estimator USED ++++++++++++++++++++++++++++++ + fHistCentStatsUsed->Fill(0.,centrality->GetCentralityPercentile(fCentralityEstimator.Data())); + + // centrality QA (V0M) + fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C()); + }//ESD + + else if(gAnalysisLevel == "MC"){ + Double_t gImpactParameter = 0.; + AliMCEvent *gMCEvent = dynamic_cast(event); + if(gMCEvent){ + AliCollisionGeometry* headerH = dynamic_cast(gMCEvent->GenEventHeader()); + if(headerH){ + gImpactParameter = headerH->ImpactParameter(); + gCentrality = gImpactParameter; + }//MC header + }//MC event cast + }//MC + + else{ + gCentrality = -1.; + } + + // calculate reference multiplicity always (not only in multiplicity mode) + if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){ + AliESDEvent* gESDEvent = dynamic_cast(event); + if(gESDEvent){ + gMultiplicity = fESDtrackCuts->GetReferenceMultiplicity(gESDEvent, AliESDtrackCuts::kTrackletsITSTPC,0.5); + fHistMultiplicity->Fill(gMultiplicity); + }//AliESDevent cast + }//ESD mode + + else if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ){ + AliAODHeader *header = (AliAODHeader*) event->GetHeader(); + if ((fMultiplicityEstimator == "V0M")|| + (fMultiplicityEstimator == "V0A")|| + (fMultiplicityEstimator == "V0C") || + (fMultiplicityEstimator == "TPC")) { + gMultiplicity = GetReferenceMultiplicityFromAOD(event); + if(fDebugLevel) Printf("Reference multiplicity (calculated): %.0f",gMultiplicity); + } + else { + if(header) + gMultiplicity = header->GetRefMultiplicity(); + if(fDebugLevel) Printf("Reference multiplicity (AOD header): %.0f",gMultiplicity); + } + fHistMultiplicity->Fill(gMultiplicity); + }//AOD mode + else if(gAnalysisLevel == "MC") { + AliMCEvent* gMCEvent = dynamic_cast(event); + //Calculating the multiplicity as the number of charged primaries + //within \pm 0.8 in eta and pT > 0.1 GeV/c + for(Int_t iParticle = 0; iParticle < gMCEvent->GetNumberOfPrimaries(); iParticle++) { + AliMCParticle* track = dynamic_cast(gMCEvent->GetTrack(iParticle)); + if (!track) { + AliError(Form("Could not receive particle %d", iParticle)); + continue; + } + + //exclude non stable particles + if(!(gMCEvent->IsPhysicalPrimary(iParticle))) continue; + + //++++++++++++++++ + if (fMultiplicityEstimator == "V0M") { + if((track->Eta() > 5.1 || track->Eta() < 2.8)&&(track->Eta() < -3.7 || track->Eta() > -1.7)) + continue;} + else if (fMultiplicityEstimator == "V0A") { + if(track->Eta() > 5.1 || track->Eta() < 2.8) continue;} + else if (fMultiplicityEstimator == "V0C") { + if(track->Eta() > -1.7 || track->Eta() < -3.7) continue;} + else if (fMultiplicityEstimator == "TPC") { + if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue; + if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue; + } + else{ + if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue; + if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue; + } + //++++++++++++++++ + + if(track->Charge() == 0) continue; + + gMultiplicity += 1; + }//loop over primaries + fHistMultiplicity->Fill(gMultiplicity); + }//MC mode + else{ + gMultiplicity = -1; + } + + + // decide what should be returned only here + Double_t lReturnVal = -100; + if(fEventClass=="Multiplicity"){ + lReturnVal = gMultiplicity; + }else if(fEventClass=="Centrality"){ + lReturnVal = gCentrality; + } + return lReturnVal; +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event){ + //Function that returns the reference multiplicity from AODs (data or reco MC) + //Different ref. mult. implemented: V0M, V0A, V0C, TPC + Double_t gRefMultiplicity = 0., gRefMultiplicityTPC = 0.; + Double_t gRefMultiplicityVZERO = 0., gRefMultiplicityVZEROA = 0., gRefMultiplicityVZEROC = 0.; + + AliAODHeader *header = dynamic_cast(event->GetHeader()); + if(!header) { + Printf("ERROR: AOD header not available"); + return -999; + } + Int_t gRunNumber = header->GetRunNumber(); + + // Loop over tracks in event + for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { + AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); + if (!aodTrack) { + AliError(Form("Could not receive track %d", iTracks)); + continue; + } + + // AOD track cuts + if(!aodTrack->TestFilterBit(fnAODtrackCutBit)) continue; + + if(aodTrack->Charge() == 0) continue; + // Kinematics cuts from ESD track cuts + if( aodTrack->Pt() < fPtMin || aodTrack->Pt() > fPtMax) continue; + if( aodTrack->Eta() < fEtaMin || aodTrack->Eta() > fEtaMax) continue; + + //=================PID (so far only for electron rejection)==========================// + if(fElectronRejection) { + // get the electron nsigma + Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); + + // check only for given momentum range + if( aodTrack->Pt() > fElectronRejectionMinPt && aodTrack->Pt() < fElectronRejectionMaxPt ){ + //look only at electron nsigma + if(!fElectronOnlyRejection) { + //Make the decision based on the n-sigma of electrons + if(nSigma < fElectronRejectionNSigma) continue; + } + else { + Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); + Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); + Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); + + //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) + if(nSigma < fElectronRejectionNSigma + && nSigmaPions > fElectronRejectionNSigma + && nSigmaKaons > fElectronRejectionNSigma + && nSigmaProtons > fElectronRejectionNSigma ) continue; + } + } + }//electron rejection + + gRefMultiplicityTPC += 1.0; + }// track loop + + //VZERO segmentation in two detectors (0-31: VZERO-C, 32-63: VZERO-A) + for(Int_t iChannel = 0; iChannel < 64; iChannel++) { + fHistVZEROSignal->Fill(iChannel,event->GetVZEROEqMultiplicity(iChannel)); + + if(iChannel < 32) + gRefMultiplicityVZEROC += event->GetVZEROEqMultiplicity(iChannel); + else if(iChannel >= 32) + gRefMultiplicityVZEROA += event->GetVZEROEqMultiplicity(iChannel); + }//loop over PMTs + + //Equalization of gain + Double_t gFactorA = GetEqualizationFactor(gRunNumber,"A"); + if(gFactorA != 0) + gRefMultiplicityVZEROA /= gFactorA; + Double_t gFactorC = GetEqualizationFactor(gRunNumber,"C"); + if(gFactorC != 0) + gRefMultiplicityVZEROC /= gFactorC; + if((gFactorA != 0)&&(gFactorC != 0)) + gRefMultiplicityVZERO = (gRefMultiplicityVZEROA/gFactorA)+(gRefMultiplicityVZEROC/gFactorC); + + if(fDebugLevel) + Printf("VZERO multiplicity: %.0f - TPC multiplicity: %.0f",gRefMultiplicityVZERO,gRefMultiplicityTPC); + + fHistTPCvsVZEROMultiplicity->Fill(gRefMultiplicityVZERO,gRefMultiplicityTPC); + + if(fMultiplicityEstimator == "TPC") + gRefMultiplicity = gRefMultiplicityTPC; + else if(fMultiplicityEstimator == "V0M") + gRefMultiplicity = gRefMultiplicityVZERO; + else if(fMultiplicityEstimator == "V0A") + gRefMultiplicity = gRefMultiplicityVZEROA; + else if(fMultiplicityEstimator == "V0C") + gRefMultiplicity = gRefMultiplicityVZEROC; + + return gRefMultiplicity; +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetEventPlane(AliVEvent *event){ + // Get the event plane + + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + + Float_t gVZEROEventPlane = -10.; + Float_t gReactionPlane = -10.; + Double_t qxTot = 0.0, qyTot = 0.0; + + //MC: from reaction plane + if(gAnalysisLevel == "MC"){ + if(!event) { + AliError("mcEvent not available"); + return 0x0; + } + + AliMCEvent *gMCEvent = dynamic_cast(event); + if(gMCEvent){ + AliCollisionGeometry* headerH = dynamic_cast(gMCEvent->GenEventHeader()); + if (headerH) { + gReactionPlane = headerH->ReactionPlaneAngle(); + //gReactionPlane *= TMath::RadToDeg(); + }//MC header + }//MC event cast + }//MC + + // AOD,ESD,ESDMC: from VZERO Event Plane + else{ + + AliEventplane *ep = event->GetEventplane(); + if(ep){ + gVZEROEventPlane = ep->CalculateVZEROEventPlane(event,10,2,qxTot,qyTot); + if(gVZEROEventPlane < 0.) gVZEROEventPlane += TMath::Pi(); + //gReactionPlane = gVZEROEventPlane*TMath::RadToDeg(); + gReactionPlane = gVZEROEventPlane; + } + }//AOD,ESD,ESDMC + + return gReactionPlane; +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetTrackbyTrackCorrectionMatrix( Double_t vEta, + Double_t vPhi, + Double_t vPt, + Short_t vCharge, + Double_t gCentrality) { + // -- Get efficiency correction of particle dependent on (eta, phi, pt, charge, centrality) + + Double_t correction = 1.; + Int_t binEta = 0, binPt = 0, binPhi = 0; + + //Printf("EtaMAx: %lf - EtaMin: %lf - EtaBin: %lf", fEtaMaxForCorrections,fEtaMinForCorrections,fEtaBinForCorrections); + if(fEtaBinForCorrections != 0) { + Double_t widthEta = (fEtaMaxForCorrections - fEtaMinForCorrections)/fEtaBinForCorrections; + if(fEtaMaxForCorrections != fEtaMinForCorrections) + binEta = (Int_t)((vEta-fEtaMinForCorrections)/widthEta)+1; + } + + if(fPtBinForCorrections != 0) { + Double_t widthPt = (fPtMaxForCorrections - fPtMinForCorrections)/fPtBinForCorrections; + if(fPtMaxForCorrections != fPtMinForCorrections) + binPt = (Int_t)((vPt-fPtMinForCorrections)/widthPt) + 1; + } + + if(fPhiBinForCorrections != 0) { + Double_t widthPhi = (fPhiMaxForCorrections - fPhiMinForCorrections)/fPhiBinForCorrections; + if(fPhiMaxForCorrections != fPhiMinForCorrections) + binPhi = (Int_t)((vPhi-fPhiMinForCorrections)/widthPhi)+ 1; + } + + Int_t gCentralityInt = -1; + for (Int_t i=0; i no correction + if(gCentralityInt < 0){ + correction = 1.; + } + else{ + + //Printf("//=============CENTRALITY=============// %d:",gCentralityInt); + + if(fHistCorrectionPlus[gCentralityInt]){ + if (vCharge > 0) { + correction = fHistCorrectionPlus[gCentralityInt]->GetBinContent(fHistCorrectionPlus[gCentralityInt]->GetBin(binEta, binPt, binPhi)); + //Printf("CORRECTIONplus: %.2f | Centrality %d",correction,gCentralityInt); + } + if (vCharge < 0) { + correction = fHistCorrectionMinus[gCentralityInt]->GetBinContent(fHistCorrectionMinus[gCentralityInt]->GetBin(binEta, binPt, binPhi)); + //Printf("CORRECTIONminus: %.2f | Centrality %d",correction,gCentralityInt); + } + } + else { + correction = 1.; + } + }//centrality in array + + if (correction == 0.) { + AliError(Form("Should not happen : bin content = 0. >> eta: %.2f | phi : %.2f | pt : %.2f | cent %d",vEta, vPhi, vPt, gCentralityInt)); + correction = 1.; + } + + return correction; +} + +//________________________________________________________________________ +TObjArray* AliAnalysisTaskBFPsi::GetAcceptedTracks(AliVEvent *event, Double_t gCentrality, Double_t gReactionPlane){ + // Returns TObjArray with tracks after all track cuts (only for AOD!) + // Fills QA histograms + + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + + //output TObjArray holding all good tracks + TObjArray* tracksAccepted = new TObjArray; + tracksAccepted->SetOwner(kTRUE); + + Short_t vCharge; + Double_t vEta; + Double_t vY; + Double_t vPhi; + Double_t vPt; + + + if(gAnalysisLevel == "AOD") { // handling of TPC only tracks different in AOD and ESD + // Loop over tracks in event + + for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { + AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); + if (!aodTrack) { + AliError(Form("Could not receive track %d", iTracks)); + continue; + } + + // AOD track cuts + + // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C + // take only TPC only tracks + //fHistTrackStats->Fill(aodTrack->GetFilterMap()); + for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){ + fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<TestFilterBit(fnAODtrackCutBit)) continue; + + + // additional check on kPrimary flag + if(fCheckPrimaryFlagAOD){ + if(aodTrack->GetType() != AliAODTrack::kPrimary) + continue; + } + + + vCharge = aodTrack->Charge(); + vEta = aodTrack->Eta(); + vY = aodTrack->Y(); + vPhi = aodTrack->Phi();// * TMath::RadToDeg(); + vPt = aodTrack->Pt(); + + //===========================PID (so far only for electron rejection)===============================// + if(fElectronRejection) { + + // get the electron nsigma + Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); + + //Fill QA before the PID + fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); + //end of QA-before pid + + // check only for given momentum range + if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){ + + //look only at electron nsigma + if(!fElectronOnlyRejection){ + + //Make the decision based on the n-sigma of electrons + if(nSigma < fElectronRejectionNSigma) continue; + } + else{ + + Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); + Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); + Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); + + //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) + if(nSigma < fElectronRejectionNSigma + && nSigmaPions > fElectronRejectionNSigma + && nSigmaKaons > fElectronRejectionNSigma + && nSigmaProtons > fElectronRejectionNSigma ) continue; + } + } + + //Fill QA after the PID + fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); + + } + //===========================end of PID (so far only for electron rejection)===============================// + + //+++++++++++++++++++++++++++++// + //===========================PID===============================// + if(fUsePID) { + Double_t prob[AliPID::kSPECIES]={0.}; + Double_t probTPC[AliPID::kSPECIES]={0.}; + Double_t probTOF[AliPID::kSPECIES]={0.}; + Double_t probTPCTOF[AliPID::kSPECIES]={0.}; + + Double_t nSigma = 0.; + Double_t nSigmaTPC = 0.; //++++ + Double_t nSigmaTOF = 0.; //++++ + Double_t nSigmaTPCTOF = 0.; //++++ + UInt_t detUsedTPC = 0; + UInt_t detUsedTOF = 0; + UInt_t detUsedTPCTOF = 0; + + nSigmaTPC = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)fParticleOfInterest)); + nSigmaTOF = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(aodTrack,(AliPID::EParticleType)fParticleOfInterest)); + nSigmaTPCTOF = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF); + + //Decide what detector configuration we want to use + switch(fPidDetectorConfig) { + case kTPCpid: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC); + nSigma = nSigmaTPC; + detUsedTPC = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPC); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTPC[iSpecies]; + break; + case kTOFpid: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF); + nSigma = nSigmaTOF; + detUsedTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTOF); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTOF[iSpecies]; + break; + case kTPCTOF: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC); + nSigma = nSigmaTPCTOF; + detUsedTPCTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPCTOF); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTPCTOF[iSpecies]; + break; + default: + break; + }//end switch: define detector mask + + //Filling the PID QA + Double_t tofTime = -999., length = 999., tof = -999.; + Double_t c = TMath::C()*1.E-9;// m/ns + Double_t beta = -999.; + if ( (aodTrack->IsOn(AliAODTrack::kTOFin)) && + (aodTrack->IsOn(AliAODTrack::kTIME)) ) { + tofTime = aodTrack->GetTOFsignal();//in ps + length = aodTrack->GetIntegratedLength(); + tof = tofTime*1E-3; // ns + + if (tof <= 0) { + //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n"); + continue; + } + if (length <= 0){ + //printf("WARNING: track with negative length found!Skipping this track for PID checks\n"); + continue; + } + + length = length*0.01; // in meters + tof = tof*c; + beta = length/tof; + + fHistBetavsPTOFbeforePID ->Fill(aodTrack->P()*aodTrack->Charge(),beta); + fHistProbTOFvsPtbeforePID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]); + fHistNSigmaTOFvsPtbeforePID ->Fill(aodTrack->Pt(),nSigmaTOF); + }//TOF signal + + fHistdEdxVsPTPCbeforePID -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistProbTPCvsPtbeforePID -> Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]); + fHistNSigmaTPCvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPC); + + fHistProbTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]); + + //combined TPC&TOF + fHistBetaVsdEdXbeforePID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++ + fHistNSigmaTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPCTOF); + Printf("NSIGMA: %lf - nSigmaTOF: %lf - nSigmaTPC: %lf - nSigmaTPCTOF: %lf",nSigma,nSigmaTOF,nSigmaTPC,nSigmaTPCTOF); + + //end of QA-before pid + + if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) { + //Make the decision based on the n-sigma + if(fUsePIDnSigma) { + if(nSigma > fPIDNSigma) continue; + + fHistNSigmaTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTOF); + fHistNSigmaTPCvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPC); + fHistNSigmaTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPCTOF); + } + //Make the decision based on the bayesian + else if(fUsePIDPropabilities) { + if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue; + if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue; + + fHistProbTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]); + fHistProbTPCvsPtafterPID ->Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]); + fHistProbTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]); + + } + + //Fill QA after the PID + fHistBetavsPTOFafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),beta); + fHistdEdxVsPTPCafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistBetaVsdEdXafterPID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++ + } + } + //===========================PID===============================// + //+++++++++++++++++++++++++++++// + + + Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on) + Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) + + + // Kinematics cuts from ESD track cuts + if( vPt < fPtMin || vPt > fPtMax) continue; + if( vEta < fEtaMin || vEta > fEtaMax) continue; + + // Extra DCA cuts (for systematic studies [!= -1]) + if( fDCAxyCut != -1 && fDCAzCut != -1){ + if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){ + continue; // 2D cut + } + } + + // Extra TPC cuts (for systematic studies [!= -1]) + if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){ + continue; + } + if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){ + continue; + } + + // fill QA histograms + fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls()); + fHistDCA->Fill(dcaZ,dcaXY); + fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality); + fHistPt->Fill(vPt,gCentrality); + fHistEta->Fill(vEta,gCentrality); + fHistRapidity->Fill(vY,gCentrality); + if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); + else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); + fHistPhi->Fill(vPhi,gCentrality); + if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); + else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); + + //=======================================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + + // add the track to the TObjArray + tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); + }//track loop + }// AOD analysis + + //============================================================================================================== + else if(gAnalysisLevel == "MCAOD") { + + AliMCEvent* mcEvent = MCEvent(); + if (!mcEvent) { + AliError("ERROR: Could not retrieve MC event"); + } + else{ + + for (Int_t iTracks = 0; iTracks < mcEvent->GetNumberOfTracks(); iTracks++) { + AliAODMCParticle *aodTrack = (AliAODMCParticle*) mcEvent->GetTrack(iTracks); + if (!aodTrack) { + AliError(Form("ERROR: Could not receive track %d (mc loop)", iTracks)); + continue; + } + + if(!aodTrack->IsPhysicalPrimary()) continue; + + vCharge = aodTrack->Charge(); + vEta = aodTrack->Eta(); + vY = aodTrack->Y(); + vPhi = aodTrack->Phi();// * TMath::RadToDeg(); + vPt = aodTrack->Pt(); + + // Kinematics cuts from ESD track cuts + if( vPt < fPtMin || vPt > fPtMax) continue; + if( vEta < fEtaMin || vEta > fEtaMax) continue; + + // Remove neutral tracks + if( vCharge == 0 ) continue; + + //Exclude resonances + if(fExcludeResonancesInMC) { + + Bool_t kExcludeParticle = kFALSE; + Int_t gMotherIndex = aodTrack->GetMother(); + if(gMotherIndex != -1) { + AliAODMCParticle* motherTrack = dynamic_cast(mcEvent->GetTrack(gMotherIndex)); + if(motherTrack) { + Int_t pdgCodeOfMother = motherTrack->GetPdgCode(); + //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) { + //if(pdgCodeOfMother == 113) { + if(pdgCodeOfMother == 113 // rho0 + || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ + // || pdgCodeOfMother == 221 // eta + // || pdgCodeOfMother == 331 // eta' + // || pdgCodeOfMother == 223 // omega + // || pdgCodeOfMother == 333 // phi + || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 + // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* + // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* + || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda + || pdgCodeOfMother == 111 // pi0 Dalitz + || pdgCodeOfMother == 22 // photon + ) { + kExcludeParticle = kTRUE; + } + } + } + + //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi + if(kExcludeParticle) continue; + } + + //Exclude electrons with PDG + if(fExcludeElectronsInMC) { + + if(TMath::Abs(aodTrack->GetPdgCode()) == 11) continue; + + } + + // fill QA histograms + fHistPt->Fill(vPt,gCentrality); + fHistEta->Fill(vEta,gCentrality); + fHistRapidity->Fill(vY,gCentrality); + if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); + else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); + fHistPhi->Fill(vPhi,gCentrality); + if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); + else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); + + //=======================================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + + // add the track to the TObjArray + tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); + }//aodTracks + }//MC event + }//MCAOD + //============================================================================================================== + + //============================================================================================================== + else if(gAnalysisLevel == "MCAODrec") { + + /* fAOD = dynamic_cast(InputEvent()); + if (!fAOD) { + printf("ERROR: fAOD not available\n"); + return; + }*/ + + fArrayMC = dynamic_cast(event->FindListObject(AliAODMCParticle::StdBranchName())); + if (!fArrayMC) { + AliError("No array of MC particles found !!!"); + } + + AliMCEvent* mcEvent = MCEvent(); + if (!mcEvent) { + AliError("ERROR: Could not retrieve MC event"); + return tracksAccepted; + } + + for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { + AliAODTrack* aodTrack = dynamic_cast(event->GetTrack(iTracks)); + if (!aodTrack) { + AliError(Form("Could not receive track %d", iTracks)); + continue; + } + + for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){ + fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<TestFilterBit(fnAODtrackCutBit)) continue; + + vCharge = aodTrack->Charge(); + vEta = aodTrack->Eta(); + vY = aodTrack->Y(); + vPhi = aodTrack->Phi();// * TMath::RadToDeg(); + vPt = aodTrack->Pt(); + + //===========================use MC information for Kinematics===============================// + if(fUseMCforKinematics){ + + Int_t label = TMath::Abs(aodTrack->GetLabel()); + AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); + + if(AODmcTrack){ + vCharge = AODmcTrack->Charge(); + vEta = AODmcTrack->Eta(); + vY = AODmcTrack->Y(); + vPhi = AODmcTrack->Phi();// * TMath::RadToDeg(); + vPt = AODmcTrack->Pt(); + } + else{ + AliDebug(1, "no MC particle for this track"); + continue; + } + } + //===========================end of use MC information for Kinematics========================// + + + //===========================PID (so far only for electron rejection)===============================// + if(fElectronRejection) { + + // get the electron nsigma + Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron)); + + //Fill QA before the PID + fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); + //end of QA-before pid + + // check only for given momentum range + if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){ + + //look only at electron nsigma + if(!fElectronOnlyRejection){ + + //Make the decision based on the n-sigma of electrons + if(nSigma < fElectronRejectionNSigma) continue; + } + else{ + + Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion)); + Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon)); + Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton)); + + //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species) + if(nSigma < fElectronRejectionNSigma + && nSigmaPions > fElectronRejectionNSigma + && nSigmaKaons > fElectronRejectionNSigma + && nSigmaProtons > fElectronRejectionNSigma ) continue; + } + } + + //Fill QA after the PID + fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal()); + fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma); + + } + //===========================end of PID (so far only for electron rejection)===============================// + + Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on) + Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) + + // Kinematics cuts from ESD track cuts + if( vPt < fPtMin || vPt > fPtMax) continue; + if( vEta < fEtaMin || vEta > fEtaMax) continue; + + // Extra DCA cuts (for systematic studies [!= -1]) + if( fDCAxyCut != -1 && fDCAzCut != -1){ + if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){ + continue; // 2D cut + } + } + + // Extra TPC cuts (for systematic studies [!= -1]) + if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){ + continue; + } + if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){ + continue; + } + + //Exclude resonances + if(fExcludeResonancesInMC) { + + Bool_t kExcludeParticle = kFALSE; + + Int_t label = TMath::Abs(aodTrack->GetLabel()); + AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); + + if (AODmcTrack){ + //if (AODmcTrack->IsPhysicalPrimary()){ + + Int_t gMotherIndex = AODmcTrack->GetMother(); + if(gMotherIndex != -1) { + AliAODMCParticle* motherTrack = dynamic_cast(mcEvent->GetTrack(gMotherIndex)); + if(motherTrack) { + Int_t pdgCodeOfMother = motherTrack->GetPdgCode(); + if(pdgCodeOfMother == 113 // rho0 + || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ + // || pdgCodeOfMother == 221 // eta + // || pdgCodeOfMother == 331 // eta' + // || pdgCodeOfMother == 223 // omega + // || pdgCodeOfMother == 333 // phi + || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 + // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* + // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* + || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda + || pdgCodeOfMother == 111 // pi0 Dalitz + || pdgCodeOfMother == 22 // photon + ) { + kExcludeParticle = kTRUE; + } + } + } + } + //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi + if(kExcludeParticle) continue; + } + + //Exclude electrons with PDG + if(fExcludeElectronsInMC) { + + Int_t label = TMath::Abs(aodTrack->GetLabel()); + AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label); + + if (AODmcTrack){ + if(TMath::Abs(AODmcTrack->GetPdgCode()) == 11) continue; + } + } + + // fill QA histograms + fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls()); + fHistDCA->Fill(dcaZ,dcaXY); + fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality); + fHistPt->Fill(vPt,gCentrality); + fHistEta->Fill(vEta,gCentrality); + fHistRapidity->Fill(vY,gCentrality); + if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); + else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); + fHistPhi->Fill(vPhi,gCentrality); + if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); + else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); + + //=======================================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + + // add the track to the TObjArray + tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); + }//track loop + }//MCAODrec + //============================================================================================================== + + else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD") { // handling of TPC only tracks different in AOD and ESD + + AliESDtrack *trackTPC = NULL; + AliMCParticle *mcTrack = NULL; + + AliMCEvent* mcEvent = NULL; + + // for MC ESDs use also MC information + if(gAnalysisLevel == "MCESD"){ + mcEvent = MCEvent(); + if (!mcEvent) { + AliError("mcEvent not available"); + return tracksAccepted; + } + } + + // Loop over tracks in event + for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) { + AliESDtrack* track = dynamic_cast(event->GetTrack(iTracks)); + if (!track) { + AliError(Form("Could not receive track %d", iTracks)); + continue; + } + + // for MC ESDs use also MC information --> MC track not used further??? + if(gAnalysisLevel == "MCESD"){ + Int_t label = TMath::Abs(track->GetLabel()); + if(label > mcEvent->GetNumberOfTracks()) continue; + if(label > mcEvent->GetNumberOfPrimaries()) continue; + + mcTrack = dynamic_cast(mcEvent->GetTrack(label)); + if(!mcTrack) continue; + } + + // take only TPC only tracks + trackTPC = new AliESDtrack(); + if(!track->FillTPCOnlyTrack(*trackTPC)) continue; + + //ESD track cuts + if(fESDtrackCuts) + if(!fESDtrackCuts->AcceptTrack(trackTPC)) continue; + + // fill QA histograms + Float_t b[2]; + Float_t bCov[3]; + trackTPC->GetImpactParameters(b,bCov); + if (bCov[0]<=0 || bCov[2]<=0) { + AliDebug(1, "Estimated b resolution lower or equal zero!"); + bCov[0]=0; bCov[2]=0; + } + + Int_t nClustersTPC = -1; + nClustersTPC = trackTPC->GetTPCNclsIter1(); // TPC standalone + //nClustersTPC = track->GetTPCclusters(0); // global track + Float_t chi2PerClusterTPC = -1; + if (nClustersTPC!=0) { + chi2PerClusterTPC = trackTPC->GetTPCchi2Iter1()/Float_t(nClustersTPC); // TPC standalone + //chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC); // global track + } + + //===========================PID===============================// + if(fUsePID) { + Double_t prob[AliPID::kSPECIES]={0.}; + Double_t probTPC[AliPID::kSPECIES]={0.}; + Double_t probTOF[AliPID::kSPECIES]={0.}; + Double_t probTPCTOF[AliPID::kSPECIES]={0.}; + + Double_t nSigma = 0.; + UInt_t detUsedTPC = 0; + UInt_t detUsedTOF = 0; + UInt_t detUsedTPCTOF = 0; + + //Decide what detector configuration we want to use + switch(fPidDetectorConfig) { + case kTPCpid: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC); + nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest)); + detUsedTPC = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPC); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTPC[iSpecies]; + break; + case kTOFpid: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF); + nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest)); + detUsedTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTOF); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTOF[iSpecies]; + break; + case kTPCTOF: + fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC); + detUsedTPCTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPCTOF); + for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) + prob[iSpecies] = probTPCTOF[iSpecies]; + break; + default: + break; + }//end switch: define detector mask + + //Filling the PID QA + Double_t tofTime = -999., length = 999., tof = -999.; + Double_t c = TMath::C()*1.E-9;// m/ns + Double_t beta = -999.; + Double_t nSigmaTOFForParticleOfInterest = -999.; + if ( (track->IsOn(AliESDtrack::kTOFin)) && + (track->IsOn(AliESDtrack::kTIME)) ) { + tofTime = track->GetTOFsignal();//in ps + length = track->GetIntegratedLength(); + tof = tofTime*1E-3; // ns + + if (tof <= 0) { + //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n"); + continue; + } + if (length <= 0){ + //printf("WARNING: track with negative length found!Skipping this track for PID checks\n"); + continue; + } + + length = length*0.01; // in meters + tof = tof*c; + beta = length/tof; + + nSigmaTOFForParticleOfInterest = fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest); + fHistBetavsPTOFbeforePID ->Fill(track->P()*track->Charge(),beta); + fHistProbTOFvsPtbeforePID ->Fill(track->Pt(),probTOF[fParticleOfInterest]); + fHistNSigmaTOFvsPtbeforePID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest); + }//TOF signal + + + Double_t nSigmaTPCForParticleOfInterest = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest); + fHistdEdxVsPTPCbeforePID -> Fill(track->P()*track->Charge(),track->GetTPCsignal()); + fHistProbTPCvsPtbeforePID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); + fHistNSigmaTPCvsPtbeforePID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); + fHistProbTPCTOFvsPtbeforePID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]); + //end of QA-before pid + + if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) { + //Make the decision based on the n-sigma + if(fUsePIDnSigma) { + if(nSigma > fPIDNSigma) continue;} + + //Make the decision based on the bayesian + else if(fUsePIDPropabilities) { + if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue; + if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue; + } + + //Fill QA after the PID + fHistBetavsPTOFafterPID ->Fill(track->P()*track->Charge(),beta); + fHistProbTOFvsPtafterPID ->Fill(track->Pt(),probTOF[fParticleOfInterest]); + fHistNSigmaTOFvsPtafterPID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest); + + fHistdEdxVsPTPCafterPID -> Fill(track->P()*track->Charge(),track->GetTPCsignal()); + fHistProbTPCvsPtafterPID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); + fHistProbTPCTOFvsPtafterPID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]); + fHistNSigmaTPCvsPtafterPID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); + } + } + //===========================PID===============================// + vCharge = trackTPC->Charge(); + vY = trackTPC->Y(); + vEta = trackTPC->Eta(); + vPhi = trackTPC->Phi();// * TMath::RadToDeg(); + vPt = trackTPC->Pt(); + fHistClus->Fill(trackTPC->GetITSclusters(0),nClustersTPC); + fHistDCA->Fill(b[1],b[0]); + fHistChi2->Fill(chi2PerClusterTPC,gCentrality); + fHistPt->Fill(vPt,gCentrality); + fHistEta->Fill(vEta,gCentrality); + fHistPhi->Fill(vPhi,gCentrality); + if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); + else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); + fHistRapidity->Fill(vY,gCentrality); + if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); + else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); + + //=======================================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + + // add the track to the TObjArray + tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); + + delete trackTPC; + }//track loop + }// ESD analysis + + else if(gAnalysisLevel == "MC"){ + if(!event) { + AliError("mcEvent not available"); + return 0x0; + } + + AliMCEvent *gMCEvent = dynamic_cast(event); + if(gMCEvent) { + // Loop over tracks in event + for (Int_t iTracks = 0; iTracks < gMCEvent->GetNumberOfPrimaries(); iTracks++) { + AliMCParticle* track = dynamic_cast(gMCEvent->GetTrack(iTracks)); + if (!track) { + AliError(Form("Could not receive particle %d", iTracks)); + continue; + } + + //exclude non stable particles + if(!(gMCEvent->IsPhysicalPrimary(iTracks))) continue; + + vCharge = track->Charge(); + vEta = track->Eta(); + vPt = track->Pt(); + vY = track->Y(); + + if( vPt < fPtMin || vPt > fPtMax) + continue; + if (!fUsePID) { + if( vEta < fEtaMin || vEta > fEtaMax) continue; + } + else if (fUsePID){ + if( vY < fEtaMin || vY > fEtaMax) continue; + } + + // Remove neutral tracks + if( vCharge == 0 ) continue; + + //analyze one set of particles + if(fUseMCPdgCode) { + TParticle *particle = track->Particle(); + if(!particle) continue; + + Int_t gPdgCode = particle->GetPdgCode(); + if(TMath::Abs(fPDGCodeToBeAnalyzed) != TMath::Abs(gPdgCode)) + continue; + } + + //Use the acceptance parameterization + if(fAcceptanceParameterization) { + Double_t gRandomNumber = gRandom->Rndm(); + if(gRandomNumber > fAcceptanceParameterization->Eval(track->Pt())) + continue; + } + + //Exclude resonances + if(fExcludeResonancesInMC) { + TParticle *particle = track->Particle(); + if(!particle) continue; + + Bool_t kExcludeParticle = kFALSE; + Int_t gMotherIndex = particle->GetFirstMother(); + if(gMotherIndex != -1) { + AliMCParticle* motherTrack = dynamic_cast(event->GetTrack(gMotherIndex)); + if(motherTrack) { + TParticle *motherParticle = motherTrack->Particle(); + if(motherParticle) { + Int_t pdgCodeOfMother = motherParticle->GetPdgCode(); + //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) { + if(pdgCodeOfMother == 113 // rho0 + || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+ + // || pdgCodeOfMother == 221 // eta + // || pdgCodeOfMother == 331 // eta' + // || pdgCodeOfMother == 223 // omega + // || pdgCodeOfMother == 333 // phi + || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0 + // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0* + // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+* + || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda + || pdgCodeOfMother == 111 // pi0 Dalitz + ) { + kExcludeParticle = kTRUE; + } + } + } + } + + //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi + if(kExcludeParticle) continue; + } + + //Exclude electrons with PDG + if(fExcludeElectronsInMC) { + + TParticle *particle = track->Particle(); + + if (particle){ + if(TMath::Abs(particle->GetPdgCode()) == 11) continue; + } + } + + vPhi = track->Phi(); + //Printf("phi (before): %lf",vPhi); + + fHistPt->Fill(vPt,gCentrality); + fHistEta->Fill(vEta,gCentrality); + fHistPhi->Fill(vPhi,gCentrality); + if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality); + else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality); + //fHistPhi->Fill(vPhi*TMath::RadToDeg(),gCentrality); + fHistRapidity->Fill(vY,gCentrality); + //if(vCharge > 0) fHistPhiPos->Fill(vPhi*TMath::RadToDeg(),gCentrality); + //else if(vCharge < 0) fHistPhiNeg->Fill(vPhi*TMath::RadToDeg(),gCentrality); + if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality); + else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality); + + //Flow after burner + if(fUseFlowAfterBurner) { + Double_t precisionPhi = 0.001; + Int_t maxNumberOfIterations = 100; + + Double_t phi0 = vPhi; + Double_t gV2 = fDifferentialV2->Eval(vPt); + + for (Int_t j = 0; j < maxNumberOfIterations; j++) { + Double_t phiprev = vPhi; + Double_t fl = vPhi - phi0 + gV2*TMath::Sin(2.*(vPhi - gReactionPlane*TMath::DegToRad())); + Double_t fp = 1.0 + 2.0*gV2*TMath::Cos(2.*(vPhi - gReactionPlane*TMath::DegToRad())); + vPhi -= fl/fp; + if (TMath::AreEqualAbs(phiprev,vPhi,precisionPhi)) break; + } + //Printf("phi (after): %lf\n",vPhi); + Double_t vDeltaphiBefore = phi0 - gReactionPlane*TMath::DegToRad(); + if(vDeltaphiBefore < 0) vDeltaphiBefore += 2*TMath::Pi(); + fHistPhiBefore->Fill(vDeltaphiBefore,gCentrality); + + Double_t vDeltaphiAfter = vPhi - gReactionPlane*TMath::DegToRad(); + if(vDeltaphiAfter < 0) vDeltaphiAfter += 2*TMath::Pi(); + fHistPhiAfter->Fill(vDeltaphiAfter,gCentrality); + + } + + //vPhi *= TMath::RadToDeg(); + + //=======================================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + + tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction)); + } //track loop + }//MC event object + }//MC + + return tracksAccepted; +} + +//________________________________________________________________________ +TObjArray* AliAnalysisTaskBFPsi::GetShuffledTracks(TObjArray *tracks, Double_t gCentrality){ + // Clones TObjArray and returns it with tracks after shuffling the charges + + TObjArray* tracksShuffled = new TObjArray; + tracksShuffled->SetOwner(kTRUE); + + vector *chargeVector = new vector; //original charge of accepted tracks + + for (Int_t i=0; iGetEntriesFast(); i++) + { + AliVParticle* track = (AliVParticle*) tracks->At(i); + chargeVector->push_back(track->Charge()); + } + + random_shuffle(chargeVector->begin(), chargeVector->end()); + + for(Int_t i = 0; i < tracks->GetEntriesFast(); i++){ + AliVParticle* track = (AliVParticle*) tracks->At(i); + //==============================correction + Double_t correction = GetTrackbyTrackCorrectionMatrix(track->Eta(), track->Phi(),track->Pt(), chargeVector->at(i), gCentrality); + //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality); + tracksShuffled->Add(new AliBFBasicParticle(track->Eta(), track->Phi(), track->Pt(),chargeVector->at(i), correction)); + } + + delete chargeVector; + + return tracksShuffled; +} + +//________________________________________________________________________ +void AliAnalysisTaskBFPsi::SetVZEROCalibrationFile(const char* filename, + const char* lhcPeriod) { + //Function to setup the VZERO gain equalization + //============Get the equilization map============// + TFile *calibrationFile = TFile::Open(filename); + if((!calibrationFile)||(!calibrationFile->IsOpen())) { + Printf("No calibration file found!!!"); + return; + } + + TList *list = dynamic_cast(calibrationFile->Get(lhcPeriod)); + if(!list) { + Printf("Calibration TList not found!!!"); + return; + } + + fHistVZEROAGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROAGainEqualizationMap")); + if(!fHistVZEROAGainEqualizationMap) { + Printf("VZERO-A calibration object not found!!!"); + return; + } + fHistVZEROCGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROCGainEqualizationMap")); + if(!fHistVZEROCGainEqualizationMap) { + Printf("VZERO-C calibration object not found!!!"); + return; + } + + fHistVZEROChannelGainEqualizationMap = dynamic_cast(list->FindObject("gHistVZEROChannelGainEqualizationMap")); + if(!fHistVZEROChannelGainEqualizationMap) { + Printf("VZERO channel calibration object not found!!!"); + return; + } +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetChannelEqualizationFactor(Int_t run, + Int_t channel) { + // + if(!fHistVZEROAGainEqualizationMap) return 1.0; + + for(Int_t iBinX = 1; iBinX <= fHistVZEROChannelGainEqualizationMap->GetNbinsX(); iBinX++) { + Int_t gRunNumber = atoi(fHistVZEROChannelGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX)); + if(gRunNumber == run) + return fHistVZEROChannelGainEqualizationMap->GetBinContent(iBinX,channel+1); + } + + return 1.0; +} + +//________________________________________________________________________ +Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run, + const char* side) { + // + if(!fHistVZEROAGainEqualizationMap) return 1.0; + + TString gVZEROSide = side; + for(Int_t iBinX = 1; iBinX < fHistVZEROAGainEqualizationMap->GetNbinsX(); iBinX++) { + Int_t gRunNumber = atoi(fHistVZEROAGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX)); + //cout<<"Looking for run "<GetBinContent(iBinX); + else if(gVZEROSide == "C") + return fHistVZEROCGainEqualizationMap->GetBinContent(iBinX); + } + } + + return 1.0; +} + +//____________________________________________________________________ +Bool_t AliAnalysisTaskBFPsi::AcceptEventCentralityWeight(Double_t centrality) +{ + // copied from AliAnalysisTaskPhiCorrelations + // + // rejects "randomly" events such that the centrality gets flat + // uses fCentralityWeights histogram + + // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening + + Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality)); + Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.); + + Bool_t result = kFALSE; + if (centralityDigits < weight) + result = kTRUE; + + AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result)); + + return result; +} + +//________________________________________________________________________ +void AliAnalysisTaskBFPsi::FinishTaskOutput(){ + //Printf("END BF"); + + if (!fBalance) { + AliError("fBalance not available"); + return; + } + if(fRunShuffling) { + if (!fShuffledBalance) { + AliError("fShuffledBalance not available"); + return; + } + } + +} + +//________________________________________________________________________ +void AliAnalysisTaskBFPsi::Terminate(Option_t *) { + // Draw result to the screen + // Called once at the end of the query + + // not implemented ... + +} + diff --git a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h index 06e5a2cbfea..6e6f6da4c7f 100755 --- a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h +++ b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h @@ -1,378 +1,378 @@ -#ifndef ALIANALYSISTASKBFPSI_H -#define ALIANALYSISTASKBFPSI_H - -// Analysis task for the BF vs Psi code -// Authors: Panos Cristakoglou@cern.ch - -class TList; -class TH1F; -class TH2F; -class TH3F; -class TF1; -class TH3D; - -class AliBalancePsi; -class AliESDtrackCuts; -class AliEventPoolManager; - - -#include "AliAnalysisTaskSE.h" -#include "AliBalancePsi.h" - -#include "AliPID.h" -#include "AliPIDResponse.h" -#include "AliPIDCombined.h" - -//================================correction -#define kCENTRALITY 101 -//const Double_t centralityArrayForPbPb[kCENTRALITY+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; -//const TString centralityArrayForPbPb_string[kCENTRALITY] = {"0-5","5-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80"}; -//================================correction - -class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE { - public: - AliAnalysisTaskBFPsi(const char *name = "AliAnalysisTaskBFPsi"); - virtual ~AliAnalysisTaskBFPsi(); - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *option); - virtual void FinishTaskOutput(); - virtual void Terminate(Option_t *); - - //========================correction - virtual void SetInputCorrection(TString filename, - Int_t nCentralityBins, - Double_t *centralityArrayForCorrections); - //========================correction - // void SetDebugLevel() {fDebugLevel = kTRUE;} //hides overloaded virtual function - - void SetAnalysisObject(AliBalancePsi *const analysis) { - fBalance = analysis; - } - void SetShufflingObject(AliBalancePsi *const analysisShuffled) { - fRunShuffling = kTRUE; - fShuffledBalance = analysisShuffled; - } - void SetMixingObject(AliBalancePsi *const analysisMixed) { - fRunMixing = kTRUE; - fMixedBalance = analysisMixed; - } - void SetMixingWithEventPlane(Bool_t bMixingWithEventPlane = kTRUE) { fRunMixingEventPlane = bMixingWithEventPlane; } - void SetMixingTracks(Int_t tracks) { fMixingTracks = tracks; } - void SetAnalysisCutObject(AliESDtrackCuts *const trackCuts) { - fESDtrackCuts = trackCuts;} - void SetVertexDiamond(Double_t vx, Double_t vy, Double_t vz) { - fVxMax = vx; - fVyMax = vy; - fVzMax = vz; - } - - //==============AOD analysis==============// - void SetAODtrackCutBit(Int_t bit){ - fnAODtrackCutBit = bit; - } - - void SetKinematicsCutsAOD(Double_t ptmin, Double_t ptmax, Double_t etamin, Double_t etamax){ - fPtMin = ptmin; fPtMax = ptmax; - fEtaMin = etamin; fEtaMax = etamax; - } - - void SetExtraDCACutsAOD(Double_t DCAxy, Double_t DCAz){ - fDCAxyCut = DCAxy; - fDCAzCut = DCAz; - } - - void SetExtraTPCCutsAOD(Double_t maxTPCchi2, Int_t minNClustersTPC){ - fTPCchi2Cut = maxTPCchi2; - fNClustersTPCCut = minNClustersTPC; - } - - //==============MC analysis==============// - void SetKinematicsCutsMC(Double_t ptmin, Double_t ptmax, - Double_t etamin, Double_t etamax){ - fPtMin = ptmin; fPtMax = ptmax; - fEtaMin = etamin; fEtaMax = etamax; - } - void UseFlowAfterBurner(TF1 *gDifferentialV2) { - fDifferentialV2 = gDifferentialV2; - fUseFlowAfterBurner = kTRUE; - } - void ExcludeResonancesInMC() {fExcludeResonancesInMC = kTRUE;} - void ExcludeElectronsInMC() {fExcludeElectronsInMC = kTRUE;} - - void SetPDGCode(Int_t gPdgCode) { - fUseMCPdgCode = kTRUE; - fPDGCodeToBeAnalyzed = gPdgCode; - } - - //Centrality - void SetCentralityEstimator(const char* centralityEstimator) {fCentralityEstimator = centralityEstimator;} - const char* GetCentralityEstimator(void) const {return fCentralityEstimator;} - void SetCentralityPercentileRange(Double_t min, Double_t max) { - fUseCentrality = kTRUE; - fCentralityPercentileMin=min; - fCentralityPercentileMax=max; - } - void SetImpactParameterRange(Double_t min, Double_t max) { - fUseCentrality = kTRUE; - fImpactParameterMin=min; - fImpactParameterMax=max; - } - - //multiplicity - void SetMultiplicityEstimator(const char* multiplicityEstimator) {fMultiplicityEstimator = multiplicityEstimator;} - const char* GetMultiplicityEstimator(void) const {return fMultiplicityEstimator;} - void SetMultiplicityRange(Double_t min, Double_t max) { - fUseMultiplicity = kTRUE; - fNumberOfAcceptedTracksMin = min; - fNumberOfAcceptedTracksMax = max;} - - // additional event cuts (default = kFALSE) - void UseOfflineTrigger() {fUseOfflineTrigger = kTRUE;} - void CheckFirstEventInChunk() {fCheckFirstEventInChunk = kTRUE;} - void CheckPileUp() {fCheckPileUp = kTRUE;} - void CheckPrimaryFlagAOD() {fCheckPrimaryFlagAOD = kTRUE;} - void UseMCforKinematics() {fUseMCforKinematics = kTRUE;} - void SetCentralityWeights(TH1* hist) { fCentralityWeights = hist; } - Bool_t AcceptEventCentralityWeight(Double_t centrality); - - - //Acceptance filter - void SetAcceptanceParameterization(TF1 *parameterization) { - fAcceptanceParameterization = parameterization;} - - //pid - enum kDetectorUsedForPID { kTPCpid, kTOFpid, kTPCTOF }; // default TPC & TOF pid (via GetTPCpid & GetTOFpid) - enum kParticleOfInterest { kMuon, kElectron, kPion, kKaon, kProton }; - - void SetUseBayesianPID(Double_t gMinProbabilityValue) { - fUsePID = kTRUE; fUsePIDnSigma = kFALSE; fUsePIDPropabilities = kTRUE; - fMinAcceptedPIDProbability = gMinProbabilityValue; } - - void SetUseNSigmaPID(Double_t gMaxNSigma) { - fUsePID = kTRUE; fUsePIDPropabilities = kFALSE; fUsePIDnSigma = kTRUE; - fPIDNSigma = gMaxNSigma; } - - void SetParticleOfInterest(kParticleOfInterest poi) { - fParticleOfInterest = poi;} - void SetDetectorUsedForPID(kDetectorUsedForPID detConfig) { - fPidDetectorConfig = detConfig;} - void SetEventClass(TString receivedEventClass){ - fEventClass = receivedEventClass; - } - - void SetCustomBinning(TString receivedCustomBinning) { fCustomBinning = receivedCustomBinning; } - - - // electron rejection - void SetElectronRejection(Double_t gMaxNSigma){ - fElectronRejection = kTRUE; - fElectronRejectionNSigma = gMaxNSigma; - } - - void SetElectronOnlyRejection(Double_t gMaxNSigma){ - fElectronRejection = kTRUE; - fElectronOnlyRejection = kTRUE; - fElectronRejectionNSigma = gMaxNSigma; - } - - void SetElectronRejectionPt(Double_t minPt,Double_t maxPt){ - fElectronRejectionMinPt = minPt; - fElectronRejectionMaxPt = maxPt; - } - - void SetVZEROCalibrationFile(const char* filename, const char* lhcPeriod); - - private: - Double_t IsEventAccepted(AliVEvent* event); - Double_t GetRefMultiOrCentrality(AliVEvent* event); - Double_t GetReferenceMultiplicityFromAOD(AliVEvent* event); - Double_t GetEventPlane(AliVEvent* event); - //===============================correction - Double_t GetTrackbyTrackCorrectionMatrix(Double_t vEta, - Double_t vPhi, - Double_t vPt, - Short_t vCharge, - Double_t gCentrality); - //===============================correction - TObjArray* GetAcceptedTracks(AliVEvent* event, Double_t gCentrality, Double_t gReactionPlane); - TObjArray* GetShuffledTracks(TObjArray* tracks, Double_t gCentrality); - - Double_t GetChannelEqualizationFactor(Int_t run, Int_t channel); - Double_t GetEqualizationFactor(Int_t run, const char *side); - - Bool_t fDebugLevel; // debug level - - TClonesArray* fArrayMC; //! AOD object //+++++++++++++++++++++ - AliBalancePsi *fBalance; //BF object - Bool_t fRunShuffling;//run shuffling or not - AliBalancePsi *fShuffledBalance; //BF object (shuffled) - Bool_t fRunMixing;//run mixing or not - Bool_t fRunMixingEventPlane;//run mixing with Event Plane - Int_t fMixingTracks; - AliBalancePsi *fMixedBalance; //TriggeredBF object (mixed) - AliEventPoolManager* fPoolMgr; //! event pool manager - - TList *fList; //fList object - TList *fListBF; //fList object - TList *fListBFS; //fList object - TList *fListBFM; //fList object - TList *fHistListPIDQA; //! list of histograms - - TH2F *fHistEventStats; //event stats - TH2F *fHistCentStats; //centrality stats - TH2F *fHistCentStatsUsed; //centrality stats USED +++++++++++++++++++++++ - TH1F *fHistTriggerStats; //trigger stats - TH1F *fHistTrackStats; //Track filter bit stats - TH1F *fHistVx; //x coordinate of the primary vertex - TH1F *fHistVy; //y coordinate of the primary vertex - TH2F *fHistVz; //z coordinate of the primary vertex - - TH2F *fHistTPCvsVZEROMultiplicity; //VZERO vs TPC reference multiplicity - TH2F *fHistVZEROSignal; //VZERO channel vs signal - - TH2F *fHistEventPlane; //event plane distribution - - TH2F *fHistClus;//number of clusters (QA histogram) - TH2F *fHistDCA;//DCA (QA histogram) - TH2F *fHistChi2;//track chi2 (QA histogram) - TH2F *fHistPt;//transverse momentum (QA histogram) - TH2F *fHistEta;//pseudorapidity (QA histogram) - TH2F *fHistRapidity;//rapidity (QA histogram) - TH2F *fHistPhi;//phi (QA histogram) - TH3F *fHistEtaPhiPos;//eta-phi pos particles (QA histogram) - TH3F *fHistEtaPhiNeg;//eta-phi neg particles (QA histogram) - TH2F *fHistPhiBefore;//phi before v2 afterburner (QA histogram) - TH2F *fHistPhiAfter;//phi after v2 afterburner (QA histogram) - TH2F *fHistPhiPos;//phi for positive particles (QA histogram) - TH2F *fHistPhiNeg;//phi for negative particles (QA histogram) - TH2F *fHistV0M;//V0 multiplicities (QA histogram) - TH2F *fHistRefTracks;//reference track multiplicities (QA histogram) - - //============PID============// - TH2D *fHistdEdxVsPTPCbeforePID;//TPC dEdx vs momentum before PID cuts (QA histogram) - TH2D *fHistBetavsPTOFbeforePID;//beta vs momentum before PID cuts (QA histogram) - TH2D *fHistProbTPCvsPtbeforePID; //TPC probability vs pT before PID cuts (QA histogram) - TH2D *fHistProbTOFvsPtbeforePID;//TOF probability vs pT before PID cuts (QA histogram) - TH2D *fHistProbTPCTOFvsPtbeforePID;//TOF/TPC probability vs pT before PID cuts (QA histogram) - TH2D *fHistNSigmaTPCvsPtbeforePID;//TPC nsigma vs pT before PID cuts (QA histogram) - TH2D *fHistNSigmaTOFvsPtbeforePID;//TOF nsigma vs pT before PID cuts (QA histogram) - TH2D *fHistBetaVsdEdXbeforePID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ - TH2D *fHistNSigmaTPCTOFvsPtbeforePID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ - TH2D *fHistdEdxVsPTPCafterPID;//TPC dEdx vs momentum after PID cuts (QA histogram) - TH2D *fHistBetavsPTOFafterPID;//beta vs momentum after PID cuts (QA histogram) - TH2D *fHistProbTPCvsPtafterPID; //TPC probability vs pT after PID cuts (QA histogram) - TH2D *fHistProbTOFvsPtafterPID;//TOF probability vs pT after PID cuts (QA histogram) - TH2D *fHistProbTPCTOFvsPtafterPID;//TOF/TPC probability vs pT after PID cuts (QA histogram) - TH2D *fHistNSigmaTPCvsPtafterPID;//TPC nsigma vs pT after PID cuts (QA histogram) - TH2D *fHistNSigmaTOFvsPtafterPID;//TOF nsigma vs pT after PID cuts (QA histogram) - TH2D *fHistBetaVsdEdXafterPID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ - TH2D *fHistNSigmaTPCTOFvsPtafterPID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ - - TH2D *fHistdEdxVsPTPCbeforePIDelectron; //+++++++ - TH2D *fHistNSigmaTPCvsPtbeforePIDelectron; //+++++++ - TH2D *fHistdEdxVsPTPCafterPIDelectron; //+++++++ - TH2D *fHistNSigmaTPCvsPtafterPIDelectron; //+++++++ - - TH3F *fHistCorrectionPlus[kCENTRALITY]; //====correction - TH3F *fHistCorrectionMinus[kCENTRALITY]; //===correction - Double_t fCentralityArrayForCorrections[kCENTRALITY]; - Int_t fCentralityArrayBinsForCorrections; - - TH1* fCentralityWeights; // for centrality flattening - - AliPIDResponse *fPIDResponse; //! PID response object - AliPIDCombined *fPIDCombined; //! combined PID object - - kParticleOfInterest fParticleOfInterest;//analyzed particle - kDetectorUsedForPID fPidDetectorConfig;//used detector for PID - - Bool_t fUsePID; //flag to use PID - Bool_t fUsePIDnSigma;//flag to use nsigma method for PID - Bool_t fUsePIDPropabilities;//flag to use probability method for PID - Double_t fPIDNSigma;//nsigma cut for PID - Double_t fMinAcceptedPIDProbability;//probability cut for PID - - Bool_t fElectronRejection;//flag to use electron rejection - Bool_t fElectronOnlyRejection;//flag to use electron rejection with exclusive electron PID (no other particle in nsigma range) - Double_t fElectronRejectionNSigma;//nsigma cut for electron rejection - Double_t fElectronRejectionMinPt;//minimum pt for electron rejection (default = 0.) - Double_t fElectronRejectionMaxPt;//maximum pt for electron rejection (default = 1000.) - //============PID============// - - AliESDtrackCuts *fESDtrackCuts; //ESD track cuts - - TString fCentralityEstimator; //"V0M","TRK","TKL","ZDC","FMD" - Bool_t fUseCentrality;//use the centrality (PbPb) or not (pp) - Double_t fCentralityPercentileMin;//centrality percentile min - Double_t fCentralityPercentileMax;//centrality percentile max - Double_t fImpactParameterMin;//impact parameter min (used for MC) - Double_t fImpactParameterMax;//impact parameter max (used for MC) - - TString fMultiplicityEstimator;//"V0M","V0A","V0C","TPC" - Bool_t fUseMultiplicity;//use the multiplicity cuts - Double_t fNumberOfAcceptedTracksMin;//min. number of number of accepted tracks (used for the multiplicity dependence study - pp) - Double_t fNumberOfAcceptedTracksMax;//max. number of number of accepted tracks (used for the multiplicity dependence study - pp) - TH2F *fHistNumberOfAcceptedTracks;//hisot to store the number of accepted tracks - TH1F *fHistMultiplicity;//hisot to store the number of accepted tracks //++++++++++++++++++ - - Bool_t fUseOfflineTrigger;//Usage of the offline trigger selection - Bool_t fCheckFirstEventInChunk;//Usage of the "First Event in Chunk" check (not needed for new productions) - Bool_t fCheckPileUp;//Usage of the "Pile-Up" event check - Bool_t fCheckPrimaryFlagAOD;// Usage of check on AliAODtrack::kPrimary (default = OFF) - Bool_t fUseMCforKinematics;//Usage of MC information for filling the kinematics information of particles (only in MCAODrec mode) - - Double_t fVxMax;//vxmax - Double_t fVyMax;//vymax - Double_t fVzMax;//vzmax - - Int_t fnAODtrackCutBit;//track cut bit from track selection (only used for AODs) - - Double_t fPtMin;//only used for AODs - Double_t fPtMax;//only used for AODs - Double_t fPtMinForCorrections;//only used for AODs - Double_t fPtMaxForCorrections;//only used for AODs - Double_t fPtBinForCorrections; //=================================correction - Double_t fEtaMin;//only used for AODs - Double_t fEtaMax;//only used for AODs - Double_t fEtaMinForCorrections;//only used for AODs - Double_t fEtaMaxForCorrections;//only used for AODs - Double_t fEtaBinForCorrections; //=================================correction - Double_t fPhiMin; //=================================correction - Double_t fPhiMax; //=================================correction - Double_t fPhiMinForCorrections;//only used for AODs - Double_t fPhiMaxForCorrections;//only used for AODs - Double_t fPhiBinForCorrections; //=================================correction - - Double_t fDCAxyCut;//only used for AODs - Double_t fDCAzCut;//only used for AODs - - Double_t fTPCchi2Cut;//only used for AODs - Int_t fNClustersTPCCut;//only used for AODs - - TF1 *fAcceptanceParameterization;//acceptance filter used for MC - - TF1 *fDifferentialV2;//pt-differential v2 (from real data) - Bool_t fUseFlowAfterBurner;//Usage of a flow after burner - - Bool_t fExcludeResonancesInMC;//flag to exclude the resonances' decay products (and conversion) from the MC analysis - Bool_t fExcludeElectronsInMC;//flag to exclude the electrons from the MC analysis - Bool_t fUseMCPdgCode; //Boolean to analyze a set of particles in MC - Int_t fPDGCodeToBeAnalyzed; //Analyze a set of particles in MC - TString fEventClass; //Can be "EventPlane", "Centrality", "Multiplicity" - TString fCustomBinning;//for setting customized binning (for output AliTHn of AliBalancePsi) - - //VZERO calibration - TH1F *fHistVZEROAGainEqualizationMap;//VZERO calibration map - TH1F *fHistVZEROCGainEqualizationMap;//VZERO calibration map - TH2F *fHistVZEROChannelGainEqualizationMap; //VZERO calibration map - - AliAnalysisTaskBFPsi(const AliAnalysisTaskBFPsi&); // not implemented - AliAnalysisTaskBFPsi& operator=(const AliAnalysisTaskBFPsi&); // not implemented - - ClassDef(AliAnalysisTaskBFPsi, 6); // example of analysis -}; - - - -#endif +#ifndef ALIANALYSISTASKBFPSI_H +#define ALIANALYSISTASKBFPSI_H + +// Analysis task for the BF vs Psi code +// Authors: Panos Cristakoglou@cern.ch + +class TList; +class TH1F; +class TH2F; +class TH3F; +class TF1; +class TH3D; + +class AliBalancePsi; +class AliESDtrackCuts; +class AliEventPoolManager; + + +#include "AliAnalysisTaskSE.h" +#include "AliBalancePsi.h" + +#include "AliPID.h" +#include "AliPIDResponse.h" +#include "AliPIDCombined.h" + +//================================correction +#define kCENTRALITY 101 +//const Double_t centralityArrayForPbPb[kCENTRALITY+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; +//const TString centralityArrayForPbPb_string[kCENTRALITY] = {"0-5","5-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80"}; +//================================correction + +class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE { + public: + AliAnalysisTaskBFPsi(const char *name = "AliAnalysisTaskBFPsi"); + virtual ~AliAnalysisTaskBFPsi(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void FinishTaskOutput(); + virtual void Terminate(Option_t *); + + //========================correction + virtual void SetInputCorrection(TString filename, + Int_t nCentralityBins, + Double_t *centralityArrayForCorrections); + //========================correction + // void SetDebugLevel() {fDebugLevel = kTRUE;} //hides overloaded virtual function + + void SetAnalysisObject(AliBalancePsi *const analysis) { + fBalance = analysis; + } + void SetShufflingObject(AliBalancePsi *const analysisShuffled) { + fRunShuffling = kTRUE; + fShuffledBalance = analysisShuffled; + } + void SetMixingObject(AliBalancePsi *const analysisMixed) { + fRunMixing = kTRUE; + fMixedBalance = analysisMixed; + } + void SetMixingWithEventPlane(Bool_t bMixingWithEventPlane = kTRUE) { fRunMixingEventPlane = bMixingWithEventPlane; } + void SetMixingTracks(Int_t tracks) { fMixingTracks = tracks; } + void SetAnalysisCutObject(AliESDtrackCuts *const trackCuts) { + fESDtrackCuts = trackCuts;} + void SetVertexDiamond(Double_t vx, Double_t vy, Double_t vz) { + fVxMax = vx; + fVyMax = vy; + fVzMax = vz; + } + + //==============AOD analysis==============// + void SetAODtrackCutBit(Int_t bit){ + fnAODtrackCutBit = bit; + } + + void SetKinematicsCutsAOD(Double_t ptmin, Double_t ptmax, Double_t etamin, Double_t etamax){ + fPtMin = ptmin; fPtMax = ptmax; + fEtaMin = etamin; fEtaMax = etamax; + } + + void SetExtraDCACutsAOD(Double_t DCAxy, Double_t DCAz){ + fDCAxyCut = DCAxy; + fDCAzCut = DCAz; + } + + void SetExtraTPCCutsAOD(Double_t maxTPCchi2, Int_t minNClustersTPC){ + fTPCchi2Cut = maxTPCchi2; + fNClustersTPCCut = minNClustersTPC; + } + + //==============MC analysis==============// + void SetKinematicsCutsMC(Double_t ptmin, Double_t ptmax, + Double_t etamin, Double_t etamax){ + fPtMin = ptmin; fPtMax = ptmax; + fEtaMin = etamin; fEtaMax = etamax; + } + void UseFlowAfterBurner(TF1 *gDifferentialV2) { + fDifferentialV2 = gDifferentialV2; + fUseFlowAfterBurner = kTRUE; + } + void ExcludeResonancesInMC() {fExcludeResonancesInMC = kTRUE;} + void ExcludeElectronsInMC() {fExcludeElectronsInMC = kTRUE;} + + void SetPDGCode(Int_t gPdgCode) { + fUseMCPdgCode = kTRUE; + fPDGCodeToBeAnalyzed = gPdgCode; + } + + //Centrality + void SetCentralityEstimator(const char* centralityEstimator) {fCentralityEstimator = centralityEstimator;} + const char* GetCentralityEstimator(void) const {return fCentralityEstimator;} + void SetCentralityPercentileRange(Double_t min, Double_t max) { + fUseCentrality = kTRUE; + fCentralityPercentileMin=min; + fCentralityPercentileMax=max; + } + void SetImpactParameterRange(Double_t min, Double_t max) { + fUseCentrality = kTRUE; + fImpactParameterMin=min; + fImpactParameterMax=max; + } + + //multiplicity + void SetMultiplicityEstimator(const char* multiplicityEstimator) {fMultiplicityEstimator = multiplicityEstimator;} + const char* GetMultiplicityEstimator(void) const {return fMultiplicityEstimator;} + void SetMultiplicityRange(Double_t min, Double_t max) { + fUseMultiplicity = kTRUE; + fNumberOfAcceptedTracksMin = min; + fNumberOfAcceptedTracksMax = max;} + + // additional event cuts (default = kFALSE) + void UseOfflineTrigger() {fUseOfflineTrigger = kTRUE;} + void CheckFirstEventInChunk() {fCheckFirstEventInChunk = kTRUE;} + void CheckPileUp() {fCheckPileUp = kTRUE;} + void CheckPrimaryFlagAOD() {fCheckPrimaryFlagAOD = kTRUE;} + void UseMCforKinematics() {fUseMCforKinematics = kTRUE;} + void SetCentralityWeights(TH1* hist) { fCentralityWeights = hist; } + Bool_t AcceptEventCentralityWeight(Double_t centrality); + + + //Acceptance filter + void SetAcceptanceParameterization(TF1 *parameterization) { + fAcceptanceParameterization = parameterization;} + + //pid + enum kDetectorUsedForPID { kTPCpid, kTOFpid, kTPCTOF }; // default TPC & TOF pid (via GetTPCpid & GetTOFpid) + enum kParticleOfInterest { kMuon, kElectron, kPion, kKaon, kProton }; + + void SetUseBayesianPID(Double_t gMinProbabilityValue) { + fUsePID = kTRUE; fUsePIDnSigma = kFALSE; fUsePIDPropabilities = kTRUE; + fMinAcceptedPIDProbability = gMinProbabilityValue; } + + void SetUseNSigmaPID(Double_t gMaxNSigma) { + fUsePID = kTRUE; fUsePIDPropabilities = kFALSE; fUsePIDnSigma = kTRUE; + fPIDNSigma = gMaxNSigma; } + + void SetParticleOfInterest(kParticleOfInterest poi) { + fParticleOfInterest = poi;} + void SetDetectorUsedForPID(kDetectorUsedForPID detConfig) { + fPidDetectorConfig = detConfig;} + void SetEventClass(TString receivedEventClass){ + fEventClass = receivedEventClass; + } + + void SetCustomBinning(TString receivedCustomBinning) { fCustomBinning = receivedCustomBinning; } + + + // electron rejection + void SetElectronRejection(Double_t gMaxNSigma){ + fElectronRejection = kTRUE; + fElectronRejectionNSigma = gMaxNSigma; + } + + void SetElectronOnlyRejection(Double_t gMaxNSigma){ + fElectronRejection = kTRUE; + fElectronOnlyRejection = kTRUE; + fElectronRejectionNSigma = gMaxNSigma; + } + + void SetElectronRejectionPt(Double_t minPt,Double_t maxPt){ + fElectronRejectionMinPt = minPt; + fElectronRejectionMaxPt = maxPt; + } + + void SetVZEROCalibrationFile(const char* filename, const char* lhcPeriod); + + private: + Double_t IsEventAccepted(AliVEvent* event); + Double_t GetRefMultiOrCentrality(AliVEvent* event); + Double_t GetReferenceMultiplicityFromAOD(AliVEvent* event); + Double_t GetEventPlane(AliVEvent* event); + //===============================correction + Double_t GetTrackbyTrackCorrectionMatrix(Double_t vEta, + Double_t vPhi, + Double_t vPt, + Short_t vCharge, + Double_t gCentrality); + //===============================correction + TObjArray* GetAcceptedTracks(AliVEvent* event, Double_t gCentrality, Double_t gReactionPlane); + TObjArray* GetShuffledTracks(TObjArray* tracks, Double_t gCentrality); + + Double_t GetChannelEqualizationFactor(Int_t run, Int_t channel); + Double_t GetEqualizationFactor(Int_t run, const char *side); + + Bool_t fDebugLevel; // debug level + + TClonesArray* fArrayMC; //! AOD object //+++++++++++++++++++++ + AliBalancePsi *fBalance; //BF object + Bool_t fRunShuffling;//run shuffling or not + AliBalancePsi *fShuffledBalance; //BF object (shuffled) + Bool_t fRunMixing;//run mixing or not + Bool_t fRunMixingEventPlane;//run mixing with Event Plane + Int_t fMixingTracks; + AliBalancePsi *fMixedBalance; //TriggeredBF object (mixed) + AliEventPoolManager* fPoolMgr; //! event pool manager + + TList *fList; //fList object + TList *fListBF; //fList object + TList *fListBFS; //fList object + TList *fListBFM; //fList object + TList *fHistListPIDQA; //! list of histograms + + TH2F *fHistEventStats; //event stats + TH2F *fHistCentStats; //centrality stats + TH2F *fHistCentStatsUsed; //centrality stats USED +++++++++++++++++++++++ + TH1F *fHistTriggerStats; //trigger stats + TH1F *fHistTrackStats; //Track filter bit stats + TH1F *fHistVx; //x coordinate of the primary vertex + TH1F *fHistVy; //y coordinate of the primary vertex + TH2F *fHistVz; //z coordinate of the primary vertex + + TH2F *fHistTPCvsVZEROMultiplicity; //VZERO vs TPC reference multiplicity + TH2F *fHistVZEROSignal; //VZERO channel vs signal + + TH2F *fHistEventPlane; //event plane distribution + + TH2F *fHistClus;//number of clusters (QA histogram) + TH2F *fHistDCA;//DCA (QA histogram) + TH2F *fHistChi2;//track chi2 (QA histogram) + TH2F *fHistPt;//transverse momentum (QA histogram) + TH2F *fHistEta;//pseudorapidity (QA histogram) + TH2F *fHistRapidity;//rapidity (QA histogram) + TH2F *fHistPhi;//phi (QA histogram) + TH3F *fHistEtaPhiPos;//eta-phi pos particles (QA histogram) + TH3F *fHistEtaPhiNeg;//eta-phi neg particles (QA histogram) + TH2F *fHistPhiBefore;//phi before v2 afterburner (QA histogram) + TH2F *fHistPhiAfter;//phi after v2 afterburner (QA histogram) + TH2F *fHistPhiPos;//phi for positive particles (QA histogram) + TH2F *fHistPhiNeg;//phi for negative particles (QA histogram) + TH2F *fHistV0M;//V0 multiplicities (QA histogram) + TH2F *fHistRefTracks;//reference track multiplicities (QA histogram) + + //============PID============// + TH2D *fHistdEdxVsPTPCbeforePID;//TPC dEdx vs momentum before PID cuts (QA histogram) + TH2D *fHistBetavsPTOFbeforePID;//beta vs momentum before PID cuts (QA histogram) + TH2D *fHistProbTPCvsPtbeforePID; //TPC probability vs pT before PID cuts (QA histogram) + TH2D *fHistProbTOFvsPtbeforePID;//TOF probability vs pT before PID cuts (QA histogram) + TH2D *fHistProbTPCTOFvsPtbeforePID;//TOF/TPC probability vs pT before PID cuts (QA histogram) + TH2D *fHistNSigmaTPCvsPtbeforePID;//TPC nsigma vs pT before PID cuts (QA histogram) + TH2D *fHistNSigmaTOFvsPtbeforePID;//TOF nsigma vs pT before PID cuts (QA histogram) + TH2D *fHistBetaVsdEdXbeforePID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ + TH2D *fHistNSigmaTPCTOFvsPtbeforePID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ + TH2D *fHistdEdxVsPTPCafterPID;//TPC dEdx vs momentum after PID cuts (QA histogram) + TH2D *fHistBetavsPTOFafterPID;//beta vs momentum after PID cuts (QA histogram) + TH2D *fHistProbTPCvsPtafterPID; //TPC probability vs pT after PID cuts (QA histogram) + TH2D *fHistProbTOFvsPtafterPID;//TOF probability vs pT after PID cuts (QA histogram) + TH2D *fHistProbTPCTOFvsPtafterPID;//TOF/TPC probability vs pT after PID cuts (QA histogram) + TH2D *fHistNSigmaTPCvsPtafterPID;//TPC nsigma vs pT after PID cuts (QA histogram) + TH2D *fHistNSigmaTOFvsPtafterPID;//TOF nsigma vs pT after PID cuts (QA histogram) + TH2D *fHistBetaVsdEdXafterPID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ + TH2D *fHistNSigmaTPCTOFvsPtafterPID;//TPCTOF before PID cuts (QA histogram)//+++++++++++++++++++++ + + TH2D *fHistdEdxVsPTPCbeforePIDelectron; //+++++++ + TH2D *fHistNSigmaTPCvsPtbeforePIDelectron; //+++++++ + TH2D *fHistdEdxVsPTPCafterPIDelectron; //+++++++ + TH2D *fHistNSigmaTPCvsPtafterPIDelectron; //+++++++ + + TH3F *fHistCorrectionPlus[kCENTRALITY]; //====correction + TH3F *fHistCorrectionMinus[kCENTRALITY]; //===correction + Double_t fCentralityArrayForCorrections[kCENTRALITY]; + Int_t fCentralityArrayBinsForCorrections; + + TH1* fCentralityWeights; // for centrality flattening + + AliPIDResponse *fPIDResponse; //! PID response object + AliPIDCombined *fPIDCombined; //! combined PID object + + kParticleOfInterest fParticleOfInterest;//analyzed particle + kDetectorUsedForPID fPidDetectorConfig;//used detector for PID + + Bool_t fUsePID; //flag to use PID + Bool_t fUsePIDnSigma;//flag to use nsigma method for PID + Bool_t fUsePIDPropabilities;//flag to use probability method for PID + Double_t fPIDNSigma;//nsigma cut for PID + Double_t fMinAcceptedPIDProbability;//probability cut for PID + + Bool_t fElectronRejection;//flag to use electron rejection + Bool_t fElectronOnlyRejection;//flag to use electron rejection with exclusive electron PID (no other particle in nsigma range) + Double_t fElectronRejectionNSigma;//nsigma cut for electron rejection + Double_t fElectronRejectionMinPt;//minimum pt for electron rejection (default = 0.) + Double_t fElectronRejectionMaxPt;//maximum pt for electron rejection (default = 1000.) + //============PID============// + + AliESDtrackCuts *fESDtrackCuts; //ESD track cuts + + TString fCentralityEstimator; //"V0M","TRK","TKL","ZDC","FMD" + Bool_t fUseCentrality;//use the centrality (PbPb) or not (pp) + Double_t fCentralityPercentileMin;//centrality percentile min + Double_t fCentralityPercentileMax;//centrality percentile max + Double_t fImpactParameterMin;//impact parameter min (used for MC) + Double_t fImpactParameterMax;//impact parameter max (used for MC) + + TString fMultiplicityEstimator;//"V0M","V0A","V0C","TPC" + Bool_t fUseMultiplicity;//use the multiplicity cuts + Double_t fNumberOfAcceptedTracksMin;//min. number of number of accepted tracks (used for the multiplicity dependence study - pp) + Double_t fNumberOfAcceptedTracksMax;//max. number of number of accepted tracks (used for the multiplicity dependence study - pp) + TH2F *fHistNumberOfAcceptedTracks;//hisot to store the number of accepted tracks + TH1F *fHistMultiplicity;//hisot to store the number of accepted tracks //++++++++++++++++++ + + Bool_t fUseOfflineTrigger;//Usage of the offline trigger selection + Bool_t fCheckFirstEventInChunk;//Usage of the "First Event in Chunk" check (not needed for new productions) + Bool_t fCheckPileUp;//Usage of the "Pile-Up" event check + Bool_t fCheckPrimaryFlagAOD;// Usage of check on AliAODtrack::kPrimary (default = OFF) + Bool_t fUseMCforKinematics;//Usage of MC information for filling the kinematics information of particles (only in MCAODrec mode) + + Double_t fVxMax;//vxmax + Double_t fVyMax;//vymax + Double_t fVzMax;//vzmax + + Int_t fnAODtrackCutBit;//track cut bit from track selection (only used for AODs) + + Double_t fPtMin;//only used for AODs + Double_t fPtMax;//only used for AODs + Double_t fPtMinForCorrections;//only used for AODs + Double_t fPtMaxForCorrections;//only used for AODs + Double_t fPtBinForCorrections; //=================================correction + Double_t fEtaMin;//only used for AODs + Double_t fEtaMax;//only used for AODs + Double_t fEtaMinForCorrections;//only used for AODs + Double_t fEtaMaxForCorrections;//only used for AODs + Double_t fEtaBinForCorrections; //=================================correction + Double_t fPhiMin; //=================================correction + Double_t fPhiMax; //=================================correction + Double_t fPhiMinForCorrections;//only used for AODs + Double_t fPhiMaxForCorrections;//only used for AODs + Double_t fPhiBinForCorrections; //=================================correction + + Double_t fDCAxyCut;//only used for AODs + Double_t fDCAzCut;//only used for AODs + + Double_t fTPCchi2Cut;//only used for AODs + Int_t fNClustersTPCCut;//only used for AODs + + TF1 *fAcceptanceParameterization;//acceptance filter used for MC + + TF1 *fDifferentialV2;//pt-differential v2 (from real data) + Bool_t fUseFlowAfterBurner;//Usage of a flow after burner + + Bool_t fExcludeResonancesInMC;//flag to exclude the resonances' decay products (and conversion) from the MC analysis + Bool_t fExcludeElectronsInMC;//flag to exclude the electrons from the MC analysis + Bool_t fUseMCPdgCode; //Boolean to analyze a set of particles in MC + Int_t fPDGCodeToBeAnalyzed; //Analyze a set of particles in MC + TString fEventClass; //Can be "EventPlane", "Centrality", "Multiplicity" + TString fCustomBinning;//for setting customized binning (for output AliTHn of AliBalancePsi) + + //VZERO calibration + TH1F *fHistVZEROAGainEqualizationMap;//VZERO calibration map + TH1F *fHistVZEROCGainEqualizationMap;//VZERO calibration map + TH2F *fHistVZEROChannelGainEqualizationMap; //VZERO calibration map + + AliAnalysisTaskBFPsi(const AliAnalysisTaskBFPsi&); // not implemented + AliAnalysisTaskBFPsi& operator=(const AliAnalysisTaskBFPsi&); // not implemented + + ClassDef(AliAnalysisTaskBFPsi, 6); // example of analysis +}; + + + +#endif diff --git a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEventMixingBF.cxx b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEventMixingBF.cxx index 31fdd9d4c78..ee6c1d29b86 100755 --- a/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEventMixingBF.cxx +++ b/PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEventMixingBF.cxx @@ -1,692 +1,692 @@ -#include "TChain.h" -#include "TList.h" -#include "TCanvas.h" -#include "TLorentzVector.h" -#include "TGraphErrors.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TArrayF.h" -#include "TF1.h" -#include "TRandom.h" - -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" - -#include "AliESDVertex.h" -#include "AliESDEvent.h" -#include "AliESDInputHandler.h" -#include "AliAODEvent.h" -#include "AliAODTrack.h" -#include "AliAODInputHandler.h" -#include "AliGenEventHeader.h" -#include "AliGenHijingEventHeader.h" -#include "AliMCEventHandler.h" -#include "AliMCEvent.h" -#include "AliMixInputEventHandler.h" -#include "AliStack.h" -#include "AliESDtrackCuts.h" - -#include "TH2D.h" -#include "AliPID.h" -#include "AliPIDResponse.h" -#include "AliPIDCombined.h" - -#include "AliAnalysisTaskEventMixingBF.h" -#include "AliBalanceEventMixing.h" - - -// Analysis task for the EventMixingBF code -// Authors: Panos.Christakoglou@nikhef.nl, m.weber@cern.ch - -ClassImp(AliAnalysisTaskEventMixingBF) - -//________________________________________________________________________ -AliAnalysisTaskEventMixingBF::AliAnalysisTaskEventMixingBF(const char *name) -: AliAnalysisTaskSE(name), - fBalance(0), - fRunShuffling(kFALSE), - fShuffledBalance(0), - fList(0), - fListEventMixingBF(0), - fListEventMixingBFS(0), - fHistListPIDQA(0), - fHistEventStats(0), - fHistCentStats(0), - fHistTriggerStats(0), - fHistTrackStats(0), - fHistVx(0), - fHistVy(0), - fHistVz(0), - fHistClus(0), - fHistDCA(0), - fHistChi2(0), - fHistPt(0), - fHistEta(0), - fHistPhi(0), - fHistPhiBefore(0), - fHistPhiAfter(0), - fHistV0M(0), - fHistRefTracks(0), - fHistdEdxVsPTPCbeforePID(NULL), - fHistBetavsPTOFbeforePID(NULL), - fHistProbTPCvsPtbeforePID(NULL), - fHistProbTOFvsPtbeforePID(NULL), - fHistProbTPCTOFvsPtbeforePID(NULL), - fHistNSigmaTPCvsPtbeforePID(NULL), - fHistNSigmaTOFvsPtbeforePID(NULL), - fHistdEdxVsPTPCafterPID(NULL), - fHistBetavsPTOFafterPID(NULL), - fHistProbTPCvsPtafterPID(NULL), - fHistProbTOFvsPtafterPID(NULL), - fHistProbTPCTOFvsPtafterPID(NULL), - fHistNSigmaTPCvsPtafterPID(NULL), - fHistNSigmaTOFvsPtafterPID(NULL), - fPIDResponse(0x0), - fPIDCombined(0x0), - fParticleOfInterest(kPion), - fPidDetectorConfig(kTPCTOF), - fUsePID(kFALSE), - fUsePIDnSigma(kTRUE), - fUsePIDPropabilities(kFALSE), - fPIDNSigma(3.), - fMinAcceptedPIDProbability(0.8), - fESDtrackCuts(0), - fCentralityEstimator("V0M"), - fUseCentrality(kFALSE), - fCentralityPercentileMin(0.), - fCentralityPercentileMax(5.), - fImpactParameterMin(0.), - fImpactParameterMax(20.), - fUseMultiplicity(kFALSE), - fNumberOfAcceptedTracksMin(0), - fNumberOfAcceptedTracksMax(10000), - fHistNumberOfAcceptedTracks(0), - fUseOfflineTrigger(kFALSE), - fVxMax(0.3), - fVyMax(0.3), - fVzMax(10.), - nAODtrackCutBit(128), - fPtMin(0.3), - fPtMax(1.5), - fEtaMin(-0.8), - fEtaMax(-0.8), - fDCAxyCut(-1), - fDCAzCut(-1), - fTPCchi2Cut(-1), - fNClustersTPCCut(-1), - fAcceptanceParameterization(0), - fDifferentialV2(0), - fUseFlowAfterBurner(kFALSE), - fExcludeResonancesInMC(kFALSE), - fUseMCPdgCode(kFALSE), - fPDGCodeToBeAnalyzed(-1), - fMainEvent(0x0), - fMixEvent(0x0) -{ - // Constructor - // Define input and output slots here - // Input slot #0 works with a TChain - DefineInput(0, TChain::Class()); - // Output slot #0 writes into a TH1 container - DefineOutput(1, TList::Class()); - DefineOutput(2, TList::Class()); - DefineOutput(3, TList::Class()); - DefineOutput(4, TList::Class()); -} - -//________________________________________________________________________ -AliAnalysisTaskEventMixingBF::~AliAnalysisTaskEventMixingBF() { - - // delete fBalance; - // delete fShuffledBalance; - // delete fList; - // delete fListEventMixingBF; - // delete fListEventMixingBFS; - - // delete fHistEventStats; - // delete fHistTrackStats; - // delete fHistVx; - // delete fHistVy; - // delete fHistVz; - - // delete fHistClus; - // delete fHistDCA; - // delete fHistChi2; - // delete fHistPt; - // delete fHistEta; - // delete fHistPhi; - // delete fHistV0M; -} - -//________________________________________________________________________ -void AliAnalysisTaskEventMixingBF::UserCreateOutputObjects() { - // Create histograms - // Called once - if(!fBalance) { - fBalance = new AliBalanceEventMixing(); - fBalance->SetAnalysisLevel("ESD"); - //fBalance->SetNumberOfBins(-1,16); - fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6); - } - if(fRunShuffling) { - if(!fShuffledBalance) { - fShuffledBalance = new AliBalanceEventMixing(); - fShuffledBalance->SetAnalysisLevel("ESD"); - //fShuffledBalance->SetNumberOfBins(-1,16); - fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6); - } - } - - //QA list - fList = new TList(); - fList->SetName("listQA"); - fList->SetOwner(); - - //Balance Function list - fListEventMixingBF = new TList(); - fListEventMixingBF->SetName("listEventMixingBF"); - fListEventMixingBF->SetOwner(); - - if(fRunShuffling) { - fListEventMixingBFS = new TList(); - fListEventMixingBFS->SetName("listEventMixingBFShuffled"); - fListEventMixingBFS->SetOwner(); - } - - //PID QA list - if(fUsePID) { - fHistListPIDQA = new TList(); - fHistListPIDQA->SetName("listQAPID"); - fHistListPIDQA->SetOwner(); - } - - //Event stats. - TString gCutName[4] = {"Total","Offline trigger", - "Vertex","Analyzed"}; - fHistEventStats = new TH1F("fHistEventStats", - "Event statistics;;N_{events}", - 4,0.5,4.5); - for(Int_t i = 1; i <= 4; i++) - fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); - fList->Add(fHistEventStats); - - TString gCentName[9] = {"V0M","FMD","TRK","TKL","CL0","CL1","V0MvsFMD","TKLvsV0M","ZEMvsZDC"}; - fHistCentStats = new TH2F("fHistCentStats", - "Centrality statistics;;Cent percentile", - 9,-0.5,8.5,220,-5,105); - for(Int_t i = 1; i <= 9; i++) - fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); - fList->Add(fHistCentStats); - - fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",130,0,130); - fList->Add(fHistTriggerStats); - - fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",130,0,130); - fList->Add(fHistTrackStats); - - fHistNumberOfAcceptedTracks = new TH1F("fHistNumberOfAcceptedTracks",";N_{acc.};Entries",4001,-0.5,4000.5); - fList->Add(fHistNumberOfAcceptedTracks); - - // Vertex distributions - fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5); - fList->Add(fHistVx); - fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5); - fList->Add(fHistVy); - fHistVz = new TH1F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Entries",100,-20.,20.); - fList->Add(fHistVz); - - // QA histograms - fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200); - fList->Add(fHistClus); - fHistChi2 = new TH1F("fHistChi2","Chi2/NDF distribution",200,0,10); - fList->Add(fHistChi2); - fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5); - fList->Add(fHistDCA); - fHistPt = new TH1F("fHistPt","p_{T} distribution",200,0,10); - fList->Add(fHistPt); - fHistEta = new TH1F("fHistEta","#eta distribution",200,-2,2); - fList->Add(fHistEta); - fHistPhi = new TH1F("fHistPhi","#phi distribution",200,-20,380); - fList->Add(fHistPhi); - fHistPhiBefore = new TH1F("fHistPhiBefore","#phi distribution",200,0.,2*TMath::Pi()); - fList->Add(fHistPhiBefore); - fHistPhiAfter = new TH1F("fHistPhiAfter","#phi distribution",200,0.,2*TMath::Pi()); - fList->Add(fHistPhiAfter); - fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000); - fList->Add(fHistV0M); - TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"}; - fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000); - for(Int_t i = 1; i <= 6; i++) - fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data()); - fList->Add(fHistRefTracks); - - // Balance function histograms - // Initialize histograms if not done yet - if(!fBalance->GetHistNp(0)){ - AliWarning("Histograms not yet initialized! --> Will be done now"); - AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction"); - fBalance->InitHistograms(); - } - - if(fRunShuffling) { - if(!fShuffledBalance->GetHistNp(0)) { - AliWarning("Histograms (shuffling) not yet initialized! --> Will be done now"); - AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction"); - fShuffledBalance->InitHistograms(); - } - } - - for(Int_t a = 0; a < ANALYSIS_TYPES; a++){ - fListEventMixingBF->Add(fBalance->GetHistNp(a)); - fListEventMixingBF->Add(fBalance->GetHistNn(a)); - fListEventMixingBF->Add(fBalance->GetHistNpn(a)); - fListEventMixingBF->Add(fBalance->GetHistNnn(a)); - fListEventMixingBF->Add(fBalance->GetHistNpp(a)); - fListEventMixingBF->Add(fBalance->GetHistNnp(a)); - - if(fRunShuffling) { - fListEventMixingBFS->Add(fShuffledBalance->GetHistNp(a)); - fListEventMixingBFS->Add(fShuffledBalance->GetHistNn(a)); - fListEventMixingBFS->Add(fShuffledBalance->GetHistNpn(a)); - fListEventMixingBFS->Add(fShuffledBalance->GetHistNnn(a)); - fListEventMixingBFS->Add(fShuffledBalance->GetHistNpp(a)); - fListEventMixingBFS->Add(fShuffledBalance->GetHistNnp(a)); - } - } - - if(fESDtrackCuts) fList->Add(fESDtrackCuts); - - //====================PID========================// - if(fUsePID) { - fPIDCombined = new AliPIDCombined(); - fPIDCombined->SetDefaultTPCPriors(); - - fHistdEdxVsPTPCbeforePID = new TH2D ("dEdxVsPTPCbefore","dEdxVsPTPCbefore", 1000, -10.0, 10.0, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePID); //addition - - fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetavsPTOFbeforePID); //addition - - fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID); //addition - - fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID); //addition - - fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID); //addition - - fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID); //addition - - fHistNSigmaTOFvsPtbeforePID = new TH2D ("NSigmaTOFvsPtbefore","NSigmaTOFvsPtbefore", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTOFvsPtbeforePID); //addition - - fHistdEdxVsPTPCafterPID = new TH2D ("dEdxVsPTPCafter","dEdxVsPTPCafter", 1000, -10, 10, 1000, 0, 1000); - fHistListPIDQA->Add(fHistdEdxVsPTPCafterPID); //addition - - fHistBetavsPTOFafterPID = new TH2D ("BetavsPTOFafter","BetavsPTOFafter", 1000, -10, 10, 1000, 0, 1.2); - fHistListPIDQA->Add(fHistBetavsPTOFafterPID); //addition - - fHistProbTPCvsPtafterPID = new TH2D ("ProbTPCvsPtafter","ProbTPCvsPtafter", 1000, -10, 10, 1000, 0, 2); - fHistListPIDQA->Add(fHistProbTPCvsPtafterPID); //addition - - fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000, -10, 10, 1000, 0, 2); - fHistListPIDQA->Add(fHistProbTOFvsPtafterPID); //addition - - fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0); - fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID); //addition - - fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID); //addition - - fHistNSigmaTOFvsPtafterPID = new TH2D ("NSigmaTOFvsPtafter","NSigmaTOFvsPtafter", 1000, -10, 10, 1000, 0, 500); - fHistListPIDQA->Add(fHistNSigmaTOFvsPtafterPID); //addition - } - //====================PID========================// - - // Post output data. - PostData(1, fList); - PostData(2, fListEventMixingBF); - if(fRunShuffling) PostData(3, fListEventMixingBFS); - if(fUsePID) PostData(4, fHistListPIDQA); //PID -} - -//________________________________________________________________________ -void AliAnalysisTaskEventMixingBF::UserExec(Option_t *) { - // Main loop - // Called for each event - // NOTHING TO DO for event mixing! -} - -//________________________________________________________________________ -void AliAnalysisTaskEventMixingBF::FinishTaskOutput(){ - //Printf("END EventMixingBF"); - - if (!fBalance) { - AliError("ERROR: fBalance not available"); - return; - } - if(fRunShuffling) { - if (!fShuffledBalance) { - AliError("ERROR: fShuffledBalance not available"); - return; - } - } - -} - -//________________________________________________________________________ -void AliAnalysisTaskEventMixingBF::Terminate(Option_t *) { - // Draw result to the screen - // Called once at the end of the query - - // not implemented ... - -} - -void AliAnalysisTaskEventMixingBF::UserExecMix(Option_t *) -{ - // Main loop for event mixing - - TString gAnalysisLevel = fBalance->GetAnalysisLevel(); - - AliMixInputEventHandler *mixIEH = SetupEventsForMixing(); - - Float_t fCentrality = 0.; - - // for HBT like cuts need magnetic field sign - Float_t bSign = 0; // only used in AOD so far - - // vector holding the charges/kinematics of all tracks (charge,y,eta,phi,p0,p1,p2,pt,E) - vector *chargeVector[9]; // original charge - for(Int_t i = 0; i < 9; i++){ - chargeVector[i] = new vector; - } - - Double_t vCharge; - Double_t vY; - Double_t vEta; - Double_t vPhi; - Double_t vP[3]; - Double_t vPt; - Double_t vE; - - Int_t iMainTrackUsed = -1; - - // ------------------------------------------------------------- - // At the moment MIXING only for AODs - if(mixIEH){ - - //AOD analysis (vertex and track cuts also here!!!!) - if(gAnalysisLevel == "AOD") { - AliAODEvent* aodEventMain = dynamic_cast(fMainEvent); - if(!aodEventMain) { - AliError("ERROR: aodEventMain not available"); - return; - } - AliAODEvent *aodEventMix = dynamic_cast(fMixEvent); - if(!aodEventMix) { - AliError("ERROR: aodEventMix not available"); - return; - } - - // for HBT like cuts need magnetic field sign - bSign = (aodEventMain->GetMagneticField() > 0) ? 1 : -1; - - AliAODHeader *aodHeaderMain = aodEventMain->GetHeader(); - - // event selection done in AliAnalysisTaskSE::Exec() --> this is not used - fHistEventStats->Fill(1); //all events - - // this is not needed (checked in mixing handler!) - Bool_t isSelectedMain = kTRUE; - Bool_t isSelectedMix = kTRUE; - - if(fUseOfflineTrigger){ - isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); - isSelectedMix = ((AliInputEventHandler*)((AliMultiInputEventHandler *)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetFirstMultiInputHandler())->IsEventSelected(); - } - - if(isSelectedMain && isSelectedMix) { - fHistEventStats->Fill(2); //triggered events - - //Centrality stuff (centrality in AOD header) - if(fUseCentrality) { - fCentrality = aodHeaderMain->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); - - // QA for centrality estimators - fHistCentStats->Fill(0.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("V0M")); - fHistCentStats->Fill(1.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("FMD")); - fHistCentStats->Fill(2.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TRK")); - fHistCentStats->Fill(3.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TKL")); - fHistCentStats->Fill(4.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("CL0")); - fHistCentStats->Fill(5.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("CL1")); - fHistCentStats->Fill(6.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("V0MvsFMD")); - fHistCentStats->Fill(7.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TKLvsV0M")); - fHistCentStats->Fill(8.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC")); - - // take only events inside centrality class - if((fCentrality < fCentralityPercentileMin) || (fCentrality > fCentralityPercentileMax)) - return; - - // centrality QA (V0M) - fHistV0M->Fill(aodEventMain->GetVZEROData()->GetMTotV0A(), aodEventMain->GetVZEROData()->GetMTotV0C()); - - // centrality QA (reference tracks) - fHistRefTracks->Fill(0.,aodHeaderMain->GetRefMultiplicity()); - fHistRefTracks->Fill(1.,aodHeaderMain->GetRefMultiplicityPos()); - fHistRefTracks->Fill(2.,aodHeaderMain->GetRefMultiplicityNeg()); - fHistRefTracks->Fill(3.,aodHeaderMain->GetTPConlyRefMultiplicity()); - fHistRefTracks->Fill(4.,aodHeaderMain->GetNumberOfITSClusters(0)); - fHistRefTracks->Fill(5.,aodHeaderMain->GetNumberOfITSClusters(1)); - fHistRefTracks->Fill(6.,aodHeaderMain->GetNumberOfITSClusters(2)); - fHistRefTracks->Fill(7.,aodHeaderMain->GetNumberOfITSClusters(3)); - fHistRefTracks->Fill(8.,aodHeaderMain->GetNumberOfITSClusters(4)); - } - - // // this is crashing (Bug in ROOT (to be solved)) but not needed (checked in mixing handler) - // const AliAODVertex *vertexMain = aodEventMain->GetPrimaryVertex(); - // const AliAODVertex *vertexMix = aodEventMix->GetPrimaryVertex(); - - // if(vertexMain && vertexMix) { - // Double32_t fCovMain[6]; - // Double32_t fCovMix[6]; - // vertexMain->GetCovarianceMatrix(fCovMain); - // vertexMix->GetCovarianceMatrix(fCovMix); - - // if(vertexMain->GetNContributors() > 0 && vertexMix->GetNContributors() > 0) { - // if(fCovMain[5] != 0 && fCovMix[5] != 0) { - // fHistEventStats->Fill(3); //events with a proper vertex - // if(TMath::Abs(vertexMain->GetX()) < fVxMax && TMath::Abs(vertexMix->GetX()) < fVxMax ) { - // if(TMath::Abs(vertexMain->GetY()) < fVyMax && TMath::Abs(vertexMix->GetY()) < fVyMax) { - // if(TMath::Abs(vertexMain->GetZ()) < fVzMax && TMath::Abs(vertexMix->GetZ()) < fVzMax) { - // fHistEventStats->Fill(4); //analyzed events - // fHistVx->Fill(vertexMain->GetX()); - // fHistVy->Fill(vertexMain->GetY()); - // fHistVz->Fill(vertexMain->GetZ()); - - // Loop over tracks in main event - for (Int_t iTracksMain = 0; iTracksMain < aodEventMain->GetNumberOfTracks(); iTracksMain++) { - AliAODTrack* aodTrackMain = dynamic_cast(aodEventMain->GetTrack(iTracksMain)); - if (!aodTrackMain) { - AliError(Form("ERROR: Could not receive track %d", iTracksMain)); - continue; - } - - // AOD track cuts - - // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C - // take only TPC only tracks - fHistTrackStats->Fill(aodTrackMain->GetFilterMap()); - if(!aodTrackMain->TestFilterBit(nAODtrackCutBit)) continue; - - vCharge = aodTrackMain->Charge(); - vY = aodTrackMain->Y(); - vEta = aodTrackMain->Eta(); - vPhi = aodTrackMain->Phi() * TMath::RadToDeg(); - vE = aodTrackMain->E(); - vPt = aodTrackMain->Pt(); - aodTrackMain->PxPyPz(vP); - - Float_t dcaXYMain = aodTrackMain->DCA(); // this is the DCA from global track (not exactly what is cut on) - Float_t dcaZMain = aodTrackMain->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) - - - // Kinematics cuts from ESD track cuts - if( vPt < fPtMin || vPt > fPtMax) continue; - if( vEta < fEtaMin || vEta > fEtaMax) continue; - - // Extra DCA cuts (for systematic studies [!= -1]) - if( fDCAxyCut != -1 && fDCAzCut != -1){ - if(TMath::Sqrt((dcaXYMain*dcaXYMain)/(fDCAxyCut*fDCAxyCut)+(dcaZMain*dcaZMain)/(fDCAzCut*fDCAzCut)) > 1 ){ - continue; // 2D cut - } - } - - // Extra TPC cuts (for systematic studies [!= -1]) - if( fTPCchi2Cut != -1 && aodTrackMain->Chi2perNDF() > fTPCchi2Cut){ - continue; - } - if( fNClustersTPCCut != -1 && aodTrackMain->GetTPCNcls() < fNClustersTPCCut){ - continue; - } - - // fill QA histograms - fHistClus->Fill(aodTrackMain->GetITSNcls(),aodTrackMain->GetTPCNcls()); - fHistDCA->Fill(dcaZMain,dcaXYMain); - fHistChi2->Fill(aodTrackMain->Chi2perNDF()); - fHistPt->Fill(vPt); - fHistEta->Fill(vEta); - fHistPhi->Fill(vPhi); - - // fill charge vector - chargeVector[0]->push_back(vCharge); - chargeVector[1]->push_back(vY); - chargeVector[2]->push_back(vEta); - chargeVector[3]->push_back(vPhi); - chargeVector[4]->push_back(vP[0]); - chargeVector[5]->push_back(vP[1]); - chargeVector[6]->push_back(vP[2]); - chargeVector[7]->push_back(vPt); - chargeVector[8]->push_back(vE); - - // ------------------------------------------------------------- - // for each track in main event loop over all tracks in mix event - for (Int_t iTracksMix = 0; iTracksMix < aodEventMix->GetNumberOfTracks(); iTracksMix++) { - - AliAODTrack* aodTrackMix = dynamic_cast(aodEventMix->GetTrack(iTracksMix)); - if (!aodTrackMix) { - AliError(Form("ERROR: Could not receive track %d", iTracksMix)); - continue; - } - - // AOD track cuts - - // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C - // take only TPC only tracks - fHistTrackStats->Fill(aodTrackMix->GetFilterMap()); - if(!aodTrackMix->TestFilterBit(nAODtrackCutBit)) continue; - - vCharge = aodTrackMix->Charge(); - vY = aodTrackMix->Y(); - vEta = aodTrackMix->Eta(); - vPhi = aodTrackMix->Phi() * TMath::RadToDeg(); - vE = aodTrackMix->E(); - vPt = aodTrackMix->Pt(); - aodTrackMix->PxPyPz(vP); - - Float_t dcaXYMix = aodTrackMix->DCA(); // this is the DCA from global track (not exactly what is cut on) - Float_t dcaZMix = aodTrackMix->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) - - - // Kinematics cuts from ESD track cuts - if( vPt < fPtMin || vPt > fPtMax) continue; - if( vEta < fEtaMin || vEta > fEtaMax) continue; - - // Extra DCA cuts (for systematic studies [!= -1]) - if( fDCAxyCut != -1 && fDCAxyCut != -1){ - if(TMath::Sqrt((dcaXYMix*dcaXYMix)/(fDCAxyCut*fDCAxyCut)+(dcaZMix*dcaZMix)/(fDCAzCut*fDCAzCut)) > 1 ){ - continue; // 2D cut - } - } - - // Extra TPC cuts (for systematic studies [!= -1]) - if( fTPCchi2Cut != -1 && aodTrackMix->Chi2perNDF() > fTPCchi2Cut){ - continue; - } - if( fNClustersTPCCut != -1 && aodTrackMix->GetTPCNcls() < fNClustersTPCCut){ - continue; - } - - // fill QA histograms - fHistClus->Fill(aodTrackMix->GetITSNcls(),aodTrackMix->GetTPCNcls()); - fHistDCA->Fill(dcaZMix,dcaXYMix); - fHistChi2->Fill(aodTrackMix->Chi2perNDF()); - fHistPt->Fill(vPt); - fHistEta->Fill(vEta); - fHistPhi->Fill(vPhi); - - // fill charge vector - chargeVector[0]->push_back(vCharge); - chargeVector[1]->push_back(vY); - chargeVector[2]->push_back(vEta); - chargeVector[3]->push_back(vPhi); - chargeVector[4]->push_back(vP[0]); - chargeVector[5]->push_back(vP[1]); - chargeVector[6]->push_back(vP[2]); - chargeVector[7]->push_back(vPt); - chargeVector[8]->push_back(vE); - - - - } //mix track loop - - // calculate balance function for each track in main event - iMainTrackUsed++; // is needed to do no double counting in Balance Function calculation - if(iMainTrackUsed >= (Int_t)chargeVector[0]->size()) break; //do not allow more tracks than in mixed event! - fBalance->CalculateBalance(fCentrality,chargeVector,iMainTrackUsed,bSign); - // clean charge vector afterwards - for(Int_t i = 0; i < 9; i++){ - chargeVector[i]->clear(); - } - - - } //main track loop - // }//Vz cut - // }//Vy cut - // }//Vx cut - // }//proper vertexresolution - // }//proper number of contributors - // }//vertex object valid - }//triggered event - }//AOD analysis - } -} - -AliMixInputEventHandler *AliAnalysisTaskEventMixingBF::SetupEventsForMixing() { - //sets the input handlers for event mixing - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliMultiInputEventHandler *inEvHMain = dynamic_cast(mgr->GetInputEventHandler()); - if (inEvHMain) { - - AliMixInputEventHandler *mixEH = dynamic_cast(inEvHMain->GetFirstMultiInputHandler()); - if (!mixEH) return nullptr; - if (mixEH->CurrentBinIndex() < 0) { - AliDebug(AliLog::kDebug + 1, "Current event mixEH->CurrentEntry() == -1"); - return nullptr; - } - AliDebug(AliLog::kDebug, Form("Mixing %lld %d [%lld,%lld] %d", mixEH->CurrentEntry(), mixEH->CurrentBinIndex(), mixEH->CurrentEntryMain(), mixEH->CurrentEntryMix(), mixEH->NumberMixed())); - - AliInputEventHandler *ihMainCurrent = inEvHMain->GetFirstInputEventHandler(); - fMainEvent = ihMainCurrent->GetEvent(); - - AliMultiInputEventHandler *inEvHMixedCurrent = mixEH->GetFirstMultiInputHandler(); // for buffer = 1 - AliInputEventHandler *ihMixedCurrent = inEvHMixedCurrent->GetFirstInputEventHandler(); - fMixEvent = ihMixedCurrent->GetEvent(); - - return mixEH; - } - return NULL; -} +#include "TChain.h" +#include "TList.h" +#include "TCanvas.h" +#include "TLorentzVector.h" +#include "TGraphErrors.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TArrayF.h" +#include "TF1.h" +#include "TRandom.h" + +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" + +#include "AliESDVertex.h" +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" +#include "AliAODEvent.h" +#include "AliAODTrack.h" +#include "AliAODInputHandler.h" +#include "AliGenEventHeader.h" +#include "AliGenHijingEventHeader.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" +#include "AliMixInputEventHandler.h" +#include "AliStack.h" +#include "AliESDtrackCuts.h" + +#include "TH2D.h" +#include "AliPID.h" +#include "AliPIDResponse.h" +#include "AliPIDCombined.h" + +#include "AliAnalysisTaskEventMixingBF.h" +#include "AliBalanceEventMixing.h" + + +// Analysis task for the EventMixingBF code +// Authors: Panos.Christakoglou@nikhef.nl, m.weber@cern.ch + +ClassImp(AliAnalysisTaskEventMixingBF) + +//________________________________________________________________________ +AliAnalysisTaskEventMixingBF::AliAnalysisTaskEventMixingBF(const char *name) +: AliAnalysisTaskSE(name), + fBalance(0), + fRunShuffling(kFALSE), + fShuffledBalance(0), + fList(0), + fListEventMixingBF(0), + fListEventMixingBFS(0), + fHistListPIDQA(0), + fHistEventStats(0), + fHistCentStats(0), + fHistTriggerStats(0), + fHistTrackStats(0), + fHistVx(0), + fHistVy(0), + fHistVz(0), + fHistClus(0), + fHistDCA(0), + fHistChi2(0), + fHistPt(0), + fHistEta(0), + fHistPhi(0), + fHistPhiBefore(0), + fHistPhiAfter(0), + fHistV0M(0), + fHistRefTracks(0), + fHistdEdxVsPTPCbeforePID(NULL), + fHistBetavsPTOFbeforePID(NULL), + fHistProbTPCvsPtbeforePID(NULL), + fHistProbTOFvsPtbeforePID(NULL), + fHistProbTPCTOFvsPtbeforePID(NULL), + fHistNSigmaTPCvsPtbeforePID(NULL), + fHistNSigmaTOFvsPtbeforePID(NULL), + fHistdEdxVsPTPCafterPID(NULL), + fHistBetavsPTOFafterPID(NULL), + fHistProbTPCvsPtafterPID(NULL), + fHistProbTOFvsPtafterPID(NULL), + fHistProbTPCTOFvsPtafterPID(NULL), + fHistNSigmaTPCvsPtafterPID(NULL), + fHistNSigmaTOFvsPtafterPID(NULL), + fPIDResponse(0x0), + fPIDCombined(0x0), + fParticleOfInterest(kPion), + fPidDetectorConfig(kTPCTOF), + fUsePID(kFALSE), + fUsePIDnSigma(kTRUE), + fUsePIDPropabilities(kFALSE), + fPIDNSigma(3.), + fMinAcceptedPIDProbability(0.8), + fESDtrackCuts(0), + fCentralityEstimator("V0M"), + fUseCentrality(kFALSE), + fCentralityPercentileMin(0.), + fCentralityPercentileMax(5.), + fImpactParameterMin(0.), + fImpactParameterMax(20.), + fUseMultiplicity(kFALSE), + fNumberOfAcceptedTracksMin(0), + fNumberOfAcceptedTracksMax(10000), + fHistNumberOfAcceptedTracks(0), + fUseOfflineTrigger(kFALSE), + fVxMax(0.3), + fVyMax(0.3), + fVzMax(10.), + nAODtrackCutBit(128), + fPtMin(0.3), + fPtMax(1.5), + fEtaMin(-0.8), + fEtaMax(-0.8), + fDCAxyCut(-1), + fDCAzCut(-1), + fTPCchi2Cut(-1), + fNClustersTPCCut(-1), + fAcceptanceParameterization(0), + fDifferentialV2(0), + fUseFlowAfterBurner(kFALSE), + fExcludeResonancesInMC(kFALSE), + fUseMCPdgCode(kFALSE), + fPDGCodeToBeAnalyzed(-1), + fMainEvent(0x0), + fMixEvent(0x0) +{ + // Constructor + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TH1 container + DefineOutput(1, TList::Class()); + DefineOutput(2, TList::Class()); + DefineOutput(3, TList::Class()); + DefineOutput(4, TList::Class()); +} + +//________________________________________________________________________ +AliAnalysisTaskEventMixingBF::~AliAnalysisTaskEventMixingBF() { + + // delete fBalance; + // delete fShuffledBalance; + // delete fList; + // delete fListEventMixingBF; + // delete fListEventMixingBFS; + + // delete fHistEventStats; + // delete fHistTrackStats; + // delete fHistVx; + // delete fHistVy; + // delete fHistVz; + + // delete fHistClus; + // delete fHistDCA; + // delete fHistChi2; + // delete fHistPt; + // delete fHistEta; + // delete fHistPhi; + // delete fHistV0M; +} + +//________________________________________________________________________ +void AliAnalysisTaskEventMixingBF::UserCreateOutputObjects() { + // Create histograms + // Called once + if(!fBalance) { + fBalance = new AliBalanceEventMixing(); + fBalance->SetAnalysisLevel("ESD"); + //fBalance->SetNumberOfBins(-1,16); + fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6); + } + if(fRunShuffling) { + if(!fShuffledBalance) { + fShuffledBalance = new AliBalanceEventMixing(); + fShuffledBalance->SetAnalysisLevel("ESD"); + //fShuffledBalance->SetNumberOfBins(-1,16); + fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6); + } + } + + //QA list + fList = new TList(); + fList->SetName("listQA"); + fList->SetOwner(); + + //Balance Function list + fListEventMixingBF = new TList(); + fListEventMixingBF->SetName("listEventMixingBF"); + fListEventMixingBF->SetOwner(); + + if(fRunShuffling) { + fListEventMixingBFS = new TList(); + fListEventMixingBFS->SetName("listEventMixingBFShuffled"); + fListEventMixingBFS->SetOwner(); + } + + //PID QA list + if(fUsePID) { + fHistListPIDQA = new TList(); + fHistListPIDQA->SetName("listQAPID"); + fHistListPIDQA->SetOwner(); + } + + //Event stats. + TString gCutName[4] = {"Total","Offline trigger", + "Vertex","Analyzed"}; + fHistEventStats = new TH1F("fHistEventStats", + "Event statistics;;N_{events}", + 4,0.5,4.5); + for(Int_t i = 1; i <= 4; i++) + fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); + fList->Add(fHistEventStats); + + TString gCentName[9] = {"V0M","FMD","TRK","TKL","CL0","CL1","V0MvsFMD","TKLvsV0M","ZEMvsZDC"}; + fHistCentStats = new TH2F("fHistCentStats", + "Centrality statistics;;Cent percentile", + 9,-0.5,8.5,220,-5,105); + for(Int_t i = 1; i <= 9; i++) + fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data()); + fList->Add(fHistCentStats); + + fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",130,0,130); + fList->Add(fHistTriggerStats); + + fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",130,0,130); + fList->Add(fHistTrackStats); + + fHistNumberOfAcceptedTracks = new TH1F("fHistNumberOfAcceptedTracks",";N_{acc.};Entries",4001,-0.5,4000.5); + fList->Add(fHistNumberOfAcceptedTracks); + + // Vertex distributions + fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5); + fList->Add(fHistVx); + fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5); + fList->Add(fHistVy); + fHistVz = new TH1F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Entries",100,-20.,20.); + fList->Add(fHistVz); + + // QA histograms + fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200); + fList->Add(fHistClus); + fHistChi2 = new TH1F("fHistChi2","Chi2/NDF distribution",200,0,10); + fList->Add(fHistChi2); + fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5); + fList->Add(fHistDCA); + fHistPt = new TH1F("fHistPt","p_{T} distribution",200,0,10); + fList->Add(fHistPt); + fHistEta = new TH1F("fHistEta","#eta distribution",200,-2,2); + fList->Add(fHistEta); + fHistPhi = new TH1F("fHistPhi","#phi distribution",200,-20,380); + fList->Add(fHistPhi); + fHistPhiBefore = new TH1F("fHistPhiBefore","#phi distribution",200,0.,2*TMath::Pi()); + fList->Add(fHistPhiBefore); + fHistPhiAfter = new TH1F("fHistPhiAfter","#phi distribution",200,0.,2*TMath::Pi()); + fList->Add(fHistPhiAfter); + fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000); + fList->Add(fHistV0M); + TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"}; + fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000); + for(Int_t i = 1; i <= 6; i++) + fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data()); + fList->Add(fHistRefTracks); + + // Balance function histograms + // Initialize histograms if not done yet + if(!fBalance->GetHistNp(0)){ + AliWarning("Histograms not yet initialized! --> Will be done now"); + AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction"); + fBalance->InitHistograms(); + } + + if(fRunShuffling) { + if(!fShuffledBalance->GetHistNp(0)) { + AliWarning("Histograms (shuffling) not yet initialized! --> Will be done now"); + AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction"); + fShuffledBalance->InitHistograms(); + } + } + + for(Int_t a = 0; a < ANALYSIS_TYPES; a++){ + fListEventMixingBF->Add(fBalance->GetHistNp(a)); + fListEventMixingBF->Add(fBalance->GetHistNn(a)); + fListEventMixingBF->Add(fBalance->GetHistNpn(a)); + fListEventMixingBF->Add(fBalance->GetHistNnn(a)); + fListEventMixingBF->Add(fBalance->GetHistNpp(a)); + fListEventMixingBF->Add(fBalance->GetHistNnp(a)); + + if(fRunShuffling) { + fListEventMixingBFS->Add(fShuffledBalance->GetHistNp(a)); + fListEventMixingBFS->Add(fShuffledBalance->GetHistNn(a)); + fListEventMixingBFS->Add(fShuffledBalance->GetHistNpn(a)); + fListEventMixingBFS->Add(fShuffledBalance->GetHistNnn(a)); + fListEventMixingBFS->Add(fShuffledBalance->GetHistNpp(a)); + fListEventMixingBFS->Add(fShuffledBalance->GetHistNnp(a)); + } + } + + if(fESDtrackCuts) fList->Add(fESDtrackCuts); + + //====================PID========================// + if(fUsePID) { + fPIDCombined = new AliPIDCombined(); + fPIDCombined->SetDefaultTPCPriors(); + + fHistdEdxVsPTPCbeforePID = new TH2D ("dEdxVsPTPCbefore","dEdxVsPTPCbefore", 1000, -10.0, 10.0, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePID); //addition + + fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetavsPTOFbeforePID); //addition + + fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID); //addition + + fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID); //addition + + fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID); //addition + + fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID); //addition + + fHistNSigmaTOFvsPtbeforePID = new TH2D ("NSigmaTOFvsPtbefore","NSigmaTOFvsPtbefore", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTOFvsPtbeforePID); //addition + + fHistdEdxVsPTPCafterPID = new TH2D ("dEdxVsPTPCafter","dEdxVsPTPCafter", 1000, -10, 10, 1000, 0, 1000); + fHistListPIDQA->Add(fHistdEdxVsPTPCafterPID); //addition + + fHistBetavsPTOFafterPID = new TH2D ("BetavsPTOFafter","BetavsPTOFafter", 1000, -10, 10, 1000, 0, 1.2); + fHistListPIDQA->Add(fHistBetavsPTOFafterPID); //addition + + fHistProbTPCvsPtafterPID = new TH2D ("ProbTPCvsPtafter","ProbTPCvsPtafter", 1000, -10, 10, 1000, 0, 2); + fHistListPIDQA->Add(fHistProbTPCvsPtafterPID); //addition + + fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000, -10, 10, 1000, 0, 2); + fHistListPIDQA->Add(fHistProbTOFvsPtafterPID); //addition + + fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0); + fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID); //addition + + fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID); //addition + + fHistNSigmaTOFvsPtafterPID = new TH2D ("NSigmaTOFvsPtafter","NSigmaTOFvsPtafter", 1000, -10, 10, 1000, 0, 500); + fHistListPIDQA->Add(fHistNSigmaTOFvsPtafterPID); //addition + } + //====================PID========================// + + // Post output data. + PostData(1, fList); + PostData(2, fListEventMixingBF); + if(fRunShuffling) PostData(3, fListEventMixingBFS); + if(fUsePID) PostData(4, fHistListPIDQA); //PID +} + +//________________________________________________________________________ +void AliAnalysisTaskEventMixingBF::UserExec(Option_t *) { + // Main loop + // Called for each event + // NOTHING TO DO for event mixing! +} + +//________________________________________________________________________ +void AliAnalysisTaskEventMixingBF::FinishTaskOutput(){ + //Printf("END EventMixingBF"); + + if (!fBalance) { + AliError("ERROR: fBalance not available"); + return; + } + if(fRunShuffling) { + if (!fShuffledBalance) { + AliError("ERROR: fShuffledBalance not available"); + return; + } + } + +} + +//________________________________________________________________________ +void AliAnalysisTaskEventMixingBF::Terminate(Option_t *) { + // Draw result to the screen + // Called once at the end of the query + + // not implemented ... + +} + +void AliAnalysisTaskEventMixingBF::UserExecMix(Option_t *) +{ + // Main loop for event mixing + + TString gAnalysisLevel = fBalance->GetAnalysisLevel(); + + AliMixInputEventHandler *mixIEH = SetupEventsForMixing(); + + Float_t fCentrality = 0.; + + // for HBT like cuts need magnetic field sign + Float_t bSign = 0; // only used in AOD so far + + // vector holding the charges/kinematics of all tracks (charge,y,eta,phi,p0,p1,p2,pt,E) + vector *chargeVector[9]; // original charge + for(Int_t i = 0; i < 9; i++){ + chargeVector[i] = new vector; + } + + Double_t vCharge; + Double_t vY; + Double_t vEta; + Double_t vPhi; + Double_t vP[3]; + Double_t vPt; + Double_t vE; + + Int_t iMainTrackUsed = -1; + + // ------------------------------------------------------------- + // At the moment MIXING only for AODs + if(mixIEH){ + + //AOD analysis (vertex and track cuts also here!!!!) + if(gAnalysisLevel == "AOD") { + AliAODEvent* aodEventMain = dynamic_cast(fMainEvent); + if(!aodEventMain) { + AliError("ERROR: aodEventMain not available"); + return; + } + AliAODEvent *aodEventMix = dynamic_cast(fMixEvent); + if(!aodEventMix) { + AliError("ERROR: aodEventMix not available"); + return; + } + + // for HBT like cuts need magnetic field sign + bSign = (aodEventMain->GetMagneticField() > 0) ? 1 : -1; + + AliAODHeader *aodHeaderMain = aodEventMain->GetHeader(); + + // event selection done in AliAnalysisTaskSE::Exec() --> this is not used + fHistEventStats->Fill(1); //all events + + // this is not needed (checked in mixing handler!) + Bool_t isSelectedMain = kTRUE; + Bool_t isSelectedMix = kTRUE; + + if(fUseOfflineTrigger){ + isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); + isSelectedMix = ((AliInputEventHandler*)((AliMultiInputEventHandler *)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetFirstMultiInputHandler())->IsEventSelected(); + } + + if(isSelectedMain && isSelectedMix) { + fHistEventStats->Fill(2); //triggered events + + //Centrality stuff (centrality in AOD header) + if(fUseCentrality) { + fCentrality = aodHeaderMain->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); + + // QA for centrality estimators + fHistCentStats->Fill(0.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("V0M")); + fHistCentStats->Fill(1.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("FMD")); + fHistCentStats->Fill(2.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TRK")); + fHistCentStats->Fill(3.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TKL")); + fHistCentStats->Fill(4.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("CL0")); + fHistCentStats->Fill(5.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("CL1")); + fHistCentStats->Fill(6.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("V0MvsFMD")); + fHistCentStats->Fill(7.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("TKLvsV0M")); + fHistCentStats->Fill(8.,aodHeaderMain->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC")); + + // take only events inside centrality class + if((fCentrality < fCentralityPercentileMin) || (fCentrality > fCentralityPercentileMax)) + return; + + // centrality QA (V0M) + fHistV0M->Fill(aodEventMain->GetVZEROData()->GetMTotV0A(), aodEventMain->GetVZEROData()->GetMTotV0C()); + + // centrality QA (reference tracks) + fHistRefTracks->Fill(0.,aodHeaderMain->GetRefMultiplicity()); + fHistRefTracks->Fill(1.,aodHeaderMain->GetRefMultiplicityPos()); + fHistRefTracks->Fill(2.,aodHeaderMain->GetRefMultiplicityNeg()); + fHistRefTracks->Fill(3.,aodHeaderMain->GetTPConlyRefMultiplicity()); + fHistRefTracks->Fill(4.,aodHeaderMain->GetNumberOfITSClusters(0)); + fHistRefTracks->Fill(5.,aodHeaderMain->GetNumberOfITSClusters(1)); + fHistRefTracks->Fill(6.,aodHeaderMain->GetNumberOfITSClusters(2)); + fHistRefTracks->Fill(7.,aodHeaderMain->GetNumberOfITSClusters(3)); + fHistRefTracks->Fill(8.,aodHeaderMain->GetNumberOfITSClusters(4)); + } + + // // this is crashing (Bug in ROOT (to be solved)) but not needed (checked in mixing handler) + // const AliAODVertex *vertexMain = aodEventMain->GetPrimaryVertex(); + // const AliAODVertex *vertexMix = aodEventMix->GetPrimaryVertex(); + + // if(vertexMain && vertexMix) { + // Double32_t fCovMain[6]; + // Double32_t fCovMix[6]; + // vertexMain->GetCovarianceMatrix(fCovMain); + // vertexMix->GetCovarianceMatrix(fCovMix); + + // if(vertexMain->GetNContributors() > 0 && vertexMix->GetNContributors() > 0) { + // if(fCovMain[5] != 0 && fCovMix[5] != 0) { + // fHistEventStats->Fill(3); //events with a proper vertex + // if(TMath::Abs(vertexMain->GetX()) < fVxMax && TMath::Abs(vertexMix->GetX()) < fVxMax ) { + // if(TMath::Abs(vertexMain->GetY()) < fVyMax && TMath::Abs(vertexMix->GetY()) < fVyMax) { + // if(TMath::Abs(vertexMain->GetZ()) < fVzMax && TMath::Abs(vertexMix->GetZ()) < fVzMax) { + // fHistEventStats->Fill(4); //analyzed events + // fHistVx->Fill(vertexMain->GetX()); + // fHistVy->Fill(vertexMain->GetY()); + // fHistVz->Fill(vertexMain->GetZ()); + + // Loop over tracks in main event + for (Int_t iTracksMain = 0; iTracksMain < aodEventMain->GetNumberOfTracks(); iTracksMain++) { + AliAODTrack* aodTrackMain = dynamic_cast(aodEventMain->GetTrack(iTracksMain)); + if (!aodTrackMain) { + AliError(Form("ERROR: Could not receive track %d", iTracksMain)); + continue; + } + + // AOD track cuts + + // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C + // take only TPC only tracks + fHistTrackStats->Fill(aodTrackMain->GetFilterMap()); + if(!aodTrackMain->TestFilterBit(nAODtrackCutBit)) continue; + + vCharge = aodTrackMain->Charge(); + vY = aodTrackMain->Y(); + vEta = aodTrackMain->Eta(); + vPhi = aodTrackMain->Phi() * TMath::RadToDeg(); + vE = aodTrackMain->E(); + vPt = aodTrackMain->Pt(); + aodTrackMain->PxPyPz(vP); + + Float_t dcaXYMain = aodTrackMain->DCA(); // this is the DCA from global track (not exactly what is cut on) + Float_t dcaZMain = aodTrackMain->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) + + + // Kinematics cuts from ESD track cuts + if( vPt < fPtMin || vPt > fPtMax) continue; + if( vEta < fEtaMin || vEta > fEtaMax) continue; + + // Extra DCA cuts (for systematic studies [!= -1]) + if( fDCAxyCut != -1 && fDCAzCut != -1){ + if(TMath::Sqrt((dcaXYMain*dcaXYMain)/(fDCAxyCut*fDCAxyCut)+(dcaZMain*dcaZMain)/(fDCAzCut*fDCAzCut)) > 1 ){ + continue; // 2D cut + } + } + + // Extra TPC cuts (for systematic studies [!= -1]) + if( fTPCchi2Cut != -1 && aodTrackMain->Chi2perNDF() > fTPCchi2Cut){ + continue; + } + if( fNClustersTPCCut != -1 && aodTrackMain->GetTPCNcls() < fNClustersTPCCut){ + continue; + } + + // fill QA histograms + fHistClus->Fill(aodTrackMain->GetITSNcls(),aodTrackMain->GetTPCNcls()); + fHistDCA->Fill(dcaZMain,dcaXYMain); + fHistChi2->Fill(aodTrackMain->Chi2perNDF()); + fHistPt->Fill(vPt); + fHistEta->Fill(vEta); + fHistPhi->Fill(vPhi); + + // fill charge vector + chargeVector[0]->push_back(vCharge); + chargeVector[1]->push_back(vY); + chargeVector[2]->push_back(vEta); + chargeVector[3]->push_back(vPhi); + chargeVector[4]->push_back(vP[0]); + chargeVector[5]->push_back(vP[1]); + chargeVector[6]->push_back(vP[2]); + chargeVector[7]->push_back(vPt); + chargeVector[8]->push_back(vE); + + // ------------------------------------------------------------- + // for each track in main event loop over all tracks in mix event + for (Int_t iTracksMix = 0; iTracksMix < aodEventMix->GetNumberOfTracks(); iTracksMix++) { + + AliAODTrack* aodTrackMix = dynamic_cast(aodEventMix->GetTrack(iTracksMix)); + if (!aodTrackMix) { + AliError(Form("ERROR: Could not receive track %d", iTracksMix)); + continue; + } + + // AOD track cuts + + // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C + // take only TPC only tracks + fHistTrackStats->Fill(aodTrackMix->GetFilterMap()); + if(!aodTrackMix->TestFilterBit(nAODtrackCutBit)) continue; + + vCharge = aodTrackMix->Charge(); + vY = aodTrackMix->Y(); + vEta = aodTrackMix->Eta(); + vPhi = aodTrackMix->Phi() * TMath::RadToDeg(); + vE = aodTrackMix->E(); + vPt = aodTrackMix->Pt(); + aodTrackMix->PxPyPz(vP); + + Float_t dcaXYMix = aodTrackMix->DCA(); // this is the DCA from global track (not exactly what is cut on) + Float_t dcaZMix = aodTrackMix->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on) + + + // Kinematics cuts from ESD track cuts + if( vPt < fPtMin || vPt > fPtMax) continue; + if( vEta < fEtaMin || vEta > fEtaMax) continue; + + // Extra DCA cuts (for systematic studies [!= -1]) + if( fDCAxyCut != -1 && fDCAxyCut != -1){ + if(TMath::Sqrt((dcaXYMix*dcaXYMix)/(fDCAxyCut*fDCAxyCut)+(dcaZMix*dcaZMix)/(fDCAzCut*fDCAzCut)) > 1 ){ + continue; // 2D cut + } + } + + // Extra TPC cuts (for systematic studies [!= -1]) + if( fTPCchi2Cut != -1 && aodTrackMix->Chi2perNDF() > fTPCchi2Cut){ + continue; + } + if( fNClustersTPCCut != -1 && aodTrackMix->GetTPCNcls() < fNClustersTPCCut){ + continue; + } + + // fill QA histograms + fHistClus->Fill(aodTrackMix->GetITSNcls(),aodTrackMix->GetTPCNcls()); + fHistDCA->Fill(dcaZMix,dcaXYMix); + fHistChi2->Fill(aodTrackMix->Chi2perNDF()); + fHistPt->Fill(vPt); + fHistEta->Fill(vEta); + fHistPhi->Fill(vPhi); + + // fill charge vector + chargeVector[0]->push_back(vCharge); + chargeVector[1]->push_back(vY); + chargeVector[2]->push_back(vEta); + chargeVector[3]->push_back(vPhi); + chargeVector[4]->push_back(vP[0]); + chargeVector[5]->push_back(vP[1]); + chargeVector[6]->push_back(vP[2]); + chargeVector[7]->push_back(vPt); + chargeVector[8]->push_back(vE); + + + + } //mix track loop + + // calculate balance function for each track in main event + iMainTrackUsed++; // is needed to do no double counting in Balance Function calculation + if(iMainTrackUsed >= (Int_t)chargeVector[0]->size()) break; //do not allow more tracks than in mixed event! + fBalance->CalculateBalance(fCentrality,chargeVector,iMainTrackUsed,bSign); + // clean charge vector afterwards + for(Int_t i = 0; i < 9; i++){ + chargeVector[i]->clear(); + } + + + } //main track loop + // }//Vz cut + // }//Vy cut + // }//Vx cut + // }//proper vertexresolution + // }//proper number of contributors + // }//vertex object valid + }//triggered event + }//AOD analysis + } +} + +AliMixInputEventHandler *AliAnalysisTaskEventMixingBF::SetupEventsForMixing() { + //sets the input handlers for event mixing + + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliMultiInputEventHandler *inEvHMain = dynamic_cast(mgr->GetInputEventHandler()); + if (inEvHMain) { + + AliMixInputEventHandler *mixEH = dynamic_cast(inEvHMain->GetFirstMultiInputHandler()); + if (!mixEH) return nullptr; + if (mixEH->CurrentBinIndex() < 0) { + AliDebug(AliLog::kDebug + 1, "Current event mixEH->CurrentEntry() == -1"); + return nullptr; + } + AliDebug(AliLog::kDebug, Form("Mixing %lld %d [%lld,%lld] %d", mixEH->CurrentEntry(), mixEH->CurrentBinIndex(), mixEH->CurrentEntryMain(), mixEH->CurrentEntryMix(), mixEH->NumberMixed())); + + AliInputEventHandler *ihMainCurrent = inEvHMain->GetFirstInputEventHandler(); + fMainEvent = ihMainCurrent->GetEvent(); + + AliMultiInputEventHandler *inEvHMixedCurrent = mixEH->GetFirstMultiInputHandler(); // for buffer = 1 + AliInputEventHandler *ihMixedCurrent = inEvHMixedCurrent->GetFirstInputEventHandler(); + fMixEvent = ihMixedCurrent->GetEvent(); + + return mixEH; + } + return NULL; +} diff --git a/PWGCF/EBYE/LRC/AliAnalysisTaskLRC.h b/PWGCF/EBYE/LRC/AliAnalysisTaskLRC.h index b3e8d8d2386..a93544026be 100644 --- a/PWGCF/EBYE/LRC/AliAnalysisTaskLRC.h +++ b/PWGCF/EBYE/LRC/AliAnalysisTaskLRC.h @@ -1,408 +1,408 @@ -#ifndef AliAnalysisTaskLRC_H -#define AliAnalysisTaskLRC_H - -// Analysis task for Long Range Correlation (LRC) analysis using TPC data -// This includes a TList of AliLRCProcess objects that are processing LRC analysis -// for a given eta-phi windows - -// Author : Andrey Ivanov, Igor Altsybeev, St.Peterburg State University -// Email: Igor.Altsybeev.ch - - -#include -#include -#include - -//#define kNumberOfParentParticleClassesInMC 8 - -//class AliLRCProcess; -class AliLRCBase; -class AliESDtrackCuts; -class TH1D; -class TH2D; -class TH1I; -class TRandom3; -class TParticle; -//class AliSimpleEvent; -class TTree; - -class TStopwatch; -//enum en_AnalysisType -//{ -// en_AnalysisType_ESD = 0, -// en_AnalysisType_AOD - -//}; - -class AliAnalysisTaskLRC : public AliAnalysisTaskSE { - -public: - //Constructors - AliAnalysisTaskLRC( const char *name = "AliAnalysisTaskLRC", Bool_t runKine = kFALSE ); - virtual ~AliAnalysisTaskLRC() {} - - //AliAnalysisTaskSE overloading - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *option); - // virtual void UserExecLoop( Double_t phiAdditional = 0 );//Option_t *option); - virtual void Terminate(Option_t *); - //---------------------------------- - - void AddLRCProcess(AliLRCBase *newProc); //Adds new AliLRCProcess to analysis task - - // Setters - void SetMinNumberOfSPDtracklets( Int_t MinSPDtracklets ); //Sets min number of SPD tracklets - void SetMaxPtLimit(Double_t MaxPtLimit); //Sets Max Pt filter - void SetMinPtLimit(Double_t MinPtLimit); //Sets Min Pt filter - void SetKineLowPtCut(Double_t MinKineParticlePtLimit); //Sets Min Pt filter for kine particles - void SetCheckForkVtx(Bool_t CheckForkVtx){fCheckForkVtx=CheckForkVtx;} // Accept only events with veretex - void SetCheckForVtxPosition(Bool_t CheckForVtxPosition ){fCheckForVtxPosition=CheckForVtxPosition;} //Accept only events with veretex in slected range - void SetTrackCuts(AliESDtrackCuts* const cuts) { fEsdTrackCuts = cuts; } - void SetAODtrackCutBit(UInt_t bit){ fAODtrackCutBit = bit; } //AOD track cut bit - void SetShowEventStats(Bool_t ShowEventStats) {fShowEventStats= ShowEventStats;} - void SetShowPerTrackStats(Bool_t ShowPerTrackStats) {fShowPerTrackStats=ShowPerTrackStats;} - void SetVtxDiamond(Double_t Vx, Double_t Vy, Double_t Vz) {fVxMax = Vx;fVyMax =Vy;fVzMax = Vz;} - void SetNchCuts(Int_t minNch, Int_t maxNch){fMinAcceptedTracksCut=minNch; fMaxAcceptedTracksCut=maxNch;} - - void SetNumberOfPhiSectors(Int_t nSectors){ fNumberOfPhiSectors = nSectors; }//fNeedToRotateSector = kTRUE; } - void SetCentralityClass(Float_t minCentralityClass, Float_t maxCentralityClass ){ fMinCentralityClass = minCentralityClass; fMaxCentralityClass = maxCentralityClass; } - - void SetIonsAnalysis(Bool_t isIonsFlag ){ fIsIonsAnalysis = isIonsFlag; } - void SetEtAnalysis(Bool_t isEtAnalysisFlag ){ fEtInsteadOfPt = isEtAnalysisFlag; } - void SetUsePhiShufflingByHand(Bool_t usePhiShufflingByHand ){ fUsePhiShufflingByHand = usePhiShufflingByHand; } - void SetUseToyEvents(Bool_t useToyEvents ){ fUseToyEvents = useToyEvents; } - void SetNumberOfToyEvents(Int_t nEvents ){ fNumberOfToyEvents = nEvents; } - void SetArtificialInefficiencyCoeff( Double_t artificialInefficiencyCoeff ) { fArtificialInefficiency = artificialInefficiencyCoeff; } //Sets coeff for artificial inefficiency - - //void SetNumberOfPhiSectorsByHand( Int_t numberOfPhiSectorsByHand ) { fNumberOfPhiSectorsByHand = numberOfPhiSectorsByHand; } - - // Getters - TList* GetListOfProcessors() { return &fLRCproc;} // Returns list of included - AliESDtrackCuts* GetTrackCuts() const { return fEsdTrackCuts; } - AliLRCBase * Proc(Int_t index);// Get Processor i - - void SetParticleTypeForTask( TString strF, TString strB ); //( char* strF, char* strB ); - // void SetMCparticleClassForFillingLRC( TString strParticleType ) { fStrMCparticleClassForFillingLRC = strParticleType; } - // void SetEtaCutsForSpecMCanalysis( double etaMin, double etaMax ) { fEtaMCanalysisCutMin = etaMin; fEtaMCanalysisCutMax = etaMax; } - - void SetV0ACMultThreshold( int minMult ) { fThresholdOnV0mult = minMult; } - - // void SetIncludeEventTreeInOutput( Bool_t flag ) { fSetIncludeEventTreeInOutput = flag; } - // Bool_t GetIncludeEventTreeInOutput() { return fSetIncludeEventTreeInOutput; } - - // void SetAnalysisType( en_AnalysisType analysisType ) { fAnalysisType = analysisType; } - // en_AnalysisType GetAnalysisType() { return fAnalysisType; } - - Double_t GetEventPlane(AliVEvent *event); - - - //track cuts array stuff - void AddTrackCutForBits(AliESDtrackCuts* const cuts, TString cutsName ); - void SetUseListCuts( Bool_t const useCutsList ) { fSwitchToListingCuts = useCutsList; } - Int_t GetNumberOfTrackCutForBits() const { return fArrTrackCuts.GetEntries();/*fNumberOfCutsToRemember*/; } - - void SetAnalysisLevel(const char* analysisLevel) { fAnalysisLevel = analysisLevel;} - const char* GetAnalysisLevel() { return fAnalysisLevel.Data(); } - - void SetMCESD( Bool_t flagMCESD ) { fAnalyseMCESD = flagMCESD; } - Bool_t GetMCESD() const { return fAnalyseMCESD; } - - void SetFlagWatchZDC( Bool_t flagWatchZDC) { fFlagWatchZDC = flagWatchZDC;} - void SetFlagWatchV0 ( Bool_t flagWatchV0 ) { fFlagWatchV0 = flagWatchV0 ;} - void SetFlagWatchFMD( Bool_t flagWatchFMD) { fFlagWatchFMD = flagWatchFMD;} - Bool_t GetFlagWatchZDC() { return fFlagWatchZDC; } - Bool_t GetFlagWatchV0 () { return fFlagWatchV0 ; } - Bool_t GetFlagWatchFMD() { return fFlagWatchFMD; } - - void FillLRCProcessors( int nTracks, Double_t eventCentrality ); - void ProfilePhiByHand( int numberOfAcceptedTracksForLRC ); - void UseToyEvents(); - - void SetEtaRegionForTests( Double_t etaRegionForTests ) { fEtaRegionForTests = etaRegionForTests; } - Double_t GetEtaRegionForTests() { return fEtaRegionForTests; } - - void SetMultCutInEtaRegion( Double_t multCutInEtaRegion ) { fMultCutInEtaRegion = multCutInEtaRegion; } - Double_t GetMultCutInEtaRegion() { return fMultCutInEtaRegion; } - - inline void FixAngleInTwoPi( Double_t &lPhi ) - { - if ( lPhi > 2 * TMath::Pi() ) - lPhi -= 2 * TMath::Pi(); - else if ( lPhi < 0 ) - lPhi += 2 * TMath::Pi(); - } - - void SetFlagSuppressAddingSomeHistos( Bool_t flagSuppressAddingSomeHistos ) { fFlagSuppressAddingSomeHistos = flagSuppressAddingSomeHistos; } - - enum enTaskObjectParameters { kMaxParticlesNumber = 15000, kMaxLRCprocArrayPointers = 10000 }; // default TPC & TOF pid (via GetTPCpid & GetTOFpid) - -protected: - void SetParticleTypeToProcessors( int windowId, TString strPid ); - - Int_t fNumberOfPhiSectors; // n of phi rotations - Bool_t fFlagSuppressAddingSomeHistos; //flag to include in output list some histos or not include - // AliLRCBase *fLRCprocArrayPointers[kMaxLRCprocArrayPointers]; - - // Track cuts - TString fAnalysisLevel; //ESD, AOD or MC - AliESDtrackCuts *fEsdTrackCuts; // esd track cuts - UInt_t fAODtrackCutBit;//track cut bit from track selection (only used for AODs) - - // Array with different track cuts to remember in simple event Tree - TObjArray fArrTrackCuts; //AliESDtrackCuts* [100]; // Arr with different track cuts - TString fArrCutsNames[100]; // Arr with names of different track cuts - TH1I *fHistCutsNamesBins; //! tracks passed different cut sets in histogram bins - Bool_t fSwitchToListingCuts; // switch to remember cuts desicions and not to drop track by fTrackCuts - - - // en_AnalysisType fAnalysisType; // type of analysis - - //SPD tracklets cut - Int_t fMinNumberOfSPDtracklets; //Minimum number of SPD tracklets in ESD event - - // Acceptance cuts - Double_t fMaxPtLimit; //Max Pt filter - Double_t fMinPtLimit; // Min Pt filter - Double_t fKineLowPtCut; // Min Pt for Kine tracks - - // Nch cuts - Int_t fMinAcceptedTracksCut; //Minimum number of accepted tracks in event - Int_t fMaxAcceptedTracksCut; //Maximum number of accepted tracks in event - - // Vtx cuts - Bool_t fCheckForkVtx; // Check for vertex - Bool_t fCheckForVtxPosition; // Check if vertex position in range - Double_t fVxMax; // X vrtx max - Double_t fVyMax; // Y vrtx max - Double_t fVzMax; // Z vrtx max - - - TList fLRCproc; // AliLRCProcess objects list - TList* fOutList; //! Task Output data container - - Bool_t fRunKine; // ESD/AOD - KINE switch - Bool_t fAnalyseMCESD; // MCESD switch - Bool_t fShowEventStats; // Allows per event debug output (trigger Nch, cuts etc) - Bool_t fShowPerTrackStats; // Allows per track debug output - - - Double_t fEtaRegionForTests; //eta region to tests - Double_t fMultCutInEtaRegion; // cut on mult in eta region - - // QA histos - - TH1I *fHistEventCutStats; //! Event cut statistics - TH1I *fHistTrackCutStats; //! Track cut statistics - TH1I *fHistAODTrackStats; //! AOD track bits statistics - - - TH1D *fHistVx; //! Vx hist - TH1D *fHistVy; //! Vy hist - TH1D *fHistVz; //! Vz hist - - TH1D *fHistVxMCrecoDiff; //! Vx hist MC-reco diff - TH1D *fHistVyMCrecoDiff; //! Vy hist MC-reco diff - TH1D *fHistVzMCrecoDiff; //! Vz hist MC-reco diff - - TH1I *fHistVertexNconributors; //! vertex contributors number - TH1I *fHistNumberOfPileupVerticesTracks; //! number of pileup verteces in event (ESD or AOD) by tracks - TH1I *fHistNumberOfPileupVerticesSPD; //! number of pileup verteces in event (ESD or AOD) by SPD - - TH2F *fHistEventPlane; //event plane distribution - - - TH1F *fHistPt; //! Overal Pt spectrum - TH1F *fHistEta; //! Overal Eta spectrum - TH1F *fHistEtaAODpure; //! Overal Eta spectrum aod pure before cuts - TH1F *fHistPhi; //! Overal Phi spectrum - TH2D *fHistEtaPhi; //! 2D plot for checking acceptance - TH1F *fHistPhiLRCrotationsCheck; //! Overal Phi spectrum for LRC rotations - TH1F *fHistPhiArtificialProfilingCheck; //! hist for the check of profiled phi - TH1F *fHistPhiArtificialProfilingCheckWrtEvPlane; //! hist for the check of profiled phi wrt event plane - TH1F *fHistPhiArtificialEvPlane; //! hist artificial event plane - - TH2D *fHistEtaVsZvCoverage; //! Statistics on tracks Zv and Eta for all tracks - TH2D *fHistEtaVsZvCoverageAccepted; //! Statistics on tracks Zv and Eta for accepted tracks - - TH1D *fHistMultBeforeCuts; //! Histo: Number of tracks before applying cuts - TH1D *fHistAcceptedMult; //! Number of accepted tracks histo - TH1D *fHistAcceptedTracks; //! Number of tracks accepted for filling LRC processors, histo - TH1D *fHistMultiplicityInEtaRegion; //! Number of tracks in |eta| region - TH1D *fHistMultiplicityInEtaRegionAfterPtCuts; //! Number of tracks in |eta| region after Pt Cuts - TH2D *fHist2DMultiplicityMCESDInEtaRegion; //! Number of tracks in |eta| region (MC vs ESD) - TH1D *fHistAcceptedTracksAfterPtCuts; //! Number of tracks accepted for filling LRC processors, histo - TH1D *fHistAcceptedTPCtracks; //! Number of accepted tracks with TPC inner param - TH1D *fHistClustersTPC; //! Number of TPC clusters distribution - TH1D *fHistClustersTPCafterCuts; //! Number of TPC clusters distribution after cuts - TH1D *fHistCrossedRowsTPC; //! Number of TPC crossed rows - TH1D *fHistCrossedRowsTPCafterCuts; //! Number of TPC crossed rows after cuts - - - TH1D *fHistClustersITS; //! Number of ITS clusters distribution - TH1D *fHistTrackletsITS; //! Number of ITS tracklets distribution - TH2D *fHist2DClustersTPCvsPt; //! Number of TPC clusters vs Pt distribution (to see the dependence!) - TH2D *fHist2DClustersTPCvsEta; //! Number of TPC clusters vs Eta distribution (to see the dependence!) - - TH2D *fHist2DAcceptedTracksPtvsEta; //! rejected tracks pt vs eta - - TH1D *fHistMClabels; //! MC labels - TH1D *fHistRejectedTracksCharge; //! Charge of rejected tracks - TH1D *fHistTracksCharge; //! Charge of accepted tracks (zero is filled only for MC truth) - - //netcharge study - TH1D *fHistPtPlus; //! pt distr for + - TH1D *fHistPtMinus; //! pt distr for - - TH1D *fHistNetChargeVsPt; //! Net charge vs pt of accepted tracks - TH1D *fHistChargePlusVsPtTmp; //! Net charge vs pt of accepted tracks + - TH1D *fHistChargeMinusVsPtTmp; //! Net charge vs pt of accepted tracks - - TH2D *fHist2DNetChargeVsPt; //! Net charge vs pt of accepted tracks 2D - TH2D *fHist2DNetChargeVsPtCorrectedOnEventMean; //! Net charge vs pt of accepted tracks 2D shifted by mean - TH2D *fHist2DNetChargeVsPtCorrectedOnEventMeanNormOnNch; //! Net charge vs pt of accepted tracks 2D norm on nCh - - AliAnalysisTaskLRC(const AliAnalysisTaskLRC&); // not implemented - AliAnalysisTaskLRC& operator=(const AliAnalysisTaskLRC&); // not implemented - - TH1D *fHistProbabilitiesPID; //!hist of esd pid prob-s - //Double_t *fProbabilitiesPID; //! array of esd pid prob-s - TH1D *fHistESDtrackMass; //!hist of esd particle masses - TH1D *fHistProbabilityPion; //!hist of pion probability - TH1D *fHistProbabilityKaon; //!hist of kaon probability - TH1D *fHistProbabilityProton; //!hist of proton probability - TH1D *fHistParticlesDistr; //!hist of particles distr - TH1D *fHistParticlesDistrBeforeCuts; //!hist of particles distr - - - - TH1D *fHistCentralityPercentile; //! centrality class - TH1D *fHistCentralityClass10; //! centrality class by 10 - TH1D *fHistCentralityClass5; //! centrality class by 5 - - - //ZDC stuff - TH1D *fHistZDCenergy[5]; //! ZDC energy for diff mult conditions - TH1D *fHistZDCparticipants; //! ZDC participants - - //V0 stuff - TH1D *fHistV0multiplicity; //! V0 mult - TH1D *fHistV0Amultiplicity; //! V0 A mult - TH1D *fHistV0Cmultiplicity; //! V0 C mult - TH2D *fHist2DV0ACmultiplicity; //! V0 A-C mult - //TH1D *fHistV0spectra; //! V0 particle masses - TH2D *fHist2DTracksAcceptedVsV0multiplicity; //! V0 mult Vs N tracks Accepted - - TH1D *fHistV0AmultiplicityRing[4]; //! V0 A mult in rings - TH1D *fHistV0CmultiplicityRing[4]; //! V0 C mult in rings - TH2D *fHist2DV0ACmultiplicityRing[4]; //! V0 A-C mult in rings - TH2D *fHist2DTracksAcceptedVsV0AmultiplicityRing[4]; //! V0A mult Rings Vs N tracks Accepted - TH2D *fHist2DTracksAcceptedVsV0CmultiplicityRing[4]; //! V0C mult Rings Vs N tracks Accepted - - TH1D *fHistV0cells ; //! V0 cells - TH1D *fHistV0Acells ; //! V0 A cells - TH1D *fHistV0Ccells ; //! V0 C cells - TH2D *fHist2DV0ACcells ; //! V0 A-C cells - - Int_t fThresholdOnV0mult; //min V0AC mult to analyse this event (default is 0) - - - //centrality class - Float_t fMinCentralityClass; // min bound on centrality percentile - Float_t fMaxCentralityClass; // max bound on centrality percentile - - - Bool_t fIsIonsAnalysis; //Ions analysis flag - Bool_t fEtInsteadOfPt; //pass the Et instead of Pt to LRC processors - - Bool_t fUsePhiShufflingByHand; //flag for manual suffling of tracks phi - Bool_t fUseToyEvents; //flag for manual suffling of tracks phi - Int_t fNumberOfToyEvents; //number of toy events - - Int_t fTmpCounter; //! TMP - - const AliPIDResponse *fPIDResponse; //! PID response object - AliPIDCombined *fPIDCombined; //! combined PID object - TH1F *fPriors[AliPID::kSPECIES]; //! priors - TH2D *fPriorsUsed[AliPID::kSPECIES]; //! priors used - TH2D *fProbTPCTOF[AliPID::kSPECIES]; //! combined probabilities vs mom TPC-TOF - TH2D *fProbAllDets[AliPID::kSPECIES]; //! combined probabilities ALL dets vs mom - - TH1D *fHistPidMaxProbability; //!hist of max probabilities for arrays PID species - TH1D *fHistPidPureMaxProbability; //!hist of max probabilities for arrays PID species (when detId is TPC+TOF) - - TString fStrPIDforFwd; //PID name for FWD win - TString fStrPIDforBwd; //PID name for BWD win - Bool_t fPIDsensingFlag; //flag that we sense PID in processors - - - int fMultForZDCstudy[5]; //! threshold multiplicities for ZDC study - - //artificial inefficiency (27.09.12) - Double_t fArtificialInefficiency; // inefficiency by hand in [0,1], default is 0 - TH2D *fHistNumberOfDroppedByHandTracks; //! Number of tracks which were dropped by hand vs N of accepted tracks - TRandom3 *fRand; //random generator for some uses - - //phi artificial gaps - Double_t fPhiArtificialGapBegin; // inefficiency in phi - gap position edge begins - Double_t fPhiArtificialGapEnd; // inefficiency in phi - gap position edge ends - - //flags for inclusion of detectors info: - Bool_t fFlagWatchZDC; //study ZDC issues - Bool_t fFlagWatchV0; //study V0 issues - Bool_t fFlagWatchFMD; //study FMD issues - - - TStopwatch *fAnalysisTimer; - - - //arrays with data for LRC processors - Double_t fArrayTracksPt[kMaxParticlesNumber]; - Double_t fArrayTracksEta[kMaxParticlesNumber]; - Double_t fArrayTracksPhi[kMaxParticlesNumber]; - Short_t fArrayTracksCharge[kMaxParticlesNumber]; - Int_t fArrayTracksPID[kMaxParticlesNumber]; - - - //test MC particles - // TH1D *fHistMCvertexRdeltaFromParent; //!MC R hist - // TH1F *fHistMCparentsStat; //! MC parent ratios for different partile classes - // TH1F *fHistMCparentsEta[kNumberOfParentParticleClassesInMC]; //! MC parents eta distributions for different particle classes - // TH1F *fHistMCchildsEta[kNumberOfParentParticleClassesInMC]; //! MC childs eta distributions for different partile classes - // TH1F *fHistMCdeltaEtaChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta eta b/n parent and child - // TH1F *fHistMCdeltaPhiChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta phi b/n parent and child - // TH2D *fHist2DMCchildrenPhiChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta b/n parent and child in eta-phi - - // TH1F *fHistMCNumberOfChildren[kNumberOfParentParticleClassesInMC]; //! Number of children for fathers in MC (for different father classes) - // TH1D *fHistMCchildrenEtaDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. eta and each child's eta for each father (for different father classes) - // TH1D *fHistMCchildrenPhiDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. phi and each child's phi for each father (for different father classes) - // TH2D *fHist2DMCchildrenPhiDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. eta-phi and each child's eta and phi for each father (for different father classes) - - // TString fStrMCparticleClassForFillingLRC; // name of particle class for LRC filling (default is All) - // Double_t fEtaMCanalysisCutMin; // spec MC analysis: cut on eta - // Double_t fEtaMCanalysisCutMax; // spec MC analysis: cut on eta - - // TH1F *fHistMCparentDeepness; //! MC deepness of parent tree from "physical primary" children - // TH1F *fHistMCparentsInitialStat; //! MC initial papa particle class distr - - // TH1F *fHistMCEtaInitialQuark; //! MC eta distr of "initial" quarks - // TH1F *fHistMCEtaInitialGluon; //! MC eta distr of "initial" gluons - // TH1F *fHistMCEtaInitialProton; //! MC eta distr of "initial" protons - - // TH1F *fHistMCnumberInitialQuarksInEvent; //! MC initial quarks number distr - // TH1F *fHistMCnumberInitialGluonsInEvent; //! MC initial gluons number distr - // TH1F *fHistMCnumberInitialProtonInEvent; //! MC initial proton number distr (check that there are 2) - - // TH1F *fHistMCnumberChildrenFromInitialQuarksInEvent; //! MC children number from initial quarks distr - // TH1F *fHistMCnumberChildrenFromInitialGluonsInEvent; //! MC children number from initial gluons distr - // TH1F *fHistMCnumberChildrenFromInitialProtonInEvent; //! MC children number from initial proton distr (check that there are 2) - - - // 4.01.2012: MyTree stuff - // AliSimpleEvent *fSimpleEvent; // instance of simple event to be filled in analysis loop - // Int_t fNsimpleEvents; - // TTree *fEventTree; //! event tree to write into output file - // Bool_t fSetIncludeEventTreeInOutput; // flag to use event tree or not - - ClassDef(AliAnalysisTaskLRC, 11 ); -}; - -#endif +#ifndef AliAnalysisTaskLRC_H +#define AliAnalysisTaskLRC_H + +// Analysis task for Long Range Correlation (LRC) analysis using TPC data +// This includes a TList of AliLRCProcess objects that are processing LRC analysis +// for a given eta-phi windows + +// Author : Andrey Ivanov, Igor Altsybeev, St.Peterburg State University +// Email: Igor.Altsybeev.ch + + +#include +#include +#include + +//#define kNumberOfParentParticleClassesInMC 8 + +//class AliLRCProcess; +class AliLRCBase; +class AliESDtrackCuts; +class TH1D; +class TH2D; +class TH1I; +class TRandom3; +class TParticle; +//class AliSimpleEvent; +class TTree; + +class TStopwatch; +//enum en_AnalysisType +//{ +// en_AnalysisType_ESD = 0, +// en_AnalysisType_AOD + +//}; + +class AliAnalysisTaskLRC : public AliAnalysisTaskSE { + +public: + //Constructors + AliAnalysisTaskLRC( const char *name = "AliAnalysisTaskLRC", Bool_t runKine = kFALSE ); + virtual ~AliAnalysisTaskLRC() {} + + //AliAnalysisTaskSE overloading + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + // virtual void UserExecLoop( Double_t phiAdditional = 0 );//Option_t *option); + virtual void Terminate(Option_t *); + //---------------------------------- + + void AddLRCProcess(AliLRCBase *newProc); //Adds new AliLRCProcess to analysis task + + // Setters + void SetMinNumberOfSPDtracklets( Int_t MinSPDtracklets ); //Sets min number of SPD tracklets + void SetMaxPtLimit(Double_t MaxPtLimit); //Sets Max Pt filter + void SetMinPtLimit(Double_t MinPtLimit); //Sets Min Pt filter + void SetKineLowPtCut(Double_t MinKineParticlePtLimit); //Sets Min Pt filter for kine particles + void SetCheckForkVtx(Bool_t CheckForkVtx){fCheckForkVtx=CheckForkVtx;} // Accept only events with veretex + void SetCheckForVtxPosition(Bool_t CheckForVtxPosition ){fCheckForVtxPosition=CheckForVtxPosition;} //Accept only events with veretex in slected range + void SetTrackCuts(AliESDtrackCuts* const cuts) { fEsdTrackCuts = cuts; } + void SetAODtrackCutBit(UInt_t bit){ fAODtrackCutBit = bit; } //AOD track cut bit + void SetShowEventStats(Bool_t ShowEventStats) {fShowEventStats= ShowEventStats;} + void SetShowPerTrackStats(Bool_t ShowPerTrackStats) {fShowPerTrackStats=ShowPerTrackStats;} + void SetVtxDiamond(Double_t Vx, Double_t Vy, Double_t Vz) {fVxMax = Vx;fVyMax =Vy;fVzMax = Vz;} + void SetNchCuts(Int_t minNch, Int_t maxNch){fMinAcceptedTracksCut=minNch; fMaxAcceptedTracksCut=maxNch;} + + void SetNumberOfPhiSectors(Int_t nSectors){ fNumberOfPhiSectors = nSectors; }//fNeedToRotateSector = kTRUE; } + void SetCentralityClass(Float_t minCentralityClass, Float_t maxCentralityClass ){ fMinCentralityClass = minCentralityClass; fMaxCentralityClass = maxCentralityClass; } + + void SetIonsAnalysis(Bool_t isIonsFlag ){ fIsIonsAnalysis = isIonsFlag; } + void SetEtAnalysis(Bool_t isEtAnalysisFlag ){ fEtInsteadOfPt = isEtAnalysisFlag; } + void SetUsePhiShufflingByHand(Bool_t usePhiShufflingByHand ){ fUsePhiShufflingByHand = usePhiShufflingByHand; } + void SetUseToyEvents(Bool_t useToyEvents ){ fUseToyEvents = useToyEvents; } + void SetNumberOfToyEvents(Int_t nEvents ){ fNumberOfToyEvents = nEvents; } + void SetArtificialInefficiencyCoeff( Double_t artificialInefficiencyCoeff ) { fArtificialInefficiency = artificialInefficiencyCoeff; } //Sets coeff for artificial inefficiency + + //void SetNumberOfPhiSectorsByHand( Int_t numberOfPhiSectorsByHand ) { fNumberOfPhiSectorsByHand = numberOfPhiSectorsByHand; } + + // Getters + TList* GetListOfProcessors() { return &fLRCproc;} // Returns list of included + AliESDtrackCuts* GetTrackCuts() const { return fEsdTrackCuts; } + AliLRCBase * Proc(Int_t index);// Get Processor i + + void SetParticleTypeForTask( TString strF, TString strB ); //( char* strF, char* strB ); + // void SetMCparticleClassForFillingLRC( TString strParticleType ) { fStrMCparticleClassForFillingLRC = strParticleType; } + // void SetEtaCutsForSpecMCanalysis( double etaMin, double etaMax ) { fEtaMCanalysisCutMin = etaMin; fEtaMCanalysisCutMax = etaMax; } + + void SetV0ACMultThreshold( int minMult ) { fThresholdOnV0mult = minMult; } + + // void SetIncludeEventTreeInOutput( Bool_t flag ) { fSetIncludeEventTreeInOutput = flag; } + // Bool_t GetIncludeEventTreeInOutput() { return fSetIncludeEventTreeInOutput; } + + // void SetAnalysisType( en_AnalysisType analysisType ) { fAnalysisType = analysisType; } + // en_AnalysisType GetAnalysisType() { return fAnalysisType; } + + Double_t GetEventPlane(AliVEvent *event); + + + //track cuts array stuff + void AddTrackCutForBits(AliESDtrackCuts* const cuts, TString cutsName ); + void SetUseListCuts( Bool_t const useCutsList ) { fSwitchToListingCuts = useCutsList; } + Int_t GetNumberOfTrackCutForBits() const { return fArrTrackCuts.GetEntries();/*fNumberOfCutsToRemember*/; } + + void SetAnalysisLevel(const char* analysisLevel) { fAnalysisLevel = analysisLevel;} + const char* GetAnalysisLevel() { return fAnalysisLevel.Data(); } + + void SetMCESD( Bool_t flagMCESD ) { fAnalyseMCESD = flagMCESD; } + Bool_t GetMCESD() const { return fAnalyseMCESD; } + + void SetFlagWatchZDC( Bool_t flagWatchZDC) { fFlagWatchZDC = flagWatchZDC;} + void SetFlagWatchV0 ( Bool_t flagWatchV0 ) { fFlagWatchV0 = flagWatchV0 ;} + void SetFlagWatchFMD( Bool_t flagWatchFMD) { fFlagWatchFMD = flagWatchFMD;} + Bool_t GetFlagWatchZDC() { return fFlagWatchZDC; } + Bool_t GetFlagWatchV0 () { return fFlagWatchV0 ; } + Bool_t GetFlagWatchFMD() { return fFlagWatchFMD; } + + void FillLRCProcessors( int nTracks, Double_t eventCentrality ); + void ProfilePhiByHand( int numberOfAcceptedTracksForLRC ); + void UseToyEvents(); + + void SetEtaRegionForTests( Double_t etaRegionForTests ) { fEtaRegionForTests = etaRegionForTests; } + Double_t GetEtaRegionForTests() { return fEtaRegionForTests; } + + void SetMultCutInEtaRegion( Double_t multCutInEtaRegion ) { fMultCutInEtaRegion = multCutInEtaRegion; } + Double_t GetMultCutInEtaRegion() { return fMultCutInEtaRegion; } + + inline void FixAngleInTwoPi( Double_t &lPhi ) + { + if ( lPhi > 2 * TMath::Pi() ) + lPhi -= 2 * TMath::Pi(); + else if ( lPhi < 0 ) + lPhi += 2 * TMath::Pi(); + } + + void SetFlagSuppressAddingSomeHistos( Bool_t flagSuppressAddingSomeHistos ) { fFlagSuppressAddingSomeHistos = flagSuppressAddingSomeHistos; } + + enum enTaskObjectParameters { kMaxParticlesNumber = 15000, kMaxLRCprocArrayPointers = 10000 }; // default TPC & TOF pid (via GetTPCpid & GetTOFpid) + +protected: + void SetParticleTypeToProcessors( int windowId, TString strPid ); + + Int_t fNumberOfPhiSectors; // n of phi rotations + Bool_t fFlagSuppressAddingSomeHistos; //flag to include in output list some histos or not include + // AliLRCBase *fLRCprocArrayPointers[kMaxLRCprocArrayPointers]; + + // Track cuts + TString fAnalysisLevel; //ESD, AOD or MC + AliESDtrackCuts *fEsdTrackCuts; // esd track cuts + UInt_t fAODtrackCutBit;//track cut bit from track selection (only used for AODs) + + // Array with different track cuts to remember in simple event Tree + TObjArray fArrTrackCuts; //AliESDtrackCuts* [100]; // Arr with different track cuts + TString fArrCutsNames[100]; // Arr with names of different track cuts + TH1I *fHistCutsNamesBins; //! tracks passed different cut sets in histogram bins + Bool_t fSwitchToListingCuts; // switch to remember cuts desicions and not to drop track by fTrackCuts + + + // en_AnalysisType fAnalysisType; // type of analysis + + //SPD tracklets cut + Int_t fMinNumberOfSPDtracklets; //Minimum number of SPD tracklets in ESD event + + // Acceptance cuts + Double_t fMaxPtLimit; //Max Pt filter + Double_t fMinPtLimit; // Min Pt filter + Double_t fKineLowPtCut; // Min Pt for Kine tracks + + // Nch cuts + Int_t fMinAcceptedTracksCut; //Minimum number of accepted tracks in event + Int_t fMaxAcceptedTracksCut; //Maximum number of accepted tracks in event + + // Vtx cuts + Bool_t fCheckForkVtx; // Check for vertex + Bool_t fCheckForVtxPosition; // Check if vertex position in range + Double_t fVxMax; // X vrtx max + Double_t fVyMax; // Y vrtx max + Double_t fVzMax; // Z vrtx max + + + TList fLRCproc; // AliLRCProcess objects list + TList* fOutList; //! Task Output data container + + Bool_t fRunKine; // ESD/AOD - KINE switch + Bool_t fAnalyseMCESD; // MCESD switch + Bool_t fShowEventStats; // Allows per event debug output (trigger Nch, cuts etc) + Bool_t fShowPerTrackStats; // Allows per track debug output + + + Double_t fEtaRegionForTests; //eta region to tests + Double_t fMultCutInEtaRegion; // cut on mult in eta region + + // QA histos + + TH1I *fHistEventCutStats; //! Event cut statistics + TH1I *fHistTrackCutStats; //! Track cut statistics + TH1I *fHistAODTrackStats; //! AOD track bits statistics + + + TH1D *fHistVx; //! Vx hist + TH1D *fHistVy; //! Vy hist + TH1D *fHistVz; //! Vz hist + + TH1D *fHistVxMCrecoDiff; //! Vx hist MC-reco diff + TH1D *fHistVyMCrecoDiff; //! Vy hist MC-reco diff + TH1D *fHistVzMCrecoDiff; //! Vz hist MC-reco diff + + TH1I *fHistVertexNconributors; //! vertex contributors number + TH1I *fHistNumberOfPileupVerticesTracks; //! number of pileup verteces in event (ESD or AOD) by tracks + TH1I *fHistNumberOfPileupVerticesSPD; //! number of pileup verteces in event (ESD or AOD) by SPD + + TH2F *fHistEventPlane; //event plane distribution + + + TH1F *fHistPt; //! Overal Pt spectrum + TH1F *fHistEta; //! Overal Eta spectrum + TH1F *fHistEtaAODpure; //! Overal Eta spectrum aod pure before cuts + TH1F *fHistPhi; //! Overal Phi spectrum + TH2D *fHistEtaPhi; //! 2D plot for checking acceptance + TH1F *fHistPhiLRCrotationsCheck; //! Overal Phi spectrum for LRC rotations + TH1F *fHistPhiArtificialProfilingCheck; //! hist for the check of profiled phi + TH1F *fHistPhiArtificialProfilingCheckWrtEvPlane; //! hist for the check of profiled phi wrt event plane + TH1F *fHistPhiArtificialEvPlane; //! hist artificial event plane + + TH2D *fHistEtaVsZvCoverage; //! Statistics on tracks Zv and Eta for all tracks + TH2D *fHistEtaVsZvCoverageAccepted; //! Statistics on tracks Zv and Eta for accepted tracks + + TH1D *fHistMultBeforeCuts; //! Histo: Number of tracks before applying cuts + TH1D *fHistAcceptedMult; //! Number of accepted tracks histo + TH1D *fHistAcceptedTracks; //! Number of tracks accepted for filling LRC processors, histo + TH1D *fHistMultiplicityInEtaRegion; //! Number of tracks in |eta| region + TH1D *fHistMultiplicityInEtaRegionAfterPtCuts; //! Number of tracks in |eta| region after Pt Cuts + TH2D *fHist2DMultiplicityMCESDInEtaRegion; //! Number of tracks in |eta| region (MC vs ESD) + TH1D *fHistAcceptedTracksAfterPtCuts; //! Number of tracks accepted for filling LRC processors, histo + TH1D *fHistAcceptedTPCtracks; //! Number of accepted tracks with TPC inner param + TH1D *fHistClustersTPC; //! Number of TPC clusters distribution + TH1D *fHistClustersTPCafterCuts; //! Number of TPC clusters distribution after cuts + TH1D *fHistCrossedRowsTPC; //! Number of TPC crossed rows + TH1D *fHistCrossedRowsTPCafterCuts; //! Number of TPC crossed rows after cuts + + + TH1D *fHistClustersITS; //! Number of ITS clusters distribution + TH1D *fHistTrackletsITS; //! Number of ITS tracklets distribution + TH2D *fHist2DClustersTPCvsPt; //! Number of TPC clusters vs Pt distribution (to see the dependence!) + TH2D *fHist2DClustersTPCvsEta; //! Number of TPC clusters vs Eta distribution (to see the dependence!) + + TH2D *fHist2DAcceptedTracksPtvsEta; //! rejected tracks pt vs eta + + TH1D *fHistMClabels; //! MC labels + TH1D *fHistRejectedTracksCharge; //! Charge of rejected tracks + TH1D *fHistTracksCharge; //! Charge of accepted tracks (zero is filled only for MC truth) + + //netcharge study + TH1D *fHistPtPlus; //! pt distr for + + TH1D *fHistPtMinus; //! pt distr for - + TH1D *fHistNetChargeVsPt; //! Net charge vs pt of accepted tracks + TH1D *fHistChargePlusVsPtTmp; //! Net charge vs pt of accepted tracks + + TH1D *fHistChargeMinusVsPtTmp; //! Net charge vs pt of accepted tracks - + TH2D *fHist2DNetChargeVsPt; //! Net charge vs pt of accepted tracks 2D + TH2D *fHist2DNetChargeVsPtCorrectedOnEventMean; //! Net charge vs pt of accepted tracks 2D shifted by mean + TH2D *fHist2DNetChargeVsPtCorrectedOnEventMeanNormOnNch; //! Net charge vs pt of accepted tracks 2D norm on nCh + + AliAnalysisTaskLRC(const AliAnalysisTaskLRC&); // not implemented + AliAnalysisTaskLRC& operator=(const AliAnalysisTaskLRC&); // not implemented + + TH1D *fHistProbabilitiesPID; //!hist of esd pid prob-s + //Double_t *fProbabilitiesPID; //! array of esd pid prob-s + TH1D *fHistESDtrackMass; //!hist of esd particle masses + TH1D *fHistProbabilityPion; //!hist of pion probability + TH1D *fHistProbabilityKaon; //!hist of kaon probability + TH1D *fHistProbabilityProton; //!hist of proton probability + TH1D *fHistParticlesDistr; //!hist of particles distr + TH1D *fHistParticlesDistrBeforeCuts; //!hist of particles distr + + + + TH1D *fHistCentralityPercentile; //! centrality class + TH1D *fHistCentralityClass10; //! centrality class by 10 + TH1D *fHistCentralityClass5; //! centrality class by 5 + + + //ZDC stuff + TH1D *fHistZDCenergy[5]; //! ZDC energy for diff mult conditions + TH1D *fHistZDCparticipants; //! ZDC participants + + //V0 stuff + TH1D *fHistV0multiplicity; //! V0 mult + TH1D *fHistV0Amultiplicity; //! V0 A mult + TH1D *fHistV0Cmultiplicity; //! V0 C mult + TH2D *fHist2DV0ACmultiplicity; //! V0 A-C mult + //TH1D *fHistV0spectra; //! V0 particle masses + TH2D *fHist2DTracksAcceptedVsV0multiplicity; //! V0 mult Vs N tracks Accepted + + TH1D *fHistV0AmultiplicityRing[4]; //! V0 A mult in rings + TH1D *fHistV0CmultiplicityRing[4]; //! V0 C mult in rings + TH2D *fHist2DV0ACmultiplicityRing[4]; //! V0 A-C mult in rings + TH2D *fHist2DTracksAcceptedVsV0AmultiplicityRing[4]; //! V0A mult Rings Vs N tracks Accepted + TH2D *fHist2DTracksAcceptedVsV0CmultiplicityRing[4]; //! V0C mult Rings Vs N tracks Accepted + + TH1D *fHistV0cells ; //! V0 cells + TH1D *fHistV0Acells ; //! V0 A cells + TH1D *fHistV0Ccells ; //! V0 C cells + TH2D *fHist2DV0ACcells ; //! V0 A-C cells + + Int_t fThresholdOnV0mult; //min V0AC mult to analyse this event (default is 0) + + + //centrality class + Float_t fMinCentralityClass; // min bound on centrality percentile + Float_t fMaxCentralityClass; // max bound on centrality percentile + + + Bool_t fIsIonsAnalysis; //Ions analysis flag + Bool_t fEtInsteadOfPt; //pass the Et instead of Pt to LRC processors + + Bool_t fUsePhiShufflingByHand; //flag for manual suffling of tracks phi + Bool_t fUseToyEvents; //flag for manual suffling of tracks phi + Int_t fNumberOfToyEvents; //number of toy events + + Int_t fTmpCounter; //! TMP + + const AliPIDResponse *fPIDResponse; //! PID response object + AliPIDCombined *fPIDCombined; //! combined PID object + TH1F *fPriors[AliPID::kSPECIES]; //! priors + TH2D *fPriorsUsed[AliPID::kSPECIES]; //! priors used + TH2D *fProbTPCTOF[AliPID::kSPECIES]; //! combined probabilities vs mom TPC-TOF + TH2D *fProbAllDets[AliPID::kSPECIES]; //! combined probabilities ALL dets vs mom + + TH1D *fHistPidMaxProbability; //!hist of max probabilities for arrays PID species + TH1D *fHistPidPureMaxProbability; //!hist of max probabilities for arrays PID species (when detId is TPC+TOF) + + TString fStrPIDforFwd; //PID name for FWD win + TString fStrPIDforBwd; //PID name for BWD win + Bool_t fPIDsensingFlag; //flag that we sense PID in processors + + + int fMultForZDCstudy[5]; //! threshold multiplicities for ZDC study + + //artificial inefficiency (27.09.12) + Double_t fArtificialInefficiency; // inefficiency by hand in [0,1], default is 0 + TH2D *fHistNumberOfDroppedByHandTracks; //! Number of tracks which were dropped by hand vs N of accepted tracks + TRandom3 *fRand; //random generator for some uses + + //phi artificial gaps + Double_t fPhiArtificialGapBegin; // inefficiency in phi - gap position edge begins + Double_t fPhiArtificialGapEnd; // inefficiency in phi - gap position edge ends + + //flags for inclusion of detectors info: + Bool_t fFlagWatchZDC; //study ZDC issues + Bool_t fFlagWatchV0; //study V0 issues + Bool_t fFlagWatchFMD; //study FMD issues + + + TStopwatch *fAnalysisTimer; + + + //arrays with data for LRC processors + Double_t fArrayTracksPt[kMaxParticlesNumber]; + Double_t fArrayTracksEta[kMaxParticlesNumber]; + Double_t fArrayTracksPhi[kMaxParticlesNumber]; + Short_t fArrayTracksCharge[kMaxParticlesNumber]; + Int_t fArrayTracksPID[kMaxParticlesNumber]; + + + //test MC particles + // TH1D *fHistMCvertexRdeltaFromParent; //!MC R hist + // TH1F *fHistMCparentsStat; //! MC parent ratios for different partile classes + // TH1F *fHistMCparentsEta[kNumberOfParentParticleClassesInMC]; //! MC parents eta distributions for different particle classes + // TH1F *fHistMCchildsEta[kNumberOfParentParticleClassesInMC]; //! MC childs eta distributions for different partile classes + // TH1F *fHistMCdeltaEtaChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta eta b/n parent and child + // TH1F *fHistMCdeltaPhiChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta phi b/n parent and child + // TH2D *fHist2DMCchildrenPhiChildParent[kNumberOfParentParticleClassesInMC]; //! MC delta b/n parent and child in eta-phi + + // TH1F *fHistMCNumberOfChildren[kNumberOfParentParticleClassesInMC]; //! Number of children for fathers in MC (for different father classes) + // TH1D *fHistMCchildrenEtaDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. eta and each child's eta for each father (for different father classes) + // TH1D *fHistMCchildrenPhiDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. phi and each child's phi for each father (for different father classes) + // TH2D *fHist2DMCchildrenPhiDeviationsFromAverage[kNumberOfParentParticleClassesInMC]; //! MC delta b/n av. eta-phi and each child's eta and phi for each father (for different father classes) + + // TString fStrMCparticleClassForFillingLRC; // name of particle class for LRC filling (default is All) + // Double_t fEtaMCanalysisCutMin; // spec MC analysis: cut on eta + // Double_t fEtaMCanalysisCutMax; // spec MC analysis: cut on eta + + // TH1F *fHistMCparentDeepness; //! MC deepness of parent tree from "physical primary" children + // TH1F *fHistMCparentsInitialStat; //! MC initial papa particle class distr + + // TH1F *fHistMCEtaInitialQuark; //! MC eta distr of "initial" quarks + // TH1F *fHistMCEtaInitialGluon; //! MC eta distr of "initial" gluons + // TH1F *fHistMCEtaInitialProton; //! MC eta distr of "initial" protons + + // TH1F *fHistMCnumberInitialQuarksInEvent; //! MC initial quarks number distr + // TH1F *fHistMCnumberInitialGluonsInEvent; //! MC initial gluons number distr + // TH1F *fHistMCnumberInitialProtonInEvent; //! MC initial proton number distr (check that there are 2) + + // TH1F *fHistMCnumberChildrenFromInitialQuarksInEvent; //! MC children number from initial quarks distr + // TH1F *fHistMCnumberChildrenFromInitialGluonsInEvent; //! MC children number from initial gluons distr + // TH1F *fHistMCnumberChildrenFromInitialProtonInEvent; //! MC children number from initial proton distr (check that there are 2) + + + // 4.01.2012: MyTree stuff + // AliSimpleEvent *fSimpleEvent; // instance of simple event to be filled in analysis loop + // Int_t fNsimpleEvents; + // TTree *fEventTree; //! event tree to write into output file + // Bool_t fSetIncludeEventTreeInOutput; // flag to use event tree or not + + ClassDef(AliAnalysisTaskLRC, 11 ); +}; + +#endif diff --git a/PWGCF/EBYE/LRC/AliLRCProcess.cxx b/PWGCF/EBYE/LRC/AliLRCProcess.cxx index 182088fd8f0..5f329139892 100644 --- a/PWGCF/EBYE/LRC/AliLRCProcess.cxx +++ b/PWGCF/EBYE/LRC/AliLRCProcess.cxx @@ -1,1431 +1,1431 @@ -/************************************************************************** - * Authors: Andrey Ivanov, Igor Altsybeev. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -// This class creates TH2D histogramms for Nch - Nch , Nch - Pt , Pt - Pt -// dirtributions for given ETA windows and some supplementary data for Long Range Correlation (LRC) analysis . -// Class is designid to work with AliAnalysisTaskLRC - -// Authors : Andrey Ivanov, Igor Altsybeev, St.Peterburg State University -// Email: Igor.Altsybeev@cern.ch - -#include "Riostream.h" -#include "AliLRCProcess.h" -//#include "THnSparse.h" -#include "TH1F.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TProfile.h" -#include "TList.h" -#include "TString.h" -#include "TMath.h" -//#include "TClonesArray.h" - -//#include //for particle mass only -ClassImp(AliLRCProcess) - -//const bool useSparse = false;//false; -//const bool useAccumulatingHist = true;//false; -using std::endl; -using std::cout; - -AliLRCProcess::AliLRCProcess():fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE) - ,fUseSparse(false) - ,fUseAccumulatingHist(true) - ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0) - ,fStartForwardPhi(0) - ,fEndForwardPhi(0) - ,fStartBackwardETA(0) - ,fEndBackwardETA(0) - ,fStartBackwardPhi(0) - ,fEndBackwardPhi(0) - ,fDoubleSidedBackwardPhiWindow(kFALSE) - ,fHiPt(0) - ,fLoPt(0) - ,fHiMultHor(0) - ,fLowMultHor(0) - ,fHiMultVert(0) - ,fLowMultVert(0) - ,fMultBinsHor(0) - ,fMultBinsVert(0) - ,fPtBins(0) - ,fPtHistXaxisRebinFactor(1) - ,fSumPtFw(0) - ,fSumPtBw(0) - ,fSumPtBw2(0) - ,fNchFw(0) - ,fNchBw(0) - ,fNchFwPlus(0) - ,fNchBwPlus(0) - ,fNchFwMinus(0) - ,fNchBwMinus(0) - ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0) - - ,fHistPtForward(0) - ,fHistEtaForward(0) - ,fHistNchForward(0) - ,fHistNchForwardPtPt(0) - ,fHistPhiForward(0) - ,fHistTracksChargeForward(0) - ,fHistPtPlusForward(0) - ,fHistPtMinusForward(0) - ,fHistNetChargeVsPtForward(0) - - ,fHistPtBackward(0) - ,fHistEtaBackward(0) - ,fHistNchBackward(0) - ,fHistPhiBackward(0) - ,fHistTracksChargeBackward(0) - ,fHistPtPlusBackward(0) - ,fHistPtMinusBackward(0) - ,fHistNetChargeVsPtBackward(0) - - ,fArrAccumulatedValues(0) - // ,fHistArrayLabeling(0) - ,fEventCentrality(0) - ,fHistNfCentrality(0) - ,fHistTestPIDForward(0) - ,fHistTestPIDBackward(0) - ,fHistDifferenceNf(0) - ,fHistDifferenceNb(0) - - ,fPidForward(-1)//kLRCany) - ,fPidBackward(-1)//kLRCany) - //,fWhichParticleToProcess(kLRCany)//kLRCany) - //,fPidFillCondition(kLRCpidIgnored) - //,fNumberOfSectors(1) - //,fNeedToRotateSector(kFALSE) -{ - //fWhichParticleToProcess = kLRCany; //default - all particle types - //fPidFillCondition = kLRCpidIgnored; - SetCorrespondanceWithAliROOTpid(); - ZeroPidArrays(); -} - -AliLRCProcess::AliLRCProcess(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA ): fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE) - ,fUseSparse(false) - ,fUseAccumulatingHist(true) - ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0), fStartForwardPhi(0),fEndForwardPhi(0),fStartBackwardETA(0), fEndBackwardETA(0),fStartBackwardPhi(0) - ,fEndBackwardPhi(0) - ,fDoubleSidedBackwardPhiWindow(kFALSE) - ,fHiPt(0) - ,fLoPt(0) - ,fHiMultHor(0) - ,fLowMultHor(0) - ,fHiMultVert(0) - ,fLowMultVert(0) - ,fMultBinsHor(0) - ,fMultBinsVert(0) - ,fPtBins(0) - ,fPtHistXaxisRebinFactor(1) - ,fSumPtFw(0), fSumPtBw(0), fSumPtBw2(0),fNchFw(0) - ,/*fNchFwPtPt(0),*/ fNchBw(0) - ,fNchFwPlus(0) - ,fNchBwPlus(0) - ,fNchFwMinus(0) - ,fNchBwMinus(0) - ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0) - - ,fHistPtForward(0) - ,fHistEtaForward(0) - ,fHistNchForward(0) - ,fHistNchForwardPtPt(0) - ,fHistPhiForward(0) - ,fHistTracksChargeForward(0) - ,fHistPtPlusForward(0) - ,fHistPtMinusForward(0) - ,fHistNetChargeVsPtForward(0) - - ,fHistPtBackward(0) - ,fHistEtaBackward(0) - ,fHistNchBackward(0) - ,fHistPhiBackward(0) - ,fHistTracksChargeBackward(0) - ,fHistPtPlusBackward(0) - ,fHistPtMinusBackward(0) - ,fHistNetChargeVsPtBackward(0) - - ,fArrAccumulatedValues(0) - // ,fHistArrayLabeling(0) - ,fEventCentrality(0) - ,fHistNfCentrality(0) - ,fHistTestPIDForward(0) - ,fHistTestPIDBackward(0) - ,fHistDifferenceNf(0) - ,fHistDifferenceNb(0) - ,fPidForward(-1)//kLRCany) - ,fPidBackward(-1)//kLRCany) - //,fWhichParticleToProcess(kLRCany)//kLRCany) - //,fPidFillCondition(kLRCpidIgnored) - //,fNumberOfSectors(1) - //,fNeedToRotateSector(kFALSE) -{ - // Constructor with window setup makes ready-to-run processor - fEventCount=0; - - //fWhichParticleToProcess = kLRCany; //default - all particle types - //fPidFillCondition = kLRCpidIgnored; - - //cout << "TEST" << endl; - SetETAWindows( _StartForwardETA, _EndForwardETA,_StartBakwardETA,_EndBakwardETA); - SetHistPtRange( 0.15, 1.5, 270 ); - SetHistMultRange( 0, 0, 100 ); - SetForwardWindowPhi( 0, 2*TMath::Pi() ); - SetBackwardWindowPhi( 0, 2*TMath::Pi() ); - - SetCorrespondanceWithAliROOTpid(); - ZeroPidArrays(); - - - -} - -Bool_t AliLRCProcess::InitDataMembers() -{ - //Printf("INITDATAMEMBERS"); - // This method is actualy creating output histogramms - // Thist method is to be called in CreateOutputObjects method of AliAnalysisTask - //cout<<" # Init for "<SetOwner(); // IMPORTANT! - - fOutList->SetName(fShortDef); - - Double_t lowMultHor, hiMultHor; - Double_t lowMultVert, hiMultVert; - - lowMultHor = fLowMultHor - 0.5; - hiMultHor = fHiMultHor + 0.5; - - lowMultVert = fLowMultVert - 0.5; - hiMultVert = fHiMultVert + 0.5; - - - //TArray to accumulate data, with names hist - //26.01.2013: array with accumulated values - //fArrAccumulatedValues = new TClonesArray("Float_t", en_arr_labels_total );//TArrayF(en_arr_labels_total); - if ( fUseAccumulatingHist ) - { - fArrAccumulatedValues = new TH1D( "fArrAccumulatedValues", "Accumulating hist with labeling", en_arr_labels_total,-0.5,en_arr_labels_total-0.5); - TString gArrayMemberNames[en_arr_labels_total]; - gArrayMemberNames[ en_arr_labels_NN_Nevents ] = "NN_Nevents" ; - gArrayMemberNames[ en_arr_labels_NN_Nf ] = "NN_Nf" ; - gArrayMemberNames[ en_arr_labels_NN_Nb ] = "NN_Nb" ; - gArrayMemberNames[ en_arr_labels_NN_N2_f ] = "NN_N2_f" ; - gArrayMemberNames[ en_arr_labels_NN_Nf_Nb ] = "NN_Nf_Nb" ; - gArrayMemberNames[ en_arr_labels_NN_N2_b ] = "NN_N2_b" ; - - gArrayMemberNames[ en_arr_labels_PtN_Nevents ] = "PtN_Nevents" ; - gArrayMemberNames[ en_arr_labels_PtN_Nf ] = "PtN_Nf" ; - gArrayMemberNames[ en_arr_labels_PtN_PtB ] = "PtN_PtB" ; - gArrayMemberNames[ en_arr_labels_PtN_N2_f ] = "PtN_N2_f" ; - gArrayMemberNames[ en_arr_labels_PtN_Ptb_Nf ] = "PtN_Ptb_Nf" ; - - gArrayMemberNames[ en_arr_labels_PtPt_Nevents] = "PtPt_Nevents" ; - gArrayMemberNames[ en_arr_labels_PtPt_PtF ] = "PtPt_PtF" ; - gArrayMemberNames[ en_arr_labels_PtPt_PtB ] = "PtPt_PtB" ; - gArrayMemberNames[ en_arr_labels_PtPt_Pt2_f ] = "PtPt_Pt2_f" ; - gArrayMemberNames[ en_arr_labels_PtPt_Ptf_Ptb] = "PtPt_Ptf_Ptb" ; - - for( Int_t i = 1; i <= en_arr_labels_total; i++ ) - fArrAccumulatedValues->GetXaxis()->SetBinLabel(i,gArrayMemberNames[i-1].Data()); - //fOutList->Add(fArrAccumulatedValues); - fOutList->Add(fArrAccumulatedValues); - } - - - - - // Window statistics histograms - - // ########## Forward - - fHistPtForward = new TH1D("fHistPtForward", "P_{T} distribution in Forward window", 100, 0.0, 5); - fHistPtForward->GetXaxis()->SetTitle("P_{T} (GeV/c)"); - fHistPtForward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); - fHistPtForward->SetMarkerStyle(kFullCircle); - - - fHistEtaForward = new TH1D("fEtaForward", "#eta distribution in Forward window", 200, -2, 2); - fHistEtaForward->GetXaxis()->SetTitle("ETA"); - fHistEtaForward->GetYaxis()->SetTitle("dN/ETA"); - fHistEtaForward->SetMarkerStyle(kFullCircle); - - - fHistNchForward = new TH1D("fHistNchForward", "N_{ch} distribution in Forward window", fMultBinsHor, lowMultHor, hiMultHor); - fHistNchForward->GetXaxis()->SetTitle("N_{ch}"); - fHistNchForward->GetYaxis()->SetTitle("dN/dN_{ch}"); - fHistNchForward->SetMarkerStyle(kFullCircle); - - fHistNchForwardPtPt = new TH1D("fHistNchForwardPtPt", "N_{ch} distribution in Forward window for PtPt accept conditions", fMultBinsHor, lowMultHor, hiMultHor); - fHistNchForwardPtPt->GetXaxis()->SetTitle("N_{ch}"); - fHistNchForwardPtPt->GetYaxis()->SetTitle("dN/dN_{ch}"); - fHistNchForwardPtPt->SetMarkerStyle(kFullCircle); - - fHistPhiForward = new TH1D("fPhiForward", "#phi distribution in Forward window", 144, 0, 2*TMath::Pi()); - fHistPhiForward->GetXaxis()->SetTitle("Phi"); - fHistPhiForward->GetYaxis()->SetTitle("dN/Phi"); - fHistPhiForward->SetMarkerStyle(kFullCircle); - - fHistTestPIDForward = new TH1D("fHistTestPIDForward","PID distribution in Forward window;PID;N",5,-0.5,4.5); - TString gBinParticleNames[5] = {/*"Other",*/"Electron","Muon","Pion","Kaon", "Proton"}; - for(Int_t i = 1; i <= 5; i++) - fHistTestPIDForward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data()); - - //15/12/2012: charge hist - fHistTracksChargeForward = new TH1D("fHistTracksChargeForward","Accepted tracks charge;charge;Entries",3,-1.5,1.5); - - - // ### net charge vs pt study (July 2013) - const int kPtNetChargePtBins = 200; - const double kPtNetChargePtMin = 0.1; - const double kPtNetChargePtMax = 2.1; - - //pt plus - fHistPtPlusForward = new TH1D("fHistPtPlusForward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistPtPlusForward); - //pt minus - fHistPtMinusForward = new TH1D("fHistPtMinusForward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistPtMinusForward); - //net charge vs pT - fHistNetChargeVsPtForward = new TH1D("fHistNetChargeVsPtForward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistNetChargeVsPtForward); - - - // ########## Backward - - fHistPtBackward = new TH1D("fHistPtBakward", "P_{T} distribution in Backward window", 100, 0.0, 5); - fHistPtBackward->GetXaxis()->SetTitle("P_{T} (GeV/c)"); - fHistPtBackward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); - fHistPtBackward->SetMarkerStyle(kFullCircle); - - - fHistEtaBackward = new TH1D("fEtaBakward", "#eta distribution in Backward window", 200, -2, 2); - fHistEtaBackward->GetXaxis()->SetTitle("ETA"); - fHistEtaBackward->GetYaxis()->SetTitle("dN/ETA"); - fHistEtaBackward->SetMarkerStyle(kFullCircle); - - - fHistNchBackward = new TH1D("fHistNchBakward", "N_{ch} distribution in Backward window", fMultBinsVert, lowMultVert, hiMultVert); - fHistNchBackward->GetXaxis()->SetTitle("N_{ch}"); - fHistNchBackward->GetYaxis()->SetTitle("dN/dN_{ch}"); - fHistNchBackward->SetMarkerStyle(kFullCircle); - - fHistPhiBackward = new TH1D("fPhiBakward", "#phi distribution in Backward window", 144, 0, 2*TMath::Pi()); - fHistPhiBackward->GetXaxis()->SetTitle("Phi"); - fHistPhiBackward->GetYaxis()->SetTitle("dN/Phi"); - fHistPhiBackward->SetMarkerStyle(kFullCircle); - - fHistTestPIDBackward = new TH1D("fHistTestPIDBackward","PID distribution in Backward window;PID;N",5,-0.5,4.5); - for(Int_t i = 1; i <= 5; i++) - fHistTestPIDBackward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data()); - - - //15/12/2012: charge hist - fHistTracksChargeBackward = new TH1D("fHistTracksChargeBackward","Accepted tracks charge;charge;Entries",3,-1.5,1.5); - - // ### net charge vs pt study (July 2013) - //pt plus - fHistPtPlusBackward = new TH1D("fHistPtPlusBackward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistPtPlusBackward); - //pt minus - fHistPtMinusBackward = new TH1D("fHistPtMinusBackward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistPtMinusBackward); - //net charge vs pT - fHistNetChargeVsPtBackward = new TH1D("fHistNetChargeVsPtBackward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); - fOutList->Add(fHistNetChargeVsPtBackward); - - - - - - //Overal statistics histograms - - fHistPt = new TH1F("fHistPt", "P_{T} distribution", 100, 0.0, 5.0); - fHistPt->GetXaxis()->SetTitle("P_{T} (GeV/c)"); - fHistPt->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); - fHistPt->SetMarkerStyle(kFullCircle); - - - fHistEta = new TH1F("fHistEta", "#eta distribution", 200, -2, 2); - fHistEta->GetXaxis()->SetTitle("ETA"); - fHistEta->GetYaxis()->SetTitle("dN/ETA"); - fHistEta->SetMarkerStyle(kFullCircle); - - - - // -------- LRC histograms - //new cloud implementation - //const int lSparseDim = en_sparse_total; - //const int nSparseBins = 1000; - - - /* from AliROOT //deprecated! - enum EParticleType { - kElectron = 0, - kMuon = 1, - kPion = 2, - kKaon = 3, - kProton = 4, - kPhoton = 5, - kPi0 = 6, - kNeutron = 7, - kKaon0 = 8, - kEleCon = 9, - kDeuteron = 10, - kTriton = 11, - kHe3 = 12, - kAlpha = 13, - kUnknown = 14 - };*/ - - - if ( fUseSparse ) - { - - //correspondance of PID blocks - //it's a way to unlink THnSparse data dimenstion from enum - fHistSparsePIDblocksLabeling = new TH1D("fHistSparsePIDblocksLabeling","THnSparse PID blocks labeling", kSparsePIDtotal,-0.5,kSparsePIDtotal-0.5); - TString gEventCutBinPIDblocksNames[kSparsePIDtotal]; // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"}; - gEventCutBinPIDblocksNames[kSparsePIDany] = "any"; - gEventCutBinPIDblocksNames[kSparsePIDdefined] = "defined"; - gEventCutBinPIDblocksNames[kSparsePIDpion] = "pion"; - gEventCutBinPIDblocksNames[kSparsePIDkaon] = "kaon"; - gEventCutBinPIDblocksNames[kSparsePIDproton] = "proton"; - - - for(Int_t i = 1; i <= kSparsePIDtotal; i++)fHistSparsePIDblocksLabeling->GetXaxis()->SetBinLabel(i,gEventCutBinPIDblocksNames[i-1].Data()); - //for(Int_t i = 0; i < nEnumBins; i++)fHistSparseDimensionLabeling->Fill( i ); - - //dimensions labelling - - fHistSparseDimensionLabeling = new TH1D("fHistSparseDimensionLabeling","THnSparse labeling", kSparseTotal,-0.5,kSparseTotal-0.5); - TString gSparseDimensionsNames[kSparseTotal]; // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"}; - gSparseDimensionsNames[kSparseNf] = "N_f"; - gSparseDimensionsNames[kSparseNb] = "N_b"; - gSparseDimensionsNames[kSparsePtF] = "Pt_f"; - gSparseDimensionsNames[kSparsePtB] = "Pt_b"; - gSparseDimensionsNames[en_sparse_N2_f] = "N2_f"; - gSparseDimensionsNames[en_sparse_Nf_Nb] = "Nf_Nb"; - gSparseDimensionsNames[en_sparse_Ptb_Nf] = "Ptb_Nf"; - gSparseDimensionsNames[en_sparse_Pt2_f] = "Pt2_f"; - gSparseDimensionsNames[en_sparse_Ptf_Ptb] = "Ptf_Ptb"; - - for( Int_t i = 1; i <= kSparseTotal; i++ ) - fHistSparseDimensionLabeling->GetXaxis()->SetBinLabel(i,gSparseDimensionsNames[i-1].Data()); - - - - Int_t* lSparseBins = new Int_t[kSparseTotal*kSparsePIDtotal]; - Double_t *lSparseXmin = new Double_t[kSparseTotal*kSparsePIDtotal]; - Double_t *lSparseXmax = new Double_t[kSparseTotal*kSparsePIDtotal]; - TString *lSparseAxisNames = new TString[kSparseTotal*kSparsePIDtotal]; - - TString *lPIDNames = new TString[kSparsePIDtotal]; - lPIDNames[ kSparsePIDany ] = Form( "any" ); - lPIDNames[ kSparsePIDdefined ] = Form( "defined" ); - lPIDNames[ kSparsePIDpion ] = Form( "pion" ); - lPIDNames[ kSparsePIDkaon ] = Form( "kaon" ); - lPIDNames[ kSparsePIDproton ] = Form( "proton" ); - - - - for ( Int_t d = 0; d < kSparsePIDtotal; ++d ) - { - Int_t binShift = kSparseTotal*d; - - lSparseAxisNames[kSparseNf + binShift] = Form( "axisNf_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[kSparseNb + binShift] = Form( "axisNb_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[kSparsePtF + binShift] = Form( "axisPtf_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[kSparsePtB + binShift] = Form( "axisPtb_%s", lPIDNames[ d ].Data() ); - - lSparseAxisNames[en_sparse_N2_f + binShift] = Form( "axisN2_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[en_sparse_Nf_Nb + binShift] = Form( "axisNf_Nb_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[en_sparse_Ptb_Nf + binShift] = Form( "axisPtb_Nf_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[en_sparse_Pt2_f + binShift] = Form( "axisPt2_f_%s", lPIDNames[ d ].Data() ); - lSparseAxisNames[en_sparse_Ptf_Ptb + binShift] = Form( "axisPtf_Ptb_%s", lPIDNames[ d ].Data() ); - - - lSparseBins[kSparseNf + binShift ] = fMultBinsHor; - lSparseXmin[kSparseNf + binShift ] = lowMultHor; - lSparseXmax[kSparseNf + binShift ] = hiMultHor; - lSparseBins[kSparseNb + binShift ] = fMultBinsVert; - lSparseXmin[kSparseNb + binShift ] = lowMultVert; - lSparseXmax[kSparseNb + binShift ] = hiMultVert; - //} - //for (Int_t d = 2; d < lSparseDim; ++d) { - lSparseBins[kSparsePtF + binShift ] = fPtBins; - lSparseXmin[kSparsePtF + binShift ] = fLoPt; - lSparseXmax[kSparsePtF + binShift ] = fHiPt; - lSparseBins[kSparsePtB + binShift ] = fPtBins; - lSparseXmin[kSparsePtB + binShift ] = fLoPt; - lSparseXmax[kSparsePtB + binShift ] = fHiPt; - - - - - - //} - /* - lSparseBins[en_sparse_Et_f + binShift ] = 500; - lSparseXmin[en_sparse_Et_f + binShift ] = 0.2; - lSparseXmax[en_sparse_Et_f + binShift ] = 2.7; - lSparseBins[en_sparse_Et_b + binShift ] = 500; - lSparseXmin[en_sparse_Et_b + binShift ] = 0.2; - lSparseXmax[en_sparse_Et_b + binShift ] = 2.7; -*/ - - lSparseBins[en_sparse_N2_f + binShift ] = (fMultBinsHor-1)*(fMultBinsHor-1)+1; - lSparseXmin[en_sparse_N2_f + binShift ] = fLowMultHor*fLowMultHor-0.5; // ! use global mult without shift - lSparseXmax[en_sparse_N2_f + binShift ] = fHiMultHor*fHiMultHor+0.5; - //lSparseBins[en_sparse_N_b] = fMultBinsVert; - //lSparseXmin[en_sparse_N_b] = lowMultVert; - //lSparseXmax[en_sparse_N_b] = hiMultVert; - lSparseBins[en_sparse_Nf_Nb + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1; - lSparseXmin[en_sparse_Nf_Nb + binShift ] = fLowMultHor*fLowMultVert-0.5; - lSparseXmax[en_sparse_Nf_Nb + binShift ] = fHiMultHor*fHiMultVert+0.5; - - - - lSparseBins[en_sparse_Ptb_Nf + binShift ] = /*(fMultBinsHor-1)**/(10*fPtBins);//+1; - lSparseXmin[en_sparse_Ptb_Nf + binShift ] = fLowMultHor*fLoPt-0.5; - lSparseXmax[en_sparse_Ptb_Nf + binShift ] = fHiMultHor*fHiPt+0.5; - - lSparseBins[en_sparse_Pt2_f + binShift ] = (10*fPtBins);//*(fPtBins);//+1; - lSparseXmin[en_sparse_Pt2_f + binShift ] = fLoPt*fLoPt; - lSparseXmax[en_sparse_Pt2_f + binShift ] = fHiPt*fHiPt; - - lSparseBins[en_sparse_Ptf_Ptb + binShift ] = (10*fPtBins);//*(fPtBins)+1; - lSparseXmin[en_sparse_Ptf_Ptb + binShift ] = fLoPt*fLoPt; - lSparseXmax[en_sparse_Ptf_Ptb + binShift ] = fHiPt*fHiPt; - - /* - lSparseBins[en_sparse_Nf_plus + binShift ] = fMultBinsHor; - lSparseXmin[en_sparse_Nf_plus + binShift ] = lowMultHor; - lSparseXmax[en_sparse_Nf_plus + binShift ] = hiMultHor; - lSparseBins[en_sparse_Nf_minus + binShift ] = fMultBinsHor; - lSparseXmin[en_sparse_Nf_minus + binShift ] = lowMultHor; - lSparseXmax[en_sparse_Nf_minus + binShift ] = hiMultHor; - - lSparseBins[en_sparse_Nb_plus + binShift ] = fMultBinsVert; - lSparseXmin[en_sparse_Nb_plus + binShift ] = lowMultVert; - lSparseXmax[en_sparse_Nb_plus + binShift ] = hiMultVert; - lSparseBins[en_sparse_Nb_minus + binShift ] = fMultBinsVert; - lSparseXmin[en_sparse_Nb_minus + binShift ] = lowMultVert; - lSparseXmax[en_sparse_Nb_minus + binShift ] = hiMultVert; - - lSparseBins[en_sparse_Nf_plus_Nb_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1; - lSparseXmin[en_sparse_Nf_plus_Nb_minus + binShift ] = fLowMultHor*fLowMultVert-0.5; - lSparseXmax[en_sparse_Nf_plus_Nb_minus + binShift ] = fHiMultHor*fHiMultVert+0.5; - - lSparseBins[en_sparse_Nb_plus_Nf_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1); - lSparseXmin[en_sparse_Nb_plus_Nf_minus + binShift ] = fLowMultHor*fLowMultVert-0.5; - lSparseXmax[en_sparse_Nb_plus_Nf_minus + binShift ] = fHiMultHor*fHiMultVert+0.5; - */ - } - - fHistClouds = new THnSparseD("cloudLRC", "cloudLRC", kSparseTotal*kSparsePIDtotal, lSparseBins, lSparseXmin, lSparseXmax); - //end of cloud implementation - - //set axis names - TAxis *lSparseAxis = 0x0; - for ( Int_t d = 0; d < kSparseTotal*kSparsePIDtotal; ++d ) - { - lSparseAxis = fHistClouds->GetAxis( d ); - lSparseAxis->SetNameTitle( lSparseAxisNames[d], lSparseAxisNames[d] ); - } - - - delete [] lSparseBins; - delete [] lSparseXmin; - delete [] lSparseXmax; - delete [] lSparseAxisNames; - - - fOutList->Add(fHistSparseDimensionLabeling); - fOutList->Add(fHistSparsePIDblocksLabeling); - - // bool useSparse = false; - - // !!!!!! temp comment! - fOutList->Add(fHistClouds); - } - - - fHistNN = new TH2D("NN","NN",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsVert, lowMultVert, hiMultVert ); - fHistPtN = new TH2D("PtN","PtN",fMultBinsHor, lowMultHor, hiMultHor,fPtBins/* /fPtHistXaxisRebinFactor*/,fLoPt,fHiPt); - fHistPtPt = new TH2D("PtPt","PtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt,fPtBins,fLoPt,fHiPt); - fProfNberr = new TProfile("nber","nber",fMultBinsHor, lowMultHor, hiMultHor); - fProfNberrPtPt = new TProfile("nberPtPt","nberPtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt); - fProfdPtB = new TProfile("dPtB","Overal multievent Pt_Backward (first bin) Pt_Backward^2 (sec. bin) ",16,0.5,16.5); - fProfTestLRC = new TProfile("TestLRC","Test LRC calculaion via TProfile",fMultBinsHor, lowMultHor, hiMultHor); - - fHistNfCentrality = new TH2D("NfCentrality","NfCentrality",fMultBinsHor, lowMultHor, hiMultHor,101,-1.01,100.01); - fHistDifferenceNf = new TH2D("fHistDifferenceNf","Hist nF-nB;nF;nF-nB",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsHor,-hiMultHor,hiMultHor); - fHistDifferenceNb = new TH2D("fHistDifferenceNb","Hist nB-nF;nB;nB-nF",fMultBinsVert, lowMultVert, hiMultVert,fMultBinsVert,-hiMultVert,hiMultVert); - - // ---------- Adding data members to output list - - // Adding overal statistics - - //commented: to save memory - //fOutList->Add(fHistPt); - //fOutList->Add(fHistEta); - - //Adding LRC hists - - - if (1) - { - fOutList->Add(fHistNN); - fOutList->Add(fHistPtN); - fOutList->Add(fHistPtPt); - } - fOutList->Add(fProfNberr); - fOutList->Add(fProfNberrPtPt); - fOutList->Add(fProfdPtB); - fOutList->Add(fProfTestLRC); - - - //Adding window statistics - - - - fOutList->Add(fHistNchForward); - fOutList->Add(fHistNchBackward); - fOutList->Add(fHistNchForwardPtPt); - - fOutList->Add(fHistPtForward); - fOutList->Add(fHistPtBackward); - - fOutList->Add(fHistEtaForward); - fOutList->Add(fHistEtaBackward); - - fOutList->Add(fHistPhiForward); - fOutList->Add(fHistPhiBackward); - - fOutList->Add(fHistTracksChargeForward); - fOutList->Add(fHistTracksChargeBackward); - - fOutList->Add(fHistTestPIDForward); - fOutList->Add(fHistTestPIDBackward); - - // fOutList->Add(fHistNfCentrality); - - - //fOutList->Add(fHistDifferenceNf); - //fOutList->Add(fHistDifferenceNb); - - // Adding status to dPtB - - fProfdPtB->Fill(3 , fStartForwardETA); - fProfdPtB->Fill(4 , fEndForwardETA); - fProfdPtB->Fill(5 , fStartBackwardETA); - fProfdPtB->Fill(6 , fEndBackwardETA); - fProfdPtB->Fill(7 , fStartForwardPhi); - fProfdPtB->Fill(8 , fEndForwardPhi); - fProfdPtB->Fill(9 , fStartBackwardPhi); - fProfdPtB->Fill(10 , fEndBackwardPhi); - - - - - fIsOnline = kTRUE; - return kTRUE; -} -AliLRCProcess::~AliLRCProcess() -{ - //Destructor - -} - -// --------------------------------------- Setters ------------------ -void AliLRCProcess::SetShortDef() -{ - // Creating task and output container name - char str[200]; - snprintf(str,200, "TaskLRCw%3.1fto%3.1fvs%3.1fto%3.1f",fStartForwardETA,fEndForwardETA,fStartBackwardETA,fEndBackwardETA); - /*if ( fWhichParticleToProcess != kLRCany - && (int)fWhichParticleToProcess > 0 && (int)fWhichParticleToProcess <= 6 ) //to avoid program falling - { - char str2[80]; - TString gBinParticleNames[6] = {"Other","Electron","Muon","Pion","Kaon", "Proton"}; - snprintf(str2,80, "%s_%s",str,gBinParticleNames[(int)fWhichParticleToProcess].Data()); - fShortDef= str2; - } - else*/ - fShortDef= str; - -} - -void AliLRCProcess::SetForwardWindow(Double_t StartETA,Double_t EndETA) -{ - //setter for the forward eta window - fStartForwardETA=StartETA; - fEndForwardETA=EndETA; - SetShortDef(); -} -void AliLRCProcess::SetBackwardWindow(Double_t StartETA,Double_t EndETA) -{ - //setter for the backward eta window - fStartBackwardETA=StartETA; - fEndBackwardETA=EndETA; - SetShortDef(); -} -void AliLRCProcess::SetETAWindows(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA) -{ - //setter for the eta windows - fStartForwardETA=_StartForwardETA; - fEndForwardETA=_EndForwardETA; - fStartBackwardETA=_StartBakwardETA; - fEndBackwardETA=_EndBakwardETA; - SetShortDef(); -} -void AliLRCProcess::GetETAWindows(Double_t &_StartForwardETA,Double_t &_EndForwardETA,Double_t &_StartBakwardETA,Double_t &_EndBakwardETA) -{ - //getter for the eta windows - _StartForwardETA = fStartForwardETA; - _EndForwardETA = fEndForwardETA; - _StartBakwardETA = fStartBackwardETA; - _EndBakwardETA = fEndBackwardETA; -} - -void AliLRCProcess::GetPhiWindows(Double_t &_StartForwardPhi,Double_t &_EndForwardPhi,Double_t &_StartBakwardPhi,Double_t &_EndBakwardPhi) -{ - //getter for the eta windows - _StartForwardPhi = fStartForwardPhi; - _EndForwardPhi = fEndForwardPhi; - _StartBakwardPhi = fStartBackwardPhi; - _EndBakwardPhi = fEndBackwardPhi; -} - -void AliLRCProcess::SetParticleType( char* strForwardOrBackward, char* strPid ) -{ - //cout << "hm! strForwardOrBackward = " << strForwardOrBackward - // << ", strPid = " << strPid << endl; - //cout << "before ae! fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl; - - int lPid = -1;//kLRCany; - if ( !strcmp( strPid, "pion") ) - lPid = 2;//kLRCpion; - else if ( !strcmp( strPid, "kaon") ) - lPid = 3;//kLRCkaon; - else if ( !strcmp( strPid, "proton") ) - lPid = 4;//kLRCproton; - else if ( !strcmp( strPid, "knownpid") ) - lPid = 100;//will will histos if we KNOW PID! (not important which) - - //set pid for window - if ( !strcmp( strForwardOrBackward, "fwd") ) - fPidForward = lPid; - else if ( !strcmp( strForwardOrBackward, "bkwd") ) - fPidBackward = lPid; - //cout << "ae! lPid = " << lPid << ", fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl; - //int aaaa; - //cin>> aaaa; -} - - -void AliLRCProcess::SetHistPtRangeForwardWindowRebinFactor( Int_t ptHistXaxisRebinFactor ) -{ - // Rebining for Pt histograms X-axis - if(fIsOnline) - { - Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); - return ; - } - fPtHistXaxisRebinFactor = ptHistXaxisRebinFactor; -} - -void AliLRCProcess::SetHistPtRange(Double_t LoPt,Double_t HiPt,Int_t PtBins) -{ - // Sets Pt range and number of bins for Pt axis of histos - if(fIsOnline) - { - Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); - return ; - } - // Setter for Pt range and N bins in histos - fLoPt=LoPt; - fHiPt=HiPt; - fPtBins=PtBins; -} -void AliLRCProcess::SetHistMultRange( Int_t whichWindow, Int_t LoMult,Int_t HiMult,Int_t MultBins) -{ - // Setter for multiplicity range and N bins in histos - if ( whichWindow == 0 ) //set range for both windows - { - SetHistMultRangeHor( LoMult, HiMult, MultBins) ; - SetHistMultRangeVert( LoMult, HiMult, MultBins) ; - } - else if ( whichWindow == 1 ) //for fwd - SetHistMultRangeHor( LoMult, HiMult, MultBins) ; - else if ( whichWindow == 2 ) //for bwd - SetHistMultRangeVert( LoMult, HiMult, MultBins) ; - /* - - if(fIsOnline) - { - Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); - return ; - } - fLoMult=LoMult; - fHiMult=HiMult; - if(!MultBins) - { - fMultBins=fHiMult-fLoMult+1; - }else - { - fMultBins=MultBins; - }*/ -} - -void AliLRCProcess::SetHistMultRangeHor(Int_t LoMult,Int_t HiMult,Int_t MultBins) -{ - // Setter for multiplicity range and N bins in histos - if(fIsOnline) - { - Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); - return ; - } - fLowMultHor = LoMult; - fHiMultHor = HiMult; - if(!MultBins) - { - fMultBinsHor = fHiMultHor-fLowMultHor+1; - }else - { - fMultBinsHor = MultBins; - } -} - -void AliLRCProcess::SetHistMultRangeVert(Int_t LoMult,Int_t HiMult,Int_t MultBins) -{ - // Setter for multiplicity range and N bins in histos - if(fIsOnline) - { - Printf("Can't change histos parameters after InitDataMembers() was called! \n"); - return ; - } - fLowMultVert = LoMult; - fHiMultVert = HiMult; - if(!MultBins) - { - fMultBinsVert = fHiMultVert-fLowMultVert+1; - }else - { - fMultBinsVert = MultBins; - } -} - -void AliLRCProcess::SetOutputSlotNumber(Int_t SlotNumber) -{ - //Sets number of output slot for LRCProcessor - fOutputSlot=SlotNumber; -} - -//________________________________________________________________________ - - - -TList* AliLRCProcess::CreateOutput() const -{ - // Creates a link to output data TList - return fOutList; -} - -TString AliLRCProcess::GetShortDef() const -{ - return fShortDef; -} - -Int_t AliLRCProcess::GetOutputSlotNumber() const -{ - // Returns number of output slot for LRCProcessor - return fOutputSlot; -} - -void AliLRCProcess::StartEvent() -{ - // Open new Event for track by track event import - if(fIsEventOpend) // Check if trying to open event more than once ! - { - Printf("Event is already opened! Auto finishing ! \n"); -// cout<Fill( particleType ); - - fNchFw++; - Charge > 0 ? fNchFwPlus++ : fNchFwMinus++; - fSumPtFw+=Pt; - fHistPtForward->Fill(Pt); - fHistEtaForward->Fill(Eta); - fHistPhiForward->Fill(Phi); - - //added 15.12.12 - fHistTracksChargeForward->Fill(Charge); - - //added 23.03 - for ( int pid = 0; pid < kSparsePIDtotal; pid++ ) - { - if ( pid == kSparsePIDany //write ALL pid types - || - ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles - || - ( fCorrespondanceWithAliROOTpid[pid] == particleType ) //write not defined particles - ) - { - fNchFwPID[pid]++; - Charge > 0 ? fNchFwPlusPID[pid]++ : fNchFwMinusPID[pid]++; - fSumPtFwPID[pid] += Pt; - if ( pid != kSparsePIDany ) - { - Double_t lMass = 0;//AliPID::ParticleMass( particleType ); - fSumEtFwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ; - } - } - } - - //netcharge part (July 2013) - fHistNetChargeVsPtForward->Fill( Pt, Charge ); - if ( Charge > 0 ) - fHistPtPlusForward->Fill( Pt ); - else if ( Charge < 0 ) - fHistPtMinusForward->Fill( Pt ); - - -} -void AliLRCProcess::AddTrackBackward(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) -{ - // Imports track to the event directly to Backward window - if(!fIsEventOpend) - {Printf("Event is not opened!\n"); - return;} - - /*Bool_t lAddDecision = kFALSE; - - if ( fPidBackward == 100 ) //add particle if we know pid (i.e. particleType != -1) - { - if ( particleType != -1 ) - { - lAddDecision = kTRUE; - //cout << "fill fwd with pid " << particleType << endl; - } - } - else if ( fPidBackward != -1 ) //if we specify pid for this window - just check it - { - if ( particleType == fPidBackward ) - { - lAddDecision = kTRUE; - //cout << "fill fwd with pid " << particleType << endl; - } - } - else - lAddDecision = kTRUE; - - if ( !lAddDecision ) - return; - */ - fHistTestPIDBackward->Fill( particleType ); - - fNchBw++; - Charge > 0 ? fNchBwPlus++ : fNchBwMinus++; - fSumPtBw += Pt; - fSumPtBw2 += Pt*Pt; - fProfdPtB->Fill( 1, Pt ); - fProfdPtB->Fill( 2, Pt*Pt ); - fHistPtBackward->Fill( Pt ); - fHistEtaBackward->Fill( Eta ); - fHistPhiBackward->Fill( Phi ); - - //added 15.12.12 - fHistTracksChargeBackward->Fill(Charge); - - //added 23.03 - for ( int pid = 0; pid < kSparsePIDtotal; pid++ ) - { - if ( pid == kSparsePIDany //write ALL pid types - || - ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles - || - ( fCorrespondanceWithAliROOTpid[pid] == particleType ) - ) - { - fNchBwPID[pid]++; - Charge > 0 ? fNchBwPlusPID[pid]++ : fNchBwMinusPID[pid]++; - fSumPtBwPID[pid] += Pt; - if ( pid != kSparsePIDany ) - { - Double_t lMass = 0;//AliPID::ParticleMass( particleType ); - fSumEtBwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ; - } - - } - } - - //netcharge part (July 2013) - fHistNetChargeVsPtBackward->Fill( Pt, Charge ); - if ( Charge > 0 ) - fHistPtPlusBackward->Fill( Pt ); - else if ( Charge < 0 ) - fHistPtMinusBackward->Fill( Pt ); - -} - - - -void AliLRCProcess::AddTrackPtEta(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) -{ - //cout << Pt << endl; - - - //if particle type is different - ignore the track - //if ( fWhichParticleToFill != -1 && ParticleType != fWhichParticleToFill ) - // return; - //Track by track event import : Imports track to the event - - //cout << "fWhichParticleToProcess = " << fWhichParticleToProcess - // << ", particleType = " << particleType << endl; - if(!fIsEventOpend) - {Printf("Event is not opened!\n"); - return;} - - // Global track data - fHistPt->Fill(Pt); - fHistEta->Fill(Eta); - - //Bool_t lAddForwardDecision = kFALSE; - //Bool_t lAddBackwardDecision = kFALSE; - - //Forward window - if( ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) ) - if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) )//( fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) ) - { - AddTrackForward( Pt, Eta, Phi, Charge, particleType ); - //if ( fPidFillCondition == kLRCpidForForwardOnly - // || fPidFillCondition == kLRCpidForBoth ) - //if ( fPidForward != -1 )//kLRCany ) - //{ - // if ( particleType == fPidForward )//kLRCpion )//particleType ) - // { - // lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi ); - //cout << "fill fwd with pid " << particleType << endl; - // } - //} - //else - // lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi ); - } - //if ( lAddForwardDecision ) - //{ - // AddTrackForward( Pt, Eta, Phi, particleType ); - // fHistTestPIDForward->Fill( particleType ); - //} - - //Backward window - if( ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) ) - if ( - ( - IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi) //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi ) - ) - || - ( - fDoubleSidedBackwardPhiWindow //if this option is true - && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() ) // - //&& ( fStartBackwardPhi + TMath::Pi() < Phi ) - //&& ( Phi < fEndBackwardPhi + TMath::Pi() ) - ) - ) - { - AddTrackBackward( Pt, Eta, Phi, Charge, particleType ); - //if ( fPidFillCondition == kLRCpidForBackwardOnly - // || fPidFillCondition == kLRCpidForBoth ) - //if ( fPidBackward != -1 )//kLRCany ) - //{ - // if ( particleType == fPidBackward )//kLRCpion )//particleType ) - // { - // lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi ); - //cout << "fill bkwd with pid " << particleType << endl; - // } - - //} - //else - // lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi ); - } - //if ( lAddBackwardDecision ) - //{ - // AddTrackBackward( Pt, Eta, Phi, particleType ); - // fHistTestPIDBackward->Fill( particleType ); - //} - -} - - - -void AliLRCProcess::AddTrackPtEtaMixing( Int_t winFB, Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) -{ - // put track in F or B window using varible winFB - if(!fIsEventOpend) - { - Printf("Event is not opened!\n"); - return; - } - - // Global track data - fHistPt->Fill(Pt); - fHistEta->Fill(Eta); - - - //Forward window - if( winFB == 0 - && ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) ) - if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) ) // (fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) ) - { - AddTrackForward( Pt, Eta, Phi, Charge, particleType ); - } - - //Backward window - if( winFB == 1 - && ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) ) - if ( - ( - IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi) //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi ) - ) - || - ( - fDoubleSidedBackwardPhiWindow //if this option is true - && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() ) - //&& ( fStartBackwardPhi + TMath::Pi() < Phi ) - //&& ( Phi < fEndBackwardPhi + TMath::Pi() ) - ) - ) - { - AddTrackBackward( Pt, Eta, Phi, Charge, particleType ); - } - - -} - -void AliLRCProcess::FinishEvent(Bool_t kDontCount) -{ - // Track by track event import : Close opened event and fill event summary histos - - if(!fIsEventOpend) - { - Printf("Event is not opened!\n"); - return; - } - if ( kDontCount ) //don't count this event! just ignore it - { - fIsEventOpend = kFALSE; - return; - } - //fHistSparseDimensionLabeling->Fill(1); - //Filling even-total data - //cout << "filling" << endl; - /*Double_t lCloudData[en_sparse_total*en_sparse_PID_total]; - lCloudData[en_sparse_N_f] = fNchFw; //write Nf - lCloudData[en_sparse_N_b] = fNchBw; //write Nb - lCloudData[en_sparse_N2_f] = fNchFw*fNchFw; //write Nf^2 - lCloudData[en_sparse_Nf_Nb] = fNchFw*fNchBw; //write Nb - - lCloudData[en_sparse_Pt_f] = 0; //fill bin 0, if don't have appropriate PtSum - lCloudData[en_sparse_Pt_b] = 0; //fill bin 0, if don't have appropriate PtSum - - lCloudData[en_sparse_Nf_plus] = fNchFwPlus; - lCloudData[en_sparse_Nf_minus] = fNchFwMinus; - lCloudData[en_sparse_Nb_plus] = fNchBwPlus; - lCloudData[en_sparse_Nb_minus] = fNchBwMinus; - lCloudData[en_sparse_Nf_plus_Nb_minus] = fNchFwPlus * fNchBwMinus; - lCloudData[en_sparse_Nb_plus_Nf_minus] = fNchBwPlus * fNchFwMinus; */ - - fHistNN->Fill(fNchFw,fNchBw); - - if ( fUseAccumulatingHist ) - { - fArrAccumulatedValues->Fill( en_arr_labels_NN_Nevents, 1 ); - fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf , fNchFw ); - fArrAccumulatedValues->Fill( en_arr_labels_NN_Nb , fNchBw ); - fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_f , fNchFw*fNchFw ); - fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf_Nb , fNchFw*fNchBw ); - fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_b , fNchBw*fNchBw ); - } - - if( fNchBw != 0 ) - { - fSumPtBw = fSumPtBw / fNchBw; - //lCloudData[en_sparse_Pt_b] = fSumPtBw; //write - fProfTestLRC->Fill( fNchFw, fSumPtBw ); - fHistPtN->Fill( fNchFw, fSumPtBw ); - //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw << endl; - fProfNberr->Fill(fNchFw, 1.0 / fNchBw); - - if ( fUseAccumulatingHist ) - { - fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nevents, 1 ); - fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nf , fNchFw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtN_PtB , fSumPtBw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtN_N2_f , fNchFw*fNchFw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtN_Ptb_Nf , fSumPtBw*fNchFw ); - } - - if( fNchFw != 0 ) - { - fSumPtFw = fSumPtFw / fNchFw; - //lCloudData[en_sparse_Pt_f] = fSumPtFw; //write - fHistPtPt->Fill( fSumPtFw, fSumPtBw ); - fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw ); - // dPtB for PtPt - fProfdPtB->Fill( 15, fSumPtBw, fNchBw ); - fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw ); - fHistNchForwardPtPt->Fill(fNchFw); - - if ( fUseAccumulatingHist ) - { - fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Nevents, 1 ); - fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtF , fSumPtFw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtB , fSumPtBw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Pt2_f , fSumPtFw*fSumPtFw ); - fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Ptf_Ptb, fSumPtBw*fSumPtFw ); - } - - } - } - - - - - - if ( fUseSparse ) - { - Double_t lCloudData[kSparseTotal*kSparsePIDtotal]; - - for (Int_t d = 0; d < kSparsePIDtotal; ++d) - { - Int_t binShift = kSparseTotal*d; //step over dimension set - - lCloudData[kSparseNf + binShift ] = fNchFwPID[d]; //write Nf - lCloudData[kSparseNb + binShift ] = fNchBwPID[d]; //write Nb - lCloudData[en_sparse_N2_f + binShift ] = fNchFwPID[d]*fNchFwPID[d]; //write Nf^2 - lCloudData[en_sparse_Nf_Nb + binShift ] = fNchFwPID[d]*fNchBwPID[d]; //write Nb - - lCloudData[kSparsePtF + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum - lCloudData[kSparsePtB + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum - - lCloudData[en_sparse_Ptb_Nf + binShift ] = 0; - lCloudData[en_sparse_Pt2_f + binShift ] = 0; - lCloudData[en_sparse_Ptf_Ptb + binShift ] = 0; - - - if( fNchBwPID[d] != 0 ) - { - double lSumPtBwPID = fSumPtBwPID[d] / fNchBwPID[d]; - lCloudData[kSparsePtB + binShift ] = lSumPtBwPID; //write - - fSumEtBwPID[d] = fSumEtBwPID[d] / fNchBwPID[d]; - //lCloudData[en_sparse_Et_b + binShift ] = fSumEtBwPID[d]; //write - lCloudData[en_sparse_Ptb_Nf + binShift ] = lSumPtBwPID * fNchFwPID[d]; - - //fProfTestLRC->Fill( fNchFw, fSumPtBw ); - //fHistPtN->Fill( fNchFw, fSumPtBw ); - //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw << endl; - - //fProfNberr->Fill(fNchFw, 1.0 / fNchBw); - - - if( fNchFwPID[d] != 0 ) - { - double lSumPtFwPID = fSumPtFwPID[d] / fNchFwPID[d]; - lCloudData[kSparsePtF + binShift ] = lSumPtFwPID; //write - - fSumEtFwPID[d] = fSumEtFwPID[d] / fNchFwPID[d]; - - lCloudData[en_sparse_Pt2_f + binShift ] = lSumPtFwPID * lSumPtFwPID; - lCloudData[en_sparse_Ptf_Ptb + binShift ] = lSumPtFwPID*lSumPtBwPID; - - //lCloudData[en_sparse_Et_f + binShift ] = fSumEtFwPID[d]; //write - //fHistPtPt->Fill( fSumPtFw, fSumPtBw ); - //fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw ); - // dPtB for PtPt - //fProfdPtB->Fill( 15, fSumPtBw, fNchBw ); - //fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw ); - //fHistNchForwardPtPt->Fill(fNchFw); - - } - } - /* - lCloudData[en_sparse_Nf_plus + binShift ] = fNchFwPlusPID[d]; - lCloudData[en_sparse_Nf_minus + binShift ] = fNchFwMinusPID[d]; - lCloudData[en_sparse_Nb_plus + binShift ] = fNchBwPlusPID[d]; - lCloudData[en_sparse_Nb_minus + binShift ] = fNchBwMinusPID[d]; - lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = fNchFwPlusPID[d] * fNchBwMinusPID[d]; - lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = fNchBwPlusPID[d] * fNchFwMinusPID[d]; - */ - } - - //tmp (22.03): fill pid with fignya data - /* for (Int_t d = 1; d < en_sparse_PID_total; ++d) - { - Int_t binShift = en_sparse_total*d; - lCloudData[en_sparse_N_f + binShift ] = 1+d; //write Nf - lCloudData[en_sparse_N_b + binShift ] = 2+d; //write Nb - lCloudData[en_sparse_N2_f + binShift ] = 3+d; //write Nf^2 - lCloudData[en_sparse_Nf_Nb + binShift ] = 4+d; //write Nb - - lCloudData[en_sparse_Pt_f + binShift ] = 5+d; //fill bin 0, if don't have appropriate PtSum - lCloudData[en_sparse_Pt_b + binShift ] = 6+d; //fill bin 0, if don't have appropriate PtSum - - lCloudData[en_sparse_Nf_plus + binShift ] = 7+d; - lCloudData[en_sparse_Nf_minus + binShift ] = 8+d; - lCloudData[en_sparse_Nb_plus + binShift ] = 9+d; - lCloudData[en_sparse_Nb_minus + binShift ] = 10+d; - lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = 11+d; - lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = 12+d; - } - */ - - // cout << "before filling" << endl; - fHistClouds->Fill( lCloudData ); //fill sparse hist with Nf, Nb, , - // cout << "filled." << endl; - } - - - - - //additional info-hist - if ( fNchFw > 0 || fNchBw > 0 ) - { - Double_t lAvMult = ( fNchFw + fNchBw ) / 2.; - fHistDifferenceNf->Fill( fNchFw, ( fNchFw-fNchBw ) / lAvMult ); - fHistDifferenceNb->Fill( fNchBw, ( fNchBw-fNchFw ) / lAvMult); - } - - //cout << "n particles: " << fNchFw << " , Back = " << fNchBw << endl; - //cout << "fHistNN: " << fHistNN->GetEntries() << endl; - //cout << "mean= " << fHistNN->GetMean() << endl; - - - fHistNchForward->Fill(fNchFw); - fHistNchBackward->Fill(fNchBw); - - fEventCount++; - fIsEventOpend = kFALSE; - - //fill nf-centr plot - fHistNfCentrality->Fill( fNchFw, fEventCentrality ); - - //cout< //for particle mass only +ClassImp(AliLRCProcess) + +//const bool useSparse = false;//false; +//const bool useAccumulatingHist = true;//false; +using std::endl; +using std::cout; + +AliLRCProcess::AliLRCProcess():fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE) + ,fUseSparse(false) + ,fUseAccumulatingHist(true) + ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0) + ,fStartForwardPhi(0) + ,fEndForwardPhi(0) + ,fStartBackwardETA(0) + ,fEndBackwardETA(0) + ,fStartBackwardPhi(0) + ,fEndBackwardPhi(0) + ,fDoubleSidedBackwardPhiWindow(kFALSE) + ,fHiPt(0) + ,fLoPt(0) + ,fHiMultHor(0) + ,fLowMultHor(0) + ,fHiMultVert(0) + ,fLowMultVert(0) + ,fMultBinsHor(0) + ,fMultBinsVert(0) + ,fPtBins(0) + ,fPtHistXaxisRebinFactor(1) + ,fSumPtFw(0) + ,fSumPtBw(0) + ,fSumPtBw2(0) + ,fNchFw(0) + ,fNchBw(0) + ,fNchFwPlus(0) + ,fNchBwPlus(0) + ,fNchFwMinus(0) + ,fNchBwMinus(0) + ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0) + + ,fHistPtForward(0) + ,fHistEtaForward(0) + ,fHistNchForward(0) + ,fHistNchForwardPtPt(0) + ,fHistPhiForward(0) + ,fHistTracksChargeForward(0) + ,fHistPtPlusForward(0) + ,fHistPtMinusForward(0) + ,fHistNetChargeVsPtForward(0) + + ,fHistPtBackward(0) + ,fHistEtaBackward(0) + ,fHistNchBackward(0) + ,fHistPhiBackward(0) + ,fHistTracksChargeBackward(0) + ,fHistPtPlusBackward(0) + ,fHistPtMinusBackward(0) + ,fHistNetChargeVsPtBackward(0) + + ,fArrAccumulatedValues(0) + // ,fHistArrayLabeling(0) + ,fEventCentrality(0) + ,fHistNfCentrality(0) + ,fHistTestPIDForward(0) + ,fHistTestPIDBackward(0) + ,fHistDifferenceNf(0) + ,fHistDifferenceNb(0) + + ,fPidForward(-1)//kLRCany) + ,fPidBackward(-1)//kLRCany) + //,fWhichParticleToProcess(kLRCany)//kLRCany) + //,fPidFillCondition(kLRCpidIgnored) + //,fNumberOfSectors(1) + //,fNeedToRotateSector(kFALSE) +{ + //fWhichParticleToProcess = kLRCany; //default - all particle types + //fPidFillCondition = kLRCpidIgnored; + SetCorrespondanceWithAliROOTpid(); + ZeroPidArrays(); +} + +AliLRCProcess::AliLRCProcess(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA ): fIsEventOpend(kFALSE), fIsOnline(kFALSE), fDisplayInitOnDemandWarning(kTRUE) + ,fUseSparse(false) + ,fUseAccumulatingHist(true) + ,fEventCount(0),fStartForwardETA(0), fEndForwardETA(0), fStartForwardPhi(0),fEndForwardPhi(0),fStartBackwardETA(0), fEndBackwardETA(0),fStartBackwardPhi(0) + ,fEndBackwardPhi(0) + ,fDoubleSidedBackwardPhiWindow(kFALSE) + ,fHiPt(0) + ,fLoPt(0) + ,fHiMultHor(0) + ,fLowMultHor(0) + ,fHiMultVert(0) + ,fLowMultVert(0) + ,fMultBinsHor(0) + ,fMultBinsVert(0) + ,fPtBins(0) + ,fPtHistXaxisRebinFactor(1) + ,fSumPtFw(0), fSumPtBw(0), fSumPtBw2(0),fNchFw(0) + ,/*fNchFwPtPt(0),*/ fNchBw(0) + ,fNchFwPlus(0) + ,fNchBwPlus(0) + ,fNchFwMinus(0) + ,fNchBwMinus(0) + ,fOutList(0), fShortDef(0),fOutputSlot(0), fHistPt(0),fHistEta(0),fHistClouds(0),fHistNN(0),fHistPtN(0),fHistPtPt(0),fProfNberr(0),fProfNberrPtPt(0),fProfdPtB(0),fProfTestLRC(0),fHistSparseDimensionLabeling(0),fHistSparsePIDblocksLabeling(0) + + ,fHistPtForward(0) + ,fHistEtaForward(0) + ,fHistNchForward(0) + ,fHistNchForwardPtPt(0) + ,fHistPhiForward(0) + ,fHistTracksChargeForward(0) + ,fHistPtPlusForward(0) + ,fHistPtMinusForward(0) + ,fHistNetChargeVsPtForward(0) + + ,fHistPtBackward(0) + ,fHistEtaBackward(0) + ,fHistNchBackward(0) + ,fHistPhiBackward(0) + ,fHistTracksChargeBackward(0) + ,fHistPtPlusBackward(0) + ,fHistPtMinusBackward(0) + ,fHistNetChargeVsPtBackward(0) + + ,fArrAccumulatedValues(0) + // ,fHistArrayLabeling(0) + ,fEventCentrality(0) + ,fHistNfCentrality(0) + ,fHistTestPIDForward(0) + ,fHistTestPIDBackward(0) + ,fHistDifferenceNf(0) + ,fHistDifferenceNb(0) + ,fPidForward(-1)//kLRCany) + ,fPidBackward(-1)//kLRCany) + //,fWhichParticleToProcess(kLRCany)//kLRCany) + //,fPidFillCondition(kLRCpidIgnored) + //,fNumberOfSectors(1) + //,fNeedToRotateSector(kFALSE) +{ + // Constructor with window setup makes ready-to-run processor + fEventCount=0; + + //fWhichParticleToProcess = kLRCany; //default - all particle types + //fPidFillCondition = kLRCpidIgnored; + + //cout << "TEST" << endl; + SetETAWindows( _StartForwardETA, _EndForwardETA,_StartBakwardETA,_EndBakwardETA); + SetHistPtRange( 0.15, 1.5, 270 ); + SetHistMultRange( 0, 0, 100 ); + SetForwardWindowPhi( 0, 2*TMath::Pi() ); + SetBackwardWindowPhi( 0, 2*TMath::Pi() ); + + SetCorrespondanceWithAliROOTpid(); + ZeroPidArrays(); + + + +} + +Bool_t AliLRCProcess::InitDataMembers() +{ + //Printf("INITDATAMEMBERS"); + // This method is actualy creating output histogramms + // Thist method is to be called in CreateOutputObjects method of AliAnalysisTask + //cout<<" # Init for "<SetOwner(); // IMPORTANT! + + fOutList->SetName(fShortDef); + + Double_t lowMultHor, hiMultHor; + Double_t lowMultVert, hiMultVert; + + lowMultHor = fLowMultHor - 0.5; + hiMultHor = fHiMultHor + 0.5; + + lowMultVert = fLowMultVert - 0.5; + hiMultVert = fHiMultVert + 0.5; + + + //TArray to accumulate data, with names hist + //26.01.2013: array with accumulated values + //fArrAccumulatedValues = new TClonesArray("Float_t", en_arr_labels_total );//TArrayF(en_arr_labels_total); + if ( fUseAccumulatingHist ) + { + fArrAccumulatedValues = new TH1D( "fArrAccumulatedValues", "Accumulating hist with labeling", en_arr_labels_total,-0.5,en_arr_labels_total-0.5); + TString gArrayMemberNames[en_arr_labels_total]; + gArrayMemberNames[ en_arr_labels_NN_Nevents ] = "NN_Nevents" ; + gArrayMemberNames[ en_arr_labels_NN_Nf ] = "NN_Nf" ; + gArrayMemberNames[ en_arr_labels_NN_Nb ] = "NN_Nb" ; + gArrayMemberNames[ en_arr_labels_NN_N2_f ] = "NN_N2_f" ; + gArrayMemberNames[ en_arr_labels_NN_Nf_Nb ] = "NN_Nf_Nb" ; + gArrayMemberNames[ en_arr_labels_NN_N2_b ] = "NN_N2_b" ; + + gArrayMemberNames[ en_arr_labels_PtN_Nevents ] = "PtN_Nevents" ; + gArrayMemberNames[ en_arr_labels_PtN_Nf ] = "PtN_Nf" ; + gArrayMemberNames[ en_arr_labels_PtN_PtB ] = "PtN_PtB" ; + gArrayMemberNames[ en_arr_labels_PtN_N2_f ] = "PtN_N2_f" ; + gArrayMemberNames[ en_arr_labels_PtN_Ptb_Nf ] = "PtN_Ptb_Nf" ; + + gArrayMemberNames[ en_arr_labels_PtPt_Nevents] = "PtPt_Nevents" ; + gArrayMemberNames[ en_arr_labels_PtPt_PtF ] = "PtPt_PtF" ; + gArrayMemberNames[ en_arr_labels_PtPt_PtB ] = "PtPt_PtB" ; + gArrayMemberNames[ en_arr_labels_PtPt_Pt2_f ] = "PtPt_Pt2_f" ; + gArrayMemberNames[ en_arr_labels_PtPt_Ptf_Ptb] = "PtPt_Ptf_Ptb" ; + + for( Int_t i = 1; i <= en_arr_labels_total; i++ ) + fArrAccumulatedValues->GetXaxis()->SetBinLabel(i,gArrayMemberNames[i-1].Data()); + //fOutList->Add(fArrAccumulatedValues); + fOutList->Add(fArrAccumulatedValues); + } + + + + + // Window statistics histograms + + // ########## Forward + + fHistPtForward = new TH1D("fHistPtForward", "P_{T} distribution in Forward window", 100, 0.0, 5); + fHistPtForward->GetXaxis()->SetTitle("P_{T} (GeV/c)"); + fHistPtForward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); + fHistPtForward->SetMarkerStyle(kFullCircle); + + + fHistEtaForward = new TH1D("fEtaForward", "#eta distribution in Forward window", 200, -2, 2); + fHistEtaForward->GetXaxis()->SetTitle("ETA"); + fHistEtaForward->GetYaxis()->SetTitle("dN/ETA"); + fHistEtaForward->SetMarkerStyle(kFullCircle); + + + fHistNchForward = new TH1D("fHistNchForward", "N_{ch} distribution in Forward window", fMultBinsHor, lowMultHor, hiMultHor); + fHistNchForward->GetXaxis()->SetTitle("N_{ch}"); + fHistNchForward->GetYaxis()->SetTitle("dN/dN_{ch}"); + fHistNchForward->SetMarkerStyle(kFullCircle); + + fHistNchForwardPtPt = new TH1D("fHistNchForwardPtPt", "N_{ch} distribution in Forward window for PtPt accept conditions", fMultBinsHor, lowMultHor, hiMultHor); + fHistNchForwardPtPt->GetXaxis()->SetTitle("N_{ch}"); + fHistNchForwardPtPt->GetYaxis()->SetTitle("dN/dN_{ch}"); + fHistNchForwardPtPt->SetMarkerStyle(kFullCircle); + + fHistPhiForward = new TH1D("fPhiForward", "#phi distribution in Forward window", 144, 0, 2*TMath::Pi()); + fHistPhiForward->GetXaxis()->SetTitle("Phi"); + fHistPhiForward->GetYaxis()->SetTitle("dN/Phi"); + fHistPhiForward->SetMarkerStyle(kFullCircle); + + fHistTestPIDForward = new TH1D("fHistTestPIDForward","PID distribution in Forward window;PID;N",5,-0.5,4.5); + TString gBinParticleNames[5] = {/*"Other",*/"Electron","Muon","Pion","Kaon", "Proton"}; + for(Int_t i = 1; i <= 5; i++) + fHistTestPIDForward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data()); + + //15/12/2012: charge hist + fHistTracksChargeForward = new TH1D("fHistTracksChargeForward","Accepted tracks charge;charge;Entries",3,-1.5,1.5); + + + // ### net charge vs pt study (July 2013) + const int kPtNetChargePtBins = 200; + const double kPtNetChargePtMin = 0.1; + const double kPtNetChargePtMax = 2.1; + + //pt plus + fHistPtPlusForward = new TH1D("fHistPtPlusForward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistPtPlusForward); + //pt minus + fHistPtMinusForward = new TH1D("fHistPtMinusForward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistPtMinusForward); + //net charge vs pT + fHistNetChargeVsPtForward = new TH1D("fHistNetChargeVsPtForward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistNetChargeVsPtForward); + + + // ########## Backward + + fHistPtBackward = new TH1D("fHistPtBakward", "P_{T} distribution in Backward window", 100, 0.0, 5); + fHistPtBackward->GetXaxis()->SetTitle("P_{T} (GeV/c)"); + fHistPtBackward->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); + fHistPtBackward->SetMarkerStyle(kFullCircle); + + + fHistEtaBackward = new TH1D("fEtaBakward", "#eta distribution in Backward window", 200, -2, 2); + fHistEtaBackward->GetXaxis()->SetTitle("ETA"); + fHistEtaBackward->GetYaxis()->SetTitle("dN/ETA"); + fHistEtaBackward->SetMarkerStyle(kFullCircle); + + + fHistNchBackward = new TH1D("fHistNchBakward", "N_{ch} distribution in Backward window", fMultBinsVert, lowMultVert, hiMultVert); + fHistNchBackward->GetXaxis()->SetTitle("N_{ch}"); + fHistNchBackward->GetYaxis()->SetTitle("dN/dN_{ch}"); + fHistNchBackward->SetMarkerStyle(kFullCircle); + + fHistPhiBackward = new TH1D("fPhiBakward", "#phi distribution in Backward window", 144, 0, 2*TMath::Pi()); + fHistPhiBackward->GetXaxis()->SetTitle("Phi"); + fHistPhiBackward->GetYaxis()->SetTitle("dN/Phi"); + fHistPhiBackward->SetMarkerStyle(kFullCircle); + + fHistTestPIDBackward = new TH1D("fHistTestPIDBackward","PID distribution in Backward window;PID;N",5,-0.5,4.5); + for(Int_t i = 1; i <= 5; i++) + fHistTestPIDBackward->GetXaxis()->SetBinLabel(i,gBinParticleNames[i-1].Data()); + + + //15/12/2012: charge hist + fHistTracksChargeBackward = new TH1D("fHistTracksChargeBackward","Accepted tracks charge;charge;Entries",3,-1.5,1.5); + + // ### net charge vs pt study (July 2013) + //pt plus + fHistPtPlusBackward = new TH1D("fHistPtPlusBackward","p_{T} +;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistPtPlusBackward); + //pt minus + fHistPtMinusBackward = new TH1D("fHistPtMinusBackward","p_{T} -;p_{T};dN/dpT", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistPtMinusBackward); + //net charge vs pT + fHistNetChargeVsPtBackward = new TH1D("fHistNetChargeVsPtBackward","charge vs p_{T};p_{T};Q", kPtNetChargePtBins, kPtNetChargePtMin, kPtNetChargePtMax ); + fOutList->Add(fHistNetChargeVsPtBackward); + + + + + + //Overal statistics histograms + + fHistPt = new TH1F("fHistPt", "P_{T} distribution", 100, 0.0, 5.0); + fHistPt->GetXaxis()->SetTitle("P_{T} (GeV/c)"); + fHistPt->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)"); + fHistPt->SetMarkerStyle(kFullCircle); + + + fHistEta = new TH1F("fHistEta", "#eta distribution", 200, -2, 2); + fHistEta->GetXaxis()->SetTitle("ETA"); + fHistEta->GetYaxis()->SetTitle("dN/ETA"); + fHistEta->SetMarkerStyle(kFullCircle); + + + + // -------- LRC histograms + //new cloud implementation + //const int lSparseDim = en_sparse_total; + //const int nSparseBins = 1000; + + + /* from AliROOT //deprecated! + enum EParticleType { + kElectron = 0, + kMuon = 1, + kPion = 2, + kKaon = 3, + kProton = 4, + kPhoton = 5, + kPi0 = 6, + kNeutron = 7, + kKaon0 = 8, + kEleCon = 9, + kDeuteron = 10, + kTriton = 11, + kHe3 = 12, + kAlpha = 13, + kUnknown = 14 + };*/ + + + if ( fUseSparse ) + { + + //correspondance of PID blocks + //it's a way to unlink THnSparse data dimenstion from enum + fHistSparsePIDblocksLabeling = new TH1D("fHistSparsePIDblocksLabeling","THnSparse PID blocks labeling", kSparsePIDtotal,-0.5,kSparsePIDtotal-0.5); + TString gEventCutBinPIDblocksNames[kSparsePIDtotal]; // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"}; + gEventCutBinPIDblocksNames[kSparsePIDany] = "any"; + gEventCutBinPIDblocksNames[kSparsePIDdefined] = "defined"; + gEventCutBinPIDblocksNames[kSparsePIDpion] = "pion"; + gEventCutBinPIDblocksNames[kSparsePIDkaon] = "kaon"; + gEventCutBinPIDblocksNames[kSparsePIDproton] = "proton"; + + + for(Int_t i = 1; i <= kSparsePIDtotal; i++)fHistSparsePIDblocksLabeling->GetXaxis()->SetBinLabel(i,gEventCutBinPIDblocksNames[i-1].Data()); + //for(Int_t i = 0; i < nEnumBins; i++)fHistSparseDimensionLabeling->Fill( i ); + + //dimensions labelling + + fHistSparseDimensionLabeling = new TH1D("fHistSparseDimensionLabeling","THnSparse labeling", kSparseTotal,-0.5,kSparseTotal-0.5); + TString gSparseDimensionsNames[kSparseTotal]; // = {"Total","No trigger","Centrality","No vertex","Bad vertex position","HighMult cut","LowMult cut","Analyzed"}; + gSparseDimensionsNames[kSparseNf] = "N_f"; + gSparseDimensionsNames[kSparseNb] = "N_b"; + gSparseDimensionsNames[kSparsePtF] = "Pt_f"; + gSparseDimensionsNames[kSparsePtB] = "Pt_b"; + gSparseDimensionsNames[en_sparse_N2_f] = "N2_f"; + gSparseDimensionsNames[en_sparse_Nf_Nb] = "Nf_Nb"; + gSparseDimensionsNames[en_sparse_Ptb_Nf] = "Ptb_Nf"; + gSparseDimensionsNames[en_sparse_Pt2_f] = "Pt2_f"; + gSparseDimensionsNames[en_sparse_Ptf_Ptb] = "Ptf_Ptb"; + + for( Int_t i = 1; i <= kSparseTotal; i++ ) + fHistSparseDimensionLabeling->GetXaxis()->SetBinLabel(i,gSparseDimensionsNames[i-1].Data()); + + + + Int_t* lSparseBins = new Int_t[kSparseTotal*kSparsePIDtotal]; + Double_t *lSparseXmin = new Double_t[kSparseTotal*kSparsePIDtotal]; + Double_t *lSparseXmax = new Double_t[kSparseTotal*kSparsePIDtotal]; + TString *lSparseAxisNames = new TString[kSparseTotal*kSparsePIDtotal]; + + TString *lPIDNames = new TString[kSparsePIDtotal]; + lPIDNames[ kSparsePIDany ] = Form( "any" ); + lPIDNames[ kSparsePIDdefined ] = Form( "defined" ); + lPIDNames[ kSparsePIDpion ] = Form( "pion" ); + lPIDNames[ kSparsePIDkaon ] = Form( "kaon" ); + lPIDNames[ kSparsePIDproton ] = Form( "proton" ); + + + + for ( Int_t d = 0; d < kSparsePIDtotal; ++d ) + { + Int_t binShift = kSparseTotal*d; + + lSparseAxisNames[kSparseNf + binShift] = Form( "axisNf_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[kSparseNb + binShift] = Form( "axisNb_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[kSparsePtF + binShift] = Form( "axisPtf_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[kSparsePtB + binShift] = Form( "axisPtb_%s", lPIDNames[ d ].Data() ); + + lSparseAxisNames[en_sparse_N2_f + binShift] = Form( "axisN2_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[en_sparse_Nf_Nb + binShift] = Form( "axisNf_Nb_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[en_sparse_Ptb_Nf + binShift] = Form( "axisPtb_Nf_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[en_sparse_Pt2_f + binShift] = Form( "axisPt2_f_%s", lPIDNames[ d ].Data() ); + lSparseAxisNames[en_sparse_Ptf_Ptb + binShift] = Form( "axisPtf_Ptb_%s", lPIDNames[ d ].Data() ); + + + lSparseBins[kSparseNf + binShift ] = fMultBinsHor; + lSparseXmin[kSparseNf + binShift ] = lowMultHor; + lSparseXmax[kSparseNf + binShift ] = hiMultHor; + lSparseBins[kSparseNb + binShift ] = fMultBinsVert; + lSparseXmin[kSparseNb + binShift ] = lowMultVert; + lSparseXmax[kSparseNb + binShift ] = hiMultVert; + //} + //for (Int_t d = 2; d < lSparseDim; ++d) { + lSparseBins[kSparsePtF + binShift ] = fPtBins; + lSparseXmin[kSparsePtF + binShift ] = fLoPt; + lSparseXmax[kSparsePtF + binShift ] = fHiPt; + lSparseBins[kSparsePtB + binShift ] = fPtBins; + lSparseXmin[kSparsePtB + binShift ] = fLoPt; + lSparseXmax[kSparsePtB + binShift ] = fHiPt; + + + + + + //} + /* + lSparseBins[en_sparse_Et_f + binShift ] = 500; + lSparseXmin[en_sparse_Et_f + binShift ] = 0.2; + lSparseXmax[en_sparse_Et_f + binShift ] = 2.7; + lSparseBins[en_sparse_Et_b + binShift ] = 500; + lSparseXmin[en_sparse_Et_b + binShift ] = 0.2; + lSparseXmax[en_sparse_Et_b + binShift ] = 2.7; +*/ + + lSparseBins[en_sparse_N2_f + binShift ] = (fMultBinsHor-1)*(fMultBinsHor-1)+1; + lSparseXmin[en_sparse_N2_f + binShift ] = fLowMultHor*fLowMultHor-0.5; // ! use global mult without shift + lSparseXmax[en_sparse_N2_f + binShift ] = fHiMultHor*fHiMultHor+0.5; + //lSparseBins[en_sparse_N_b] = fMultBinsVert; + //lSparseXmin[en_sparse_N_b] = lowMultVert; + //lSparseXmax[en_sparse_N_b] = hiMultVert; + lSparseBins[en_sparse_Nf_Nb + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1; + lSparseXmin[en_sparse_Nf_Nb + binShift ] = fLowMultHor*fLowMultVert-0.5; + lSparseXmax[en_sparse_Nf_Nb + binShift ] = fHiMultHor*fHiMultVert+0.5; + + + + lSparseBins[en_sparse_Ptb_Nf + binShift ] = /*(fMultBinsHor-1)**/(10*fPtBins);//+1; + lSparseXmin[en_sparse_Ptb_Nf + binShift ] = fLowMultHor*fLoPt-0.5; + lSparseXmax[en_sparse_Ptb_Nf + binShift ] = fHiMultHor*fHiPt+0.5; + + lSparseBins[en_sparse_Pt2_f + binShift ] = (10*fPtBins);//*(fPtBins);//+1; + lSparseXmin[en_sparse_Pt2_f + binShift ] = fLoPt*fLoPt; + lSparseXmax[en_sparse_Pt2_f + binShift ] = fHiPt*fHiPt; + + lSparseBins[en_sparse_Ptf_Ptb + binShift ] = (10*fPtBins);//*(fPtBins)+1; + lSparseXmin[en_sparse_Ptf_Ptb + binShift ] = fLoPt*fLoPt; + lSparseXmax[en_sparse_Ptf_Ptb + binShift ] = fHiPt*fHiPt; + + /* + lSparseBins[en_sparse_Nf_plus + binShift ] = fMultBinsHor; + lSparseXmin[en_sparse_Nf_plus + binShift ] = lowMultHor; + lSparseXmax[en_sparse_Nf_plus + binShift ] = hiMultHor; + lSparseBins[en_sparse_Nf_minus + binShift ] = fMultBinsHor; + lSparseXmin[en_sparse_Nf_minus + binShift ] = lowMultHor; + lSparseXmax[en_sparse_Nf_minus + binShift ] = hiMultHor; + + lSparseBins[en_sparse_Nb_plus + binShift ] = fMultBinsVert; + lSparseXmin[en_sparse_Nb_plus + binShift ] = lowMultVert; + lSparseXmax[en_sparse_Nb_plus + binShift ] = hiMultVert; + lSparseBins[en_sparse_Nb_minus + binShift ] = fMultBinsVert; + lSparseXmin[en_sparse_Nb_minus + binShift ] = lowMultVert; + lSparseXmax[en_sparse_Nb_minus + binShift ] = hiMultVert; + + lSparseBins[en_sparse_Nf_plus_Nb_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1)+1; + lSparseXmin[en_sparse_Nf_plus_Nb_minus + binShift ] = fLowMultHor*fLowMultVert-0.5; + lSparseXmax[en_sparse_Nf_plus_Nb_minus + binShift ] = fHiMultHor*fHiMultVert+0.5; + + lSparseBins[en_sparse_Nb_plus_Nf_minus + binShift ] = (fMultBinsHor-1)*(fMultBinsVert-1); + lSparseXmin[en_sparse_Nb_plus_Nf_minus + binShift ] = fLowMultHor*fLowMultVert-0.5; + lSparseXmax[en_sparse_Nb_plus_Nf_minus + binShift ] = fHiMultHor*fHiMultVert+0.5; + */ + } + + fHistClouds = new THnSparseD("cloudLRC", "cloudLRC", kSparseTotal*kSparsePIDtotal, lSparseBins, lSparseXmin, lSparseXmax); + //end of cloud implementation + + //set axis names + TAxis *lSparseAxis = 0x0; + for ( Int_t d = 0; d < kSparseTotal*kSparsePIDtotal; ++d ) + { + lSparseAxis = fHistClouds->GetAxis( d ); + lSparseAxis->SetNameTitle( lSparseAxisNames[d], lSparseAxisNames[d] ); + } + + + delete [] lSparseBins; + delete [] lSparseXmin; + delete [] lSparseXmax; + delete [] lSparseAxisNames; + + + fOutList->Add(fHistSparseDimensionLabeling); + fOutList->Add(fHistSparsePIDblocksLabeling); + + // bool useSparse = false; + + // !!!!!! temp comment! + fOutList->Add(fHistClouds); + } + + + fHistNN = new TH2D("NN","NN",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsVert, lowMultVert, hiMultVert ); + fHistPtN = new TH2D("PtN","PtN",fMultBinsHor, lowMultHor, hiMultHor,fPtBins/* /fPtHistXaxisRebinFactor*/,fLoPt,fHiPt); + fHistPtPt = new TH2D("PtPt","PtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt,fPtBins,fLoPt,fHiPt); + fProfNberr = new TProfile("nber","nber",fMultBinsHor, lowMultHor, hiMultHor); + fProfNberrPtPt = new TProfile("nberPtPt","nberPtPt",fPtBins/fPtHistXaxisRebinFactor,fLoPt,fHiPt); + fProfdPtB = new TProfile("dPtB","Overal multievent Pt_Backward (first bin) Pt_Backward^2 (sec. bin) ",16,0.5,16.5); + fProfTestLRC = new TProfile("TestLRC","Test LRC calculaion via TProfile",fMultBinsHor, lowMultHor, hiMultHor); + + fHistNfCentrality = new TH2D("NfCentrality","NfCentrality",fMultBinsHor, lowMultHor, hiMultHor,101,-1.01,100.01); + fHistDifferenceNf = new TH2D("fHistDifferenceNf","Hist nF-nB;nF;nF-nB",fMultBinsHor, lowMultHor, hiMultHor,fMultBinsHor,-hiMultHor,hiMultHor); + fHistDifferenceNb = new TH2D("fHistDifferenceNb","Hist nB-nF;nB;nB-nF",fMultBinsVert, lowMultVert, hiMultVert,fMultBinsVert,-hiMultVert,hiMultVert); + + // ---------- Adding data members to output list + + // Adding overal statistics + + //commented: to save memory + //fOutList->Add(fHistPt); + //fOutList->Add(fHistEta); + + //Adding LRC hists + + + if (1) + { + fOutList->Add(fHistNN); + fOutList->Add(fHistPtN); + fOutList->Add(fHistPtPt); + } + fOutList->Add(fProfNberr); + fOutList->Add(fProfNberrPtPt); + fOutList->Add(fProfdPtB); + fOutList->Add(fProfTestLRC); + + + //Adding window statistics + + + + fOutList->Add(fHistNchForward); + fOutList->Add(fHistNchBackward); + fOutList->Add(fHistNchForwardPtPt); + + fOutList->Add(fHistPtForward); + fOutList->Add(fHistPtBackward); + + fOutList->Add(fHistEtaForward); + fOutList->Add(fHistEtaBackward); + + fOutList->Add(fHistPhiForward); + fOutList->Add(fHistPhiBackward); + + fOutList->Add(fHistTracksChargeForward); + fOutList->Add(fHistTracksChargeBackward); + + fOutList->Add(fHistTestPIDForward); + fOutList->Add(fHistTestPIDBackward); + + // fOutList->Add(fHistNfCentrality); + + + //fOutList->Add(fHistDifferenceNf); + //fOutList->Add(fHistDifferenceNb); + + // Adding status to dPtB + + fProfdPtB->Fill(3 , fStartForwardETA); + fProfdPtB->Fill(4 , fEndForwardETA); + fProfdPtB->Fill(5 , fStartBackwardETA); + fProfdPtB->Fill(6 , fEndBackwardETA); + fProfdPtB->Fill(7 , fStartForwardPhi); + fProfdPtB->Fill(8 , fEndForwardPhi); + fProfdPtB->Fill(9 , fStartBackwardPhi); + fProfdPtB->Fill(10 , fEndBackwardPhi); + + + + + fIsOnline = kTRUE; + return kTRUE; +} +AliLRCProcess::~AliLRCProcess() +{ + //Destructor + +} + +// --------------------------------------- Setters ------------------ +void AliLRCProcess::SetShortDef() +{ + // Creating task and output container name + char str[200]; + snprintf(str,200, "TaskLRCw%3.1fto%3.1fvs%3.1fto%3.1f",fStartForwardETA,fEndForwardETA,fStartBackwardETA,fEndBackwardETA); + /*if ( fWhichParticleToProcess != kLRCany + && (int)fWhichParticleToProcess > 0 && (int)fWhichParticleToProcess <= 6 ) //to avoid program falling + { + char str2[80]; + TString gBinParticleNames[6] = {"Other","Electron","Muon","Pion","Kaon", "Proton"}; + snprintf(str2,80, "%s_%s",str,gBinParticleNames[(int)fWhichParticleToProcess].Data()); + fShortDef= str2; + } + else*/ + fShortDef= str; + +} + +void AliLRCProcess::SetForwardWindow(Double_t StartETA,Double_t EndETA) +{ + //setter for the forward eta window + fStartForwardETA=StartETA; + fEndForwardETA=EndETA; + SetShortDef(); +} +void AliLRCProcess::SetBackwardWindow(Double_t StartETA,Double_t EndETA) +{ + //setter for the backward eta window + fStartBackwardETA=StartETA; + fEndBackwardETA=EndETA; + SetShortDef(); +} +void AliLRCProcess::SetETAWindows(Double_t _StartForwardETA,Double_t _EndForwardETA,Double_t _StartBakwardETA,Double_t _EndBakwardETA) +{ + //setter for the eta windows + fStartForwardETA=_StartForwardETA; + fEndForwardETA=_EndForwardETA; + fStartBackwardETA=_StartBakwardETA; + fEndBackwardETA=_EndBakwardETA; + SetShortDef(); +} +void AliLRCProcess::GetETAWindows(Double_t &_StartForwardETA,Double_t &_EndForwardETA,Double_t &_StartBakwardETA,Double_t &_EndBakwardETA) +{ + //getter for the eta windows + _StartForwardETA = fStartForwardETA; + _EndForwardETA = fEndForwardETA; + _StartBakwardETA = fStartBackwardETA; + _EndBakwardETA = fEndBackwardETA; +} + +void AliLRCProcess::GetPhiWindows(Double_t &_StartForwardPhi,Double_t &_EndForwardPhi,Double_t &_StartBakwardPhi,Double_t &_EndBakwardPhi) +{ + //getter for the eta windows + _StartForwardPhi = fStartForwardPhi; + _EndForwardPhi = fEndForwardPhi; + _StartBakwardPhi = fStartBackwardPhi; + _EndBakwardPhi = fEndBackwardPhi; +} + +void AliLRCProcess::SetParticleType( char* strForwardOrBackward, char* strPid ) +{ + //cout << "hm! strForwardOrBackward = " << strForwardOrBackward + // << ", strPid = " << strPid << endl; + //cout << "before ae! fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl; + + int lPid = -1;//kLRCany; + if ( !strcmp( strPid, "pion") ) + lPid = 2;//kLRCpion; + else if ( !strcmp( strPid, "kaon") ) + lPid = 3;//kLRCkaon; + else if ( !strcmp( strPid, "proton") ) + lPid = 4;//kLRCproton; + else if ( !strcmp( strPid, "knownpid") ) + lPid = 100;//will will histos if we KNOW PID! (not important which) + + //set pid for window + if ( !strcmp( strForwardOrBackward, "fwd") ) + fPidForward = lPid; + else if ( !strcmp( strForwardOrBackward, "bkwd") ) + fPidBackward = lPid; + //cout << "ae! lPid = " << lPid << ", fPidForward = " << fPidForward << ", fPidBackward = " << fPidBackward << endl; + //int aaaa; + //cin>> aaaa; +} + + +void AliLRCProcess::SetHistPtRangeForwardWindowRebinFactor( Int_t ptHistXaxisRebinFactor ) +{ + // Rebining for Pt histograms X-axis + if(fIsOnline) + { + Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); + return ; + } + fPtHistXaxisRebinFactor = ptHistXaxisRebinFactor; +} + +void AliLRCProcess::SetHistPtRange(Double_t LoPt,Double_t HiPt,Int_t PtBins) +{ + // Sets Pt range and number of bins for Pt axis of histos + if(fIsOnline) + { + Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); + return ; + } + // Setter for Pt range and N bins in histos + fLoPt=LoPt; + fHiPt=HiPt; + fPtBins=PtBins; +} +void AliLRCProcess::SetHistMultRange( Int_t whichWindow, Int_t LoMult,Int_t HiMult,Int_t MultBins) +{ + // Setter for multiplicity range and N bins in histos + if ( whichWindow == 0 ) //set range for both windows + { + SetHistMultRangeHor( LoMult, HiMult, MultBins) ; + SetHistMultRangeVert( LoMult, HiMult, MultBins) ; + } + else if ( whichWindow == 1 ) //for fwd + SetHistMultRangeHor( LoMult, HiMult, MultBins) ; + else if ( whichWindow == 2 ) //for bwd + SetHistMultRangeVert( LoMult, HiMult, MultBins) ; + /* + + if(fIsOnline) + { + Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); + return ; + } + fLoMult=LoMult; + fHiMult=HiMult; + if(!MultBins) + { + fMultBins=fHiMult-fLoMult+1; + }else + { + fMultBins=MultBins; + }*/ +} + +void AliLRCProcess::SetHistMultRangeHor(Int_t LoMult,Int_t HiMult,Int_t MultBins) +{ + // Setter for multiplicity range and N bins in histos + if(fIsOnline) + { + Printf("Can't change histos paramiters after InitDataMembers() was called! \n"); + return ; + } + fLowMultHor = LoMult; + fHiMultHor = HiMult; + if(!MultBins) + { + fMultBinsHor = fHiMultHor-fLowMultHor+1; + }else + { + fMultBinsHor = MultBins; + } +} + +void AliLRCProcess::SetHistMultRangeVert(Int_t LoMult,Int_t HiMult,Int_t MultBins) +{ + // Setter for multiplicity range and N bins in histos + if(fIsOnline) + { + Printf("Can't change histos parameters after InitDataMembers() was called! \n"); + return ; + } + fLowMultVert = LoMult; + fHiMultVert = HiMult; + if(!MultBins) + { + fMultBinsVert = fHiMultVert-fLowMultVert+1; + }else + { + fMultBinsVert = MultBins; + } +} + +void AliLRCProcess::SetOutputSlotNumber(Int_t SlotNumber) +{ + //Sets number of output slot for LRCProcessor + fOutputSlot=SlotNumber; +} + +//________________________________________________________________________ + + + +TList* AliLRCProcess::CreateOutput() const +{ + // Creates a link to output data TList + return fOutList; +} + +TString AliLRCProcess::GetShortDef() const +{ + return fShortDef; +} + +Int_t AliLRCProcess::GetOutputSlotNumber() const +{ + // Returns number of output slot for LRCProcessor + return fOutputSlot; +} + +void AliLRCProcess::StartEvent() +{ + // Open new Event for track by track event import + if(fIsEventOpend) // Check if trying to open event more than once ! + { + Printf("Event is already opened! Auto finishing ! \n"); +// cout<Fill( particleType ); + + fNchFw++; + Charge > 0 ? fNchFwPlus++ : fNchFwMinus++; + fSumPtFw+=Pt; + fHistPtForward->Fill(Pt); + fHistEtaForward->Fill(Eta); + fHistPhiForward->Fill(Phi); + + //added 15.12.12 + fHistTracksChargeForward->Fill(Charge); + + //added 23.03 + for ( int pid = 0; pid < kSparsePIDtotal; pid++ ) + { + if ( pid == kSparsePIDany //write ALL pid types + || + ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles + || + ( fCorrespondanceWithAliROOTpid[pid] == particleType ) //write not defined particles + ) + { + fNchFwPID[pid]++; + Charge > 0 ? fNchFwPlusPID[pid]++ : fNchFwMinusPID[pid]++; + fSumPtFwPID[pid] += Pt; + if ( pid != kSparsePIDany ) + { + Double_t lMass = 0;//AliPID::ParticleMass( particleType ); + fSumEtFwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ; + } + } + } + + //netcharge part (July 2013) + fHistNetChargeVsPtForward->Fill( Pt, Charge ); + if ( Charge > 0 ) + fHistPtPlusForward->Fill( Pt ); + else if ( Charge < 0 ) + fHistPtMinusForward->Fill( Pt ); + + +} +void AliLRCProcess::AddTrackBackward(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) +{ + // Imports track to the event directly to Backward window + if(!fIsEventOpend) + {Printf("Event is not opened!\n"); + return;} + + /*Bool_t lAddDecision = kFALSE; + + if ( fPidBackward == 100 ) //add particle if we know pid (i.e. particleType != -1) + { + if ( particleType != -1 ) + { + lAddDecision = kTRUE; + //cout << "fill fwd with pid " << particleType << endl; + } + } + else if ( fPidBackward != -1 ) //if we specify pid for this window - just check it + { + if ( particleType == fPidBackward ) + { + lAddDecision = kTRUE; + //cout << "fill fwd with pid " << particleType << endl; + } + } + else + lAddDecision = kTRUE; + + if ( !lAddDecision ) + return; + */ + fHistTestPIDBackward->Fill( particleType ); + + fNchBw++; + Charge > 0 ? fNchBwPlus++ : fNchBwMinus++; + fSumPtBw += Pt; + fSumPtBw2 += Pt*Pt; + fProfdPtB->Fill( 1, Pt ); + fProfdPtB->Fill( 2, Pt*Pt ); + fHistPtBackward->Fill( Pt ); + fHistEtaBackward->Fill( Eta ); + fHistPhiBackward->Fill( Phi ); + + //added 15.12.12 + fHistTracksChargeBackward->Fill(Charge); + + //added 23.03 + for ( int pid = 0; pid < kSparsePIDtotal; pid++ ) + { + if ( pid == kSparsePIDany //write ALL pid types + || + ( pid == kSparsePIDdefined && particleType != -1 ) //write defined particles + || + ( fCorrespondanceWithAliROOTpid[pid] == particleType ) + ) + { + fNchBwPID[pid]++; + Charge > 0 ? fNchBwPlusPID[pid]++ : fNchBwMinusPID[pid]++; + fSumPtBwPID[pid] += Pt; + if ( pid != kSparsePIDany ) + { + Double_t lMass = 0;//AliPID::ParticleMass( particleType ); + fSumEtBwPID[pid] += sqrt( Pt*Pt + lMass*lMass ) ; + } + + } + } + + //netcharge part (July 2013) + fHistNetChargeVsPtBackward->Fill( Pt, Charge ); + if ( Charge > 0 ) + fHistPtPlusBackward->Fill( Pt ); + else if ( Charge < 0 ) + fHistPtMinusBackward->Fill( Pt ); + +} + + + +void AliLRCProcess::AddTrackPtEta(Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) +{ + //cout << Pt << endl; + + + //if particle type is different - ignore the track + //if ( fWhichParticleToFill != -1 && ParticleType != fWhichParticleToFill ) + // return; + //Track by track event import : Imports track to the event + + //cout << "fWhichParticleToProcess = " << fWhichParticleToProcess + // << ", particleType = " << particleType << endl; + if(!fIsEventOpend) + {Printf("Event is not opened!\n"); + return;} + + // Global track data + fHistPt->Fill(Pt); + fHistEta->Fill(Eta); + + //Bool_t lAddForwardDecision = kFALSE; + //Bool_t lAddBackwardDecision = kFALSE; + + //Forward window + if( ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) ) + if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) )//( fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) ) + { + AddTrackForward( Pt, Eta, Phi, Charge, particleType ); + //if ( fPidFillCondition == kLRCpidForForwardOnly + // || fPidFillCondition == kLRCpidForBoth ) + //if ( fPidForward != -1 )//kLRCany ) + //{ + // if ( particleType == fPidForward )//kLRCpion )//particleType ) + // { + // lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi ); + //cout << "fill fwd with pid " << particleType << endl; + // } + //} + //else + // lAddForwardDecision = kTRUE;//AddTrackForward( Pt, Eta, Phi ); + } + //if ( lAddForwardDecision ) + //{ + // AddTrackForward( Pt, Eta, Phi, particleType ); + // fHistTestPIDForward->Fill( particleType ); + //} + + //Backward window + if( ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) ) + if ( + ( + IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi) //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi ) + ) + || + ( + fDoubleSidedBackwardPhiWindow //if this option is true + && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() ) // + //&& ( fStartBackwardPhi + TMath::Pi() < Phi ) + //&& ( Phi < fEndBackwardPhi + TMath::Pi() ) + ) + ) + { + AddTrackBackward( Pt, Eta, Phi, Charge, particleType ); + //if ( fPidFillCondition == kLRCpidForBackwardOnly + // || fPidFillCondition == kLRCpidForBoth ) + //if ( fPidBackward != -1 )//kLRCany ) + //{ + // if ( particleType == fPidBackward )//kLRCpion )//particleType ) + // { + // lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi ); + //cout << "fill bkwd with pid " << particleType << endl; + // } + + //} + //else + // lAddBackwardDecision = kTRUE;//AddTrackBackward( Pt, Eta, Phi ); + } + //if ( lAddBackwardDecision ) + //{ + // AddTrackBackward( Pt, Eta, Phi, particleType ); + // fHistTestPIDBackward->Fill( particleType ); + //} + +} + + + +void AliLRCProcess::AddTrackPtEtaMixing( Int_t winFB, Double_t Pt, Double_t Eta ,Double_t Phi, Short_t Charge, Int_t particleType ) +{ + // put track in F or B window using varible winFB + if(!fIsEventOpend) + { + Printf("Event is not opened!\n"); + return; + } + + // Global track data + fHistPt->Fill(Pt); + fHistEta->Fill(Eta); + + + //Forward window + if( winFB == 0 + && ( fStartForwardETA < Eta ) && ( Eta < fEndForwardETA ) ) + if( IsPhiInRange( Phi, fStartForwardPhi, fEndForwardPhi) ) // (fStartForwardPhi < Phi ) && ( Phi < fEndForwardPhi ) ) + { + AddTrackForward( Pt, Eta, Phi, Charge, particleType ); + } + + //Backward window + if( winFB == 1 + && ( fStartBackwardETA < Eta ) && ( Eta < fEndBackwardETA ) ) + if ( + ( + IsPhiInRange( Phi, fStartBackwardPhi, fEndBackwardPhi) //( fStartBackwardPhi < Phi ) && ( Phi < fEndBackwardPhi ) + ) + || + ( + fDoubleSidedBackwardPhiWindow //if this option is true + && IsPhiInRange( Phi, fStartBackwardPhi + TMath::Pi(), fEndBackwardPhi + TMath::Pi() ) + //&& ( fStartBackwardPhi + TMath::Pi() < Phi ) + //&& ( Phi < fEndBackwardPhi + TMath::Pi() ) + ) + ) + { + AddTrackBackward( Pt, Eta, Phi, Charge, particleType ); + } + + +} + +void AliLRCProcess::FinishEvent(Bool_t kDontCount) +{ + // Track by track event import : Close opened event and fill event summary histos + + if(!fIsEventOpend) + { + Printf("Event is not opened!\n"); + return; + } + if ( kDontCount ) //don't count this event! just ignore it + { + fIsEventOpend = kFALSE; + return; + } + //fHistSparseDimensionLabeling->Fill(1); + //Filling even-total data + //cout << "filling" << endl; + /*Double_t lCloudData[en_sparse_total*en_sparse_PID_total]; + lCloudData[en_sparse_N_f] = fNchFw; //write Nf + lCloudData[en_sparse_N_b] = fNchBw; //write Nb + lCloudData[en_sparse_N2_f] = fNchFw*fNchFw; //write Nf^2 + lCloudData[en_sparse_Nf_Nb] = fNchFw*fNchBw; //write Nb + + lCloudData[en_sparse_Pt_f] = 0; //fill bin 0, if don't have appropriate PtSum + lCloudData[en_sparse_Pt_b] = 0; //fill bin 0, if don't have appropriate PtSum + + lCloudData[en_sparse_Nf_plus] = fNchFwPlus; + lCloudData[en_sparse_Nf_minus] = fNchFwMinus; + lCloudData[en_sparse_Nb_plus] = fNchBwPlus; + lCloudData[en_sparse_Nb_minus] = fNchBwMinus; + lCloudData[en_sparse_Nf_plus_Nb_minus] = fNchFwPlus * fNchBwMinus; + lCloudData[en_sparse_Nb_plus_Nf_minus] = fNchBwPlus * fNchFwMinus; */ + + fHistNN->Fill(fNchFw,fNchBw); + + if ( fUseAccumulatingHist ) + { + fArrAccumulatedValues->Fill( en_arr_labels_NN_Nevents, 1 ); + fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf , fNchFw ); + fArrAccumulatedValues->Fill( en_arr_labels_NN_Nb , fNchBw ); + fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_f , fNchFw*fNchFw ); + fArrAccumulatedValues->Fill( en_arr_labels_NN_Nf_Nb , fNchFw*fNchBw ); + fArrAccumulatedValues->Fill( en_arr_labels_NN_N2_b , fNchBw*fNchBw ); + } + + if( fNchBw != 0 ) + { + fSumPtBw = fSumPtBw / fNchBw; + //lCloudData[en_sparse_Pt_b] = fSumPtBw; //write + fProfTestLRC->Fill( fNchFw, fSumPtBw ); + fHistPtN->Fill( fNchFw, fSumPtBw ); + //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw << endl; + fProfNberr->Fill(fNchFw, 1.0 / fNchBw); + + if ( fUseAccumulatingHist ) + { + fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nevents, 1 ); + fArrAccumulatedValues->Fill( en_arr_labels_PtN_Nf , fNchFw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtN_PtB , fSumPtBw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtN_N2_f , fNchFw*fNchFw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtN_Ptb_Nf , fSumPtBw*fNchFw ); + } + + if( fNchFw != 0 ) + { + fSumPtFw = fSumPtFw / fNchFw; + //lCloudData[en_sparse_Pt_f] = fSumPtFw; //write + fHistPtPt->Fill( fSumPtFw, fSumPtBw ); + fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw ); + // dPtB for PtPt + fProfdPtB->Fill( 15, fSumPtBw, fNchBw ); + fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw ); + fHistNchForwardPtPt->Fill(fNchFw); + + if ( fUseAccumulatingHist ) + { + fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Nevents, 1 ); + fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtF , fSumPtFw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtPt_PtB , fSumPtBw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Pt2_f , fSumPtFw*fSumPtFw ); + fArrAccumulatedValues->Fill( en_arr_labels_PtPt_Ptf_Ptb, fSumPtBw*fSumPtFw ); + } + + } + } + + + + + + if ( fUseSparse ) + { + Double_t lCloudData[kSparseTotal*kSparsePIDtotal]; + + for (Int_t d = 0; d < kSparsePIDtotal; ++d) + { + Int_t binShift = kSparseTotal*d; //step over dimension set + + lCloudData[kSparseNf + binShift ] = fNchFwPID[d]; //write Nf + lCloudData[kSparseNb + binShift ] = fNchBwPID[d]; //write Nb + lCloudData[en_sparse_N2_f + binShift ] = fNchFwPID[d]*fNchFwPID[d]; //write Nf^2 + lCloudData[en_sparse_Nf_Nb + binShift ] = fNchFwPID[d]*fNchBwPID[d]; //write Nb + + lCloudData[kSparsePtF + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum + lCloudData[kSparsePtB + binShift ] = 0; //fill bin 0, if don't have appropriate PtSum + + lCloudData[en_sparse_Ptb_Nf + binShift ] = 0; + lCloudData[en_sparse_Pt2_f + binShift ] = 0; + lCloudData[en_sparse_Ptf_Ptb + binShift ] = 0; + + + if( fNchBwPID[d] != 0 ) + { + double lSumPtBwPID = fSumPtBwPID[d] / fNchBwPID[d]; + lCloudData[kSparsePtB + binShift ] = lSumPtBwPID; //write + + fSumEtBwPID[d] = fSumEtBwPID[d] / fNchBwPID[d]; + //lCloudData[en_sparse_Et_b + binShift ] = fSumEtBwPID[d]; //write + lCloudData[en_sparse_Ptb_Nf + binShift ] = lSumPtBwPID * fNchFwPID[d]; + + //fProfTestLRC->Fill( fNchFw, fSumPtBw ); + //fHistPtN->Fill( fNchFw, fSumPtBw ); + //cout << "fill PtN: fNchFw = " << fNchFw << ", fSumPtBw=" << fSumPtBw << endl; + + //fProfNberr->Fill(fNchFw, 1.0 / fNchBw); + + + if( fNchFwPID[d] != 0 ) + { + double lSumPtFwPID = fSumPtFwPID[d] / fNchFwPID[d]; + lCloudData[kSparsePtF + binShift ] = lSumPtFwPID; //write + + fSumEtFwPID[d] = fSumEtFwPID[d] / fNchFwPID[d]; + + lCloudData[en_sparse_Pt2_f + binShift ] = lSumPtFwPID * lSumPtFwPID; + lCloudData[en_sparse_Ptf_Ptb + binShift ] = lSumPtFwPID*lSumPtBwPID; + + //lCloudData[en_sparse_Et_f + binShift ] = fSumEtFwPID[d]; //write + //fHistPtPt->Fill( fSumPtFw, fSumPtBw ); + //fProfNberrPtPt->Fill( fSumPtFw, 1.0 / fNchBw ); + // dPtB for PtPt + //fProfdPtB->Fill( 15, fSumPtBw, fNchBw ); + //fProfdPtB->Fill( 16, fSumPtBw2 / fNchBw, fNchBw ); + //fHistNchForwardPtPt->Fill(fNchFw); + + } + } + /* + lCloudData[en_sparse_Nf_plus + binShift ] = fNchFwPlusPID[d]; + lCloudData[en_sparse_Nf_minus + binShift ] = fNchFwMinusPID[d]; + lCloudData[en_sparse_Nb_plus + binShift ] = fNchBwPlusPID[d]; + lCloudData[en_sparse_Nb_minus + binShift ] = fNchBwMinusPID[d]; + lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = fNchFwPlusPID[d] * fNchBwMinusPID[d]; + lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = fNchBwPlusPID[d] * fNchFwMinusPID[d]; + */ + } + + //tmp (22.03): fill pid with fignya data + /* for (Int_t d = 1; d < en_sparse_PID_total; ++d) + { + Int_t binShift = en_sparse_total*d; + lCloudData[en_sparse_N_f + binShift ] = 1+d; //write Nf + lCloudData[en_sparse_N_b + binShift ] = 2+d; //write Nb + lCloudData[en_sparse_N2_f + binShift ] = 3+d; //write Nf^2 + lCloudData[en_sparse_Nf_Nb + binShift ] = 4+d; //write Nb + + lCloudData[en_sparse_Pt_f + binShift ] = 5+d; //fill bin 0, if don't have appropriate PtSum + lCloudData[en_sparse_Pt_b + binShift ] = 6+d; //fill bin 0, if don't have appropriate PtSum + + lCloudData[en_sparse_Nf_plus + binShift ] = 7+d; + lCloudData[en_sparse_Nf_minus + binShift ] = 8+d; + lCloudData[en_sparse_Nb_plus + binShift ] = 9+d; + lCloudData[en_sparse_Nb_minus + binShift ] = 10+d; + lCloudData[en_sparse_Nf_plus_Nb_minus + binShift ] = 11+d; + lCloudData[en_sparse_Nb_plus_Nf_minus + binShift ] = 12+d; + } + */ + + // cout << "before filling" << endl; + fHistClouds->Fill( lCloudData ); //fill sparse hist with Nf, Nb, , + // cout << "filled." << endl; + } + + + + + //additional info-hist + if ( fNchFw > 0 || fNchBw > 0 ) + { + Double_t lAvMult = ( fNchFw + fNchBw ) / 2.; + fHistDifferenceNf->Fill( fNchFw, ( fNchFw-fNchBw ) / lAvMult ); + fHistDifferenceNb->Fill( fNchBw, ( fNchBw-fNchFw ) / lAvMult); + } + + //cout << "n particles: " << fNchFw << " , Back = " << fNchBw << endl; + //cout << "fHistNN: " << fHistNN->GetEntries() << endl; + //cout << "mean= " << fHistNN->GetMean() << endl; + + + fHistNchForward->Fill(fNchFw); + fHistNchBackward->Fill(fNchBw); + + fEventCount++; + fIsEventOpend = kFALSE; + + //fill nf-centr plot + fHistNfCentrality->Fill( fNchFw, fEventCentrality ); + + //cout<SetOwner(kTRUE); - - fEventCounter = new TH1D("fEventCounter","EventCounter", 300, 0.5,300.5); - if (isQA) fThnList->Add(fEventCounter); - - fHistQA[0] = new TH2F("fHistQAvx", "Histo Vx Selected;Centrality;Vx", 100,0,100, 5000, -5., 5.); - fHistQA[1] = new TH2F("fHistQAvy", "Histo Vy Selected;Centrality;Vy", 100,0,100, 5000, -5., 5.); - fHistQA[2] = new TH2F("fHistQAvz", "Histo Vz Selected;Centrality;Vz", 100,0,100, 5000, -25., 25.); - fHistQA[3] = new TH2F("fHistQAvxA", "Histo Vx;Centrality;Vx", 100,0,100, 5000, -5., 5.); - fHistQA[4] = new TH2F("fHistQAvyA", "Histo Vy;Centrality;Vy", 100,0,100, 5000, -5., 5.); - fHistQA[5] = new TH2F("fHistQAvzA", "Histo Vz;Centrality;Vz", 100,0,100, 5000, -25., 25.); - - fHistQA[6] = new TH2F("fHistQADcaXyA", "Histo DCAxy;Centrality;DCAxy",100,0,100, 600, -15., 15.); - fHistQA[7] = new TH2F("fHistQADcaZA", "Histo DCAz;Centrality;DCAz ",100,0,100, 600, -15., 15.); - fHistQA[8] = new TH2F("fHistQAPtA","p_{T} distribution;Centrality;p_{T}",100,0,100,1000,0,10); - fHistQA[9] = new TH2F("fHistQAEtaA","#eta distribution;Centrality;#eta",100,0,100,240,-1.2,1.2); - - fHistQA[10] = new TH2F("fHistQADcaXy", "Histo DCAxy after Selected;Centrality;DCAxy", 100,0,100,600, -15., 15.); - fHistQA[11] = new TH2F("fHistQADcaZ", "Histo DCAz Selected;Centrality;DCAz", 100,0,100,600, -15., 15.); - fHistQA[12] = new TH2F("fHistQAPt","p_{T} distribution Selected;Centrality;p_{T}",100,0,100,1000,0,10); - fHistQA[13] = new TH2F("fHistQAEta","#eta distribution Selected;Centrality;#eta",100,0,100, 240,-1.2,1.2); - - if (isQA) for(Int_t i = 0; i < 14; i++) fThnList->Add(fHistQA[i]); - - Int_t fgSparseDataBins[kNSparseData] = {100, 5000, 5000, 2500, 2500, 3000, 1500, 1500, 1000, 500, 500, 500, 250, 250}; - Double_t fgSparseDataMin[kNSparseData] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; - Double_t fgSparseDataMax[kNSparseData] = {100.,5000.,5000.,2500.,2500.,3000.,1500.,1500.,1000.,500.,500.,500.,250.,250.}; - - const Char_t *fgkSparseDataTitle[] = {"centrality","RefMult","N_{ch}", "N_{+}","N_{-}","N_{#pi}", "N_{#pi^{+}}","N_{#pi^{-}}","N_{K}","N_{K^{+}}", "N_{K^{-}}","N_{p}","N_{p}","N_{#bar{p}}"}; - - fHistoCorrelation = new THnSparseI("fThnCorr", "", kNSparseData, fgSparseDataBins, fgSparseDataMin, fgSparseDataMax); - for (Int_t iaxis = 0; iaxis < kNSparseData; iaxis++) - fHistoCorrelation->GetAxis(iaxis)->SetTitle(fgkSparseDataTitle[iaxis]); - - if(!isQA) fThnList->Add(fHistoCorrelation); - if(isQA) - if (fHelperPID) - fThnList->Add(fHelperPID); - - PostData(1, fThnList); -} - -//---------------------------------------------------------------------------------- -void AliEbyEParticleRatioFluctuationTask::UserExec( Option_t * ){ - - if (isQA) fEventCounter->Fill(1); - - AliAODEvent* event = dynamic_cast(InputEvent()); - if (!event) { - Printf("ERROR 01: AOD not found "); - return; - } - - Int_t gCent = -1; - Float_t gRefMul = -1; - - AliAODHeader *aodHeader = event->GetHeader(); - gCent = (Int_t)aodHeader->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); - gRefMul = aodHeader->GetRefMultiplicity(); - if (gCent < 0 || gCent > 100) return; - if (isQA) fEventCounter->Fill(2); - - if (!AcceptEvent(event,gCent)) return; - - Int_t icharge = -1; - Int_t gCharge[2]; - Int_t gPid[3][2]; - - for (Int_t i = 0; i < 2; i++) { - gCharge[i] = 0; - for (Int_t ii = 0; ii < 3; ii++) { - gPid[ii][i] = 0; - } - } - - - if(fAnalysisType == "AOD") { - if (isQA) { - fEventCounter->Fill(5); - fEventCounter->Fill(50+gCent); - } - - for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) { - AliAODTrack* track = dynamic_cast(event->GetTrack(itrk)); - if (!track) continue; - - if (!AcceptTrack(track, gCent)) continue; - - Int_t a = fHelperPID->GetParticleSpecies((AliVTrack*) track,kTRUE); - - if(a < 0 || a > 2) continue; - icharge = track->Charge() > 0 ? 0 : 1; - gCharge[icharge]++; - gPid[a][icharge]++; - } - } - else if(fAnalysisType == "MCAOD") { - TClonesArray *arrayMC= 0; - arrayMC = dynamic_cast (event->GetList()->FindObject(AliAODMCParticle::StdBranchName())); - if (!arrayMC) { - Printf("Error: MC particles branch not found!\n"); - return; - } - AliAODMCHeader *mcHdr=0; - mcHdr=(AliAODMCHeader*)event->GetList()->FindObject(AliAODMCHeader::StdBranchName()); - if(!mcHdr) { - Printf("MC header branch not found!\n"); - return; - } - - if (isQA) { - fEventCounter->Fill(5); - fEventCounter->Fill(50+gCent); - } - - Int_t nMC = arrayMC->GetEntries(); - for (Int_t iMC = 0; iMC < nMC; iMC++) { - AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC); - if(!AcceptMCTrack(partMC, gCent)) continue; - Int_t a = fHelperPID->GetMCParticleSpecie((AliVEvent*) event,(AliVTrack*)partMC,1); - if(a < 0 || a > 2) continue; - icharge = partMC->Charge() > 0 ? 0 : 1; - gCharge[icharge]++; - gPid[a][icharge]++; - } - } - else { - printf(" No Event Type is Defined "); - return; - } - - if( (gCharge[0] + gCharge[1]) != 0 ) { - if (isQA) { - fEventCounter->Fill(6); - fEventCounter->Fill(160 + gCent); - } - else { - Double_t vsparse[kNSparseData]; - vsparse[0] = gCent; - vsparse[1] = gRefMul; - vsparse[2] = gCharge[0] + gCharge[1]; - vsparse[3] = gCharge[0]; - vsparse[4] = gCharge[1]; - vsparse[5] = gPid[0][0] + gPid[0][1]; - vsparse[6] = gPid[0][0]; - vsparse[7] = gPid[0][1]; - vsparse[8] = gPid[1][0] + gPid[1][0]; - vsparse[9] = gPid[1][0]; - vsparse[10] = gPid[1][1]; - vsparse[11] = gPid[2][0] + gPid[2][1]; - vsparse[12] = gPid[2][0]; - vsparse[13] = gPid[2][1]; - fHistoCorrelation->Fill(vsparse); - } - } - - if(fDebug && isQA) Printf(" %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d", - (Int_t)fEventCounter->GetBinContent(1), - (Int_t)fEventCounter->GetBinContent(2), - (Int_t)fEventCounter->GetBinContent(3), - (Int_t)gCent, (Int_t)gRefMul, - gCharge[0], gCharge[1], - gPid[0][0], gPid[0][1], gPid[1][0], - gPid[1][1], gPid[2][0], gPid[2][1]); - - PostData(1, fThnList); -} - -void AliEbyEParticleRatioFluctuationTask::Terminate( Option_t * ){ - Info("AliEbyEParticleRatioFluctuationTask"," Task Successfully finished"); -} - -//___________________________________________________________ -Bool_t AliEbyEParticleRatioFluctuationTask::AcceptEvent(AliAODEvent *event, Int_t cent) const { - Bool_t ver = kFALSE; - const AliAODVertex *vertex = event->GetPrimaryVertex(); - if(vertex) { - Double32_t fCov[6]; - vertex->GetCovarianceMatrix(fCov); - if(vertex->GetNContributors() > 0) { - if(fCov[5] != 0) { - - if(isQA) { - fEventCounter->Fill(3); - fHistQA[3]->Fill(cent,vertex->GetX()); - fHistQA[4]->Fill(cent,vertex->GetY()); - fHistQA[5]->Fill(cent,vertex->GetZ()); - } - - if(TMath::Abs(vertex->GetX()) < fVxMax) { - if(TMath::Abs(vertex->GetY()) < fVyMax) { - if(TMath::Abs(vertex->GetZ()) < fVzMax) { - ver = kTRUE; - if(isQA) { - fEventCounter->Fill(4); - fHistQA[0]->Fill(cent,vertex->GetX()); - fHistQA[1]->Fill(cent,vertex->GetY()); - fHistQA[2]->Fill(cent,vertex->GetZ()); - } - } - } - } - } - } - } - - AliCentrality *centrality = event->GetCentrality(); - if (centrality->GetQuality() != 0) ver = kFALSE; - return ver; -} - - -//___________________________________________________________ -Bool_t AliEbyEParticleRatioFluctuationTask::AcceptTrack(AliAODTrack *track, Int_t cent) const { - if(!track) return kFALSE; - if (track->Charge() == 0 ) return kFALSE; - - if(isQA) { - fHistQA[6]->Fill(cent,track->DCA()); - fHistQA[7]->Fill(cent,track->ZAtDCA()); - fHistQA[8]->Fill(cent,track->Pt()); - fHistQA[9]->Fill(cent,track->Eta()); - } - - if (!track->TestFilterBit(fAODtrackCutBit)) return kFALSE; - - if (track->Eta() < fEtaLowerLimit || - track->Eta() > fEtaHigherLimit) return kFALSE; - if (track->Pt() < fPtLowerLimit || - track->Pt() > fPtHigherLimit) return kFALSE; - if ( track->DCA() > fDCAxy ) return kFALSE; - if ( track->ZAtDCA() > fDCAz ) return kFALSE; - - if(isQA) { - fHistQA[10]->Fill(cent,track->DCA()); - fHistQA[11]->Fill(cent,track->ZAtDCA()); - fHistQA[12]->Fill(cent,track->Pt()); - fHistQA[13]->Fill(cent,track->Eta()); - } - - return kTRUE; -} - - -//___________________________________________________________ -Bool_t AliEbyEParticleRatioFluctuationTask::AcceptMCTrack(AliAODMCParticle *track, Int_t cent) const { - if(!track) return kFALSE; - if(!track->IsPhysicalPrimary()) return kFALSE; - if (track->Charge() == 0 ) return kFALSE; - if(isQA) { - fHistQA[8]->Fill(cent,track->Pt()); - fHistQA[9]->Fill(cent,track->Eta()); - } - - if (track->Eta() < fEtaLowerLimit || - track->Eta() > fEtaHigherLimit) return kFALSE; - if (track->Pt() < fPtLowerLimit || - track->Pt() > fPtHigherLimit) return kFALSE; - - if(isQA) { - fHistQA[12]->Fill(cent,track->Pt()); - fHistQA[13]->Fill(cent,track->Eta()); - } - - return kTRUE; -} +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: Satyajit Jena. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +//=========================================================================// +// AliEbyE Analysis for Particle Ratio Fluctuation // +// Deepika Rathee | Satyajit Jena // +// drathee@cern.ch | sjena@cern.ch // +// +// V0.1 2013/03/25 Using THnSparse +// V0.2 2013/04/03 Cleanup +// V1.0 2013/04/10 Cleanup Bins for Less Memory +// V1.1 2013/04/15 Bins Added +// Todo: pp and pA, Mix Events +//=========================================================================// + +#include "TChain.h" +#include "TList.h" +#include "TFile.h" +#include "TTree.h" +#include "TH1D.h" +#include "TH2F.h" +#include "TH3F.h" +#include "TCanvas.h" +#include "AliAnalysisTask.h" +#include "AliAnalysisManager.h" +#include "AliVEvent.h" +#include "AliESD.h" +#include "AliESDEvent.h" +#include "AliAODEvent.h" +#include "AliAODMCParticle.h" +#include "AliAODMCHeader.h" +#include "AliPIDResponse.h" +#include "AliAODHeader.h" +#include "AliAODpidUtil.h" +#include "AliHelperPID.h" +using std::endl; +using std::cout; +#include "AliEbyEParticleRatioFluctuationTask.h" + +ClassImp(AliEbyEParticleRatioFluctuationTask) + +//----------------------------------------------------------------------- +AliEbyEParticleRatioFluctuationTask::AliEbyEParticleRatioFluctuationTask( const char *name ) : AliAnalysisTaskSE( name ), + fThnList(NULL), + fAnalysisType("AOD"), + fAnalysisData("PbPb"), + fCentralityEstimator("V0M"), + fVxMax(3.), + fVyMax(3.), + fVzMax(10.), + fDCAxy(2.4), + fDCAz(3.2), + fPtLowerLimit(0.2), + fPtHigherLimit(5.), + fEtaLowerLimit(-1.), + fEtaHigherLimit(1.), + fTPCNClus(80), + fAODtrackCutBit(128), + isQA(kFALSE), + fDebug(kFALSE), + fHelperPID(0x0), + fEventCounter(NULL), + fHistoCorrelation(NULL) { + for(Int_t i = 0; i < 14; i++ ) fHistQA[i] = NULL; + DefineOutput(1, TList::Class()); //! Connect Outpput.... +} + +AliEbyEParticleRatioFluctuationTask::~AliEbyEParticleRatioFluctuationTask() { + //! Cleaning up + if (fThnList) delete fThnList; + if (fHelperPID) delete fHelperPID; +} + +//--------------------------------------------------------------------------------- +void AliEbyEParticleRatioFluctuationTask::UserCreateOutputObjects() { + fThnList = new TList(); + fThnList->SetOwner(kTRUE); + + fEventCounter = new TH1D("fEventCounter","EventCounter", 300, 0.5,300.5); + if (isQA) fThnList->Add(fEventCounter); + + fHistQA[0] = new TH2F("fHistQAvx", "Histo Vx Selected;Centrality;Vx", 100,0,100, 5000, -5., 5.); + fHistQA[1] = new TH2F("fHistQAvy", "Histo Vy Selected;Centrality;Vy", 100,0,100, 5000, -5., 5.); + fHistQA[2] = new TH2F("fHistQAvz", "Histo Vz Selected;Centrality;Vz", 100,0,100, 5000, -25., 25.); + fHistQA[3] = new TH2F("fHistQAvxA", "Histo Vx;Centrality;Vx", 100,0,100, 5000, -5., 5.); + fHistQA[4] = new TH2F("fHistQAvyA", "Histo Vy;Centrality;Vy", 100,0,100, 5000, -5., 5.); + fHistQA[5] = new TH2F("fHistQAvzA", "Histo Vz;Centrality;Vz", 100,0,100, 5000, -25., 25.); + + fHistQA[6] = new TH2F("fHistQADcaXyA", "Histo DCAxy;Centrality;DCAxy",100,0,100, 600, -15., 15.); + fHistQA[7] = new TH2F("fHistQADcaZA", "Histo DCAz;Centrality;DCAz ",100,0,100, 600, -15., 15.); + fHistQA[8] = new TH2F("fHistQAPtA","p_{T} distribution;Centrality;p_{T}",100,0,100,1000,0,10); + fHistQA[9] = new TH2F("fHistQAEtaA","#eta distribution;Centrality;#eta",100,0,100,240,-1.2,1.2); + + fHistQA[10] = new TH2F("fHistQADcaXy", "Histo DCAxy after Selected;Centrality;DCAxy", 100,0,100,600, -15., 15.); + fHistQA[11] = new TH2F("fHistQADcaZ", "Histo DCAz Selected;Centrality;DCAz", 100,0,100,600, -15., 15.); + fHistQA[12] = new TH2F("fHistQAPt","p_{T} distribution Selected;Centrality;p_{T}",100,0,100,1000,0,10); + fHistQA[13] = new TH2F("fHistQAEta","#eta distribution Selected;Centrality;#eta",100,0,100, 240,-1.2,1.2); + + if (isQA) for(Int_t i = 0; i < 14; i++) fThnList->Add(fHistQA[i]); + + Int_t fgSparseDataBins[kNSparseData] = {100, 5000, 5000, 2500, 2500, 3000, 1500, 1500, 1000, 500, 500, 500, 250, 250}; + Double_t fgSparseDataMin[kNSparseData] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; + Double_t fgSparseDataMax[kNSparseData] = {100.,5000.,5000.,2500.,2500.,3000.,1500.,1500.,1000.,500.,500.,500.,250.,250.}; + + const Char_t *fgkSparseDataTitle[] = {"centrality","RefMult","N_{ch}", "N_{+}","N_{-}","N_{#pi}", "N_{#pi^{+}}","N_{#pi^{-}}","N_{K}","N_{K^{+}}", "N_{K^{-}}","N_{p}","N_{p}","N_{#bar{p}}"}; + + fHistoCorrelation = new THnSparseI("fThnCorr", "", kNSparseData, fgSparseDataBins, fgSparseDataMin, fgSparseDataMax); + for (Int_t iaxis = 0; iaxis < kNSparseData; iaxis++) + fHistoCorrelation->GetAxis(iaxis)->SetTitle(fgkSparseDataTitle[iaxis]); + + if(!isQA) fThnList->Add(fHistoCorrelation); + if(isQA) + if (fHelperPID) + fThnList->Add(fHelperPID); + + PostData(1, fThnList); +} + +//---------------------------------------------------------------------------------- +void AliEbyEParticleRatioFluctuationTask::UserExec( Option_t * ){ + + if (isQA) fEventCounter->Fill(1); + + AliAODEvent* event = dynamic_cast(InputEvent()); + if (!event) { + Printf("ERROR 01: AOD not found "); + return; + } + + Int_t gCent = -1; + Float_t gRefMul = -1; + + AliAODHeader *aodHeader = event->GetHeader(); + gCent = (Int_t)aodHeader->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()); + gRefMul = aodHeader->GetRefMultiplicity(); + if (gCent < 0 || gCent > 100) return; + if (isQA) fEventCounter->Fill(2); + + if (!AcceptEvent(event,gCent)) return; + + Int_t icharge = -1; + Int_t gCharge[2]; + Int_t gPid[3][2]; + + for (Int_t i = 0; i < 2; i++) { + gCharge[i] = 0; + for (Int_t ii = 0; ii < 3; ii++) { + gPid[ii][i] = 0; + } + } + + + if(fAnalysisType == "AOD") { + if (isQA) { + fEventCounter->Fill(5); + fEventCounter->Fill(50+gCent); + } + + for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) { + AliAODTrack* track = dynamic_cast(event->GetTrack(itrk)); + if (!track) continue; + + if (!AcceptTrack(track, gCent)) continue; + + Int_t a = fHelperPID->GetParticleSpecies((AliVTrack*) track,kTRUE); + + if(a < 0 || a > 2) continue; + icharge = track->Charge() > 0 ? 0 : 1; + gCharge[icharge]++; + gPid[a][icharge]++; + } + } + else if(fAnalysisType == "MCAOD") { + TClonesArray *arrayMC= 0; + arrayMC = dynamic_cast (event->GetList()->FindObject(AliAODMCParticle::StdBranchName())); + if (!arrayMC) { + Printf("Error: MC particles branch not found!\n"); + return; + } + AliAODMCHeader *mcHdr=0; + mcHdr=(AliAODMCHeader*)event->GetList()->FindObject(AliAODMCHeader::StdBranchName()); + if(!mcHdr) { + Printf("MC header branch not found!\n"); + return; + } + + if (isQA) { + fEventCounter->Fill(5); + fEventCounter->Fill(50+gCent); + } + + Int_t nMC = arrayMC->GetEntries(); + for (Int_t iMC = 0; iMC < nMC; iMC++) { + AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC); + if(!AcceptMCTrack(partMC, gCent)) continue; + Int_t a = fHelperPID->GetMCParticleSpecie((AliVEvent*) event,(AliVTrack*)partMC,1); + if(a < 0 || a > 2) continue; + icharge = partMC->Charge() > 0 ? 0 : 1; + gCharge[icharge]++; + gPid[a][icharge]++; + } + } + else { + printf(" No Event Type is Defined "); + return; + } + + if( (gCharge[0] + gCharge[1]) != 0 ) { + if (isQA) { + fEventCounter->Fill(6); + fEventCounter->Fill(160 + gCent); + } + else { + Double_t vsparse[kNSparseData]; + vsparse[0] = gCent; + vsparse[1] = gRefMul; + vsparse[2] = gCharge[0] + gCharge[1]; + vsparse[3] = gCharge[0]; + vsparse[4] = gCharge[1]; + vsparse[5] = gPid[0][0] + gPid[0][1]; + vsparse[6] = gPid[0][0]; + vsparse[7] = gPid[0][1]; + vsparse[8] = gPid[1][0] + gPid[1][0]; + vsparse[9] = gPid[1][0]; + vsparse[10] = gPid[1][1]; + vsparse[11] = gPid[2][0] + gPid[2][1]; + vsparse[12] = gPid[2][0]; + vsparse[13] = gPid[2][1]; + fHistoCorrelation->Fill(vsparse); + } + } + + if(fDebug && isQA) Printf(" %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d", + (Int_t)fEventCounter->GetBinContent(1), + (Int_t)fEventCounter->GetBinContent(2), + (Int_t)fEventCounter->GetBinContent(3), + (Int_t)gCent, (Int_t)gRefMul, + gCharge[0], gCharge[1], + gPid[0][0], gPid[0][1], gPid[1][0], + gPid[1][1], gPid[2][0], gPid[2][1]); + + PostData(1, fThnList); +} + +void AliEbyEParticleRatioFluctuationTask::Terminate( Option_t * ){ + Info("AliEbyEParticleRatioFluctuationTask"," Task Successfully finished"); +} + +//___________________________________________________________ +Bool_t AliEbyEParticleRatioFluctuationTask::AcceptEvent(AliAODEvent *event, Int_t cent) const { + Bool_t ver = kFALSE; + const AliAODVertex *vertex = event->GetPrimaryVertex(); + if(vertex) { + Double32_t fCov[6]; + vertex->GetCovarianceMatrix(fCov); + if(vertex->GetNContributors() > 0) { + if(fCov[5] != 0) { + + if(isQA) { + fEventCounter->Fill(3); + fHistQA[3]->Fill(cent,vertex->GetX()); + fHistQA[4]->Fill(cent,vertex->GetY()); + fHistQA[5]->Fill(cent,vertex->GetZ()); + } + + if(TMath::Abs(vertex->GetX()) < fVxMax) { + if(TMath::Abs(vertex->GetY()) < fVyMax) { + if(TMath::Abs(vertex->GetZ()) < fVzMax) { + ver = kTRUE; + if(isQA) { + fEventCounter->Fill(4); + fHistQA[0]->Fill(cent,vertex->GetX()); + fHistQA[1]->Fill(cent,vertex->GetY()); + fHistQA[2]->Fill(cent,vertex->GetZ()); + } + } + } + } + } + } + } + + AliCentrality *centrality = event->GetCentrality(); + if (centrality->GetQuality() != 0) ver = kFALSE; + return ver; +} + + +//___________________________________________________________ +Bool_t AliEbyEParticleRatioFluctuationTask::AcceptTrack(AliAODTrack *track, Int_t cent) const { + if(!track) return kFALSE; + if (track->Charge() == 0 ) return kFALSE; + + if(isQA) { + fHistQA[6]->Fill(cent,track->DCA()); + fHistQA[7]->Fill(cent,track->ZAtDCA()); + fHistQA[8]->Fill(cent,track->Pt()); + fHistQA[9]->Fill(cent,track->Eta()); + } + + if (!track->TestFilterBit(fAODtrackCutBit)) return kFALSE; + + if (track->Eta() < fEtaLowerLimit || + track->Eta() > fEtaHigherLimit) return kFALSE; + if (track->Pt() < fPtLowerLimit || + track->Pt() > fPtHigherLimit) return kFALSE; + if ( track->DCA() > fDCAxy ) return kFALSE; + if ( track->ZAtDCA() > fDCAz ) return kFALSE; + + if(isQA) { + fHistQA[10]->Fill(cent,track->DCA()); + fHistQA[11]->Fill(cent,track->ZAtDCA()); + fHistQA[12]->Fill(cent,track->Pt()); + fHistQA[13]->Fill(cent,track->Eta()); + } + + return kTRUE; +} + + +//___________________________________________________________ +Bool_t AliEbyEParticleRatioFluctuationTask::AcceptMCTrack(AliAODMCParticle *track, Int_t cent) const { + if(!track) return kFALSE; + if(!track->IsPhysicalPrimary()) return kFALSE; + if (track->Charge() == 0 ) return kFALSE; + if(isQA) { + fHistQA[8]->Fill(cent,track->Pt()); + fHistQA[9]->Fill(cent,track->Eta()); + } + + if (track->Eta() < fEtaLowerLimit || + track->Eta() > fEtaHigherLimit) return kFALSE; + if (track->Pt() < fPtLowerLimit || + track->Pt() > fPtHigherLimit) return kFALSE; + + if(isQA) { + fHistQA[12]->Fill(cent,track->Pt()); + fHistQA[13]->Fill(cent,track->Eta()); + } + + return kTRUE; +} diff --git a/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C b/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C index ef1364ed056..208c4f13321 100644 --- a/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C +++ b/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C @@ -1,269 +1,269 @@ -// now in options -//=============================================// -//const char* centralityEstimator = "V0M"; -//const char* centralityEstimator = "CL1"; -//const char* centralityEstimator = "TRK"; -//=============================================// -//Bool_t gRunShuffling = kFALSE; -//Bool_t gRunShuffling = kTRUE; -//=============================================// - -//PID config -Bool_t kUseNSigmaPID = kTRUE; -Double_t nSigmaMax = 3.0; -Bool_t kUseBayesianPID = kFALSE; -Double_t gMinAcceptedProbability = 0.7; - -//_________________________________________________________// -AliAnalysisTaskBFPsi *AddTaskBalancePsiCentralityTrain(Double_t centrMin=0., - Double_t centrMax=100., - Bool_t gRunShuffling=kFALSE, - Bool_t gRunMixing=kTRUE, - Bool_t gRunMixingWithEventPlane=kFALSE, - TString centralityEstimator="V0M", - Double_t vertexZ=10., - Double_t DCAxy=-1, - Double_t DCAz=-1, - Double_t ptMin=0.3, - Double_t ptMax=1.5, - Double_t etaMin=-0.8, - Double_t etaMax=0.8, - Double_t maxTPCchi2 = -1, - Int_t minNClustersTPC = -1, - Bool_t kUsePID = kTRUE, - Bool_t bResonancesCut = kTRUE, - Bool_t bHBTcut = kTRUE, - Double_t HBTCutValue = 0.02, - Bool_t bConversionCut = kTRUE, - Double_t invMassForConversionCut = 0.04, - Bool_t bMomentumDifferenceCut = kTRUE, - Double_t fQCutMin = 0.0, - Int_t AODfilterBit = 128, - Bool_t bCentralTrigger = kFALSE, - TString fileNameBase="AnalysisResults", - TString dirNameExtra="", - TString fArgEventClass="Centrality", - TString analysisTypeUser="AOD", - Bool_t bVertexBinning=kTRUE, - Double_t sigmaElectronRejection=3, - Bool_t electronExclusiveRejection=kFALSE, - TString correctionFileName = "", - Int_t nCentralityArrayBinsForCorrection, - Double_t *gCentralityArrayForCorrections) { - // Creates a balance function analysis task and adds it to the analysis manager. - // Get the pointer to the existing analysis manager via the static access method. - TString outputFileName(fileNameBase); - outputFileName.Append(".root"); - - //=========================================================================== - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - ::Error("AddTaskBF", "No analysis manager to connect to."); - return NULL; - } - - // Check the analysis type using the event handlers connected to the analysis manager. - //=========================================================================== - if (!mgr->GetInputEventHandler()) { - ::Error("AddTaskBF", "This task requires an input event handler"); - return NULL; - } - TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" - if(dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC"; - - // to set the analysis type manually - if(analysisTypeUser != ""){ - analysisType = analysisTypeUser; - ::Info("AddTaskBF",Form("Analysis Type manually set to %s",analysisType.Data())); - } - - // for local changed BF configuration - //gROOT->LoadMacro("./configBalanceFunctionPsiAnalysis.C"); - gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C"); - AliBalancePsi *bf = 0; // Balance Function object - AliBalancePsi *bfs = 0; // shuffled Balance function object - AliBalancePsi *bfm = 0; // mixing Balance function object - - //maximum Delta eta range - Double_t deltaEtaMax=TMath::Abs(etaMax-etaMin); - - if (analysisType=="ESD"){ - bf = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunMixing) bfm = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - } - else if (analysisType=="AOD"){ - bf = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunMixing) bfm = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - } - else if (analysisType=="MC"){ - bf = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunMixing) bfm = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - } - else if (analysisType=="MCAOD"){ - bf = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunMixing) bfm = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - } - else if (analysisType=="MCAODrec"){ - bf = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - if(gRunMixing) bfm = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); - } - else{ - ::Error("AddTaskBF", "analysis type NOT known."); - return NULL; - } - - // Create the task, add it to manager and configure it. - //=========================================================================== - AliAnalysisTaskBFPsi *taskBF = new AliAnalysisTaskBFPsi(Form("TaskBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data())); - - //Event characteristics scheme - taskBF->SetEventClass(fArgEventClass); - //taskBF->SetCustomBinning("centralityVertex:0,80"); - //taskBF->SetCustomBinning("multiplicity:0,260"); - - if(fArgEventClass == "Multiplicity") { - taskBF->SetMultiplicityRange(centrMin,centrMax); - taskBF->SetMultiplicityEstimator(centralityEstimator); - cout<<"Multiplicity estimator "<SetImpactParameterRange(centrMin,centrMax); - else { - taskBF->SetCentralityPercentileRange(centrMin,centrMax); - // centrality estimator (default = V0M) - taskBF->SetCentralityEstimator(centralityEstimator); - cout<<"Centrality estimator "<SetInputCorrection(Form("$ALICE_ROOT/PWGCF/EBYE/BalanceFunctions/Corrections/%s",correctionFileName.Data()),nCentralityArrayBinsForCorrection,gCentralityArrayForCorrections); - - //+++++++++++++++++++++ - - taskBF->SetAnalysisObject(bf); - if(gRunShuffling) taskBF->SetShufflingObject(bfs); - if(gRunMixing){ - taskBF->SetMixingObject(bfm); - taskBF->SetMixingTracks(50000); - if(gRunMixingWithEventPlane){ - taskBF->SetMixingWithEventPlane(gRunMixingWithEventPlane); - } - } - - if(analysisType == "ESD") { - AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC); - taskBF->SetAnalysisCutObject(trackCuts); - if(kUsePID) { - if(kUseBayesianPID) - taskBF->SetUseBayesianPID(gMinAcceptedProbability); - else if(kUseNSigmaPID) - taskBF->SetUseNSigmaPID(nSigmaMax); - taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion); - taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTOFpid); - } - } - else if(analysisType == "AOD") { - // pt and eta cut (pt_min, pt_max, eta_min, eta_max) - taskBF->SetAODtrackCutBit(AODfilterBit); - taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); - - // set extra DCA cuts (-1 no extra cut) - taskBF->SetExtraDCACutsAOD(DCAxy,DCAz); - - // set extra TPC chi2 / nr of clusters cut - taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC); - - // electron rejection (so far only for AOD), <0 --> no rejection - if(sigmaElectronRejection > 0){ - if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma - else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma - } - - //++++++++++++++++// - if(kUsePID) { - if(kUseBayesianPID) - taskBF->SetUseBayesianPID(gMinAcceptedProbability); - else if(kUseNSigmaPID) - taskBF->SetUseNSigmaPID(nSigmaMax); - taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion); - taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTPCTOF); //TOFpid,TPCpid - } - //++++++++++++++++// - - } - else if(analysisType == "MC") { - taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); - } - else if(analysisType == "MCAOD") { - // pt and eta cut (pt_min, pt_max, eta_min, eta_max) - taskBF->SetAODtrackCutBit(AODfilterBit); - taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); - } - else if(analysisType == "MCAODrec") { //++++++++++++++++ - // pt and eta cut (pt_min, pt_max, eta_min, eta_max) - taskBF->SetAODtrackCutBit(AODfilterBit); - taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); - - // set extra DCA cuts (-1 no extra cut) - taskBF->SetExtraDCACutsAOD(DCAxy,DCAz); - - // set extra TPC chi2 / nr of clusters cut - taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC); - - // electron rejection (so far only for AOD), <0 --> no rejection - if(sigmaElectronRejection > 0){ - if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma - else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma - } - }//++++++++++++++++ - - // offline trigger selection (AliVEvent.h) - // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) - // with this only selected events are analyzed (first 2 bins in event QA histogram are the same)) - // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation - if(bCentralTrigger) taskBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral); - else taskBF->SelectCollisionCandidates(AliVEvent::kMB); - - // centrality estimator (default = V0M) - taskBF->SetCentralityEstimator(centralityEstimator); - - // vertex cut (x,y,z) - taskBF->SetVertexDiamond(3.,3.,vertexZ); - - - - //bf->PrintAnalysisSettings(); - mgr->AddTask(taskBF); - - // Create ONLY the output containers for the data produced by the task. - // Get and connect other common input/output containers via the manager as below - //============================================================================== - TString outputFileName = AliAnalysisManager::GetCommonFileName(); - outputFileName += ":PWGCFEbyE.outputBalanceFunctionPsiAnalysis"; - AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQAPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); - AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); - if(gRunShuffling) AliAnalysisDataContainer *coutBFS = mgr->CreateContainer(Form("listBFPsiShuffled_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); - if(gRunMixing) AliAnalysisDataContainer *coutBFM = mgr->CreateContainer(Form("listBFPsiMixed_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); - if(kUsePID || sigmaElectronRejection > 0) AliAnalysisDataContainer *coutQAPID = mgr->CreateContainer(Form("listQAPIDPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); - - mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput(taskBF, 1, coutQA); - mgr->ConnectOutput(taskBF, 2, coutBF); - if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS); - if(gRunMixing) mgr->ConnectOutput(taskBF, 4, coutBFM); - if(kUsePID||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); - //if((kUsePID && analysisType == "AOD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); - //if((kUsePID && analysisType == "ESD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); - - return taskBF; -} +// now in options +//=============================================// +//const char* centralityEstimator = "V0M"; +//const char* centralityEstimator = "CL1"; +//const char* centralityEstimator = "TRK"; +//=============================================// +//Bool_t gRunShuffling = kFALSE; +//Bool_t gRunShuffling = kTRUE; +//=============================================// + +//PID config +Bool_t kUseNSigmaPID = kTRUE; +Double_t nSigmaMax = 3.0; +Bool_t kUseBayesianPID = kFALSE; +Double_t gMinAcceptedProbability = 0.7; + +//_________________________________________________________// +AliAnalysisTaskBFPsi *AddTaskBalancePsiCentralityTrain(Double_t centrMin=0., + Double_t centrMax=100., + Bool_t gRunShuffling=kFALSE, + Bool_t gRunMixing=kTRUE, + Bool_t gRunMixingWithEventPlane=kFALSE, + TString centralityEstimator="V0M", + Double_t vertexZ=10., + Double_t DCAxy=-1, + Double_t DCAz=-1, + Double_t ptMin=0.3, + Double_t ptMax=1.5, + Double_t etaMin=-0.8, + Double_t etaMax=0.8, + Double_t maxTPCchi2 = -1, + Int_t minNClustersTPC = -1, + Bool_t kUsePID = kTRUE, + Bool_t bResonancesCut = kTRUE, + Bool_t bHBTcut = kTRUE, + Double_t HBTCutValue = 0.02, + Bool_t bConversionCut = kTRUE, + Double_t invMassForConversionCut = 0.04, + Bool_t bMomentumDifferenceCut = kTRUE, + Double_t fQCutMin = 0.0, + Int_t AODfilterBit = 128, + Bool_t bCentralTrigger = kFALSE, + TString fileNameBase="AnalysisResults", + TString dirNameExtra="", + TString fArgEventClass="Centrality", + TString analysisTypeUser="AOD", + Bool_t bVertexBinning=kTRUE, + Double_t sigmaElectronRejection=3, + Bool_t electronExclusiveRejection=kFALSE, + TString correctionFileName = "", + Int_t nCentralityArrayBinsForCorrection, + Double_t *gCentralityArrayForCorrections) { + // Creates a balance function analysis task and adds it to the analysis manager. + // Get the pointer to the existing analysis manager via the static access method. + TString outputFileName(fileNameBase); + outputFileName.Append(".root"); + + //=========================================================================== + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error("AddTaskBF", "No analysis manager to connect to."); + return NULL; + } + + // Check the analysis type using the event handlers connected to the analysis manager. + //=========================================================================== + if (!mgr->GetInputEventHandler()) { + ::Error("AddTaskBF", "This task requires an input event handler"); + return NULL; + } + TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" + if(dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC"; + + // to set the analysis type manually + if(analysisTypeUser != ""){ + analysisType = analysisTypeUser; + ::Info("AddTaskBF",Form("Analysis Type manually set to %s",analysisType.Data())); + } + + // for local changed BF configuration + //gROOT->LoadMacro("./configBalanceFunctionPsiAnalysis.C"); + gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C"); + AliBalancePsi *bf = 0; // Balance Function object + AliBalancePsi *bfs = 0; // shuffled Balance function object + AliBalancePsi *bfm = 0; // mixing Balance function object + + //maximum Delta eta range + Double_t deltaEtaMax=TMath::Abs(etaMax-etaMin); + + if (analysisType=="ESD"){ + bf = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunMixing) bfm = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + } + else if (analysisType=="AOD"){ + bf = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunMixing) bfm = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + } + else if (analysisType=="MC"){ + bf = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunMixing) bfm = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + } + else if (analysisType=="MCAOD"){ + bf = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunMixing) bfm = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + } + else if (analysisType=="MCAODrec"){ + bf = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + if(gRunMixing) bfm = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning); + } + else{ + ::Error("AddTaskBF", "analysis type NOT known."); + return NULL; + } + + // Create the task, add it to manager and configure it. + //=========================================================================== + AliAnalysisTaskBFPsi *taskBF = new AliAnalysisTaskBFPsi(Form("TaskBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data())); + + //Event characteristics scheme + taskBF->SetEventClass(fArgEventClass); + //taskBF->SetCustomBinning("centralityVertex:0,80"); + //taskBF->SetCustomBinning("multiplicity:0,260"); + + if(fArgEventClass == "Multiplicity") { + taskBF->SetMultiplicityRange(centrMin,centrMax); + taskBF->SetMultiplicityEstimator(centralityEstimator); + cout<<"Multiplicity estimator "<SetImpactParameterRange(centrMin,centrMax); + else { + taskBF->SetCentralityPercentileRange(centrMin,centrMax); + // centrality estimator (default = V0M) + taskBF->SetCentralityEstimator(centralityEstimator); + cout<<"Centrality estimator "<SetInputCorrection(Form("$ALICE_ROOT/PWGCF/EBYE/BalanceFunctions/Corrections/%s",correctionFileName.Data()),nCentralityArrayBinsForCorrection,gCentralityArrayForCorrections); + + //+++++++++++++++++++++ + + taskBF->SetAnalysisObject(bf); + if(gRunShuffling) taskBF->SetShufflingObject(bfs); + if(gRunMixing){ + taskBF->SetMixingObject(bfm); + taskBF->SetMixingTracks(50000); + if(gRunMixingWithEventPlane){ + taskBF->SetMixingWithEventPlane(gRunMixingWithEventPlane); + } + } + + if(analysisType == "ESD") { + AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC); + taskBF->SetAnalysisCutObject(trackCuts); + if(kUsePID) { + if(kUseBayesianPID) + taskBF->SetUseBayesianPID(gMinAcceptedProbability); + else if(kUseNSigmaPID) + taskBF->SetUseNSigmaPID(nSigmaMax); + taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion); + taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTOFpid); + } + } + else if(analysisType == "AOD") { + // pt and eta cut (pt_min, pt_max, eta_min, eta_max) + taskBF->SetAODtrackCutBit(AODfilterBit); + taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); + + // set extra DCA cuts (-1 no extra cut) + taskBF->SetExtraDCACutsAOD(DCAxy,DCAz); + + // set extra TPC chi2 / nr of clusters cut + taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC); + + // electron rejection (so far only for AOD), <0 --> no rejection + if(sigmaElectronRejection > 0){ + if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma + else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma + } + + //++++++++++++++++// + if(kUsePID) { + if(kUseBayesianPID) + taskBF->SetUseBayesianPID(gMinAcceptedProbability); + else if(kUseNSigmaPID) + taskBF->SetUseNSigmaPID(nSigmaMax); + taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion); + taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTPCTOF); //TOFpid,TPCpid + } + //++++++++++++++++// + + } + else if(analysisType == "MC") { + taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); + } + else if(analysisType == "MCAOD") { + // pt and eta cut (pt_min, pt_max, eta_min, eta_max) + taskBF->SetAODtrackCutBit(AODfilterBit); + taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); + } + else if(analysisType == "MCAODrec") { //++++++++++++++++ + // pt and eta cut (pt_min, pt_max, eta_min, eta_max) + taskBF->SetAODtrackCutBit(AODfilterBit); + taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); + + // set extra DCA cuts (-1 no extra cut) + taskBF->SetExtraDCACutsAOD(DCAxy,DCAz); + + // set extra TPC chi2 / nr of clusters cut + taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC); + + // electron rejection (so far only for AOD), <0 --> no rejection + if(sigmaElectronRejection > 0){ + if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma + else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma + } + }//++++++++++++++++ + + // offline trigger selection (AliVEvent.h) + // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) + // with this only selected events are analyzed (first 2 bins in event QA histogram are the same)) + // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation + if(bCentralTrigger) taskBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral); + else taskBF->SelectCollisionCandidates(AliVEvent::kMB); + + // centrality estimator (default = V0M) + taskBF->SetCentralityEstimator(centralityEstimator); + + // vertex cut (x,y,z) + taskBF->SetVertexDiamond(3.,3.,vertexZ); + + + + //bf->PrintAnalysisSettings(); + mgr->AddTask(taskBF); + + // Create ONLY the output containers for the data produced by the task. + // Get and connect other common input/output containers via the manager as below + //============================================================================== + TString outputFileName = AliAnalysisManager::GetCommonFileName(); + outputFileName += ":PWGCFEbyE.outputBalanceFunctionPsiAnalysis"; + AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQAPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); + AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); + if(gRunShuffling) AliAnalysisDataContainer *coutBFS = mgr->CreateContainer(Form("listBFPsiShuffled_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); + if(gRunMixing) AliAnalysisDataContainer *coutBFM = mgr->CreateContainer(Form("listBFPsiMixed_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); + if(kUsePID || sigmaElectronRejection > 0) AliAnalysisDataContainer *coutQAPID = mgr->CreateContainer(Form("listQAPIDPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); + + mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput(taskBF, 1, coutQA); + mgr->ConnectOutput(taskBF, 2, coutBF); + if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS); + if(gRunMixing) mgr->ConnectOutput(taskBF, 4, coutBFM); + if(kUsePID||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); + //if((kUsePID && analysisType == "AOD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); + //if((kUsePID && analysisType == "ESD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID); + + return taskBF; +} diff --git a/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C b/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C index a8b940acd10..9d48377e2dc 100644 --- a/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C +++ b/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C @@ -1,80 +1,80 @@ -//__________________________________________________// -AliBalancePsi *GetBalanceFunctionObject(const char* analysisLevel = "MCAOD", // - const char* centralityName = 0x0, - Double_t centrMin = 0., - Double_t centrMax = 100., - Bool_t bShuffle = kFALSE, - Bool_t bResonancesCut = kFALSE, - Bool_t bHBTCut = kFALSE, - Double_t HBTCutValue = 0.02, - Bool_t bConversionCut = kFALSE, - Double_t invMassForConversionCut = 0.04, - Bool_t bMomentumDifferenceCut = kFALSE, - Double_t fQCutMin = 0.0, - TString fArgEventClass = "EventPlane", - Double_t deltaEtaMax = 2.0, - Bool_t bVertexBinning = kFALSE) { - //Function to setup the AliBalance object and return it - AliBalancePsi *gBalance = new AliBalancePsi(); - gBalance->SetAnalysisLevel(analysisLevel); - gBalance->SetShuffle(bShuffle); - if(bResonancesCut) gBalance->UseResonancesCut(); - if(bHBTCut) gBalance->UseHBTCut(HBTCutValue); - if(bConversionCut) gBalance->UseConversionCut(invMassForConversionCut); - if(bMomentumDifferenceCut) gBalance->UseMomentumDifferenceCut(fQCutMin); - if(centralityName) gBalance->SetCentralityIdentifier(centralityName); - if(bVertexBinning) gBalance->SetVertexZBinning(); - gBalance->SetCentralityInterval(centrMin,centrMax); - gBalance->SetEventClass(fArgEventClass); - gBalance->SetDeltaEtaMax(deltaEtaMax); - - //Set all analyses separately - //Rapidity - //gBalance->SetInterval(AliBalance::kRapidity,-0.8,0.8,32,-1.6,1.6,15.); - //Eta - //gBalance->SetInterval(AliBalance::kEta,-0.8,0.8,32,-1.6,1.6,15); - //Qlong - //gBalance->SetInterval(AliBalance::kQlong,-1,1,200,0.0,4.0,15); - //Qout - //gBalance->SetInterval(AliBalance::kQout,-1,1,200,0.0,4.0,15); - //Qside - //gBalance->SetInterval(AliBalance::kQside,-1,1,200,0.0,4.0,15); - //Qinv - //gBalance->SetInterval(AliBalance::kQinv,-1,1,200,0.0,4.0,15); - //Phi - //gBalance->SetInterval(AliBalance::kPhi,0.,360.,90,-180.,180.0,15); - - // Init the histograms (not done here, for customization from analysis task) - // gBalance->InitHistograms(); - - return gBalance; -} - -//__________________________________________________// -AliESDtrackCuts *GetTrackCutsObject(Double_t ptMin, Double_t ptMax, Double_t etaMin, Double_t etaMax, Double_t maxTPCchi2, Double_t maxDCAz, Double_t maxDCAxy, Int_t minNClustersTPC) { - - // only used for ESDs - // Function to setup the AliESDtrackCuts object and return it - AliESDtrackCuts *cuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); - cuts->SetRequireTPCStandAlone(kTRUE); // TPC only cuts! - - // extra TPC cuts (Syst studies) - if(minNClustersTPC != -1) cuts->SetMinNClustersTPC(minNClustersTPC); - else cuts->SetMinNClustersTPC(70); // standard for filter bit 128 - - if(maxTPCchi2 != -1) cuts->SetMaxChi2PerClusterTPC(maxTPCchi2); - - // extra DCA cuts (Syst studies) - if(maxDCAz!=-1 && maxDCAxy != -1){ - cuts->SetMaxDCAToVertexZ(maxDCAz); - cuts->SetMaxDCAToVertexXY(maxDCAxy); - } - - cuts->SetPtRange(ptMin,ptMax); - cuts->SetEtaRange(etaMin,etaMax); - cuts->DefineHistograms(1); - //cuts->SaveHistograms("trackCuts"); - - return cuts; -} - +//__________________________________________________// +AliBalancePsi *GetBalanceFunctionObject(const char* analysisLevel = "MCAOD", // + const char* centralityName = 0x0, + Double_t centrMin = 0., + Double_t centrMax = 100., + Bool_t bShuffle = kFALSE, + Bool_t bResonancesCut = kFALSE, + Bool_t bHBTCut = kFALSE, + Double_t HBTCutValue = 0.02, + Bool_t bConversionCut = kFALSE, + Double_t invMassForConversionCut = 0.04, + Bool_t bMomentumDifferenceCut = kFALSE, + Double_t fQCutMin = 0.0, + TString fArgEventClass = "EventPlane", + Double_t deltaEtaMax = 2.0, + Bool_t bVertexBinning = kFALSE) { + //Function to setup the AliBalance object and return it + AliBalancePsi *gBalance = new AliBalancePsi(); + gBalance->SetAnalysisLevel(analysisLevel); + gBalance->SetShuffle(bShuffle); + if(bResonancesCut) gBalance->UseResonancesCut(); + if(bHBTCut) gBalance->UseHBTCut(HBTCutValue); + if(bConversionCut) gBalance->UseConversionCut(invMassForConversionCut); + if(bMomentumDifferenceCut) gBalance->UseMomentumDifferenceCut(fQCutMin); + if(centralityName) gBalance->SetCentralityIdentifier(centralityName); + if(bVertexBinning) gBalance->SetVertexZBinning(); + gBalance->SetCentralityInterval(centrMin,centrMax); + gBalance->SetEventClass(fArgEventClass); + gBalance->SetDeltaEtaMax(deltaEtaMax); + + //Set all analyses separately + //Rapidity + //gBalance->SetInterval(AliBalance::kRapidity,-0.8,0.8,32,-1.6,1.6,15.); + //Eta + //gBalance->SetInterval(AliBalance::kEta,-0.8,0.8,32,-1.6,1.6,15); + //Qlong + //gBalance->SetInterval(AliBalance::kQlong,-1,1,200,0.0,4.0,15); + //Qout + //gBalance->SetInterval(AliBalance::kQout,-1,1,200,0.0,4.0,15); + //Qside + //gBalance->SetInterval(AliBalance::kQside,-1,1,200,0.0,4.0,15); + //Qinv + //gBalance->SetInterval(AliBalance::kQinv,-1,1,200,0.0,4.0,15); + //Phi + //gBalance->SetInterval(AliBalance::kPhi,0.,360.,90,-180.,180.0,15); + + // Init the histograms (not done here, for customization from analysis task) + // gBalance->InitHistograms(); + + return gBalance; +} + +//__________________________________________________// +AliESDtrackCuts *GetTrackCutsObject(Double_t ptMin, Double_t ptMax, Double_t etaMin, Double_t etaMax, Double_t maxTPCchi2, Double_t maxDCAz, Double_t maxDCAxy, Int_t minNClustersTPC) { + + // only used for ESDs + // Function to setup the AliESDtrackCuts object and return it + AliESDtrackCuts *cuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); + cuts->SetRequireTPCStandAlone(kTRUE); // TPC only cuts! + + // extra TPC cuts (Syst studies) + if(minNClustersTPC != -1) cuts->SetMinNClustersTPC(minNClustersTPC); + else cuts->SetMinNClustersTPC(70); // standard for filter bit 128 + + if(maxTPCchi2 != -1) cuts->SetMaxChi2PerClusterTPC(maxTPCchi2); + + // extra DCA cuts (Syst studies) + if(maxDCAz!=-1 && maxDCAxy != -1){ + cuts->SetMaxDCAToVertexZ(maxDCAz); + cuts->SetMaxDCAToVertexXY(maxDCAxy); + } + + cuts->SetPtRange(ptMin,ptMax); + cuts->SetEtaRange(etaMin,etaMax); + cuts->DefineHistograms(1); + //cuts->SaveHistograms("trackCuts"); + + return cuts; +} + diff --git a/PWGCF/EBYE/macros/runBalanceFunctionPsi.C b/PWGCF/EBYE/macros/runBalanceFunctionPsi.C index 88bcd21e86a..e35649d6abe 100644 --- a/PWGCF/EBYE/macros/runBalanceFunctionPsi.C +++ b/PWGCF/EBYE/macros/runBalanceFunctionPsi.C @@ -1,510 +1,510 @@ -// run.C -// -// Template run macro for AliBasicTask.cxx/.h with example layout of -// physics selections and options, in macro and task. -// -// Author: Arvinder Palaha -// -class AliAnalysisGrid; -class AliAnalysisTaskBF; -class AliBalance; - -//Centrality stuff -Int_t binfirst = 0; //where do we start numbering bins -Int_t binlast = 8; //where do we stop numbering bins -const Int_t numberOfCentralityBins = 9; -Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile - -//Systematic studies -const Int_t numberOfSyst = 13; -Float_t vZ[numberOfSyst] = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.}; // global Vertex Z cut -Float_t DCAxy[numberOfSyst] = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4}; // DCA xy cut (afterburner, -1 = w/o additional cut) -Float_t DCAz[numberOfSyst] = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2}; // DCA z cut (afterburner, -1 = w/o additional cut) -Float_t ptMin[numberOfSyst] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3}; // pt cuts -Float_t ptMax[numberOfSyst] = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts -Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts -Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4}; // eta cuts - -Bool_t kUsePID = kFALSE; -Bool_t bUseHBTCut = kTRUE; -Bool_t bUseConversionCut = kTRUE; -Bool_t bResonancesCut = kTRUE; -Bool_t bMomentumDifferenceCut = kTRUE; -Int_t kNSigmaElectronRejection = 3; - -//______________________________________________________________________________ -void runBalanceFunctionPsi( - const char* runtype = "local", // local, proof or grid - const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof - const Int_t bunchN = 0, - const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS - const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data) - const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data - const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. - const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode - TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis - const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode - const char *taskname = "BF_Syst_Test" // sets name of grid generated macros - ) -{ - // check run type - if(runtype != "local" && runtype != "proof" && runtype != "grid") { - Printf("\n\tIncorrect run option, check first argument of run macro"); - Printf("\tint runtype = local, proof or grid\n"); - return; - } - Printf("%s analysis chosen",runtype); - - // load libraries - gSystem->Load("libCore.so"); - gSystem->Load("libGeom.so"); - gSystem->Load("libVMC.so"); - gSystem->Load("libPhysics.so"); - gSystem->Load("libTree.so"); - gSystem->Load("libSTEERBase.so"); - gSystem->Load("libESD.so"); - gSystem->Load("libAOD.so"); - gSystem->Load("libANALYSIS.so"); - gSystem->Load("libANALYSISalice.so"); - gSystem->Load("libEventMixing.so"); - gSystem->Load("libCORRFW.so"); - gSystem->Load("libPWGTools.so"); - gSystem->Load("libPWGCFebye.so"); - - // additional - - // compile standalone stuff - //gROOT->LoadMacro("AliBalance.cxx++g"); - //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g"); - - // add aliroot indlude path - //gROOT->ProcessLine(".include $PWD/."); - //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT"))); - - gROOT->SetStyle("Plain"); - - // analysis manager - AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN)); - - // create the alien handler and attach it to the manager - if(runtype == "grid") { - AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); - mgr->SetGridHandler(plugin); - } - else if(runtype == "local") { - TString filename; - TChain* chain = 0x0; - if((!bAOD)&&(!bMCtruth)) { - chain = new TChain("esdTree"); - for(Int_t i = 0; i < 4; i++) { - filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set"; - filename += i; filename += "/AliESDs.root"; - chain->Add(filename.Data()); - } - } - else if((bAOD)&&(!bMCtruth)) { - chain = new TChain("aodTree"); - for(Int_t i = 1; i < 20; i++) { - filename = "/glusterfs/alice1/alice2/pchrist/pp/LHC10c/7TeV/Data/Set"; - filename += i; filename += "/AliAOD.root"; - chain->Add(filename.Data()); - } - } - else if((!bAOD)&&(bMCtruth)) { - chain = new TChain("TE"); - for(Int_t i = 10; i < 99; i++) { - filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; - filename += i; - filename += "/galice.root"; - chain->Add(filename.Data()); - } - } - else if((bAOD)&&(bMCtruth)) { //used for MCAOD - chain = new TChain("aodTree"); - for(Int_t i = 10; i < 99; i++) { - filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; - filename += i; - filename += "/AliAOD.root"; - chain->Add(filename.Data()); - } - } - - - }//local mode - - // input handler (ESD or AOD) - AliVEventHandler* inputH = NULL; - if(!bAOD){ - inputH = new AliESDInputHandler(); - } - else{ - inputH = new AliAODInputHandler(); - } - mgr->SetInputEventHandler(inputH); - - // mc event handler - if(bMCtruth) { - AliMCEventHandler* mchandler = new AliMCEventHandler(); - // Not reading track references - mchandler->SetReadTR(kFALSE); - mgr->SetMCtruthEventHandler(mchandler); - } - - // AOD output handler - //AliAODHandler* aodoutHandler = new AliAODHandler(); - //aodoutHandler->SetOutputFileName("aod.root"); - //mgr->SetOutputEventHandler(aodoutHandler); - - // === Physics Selection Task === - // - // In SelectCollisionCandidate(), default is kMB, so the task UserExec() - // function is only called for these events. - // Options are: - // kMB Minimum Bias trigger - // kMBNoTRD Minimum bias trigger where the TRD is not read out - // kMUON Muon trigger - // kHighMult High-Multiplicity Trigger - // kUserDefined For manually defined trigger selection - // - // Multiple options possible with the standard AND/OR operators && and || - // These all have the usual offline SPD or V0 selections performed. - // - // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), - // one can manually set the selected and background classes using: - // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") - // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); - // - // One can also specify multiple classes at once, or require a class to NOT - // trigger, for e.g. - // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); - // - // NOTE that manually setting the physics selection overrides the standard - // selection, so it must be done in completeness. - // - // ALTERNATIVELY, one can make the physics selection inside the task - // UserExec(). - // For this case, comment out the task->SelectCol.... line, - // and see AliBasicTask.cxx UserExec() function for details on this. - - //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); - //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); - //if(!physSelTask) { Printf("no physSelTask"); return; } - //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); - //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); - - // create task - //Add the centrality determination task and the physics selection - // (only on ESD level, in AODs centrality is already in header and events are selected) - if((!bAOD)&&(!bMCtruth)){ - gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C"); - AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); - - // Add physics selection task (NOT needed for AODs) - gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); - AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel); - } - - //Add the PID response - if((kUsePID)||(kNSigmaElectronRejection)) { - gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); - AddTaskPIDResponse(bMCphyssel); - } - - //Add the VZERO event plane task - gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); - AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection(); - - //Add the BF task (all centralities) - gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); - - AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection); - //taskBF->SetDebugLevel(); - - // enable debug printouts - //mgr->SetDebugLevel(2); - //mgr->SetUseProgressBar(1,100); - if (!mgr->InitAnalysis()) return; - mgr->PrintStatus(); - - // start analysis - Printf("Starting Analysis...."); - if(runtype == "local") - mgr->StartAnalysis("local",chain); - else - mgr->StartAnalysis(runtype,nentries,firstentry); -} - -//______________________________________________________________________________ -AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset) -{ - AliAnalysisAlien *plugin = new AliAnalysisAlien(); - // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") - plugin->SetRunMode(gridmode); - - // Set versions of used packages - plugin->SetAPIVersion("V1.1x"); - plugin->SetROOTVersion("v5-28-00d"); - plugin->SetAliROOTVersion("v5-02-05-AN"); - - // Declare input data to be processed. - - // Method 1: Create automatically XML collections using alien 'find' command. - // Define production directory LFN - plugin->SetGridDataDir("/alice/data/2010/LHC10h/"); - // On real reconstructed data: - // plugin->SetGridDataDir("/alice/data/2009/LHC09d"); - - // Set data search pattern - //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES - // Data pattern for reconstructed data - if(!bAOD){ - plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH - } - else{ - plugin->SetDataPattern("*ESDs/pass2/AOD049/*/AliAOD.root"); - } - - plugin->SetRunPrefix("000"); // real data - // ...then add run numbers to be considered - //plugin->SetRunRange(114917,115322); - - if(bunchN==0){ - plugin->AddRunNumber(137366); - } - - //bunch1 - else if(bunchN == 1){ - plugin->AddRunNumber(139510); - plugin->AddRunNumber(139507); - plugin->AddRunNumber(139505); - plugin->AddRunNumber(139503); - plugin->AddRunNumber(139465); - plugin->AddRunNumber(139438); - plugin->AddRunNumber(139437); - plugin->AddRunNumber(139360); - plugin->AddRunNumber(139329); - plugin->AddRunNumber(139328); - } - - //bunch2 - else if(bunchN == 2){ - plugin->AddRunNumber(139314); - plugin->AddRunNumber(139310); - plugin->AddRunNumber(139309); - plugin->AddRunNumber(139173); - plugin->AddRunNumber(139107); - plugin->AddRunNumber(139105); - plugin->AddRunNumber(139038); - plugin->AddRunNumber(139037); - plugin->AddRunNumber(139036); - plugin->AddRunNumber(139029); - plugin->AddRunNumber(139028); - plugin->AddRunNumber(138872); - plugin->AddRunNumber(138871); - plugin->AddRunNumber(138870); - plugin->AddRunNumber(138837); - plugin->AddRunNumber(138732); - plugin->AddRunNumber(138730); - plugin->AddRunNumber(138666); - plugin->AddRunNumber(138662); - plugin->AddRunNumber(138653); - } - - else if(bunchN == 3){ - plugin->AddRunNumber(138652); - plugin->AddRunNumber(138638); - plugin->AddRunNumber(138624); - plugin->AddRunNumber(138621); - plugin->AddRunNumber(138583); - plugin->AddRunNumber(138582); - plugin->AddRunNumber(138579); - plugin->AddRunNumber(138578); - plugin->AddRunNumber(138534); - plugin->AddRunNumber(138469); - } - - else if(bunchN == 4){ - - plugin->AddRunNumber(138442); - plugin->AddRunNumber(138439); - plugin->AddRunNumber(138438); - plugin->AddRunNumber(138396); - plugin->AddRunNumber(138364); - plugin->AddRunNumber(138275); - plugin->AddRunNumber(138225); - plugin->AddRunNumber(138201); - plugin->AddRunNumber(138197); - plugin->AddRunNumber(138192); - } - - else if(bunchN == 5){ - - plugin->AddRunNumber(138190); - plugin->AddRunNumber(137848); - plugin->AddRunNumber(137844); - plugin->AddRunNumber(137752); - plugin->AddRunNumber(137751); - plugin->AddRunNumber(137724); - plugin->AddRunNumber(137722); - plugin->AddRunNumber(137718); - plugin->AddRunNumber(137704); - plugin->AddRunNumber(137693); - } - - else if(bunchN == 6){ - - plugin->AddRunNumber(137692); - plugin->AddRunNumber(137691); - plugin->AddRunNumber(137686); - plugin->AddRunNumber(137685); - plugin->AddRunNumber(137639); - plugin->AddRunNumber(137638); - plugin->AddRunNumber(137608); - plugin->AddRunNumber(137595); - plugin->AddRunNumber(137549); - plugin->AddRunNumber(137546); - - } - - else if(bunchN == 7){ - - plugin->AddRunNumber(137544); - plugin->AddRunNumber(137541); - plugin->AddRunNumber(137539); - plugin->AddRunNumber(137531); - plugin->AddRunNumber(137530); - plugin->AddRunNumber(137443); - plugin->AddRunNumber(137441); - plugin->AddRunNumber(137440); - plugin->AddRunNumber(137439); - plugin->AddRunNumber(137434); - - } - - else if(bunchN == 8){ - - plugin->AddRunNumber(137432); - plugin->AddRunNumber(137431); - plugin->AddRunNumber(137430); - plugin->AddRunNumber(137366); - plugin->AddRunNumber(137243); - plugin->AddRunNumber(137236); - plugin->AddRunNumber(137235); - plugin->AddRunNumber(137232); - plugin->AddRunNumber(137231); - plugin->AddRunNumber(137162); - plugin->AddRunNumber(137161); - } - - else{ - - stderr<<"BUNCH NOT THERE"<AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161"); - - - - - - plugin->SetNrunsPerMaster(1); - plugin->SetOutputToRunNo(); - // comment out the next line when using the "terminate" option, unless - // you want separate merged files for each run - plugin->SetMergeViaJDL(); - - // Method 2: Declare existing data files (raw collections, xml collections, root file) - // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) - // XML collections added via this method can be combined with the first method if - // the content is compatible (using or not tags) - // plugin->AddDataFile("tag.xml"); - // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); - - // Define alien work directory where all files will be copied. Relative to alien $HOME. - plugin->SetGridWorkingDir(taskname); - - // Declare alien output directory. Relative to working directory. - plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out - - // Declare the analysis source files names separated by blancs. To be compiled runtime - // using ACLiC on the worker nodes. - plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx"); - - // Declare all libraries (other than the default ones for the framework. These will be - // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. - //plugin->AddIncludePath("-I."); - //plugin->SetAdditionalLibs("libPWGCFebye.so"); - plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h"); - - // Declare the output file names separated by blancs. - // (can be like: file.root or file.root@ALICE::Niham::File) - // To only save certain files, use SetDefaultOutputs(kFALSE), and then - // SetOutputFiles("list.root other.filename") to choose which files to save - plugin->SetDefaultOutputs(); - //plugin->SetOutputFiles("list.root"); - - // Optionally set a name for the generated analysis macro (default MyAnalysis.C) - plugin->SetAnalysisMacro(Form("%s.C",taskname)); - - // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) - plugin->SetSplitMaxInputFileNumber(100); - - // Optionally modify the executable name (default analysis.sh) - plugin->SetExecutable(Form("%s.sh",taskname)); - - // set number of test files to use in "test" mode - plugin->SetNtestFiles(1); - - // Optionally resubmit threshold. - plugin->SetMasterResubmitThreshold(90); - - // Optionally set time to live (default 30000 sec) - plugin->SetTTL(90000); - - // Optionally set input format (default xml-single) - plugin->SetInputFormat("xml-single"); - - // Optionally modify the name of the generated JDL (default analysis.jdl) - plugin->SetJDLName(Form("%s.jdl",taskname)); - - // Optionally modify job price (default 1) - plugin->SetPrice(1); - - // Optionally modify split mode (default 'se') - plugin->SetSplitMode("se"); - - //plugin->SetUseSubmitPolicy(); - //plugin->SetKeepLogs(); - - //---------------------------------------------------------- - //--- PROOF MODE SPECIFIC SETTINGS ------------ - //---------------------------------------------------------- - // Proof cluster - plugin->SetProofCluster(proofcluster); - // Dataset to be used - plugin->SetProofDataSet(proofdataset); - // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard - plugin->SetProofReset(0); - // May limit number of workers - plugin->SetNproofWorkers(0); - // May limit the number of workers per slave - plugin->SetNproofWorkersPerSlave(1); - // May use a specific version of root installed in proof - plugin->SetRootVersionForProof("current"); - // May set the aliroot mode. Check http://aaf.cern.ch/node/83 - plugin->SetAliRootMode("default"); // Loads AF libs by default - // May request ClearPackages (individual ClearPackage not supported) - plugin->SetClearPackages(kFALSE); - // Plugin test mode works only providing a file containing test file locations, used in "local" mode also - plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc - // Request connection to alien upon connection to grid - plugin->SetProofConnectGrid(kFALSE); - - plugin->Print(); - - return plugin; -} - +// run.C +// +// Template run macro for AliBasicTask.cxx/.h with example layout of +// physics selections and options, in macro and task. +// +// Author: Arvinder Palaha +// +class AliAnalysisGrid; +class AliAnalysisTaskBF; +class AliBalance; + +//Centrality stuff +Int_t binfirst = 0; //where do we start numbering bins +Int_t binlast = 8; //where do we stop numbering bins +const Int_t numberOfCentralityBins = 9; +Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile + +//Systematic studies +const Int_t numberOfSyst = 13; +Float_t vZ[numberOfSyst] = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.}; // global Vertex Z cut +Float_t DCAxy[numberOfSyst] = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4}; // DCA xy cut (afterburner, -1 = w/o additional cut) +Float_t DCAz[numberOfSyst] = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2}; // DCA z cut (afterburner, -1 = w/o additional cut) +Float_t ptMin[numberOfSyst] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3}; // pt cuts +Float_t ptMax[numberOfSyst] = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts +Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts +Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4}; // eta cuts + +Bool_t kUsePID = kFALSE; +Bool_t bUseHBTCut = kTRUE; +Bool_t bUseConversionCut = kTRUE; +Bool_t bResonancesCut = kTRUE; +Bool_t bMomentumDifferenceCut = kTRUE; +Int_t kNSigmaElectronRejection = 3; + +//______________________________________________________________________________ +void runBalanceFunctionPsi( + const char* runtype = "local", // local, proof or grid + const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof + const Int_t bunchN = 0, + const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS + const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data) + const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data + const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. + const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode + TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis + const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode + const char *taskname = "BF_Syst_Test" // sets name of grid generated macros + ) +{ + // check run type + if(runtype != "local" && runtype != "proof" && runtype != "grid") { + Printf("\n\tIncorrect run option, check first argument of run macro"); + Printf("\tint runtype = local, proof or grid\n"); + return; + } + Printf("%s analysis chosen",runtype); + + // load libraries + gSystem->Load("libCore.so"); + gSystem->Load("libGeom.so"); + gSystem->Load("libVMC.so"); + gSystem->Load("libPhysics.so"); + gSystem->Load("libTree.so"); + gSystem->Load("libSTEERBase.so"); + gSystem->Load("libESD.so"); + gSystem->Load("libAOD.so"); + gSystem->Load("libANALYSIS.so"); + gSystem->Load("libANALYSISalice.so"); + gSystem->Load("libEventMixing.so"); + gSystem->Load("libCORRFW.so"); + gSystem->Load("libPWGTools.so"); + gSystem->Load("libPWGCFebye.so"); + + // additional + + // compile standalone stuff + //gROOT->LoadMacro("AliBalance.cxx++g"); + //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g"); + + // add aliroot indlude path + //gROOT->ProcessLine(".include $PWD/."); + //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT"))); + + gROOT->SetStyle("Plain"); + + // analysis manager + AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN)); + + // create the alien handler and attach it to the manager + if(runtype == "grid") { + AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); + mgr->SetGridHandler(plugin); + } + else if(runtype == "local") { + TString filename; + TChain* chain = 0x0; + if((!bAOD)&&(!bMCtruth)) { + chain = new TChain("esdTree"); + for(Int_t i = 0; i < 4; i++) { + filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set"; + filename += i; filename += "/AliESDs.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(!bMCtruth)) { + chain = new TChain("aodTree"); + for(Int_t i = 1; i < 20; i++) { + filename = "/glusterfs/alice1/alice2/pchrist/pp/LHC10c/7TeV/Data/Set"; + filename += i; filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + else if((!bAOD)&&(bMCtruth)) { + chain = new TChain("TE"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/galice.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(bMCtruth)) { //used for MCAOD + chain = new TChain("aodTree"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + + + }//local mode + + // input handler (ESD or AOD) + AliVEventHandler* inputH = NULL; + if(!bAOD){ + inputH = new AliESDInputHandler(); + } + else{ + inputH = new AliAODInputHandler(); + } + mgr->SetInputEventHandler(inputH); + + // mc event handler + if(bMCtruth) { + AliMCEventHandler* mchandler = new AliMCEventHandler(); + // Not reading track references + mchandler->SetReadTR(kFALSE); + mgr->SetMCtruthEventHandler(mchandler); + } + + // AOD output handler + //AliAODHandler* aodoutHandler = new AliAODHandler(); + //aodoutHandler->SetOutputFileName("aod.root"); + //mgr->SetOutputEventHandler(aodoutHandler); + + // === Physics Selection Task === + // + // In SelectCollisionCandidate(), default is kMB, so the task UserExec() + // function is only called for these events. + // Options are: + // kMB Minimum Bias trigger + // kMBNoTRD Minimum bias trigger where the TRD is not read out + // kMUON Muon trigger + // kHighMult High-Multiplicity Trigger + // kUserDefined For manually defined trigger selection + // + // Multiple options possible with the standard AND/OR operators && and || + // These all have the usual offline SPD or V0 selections performed. + // + // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), + // one can manually set the selected and background classes using: + // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") + // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); + // + // One can also specify multiple classes at once, or require a class to NOT + // trigger, for e.g. + // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); + // + // NOTE that manually setting the physics selection overrides the standard + // selection, so it must be done in completeness. + // + // ALTERNATIVELY, one can make the physics selection inside the task + // UserExec(). + // For this case, comment out the task->SelectCol.... line, + // and see AliBasicTask.cxx UserExec() function for details on this. + + //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); + //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); + //if(!physSelTask) { Printf("no physSelTask"); return; } + //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); + //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); + + // create task + //Add the centrality determination task and the physics selection + // (only on ESD level, in AODs centrality is already in header and events are selected) + if((!bAOD)&&(!bMCtruth)){ + gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C"); + AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); + + // Add physics selection task (NOT needed for AODs) + gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); + AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel); + } + + //Add the PID response + if((kUsePID)||(kNSigmaElectronRejection)) { + gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); + AddTaskPIDResponse(bMCphyssel); + } + + //Add the VZERO event plane task + gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); + AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection(); + + //Add the BF task (all centralities) + gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); + + AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection); + //taskBF->SetDebugLevel(); + + // enable debug printouts + //mgr->SetDebugLevel(2); + //mgr->SetUseProgressBar(1,100); + if (!mgr->InitAnalysis()) return; + mgr->PrintStatus(); + + // start analysis + Printf("Starting Analysis...."); + if(runtype == "local") + mgr->StartAnalysis("local",chain); + else + mgr->StartAnalysis(runtype,nentries,firstentry); +} + +//______________________________________________________________________________ +AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset) +{ + AliAnalysisAlien *plugin = new AliAnalysisAlien(); + // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") + plugin->SetRunMode(gridmode); + + // Set versions of used packages + plugin->SetAPIVersion("V1.1x"); + plugin->SetROOTVersion("v5-28-00d"); + plugin->SetAliROOTVersion("v5-02-05-AN"); + + // Declare input data to be processed. + + // Method 1: Create automatically XML collections using alien 'find' command. + // Define production directory LFN + plugin->SetGridDataDir("/alice/data/2010/LHC10h/"); + // On real reconstructed data: + // plugin->SetGridDataDir("/alice/data/2009/LHC09d"); + + // Set data search pattern + //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES + // Data pattern for reconstructed data + if(!bAOD){ + plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH + } + else{ + plugin->SetDataPattern("*ESDs/pass2/AOD049/*/AliAOD.root"); + } + + plugin->SetRunPrefix("000"); // real data + // ...then add run numbers to be considered + //plugin->SetRunRange(114917,115322); + + if(bunchN==0){ + plugin->AddRunNumber(137366); + } + + //bunch1 + else if(bunchN == 1){ + plugin->AddRunNumber(139510); + plugin->AddRunNumber(139507); + plugin->AddRunNumber(139505); + plugin->AddRunNumber(139503); + plugin->AddRunNumber(139465); + plugin->AddRunNumber(139438); + plugin->AddRunNumber(139437); + plugin->AddRunNumber(139360); + plugin->AddRunNumber(139329); + plugin->AddRunNumber(139328); + } + + //bunch2 + else if(bunchN == 2){ + plugin->AddRunNumber(139314); + plugin->AddRunNumber(139310); + plugin->AddRunNumber(139309); + plugin->AddRunNumber(139173); + plugin->AddRunNumber(139107); + plugin->AddRunNumber(139105); + plugin->AddRunNumber(139038); + plugin->AddRunNumber(139037); + plugin->AddRunNumber(139036); + plugin->AddRunNumber(139029); + plugin->AddRunNumber(139028); + plugin->AddRunNumber(138872); + plugin->AddRunNumber(138871); + plugin->AddRunNumber(138870); + plugin->AddRunNumber(138837); + plugin->AddRunNumber(138732); + plugin->AddRunNumber(138730); + plugin->AddRunNumber(138666); + plugin->AddRunNumber(138662); + plugin->AddRunNumber(138653); + } + + else if(bunchN == 3){ + plugin->AddRunNumber(138652); + plugin->AddRunNumber(138638); + plugin->AddRunNumber(138624); + plugin->AddRunNumber(138621); + plugin->AddRunNumber(138583); + plugin->AddRunNumber(138582); + plugin->AddRunNumber(138579); + plugin->AddRunNumber(138578); + plugin->AddRunNumber(138534); + plugin->AddRunNumber(138469); + } + + else if(bunchN == 4){ + + plugin->AddRunNumber(138442); + plugin->AddRunNumber(138439); + plugin->AddRunNumber(138438); + plugin->AddRunNumber(138396); + plugin->AddRunNumber(138364); + plugin->AddRunNumber(138275); + plugin->AddRunNumber(138225); + plugin->AddRunNumber(138201); + plugin->AddRunNumber(138197); + plugin->AddRunNumber(138192); + } + + else if(bunchN == 5){ + + plugin->AddRunNumber(138190); + plugin->AddRunNumber(137848); + plugin->AddRunNumber(137844); + plugin->AddRunNumber(137752); + plugin->AddRunNumber(137751); + plugin->AddRunNumber(137724); + plugin->AddRunNumber(137722); + plugin->AddRunNumber(137718); + plugin->AddRunNumber(137704); + plugin->AddRunNumber(137693); + } + + else if(bunchN == 6){ + + plugin->AddRunNumber(137692); + plugin->AddRunNumber(137691); + plugin->AddRunNumber(137686); + plugin->AddRunNumber(137685); + plugin->AddRunNumber(137639); + plugin->AddRunNumber(137638); + plugin->AddRunNumber(137608); + plugin->AddRunNumber(137595); + plugin->AddRunNumber(137549); + plugin->AddRunNumber(137546); + + } + + else if(bunchN == 7){ + + plugin->AddRunNumber(137544); + plugin->AddRunNumber(137541); + plugin->AddRunNumber(137539); + plugin->AddRunNumber(137531); + plugin->AddRunNumber(137530); + plugin->AddRunNumber(137443); + plugin->AddRunNumber(137441); + plugin->AddRunNumber(137440); + plugin->AddRunNumber(137439); + plugin->AddRunNumber(137434); + + } + + else if(bunchN == 8){ + + plugin->AddRunNumber(137432); + plugin->AddRunNumber(137431); + plugin->AddRunNumber(137430); + plugin->AddRunNumber(137366); + plugin->AddRunNumber(137243); + plugin->AddRunNumber(137236); + plugin->AddRunNumber(137235); + plugin->AddRunNumber(137232); + plugin->AddRunNumber(137231); + plugin->AddRunNumber(137162); + plugin->AddRunNumber(137161); + } + + else{ + + stderr<<"BUNCH NOT THERE"<AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161"); + + + + + + plugin->SetNrunsPerMaster(1); + plugin->SetOutputToRunNo(); + // comment out the next line when using the "terminate" option, unless + // you want separate merged files for each run + plugin->SetMergeViaJDL(); + + // Method 2: Declare existing data files (raw collections, xml collections, root file) + // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) + // XML collections added via this method can be combined with the first method if + // the content is compatible (using or not tags) + // plugin->AddDataFile("tag.xml"); + // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); + + // Define alien work directory where all files will be copied. Relative to alien $HOME. + plugin->SetGridWorkingDir(taskname); + + // Declare alien output directory. Relative to working directory. + plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out + + // Declare the analysis source files names separated by blancs. To be compiled runtime + // using ACLiC on the worker nodes. + plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx"); + + // Declare all libraries (other than the default ones for the framework. These will be + // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. + //plugin->AddIncludePath("-I."); + //plugin->SetAdditionalLibs("libPWGCFebye.so"); + plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h"); + + // Declare the output file names separated by blancs. + // (can be like: file.root or file.root@ALICE::Niham::File) + // To only save certain files, use SetDefaultOutputs(kFALSE), and then + // SetOutputFiles("list.root other.filename") to choose which files to save + plugin->SetDefaultOutputs(); + //plugin->SetOutputFiles("list.root"); + + // Optionally set a name for the generated analysis macro (default MyAnalysis.C) + plugin->SetAnalysisMacro(Form("%s.C",taskname)); + + // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) + plugin->SetSplitMaxInputFileNumber(100); + + // Optionally modify the executable name (default analysis.sh) + plugin->SetExecutable(Form("%s.sh",taskname)); + + // set number of test files to use in "test" mode + plugin->SetNtestFiles(1); + + // Optionally resubmit threshold. + plugin->SetMasterResubmitThreshold(90); + + // Optionally set time to live (default 30000 sec) + plugin->SetTTL(90000); + + // Optionally set input format (default xml-single) + plugin->SetInputFormat("xml-single"); + + // Optionally modify the name of the generated JDL (default analysis.jdl) + plugin->SetJDLName(Form("%s.jdl",taskname)); + + // Optionally modify job price (default 1) + plugin->SetPrice(1); + + // Optionally modify split mode (default 'se') + plugin->SetSplitMode("se"); + + //plugin->SetUseSubmitPolicy(); + //plugin->SetKeepLogs(); + + //---------------------------------------------------------- + //--- PROOF MODE SPECIFIC SETTINGS ------------ + //---------------------------------------------------------- + // Proof cluster + plugin->SetProofCluster(proofcluster); + // Dataset to be used + plugin->SetProofDataSet(proofdataset); + // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard + plugin->SetProofReset(0); + // May limit number of workers + plugin->SetNproofWorkers(0); + // May limit the number of workers per slave + plugin->SetNproofWorkersPerSlave(1); + // May use a specific version of root installed in proof + plugin->SetRootVersionForProof("current"); + // May set the aliroot mode. Check http://aaf.cern.ch/node/83 + plugin->SetAliRootMode("default"); // Loads AF libs by default + // May request ClearPackages (individual ClearPackage not supported) + plugin->SetClearPackages(kFALSE); + // Plugin test mode works only providing a file containing test file locations, used in "local" mode also + plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc + // Request connection to alien upon connection to grid + plugin->SetProofConnectGrid(kFALSE); + + plugin->Print(); + + return plugin; +} + diff --git a/PWGCF/FEMTOSCOPY/macros/Train/Kch_Eta05Pt01415/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/Kch_Eta05Pt01415/ConfigFemtoAnalysis.C index 5d203048042..e081b6730a4 100644 --- a/PWGCF/FEMTOSCOPY/macros/Train/Kch_Eta05Pt01415/ConfigFemtoAnalysis.C +++ b/PWGCF/FEMTOSCOPY/macros/Train/Kch_Eta05Pt01415/ConfigFemtoAnalysis.C @@ -1,334 +1,334 @@ - -/********************************************************************* - * * - * ConfigFemtoAnalysis.C - configuration macro for the femtoscopic * - * analysis, meant as a QA process for two-particle effects * - * * - * Author: Adam Kisiel (Adam.Kisiel@cern.ch) * - * * - *********************************************************************/ - -#if !defined(__CINT__) || defined(__MAKECINT_) -#include "AliFemtoManager.h" -#include "AliFemtoEventReaderESDChain.h" -#include "AliFemtoEventReaderESDChainKine.h" -#include "AliFemtoEventReaderAODChain.h" -#include "AliFemtoSimpleAnalysis.h" -#include "AliFemtoBasicEventCut.h" -#include "AliFemtoESDTrackCut.h" -#include "AliFemtoKKTrackCut.h" -#include "AliFemtoCorrFctn.h" -#include "AliFemtoCutMonitorParticleYPt.h" -#include "AliFemtoCutMonitorParticleVertPos.h" -#include "AliFemtoCutMonitorParticleMomRes.h" -#include "AliFemtoCutMonitorParticlePID.h" -#include "AliFemtoCutMonitorEventMult.h" -#include "AliFemtoCutMonitorEventVertex.h" -#include "AliFemtoShareQualityTPCEntranceSepPairCut.h" -#include "AliFemtoPairCutAntiGamma.h" -#include "AliFemtoPairCutRadialDistance.h" -#include "AliFemtoQinvCorrFctn.h" -#include "AliFemtoShareQualityCorrFctn.h" -#include "AliFemtoTPCInnerCorrFctn.h" -#include "AliFemtoVertexMultAnalysis.h" -#include "AliFemtoCorrFctn3DSpherical.h" -#include "AliFemtoChi2CorrFctn.h" -#include "AliFemtoCorrFctnTPCNcls.h" -#include "AliFemtoBPLCMS3DCorrFctn.h" -#include "AliFemtoCorrFctn3DLCMSSym.h" -#include "AliFemtoModelBPLCMSCorrFctn.h" -#include "AliFemtoModelCorrFctn3DSpherical.h" -#include "AliFemtoModelGausLCMSFreezeOutGenerator.h" -#include "AliFemtoModelGausRinvFreezeOutGenerator.h" -#include "AliFemtoModelManager.h" -#include "AliFemtoModelWeightGeneratorBasic.h" -#include "AliFemtoModelWeightGeneratorLednicky.h" -#include "AliFemtoCorrFctnDirectYlm.h" -#include "AliFemtoModelCorrFctnDirectYlm.h" -#include "AliFemtoModelCorrFctnSource.h" -#include "AliFemtoCutMonitorParticlePtPDG.h" -#include "AliFemtoKTPairCut.h" -#include "AliFemtoCutMonitorCollections.h" -#endif - -//________________________________________________________________________ -AliFemtoManager* ConfigFemtoAnalysis() { - - double PionMass = 0.13956995; - double KaonMass = 0.493677; - - //multiplicity bins - //int runmults[10] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0}; - //int multbins[11] = {0.01, 200, 400, 600, 1000, 950, 500, 600, 700, 800, 900}; - //int runmults[3] = {1, 1, 1}; - //int multbins[4] = {0.01, 200, 400, 900}; - int runmults[3] = {1, 0, 0}; - int multbins[4] = {0.01, 50, 100, 900}; - - int runch[2] = {1, 1}; - //const char *chrgs[2] = { "pip", "pim" }; - const char *chrgs[2] = { "Kp", "Km"}; - - int runktdep = 1; - //double ktrng[8] = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0}; - //double ktrng[3] = {0.2, 0.5, 1.0}; - //double ktrng[3] = {0.2, 0.5, 1.0}; - double ktrng[2] = {0.2, 0.36}; - - int run3d = 1; // Do 3D cartesian analysis? - //int runshlcms = 1; - int runshlcms = 0; - - //PhysicsSelection set only in runBatch with trigger + Physics Selection Task - - - double shqmax; - int nbinssh = 200; - //int nbinssh = 100; - - //if (runshlcms) shqmax = 2.0; - if (runshlcms) shqmax = 0.25; - //else shqmax = 0.9; - else shqmax = 2.0; - - AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain(); - Reader->SetFilterBit(0); - Reader->SetCentralityPreSelection(0.01, 900); - - //AliFemtoEventReaderESDChainKine* Reader=new AliFemtoEventReaderESDChainKine(); - //Reader->SetConstrained(true); - // Reader->SetUseTPCOnly(false); - - // AliFemtoEventReaderESDChain *Reader = new AliFemtoEventReaderESDChain(); - // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality); - // Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kGlobal); - - - AliFemtoManager* Manager=new AliFemtoManager(); - Manager->SetEventReader(Reader); - - AliFemtoVertexMultAnalysis *anetaphitpc[20]; - AliFemtoBasicEventCut *mecetaphitpc[20]; - AliFemtoCutMonitorEventMult *cutPassEvMetaphitpc[20]; - AliFemtoCutMonitorEventMult *cutFailEvMetaphitpc[20]; - AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[20]; - AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[20]; - AliFemtoCutMonitorCollections *cutPassColletaphitpc[20]; - AliFemtoCutMonitorCollections *cutFailColletaphitpc[20]; - AliFemtoKKTrackCut *dtc1etaphitpc[20]; - AliFemtoKKTrackCut *dtc2etaphitpc[20]; - //AliFemtoESDTrackCut *dtc1etaphitpc[20]; - //AliFemtoESDTrackCut *dtc2etaphitpc[20]; - AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[20]; - AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[20]; - AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[20]; - AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[20]; - AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[20]; - AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[20]; - AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[20]; - AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[20]; - // AliFemtoPairCutAntiGamma *sqpcetaphitpc[20]; - AliFemtoShareQualityPairCut *sqpcetaphitpc[20]; - //AliFemtoPairCutRadialDistance *sqpcetaphitpc[20]; - AliFemtoCorrFctnDirectYlm *cylmetaphitpc[20]; - AliFemtoCorrFctnDEtaDPhi *cdedpetaphi[20]; - AliFemtoChi2CorrFctn *cchiqinvetaphitpc[20]; - //AliFemtoKTPairCut *ktpcuts[20*7]; - //AliFemtoCorrFctnDirectYlm *cylmkttpc[20*7]; - //AliFemtoQinvCorrFctn *cqinvkttpc[20*7]; - //AliFemtoCorrFctn3DLCMSSym *cq3dlcmskttpc[20*7]; - AliFemtoKTPairCut *ktpcuts[20*8]; - AliFemtoCorrFctnDirectYlm *cylmkttpc[20*8]; - AliFemtoQinvCorrFctn *cqinvkttpc[20*8]; - AliFemtoCorrFctn3DLCMSSym *cq3dlcmskttpc[20*8]; - AliFemtoCorrFctnTPCNcls *cqinvnclstpc[20]; - AliFemtoShareQualityCorrFctn *cqinvsqtpc[20*10]; - AliFemtoChi2CorrFctn *cqinvchi2tpc[20]; - AliFemtoTPCInnerCorrFctn *cqinvinnertpc[20*10]; - - // *** Begin pion-pion analysis *** - int aniter = 0; - - for (int imult=0; imult<3; imult++) { - if (runmults[imult]) { - for (int ichg=0; ichg<2; ichg++) { - if (runch[ichg]) { - aniter = ichg*3+imult; - - anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(10, -10.0, 10.0, 4, multbins[imult], multbins[imult+1]); - anetaphitpc[aniter]->SetNumEventsToMix(5); - anetaphitpc[aniter]->SetMinSizePartCollection(1); - - mecetaphitpc[aniter] = new AliFemtoBasicEventCut(); - mecetaphitpc[aniter]->SetEventMult(0,10000); - mecetaphitpc[aniter]->SetVertZPos(-10,10); - - //cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult)); - //cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult)); - - cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult),500); - cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult),500); - - mecetaphitpc[aniter]->AddCutMonitor(cutPassEvMetaphitpc[aniter], cutFailEvMetaphitpc[aniter]); - - cutPassEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutPass%stpcM%i", chrgs[ichg], imult)); - cutFailEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutFail%stpcM%i", chrgs[ichg], imult)); - mecetaphitpc[aniter]->AddCutMonitor(cutPassEvVetaphitpc[aniter], cutFailEvVetaphitpc[aniter]); - - cutPassColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutPass%stpcM%i", chrgs[ichg], imult)); - cutFailColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutFail%stpcM%i", chrgs[ichg], imult)); - mecetaphitpc[aniter]->AddCutMonitor(cutPassColletaphitpc[aniter], cutFailColletaphitpc[aniter]); - - //dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut(); - dtc1etaphitpc[aniter] = new AliFemtoKKTrackCut(); - - if (ichg == 0) - dtc1etaphitpc[aniter]->SetCharge(1.0); - else if (ichg == 1) - dtc1etaphitpc[aniter]->SetCharge(-1.0); - - dtc1etaphitpc[aniter]->SetPt(0.14,1.5); - dtc1etaphitpc[aniter]->SetRapidity(-0.5,0.5); - //dtc1etaphitpc[aniter]->SetPt(0.14,1.5); - //dtc1etaphitpc[aniter]->SetEta(-0.8,0.8); - - //PID method - //dtc1etaphitpc[aniter]->SetMass(PionMass); - //dtc1etaphitpc[aniter]->SetMostProbablePion(); - dtc1etaphitpc[aniter]->SetMass(KaonMass); - dtc1etaphitpc[aniter]->SetMostProbableKaon(); - //dtc1etaphitpc[aniter]->SetPIDMethod(AliFemtoESDTrackCut::kContour); - - //Track quality cuts - dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit); - dtc1etaphitpc[aniter]->SetminTPCncls(50); - dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE); - - - dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0); - dtc1etaphitpc[aniter]->SetMaxITSChiNdof(36); - dtc1etaphitpc[aniter]->SetLabel(kFALSE); - - //primary particles: hits in ITS + DCA cut - //dtc1etaphitpc[aniter]->SetClusterRequirementITS(AliESDtrackCuts::kSPD, - // AliESDtrackCuts::kAny); - dtc1etaphitpc[aniter]->SetMaxImpactZ(2.0); - //dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); - dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0105, 0.0350, -1.1); - //dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01); - //dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0); - - //cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%i", chrgs[ichg], imult), 0.13957); - //cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%i", chrgs[ichg], imult), 0.13957); - cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%i", chrgs[ichg], imult), 0.493677); - cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%i", chrgs[ichg], imult), 0.493677); - dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]); - - //cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%i", chrgs[ichg], imult),0); - //cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%i", chrgs[ichg], imult),0); - cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%i", chrgs[ichg], imult),1); - cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%i", chrgs[ichg], imult),1); - dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]); - - //sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma(); - sqpcetaphitpc[aniter] = new AliFemtoShareQualityPairCut(); - //sqpcetaphitpc[aniter] = new AliFemtoShareQualityTPCEntranceSepPairCut(); - //sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance(); - sqpcetaphitpc[aniter]->SetShareQualityMax(1.0); - sqpcetaphitpc[aniter]->SetShareFractionMax(0.05); - sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE); - //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016); - //sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.02); - //runtype==0 - // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0); - // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0); - // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5); - // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); - // sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03); - //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); - //runtype==1 - // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0); - // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); - //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03); - //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); - //runtype==2 - // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.0); - // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); - //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.045); - //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016); - //sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.02); - - anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]); - anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]); - anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]); - anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]); - - //Correlation functions - - //Spherical harmonics (without kT bins) - //cylmetaphitpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),3,nbinssh,0.0,shqmax,runshlcms); - //anetaphitpc[aniter]->AddCorrFctn(cylmetaphitpc[aniter]); - - //Qinv (without kT bins) - cqinvkttpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); - anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[aniter]); - - //3D cartesian (without kT bins) - if(run3d){ - //cq3dlcmskttpc[aniter] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%i", chrgs[ichg], imult),60,0.5); - cq3dlcmskttpc[aniter] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%i", chrgs[ichg], imult),100,0.5); - anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[aniter]); - } - - // cqinvnclstpc[aniter] = new AliFemtoCorrFctnTPCNcls(Form("cqinvncls%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); - // anetaphitpc[aniter]->AddCorrFctn(cqinvnclstpc[aniter]); - - // cqinvchi2tpc[aniter] = new AliFemtoChi2CorrFctn(Form("cqinvchi2%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); - // anetaphitpc[aniter]->AddCorrFctn(cqinvchi2tpc[aniter]); - - if (runktdep) { - int ktm; - for (int ikt=0; ikt<2; ikt++) { - ktm = aniter*2 + ikt; - ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]); - - //cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%ikT%i", chrgs[ichg], imult, ikt),3, - // nbinssh, 0.0, shqmax, runshlcms); - //cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); - //anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]); - - cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0, shqmax); - cqinvkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); - anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[ktm]); - - cqinvsqtpc[ktm] = new AliFemtoShareQualityCorrFctn(Form("cqinvsq%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,shqmax); - cqinvsqtpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); - anetaphitpc[aniter]->AddCorrFctn(cqinvsqtpc[ktm]); - - cqinvinnertpc[ktm] = new AliFemtoTPCInnerCorrFctn(Form("cqinvinner%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,shqmax); - cqinvinnertpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); - cqinvinnertpc[ktm]->SetRadius(1.2); - anetaphitpc[aniter]->AddCorrFctn(cqinvinnertpc[ktm]); - - if (run3d) { - // cq3dlcmskttpc[ktm] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%ikT%i", chrgs[ichg], imult, ikt),60,(imult>3)?((imult>6)?((imult>7)?0.6:0.4):0.25):0.15); - cq3dlcmskttpc[ktm] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%ikT%i", chrgs[ichg], imult, ikt),60,0.5); - cq3dlcmskttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); - anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]); - } - } - } - - cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),39, 39); - anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]); - - Manager->AddAnalysis(anetaphitpc[aniter]); - } - } - } - } - // *** End pion-pion analysis - - return Manager; -} - + +/********************************************************************* + * * + * ConfigFemtoAnalysis.C - configuration macro for the femtoscopic * + * analysis, meant as a QA process for two-particle effects * + * * + * Author: Adam Kisiel (Adam.Kisiel@cern.ch) * + * * + *********************************************************************/ + +#if !defined(__CINT__) || defined(__MAKECINT_) +#include "AliFemtoManager.h" +#include "AliFemtoEventReaderESDChain.h" +#include "AliFemtoEventReaderESDChainKine.h" +#include "AliFemtoEventReaderAODChain.h" +#include "AliFemtoSimpleAnalysis.h" +#include "AliFemtoBasicEventCut.h" +#include "AliFemtoESDTrackCut.h" +#include "AliFemtoKKTrackCut.h" +#include "AliFemtoCorrFctn.h" +#include "AliFemtoCutMonitorParticleYPt.h" +#include "AliFemtoCutMonitorParticleVertPos.h" +#include "AliFemtoCutMonitorParticleMomRes.h" +#include "AliFemtoCutMonitorParticlePID.h" +#include "AliFemtoCutMonitorEventMult.h" +#include "AliFemtoCutMonitorEventVertex.h" +#include "AliFemtoShareQualityTPCEntranceSepPairCut.h" +#include "AliFemtoPairCutAntiGamma.h" +#include "AliFemtoPairCutRadialDistance.h" +#include "AliFemtoQinvCorrFctn.h" +#include "AliFemtoShareQualityCorrFctn.h" +#include "AliFemtoTPCInnerCorrFctn.h" +#include "AliFemtoVertexMultAnalysis.h" +#include "AliFemtoCorrFctn3DSpherical.h" +#include "AliFemtoChi2CorrFctn.h" +#include "AliFemtoCorrFctnTPCNcls.h" +#include "AliFemtoBPLCMS3DCorrFctn.h" +#include "AliFemtoCorrFctn3DLCMSSym.h" +#include "AliFemtoModelBPLCMSCorrFctn.h" +#include "AliFemtoModelCorrFctn3DSpherical.h" +#include "AliFemtoModelGausLCMSFreezeOutGenerator.h" +#include "AliFemtoModelGausRinvFreezeOutGenerator.h" +#include "AliFemtoModelManager.h" +#include "AliFemtoModelWeightGeneratorBasic.h" +#include "AliFemtoModelWeightGeneratorLednicky.h" +#include "AliFemtoCorrFctnDirectYlm.h" +#include "AliFemtoModelCorrFctnDirectYlm.h" +#include "AliFemtoModelCorrFctnSource.h" +#include "AliFemtoCutMonitorParticlePtPDG.h" +#include "AliFemtoKTPairCut.h" +#include "AliFemtoCutMonitorCollections.h" +#endif + +//________________________________________________________________________ +AliFemtoManager* ConfigFemtoAnalysis() { + + double PionMass = 0.13956995; + double KaonMass = 0.493677; + + //multiplicity bins + //int runmults[10] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0}; + //int multbins[11] = {0.01, 200, 400, 600, 1000, 950, 500, 600, 700, 800, 900}; + //int runmults[3] = {1, 1, 1}; + //int multbins[4] = {0.01, 200, 400, 900}; + int runmults[3] = {1, 0, 0}; + int multbins[4] = {0.01, 50, 100, 900}; + + int runch[2] = {1, 1}; + //const char *chrgs[2] = { "pip", "pim" }; + const char *chrgs[2] = { "Kp", "Km"}; + + int runktdep = 1; + //double ktrng[8] = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0}; + //double ktrng[3] = {0.2, 0.5, 1.0}; + //double ktrng[3] = {0.2, 0.5, 1.0}; + double ktrng[2] = {0.2, 0.36}; + + int run3d = 1; // Do 3D cartesian analysis? + //int runshlcms = 1; + int runshlcms = 0; + + //PhysicsSelection set only in runBatch with trigger + Physics Selection Task + + + double shqmax; + int nbinssh = 200; + //int nbinssh = 100; + + //if (runshlcms) shqmax = 2.0; + if (runshlcms) shqmax = 0.25; + //else shqmax = 0.9; + else shqmax = 2.0; + + AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain(); + Reader->SetFilterBit(0); + Reader->SetCentralityPreSelection(0.01, 900); + + //AliFemtoEventReaderESDChainKine* Reader=new AliFemtoEventReaderESDChainKine(); + //Reader->SetConstrained(true); + // Reader->SetUseTPCOnly(false); + + // AliFemtoEventReaderESDChain *Reader = new AliFemtoEventReaderESDChain(); + // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality); + // Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kGlobal); + + + AliFemtoManager* Manager=new AliFemtoManager(); + Manager->SetEventReader(Reader); + + AliFemtoVertexMultAnalysis *anetaphitpc[20]; + AliFemtoBasicEventCut *mecetaphitpc[20]; + AliFemtoCutMonitorEventMult *cutPassEvMetaphitpc[20]; + AliFemtoCutMonitorEventMult *cutFailEvMetaphitpc[20]; + AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[20]; + AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[20]; + AliFemtoCutMonitorCollections *cutPassColletaphitpc[20]; + AliFemtoCutMonitorCollections *cutFailColletaphitpc[20]; + AliFemtoKKTrackCut *dtc1etaphitpc[20]; + AliFemtoKKTrackCut *dtc2etaphitpc[20]; + //AliFemtoESDTrackCut *dtc1etaphitpc[20]; + //AliFemtoESDTrackCut *dtc2etaphitpc[20]; + AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[20]; + AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[20]; + AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[20]; + AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[20]; + AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[20]; + AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[20]; + AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[20]; + AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[20]; + // AliFemtoPairCutAntiGamma *sqpcetaphitpc[20]; + AliFemtoShareQualityPairCut *sqpcetaphitpc[20]; + //AliFemtoPairCutRadialDistance *sqpcetaphitpc[20]; + AliFemtoCorrFctnDirectYlm *cylmetaphitpc[20]; + AliFemtoCorrFctnDEtaDPhi *cdedpetaphi[20]; + AliFemtoChi2CorrFctn *cchiqinvetaphitpc[20]; + //AliFemtoKTPairCut *ktpcuts[20*7]; + //AliFemtoCorrFctnDirectYlm *cylmkttpc[20*7]; + //AliFemtoQinvCorrFctn *cqinvkttpc[20*7]; + //AliFemtoCorrFctn3DLCMSSym *cq3dlcmskttpc[20*7]; + AliFemtoKTPairCut *ktpcuts[20*8]; + AliFemtoCorrFctnDirectYlm *cylmkttpc[20*8]; + AliFemtoQinvCorrFctn *cqinvkttpc[20*8]; + AliFemtoCorrFctn3DLCMSSym *cq3dlcmskttpc[20*8]; + AliFemtoCorrFctnTPCNcls *cqinvnclstpc[20]; + AliFemtoShareQualityCorrFctn *cqinvsqtpc[20*10]; + AliFemtoChi2CorrFctn *cqinvchi2tpc[20]; + AliFemtoTPCInnerCorrFctn *cqinvinnertpc[20*10]; + + // *** Begin pion-pion analysis *** + int aniter = 0; + + for (int imult=0; imult<3; imult++) { + if (runmults[imult]) { + for (int ichg=0; ichg<2; ichg++) { + if (runch[ichg]) { + aniter = ichg*3+imult; + + anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(10, -10.0, 10.0, 4, multbins[imult], multbins[imult+1]); + anetaphitpc[aniter]->SetNumEventsToMix(5); + anetaphitpc[aniter]->SetMinSizePartCollection(1); + + mecetaphitpc[aniter] = new AliFemtoBasicEventCut(); + mecetaphitpc[aniter]->SetEventMult(0,10000); + mecetaphitpc[aniter]->SetVertZPos(-10,10); + + //cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult)); + //cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult)); + + cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult),500); + cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult),500); + + mecetaphitpc[aniter]->AddCutMonitor(cutPassEvMetaphitpc[aniter], cutFailEvMetaphitpc[aniter]); + + cutPassEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutPass%stpcM%i", chrgs[ichg], imult)); + cutFailEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutFail%stpcM%i", chrgs[ichg], imult)); + mecetaphitpc[aniter]->AddCutMonitor(cutPassEvVetaphitpc[aniter], cutFailEvVetaphitpc[aniter]); + + cutPassColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutPass%stpcM%i", chrgs[ichg], imult)); + cutFailColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutFail%stpcM%i", chrgs[ichg], imult)); + mecetaphitpc[aniter]->AddCutMonitor(cutPassColletaphitpc[aniter], cutFailColletaphitpc[aniter]); + + //dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut(); + dtc1etaphitpc[aniter] = new AliFemtoKKTrackCut(); + + if (ichg == 0) + dtc1etaphitpc[aniter]->SetCharge(1.0); + else if (ichg == 1) + dtc1etaphitpc[aniter]->SetCharge(-1.0); + + dtc1etaphitpc[aniter]->SetPt(0.14,1.5); + dtc1etaphitpc[aniter]->SetRapidity(-0.5,0.5); + //dtc1etaphitpc[aniter]->SetPt(0.14,1.5); + //dtc1etaphitpc[aniter]->SetEta(-0.8,0.8); + + //PID method + //dtc1etaphitpc[aniter]->SetMass(PionMass); + //dtc1etaphitpc[aniter]->SetMostProbablePion(); + dtc1etaphitpc[aniter]->SetMass(KaonMass); + dtc1etaphitpc[aniter]->SetMostProbableKaon(); + //dtc1etaphitpc[aniter]->SetPIDMethod(AliFemtoESDTrackCut::kContour); + + //Track quality cuts + dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit); + dtc1etaphitpc[aniter]->SetminTPCncls(50); + dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE); + + + dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0); + dtc1etaphitpc[aniter]->SetMaxITSChiNdof(36); + dtc1etaphitpc[aniter]->SetLabel(kFALSE); + + //primary particles: hits in ITS + DCA cut + //dtc1etaphitpc[aniter]->SetClusterRequirementITS(AliESDtrackCuts::kSPD, + // AliESDtrackCuts::kAny); + dtc1etaphitpc[aniter]->SetMaxImpactZ(2.0); + //dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); + dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0105, 0.0350, -1.1); + //dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01); + //dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0); + + //cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%i", chrgs[ichg], imult), 0.13957); + //cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%i", chrgs[ichg], imult), 0.13957); + cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%i", chrgs[ichg], imult), 0.493677); + cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%i", chrgs[ichg], imult), 0.493677); + dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]); + + //cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%i", chrgs[ichg], imult),0); + //cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%i", chrgs[ichg], imult),0); + cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%i", chrgs[ichg], imult),1); + cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%i", chrgs[ichg], imult),1); + dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]); + + //sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma(); + sqpcetaphitpc[aniter] = new AliFemtoShareQualityPairCut(); + //sqpcetaphitpc[aniter] = new AliFemtoShareQualityTPCEntranceSepPairCut(); + //sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance(); + sqpcetaphitpc[aniter]->SetShareQualityMax(1.0); + sqpcetaphitpc[aniter]->SetShareFractionMax(0.05); + sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE); + //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016); + //sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.02); + //runtype==0 + // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0); + // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0); + // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5); + // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); + // sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03); + //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); + //runtype==1 + // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0); + // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); + //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03); + //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); + //runtype==2 + // sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.0); + // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); + //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.045); + //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016); + //sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.02); + + anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]); + anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]); + anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]); + anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]); + + //Correlation functions + + //Spherical harmonics (without kT bins) + //cylmetaphitpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),3,nbinssh,0.0,shqmax,runshlcms); + //anetaphitpc[aniter]->AddCorrFctn(cylmetaphitpc[aniter]); + + //Qinv (without kT bins) + cqinvkttpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); + anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[aniter]); + + //3D cartesian (without kT bins) + if(run3d){ + //cq3dlcmskttpc[aniter] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%i", chrgs[ichg], imult),60,0.5); + cq3dlcmskttpc[aniter] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%i", chrgs[ichg], imult),100,0.5); + anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[aniter]); + } + + // cqinvnclstpc[aniter] = new AliFemtoCorrFctnTPCNcls(Form("cqinvncls%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); + // anetaphitpc[aniter]->AddCorrFctn(cqinvnclstpc[aniter]); + + // cqinvchi2tpc[aniter] = new AliFemtoChi2CorrFctn(Form("cqinvchi2%stpcM%i", chrgs[ichg], imult),nbinssh,0.0,shqmax); + // anetaphitpc[aniter]->AddCorrFctn(cqinvchi2tpc[aniter]); + + if (runktdep) { + int ktm; + for (int ikt=0; ikt<2; ikt++) { + ktm = aniter*2 + ikt; + ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]); + + //cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%ikT%i", chrgs[ichg], imult, ikt),3, + // nbinssh, 0.0, shqmax, runshlcms); + //cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); + //anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]); + + cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0, shqmax); + cqinvkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); + anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[ktm]); + + cqinvsqtpc[ktm] = new AliFemtoShareQualityCorrFctn(Form("cqinvsq%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,shqmax); + cqinvsqtpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); + anetaphitpc[aniter]->AddCorrFctn(cqinvsqtpc[ktm]); + + cqinvinnertpc[ktm] = new AliFemtoTPCInnerCorrFctn(Form("cqinvinner%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,shqmax); + cqinvinnertpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); + cqinvinnertpc[ktm]->SetRadius(1.2); + anetaphitpc[aniter]->AddCorrFctn(cqinvinnertpc[ktm]); + + if (run3d) { + // cq3dlcmskttpc[ktm] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%ikT%i", chrgs[ichg], imult, ikt),60,(imult>3)?((imult>6)?((imult>7)?0.6:0.4):0.25):0.15); + cq3dlcmskttpc[ktm] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%ikT%i", chrgs[ichg], imult, ikt),60,0.5); + cq3dlcmskttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); + anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]); + } + } + } + + cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),39, 39); + anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]); + + Manager->AddAnalysis(anetaphitpc[aniter]); + } + } + } + } + // *** End pion-pion analysis + + return Manager; +} + diff --git a/PWGCF/FLOW/macros/AddTaskFlowCascade.C b/PWGCF/FLOW/macros/AddTaskFlowCascade.C index 9b6837e2588..72de9397b89 100644 --- a/PWGCF/FLOW/macros/AddTaskFlowCascade.C +++ b/PWGCF/FLOW/macros/AddTaskFlowCascade.C @@ -1,222 +1,222 @@ -void AddTaskFlowCascade(int trigger, int centrMin, int centrMax, int cut=1, int harmonic=2) { - AddTaskFlowCascade(trigger, centrMin, centrMax, "Xi", - Form("Xi%d%dcut%d", centrMin, centrMax, cut), 0, cut, "V0M", "VZESP", harmonic); - - AddTaskFlowCascade(trigger, centrMin, centrMax, "Omega", - Form("Omega%d%dcut%d", centrMin,centrMax, cut), 1, cut, "V0M", "VZESP", harmonic); -} - -void AddTaskFlowCascade(int trigger, float centrMin, float centrMax, - TString folderName="myFolder", TString suffixName="mySuffix", - int specie=0, int cuts=1, char* MULT="V0M", - TString method="VZESP QC TPCSP", int harmonic=2) { - TString fileName = AliAnalysisManager::GetCommonFileName(); - // fileName.ReplaceAll(".root",""); - - //-E-V-E-N-T- -c-u-t-s-------------------------------------------------------- - AliFlowEventCuts* cutsEvent = new AliFlowEventCuts(Form("event_cuts_%s",suffixName.Data())); - cutsEvent->SetCentralityPercentileRange(centrMin,centrMax); - if(MULT=="V0M") - cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0); - else - cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kTPConly); - cutsEvent->SetRefMultMethod(AliFlowEventCuts::kSPDtracklets); - cutsEvent->SetNContributorsRange(2); - cutsEvent->SetPrimaryVertexZrange(-10.,+10.); - - //-R-P---c-u-t-s-------------------------------------------------------------- - AliFlowTrackCuts *cutsRPTPC - = AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts(); - cutsRPTPC->SetParamType( AliFlowTrackCuts::kGlobal ); - cutsRPTPC->SetAODfilterBit(1); // for AOD compatibility - - AliFlowTrackCuts *cutsRPVZE = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts(); - // AliFlowTrackCuts* trkCuts = new AliFlowTrackCuts(); - //AliFlowTrackCuts *cutsRPVZE = trkCuts->GetStandardVZEROOnlyTrackCuts(); - cutsRPVZE->SetApplyRecentering(kTRUE); - - //-D-A-U-G-H-T-E-R-S---c-u-t-s------------------------------------------------ - // AliESDtrackCuts* cutsDaughter - // = new AliESDtrackCuts(Form("daughter_cuts_%s",suffixName.Data()) ); - AliFlowTrackCuts * cutsDaughter - = new AliFlowTrackCuts(Form("daughter_cuts_%s",suffixName.Data())); - cutsDaughter->SetPtRange(0.15,10.0); - cutsDaughter->SetEtaRange(-0.8, 0.8 ); - cutsDaughter->SetMinNClustersTPC(70); - cutsDaughter->SetMaxChi2PerClusterTPC(4.0); - cutsDaughter->SetRequireTPCRefit(kTRUE); - cutsDaughter->SetAcceptKinkDaughters(kFALSE); - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); - - //-----------------Cascade TASK---------------------------- - AliAnalysisTaskFlowCascade *taskSel - = new AliAnalysisTaskFlowCascade(Form("Cascade_%s",suffixName.Data()), - cutsEvent, cutsRPTPC, cutsRPVZE, - cutsDaughter ); - taskSel->SelectCollisionCandidates(trigger); - //taskSel->SetDebug(); - taskSel->SetCuts2010(cuts); - taskSel->SetSpecie(specie); - //printf( "CMM %d %f %f\n", MassBins(specie), MinMass(specie), MSFT_MaxMass(specie) ); - taskSel->SetCommonConstants( MSFT_MassBins(specie), MSFT_MinMass(specie), MSFT_MaxMass(specie) ); - AliAnalysisDataContainer *cOutHist - = mgr->CreateContainer(Form("OutHistos_%s",suffixName.Data()), - TList::Class(), - AliAnalysisManager::kOutputContainer, - Form("%s:Selector_%s",fileName.Data(), - folderName.Data())); - AliAnalysisDataContainer *exc_TPC - = mgr->CreateContainer( Form("TPCEventWithCandidates_%s",suffixName.Data()), - AliFlowEventSimple::Class(), - AliAnalysisManager::kExchangeContainer ); - AliAnalysisDataContainer *exc_VZE - = mgr->CreateContainer( Form("VZEEventWithCandidates_%s",suffixName.Data()), - AliFlowEventSimple::Class(), - AliAnalysisManager::kExchangeContainer ); - mgr->AddTask(taskSel); - mgr->ConnectInput (taskSel, 0, cinput1); - mgr->ConnectOutput(taskSel, 1, exc_TPC); - mgr->ConnectOutput(taskSel, 2, exc_VZE); - mgr->ConnectOutput(taskSel, 3, cOutHist); - - //-------------------FLOW TASKS---------------------------- - AliFlowTrackSimpleCuts *filter[15], *filterhf[15][2]; // MASS BANDS - for(int mb=0; mb!=MSFT_MassBands(0); ++mb) { - filter[mb] = new AliFlowTrackSimpleCuts( Form("Filter_MB%d",mb) ); - filter[mb]->SetEtaMin( -0.8 ); - filter[mb]->SetEtaMax( +0.8 ); - filter[mb]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); - filter[mb]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); - - filterhf[mb][0] = new AliFlowTrackSimpleCuts( Form("Filterhf0_MB%d",mb) ); - filterhf[mb][0]->SetEtaMin( 0.0 ); - filterhf[mb][0]->SetEtaMax( +0.8 ); - filterhf[mb][0]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); - filterhf[mb][0]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); - - filterhf[mb][1] = new AliFlowTrackSimpleCuts( Form("Filterhf1_MB%d",mb) ); - filterhf[mb][1]->SetEtaMin( -0.8 ); - filterhf[mb][1]->SetEtaMax( 0.0 ); - filterhf[mb][1]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); - filterhf[mb][1]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); - - if(method.Contains("QC")) - MSFT_AddQCmethod( Form("QCTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, - exc_TPC, filter[mb]); // QC TPC - if(method.Contains("TPCSP")){ - MSFT_AddSPmethod( Form("SPTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, - exc_TPC, filterhf[mb][0], "Qa" ); // SP TPC Qa - MSFT_AddSPmethod( Form("SPTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, - exc_TPC, filterhf[mb][1], "Qb" ); // SP TPC Qb - } - if(method.Contains("VZESP")){ - MSFT_AddSPmethod( Form("SPVZEMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, - exc_VZE, filter[mb], "Qa" ); // SP VZE Qa - MSFT_AddSPmethod( Form("SPVZEMB%d",mb), folderName.Data(), suffixName.Data(), harmonic, - exc_VZE, filter[mb], "Qb" ); // SP VZE Qa - MSFT_AddSPmethod( Form("SPVZEMB%d",mb), folderName.Data(), suffixName.Data(), harmonic, - exc_VZE, filter[mb], "QaQb" ); // SP VZE QaQb - } - } -} - -void MSFT_AddQCmethod(char *name, TString myFolder, char *thecuts, int harmonic, - AliAnalysisDataContainer *flowEvent, - AliFlowTrackSimpleCuts *cutsPOI=NULL) { - TString fileName = AliAnalysisManager::GetCommonFileName(); - myFolder.Append( Form("v%d",harmonic) ); - TString myName = Form("%sv%d_%s", name, harmonic, thecuts); - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEvent2 - = mgr->CreateContainer( Form("Filter_%s", myName.Data()), - AliFlowEventSimple::Class(), - AliAnalysisManager::kExchangeContainer ); - AliAnalysisTaskFilterFE *tskFilter - = new AliAnalysisTaskFilterFE( Form("TaskFilter_%s",myName.Data()), - NULL, cutsPOI); - mgr->AddTask(tskFilter); - mgr->ConnectInput( tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEvent2); - - AliAnalysisDataContainer *outQC - = mgr->CreateContainer( myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, - Form("%s:FlowCascade_QC_%s", fileName.Data(), myFolder.Data()) ); - AliAnalysisTaskQCumulants *tskQC - = new AliAnalysisTaskQCumulants( Form("TaskQCumulants_%s",myName.Data()),kFALSE ); - tskQC->SetApplyCorrectionForNUA(kTRUE); - tskQC->SetHarmonic(harmonic); - tskQC->SetBookOnlyBasicCCH(kTRUE); - mgr->AddTask(tskQC); - mgr->ConnectInput( tskQC, 0, flowEvent2); - mgr->ConnectOutput(tskQC, 1, outQC); -} - - -void MSFT_AddSPmethod(char *name, TString myFolder, char *thecuts, int harmonic, - AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI=NULL, - char *Qvector) { - TString fileName = AliAnalysisManager::GetCommonFileName(); - myFolder.Append( Form("v%d",harmonic) ); - TString myNameSP = Form("%sv%d%s_%s", name, harmonic, Qvector, thecuts); - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEvent2 - = mgr->CreateContainer( Form("Filter_%s", myNameSP.Data()), - AliFlowEventSimple::Class(), - AliAnalysisManager::kExchangeContainer ); - AliAnalysisTaskFilterFE *tskFilter - = new AliAnalysisTaskFilterFE( Form("TaskFilter_%s",myNameSP.Data()), - NULL, cutsPOI); - tskFilter->SetSubeventEtaRange( -5.0, -1.0, 1.0, +5.0 ); - mgr->AddTask(tskFilter); - mgr->ConnectInput( tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEvent2); - AliAnalysisDataContainer *outSP - = mgr->CreateContainer( myNameSP.Data(),TList::Class(),AliAnalysisManager::kOutputContainer, - Form("%s:FlowCascade_SP_%s",fileName.Data(),myFolder.Data()) ); - AliAnalysisTaskScalarProduct *tskSP - = new AliAnalysisTaskScalarProduct( Form("TaskScalarProduct_%s",myNameSP.Data()),kFALSE); - tskSP->SetApplyCorrectionForNUA(kTRUE); - tskSP->SetHarmonic(harmonic); - tskSP->SetTotalQvector(Qvector); - tskSP->SetBookOnlyBasicCCH(kTRUE); - mgr->AddTask(tskSP); - mgr->ConnectInput( tskSP,0,flowEvent2); - mgr->ConnectOutput(tskSP,1,outSP); -} - -double MSFT_MassBandLowEdge( int nv0, int mb ) { - if(nv0==0) { - double lowEdge[15+1]={ 1.282, 1.292, 1.302, 1.312, 1.317, 1.319, 1.321, 1.322, - 1.323, 1.325, 1.327, 1.332, 1.342, 1.352, 1.362, 1.372}; - } if(nv0==1) { - double lowEdge[15+1]={ 1.632, 1.642, 1.652, 1.662, 1.667, 1.669, 1.671, 1.672, - 1.673, 1.675, 1.677, 1.682, 1.692, 1.702, 1.712, 1.722 }; - } - return lowEdge[mb]; -} - -int MSFT_MassBands( int nv0 ) { - if(nv0==0) { - return 15; - } else if(nv0==1) { - return 15; - } -} - -int MSFT_MassBins( int nv0 ) { - if(nv0==0) { - return 90; - } else if(nv0==1) { - return 90; - } -} - -double MSFT_MinMass( int nv0 ) { - return MSFT_MassBandLowEdge( nv0, 0 ); -} - -double MSFT_MaxMass( int nv0 ) { - return MSFT_MassBandLowEdge( nv0, MSFT_MassBands(nv0) ); -} +void AddTaskFlowCascade(int trigger, int centrMin, int centrMax, int cut=1, int harmonic=2) { + AddTaskFlowCascade(trigger, centrMin, centrMax, "Xi", + Form("Xi%d%dcut%d", centrMin, centrMax, cut), 0, cut, "V0M", "VZESP", harmonic); + + AddTaskFlowCascade(trigger, centrMin, centrMax, "Omega", + Form("Omega%d%dcut%d", centrMin,centrMax, cut), 1, cut, "V0M", "VZESP", harmonic); +} + +void AddTaskFlowCascade(int trigger, float centrMin, float centrMax, + TString folderName="myFolder", TString suffixName="mySuffix", + int specie=0, int cuts=1, char* MULT="V0M", + TString method="VZESP QC TPCSP", int harmonic=2) { + TString fileName = AliAnalysisManager::GetCommonFileName(); + // fileName.ReplaceAll(".root",""); + + //-E-V-E-N-T- -c-u-t-s-------------------------------------------------------- + AliFlowEventCuts* cutsEvent = new AliFlowEventCuts(Form("event_cuts_%s",suffixName.Data())); + cutsEvent->SetCentralityPercentileRange(centrMin,centrMax); + if(MULT=="V0M") + cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0); + else + cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kTPConly); + cutsEvent->SetRefMultMethod(AliFlowEventCuts::kSPDtracklets); + cutsEvent->SetNContributorsRange(2); + cutsEvent->SetPrimaryVertexZrange(-10.,+10.); + + //-R-P---c-u-t-s-------------------------------------------------------------- + AliFlowTrackCuts *cutsRPTPC + = AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts(); + cutsRPTPC->SetParamType( AliFlowTrackCuts::kGlobal ); + cutsRPTPC->SetAODfilterBit(1); // for AOD compatibility + + AliFlowTrackCuts *cutsRPVZE = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts(); + // AliFlowTrackCuts* trkCuts = new AliFlowTrackCuts(); + //AliFlowTrackCuts *cutsRPVZE = trkCuts->GetStandardVZEROOnlyTrackCuts(); + cutsRPVZE->SetApplyRecentering(kTRUE); + + //-D-A-U-G-H-T-E-R-S---c-u-t-s------------------------------------------------ + // AliESDtrackCuts* cutsDaughter + // = new AliESDtrackCuts(Form("daughter_cuts_%s",suffixName.Data()) ); + AliFlowTrackCuts * cutsDaughter + = new AliFlowTrackCuts(Form("daughter_cuts_%s",suffixName.Data())); + cutsDaughter->SetPtRange(0.15,10.0); + cutsDaughter->SetEtaRange(-0.8, 0.8 ); + cutsDaughter->SetMinNClustersTPC(70); + cutsDaughter->SetMaxChi2PerClusterTPC(4.0); + cutsDaughter->SetRequireTPCRefit(kTRUE); + cutsDaughter->SetAcceptKinkDaughters(kFALSE); + + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); + + //-----------------Cascade TASK---------------------------- + AliAnalysisTaskFlowCascade *taskSel + = new AliAnalysisTaskFlowCascade(Form("Cascade_%s",suffixName.Data()), + cutsEvent, cutsRPTPC, cutsRPVZE, + cutsDaughter ); + taskSel->SelectCollisionCandidates(trigger); + //taskSel->SetDebug(); + taskSel->SetCuts2010(cuts); + taskSel->SetSpecie(specie); + //printf( "CMM %d %f %f\n", MassBins(specie), MinMass(specie), MSFT_MaxMass(specie) ); + taskSel->SetCommonConstants( MSFT_MassBins(specie), MSFT_MinMass(specie), MSFT_MaxMass(specie) ); + AliAnalysisDataContainer *cOutHist + = mgr->CreateContainer(Form("OutHistos_%s",suffixName.Data()), + TList::Class(), + AliAnalysisManager::kOutputContainer, + Form("%s:Selector_%s",fileName.Data(), + folderName.Data())); + AliAnalysisDataContainer *exc_TPC + = mgr->CreateContainer( Form("TPCEventWithCandidates_%s",suffixName.Data()), + AliFlowEventSimple::Class(), + AliAnalysisManager::kExchangeContainer ); + AliAnalysisDataContainer *exc_VZE + = mgr->CreateContainer( Form("VZEEventWithCandidates_%s",suffixName.Data()), + AliFlowEventSimple::Class(), + AliAnalysisManager::kExchangeContainer ); + mgr->AddTask(taskSel); + mgr->ConnectInput (taskSel, 0, cinput1); + mgr->ConnectOutput(taskSel, 1, exc_TPC); + mgr->ConnectOutput(taskSel, 2, exc_VZE); + mgr->ConnectOutput(taskSel, 3, cOutHist); + + //-------------------FLOW TASKS---------------------------- + AliFlowTrackSimpleCuts *filter[15], *filterhf[15][2]; // MASS BANDS + for(int mb=0; mb!=MSFT_MassBands(0); ++mb) { + filter[mb] = new AliFlowTrackSimpleCuts( Form("Filter_MB%d",mb) ); + filter[mb]->SetEtaMin( -0.8 ); + filter[mb]->SetEtaMax( +0.8 ); + filter[mb]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); + filter[mb]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); + + filterhf[mb][0] = new AliFlowTrackSimpleCuts( Form("Filterhf0_MB%d",mb) ); + filterhf[mb][0]->SetEtaMin( 0.0 ); + filterhf[mb][0]->SetEtaMax( +0.8 ); + filterhf[mb][0]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); + filterhf[mb][0]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); + + filterhf[mb][1] = new AliFlowTrackSimpleCuts( Form("Filterhf1_MB%d",mb) ); + filterhf[mb][1]->SetEtaMin( -0.8 ); + filterhf[mb][1]->SetEtaMax( 0.0 ); + filterhf[mb][1]->SetMassMin( MSFT_MassBandLowEdge(specie, mb) ); + filterhf[mb][1]->SetMassMax( MSFT_MassBandLowEdge(specie, mb+1) ); + + if(method.Contains("QC")) + MSFT_AddQCmethod( Form("QCTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, + exc_TPC, filter[mb]); // QC TPC + if(method.Contains("TPCSP")){ + MSFT_AddSPmethod( Form("SPTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, + exc_TPC, filterhf[mb][0], "Qa" ); // SP TPC Qa + MSFT_AddSPmethod( Form("SPTPCMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, + exc_TPC, filterhf[mb][1], "Qb" ); // SP TPC Qb + } + if(method.Contains("VZESP")){ + MSFT_AddSPmethod( Form("SPVZEMB%d", mb), folderName.Data(), suffixName.Data(), harmonic, + exc_VZE, filter[mb], "Qa" ); // SP VZE Qa + MSFT_AddSPmethod( Form("SPVZEMB%d",mb), folderName.Data(), suffixName.Data(), harmonic, + exc_VZE, filter[mb], "Qb" ); // SP VZE Qa + MSFT_AddSPmethod( Form("SPVZEMB%d",mb), folderName.Data(), suffixName.Data(), harmonic, + exc_VZE, filter[mb], "QaQb" ); // SP VZE QaQb + } + } +} + +void MSFT_AddQCmethod(char *name, TString myFolder, char *thecuts, int harmonic, + AliAnalysisDataContainer *flowEvent, + AliFlowTrackSimpleCuts *cutsPOI=NULL) { + TString fileName = AliAnalysisManager::GetCommonFileName(); + myFolder.Append( Form("v%d",harmonic) ); + TString myName = Form("%sv%d_%s", name, harmonic, thecuts); + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEvent2 + = mgr->CreateContainer( Form("Filter_%s", myName.Data()), + AliFlowEventSimple::Class(), + AliAnalysisManager::kExchangeContainer ); + AliAnalysisTaskFilterFE *tskFilter + = new AliAnalysisTaskFilterFE( Form("TaskFilter_%s",myName.Data()), + NULL, cutsPOI); + mgr->AddTask(tskFilter); + mgr->ConnectInput( tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEvent2); + + AliAnalysisDataContainer *outQC + = mgr->CreateContainer( myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, + Form("%s:FlowCascade_QC_%s", fileName.Data(), myFolder.Data()) ); + AliAnalysisTaskQCumulants *tskQC + = new AliAnalysisTaskQCumulants( Form("TaskQCumulants_%s",myName.Data()),kFALSE ); + tskQC->SetApplyCorrectionForNUA(kTRUE); + tskQC->SetHarmonic(harmonic); + tskQC->SetBookOnlyBasicCCH(kTRUE); + mgr->AddTask(tskQC); + mgr->ConnectInput( tskQC, 0, flowEvent2); + mgr->ConnectOutput(tskQC, 1, outQC); +} + + +void MSFT_AddSPmethod(char *name, TString myFolder, char *thecuts, int harmonic, + AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI=NULL, + char *Qvector) { + TString fileName = AliAnalysisManager::GetCommonFileName(); + myFolder.Append( Form("v%d",harmonic) ); + TString myNameSP = Form("%sv%d%s_%s", name, harmonic, Qvector, thecuts); + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEvent2 + = mgr->CreateContainer( Form("Filter_%s", myNameSP.Data()), + AliFlowEventSimple::Class(), + AliAnalysisManager::kExchangeContainer ); + AliAnalysisTaskFilterFE *tskFilter + = new AliAnalysisTaskFilterFE( Form("TaskFilter_%s",myNameSP.Data()), + NULL, cutsPOI); + tskFilter->SetSubeventEtaRange( -5.0, -1.0, 1.0, +5.0 ); + mgr->AddTask(tskFilter); + mgr->ConnectInput( tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEvent2); + AliAnalysisDataContainer *outSP + = mgr->CreateContainer( myNameSP.Data(),TList::Class(),AliAnalysisManager::kOutputContainer, + Form("%s:FlowCascade_SP_%s",fileName.Data(),myFolder.Data()) ); + AliAnalysisTaskScalarProduct *tskSP + = new AliAnalysisTaskScalarProduct( Form("TaskScalarProduct_%s",myNameSP.Data()),kFALSE); + tskSP->SetApplyCorrectionForNUA(kTRUE); + tskSP->SetHarmonic(harmonic); + tskSP->SetTotalQvector(Qvector); + tskSP->SetBookOnlyBasicCCH(kTRUE); + mgr->AddTask(tskSP); + mgr->ConnectInput( tskSP,0,flowEvent2); + mgr->ConnectOutput(tskSP,1,outSP); +} + +double MSFT_MassBandLowEdge( int nv0, int mb ) { + if(nv0==0) { + double lowEdge[15+1]={ 1.282, 1.292, 1.302, 1.312, 1.317, 1.319, 1.321, 1.322, + 1.323, 1.325, 1.327, 1.332, 1.342, 1.352, 1.362, 1.372}; + } if(nv0==1) { + double lowEdge[15+1]={ 1.632, 1.642, 1.652, 1.662, 1.667, 1.669, 1.671, 1.672, + 1.673, 1.675, 1.677, 1.682, 1.692, 1.702, 1.712, 1.722 }; + } + return lowEdge[mb]; +} + +int MSFT_MassBands( int nv0 ) { + if(nv0==0) { + return 15; + } else if(nv0==1) { + return 15; + } +} + +int MSFT_MassBins( int nv0 ) { + if(nv0==0) { + return 90; + } else if(nv0==1) { + return 90; + } +} + +double MSFT_MinMass( int nv0 ) { + return MSFT_MassBandLowEdge( nv0, 0 ); +} + +double MSFT_MaxMass( int nv0 ) { + return MSFT_MassBandLowEdge( nv0, MSFT_MassBands(nv0) ); +} diff --git a/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersPID.C b/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersPID.C index 1f5409acc59..139bcc51ec8 100644 --- a/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersPID.C +++ b/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersPID.C @@ -1,682 +1,682 @@ -///////////////////////////////////////////////////////////////////////////////////////////// -// -// AddTask* macro for flow analysis -// Creates a Flow Event task and adds it to the analysis manager. -// Sets the cuts using the correction framework (CORRFW) classes. -// Also creates Flow Analysis tasks and connects them to the output of the flow event task. -// -///////////////////////////////////////////////////////////////////////////////////////////// - -void AddTaskFlowHigherOrdersPID(Int_t centralitysel, - Float_t centrMin=0., - Float_t centrMax=100., - TString fileNameBase="output", - Bool_t isPID = kTRUE, - Int_t AODfilterBitRP = 768, - Int_t AODfilterBitPOI = 768, - AliPID::EParticleType particleType=AliPID::kPion, - AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFbayesian, - Int_t charge=0, - Int_t harmonic=3, - Bool_t doQA=kFALSE, - Float_t etamin=-0.8, - Float_t etamax=0.8, - TString uniqueStr="" ) -{ - // Define the range for eta subevents (for SP method) - Double_t minA = -0.9;// - Double_t maxA = -0.5;// - Double_t minB = 0.5;// - Double_t maxB = 0.9;// - - // AFTERBURNER - Bool_t useAfterBurner=kFALSE; - Double_t v1=0.0; - Double_t v2=0.0; - Double_t v3=0.0; - Double_t v4=0.0; - Int_t numberOfTrackClones=0; //non-flow - - // Define a range of the detector to exclude - Bool_t ExcludeRegion = kFALSE; - Double_t excludeEtaMin = -0.; - Double_t excludeEtaMax = 0.; - Double_t excludePhiMin = 0.; - Double_t excludePhiMax = 0.; - - // use physics selection class - Bool_t UsePhysicsSelection = kTRUE; - - // QA - Bool_t runQAtask=kFALSE; - Bool_t FillQAntuple=kFALSE; - Bool_t DoQAcorrelations=kFALSE; - - // RUN SETTINGS - // Flow analysis method can be:(set to kTRUE or kFALSE) - Bool_t SP = kTRUE; // scalar product method (similar to eventplane method) - Bool_t QC = kTRUE; // cumulants using Q vectors - - //these are OBSOLETE, use at own peril - Bool_t GFC = kFALSE; // cumulants based on generating function - Bool_t MCEP = kFALSE; // correlation with Monte Carlo reaction plane - Bool_t FQD = kFALSE; // fit of the distribution of the Q vector (only integrated v) - Bool_t LYZ1SUM = kFALSE; // Lee Yang Zeroes using sum generating function (integrated v) - Bool_t LYZ1PROD = kFALSE; // Lee Yang Zeroes using product generating function (integrated v) - Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v) - Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v) - Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight) - Bool_t MH = kFALSE; // azimuthal correlators in mixed harmonics - Bool_t NL = kFALSE; // nested loops (for instance distribution of phi1-phi2 for all distinct pairs) - - Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL}; - - // Boolean to use/not use weights for the Q vector - Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta) - - // SETTING THE CUTS - - //---------Data selection---------- - //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet - AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kTPCstandalone; - AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kTPCstandalone; - - //---------Parameter mixing-------- - //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt - AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure; - AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure; - - - const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype); - const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype); - - //=========================================================================== - // EVENTS CUTS: - AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts"); - cutsEvent->SetCentralityPercentileRange(centrMin,centrMax); - cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0); -// cutsEvent->SetRefMultMethod(AliFlowEventCuts::kVZERO); - //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets); - //cutsEvent->SetNContributorsRange(2); - cutsEvent->SetPrimaryVertexZrange(-10.,10.); - cutsEvent->SetQA(doQA); - cutsEvent->SetCutTPCmultiplicityOutliers(); - - // RP TRACK CUTS: -// AliFlowTrackCuts* cutsRP2 = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts(); - AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP"); - cutsRP->SetParamType(rptype); - cutsRP->SetParamMix(rpmix); - cutsRP->SetPtRange(0.2,5.); - cutsRP->SetEtaRange(etamin,etamax); - cutsRP->SetMinNClustersTPC(70); -// cutsRP->SetMinChi2PerClusterTPC(0.1);// - // cutsRP->SetMaxChi2PerClusterTPC(4.0);// - cutsRP->SetMaxDCAToVertexXY(3.0); - cutsRP->SetMaxDCAToVertexZ(3.0); - cutsRP->SetAcceptKinkDaughters(kFALSE); - cutsRP->SetMinimalTPCdedx(10.); - cutsRP->SetAODfilterBit(AODfilterBitRP); -// cutsRP->SetAODfilterBit(768); -cutsRP->SetQA(doQA); - - // POI TRACK CUTS: - AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("TPConlyPOI"); - cutsPOI->GetBayesianResponse()->ForceOldDedx(); // for 2010 data to use old TPC PID Response instead of the official one - cutsPOI->SetParamType(poitype); - cutsPOI->SetParamMix(poimix); - cutsPOI->SetPtRange(0.2,5.);// - cutsPOI->SetEtaRange(etamin,etamax); - //cutsPOI->SetRequireCharge(kTRUE); - //cutsPOI->SetPID(PdgRP); - cutsPOI->SetMinNClustersTPC(70); - // cutsPOI->SetMinChi2PerClusterTPC(0.1); // - // cutsPOI->SetMaxChi2PerClusterTPC(4.0); // -// cutsPOI->SetRequireITSRefit(kTRUE); -// cutsPOI->SetRequireTPCRefit(kTRUE); -// cutsPOI->SetMinNClustersITS(2); - //cutsPOI->SetMaxChi2PerClusterITS(1.e+09); - cutsPOI->SetMaxDCAToVertexXY(3.0); - cutsPOI->SetMaxDCAToVertexZ(3.0); - //cutsPOI->SetDCAToVertex2D(kTRUE); - //cutsPOI->SetMaxNsigmaToVertex(1.e+10); - //cutsPOI->SetRequireSigmaToVertex(kFALSE); - cutsPOI->SetAcceptKinkDaughters(kFALSE); - if(isPID) cutsPOI->SetPID(particleType, sourcePID);//particleType, sourcePID - if (charge!=0) cutsPOI->SetCharge(charge); - //cutsPOI->SetAllowTOFmismatch(kFALSE); - cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE); - //iexample: francesco's tunig TPC Bethe Bloch for data: - //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00); - //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49); - cutsPOI->SetMinimalTPCdedx(10.); - cutsPOI->SetAODfilterBit(AODfilterBitPOI); - // cutsPOI->SetAODfilterBit(768); - cutsPOI->SetQA(doQA); - cutsPOI->SetPriors((centrMin+centrMax)*0.5); // set priors and PID as a function of the centrality - -// Int_t sourcePID = 2; -// Int_t particleType = 2; //2 or 3 or 4 for kPion, kKaon and kProton - TString outputSlotName(""); - outputSlotName+=uniqueStr; - outputSlotName+=Form("QC(%i) ",harmonic); - outputSlotName+=cutsRP->GetName(); - outputSlotName+=" "; - outputSlotName+=cutsPOI->GetName(); - outputSlotName+=Form(" %.0f-",centrMin); - outputSlotName+=Form("%.0f ",centrMax); - if(isPID){ - outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);//sourcePID - outputSlotName+=" "; - outputSlotName+=AliPID::ParticleName(particleType);//particleType - } - else{ - outputSlotName+="AllCharged"; - } - if (charge<0) outputSlotName+="-"; - if (charge>0) outputSlotName+="+"; - - TString fileName(fileNameBase); - fileName.Append(".root"); - - Bool_t useWeights = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2]; - if (useWeights) cout<<"Weights are used"<GetInputEventHandler()) { - ::Error("AddTaskFlowEvent", "This task requires an input event handler"); - return NULL; - } - - // Open external input files - //=========================================================================== - //weights: - TFile *weightsFile = NULL; - TList *weightsList = NULL; - - if(useWeights) { - //open the file with the weights: - weightsFile = TFile::Open("weights.root","READ"); - if(weightsFile) { - //access the list which holds the histos with weigths: - weightsList = (TList*)weightsFile->Get("weights"); - } - else { - cout<<" WARNING: the file with weights from the previous run was not available."<pwd()); - pwd+="/"; - pwd+=outputFileName.Data(); - TFile *outputFile = NULL; - if(gSystem->AccessPathName(pwd.Data(),kFileExists)) { - cout<<"WARNING: You do not have an output file:"<FindObjectAny(inputFileNameLYZ2SUM.Data()); - if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { - cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; - break; - } - else { - TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM"); - if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<FindObjectAny(inputFileNameLYZ2PROD.Data()); - if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { - cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; - break; - } - else { - TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD"); - if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<pwd()); - pwd+="/"; - pwd+=outputFileName.Data(); - TFile *outputFile = NULL; - if(gSystem->AccessPathName(pwd.Data(),kFileExists)) { - cout<<"WARNING: You do not have an output file:"<FindObjectAny(inputFileNameLYZEP.Data()); - if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { - cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; - break; - } - else { - TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM"); - if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<SelectCollisionCandidates(centralitysel); - mgr->AddTask(taskfmd); - - AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance(); - pars->Init(); - pars->SetProcessPrimary(kTRUE); //for MC only - pars->SetProcessHits(kFALSE); - - //pars->SetRealData(kTRUE); //for real data - //pars->SetProcessPrimary(kFALSE); //for real data - } - } - - // Create the flow event task, add it to the manager. - //=========================================================================== - AliAnalysisTaskFlowEvent *taskFE = NULL; - - if(useAfterBurner) - { - taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1); - taskFE->SetFlow(v1,v2,v3,v4); - taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones); - taskFE->SetAfterburnerOn(); - taskFE->SelectCollisionCandidates(centralitysel); - } - else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); - taskFE->SelectCollisionCandidates(centralitysel);} - if (ExcludeRegion) { - taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); - } - taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB); - if (UsePhysicsSelection) { - taskFE->SelectCollisionCandidates(AliVEvent::kMB); - cout<<"Using Physics Selection"<AddTask(taskFE); - - // Pass cuts for RPs and POIs to the task: - taskFE->SetCutsEvent(cutsEvent); - taskFE->SetCutsRP(cutsRP); - taskFE->SetCutsPOI(cutsPOI); - if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO) - { - //TODO: since this is set in a static object all analyses in an analysis train - //will be affected. - taskFE->SetHistWeightvsPhiMin(0.); - taskFE->SetHistWeightvsPhiMax(200.); - } - - // Create the analysis tasks, add them to the manager. - //=========================================================================== - if (SP){ - AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]); - taskSP->SelectCollisionCandidates(centralitysel); - taskSP->SetRelDiffMsub(1.0); - taskSP->SetApplyCorrectionForNUA(kTRUE); - mgr->AddTask(taskSP); - } - if (LYZ1SUM){ - AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE); - taskLYZ1SUM->SelectCollisionCandidates(centralitysel); - taskLYZ1SUM->SetFirstRunLYZ(kTRUE); - taskLYZ1SUM->SetUseSumLYZ(kTRUE); - mgr->AddTask(taskLYZ1SUM); - } - if (LYZ1PROD){ - AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE); - taskLYZ1PROD->SelectCollisionCandidates(centralitysel); - taskLYZ1PROD->SetFirstRunLYZ(kTRUE); - taskLYZ1PROD->SetUseSumLYZ(kFALSE); - mgr->AddTask(taskLYZ1PROD); - } - if (LYZ2SUM){ - AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE); - taskLYZ2SUM->SelectCollisionCandidates(centralitysel); - taskLYZ2SUM->SetFirstRunLYZ(kFALSE); - taskLYZ2SUM->SetUseSumLYZ(kTRUE); - mgr->AddTask(taskLYZ2SUM); - } - if (LYZ2PROD){ - AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE); - taskLYZ2PROD->SelectCollisionCandidates(centralitysel); - taskLYZ2PROD->SetFirstRunLYZ(kFALSE); - taskLYZ2PROD->SetUseSumLYZ(kFALSE); - mgr->AddTask(taskLYZ2PROD); - } - if (LYZEP){ - AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data())); - taskLYZEP->SelectCollisionCandidates(centralitysel); - mgr->AddTask(taskLYZEP); - } - if (GFC){ - AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights); - taskGFC->SelectCollisionCandidates(centralitysel); - taskGFC->SetUsePhiWeights(WEIGHTS[0]); - taskGFC->SetUsePtWeights(WEIGHTS[1]); - taskGFC->SetUseEtaWeights(WEIGHTS[2]); - mgr->AddTask(taskGFC); - } - if (QC){ - AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights); - taskQC->SelectCollisionCandidates(centralitysel); - taskQC->SetUsePhiWeights(WEIGHTS[0]); - taskQC->SetUsePtWeights(WEIGHTS[1]); - taskQC->SetUseEtaWeights(WEIGHTS[2]); - taskQC->SetCalculateCumulantsVsM(kFALSE); - taskQC->SetnBinsMult(10000); - taskQC->SetMinMult(0.); - taskQC->SetMaxMult(10000.); - taskQC->SetHarmonic(harmonic); - taskQC->SetApplyCorrectionForNUA(kFALSE); - taskQC->SetFillMultipleControlHistograms(kFALSE); - mgr->AddTask(taskQC); - } - if (FQD){ - AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE); - taskFQD->SelectCollisionCandidates(centralitysel); - taskFQD->SetUsePhiWeights(WEIGHTS[0]); - taskFQD->SetqMin(0.); - taskFQD->SetqMax(1000.); - taskFQD->SetqNbins(10000); - mgr->AddTask(taskFQD); - } - if (MCEP){ - AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data())); - taskMCEP->SelectCollisionCandidates(centralitysel); - mgr->AddTask(taskMCEP); - } - if (MH){ - AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights); - taskMH->SelectCollisionCandidates(centralitysel); - taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)] - taskMH->SetNoOfMultipicityBins(10000); - taskMH->SetMultipicityBinWidth(1.); - taskMH->SetMinMultiplicity(1.); - taskMH->SetCorrectForDetectorEffects(kTRUE); - taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <> (Remark: two nested loops) - taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges - mgr->AddTask(taskMH); - } - if (NL){ - AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights); - taskNL->SelectCollisionCandidates(centralitysel); - taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)] - taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution - taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <> (Remark: three nested loops) - taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <> (Remark: three nested loops) - taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges - mgr->AddTask(taskNL); - } - - // Create the output container for the data produced by the task - // Connect to the input and output containers - //=========================================================================== - AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); - - if (rptypestr == "FMD") { - AliAnalysisDataContainer *coutputFMD = - mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer); - //input and output taskFMD - mgr->ConnectInput(taskfmd, 0, cinput1); - mgr->ConnectOutput(taskfmd, 1, coutputFMD); - //input into taskFE - mgr->ConnectInput(taskFE,1,coutputFMD); - } - - AliAnalysisDataContainer *coutputFE = - mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); - mgr->ConnectInput(taskFE,0,cinput1); - mgr->ConnectOutput(taskFE,1,coutputFE); - - if (taskFE->GetQAOn()) - { - TString outputQA = fileName; - outputQA += ":QA"; - AliAnalysisDataContainer* coutputFEQA = - mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA); - mgr->ConnectOutput(taskFE,2,coutputFEQA); - } - - // Create the output containers for the data produced by the analysis tasks - // Connect to the input and output containers - //=========================================================================== - if (useWeights) { - AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kInputContainer); - } - - if(SP) { - TString outputSP = fileName; - outputSP += ":outputSPanalysis"; - outputSP+= rptypestr; - AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); - mgr->ConnectInput(taskSP,0,coutputFE); - mgr->ConnectOutput(taskSP,1,coutputSP); - if (WEIGHTS[0]) { - mgr->ConnectInput(taskSP,1,cinputWeights); - cinputWeights->SetData(weightsList); - } - } - if(LYZ1SUM) { - TString outputLYZ1SUM = fileName; - outputLYZ1SUM += ":outputLYZ1SUManalysis"; - outputLYZ1SUM+= rptypestr; - AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); - mgr->ConnectInput(taskLYZ1SUM,0,coutputFE); - mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM); - } - if(LYZ1PROD) { - TString outputLYZ1PROD = fileName; - outputLYZ1PROD += ":outputLYZ1PRODanalysis"; - outputLYZ1PROD+= rptypestr; - AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); - mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); - mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD); - } - if(LYZ2SUM) { - AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kInputContainer); - TString outputLYZ2SUM = fileName; - outputLYZ2SUM += ":outputLYZ2SUManalysis"; - outputLYZ2SUM+= rptypestr; - - AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); - mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); - mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM); - mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); - cinputLYZ2SUM->SetData(fInputListLYZ2SUM); - } - if(LYZ2PROD) { - AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kInputContainer); - TString outputLYZ2PROD = fileName; - outputLYZ2PROD += ":outputLYZ2PRODanalysis"; - outputLYZ2PROD+= rptypestr; - - AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); - mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); - mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD); - mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); - cinputLYZ2PROD->SetData(fInputListLYZ2PROD); - } - if(LYZEP) { - AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kInputContainer); - TString outputLYZEP = fileName; - outputLYZEP += ":outputLYZEPanalysis"; - outputLYZEP+= rptypestr; - - AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); - mgr->ConnectInput(taskLYZEP,0,coutputFE); - mgr->ConnectInput(taskLYZEP,1,cinputLYZEP); - mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); - cinputLYZEP->SetData(fInputListLYZEP); - } - if(GFC) { - TString outputGFC = fileName; - outputGFC += ":outputGFCanalysis"; - outputGFC+= rptypestr; - - AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); - mgr->ConnectInput(taskGFC,0,coutputFE); - mgr->ConnectOutput(taskGFC,1,coutputGFC); - if (useWeights) { - mgr->ConnectInput(taskGFC,1,cinputWeights); - cinputWeights->SetData(weightsList); - } - } - if(QC) { - TString outputQC = fileName; - outputQC += ":outputQCanalysis"; - outputQC+= rptypestr; - - AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); - mgr->ConnectInput(taskQC,0,coutputFE); - mgr->ConnectOutput(taskQC,1,coutputQC); - if (useWeights) { - mgr->ConnectInput(taskQC,1,cinputWeights); - cinputWeights->SetData(weightsList); - } - } - if(FQD) { - TString outputFQD = fileName; - outputFQD += ":outputFQDanalysis"; - outputFQD+= rptypestr; - - AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); - mgr->ConnectInput(taskFQD,0,coutputFE); - mgr->ConnectOutput(taskFQD,1,coutputFQD); - if(useWeights) { - mgr->ConnectInput(taskFQD,1,cinputWeights); - cinputWeights->SetData(weightsList); - } - } - if(MCEP) { - TString outputMCEP = fileName; - outputMCEP += ":outputMCEPanalysis"; - outputMCEP+= rptypestr; - - AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); - mgr->ConnectInput(taskMCEP,0,coutputFE); - mgr->ConnectOutput(taskMCEP,1,coutputMCEP); - } - if(MH) { - TString outputMH = fileName; - outputMH += ":outputMHanalysis"; - outputMH += rptypestr; - - AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); - mgr->ConnectInput(taskMH,0,coutputFE); - mgr->ConnectOutput(taskMH,1,coutputMH); - //if (useWeights) { - // mgr->ConnectInput(taskMH,1,cinputWeights); - // cinputWeights->SetData(weightsList); - //} - } - if(NL) { - TString outputNL = fileName; - outputNL += ":outputNLanalysis"; - outputNL += rptypestr; - - AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), - TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); - mgr->ConnectInput(taskNL,0,coutputFE); - mgr->ConnectOutput(taskNL,1,coutputNL); - //if (useWeights) { - // mgr->ConnectInput(taskNL,1,cinputWeights); - // cinputWeights->SetData(weightsList); - //} - } - - /////////////////////////////////////////////////////////////////////////////////////////// - if (runQAtask) - { - AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data())); - taskQAflow->SelectCollisionCandidates(centralitysel); - taskQAflow->SetEventCuts(cutsEvent); - taskQAflow->SetTrackCuts(cutsRP); - taskQAflow->SetFillNTuple(FillQAntuple); - taskQAflow->SetDoCorrelations(DoQAcorrelations); - mgr->AddTask(taskQAflow); - - Printf("outputSlotName %s",outputSlotName.Data()); - TString taskQAoutputFileName(fileNameBase); - taskQAoutputFileName.Append("_QA.root"); - AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()), - TObjArray::Class(), - AliAnalysisManager::kOutputContainer, - taskQAoutputFileName); - AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()), - TNtuple::Class(), - AliAnalysisManager::kOutputContainer, - taskQAoutputFileName); - mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer()); - mgr->ConnectInput(taskQAflow,1,coutputFE); - mgr->ConnectOutput(taskQAflow,1,coutputQAtask); - if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree); - } -} - - - - - +///////////////////////////////////////////////////////////////////////////////////////////// +// +// AddTask* macro for flow analysis +// Creates a Flow Event task and adds it to the analysis manager. +// Sets the cuts using the correction framework (CORRFW) classes. +// Also creates Flow Analysis tasks and connects them to the output of the flow event task. +// +///////////////////////////////////////////////////////////////////////////////////////////// + +void AddTaskFlowHigherOrdersPID(Int_t centralitysel, + Float_t centrMin=0., + Float_t centrMax=100., + TString fileNameBase="output", + Bool_t isPID = kTRUE, + Int_t AODfilterBitRP = 768, + Int_t AODfilterBitPOI = 768, + AliPID::EParticleType particleType=AliPID::kPion, + AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFbayesian, + Int_t charge=0, + Int_t harmonic=3, + Bool_t doQA=kFALSE, + Float_t etamin=-0.8, + Float_t etamax=0.8, + TString uniqueStr="" ) +{ + // Define the range for eta subevents (for SP method) + Double_t minA = -0.9;// + Double_t maxA = -0.5;// + Double_t minB = 0.5;// + Double_t maxB = 0.9;// + + // AFTERBURNER + Bool_t useAfterBurner=kFALSE; + Double_t v1=0.0; + Double_t v2=0.0; + Double_t v3=0.0; + Double_t v4=0.0; + Int_t numberOfTrackClones=0; //non-flow + + // Define a range of the detector to exclude + Bool_t ExcludeRegion = kFALSE; + Double_t excludeEtaMin = -0.; + Double_t excludeEtaMax = 0.; + Double_t excludePhiMin = 0.; + Double_t excludePhiMax = 0.; + + // use physics selection class + Bool_t UsePhysicsSelection = kTRUE; + + // QA + Bool_t runQAtask=kFALSE; + Bool_t FillQAntuple=kFALSE; + Bool_t DoQAcorrelations=kFALSE; + + // RUN SETTINGS + // Flow analysis method can be:(set to kTRUE or kFALSE) + Bool_t SP = kTRUE; // scalar product method (similar to eventplane method) + Bool_t QC = kTRUE; // cumulants using Q vectors + + //these are OBSOLETE, use at own peril + Bool_t GFC = kFALSE; // cumulants based on generating function + Bool_t MCEP = kFALSE; // correlation with Monte Carlo reaction plane + Bool_t FQD = kFALSE; // fit of the distribution of the Q vector (only integrated v) + Bool_t LYZ1SUM = kFALSE; // Lee Yang Zeroes using sum generating function (integrated v) + Bool_t LYZ1PROD = kFALSE; // Lee Yang Zeroes using product generating function (integrated v) + Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v) + Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v) + Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight) + Bool_t MH = kFALSE; // azimuthal correlators in mixed harmonics + Bool_t NL = kFALSE; // nested loops (for instance distribution of phi1-phi2 for all distinct pairs) + + Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL}; + + // Boolean to use/not use weights for the Q vector + Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta) + + // SETTING THE CUTS + + //---------Data selection---------- + //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet + AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kTPCstandalone; + AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kTPCstandalone; + + //---------Parameter mixing-------- + //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt + AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure; + AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure; + + + const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype); + const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype); + + //=========================================================================== + // EVENTS CUTS: + AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts"); + cutsEvent->SetCentralityPercentileRange(centrMin,centrMax); + cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0); +// cutsEvent->SetRefMultMethod(AliFlowEventCuts::kVZERO); + //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets); + //cutsEvent->SetNContributorsRange(2); + cutsEvent->SetPrimaryVertexZrange(-10.,10.); + cutsEvent->SetQA(doQA); + cutsEvent->SetCutTPCmultiplicityOutliers(); + + // RP TRACK CUTS: +// AliFlowTrackCuts* cutsRP2 = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts(); + AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP"); + cutsRP->SetParamType(rptype); + cutsRP->SetParamMix(rpmix); + cutsRP->SetPtRange(0.2,5.); + cutsRP->SetEtaRange(etamin,etamax); + cutsRP->SetMinNClustersTPC(70); +// cutsRP->SetMinChi2PerClusterTPC(0.1);// + // cutsRP->SetMaxChi2PerClusterTPC(4.0);// + cutsRP->SetMaxDCAToVertexXY(3.0); + cutsRP->SetMaxDCAToVertexZ(3.0); + cutsRP->SetAcceptKinkDaughters(kFALSE); + cutsRP->SetMinimalTPCdedx(10.); + cutsRP->SetAODfilterBit(AODfilterBitRP); +// cutsRP->SetAODfilterBit(768); +cutsRP->SetQA(doQA); + + // POI TRACK CUTS: + AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("TPConlyPOI"); + cutsPOI->GetBayesianResponse()->ForceOldDedx(); // for 2010 data to use old TPC PID Response instead of the official one + cutsPOI->SetParamType(poitype); + cutsPOI->SetParamMix(poimix); + cutsPOI->SetPtRange(0.2,5.);// + cutsPOI->SetEtaRange(etamin,etamax); + //cutsPOI->SetRequireCharge(kTRUE); + //cutsPOI->SetPID(PdgRP); + cutsPOI->SetMinNClustersTPC(70); + // cutsPOI->SetMinChi2PerClusterTPC(0.1); // + // cutsPOI->SetMaxChi2PerClusterTPC(4.0); // +// cutsPOI->SetRequireITSRefit(kTRUE); +// cutsPOI->SetRequireTPCRefit(kTRUE); +// cutsPOI->SetMinNClustersITS(2); + //cutsPOI->SetMaxChi2PerClusterITS(1.e+09); + cutsPOI->SetMaxDCAToVertexXY(3.0); + cutsPOI->SetMaxDCAToVertexZ(3.0); + //cutsPOI->SetDCAToVertex2D(kTRUE); + //cutsPOI->SetMaxNsigmaToVertex(1.e+10); + //cutsPOI->SetRequireSigmaToVertex(kFALSE); + cutsPOI->SetAcceptKinkDaughters(kFALSE); + if(isPID) cutsPOI->SetPID(particleType, sourcePID);//particleType, sourcePID + if (charge!=0) cutsPOI->SetCharge(charge); + //cutsPOI->SetAllowTOFmismatch(kFALSE); + cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE); + //iexample: francesco's tunig TPC Bethe Bloch for data: + //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00); + //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49); + cutsPOI->SetMinimalTPCdedx(10.); + cutsPOI->SetAODfilterBit(AODfilterBitPOI); + // cutsPOI->SetAODfilterBit(768); + cutsPOI->SetQA(doQA); + cutsPOI->SetPriors((centrMin+centrMax)*0.5); // set priors and PID as a function of the centrality + +// Int_t sourcePID = 2; +// Int_t particleType = 2; //2 or 3 or 4 for kPion, kKaon and kProton + TString outputSlotName(""); + outputSlotName+=uniqueStr; + outputSlotName+=Form("QC(%i) ",harmonic); + outputSlotName+=cutsRP->GetName(); + outputSlotName+=" "; + outputSlotName+=cutsPOI->GetName(); + outputSlotName+=Form(" %.0f-",centrMin); + outputSlotName+=Form("%.0f ",centrMax); + if(isPID){ + outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);//sourcePID + outputSlotName+=" "; + outputSlotName+=AliPID::ParticleName(particleType);//particleType + } + else{ + outputSlotName+="AllCharged"; + } + if (charge<0) outputSlotName+="-"; + if (charge>0) outputSlotName+="+"; + + TString fileName(fileNameBase); + fileName.Append(".root"); + + Bool_t useWeights = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2]; + if (useWeights) cout<<"Weights are used"<GetInputEventHandler()) { + ::Error("AddTaskFlowEvent", "This task requires an input event handler"); + return NULL; + } + + // Open external input files + //=========================================================================== + //weights: + TFile *weightsFile = NULL; + TList *weightsList = NULL; + + if(useWeights) { + //open the file with the weights: + weightsFile = TFile::Open("weights.root","READ"); + if(weightsFile) { + //access the list which holds the histos with weigths: + weightsList = (TList*)weightsFile->Get("weights"); + } + else { + cout<<" WARNING: the file with weights from the previous run was not available."<pwd()); + pwd+="/"; + pwd+=outputFileName.Data(); + TFile *outputFile = NULL; + if(gSystem->AccessPathName(pwd.Data(),kFileExists)) { + cout<<"WARNING: You do not have an output file:"<FindObjectAny(inputFileNameLYZ2SUM.Data()); + if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { + cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; + break; + } + else { + TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM"); + if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<FindObjectAny(inputFileNameLYZ2PROD.Data()); + if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { + cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; + break; + } + else { + TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD"); + if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<pwd()); + pwd+="/"; + pwd+=outputFileName.Data(); + TFile *outputFile = NULL; + if(gSystem->AccessPathName(pwd.Data(),kFileExists)) { + cout<<"WARNING: You do not have an output file:"<FindObjectAny(inputFileNameLYZEP.Data()); + if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { + cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; + break; + } + else { + TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM"); + if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<SelectCollisionCandidates(centralitysel); + mgr->AddTask(taskfmd); + + AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance(); + pars->Init(); + pars->SetProcessPrimary(kTRUE); //for MC only + pars->SetProcessHits(kFALSE); + + //pars->SetRealData(kTRUE); //for real data + //pars->SetProcessPrimary(kFALSE); //for real data + } + } + + // Create the flow event task, add it to the manager. + //=========================================================================== + AliAnalysisTaskFlowEvent *taskFE = NULL; + + if(useAfterBurner) + { + taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1); + taskFE->SetFlow(v1,v2,v3,v4); + taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones); + taskFE->SetAfterburnerOn(); + taskFE->SelectCollisionCandidates(centralitysel); + } + else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); + taskFE->SelectCollisionCandidates(centralitysel);} + if (ExcludeRegion) { + taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); + } + taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB); + if (UsePhysicsSelection) { + taskFE->SelectCollisionCandidates(AliVEvent::kMB); + cout<<"Using Physics Selection"<AddTask(taskFE); + + // Pass cuts for RPs and POIs to the task: + taskFE->SetCutsEvent(cutsEvent); + taskFE->SetCutsRP(cutsRP); + taskFE->SetCutsPOI(cutsPOI); + if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO) + { + //TODO: since this is set in a static object all analyses in an analysis train + //will be affected. + taskFE->SetHistWeightvsPhiMin(0.); + taskFE->SetHistWeightvsPhiMax(200.); + } + + // Create the analysis tasks, add them to the manager. + //=========================================================================== + if (SP){ + AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]); + taskSP->SelectCollisionCandidates(centralitysel); + taskSP->SetRelDiffMsub(1.0); + taskSP->SetApplyCorrectionForNUA(kTRUE); + mgr->AddTask(taskSP); + } + if (LYZ1SUM){ + AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE); + taskLYZ1SUM->SelectCollisionCandidates(centralitysel); + taskLYZ1SUM->SetFirstRunLYZ(kTRUE); + taskLYZ1SUM->SetUseSumLYZ(kTRUE); + mgr->AddTask(taskLYZ1SUM); + } + if (LYZ1PROD){ + AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE); + taskLYZ1PROD->SelectCollisionCandidates(centralitysel); + taskLYZ1PROD->SetFirstRunLYZ(kTRUE); + taskLYZ1PROD->SetUseSumLYZ(kFALSE); + mgr->AddTask(taskLYZ1PROD); + } + if (LYZ2SUM){ + AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE); + taskLYZ2SUM->SelectCollisionCandidates(centralitysel); + taskLYZ2SUM->SetFirstRunLYZ(kFALSE); + taskLYZ2SUM->SetUseSumLYZ(kTRUE); + mgr->AddTask(taskLYZ2SUM); + } + if (LYZ2PROD){ + AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE); + taskLYZ2PROD->SelectCollisionCandidates(centralitysel); + taskLYZ2PROD->SetFirstRunLYZ(kFALSE); + taskLYZ2PROD->SetUseSumLYZ(kFALSE); + mgr->AddTask(taskLYZ2PROD); + } + if (LYZEP){ + AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data())); + taskLYZEP->SelectCollisionCandidates(centralitysel); + mgr->AddTask(taskLYZEP); + } + if (GFC){ + AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights); + taskGFC->SelectCollisionCandidates(centralitysel); + taskGFC->SetUsePhiWeights(WEIGHTS[0]); + taskGFC->SetUsePtWeights(WEIGHTS[1]); + taskGFC->SetUseEtaWeights(WEIGHTS[2]); + mgr->AddTask(taskGFC); + } + if (QC){ + AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights); + taskQC->SelectCollisionCandidates(centralitysel); + taskQC->SetUsePhiWeights(WEIGHTS[0]); + taskQC->SetUsePtWeights(WEIGHTS[1]); + taskQC->SetUseEtaWeights(WEIGHTS[2]); + taskQC->SetCalculateCumulantsVsM(kFALSE); + taskQC->SetnBinsMult(10000); + taskQC->SetMinMult(0.); + taskQC->SetMaxMult(10000.); + taskQC->SetHarmonic(harmonic); + taskQC->SetApplyCorrectionForNUA(kFALSE); + taskQC->SetFillMultipleControlHistograms(kFALSE); + mgr->AddTask(taskQC); + } + if (FQD){ + AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE); + taskFQD->SelectCollisionCandidates(centralitysel); + taskFQD->SetUsePhiWeights(WEIGHTS[0]); + taskFQD->SetqMin(0.); + taskFQD->SetqMax(1000.); + taskFQD->SetqNbins(10000); + mgr->AddTask(taskFQD); + } + if (MCEP){ + AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data())); + taskMCEP->SelectCollisionCandidates(centralitysel); + mgr->AddTask(taskMCEP); + } + if (MH){ + AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights); + taskMH->SelectCollisionCandidates(centralitysel); + taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)] + taskMH->SetNoOfMultipicityBins(10000); + taskMH->SetMultipicityBinWidth(1.); + taskMH->SetMinMultiplicity(1.); + taskMH->SetCorrectForDetectorEffects(kTRUE); + taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <> (Remark: two nested loops) + taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges + mgr->AddTask(taskMH); + } + if (NL){ + AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights); + taskNL->SelectCollisionCandidates(centralitysel); + taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)] + taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution + taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <> (Remark: three nested loops) + taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <> (Remark: three nested loops) + taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges + mgr->AddTask(taskNL); + } + + // Create the output container for the data produced by the task + // Connect to the input and output containers + //=========================================================================== + AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer(); + + if (rptypestr == "FMD") { + AliAnalysisDataContainer *coutputFMD = + mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer); + //input and output taskFMD + mgr->ConnectInput(taskfmd, 0, cinput1); + mgr->ConnectOutput(taskfmd, 1, coutputFMD); + //input into taskFE + mgr->ConnectInput(taskFE,1,coutputFMD); + } + + AliAnalysisDataContainer *coutputFE = + mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + mgr->ConnectInput(taskFE,0,cinput1); + mgr->ConnectOutput(taskFE,1,coutputFE); + + if (taskFE->GetQAOn()) + { + TString outputQA = fileName; + outputQA += ":QA"; + AliAnalysisDataContainer* coutputFEQA = + mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA); + mgr->ConnectOutput(taskFE,2,coutputFEQA); + } + + // Create the output containers for the data produced by the analysis tasks + // Connect to the input and output containers + //=========================================================================== + if (useWeights) { + AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kInputContainer); + } + + if(SP) { + TString outputSP = fileName; + outputSP += ":outputSPanalysis"; + outputSP+= rptypestr; + AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); + mgr->ConnectInput(taskSP,0,coutputFE); + mgr->ConnectOutput(taskSP,1,coutputSP); + if (WEIGHTS[0]) { + mgr->ConnectInput(taskSP,1,cinputWeights); + cinputWeights->SetData(weightsList); + } + } + if(LYZ1SUM) { + TString outputLYZ1SUM = fileName; + outputLYZ1SUM += ":outputLYZ1SUManalysis"; + outputLYZ1SUM+= rptypestr; + AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); + mgr->ConnectInput(taskLYZ1SUM,0,coutputFE); + mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM); + } + if(LYZ1PROD) { + TString outputLYZ1PROD = fileName; + outputLYZ1PROD += ":outputLYZ1PRODanalysis"; + outputLYZ1PROD+= rptypestr; + AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); + mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); + mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD); + } + if(LYZ2SUM) { + AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kInputContainer); + TString outputLYZ2SUM = fileName; + outputLYZ2SUM += ":outputLYZ2SUManalysis"; + outputLYZ2SUM+= rptypestr; + + AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); + mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); + mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM); + mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); + cinputLYZ2SUM->SetData(fInputListLYZ2SUM); + } + if(LYZ2PROD) { + AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kInputContainer); + TString outputLYZ2PROD = fileName; + outputLYZ2PROD += ":outputLYZ2PRODanalysis"; + outputLYZ2PROD+= rptypestr; + + AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); + mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); + mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD); + mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); + cinputLYZ2PROD->SetData(fInputListLYZ2PROD); + } + if(LYZEP) { + AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kInputContainer); + TString outputLYZEP = fileName; + outputLYZEP += ":outputLYZEPanalysis"; + outputLYZEP+= rptypestr; + + AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); + mgr->ConnectInput(taskLYZEP,0,coutputFE); + mgr->ConnectInput(taskLYZEP,1,cinputLYZEP); + mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); + cinputLYZEP->SetData(fInputListLYZEP); + } + if(GFC) { + TString outputGFC = fileName; + outputGFC += ":outputGFCanalysis"; + outputGFC+= rptypestr; + + AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); + mgr->ConnectInput(taskGFC,0,coutputFE); + mgr->ConnectOutput(taskGFC,1,coutputGFC); + if (useWeights) { + mgr->ConnectInput(taskGFC,1,cinputWeights); + cinputWeights->SetData(weightsList); + } + } + if(QC) { + TString outputQC = fileName; + outputQC += ":outputQCanalysis"; + outputQC+= rptypestr; + + AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); + mgr->ConnectInput(taskQC,0,coutputFE); + mgr->ConnectOutput(taskQC,1,coutputQC); + if (useWeights) { + mgr->ConnectInput(taskQC,1,cinputWeights); + cinputWeights->SetData(weightsList); + } + } + if(FQD) { + TString outputFQD = fileName; + outputFQD += ":outputFQDanalysis"; + outputFQD+= rptypestr; + + AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); + mgr->ConnectInput(taskFQD,0,coutputFE); + mgr->ConnectOutput(taskFQD,1,coutputFQD); + if(useWeights) { + mgr->ConnectInput(taskFQD,1,cinputWeights); + cinputWeights->SetData(weightsList); + } + } + if(MCEP) { + TString outputMCEP = fileName; + outputMCEP += ":outputMCEPanalysis"; + outputMCEP+= rptypestr; + + AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); + mgr->ConnectInput(taskMCEP,0,coutputFE); + mgr->ConnectOutput(taskMCEP,1,coutputMCEP); + } + if(MH) { + TString outputMH = fileName; + outputMH += ":outputMHanalysis"; + outputMH += rptypestr; + + AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); + mgr->ConnectInput(taskMH,0,coutputFE); + mgr->ConnectOutput(taskMH,1,coutputMH); + //if (useWeights) { + // mgr->ConnectInput(taskMH,1,cinputWeights); + // cinputWeights->SetData(weightsList); + //} + } + if(NL) { + TString outputNL = fileName; + outputNL += ":outputNLanalysis"; + outputNL += rptypestr; + + AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); + mgr->ConnectInput(taskNL,0,coutputFE); + mgr->ConnectOutput(taskNL,1,coutputNL); + //if (useWeights) { + // mgr->ConnectInput(taskNL,1,cinputWeights); + // cinputWeights->SetData(weightsList); + //} + } + + /////////////////////////////////////////////////////////////////////////////////////////// + if (runQAtask) + { + AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data())); + taskQAflow->SelectCollisionCandidates(centralitysel); + taskQAflow->SetEventCuts(cutsEvent); + taskQAflow->SetTrackCuts(cutsRP); + taskQAflow->SetFillNTuple(FillQAntuple); + taskQAflow->SetDoCorrelations(DoQAcorrelations); + mgr->AddTask(taskQAflow); + + Printf("outputSlotName %s",outputSlotName.Data()); + TString taskQAoutputFileName(fileNameBase); + taskQAoutputFileName.Append("_QA.root"); + AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()), + TObjArray::Class(), + AliAnalysisManager::kOutputContainer, + taskQAoutputFileName); + AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()), + TNtuple::Class(), + AliAnalysisManager::kOutputContainer, + taskQAoutputFileName); + mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer()); + mgr->ConnectInput(taskQAflow,1,coutputFE); + mgr->ConnectOutput(taskQAflow,1,coutputQAtask); + if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree); + } +} + + + + + diff --git a/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C b/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C index 1f822d89b0b..b39086bbb7c 100644 --- a/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C +++ b/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C @@ -1,520 +1,520 @@ -// run.C -// -// Template run macro for AliBasicTask.cxx/.h with example layout of -// physics selections and options, in macro and task. -// -// Author: Arvinder Palaha -// -class AliAnalysisGrid; -class AliAnalysisTaskBF; -class AliBalance; - -//Centrality stuff -Int_t binfirst = 0; //where do we start numbering bins -Int_t binlast = 8; //where do we stop numbering bins -const Int_t numberOfCentralityBins = 9; -Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile - -//Systematic studies -const Int_t numberOfSyst = 13; -Float_t vZ[numberOfSyst] = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.}; // global Vertex Z cut -Float_t DCAxy[numberOfSyst] = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4}; // DCA xy cut (afterburner, -1 = w/o additional cut) -Float_t DCAz[numberOfSyst] = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2}; // DCA z cut (afterburner, -1 = w/o additional cut) -Float_t ptMin[numberOfSyst] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3}; // pt cuts -Float_t ptMax[numberOfSyst] = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts -Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts -Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4}; // eta cuts - -Bool_t kUsePID = kFALSE; -Bool_t bUseHBTCut = kTRUE; -Bool_t bUseConversionCut = kTRUE; -Bool_t bResonancesCut = kTRUE; -Bool_t bMomentumDifferenceCut = kTRUE; -Int_t kNSigmaElectronRejection = 3; - -//______________________________________________________________________________ -void runTaskFlowHigherOrdersAllPID( - const char* runtype = "local", // local, proof or grid - const char *gridmode = "terminate", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof - const Int_t bunchN = 0, - const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS - const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data) - const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data - const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. - const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode - TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis - const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode - const char *taskname = "BF_Syst_Test" // sets name of grid generated macros - ) -{ - // check run type - if(runtype != "local" && runtype != "proof" && runtype != "grid") { - Printf("\n\tIncorrect run option, check first argument of run macro"); - Printf("\tint runtype = local, proof or grid\n"); - return; - } - Printf("%s analysis chosen",runtype); - - // load libraries - gSystem->Load("libCore.so"); - gSystem->Load("libGeom.so"); - gSystem->Load("libVMC.so"); - gSystem->Load("libPhysics.so"); - gSystem->Load("libTree.so"); - gSystem->Load("libSTEERBase.so"); - gSystem->Load("libESD.so"); - gSystem->Load("libAOD.so"); - gSystem->Load("libANALYSIS.so"); - gSystem->Load("libANALYSISalice.so"); - gSystem->Load("libEventMixing.so"); - gSystem->Load("libCORRFW.so"); - gSystem->Load("libPWGTools.so"); - gSystem->Load("libPWGCFebye.so"); - gSystem->Load("libPWGflowBase.so"); - gSystem->Load("libPWGflowTasks.so"); - - // additional - - // compile standalone stuff - //gROOT->LoadMacro("AliBalance.cxx++g"); - //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g"); - - // add aliroot indlude path - //gROOT->ProcessLine(".include $PWD/."); - //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT"))); - - gROOT->SetStyle("Plain"); - - // analysis manager - AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN)); - - // create the alien handler and attach it to the manager - if(runtype == "grid") { - AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); - mgr->SetGridHandler(plugin); - } - else if(runtype == "local") { - TString filename; - TChain* chain = 0x0; - if((!bAOD)&&(!bMCtruth)) { - chain = new TChain("esdTree"); - for(Int_t i = 0; i < 4; i++) { - filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set"; - filename += i; filename += "/AliESDs.root"; - chain->Add(filename.Data()); - } - } - else if((bAOD)&&(!bMCtruth)) { - chain = new TChain("aodTree"); - for(Int_t i = 0; i < 10; i++) { - filename = "/glusterfs/alice1/alice2/pchrist/HeavyIons/Data/2011/Set"; - filename += i; filename += "/AliAOD.root"; - chain->Add(filename.Data()); - } - } - else if((!bAOD)&&(bMCtruth)) { - chain = new TChain("TE"); - for(Int_t i = 10; i < 99; i++) { - filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; - filename += i; - filename += "/galice.root"; - chain->Add(filename.Data()); - } - } - else if((bAOD)&&(bMCtruth)) { //used for MCAOD - chain = new TChain("aodTree"); - for(Int_t i = 10; i < 99; i++) { - filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; - filename += i; - filename += "/AliAOD.root"; - chain->Add(filename.Data()); - } - } - - - }//local mode - - // input handler (ESD or AOD) - AliVEventHandler* inputH = NULL; - if(!bAOD){ - inputH = new AliESDInputHandler(); - } - else{ - inputH = new AliAODInputHandler(); - } - mgr->SetInputEventHandler(inputH); - - // mc event handler - if(bMCtruth) { - AliMCEventHandler* mchandler = new AliMCEventHandler(); - // Not reading track references - mchandler->SetReadTR(kFALSE); - mgr->SetMCtruthEventHandler(mchandler); - } - - // AOD output handler - //AliAODHandler* aodoutHandler = new AliAODHandler(); - //aodoutHandler->SetOutputFileName("aod.root"); - //mgr->SetOutputEventHandler(aodoutHandler); - - // === Physics Selection Task === - // - // In SelectCollisionCandidate(), default is kMB, so the task UserExec() - // function is only called for these events. - // Options are: - // kMB Minimum Bias trigger - // kMBNoTRD Minimum bias trigger where the TRD is not read out - // kMUON Muon trigger - // kHighMult High-Multiplicity Trigger - // kUserDefined For manually defined trigger selection - // - // Multiple options possible with the standard AND/OR operators && and || - // These all have the usual offline SPD or V0 selections performed. - // - // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), - // one can manually set the selected and background classes using: - // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") - // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); - // - // One can also specify multiple classes at once, or require a class to NOT - // trigger, for e.g. - // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); - // - // NOTE that manually setting the physics selection overrides the standard - // selection, so it must be done in completeness. - // - // ALTERNATIVELY, one can make the physics selection inside the task - // UserExec(). - // For this case, comment out the task->SelectCol.... line, - // and see AliBasicTask.cxx UserExec() function for details on this. - - //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); - //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); - //if(!physSelTask) { Printf("no physSelTask"); return; } - //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); - //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); - - // create task - //Add the centrality determination task and the physics selection - // (only on ESD level, in AODs centrality is already in header and events are selected) -// if((!bAOD)&&(!bMCtruth)){ -// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C"); -// AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); - - // Add physics selection task (NOT needed for AODs) -// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); -// AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel); -// } -///////////////////////////////////////// - //Add flow centrality bayesian - - gROOT->LoadMacro("AddTaskFlowHigherOrdersAllPID.C"); - //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C"); - // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowCentralityBayesian.C"); - // gROOT->LoadMacro("~/Desktop/work/PhD/flow/AddTaskFlowCentralityBayesian.C"); - AliAnalysisTaskFlowEvent* FlowTask = AddTaskFlowHigherOrdersAllPID(AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB,0.,80.,"AnalysisResults",kTRUE,768,768,AliPID::kPion,AliFlowTrackCuts::kTOFbayesian,0,kFALSE,-0.8,0.8,""); -///////////////////////////////////////// - - //Add the PID response -// if((kUsePID)||(kNSigmaElectronRejection)) { -// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); -// AddTaskPIDResponse(bMCphyssel); -// } - - //Add the VZERO event plane task -// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); -// AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection(); - - //Add the BF task (all centralities) - // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); - -// AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection); - //taskBF->SetDebugLevel(); - - // enable debug printouts - //mgr->SetDebugLevel(2); - //mgr->SetUseProgressBar(1,100); - if (!mgr->InitAnalysis()) return; - mgr->PrintStatus(); - - // start analysis - Printf("Starting Analysis...."); - if(runtype == "local") - mgr->StartAnalysis("local",chain); - else - mgr->StartAnalysis(runtype,nentries,firstentry); -} - -//______________________________________________________________________________ -AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset) -{ - AliAnalysisAlien *plugin = new AliAnalysisAlien(); - // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") - plugin->SetRunMode(gridmode); - - // Set versions of used packages - plugin->SetAPIVersion("V1.1x"); - plugin->SetROOTVersion("v5-34-08"); - plugin->SetAliROOTVersion("v5-05-19-AN"); - - // Declare input data to be processed. - - // Method 1: Create automatically XML collections using alien 'find' command. - // Define production directory LFN - plugin->SetGridDataDir("/alice/data/2010/LHC10h/"); - // On real reconstructed data: - // plugin->SetGridDataDir("/alice/data/2009/LHC09d"); - - // Set data search pattern - //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES - // Data pattern for reconstructed data - if(!bAOD){ - plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH - } - else{ - plugin->SetDataPattern("*ESDs/pass2/AOD086/*/AliAOD.root"); - } - - plugin->SetRunPrefix("000"); // real data - // ...then add run numbers to be considered - //plugin->SetRunRange(114917,115322); - - if(bunchN==0){ - plugin->AddRunNumber(137366); - } - - //bunch1 - else if(bunchN == 1){ - plugin->AddRunNumber(139510); - plugin->AddRunNumber(139507); - plugin->AddRunNumber(139505); - plugin->AddRunNumber(139503); - plugin->AddRunNumber(139465); - plugin->AddRunNumber(139438); - plugin->AddRunNumber(139437); - plugin->AddRunNumber(139360); - plugin->AddRunNumber(139329); - plugin->AddRunNumber(139328); - } - - //bunch2 - else if(bunchN == 2){ - plugin->AddRunNumber(139314); - plugin->AddRunNumber(139310); - plugin->AddRunNumber(139309); - plugin->AddRunNumber(139173); - plugin->AddRunNumber(139107); - plugin->AddRunNumber(139105); - plugin->AddRunNumber(139038); - plugin->AddRunNumber(139037); - plugin->AddRunNumber(139036); - plugin->AddRunNumber(139029); - plugin->AddRunNumber(139028); - plugin->AddRunNumber(138872); - plugin->AddRunNumber(138871); - plugin->AddRunNumber(138870); - plugin->AddRunNumber(138837); - plugin->AddRunNumber(138732); - plugin->AddRunNumber(138730); - plugin->AddRunNumber(138666); - plugin->AddRunNumber(138662); - plugin->AddRunNumber(138653); - } - - else if(bunchN == 3){ - plugin->AddRunNumber(138652); - plugin->AddRunNumber(138638); - plugin->AddRunNumber(138624); - plugin->AddRunNumber(138621); - plugin->AddRunNumber(138583); - plugin->AddRunNumber(138582); - plugin->AddRunNumber(138579); - plugin->AddRunNumber(138578); - plugin->AddRunNumber(138534); - plugin->AddRunNumber(138469); - } - - else if(bunchN == 4){ - - plugin->AddRunNumber(138442); - plugin->AddRunNumber(138439); - plugin->AddRunNumber(138438); - plugin->AddRunNumber(138396); - plugin->AddRunNumber(138364); - plugin->AddRunNumber(138275); - plugin->AddRunNumber(138225); - plugin->AddRunNumber(138201); - plugin->AddRunNumber(138197); - plugin->AddRunNumber(138192); - } - - else if(bunchN == 5){ - - plugin->AddRunNumber(138190); - plugin->AddRunNumber(137848); - plugin->AddRunNumber(137844); - plugin->AddRunNumber(137752); - plugin->AddRunNumber(137751); - plugin->AddRunNumber(137724); - plugin->AddRunNumber(137722); - plugin->AddRunNumber(137718); - plugin->AddRunNumber(137704); - plugin->AddRunNumber(137693); - } - - else if(bunchN == 6){ - - plugin->AddRunNumber(137692); - plugin->AddRunNumber(137691); - plugin->AddRunNumber(137686); - plugin->AddRunNumber(137685); - plugin->AddRunNumber(137639); - plugin->AddRunNumber(137638); - plugin->AddRunNumber(137608); - plugin->AddRunNumber(137595); - plugin->AddRunNumber(137549); - plugin->AddRunNumber(137546); - - } - - else if(bunchN == 7){ - - plugin->AddRunNumber(137544); - plugin->AddRunNumber(137541); - plugin->AddRunNumber(137539); - plugin->AddRunNumber(137531); - plugin->AddRunNumber(137530); - plugin->AddRunNumber(137443); - plugin->AddRunNumber(137441); - plugin->AddRunNumber(137440); - plugin->AddRunNumber(137439); - plugin->AddRunNumber(137434); - - } - - else if(bunchN == 8){ - - plugin->AddRunNumber(137432); - plugin->AddRunNumber(137431); - plugin->AddRunNumber(137430); - plugin->AddRunNumber(137366); - plugin->AddRunNumber(137243); - plugin->AddRunNumber(137236); - plugin->AddRunNumber(137235); - plugin->AddRunNumber(137232); - plugin->AddRunNumber(137231); - plugin->AddRunNumber(137162); - plugin->AddRunNumber(137161); - } - - else{ - - stderr<<"BUNCH NOT THERE"<AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161"); - - - - - - plugin->SetNrunsPerMaster(1); - plugin->SetOutputToRunNo(); - // comment out the next line when using the "terminate" option, unless - // you want separate merged files for each run - plugin->SetMergeViaJDL(); - - // Method 2: Declare existing data files (raw collections, xml collections, root file) - // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) - // XML collections added via this method can be combined with the first method if - // the content is compatible (using or not tags) - // plugin->AddDataFile("tag.xml"); - // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); - - // Define alien work directory where all files will be copied. Relative to alien $HOME. - plugin->SetGridWorkingDir(taskname); - - // Declare alien output directory. Relative to working directory. - plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out - - // Declare the analysis source files names separated by blancs. To be compiled runtime - // using ACLiC on the worker nodes. - plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx"); - - // Declare all libraries (other than the default ones for the framework. These will be - // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. - //plugin->AddIncludePath("-I."); - //plugin->SetAdditionalLibs("libPWGCFebye.so"); - plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h"); - - // Declare the output file names separated by blancs. - // (can be like: file.root or file.root@ALICE::Niham::File) - // To only save certain files, use SetDefaultOutputs(kFALSE), and then - // SetOutputFiles("list.root other.filename") to choose which files to save - plugin->SetDefaultOutputs(); - //plugin->SetOutputFiles("list.root"); - - // Optionally set a name for the generated analysis macro (default MyAnalysis.C) - plugin->SetAnalysisMacro(Form("%s.C",taskname)); - - // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) - plugin->SetSplitMaxInputFileNumber(100); - - // Optionally modify the executable name (default analysis.sh) - plugin->SetExecutable(Form("%s.sh",taskname)); - - // set number of test files to use in "test" mode - plugin->SetNtestFiles(1); - - // Optionally resubmit threshold. - plugin->SetMasterResubmitThreshold(90); - - // Optionally set time to live (default 30000 sec) - plugin->SetTTL(90000); - - // Optionally set input format (default xml-single) - plugin->SetInputFormat("xml-single"); - - // Optionally modify the name of the generated JDL (default analysis.jdl) - plugin->SetJDLName(Form("%s.jdl",taskname)); - - // Optionally modify job price (default 1) - plugin->SetPrice(1); - - // Optionally modify split mode (default 'se') - plugin->SetSplitMode("se"); - - //plugin->SetUseSubmitPolicy(); - //plugin->SetKeepLogs(); - - //---------------------------------------------------------- - //--- PROOF MODE SPECIFIC SETTINGS ------------ - //---------------------------------------------------------- - // Proof cluster - plugin->SetProofCluster(proofcluster); - // Dataset to be used - plugin->SetProofDataSet(proofdataset); - // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard - plugin->SetProofReset(0); - // May limit number of workers - plugin->SetNproofWorkers(0); - // May limit the number of workers per slave - plugin->SetNproofWorkersPerSlave(1); - // May use a specific version of root installed in proof - plugin->SetRootVersionForProof("current"); - // May set the aliroot mode. Check http://aaf.cern.ch/node/83 - plugin->SetAliRootMode("default"); // Loads AF libs by default - // May request ClearPackages (individual ClearPackage not supported) - plugin->SetClearPackages(kFALSE); - // Plugin test mode works only providing a file containing test file locations, used in "local" mode also - plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc - // Request connection to alien upon connection to grid - plugin->SetProofConnectGrid(kFALSE); - - plugin->Print(); - - return plugin; -} - +// run.C +// +// Template run macro for AliBasicTask.cxx/.h with example layout of +// physics selections and options, in macro and task. +// +// Author: Arvinder Palaha +// +class AliAnalysisGrid; +class AliAnalysisTaskBF; +class AliBalance; + +//Centrality stuff +Int_t binfirst = 0; //where do we start numbering bins +Int_t binlast = 8; //where do we stop numbering bins +const Int_t numberOfCentralityBins = 9; +Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile + +//Systematic studies +const Int_t numberOfSyst = 13; +Float_t vZ[numberOfSyst] = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.}; // global Vertex Z cut +Float_t DCAxy[numberOfSyst] = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4}; // DCA xy cut (afterburner, -1 = w/o additional cut) +Float_t DCAz[numberOfSyst] = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2}; // DCA z cut (afterburner, -1 = w/o additional cut) +Float_t ptMin[numberOfSyst] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3}; // pt cuts +Float_t ptMax[numberOfSyst] = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts +Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts +Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4}; // eta cuts + +Bool_t kUsePID = kFALSE; +Bool_t bUseHBTCut = kTRUE; +Bool_t bUseConversionCut = kTRUE; +Bool_t bResonancesCut = kTRUE; +Bool_t bMomentumDifferenceCut = kTRUE; +Int_t kNSigmaElectronRejection = 3; + +//______________________________________________________________________________ +void runTaskFlowHigherOrdersAllPID( + const char* runtype = "local", // local, proof or grid + const char *gridmode = "terminate", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof + const Int_t bunchN = 0, + const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS + const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data) + const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data + const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. + const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode + TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis + const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode + const char *taskname = "BF_Syst_Test" // sets name of grid generated macros + ) +{ + // check run type + if(runtype != "local" && runtype != "proof" && runtype != "grid") { + Printf("\n\tIncorrect run option, check first argument of run macro"); + Printf("\tint runtype = local, proof or grid\n"); + return; + } + Printf("%s analysis chosen",runtype); + + // load libraries + gSystem->Load("libCore.so"); + gSystem->Load("libGeom.so"); + gSystem->Load("libVMC.so"); + gSystem->Load("libPhysics.so"); + gSystem->Load("libTree.so"); + gSystem->Load("libSTEERBase.so"); + gSystem->Load("libESD.so"); + gSystem->Load("libAOD.so"); + gSystem->Load("libANALYSIS.so"); + gSystem->Load("libANALYSISalice.so"); + gSystem->Load("libEventMixing.so"); + gSystem->Load("libCORRFW.so"); + gSystem->Load("libPWGTools.so"); + gSystem->Load("libPWGCFebye.so"); + gSystem->Load("libPWGflowBase.so"); + gSystem->Load("libPWGflowTasks.so"); + + // additional + + // compile standalone stuff + //gROOT->LoadMacro("AliBalance.cxx++g"); + //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g"); + + // add aliroot indlude path + //gROOT->ProcessLine(".include $PWD/."); + //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT"))); + + gROOT->SetStyle("Plain"); + + // analysis manager + AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN)); + + // create the alien handler and attach it to the manager + if(runtype == "grid") { + AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); + mgr->SetGridHandler(plugin); + } + else if(runtype == "local") { + TString filename; + TChain* chain = 0x0; + if((!bAOD)&&(!bMCtruth)) { + chain = new TChain("esdTree"); + for(Int_t i = 0; i < 4; i++) { + filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set"; + filename += i; filename += "/AliESDs.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(!bMCtruth)) { + chain = new TChain("aodTree"); + for(Int_t i = 0; i < 10; i++) { + filename = "/glusterfs/alice1/alice2/pchrist/HeavyIons/Data/2011/Set"; + filename += i; filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + else if((!bAOD)&&(bMCtruth)) { + chain = new TChain("TE"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/galice.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(bMCtruth)) { //used for MCAOD + chain = new TChain("aodTree"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + + + }//local mode + + // input handler (ESD or AOD) + AliVEventHandler* inputH = NULL; + if(!bAOD){ + inputH = new AliESDInputHandler(); + } + else{ + inputH = new AliAODInputHandler(); + } + mgr->SetInputEventHandler(inputH); + + // mc event handler + if(bMCtruth) { + AliMCEventHandler* mchandler = new AliMCEventHandler(); + // Not reading track references + mchandler->SetReadTR(kFALSE); + mgr->SetMCtruthEventHandler(mchandler); + } + + // AOD output handler + //AliAODHandler* aodoutHandler = new AliAODHandler(); + //aodoutHandler->SetOutputFileName("aod.root"); + //mgr->SetOutputEventHandler(aodoutHandler); + + // === Physics Selection Task === + // + // In SelectCollisionCandidate(), default is kMB, so the task UserExec() + // function is only called for these events. + // Options are: + // kMB Minimum Bias trigger + // kMBNoTRD Minimum bias trigger where the TRD is not read out + // kMUON Muon trigger + // kHighMult High-Multiplicity Trigger + // kUserDefined For manually defined trigger selection + // + // Multiple options possible with the standard AND/OR operators && and || + // These all have the usual offline SPD or V0 selections performed. + // + // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), + // one can manually set the selected and background classes using: + // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") + // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); + // + // One can also specify multiple classes at once, or require a class to NOT + // trigger, for e.g. + // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); + // + // NOTE that manually setting the physics selection overrides the standard + // selection, so it must be done in completeness. + // + // ALTERNATIVELY, one can make the physics selection inside the task + // UserExec(). + // For this case, comment out the task->SelectCol.... line, + // and see AliBasicTask.cxx UserExec() function for details on this. + + //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); + //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); + //if(!physSelTask) { Printf("no physSelTask"); return; } + //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); + //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); + + // create task + //Add the centrality determination task and the physics selection + // (only on ESD level, in AODs centrality is already in header and events are selected) +// if((!bAOD)&&(!bMCtruth)){ +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C"); +// AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); + + // Add physics selection task (NOT needed for AODs) +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); +// AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel); +// } +///////////////////////////////////////// + //Add flow centrality bayesian + + gROOT->LoadMacro("AddTaskFlowHigherOrdersAllPID.C"); + //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C"); + // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowCentralityBayesian.C"); + // gROOT->LoadMacro("~/Desktop/work/PhD/flow/AddTaskFlowCentralityBayesian.C"); + AliAnalysisTaskFlowEvent* FlowTask = AddTaskFlowHigherOrdersAllPID(AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB,0.,80.,"AnalysisResults",kTRUE,768,768,AliPID::kPion,AliFlowTrackCuts::kTOFbayesian,0,kFALSE,-0.8,0.8,""); +///////////////////////////////////////// + + //Add the PID response +// if((kUsePID)||(kNSigmaElectronRejection)) { +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); +// AddTaskPIDResponse(bMCphyssel); +// } + + //Add the VZERO event plane task +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); +// AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection(); + + //Add the BF task (all centralities) + // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); + +// AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection); + //taskBF->SetDebugLevel(); + + // enable debug printouts + //mgr->SetDebugLevel(2); + //mgr->SetUseProgressBar(1,100); + if (!mgr->InitAnalysis()) return; + mgr->PrintStatus(); + + // start analysis + Printf("Starting Analysis...."); + if(runtype == "local") + mgr->StartAnalysis("local",chain); + else + mgr->StartAnalysis(runtype,nentries,firstentry); +} + +//______________________________________________________________________________ +AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset) +{ + AliAnalysisAlien *plugin = new AliAnalysisAlien(); + // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") + plugin->SetRunMode(gridmode); + + // Set versions of used packages + plugin->SetAPIVersion("V1.1x"); + plugin->SetROOTVersion("v5-34-08"); + plugin->SetAliROOTVersion("v5-05-19-AN"); + + // Declare input data to be processed. + + // Method 1: Create automatically XML collections using alien 'find' command. + // Define production directory LFN + plugin->SetGridDataDir("/alice/data/2010/LHC10h/"); + // On real reconstructed data: + // plugin->SetGridDataDir("/alice/data/2009/LHC09d"); + + // Set data search pattern + //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES + // Data pattern for reconstructed data + if(!bAOD){ + plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH + } + else{ + plugin->SetDataPattern("*ESDs/pass2/AOD086/*/AliAOD.root"); + } + + plugin->SetRunPrefix("000"); // real data + // ...then add run numbers to be considered + //plugin->SetRunRange(114917,115322); + + if(bunchN==0){ + plugin->AddRunNumber(137366); + } + + //bunch1 + else if(bunchN == 1){ + plugin->AddRunNumber(139510); + plugin->AddRunNumber(139507); + plugin->AddRunNumber(139505); + plugin->AddRunNumber(139503); + plugin->AddRunNumber(139465); + plugin->AddRunNumber(139438); + plugin->AddRunNumber(139437); + plugin->AddRunNumber(139360); + plugin->AddRunNumber(139329); + plugin->AddRunNumber(139328); + } + + //bunch2 + else if(bunchN == 2){ + plugin->AddRunNumber(139314); + plugin->AddRunNumber(139310); + plugin->AddRunNumber(139309); + plugin->AddRunNumber(139173); + plugin->AddRunNumber(139107); + plugin->AddRunNumber(139105); + plugin->AddRunNumber(139038); + plugin->AddRunNumber(139037); + plugin->AddRunNumber(139036); + plugin->AddRunNumber(139029); + plugin->AddRunNumber(139028); + plugin->AddRunNumber(138872); + plugin->AddRunNumber(138871); + plugin->AddRunNumber(138870); + plugin->AddRunNumber(138837); + plugin->AddRunNumber(138732); + plugin->AddRunNumber(138730); + plugin->AddRunNumber(138666); + plugin->AddRunNumber(138662); + plugin->AddRunNumber(138653); + } + + else if(bunchN == 3){ + plugin->AddRunNumber(138652); + plugin->AddRunNumber(138638); + plugin->AddRunNumber(138624); + plugin->AddRunNumber(138621); + plugin->AddRunNumber(138583); + plugin->AddRunNumber(138582); + plugin->AddRunNumber(138579); + plugin->AddRunNumber(138578); + plugin->AddRunNumber(138534); + plugin->AddRunNumber(138469); + } + + else if(bunchN == 4){ + + plugin->AddRunNumber(138442); + plugin->AddRunNumber(138439); + plugin->AddRunNumber(138438); + plugin->AddRunNumber(138396); + plugin->AddRunNumber(138364); + plugin->AddRunNumber(138275); + plugin->AddRunNumber(138225); + plugin->AddRunNumber(138201); + plugin->AddRunNumber(138197); + plugin->AddRunNumber(138192); + } + + else if(bunchN == 5){ + + plugin->AddRunNumber(138190); + plugin->AddRunNumber(137848); + plugin->AddRunNumber(137844); + plugin->AddRunNumber(137752); + plugin->AddRunNumber(137751); + plugin->AddRunNumber(137724); + plugin->AddRunNumber(137722); + plugin->AddRunNumber(137718); + plugin->AddRunNumber(137704); + plugin->AddRunNumber(137693); + } + + else if(bunchN == 6){ + + plugin->AddRunNumber(137692); + plugin->AddRunNumber(137691); + plugin->AddRunNumber(137686); + plugin->AddRunNumber(137685); + plugin->AddRunNumber(137639); + plugin->AddRunNumber(137638); + plugin->AddRunNumber(137608); + plugin->AddRunNumber(137595); + plugin->AddRunNumber(137549); + plugin->AddRunNumber(137546); + + } + + else if(bunchN == 7){ + + plugin->AddRunNumber(137544); + plugin->AddRunNumber(137541); + plugin->AddRunNumber(137539); + plugin->AddRunNumber(137531); + plugin->AddRunNumber(137530); + plugin->AddRunNumber(137443); + plugin->AddRunNumber(137441); + plugin->AddRunNumber(137440); + plugin->AddRunNumber(137439); + plugin->AddRunNumber(137434); + + } + + else if(bunchN == 8){ + + plugin->AddRunNumber(137432); + plugin->AddRunNumber(137431); + plugin->AddRunNumber(137430); + plugin->AddRunNumber(137366); + plugin->AddRunNumber(137243); + plugin->AddRunNumber(137236); + plugin->AddRunNumber(137235); + plugin->AddRunNumber(137232); + plugin->AddRunNumber(137231); + plugin->AddRunNumber(137162); + plugin->AddRunNumber(137161); + } + + else{ + + stderr<<"BUNCH NOT THERE"<AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161"); + + + + + + plugin->SetNrunsPerMaster(1); + plugin->SetOutputToRunNo(); + // comment out the next line when using the "terminate" option, unless + // you want separate merged files for each run + plugin->SetMergeViaJDL(); + + // Method 2: Declare existing data files (raw collections, xml collections, root file) + // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) + // XML collections added via this method can be combined with the first method if + // the content is compatible (using or not tags) + // plugin->AddDataFile("tag.xml"); + // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); + + // Define alien work directory where all files will be copied. Relative to alien $HOME. + plugin->SetGridWorkingDir(taskname); + + // Declare alien output directory. Relative to working directory. + plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out + + // Declare the analysis source files names separated by blancs. To be compiled runtime + // using ACLiC on the worker nodes. + plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx"); + + // Declare all libraries (other than the default ones for the framework. These will be + // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. + //plugin->AddIncludePath("-I."); + //plugin->SetAdditionalLibs("libPWGCFebye.so"); + plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h"); + + // Declare the output file names separated by blancs. + // (can be like: file.root or file.root@ALICE::Niham::File) + // To only save certain files, use SetDefaultOutputs(kFALSE), and then + // SetOutputFiles("list.root other.filename") to choose which files to save + plugin->SetDefaultOutputs(); + //plugin->SetOutputFiles("list.root"); + + // Optionally set a name for the generated analysis macro (default MyAnalysis.C) + plugin->SetAnalysisMacro(Form("%s.C",taskname)); + + // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) + plugin->SetSplitMaxInputFileNumber(100); + + // Optionally modify the executable name (default analysis.sh) + plugin->SetExecutable(Form("%s.sh",taskname)); + + // set number of test files to use in "test" mode + plugin->SetNtestFiles(1); + + // Optionally resubmit threshold. + plugin->SetMasterResubmitThreshold(90); + + // Optionally set time to live (default 30000 sec) + plugin->SetTTL(90000); + + // Optionally set input format (default xml-single) + plugin->SetInputFormat("xml-single"); + + // Optionally modify the name of the generated JDL (default analysis.jdl) + plugin->SetJDLName(Form("%s.jdl",taskname)); + + // Optionally modify job price (default 1) + plugin->SetPrice(1); + + // Optionally modify split mode (default 'se') + plugin->SetSplitMode("se"); + + //plugin->SetUseSubmitPolicy(); + //plugin->SetKeepLogs(); + + //---------------------------------------------------------- + //--- PROOF MODE SPECIFIC SETTINGS ------------ + //---------------------------------------------------------- + // Proof cluster + plugin->SetProofCluster(proofcluster); + // Dataset to be used + plugin->SetProofDataSet(proofdataset); + // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard + plugin->SetProofReset(0); + // May limit number of workers + plugin->SetNproofWorkers(0); + // May limit the number of workers per slave + plugin->SetNproofWorkersPerSlave(1); + // May use a specific version of root installed in proof + plugin->SetRootVersionForProof("current"); + // May set the aliroot mode. Check http://aaf.cern.ch/node/83 + plugin->SetAliRootMode("default"); // Loads AF libs by default + // May request ClearPackages (individual ClearPackage not supported) + plugin->SetClearPackages(kFALSE); + // Plugin test mode works only providing a file containing test file locations, used in "local" mode also + plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc + // Request connection to alien upon connection to grid + plugin->SetProofConnectGrid(kFALSE); + + plugin->Print(); + + return plugin; +} + diff --git a/PWGDQ/dielectron/AliDielectronBtoJPSItoEle.h b/PWGDQ/dielectron/AliDielectronBtoJPSItoEle.h index 016c9c2204b..5d172c13d43 100644 --- a/PWGDQ/dielectron/AliDielectronBtoJPSItoEle.h +++ b/PWGDQ/dielectron/AliDielectronBtoJPSItoEle.h @@ -1,47 +1,47 @@ -#ifndef ALIDIELECTRONBTOJPSITOELE_H -#define ALIDIELECTRONBTOJPSITOELE_H -/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//------------------------------------------------------------------------- -// Class AliDielectronBtoJPSItoEle -// Unbinned log-likelihood fit analysis class -// -// Origin: C.Di Giglio -// Contact: Carmelo.Digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it -//------------------------------------------------------------------------- - -#include "TH1F.h" - -class TNtuple ; -class AliDielectronBtoJPSItoEleCDFfitHandler ; -class AliDielectronBtoJPSItoEleCDFfitFCN ; - -class AliDielectronBtoJPSItoEle : public TNamed { - public: - // - AliDielectronBtoJPSItoEle(); - AliDielectronBtoJPSItoEle(const AliDielectronBtoJPSItoEle& source); - AliDielectronBtoJPSItoEle& operator=(const AliDielectronBtoJPSItoEle& source); - virtual ~AliDielectronBtoJPSItoEle(); - - Int_t DoMinimization(Int_t step = 0); - void ReadCandidates(TNtuple* nt, Double_t* &x, Double_t* &m, Double_t* &pt, Int_t * &typeCand, Int_t& n,Double_t massLow = -1., Double_t massUp = -1., Double_t ptLow = -1., Double_t ptUp = -1.); // primary JPSI + secondary JPSI + bkg couples - - void SetCsiMC(); - void SetFitHandler(Double_t* x /*pseudoproper*/, Double_t* m /*inv mass*/, Double_t *pt /*transverse momentum */, Int_t *type /*type*/, Int_t ncand /*candidates*/); - void CloneMCtemplate(const TH1F* MCtemplate) {fMCtemplate = (TH1F*)MCtemplate->Clone("fMCtemplate");} - void SetResTypeAnalysis(TString resType){fResType = resType;} - Double_t* GetResolutionConstants(Double_t* resolutionConst); - AliDielectronBtoJPSItoEleCDFfitHandler* GetCDFFitHandler() const { return fFCNfunction ; } - - private: - // - AliDielectronBtoJPSItoEleCDFfitHandler* fFCNfunction; //! pointer to the interface class - TH1F* fMCtemplate; //! template of the MC distribution for the x distribution of the secondary J/psi - TString fResType; // string with candidate's types considered - - ClassDef(AliDielectronBtoJPSItoEle,1); // AliDielectronBtoJPSItoEle class -}; - -#endif +#ifndef ALIDIELECTRONBTOJPSITOELE_H +#define ALIDIELECTRONBTOJPSITOELE_H +/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//------------------------------------------------------------------------- +// Class AliDielectronBtoJPSItoEle +// Unbinned log-likelihood fit analysis class +// +// Origin: C.Di Giglio +// Contact: Carmelo.Digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it +//------------------------------------------------------------------------- + +#include "TH1F.h" + +class TNtuple ; +class AliDielectronBtoJPSItoEleCDFfitHandler ; +class AliDielectronBtoJPSItoEleCDFfitFCN ; + +class AliDielectronBtoJPSItoEle : public TNamed { + public: + // + AliDielectronBtoJPSItoEle(); + AliDielectronBtoJPSItoEle(const AliDielectronBtoJPSItoEle& source); + AliDielectronBtoJPSItoEle& operator=(const AliDielectronBtoJPSItoEle& source); + virtual ~AliDielectronBtoJPSItoEle(); + + Int_t DoMinimization(Int_t step = 0); + void ReadCandidates(TNtuple* nt, Double_t* &x, Double_t* &m, Double_t* &pt, Int_t * &typeCand, Int_t& n,Double_t massLow = -1., Double_t massUp = -1., Double_t ptLow = -1., Double_t ptUp = -1.); // primary JPSI + secondary JPSI + bkg couples + + void SetCsiMC(); + void SetFitHandler(Double_t* x /*pseudoproper*/, Double_t* m /*inv mass*/, Double_t *pt /*transverse momentum */, Int_t *type /*type*/, Int_t ncand /*candidates*/); + void CloneMCtemplate(const TH1F* MCtemplate) {fMCtemplate = (TH1F*)MCtemplate->Clone("fMCtemplate");} + void SetResTypeAnalysis(TString resType){fResType = resType;} + Double_t* GetResolutionConstants(Double_t* resolutionConst); + AliDielectronBtoJPSItoEleCDFfitHandler* GetCDFFitHandler() const { return fFCNfunction ; } + + private: + // + AliDielectronBtoJPSItoEleCDFfitHandler* fFCNfunction; //! pointer to the interface class + TH1F* fMCtemplate; //! template of the MC distribution for the x distribution of the secondary J/psi + TString fResType; // string with candidate's types considered + + ClassDef(AliDielectronBtoJPSItoEle,1); // AliDielectronBtoJPSItoEle class +}; + +#endif diff --git a/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h b/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h index 1a7acebea98..d57b738dc8a 100644 --- a/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h +++ b/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h @@ -1,283 +1,283 @@ -#ifndef ALIDIELECTRONBTOJPSITOELECDFFITFCN_H -#define ALIDIELECTRONBTOJPSITOELECDFFITFCN_H -/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//_________________________________________________________________________ -// Class AliDielectronBtoJPSItoEleCDFfitFCN -// Definition of main function used in -// unbinned log-likelihood fit for -// the channel B -> JPsi + X -> e+e- + X -// -// Origin: C.Di Giglio -// Contact: Carmelo.Digiglio@ba.infn.it , Giuseppe.Bruno@ba.infn.it -//_________________________________________________________________________ - -#include -#include -#include - - -class TRandom3; -class TF1; - -//_________________________________________________________________________________________________ -class AliDielectronBtoJPSItoEleCDFfitFCN : public TNamed { - public: - // - AliDielectronBtoJPSItoEleCDFfitFCN(); - AliDielectronBtoJPSItoEleCDFfitFCN(const AliDielectronBtoJPSItoEleCDFfitFCN& source); - AliDielectronBtoJPSItoEleCDFfitFCN& operator=(const AliDielectronBtoJPSItoEleCDFfitFCN& source); - virtual ~AliDielectronBtoJPSItoEleCDFfitFCN(); - - Double_t EvaluateLikelihood(const Double_t* pseudoproperdecaytime, - const Double_t* invariantmass, const Double_t* pt, const Int_t* type, const Int_t ncand) const; - - // getters for parameters - Double_t GetResWeight() const { return fParameters[0]; } - Double_t GetFPlus() const { return fParameters[1]; } - Double_t GetFMinus() const { return fParameters[2]; } - Double_t GetFSym() const { return fParameters[3]; } - Double_t GetFSym1() const { return fParameters[46]; } - Double_t GetLamPlus() const { return fParameters[4]; } - Double_t GetLamMinus() const { return fParameters[5]; } - Double_t GetLamSym() const { return fParameters[6]; } - Double_t GetLamSym1() const { return fParameters[45]; } - Double_t GetFractionJpsiFromBeauty() const { return fParameters[7]; } - Double_t GetFsig() const { return fParameters[8]; } - Double_t GetCrystalBallMmean() const { return fParameters[9]; } - Double_t GetCrystalBallNexp() const { return fParameters[10]; } - Double_t GetCrystalBallSigma() const { return fParameters[11]; } - Double_t GetCrystalBallAlpha() const { return fParameters[12]; } - Double_t GetCrystalBallNorm() const { return fParameters[13]; } - Double_t GetBkgInvMassNorm() const { return fParameters[14]; } - Double_t GetBkgInvMassMean() const { return fParameters[15]; } - Double_t GetBkgInvMassSlope() const { return fParameters[16]; } - Double_t GetBkgInvMassConst() const { return fParameters[17]; } - Double_t GetNormGaus1ResFunc(Int_t type) const { return fParameters[18+(2-type)*9]; } - Double_t GetNormGaus2ResFunc(Int_t type) const { return fParameters[19+(2-type)*9]; } - Double_t GetIntegralMassSig() const { return fintmMassSig; } - Double_t GetIntegralMassBkg() const { return fintmMassBkg; } - Double_t GetResMean1(Int_t type) const { return fParameters[20+(2-type)*9]; } - Double_t GetResSigma1(Int_t type) const { return fParameters[21+(2-type)*9]; } - Double_t GetResMean2(Int_t type) const { return fParameters[22+(2-type)*9]; } - Double_t GetResSigma2(Int_t type) const { return fParameters[23+(2-type)*9]; } - Double_t GetResAlfa(Int_t type) const { return fParameters[24+(2-type)*9]; } - Double_t GetResLambda(Int_t type) const { return fParameters[25+(2-type)*9]; } - Double_t GetResNormExp(Int_t type) const { return fParameters[26+(2-type)*9]; } - Double_t GetPolyn4() const { return fParameters[47]; } - Double_t GetPolyn5() const { return fParameters[48]; } - Bool_t GetCrystalBallParam() const { return fCrystalBallParam; } - Bool_t GetExponentialParam() const { return fExponentialParam; } - TH1F * GetCsiMcHisto() const { return fhCsiMC; } - Double_t GetResWeight(Int_t iW) const { return fWeightType[iW]; } - - // return pointer to likelihood functions - TF1* GetCsiMC(Double_t xmin, Double_t xmax,Double_t normalization); - TF1* GetResolutionFunc(Double_t xmin, Double_t xmax,Double_t normalization, Double_t pt, Int_t type=2); - TF1* GetResolutionFuncAllTypes(Double_t xmin, Double_t xmax,Double_t normalization); - TF1* GetFunB(Double_t xmin, Double_t xmax, Double_t normalization, Double_t pt, Int_t type=2, Int_t npx = 5000); - TF1* GetFunBAllTypes(Double_t xmin, Double_t xmax, Double_t normalization); - TF1* GetEvaluateCDFDecayTimeBkgDistr(Double_t xmin, Double_t xmax, Double_t normalization, Int_t type = 2, Double_t mass = 3.09, Double_t pt = 200.,Int_t npx = 5000); - TF1* GetEvaluateCDFDecayTimeBkgDistrAllTypes(Double_t xmin, Double_t xmax, Double_t normalization); - TF1* GetEvaluateCDFDecayTimeSigDistr(Double_t xmin, Double_t xmax, Double_t normalization, Double_t type); - TF1* GetEvaluateCDFInvMassBkgDistr(Double_t mMin, Double_t mMax, Double_t normalization); - TF1* GetEvaluateCDFInvMassSigDistr(Double_t mMin, Double_t mMax, Double_t normalization); - TF1* GetEvaluateCDFInvMassTotalDistr(Double_t mMin, Double_t mMax, Double_t normalization); - TF1* GetEvaluateCDFDecayTimeTotalDistr(Double_t xMin, Double_t xMax, Double_t normalization,Double_t pt = 200., Int_t type=2); - TF1 *GetEvaluateCDFDecayTimeTotalDistrAllTypes(Double_t xMin, Double_t xMax, Double_t normalization); - - void SetResWeight(Double_t resWgt) {fParameters[0] = resWgt;} - void SetFPlus(Double_t plus) {fParameters[1] = plus;} - void SetFMinus(Double_t minus) {fParameters[2] = minus;} - void SetFSym(Double_t sym) {fParameters[3] = sym;} - void SetFSym1(Double_t sym) {fParameters[46] = sym;} - void SetLamPlus(Double_t lamplus) {fParameters[4] = lamplus;} - void SetLamMinus(Double_t lamminus) {fParameters[5] = lamminus;} - void SetLamSym(Double_t lamsym) {fParameters[6] = lamsym;} - void SetLamSym1(Double_t lamsym) {fParameters[45] = lamsym;} - void SetFractionJpsiFromBeauty(Double_t B) {fParameters[7] = B;} - void SetFsig(Double_t Fsig) {fParameters[8] = Fsig;} - void SetCrystalBallMmean(Double_t CrystalBallMmean) {fParameters[9] = CrystalBallMmean;} - void SetCrystalBallNexp(Double_t CrystalBallNexp) {fParameters[10] = CrystalBallNexp;} - void SetCrystalBallSigma(Double_t CrystalBallSigma) {fParameters[11] = CrystalBallSigma;} - void SetCrystalBallAlpha(Double_t CrystalBallAlpha) {fParameters[12] = CrystalBallAlpha;} - void SetCrystalBallNorm(Double_t CrystalBallNorm) {fParameters[13] = CrystalBallNorm;} - void SetBkgInvMassNorm(Double_t BkgInvMassNorm) {fParameters[14] = BkgInvMassNorm;} - void SetBkgInvMassMean(Double_t BkgInvMassMean) {fParameters[15] = BkgInvMassMean;} - void SetBkgInvMassSlope(Double_t BkgInvMassSlope) {fParameters[16] = BkgInvMassSlope;} - void SetBkgInvMassConst(Double_t BkgInvMassConst) {fParameters[17] = BkgInvMassConst;} - void SetBkgInvMassPolyn4(Double_t coeffPol4) {fParameters[47] = coeffPol4;} - void SetBkgInvMassPolyn5(Double_t coeffPol5) {fParameters[48] = coeffPol5;} - void SetNormGaus1ResFunc(Double_t norm1) {fParameters[18] = norm1;} - void SetNormGaus2ResFunc(Double_t norm2) {fParameters[19] = norm2;} - void SetAllParameters(const Double_t* parameters); - void SetIntegralMassSig(Double_t integral) { fintmMassSig = integral; } - void SetIntegralMassBkg(Double_t integral) { fintmMassBkg = integral; } - void SetCsiMC(const TH1F* MCtemplate) {fhCsiMC = (TH1F*)MCtemplate->Clone("fhCsiMC");} - void SetTemplateShift(Double_t shift = 0.){fShiftTemplate = shift;} - - void SetResolutionConstants(const Double_t* resolutionConst, Int_t type); - void SetMassWndHigh(Double_t limit) { fMassWndHigh = TDatabasePDG::Instance()->GetParticle(443)->Mass() + limit ;} - void SetMassWndLow(Double_t limit) { fMassWndLow = TDatabasePDG::Instance()->GetParticle(443)->Mass() - limit ;} - void SetCrystalBallFunction(Bool_t okCB) {fCrystalBallParam = okCB;} - void SetExponentialFunction(Bool_t okExp) {fExponentialParam = okExp;} - - void SetWeightType(Double_t wFF, Double_t wFS, Double_t wSS) {fWeightType[0]= wSS; fWeightType[1]= wFS; fWeightType[2]= wFF;} - - void SetChangeResolution(Double_t change){fChangeResolution = change;} - void SetChangeMass(Double_t change){fChangeMass = change;} - void ComputeMassIntegral(); - void ReadMCtemplates(Int_t BinNum); - void PrintStatus(); - - //specific methods for multi-variational fit - void SetBkgWeights(Double_t ***bkgWgt){for(int kpt=0; kpt<(fPtWindows->GetSize()-1); kpt++){for(int k=0; k<(fMassWindows->GetSize()-2); k++) { for(int ktype=0; ktype<3; ktype++) fWeights[k][kpt][ktype]=bkgWgt[k][kpt][ktype]; }}} - - void SetBkgFunction(Int_t massRange,Int_t type, Int_t ptB, TF1 *histBkg){ - fFunBkgSaved[ptB][massRange][type] = histBkg; - } - TF1 *GetBkgFunction(Int_t massRange, Int_t ptB, Int_t type) const {return fFunBkgSaved[ptB][massRange][type];} - void SetFunBFunction(Int_t type, Int_t ptB, TF1 *histSec) { fFunBSaved[ptB][type] = histSec; } - void SetBackgroundSpecificParameters(Int_t pt, Int_t mb, Int_t tp); - void SetExtrapolationRegion(Int_t extrRegion){fSignalBinForExtrapolation = extrRegion;} void SetLoadFunction(Bool_t loadFunc) { fLoadFunctions = loadFunc;} - void SetMultivariateFit(Bool_t multVar) { fMultivariate = multVar;} - Bool_t GetMultivariate() const { return fMultivariate;} - void SetFunctionsSaved(Int_t npxFunB=5000, Int_t npxFunBkg=5000, Double_t funBLimits = 20000., Double_t funBkgLimits = 40000., Int_t signalRegion=2); - void SetResParams(Double_t ***pars){ fResParams = pars;} - void SetBkgParams(Float_t ****pars){ fBkgParams = pars;} - void SetMassWindows(TArrayD *msWnd){ fMassWindows = msWnd;} - void SetPtWindows(TArrayD *ptWnd){ fPtWindows = ptWnd;} - void InitializeFunctions(Int_t ptSize, Int_t massSize); - Double_t EvaluateCDFInvMassSigDistr(Double_t m) const ; - Double_t EvaluateCDFInvMassBkgDistr(Double_t m) const; - Double_t ResolutionFunc(Double_t x, Double_t pt, Int_t type) const; - Double_t EvaluateCDFDecayTimeBkgDistr(Double_t x, Int_t type, Double_t m=3.09, Double_t pt=200.) const ; - - - private: - Double_t fParameters[49]; /* par[0] = weightRes; - par[1] = fPos; - par[2] = fNeg; - par[3] = fSym - par[4] = fOneOvLamPlus; - par[5] = fOneOvLamMinus; - par[6] = fOneOvLamSym; - par[7] = fFractionJpsiFromBeauty; - par[8] = fFsig; - par[9] = fCrystalBallMmean; - par[10] = fCrystalBallNexp; - par[11] = fCrystalBallSigma; - par[12] = fCrystalBallAlpha; - par[13] = fCrystalBallNorm; - par[14] = fBkgNorm; - par[15] = fBkgMean; - par[16] = fBkgSlope; - par[17] = fBkgConst; - par[18] = norm1Gaus; // resolution param used for First-First - par[19] = norm2Gaus; - par[20] = fMean1ResFunc; - par[21] = fSigma1ResFunc; - par[22] = fMean2ResFunc; - par[23] = fSigma2ResFunc; - par[24] = fResAlfa; - par[25] = fResLambda; - par[26] = fResNormExp; - par[27] = norm1Gaus; // resolution param used for First-Second - par[28] = norm2Gaus; - par[29] = fMean1ResFunc; - par[30] = fSigma1ResFunc; - par[31] = fMean2ResFunc; - par[32] = fSigma2ResFunc; - par[33] = fResAlfa; - par[34] = fResLambda; - par[35] = fResNormExp; - par[36] = norm1Gaus; // resolution param used for Second-Second - par[37] = norm2Gaus; - par[38] = fMean1ResFunc; - par[39] = fSigma1ResFunc; - par[40] = fMean2ResFunc; - par[41] = fSigma2ResFunc; - par[42] = fResAlfa; - par[43] = fResLambda; - par[44] = fResNormExp; - ------------------------------> parameters to describe x and m à la CDF - // additional parameters below (added for PbPb analysis): if not used should be fixed - // by the FitHandler pointer - par[45] = fOneOvLamSym1; // additional parameter for background - par[46] = fSym1; // additional parameter for background - par[47] = fPolyn4; //additional parameter for inv. mass background - par[48] = fPolyn5; //additional parameter for inv. mass background */ - - Double_t fFPlus; // parameter of the log-likelihood function - Double_t fFMinus; // slopes of the x distributions of the background - Double_t fFSym; // functions - - Double_t fintmMassSig; // integral of invariant mass distribution for the signal - Double_t fintmMassBkg; // integral of invariant mass distribution for the bkg - - TH1F *fhCsiMC; // X distribution used as MC template for JPSI from B - - Double_t fShiftTemplate; // to shift the MC template - Double_t fMassWndHigh; // JPSI Mass window higher limit - Double_t fMassWndLow; // JPSI Mass window lower limit - Bool_t fCrystalBallParam; // Boolean to switch to Crystall Ball parameterisation - - Double_t fWeightType[3]; // vector with weights of candidates types (used to draw functions) - Double_t fChangeResolution; // constant to change the RMS of the resolution function - Double_t fChangeMass; // constant to change the RMS of the signal mass function - - // data members for multivariate fit - Double_t ***fWeights; // weights to interpolate bkg shape in pt, mass, type bins under signal region - Bool_t fLoadFunctions; // boolean to load functions saved - Bool_t fMultivariate; // switch-on multivariate fit - TF1 ***fFunBSaved; // pointers to save functions for x of non-prompt J/psi in pt, mass, type bins - TF1 ****fFunBkgSaved; // pointers to save functions for x of background in pt, mass, type bins - Double_t ***fResParams; // resolution function parameters in pt and type bins - Float_t ****fBkgParams; // x background parameters in pt, mass, type bins - TArrayD *fMassWindows; // limits for invariant mass bins - TArrayD *fPtWindows; // limits for pt bins - Bool_t fExponentialParam; // Boolean to switch to Exponential parameterisation - Double_t fSignalBinForExtrapolation; // inv. mass region in which extrapolate the background shape - // starting from background shapes in the near inv. mass regions - - - Double_t EvaluateCDFfunc(Double_t x, Double_t m, Double_t pt, Int_t type) const ; - Double_t EvaluateCDFfuncNorm(Double_t x, Double_t m, Double_t pt, Int_t type) const ; - Double_t EvaluateCDFfuncSignalPart(Double_t x, Double_t m, Double_t pt, Int_t type) const ; // Signal part - Double_t EvaluateCDFDecayTimeSigDistr(Double_t x, Double_t pt, Int_t type) const ; - Double_t EvaluateCDFDecayTimeSigDistrFunc(const Double_t* x, const Double_t *par) const { return par[0]*EvaluateCDFDecayTimeSigDistr(x[0],par[1],(Int_t)par[2]);} - Double_t EvaluateCDFInvMassSigDistrFunc(const Double_t* x, const Double_t *par) const {return par[0]*EvaluateCDFInvMassSigDistr(x[0])/fintmMassSig;} - Double_t EvaluateCDFfuncBkgPart(Double_t x,Double_t m, Double_t pt, Int_t type) const ; // Background part - Double_t EvaluateCDFDecayTimeBkgDistrFunc(const Double_t* x, const Double_t *par) const { return EvaluateCDFDecayTimeBkgDistr(x[0],(Int_t)par[1],par[2],par[3])*par[0];} - Double_t EvaluateCDFDecayTimeBkgDistrFuncAllTypes(const Double_t* x, const Double_t *par) const {return (fWeightType[2]*EvaluateCDFDecayTimeBkgDistr(x[0],2)+fWeightType[1]*EvaluateCDFDecayTimeBkgDistr(x[0],1)+fWeightType[0]*EvaluateCDFDecayTimeBkgDistr(x[0],0))*par[0];} - Double_t EvaluateCDFInvMassBkgDistrFunc(const Double_t* x, const Double_t *par) const {return par[0]*EvaluateCDFInvMassBkgDistr(x[0])/fintmMassBkg;} - - Double_t EvaluateCDFInvMassTotalDistr(const Double_t* x, const Double_t *par) const; - Double_t EvaluateCDFDecayTimeTotalDistr(const Double_t* x, const Double_t *par) const; - //// - Double_t EvaluateCDFDecayTimeTotalDistrAllTypes(const Double_t* x, const Double_t *par) const; - - Double_t FunB(Double_t x, Double_t pt, Int_t type) const; - Double_t FunBfunc(const Double_t *x, const Double_t *par) const {return FunB(x[0],par[1],(Int_t)par[2])*par[0];} - Double_t FunBfuncAllTypes(const Double_t *x, const Double_t *par) const {return (fWeightType[2]*FunB(x[0],200.,2)+fWeightType[1]*FunB(x[0],200.,1)+fWeightType[0]*FunB(x[0],200.,0))*par[0];} - Double_t FunP(Double_t x, Double_t pt,Int_t type) const ; - Double_t CsiMC(Double_t x) const; - Double_t CsiMCfunc(const Double_t* x, const Double_t *par) const { return CsiMC(x[0])*par[0];} - Double_t FunBkgPos(Double_t x, Double_t pt, Int_t type) const ; - Double_t FunBkgNeg(Double_t x, Double_t pt, Int_t type) const ; - Double_t FunBkgSym(Double_t x, Double_t pt, Int_t type) const ; - Double_t FunBkgSym1(Double_t x, Double_t pt, Int_t type) const ; - Double_t ResolutionFuncf(const Double_t* x, const Double_t *par) const { return ResolutionFunc(x[0],par[1],(Int_t)par[2])*par[0];} - Double_t ResolutionFuncAllTypes(const Double_t* x, const Double_t *par) const { return (fWeightType[2]*ResolutionFunc(x[0],200.,2)+fWeightType[1]*ResolutionFunc(x[0],200.,1)+fWeightType[0]*ResolutionFunc(x[0],200.,0))*par[0]; } - - // private methods for multivariate fit - Double_t EvaluateCDFDecayTimeBkgDistrSaved(Double_t x, Int_t type, Double_t m=3.09, Double_t pt = 200.) const ; - Double_t EvaluateCDFDecayTimeBkgDistrDifferential(Double_t x, Int_t type, Double_t m=3.09, Double_t pt = 200.) const; - Double_t FunBsaved(Double_t x, Double_t pt, Int_t type) const; - - ClassDef (AliDielectronBtoJPSItoEleCDFfitFCN,1); // Unbinned log-likelihood fit - -}; - -#endif +#ifndef ALIDIELECTRONBTOJPSITOELECDFFITFCN_H +#define ALIDIELECTRONBTOJPSITOELECDFFITFCN_H +/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//_________________________________________________________________________ +// Class AliDielectronBtoJPSItoEleCDFfitFCN +// Definition of main function used in +// unbinned log-likelihood fit for +// the channel B -> JPsi + X -> e+e- + X +// +// Origin: C.Di Giglio +// Contact: Carmelo.Digiglio@ba.infn.it , Giuseppe.Bruno@ba.infn.it +//_________________________________________________________________________ + +#include +#include +#include + + +class TRandom3; +class TF1; + +//_________________________________________________________________________________________________ +class AliDielectronBtoJPSItoEleCDFfitFCN : public TNamed { + public: + // + AliDielectronBtoJPSItoEleCDFfitFCN(); + AliDielectronBtoJPSItoEleCDFfitFCN(const AliDielectronBtoJPSItoEleCDFfitFCN& source); + AliDielectronBtoJPSItoEleCDFfitFCN& operator=(const AliDielectronBtoJPSItoEleCDFfitFCN& source); + virtual ~AliDielectronBtoJPSItoEleCDFfitFCN(); + + Double_t EvaluateLikelihood(const Double_t* pseudoproperdecaytime, + const Double_t* invariantmass, const Double_t* pt, const Int_t* type, const Int_t ncand) const; + + // getters for parameters + Double_t GetResWeight() const { return fParameters[0]; } + Double_t GetFPlus() const { return fParameters[1]; } + Double_t GetFMinus() const { return fParameters[2]; } + Double_t GetFSym() const { return fParameters[3]; } + Double_t GetFSym1() const { return fParameters[46]; } + Double_t GetLamPlus() const { return fParameters[4]; } + Double_t GetLamMinus() const { return fParameters[5]; } + Double_t GetLamSym() const { return fParameters[6]; } + Double_t GetLamSym1() const { return fParameters[45]; } + Double_t GetFractionJpsiFromBeauty() const { return fParameters[7]; } + Double_t GetFsig() const { return fParameters[8]; } + Double_t GetCrystalBallMmean() const { return fParameters[9]; } + Double_t GetCrystalBallNexp() const { return fParameters[10]; } + Double_t GetCrystalBallSigma() const { return fParameters[11]; } + Double_t GetCrystalBallAlpha() const { return fParameters[12]; } + Double_t GetCrystalBallNorm() const { return fParameters[13]; } + Double_t GetBkgInvMassNorm() const { return fParameters[14]; } + Double_t GetBkgInvMassMean() const { return fParameters[15]; } + Double_t GetBkgInvMassSlope() const { return fParameters[16]; } + Double_t GetBkgInvMassConst() const { return fParameters[17]; } + Double_t GetNormGaus1ResFunc(Int_t type) const { return fParameters[18+(2-type)*9]; } + Double_t GetNormGaus2ResFunc(Int_t type) const { return fParameters[19+(2-type)*9]; } + Double_t GetIntegralMassSig() const { return fintmMassSig; } + Double_t GetIntegralMassBkg() const { return fintmMassBkg; } + Double_t GetResMean1(Int_t type) const { return fParameters[20+(2-type)*9]; } + Double_t GetResSigma1(Int_t type) const { return fParameters[21+(2-type)*9]; } + Double_t GetResMean2(Int_t type) const { return fParameters[22+(2-type)*9]; } + Double_t GetResSigma2(Int_t type) const { return fParameters[23+(2-type)*9]; } + Double_t GetResAlfa(Int_t type) const { return fParameters[24+(2-type)*9]; } + Double_t GetResLambda(Int_t type) const { return fParameters[25+(2-type)*9]; } + Double_t GetResNormExp(Int_t type) const { return fParameters[26+(2-type)*9]; } + Double_t GetPolyn4() const { return fParameters[47]; } + Double_t GetPolyn5() const { return fParameters[48]; } + Bool_t GetCrystalBallParam() const { return fCrystalBallParam; } + Bool_t GetExponentialParam() const { return fExponentialParam; } + TH1F * GetCsiMcHisto() const { return fhCsiMC; } + Double_t GetResWeight(Int_t iW) const { return fWeightType[iW]; } + + // return pointer to likelihood functions + TF1* GetCsiMC(Double_t xmin, Double_t xmax,Double_t normalization); + TF1* GetResolutionFunc(Double_t xmin, Double_t xmax,Double_t normalization, Double_t pt, Int_t type=2); + TF1* GetResolutionFuncAllTypes(Double_t xmin, Double_t xmax,Double_t normalization); + TF1* GetFunB(Double_t xmin, Double_t xmax, Double_t normalization, Double_t pt, Int_t type=2, Int_t npx = 5000); + TF1* GetFunBAllTypes(Double_t xmin, Double_t xmax, Double_t normalization); + TF1* GetEvaluateCDFDecayTimeBkgDistr(Double_t xmin, Double_t xmax, Double_t normalization, Int_t type = 2, Double_t mass = 3.09, Double_t pt = 200.,Int_t npx = 5000); + TF1* GetEvaluateCDFDecayTimeBkgDistrAllTypes(Double_t xmin, Double_t xmax, Double_t normalization); + TF1* GetEvaluateCDFDecayTimeSigDistr(Double_t xmin, Double_t xmax, Double_t normalization, Double_t type); + TF1* GetEvaluateCDFInvMassBkgDistr(Double_t mMin, Double_t mMax, Double_t normalization); + TF1* GetEvaluateCDFInvMassSigDistr(Double_t mMin, Double_t mMax, Double_t normalization); + TF1* GetEvaluateCDFInvMassTotalDistr(Double_t mMin, Double_t mMax, Double_t normalization); + TF1* GetEvaluateCDFDecayTimeTotalDistr(Double_t xMin, Double_t xMax, Double_t normalization,Double_t pt = 200., Int_t type=2); + TF1 *GetEvaluateCDFDecayTimeTotalDistrAllTypes(Double_t xMin, Double_t xMax, Double_t normalization); + + void SetResWeight(Double_t resWgt) {fParameters[0] = resWgt;} + void SetFPlus(Double_t plus) {fParameters[1] = plus;} + void SetFMinus(Double_t minus) {fParameters[2] = minus;} + void SetFSym(Double_t sym) {fParameters[3] = sym;} + void SetFSym1(Double_t sym) {fParameters[46] = sym;} + void SetLamPlus(Double_t lamplus) {fParameters[4] = lamplus;} + void SetLamMinus(Double_t lamminus) {fParameters[5] = lamminus;} + void SetLamSym(Double_t lamsym) {fParameters[6] = lamsym;} + void SetLamSym1(Double_t lamsym) {fParameters[45] = lamsym;} + void SetFractionJpsiFromBeauty(Double_t B) {fParameters[7] = B;} + void SetFsig(Double_t Fsig) {fParameters[8] = Fsig;} + void SetCrystalBallMmean(Double_t CrystalBallMmean) {fParameters[9] = CrystalBallMmean;} + void SetCrystalBallNexp(Double_t CrystalBallNexp) {fParameters[10] = CrystalBallNexp;} + void SetCrystalBallSigma(Double_t CrystalBallSigma) {fParameters[11] = CrystalBallSigma;} + void SetCrystalBallAlpha(Double_t CrystalBallAlpha) {fParameters[12] = CrystalBallAlpha;} + void SetCrystalBallNorm(Double_t CrystalBallNorm) {fParameters[13] = CrystalBallNorm;} + void SetBkgInvMassNorm(Double_t BkgInvMassNorm) {fParameters[14] = BkgInvMassNorm;} + void SetBkgInvMassMean(Double_t BkgInvMassMean) {fParameters[15] = BkgInvMassMean;} + void SetBkgInvMassSlope(Double_t BkgInvMassSlope) {fParameters[16] = BkgInvMassSlope;} + void SetBkgInvMassConst(Double_t BkgInvMassConst) {fParameters[17] = BkgInvMassConst;} + void SetBkgInvMassPolyn4(Double_t coeffPol4) {fParameters[47] = coeffPol4;} + void SetBkgInvMassPolyn5(Double_t coeffPol5) {fParameters[48] = coeffPol5;} + void SetNormGaus1ResFunc(Double_t norm1) {fParameters[18] = norm1;} + void SetNormGaus2ResFunc(Double_t norm2) {fParameters[19] = norm2;} + void SetAllParameters(const Double_t* parameters); + void SetIntegralMassSig(Double_t integral) { fintmMassSig = integral; } + void SetIntegralMassBkg(Double_t integral) { fintmMassBkg = integral; } + void SetCsiMC(const TH1F* MCtemplate) {fhCsiMC = (TH1F*)MCtemplate->Clone("fhCsiMC");} + void SetTemplateShift(Double_t shift = 0.){fShiftTemplate = shift;} + + void SetResolutionConstants(const Double_t* resolutionConst, Int_t type); + void SetMassWndHigh(Double_t limit) { fMassWndHigh = TDatabasePDG::Instance()->GetParticle(443)->Mass() + limit ;} + void SetMassWndLow(Double_t limit) { fMassWndLow = TDatabasePDG::Instance()->GetParticle(443)->Mass() - limit ;} + void SetCrystalBallFunction(Bool_t okCB) {fCrystalBallParam = okCB;} + void SetExponentialFunction(Bool_t okExp) {fExponentialParam = okExp;} + + void SetWeightType(Double_t wFF, Double_t wFS, Double_t wSS) {fWeightType[0]= wSS; fWeightType[1]= wFS; fWeightType[2]= wFF;} + + void SetChangeResolution(Double_t change){fChangeResolution = change;} + void SetChangeMass(Double_t change){fChangeMass = change;} + void ComputeMassIntegral(); + void ReadMCtemplates(Int_t BinNum); + void PrintStatus(); + + //specific methods for multi-variational fit + void SetBkgWeights(Double_t ***bkgWgt){for(int kpt=0; kpt<(fPtWindows->GetSize()-1); kpt++){for(int k=0; k<(fMassWindows->GetSize()-2); k++) { for(int ktype=0; ktype<3; ktype++) fWeights[k][kpt][ktype]=bkgWgt[k][kpt][ktype]; }}} + + void SetBkgFunction(Int_t massRange,Int_t type, Int_t ptB, TF1 *histBkg){ + fFunBkgSaved[ptB][massRange][type] = histBkg; + } + TF1 *GetBkgFunction(Int_t massRange, Int_t ptB, Int_t type) const {return fFunBkgSaved[ptB][massRange][type];} + void SetFunBFunction(Int_t type, Int_t ptB, TF1 *histSec) { fFunBSaved[ptB][type] = histSec; } + void SetBackgroundSpecificParameters(Int_t pt, Int_t mb, Int_t tp); + void SetExtrapolationRegion(Int_t extrRegion){fSignalBinForExtrapolation = extrRegion;} void SetLoadFunction(Bool_t loadFunc) { fLoadFunctions = loadFunc;} + void SetMultivariateFit(Bool_t multVar) { fMultivariate = multVar;} + Bool_t GetMultivariate() const { return fMultivariate;} + void SetFunctionsSaved(Int_t npxFunB=5000, Int_t npxFunBkg=5000, Double_t funBLimits = 20000., Double_t funBkgLimits = 40000., Int_t signalRegion=2); + void SetResParams(Double_t ***pars){ fResParams = pars;} + void SetBkgParams(Float_t ****pars){ fBkgParams = pars;} + void SetMassWindows(TArrayD *msWnd){ fMassWindows = msWnd;} + void SetPtWindows(TArrayD *ptWnd){ fPtWindows = ptWnd;} + void InitializeFunctions(Int_t ptSize, Int_t massSize); + Double_t EvaluateCDFInvMassSigDistr(Double_t m) const ; + Double_t EvaluateCDFInvMassBkgDistr(Double_t m) const; + Double_t ResolutionFunc(Double_t x, Double_t pt, Int_t type) const; + Double_t EvaluateCDFDecayTimeBkgDistr(Double_t x, Int_t type, Double_t m=3.09, Double_t pt=200.) const ; + + + private: + Double_t fParameters[49]; /* par[0] = weightRes; + par[1] = fPos; + par[2] = fNeg; + par[3] = fSym + par[4] = fOneOvLamPlus; + par[5] = fOneOvLamMinus; + par[6] = fOneOvLamSym; + par[7] = fFractionJpsiFromBeauty; + par[8] = fFsig; + par[9] = fCrystalBallMmean; + par[10] = fCrystalBallNexp; + par[11] = fCrystalBallSigma; + par[12] = fCrystalBallAlpha; + par[13] = fCrystalBallNorm; + par[14] = fBkgNorm; + par[15] = fBkgMean; + par[16] = fBkgSlope; + par[17] = fBkgConst; + par[18] = norm1Gaus; // resolution param used for First-First + par[19] = norm2Gaus; + par[20] = fMean1ResFunc; + par[21] = fSigma1ResFunc; + par[22] = fMean2ResFunc; + par[23] = fSigma2ResFunc; + par[24] = fResAlfa; + par[25] = fResLambda; + par[26] = fResNormExp; + par[27] = norm1Gaus; // resolution param used for First-Second + par[28] = norm2Gaus; + par[29] = fMean1ResFunc; + par[30] = fSigma1ResFunc; + par[31] = fMean2ResFunc; + par[32] = fSigma2ResFunc; + par[33] = fResAlfa; + par[34] = fResLambda; + par[35] = fResNormExp; + par[36] = norm1Gaus; // resolution param used for Second-Second + par[37] = norm2Gaus; + par[38] = fMean1ResFunc; + par[39] = fSigma1ResFunc; + par[40] = fMean2ResFunc; + par[41] = fSigma2ResFunc; + par[42] = fResAlfa; + par[43] = fResLambda; + par[44] = fResNormExp; + ------------------------------> parameters to describe x and m à la CDF + // additional parameters below (added for PbPb analysis): if not used should be fixed + // by the FitHandler pointer + par[45] = fOneOvLamSym1; // additional parameter for background + par[46] = fSym1; // additional parameter for background + par[47] = fPolyn4; //additional parameter for inv. mass background + par[48] = fPolyn5; //additional parameter for inv. mass background */ + + Double_t fFPlus; // parameter of the log-likelihood function + Double_t fFMinus; // slopes of the x distributions of the background + Double_t fFSym; // functions + + Double_t fintmMassSig; // integral of invariant mass distribution for the signal + Double_t fintmMassBkg; // integral of invariant mass distribution for the bkg + + TH1F *fhCsiMC; // X distribution used as MC template for JPSI from B + + Double_t fShiftTemplate; // to shift the MC template + Double_t fMassWndHigh; // JPSI Mass window higher limit + Double_t fMassWndLow; // JPSI Mass window lower limit + Bool_t fCrystalBallParam; // Boolean to switch to Crystall Ball parameterisation + + Double_t fWeightType[3]; // vector with weights of candidates types (used to draw functions) + Double_t fChangeResolution; // constant to change the RMS of the resolution function + Double_t fChangeMass; // constant to change the RMS of the signal mass function + + // data members for multivariate fit + Double_t ***fWeights; // weights to interpolate bkg shape in pt, mass, type bins under signal region + Bool_t fLoadFunctions; // boolean to load functions saved + Bool_t fMultivariate; // switch-on multivariate fit + TF1 ***fFunBSaved; // pointers to save functions for x of non-prompt J/psi in pt, mass, type bins + TF1 ****fFunBkgSaved; // pointers to save functions for x of background in pt, mass, type bins + Double_t ***fResParams; // resolution function parameters in pt and type bins + Float_t ****fBkgParams; // x background parameters in pt, mass, type bins + TArrayD *fMassWindows; // limits for invariant mass bins + TArrayD *fPtWindows; // limits for pt bins + Bool_t fExponentialParam; // Boolean to switch to Exponential parameterisation + Double_t fSignalBinForExtrapolation; // inv. mass region in which extrapolate the background shape + // starting from background shapes in the near inv. mass regions + + + Double_t EvaluateCDFfunc(Double_t x, Double_t m, Double_t pt, Int_t type) const ; + Double_t EvaluateCDFfuncNorm(Double_t x, Double_t m, Double_t pt, Int_t type) const ; + Double_t EvaluateCDFfuncSignalPart(Double_t x, Double_t m, Double_t pt, Int_t type) const ; // Signal part + Double_t EvaluateCDFDecayTimeSigDistr(Double_t x, Double_t pt, Int_t type) const ; + Double_t EvaluateCDFDecayTimeSigDistrFunc(const Double_t* x, const Double_t *par) const { return par[0]*EvaluateCDFDecayTimeSigDistr(x[0],par[1],(Int_t)par[2]);} + Double_t EvaluateCDFInvMassSigDistrFunc(const Double_t* x, const Double_t *par) const {return par[0]*EvaluateCDFInvMassSigDistr(x[0])/fintmMassSig;} + Double_t EvaluateCDFfuncBkgPart(Double_t x,Double_t m, Double_t pt, Int_t type) const ; // Background part + Double_t EvaluateCDFDecayTimeBkgDistrFunc(const Double_t* x, const Double_t *par) const { return EvaluateCDFDecayTimeBkgDistr(x[0],(Int_t)par[1],par[2],par[3])*par[0];} + Double_t EvaluateCDFDecayTimeBkgDistrFuncAllTypes(const Double_t* x, const Double_t *par) const {return (fWeightType[2]*EvaluateCDFDecayTimeBkgDistr(x[0],2)+fWeightType[1]*EvaluateCDFDecayTimeBkgDistr(x[0],1)+fWeightType[0]*EvaluateCDFDecayTimeBkgDistr(x[0],0))*par[0];} + Double_t EvaluateCDFInvMassBkgDistrFunc(const Double_t* x, const Double_t *par) const {return par[0]*EvaluateCDFInvMassBkgDistr(x[0])/fintmMassBkg;} + + Double_t EvaluateCDFInvMassTotalDistr(const Double_t* x, const Double_t *par) const; + Double_t EvaluateCDFDecayTimeTotalDistr(const Double_t* x, const Double_t *par) const; + //// + Double_t EvaluateCDFDecayTimeTotalDistrAllTypes(const Double_t* x, const Double_t *par) const; + + Double_t FunB(Double_t x, Double_t pt, Int_t type) const; + Double_t FunBfunc(const Double_t *x, const Double_t *par) const {return FunB(x[0],par[1],(Int_t)par[2])*par[0];} + Double_t FunBfuncAllTypes(const Double_t *x, const Double_t *par) const {return (fWeightType[2]*FunB(x[0],200.,2)+fWeightType[1]*FunB(x[0],200.,1)+fWeightType[0]*FunB(x[0],200.,0))*par[0];} + Double_t FunP(Double_t x, Double_t pt,Int_t type) const ; + Double_t CsiMC(Double_t x) const; + Double_t CsiMCfunc(const Double_t* x, const Double_t *par) const { return CsiMC(x[0])*par[0];} + Double_t FunBkgPos(Double_t x, Double_t pt, Int_t type) const ; + Double_t FunBkgNeg(Double_t x, Double_t pt, Int_t type) const ; + Double_t FunBkgSym(Double_t x, Double_t pt, Int_t type) const ; + Double_t FunBkgSym1(Double_t x, Double_t pt, Int_t type) const ; + Double_t ResolutionFuncf(const Double_t* x, const Double_t *par) const { return ResolutionFunc(x[0],par[1],(Int_t)par[2])*par[0];} + Double_t ResolutionFuncAllTypes(const Double_t* x, const Double_t *par) const { return (fWeightType[2]*ResolutionFunc(x[0],200.,2)+fWeightType[1]*ResolutionFunc(x[0],200.,1)+fWeightType[0]*ResolutionFunc(x[0],200.,0))*par[0]; } + + // private methods for multivariate fit + Double_t EvaluateCDFDecayTimeBkgDistrSaved(Double_t x, Int_t type, Double_t m=3.09, Double_t pt = 200.) const ; + Double_t EvaluateCDFDecayTimeBkgDistrDifferential(Double_t x, Int_t type, Double_t m=3.09, Double_t pt = 200.) const; + Double_t FunBsaved(Double_t x, Double_t pt, Int_t type) const; + + ClassDef (AliDielectronBtoJPSItoEleCDFfitFCN,1); // Unbinned log-likelihood fit + +}; + +#endif diff --git a/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h b/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h index 787fcc85b45..11a667296dd 100644 --- a/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h +++ b/PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h @@ -1,80 +1,80 @@ -#ifndef ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H -#define ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H -/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//___________________________________________________________________________ -// Class AliDielectronBtoJPSItoEleCDFfitHandler -// Class to perform unbinned log-likelihood fit -// -// Origin: C. Di Giglio -// Contact: Carmelo.Digiglio@ba.infn.it; Giuseppe.Bruno@ba.infn.it -//____________________________________________________________________________ - -#include -#include -#include -#include - -class AliDielectronBtoJPSItoEleCDFfitFCN ; - -class AliDielectronBtoJPSItoEleCDFfitHandler : public TNamed { - public: - // - AliDielectronBtoJPSItoEleCDFfitHandler(); - AliDielectronBtoJPSItoEleCDFfitHandler& operator= (const AliDielectronBtoJPSItoEleCDFfitHandler& c); - AliDielectronBtoJPSItoEleCDFfitHandler(const AliDielectronBtoJPSItoEleCDFfitHandler& c); - AliDielectronBtoJPSItoEleCDFfitHandler(Double_t* decaytime, Double_t* invariantmass, Double_t *pt, Int_t *type, Int_t ncand); - ~AliDielectronBtoJPSItoEleCDFfitHandler(); - Double_t Up() const { return fUp; } - void SetErrorDef(Double_t up) {fUp = up;} - void SetPrintStatus(Bool_t okPrintStatus) { fPrintStatus = okPrintStatus; } - Bool_t GetPrintStatus() const { return fPrintStatus ; } - void SetParamStartValues (Double_t*); - Double_t* GetStartParamValues() { return fParamStartValues; } - TBits GetFixedParamList() const { return fIsParamFixed; } - TFitter *GetFitter() const {return fitter;} - Double_t GetParameter(Int_t numPar) const {return fitter->GetParameter(numPar);} - Double_t GetParameterError(Int_t numPar) const {return fitter->GetParError(numPar);} - - void FixParam(UInt_t param, Bool_t value) { fIsParamFixed.SetBitNumber(param,value); } - void FixAllParam(Bool_t value) { for(UInt_t par=0;par<49;par++) fIsParamFixed.SetBitNumber(par,value); } - Bool_t IsParamFixed(UInt_t param) { return fIsParamFixed.TestBitNumber(param); } - void SetResolutionConstants(Double_t* resolutionConst, Int_t type); - void SetCrystalBallFunction(Bool_t okCB); - void SetExponentialFunction(Bool_t okEpx); - void SetMassWndHigh(Double_t limit); - void SetMassWndLow(Double_t limit); - - Double_t operator()(const Double_t* par) const ; - void CdfFCN(Int_t & /* npar */, Double_t * /* gin */, Double_t &f, Double_t *par, Int_t /* iflag */); - - Double_t* Decaytime() const { return fX; } - Double_t* InvariantMass() const { return fM; } - Double_t* TransverseMom() const { return fPt; } - Int_t* TypeCand() const { return fType;} - AliDielectronBtoJPSItoEleCDFfitFCN* LikelihoodPointer() const { return fLikely; } - Int_t DoMinimization(Int_t step = 0); - - - private: - // - TBits fIsParamFixed; //array of bits: 0 = param free; 1 = param fixed; - Bool_t fPrintStatus; //flag to enable the prit out of the algorithm at each step - Double_t fParamStartValues[49]; //array of parameters input value - Double_t fUp; //error definition - Double_t* fX; //pseudo-proper decay time X - Double_t* fM; //invariant mass M - Double_t* fPt; //invariant mass M - Int_t* fType; //candidate type - AliDielectronBtoJPSItoEleCDFfitFCN* fLikely; //Log likelihood function - Int_t fNcand; //number of candidates - TGraph* fContPlot1; //contour plot - TGraph* fContPlot2; //contour plot - TGraph* fContPlot3; //contour plot - TFitter *fitter; //pointer to TFitter object - // - ClassDef(AliDielectronBtoJPSItoEleCDFfitHandler,1); - -}; -#endif +#ifndef ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H +#define ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H +/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//___________________________________________________________________________ +// Class AliDielectronBtoJPSItoEleCDFfitHandler +// Class to perform unbinned log-likelihood fit +// +// Origin: C. Di Giglio +// Contact: Carmelo.Digiglio@ba.infn.it; Giuseppe.Bruno@ba.infn.it +//____________________________________________________________________________ + +#include +#include +#include +#include + +class AliDielectronBtoJPSItoEleCDFfitFCN ; + +class AliDielectronBtoJPSItoEleCDFfitHandler : public TNamed { + public: + // + AliDielectronBtoJPSItoEleCDFfitHandler(); + AliDielectronBtoJPSItoEleCDFfitHandler& operator= (const AliDielectronBtoJPSItoEleCDFfitHandler& c); + AliDielectronBtoJPSItoEleCDFfitHandler(const AliDielectronBtoJPSItoEleCDFfitHandler& c); + AliDielectronBtoJPSItoEleCDFfitHandler(Double_t* decaytime, Double_t* invariantmass, Double_t *pt, Int_t *type, Int_t ncand); + ~AliDielectronBtoJPSItoEleCDFfitHandler(); + Double_t Up() const { return fUp; } + void SetErrorDef(Double_t up) {fUp = up;} + void SetPrintStatus(Bool_t okPrintStatus) { fPrintStatus = okPrintStatus; } + Bool_t GetPrintStatus() const { return fPrintStatus ; } + void SetParamStartValues (Double_t*); + Double_t* GetStartParamValues() { return fParamStartValues; } + TBits GetFixedParamList() const { return fIsParamFixed; } + TFitter *GetFitter() const {return fitter;} + Double_t GetParameter(Int_t numPar) const {return fitter->GetParameter(numPar);} + Double_t GetParameterError(Int_t numPar) const {return fitter->GetParError(numPar);} + + void FixParam(UInt_t param, Bool_t value) { fIsParamFixed.SetBitNumber(param,value); } + void FixAllParam(Bool_t value) { for(UInt_t par=0;par<49;par++) fIsParamFixed.SetBitNumber(par,value); } + Bool_t IsParamFixed(UInt_t param) { return fIsParamFixed.TestBitNumber(param); } + void SetResolutionConstants(Double_t* resolutionConst, Int_t type); + void SetCrystalBallFunction(Bool_t okCB); + void SetExponentialFunction(Bool_t okEpx); + void SetMassWndHigh(Double_t limit); + void SetMassWndLow(Double_t limit); + + Double_t operator()(const Double_t* par) const ; + void CdfFCN(Int_t & /* npar */, Double_t * /* gin */, Double_t &f, Double_t *par, Int_t /* iflag */); + + Double_t* Decaytime() const { return fX; } + Double_t* InvariantMass() const { return fM; } + Double_t* TransverseMom() const { return fPt; } + Int_t* TypeCand() const { return fType;} + AliDielectronBtoJPSItoEleCDFfitFCN* LikelihoodPointer() const { return fLikely; } + Int_t DoMinimization(Int_t step = 0); + + + private: + // + TBits fIsParamFixed; //array of bits: 0 = param free; 1 = param fixed; + Bool_t fPrintStatus; //flag to enable the prit out of the algorithm at each step + Double_t fParamStartValues[49]; //array of parameters input value + Double_t fUp; //error definition + Double_t* fX; //pseudo-proper decay time X + Double_t* fM; //invariant mass M + Double_t* fPt; //invariant mass M + Int_t* fType; //candidate type + AliDielectronBtoJPSItoEleCDFfitFCN* fLikely; //Log likelihood function + Int_t fNcand; //number of candidates + TGraph* fContPlot1; //contour plot + TGraph* fContPlot2; //contour plot + TGraph* fContPlot3; //contour plot + TFitter *fitter; //pointer to TFitter object + // + ClassDef(AliDielectronBtoJPSItoEleCDFfitHandler,1); + +}; +#endif diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_oezdemir_pp2012.C b/PWGDQ/dielectron/macrosLMEE/AddTask_oezdemir_pp2012.C index 27503f0e56a..51cd6c1485f 100644 --- a/PWGDQ/dielectron/macrosLMEE/AddTask_oezdemir_pp2012.C +++ b/PWGDQ/dielectron/macrosLMEE/AddTask_oezdemir_pp2012.C @@ -1,90 +1,90 @@ -AliAnalysisTask *AddTask_oezdemir_pp2012(Bool_t getFromAlien=kFALSE){ - - - //get the current analysis manager - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - Error("AddTask_oezdemir_pp2012", "No analysis manager found."); - return 0; - } - -//Get the current train configuration - TString trainConfig=gSystem->Getenv("CONFIG_FILE"); - TString configBasePath("$TRAIN_ROOT/oezdemir_LOWMASS/"); - TString trainRoot=gSystem->Getenv("TRAIN_ROOT"); - if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"; - - if (getFromAlien && - (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/m/mozdemir/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C")) - ) { - configBasePath=Form("%s/",gSystem->pwd()); - } - - TString configFile("Configpp2012Oezdemir.C"); - - TString configFilePath(configBasePath+configFile); - - //Do we have an MC handler? - Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); - - - //create task and add it to the manager - AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData"); - if (!hasMC) task->UsePhysicsSelection(); - -//Add event filter -AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); -eventCuts->SetRequireVertex(); -eventCuts->SetVertexZ(-10.,10.); -eventCuts->SetMinVtxContributors(1); - - task->SetEventFilter(eventCuts); - //2012 Min Bias? - task->SetTriggerMask(AliVEvent::kINT7+AliVEvent::kMB+AliVEvent::kINT8); - - mgr->AddTask(task); - - - //load dielectron configuration file - gROOT->LoadMacro(configFilePath.Data()); - - //If MC available decide which pdg codes are tested: - - AliDielectron *lowmass0=Configpp2012Oezdemir(0,hasMC); - task->AddDielectron(lowmass0); - printf("add: %s\n",lowmass0->GetName()); - - //create output container - AliAnalysisDataContainer *coutput1 = - mgr->CreateContainer("oezdemir_pp2012_tree", - TTree::Class(), - AliAnalysisManager::kExchangeContainer, - "LMEEoutput.root"); - - AliAnalysisDataContainer *cOutputHist1 = - mgr->CreateContainer("oezdemir_pp2012_out", - TList::Class(), - AliAnalysisManager::kOutputContainer, - "LMEEoutput.root"); - - AliAnalysisDataContainer *cOutputHist2 = - mgr->CreateContainer("oezdemir_pp2012_CF", - TList::Class(), - AliAnalysisManager::kOutputContainer, - "LMEEoutput.root"); - - AliAnalysisDataContainer *cOutputHist3 = - mgr->CreateContainer("oezdemir_pp2012_EventStat", - TH1D::Class(), - AliAnalysisManager::kOutputContainer, - "LMEEoutput.root"); - - - mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task, 0, coutput1 ); - mgr->ConnectOutput(task, 1, cOutputHist1); - mgr->ConnectOutput(task, 2, cOutputHist2); - mgr->ConnectOutput(task, 3, cOutputHist3); - - return task; -} +AliAnalysisTask *AddTask_oezdemir_pp2012(Bool_t getFromAlien=kFALSE){ + + + //get the current analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + Error("AddTask_oezdemir_pp2012", "No analysis manager found."); + return 0; + } + +//Get the current train configuration + TString trainConfig=gSystem->Getenv("CONFIG_FILE"); + TString configBasePath("$TRAIN_ROOT/oezdemir_LOWMASS/"); + TString trainRoot=gSystem->Getenv("TRAIN_ROOT"); + if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"; + + if (getFromAlien && + (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/m/mozdemir/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C")) + ) { + configBasePath=Form("%s/",gSystem->pwd()); + } + + TString configFile("Configpp2012Oezdemir.C"); + + TString configFilePath(configBasePath+configFile); + + //Do we have an MC handler? + Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); + + + //create task and add it to the manager + AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData"); + if (!hasMC) task->UsePhysicsSelection(); + +//Add event filter +AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); +eventCuts->SetRequireVertex(); +eventCuts->SetVertexZ(-10.,10.); +eventCuts->SetMinVtxContributors(1); + + task->SetEventFilter(eventCuts); + //2012 Min Bias? + task->SetTriggerMask(AliVEvent::kINT7+AliVEvent::kMB+AliVEvent::kINT8); + + mgr->AddTask(task); + + + //load dielectron configuration file + gROOT->LoadMacro(configFilePath.Data()); + + //If MC available decide which pdg codes are tested: + + AliDielectron *lowmass0=Configpp2012Oezdemir(0,hasMC); + task->AddDielectron(lowmass0); + printf("add: %s\n",lowmass0->GetName()); + + //create output container + AliAnalysisDataContainer *coutput1 = + mgr->CreateContainer("oezdemir_pp2012_tree", + TTree::Class(), + AliAnalysisManager::kExchangeContainer, + "LMEEoutput.root"); + + AliAnalysisDataContainer *cOutputHist1 = + mgr->CreateContainer("oezdemir_pp2012_out", + TList::Class(), + AliAnalysisManager::kOutputContainer, + "LMEEoutput.root"); + + AliAnalysisDataContainer *cOutputHist2 = + mgr->CreateContainer("oezdemir_pp2012_CF", + TList::Class(), + AliAnalysisManager::kOutputContainer, + "LMEEoutput.root"); + + AliAnalysisDataContainer *cOutputHist3 = + mgr->CreateContainer("oezdemir_pp2012_EventStat", + TH1D::Class(), + AliAnalysisManager::kOutputContainer, + "LMEEoutput.root"); + + + mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task, 0, coutput1 ); + mgr->ConnectOutput(task, 1, cOutputHist1); + mgr->ConnectOutput(task, 2, cOutputHist2); + mgr->ConnectOutput(task, 3, cOutputHist3); + + return task; +} diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPb.C b/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPb.C index d1997fe0e17..14332a798d0 100644 --- a/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPb.C +++ b/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPb.C @@ -1,79 +1,79 @@ -AliAnalysisTask *AddTask_shin_pPb(){ - //get the current analysis manager - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - Error("AddTask_shin_pPb", "No analysis manager found."); - return 0; - } - - - //Do we have an MC handler? - Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); - - //Get the current train configuration - // TString trainConfig=gSystem->Getenv("CONFIG_FILE"); - - //set config file name - TString configBasePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"); - TString configFile("Config_shin_pPb.C"); - TString configFilePath(configBasePath+configFile); - - // TString list=gSystem->Getenv("LIST"); - //create task and add it to the manager - AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDieData"); - if (!hasMC ) task->UsePhysicsSelection(); - task->SetTriggerMask(AliVEvent::kINT7); - mgr->AddTask(task); - - - //load dielectron configuration file - gROOT->LoadMacro(configFilePath.Data()); - - //add dielectron analysis with different cuts to the task - for (Int_t i=0; iAddDielectron(dile); - } - - //Add event filter - AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); - eventCuts->SetRequireVertex(); - eventCuts->SetMinVtxContributors(1); - eventCuts->SetVertexZ(-10.,10.); - task->SetEventFilter(eventCuts); - - //create output container - TString containerName = "hayashi_lowmass.root"; - AliAnalysisDataContainer *coutput1 = - mgr->CreateContainer("tree_lowmass", - TTree::Class(), - AliAnalysisManager::kExchangeContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist1 = - mgr->CreateContainer("Histos_diel_lowmass", - TList::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist2 = - mgr->CreateContainer("CF_diel_lowmass", - TList::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist3 = - mgr->CreateContainer("sweber_EventStat", - TH1D::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task, 0, coutput1 ); - mgr->ConnectOutput(task, 1, cOutputHist1); - mgr->ConnectOutput(task, 2, cOutputHist2); - mgr->ConnectOutput(task, 3, cOutputHist3); - - return task; -} +AliAnalysisTask *AddTask_shin_pPb(){ + //get the current analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + Error("AddTask_shin_pPb", "No analysis manager found."); + return 0; + } + + + //Do we have an MC handler? + Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); + + //Get the current train configuration + // TString trainConfig=gSystem->Getenv("CONFIG_FILE"); + + //set config file name + TString configBasePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"); + TString configFile("Config_shin_pPb.C"); + TString configFilePath(configBasePath+configFile); + + // TString list=gSystem->Getenv("LIST"); + //create task and add it to the manager + AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDieData"); + if (!hasMC ) task->UsePhysicsSelection(); + task->SetTriggerMask(AliVEvent::kINT7); + mgr->AddTask(task); + + + //load dielectron configuration file + gROOT->LoadMacro(configFilePath.Data()); + + //add dielectron analysis with different cuts to the task + for (Int_t i=0; iAddDielectron(dile); + } + + //Add event filter + AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); + eventCuts->SetRequireVertex(); + eventCuts->SetMinVtxContributors(1); + eventCuts->SetVertexZ(-10.,10.); + task->SetEventFilter(eventCuts); + + //create output container + TString containerName = "hayashi_lowmass.root"; + AliAnalysisDataContainer *coutput1 = + mgr->CreateContainer("tree_lowmass", + TTree::Class(), + AliAnalysisManager::kExchangeContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist1 = + mgr->CreateContainer("Histos_diel_lowmass", + TList::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist2 = + mgr->CreateContainer("CF_diel_lowmass", + TList::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist3 = + mgr->CreateContainer("sweber_EventStat", + TH1D::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task, 0, coutput1 ); + mgr->ConnectOutput(task, 1, cOutputHist1); + mgr->ConnectOutput(task, 2, cOutputHist2); + mgr->ConnectOutput(task, 3, cOutputHist3); + + return task; +} diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPbTRD.C b/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPbTRD.C index 0b351547ef3..675cf67cf23 100644 --- a/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPbTRD.C +++ b/PWGDQ/dielectron/macrosLMEE/AddTask_shin_pPbTRD.C @@ -1,91 +1,91 @@ -AliAnalysisTask *AddTask_shin_pPbTRD(){ - //get the current analysis manager - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - Error("AddTask_sweber_JPsi_pPb_TRDtrigger", "No analysis manager found."); - return 0; - } - - - //Do we have an MC handler? - Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); - - //Get the current train configuration - // TString trainConfig=gSystem->Getenv("CONFIG_FILE"); - - //set config file name - TString configBasePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"); - TString configFile("Config_shin_pPbTRD.C"); - TString configFilePath(configBasePath+configFile); - - - - - // TString list=gSystem->Getenv("LIST"); - //create task and add it to the manager - AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDieDataTRDtrigger"); - if (!hasMC ) task->UsePhysicsSelection();//taking out for testing - task->SetTriggerMask(AliVEvent::kTRD); - task->SetFiredTriggerName("CINT7WUHJT-B-NOPF-CENT",kTRUE); - //task->SetTRDtrigger(3); - // task->SetFiredTriggerName("HQU",kFALSE);//take not kTRUE in order not to get both triggers, exclude (since not yet otherwise possible) - // - //not yet implemented to get a logical or of 2 different trigger classes, therefore exclude HJT, not exactly what I want... - // if (list.Contains("LHC11d")) task->SetTriggerMask(AliVEvent::kEMCEJE+AliVEvent::kEMC7+AliVEvent::kEMCEGA); - //if (list.Contains("LHC12h")) task->SetTRDtrigger(1+2); - mgr->AddTask(task); - - - //load dielectron configuration file - gROOT->LoadMacro(configFilePath.Data()); - - //add dielectron analysis with different cuts to the task - for (Int_t i=0; iAddDielectron(dile); - } - - //Add event filter - AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); - eventCuts->SetRequireVertex();//NOTE: all of these cuts can for some reasons not be applied to self-filtered AODs by mwinn in - //(list/hera/alice/mwinn/mwinn/train/lists/...) - eventCuts->SetMinVtxContributors(1); - eventCuts->SetVertexZ(-10.,10.); - task->SetEventFilter(eventCuts); - - - //create output container - TString containerName = "hayashi_lowmass.root"; - AliAnalysisDataContainer *coutput1 = - mgr->CreateContainer("tree_lowmass", - TTree::Class(), - AliAnalysisManager::kExchangeContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist1 = - mgr->CreateContainer("Histos_diel_lowmass", - TList::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist2 = - mgr->CreateContainer("CF_diel_lowmass", - TList::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - AliAnalysisDataContainer *cOutputHist3 = - mgr->CreateContainer("sweber_EventStat", - TH1D::Class(), - AliAnalysisManager::kOutputContainer, - containerName.Data()); - - mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task, 0, coutput1 ); - mgr->ConnectOutput(task, 1, cOutputHist1); - mgr->ConnectOutput(task, 2, cOutputHist2); - mgr->ConnectOutput(task, 3, cOutputHist3); - - return task; -} +AliAnalysisTask *AddTask_shin_pPbTRD(){ + //get the current analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + Error("AddTask_sweber_JPsi_pPb_TRDtrigger", "No analysis manager found."); + return 0; + } + + + //Do we have an MC handler? + Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0); + + //Get the current train configuration + // TString trainConfig=gSystem->Getenv("CONFIG_FILE"); + + //set config file name + TString configBasePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/"); + TString configFile("Config_shin_pPbTRD.C"); + TString configFilePath(configBasePath+configFile); + + + + + // TString list=gSystem->Getenv("LIST"); + //create task and add it to the manager + AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDieDataTRDtrigger"); + if (!hasMC ) task->UsePhysicsSelection();//taking out for testing + task->SetTriggerMask(AliVEvent::kTRD); + task->SetFiredTriggerName("CINT7WUHJT-B-NOPF-CENT",kTRUE); + //task->SetTRDtrigger(3); + // task->SetFiredTriggerName("HQU",kFALSE);//take not kTRUE in order not to get both triggers, exclude (since not yet otherwise possible) + // + //not yet implemented to get a logical or of 2 different trigger classes, therefore exclude HJT, not exactly what I want... + // if (list.Contains("LHC11d")) task->SetTriggerMask(AliVEvent::kEMCEJE+AliVEvent::kEMC7+AliVEvent::kEMCEGA); + //if (list.Contains("LHC12h")) task->SetTRDtrigger(1+2); + mgr->AddTask(task); + + + //load dielectron configuration file + gROOT->LoadMacro(configFilePath.Data()); + + //add dielectron analysis with different cuts to the task + for (Int_t i=0; iAddDielectron(dile); + } + + //Add event filter + AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0"); + eventCuts->SetRequireVertex();//NOTE: all of these cuts can for some reasons not be applied to self-filtered AODs by mwinn in + //(list/hera/alice/mwinn/mwinn/train/lists/...) + eventCuts->SetMinVtxContributors(1); + eventCuts->SetVertexZ(-10.,10.); + task->SetEventFilter(eventCuts); + + + //create output container + TString containerName = "hayashi_lowmass.root"; + AliAnalysisDataContainer *coutput1 = + mgr->CreateContainer("tree_lowmass", + TTree::Class(), + AliAnalysisManager::kExchangeContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist1 = + mgr->CreateContainer("Histos_diel_lowmass", + TList::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist2 = + mgr->CreateContainer("CF_diel_lowmass", + TList::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + AliAnalysisDataContainer *cOutputHist3 = + mgr->CreateContainer("sweber_EventStat", + TH1D::Class(), + AliAnalysisManager::kOutputContainer, + containerName.Data()); + + mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task, 0, coutput1 ); + mgr->ConnectOutput(task, 1, cOutputHist1); + mgr->ConnectOutput(task, 2, cOutputHist2); + mgr->ConnectOutput(task, 3, cOutputHist3); + + return task; +} diff --git a/PWGDQ/dielectron/macrosLMEE/Config_shin_pPbTRD.C b/PWGDQ/dielectron/macrosLMEE/Config_shin_pPbTRD.C index 98d1c0987c3..e49551396d8 100644 --- a/PWGDQ/dielectron/macrosLMEE/Config_shin_pPbTRD.C +++ b/PWGDQ/dielectron/macrosLMEE/Config_shin_pPbTRD.C @@ -1,516 +1,516 @@ -void InitHistograms(AliDielectron *die, Int_t cutDefinition); -void InitCF(AliDielectron* die, Int_t cutDefinition); - -//void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition); - -void SetupTrackCuts(AliDielectron*die, Int_t cutDefinition); -void SetupPairCuts(AliDielectron*die, Int_t cutDefinition); - - -Bool_t kRot = 0; -Bool_t kMix = 1; - -//start systematics -TString names= ("Phiv;Pt10;Open;Mass"); -TObjArray *arrNames=names.Tokenize(";"); -const Int_t nDie=arrNames->GetEntriesFast(); - -AliDielectron* Config_shin_pPbTRD(Int_t cutDefinition=1) -{ - // - // Setup the instance of AliDielectron - // - - // create the actual framework object - TString name=Form("%02d",cutDefinition); - if (cutDefinitionGetEntriesFast()){ - name=arrNames->At(cutDefinition)->GetName(); - } - AliDielectron *die = - new AliDielectron(Form("%s",name.Data()), - Form("Track cuts: %s",name.Data())); - - - if(kRot){ - AliDielectronTrackRotator *rot = new AliDielectronTrackRotator; - rot->SetConeAnglePhi(TMath::Pi()); - rot->SetIterations(10); - die->SetTrackRotator(rot); - }//kRot - - - if(kMix){ - AliDielectronMixingHandler *mix = new AliDielectronMixingHandler; - mix->SetMixType(AliDielectronMixingHandler::kAll); - mix->AddVariable(AliDielectronVarManager::kZvPrim,"-10., -7.5, -5., -2.5 , 0., 2.5, 5., 7.5 , 10."); - mix->SetDepth(10); - die->SetMixingHandler(mix); - }//kMix - - - // set track cuts - SetupTrackCuts(die,cutDefinition); - SetupPairCuts(die,cutDefinition); - - // histogram setup - // only if an AliDielectronHistos object is attached to the - // dielectron framework histograms will be filled - InitHistograms(die,cutDefinition); - // if(cutDefinition==0){ - // InitCF(die,cutDefinition); - //} - - return die; - -} - -//______________________________________________________________________________________ -void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition) -{ - // - // Setup the track cuts - // - //pairing with TLorentzVector - // die->SetUseKF(kFALSE); - //options - die->SetPreFilterAllSigns(); - - - - AliDielectronVarCuts *varkinCuts = new AliDielectronVarCuts("trackkine","trackkine"); - varkinCuts->AddCut(AliDielectronVarManager::kPt,0.4,100.); - if(cutDefinition==2){ - varkinCuts->AddCut(AliDielectronVarManager::kPt,1.,100.); - } - // if(cutDefinition==3){ - // varkinCuts->AddCut(AliDielectronVarManager::kPt,1.,100.); - // } - varkinCuts->AddCut(AliDielectronVarManager::kEta,-0.8,0.8); - die->GetTrackFilter().AddCuts(varkinCuts); - - AliDielectronTrackCuts *TrackCuts = new AliDielectronTrackCuts("StandardCuts","StandardCut"); - //refit - TrackCuts->SetRequireTPCRefit(kTRUE); - TrackCuts->SetRequireITSRefit(kTRUE); - //SPD require - // if(cutDefinition == 0 ) - TrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst); - die->GetTrackFilter().AddCuts(TrackCuts); - - - AliDielectronVarCuts *varCuts = new AliDielectronVarCuts("trackkineandTPCQ","trackkine_and_TPC"); - varCuts->AddCut(AliDielectronVarManager::kPt,0.2,100.); - varCuts->AddCut(AliDielectronVarManager::kEta,-0.8,0.8); - varCuts->AddCut(AliDielectronVarManager::kImpactParZ,-3.,3.); - varCuts->AddCut(AliDielectronVarManager::kImpactParXY,-1.,1.); - varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,0.); - - varCuts->AddCut(AliDielectronVarManager::kNclsITS,3.,7.); - - varCuts->AddCut(AliDielectronVarManager::kNclsTPC,80.,500.); - varCuts->AddCut(AliDielectronVarManager::kNFclsTPCr,100.,500.); // or NFclsTPCr? - varCuts->AddCut(AliDielectronVarManager::kNFclsTPCfCross,0.5,500.); - varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,0.,4.); - die->GetTrackFilter().AddCuts(varCuts); - - // if(cutDefinition > 2){ - AliDielectronPID *pid = new AliDielectronPID("pid","pid"); - pid->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,100.,kFALSE); - pid->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,3.,0.2,100.,kTRUE); - pid->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3.,3.,0.4, 5., kFALSE); - die->GetTrackFilter().AddCuts(pid); - // } - - // } - // if(cutDefinition>0){ - - AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("V0","V0"); - gammaV0Cuts->SetPdgCodes(22,11,11); - gammaV0Cuts->SetDefaultPID(16); - gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02), 1.0, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kChi2NDF, 0.0, 10.0, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kLegDist, 0.0, 0.25, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kR, 3.0, 90.0, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kPsiPair, 0.0, 0.05, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kM, 0.0, 0.05, kFALSE); - // gammaV0Cuts->AddCut(AliDielectronVarManager::kOpeningAngle, 0.0, 0.1, kFALSE); - gammaV0Cuts->AddCut(AliDielectronVarManager::kArmPt, 0.0, 0.05, kFALSE); - // gammaV0Cuts->AddCut(AliDielectronVarManager::kArmAlpha, -0.35, 0.35, kFALSE); // not sure if it works as expected - gammaV0Cuts->SetExcludeTracks(kTRUE); - gammaV0Cuts->Print(); - - // const Double_t |cutAlphaG| < 0.35; && const Double_t cutQTG < 0.05; - // const Double_t |cutAlphaG2|[2] = {0.6, 0.8}; && const Double_t cutQTG2 < 0.04; - - // if(cuts) - // ((AliDielectronCutGroup*)cuts)->AddCut(gammaV0Cuts); - // else - die->GetTrackFilter().AddCuts(gammaV0Cuts); - - - // } - -} -//----------------------------------Pair Cut------------------------------------------- -void SetupPairCuts(AliDielectron *die, Int_t cutDefinition) -{ - // if(cutDefinition > ){ - AliDielectronVarCuts *PhiV = new AliDielectronVarCuts("PhiV","PhiV");//mass and Phiv together - PhiV->AddCut(AliDielectronVarManager::kM, 0. , 0.05); - PhiV->AddCut(AliDielectronVarManager::kPhivPair, 2.5 , 3.2); - die->GetPairPreFilter().AddCuts(PhiV); - // } - if(cutDefinition==2){ - AliDielectronVarCuts *Open = new AliDielectronVarCuts("Open","Open");//mass and Phiv together - Open->AddCut(AliDielectronVarManager::kM, 0. , 0.1); - Open->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.1); - die->GetPairPreFilter().AddCuts(Open); - - } - if(cutDefinition==3){ - AliDielectronVarCuts *Mcut = new AliDielectronVarCuts("Mcut","Mcut");//mass and Phiv together - Mcut->AddCut(AliDielectronVarManager::kM, 0. , 0.1); - // Open->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.1); - die->GetPairPreFilter().AddCuts(Mcut); - - } - -} - -//______________________________________________________________________________________ -void InitHistograms(AliDielectron *die, Int_t cutDefinition) -{ - // - // Initialise the histograms - // - - //Setup histogram classes - AliDielectronHistos *histos= - new AliDielectronHistos(die->GetName(), - die->GetTitle()); - - //Initialise histogram classes - histos->SetReservedWords("Track;Pair"); - - //Event class - histos->AddClass("Event"); - - //Track classes - //to fill also track info from 2nd event loop until 2 - for (Int_t i=0; i<2; ++i){ - histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i))); - } - - //Pair classes - // to fill also mixed event histograms loop until 10 - for (Int_t i=0; i<3; ++i){ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i))); - } - - // histos->AddClass(Form("Pair_%s","lowMassDiele")); - - if(kMix){ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3))); //ME ++ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));//ME -+ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));//ME +- - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7))); // ME -- - } - - if(kRot)histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(10)));//Rot - - - //add histograms to event class - histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",1,0,1,AliDielectronVarManager::kNevents); - histos->UserHistogram("Event","ZVertex","ZVertex;ZVertex/cm",480,-12.,12.,AliDielectronVarManager::kZvPrim); - histos->UserHistogram("Event","nESDTracks","ESD tracks;ESD tracks;Number events",100,0,200,AliDielectronVarManager::kTracks); - histos->UserHistogram("Event","Nacc","Number of accepted tracks;Number events",100,0,200,AliDielectronVarManager::kNacc); - histos->UserHistogram("Event","NVtxContrib","Number of Vertex Contributor;NVtx;Number events",100,0,100,AliDielectronVarManager::kNVtxContrib); - - - //add histograms to Track classes - histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",1000,0.,10.,AliDielectronVarManager::kPt); - // histos->UserHistogram("Track","Pt_bin2","Pt;Pt [GeV];#tracks", - // "0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,2.,3.,4.,5.,6.,8.,10" - // ,AliDielectronVarManager::kPt); - // histos->UserHistogram("Track","Eta","Eta; Eta ;#tracks",100,-1.,1.,AliDielectronVarManager::kEta); - // histos->UserHistogram("Track","Phi","Phi; Phi ;#tracks",640,0.,6.4,AliDielectronVarManager::kPhi); - - // histos->UserHistogram("Track","Pt_Eta_Phi","Pt",100,0.,10.,100,-1,1,320,0,6.4,AliDielectronVarManager::kPt,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); - - //histos->UserHistogram("Track","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",160,-0.5,159.5,AliDielectronVarManager::kNclsTPC); - //histos->UserHistogram("Track","nClsoverfindablecluster","Number of found Clusters TPC over findably ;TPC number cluster over findable;#tracks",160,0.0,1.1,AliDielectronVarManager::kNFclsTPCrFrac); - //histos->UserHistogram("Track","Eta_phi","Eta vs Phi;Eta;Phi",100,-1.,1.,320,0.,6.4,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); - histos->UserHistogram("Track","Eta_pt","Eta vs Pt;Eta;Pt",100,-1.,1.,500,0.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kPt); - histos->UserHistogram("Track","Phi_pt","Eta vs Pt;Phi;Pt",640,0.,6.4,500,0.,10.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kPt); - histos->UserHistogram("Track","Eta_Phi","Eta vs Phi;Phi;Pt",640,0.,6.4,200,-1.,1.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kEta); - histos->UserHistogram("Track","TOFnSigma_MomEle","TOF number of sigmas Electrons vs Momentum;Mom;TOFsigmaEle",500,0.,5.,700,-30,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaEle); - histos->UserHistogram("Track","TPCdEdx_P","dEdx;P [GeV];TPC signal (arb units) vs Momentum;Mom;TPCsignal", 1000,0,10.,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal); - histos->UserHistogram("Track","TPCnSigma_P","TPC number of sigmas Electrons vs Eta;Eta;TPCsigmaEle",100,0.,10.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle); - //histos->UserHistogram("Track","TPCnSigma_Eta","TPC number of sigmas Electrons vs Eta;Eta;TPCsigmaEle",800,-0.8.,0.8.,800,-40,40,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle); - //histos->UserHistogram("Track","TPCdEdx_Eta","TPC dEdx vs Eta;Eta;TPCsigmaEle",800,-0.8,0.8,800,0,200,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCsignal); - //histos->UserHistogram("Track","TPCnSigma_Phi","TPC number of sigmas Electrons vs Phi;Phi;TPCsigmaEle",640,0.,6.4,800,-40,40,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCnSigmaEle); - // histos->UserHistogram("Track","TPCdEdx_Phi","TPC dEdx vs Phi;Phi;TPCsigmaEle",640,0.,6.4,800,0,200,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCsignal); - - - - //add histograms to Pair classes - - // histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs", - // 500,0,4,AliDielectronVarManager::kM); - - // histos->UserHistogram("Pair","InvMass_low","Inv.Mass;Inv. Mass [GeV];#pairs", - // 500,0,0.5,AliDielectronVarManager::kM); - /* - histos->UserHistogram("Pair","kDeltaEta","kDeltaEta;kDeltaEta;#pairs", - 160,0.,1.6,AliDielectronVarManager::kDeltaEta); - histos->UserHistogram("Pair","kDeltaPhi","kDeltaPhi;kDeltaPhi;#pairs", - 320,0.,6.4,AliDielectronVarManager::kDeltaPhi); - histos->UserHistogram("Pair","PhiV",";PhiV;#pairs", - 320,0.,6.4,AliDielectronVarManager::kPhivPair); - histos->UserHistogram("Pair","InvMass_bin2","Inv.Mass;Inv. Mass [GeV];#pairs", - "0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , - 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , - 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , - 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , - 3.3 , 3.5, 3.75 , 4.0",AliDielectronVarManager::kM); - histos->UserHistogram("Pair", - "InvMass_Pt","InvMass_Pt;InvMass;Pt", - 500, 0. , 4., 100 , 0., 5. , - AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); - */ - histos->UserHistogram("Pair", - "InvMass_Pt","InvMass_Pt;InvMass;Pt", - 400, 0. , 4., 1000 , 0., 10. , - AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); - histos->UserHistogram("Pair", - "InvMass_Eta","InvMass_Eta;InvMass;Eta", - 400, 0. , 4., 200 , -1., 1. , - AliDielectronVarManager::kM , AliDielectronVarManager::kEta ); - histos->UserHistogram("Pair", - "InvMass_PhivPair","InvMass_PhivPair;InvMass;PhivPair", - 400, 0. , 4., 320 , 0., 3.2 , - AliDielectronVarManager::kM , AliDielectronVarManager::kPhivPair ); - histos->UserHistogram("Pair", - "InvMass_dPhi","InvMass_PhivPair;InvMass;PhivPair", - 400, 0. , 4., 320 , 0., 3.2 , - AliDielectronVarManager::kM , AliDielectronVarManager::kDeltaPhi ); - histos->UserHistogram("Pair", - "InvMass_OpenAng","OpAngle_InvMass;Opening angle;Invariant Mass", - 400 , 0. , 4. , 320, 0. , 3.2, - AliDielectronVarManager::kM, AliDielectronVarManager::kOpeningAngle); - - - /* - histos->UserHistogram("Pair", - "Y_PtPair","InvMass_PhivPair;InvMass;PhivPair", - 120, -1.2. , 1.2, 100 , 0., 5. , - AliDielectronVarManager::kY , AliDielectronVarManager::kPt ); - histos->UserHistogram("Pair", - "OpAngle","Opening angle;Opening angle;#pairs", - 320, 0. , 3.2, - AliDielectronVarManager::kOpeningAngle); - histos->UserHistogram("Pair", - "OpAngle_InvMass","OpAngle_InvMass;Opening angle;Invariant Mass", - 320, 0. , 3.2, 500 , 0. , 4. , - AliDielectronVarManager::kOpeningAngle,AliDielectronVarManager::kM); - histos->UserHistogram("Pair", - "Phi","Phi;counts;Phi", - 320, 0. , 6.4, AliDielectronVarManager::kPhi); - histos->UserHistogram("Pair", - "Y","Y;counts;Y", - 120, -1.2 , 1.2, AliDielectronVarManager::kY); - histos->UserHistogram("Pair", - "Pt","Pt;counts;Pt", - 500, 0 , 10, AliDielectronVarManager::kPt); - */ - die->SetHistogramManager(histos); - -} - - - - -void InitCF(AliDielectron* die, Int_t cutDefinition) -{ - // - // Setup the CF Manager if needed - // - - AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle()); - - //pair variables - // cf->AddVariable(AliDielectronVarManager::kM,500,0.,4.); - cf->AddVariable(AliDielectronVarManager::kM,"0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , - 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , - 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , - 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , - 3.3 , 3.5, 3.75 , 4.0");//data - cf->AddVariable(AliDielectronVarManager::kM,500,0.,5.); - cf->AddVariable(AliDielectronVarManager::kM,500,0.,0.1); - // cf->AddVariable(AliDielectronVarManager::kM,500,0.,0.1); - cf->AddVariable(AliDielectronVarManager::kY,20,-1.,1.); - cf->AddVariable(AliDielectronVarManager::kR,500,0.,100.); - cf->AddVariable(AliDielectronVarManager::kPhi,32, 0., 3.2); - cf->AddVariable(AliDielectronVarManager::kPt,100,0.,5.); - cf->AddVariable(AliDielectronVarManager::kPt,"0.,0.2,0.3,0.4,0.5,0.6,0.8,1.0,1.25,1.5,1.75,2.0,3.,5."); - cf->AddVariable(AliDielectronVarManager::kOpeningAngle,62,0.,6.2); - cf->AddVariable(AliDielectronVarManager::kPhivPair,64, 0., 6.4); - cf->AddVariable(AliDielectronVarManager::kPairType,4,-0.5,3.5); - - - cf->AddVariable(AliDielectronVarManager::kEta,40,-1.,1.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kCharge,40,-2.,2.,kTRUE); - //leg - cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kPhi,36,0.,360.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kEta,100,-1.,1.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,20,-3.,4.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kTPCsignal,"40,50,55,60,65,68,70,72,75,80,90,100,110,120",kTRUE); - // cf->AddVariable(AliDielectronVarManager::kTPCsignal,200,0.,200.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kNFclsTPCr,200,0.,200.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kNFclsTPCfCross,200,0.,2.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kTPCchi2Cl,200,0.,10.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kImpactParXY,400,-.5,.5,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kImpactParZ,400,-2.,2.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kNclsITS,10,0.,10.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kNFclsTPCrFrac,10,0.,1.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE); - cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE); - - - if(cutDefinition==0){ - cf->SetStepForMCtruth(); - } - cf->SetStepForAfterAllCuts(); - cf->SetStepsForSignal(); - die->SetCFManagerPair(cf); - - - //primary - AliDielectronSignalMC* DielePrimary=new - AliDielectronSignalMC("Diele Primary","low mass primary dielectron pairs"); - DielePrimary->SetLegPDGs(11,-11); - DielePrimary->SetCheckBothChargesLegs(kTRUE,kTRUE); - DielePrimary->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - //DielePrimary->SetFillPureMCStep(kTRUE); - die->AddSignalMC(DielePrimary); - - // secondary - AliDielectronSignalMC* secsec = new - AliDielectronSignalMC("Secondarypairs","secondary electron pairs"); // pairs made from conversion (may be also from 2 different conversions) - secsec->SetLegPDGs(11,-11); - secsec->SetCheckBothChargesLegs(kTRUE,kTRUE); - secsec->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary); - // secsec->SetFillPureMCStep(kTRUE); - die->AddSignalMC(secsec); - - // secondary-primary - AliDielectronSignalMC* DielePriSec=new - AliDielectronSignalMC("Diele Prim-Sec","low mass prim-sec dielectron pairs"); - DielePriSec->SetLegPDGs(11,-11); - DielePriSec->SetCheckBothChargesLegs(kTRUE,kTRUE); - DielePriSec->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kSecondary); - //DielePriSec->SetFillPureMCStep(kTRUE); - die->AddSignalMC(DielePriSec); - - /* - AliDielectronSignalMC* DielePrimary=new - AliDielectronSignalMC("Diele Primary","low mass primary dielectron pairs"); - DielePrimary->SetLegPDGs(11,-11); - DielePrimary->SetCheckBothChargesLegs(kTRUE,kTRUE); - DielePrimary->SetLegSources(AliDielectronSignalMC::kFinalState, - AliDielectronSignalMC::kFinalState); - DielePrimary->SetMothersRelation(AliDielectronSignalMC::kSame); - DielePrimary->SetFillPureMCStep(kTRUE); - die->AddSignalMC(DielePrimary); - */ - - AliDielectronSignalMC* pi0 = new AliDielectronSignalMC("pi0dalitz","pi0dalitz"); - pi0->SetLegPDGs(11,-11); - pi0->SetMotherPDGs(111,111); - pi0->SetMothersRelation(AliDielectronSignalMC::kSame); - pi0->SetLegSources(AliDielectronSignalMC::kFinalState,AliDielectronSignalMC::kFinalState); - pi0->SetCheckBothChargesLegs(kTRUE,kTRUE); - pi0->SetCheckBothChargesMothers(kTRUE,kTRUE); - pi0->SetFillPureMCStep(kTRUE); - die->AddSignalMC(pi0); - - AliDielectronSignalMC* etaSig = new AliDielectronSignalMC("Eta", "etaSignal"); ///eta dalitz pairs - etaSig->SetLegPDGs(11,-11); - etaSig->SetMotherPDGs(221,221); - etaSig->SetMothersRelation(AliDielectronSignalMC::kSame); - etaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - etaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); - etaSig->SetCheckBothChargesLegs(kTRUE,kTRUE); - etaSig->SetCheckBothChargesMothers(kTRUE,kTRUE); - etaSig->SetFillPureMCStep(kTRUE); - die->AddSignalMC(etaSig); - - AliDielectronSignalMC* etaprimeSig = new AliDielectronSignalMC("Etaprime", "etaprimeSignal"); ///etaprime pairs - etaprimeSig->SetLegPDGs(11,-11); - etaprimeSig->SetMotherPDGs(331,331); - etaprimeSig->SetMothersRelation(AliDielectronSignalMC::kSame); - etaprimeSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - etaprimeSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); - etaprimeSig->SetCheckBothChargesLegs(kTRUE,kTRUE); - etaprimeSig->SetCheckBothChargesMothers(kTRUE,kTRUE); - etaprimeSig->SetFillPureMCStep(kTRUE); - die->AddSignalMC(etaprimeSig); - - AliDielectronSignalMC* rhoSig = new AliDielectronSignalMC("Rho", "rhoSignal"); ///rho pairs - rhoSig->SetLegPDGs(11,-11); - rhoSig->SetMotherPDGs(113,113); - rhoSig->SetMothersRelation(AliDielectronSignalMC::kSame); - rhoSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - rhoSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); - rhoSig->SetCheckBothChargesLegs(kTRUE,kTRUE); - rhoSig->SetCheckBothChargesMothers(kTRUE,kTRUE); - rhoSig->SetFillPureMCStep(kTRUE); - die->AddSignalMC(rhoSig); - - AliDielectronSignalMC* omegaSig = new AliDielectronSignalMC("Omega", "omegaSignal"); ///omega pairs - omegaSig->SetLegPDGs(11,-11); - omegaSig->SetMotherPDGs(223,223); - omegaSig->SetMothersRelation(AliDielectronSignalMC::kSame); - omegaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - omegaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); - omegaSig->SetCheckBothChargesLegs(kTRUE,kTRUE); - omegaSig->SetCheckBothChargesMothers(kTRUE,kTRUE); - omegaSig->SetFillPureMCStep(kTRUE); - die->AddSignalMC(omegaSig); - - AliDielectronSignalMC* phiSig = new AliDielectronSignalMC("Phi", "phiSignal"); ///phi pairs - phiSig->SetLegPDGs(11,-11); - phiSig->SetMotherPDGs(333,333); - phiSig->SetMothersRelation(AliDielectronSignalMC::kSame); - phiSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - phiSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); - phiSig->SetCheckBothChargesLegs(kTRUE,kTRUE); - phiSig->SetCheckBothChargesMothers(kTRUE,kTRUE); - phiSig->SetFillPureMCStep(kTRUE); - die->AddSignalMC(phiSig); - - AliDielectronSignalMC* dieleOpenCharm = new AliDielectronSignalMC("dieleOpenCharm", "dieleOpenCharm"); - dieleOpenCharm->SetLegPDGs(11,-11); - dieleOpenCharm->SetMotherPDGs(402,402); - dieleOpenCharm->SetLegSources(AliDielectronSignalMC::kFinalState,AliDielectronSignalMC::kFinalState); - dieleOpenCharm->SetCheckBothChargesLegs(kTRUE,kTRUE); - dieleOpenCharm->SetCheckBothChargesMothers(kTRUE,kTRUE); - dieleOpenCharm->SetFillPureMCStep(kTRUE); - die->AddSignalMC(dieleOpenCharm); - - AliDielectronSignalMC* diEleCharm = new AliDielectronSignalMC("diEleCharm","di-electrons from charm"); // dielectrons originating from charm hadrons (not neccessary from same mother) - diEleCharm->SetLegPDGs(11,-11); - diEleCharm->SetMotherPDGs(403,403); - diEleCharm->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); - diEleCharm->SetCheckBothChargesLegs(kTRUE,kTRUE); - diEleCharm->SetFillPureMCStep(kTRUE); - die->AddSignalMC(diEleCharm); - - -} - - - - - +void InitHistograms(AliDielectron *die, Int_t cutDefinition); +void InitCF(AliDielectron* die, Int_t cutDefinition); + +//void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition); + +void SetupTrackCuts(AliDielectron*die, Int_t cutDefinition); +void SetupPairCuts(AliDielectron*die, Int_t cutDefinition); + + +Bool_t kRot = 0; +Bool_t kMix = 1; + +//start systematics +TString names= ("Phiv;Pt10;Open;Mass"); +TObjArray *arrNames=names.Tokenize(";"); +const Int_t nDie=arrNames->GetEntriesFast(); + +AliDielectron* Config_shin_pPbTRD(Int_t cutDefinition=1) +{ + // + // Setup the instance of AliDielectron + // + + // create the actual framework object + TString name=Form("%02d",cutDefinition); + if (cutDefinitionGetEntriesFast()){ + name=arrNames->At(cutDefinition)->GetName(); + } + AliDielectron *die = + new AliDielectron(Form("%s",name.Data()), + Form("Track cuts: %s",name.Data())); + + + if(kRot){ + AliDielectronTrackRotator *rot = new AliDielectronTrackRotator; + rot->SetConeAnglePhi(TMath::Pi()); + rot->SetIterations(10); + die->SetTrackRotator(rot); + }//kRot + + + if(kMix){ + AliDielectronMixingHandler *mix = new AliDielectronMixingHandler; + mix->SetMixType(AliDielectronMixingHandler::kAll); + mix->AddVariable(AliDielectronVarManager::kZvPrim,"-10., -7.5, -5., -2.5 , 0., 2.5, 5., 7.5 , 10."); + mix->SetDepth(10); + die->SetMixingHandler(mix); + }//kMix + + + // set track cuts + SetupTrackCuts(die,cutDefinition); + SetupPairCuts(die,cutDefinition); + + // histogram setup + // only if an AliDielectronHistos object is attached to the + // dielectron framework histograms will be filled + InitHistograms(die,cutDefinition); + // if(cutDefinition==0){ + // InitCF(die,cutDefinition); + //} + + return die; + +} + +//______________________________________________________________________________________ +void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition) +{ + // + // Setup the track cuts + // + //pairing with TLorentzVector + // die->SetUseKF(kFALSE); + //options + die->SetPreFilterAllSigns(); + + + + AliDielectronVarCuts *varkinCuts = new AliDielectronVarCuts("trackkine","trackkine"); + varkinCuts->AddCut(AliDielectronVarManager::kPt,0.4,100.); + if(cutDefinition==2){ + varkinCuts->AddCut(AliDielectronVarManager::kPt,1.,100.); + } + // if(cutDefinition==3){ + // varkinCuts->AddCut(AliDielectronVarManager::kPt,1.,100.); + // } + varkinCuts->AddCut(AliDielectronVarManager::kEta,-0.8,0.8); + die->GetTrackFilter().AddCuts(varkinCuts); + + AliDielectronTrackCuts *TrackCuts = new AliDielectronTrackCuts("StandardCuts","StandardCut"); + //refit + TrackCuts->SetRequireTPCRefit(kTRUE); + TrackCuts->SetRequireITSRefit(kTRUE); + //SPD require + // if(cutDefinition == 0 ) + TrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst); + die->GetTrackFilter().AddCuts(TrackCuts); + + + AliDielectronVarCuts *varCuts = new AliDielectronVarCuts("trackkineandTPCQ","trackkine_and_TPC"); + varCuts->AddCut(AliDielectronVarManager::kPt,0.2,100.); + varCuts->AddCut(AliDielectronVarManager::kEta,-0.8,0.8); + varCuts->AddCut(AliDielectronVarManager::kImpactParZ,-3.,3.); + varCuts->AddCut(AliDielectronVarManager::kImpactParXY,-1.,1.); + varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,0.); + + varCuts->AddCut(AliDielectronVarManager::kNclsITS,3.,7.); + + varCuts->AddCut(AliDielectronVarManager::kNclsTPC,80.,500.); + varCuts->AddCut(AliDielectronVarManager::kNFclsTPCr,100.,500.); // or NFclsTPCr? + varCuts->AddCut(AliDielectronVarManager::kNFclsTPCfCross,0.5,500.); + varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,0.,4.); + die->GetTrackFilter().AddCuts(varCuts); + + // if(cutDefinition > 2){ + AliDielectronPID *pid = new AliDielectronPID("pid","pid"); + pid->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,100.,kFALSE); + pid->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,3.,0.2,100.,kTRUE); + pid->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3.,3.,0.4, 5., kFALSE); + die->GetTrackFilter().AddCuts(pid); + // } + + // } + // if(cutDefinition>0){ + + AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("V0","V0"); + gammaV0Cuts->SetPdgCodes(22,11,11); + gammaV0Cuts->SetDefaultPID(16); + gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02), 1.0, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kChi2NDF, 0.0, 10.0, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kLegDist, 0.0, 0.25, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kR, 3.0, 90.0, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kPsiPair, 0.0, 0.05, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kM, 0.0, 0.05, kFALSE); + // gammaV0Cuts->AddCut(AliDielectronVarManager::kOpeningAngle, 0.0, 0.1, kFALSE); + gammaV0Cuts->AddCut(AliDielectronVarManager::kArmPt, 0.0, 0.05, kFALSE); + // gammaV0Cuts->AddCut(AliDielectronVarManager::kArmAlpha, -0.35, 0.35, kFALSE); // not sure if it works as expected + gammaV0Cuts->SetExcludeTracks(kTRUE); + gammaV0Cuts->Print(); + + // const Double_t |cutAlphaG| < 0.35; && const Double_t cutQTG < 0.05; + // const Double_t |cutAlphaG2|[2] = {0.6, 0.8}; && const Double_t cutQTG2 < 0.04; + + // if(cuts) + // ((AliDielectronCutGroup*)cuts)->AddCut(gammaV0Cuts); + // else + die->GetTrackFilter().AddCuts(gammaV0Cuts); + + + // } + +} +//----------------------------------Pair Cut------------------------------------------- +void SetupPairCuts(AliDielectron *die, Int_t cutDefinition) +{ + // if(cutDefinition > ){ + AliDielectronVarCuts *PhiV = new AliDielectronVarCuts("PhiV","PhiV");//mass and Phiv together + PhiV->AddCut(AliDielectronVarManager::kM, 0. , 0.05); + PhiV->AddCut(AliDielectronVarManager::kPhivPair, 2.5 , 3.2); + die->GetPairPreFilter().AddCuts(PhiV); + // } + if(cutDefinition==2){ + AliDielectronVarCuts *Open = new AliDielectronVarCuts("Open","Open");//mass and Phiv together + Open->AddCut(AliDielectronVarManager::kM, 0. , 0.1); + Open->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.1); + die->GetPairPreFilter().AddCuts(Open); + + } + if(cutDefinition==3){ + AliDielectronVarCuts *Mcut = new AliDielectronVarCuts("Mcut","Mcut");//mass and Phiv together + Mcut->AddCut(AliDielectronVarManager::kM, 0. , 0.1); + // Open->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.1); + die->GetPairPreFilter().AddCuts(Mcut); + + } + +} + +//______________________________________________________________________________________ +void InitHistograms(AliDielectron *die, Int_t cutDefinition) +{ + // + // Initialise the histograms + // + + //Setup histogram classes + AliDielectronHistos *histos= + new AliDielectronHistos(die->GetName(), + die->GetTitle()); + + //Initialise histogram classes + histos->SetReservedWords("Track;Pair"); + + //Event class + histos->AddClass("Event"); + + //Track classes + //to fill also track info from 2nd event loop until 2 + for (Int_t i=0; i<2; ++i){ + histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i))); + } + + //Pair classes + // to fill also mixed event histograms loop until 10 + for (Int_t i=0; i<3; ++i){ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i))); + } + + // histos->AddClass(Form("Pair_%s","lowMassDiele")); + + if(kMix){ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3))); //ME ++ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));//ME -+ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));//ME +- + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7))); // ME -- + } + + if(kRot)histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(10)));//Rot + + + //add histograms to event class + histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",1,0,1,AliDielectronVarManager::kNevents); + histos->UserHistogram("Event","ZVertex","ZVertex;ZVertex/cm",480,-12.,12.,AliDielectronVarManager::kZvPrim); + histos->UserHistogram("Event","nESDTracks","ESD tracks;ESD tracks;Number events",100,0,200,AliDielectronVarManager::kTracks); + histos->UserHistogram("Event","Nacc","Number of accepted tracks;Number events",100,0,200,AliDielectronVarManager::kNacc); + histos->UserHistogram("Event","NVtxContrib","Number of Vertex Contributor;NVtx;Number events",100,0,100,AliDielectronVarManager::kNVtxContrib); + + + //add histograms to Track classes + histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",1000,0.,10.,AliDielectronVarManager::kPt); + // histos->UserHistogram("Track","Pt_bin2","Pt;Pt [GeV];#tracks", + // "0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,2.,3.,4.,5.,6.,8.,10" + // ,AliDielectronVarManager::kPt); + // histos->UserHistogram("Track","Eta","Eta; Eta ;#tracks",100,-1.,1.,AliDielectronVarManager::kEta); + // histos->UserHistogram("Track","Phi","Phi; Phi ;#tracks",640,0.,6.4,AliDielectronVarManager::kPhi); + + // histos->UserHistogram("Track","Pt_Eta_Phi","Pt",100,0.,10.,100,-1,1,320,0,6.4,AliDielectronVarManager::kPt,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); + + //histos->UserHistogram("Track","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",160,-0.5,159.5,AliDielectronVarManager::kNclsTPC); + //histos->UserHistogram("Track","nClsoverfindablecluster","Number of found Clusters TPC over findably ;TPC number cluster over findable;#tracks",160,0.0,1.1,AliDielectronVarManager::kNFclsTPCrFrac); + //histos->UserHistogram("Track","Eta_phi","Eta vs Phi;Eta;Phi",100,-1.,1.,320,0.,6.4,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); + histos->UserHistogram("Track","Eta_pt","Eta vs Pt;Eta;Pt",100,-1.,1.,500,0.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kPt); + histos->UserHistogram("Track","Phi_pt","Eta vs Pt;Phi;Pt",640,0.,6.4,500,0.,10.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kPt); + histos->UserHistogram("Track","Eta_Phi","Eta vs Phi;Phi;Pt",640,0.,6.4,200,-1.,1.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kEta); + histos->UserHistogram("Track","TOFnSigma_MomEle","TOF number of sigmas Electrons vs Momentum;Mom;TOFsigmaEle",500,0.,5.,700,-30,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaEle); + histos->UserHistogram("Track","TPCdEdx_P","dEdx;P [GeV];TPC signal (arb units) vs Momentum;Mom;TPCsignal", 1000,0,10.,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal); + histos->UserHistogram("Track","TPCnSigma_P","TPC number of sigmas Electrons vs Eta;Eta;TPCsigmaEle",100,0.,10.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle); + //histos->UserHistogram("Track","TPCnSigma_Eta","TPC number of sigmas Electrons vs Eta;Eta;TPCsigmaEle",800,-0.8.,0.8.,800,-40,40,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle); + //histos->UserHistogram("Track","TPCdEdx_Eta","TPC dEdx vs Eta;Eta;TPCsigmaEle",800,-0.8,0.8,800,0,200,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCsignal); + //histos->UserHistogram("Track","TPCnSigma_Phi","TPC number of sigmas Electrons vs Phi;Phi;TPCsigmaEle",640,0.,6.4,800,-40,40,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCnSigmaEle); + // histos->UserHistogram("Track","TPCdEdx_Phi","TPC dEdx vs Phi;Phi;TPCsigmaEle",640,0.,6.4,800,0,200,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCsignal); + + + + //add histograms to Pair classes + + // histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs", + // 500,0,4,AliDielectronVarManager::kM); + + // histos->UserHistogram("Pair","InvMass_low","Inv.Mass;Inv. Mass [GeV];#pairs", + // 500,0,0.5,AliDielectronVarManager::kM); + /* + histos->UserHistogram("Pair","kDeltaEta","kDeltaEta;kDeltaEta;#pairs", + 160,0.,1.6,AliDielectronVarManager::kDeltaEta); + histos->UserHistogram("Pair","kDeltaPhi","kDeltaPhi;kDeltaPhi;#pairs", + 320,0.,6.4,AliDielectronVarManager::kDeltaPhi); + histos->UserHistogram("Pair","PhiV",";PhiV;#pairs", + 320,0.,6.4,AliDielectronVarManager::kPhivPair); + histos->UserHistogram("Pair","InvMass_bin2","Inv.Mass;Inv. Mass [GeV];#pairs", + "0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , + 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , + 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , + 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , + 3.3 , 3.5, 3.75 , 4.0",AliDielectronVarManager::kM); + histos->UserHistogram("Pair", + "InvMass_Pt","InvMass_Pt;InvMass;Pt", + 500, 0. , 4., 100 , 0., 5. , + AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); + */ + histos->UserHistogram("Pair", + "InvMass_Pt","InvMass_Pt;InvMass;Pt", + 400, 0. , 4., 1000 , 0., 10. , + AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); + histos->UserHistogram("Pair", + "InvMass_Eta","InvMass_Eta;InvMass;Eta", + 400, 0. , 4., 200 , -1., 1. , + AliDielectronVarManager::kM , AliDielectronVarManager::kEta ); + histos->UserHistogram("Pair", + "InvMass_PhivPair","InvMass_PhivPair;InvMass;PhivPair", + 400, 0. , 4., 320 , 0., 3.2 , + AliDielectronVarManager::kM , AliDielectronVarManager::kPhivPair ); + histos->UserHistogram("Pair", + "InvMass_dPhi","InvMass_PhivPair;InvMass;PhivPair", + 400, 0. , 4., 320 , 0., 3.2 , + AliDielectronVarManager::kM , AliDielectronVarManager::kDeltaPhi ); + histos->UserHistogram("Pair", + "InvMass_OpenAng","OpAngle_InvMass;Opening angle;Invariant Mass", + 400 , 0. , 4. , 320, 0. , 3.2, + AliDielectronVarManager::kM, AliDielectronVarManager::kOpeningAngle); + + + /* + histos->UserHistogram("Pair", + "Y_PtPair","InvMass_PhivPair;InvMass;PhivPair", + 120, -1.2. , 1.2, 100 , 0., 5. , + AliDielectronVarManager::kY , AliDielectronVarManager::kPt ); + histos->UserHistogram("Pair", + "OpAngle","Opening angle;Opening angle;#pairs", + 320, 0. , 3.2, + AliDielectronVarManager::kOpeningAngle); + histos->UserHistogram("Pair", + "OpAngle_InvMass","OpAngle_InvMass;Opening angle;Invariant Mass", + 320, 0. , 3.2, 500 , 0. , 4. , + AliDielectronVarManager::kOpeningAngle,AliDielectronVarManager::kM); + histos->UserHistogram("Pair", + "Phi","Phi;counts;Phi", + 320, 0. , 6.4, AliDielectronVarManager::kPhi); + histos->UserHistogram("Pair", + "Y","Y;counts;Y", + 120, -1.2 , 1.2, AliDielectronVarManager::kY); + histos->UserHistogram("Pair", + "Pt","Pt;counts;Pt", + 500, 0 , 10, AliDielectronVarManager::kPt); + */ + die->SetHistogramManager(histos); + +} + + + + +void InitCF(AliDielectron* die, Int_t cutDefinition) +{ + // + // Setup the CF Manager if needed + // + + AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle()); + + //pair variables + // cf->AddVariable(AliDielectronVarManager::kM,500,0.,4.); + cf->AddVariable(AliDielectronVarManager::kM,"0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , + 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , + 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , + 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , + 3.3 , 3.5, 3.75 , 4.0");//data + cf->AddVariable(AliDielectronVarManager::kM,500,0.,5.); + cf->AddVariable(AliDielectronVarManager::kM,500,0.,0.1); + // cf->AddVariable(AliDielectronVarManager::kM,500,0.,0.1); + cf->AddVariable(AliDielectronVarManager::kY,20,-1.,1.); + cf->AddVariable(AliDielectronVarManager::kR,500,0.,100.); + cf->AddVariable(AliDielectronVarManager::kPhi,32, 0., 3.2); + cf->AddVariable(AliDielectronVarManager::kPt,100,0.,5.); + cf->AddVariable(AliDielectronVarManager::kPt,"0.,0.2,0.3,0.4,0.5,0.6,0.8,1.0,1.25,1.5,1.75,2.0,3.,5."); + cf->AddVariable(AliDielectronVarManager::kOpeningAngle,62,0.,6.2); + cf->AddVariable(AliDielectronVarManager::kPhivPair,64, 0., 6.4); + cf->AddVariable(AliDielectronVarManager::kPairType,4,-0.5,3.5); + + + cf->AddVariable(AliDielectronVarManager::kEta,40,-1.,1.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kCharge,40,-2.,2.,kTRUE); + //leg + cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kPhi,36,0.,360.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kEta,100,-1.,1.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,20,-3.,4.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kTPCsignal,"40,50,55,60,65,68,70,72,75,80,90,100,110,120",kTRUE); + // cf->AddVariable(AliDielectronVarManager::kTPCsignal,200,0.,200.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kNFclsTPCr,200,0.,200.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kNFclsTPCfCross,200,0.,2.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kTPCchi2Cl,200,0.,10.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kImpactParXY,400,-.5,.5,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kImpactParZ,400,-2.,2.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kNclsITS,10,0.,10.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kNFclsTPCrFrac,10,0.,1.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE); + cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE); + + + if(cutDefinition==0){ + cf->SetStepForMCtruth(); + } + cf->SetStepForAfterAllCuts(); + cf->SetStepsForSignal(); + die->SetCFManagerPair(cf); + + + //primary + AliDielectronSignalMC* DielePrimary=new + AliDielectronSignalMC("Diele Primary","low mass primary dielectron pairs"); + DielePrimary->SetLegPDGs(11,-11); + DielePrimary->SetCheckBothChargesLegs(kTRUE,kTRUE); + DielePrimary->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + //DielePrimary->SetFillPureMCStep(kTRUE); + die->AddSignalMC(DielePrimary); + + // secondary + AliDielectronSignalMC* secsec = new + AliDielectronSignalMC("Secondarypairs","secondary electron pairs"); // pairs made from conversion (may be also from 2 different conversions) + secsec->SetLegPDGs(11,-11); + secsec->SetCheckBothChargesLegs(kTRUE,kTRUE); + secsec->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary); + // secsec->SetFillPureMCStep(kTRUE); + die->AddSignalMC(secsec); + + // secondary-primary + AliDielectronSignalMC* DielePriSec=new + AliDielectronSignalMC("Diele Prim-Sec","low mass prim-sec dielectron pairs"); + DielePriSec->SetLegPDGs(11,-11); + DielePriSec->SetCheckBothChargesLegs(kTRUE,kTRUE); + DielePriSec->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kSecondary); + //DielePriSec->SetFillPureMCStep(kTRUE); + die->AddSignalMC(DielePriSec); + + /* + AliDielectronSignalMC* DielePrimary=new + AliDielectronSignalMC("Diele Primary","low mass primary dielectron pairs"); + DielePrimary->SetLegPDGs(11,-11); + DielePrimary->SetCheckBothChargesLegs(kTRUE,kTRUE); + DielePrimary->SetLegSources(AliDielectronSignalMC::kFinalState, + AliDielectronSignalMC::kFinalState); + DielePrimary->SetMothersRelation(AliDielectronSignalMC::kSame); + DielePrimary->SetFillPureMCStep(kTRUE); + die->AddSignalMC(DielePrimary); + */ + + AliDielectronSignalMC* pi0 = new AliDielectronSignalMC("pi0dalitz","pi0dalitz"); + pi0->SetLegPDGs(11,-11); + pi0->SetMotherPDGs(111,111); + pi0->SetMothersRelation(AliDielectronSignalMC::kSame); + pi0->SetLegSources(AliDielectronSignalMC::kFinalState,AliDielectronSignalMC::kFinalState); + pi0->SetCheckBothChargesLegs(kTRUE,kTRUE); + pi0->SetCheckBothChargesMothers(kTRUE,kTRUE); + pi0->SetFillPureMCStep(kTRUE); + die->AddSignalMC(pi0); + + AliDielectronSignalMC* etaSig = new AliDielectronSignalMC("Eta", "etaSignal"); ///eta dalitz pairs + etaSig->SetLegPDGs(11,-11); + etaSig->SetMotherPDGs(221,221); + etaSig->SetMothersRelation(AliDielectronSignalMC::kSame); + etaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + etaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); + etaSig->SetCheckBothChargesLegs(kTRUE,kTRUE); + etaSig->SetCheckBothChargesMothers(kTRUE,kTRUE); + etaSig->SetFillPureMCStep(kTRUE); + die->AddSignalMC(etaSig); + + AliDielectronSignalMC* etaprimeSig = new AliDielectronSignalMC("Etaprime", "etaprimeSignal"); ///etaprime pairs + etaprimeSig->SetLegPDGs(11,-11); + etaprimeSig->SetMotherPDGs(331,331); + etaprimeSig->SetMothersRelation(AliDielectronSignalMC::kSame); + etaprimeSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + etaprimeSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); + etaprimeSig->SetCheckBothChargesLegs(kTRUE,kTRUE); + etaprimeSig->SetCheckBothChargesMothers(kTRUE,kTRUE); + etaprimeSig->SetFillPureMCStep(kTRUE); + die->AddSignalMC(etaprimeSig); + + AliDielectronSignalMC* rhoSig = new AliDielectronSignalMC("Rho", "rhoSignal"); ///rho pairs + rhoSig->SetLegPDGs(11,-11); + rhoSig->SetMotherPDGs(113,113); + rhoSig->SetMothersRelation(AliDielectronSignalMC::kSame); + rhoSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + rhoSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); + rhoSig->SetCheckBothChargesLegs(kTRUE,kTRUE); + rhoSig->SetCheckBothChargesMothers(kTRUE,kTRUE); + rhoSig->SetFillPureMCStep(kTRUE); + die->AddSignalMC(rhoSig); + + AliDielectronSignalMC* omegaSig = new AliDielectronSignalMC("Omega", "omegaSignal"); ///omega pairs + omegaSig->SetLegPDGs(11,-11); + omegaSig->SetMotherPDGs(223,223); + omegaSig->SetMothersRelation(AliDielectronSignalMC::kSame); + omegaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + omegaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); + omegaSig->SetCheckBothChargesLegs(kTRUE,kTRUE); + omegaSig->SetCheckBothChargesMothers(kTRUE,kTRUE); + omegaSig->SetFillPureMCStep(kTRUE); + die->AddSignalMC(omegaSig); + + AliDielectronSignalMC* phiSig = new AliDielectronSignalMC("Phi", "phiSignal"); ///phi pairs + phiSig->SetLegPDGs(11,-11); + phiSig->SetMotherPDGs(333,333); + phiSig->SetMothersRelation(AliDielectronSignalMC::kSame); + phiSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + phiSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary); + phiSig->SetCheckBothChargesLegs(kTRUE,kTRUE); + phiSig->SetCheckBothChargesMothers(kTRUE,kTRUE); + phiSig->SetFillPureMCStep(kTRUE); + die->AddSignalMC(phiSig); + + AliDielectronSignalMC* dieleOpenCharm = new AliDielectronSignalMC("dieleOpenCharm", "dieleOpenCharm"); + dieleOpenCharm->SetLegPDGs(11,-11); + dieleOpenCharm->SetMotherPDGs(402,402); + dieleOpenCharm->SetLegSources(AliDielectronSignalMC::kFinalState,AliDielectronSignalMC::kFinalState); + dieleOpenCharm->SetCheckBothChargesLegs(kTRUE,kTRUE); + dieleOpenCharm->SetCheckBothChargesMothers(kTRUE,kTRUE); + dieleOpenCharm->SetFillPureMCStep(kTRUE); + die->AddSignalMC(dieleOpenCharm); + + AliDielectronSignalMC* diEleCharm = new AliDielectronSignalMC("diEleCharm","di-electrons from charm"); // dielectrons originating from charm hadrons (not neccessary from same mother) + diEleCharm->SetLegPDGs(11,-11); + diEleCharm->SetMotherPDGs(403,403); + diEleCharm->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); + diEleCharm->SetCheckBothChargesLegs(kTRUE,kTRUE); + diEleCharm->SetFillPureMCStep(kTRUE); + die->AddSignalMC(diEleCharm); + + +} + + + + + diff --git a/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C b/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C index 4a8195a0a41..671d4127f02 100644 --- a/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C +++ b/PWGDQ/dielectron/macrosLMEE/Configpp2012Oezdemir.C @@ -1,496 +1,496 @@ - void InitHistograms(AliDielectron *die, Int_t cutDefinition); - void InitCF(AliDielectron* die, Int_t cutDefinition); - - void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition); - void SetupPairCuts(AliDielectron *die, Int_t cutDefinition); - - void EnableMC(); - AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition); - - TString names=("MixEvt"); - TObjArray *arrNames=names.Tokenize(";"); - const Int_t nDie=arrNames->GetEntries(); - Bool_t MCenabled=kFALSE; - - Bool_t kMix = 1; - - AliDielectron* Configpp2012Oezdemir(Int_t cutDefinition,Bool_t hasMC=kFALSE) - { - // - // Setup the instance of AliDielectron - // - - MCenabled=hasMC; - - // create the actual framework object - - TString name=Form("%02d",cutDefinition); - if ((cutDefinition)GetEntriesFast()){ - name=arrNames->At((cutDefinition))->GetName(); - } - - //thisCut only relevant for MC: - AliDielectron *die = - new AliDielectron(Form - ("%s",name.Data()), - Form("Track cuts: %s",name.Data())); - - if(kMix){ - AliDielectronMixingHandler *mix = new AliDielectronMixingHandler; - mix->SetMixType(AliDielectronMixingHandler::kAll); - mix->AddVariable(AliDielectronVarManager::kZvPrim,"-10., -7.5, -5., -2.5 , 0., 2.5, 5., 7.5 , 10."); - mix->AddVariable(AliDielectronVarManager::kNacc,"0,10000"); - mix->SetDepth(10); - die->SetMixingHandler(mix); - } - - // cut setup - SetupTrackCuts(die,cutDefinition); - SetupPairCuts(die,cutDefinition); - - // histogram setup - // only if an AliDielectronHistos object is attached to the - // dielectron framework histograms will be filled - // - InitHistograms(die,cutDefinition); - - // the last definition uses no cuts and only the QA histograms should be filled! - //InitCF(die,cutDefinition); - - return die; - } - - //______________________________________________________________________________________ - void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition) - { - // - // Setup the track cuts - // - // - //___________________________________________ - AliDielectronPID *pidTT = new AliDielectronPID("TPC-TOF","TPC-TOF"); - pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,100.,kFALSE); - pidTT->AddCut( AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.4 , 5., kFALSE ); - pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.,0.2,100.,kTRUE); - - //___________________________________________ - AliDielectronPID *pidTOF = new AliDielectronPID("TOF","TOF"); - pidTOF->AddCut( AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.4 , 5., kFALSE ); - // - // =============CREATE GROUPS FOR ============== - // - - //Config 0: TPC-TOF - AliDielectronCutGroup* cgTrackFilterPIDTPC = new AliDielectronCutGroup("cgPIDTPC","cgPIDTPC",AliDielectronCutGroup::kCompAND); - cgTrackFilterPIDTPC->AddCut(SetupESDtrackCuts(cutDefinition)); - cgTrackFilterPIDTPC->AddCut(pidTT); - - //Config 1: TOF - AliDielectronCutGroup* cgTrackFilterPIDTOF = new AliDielectronCutGroup("cgPIDTOF","cgPIDTOF",AliDielectronCutGroup::kCompAND); - cgTrackFilterPIDTOF->AddCut(SetupESDtrackCuts(cutDefinition)); - cgTrackFilterPIDTOF->AddCut(pidTOF); - - //Config 2: no PID - AliDielectronCutGroup* cgTrackFilternoPID = new AliDielectronCutGroup("cgnoPID","cgnoPID",AliDielectronCutGroup::kCompAND); - cgTrackFilternoPID->AddCut(SetupESDtrackCuts(cutDefinition)); - - //Correct BG scheme for Combinatorial BG - //die->SetPreFilterUnlikeOnly(); - die->SetPreFilterAllSigns(); - die->SetUseKF(kFALSE); - - if ( cutDefinition ==0 ) { - die->GetTrackFilter().AddCuts(cgTrackFilterPIDTPC); - } - - } - //______________________________________________________________________________________ - - void SetupPairCuts(AliDielectron *die, Int_t cutDefinition) - { - // - // Setup the pair cuts - // - - - if(cutDefinition == 0){ - - AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","conversion tagging"); - noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE); - die->GetTrackFilter().AddCuts(noconv); - - //pair rapidity -// AliDielectronVarCuts *RapidityCut=new AliDielectronVarCuts("RapidityCut","RapidityCut"); -// RapidityCut->AddCut(AliDielectronVarManager::kY, -0.8 , 0.8); -// die->GetPairFilter().AddCuts(RapidityCut); - - AliDielectronVarCuts *PhiV = new AliDielectronVarCuts("PhiV","PhiV");//mass and Phiv together - PhiV->AddCut(AliDielectronVarManager::kM, 0.0 , 0.05); - PhiV->AddCut(AliDielectronVarManager::kPhivPair, 2.5 , 3.2 ); - die->GetPairPreFilter().AddCuts(PhiV); - /* - AliDielectronVarCuts *PhiV2 = new AliDielectronVarCuts("PhiV2","PhiV2");//mass and Phiv together - PhiV2->AddCut(AliDielectronVarManager::kM, 0.05 , 1000.); - - AliDielectronCutGroup* pairCutsCG2 =new AliDielectronCutGroup("pairCutsCG2","pairCutsCG2",AliDielectronCutGroup::kCompOR); - pairCutsCG2->AddCut(PhiV); - pairCutsCG2->AddCut(PhiV2); - die->GetPairFilter().AddCuts(pairCutsCG2); - */ - /* - if (MCenabled) { - AliDielectronVarCuts *mcpid =new AliDielectronVarCuts("mcpid","mcpid"); - mcpid->SetCutType(AliDielectronVarCuts::kAny); - mcpid->AddCut(AliDielectronVarManager::kPdgCode, 11); - mcpid->AddCut(AliDielectronVarManager::kPdgCode, -11); - die->GetTrackFilter().AddCuts(mcpid); - - AliDielectronVarCuts *MCnoConv =new AliDielectronVarCuts("MCnoConv","MCnoConv"); - MCnoConv->AddCut(AliDielectronVarManager::kPdgCodeMother, 22,kTRUE); - die->GetTrackFilter().AddCuts(MCnoConv); - } - */ - } - - } - - //______________________________________________________________________________________ - AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition) - { - // - // Setup default AliESDtrackCuts - // - AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts; - - esdTrackCuts->SetMaxDCAToVertexZ(3.0); - esdTrackCuts->SetMaxDCAToVertexXY(1.0); - - esdTrackCuts->SetPtRange( 0.2 , 100.0); - esdTrackCuts->SetEtaRange( -0.8 , 0.8 ); - esdTrackCuts->SetRequireSigmaToVertex(kFALSE); - esdTrackCuts->SetAcceptKinkDaughters(kFALSE); - esdTrackCuts->SetDCAToVertex2D(kFALSE); - - esdTrackCuts->SetRequireITSRefit(kTRUE); - esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst); //Base - esdTrackCuts->SetMinNClustersITS(3); //Base - - esdTrackCuts->SetRequireTPCRefit(kTRUE); - esdTrackCuts->SetMinNClustersTPC(80); //Base - - esdTrackCuts->SetMinNCrossedRowsTPC(100); //Base - - esdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.5); - esdTrackCuts->SetMaxChi2PerClusterTPC(4); - - return esdTrackCuts; - } - - //______________________________________________________________________________________ - -void InitHistograms(AliDielectron *die, Int_t cutDefinition) - { - // - // Initialise the histograms - // - - //Setup histogram classes - AliDielectronHistos *histos= - new AliDielectronHistos(die->GetName(), - die->GetTitle()); - - - - //Initialise histogram classes - histos->SetReservedWords("Track;Pair"); - //histos->SetReservedWords("Track"); - - //Event class - histos->AddClass("Event"); - - - //Track classes - //to fill also track info from 2nd event loop until 2 - for (Int_t i=0; i<2; ++i){ - histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i))); - } - - //Pair classes - // to fill also mixed event histograms loop until 10 - - for (Int_t i=0; i<3; ++i){ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i))); - - } - - if(kMix){ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3))); //ME ++ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));//ME -+ - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));//ME +- - histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7))); // ME -- - } - - - //add histograms to event class - histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",1,0,1,AliDielectronVarManager::kNevents); - histos->UserHistogram("Event","ZVertex","ZVertex;ZVertex/cm",480,-12.,12.,AliDielectronVarManager::kZvPrim); - histos->UserHistogram("Event","nESDTracks","ESD tracks;ESD tracks;Number events",100,0,200,AliDielectronVarManager::kTracks); - histos->UserHistogram("Event","Nacc","Number of accepted tracks;Number events",100,0,200,AliDielectronVarManager::kNacc); - histos->UserHistogram("Event","NVtxContrib","Number of Vertex Contributor;NVtx;Number events",100,0,100,AliDielectronVarManager::kNVtxContrib); - - - //add histograms to Track classes - histos->UserHistogram("Track","P","P;P [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPIn); - histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPt); - histos->UserHistogram("Track","Eta","Eta; Eta ;#tracks",100,-1.,1.,AliDielectronVarManager::kEta); - histos->UserHistogram("Track","Phi","Phi; Phi ;#tracks",640,0.,6.4,AliDielectronVarManager::kPhi); - - - histos->UserHistogram("Track","Eta_phi","Eta vs Phi;Eta;Phi",100,-1.,1.,320,0.,6.4,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); - histos->UserHistogram("Track","Eta_pt","Eta vs Pt;Eta;Pt",100,-1.,1.,500,0.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kPt); - histos->UserHistogram("Track","ImpParXY_Pt","ImpParXY_Pt; Pt; ÍmpParXY",500,0.,10.,500,-5.,5.,AliDielectronVarManager::kPt,AliDielectronVarManager::kImpactParXY); - histos->UserHistogram("Track","ImpParZ_Pt","ImpParZ_Pt; Pt; ÍmpParZ",500,0.,10.,500,-5.,5.,AliDielectronVarManager::kPt,AliDielectronVarManager::kImpactParZ); - - - //track checks (ITS) - histos->UserHistogram("Track","ITSchi2Cl_Mom","ITS Chi2 vs Momentum;Mom;ITS chi2",500,0.,5.,50,0.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSchi2Cl); - histos->UserHistogram("Track","NclsITS_Mom",";Mom;kNclsITS",500,0.,5.,7,0,7,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsITS); - - //track checks (TPC) - histos->UserHistogram("Track","TPCsignalNfrac_Mom",";fraction TPCSignalN/TPCncls vs Momentum;Mom;TPCSignalN/TPCncls",500,0.,5.,60,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignalNfrac); - histos->UserHistogram("Track","TPCchi2Cl_Mom","TPC Chi2 vs Momentum;Mom;TPC Chi2",500,0.,10.,100,0,5,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCchi2Cl); - histos->UserHistogram("Track","TPCclsDiff_Mom","kTPCclsDiff vs Momentum;Mom;kTPCclsDiff",500,0.,10.,100,-10,10,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCclsDiff); - histos->UserHistogram("Track","FindableTPCcls_Mom","kNFclsTPC vs Momentum;Mom;kNFclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPC); - histos->UserHistogram("Track","TPCcls_Mom","kNclsTPC vs Momentum;Mom;kNclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsTPC); - histos->UserHistogram("Track","kNclsSFracTPC_Mom","kNclsSFracTPC vs Momentum;Mom;kTPCclsSFrac",500,0.,10.,1000,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsSFracTPC); - histos->UserHistogram("Track","kNFclsTPCrFrac_Mom","kNFclsTPCrFrac vs Momentum;Mom;kNFclsTPCrFrac",500,0.,10.,60,0.,1.2.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPCrFrac); - - //track checks (TOF) - histos->UserHistogram("Track","TOFbeta_Mom","kTOFbeta vs Momentum;Mom;TOFbeta",500,0.,5.,120,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta); - histos->UserHistogram("Track","TOFPIDBit_Mom","kTOFPIDBit vs Momentum;Mom;TOFPIDbit",500,0.,5.,2,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFPIDBit); - - //track checks (PID) - histos->UserHistogram("Track","ITSnSigma_MomPio","ITS number of sigmas Pion vs Momentum;Mom;ITSsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaPio); - histos->UserHistogram("Track","TPCnSigma_MomPio","TPC number of sigmas Pions vs Momentum;Mom;TPCsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio); - - histos->UserHistogram("Track","ITSnSigma_MomEle","ITS number of sigmas Electrons vs Momentum;Mom;ITSsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaEle); - histos->UserHistogram("Track","TPCnSigma_MomEle","TPC number of sigmas Electrons vs Momentum;Mom;TPCsigmaEle",1000,0.,10.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle); - histos->UserHistogram("Track","TOFnSigma_MomEle","TOF number of sigmas Electrons vs Momentum;Mom;TOFsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaEle); - - histos->UserHistogram("Track","ITSdEdx_P","dEdx;P [GeV];ITS signal (arb units) vs Momentum;Mom;ITSsignal", 500,0,5,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal); - histos->UserHistogram("Track","TPCdEdx_P","dEdx;P [GeV];TPC signal (arb units) vs Momentum;Mom;TPCsignal", 500,0,10.,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal); - - // - //add histograms to Pair classes - // - - histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs", - 500,0,4,AliDielectronVarManager::kM); - - histos->UserHistogram("Pair","InvMass_low","Inv.Mass;Inv. Mass [GeV];#pairs", - 500,0,0.5,AliDielectronVarManager::kM); - - histos->UserHistogram("Pair","InvMass10","Inv.Mass;Inv. Mass [GeV];#pairs", - 500,0.,5.,AliDielectronVarManager::kM); - - histos->UserHistogram("Pair","kDeltaEta","kDeltaEta;kDeltaEta;#pairs", - 160,0.,1.6,AliDielectronVarManager::kDeltaEta); - - histos->UserHistogram("Pair","kDeltaEta_low","kDeltaEta;kDeltaEta;#pairs", - 500,0.,0.5,AliDielectronVarManager::kDeltaEta); - - histos->UserHistogram("Pair","kDeltaPhi","kDeltaPhi;kDeltaPhi;#pairs", - 320,0.,6.4,AliDielectronVarManager::kDeltaPhi); - - histos->UserHistogram("Pair", - "kDeltaEta_kDeltaPhi","kDeltaEta_kDeltaPhi;kDeltaEta;kDeltaPhi", - 160, 0. , 1.6, 320 , 0., 6.4 , - AliDielectronVarManager::kDeltaEta , AliDielectronVarManager::kDeltaPhi ); - - histos->UserHistogram("Pair","PhiV",";PhiV;#pairs", - 320,0.,6.4,AliDielectronVarManager::kPhivPair); - - - histos->UserHistogram("Pair","PhiV_Pt",";Pt;PhiV", - 100,0.,10.,320,0.,6.4,AliDielectronVarManager::kPt,AliDielectronVarManager::kPhivPair); - - histos->UserHistogram("Pair","InvMass_bin2","Inv.Mass;Inv. Mass [GeV];#pairs", - "0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , - 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , - 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , - 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , - 3.3 , 3.5, 3.75 , 4.0",AliDielectronVarManager::kM); - - - histos->UserHistogram("Pair", - "InvMass_Pt","InvMass_Pt;InvMass;Pt", - 500, 0. , 4., 100 , 0., 5. , - AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); - - histos->UserHistogram("Pair", - "InvMass_PhivPair","InvMass_PhivPair;InvMass;PhivPair", - 500, 0. , 4., 320 , 0., 3.2 , - AliDielectronVarManager::kM , AliDielectronVarManager::kPhivPair ); - - histos->UserHistogram("Pair", - "OpAngle","Opening angle;Opening angle;#pairs", - 320, 0. , 3.2, - AliDielectronVarManager::kOpeningAngle); - - histos->UserHistogram("Pair", - "OpAngle_InvMass","OpAngle_InvMass;Opening angle;Invariant Mass", - 320, 0. , 3.2, 500 , 0. , 4. , - AliDielectronVarManager::kOpeningAngle,AliDielectronVarManager::kM); - - - histos->UserHistogram("Pair", - "Phi","Phi;counts;Phi", - 320, 0. , 6.4, AliDielectronVarManager::kPhi); - - histos->UserHistogram("Pair", - "Y","Y;counts;Y", - 120, -1.2 , 1.2, AliDielectronVarManager::kY); - - die->SetHistogramManager(histos); - -} - - -void InitCF(AliDielectron* die, Int_t cutDefinition) -{ - // - // Setupd the CF Manager if needed - // - AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle()); - - //pair variables - cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.); - //cf->AddVariable(AliDielectronVarManager::kP,200,0,20); - //cf->AddVariable(AliDielectronVarManager::kPhi,64, -3.2, 3.2); - cf->AddVariable(AliDielectronVarManager::kY,40,-2.,2.); - cf->AddVariable(AliDielectronVarManager::kM,500,0.,4.); - //cf->AddVariable(AliDielectronVarManager::kPairType,10,0,10); - //cf->AddVariable(AliDielectronVarManager::kOpeningAngle,315,0,3.15); - //cf->AddVariable(AliDielectronVarManager::kDeltaEta,200,-2,2); - //cf->AddVariable(AliDielectronVarManager::kDeltaPhi,100,0,3.15); - //cf->AddVariable(AliDielectronVarManager::kHaveSameMother,21,-10,10); - cf->AddVariable(AliDielectronVarManager::kNumberOfDaughters,5,0,5); - //leg variables - cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kP,200,0.,20.,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kY,40,-2.,2.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kEta,20,-1.,1.,kTRUE); - cf->AddVariable(AliDielectronVarManager::kPhi,100,0.,3.15,kTRUE); -// cf->AddVariable(AliDielectronVarManager::kITSsignal,1000,0.0.,1000.,kTRUE); -// cf->AddVariable(AliDielectronVarManager::kHaveSameMother,21,-10,10,kTRUE); -// cf->AddVariable(AliDielectronVarManager::kNumberOfDaughters,11,0,10,kTRUE); - - //only in this case write MC truth info - - if (MCenabled) { - cf->SetStepForMCtruth(); - //cf->SetStepsForMCtruthOnly(); - //cf->SetStepForNoCutsMCmotherPid(); - cout << "MC ENABLED ------------------------------------------------------" << endl; - //cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE); - //cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE); - } - - //cf->SetStepsForEachCut(); - //cf->SetStepForPreFilter(); - cf->SetStepForAfterAllCuts(); - //cf->SetStepsForBackground(); - cf->SetStepsForSignal(); - - die->SetCFManagerPair(cf); - -/* - - AliDielectronSignalMC* lowMassDiele=new - AliDielectronSignalMC("lowMassDiele","low mass dielectron pairs"); - lowMassDiele->SetLegPDGs(11,-11); - lowMassDiele->SetCheckBothChargesLegs(kTRUE,kTRUE); - lowMassDiele->SetLegSources(AliDielectronSignalMC::kPrimary, - AliDielectronSignalMC::kPrimary); - lowMassDiele->SetFillPureMCStep(kTRUE); - die->AddSignalMC(lowMassDiele); - - AliDielectronSignalMC* secondary=new - AliDielectronSignalMC("secondary","secondary electrons pairs"); - secondary->SetLegPDGs(11,-11); - secondary->SetCheckBothChargesLegs(kTRUE,kTRUE); - secondary->SetLegSources(AliDielectronSignalMC::kSecondary, - AliDielectronSignalMC::kSecondary); - die->AddSignalMC(secondary); - - AliDielectronSignalMC* eleFromConversions=new - AliDielectronSignalMC("eleFromConversions","conversion electrons"); - eleFromConversions->SetLegPDGs(11,-11); - eleFromConversions->SetCheckBothChargesLegs(kTRUE,kTRUE); - eleFromConversions->SetLegSources(AliDielectronSignalMC::kSecondary, - AliDielectronSignalMC::kSecondary); - eleFromConversions->SetMotherPDGs(22,22); // 22- photon - die->AddSignalMC(eleFromConversions); - - AliDielectronSignalMC* misIdPions=new - AliDielectronSignalMC("misIdPions","mis id. pion pairs"); - misIdPions->SetLegPDGs(211,-211); - misIdPions->SetCheckBothChargesLegs(kTRUE,kTRUE); - die->AddSignalMC(misIdPions); - - AliDielectronSignalMC* dalitzDecays=new - AliDielectronSignalMC("dalitzDecays","dalitz Pairs"); - dalitzDecays->SetLegPDGs(11,-11); - dalitzDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); - dalitzDecays->SetLegSources(AliDielectronSignalMC::kSecondary, - AliDielectronSignalMC::kSecondary); - dalitzDecays->SetMotherPDGs(111,111); - dalitzDecays->SetFillPureMCStep(kTRUE); - die->AddSignalMC(dalitzDecays); -*/ - -AliDielectronSignalMC* PhiDecays= new AliDielectronSignalMC("PhiDecays","Phi Pairs"); -PhiDecays->SetLegPDGs(11,-11); -PhiDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); -PhiDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); -PhiDecays->SetMotherPDGs(333,333); -PhiDecays->SetMothersRelation(AliDielectronSignalMC::kSame); -PhiDecays->SetFillPureMCStep(kTRUE); -die->AddSignalMC(PhiDecays); - -AliDielectronSignalMC* OmegaDecays= new AliDielectronSignalMC("OmegaDecays","Omega Pairs"); -OmegaDecays->SetLegPDGs(11,-11); -OmegaDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); -OmegaDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); -OmegaDecays->SetMotherPDGs(223,223); -OmegaDecays->SetMothersRelation(AliDielectronSignalMC::kSame); -OmegaDecays->SetDalitz(AliDielectronSignalMC::kIsNotDalitz); -OmegaDecays->SetFillPureMCStep(kTRUE); -die->AddSignalMC(OmegaDecays); - -/* -AliDielectronSignalMC* RhoDecays= new AliDielectronSignalMC("RhoDecays","Rho Pairs"); -RhoDecays->SetLegPDGs(11,-11); -RhoDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); -RhoDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); -RhoDecays->SetMotherPDGs(113,113); -RhoDecays->SetMothersRelation(AliDielectronSignalMC::kSame); -RhoDecays->SetFillPureMCStep(kTRUE); -die->AddSignalMC(RhoDecays); - -AliDielectronSignalMC* DieleConti= new AliDielectronSignalMC("DieleConti","low mass ee pairs"); -DieleConti->SetLegPDGs(11,-11); -DieleConti->SetMotherPDGs(0,0,22,22); -DieleConti->SetCheckBothChargesLegs(kTRUE,kTRUE); -DieleConti->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); -DieleConti->SetMothersRelation(AliDielectronSignalMC::kSame); -DieleConti->SetFillPureMCStep(kTRUE); -die->AddSignalMC(DieleConti);*/ - - -} - -//-------------------------------------- - void EnableMC() { - MCenabled=kTRUE; - } + void InitHistograms(AliDielectron *die, Int_t cutDefinition); + void InitCF(AliDielectron* die, Int_t cutDefinition); + + void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition); + void SetupPairCuts(AliDielectron *die, Int_t cutDefinition); + + void EnableMC(); + AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition); + + TString names=("MixEvt"); + TObjArray *arrNames=names.Tokenize(";"); + const Int_t nDie=arrNames->GetEntries(); + Bool_t MCenabled=kFALSE; + + Bool_t kMix = 1; + + AliDielectron* Configpp2012Oezdemir(Int_t cutDefinition,Bool_t hasMC=kFALSE) + { + // + // Setup the instance of AliDielectron + // + + MCenabled=hasMC; + + // create the actual framework object + + TString name=Form("%02d",cutDefinition); + if ((cutDefinition)GetEntriesFast()){ + name=arrNames->At((cutDefinition))->GetName(); + } + + //thisCut only relevant for MC: + AliDielectron *die = + new AliDielectron(Form + ("%s",name.Data()), + Form("Track cuts: %s",name.Data())); + + if(kMix){ + AliDielectronMixingHandler *mix = new AliDielectronMixingHandler; + mix->SetMixType(AliDielectronMixingHandler::kAll); + mix->AddVariable(AliDielectronVarManager::kZvPrim,"-10., -7.5, -5., -2.5 , 0., 2.5, 5., 7.5 , 10."); + mix->AddVariable(AliDielectronVarManager::kNacc,"0,10000"); + mix->SetDepth(10); + die->SetMixingHandler(mix); + } + + // cut setup + SetupTrackCuts(die,cutDefinition); + SetupPairCuts(die,cutDefinition); + + // histogram setup + // only if an AliDielectronHistos object is attached to the + // dielectron framework histograms will be filled + // + InitHistograms(die,cutDefinition); + + // the last definition uses no cuts and only the QA histograms should be filled! + //InitCF(die,cutDefinition); + + return die; + } + + //______________________________________________________________________________________ + void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition) + { + // + // Setup the track cuts + // + // + //___________________________________________ + AliDielectronPID *pidTT = new AliDielectronPID("TPC-TOF","TPC-TOF"); + pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,100.,kFALSE); + pidTT->AddCut( AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.4 , 5., kFALSE ); + pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.,0.2,100.,kTRUE); + + //___________________________________________ + AliDielectronPID *pidTOF = new AliDielectronPID("TOF","TOF"); + pidTOF->AddCut( AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.4 , 5., kFALSE ); + // + // =============CREATE GROUPS FOR ============== + // + + //Config 0: TPC-TOF + AliDielectronCutGroup* cgTrackFilterPIDTPC = new AliDielectronCutGroup("cgPIDTPC","cgPIDTPC",AliDielectronCutGroup::kCompAND); + cgTrackFilterPIDTPC->AddCut(SetupESDtrackCuts(cutDefinition)); + cgTrackFilterPIDTPC->AddCut(pidTT); + + //Config 1: TOF + AliDielectronCutGroup* cgTrackFilterPIDTOF = new AliDielectronCutGroup("cgPIDTOF","cgPIDTOF",AliDielectronCutGroup::kCompAND); + cgTrackFilterPIDTOF->AddCut(SetupESDtrackCuts(cutDefinition)); + cgTrackFilterPIDTOF->AddCut(pidTOF); + + //Config 2: no PID + AliDielectronCutGroup* cgTrackFilternoPID = new AliDielectronCutGroup("cgnoPID","cgnoPID",AliDielectronCutGroup::kCompAND); + cgTrackFilternoPID->AddCut(SetupESDtrackCuts(cutDefinition)); + + //Correct BG scheme for Combinatorial BG + //die->SetPreFilterUnlikeOnly(); + die->SetPreFilterAllSigns(); + die->SetUseKF(kFALSE); + + if ( cutDefinition ==0 ) { + die->GetTrackFilter().AddCuts(cgTrackFilterPIDTPC); + } + + } + //______________________________________________________________________________________ + + void SetupPairCuts(AliDielectron *die, Int_t cutDefinition) + { + // + // Setup the pair cuts + // + + + if(cutDefinition == 0){ + + AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","conversion tagging"); + noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE); + die->GetTrackFilter().AddCuts(noconv); + + //pair rapidity +// AliDielectronVarCuts *RapidityCut=new AliDielectronVarCuts("RapidityCut","RapidityCut"); +// RapidityCut->AddCut(AliDielectronVarManager::kY, -0.8 , 0.8); +// die->GetPairFilter().AddCuts(RapidityCut); + + AliDielectronVarCuts *PhiV = new AliDielectronVarCuts("PhiV","PhiV");//mass and Phiv together + PhiV->AddCut(AliDielectronVarManager::kM, 0.0 , 0.05); + PhiV->AddCut(AliDielectronVarManager::kPhivPair, 2.5 , 3.2 ); + die->GetPairPreFilter().AddCuts(PhiV); + /* + AliDielectronVarCuts *PhiV2 = new AliDielectronVarCuts("PhiV2","PhiV2");//mass and Phiv together + PhiV2->AddCut(AliDielectronVarManager::kM, 0.05 , 1000.); + + AliDielectronCutGroup* pairCutsCG2 =new AliDielectronCutGroup("pairCutsCG2","pairCutsCG2",AliDielectronCutGroup::kCompOR); + pairCutsCG2->AddCut(PhiV); + pairCutsCG2->AddCut(PhiV2); + die->GetPairFilter().AddCuts(pairCutsCG2); + */ + /* + if (MCenabled) { + AliDielectronVarCuts *mcpid =new AliDielectronVarCuts("mcpid","mcpid"); + mcpid->SetCutType(AliDielectronVarCuts::kAny); + mcpid->AddCut(AliDielectronVarManager::kPdgCode, 11); + mcpid->AddCut(AliDielectronVarManager::kPdgCode, -11); + die->GetTrackFilter().AddCuts(mcpid); + + AliDielectronVarCuts *MCnoConv =new AliDielectronVarCuts("MCnoConv","MCnoConv"); + MCnoConv->AddCut(AliDielectronVarManager::kPdgCodeMother, 22,kTRUE); + die->GetTrackFilter().AddCuts(MCnoConv); + } + */ + } + + } + + //______________________________________________________________________________________ + AliESDtrackCuts *SetupESDtrackCuts(Int_t cutDefinition) + { + // + // Setup default AliESDtrackCuts + // + AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts; + + esdTrackCuts->SetMaxDCAToVertexZ(3.0); + esdTrackCuts->SetMaxDCAToVertexXY(1.0); + + esdTrackCuts->SetPtRange( 0.2 , 100.0); + esdTrackCuts->SetEtaRange( -0.8 , 0.8 ); + esdTrackCuts->SetRequireSigmaToVertex(kFALSE); + esdTrackCuts->SetAcceptKinkDaughters(kFALSE); + esdTrackCuts->SetDCAToVertex2D(kFALSE); + + esdTrackCuts->SetRequireITSRefit(kTRUE); + esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst); //Base + esdTrackCuts->SetMinNClustersITS(3); //Base + + esdTrackCuts->SetRequireTPCRefit(kTRUE); + esdTrackCuts->SetMinNClustersTPC(80); //Base + + esdTrackCuts->SetMinNCrossedRowsTPC(100); //Base + + esdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.5); + esdTrackCuts->SetMaxChi2PerClusterTPC(4); + + return esdTrackCuts; + } + + //______________________________________________________________________________________ + +void InitHistograms(AliDielectron *die, Int_t cutDefinition) + { + // + // Initialise the histograms + // + + //Setup histogram classes + AliDielectronHistos *histos= + new AliDielectronHistos(die->GetName(), + die->GetTitle()); + + + + //Initialise histogram classes + histos->SetReservedWords("Track;Pair"); + //histos->SetReservedWords("Track"); + + //Event class + histos->AddClass("Event"); + + + //Track classes + //to fill also track info from 2nd event loop until 2 + for (Int_t i=0; i<2; ++i){ + histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i))); + } + + //Pair classes + // to fill also mixed event histograms loop until 10 + + for (Int_t i=0; i<3; ++i){ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i))); + + } + + if(kMix){ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3))); //ME ++ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));//ME -+ + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));//ME +- + histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7))); // ME -- + } + + + //add histograms to event class + histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",1,0,1,AliDielectronVarManager::kNevents); + histos->UserHistogram("Event","ZVertex","ZVertex;ZVertex/cm",480,-12.,12.,AliDielectronVarManager::kZvPrim); + histos->UserHistogram("Event","nESDTracks","ESD tracks;ESD tracks;Number events",100,0,200,AliDielectronVarManager::kTracks); + histos->UserHistogram("Event","Nacc","Number of accepted tracks;Number events",100,0,200,AliDielectronVarManager::kNacc); + histos->UserHistogram("Event","NVtxContrib","Number of Vertex Contributor;NVtx;Number events",100,0,100,AliDielectronVarManager::kNVtxContrib); + + + //add histograms to Track classes + histos->UserHistogram("Track","P","P;P [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPIn); + histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",500,0.,10.,AliDielectronVarManager::kPt); + histos->UserHistogram("Track","Eta","Eta; Eta ;#tracks",100,-1.,1.,AliDielectronVarManager::kEta); + histos->UserHistogram("Track","Phi","Phi; Phi ;#tracks",640,0.,6.4,AliDielectronVarManager::kPhi); + + + histos->UserHistogram("Track","Eta_phi","Eta vs Phi;Eta;Phi",100,-1.,1.,320,0.,6.4,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi); + histos->UserHistogram("Track","Eta_pt","Eta vs Pt;Eta;Pt",100,-1.,1.,500,0.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kPt); + histos->UserHistogram("Track","ImpParXY_Pt","ImpParXY_Pt; Pt; ÍmpParXY",500,0.,10.,500,-5.,5.,AliDielectronVarManager::kPt,AliDielectronVarManager::kImpactParXY); + histos->UserHistogram("Track","ImpParZ_Pt","ImpParZ_Pt; Pt; ÍmpParZ",500,0.,10.,500,-5.,5.,AliDielectronVarManager::kPt,AliDielectronVarManager::kImpactParZ); + + + //track checks (ITS) + histos->UserHistogram("Track","ITSchi2Cl_Mom","ITS Chi2 vs Momentum;Mom;ITS chi2",500,0.,5.,50,0.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSchi2Cl); + histos->UserHistogram("Track","NclsITS_Mom",";Mom;kNclsITS",500,0.,5.,7,0,7,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsITS); + + //track checks (TPC) + histos->UserHistogram("Track","TPCsignalNfrac_Mom",";fraction TPCSignalN/TPCncls vs Momentum;Mom;TPCSignalN/TPCncls",500,0.,5.,60,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignalNfrac); + histos->UserHistogram("Track","TPCchi2Cl_Mom","TPC Chi2 vs Momentum;Mom;TPC Chi2",500,0.,10.,100,0,5,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCchi2Cl); + histos->UserHistogram("Track","TPCclsDiff_Mom","kTPCclsDiff vs Momentum;Mom;kTPCclsDiff",500,0.,10.,100,-10,10,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCclsDiff); + histos->UserHistogram("Track","FindableTPCcls_Mom","kNFclsTPC vs Momentum;Mom;kNFclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPC); + histos->UserHistogram("Track","TPCcls_Mom","kNclsTPC vs Momentum;Mom;kNclsTPC",500,0.,10.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsTPC); + histos->UserHistogram("Track","kNclsSFracTPC_Mom","kNclsSFracTPC vs Momentum;Mom;kTPCclsSFrac",500,0.,10.,1000,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNclsSFracTPC); + histos->UserHistogram("Track","kNFclsTPCrFrac_Mom","kNFclsTPCrFrac vs Momentum;Mom;kNFclsTPCrFrac",500,0.,10.,60,0.,1.2.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kNFclsTPCrFrac); + + //track checks (TOF) + histos->UserHistogram("Track","TOFbeta_Mom","kTOFbeta vs Momentum;Mom;TOFbeta",500,0.,5.,120,0.,1.2,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta); + histos->UserHistogram("Track","TOFPIDBit_Mom","kTOFPIDBit vs Momentum;Mom;TOFPIDbit",500,0.,5.,2,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFPIDBit); + + //track checks (PID) + histos->UserHistogram("Track","ITSnSigma_MomPio","ITS number of sigmas Pion vs Momentum;Mom;ITSsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaPio); + histos->UserHistogram("Track","TPCnSigma_MomPio","TPC number of sigmas Pions vs Momentum;Mom;TPCsigmaPion",500,0.,5.,1000,-20,20,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio); + + histos->UserHistogram("Track","ITSnSigma_MomEle","ITS number of sigmas Electrons vs Momentum;Mom;ITSsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSnSigmaEle); + histos->UserHistogram("Track","TPCnSigma_MomEle","TPC number of sigmas Electrons vs Momentum;Mom;TPCsigmaEle",1000,0.,10.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle); + histos->UserHistogram("Track","TOFnSigma_MomEle","TOF number of sigmas Electrons vs Momentum;Mom;TOFsigmaEle",500,0.,5.,800,-40,40,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaEle); + + histos->UserHistogram("Track","ITSdEdx_P","dEdx;P [GeV];ITS signal (arb units) vs Momentum;Mom;ITSsignal", 500,0,5,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal); + histos->UserHistogram("Track","TPCdEdx_P","dEdx;P [GeV];TPC signal (arb units) vs Momentum;Mom;TPCsignal", 500,0,10.,800,0,200,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal); + + // + //add histograms to Pair classes + // + + histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs", + 500,0,4,AliDielectronVarManager::kM); + + histos->UserHistogram("Pair","InvMass_low","Inv.Mass;Inv. Mass [GeV];#pairs", + 500,0,0.5,AliDielectronVarManager::kM); + + histos->UserHistogram("Pair","InvMass10","Inv.Mass;Inv. Mass [GeV];#pairs", + 500,0.,5.,AliDielectronVarManager::kM); + + histos->UserHistogram("Pair","kDeltaEta","kDeltaEta;kDeltaEta;#pairs", + 160,0.,1.6,AliDielectronVarManager::kDeltaEta); + + histos->UserHistogram("Pair","kDeltaEta_low","kDeltaEta;kDeltaEta;#pairs", + 500,0.,0.5,AliDielectronVarManager::kDeltaEta); + + histos->UserHistogram("Pair","kDeltaPhi","kDeltaPhi;kDeltaPhi;#pairs", + 320,0.,6.4,AliDielectronVarManager::kDeltaPhi); + + histos->UserHistogram("Pair", + "kDeltaEta_kDeltaPhi","kDeltaEta_kDeltaPhi;kDeltaEta;kDeltaPhi", + 160, 0. , 1.6, 320 , 0., 6.4 , + AliDielectronVarManager::kDeltaEta , AliDielectronVarManager::kDeltaPhi ); + + histos->UserHistogram("Pair","PhiV",";PhiV;#pairs", + 320,0.,6.4,AliDielectronVarManager::kPhivPair); + + + histos->UserHistogram("Pair","PhiV_Pt",";Pt;PhiV", + 100,0.,10.,320,0.,6.4,AliDielectronVarManager::kPt,AliDielectronVarManager::kPhivPair); + + histos->UserHistogram("Pair","InvMass_bin2","Inv.Mass;Inv. Mass [GeV];#pairs", + "0. , 0.025, 0.05 , 0.075 ,0.1 ,0.15 , 0.2 , 0.25 , 0.3 , + 0.4 , 0.5 , 0.6, 0.65 , 0.688 , 0.725, 0.75, 0.775, 0.8 , 0.85 , + 0.95, 0.975 , 1.0 , 1.025 , 1.05, 1.125 , 1.25 , 1.5 , 1.75 , 2.0 , + 2.25, 2.5 , 2.75 , 2.85, 2.95,3.05, 3.1 , 3.15 , + 3.3 , 3.5, 3.75 , 4.0",AliDielectronVarManager::kM); + + + histos->UserHistogram("Pair", + "InvMass_Pt","InvMass_Pt;InvMass;Pt", + 500, 0. , 4., 100 , 0., 5. , + AliDielectronVarManager::kM , AliDielectronVarManager::kPt ); + + histos->UserHistogram("Pair", + "InvMass_PhivPair","InvMass_PhivPair;InvMass;PhivPair", + 500, 0. , 4., 320 , 0., 3.2 , + AliDielectronVarManager::kM , AliDielectronVarManager::kPhivPair ); + + histos->UserHistogram("Pair", + "OpAngle","Opening angle;Opening angle;#pairs", + 320, 0. , 3.2, + AliDielectronVarManager::kOpeningAngle); + + histos->UserHistogram("Pair", + "OpAngle_InvMass","OpAngle_InvMass;Opening angle;Invariant Mass", + 320, 0. , 3.2, 500 , 0. , 4. , + AliDielectronVarManager::kOpeningAngle,AliDielectronVarManager::kM); + + + histos->UserHistogram("Pair", + "Phi","Phi;counts;Phi", + 320, 0. , 6.4, AliDielectronVarManager::kPhi); + + histos->UserHistogram("Pair", + "Y","Y;counts;Y", + 120, -1.2 , 1.2, AliDielectronVarManager::kY); + + die->SetHistogramManager(histos); + +} + + +void InitCF(AliDielectron* die, Int_t cutDefinition) +{ + // + // Setupd the CF Manager if needed + // + AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle()); + + //pair variables + cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.); + //cf->AddVariable(AliDielectronVarManager::kP,200,0,20); + //cf->AddVariable(AliDielectronVarManager::kPhi,64, -3.2, 3.2); + cf->AddVariable(AliDielectronVarManager::kY,40,-2.,2.); + cf->AddVariable(AliDielectronVarManager::kM,500,0.,4.); + //cf->AddVariable(AliDielectronVarManager::kPairType,10,0,10); + //cf->AddVariable(AliDielectronVarManager::kOpeningAngle,315,0,3.15); + //cf->AddVariable(AliDielectronVarManager::kDeltaEta,200,-2,2); + //cf->AddVariable(AliDielectronVarManager::kDeltaPhi,100,0,3.15); + //cf->AddVariable(AliDielectronVarManager::kHaveSameMother,21,-10,10); + cf->AddVariable(AliDielectronVarManager::kNumberOfDaughters,5,0,5); + //leg variables + cf->AddVariable(AliDielectronVarManager::kPt,100,0.,10.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kP,200,0.,20.,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kY,40,-2.,2.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kEta,20,-1.,1.,kTRUE); + cf->AddVariable(AliDielectronVarManager::kPhi,100,0.,3.15,kTRUE); +// cf->AddVariable(AliDielectronVarManager::kITSsignal,1000,0.0.,1000.,kTRUE); +// cf->AddVariable(AliDielectronVarManager::kHaveSameMother,21,-10,10,kTRUE); +// cf->AddVariable(AliDielectronVarManager::kNumberOfDaughters,11,0,10,kTRUE); + + //only in this case write MC truth info + + if (MCenabled) { + cf->SetStepForMCtruth(); + //cf->SetStepsForMCtruthOnly(); + //cf->SetStepForNoCutsMCmotherPid(); + cout << "MC ENABLED ------------------------------------------------------" << endl; + //cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE); + //cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE); + } + + //cf->SetStepsForEachCut(); + //cf->SetStepForPreFilter(); + cf->SetStepForAfterAllCuts(); + //cf->SetStepsForBackground(); + cf->SetStepsForSignal(); + + die->SetCFManagerPair(cf); + +/* + + AliDielectronSignalMC* lowMassDiele=new + AliDielectronSignalMC("lowMassDiele","low mass dielectron pairs"); + lowMassDiele->SetLegPDGs(11,-11); + lowMassDiele->SetCheckBothChargesLegs(kTRUE,kTRUE); + lowMassDiele->SetLegSources(AliDielectronSignalMC::kPrimary, + AliDielectronSignalMC::kPrimary); + lowMassDiele->SetFillPureMCStep(kTRUE); + die->AddSignalMC(lowMassDiele); + + AliDielectronSignalMC* secondary=new + AliDielectronSignalMC("secondary","secondary electrons pairs"); + secondary->SetLegPDGs(11,-11); + secondary->SetCheckBothChargesLegs(kTRUE,kTRUE); + secondary->SetLegSources(AliDielectronSignalMC::kSecondary, + AliDielectronSignalMC::kSecondary); + die->AddSignalMC(secondary); + + AliDielectronSignalMC* eleFromConversions=new + AliDielectronSignalMC("eleFromConversions","conversion electrons"); + eleFromConversions->SetLegPDGs(11,-11); + eleFromConversions->SetCheckBothChargesLegs(kTRUE,kTRUE); + eleFromConversions->SetLegSources(AliDielectronSignalMC::kSecondary, + AliDielectronSignalMC::kSecondary); + eleFromConversions->SetMotherPDGs(22,22); // 22- photon + die->AddSignalMC(eleFromConversions); + + AliDielectronSignalMC* misIdPions=new + AliDielectronSignalMC("misIdPions","mis id. pion pairs"); + misIdPions->SetLegPDGs(211,-211); + misIdPions->SetCheckBothChargesLegs(kTRUE,kTRUE); + die->AddSignalMC(misIdPions); + + AliDielectronSignalMC* dalitzDecays=new + AliDielectronSignalMC("dalitzDecays","dalitz Pairs"); + dalitzDecays->SetLegPDGs(11,-11); + dalitzDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); + dalitzDecays->SetLegSources(AliDielectronSignalMC::kSecondary, + AliDielectronSignalMC::kSecondary); + dalitzDecays->SetMotherPDGs(111,111); + dalitzDecays->SetFillPureMCStep(kTRUE); + die->AddSignalMC(dalitzDecays); +*/ + +AliDielectronSignalMC* PhiDecays= new AliDielectronSignalMC("PhiDecays","Phi Pairs"); +PhiDecays->SetLegPDGs(11,-11); +PhiDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); +PhiDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); +PhiDecays->SetMotherPDGs(333,333); +PhiDecays->SetMothersRelation(AliDielectronSignalMC::kSame); +PhiDecays->SetFillPureMCStep(kTRUE); +die->AddSignalMC(PhiDecays); + +AliDielectronSignalMC* OmegaDecays= new AliDielectronSignalMC("OmegaDecays","Omega Pairs"); +OmegaDecays->SetLegPDGs(11,-11); +OmegaDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); +OmegaDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); +OmegaDecays->SetMotherPDGs(223,223); +OmegaDecays->SetMothersRelation(AliDielectronSignalMC::kSame); +OmegaDecays->SetDalitz(AliDielectronSignalMC::kIsNotDalitz); +OmegaDecays->SetFillPureMCStep(kTRUE); +die->AddSignalMC(OmegaDecays); + +/* +AliDielectronSignalMC* RhoDecays= new AliDielectronSignalMC("RhoDecays","Rho Pairs"); +RhoDecays->SetLegPDGs(11,-11); +RhoDecays->SetCheckBothChargesLegs(kTRUE,kTRUE); +RhoDecays->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); +RhoDecays->SetMotherPDGs(113,113); +RhoDecays->SetMothersRelation(AliDielectronSignalMC::kSame); +RhoDecays->SetFillPureMCStep(kTRUE); +die->AddSignalMC(RhoDecays); + +AliDielectronSignalMC* DieleConti= new AliDielectronSignalMC("DieleConti","low mass ee pairs"); +DieleConti->SetLegPDGs(11,-11); +DieleConti->SetMotherPDGs(0,0,22,22); +DieleConti->SetCheckBothChargesLegs(kTRUE,kTRUE); +DieleConti->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); +DieleConti->SetMothersRelation(AliDielectronSignalMC::kSame); +DieleConti->SetFillPureMCStep(kTRUE); +die->AddSignalMC(DieleConti);*/ + + +} + +//-------------------------------------- + void EnableMC() { + MCenabled=kTRUE; + } diff --git a/PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhoton.h b/PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhoton.h index f3ec467511b..caed174f196 100644 --- a/PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhoton.h +++ b/PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhoton.h @@ -1,292 +1,292 @@ -#ifndef AliAnalysisTaskEMCALPhoton_h -#define AliAnalysisTaskEMCALPhoton_h - -// $Id$ - -class TH1; -class TH2; -class TObjArray; -class AliESDEvent; -class AliMCEvent; -class AliStack; -class AliESDtrack; -class AliESDtrackCuts; -class AliESDCaloCells; -class AliAODEvent; -class AliAODCaloCells; -class AliEMCALGeometry; -class AliOADBContainer; -class AliVCluster; -class AliVCaloCells; -class AliAnalysisTaskEMCALClusterizeFast; -class TParticle; -class TGeoHMatrix; -class AliPhotonHeaderObj; -class AliPhotonConvObj; -class AliPhotonClusterObj; -class AliPhotonCellObj; - -#include "AliAnalysisTaskSE.h" - -class AliAnalysisTaskEMCALPhoton : public AliAnalysisTaskSE { - public: - AliAnalysisTaskEMCALPhoton(); - AliAnalysisTaskEMCALPhoton(const char *name); - virtual ~AliAnalysisTaskEMCALPhoton() {} - - void UserCreateOutputObjects(); - void UserExec(Option_t *option); - void Terminate(Option_t *); - - void SetTrackCuts(AliESDtrackCuts *c) { fTrCuts = c; } - void SetPrimTrackCuts(AliESDtrackCuts *c) { fPrTrCuts = c; } - void SetTimeResTOF(Float_t tr = 130.) { fTimeResTOF = tr; } - void SetMipResponseTPC(Float_t mr = 47.9) { fMipResponseTPC = mr; } - void SetGeoName(const char *n) { fGeoName = n; } - void SetPeriod(const char *n) { fPeriod = n; } - void SetTrainMode(Bool_t t) { fIsTrain = t; } - void SetGridMode(Bool_t g) { fIsGrid = g; } - void SetClusThreshold(Double_t et) { fClusThresh = et; } - void SetClusterizer(AliAnalysisTaskEMCALClusterizeFast *c) { fClusterizer = c; } - void SetMcMode(Bool_t mc) { fIsMC = mc; } - void SetDebugMode(Bool_t d) { fDebug = d; } - void SetRedoV0(Bool_t v) { fRedoV0 = v; } - void FindConversions(); - void FillMyCells(); - void FillMyClusters(); - void FillMyAltClusters(); - void FillIsoTracks(); - void FillMcPart( Int_t itrack, Int_t label); - void GetMcParts(); - Double_t GetMcIsolation( Int_t itrack, Double_t radius, Double_t pt) const; - Double_t GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; - Double_t GetPhiBandEt(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; - // Double_t GetPhiBandEt(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; - Double_t GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax); - Double_t GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const; - - protected: - AliESDtrackCuts *fTrCuts; // track cuts - AliESDtrackCuts *fPrTrCuts; // primary track cuts - TObjArray *fSelTracks; //!pointer to selected inclusive tracks - TObjArray *fSelPrimTracks; //!pointer to selected primary tracks - TClonesArray *fTracks; //!track input array - TClonesArray *fPhotConvArray; //!array of AliPhotonConvObj - TClonesArray *fMyClusts; //!array of AliPhotonClusterObj - TClonesArray *fMyAltClusts; //!array of AliPhotonClusterObj from the alternative clusterizer - TClonesArray *fMyCells; //!array of AliPhotonCellObj - TClonesArray *fMyTracks; //!array of AliPhotonTrackObj - TClonesArray *fMyMcParts; //!array of AliPhotonMcPartObj - AliPhotonHeaderObj *fHeader; //! - AliOADBContainer *fOADBContainer; //!OADB container used to load misalignment matrices - TClonesArray *fCaloClusters; //!pointer to EMCal clusters - TClonesArray *fCaloClustersNew; //!pointer to EMCal clusters v2 - TClonesArray *fAODMCParticles; //!MC particles array for AOD analysis - AliVCaloCells *fVCells; //!pointer to EMCal cells - AliEMCALGeometry *fGeom; // geometry utils - Float_t fTimeResTOF; //TOF time resolution for track PID - Float_t fMipResponseTPC; //TPC mip response for track pid - TString fGeoName; // geometry name (def = EMCAL_FIRSTYEARV1) - TString fPeriod; // string to the LHC period - Bool_t fIsTrain; //variable to set train mode - Bool_t fIsMC; //variable to switch mcparts branch on/off - Bool_t fDebug; //variable to switch debug on/off - Bool_t fRedoV0; //variable to recalculate V0s - must be off for A-A collisions - Bool_t fIsGrid; //variable to set grid mode - Double_t fClusThresh; //!energy threshold for cluster be saved - AliAnalysisTaskEMCALClusterizeFast *fClusterizer; //!pointer for alternative clusterizer - TString fCaloClustersName; //alternative clusterizer name - - - - private: - AliESDEvent *fESD; //! ESD object - AliAODEvent *fAOD; //! AOD object - AliVEvent *fVev; //!virtual event obj - AliMCEvent *fMCEvent; //! MC event object - AliStack *fStack; //!MC particles stack object - TGeoHMatrix *fGeomMatrix[12];//! Geometry misalignment matrices for EMCal - - TList *fOutputList; //! Output list - TTree *fTree; //!output tree - Int_t fMyMcIndex; //!counter of the saved mc particlesx - - //conversion histograms - TH2F *fNV0sBefAndAftRerun; //!check the number of V0s before and after rerun - TH2F *fConversionVtxXY; //! X x Y of found conversion vertices - TH1F *fInvMassV0; //!invariant mass from v0->GetEffMass() - TH1F *fInvMassV0KF; //!invariant mass from the v0 tracks - TH1F *fInvMassV0SS; //!invariant mass from the tracks in the "dirty" finder - TH2F *fDedxPAll; //!dE/dx vs p of all selected tracks - - - - AliAnalysisTaskEMCALPhoton(const AliAnalysisTaskEMCALPhoton&); // not implemented - AliAnalysisTaskEMCALPhoton& operator=(const AliAnalysisTaskEMCALPhoton&); // not implemented - - ClassDef(AliAnalysisTaskEMCALPhoton, 1); // example of analysis -}; - -#endif - -#ifndef AliPhotonObjs_h -#define AliPhotonObjs_h - -class AliPhotonHeaderObj : public TObject -{ - public: AliPhotonHeaderObj() : - TObject(), fInputFileName(""), fTrClassMask(0), fTrCluster(0), fV0Cent(0), fV0(0), fCl1Cent(0), - fCl1(0), fTrCent(0), fTr(0), fNClus(0), fNCells(0), fTrackMult(0), fNMcParts(0) {;} - public: - TString fInputFileName; // used for normalization purposes in MC productions - ULong64_t fTrClassMask; // trigger class mask - UChar_t fTrCluster; // trigger cluster mask - Double32_t fV0Cent; //[0,0,16] v0 cent - Double32_t fV0; //[0,0,16] v0 result used for cent - Double32_t fCl1Cent; //[0,0,16] cl1 cent - Double32_t fCl1; //[0,0,16] cl1 result used for cent - Double32_t fTrCent; //[0,0,16] tr cent - Double32_t fTr; //[0,0,16] tr result used for cent - Int_t fNClus; - Int_t fNCells; - Int_t fTrackMult; - Int_t fNMcParts; - - ClassDef(AliPhotonHeaderObj,5) -}; - -class AliPhotonConvObj : public TObject -{ - public: AliPhotonConvObj() : - TObject(), fPt(0), fEta(0), fPhi(0), fVR(0), fVEta(0), fVPhi(0), fMass(0), fMcLabel(-1), - fNegPt(0), fNegEta(0), fNegPhi(0), fNegDedx(0), fNegMcLabel(-1), - fPosPt(0), fPosEta(0), fPosPhi(0), fPosDedx(0), fPosMcLabel(-1) {;} - public: - Double32_t fPt; //[0,0,16] pt - Double32_t fEta; //[0,0,16] eta - Double32_t fPhi; //[0,0,16] phi - Double32_t fVR; //[0,0,16] prod r (cylinder) - Double32_t fVEta; //[0,0,16] prod eta - Double32_t fVPhi; //[0,0,16] prod phi - Double32_t fMass; //[0,0,16] if correctly filled, should be <50 MeV - Short_t fMcLabel; //corresponding MC label - - //negative daughter - Double32_t fNegPt; //[0,0,16] pt - Double32_t fNegEta; //[0,0,16] eta - Double32_t fNegPhi; //[0,0,16] phi - Double32_t fNegDedx; //[0,0,16] if correctly filled, should be <50 MeV - Short_t fNegMcLabel; //corresponding MC label - - //positive daughter - Double32_t fPosPt; //[0,0,16] pt - Double32_t fPosEta; //[0,0,16] eta - Double32_t fPosPhi; //[0,0,16] phi - Double32_t fPosDedx; //[0,0,16] if correctly filled, should be <50 MeV - Short_t fPosMcLabel; //corresponding MC label - - ClassDef(AliPhotonConvObj,1) // conversion class - -}; -class AliPhotonClusterObj : public TObject -{ - public: AliPhotonClusterObj() : - TObject(), fE(0), fEt(0), fR(0), fEta(0), fPhi(0), fN(0),fEmax(0),fTmax(0), fIdmax(0), fEcross(0),fDisp(-1), - fM20(-1), fM02(-1),fTrDEta(0), fTrDPhi(0), fTrEp(-1), fTrDedx(-1), fTrIso01(0), fTrIso02(0), fTrIso03(0), fTrIso04(0), - fTrPhiBand01(0), fTrPhiBand02(0), fTrPhiBand03(0), fTrPhiBand04(0), fCellsAbsId(""),fMcLabel(-1) - {;} - public: - Double32_t fE; - Double32_t fEt; - Double32_t fR; - Double32_t fEta; - Double32_t fPhi; - UShort_t fN; - Double_t fEmax; - Double_t fTmax; - Short_t fIdmax; - Double_t fEcross; - Double32_t fDisp; - Double32_t fM20; - Double32_t fM02; - Double32_t fTrDEta; - Double32_t fTrDPhi; - Double32_t fTrEp; - Double32_t fTrDedx; - Double32_t fTrIso01; - Double32_t fTrIso02; - Double32_t fTrIso03; - Double32_t fTrIso04; - Double32_t fTrPhiBand01; - Double32_t fTrPhiBand02; - Double32_t fTrPhiBand03; - Double32_t fTrPhiBand04; - TString fCellsAbsId; //cluster cells absid - Short_t fMcLabel; - - - - ClassDef(AliPhotonClusterObj,6) // cluster class - -}; - -class AliPhotonCellObj : public TObject -{ - public: AliPhotonCellObj() : - TObject(), fAbsID(-1), fE(0), fEt(0), fEta(0), fPhi(0), fTime(0) - {;} - public: - Short_t fAbsID; - Double32_t fE; - Double32_t fEt; - Double32_t fEta; - Double32_t fPhi; - Double32_t fTime; - - - - ClassDef(AliPhotonCellObj,1) // cell class - -}; - -class AliPhotonTrackObj : public TObject -{ - public: AliPhotonTrackObj() : - TObject(), fPt(0), fEta(0), fPhi(0), fDedx(0), fCharge(0), fMcLabel(-1) {;} - public: - Double32_t fPt; - Double32_t fEta; - Double32_t fPhi; - Double32_t fDedx; - Short_t fCharge; - Short_t fMcLabel; - - ClassDef(AliPhotonTrackObj,3) -}; - -class AliPhotonMcPartObj : public TObject -{ - public: AliPhotonMcPartObj() : - TObject(), fLabel(-1), fPdg(0), fPt(0), fEta(0), fPhi(0), - fVR(0), fVEta(0), fVPhi(0), fMother(-1), fFirstD(-1), - fLastD(-1), fStatus(-1), fIso(-1), fIso3(-1) {;} - public: - Short_t fLabel; - Short_t fPdg; - Double32_t fPt; - Double32_t fEta; - Double32_t fPhi; - Double32_t fVR; - Double32_t fVEta; - Double32_t fVPhi; - Short_t fMother; - Short_t fFirstD; - Short_t fLastD; - Short_t fStatus; - Double32_t fIso; - Double32_t fIso3; //in cone of radius 0.3 - - ClassDef(AliPhotonMcPartObj,3) -}; - -#endif +#ifndef AliAnalysisTaskEMCALPhoton_h +#define AliAnalysisTaskEMCALPhoton_h + +// $Id$ + +class TH1; +class TH2; +class TObjArray; +class AliESDEvent; +class AliMCEvent; +class AliStack; +class AliESDtrack; +class AliESDtrackCuts; +class AliESDCaloCells; +class AliAODEvent; +class AliAODCaloCells; +class AliEMCALGeometry; +class AliOADBContainer; +class AliVCluster; +class AliVCaloCells; +class AliAnalysisTaskEMCALClusterizeFast; +class TParticle; +class TGeoHMatrix; +class AliPhotonHeaderObj; +class AliPhotonConvObj; +class AliPhotonClusterObj; +class AliPhotonCellObj; + +#include "AliAnalysisTaskSE.h" + +class AliAnalysisTaskEMCALPhoton : public AliAnalysisTaskSE { + public: + AliAnalysisTaskEMCALPhoton(); + AliAnalysisTaskEMCALPhoton(const char *name); + virtual ~AliAnalysisTaskEMCALPhoton() {} + + void UserCreateOutputObjects(); + void UserExec(Option_t *option); + void Terminate(Option_t *); + + void SetTrackCuts(AliESDtrackCuts *c) { fTrCuts = c; } + void SetPrimTrackCuts(AliESDtrackCuts *c) { fPrTrCuts = c; } + void SetTimeResTOF(Float_t tr = 130.) { fTimeResTOF = tr; } + void SetMipResponseTPC(Float_t mr = 47.9) { fMipResponseTPC = mr; } + void SetGeoName(const char *n) { fGeoName = n; } + void SetPeriod(const char *n) { fPeriod = n; } + void SetTrainMode(Bool_t t) { fIsTrain = t; } + void SetGridMode(Bool_t g) { fIsGrid = g; } + void SetClusThreshold(Double_t et) { fClusThresh = et; } + void SetClusterizer(AliAnalysisTaskEMCALClusterizeFast *c) { fClusterizer = c; } + void SetMcMode(Bool_t mc) { fIsMC = mc; } + void SetDebugMode(Bool_t d) { fDebug = d; } + void SetRedoV0(Bool_t v) { fRedoV0 = v; } + void FindConversions(); + void FillMyCells(); + void FillMyClusters(); + void FillMyAltClusters(); + void FillIsoTracks(); + void FillMcPart( Int_t itrack, Int_t label); + void GetMcParts(); + Double_t GetMcIsolation( Int_t itrack, Double_t radius, Double_t pt) const; + Double_t GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; + Double_t GetPhiBandEt(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; + // Double_t GetPhiBandEt(Double_t cEta, Double_t cPhi, Double_t radius=0.2, Double_t pt=0.) const; + Double_t GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax); + Double_t GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const; + + protected: + AliESDtrackCuts *fTrCuts; // track cuts + AliESDtrackCuts *fPrTrCuts; // primary track cuts + TObjArray *fSelTracks; //!pointer to selected inclusive tracks + TObjArray *fSelPrimTracks; //!pointer to selected primary tracks + TClonesArray *fTracks; //!track input array + TClonesArray *fPhotConvArray; //!array of AliPhotonConvObj + TClonesArray *fMyClusts; //!array of AliPhotonClusterObj + TClonesArray *fMyAltClusts; //!array of AliPhotonClusterObj from the alternative clusterizer + TClonesArray *fMyCells; //!array of AliPhotonCellObj + TClonesArray *fMyTracks; //!array of AliPhotonTrackObj + TClonesArray *fMyMcParts; //!array of AliPhotonMcPartObj + AliPhotonHeaderObj *fHeader; //! + AliOADBContainer *fOADBContainer; //!OADB container used to load misalignment matrices + TClonesArray *fCaloClusters; //!pointer to EMCal clusters + TClonesArray *fCaloClustersNew; //!pointer to EMCal clusters v2 + TClonesArray *fAODMCParticles; //!MC particles array for AOD analysis + AliVCaloCells *fVCells; //!pointer to EMCal cells + AliEMCALGeometry *fGeom; // geometry utils + Float_t fTimeResTOF; //TOF time resolution for track PID + Float_t fMipResponseTPC; //TPC mip response for track pid + TString fGeoName; // geometry name (def = EMCAL_FIRSTYEARV1) + TString fPeriod; // string to the LHC period + Bool_t fIsTrain; //variable to set train mode + Bool_t fIsMC; //variable to switch mcparts branch on/off + Bool_t fDebug; //variable to switch debug on/off + Bool_t fRedoV0; //variable to recalculate V0s - must be off for A-A collisions + Bool_t fIsGrid; //variable to set grid mode + Double_t fClusThresh; //!energy threshold for cluster be saved + AliAnalysisTaskEMCALClusterizeFast *fClusterizer; //!pointer for alternative clusterizer + TString fCaloClustersName; //alternative clusterizer name + + + + private: + AliESDEvent *fESD; //! ESD object + AliAODEvent *fAOD; //! AOD object + AliVEvent *fVev; //!virtual event obj + AliMCEvent *fMCEvent; //! MC event object + AliStack *fStack; //!MC particles stack object + TGeoHMatrix *fGeomMatrix[12];//! Geometry misalignment matrices for EMCal + + TList *fOutputList; //! Output list + TTree *fTree; //!output tree + Int_t fMyMcIndex; //!counter of the saved mc particlesx + + //conversion histograms + TH2F *fNV0sBefAndAftRerun; //!check the number of V0s before and after rerun + TH2F *fConversionVtxXY; //! X x Y of found conversion vertices + TH1F *fInvMassV0; //!invariant mass from v0->GetEffMass() + TH1F *fInvMassV0KF; //!invariant mass from the v0 tracks + TH1F *fInvMassV0SS; //!invariant mass from the tracks in the "dirty" finder + TH2F *fDedxPAll; //!dE/dx vs p of all selected tracks + + + + AliAnalysisTaskEMCALPhoton(const AliAnalysisTaskEMCALPhoton&); // not implemented + AliAnalysisTaskEMCALPhoton& operator=(const AliAnalysisTaskEMCALPhoton&); // not implemented + + ClassDef(AliAnalysisTaskEMCALPhoton, 1); // example of analysis +}; + +#endif + +#ifndef AliPhotonObjs_h +#define AliPhotonObjs_h + +class AliPhotonHeaderObj : public TObject +{ + public: AliPhotonHeaderObj() : + TObject(), fInputFileName(""), fTrClassMask(0), fTrCluster(0), fV0Cent(0), fV0(0), fCl1Cent(0), + fCl1(0), fTrCent(0), fTr(0), fNClus(0), fNCells(0), fTrackMult(0), fNMcParts(0) {;} + public: + TString fInputFileName; // used for normalization purposes in MC productions + ULong64_t fTrClassMask; // trigger class mask + UChar_t fTrCluster; // trigger cluster mask + Double32_t fV0Cent; //[0,0,16] v0 cent + Double32_t fV0; //[0,0,16] v0 result used for cent + Double32_t fCl1Cent; //[0,0,16] cl1 cent + Double32_t fCl1; //[0,0,16] cl1 result used for cent + Double32_t fTrCent; //[0,0,16] tr cent + Double32_t fTr; //[0,0,16] tr result used for cent + Int_t fNClus; + Int_t fNCells; + Int_t fTrackMult; + Int_t fNMcParts; + + ClassDef(AliPhotonHeaderObj,5) +}; + +class AliPhotonConvObj : public TObject +{ + public: AliPhotonConvObj() : + TObject(), fPt(0), fEta(0), fPhi(0), fVR(0), fVEta(0), fVPhi(0), fMass(0), fMcLabel(-1), + fNegPt(0), fNegEta(0), fNegPhi(0), fNegDedx(0), fNegMcLabel(-1), + fPosPt(0), fPosEta(0), fPosPhi(0), fPosDedx(0), fPosMcLabel(-1) {;} + public: + Double32_t fPt; //[0,0,16] pt + Double32_t fEta; //[0,0,16] eta + Double32_t fPhi; //[0,0,16] phi + Double32_t fVR; //[0,0,16] prod r (cylinder) + Double32_t fVEta; //[0,0,16] prod eta + Double32_t fVPhi; //[0,0,16] prod phi + Double32_t fMass; //[0,0,16] if correctly filled, should be <50 MeV + Short_t fMcLabel; //corresponding MC label + + //negative daughter + Double32_t fNegPt; //[0,0,16] pt + Double32_t fNegEta; //[0,0,16] eta + Double32_t fNegPhi; //[0,0,16] phi + Double32_t fNegDedx; //[0,0,16] if correctly filled, should be <50 MeV + Short_t fNegMcLabel; //corresponding MC label + + //positive daughter + Double32_t fPosPt; //[0,0,16] pt + Double32_t fPosEta; //[0,0,16] eta + Double32_t fPosPhi; //[0,0,16] phi + Double32_t fPosDedx; //[0,0,16] if correctly filled, should be <50 MeV + Short_t fPosMcLabel; //corresponding MC label + + ClassDef(AliPhotonConvObj,1) // conversion class + +}; +class AliPhotonClusterObj : public TObject +{ + public: AliPhotonClusterObj() : + TObject(), fE(0), fEt(0), fR(0), fEta(0), fPhi(0), fN(0),fEmax(0),fTmax(0), fIdmax(0), fEcross(0),fDisp(-1), + fM20(-1), fM02(-1),fTrDEta(0), fTrDPhi(0), fTrEp(-1), fTrDedx(-1), fTrIso01(0), fTrIso02(0), fTrIso03(0), fTrIso04(0), + fTrPhiBand01(0), fTrPhiBand02(0), fTrPhiBand03(0), fTrPhiBand04(0), fCellsAbsId(""),fMcLabel(-1) + {;} + public: + Double32_t fE; + Double32_t fEt; + Double32_t fR; + Double32_t fEta; + Double32_t fPhi; + UShort_t fN; + Double_t fEmax; + Double_t fTmax; + Short_t fIdmax; + Double_t fEcross; + Double32_t fDisp; + Double32_t fM20; + Double32_t fM02; + Double32_t fTrDEta; + Double32_t fTrDPhi; + Double32_t fTrEp; + Double32_t fTrDedx; + Double32_t fTrIso01; + Double32_t fTrIso02; + Double32_t fTrIso03; + Double32_t fTrIso04; + Double32_t fTrPhiBand01; + Double32_t fTrPhiBand02; + Double32_t fTrPhiBand03; + Double32_t fTrPhiBand04; + TString fCellsAbsId; //cluster cells absid + Short_t fMcLabel; + + + + ClassDef(AliPhotonClusterObj,6) // cluster class + +}; + +class AliPhotonCellObj : public TObject +{ + public: AliPhotonCellObj() : + TObject(), fAbsID(-1), fE(0), fEt(0), fEta(0), fPhi(0), fTime(0) + {;} + public: + Short_t fAbsID; + Double32_t fE; + Double32_t fEt; + Double32_t fEta; + Double32_t fPhi; + Double32_t fTime; + + + + ClassDef(AliPhotonCellObj,1) // cell class + +}; + +class AliPhotonTrackObj : public TObject +{ + public: AliPhotonTrackObj() : + TObject(), fPt(0), fEta(0), fPhi(0), fDedx(0), fCharge(0), fMcLabel(-1) {;} + public: + Double32_t fPt; + Double32_t fEta; + Double32_t fPhi; + Double32_t fDedx; + Short_t fCharge; + Short_t fMcLabel; + + ClassDef(AliPhotonTrackObj,3) +}; + +class AliPhotonMcPartObj : public TObject +{ + public: AliPhotonMcPartObj() : + TObject(), fLabel(-1), fPdg(0), fPt(0), fEta(0), fPhi(0), + fVR(0), fVEta(0), fVPhi(0), fMother(-1), fFirstD(-1), + fLastD(-1), fStatus(-1), fIso(-1), fIso3(-1) {;} + public: + Short_t fLabel; + Short_t fPdg; + Double32_t fPt; + Double32_t fEta; + Double32_t fPhi; + Double32_t fVR; + Double32_t fVEta; + Double32_t fVPhi; + Short_t fMother; + Short_t fFirstD; + Short_t fLastD; + Short_t fStatus; + Double32_t fIso; + Double32_t fIso3; //in cone of radius 0.3 + + ClassDef(AliPhotonMcPartObj,3) +}; + +#endif diff --git a/PWGGA/GammaConv/AliAnaConvCorrBase.h b/PWGGA/GammaConv/AliAnaConvCorrBase.h index 48f7b877523..c9872e0deac 100644 --- a/PWGGA/GammaConv/AliAnaConvCorrBase.h +++ b/PWGGA/GammaConv/AliAnaConvCorrBase.h @@ -1,109 +1,109 @@ -/* This file is property of and copyright * - * ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/// @file AliAnaConvCorrPhoton.h -/// @author Svein Lindal -/// @brief Base class for analysis of correlations between conversion particles and charged tracks - -#ifndef ALIANACONVCORRBASE_CXX -#define ALIANACONVCORRBASE_CXX - -#include "Rtypes.h" -#include "TMath.h" -#include "TList.h" -#include "TH1.h" -#include - -class AliAODConversionParticle; -class TClonesArray; -class TString; - -class AliAnaConvCorrBase : public TNamed { - -public: - - - - //Constructor / desctructor - AliAnaConvCorrBase(TString name, TString title); - virtual ~AliAnaConvCorrBase(); - - //CreateHistograms - void CreateBaseHistograms(); - //To be overrriden by children. Should always call CreateBaseHistograms() - virtual void CreateHistograms(); - - //Get list of histograms - TList * GetHistograms() const { return fHistograms;} - - //Add histogram to list - void AddHistogram(TH1 * histogram) { fHistograms->Add(dynamic_cast(histogram));} - - void AddAxis(TAxis * axis) { fAxesList.Add(axis); } - - ///Get the distance in phi between trigger particle and correlated particle - Float_t GetDPhi(Float_t dPhi) { - if ( dPhi < 3*TMath::PiOver2() && dPhi > - TMath::PiOver2() ) return dPhi; - else return ( (dPhi>0)? dPhi - TMath::TwoPi() : dPhi + TMath::TwoPi() ); - } - - void CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, const Int_t tIDs[4], Float_t cent, Float_t vtxz); - void FillCounters(TObjArray * particles, TObjArray * tracks, Float_t cent, Float_t vtxz); - - TAxis& GetAxistPt() { return fAxistPt; } - TAxis& GetAxiscPt() { return fAxiscPt; } - TAxis& GetAxisdEta() { return fAxisdEta; } - TAxis& GetAxisdPhi() { return fAxisdPhi; } - TAxis& GetAxisIso() { return fAxisIso; } - TAxis& GetAxisCent() { return fAxisCent; } - TAxis& GetAxisZ() { return fAxisZ; } - TAxis& GetAxisTrigEta() { return fAxisTrigEta; } - TAxis& GetAxisAssEta() { return fAxisAssEta; } - TAxis& GetAxisMEPhi() { return fAxisMEPhi; } - - TList& GetAxisList() { return fAxesList; } - TList& GetTrackAxisList() { return fTrackAxisList; } - TList& GetTrigAxisList() { return fTrigAxisList; } - - -protected: - - THnSparseF * CreateSparse(TString name, TString title, TList * axes); - -private: - - void SetUpDefaultBins(); - - //TString fName; //name of analysis - TList * fHistograms; //List of histograms - TList fAxesList; //List over axes to be used in sparse - TList fTrigAxisList; //list - TList fTrackAxisList; //list - - TAxis fAxistPt; //Pt axis - TAxis fAxiscPt; //correlated particle pt axis - TAxis fAxisdEta; //delta eta axis - TAxis fAxisdPhi; //delta phi axis - TAxis fAxisIso; //Isolated particle axis - TAxis fAxisCent; //Centrality - TAxis fAxisZ; //vtx - - TAxis fAxisTrigEta ; //Eta axis for ME - TAxis fAxisAssEta ; //Eta axis for ME - TAxis fAxisMEPhi ; //Phi axis for ME - - THnSparseF * fCorrSparse; // Sparse for corr - THnSparseF * fTrigSparse; // ME Sparse - THnSparseF * fTrackSparse; //Track Sparse - - //Default constructor prohibited - AliAnaConvCorrBase(); //not implemented - AliAnaConvCorrBase(const AliAnaConvCorrBase&); // not implemented - AliAnaConvCorrBase& operator=(const AliAnaConvCorrBase&); // not implemented - - ClassDef(AliAnaConvCorrBase, 7); // example of analysis - -}; - -#endif +/* This file is property of and copyright * + * ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/// @file AliAnaConvCorrPhoton.h +/// @author Svein Lindal +/// @brief Base class for analysis of correlations between conversion particles and charged tracks + +#ifndef ALIANACONVCORRBASE_CXX +#define ALIANACONVCORRBASE_CXX + +#include "Rtypes.h" +#include "TMath.h" +#include "TList.h" +#include "TH1.h" +#include + +class AliAODConversionParticle; +class TClonesArray; +class TString; + +class AliAnaConvCorrBase : public TNamed { + +public: + + + + //Constructor / desctructor + AliAnaConvCorrBase(TString name, TString title); + virtual ~AliAnaConvCorrBase(); + + //CreateHistograms + void CreateBaseHistograms(); + //To be overrriden by children. Should always call CreateBaseHistograms() + virtual void CreateHistograms(); + + //Get list of histograms + TList * GetHistograms() const { return fHistograms;} + + //Add histogram to list + void AddHistogram(TH1 * histogram) { fHistograms->Add(dynamic_cast(histogram));} + + void AddAxis(TAxis * axis) { fAxesList.Add(axis); } + + ///Get the distance in phi between trigger particle and correlated particle + Float_t GetDPhi(Float_t dPhi) { + if ( dPhi < 3*TMath::PiOver2() && dPhi > - TMath::PiOver2() ) return dPhi; + else return ( (dPhi>0)? dPhi - TMath::TwoPi() : dPhi + TMath::TwoPi() ); + } + + void CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, const Int_t tIDs[4], Float_t cent, Float_t vtxz); + void FillCounters(TObjArray * particles, TObjArray * tracks, Float_t cent, Float_t vtxz); + + TAxis& GetAxistPt() { return fAxistPt; } + TAxis& GetAxiscPt() { return fAxiscPt; } + TAxis& GetAxisdEta() { return fAxisdEta; } + TAxis& GetAxisdPhi() { return fAxisdPhi; } + TAxis& GetAxisIso() { return fAxisIso; } + TAxis& GetAxisCent() { return fAxisCent; } + TAxis& GetAxisZ() { return fAxisZ; } + TAxis& GetAxisTrigEta() { return fAxisTrigEta; } + TAxis& GetAxisAssEta() { return fAxisAssEta; } + TAxis& GetAxisMEPhi() { return fAxisMEPhi; } + + TList& GetAxisList() { return fAxesList; } + TList& GetTrackAxisList() { return fTrackAxisList; } + TList& GetTrigAxisList() { return fTrigAxisList; } + + +protected: + + THnSparseF * CreateSparse(TString name, TString title, TList * axes); + +private: + + void SetUpDefaultBins(); + + //TString fName; //name of analysis + TList * fHistograms; //List of histograms + TList fAxesList; //List over axes to be used in sparse + TList fTrigAxisList; //list + TList fTrackAxisList; //list + + TAxis fAxistPt; //Pt axis + TAxis fAxiscPt; //correlated particle pt axis + TAxis fAxisdEta; //delta eta axis + TAxis fAxisdPhi; //delta phi axis + TAxis fAxisIso; //Isolated particle axis + TAxis fAxisCent; //Centrality + TAxis fAxisZ; //vtx + + TAxis fAxisTrigEta ; //Eta axis for ME + TAxis fAxisAssEta ; //Eta axis for ME + TAxis fAxisMEPhi ; //Phi axis for ME + + THnSparseF * fCorrSparse; // Sparse for corr + THnSparseF * fTrigSparse; // ME Sparse + THnSparseF * fTrackSparse; //Track Sparse + + //Default constructor prohibited + AliAnaConvCorrBase(); //not implemented + AliAnaConvCorrBase(const AliAnaConvCorrBase&); // not implemented + AliAnaConvCorrBase& operator=(const AliAnaConvCorrBase&); // not implemented + + ClassDef(AliAnaConvCorrBase, 7); // example of analysis + +}; + +#endif diff --git a/PWGGA/GammaConv/AliAnaConvCorrPion.h b/PWGGA/GammaConv/AliAnaConvCorrPion.h index 24d47972b13..60541fe6770 100644 --- a/PWGGA/GammaConv/AliAnaConvCorrPion.h +++ b/PWGGA/GammaConv/AliAnaConvCorrPion.h @@ -1,44 +1,44 @@ -/* This file is property of and copyright * - * ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/// @file AliAnaConvCorrPion.h -/// @author Svein Lindal -/// @brief Class used to find correlations between pions and charged tracks - - -#ifndef ALIANACONVCORRPION_CXX -#define ALIANACONVCORRPION_CXX - -#include "AliAnaConvCorrBase.h" -class TH2D; -//#include "THnSparse.h" - -//class AliAODConversionPhoton; -class TClonesArray; - -class AliAnaConvCorrPion : public AliAnaConvCorrBase { - -public: - - AliAnaConvCorrPion(); - AliAnaConvCorrPion(TString name, TString title); - virtual ~AliAnaConvCorrPion(); - - TAxis& GetAxisM() { return fAxisM; } - void CreateHistograms(); - void FillTriggerCounters(const AliAODConversionParticle * particle); - - private: - - void InitMassAxis(); - TH2D * hTriggerPtvsMass; //Histograms containing number of triggers in various bins - TAxis fAxisM; //Mass axis - - AliAnaConvCorrPion(const AliAnaConvCorrPion&); // not implemented - AliAnaConvCorrPion& operator=(const AliAnaConvCorrPion&); // not implemented - ClassDef(AliAnaConvCorrPion, 3); // - -}; - -#endif +/* This file is property of and copyright * + * ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/// @file AliAnaConvCorrPion.h +/// @author Svein Lindal +/// @brief Class used to find correlations between pions and charged tracks + + +#ifndef ALIANACONVCORRPION_CXX +#define ALIANACONVCORRPION_CXX + +#include "AliAnaConvCorrBase.h" +class TH2D; +//#include "THnSparse.h" + +//class AliAODConversionPhoton; +class TClonesArray; + +class AliAnaConvCorrPion : public AliAnaConvCorrBase { + +public: + + AliAnaConvCorrPion(); + AliAnaConvCorrPion(TString name, TString title); + virtual ~AliAnaConvCorrPion(); + + TAxis& GetAxisM() { return fAxisM; } + void CreateHistograms(); + void FillTriggerCounters(const AliAODConversionParticle * particle); + + private: + + void InitMassAxis(); + TH2D * hTriggerPtvsMass; //Histograms containing number of triggers in various bins + TAxis fAxisM; //Mass axis + + AliAnaConvCorrPion(const AliAnaConvCorrPion&); // not implemented + AliAnaConvCorrPion& operator=(const AliAnaConvCorrPion&); // not implemented + ClassDef(AliAnaConvCorrPion, 3); // + +}; + +#endif diff --git a/PWGGA/GammaConv/AliDalitzElectronCuts.cxx b/PWGGA/GammaConv/AliDalitzElectronCuts.cxx index ae70d955f12..c6d3d7209a2 100644 --- a/PWGGA/GammaConv/AliDalitzElectronCuts.cxx +++ b/PWGGA/GammaConv/AliDalitzElectronCuts.cxx @@ -1,1802 +1,1802 @@ - -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Authors: Svein Lindal, Daniel Lohner * - * Version 1.0 * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -//////////////////////////////////////////////// -//--------------------------------------------- -// Class handling all kinds of selection cuts for -// Gamma Conversion analysis -//--------------------------------------------- -//////////////////////////////////////////////// - - -#include "AliDalitzElectronCuts.h" -#include "AliAODConversionPhoton.h" -#include "AliKFVertex.h" -#include "AliAODTrack.h" -#include "AliESDtrack.h" -#include "AliAnalysisManager.h" -#include "AliInputEventHandler.h" -#include "AliMCEventHandler.h" -#include "AliAODHandler.h" -#include "AliPIDResponse.h" -#include "TH1.h" -#include "TH2.h" -#include "AliStack.h" -#include "TObjString.h" -#include "AliAODEvent.h" -#include "AliESDEvent.h" -#include "TList.h" -class iostream; - -using namespace std; - -ClassImp(AliDalitzElectronCuts) - - -const char* AliDalitzElectronCuts::fgkCutNames[AliDalitzElectronCuts::kNCuts] = { -"GoodId", -"ededxSigmaITSCut", -"ededxSigmaTPCCut", -"pidedxSigmaTPCCut", -"piMinMomdedxSigmaTPCCut", -"piMaxMomdedxSigmaTPCCut", -"LowPRejectionSigmaCut", -"kTOFelectronPID", -"clsITSCut", -"clsTPCCut", -"EtaCut", -"PsiPair", -"RejectSharedElecGamma", -"BackgroundScheme", -"NumberOfRotations", -"PtCut", -"DCAcut", -"MassCut", -"kWeights" -}; - -//________________________________________________________________________ -AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title) : AliAnalysisCuts(name,title), - fHistograms(NULL), - fPIDResponse(NULL), - fesdTrackCuts(NULL), - fEtaCut(0.9), - fEtaShift(0.0), - fDoEtaCut(kFALSE), - fPtCut(0.0), - fRadiusCut(1000.0), - fPsiPairCut(0.45), - fDeltaPhiCutMin(0.), - fDeltaPhiCutMax(0.12), - fMinClsTPC(0), // minimum clusters in the TPC - fMinClsTPCToF(0), // minimum clusters to findable clusters - fDodEdxSigmaITSCut(kFALSE), - fDodEdxSigmaTPCCut(kTRUE), - fDoTOFsigmaCut(kFALSE), // RRnewTOF - fDoRejectSharedElecGamma(kFALSE), - fDoPsiPairCut(kFALSE), - fPIDnSigmaAboveElectronLineITS(100), - fPIDnSigmaBelowElectronLineITS(-100), - fPIDnSigmaAboveElectronLineTPC(100), - fPIDnSigmaBelowElectronLineTPC(-100), - fPIDnSigmaAbovePionLineTPC(0), - fPIDnSigmaAbovePionLineTPCHighPt(-100), - fTofPIDnSigmaAboveElectronLine(100), // RRnewTOF - fTofPIDnSigmaBelowElectronLine(-100), // RRnewTOF - fPIDMinPnSigmaAbovePionLineTPC(0), - fPIDMaxPnSigmaAbovePionLineTPC(0), - fDoKaonRejectionLowP(kFALSE), - fDoProtonRejectionLowP(kFALSE), - fDoPionRejectionLowP(kFALSE), - fPIDnSigmaAtLowPAroundKaonLine(0), - fPIDnSigmaAtLowPAroundProtonLine(0), - fPIDnSigmaAtLowPAroundPionLine(0), - fPIDMinPKaonRejectionLowP(1.5), - fPIDMinPProtonRejectionLowP(2.0), - fPIDMinPPionRejectionLowP(0.5), - fUseCorrectedTPCClsInfo(kFALSE), - fUseTOFpid(kFALSE), - fRequireTOF(kFALSE), - fUseTrackMultiplicityForBG(kFALSE), - fBKGMethod(0), - fnumberOfRotationEventsForBG(0), - fDoMassCut(kFALSE), - fMassCutLowPt(999.), - fMassCutHighPt(999.), - fMassCutPtMin(-100.0), - fDoWeights(kFALSE), - fCutString(NULL), - hCutIndex(NULL), - hdEdxCuts(NULL), - hITSdEdxbefore(NULL), - hITSdEdxafter(NULL), - hTPCdEdxbefore(NULL), - hTPCdEdxafter(NULL), - hTPCdEdxSignalbefore(NULL), - hTPCdEdxSignalafter(NULL), - hTOFbefore(NULL), - hTOFafter(NULL), - hTrackDCAxyPtbefore(NULL), - hTrackDCAxyPtafter(NULL), - hTrackDCAzPtbefore(NULL), - hTrackDCAzPtafter(NULL), - hTrackNFindClsPtTPCbefore(NULL), - hTrackNFindClsPtTPCafter(NULL) - { - InitPIDResponse(); - for(Int_t jj=0;jjSetName(Form("ElectronCuts_%s",cutName.Data())); - else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data())); - } - - - hCutIndex=new TH1F(Form("IsElectronSelected %s",cutName.Data()),"IsElectronSelected",10,-0.5,9.5); - hCutIndex->GetXaxis()->SetBinLabel(kElectronIn+1,"in"); - hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks"); - hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts"); - hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx"); - hCutIndex->GetXaxis()->SetBinLabel(kElectronOut+1,"out"); - fHistograms->Add(hCutIndex); - - - - // dEdx Cuts - hdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",10,-0.5,9.5); - hdEdxCuts->GetXaxis()->SetBinLabel(1,"in"); - hdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSelectron"); - hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCelectron"); - hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpion"); - hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCpionhighp"); - hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCkaonlowprej"); - hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCprotonlowprej"); - hdEdxCuts->GetXaxis()->SetBinLabel(8,"TPCpionlowprej"); - hdEdxCuts->GetXaxis()->SetBinLabel(9,"TOFelectron"); - hdEdxCuts->GetXaxis()->SetBinLabel(10,"out"); - fHistograms->Add(hdEdxCuts); - - - - TAxis *AxisBeforeITS = NULL; - TAxis *AxisBeforedEdx = NULL; - TAxis *AxisBeforeTOF = NULL; - TAxis *AxisBeforedEdxSignal = NULL; - - if(preCut){ - - - hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",cutName.Data()),"ITS dEdx electron before" ,150,0.05,20,400,-10,10); - fHistograms->Add(hITSdEdxbefore); - AxisBeforeITS = hITSdEdxbefore->GetXaxis(); - - hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",cutName.Data()),"dEdx electron before" ,150,0.05,20,400,-10,10); - fHistograms->Add(hTPCdEdxbefore); - AxisBeforedEdx = hTPCdEdxbefore->GetXaxis(); - - hTPCdEdxSignalbefore=new TH2F(Form("Electron_dEdxSignal_before %s",cutName.Data()),"dEdx electron signal before" ,150,0.05,20.0,800,0.0,200); - fHistograms->Add(hTPCdEdxSignalbefore); - AxisBeforedEdxSignal = hTPCdEdxSignalbefore->GetXaxis(); - - hTOFbefore=new TH2F(Form("Electron_TOF_before %s",cutName.Data()),"TOF electron before" ,150,0.05,20,400,-6,10); - fHistograms->Add(hTOFbefore); - AxisBeforeTOF = hTOFbefore->GetXaxis(); - - hTrackDCAxyPtbefore = new TH2F(Form("hTrack_DCAxy_Pt_before %s",cutName.Data()),"DCAxy Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.); - fHistograms->Add(hTrackDCAxyPtbefore); - - hTrackDCAzPtbefore = new TH2F(Form("hTrack_DCAz_Pt_before %s",cutName.Data()), "DCAz Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.); - fHistograms->Add(hTrackDCAzPtbefore); - - hTrackNFindClsPtTPCbefore = new TH2F(Form("hTrack_NFindCls_Pt_TPC_before %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt before",100,0,1,400,0.,10.); - fHistograms->Add(hTrackNFindClsPtTPCbefore); - - - - } - - - hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",cutName.Data()),"ITS dEdx electron after" ,150,0.05,20,400, -10,10); - fHistograms->Add(hITSdEdxafter); - - hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",cutName.Data()),"dEdx electron after" ,150,0.05,20,400, -10,10); - fHistograms->Add(hTPCdEdxafter); - - hTPCdEdxSignalafter=new TH2F(Form("Electron_dEdxSignal_after %s",cutName.Data()),"dEdx electron signal after" ,150,0.05,20.0,800,0.0,200); - fHistograms->Add(hTPCdEdxSignalafter); - - hTOFafter=new TH2F(Form("Electron_TOF_after %s",cutName.Data()),"TOF electron after" ,150,0.05,20,400,-6,10); - fHistograms->Add(hTOFafter); - - hTrackDCAxyPtafter = new TH2F(Form("hTrack_DCAxy_Pt_after %s",cutName.Data()),"DCAxy Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.); - fHistograms->Add(hTrackDCAxyPtafter); - - hTrackDCAzPtafter = new TH2F(Form("hTrack_DCAz_Pt_after %s",cutName.Data()), "DCAz Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.); - fHistograms->Add(hTrackDCAzPtafter); - - hTrackNFindClsPtTPCafter = new TH2F(Form("hTrack_NFindCls_Pt_TPC_after %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt after",100,0,1,400,0.,10.); - fHistograms->Add(hTrackNFindClsPtTPCafter); - - - - TAxis *AxisAfter = hTPCdEdxafter->GetXaxis(); - Int_t bins = AxisAfter->GetNbins(); - Double_t from = AxisAfter->GetXmin(); - Double_t to = AxisAfter->GetXmax(); - Double_t *newBins = new Double_t[bins+1]; - newBins[0] = from; - Double_t factor = TMath::Power(to/from, 1./bins); - for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1]; - AxisAfter->Set(bins, newBins); - AxisAfter = hTOFafter->GetXaxis(); - AxisAfter->Set(bins, newBins); - AxisAfter = hITSdEdxafter->GetXaxis(); - AxisAfter->Set(bins,newBins); - AxisAfter = hTPCdEdxSignalafter->GetXaxis(); - AxisAfter->Set(bins,newBins); - - if(preCut){ - AxisBeforeITS->Set(bins, newBins); - AxisBeforedEdx->Set(bins, newBins); - AxisBeforedEdxSignal->Set(bins,newBins); - AxisBeforeTOF->Set(bins, newBins); - - } - delete [] newBins; - - - // Event Cuts and Info -} - - -//________________________________________________________________________ -Bool_t AliDalitzElectronCuts::InitPIDResponse(){ - -// Set Pointer to AliPIDResponse - - AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); - - if(man) { - - AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); - fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse(); - if(fPIDResponse)return kTRUE; - - } - - return kFALSE; -} -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::ElectronIsSelectedMC(Int_t labelParticle,AliStack *fMCStack) -{ - if( labelParticle < 0 || labelParticle >= fMCStack->GetNtrack() ) return kFALSE; - if( fMCStack->IsPhysicalPrimary(labelParticle) == kFALSE ) return kFALSE; //Ask Ana - - TParticle* particle = fMCStack->Particle(labelParticle); - - if( TMath::Abs( particle->GetPdgCode() ) != 11 ) return kFALSE; - - if( fDoEtaCut ){ - if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) ) - return kFALSE; - } - - -return kTRUE; -} - - -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::ElectronIsSelected(AliESDtrack* lTrack) -{ - //Selection of Reconstructed electrons - - - Float_t b[2]; - Float_t bCov[3]; - lTrack->GetImpactParameters(b,bCov); - - if (bCov[0]<=0 || bCov[2]<=0) { - AliDebug(1, "Estimated b resolution lower or equal zero!"); - bCov[0]=0; bCov[2]=0; - } - - - - Float_t dcaToVertexXY = b[0]; - Float_t dcaToVertexZ = b[1]; - Double_t clsToF = GetNFindableClustersTPC(lTrack); - - if( hTrackDCAxyPtbefore) hTrackDCAxyPtbefore->Fill(dcaToVertexXY,lTrack->Pt()); - if( hTrackDCAzPtbefore ) hTrackDCAzPtbefore->Fill( dcaToVertexZ, lTrack->Pt()); - if( hTrackNFindClsPtTPCbefore ) hTrackNFindClsPtTPCbefore->Fill( clsToF, lTrack->Pt()); - - - - if(hCutIndex)hCutIndex->Fill(kElectronIn); - - if (lTrack == NULL){ - if(hCutIndex)hCutIndex->Fill(kNoTracks); - return kFALSE; - } - - if ( ! lTrack->GetConstrainedParam() ){ - return kFALSE; - } - AliVTrack * track = dynamic_cast(lTrack); - - - // Track Cuts - if( !TrackIsSelected(lTrack) ){ - if(hCutIndex)hCutIndex->Fill(kTrackCuts); - return kFALSE; - } - - - // dEdx Cuts - if( ! dEdxCuts( track ) ) { - if(hCutIndex)hCutIndex->Fill(kdEdxCuts); - return kFALSE; - - } - - //Electron passed the cuts - if(hCutIndex)hCutIndex->Fill(kElectronOut); - - if( hTrackDCAxyPtafter) hTrackDCAxyPtafter->Fill(dcaToVertexXY,lTrack->Pt()); - if( hTrackDCAzPtafter ) hTrackDCAzPtafter->Fill(dcaToVertexZ,lTrack->Pt()); - if( hTrackNFindClsPtTPCafter ) hTrackNFindClsPtTPCafter->Fill( clsToF, lTrack->Pt()); - - - return kTRUE; -} - -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::TrackIsSelected(AliESDtrack* lTrack) { - // Track Selection for Photon Reconstruction - - - Double_t clsToF = GetNFindableClustersTPC(lTrack); - - - if( ! fesdTrackCuts->AcceptTrack(lTrack) ){ - - return kFALSE; - } - - if( fDoEtaCut ) { - if( lTrack->Eta() > (fEtaCut + fEtaShift) || lTrack->Eta() < (-fEtaCut + fEtaShift) ) { - return kFALSE; - } - } - - - if( lTrack->Pt() < fPtCut ) { - - return kFALSE; - - } - - - - if( clsToF < fMinClsTPCToF){ - return kFALSE; - } - - - - return kTRUE; -} -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){ - - // Electron Identification Cuts for Photon reconstruction - - if(!fPIDResponse){ InitPIDResponse(); }// Try to reinitialize PID Response - if(!fPIDResponse){ AliError("No PID Response"); return kFALSE;}// if still missing fatal error - - - - //cout<<"dEdxCuts: //////////////////////////////////////////////////////////////////////////"<Fill(cutIndex); - if(hITSdEdxbefore)hITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron)); - if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron)); - if(hTPCdEdxSignalbefore)hTPCdEdxSignalbefore->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal())); - - - cutIndex++; - - - if( fDodEdxSigmaITSCut == kTRUE ){ - - - if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)> fPIDnSigmaAboveElectronLineITS ){ - - if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); - return kFALSE; - } - - } - - if(hITSdEdxafter)hITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron)); - - - cutIndex++; - - - if(fDodEdxSigmaTPCCut == kTRUE){ - - - // TPC Electron Line - if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLineTPC){ - - if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); - return kFALSE; - } - cutIndex++; - - // TPC Pion Line - if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLineTPC && fCurrentTrack->P()NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC && - fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)Fill(cutIndex); - return kFALSE; - } - } - cutIndex++; - - // High Pt Pion rej - if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLineTPC ){ - if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC && - fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)Fill(cutIndex); - return kFALSE; - } - } - - cutIndex++; - } - - else{ cutIndex+=3; } - - - if( fDoKaonRejectionLowP == kTRUE ){ - - if( fCurrentTrack->P() < fPIDMinPKaonRejectionLowP ){ - - if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))Fill(cutIndex); - - return kFALSE; - } - } - } - cutIndex++; - - if( fDoProtonRejectionLowP == kTRUE ){ - - if( fCurrentTrack->P() < fPIDMinPProtonRejectionLowP ){ - if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))Fill(cutIndex); - return kFALSE; - } - } - } - cutIndex++; - - if(fDoPionRejectionLowP == kTRUE){ - if( fCurrentTrack->P() < fPIDMinPPionRejectionLowP ){ - if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)) < fPIDnSigmaAtLowPAroundPionLine ){ - - if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); - return kFALSE; - } - } - } - cutIndex++; - - - if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){ - if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)); - if(fUseTOFpid){ - if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine || - fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)Fill(cutIndex); - return kFALSE; - } - } - if(hTOFafter)hTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)); - } - else if ( fRequireTOF == kTRUE ) { - - if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); - return kFALSE; - } - cutIndex++; - - if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); - if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron)); - if(hTPCdEdxSignalafter)hTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal())); - - return kTRUE; -} -///________________________________________________________________________ - - -AliVTrack *AliDalitzElectronCuts::GetTrack(AliVEvent * event, Int_t label){ - //Returns pointer to the track with given ESD label - //(Important for AOD implementation, since Track array in AOD data is different - //from ESD array, but ESD tracklabels are stored in AOD Tracks) - - AliESDEvent * esdEvent = dynamic_cast(event); - if(esdEvent) { - if(label > event->GetNumberOfTracks() ) return NULL; - AliESDtrack * track = esdEvent->GetTrack(label); - return track; - - } else { - for(Int_t ii=0; iiGetNumberOfTracks(); ii++) { - AliVTrack * track = dynamic_cast(event->GetTrack(ii)); - - if(track) { - if(track->GetID() == label) { - return track; - } - } - } - } - - cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl; - return NULL; -} -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::RejectSharedElecGamma(TList *photons, Int_t indexEle){ - - - for(Int_t i = 0;iGetEntries();i++){ - - AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i); - - Int_t posLabel = photonComp->GetTrackLabelPositive(); - Int_t negLabel = photonComp->GetTrackLabelNegative(); - - if( (photonComp->GetConversionRadius() < fRadiusCut) && (posLabel == indexEle || negLabel == indexEle) ){ - return kFALSE; - } - } - - return kTRUE; -} -Bool_t AliDalitzElectronCuts::MassCut(Double_t pi0CandidatePt , Double_t vphotonCandidateMass){ - - if( pi0CandidatePt < fMassCutPtMin ){ - - if( vphotonCandidateMass < fMassCutLowPt ){ - return kTRUE; - } - - } - else{ - - if( vphotonCandidateMass < fMassCutHighPt ){ - return kTRUE; - } - - } - - return kFALSE; - -} - -Double_t AliDalitzElectronCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){ - - - Double_t clsToF=0; - - - if ( !fUseCorrectedTPCClsInfo ){ - if(lTrack->GetTPCNclsF()!=0){ - - clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF(); - }// Ncluster/Nfindablecluster - } - else { - - //clsToF = lTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius())); - clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike - - } - - return clsToF; - -} - -/* -Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) -{ -// -// This angle is a measure for the contribution of the opening in polar -// direction ??0 to the opening angle ?? Pair -// -// Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC -// Master Thesis. Thorsten Dahms. 2005 -// https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf -// - Double_t momPos[3]; - Double_t momNeg[3]; - if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos ); - if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg ); - - TVector3 posDaughter; - TVector3 negDaughter; - - posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] ); - negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] ); - - Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta(); - Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) ); - - if( openingAngle < 1e-20 ) return 0.; - - Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle ); - - return psiAngle; -}*/ - -Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi ) -{ -// -// Returns true if it is a gamma conversion according to psi pair value -// - return ( (deltaPhi > fDeltaPhiCutMin && deltaPhi < fDeltaPhiCutMax) && - TMath::Abs(psiPair) < ( fPsiPairCut - fPsiPairCut/fDeltaPhiCutMax * deltaPhi ) ); -} - -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::UpdateCutString(cutIds cutID, Int_t value) { -///Update the cut string (if it has been created yet) - - if(fCutString && fCutString->GetString().Length() == kNCuts) { -// cout << "Updating cut id in spot number " << cutID << " to " << value << endl; - fCutString->SetString(GetCutNumber()); - } else { -// cout << "fCutString not yet initialized, will not be updated" << endl; - return kFALSE; - } - // cout << fCutString->GetString().Data() << endl; - return kTRUE; -} - -///________________________________________________________________________ -Bool_t AliDalitzElectronCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) { - // Initialize Cuts from a given Cut string - -// out<<"Set Cut Number: "<SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff); - break; - case 1: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst); - break; //1 hit first layer of SPD - case 2: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - break; //1 hit in any layer of SPD - case 3: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst); - fesdTrackCuts->SetMinNClustersITS(4); - // 4 hits in total in the ITS. At least 1 hit in the first layer of SPD - break; - case 4: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - fesdTrackCuts->SetMinNClustersITS(3); - // 3 hits in total in the ITS. At least 1 hit in any layer of SPD - break; - case 5: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - fesdTrackCuts->SetMinNClustersITS(4); - // 4 hits in total in the ITS. At least 1 hit in any layer of SPD - break; - case 6: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - fesdTrackCuts->SetMinNClustersITS(5); - // 5 hits in total in the ITS. At least 1 hit in any layer of SPD - break; - default: - cout<<"Warning: clsITSCut not defined "<SetMinNClustersTPC(fMinClsTPC); - break; - case 1: // 70 - fMinClsTPC= 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - break; - case 2: // 80 - fMinClsTPC= 80.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - break; - case 3: // 100 - fMinClsTPC= 100.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - break; - case 4: // 0% of findable clusters - fMinClsTPC= 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.0; - fUseCorrectedTPCClsInfo=0; - break; - case 5: // 35% of findable clusters - fMinClsTPC = 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.35; - fUseCorrectedTPCClsInfo=0; - break; - case 6: // 60% of findable clusters - fMinClsTPC= 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.6; - fUseCorrectedTPCClsInfo=0; - break; - case 7: // 70% of findable clusters - fMinClsTPC= 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.7; - fUseCorrectedTPCClsInfo=0; - break; - case 8: fMinClsTPC = 0.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.35; - fUseCorrectedTPCClsInfo=0; - break; - case 9: // 35% of findable clusters - fMinClsTPC = 70.; - fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); - fMinClsTPCToF= 0.35; - fUseCorrectedTPCClsInfo=1; - break; - - default: - cout<<"Warning: clsTPCCut not defined "<SetMaxDCAToVertexZ(1000); - fesdTrackCuts->SetMaxDCAToVertexXY(1000); - fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); - break; - - case 1: - fesdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); - fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); - - break; - case 2: fesdTrackCuts->SetMaxDCAToVertexZ(2); - fesdTrackCuts->SetMaxDCAToVertexXY(1); - fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); - break; - - default: - cout<<"Warning: dcaCut not defined "<InitializeCutsFromCutString("9069640364102")){ - cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<InitializeCutsFromCutString("9069640364102")){ - cout<<"Warning: Initialization of Standardcuts2010pp failed"<SetName(Form("ElectronCuts_%s",cutName.Data())); + else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data())); + } + + + hCutIndex=new TH1F(Form("IsElectronSelected %s",cutName.Data()),"IsElectronSelected",10,-0.5,9.5); + hCutIndex->GetXaxis()->SetBinLabel(kElectronIn+1,"in"); + hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks"); + hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts"); + hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx"); + hCutIndex->GetXaxis()->SetBinLabel(kElectronOut+1,"out"); + fHistograms->Add(hCutIndex); + + + + // dEdx Cuts + hdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",10,-0.5,9.5); + hdEdxCuts->GetXaxis()->SetBinLabel(1,"in"); + hdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSelectron"); + hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCelectron"); + hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpion"); + hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCpionhighp"); + hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCkaonlowprej"); + hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCprotonlowprej"); + hdEdxCuts->GetXaxis()->SetBinLabel(8,"TPCpionlowprej"); + hdEdxCuts->GetXaxis()->SetBinLabel(9,"TOFelectron"); + hdEdxCuts->GetXaxis()->SetBinLabel(10,"out"); + fHistograms->Add(hdEdxCuts); + + + + TAxis *AxisBeforeITS = NULL; + TAxis *AxisBeforedEdx = NULL; + TAxis *AxisBeforeTOF = NULL; + TAxis *AxisBeforedEdxSignal = NULL; + + if(preCut){ + + + hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",cutName.Data()),"ITS dEdx electron before" ,150,0.05,20,400,-10,10); + fHistograms->Add(hITSdEdxbefore); + AxisBeforeITS = hITSdEdxbefore->GetXaxis(); + + hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",cutName.Data()),"dEdx electron before" ,150,0.05,20,400,-10,10); + fHistograms->Add(hTPCdEdxbefore); + AxisBeforedEdx = hTPCdEdxbefore->GetXaxis(); + + hTPCdEdxSignalbefore=new TH2F(Form("Electron_dEdxSignal_before %s",cutName.Data()),"dEdx electron signal before" ,150,0.05,20.0,800,0.0,200); + fHistograms->Add(hTPCdEdxSignalbefore); + AxisBeforedEdxSignal = hTPCdEdxSignalbefore->GetXaxis(); + + hTOFbefore=new TH2F(Form("Electron_TOF_before %s",cutName.Data()),"TOF electron before" ,150,0.05,20,400,-6,10); + fHistograms->Add(hTOFbefore); + AxisBeforeTOF = hTOFbefore->GetXaxis(); + + hTrackDCAxyPtbefore = new TH2F(Form("hTrack_DCAxy_Pt_before %s",cutName.Data()),"DCAxy Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.); + fHistograms->Add(hTrackDCAxyPtbefore); + + hTrackDCAzPtbefore = new TH2F(Form("hTrack_DCAz_Pt_before %s",cutName.Data()), "DCAz Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.); + fHistograms->Add(hTrackDCAzPtbefore); + + hTrackNFindClsPtTPCbefore = new TH2F(Form("hTrack_NFindCls_Pt_TPC_before %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt before",100,0,1,400,0.,10.); + fHistograms->Add(hTrackNFindClsPtTPCbefore); + + + + } + + + hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",cutName.Data()),"ITS dEdx electron after" ,150,0.05,20,400, -10,10); + fHistograms->Add(hITSdEdxafter); + + hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",cutName.Data()),"dEdx electron after" ,150,0.05,20,400, -10,10); + fHistograms->Add(hTPCdEdxafter); + + hTPCdEdxSignalafter=new TH2F(Form("Electron_dEdxSignal_after %s",cutName.Data()),"dEdx electron signal after" ,150,0.05,20.0,800,0.0,200); + fHistograms->Add(hTPCdEdxSignalafter); + + hTOFafter=new TH2F(Form("Electron_TOF_after %s",cutName.Data()),"TOF electron after" ,150,0.05,20,400,-6,10); + fHistograms->Add(hTOFafter); + + hTrackDCAxyPtafter = new TH2F(Form("hTrack_DCAxy_Pt_after %s",cutName.Data()),"DCAxy Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.); + fHistograms->Add(hTrackDCAxyPtafter); + + hTrackDCAzPtafter = new TH2F(Form("hTrack_DCAz_Pt_after %s",cutName.Data()), "DCAz Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.); + fHistograms->Add(hTrackDCAzPtafter); + + hTrackNFindClsPtTPCafter = new TH2F(Form("hTrack_NFindCls_Pt_TPC_after %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt after",100,0,1,400,0.,10.); + fHistograms->Add(hTrackNFindClsPtTPCafter); + + + + TAxis *AxisAfter = hTPCdEdxafter->GetXaxis(); + Int_t bins = AxisAfter->GetNbins(); + Double_t from = AxisAfter->GetXmin(); + Double_t to = AxisAfter->GetXmax(); + Double_t *newBins = new Double_t[bins+1]; + newBins[0] = from; + Double_t factor = TMath::Power(to/from, 1./bins); + for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1]; + AxisAfter->Set(bins, newBins); + AxisAfter = hTOFafter->GetXaxis(); + AxisAfter->Set(bins, newBins); + AxisAfter = hITSdEdxafter->GetXaxis(); + AxisAfter->Set(bins,newBins); + AxisAfter = hTPCdEdxSignalafter->GetXaxis(); + AxisAfter->Set(bins,newBins); + + if(preCut){ + AxisBeforeITS->Set(bins, newBins); + AxisBeforedEdx->Set(bins, newBins); + AxisBeforedEdxSignal->Set(bins,newBins); + AxisBeforeTOF->Set(bins, newBins); + + } + delete [] newBins; + + + // Event Cuts and Info +} + + +//________________________________________________________________________ +Bool_t AliDalitzElectronCuts::InitPIDResponse(){ + +// Set Pointer to AliPIDResponse + + AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); + + if(man) { + + AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); + fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse(); + if(fPIDResponse)return kTRUE; + + } + + return kFALSE; +} +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::ElectronIsSelectedMC(Int_t labelParticle,AliStack *fMCStack) +{ + if( labelParticle < 0 || labelParticle >= fMCStack->GetNtrack() ) return kFALSE; + if( fMCStack->IsPhysicalPrimary(labelParticle) == kFALSE ) return kFALSE; //Ask Ana + + TParticle* particle = fMCStack->Particle(labelParticle); + + if( TMath::Abs( particle->GetPdgCode() ) != 11 ) return kFALSE; + + if( fDoEtaCut ){ + if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) ) + return kFALSE; + } + + +return kTRUE; +} + + +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::ElectronIsSelected(AliESDtrack* lTrack) +{ + //Selection of Reconstructed electrons + + + Float_t b[2]; + Float_t bCov[3]; + lTrack->GetImpactParameters(b,bCov); + + if (bCov[0]<=0 || bCov[2]<=0) { + AliDebug(1, "Estimated b resolution lower or equal zero!"); + bCov[0]=0; bCov[2]=0; + } + + + + Float_t dcaToVertexXY = b[0]; + Float_t dcaToVertexZ = b[1]; + Double_t clsToF = GetNFindableClustersTPC(lTrack); + + if( hTrackDCAxyPtbefore) hTrackDCAxyPtbefore->Fill(dcaToVertexXY,lTrack->Pt()); + if( hTrackDCAzPtbefore ) hTrackDCAzPtbefore->Fill( dcaToVertexZ, lTrack->Pt()); + if( hTrackNFindClsPtTPCbefore ) hTrackNFindClsPtTPCbefore->Fill( clsToF, lTrack->Pt()); + + + + if(hCutIndex)hCutIndex->Fill(kElectronIn); + + if (lTrack == NULL){ + if(hCutIndex)hCutIndex->Fill(kNoTracks); + return kFALSE; + } + + if ( ! lTrack->GetConstrainedParam() ){ + return kFALSE; + } + AliVTrack * track = dynamic_cast(lTrack); + + + // Track Cuts + if( !TrackIsSelected(lTrack) ){ + if(hCutIndex)hCutIndex->Fill(kTrackCuts); + return kFALSE; + } + + + // dEdx Cuts + if( ! dEdxCuts( track ) ) { + if(hCutIndex)hCutIndex->Fill(kdEdxCuts); + return kFALSE; + + } + + //Electron passed the cuts + if(hCutIndex)hCutIndex->Fill(kElectronOut); + + if( hTrackDCAxyPtafter) hTrackDCAxyPtafter->Fill(dcaToVertexXY,lTrack->Pt()); + if( hTrackDCAzPtafter ) hTrackDCAzPtafter->Fill(dcaToVertexZ,lTrack->Pt()); + if( hTrackNFindClsPtTPCafter ) hTrackNFindClsPtTPCafter->Fill( clsToF, lTrack->Pt()); + + + return kTRUE; +} + +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::TrackIsSelected(AliESDtrack* lTrack) { + // Track Selection for Photon Reconstruction + + + Double_t clsToF = GetNFindableClustersTPC(lTrack); + + + if( ! fesdTrackCuts->AcceptTrack(lTrack) ){ + + return kFALSE; + } + + if( fDoEtaCut ) { + if( lTrack->Eta() > (fEtaCut + fEtaShift) || lTrack->Eta() < (-fEtaCut + fEtaShift) ) { + return kFALSE; + } + } + + + if( lTrack->Pt() < fPtCut ) { + + return kFALSE; + + } + + + + if( clsToF < fMinClsTPCToF){ + return kFALSE; + } + + + + return kTRUE; +} +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){ + + // Electron Identification Cuts for Photon reconstruction + + if(!fPIDResponse){ InitPIDResponse(); }// Try to reinitialize PID Response + if(!fPIDResponse){ AliError("No PID Response"); return kFALSE;}// if still missing fatal error + + + + //cout<<"dEdxCuts: //////////////////////////////////////////////////////////////////////////"<Fill(cutIndex); + if(hITSdEdxbefore)hITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron)); + if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron)); + if(hTPCdEdxSignalbefore)hTPCdEdxSignalbefore->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal())); + + + cutIndex++; + + + if( fDodEdxSigmaITSCut == kTRUE ){ + + + if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)> fPIDnSigmaAboveElectronLineITS ){ + + if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); + return kFALSE; + } + + } + + if(hITSdEdxafter)hITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron)); + + + cutIndex++; + + + if(fDodEdxSigmaTPCCut == kTRUE){ + + + // TPC Electron Line + if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLineTPC){ + + if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); + return kFALSE; + } + cutIndex++; + + // TPC Pion Line + if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLineTPC && fCurrentTrack->P()NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC && + fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)Fill(cutIndex); + return kFALSE; + } + } + cutIndex++; + + // High Pt Pion rej + if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLineTPC ){ + if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC && + fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)Fill(cutIndex); + return kFALSE; + } + } + + cutIndex++; + } + + else{ cutIndex+=3; } + + + if( fDoKaonRejectionLowP == kTRUE ){ + + if( fCurrentTrack->P() < fPIDMinPKaonRejectionLowP ){ + + if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))Fill(cutIndex); + + return kFALSE; + } + } + } + cutIndex++; + + if( fDoProtonRejectionLowP == kTRUE ){ + + if( fCurrentTrack->P() < fPIDMinPProtonRejectionLowP ){ + if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))Fill(cutIndex); + return kFALSE; + } + } + } + cutIndex++; + + if(fDoPionRejectionLowP == kTRUE){ + if( fCurrentTrack->P() < fPIDMinPPionRejectionLowP ){ + if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)) < fPIDnSigmaAtLowPAroundPionLine ){ + + if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); + return kFALSE; + } + } + } + cutIndex++; + + + if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){ + if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)); + if(fUseTOFpid){ + if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine || + fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)Fill(cutIndex); + return kFALSE; + } + } + if(hTOFafter)hTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)); + } + else if ( fRequireTOF == kTRUE ) { + + if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); + return kFALSE; + } + cutIndex++; + + if(hdEdxCuts)hdEdxCuts->Fill(cutIndex); + if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron)); + if(hTPCdEdxSignalafter)hTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal())); + + return kTRUE; +} +///________________________________________________________________________ + + +AliVTrack *AliDalitzElectronCuts::GetTrack(AliVEvent * event, Int_t label){ + //Returns pointer to the track with given ESD label + //(Important for AOD implementation, since Track array in AOD data is different + //from ESD array, but ESD tracklabels are stored in AOD Tracks) + + AliESDEvent * esdEvent = dynamic_cast(event); + if(esdEvent) { + if(label > event->GetNumberOfTracks() ) return NULL; + AliESDtrack * track = esdEvent->GetTrack(label); + return track; + + } else { + for(Int_t ii=0; iiGetNumberOfTracks(); ii++) { + AliVTrack * track = dynamic_cast(event->GetTrack(ii)); + + if(track) { + if(track->GetID() == label) { + return track; + } + } + } + } + + cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl; + return NULL; +} +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::RejectSharedElecGamma(TList *photons, Int_t indexEle){ + + + for(Int_t i = 0;iGetEntries();i++){ + + AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i); + + Int_t posLabel = photonComp->GetTrackLabelPositive(); + Int_t negLabel = photonComp->GetTrackLabelNegative(); + + if( (photonComp->GetConversionRadius() < fRadiusCut) && (posLabel == indexEle || negLabel == indexEle) ){ + return kFALSE; + } + } + + return kTRUE; +} +Bool_t AliDalitzElectronCuts::MassCut(Double_t pi0CandidatePt , Double_t vphotonCandidateMass){ + + if( pi0CandidatePt < fMassCutPtMin ){ + + if( vphotonCandidateMass < fMassCutLowPt ){ + return kTRUE; + } + + } + else{ + + if( vphotonCandidateMass < fMassCutHighPt ){ + return kTRUE; + } + + } + + return kFALSE; + +} + +Double_t AliDalitzElectronCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){ + + + Double_t clsToF=0; + + + if ( !fUseCorrectedTPCClsInfo ){ + if(lTrack->GetTPCNclsF()!=0){ + + clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF(); + }// Ncluster/Nfindablecluster + } + else { + + //clsToF = lTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius())); + clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike + + } + + return clsToF; + +} + +/* +Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) +{ +// +// This angle is a measure for the contribution of the opening in polar +// direction ??0 to the opening angle ?? Pair +// +// Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC +// Master Thesis. Thorsten Dahms. 2005 +// https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf +// + Double_t momPos[3]; + Double_t momNeg[3]; + if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos ); + if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg ); + + TVector3 posDaughter; + TVector3 negDaughter; + + posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] ); + negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] ); + + Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta(); + Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) ); + + if( openingAngle < 1e-20 ) return 0.; + + Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle ); + + return psiAngle; +}*/ + +Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi ) +{ +// +// Returns true if it is a gamma conversion according to psi pair value +// + return ( (deltaPhi > fDeltaPhiCutMin && deltaPhi < fDeltaPhiCutMax) && + TMath::Abs(psiPair) < ( fPsiPairCut - fPsiPairCut/fDeltaPhiCutMax * deltaPhi ) ); +} + +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::UpdateCutString(cutIds cutID, Int_t value) { +///Update the cut string (if it has been created yet) + + if(fCutString && fCutString->GetString().Length() == kNCuts) { +// cout << "Updating cut id in spot number " << cutID << " to " << value << endl; + fCutString->SetString(GetCutNumber()); + } else { +// cout << "fCutString not yet initialized, will not be updated" << endl; + return kFALSE; + } + // cout << fCutString->GetString().Data() << endl; + return kTRUE; +} + +///________________________________________________________________________ +Bool_t AliDalitzElectronCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) { + // Initialize Cuts from a given Cut string + +// out<<"Set Cut Number: "<SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff); + break; + case 1: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst); + break; //1 hit first layer of SPD + case 2: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + break; //1 hit in any layer of SPD + case 3: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst); + fesdTrackCuts->SetMinNClustersITS(4); + // 4 hits in total in the ITS. At least 1 hit in the first layer of SPD + break; + case 4: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + fesdTrackCuts->SetMinNClustersITS(3); + // 3 hits in total in the ITS. At least 1 hit in any layer of SPD + break; + case 5: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + fesdTrackCuts->SetMinNClustersITS(4); + // 4 hits in total in the ITS. At least 1 hit in any layer of SPD + break; + case 6: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); + fesdTrackCuts->SetMinNClustersITS(5); + // 5 hits in total in the ITS. At least 1 hit in any layer of SPD + break; + default: + cout<<"Warning: clsITSCut not defined "<SetMinNClustersTPC(fMinClsTPC); + break; + case 1: // 70 + fMinClsTPC= 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + break; + case 2: // 80 + fMinClsTPC= 80.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + break; + case 3: // 100 + fMinClsTPC= 100.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + break; + case 4: // 0% of findable clusters + fMinClsTPC= 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.0; + fUseCorrectedTPCClsInfo=0; + break; + case 5: // 35% of findable clusters + fMinClsTPC = 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.35; + fUseCorrectedTPCClsInfo=0; + break; + case 6: // 60% of findable clusters + fMinClsTPC= 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.6; + fUseCorrectedTPCClsInfo=0; + break; + case 7: // 70% of findable clusters + fMinClsTPC= 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.7; + fUseCorrectedTPCClsInfo=0; + break; + case 8: fMinClsTPC = 0.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.35; + fUseCorrectedTPCClsInfo=0; + break; + case 9: // 35% of findable clusters + fMinClsTPC = 70.; + fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC); + fMinClsTPCToF= 0.35; + fUseCorrectedTPCClsInfo=1; + break; + + default: + cout<<"Warning: clsTPCCut not defined "<SetMaxDCAToVertexZ(1000); + fesdTrackCuts->SetMaxDCAToVertexXY(1000); + fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); + break; + + case 1: + fesdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); + fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); + + break; + case 2: fesdTrackCuts->SetMaxDCAToVertexZ(2); + fesdTrackCuts->SetMaxDCAToVertexXY(1); + fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); + break; + + default: + cout<<"Warning: dcaCut not defined "<InitializeCutsFromCutString("9069640364102")){ + cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<InitializeCutsFromCutString("9069640364102")){ + cout<<"Warning: Initialization of Standardcuts2010pp failed"<5) AliFatal(Form("Wrong module number: %d",mod)); - else fRecalib[mod-1] = recalib; - } - void SetPHOSBadMap(Int_t mod,TH2I * h) - { - if(fPHOSBadMap[mod]) delete fPHOSBadMap[mod] ; - fPHOSBadMap[mod]=new TH2I(*h) ; - printf("Set %s \n",fPHOSBadMap[mod]->GetName()); - } - -private: - AliAnalysisTaskPi0(const AliAnalysisTaskPi0&); // not implemented - AliAnalysisTaskPi0& operator=(const AliAnalysisTaskPi0&); // not implemented - Bool_t IsGoodChannel(const char * det, Int_t mod,Int_t ix, Int_t iz); - void FillHistogram(const char * key,Double_t x) const ; //Fill 1D histogram witn name key - void FillHistogram(const char * key,Double_t x, Double_t y) const ; //Fill 2D histogram witn name key - void FillHistogram(const char * key,Double_t x, Double_t y, Double_t z) const ; //Fill 3D histogram witn name key - Bool_t TestLambda(Double_t l1,Double_t l2) ; - Int_t TestBC(Double_t tof) ; - -private: - AliESDtrackCuts *fESDtrackCuts; // Track cut - TList * fOutputContainer; //final histogram container - TList * fPHOSEvents[10][2] ; //Container for PHOS photons - TClonesArray * fPHOSEvent ; //PHOS photons in current event - - Int_t fnCINT1B; // Number of CINT1B triggers - Int_t fnCINT1A; // Number of CINT1A triggers - Int_t fnCINT1C; // Number of CINT1C triggers - Int_t fnCINT1E; // Number of CINT1E triggers - - Double_t fBCgap; // time gap between BC in seconds - Double_t fRecalib[5]; // Correction for abs.calibration per module - - TH2I *fPHOSBadMap[6] ; //Container for PHOS bad channels map - - AliPHOSGeometry *fPHOSGeo; // PHOS geometry - Int_t fEventCounter; // number of analyzed events - AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation - - ClassDef(AliAnalysisTaskPi0, 3); // PHOS analysis task -}; - -#endif +#ifndef AliAnalysisTaskPi0_cxx +#define AliAnalysisTaskPi0_cxx + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ +/* $Id$ */ + +// Analysis task for pi0 and eta meson analysis in pp collisions +// Authors: Yuri Kharlov, Dmitri Peressounko + +class TObjArray; +class TH1F; +class TH2I; +class TH2F; +class TH3F; +class AliESDtrackCuts; +class AliPHOSGeometry; +class AliTriggerAnalysis; + +#include "TH2I.h" +#include "AliAnalysisTaskSE.h" +#include "AliLog.h" + +class AliAnalysisTaskPi0 : public AliAnalysisTaskSE { +public: + AliAnalysisTaskPi0(const char *name = "AliAnalysisTaskPi0"); + virtual ~AliAnalysisTaskPi0() {} + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + void SetBCgap(const Double_t bcgap) {fBCgap = bcgap;} + void SetRecalib(const Int_t mod, const Double_t recalib) + { + if (mod<1 || mod>5) AliFatal(Form("Wrong module number: %d",mod)); + else fRecalib[mod-1] = recalib; + } + void SetPHOSBadMap(Int_t mod,TH2I * h) + { + if(fPHOSBadMap[mod]) delete fPHOSBadMap[mod] ; + fPHOSBadMap[mod]=new TH2I(*h) ; + printf("Set %s \n",fPHOSBadMap[mod]->GetName()); + } + +private: + AliAnalysisTaskPi0(const AliAnalysisTaskPi0&); // not implemented + AliAnalysisTaskPi0& operator=(const AliAnalysisTaskPi0&); // not implemented + Bool_t IsGoodChannel(const char * det, Int_t mod,Int_t ix, Int_t iz); + void FillHistogram(const char * key,Double_t x) const ; //Fill 1D histogram witn name key + void FillHistogram(const char * key,Double_t x, Double_t y) const ; //Fill 2D histogram witn name key + void FillHistogram(const char * key,Double_t x, Double_t y, Double_t z) const ; //Fill 3D histogram witn name key + Bool_t TestLambda(Double_t l1,Double_t l2) ; + Int_t TestBC(Double_t tof) ; + +private: + AliESDtrackCuts *fESDtrackCuts; // Track cut + TList * fOutputContainer; //final histogram container + TList * fPHOSEvents[10][2] ; //Container for PHOS photons + TClonesArray * fPHOSEvent ; //PHOS photons in current event + + Int_t fnCINT1B; // Number of CINT1B triggers + Int_t fnCINT1A; // Number of CINT1A triggers + Int_t fnCINT1C; // Number of CINT1C triggers + Int_t fnCINT1E; // Number of CINT1E triggers + + Double_t fBCgap; // time gap between BC in seconds + Double_t fRecalib[5]; // Correction for abs.calibration per module + + TH2I *fPHOSBadMap[6] ; //Container for PHOS bad channels map + + AliPHOSGeometry *fPHOSGeo; // PHOS geometry + Int_t fEventCounter; // number of analyzed events + AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation + + ClassDef(AliAnalysisTaskPi0, 3); // PHOS analysis task +}; + +#endif diff --git a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/MakeFinalSpectrum.C b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/MakeFinalSpectrum.C index 6251635b18a..99b810a1887 100644 --- a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/MakeFinalSpectrum.C +++ b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/MakeFinalSpectrum.C @@ -1,384 +1,384 @@ -void MakeFinalSpectrum() -{ - //----------------------------------------------------------------------------- - // This macro takes the raw pi0 spectrum from LHC11a_FitResult_20130314.root, - // correct it for feed down, then for efficiency, - // adds all systematic errors and produces the production invariant spectrum - //-- - // Last modification: 06.07.2012 by Yuri Kharlov - //----------------------------------------------------------------------------- - - TFile *f = new TFile("LHC11a_FitResult_20130913.root"); - TH1D * nr1CB = (TH1D*)f->Get("Mix_CB_yr1") ; - TH1D * nr1intCB = (TH1D*)f->Get("Mix_CB_yr1int") ; - TH1D * nr2CB = (TH1D*)f->Get("Mix_CB_yr2") ; - TH1D * nr2intCB = (TH1D*)f->Get("Mix_CB_yr2int") ; - - TH1D * nr1GS = (TH1D*)f->Get("Mix_yr1") ; - TH1D * nr1intGS = (TH1D*)f->Get("Mix_yr1int") ; - TH1D * nr2GS = (TH1D*)f->Get("Mix_yr2") ; - TH1D * nr2intGS = (TH1D*)f->Get("Mix_yr2int") ; - - //Divide by bin width - for(Int_t i=1;i<= nr1CB->GetNbinsX();i++){ - nr1CB ->SetBinContent(i,nr1CB->GetBinContent(i)/nr1CB->GetXaxis()->GetBinWidth(i)) ; - nr1CB ->SetBinError (i,nr1CB->GetBinError(i)/nr1CB->GetXaxis()->GetBinWidth(i)) ; - nr1intCB->SetBinContent(i,nr1intCB->GetBinContent(i)/nr1intCB->GetXaxis()->GetBinWidth(i)) ; - nr1intCB->SetBinError (i,nr1intCB->GetBinError(i)/nr1intCB->GetXaxis()->GetBinWidth(i)) ; - nr2CB ->SetBinContent(i,nr2CB->GetBinContent(i)/nr2CB->GetXaxis()->GetBinWidth(i)) ; - nr2CB ->SetBinError (i,nr2CB->GetBinError(i)/nr2CB->GetXaxis()->GetBinWidth(i)) ; - nr2intCB->SetBinContent(i,nr2intCB->GetBinContent(i)/nr2intCB->GetXaxis()->GetBinWidth(i)) ; - nr2intCB->SetBinError (i,nr2intCB->GetBinError(i)/nr2intCB->GetXaxis()->GetBinWidth(i)) ; - - nr1GS ->SetBinContent(i,nr1GS->GetBinContent(i)/nr1GS->GetXaxis()->GetBinWidth(i)) ; - nr1GS ->SetBinError (i,nr1GS->GetBinError(i)/nr1GS->GetXaxis()->GetBinWidth(i)) ; - nr1intGS->SetBinContent(i,nr1intGS->GetBinContent(i)/nr1intGS->GetXaxis()->GetBinWidth(i)) ; - nr1intGS->SetBinError (i,nr1intGS->GetBinError(i)/nr1intGS->GetXaxis()->GetBinWidth(i)) ; - nr2GS ->SetBinContent(i,nr2GS->GetBinContent(i)/nr2GS->GetXaxis()->GetBinWidth(i)) ; - nr2GS ->SetBinError (i,nr2GS->GetBinError(i)/nr2GS->GetXaxis()->GetBinWidth(i)) ; - nr2intGS->SetBinContent(i,nr2intGS->GetBinContent(i)/nr2intGS->GetXaxis()->GetBinWidth(i)) ; - nr2intGS->SetBinError (i,nr2intGS->GetBinError(i)/nr2intGS->GetXaxis()->GetBinWidth(i)) ; - } - - // feed down correction - - TF1 *fKaonContaminationToPi0 = new TF1("kaonCont","1./(1.-1.33*1.2*exp(-2.95-0.16*x))",0.,30.); - nr1GS ->Divide(fKaonContaminationToPi0); - nr1intGS->Divide(fKaonContaminationToPi0); - nr2GS ->Divide(fKaonContaminationToPi0); - nr2intGS->Divide(fKaonContaminationToPi0); - nr1CB ->Divide(fKaonContaminationToPi0); - nr2CB ->Divide(fKaonContaminationToPi0); - nr1intCB->Divide(fKaonContaminationToPi0); - nr2intCB->Divide(fKaonContaminationToPi0); - - // SPD pileup correction - - TF1 *fSPDpileup = new TF1("SPDpileup","0.988",0.,30.); - nr1GS ->Multiply(fSPDpileup); - nr1intGS->Multiply(fSPDpileup); - nr2GS ->Multiply(fSPDpileup); - nr2intGS->Multiply(fSPDpileup); - nr1CB ->Multiply(fSPDpileup); - nr2CB ->Multiply(fSPDpileup); - nr1intCB->Multiply(fSPDpileup); - nr2intCB->Multiply(fSPDpileup); - - //correct for efficiency - TFile *fEff = new TFile("Pi0_efficiency_LHC11a__20131029_Mall.root") ; - - TF1 * effGS=fEff->Get("eff_Pi0_Gaus_2760GeV") ; - TF1 * effCB=fEff->Get("eff_Pi0_CB_2760GeV") ; - effGS ->SetRange(0.,25.) ; - effCB ->SetRange(0.,25.) ; - - nr1GS ->Divide(effGS) ; - nr1intGS->Divide(effGS) ; - nr2GS ->Divide(effGS) ; - nr2intGS->Divide(effGS) ; - nr1CB ->Divide(effCB) ; - nr2CB ->Divide(effCB) ; - nr1intCB->Divide(effCB) ; - nr2intCB->Divide(effCB) ; - - //make 1/pt - for(Int_t i=1;i<=nr1CB->GetNbinsX();i++){ - Double_t pt = TMath::TwoPi()*nr1CB->GetXaxis()->GetBinCenter(i); - nr1CB ->SetBinContent(i,nr1CB ->GetBinContent(i)/pt) ; - nr1CB ->SetBinError (i,nr1CB ->GetBinError(i) /pt) ; - nr1intCB->SetBinContent(i,nr1intCB->GetBinContent(i)/pt) ; - nr1intCB->SetBinError (i,nr1intCB->GetBinError(i) /pt) ; - nr2CB ->SetBinContent(i,nr2CB ->GetBinContent(i)/pt) ; - nr2CB ->SetBinError (i,nr2CB ->GetBinError(i) /pt) ; - nr2intCB->SetBinContent(i,nr2intCB->GetBinContent(i)/pt) ; - nr2intCB->SetBinError (i,nr2intCB->GetBinError(i) /pt) ; - - nr1GS ->SetBinContent(i,nr1GS ->GetBinContent(i)/pt) ; - nr1GS ->SetBinError (i,nr1GS ->GetBinError(i) /pt) ; - nr1intGS->SetBinContent(i,nr1intGS->GetBinContent(i)/pt) ; - nr1intGS->SetBinError (i,nr1intGS->GetBinError(i) /pt) ; - nr2GS ->SetBinContent(i,nr2GS ->GetBinContent(i)/pt) ; - nr2GS ->SetBinError (i,nr2GS ->GetBinError(i) /pt) ; - nr2intGS->SetBinContent(i,nr2intGS->GetBinContent(i)/pt) ; - nr2intGS->SetBinError (i,nr2intGS->GetBinError(i) /pt) ; - } - - //For the final spectrum we take average of fits - //with numerical integration of entries in signal - - TH1D * hStat = (TH1D*)nr2intCB->Clone("hPi02760GeVStat") ; - TH1D * hSys = (TH1D*)hStat ->Clone("hPi02760GeVSys") ; - TH1D * hSys2 = (TH1D*)hStat ->Clone("hPi02760GeVSysTypeB") ; - TH1D * hSys3 = (TH1D*)hStat ->Clone("hPi02760GeVSysTypeC") ; - hStat->SetAxisRange(0.,14.9,"X"); - hSys ->SetAxisRange(0.,14.9,"X"); - - //For systematic error estimate take largest deviation - //of integrated yeilds (note, they are efficiency corrected) - for(Int_t i=1;i<=nr1CB->GetNbinsX();i++){ - Double_t mean= hStat->GetBinContent(i) ; - Double_t dev = TMath::Max( - TMath::Max(TMath::Abs(nr1intCB->GetBinContent(i)-mean), - TMath::Abs(nr2intCB->GetBinContent(i)-mean)), - TMath::Max(TMath::Abs(nr1intGS->GetBinContent(i)-mean), - TMath::Abs(nr2intGS->GetBinContent(i)-mean)) - ); - hSys ->SetBinError(i,dev) ; - hSys2->SetBinError(i,dev) ; - } - - //Add other sys errors - TF1 * globalE = new TF1("globalE","1.-((x+1.354)/(x*1.002+1.354))^6.18 ",1.,30.) ; - TF1 * conv = new TF1("conversion","0.035",0.,30.) ; - TF1 * accept = new TF1("accept" ,"0.01" ,0.,30.) ; - TF1 * pileup = new TF1("pileup" ,"0.004",0.,30.) ; - TF1 * calib = new TF1("calib" ,"0.005",0.,30.) ; - TF1 * modDiff = new TF1("modDiff" ,"0.04",0.,30.) ; - // TF1 * modDiff = new TF1("modDiff" ,"16.9*exp(-4.5*x)+0.033",0.,30.) ; - TF1 * tofCut = new TF1("tofCut" ,"0.0105" ,0.,30.) ; - - //Borya's estimate of non-linearity (found for pp @ 7 TeV) - TF1 * nonlin= new TF1("nl","0.015+7.38*exp(-x/0.24)",0.,30.) ; - - //Draw sys errors - TH1D * hRelSysRaw = (TH1D*)hSys->Clone("RelSysRaw") ; - hRelSysRaw->SetTitle("Summary of systematic errors"); - for(Int_t i=1;i<=hSys->GetNbinsX();i++){ - Double_t mean= hSys->GetBinContent(i) ; - Double_t a=hSys->GetBinError(i) ; - if(mean>0) - hRelSysRaw->SetBinContent(i,a/mean) ; - else - hRelSysRaw->SetBinContent(i,0.) ; - hRelSysRaw->SetBinError(i,0.) ; - } - - //Add errors in sys errors - - TH1D * hRelSysTot = (TH1D*)hSys->Clone("RelSys") ; - hRelSysTot->SetTitle("Summary of systematic uncertainties"); - - for(Int_t i=1;i<=hSys->GetNbinsX();i++){ - Double_t pt = hSys->GetXaxis()->GetBinCenter(i) ; - Double_t mean = hSys->GetBinContent(i) ; - Double_t a = hSys->GetBinError(i) ; - // Double_t b = mean * hSysErrModules->GetBinContent(i) ; - Double_t tot= mean*mean*nonlin ->Eval(pt)*nonlin ->Eval(pt) - +mean*mean*conv ->Eval(pt)*conv ->Eval(pt) - +mean*mean*accept ->Eval(pt)*accept ->Eval(pt) - +mean*mean*pileup ->Eval(pt)*pileup ->Eval(pt) - +mean*mean*calib ->Eval(pt)*calib ->Eval(pt) - +mean*mean*modDiff->Eval(pt)*modDiff->Eval(pt) - +mean*mean*tofCut ->Eval(pt)*tofCut ->Eval(pt) - +mean*mean*globalE->Eval(pt)*globalE->Eval(pt); - Double_t raa= mean*mean*nonlin->Eval(pt)*nonlin->Eval(pt) - +mean*mean*pileup->Eval(pt)*pileup->Eval(pt) - +mean*mean*calib ->Eval(pt)*calib ->Eval(pt); - hSys3->SetBinError(i,TMath::Sqrt(tot)) ; - // hSys->SetBinError(i,TMath::Sqrt(tot + a*a + b*b)) ; - hSys2->SetBinError(i,TMath::Sqrt(raa + a*a)) ; - hSys ->SetBinError(i,TMath::Sqrt(tot + a*a)) ; - - a = hSys->GetBinError(i) ; - printf("i=%d, %g+-%g\n",i,mean,a); - if(mean>0) - hRelSysTot->SetBinContent(i,a/mean) ; - else { - hRelSysTot->SetBinContent(i,0.) ; - hRelSysTot->SetBinError(i,0.) ; - } - } - - // TFile *fSysErrModules = TFile::Open("PHOS_sysErr_modules.root"); - // TH1D* hSysErrModules = (TH1D*)fSysErrModules->Get("hSyserr"); - - gStyle->SetOptStat(0); - TCanvas * c = new TCanvas("c","SysErrors") ; - c->SetLogy(); - c->cd() ; - gPad->SetRightMargin(0.02); - gPad->SetTopMargin(0.07); - hRelSysTot->SetAxisRange(0.8 ,11.9,"X"); - hRelSysTot->SetAxisRange(0.0031,0.45,"Y"); - hRelSysTot->GetYaxis()->SetMoreLogLabels(); - hRelSysTot->GetYaxis()->SetNoExponent(); - hRelSysTot->SetNdivisions(520,"X"); - hRelSysTot->SetLineColor(1) ; - hRelSysTot->SetLineWidth(2) ; - hRelSysRaw->SetLineColor(2) ; - hRelSysRaw->SetLineWidth(2) ; - globalE->SetLineColor(kGreen+2) ; - nonlin ->SetLineColor(4) ; - conv ->SetLineColor(6) ; - accept ->SetLineColor(kOrange) ; - pileup ->SetLineColor(42); - calib ->SetLineColor(44); - calib ->SetLineStyle(2); - modDiff->SetLineColor(52); - modDiff->SetLineStyle(2); - tofCut ->SetLineColor(53); - tofCut ->SetLineStyle(3); - // hSysErrModules->SetLineColor(kOrange+2); - // hSysErrModules->SetLineStyle(2); - hRelSysTot->SetXTitle("p_{T} (GeV/c)") ; - hRelSysTot->SetYTitle("Rel.syst.error") ; - hRelSysTot->GetYaxis()->SetTitleOffset(1.2) ; - hRelSysTot->Draw("hist") ; - hRelSysRaw->Draw("h same") ; - globalE->Draw("same") ; - nonlin ->Draw("same") ; - conv ->Draw("same") ; - accept ->Draw("same") ; - pileup ->Draw("same"); - calib ->Draw("same"); - modDiff->Draw("same"); - tofCut ->Draw("same"); - // hSysErrModules->Draw("same ]["); - TLegend * l = new TLegend(0.57,0.62,0.85,0.925) ; - l->SetFillColor(kWhite); - l->SetBorderSize(0); - l->AddEntry(hRelSysTot,"Total uncertainty","l") ; - l->AddEntry(hRelSysRaw,"Raw extraction","l") ; - l->AddEntry(conv ,"Conversion","l") ; - l->AddEntry(nonlin ,"Non-linearity","l") ; - l->AddEntry(accept ,"Acceptance","l"); - l->AddEntry(pileup ,"Pileup","l"); - l->AddEntry(calib ,"Rel.calib.","l"); - l->AddEntry(modDiff,"Per-module yield","l"); - l->AddEntry(tofCut ,"Timing cut","l"); - // l->AddEntry(hSysErrModules,"Intermodule spectra","l"); - l->AddEntry(globalE,"Global E scale","l") ; - l->Draw() ; - - c->Print("LHC11a_SysErrors.eps"); - - hStat->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, stat.err."); - hStat->SetXTitle("p_{T}, GeV/c"); - hStat->SetYTitle("1/N_{ev} 1/(2#pi p_{T}) d^{2}N/dydp_{T} (GeV^{-2}c^{2})"); - hSys ->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, total syst.err."); - hSys ->SetXTitle("p_{T}, GeV/c"); - hSys ->SetYTitle("1/N_{ev} 1/(2#pi p_{T}) d^{2}N/dydp_{T} (GeV^{-2}c^{2})"); - hSys2->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, syst.err. for R_{AA}"); - hSys3->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, apparatus syst.err."); - hSys ->SetFillColor(kBlue-10) ; - hSys ->SetNdivisions(520,"X"); - - hSysFinal = (TH1F*)hSys->Clone("hSysFinal"); - hSysFinal ->SetTitle("Production #pi^{0} yield, pp @ 2.76 TeV, 07.11.2013"); - hSysFinal ->GetYaxis()->SetTitleOffset(1.2); - hStat->GetYaxis()->SetTitleOffset(1.2); - hSysFinal ->SetAxisRange(0.8,9.9,"X"); - - TCanvas *c2 = new TCanvas("c2","Production spectrum"); - gPad->SetRightMargin(0.02); - gPad->SetTopMargin(0.07); - gPad->SetGridx(); - gPad->SetGridy(); - c2->SetLogy(); - hSysFinal->Draw("E2") ; - hStat->SetMarkerStyle(20) ; - hStat->SetMarkerColor(4) ; - hStat->SetLineColor(4) ; - hStat->Draw("same") ; - - // //Apply bin width correction - // TH1D * hBWcorr = BinWidthCorrection(hStat) ; - // hSys->Divide(hBWcorr) ; - // hSys2->Divide(hBWcorr) ; - // hSys3->Divide(hBWcorr) ; - // hStat->Divide(hBWcorr) ; - - c2->Print("LHC11a_pi0Spectrum.eps"); - - TF1 *tsallis = FitTsallis(hStat,hSys); - - TFile fout("PHOS_pi0_2760eV_noBinWidthCorr_20131112.root","recreate") ; - hSys ->Write() ; - hSys2 ->Write() ; - hSys3 ->Write() ; - hStat ->Write() ; - tsallis->Write() ; - fout.Close() ; - - -} - -//----------------------------------------------------------------------------- -TF1 *FitTsallis(TH1D* hStat, TH1D* hSys) -{ - TF1 * fit = new TF1("Tsalis","[0]/2./3.1415*([2]-1.)*([2]-2.)/([2]*[1]*([2]*[1]+0.135*([2]-2.)))*(1.+(sqrt(x*x+0.135*0.135)-0.135)/([2]*[1]))^-[2]",0.5,25.) ; - fit->SetParameters(10.,0.2,8.) ; - fit->SetLineColor(kBlack) ; - fit->SetLineWidth(2) ; - fit->SetParName(0,"dN/dy") ; - fit->SetParName(1,"T") ; - fit->SetParName(2,"n") ; - - TH1D * hSysRatio = (TH1D*)hSys ->Clone("RatioSys") ; - TH1D * hStatRatio = (TH1D*)hStat->Clone("RatioStat") ; - - TH1D * hsum = (TH1D*)hStat->Clone("sum") ; - for(Int_t i=1; i<=hsum->GetNbinsX();i++){ - Double_t a=hSys->GetBinError(i) ; - Double_t b=hStat->GetBinError(i) ; - hsum->SetBinError(i,TMath::Sqrt(a*a+b*b)) ; - } - hsum->SetStats(1) ; - hsum->Fit(fit,"Q") ; - Double_t meanPt=fit->Moment(1,1.,10.) ; - printf("=%f \n",meanPt) ; - - hSysRatio ->Divide(fit) ; - hStatRatio->Divide(fit) ; - - return fit; -} -//----------------------------------------------------------------------------- -TH1D * BinWidthCorrection(TH1D * h){ - //We apply bin width a-la PHENIX - //Use Tsalis fit to calculate shift in y direction - - TF1 * fit = new TF1("hag","[0]*(([2]*[1]+sqrt(x*x+0.135*0.135))/([2]*[1]+0.135))^-[2]",0.5,25.) ; - fit->SetParameters(10.,0.2,8.) ; - TCanvas * corr = new TCanvas("BWcorr","Bin width correction") ; - Int_t col[6]={kRed,kOrange,kMagenta,kGreen,kCyan,kBlue} ; - TH1D * hcorr[20] ; - char key[55] ; - Double_t rMax=10 ; - Int_t iteration=0 ; - TH1D * htmp = (TH1D*)h->Clone("tmp") ; - while(iteration<6){ - printf(" Iteration %d: rMax=%f \n",iteration, rMax) ; - htmp->Fit(fit,"N") ; - sprintf(key,"Ineration%d",iteration) ; - hcorr[iteration]=(TH1D*)h->Clone(key); - rMax= 0; - for(Int_t i=1;i<=h->GetNbinsX();i++){ - Double_t a=h->GetXaxis()->GetBinLowEdge(i) ; - Double_t b=h->GetXaxis()->GetBinUpEdge(i) ; - Double_t r=fit->Integral(a,b)/(b-a)/fit->Eval(0.5*(a+b)) ; - hcorr[iteration]->SetBinContent(i,r) ; - hcorr[iteration]->SetBinError(i,0.) ; - if(rMaxClone("tmp") ; - htmp->Divide(hcorr[iteration]) ; - corr->cd() ; - hcorr[iteration]->SetLineColor(col[iteration]); - if(iteration==0) - hcorr[iteration]->Draw() ; - else - hcorr[iteration]->Draw("same") ; - corr->Update() ; - iteration++ ; - } - - hcorr[5]->SetTitle("Bin-width correction for #pi^{0} spectrum"); - hcorr[5]->SetYTitle("Bin-width corrected / uncorrected"); - TFile fout("PHOS_pi0_7TeV_BinWidthCorrection.root","recreate") ; - hcorr[5]->Write(); - fout.Close(); - - return hcorr[5] ; -} +void MakeFinalSpectrum() +{ + //----------------------------------------------------------------------------- + // This macro takes the raw pi0 spectrum from LHC11a_FitResult_20130314.root, + // correct it for feed down, then for efficiency, + // adds all systematic errors and produces the production invariant spectrum + //-- + // Last modification: 06.07.2012 by Yuri Kharlov + //----------------------------------------------------------------------------- + + TFile *f = new TFile("LHC11a_FitResult_20130913.root"); + TH1D * nr1CB = (TH1D*)f->Get("Mix_CB_yr1") ; + TH1D * nr1intCB = (TH1D*)f->Get("Mix_CB_yr1int") ; + TH1D * nr2CB = (TH1D*)f->Get("Mix_CB_yr2") ; + TH1D * nr2intCB = (TH1D*)f->Get("Mix_CB_yr2int") ; + + TH1D * nr1GS = (TH1D*)f->Get("Mix_yr1") ; + TH1D * nr1intGS = (TH1D*)f->Get("Mix_yr1int") ; + TH1D * nr2GS = (TH1D*)f->Get("Mix_yr2") ; + TH1D * nr2intGS = (TH1D*)f->Get("Mix_yr2int") ; + + //Divide by bin width + for(Int_t i=1;i<= nr1CB->GetNbinsX();i++){ + nr1CB ->SetBinContent(i,nr1CB->GetBinContent(i)/nr1CB->GetXaxis()->GetBinWidth(i)) ; + nr1CB ->SetBinError (i,nr1CB->GetBinError(i)/nr1CB->GetXaxis()->GetBinWidth(i)) ; + nr1intCB->SetBinContent(i,nr1intCB->GetBinContent(i)/nr1intCB->GetXaxis()->GetBinWidth(i)) ; + nr1intCB->SetBinError (i,nr1intCB->GetBinError(i)/nr1intCB->GetXaxis()->GetBinWidth(i)) ; + nr2CB ->SetBinContent(i,nr2CB->GetBinContent(i)/nr2CB->GetXaxis()->GetBinWidth(i)) ; + nr2CB ->SetBinError (i,nr2CB->GetBinError(i)/nr2CB->GetXaxis()->GetBinWidth(i)) ; + nr2intCB->SetBinContent(i,nr2intCB->GetBinContent(i)/nr2intCB->GetXaxis()->GetBinWidth(i)) ; + nr2intCB->SetBinError (i,nr2intCB->GetBinError(i)/nr2intCB->GetXaxis()->GetBinWidth(i)) ; + + nr1GS ->SetBinContent(i,nr1GS->GetBinContent(i)/nr1GS->GetXaxis()->GetBinWidth(i)) ; + nr1GS ->SetBinError (i,nr1GS->GetBinError(i)/nr1GS->GetXaxis()->GetBinWidth(i)) ; + nr1intGS->SetBinContent(i,nr1intGS->GetBinContent(i)/nr1intGS->GetXaxis()->GetBinWidth(i)) ; + nr1intGS->SetBinError (i,nr1intGS->GetBinError(i)/nr1intGS->GetXaxis()->GetBinWidth(i)) ; + nr2GS ->SetBinContent(i,nr2GS->GetBinContent(i)/nr2GS->GetXaxis()->GetBinWidth(i)) ; + nr2GS ->SetBinError (i,nr2GS->GetBinError(i)/nr2GS->GetXaxis()->GetBinWidth(i)) ; + nr2intGS->SetBinContent(i,nr2intGS->GetBinContent(i)/nr2intGS->GetXaxis()->GetBinWidth(i)) ; + nr2intGS->SetBinError (i,nr2intGS->GetBinError(i)/nr2intGS->GetXaxis()->GetBinWidth(i)) ; + } + + // feed down correction + + TF1 *fKaonContaminationToPi0 = new TF1("kaonCont","1./(1.-1.33*1.2*exp(-2.95-0.16*x))",0.,30.); + nr1GS ->Divide(fKaonContaminationToPi0); + nr1intGS->Divide(fKaonContaminationToPi0); + nr2GS ->Divide(fKaonContaminationToPi0); + nr2intGS->Divide(fKaonContaminationToPi0); + nr1CB ->Divide(fKaonContaminationToPi0); + nr2CB ->Divide(fKaonContaminationToPi0); + nr1intCB->Divide(fKaonContaminationToPi0); + nr2intCB->Divide(fKaonContaminationToPi0); + + // SPD pileup correction + + TF1 *fSPDpileup = new TF1("SPDpileup","0.988",0.,30.); + nr1GS ->Multiply(fSPDpileup); + nr1intGS->Multiply(fSPDpileup); + nr2GS ->Multiply(fSPDpileup); + nr2intGS->Multiply(fSPDpileup); + nr1CB ->Multiply(fSPDpileup); + nr2CB ->Multiply(fSPDpileup); + nr1intCB->Multiply(fSPDpileup); + nr2intCB->Multiply(fSPDpileup); + + //correct for efficiency + TFile *fEff = new TFile("Pi0_efficiency_LHC11a__20131029_Mall.root") ; + + TF1 * effGS=fEff->Get("eff_Pi0_Gaus_2760GeV") ; + TF1 * effCB=fEff->Get("eff_Pi0_CB_2760GeV") ; + effGS ->SetRange(0.,25.) ; + effCB ->SetRange(0.,25.) ; + + nr1GS ->Divide(effGS) ; + nr1intGS->Divide(effGS) ; + nr2GS ->Divide(effGS) ; + nr2intGS->Divide(effGS) ; + nr1CB ->Divide(effCB) ; + nr2CB ->Divide(effCB) ; + nr1intCB->Divide(effCB) ; + nr2intCB->Divide(effCB) ; + + //make 1/pt + for(Int_t i=1;i<=nr1CB->GetNbinsX();i++){ + Double_t pt = TMath::TwoPi()*nr1CB->GetXaxis()->GetBinCenter(i); + nr1CB ->SetBinContent(i,nr1CB ->GetBinContent(i)/pt) ; + nr1CB ->SetBinError (i,nr1CB ->GetBinError(i) /pt) ; + nr1intCB->SetBinContent(i,nr1intCB->GetBinContent(i)/pt) ; + nr1intCB->SetBinError (i,nr1intCB->GetBinError(i) /pt) ; + nr2CB ->SetBinContent(i,nr2CB ->GetBinContent(i)/pt) ; + nr2CB ->SetBinError (i,nr2CB ->GetBinError(i) /pt) ; + nr2intCB->SetBinContent(i,nr2intCB->GetBinContent(i)/pt) ; + nr2intCB->SetBinError (i,nr2intCB->GetBinError(i) /pt) ; + + nr1GS ->SetBinContent(i,nr1GS ->GetBinContent(i)/pt) ; + nr1GS ->SetBinError (i,nr1GS ->GetBinError(i) /pt) ; + nr1intGS->SetBinContent(i,nr1intGS->GetBinContent(i)/pt) ; + nr1intGS->SetBinError (i,nr1intGS->GetBinError(i) /pt) ; + nr2GS ->SetBinContent(i,nr2GS ->GetBinContent(i)/pt) ; + nr2GS ->SetBinError (i,nr2GS ->GetBinError(i) /pt) ; + nr2intGS->SetBinContent(i,nr2intGS->GetBinContent(i)/pt) ; + nr2intGS->SetBinError (i,nr2intGS->GetBinError(i) /pt) ; + } + + //For the final spectrum we take average of fits + //with numerical integration of entries in signal + + TH1D * hStat = (TH1D*)nr2intCB->Clone("hPi02760GeVStat") ; + TH1D * hSys = (TH1D*)hStat ->Clone("hPi02760GeVSys") ; + TH1D * hSys2 = (TH1D*)hStat ->Clone("hPi02760GeVSysTypeB") ; + TH1D * hSys3 = (TH1D*)hStat ->Clone("hPi02760GeVSysTypeC") ; + hStat->SetAxisRange(0.,14.9,"X"); + hSys ->SetAxisRange(0.,14.9,"X"); + + //For systematic error estimate take largest deviation + //of integrated yeilds (note, they are efficiency corrected) + for(Int_t i=1;i<=nr1CB->GetNbinsX();i++){ + Double_t mean= hStat->GetBinContent(i) ; + Double_t dev = TMath::Max( + TMath::Max(TMath::Abs(nr1intCB->GetBinContent(i)-mean), + TMath::Abs(nr2intCB->GetBinContent(i)-mean)), + TMath::Max(TMath::Abs(nr1intGS->GetBinContent(i)-mean), + TMath::Abs(nr2intGS->GetBinContent(i)-mean)) + ); + hSys ->SetBinError(i,dev) ; + hSys2->SetBinError(i,dev) ; + } + + //Add other sys errors + TF1 * globalE = new TF1("globalE","1.-((x+1.354)/(x*1.002+1.354))^6.18 ",1.,30.) ; + TF1 * conv = new TF1("conversion","0.035",0.,30.) ; + TF1 * accept = new TF1("accept" ,"0.01" ,0.,30.) ; + TF1 * pileup = new TF1("pileup" ,"0.004",0.,30.) ; + TF1 * calib = new TF1("calib" ,"0.005",0.,30.) ; + TF1 * modDiff = new TF1("modDiff" ,"0.04",0.,30.) ; + // TF1 * modDiff = new TF1("modDiff" ,"16.9*exp(-4.5*x)+0.033",0.,30.) ; + TF1 * tofCut = new TF1("tofCut" ,"0.0105" ,0.,30.) ; + + //Borya's estimate of non-linearity (found for pp @ 7 TeV) + TF1 * nonlin= new TF1("nl","0.015+7.38*exp(-x/0.24)",0.,30.) ; + + //Draw sys errors + TH1D * hRelSysRaw = (TH1D*)hSys->Clone("RelSysRaw") ; + hRelSysRaw->SetTitle("Summary of systematic errors"); + for(Int_t i=1;i<=hSys->GetNbinsX();i++){ + Double_t mean= hSys->GetBinContent(i) ; + Double_t a=hSys->GetBinError(i) ; + if(mean>0) + hRelSysRaw->SetBinContent(i,a/mean) ; + else + hRelSysRaw->SetBinContent(i,0.) ; + hRelSysRaw->SetBinError(i,0.) ; + } + + //Add errors in sys errors + + TH1D * hRelSysTot = (TH1D*)hSys->Clone("RelSys") ; + hRelSysTot->SetTitle("Summary of systematic uncertainties"); + + for(Int_t i=1;i<=hSys->GetNbinsX();i++){ + Double_t pt = hSys->GetXaxis()->GetBinCenter(i) ; + Double_t mean = hSys->GetBinContent(i) ; + Double_t a = hSys->GetBinError(i) ; + // Double_t b = mean * hSysErrModules->GetBinContent(i) ; + Double_t tot= mean*mean*nonlin ->Eval(pt)*nonlin ->Eval(pt) + +mean*mean*conv ->Eval(pt)*conv ->Eval(pt) + +mean*mean*accept ->Eval(pt)*accept ->Eval(pt) + +mean*mean*pileup ->Eval(pt)*pileup ->Eval(pt) + +mean*mean*calib ->Eval(pt)*calib ->Eval(pt) + +mean*mean*modDiff->Eval(pt)*modDiff->Eval(pt) + +mean*mean*tofCut ->Eval(pt)*tofCut ->Eval(pt) + +mean*mean*globalE->Eval(pt)*globalE->Eval(pt); + Double_t raa= mean*mean*nonlin->Eval(pt)*nonlin->Eval(pt) + +mean*mean*pileup->Eval(pt)*pileup->Eval(pt) + +mean*mean*calib ->Eval(pt)*calib ->Eval(pt); + hSys3->SetBinError(i,TMath::Sqrt(tot)) ; + // hSys->SetBinError(i,TMath::Sqrt(tot + a*a + b*b)) ; + hSys2->SetBinError(i,TMath::Sqrt(raa + a*a)) ; + hSys ->SetBinError(i,TMath::Sqrt(tot + a*a)) ; + + a = hSys->GetBinError(i) ; + printf("i=%d, %g+-%g\n",i,mean,a); + if(mean>0) + hRelSysTot->SetBinContent(i,a/mean) ; + else { + hRelSysTot->SetBinContent(i,0.) ; + hRelSysTot->SetBinError(i,0.) ; + } + } + + // TFile *fSysErrModules = TFile::Open("PHOS_sysErr_modules.root"); + // TH1D* hSysErrModules = (TH1D*)fSysErrModules->Get("hSyserr"); + + gStyle->SetOptStat(0); + TCanvas * c = new TCanvas("c","SysErrors") ; + c->SetLogy(); + c->cd() ; + gPad->SetRightMargin(0.02); + gPad->SetTopMargin(0.07); + hRelSysTot->SetAxisRange(0.8 ,11.9,"X"); + hRelSysTot->SetAxisRange(0.0031,0.45,"Y"); + hRelSysTot->GetYaxis()->SetMoreLogLabels(); + hRelSysTot->GetYaxis()->SetNoExponent(); + hRelSysTot->SetNdivisions(520,"X"); + hRelSysTot->SetLineColor(1) ; + hRelSysTot->SetLineWidth(2) ; + hRelSysRaw->SetLineColor(2) ; + hRelSysRaw->SetLineWidth(2) ; + globalE->SetLineColor(kGreen+2) ; + nonlin ->SetLineColor(4) ; + conv ->SetLineColor(6) ; + accept ->SetLineColor(kOrange) ; + pileup ->SetLineColor(42); + calib ->SetLineColor(44); + calib ->SetLineStyle(2); + modDiff->SetLineColor(52); + modDiff->SetLineStyle(2); + tofCut ->SetLineColor(53); + tofCut ->SetLineStyle(3); + // hSysErrModules->SetLineColor(kOrange+2); + // hSysErrModules->SetLineStyle(2); + hRelSysTot->SetXTitle("p_{T} (GeV/c)") ; + hRelSysTot->SetYTitle("Rel.syst.error") ; + hRelSysTot->GetYaxis()->SetTitleOffset(1.2) ; + hRelSysTot->Draw("hist") ; + hRelSysRaw->Draw("h same") ; + globalE->Draw("same") ; + nonlin ->Draw("same") ; + conv ->Draw("same") ; + accept ->Draw("same") ; + pileup ->Draw("same"); + calib ->Draw("same"); + modDiff->Draw("same"); + tofCut ->Draw("same"); + // hSysErrModules->Draw("same ]["); + TLegend * l = new TLegend(0.57,0.62,0.85,0.925) ; + l->SetFillColor(kWhite); + l->SetBorderSize(0); + l->AddEntry(hRelSysTot,"Total uncertainty","l") ; + l->AddEntry(hRelSysRaw,"Raw extraction","l") ; + l->AddEntry(conv ,"Conversion","l") ; + l->AddEntry(nonlin ,"Non-linearity","l") ; + l->AddEntry(accept ,"Acceptance","l"); + l->AddEntry(pileup ,"Pileup","l"); + l->AddEntry(calib ,"Rel.calib.","l"); + l->AddEntry(modDiff,"Per-module yield","l"); + l->AddEntry(tofCut ,"Timing cut","l"); + // l->AddEntry(hSysErrModules,"Intermodule spectra","l"); + l->AddEntry(globalE,"Global E scale","l") ; + l->Draw() ; + + c->Print("LHC11a_SysErrors.eps"); + + hStat->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, stat.err."); + hStat->SetXTitle("p_{T}, GeV/c"); + hStat->SetYTitle("1/N_{ev} 1/(2#pi p_{T}) d^{2}N/dydp_{T} (GeV^{-2}c^{2})"); + hSys ->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, total syst.err."); + hSys ->SetXTitle("p_{T}, GeV/c"); + hSys ->SetYTitle("1/N_{ev} 1/(2#pi p_{T}) d^{2}N/dydp_{T} (GeV^{-2}c^{2})"); + hSys2->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, syst.err. for R_{AA}"); + hSys3->SetTitle("Normalized production #pi^{0} yield, pp @ 2.76 TeV, apparatus syst.err."); + hSys ->SetFillColor(kBlue-10) ; + hSys ->SetNdivisions(520,"X"); + + hSysFinal = (TH1F*)hSys->Clone("hSysFinal"); + hSysFinal ->SetTitle("Production #pi^{0} yield, pp @ 2.76 TeV, 07.11.2013"); + hSysFinal ->GetYaxis()->SetTitleOffset(1.2); + hStat->GetYaxis()->SetTitleOffset(1.2); + hSysFinal ->SetAxisRange(0.8,9.9,"X"); + + TCanvas *c2 = new TCanvas("c2","Production spectrum"); + gPad->SetRightMargin(0.02); + gPad->SetTopMargin(0.07); + gPad->SetGridx(); + gPad->SetGridy(); + c2->SetLogy(); + hSysFinal->Draw("E2") ; + hStat->SetMarkerStyle(20) ; + hStat->SetMarkerColor(4) ; + hStat->SetLineColor(4) ; + hStat->Draw("same") ; + + // //Apply bin width correction + // TH1D * hBWcorr = BinWidthCorrection(hStat) ; + // hSys->Divide(hBWcorr) ; + // hSys2->Divide(hBWcorr) ; + // hSys3->Divide(hBWcorr) ; + // hStat->Divide(hBWcorr) ; + + c2->Print("LHC11a_pi0Spectrum.eps"); + + TF1 *tsallis = FitTsallis(hStat,hSys); + + TFile fout("PHOS_pi0_2760eV_noBinWidthCorr_20131112.root","recreate") ; + hSys ->Write() ; + hSys2 ->Write() ; + hSys3 ->Write() ; + hStat ->Write() ; + tsallis->Write() ; + fout.Close() ; + + +} + +//----------------------------------------------------------------------------- +TF1 *FitTsallis(TH1D* hStat, TH1D* hSys) +{ + TF1 * fit = new TF1("Tsalis","[0]/2./3.1415*([2]-1.)*([2]-2.)/([2]*[1]*([2]*[1]+0.135*([2]-2.)))*(1.+(sqrt(x*x+0.135*0.135)-0.135)/([2]*[1]))^-[2]",0.5,25.) ; + fit->SetParameters(10.,0.2,8.) ; + fit->SetLineColor(kBlack) ; + fit->SetLineWidth(2) ; + fit->SetParName(0,"dN/dy") ; + fit->SetParName(1,"T") ; + fit->SetParName(2,"n") ; + + TH1D * hSysRatio = (TH1D*)hSys ->Clone("RatioSys") ; + TH1D * hStatRatio = (TH1D*)hStat->Clone("RatioStat") ; + + TH1D * hsum = (TH1D*)hStat->Clone("sum") ; + for(Int_t i=1; i<=hsum->GetNbinsX();i++){ + Double_t a=hSys->GetBinError(i) ; + Double_t b=hStat->GetBinError(i) ; + hsum->SetBinError(i,TMath::Sqrt(a*a+b*b)) ; + } + hsum->SetStats(1) ; + hsum->Fit(fit,"Q") ; + Double_t meanPt=fit->Moment(1,1.,10.) ; + printf("=%f \n",meanPt) ; + + hSysRatio ->Divide(fit) ; + hStatRatio->Divide(fit) ; + + return fit; +} +//----------------------------------------------------------------------------- +TH1D * BinWidthCorrection(TH1D * h){ + //We apply bin width a-la PHENIX + //Use Tsalis fit to calculate shift in y direction + + TF1 * fit = new TF1("hag","[0]*(([2]*[1]+sqrt(x*x+0.135*0.135))/([2]*[1]+0.135))^-[2]",0.5,25.) ; + fit->SetParameters(10.,0.2,8.) ; + TCanvas * corr = new TCanvas("BWcorr","Bin width correction") ; + Int_t col[6]={kRed,kOrange,kMagenta,kGreen,kCyan,kBlue} ; + TH1D * hcorr[20] ; + char key[55] ; + Double_t rMax=10 ; + Int_t iteration=0 ; + TH1D * htmp = (TH1D*)h->Clone("tmp") ; + while(iteration<6){ + printf(" Iteration %d: rMax=%f \n",iteration, rMax) ; + htmp->Fit(fit,"N") ; + sprintf(key,"Ineration%d",iteration) ; + hcorr[iteration]=(TH1D*)h->Clone(key); + rMax= 0; + for(Int_t i=1;i<=h->GetNbinsX();i++){ + Double_t a=h->GetXaxis()->GetBinLowEdge(i) ; + Double_t b=h->GetXaxis()->GetBinUpEdge(i) ; + Double_t r=fit->Integral(a,b)/(b-a)/fit->Eval(0.5*(a+b)) ; + hcorr[iteration]->SetBinContent(i,r) ; + hcorr[iteration]->SetBinError(i,0.) ; + if(rMaxClone("tmp") ; + htmp->Divide(hcorr[iteration]) ; + corr->cd() ; + hcorr[iteration]->SetLineColor(col[iteration]); + if(iteration==0) + hcorr[iteration]->Draw() ; + else + hcorr[iteration]->Draw("same") ; + corr->Update() ; + iteration++ ; + } + + hcorr[5]->SetTitle("Bin-width correction for #pi^{0} spectrum"); + hcorr[5]->SetYTitle("Bin-width corrected / uncorrected"); + TFile fout("PHOS_pi0_7TeV_BinWidthCorrection.root","recreate") ; + hcorr[5]->Write(); + fout.Close(); + + return hcorr[5] ; +} diff --git a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_CB.C b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_CB.C index 69a165b6644..03f41c30146 100644 --- a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_CB.C +++ b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_CB.C @@ -1,484 +1,484 @@ -void makeMmixPU_CB(const TString histoFile="LHC11a_pass4_20130913.root", - const Int_t nSigma=2, - const char* module="A10") -{ - //Fit Real/Mixed ratio, normalize Mixed and subtract it from Real. - // The pi0 peak if fitted by the Crystal Ball function, - // the background is fitted by pol1 or pol2 - - TString hMassName; - TFile * file = new TFile(histoFile) ; - THashList *hList = (THashList*)file->Get("histESD"); - char key[125] ; - hMassName = "hMassPt"; - hMassName += module; - TH2F * h = (TH2F*)hList->FindObject(hMassName) ; - - hMassName = "hMiMassPt"; - hMassName += module; - TH2F * hm = (TH2F*)hList->FindObject(hMassName) ; - - TH1F * hev = (TH1F*)hList->FindObject("hSelEvents") ; - - // Array of pt bins - Int_t nPadX = 6, nPadY = 3; - Int_t nbin=18 ; - Double_t xa[]={0.6,0.8,1.,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,3.0,3.5,4.0,5.,6.,8.,10.,12.} ; - PPRstyle(); - gStyle->SetPadLeftMargin(0.16); - gStyle->SetPadRightMargin(0.01); - gStyle->SetPadTopMargin(0.02); - gStyle->SetPadBottomMargin(0.11); - gStyle->SetTitleX(0.80); - gStyle->SetTitleY(0.98); - - //Fit real only - //Linear Bg - char key2[155]; - sprintf(key,"Mix_CB") ; - sprintf(key2,"%s_mr1",key) ; - TH1D * mr1 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_sr1",key) ; - TH1D * sr1 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_rms1",key) ; - TH1D * rms1 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_nnr1",key) ; - TH1D * nnr1 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_ar1",key) ; - TH1D * ar1 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_yr1",key) ; - TH1D * nr1 = new TH1D(key2,"Raw yield",nbin,xa) ; - sprintf(key2,"%s_yr1int",key) ; - TH1D * nr1int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; - - //Quadratic Bg - sprintf(key2,"%s_mr2",key) ; - TH1D * mr2 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_sr2",key) ; - TH1D * sr2 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_rms2",key) ; - TH1D * rms2 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_nnr2",key) ; - TH1D * nnr2 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_ar2",key) ; - TH1D * ar2 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_yr2",key) ; - TH1D * nr2 = new TH1D(key2,"Raw yield",nbin,xa) ; - sprintf(key2,"%s_yr2int",key) ; - TH1D * nr2int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; - - - TF1 * fit1 = new TF1("fit",CB,0.,1.,7) ; - fit->SetParName(0,"A") ; - fit->SetParName(1,"m_{0}") ; - fit->SetParName(2,"#sigma") ; - fit->SetParName(3,"a_{0}") ; - fit->SetParName(4,"a_{1}") ; - fit->SetLineWidth(2) ; - fit->SetLineColor(2) ; - - TF1 * fgs = new TF1("gs",CBs,0.,1.,5) ; - fgs->SetLineColor(2) ; - fgs->SetLineWidth(1) ; - - TF1 * fit2 = new TF1("fit2",CB2,0.,1.,8) ; - fit2->SetParName(0,"A") ; - fit2->SetParName(1,"m_{0}") ; - fit2->SetParName(2,"#sigma") ; - fit2->SetParName(3,"a_{0}") ; - fit2->SetParName(4,"a_{1}") ; - fit2->SetLineWidth(2) ; - fit2->SetLineColor(4) ; - fit2->SetLineStyle(2) ; - - TF1 * fbg1 = new TF1("bg1",BG1,0.,1.,2) ; - TF1 * fbg2 = new TF1("bg2",BG2,0.,1.,3) ; - - TCanvas * c3 = new TCanvas("mggFit1_CB_Signal","mggFitCB",10,10,1400,800) ; - c3->Divide(nPadX,nPadY) ; - - TCanvas * cReal = new TCanvas("cReal","Mgg real events",10,10,1400,800) ; - cReal->Divide(nPadX,nPadY) ; - - TCanvas * c1 = new TCanvas("mggFit1_CB","mggFit1",10,10,1400,800) ; - c1->Divide(nPadX,nPadY) ; - c1->cd(0) ; - TCanvas * c2=0,*c4=0,*c5=0,*c6=0 ; - - TAxis * pta=h->GetYaxis() ; - TAxis * ma=h->GetXaxis() ; - for(Int_t i=1;i<=nbin;i++){ - c1->cd(i) ; - Int_t imin=pta->FindBin(xa[i-1]+0.0001); - Int_t imax=pta->FindBin(xa[i]-0.0001) ; - Double_t pt=(xa[i]+xa[i-1])/2. ; - TH1D * hp = h->ProjectionX("re",imin,imax) ; - hp->Sumw2() ; - hp->SetNdivisions(505,"X"); - TH1D * hpm= hm->ProjectionX("mi",imin,imax) ; - hpm->Sumw2() ; - hpm->SetNdivisions(505,"X"); - if(i<15){ - hp ->Rebin(2) ; - hpm->Rebin(2) ; - } - else{ - hp ->Rebin(5) ; - hpm->Rebin(5) ; - } - hp ->SetNdivisions(506); - hpm->SetNdivisions(506); - hp ->SetLabelSize(0.05,"X"); - hpm->SetLabelSize(0.05,"X"); - hp ->SetTitleSize(0.00,"X"); - hpm->SetTitleSize(0.00,"X"); - hp ->SetLabelSize(0.05,"Y"); - hpm->SetLabelSize(0.05,"Y"); - hp ->SetTitleSize(0.05,"Y"); - hpm->SetTitleSize(0.05,"Y"); - hp ->SetTitleOffset(1.0,"X"); - hpm->SetTitleOffset(1.0,"X"); - if (i>12) { - hp ->SetLabelSize(0.05,"X"); - hpm->SetLabelSize(0.05,"X"); - hp ->SetTitleSize(0.05,"X"); - hpm->SetTitleSize(0.05,"X"); - hp ->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); - hpm->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); - } - // //Asign errors to the zero bins - // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hp->GetBinContent(ib)==0)hp->SetBinError(ib,1.);} - // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hpm->GetBinContent(ib)==0)hpm->SetBinError(ib,1.);} - - TH1D * hpm2 = (TH1D*)hpm->Clone("Bg1") ; - TH1D * hpcopy = (TH1D*)hp ->Clone("hpcopy") ; - TH1D * hp2 = (TH1D*)hp ->Clone("hp2") ; - TH1D * hpReal = (TH1D*)hp ->Clone("hpReal") ; - hpcopy->Divide(hpm) ; - sprintf(key,"%3.1fSetTitle(key) ; - hpReal->SetTitle(key) ; - hpReal->SetLineWidth(2); - hpcopy->SetMarkerStyle(20) ; - hpcopy->SetMarkerSize(0.7) ; - - Double_t mInit = 0.136., wInit = 0.005; - if(i==1) { - mInit = 0.139; - wInit = 0.007; - } - if(i==2) { - mInit = 0.136; - wInit = 0.007; - } - fit1->SetParameters(0.001,mInit,wInit,9.,0.5,0.0013,0.) ; - fit1->SetParLimits(2,0.003,0.010) ; - fit1->SetParLimits(1,0.132,0.139) ; - fit1->SetParLimits(0,0.,1e+6) ; -// fit1->SetParLimits(3,0.,10.) ; -// fit1->SetParLimits(4,0.,1e+2) ; - fit1->FixParameter(3,1.60) ; - fit1->FixParameter(4,1.27) ; - - //Select fitting range - Double_t rangeMin=0.06 ; - Double_t rangeMax=0.22 ; - if(i>=16)rangeMax=0.3 ; //More points to fix background - hpcopy->Fit(fit1,"NQ","",rangeMin,rangeMax) ; - hpcopy->Fit(fit1,"MQ","",rangeMin,rangeMax) ; - - fit2->SetParameters(fit1->GetParameters()) ; - fit2->SetParameter(2,wInit); - fit2->SetParLimits(2,0.003,0.008) ; - fit2->SetParLimits(1,0.130,0.142) ; - fit2->SetParLimits(0,0.,1e+6) ; -// fit2->SetParLimits(3,0.,10.) ; -// fit2->SetParLimits(4,0.,1e+2) ; - fit2->FixParameter(3,1.60) ; - fit2->FixParameter(4,1.27) ; - fit2->SetParameter(7,0.) ; - - hpcopy->Fit(fit2,"+NQ","",rangeMin,rangeMax) ; - hpcopy->Fit(fit2,"+MQ","",rangeMin,rangeMax) ; - - c1->cd(i) ; - hpcopy->SetAxisRange(0.065,0.229,"X") ; - hpcopy->Draw() ; - - cReal->cd(i) ; - hpReal->SetAxisRange(0.065,0.229,"X") ; - hpReal->Draw("ehist") ; - - fbg1->SetParameters(fit1->GetParameter(5),fit1->GetParameter(6)); - fbg2->SetParameters(fit2->GetParameter(5),fit2->GetParameter(6),fit2->GetParameter(7)); - Double_t intRangeMin = PeakPosition(pt)-nSigma*PeakWidth(pt) ; - Double_t intRangeMax = PeakPosition(pt)+nSigma*PeakWidth(pt) ; - Int_t intBinMin = hp->GetXaxis()->FindBin(intRangeMin) ; - Int_t intBinMax = hp->GetXaxis()->FindBin(intRangeMax) ; - Double_t errStat = hpm->Integral(intBinMin,intBinMax); - - hpm ->Multiply(fbg1) ; - hpm2->Multiply(fbg2) ; - hp ->Add(hpm,-1.) ; - hp2 ->Add(hpm2,-1.) ; - - c3->cd(i) ; - - if(i<15) - fgs->SetParameters(hp->Integral(32,36)/5.,fit1->GetParameter(1),fit1->GetParameter(2),fit1->GetParameter(3),fit1->GetParameter(4)) ; - else - fgs->SetParameters(hp->Integral(13,15)/3.,fit1->GetParameter(1),fit1->GetParameter(2),fit1->GetParameter(3),fit1->GetParameter(4)) ; -// fgs->SetParameters(hp->Integral(13,15)/3.,0.135,0.008,0.7,2.) ; - - fgs->SetParLimits(0,0.,1e+06) ; - fgs->SetParLimits(1,0.130,0.142) ; - fgs->SetParLimits(2,0.003,0.008) ; - fgs->FixParameter(3,1.60) ; - fgs->FixParameter(4,1.27) ; - - hp->Fit(fgs,"Q","",rangeMin,rangeMax) ; - hp->SetMaximum(hp2->GetMaximum()*1.1) ; - hp->SetMinimum(hp2->GetMinimum()*1.1) ; - hp->SetMarkerStyle(20) ; - hp->SetMarkerSize(0.7) ; - mr1->SetBinContent (i,fgs->GetParameter(1)) ; - mr1->SetBinError (i,fgs->GetParError(1)) ; - sr1->SetBinContent (i,TMath::Abs(fgs->GetParameter(2))) ; - sr1->SetBinError (i,fgs->GetParError(2)) ; - nnr1->SetBinContent(i,fgs->GetParameter(3)) ; - nnr1->SetBinError (i,fgs->GetParError(3)) ; - ar1->SetBinContent (i,fgs->GetParameter(4)) ; - ar1->SetBinError (i,fgs->GetParError(4)) ; - - Double_t y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; - nr1->SetBinContent(i,y) ; - if(y>0) - rms1->SetBinContent(i,fgs->CentralMoment(2.,0.05,0.2)) ; - Double_t ey=0 ; - if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ - Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; - Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; - ey=y*TMath::Sqrt(en*en+es*es) ; - } - nr1->SetBinError(i,ey) ; - - Double_t npiInt=hp->Integral(intBinMin,intBinMax) ; - Double_t norm=fbg1->GetParameter(0) ; - Double_t normErr=fbg1->GetParError(0) ; - if(npiInt>0.){ - nr1int->SetBinContent(i,npiInt) ; - nr1int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; - } - - hp2->GetXaxis()->SetRangeUser(0.05,0.25) ; - hp2->SetMaximum(hp2->GetMaximum()*1.1) ; - hp2->SetMinimum(hp2->GetMinimum()*1.1) ; - hp2->SetMarkerStyle(20) ; - hp2->SetMarkerSize(0.7) ; - - hp2->Fit(fgs,"Q","",rangeMin,rangeMax) ; - mr2->SetBinContent (i,fgs->GetParameter(1)) ; - mr2->SetBinError (i,fgs->GetParError(1)) ; - sr2->SetBinContent (i,TMath::Abs(fgs->GetParameter(2))) ; - sr2->SetBinError (i,fgs->GetParError(2)) ; - nnr2->SetBinContent(i,fgs->GetParameter(3)) ; - nnr2->SetBinError (i,fgs->GetParError(3)) ; - ar2->SetBinContent (i,fgs->GetParameter(4)) ; - ar2->SetBinError (i,fgs->GetParError(4)) ; - - y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; - nr2->SetBinContent(i,y) ; - ey=0 ; - if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ - Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; - Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; - ey=y*TMath::Sqrt(en*en+es*es) ; - } - nr2->SetBinError(i,ey) ; - npiInt=hp2->Integral(intBinMin,intBinMax) ; - norm=fbg2->GetParameter(0) ; - normErr=fbg2->GetParError(0) ; - if(npiInt>0.){ - nr2int->SetBinContent(i,npiInt) ; - nr2int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; - } - - hp2->SetTitle(key) ; - hp2->SetAxisRange(0.065,0.229,"X") ; - hp2->Draw() ; - delete hp ; -// delete hp2 ; -// delete hpcopy ; - delete hpm ; - delete hpm2 ; - c1->Update() ; - c3->Update() ; - cReal->Update() ; - } - - if (c3) c3->Print("Pi0_Signal_CB.eps") ; - if (c1) c1->Print("Pi0_Ratio_CB.eps") ; - if (cReal) cReal->Print("Pi0_InvMass_CB.eps") ; - - //Normalize by the number of non-pileup events - Double_t nMBOR = hev->GetBinContent(2); // MBOR events pass4 - // Double_t nPU = hev->GetBinContent(7); - // Double_t nMBOR = hev->GetBinContent(1); // MBOR events pass3 - // Double_t nPU = hev->GetBinContent(6); - Double_t nevents = nMBOR; - // Double_t nevents = nMBOR - nPU; - printf("==============\nN events = %d\n==============\n",nevents); - - nr1 ->Scale(1./nevents) ; - nr1int->Scale(1./nevents) ; - nr2 ->Scale(1./nevents) ; - nr2int->Scale(1./nevents) ; - - - TFile fout("LHC11a_FitResult.root","update"); - mr1 ->Write(0,TObject::kOverwrite) ; - sr1 ->Write(0,TObject::kOverwrite) ; - rms1 ->Write(0,TObject::kOverwrite) ; - nnr1 ->Write(0,TObject::kOverwrite) ; - ar1 ->Write(0,TObject::kOverwrite) ; - nr1 ->Write(0,TObject::kOverwrite) ; - nr1int->Write(0,TObject::kOverwrite) ; - mr2 ->Write(0,TObject::kOverwrite) ; - sr2 ->Write(0,TObject::kOverwrite) ; - rms2 ->Write(0,TObject::kOverwrite) ; - nnr2 ->Write(0,TObject::kOverwrite) ; - ar2 ->Write(0,TObject::kOverwrite) ; - nr2 ->Write(0,TObject::kOverwrite) ; - nr2int->Write(0,TObject::kOverwrite) ; - fout.Close() ; - -} - - -//----------------------------------------------------------------------------- -const Double_t kMean=0.135 ; //Approximate peak position to facilitate error estimate - -Double_t PeakPosition(Double_t pt){ - //Fit to the measured peak position - // return 4.99292e-003*exp(-pt*9.32300e-001)+1.34944e-001 ; - return 0.57*exp(-pt*7.62)+0.13592 ; -} -Double_t PeakWidth(Double_t pt){ - //fit to the measured peak width - return 1.60935e-02*exp(-pt*2.25609e+00)+4.65743e-03 ; - // return 0.0068 ; -} - -Double_t CB(Double_t * x, Double_t * par){ - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t n=par[3] ; - Double_t a=par[4] ; - Double_t dx=(x[0]-m)/s ; - if(dx>-a) - return par[0]*exp(-dx*dx/2.)+par[5]+par[6]*(x[0]-kMean) ; - else{ - Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; - Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; - return par[0]*A*TMath::Power((B-dx),-n)+par[5]+par[6]*(x[0]-kMean) ; - } - -} -Double_t CB2(Double_t * x, Double_t * par){ - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t n=par[3] ; - Double_t a=par[4] ; - Double_t dx=(x[0]-m)/s ; - if(dx>-a) - return par[0]*exp(-dx*dx/2.)+par[5]+par[6]*(x[0]-kMean)+par[7]*(x[0]-kMean)*(x[0]-kMean) ; - else{ - Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; - Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; - return par[0]*A*TMath::Power((B-dx),-n)+par[5]+par[6]*(x[0]-kMean)+par[7]*(x[0]-kMean)*(x[0]-kMean) ; - } - -} -Double_t CBs(Double_t * x, Double_t * par){ - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t n=par[3] ; - Double_t a=par[4] ; - Double_t dx=(x[0]-m)/s ; - if(dx>-a) - return par[0]*exp(-dx*dx/2.) ; - else{ - Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; - Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; - return par[0]*A*TMath::Power((B-dx),-n) ; - } -} -Double_t BG1(Double_t * x, Double_t * par){ - //Normalizatino of Mixed - return par[0]+par[1]*(x[0]-kMean) ; -} -Double_t BG2(Double_t * x, Double_t * par){ - //Another normalization of Mixed - return par[0]+par[1]*(x[0]-kMean)+par[2]*(x[0]-kMean)*(x[0]-kMean) ; -} - -//----------------------------------------------------------------------------- -PPRstyle() -{ - - ////////////////////////////////////////////////////////////////////// - // - // ROOT style macro for the TRD TDR - // - ////////////////////////////////////////////////////////////////////// - - gStyle->SetPalette(1); - gStyle->SetCanvasBorderMode(-1); - gStyle->SetCanvasBorderSize(1); - gStyle->SetCanvasColor(10); - - gStyle->SetFrameFillColor(10); - gStyle->SetFrameBorderSize(1); - gStyle->SetFrameBorderMode(-1); - gStyle->SetFrameLineWidth(1.2); - gStyle->SetFrameLineColor(1); - - gStyle->SetHistFillColor(0); - gStyle->SetHistLineWidth(1); - gStyle->SetHistLineColor(1); - - gStyle->SetPadColor(10); - gStyle->SetPadBorderSize(1); - gStyle->SetPadBorderMode(-1); - - gStyle->SetStatColor(10); - gStyle->SetTitleColor(kBlack,"X"); - gStyle->SetTitleColor(kBlack,"Y"); - - gStyle->SetLabelSize(0.04,"X"); - gStyle->SetLabelSize(0.04,"Y"); - gStyle->SetLabelSize(0.04,"Z"); - gStyle->SetTitleSize(0.04,"X"); - gStyle->SetTitleSize(0.04,"Y"); - gStyle->SetTitleSize(0.04,"Z"); - gStyle->SetTitleFont(42,"X"); - gStyle->SetTitleFont(42,"Y"); - gStyle->SetTitleFont(42,"X"); - gStyle->SetLabelFont(42,"X"); - gStyle->SetLabelFont(42,"Y"); - gStyle->SetLabelFont(42,"Z"); - gStyle->SetStatFont(42); - - gStyle->SetTitleOffset(1.0,"X"); - gStyle->SetTitleOffset(1.4,"Y"); - - gStyle->SetFillColor(kWhite); - gStyle->SetTitleFillColor(kWhite); - - gStyle->SetOptDate(0); - gStyle->SetOptTitle(1); - gStyle->SetOptStat(0); - gStyle->SetOptFit(0); - -} - +void makeMmixPU_CB(const TString histoFile="LHC11a_pass4_20130913.root", + const Int_t nSigma=2, + const char* module="A10") +{ + //Fit Real/Mixed ratio, normalize Mixed and subtract it from Real. + // The pi0 peak if fitted by the Crystal Ball function, + // the background is fitted by pol1 or pol2 + + TString hMassName; + TFile * file = new TFile(histoFile) ; + THashList *hList = (THashList*)file->Get("histESD"); + char key[125] ; + hMassName = "hMassPt"; + hMassName += module; + TH2F * h = (TH2F*)hList->FindObject(hMassName) ; + + hMassName = "hMiMassPt"; + hMassName += module; + TH2F * hm = (TH2F*)hList->FindObject(hMassName) ; + + TH1F * hev = (TH1F*)hList->FindObject("hSelEvents") ; + + // Array of pt bins + Int_t nPadX = 6, nPadY = 3; + Int_t nbin=18 ; + Double_t xa[]={0.6,0.8,1.,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,3.0,3.5,4.0,5.,6.,8.,10.,12.} ; + PPRstyle(); + gStyle->SetPadLeftMargin(0.16); + gStyle->SetPadRightMargin(0.01); + gStyle->SetPadTopMargin(0.02); + gStyle->SetPadBottomMargin(0.11); + gStyle->SetTitleX(0.80); + gStyle->SetTitleY(0.98); + + //Fit real only + //Linear Bg + char key2[155]; + sprintf(key,"Mix_CB") ; + sprintf(key2,"%s_mr1",key) ; + TH1D * mr1 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_sr1",key) ; + TH1D * sr1 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_rms1",key) ; + TH1D * rms1 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_nnr1",key) ; + TH1D * nnr1 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_ar1",key) ; + TH1D * ar1 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_yr1",key) ; + TH1D * nr1 = new TH1D(key2,"Raw yield",nbin,xa) ; + sprintf(key2,"%s_yr1int",key) ; + TH1D * nr1int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; + + //Quadratic Bg + sprintf(key2,"%s_mr2",key) ; + TH1D * mr2 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_sr2",key) ; + TH1D * sr2 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_rms2",key) ; + TH1D * rms2 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_nnr2",key) ; + TH1D * nnr2 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_ar2",key) ; + TH1D * ar2 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_yr2",key) ; + TH1D * nr2 = new TH1D(key2,"Raw yield",nbin,xa) ; + sprintf(key2,"%s_yr2int",key) ; + TH1D * nr2int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; + + + TF1 * fit1 = new TF1("fit",CB,0.,1.,7) ; + fit->SetParName(0,"A") ; + fit->SetParName(1,"m_{0}") ; + fit->SetParName(2,"#sigma") ; + fit->SetParName(3,"a_{0}") ; + fit->SetParName(4,"a_{1}") ; + fit->SetLineWidth(2) ; + fit->SetLineColor(2) ; + + TF1 * fgs = new TF1("gs",CBs,0.,1.,5) ; + fgs->SetLineColor(2) ; + fgs->SetLineWidth(1) ; + + TF1 * fit2 = new TF1("fit2",CB2,0.,1.,8) ; + fit2->SetParName(0,"A") ; + fit2->SetParName(1,"m_{0}") ; + fit2->SetParName(2,"#sigma") ; + fit2->SetParName(3,"a_{0}") ; + fit2->SetParName(4,"a_{1}") ; + fit2->SetLineWidth(2) ; + fit2->SetLineColor(4) ; + fit2->SetLineStyle(2) ; + + TF1 * fbg1 = new TF1("bg1",BG1,0.,1.,2) ; + TF1 * fbg2 = new TF1("bg2",BG2,0.,1.,3) ; + + TCanvas * c3 = new TCanvas("mggFit1_CB_Signal","mggFitCB",10,10,1400,800) ; + c3->Divide(nPadX,nPadY) ; + + TCanvas * cReal = new TCanvas("cReal","Mgg real events",10,10,1400,800) ; + cReal->Divide(nPadX,nPadY) ; + + TCanvas * c1 = new TCanvas("mggFit1_CB","mggFit1",10,10,1400,800) ; + c1->Divide(nPadX,nPadY) ; + c1->cd(0) ; + TCanvas * c2=0,*c4=0,*c5=0,*c6=0 ; + + TAxis * pta=h->GetYaxis() ; + TAxis * ma=h->GetXaxis() ; + for(Int_t i=1;i<=nbin;i++){ + c1->cd(i) ; + Int_t imin=pta->FindBin(xa[i-1]+0.0001); + Int_t imax=pta->FindBin(xa[i]-0.0001) ; + Double_t pt=(xa[i]+xa[i-1])/2. ; + TH1D * hp = h->ProjectionX("re",imin,imax) ; + hp->Sumw2() ; + hp->SetNdivisions(505,"X"); + TH1D * hpm= hm->ProjectionX("mi",imin,imax) ; + hpm->Sumw2() ; + hpm->SetNdivisions(505,"X"); + if(i<15){ + hp ->Rebin(2) ; + hpm->Rebin(2) ; + } + else{ + hp ->Rebin(5) ; + hpm->Rebin(5) ; + } + hp ->SetNdivisions(506); + hpm->SetNdivisions(506); + hp ->SetLabelSize(0.05,"X"); + hpm->SetLabelSize(0.05,"X"); + hp ->SetTitleSize(0.00,"X"); + hpm->SetTitleSize(0.00,"X"); + hp ->SetLabelSize(0.05,"Y"); + hpm->SetLabelSize(0.05,"Y"); + hp ->SetTitleSize(0.05,"Y"); + hpm->SetTitleSize(0.05,"Y"); + hp ->SetTitleOffset(1.0,"X"); + hpm->SetTitleOffset(1.0,"X"); + if (i>12) { + hp ->SetLabelSize(0.05,"X"); + hpm->SetLabelSize(0.05,"X"); + hp ->SetTitleSize(0.05,"X"); + hpm->SetTitleSize(0.05,"X"); + hp ->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); + hpm->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); + } + // //Asign errors to the zero bins + // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hp->GetBinContent(ib)==0)hp->SetBinError(ib,1.);} + // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hpm->GetBinContent(ib)==0)hpm->SetBinError(ib,1.);} + + TH1D * hpm2 = (TH1D*)hpm->Clone("Bg1") ; + TH1D * hpcopy = (TH1D*)hp ->Clone("hpcopy") ; + TH1D * hp2 = (TH1D*)hp ->Clone("hp2") ; + TH1D * hpReal = (TH1D*)hp ->Clone("hpReal") ; + hpcopy->Divide(hpm) ; + sprintf(key,"%3.1fSetTitle(key) ; + hpReal->SetTitle(key) ; + hpReal->SetLineWidth(2); + hpcopy->SetMarkerStyle(20) ; + hpcopy->SetMarkerSize(0.7) ; + + Double_t mInit = 0.136., wInit = 0.005; + if(i==1) { + mInit = 0.139; + wInit = 0.007; + } + if(i==2) { + mInit = 0.136; + wInit = 0.007; + } + fit1->SetParameters(0.001,mInit,wInit,9.,0.5,0.0013,0.) ; + fit1->SetParLimits(2,0.003,0.010) ; + fit1->SetParLimits(1,0.132,0.139) ; + fit1->SetParLimits(0,0.,1e+6) ; +// fit1->SetParLimits(3,0.,10.) ; +// fit1->SetParLimits(4,0.,1e+2) ; + fit1->FixParameter(3,1.60) ; + fit1->FixParameter(4,1.27) ; + + //Select fitting range + Double_t rangeMin=0.06 ; + Double_t rangeMax=0.22 ; + if(i>=16)rangeMax=0.3 ; //More points to fix background + hpcopy->Fit(fit1,"NQ","",rangeMin,rangeMax) ; + hpcopy->Fit(fit1,"MQ","",rangeMin,rangeMax) ; + + fit2->SetParameters(fit1->GetParameters()) ; + fit2->SetParameter(2,wInit); + fit2->SetParLimits(2,0.003,0.008) ; + fit2->SetParLimits(1,0.130,0.142) ; + fit2->SetParLimits(0,0.,1e+6) ; +// fit2->SetParLimits(3,0.,10.) ; +// fit2->SetParLimits(4,0.,1e+2) ; + fit2->FixParameter(3,1.60) ; + fit2->FixParameter(4,1.27) ; + fit2->SetParameter(7,0.) ; + + hpcopy->Fit(fit2,"+NQ","",rangeMin,rangeMax) ; + hpcopy->Fit(fit2,"+MQ","",rangeMin,rangeMax) ; + + c1->cd(i) ; + hpcopy->SetAxisRange(0.065,0.229,"X") ; + hpcopy->Draw() ; + + cReal->cd(i) ; + hpReal->SetAxisRange(0.065,0.229,"X") ; + hpReal->Draw("ehist") ; + + fbg1->SetParameters(fit1->GetParameter(5),fit1->GetParameter(6)); + fbg2->SetParameters(fit2->GetParameter(5),fit2->GetParameter(6),fit2->GetParameter(7)); + Double_t intRangeMin = PeakPosition(pt)-nSigma*PeakWidth(pt) ; + Double_t intRangeMax = PeakPosition(pt)+nSigma*PeakWidth(pt) ; + Int_t intBinMin = hp->GetXaxis()->FindBin(intRangeMin) ; + Int_t intBinMax = hp->GetXaxis()->FindBin(intRangeMax) ; + Double_t errStat = hpm->Integral(intBinMin,intBinMax); + + hpm ->Multiply(fbg1) ; + hpm2->Multiply(fbg2) ; + hp ->Add(hpm,-1.) ; + hp2 ->Add(hpm2,-1.) ; + + c3->cd(i) ; + + if(i<15) + fgs->SetParameters(hp->Integral(32,36)/5.,fit1->GetParameter(1),fit1->GetParameter(2),fit1->GetParameter(3),fit1->GetParameter(4)) ; + else + fgs->SetParameters(hp->Integral(13,15)/3.,fit1->GetParameter(1),fit1->GetParameter(2),fit1->GetParameter(3),fit1->GetParameter(4)) ; +// fgs->SetParameters(hp->Integral(13,15)/3.,0.135,0.008,0.7,2.) ; + + fgs->SetParLimits(0,0.,1e+06) ; + fgs->SetParLimits(1,0.130,0.142) ; + fgs->SetParLimits(2,0.003,0.008) ; + fgs->FixParameter(3,1.60) ; + fgs->FixParameter(4,1.27) ; + + hp->Fit(fgs,"Q","",rangeMin,rangeMax) ; + hp->SetMaximum(hp2->GetMaximum()*1.1) ; + hp->SetMinimum(hp2->GetMinimum()*1.1) ; + hp->SetMarkerStyle(20) ; + hp->SetMarkerSize(0.7) ; + mr1->SetBinContent (i,fgs->GetParameter(1)) ; + mr1->SetBinError (i,fgs->GetParError(1)) ; + sr1->SetBinContent (i,TMath::Abs(fgs->GetParameter(2))) ; + sr1->SetBinError (i,fgs->GetParError(2)) ; + nnr1->SetBinContent(i,fgs->GetParameter(3)) ; + nnr1->SetBinError (i,fgs->GetParError(3)) ; + ar1->SetBinContent (i,fgs->GetParameter(4)) ; + ar1->SetBinError (i,fgs->GetParError(4)) ; + + Double_t y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; + nr1->SetBinContent(i,y) ; + if(y>0) + rms1->SetBinContent(i,fgs->CentralMoment(2.,0.05,0.2)) ; + Double_t ey=0 ; + if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ + Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; + Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; + ey=y*TMath::Sqrt(en*en+es*es) ; + } + nr1->SetBinError(i,ey) ; + + Double_t npiInt=hp->Integral(intBinMin,intBinMax) ; + Double_t norm=fbg1->GetParameter(0) ; + Double_t normErr=fbg1->GetParError(0) ; + if(npiInt>0.){ + nr1int->SetBinContent(i,npiInt) ; + nr1int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; + } + + hp2->GetXaxis()->SetRangeUser(0.05,0.25) ; + hp2->SetMaximum(hp2->GetMaximum()*1.1) ; + hp2->SetMinimum(hp2->GetMinimum()*1.1) ; + hp2->SetMarkerStyle(20) ; + hp2->SetMarkerSize(0.7) ; + + hp2->Fit(fgs,"Q","",rangeMin,rangeMax) ; + mr2->SetBinContent (i,fgs->GetParameter(1)) ; + mr2->SetBinError (i,fgs->GetParError(1)) ; + sr2->SetBinContent (i,TMath::Abs(fgs->GetParameter(2))) ; + sr2->SetBinError (i,fgs->GetParError(2)) ; + nnr2->SetBinContent(i,fgs->GetParameter(3)) ; + nnr2->SetBinError (i,fgs->GetParError(3)) ; + ar2->SetBinContent (i,fgs->GetParameter(4)) ; + ar2->SetBinError (i,fgs->GetParError(4)) ; + + y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; + nr2->SetBinContent(i,y) ; + ey=0 ; + if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ + Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; + Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; + ey=y*TMath::Sqrt(en*en+es*es) ; + } + nr2->SetBinError(i,ey) ; + npiInt=hp2->Integral(intBinMin,intBinMax) ; + norm=fbg2->GetParameter(0) ; + normErr=fbg2->GetParError(0) ; + if(npiInt>0.){ + nr2int->SetBinContent(i,npiInt) ; + nr2int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; + } + + hp2->SetTitle(key) ; + hp2->SetAxisRange(0.065,0.229,"X") ; + hp2->Draw() ; + delete hp ; +// delete hp2 ; +// delete hpcopy ; + delete hpm ; + delete hpm2 ; + c1->Update() ; + c3->Update() ; + cReal->Update() ; + } + + if (c3) c3->Print("Pi0_Signal_CB.eps") ; + if (c1) c1->Print("Pi0_Ratio_CB.eps") ; + if (cReal) cReal->Print("Pi0_InvMass_CB.eps") ; + + //Normalize by the number of non-pileup events + Double_t nMBOR = hev->GetBinContent(2); // MBOR events pass4 + // Double_t nPU = hev->GetBinContent(7); + // Double_t nMBOR = hev->GetBinContent(1); // MBOR events pass3 + // Double_t nPU = hev->GetBinContent(6); + Double_t nevents = nMBOR; + // Double_t nevents = nMBOR - nPU; + printf("==============\nN events = %d\n==============\n",nevents); + + nr1 ->Scale(1./nevents) ; + nr1int->Scale(1./nevents) ; + nr2 ->Scale(1./nevents) ; + nr2int->Scale(1./nevents) ; + + + TFile fout("LHC11a_FitResult.root","update"); + mr1 ->Write(0,TObject::kOverwrite) ; + sr1 ->Write(0,TObject::kOverwrite) ; + rms1 ->Write(0,TObject::kOverwrite) ; + nnr1 ->Write(0,TObject::kOverwrite) ; + ar1 ->Write(0,TObject::kOverwrite) ; + nr1 ->Write(0,TObject::kOverwrite) ; + nr1int->Write(0,TObject::kOverwrite) ; + mr2 ->Write(0,TObject::kOverwrite) ; + sr2 ->Write(0,TObject::kOverwrite) ; + rms2 ->Write(0,TObject::kOverwrite) ; + nnr2 ->Write(0,TObject::kOverwrite) ; + ar2 ->Write(0,TObject::kOverwrite) ; + nr2 ->Write(0,TObject::kOverwrite) ; + nr2int->Write(0,TObject::kOverwrite) ; + fout.Close() ; + +} + + +//----------------------------------------------------------------------------- +const Double_t kMean=0.135 ; //Approximate peak position to facilitate error estimate + +Double_t PeakPosition(Double_t pt){ + //Fit to the measured peak position + // return 4.99292e-003*exp(-pt*9.32300e-001)+1.34944e-001 ; + return 0.57*exp(-pt*7.62)+0.13592 ; +} +Double_t PeakWidth(Double_t pt){ + //fit to the measured peak width + return 1.60935e-02*exp(-pt*2.25609e+00)+4.65743e-03 ; + // return 0.0068 ; +} + +Double_t CB(Double_t * x, Double_t * par){ + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t n=par[3] ; + Double_t a=par[4] ; + Double_t dx=(x[0]-m)/s ; + if(dx>-a) + return par[0]*exp(-dx*dx/2.)+par[5]+par[6]*(x[0]-kMean) ; + else{ + Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; + Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; + return par[0]*A*TMath::Power((B-dx),-n)+par[5]+par[6]*(x[0]-kMean) ; + } + +} +Double_t CB2(Double_t * x, Double_t * par){ + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t n=par[3] ; + Double_t a=par[4] ; + Double_t dx=(x[0]-m)/s ; + if(dx>-a) + return par[0]*exp(-dx*dx/2.)+par[5]+par[6]*(x[0]-kMean)+par[7]*(x[0]-kMean)*(x[0]-kMean) ; + else{ + Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; + Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; + return par[0]*A*TMath::Power((B-dx),-n)+par[5]+par[6]*(x[0]-kMean)+par[7]*(x[0]-kMean)*(x[0]-kMean) ; + } + +} +Double_t CBs(Double_t * x, Double_t * par){ + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t n=par[3] ; + Double_t a=par[4] ; + Double_t dx=(x[0]-m)/s ; + if(dx>-a) + return par[0]*exp(-dx*dx/2.) ; + else{ + Double_t A=TMath::Power((n/TMath::Abs(a)),n)*TMath::Exp(-a*a/2) ; + Double_t B=n/TMath::Abs(a)-TMath::Abs(a) ; + return par[0]*A*TMath::Power((B-dx),-n) ; + } +} +Double_t BG1(Double_t * x, Double_t * par){ + //Normalizatino of Mixed + return par[0]+par[1]*(x[0]-kMean) ; +} +Double_t BG2(Double_t * x, Double_t * par){ + //Another normalization of Mixed + return par[0]+par[1]*(x[0]-kMean)+par[2]*(x[0]-kMean)*(x[0]-kMean) ; +} + +//----------------------------------------------------------------------------- +PPRstyle() +{ + + ////////////////////////////////////////////////////////////////////// + // + // ROOT style macro for the TRD TDR + // + ////////////////////////////////////////////////////////////////////// + + gStyle->SetPalette(1); + gStyle->SetCanvasBorderMode(-1); + gStyle->SetCanvasBorderSize(1); + gStyle->SetCanvasColor(10); + + gStyle->SetFrameFillColor(10); + gStyle->SetFrameBorderSize(1); + gStyle->SetFrameBorderMode(-1); + gStyle->SetFrameLineWidth(1.2); + gStyle->SetFrameLineColor(1); + + gStyle->SetHistFillColor(0); + gStyle->SetHistLineWidth(1); + gStyle->SetHistLineColor(1); + + gStyle->SetPadColor(10); + gStyle->SetPadBorderSize(1); + gStyle->SetPadBorderMode(-1); + + gStyle->SetStatColor(10); + gStyle->SetTitleColor(kBlack,"X"); + gStyle->SetTitleColor(kBlack,"Y"); + + gStyle->SetLabelSize(0.04,"X"); + gStyle->SetLabelSize(0.04,"Y"); + gStyle->SetLabelSize(0.04,"Z"); + gStyle->SetTitleSize(0.04,"X"); + gStyle->SetTitleSize(0.04,"Y"); + gStyle->SetTitleSize(0.04,"Z"); + gStyle->SetTitleFont(42,"X"); + gStyle->SetTitleFont(42,"Y"); + gStyle->SetTitleFont(42,"X"); + gStyle->SetLabelFont(42,"X"); + gStyle->SetLabelFont(42,"Y"); + gStyle->SetLabelFont(42,"Z"); + gStyle->SetStatFont(42); + + gStyle->SetTitleOffset(1.0,"X"); + gStyle->SetTitleOffset(1.4,"Y"); + + gStyle->SetFillColor(kWhite); + gStyle->SetTitleFillColor(kWhite); + + gStyle->SetOptDate(0); + gStyle->SetOptTitle(1); + gStyle->SetOptStat(0); + gStyle->SetOptFit(0); + +} + diff --git a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_GS.C b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_GS.C index ea6c4b6dfd7..70f963dcd03 100644 --- a/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_GS.C +++ b/PWGGA/PHOSTasks/PHOS_pp_pi0/macros/makeMmixPU_GS.C @@ -1,421 +1,421 @@ -//----------------------------------------------------------------------------- -void makeMmixPU_GS(const TString histoFile="LHC11a_pass4_20130913.root", - const Int_t nSigma=2, - const char* module="A10") -{ - //Fit Real/Mixed ratio, normalize Mixed and subtract it from Real. - // The pi0 peak if fitted by the Gaussian function, - // the background is fitted by pol1 or pol2 - - TString hMassName; - TFile * file = new TFile(histoFile) ; - THashList *hList = (THashList*)file->Get("histESD"); - char key[125] ; - hMassName = "hMassPt"; - hMassName += module; - TH2F * h = (TH2F*)hList->FindObject(hMassName) ; - - hMassName = "hMiMassPt"; - hMassName += module; - TH2F * hm = (TH2F*)hList->FindObject(hMassName) ; - - TH1F * hev = (TH1F*)hList->FindObject("hSelEvents") ; - - // Array of pt bins - Int_t nbin=18 ; - Double_t xa[]={0.6,0.8,1.,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,3.0,3.5,4.0,5.,6.,8.,10.,12.} ; - PPRstyle(); - gStyle->SetPadLeftMargin(0.16); - gStyle->SetPadRightMargin(0.01); - gStyle->SetPadTopMargin(0.02); - gStyle->SetPadBottomMargin(0.11); - gStyle->SetTitleX(0.80); - gStyle->SetTitleY(0.98); - - //Fit real only - //Linear Bg - char key2[155]; - sprintf(key,"Mix") ; - sprintf(key2,"%s_mr1",key) ; - TH1D * mr1 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_sr1",key) ; - TH1D * sr1 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_ar1",key) ; - TH1D * ar1 = new TH1D(key2,"a",nbin,xa) ; - sprintf(key2,"%s_br1",key) ; - TH1D * br1 = new TH1D(key2,"a",nbin,xa) ; - sprintf(key2,"%s_yr1",key) ; - TH1D * nr1 = new TH1D(key2,"Raw yield",nbin,xa) ; - sprintf(key2,"%s_yr1int",key) ; - TH1D * nr1int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; - - //Quadratic Bg - sprintf(key2,"%s_mr2",key) ; - TH1D * mr2 = new TH1D(key2,"Mass",nbin,xa) ; - sprintf(key2,"%s_sr2",key) ; - TH1D * sr2 = new TH1D(key2,"Width",nbin,xa) ; - sprintf(key2,"%s_ar2",key) ; - TH1D * ar2 = new TH1D(key2,"a",nbin,xa) ; - sprintf(key2,"%s_br2",key) ; - TH1D * br2 = new TH1D(key2,"a",nbin,xa) ; - sprintf(key2,"%s_cr2",key) ; - TH1D * cr2 = new TH1D(key2,"a",nbin,xa) ; - sprintf(key2,"%s_yr2",key) ; - TH1D * nr2 = new TH1D(key2,"Raw yield",nbin,xa) ; - sprintf(key2,"%s_yr2int",key) ; - TH1D * nr2int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; - - TF1 * fit1 = new TF1("fit",CB,0.,1.,5) ; - fit->SetParName(0,"A") ; - fit->SetParName(1,"m_{0}") ; - fit->SetParName(2,"#sigma") ; - fit->SetParName(3,"a_{0}") ; - fit->SetParName(4,"a_{1}") ; - fit->SetLineWidth(2) ; - fit->SetLineColor(2) ; - TF1 * fgs = new TF1("gs",CBs,0.,1.,3) ; - fgs->SetLineColor(2) ; - fgs->SetLineWidth(1) ; - - TF1 * fit2 = new TF1("fit2",CB2,0.,1.,6) ; - fit2->SetParName(0,"A") ; - fit2->SetParName(1,"m_{0}") ; - fit2->SetParName(2,"#sigma") ; - fit2->SetParName(3,"a_{0}") ; - fit2->SetParName(4,"a_{1}") ; - fit2->SetLineWidth(2) ; - fit2->SetLineColor(4) ; - fit2->SetLineStyle(2) ; - TF1 * fbg1 = new TF1("bg1",BG1,0.,1.,2) ; - TF1 * fbg2 = new TF1("bg2",BG2,0.,1.,3) ; - - TCanvas * c3 = new TCanvas("mggFit1_Signal","mggFitCB",10,10,1400,800) ; - c3->Divide(6,3) ; - - TCanvas * cReal = new TCanvas("cReal","Mgg real events",10,10,1400,800) ; - cReal->Divide(6,3) ; - - TCanvas * c1 = new TCanvas("mggFit1","mggFit1",10,10,1400,800) ; - c1->Divide(6,3) ; - c1->cd(0) ; - TCanvas * c2=0,*c4=0,*c5=0,*c6=0 ; - - TAxis * pta=h->GetYaxis() ; - TAxis * ma=h->GetXaxis() ; - for(Int_t i=1;i<=nbin;i++){ - c1->cd(i) ; - Int_t imin=pta->FindBin(xa[i-1]+0.0001); - Int_t imax=pta->FindBin(xa[i]-0.0001) ; - Double_t pt=(xa[i]+xa[i-1])/2. ; - TH1D * hp = h->ProjectionX(Form("re%d",i),imin,imax) ; - hp->Sumw2() ; - TH1D * hpm= hm->ProjectionX(Form("mi%d",i),imin,imax) ; - hpm->Sumw2() ; - if(i<15){ - hp ->Rebin(2) ; - hpm->Rebin(2) ; - } - else{ - hp ->Rebin(5) ; - hpm->Rebin(5) ; - } - hp ->SetNdivisions(506); - hpm->SetNdivisions(506); - hp ->SetLabelSize(0.05,"X"); - hpm->SetLabelSize(0.05,"X"); - hp ->SetTitleSize(0.00,"X"); - hpm->SetTitleSize(0.00,"X"); - hp ->SetLabelSize(0.05,"Y"); - hpm->SetLabelSize(0.05,"Y"); - hp ->SetTitleSize(0.05,"Y"); - hpm->SetTitleSize(0.05,"Y"); - hp ->SetTitleOffset(1.0,"X"); - hpm->SetTitleOffset(1.0,"X"); - if (i>12) { - hp ->SetLabelSize(0.05,"X"); - hpm->SetLabelSize(0.05,"X"); - hp ->SetTitleSize(0.05,"X"); - hpm->SetTitleSize(0.05,"X"); - hp ->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); - hpm->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); - } - - // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hp ->GetBinContent(ib)==0)hp ->SetBinError(ib,1.);} - // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hpm->GetBinContent(ib)==0)hpm->SetBinError(ib,1.);} - TH1D * hpm2 = (TH1D*)hpm->Clone("Bg1") ; - TH1D * hpcopy = (TH1D*)hp ->Clone("hpcopy") ; - TH1D * hp2 = (TH1D*)hp ->Clone("hp2") ; - TH1D * hpReal = (TH1D*)hp ->Clone("hpReal") ; - hpcopy->Divide(hpm) ; - sprintf(key,"%3.1fSetTitle(key) ; - hpReal->SetTitle(key) ; - hpReal->SetLineWidth(2); - hpcopy->SetMarkerStyle(20) ; - hpcopy->SetMarkerSize(0.7) ; - - fit1->SetParameters(TMath::Min(0.3,0.001*i*i),0.136,0.0077,0.0013,-0.0007) ; - fit1->SetParLimits(2,0.003,0.010) ; - fit1->SetParLimits(1,0.132,0.139) ; - fit1->SetParLimits(0,0.,1.) ; - - Double_t rangeMin=0.06 ; - Double_t rangeMax=0.22 ; - if(i>=16)rangeMax=0.3 ; //More points to fix background - hpcopy->Fit(fit1,"NQ","",rangeMin,rangeMax) ; - hpcopy->Fit(fit1,"MQ","",rangeMin,rangeMax) ; - // hpcopy->Fit(fit1,"LQ","",rangeMin,rangeMax) ; - ar1->SetBinContent(i,fit1->GetParameter(3)) ; - ar1->SetBinError (i,fit1->GetParError (3)) ; - br1->SetBinContent(i,fit1->GetParameter(4)) ; - br1->SetBinError (i,fit1->GetParError (4)) ; - - fit2->SetParameters(fit1->GetParameters()) ; - fit2->SetParLimits(2,0.003,0.010) ; - fit2->SetParLimits(1,0.132,0.139) ; - fit2->SetParLimits(0,0.,1.) ; - fit2->SetParameter(5,0.) ; - - hpcopy->Fit(fit2,"+NQ","",rangeMin,rangeMax) ; - hpcopy->Fit(fit2,"+MQ","",rangeMin,rangeMax) ; - // hpcopy->Fit(fit2,"+LQ","",rangeMin,rangeMax) ; - ar2->SetBinContent(i,fit2->GetParameter(3)) ; - ar2->SetBinError (i,fit2->GetParError (3)) ; - br2->SetBinContent(i,fit2->GetParameter(4)) ; - br2->SetBinError (i,fit2->GetParError (4)) ; - cr2->SetBinContent(i,fit2->GetParameter(5)) ; - cr2->SetBinError (i,fit2->GetParError (5)) ; - - c1->cd(i) ; - hpcopy->SetAxisRange(0.065,0.229,"X") ; - hpcopy->Draw() ; - - cReal->cd(i) ; - hpReal->SetAxisRange(0.065,0.229,"X") ; - hpReal->Draw("ehist") ; - - fbg1->SetParameters(fit1->GetParameter(3),fit1->GetParameter(4)); - fbg2->SetParameters(fit2->GetParameter(3),fit2->GetParameter(4),fit2->GetParameter(5)); - - Double_t intRangeMin = PeakPosition(pt)-nSigma*PeakWidth(pt) ; - Double_t intRangeMax = PeakPosition(pt)+nSigma*PeakWidth(pt) ; - Int_t intBinMin = hp->GetXaxis()->FindBin(intRangeMin) ; - Int_t intBinMax = hp->GetXaxis()->FindBin(intRangeMax) ; - Double_t errStat = hpm->Integral(intBinMin,intBinMax); - - hpm ->Multiply(fbg1) ; - hpm2->Multiply(fbg2) ; - hp ->Add(hpm,-1.) ; - hp2 ->Add(hpm2,-1.) ; - - c3->cd(i) ; - - if(i<15) - fgs->SetParameters(hp->Integral(32,36)/5.,fit1->GetParameter(1),fit1->GetParameter(2)) ; - else - fgs->SetParameters(hp->Integral(13,15)/3.,0.136,0.005) ; - fgs->SetParLimits(2,0.003,0.010) ; - fgs->SetParLimits(1,0.132,0.142) ; - fgs->SetParLimits(0,0.,1.e+6) ; - - hp->Fit(fgs,"Q","",rangeMin,rangeMax) ; - hp->SetMaximum(hp2->GetMaximum()*1.1) ; - hp->SetMinimum(hp2->GetMinimum()*1.1) ; - hp->SetMarkerStyle(20) ; - hp->SetMarkerSize(0.7) ; - mr1->SetBinContent(i,fgs->GetParameter(1)) ; - mr1->SetBinError (i,fgs->GetParError(1)) ; - sr1->SetBinContent(i,TMath::Abs(fgs->GetParameter(2))) ; - sr1->SetBinError (i,fgs->GetParError(2)) ; - - Double_t y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; - nr1->SetBinContent(i,y) ; - Double_t ey=0 ; - if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ - Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; - Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; - ey=y*TMath::Sqrt(en*en+es*es) ; - } - nr1->SetBinError(i,ey) ; - - Double_t npiInt=hp->Integral(intBinMin,intBinMax) ; - Double_t norm=fbg1->GetParameter(0) ; - Double_t normErr=fbg1->GetParError(0) ; - if(npiInt>0.){ - nr1int->SetBinContent(i,npiInt) ; - nr1int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; - } - hp2->GetXaxis()->SetRangeUser(0.06,0.229) ; - hp2->SetMaximum(hp2->GetMaximum()*1.1) ; - hp2->SetMinimum(hp2->GetMinimum()*1.1) ; - hp2->SetMarkerStyle(20) ; - hp2->SetMarkerSize(0.7) ; - - hp2->Fit(fgs,"Q","",rangeMin,rangeMax) ; - mr2->SetBinContent(i,fgs->GetParameter(1)) ; - mr2->SetBinError (i,fgs->GetParError(1)) ; - sr2->SetBinContent(i,TMath::Abs(fgs->GetParameter(2))) ; - sr2->SetBinError (i,fgs->GetParError(2)) ; - y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; - nr2->SetBinContent(i,y) ; - ey=0 ; - if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ - Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; - Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; - ey=y*TMath::Sqrt(en*en+es*es) ; - } - nr2->SetBinError(i,ey) ; - npiInt=hp2->Integral(intBinMin,intBinMax) ; - norm=fbg2->GetParameter(0) ; - normErr=fbg2->GetParError(0) ; - if(npiInt>0.){ - nr2int->SetBinContent(i,npiInt) ; - nr2int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; - } - hp2->SetTitle(key) ; - hp2->SetAxisRange(0.065,0.229,"X") ; - hp2->Draw() ; - hp ->Draw("same") ; - delete hpm ; - delete hpm2 ; - c1->Update() ; - c3->Update() ; - cReal->Update() ; - } - - if (c3) c3->Print("Pi0_Signal_Gaus.eps") ; - if (c1) c1->Print("Pi0_Ratio_Gaus.eps") ; - if (cReal) cReal->Print("Pi0_InvMass_Gaus.eps") ; - - //Normalize by the number of events - Double_t nMBOR = hev->GetBinContent(2); // MBOR events pass4 - Double_t nevents = nMBOR; - printf("==============\nN events = %d\n==============\n",nevents); - - nr1 ->Scale(1./nevents) ; - nr1int->Scale(1./nevents) ; - nr2 ->Scale(1./nevents) ; - nr2int->Scale(1./nevents) ; - - - TFile fout("LHC11a_FitResult.root","update"); - mr1->Write(0,TObject::kOverwrite) ; - sr1->Write(0,TObject::kOverwrite) ; - ar1->Write(0,TObject::kOverwrite) ; - br1->Write(0,TObject::kOverwrite) ; - nr1->Write(0,TObject::kOverwrite) ; - nr1int->Write(0,TObject::kOverwrite) ; - ar2->Write(0,TObject::kOverwrite) ; - br2->Write(0,TObject::kOverwrite) ; - cr2->Write(0,TObject::kOverwrite) ; - mr2->Write(0,TObject::kOverwrite) ; - sr2->Write(0,TObject::kOverwrite) ; - nr2->Write(0,TObject::kOverwrite) ; - nr2int->Write(0,TObject::kOverwrite) ; - fout.Close() ; - -} - -//----------------------------------------------------------------------------- -const Double_t kMean=0.135 ; //Approximate peak position to facilitate error estimate - -Double_t PeakPosition(Double_t pt){ - //Fit to the measured peak position - return 0.454*exp(-pt*7.13)+0.13569 ; -} -Double_t PeakWidth(Double_t pt){ - //fit to the measured peak width - return 1.69e-02*exp(-pt*2.82)+4.93e-03 ; -} - -Double_t CB(Double_t * x, Double_t * par){ - //Parameterization of Real/Mixed ratio - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t dx=(x[0]-m)/s ; - return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean) ; -} -Double_t CB2(Double_t * x, Double_t * par){ - //Another parameterization of Real/Mixed ratio - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t dx=(x[0]-m)/s ; - return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean)+par[5]*(x[0]-kMean)*(x[0]-kMean) ; -} -Double_t CBs(Double_t * x, Double_t * par){ - //Parameterizatin of signal - Double_t m=par[1] ; - Double_t s=par[2] ; - Double_t dx=(x[0]-m)/s ; - return par[0]*exp(-dx*dx/2.) ; -} -Double_t BG1(Double_t * x, Double_t * par){ - //Normalizatino of Mixed - return par[0]+par[1]*(x[0]-kMean) ; -} -Double_t BG2(Double_t * x, Double_t * par){ - //Another normalization of Mixed - return par[0]+par[1]*(x[0]-kMean)+par[2]*(x[0]-kMean)*(x[0]-kMean) ; -} - - -//----------------------------------------------------------------------------- -PPRstyle() -{ - - ////////////////////////////////////////////////////////////////////// - // - // ROOT style macro for the TRD TDR - // - ////////////////////////////////////////////////////////////////////// - - gStyle->SetPalette(1); - gStyle->SetCanvasBorderMode(-1); - gStyle->SetCanvasBorderSize(1); - gStyle->SetCanvasColor(10); - - gStyle->SetFrameFillColor(10); - gStyle->SetFrameBorderSize(1); - gStyle->SetFrameBorderMode(-1); - gStyle->SetFrameLineWidth(1.2); - gStyle->SetFrameLineColor(1); - - gStyle->SetHistFillColor(0); - gStyle->SetHistLineWidth(1); - gStyle->SetHistLineColor(1); - - gStyle->SetPadColor(10); - gStyle->SetPadBorderSize(1); - gStyle->SetPadBorderMode(-1); - - gStyle->SetStatColor(10); - gStyle->SetTitleColor(kBlack,"X"); - gStyle->SetTitleColor(kBlack,"Y"); - - gStyle->SetLabelSize(0.04,"X"); - gStyle->SetLabelSize(0.04,"Y"); - gStyle->SetLabelSize(0.04,"Z"); - gStyle->SetTitleSize(0.04,"X"); - gStyle->SetTitleSize(0.04,"Y"); - gStyle->SetTitleSize(0.04,"Z"); - gStyle->SetTitleFont(42,"X"); - gStyle->SetTitleFont(42,"Y"); - gStyle->SetTitleFont(42,"X"); - gStyle->SetLabelFont(42,"X"); - gStyle->SetLabelFont(42,"Y"); - gStyle->SetLabelFont(42,"Z"); - gStyle->SetStatFont(42); - - gStyle->SetTitleOffset(1.0,"X"); - gStyle->SetTitleOffset(1.4,"Y"); - - gStyle->SetFillColor(kWhite); - gStyle->SetTitleFillColor(kWhite); - - gStyle->SetOptDate(0); - gStyle->SetOptTitle(1); - gStyle->SetOptStat(0); - gStyle->SetOptFit(0); - -} - +//----------------------------------------------------------------------------- +void makeMmixPU_GS(const TString histoFile="LHC11a_pass4_20130913.root", + const Int_t nSigma=2, + const char* module="A10") +{ + //Fit Real/Mixed ratio, normalize Mixed and subtract it from Real. + // The pi0 peak if fitted by the Gaussian function, + // the background is fitted by pol1 or pol2 + + TString hMassName; + TFile * file = new TFile(histoFile) ; + THashList *hList = (THashList*)file->Get("histESD"); + char key[125] ; + hMassName = "hMassPt"; + hMassName += module; + TH2F * h = (TH2F*)hList->FindObject(hMassName) ; + + hMassName = "hMiMassPt"; + hMassName += module; + TH2F * hm = (TH2F*)hList->FindObject(hMassName) ; + + TH1F * hev = (TH1F*)hList->FindObject("hSelEvents") ; + + // Array of pt bins + Int_t nbin=18 ; + Double_t xa[]={0.6,0.8,1.,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,3.0,3.5,4.0,5.,6.,8.,10.,12.} ; + PPRstyle(); + gStyle->SetPadLeftMargin(0.16); + gStyle->SetPadRightMargin(0.01); + gStyle->SetPadTopMargin(0.02); + gStyle->SetPadBottomMargin(0.11); + gStyle->SetTitleX(0.80); + gStyle->SetTitleY(0.98); + + //Fit real only + //Linear Bg + char key2[155]; + sprintf(key,"Mix") ; + sprintf(key2,"%s_mr1",key) ; + TH1D * mr1 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_sr1",key) ; + TH1D * sr1 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_ar1",key) ; + TH1D * ar1 = new TH1D(key2,"a",nbin,xa) ; + sprintf(key2,"%s_br1",key) ; + TH1D * br1 = new TH1D(key2,"a",nbin,xa) ; + sprintf(key2,"%s_yr1",key) ; + TH1D * nr1 = new TH1D(key2,"Raw yield",nbin,xa) ; + sprintf(key2,"%s_yr1int",key) ; + TH1D * nr1int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; + + //Quadratic Bg + sprintf(key2,"%s_mr2",key) ; + TH1D * mr2 = new TH1D(key2,"Mass",nbin,xa) ; + sprintf(key2,"%s_sr2",key) ; + TH1D * sr2 = new TH1D(key2,"Width",nbin,xa) ; + sprintf(key2,"%s_ar2",key) ; + TH1D * ar2 = new TH1D(key2,"a",nbin,xa) ; + sprintf(key2,"%s_br2",key) ; + TH1D * br2 = new TH1D(key2,"a",nbin,xa) ; + sprintf(key2,"%s_cr2",key) ; + TH1D * cr2 = new TH1D(key2,"a",nbin,xa) ; + sprintf(key2,"%s_yr2",key) ; + TH1D * nr2 = new TH1D(key2,"Raw yield",nbin,xa) ; + sprintf(key2,"%s_yr2int",key) ; + TH1D * nr2int = new TH1D(key2,"Raw yield, integrated",nbin,xa) ; + + TF1 * fit1 = new TF1("fit",CB,0.,1.,5) ; + fit->SetParName(0,"A") ; + fit->SetParName(1,"m_{0}") ; + fit->SetParName(2,"#sigma") ; + fit->SetParName(3,"a_{0}") ; + fit->SetParName(4,"a_{1}") ; + fit->SetLineWidth(2) ; + fit->SetLineColor(2) ; + TF1 * fgs = new TF1("gs",CBs,0.,1.,3) ; + fgs->SetLineColor(2) ; + fgs->SetLineWidth(1) ; + + TF1 * fit2 = new TF1("fit2",CB2,0.,1.,6) ; + fit2->SetParName(0,"A") ; + fit2->SetParName(1,"m_{0}") ; + fit2->SetParName(2,"#sigma") ; + fit2->SetParName(3,"a_{0}") ; + fit2->SetParName(4,"a_{1}") ; + fit2->SetLineWidth(2) ; + fit2->SetLineColor(4) ; + fit2->SetLineStyle(2) ; + TF1 * fbg1 = new TF1("bg1",BG1,0.,1.,2) ; + TF1 * fbg2 = new TF1("bg2",BG2,0.,1.,3) ; + + TCanvas * c3 = new TCanvas("mggFit1_Signal","mggFitCB",10,10,1400,800) ; + c3->Divide(6,3) ; + + TCanvas * cReal = new TCanvas("cReal","Mgg real events",10,10,1400,800) ; + cReal->Divide(6,3) ; + + TCanvas * c1 = new TCanvas("mggFit1","mggFit1",10,10,1400,800) ; + c1->Divide(6,3) ; + c1->cd(0) ; + TCanvas * c2=0,*c4=0,*c5=0,*c6=0 ; + + TAxis * pta=h->GetYaxis() ; + TAxis * ma=h->GetXaxis() ; + for(Int_t i=1;i<=nbin;i++){ + c1->cd(i) ; + Int_t imin=pta->FindBin(xa[i-1]+0.0001); + Int_t imax=pta->FindBin(xa[i]-0.0001) ; + Double_t pt=(xa[i]+xa[i-1])/2. ; + TH1D * hp = h->ProjectionX(Form("re%d",i),imin,imax) ; + hp->Sumw2() ; + TH1D * hpm= hm->ProjectionX(Form("mi%d",i),imin,imax) ; + hpm->Sumw2() ; + if(i<15){ + hp ->Rebin(2) ; + hpm->Rebin(2) ; + } + else{ + hp ->Rebin(5) ; + hpm->Rebin(5) ; + } + hp ->SetNdivisions(506); + hpm->SetNdivisions(506); + hp ->SetLabelSize(0.05,"X"); + hpm->SetLabelSize(0.05,"X"); + hp ->SetTitleSize(0.00,"X"); + hpm->SetTitleSize(0.00,"X"); + hp ->SetLabelSize(0.05,"Y"); + hpm->SetLabelSize(0.05,"Y"); + hp ->SetTitleSize(0.05,"Y"); + hpm->SetTitleSize(0.05,"Y"); + hp ->SetTitleOffset(1.0,"X"); + hpm->SetTitleOffset(1.0,"X"); + if (i>12) { + hp ->SetLabelSize(0.05,"X"); + hpm->SetLabelSize(0.05,"X"); + hp ->SetTitleSize(0.05,"X"); + hpm->SetTitleSize(0.05,"X"); + hp ->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); + hpm->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})"); + } + + // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hp ->GetBinContent(ib)==0)hp ->SetBinError(ib,1.);} + // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hpm->GetBinContent(ib)==0)hpm->SetBinError(ib,1.);} + TH1D * hpm2 = (TH1D*)hpm->Clone("Bg1") ; + TH1D * hpcopy = (TH1D*)hp ->Clone("hpcopy") ; + TH1D * hp2 = (TH1D*)hp ->Clone("hp2") ; + TH1D * hpReal = (TH1D*)hp ->Clone("hpReal") ; + hpcopy->Divide(hpm) ; + sprintf(key,"%3.1fSetTitle(key) ; + hpReal->SetTitle(key) ; + hpReal->SetLineWidth(2); + hpcopy->SetMarkerStyle(20) ; + hpcopy->SetMarkerSize(0.7) ; + + fit1->SetParameters(TMath::Min(0.3,0.001*i*i),0.136,0.0077,0.0013,-0.0007) ; + fit1->SetParLimits(2,0.003,0.010) ; + fit1->SetParLimits(1,0.132,0.139) ; + fit1->SetParLimits(0,0.,1.) ; + + Double_t rangeMin=0.06 ; + Double_t rangeMax=0.22 ; + if(i>=16)rangeMax=0.3 ; //More points to fix background + hpcopy->Fit(fit1,"NQ","",rangeMin,rangeMax) ; + hpcopy->Fit(fit1,"MQ","",rangeMin,rangeMax) ; + // hpcopy->Fit(fit1,"LQ","",rangeMin,rangeMax) ; + ar1->SetBinContent(i,fit1->GetParameter(3)) ; + ar1->SetBinError (i,fit1->GetParError (3)) ; + br1->SetBinContent(i,fit1->GetParameter(4)) ; + br1->SetBinError (i,fit1->GetParError (4)) ; + + fit2->SetParameters(fit1->GetParameters()) ; + fit2->SetParLimits(2,0.003,0.010) ; + fit2->SetParLimits(1,0.132,0.139) ; + fit2->SetParLimits(0,0.,1.) ; + fit2->SetParameter(5,0.) ; + + hpcopy->Fit(fit2,"+NQ","",rangeMin,rangeMax) ; + hpcopy->Fit(fit2,"+MQ","",rangeMin,rangeMax) ; + // hpcopy->Fit(fit2,"+LQ","",rangeMin,rangeMax) ; + ar2->SetBinContent(i,fit2->GetParameter(3)) ; + ar2->SetBinError (i,fit2->GetParError (3)) ; + br2->SetBinContent(i,fit2->GetParameter(4)) ; + br2->SetBinError (i,fit2->GetParError (4)) ; + cr2->SetBinContent(i,fit2->GetParameter(5)) ; + cr2->SetBinError (i,fit2->GetParError (5)) ; + + c1->cd(i) ; + hpcopy->SetAxisRange(0.065,0.229,"X") ; + hpcopy->Draw() ; + + cReal->cd(i) ; + hpReal->SetAxisRange(0.065,0.229,"X") ; + hpReal->Draw("ehist") ; + + fbg1->SetParameters(fit1->GetParameter(3),fit1->GetParameter(4)); + fbg2->SetParameters(fit2->GetParameter(3),fit2->GetParameter(4),fit2->GetParameter(5)); + + Double_t intRangeMin = PeakPosition(pt)-nSigma*PeakWidth(pt) ; + Double_t intRangeMax = PeakPosition(pt)+nSigma*PeakWidth(pt) ; + Int_t intBinMin = hp->GetXaxis()->FindBin(intRangeMin) ; + Int_t intBinMax = hp->GetXaxis()->FindBin(intRangeMax) ; + Double_t errStat = hpm->Integral(intBinMin,intBinMax); + + hpm ->Multiply(fbg1) ; + hpm2->Multiply(fbg2) ; + hp ->Add(hpm,-1.) ; + hp2 ->Add(hpm2,-1.) ; + + c3->cd(i) ; + + if(i<15) + fgs->SetParameters(hp->Integral(32,36)/5.,fit1->GetParameter(1),fit1->GetParameter(2)) ; + else + fgs->SetParameters(hp->Integral(13,15)/3.,0.136,0.005) ; + fgs->SetParLimits(2,0.003,0.010) ; + fgs->SetParLimits(1,0.132,0.142) ; + fgs->SetParLimits(0,0.,1.e+6) ; + + hp->Fit(fgs,"Q","",rangeMin,rangeMax) ; + hp->SetMaximum(hp2->GetMaximum()*1.1) ; + hp->SetMinimum(hp2->GetMinimum()*1.1) ; + hp->SetMarkerStyle(20) ; + hp->SetMarkerSize(0.7) ; + mr1->SetBinContent(i,fgs->GetParameter(1)) ; + mr1->SetBinError (i,fgs->GetParError(1)) ; + sr1->SetBinContent(i,TMath::Abs(fgs->GetParameter(2))) ; + sr1->SetBinError (i,fgs->GetParError(2)) ; + + Double_t y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; + nr1->SetBinContent(i,y) ; + Double_t ey=0 ; + if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ + Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; + Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; + ey=y*TMath::Sqrt(en*en+es*es) ; + } + nr1->SetBinError(i,ey) ; + + Double_t npiInt=hp->Integral(intBinMin,intBinMax) ; + Double_t norm=fbg1->GetParameter(0) ; + Double_t normErr=fbg1->GetParError(0) ; + if(npiInt>0.){ + nr1int->SetBinContent(i,npiInt) ; + nr1int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; + } + hp2->GetXaxis()->SetRangeUser(0.06,0.229) ; + hp2->SetMaximum(hp2->GetMaximum()*1.1) ; + hp2->SetMinimum(hp2->GetMinimum()*1.1) ; + hp2->SetMarkerStyle(20) ; + hp2->SetMarkerSize(0.7) ; + + hp2->Fit(fgs,"Q","",rangeMin,rangeMax) ; + mr2->SetBinContent(i,fgs->GetParameter(1)) ; + mr2->SetBinError (i,fgs->GetParError(1)) ; + sr2->SetBinContent(i,TMath::Abs(fgs->GetParameter(2))) ; + sr2->SetBinError (i,fgs->GetParError(2)) ; + y=fgs->Integral(intRangeMin,intRangeMax)/hp->GetXaxis()->GetBinWidth(1) ; + nr2->SetBinContent(i,y) ; + ey=0 ; + if(fgs->GetParameter(0)!=0. && fgs->GetParameter(2)!=0.){ + Double_t en=fgs->GetParError(0)/fgs->GetParameter(0) ; + Double_t es=fgs->GetParError(2)/fgs->GetParameter(2) ; + ey=y*TMath::Sqrt(en*en+es*es) ; + } + nr2->SetBinError(i,ey) ; + npiInt=hp2->Integral(intBinMin,intBinMax) ; + norm=fbg2->GetParameter(0) ; + normErr=fbg2->GetParError(0) ; + if(npiInt>0.){ + nr2int->SetBinContent(i,npiInt) ; + nr2int->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; + } + hp2->SetTitle(key) ; + hp2->SetAxisRange(0.065,0.229,"X") ; + hp2->Draw() ; + hp ->Draw("same") ; + delete hpm ; + delete hpm2 ; + c1->Update() ; + c3->Update() ; + cReal->Update() ; + } + + if (c3) c3->Print("Pi0_Signal_Gaus.eps") ; + if (c1) c1->Print("Pi0_Ratio_Gaus.eps") ; + if (cReal) cReal->Print("Pi0_InvMass_Gaus.eps") ; + + //Normalize by the number of events + Double_t nMBOR = hev->GetBinContent(2); // MBOR events pass4 + Double_t nevents = nMBOR; + printf("==============\nN events = %d\n==============\n",nevents); + + nr1 ->Scale(1./nevents) ; + nr1int->Scale(1./nevents) ; + nr2 ->Scale(1./nevents) ; + nr2int->Scale(1./nevents) ; + + + TFile fout("LHC11a_FitResult.root","update"); + mr1->Write(0,TObject::kOverwrite) ; + sr1->Write(0,TObject::kOverwrite) ; + ar1->Write(0,TObject::kOverwrite) ; + br1->Write(0,TObject::kOverwrite) ; + nr1->Write(0,TObject::kOverwrite) ; + nr1int->Write(0,TObject::kOverwrite) ; + ar2->Write(0,TObject::kOverwrite) ; + br2->Write(0,TObject::kOverwrite) ; + cr2->Write(0,TObject::kOverwrite) ; + mr2->Write(0,TObject::kOverwrite) ; + sr2->Write(0,TObject::kOverwrite) ; + nr2->Write(0,TObject::kOverwrite) ; + nr2int->Write(0,TObject::kOverwrite) ; + fout.Close() ; + +} + +//----------------------------------------------------------------------------- +const Double_t kMean=0.135 ; //Approximate peak position to facilitate error estimate + +Double_t PeakPosition(Double_t pt){ + //Fit to the measured peak position + return 0.454*exp(-pt*7.13)+0.13569 ; +} +Double_t PeakWidth(Double_t pt){ + //fit to the measured peak width + return 1.69e-02*exp(-pt*2.82)+4.93e-03 ; +} + +Double_t CB(Double_t * x, Double_t * par){ + //Parameterization of Real/Mixed ratio + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t dx=(x[0]-m)/s ; + return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean) ; +} +Double_t CB2(Double_t * x, Double_t * par){ + //Another parameterization of Real/Mixed ratio + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t dx=(x[0]-m)/s ; + return par[0]*exp(-dx*dx/2.)+par[3]+par[4]*(x[0]-kMean)+par[5]*(x[0]-kMean)*(x[0]-kMean) ; +} +Double_t CBs(Double_t * x, Double_t * par){ + //Parameterizatin of signal + Double_t m=par[1] ; + Double_t s=par[2] ; + Double_t dx=(x[0]-m)/s ; + return par[0]*exp(-dx*dx/2.) ; +} +Double_t BG1(Double_t * x, Double_t * par){ + //Normalizatino of Mixed + return par[0]+par[1]*(x[0]-kMean) ; +} +Double_t BG2(Double_t * x, Double_t * par){ + //Another normalization of Mixed + return par[0]+par[1]*(x[0]-kMean)+par[2]*(x[0]-kMean)*(x[0]-kMean) ; +} + + +//----------------------------------------------------------------------------- +PPRstyle() +{ + + ////////////////////////////////////////////////////////////////////// + // + // ROOT style macro for the TRD TDR + // + ////////////////////////////////////////////////////////////////////// + + gStyle->SetPalette(1); + gStyle->SetCanvasBorderMode(-1); + gStyle->SetCanvasBorderSize(1); + gStyle->SetCanvasColor(10); + + gStyle->SetFrameFillColor(10); + gStyle->SetFrameBorderSize(1); + gStyle->SetFrameBorderMode(-1); + gStyle->SetFrameLineWidth(1.2); + gStyle->SetFrameLineColor(1); + + gStyle->SetHistFillColor(0); + gStyle->SetHistLineWidth(1); + gStyle->SetHistLineColor(1); + + gStyle->SetPadColor(10); + gStyle->SetPadBorderSize(1); + gStyle->SetPadBorderMode(-1); + + gStyle->SetStatColor(10); + gStyle->SetTitleColor(kBlack,"X"); + gStyle->SetTitleColor(kBlack,"Y"); + + gStyle->SetLabelSize(0.04,"X"); + gStyle->SetLabelSize(0.04,"Y"); + gStyle->SetLabelSize(0.04,"Z"); + gStyle->SetTitleSize(0.04,"X"); + gStyle->SetTitleSize(0.04,"Y"); + gStyle->SetTitleSize(0.04,"Z"); + gStyle->SetTitleFont(42,"X"); + gStyle->SetTitleFont(42,"Y"); + gStyle->SetTitleFont(42,"X"); + gStyle->SetLabelFont(42,"X"); + gStyle->SetLabelFont(42,"Y"); + gStyle->SetLabelFont(42,"Z"); + gStyle->SetStatFont(42); + + gStyle->SetTitleOffset(1.0,"X"); + gStyle->SetTitleOffset(1.4,"Y"); + + gStyle->SetFillColor(kWhite); + gStyle->SetTitleFillColor(kWhite); + + gStyle->SetOptDate(0); + gStyle->SetOptTitle(1); + gStyle->SetOptStat(0); + gStyle->SetOptFit(0); + +} + diff --git a/PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx b/PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx index 8877e0c3b44..6bf6cf436ed 100644 --- a/PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx +++ b/PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx @@ -1,718 +1,718 @@ -/************************************************************************** - * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* $Id$ */ - -//////////////////////////////////////////////////////////////////////// -// -// Base class for cuts on Associated tracks for HF Correlation analysis -// -// Author: S.Bjelogrlic (Utrecht) sandro.bjelogrlic@cern.ch -//////////////////////////////////////////////////////////////////////// -#include -#include "AliHFAssociatedTrackCuts.h" -#include "AliAODPidHF.h" -#include "AliESDtrackCuts.h" -#include "AliESDtrack.h" -#include "AliESDVertex.h" -#include "AliAODv0.h" -#include "AliAODVertex.h" -#include "AliAODMCParticle.h" -#include "AliAnalysisManager.h" -#include "AliInputEventHandler.h" -#include "TString.h" - -using std::cout; -using std::endl; - -ClassImp(AliHFAssociatedTrackCuts) - -//-------------------------------------------------------------------------- -AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(): -AliAnalysisCuts(), -fESDTrackCuts(0), -fPidObj(0), - fEffWeights(0), - -fTrigEffWeightsvspt(0), -fTrigEffWeightsvsptB(0), -fTrigEffWeights(0), -fTrigEffWeightsB(0), -fPoolMaxNEvents(0), -fPoolMinNTracks(0), -fMinEventsToMix(0), -fNzVtxBins(0), -fNzVtxBinsDim(0), -fZvtxBins(0), -fNCentBins(0), -fNCentBinsDim(0), -fCentBins(0), - -fNofMCEventType(0), -fMCEventType(0), - -fNTrackCuts(0), -fAODTrackCuts(0), -fTrackCutsNames(0), -fNvZeroCuts(0), -fAODvZeroCuts(0), -fvZeroCutsNames(0), -fBit(-1), -fCharge(0), -fDescription("") - -{ - // - //default constructor - // - // - //default constructor - // - -} - -//-------------------------------------------------------------------------- -AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(const char* name, const char* title): -AliAnalysisCuts(name,title), -fESDTrackCuts(0), -fPidObj(0), -fEffWeights(0), -fTrigEffWeightsvspt(0), -fTrigEffWeightsvsptB(0), -fTrigEffWeights(0), -fTrigEffWeightsB(0), -fPoolMaxNEvents(0), -fPoolMinNTracks(0), -fMinEventsToMix(0), -fNzVtxBins(0), -fNzVtxBinsDim(0), -fZvtxBins(0), -fNCentBins(0), -fNCentBinsDim(0), -fCentBins(0), - -fNofMCEventType(0), -fMCEventType(0), - -fNTrackCuts(0), -fAODTrackCuts(0), -fTrackCutsNames(0), -fNvZeroCuts(0), -fAODvZeroCuts(0), -fvZeroCutsNames(0), -fBit(-1), -fCharge(0), -fDescription("") - -{ - // - //default constructor - // - -} -//-------------------------------------------------------------------------- -AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(const AliHFAssociatedTrackCuts &source) : -AliAnalysisCuts(source), -fESDTrackCuts(source.fESDTrackCuts), -fPidObj(source.fPidObj), -fEffWeights(source.fEffWeights), -fTrigEffWeightsvspt(source.fTrigEffWeightsvspt), -fTrigEffWeightsvsptB(source.fTrigEffWeightsvsptB), -fTrigEffWeights(source.fTrigEffWeights), -fTrigEffWeightsB(source.fTrigEffWeightsB), - -fPoolMaxNEvents(source.fPoolMaxNEvents), -fPoolMinNTracks(source.fPoolMinNTracks), -fMinEventsToMix(source.fMinEventsToMix), -fNzVtxBins(source.fNzVtxBins), -fNzVtxBinsDim(source.fNzVtxBinsDim), -fZvtxBins(source.fZvtxBins), -fNCentBins(source.fNCentBins), -fNCentBinsDim(source.fNCentBinsDim), -fCentBins(source.fCentBins), - -fNofMCEventType(source.fNofMCEventType), -fMCEventType(source.fMCEventType), - -fNTrackCuts(source.fNTrackCuts), -fAODTrackCuts(source.fAODTrackCuts), -fTrackCutsNames(source.fTrackCutsNames), -fNvZeroCuts(source.fNvZeroCuts), -fAODvZeroCuts(source.fAODvZeroCuts), -fvZeroCutsNames(source.fvZeroCutsNames), -fBit(source.fBit), -fCharge(source.fCharge), -fDescription(source.fDescription) -{ - // - // copy constructor - // - - - AliInfo("AliHFAssociatedTrackCuts::Copy constructor "); - if(source.fESDTrackCuts) AddTrackCuts(source.fESDTrackCuts); - if(source.fAODTrackCuts) SetAODTrackCuts(source.fAODTrackCuts); - if(source.fAODvZeroCuts) SetAODvZeroCuts(source.fAODvZeroCuts); - if(source.fPidObj) SetPidHF(source.fPidObj); - if(source.fEffWeights) SetEfficiencyWeightMap(source.fEffWeights); - if(source.fTrigEffWeightsvspt) SetTriggerEffWeightMapvspt(source.fTrigEffWeightsvspt); - if(source.fTrigEffWeightsvsptB) SetTriggerEffWeightMapvsptB(source.fTrigEffWeightsvsptB); - if(source.fTrigEffWeights) SetTriggerEffWeightMap(source.fTrigEffWeights); - if(source.fTrigEffWeightsB)SetTriggerEffWeightMapB(source.fTrigEffWeightsB); - - -} -//-------------------------------------------------------------------------- -AliHFAssociatedTrackCuts &AliHFAssociatedTrackCuts::operator=(const AliHFAssociatedTrackCuts &source) -{ - // - // assignment operator - // - if(&source == this) return *this; - - AliAnalysisCuts::operator=(source); - fESDTrackCuts=source.fESDTrackCuts; - fPidObj=source.fPidObj; - fEffWeights=source.fEffWeights; - fTrigEffWeightsvspt=source.fTrigEffWeightsvspt; - fTrigEffWeightsvsptB=source.fTrigEffWeightsvsptB; - fTrigEffWeights=source.fTrigEffWeights; - fTrigEffWeightsB=source.fTrigEffWeightsB; - fNTrackCuts=source.fNTrackCuts; - fAODTrackCuts=source.fAODTrackCuts; - fTrackCutsNames=source.fTrackCutsNames; - fNvZeroCuts=source.fNvZeroCuts; - fAODvZeroCuts=source.fAODvZeroCuts; - fvZeroCutsNames=source.fvZeroCutsNames; - fBit=source.fBit; - fCharge=source.fCharge; - - return *this; - -} - - -//-------------------------------------------------------------------------- -AliHFAssociatedTrackCuts::~AliHFAssociatedTrackCuts() -{ - if(fESDTrackCuts) {delete fESDTrackCuts; fESDTrackCuts = 0;} - if(fPidObj) {delete fPidObj; fPidObj = 0;} - if(fEffWeights){delete fEffWeights;fEffWeights=0;} - if(fTrigEffWeightsvspt){delete fTrigEffWeightsvspt;fTrigEffWeightsvspt=0;} - if(fTrigEffWeightsvsptB){delete fTrigEffWeightsvsptB;fTrigEffWeightsvsptB=0;} - if(fTrigEffWeights){delete fTrigEffWeights;fTrigEffWeights=0;} - if(fTrigEffWeightsB){delete fTrigEffWeightsB;fTrigEffWeightsB=0;} - if(fZvtxBins) {delete[] fZvtxBins; fZvtxBins=0;} - if(fCentBins) {delete[] fCentBins; fCentBins=0;} - if(fAODTrackCuts) {delete[] fAODTrackCuts; fAODTrackCuts=0;} - if(fTrackCutsNames) {delete[] fTrackCutsNames; fTrackCutsNames=0;} - if(fAODvZeroCuts){delete[] fAODvZeroCuts; fAODvZeroCuts=0;} - if(fvZeroCutsNames) {delete[] fvZeroCutsNames; fvZeroCutsNames=0;} - - -} -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::IsInAcceptance() -{ - printf("Careful: method AliHFAssociatedTrackCuts::IsInAcceptance is not implemented yet \n"); - return kFALSE; -} -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary, Double_t magfield) -{ - - AliESDtrack esdtrack(track); - if(primary){// needed to calculate impact parameters - // needed to calculate the impact parameters - esdtrack.RelateToVertex(primary,magfield,3.); - } - // set the TPC cluster info - esdtrack.SetTPCClusterMap(track->GetTPCClusterMap()); - esdtrack.SetTPCSharedMap(track->GetTPCSharedMap()); - esdtrack.SetTPCPointsF(track->GetTPCNclsF()); - - if(!fESDTrackCuts->IsSelected(&esdtrack)) return kFALSE; - - if(fBit>-1 && !track->TestFilterBit(fBit)) return kFALSE; // check the filter bit - - return kTRUE; - -} - -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::CheckHadronKinematic(Double_t pt, Double_t d0) -{ - - - - if(pt < fAODTrackCuts[0]) return kFALSE; - if(pt > fAODTrackCuts[1]) return kFALSE; - if(d0 < fAODTrackCuts[2]) return kFALSE; - if(d0 > fAODTrackCuts[3]) return kFALSE; - - return kTRUE; - - -} -//-------------------------------------------------------------------------- - -Bool_t AliHFAssociatedTrackCuts::Charge(Short_t charge, AliAODTrack* track) -{// charge is the charge to compare to (for example, a daughter of a D meson) - - if(!fCharge) return kTRUE; // if fCharge is set to 0 (no selection on the charge), returns always true - if(track->Charge()!= fCharge*charge) return kFALSE; - return kTRUE; -} - -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::CheckKaonCompatibility(AliAODTrack * track, Bool_t useMc, TClonesArray* mcArray, Int_t method) -{ - Bool_t isKaon = kFALSE; - - if(useMc) { // on MC - Int_t hadLabel = track->GetLabel(); - if(hadLabel < 0) return kFALSE; - AliAODMCParticle* hadron = dynamic_cast(mcArray->At(hadLabel)); - if(hadron){ - Int_t pdg = TMath::Abs(hadron->GetPdgCode()); - if (pdg == 321) isKaon = kTRUE; - } - } - - if(!useMc) { // on DATA - switch(method) { - case(1): { - Bool_t isKTPC=kFALSE; - Bool_t isPiTPC=kFALSE; - Bool_t isPTPC=kFALSE; - Bool_t isKTOF=kFALSE; - Bool_t isPiTOF=kFALSE; - Bool_t isPTOF=kFALSE; - - Bool_t KaonHyp = kFALSE; - Bool_t PionHyp = kFALSE; - Bool_t ProtonHyp = kFALSE; - - if(fPidObj->CheckStatus(track,"TOF")) { - isKTOF=fPidObj->IsKaonRaw(track,"TOF"); - isPiTOF=fPidObj->IsPionRaw(track,"TOF"); - isPTOF=fPidObj->IsProtonRaw(track,"TOF"); - } - if(fPidObj->CheckStatus(track,"TPC")){ - isKTPC=fPidObj->IsKaonRaw(track,"TPC"); - isPiTPC=fPidObj->IsPionRaw(track,"TPC"); - isPTPC=fPidObj->IsProtonRaw(track,"TPC"); - } - - if (isKTOF && isKTPC) KaonHyp = kTRUE; - if (isPiTOF && isPiTPC) PionHyp = kTRUE; - if (isPTOF && isPTPC) ProtonHyp = kTRUE; - - if(KaonHyp && !PionHyp && !ProtonHyp) isKaon = kTRUE; - break; - } - case(2): { - if(fPidObj->MakeRawPid(track,3)>=1) isKaon = kTRUE; - break; - } - } - } - - return isKaon; - -} -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::IsKZeroSelected(AliAODv0 *vzero, AliAODVertex *vtx1) -{ - - if(vzero->DcaV0Daughters()>fAODvZeroCuts[0]) return kFALSE; - if(vzero->Chi2V0()>fAODvZeroCuts[1]) return kFALSE; - if(vzero->DecayLength(vtx1) < fAODvZeroCuts[2]) return kFALSE; - if(vzero->DecayLength(vtx1) > fAODvZeroCuts[3]) return kFALSE; - if(vzero->OpenAngleV0() > fAODvZeroCuts[4]) return kFALSE; - if(vzero->Pt() < fAODvZeroCuts[5]) return kFALSE; - if(TMath::Abs(vzero->Eta()) > fAODvZeroCuts[6]) return kFALSE; - - - return kTRUE; -} -//-------------------------------------------------------------------------- -Bool_t *AliHFAssociatedTrackCuts::IsMCpartFromHF(Int_t label, TClonesArray*mcArray){ - // Check origin in MC - - AliAODMCParticle* mcParticle; - Int_t pdgCode = -1; - - Bool_t isCharmy = kFALSE; - Bool_t isBeauty = kFALSE; - Bool_t isD = kFALSE; - Bool_t isB = kFALSE; - - Bool_t *originvect = new Bool_t[4]; - - originvect[0] = kFALSE; - originvect[1] = kFALSE; - originvect[2] = kFALSE; - originvect[3] = kFALSE; - - if (label<0) return originvect; - - while(pdgCode!=2212){ // loops back to the collision to check the particle source - - mcParticle = dynamic_cast(mcArray->At(label)); - if(!mcParticle) {AliError("NO MC PARTICLE"); break;} - pdgCode = TMath::Abs(mcParticle->GetPdgCode()); - - label = mcParticle->GetMother(); - - - if((pdgCode>=400 && pdgCode <500) || (pdgCode>=4000 && pdgCode<5000 )) isD = kTRUE; - if((pdgCode>=500 && pdgCode <600) || (pdgCode>=5000 && pdgCode<6000 )) {isD = kFALSE; isB = kTRUE;} - - - if(pdgCode == 4) isCharmy = kTRUE; - if(pdgCode == 5) {isBeauty = kTRUE; isCharmy = kFALSE;} - if(label<0) break; - - } - - - originvect[0] = isCharmy; - originvect[1] = isBeauty; - originvect[2] = isD; - originvect[3] = isB; - - - return originvect; -} - -//-------------------------------------------------------------------------- -Bool_t AliHFAssociatedTrackCuts::InvMassDstarRejection(AliAODRecoDecayHF2Prong* d, AliAODTrack *track, Int_t hypD0) const { - // - // Calculates invmass of track+D0 and rejects if compatible with D* - // (to remove pions from D*) - // - Double_t nsigma = 3.; - - Double_t mD0, mD0bar; - d->InvMassD0(mD0,mD0bar); - - Double_t invmassDstar1 = 0, invmassDstar2 = 0; - Double_t e1Pi = d->EProng(0,211), e2K = d->EProng(1,321); //hyp 1 (pi,K) - D0 - Double_t e1K = d->EProng(0,321), e2Pi = d->EProng(1,211); //hyp 2 (K,pi) - D0bar - Double_t psum2 = (d->Px()+track->Px())*(d->Px()+track->Px()) - +(d->Py()+track->Py())*(d->Py()+track->Py()) - +(d->Pz()+track->Pz())*(d->Pz()+track->Pz()); - - switch(hypD0) { - case 1: - invmassDstar1 = TMath::Sqrt(pow(e1Pi+e2K+track->E(0.1396),2.)-psum2); - if ((TMath::Abs(invmassDstar1-mD0)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; - break; - case 2: - invmassDstar2 = TMath::Sqrt(pow(e2Pi+e1K+track->E(0.1396),2.)-psum2); - if ((TMath::Abs(invmassDstar2-mD0bar)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; - break; - case 3: - invmassDstar1 = TMath::Sqrt(pow(e1Pi+e2K+track->E(0.1396),2.)-psum2); - invmassDstar2 = TMath::Sqrt(pow(e2Pi+e1K+track->E(0.1396),2.)-psum2); - if ((TMath::Abs(invmassDstar1-mD0)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; - if ((TMath::Abs(invmassDstar2-mD0bar)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; - break; - } - - return kTRUE; -} -//________________________________________________________ -void AliHFAssociatedTrackCuts::SetMCEventTypes(Int_t *MCEventTypeArray) -// set the array of event types you want to process in MonteCarlo (gluon splitting, pair production etc.) -{ - if(!fMCEventType) fMCEventType = new Int_t[fNofMCEventType]; - - for(Int_t k=0; kGetOldPid()==kFALSE && fPidObj->GetPidResponse()==0x0){ - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler(); - AliPIDResponse *pidResp=inputHandler->GetPIDResponse(); - fPidObj->SetPidResponse(pidResp); - } -} -//-------------------------------------------------------------------------- - -void AliHFAssociatedTrackCuts::Print(Option_t *option) const -{ - /// overloaded from TObject: print info - if (strcmp(option, "parameters")==0) { - PrintPoolParameters(); - return; - } else if (strcmp(option, "selectedMC")==0) { - PrintSelectedMCevents(); - return; - } - PrintAll(); -} - -//-------------------------------------------------------------------------- -Int_t AliHFAssociatedTrackCuts::GetPoolBin(Double_t multorcent, Double_t zVtx) const -{ - - Int_t poolbin = -1; - Int_t centbin = -1; - Int_t zvtxbin = -1; - - - if(multorcent GetRequireITSRefit() ? "Yes" : "No"); - printf("TPC Refit........................................: %s\n",fESDTrackCuts->GetRequireTPCRefit() ? "Yes" : "No"); - printf("ITS SA...........................................: %s\n",fESDTrackCuts->GetRequireITSStandAlone() ? "Yes" : "No"); - printf("TPC SA...........................................: %s\n",fESDTrackCuts->GetRequireTPCStandAlone() ? "Yes" : "No"); - printf("Min number of ITS clusters.......................: %d\n",fESDTrackCuts->GetMinNClustersITS()); - printf("Min number of TPC clusters.......................: %d\n",fESDTrackCuts->GetMinNClusterTPC()); - Int_t spd = fESDTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD); - if(spd==0) std::cout << "SPD..............................................: kOff" << std::endl; - if(spd==1) std::cout << "SPD..............................................: kNone" << std::endl; - if(spd==2) std::cout << "SPD..............................................: kAny" << std::endl; - if(spd==3) std::cout << "SPD..............................................: kFirst" << std::endl; - if(spd==4) std::cout << "SPD..............................................: kOnlyFirst" << std::endl; - if(spd==5) std::cout << "SPD..............................................: kSecond" << std::endl; - if(spd==6) std::cout << "SPD..............................................: kOnlySecond" << std::endl; - if(spd==7) std::cout << "SPD..............................................: kBoth" << std::endl; - } - else printf("\nNo Cuts for Associated Tracks\n"); - std::cout << "Filter Bit.......................................: " << fBit << std::endl; - std::cout << "Charge...........................................: " << fCharge << std::endl; - - if(fAODTrackCuts){ - for(Int_t j=0;jFindBin(pt,eta,zvtx); - if(fEffWeights->IsBinUnderflow(bin)||fEffWeights->IsBinOverflow(bin))return 1.; - return fEffWeights->GetBinContent(bin); - -} - - -//-------------------------------------------------------------------------- -Double_t AliHFAssociatedTrackCuts::GetTrigWeight(Double_t pt, Double_t mult){ - - - - if(fTrigEffWeightsvspt){ - Int_t bin=fTrigEffWeightsvspt->FindBin(pt); - if(fTrigEffWeightsvspt->IsBinUnderflow(bin)||fTrigEffWeightsvspt->IsBinOverflow(bin))return 1.; - return fTrigEffWeightsvspt->GetBinContent(bin); - - } - - if(fTrigEffWeights){ - Int_t bin=fTrigEffWeights->FindBin(pt,mult); - if(fTrigEffWeights->IsBinUnderflow(bin)||fTrigEffWeights->IsBinOverflow(bin))return 1.; - return fTrigEffWeights->GetBinContent(bin); - - } - - //if(!fTrigEffWeights && !fTrigEffWeightsvspt)return 1.; - - return 1.; - -} - -//-------------------------------------------------------------------------- -Double_t AliHFAssociatedTrackCuts::GetTrigWeightB(Double_t pt, Double_t mult){ - - if(fTrigEffWeightsvsptB){ - Int_t bin=fTrigEffWeightsvsptB->FindBin(pt); - if(fTrigEffWeightsvsptB->IsBinUnderflow(bin)||fTrigEffWeightsvsptB->IsBinOverflow(bin))return 1.; - return fTrigEffWeightsvsptB->GetBinContent(bin); - - } - - if(fTrigEffWeightsB){ - Int_t bin=fTrigEffWeightsB->FindBin(pt,mult); - if(fTrigEffWeightsB->IsBinUnderflow(bin)||fTrigEffWeightsB->IsBinOverflow(bin))return 1.; - return fTrigEffWeightsB->GetBinContent(bin); - - } - - // if(!fTrigEffWeightsB && !fTrigEffWeightsvsptB)return 1.; - return 1; -} -//-------------------------------------------------------------------------- -void AliHFAssociatedTrackCuts::PrintSelectedMCevents() const -{ - printf("\n================================================="); - - printf("\nSelected MC events: \n \n"); - printf("Number of selected events: %d\n",fNofMCEventType); - - for(Int_t k=0; k Flavour excitation \n"); - if(fMCEventType[k]==53) printf("=> Pair creation \n"); - if(fMCEventType[k]==68) printf("=> Gluon splitting \n"); - } - - printf("\n"); - for(Int_t k=0; k +#include "AliHFAssociatedTrackCuts.h" +#include "AliAODPidHF.h" +#include "AliESDtrackCuts.h" +#include "AliESDtrack.h" +#include "AliESDVertex.h" +#include "AliAODv0.h" +#include "AliAODVertex.h" +#include "AliAODMCParticle.h" +#include "AliAnalysisManager.h" +#include "AliInputEventHandler.h" +#include "TString.h" + +using std::cout; +using std::endl; + +ClassImp(AliHFAssociatedTrackCuts) + +//-------------------------------------------------------------------------- +AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(): +AliAnalysisCuts(), +fESDTrackCuts(0), +fPidObj(0), + fEffWeights(0), + +fTrigEffWeightsvspt(0), +fTrigEffWeightsvsptB(0), +fTrigEffWeights(0), +fTrigEffWeightsB(0), +fPoolMaxNEvents(0), +fPoolMinNTracks(0), +fMinEventsToMix(0), +fNzVtxBins(0), +fNzVtxBinsDim(0), +fZvtxBins(0), +fNCentBins(0), +fNCentBinsDim(0), +fCentBins(0), + +fNofMCEventType(0), +fMCEventType(0), + +fNTrackCuts(0), +fAODTrackCuts(0), +fTrackCutsNames(0), +fNvZeroCuts(0), +fAODvZeroCuts(0), +fvZeroCutsNames(0), +fBit(-1), +fCharge(0), +fDescription("") + +{ + // + //default constructor + // + // + //default constructor + // + +} + +//-------------------------------------------------------------------------- +AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(const char* name, const char* title): +AliAnalysisCuts(name,title), +fESDTrackCuts(0), +fPidObj(0), +fEffWeights(0), +fTrigEffWeightsvspt(0), +fTrigEffWeightsvsptB(0), +fTrigEffWeights(0), +fTrigEffWeightsB(0), +fPoolMaxNEvents(0), +fPoolMinNTracks(0), +fMinEventsToMix(0), +fNzVtxBins(0), +fNzVtxBinsDim(0), +fZvtxBins(0), +fNCentBins(0), +fNCentBinsDim(0), +fCentBins(0), + +fNofMCEventType(0), +fMCEventType(0), + +fNTrackCuts(0), +fAODTrackCuts(0), +fTrackCutsNames(0), +fNvZeroCuts(0), +fAODvZeroCuts(0), +fvZeroCutsNames(0), +fBit(-1), +fCharge(0), +fDescription("") + +{ + // + //default constructor + // + +} +//-------------------------------------------------------------------------- +AliHFAssociatedTrackCuts::AliHFAssociatedTrackCuts(const AliHFAssociatedTrackCuts &source) : +AliAnalysisCuts(source), +fESDTrackCuts(source.fESDTrackCuts), +fPidObj(source.fPidObj), +fEffWeights(source.fEffWeights), +fTrigEffWeightsvspt(source.fTrigEffWeightsvspt), +fTrigEffWeightsvsptB(source.fTrigEffWeightsvsptB), +fTrigEffWeights(source.fTrigEffWeights), +fTrigEffWeightsB(source.fTrigEffWeightsB), + +fPoolMaxNEvents(source.fPoolMaxNEvents), +fPoolMinNTracks(source.fPoolMinNTracks), +fMinEventsToMix(source.fMinEventsToMix), +fNzVtxBins(source.fNzVtxBins), +fNzVtxBinsDim(source.fNzVtxBinsDim), +fZvtxBins(source.fZvtxBins), +fNCentBins(source.fNCentBins), +fNCentBinsDim(source.fNCentBinsDim), +fCentBins(source.fCentBins), + +fNofMCEventType(source.fNofMCEventType), +fMCEventType(source.fMCEventType), + +fNTrackCuts(source.fNTrackCuts), +fAODTrackCuts(source.fAODTrackCuts), +fTrackCutsNames(source.fTrackCutsNames), +fNvZeroCuts(source.fNvZeroCuts), +fAODvZeroCuts(source.fAODvZeroCuts), +fvZeroCutsNames(source.fvZeroCutsNames), +fBit(source.fBit), +fCharge(source.fCharge), +fDescription(source.fDescription) +{ + // + // copy constructor + // + + + AliInfo("AliHFAssociatedTrackCuts::Copy constructor "); + if(source.fESDTrackCuts) AddTrackCuts(source.fESDTrackCuts); + if(source.fAODTrackCuts) SetAODTrackCuts(source.fAODTrackCuts); + if(source.fAODvZeroCuts) SetAODvZeroCuts(source.fAODvZeroCuts); + if(source.fPidObj) SetPidHF(source.fPidObj); + if(source.fEffWeights) SetEfficiencyWeightMap(source.fEffWeights); + if(source.fTrigEffWeightsvspt) SetTriggerEffWeightMapvspt(source.fTrigEffWeightsvspt); + if(source.fTrigEffWeightsvsptB) SetTriggerEffWeightMapvsptB(source.fTrigEffWeightsvsptB); + if(source.fTrigEffWeights) SetTriggerEffWeightMap(source.fTrigEffWeights); + if(source.fTrigEffWeightsB)SetTriggerEffWeightMapB(source.fTrigEffWeightsB); + + +} +//-------------------------------------------------------------------------- +AliHFAssociatedTrackCuts &AliHFAssociatedTrackCuts::operator=(const AliHFAssociatedTrackCuts &source) +{ + // + // assignment operator + // + if(&source == this) return *this; + + AliAnalysisCuts::operator=(source); + fESDTrackCuts=source.fESDTrackCuts; + fPidObj=source.fPidObj; + fEffWeights=source.fEffWeights; + fTrigEffWeightsvspt=source.fTrigEffWeightsvspt; + fTrigEffWeightsvsptB=source.fTrigEffWeightsvsptB; + fTrigEffWeights=source.fTrigEffWeights; + fTrigEffWeightsB=source.fTrigEffWeightsB; + fNTrackCuts=source.fNTrackCuts; + fAODTrackCuts=source.fAODTrackCuts; + fTrackCutsNames=source.fTrackCutsNames; + fNvZeroCuts=source.fNvZeroCuts; + fAODvZeroCuts=source.fAODvZeroCuts; + fvZeroCutsNames=source.fvZeroCutsNames; + fBit=source.fBit; + fCharge=source.fCharge; + + return *this; + +} + + +//-------------------------------------------------------------------------- +AliHFAssociatedTrackCuts::~AliHFAssociatedTrackCuts() +{ + if(fESDTrackCuts) {delete fESDTrackCuts; fESDTrackCuts = 0;} + if(fPidObj) {delete fPidObj; fPidObj = 0;} + if(fEffWeights){delete fEffWeights;fEffWeights=0;} + if(fTrigEffWeightsvspt){delete fTrigEffWeightsvspt;fTrigEffWeightsvspt=0;} + if(fTrigEffWeightsvsptB){delete fTrigEffWeightsvsptB;fTrigEffWeightsvsptB=0;} + if(fTrigEffWeights){delete fTrigEffWeights;fTrigEffWeights=0;} + if(fTrigEffWeightsB){delete fTrigEffWeightsB;fTrigEffWeightsB=0;} + if(fZvtxBins) {delete[] fZvtxBins; fZvtxBins=0;} + if(fCentBins) {delete[] fCentBins; fCentBins=0;} + if(fAODTrackCuts) {delete[] fAODTrackCuts; fAODTrackCuts=0;} + if(fTrackCutsNames) {delete[] fTrackCutsNames; fTrackCutsNames=0;} + if(fAODvZeroCuts){delete[] fAODvZeroCuts; fAODvZeroCuts=0;} + if(fvZeroCutsNames) {delete[] fvZeroCutsNames; fvZeroCutsNames=0;} + + +} +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::IsInAcceptance() +{ + printf("Careful: method AliHFAssociatedTrackCuts::IsInAcceptance is not implemented yet \n"); + return kFALSE; +} +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary, Double_t magfield) +{ + + AliESDtrack esdtrack(track); + if(primary){// needed to calculate impact parameters + // needed to calculate the impact parameters + esdtrack.RelateToVertex(primary,magfield,3.); + } + // set the TPC cluster info + esdtrack.SetTPCClusterMap(track->GetTPCClusterMap()); + esdtrack.SetTPCSharedMap(track->GetTPCSharedMap()); + esdtrack.SetTPCPointsF(track->GetTPCNclsF()); + + if(!fESDTrackCuts->IsSelected(&esdtrack)) return kFALSE; + + if(fBit>-1 && !track->TestFilterBit(fBit)) return kFALSE; // check the filter bit + + return kTRUE; + +} + +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::CheckHadronKinematic(Double_t pt, Double_t d0) +{ + + + + if(pt < fAODTrackCuts[0]) return kFALSE; + if(pt > fAODTrackCuts[1]) return kFALSE; + if(d0 < fAODTrackCuts[2]) return kFALSE; + if(d0 > fAODTrackCuts[3]) return kFALSE; + + return kTRUE; + + +} +//-------------------------------------------------------------------------- + +Bool_t AliHFAssociatedTrackCuts::Charge(Short_t charge, AliAODTrack* track) +{// charge is the charge to compare to (for example, a daughter of a D meson) + + if(!fCharge) return kTRUE; // if fCharge is set to 0 (no selection on the charge), returns always true + if(track->Charge()!= fCharge*charge) return kFALSE; + return kTRUE; +} + +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::CheckKaonCompatibility(AliAODTrack * track, Bool_t useMc, TClonesArray* mcArray, Int_t method) +{ + Bool_t isKaon = kFALSE; + + if(useMc) { // on MC + Int_t hadLabel = track->GetLabel(); + if(hadLabel < 0) return kFALSE; + AliAODMCParticle* hadron = dynamic_cast(mcArray->At(hadLabel)); + if(hadron){ + Int_t pdg = TMath::Abs(hadron->GetPdgCode()); + if (pdg == 321) isKaon = kTRUE; + } + } + + if(!useMc) { // on DATA + switch(method) { + case(1): { + Bool_t isKTPC=kFALSE; + Bool_t isPiTPC=kFALSE; + Bool_t isPTPC=kFALSE; + Bool_t isKTOF=kFALSE; + Bool_t isPiTOF=kFALSE; + Bool_t isPTOF=kFALSE; + + Bool_t KaonHyp = kFALSE; + Bool_t PionHyp = kFALSE; + Bool_t ProtonHyp = kFALSE; + + if(fPidObj->CheckStatus(track,"TOF")) { + isKTOF=fPidObj->IsKaonRaw(track,"TOF"); + isPiTOF=fPidObj->IsPionRaw(track,"TOF"); + isPTOF=fPidObj->IsProtonRaw(track,"TOF"); + } + if(fPidObj->CheckStatus(track,"TPC")){ + isKTPC=fPidObj->IsKaonRaw(track,"TPC"); + isPiTPC=fPidObj->IsPionRaw(track,"TPC"); + isPTPC=fPidObj->IsProtonRaw(track,"TPC"); + } + + if (isKTOF && isKTPC) KaonHyp = kTRUE; + if (isPiTOF && isPiTPC) PionHyp = kTRUE; + if (isPTOF && isPTPC) ProtonHyp = kTRUE; + + if(KaonHyp && !PionHyp && !ProtonHyp) isKaon = kTRUE; + break; + } + case(2): { + if(fPidObj->MakeRawPid(track,3)>=1) isKaon = kTRUE; + break; + } + } + } + + return isKaon; + +} +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::IsKZeroSelected(AliAODv0 *vzero, AliAODVertex *vtx1) +{ + + if(vzero->DcaV0Daughters()>fAODvZeroCuts[0]) return kFALSE; + if(vzero->Chi2V0()>fAODvZeroCuts[1]) return kFALSE; + if(vzero->DecayLength(vtx1) < fAODvZeroCuts[2]) return kFALSE; + if(vzero->DecayLength(vtx1) > fAODvZeroCuts[3]) return kFALSE; + if(vzero->OpenAngleV0() > fAODvZeroCuts[4]) return kFALSE; + if(vzero->Pt() < fAODvZeroCuts[5]) return kFALSE; + if(TMath::Abs(vzero->Eta()) > fAODvZeroCuts[6]) return kFALSE; + + + return kTRUE; +} +//-------------------------------------------------------------------------- +Bool_t *AliHFAssociatedTrackCuts::IsMCpartFromHF(Int_t label, TClonesArray*mcArray){ + // Check origin in MC + + AliAODMCParticle* mcParticle; + Int_t pdgCode = -1; + + Bool_t isCharmy = kFALSE; + Bool_t isBeauty = kFALSE; + Bool_t isD = kFALSE; + Bool_t isB = kFALSE; + + Bool_t *originvect = new Bool_t[4]; + + originvect[0] = kFALSE; + originvect[1] = kFALSE; + originvect[2] = kFALSE; + originvect[3] = kFALSE; + + if (label<0) return originvect; + + while(pdgCode!=2212){ // loops back to the collision to check the particle source + + mcParticle = dynamic_cast(mcArray->At(label)); + if(!mcParticle) {AliError("NO MC PARTICLE"); break;} + pdgCode = TMath::Abs(mcParticle->GetPdgCode()); + + label = mcParticle->GetMother(); + + + if((pdgCode>=400 && pdgCode <500) || (pdgCode>=4000 && pdgCode<5000 )) isD = kTRUE; + if((pdgCode>=500 && pdgCode <600) || (pdgCode>=5000 && pdgCode<6000 )) {isD = kFALSE; isB = kTRUE;} + + + if(pdgCode == 4) isCharmy = kTRUE; + if(pdgCode == 5) {isBeauty = kTRUE; isCharmy = kFALSE;} + if(label<0) break; + + } + + + originvect[0] = isCharmy; + originvect[1] = isBeauty; + originvect[2] = isD; + originvect[3] = isB; + + + return originvect; +} + +//-------------------------------------------------------------------------- +Bool_t AliHFAssociatedTrackCuts::InvMassDstarRejection(AliAODRecoDecayHF2Prong* d, AliAODTrack *track, Int_t hypD0) const { + // + // Calculates invmass of track+D0 and rejects if compatible with D* + // (to remove pions from D*) + // + Double_t nsigma = 3.; + + Double_t mD0, mD0bar; + d->InvMassD0(mD0,mD0bar); + + Double_t invmassDstar1 = 0, invmassDstar2 = 0; + Double_t e1Pi = d->EProng(0,211), e2K = d->EProng(1,321); //hyp 1 (pi,K) - D0 + Double_t e1K = d->EProng(0,321), e2Pi = d->EProng(1,211); //hyp 2 (K,pi) - D0bar + Double_t psum2 = (d->Px()+track->Px())*(d->Px()+track->Px()) + +(d->Py()+track->Py())*(d->Py()+track->Py()) + +(d->Pz()+track->Pz())*(d->Pz()+track->Pz()); + + switch(hypD0) { + case 1: + invmassDstar1 = TMath::Sqrt(pow(e1Pi+e2K+track->E(0.1396),2.)-psum2); + if ((TMath::Abs(invmassDstar1-mD0)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; + break; + case 2: + invmassDstar2 = TMath::Sqrt(pow(e2Pi+e1K+track->E(0.1396),2.)-psum2); + if ((TMath::Abs(invmassDstar2-mD0bar)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; + break; + case 3: + invmassDstar1 = TMath::Sqrt(pow(e1Pi+e2K+track->E(0.1396),2.)-psum2); + invmassDstar2 = TMath::Sqrt(pow(e2Pi+e1K+track->E(0.1396),2.)-psum2); + if ((TMath::Abs(invmassDstar1-mD0)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; + if ((TMath::Abs(invmassDstar2-mD0bar)-0.14543) < nsigma*800.*pow(10.,-6.)) return kFALSE; + break; + } + + return kTRUE; +} +//________________________________________________________ +void AliHFAssociatedTrackCuts::SetMCEventTypes(Int_t *MCEventTypeArray) +// set the array of event types you want to process in MonteCarlo (gluon splitting, pair production etc.) +{ + if(!fMCEventType) fMCEventType = new Int_t[fNofMCEventType]; + + for(Int_t k=0; kGetOldPid()==kFALSE && fPidObj->GetPidResponse()==0x0){ + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler(); + AliPIDResponse *pidResp=inputHandler->GetPIDResponse(); + fPidObj->SetPidResponse(pidResp); + } +} +//-------------------------------------------------------------------------- + +void AliHFAssociatedTrackCuts::Print(Option_t *option) const +{ + /// overloaded from TObject: print info + if (strcmp(option, "parameters")==0) { + PrintPoolParameters(); + return; + } else if (strcmp(option, "selectedMC")==0) { + PrintSelectedMCevents(); + return; + } + PrintAll(); +} + +//-------------------------------------------------------------------------- +Int_t AliHFAssociatedTrackCuts::GetPoolBin(Double_t multorcent, Double_t zVtx) const +{ + + Int_t poolbin = -1; + Int_t centbin = -1; + Int_t zvtxbin = -1; + + + if(multorcent GetRequireITSRefit() ? "Yes" : "No"); + printf("TPC Refit........................................: %s\n",fESDTrackCuts->GetRequireTPCRefit() ? "Yes" : "No"); + printf("ITS SA...........................................: %s\n",fESDTrackCuts->GetRequireITSStandAlone() ? "Yes" : "No"); + printf("TPC SA...........................................: %s\n",fESDTrackCuts->GetRequireTPCStandAlone() ? "Yes" : "No"); + printf("Min number of ITS clusters.......................: %d\n",fESDTrackCuts->GetMinNClustersITS()); + printf("Min number of TPC clusters.......................: %d\n",fESDTrackCuts->GetMinNClusterTPC()); + Int_t spd = fESDTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD); + if(spd==0) std::cout << "SPD..............................................: kOff" << std::endl; + if(spd==1) std::cout << "SPD..............................................: kNone" << std::endl; + if(spd==2) std::cout << "SPD..............................................: kAny" << std::endl; + if(spd==3) std::cout << "SPD..............................................: kFirst" << std::endl; + if(spd==4) std::cout << "SPD..............................................: kOnlyFirst" << std::endl; + if(spd==5) std::cout << "SPD..............................................: kSecond" << std::endl; + if(spd==6) std::cout << "SPD..............................................: kOnlySecond" << std::endl; + if(spd==7) std::cout << "SPD..............................................: kBoth" << std::endl; + } + else printf("\nNo Cuts for Associated Tracks\n"); + std::cout << "Filter Bit.......................................: " << fBit << std::endl; + std::cout << "Charge...........................................: " << fCharge << std::endl; + + if(fAODTrackCuts){ + for(Int_t j=0;jFindBin(pt,eta,zvtx); + if(fEffWeights->IsBinUnderflow(bin)||fEffWeights->IsBinOverflow(bin))return 1.; + return fEffWeights->GetBinContent(bin); + +} + + +//-------------------------------------------------------------------------- +Double_t AliHFAssociatedTrackCuts::GetTrigWeight(Double_t pt, Double_t mult){ + + + + if(fTrigEffWeightsvspt){ + Int_t bin=fTrigEffWeightsvspt->FindBin(pt); + if(fTrigEffWeightsvspt->IsBinUnderflow(bin)||fTrigEffWeightsvspt->IsBinOverflow(bin))return 1.; + return fTrigEffWeightsvspt->GetBinContent(bin); + + } + + if(fTrigEffWeights){ + Int_t bin=fTrigEffWeights->FindBin(pt,mult); + if(fTrigEffWeights->IsBinUnderflow(bin)||fTrigEffWeights->IsBinOverflow(bin))return 1.; + return fTrigEffWeights->GetBinContent(bin); + + } + + //if(!fTrigEffWeights && !fTrigEffWeightsvspt)return 1.; + + return 1.; + +} + +//-------------------------------------------------------------------------- +Double_t AliHFAssociatedTrackCuts::GetTrigWeightB(Double_t pt, Double_t mult){ + + if(fTrigEffWeightsvsptB){ + Int_t bin=fTrigEffWeightsvsptB->FindBin(pt); + if(fTrigEffWeightsvsptB->IsBinUnderflow(bin)||fTrigEffWeightsvsptB->IsBinOverflow(bin))return 1.; + return fTrigEffWeightsvsptB->GetBinContent(bin); + + } + + if(fTrigEffWeightsB){ + Int_t bin=fTrigEffWeightsB->FindBin(pt,mult); + if(fTrigEffWeightsB->IsBinUnderflow(bin)||fTrigEffWeightsB->IsBinOverflow(bin))return 1.; + return fTrigEffWeightsB->GetBinContent(bin); + + } + + // if(!fTrigEffWeightsB && !fTrigEffWeightsvsptB)return 1.; + return 1; +} +//-------------------------------------------------------------------------- +void AliHFAssociatedTrackCuts::PrintSelectedMCevents() const +{ + printf("\n================================================="); + + printf("\nSelected MC events: \n \n"); + printf("Number of selected events: %d\n",fNofMCEventType); + + for(Int_t k=0; k Flavour excitation \n"); + if(fMCEventType[k]==53) printf("=> Pair creation \n"); + if(fMCEventType[k]==68) printf("=> Gluon splitting \n"); + } + + printf("\n"); + for(Int_t k=0; k -#include "AliAnalysisCuts.h" -#include "AliESDtrackCuts.h" -#include "AliESDVertex.h" -#include "AliAODPidHF.h" -#include "AliAODEvent.h" -#include "AliAODRecoDecayHF2Prong.h" -#include -#include - - -class AliAODTrack; -class AliAODEvent; - - -// -class AliHFAssociatedTrackCuts : public AliAnalysisCuts -{ - public: - AliHFAssociatedTrackCuts(); - AliHFAssociatedTrackCuts(const char* name, const char* title); - - - AliHFAssociatedTrackCuts(const AliHFAssociatedTrackCuts& source); - AliHFAssociatedTrackCuts& operator=(const AliHFAssociatedTrackCuts& source); - - virtual ~AliHFAssociatedTrackCuts(); // destructor - Bool_t IsSelected(TList* list) {if(list) return kTRUE; return kFALSE;}; - Bool_t IsSelected(TObject* obj) {if(obj) return kTRUE; return kFALSE;}; - Bool_t IsInAcceptance(); - Bool_t IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary=0x0, Double_t magfield=0); - Bool_t CheckHadronKinematic(Double_t pt, Double_t d0); - Bool_t Charge(Short_t charge, AliAODTrack* track); - Bool_t CheckKaonCompatibility(AliAODTrack * track, Bool_t useMc, TClonesArray* mcArray, Int_t method=1); - Bool_t IsKZeroSelected(AliAODv0 *vzero, AliAODVertex *vtx1); - Bool_t *IsMCpartFromHF(Int_t label, TClonesArray*mcArray); - Bool_t InvMassDstarRejection(AliAODRecoDecayHF2Prong* d, AliAODTrack *track, Int_t hypD0) const; - void SetPidAssociated(); - - // getters - AliESDtrackCuts * GetESDTrackCuts() const {return fESDTrackCuts;} - AliAODPidHF * GetPIDObject() const {return fPidObj;} - TH3D * GetEfficiencyWeight() const {return fEffWeights;} - - Int_t GetMaxNEventsInPool() const {return fPoolMaxNEvents;} - Int_t GetMinNTracksInPool() const {return fPoolMinNTracks;} - Int_t GetMinEventsToMix() const {return fMinEventsToMix;} - Int_t GetNZvtxPoolBins() const {return fNzVtxBins;} - Double_t *GetZvtxPoolBins() const {return fZvtxBins;} - Int_t GetNCentPoolBins() const {return fNCentBins;} - Double_t *GetCentPoolBins() const {return fCentBins;} - - Int_t GetNofMCEventType() const {return fNofMCEventType;} - Int_t *GetMCEventType() const {return fMCEventType;} - Int_t GetPoolBin(Double_t multorcent, Double_t zVtx) const; - - Int_t GetNTrackCuts() const {return fNTrackCuts;} - Float_t* GetAODTrackCuts() const {return fAODTrackCuts;} - TString * GetTrackCutNames() const {return fTrackCutsNames;} - Int_t GetNvZeroCuts() const {return fNvZeroCuts;} - Float_t * GetAODvZeroCuts() const {return fAODvZeroCuts;} - TString * GetvZeroCutNames() const {return fvZeroCutsNames;} - Int_t GetFilterBit() const {return fBit;} - Short_t GetCharge() const {return fCharge;} - TString GetDescription() const {return fDescription;} - - - - - - void AddTrackCuts(const AliESDtrackCuts *cuts) { - delete fESDTrackCuts; - fESDTrackCuts=new AliESDtrackCuts(*cuts); - return; - } - - void AddDescription(TString description){fDescription=description;} - - //setters - //event pool settings - void SetMaxNEventsInPool(Int_t events){fPoolMaxNEvents=events;} - void SetMinNTracksInPool(Int_t tracks){fPoolMinNTracks=tracks;} - void SetMinEventsToMix(Int_t events){fMinEventsToMix=events;} - - void SetNofPoolBins(Int_t Nzvtxbins, Int_t Ncentbins){ - fNzVtxBins=Nzvtxbins; - fNzVtxBinsDim=Nzvtxbins+1; - - fNCentBins=Ncentbins; - fNCentBinsDim=Ncentbins+1; - } - - void SetPoolBins(Double_t *ZvtxBins, Double_t* CentBins){ - fZvtxBins=ZvtxBins; - fCentBins=CentBins; - } - - // set MC events to process - - void SetNofMCEventTypes(Int_t k) {fNofMCEventType=k;} - void SetMCEventTypes(Int_t *MCEventTypeArray); - - //cut settings - void SetAODTrackCuts(Float_t *cutsarray); - void SetTrackCutsNames(/*TString *namearray*/); - void SetAODvZeroCuts(Float_t *cutsarray); - void SetvZeroCutsNames(/*TString *namearray*/); - void SetPidHF(AliAODPidHF* pid) {fPidObj = pid; return;} - void SetCharge(Short_t charge) {fCharge = charge;} - void SetFilterBit(Int_t bit) {fBit = bit;} - void SetEfficiencyWeightMap(TH3D *hMap){if(fEffWeights)delete fEffWeights;fEffWeights=(TH3D*)hMap->Clone();} - - void SetTriggerEffWeightMapvspt(TH1D* hTrigMap) {if(fTrigEffWeightsvspt) delete fTrigEffWeightsvspt; fTrigEffWeightsvspt=(TH1D*)hTrigMap->Clone();} - void SetTriggerEffWeightMapvsptB(TH1D* hTrigMapB) {if(fTrigEffWeightsvsptB) delete fTrigEffWeightsvsptB; fTrigEffWeightsvsptB=(TH1D*)hTrigMapB->Clone();} - - void SetTriggerEffWeightMap(TH2D* hTrigMap) {if(fTrigEffWeights) delete fTrigEffWeights; fTrigEffWeights=(TH2D*)hTrigMap->Clone();} - void SetTriggerEffWeightMapB(TH2D* hTrigMapB) {if(fTrigEffWeightsB) delete fTrigEffWeightsB; fTrigEffWeightsB=(TH2D*)hTrigMapB->Clone();} - - - Double_t GetTrackWeight(Double_t pt, Double_t eta,Double_t zvtx); - Double_t GetTrigWeight(Double_t pt, Double_t mult=0); - Double_t GetTrigWeightB(Double_t pt, Double_t mult=0); - - Bool_t IsTrackEffMap(){if(fEffWeights) return kTRUE; else return kFALSE;} - Bool_t IsTrigEffMap1D(){ if(fTrigEffWeightsvspt) return kTRUE; else return kFALSE;} - Bool_t IsTrigEffMap1DB(){ if(fTrigEffWeightsvsptB) return kTRUE; else return kFALSE;} - Bool_t IsTrigEffMap2D(){ if(fTrigEffWeights) return kTRUE; else return kFALSE;} - Bool_t IsTrigEffMap2DB(){ if(fTrigEffWeightsB) return kTRUE; else return kFALSE;} - - - void Print(Option_t *option) const; - virtual void PrintAll() const; - virtual void PrintPoolParameters() const; - virtual void PrintSelectedMCevents() const; - - - - - void SetNVarsTrack(Int_t nVars){fNTrackCuts=nVars;} - void SetNVarsVzero(Int_t nVars){fNvZeroCuts=nVars;} - - - -private: - AliESDtrackCuts *fESDTrackCuts; // track cut object - AliAODPidHF * fPidObj; /// PID object - TH3D *fEffWeights; // weight map (pt,eta,zvtx) to account for single track efficiency - TH1D *fTrigEffWeightsvspt; // weight map (pt,mult) to account for trigger efficiency (on data, from c) - TH1D *fTrigEffWeightsvsptB; // weight map (pt,mult) to account for trigger efficiency (from b) - TH2D *fTrigEffWeights; // weight map (pt,mult) to account for trigger efficiency (on data, from c) - TH2D *fTrigEffWeightsB; // weight map (pt,mult) to account for trigger efficiency (from b) - Int_t fPoolMaxNEvents; // set maximum number of events in the pool - Int_t fPoolMinNTracks; // se minimum number of tracks in the pool - Int_t fMinEventsToMix; // set the minimum number of events you wanna mix - - Int_t fNzVtxBins; // number of z vrtx bins - Int_t fNzVtxBinsDim; // number of z vrtx bins +1 : necessary to initialize correctly the array - Double_t* fZvtxBins; // [fNzVtxBinsDim] - - - Int_t fNCentBins; //number of centrality bins - Int_t fNCentBinsDim; //number of centrality bins bins +1 : necessary to initialize correctly the array - Double_t* fCentBins; // [fNCentBinsDim] - - Int_t fNofMCEventType;// number of event types to be selected in MC simultaneously; - Int_t *fMCEventType;//[fNofMCEventType] - - Int_t fNTrackCuts; // array dimension - Float_t* fAODTrackCuts;//[fNTrackCuts] - TString * fTrackCutsNames;//[fNTrackCuts] - Int_t fNvZeroCuts;// array dimension - Float_t *fAODvZeroCuts;//[fNvZeroCuts] - TString * fvZeroCutsNames;//[fNvZeroCuts] - Int_t fBit; // filterBit - Short_t fCharge; // charge (+1 or -1) - TString fDescription; // additional description to the cuts - - - ClassDef(AliHFAssociatedTrackCuts,6); -}; - - -#endif +#ifndef AliHFAssociatedTrackCuts_H +#define AliHFAssociatedTrackCuts_H +/************************************************************************** + * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +//////////////////////////////////////////////////////////////////////// +// +// Base class for cuts on Associated tracks for HF Correlation analysis +// +// Author: S.Bjelogrlic (Utrecht) sandro.bjelogrlic@cern.ch +//////////////////////////////////////////////////////////////////////// + +#include +#include "AliAnalysisCuts.h" +#include "AliESDtrackCuts.h" +#include "AliESDVertex.h" +#include "AliAODPidHF.h" +#include "AliAODEvent.h" +#include "AliAODRecoDecayHF2Prong.h" +#include +#include + + +class AliAODTrack; +class AliAODEvent; + + +// +class AliHFAssociatedTrackCuts : public AliAnalysisCuts +{ + public: + AliHFAssociatedTrackCuts(); + AliHFAssociatedTrackCuts(const char* name, const char* title); + + + AliHFAssociatedTrackCuts(const AliHFAssociatedTrackCuts& source); + AliHFAssociatedTrackCuts& operator=(const AliHFAssociatedTrackCuts& source); + + virtual ~AliHFAssociatedTrackCuts(); // destructor + Bool_t IsSelected(TList* list) {if(list) return kTRUE; return kFALSE;}; + Bool_t IsSelected(TObject* obj) {if(obj) return kTRUE; return kFALSE;}; + Bool_t IsInAcceptance(); + Bool_t IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary=0x0, Double_t magfield=0); + Bool_t CheckHadronKinematic(Double_t pt, Double_t d0); + Bool_t Charge(Short_t charge, AliAODTrack* track); + Bool_t CheckKaonCompatibility(AliAODTrack * track, Bool_t useMc, TClonesArray* mcArray, Int_t method=1); + Bool_t IsKZeroSelected(AliAODv0 *vzero, AliAODVertex *vtx1); + Bool_t *IsMCpartFromHF(Int_t label, TClonesArray*mcArray); + Bool_t InvMassDstarRejection(AliAODRecoDecayHF2Prong* d, AliAODTrack *track, Int_t hypD0) const; + void SetPidAssociated(); + + // getters + AliESDtrackCuts * GetESDTrackCuts() const {return fESDTrackCuts;} + AliAODPidHF * GetPIDObject() const {return fPidObj;} + TH3D * GetEfficiencyWeight() const {return fEffWeights;} + + Int_t GetMaxNEventsInPool() const {return fPoolMaxNEvents;} + Int_t GetMinNTracksInPool() const {return fPoolMinNTracks;} + Int_t GetMinEventsToMix() const {return fMinEventsToMix;} + Int_t GetNZvtxPoolBins() const {return fNzVtxBins;} + Double_t *GetZvtxPoolBins() const {return fZvtxBins;} + Int_t GetNCentPoolBins() const {return fNCentBins;} + Double_t *GetCentPoolBins() const {return fCentBins;} + + Int_t GetNofMCEventType() const {return fNofMCEventType;} + Int_t *GetMCEventType() const {return fMCEventType;} + Int_t GetPoolBin(Double_t multorcent, Double_t zVtx) const; + + Int_t GetNTrackCuts() const {return fNTrackCuts;} + Float_t* GetAODTrackCuts() const {return fAODTrackCuts;} + TString * GetTrackCutNames() const {return fTrackCutsNames;} + Int_t GetNvZeroCuts() const {return fNvZeroCuts;} + Float_t * GetAODvZeroCuts() const {return fAODvZeroCuts;} + TString * GetvZeroCutNames() const {return fvZeroCutsNames;} + Int_t GetFilterBit() const {return fBit;} + Short_t GetCharge() const {return fCharge;} + TString GetDescription() const {return fDescription;} + + + + + + void AddTrackCuts(const AliESDtrackCuts *cuts) { + delete fESDTrackCuts; + fESDTrackCuts=new AliESDtrackCuts(*cuts); + return; + } + + void AddDescription(TString description){fDescription=description;} + + //setters + //event pool settings + void SetMaxNEventsInPool(Int_t events){fPoolMaxNEvents=events;} + void SetMinNTracksInPool(Int_t tracks){fPoolMinNTracks=tracks;} + void SetMinEventsToMix(Int_t events){fMinEventsToMix=events;} + + void SetNofPoolBins(Int_t Nzvtxbins, Int_t Ncentbins){ + fNzVtxBins=Nzvtxbins; + fNzVtxBinsDim=Nzvtxbins+1; + + fNCentBins=Ncentbins; + fNCentBinsDim=Ncentbins+1; + } + + void SetPoolBins(Double_t *ZvtxBins, Double_t* CentBins){ + fZvtxBins=ZvtxBins; + fCentBins=CentBins; + } + + // set MC events to process + + void SetNofMCEventTypes(Int_t k) {fNofMCEventType=k;} + void SetMCEventTypes(Int_t *MCEventTypeArray); + + //cut settings + void SetAODTrackCuts(Float_t *cutsarray); + void SetTrackCutsNames(/*TString *namearray*/); + void SetAODvZeroCuts(Float_t *cutsarray); + void SetvZeroCutsNames(/*TString *namearray*/); + void SetPidHF(AliAODPidHF* pid) {fPidObj = pid; return;} + void SetCharge(Short_t charge) {fCharge = charge;} + void SetFilterBit(Int_t bit) {fBit = bit;} + void SetEfficiencyWeightMap(TH3D *hMap){if(fEffWeights)delete fEffWeights;fEffWeights=(TH3D*)hMap->Clone();} + + void SetTriggerEffWeightMapvspt(TH1D* hTrigMap) {if(fTrigEffWeightsvspt) delete fTrigEffWeightsvspt; fTrigEffWeightsvspt=(TH1D*)hTrigMap->Clone();} + void SetTriggerEffWeightMapvsptB(TH1D* hTrigMapB) {if(fTrigEffWeightsvsptB) delete fTrigEffWeightsvsptB; fTrigEffWeightsvsptB=(TH1D*)hTrigMapB->Clone();} + + void SetTriggerEffWeightMap(TH2D* hTrigMap) {if(fTrigEffWeights) delete fTrigEffWeights; fTrigEffWeights=(TH2D*)hTrigMap->Clone();} + void SetTriggerEffWeightMapB(TH2D* hTrigMapB) {if(fTrigEffWeightsB) delete fTrigEffWeightsB; fTrigEffWeightsB=(TH2D*)hTrigMapB->Clone();} + + + Double_t GetTrackWeight(Double_t pt, Double_t eta,Double_t zvtx); + Double_t GetTrigWeight(Double_t pt, Double_t mult=0); + Double_t GetTrigWeightB(Double_t pt, Double_t mult=0); + + Bool_t IsTrackEffMap(){if(fEffWeights) return kTRUE; else return kFALSE;} + Bool_t IsTrigEffMap1D(){ if(fTrigEffWeightsvspt) return kTRUE; else return kFALSE;} + Bool_t IsTrigEffMap1DB(){ if(fTrigEffWeightsvsptB) return kTRUE; else return kFALSE;} + Bool_t IsTrigEffMap2D(){ if(fTrigEffWeights) return kTRUE; else return kFALSE;} + Bool_t IsTrigEffMap2DB(){ if(fTrigEffWeightsB) return kTRUE; else return kFALSE;} + + + void Print(Option_t *option) const; + virtual void PrintAll() const; + virtual void PrintPoolParameters() const; + virtual void PrintSelectedMCevents() const; + + + + + void SetNVarsTrack(Int_t nVars){fNTrackCuts=nVars;} + void SetNVarsVzero(Int_t nVars){fNvZeroCuts=nVars;} + + + +private: + AliESDtrackCuts *fESDTrackCuts; // track cut object + AliAODPidHF * fPidObj; /// PID object + TH3D *fEffWeights; // weight map (pt,eta,zvtx) to account for single track efficiency + TH1D *fTrigEffWeightsvspt; // weight map (pt,mult) to account for trigger efficiency (on data, from c) + TH1D *fTrigEffWeightsvsptB; // weight map (pt,mult) to account for trigger efficiency (from b) + TH2D *fTrigEffWeights; // weight map (pt,mult) to account for trigger efficiency (on data, from c) + TH2D *fTrigEffWeightsB; // weight map (pt,mult) to account for trigger efficiency (from b) + Int_t fPoolMaxNEvents; // set maximum number of events in the pool + Int_t fPoolMinNTracks; // se minimum number of tracks in the pool + Int_t fMinEventsToMix; // set the minimum number of events you wanna mix + + Int_t fNzVtxBins; // number of z vrtx bins + Int_t fNzVtxBinsDim; // number of z vrtx bins +1 : necessary to initialize correctly the array + Double_t* fZvtxBins; // [fNzVtxBinsDim] + + + Int_t fNCentBins; //number of centrality bins + Int_t fNCentBinsDim; //number of centrality bins bins +1 : necessary to initialize correctly the array + Double_t* fCentBins; // [fNCentBinsDim] + + Int_t fNofMCEventType;// number of event types to be selected in MC simultaneously; + Int_t *fMCEventType;//[fNofMCEventType] + + Int_t fNTrackCuts; // array dimension + Float_t* fAODTrackCuts;//[fNTrackCuts] + TString * fTrackCutsNames;//[fNTrackCuts] + Int_t fNvZeroCuts;// array dimension + Float_t *fAODvZeroCuts;//[fNvZeroCuts] + TString * fvZeroCutsNames;//[fNvZeroCuts] + Int_t fBit; // filterBit + Short_t fCharge; // charge (+1 or -1) + TString fDescription; // additional description to the cuts + + + ClassDef(AliHFAssociatedTrackCuts,6); +}; + + +#endif diff --git a/PWGHF/correlationHF/AliHFCorrelator.cxx b/PWGHF/correlationHF/AliHFCorrelator.cxx index 7ff8fa6b8e9..7d2ea38dfa7 100644 --- a/PWGHF/correlationHF/AliHFCorrelator.cxx +++ b/PWGHF/correlationHF/AliHFCorrelator.cxx @@ -1,522 +1,522 @@ -/************************************************************************** - * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ -// -// -// Base class for Heavy Flavour Correlations Analysis -// Single Event and Mixed Event Analysis are implemented -// -//----------------------------------------------------------------------- -// -// -// Author S.Bjelogrlic -// Utrecht University -// sandro.bjelogrlic@cern.ch -// -//----------------------------------------------------------------------- - -/* $Id$ */ - -#include -#include -#include -#include "TROOT.h" -#include "AliHFCorrelator.h" -#include "AliRDHFCutsDStartoKpipi.h" -#include "AliHFAssociatedTrackCuts.h" -#include "AliEventPoolManager.h" -#include "AliReducedParticle.h" -#include "AliCentrality.h" -#include "AliAODMCParticle.h" - -using std::cout; -using std::endl; - -//_____________________________________________________ -AliHFCorrelator::AliHFCorrelator() : -// -// default constructor -// -TNamed(), -fPoolMgr(0x0), -fPool(0x0), -fhadcuts(0x0), -fAODEvent(0x0), -fAssociatedTracks(0x0), -fmcArray(0x0), -fReducedPart(0x0), -fD0cand(0x0), -fhypD0(0), -fDCharge(0), - -fmixing(kFALSE), -fmontecarlo(kFALSE), -fsystem(kFALSE), -fUseReco(kTRUE), -fselect(kUndefined), - -fUseImpactParameter(0), -fPIDmode(0), - -fNofTracks(0), -fPoolContent(0), - -fPhiMin(0), -fPhiMax(0), - -fPtTrigger(0), -fPhiTrigger(0), -fEtaTrigger(0), - - -fDeltaPhi(0), -fDeltaEta(0), -fk0InvMass(0) - -{ - // default constructor -} - - - -//_____________________________________________________ -AliHFCorrelator::AliHFCorrelator(const Char_t* name, AliHFAssociatedTrackCuts *cuts, Bool_t ppOrPbPb) : -TNamed(name,"title"), -fPoolMgr(0x0), -fPool(0x0), -fhadcuts(0x0), -fAODEvent(0x0), -fAssociatedTracks(0x0), -fmcArray(0x0), -fReducedPart(0x0), -fD0cand(0x0), -fhypD0(0), -fDCharge(0), - -fmixing(kFALSE), -fmontecarlo(kFALSE), -fsystem(ppOrPbPb), -fUseReco(kTRUE), -fselect(kUndefined), -fUseImpactParameter(0), -fPIDmode(0), - -fNofTracks(0), -fPoolContent(0), - -fPhiMin(0), -fPhiMax(0), - -fPtTrigger(0), -fPhiTrigger(0), -fEtaTrigger(0), - - -fDeltaPhi(0), -fDeltaEta(0), -fk0InvMass(0) -{ - fhadcuts = cuts; -} - -//_____________________________________________________ -AliHFCorrelator::~AliHFCorrelator() -{ -// -// destructor -// - - if(fPoolMgr) {delete fPoolMgr; fPoolMgr=0;} - if(fPool) {delete fPool; fPool=0;} - if(fhadcuts) {delete fhadcuts; fhadcuts=0;} - if(fAODEvent) {delete fAODEvent; fAODEvent=0;} - if(fAssociatedTracks) {delete fAssociatedTracks; fAssociatedTracks=0;} - if(fmcArray) {delete fmcArray; fmcArray=0;} - if(fReducedPart) {delete fReducedPart; fReducedPart=0;} - if(fD0cand) {delete fD0cand; fD0cand=0;} - - - if(fNofTracks) fNofTracks = 0; - - if(fPhiMin) fPhiMin = 0; - if(fPhiMax) fPhiMax = 0; - - if(fPtTrigger) fPtTrigger=0; - if(fPhiTrigger) fPhiTrigger=0; - if(fEtaTrigger) fEtaTrigger=0; - - if(fDeltaPhi) fDeltaPhi=0; - if(fDeltaEta) fDeltaEta=0; - - if(fk0InvMass) fk0InvMass=0; - -} -//_____________________________________________________ -Bool_t AliHFCorrelator::DefineEventPool(){ - // definition of the Pool Manager for Event Mixing - - - Int_t MaxNofEvents = fhadcuts->GetMaxNEventsInPool(); - Int_t MinNofTracks = fhadcuts->GetMinNTracksInPool(); - Int_t NofCentBins = fhadcuts->GetNCentPoolBins(); - Double_t * CentBins = fhadcuts->GetCentPoolBins(); - Int_t NofZVrtxBins = fhadcuts->GetNZvtxPoolBins(); - Double_t *ZVrtxBins = fhadcuts->GetZvtxPoolBins(); - - - fPoolMgr = new AliEventPoolManager(MaxNofEvents, MinNofTracks, NofCentBins, CentBins, NofZVrtxBins, ZVrtxBins); - if(!fPoolMgr) return kFALSE; - return kTRUE; -} -//_____________________________________________________ -Bool_t AliHFCorrelator::Initialize(){ - - // std::cout << "AliHFCorrelator::Initialize"<< std::endl; -// AliInfo("AliHFCorrelator::Initialize") ; - if(!fAODEvent){ - AliInfo("No AOD event") ; - return kFALSE; - } - //std::cout << "No AOD event" << std::endl; - - AliCentrality *centralityObj = 0; - //Int_t multiplicity = -1; - Double_t MultipOrCent = -1; - - // initialize the pool for event mixing - if(!fsystem){ // pp - //multiplicity = fAODEvent->GetNTracks(); - MultipOrCent = AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(fAODEvent,-1.,1.); - // MultipOrCent = multiplicity; // convert from Int_t to Double_t - // AliInfo(Form("Multiplicity is %f", MultipOrCent)); - } - if(fsystem){ // PbPb - - centralityObj = fAODEvent->GetHeader()->GetCentralityP(); - MultipOrCent = centralityObj->GetCentralityPercentileUnchecked("V0M"); -// AliInfo(Form("Centrality is %f", MultipOrCent)); - } - - AliAODVertex *vtx = fAODEvent->GetPrimaryVertex(); - Double_t zvertex = vtx->GetZ(); // zvertex - Double_t * CentBins = fhadcuts->GetCentPoolBins(); - Double_t poolmin=CentBins[0]; - Double_t poolmax=CentBins[fhadcuts->GetNCentPoolBins()]; - - - if(TMath::Abs(zvertex)>=10 || MultipOrCent>poolmax || MultipOrCent < poolmin) { - if(!fsystem)AliInfo(Form("pp or pA Event with Zvertex = %.2f cm and multiplicity = %.0f out of pool bounds, SKIPPING",zvertex,MultipOrCent)); - if(fsystem) AliInfo(Form("PbPb Event with Zvertex = %.2f cm and centrality = %.1f out of pool bounds, SKIPPING",zvertex,MultipOrCent)); - - return kFALSE; - } - - fPool = fPoolMgr->GetEventPool(MultipOrCent, zvertex); - - if (!fPool){ - AliInfo(Form("No pool found for multiplicity = %f, zVtx = %f cm", MultipOrCent, zvertex)); - return kFALSE; - } - //fPool->PrintInfo(); - return kTRUE; -} - -//_____________________________________________________ -Bool_t AliHFCorrelator::ProcessEventPool(){ - // analysis on Mixed Events - //cout << "AliHFCorrelator::ProcessEventPool"<< endl; - if(!fmixing) return kFALSE; - if(!fPool->IsReady()) return kFALSE; - if(fPool->GetCurrentNEvents()GetMinEventsToMix()) return kFALSE; - // fPool->PrintInfo(); - fPoolContent = fPool->GetCurrentNEvents(); - - return kTRUE; - -} - -//_____________________________________________________ -Bool_t AliHFCorrelator::ProcessAssociatedTracks(Int_t EventLoopIndex, const TObjArray* associatedTracks){ - // associatedTracks is not deleted, it should be (if needed) deleted in the user task - - if(!fmixing){ // analysis on Single Event - if(fAssociatedTracks){ - fAssociatedTracks->Delete(); - delete fAssociatedTracks; - } - if(fselect==kHadron || fselect ==kKaon){ - fAssociatedTracks = AcceptAndReduceTracks(fAODEvent); - fAssociatedTracks->SetOwner(kTRUE); - } - if(fselect==kKZero) { - fAssociatedTracks = AcceptAndReduceKZero(fAODEvent); - fAssociatedTracks->SetOwner(kTRUE); - } - if(fselect==kElectron && associatedTracks) { - fAssociatedTracks=new TObjArray(*associatedTracks);// Maybe better to call the copy constructor - fAssociatedTracks->SetOwner(kFALSE); - } - - } - - if(fmixing) { // analysis on Mixed Events - - - fAssociatedTracks = fPool->GetEvent(EventLoopIndex); - - - - - } // end if mixing - - if(!fAssociatedTracks) return kFALSE; - - fNofTracks = fAssociatedTracks->GetEntriesFast(); - - return kTRUE; - -} -//_____________________________________________________ -Bool_t AliHFCorrelator::Correlate(Int_t loopindex){ - - if(loopindex >= fNofTracks) return kFALSE; - if(!fAssociatedTracks) return kFALSE; - - fReducedPart = (AliReducedParticle*)fAssociatedTracks->At(loopindex); - - - fDeltaPhi = SetCorrectPhiRange(fPhiTrigger - fReducedPart->Phi()); - - fDeltaEta = fEtaTrigger - fReducedPart->Eta(); - - return kTRUE; - -} - -//_____________________________________________________ -Bool_t AliHFCorrelator::PoolUpdate(const TObjArray* associatedTracks){ - - if(!fmixing) return kFALSE; - if(!fPool) return kFALSE; - if(fmixing) { // update the pool for Event Mixing - TObjArray* objArr = NULL; - if(fselect==kHadron || fselect==kKaon) objArr = (TObjArray*)AcceptAndReduceTracks(fAODEvent); - else if(fselect==kKZero) objArr = (TObjArray*)AcceptAndReduceKZero(fAODEvent); - else if(fselect==kElectron && associatedTracks){ - objArr = new TObjArray(*associatedTracks); - } - else return kFALSE; - if(objArr->GetEntriesFast()>0) fPool->UpdatePool(objArr); // updating the pool only if there are entries in the array - } - - return kTRUE; - -} - -//_____________________________________________________ -Double_t AliHFCorrelator::SetCorrectPhiRange(Double_t phi){ - Double_t pi = TMath::Pi(); - - if(phifPhiMax) phi = phi - 2*pi; - - return phi; -} - -//_____________________________________________________ -TObjArray* AliHFCorrelator::AcceptAndReduceTracks(AliAODEvent* inputEvent){ - - Double_t weight=1.; - Int_t nTracks = inputEvent->GetNTracks(); - AliAODVertex * vtx = inputEvent->GetPrimaryVertex(); - Double_t pos[3],cov[6]; - vtx->GetXYZ(pos); - vtx->GetCovarianceMatrix(cov); - const AliESDVertex vESD(pos,cov,100.,100); - - Double_t Bz = inputEvent->GetMagneticField(); - - - TObjArray* tracksClone = new TObjArray; - tracksClone->SetOwner(kTRUE); - - //******************************************************* - // use reconstruction - if(fUseReco){ - for (Int_t iTrack=0; iTrackGetTrack(iTrack); - if (!track) continue; - if(!fhadcuts->IsHadronSelected(track,&vESD,Bz)) continue; // apply ESD level selections - if(!fhadcuts->Charge(fDCharge,track)) continue; // apply selection on charge, if required - - Double_t pT = track->Pt(); - - //compute impact parameter - Double_t d0z0[2],covd0z0[3]; - Double_t d0=-999999.; - if(fUseImpactParameter) track->PropagateToDCA(vtx,Bz,100,d0z0,covd0z0); - else d0z0[0] = 1. ; // random number - be careful with the cuts you applied - - if(fUseImpactParameter==1) d0 = TMath::Abs(d0z0[0]); // use impact parameter - if(fUseImpactParameter==2) { // use impact parameter over resolution - if(TMath::Abs(covd0z0[0])>0.00000001) d0 = TMath::Abs(d0z0[0])/TMath::Sqrt(covd0z0[0]); - else d0 = -1.; // if the resoultion is Zero, rejects the track - to be on the safe side - - } - - if(fmontecarlo) {// THIS TO BE CHECKED - Int_t hadLabel = track->GetLabel(); - if(hadLabel < 0) continue; - } - - if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts - Bool_t rejectsoftpi = kTRUE;// TO BE CHECKED: DO WE WANT IT TO kTRUE AS A DEFAULT? - if(fD0cand && !fmixing) rejectsoftpi = fhadcuts->InvMassDstarRejection(fD0cand,track,fhypD0); // TO BE CHECKED: WHY NOT FOR EM? - - - if(fselect ==kKaon){ - if(!fhadcuts->CheckKaonCompatibility(track,fmontecarlo,fmcArray,fPIDmode)) continue; // check if it is a Kaon - data and MC - } - weight=fhadcuts->GetTrackWeight(pT,track->Eta(),pos[2]); - tracksClone->Add(new AliReducedParticle(track->Eta(), track->Phi(), pT,track->GetLabel(),track->GetID(),d0,rejectsoftpi,track->Charge(),weight)); - } // end loop on tracks - } // end if use reconstruction kTRUE - - //******************************************************* - - //use MC truth - if(fmontecarlo && !fUseReco){ - - for (Int_t iPart=0; iPartGetEntriesFast(); iPart++) { - AliAODMCParticle* mcPart = dynamic_cast(fmcArray->At(iPart)); - if (!mcPart) { - AliWarning("MC Particle not found in tree, skipping"); - continue; - } - if(!mcPart->Charge()) continue; // consider only charged tracks - - Int_t PDG =TMath::Abs(mcPart->PdgCode()); -if(fselect ==kHadron) {if(!((PDG==321)||(PDG==211)||(PDG==2212)||(PDG==13)||(PDG==11))) continue;} // select only if kaon, pion, proton, muon or electron - else if(fselect ==kKaon) {if(!(PDG==321)) continue;} // select only if kaon - else if(fselect ==kElectron) {if(!(PDG==11)) continue;} // select only if electron - - Double_t pT = mcPart->Pt(); - Double_t d0 =1; // set 1 fot the moment - no displacement calculation implemented yet - if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts - - tracksClone->Add(new AliReducedParticle(mcPart->Eta(), mcPart->Phi(), pT,iPart,-1,d0,kFALSE,mcPart->Charge())); - } - - } // end if use MC truth - - - return tracksClone; -} - -//_____________________________________________________ -TObjArray* AliHFCorrelator::AcceptAndReduceKZero(AliAODEvent* inputEvent){ - - Int_t nOfVZeros = inputEvent->GetNumberOfV0s(); - TObjArray* KZeroClone = new TObjArray; - AliAODVertex *vertex1 = (AliAODVertex*)inputEvent->GetPrimaryVertex(); - - // use reconstruction - if(fUseReco){ - Int_t v0label = -1; - Int_t pdgDgK0toPipi[2] = {211,211}; - Double_t mPDGK0=0.497614;//TDatabasePDG::Instance()->GetParticle(310)->Mass(); - const Int_t size = inputEvent->GetNumberOfV0s(); - Int_t prevnegID[size]; - Int_t prevposID[size]; - for(Int_t iv0 =0; iv0< nOfVZeros; iv0++){// loop on all v0 candidates - AliAODv0 *v0 = (static_cast (inputEvent))->GetV0(iv0); - if(!v0) { - AliInfo(Form("is not a v0 at step, %d", iv0)) ; - //cout << "is not a v0 at step " << iv0 << endl; - continue; - } - - if(!fhadcuts->IsKZeroSelected(v0,vertex1)) continue; // check if it is a k0 - - // checks to avoid double counting - Int_t negID = -999; - Int_t posID = -998; - //Int_t a = 0; - prevnegID[iv0] = -997; - prevposID[iv0]= -996; - negID = v0->GetNegID(); - posID = v0->GetPosID(); - Bool_t DoubleCounting = kFALSE; - - for(Int_t k=0; kMatchToMC(310,fmcArray, 0, pdgDgK0toPipi); //match a K0 short - Double_t k0pt = v0->Pt(); - Double_t k0eta = v0->Eta(); - Double_t k0Phi = v0->Phi(); - fk0InvMass = v0->MassK0Short(); - - //if (loopindex == 0) { - // if(!plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectra"))->Fill(k0InvMass,k0pt); // spectra for all k0 - // if(plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectraifHF"))->Fill(k0InvMass,k0pt); // spectra for k0 in association with a D* - //} - // if there are more D* candidates per event, loopindex == 0 makes sure you fill the mass spectra only once! - - if(TMath::Abs(fk0InvMass-mPDGK0)>3*0.004) continue; // select candidates within 3 sigma - KZeroClone->Add(new AliReducedParticle(k0eta,k0Phi,k0pt,v0label)); - - } - } // end if use reconstruction kTRUE - - - -//*********************************************************************// - //use MC truth - if(fmontecarlo && !fUseReco){ - - for (Int_t iPart=0; iPartGetEntriesFast(); iPart++) { - AliAODMCParticle* mcPart = dynamic_cast(fmcArray->At(iPart)); - if (!mcPart) { - AliWarning("MC Particle not found in tree, skipping"); - continue; - } - - Int_t PDG =TMath::Abs(mcPart->PdgCode()); - if(!(PDG==310)) continue; // select only if k0 short - - Double_t pT = mcPart->Pt(); - Double_t d0 =1; // set 1 fot the moment - no displacement calculation implemented yet - if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts - - KZeroClone->Add(new AliReducedParticle(mcPart->Eta(), mcPart->Phi(), pT,iPart,-1,d0,kTRUE,mcPart->Charge())); - } - - } // end if use MC truth - - - - return KZeroClone; -} +/************************************************************************** + * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ +// +// +// Base class for Heavy Flavour Correlations Analysis +// Single Event and Mixed Event Analysis are implemented +// +//----------------------------------------------------------------------- +// +// +// Author S.Bjelogrlic +// Utrecht University +// sandro.bjelogrlic@cern.ch +// +//----------------------------------------------------------------------- + +/* $Id$ */ + +#include +#include +#include +#include "TROOT.h" +#include "AliHFCorrelator.h" +#include "AliRDHFCutsDStartoKpipi.h" +#include "AliHFAssociatedTrackCuts.h" +#include "AliEventPoolManager.h" +#include "AliReducedParticle.h" +#include "AliCentrality.h" +#include "AliAODMCParticle.h" + +using std::cout; +using std::endl; + +//_____________________________________________________ +AliHFCorrelator::AliHFCorrelator() : +// +// default constructor +// +TNamed(), +fPoolMgr(0x0), +fPool(0x0), +fhadcuts(0x0), +fAODEvent(0x0), +fAssociatedTracks(0x0), +fmcArray(0x0), +fReducedPart(0x0), +fD0cand(0x0), +fhypD0(0), +fDCharge(0), + +fmixing(kFALSE), +fmontecarlo(kFALSE), +fsystem(kFALSE), +fUseReco(kTRUE), +fselect(kUndefined), + +fUseImpactParameter(0), +fPIDmode(0), + +fNofTracks(0), +fPoolContent(0), + +fPhiMin(0), +fPhiMax(0), + +fPtTrigger(0), +fPhiTrigger(0), +fEtaTrigger(0), + + +fDeltaPhi(0), +fDeltaEta(0), +fk0InvMass(0) + +{ + // default constructor +} + + + +//_____________________________________________________ +AliHFCorrelator::AliHFCorrelator(const Char_t* name, AliHFAssociatedTrackCuts *cuts, Bool_t ppOrPbPb) : +TNamed(name,"title"), +fPoolMgr(0x0), +fPool(0x0), +fhadcuts(0x0), +fAODEvent(0x0), +fAssociatedTracks(0x0), +fmcArray(0x0), +fReducedPart(0x0), +fD0cand(0x0), +fhypD0(0), +fDCharge(0), + +fmixing(kFALSE), +fmontecarlo(kFALSE), +fsystem(ppOrPbPb), +fUseReco(kTRUE), +fselect(kUndefined), +fUseImpactParameter(0), +fPIDmode(0), + +fNofTracks(0), +fPoolContent(0), + +fPhiMin(0), +fPhiMax(0), + +fPtTrigger(0), +fPhiTrigger(0), +fEtaTrigger(0), + + +fDeltaPhi(0), +fDeltaEta(0), +fk0InvMass(0) +{ + fhadcuts = cuts; +} + +//_____________________________________________________ +AliHFCorrelator::~AliHFCorrelator() +{ +// +// destructor +// + + if(fPoolMgr) {delete fPoolMgr; fPoolMgr=0;} + if(fPool) {delete fPool; fPool=0;} + if(fhadcuts) {delete fhadcuts; fhadcuts=0;} + if(fAODEvent) {delete fAODEvent; fAODEvent=0;} + if(fAssociatedTracks) {delete fAssociatedTracks; fAssociatedTracks=0;} + if(fmcArray) {delete fmcArray; fmcArray=0;} + if(fReducedPart) {delete fReducedPart; fReducedPart=0;} + if(fD0cand) {delete fD0cand; fD0cand=0;} + + + if(fNofTracks) fNofTracks = 0; + + if(fPhiMin) fPhiMin = 0; + if(fPhiMax) fPhiMax = 0; + + if(fPtTrigger) fPtTrigger=0; + if(fPhiTrigger) fPhiTrigger=0; + if(fEtaTrigger) fEtaTrigger=0; + + if(fDeltaPhi) fDeltaPhi=0; + if(fDeltaEta) fDeltaEta=0; + + if(fk0InvMass) fk0InvMass=0; + +} +//_____________________________________________________ +Bool_t AliHFCorrelator::DefineEventPool(){ + // definition of the Pool Manager for Event Mixing + + + Int_t MaxNofEvents = fhadcuts->GetMaxNEventsInPool(); + Int_t MinNofTracks = fhadcuts->GetMinNTracksInPool(); + Int_t NofCentBins = fhadcuts->GetNCentPoolBins(); + Double_t * CentBins = fhadcuts->GetCentPoolBins(); + Int_t NofZVrtxBins = fhadcuts->GetNZvtxPoolBins(); + Double_t *ZVrtxBins = fhadcuts->GetZvtxPoolBins(); + + + fPoolMgr = new AliEventPoolManager(MaxNofEvents, MinNofTracks, NofCentBins, CentBins, NofZVrtxBins, ZVrtxBins); + if(!fPoolMgr) return kFALSE; + return kTRUE; +} +//_____________________________________________________ +Bool_t AliHFCorrelator::Initialize(){ + + // std::cout << "AliHFCorrelator::Initialize"<< std::endl; +// AliInfo("AliHFCorrelator::Initialize") ; + if(!fAODEvent){ + AliInfo("No AOD event") ; + return kFALSE; + } + //std::cout << "No AOD event" << std::endl; + + AliCentrality *centralityObj = 0; + //Int_t multiplicity = -1; + Double_t MultipOrCent = -1; + + // initialize the pool for event mixing + if(!fsystem){ // pp + //multiplicity = fAODEvent->GetNTracks(); + MultipOrCent = AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(fAODEvent,-1.,1.); + // MultipOrCent = multiplicity; // convert from Int_t to Double_t + // AliInfo(Form("Multiplicity is %f", MultipOrCent)); + } + if(fsystem){ // PbPb + + centralityObj = fAODEvent->GetHeader()->GetCentralityP(); + MultipOrCent = centralityObj->GetCentralityPercentileUnchecked("V0M"); +// AliInfo(Form("Centrality is %f", MultipOrCent)); + } + + AliAODVertex *vtx = fAODEvent->GetPrimaryVertex(); + Double_t zvertex = vtx->GetZ(); // zvertex + Double_t * CentBins = fhadcuts->GetCentPoolBins(); + Double_t poolmin=CentBins[0]; + Double_t poolmax=CentBins[fhadcuts->GetNCentPoolBins()]; + + + if(TMath::Abs(zvertex)>=10 || MultipOrCent>poolmax || MultipOrCent < poolmin) { + if(!fsystem)AliInfo(Form("pp or pA Event with Zvertex = %.2f cm and multiplicity = %.0f out of pool bounds, SKIPPING",zvertex,MultipOrCent)); + if(fsystem) AliInfo(Form("PbPb Event with Zvertex = %.2f cm and centrality = %.1f out of pool bounds, SKIPPING",zvertex,MultipOrCent)); + + return kFALSE; + } + + fPool = fPoolMgr->GetEventPool(MultipOrCent, zvertex); + + if (!fPool){ + AliInfo(Form("No pool found for multiplicity = %f, zVtx = %f cm", MultipOrCent, zvertex)); + return kFALSE; + } + //fPool->PrintInfo(); + return kTRUE; +} + +//_____________________________________________________ +Bool_t AliHFCorrelator::ProcessEventPool(){ + // analysis on Mixed Events + //cout << "AliHFCorrelator::ProcessEventPool"<< endl; + if(!fmixing) return kFALSE; + if(!fPool->IsReady()) return kFALSE; + if(fPool->GetCurrentNEvents()GetMinEventsToMix()) return kFALSE; + // fPool->PrintInfo(); + fPoolContent = fPool->GetCurrentNEvents(); + + return kTRUE; + +} + +//_____________________________________________________ +Bool_t AliHFCorrelator::ProcessAssociatedTracks(Int_t EventLoopIndex, const TObjArray* associatedTracks){ + // associatedTracks is not deleted, it should be (if needed) deleted in the user task + + if(!fmixing){ // analysis on Single Event + if(fAssociatedTracks){ + fAssociatedTracks->Delete(); + delete fAssociatedTracks; + } + if(fselect==kHadron || fselect ==kKaon){ + fAssociatedTracks = AcceptAndReduceTracks(fAODEvent); + fAssociatedTracks->SetOwner(kTRUE); + } + if(fselect==kKZero) { + fAssociatedTracks = AcceptAndReduceKZero(fAODEvent); + fAssociatedTracks->SetOwner(kTRUE); + } + if(fselect==kElectron && associatedTracks) { + fAssociatedTracks=new TObjArray(*associatedTracks);// Maybe better to call the copy constructor + fAssociatedTracks->SetOwner(kFALSE); + } + + } + + if(fmixing) { // analysis on Mixed Events + + + fAssociatedTracks = fPool->GetEvent(EventLoopIndex); + + + + + } // end if mixing + + if(!fAssociatedTracks) return kFALSE; + + fNofTracks = fAssociatedTracks->GetEntriesFast(); + + return kTRUE; + +} +//_____________________________________________________ +Bool_t AliHFCorrelator::Correlate(Int_t loopindex){ + + if(loopindex >= fNofTracks) return kFALSE; + if(!fAssociatedTracks) return kFALSE; + + fReducedPart = (AliReducedParticle*)fAssociatedTracks->At(loopindex); + + + fDeltaPhi = SetCorrectPhiRange(fPhiTrigger - fReducedPart->Phi()); + + fDeltaEta = fEtaTrigger - fReducedPart->Eta(); + + return kTRUE; + +} + +//_____________________________________________________ +Bool_t AliHFCorrelator::PoolUpdate(const TObjArray* associatedTracks){ + + if(!fmixing) return kFALSE; + if(!fPool) return kFALSE; + if(fmixing) { // update the pool for Event Mixing + TObjArray* objArr = NULL; + if(fselect==kHadron || fselect==kKaon) objArr = (TObjArray*)AcceptAndReduceTracks(fAODEvent); + else if(fselect==kKZero) objArr = (TObjArray*)AcceptAndReduceKZero(fAODEvent); + else if(fselect==kElectron && associatedTracks){ + objArr = new TObjArray(*associatedTracks); + } + else return kFALSE; + if(objArr->GetEntriesFast()>0) fPool->UpdatePool(objArr); // updating the pool only if there are entries in the array + } + + return kTRUE; + +} + +//_____________________________________________________ +Double_t AliHFCorrelator::SetCorrectPhiRange(Double_t phi){ + Double_t pi = TMath::Pi(); + + if(phifPhiMax) phi = phi - 2*pi; + + return phi; +} + +//_____________________________________________________ +TObjArray* AliHFCorrelator::AcceptAndReduceTracks(AliAODEvent* inputEvent){ + + Double_t weight=1.; + Int_t nTracks = inputEvent->GetNTracks(); + AliAODVertex * vtx = inputEvent->GetPrimaryVertex(); + Double_t pos[3],cov[6]; + vtx->GetXYZ(pos); + vtx->GetCovarianceMatrix(cov); + const AliESDVertex vESD(pos,cov,100.,100); + + Double_t Bz = inputEvent->GetMagneticField(); + + + TObjArray* tracksClone = new TObjArray; + tracksClone->SetOwner(kTRUE); + + //******************************************************* + // use reconstruction + if(fUseReco){ + for (Int_t iTrack=0; iTrackGetTrack(iTrack); + if (!track) continue; + if(!fhadcuts->IsHadronSelected(track,&vESD,Bz)) continue; // apply ESD level selections + if(!fhadcuts->Charge(fDCharge,track)) continue; // apply selection on charge, if required + + Double_t pT = track->Pt(); + + //compute impact parameter + Double_t d0z0[2],covd0z0[3]; + Double_t d0=-999999.; + if(fUseImpactParameter) track->PropagateToDCA(vtx,Bz,100,d0z0,covd0z0); + else d0z0[0] = 1. ; // random number - be careful with the cuts you applied + + if(fUseImpactParameter==1) d0 = TMath::Abs(d0z0[0]); // use impact parameter + if(fUseImpactParameter==2) { // use impact parameter over resolution + if(TMath::Abs(covd0z0[0])>0.00000001) d0 = TMath::Abs(d0z0[0])/TMath::Sqrt(covd0z0[0]); + else d0 = -1.; // if the resoultion is Zero, rejects the track - to be on the safe side + + } + + if(fmontecarlo) {// THIS TO BE CHECKED + Int_t hadLabel = track->GetLabel(); + if(hadLabel < 0) continue; + } + + if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts + Bool_t rejectsoftpi = kTRUE;// TO BE CHECKED: DO WE WANT IT TO kTRUE AS A DEFAULT? + if(fD0cand && !fmixing) rejectsoftpi = fhadcuts->InvMassDstarRejection(fD0cand,track,fhypD0); // TO BE CHECKED: WHY NOT FOR EM? + + + if(fselect ==kKaon){ + if(!fhadcuts->CheckKaonCompatibility(track,fmontecarlo,fmcArray,fPIDmode)) continue; // check if it is a Kaon - data and MC + } + weight=fhadcuts->GetTrackWeight(pT,track->Eta(),pos[2]); + tracksClone->Add(new AliReducedParticle(track->Eta(), track->Phi(), pT,track->GetLabel(),track->GetID(),d0,rejectsoftpi,track->Charge(),weight)); + } // end loop on tracks + } // end if use reconstruction kTRUE + + //******************************************************* + + //use MC truth + if(fmontecarlo && !fUseReco){ + + for (Int_t iPart=0; iPartGetEntriesFast(); iPart++) { + AliAODMCParticle* mcPart = dynamic_cast(fmcArray->At(iPart)); + if (!mcPart) { + AliWarning("MC Particle not found in tree, skipping"); + continue; + } + if(!mcPart->Charge()) continue; // consider only charged tracks + + Int_t PDG =TMath::Abs(mcPart->PdgCode()); +if(fselect ==kHadron) {if(!((PDG==321)||(PDG==211)||(PDG==2212)||(PDG==13)||(PDG==11))) continue;} // select only if kaon, pion, proton, muon or electron + else if(fselect ==kKaon) {if(!(PDG==321)) continue;} // select only if kaon + else if(fselect ==kElectron) {if(!(PDG==11)) continue;} // select only if electron + + Double_t pT = mcPart->Pt(); + Double_t d0 =1; // set 1 fot the moment - no displacement calculation implemented yet + if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts + + tracksClone->Add(new AliReducedParticle(mcPart->Eta(), mcPart->Phi(), pT,iPart,-1,d0,kFALSE,mcPart->Charge())); + } + + } // end if use MC truth + + + return tracksClone; +} + +//_____________________________________________________ +TObjArray* AliHFCorrelator::AcceptAndReduceKZero(AliAODEvent* inputEvent){ + + Int_t nOfVZeros = inputEvent->GetNumberOfV0s(); + TObjArray* KZeroClone = new TObjArray; + AliAODVertex *vertex1 = (AliAODVertex*)inputEvent->GetPrimaryVertex(); + + // use reconstruction + if(fUseReco){ + Int_t v0label = -1; + Int_t pdgDgK0toPipi[2] = {211,211}; + Double_t mPDGK0=0.497614;//TDatabasePDG::Instance()->GetParticle(310)->Mass(); + const Int_t size = inputEvent->GetNumberOfV0s(); + Int_t prevnegID[size]; + Int_t prevposID[size]; + for(Int_t iv0 =0; iv0< nOfVZeros; iv0++){// loop on all v0 candidates + AliAODv0 *v0 = (static_cast (inputEvent))->GetV0(iv0); + if(!v0) { + AliInfo(Form("is not a v0 at step, %d", iv0)) ; + //cout << "is not a v0 at step " << iv0 << endl; + continue; + } + + if(!fhadcuts->IsKZeroSelected(v0,vertex1)) continue; // check if it is a k0 + + // checks to avoid double counting + Int_t negID = -999; + Int_t posID = -998; + //Int_t a = 0; + prevnegID[iv0] = -997; + prevposID[iv0]= -996; + negID = v0->GetNegID(); + posID = v0->GetPosID(); + Bool_t DoubleCounting = kFALSE; + + for(Int_t k=0; kMatchToMC(310,fmcArray, 0, pdgDgK0toPipi); //match a K0 short + Double_t k0pt = v0->Pt(); + Double_t k0eta = v0->Eta(); + Double_t k0Phi = v0->Phi(); + fk0InvMass = v0->MassK0Short(); + + //if (loopindex == 0) { + // if(!plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectra"))->Fill(k0InvMass,k0pt); // spectra for all k0 + // if(plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectraifHF"))->Fill(k0InvMass,k0pt); // spectra for k0 in association with a D* + //} + // if there are more D* candidates per event, loopindex == 0 makes sure you fill the mass spectra only once! + + if(TMath::Abs(fk0InvMass-mPDGK0)>3*0.004) continue; // select candidates within 3 sigma + KZeroClone->Add(new AliReducedParticle(k0eta,k0Phi,k0pt,v0label)); + + } + } // end if use reconstruction kTRUE + + + +//*********************************************************************// + //use MC truth + if(fmontecarlo && !fUseReco){ + + for (Int_t iPart=0; iPartGetEntriesFast(); iPart++) { + AliAODMCParticle* mcPart = dynamic_cast(fmcArray->At(iPart)); + if (!mcPart) { + AliWarning("MC Particle not found in tree, skipping"); + continue; + } + + Int_t PDG =TMath::Abs(mcPart->PdgCode()); + if(!(PDG==310)) continue; // select only if k0 short + + Double_t pT = mcPart->Pt(); + Double_t d0 =1; // set 1 fot the moment - no displacement calculation implemented yet + if(!fhadcuts->CheckHadronKinematic(pT,d0)) continue; // apply kinematic cuts + + KZeroClone->Add(new AliReducedParticle(mcPart->Eta(), mcPart->Phi(), pT,iPart,-1,d0,kTRUE,mcPart->Charge())); + } + + } // end if use MC truth + + + + return KZeroClone; +} diff --git a/PWGHF/correlationHF/AliHFCorrelator.h b/PWGHF/correlationHF/AliHFCorrelator.h index 4ca6f5c2394..9e525cfd0c9 100644 --- a/PWGHF/correlationHF/AliHFCorrelator.h +++ b/PWGHF/correlationHF/AliHFCorrelator.h @@ -1,162 +1,162 @@ -#ifndef AliHFCorrelator_H -#define AliHFCorrelator_H - -/************************************************************************** - * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -// -// Base class for Heavy Flavour Correlations Analysis -// Single Event and Mixed Event Analysis are implemented -//----------------------------------------------------------------------- -// -// -// Author S.Bjelogrlic -// Utrecht University -// sandro.bjelogrlic@cern.ch -// -//----------------------------------------------------------------------- - -/* $Id$ */ - -#include "AliHFAssociatedTrackCuts.h" -#include "AliEventPoolManager.h" -#include "AliVParticle.h" -#include "AliReducedParticle.h" -#include "AliVertexingHFUtils.h" - - -class AliHFCorrelator : public TNamed -{ - - public: - - AliHFCorrelator(); - AliHFCorrelator(const Char_t* name, AliHFAssociatedTrackCuts *cuts, Bool_t ppOrPbPb); - virtual ~AliHFCorrelator(); - - // enum for setting which associated particle type to work with - enum{ - kUndefined=0, - kHadron=1, - kKaon, - kKZero, - kElectron - }; - - //setters - void SetDeltaPhiInterval (Double_t min, Double_t max){ - fPhiMin = min; fPhiMax = max; - if(TMath::Abs(fPhiMin-fPhiMax) != 2*TMath::Pi()) AliInfo("AliHFCorrelator::Warning: the delta phi interval is not set to 2 Pi"); - } - void SetEventMixing(Bool_t mixON){fmixing=mixON;} - void SetTriggerParticleProperties(Double_t ptTrig, Double_t phiTrig, Double_t etaTrig) - {fPtTrigger = ptTrig; fPhiTrigger = phiTrig; fEtaTrigger = etaTrig;} - void SetTriggerParticleDaughterCharge(Short_t charge) {fDCharge=charge;} - - - void SetAssociatedParticleType(Int_t type){fselect = type;} - void SetAODEvent(AliAODEvent* inputevent){fAODEvent = inputevent;} - void SetMCArray(TClonesArray* mcArray){fmcArray = mcArray;} - void SetUseMC(Bool_t useMC){fmontecarlo = useMC;} - void SetApplyDisplacementCut(Int_t applycut){fUseImpactParameter = applycut;} - void SetPIDmode(Int_t mode){fPIDmode = mode;} - - void SetD0Properties(AliAODRecoDecayHF2Prong* d, Int_t D0hyp) - {fD0cand = d; fhypD0 = D0hyp;} - - void SetUseReco(Bool_t useReco) {fUseReco = useReco;} - - - - Bool_t DefineEventPool(); // Definition of the Event pool parameters - Bool_t Initialize(); // function that initlize everything for the analysis - Bool_t ProcessEventPool(); // processes the event pool - Bool_t ProcessAssociatedTracks(Int_t EventLoopIndex, const TObjArray* associatedTracks=NULL); // - Bool_t Correlate(Int_t loopindex); // function that computes the correlations between the trigger particle and the track n. loopindex - Bool_t PoolUpdate(const TObjArray* associatedTracks=NULL);// updates the event pool - Double_t SetCorrectPhiRange(Double_t phi); // sets all the angles in the correct range - void SetPidAssociated() {fhadcuts->SetPidAssociated();} - - //getters - AliEventPool* GetPool() {return fPool;} - TObjArray * GetTrackArray(){return fAssociatedTracks;} - AliHFAssociatedTrackCuts* GetSelectionCuts() {return fhadcuts;} - AliReducedParticle* GetAssociatedParticle() {return fReducedPart;} - - Int_t GetNofTracks(){return fNofTracks;} - Int_t GetNofEventsInPool(){return fPoolContent;} - - Double_t GetDeltaPhi(){return fDeltaPhi;} // Delta Phi, needs to be called after the method correlate - Double_t GetDeltaEta(){return fDeltaEta;} // Delta Eta - - Double_t GetAssociatedKZeroInvariantmass(){return fk0InvMass;} - - - - // methods to reduce the tracks to correlate with track selection cuts applied here - TObjArray* AcceptAndReduceTracks(AliAODEvent* inputEvent); // selecting hadrons and kaons - TObjArray* AcceptAndReduceKZero(AliAODEvent* inputEvent); // selecting kzeros - - - private: - - AliHFCorrelator(const AliHFCorrelator& vtxr); - AliHFCorrelator& operator=(const AliHFCorrelator& vtxr ); - - AliEventPoolManager* fPoolMgr; //! event pool manager - AliEventPool * fPool; //! Pool for event mixing - AliHFAssociatedTrackCuts* fhadcuts;//! hadron cuts - AliAODEvent * fAODEvent;//! AOD Event - TObjArray* fAssociatedTracks; // Array of associated tracks - TClonesArray* fmcArray; //mcarray - AliReducedParticle * fReducedPart; // reduced AOD particle; - AliAODRecoDecayHF2Prong* fD0cand; //D0 candidate - Int_t fhypD0; //hypothesis necessary for - Int_t fDCharge; // charge of a daughter of the D meson - - Bool_t fmixing;// switch for event mixing - Bool_t fmontecarlo; // switch for MonteCarlo - Bool_t fsystem; // select pp (kFALSE) or PbPb (kTRUE) - Bool_t fUseReco; // switch to use reconstruction (kTRUE) or MC truth (kFALSE) - - Int_t fselect; // 1 for hadrons, 2 for kaons, 3 for KZeros - Int_t fUseImpactParameter; // switch to use the impact parameter cut - Int_t fPIDmode; // set the PID mode for Kaon identification - - Int_t fNofTracks; // number of tracks in track array - Int_t fPoolContent; // n of events in pool - - Double_t fPhiMin; // min for phi - Double_t fPhiMax; // max for phi - - Double_t fPtTrigger; // pt of the trigger D meson - Double_t fPhiTrigger; // phi of the trigger D meson - Double_t fEtaTrigger; // Eta of the trigger D meson - - - Double_t fDeltaPhi; // delta phi between D meson and associated track - Double_t fDeltaEta; // delta eta between D meson and associated track - - Double_t fk0InvMass; // KZero invariant mass - - - ClassDef(AliHFCorrelator,3); // class for HF correlations -}; - - - - - -#endif +#ifndef AliHFCorrelator_H +#define AliHFCorrelator_H + +/************************************************************************** + * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +// +// Base class for Heavy Flavour Correlations Analysis +// Single Event and Mixed Event Analysis are implemented +//----------------------------------------------------------------------- +// +// +// Author S.Bjelogrlic +// Utrecht University +// sandro.bjelogrlic@cern.ch +// +//----------------------------------------------------------------------- + +/* $Id$ */ + +#include "AliHFAssociatedTrackCuts.h" +#include "AliEventPoolManager.h" +#include "AliVParticle.h" +#include "AliReducedParticle.h" +#include "AliVertexingHFUtils.h" + + +class AliHFCorrelator : public TNamed +{ + + public: + + AliHFCorrelator(); + AliHFCorrelator(const Char_t* name, AliHFAssociatedTrackCuts *cuts, Bool_t ppOrPbPb); + virtual ~AliHFCorrelator(); + + // enum for setting which associated particle type to work with + enum{ + kUndefined=0, + kHadron=1, + kKaon, + kKZero, + kElectron + }; + + //setters + void SetDeltaPhiInterval (Double_t min, Double_t max){ + fPhiMin = min; fPhiMax = max; + if(TMath::Abs(fPhiMin-fPhiMax) != 2*TMath::Pi()) AliInfo("AliHFCorrelator::Warning: the delta phi interval is not set to 2 Pi"); + } + void SetEventMixing(Bool_t mixON){fmixing=mixON;} + void SetTriggerParticleProperties(Double_t ptTrig, Double_t phiTrig, Double_t etaTrig) + {fPtTrigger = ptTrig; fPhiTrigger = phiTrig; fEtaTrigger = etaTrig;} + void SetTriggerParticleDaughterCharge(Short_t charge) {fDCharge=charge;} + + + void SetAssociatedParticleType(Int_t type){fselect = type;} + void SetAODEvent(AliAODEvent* inputevent){fAODEvent = inputevent;} + void SetMCArray(TClonesArray* mcArray){fmcArray = mcArray;} + void SetUseMC(Bool_t useMC){fmontecarlo = useMC;} + void SetApplyDisplacementCut(Int_t applycut){fUseImpactParameter = applycut;} + void SetPIDmode(Int_t mode){fPIDmode = mode;} + + void SetD0Properties(AliAODRecoDecayHF2Prong* d, Int_t D0hyp) + {fD0cand = d; fhypD0 = D0hyp;} + + void SetUseReco(Bool_t useReco) {fUseReco = useReco;} + + + + Bool_t DefineEventPool(); // Definition of the Event pool parameters + Bool_t Initialize(); // function that initlize everything for the analysis + Bool_t ProcessEventPool(); // processes the event pool + Bool_t ProcessAssociatedTracks(Int_t EventLoopIndex, const TObjArray* associatedTracks=NULL); // + Bool_t Correlate(Int_t loopindex); // function that computes the correlations between the trigger particle and the track n. loopindex + Bool_t PoolUpdate(const TObjArray* associatedTracks=NULL);// updates the event pool + Double_t SetCorrectPhiRange(Double_t phi); // sets all the angles in the correct range + void SetPidAssociated() {fhadcuts->SetPidAssociated();} + + //getters + AliEventPool* GetPool() {return fPool;} + TObjArray * GetTrackArray(){return fAssociatedTracks;} + AliHFAssociatedTrackCuts* GetSelectionCuts() {return fhadcuts;} + AliReducedParticle* GetAssociatedParticle() {return fReducedPart;} + + Int_t GetNofTracks(){return fNofTracks;} + Int_t GetNofEventsInPool(){return fPoolContent;} + + Double_t GetDeltaPhi(){return fDeltaPhi;} // Delta Phi, needs to be called after the method correlate + Double_t GetDeltaEta(){return fDeltaEta;} // Delta Eta + + Double_t GetAssociatedKZeroInvariantmass(){return fk0InvMass;} + + + + // methods to reduce the tracks to correlate with track selection cuts applied here + TObjArray* AcceptAndReduceTracks(AliAODEvent* inputEvent); // selecting hadrons and kaons + TObjArray* AcceptAndReduceKZero(AliAODEvent* inputEvent); // selecting kzeros + + + private: + + AliHFCorrelator(const AliHFCorrelator& vtxr); + AliHFCorrelator& operator=(const AliHFCorrelator& vtxr ); + + AliEventPoolManager* fPoolMgr; //! event pool manager + AliEventPool * fPool; //! Pool for event mixing + AliHFAssociatedTrackCuts* fhadcuts;//! hadron cuts + AliAODEvent * fAODEvent;//! AOD Event + TObjArray* fAssociatedTracks; // Array of associated tracks + TClonesArray* fmcArray; //mcarray + AliReducedParticle * fReducedPart; // reduced AOD particle; + AliAODRecoDecayHF2Prong* fD0cand; //D0 candidate + Int_t fhypD0; //hypothesis necessary for + Int_t fDCharge; // charge of a daughter of the D meson + + Bool_t fmixing;// switch for event mixing + Bool_t fmontecarlo; // switch for MonteCarlo + Bool_t fsystem; // select pp (kFALSE) or PbPb (kTRUE) + Bool_t fUseReco; // switch to use reconstruction (kTRUE) or MC truth (kFALSE) + + Int_t fselect; // 1 for hadrons, 2 for kaons, 3 for KZeros + Int_t fUseImpactParameter; // switch to use the impact parameter cut + Int_t fPIDmode; // set the PID mode for Kaon identification + + Int_t fNofTracks; // number of tracks in track array + Int_t fPoolContent; // n of events in pool + + Double_t fPhiMin; // min for phi + Double_t fPhiMax; // max for phi + + Double_t fPtTrigger; // pt of the trigger D meson + Double_t fPhiTrigger; // phi of the trigger D meson + Double_t fEtaTrigger; // Eta of the trigger D meson + + + Double_t fDeltaPhi; // delta phi between D meson and associated track + Double_t fDeltaEta; // delta eta between D meson and associated track + + Double_t fk0InvMass; // KZero invariant mass + + + ClassDef(AliHFCorrelator,3); // class for HF correlations +}; + + + + + +#endif diff --git a/PWGHF/correlationHF/macros/AddTaskDStarCorrelations.C b/PWGHF/correlationHF/macros/AddTaskDStarCorrelations.C index 49a9cfeb19d..25dbcc86346 100644 --- a/PWGHF/correlationHF/macros/AddTaskDStarCorrelations.C +++ b/PWGHF/correlationHF/macros/AddTaskDStarCorrelations.C @@ -1,375 +1,375 @@ - //DEFINITION OF A FEW CONSTANTS -//---------------------------------------------------- - -/* $Id$ */ - -AliAnalysisTaskDStarCorrelations *AddTaskDStarCorrelations(AliAnalysisTaskDStarCorrelations::CollSyst syst, - Bool_t theMCon, Bool_t mixing, Bool_t UseReco=kTRUE,Bool_t UseHadChannelinMC,Bool_t fullmode = kFALSE,Bool_t UseEffic=kFALSE,Bool_t UseDEffic = kFALSE, - AliAnalysisTaskDStarCorrelations::DEffVariable var, - Int_t trackselect =1, Int_t usedispl =0, Int_t nbins, Float_t DStarSigma, Float_t D0Sigma, Float_t D0SBSigmaLow, Float_t D0SBSigmaHigh, Float_t eta, - TString DStarCutsFile, TString TrackCutsFile, - Int_t tasknumber = 0) -{ - - - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - ::Error(" AliAnalysisTaskDStarCorrelations", "No analysis manager to connect to."); - return NULL; - } - - cout << "==========================================================" << endl; - cout << "Set Inputs : " << endl; - cout << " " << endl; - if(syst == AliAnalysisTaskDStarCorrelations::pp) cout << "Running on pp @ 7 TeV" << endl; - if(syst == AliAnalysisTaskDStarCorrelations::pA) cout << "Running on pPb @ 5.02 TeV" << endl; - if(syst == AliAnalysisTaskDStarCorrelations::AA) cout << "Running on PbPb @ 2.76 TeV" << endl; - - if(theMCon) cout << "Analysis on MonteCarlo" << endl; - else cout << "Analysis on Data" << endl; - - if(mixing) cout << "Analysis on Mixed Events" << endl; - else cout << "Analysis on Single Events" << endl; - - if(UseReco) cout << "Using Reconstructed objects" << endl; - else cout << "Using Pure MC information " << endl; - - if(fullmode) cout << "Running in full mode" << endl; - else cout << "Running in fast mode " << endl; - - if(UseEffic) cout << "Using single track efficiency map" << endl; - else cout << "Not Using single track efficiency map " << endl; - - if(UseDEffic) cout << "Using Dmeson efficiency map" << endl; - else cout << "Not Using Dmeson efficiency map " << endl; - - - if(var == AliAnalysisTaskDStarCorrelations::kNone) cout << "Applying D Efficiency map vs pT " << endl; - if(var == AliAnalysisTaskDStarCorrelations::kMult) cout << "Applying D Efficiency map vs pT vs Multiplicity" << endl; - if(var == AliAnalysisTaskDStarCorrelations::kCentr) cout << "Applying D Efficiency map vs pT vs Centrality" << endl; - if(var == AliAnalysisTaskDStarCorrelations::kRapidity) cout << "Applying D Efficiency map vs pT vs Rapidity" << endl; - if(var == AliAnalysisTaskDStarCorrelations::kEta) cout << "Applying D Efficiency map vs pT vs Eta" << endl; - - if(trackselect == 1) cout << "Correlating with hadrons" << endl; - if(trackselect == 2) cout << "Correlating with kaons" << endl; - if(trackselect == 3) cout << "Correlating with kzeros" << endl; - - if(usedispl == 0) cout << "Not using displacement cut" << endl; - if(usedispl == 1) cout << "Using absolute displacement cut" << endl; - if(usedispl == 2) cout << "Using relative displacement cut" << endl; - - - cout << "Number of bins in deltaphi = " << nbins << endl; - - cout << "N of Sigmas in D* selection =" << DStarSigma << endl; - cout << "N of Sigmas in D0 selection = " << D0Sigma << endl; - cout << "D0 Sidebands taken from = " << D0SBSigmaLow << " - " << D0SBSigmaHigh << " sigmas " << endl; endl; - - - - cout << "DStar cut object: " << DStarCutsFile << endl; - cout << "Tracks cut object: " << TrackCutsFile << endl; - - - cout << "==========================================================" << endl; - //gSystem->Sleep(2000); - -// TString DCutObjPath = "CutObjects/DStar/"; - - -// ******************************** OPENING THE D* CUTS ************************************ - cout << "Getting D meson cut object from file \n" << DStarCutsFile.Data() << "\n " << endl; - TFile* filecuts=TFile::Open(DStarCutsFile.Data()); - if(!filecuts->IsOpen()){ - cout<<"DStar cut object file not found: exit"<Get("DStartoKpipiCuts"); - RDHFDStartoKpipi->SetName("DStartoKpipiCuts"); - - // mm let's see if everything is ok - if(!RDHFDStartoKpipi){ - cout<<"Specific AliRDHFCuts not found"<SetTriggerClass(""); - // RDHFDStartoKpipi->SetTriggerMask(AliVEvent::kCentral); - - - -// ******************************** OPENING THE ASSOCIATED TRACK CUTS ************************************ - cout << "Getting associated track cut object from file \n" << TrackCutsFile.Data() << "\n " << endl; - TFile* filecuts2=TFile::Open(TrackCutsFile.Data()); - if(!filecuts2->IsOpen()){ - cout<<"Track cut object file not found: exit"<Get("AssociatedCuts"); - corrCuts->SetName("AssociatedCuts"); - corrCuts->PrintAll(); - if(!corrCuts){ - cout<<"Specific associated track cuts not found"<GetNofMCEventType(); - for(Int_t k=0; kGetMCEventType(); - selectMCproc += Form("%d",MCEventType[k]); - } - - cout << "Select process string = " << selectMCproc << endl; - - - -// ******************************** CREATING THE TASK ************************************ - - printf("CREATE TASK \n"); - // create the task - AliAnalysisTaskDStarCorrelations *task = new AliAnalysisTaskDStarCorrelations("AliAnalysisTaskDStarCorrelations",RDHFDStartoKpipi,corrCuts,syst,fullmode); - - // Setters - - if(!theMCon) { - printf("Analysis on Data - reconstruction only!"); - UseReco = kTRUE; - printf("Analysis on Data - hadronic channel only!"); - UseHadChannelinMC = kFALSE; - } - - - - - - task->SetNofPhiBins(nbins); - task->SetMonteCarlo(theMCon); - task->SetUseMixing(mixing); - task->SetCorrelator(trackselect) ; - task->SetUseDisplacement(usedispl); - //task->SetCollSys(syst); - task->SetLevelOfDebug(2); - task->SetUseReconstruction(UseReco); // set kTRUE for Using Reconstruction, kFALSe for MC Truth - task->SetDMesonSigmas(DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh); - //task->SetDMesonSigmas(sigmas); - //task->SetDMesonSigmas(sigmas); - task->SetUseEfficiencyCorrection(UseEffic); - task->SetUseDmesonEfficiencyCorrection(UseDEffic); - - task->SetEfficiencyVariable(var); - task->SetMaxDStarEta(eta); - task->SetUseHadronicChannelAtKineLevel(UseHadChannelinMC); - - - if(trackselect == 1) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged hadrons \n"); - else if(trackselect == 2) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged kaons \n"); - else if(trackselect == 3) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with reconstructed K0s \n"); - else Fatal(" AliAnalysisTaskDStarCorrelations","Nothing to correlate with!"); - if(mixing) Info (" AliAnalysisTaskDStarCorrelations","Event Mixing Analysis\n"); - if(!mixing) Info (" AliAnalysisTaskDStarCorrelations","Single Event Analysis \n"); - - // Create and connect containers for input/output - //TString dcavalue = " "; - if(!theMCon) TString contname = "Data"; - if(theMCon) TString contname = "MonteCarlo"; - TString contname2 = "MC"; - if(trackselect ==1) TString particle = "Hadron"; - if(trackselect ==2) TString particle = "Kaon"; - if(trackselect ==3) TString particle = "KZero"; - - TString cutname = "cuts" ; - TString cutname2 = "hadroncuts" ; - TString outputfile = AliAnalysisManager::GetCommonFileName(); - TString outputfileMC = AliAnalysisManager::GetCommonFileName(); - TString counter = "NormCounter"; - outputfile += ":PWGHF_HFCJ_"; - outputfileMC += ":PWGHF_HFCJ_"; - - if(!mixing) { - outputfile += "SE"; - outputfileMC += "SE"; - contname += "SE"; - contname2 += "SE"; - cutname += "SE"; - cutname2 += "SE"; - counter+= "SE"; - } - if(mixing){ - outputfile += "ME"; - outputfileMC += "ME"; - contname += "ME"; - contname2 += "ME"; - cutname += "ME"; - cutname2 += "ME"; - counter+= "ME"; - } - - - - outputfile += "Dphi_DStar"; - outputfileMC += "Dphi_DStar"; - outputfile += particle; - outputfileMC += particle; - cutname += particle; - cutname2 += particle; - contname += particle; - contname2 += particle; - counter+= particle; - - if(UseEffic){ - outputfile += "_EffY_"; - outputfileMC += "_EffY_"; - contname += "_EffY_"; - contname2 += "_EffY_"; - cutname += "_EffY_"; - cutname2 += "_EffY_"; - counter+= "_EffY_"; - } - - if(!UseEffic){ - outputfile += "_EffN_"; - outputfileMC += "_EffN_"; - contname += "_EffN_"; - contname2 += "_EffN_"; - cutname += "_EffN_"; - cutname2 += "_EffN_"; - counter+= "_EffN_"; - } - - if(UseDEffic){ - TString string = "DEffY_"; - - if(var == AliAnalysisTaskDStarCorrelations::kNone) string += "vsPt_"; - if(var == AliAnalysisTaskDStarCorrelations::kMult) string += "vsPtMult_"; - if(var == AliAnalysisTaskDStarCorrelations::kCentr) string += "vsPCentrt_"; - if(var == AliAnalysisTaskDStarCorrelations::kRapidity) string += "vsPtY_"; - if(var == AliAnalysisTaskDStarCorrelations::kEta) string += "vsPtEta_"; - - outputfile += string; - outputfileMC += string; - contname += string; - contname2 += string; - cutname += string; - cutname2 += string; - counter+= string; - } - - if(!UseDEffic){ - outputfile += "DEffN_"; - outputfileMC += "DEffN_"; - contname += "DEffN_"; - contname2 += "DEffN_"; - cutname += "DEffN_"; - cutname2 += "DEffN_"; - counter+= "DEffN_"; - } - - - outputfile += Form("%d_bins_",nbins); - outputfileMC += Form("%d_bins_",nbins); - cutname += Form("%d_bins_",nbins); - cutname2 += Form("%d_bins_",nbins); - contname += Form("%d_bins_",nbins); - contname2 += Form("%d_bins_",nbins); - counter+= Form("%d_bins_",nbins); - - - outputfile += Form("task_%d",tasknumber); - outputfileMC += Form("task_%d",tasknumber); - cutname += Form("task_%d",tasknumber); - cutname2 += Form("task_%d",tasknumber); - contname += Form("task_%d",tasknumber); - contname2 += Form("task_%d",tasknumber); - counter+= Form("task_%d",tasknumber); - -/* outputfile += TrackCutObjNamePrefix; - outputfileMC += TrackCutObjNamePrefix; - cutname += TrackCutObjNamePrefix; - cutname2 += TrackCutObjNamePrefix; - contname += TrackCutObjNamePrefix; - contname2 += TrackCutObjNamePrefix; - counter+= TrackCutObjNamePrefix; -*/ - outputfile += selectMCproc; - outputfileMC += selectMCproc; - cutname += selectMCproc; - cutname2 += selectMCproc; - contname += selectMCproc; - contname2 += selectMCproc; - counter+= selectMCproc; - - TString reco = ""; - - if(UseReco) reco = "_reco"; - if(!UseReco) { - if(UseHadChannelinMC) reco = "_MCTruthHadChan"; - if(!UseHadChannelinMC) reco = "_MCTruthAllChan"; - } - outputfile += reco; - outputfileMC += reco; - cutname += reco; - cutname2 += reco; - contname += reco; - contname2 += reco; - counter+= reco; - - TString nsigma = Form("_%.0f_%.0f%.0f%.0f_sigmas",DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh); - - //cout << "nsigma string = "<< nsigma << endl; - - outputfile += nsigma; - outputfileMC += nsigma; - cutname += nsigma; - cutname2 += nsigma; - contname += nsigma; - contname2 += nsigma; - counter+= nsigma; - - - cout << contname << endl; - cout << contname2 << endl; - cout << cutname << endl; - cout << cutname2 << endl; - cout << counter << endl; - cout << outputfile << endl; - //return; - - mgr->AddTask(task); - // ------ input data ------ - AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); - - // ----- output data ----- - - // output TH1I for event counting - - //TLists - AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); - AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(contname2, TList::Class(),AliAnalysisManager::kOutputContainer,outputfileMC.Data()); - // Cut Objects - AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(cutname,AliRDHFCutsDStartoKpipi::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts D - AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(cutname2,AliHFAssociatedTrackCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts tracks - // Normalization Counter - AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(counter,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); - - - mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task,1,coutput1); - mgr->ConnectOutput(task,2,coutput2); - mgr->ConnectOutput(task,3,coutput3); - mgr->ConnectOutput(task,4,coutput4); - mgr->ConnectOutput(task,5,coutput5); - - return task ; - -} - + //DEFINITION OF A FEW CONSTANTS +//---------------------------------------------------- + +/* $Id$ */ + +AliAnalysisTaskDStarCorrelations *AddTaskDStarCorrelations(AliAnalysisTaskDStarCorrelations::CollSyst syst, + Bool_t theMCon, Bool_t mixing, Bool_t UseReco=kTRUE,Bool_t UseHadChannelinMC,Bool_t fullmode = kFALSE,Bool_t UseEffic=kFALSE,Bool_t UseDEffic = kFALSE, + AliAnalysisTaskDStarCorrelations::DEffVariable var, + Int_t trackselect =1, Int_t usedispl =0, Int_t nbins, Float_t DStarSigma, Float_t D0Sigma, Float_t D0SBSigmaLow, Float_t D0SBSigmaHigh, Float_t eta, + TString DStarCutsFile, TString TrackCutsFile, + Int_t tasknumber = 0) +{ + + + + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error(" AliAnalysisTaskDStarCorrelations", "No analysis manager to connect to."); + return NULL; + } + + cout << "==========================================================" << endl; + cout << "Set Inputs : " << endl; + cout << " " << endl; + if(syst == AliAnalysisTaskDStarCorrelations::pp) cout << "Running on pp @ 7 TeV" << endl; + if(syst == AliAnalysisTaskDStarCorrelations::pA) cout << "Running on pPb @ 5.02 TeV" << endl; + if(syst == AliAnalysisTaskDStarCorrelations::AA) cout << "Running on PbPb @ 2.76 TeV" << endl; + + if(theMCon) cout << "Analysis on MonteCarlo" << endl; + else cout << "Analysis on Data" << endl; + + if(mixing) cout << "Analysis on Mixed Events" << endl; + else cout << "Analysis on Single Events" << endl; + + if(UseReco) cout << "Using Reconstructed objects" << endl; + else cout << "Using Pure MC information " << endl; + + if(fullmode) cout << "Running in full mode" << endl; + else cout << "Running in fast mode " << endl; + + if(UseEffic) cout << "Using single track efficiency map" << endl; + else cout << "Not Using single track efficiency map " << endl; + + if(UseDEffic) cout << "Using Dmeson efficiency map" << endl; + else cout << "Not Using Dmeson efficiency map " << endl; + + + if(var == AliAnalysisTaskDStarCorrelations::kNone) cout << "Applying D Efficiency map vs pT " << endl; + if(var == AliAnalysisTaskDStarCorrelations::kMult) cout << "Applying D Efficiency map vs pT vs Multiplicity" << endl; + if(var == AliAnalysisTaskDStarCorrelations::kCentr) cout << "Applying D Efficiency map vs pT vs Centrality" << endl; + if(var == AliAnalysisTaskDStarCorrelations::kRapidity) cout << "Applying D Efficiency map vs pT vs Rapidity" << endl; + if(var == AliAnalysisTaskDStarCorrelations::kEta) cout << "Applying D Efficiency map vs pT vs Eta" << endl; + + if(trackselect == 1) cout << "Correlating with hadrons" << endl; + if(trackselect == 2) cout << "Correlating with kaons" << endl; + if(trackselect == 3) cout << "Correlating with kzeros" << endl; + + if(usedispl == 0) cout << "Not using displacement cut" << endl; + if(usedispl == 1) cout << "Using absolute displacement cut" << endl; + if(usedispl == 2) cout << "Using relative displacement cut" << endl; + + + cout << "Number of bins in deltaphi = " << nbins << endl; + + cout << "N of Sigmas in D* selection =" << DStarSigma << endl; + cout << "N of Sigmas in D0 selection = " << D0Sigma << endl; + cout << "D0 Sidebands taken from = " << D0SBSigmaLow << " - " << D0SBSigmaHigh << " sigmas " << endl; endl; + + + + cout << "DStar cut object: " << DStarCutsFile << endl; + cout << "Tracks cut object: " << TrackCutsFile << endl; + + + cout << "==========================================================" << endl; + //gSystem->Sleep(2000); + +// TString DCutObjPath = "CutObjects/DStar/"; + + +// ******************************** OPENING THE D* CUTS ************************************ + cout << "Getting D meson cut object from file \n" << DStarCutsFile.Data() << "\n " << endl; + TFile* filecuts=TFile::Open(DStarCutsFile.Data()); + if(!filecuts->IsOpen()){ + cout<<"DStar cut object file not found: exit"<Get("DStartoKpipiCuts"); + RDHFDStartoKpipi->SetName("DStartoKpipiCuts"); + + // mm let's see if everything is ok + if(!RDHFDStartoKpipi){ + cout<<"Specific AliRDHFCuts not found"<SetTriggerClass(""); + // RDHFDStartoKpipi->SetTriggerMask(AliVEvent::kCentral); + + + +// ******************************** OPENING THE ASSOCIATED TRACK CUTS ************************************ + cout << "Getting associated track cut object from file \n" << TrackCutsFile.Data() << "\n " << endl; + TFile* filecuts2=TFile::Open(TrackCutsFile.Data()); + if(!filecuts2->IsOpen()){ + cout<<"Track cut object file not found: exit"<Get("AssociatedCuts"); + corrCuts->SetName("AssociatedCuts"); + corrCuts->PrintAll(); + if(!corrCuts){ + cout<<"Specific associated track cuts not found"<GetNofMCEventType(); + for(Int_t k=0; kGetMCEventType(); + selectMCproc += Form("%d",MCEventType[k]); + } + + cout << "Select process string = " << selectMCproc << endl; + + + +// ******************************** CREATING THE TASK ************************************ + + printf("CREATE TASK \n"); + // create the task + AliAnalysisTaskDStarCorrelations *task = new AliAnalysisTaskDStarCorrelations("AliAnalysisTaskDStarCorrelations",RDHFDStartoKpipi,corrCuts,syst,fullmode); + + // Setters + + if(!theMCon) { + printf("Analysis on Data - reconstruction only!"); + UseReco = kTRUE; + printf("Analysis on Data - hadronic channel only!"); + UseHadChannelinMC = kFALSE; + } + + + + + + task->SetNofPhiBins(nbins); + task->SetMonteCarlo(theMCon); + task->SetUseMixing(mixing); + task->SetCorrelator(trackselect) ; + task->SetUseDisplacement(usedispl); + //task->SetCollSys(syst); + task->SetLevelOfDebug(2); + task->SetUseReconstruction(UseReco); // set kTRUE for Using Reconstruction, kFALSe for MC Truth + task->SetDMesonSigmas(DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh); + //task->SetDMesonSigmas(sigmas); + //task->SetDMesonSigmas(sigmas); + task->SetUseEfficiencyCorrection(UseEffic); + task->SetUseDmesonEfficiencyCorrection(UseDEffic); + + task->SetEfficiencyVariable(var); + task->SetMaxDStarEta(eta); + task->SetUseHadronicChannelAtKineLevel(UseHadChannelinMC); + + + if(trackselect == 1) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged hadrons \n"); + else if(trackselect == 2) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged kaons \n"); + else if(trackselect == 3) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with reconstructed K0s \n"); + else Fatal(" AliAnalysisTaskDStarCorrelations","Nothing to correlate with!"); + if(mixing) Info (" AliAnalysisTaskDStarCorrelations","Event Mixing Analysis\n"); + if(!mixing) Info (" AliAnalysisTaskDStarCorrelations","Single Event Analysis \n"); + + // Create and connect containers for input/output + //TString dcavalue = " "; + if(!theMCon) TString contname = "Data"; + if(theMCon) TString contname = "MonteCarlo"; + TString contname2 = "MC"; + if(trackselect ==1) TString particle = "Hadron"; + if(trackselect ==2) TString particle = "Kaon"; + if(trackselect ==3) TString particle = "KZero"; + + TString cutname = "cuts" ; + TString cutname2 = "hadroncuts" ; + TString outputfile = AliAnalysisManager::GetCommonFileName(); + TString outputfileMC = AliAnalysisManager::GetCommonFileName(); + TString counter = "NormCounter"; + outputfile += ":PWGHF_HFCJ_"; + outputfileMC += ":PWGHF_HFCJ_"; + + if(!mixing) { + outputfile += "SE"; + outputfileMC += "SE"; + contname += "SE"; + contname2 += "SE"; + cutname += "SE"; + cutname2 += "SE"; + counter+= "SE"; + } + if(mixing){ + outputfile += "ME"; + outputfileMC += "ME"; + contname += "ME"; + contname2 += "ME"; + cutname += "ME"; + cutname2 += "ME"; + counter+= "ME"; + } + + + + outputfile += "Dphi_DStar"; + outputfileMC += "Dphi_DStar"; + outputfile += particle; + outputfileMC += particle; + cutname += particle; + cutname2 += particle; + contname += particle; + contname2 += particle; + counter+= particle; + + if(UseEffic){ + outputfile += "_EffY_"; + outputfileMC += "_EffY_"; + contname += "_EffY_"; + contname2 += "_EffY_"; + cutname += "_EffY_"; + cutname2 += "_EffY_"; + counter+= "_EffY_"; + } + + if(!UseEffic){ + outputfile += "_EffN_"; + outputfileMC += "_EffN_"; + contname += "_EffN_"; + contname2 += "_EffN_"; + cutname += "_EffN_"; + cutname2 += "_EffN_"; + counter+= "_EffN_"; + } + + if(UseDEffic){ + TString string = "DEffY_"; + + if(var == AliAnalysisTaskDStarCorrelations::kNone) string += "vsPt_"; + if(var == AliAnalysisTaskDStarCorrelations::kMult) string += "vsPtMult_"; + if(var == AliAnalysisTaskDStarCorrelations::kCentr) string += "vsPCentrt_"; + if(var == AliAnalysisTaskDStarCorrelations::kRapidity) string += "vsPtY_"; + if(var == AliAnalysisTaskDStarCorrelations::kEta) string += "vsPtEta_"; + + outputfile += string; + outputfileMC += string; + contname += string; + contname2 += string; + cutname += string; + cutname2 += string; + counter+= string; + } + + if(!UseDEffic){ + outputfile += "DEffN_"; + outputfileMC += "DEffN_"; + contname += "DEffN_"; + contname2 += "DEffN_"; + cutname += "DEffN_"; + cutname2 += "DEffN_"; + counter+= "DEffN_"; + } + + + outputfile += Form("%d_bins_",nbins); + outputfileMC += Form("%d_bins_",nbins); + cutname += Form("%d_bins_",nbins); + cutname2 += Form("%d_bins_",nbins); + contname += Form("%d_bins_",nbins); + contname2 += Form("%d_bins_",nbins); + counter+= Form("%d_bins_",nbins); + + + outputfile += Form("task_%d",tasknumber); + outputfileMC += Form("task_%d",tasknumber); + cutname += Form("task_%d",tasknumber); + cutname2 += Form("task_%d",tasknumber); + contname += Form("task_%d",tasknumber); + contname2 += Form("task_%d",tasknumber); + counter+= Form("task_%d",tasknumber); + +/* outputfile += TrackCutObjNamePrefix; + outputfileMC += TrackCutObjNamePrefix; + cutname += TrackCutObjNamePrefix; + cutname2 += TrackCutObjNamePrefix; + contname += TrackCutObjNamePrefix; + contname2 += TrackCutObjNamePrefix; + counter+= TrackCutObjNamePrefix; +*/ + outputfile += selectMCproc; + outputfileMC += selectMCproc; + cutname += selectMCproc; + cutname2 += selectMCproc; + contname += selectMCproc; + contname2 += selectMCproc; + counter+= selectMCproc; + + TString reco = ""; + + if(UseReco) reco = "_reco"; + if(!UseReco) { + if(UseHadChannelinMC) reco = "_MCTruthHadChan"; + if(!UseHadChannelinMC) reco = "_MCTruthAllChan"; + } + outputfile += reco; + outputfileMC += reco; + cutname += reco; + cutname2 += reco; + contname += reco; + contname2 += reco; + counter+= reco; + + TString nsigma = Form("_%.0f_%.0f%.0f%.0f_sigmas",DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh); + + //cout << "nsigma string = "<< nsigma << endl; + + outputfile += nsigma; + outputfileMC += nsigma; + cutname += nsigma; + cutname2 += nsigma; + contname += nsigma; + contname2 += nsigma; + counter+= nsigma; + + + cout << contname << endl; + cout << contname2 << endl; + cout << cutname << endl; + cout << cutname2 << endl; + cout << counter << endl; + cout << outputfile << endl; + //return; + + mgr->AddTask(task); + // ------ input data ------ + AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); + + // ----- output data ----- + + // output TH1I for event counting + + //TLists + AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); + AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(contname2, TList::Class(),AliAnalysisManager::kOutputContainer,outputfileMC.Data()); + // Cut Objects + AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(cutname,AliRDHFCutsDStartoKpipi::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts D + AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(cutname2,AliHFAssociatedTrackCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts tracks + // Normalization Counter + AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(counter,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); + + + mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task,1,coutput1); + mgr->ConnectOutput(task,2,coutput2); + mgr->ConnectOutput(task,3,coutput3); + mgr->ConnectOutput(task,4,coutput4); + mgr->ConnectOutput(task,5,coutput5); + + return task ; + +} + diff --git a/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.cxx b/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.cxx index 57a54e296bc..86453027ee6 100644 --- a/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.cxx +++ b/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.cxx @@ -1,2885 +1,2885 @@ -/************************************************************************** -* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ -// -// Flow task -// -// Authors: -// Raphaelle Bailhache -// Theodor Rascanu -// -#include "TROOT.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TChain.h" -#include "TVector2.h" -#include "THnSparse.h" -#include "TMath.h" -#include "TRandom3.h" -#include "TProfile.h" -#include "TProfile2D.h" -#include "TLorentzVector.h" -#include "TParticle.h" -#include "TF1.h" - -#include -#include - -#include "AliVEventHandler.h" -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" - -#include "AliVEvent.h" -#include "AliESDInputHandler.h" -#include "AliMCEvent.h" -#include "AliESD.h" -#include "AliESDEvent.h" -#include "AliPID.h" -#include "AliPIDResponse.h" -#include "AliESDVZERO.h" -#include "AliESDUtils.h" -#include "AliMCParticle.h" -#include "AliAODMCParticle.h" -#include "AliAODEvent.h" -#include "AliAODVertex.h" -#include "AliAODTrack.h" -#include "AliVTrack.h" -#include "AliESDtrack.h" -#include "AliESDtrackCuts.h" -#include "AliAODTrack.h" -#include "AliStack.h" -#include "AliMCEvent.h" - -#include "AliFlowCandidateTrack.h" -#include "AliFlowEvent.h" -#include "AliFlowTrackCuts.h" -#include "AliFlowVector.h" -#include "AliFlowCommonConstants.h" -#include "AliKFParticle.h" -#include "AliKFVertex.h" - -#include "AliHFEcuts.h" -#include "AliHFEpid.h" -#include "AliHFEpidQAmanager.h" -#include "AliHFEtools.h" -#include "AliHFEVZEROEventPlane.h" - -#include "AliCentrality.h" -#include "AliEventplane.h" -#include "AliAnalysisTaskFlowTPCTOFEPSP.h" -#include "AliAODMCHeader.h" -#include "TClonesArray.h" -#include "AliHFENonPhotonicElectron.h" - -ClassImp(AliAnalysisTaskFlowTPCTOFEPSP) - -//____________________________________________________________________ -AliAnalysisTaskFlowTPCTOFEPSP::AliAnalysisTaskFlowTPCTOFEPSP() : - AliAnalysisTaskSE(), - fListHist(0x0), - fAODAnalysis(kFALSE), - fFilter(1<<4), - fAODMCHeader(NULL), - fAODArrayMCInfo(NULL), - fBackgroundSubtraction(NULL), - fVZEROEventPlane(kFALSE), - fVZEROEventPlaneA(kFALSE), - fVZEROEventPlaneC(kFALSE), - fSubEtaGapTPC(kFALSE), - fEtaGap(0.0), - fNbBinsCentralityQCumulant(4), - fNbBinsPtQCumulant(12), - fMinPtQCumulant(0.2), - fMaxPtQCumulant(6.0), - fAfterBurnerOn(kFALSE), - fNonFlowNumberOfTrackClones(0), - fV1(0.), - fV2(0.), - fV3(0.), - fV4(0.), - fV5(0.), - fMaxNumberOfIterations(100), - fPrecisionPhi(0.001), - fUseMCReactionPlane(kFALSE), - fSP(kFALSE), - fMCPID(kFALSE), - fNoPID(kFALSE), - fChi2OverNDFCut(3.0), - fMaxdca(3.0), - fMaxopeningtheta(0.02), - fMaxopeningphi(0.1), - fMaxopening3D(0.1), - fMaxInvmass(0.1), - fSetMassConstraint(kFALSE), - fMonitorEventPlane(kFALSE), - fMonitorContamination(kFALSE), - fMonitorPhotonic(kFALSE), - fMonitorWithoutPID(kFALSE), - fMonitorTrackCuts(kFALSE), - fMonitorQCumulant(kFALSE), - fcutsRP(0), - fcutsPOI(0), - fHFECuts(0), - fPID(0), - fPIDTOFOnly(0), - fPIDqa(0), - fflowEvent(NULL), - fHFEBackgroundCuts(0), - fPIDBackground(0), - fPIDBackgroundqa(0), - fAlgorithmMA(kTRUE), - fArraytrack(NULL), - fCounterPoolBackground(0), - fHFEVZEROEventPlane(0x0), - fHistEV(0), - fHistPileUp(0), - fPileUpCut(kFALSE), - fEventPlane(0x0), - fEventPlaneaftersubtraction(0x0), - fFractionContamination(0x0), - fContaminationv2(0x0), - fCosSin2phiep(0x0), - fCos2phie(0x0), - fSin2phie(0x0), - fCos2phiep(0x0), - fSin2phiep(0x0), - fSin2phiephiep(0x0), - fCosResabc(0x0), - fSinResabc(0x0), - fProfileCosResab(0x0), - fProfileCosResac(0x0), - fProfileCosResbc(0x0), - fCosRes(0x0), - fSinRes(0x0), - fProfileCosRes(0x0), - fTrackingCuts(0x0), - fDeltaPhiMapsBeforePID(0x0), - fCosPhiMapsBeforePID(0x0), - fDeltaPhiMaps(0x0), - fDeltaPhiMapsContamination(0x0), - fCosPhiMaps(0x0), - fProfileCosPhiMaps(0x0), - fDeltaPhiMapsTaggedPhotonic(0x0), - //fCosPhiMapsTaggedPhotonic(0x0), - fDeltaPhiMapsTaggedNonPhotonic(0x0), - //fCosPhiMapsTaggedNonPhotonic(0x0), - fDeltaPhiMapsTaggedPhotonicLS(0x0), - //fCosPhiMapsTaggedPhotonicLS(0x0), - fMCSourceDeltaPhiMaps(0x0), - fOppSignDeltaPhiMaps(0x0), - fSameSignDeltaPhiMaps(0x0), - fOppSignAngle(0x0), - fSameSignAngle(0x0), - fDebugStreamer(0) -{ - // Constructor - - for(Int_t k = 0; k < 10; k++) { - fBinCentralityLess[k] = 0.0; - } - for(Int_t k = 0; k < 11; k++) { - fContamination[k] = NULL; - fv2contamination[k] = NULL; - } - -} -//______________________________________________________________________________ -AliAnalysisTaskFlowTPCTOFEPSP:: AliAnalysisTaskFlowTPCTOFEPSP(const char *name) : - AliAnalysisTaskSE(name), - fListHist(0x0), - fAODAnalysis(kFALSE), - fFilter(1<<4), - fAODMCHeader(NULL), - fAODArrayMCInfo(NULL), - fBackgroundSubtraction(NULL), - fVZEROEventPlane(kFALSE), - fVZEROEventPlaneA(kFALSE), - fVZEROEventPlaneC(kFALSE), - fSubEtaGapTPC(kFALSE), - fEtaGap(0.0), - fNbBinsCentralityQCumulant(4), - fNbBinsPtQCumulant(15), - fMinPtQCumulant(0.0), - fMaxPtQCumulant(6.0), - fAfterBurnerOn(kFALSE), - fNonFlowNumberOfTrackClones(0), - fV1(0.), - fV2(0.), - fV3(0.), - fV4(0.), - fV5(0.), - fMaxNumberOfIterations(100), - fPrecisionPhi(0.001), - fUseMCReactionPlane(kFALSE), - fSP(kFALSE), - fMCPID(kFALSE), - fNoPID(kFALSE), - fChi2OverNDFCut(3.0), - fMaxdca(3.0), - fMaxopeningtheta(0.02), - fMaxopeningphi(0.1), - fMaxopening3D(0.1), - fMaxInvmass(0.1), - fSetMassConstraint(kFALSE), - fMonitorEventPlane(kFALSE), - fMonitorContamination(kFALSE), - fMonitorPhotonic(kFALSE), - fMonitorWithoutPID(kFALSE), - fMonitorTrackCuts(kFALSE), - fMonitorQCumulant(kFALSE), - fcutsRP(0), - fcutsPOI(0), - fHFECuts(0), - fPID(0), - fPIDTOFOnly(0), - fPIDqa(0), - fflowEvent(NULL), - fHFEBackgroundCuts(0), - fPIDBackground(0), - fPIDBackgroundqa(0), - fAlgorithmMA(kTRUE), - fArraytrack(NULL), - fCounterPoolBackground(0), - fHFEVZEROEventPlane(0x0), - fHistEV(0), - fHistPileUp(0), - fPileUpCut(kFALSE), - fEventPlane(0x0), - fEventPlaneaftersubtraction(0x0), - fFractionContamination(0x0), - fContaminationv2(0x0), - fCosSin2phiep(0x0), - fCos2phie(0x0), - fSin2phie(0x0), - fCos2phiep(0x0), - fSin2phiep(0x0), - fSin2phiephiep(0x0), - fCosResabc(0x0), - fSinResabc(0x0), - fProfileCosResab(0x0), - fProfileCosResac(0x0), - fProfileCosResbc(0x0), - fCosRes(0x0), - fSinRes(0x0), - fProfileCosRes(0x0), - fTrackingCuts(0x0), - fDeltaPhiMapsBeforePID(0x0), - fCosPhiMapsBeforePID(0x0), - fDeltaPhiMaps(0x0), - fDeltaPhiMapsContamination(0x0), - fCosPhiMaps(0x0), - fProfileCosPhiMaps(0x0), - fDeltaPhiMapsTaggedPhotonic(0x0), - //fCosPhiMapsTaggedPhotonic(0x0), - fDeltaPhiMapsTaggedNonPhotonic(0x0), - //fCosPhiMapsTaggedNonPhotonic(0x0), - fDeltaPhiMapsTaggedPhotonicLS(0x0), - //fCosPhiMapsTaggedPhotonicLS(0x0), - fMCSourceDeltaPhiMaps(0x0), - fOppSignDeltaPhiMaps(0x0), - fSameSignDeltaPhiMaps(0x0), - fOppSignAngle(0x0), - fSameSignAngle(0x0), - fDebugStreamer(0) -{ - // - // named ctor - // - - for(Int_t k = 0; k < 10; k++) { - fBinCentralityLess[k] = 0.0; - } - fBinCentralityLess[0] = 0.0; - fBinCentralityLess[1] = 20.0; - fBinCentralityLess[2] = 40.0; - fBinCentralityLess[3] = 60.0; - fBinCentralityLess[4] = 80.0; - - for(Int_t k = 0; k < 11; k++) { - fContamination[k] = NULL; - fv2contamination[k] = NULL; - } - - fPID = new AliHFEpid("hfePid"); - fPIDqa = new AliHFEpidQAmanager; - - fPIDBackground = new AliHFEpid("hfePidBackground"); - fPIDBackgroundqa = new AliHFEpidQAmanager; - - fPIDTOFOnly = new AliHFEpid("hfePidTOFOnly"); - - DefineInput(0,TChain::Class()); - DefineOutput(1, TList::Class()); - //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { - // DefineOutput(bincless+2,AliFlowEventSimple::Class()); - //} - -} -//____________________________________________________________ -AliAnalysisTaskFlowTPCTOFEPSP::AliAnalysisTaskFlowTPCTOFEPSP(const AliAnalysisTaskFlowTPCTOFEPSP &ref): - AliAnalysisTaskSE(ref), - fListHist(NULL), - fAODAnalysis(ref.fAODAnalysis), - fFilter(ref.fFilter), - fAODMCHeader(ref.fAODMCHeader), - fAODArrayMCInfo(ref.fAODArrayMCInfo), - fBackgroundSubtraction(ref.fBackgroundSubtraction), - fVZEROEventPlane(ref.fVZEROEventPlane), - fVZEROEventPlaneA(ref.fVZEROEventPlaneA), - fVZEROEventPlaneC(ref.fVZEROEventPlaneC), - fSubEtaGapTPC(ref.fSubEtaGapTPC), - fEtaGap(ref.fEtaGap), - fNbBinsCentralityQCumulant(ref.fNbBinsCentralityQCumulant), - fNbBinsPtQCumulant(ref.fNbBinsPtQCumulant), - fMinPtQCumulant(ref.fMinPtQCumulant), - fMaxPtQCumulant(ref.fMaxPtQCumulant), - fAfterBurnerOn(ref.fAfterBurnerOn), - fNonFlowNumberOfTrackClones(ref.fNonFlowNumberOfTrackClones), - fV1(ref.fV1), - fV2(ref.fV2), - fV3(ref.fV3), - fV4(ref.fV4), - fV5(ref.fV5), - fMaxNumberOfIterations(ref.fMaxNumberOfIterations), - fPrecisionPhi(ref.fPrecisionPhi), - fUseMCReactionPlane(ref.fUseMCReactionPlane), - fSP(ref.fSP), - fMCPID(ref.fMCPID), - fNoPID(ref.fNoPID), - fChi2OverNDFCut(ref.fChi2OverNDFCut), - fMaxdca(ref.fMaxdca), - fMaxopeningtheta(ref.fMaxopeningtheta), - fMaxopeningphi(ref.fMaxopeningphi), - fMaxopening3D(ref.fMaxopening3D), - fMaxInvmass(ref.fMaxInvmass), - fSetMassConstraint(ref.fSetMassConstraint), - fMonitorEventPlane(ref.fMonitorEventPlane), - fMonitorContamination(ref.fMonitorContamination), - fMonitorPhotonic(ref.fMonitorPhotonic), - fMonitorWithoutPID(ref.fMonitorWithoutPID), - fMonitorTrackCuts(ref.fMonitorTrackCuts), - fMonitorQCumulant(ref.fMonitorQCumulant), - fcutsRP(NULL), - fcutsPOI(NULL), - fHFECuts(NULL), - fPID(NULL), - fPIDTOFOnly(NULL), - fPIDqa(NULL), - fflowEvent(NULL), - fHFEBackgroundCuts(NULL), - fPIDBackground(NULL), - fPIDBackgroundqa(NULL), - fAlgorithmMA(ref.fAlgorithmMA), - fArraytrack(NULL), - fCounterPoolBackground(ref.fCounterPoolBackground), - fHFEVZEROEventPlane(NULL), - fHistEV(NULL), - fHistPileUp(NULL), - fPileUpCut(kFALSE), - fEventPlane(NULL), - fEventPlaneaftersubtraction(NULL), - fFractionContamination(NULL), - fContaminationv2(NULL), - fCosSin2phiep(NULL), - fCos2phie(NULL), - fSin2phie(NULL), - fCos2phiep(NULL), - fSin2phiep(NULL), - fSin2phiephiep(NULL), - fCosResabc(NULL), - fSinResabc(NULL), - fProfileCosResab(NULL), - fProfileCosResac(NULL), - fProfileCosResbc(NULL), - fCosRes(NULL), - fSinRes(NULL), - fProfileCosRes(NULL), - fTrackingCuts(NULL), - fDeltaPhiMapsBeforePID(NULL), - fCosPhiMapsBeforePID(NULL), - fDeltaPhiMaps(NULL), - fDeltaPhiMapsContamination(NULL), - fCosPhiMaps(NULL), - fProfileCosPhiMaps(NULL), - fDeltaPhiMapsTaggedPhotonic(NULL), - //fCosPhiMapsTaggedPhotonic(NULL), - fDeltaPhiMapsTaggedNonPhotonic(NULL), - //fCosPhiMapsTaggedNonPhotonic(NULL), - fDeltaPhiMapsTaggedPhotonicLS(NULL), - //fCosPhiMapsTaggedPhotonicLS(NULL), - fMCSourceDeltaPhiMaps(NULL), - fOppSignDeltaPhiMaps(NULL), - fSameSignDeltaPhiMaps(NULL), - fOppSignAngle(NULL), - fSameSignAngle(NULL), - fDebugStreamer(0) -{ - // - // Copy Constructor - // - - for(Int_t k = 0; k < 10; k++) { - fBinCentralityLess[k] = 0.0; - } - for(Int_t k = 0; k < 11; k++) { - fContamination[k] = NULL; - fv2contamination[k] = NULL; - } - - - ref.Copy(*this); -} - -//____________________________________________________________ -AliAnalysisTaskFlowTPCTOFEPSP &AliAnalysisTaskFlowTPCTOFEPSP::operator=(const AliAnalysisTaskFlowTPCTOFEPSP &ref){ - // - // Assignment operator - // - if(this == &ref) - ref.Copy(*this); - return *this; -} - -//____________________________________________________________ -void AliAnalysisTaskFlowTPCTOFEPSP::Copy(TObject &o) const { - // - // Copy into object o - // - AliAnalysisTaskFlowTPCTOFEPSP &target = dynamic_cast(o); - target.fListHist = fListHist; - target.fAODAnalysis = fAODAnalysis; - target.fFilter = fFilter; - target.fAODMCHeader = fAODMCHeader; - target.fAODArrayMCInfo = fAODArrayMCInfo; - target.fBackgroundSubtraction = fBackgroundSubtraction; - target.fVZEROEventPlane = fVZEROEventPlane; - target.fVZEROEventPlaneA = fVZEROEventPlaneA; - target.fVZEROEventPlaneC = fVZEROEventPlaneC; - target.fSubEtaGapTPC = fSubEtaGapTPC; - target.fEtaGap = fEtaGap; - target.fNbBinsCentralityQCumulant = fNbBinsCentralityQCumulant; - target.fNbBinsPtQCumulant = fNbBinsPtQCumulant; - target.fMinPtQCumulant = fMinPtQCumulant; - target.fMaxPtQCumulant = fMaxPtQCumulant; - target.fAfterBurnerOn = fAfterBurnerOn; - target.fNonFlowNumberOfTrackClones = fNonFlowNumberOfTrackClones; - target.fV1 = fV1; - target.fV2 = fV2; - target.fV3 = fV3; - target.fV4 = fV4; - target.fV5 = fV5; - target.fMaxNumberOfIterations = fMaxNumberOfIterations; - target.fPrecisionPhi = fPrecisionPhi; - target.fUseMCReactionPlane = fUseMCReactionPlane; - target.fSP = fSP; - target.fMCPID = fMCPID; - target.fNoPID = fNoPID; - target.fChi2OverNDFCut = fChi2OverNDFCut; - target.fMaxdca = fMaxdca; - target.fMaxopeningtheta = fMaxopeningtheta; - target.fMaxopeningphi = fMaxopeningphi; - target.fMaxopening3D = fMaxopening3D; - target.fMaxInvmass = fMaxInvmass; - target.fSetMassConstraint = fSetMassConstraint; - target.fMonitorEventPlane = fMonitorEventPlane; - target.fMonitorContamination = fMonitorContamination; - target.fMonitorPhotonic = fMonitorPhotonic; - target.fMonitorWithoutPID = fMonitorWithoutPID; - target.fMonitorTrackCuts = fMonitorTrackCuts; - target.fMonitorQCumulant = fMonitorQCumulant; - target.fcutsRP = fcutsRP; - target.fcutsPOI = fcutsPOI; - target.fHFECuts = fHFECuts; - target.fPID = fPID; - target.fPIDTOFOnly = fPIDTOFOnly; - target.fPIDqa = fPIDqa; - target.fflowEvent = fflowEvent; - target.fHFEBackgroundCuts = fHFEBackgroundCuts; - target.fPIDBackground = fPIDBackground; - target.fPIDBackgroundqa = fPIDBackgroundqa; - target.fAlgorithmMA = fAlgorithmMA; - target.fArraytrack = fArraytrack; - target.fCounterPoolBackground = fCounterPoolBackground; - target.fHFEVZEROEventPlane = fHFEVZEROEventPlane; - target.fHistEV=fHistEV; - target.fHistPileUp=fHistPileUp; - target.fPileUpCut=fPileUpCut; - target.fEventPlane=fEventPlane; - target.fEventPlaneaftersubtraction=fEventPlaneaftersubtraction; - target.fFractionContamination=fFractionContamination; - target.fContaminationv2=fContaminationv2; - target.fCosSin2phiep=fCosSin2phiep; - target.fCos2phie=fCos2phie; - target.fSin2phie=fSin2phie; - target.fCos2phiep=fCos2phiep; - target.fSin2phiep=fSin2phiep; - target.fSin2phiephiep=fSin2phiephiep; - target.fCosResabc=fCosResabc; - target.fSinResabc=fSinResabc; - target.fProfileCosResab=fProfileCosResab; - target.fProfileCosResac=fProfileCosResac; - target.fProfileCosResbc=fProfileCosResbc; - target.fCosRes=fCosRes; - target.fSinRes=fSinRes; - target.fProfileCosRes=fProfileCosRes; - target.fTrackingCuts=fTrackingCuts; - target.fDeltaPhiMapsBeforePID=fDeltaPhiMapsBeforePID; - target.fCosPhiMapsBeforePID=fCosPhiMapsBeforePID; - target.fDeltaPhiMaps=fDeltaPhiMaps; - target.fDeltaPhiMapsContamination=fDeltaPhiMapsContamination; - target.fCosPhiMaps=fCosPhiMaps; - target.fProfileCosPhiMaps=fProfileCosPhiMaps; - target.fDeltaPhiMapsTaggedPhotonic=fDeltaPhiMapsTaggedPhotonic; - target.fDeltaPhiMapsTaggedNonPhotonic=fDeltaPhiMapsTaggedNonPhotonic; - target.fDeltaPhiMapsTaggedPhotonicLS=fDeltaPhiMapsTaggedPhotonicLS; - target.fMCSourceDeltaPhiMaps=fMCSourceDeltaPhiMaps; - target.fOppSignDeltaPhiMaps=fOppSignDeltaPhiMaps; - target.fSameSignDeltaPhiMaps=fSameSignDeltaPhiMaps; - target.fOppSignAngle=fOppSignAngle; - target.fSameSignAngle=fSameSignAngle; - - - for(Int_t k = 0; k < 10; k++) { - target.fBinCentralityLess[k] = fBinCentralityLess[k]; - } - for(Int_t k = 0; k < 11; k++) { - target.fContamination[k] = fContamination[k]; - target.fv2contamination[k] = fv2contamination[k]; - } - target.fDebugStreamer=fDebugStreamer; -} -//____________________________________________________________ -AliAnalysisTaskFlowTPCTOFEPSP::~AliAnalysisTaskFlowTPCTOFEPSP(){ - // - // Destructor - // - - - if(fArraytrack) delete fArraytrack; - if(fListHist) delete fListHist; - if(fcutsRP) delete fcutsRP; - if(fcutsPOI) delete fcutsPOI; - if(fHFECuts) delete fHFECuts; - if(fPID) delete fPID; - if(fPIDTOFOnly) delete fPIDTOFOnly; - //if(fPIDqa) delete fPIDqa; - if(fflowEvent) delete fflowEvent; - if(fHFEBackgroundCuts) delete fHFEBackgroundCuts; - if(fPIDBackground) delete fPIDBackground; - //if(fBackgroundSubtraction) delete fBackgroundSubtraction; - //if(fPIDBackgroundqa) delete fPIDBackgroundqa; - //if(fHFEVZEROEventPlane) delete fHFEVZEROEventPlane; - if ( fDebugStreamer ) delete fDebugStreamer; - - -} -//________________________________________________________________________ -void AliAnalysisTaskFlowTPCTOFEPSP::UserCreateOutputObjects() -{ - - //******************** - // Create histograms - //******************** - - //************** - // Cuts - //************** - - //---------Data selection---------- - //kMC, kGlobal, kTPCstandalone, kSPDtracklet, kPMD - //AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; - //AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal; - - //---------Parameter mixing-------- - //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt - //AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure; - //AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure; - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: User create output objects"); - - - // AOD or ESD - AliVEventHandler *inputHandler = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); - if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){ - SetAODAnalysis(kTRUE); - AliDebug(2,"Put AOD analysis on"); - } else { - SetAODAnalysis(kFALSE); - } - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: AOD ESD"); - - // RP TRACK CUTS: - fcutsRP = AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010(); - fcutsRP->SetName("StandartTPC"); - fcutsRP->SetEtaRange(-0.9,0.9); - fcutsRP->SetQA(kTRUE); - //TList *qaCutsRP = fcutsRP->GetQA(); - //qaCutsRP->SetName("QA_StandartTPC_RP"); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cutsRP"); - - //POI TRACK CUTS: - fcutsPOI = new AliFlowTrackCuts("dummy"); - fcutsPOI->SetParamType(AliFlowTrackCuts::kGlobal); - fcutsPOI->SetPtRange(+1,-1); // select nothing QUICK - fcutsPOI->SetEtaRange(+1,-1); // select nothing VZERO - - if( fflowEvent ){ - fflowEvent->~AliFlowEvent(); - new(fflowEvent) AliFlowEvent(fcutsRP,fcutsPOI); - } - else fflowEvent = new AliFlowEvent(fcutsRP,fcutsPOI); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cutsPOI"); - - // Flow - AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster(); - cc->SetNbinsMult(10000); - cc->SetMultMin(0); - cc->SetMultMax(10000.); - cc->SetNbinsPt(fNbBinsPtQCumulant); - cc->SetPtMin(fMinPtQCumulant); - cc->SetPtMax(fMaxPtQCumulant); - cc->SetNbinsPhi(180); - cc->SetPhiMin(0.0); - cc->SetPhiMax(TMath::TwoPi()); - cc->SetNbinsEta(200); - cc->SetEtaMin(-0.9); - cc->SetEtaMax(+0.9); - cc->SetNbinsQ(500); - cc->SetQMin(0.0); - cc->SetQMax(3.0); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: common constants"); - - // HFE cuts - - if(!fHFECuts){ - fHFECuts = new AliHFEcuts; - fHFECuts->CreateStandardCuts(); - } - fHFECuts->Initialize(); - if(fAODAnalysis) fHFECuts->SetAOD(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: HFE cuts"); - - - // PID HFE - //fPID->SetHasMCData(HasMCData()); - if(!fPID) { - fPID =new AliHFEpid("hfePid"); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid init 0"); - } - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid init 1"); - if(!fPID->GetNumberOfPIDdetectors()) fPID->AddDetector("TPC", 0); - AliDebug(2,Form("AliAnalysisTaskFlowTPCTOFEPSP: GetNumber of PID detectors %d",fPID->GetNumberOfPIDdetectors())); - fPID->InitializePID(); - fPIDqa->Initialize(fPID); - fPID->SortDetectors(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid and pidqa"); - - if(!fPIDTOFOnly->GetNumberOfPIDdetectors()) { - fPIDTOFOnly->AddDetector("TOF", 0); - fPIDTOFOnly->ConfigureTOF(3.); - } - fPIDTOFOnly->InitializePID(); - fPIDTOFOnly->SortDetectors(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pidtof"); - - // HFE Background cuts - - if(!fHFEBackgroundCuts){ - fHFEBackgroundCuts = new AliESDtrackCuts(); - fHFEBackgroundCuts->SetName("nackgroundcuts"); - //Configure Default Track Cuts - fHFEBackgroundCuts->SetAcceptKinkDaughters(kFALSE); - fHFEBackgroundCuts->SetRequireTPCRefit(kTRUE); - fHFEBackgroundCuts->SetEtaRange(-0.9,0.9); - fHFEBackgroundCuts->SetRequireSigmaToVertex(kTRUE); - fHFEBackgroundCuts->SetMaxChi2PerClusterTPC(4.0); - fHFEBackgroundCuts->SetMinNClustersTPC(50); - fHFEBackgroundCuts->SetPtRange(0.3,1e10); - } - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: hfe background"); - - // PID background HFE - if(!fPIDBackground->GetNumberOfPIDdetectors()) fPIDBackground->AddDetector("TPC", 0); - fPIDBackground->InitializePID(); - fPIDBackgroundqa->Initialize(fPIDBackground); - fPIDBackground->SortDetectors(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid background"); - - if (fMonitorPhotonic) { - if(!fBackgroundSubtraction) fBackgroundSubtraction = new AliHFENonPhotonicElectron(); - if(fAODAnalysis) fBackgroundSubtraction->SetAOD(kTRUE); - fBackgroundSubtraction->Init(); - } - - - - //************************** - // Bins for the THnSparse - //************************** - - /* - Int_t nBinsPt = 44; - Double_t minPt = 0.1; - Double_t maxPt = 20.0; - Double_t binLimLogPt[nBinsPt+1]; - Double_t binLimPt[nBinsPt+1]; - for(Int_t i=0; i<=nBinsPt; i++) binLimLogPt[i]=(Double_t)TMath::Log10(minPt) + (TMath::Log10(maxPt)-TMath::Log10(minPt))/nBinsPt*(Double_t)i ; - for(Int_t i=0; i<=nBinsPt; i++) binLimPt[i]=(Double_t)TMath::Power(10,binLimLogPt[i]); - */ - - Int_t nBinsPt = 20; - Double_t binLimPt[21] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, - 1.3, 1.4, 1.5, 2., 2.5, 3., 4., 6.}; - - Int_t nBinsPtPlus = fNbBinsPtQCumulant; - Double_t minPtPlus = fMinPtQCumulant; - Double_t maxPtPlus = fMaxPtQCumulant; - Double_t binLimPtPlus[nBinsPtPlus+1]; - for(Int_t i=0; i<=nBinsPtPlus; i++) binLimPtPlus[i]=(Double_t)minPtPlus + (maxPtPlus-minPtPlus)/nBinsPtPlus*(Double_t)i ; - - Int_t nBinsEta = 8; - Double_t minEta = -0.8; - Double_t maxEta = 0.8; - Double_t binLimEta[nBinsEta+1]; - for(Int_t i=0; i<=nBinsEta; i++) binLimEta[i]=(Double_t)minEta + (maxEta-minEta)/nBinsEta*(Double_t)i ; - - Int_t nBinsStep = 6; - Double_t minStep = 0.; - Double_t maxStep = 6.; - Double_t binLimStep[nBinsStep+1]; - for(Int_t i=0; i<=nBinsStep; i++) binLimStep[i]=(Double_t)minStep + (maxStep-minStep)/nBinsStep*(Double_t)i ; - - Int_t nBinsEtaLess = 2; - Double_t binLimEtaLess[nBinsEtaLess+1]; - for(Int_t i=0; i<=nBinsEtaLess; i++) binLimEtaLess[i]=(Double_t)minEta + (maxEta-minEta)/nBinsEtaLess*(Double_t)i ; - - Int_t nBinsCos = 50; - Double_t minCos = -1.0; - Double_t maxCos = 1.0; - Double_t binLimCos[nBinsCos+1]; - for(Int_t i=0; i<=nBinsCos; i++) binLimCos[i]=(Double_t)minCos + (maxCos-minCos)/nBinsCos*(Double_t)i ; - - // Int_t nBinsCosSP = 50; - // Double_t minCosSP = -100.0; - // Double_t maxCosSP = 100.0; - // Double_t binLimCosSP[nBinsCosSP+1]; - // for(Int_t i=0; i<=nBinsCosSP; i++) binLimCosSP[i]=(Double_t)minCosSP + (maxCosSP-minCosSP)/nBinsCosSP*(Double_t)i ; - - Int_t nBinsC = 11; - Double_t minC = 0.0; - Double_t maxC = 11.0; - Double_t binLimC[nBinsC+1]; - for(Int_t i=0; i<=nBinsC; i++) binLimC[i]=(Double_t)minC + (maxC-minC)/nBinsC*(Double_t)i ; - - Int_t nBinsCMore = 20; - Double_t minCMore = 0.0; - Double_t maxCMore = 20.0; - Double_t binLimCMore[nBinsCMore+1]; - for(Int_t i=0; i<=nBinsCMore; i++) binLimCMore[i]=(Double_t)minCMore + (maxCMore-minCMore)/nBinsCMore*(Double_t)i ; - - Int_t nBinsCEvenMore = 100; - Double_t minCEvenMore = 0.0; - Double_t maxCEvenMore = 100.0; - Double_t binLimCEvenMore[nBinsCEvenMore+1]; - for(Int_t i=0; i<=nBinsCEvenMore; i++) binLimCEvenMore[i]=(Double_t)minCEvenMore + (maxCEvenMore-minCEvenMore)/nBinsCEvenMore*(Double_t)i ; - - Int_t nBinsPhi = 8; - Double_t minPhi = 0.0; - Double_t maxPhi = TMath::Pi(); - Double_t binLimPhi[nBinsPhi+1]; - for(Int_t i=0; i<=nBinsPhi; i++) { - binLimPhi[i]=(Double_t)minPhi + (maxPhi-minPhi)/nBinsPhi*(Double_t)i ; - AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i)); - } - - Int_t nBinsPhiLess = 2.0; - Double_t minPhiLess = 0.0; - Double_t maxPhiLess = 2.0; - Double_t binLimPhiLess[nBinsPhiLess+1]; - for(Int_t i=0; i<=nBinsPhiLess; i++) { - binLimPhiLess[i]=(Double_t)minPhiLess + (maxPhiLess-minPhiLess)/nBinsPhiLess*(Double_t)i ; - } - - Int_t nBinsTPCdEdx = 140; - Double_t minTPCdEdx = -12.0; - Double_t maxTPCdEdx = 12.0; - Double_t binLimTPCdEdx[nBinsTPCdEdx+1]; - for(Int_t i=0; i<=nBinsTPCdEdx; i++) { - binLimTPCdEdx[i]=(Double_t)minTPCdEdx + (maxTPCdEdx-minTPCdEdx)/nBinsTPCdEdx*(Double_t)i ; - } - - Int_t nBinsAngle = 40; - Double_t minAngle = 0.0; - Double_t maxAngle = 1.0; - Double_t binLimAngle[nBinsAngle+1]; - for(Int_t i=0; i<=nBinsAngle; i++) { - binLimAngle[i]=(Double_t)minAngle + (maxAngle-minAngle)/nBinsAngle*(Double_t)i ; - AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i)); - } - - Int_t nBinsCharge = 2; - Double_t minCharge = -1.0; - Double_t maxCharge = 1.0; - Double_t binLimCharge[nBinsCharge+1]; - for(Int_t i=0; i<=nBinsCharge; i++) binLimCharge[i]=(Double_t)minCharge + (maxCharge-minCharge)/nBinsCharge*(Double_t)i ; - - Int_t nBinsSource = 10; - Double_t minSource = 0.; - Double_t maxSource = 10.; - Double_t binLimSource[nBinsSource+1]; - for(Int_t i=0; i<=nBinsSource; i++) binLimSource[i]=(Double_t)minSource + (maxSource-minSource)/nBinsSource*(Double_t)i ; - - Int_t nBinsInvMass = 50; - Double_t minInvMass = 0.; - Double_t maxInvMass = 0.3; - Double_t binLimInvMass[nBinsInvMass+1]; - for(Int_t i=0; i<=nBinsInvMass; i++) binLimInvMass[i]=(Double_t)minInvMass + (maxInvMass-minInvMass)/nBinsInvMass*(Double_t)i ; - - Int_t nBinsMult = 100; - Double_t minMult = 0.; - Double_t maxMult = 3000; - Double_t binLimMult[nBinsMult+1]; - //for(Int_t i=0; i<=nBinsMult; i++) binLimMult[i]=TMath::Power((Double_t)minMult + (TMath::Sqrt(maxMult)-TMath::Sqrt(minMult))/nBinsMult*(Double_t)i,2); - for(Int_t i=0; i<=nBinsMult; i++) binLimMult[i]=(Double_t)minMult + (maxMult-minMult)/nBinsMult*(Double_t)i; - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: variables"); - - //****************** - // Histograms - //****************** - - fListHist = new TList(); - fListHist->SetOwner(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: list"); - - // Minimum histos - - // Histos - fHistEV = new TH2D("fHistEV", "events", 3, 0, 3, 3, 0,3); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: histev"); - - // V0 multiplicity vs # of tracks vs centraliy - const Int_t nDimPU=4; - Int_t nBinPU[nDimPU] = {nBinsCEvenMore,nBinsCEvenMore,nBinsMult,nBinsMult}; - fHistPileUp = new THnSparseF("PileUp","PileUp",nDimPU,nBinPU); - fHistPileUp->SetBinEdges(0,binLimCEvenMore); - fHistPileUp->SetBinEdges(1,binLimCEvenMore); - fHistPileUp->SetBinEdges(2,binLimMult); - fHistPileUp->SetBinEdges(3,binLimMult); - fHistPileUp->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane"); - - // Event plane as function of phiep, centrality - const Int_t nDima=4; - Int_t nBina[nDima] = {nBinsPhi,nBinsPhi,nBinsPhi,nBinsC}; - fEventPlane = new THnSparseF("EventPlane","EventPlane",nDima,nBina); - fEventPlane->SetBinEdges(0,binLimPhi); - fEventPlane->SetBinEdges(1,binLimPhi); - fEventPlane->SetBinEdges(2,binLimPhi); - fEventPlane->SetBinEdges(3,binLimC); - fEventPlane->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane"); - - // Fraction of contamination, centrality - const Int_t nDimcont=2; - Int_t nBincont[nDimcont] = {nBinsPt,nBinsC}; - fFractionContamination = new THnSparseF("Contamination","Contamination",nDimcont,nBincont); - fFractionContamination->SetBinEdges(0,binLimPt); - fFractionContamination->SetBinEdges(1,binLimC); - fFractionContamination->Sumw2(); - // - fContaminationv2 = new TProfile2D("Contaminationv2","",nBinsC,binLimC,nBinsPt,binLimPt); - fContaminationv2->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: fraction of contamination"); - - // Resolution cosres_abc centrality - const Int_t nDimfbis=4; - Int_t nBinfbis[nDimfbis] = {nBinsCos,nBinsCos,nBinsCos,nBinsCMore}; - fCosResabc = new THnSparseF("CosRes_abc","CosRes_abc",nDimfbis,nBinfbis); - fCosResabc->SetBinEdges(0,binLimCos); - fCosResabc->SetBinEdges(1,binLimCos); - fCosResabc->SetBinEdges(2,binLimCos); - fCosResabc->SetBinEdges(3,binLimCMore); - fCosResabc->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosresabc"); - - // Resolution cosres centrality - const Int_t nDimf=2; - Int_t nBinf[nDimf] = {nBinsCos, nBinsCMore}; - fCosRes = new THnSparseF("CosRes","CosRes",nDimf,nBinf); - fCosRes->SetBinEdges(0,binLimCos); - fCosRes->SetBinEdges(1,binLimCMore); - fCosRes->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosres"); - - // Maps delta phi - const Int_t nDimg=5; - Int_t nBing[nDimg] = {nBinsPhi,nBinsC,nBinsPt, nBinsCharge,nBinsEtaLess}; - fDeltaPhiMaps = new THnSparseF("DeltaPhiMaps","DeltaPhiMaps",nDimg,nBing); - fDeltaPhiMaps->SetBinEdges(0,binLimPhi); - fDeltaPhiMaps->SetBinEdges(1,binLimC); - fDeltaPhiMaps->SetBinEdges(2,binLimPt); - fDeltaPhiMaps->SetBinEdges(3,binLimCharge); - fDeltaPhiMaps->SetBinEdges(4,binLimEtaLess); - fDeltaPhiMaps->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimaps"); - - // Maps cos phi - const Int_t nDimh=5; - Int_t nBinh[nDimh] = {nBinsCos,nBinsC,nBinsPt,nBinsCharge,nBinsEtaLess}; - fCosPhiMaps = new THnSparseF("CosPhiMaps","CosPhiMaps",nDimh,nBinh); - fCosPhiMaps->SetBinEdges(0,binLimCos); - fCosPhiMaps->SetBinEdges(1,binLimC); - fCosPhiMaps->SetBinEdges(2,binLimPt); - fCosPhiMaps->SetBinEdges(3,binLimCharge); - fCosPhiMaps->SetBinEdges(4,binLimEtaLess); - fCosPhiMaps->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosphimaps"); - - // - // fMonitorEventPlane - // - // - - if(fMonitorEventPlane) { - // Event Plane after subtraction as function of phiep, centrality, pt, eta - const Int_t nDimb=2; - Int_t nBinb[nDimb] = {nBinsPhi, nBinsC}; - fEventPlaneaftersubtraction = new THnSparseF("EventPlane_aftersubtraction","EventPlane_aftersubtraction",nDimb,nBinb); - fEventPlaneaftersubtraction->SetBinEdges(0,binLimPhi); - fEventPlaneaftersubtraction->SetBinEdges(1,binLimC); - fEventPlaneaftersubtraction->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane after sub"); - - // Monitoring of the event Plane cos(2phi) sin(2phi) centrality - const Int_t nDimi=3; - Int_t nBini[nDimi] = {nBinsCos, nBinsCos, nBinsCMore}; - fCosSin2phiep = new THnSparseF("CosSin2phiep","CosSin2phiep",nDimi,nBini); - fCosSin2phiep->SetBinEdges(0,binLimCos); - fCosSin2phiep->SetBinEdges(1,binLimCos); - fCosSin2phiep->SetBinEdges(2,binLimCMore); - fCosSin2phiep->Sumw2(); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cossin2phiep"); - - // Monitoring Event plane after subtraction of the track - const Int_t nDime=4; - Int_t nBine[nDime] = {nBinsCos, nBinsC, nBinsPt, nBinsEta}; - fCos2phie = new THnSparseF("cos2phie","cos2phie",nDime,nBine); - fCos2phie->SetBinEdges(2,binLimPt); - fCos2phie->SetBinEdges(3,binLimEta); - fCos2phie->SetBinEdges(0,binLimCos); - fCos2phie->SetBinEdges(1,binLimC); - fCos2phie->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cos2phie"); - fSin2phie = new THnSparseF("sin2phie","sin2phie",nDime,nBine); - fSin2phie->SetBinEdges(2,binLimPt); - fSin2phie->SetBinEdges(3,binLimEta); - fSin2phie->SetBinEdges(0,binLimCos); - fSin2phie->SetBinEdges(1,binLimC); - fSin2phie->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phie"); - fCos2phiep = new THnSparseF("cos2phiep","cos2phiep",nDime,nBine); - fCos2phiep->SetBinEdges(2,binLimPt); - fCos2phiep->SetBinEdges(3,binLimEta); - fCos2phiep->SetBinEdges(0,binLimCos); - fCos2phiep->SetBinEdges(1,binLimC); - fCos2phiep->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cos2phiep"); - fSin2phiep = new THnSparseF("sin2phiep","sin2phiep",nDime,nBine); - fSin2phiep->SetBinEdges(2,binLimPt); - fSin2phiep->SetBinEdges(3,binLimEta); - fSin2phiep->SetBinEdges(0,binLimCos); - fSin2phiep->SetBinEdges(1,binLimC); - fSin2phiep->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phiep"); - fSin2phiephiep = new THnSparseF("sin2phie_phiep","sin2phie_phiep",nDime,nBine); - fSin2phiephiep->SetBinEdges(2,binLimPt); - fSin2phiephiep->SetBinEdges(3,binLimEta); - fSin2phiephiep->SetBinEdges(0,binLimCos); - fSin2phiephiep->SetBinEdges(1,binLimC); - fSin2phiephiep->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phiephiep"); - - const Int_t nDimfbiss=4; - Int_t nBinfbiss[nDimfbiss] = {nBinsCos,nBinsCos,nBinsCos,nBinsC}; - fSinResabc = new THnSparseF("SinRes_abc","SinRes_abc",nDimfbiss,nBinfbiss); - fSinResabc->SetBinEdges(0,binLimCos); - fSinResabc->SetBinEdges(1,binLimCos); - fSinResabc->SetBinEdges(2,binLimCos); - fSinResabc->SetBinEdges(3,binLimC); - fSinResabc->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sinresabc"); - - // Profile cosres centrality with 3 subevents - fProfileCosResab = new TProfile("ProfileCosRes_a_b","ProfileCosRes_a_b",nBinsCMore,binLimCMore); - fProfileCosResab->Sumw2(); - fProfileCosResac = new TProfile("ProfileCosRes_a_c","ProfileCosRes_a_c",nBinsCMore,binLimCMore); - fProfileCosResac->Sumw2(); - fProfileCosResbc = new TProfile("ProfileCosRes_b_c","ProfileCosRes_b_c",nBinsCMore,binLimCMore); - fProfileCosResbc->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosresbc"); - - // - const Int_t nDimff=2; - Int_t nBinff[nDimff] = {nBinsCos, nBinsC}; - fSinRes = new THnSparseF("SinRes","SinRes",nDimff,nBinff); - fSinRes->SetBinEdges(0,binLimCos); - fSinRes->SetBinEdges(1,binLimC); - fSinRes->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sinres"); - - // Profile cosres centrality - fProfileCosRes = new TProfile("ProfileCosRes","ProfileCosRes",nBinsCMore,binLimCMore); - fProfileCosRes->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosres"); - - // Profile Maps cos phi - fProfileCosPhiMaps = new TProfile2D("ProfileCosPhiMaps","ProfileCosPhiMaps",nBinsC,binLimC,nBinsPt,binLimPt); - fProfileCosPhiMaps->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosphimaps"); - - } - // - // fMonitorTrackCuts - // - - if(fMonitorTrackCuts) { - // Debugging tracking steps - const Int_t nDimTrStep=2; - Int_t nBinTrStep[nDimTrStep] = {nBinsPt,nBinsStep}; - fTrackingCuts = new THnSparseF("TrackingCuts","TrackingCuts",nDimTrStep,nBinTrStep); - fTrackingCuts->SetBinEdges(0,binLimPt); - fTrackingCuts->SetBinEdges(1,binLimStep); - fTrackingCuts->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: trackingcuts"); - } - - // - // fMonitorContamination - // - - if(fMonitorContamination) { - // Maps delta phi contamination - const Int_t nDimgcont=4; - Int_t nBingcont[nDimgcont] = {nBinsPhiLess,nBinsC,nBinsPt, nBinsTPCdEdx}; - fDeltaPhiMapsContamination = new THnSparseF("DeltaPhiMapsContamination","DeltaPhiMapsContamination",nDimgcont,nBingcont); - fDeltaPhiMapsContamination->SetBinEdges(0,binLimPhiLess); - fDeltaPhiMapsContamination->SetBinEdges(1,binLimC); - fDeltaPhiMapsContamination->SetBinEdges(2,binLimPt); - fDeltaPhiMapsContamination->SetBinEdges(3,binLimTPCdEdx); - fDeltaPhiMapsContamination->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapscontamination"); - - } - // - // fMonitorWithoutPID - // - - if(fMonitorWithoutPID) { - // - const Int_t nDimgb=3; - Int_t nBingb[nDimgb] = {nBinsPhi,nBinsC,nBinsPt}; - - fDeltaPhiMapsBeforePID = new THnSparseF("DeltaPhiMapsBeforePID","DeltaPhiMapsBeforePID",nDimgb,nBingb); - fDeltaPhiMapsBeforePID->SetBinEdges(0,binLimPhi); - fDeltaPhiMapsBeforePID->SetBinEdges(1,binLimC); - fDeltaPhiMapsBeforePID->SetBinEdges(2,binLimPt); - fDeltaPhiMapsBeforePID->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapsbeforepid"); - - const Int_t nDimhb=3; - Int_t nBinhb[nDimhb] = {nBinsCos,nBinsC,nBinsPt}; - - fCosPhiMapsBeforePID = new THnSparseF("CosPhiMapsBeforePID","CosPhiMapsBeforePID",nDimhb,nBinhb); - fCosPhiMapsBeforePID->SetBinEdges(0,binLimCos); - fCosPhiMapsBeforePID->SetBinEdges(1,binLimC); - fCosPhiMapsBeforePID->SetBinEdges(2,binLimPt); - fCosPhiMapsBeforePID->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosphimapsbeforepid"); - } - // - // fMonitorPhotonic - // - - if(fMonitorPhotonic) { - - const Int_t nDimgbp=3; - Int_t nBingbp[nDimgbp] = {nBinsPhi,nBinsC,nBinsPt}; - - fDeltaPhiMapsTaggedPhotonic = new THnSparseF("DeltaPhiMapsTaggedPhotonic","DeltaPhiMapsTaggedPhotonic",nDimgbp,nBingbp); - fDeltaPhiMapsTaggedPhotonic->SetBinEdges(0,binLimPhi); - fDeltaPhiMapsTaggedPhotonic->SetBinEdges(1,binLimC); - fDeltaPhiMapsTaggedPhotonic->SetBinEdges(2,binLimPt); - fDeltaPhiMapsTaggedPhotonic->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggedphotonic"); - - fDeltaPhiMapsTaggedNonPhotonic = new THnSparseF("DeltaPhiMapsTaggedNonPhotonic","DeltaPhiMapsTaggedNonPhotonic",nDimgbp,nBingbp); - fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(0,binLimPhi); - fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(1,binLimC); - fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(2,binLimPt); - fDeltaPhiMapsTaggedNonPhotonic->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggednonphotonic"); - - fDeltaPhiMapsTaggedPhotonicLS = new THnSparseF("DeltaPhiMapsTaggedPhotonicLS","DeltaPhiMapsTaggedPhotonicLS",nDimgbp,nBingbp); - fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(0,binLimPhi); - fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(1,binLimC); - fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(2,binLimPt); - fDeltaPhiMapsTaggedPhotonicLS->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggedphotonicls"); - - const Int_t nDimMCSource=3; - Int_t nBinMCSource[nDimMCSource] = {nBinsC,nBinsPt,nBinsSource}; - fMCSourceDeltaPhiMaps = new THnSparseF("MCSourceDeltaPhiMaps","MCSourceDeltaPhiMaps",nDimMCSource,nBinMCSource); - fMCSourceDeltaPhiMaps->SetBinEdges(0,binLimC); - fMCSourceDeltaPhiMaps->SetBinEdges(1,binLimPt); - fMCSourceDeltaPhiMaps->SetBinEdges(2,binLimSource); - fMCSourceDeltaPhiMaps->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: mcsourcedeltaphimaps"); - - // Maps invmass opposite - const Int_t nDimOppSign=5; - Int_t nBinOppSign[nDimOppSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource}; - fOppSignDeltaPhiMaps = new THnSparseF("OppSignDeltaPhiMaps","OppSignDeltaPhiMaps",nDimOppSign,nBinOppSign); - fOppSignDeltaPhiMaps->SetBinEdges(0,binLimPhi); - fOppSignDeltaPhiMaps->SetBinEdges(1,binLimC); - fOppSignDeltaPhiMaps->SetBinEdges(2,binLimPt); - fOppSignDeltaPhiMaps->SetBinEdges(3,binLimInvMass); - fOppSignDeltaPhiMaps->SetBinEdges(4,binLimSource); - fOppSignDeltaPhiMaps->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: oppsigndeltaphimaps"); - - // Maps invmass same sign - const Int_t nDimSameSign=5; - Int_t nBinSameSign[nDimSameSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource}; - fSameSignDeltaPhiMaps = new THnSparseF("SameSignDeltaPhiMaps","SameSignDeltaPhiMaps",nDimSameSign,nBinSameSign); - fSameSignDeltaPhiMaps->SetBinEdges(0,binLimPhi); - fSameSignDeltaPhiMaps->SetBinEdges(1,binLimC); - fSameSignDeltaPhiMaps->SetBinEdges(2,binLimPt); - fSameSignDeltaPhiMaps->SetBinEdges(3,binLimInvMass); - fSameSignDeltaPhiMaps->SetBinEdges(4,binLimSource); - fSameSignDeltaPhiMaps->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: samesigndeltaphimaps"); - - // Maps angle same sign - const Int_t nDimAngleSameSign=3; - Int_t nBinAngleSameSign[nDimAngleSameSign] = {nBinsAngle,nBinsC,nBinsSource}; - fSameSignAngle = new THnSparseF("SameSignAngleMaps","SameSignAngleMaps",nDimAngleSameSign,nBinAngleSameSign); - fSameSignAngle->SetBinEdges(0,binLimAngle); - fSameSignAngle->SetBinEdges(1,binLimC); - fSameSignAngle->SetBinEdges(2,binLimSource); - fSameSignAngle->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: samesignangle"); - - // Maps angle opp sign - const Int_t nDimAngleOppSign=3; - Int_t nBinAngleOppSign[nDimAngleOppSign] = {nBinsAngle,nBinsC,nBinsSource}; - fOppSignAngle = new THnSparseF("OppSignAngleMaps","OppSignAngleMaps",nDimAngleOppSign,nBinAngleOppSign); - fOppSignAngle->SetBinEdges(0,binLimAngle); - fOppSignAngle->SetBinEdges(1,binLimC); - fOppSignAngle->SetBinEdges(2,binLimSource); - fOppSignAngle->Sumw2(); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: oppsignangle"); - - } - - //************************** - // Add to the list - //****************************** - - fListHist->Add(fHistEV); - fListHist->Add(fHistPileUp); - fListHist->Add(fEventPlane); - fListHist->Add(fFractionContamination); - fListHist->Add(fCosRes); - fListHist->Add(fCosResabc); - fListHist->Add(fCosPhiMaps); - fListHist->Add(fDeltaPhiMaps); - fListHist->Add(fPIDqa->MakeList("HFEpidQA")); - fListHist->Add(fContaminationv2); - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add default"); - - if(fMonitorEventPlane) { - fListHist->Add(fProfileCosRes); - fListHist->Add(fProfileCosResab); - fListHist->Add(fProfileCosResac); - fListHist->Add(fProfileCosResbc); - fListHist->Add(fCosSin2phiep); - fListHist->Add(fCos2phie); - fListHist->Add(fSin2phie); - fListHist->Add(fCos2phiep); - fListHist->Add(fSin2phiep); - fListHist->Add(fSin2phiephiep); - fListHist->Add(fSinRes); - fListHist->Add(fSinResabc); - fListHist->Add(fProfileCosPhiMaps); - } - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add monitor"); - - if(fMonitorTrackCuts) fListHist->Add(fTrackingCuts); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add monitortrackcuts"); - - if(fMonitorContamination) { - fListHist->Add(fDeltaPhiMapsContamination); - } - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add deltaphimapscontamination"); - - if(fMonitorWithoutPID) { - fListHist->Add(fDeltaPhiMapsBeforePID); - fListHist->Add(fCosPhiMapsBeforePID); - } - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add without pid"); - - if(fMonitorPhotonic) { - fListHist->Add(fPIDBackgroundqa->MakeList("HFEpidBackgroundQA")); - fListHist->Add(fDeltaPhiMapsTaggedPhotonic); - fListHist->Add(fDeltaPhiMapsTaggedNonPhotonic); - fListHist->Add(fDeltaPhiMapsTaggedPhotonicLS); - fListHist->Add(fMCSourceDeltaPhiMaps); - fListHist->Add(fOppSignDeltaPhiMaps); - fListHist->Add(fSameSignDeltaPhiMaps); - fListHist->Add(fSameSignAngle); - fListHist->Add(fOppSignAngle); - fListHist->Add(fBackgroundSubtraction->GetListOutput()); - } - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add photonic"); - - if(fHFEVZEROEventPlane && fMonitorEventPlane) fListHist->Add(fHFEVZEROEventPlane->GetOutputList()); - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add event plane"); - - fListHist->Print(); - - PostData(1, fListHist); - //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { - // PostData(bincless+2,fflowEvent); - //} - - AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: post"); - - -} - -//________________________________________________________________________ -void AliAnalysisTaskFlowTPCTOFEPSP::UserExec(Option_t */*option*/) -{ - // - // Loop over event - // - - - Double_t massElectron = 0.000511; - Double_t mcReactionPlane = 0.0; - - Float_t cntr = 0.0; - Double_t binct = 11.5; - Double_t binctMore = 20.5; - Double_t binctLess = -0.5; - Float_t binctt = -1.0; - - Double_t valuecossinephiep[3]; - Double_t valuensparsea[4]; - Double_t valuensparseabis[5]; - Double_t valuensparsee[4]; - Double_t valuensparsef[2]; - Double_t valuensparsefsin[2]; - Double_t valuensparsefbis[4]; - Double_t valuensparsefbissin[4]; - Double_t valuensparseg[5]; - Double_t valuensparseh[5]; - Double_t valuensparsehprofile[3]; - Double_t valuensparseMCSourceDeltaPhiMaps[3]; - Double_t valuetrackingcuts[2]; - Double_t valuedeltaphicontamination[4]; - Double_t valuefractioncont[2]; - - AliMCEvent *mcEvent = MCEvent(); - AliMCParticle *mctrack = NULL; - - // MC info - Bool_t mcthere = kTRUE; - if(fAODAnalysis) { - AliAODEvent *aodE = dynamic_cast(fInputEvent); - if(!aodE){ - // printf("testd\n"); - AliError("No AOD Event"); - return; - } - fAODMCHeader = dynamic_cast(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName())); - if(!fAODMCHeader){ - mcthere = kFALSE; - } - fAODArrayMCInfo = dynamic_cast(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); - if(!fAODArrayMCInfo){ - mcthere = kFALSE; - } - else { - fHFECuts->SetMCEvent(aodE); - if(fMonitorPhotonic) fBackgroundSubtraction->SetAODArrayMCInfo(fAODArrayMCInfo); - } - } - else { - AliMCEventHandler *mcH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); - if(!mcH) mcthere = kFALSE; - else { - if(fMonitorPhotonic) fBackgroundSubtraction->SetMCEvent(fMCEvent); - } - } - - - ///////////////// - // centrality - ///////////////// - - //AliESDEvent *esd = dynamic_cast(InputEvent()); - //if(!esd) return; - AliCentrality *centrality = fInputEvent->GetCentrality(); - //AliDebug(2,"Got the centrality"); - if(!centrality) return; - cntr = centrality->GetCentralityPercentile("V0M"); - if((0.0< cntr) && (cntr<5.0)) binct = 0.5; - if((5.0< cntr) && (cntr<10.0)) binct = 1.5; - if((10.0< cntr) && (cntr<20.0)) binct = 2.5; - if((20.0< cntr) && (cntr<30.0)) binct = 3.5; - if((30.0< cntr) && (cntr<40.0)) binct = 4.5; - if((40.0< cntr) && (cntr<50.0)) binct = 5.5; - if((50.0< cntr) && (cntr<60.0)) binct = 6.5; - if((60.0< cntr) && (cntr<70.0)) binct = 7.5; - if((70.0< cntr) && (cntr<80.0)) binct = 8.5; - if((80.0< cntr) && (cntr<90.0)) binct = 9.5; - if((90.0< cntr) && (cntr<100.0)) binct = 10.5; - - if((0.< cntr) && (cntr < 20.)) binctt = 0.5; - if((20.< cntr) && (cntr < 40.)) binctt = 1.5; - if((40.< cntr) && (cntr < 80.)) binctt = 2.5; - - if((0.0< cntr) && (cntr<5.0)) binctMore = 0.5; - if((5.0< cntr) && (cntr<10.0)) binctMore = 1.5; - if((10.0< cntr) && (cntr<15.0)) binctMore = 2.5; - if((15.0< cntr) && (cntr<20.0)) binctMore = 3.5; - if((20.0< cntr) && (cntr<25.0)) binctMore = 4.5; - if((25.0< cntr) && (cntr<30.0)) binctMore = 5.5; - if((30.0< cntr) && (cntr<35.0)) binctMore = 6.5; - if((35.0< cntr) && (cntr<40.0)) binctMore = 7.5; - if((40.0< cntr) && (cntr<45.0)) binctMore = 8.5; - if((45.0< cntr) && (cntr<50.0)) binctMore = 9.5; - if((50.0< cntr) && (cntr<55.0)) binctMore = 10.5; - if((55.0< cntr) && (cntr<60.0)) binctMore = 11.5; - if((60.0< cntr) && (cntr<65.0)) binctMore = 12.5; - if((65.0< cntr) && (cntr<70.0)) binctMore = 13.5; - if((70.0< cntr) && (cntr<75.0)) binctMore = 14.5; - if((75.0< cntr) && (cntr<80.0)) binctMore = 15.5; - if((80.0< cntr) && (cntr<85.0)) binctMore = 16.5; - if((85.0< cntr) && (cntr<90.0)) binctMore = 17.5; - if((90.0< cntr) && (cntr<95.0)) binctMore = 18.5; - if((95.0< cntr) && (cntr<100.0)) binctMore = 19.5; - - binctLess = cntr; - - - if(binct > 11.0) return; - - // centrality - valuensparsea[3] = binct; - valuensparseabis[1] = binct; - valuensparsee[1] = binct; - valuensparsef[1] = binctMore; - valuensparsefsin[1] = binct; - valuensparsefbis[3] = binctMore; - valuensparsefbissin[3] = binct; - valuensparseg[1] = binct; - valuensparseh[1] = binct; - valuefractioncont[1] = binct; - valuensparsehprofile[1] = binct; - valuecossinephiep[2] = binctMore; - valuensparseMCSourceDeltaPhiMaps[0] = binct; - valuedeltaphicontamination[1] = binct; - - ////////////////////// - // run number - ////////////////////// - - Int_t runnumber = fInputEvent->GetRunNumber(); - AliDebug(2,Form("Run number %d",runnumber)); - - if(!fPID->IsInitialized()){ - // Initialize PID with the given run number - fPID->InitializePID(runnumber); - } - if(!fPIDTOFOnly->IsInitialized()){ - // Initialize PID with the given run number - fPIDTOFOnly->InitializePID(runnumber); - } - - // - if(!fPIDBackground->IsInitialized()){ - // Initialize PID with the given run number - fPIDBackground->InitializePID(runnumber); - } - - fHFECuts->SetRecEvent(fInputEvent); - if(mcEvent) fHFECuts->SetMCEvent(mcEvent); - - - ////////// - // PID - ////////// - - AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse(); - if(!pidResponse){ - AliDebug(2,"No PID response set"); - return; - } - fPID->SetPIDResponse(pidResponse); - fPIDTOFOnly->SetPIDResponse(pidResponse); - fPIDBackground->SetPIDResponse(pidResponse); - if(fMonitorPhotonic) fBackgroundSubtraction->InitRun(fInputEvent,pidResponse); - - fHistEV->Fill(binctt,0.0); - - ////////////////// - // Event cut - ////////////////// - if(!fHFECuts->CheckEventCuts("fEvRecCuts", fInputEvent)) { - AliDebug(2,"Does not pass the event cut"); - PostData(1, fListHist); - return; - } - - fHistEV->Fill(binctt,1.0); - - - /////////////////////////////////////////////////////////// - // PileUpCut - /////////////////////////////////////////////////////////// - - Float_t multTPC(0.); // tpc mult estimate - Float_t multGlob(0.); // global multiplicity - const Int_t nGoodTracks = fInputEvent->GetNumberOfTracks(); - for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill tpc mult - AliAODTrack* trackAOD = dynamic_cast(fInputEvent->GetTrack(iTracks)); - if (!trackAOD) continue; - if (!(trackAOD->TestFilterBit(1))) continue; - if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.2)) continue; - multTPC++; - } - for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill global mult - AliAODTrack* trackAOD = dynamic_cast(fInputEvent->GetTrack(iTracks)); - if (!trackAOD) continue; - if (!(trackAOD->TestFilterBit(16))) continue; - if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.1)) continue; - Double_t b[2] = {-99., -99.}; - Double_t bCov[3] = {-99., -99., -99.}; - if (!(trackAOD->PropagateToDCA(fInputEvent->GetPrimaryVertex(), fInputEvent->GetMagneticField(), 100., b, bCov))) continue; - if ((TMath::Abs(b[0]) > 0.3) || (TMath::Abs(b[1]) > 0.3)) continue; - multGlob++; - } //track loop - - Double_t pileup[4]; - pileup[0]=fInputEvent->GetCentrality()->GetCentralityPercentile("V0M"); - pileup[1]=fInputEvent->GetCentrality()->GetCentralityPercentile("TRK"); - pileup[2]=multTPC; - pileup[3]=multGlob; - fHistPileUp->Fill(pileup); - - if(fPileUpCut){ - if (TMath::Abs(pileup[0]-pileup[1]) > 5) { - AliDebug(2,"Does not pass the centrality correlation cut"); - return; - } - if(multTPC < (-36.81+1.48*multGlob) && multTPC > (63.03+1.78*multGlob)){ - AliDebug(2,"Does not pass the multiplicity correlation cut"); - return; - } - } - - // AliVVZERO* vzeroData=fInputEvent->GetVZEROData(); - // Double_t mult[3],multV0A(0),multV0C(0); - // for(Int_t i=0; i<32; ++i) { - // multV0A += vzeroData->GetMultiplicityV0A(i); - // multV0C += vzeroData->GetMultiplicityV0C(i); - // } - - // int ntrk=0; - // for(Int_t k = 0; k < fInputEvent->GetNumberOfTracks(); k++){ - // AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); - // if(!track) continue; - // if(!(track->GetStatus()&AliVTrack::kITSrefit)) continue; - // if(!(track->GetStatus()&AliVTrack::kTPCrefit)) continue; - // ntrk++; - // } - - // mult[0]=fInputEvent->GetNumberOfTracks(); - // mult[1]=multV0A+multV0C; - // mult[2]=binctMore; - // fHistPileUp->Fill(mult); - - // if(fUpperPileUpCut&&fLowerPileUpCut){ - // if((mult[0]Eval(mult[1])) || - // (mult[0]>fUpperPileUpCut->Eval(mult[1]))){ - // AliDebug(2,"Does not pass the pileup cut"); - // PostData(1, fListHist); - // return; - // } - // } - - //////////////////////////////////// - // First method event plane - //////////////////////////////////// - - AliEventplane* vEPa = fInputEvent->GetEventplane(); - Float_t eventPlanea = 0.0; - Float_t eventPlaneTPC = 0.0; - Float_t eventPlaneV0A = 0.0; - Float_t eventPlaneV0C = 0.0; - Float_t eventPlaneV0 = 0.0; - TVector2 *qTPC = 0x0; - TVector2 *qsub1a = 0x0; - TVector2 *qsub2a = 0x0; - TVector2 qV0A,qV0C,qV0,*qAna; - - // V0 - - if(fHFEVZEROEventPlane && (!fAODAnalysis)){ - - //AliESDEvent *esd = dynamic_cast(InputEvent()); - //if(!esd) return; - - fHFEVZEROEventPlane->ProcessEvent(fInputEvent); - - if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0A()+100) < 0.0000001) eventPlaneV0A = -100.0; - else { - eventPlaneV0A = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0A()); - if(eventPlaneV0A > TMath::Pi()) eventPlaneV0A = eventPlaneV0A - TMath::Pi(); - } - - if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0C()+100) < 0.0000001) eventPlaneV0C = -100.0; - else { - eventPlaneV0C = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0C()); - if(eventPlaneV0C > TMath::Pi()) eventPlaneV0C = eventPlaneV0C - TMath::Pi(); - } - - if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0()+100) < 0.0000001) eventPlaneV0 = -100.0; - else { - eventPlaneV0 = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0()); - if(eventPlaneV0 > TMath::Pi()) eventPlaneV0 = eventPlaneV0 - TMath::Pi(); - } - - } - else { - - Double_t qVx, qVy; //TR: info - eventPlaneV0 = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,10,2,qVx,qVy)); - if(eventPlaneV0 > TMath::Pi()) eventPlaneV0 = eventPlaneV0 - TMath::Pi(); - qV0.Set(qVx,qVy); - eventPlaneV0A = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,8,2,qVx,qVy)); - if(eventPlaneV0A > TMath::Pi()) eventPlaneV0A = eventPlaneV0A - TMath::Pi(); - qV0A.Set(qVx,qVy); - eventPlaneV0C = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,9,2,qVx,qVy)); - if(eventPlaneV0C > TMath::Pi()) eventPlaneV0C = eventPlaneV0C - TMath::Pi(); - qV0C.Set(qVx,qVy); - - if(eventPlaneV0<-900) return; - if(eventPlaneV0A<-900) return; - if(eventPlaneV0C<-900) return; - - - eventPlaneV0=TVector2::Phi_0_2pi(eventPlaneV0); - eventPlaneV0A=TVector2::Phi_0_2pi(eventPlaneV0A); - eventPlaneV0C=TVector2::Phi_0_2pi(eventPlaneV0C); - } - - - // TPC - - qTPC = vEPa->GetQVector(); - Double_t qx = -1.0; - Double_t qy = -1.0; - if(qTPC) { - qx = qTPC->X(); - qy = qTPC->Y(); - } - TVector2 qVectorfortrack; - qVectorfortrack.Set(qx,qy); - eventPlaneTPC = TVector2::Phi_0_2pi(qVectorfortrack.Phi())/2.; - - // Choose the one used for v2 - - if(fVZEROEventPlane){ //TR: info - eventPlanea = eventPlaneV0; - qAna = &qV0; - } - if(fVZEROEventPlaneA){ - eventPlanea = eventPlaneV0A; - qAna = &qV0A; - } - if(fVZEROEventPlaneC){ - eventPlanea = eventPlaneV0C; - qAna = &qV0C; - } - if(!fVZEROEventPlane){ - eventPlanea = eventPlaneTPC; - qAna = &qV0C; - } - - valuecossinephiep[0] = TMath::Cos(2*eventPlanea); - valuecossinephiep[1] = TMath::Sin(2*eventPlanea); - - Float_t eventPlanesub1a = -100.0; - Float_t eventPlanesub2a = -100.0; - Double_t diffsub1sub2a = -100.0; - Double_t diffsub1sub2asin = -100.0; - Double_t diffsubasubb = -100.0; - Double_t diffsubasubc = -100.0; - Double_t diffsubbsubc = -100.0; - Double_t diffsubasubbsin = -100.0; - Double_t diffsubasubcsin = -100.0; - Double_t diffsubbsubcsin = -100.0; - - // two sub event TPC - qsub1a = vEPa->GetQsub1(); - qsub2a = vEPa->GetQsub2(); - - ///////////////////////////////////////////////////////// - // Cut for event with event plane reconstructed by all - //////////////////////////////////////////////////////// - - if((!qTPC) || (!qsub1a) || (!qsub2a)) { - AliDebug(2,"No event plane"); - return; - } - - eventPlanesub1a = TVector2::Phi_0_2pi(qsub1a->Phi())/2.; - eventPlanesub2a = TVector2::Phi_0_2pi(qsub2a->Phi())/2.; - diffsub1sub2a = TMath::Cos(2.*TVector2::Phi_0_2pi(qsub1a->Phi()/2.- qsub2a->Phi()/2.)); - diffsub1sub2asin = TMath::Sin(2.*TVector2::Phi_0_2pi(qsub1a->Phi()/2.- qsub2a->Phi()/2.)); - - - // if ( !fDebugStreamer ) { - // //debug stream - // TDirectory *backup = gDirectory; - // fDebugStreamer = new TTreeSRedirector("TaskFlowTPCTOFEPSPdebug.root"); - // if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer - // } - - // { - - // double v0nrom = TMath::Sqrt(qV0.X()*qV0.X()+qV0.Y()*qV0.Y()); - // double v0Anrom = TMath::Sqrt(qV0A.X()*qV0A.X()+qV0A.Y()*qV0A.Y()); - // double v0Cnrom = TMath::Sqrt(qV0C.X()*qV0C.X()+qV0C.Y()*qV0C.Y()); - // double sub1nrom = TMath::Sqrt(qsub1a->X()*qsub1a->X()+qsub1a->Y()*qsub1a->Y()); - // double sub2nrom = TMath::Sqrt(qsub2a->X()*qsub2a->X()+qsub2a->Y()*qsub2a->Y()); - - // (* fDebugStreamer) << "UserExec" << - // "binct="<X()+qV0A.Y()*qTPC->Y(); - diffsubbsubc = qV0C.X()*qTPC->X()+qV0C.Y()*qTPC->Y(); - } - else if(fVZEROEventPlaneC){ - diffsubasubb = qV0C.X()*qV0A.X()+qV0C.Y()*qV0A.Y(); - diffsubasubc = qV0C.X()*qTPC->X()+qV0C.Y()*qTPC->Y(); - diffsubbsubc = qV0A.X()*qTPC->X()+qV0A.Y()*qTPC->Y(); - } - } - - diffsubasubbsin = TMath::Sin(2.*(eventPlaneV0A - eventPlaneV0C)); - diffsubasubcsin = TMath::Sin(2.*(eventPlaneV0A - eventPlaneTPC)); - diffsubbsubcsin = TMath::Sin(2.*(eventPlaneV0C - eventPlaneTPC)); - // three sub events in case of VZERO all - if(fVZEROEventPlane && (!fVZEROEventPlaneA) && (!fVZEROEventPlaneC)) { - if(!fSP){ - diffsubasubb = TMath::Cos(2.*(eventPlaneV0 - eventPlanesub1a)); //TR: - diffsubasubc = TMath::Cos(2.*(eventPlaneV0 - eventPlanesub2a)); //TR: - diffsubbsubc = TMath::Cos(2.*(eventPlanesub1a - eventPlanesub2a)); //TR: - } - else{ - diffsubasubb = qV0.X()*qsub1a->X()+qV0.Y()*qsub1a->Y(); - diffsubasubc = qV0.X()*qsub2a->X()+qV0.Y()*qsub2a->Y(); - diffsubbsubc = qsub1a->X()*qsub2a->X()+qsub1a->Y()*qsub2a->Y(); - } - - diffsubasubbsin = TMath::Sin(2.*(eventPlaneV0 - eventPlanesub1a)); - diffsubasubcsin = TMath::Sin(2.*(eventPlaneV0 - eventPlanesub2a)); - diffsubbsubcsin = TMath::Sin(2.*(eventPlanesub1a - eventPlanesub2a)); - } - - ////////////////////////////////////// - // AliFlowEvent and MC event plane - ///////////////////////////////////// - - Int_t nbtracks = fInputEvent->GetNumberOfTracks(); - AliDebug(2,Form("Number of tracks %d",nbtracks)); - - if(fMonitorQCumulant) { - - fcutsRP->SetEvent( InputEvent(), MCEvent()); - fcutsPOI->SetEvent( InputEvent(), MCEvent()); - if( fflowEvent ){ - fflowEvent->~AliFlowEvent(); - new(fflowEvent) AliFlowEvent(fcutsRP,fcutsPOI); - }else fflowEvent = new AliFlowEvent(fcutsRP,fcutsPOI); - if(mcEvent && mcEvent->GenEventHeader()) { - fflowEvent->SetMCReactionPlaneAngle(mcEvent); - //if reaction plane not set from elsewhere randomize it before adding flow - //if (!fflowEvent->IsSetMCReactionPlaneAngle()) fflowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi())); - mcReactionPlane = TVector2::Phi_0_2pi(fflowEvent->GetMCReactionPlaneAngle()); - if(mcReactionPlane > TMath::Pi()) mcReactionPlane = mcReactionPlane - TMath::Pi(); - AliDebug(2,Form("MC reaction plane %f",mcReactionPlane)); - } - fflowEvent->SetReferenceMultiplicity( nbtracks ); - fflowEvent->DefineDeadZone(0,0,0,0); - //fflowEvent.TagSubeventsInEta(-0.8,-0.1,0.1,0.8); - - //////////////// - // MC - /////////////// - if(fUseMCReactionPlane) { - eventPlanea = mcReactionPlane; - diffsub1sub2a = 0.0; - } - } - - - ////////////////////// - // Fill Histos - ////////////////////// - - fHistEV->Fill(binctt,2.0); - - // Fill - valuensparsea[0] = eventPlaneV0A; - valuensparsea[1] = eventPlaneV0C; - valuensparsea[2] = eventPlaneTPC; - if(fVZEROEventPlane && (!fVZEROEventPlaneA) && (!fVZEROEventPlaneC)) { - // case VZERO all - valuensparsea[0] = eventPlaneV0; - valuensparsea[1] = eventPlanesub1a; - valuensparsea[2] = eventPlanesub2a; - } - fEventPlane->Fill(&valuensparsea[0]); - - // Fill - if(fMonitorEventPlane) fCosSin2phiep->Fill(&valuecossinephiep[0]); - - if(!fVZEROEventPlane) { - valuensparsef[0] = diffsub1sub2a; - fCosRes->Fill(&valuensparsef[0]); - valuensparsefsin[0] = diffsub1sub2asin; - if(fMonitorEventPlane) fSinRes->Fill(&valuensparsefsin[0]); - if(fMonitorEventPlane) { - fProfileCosRes->Fill(valuensparsef[1],valuensparsef[0]); - } - } - else { - valuensparsefbis[0] = diffsubasubb; - valuensparsefbis[1] = diffsubasubc; - valuensparsefbis[2] = diffsubbsubc; - fCosResabc->Fill(&valuensparsefbis[0]); //TR: info - valuensparsefbissin[0] = diffsubasubbsin; - valuensparsefbissin[1] = diffsubbsubcsin; - valuensparsefbissin[2] = diffsubasubcsin; - if(fMonitorEventPlane) fSinResabc->Fill(&valuensparsefbissin[0]); - if(fMonitorEventPlane) { - fProfileCosResab->Fill(valuensparsefbis[3],valuensparsefbis[0]); - fProfileCosResac->Fill(valuensparsefbis[3],valuensparsefbis[1]); - fProfileCosResbc->Fill(valuensparsefbis[3],valuensparsefbis[2]); - } - } - - //////////////////////////////////////// - // Loop to determine pool background - ///////////////////////////////////////// - if(fMonitorPhotonic) { - - fBackgroundSubtraction->FillPoolAssociatedTracks(fInputEvent,binct); - - if( fArraytrack ){ - fArraytrack->~TArrayI(); - new(fArraytrack) TArrayI(nbtracks); - } - else { - fArraytrack = new TArrayI(nbtracks); - } - fCounterPoolBackground = 0; - - for(Int_t k = 0; k < nbtracks; k++){ - - AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); - if(!track) continue; - - // Track cuts - Bool_t survivedbackground = kTRUE; - if(fAODAnalysis) { - AliAODTrack *aodtrack = dynamic_cast(track); - if(aodtrack) { - AliESDtrack esdTrack(aodtrack); - // set the TPC cluster info - esdTrack.SetTPCClusterMap(aodtrack->GetTPCClusterMap()); - esdTrack.SetTPCSharedMap(aodtrack->GetTPCSharedMap()); - esdTrack.SetTPCPointsF(aodtrack->GetTPCNclsF()); - // needed to calculate the impact parameters - AliAODEvent *aodeventu = dynamic_cast(fInputEvent); - if(aodeventu) { - AliAODVertex *vAOD = aodeventu->GetPrimaryVertex(); - Double_t bfield = aodeventu->GetMagneticField(); - Double_t pos[3],cov[6]; - vAOD->GetXYZ(pos); - vAOD->GetCovarianceMatrix(cov); - const AliESDVertex vESD(pos,cov,100.,100); - esdTrack.RelateToVertex(&vESD,bfield,3.); - } - if(!fHFEBackgroundCuts->IsSelected(&esdTrack)) { - survivedbackground = kFALSE; - } - } - } - else { - AliESDtrack *esdtrack = dynamic_cast(track); - if(esdtrack) { - if(!fHFEBackgroundCuts->IsSelected(esdtrack)) survivedbackground = kFALSE; - } - } - // PID - if(survivedbackground) { - // PID track cuts - AliHFEpidObject hfetrack2; - if(!fAODAnalysis) hfetrack2.SetAnalysisType(AliHFEpidObject::kESDanalysis); - else hfetrack2.SetAnalysisType(AliHFEpidObject::kAODanalysis); - hfetrack2.SetRecTrack(track); - hfetrack2.SetCentrality((Int_t)binct); - AliDebug(2,Form("centrality %f and %d",binct,hfetrack2.GetCentrality())); - hfetrack2.SetPbPb(); - if(fPIDBackground->IsSelected(&hfetrack2,0x0,"recTrackCont",fPIDBackgroundqa)) { - fArraytrack->AddAt(k,fCounterPoolBackground); - fCounterPoolBackground++; - AliDebug(2,Form("fCounterPoolBackground %d, track %d",fCounterPoolBackground,k)); - } - } - } - } - - - ////////////////////////// - // Loop over track - ////////////////////////// - for(Int_t k = 0; k < nbtracks; k++){ - - AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); - if(!track) continue; - - if(fAODAnalysis) { - AliAODTrack *aodtrack = dynamic_cast(track); - if(!aodtrack){ - AliError("AOD track is not there"); - continue; - } - AliDebug(2,"Find AOD track on"); - if(!(aodtrack->TestFilterBit(fFilter))) continue; // Only process AOD tracks where the HFE is set - } - - - valuetrackingcuts[0] = track->Pt(); - valuetrackingcuts[1] = 0; - - // RecKine: ITSTPC cuts - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - // RecPrim - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - valuetrackingcuts[1] = 1; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - // HFEcuts: ITS layers cuts - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - valuetrackingcuts[1] = 2; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - // HFE cuts: TOF and mismatch flag - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTOF + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - valuetrackingcuts[1] = 3; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - // HFE cuts: TPC PID cleanup - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - valuetrackingcuts[1] = 4; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - // HFEcuts: Nb of tracklets TRD0 - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - valuetrackingcuts[1] = 5; - if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); - - AliDebug(2,"Survived"); - - ///////////////////////////////////////////////////////// - // Subtract candidate from TPC event plane - //////////////////////////////////////////////////////// - Float_t eventplanesubtracted = 0.0; - - if(!fVZEROEventPlane) { - // Subtract the tracks from the event plane - Double_t qX = qTPC->X() - vEPa->GetQContributionX(track); //Modify the components: subtract the track you want to look at with your analysis - Double_t qY = qTPC->Y() - vEPa->GetQContributionY(track); //Modify the components: subtract the track you want to look at with your analysis - TVector2 newQVectorfortrack; - newQVectorfortrack.Set(qX,qY); - eventplanesubtracted = TVector2::Phi_0_2pi(newQVectorfortrack.Phi())/2; - } - else eventplanesubtracted = eventPlanea; - - /////////////////////////////////////////// - // Event plane - ////////////////////////////////////////// - Bool_t fillEventPlane = kTRUE; - if(!fVZEROEventPlane){ - if((!qsub1a) || (!qsub2a)) fillEventPlane = kFALSE; - if(fSubEtaGapTPC) { - if(track->Eta() < (- fEtaGap/2.)) eventplanesubtracted = eventPlanesub1a; - else if(track->Eta() > (fEtaGap/2.)) eventplanesubtracted = eventPlanesub2a; - else fillEventPlane = kFALSE; - } - } - - /////////////// - // MC - ////////////// - if(fUseMCReactionPlane) { - eventplanesubtracted = mcReactionPlane; - fillEventPlane = kTRUE; - } - - ////////////////////////////////////////////////////////////////////////////// - ///////////////////////////AFTERBURNER - Double_t phitrack = track->Phi(); - if (fAfterBurnerOn) - { - phitrack = GetPhiAfterAddV2(track->Phi(),mcReactionPlane); - } - ////////////////////////////////////////////////////////////////////////////// - - - /////////////////////// - // Calculate deltaphi - /////////////////////// - - // Suppose phi track is between 0.0 and phi - Double_t deltaphi = TVector2::Phi_0_2pi(phitrack - eventplanesubtracted); - if(deltaphi > TMath::Pi()) deltaphi = deltaphi - TMath::Pi(); - - //////////////////////////////// - // Determine the deltaphi bin - /////////////////////////////// - - // in-plane - if(((deltaphi<(TMath::Pi()/4.)) && (deltaphi>0.0)) || ((deltaphi>(3*TMath::Pi()/4.)) && (deltaphi(TMath::Pi()/4.)) && (deltaphi<(3*TMath::Pi()/4.))) valuedeltaphicontamination[0] = 1.5; - - //////////////////////////////////////// - // Define variables - /////////////////////////////////////// - - - valuedeltaphicontamination[2] = track->Pt(); - valuensparsee[2] = track->Pt(); - valuensparsee[3] = track->Eta(); - valuensparseg[2] = track->Pt(); - valuensparseh[2] = track->Pt(); - valuefractioncont[0] = track->Pt(); - valuensparsehprofile[2] = track->Pt(); - valuensparseMCSourceDeltaPhiMaps[1] = track->Pt(); - if(track->Charge() > 0.0) { - valuensparseg[3] = 0.2; - valuensparseh[3] = 0.2; - } - else { - valuensparseg[3] = -0.2; - valuensparseh[3] = -0.2; - } - valuensparseh[4] = track->Eta(); - valuensparseg[4] = track->Eta(); - - AliDebug(2,Form("charge %d",(Int_t)track->Charge())); - - //////////////////////// - // Fill before PID - /////////////////////// - - if(fMonitorWithoutPID) { - - valuensparseg[0] = deltaphi; - if(fillEventPlane) fDeltaPhiMapsBeforePID->Fill(&valuensparseg[0]); - - // - valuensparseh[0] = TMath::Cos(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); - if(fillEventPlane) { - fCosPhiMapsBeforePID->Fill(&valuensparseh[0]); - } - } - - //////////////////////// - // Apply PID - //////////////////////// - if(!fNoPID) { - // Apply PID for Data - if(!fMCPID) { - // pid object - AliHFEpidObject hfetrack; - if(!fAODAnalysis) hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); - else hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis); - hfetrack.SetRecTrack(track); - hfetrack.SetCentrality((Int_t)binct); - AliDebug(2,Form("centrality %f and %d",binct,hfetrack.GetCentrality())); - hfetrack.SetPbPb(); - - // Only TOF PID - if(fMonitorContamination) { - if(fPIDTOFOnly->IsSelected(&hfetrack,0x0,"recTrackCont",0x0)) { - Float_t nsigma = pidResponse->NumberOfSigmasTPC(track, AliPID::kElectron); - valuedeltaphicontamination[3] = nsigma; - fDeltaPhiMapsContamination->Fill(&valuedeltaphicontamination[0]); - } - } - - // Complete PID TOF+TPC - if(!fPID->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqa)) { - continue; - } - } - else { - if(!mcEvent) continue; - if(!(mctrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(track->GetLabel()))))) continue; - AliDebug(2,Form("PdgCode %d",TMath::Abs(mctrack->Particle()->GetPdgCode()))); - if(TMath::Abs(mctrack->Particle()->GetPdgCode())!=11) continue; - } - } - - - ///////////////////////////////////////////////////////////////////////////// - // Add candidate to AliFlowEvent for POI and subtract from RP if needed - //////////////////////////////////////////////////////////////////////////// - if(fMonitorQCumulant) { - Int_t idtrack = static_cast(track)->GetID(); - Bool_t found = kFALSE; - Int_t numberoffound = 0; - AliDebug(2,Form("A: Number of tracks %d",fflowEvent->NumberOfTracks())); - for(Int_t iRPs=0; iRPs< fflowEvent->NumberOfTracks(); iRPs++) { - AliFlowTrack *iRP = (AliFlowTrack*) (fflowEvent->GetTrack(iRPs)); - if(!iRP) continue; - //if(!iRP->InRPSelection()) continue; - if( TMath::Abs(idtrack) == TMath::Abs(iRP->GetID()) ) { - iRP->SetForPOISelection(kTRUE); - found = kTRUE; - numberoffound ++; - } - } - AliDebug(2,Form("Found %d mal",numberoffound)); - if(!found) { - AliFlowCandidateTrack *sTrack = (AliFlowCandidateTrack*) MakeTrack(massElectron,track->Pt(),track->Phi(), track->Eta()); - sTrack->SetID(idtrack); - fflowEvent->AddTrack(sTrack); - AliDebug(2,"Add the track"); - } - AliDebug(2,Form("B: Number of tracks %d",fflowEvent->NumberOfTracks())); - } - - - ///////////////////// - // Fill THnSparseF - ///////////////////// - - // - valuensparseabis[0] = eventplanesubtracted; - if((fillEventPlane) && (fMonitorEventPlane)) fEventPlaneaftersubtraction->Fill(&valuensparseabis[0]); - - - if(fMonitorEventPlane) - { - // - valuensparsee[0] = TMath::Cos(2*phitrack); - fCos2phie->Fill(&valuensparsee[0]); - valuensparsee[0] = TMath::Sin(2*phitrack); - fSin2phie->Fill(&valuensparsee[0]); - // - valuensparsee[0] = TMath::Cos(2*eventplanesubtracted); - if(fillEventPlane) fCos2phiep->Fill(&valuensparsee[0]); - valuensparsee[0] = TMath::Sin(2*eventplanesubtracted); - if(fillEventPlane) fSin2phiep->Fill(&valuensparsee[0]); - valuensparsee[0] = TMath::Sin(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); - if(fillEventPlane) fSin2phiephiep->Fill(&valuensparsee[0]); - // - } - - // - valuensparseg[0] = deltaphi; - if(fillEventPlane) fDeltaPhiMaps->Fill(&valuensparseg[0]); - - // - valuensparseh[0] = TMath::Cos(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); - if(fillEventPlane) { - fCosPhiMaps->Fill(&valuensparseh[0]); //TR: fCosPhiQSum+=valuensparseh[0]*TMath:Sqrt(qAna->X()*qAna->X()+qAna->Y()*qAna->Y()); fCosPhiQN++; - if((valuefractioncont[1] >=0) && (valuefractioncont[1] < 11)){ - if(fContamination[((Int_t)valuefractioncont[1])]){ - Double_t weight = fContamination[((Int_t)valuefractioncont[1])]->Eval(track->P()); - if(weight<0.0) weight=0.0; - if(weight>1.0) weight=1.0; - fFractionContamination->Fill(&valuefractioncont[0],weight); - if(fv2contamination[((Int_t)valuefractioncont[1])]){ - Double_t v2 = fv2contamination[((Int_t)valuefractioncont[1])]->Eval(track->Pt()); - AliDebug(2,Form("value v2 %f, contamination %f and pt %f centrality %d\n",v2,weight,track->Pt(),(Int_t)valuefractioncont[1])); - AliDebug(2,Form("Check for centrality 3: value v2 %f, contamination %f\n",fv2contamination[3]->Eval(track->Pt()),fContamination[3]->Eval(track->P()))); - AliDebug(2,Form("Check for centrality 4: value v2 %f, contamination %f\n",fv2contamination[4]->Eval(track->Pt()),fContamination[4]->Eval(track->P()))); - AliDebug(2,Form("Check for centrality 5: value v2 %f, contamination %f\n",fv2contamination[5]->Eval(track->Pt()),fContamination[5]->Eval(track->P()))); - fContaminationv2->Fill(valuefractioncont[1],valuefractioncont[0],v2,weight); - } - } - } - if(fMonitorEventPlane) { - if(fSP) - valuensparseh[0] *= TMath::Sqrt(qAna->X()*qAna->X()+qAna->Y()*qAna->Y()); - fProfileCosPhiMaps->Fill(valuensparsehprofile[1],valuensparsehprofile[2],valuensparseh[0]); //TR: info - } - } - - if(fMonitorPhotonic) { - Int_t indexmother = -1; - Int_t source = 1; - if(mcthere) source = fBackgroundSubtraction->FindMother(mctrack->GetLabel(),indexmother); - fBackgroundSubtraction->LookAtNonHFE(k, track, fInputEvent, 1, binct, deltaphi, source, indexmother); - - if((!fAODAnalysis && mcthere) || !mcthere) { - // background - source = 0; - indexmother = -1; - source = FindMother(TMath::Abs(track->GetLabel()),mcEvent, indexmother); - valuensparseMCSourceDeltaPhiMaps[2] = source; - if(mcEvent) fMCSourceDeltaPhiMaps->Fill(&valuensparseMCSourceDeltaPhiMaps[0]); - //LookAtNonHFE(k,track,fInputEvent,mcEvent,binct,deltaphi,source,indexmother); - Int_t taggedvalue = LookAtNonHFE(k,track,fInputEvent,mcEvent,binct,deltaphi,source,indexmother); - if(fMonitorPhotonic) { - // No opposite charge partner found in the invariant mass choosen - if((taggedvalue!=2) && (taggedvalue!=6)) { - //fDeltaPhiMapsTaggedNonPhotonic->Fill(&valuensparseg[0]); - //fCosPhiMapsTaggedNonPhotonic->Fill(&valuensparseh[0]); - } - // One opposite charge partner found in the invariant mass choosen - if((taggedvalue==2) || (taggedvalue==6)) { - fDeltaPhiMapsTaggedPhotonic->Fill(&valuensparseg[0]); - //fCosPhiMapsTaggedPhotonic->Fill(&valuensparseh[0]); - } - // One same charge partner found in the invariant mass choosen - if((taggedvalue==4) || (taggedvalue==6)) { - fDeltaPhiMapsTaggedPhotonicLS->Fill(&valuensparseg[0]); - //fCosPhiMapsTaggedPhotonicLS->Fill(&valuensparseh[0]); - } - } - } - } - - } - - ////////////////////////////////////////////////////////////////////////////// - ///////////////////////////AFTERBURNER - if (fAfterBurnerOn & fMonitorQCumulant) - { - fflowEvent->AddFlow(fV1,fV2,fV3,fV4,fV5); //add flow - fflowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks - } - ////////////////////////////////////////////////////////////////////////////// - - - - //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { - // if((fBinCentralityLess[bincless]< cntr) && (cntr < fBinCentralityLess[bincless+1])) PostData(bincless+2,fflowEvent); - //} - - if(fMonitorPhotonic) { - if(fArraytrack) { - delete fArraytrack; - fArraytrack = NULL; - } - } - - if(fMonitorPhotonic) fBackgroundSubtraction->CountPoolAssociated(fInputEvent,binct); - - PostData(1, fListHist); - - - -} -//______________________________________________________________________________ -AliFlowCandidateTrack *AliAnalysisTaskFlowTPCTOFEPSP::MakeTrack( Double_t mass, - Double_t pt, Double_t phi, Double_t eta) { - // - // Make Track (Not needed actually) - // - - AliFlowCandidateTrack *sTrack = new AliFlowCandidateTrack(); - sTrack->SetMass(mass); - sTrack->SetPt(pt); - sTrack->SetPhi(phi); - sTrack->SetEta(eta); - sTrack->SetForPOISelection(kTRUE); - sTrack->SetForRPSelection(kFALSE); - return sTrack; -} -//_________________________________________________________________________________ -Double_t AliAnalysisTaskFlowTPCTOFEPSP::GetPhiAfterAddV2(Double_t phi,Double_t reactionPlaneAngle) const -{ - // - // Adds v2, uses Newton-Raphson iteration - // - Double_t phiend=phi; - Double_t phi0=phi; - Double_t f=0.; - Double_t fp=0.; - Double_t phiprev=0.; - - for (Int_t i=0; iPt(); - valuensparseDeltaPhiMaps[0] = deltaphi; - valuensparseDeltaPhiMaps[4] = source; - - valueangle[2] = source; - valueangle[1] = binct; - - // Pdg code - Int_t pdg1 = CheckPdg(TMath::Abs(track1->GetLabel()),mcEvent); - Int_t numberfound = 0; - - //Magnetic Field - Double_t bfield = vEvent->GetMagneticField(); - - // Get Primary vertex - const AliVVertex *pVtx = vEvent->GetPrimaryVertex(); - - for(Int_t idex = 0; idex < fCounterPoolBackground; idex++) - { - - Int_t iTrack2 = fArraytrack->At(idex); - AliDebug(2,Form("track %d",iTrack2)); - AliVTrack* track2 = (AliVTrack *) vEvent->GetTrack(iTrack2); - if (!track2) - { - printf("ERROR: Could not receive track %d", iTrack2); - continue; - } - if(iTrack2==iTrack1) continue; - AliDebug(2,"Different"); - - // Reset the MC info - valueangle[2] = source; - valuensparseDeltaPhiMaps[4] = source; - - // track cuts and PID already done - - // if MC look - Int_t pdg2 = -100; - if(mcEvent) { - Int_t source2 = 0; - Int_t indexmother2 = -1; - source2 = FindMother(TMath::Abs(track2->GetLabel()),mcEvent, indexmother2); - pdg2 = CheckPdg(TMath::Abs(track2->GetLabel()),mcEvent); - if(source2 >=0 ) { - if((indexmother2 == indexmother) && (source == source2) && ((pdg1*pdg2)<0.0)) { - if(source == kElectronfromconversion) { - valueangle[2] = kElectronfromconversionboth; - valuensparseDeltaPhiMaps[4] = kElectronfromconversionboth; - numberfound++; - } - if(source == kElectronfrompi0) { - valueangle[2] = kElectronfrompi0both; - valuensparseDeltaPhiMaps[4] = kElectronfrompi0both; - } - if(source == kElectronfrometa) { - valueangle[2] = kElectronfrometaboth; - valuensparseDeltaPhiMaps[4] = kElectronfrometaboth; - } - } - } - } - - if(fAlgorithmMA && (!fAODAnalysis)) - { - // tracks - AliESDtrack *esdtrack2 = dynamic_cast(track2); - AliESDtrack *esdtrack1 = dynamic_cast(track1); - if((!esdtrack2) || (!esdtrack1)) continue; - - //Variables - Double_t p1[3]; - Double_t p2[3]; - Double_t xt1; //radial position track 1 at the DCA point - Double_t xt2; //radial position track 2 at the DCA point - //DCA track1-track2 - Double_t dca12 = esdtrack2->GetDCA(esdtrack1,bfield,xt2,xt1); - - // Cut dca - if(dca12 > fMaxdca) continue; - - //Momento of the track extrapolated to DCA track-track - //Track1 - Bool_t hasdcaT1 = esdtrack1->GetPxPyPzAt(xt1,bfield,p1); - //Track2 - Bool_t hasdcaT2 = esdtrack2->GetPxPyPzAt(xt2,bfield,p2); - - if(!hasdcaT1 || !hasdcaT2) AliWarning("It could be a problem in the extrapolation"); - - //track1-track2 Invariant Mass - Double_t eMass = 0.000510998910; //Electron mass in GeV - Double_t pP1 = sqrt(p1[0]*p1[0]+p1[1]*p1[1]+p1[2]*p1[2]); //Track 1 momentum - Double_t pP2 = sqrt(p2[0]*p2[0]+p2[1]*p2[1]+p2[2]*p2[2]); //Track 2 momentum - Double_t eE1 = TMath::Sqrt(pP1*pP1+eMass*eMass); - Double_t eE2 = TMath::Sqrt(pP2*pP2+eMass*eMass); - - //TLorentzVector v1(p1[0],p1[1],p1[2],sqrt(eMass*eMass+pP1*pP1)); - //TLorentzVector v2(p2[0],p2[1],p2[2],sqrt(eMass*eMass+pP2*pP2)); - //Double_t imass = (v1+v2).M(); //Invariant Mass - //Double_t angle3D = v1.Angle(v2.Vect()); //Opening Angle (Total Angle) - - // daughter - v3D1.SetXYZ(p1[0],p1[1],p1[2]); - v3D2.SetXYZ(p2[0],p2[1],p2[2]); - Double_t openingangle = TVector2::Phi_0_2pi(v3D2.Angle(v3D1)); - - // mother - TVector3 motherrec = v3D1 + v3D2; - Double_t invmass = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(motherrec.Px()*motherrec.Px()+motherrec.Py()*motherrec.Py()+motherrec.Pz()*motherrec.Pz())); - - // xy - //TVector3 vectordiff = v3D1 - v3D2; - //Double_t diffphi = TVector2::Phi_0_2pi(vectordiff.Phi()); - //Double_t massxy = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(pP1*pP1+pP2*pP2+2*pP1*pP2*TMath::Cos(diffphi))); - - // rz - //Double_t difftheta = TVector2::Phi_0_2pi(vectordiff.Eta()); - //Double_t massrz = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(pP1*pP1+pP2*pP2+2*pP1*pP2*TMath::Cos(difftheta))); - - - Float_t fCharge1 = track1->Charge(); - Float_t fCharge2 = track2->Charge(); - - // Fill Histo - //valueangle[0] = diffphi; - //valueangle[1] = difftheta; - valueangle[0] = openingangle; - if((fCharge1*fCharge2)>0.0) fSameSignAngle->Fill(&valueangle[0]); - else fOppSignAngle->Fill(&valueangle[0]); - - // Cut - if(openingangle > fMaxopening3D) continue; - //if(difftheta > fMaxopeningtheta) continue; - //if(diffphi > fMaxopeningphi) continue; - - // Invmass - valuensparseDeltaPhiMaps[3] = invmass; - if((fCharge1*fCharge2)>0.0) fSameSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); - else fOppSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); - - // Cut - if(invmass < fMaxInvmass) { - if((fCharge1*fCharge2)<0.0) oppositetaggedphotonic=kTRUE; - if((fCharge1*fCharge2)>0.0) sametaggedphotonic=kTRUE; - } - - - } - else - { - Int_t fPDGtrack1 = 11; - Int_t fPDGtrack2 = 11; - - Float_t fCharge1 = track1->Charge(); - Float_t fCharge2 = track2->Charge(); - - if(fCharge1>0) fPDGtrack1 = -11; - if(fCharge2>0) fPDGtrack2 = -11; - - AliKFParticle ktrack1(*track1, fPDGtrack1); - AliKFParticle ktrack2(*track2, fPDGtrack2); - AliKFParticle recoGamma(ktrack1, ktrack2); - - //Reconstruction Cuts - if(recoGamma.GetNDF()<1) continue; - Double_t chi2OverNDF = recoGamma.GetChi2()/recoGamma.GetNDF(); - if(TMath::Sqrt(TMath::Abs(chi2OverNDF))>fChi2OverNDFCut) continue; - - // DCA - //Double_t dca12 = ktrack1.GetDistanceFromParticle(ktrack2); - //if(dca12 > fMaxdca) continue; - - // if set mass constraint - if(fSetMassConstraint && pVtx) { - AliKFVertex primV(*pVtx); - primV += recoGamma; - primV -= ktrack1; - primV -= ktrack2; - recoGamma.SetProductionVertex(primV); - recoGamma.SetMassConstraint(0,0.0001); - } - - //Invariant Mass - Double_t imass; - Double_t width; - recoGamma.GetMass(imass,width); - - //Opening Angle (Total Angle) - Double_t angle = ktrack1.GetAngle(ktrack2); - valueangle[0] = angle; - if((fCharge1*fCharge2)>0.0) fSameSignAngle->Fill(&valueangle[0]); - else fOppSignAngle->Fill(&valueangle[0]); - - // Cut - if(angle > fMaxopening3D) continue; - - // Invmass - valuensparseDeltaPhiMaps[3] = imass; - if((fCharge1*fCharge2)>0.0) fSameSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); - else { - fOppSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); - /* - if(valueangle[2] == kElectronfromconversionboth) { - printf("Reconstructed charge1 %f, charge 2 %f and invmass %f",fCharge1,fCharge2,imass); - printf("MC charge1 %d, charge 2 %d",pdg1,pdg2); - printf("DCA %f",dca12); - printf("Number of found %d",numberfound); - } - */ - } - - // Cut - if(imass < fMaxInvmass) { - if((fCharge1*fCharge2)<0.0) oppositetaggedphotonic=kTRUE; - if((fCharge1*fCharge2)>0.0) sametaggedphotonic=kTRUE; - } - } - } - - if(oppositetaggedphotonic && sametaggedphotonic){ - taggedphotonic = 6; - } - - if(!oppositetaggedphotonic && sametaggedphotonic){ - taggedphotonic = 4; - } - - if(oppositetaggedphotonic && !sametaggedphotonic){ - taggedphotonic = 2; - } - - - return taggedphotonic; -} -//_________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &indexmother){ - // - // Find the mother if MC - // - - if(!mcEvent) return 0; - - Int_t pdg = CheckPdg(tr,mcEvent); - if(TMath::Abs(pdg)!= 11) { - indexmother = -1; - return kNoElectron; - } - - indexmother = IsMotherGamma(tr,mcEvent); - if(indexmother > 0) return kElectronfromconversion; - indexmother = IsMotherPi0(tr,mcEvent); - if(indexmother > 0) return kElectronfrompi0; - indexmother = IsMotherC(tr,mcEvent); - if(indexmother > 0) return kElectronfromC; - indexmother = IsMotherB(tr,mcEvent); - if(indexmother > 0) return kElectronfromB; - indexmother = IsMotherEta(tr,mcEvent); - if(indexmother > 0) return kElectronfrometa; - - return kElectronfromother; - - -} -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::CheckPdg(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the pdg of the particle - // - - - Int_t pdgcode = -1; - if(tr < 0) return pdgcode; - - if(!mcEvent) return pdgcode; - - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode; - pdgcode = mctrackesd->PdgCode(); - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode; - pdgcode = mctrackaod->GetPdgCode(); - } - - return pdgcode; - - -} -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherGamma(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the lab of gamma mother or -1 if not gamma - // - - if(tr < 0) return -1; - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - TParticle *particle = 0x0; - particle = mctrackesd->Particle(); - // Take mother - if(!particle) return -1; - Int_t imother = particle->GetFirstMother(); - if(imother < 0) return -1; - AliMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - TParticle * mother = mothertrack->Particle(); - if(!mother) return -1; - // Check gamma - Int_t pdg = mother->GetPdgCode(); - if(TMath::Abs(pdg) == 22) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherGamma(imother,mcEvent); - } - return -1; - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - // Take mother - Int_t imother = mctrackaod->GetMother(); - if(imother < 0) return -1; - AliAODMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - // Check gamma - Int_t pdg = mothertrack->GetPdgCode(); - if(TMath::Abs(pdg) == 22) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherGamma(imother,mcEvent); - } - return -1; - - } - - return -1; - - -} -// -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherPi0(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the lab of pi0 mother or -1 if not pi0 - // - - if(tr < 0) return -1; - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - TParticle *particle = 0x0; - particle = mctrackesd->Particle(); - // Take mother - if(!particle) return -1; - Int_t imother = particle->GetFirstMother(); - if(imother < 0) return -1; - AliMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - TParticle * mother = mothertrack->Particle(); - if(!mother) return -1; - // Check gamma - Int_t pdg = mother->GetPdgCode(); - if(TMath::Abs(pdg) == 111) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherPi0(imother,mcEvent); - } - return -1; - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - // Take mother - Int_t imother = mctrackaod->GetMother(); - if(imother < 0) return -1; - AliAODMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - // Check gamma - Int_t pdg = mothertrack->GetPdgCode(); - if(TMath::Abs(pdg) == 111) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherPi0(imother,mcEvent); - } - return -1; - } - - return -1; - -} -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherC(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the lab of signal mother or -1 if not signal - // - - if(tr < 0) return -1; - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - TParticle *particle = 0x0; - particle = mctrackesd->Particle(); - // Take mother - if(!particle) return -1; - Int_t imother = particle->GetFirstMother(); - if(imother < 0) return -1; - AliMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - TParticle * mother = mothertrack->Particle(); - if(!mother) return -1; - // Check gamma - Int_t pdg = mother->GetPdgCode(); - if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherC(imother,mcEvent); - } - return -1; - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - // Take mother - Int_t imother = mctrackaod->GetMother(); - if(imother < 0) return -1; - AliAODMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - // Check gamma - Int_t pdg = mothertrack->GetPdgCode(); - if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherC(imother,mcEvent); - } - return -1; - } - - return -1; - -} -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherB(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the lab of signal mother or -1 if not signal - // - - if(tr < 0) return -1; - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - TParticle *particle = 0x0; - particle = mctrackesd->Particle(); - // Take mother - if(!particle) return -1; - Int_t imother = particle->GetFirstMother(); - if(imother < 0) return -1; - AliMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - TParticle * mother = mothertrack->Particle(); - if(!mother) return -1; - // Check gamma - Int_t pdg = mother->GetPdgCode(); - if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherB(imother,mcEvent); - } - return -1; - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - // Take mother - Int_t imother = mctrackaod->GetMother(); - if(imother < 0) return -1; - AliAODMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - // Check gamma - Int_t pdg = mothertrack->GetPdgCode(); - if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherB(imother,mcEvent); - } - return -1; - } - - return -1; - -} -//____________________________________________________________________________________________________________ -Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherEta(Int_t tr, AliMCEvent* mcEvent) { - - // - // Return the lab of pi0 mother or -1 if not pi0 - // - - if(tr < 0) return -1; - AliVParticle *mctrack = mcEvent->GetTrack(tr); - - if(mctrack->IsA() == AliMCParticle::Class()) { - AliMCParticle *mctrackesd = NULL; - if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - TParticle *particle = 0x0; - particle = mctrackesd->Particle(); - // Take mother - if(!particle) return -1; - Int_t imother = particle->GetFirstMother(); - if(imother < 0) return -1; - AliMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - TParticle * mother = mothertrack->Particle(); - if(!mother) return -1; - // Check gamma - Int_t pdg = mother->GetPdgCode(); - if(TMath::Abs(pdg) == 221) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherEta(imother,mcEvent); - } - return -1; - } - - if(mctrack->IsA() == AliAODMCParticle::Class()) { - AliAODMCParticle *mctrackaod = NULL; - if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; - // Take mother - Int_t imother = mctrackaod->GetMother(); - if(imother < 0) return -1; - AliAODMCParticle *mothertrack = NULL; - if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; - // Check gamma - Int_t pdg = mothertrack->GetPdgCode(); - if(TMath::Abs(pdg) == 221) return imother; - if(TMath::Abs(pdg) == 11) { - return IsMotherEta(imother,mcEvent); - } - return -1; - } - - return -1; - -} +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ +// +// Flow task +// +// Authors: +// Raphaelle Bailhache +// Theodor Rascanu +// +#include "TROOT.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TChain.h" +#include "TVector2.h" +#include "THnSparse.h" +#include "TMath.h" +#include "TRandom3.h" +#include "TProfile.h" +#include "TProfile2D.h" +#include "TLorentzVector.h" +#include "TParticle.h" +#include "TF1.h" + +#include +#include + +#include "AliVEventHandler.h" +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" + +#include "AliVEvent.h" +#include "AliESDInputHandler.h" +#include "AliMCEvent.h" +#include "AliESD.h" +#include "AliESDEvent.h" +#include "AliPID.h" +#include "AliPIDResponse.h" +#include "AliESDVZERO.h" +#include "AliESDUtils.h" +#include "AliMCParticle.h" +#include "AliAODMCParticle.h" +#include "AliAODEvent.h" +#include "AliAODVertex.h" +#include "AliAODTrack.h" +#include "AliVTrack.h" +#include "AliESDtrack.h" +#include "AliESDtrackCuts.h" +#include "AliAODTrack.h" +#include "AliStack.h" +#include "AliMCEvent.h" + +#include "AliFlowCandidateTrack.h" +#include "AliFlowEvent.h" +#include "AliFlowTrackCuts.h" +#include "AliFlowVector.h" +#include "AliFlowCommonConstants.h" +#include "AliKFParticle.h" +#include "AliKFVertex.h" + +#include "AliHFEcuts.h" +#include "AliHFEpid.h" +#include "AliHFEpidQAmanager.h" +#include "AliHFEtools.h" +#include "AliHFEVZEROEventPlane.h" + +#include "AliCentrality.h" +#include "AliEventplane.h" +#include "AliAnalysisTaskFlowTPCTOFEPSP.h" +#include "AliAODMCHeader.h" +#include "TClonesArray.h" +#include "AliHFENonPhotonicElectron.h" + +ClassImp(AliAnalysisTaskFlowTPCTOFEPSP) + +//____________________________________________________________________ +AliAnalysisTaskFlowTPCTOFEPSP::AliAnalysisTaskFlowTPCTOFEPSP() : + AliAnalysisTaskSE(), + fListHist(0x0), + fAODAnalysis(kFALSE), + fFilter(1<<4), + fAODMCHeader(NULL), + fAODArrayMCInfo(NULL), + fBackgroundSubtraction(NULL), + fVZEROEventPlane(kFALSE), + fVZEROEventPlaneA(kFALSE), + fVZEROEventPlaneC(kFALSE), + fSubEtaGapTPC(kFALSE), + fEtaGap(0.0), + fNbBinsCentralityQCumulant(4), + fNbBinsPtQCumulant(12), + fMinPtQCumulant(0.2), + fMaxPtQCumulant(6.0), + fAfterBurnerOn(kFALSE), + fNonFlowNumberOfTrackClones(0), + fV1(0.), + fV2(0.), + fV3(0.), + fV4(0.), + fV5(0.), + fMaxNumberOfIterations(100), + fPrecisionPhi(0.001), + fUseMCReactionPlane(kFALSE), + fSP(kFALSE), + fMCPID(kFALSE), + fNoPID(kFALSE), + fChi2OverNDFCut(3.0), + fMaxdca(3.0), + fMaxopeningtheta(0.02), + fMaxopeningphi(0.1), + fMaxopening3D(0.1), + fMaxInvmass(0.1), + fSetMassConstraint(kFALSE), + fMonitorEventPlane(kFALSE), + fMonitorContamination(kFALSE), + fMonitorPhotonic(kFALSE), + fMonitorWithoutPID(kFALSE), + fMonitorTrackCuts(kFALSE), + fMonitorQCumulant(kFALSE), + fcutsRP(0), + fcutsPOI(0), + fHFECuts(0), + fPID(0), + fPIDTOFOnly(0), + fPIDqa(0), + fflowEvent(NULL), + fHFEBackgroundCuts(0), + fPIDBackground(0), + fPIDBackgroundqa(0), + fAlgorithmMA(kTRUE), + fArraytrack(NULL), + fCounterPoolBackground(0), + fHFEVZEROEventPlane(0x0), + fHistEV(0), + fHistPileUp(0), + fPileUpCut(kFALSE), + fEventPlane(0x0), + fEventPlaneaftersubtraction(0x0), + fFractionContamination(0x0), + fContaminationv2(0x0), + fCosSin2phiep(0x0), + fCos2phie(0x0), + fSin2phie(0x0), + fCos2phiep(0x0), + fSin2phiep(0x0), + fSin2phiephiep(0x0), + fCosResabc(0x0), + fSinResabc(0x0), + fProfileCosResab(0x0), + fProfileCosResac(0x0), + fProfileCosResbc(0x0), + fCosRes(0x0), + fSinRes(0x0), + fProfileCosRes(0x0), + fTrackingCuts(0x0), + fDeltaPhiMapsBeforePID(0x0), + fCosPhiMapsBeforePID(0x0), + fDeltaPhiMaps(0x0), + fDeltaPhiMapsContamination(0x0), + fCosPhiMaps(0x0), + fProfileCosPhiMaps(0x0), + fDeltaPhiMapsTaggedPhotonic(0x0), + //fCosPhiMapsTaggedPhotonic(0x0), + fDeltaPhiMapsTaggedNonPhotonic(0x0), + //fCosPhiMapsTaggedNonPhotonic(0x0), + fDeltaPhiMapsTaggedPhotonicLS(0x0), + //fCosPhiMapsTaggedPhotonicLS(0x0), + fMCSourceDeltaPhiMaps(0x0), + fOppSignDeltaPhiMaps(0x0), + fSameSignDeltaPhiMaps(0x0), + fOppSignAngle(0x0), + fSameSignAngle(0x0), + fDebugStreamer(0) +{ + // Constructor + + for(Int_t k = 0; k < 10; k++) { + fBinCentralityLess[k] = 0.0; + } + for(Int_t k = 0; k < 11; k++) { + fContamination[k] = NULL; + fv2contamination[k] = NULL; + } + +} +//______________________________________________________________________________ +AliAnalysisTaskFlowTPCTOFEPSP:: AliAnalysisTaskFlowTPCTOFEPSP(const char *name) : + AliAnalysisTaskSE(name), + fListHist(0x0), + fAODAnalysis(kFALSE), + fFilter(1<<4), + fAODMCHeader(NULL), + fAODArrayMCInfo(NULL), + fBackgroundSubtraction(NULL), + fVZEROEventPlane(kFALSE), + fVZEROEventPlaneA(kFALSE), + fVZEROEventPlaneC(kFALSE), + fSubEtaGapTPC(kFALSE), + fEtaGap(0.0), + fNbBinsCentralityQCumulant(4), + fNbBinsPtQCumulant(15), + fMinPtQCumulant(0.0), + fMaxPtQCumulant(6.0), + fAfterBurnerOn(kFALSE), + fNonFlowNumberOfTrackClones(0), + fV1(0.), + fV2(0.), + fV3(0.), + fV4(0.), + fV5(0.), + fMaxNumberOfIterations(100), + fPrecisionPhi(0.001), + fUseMCReactionPlane(kFALSE), + fSP(kFALSE), + fMCPID(kFALSE), + fNoPID(kFALSE), + fChi2OverNDFCut(3.0), + fMaxdca(3.0), + fMaxopeningtheta(0.02), + fMaxopeningphi(0.1), + fMaxopening3D(0.1), + fMaxInvmass(0.1), + fSetMassConstraint(kFALSE), + fMonitorEventPlane(kFALSE), + fMonitorContamination(kFALSE), + fMonitorPhotonic(kFALSE), + fMonitorWithoutPID(kFALSE), + fMonitorTrackCuts(kFALSE), + fMonitorQCumulant(kFALSE), + fcutsRP(0), + fcutsPOI(0), + fHFECuts(0), + fPID(0), + fPIDTOFOnly(0), + fPIDqa(0), + fflowEvent(NULL), + fHFEBackgroundCuts(0), + fPIDBackground(0), + fPIDBackgroundqa(0), + fAlgorithmMA(kTRUE), + fArraytrack(NULL), + fCounterPoolBackground(0), + fHFEVZEROEventPlane(0x0), + fHistEV(0), + fHistPileUp(0), + fPileUpCut(kFALSE), + fEventPlane(0x0), + fEventPlaneaftersubtraction(0x0), + fFractionContamination(0x0), + fContaminationv2(0x0), + fCosSin2phiep(0x0), + fCos2phie(0x0), + fSin2phie(0x0), + fCos2phiep(0x0), + fSin2phiep(0x0), + fSin2phiephiep(0x0), + fCosResabc(0x0), + fSinResabc(0x0), + fProfileCosResab(0x0), + fProfileCosResac(0x0), + fProfileCosResbc(0x0), + fCosRes(0x0), + fSinRes(0x0), + fProfileCosRes(0x0), + fTrackingCuts(0x0), + fDeltaPhiMapsBeforePID(0x0), + fCosPhiMapsBeforePID(0x0), + fDeltaPhiMaps(0x0), + fDeltaPhiMapsContamination(0x0), + fCosPhiMaps(0x0), + fProfileCosPhiMaps(0x0), + fDeltaPhiMapsTaggedPhotonic(0x0), + //fCosPhiMapsTaggedPhotonic(0x0), + fDeltaPhiMapsTaggedNonPhotonic(0x0), + //fCosPhiMapsTaggedNonPhotonic(0x0), + fDeltaPhiMapsTaggedPhotonicLS(0x0), + //fCosPhiMapsTaggedPhotonicLS(0x0), + fMCSourceDeltaPhiMaps(0x0), + fOppSignDeltaPhiMaps(0x0), + fSameSignDeltaPhiMaps(0x0), + fOppSignAngle(0x0), + fSameSignAngle(0x0), + fDebugStreamer(0) +{ + // + // named ctor + // + + for(Int_t k = 0; k < 10; k++) { + fBinCentralityLess[k] = 0.0; + } + fBinCentralityLess[0] = 0.0; + fBinCentralityLess[1] = 20.0; + fBinCentralityLess[2] = 40.0; + fBinCentralityLess[3] = 60.0; + fBinCentralityLess[4] = 80.0; + + for(Int_t k = 0; k < 11; k++) { + fContamination[k] = NULL; + fv2contamination[k] = NULL; + } + + fPID = new AliHFEpid("hfePid"); + fPIDqa = new AliHFEpidQAmanager; + + fPIDBackground = new AliHFEpid("hfePidBackground"); + fPIDBackgroundqa = new AliHFEpidQAmanager; + + fPIDTOFOnly = new AliHFEpid("hfePidTOFOnly"); + + DefineInput(0,TChain::Class()); + DefineOutput(1, TList::Class()); + //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { + // DefineOutput(bincless+2,AliFlowEventSimple::Class()); + //} + +} +//____________________________________________________________ +AliAnalysisTaskFlowTPCTOFEPSP::AliAnalysisTaskFlowTPCTOFEPSP(const AliAnalysisTaskFlowTPCTOFEPSP &ref): + AliAnalysisTaskSE(ref), + fListHist(NULL), + fAODAnalysis(ref.fAODAnalysis), + fFilter(ref.fFilter), + fAODMCHeader(ref.fAODMCHeader), + fAODArrayMCInfo(ref.fAODArrayMCInfo), + fBackgroundSubtraction(ref.fBackgroundSubtraction), + fVZEROEventPlane(ref.fVZEROEventPlane), + fVZEROEventPlaneA(ref.fVZEROEventPlaneA), + fVZEROEventPlaneC(ref.fVZEROEventPlaneC), + fSubEtaGapTPC(ref.fSubEtaGapTPC), + fEtaGap(ref.fEtaGap), + fNbBinsCentralityQCumulant(ref.fNbBinsCentralityQCumulant), + fNbBinsPtQCumulant(ref.fNbBinsPtQCumulant), + fMinPtQCumulant(ref.fMinPtQCumulant), + fMaxPtQCumulant(ref.fMaxPtQCumulant), + fAfterBurnerOn(ref.fAfterBurnerOn), + fNonFlowNumberOfTrackClones(ref.fNonFlowNumberOfTrackClones), + fV1(ref.fV1), + fV2(ref.fV2), + fV3(ref.fV3), + fV4(ref.fV4), + fV5(ref.fV5), + fMaxNumberOfIterations(ref.fMaxNumberOfIterations), + fPrecisionPhi(ref.fPrecisionPhi), + fUseMCReactionPlane(ref.fUseMCReactionPlane), + fSP(ref.fSP), + fMCPID(ref.fMCPID), + fNoPID(ref.fNoPID), + fChi2OverNDFCut(ref.fChi2OverNDFCut), + fMaxdca(ref.fMaxdca), + fMaxopeningtheta(ref.fMaxopeningtheta), + fMaxopeningphi(ref.fMaxopeningphi), + fMaxopening3D(ref.fMaxopening3D), + fMaxInvmass(ref.fMaxInvmass), + fSetMassConstraint(ref.fSetMassConstraint), + fMonitorEventPlane(ref.fMonitorEventPlane), + fMonitorContamination(ref.fMonitorContamination), + fMonitorPhotonic(ref.fMonitorPhotonic), + fMonitorWithoutPID(ref.fMonitorWithoutPID), + fMonitorTrackCuts(ref.fMonitorTrackCuts), + fMonitorQCumulant(ref.fMonitorQCumulant), + fcutsRP(NULL), + fcutsPOI(NULL), + fHFECuts(NULL), + fPID(NULL), + fPIDTOFOnly(NULL), + fPIDqa(NULL), + fflowEvent(NULL), + fHFEBackgroundCuts(NULL), + fPIDBackground(NULL), + fPIDBackgroundqa(NULL), + fAlgorithmMA(ref.fAlgorithmMA), + fArraytrack(NULL), + fCounterPoolBackground(ref.fCounterPoolBackground), + fHFEVZEROEventPlane(NULL), + fHistEV(NULL), + fHistPileUp(NULL), + fPileUpCut(kFALSE), + fEventPlane(NULL), + fEventPlaneaftersubtraction(NULL), + fFractionContamination(NULL), + fContaminationv2(NULL), + fCosSin2phiep(NULL), + fCos2phie(NULL), + fSin2phie(NULL), + fCos2phiep(NULL), + fSin2phiep(NULL), + fSin2phiephiep(NULL), + fCosResabc(NULL), + fSinResabc(NULL), + fProfileCosResab(NULL), + fProfileCosResac(NULL), + fProfileCosResbc(NULL), + fCosRes(NULL), + fSinRes(NULL), + fProfileCosRes(NULL), + fTrackingCuts(NULL), + fDeltaPhiMapsBeforePID(NULL), + fCosPhiMapsBeforePID(NULL), + fDeltaPhiMaps(NULL), + fDeltaPhiMapsContamination(NULL), + fCosPhiMaps(NULL), + fProfileCosPhiMaps(NULL), + fDeltaPhiMapsTaggedPhotonic(NULL), + //fCosPhiMapsTaggedPhotonic(NULL), + fDeltaPhiMapsTaggedNonPhotonic(NULL), + //fCosPhiMapsTaggedNonPhotonic(NULL), + fDeltaPhiMapsTaggedPhotonicLS(NULL), + //fCosPhiMapsTaggedPhotonicLS(NULL), + fMCSourceDeltaPhiMaps(NULL), + fOppSignDeltaPhiMaps(NULL), + fSameSignDeltaPhiMaps(NULL), + fOppSignAngle(NULL), + fSameSignAngle(NULL), + fDebugStreamer(0) +{ + // + // Copy Constructor + // + + for(Int_t k = 0; k < 10; k++) { + fBinCentralityLess[k] = 0.0; + } + for(Int_t k = 0; k < 11; k++) { + fContamination[k] = NULL; + fv2contamination[k] = NULL; + } + + + ref.Copy(*this); +} + +//____________________________________________________________ +AliAnalysisTaskFlowTPCTOFEPSP &AliAnalysisTaskFlowTPCTOFEPSP::operator=(const AliAnalysisTaskFlowTPCTOFEPSP &ref){ + // + // Assignment operator + // + if(this == &ref) + ref.Copy(*this); + return *this; +} + +//____________________________________________________________ +void AliAnalysisTaskFlowTPCTOFEPSP::Copy(TObject &o) const { + // + // Copy into object o + // + AliAnalysisTaskFlowTPCTOFEPSP &target = dynamic_cast(o); + target.fListHist = fListHist; + target.fAODAnalysis = fAODAnalysis; + target.fFilter = fFilter; + target.fAODMCHeader = fAODMCHeader; + target.fAODArrayMCInfo = fAODArrayMCInfo; + target.fBackgroundSubtraction = fBackgroundSubtraction; + target.fVZEROEventPlane = fVZEROEventPlane; + target.fVZEROEventPlaneA = fVZEROEventPlaneA; + target.fVZEROEventPlaneC = fVZEROEventPlaneC; + target.fSubEtaGapTPC = fSubEtaGapTPC; + target.fEtaGap = fEtaGap; + target.fNbBinsCentralityQCumulant = fNbBinsCentralityQCumulant; + target.fNbBinsPtQCumulant = fNbBinsPtQCumulant; + target.fMinPtQCumulant = fMinPtQCumulant; + target.fMaxPtQCumulant = fMaxPtQCumulant; + target.fAfterBurnerOn = fAfterBurnerOn; + target.fNonFlowNumberOfTrackClones = fNonFlowNumberOfTrackClones; + target.fV1 = fV1; + target.fV2 = fV2; + target.fV3 = fV3; + target.fV4 = fV4; + target.fV5 = fV5; + target.fMaxNumberOfIterations = fMaxNumberOfIterations; + target.fPrecisionPhi = fPrecisionPhi; + target.fUseMCReactionPlane = fUseMCReactionPlane; + target.fSP = fSP; + target.fMCPID = fMCPID; + target.fNoPID = fNoPID; + target.fChi2OverNDFCut = fChi2OverNDFCut; + target.fMaxdca = fMaxdca; + target.fMaxopeningtheta = fMaxopeningtheta; + target.fMaxopeningphi = fMaxopeningphi; + target.fMaxopening3D = fMaxopening3D; + target.fMaxInvmass = fMaxInvmass; + target.fSetMassConstraint = fSetMassConstraint; + target.fMonitorEventPlane = fMonitorEventPlane; + target.fMonitorContamination = fMonitorContamination; + target.fMonitorPhotonic = fMonitorPhotonic; + target.fMonitorWithoutPID = fMonitorWithoutPID; + target.fMonitorTrackCuts = fMonitorTrackCuts; + target.fMonitorQCumulant = fMonitorQCumulant; + target.fcutsRP = fcutsRP; + target.fcutsPOI = fcutsPOI; + target.fHFECuts = fHFECuts; + target.fPID = fPID; + target.fPIDTOFOnly = fPIDTOFOnly; + target.fPIDqa = fPIDqa; + target.fflowEvent = fflowEvent; + target.fHFEBackgroundCuts = fHFEBackgroundCuts; + target.fPIDBackground = fPIDBackground; + target.fPIDBackgroundqa = fPIDBackgroundqa; + target.fAlgorithmMA = fAlgorithmMA; + target.fArraytrack = fArraytrack; + target.fCounterPoolBackground = fCounterPoolBackground; + target.fHFEVZEROEventPlane = fHFEVZEROEventPlane; + target.fHistEV=fHistEV; + target.fHistPileUp=fHistPileUp; + target.fPileUpCut=fPileUpCut; + target.fEventPlane=fEventPlane; + target.fEventPlaneaftersubtraction=fEventPlaneaftersubtraction; + target.fFractionContamination=fFractionContamination; + target.fContaminationv2=fContaminationv2; + target.fCosSin2phiep=fCosSin2phiep; + target.fCos2phie=fCos2phie; + target.fSin2phie=fSin2phie; + target.fCos2phiep=fCos2phiep; + target.fSin2phiep=fSin2phiep; + target.fSin2phiephiep=fSin2phiephiep; + target.fCosResabc=fCosResabc; + target.fSinResabc=fSinResabc; + target.fProfileCosResab=fProfileCosResab; + target.fProfileCosResac=fProfileCosResac; + target.fProfileCosResbc=fProfileCosResbc; + target.fCosRes=fCosRes; + target.fSinRes=fSinRes; + target.fProfileCosRes=fProfileCosRes; + target.fTrackingCuts=fTrackingCuts; + target.fDeltaPhiMapsBeforePID=fDeltaPhiMapsBeforePID; + target.fCosPhiMapsBeforePID=fCosPhiMapsBeforePID; + target.fDeltaPhiMaps=fDeltaPhiMaps; + target.fDeltaPhiMapsContamination=fDeltaPhiMapsContamination; + target.fCosPhiMaps=fCosPhiMaps; + target.fProfileCosPhiMaps=fProfileCosPhiMaps; + target.fDeltaPhiMapsTaggedPhotonic=fDeltaPhiMapsTaggedPhotonic; + target.fDeltaPhiMapsTaggedNonPhotonic=fDeltaPhiMapsTaggedNonPhotonic; + target.fDeltaPhiMapsTaggedPhotonicLS=fDeltaPhiMapsTaggedPhotonicLS; + target.fMCSourceDeltaPhiMaps=fMCSourceDeltaPhiMaps; + target.fOppSignDeltaPhiMaps=fOppSignDeltaPhiMaps; + target.fSameSignDeltaPhiMaps=fSameSignDeltaPhiMaps; + target.fOppSignAngle=fOppSignAngle; + target.fSameSignAngle=fSameSignAngle; + + + for(Int_t k = 0; k < 10; k++) { + target.fBinCentralityLess[k] = fBinCentralityLess[k]; + } + for(Int_t k = 0; k < 11; k++) { + target.fContamination[k] = fContamination[k]; + target.fv2contamination[k] = fv2contamination[k]; + } + target.fDebugStreamer=fDebugStreamer; +} +//____________________________________________________________ +AliAnalysisTaskFlowTPCTOFEPSP::~AliAnalysisTaskFlowTPCTOFEPSP(){ + // + // Destructor + // + + + if(fArraytrack) delete fArraytrack; + if(fListHist) delete fListHist; + if(fcutsRP) delete fcutsRP; + if(fcutsPOI) delete fcutsPOI; + if(fHFECuts) delete fHFECuts; + if(fPID) delete fPID; + if(fPIDTOFOnly) delete fPIDTOFOnly; + //if(fPIDqa) delete fPIDqa; + if(fflowEvent) delete fflowEvent; + if(fHFEBackgroundCuts) delete fHFEBackgroundCuts; + if(fPIDBackground) delete fPIDBackground; + //if(fBackgroundSubtraction) delete fBackgroundSubtraction; + //if(fPIDBackgroundqa) delete fPIDBackgroundqa; + //if(fHFEVZEROEventPlane) delete fHFEVZEROEventPlane; + if ( fDebugStreamer ) delete fDebugStreamer; + + +} +//________________________________________________________________________ +void AliAnalysisTaskFlowTPCTOFEPSP::UserCreateOutputObjects() +{ + + //******************** + // Create histograms + //******************** + + //************** + // Cuts + //************** + + //---------Data selection---------- + //kMC, kGlobal, kTPCstandalone, kSPDtracklet, kPMD + //AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; + //AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal; + + //---------Parameter mixing-------- + //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt + //AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure; + //AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure; + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: User create output objects"); + + + // AOD or ESD + AliVEventHandler *inputHandler = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){ + SetAODAnalysis(kTRUE); + AliDebug(2,"Put AOD analysis on"); + } else { + SetAODAnalysis(kFALSE); + } + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: AOD ESD"); + + // RP TRACK CUTS: + fcutsRP = AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010(); + fcutsRP->SetName("StandartTPC"); + fcutsRP->SetEtaRange(-0.9,0.9); + fcutsRP->SetQA(kTRUE); + //TList *qaCutsRP = fcutsRP->GetQA(); + //qaCutsRP->SetName("QA_StandartTPC_RP"); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cutsRP"); + + //POI TRACK CUTS: + fcutsPOI = new AliFlowTrackCuts("dummy"); + fcutsPOI->SetParamType(AliFlowTrackCuts::kGlobal); + fcutsPOI->SetPtRange(+1,-1); // select nothing QUICK + fcutsPOI->SetEtaRange(+1,-1); // select nothing VZERO + + if( fflowEvent ){ + fflowEvent->~AliFlowEvent(); + new(fflowEvent) AliFlowEvent(fcutsRP,fcutsPOI); + } + else fflowEvent = new AliFlowEvent(fcutsRP,fcutsPOI); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cutsPOI"); + + // Flow + AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster(); + cc->SetNbinsMult(10000); + cc->SetMultMin(0); + cc->SetMultMax(10000.); + cc->SetNbinsPt(fNbBinsPtQCumulant); + cc->SetPtMin(fMinPtQCumulant); + cc->SetPtMax(fMaxPtQCumulant); + cc->SetNbinsPhi(180); + cc->SetPhiMin(0.0); + cc->SetPhiMax(TMath::TwoPi()); + cc->SetNbinsEta(200); + cc->SetEtaMin(-0.9); + cc->SetEtaMax(+0.9); + cc->SetNbinsQ(500); + cc->SetQMin(0.0); + cc->SetQMax(3.0); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: common constants"); + + // HFE cuts + + if(!fHFECuts){ + fHFECuts = new AliHFEcuts; + fHFECuts->CreateStandardCuts(); + } + fHFECuts->Initialize(); + if(fAODAnalysis) fHFECuts->SetAOD(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: HFE cuts"); + + + // PID HFE + //fPID->SetHasMCData(HasMCData()); + if(!fPID) { + fPID =new AliHFEpid("hfePid"); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid init 0"); + } + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid init 1"); + if(!fPID->GetNumberOfPIDdetectors()) fPID->AddDetector("TPC", 0); + AliDebug(2,Form("AliAnalysisTaskFlowTPCTOFEPSP: GetNumber of PID detectors %d",fPID->GetNumberOfPIDdetectors())); + fPID->InitializePID(); + fPIDqa->Initialize(fPID); + fPID->SortDetectors(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid and pidqa"); + + if(!fPIDTOFOnly->GetNumberOfPIDdetectors()) { + fPIDTOFOnly->AddDetector("TOF", 0); + fPIDTOFOnly->ConfigureTOF(3.); + } + fPIDTOFOnly->InitializePID(); + fPIDTOFOnly->SortDetectors(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pidtof"); + + // HFE Background cuts + + if(!fHFEBackgroundCuts){ + fHFEBackgroundCuts = new AliESDtrackCuts(); + fHFEBackgroundCuts->SetName("nackgroundcuts"); + //Configure Default Track Cuts + fHFEBackgroundCuts->SetAcceptKinkDaughters(kFALSE); + fHFEBackgroundCuts->SetRequireTPCRefit(kTRUE); + fHFEBackgroundCuts->SetEtaRange(-0.9,0.9); + fHFEBackgroundCuts->SetRequireSigmaToVertex(kTRUE); + fHFEBackgroundCuts->SetMaxChi2PerClusterTPC(4.0); + fHFEBackgroundCuts->SetMinNClustersTPC(50); + fHFEBackgroundCuts->SetPtRange(0.3,1e10); + } + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: hfe background"); + + // PID background HFE + if(!fPIDBackground->GetNumberOfPIDdetectors()) fPIDBackground->AddDetector("TPC", 0); + fPIDBackground->InitializePID(); + fPIDBackgroundqa->Initialize(fPIDBackground); + fPIDBackground->SortDetectors(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: pid background"); + + if (fMonitorPhotonic) { + if(!fBackgroundSubtraction) fBackgroundSubtraction = new AliHFENonPhotonicElectron(); + if(fAODAnalysis) fBackgroundSubtraction->SetAOD(kTRUE); + fBackgroundSubtraction->Init(); + } + + + + //************************** + // Bins for the THnSparse + //************************** + + /* + Int_t nBinsPt = 44; + Double_t minPt = 0.1; + Double_t maxPt = 20.0; + Double_t binLimLogPt[nBinsPt+1]; + Double_t binLimPt[nBinsPt+1]; + for(Int_t i=0; i<=nBinsPt; i++) binLimLogPt[i]=(Double_t)TMath::Log10(minPt) + (TMath::Log10(maxPt)-TMath::Log10(minPt))/nBinsPt*(Double_t)i ; + for(Int_t i=0; i<=nBinsPt; i++) binLimPt[i]=(Double_t)TMath::Power(10,binLimLogPt[i]); + */ + + Int_t nBinsPt = 20; + Double_t binLimPt[21] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, + 1.3, 1.4, 1.5, 2., 2.5, 3., 4., 6.}; + + Int_t nBinsPtPlus = fNbBinsPtQCumulant; + Double_t minPtPlus = fMinPtQCumulant; + Double_t maxPtPlus = fMaxPtQCumulant; + Double_t binLimPtPlus[nBinsPtPlus+1]; + for(Int_t i=0; i<=nBinsPtPlus; i++) binLimPtPlus[i]=(Double_t)minPtPlus + (maxPtPlus-minPtPlus)/nBinsPtPlus*(Double_t)i ; + + Int_t nBinsEta = 8; + Double_t minEta = -0.8; + Double_t maxEta = 0.8; + Double_t binLimEta[nBinsEta+1]; + for(Int_t i=0; i<=nBinsEta; i++) binLimEta[i]=(Double_t)minEta + (maxEta-minEta)/nBinsEta*(Double_t)i ; + + Int_t nBinsStep = 6; + Double_t minStep = 0.; + Double_t maxStep = 6.; + Double_t binLimStep[nBinsStep+1]; + for(Int_t i=0; i<=nBinsStep; i++) binLimStep[i]=(Double_t)minStep + (maxStep-minStep)/nBinsStep*(Double_t)i ; + + Int_t nBinsEtaLess = 2; + Double_t binLimEtaLess[nBinsEtaLess+1]; + for(Int_t i=0; i<=nBinsEtaLess; i++) binLimEtaLess[i]=(Double_t)minEta + (maxEta-minEta)/nBinsEtaLess*(Double_t)i ; + + Int_t nBinsCos = 50; + Double_t minCos = -1.0; + Double_t maxCos = 1.0; + Double_t binLimCos[nBinsCos+1]; + for(Int_t i=0; i<=nBinsCos; i++) binLimCos[i]=(Double_t)minCos + (maxCos-minCos)/nBinsCos*(Double_t)i ; + + // Int_t nBinsCosSP = 50; + // Double_t minCosSP = -100.0; + // Double_t maxCosSP = 100.0; + // Double_t binLimCosSP[nBinsCosSP+1]; + // for(Int_t i=0; i<=nBinsCosSP; i++) binLimCosSP[i]=(Double_t)minCosSP + (maxCosSP-minCosSP)/nBinsCosSP*(Double_t)i ; + + Int_t nBinsC = 11; + Double_t minC = 0.0; + Double_t maxC = 11.0; + Double_t binLimC[nBinsC+1]; + for(Int_t i=0; i<=nBinsC; i++) binLimC[i]=(Double_t)minC + (maxC-minC)/nBinsC*(Double_t)i ; + + Int_t nBinsCMore = 20; + Double_t minCMore = 0.0; + Double_t maxCMore = 20.0; + Double_t binLimCMore[nBinsCMore+1]; + for(Int_t i=0; i<=nBinsCMore; i++) binLimCMore[i]=(Double_t)minCMore + (maxCMore-minCMore)/nBinsCMore*(Double_t)i ; + + Int_t nBinsCEvenMore = 100; + Double_t minCEvenMore = 0.0; + Double_t maxCEvenMore = 100.0; + Double_t binLimCEvenMore[nBinsCEvenMore+1]; + for(Int_t i=0; i<=nBinsCEvenMore; i++) binLimCEvenMore[i]=(Double_t)minCEvenMore + (maxCEvenMore-minCEvenMore)/nBinsCEvenMore*(Double_t)i ; + + Int_t nBinsPhi = 8; + Double_t minPhi = 0.0; + Double_t maxPhi = TMath::Pi(); + Double_t binLimPhi[nBinsPhi+1]; + for(Int_t i=0; i<=nBinsPhi; i++) { + binLimPhi[i]=(Double_t)minPhi + (maxPhi-minPhi)/nBinsPhi*(Double_t)i ; + AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i)); + } + + Int_t nBinsPhiLess = 2.0; + Double_t minPhiLess = 0.0; + Double_t maxPhiLess = 2.0; + Double_t binLimPhiLess[nBinsPhiLess+1]; + for(Int_t i=0; i<=nBinsPhiLess; i++) { + binLimPhiLess[i]=(Double_t)minPhiLess + (maxPhiLess-minPhiLess)/nBinsPhiLess*(Double_t)i ; + } + + Int_t nBinsTPCdEdx = 140; + Double_t minTPCdEdx = -12.0; + Double_t maxTPCdEdx = 12.0; + Double_t binLimTPCdEdx[nBinsTPCdEdx+1]; + for(Int_t i=0; i<=nBinsTPCdEdx; i++) { + binLimTPCdEdx[i]=(Double_t)minTPCdEdx + (maxTPCdEdx-minTPCdEdx)/nBinsTPCdEdx*(Double_t)i ; + } + + Int_t nBinsAngle = 40; + Double_t minAngle = 0.0; + Double_t maxAngle = 1.0; + Double_t binLimAngle[nBinsAngle+1]; + for(Int_t i=0; i<=nBinsAngle; i++) { + binLimAngle[i]=(Double_t)minAngle + (maxAngle-minAngle)/nBinsAngle*(Double_t)i ; + AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i)); + } + + Int_t nBinsCharge = 2; + Double_t minCharge = -1.0; + Double_t maxCharge = 1.0; + Double_t binLimCharge[nBinsCharge+1]; + for(Int_t i=0; i<=nBinsCharge; i++) binLimCharge[i]=(Double_t)minCharge + (maxCharge-minCharge)/nBinsCharge*(Double_t)i ; + + Int_t nBinsSource = 10; + Double_t minSource = 0.; + Double_t maxSource = 10.; + Double_t binLimSource[nBinsSource+1]; + for(Int_t i=0; i<=nBinsSource; i++) binLimSource[i]=(Double_t)minSource + (maxSource-minSource)/nBinsSource*(Double_t)i ; + + Int_t nBinsInvMass = 50; + Double_t minInvMass = 0.; + Double_t maxInvMass = 0.3; + Double_t binLimInvMass[nBinsInvMass+1]; + for(Int_t i=0; i<=nBinsInvMass; i++) binLimInvMass[i]=(Double_t)minInvMass + (maxInvMass-minInvMass)/nBinsInvMass*(Double_t)i ; + + Int_t nBinsMult = 100; + Double_t minMult = 0.; + Double_t maxMult = 3000; + Double_t binLimMult[nBinsMult+1]; + //for(Int_t i=0; i<=nBinsMult; i++) binLimMult[i]=TMath::Power((Double_t)minMult + (TMath::Sqrt(maxMult)-TMath::Sqrt(minMult))/nBinsMult*(Double_t)i,2); + for(Int_t i=0; i<=nBinsMult; i++) binLimMult[i]=(Double_t)minMult + (maxMult-minMult)/nBinsMult*(Double_t)i; + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: variables"); + + //****************** + // Histograms + //****************** + + fListHist = new TList(); + fListHist->SetOwner(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: list"); + + // Minimum histos + + // Histos + fHistEV = new TH2D("fHistEV", "events", 3, 0, 3, 3, 0,3); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: histev"); + + // V0 multiplicity vs # of tracks vs centraliy + const Int_t nDimPU=4; + Int_t nBinPU[nDimPU] = {nBinsCEvenMore,nBinsCEvenMore,nBinsMult,nBinsMult}; + fHistPileUp = new THnSparseF("PileUp","PileUp",nDimPU,nBinPU); + fHistPileUp->SetBinEdges(0,binLimCEvenMore); + fHistPileUp->SetBinEdges(1,binLimCEvenMore); + fHistPileUp->SetBinEdges(2,binLimMult); + fHistPileUp->SetBinEdges(3,binLimMult); + fHistPileUp->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane"); + + // Event plane as function of phiep, centrality + const Int_t nDima=4; + Int_t nBina[nDima] = {nBinsPhi,nBinsPhi,nBinsPhi,nBinsC}; + fEventPlane = new THnSparseF("EventPlane","EventPlane",nDima,nBina); + fEventPlane->SetBinEdges(0,binLimPhi); + fEventPlane->SetBinEdges(1,binLimPhi); + fEventPlane->SetBinEdges(2,binLimPhi); + fEventPlane->SetBinEdges(3,binLimC); + fEventPlane->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane"); + + // Fraction of contamination, centrality + const Int_t nDimcont=2; + Int_t nBincont[nDimcont] = {nBinsPt,nBinsC}; + fFractionContamination = new THnSparseF("Contamination","Contamination",nDimcont,nBincont); + fFractionContamination->SetBinEdges(0,binLimPt); + fFractionContamination->SetBinEdges(1,binLimC); + fFractionContamination->Sumw2(); + // + fContaminationv2 = new TProfile2D("Contaminationv2","",nBinsC,binLimC,nBinsPt,binLimPt); + fContaminationv2->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: fraction of contamination"); + + // Resolution cosres_abc centrality + const Int_t nDimfbis=4; + Int_t nBinfbis[nDimfbis] = {nBinsCos,nBinsCos,nBinsCos,nBinsCMore}; + fCosResabc = new THnSparseF("CosRes_abc","CosRes_abc",nDimfbis,nBinfbis); + fCosResabc->SetBinEdges(0,binLimCos); + fCosResabc->SetBinEdges(1,binLimCos); + fCosResabc->SetBinEdges(2,binLimCos); + fCosResabc->SetBinEdges(3,binLimCMore); + fCosResabc->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosresabc"); + + // Resolution cosres centrality + const Int_t nDimf=2; + Int_t nBinf[nDimf] = {nBinsCos, nBinsCMore}; + fCosRes = new THnSparseF("CosRes","CosRes",nDimf,nBinf); + fCosRes->SetBinEdges(0,binLimCos); + fCosRes->SetBinEdges(1,binLimCMore); + fCosRes->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosres"); + + // Maps delta phi + const Int_t nDimg=5; + Int_t nBing[nDimg] = {nBinsPhi,nBinsC,nBinsPt, nBinsCharge,nBinsEtaLess}; + fDeltaPhiMaps = new THnSparseF("DeltaPhiMaps","DeltaPhiMaps",nDimg,nBing); + fDeltaPhiMaps->SetBinEdges(0,binLimPhi); + fDeltaPhiMaps->SetBinEdges(1,binLimC); + fDeltaPhiMaps->SetBinEdges(2,binLimPt); + fDeltaPhiMaps->SetBinEdges(3,binLimCharge); + fDeltaPhiMaps->SetBinEdges(4,binLimEtaLess); + fDeltaPhiMaps->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimaps"); + + // Maps cos phi + const Int_t nDimh=5; + Int_t nBinh[nDimh] = {nBinsCos,nBinsC,nBinsPt,nBinsCharge,nBinsEtaLess}; + fCosPhiMaps = new THnSparseF("CosPhiMaps","CosPhiMaps",nDimh,nBinh); + fCosPhiMaps->SetBinEdges(0,binLimCos); + fCosPhiMaps->SetBinEdges(1,binLimC); + fCosPhiMaps->SetBinEdges(2,binLimPt); + fCosPhiMaps->SetBinEdges(3,binLimCharge); + fCosPhiMaps->SetBinEdges(4,binLimEtaLess); + fCosPhiMaps->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosphimaps"); + + // + // fMonitorEventPlane + // + // + + if(fMonitorEventPlane) { + // Event Plane after subtraction as function of phiep, centrality, pt, eta + const Int_t nDimb=2; + Int_t nBinb[nDimb] = {nBinsPhi, nBinsC}; + fEventPlaneaftersubtraction = new THnSparseF("EventPlane_aftersubtraction","EventPlane_aftersubtraction",nDimb,nBinb); + fEventPlaneaftersubtraction->SetBinEdges(0,binLimPhi); + fEventPlaneaftersubtraction->SetBinEdges(1,binLimC); + fEventPlaneaftersubtraction->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: eventplane after sub"); + + // Monitoring of the event Plane cos(2phi) sin(2phi) centrality + const Int_t nDimi=3; + Int_t nBini[nDimi] = {nBinsCos, nBinsCos, nBinsCMore}; + fCosSin2phiep = new THnSparseF("CosSin2phiep","CosSin2phiep",nDimi,nBini); + fCosSin2phiep->SetBinEdges(0,binLimCos); + fCosSin2phiep->SetBinEdges(1,binLimCos); + fCosSin2phiep->SetBinEdges(2,binLimCMore); + fCosSin2phiep->Sumw2(); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cossin2phiep"); + + // Monitoring Event plane after subtraction of the track + const Int_t nDime=4; + Int_t nBine[nDime] = {nBinsCos, nBinsC, nBinsPt, nBinsEta}; + fCos2phie = new THnSparseF("cos2phie","cos2phie",nDime,nBine); + fCos2phie->SetBinEdges(2,binLimPt); + fCos2phie->SetBinEdges(3,binLimEta); + fCos2phie->SetBinEdges(0,binLimCos); + fCos2phie->SetBinEdges(1,binLimC); + fCos2phie->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cos2phie"); + fSin2phie = new THnSparseF("sin2phie","sin2phie",nDime,nBine); + fSin2phie->SetBinEdges(2,binLimPt); + fSin2phie->SetBinEdges(3,binLimEta); + fSin2phie->SetBinEdges(0,binLimCos); + fSin2phie->SetBinEdges(1,binLimC); + fSin2phie->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phie"); + fCos2phiep = new THnSparseF("cos2phiep","cos2phiep",nDime,nBine); + fCos2phiep->SetBinEdges(2,binLimPt); + fCos2phiep->SetBinEdges(3,binLimEta); + fCos2phiep->SetBinEdges(0,binLimCos); + fCos2phiep->SetBinEdges(1,binLimC); + fCos2phiep->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cos2phiep"); + fSin2phiep = new THnSparseF("sin2phiep","sin2phiep",nDime,nBine); + fSin2phiep->SetBinEdges(2,binLimPt); + fSin2phiep->SetBinEdges(3,binLimEta); + fSin2phiep->SetBinEdges(0,binLimCos); + fSin2phiep->SetBinEdges(1,binLimC); + fSin2phiep->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phiep"); + fSin2phiephiep = new THnSparseF("sin2phie_phiep","sin2phie_phiep",nDime,nBine); + fSin2phiephiep->SetBinEdges(2,binLimPt); + fSin2phiephiep->SetBinEdges(3,binLimEta); + fSin2phiephiep->SetBinEdges(0,binLimCos); + fSin2phiephiep->SetBinEdges(1,binLimC); + fSin2phiephiep->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sin2phiephiep"); + + const Int_t nDimfbiss=4; + Int_t nBinfbiss[nDimfbiss] = {nBinsCos,nBinsCos,nBinsCos,nBinsC}; + fSinResabc = new THnSparseF("SinRes_abc","SinRes_abc",nDimfbiss,nBinfbiss); + fSinResabc->SetBinEdges(0,binLimCos); + fSinResabc->SetBinEdges(1,binLimCos); + fSinResabc->SetBinEdges(2,binLimCos); + fSinResabc->SetBinEdges(3,binLimC); + fSinResabc->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sinresabc"); + + // Profile cosres centrality with 3 subevents + fProfileCosResab = new TProfile("ProfileCosRes_a_b","ProfileCosRes_a_b",nBinsCMore,binLimCMore); + fProfileCosResab->Sumw2(); + fProfileCosResac = new TProfile("ProfileCosRes_a_c","ProfileCosRes_a_c",nBinsCMore,binLimCMore); + fProfileCosResac->Sumw2(); + fProfileCosResbc = new TProfile("ProfileCosRes_b_c","ProfileCosRes_b_c",nBinsCMore,binLimCMore); + fProfileCosResbc->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosresbc"); + + // + const Int_t nDimff=2; + Int_t nBinff[nDimff] = {nBinsCos, nBinsC}; + fSinRes = new THnSparseF("SinRes","SinRes",nDimff,nBinff); + fSinRes->SetBinEdges(0,binLimCos); + fSinRes->SetBinEdges(1,binLimC); + fSinRes->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: sinres"); + + // Profile cosres centrality + fProfileCosRes = new TProfile("ProfileCosRes","ProfileCosRes",nBinsCMore,binLimCMore); + fProfileCosRes->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosres"); + + // Profile Maps cos phi + fProfileCosPhiMaps = new TProfile2D("ProfileCosPhiMaps","ProfileCosPhiMaps",nBinsC,binLimC,nBinsPt,binLimPt); + fProfileCosPhiMaps->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: profilecosphimaps"); + + } + // + // fMonitorTrackCuts + // + + if(fMonitorTrackCuts) { + // Debugging tracking steps + const Int_t nDimTrStep=2; + Int_t nBinTrStep[nDimTrStep] = {nBinsPt,nBinsStep}; + fTrackingCuts = new THnSparseF("TrackingCuts","TrackingCuts",nDimTrStep,nBinTrStep); + fTrackingCuts->SetBinEdges(0,binLimPt); + fTrackingCuts->SetBinEdges(1,binLimStep); + fTrackingCuts->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: trackingcuts"); + } + + // + // fMonitorContamination + // + + if(fMonitorContamination) { + // Maps delta phi contamination + const Int_t nDimgcont=4; + Int_t nBingcont[nDimgcont] = {nBinsPhiLess,nBinsC,nBinsPt, nBinsTPCdEdx}; + fDeltaPhiMapsContamination = new THnSparseF("DeltaPhiMapsContamination","DeltaPhiMapsContamination",nDimgcont,nBingcont); + fDeltaPhiMapsContamination->SetBinEdges(0,binLimPhiLess); + fDeltaPhiMapsContamination->SetBinEdges(1,binLimC); + fDeltaPhiMapsContamination->SetBinEdges(2,binLimPt); + fDeltaPhiMapsContamination->SetBinEdges(3,binLimTPCdEdx); + fDeltaPhiMapsContamination->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapscontamination"); + + } + // + // fMonitorWithoutPID + // + + if(fMonitorWithoutPID) { + // + const Int_t nDimgb=3; + Int_t nBingb[nDimgb] = {nBinsPhi,nBinsC,nBinsPt}; + + fDeltaPhiMapsBeforePID = new THnSparseF("DeltaPhiMapsBeforePID","DeltaPhiMapsBeforePID",nDimgb,nBingb); + fDeltaPhiMapsBeforePID->SetBinEdges(0,binLimPhi); + fDeltaPhiMapsBeforePID->SetBinEdges(1,binLimC); + fDeltaPhiMapsBeforePID->SetBinEdges(2,binLimPt); + fDeltaPhiMapsBeforePID->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapsbeforepid"); + + const Int_t nDimhb=3; + Int_t nBinhb[nDimhb] = {nBinsCos,nBinsC,nBinsPt}; + + fCosPhiMapsBeforePID = new THnSparseF("CosPhiMapsBeforePID","CosPhiMapsBeforePID",nDimhb,nBinhb); + fCosPhiMapsBeforePID->SetBinEdges(0,binLimCos); + fCosPhiMapsBeforePID->SetBinEdges(1,binLimC); + fCosPhiMapsBeforePID->SetBinEdges(2,binLimPt); + fCosPhiMapsBeforePID->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: cosphimapsbeforepid"); + } + // + // fMonitorPhotonic + // + + if(fMonitorPhotonic) { + + const Int_t nDimgbp=3; + Int_t nBingbp[nDimgbp] = {nBinsPhi,nBinsC,nBinsPt}; + + fDeltaPhiMapsTaggedPhotonic = new THnSparseF("DeltaPhiMapsTaggedPhotonic","DeltaPhiMapsTaggedPhotonic",nDimgbp,nBingbp); + fDeltaPhiMapsTaggedPhotonic->SetBinEdges(0,binLimPhi); + fDeltaPhiMapsTaggedPhotonic->SetBinEdges(1,binLimC); + fDeltaPhiMapsTaggedPhotonic->SetBinEdges(2,binLimPt); + fDeltaPhiMapsTaggedPhotonic->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggedphotonic"); + + fDeltaPhiMapsTaggedNonPhotonic = new THnSparseF("DeltaPhiMapsTaggedNonPhotonic","DeltaPhiMapsTaggedNonPhotonic",nDimgbp,nBingbp); + fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(0,binLimPhi); + fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(1,binLimC); + fDeltaPhiMapsTaggedNonPhotonic->SetBinEdges(2,binLimPt); + fDeltaPhiMapsTaggedNonPhotonic->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggednonphotonic"); + + fDeltaPhiMapsTaggedPhotonicLS = new THnSparseF("DeltaPhiMapsTaggedPhotonicLS","DeltaPhiMapsTaggedPhotonicLS",nDimgbp,nBingbp); + fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(0,binLimPhi); + fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(1,binLimC); + fDeltaPhiMapsTaggedPhotonicLS->SetBinEdges(2,binLimPt); + fDeltaPhiMapsTaggedPhotonicLS->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: deltaphimapstaggedphotonicls"); + + const Int_t nDimMCSource=3; + Int_t nBinMCSource[nDimMCSource] = {nBinsC,nBinsPt,nBinsSource}; + fMCSourceDeltaPhiMaps = new THnSparseF("MCSourceDeltaPhiMaps","MCSourceDeltaPhiMaps",nDimMCSource,nBinMCSource); + fMCSourceDeltaPhiMaps->SetBinEdges(0,binLimC); + fMCSourceDeltaPhiMaps->SetBinEdges(1,binLimPt); + fMCSourceDeltaPhiMaps->SetBinEdges(2,binLimSource); + fMCSourceDeltaPhiMaps->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: mcsourcedeltaphimaps"); + + // Maps invmass opposite + const Int_t nDimOppSign=5; + Int_t nBinOppSign[nDimOppSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource}; + fOppSignDeltaPhiMaps = new THnSparseF("OppSignDeltaPhiMaps","OppSignDeltaPhiMaps",nDimOppSign,nBinOppSign); + fOppSignDeltaPhiMaps->SetBinEdges(0,binLimPhi); + fOppSignDeltaPhiMaps->SetBinEdges(1,binLimC); + fOppSignDeltaPhiMaps->SetBinEdges(2,binLimPt); + fOppSignDeltaPhiMaps->SetBinEdges(3,binLimInvMass); + fOppSignDeltaPhiMaps->SetBinEdges(4,binLimSource); + fOppSignDeltaPhiMaps->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: oppsigndeltaphimaps"); + + // Maps invmass same sign + const Int_t nDimSameSign=5; + Int_t nBinSameSign[nDimSameSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource}; + fSameSignDeltaPhiMaps = new THnSparseF("SameSignDeltaPhiMaps","SameSignDeltaPhiMaps",nDimSameSign,nBinSameSign); + fSameSignDeltaPhiMaps->SetBinEdges(0,binLimPhi); + fSameSignDeltaPhiMaps->SetBinEdges(1,binLimC); + fSameSignDeltaPhiMaps->SetBinEdges(2,binLimPt); + fSameSignDeltaPhiMaps->SetBinEdges(3,binLimInvMass); + fSameSignDeltaPhiMaps->SetBinEdges(4,binLimSource); + fSameSignDeltaPhiMaps->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: samesigndeltaphimaps"); + + // Maps angle same sign + const Int_t nDimAngleSameSign=3; + Int_t nBinAngleSameSign[nDimAngleSameSign] = {nBinsAngle,nBinsC,nBinsSource}; + fSameSignAngle = new THnSparseF("SameSignAngleMaps","SameSignAngleMaps",nDimAngleSameSign,nBinAngleSameSign); + fSameSignAngle->SetBinEdges(0,binLimAngle); + fSameSignAngle->SetBinEdges(1,binLimC); + fSameSignAngle->SetBinEdges(2,binLimSource); + fSameSignAngle->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: samesignangle"); + + // Maps angle opp sign + const Int_t nDimAngleOppSign=3; + Int_t nBinAngleOppSign[nDimAngleOppSign] = {nBinsAngle,nBinsC,nBinsSource}; + fOppSignAngle = new THnSparseF("OppSignAngleMaps","OppSignAngleMaps",nDimAngleOppSign,nBinAngleOppSign); + fOppSignAngle->SetBinEdges(0,binLimAngle); + fOppSignAngle->SetBinEdges(1,binLimC); + fOppSignAngle->SetBinEdges(2,binLimSource); + fOppSignAngle->Sumw2(); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: oppsignangle"); + + } + + //************************** + // Add to the list + //****************************** + + fListHist->Add(fHistEV); + fListHist->Add(fHistPileUp); + fListHist->Add(fEventPlane); + fListHist->Add(fFractionContamination); + fListHist->Add(fCosRes); + fListHist->Add(fCosResabc); + fListHist->Add(fCosPhiMaps); + fListHist->Add(fDeltaPhiMaps); + fListHist->Add(fPIDqa->MakeList("HFEpidQA")); + fListHist->Add(fContaminationv2); + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add default"); + + if(fMonitorEventPlane) { + fListHist->Add(fProfileCosRes); + fListHist->Add(fProfileCosResab); + fListHist->Add(fProfileCosResac); + fListHist->Add(fProfileCosResbc); + fListHist->Add(fCosSin2phiep); + fListHist->Add(fCos2phie); + fListHist->Add(fSin2phie); + fListHist->Add(fCos2phiep); + fListHist->Add(fSin2phiep); + fListHist->Add(fSin2phiephiep); + fListHist->Add(fSinRes); + fListHist->Add(fSinResabc); + fListHist->Add(fProfileCosPhiMaps); + } + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add monitor"); + + if(fMonitorTrackCuts) fListHist->Add(fTrackingCuts); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add monitortrackcuts"); + + if(fMonitorContamination) { + fListHist->Add(fDeltaPhiMapsContamination); + } + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add deltaphimapscontamination"); + + if(fMonitorWithoutPID) { + fListHist->Add(fDeltaPhiMapsBeforePID); + fListHist->Add(fCosPhiMapsBeforePID); + } + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add without pid"); + + if(fMonitorPhotonic) { + fListHist->Add(fPIDBackgroundqa->MakeList("HFEpidBackgroundQA")); + fListHist->Add(fDeltaPhiMapsTaggedPhotonic); + fListHist->Add(fDeltaPhiMapsTaggedNonPhotonic); + fListHist->Add(fDeltaPhiMapsTaggedPhotonicLS); + fListHist->Add(fMCSourceDeltaPhiMaps); + fListHist->Add(fOppSignDeltaPhiMaps); + fListHist->Add(fSameSignDeltaPhiMaps); + fListHist->Add(fSameSignAngle); + fListHist->Add(fOppSignAngle); + fListHist->Add(fBackgroundSubtraction->GetListOutput()); + } + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add photonic"); + + if(fHFEVZEROEventPlane && fMonitorEventPlane) fListHist->Add(fHFEVZEROEventPlane->GetOutputList()); + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: add event plane"); + + fListHist->Print(); + + PostData(1, fListHist); + //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { + // PostData(bincless+2,fflowEvent); + //} + + AliDebug(2,"AliAnalysisTaskFlowTPCTOFEPSP: post"); + + +} + +//________________________________________________________________________ +void AliAnalysisTaskFlowTPCTOFEPSP::UserExec(Option_t */*option*/) +{ + // + // Loop over event + // + + + Double_t massElectron = 0.000511; + Double_t mcReactionPlane = 0.0; + + Float_t cntr = 0.0; + Double_t binct = 11.5; + Double_t binctMore = 20.5; + Double_t binctLess = -0.5; + Float_t binctt = -1.0; + + Double_t valuecossinephiep[3]; + Double_t valuensparsea[4]; + Double_t valuensparseabis[5]; + Double_t valuensparsee[4]; + Double_t valuensparsef[2]; + Double_t valuensparsefsin[2]; + Double_t valuensparsefbis[4]; + Double_t valuensparsefbissin[4]; + Double_t valuensparseg[5]; + Double_t valuensparseh[5]; + Double_t valuensparsehprofile[3]; + Double_t valuensparseMCSourceDeltaPhiMaps[3]; + Double_t valuetrackingcuts[2]; + Double_t valuedeltaphicontamination[4]; + Double_t valuefractioncont[2]; + + AliMCEvent *mcEvent = MCEvent(); + AliMCParticle *mctrack = NULL; + + // MC info + Bool_t mcthere = kTRUE; + if(fAODAnalysis) { + AliAODEvent *aodE = dynamic_cast(fInputEvent); + if(!aodE){ + // printf("testd\n"); + AliError("No AOD Event"); + return; + } + fAODMCHeader = dynamic_cast(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName())); + if(!fAODMCHeader){ + mcthere = kFALSE; + } + fAODArrayMCInfo = dynamic_cast(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); + if(!fAODArrayMCInfo){ + mcthere = kFALSE; + } + else { + fHFECuts->SetMCEvent(aodE); + if(fMonitorPhotonic) fBackgroundSubtraction->SetAODArrayMCInfo(fAODArrayMCInfo); + } + } + else { + AliMCEventHandler *mcH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); + if(!mcH) mcthere = kFALSE; + else { + if(fMonitorPhotonic) fBackgroundSubtraction->SetMCEvent(fMCEvent); + } + } + + + ///////////////// + // centrality + ///////////////// + + //AliESDEvent *esd = dynamic_cast(InputEvent()); + //if(!esd) return; + AliCentrality *centrality = fInputEvent->GetCentrality(); + //AliDebug(2,"Got the centrality"); + if(!centrality) return; + cntr = centrality->GetCentralityPercentile("V0M"); + if((0.0< cntr) && (cntr<5.0)) binct = 0.5; + if((5.0< cntr) && (cntr<10.0)) binct = 1.5; + if((10.0< cntr) && (cntr<20.0)) binct = 2.5; + if((20.0< cntr) && (cntr<30.0)) binct = 3.5; + if((30.0< cntr) && (cntr<40.0)) binct = 4.5; + if((40.0< cntr) && (cntr<50.0)) binct = 5.5; + if((50.0< cntr) && (cntr<60.0)) binct = 6.5; + if((60.0< cntr) && (cntr<70.0)) binct = 7.5; + if((70.0< cntr) && (cntr<80.0)) binct = 8.5; + if((80.0< cntr) && (cntr<90.0)) binct = 9.5; + if((90.0< cntr) && (cntr<100.0)) binct = 10.5; + + if((0.< cntr) && (cntr < 20.)) binctt = 0.5; + if((20.< cntr) && (cntr < 40.)) binctt = 1.5; + if((40.< cntr) && (cntr < 80.)) binctt = 2.5; + + if((0.0< cntr) && (cntr<5.0)) binctMore = 0.5; + if((5.0< cntr) && (cntr<10.0)) binctMore = 1.5; + if((10.0< cntr) && (cntr<15.0)) binctMore = 2.5; + if((15.0< cntr) && (cntr<20.0)) binctMore = 3.5; + if((20.0< cntr) && (cntr<25.0)) binctMore = 4.5; + if((25.0< cntr) && (cntr<30.0)) binctMore = 5.5; + if((30.0< cntr) && (cntr<35.0)) binctMore = 6.5; + if((35.0< cntr) && (cntr<40.0)) binctMore = 7.5; + if((40.0< cntr) && (cntr<45.0)) binctMore = 8.5; + if((45.0< cntr) && (cntr<50.0)) binctMore = 9.5; + if((50.0< cntr) && (cntr<55.0)) binctMore = 10.5; + if((55.0< cntr) && (cntr<60.0)) binctMore = 11.5; + if((60.0< cntr) && (cntr<65.0)) binctMore = 12.5; + if((65.0< cntr) && (cntr<70.0)) binctMore = 13.5; + if((70.0< cntr) && (cntr<75.0)) binctMore = 14.5; + if((75.0< cntr) && (cntr<80.0)) binctMore = 15.5; + if((80.0< cntr) && (cntr<85.0)) binctMore = 16.5; + if((85.0< cntr) && (cntr<90.0)) binctMore = 17.5; + if((90.0< cntr) && (cntr<95.0)) binctMore = 18.5; + if((95.0< cntr) && (cntr<100.0)) binctMore = 19.5; + + binctLess = cntr; + + + if(binct > 11.0) return; + + // centrality + valuensparsea[3] = binct; + valuensparseabis[1] = binct; + valuensparsee[1] = binct; + valuensparsef[1] = binctMore; + valuensparsefsin[1] = binct; + valuensparsefbis[3] = binctMore; + valuensparsefbissin[3] = binct; + valuensparseg[1] = binct; + valuensparseh[1] = binct; + valuefractioncont[1] = binct; + valuensparsehprofile[1] = binct; + valuecossinephiep[2] = binctMore; + valuensparseMCSourceDeltaPhiMaps[0] = binct; + valuedeltaphicontamination[1] = binct; + + ////////////////////// + // run number + ////////////////////// + + Int_t runnumber = fInputEvent->GetRunNumber(); + AliDebug(2,Form("Run number %d",runnumber)); + + if(!fPID->IsInitialized()){ + // Initialize PID with the given run number + fPID->InitializePID(runnumber); + } + if(!fPIDTOFOnly->IsInitialized()){ + // Initialize PID with the given run number + fPIDTOFOnly->InitializePID(runnumber); + } + + // + if(!fPIDBackground->IsInitialized()){ + // Initialize PID with the given run number + fPIDBackground->InitializePID(runnumber); + } + + fHFECuts->SetRecEvent(fInputEvent); + if(mcEvent) fHFECuts->SetMCEvent(mcEvent); + + + ////////// + // PID + ////////// + + AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse(); + if(!pidResponse){ + AliDebug(2,"No PID response set"); + return; + } + fPID->SetPIDResponse(pidResponse); + fPIDTOFOnly->SetPIDResponse(pidResponse); + fPIDBackground->SetPIDResponse(pidResponse); + if(fMonitorPhotonic) fBackgroundSubtraction->InitRun(fInputEvent,pidResponse); + + fHistEV->Fill(binctt,0.0); + + ////////////////// + // Event cut + ////////////////// + if(!fHFECuts->CheckEventCuts("fEvRecCuts", fInputEvent)) { + AliDebug(2,"Does not pass the event cut"); + PostData(1, fListHist); + return; + } + + fHistEV->Fill(binctt,1.0); + + + /////////////////////////////////////////////////////////// + // PileUpCut + /////////////////////////////////////////////////////////// + + Float_t multTPC(0.); // tpc mult estimate + Float_t multGlob(0.); // global multiplicity + const Int_t nGoodTracks = fInputEvent->GetNumberOfTracks(); + for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill tpc mult + AliAODTrack* trackAOD = dynamic_cast(fInputEvent->GetTrack(iTracks)); + if (!trackAOD) continue; + if (!(trackAOD->TestFilterBit(1))) continue; + if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.2)) continue; + multTPC++; + } + for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill global mult + AliAODTrack* trackAOD = dynamic_cast(fInputEvent->GetTrack(iTracks)); + if (!trackAOD) continue; + if (!(trackAOD->TestFilterBit(16))) continue; + if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.1)) continue; + Double_t b[2] = {-99., -99.}; + Double_t bCov[3] = {-99., -99., -99.}; + if (!(trackAOD->PropagateToDCA(fInputEvent->GetPrimaryVertex(), fInputEvent->GetMagneticField(), 100., b, bCov))) continue; + if ((TMath::Abs(b[0]) > 0.3) || (TMath::Abs(b[1]) > 0.3)) continue; + multGlob++; + } //track loop + + Double_t pileup[4]; + pileup[0]=fInputEvent->GetCentrality()->GetCentralityPercentile("V0M"); + pileup[1]=fInputEvent->GetCentrality()->GetCentralityPercentile("TRK"); + pileup[2]=multTPC; + pileup[3]=multGlob; + fHistPileUp->Fill(pileup); + + if(fPileUpCut){ + if (TMath::Abs(pileup[0]-pileup[1]) > 5) { + AliDebug(2,"Does not pass the centrality correlation cut"); + return; + } + if(multTPC < (-36.81+1.48*multGlob) && multTPC > (63.03+1.78*multGlob)){ + AliDebug(2,"Does not pass the multiplicity correlation cut"); + return; + } + } + + // AliVVZERO* vzeroData=fInputEvent->GetVZEROData(); + // Double_t mult[3],multV0A(0),multV0C(0); + // for(Int_t i=0; i<32; ++i) { + // multV0A += vzeroData->GetMultiplicityV0A(i); + // multV0C += vzeroData->GetMultiplicityV0C(i); + // } + + // int ntrk=0; + // for(Int_t k = 0; k < fInputEvent->GetNumberOfTracks(); k++){ + // AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); + // if(!track) continue; + // if(!(track->GetStatus()&AliVTrack::kITSrefit)) continue; + // if(!(track->GetStatus()&AliVTrack::kTPCrefit)) continue; + // ntrk++; + // } + + // mult[0]=fInputEvent->GetNumberOfTracks(); + // mult[1]=multV0A+multV0C; + // mult[2]=binctMore; + // fHistPileUp->Fill(mult); + + // if(fUpperPileUpCut&&fLowerPileUpCut){ + // if((mult[0]Eval(mult[1])) || + // (mult[0]>fUpperPileUpCut->Eval(mult[1]))){ + // AliDebug(2,"Does not pass the pileup cut"); + // PostData(1, fListHist); + // return; + // } + // } + + //////////////////////////////////// + // First method event plane + //////////////////////////////////// + + AliEventplane* vEPa = fInputEvent->GetEventplane(); + Float_t eventPlanea = 0.0; + Float_t eventPlaneTPC = 0.0; + Float_t eventPlaneV0A = 0.0; + Float_t eventPlaneV0C = 0.0; + Float_t eventPlaneV0 = 0.0; + TVector2 *qTPC = 0x0; + TVector2 *qsub1a = 0x0; + TVector2 *qsub2a = 0x0; + TVector2 qV0A,qV0C,qV0,*qAna; + + // V0 + + if(fHFEVZEROEventPlane && (!fAODAnalysis)){ + + //AliESDEvent *esd = dynamic_cast(InputEvent()); + //if(!esd) return; + + fHFEVZEROEventPlane->ProcessEvent(fInputEvent); + + if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0A()+100) < 0.0000001) eventPlaneV0A = -100.0; + else { + eventPlaneV0A = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0A()); + if(eventPlaneV0A > TMath::Pi()) eventPlaneV0A = eventPlaneV0A - TMath::Pi(); + } + + if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0C()+100) < 0.0000001) eventPlaneV0C = -100.0; + else { + eventPlaneV0C = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0C()); + if(eventPlaneV0C > TMath::Pi()) eventPlaneV0C = eventPlaneV0C - TMath::Pi(); + } + + if(TMath::Abs(fHFEVZEROEventPlane->GetEventPlaneV0()+100) < 0.0000001) eventPlaneV0 = -100.0; + else { + eventPlaneV0 = TVector2::Phi_0_2pi(fHFEVZEROEventPlane->GetEventPlaneV0()); + if(eventPlaneV0 > TMath::Pi()) eventPlaneV0 = eventPlaneV0 - TMath::Pi(); + } + + } + else { + + Double_t qVx, qVy; //TR: info + eventPlaneV0 = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,10,2,qVx,qVy)); + if(eventPlaneV0 > TMath::Pi()) eventPlaneV0 = eventPlaneV0 - TMath::Pi(); + qV0.Set(qVx,qVy); + eventPlaneV0A = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,8,2,qVx,qVy)); + if(eventPlaneV0A > TMath::Pi()) eventPlaneV0A = eventPlaneV0A - TMath::Pi(); + qV0A.Set(qVx,qVy); + eventPlaneV0C = TVector2::Phi_0_2pi(vEPa->CalculateVZEROEventPlane(fInputEvent,9,2,qVx,qVy)); + if(eventPlaneV0C > TMath::Pi()) eventPlaneV0C = eventPlaneV0C - TMath::Pi(); + qV0C.Set(qVx,qVy); + + if(eventPlaneV0<-900) return; + if(eventPlaneV0A<-900) return; + if(eventPlaneV0C<-900) return; + + + eventPlaneV0=TVector2::Phi_0_2pi(eventPlaneV0); + eventPlaneV0A=TVector2::Phi_0_2pi(eventPlaneV0A); + eventPlaneV0C=TVector2::Phi_0_2pi(eventPlaneV0C); + } + + + // TPC + + qTPC = vEPa->GetQVector(); + Double_t qx = -1.0; + Double_t qy = -1.0; + if(qTPC) { + qx = qTPC->X(); + qy = qTPC->Y(); + } + TVector2 qVectorfortrack; + qVectorfortrack.Set(qx,qy); + eventPlaneTPC = TVector2::Phi_0_2pi(qVectorfortrack.Phi())/2.; + + // Choose the one used for v2 + + if(fVZEROEventPlane){ //TR: info + eventPlanea = eventPlaneV0; + qAna = &qV0; + } + if(fVZEROEventPlaneA){ + eventPlanea = eventPlaneV0A; + qAna = &qV0A; + } + if(fVZEROEventPlaneC){ + eventPlanea = eventPlaneV0C; + qAna = &qV0C; + } + if(!fVZEROEventPlane){ + eventPlanea = eventPlaneTPC; + qAna = &qV0C; + } + + valuecossinephiep[0] = TMath::Cos(2*eventPlanea); + valuecossinephiep[1] = TMath::Sin(2*eventPlanea); + + Float_t eventPlanesub1a = -100.0; + Float_t eventPlanesub2a = -100.0; + Double_t diffsub1sub2a = -100.0; + Double_t diffsub1sub2asin = -100.0; + Double_t diffsubasubb = -100.0; + Double_t diffsubasubc = -100.0; + Double_t diffsubbsubc = -100.0; + Double_t diffsubasubbsin = -100.0; + Double_t diffsubasubcsin = -100.0; + Double_t diffsubbsubcsin = -100.0; + + // two sub event TPC + qsub1a = vEPa->GetQsub1(); + qsub2a = vEPa->GetQsub2(); + + ///////////////////////////////////////////////////////// + // Cut for event with event plane reconstructed by all + //////////////////////////////////////////////////////// + + if((!qTPC) || (!qsub1a) || (!qsub2a)) { + AliDebug(2,"No event plane"); + return; + } + + eventPlanesub1a = TVector2::Phi_0_2pi(qsub1a->Phi())/2.; + eventPlanesub2a = TVector2::Phi_0_2pi(qsub2a->Phi())/2.; + diffsub1sub2a = TMath::Cos(2.*TVector2::Phi_0_2pi(qsub1a->Phi()/2.- qsub2a->Phi()/2.)); + diffsub1sub2asin = TMath::Sin(2.*TVector2::Phi_0_2pi(qsub1a->Phi()/2.- qsub2a->Phi()/2.)); + + + // if ( !fDebugStreamer ) { + // //debug stream + // TDirectory *backup = gDirectory; + // fDebugStreamer = new TTreeSRedirector("TaskFlowTPCTOFEPSPdebug.root"); + // if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer + // } + + // { + + // double v0nrom = TMath::Sqrt(qV0.X()*qV0.X()+qV0.Y()*qV0.Y()); + // double v0Anrom = TMath::Sqrt(qV0A.X()*qV0A.X()+qV0A.Y()*qV0A.Y()); + // double v0Cnrom = TMath::Sqrt(qV0C.X()*qV0C.X()+qV0C.Y()*qV0C.Y()); + // double sub1nrom = TMath::Sqrt(qsub1a->X()*qsub1a->X()+qsub1a->Y()*qsub1a->Y()); + // double sub2nrom = TMath::Sqrt(qsub2a->X()*qsub2a->X()+qsub2a->Y()*qsub2a->Y()); + + // (* fDebugStreamer) << "UserExec" << + // "binct="<X()+qV0A.Y()*qTPC->Y(); + diffsubbsubc = qV0C.X()*qTPC->X()+qV0C.Y()*qTPC->Y(); + } + else if(fVZEROEventPlaneC){ + diffsubasubb = qV0C.X()*qV0A.X()+qV0C.Y()*qV0A.Y(); + diffsubasubc = qV0C.X()*qTPC->X()+qV0C.Y()*qTPC->Y(); + diffsubbsubc = qV0A.X()*qTPC->X()+qV0A.Y()*qTPC->Y(); + } + } + + diffsubasubbsin = TMath::Sin(2.*(eventPlaneV0A - eventPlaneV0C)); + diffsubasubcsin = TMath::Sin(2.*(eventPlaneV0A - eventPlaneTPC)); + diffsubbsubcsin = TMath::Sin(2.*(eventPlaneV0C - eventPlaneTPC)); + // three sub events in case of VZERO all + if(fVZEROEventPlane && (!fVZEROEventPlaneA) && (!fVZEROEventPlaneC)) { + if(!fSP){ + diffsubasubb = TMath::Cos(2.*(eventPlaneV0 - eventPlanesub1a)); //TR: + diffsubasubc = TMath::Cos(2.*(eventPlaneV0 - eventPlanesub2a)); //TR: + diffsubbsubc = TMath::Cos(2.*(eventPlanesub1a - eventPlanesub2a)); //TR: + } + else{ + diffsubasubb = qV0.X()*qsub1a->X()+qV0.Y()*qsub1a->Y(); + diffsubasubc = qV0.X()*qsub2a->X()+qV0.Y()*qsub2a->Y(); + diffsubbsubc = qsub1a->X()*qsub2a->X()+qsub1a->Y()*qsub2a->Y(); + } + + diffsubasubbsin = TMath::Sin(2.*(eventPlaneV0 - eventPlanesub1a)); + diffsubasubcsin = TMath::Sin(2.*(eventPlaneV0 - eventPlanesub2a)); + diffsubbsubcsin = TMath::Sin(2.*(eventPlanesub1a - eventPlanesub2a)); + } + + ////////////////////////////////////// + // AliFlowEvent and MC event plane + ///////////////////////////////////// + + Int_t nbtracks = fInputEvent->GetNumberOfTracks(); + AliDebug(2,Form("Number of tracks %d",nbtracks)); + + if(fMonitorQCumulant) { + + fcutsRP->SetEvent( InputEvent(), MCEvent()); + fcutsPOI->SetEvent( InputEvent(), MCEvent()); + if( fflowEvent ){ + fflowEvent->~AliFlowEvent(); + new(fflowEvent) AliFlowEvent(fcutsRP,fcutsPOI); + }else fflowEvent = new AliFlowEvent(fcutsRP,fcutsPOI); + if(mcEvent && mcEvent->GenEventHeader()) { + fflowEvent->SetMCReactionPlaneAngle(mcEvent); + //if reaction plane not set from elsewhere randomize it before adding flow + //if (!fflowEvent->IsSetMCReactionPlaneAngle()) fflowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi())); + mcReactionPlane = TVector2::Phi_0_2pi(fflowEvent->GetMCReactionPlaneAngle()); + if(mcReactionPlane > TMath::Pi()) mcReactionPlane = mcReactionPlane - TMath::Pi(); + AliDebug(2,Form("MC reaction plane %f",mcReactionPlane)); + } + fflowEvent->SetReferenceMultiplicity( nbtracks ); + fflowEvent->DefineDeadZone(0,0,0,0); + //fflowEvent.TagSubeventsInEta(-0.8,-0.1,0.1,0.8); + + //////////////// + // MC + /////////////// + if(fUseMCReactionPlane) { + eventPlanea = mcReactionPlane; + diffsub1sub2a = 0.0; + } + } + + + ////////////////////// + // Fill Histos + ////////////////////// + + fHistEV->Fill(binctt,2.0); + + // Fill + valuensparsea[0] = eventPlaneV0A; + valuensparsea[1] = eventPlaneV0C; + valuensparsea[2] = eventPlaneTPC; + if(fVZEROEventPlane && (!fVZEROEventPlaneA) && (!fVZEROEventPlaneC)) { + // case VZERO all + valuensparsea[0] = eventPlaneV0; + valuensparsea[1] = eventPlanesub1a; + valuensparsea[2] = eventPlanesub2a; + } + fEventPlane->Fill(&valuensparsea[0]); + + // Fill + if(fMonitorEventPlane) fCosSin2phiep->Fill(&valuecossinephiep[0]); + + if(!fVZEROEventPlane) { + valuensparsef[0] = diffsub1sub2a; + fCosRes->Fill(&valuensparsef[0]); + valuensparsefsin[0] = diffsub1sub2asin; + if(fMonitorEventPlane) fSinRes->Fill(&valuensparsefsin[0]); + if(fMonitorEventPlane) { + fProfileCosRes->Fill(valuensparsef[1],valuensparsef[0]); + } + } + else { + valuensparsefbis[0] = diffsubasubb; + valuensparsefbis[1] = diffsubasubc; + valuensparsefbis[2] = diffsubbsubc; + fCosResabc->Fill(&valuensparsefbis[0]); //TR: info + valuensparsefbissin[0] = diffsubasubbsin; + valuensparsefbissin[1] = diffsubbsubcsin; + valuensparsefbissin[2] = diffsubasubcsin; + if(fMonitorEventPlane) fSinResabc->Fill(&valuensparsefbissin[0]); + if(fMonitorEventPlane) { + fProfileCosResab->Fill(valuensparsefbis[3],valuensparsefbis[0]); + fProfileCosResac->Fill(valuensparsefbis[3],valuensparsefbis[1]); + fProfileCosResbc->Fill(valuensparsefbis[3],valuensparsefbis[2]); + } + } + + //////////////////////////////////////// + // Loop to determine pool background + ///////////////////////////////////////// + if(fMonitorPhotonic) { + + fBackgroundSubtraction->FillPoolAssociatedTracks(fInputEvent,binct); + + if( fArraytrack ){ + fArraytrack->~TArrayI(); + new(fArraytrack) TArrayI(nbtracks); + } + else { + fArraytrack = new TArrayI(nbtracks); + } + fCounterPoolBackground = 0; + + for(Int_t k = 0; k < nbtracks; k++){ + + AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); + if(!track) continue; + + // Track cuts + Bool_t survivedbackground = kTRUE; + if(fAODAnalysis) { + AliAODTrack *aodtrack = dynamic_cast(track); + if(aodtrack) { + AliESDtrack esdTrack(aodtrack); + // set the TPC cluster info + esdTrack.SetTPCClusterMap(aodtrack->GetTPCClusterMap()); + esdTrack.SetTPCSharedMap(aodtrack->GetTPCSharedMap()); + esdTrack.SetTPCPointsF(aodtrack->GetTPCNclsF()); + // needed to calculate the impact parameters + AliAODEvent *aodeventu = dynamic_cast(fInputEvent); + if(aodeventu) { + AliAODVertex *vAOD = aodeventu->GetPrimaryVertex(); + Double_t bfield = aodeventu->GetMagneticField(); + Double_t pos[3],cov[6]; + vAOD->GetXYZ(pos); + vAOD->GetCovarianceMatrix(cov); + const AliESDVertex vESD(pos,cov,100.,100); + esdTrack.RelateToVertex(&vESD,bfield,3.); + } + if(!fHFEBackgroundCuts->IsSelected(&esdTrack)) { + survivedbackground = kFALSE; + } + } + } + else { + AliESDtrack *esdtrack = dynamic_cast(track); + if(esdtrack) { + if(!fHFEBackgroundCuts->IsSelected(esdtrack)) survivedbackground = kFALSE; + } + } + // PID + if(survivedbackground) { + // PID track cuts + AliHFEpidObject hfetrack2; + if(!fAODAnalysis) hfetrack2.SetAnalysisType(AliHFEpidObject::kESDanalysis); + else hfetrack2.SetAnalysisType(AliHFEpidObject::kAODanalysis); + hfetrack2.SetRecTrack(track); + hfetrack2.SetCentrality((Int_t)binct); + AliDebug(2,Form("centrality %f and %d",binct,hfetrack2.GetCentrality())); + hfetrack2.SetPbPb(); + if(fPIDBackground->IsSelected(&hfetrack2,0x0,"recTrackCont",fPIDBackgroundqa)) { + fArraytrack->AddAt(k,fCounterPoolBackground); + fCounterPoolBackground++; + AliDebug(2,Form("fCounterPoolBackground %d, track %d",fCounterPoolBackground,k)); + } + } + } + } + + + ////////////////////////// + // Loop over track + ////////////////////////// + for(Int_t k = 0; k < nbtracks; k++){ + + AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); + if(!track) continue; + + if(fAODAnalysis) { + AliAODTrack *aodtrack = dynamic_cast(track); + if(!aodtrack){ + AliError("AOD track is not there"); + continue; + } + AliDebug(2,"Find AOD track on"); + if(!(aodtrack->TestFilterBit(fFilter))) continue; // Only process AOD tracks where the HFE is set + } + + + valuetrackingcuts[0] = track->Pt(); + valuetrackingcuts[1] = 0; + + // RecKine: ITSTPC cuts + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + // RecPrim + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + valuetrackingcuts[1] = 1; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + // HFEcuts: ITS layers cuts + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + valuetrackingcuts[1] = 2; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + // HFE cuts: TOF and mismatch flag + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTOF + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + valuetrackingcuts[1] = 3; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + // HFE cuts: TPC PID cleanup + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + valuetrackingcuts[1] = 4; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + // HFEcuts: Nb of tracklets TRD0 + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + valuetrackingcuts[1] = 5; + if(fMonitorTrackCuts) fTrackingCuts->Fill(&valuetrackingcuts[0]); + + AliDebug(2,"Survived"); + + ///////////////////////////////////////////////////////// + // Subtract candidate from TPC event plane + //////////////////////////////////////////////////////// + Float_t eventplanesubtracted = 0.0; + + if(!fVZEROEventPlane) { + // Subtract the tracks from the event plane + Double_t qX = qTPC->X() - vEPa->GetQContributionX(track); //Modify the components: subtract the track you want to look at with your analysis + Double_t qY = qTPC->Y() - vEPa->GetQContributionY(track); //Modify the components: subtract the track you want to look at with your analysis + TVector2 newQVectorfortrack; + newQVectorfortrack.Set(qX,qY); + eventplanesubtracted = TVector2::Phi_0_2pi(newQVectorfortrack.Phi())/2; + } + else eventplanesubtracted = eventPlanea; + + /////////////////////////////////////////// + // Event plane + ////////////////////////////////////////// + Bool_t fillEventPlane = kTRUE; + if(!fVZEROEventPlane){ + if((!qsub1a) || (!qsub2a)) fillEventPlane = kFALSE; + if(fSubEtaGapTPC) { + if(track->Eta() < (- fEtaGap/2.)) eventplanesubtracted = eventPlanesub1a; + else if(track->Eta() > (fEtaGap/2.)) eventplanesubtracted = eventPlanesub2a; + else fillEventPlane = kFALSE; + } + } + + /////////////// + // MC + ////////////// + if(fUseMCReactionPlane) { + eventplanesubtracted = mcReactionPlane; + fillEventPlane = kTRUE; + } + + ////////////////////////////////////////////////////////////////////////////// + ///////////////////////////AFTERBURNER + Double_t phitrack = track->Phi(); + if (fAfterBurnerOn) + { + phitrack = GetPhiAfterAddV2(track->Phi(),mcReactionPlane); + } + ////////////////////////////////////////////////////////////////////////////// + + + /////////////////////// + // Calculate deltaphi + /////////////////////// + + // Suppose phi track is between 0.0 and phi + Double_t deltaphi = TVector2::Phi_0_2pi(phitrack - eventplanesubtracted); + if(deltaphi > TMath::Pi()) deltaphi = deltaphi - TMath::Pi(); + + //////////////////////////////// + // Determine the deltaphi bin + /////////////////////////////// + + // in-plane + if(((deltaphi<(TMath::Pi()/4.)) && (deltaphi>0.0)) || ((deltaphi>(3*TMath::Pi()/4.)) && (deltaphi(TMath::Pi()/4.)) && (deltaphi<(3*TMath::Pi()/4.))) valuedeltaphicontamination[0] = 1.5; + + //////////////////////////////////////// + // Define variables + /////////////////////////////////////// + + + valuedeltaphicontamination[2] = track->Pt(); + valuensparsee[2] = track->Pt(); + valuensparsee[3] = track->Eta(); + valuensparseg[2] = track->Pt(); + valuensparseh[2] = track->Pt(); + valuefractioncont[0] = track->Pt(); + valuensparsehprofile[2] = track->Pt(); + valuensparseMCSourceDeltaPhiMaps[1] = track->Pt(); + if(track->Charge() > 0.0) { + valuensparseg[3] = 0.2; + valuensparseh[3] = 0.2; + } + else { + valuensparseg[3] = -0.2; + valuensparseh[3] = -0.2; + } + valuensparseh[4] = track->Eta(); + valuensparseg[4] = track->Eta(); + + AliDebug(2,Form("charge %d",(Int_t)track->Charge())); + + //////////////////////// + // Fill before PID + /////////////////////// + + if(fMonitorWithoutPID) { + + valuensparseg[0] = deltaphi; + if(fillEventPlane) fDeltaPhiMapsBeforePID->Fill(&valuensparseg[0]); + + // + valuensparseh[0] = TMath::Cos(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); + if(fillEventPlane) { + fCosPhiMapsBeforePID->Fill(&valuensparseh[0]); + } + } + + //////////////////////// + // Apply PID + //////////////////////// + if(!fNoPID) { + // Apply PID for Data + if(!fMCPID) { + // pid object + AliHFEpidObject hfetrack; + if(!fAODAnalysis) hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); + else hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis); + hfetrack.SetRecTrack(track); + hfetrack.SetCentrality((Int_t)binct); + AliDebug(2,Form("centrality %f and %d",binct,hfetrack.GetCentrality())); + hfetrack.SetPbPb(); + + // Only TOF PID + if(fMonitorContamination) { + if(fPIDTOFOnly->IsSelected(&hfetrack,0x0,"recTrackCont",0x0)) { + Float_t nsigma = pidResponse->NumberOfSigmasTPC(track, AliPID::kElectron); + valuedeltaphicontamination[3] = nsigma; + fDeltaPhiMapsContamination->Fill(&valuedeltaphicontamination[0]); + } + } + + // Complete PID TOF+TPC + if(!fPID->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqa)) { + continue; + } + } + else { + if(!mcEvent) continue; + if(!(mctrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(track->GetLabel()))))) continue; + AliDebug(2,Form("PdgCode %d",TMath::Abs(mctrack->Particle()->GetPdgCode()))); + if(TMath::Abs(mctrack->Particle()->GetPdgCode())!=11) continue; + } + } + + + ///////////////////////////////////////////////////////////////////////////// + // Add candidate to AliFlowEvent for POI and subtract from RP if needed + //////////////////////////////////////////////////////////////////////////// + if(fMonitorQCumulant) { + Int_t idtrack = static_cast(track)->GetID(); + Bool_t found = kFALSE; + Int_t numberoffound = 0; + AliDebug(2,Form("A: Number of tracks %d",fflowEvent->NumberOfTracks())); + for(Int_t iRPs=0; iRPs< fflowEvent->NumberOfTracks(); iRPs++) { + AliFlowTrack *iRP = (AliFlowTrack*) (fflowEvent->GetTrack(iRPs)); + if(!iRP) continue; + //if(!iRP->InRPSelection()) continue; + if( TMath::Abs(idtrack) == TMath::Abs(iRP->GetID()) ) { + iRP->SetForPOISelection(kTRUE); + found = kTRUE; + numberoffound ++; + } + } + AliDebug(2,Form("Found %d mal",numberoffound)); + if(!found) { + AliFlowCandidateTrack *sTrack = (AliFlowCandidateTrack*) MakeTrack(massElectron,track->Pt(),track->Phi(), track->Eta()); + sTrack->SetID(idtrack); + fflowEvent->AddTrack(sTrack); + AliDebug(2,"Add the track"); + } + AliDebug(2,Form("B: Number of tracks %d",fflowEvent->NumberOfTracks())); + } + + + ///////////////////// + // Fill THnSparseF + ///////////////////// + + // + valuensparseabis[0] = eventplanesubtracted; + if((fillEventPlane) && (fMonitorEventPlane)) fEventPlaneaftersubtraction->Fill(&valuensparseabis[0]); + + + if(fMonitorEventPlane) + { + // + valuensparsee[0] = TMath::Cos(2*phitrack); + fCos2phie->Fill(&valuensparsee[0]); + valuensparsee[0] = TMath::Sin(2*phitrack); + fSin2phie->Fill(&valuensparsee[0]); + // + valuensparsee[0] = TMath::Cos(2*eventplanesubtracted); + if(fillEventPlane) fCos2phiep->Fill(&valuensparsee[0]); + valuensparsee[0] = TMath::Sin(2*eventplanesubtracted); + if(fillEventPlane) fSin2phiep->Fill(&valuensparsee[0]); + valuensparsee[0] = TMath::Sin(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); + if(fillEventPlane) fSin2phiephiep->Fill(&valuensparsee[0]); + // + } + + // + valuensparseg[0] = deltaphi; + if(fillEventPlane) fDeltaPhiMaps->Fill(&valuensparseg[0]); + + // + valuensparseh[0] = TMath::Cos(2*TVector2::Phi_mpi_pi(phitrack-eventplanesubtracted)); + if(fillEventPlane) { + fCosPhiMaps->Fill(&valuensparseh[0]); //TR: fCosPhiQSum+=valuensparseh[0]*TMath:Sqrt(qAna->X()*qAna->X()+qAna->Y()*qAna->Y()); fCosPhiQN++; + if((valuefractioncont[1] >=0) && (valuefractioncont[1] < 11)){ + if(fContamination[((Int_t)valuefractioncont[1])]){ + Double_t weight = fContamination[((Int_t)valuefractioncont[1])]->Eval(track->P()); + if(weight<0.0) weight=0.0; + if(weight>1.0) weight=1.0; + fFractionContamination->Fill(&valuefractioncont[0],weight); + if(fv2contamination[((Int_t)valuefractioncont[1])]){ + Double_t v2 = fv2contamination[((Int_t)valuefractioncont[1])]->Eval(track->Pt()); + AliDebug(2,Form("value v2 %f, contamination %f and pt %f centrality %d\n",v2,weight,track->Pt(),(Int_t)valuefractioncont[1])); + AliDebug(2,Form("Check for centrality 3: value v2 %f, contamination %f\n",fv2contamination[3]->Eval(track->Pt()),fContamination[3]->Eval(track->P()))); + AliDebug(2,Form("Check for centrality 4: value v2 %f, contamination %f\n",fv2contamination[4]->Eval(track->Pt()),fContamination[4]->Eval(track->P()))); + AliDebug(2,Form("Check for centrality 5: value v2 %f, contamination %f\n",fv2contamination[5]->Eval(track->Pt()),fContamination[5]->Eval(track->P()))); + fContaminationv2->Fill(valuefractioncont[1],valuefractioncont[0],v2,weight); + } + } + } + if(fMonitorEventPlane) { + if(fSP) + valuensparseh[0] *= TMath::Sqrt(qAna->X()*qAna->X()+qAna->Y()*qAna->Y()); + fProfileCosPhiMaps->Fill(valuensparsehprofile[1],valuensparsehprofile[2],valuensparseh[0]); //TR: info + } + } + + if(fMonitorPhotonic) { + Int_t indexmother = -1; + Int_t source = 1; + if(mcthere) source = fBackgroundSubtraction->FindMother(mctrack->GetLabel(),indexmother); + fBackgroundSubtraction->LookAtNonHFE(k, track, fInputEvent, 1, binct, deltaphi, source, indexmother); + + if((!fAODAnalysis && mcthere) || !mcthere) { + // background + source = 0; + indexmother = -1; + source = FindMother(TMath::Abs(track->GetLabel()),mcEvent, indexmother); + valuensparseMCSourceDeltaPhiMaps[2] = source; + if(mcEvent) fMCSourceDeltaPhiMaps->Fill(&valuensparseMCSourceDeltaPhiMaps[0]); + //LookAtNonHFE(k,track,fInputEvent,mcEvent,binct,deltaphi,source,indexmother); + Int_t taggedvalue = LookAtNonHFE(k,track,fInputEvent,mcEvent,binct,deltaphi,source,indexmother); + if(fMonitorPhotonic) { + // No opposite charge partner found in the invariant mass choosen + if((taggedvalue!=2) && (taggedvalue!=6)) { + //fDeltaPhiMapsTaggedNonPhotonic->Fill(&valuensparseg[0]); + //fCosPhiMapsTaggedNonPhotonic->Fill(&valuensparseh[0]); + } + // One opposite charge partner found in the invariant mass choosen + if((taggedvalue==2) || (taggedvalue==6)) { + fDeltaPhiMapsTaggedPhotonic->Fill(&valuensparseg[0]); + //fCosPhiMapsTaggedPhotonic->Fill(&valuensparseh[0]); + } + // One same charge partner found in the invariant mass choosen + if((taggedvalue==4) || (taggedvalue==6)) { + fDeltaPhiMapsTaggedPhotonicLS->Fill(&valuensparseg[0]); + //fCosPhiMapsTaggedPhotonicLS->Fill(&valuensparseh[0]); + } + } + } + } + + } + + ////////////////////////////////////////////////////////////////////////////// + ///////////////////////////AFTERBURNER + if (fAfterBurnerOn & fMonitorQCumulant) + { + fflowEvent->AddFlow(fV1,fV2,fV3,fV4,fV5); //add flow + fflowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks + } + ////////////////////////////////////////////////////////////////////////////// + + + + //for(Int_t bincless = 0; bincless < fNbBinsCentralityQCumulant; bincless++) { + // if((fBinCentralityLess[bincless]< cntr) && (cntr < fBinCentralityLess[bincless+1])) PostData(bincless+2,fflowEvent); + //} + + if(fMonitorPhotonic) { + if(fArraytrack) { + delete fArraytrack; + fArraytrack = NULL; + } + } + + if(fMonitorPhotonic) fBackgroundSubtraction->CountPoolAssociated(fInputEvent,binct); + + PostData(1, fListHist); + + + +} +//______________________________________________________________________________ +AliFlowCandidateTrack *AliAnalysisTaskFlowTPCTOFEPSP::MakeTrack( Double_t mass, + Double_t pt, Double_t phi, Double_t eta) { + // + // Make Track (Not needed actually) + // + + AliFlowCandidateTrack *sTrack = new AliFlowCandidateTrack(); + sTrack->SetMass(mass); + sTrack->SetPt(pt); + sTrack->SetPhi(phi); + sTrack->SetEta(eta); + sTrack->SetForPOISelection(kTRUE); + sTrack->SetForRPSelection(kFALSE); + return sTrack; +} +//_________________________________________________________________________________ +Double_t AliAnalysisTaskFlowTPCTOFEPSP::GetPhiAfterAddV2(Double_t phi,Double_t reactionPlaneAngle) const +{ + // + // Adds v2, uses Newton-Raphson iteration + // + Double_t phiend=phi; + Double_t phi0=phi; + Double_t f=0.; + Double_t fp=0.; + Double_t phiprev=0.; + + for (Int_t i=0; iPt(); + valuensparseDeltaPhiMaps[0] = deltaphi; + valuensparseDeltaPhiMaps[4] = source; + + valueangle[2] = source; + valueangle[1] = binct; + + // Pdg code + Int_t pdg1 = CheckPdg(TMath::Abs(track1->GetLabel()),mcEvent); + Int_t numberfound = 0; + + //Magnetic Field + Double_t bfield = vEvent->GetMagneticField(); + + // Get Primary vertex + const AliVVertex *pVtx = vEvent->GetPrimaryVertex(); + + for(Int_t idex = 0; idex < fCounterPoolBackground; idex++) + { + + Int_t iTrack2 = fArraytrack->At(idex); + AliDebug(2,Form("track %d",iTrack2)); + AliVTrack* track2 = (AliVTrack *) vEvent->GetTrack(iTrack2); + if (!track2) + { + printf("ERROR: Could not receive track %d", iTrack2); + continue; + } + if(iTrack2==iTrack1) continue; + AliDebug(2,"Different"); + + // Reset the MC info + valueangle[2] = source; + valuensparseDeltaPhiMaps[4] = source; + + // track cuts and PID already done + + // if MC look + Int_t pdg2 = -100; + if(mcEvent) { + Int_t source2 = 0; + Int_t indexmother2 = -1; + source2 = FindMother(TMath::Abs(track2->GetLabel()),mcEvent, indexmother2); + pdg2 = CheckPdg(TMath::Abs(track2->GetLabel()),mcEvent); + if(source2 >=0 ) { + if((indexmother2 == indexmother) && (source == source2) && ((pdg1*pdg2)<0.0)) { + if(source == kElectronfromconversion) { + valueangle[2] = kElectronfromconversionboth; + valuensparseDeltaPhiMaps[4] = kElectronfromconversionboth; + numberfound++; + } + if(source == kElectronfrompi0) { + valueangle[2] = kElectronfrompi0both; + valuensparseDeltaPhiMaps[4] = kElectronfrompi0both; + } + if(source == kElectronfrometa) { + valueangle[2] = kElectronfrometaboth; + valuensparseDeltaPhiMaps[4] = kElectronfrometaboth; + } + } + } + } + + if(fAlgorithmMA && (!fAODAnalysis)) + { + // tracks + AliESDtrack *esdtrack2 = dynamic_cast(track2); + AliESDtrack *esdtrack1 = dynamic_cast(track1); + if((!esdtrack2) || (!esdtrack1)) continue; + + //Variables + Double_t p1[3]; + Double_t p2[3]; + Double_t xt1; //radial position track 1 at the DCA point + Double_t xt2; //radial position track 2 at the DCA point + //DCA track1-track2 + Double_t dca12 = esdtrack2->GetDCA(esdtrack1,bfield,xt2,xt1); + + // Cut dca + if(dca12 > fMaxdca) continue; + + //Momento of the track extrapolated to DCA track-track + //Track1 + Bool_t hasdcaT1 = esdtrack1->GetPxPyPzAt(xt1,bfield,p1); + //Track2 + Bool_t hasdcaT2 = esdtrack2->GetPxPyPzAt(xt2,bfield,p2); + + if(!hasdcaT1 || !hasdcaT2) AliWarning("It could be a problem in the extrapolation"); + + //track1-track2 Invariant Mass + Double_t eMass = 0.000510998910; //Electron mass in GeV + Double_t pP1 = sqrt(p1[0]*p1[0]+p1[1]*p1[1]+p1[2]*p1[2]); //Track 1 momentum + Double_t pP2 = sqrt(p2[0]*p2[0]+p2[1]*p2[1]+p2[2]*p2[2]); //Track 2 momentum + Double_t eE1 = TMath::Sqrt(pP1*pP1+eMass*eMass); + Double_t eE2 = TMath::Sqrt(pP2*pP2+eMass*eMass); + + //TLorentzVector v1(p1[0],p1[1],p1[2],sqrt(eMass*eMass+pP1*pP1)); + //TLorentzVector v2(p2[0],p2[1],p2[2],sqrt(eMass*eMass+pP2*pP2)); + //Double_t imass = (v1+v2).M(); //Invariant Mass + //Double_t angle3D = v1.Angle(v2.Vect()); //Opening Angle (Total Angle) + + // daughter + v3D1.SetXYZ(p1[0],p1[1],p1[2]); + v3D2.SetXYZ(p2[0],p2[1],p2[2]); + Double_t openingangle = TVector2::Phi_0_2pi(v3D2.Angle(v3D1)); + + // mother + TVector3 motherrec = v3D1 + v3D2; + Double_t invmass = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(motherrec.Px()*motherrec.Px()+motherrec.Py()*motherrec.Py()+motherrec.Pz()*motherrec.Pz())); + + // xy + //TVector3 vectordiff = v3D1 - v3D2; + //Double_t diffphi = TVector2::Phi_0_2pi(vectordiff.Phi()); + //Double_t massxy = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(pP1*pP1+pP2*pP2+2*pP1*pP2*TMath::Cos(diffphi))); + + // rz + //Double_t difftheta = TVector2::Phi_0_2pi(vectordiff.Eta()); + //Double_t massrz = TMath::Sqrt((eE1+eE2)*(eE1+eE2)-(pP1*pP1+pP2*pP2+2*pP1*pP2*TMath::Cos(difftheta))); + + + Float_t fCharge1 = track1->Charge(); + Float_t fCharge2 = track2->Charge(); + + // Fill Histo + //valueangle[0] = diffphi; + //valueangle[1] = difftheta; + valueangle[0] = openingangle; + if((fCharge1*fCharge2)>0.0) fSameSignAngle->Fill(&valueangle[0]); + else fOppSignAngle->Fill(&valueangle[0]); + + // Cut + if(openingangle > fMaxopening3D) continue; + //if(difftheta > fMaxopeningtheta) continue; + //if(diffphi > fMaxopeningphi) continue; + + // Invmass + valuensparseDeltaPhiMaps[3] = invmass; + if((fCharge1*fCharge2)>0.0) fSameSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); + else fOppSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); + + // Cut + if(invmass < fMaxInvmass) { + if((fCharge1*fCharge2)<0.0) oppositetaggedphotonic=kTRUE; + if((fCharge1*fCharge2)>0.0) sametaggedphotonic=kTRUE; + } + + + } + else + { + Int_t fPDGtrack1 = 11; + Int_t fPDGtrack2 = 11; + + Float_t fCharge1 = track1->Charge(); + Float_t fCharge2 = track2->Charge(); + + if(fCharge1>0) fPDGtrack1 = -11; + if(fCharge2>0) fPDGtrack2 = -11; + + AliKFParticle ktrack1(*track1, fPDGtrack1); + AliKFParticle ktrack2(*track2, fPDGtrack2); + AliKFParticle recoGamma(ktrack1, ktrack2); + + //Reconstruction Cuts + if(recoGamma.GetNDF()<1) continue; + Double_t chi2OverNDF = recoGamma.GetChi2()/recoGamma.GetNDF(); + if(TMath::Sqrt(TMath::Abs(chi2OverNDF))>fChi2OverNDFCut) continue; + + // DCA + //Double_t dca12 = ktrack1.GetDistanceFromParticle(ktrack2); + //if(dca12 > fMaxdca) continue; + + // if set mass constraint + if(fSetMassConstraint && pVtx) { + AliKFVertex primV(*pVtx); + primV += recoGamma; + primV -= ktrack1; + primV -= ktrack2; + recoGamma.SetProductionVertex(primV); + recoGamma.SetMassConstraint(0,0.0001); + } + + //Invariant Mass + Double_t imass; + Double_t width; + recoGamma.GetMass(imass,width); + + //Opening Angle (Total Angle) + Double_t angle = ktrack1.GetAngle(ktrack2); + valueangle[0] = angle; + if((fCharge1*fCharge2)>0.0) fSameSignAngle->Fill(&valueangle[0]); + else fOppSignAngle->Fill(&valueangle[0]); + + // Cut + if(angle > fMaxopening3D) continue; + + // Invmass + valuensparseDeltaPhiMaps[3] = imass; + if((fCharge1*fCharge2)>0.0) fSameSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); + else { + fOppSignDeltaPhiMaps->Fill(&valuensparseDeltaPhiMaps[0]); + /* + if(valueangle[2] == kElectronfromconversionboth) { + printf("Reconstructed charge1 %f, charge 2 %f and invmass %f",fCharge1,fCharge2,imass); + printf("MC charge1 %d, charge 2 %d",pdg1,pdg2); + printf("DCA %f",dca12); + printf("Number of found %d",numberfound); + } + */ + } + + // Cut + if(imass < fMaxInvmass) { + if((fCharge1*fCharge2)<0.0) oppositetaggedphotonic=kTRUE; + if((fCharge1*fCharge2)>0.0) sametaggedphotonic=kTRUE; + } + } + } + + if(oppositetaggedphotonic && sametaggedphotonic){ + taggedphotonic = 6; + } + + if(!oppositetaggedphotonic && sametaggedphotonic){ + taggedphotonic = 4; + } + + if(oppositetaggedphotonic && !sametaggedphotonic){ + taggedphotonic = 2; + } + + + return taggedphotonic; +} +//_________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &indexmother){ + // + // Find the mother if MC + // + + if(!mcEvent) return 0; + + Int_t pdg = CheckPdg(tr,mcEvent); + if(TMath::Abs(pdg)!= 11) { + indexmother = -1; + return kNoElectron; + } + + indexmother = IsMotherGamma(tr,mcEvent); + if(indexmother > 0) return kElectronfromconversion; + indexmother = IsMotherPi0(tr,mcEvent); + if(indexmother > 0) return kElectronfrompi0; + indexmother = IsMotherC(tr,mcEvent); + if(indexmother > 0) return kElectronfromC; + indexmother = IsMotherB(tr,mcEvent); + if(indexmother > 0) return kElectronfromB; + indexmother = IsMotherEta(tr,mcEvent); + if(indexmother > 0) return kElectronfrometa; + + return kElectronfromother; + + +} +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::CheckPdg(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the pdg of the particle + // + + + Int_t pdgcode = -1; + if(tr < 0) return pdgcode; + + if(!mcEvent) return pdgcode; + + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode; + pdgcode = mctrackesd->PdgCode(); + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return pdgcode; + pdgcode = mctrackaod->GetPdgCode(); + } + + return pdgcode; + + +} +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherGamma(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the lab of gamma mother or -1 if not gamma + // + + if(tr < 0) return -1; + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + TParticle *particle = 0x0; + particle = mctrackesd->Particle(); + // Take mother + if(!particle) return -1; + Int_t imother = particle->GetFirstMother(); + if(imother < 0) return -1; + AliMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + TParticle * mother = mothertrack->Particle(); + if(!mother) return -1; + // Check gamma + Int_t pdg = mother->GetPdgCode(); + if(TMath::Abs(pdg) == 22) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherGamma(imother,mcEvent); + } + return -1; + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + // Take mother + Int_t imother = mctrackaod->GetMother(); + if(imother < 0) return -1; + AliAODMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + // Check gamma + Int_t pdg = mothertrack->GetPdgCode(); + if(TMath::Abs(pdg) == 22) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherGamma(imother,mcEvent); + } + return -1; + + } + + return -1; + + +} +// +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherPi0(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the lab of pi0 mother or -1 if not pi0 + // + + if(tr < 0) return -1; + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + TParticle *particle = 0x0; + particle = mctrackesd->Particle(); + // Take mother + if(!particle) return -1; + Int_t imother = particle->GetFirstMother(); + if(imother < 0) return -1; + AliMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + TParticle * mother = mothertrack->Particle(); + if(!mother) return -1; + // Check gamma + Int_t pdg = mother->GetPdgCode(); + if(TMath::Abs(pdg) == 111) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherPi0(imother,mcEvent); + } + return -1; + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + // Take mother + Int_t imother = mctrackaod->GetMother(); + if(imother < 0) return -1; + AliAODMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + // Check gamma + Int_t pdg = mothertrack->GetPdgCode(); + if(TMath::Abs(pdg) == 111) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherPi0(imother,mcEvent); + } + return -1; + } + + return -1; + +} +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherC(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the lab of signal mother or -1 if not signal + // + + if(tr < 0) return -1; + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + TParticle *particle = 0x0; + particle = mctrackesd->Particle(); + // Take mother + if(!particle) return -1; + Int_t imother = particle->GetFirstMother(); + if(imother < 0) return -1; + AliMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + TParticle * mother = mothertrack->Particle(); + if(!mother) return -1; + // Check gamma + Int_t pdg = mother->GetPdgCode(); + if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherC(imother,mcEvent); + } + return -1; + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + // Take mother + Int_t imother = mctrackaod->GetMother(); + if(imother < 0) return -1; + AliAODMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + // Check gamma + Int_t pdg = mothertrack->GetPdgCode(); + if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherC(imother,mcEvent); + } + return -1; + } + + return -1; + +} +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherB(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the lab of signal mother or -1 if not signal + // + + if(tr < 0) return -1; + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + TParticle *particle = 0x0; + particle = mctrackesd->Particle(); + // Take mother + if(!particle) return -1; + Int_t imother = particle->GetFirstMother(); + if(imother < 0) return -1; + AliMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + TParticle * mother = mothertrack->Particle(); + if(!mother) return -1; + // Check gamma + Int_t pdg = mother->GetPdgCode(); + if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherB(imother,mcEvent); + } + return -1; + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + // Take mother + Int_t imother = mctrackaod->GetMother(); + if(imother < 0) return -1; + AliAODMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + // Check gamma + Int_t pdg = mothertrack->GetPdgCode(); + if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherB(imother,mcEvent); + } + return -1; + } + + return -1; + +} +//____________________________________________________________________________________________________________ +Int_t AliAnalysisTaskFlowTPCTOFEPSP::IsMotherEta(Int_t tr, AliMCEvent* mcEvent) { + + // + // Return the lab of pi0 mother or -1 if not pi0 + // + + if(tr < 0) return -1; + AliVParticle *mctrack = mcEvent->GetTrack(tr); + + if(mctrack->IsA() == AliMCParticle::Class()) { + AliMCParticle *mctrackesd = NULL; + if(!(mctrackesd = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + TParticle *particle = 0x0; + particle = mctrackesd->Particle(); + // Take mother + if(!particle) return -1; + Int_t imother = particle->GetFirstMother(); + if(imother < 0) return -1; + AliMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + TParticle * mother = mothertrack->Particle(); + if(!mother) return -1; + // Check gamma + Int_t pdg = mother->GetPdgCode(); + if(TMath::Abs(pdg) == 221) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherEta(imother,mcEvent); + } + return -1; + } + + if(mctrack->IsA() == AliAODMCParticle::Class()) { + AliAODMCParticle *mctrackaod = NULL; + if(!(mctrackaod = dynamic_cast(mcEvent->GetTrack(TMath::Abs(tr))))) return -1; + // Take mother + Int_t imother = mctrackaod->GetMother(); + if(imother < 0) return -1; + AliAODMCParticle *mothertrack = NULL; + if(!(mothertrack = dynamic_cast(mcEvent->GetTrack(TMath::Abs(imother))))) return -1; + // Check gamma + Int_t pdg = mothertrack->GetPdgCode(); + if(TMath::Abs(pdg) == 221) return imother; + if(TMath::Abs(pdg) == 11) { + return IsMotherEta(imother,mcEvent); + } + return -1; + } + + return -1; + +} diff --git a/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.h b/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.h index 1050f06e39c..648acc0f1f6 100644 --- a/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.h +++ b/PWGHF/hfe/AliAnalysisTaskFlowTPCTOFEPSP.h @@ -1,314 +1,314 @@ -/************************************************************************** -* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ -// -// Flow task class for the ALICE HFE group -// -// -#ifndef ALIANALYSISTASKFLOWTPCTOFEPSP_H -#define ALIANALYSISTASKFLOWTPCTOFEPSP_H - - - - -#include - -class TList; -class AliVTrack; -class AliVEvent; -class AliESDtrack; -class AliESDEvent; -class AliMCEvent; -class AliFlowTrackCuts; -class AliFlowCandidateTrack; -class AliHFEcuts; -class AliHFEpid; -class TH1D; -class TH2D; -class TF1; -class TProfile; -class TProfile2D; -class THnSparse; -class AliHFEpidQAmanager; -class AliFlowEvent; -class AliESDtrackCuts; -class AliHFEVZEROEventPlane; -class TArrayI; -class AliAODMCHeader; -class TClonesArray; -class AliHFENonPhotonicElectron; -class TTreeSRedirector; - -class AliAnalysisTaskFlowTPCTOFEPSP: public AliAnalysisTaskSE { -public: - - typedef enum{ - kElectronfromconversion = 0, - kElectronfromconversionboth = 1, - kElectronfrompi0 = 2, - kElectronfrompi0both = 3, - kElectronfrometa = 4, - kElectronfrometaboth = 5, - kElectronfromC = 6, - kElectronfromB = 7, - kElectronfromother = 8, - kNoElectron = 9 - } FlowSource_t; - - typedef enum{ - kS = 0, - kOp = 1 - } FlowSign_t; - - - - - AliAnalysisTaskFlowTPCTOFEPSP(); - AliAnalysisTaskFlowTPCTOFEPSP(const char *name); - AliAnalysisTaskFlowTPCTOFEPSP(const AliAnalysisTaskFlowTPCTOFEPSP &ref); - AliAnalysisTaskFlowTPCTOFEPSP& operator=(const AliAnalysisTaskFlowTPCTOFEPSP &ref); - virtual void Copy(TObject &o) const; - virtual ~AliAnalysisTaskFlowTPCTOFEPSP(); - - virtual void UserExec(Option_t */*option*/); - virtual void UserCreateOutputObjects(); - - void SetAODAnalysis(Bool_t aodAnalysis) { fAODAnalysis = aodAnalysis; }; - void SetFilter(ULong_t filter) { fFilter = filter; } - - AliHFEpid *GetPID() const { return fPID; } - AliHFEpid *GetPIDTOFOnly() const { return fPIDTOFOnly; } - AliHFEpidQAmanager *GetPIDQAManager() const { return fPIDqa; } - AliHFEpid *GetPIDBackground() const { return fPIDBackground; } - AliHFEpidQAmanager *GetPIDBackgroundQAManager() const { return fPIDBackgroundqa; } - AliHFENonPhotonicElectron *GetHFEBackgroundSubtraction() const { return fBackgroundSubtraction; } - - - void SetContamination(TF1 * const function,Int_t k) { fContamination[k] = function; }; - void SetV2Contamination(TF1 * const function,Int_t k) { fv2contamination[k] = function; }; - void SetHFECuts(AliHFEcuts * const cuts) { fHFECuts = cuts; }; - void SetHFEBackgroundSubtraction(AliHFENonPhotonicElectron * const backgroundSubtraction) { fBackgroundSubtraction = backgroundSubtraction; }; - void SetHFEBackgroundCuts(AliESDtrackCuts * const cuts) { fHFEBackgroundCuts = cuts; }; - void SetSubEtaGapTPC(Bool_t subEtaGapTPC) { fSubEtaGapTPC = subEtaGapTPC; }; - void SetEtaGap(Double_t etaGap) { fEtaGap = etaGap; }; - void SetVZEROEventPlane(Bool_t vzeroEventPlane) { fVZEROEventPlane = vzeroEventPlane; }; - void SetVZEROEventPlaneA(Bool_t vzeroEventPlaneA) { fVZEROEventPlaneA = vzeroEventPlaneA; }; - void SetVZEROEventPlaneC(Bool_t vzeroEventPlaneC) { fVZEROEventPlaneC = vzeroEventPlaneC; }; - void SetHFEVZEROEventPlane(AliHFEVZEROEventPlane *hfeVZEROEventPlane) { fHFEVZEROEventPlane = hfeVZEROEventPlane; }; - - void SetNbBinsCentralityQCumulant(Int_t nbBinsCentralityQCumulant) { fNbBinsCentralityQCumulant = nbBinsCentralityQCumulant; }; - void SetBinCentralityLess(Int_t k, Float_t value) { fBinCentralityLess[k] = value; }; - void SetNbBinsPtQCumulant(Int_t nbBinsPtQCumulant) { fNbBinsPtQCumulant = nbBinsPtQCumulant; }; - void SetMinPtQCumulant(Double_t minPtQCumulant) { fMinPtQCumulant = minPtQCumulant; }; - void SetMaxPtQCumulant(Double_t maxPtQCumulant) { fMaxPtQCumulant = maxPtQCumulant; }; - - void SetAfterBurnerOn(Bool_t afterBurnerOn) { fAfterBurnerOn = afterBurnerOn; }; - void SetNonFlowNumberOfTrackClones(Int_t nonFlowNumberOfTrackClones) { fNonFlowNumberOfTrackClones = nonFlowNumberOfTrackClones; }; - void SetV1V2V3V4V5(Double_t v1,Double_t v2,Double_t v3,Double_t v4,Double_t v5) {fV1 = v1; fV2 = v2; fV3 = v3; fV4 = v4; fV5 = v5; }; - void SetMaxNumberOfIterations(Int_t maxNumberOfIterations) { fMaxNumberOfIterations = maxNumberOfIterations; }; - void SetPrecisionPhi(Double_t precisionPhi) { fPrecisionPhi = precisionPhi;}; - void SetUseMCReactionPlane(Bool_t useMCReactionPlane) { fUseMCReactionPlane = useMCReactionPlane;}; - void SetUseSP(Bool_t useSP) { fSP = useSP;} - void SetMCPID(Bool_t mcPID) { fMCPID = mcPID;}; - void SetNoPID(Bool_t noPID) { fNoPID = noPID;}; - - void SetMonitorEventPlane(Bool_t monitorEventPlane) { fMonitorEventPlane = monitorEventPlane;}; - void SetMonitorContamination(Bool_t monitorContamination) { fMonitorContamination = monitorContamination;}; - void SetMonitorPhotonic(Bool_t monitorPhotonic) { fMonitorPhotonic = monitorPhotonic;}; - void SetMonitorWithoutPID(Bool_t monitorWithoutPID) { fMonitorWithoutPID = monitorWithoutPID;}; - void SetMonitorTrackCuts(Bool_t monitorTrackCuts) { fMonitorTrackCuts = monitorTrackCuts;}; - void SetMonitorQCumulant(Bool_t monitorQCumulant) { fMonitorQCumulant = monitorQCumulant;}; - - Int_t GetNbBinsCentralityQCumulant() const { return fNbBinsCentralityQCumulant; }; - Double_t GetBinCentralityLess(Int_t k) const { return fBinCentralityLess[k]; }; - - AliFlowCandidateTrack *MakeTrack( Double_t mass, Double_t pt, Double_t phi, Double_t eta) ; - Double_t GetPhiAfterAddV2(Double_t phi,Double_t reactionPlaneAngle) const; - - void SetMaxInvmass(Double_t maxInvmass) { fMaxInvmass = maxInvmass; }; - void SetMaxopening3D(Double_t maxOpening3D) { fMaxopening3D = maxOpening3D; }; - void SetMaxopeningtheta(Double_t maxOpeningtheta) { fMaxopeningtheta = maxOpeningtheta; }; - void SetMaxopeningphi(Double_t maxOpeningphi) { fMaxopeningphi = maxOpeningphi; }; - void SetAlgorithmMA(Bool_t algorithmMA) { fAlgorithmMA = algorithmMA; }; - void SetMassConstraint(Bool_t massConstraint) { fSetMassConstraint = massConstraint; }; - void SetPileUpCut(Bool_t cut=kTRUE) { fPileUpCut=cut; } - - Int_t LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, AliVEvent *fESD, AliMCEvent *mcEvent,Int_t binct,Double_t deltaphi,Int_t source,Int_t indexmother); - -private: - TList *fListHist; //! TH list - Bool_t fAODAnalysis; // AOD analysis - ULong_t fFilter; // reconstruction AOD status flags - AliAODMCHeader *fAODMCHeader; // ! MC info AOD - TClonesArray *fAODArrayMCInfo; // ! MC info particle AOD - AliHFENonPhotonicElectron *fBackgroundSubtraction; // Background subtraction - - Bool_t fVZEROEventPlane; // Use Event Planes from VZERO - Bool_t fVZEROEventPlaneA; // Use Event Planes from VZERO A - Bool_t fVZEROEventPlaneC; // Use Event Planes from VZERO C - - Bool_t fSubEtaGapTPC; // bool to fill with eta gap - Double_t fEtaGap; // Value of the eta gap - - Int_t fNbBinsCentralityQCumulant; // Number of Bins Q Cumulant - Double_t fBinCentralityLess[10]; // Centrality Bin lower value - Int_t fNbBinsPtQCumulant; // Nbbinspt QCumulant method - Double_t fMinPtQCumulant; // Min pt QCumulant method - Double_t fMaxPtQCumulant; // Max pt QCumulant method - Bool_t fAfterBurnerOn; // Add flow to all tracks - Int_t fNonFlowNumberOfTrackClones; // number of times to clone the particles (nonflow) - Double_t fV1; // Add Flow. Must be in range [0,0.5]. - Double_t fV2; // Add Flow. Must be in range [0,0.5]. - Double_t fV3; // Add Flow. Must be in range [0,0.5]. - Double_t fV4; // Add Flow. Must be in range [0,0.5]. - Double_t fV5; // Add Flow. Must be in range [0,0.5]. - Int_t fMaxNumberOfIterations; // Max number of iteration for adding v2 - Double_t fPrecisionPhi; // precision phi for adding v2 - Bool_t fUseMCReactionPlane; // use MC reaction plane - Bool_t fSP; // calculate using scalar product method (instead of event plane method) - - Bool_t fMCPID; // MC PID for electrons - Bool_t fNoPID; // No PID for checks - - Double_t fChi2OverNDFCut; // Limit chi2 - Double_t fMaxdca; // Limit dca - Double_t fMaxopeningtheta; // Limit opening angle in theta - Double_t fMaxopeningphi; // Limit opening angle in phi - Double_t fMaxopening3D; // Limit opening 3D - Double_t fMaxInvmass; // Limit invariant mass - Bool_t fSetMassConstraint; // Set mass constraint - - - Bool_t fMonitorEventPlane; // Monitor event plane - Bool_t fMonitorContamination; // Monitor contamination - Bool_t fMonitorPhotonic;// Monitor photonic - Bool_t fMonitorWithoutPID;// Monitor without PID - Bool_t fMonitorTrackCuts;// Monitor track cuts - Bool_t fMonitorQCumulant;// Monitor Q cumulant - - // Cuts for FLOW PWG2 - AliFlowTrackCuts* fcutsRP; //! Reference particle cut - AliFlowTrackCuts* fcutsPOI; //! Particle Of Interest cut - - // Cuts for HFE - AliHFEcuts *fHFECuts; // HFE cuts - AliHFEpid *fPID; // PID cuts - AliHFEpid *fPIDTOFOnly; // PID cuts TOF only - AliHFEpidQAmanager *fPIDqa; // QA Manager - AliFlowEvent *fflowEvent; //! Flow event - - // Hadron Contamination - TF1 *fContamination[11]; // Parametrization of the contamination (0-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100) - TF1 *fv2contamination[11]; // Parametrization of the v2 of charged pions (0-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100) - - // Cuts for background study - AliESDtrackCuts *fHFEBackgroundCuts; // HFE background cuts - AliHFEpid *fPIDBackground; // PID background cuts - AliHFEpidQAmanager *fPIDBackgroundqa; // QA Manager Background - Bool_t fAlgorithmMA; // algorithm MA - - // List of tracks - TArrayI *fArraytrack; //! list of tracks - Int_t fCounterPoolBackground; // number of tracks - - // VZERO Event plane after calibration 2010 - AliHFEVZEROEventPlane *fHFEVZEROEventPlane; // VZERO event plane calibrated - - // Histos - TH2D *fHistEV; //! Number of events - THnSparseF *fHistPileUp; //! Pile up histogram - Bool_t fPileUpCut; - - // A Event plane as function of phiepa, phiepb, phiepc, phiepd centrality - // a V0A, b V0C, c TPC, - THnSparseF *fEventPlane; //! Event plane - - // B Event Plane after subtraction as function of phiep, centrality - THnSparseF *fEventPlaneaftersubtraction; //! Event plane - - // Contamination - THnSparseF *fFractionContamination; //! Fraction of contamination as function of pt - TProfile2D *fContaminationv2; //! v2 of contamination - - // Monitoring Event plane: cos2phi, sin2phi, centrality - THnSparseF *fCosSin2phiep; //! Cos(2phi), Sin(2phi) - - // E Monitoring Event plane after subtraction of the track: cos, centrality, pt, eta - THnSparseF *fCos2phie; //! Monitoring - THnSparseF *fSin2phie; //! Monitoring - THnSparseF *fCos2phiep; //! Monitoring - THnSparseF *fSin2phiep; //! Monitoring - THnSparseF *fSin2phiephiep; //! Monitoring - - // Fbis Resolution as function of cosres, cosres, cosres, centrality for three subevents (V0) - // a V0A, b V0C, c TPC - THnSparseF *fCosResabc; //! Res - THnSparseF *fSinResabc; //! Res - TProfile *fProfileCosResab; //! Profile Res_a_b - TProfile *fProfileCosResac; //! Profile Res_a_c - TProfile *fProfileCosResbc; //! Profile Res_b_c - - // F Resolution as function of cosres, centrality for two subevents (TPC) - THnSparseF *fCosRes; //! Res - THnSparseF *fSinRes; //! Res - TProfile *fProfileCosRes; //! Profile Res - - // Debuging Cuts step by step all centrality together: pt, step (6) - THnSparseF *fTrackingCuts; //! Tracking Cuts - - // Before PID cut - // G Maps delta phi as function of deltaphi, centrality, pt - THnSparseF *fDeltaPhiMapsBeforePID; //! Delta phi - // H Maps cos phi : cos, centrality, pt - THnSparseF *fCosPhiMapsBeforePID; //! Cos - - // G Maps delta phi as function of deltaphi, centrality, pt - THnSparseF *fDeltaPhiMaps; //! Delta phi - THnSparseF *fDeltaPhiMapsContamination; //! Delta phi for contamination substraction - // H Maps cos phi : cos, centrality, pt - THnSparseF *fCosPhiMaps; //! Cos - TProfile2D *fProfileCosPhiMaps; //! Profile Cos - - // Background study: not statistic but tagged - THnSparseF *fDeltaPhiMapsTaggedPhotonic; //! Delta phi - //THnSparseF *fCosPhiMapsTaggedPhotonic; //! Cos - THnSparseF *fDeltaPhiMapsTaggedNonPhotonic; //! Delta phi - //THnSparseF *fCosPhiMapsTaggedNonPhotonic; //! Cos - THnSparseF *fDeltaPhiMapsTaggedPhotonicLS; //! Delta phi - //THnSparseF *fCosPhiMapsTaggedPhotonicLS; //! Cos - - // Background study: centrality, pt, source - THnSparseF *fMCSourceDeltaPhiMaps; //! Source MC - // Background study: deltaphi, centrality, pt, minv, source - THnSparseF *fOppSignDeltaPhiMaps; //! Delta phi - THnSparseF *fSameSignDeltaPhiMaps; //! Delta phi - // Background study: angle, centrality, source - THnSparseF *fOppSignAngle; // ! Opening Angles - THnSparseF *fSameSignAngle; // ! Opening Angles - - TTreeSRedirector *fDebugStreamer; //!Debug streamer - - Int_t FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &indexmother); - Int_t CheckPdg(Int_t tr, AliMCEvent* mcEvent); - Int_t IsMotherGamma(Int_t tr, AliMCEvent* mcEvent); - Int_t IsMotherPi0(Int_t tr, AliMCEvent* mcEvent); - Int_t IsMotherC(Int_t tr, AliMCEvent* mcEvent); - Int_t IsMotherB(Int_t tr, AliMCEvent* mcEvent); - Int_t IsMotherEta(Int_t tr, AliMCEvent* mcEvent); - - - ClassDef(AliAnalysisTaskFlowTPCTOFEPSP, 1); // analysisclass -}; - -#endif +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ +// +// Flow task class for the ALICE HFE group +// +// +#ifndef ALIANALYSISTASKFLOWTPCTOFEPSP_H +#define ALIANALYSISTASKFLOWTPCTOFEPSP_H + + + + +#include + +class TList; +class AliVTrack; +class AliVEvent; +class AliESDtrack; +class AliESDEvent; +class AliMCEvent; +class AliFlowTrackCuts; +class AliFlowCandidateTrack; +class AliHFEcuts; +class AliHFEpid; +class TH1D; +class TH2D; +class TF1; +class TProfile; +class TProfile2D; +class THnSparse; +class AliHFEpidQAmanager; +class AliFlowEvent; +class AliESDtrackCuts; +class AliHFEVZEROEventPlane; +class TArrayI; +class AliAODMCHeader; +class TClonesArray; +class AliHFENonPhotonicElectron; +class TTreeSRedirector; + +class AliAnalysisTaskFlowTPCTOFEPSP: public AliAnalysisTaskSE { +public: + + typedef enum{ + kElectronfromconversion = 0, + kElectronfromconversionboth = 1, + kElectronfrompi0 = 2, + kElectronfrompi0both = 3, + kElectronfrometa = 4, + kElectronfrometaboth = 5, + kElectronfromC = 6, + kElectronfromB = 7, + kElectronfromother = 8, + kNoElectron = 9 + } FlowSource_t; + + typedef enum{ + kS = 0, + kOp = 1 + } FlowSign_t; + + + + + AliAnalysisTaskFlowTPCTOFEPSP(); + AliAnalysisTaskFlowTPCTOFEPSP(const char *name); + AliAnalysisTaskFlowTPCTOFEPSP(const AliAnalysisTaskFlowTPCTOFEPSP &ref); + AliAnalysisTaskFlowTPCTOFEPSP& operator=(const AliAnalysisTaskFlowTPCTOFEPSP &ref); + virtual void Copy(TObject &o) const; + virtual ~AliAnalysisTaskFlowTPCTOFEPSP(); + + virtual void UserExec(Option_t */*option*/); + virtual void UserCreateOutputObjects(); + + void SetAODAnalysis(Bool_t aodAnalysis) { fAODAnalysis = aodAnalysis; }; + void SetFilter(ULong_t filter) { fFilter = filter; } + + AliHFEpid *GetPID() const { return fPID; } + AliHFEpid *GetPIDTOFOnly() const { return fPIDTOFOnly; } + AliHFEpidQAmanager *GetPIDQAManager() const { return fPIDqa; } + AliHFEpid *GetPIDBackground() const { return fPIDBackground; } + AliHFEpidQAmanager *GetPIDBackgroundQAManager() const { return fPIDBackgroundqa; } + AliHFENonPhotonicElectron *GetHFEBackgroundSubtraction() const { return fBackgroundSubtraction; } + + + void SetContamination(TF1 * const function,Int_t k) { fContamination[k] = function; }; + void SetV2Contamination(TF1 * const function,Int_t k) { fv2contamination[k] = function; }; + void SetHFECuts(AliHFEcuts * const cuts) { fHFECuts = cuts; }; + void SetHFEBackgroundSubtraction(AliHFENonPhotonicElectron * const backgroundSubtraction) { fBackgroundSubtraction = backgroundSubtraction; }; + void SetHFEBackgroundCuts(AliESDtrackCuts * const cuts) { fHFEBackgroundCuts = cuts; }; + void SetSubEtaGapTPC(Bool_t subEtaGapTPC) { fSubEtaGapTPC = subEtaGapTPC; }; + void SetEtaGap(Double_t etaGap) { fEtaGap = etaGap; }; + void SetVZEROEventPlane(Bool_t vzeroEventPlane) { fVZEROEventPlane = vzeroEventPlane; }; + void SetVZEROEventPlaneA(Bool_t vzeroEventPlaneA) { fVZEROEventPlaneA = vzeroEventPlaneA; }; + void SetVZEROEventPlaneC(Bool_t vzeroEventPlaneC) { fVZEROEventPlaneC = vzeroEventPlaneC; }; + void SetHFEVZEROEventPlane(AliHFEVZEROEventPlane *hfeVZEROEventPlane) { fHFEVZEROEventPlane = hfeVZEROEventPlane; }; + + void SetNbBinsCentralityQCumulant(Int_t nbBinsCentralityQCumulant) { fNbBinsCentralityQCumulant = nbBinsCentralityQCumulant; }; + void SetBinCentralityLess(Int_t k, Float_t value) { fBinCentralityLess[k] = value; }; + void SetNbBinsPtQCumulant(Int_t nbBinsPtQCumulant) { fNbBinsPtQCumulant = nbBinsPtQCumulant; }; + void SetMinPtQCumulant(Double_t minPtQCumulant) { fMinPtQCumulant = minPtQCumulant; }; + void SetMaxPtQCumulant(Double_t maxPtQCumulant) { fMaxPtQCumulant = maxPtQCumulant; }; + + void SetAfterBurnerOn(Bool_t afterBurnerOn) { fAfterBurnerOn = afterBurnerOn; }; + void SetNonFlowNumberOfTrackClones(Int_t nonFlowNumberOfTrackClones) { fNonFlowNumberOfTrackClones = nonFlowNumberOfTrackClones; }; + void SetV1V2V3V4V5(Double_t v1,Double_t v2,Double_t v3,Double_t v4,Double_t v5) {fV1 = v1; fV2 = v2; fV3 = v3; fV4 = v4; fV5 = v5; }; + void SetMaxNumberOfIterations(Int_t maxNumberOfIterations) { fMaxNumberOfIterations = maxNumberOfIterations; }; + void SetPrecisionPhi(Double_t precisionPhi) { fPrecisionPhi = precisionPhi;}; + void SetUseMCReactionPlane(Bool_t useMCReactionPlane) { fUseMCReactionPlane = useMCReactionPlane;}; + void SetUseSP(Bool_t useSP) { fSP = useSP;} + void SetMCPID(Bool_t mcPID) { fMCPID = mcPID;}; + void SetNoPID(Bool_t noPID) { fNoPID = noPID;}; + + void SetMonitorEventPlane(Bool_t monitorEventPlane) { fMonitorEventPlane = monitorEventPlane;}; + void SetMonitorContamination(Bool_t monitorContamination) { fMonitorContamination = monitorContamination;}; + void SetMonitorPhotonic(Bool_t monitorPhotonic) { fMonitorPhotonic = monitorPhotonic;}; + void SetMonitorWithoutPID(Bool_t monitorWithoutPID) { fMonitorWithoutPID = monitorWithoutPID;}; + void SetMonitorTrackCuts(Bool_t monitorTrackCuts) { fMonitorTrackCuts = monitorTrackCuts;}; + void SetMonitorQCumulant(Bool_t monitorQCumulant) { fMonitorQCumulant = monitorQCumulant;}; + + Int_t GetNbBinsCentralityQCumulant() const { return fNbBinsCentralityQCumulant; }; + Double_t GetBinCentralityLess(Int_t k) const { return fBinCentralityLess[k]; }; + + AliFlowCandidateTrack *MakeTrack( Double_t mass, Double_t pt, Double_t phi, Double_t eta) ; + Double_t GetPhiAfterAddV2(Double_t phi,Double_t reactionPlaneAngle) const; + + void SetMaxInvmass(Double_t maxInvmass) { fMaxInvmass = maxInvmass; }; + void SetMaxopening3D(Double_t maxOpening3D) { fMaxopening3D = maxOpening3D; }; + void SetMaxopeningtheta(Double_t maxOpeningtheta) { fMaxopeningtheta = maxOpeningtheta; }; + void SetMaxopeningphi(Double_t maxOpeningphi) { fMaxopeningphi = maxOpeningphi; }; + void SetAlgorithmMA(Bool_t algorithmMA) { fAlgorithmMA = algorithmMA; }; + void SetMassConstraint(Bool_t massConstraint) { fSetMassConstraint = massConstraint; }; + void SetPileUpCut(Bool_t cut=kTRUE) { fPileUpCut=cut; } + + Int_t LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, AliVEvent *fESD, AliMCEvent *mcEvent,Int_t binct,Double_t deltaphi,Int_t source,Int_t indexmother); + +private: + TList *fListHist; //! TH list + Bool_t fAODAnalysis; // AOD analysis + ULong_t fFilter; // reconstruction AOD status flags + AliAODMCHeader *fAODMCHeader; // ! MC info AOD + TClonesArray *fAODArrayMCInfo; // ! MC info particle AOD + AliHFENonPhotonicElectron *fBackgroundSubtraction; // Background subtraction + + Bool_t fVZEROEventPlane; // Use Event Planes from VZERO + Bool_t fVZEROEventPlaneA; // Use Event Planes from VZERO A + Bool_t fVZEROEventPlaneC; // Use Event Planes from VZERO C + + Bool_t fSubEtaGapTPC; // bool to fill with eta gap + Double_t fEtaGap; // Value of the eta gap + + Int_t fNbBinsCentralityQCumulant; // Number of Bins Q Cumulant + Double_t fBinCentralityLess[10]; // Centrality Bin lower value + Int_t fNbBinsPtQCumulant; // Nbbinspt QCumulant method + Double_t fMinPtQCumulant; // Min pt QCumulant method + Double_t fMaxPtQCumulant; // Max pt QCumulant method + Bool_t fAfterBurnerOn; // Add flow to all tracks + Int_t fNonFlowNumberOfTrackClones; // number of times to clone the particles (nonflow) + Double_t fV1; // Add Flow. Must be in range [0,0.5]. + Double_t fV2; // Add Flow. Must be in range [0,0.5]. + Double_t fV3; // Add Flow. Must be in range [0,0.5]. + Double_t fV4; // Add Flow. Must be in range [0,0.5]. + Double_t fV5; // Add Flow. Must be in range [0,0.5]. + Int_t fMaxNumberOfIterations; // Max number of iteration for adding v2 + Double_t fPrecisionPhi; // precision phi for adding v2 + Bool_t fUseMCReactionPlane; // use MC reaction plane + Bool_t fSP; // calculate using scalar product method (instead of event plane method) + + Bool_t fMCPID; // MC PID for electrons + Bool_t fNoPID; // No PID for checks + + Double_t fChi2OverNDFCut; // Limit chi2 + Double_t fMaxdca; // Limit dca + Double_t fMaxopeningtheta; // Limit opening angle in theta + Double_t fMaxopeningphi; // Limit opening angle in phi + Double_t fMaxopening3D; // Limit opening 3D + Double_t fMaxInvmass; // Limit invariant mass + Bool_t fSetMassConstraint; // Set mass constraint + + + Bool_t fMonitorEventPlane; // Monitor event plane + Bool_t fMonitorContamination; // Monitor contamination + Bool_t fMonitorPhotonic;// Monitor photonic + Bool_t fMonitorWithoutPID;// Monitor without PID + Bool_t fMonitorTrackCuts;// Monitor track cuts + Bool_t fMonitorQCumulant;// Monitor Q cumulant + + // Cuts for FLOW PWG2 + AliFlowTrackCuts* fcutsRP; //! Reference particle cut + AliFlowTrackCuts* fcutsPOI; //! Particle Of Interest cut + + // Cuts for HFE + AliHFEcuts *fHFECuts; // HFE cuts + AliHFEpid *fPID; // PID cuts + AliHFEpid *fPIDTOFOnly; // PID cuts TOF only + AliHFEpidQAmanager *fPIDqa; // QA Manager + AliFlowEvent *fflowEvent; //! Flow event + + // Hadron Contamination + TF1 *fContamination[11]; // Parametrization of the contamination (0-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100) + TF1 *fv2contamination[11]; // Parametrization of the v2 of charged pions (0-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100) + + // Cuts for background study + AliESDtrackCuts *fHFEBackgroundCuts; // HFE background cuts + AliHFEpid *fPIDBackground; // PID background cuts + AliHFEpidQAmanager *fPIDBackgroundqa; // QA Manager Background + Bool_t fAlgorithmMA; // algorithm MA + + // List of tracks + TArrayI *fArraytrack; //! list of tracks + Int_t fCounterPoolBackground; // number of tracks + + // VZERO Event plane after calibration 2010 + AliHFEVZEROEventPlane *fHFEVZEROEventPlane; // VZERO event plane calibrated + + // Histos + TH2D *fHistEV; //! Number of events + THnSparseF *fHistPileUp; //! Pile up histogram + Bool_t fPileUpCut; + + // A Event plane as function of phiepa, phiepb, phiepc, phiepd centrality + // a V0A, b V0C, c TPC, + THnSparseF *fEventPlane; //! Event plane + + // B Event Plane after subtraction as function of phiep, centrality + THnSparseF *fEventPlaneaftersubtraction; //! Event plane + + // Contamination + THnSparseF *fFractionContamination; //! Fraction of contamination as function of pt + TProfile2D *fContaminationv2; //! v2 of contamination + + // Monitoring Event plane: cos2phi, sin2phi, centrality + THnSparseF *fCosSin2phiep; //! Cos(2phi), Sin(2phi) + + // E Monitoring Event plane after subtraction of the track: cos, centrality, pt, eta + THnSparseF *fCos2phie; //! Monitoring + THnSparseF *fSin2phie; //! Monitoring + THnSparseF *fCos2phiep; //! Monitoring + THnSparseF *fSin2phiep; //! Monitoring + THnSparseF *fSin2phiephiep; //! Monitoring + + // Fbis Resolution as function of cosres, cosres, cosres, centrality for three subevents (V0) + // a V0A, b V0C, c TPC + THnSparseF *fCosResabc; //! Res + THnSparseF *fSinResabc; //! Res + TProfile *fProfileCosResab; //! Profile Res_a_b + TProfile *fProfileCosResac; //! Profile Res_a_c + TProfile *fProfileCosResbc; //! Profile Res_b_c + + // F Resolution as function of cosres, centrality for two subevents (TPC) + THnSparseF *fCosRes; //! Res + THnSparseF *fSinRes; //! Res + TProfile *fProfileCosRes; //! Profile Res + + // Debuging Cuts step by step all centrality together: pt, step (6) + THnSparseF *fTrackingCuts; //! Tracking Cuts + + // Before PID cut + // G Maps delta phi as function of deltaphi, centrality, pt + THnSparseF *fDeltaPhiMapsBeforePID; //! Delta phi + // H Maps cos phi : cos, centrality, pt + THnSparseF *fCosPhiMapsBeforePID; //! Cos + + // G Maps delta phi as function of deltaphi, centrality, pt + THnSparseF *fDeltaPhiMaps; //! Delta phi + THnSparseF *fDeltaPhiMapsContamination; //! Delta phi for contamination substraction + // H Maps cos phi : cos, centrality, pt + THnSparseF *fCosPhiMaps; //! Cos + TProfile2D *fProfileCosPhiMaps; //! Profile Cos + + // Background study: not statistic but tagged + THnSparseF *fDeltaPhiMapsTaggedPhotonic; //! Delta phi + //THnSparseF *fCosPhiMapsTaggedPhotonic; //! Cos + THnSparseF *fDeltaPhiMapsTaggedNonPhotonic; //! Delta phi + //THnSparseF *fCosPhiMapsTaggedNonPhotonic; //! Cos + THnSparseF *fDeltaPhiMapsTaggedPhotonicLS; //! Delta phi + //THnSparseF *fCosPhiMapsTaggedPhotonicLS; //! Cos + + // Background study: centrality, pt, source + THnSparseF *fMCSourceDeltaPhiMaps; //! Source MC + // Background study: deltaphi, centrality, pt, minv, source + THnSparseF *fOppSignDeltaPhiMaps; //! Delta phi + THnSparseF *fSameSignDeltaPhiMaps; //! Delta phi + // Background study: angle, centrality, source + THnSparseF *fOppSignAngle; // ! Opening Angles + THnSparseF *fSameSignAngle; // ! Opening Angles + + TTreeSRedirector *fDebugStreamer; //!Debug streamer + + Int_t FindMother(Int_t tr, AliMCEvent *mcEvent, Int_t &indexmother); + Int_t CheckPdg(Int_t tr, AliMCEvent* mcEvent); + Int_t IsMotherGamma(Int_t tr, AliMCEvent* mcEvent); + Int_t IsMotherPi0(Int_t tr, AliMCEvent* mcEvent); + Int_t IsMotherC(Int_t tr, AliMCEvent* mcEvent); + Int_t IsMotherB(Int_t tr, AliMCEvent* mcEvent); + Int_t IsMotherEta(Int_t tr, AliMCEvent* mcEvent); + + + ClassDef(AliAnalysisTaskFlowTPCTOFEPSP, 1); // analysisclass +}; + +#endif diff --git a/PWGHF/hfe/AliAnalysisTaskHFEQA.cxx b/PWGHF/hfe/AliAnalysisTaskHFEQA.cxx index 87205e00ee9..5b126dfc829 100644 --- a/PWGHF/hfe/AliAnalysisTaskHFEQA.cxx +++ b/PWGHF/hfe/AliAnalysisTaskHFEQA.cxx @@ -1,644 +1,644 @@ -/************************************************************************** -* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ -// -// QA task -// -// Authors: -// Raphaelle Bailhache -// -#include "TROOT.h" -#include "TChain.h" -#include "TMath.h" -#include -#include -#include - -#include -#include - -#include "AliVEventHandler.h" -#include "AliMCEventHandler.h" -#include "AliAnalysisTaskSE.h" -#include "AliAnalysisManager.h" - -#include "AliVEvent.h" -#include "AliESDInputHandler.h" -#include "AliMCEvent.h" -#include "AliESD.h" -#include "AliESDEvent.h" -#include "AliPID.h" -#include "AliPIDResponse.h" -#include "AliESDUtils.h" -#include "AliMCParticle.h" -#include "AliAODMCParticle.h" -#include "AliAODEvent.h" -#include "AliAODVertex.h" -#include "AliAODTrack.h" -#include "AliVTrack.h" -#include "AliESDtrack.h" -#include "AliESDtrackCuts.h" -#include "AliAODTrack.h" -#include "AliStack.h" -#include "AliMCEvent.h" - -#include "AliHFEcuts.h" -#include "AliHFEpid.h" -#include "AliHFEpidQAmanager.h" -#include "AliHFEtools.h" - -#include "AliCentrality.h" -#include "AliEventplane.h" -#include "AliAnalysisTaskHFEQA.h" -#include "AliAODMCHeader.h" - - -ClassImp(AliAnalysisTaskHFEQA) - -//____________________________________________________________________ -AliAnalysisTaskHFEQA::AliAnalysisTaskHFEQA() : - AliAnalysisTaskSE(), - fListHist(0x0), - fAODAnalysis(kFALSE), - fAODMCHeader(NULL), - fAODArrayMCInfo(NULL), - fHFECuts(0), - fPIDTPConly(0), - fPIDTRDonly(0), - fPIDTOFTPC(0), - fPIDTPCTRD(0), - fPIDTPCEMCal(0), - fPIDqaTRDonly(0), - fPIDqaTOFTPC(0), - fPIDqaTPCTRD(0), - fPIDqaTPCEMCal(0), - fCentralityEstimator("V0M"), - fCollisionSystem(3), - fNbEvent(0), - fTPConly(0), - fTOFTPC(0), - fTPCTRD(0), - fTPCEMCal(0), - fTPConlydo(kFALSE), - fTRDonlydo(kFALSE), - fTOFTPCdo(kFALSE), - fTPCTRDdo(kFALSE), - fTPCEMCaldo(kFALSE) -{ - // Constructor - -} -//______________________________________________________________________________ -AliAnalysisTaskHFEQA:: AliAnalysisTaskHFEQA(const char *name) : - AliAnalysisTaskSE(name), - fListHist(0x0), - fAODAnalysis(kFALSE), - fAODMCHeader(NULL), - fAODArrayMCInfo(NULL), - fHFECuts(0), - fPIDTPConly(0), - fPIDTRDonly(0), - fPIDTOFTPC(0), - fPIDTPCTRD(0), - fPIDTPCEMCal(0), - fPIDqaTRDonly(0), - fPIDqaTOFTPC(0), - fPIDqaTPCTRD(0), - fPIDqaTPCEMCal(0), - fCentralityEstimator("V0M"), - fCollisionSystem(3), - fNbEvent(0), - fTPConly(0), - fTOFTPC(0), - fTPCTRD(0), - fTPCEMCal(0), - fTPConlydo(kFALSE), - fTRDonlydo(kFALSE), - fTOFTPCdo(kFALSE), - fTPCTRDdo(kFALSE), - fTPCEMCaldo(kFALSE) -{ - // - // named ctor - // - - fPIDTPConly = new AliHFEpid("hfePidTPConly"); - fPIDTRDonly = new AliHFEpid("hfePidTRDonly"); - fPIDTOFTPC = new AliHFEpid("hfePidTOFTPC"); - fPIDTPCTRD = new AliHFEpid("hfePidTPCTRD"); - fPIDTPCEMCal = new AliHFEpid("hfePidTPCEMCal"); - - fPIDqaTRDonly = new AliHFEpidQAmanager; - fPIDqaTOFTPC = new AliHFEpidQAmanager; - fPIDqaTPCTRD = new AliHFEpidQAmanager; - fPIDqaTPCEMCal = new AliHFEpidQAmanager; - - SetPbPbAnalysis(); - - DefineInput(0,TChain::Class()); - DefineOutput(1, TList::Class()); - -} -//____________________________________________________________ -AliAnalysisTaskHFEQA::AliAnalysisTaskHFEQA(const AliAnalysisTaskHFEQA &ref): - AliAnalysisTaskSE(ref), - fListHist(NULL), - fAODAnalysis(ref.fAODAnalysis), - fAODMCHeader(ref.fAODMCHeader), - fAODArrayMCInfo(ref.fAODArrayMCInfo), - fHFECuts(NULL), - fPIDTPConly(0), - fPIDTRDonly(0), - fPIDTOFTPC(0), - fPIDTPCTRD(0), - fPIDTPCEMCal(0), - fPIDqaTRDonly(0), - fPIDqaTOFTPC(0), - fPIDqaTPCTRD(0), - fPIDqaTPCEMCal(0), - fCentralityEstimator(ref.fCentralityEstimator), - fCollisionSystem(ref.fCollisionSystem), - fNbEvent(ref.fNbEvent), - fTPConly(ref.fTPConly), - fTOFTPC(ref.fTOFTPC), - fTPCTRD(ref.fTPCTRD), - fTPCEMCal(ref.fTPCEMCal), - fTPConlydo(ref.fTPConlydo), - fTRDonlydo(ref.fTRDonlydo), - fTOFTPCdo(ref.fTOFTPCdo), - fTPCTRDdo(ref.fTPCTRDdo), - fTPCEMCaldo(ref.fTPCEMCaldo) -{ - // - // Copy Constructor - // - - ref.Copy(*this); -} - -//____________________________________________________________ -AliAnalysisTaskHFEQA &AliAnalysisTaskHFEQA::operator=(const AliAnalysisTaskHFEQA &ref){ - // - // Assignment operator - // - if(this == &ref) - ref.Copy(*this); - return *this; -} - -//____________________________________________________________ -void AliAnalysisTaskHFEQA::Copy(TObject &o) const { - // - // Copy into object o - // - AliAnalysisTaskHFEQA &target = dynamic_cast(o); - target.fListHist = fListHist; - target.fAODAnalysis = fAODAnalysis; - target.fAODMCHeader = fAODMCHeader; - target.fAODArrayMCInfo = fAODArrayMCInfo; - target.fHFECuts = fHFECuts; - target.fPIDTPConly = fPIDTPConly; - target.fPIDTRDonly = fPIDTRDonly; - target.fPIDTOFTPC = fPIDTOFTPC; - target.fPIDTPCTRD = fPIDTPCTRD; - target.fPIDTPCEMCal = fPIDTPCEMCal; - target.fPIDqaTRDonly = fPIDqaTRDonly; - target.fPIDqaTOFTPC = fPIDqaTOFTPC; - target.fPIDqaTPCTRD = fPIDqaTPCTRD; - target.fPIDqaTPCEMCal = fPIDqaTPCEMCal; - target.fCentralityEstimator = fCentralityEstimator; - target.fCollisionSystem = fCollisionSystem; - target.fNbEvent = fNbEvent; - target.fTPConly = fTPConly; - target.fTOFTPC = fTOFTPC; - target.fTPCTRD = fTPCTRD; - target.fTPCEMCal = fTPCEMCal; - target.fTPConlydo = fTPConlydo; - target.fTRDonlydo = fTRDonlydo; - target.fTOFTPCdo = fTOFTPCdo; - target.fTPCTRDdo = fTPCTRDdo; - target.fTPCEMCaldo = fTPCEMCaldo; - - -} -//____________________________________________________________ -AliAnalysisTaskHFEQA::~AliAnalysisTaskHFEQA(){ - // - // Destructor - // - - - if(fListHist) delete fListHist; - if(fHFECuts) delete fHFECuts; - if(fPIDTPConly) delete fPIDTPConly; - if(fPIDTRDonly) delete fPIDTRDonly; - if(fPIDTOFTPC) delete fPIDTOFTPC; - if(fPIDTPCTRD) delete fPIDTPCTRD; - if(fPIDTPCEMCal) delete fPIDTPCEMCal; - - -} -//________________________________________________________________________ -void AliAnalysisTaskHFEQA::UserCreateOutputObjects() -{ - - //******************** - // Create histograms - //******************** - AliDebug(2,"AliAnalysisTaskHFEQA: User create output objects"); - - - // AOD or ESD - AliVEventHandler *inputHandler = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); - if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){ - SetAODAnalysis(kTRUE); - AliDebug(2,"Put AOD analysis on"); - } else { - SetAODAnalysis(kFALSE); - } - - AliDebug(2,"AliAnalysisTaskHFEQA: AOD ESD"); - - // HFE cuts - - if(!fHFECuts){ - fHFECuts = new AliHFEcuts; - fHFECuts->CreateStandardCuts(); - } - fHFECuts->Initialize(); - if(fAODAnalysis) { - fHFECuts->SetAOD(); - } - - AliDebug(2,"AliAnalysisTaskHFEQA: HFE cuts"); - - - // PIDTPConly HFE - if(!fPIDTPConly) { - fPIDTPConly =new AliHFEpid("hfePidTPConly"); - } - if(!fPIDTPConly->GetNumberOfPIDdetectors()) fPIDTPConly->AddDetector("TPC", 0); - fPIDTPConly->InitializePID(); - fPIDTPConly->SortDetectors(); - - // PIDTRDonly HFE - if(!fPIDTRDonly) { - fPIDTRDonly =new AliHFEpid("hfePidTRDonly"); - } - if(!fPIDTRDonly->GetNumberOfPIDdetectors()) fPIDTRDonly->AddDetector("TRD", 0); - fPIDTRDonly->InitializePID(); - fPIDqaTRDonly->Initialize(fPIDTRDonly); - fPIDTRDonly->SortDetectors(); - - // PIDTOFTPC HFE - if(!fPIDTOFTPC) { - fPIDTOFTPC =new AliHFEpid("hfePidTOFTPC"); - } - if(!fPIDTOFTPC->GetNumberOfPIDdetectors()) { - fPIDTOFTPC->AddDetector("TOF", 0); - fPIDTOFTPC->AddDetector("TPC", 1); - } - fPIDTOFTPC->InitializePID(); - fPIDqaTOFTPC->Initialize(fPIDTOFTPC); - fPIDTOFTPC->SortDetectors(); - - - // PIDTPCTRD HFE - if(!fPIDTPCTRD) { - fPIDTPCTRD =new AliHFEpid("hfePidTPCTRD"); - } - if(!fPIDTPCTRD->GetNumberOfPIDdetectors()) { - fPIDTPCTRD->AddDetector("TPC", 0); - fPIDTPCTRD->AddDetector("TRD", 1); - } - fPIDTPCTRD->InitializePID(); - fPIDqaTPCTRD->Initialize(fPIDTPCTRD); - fPIDTPCTRD->SortDetectors(); - - // PIDTPCEMCal HFE - if(!fPIDTPCEMCal) { - fPIDTPCEMCal =new AliHFEpid("hfePidTPCEMCal"); - } - if(!fPIDTPCEMCal->GetNumberOfPIDdetectors()) { - fPIDTPCEMCal->AddDetector("TPC", 0); - fPIDTPCEMCal->AddDetector("EMCal", 1); - } - fPIDTPCEMCal->InitializePID(); - fPIDqaTPCEMCal->Initialize(fPIDTPCEMCal); - fPIDTPCEMCal->SortDetectors(); - - // Histograms - fNbEvent = new TH1F("NbEvent", "",11,0,11); - fNbEvent->Sumw2(); - Double_t ptbinning[36] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5., 5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.}; - fTPConly = new TH1F("TPCOnly", "",35,&ptbinning[0]); - fTPConly->Sumw2(); - fTOFTPC = new TH1F("TOFTPC", "",35,&ptbinning[0]); - fTOFTPC->Sumw2(); - fTPCTRD = new TH1F("TPCTRD", "",35,&ptbinning[0]); - fTPCTRD->Sumw2(); - fTPCEMCal = new TH1F("TPCEMCal", "",35,&ptbinning[0]); - fTPCEMCal->Sumw2(); - - - // List - - fListHist = new TList(); - fListHist->SetOwner(); - - fListHist->Add(fPIDqaTRDonly->MakeList("HFEpidQATRDonly")); - fListHist->Add(fPIDqaTOFTPC->MakeList("HFEpidQATOFTPC")); - fListHist->Add(fPIDqaTPCTRD->MakeList("HFEpidQATPCTRD")); - fListHist->Add(fPIDqaTPCEMCal->MakeList("HFEpidQATPCEMCal")); - - fListHist->Add(fNbEvent); - fListHist->Add(fTPConly); - fListHist->Add(fTOFTPC); - fListHist->Add(fTPCTRD); - fListHist->Add(fTPCEMCal); - - AliDebug(2,"AliAnalysisTaskHFEQA: list"); - - - fListHist->Print(); - - PostData(1, fListHist); - - AliDebug(2,"AliAnalysisTaskHFEQA: post"); - - -} - -//________________________________________________________________________ -void AliAnalysisTaskHFEQA::UserExec(Option_t */*option*/) -{ - // - // Loop over event - // - - Double_t binct = 11.5; - - AliMCEvent *mcEvent = MCEvent(); - - - AliDebug(2,"MC info"); - // MC info - Bool_t mcthere = kTRUE; - if(fAODAnalysis) { - AliAODEvent *aodE = dynamic_cast(fInputEvent); - if(!aodE){ - AliError("No AOD Event"); - return; - } - fAODMCHeader = dynamic_cast(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName())); - if(!fAODMCHeader){ - mcthere = kFALSE; - } - fAODArrayMCInfo = dynamic_cast(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); - if(!fAODArrayMCInfo){ - mcthere = kFALSE; - } - else { - fHFECuts->SetMCEvent(aodE); - } - } - else { - AliMCEventHandler *mcH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); - if(!mcH){ - mcthere=kFALSE; - } - if(mcEvent) fHFECuts->SetMCEvent(mcEvent); - } - - - //////////////////////////////////// - // Number of contributors - /////////////////////////////////// - AliDebug(2,"Number of contributors"); - Int_t ncontribVtx = 0; - if(fAODAnalysis) { - AliAODEvent *fAOD = dynamic_cast(fInputEvent); - if(!fAOD){ - AliError("AOD Event required for AOD Analysis"); - return; - } - AliAODVertex *priVtx = fAOD->GetPrimaryVertex(); - if(priVtx){ - ncontribVtx = priVtx->GetNContributors(); - } - } - else { - AliESDEvent *fESD = dynamic_cast(fInputEvent); - if(!fESD){ - AliError("ESD Event required for ESD Analysis"); - return; - } - const AliESDVertex *priVtx = fESD->GetPrimaryVertexTracks(); - if(priVtx){ - ncontribVtx = priVtx->GetNContributors(); - } - } - AliDebug(2,Form("Number of contributors %d",ncontribVtx)); - - - ///////////////////////////////// - // centrality - //////////////////////////////// - - //printf("Centrality \n"); - AliCentrality *centrality = fInputEvent->GetCentrality(); - AliDebug(2,"Got the centrality"); - Float_t cntr = 0.; - if(centrality && (! Ispp())) { - cntr = centrality->GetCentralityPercentile(fCentralityEstimator.Data()); - if((0.0< cntr) && (cntr<5.0)) binct = 0.5; - if((5.0< cntr) && (cntr<10.0)) binct = 1.5; - if((10.0< cntr) && (cntr<20.0)) binct = 2.5; - if((20.0< cntr) && (cntr<30.0)) binct = 3.5; - if((30.0< cntr) && (cntr<40.0)) binct = 4.5; - if((40.0< cntr) && (cntr<50.0)) binct = 5.5; - if((50.0< cntr) && (cntr<60.0)) binct = 6.5; - if((60.0< cntr) && (cntr<70.0)) binct = 7.5; - if((70.0< cntr) && (cntr<80.0)) binct = 8.5; - if((80.0< cntr) && (cntr<90.0)) binct = 9.5; - if((90.0< cntr) && (cntr<100.0)) binct = 10.5; - if(binct > 11.0) return; - } - else binct = 0.5; - AliDebug(2,Form("Centrality %f with %s",binct,fCentralityEstimator.Data())); - - ////////////////////// - // run number - ////////////////////// - - Int_t runnumber = fInputEvent->GetRunNumber(); - AliDebug(2,Form("Run number %d",runnumber)); - - if(!fPIDTPConly->IsInitialized()){ - fPIDTPConly->InitializePID(runnumber); - } - if(!fPIDTRDonly->IsInitialized()){ - fPIDTRDonly->InitializePID(runnumber); - } - if(!fPIDTOFTPC->IsInitialized()){ - fPIDTOFTPC->InitializePID(runnumber); - } - if(!fPIDTPCTRD->IsInitialized()){ - fPIDTPCTRD->InitializePID(runnumber); - } - if(!fPIDTPCEMCal->IsInitialized()){ - fPIDTPCEMCal->InitializePID(runnumber); - } - - // - fHFECuts->SetRecEvent(fInputEvent); - - - - ////////// - // PID - ////////// - AliDebug(2,"PID response"); - AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse(); - if(!pidResponse){ - AliDebug(2,"No PID response set"); - return; - } - fPIDTPConly->SetPIDResponse(pidResponse); - fPIDTRDonly->SetPIDResponse(pidResponse); - fPIDTOFTPC->SetPIDResponse(pidResponse); - fPIDTPCTRD->SetPIDResponse(pidResponse); - fPIDTPCEMCal->SetPIDResponse(pidResponse); - - ////////////////// - // Event cut - ////////////////// - AliDebug(2,"Event cut"); - if(!fHFECuts->CheckEventCuts("fEvRecCuts", fInputEvent)) { - AliDebug(2,"Does not pass the event cut"); - PostData(1, fListHist); - return; - } - fNbEvent->Fill(binct); - - ////////////////////////// - // Loop over track - ////////////////////////// - Int_t nbtracks = fInputEvent->GetNumberOfTracks(); - AliDebug(2,Form("Number of tracks %d",nbtracks)); - for(Int_t k = 0; k < nbtracks; k++){ - - AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); - if(!track) continue; - Double_t pt = track->Pt(); - - AliDebug(2,"test 0\n"); - - // RecKine: ITSTPC cuts - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - AliDebug(2,"test 1\n"); - - // RecPrim - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - AliDebug(2,"test 2\n"); - - // HFEcuts: ITS layers cuts - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - AliDebug(2,"test 3\n"); - - // HFE cuts: TOF and mismatch flag - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTOF + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - AliDebug(2,"test 4\n"); - - // HFE cuts: TPC PID cleanup - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - AliDebug(2,"test 5\n"); - - // HFEcuts: Nb of tracklets TRD0 - if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; - - AliDebug(2,"Survived"); - - - //////////////////////// - // Apply PID - //////////////////////// - AliHFEpidObject hfetrack; - if(!fAODAnalysis) hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); - else hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis); - hfetrack.SetRecTrack(track); - hfetrack.SetCentrality((Int_t)binct); - hfetrack.SetMulitplicity(ncontribVtx); // for correction - if(IsPbPb()) hfetrack.SetPbPb(); - else{ - if(IspPb()) hfetrack.SetpPb(); - else { - hfetrack.SetPP(); - //printf("pp\n"); - } - } - AliDebug(2,Form("centrality %f and %d",binct,hfetrack.GetCentrality())); - - //printf("test 7\n"); - - // Complete PID TPC alone - if(fTPConlydo) { - if(fPIDTPConly->IsSelected(&hfetrack,0x0,"recTrackCont",0x0)) { - fTPConly->Fill(pt); - } - } - AliDebug(2,"TPC only PID\n"); - - // Complete PID TRD alone - if(fTRDonlydo) { - if(fPIDTRDonly->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTRDonly)) { - AliDebug(2,"Passed TRD only PID\n"); - } - } - AliDebug(2,"TRD only PID\n"); - - - // Complete PID TPC TOF - if(fTOFTPCdo) { - if(fPIDTOFTPC->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTOFTPC)) { - fTOFTPC->Fill(pt); - } - } - AliDebug(2,"TOF TPC PID\n"); - - // Complete PID TPC TRD - if(fTPCTRDdo) { - if(fPIDTPCTRD->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTPCTRD)) { - fTPCTRD->Fill(pt); - } - } - AliDebug(2,"TPC TRD PID\n"); - - - if(fTPCEMCaldo) { - if(!fAODAnalysis) { - // Complete PID TPC TRD - if(fPIDTPCEMCal->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTPCEMCal)) { - fTPCEMCal->Fill(pt); - } - } - } - AliDebug(2,"TPC EMCal PID\n"); - - - } - - PostData(1, fListHist); - -} +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ +// +// QA task +// +// Authors: +// Raphaelle Bailhache +// +#include "TROOT.h" +#include "TChain.h" +#include "TMath.h" +#include +#include +#include + +#include +#include + +#include "AliVEventHandler.h" +#include "AliMCEventHandler.h" +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" + +#include "AliVEvent.h" +#include "AliESDInputHandler.h" +#include "AliMCEvent.h" +#include "AliESD.h" +#include "AliESDEvent.h" +#include "AliPID.h" +#include "AliPIDResponse.h" +#include "AliESDUtils.h" +#include "AliMCParticle.h" +#include "AliAODMCParticle.h" +#include "AliAODEvent.h" +#include "AliAODVertex.h" +#include "AliAODTrack.h" +#include "AliVTrack.h" +#include "AliESDtrack.h" +#include "AliESDtrackCuts.h" +#include "AliAODTrack.h" +#include "AliStack.h" +#include "AliMCEvent.h" + +#include "AliHFEcuts.h" +#include "AliHFEpid.h" +#include "AliHFEpidQAmanager.h" +#include "AliHFEtools.h" + +#include "AliCentrality.h" +#include "AliEventplane.h" +#include "AliAnalysisTaskHFEQA.h" +#include "AliAODMCHeader.h" + + +ClassImp(AliAnalysisTaskHFEQA) + +//____________________________________________________________________ +AliAnalysisTaskHFEQA::AliAnalysisTaskHFEQA() : + AliAnalysisTaskSE(), + fListHist(0x0), + fAODAnalysis(kFALSE), + fAODMCHeader(NULL), + fAODArrayMCInfo(NULL), + fHFECuts(0), + fPIDTPConly(0), + fPIDTRDonly(0), + fPIDTOFTPC(0), + fPIDTPCTRD(0), + fPIDTPCEMCal(0), + fPIDqaTRDonly(0), + fPIDqaTOFTPC(0), + fPIDqaTPCTRD(0), + fPIDqaTPCEMCal(0), + fCentralityEstimator("V0M"), + fCollisionSystem(3), + fNbEvent(0), + fTPConly(0), + fTOFTPC(0), + fTPCTRD(0), + fTPCEMCal(0), + fTPConlydo(kFALSE), + fTRDonlydo(kFALSE), + fTOFTPCdo(kFALSE), + fTPCTRDdo(kFALSE), + fTPCEMCaldo(kFALSE) +{ + // Constructor + +} +//______________________________________________________________________________ +AliAnalysisTaskHFEQA:: AliAnalysisTaskHFEQA(const char *name) : + AliAnalysisTaskSE(name), + fListHist(0x0), + fAODAnalysis(kFALSE), + fAODMCHeader(NULL), + fAODArrayMCInfo(NULL), + fHFECuts(0), + fPIDTPConly(0), + fPIDTRDonly(0), + fPIDTOFTPC(0), + fPIDTPCTRD(0), + fPIDTPCEMCal(0), + fPIDqaTRDonly(0), + fPIDqaTOFTPC(0), + fPIDqaTPCTRD(0), + fPIDqaTPCEMCal(0), + fCentralityEstimator("V0M"), + fCollisionSystem(3), + fNbEvent(0), + fTPConly(0), + fTOFTPC(0), + fTPCTRD(0), + fTPCEMCal(0), + fTPConlydo(kFALSE), + fTRDonlydo(kFALSE), + fTOFTPCdo(kFALSE), + fTPCTRDdo(kFALSE), + fTPCEMCaldo(kFALSE) +{ + // + // named ctor + // + + fPIDTPConly = new AliHFEpid("hfePidTPConly"); + fPIDTRDonly = new AliHFEpid("hfePidTRDonly"); + fPIDTOFTPC = new AliHFEpid("hfePidTOFTPC"); + fPIDTPCTRD = new AliHFEpid("hfePidTPCTRD"); + fPIDTPCEMCal = new AliHFEpid("hfePidTPCEMCal"); + + fPIDqaTRDonly = new AliHFEpidQAmanager; + fPIDqaTOFTPC = new AliHFEpidQAmanager; + fPIDqaTPCTRD = new AliHFEpidQAmanager; + fPIDqaTPCEMCal = new AliHFEpidQAmanager; + + SetPbPbAnalysis(); + + DefineInput(0,TChain::Class()); + DefineOutput(1, TList::Class()); + +} +//____________________________________________________________ +AliAnalysisTaskHFEQA::AliAnalysisTaskHFEQA(const AliAnalysisTaskHFEQA &ref): + AliAnalysisTaskSE(ref), + fListHist(NULL), + fAODAnalysis(ref.fAODAnalysis), + fAODMCHeader(ref.fAODMCHeader), + fAODArrayMCInfo(ref.fAODArrayMCInfo), + fHFECuts(NULL), + fPIDTPConly(0), + fPIDTRDonly(0), + fPIDTOFTPC(0), + fPIDTPCTRD(0), + fPIDTPCEMCal(0), + fPIDqaTRDonly(0), + fPIDqaTOFTPC(0), + fPIDqaTPCTRD(0), + fPIDqaTPCEMCal(0), + fCentralityEstimator(ref.fCentralityEstimator), + fCollisionSystem(ref.fCollisionSystem), + fNbEvent(ref.fNbEvent), + fTPConly(ref.fTPConly), + fTOFTPC(ref.fTOFTPC), + fTPCTRD(ref.fTPCTRD), + fTPCEMCal(ref.fTPCEMCal), + fTPConlydo(ref.fTPConlydo), + fTRDonlydo(ref.fTRDonlydo), + fTOFTPCdo(ref.fTOFTPCdo), + fTPCTRDdo(ref.fTPCTRDdo), + fTPCEMCaldo(ref.fTPCEMCaldo) +{ + // + // Copy Constructor + // + + ref.Copy(*this); +} + +//____________________________________________________________ +AliAnalysisTaskHFEQA &AliAnalysisTaskHFEQA::operator=(const AliAnalysisTaskHFEQA &ref){ + // + // Assignment operator + // + if(this == &ref) + ref.Copy(*this); + return *this; +} + +//____________________________________________________________ +void AliAnalysisTaskHFEQA::Copy(TObject &o) const { + // + // Copy into object o + // + AliAnalysisTaskHFEQA &target = dynamic_cast(o); + target.fListHist = fListHist; + target.fAODAnalysis = fAODAnalysis; + target.fAODMCHeader = fAODMCHeader; + target.fAODArrayMCInfo = fAODArrayMCInfo; + target.fHFECuts = fHFECuts; + target.fPIDTPConly = fPIDTPConly; + target.fPIDTRDonly = fPIDTRDonly; + target.fPIDTOFTPC = fPIDTOFTPC; + target.fPIDTPCTRD = fPIDTPCTRD; + target.fPIDTPCEMCal = fPIDTPCEMCal; + target.fPIDqaTRDonly = fPIDqaTRDonly; + target.fPIDqaTOFTPC = fPIDqaTOFTPC; + target.fPIDqaTPCTRD = fPIDqaTPCTRD; + target.fPIDqaTPCEMCal = fPIDqaTPCEMCal; + target.fCentralityEstimator = fCentralityEstimator; + target.fCollisionSystem = fCollisionSystem; + target.fNbEvent = fNbEvent; + target.fTPConly = fTPConly; + target.fTOFTPC = fTOFTPC; + target.fTPCTRD = fTPCTRD; + target.fTPCEMCal = fTPCEMCal; + target.fTPConlydo = fTPConlydo; + target.fTRDonlydo = fTRDonlydo; + target.fTOFTPCdo = fTOFTPCdo; + target.fTPCTRDdo = fTPCTRDdo; + target.fTPCEMCaldo = fTPCEMCaldo; + + +} +//____________________________________________________________ +AliAnalysisTaskHFEQA::~AliAnalysisTaskHFEQA(){ + // + // Destructor + // + + + if(fListHist) delete fListHist; + if(fHFECuts) delete fHFECuts; + if(fPIDTPConly) delete fPIDTPConly; + if(fPIDTRDonly) delete fPIDTRDonly; + if(fPIDTOFTPC) delete fPIDTOFTPC; + if(fPIDTPCTRD) delete fPIDTPCTRD; + if(fPIDTPCEMCal) delete fPIDTPCEMCal; + + +} +//________________________________________________________________________ +void AliAnalysisTaskHFEQA::UserCreateOutputObjects() +{ + + //******************** + // Create histograms + //******************** + AliDebug(2,"AliAnalysisTaskHFEQA: User create output objects"); + + + // AOD or ESD + AliVEventHandler *inputHandler = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){ + SetAODAnalysis(kTRUE); + AliDebug(2,"Put AOD analysis on"); + } else { + SetAODAnalysis(kFALSE); + } + + AliDebug(2,"AliAnalysisTaskHFEQA: AOD ESD"); + + // HFE cuts + + if(!fHFECuts){ + fHFECuts = new AliHFEcuts; + fHFECuts->CreateStandardCuts(); + } + fHFECuts->Initialize(); + if(fAODAnalysis) { + fHFECuts->SetAOD(); + } + + AliDebug(2,"AliAnalysisTaskHFEQA: HFE cuts"); + + + // PIDTPConly HFE + if(!fPIDTPConly) { + fPIDTPConly =new AliHFEpid("hfePidTPConly"); + } + if(!fPIDTPConly->GetNumberOfPIDdetectors()) fPIDTPConly->AddDetector("TPC", 0); + fPIDTPConly->InitializePID(); + fPIDTPConly->SortDetectors(); + + // PIDTRDonly HFE + if(!fPIDTRDonly) { + fPIDTRDonly =new AliHFEpid("hfePidTRDonly"); + } + if(!fPIDTRDonly->GetNumberOfPIDdetectors()) fPIDTRDonly->AddDetector("TRD", 0); + fPIDTRDonly->InitializePID(); + fPIDqaTRDonly->Initialize(fPIDTRDonly); + fPIDTRDonly->SortDetectors(); + + // PIDTOFTPC HFE + if(!fPIDTOFTPC) { + fPIDTOFTPC =new AliHFEpid("hfePidTOFTPC"); + } + if(!fPIDTOFTPC->GetNumberOfPIDdetectors()) { + fPIDTOFTPC->AddDetector("TOF", 0); + fPIDTOFTPC->AddDetector("TPC", 1); + } + fPIDTOFTPC->InitializePID(); + fPIDqaTOFTPC->Initialize(fPIDTOFTPC); + fPIDTOFTPC->SortDetectors(); + + + // PIDTPCTRD HFE + if(!fPIDTPCTRD) { + fPIDTPCTRD =new AliHFEpid("hfePidTPCTRD"); + } + if(!fPIDTPCTRD->GetNumberOfPIDdetectors()) { + fPIDTPCTRD->AddDetector("TPC", 0); + fPIDTPCTRD->AddDetector("TRD", 1); + } + fPIDTPCTRD->InitializePID(); + fPIDqaTPCTRD->Initialize(fPIDTPCTRD); + fPIDTPCTRD->SortDetectors(); + + // PIDTPCEMCal HFE + if(!fPIDTPCEMCal) { + fPIDTPCEMCal =new AliHFEpid("hfePidTPCEMCal"); + } + if(!fPIDTPCEMCal->GetNumberOfPIDdetectors()) { + fPIDTPCEMCal->AddDetector("TPC", 0); + fPIDTPCEMCal->AddDetector("EMCal", 1); + } + fPIDTPCEMCal->InitializePID(); + fPIDqaTPCEMCal->Initialize(fPIDTPCEMCal); + fPIDTPCEMCal->SortDetectors(); + + // Histograms + fNbEvent = new TH1F("NbEvent", "",11,0,11); + fNbEvent->Sumw2(); + Double_t ptbinning[36] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5., 5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.}; + fTPConly = new TH1F("TPCOnly", "",35,&ptbinning[0]); + fTPConly->Sumw2(); + fTOFTPC = new TH1F("TOFTPC", "",35,&ptbinning[0]); + fTOFTPC->Sumw2(); + fTPCTRD = new TH1F("TPCTRD", "",35,&ptbinning[0]); + fTPCTRD->Sumw2(); + fTPCEMCal = new TH1F("TPCEMCal", "",35,&ptbinning[0]); + fTPCEMCal->Sumw2(); + + + // List + + fListHist = new TList(); + fListHist->SetOwner(); + + fListHist->Add(fPIDqaTRDonly->MakeList("HFEpidQATRDonly")); + fListHist->Add(fPIDqaTOFTPC->MakeList("HFEpidQATOFTPC")); + fListHist->Add(fPIDqaTPCTRD->MakeList("HFEpidQATPCTRD")); + fListHist->Add(fPIDqaTPCEMCal->MakeList("HFEpidQATPCEMCal")); + + fListHist->Add(fNbEvent); + fListHist->Add(fTPConly); + fListHist->Add(fTOFTPC); + fListHist->Add(fTPCTRD); + fListHist->Add(fTPCEMCal); + + AliDebug(2,"AliAnalysisTaskHFEQA: list"); + + + fListHist->Print(); + + PostData(1, fListHist); + + AliDebug(2,"AliAnalysisTaskHFEQA: post"); + + +} + +//________________________________________________________________________ +void AliAnalysisTaskHFEQA::UserExec(Option_t */*option*/) +{ + // + // Loop over event + // + + Double_t binct = 11.5; + + AliMCEvent *mcEvent = MCEvent(); + + + AliDebug(2,"MC info"); + // MC info + Bool_t mcthere = kTRUE; + if(fAODAnalysis) { + AliAODEvent *aodE = dynamic_cast(fInputEvent); + if(!aodE){ + AliError("No AOD Event"); + return; + } + fAODMCHeader = dynamic_cast(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName())); + if(!fAODMCHeader){ + mcthere = kFALSE; + } + fAODArrayMCInfo = dynamic_cast(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); + if(!fAODArrayMCInfo){ + mcthere = kFALSE; + } + else { + fHFECuts->SetMCEvent(aodE); + } + } + else { + AliMCEventHandler *mcH = dynamic_cast(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); + if(!mcH){ + mcthere=kFALSE; + } + if(mcEvent) fHFECuts->SetMCEvent(mcEvent); + } + + + //////////////////////////////////// + // Number of contributors + /////////////////////////////////// + AliDebug(2,"Number of contributors"); + Int_t ncontribVtx = 0; + if(fAODAnalysis) { + AliAODEvent *fAOD = dynamic_cast(fInputEvent); + if(!fAOD){ + AliError("AOD Event required for AOD Analysis"); + return; + } + AliAODVertex *priVtx = fAOD->GetPrimaryVertex(); + if(priVtx){ + ncontribVtx = priVtx->GetNContributors(); + } + } + else { + AliESDEvent *fESD = dynamic_cast(fInputEvent); + if(!fESD){ + AliError("ESD Event required for ESD Analysis"); + return; + } + const AliESDVertex *priVtx = fESD->GetPrimaryVertexTracks(); + if(priVtx){ + ncontribVtx = priVtx->GetNContributors(); + } + } + AliDebug(2,Form("Number of contributors %d",ncontribVtx)); + + + ///////////////////////////////// + // centrality + //////////////////////////////// + + //printf("Centrality \n"); + AliCentrality *centrality = fInputEvent->GetCentrality(); + AliDebug(2,"Got the centrality"); + Float_t cntr = 0.; + if(centrality && (! Ispp())) { + cntr = centrality->GetCentralityPercentile(fCentralityEstimator.Data()); + if((0.0< cntr) && (cntr<5.0)) binct = 0.5; + if((5.0< cntr) && (cntr<10.0)) binct = 1.5; + if((10.0< cntr) && (cntr<20.0)) binct = 2.5; + if((20.0< cntr) && (cntr<30.0)) binct = 3.5; + if((30.0< cntr) && (cntr<40.0)) binct = 4.5; + if((40.0< cntr) && (cntr<50.0)) binct = 5.5; + if((50.0< cntr) && (cntr<60.0)) binct = 6.5; + if((60.0< cntr) && (cntr<70.0)) binct = 7.5; + if((70.0< cntr) && (cntr<80.0)) binct = 8.5; + if((80.0< cntr) && (cntr<90.0)) binct = 9.5; + if((90.0< cntr) && (cntr<100.0)) binct = 10.5; + if(binct > 11.0) return; + } + else binct = 0.5; + AliDebug(2,Form("Centrality %f with %s",binct,fCentralityEstimator.Data())); + + ////////////////////// + // run number + ////////////////////// + + Int_t runnumber = fInputEvent->GetRunNumber(); + AliDebug(2,Form("Run number %d",runnumber)); + + if(!fPIDTPConly->IsInitialized()){ + fPIDTPConly->InitializePID(runnumber); + } + if(!fPIDTRDonly->IsInitialized()){ + fPIDTRDonly->InitializePID(runnumber); + } + if(!fPIDTOFTPC->IsInitialized()){ + fPIDTOFTPC->InitializePID(runnumber); + } + if(!fPIDTPCTRD->IsInitialized()){ + fPIDTPCTRD->InitializePID(runnumber); + } + if(!fPIDTPCEMCal->IsInitialized()){ + fPIDTPCEMCal->InitializePID(runnumber); + } + + // + fHFECuts->SetRecEvent(fInputEvent); + + + + ////////// + // PID + ////////// + AliDebug(2,"PID response"); + AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse(); + if(!pidResponse){ + AliDebug(2,"No PID response set"); + return; + } + fPIDTPConly->SetPIDResponse(pidResponse); + fPIDTRDonly->SetPIDResponse(pidResponse); + fPIDTOFTPC->SetPIDResponse(pidResponse); + fPIDTPCTRD->SetPIDResponse(pidResponse); + fPIDTPCEMCal->SetPIDResponse(pidResponse); + + ////////////////// + // Event cut + ////////////////// + AliDebug(2,"Event cut"); + if(!fHFECuts->CheckEventCuts("fEvRecCuts", fInputEvent)) { + AliDebug(2,"Does not pass the event cut"); + PostData(1, fListHist); + return; + } + fNbEvent->Fill(binct); + + ////////////////////////// + // Loop over track + ////////////////////////// + Int_t nbtracks = fInputEvent->GetNumberOfTracks(); + AliDebug(2,Form("Number of tracks %d",nbtracks)); + for(Int_t k = 0; k < nbtracks; k++){ + + AliVTrack *track = (AliVTrack *) fInputEvent->GetTrack(k); + if(!track) continue; + Double_t pt = track->Pt(); + + AliDebug(2,"test 0\n"); + + // RecKine: ITSTPC cuts + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + AliDebug(2,"test 1\n"); + + // RecPrim + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + AliDebug(2,"test 2\n"); + + // HFEcuts: ITS layers cuts + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + AliDebug(2,"test 3\n"); + + // HFE cuts: TOF and mismatch flag + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTOF + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + AliDebug(2,"test 4\n"); + + // HFE cuts: TPC PID cleanup + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + AliDebug(2,"test 5\n"); + + // HFEcuts: Nb of tracklets TRD0 + if(!fHFECuts->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)) continue; + + AliDebug(2,"Survived"); + + + //////////////////////// + // Apply PID + //////////////////////// + AliHFEpidObject hfetrack; + if(!fAODAnalysis) hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis); + else hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis); + hfetrack.SetRecTrack(track); + hfetrack.SetCentrality((Int_t)binct); + hfetrack.SetMulitplicity(ncontribVtx); // for correction + if(IsPbPb()) hfetrack.SetPbPb(); + else{ + if(IspPb()) hfetrack.SetpPb(); + else { + hfetrack.SetPP(); + //printf("pp\n"); + } + } + AliDebug(2,Form("centrality %f and %d",binct,hfetrack.GetCentrality())); + + //printf("test 7\n"); + + // Complete PID TPC alone + if(fTPConlydo) { + if(fPIDTPConly->IsSelected(&hfetrack,0x0,"recTrackCont",0x0)) { + fTPConly->Fill(pt); + } + } + AliDebug(2,"TPC only PID\n"); + + // Complete PID TRD alone + if(fTRDonlydo) { + if(fPIDTRDonly->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTRDonly)) { + AliDebug(2,"Passed TRD only PID\n"); + } + } + AliDebug(2,"TRD only PID\n"); + + + // Complete PID TPC TOF + if(fTOFTPCdo) { + if(fPIDTOFTPC->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTOFTPC)) { + fTOFTPC->Fill(pt); + } + } + AliDebug(2,"TOF TPC PID\n"); + + // Complete PID TPC TRD + if(fTPCTRDdo) { + if(fPIDTPCTRD->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTPCTRD)) { + fTPCTRD->Fill(pt); + } + } + AliDebug(2,"TPC TRD PID\n"); + + + if(fTPCEMCaldo) { + if(!fAODAnalysis) { + // Complete PID TPC TRD + if(fPIDTPCEMCal->IsSelected(&hfetrack,0x0,"recTrackCont",fPIDqaTPCEMCal)) { + fTPCEMCal->Fill(pt); + } + } + } + AliDebug(2,"TPC EMCal PID\n"); + + + } + + PostData(1, fListHist); + +} diff --git a/PWGHF/hfe/AliAnalysisTaskHFEQA.h b/PWGHF/hfe/AliAnalysisTaskHFEQA.h index a5aa06885d0..05f3e996ad5 100644 --- a/PWGHF/hfe/AliAnalysisTaskHFEQA.h +++ b/PWGHF/hfe/AliAnalysisTaskHFEQA.h @@ -1,147 +1,147 @@ -/************************************************************************** -* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ -// -// Flow task class for the ALICE HFE group -// -// -#ifndef ALIANALYSISTASKHFEQA_H -#define ALIANALYSISTASKHFEQA_H - - -#ifndef ALIANALYSISTASKSE_H -#include "AliAnalysisTaskSE.h" -#endif - -#ifndef ROOT_TString -#include -#endif - -#ifndef ROOT_TBits -#include -#endif - - -class TList; -class AliHFEcuts; -class AliHFEpid; -class AliHFEpidQAmanager; -class AliAODMCHeader; -class TClonesArray; -class TH1F; - - -class AliAnalysisTaskHFEQA: public AliAnalysisTaskSE { -public: - - typedef enum{ - kpp = 0, - kpPb = 1, - kPbPb = 2 - } ESystem_t; - - - AliAnalysisTaskHFEQA(); - AliAnalysisTaskHFEQA(const char *name); - AliAnalysisTaskHFEQA(const AliAnalysisTaskHFEQA &ref); - AliAnalysisTaskHFEQA& operator=(const AliAnalysisTaskHFEQA &ref); - virtual void Copy(TObject &o) const; - virtual ~AliAnalysisTaskHFEQA(); - - virtual void UserExec(Option_t */*option*/); - virtual void UserCreateOutputObjects(); - - void SetDoTPConly(Bool_t tpconlydo) { fTPConlydo = tpconlydo; }; - void SetDoTRDonly(Bool_t trdonlydo) { fTRDonlydo = trdonlydo; }; - void SetDoTOFTPC(Bool_t toftpcdo) { fTOFTPCdo = toftpcdo; }; - void SetDoTPCTRD(Bool_t tpctrddo) { fTPCTRDdo = tpctrddo; }; - void SetDoTPCEMCal(Bool_t tpcemcaldo) { fTPCEMCaldo = tpcemcaldo; }; - void SetAODAnalysis(Bool_t aodAnalysis) { fAODAnalysis = aodAnalysis; }; - void SetCentralityEstimator(const char *estimator) { fCentralityEstimator = estimator; } - void SetppAnalysis(){ - fCollisionSystem.SetBitNumber(kpPb, kFALSE); - fCollisionSystem.SetBitNumber(kPbPb, kFALSE); - fCollisionSystem.SetBitNumber(kpp, kTRUE); - } - void SetpPbAnalysis() { - fCollisionSystem.SetBitNumber(kpp, kFALSE); - fCollisionSystem.SetBitNumber(kPbPb, kFALSE); - fCollisionSystem.SetBitNumber(kpPb, kTRUE); - } - void SetPbPbAnalysis() { - fCollisionSystem.SetBitNumber(kpp, kFALSE); - fCollisionSystem.SetBitNumber(kpPb, kFALSE); - fCollisionSystem.SetBitNumber(kPbPb, kTRUE); - }; - Bool_t Ispp() const { return fCollisionSystem.TestBitNumber(kpp); } - Bool_t IsPbPb() const { return fCollisionSystem.TestBitNumber(kPbPb); } - Bool_t IspPb() const { return fCollisionSystem.TestBitNumber(kpPb); } - - AliHFEpid *GetPIDTPConly() const { return fPIDTPConly; } - AliHFEpid *GetPIDTRDonly() const { return fPIDTRDonly; } - AliHFEpid *GetPIDTOFTPC() const { return fPIDTOFTPC; } - AliHFEpid *GetPIDTPCTRD() const { return fPIDTPCTRD; } - AliHFEpid *GetPIDTPCEMCal() const { return fPIDTPCEMCal; } - AliHFEpidQAmanager *GetPIDQAManagerTRDonly() const { return fPIDqaTRDonly; } - AliHFEpidQAmanager *GetPIDQAManagerTOFTPC() const { return fPIDqaTOFTPC; } - AliHFEpidQAmanager *GetPIDQAManagerTPCTRD() const { return fPIDqaTPCTRD; } - AliHFEpidQAmanager *GetPIDQAManagerTPCEMCal() const { return fPIDqaTPCEMCal; } - - - void SetHFECuts(AliHFEcuts * const cuts) { fHFECuts = cuts; }; - - private: - TList *fListHist; //! TH list - Bool_t fAODAnalysis; // AOD analysis - AliAODMCHeader *fAODMCHeader; // ! MC info AOD - TClonesArray *fAODArrayMCInfo; // ! MC info particle AOD - - // Cuts for HFE - AliHFEcuts *fHFECuts; // HFE cuts - AliHFEpid *fPIDTPConly; // PID cuts - AliHFEpid *fPIDTRDonly; // PID cuts - AliHFEpid *fPIDTOFTPC; // PID cuts TOF-TPC only - AliHFEpid *fPIDTPCTRD; // PID cuts TPC-TRD - AliHFEpid *fPIDTPCEMCal; // PID cuts TPC-EMCal - AliHFEpidQAmanager *fPIDqaTRDonly; // QA Manager TOF TPC - AliHFEpidQAmanager *fPIDqaTOFTPC; // QA Manager TOF TPC - AliHFEpidQAmanager *fPIDqaTPCTRD; // QA Manager TPC TRD - AliHFEpidQAmanager *fPIDqaTPCEMCal; // QA Manager TPC EMCal - TString fCentralityEstimator; // Centrality Estimator - TBits fCollisionSystem; // Collision System; - - // Histo yields - TH1F *fNbEvent; // Number of events - TH1F *fTPConly; // TPC only electron yield - TH1F *fTOFTPC; // TOF TPC electron yield - TH1F *fTPCTRD; // TPC TRD electron yield - TH1F *fTPCEMCal; // TPC EMCal electron yield - - // Do PID or not - Bool_t fTPConlydo; // Do TPC only PID - Bool_t fTRDonlydo; // Do TRD only PID - Bool_t fTOFTPCdo; // Do TOF TPC - Bool_t fTPCTRDdo; // Do TPC TRD - Bool_t fTPCEMCaldo; // Do TPC EMCal - - - // Debuging Cuts step by step all centrality together: pt, step (6) - //THnSparseF *fTrackingCuts; //! Tracking Cuts - - - - ClassDef(AliAnalysisTaskHFEQA, 3); // analysisclass -}; - -#endif +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ +// +// Flow task class for the ALICE HFE group +// +// +#ifndef ALIANALYSISTASKHFEQA_H +#define ALIANALYSISTASKHFEQA_H + + +#ifndef ALIANALYSISTASKSE_H +#include "AliAnalysisTaskSE.h" +#endif + +#ifndef ROOT_TString +#include +#endif + +#ifndef ROOT_TBits +#include +#endif + + +class TList; +class AliHFEcuts; +class AliHFEpid; +class AliHFEpidQAmanager; +class AliAODMCHeader; +class TClonesArray; +class TH1F; + + +class AliAnalysisTaskHFEQA: public AliAnalysisTaskSE { +public: + + typedef enum{ + kpp = 0, + kpPb = 1, + kPbPb = 2 + } ESystem_t; + + + AliAnalysisTaskHFEQA(); + AliAnalysisTaskHFEQA(const char *name); + AliAnalysisTaskHFEQA(const AliAnalysisTaskHFEQA &ref); + AliAnalysisTaskHFEQA& operator=(const AliAnalysisTaskHFEQA &ref); + virtual void Copy(TObject &o) const; + virtual ~AliAnalysisTaskHFEQA(); + + virtual void UserExec(Option_t */*option*/); + virtual void UserCreateOutputObjects(); + + void SetDoTPConly(Bool_t tpconlydo) { fTPConlydo = tpconlydo; }; + void SetDoTRDonly(Bool_t trdonlydo) { fTRDonlydo = trdonlydo; }; + void SetDoTOFTPC(Bool_t toftpcdo) { fTOFTPCdo = toftpcdo; }; + void SetDoTPCTRD(Bool_t tpctrddo) { fTPCTRDdo = tpctrddo; }; + void SetDoTPCEMCal(Bool_t tpcemcaldo) { fTPCEMCaldo = tpcemcaldo; }; + void SetAODAnalysis(Bool_t aodAnalysis) { fAODAnalysis = aodAnalysis; }; + void SetCentralityEstimator(const char *estimator) { fCentralityEstimator = estimator; } + void SetppAnalysis(){ + fCollisionSystem.SetBitNumber(kpPb, kFALSE); + fCollisionSystem.SetBitNumber(kPbPb, kFALSE); + fCollisionSystem.SetBitNumber(kpp, kTRUE); + } + void SetpPbAnalysis() { + fCollisionSystem.SetBitNumber(kpp, kFALSE); + fCollisionSystem.SetBitNumber(kPbPb, kFALSE); + fCollisionSystem.SetBitNumber(kpPb, kTRUE); + } + void SetPbPbAnalysis() { + fCollisionSystem.SetBitNumber(kpp, kFALSE); + fCollisionSystem.SetBitNumber(kpPb, kFALSE); + fCollisionSystem.SetBitNumber(kPbPb, kTRUE); + }; + Bool_t Ispp() const { return fCollisionSystem.TestBitNumber(kpp); } + Bool_t IsPbPb() const { return fCollisionSystem.TestBitNumber(kPbPb); } + Bool_t IspPb() const { return fCollisionSystem.TestBitNumber(kpPb); } + + AliHFEpid *GetPIDTPConly() const { return fPIDTPConly; } + AliHFEpid *GetPIDTRDonly() const { return fPIDTRDonly; } + AliHFEpid *GetPIDTOFTPC() const { return fPIDTOFTPC; } + AliHFEpid *GetPIDTPCTRD() const { return fPIDTPCTRD; } + AliHFEpid *GetPIDTPCEMCal() const { return fPIDTPCEMCal; } + AliHFEpidQAmanager *GetPIDQAManagerTRDonly() const { return fPIDqaTRDonly; } + AliHFEpidQAmanager *GetPIDQAManagerTOFTPC() const { return fPIDqaTOFTPC; } + AliHFEpidQAmanager *GetPIDQAManagerTPCTRD() const { return fPIDqaTPCTRD; } + AliHFEpidQAmanager *GetPIDQAManagerTPCEMCal() const { return fPIDqaTPCEMCal; } + + + void SetHFECuts(AliHFEcuts * const cuts) { fHFECuts = cuts; }; + + private: + TList *fListHist; //! TH list + Bool_t fAODAnalysis; // AOD analysis + AliAODMCHeader *fAODMCHeader; // ! MC info AOD + TClonesArray *fAODArrayMCInfo; // ! MC info particle AOD + + // Cuts for HFE + AliHFEcuts *fHFECuts; // HFE cuts + AliHFEpid *fPIDTPConly; // PID cuts + AliHFEpid *fPIDTRDonly; // PID cuts + AliHFEpid *fPIDTOFTPC; // PID cuts TOF-TPC only + AliHFEpid *fPIDTPCTRD; // PID cuts TPC-TRD + AliHFEpid *fPIDTPCEMCal; // PID cuts TPC-EMCal + AliHFEpidQAmanager *fPIDqaTRDonly; // QA Manager TOF TPC + AliHFEpidQAmanager *fPIDqaTOFTPC; // QA Manager TOF TPC + AliHFEpidQAmanager *fPIDqaTPCTRD; // QA Manager TPC TRD + AliHFEpidQAmanager *fPIDqaTPCEMCal; // QA Manager TPC EMCal + TString fCentralityEstimator; // Centrality Estimator + TBits fCollisionSystem; // Collision System; + + // Histo yields + TH1F *fNbEvent; // Number of events + TH1F *fTPConly; // TPC only electron yield + TH1F *fTOFTPC; // TOF TPC electron yield + TH1F *fTPCTRD; // TPC TRD electron yield + TH1F *fTPCEMCal; // TPC EMCal electron yield + + // Do PID or not + Bool_t fTPConlydo; // Do TPC only PID + Bool_t fTRDonlydo; // Do TRD only PID + Bool_t fTOFTPCdo; // Do TOF TPC + Bool_t fTPCTRDdo; // Do TPC TRD + Bool_t fTPCEMCaldo; // Do TPC EMCal + + + // Debuging Cuts step by step all centrality together: pt, step (6) + //THnSparseF *fTrackingCuts; //! Tracking Cuts + + + + ClassDef(AliAnalysisTaskHFEQA, 3); // analysisclass +}; + +#endif diff --git a/PWGHF/hfe/macros/AddTaskFlowITSTPCTOFQCSP.C b/PWGHF/hfe/macros/AddTaskFlowITSTPCTOFQCSP.C index 55946efac83..55b6d1d03ec 100755 --- a/PWGHF/hfe/macros/AddTaskFlowITSTPCTOFQCSP.C +++ b/PWGHF/hfe/macros/AddTaskFlowITSTPCTOFQCSP.C @@ -1,348 +1,348 @@ -/////////////////////////////////////////////////////////////////// -// // -// AddTaskFlowITSTPCTOFQCSP macro // -// Author: Andrea Dubla, Utrecht University, 2012 // -// // -/////////////////////////////////////////////////////////////////// -class AliAnalysisDataContainer; -class AliFlowTrackCuts; -class AliFlowTrackSimpleCuts; -class AliFlowEventCuts; -class AliFlowEventSimpleCuts; -class AliAnalysisDataContainer; -class AliHFEextraCuts; - -AliAnalysisTaskFlowITSTPCTOFQCSP* AddTaskFlowITSTPCTOFQCSP( - TString uniqueID = "", - Float_t centrMin , - Float_t centrMax , - Double_t InvmassCut, - Int_t Trigger, - Bool_t multCorrcut, - Double_t pTCutmin, - Double_t pTCutmax, - Double_t minTOFnSigma, - Double_t maxTOFnSigma, - Double_t minITSnsigmaLowpT, - Double_t maxITSnsigmaLowpT, - Double_t minITSnsigmaHighpT, - Double_t maxITSnsigmaHighpT, - Double_t minTPCnsigmaLowpT, - Double_t maxTPCnsigmaLowpT, - Double_t minTPCnsigmaHighpT, - Double_t maxTPCnsigmaHighpT, - Int_t minTPCCluster, - Int_t TPCS, - AliHFEextraCuts::ITSPixel_t pixel, - Bool_t PhotonicElectronDCA = kFALSE, - // Bool_t QaPidSparse = kFALSE, - const char *Cent = "V0M", - Bool_t QC = kTRUE, // use qc2 and qc4 - Bool_t SP_TPC = kTRUE, //use tpc sp method - Bool_t VZERO_SP = kFALSE, // use vzero sp method - Int_t harmonic = 2, - Bool_t shrinkSP = kTRUE, - Bool_t debug = kFALSE, - Int_t RPFilterBit = 1, - Bool_t op_ang = kFALSE, - Int_t Vz = 10, - Double_t op_angle_cut = 3., - TString histoflatname = "alien:///alice/cern.ch/user/a/adubla/CentrDistrBins005.root" - ) - -{ - - - - if(debug) cout << " === Adding Task ElectFlow === " << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - fileName += ":ElectroID_"; - fileName += uniqueID; - if(debug) cout << " --> Reconstruction data container: " << fileName << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - if(debug) cout << " Fatal error: no analysis manager found! " << endl; - return 0x0; - } - if (!mgr->GetInputEventHandler()) { - if(debug) cout << " Fatal error: no imput event handler found!" << endl; - return 0x0; - } - - //create a task - AliAnalysisTaskFlowITSTPCTOFQCSP *taskHFE = ConfigHFEStandardCuts(kFALSE, minTPCCluster, pixel); //kTRUE if MC - - if(debug) cout << " === AliAnalysisTaskFlowITSTPCTOFQCSP === " << taskHFE << endl; - if(!taskHFE) { - if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl; - return 0x0; - } - taskHFE->SetTrigger(Trigger); - - if(Trigger==0 || Trigger==4){ - TFile *fFlat=TFile::Open(histoflatname.Data()); - TCanvas *c=fFlat->Get("cintegral"); - TH1F *hfl=(TH1F*)c->FindObject("hint"); - taskHFE->SetHistoForCentralityFlattening(hfl,centrMin,centrMax,0.,0); - } - // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC - taskHFE->SetCentralityParameters(centrMin, centrMax, Cent); - taskHFE->SetInvariantMassCut(InvmassCut); - taskHFE->SetpTCuttrack(pTCutmin, pTCutmax); - taskHFE->SetTPCS(TPCS); - taskHFE->SetVz(Vz); - taskHFE->SetIDCuts(minTOFnSigma, maxTOFnSigma, minITSnsigmaLowpT, maxITSnsigmaLowpT, minITSnsigmaHighpT, maxITSnsigmaHighpT, minTPCnsigmaLowpT, maxTPCnsigmaLowpT, minTPCnsigmaHighpT, maxTPCnsigmaHighpT); - // taskHFE->SetQAPIDSparse(QaPidSparse); - taskHFE->SelectPhotonicElectronMethod(PhotonicElectronDCA); - taskHFE->SetOpeningAngleflag(op_ang); - taskHFE->SetOpeningAngleCut(op_angle_cut); - taskHFE->SetMultCorrelationCut(multCorrcut); - - - //set RP cuts for flow package analysis - cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID)); - if(!cutsRP) { - if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl; - return 0x0; - } - - if(!VZERO_SP) { - AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; - cutsRP->SetParamType(rptype); - cutsRP->SetAODfilterBit(RPFilterBit); - cutsRP->SetPtRange(0.2, 5.0); - cutsRP->SetEtaRange(-0.8, 0.8); - cutsRP->SetMinNClustersTPC(70); - cutsRP->SetMinChi2PerClusterTPC(0.1); - cutsRP->SetMaxChi2PerClusterTPC(4.0); - cutsRP->SetRequireTPCRefit(kTRUE); - cutsRP->SetMaxDCAToVertexXY(0.3); - cutsRP->SetMaxDCAToVertexZ(0.3); - cutsRP->SetAcceptKinkDaughters(kFALSE); - cutsRP->SetMinimalTPCdedx(10.); - if(debug) cout << " --> kGlobal RP's " << cutsRP << endl; - } - if(VZERO_SP) { // use vzero sub analysis - cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks - SP_TPC = kFALSE; // disable other methods - QC = kFALSE; - if(debug) cout << " --> VZERO RP's " << cutsRP << endl; - } - - AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts(); - AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts(); - if(SP_TPC){ - POIfilterLeft->SetEtaMin(-0.8); - POIfilterLeft->SetEtaMax(0.0); - POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733); - - POIfilterRight->SetEtaMin(0.0); - POIfilterRight->SetEtaMax(0.8); - POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733); - } - - - AliFlowTrackSimpleCuts *POIfilterVZERO = new AliFlowTrackSimpleCuts(); - if(VZERO_SP || QC){ - POIfilterVZERO->SetEtaMin(-0.8); - POIfilterVZERO->SetEtaMax(0.8); - POIfilterVZERO->SetMassMin(263731); POIfilterVZERO->SetMassMax(263733); - - } - - - AliFlowTrackSimpleCuts *POIfilterLeftH = new AliFlowTrackSimpleCuts(); - AliFlowTrackSimpleCuts *POIfilterRightH = new AliFlowTrackSimpleCuts(); - if(SP_TPC){ - POIfilterLeftH->SetEtaMin(-0.8); - POIfilterLeftH->SetEtaMax(0.0); - POIfilterLeftH->SetMassMin(2636); POIfilterLeftH->SetMassMax(2638); - - POIfilterRightH->SetEtaMin(0.0); - POIfilterRightH->SetEtaMax(0.8); - POIfilterRightH->SetMassMin(2636); POIfilterRightH->SetMassMax(2638); - } - - - AliFlowTrackSimpleCuts *POIfilterQCH = new AliFlowTrackSimpleCuts(); - if(QC){ - POIfilterQCH->SetEtaMin(-0.8); - POIfilterQCH->SetEtaMax(0.8); - POIfilterQCH->SetMassMin(2636); POIfilterQCH->SetMassMax(2638); - - } - - - - taskHFE->SetRPCuts(cutsRP); - - - AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName); - - mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer()); - mgr->ConnectOutput(taskHFE,1,coutput3); - - - if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; - AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); - mgr->ConnectOutput(taskHFE, 2, flowEvent); - if(debug) cout << " --> Created IO containers " << flowEvent << endl; - - - mgr->AddTask(taskHFE); - - if (QC) { // add qc tasks - TPCTOFnew::AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent, debug ,uniqueID, -0.8, -0.0, 0.0, 0.8,false,POIfilterVZERO); - if(debug) cout << " --> Hanging QC task ...succes! "<< endl; - } - if (SP_TPC) { // add sp subevent tasks - TPCTOFnew::AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight); - if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; - TPCTOFnew::AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterLeft); - if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; - } - if (VZERO_SP) { // add sp subevent tasks - TPCTOFnew::AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterVZERO); - if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; - TPCTOFnew::AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterVZERO); - if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; - } - - - return taskHFE; - -} - -//_____________________________________________________________________________ -//_____________________________________________________________________________ - -AliAnalysisTaskFlowITSTPCTOFQCSP* ConfigHFEStandardCuts(Bool_t useMC,Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel){ - // - // HFE standard task configuration - // - - Bool_t kAnalyseTaggedTracks = kTRUE; - - AliHFEcuts *hfecuts = new AliHFEcuts("hfeCuts","HFE Standard Cuts"); //TODO....change the cuts values to PbPb - // hfecuts->CreateStandardCuts(); - hfecuts->SetMinNClustersTPC(minTPCCulster); - hfecuts->SetMinNClustersITS(5);//5 for ITS pid.....usually i used 3. - hfecuts->SetMinNTrackletsTRD(0); - hfecuts->SetMinRatioTPCclusters(0.6); - - // hfecuts->SetEtaRange(-0.9,0.9); - // hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); - hfecuts->SetRequireITSPixel(); - hfecuts->SetCutITSpixel(pixel);//kAny - hfecuts->SetMaxChi2perClusterITS(36); //new from ALberto - hfecuts->SetMaxChi2perClusterTPC(3.5); - hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back - // hfecuts->UnsetVertexRequirement(); - hfecuts->SetVertexRange(10.); - hfecuts->SetRequireSigmaToVertex(); - //hfecuts->SetSigmaToVertex(10); - hfecuts->SetTOFPIDStep(kFALSE); - // hfecuts->SetQAOn(); - hfecuts->SetPtRange(0, 5.); - - AliAnalysisTaskFlowITSTPCTOFQCSP *task = new AliAnalysisTaskFlowITSTPCTOFQCSP("HFE_Flow_TPCTOF"); - printf("*************************************************************"); - printf("task -------------------------------------------- %p\n ", task); - printf("*************************************************************\n"); - - - task->SetHFECuts(hfecuts); - - // task->SetInvariantMassCut(0.05); - // task->SetRejectKinkMother(kTRUE); - // task->SetRemovePileUp(kTRUE); - - // Define PID - AliHFEpid *pid = task->GetPID(); - if(useMC) pid->SetHasMCData(kTRUE); - pid->AddDetector("ITS", 0); - pid->AddDetector("TOF", 1); - pid->AddDetector("TPC", 2); - - printf("*************************************\n"); - printf("Configuring standard Task:\n"); - // task->PrintStatus(); - pid->PrintStatus(); - printf("*************************************\n"); - return task; - - -} - -//_____________________________________________________________________________ - -namespace TPCTOFnew{ - //_____________________________________________________________________________ - void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, bool bEP, bool shrink = false, bool debug, TString uniqueID,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter) - { - // add sp task and invm filter tasks - if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - (bEP) ? fileName+=":EP_tpctof" : fileName+=":SP_tpctof"; - // if(etagap) { - // fileName+="_SUBEVENTS"; - // if(debug) cout << " --> Setting up subevent analysis <-- " << endl; - // } - if(debug) cout << " --> fileName " << fileName << endl; - TString myFolder = fileName; - if(debug) cout << " --> myFolder " << myFolder << endl; - TString myNameSP; - (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector); - if(debug) cout << " myNameSP " << myNameSP << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); - AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter); - tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); - if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); - mgr->AddTask(tskFilter); - mgr->ConnectInput(tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEventOut); - AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); - AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE); - tskSP->SetApplyCorrectionForNUA(kTRUE); - tskSP->SetHarmonic(harmonic); - tskSP->SetTotalQvector(Qvector); - if (bEP) tskSP->SetBehaveAsEP(); - if (shrink) tskSP->SetBookOnlyBasicCCH(kTRUE); - mgr->AddTask(tskSP); - mgr->ConnectInput(tskSP, 0, flowEventOut); - mgr->ConnectOutput(tskSP, 1, outSP); - } - //_____________________________________________________________________________ - void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, Bool_t debug, TString uniqueID,double minEtaA, double maxEtaA, double minEtaB, double maxEtaB,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter) - { - // add qc task and invm filter tasks - if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - fileName+=":QC_tpctof"; - if(debug) cout << " --> Common filename: " << fileName << endl; - TString myFolder = Form("v%d", harmonic); - if(debug) cout << " --> myFolder: " << myFolder << endl; - TString myName = Form("%s", name); - if(debug) cout << " --> myName: " << myName << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); - AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter); - tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); - // if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); - mgr->AddTask(tskFilter); - mgr->ConnectInput(tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEventOut); - - AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); - AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE); - tskQC->SetApplyCorrectionForNUA(kTRUE); - tskQC->SetHarmonic(harmonic); - tskQC->SetBookOnlyBasicCCH(kTRUE); - mgr->AddTask(tskQC); - mgr->ConnectInput(tskQC, 0, flowEventOut); - mgr->ConnectOutput(tskQC, 1, outQC); - } - //_____________________________________________________________________________ -} - +/////////////////////////////////////////////////////////////////// +// // +// AddTaskFlowITSTPCTOFQCSP macro // +// Author: Andrea Dubla, Utrecht University, 2012 // +// // +/////////////////////////////////////////////////////////////////// +class AliAnalysisDataContainer; +class AliFlowTrackCuts; +class AliFlowTrackSimpleCuts; +class AliFlowEventCuts; +class AliFlowEventSimpleCuts; +class AliAnalysisDataContainer; +class AliHFEextraCuts; + +AliAnalysisTaskFlowITSTPCTOFQCSP* AddTaskFlowITSTPCTOFQCSP( + TString uniqueID = "", + Float_t centrMin , + Float_t centrMax , + Double_t InvmassCut, + Int_t Trigger, + Bool_t multCorrcut, + Double_t pTCutmin, + Double_t pTCutmax, + Double_t minTOFnSigma, + Double_t maxTOFnSigma, + Double_t minITSnsigmaLowpT, + Double_t maxITSnsigmaLowpT, + Double_t minITSnsigmaHighpT, + Double_t maxITSnsigmaHighpT, + Double_t minTPCnsigmaLowpT, + Double_t maxTPCnsigmaLowpT, + Double_t minTPCnsigmaHighpT, + Double_t maxTPCnsigmaHighpT, + Int_t minTPCCluster, + Int_t TPCS, + AliHFEextraCuts::ITSPixel_t pixel, + Bool_t PhotonicElectronDCA = kFALSE, + // Bool_t QaPidSparse = kFALSE, + const char *Cent = "V0M", + Bool_t QC = kTRUE, // use qc2 and qc4 + Bool_t SP_TPC = kTRUE, //use tpc sp method + Bool_t VZERO_SP = kFALSE, // use vzero sp method + Int_t harmonic = 2, + Bool_t shrinkSP = kTRUE, + Bool_t debug = kFALSE, + Int_t RPFilterBit = 1, + Bool_t op_ang = kFALSE, + Int_t Vz = 10, + Double_t op_angle_cut = 3., + TString histoflatname = "alien:///alice/cern.ch/user/a/adubla/CentrDistrBins005.root" + ) + +{ + + + + if(debug) cout << " === Adding Task ElectFlow === " << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + fileName += ":ElectroID_"; + fileName += uniqueID; + if(debug) cout << " --> Reconstruction data container: " << fileName << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + if(debug) cout << " Fatal error: no analysis manager found! " << endl; + return 0x0; + } + if (!mgr->GetInputEventHandler()) { + if(debug) cout << " Fatal error: no imput event handler found!" << endl; + return 0x0; + } + + //create a task + AliAnalysisTaskFlowITSTPCTOFQCSP *taskHFE = ConfigHFEStandardCuts(kFALSE, minTPCCluster, pixel); //kTRUE if MC + + if(debug) cout << " === AliAnalysisTaskFlowITSTPCTOFQCSP === " << taskHFE << endl; + if(!taskHFE) { + if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl; + return 0x0; + } + taskHFE->SetTrigger(Trigger); + + if(Trigger==0 || Trigger==4){ + TFile *fFlat=TFile::Open(histoflatname.Data()); + TCanvas *c=fFlat->Get("cintegral"); + TH1F *hfl=(TH1F*)c->FindObject("hint"); + taskHFE->SetHistoForCentralityFlattening(hfl,centrMin,centrMax,0.,0); + } + // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC + taskHFE->SetCentralityParameters(centrMin, centrMax, Cent); + taskHFE->SetInvariantMassCut(InvmassCut); + taskHFE->SetpTCuttrack(pTCutmin, pTCutmax); + taskHFE->SetTPCS(TPCS); + taskHFE->SetVz(Vz); + taskHFE->SetIDCuts(minTOFnSigma, maxTOFnSigma, minITSnsigmaLowpT, maxITSnsigmaLowpT, minITSnsigmaHighpT, maxITSnsigmaHighpT, minTPCnsigmaLowpT, maxTPCnsigmaLowpT, minTPCnsigmaHighpT, maxTPCnsigmaHighpT); + // taskHFE->SetQAPIDSparse(QaPidSparse); + taskHFE->SelectPhotonicElectronMethod(PhotonicElectronDCA); + taskHFE->SetOpeningAngleflag(op_ang); + taskHFE->SetOpeningAngleCut(op_angle_cut); + taskHFE->SetMultCorrelationCut(multCorrcut); + + + //set RP cuts for flow package analysis + cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID)); + if(!cutsRP) { + if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl; + return 0x0; + } + + if(!VZERO_SP) { + AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; + cutsRP->SetParamType(rptype); + cutsRP->SetAODfilterBit(RPFilterBit); + cutsRP->SetPtRange(0.2, 5.0); + cutsRP->SetEtaRange(-0.8, 0.8); + cutsRP->SetMinNClustersTPC(70); + cutsRP->SetMinChi2PerClusterTPC(0.1); + cutsRP->SetMaxChi2PerClusterTPC(4.0); + cutsRP->SetRequireTPCRefit(kTRUE); + cutsRP->SetMaxDCAToVertexXY(0.3); + cutsRP->SetMaxDCAToVertexZ(0.3); + cutsRP->SetAcceptKinkDaughters(kFALSE); + cutsRP->SetMinimalTPCdedx(10.); + if(debug) cout << " --> kGlobal RP's " << cutsRP << endl; + } + if(VZERO_SP) { // use vzero sub analysis + cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks + SP_TPC = kFALSE; // disable other methods + QC = kFALSE; + if(debug) cout << " --> VZERO RP's " << cutsRP << endl; + } + + AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts(); + AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts(); + if(SP_TPC){ + POIfilterLeft->SetEtaMin(-0.8); + POIfilterLeft->SetEtaMax(0.0); + POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733); + + POIfilterRight->SetEtaMin(0.0); + POIfilterRight->SetEtaMax(0.8); + POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733); + } + + + AliFlowTrackSimpleCuts *POIfilterVZERO = new AliFlowTrackSimpleCuts(); + if(VZERO_SP || QC){ + POIfilterVZERO->SetEtaMin(-0.8); + POIfilterVZERO->SetEtaMax(0.8); + POIfilterVZERO->SetMassMin(263731); POIfilterVZERO->SetMassMax(263733); + + } + + + AliFlowTrackSimpleCuts *POIfilterLeftH = new AliFlowTrackSimpleCuts(); + AliFlowTrackSimpleCuts *POIfilterRightH = new AliFlowTrackSimpleCuts(); + if(SP_TPC){ + POIfilterLeftH->SetEtaMin(-0.8); + POIfilterLeftH->SetEtaMax(0.0); + POIfilterLeftH->SetMassMin(2636); POIfilterLeftH->SetMassMax(2638); + + POIfilterRightH->SetEtaMin(0.0); + POIfilterRightH->SetEtaMax(0.8); + POIfilterRightH->SetMassMin(2636); POIfilterRightH->SetMassMax(2638); + } + + + AliFlowTrackSimpleCuts *POIfilterQCH = new AliFlowTrackSimpleCuts(); + if(QC){ + POIfilterQCH->SetEtaMin(-0.8); + POIfilterQCH->SetEtaMax(0.8); + POIfilterQCH->SetMassMin(2636); POIfilterQCH->SetMassMax(2638); + + } + + + + taskHFE->SetRPCuts(cutsRP); + + + AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName); + + mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer()); + mgr->ConnectOutput(taskHFE,1,coutput3); + + + if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; + AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); + mgr->ConnectOutput(taskHFE, 2, flowEvent); + if(debug) cout << " --> Created IO containers " << flowEvent << endl; + + + mgr->AddTask(taskHFE); + + if (QC) { // add qc tasks + TPCTOFnew::AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent, debug ,uniqueID, -0.8, -0.0, 0.0, 0.8,false,POIfilterVZERO); + if(debug) cout << " --> Hanging QC task ...succes! "<< endl; + } + if (SP_TPC) { // add sp subevent tasks + TPCTOFnew::AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight); + if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; + TPCTOFnew::AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterLeft); + if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; + } + if (VZERO_SP) { // add sp subevent tasks + TPCTOFnew::AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterVZERO); + if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; + TPCTOFnew::AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterVZERO); + if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; + } + + + return taskHFE; + +} + +//_____________________________________________________________________________ +//_____________________________________________________________________________ + +AliAnalysisTaskFlowITSTPCTOFQCSP* ConfigHFEStandardCuts(Bool_t useMC,Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel){ + // + // HFE standard task configuration + // + + Bool_t kAnalyseTaggedTracks = kTRUE; + + AliHFEcuts *hfecuts = new AliHFEcuts("hfeCuts","HFE Standard Cuts"); //TODO....change the cuts values to PbPb + // hfecuts->CreateStandardCuts(); + hfecuts->SetMinNClustersTPC(minTPCCulster); + hfecuts->SetMinNClustersITS(5);//5 for ITS pid.....usually i used 3. + hfecuts->SetMinNTrackletsTRD(0); + hfecuts->SetMinRatioTPCclusters(0.6); + + // hfecuts->SetEtaRange(-0.9,0.9); + // hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); + hfecuts->SetRequireITSPixel(); + hfecuts->SetCutITSpixel(pixel);//kAny + hfecuts->SetMaxChi2perClusterITS(36); //new from ALberto + hfecuts->SetMaxChi2perClusterTPC(3.5); + hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back + // hfecuts->UnsetVertexRequirement(); + hfecuts->SetVertexRange(10.); + hfecuts->SetRequireSigmaToVertex(); + //hfecuts->SetSigmaToVertex(10); + hfecuts->SetTOFPIDStep(kFALSE); + // hfecuts->SetQAOn(); + hfecuts->SetPtRange(0, 5.); + + AliAnalysisTaskFlowITSTPCTOFQCSP *task = new AliAnalysisTaskFlowITSTPCTOFQCSP("HFE_Flow_TPCTOF"); + printf("*************************************************************"); + printf("task -------------------------------------------- %p\n ", task); + printf("*************************************************************\n"); + + + task->SetHFECuts(hfecuts); + + // task->SetInvariantMassCut(0.05); + // task->SetRejectKinkMother(kTRUE); + // task->SetRemovePileUp(kTRUE); + + // Define PID + AliHFEpid *pid = task->GetPID(); + if(useMC) pid->SetHasMCData(kTRUE); + pid->AddDetector("ITS", 0); + pid->AddDetector("TOF", 1); + pid->AddDetector("TPC", 2); + + printf("*************************************\n"); + printf("Configuring standard Task:\n"); + // task->PrintStatus(); + pid->PrintStatus(); + printf("*************************************\n"); + return task; + + +} + +//_____________________________________________________________________________ + +namespace TPCTOFnew{ + //_____________________________________________________________________________ + void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, bool bEP, bool shrink = false, bool debug, TString uniqueID,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter) + { + // add sp task and invm filter tasks + if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + (bEP) ? fileName+=":EP_tpctof" : fileName+=":SP_tpctof"; + // if(etagap) { + // fileName+="_SUBEVENTS"; + // if(debug) cout << " --> Setting up subevent analysis <-- " << endl; + // } + if(debug) cout << " --> fileName " << fileName << endl; + TString myFolder = fileName; + if(debug) cout << " --> myFolder " << myFolder << endl; + TString myNameSP; + (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector); + if(debug) cout << " myNameSP " << myNameSP << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter); + tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); + if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); + mgr->AddTask(tskFilter); + mgr->ConnectInput(tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEventOut); + AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); + AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE); + tskSP->SetApplyCorrectionForNUA(kTRUE); + tskSP->SetHarmonic(harmonic); + tskSP->SetTotalQvector(Qvector); + if (bEP) tskSP->SetBehaveAsEP(); + if (shrink) tskSP->SetBookOnlyBasicCCH(kTRUE); + mgr->AddTask(tskSP); + mgr->ConnectInput(tskSP, 0, flowEventOut); + mgr->ConnectOutput(tskSP, 1, outSP); + } + //_____________________________________________________________________________ + void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, Bool_t debug, TString uniqueID,double minEtaA, double maxEtaA, double minEtaB, double maxEtaB,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter) + { + // add qc task and invm filter tasks + if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + fileName+=":QC_tpctof"; + if(debug) cout << " --> Common filename: " << fileName << endl; + TString myFolder = Form("v%d", harmonic); + if(debug) cout << " --> myFolder: " << myFolder << endl; + TString myName = Form("%s", name); + if(debug) cout << " --> myName: " << myName << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter); + tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); + // if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); + mgr->AddTask(tskFilter); + mgr->ConnectInput(tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEventOut); + + AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); + AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE); + tskQC->SetApplyCorrectionForNUA(kTRUE); + tskQC->SetHarmonic(harmonic); + tskQC->SetBookOnlyBasicCCH(kTRUE); + mgr->AddTask(tskQC); + mgr->ConnectInput(tskQC, 0, flowEventOut); + mgr->ConnectOutput(tskQC, 1, outQC); + } + //_____________________________________________________________________________ +} + diff --git a/PWGHF/hfe/macros/AddTaskFlowTPCEMCalQCSP.C b/PWGHF/hfe/macros/AddTaskFlowTPCEMCalQCSP.C index 586ab62cdfc..7465e54a128 100644 --- a/PWGHF/hfe/macros/AddTaskFlowTPCEMCalQCSP.C +++ b/PWGHF/hfe/macros/AddTaskFlowTPCEMCalQCSP.C @@ -1,371 +1,371 @@ -/////////////////////////////////////////////////////////////////// -// // -// AddTaskFlowTPCEMCalQCSP macro // -// Author: Andrea Dubla, Utrecht University, 2012 // -// // -/////////////////////////////////////////////////////////////////// -class AliAnalysisDataContainer; -class AliFlowTrackCuts; -class AliFlowTrackSimpleCuts; -class AliFlowEventCuts; -class AliFlowEventSimpleCuts; -class AliAnalysisDataContainer; -class AliHFEextraCuts; - -AliAnalysisTaskFlowTPCEMCalQCSP* AddTaskFlowTPCEMCalQCSP( - TString uniqueID = "", - Float_t centrMin , - Float_t centrMax , - Double_t InvmassCut, - Double_t pTCut, - Int_t Trigger, - Bool_t multCorrcut, - Double_t minTPC, - Double_t maxTPC, - Double_t minEovP, - Double_t maxEovP, - Double_t minM20, - Double_t maxM20, - Double_t minM02, - Double_t maxM02, - Double_t Dispersion, - Int_t minTPCCluster, - AliHFEextraCuts::ITSPixel_t pixel, - Bool_t NUA = kTRUE, - Bool_t PhotonicElectronDCA = kFALSE, - Int_t TPCClusterforAsso = 80, - Bool_t AssoITSref = kTRUE, - Bool_t purity = kTRUE, - Bool_t SideBandsFlow = kFALSE, - Bool_t Phi_minus_psi = kFALSE, - const char *Cent = "V0M", - Bool_t QC = kTRUE, // use qc2 and qc4 - Bool_t SP_TPC = kTRUE, //use tpc sp method - Bool_t VZERO_SP = kFALSE, // use vzero sp method - Bool_t BaseH = kFALSE, // base histo - Int_t harmonic = 2, - Bool_t shrinkSP = kTRUE, - Bool_t debug = kFALSE, - Int_t RPFilterBit = 1, - Bool_t op_ang = kFALSE, - Double_t op_angle_cut=3., - TString histoflatname = "alien:///alice/cern.ch/user/a/adubla/CentrDistrBins005.root" - ) - -{ - - - - if(debug) cout << " === Adding Task ElectFlow === " << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - fileName += ":ElectroID_"; - fileName += uniqueID; - if(debug) cout << " --> Reconstruction data container: " << fileName << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - if(debug) cout << " Fatal error: no analysis manager found! " << endl; - return 0x0; - } - if (!mgr->GetInputEventHandler()) { - if(debug) cout << " Fatal error: no imput event handler found!" << endl; - return 0x0; - } - - //create a task - AliAnalysisTaskFlowTPCEMCalQCSP *taskHFE = ConfigHFEemcalMod(kFALSE, minTPCCluster, pixel); //kTRUE if MC - - if(debug) cout << " === AliAnalysisElectronFlow === " << taskHFE << endl; - if(!taskHFE) { - if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl; - return 0x0; - } - taskHFE->SetTrigger(Trigger); - - if(Trigger==0 || Trigger==4){ - TFile *fFlat=TFile::Open(histoflatname.Data()); - TCanvas *c=fFlat->Get("cintegral"); - TH1F *hfl=(TH1F*)c->FindObject("hint"); - taskHFE->SetHistoForCentralityFlattening(hfl,centrMin,centrMax,0.,0); - } - - // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC - taskHFE->SetCentralityParameters(centrMin, centrMax, Cent); - taskHFE->SetInvariantMassCut(InvmassCut); - taskHFE->SetIDCuts(minTPC, maxTPC, minEovP, maxEovP, minM20, maxM20, minM02, maxM02, Dispersion); - taskHFE->SetFlowSideBands(SideBandsFlow); - taskHFE->Setphiminuspsi(Phi_minus_psi); - taskHFE->SetPurity(purity); - taskHFE->SetpTCuttrack(pTCut); - taskHFE->SelectPhotonicElectronMethod(PhotonicElectronDCA); - taskHFE->SetOpeningAngleflag(op_ang); - taskHFE->SetOpeningAngleCut(op_angle_cut); - taskHFE->SetAssoTPCCluster(TPCClusterforAsso); - taskHFE->SetAssoITSRefit(AssoITSref); - taskHFE->SetMultCorrelationCut(multCorrcut); - //set RP cuts for flow package analysis - cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID)); - if(!cutsRP) { - if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl; - return 0x0; - } - - if(!VZERO_SP) { - AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; - cutsRP->SetParamType(rptype); - cutsRP->SetAODfilterBit(RPFilterBit); - cutsRP->SetPtRange(0.2, 5.0); - cutsRP->SetEtaRange(-0.7, 0.7); - cutsRP->SetMinNClustersTPC(70); - cutsRP->SetMinChi2PerClusterTPC(0.1); - cutsRP->SetMaxChi2PerClusterTPC(4.0); - cutsRP->SetRequireTPCRefit(kTRUE); - cutsRP->SetMaxDCAToVertexXY(0.3); - cutsRP->SetMaxDCAToVertexZ(0.3); - cutsRP->SetAcceptKinkDaughters(kFALSE); - cutsRP->SetMinimalTPCdedx(10.); - if(debug) cout << " --> kGlobal RP's " << cutsRP << endl; - } - if(VZERO_SP) { // use vzero sub analysis - cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks - SP_TPC = kFALSE; // disable other methods - QC = kFALSE; - if(debug) cout << " --> VZERO RP's " << cutsRP << endl; - } - - AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts(); - AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts(); - if(VZERO_SP || SP_TPC){ - POIfilterLeft->SetEtaMin(-0.7); - POIfilterLeft->SetEtaMax(0.0); - POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733); - - POIfilterRight->SetEtaMin(0.0); - POIfilterRight->SetEtaMax(0.7); - POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733); - } - - - AliFlowTrackSimpleCuts *POIfilterQC = new AliFlowTrackSimpleCuts(); - if(QC){ - POIfilterQC->SetEtaMin(-0.7); - POIfilterQC->SetEtaMax(0.7); - POIfilterQC->SetMassMin(263731); POIfilterQC->SetMassMax(263733); - - } - - if(SideBandsFlow){ - - AliFlowTrackSimpleCuts *POIfilterLeftH = new AliFlowTrackSimpleCuts(); - AliFlowTrackSimpleCuts *POIfilterRightH = new AliFlowTrackSimpleCuts(); - if(SP_TPC){ - POIfilterLeftH->SetEtaMin(-0.7); - POIfilterLeftH->SetEtaMax(0.0); - POIfilterLeftH->SetMassMin(2636); POIfilterLeftH->SetMassMax(2638); - - POIfilterRightH->SetEtaMin(0.0); - POIfilterRightH->SetEtaMax(0.7); - POIfilterRightH->SetMassMin(2636); POIfilterRightH->SetMassMax(2638); - } - - - AliFlowTrackSimpleCuts *POIfilterQCH = new AliFlowTrackSimpleCuts(); - if(QC){ - POIfilterQCH->SetEtaMin(-0.7); - POIfilterQCH->SetEtaMax(0.7); - POIfilterQCH->SetMassMin(2636); POIfilterQCH->SetMassMax(2638); - - } - - } - - taskHFE->SetRPCuts(cutsRP); - - - AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName); - - mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer()); - mgr->ConnectOutput(taskHFE,1,coutput3); - - - if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; - AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); - mgr->ConnectOutput(taskHFE, 2, flowEvent); - if(debug) cout << " --> Created IO containers " << flowEvent << endl; - - if(SideBandsFlow){ - if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; - AliAnalysisDataContainer *flowEventCont = mgr->CreateContainer(Form("FlowContainer_Cont_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); - mgr->ConnectOutput(taskHFE, 3, flowEventCont); - if(debug) cout << " --> Created IO containers " << flowEventCont << endl; - } - - - mgr->AddTask(taskHFE); - - if (QC) { // add qc tasks - AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQC, NUA, shrinkSP, BaseH); - if(debug) cout << " --> Hanging QC task ...succes! "<< endl; - } - if (SP_TPC) { // add sp subevent tasks - AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; - AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterLeft, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; - } - if (VZERO_SP) { // add sp subevent tasks - AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterRight, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; - AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterLeft, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; - } - - //=========================================Flow event for elctronContamination============================================================================================== - if(SideBandsFlow){ - if (QC) { // add qc tasks - AddQCmethod(Form("QCTPCCont_%s",uniqueID.Data()), harmonic, flowEventCont, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQCH, NUA, shrinkSP,BaseH); - if(debug) cout << " --> Hanging QC task ...succes! "<< endl; - } - if (SP_TPC) { // add sp subevent tasks - AddSPmethod(Form("SPTPCQa_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterRightH, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; - AddSPmethod(Form("SPTPCQb_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterLeftH, NUA,BaseH); - if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; - } - } - //========================================================================================================================================================================== - - - return taskHFE; - -} - -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, bool bEP, bool shrink = false, bool debug, TString uniqueID, Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter, Bool_t kNUA, Bool_t kBaseH) -{ - // add sp task and invm filter tasks - if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - (bEP) ? fileName+=":EP" : fileName+=":SP"; - // if(etagap) { - // fileName+="_SUBEVENTS"; - // if(debug) cout << " --> Setting up subevent analysis <-- " << endl; - // } - if(debug) cout << " --> fileName " << fileName << endl; - TString myFolder = fileName; - if(debug) cout << " --> myFolder " << myFolder << endl; - TString myNameSP; - (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector); - if(debug) cout << " myNameSP " << myNameSP << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); - AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter); - tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); - if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); - mgr->AddTask(tskFilter); - mgr->ConnectInput(tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEventOut); - AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); - AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE); - tskSP->SetApplyCorrectionForNUA(kNUA); - tskSP->SetHarmonic(harmonic); - tskSP->SetTotalQvector(Qvector); - if (bEP) tskSP->SetBehaveAsEP(); - if (shrink)tskSP->SetBookOnlyBasicCCH(kBaseH); - mgr->AddTask(tskSP); - mgr->ConnectInput(tskSP, 0, flowEventOut); - mgr->ConnectOutput(tskSP, 1, outSP); -} -//_____________________________________________________________________________ -void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, Bool_t debug, TString uniqueID,double minEtaA, double maxEtaA, double minEtaB, double maxEtaB,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter, Bool_t kNUA, bool shrink = false, Bool_t kBaseH) -{ - // add qc task and invm filter tasks - if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl; - TString fileName = AliAnalysisManager::GetCommonFileName(); - fileName+=":QC"; - if(debug) cout << " --> Common filename: " << fileName << endl; - TString myFolder = Form("v%d", harmonic); - if(debug) cout << " --> myFolder: " << myFolder << endl; - TString myName = Form("%s", name); - if(debug) cout << " --> myName: " << myName << endl; - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); - AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter); - tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); - // if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); - mgr->AddTask(tskFilter); - mgr->ConnectInput(tskFilter, 0, flowEvent); - mgr->ConnectOutput(tskFilter, 1, flowEventOut); - - AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); - AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE); - tskQC->SetApplyCorrectionForNUA(kNUA); - tskQC->SetHarmonic(harmonic); - if (shrink)tskQC->SetBookOnlyBasicCCH(kBaseH); - mgr->AddTask(tskQC); - mgr->ConnectInput(tskQC, 0, flowEventOut); - mgr->ConnectOutput(tskQC, 1, outQC); -} -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ - -AliAnalysisTaskFlowTPCEMCalQCSP* ConfigHFEemcalMod(Bool_t useMC,Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel){ - // - // HFE standard task configuration - // - - Bool_t kAnalyseTaggedTracks = kTRUE; - - AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsEMCAL","HFE Standard Cuts"); //TODO....change the cuts values to PbPb - // hfecuts->CreateStandardCuts(); - hfecuts->SetMinNClustersTPC(minTPCCulster); - hfecuts->SetMinNClustersITS(3); - hfecuts->SetMinNTrackletsTRD(0); - hfecuts->SetMinRatioTPCclusters(0.6); - - // hfecuts->SetEtaRange(-0.9,0.9); - // hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); - hfecuts->SetRequireITSPixel(); - hfecuts->SetCutITSpixel(pixel);//kAny - hfecuts->SetMaxChi2perClusterITS(-1); - hfecuts->SetMaxChi2perClusterTPC(3.5); - hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back - // hfecuts->UnsetVertexRequirement(); - hfecuts->SetVertexRange(10.); - hfecuts->SetRequireSigmaToVertex(); - //hfecuts->SetSigmaToVertex(10); - hfecuts->SetTOFPIDStep(kFALSE); - // hfecuts->SetQAOn(); - hfecuts->SetPtRange(0, 30); - - AliAnalysisTaskFlowTPCEMCalQCSP *task = new AliAnalysisTaskFlowTPCEMCalQCSP("HFE_Flow_TPCEMCal"); - printf("task ------------------------ %p\n ", task); - - - task->SetHFECuts(hfecuts); - - // task->SetInvariantMassCut(0.05); - // task->SetRejectKinkMother(kTRUE); - // task->SetRemovePileUp(kTRUE); - - // Define PID - AliHFEpid *pid = task->GetPID(); - if(useMC) pid->SetHasMCData(kTRUE); - pid->AddDetector("TPC", 0); - pid->AddDetector("EMCAL", 1); - - printf("*************************************\n"); - printf("Configuring standard Task:\n"); - // task->PrintStatus(); - pid->PrintStatus(); - printf("*************************************\n"); - return task; - - -} - +/////////////////////////////////////////////////////////////////// +// // +// AddTaskFlowTPCEMCalQCSP macro // +// Author: Andrea Dubla, Utrecht University, 2012 // +// // +/////////////////////////////////////////////////////////////////// +class AliAnalysisDataContainer; +class AliFlowTrackCuts; +class AliFlowTrackSimpleCuts; +class AliFlowEventCuts; +class AliFlowEventSimpleCuts; +class AliAnalysisDataContainer; +class AliHFEextraCuts; + +AliAnalysisTaskFlowTPCEMCalQCSP* AddTaskFlowTPCEMCalQCSP( + TString uniqueID = "", + Float_t centrMin , + Float_t centrMax , + Double_t InvmassCut, + Double_t pTCut, + Int_t Trigger, + Bool_t multCorrcut, + Double_t minTPC, + Double_t maxTPC, + Double_t minEovP, + Double_t maxEovP, + Double_t minM20, + Double_t maxM20, + Double_t minM02, + Double_t maxM02, + Double_t Dispersion, + Int_t minTPCCluster, + AliHFEextraCuts::ITSPixel_t pixel, + Bool_t NUA = kTRUE, + Bool_t PhotonicElectronDCA = kFALSE, + Int_t TPCClusterforAsso = 80, + Bool_t AssoITSref = kTRUE, + Bool_t purity = kTRUE, + Bool_t SideBandsFlow = kFALSE, + Bool_t Phi_minus_psi = kFALSE, + const char *Cent = "V0M", + Bool_t QC = kTRUE, // use qc2 and qc4 + Bool_t SP_TPC = kTRUE, //use tpc sp method + Bool_t VZERO_SP = kFALSE, // use vzero sp method + Bool_t BaseH = kFALSE, // base histo + Int_t harmonic = 2, + Bool_t shrinkSP = kTRUE, + Bool_t debug = kFALSE, + Int_t RPFilterBit = 1, + Bool_t op_ang = kFALSE, + Double_t op_angle_cut=3., + TString histoflatname = "alien:///alice/cern.ch/user/a/adubla/CentrDistrBins005.root" + ) + +{ + + + + if(debug) cout << " === Adding Task ElectFlow === " << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + fileName += ":ElectroID_"; + fileName += uniqueID; + if(debug) cout << " --> Reconstruction data container: " << fileName << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + if(debug) cout << " Fatal error: no analysis manager found! " << endl; + return 0x0; + } + if (!mgr->GetInputEventHandler()) { + if(debug) cout << " Fatal error: no imput event handler found!" << endl; + return 0x0; + } + + //create a task + AliAnalysisTaskFlowTPCEMCalQCSP *taskHFE = ConfigHFEemcalMod(kFALSE, minTPCCluster, pixel); //kTRUE if MC + + if(debug) cout << " === AliAnalysisElectronFlow === " << taskHFE << endl; + if(!taskHFE) { + if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl; + return 0x0; + } + taskHFE->SetTrigger(Trigger); + + if(Trigger==0 || Trigger==4){ + TFile *fFlat=TFile::Open(histoflatname.Data()); + TCanvas *c=fFlat->Get("cintegral"); + TH1F *hfl=(TH1F*)c->FindObject("hint"); + taskHFE->SetHistoForCentralityFlattening(hfl,centrMin,centrMax,0.,0); + } + + // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC + taskHFE->SetCentralityParameters(centrMin, centrMax, Cent); + taskHFE->SetInvariantMassCut(InvmassCut); + taskHFE->SetIDCuts(minTPC, maxTPC, minEovP, maxEovP, minM20, maxM20, minM02, maxM02, Dispersion); + taskHFE->SetFlowSideBands(SideBandsFlow); + taskHFE->Setphiminuspsi(Phi_minus_psi); + taskHFE->SetPurity(purity); + taskHFE->SetpTCuttrack(pTCut); + taskHFE->SelectPhotonicElectronMethod(PhotonicElectronDCA); + taskHFE->SetOpeningAngleflag(op_ang); + taskHFE->SetOpeningAngleCut(op_angle_cut); + taskHFE->SetAssoTPCCluster(TPCClusterforAsso); + taskHFE->SetAssoITSRefit(AssoITSref); + taskHFE->SetMultCorrelationCut(multCorrcut); + //set RP cuts for flow package analysis + cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID)); + if(!cutsRP) { + if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl; + return 0x0; + } + + if(!VZERO_SP) { + AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal; + cutsRP->SetParamType(rptype); + cutsRP->SetAODfilterBit(RPFilterBit); + cutsRP->SetPtRange(0.2, 5.0); + cutsRP->SetEtaRange(-0.7, 0.7); + cutsRP->SetMinNClustersTPC(70); + cutsRP->SetMinChi2PerClusterTPC(0.1); + cutsRP->SetMaxChi2PerClusterTPC(4.0); + cutsRP->SetRequireTPCRefit(kTRUE); + cutsRP->SetMaxDCAToVertexXY(0.3); + cutsRP->SetMaxDCAToVertexZ(0.3); + cutsRP->SetAcceptKinkDaughters(kFALSE); + cutsRP->SetMinimalTPCdedx(10.); + if(debug) cout << " --> kGlobal RP's " << cutsRP << endl; + } + if(VZERO_SP) { // use vzero sub analysis + cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks + SP_TPC = kFALSE; // disable other methods + QC = kFALSE; + if(debug) cout << " --> VZERO RP's " << cutsRP << endl; + } + + AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts(); + AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts(); + if(VZERO_SP || SP_TPC){ + POIfilterLeft->SetEtaMin(-0.7); + POIfilterLeft->SetEtaMax(0.0); + POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733); + + POIfilterRight->SetEtaMin(0.0); + POIfilterRight->SetEtaMax(0.7); + POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733); + } + + + AliFlowTrackSimpleCuts *POIfilterQC = new AliFlowTrackSimpleCuts(); + if(QC){ + POIfilterQC->SetEtaMin(-0.7); + POIfilterQC->SetEtaMax(0.7); + POIfilterQC->SetMassMin(263731); POIfilterQC->SetMassMax(263733); + + } + + if(SideBandsFlow){ + + AliFlowTrackSimpleCuts *POIfilterLeftH = new AliFlowTrackSimpleCuts(); + AliFlowTrackSimpleCuts *POIfilterRightH = new AliFlowTrackSimpleCuts(); + if(SP_TPC){ + POIfilterLeftH->SetEtaMin(-0.7); + POIfilterLeftH->SetEtaMax(0.0); + POIfilterLeftH->SetMassMin(2636); POIfilterLeftH->SetMassMax(2638); + + POIfilterRightH->SetEtaMin(0.0); + POIfilterRightH->SetEtaMax(0.7); + POIfilterRightH->SetMassMin(2636); POIfilterRightH->SetMassMax(2638); + } + + + AliFlowTrackSimpleCuts *POIfilterQCH = new AliFlowTrackSimpleCuts(); + if(QC){ + POIfilterQCH->SetEtaMin(-0.7); + POIfilterQCH->SetEtaMax(0.7); + POIfilterQCH->SetMassMin(2636); POIfilterQCH->SetMassMax(2638); + + } + + } + + taskHFE->SetRPCuts(cutsRP); + + + AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName); + + mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer()); + mgr->ConnectOutput(taskHFE,1,coutput3); + + + if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; + AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); + mgr->ConnectOutput(taskHFE, 2, flowEvent); + if(debug) cout << " --> Created IO containers " << flowEvent << endl; + + if(SideBandsFlow){ + if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl; + AliAnalysisDataContainer *flowEventCont = mgr->CreateContainer(Form("FlowContainer_Cont_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer); + mgr->ConnectOutput(taskHFE, 3, flowEventCont); + if(debug) cout << " --> Created IO containers " << flowEventCont << endl; + } + + + mgr->AddTask(taskHFE); + + if (QC) { // add qc tasks + AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQC, NUA, shrinkSP, BaseH); + if(debug) cout << " --> Hanging QC task ...succes! "<< endl; + } + if (SP_TPC) { // add sp subevent tasks + AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; + AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterLeft, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; + } + if (VZERO_SP) { // add sp subevent tasks + AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterRight, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; + AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterLeft, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; + } + + //=========================================Flow event for elctronContamination============================================================================================== + if(SideBandsFlow){ + if (QC) { // add qc tasks + AddQCmethod(Form("QCTPCCont_%s",uniqueID.Data()), harmonic, flowEventCont, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQCH, NUA, shrinkSP,BaseH); + if(debug) cout << " --> Hanging QC task ...succes! "<< endl; + } + if (SP_TPC) { // add sp subevent tasks + AddSPmethod(Form("SPTPCQa_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterRightH, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl; + AddSPmethod(Form("SPTPCQb_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterLeftH, NUA,BaseH); + if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl; + } + } + //========================================================================================================================================================================== + + + return taskHFE; + +} + +//_____________________________________________________________________________ + + +//_____________________________________________________________________________ +void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, bool bEP, bool shrink = false, bool debug, TString uniqueID, Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter, Bool_t kNUA, Bool_t kBaseH) +{ + // add sp task and invm filter tasks + if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + (bEP) ? fileName+=":EP" : fileName+=":SP"; + // if(etagap) { + // fileName+="_SUBEVENTS"; + // if(debug) cout << " --> Setting up subevent analysis <-- " << endl; + // } + if(debug) cout << " --> fileName " << fileName << endl; + TString myFolder = fileName; + if(debug) cout << " --> myFolder " << myFolder << endl; + TString myNameSP; + (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector); + if(debug) cout << " myNameSP " << myNameSP << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter); + tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); + if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); + mgr->AddTask(tskFilter); + mgr->ConnectInput(tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEventOut); + AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); + AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE); + tskSP->SetApplyCorrectionForNUA(kNUA); + tskSP->SetHarmonic(harmonic); + tskSP->SetTotalQvector(Qvector); + if (bEP) tskSP->SetBehaveAsEP(); + if (shrink)tskSP->SetBookOnlyBasicCCH(kBaseH); + mgr->AddTask(tskSP); + mgr->ConnectInput(tskSP, 0, flowEventOut); + mgr->ConnectOutput(tskSP, 1, outSP); +} +//_____________________________________________________________________________ +void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, Bool_t debug, TString uniqueID,double minEtaA, double maxEtaA, double minEtaB, double maxEtaB,Bool_t VZERO_SP = kFALSE, AliFlowTrackSimpleCuts* POIfilter, Bool_t kNUA, bool shrink = false, Bool_t kBaseH) +{ + // add qc task and invm filter tasks + if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl; + TString fileName = AliAnalysisManager::GetCommonFileName(); + fileName+=":QC"; + if(debug) cout << " --> Common filename: " << fileName << endl; + TString myFolder = Form("v%d", harmonic); + if(debug) cout << " --> myFolder: " << myFolder << endl; + TString myName = Form("%s", name); + if(debug) cout << " --> myName: " << myName << endl; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter); + tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB); + // if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10); + mgr->AddTask(tskFilter); + mgr->ConnectInput(tskFilter, 0, flowEvent); + mgr->ConnectOutput(tskFilter, 1, flowEventOut); + + AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName); + AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE); + tskQC->SetApplyCorrectionForNUA(kNUA); + tskQC->SetHarmonic(harmonic); + if (shrink)tskQC->SetBookOnlyBasicCCH(kBaseH); + mgr->AddTask(tskQC); + mgr->ConnectInput(tskQC, 0, flowEventOut); + mgr->ConnectOutput(tskQC, 1, outQC); +} +//_____________________________________________________________________________ + + +//_____________________________________________________________________________ + +AliAnalysisTaskFlowTPCEMCalQCSP* ConfigHFEemcalMod(Bool_t useMC,Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel){ + // + // HFE standard task configuration + // + + Bool_t kAnalyseTaggedTracks = kTRUE; + + AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsEMCAL","HFE Standard Cuts"); //TODO....change the cuts values to PbPb + // hfecuts->CreateStandardCuts(); + hfecuts->SetMinNClustersTPC(minTPCCulster); + hfecuts->SetMinNClustersITS(3); + hfecuts->SetMinNTrackletsTRD(0); + hfecuts->SetMinRatioTPCclusters(0.6); + + // hfecuts->SetEtaRange(-0.9,0.9); + // hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); + hfecuts->SetRequireITSPixel(); + hfecuts->SetCutITSpixel(pixel);//kAny + hfecuts->SetMaxChi2perClusterITS(-1); + hfecuts->SetMaxChi2perClusterTPC(3.5); + hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back + // hfecuts->UnsetVertexRequirement(); + hfecuts->SetVertexRange(10.); + hfecuts->SetRequireSigmaToVertex(); + //hfecuts->SetSigmaToVertex(10); + hfecuts->SetTOFPIDStep(kFALSE); + // hfecuts->SetQAOn(); + hfecuts->SetPtRange(0, 30); + + AliAnalysisTaskFlowTPCEMCalQCSP *task = new AliAnalysisTaskFlowTPCEMCalQCSP("HFE_Flow_TPCEMCal"); + printf("task ------------------------ %p\n ", task); + + + task->SetHFECuts(hfecuts); + + // task->SetInvariantMassCut(0.05); + // task->SetRejectKinkMother(kTRUE); + // task->SetRemovePileUp(kTRUE); + + // Define PID + AliHFEpid *pid = task->GetPID(); + if(useMC) pid->SetHasMCData(kTRUE); + pid->AddDetector("TPC", 0); + pid->AddDetector("EMCAL", 1); + + printf("*************************************\n"); + printf("Configuring standard Task:\n"); + // task->PrintStatus(); + pid->PrintStatus(); + printf("*************************************\n"); + return task; + + +} + //_____________________________________________________________________________ \ No newline at end of file diff --git a/PWGHF/hfe/macros/AddTaskHFEnpePbPb.C b/PWGHF/hfe/macros/AddTaskHFEnpePbPb.C index 66a5623b956..f00e12c2f1a 100755 --- a/PWGHF/hfe/macros/AddTaskHFEnpePbPb.C +++ b/PWGHF/hfe/macros/AddTaskHFEnpePbPb.C @@ -1,167 +1,167 @@ -AliAnalysisTask *AddTaskHFEnpePbPb(Bool_t MCthere, - Bool_t isAOD, - Bool_t kNPERef = kTRUE, - Bool_t kNPEkAny = kFALSE, - Bool_t kNPERefMCf = kTRUE, - Bool_t kNPERefTPConly = kTRUE) -{ - // Default settings (TOF-TPC PbPb) - const int kDefTPCcl = 130; - const int kDefTPCclPID = 80; - const int kDefTPCclshared = 1.1; - const int kDefITScl = 4; - const int kDefITSchi2percluster = -1; // cleanup removes badly matching tracks - effects high pt (cut value = 36) - const double kDefDCAr = 1.; - const double kDefDCAz = 2.; - const double kDefTOFs = 3.; - const double kDefEtaIncMin = -0.8; - const double kDefEtaIncMax = 0.8; - const Bool_t etacorrection = kFALSE; - const Bool_t multicorrection = kTRUE; - - Double_t dEdxhm[12] = {3.11,3.11,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0}; - Double_t tpcl1[12] = {-0.14,-0.14,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3}; - - // Default setting for the associated electron for the NonPhotonic Analysis - const double kassETAm = -0.8; - const double kassETAp = 0.8; - const int kassITS = 2; - const int kassTPCcl = 60; - const int kassTPCPIDcl = 60; - const double kassDCAr = 1.0; - const double kassDCAz = 2.0; - const double kassTPCSminus = -3.0; - const double kassTPCSplus = 3.0; - - //get the current analysis manager - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - Error("AddTask_hfe_HFE", "No analysis manager found."); - return 0; - } - - //mgr->AddClassDebug("AliAnalysisTaskHFE",12); - - - AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); - - //@@ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - Double_t dEdxaclm[12], dEdxachm[12]; - for(int icent = 0; icent < 12; icent++){ - dEdxaclm[icent] = kassTPCSminus; - dEdxachm[icent] = kassTPCSplus; - } - - if(kNPERef){ - // ************************************************************** - // - // Reference task - // - // ************************************************************** - RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, - kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE,kFALSE); - } - - if(kNPEkAny){ - // ************************************************************** - // - // task for kAny instead of kBoth - // - // ************************************************************** - RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kAny, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, - kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE,kFALSE); - } - if(kNPERefMCf){ - // ************************************************************** - // - // Reference task + MC fake rejected - // - // ************************************************************** - RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, - kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE, kTRUE); - } - - if(kNPERefTPConly){ - // ************************************************************** - // - // Reference task - // - // ************************************************************** - RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, 0., AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, - kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE, kFALSE); - } - - return NULL; -} - -//=============================================================================== -AliAnalysisTask *RegisterTaskNPEPbPb(Bool_t useMC, Bool_t isAOD, - Int_t tpcCls=120, Int_t tpcClsPID=80, - Int_t itsCls=4, Double_t dcaxy=1.0, Double_t dcaz=2.0, - Double_t *tpcdEdxcutlow=NULL, Double_t *tpcdEdxcuthigh=NULL, - Double_t tofs=3., Int_t itshitpixel =AliHFEextraCuts::kBoth, - Double_t itschi2percluster = -1, Double_t tpcsharedcluster = 1.1, - Bool_t etacorr=kFALSE, Bool_t multicorr = kFALSE, - Double_t etaIncMin = -0.8, Double_t etaIncMax = 0.8, - Double_t assETAm=-0.8, Double_t assETAp=0.8, Int_t assITS=2, Int_t assTPCcl=100, - Int_t assTPCPIDcl=80, Double_t assDCAr=1.0, Double_t assDCAz=2.0, - Double_t *assTPCSminus = NULL, Double_t *assTPCSplus=NULL, - Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE, Bool_t rejectMCFake = kFALSE) -{ - - // - // Cuts on the inclusive leg - // - Int_t idcaxy = (Int_t)(dcaxy*10.); - Int_t idcaz = (Int_t)(dcaz*10.); - Int_t tpclow = 0; - if(tpcdEdxcutlow) tpclow = (Int_t) (tpcdEdxcutlow[0]*1000.); - Int_t itofs = (Int_t)(tofs*10.); - Int_t ipixelany = itshitpixel; - Int_t imult = multicorr ? 1 : 0; - - // - // Cuts on the associated leg - // - Int_t iassDCAr = (Int_t)(assDCAr*10); - Int_t iassDCAz = (Int_t)(assDCAz*10); - Int_t iassTPCSplus = assTPCSplus ? (Int_t)(assTPCSplus[0]*1000) : 0; - Int_t icat1 = useCat1Tracks ? 1 : 0; - Int_t icat2 = useCat2Tracks ? 1 : 0; - Int_t irejectMCFake = rejectMCFake ? 1 : 0; - - TString appendix(TString::Format("SPD%d_incTPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%dm%d_photTPCc%dTPCp%dITS%dDCAr%dDCAz%dTPCs%dMCf%d",ipixelany,tpcCls,tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,imult,assTPCcl,assTPCPIDcl,assITS,iassDCAr,iassDCAz,iassTPCSplus,irejectMCFake)); - - printf("Add macro appendix %s\n", appendix.Data()); - - if(!gROOT->GetListOfGlobalFunctions()->FindObject("ConfigHFEnpePbPb"))gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/ConfigHFEnpePbPb.C"); - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); - AliAnalysisTaskHFE *task = ConfigHFEnpePbPb(useMC, isAOD, appendix, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz, tpcdEdxcutlow, tpcdEdxcuthigh, tofs, 0, itshitpixel, itschi2percluster, tpcsharedcluster, etacorr, multicorr, etaIncMin, etaIncMax, - assETAm, assETAp, assITS, assTPCcl, assTPCPIDcl, assDCAr, assDCAz, assTPCSminus, assTPCSplus, useCat1Tracks, useCat2Tracks,rejectMCFake); - if(isAOD) - task->SetAODAnalysis(); - else - task->SetESDAnalysis(); - - if (useMC) task->SetHasMCData(kTRUE); - else task->SetHasMCData(kFALSE); - - task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral); - - TString containerName = mgr->GetCommonFileName(); - containerName += ":HFE"; - containerName += appendix.Data(); - printf("container name: %s\n", containerName.Data()); - - //create data containers - task->ConnectOutput(1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, containerName.Data())); - task->ConnectOutput(2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, containerName.Data())); - mgr->ConnectInput(task, 0, cinput ); - - mgr->AddTask(task); - - return NULL; -} +AliAnalysisTask *AddTaskHFEnpePbPb(Bool_t MCthere, + Bool_t isAOD, + Bool_t kNPERef = kTRUE, + Bool_t kNPEkAny = kFALSE, + Bool_t kNPERefMCf = kTRUE, + Bool_t kNPERefTPConly = kTRUE) +{ + // Default settings (TOF-TPC PbPb) + const int kDefTPCcl = 130; + const int kDefTPCclPID = 80; + const int kDefTPCclshared = 1.1; + const int kDefITScl = 4; + const int kDefITSchi2percluster = -1; // cleanup removes badly matching tracks - effects high pt (cut value = 36) + const double kDefDCAr = 1.; + const double kDefDCAz = 2.; + const double kDefTOFs = 3.; + const double kDefEtaIncMin = -0.8; + const double kDefEtaIncMax = 0.8; + const Bool_t etacorrection = kFALSE; + const Bool_t multicorrection = kTRUE; + + Double_t dEdxhm[12] = {3.11,3.11,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0}; + Double_t tpcl1[12] = {-0.14,-0.14,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3}; + + // Default setting for the associated electron for the NonPhotonic Analysis + const double kassETAm = -0.8; + const double kassETAp = 0.8; + const int kassITS = 2; + const int kassTPCcl = 60; + const int kassTPCPIDcl = 60; + const double kassDCAr = 1.0; + const double kassDCAz = 2.0; + const double kassTPCSminus = -3.0; + const double kassTPCSplus = 3.0; + + //get the current analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + Error("AddTask_hfe_HFE", "No analysis manager found."); + return 0; + } + + //mgr->AddClassDebug("AliAnalysisTaskHFE",12); + + + AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); + + //@@ 0 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + Double_t dEdxaclm[12], dEdxachm[12]; + for(int icent = 0; icent < 12; icent++){ + dEdxaclm[icent] = kassTPCSminus; + dEdxachm[icent] = kassTPCSplus; + } + + if(kNPERef){ + // ************************************************************** + // + // Reference task + // + // ************************************************************** + RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, + kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE,kFALSE); + } + + if(kNPEkAny){ + // ************************************************************** + // + // task for kAny instead of kBoth + // + // ************************************************************** + RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kAny, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, + kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE,kFALSE); + } + if(kNPERefMCf){ + // ************************************************************** + // + // Reference task + MC fake rejected + // + // ************************************************************** + RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, + kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE, kTRUE); + } + + if(kNPERefTPConly){ + // ************************************************************** + // + // Reference task + // + // ************************************************************** + RegisterTaskNPEPbPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, 0., AliHFEextraCuts::kBoth, kDefITSchi2percluster, kDefTPCclshared, etacorrection, multicorrection, kDefEtaIncMin, kDefEtaIncMax, + kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE, kFALSE); + } + + return NULL; +} + +//=============================================================================== +AliAnalysisTask *RegisterTaskNPEPbPb(Bool_t useMC, Bool_t isAOD, + Int_t tpcCls=120, Int_t tpcClsPID=80, + Int_t itsCls=4, Double_t dcaxy=1.0, Double_t dcaz=2.0, + Double_t *tpcdEdxcutlow=NULL, Double_t *tpcdEdxcuthigh=NULL, + Double_t tofs=3., Int_t itshitpixel =AliHFEextraCuts::kBoth, + Double_t itschi2percluster = -1, Double_t tpcsharedcluster = 1.1, + Bool_t etacorr=kFALSE, Bool_t multicorr = kFALSE, + Double_t etaIncMin = -0.8, Double_t etaIncMax = 0.8, + Double_t assETAm=-0.8, Double_t assETAp=0.8, Int_t assITS=2, Int_t assTPCcl=100, + Int_t assTPCPIDcl=80, Double_t assDCAr=1.0, Double_t assDCAz=2.0, + Double_t *assTPCSminus = NULL, Double_t *assTPCSplus=NULL, + Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE, Bool_t rejectMCFake = kFALSE) +{ + + // + // Cuts on the inclusive leg + // + Int_t idcaxy = (Int_t)(dcaxy*10.); + Int_t idcaz = (Int_t)(dcaz*10.); + Int_t tpclow = 0; + if(tpcdEdxcutlow) tpclow = (Int_t) (tpcdEdxcutlow[0]*1000.); + Int_t itofs = (Int_t)(tofs*10.); + Int_t ipixelany = itshitpixel; + Int_t imult = multicorr ? 1 : 0; + + // + // Cuts on the associated leg + // + Int_t iassDCAr = (Int_t)(assDCAr*10); + Int_t iassDCAz = (Int_t)(assDCAz*10); + Int_t iassTPCSplus = assTPCSplus ? (Int_t)(assTPCSplus[0]*1000) : 0; + Int_t icat1 = useCat1Tracks ? 1 : 0; + Int_t icat2 = useCat2Tracks ? 1 : 0; + Int_t irejectMCFake = rejectMCFake ? 1 : 0; + + TString appendix(TString::Format("SPD%d_incTPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%dm%d_photTPCc%dTPCp%dITS%dDCAr%dDCAz%dTPCs%dMCf%d",ipixelany,tpcCls,tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,imult,assTPCcl,assTPCPIDcl,assITS,iassDCAr,iassDCAz,iassTPCSplus,irejectMCFake)); + + printf("Add macro appendix %s\n", appendix.Data()); + + if(!gROOT->GetListOfGlobalFunctions()->FindObject("ConfigHFEnpePbPb"))gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/ConfigHFEnpePbPb.C"); + + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); + AliAnalysisTaskHFE *task = ConfigHFEnpePbPb(useMC, isAOD, appendix, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz, tpcdEdxcutlow, tpcdEdxcuthigh, tofs, 0, itshitpixel, itschi2percluster, tpcsharedcluster, etacorr, multicorr, etaIncMin, etaIncMax, + assETAm, assETAp, assITS, assTPCcl, assTPCPIDcl, assDCAr, assDCAz, assTPCSminus, assTPCSplus, useCat1Tracks, useCat2Tracks,rejectMCFake); + if(isAOD) + task->SetAODAnalysis(); + else + task->SetESDAnalysis(); + + if (useMC) task->SetHasMCData(kTRUE); + else task->SetHasMCData(kFALSE); + + task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral); + + TString containerName = mgr->GetCommonFileName(); + containerName += ":HFE"; + containerName += appendix.Data(); + printf("container name: %s\n", containerName.Data()); + + //create data containers + task->ConnectOutput(1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, containerName.Data())); + task->ConnectOutput(2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, containerName.Data())); + mgr->ConnectInput(task, 0, cinput ); + + mgr->AddTask(task); + + return NULL; +} diff --git a/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C b/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C index 0d6ba35ca6c..37f704f525d 100644 --- a/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C +++ b/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C @@ -1,86 +1,86 @@ -AliAnalysisTaskHFECal* ConfigHFECal(Bool_t useMC,Bool_t MassConst,Bool_t MassWidthCut,Bool_t MassCal,Bool_t MassNonlinear,Double_t asspTCut,Double_t angleCut,Double_t MassCut, Double_t NsigCut, Int_t fqa){ - // - // HFE standard task configuration - // - - printf("Setting in this analysis\n"); - printf("MassConst = %d/n",MassConst); - printf("MassCal = %d/n", MassCal); - printf("MassWidth = %d/n",MassWidthCut); - printf("asspTCut = %d/n",asspTCut); - printf("angleCut = %d/n",angleCut); - printf("MassCut = %d/n",MassCut); - printf("NsigCut = %d/n", NsigCut); - printf("qa = %d/n", fqa); - - Bool_t kAnalyseTaggedTracks = kTRUE; - - AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsEMCAL","HFE Standard Cuts"); - hfecuts->CreateStandardCuts(); - hfecuts->SetMinNClustersTPC(100); - hfecuts->SetMinRatioTPCclusters(0.6); - hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); - hfecuts->SetMinNClustersITS(3); - hfecuts->SetCutITSpixel(AliHFEextraCuts::kAny); - hfecuts->SetCheckITSLayerStatus(kFALSE); - hfecuts->SetVertexRange(10.); - hfecuts->SetTOFPIDStep(kFALSE); - hfecuts->SetPtRange(2, 50); - hfecuts->SetMaxImpactParam(3.,3.); - - AliAnalysisTaskHFECal *task = new AliAnalysisTaskHFECal("HFEanalysisEMCal"); - printf("task ------------------------ %p\n ", task); - task->SetHFECuts(hfecuts); - task->SetMassConstraint(MassConst); - task->SetMassWidthCut(MassWidthCut); - task->SetMassNonlinear(MassNonlinear); - //Double_t masscut = 0.05; - //if(!MassConst)masscut = 0.1; - Double_t masscut = MassCut; - task->SetInvariantMassCut(masscut); - task->SetOpeningAngleCut(angleCut); - task->SetMimpTassCut(asspTCut); - task->SetMimNsigassCut(NsigCut); - task->SetMassCalMethod(MassCal); - task->SetQAHist(fqa); - - // Define PID - AliHFEpid *pid = task->GetPID(); - if(useMC) pid->SetHasMCData(kTRUE); - pid->AddDetector("TPC", 0); - //pid->AddDetector("EMCAL", 1); - - Double_t params[4]; - char *cutmodel; - if(useMC){ - // Monte-Carlo needs modelling of the falling mean with momentum at low momentum - // for high momentum it is consistent with a flat -0.94 - //cutmodel = "[0]*TMath::Exp([1]*x) + [2] + [3]*x"; - //Double_t paramsMC[4] = {0.7174, -1.588, -0.9395, 0.0246}; - //for(int ipar = 0; ipar < 4; ipar++) params[ipar] = paramsMC[ipar]; - cutmodel = "pol0"; - params[0] = -1.0; //sigma min - } else { - // Data is consistent with a flat 0.12 - cutmodel = "pol0"; - //params[0] = -0.0015; - //params[0] = -3.0; - //params[0] = -0.05; //sigma min - params[0] = -1.0; //sigma min - } - //pid->ConfigureTPCdefaultCut(cutmodel, params,3.0); - for(Int_t a=0;a<11;a++)pid->ConfigureTPCcentralityCut(a,cutmodel,params,3.0); - - - // change E/p cuts - AliHFEpidEMCAL *emcpid = pid->AliHFEpid::GetDetPID(AliHFEpid::kEMCALpid); - emcpid->SetEoPMax(1.3); - emcpid->SetEoPMim(0.9); - - printf("*************************************\n"); - printf("Configuring standard Task:\n"); -// task->PrintStatus(); - pid->PrintStatus(); - printf("*************************************\n"); - return task; -} +AliAnalysisTaskHFECal* ConfigHFECal(Bool_t useMC,Bool_t MassConst,Bool_t MassWidthCut,Bool_t MassCal,Bool_t MassNonlinear,Double_t asspTCut,Double_t angleCut,Double_t MassCut, Double_t NsigCut, Int_t fqa){ + // + // HFE standard task configuration + // + + printf("Setting in this analysis\n"); + printf("MassConst = %d/n",MassConst); + printf("MassCal = %d/n", MassCal); + printf("MassWidth = %d/n",MassWidthCut); + printf("asspTCut = %d/n",asspTCut); + printf("angleCut = %d/n",angleCut); + printf("MassCut = %d/n",MassCut); + printf("NsigCut = %d/n", NsigCut); + printf("qa = %d/n", fqa); + + Bool_t kAnalyseTaggedTracks = kTRUE; + + AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsEMCAL","HFE Standard Cuts"); + hfecuts->CreateStandardCuts(); + hfecuts->SetMinNClustersTPC(100); + hfecuts->SetMinRatioTPCclusters(0.6); + hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); + hfecuts->SetMinNClustersITS(3); + hfecuts->SetCutITSpixel(AliHFEextraCuts::kAny); + hfecuts->SetCheckITSLayerStatus(kFALSE); + hfecuts->SetVertexRange(10.); + hfecuts->SetTOFPIDStep(kFALSE); + hfecuts->SetPtRange(2, 50); + hfecuts->SetMaxImpactParam(3.,3.); + + AliAnalysisTaskHFECal *task = new AliAnalysisTaskHFECal("HFEanalysisEMCal"); + printf("task ------------------------ %p\n ", task); + task->SetHFECuts(hfecuts); + task->SetMassConstraint(MassConst); + task->SetMassWidthCut(MassWidthCut); + task->SetMassNonlinear(MassNonlinear); + //Double_t masscut = 0.05; + //if(!MassConst)masscut = 0.1; + Double_t masscut = MassCut; + task->SetInvariantMassCut(masscut); + task->SetOpeningAngleCut(angleCut); + task->SetMimpTassCut(asspTCut); + task->SetMimNsigassCut(NsigCut); + task->SetMassCalMethod(MassCal); + task->SetQAHist(fqa); + + // Define PID + AliHFEpid *pid = task->GetPID(); + if(useMC) pid->SetHasMCData(kTRUE); + pid->AddDetector("TPC", 0); + //pid->AddDetector("EMCAL", 1); + + Double_t params[4]; + char *cutmodel; + if(useMC){ + // Monte-Carlo needs modelling of the falling mean with momentum at low momentum + // for high momentum it is consistent with a flat -0.94 + //cutmodel = "[0]*TMath::Exp([1]*x) + [2] + [3]*x"; + //Double_t paramsMC[4] = {0.7174, -1.588, -0.9395, 0.0246}; + //for(int ipar = 0; ipar < 4; ipar++) params[ipar] = paramsMC[ipar]; + cutmodel = "pol0"; + params[0] = -1.0; //sigma min + } else { + // Data is consistent with a flat 0.12 + cutmodel = "pol0"; + //params[0] = -0.0015; + //params[0] = -3.0; + //params[0] = -0.05; //sigma min + params[0] = -1.0; //sigma min + } + //pid->ConfigureTPCdefaultCut(cutmodel, params,3.0); + for(Int_t a=0;a<11;a++)pid->ConfigureTPCcentralityCut(a,cutmodel,params,3.0); + + + // change E/p cuts + AliHFEpidEMCAL *emcpid = pid->AliHFEpid::GetDetPID(AliHFEpid::kEMCALpid); + emcpid->SetEoPMax(1.3); + emcpid->SetEoPMim(0.9); + + printf("*************************************\n"); + printf("Configuring standard Task:\n"); +// task->PrintStatus(); + pid->PrintStatus(); + printf("*************************************\n"); + return task; +} diff --git a/PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.h b/PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.h index 7ded1067a13..b285c32376b 100644 --- a/PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.h +++ b/PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.h @@ -1,179 +1,179 @@ -#ifndef ALIANALYSISTASKSECHARMFRACTION_H -#define ALIANALYSISTASKSECHARMFRACTION_H - -/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//************************************************************************* -// Class AliAnalysisTaskSECharmFraction -// AliAnalysisTask for the extraction of the fraction of prompt charm -// using the charm hadron impact parameter to the primary vertex -// -// -// Author: Andrea Rossi andrea.rossi@pd.infn.it -//************************************************************************* - -class TH1F; -class TH2F; -class AliAODDEvent; -class AliAODMCHeader; -class AliAODRecoDecayHF2Prong; -class AliAODRecoDecayHF; -class AliAODMCParticle; -class AliAnalysisVertexingHF; -class AliRDHFCutsD0toKpi; -class AliNormalizationCounter; -class AliVertexingHFUtils; - -#include "AliAnalysisTaskSE.h" - -class AliAnalysisTaskSECharmFraction : public AliAnalysisTaskSE { - public: - AliAnalysisTaskSECharmFraction(); - AliAnalysisTaskSECharmFraction(const char *name); - AliAnalysisTaskSECharmFraction(const char *name,AliRDHFCutsD0toKpi *cutsA,AliRDHFCutsD0toKpi *cutsB); - - virtual ~AliAnalysisTaskSECharmFraction(); - - // Implementation of interface methods - virtual void UserCreateOutputObjects(); - virtual void Init(); - virtual void LocalInit() {Init();} - virtual void UserExec(Option_t *option); - virtual void Terminate(Option_t *option); - void SetReadMC(Bool_t readMC=kTRUE){fReadMC=readMC;} - void SetSplitMassD0D0bar(Bool_t splitD0D0bar=kTRUE){fsplitMassD0D0bar=splitD0D0bar;} - Bool_t GetIsSplitMassD0D0bar(){return fsplitMassD0D0bar;} - void SetUsePID(Bool_t pid){fusePID=pid;} - void SetAnalyzeLikeSign(Bool_t likesign=kFALSE){fLikeSign=likesign;} - void SetNMaxTrForVtx(const Int_t ntrMaxforVtx){fNtrMaxforVtx=ntrMaxforVtx;} - Int_t GetNMaxTrForVtx(){return fNtrMaxforVtx;} - void SetPtBins(Int_t nbins,const Float_t *ptbins); - void SetSignalInvMassCut(const Double_t signalInvMassCut=0.027){fsignalInvMassCut=signalInvMassCut;} - void SetLargeInvMassCut(const Double_t largeInvMassCut=2.){flargeInvMassCut=largeInvMassCut;} - void SetSideBandInvMassCut(const Double_t sidebandInvMassCut=0.054){// default value ~ 2x3 times inv mass resol.: a factor 2 is applied w.r.t. 3sigma, should be safe enough to exclude most of the reflections - fsidebandInvMassCut=sidebandInvMassCut; - } - void SetSideBandInvMassWindow(const Double_t sidebandInvMassWindow=0.108){//~ 6 times inv. mass resol. - fsidebandInvMassWindow=sidebandInvMassWindow; - } - void SetAcceptanceCut(const Double_t eta=0.8,const Double_t nITSpoints=5.,const Double_t nSPDpoints=2.){fAcceptanceCuts[0]=eta;fAcceptanceCuts[1]=nITSpoints;fAcceptanceCuts[2]=nSPDpoints;} - void SetStandardMassSelection(); - Int_t SetStandardCuts(Double_t pt,Double_t invMassCut); - Int_t SetStandardCuts(Float_t *&ptbinlimits); - void CheckInvMassD0(AliAODRecoDecayHF2Prong *d,Double_t &invMassD0,Double_t &invMassD0bar,Bool_t &isPeakD0,Bool_t &isPeakD0bar,Bool_t &isSideBandD0,Bool_t &isSideBandD0bar); - void SetAnalysisLevel(Int_t level){fFastAnalysis=level;} - void SetCheckBitD0flag(Bool_t checkfl){fcheckD0Bit=checkfl;} - Bool_t GetCheckBitD0flag(){return fcheckD0Bit;} - Int_t GetAnalysisLevel(){return fFastAnalysis;} - Int_t CheckOrigin(const TClonesArray* arrayMC, const AliAODMCParticle *mcPartCandidate)const; - AliAODRecoDecayHF *GetD0toKPiSignalType(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx); - AliAODRecoDecayHF *GetD0toKPiSignalTypeObsolete(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx); - AliAODRecoDecayHF* ConstructFakeTrueSecVtx(const AliAODMCParticle *b1,const AliAODMCParticle *b2,const AliAODMCParticle *mum,Double_t *primaryVtxTrue); - void SetUseMC(Bool_t useMC){fUseMC=useMC;} - Bool_t SpecialSelD0(AliAODRecoDecayHF2Prong *d,Int_t &nusedforVtx); - Bool_t FillAziList(AliAODEvent *aod,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t &nprim)const; - void FillAziHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t nprim,Int_t okD0,Int_t okD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar)const; - - AliAODVertex* GetPrimaryVtxSkipped(AliAODEvent *aodev,AliAODRecoDecayHF2Prong *d); - void SetRejecCandidateMCUpgrade(Bool_t selection){fselectForUpgrade=selection;} - void SetSkipEventSelection(Bool_t skip){fskipEventSelection=skip;} - void SetMaxZvtxForSkipEventSelection(Double_t zmax){fZvtxUpgr=zmax;} - /* ######### THE FOLLOWING IS FOR FURTHER IMPLEMENATION ############ - Int_t GetPtBin(Double_t pt)const; - void SetD0Cuts(Int_t ptbin,Double_t &*d0cutsLoose,Double_t &*d0cutsTight); - - // void InvMassSelection(); - - void SetCheckMC(Bool_t checkMC){fcheckMC=checkMC;} - void SetCheckMC_D0(Bool_t check_D0){fcheckMCD0=check_D0;} - void SetCheckMC_2prongs(Bool_t check2prongs){fcheckMC2prongs=check2prongs;} - void SetCheckMC_prompt(Bool_t checkprompt){fcheckMCprompt=checkprompt;} - void SetCheckMC_fromB(Bool_t checkfromB){fcheckMCfromB=checkfromB;} - void SetCheckMC_fromDstar(Bool_t skipD0star){fSkipD0star=skipD0star;} - void SetUseCuts(Bool_t usecuts){fD0usecuts=usecuts;} - void SetSideBands(Double_t sideband){fSideBands=sideband;} - void SetStudyPureBackground(Bool_t back){fStudyPureBackground=back;} - */ - AliRDHFCutsD0toKpi* GetLooseCut(){ - return fCutsLoose; - } - AliRDHFCutsD0toKpi* GetTightCut(){ - return fCutsTight; - } - /* void SetCutFunction(Int_t (*setcuts)(AliAnalysisTaskSECharmFraction*,Double_t,Double_t)){ - fSetCuts=setcuts; - fStandCuts=kFALSE; - } - */ - // Int_t SetCuts(AliAnalysisTaskSECharmFraction *alchfr,Double_t pt,Double_t invMassCut); - - private: - Bool_t FillHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Int_t okD0,Int_t okD0bar,Double_t invMassD0,Double_t invMassD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar,Double_t massmumtrue,AliAODRecoDecayHF *aodDMC,Double_t *vtxTrue); - void FillHistoMCproperties(TClonesArray *arrayMC); - - AliRDHFCutsD0toKpi *fCutsLoose; // Loose cuts object - AliRDHFCutsD0toKpi *fCutsTight; // Vertexer heavy flavour - Int_t fFastAnalysis; // Level of analysis speed: default is 1, switch it to 2 to fill the THnSparse - Bool_t fReadMC; // Flag To switch on/off access to MC - Bool_t fcheckD0Bit; // Flag to check the D0 bit flag - Bool_t fsplitMassD0D0bar; // Flag to use two shistos for D0 and D0bar invariant masses - Bool_t fLikeSign; // Flag to analyse Like Sign array - Bool_t fusePID; // Flag to use PID - Double_t fmD0PDG; // MC D0 mass - Int_t fnbins; // Number of pt bins - Float_t *fptbins; //[fnbins] ptbins - Int_t fNtrMaxforVtx; // N Max acceptable tracks used for vertex (0,1,2) - Double_t fptAll; //!Sum of pt of the reco tracks - Double_t fptAllSq; //!Sum of the square of the pt of the reco tracks - Double_t fptMax[3]; //!Three largest track pt in the event - Double_t fAcceptanceCuts[3]; // array with acceptance cuts - Double_t fsignalInvMassCut; // invariant mass cut to define signal region - Double_t flargeInvMassCut; // invariant mass cut to accept all inv mass window - Double_t fsidebandInvMassCut; // invariant mass cut to define side band region lower limit - Double_t fsidebandInvMassWindow; // invariant mass cut to define side band region width - Bool_t fUseMC; // flag to use or not MC info - Bool_t fCleanCandOwnVtx; // flag to switch on/off cleaning of the candidate own vtx - TH1F *fNentries; //!histo for #AOD analysed, container 1 - TH1F *fSignalType; //!histo for the type of MC signal , container 2 - TH1F *fSignalTypeLsCuts; //!histo for the type of MC signal with loose cuts , container 3 - TH1F *fSignalTypeTghCuts; //!histo for the type of MC signal with tight cuts, container 4 - AliNormalizationCounter *fCounter; //!counter for the normalization - TList *flistMCproperties; //!TLists for MC properties of D0 w.r.t. B mesons and c quarks cntainer 5 - TList *flistNoCutsSignal; //!TList for signal (D prompt) with nocuts, container 6 - TList *flistNoCutsBack; //!TList for background with nocuts, container 7 - TList *flistNoCutsFromB; //!TList for D from B or D from Dstar from Bwith nocuts, container 8 - TList *flistNoCutsFromDstar; //!TList for D from Dstar with nocuts, container 9 - TList *flistNoCutsOther; //!TList for others with nocuts, container 10 - TList *flistLsCutsSignal; //!TList for signal (D prompt) with loose cuts, container 11 - TList *flistLsCutsBack; //!TList for background with loose cuts, container 12 - TList *flistLsCutsFromB; //!TList for D from B or D from Dstar from B with loose cuts, container 13 - TList *flistLsCutsFromDstar; //!TList for D from Dstar with loose cuts, container 14 - TList *flistLsCutsOther; //!TList for others with loose cuts, container 15 - TList *flistTghCutsSignal; //!TList for signal (D prompt) with tight cuts, container 16 - TList *flistTghCutsBack; //!TList for backgrnd with tight cuts, container 17 - TList *flistTghCutsFromB; //!TList for D from B or D from Dstar from Bwith tight cuts, container 18 - TList *flistTghCutsFromDstar; //!TList for D from Dstar Dstar with tight cuts, container 19 - TList *flistTghCutsOther; //!TList for others with tight cuts, container 20 - AliVertexingHFUtils *fVertUtil; // vertexing HF Util - Bool_t fselectForUpgrade; // switch to reject candidates from HIJING and not Pythia for upgrade studies - Bool_t fskipEventSelection; // switch to skip event selection (for upgrade studies) - Double_t fZvtxUpgr; // cut value on max zvtx used ONLY if fskipEventSelection is kTRUE - /* Bool_t fD0usecuts; // Switch on the use of the cuts TO BE IMPLEMENTED - Bool_t fcheckMC; // Switch on MC check: minimum check is same mother TO BE IMPLEMENTED - Bool_t fcheckMCD0; // check the mother is a D0 TO BE IMPLEMENTED - Bool_t fcheckMC2prongs; // check the decay is in two prongs TO BE IMPLEMENTED - Bool_t fcheckMCprompt; // check the D0 comes from a c quark TO BE IMPLEMENTED - Bool_t fcheckMCfromB; // check the D0 comes from a b quark TO BE IMPLEMENTED - Bool_t fSkipD0star; // skip if D0 comes from a D* TO BE IMPLEMENTED - Bool_t fStudyd0fromBTrue; // Flag for analyze true impact par of D0 from B TO BE IMPLEMENTED - Bool_t fStudyPureBackground; // Flag to study the background (reverse the selection on the signal) TO BE IMPLEMENTED - Double_t fSideBands; //Side bands selection (see cxx) TO BE IMPLEMENTED - */ - AliAnalysisTaskSECharmFraction(const AliAnalysisTaskSECharmFraction&); // not implemented - AliAnalysisTaskSECharmFraction& operator=(const AliAnalysisTaskSECharmFraction&); // not implemented - - ClassDef(AliAnalysisTaskSECharmFraction,5); // analysis task for prompt charm fraction -}; - -#endif +#ifndef ALIANALYSISTASKSECHARMFRACTION_H +#define ALIANALYSISTASKSECHARMFRACTION_H + +/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//************************************************************************* +// Class AliAnalysisTaskSECharmFraction +// AliAnalysisTask for the extraction of the fraction of prompt charm +// using the charm hadron impact parameter to the primary vertex +// +// +// Author: Andrea Rossi andrea.rossi@pd.infn.it +//************************************************************************* + +class TH1F; +class TH2F; +class AliAODDEvent; +class AliAODMCHeader; +class AliAODRecoDecayHF2Prong; +class AliAODRecoDecayHF; +class AliAODMCParticle; +class AliAnalysisVertexingHF; +class AliRDHFCutsD0toKpi; +class AliNormalizationCounter; +class AliVertexingHFUtils; + +#include "AliAnalysisTaskSE.h" + +class AliAnalysisTaskSECharmFraction : public AliAnalysisTaskSE { + public: + AliAnalysisTaskSECharmFraction(); + AliAnalysisTaskSECharmFraction(const char *name); + AliAnalysisTaskSECharmFraction(const char *name,AliRDHFCutsD0toKpi *cutsA,AliRDHFCutsD0toKpi *cutsB); + + virtual ~AliAnalysisTaskSECharmFraction(); + + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *option); + void SetReadMC(Bool_t readMC=kTRUE){fReadMC=readMC;} + void SetSplitMassD0D0bar(Bool_t splitD0D0bar=kTRUE){fsplitMassD0D0bar=splitD0D0bar;} + Bool_t GetIsSplitMassD0D0bar(){return fsplitMassD0D0bar;} + void SetUsePID(Bool_t pid){fusePID=pid;} + void SetAnalyzeLikeSign(Bool_t likesign=kFALSE){fLikeSign=likesign;} + void SetNMaxTrForVtx(const Int_t ntrMaxforVtx){fNtrMaxforVtx=ntrMaxforVtx;} + Int_t GetNMaxTrForVtx(){return fNtrMaxforVtx;} + void SetPtBins(Int_t nbins,const Float_t *ptbins); + void SetSignalInvMassCut(const Double_t signalInvMassCut=0.027){fsignalInvMassCut=signalInvMassCut;} + void SetLargeInvMassCut(const Double_t largeInvMassCut=2.){flargeInvMassCut=largeInvMassCut;} + void SetSideBandInvMassCut(const Double_t sidebandInvMassCut=0.054){// default value ~ 2x3 times inv mass resol.: a factor 2 is applied w.r.t. 3sigma, should be safe enough to exclude most of the reflections + fsidebandInvMassCut=sidebandInvMassCut; + } + void SetSideBandInvMassWindow(const Double_t sidebandInvMassWindow=0.108){//~ 6 times inv. mass resol. + fsidebandInvMassWindow=sidebandInvMassWindow; + } + void SetAcceptanceCut(const Double_t eta=0.8,const Double_t nITSpoints=5.,const Double_t nSPDpoints=2.){fAcceptanceCuts[0]=eta;fAcceptanceCuts[1]=nITSpoints;fAcceptanceCuts[2]=nSPDpoints;} + void SetStandardMassSelection(); + Int_t SetStandardCuts(Double_t pt,Double_t invMassCut); + Int_t SetStandardCuts(Float_t *&ptbinlimits); + void CheckInvMassD0(AliAODRecoDecayHF2Prong *d,Double_t &invMassD0,Double_t &invMassD0bar,Bool_t &isPeakD0,Bool_t &isPeakD0bar,Bool_t &isSideBandD0,Bool_t &isSideBandD0bar); + void SetAnalysisLevel(Int_t level){fFastAnalysis=level;} + void SetCheckBitD0flag(Bool_t checkfl){fcheckD0Bit=checkfl;} + Bool_t GetCheckBitD0flag(){return fcheckD0Bit;} + Int_t GetAnalysisLevel(){return fFastAnalysis;} + Int_t CheckOrigin(const TClonesArray* arrayMC, const AliAODMCParticle *mcPartCandidate)const; + AliAODRecoDecayHF *GetD0toKPiSignalType(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx); + AliAODRecoDecayHF *GetD0toKPiSignalTypeObsolete(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx); + AliAODRecoDecayHF* ConstructFakeTrueSecVtx(const AliAODMCParticle *b1,const AliAODMCParticle *b2,const AliAODMCParticle *mum,Double_t *primaryVtxTrue); + void SetUseMC(Bool_t useMC){fUseMC=useMC;} + Bool_t SpecialSelD0(AliAODRecoDecayHF2Prong *d,Int_t &nusedforVtx); + Bool_t FillAziList(AliAODEvent *aod,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t &nprim)const; + void FillAziHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t nprim,Int_t okD0,Int_t okD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar)const; + + AliAODVertex* GetPrimaryVtxSkipped(AliAODEvent *aodev,AliAODRecoDecayHF2Prong *d); + void SetRejecCandidateMCUpgrade(Bool_t selection){fselectForUpgrade=selection;} + void SetSkipEventSelection(Bool_t skip){fskipEventSelection=skip;} + void SetMaxZvtxForSkipEventSelection(Double_t zmax){fZvtxUpgr=zmax;} + /* ######### THE FOLLOWING IS FOR FURTHER IMPLEMENATION ############ + Int_t GetPtBin(Double_t pt)const; + void SetD0Cuts(Int_t ptbin,Double_t &*d0cutsLoose,Double_t &*d0cutsTight); + + // void InvMassSelection(); + + void SetCheckMC(Bool_t checkMC){fcheckMC=checkMC;} + void SetCheckMC_D0(Bool_t check_D0){fcheckMCD0=check_D0;} + void SetCheckMC_2prongs(Bool_t check2prongs){fcheckMC2prongs=check2prongs;} + void SetCheckMC_prompt(Bool_t checkprompt){fcheckMCprompt=checkprompt;} + void SetCheckMC_fromB(Bool_t checkfromB){fcheckMCfromB=checkfromB;} + void SetCheckMC_fromDstar(Bool_t skipD0star){fSkipD0star=skipD0star;} + void SetUseCuts(Bool_t usecuts){fD0usecuts=usecuts;} + void SetSideBands(Double_t sideband){fSideBands=sideband;} + void SetStudyPureBackground(Bool_t back){fStudyPureBackground=back;} + */ + AliRDHFCutsD0toKpi* GetLooseCut(){ + return fCutsLoose; + } + AliRDHFCutsD0toKpi* GetTightCut(){ + return fCutsTight; + } + /* void SetCutFunction(Int_t (*setcuts)(AliAnalysisTaskSECharmFraction*,Double_t,Double_t)){ + fSetCuts=setcuts; + fStandCuts=kFALSE; + } + */ + // Int_t SetCuts(AliAnalysisTaskSECharmFraction *alchfr,Double_t pt,Double_t invMassCut); + + private: + Bool_t FillHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Int_t okD0,Int_t okD0bar,Double_t invMassD0,Double_t invMassD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar,Double_t massmumtrue,AliAODRecoDecayHF *aodDMC,Double_t *vtxTrue); + void FillHistoMCproperties(TClonesArray *arrayMC); + + AliRDHFCutsD0toKpi *fCutsLoose; // Loose cuts object + AliRDHFCutsD0toKpi *fCutsTight; // Vertexer heavy flavour + Int_t fFastAnalysis; // Level of analysis speed: default is 1, switch it to 2 to fill the THnSparse + Bool_t fReadMC; // Flag To switch on/off access to MC + Bool_t fcheckD0Bit; // Flag to check the D0 bit flag + Bool_t fsplitMassD0D0bar; // Flag to use two shistos for D0 and D0bar invariant masses + Bool_t fLikeSign; // Flag to analyse Like Sign array + Bool_t fusePID; // Flag to use PID + Double_t fmD0PDG; // MC D0 mass + Int_t fnbins; // Number of pt bins + Float_t *fptbins; //[fnbins] ptbins + Int_t fNtrMaxforVtx; // N Max acceptable tracks used for vertex (0,1,2) + Double_t fptAll; //!Sum of pt of the reco tracks + Double_t fptAllSq; //!Sum of the square of the pt of the reco tracks + Double_t fptMax[3]; //!Three largest track pt in the event + Double_t fAcceptanceCuts[3]; // array with acceptance cuts + Double_t fsignalInvMassCut; // invariant mass cut to define signal region + Double_t flargeInvMassCut; // invariant mass cut to accept all inv mass window + Double_t fsidebandInvMassCut; // invariant mass cut to define side band region lower limit + Double_t fsidebandInvMassWindow; // invariant mass cut to define side band region width + Bool_t fUseMC; // flag to use or not MC info + Bool_t fCleanCandOwnVtx; // flag to switch on/off cleaning of the candidate own vtx + TH1F *fNentries; //!histo for #AOD analysed, container 1 + TH1F *fSignalType; //!histo for the type of MC signal , container 2 + TH1F *fSignalTypeLsCuts; //!histo for the type of MC signal with loose cuts , container 3 + TH1F *fSignalTypeTghCuts; //!histo for the type of MC signal with tight cuts, container 4 + AliNormalizationCounter *fCounter; //!counter for the normalization + TList *flistMCproperties; //!TLists for MC properties of D0 w.r.t. B mesons and c quarks cntainer 5 + TList *flistNoCutsSignal; //!TList for signal (D prompt) with nocuts, container 6 + TList *flistNoCutsBack; //!TList for background with nocuts, container 7 + TList *flistNoCutsFromB; //!TList for D from B or D from Dstar from Bwith nocuts, container 8 + TList *flistNoCutsFromDstar; //!TList for D from Dstar with nocuts, container 9 + TList *flistNoCutsOther; //!TList for others with nocuts, container 10 + TList *flistLsCutsSignal; //!TList for signal (D prompt) with loose cuts, container 11 + TList *flistLsCutsBack; //!TList for background with loose cuts, container 12 + TList *flistLsCutsFromB; //!TList for D from B or D from Dstar from B with loose cuts, container 13 + TList *flistLsCutsFromDstar; //!TList for D from Dstar with loose cuts, container 14 + TList *flistLsCutsOther; //!TList for others with loose cuts, container 15 + TList *flistTghCutsSignal; //!TList for signal (D prompt) with tight cuts, container 16 + TList *flistTghCutsBack; //!TList for backgrnd with tight cuts, container 17 + TList *flistTghCutsFromB; //!TList for D from B or D from Dstar from Bwith tight cuts, container 18 + TList *flistTghCutsFromDstar; //!TList for D from Dstar Dstar with tight cuts, container 19 + TList *flistTghCutsOther; //!TList for others with tight cuts, container 20 + AliVertexingHFUtils *fVertUtil; // vertexing HF Util + Bool_t fselectForUpgrade; // switch to reject candidates from HIJING and not Pythia for upgrade studies + Bool_t fskipEventSelection; // switch to skip event selection (for upgrade studies) + Double_t fZvtxUpgr; // cut value on max zvtx used ONLY if fskipEventSelection is kTRUE + /* Bool_t fD0usecuts; // Switch on the use of the cuts TO BE IMPLEMENTED + Bool_t fcheckMC; // Switch on MC check: minimum check is same mother TO BE IMPLEMENTED + Bool_t fcheckMCD0; // check the mother is a D0 TO BE IMPLEMENTED + Bool_t fcheckMC2prongs; // check the decay is in two prongs TO BE IMPLEMENTED + Bool_t fcheckMCprompt; // check the D0 comes from a c quark TO BE IMPLEMENTED + Bool_t fcheckMCfromB; // check the D0 comes from a b quark TO BE IMPLEMENTED + Bool_t fSkipD0star; // skip if D0 comes from a D* TO BE IMPLEMENTED + Bool_t fStudyd0fromBTrue; // Flag for analyze true impact par of D0 from B TO BE IMPLEMENTED + Bool_t fStudyPureBackground; // Flag to study the background (reverse the selection on the signal) TO BE IMPLEMENTED + Double_t fSideBands; //Side bands selection (see cxx) TO BE IMPLEMENTED + */ + AliAnalysisTaskSECharmFraction(const AliAnalysisTaskSECharmFraction&); // not implemented + AliAnalysisTaskSECharmFraction& operator=(const AliAnalysisTaskSECharmFraction&); // not implemented + + ClassDef(AliAnalysisTaskSECharmFraction,5); // analysis task for prompt charm fraction +}; + +#endif diff --git a/PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.h b/PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.h index c5c246ea90b..7591009ac64 100644 --- a/PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.h +++ b/PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.h @@ -1,127 +1,127 @@ -#ifndef ALIANALYSISTASKFLAVOURJETCORRELATIONS_H -#define ALIANALYSISTASKFLAVOURJETCORRELATIONS_H -/************************************************************************** - * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -//----------------------------------------------------------------------- -// Author : A. Grelli, Utrecht University -// C. Bianchin, Utrecht University -// X. Zhang, LBNL -//----------------------------------------------------------------------- - - -#include -#include "AliAODEvent.h" -#include "AliPicoTrack.h" -#include "AliAnalysisTaskEmcalJet.h" - -class TH3F; -class TParticle ; -class TClonesArray ; -class AliMCParticle; -class AliAODMCParticle; -class AliRDHFCuts; -class AliEmcalJet; -class AliAODRecoDecayHF; -class AliAODRecoCascadeHF; -class AliAODEvent; - -class AliAnalysisTaskFlavourJetCorrelations : public AliAnalysisTaskEmcalJet -{ - - public: - - enum ECandidateType{ kD0toKpi, kDstartoKpipi }; - - AliAnalysisTaskFlavourJetCorrelations(); - AliAnalysisTaskFlavourJetCorrelations(const Char_t* name,AliRDHFCuts* cuts, ECandidateType candtype); - virtual ~AliAnalysisTaskFlavourJetCorrelations(); - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *option); - virtual void Terminate(Option_t *); - virtual void Init(); - virtual void LocalInit() {Init();} - - // inizializations - Bool_t DefineHistoForAnalysis(); - - // set MC usage - void SetMC(Bool_t theMCon) {fUseMCInfo = theMCon;} - Bool_t GetMC() const {return fUseMCInfo;} - // set usage of reconstructed tracks - void SetUseReco(Bool_t reco) {fUseReco=reco;} - Bool_t GetUseReco() {return fUseReco;} - - - void SetMassLimits(Double_t range, Int_t pdg); - void SetMassLimits(Double_t lowlimit, Double_t uplimit); - - //jet reconstruction algorithm - void SetJetArrayName(TString jetArrName) {fJetArrName=jetArrName;}; - TString GetJetArrayName() const {return fJetArrName;}; - - // trigger on jet events - void SetTriggerOnLeadingJet(Bool_t triggerOnLeadingJet) {fLeadingJetOnly=triggerOnLeadingJet;}; - Bool_t GetTriggerOnLeadingJet() const {return fLeadingJetOnly;} - - - // Array of D0 width for the Dstar - Bool_t SetD0WidthForDStar(Int_t nptbins,Float_t* width); - - //Bool_t FillMCDJetInfo(AliPicoTrack *jetTrk,AliEmcalJet* jet, TClonesArray *mcArray,Double_t ptjet); - void FillHistogramsRecoJetCorr(AliVParticle* candidate, AliEmcalJet *jet); - void FillHistogramsD0JetCorr(AliAODRecoDecayHF* candidate, Double_t dPhi, Double_t z, Double_t ptD, Double_t ptj, Double_t deltaR, AliAODEvent* aodEvent); - - void FillHistogramsDstarJetCorr(AliAODRecoCascadeHF* dstar, Double_t dPhi, Double_t z, Double_t ptD, Double_t ptj,Double_t deltaR); - void FillHistogramsMCGenDJetCorr(Double_t dPhi, Double_t z,Double_t ptD,Double_t ptjet,Double_t deltaR); - void SideBandBackground(AliAODRecoCascadeHF *candDstar, AliEmcalJet *jet); - void MCBackground(AliAODRecoDecayHF *candbg, AliEmcalJet *jet); - void FillMassHistograms(Double_t mass,Double_t ptD, Double_t deltaR); - void FlagFlavour(AliVParticle* charm, AliEmcalJet* jet); +#ifndef ALIANALYSISTASKFLAVOURJETCORRELATIONS_H +#define ALIANALYSISTASKFLAVOURJETCORRELATIONS_H +/************************************************************************** + * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//----------------------------------------------------------------------- +// Author : A. Grelli, Utrecht University +// C. Bianchin, Utrecht University +// X. Zhang, LBNL +//----------------------------------------------------------------------- + + +#include +#include "AliAODEvent.h" +#include "AliPicoTrack.h" +#include "AliAnalysisTaskEmcalJet.h" + +class TH3F; +class TParticle ; +class TClonesArray ; +class AliMCParticle; +class AliAODMCParticle; +class AliRDHFCuts; +class AliEmcalJet; +class AliAODRecoDecayHF; +class AliAODRecoCascadeHF; +class AliAODEvent; + +class AliAnalysisTaskFlavourJetCorrelations : public AliAnalysisTaskEmcalJet +{ + + public: + + enum ECandidateType{ kD0toKpi, kDstartoKpipi }; + + AliAnalysisTaskFlavourJetCorrelations(); + AliAnalysisTaskFlavourJetCorrelations(const Char_t* name,AliRDHFCuts* cuts, ECandidateType candtype); + virtual ~AliAnalysisTaskFlavourJetCorrelations(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + virtual void Init(); + virtual void LocalInit() {Init();} + + // inizializations + Bool_t DefineHistoForAnalysis(); + + // set MC usage + void SetMC(Bool_t theMCon) {fUseMCInfo = theMCon;} + Bool_t GetMC() const {return fUseMCInfo;} + // set usage of reconstructed tracks + void SetUseReco(Bool_t reco) {fUseReco=reco;} + Bool_t GetUseReco() {return fUseReco;} + + + void SetMassLimits(Double_t range, Int_t pdg); + void SetMassLimits(Double_t lowlimit, Double_t uplimit); + + //jet reconstruction algorithm + void SetJetArrayName(TString jetArrName) {fJetArrName=jetArrName;}; + TString GetJetArrayName() const {return fJetArrName;}; + + // trigger on jet events + void SetTriggerOnLeadingJet(Bool_t triggerOnLeadingJet) {fLeadingJetOnly=triggerOnLeadingJet;}; + Bool_t GetTriggerOnLeadingJet() const {return fLeadingJetOnly;} + + + // Array of D0 width for the Dstar + Bool_t SetD0WidthForDStar(Int_t nptbins,Float_t* width); + + //Bool_t FillMCDJetInfo(AliPicoTrack *jetTrk,AliEmcalJet* jet, TClonesArray *mcArray,Double_t ptjet); + void FillHistogramsRecoJetCorr(AliVParticle* candidate, AliEmcalJet *jet); + void FillHistogramsD0JetCorr(AliAODRecoDecayHF* candidate, Double_t dPhi, Double_t z, Double_t ptD, Double_t ptj, Double_t deltaR, AliAODEvent* aodEvent); + + void FillHistogramsDstarJetCorr(AliAODRecoCascadeHF* dstar, Double_t dPhi, Double_t z, Double_t ptD, Double_t ptj,Double_t deltaR); + void FillHistogramsMCGenDJetCorr(Double_t dPhi, Double_t z,Double_t ptD,Double_t ptjet,Double_t deltaR); + void SideBandBackground(AliAODRecoCascadeHF *candDstar, AliEmcalJet *jet); + void MCBackground(AliAODRecoDecayHF *candbg, AliEmcalJet *jet); + void FillMassHistograms(Double_t mass,Double_t ptD, Double_t deltaR); + void FlagFlavour(AliVParticle* charm, AliEmcalJet* jet); Int_t IsDzeroSideBand(AliAODRecoCascadeHF *candDstar); - - private: - - AliAnalysisTaskFlavourJetCorrelations(const AliAnalysisTaskFlavourJetCorrelations &source); - AliAnalysisTaskFlavourJetCorrelations& operator=(const AliAnalysisTaskFlavourJetCorrelations& source); - - Double_t Z(AliVParticle* part,AliEmcalJet* jet) const; - Float_t DeltaR(AliVParticle *p1, AliVParticle *p2) const; - - - Bool_t fUseMCInfo; // Use MC info - Bool_t fUseReco; // use reconstructed tracks when running on MC - Int_t fCandidateType; // Dstar or D0 - Int_t fPDGmother; // PDG code of D meson - Int_t fNProngs; // number of prong of the decay channel - Int_t fPDGdaughters[4]; // PDG codes of daughters - Float_t fSigmaD0[30]; // - TString fBranchName; // AOD branch name - TList *fmyOutput; //! user output - AliRDHFCuts *fCuts; // Cuts - - Double_t fMinMass; // mass lower limit histogram - Double_t fMaxMass; // mass upper limit histogram - - TString fJetArrName; // name of the jet array, taken from the task running the jet finder - TString fCandArrName; // string which correspond to the candidate type - Bool_t fLeadingJetOnly; // use only the leading jet in the event to make the correlations - Double_t fJetRadius; // jet radius (filled from the JetContainer) - - ClassDef(AliAnalysisTaskFlavourJetCorrelations,2); // class for charm-jet correlations -}; - -#endif + + private: + + AliAnalysisTaskFlavourJetCorrelations(const AliAnalysisTaskFlavourJetCorrelations &source); + AliAnalysisTaskFlavourJetCorrelations& operator=(const AliAnalysisTaskFlavourJetCorrelations& source); + + Double_t Z(AliVParticle* part,AliEmcalJet* jet) const; + Float_t DeltaR(AliVParticle *p1, AliVParticle *p2) const; + + + Bool_t fUseMCInfo; // Use MC info + Bool_t fUseReco; // use reconstructed tracks when running on MC + Int_t fCandidateType; // Dstar or D0 + Int_t fPDGmother; // PDG code of D meson + Int_t fNProngs; // number of prong of the decay channel + Int_t fPDGdaughters[4]; // PDG codes of daughters + Float_t fSigmaD0[30]; // + TString fBranchName; // AOD branch name + TList *fmyOutput; //! user output + AliRDHFCuts *fCuts; // Cuts + + Double_t fMinMass; // mass lower limit histogram + Double_t fMaxMass; // mass upper limit histogram + + TString fJetArrName; // name of the jet array, taken from the task running the jet finder + TString fCandArrName; // string which correspond to the candidate type + Bool_t fLeadingJetOnly; // use only the leading jet in the event to make the correlations + Double_t fJetRadius; // jet radius (filled from the JetContainer) + + ClassDef(AliAnalysisTaskFlavourJetCorrelations,2); // class for charm-jet correlations +}; + +#endif diff --git a/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.cxx b/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.cxx index 19f66d962c1..cf0a0e61449 100644 --- a/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.cxx +++ b/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.cxx @@ -1,563 +1,563 @@ -/************************************************************************** -* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * -**************************************************************************/ -// -// -// Task for selecting D mesons to be used as an input for D-Jet correlations -// -//----------------------------------------------------------------------- -// Authors: -// C. Bianchin (Utrecht University) chiara.bianchin@cern.ch -// A.Grelli (Utrecht University) a.grelli@uu.nl -// Xiaoming Zhang (LBNL) XMZhang@lbl.gov -//----------------------------------------------------------------------- - -#include -#include -#include -#include "TROOT.h" -#include - -#include "AliRDHFCutsDStartoKpipi.h" -#include "AliRDHFCutsD0toKpi.h" -#include "AliAODMCHeader.h" -#include "AliAODHandler.h" -#include "AliAnalysisManager.h" -#include "AliLog.h" -#include "AliAODVertex.h" -#include "AliAODRecoDecay.h" -#include "AliAODRecoCascadeHF.h" -#include "AliAODRecoDecayHF2Prong.h" -#include "AliESDtrack.h" -#include "AliAODMCParticle.h" -#include "AliAnalysisTaskSEDmesonsFilterCJ.h" - -ClassImp(AliAnalysisTaskSEDmesonsFilterCJ) - -//_______________________________________________________________________________ - -AliAnalysisTaskSEDmesonsFilterCJ::AliAnalysisTaskSEDmesonsFilterCJ() : -AliAnalysisTaskSE(), -fUseMCInfo(kFALSE), -fUseReco(kTRUE), -fCandidateType(0), -fCandidateName(""), -fPDGmother(0), -fNProngs(0), -fBranchName(""), -fOutput(0), -fCuts(0), -fMinMass(0.), -fMaxMass(0.), -fCandidateArray(0) - -{ - // - // Default constructor - // - - for (Int_t i=4; i--;) fPDGdaughters[i] = 0; - for (Int_t i=30; i--;) fSigmaD0[i] = 0.; -} - -//_______________________________________________________________________________ - -AliAnalysisTaskSEDmesonsFilterCJ::AliAnalysisTaskSEDmesonsFilterCJ(const char *name, AliRDHFCuts *cuts, ECandidateType candtype) : -AliAnalysisTaskSE(name), -fUseMCInfo(kFALSE), -fUseReco(kTRUE), -fCandidateType(candtype), -fCandidateName(""), -fPDGmother(0), -fNProngs(0), -fBranchName(""), -fOutput(0), -fCuts(cuts), -fMinMass(0.), -fMaxMass(0.), -fCandidateArray(0) -{ - // - // Constructor. Initialization of Inputs and Outputs - // - - Info("AliAnalysisTaskSEDmesonsFilterCJ","Calling Constructor"); - - for (Int_t i=4; i--;) fPDGdaughters[i] = 0; - for (Int_t i=30; i--;) fSigmaD0[i] = 0.; - - const Int_t nptbins = fCuts->GetNPtBins(); - Float_t defaultSigmaD013[13] = { 0.012, 0.012, 0.012, 0.015, 0.015, 0.018, 0.018, 0.020, 0.020, 0.030, 0.030, 0.037, 0.040 }; - - switch (fCandidateType) { - case 0 : - fCandidateName = "D0"; - fPDGmother = 421; - fNProngs = 2; - fPDGdaughters[0] = 211; // pi - fPDGdaughters[1] = 321; // K - fPDGdaughters[2] = 0; // empty - fPDGdaughters[3] = 0; // empty - fBranchName = "D0toKpi"; - break; - case 1 : - fCandidateName = "Dstar"; - fPDGmother = 413; - fNProngs = 3; - fPDGdaughters[1] = 211; // pi soft - fPDGdaughters[0] = 421; // D0 - fPDGdaughters[2] = 211; // pi fromD0 - fPDGdaughters[3] = 321; // K from D0 - fBranchName = "Dstar"; - - if (nptbins<=13) { - for (Int_t ipt=0; ipt1) printf("AnalysisTaskSEDmesonsForJetCorrelations::Init() \n"); - - switch (fCandidateType) { - case 0: { - AliRDHFCutsD0toKpi* copyfCutsDzero = new AliRDHFCutsD0toKpi(*(static_cast(fCuts))); - copyfCutsDzero->SetName("AnalysisCutsDzero"); - PostData(2, copyfCutsDzero); // Post the data - } break; -case 1: { - AliRDHFCutsDStartoKpipi* copyfCutsDstar = new AliRDHFCutsDStartoKpipi(*(static_cast(fCuts))); - copyfCutsDstar->SetName("AnalysisCutsDStar"); - PostData(2, copyfCutsDstar); // Post the cuts -} break; -default: return; - } - - return; -} - -//_______________________________________________________________________________ - -void AliAnalysisTaskSEDmesonsFilterCJ::UserCreateOutputObjects() -{ - // - // output - // - - Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName()); - - fOutput = new TList(); fOutput->SetOwner(); - DefineHistoForAnalysis(); // define histograms - - fCandidateArray = new TClonesArray("AliAODRecoDecayHF",0); - fCandidateArray->SetName(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")); - - if (fCandidateType==kDstartoKpipi){ - fSideBandArray = new TClonesArray("AliAODRecoCascadeHF",0); //this is for the DStar only! - fSideBandArray->SetName(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")); - } - - PostData(1, fOutput); - return; -} - -//_______________________________________________________________________________ - -void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){ - // - // user exec - // - - // add cadidate branch - fCandidateArray->Delete(); - if (!(InputEvent()->FindListObject(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fCandidateArray); - if (fCandidateType==kDstartoKpipi){ - fSideBandArray->Delete(); - if (!(InputEvent()->FindListObject(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fSideBandArray); - } - //Printf("Arr names %s, %s",fCandidateArray->GetName(),fSideBandArray->GetName()); - // Load the event - AliAODEvent *aodEvent = dynamic_cast(fInputEvent); - - TClonesArray *arrayDStartoD0pi = 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(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(); - arrayDStartoD0pi = (TClonesArray*)aodFromExt->GetList()->FindObject(fBranchName.Data()); - } - } else { - arrayDStartoD0pi = (TClonesArray*)aodEvent->GetList()->FindObject(fBranchName.Data()); - } - - if (!arrayDStartoD0pi) { - AliInfo(Form("Could not find array %s, skipping the event",fBranchName.Data())); - return; - } else { - AliDebug(2, Form("Found %d vertices",arrayDStartoD0pi->GetEntriesFast())); - } - - TClonesArray* mcArray = 0x0; - if (fUseMCInfo) { - mcArray = dynamic_cast(aodEvent->FindListObject(AliAODMCParticle::StdBranchName())); - if (!mcArray) { - printf("AliAnalysisTaskSEDStarSpectra::UserExec: MC particles not found!\n"); - return; - } - } - - //Histograms - TH1I* hstat = (TH1I*)fOutput->FindObject("hstat"); - TH1F* hnSBCandEv=(TH1F*)fOutput->FindObject("hnSBCandEv"); - TH1F* hnCandEv=(TH1F*)fOutput->FindObject("hnCandEv"); - TH2F* hInvMassptD = (TH2F*)fOutput->FindObject("hInvMassptD"); - - TH1F* hPtPion=0x0; - if (fCandidateType==kDstartoKpipi) hPtPion = (TH1F*)fOutput->FindObject("hPtPion"); - hstat->Fill(0); - - // fix for temporary bug in ESDfilter - // the AODs with null vertex pointer didn't pass the PhysSel - if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return; - - //Event selection - Bool_t iseventselected=fCuts->IsEventSelected(aodEvent); - //TString firedTriggerClasses=((AliAODEvent*)aodEvent)->GetFiredTriggerClasses(); - if (!iseventselected) return; - hstat->Fill(1); - - const Int_t nD = arrayDStartoD0pi->GetEntriesFast(); - if(fUseReco) hstat->Fill(2, nD); - - //D* and D0 prongs needed to MatchToMC method - Int_t pdgDgDStartoD0pi[2] = { 421, 211 }; // D0,pi - Int_t pdgDgD0toKpi[2] = { 321, 211 }; // K, pi - - //D0 from D0 bar - Int_t pdgdaughtersD0[2] = { 211, 321 }; // pi,K - Int_t pdgdaughtersD0bar[2] = { 321, 211 }; // K,pi - - Int_t iCand =0; - Int_t iSBCand=0; - Int_t isSelected = 0; - AliAODRecoDecayHF *charmCand = 0; - AliAODMCParticle *charmPart = 0; - Bool_t isMCBkg=kFALSE; - - Double_t mPDGD0 = TDatabasePDG::Instance()->GetParticle(421)->Mass(); - - Int_t mcLabel = -9999; - Int_t pdgMeson = 413; - if (fCandidateType==kD0toKpi) pdgMeson = 421; - - for (Int_t icharm=0; icharmAt(icharm); // D candidates - if (!charmCand) continue; - - - if (fUseMCInfo) { // Look in MC, try to simulate the z - if (fCandidateType==kDstartoKpipi) { - AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; - mcLabel = temp->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,mcArray); - } - - if (fCandidateType==kD0toKpi) - mcLabel = charmCand->MatchToMC(421,mcArray,fNProngs,fPDGdaughters); - - if (mcLabel<=0) isMCBkg=kTRUE; - else hstat->Fill(2); - if (!isMCBkg) charmPart=(AliAODMCParticle*)mcArray->At(mcLabel); - } - - Double_t ptD = charmCand->Pt(); - - // region of interest + cuts - if (!fCuts->IsInFiducialAcceptance(ptD,charmCand->Y(pdgMeson))) continue; - - if(!fUseMCInfo && fCandidateType==kDstartoKpipi){ - //select by track cuts the side band candidates (don't want mass cut) - isSelected = fCuts->IsSelected(charmCand,AliRDHFCuts::kTracks,aodEvent); - if (!isSelected) continue; - //add a reasonable cut on the invariant mass (e.g. (+-2\sigma, +-10 \sigma), with \sigma = fSigmaD0[bin]) - Int_t bin = fCuts->PtBin(ptD); - if(bin<0 || bin>=fCuts->GetNPtBins()) { - AliError(Form("Pt %.3f out of bounds",ptD)); - continue; - } - AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; - //if data and Dstar from D0 side band - if (((temp->InvMassD0()<=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()>(mPDGD0-10.*fSigmaD0[bin]))) /*left side band*/|| ((temp->InvMassD0()>=(mPDGD0+3.*fSigmaD0[bin])) && (temp->InvMassD0()<(mPDGD0+10.*fSigmaD0[bin])))/*right side band*/){ - - new ((*fSideBandArray)[iSBCand]) AliAODRecoCascadeHF(*temp); - iSBCand++; - } - } - //candidate selected by cuts and PID - isSelected = fCuts->IsSelected(charmCand,AliRDHFCuts::kAll,aodEvent); //selected - if (!isSelected) continue; - - //for data and MC signal fill fCandidateArray - if(!fUseMCInfo || (fUseMCInfo && !isMCBkg)){ - // for data or MC with the requirement fUseReco fill with candidates - if(fUseReco) { - new ((*fCandidateArray)[iCand]) AliAODRecoDecayHF(*charmCand); - //Printf("Filling reco"); - hstat->Fill(3); - } - // for MC with requirement particle level fill with AliAODMCParticle - else if (fUseMCInfo) { - new ((*fCandidateArray)[iCand]) AliAODMCParticle(*charmPart); - //Printf("Filling gen"); - hstat->Fill(3); - } - - iCand++; - } - //for MC background fill fSideBandArray (which is instead filled above for DStar in case of data for the side bands candidates) - else if(fUseReco){ - new ((*fSideBandArray)[iSBCand]) AliAODRecoDecayHF(*charmCand); - iSBCand++; - } - - - Double_t masses[2]; - if (fCandidateType==kDstartoKpipi) { //D*->D0pi->Kpipi - - //softpion from D* decay - AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; - AliAODTrack *track2 = (AliAODTrack*)temp->GetBachelor(); - - // select D* in the D0 window. - // In the cut object window is loose to allow for side bands - - - // retrieve the corresponding pt bin for the candidate - // and set the expected D0 width (x3) - // static const Int_t n = fCuts->GetNPtBins(); - Int_t bin = fCuts->PtBin(ptD); - if(bin<0 || bin>=fCuts->GetNPtBins()) { - AliError(Form("Pt %.3f out of bounds",ptD)); - continue; - } - - AliInfo(Form("Pt bin %d and sigma D0 %.4f",bin,fSigmaD0[bin])); - //consider the Dstar candidates only if the mass of the D0 is in 3 sigma wrt the PDG value - if ((temp->InvMassD0()>=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()<=(mPDGD0+3.*fSigmaD0[bin]))) { - masses[0] = temp->DeltaInvMass(); //D* - masses[1] = 0.; //dummy for D* - - //D* delta mass - hInvMassptD->Fill(masses[0], ptD); // 2 D slice for pt bins - - // D* pt and soft pion pt for good candidates - Double_t mPDGDstar = TDatabasePDG::Instance()->GetParticle(413)->Mass(); - Double_t invmassDelta = temp->DeltaInvMass(); - if (TMath::Abs(invmassDelta-(mPDGDstar-mPDGD0))<0.0021) hPtPion->Fill(track2->Pt()); - } - } //Dstar specific - - if (fCandidateType==kD0toKpi) { //D0->Kpi - - //needed quantities - masses[0] = charmCand->InvMass(fNProngs, (UInt_t*)pdgdaughtersD0); //D0 - masses[1] = charmCand->InvMass(fNProngs, (UInt_t*)pdgdaughtersD0bar); //D0bar - hstat->Fill(3); - - // mass vs pt - if (isSelected==1 || isSelected==3) hInvMassptD->Fill(masses[0],ptD); - if (isSelected>=2) hInvMassptD->Fill(masses[1],ptD); - } //D0 specific - - charmCand = 0; - isMCBkg=kFALSE; - } // end of D cand loop - - hnCandEv->Fill(fCandidateArray->GetEntriesFast()); - if (fCandidateType==kDstartoKpipi || fUseMCInfo) { - Int_t nsbcand=fSideBandArray->GetEntriesFast(); - hstat->Fill(4,nsbcand); - hnSBCandEv->Fill(nsbcand); - } - - return; -} - -//_______________________________________________________________________________ - -void AliAnalysisTaskSEDmesonsFilterCJ::Terminate(Option_t*) -{ - // The Terminate() function is the last function to be called during - // a query. It always runs on the client, it can be used to present - // the results graphically or save the results to file. - - Info("Terminate"," terminate"); - AliAnalysisTaskSE::Terminate(); - - fOutput = dynamic_cast(GetOutputData(1)); - if (!fOutput) { - printf("ERROR: fOutput not available\n"); - return; - } - - return; -} - -//_______________________________________________________________________________ - -void AliAnalysisTaskSEDmesonsFilterCJ::SetMassLimits(Double_t range, Int_t pdg) -{ - // - // AliAnalysisTaskSEDmesonsFilterCJ::SetMassLimits - // - - Float_t mass = TDatabasePDG::Instance()->GetParticle(TMath::Abs(pdg))->Mass(); - - // compute the Delta mass for the D* - if (fCandidateType==kDstartoKpipi) mass -= TDatabasePDG::Instance()->GetParticle(421)->Mass(); - - - fMinMass = mass - range; - fMaxMass = mass + range; - - AliInfo(Form("Setting mass limits to %f, %f",fMinMass,fMaxMass)); - if ((fMinMass<0.) || (fMaxMass<=0.) || (fMaxMasslowlimit) { - fMinMass = lowlimit; - fMaxMass = uplimit; - } else { - printf("Error! Lower limit larger than upper limit!\n"); - fMinMass = uplimit - uplimit*0.2; - fMaxMass = uplimit; - } - - return; -} - -//_______________________________________________________________________________ - -Bool_t AliAnalysisTaskSEDmesonsFilterCJ::SetD0WidthForDStar(Int_t nptbins, Float_t *width) -{ - // - // AliAnalysisTaskSEDmesonsFilterCJ::SetD0WidthForDStar - // - - if (nptbins>30) { - AliInfo("Maximum number of bins allowed is 30!"); - return kFALSE; - } - - if (!width) return kFALSE; - for (Int_t ipt=0; iptGetXaxis()->SetBinLabel(1, "N ev anal"); - hstat->GetXaxis()->SetBinLabel(2, "N ev sel"); - if(fUseReco) hstat->GetXaxis()->SetBinLabel(3, "N cand"); - else hstat->GetXaxis()->SetBinLabel(3, "N Gen D"); - hstat->GetXaxis()->SetBinLabel(4, "N cand sel cuts"); - if (fCandidateType==kDstartoKpipi) hstat->GetXaxis()->SetBinLabel(5, "N side band cand"); - hstat->SetNdivisions(1); - fOutput->Add(hstat); - - TH1F* hnCandEv=new TH1F("hnCandEv", "Number of candidates per event (after cuts);# cand/ev", 100, 0.,100.); - fOutput->Add(hnCandEv); - - // Invariant mass related histograms - const Int_t nbinsmass = 200; - TH2F *hInvMass = new TH2F("hInvMassptD", "D invariant mass distribution", nbinsmass, fMinMass, fMaxMass, 100, 0., 50.); - hInvMass->SetStats(kTRUE); - hInvMass->GetXaxis()->SetTitle("mass (GeV/c)"); - hInvMass->GetYaxis()->SetTitle("p_{T} (GeV/c)"); - fOutput->Add(hInvMass); - - if (fCandidateType==kDstartoKpipi) { - TH1F* hnSBCandEv=new TH1F("hnSBCandEv", "Number of side bands candidates per event (after cuts);# cand/ev", 100, 0.,100.); - fOutput->Add(hnSBCandEv); - - TH1F* hPtPion = new TH1F("hPtPion", "Primary pions candidates pt", 500, 0., 10.); - hPtPion->SetStats(kTRUE); - hPtPion->GetXaxis()->SetTitle("p_{T} (GeV/c)"); - hPtPion->GetYaxis()->SetTitle("entries"); - fOutput->Add(hPtPion); - } - - return kTRUE; -} +/************************************************************************** +* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ +// +// +// Task for selecting D mesons to be used as an input for D-Jet correlations +// +//----------------------------------------------------------------------- +// Authors: +// C. Bianchin (Utrecht University) chiara.bianchin@cern.ch +// A.Grelli (Utrecht University) a.grelli@uu.nl +// Xiaoming Zhang (LBNL) XMZhang@lbl.gov +//----------------------------------------------------------------------- + +#include +#include +#include +#include "TROOT.h" +#include + +#include "AliRDHFCutsDStartoKpipi.h" +#include "AliRDHFCutsD0toKpi.h" +#include "AliAODMCHeader.h" +#include "AliAODHandler.h" +#include "AliAnalysisManager.h" +#include "AliLog.h" +#include "AliAODVertex.h" +#include "AliAODRecoDecay.h" +#include "AliAODRecoCascadeHF.h" +#include "AliAODRecoDecayHF2Prong.h" +#include "AliESDtrack.h" +#include "AliAODMCParticle.h" +#include "AliAnalysisTaskSEDmesonsFilterCJ.h" + +ClassImp(AliAnalysisTaskSEDmesonsFilterCJ) + +//_______________________________________________________________________________ + +AliAnalysisTaskSEDmesonsFilterCJ::AliAnalysisTaskSEDmesonsFilterCJ() : +AliAnalysisTaskSE(), +fUseMCInfo(kFALSE), +fUseReco(kTRUE), +fCandidateType(0), +fCandidateName(""), +fPDGmother(0), +fNProngs(0), +fBranchName(""), +fOutput(0), +fCuts(0), +fMinMass(0.), +fMaxMass(0.), +fCandidateArray(0) + +{ + // + // Default constructor + // + + for (Int_t i=4; i--;) fPDGdaughters[i] = 0; + for (Int_t i=30; i--;) fSigmaD0[i] = 0.; +} + +//_______________________________________________________________________________ + +AliAnalysisTaskSEDmesonsFilterCJ::AliAnalysisTaskSEDmesonsFilterCJ(const char *name, AliRDHFCuts *cuts, ECandidateType candtype) : +AliAnalysisTaskSE(name), +fUseMCInfo(kFALSE), +fUseReco(kTRUE), +fCandidateType(candtype), +fCandidateName(""), +fPDGmother(0), +fNProngs(0), +fBranchName(""), +fOutput(0), +fCuts(cuts), +fMinMass(0.), +fMaxMass(0.), +fCandidateArray(0) +{ + // + // Constructor. Initialization of Inputs and Outputs + // + + Info("AliAnalysisTaskSEDmesonsFilterCJ","Calling Constructor"); + + for (Int_t i=4; i--;) fPDGdaughters[i] = 0; + for (Int_t i=30; i--;) fSigmaD0[i] = 0.; + + const Int_t nptbins = fCuts->GetNPtBins(); + Float_t defaultSigmaD013[13] = { 0.012, 0.012, 0.012, 0.015, 0.015, 0.018, 0.018, 0.020, 0.020, 0.030, 0.030, 0.037, 0.040 }; + + switch (fCandidateType) { + case 0 : + fCandidateName = "D0"; + fPDGmother = 421; + fNProngs = 2; + fPDGdaughters[0] = 211; // pi + fPDGdaughters[1] = 321; // K + fPDGdaughters[2] = 0; // empty + fPDGdaughters[3] = 0; // empty + fBranchName = "D0toKpi"; + break; + case 1 : + fCandidateName = "Dstar"; + fPDGmother = 413; + fNProngs = 3; + fPDGdaughters[1] = 211; // pi soft + fPDGdaughters[0] = 421; // D0 + fPDGdaughters[2] = 211; // pi fromD0 + fPDGdaughters[3] = 321; // K from D0 + fBranchName = "Dstar"; + + if (nptbins<=13) { + for (Int_t ipt=0; ipt1) printf("AnalysisTaskSEDmesonsForJetCorrelations::Init() \n"); + + switch (fCandidateType) { + case 0: { + AliRDHFCutsD0toKpi* copyfCutsDzero = new AliRDHFCutsD0toKpi(*(static_cast(fCuts))); + copyfCutsDzero->SetName("AnalysisCutsDzero"); + PostData(2, copyfCutsDzero); // Post the data + } break; +case 1: { + AliRDHFCutsDStartoKpipi* copyfCutsDstar = new AliRDHFCutsDStartoKpipi(*(static_cast(fCuts))); + copyfCutsDstar->SetName("AnalysisCutsDStar"); + PostData(2, copyfCutsDstar); // Post the cuts +} break; +default: return; + } + + return; +} + +//_______________________________________________________________________________ + +void AliAnalysisTaskSEDmesonsFilterCJ::UserCreateOutputObjects() +{ + // + // output + // + + Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName()); + + fOutput = new TList(); fOutput->SetOwner(); + DefineHistoForAnalysis(); // define histograms + + fCandidateArray = new TClonesArray("AliAODRecoDecayHF",0); + fCandidateArray->SetName(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")); + + if (fCandidateType==kDstartoKpipi){ + fSideBandArray = new TClonesArray("AliAODRecoCascadeHF",0); //this is for the DStar only! + fSideBandArray->SetName(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")); + } + + PostData(1, fOutput); + return; +} + +//_______________________________________________________________________________ + +void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){ + // + // user exec + // + + // add cadidate branch + fCandidateArray->Delete(); + if (!(InputEvent()->FindListObject(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fCandidateArray); + if (fCandidateType==kDstartoKpipi){ + fSideBandArray->Delete(); + if (!(InputEvent()->FindListObject(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fSideBandArray); + } + //Printf("Arr names %s, %s",fCandidateArray->GetName(),fSideBandArray->GetName()); + // Load the event + AliAODEvent *aodEvent = dynamic_cast(fInputEvent); + + TClonesArray *arrayDStartoD0pi = 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(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(); + arrayDStartoD0pi = (TClonesArray*)aodFromExt->GetList()->FindObject(fBranchName.Data()); + } + } else { + arrayDStartoD0pi = (TClonesArray*)aodEvent->GetList()->FindObject(fBranchName.Data()); + } + + if (!arrayDStartoD0pi) { + AliInfo(Form("Could not find array %s, skipping the event",fBranchName.Data())); + return; + } else { + AliDebug(2, Form("Found %d vertices",arrayDStartoD0pi->GetEntriesFast())); + } + + TClonesArray* mcArray = 0x0; + if (fUseMCInfo) { + mcArray = dynamic_cast(aodEvent->FindListObject(AliAODMCParticle::StdBranchName())); + if (!mcArray) { + printf("AliAnalysisTaskSEDStarSpectra::UserExec: MC particles not found!\n"); + return; + } + } + + //Histograms + TH1I* hstat = (TH1I*)fOutput->FindObject("hstat"); + TH1F* hnSBCandEv=(TH1F*)fOutput->FindObject("hnSBCandEv"); + TH1F* hnCandEv=(TH1F*)fOutput->FindObject("hnCandEv"); + TH2F* hInvMassptD = (TH2F*)fOutput->FindObject("hInvMassptD"); + + TH1F* hPtPion=0x0; + if (fCandidateType==kDstartoKpipi) hPtPion = (TH1F*)fOutput->FindObject("hPtPion"); + hstat->Fill(0); + + // fix for temporary bug in ESDfilter + // the AODs with null vertex pointer didn't pass the PhysSel + if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return; + + //Event selection + Bool_t iseventselected=fCuts->IsEventSelected(aodEvent); + //TString firedTriggerClasses=((AliAODEvent*)aodEvent)->GetFiredTriggerClasses(); + if (!iseventselected) return; + hstat->Fill(1); + + const Int_t nD = arrayDStartoD0pi->GetEntriesFast(); + if(fUseReco) hstat->Fill(2, nD); + + //D* and D0 prongs needed to MatchToMC method + Int_t pdgDgDStartoD0pi[2] = { 421, 211 }; // D0,pi + Int_t pdgDgD0toKpi[2] = { 321, 211 }; // K, pi + + //D0 from D0 bar + Int_t pdgdaughtersD0[2] = { 211, 321 }; // pi,K + Int_t pdgdaughtersD0bar[2] = { 321, 211 }; // K,pi + + Int_t iCand =0; + Int_t iSBCand=0; + Int_t isSelected = 0; + AliAODRecoDecayHF *charmCand = 0; + AliAODMCParticle *charmPart = 0; + Bool_t isMCBkg=kFALSE; + + Double_t mPDGD0 = TDatabasePDG::Instance()->GetParticle(421)->Mass(); + + Int_t mcLabel = -9999; + Int_t pdgMeson = 413; + if (fCandidateType==kD0toKpi) pdgMeson = 421; + + for (Int_t icharm=0; icharmAt(icharm); // D candidates + if (!charmCand) continue; + + + if (fUseMCInfo) { // Look in MC, try to simulate the z + if (fCandidateType==kDstartoKpipi) { + AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; + mcLabel = temp->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,mcArray); + } + + if (fCandidateType==kD0toKpi) + mcLabel = charmCand->MatchToMC(421,mcArray,fNProngs,fPDGdaughters); + + if (mcLabel<=0) isMCBkg=kTRUE; + else hstat->Fill(2); + if (!isMCBkg) charmPart=(AliAODMCParticle*)mcArray->At(mcLabel); + } + + Double_t ptD = charmCand->Pt(); + + // region of interest + cuts + if (!fCuts->IsInFiducialAcceptance(ptD,charmCand->Y(pdgMeson))) continue; + + if(!fUseMCInfo && fCandidateType==kDstartoKpipi){ + //select by track cuts the side band candidates (don't want mass cut) + isSelected = fCuts->IsSelected(charmCand,AliRDHFCuts::kTracks,aodEvent); + if (!isSelected) continue; + //add a reasonable cut on the invariant mass (e.g. (+-2\sigma, +-10 \sigma), with \sigma = fSigmaD0[bin]) + Int_t bin = fCuts->PtBin(ptD); + if(bin<0 || bin>=fCuts->GetNPtBins()) { + AliError(Form("Pt %.3f out of bounds",ptD)); + continue; + } + AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; + //if data and Dstar from D0 side band + if (((temp->InvMassD0()<=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()>(mPDGD0-10.*fSigmaD0[bin]))) /*left side band*/|| ((temp->InvMassD0()>=(mPDGD0+3.*fSigmaD0[bin])) && (temp->InvMassD0()<(mPDGD0+10.*fSigmaD0[bin])))/*right side band*/){ + + new ((*fSideBandArray)[iSBCand]) AliAODRecoCascadeHF(*temp); + iSBCand++; + } + } + //candidate selected by cuts and PID + isSelected = fCuts->IsSelected(charmCand,AliRDHFCuts::kAll,aodEvent); //selected + if (!isSelected) continue; + + //for data and MC signal fill fCandidateArray + if(!fUseMCInfo || (fUseMCInfo && !isMCBkg)){ + // for data or MC with the requirement fUseReco fill with candidates + if(fUseReco) { + new ((*fCandidateArray)[iCand]) AliAODRecoDecayHF(*charmCand); + //Printf("Filling reco"); + hstat->Fill(3); + } + // for MC with requirement particle level fill with AliAODMCParticle + else if (fUseMCInfo) { + new ((*fCandidateArray)[iCand]) AliAODMCParticle(*charmPart); + //Printf("Filling gen"); + hstat->Fill(3); + } + + iCand++; + } + //for MC background fill fSideBandArray (which is instead filled above for DStar in case of data for the side bands candidates) + else if(fUseReco){ + new ((*fSideBandArray)[iSBCand]) AliAODRecoDecayHF(*charmCand); + iSBCand++; + } + + + Double_t masses[2]; + if (fCandidateType==kDstartoKpipi) { //D*->D0pi->Kpipi + + //softpion from D* decay + AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand; + AliAODTrack *track2 = (AliAODTrack*)temp->GetBachelor(); + + // select D* in the D0 window. + // In the cut object window is loose to allow for side bands + + + // retrieve the corresponding pt bin for the candidate + // and set the expected D0 width (x3) + // static const Int_t n = fCuts->GetNPtBins(); + Int_t bin = fCuts->PtBin(ptD); + if(bin<0 || bin>=fCuts->GetNPtBins()) { + AliError(Form("Pt %.3f out of bounds",ptD)); + continue; + } + + AliInfo(Form("Pt bin %d and sigma D0 %.4f",bin,fSigmaD0[bin])); + //consider the Dstar candidates only if the mass of the D0 is in 3 sigma wrt the PDG value + if ((temp->InvMassD0()>=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()<=(mPDGD0+3.*fSigmaD0[bin]))) { + masses[0] = temp->DeltaInvMass(); //D* + masses[1] = 0.; //dummy for D* + + //D* delta mass + hInvMassptD->Fill(masses[0], ptD); // 2 D slice for pt bins + + // D* pt and soft pion pt for good candidates + Double_t mPDGDstar = TDatabasePDG::Instance()->GetParticle(413)->Mass(); + Double_t invmassDelta = temp->DeltaInvMass(); + if (TMath::Abs(invmassDelta-(mPDGDstar-mPDGD0))<0.0021) hPtPion->Fill(track2->Pt()); + } + } //Dstar specific + + if (fCandidateType==kD0toKpi) { //D0->Kpi + + //needed quantities + masses[0] = charmCand->InvMass(fNProngs, (UInt_t*)pdgdaughtersD0); //D0 + masses[1] = charmCand->InvMass(fNProngs, (UInt_t*)pdgdaughtersD0bar); //D0bar + hstat->Fill(3); + + // mass vs pt + if (isSelected==1 || isSelected==3) hInvMassptD->Fill(masses[0],ptD); + if (isSelected>=2) hInvMassptD->Fill(masses[1],ptD); + } //D0 specific + + charmCand = 0; + isMCBkg=kFALSE; + } // end of D cand loop + + hnCandEv->Fill(fCandidateArray->GetEntriesFast()); + if (fCandidateType==kDstartoKpipi || fUseMCInfo) { + Int_t nsbcand=fSideBandArray->GetEntriesFast(); + hstat->Fill(4,nsbcand); + hnSBCandEv->Fill(nsbcand); + } + + return; +} + +//_______________________________________________________________________________ + +void AliAnalysisTaskSEDmesonsFilterCJ::Terminate(Option_t*) +{ + // The Terminate() function is the last function to be called during + // a query. It always runs on the client, it can be used to present + // the results graphically or save the results to file. + + Info("Terminate"," terminate"); + AliAnalysisTaskSE::Terminate(); + + fOutput = dynamic_cast(GetOutputData(1)); + if (!fOutput) { + printf("ERROR: fOutput not available\n"); + return; + } + + return; +} + +//_______________________________________________________________________________ + +void AliAnalysisTaskSEDmesonsFilterCJ::SetMassLimits(Double_t range, Int_t pdg) +{ + // + // AliAnalysisTaskSEDmesonsFilterCJ::SetMassLimits + // + + Float_t mass = TDatabasePDG::Instance()->GetParticle(TMath::Abs(pdg))->Mass(); + + // compute the Delta mass for the D* + if (fCandidateType==kDstartoKpipi) mass -= TDatabasePDG::Instance()->GetParticle(421)->Mass(); + + + fMinMass = mass - range; + fMaxMass = mass + range; + + AliInfo(Form("Setting mass limits to %f, %f",fMinMass,fMaxMass)); + if ((fMinMass<0.) || (fMaxMass<=0.) || (fMaxMasslowlimit) { + fMinMass = lowlimit; + fMaxMass = uplimit; + } else { + printf("Error! Lower limit larger than upper limit!\n"); + fMinMass = uplimit - uplimit*0.2; + fMaxMass = uplimit; + } + + return; +} + +//_______________________________________________________________________________ + +Bool_t AliAnalysisTaskSEDmesonsFilterCJ::SetD0WidthForDStar(Int_t nptbins, Float_t *width) +{ + // + // AliAnalysisTaskSEDmesonsFilterCJ::SetD0WidthForDStar + // + + if (nptbins>30) { + AliInfo("Maximum number of bins allowed is 30!"); + return kFALSE; + } + + if (!width) return kFALSE; + for (Int_t ipt=0; iptGetXaxis()->SetBinLabel(1, "N ev anal"); + hstat->GetXaxis()->SetBinLabel(2, "N ev sel"); + if(fUseReco) hstat->GetXaxis()->SetBinLabel(3, "N cand"); + else hstat->GetXaxis()->SetBinLabel(3, "N Gen D"); + hstat->GetXaxis()->SetBinLabel(4, "N cand sel cuts"); + if (fCandidateType==kDstartoKpipi) hstat->GetXaxis()->SetBinLabel(5, "N side band cand"); + hstat->SetNdivisions(1); + fOutput->Add(hstat); + + TH1F* hnCandEv=new TH1F("hnCandEv", "Number of candidates per event (after cuts);# cand/ev", 100, 0.,100.); + fOutput->Add(hnCandEv); + + // Invariant mass related histograms + const Int_t nbinsmass = 200; + TH2F *hInvMass = new TH2F("hInvMassptD", "D invariant mass distribution", nbinsmass, fMinMass, fMaxMass, 100, 0., 50.); + hInvMass->SetStats(kTRUE); + hInvMass->GetXaxis()->SetTitle("mass (GeV/c)"); + hInvMass->GetYaxis()->SetTitle("p_{T} (GeV/c)"); + fOutput->Add(hInvMass); + + if (fCandidateType==kDstartoKpipi) { + TH1F* hnSBCandEv=new TH1F("hnSBCandEv", "Number of side bands candidates per event (after cuts);# cand/ev", 100, 0.,100.); + fOutput->Add(hnSBCandEv); + + TH1F* hPtPion = new TH1F("hPtPion", "Primary pions candidates pt", 500, 0., 10.); + hPtPion->SetStats(kTRUE); + hPtPion->GetXaxis()->SetTitle("p_{T} (GeV/c)"); + hPtPion->GetYaxis()->SetTitle("entries"); + fOutput->Add(hPtPion); + } + + return kTRUE; +} diff --git a/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.h b/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.h index 3370f78799a..5ff17a2fa36 100644 --- a/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.h +++ b/PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.h @@ -1,102 +1,102 @@ -#ifndef ALIANALYSISTASKSEDMESONSFILTERCJ_H -#define ALIANALYSISTASKSEDMESONSFILTERCJ_H -/************************************************************************** - * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -//----------------------------------------------------------------------- -// Author : A. Grelli, Utrecht University -// C. Bianchin, Utrecht University -// X. Zhang, LBNL -//----------------------------------------------------------------------- - - -#include -#include "AliAODEvent.h" -#include "AliPicoTrack.h" -#include "AliAnalysisTaskSE.h" - -class TH3F; -class TString; -class TParticle ; -class TClonesArray ; -class AliMCParticle; -class AliAODMCParticle; -class AliRDHFCuts; -class AliAODRecoCascadeHF; - -class AliAnalysisTaskSEDmesonsFilterCJ : public AliAnalysisTaskSE -{ - - public : - - enum ECandidateType{ kD0toKpi, kDstartoKpipi }; - - AliAnalysisTaskSEDmesonsFilterCJ(); - AliAnalysisTaskSEDmesonsFilterCJ(const Char_t* name,AliRDHFCuts* cuts,ECandidateType candtype); - virtual ~AliAnalysisTaskSEDmesonsFilterCJ(); - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *option); - virtual void Terminate(Option_t *); - virtual void Init(); - virtual void LocalInit() { Init(); } - - // inizializations - Bool_t DefineHistoForAnalysis(); - - // set MC usage - void SetMC(Bool_t theMCon) { fUseMCInfo = theMCon; } - Bool_t GetMC() const { return fUseMCInfo; } - - // set usage of generated or reconstucted quantities (relevant for MC) - void SetUseReco(Bool_t useReco=kTRUE) { fUseReco= useReco;} - Bool_t GetUseReco() const {return fUseReco;} - - void SetMassLimits(Double_t range, Int_t pdg); - void SetMassLimits(Double_t lowlimit, Double_t uplimit); - - // Array of D0 width for the Dstar - Bool_t SetD0WidthForDStar(Int_t nptbins, Float_t *width); - - private : - - AliAnalysisTaskSEDmesonsFilterCJ(const AliAnalysisTaskSEDmesonsFilterCJ &source); - AliAnalysisTaskSEDmesonsFilterCJ& operator=(const AliAnalysisTaskSEDmesonsFilterCJ& source); - - Bool_t fUseMCInfo; // Use MC info - Bool_t fUseReco; // use reconstructed tracks when running on MC - - UInt_t fCandidateType; // Dstar or D0 - TString fCandidateName; // Dstar or D0 - - Int_t fPDGmother; // PDG code of D meson - Int_t fNProngs; // number of prong of the decay channel - Int_t fPDGdaughters[4]; // PDG codes of daughters - Float_t fSigmaD0[30]; // D0 sigma for Dstar - - TString fBranchName; // AOD branch name - TList *fOutput; //! user output - - AliRDHFCuts *fCuts; // Cuts - Double_t fMinMass; // mass lower limit histogram - Double_t fMaxMass; // mass upper limit histogram - - TClonesArray *fCandidateArray; //! contains candidates selected by AliRDHFCuts - TClonesArray *fSideBandArray; //! contains candidates selected by AliRDHFCuts::IsSelected(kTracks), to be used for side bands (DStar case only!!) - - ClassDef(AliAnalysisTaskSEDmesonsFilterCJ,2); // class for charm-jet correlations -}; - -#endif +#ifndef ALIANALYSISTASKSEDMESONSFILTERCJ_H +#define ALIANALYSISTASKSEDMESONSFILTERCJ_H +/************************************************************************** + * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//----------------------------------------------------------------------- +// Author : A. Grelli, Utrecht University +// C. Bianchin, Utrecht University +// X. Zhang, LBNL +//----------------------------------------------------------------------- + + +#include +#include "AliAODEvent.h" +#include "AliPicoTrack.h" +#include "AliAnalysisTaskSE.h" + +class TH3F; +class TString; +class TParticle ; +class TClonesArray ; +class AliMCParticle; +class AliAODMCParticle; +class AliRDHFCuts; +class AliAODRecoCascadeHF; + +class AliAnalysisTaskSEDmesonsFilterCJ : public AliAnalysisTaskSE +{ + + public : + + enum ECandidateType{ kD0toKpi, kDstartoKpipi }; + + AliAnalysisTaskSEDmesonsFilterCJ(); + AliAnalysisTaskSEDmesonsFilterCJ(const Char_t* name,AliRDHFCuts* cuts,ECandidateType candtype); + virtual ~AliAnalysisTaskSEDmesonsFilterCJ(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + virtual void Init(); + virtual void LocalInit() { Init(); } + + // inizializations + Bool_t DefineHistoForAnalysis(); + + // set MC usage + void SetMC(Bool_t theMCon) { fUseMCInfo = theMCon; } + Bool_t GetMC() const { return fUseMCInfo; } + + // set usage of generated or reconstucted quantities (relevant for MC) + void SetUseReco(Bool_t useReco=kTRUE) { fUseReco= useReco;} + Bool_t GetUseReco() const {return fUseReco;} + + void SetMassLimits(Double_t range, Int_t pdg); + void SetMassLimits(Double_t lowlimit, Double_t uplimit); + + // Array of D0 width for the Dstar + Bool_t SetD0WidthForDStar(Int_t nptbins, Float_t *width); + + private : + + AliAnalysisTaskSEDmesonsFilterCJ(const AliAnalysisTaskSEDmesonsFilterCJ &source); + AliAnalysisTaskSEDmesonsFilterCJ& operator=(const AliAnalysisTaskSEDmesonsFilterCJ& source); + + Bool_t fUseMCInfo; // Use MC info + Bool_t fUseReco; // use reconstructed tracks when running on MC + + UInt_t fCandidateType; // Dstar or D0 + TString fCandidateName; // Dstar or D0 + + Int_t fPDGmother; // PDG code of D meson + Int_t fNProngs; // number of prong of the decay channel + Int_t fPDGdaughters[4]; // PDG codes of daughters + Float_t fSigmaD0[30]; // D0 sigma for Dstar + + TString fBranchName; // AOD branch name + TList *fOutput; //! user output + + AliRDHFCuts *fCuts; // Cuts + Double_t fMinMass; // mass lower limit histogram + Double_t fMaxMass; // mass upper limit histogram + + TClonesArray *fCandidateArray; //! contains candidates selected by AliRDHFCuts + TClonesArray *fSideBandArray; //! contains candidates selected by AliRDHFCuts::IsSelected(kTracks), to be used for side bands (DStar case only!!) + + ClassDef(AliAnalysisTaskSEDmesonsFilterCJ,2); // class for charm-jet correlations +}; + +#endif diff --git a/PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C b/PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C index a5f9dd19b05..5d4bb82e1eb 100644 --- a/PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C +++ b/PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C @@ -1,100 +1,100 @@ -AliAnalysisTaskFlavourJetCorrelations *AddTaskFlavourJetCorrelations( - AliAnalysisTaskFlavourJetCorrelations::ECandidateType cand = AliAnalysisTaskFlavourJetCorrelations::kDstartoKpipi, - TString filename = "DStartoKpipiCuts.root", - Bool_t theMCon = kFALSE, - Bool_t reco = kTRUE /*must be true if theMCon is false*/, - TString jetArrname = "", - TString suffix = "", - Bool_t triggerOnLeadingJet = kFALSE, - Int_t leadingHadType = 0 /*0 = charged, 1 = neutral, 2 = both*/, - Float_t R = 0.4, - Float_t jptcut = 10., - const char *cutType = "TPC", - Double_t percjetareacut = 1.) -{ - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - ::Error("AddTaskFlavourJetCorrelations::AddTaskFlavourJetCorrelations", "No analysis manager to connect to."); - return NULL; - } - - Bool_t useStdC = kFALSE; - TFile* filecuts=TFile::Open(filename); - if (!filecuts || (filecuts && !filecuts->IsOpen())) { - cout<<"Input file not found: use std cuts"<SetStandardCutsPP2010(); - } else - analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts"); - break; - case 1 : - if(useStdC) { - analysiscuts = new AliRDHFCutsDStartoKpipi(); - analysiscuts->SetStandardCutsPP2010(); - } else - analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts"); - analysiscuts->SetName("DStartoKpipiCuts"); - break; - } - - if (!analysiscuts) { // mm let's see if everything is ok - AliFatal("Specific AliRDHFCuts not found"); - return; - } - - printf("CREATE TASK\n"); //CREATE THE TASK - - // create the task - AliAnalysisTaskFlavourJetCorrelations *task = new AliAnalysisTaskFlavourJetCorrelations("AnaTaskFlavourJetCorrelations", - analysiscuts, cand); - task->SetJetsName(jetArrname); - task->SetMC(theMCon); - task->SetUseReco(reco); - task->SetTriggerOnLeadingJet(triggerOnLeadingJet); - task->SetJetAcceptanceType(cutType); - - mgr->AddTask(task); - - if(theMCon) { - suffix+="MC"; - if(reco) suffix+="rec"; - } - - // Create and connect containers for input/output - TString outputfile = AliAnalysisManager::GetCommonFileName(); - outputfile += ":PWG3_D2H_DEmcalJet"; - outputfile += suffix; - - TString candname="DStar"; - if(cand==0) candname="D0"; - - TString nameContainer1="hCor"; - TString nameContainer2="cutsJ"; - - nameContainer1 += candname; - nameContainer2 += candname; - - nameContainer1 += suffix; - nameContainer2 += suffix; - // ------ input data ------ - AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); - - // ----- output data ----- - AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer1, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); - AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer2, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); - - mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task,1,coutput1); - mgr->ConnectOutput(task,2,coutput2); - - - Printf("Input and Output connected to the manager"); - return task ; -} +AliAnalysisTaskFlavourJetCorrelations *AddTaskFlavourJetCorrelations( + AliAnalysisTaskFlavourJetCorrelations::ECandidateType cand = AliAnalysisTaskFlavourJetCorrelations::kDstartoKpipi, + TString filename = "DStartoKpipiCuts.root", + Bool_t theMCon = kFALSE, + Bool_t reco = kTRUE /*must be true if theMCon is false*/, + TString jetArrname = "", + TString suffix = "", + Bool_t triggerOnLeadingJet = kFALSE, + Int_t leadingHadType = 0 /*0 = charged, 1 = neutral, 2 = both*/, + Float_t R = 0.4, + Float_t jptcut = 10., + const char *cutType = "TPC", + Double_t percjetareacut = 1.) +{ + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error("AddTaskFlavourJetCorrelations::AddTaskFlavourJetCorrelations", "No analysis manager to connect to."); + return NULL; + } + + Bool_t useStdC = kFALSE; + TFile* filecuts=TFile::Open(filename); + if (!filecuts || (filecuts && !filecuts->IsOpen())) { + cout<<"Input file not found: use std cuts"<SetStandardCutsPP2010(); + } else + analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts"); + break; + case 1 : + if(useStdC) { + analysiscuts = new AliRDHFCutsDStartoKpipi(); + analysiscuts->SetStandardCutsPP2010(); + } else + analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts"); + analysiscuts->SetName("DStartoKpipiCuts"); + break; + } + + if (!analysiscuts) { // mm let's see if everything is ok + AliFatal("Specific AliRDHFCuts not found"); + return; + } + + printf("CREATE TASK\n"); //CREATE THE TASK + + // create the task + AliAnalysisTaskFlavourJetCorrelations *task = new AliAnalysisTaskFlavourJetCorrelations("AnaTaskFlavourJetCorrelations", + analysiscuts, cand); + task->SetJetsName(jetArrname); + task->SetMC(theMCon); + task->SetUseReco(reco); + task->SetTriggerOnLeadingJet(triggerOnLeadingJet); + task->SetJetAcceptanceType(cutType); + + mgr->AddTask(task); + + if(theMCon) { + suffix+="MC"; + if(reco) suffix+="rec"; + } + + // Create and connect containers for input/output + TString outputfile = AliAnalysisManager::GetCommonFileName(); + outputfile += ":PWG3_D2H_DEmcalJet"; + outputfile += suffix; + + TString candname="DStar"; + if(cand==0) candname="D0"; + + TString nameContainer1="hCor"; + TString nameContainer2="cutsJ"; + + nameContainer1 += candname; + nameContainer2 += candname; + + nameContainer1 += suffix; + nameContainer2 += suffix; + // ------ input data ------ + AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); + + // ----- output data ----- + AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer1, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); + AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer2, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); + + mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task,1,coutput1); + mgr->ConnectOutput(task,2,coutput2); + + + Printf("Input and Output connected to the manager"); + return task ; +} diff --git a/PWGJE/FlavourJetTasks/macros/AddTaskSEDmesonsFilterCJ.C b/PWGJE/FlavourJetTasks/macros/AddTaskSEDmesonsFilterCJ.C index 43e63b9d7e0..e8bf35bf228 100644 --- a/PWGJE/FlavourJetTasks/macros/AddTaskSEDmesonsFilterCJ.C +++ b/PWGJE/FlavourJetTasks/macros/AddTaskSEDmesonsFilterCJ.C @@ -1,94 +1,94 @@ -AliAnalysisTaskSEDmesonsFilterCJ *AddTaskSEDmesonsFilterCJ( - AliAnalysisTaskSEDmesonsFilterCJ::ECandidateType cand = AliAnalysisTaskSEDmesonsFilterCJ::kDstartoKpipi, - TString filename = "DStartoKpipiCuts.root", - Bool_t theMCon = kFALSE, - Bool_t reco = kTRUE /*must be true if theMCon is false*/, - TString suffix = "") -{ - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - if (!mgr) { - ::Error("AddTaskSEDmesonsFilterCJ", "No analysis manager to connect to."); - return NULL; - } - - Bool_t useStdC = kFALSE; - TFile* filecuts=TFile::Open(filename); - if(!filecuts || (filecuts && !filecuts->IsOpen())) { - cout<<"Input file not found: use std cuts"<SetStandardCutsPP2010(); - } else - analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts"); - break; - case 1 : - if(useStdC) { - analysiscuts = new AliRDHFCutsDStartoKpipi(); - analysiscuts->SetStandardCutsPP2010(); - } else - analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts"); - analysiscuts->SetName("DStartoKpipiCuts"); - break; - } - - if (!analysiscuts) { // mm let's see if everything is ok - AliFatal("Specific AliRDHFCuts not found"); - return; - } - - printf("CREATE TASK\n"); //CREATE THE TASK - - // create the task - AliAnalysisTaskSEDmesonsFilterCJ *task = new AliAnalysisTaskSEDmesonsFilterCJ("AnaTaskSEDmesonsFilterCJ",analysiscuts,cand); - if(!theMCon) reco=kTRUE; - task->SetMC(theMCon); //D meson settings - task->SetUseReco(reco); - mgr->AddTask(task); - if(theMCon) { - suffix+="MC"; - if(reco) suffix+="rec"; - } - - TString candname="DStar"; - if(cand==0) candname="D0"; - - // Create and connect containers for input/output - TString outputfile = AliAnalysisManager::GetCommonFileName(); - outputfile += ":PWG3_D2H_DmesonsForJetCorrelations"; - outputfile += suffix; - - TString nameContainer0="histograms"; - TString nameContainer1="cuts"; - //TString nameContainer2="DcandidatesSel"; - - nameContainer0 += candname; - nameContainer1 += candname; - - nameContainer0 += suffix; - nameContainer1 += suffix; -//nameContainer2 += suffix; - - // ------ input data ------ - AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); - - // ----- output data ----- - - AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer0, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); - AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer1, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); -//AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(nameContainer2, TList::Class(),AliAnalysisManager::kExchangeContainer, outputfile.Data()); - - mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); - mgr->ConnectOutput(task,1,coutput1); - mgr->ConnectOutput(task,2,coutput2); -//mgr->ConnectOutput(task,3,coutput3); - - Printf("Input and Output connected to the manager"); - return task ; -} - +AliAnalysisTaskSEDmesonsFilterCJ *AddTaskSEDmesonsFilterCJ( + AliAnalysisTaskSEDmesonsFilterCJ::ECandidateType cand = AliAnalysisTaskSEDmesonsFilterCJ::kDstartoKpipi, + TString filename = "DStartoKpipiCuts.root", + Bool_t theMCon = kFALSE, + Bool_t reco = kTRUE /*must be true if theMCon is false*/, + TString suffix = "") +{ + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) { + ::Error("AddTaskSEDmesonsFilterCJ", "No analysis manager to connect to."); + return NULL; + } + + Bool_t useStdC = kFALSE; + TFile* filecuts=TFile::Open(filename); + if(!filecuts || (filecuts && !filecuts->IsOpen())) { + cout<<"Input file not found: use std cuts"<SetStandardCutsPP2010(); + } else + analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts"); + break; + case 1 : + if(useStdC) { + analysiscuts = new AliRDHFCutsDStartoKpipi(); + analysiscuts->SetStandardCutsPP2010(); + } else + analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts"); + analysiscuts->SetName("DStartoKpipiCuts"); + break; + } + + if (!analysiscuts) { // mm let's see if everything is ok + AliFatal("Specific AliRDHFCuts not found"); + return; + } + + printf("CREATE TASK\n"); //CREATE THE TASK + + // create the task + AliAnalysisTaskSEDmesonsFilterCJ *task = new AliAnalysisTaskSEDmesonsFilterCJ("AnaTaskSEDmesonsFilterCJ",analysiscuts,cand); + if(!theMCon) reco=kTRUE; + task->SetMC(theMCon); //D meson settings + task->SetUseReco(reco); + mgr->AddTask(task); + if(theMCon) { + suffix+="MC"; + if(reco) suffix+="rec"; + } + + TString candname="DStar"; + if(cand==0) candname="D0"; + + // Create and connect containers for input/output + TString outputfile = AliAnalysisManager::GetCommonFileName(); + outputfile += ":PWG3_D2H_DmesonsForJetCorrelations"; + outputfile += suffix; + + TString nameContainer0="histograms"; + TString nameContainer1="cuts"; + //TString nameContainer2="DcandidatesSel"; + + nameContainer0 += candname; + nameContainer1 += candname; + + nameContainer0 += suffix; + nameContainer1 += suffix; +//nameContainer2 += suffix; + + // ------ input data ------ + AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); + + // ----- output data ----- + + AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer0, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); + AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer1, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); +//AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(nameContainer2, TList::Class(),AliAnalysisManager::kExchangeContainer, outputfile.Data()); + + mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task,1,coutput1); + mgr->ConnectOutput(task,2,coutput2); +//mgr->ConnectOutput(task,3,coutput3); + + Printf("Input and Output connected to the manager"); + return task ; +} + diff --git a/PWGJE/macros/PID/AddUpSystematicErrors.C b/PWGJE/macros/PID/AddUpSystematicErrors.C index abe2ba8fda2..e5d37a8cd3c 100644 --- a/PWGJE/macros/PID/AddUpSystematicErrors.C +++ b/PWGJE/macros/PID/AddUpSystematicErrors.C @@ -1,278 +1,278 @@ -#include "TH1D.h" -#include "TCanvas.h" -#include "TStyle.h" -#include "TString.h" -#include "TLegend.h" -#include "TFile.h" -#include "TGraphErrors.h" -#include "TGraphAsymmErrors.h" -#include "TGraph.h" -#include "TMath.h" - -#include "AliPID.h" - -#include "THnSparseDefinitions.h" - -#include -#include - -const Int_t numSpecies = 5; - -//________________________________________________________ -TCanvas* DrawFractionHistos(TString canvName, TString canvTitle, Double_t pLow, Double_t pHigh, TGraphAsymmErrors** gr, TH1F** histRef) -{ - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridx(1); - canv->SetGridy(1); - canv->SetLogx(1); - - for (Int_t i = 0; i < numSpecies; i++) { - histRef[i]->GetYaxis()->SetRangeUser(0.0, 1.0); - histRef[i]->GetYaxis()->SetTitle(canvTitle.Data()); - histRef[i]->GetXaxis()->SetRangeUser(pLow, pHigh); - //histRef[i]->SetFillStyle(3004 + i); - //histRef[i]->SetFillColor(kGray); - histRef[i]->SetFillStyle(0); - histRef[i]->SetFillColor(histRef[i]->GetMarkerColor()); - histRef[i]->SetLineColor(histRef[i]->GetMarkerColor()); - } - histRef[2]->SetMarkerStyle(20); - histRef[2]->Draw("e p"); - histRef[0]->SetMarkerStyle(21); - histRef[0]->Draw("e p same"); - histRef[1]->SetMarkerStyle(22); - histRef[1]->Draw("e p same"); - histRef[3]->SetMarkerStyle(29); - histRef[3]->Draw("e p same"); - histRef[4]->SetMarkerStyle(30); - histRef[4]->Draw("e p same"); - - gr[0]->GetHistogram()->GetXaxis()->SetRangeUser(pLow, pHigh); - gr[0]->GetHistogram()->GetYaxis()->SetRangeUser(0., 1.0); - gr[0]->Draw("2 same"); - gr[1]->Draw("2 same"); - gr[2]->Draw("2 same"); - gr[3]->Draw("2 same"); - gr[4]->Draw("2 same"); - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - legend->AddEntry(histRef[2], "#pi", "flp"); - legend->AddEntry(histRef[0], "e", "flp"); - legend->AddEntry(histRef[1], "K", "flp"); - legend->AddEntry(histRef[3], "p", "flp"); - legend->AddEntry(histRef[4], "#mu", "flp"); - legend->Draw(); - - ClearTitleFromHistoInCanvas(canv); - - return canv; -} - - -//________________________________________________________ -TGraphAsymmErrors* loadGraph(const TString graphName, TFile* f) -{ - if (!f) { - std::cout << "No file. Cannot load graph \"" << graphName.Data() << "\n!" << std::endl; - return 0x0; - } - - TGraphAsymmErrors* grTemp = dynamic_cast(f->Get(graphName.Data())); - if (!grTemp) { - std::cout << "Failed to load histo \"" << graphName.Data() << "\"!" << std::endl; - return 0x0; - } - - return grTemp; -} - - -//________________________________________________________ -TH1F* loadHisto(const TString histName, TFile* f) -{ - if (!f) { - std::cout << "No file. Cannot load hist \"" << histName.Data() << "\n!" << std::endl; - return 0x0; - } - - TH1F* hTemp = dynamic_cast(f->Get(histName.Data())); - if (!hTemp) { - std::cout << "Failed to load histo \"" << histName.Data() << "\"!" << std::endl; - return 0x0; - } - - return hTemp; -} - - -//________________________________________________________ -Int_t AddUpSystematicErrors(const TString path, const TString outFileTitle, const TString* fileNames, const Int_t numFiles, - const TString fileNameReference) -{ - if (!fileNames || numFiles < 1) - return -1; - - TFile* f[numFiles]; - TGraphAsymmErrors** grSysError[numSpecies]; - TString grNames[numSpecies] = {"systematicError_electron", "systematicError_kaon", "systematicError_pion", "systematicError_proton", - "systematicError_muon" }; - - const TString histNames[numSpecies] = {"hFractionElectrons", "hFractionKaons", "hFractionPions", "hFractionProtons", "hFractionMuons" }; - - - TGraphAsymmErrors** grSysErrorYields[numSpecies]; - TString grNamesYields[numSpecies] = {"systematicErrorYields_electron", "systematicErrorYields_kaon", "systematicErrorYields_pion", - "systematicErrorYields_proton", "systematicErrorYields_muon" }; - - const TString histNamesYields[numSpecies] = {"hYieldElectrons", "hYieldKaons", "hYieldPions", "hYieldProtons", "hYieldMuons" }; - - for (Int_t i = 0; i < numSpecies; i++) { - grSysError[i] = new TGraphAsymmErrors*[numFiles]; - grSysErrorYields[i] = new TGraphAsymmErrors*[numFiles]; - } - - for (Int_t iFile = 0; iFile < numFiles; iFile++) { - f[iFile] = TFile::Open(fileNames[iFile].Data()); - if (!f[iFile]) { - std::cout << "Failed to open file \"" << fileNames[iFile].Data() << "\"!" << std::endl; - return -1; - } - - // Extract the data graphs - for (Int_t i = 0; i < numSpecies; i++) { - grSysError[i][iFile] = loadGraph(grNames[i], f[iFile]); - if (!grSysError[i][iFile]) - return -1; - - grSysError[i][iFile]->SetName(Form("%s_fileID%d", grSysError[i][iFile]->GetName(), iFile)); - - - grSysErrorYields[i][iFile] = loadGraph(grNamesYields[i], f[iFile]); - if (!grSysErrorYields[i][iFile]) - return -1; - - grSysErrorYields[i][iFile]->SetName(Form("%s_fileID%d", grSysErrorYields[i][iFile]->GetName(), iFile)); - } - } - - // Load data points with statistical errors - TFile* fReferenceData = TFile::Open(fileNameReference.Data()); - if (!fReferenceData) { - std::cout << "Failed to open file \"" << fileNameReference.Data() << "\"!" << std::endl; - return -1; - } - - TH1F* hReferenceFractions[numSpecies]; - TH1F* hReferenceYields[numSpecies]; - - for (Int_t i = 0; i < numSpecies; i++) { - hReferenceFractions[i] = loadHisto(histNames[i], fReferenceData); - if (!hReferenceFractions[i]) - return -1; - - hReferenceYields[i] = loadHisto(histNamesYields[i], fReferenceData); - if (!hReferenceYields[i]) - return -1; - } - - const Int_t reference = 0; - - // The x,y coordinates should be those of the reference graph. Then, all corresponding sys. errors are added in quadrature. - TGraphAsymmErrors* grTotSysError[numSpecies]; - TGraphAsymmErrors* grTotSysErrorYields[numSpecies]; - Double_t sysErrorTotalSquared = 0; - Double_t temp = 0; - - for (Int_t i = 0; i < numSpecies; i++) { - grTotSysError[i] = new TGraphAsymmErrors(*grSysError[i][reference]); - grTotSysError[i]->SetName(grNames[i]); - - for (Int_t iPoint = 0; iPoint < grTotSysError[i]->GetN(); iPoint++) { - sysErrorTotalSquared = 0; - for (Int_t iFile = 0; iFile < numFiles; iFile++) { - // Already averages high and low value -> Since they are by now the same, this is ok. - temp = grSysError[i][iFile]->GetErrorY(iPoint); - if (temp > 0) { - sysErrorTotalSquared += temp * temp; - } - } - - grTotSysError[i]->SetPointEYlow(iPoint, TMath::Sqrt(sysErrorTotalSquared)); - grTotSysError[i]->SetPointEYhigh(iPoint, TMath::Sqrt(sysErrorTotalSquared)); - } - - // Same for the yields - grTotSysErrorYields[i] = new TGraphAsymmErrors(*grSysErrorYields[i][reference]); - grTotSysErrorYields[i]->SetName(grNamesYields[i]); - - for (Int_t iPoint = 0; iPoint < grTotSysErrorYields[i]->GetN(); iPoint++) { - sysErrorTotalSquared = 0; - for (Int_t iFile = 0; iFile < numFiles; iFile++) { - // Already averages high and low value -> Since they are by now the same, this is ok. - temp = grSysErrorYields[i][iFile]->GetErrorY(iPoint); - if (temp > 0) { - sysErrorTotalSquared += temp * temp; - } - } - - grTotSysErrorYields[i]->SetPointEYlow(iPoint, TMath::Sqrt(sysErrorTotalSquared)); - grTotSysErrorYields[i]->SetPointEYhigh(iPoint, TMath::Sqrt(sysErrorTotalSquared)); - } - } - - const Double_t pLow = 0.15; - const Double_t pHigh = 50.; - TCanvas* cFractionsWithTotalSystematicError = DrawFractionHistos("cFractionsWithTotalSystematicError", "Particle fractions", pLow, pHigh, - grTotSysError, hReferenceFractions); - - - // Output file - TFile* fSave = 0x0; - TDatime daTime; - TString saveFileName; - - saveFileName = Form("outputSystematicsTotal_%s__%04d_%02d_%02d.root", outFileTitle.Data(), daTime.GetYear(), - daTime.GetMonth(), daTime.GetDay()); - - fSave = TFile::Open(Form("%s/%s", path.Data(), saveFileName.Data()), "recreate"); - if (!fSave) { - std::cout << "Failed to open save file \"" << Form("%s/%s", path.Data(), saveFileName.Data()) << "\"!" << std::endl; - return -1; - } - - // Save final results - fSave->cd(); - - if (cFractionsWithTotalSystematicError) - cFractionsWithTotalSystematicError->Write(); - - for (Int_t i = 0; i < numSpecies; i++) { - if (grTotSysError[i]) - grTotSysError[i]->Write(); - if (hReferenceFractions[i]) - hReferenceFractions[i]->Write(); - - if (grTotSysErrorYields[i]) - grTotSysErrorYields[i]->Write(); - if (hReferenceYields[i]) - hReferenceYields[i]->Write(); - } - - // Save list of file names in output file - TString listOfFileNames = ""; - for (Int_t i = 0; i < numFiles; i++) { - listOfFileNames.Append(Form("%s%d: %s", i == 0 ? "" : ", ", i, fileNames[i].Data())); - } - - TNamed* settings = new TNamed(Form("Used files for systematics: %s\n", listOfFileNames.Data()), - Form("Used files for systematics: %s\n", listOfFileNames.Data())); - settings->Write(); - - delete cFractionsWithTotalSystematicError; - - fSave->Close(); - - return 0; -} +#include "TH1D.h" +#include "TCanvas.h" +#include "TStyle.h" +#include "TString.h" +#include "TLegend.h" +#include "TFile.h" +#include "TGraphErrors.h" +#include "TGraphAsymmErrors.h" +#include "TGraph.h" +#include "TMath.h" + +#include "AliPID.h" + +#include "THnSparseDefinitions.h" + +#include +#include + +const Int_t numSpecies = 5; + +//________________________________________________________ +TCanvas* DrawFractionHistos(TString canvName, TString canvTitle, Double_t pLow, Double_t pHigh, TGraphAsymmErrors** gr, TH1F** histRef) +{ + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridx(1); + canv->SetGridy(1); + canv->SetLogx(1); + + for (Int_t i = 0; i < numSpecies; i++) { + histRef[i]->GetYaxis()->SetRangeUser(0.0, 1.0); + histRef[i]->GetYaxis()->SetTitle(canvTitle.Data()); + histRef[i]->GetXaxis()->SetRangeUser(pLow, pHigh); + //histRef[i]->SetFillStyle(3004 + i); + //histRef[i]->SetFillColor(kGray); + histRef[i]->SetFillStyle(0); + histRef[i]->SetFillColor(histRef[i]->GetMarkerColor()); + histRef[i]->SetLineColor(histRef[i]->GetMarkerColor()); + } + histRef[2]->SetMarkerStyle(20); + histRef[2]->Draw("e p"); + histRef[0]->SetMarkerStyle(21); + histRef[0]->Draw("e p same"); + histRef[1]->SetMarkerStyle(22); + histRef[1]->Draw("e p same"); + histRef[3]->SetMarkerStyle(29); + histRef[3]->Draw("e p same"); + histRef[4]->SetMarkerStyle(30); + histRef[4]->Draw("e p same"); + + gr[0]->GetHistogram()->GetXaxis()->SetRangeUser(pLow, pHigh); + gr[0]->GetHistogram()->GetYaxis()->SetRangeUser(0., 1.0); + gr[0]->Draw("2 same"); + gr[1]->Draw("2 same"); + gr[2]->Draw("2 same"); + gr[3]->Draw("2 same"); + gr[4]->Draw("2 same"); + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + legend->AddEntry(histRef[2], "#pi", "flp"); + legend->AddEntry(histRef[0], "e", "flp"); + legend->AddEntry(histRef[1], "K", "flp"); + legend->AddEntry(histRef[3], "p", "flp"); + legend->AddEntry(histRef[4], "#mu", "flp"); + legend->Draw(); + + ClearTitleFromHistoInCanvas(canv); + + return canv; +} + + +//________________________________________________________ +TGraphAsymmErrors* loadGraph(const TString graphName, TFile* f) +{ + if (!f) { + std::cout << "No file. Cannot load graph \"" << graphName.Data() << "\n!" << std::endl; + return 0x0; + } + + TGraphAsymmErrors* grTemp = dynamic_cast(f->Get(graphName.Data())); + if (!grTemp) { + std::cout << "Failed to load histo \"" << graphName.Data() << "\"!" << std::endl; + return 0x0; + } + + return grTemp; +} + + +//________________________________________________________ +TH1F* loadHisto(const TString histName, TFile* f) +{ + if (!f) { + std::cout << "No file. Cannot load hist \"" << histName.Data() << "\n!" << std::endl; + return 0x0; + } + + TH1F* hTemp = dynamic_cast(f->Get(histName.Data())); + if (!hTemp) { + std::cout << "Failed to load histo \"" << histName.Data() << "\"!" << std::endl; + return 0x0; + } + + return hTemp; +} + + +//________________________________________________________ +Int_t AddUpSystematicErrors(const TString path, const TString outFileTitle, const TString* fileNames, const Int_t numFiles, + const TString fileNameReference) +{ + if (!fileNames || numFiles < 1) + return -1; + + TFile* f[numFiles]; + TGraphAsymmErrors** grSysError[numSpecies]; + TString grNames[numSpecies] = {"systematicError_electron", "systematicError_kaon", "systematicError_pion", "systematicError_proton", + "systematicError_muon" }; + + const TString histNames[numSpecies] = {"hFractionElectrons", "hFractionKaons", "hFractionPions", "hFractionProtons", "hFractionMuons" }; + + + TGraphAsymmErrors** grSysErrorYields[numSpecies]; + TString grNamesYields[numSpecies] = {"systematicErrorYields_electron", "systematicErrorYields_kaon", "systematicErrorYields_pion", + "systematicErrorYields_proton", "systematicErrorYields_muon" }; + + const TString histNamesYields[numSpecies] = {"hYieldElectrons", "hYieldKaons", "hYieldPions", "hYieldProtons", "hYieldMuons" }; + + for (Int_t i = 0; i < numSpecies; i++) { + grSysError[i] = new TGraphAsymmErrors*[numFiles]; + grSysErrorYields[i] = new TGraphAsymmErrors*[numFiles]; + } + + for (Int_t iFile = 0; iFile < numFiles; iFile++) { + f[iFile] = TFile::Open(fileNames[iFile].Data()); + if (!f[iFile]) { + std::cout << "Failed to open file \"" << fileNames[iFile].Data() << "\"!" << std::endl; + return -1; + } + + // Extract the data graphs + for (Int_t i = 0; i < numSpecies; i++) { + grSysError[i][iFile] = loadGraph(grNames[i], f[iFile]); + if (!grSysError[i][iFile]) + return -1; + + grSysError[i][iFile]->SetName(Form("%s_fileID%d", grSysError[i][iFile]->GetName(), iFile)); + + + grSysErrorYields[i][iFile] = loadGraph(grNamesYields[i], f[iFile]); + if (!grSysErrorYields[i][iFile]) + return -1; + + grSysErrorYields[i][iFile]->SetName(Form("%s_fileID%d", grSysErrorYields[i][iFile]->GetName(), iFile)); + } + } + + // Load data points with statistical errors + TFile* fReferenceData = TFile::Open(fileNameReference.Data()); + if (!fReferenceData) { + std::cout << "Failed to open file \"" << fileNameReference.Data() << "\"!" << std::endl; + return -1; + } + + TH1F* hReferenceFractions[numSpecies]; + TH1F* hReferenceYields[numSpecies]; + + for (Int_t i = 0; i < numSpecies; i++) { + hReferenceFractions[i] = loadHisto(histNames[i], fReferenceData); + if (!hReferenceFractions[i]) + return -1; + + hReferenceYields[i] = loadHisto(histNamesYields[i], fReferenceData); + if (!hReferenceYields[i]) + return -1; + } + + const Int_t reference = 0; + + // The x,y coordinates should be those of the reference graph. Then, all corresponding sys. errors are added in quadrature. + TGraphAsymmErrors* grTotSysError[numSpecies]; + TGraphAsymmErrors* grTotSysErrorYields[numSpecies]; + Double_t sysErrorTotalSquared = 0; + Double_t temp = 0; + + for (Int_t i = 0; i < numSpecies; i++) { + grTotSysError[i] = new TGraphAsymmErrors(*grSysError[i][reference]); + grTotSysError[i]->SetName(grNames[i]); + + for (Int_t iPoint = 0; iPoint < grTotSysError[i]->GetN(); iPoint++) { + sysErrorTotalSquared = 0; + for (Int_t iFile = 0; iFile < numFiles; iFile++) { + // Already averages high and low value -> Since they are by now the same, this is ok. + temp = grSysError[i][iFile]->GetErrorY(iPoint); + if (temp > 0) { + sysErrorTotalSquared += temp * temp; + } + } + + grTotSysError[i]->SetPointEYlow(iPoint, TMath::Sqrt(sysErrorTotalSquared)); + grTotSysError[i]->SetPointEYhigh(iPoint, TMath::Sqrt(sysErrorTotalSquared)); + } + + // Same for the yields + grTotSysErrorYields[i] = new TGraphAsymmErrors(*grSysErrorYields[i][reference]); + grTotSysErrorYields[i]->SetName(grNamesYields[i]); + + for (Int_t iPoint = 0; iPoint < grTotSysErrorYields[i]->GetN(); iPoint++) { + sysErrorTotalSquared = 0; + for (Int_t iFile = 0; iFile < numFiles; iFile++) { + // Already averages high and low value -> Since they are by now the same, this is ok. + temp = grSysErrorYields[i][iFile]->GetErrorY(iPoint); + if (temp > 0) { + sysErrorTotalSquared += temp * temp; + } + } + + grTotSysErrorYields[i]->SetPointEYlow(iPoint, TMath::Sqrt(sysErrorTotalSquared)); + grTotSysErrorYields[i]->SetPointEYhigh(iPoint, TMath::Sqrt(sysErrorTotalSquared)); + } + } + + const Double_t pLow = 0.15; + const Double_t pHigh = 50.; + TCanvas* cFractionsWithTotalSystematicError = DrawFractionHistos("cFractionsWithTotalSystematicError", "Particle fractions", pLow, pHigh, + grTotSysError, hReferenceFractions); + + + // Output file + TFile* fSave = 0x0; + TDatime daTime; + TString saveFileName; + + saveFileName = Form("outputSystematicsTotal_%s__%04d_%02d_%02d.root", outFileTitle.Data(), daTime.GetYear(), + daTime.GetMonth(), daTime.GetDay()); + + fSave = TFile::Open(Form("%s/%s", path.Data(), saveFileName.Data()), "recreate"); + if (!fSave) { + std::cout << "Failed to open save file \"" << Form("%s/%s", path.Data(), saveFileName.Data()) << "\"!" << std::endl; + return -1; + } + + // Save final results + fSave->cd(); + + if (cFractionsWithTotalSystematicError) + cFractionsWithTotalSystematicError->Write(); + + for (Int_t i = 0; i < numSpecies; i++) { + if (grTotSysError[i]) + grTotSysError[i]->Write(); + if (hReferenceFractions[i]) + hReferenceFractions[i]->Write(); + + if (grTotSysErrorYields[i]) + grTotSysErrorYields[i]->Write(); + if (hReferenceYields[i]) + hReferenceYields[i]->Write(); + } + + // Save list of file names in output file + TString listOfFileNames = ""; + for (Int_t i = 0; i < numFiles; i++) { + listOfFileNames.Append(Form("%s%d: %s", i == 0 ? "" : ", ", i, fileNames[i].Data())); + } + + TNamed* settings = new TNamed(Form("Used files for systematics: %s\n", listOfFileNames.Data()), + Form("Used files for systematics: %s\n", listOfFileNames.Data())); + settings->Write(); + + delete cFractionsWithTotalSystematicError; + + fSave->Close(); + + return 0; +} diff --git a/PWGJE/macros/PID/PID.C b/PWGJE/macros/PID/PID.C index bbeaaf67c19..9b81b3ba934 100644 --- a/PWGJE/macros/PID/PID.C +++ b/PWGJE/macros/PID/PID.C @@ -1,6253 +1,6253 @@ -#include "THnSparse.h" -#include "TH2D.h" -#include "TH1D.h" -#include "TProfile.h" -#include "TF1.h" -#include "TFitResultPtr.h" -#include "TFitResult.h" -#include "TCanvas.h" -#include "TStyle.h" -#include "TVirtualFitter.h" -#include "TObjArray.h" -#include "TString.h" -#include "TLegend.h" -#include "TFile.h" -#include "TGraphErrors.h" -#include "TGraph.h" -#include "TMath.h" -#include "TMatrixDSym.h" -#include "TRandom3.h" -#include "TROOT.h" - -#include -#include - -#include "AliPID.h" - -#include "THnSparseDefinitions.h" -#include "AliTPCPIDmathFit.h" - -enum processMode { kPMpT = 0, kPMz = 1, kPMxi = 2 }; -enum muonTreatment { kNoMuons = 0, kMuonFracEqualElFrac = 1, kMuonFracOverElFracTunedOnMCStandardTrackCuts = 2, - kMuonFracOverElFracTunedOnMCHybridTrackCuts = 3, kMuonFracOverElFracTunedOnMCHybridTrackCutsJets = 4, - kMuonFracOverElFracTunedOnMCStandardTrackCutsPPb = 5, - kNumHandlings = 6 }; - -const TString modeShortName[3] = { "Pt", "Z", "Xi" }; -const TString modeLatexName[3] = { "P_{T}", "z", "#xi" }; - -const TString muonFractionHandlingShortName[kNumHandlings] = - { "noMuons", "muonsEqualElectrons", "muonToElTunedOnMCStandardTrackCuts", "muonToElTunedOnMCHybridTrackCuts", - "muonToElTunedOnMCHybridTrackCutsJets", "muonToElTunedOnMCStandardTrackCutsPPB" }; - -const Double_t epsilon = 1e-10; -const TString identifiedLabels[2] = { "Most Probable PID", "MC" }; -Int_t isMC = 0; - -TString minimisationStrategy = "MIGRAD"; // "MINIMIZE" -Bool_t takeIntoAccountMuons = kTRUE; - -// 0 = no muons, 1 = muonFrac=elFrac, 2(3) = muonFrac/elFrac tuned on MC for DefaultTrackCuts (hybridTrackCuts), -// 4 = muonFrac/elFrac tuned on MC for hybridTrackCuts for jet particles, -Int_t muonFractionHandling = 3; - - -//TODO getErrorOf.... is COMPLETELY wrong now, since the parameter numbering has changed and the muons had come into play!!!!!! - -// TODO CAREFUL: fitMethod == 1 adds errors of electrons to pions, but not to muons (should be added to electron error instead!) -const Bool_t muonContamination = kFALSE;//TODO CAREFUL: fitMethod == 1 takes into account the muon contamination in the error calculation!!! - -const Bool_t normaliseResults = kTRUE; // Works only for fitMethod == 2 - -const Bool_t enableShift = kFALSE; -const Int_t dataAxis = kPidDeltaPrime;//kPidDelta; kPidDeltaPrime - -const Int_t numSimultaneousFits = 4; - -// Upper and lower axis bounds (y-axis) of (data - fit) / data QA histos -const Double_t fitQAaxisLowBound = -0.5; -const Double_t fitQAaxisUpBound = 0.5; - -Bool_t useDeltaPrime = (dataAxis == kPidDeltaPrime); - -// Will be set later -Double_t muonFractionThresholdForFitting = -1.; -Double_t muonFractionThresholdBinForFitting = -1; - -Double_t electronFractionThresholdForFitting = -1.; -Double_t electronFractionThresholdBinForFitting = -1; - - -TF1 fMuonOverElFractionMC("fMuonOverElFractionMC", "[0]+[1]/TMath::Min(x, [4])+[2]*TMath::Min(x, [4])+[3]*TMath::Min(x, [4])*TMath::Min(x, [4])+[5]*TMath::Min(x, [4])*TMath::Min(x, [4])*TMath::Min(x, [4])+[6]*(x>[7])*TMath::Min(x-[7], [8]-[7])", - 0.01, 50.); - -TF1* fElectronFraction = 0x0; -const Double_t lowFittingBoundElectronFraction = 3.0; - -TGraphErrors* gFractionElectronsData = 0x0; -Double_t lastPtForCallOfGetElectronFraction = -1; - - -//____________________________________________________________________________________________________________________ -Double_t GetElectronFraction(const Double_t pT, const Double_t *par) -{ - // During the fit (both, simultaneous and non-simultaneous), the algorithm will always start off from - // the low pT and go to higher pT. So, it is only necessary to do the fit once the first fixed bin is reached. - // Then the parameters for the electron fraction remain fixed until the next fit iteration. - // Since only for the case of regularisation the electron fractions of all x bins are stored in mathFit, - // the evaluation of this function is done here only in that case (only then the electron fraction will - // be set to "-pT". - - // NOTE 1: Electrons have index 3 per x bin - // NOTE 2: This function is only called for fitting vs. pT. In that case, xValue holds the LOG of pT! - - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - // lastPtForCallOfGetElectronFraction will be initialised with a value larger than any pT during the fit. - // So, if this function is called and the pT is smaller than lastPtForCallOfGetElectronFraction, the parameters - // must have changed and the electron fit needs to be re-done (also see comment above) - if (pT < lastPtForCallOfGetElectronFraction) { - for (Int_t xBin = 0; xBin < mathFit->GetNumXbinsRegularisation(); xBin++) { - - const Double_t xCoord = TMath::Exp(mathFit->GetXvaluesForRegularisation()[xBin]); - const Int_t parIndexWithFraction = 3 + xBin * mathFit->GetNumParametersPerXbin(); - - if (xCoord >= lowFittingBoundElectronFraction && xCoord <= electronFractionThresholdForFitting - && par[parIndexWithFraction] > epsilon) { // Skip zero values (usually due to failed fits) - gFractionElectronsData->SetPoint(xBin, TMath::Exp(mathFit->GetXvaluesForRegularisation()[xBin]), par[parIndexWithFraction]); - // Since the errors during the fitting are not reliable, use the following approximation on a statistical basis - // (which indeed turns out to be rather good!) - - // Bin effective weight required for weighted data sets. In case of no weighting, the weight error is sqrt(weight), - // i.e. effWeight is 1 - const Double_t effWeight = mathFit->GetXstatisticalWeightError()[xBin] * mathFit->GetXstatisticalWeightError()[xBin] - / mathFit->GetXstatisticalWeight()[xBin]; - gFractionElectronsData->SetPointError(xBin, 0, effWeight * TMath::Sqrt(par[parIndexWithFraction] - / mathFit->GetXstatisticalWeight()[xBin])); - } - else { - gFractionElectronsData->SetPoint(xBin, -1, 0); - gFractionElectronsData->SetPointError(xBin, 0, 0); - } - } - - gFractionElectronsData->Fit(fElectronFraction, "Ex0NQ", "", lowFittingBoundElectronFraction, electronFractionThresholdForFitting); - } - - lastPtForCallOfGetElectronFraction = pT; - - // Catch cases in which the fit function yields invalid fractions (i.e. < 0 or > 1) - return TMath::Max(0.0, TMath::Min(1.0, fElectronFraction->Eval(pT))); -} - - -//____________________________________________________________________________________________________________________ -Double_t GetElectronFractionError() -{ - // This function estimates the error of the electron fraction for the fixed values via using the parameter errors of - // the electron fraction function. Note that the parameters (and errors) must be set before calling this function. - - // Produce several values via setting the parameters to a random value, which is distributed with a gaussian with mean = parValue - // and sigma = parError and then take the 2*RMS as the error - const Int_t nGenValues = 1000; - Double_t genValues[nGenValues]; - - const Int_t nPars = fElectronFraction->GetNpar(); - Double_t par[nPars]; - - TRandom3 rnd(0); // 0 means random seed - - const Double_t x = electronFractionThresholdForFitting + 1.; // Some value above the threshold to obtain a fixed value - for (Int_t i = 0 ; i < nGenValues; i++) { - for (Int_t iPar = 0; iPar < nPars; iPar++) - par[iPar] = rnd.Gaus(fElectronFraction->GetParameter(iPar), fElectronFraction->GetParError(iPar)); - - genValues[i] = fElectronFraction->EvalPar(&x, &par[0]); - } - - // NOTE: RMS is not really the root mean square, is it rather the sigma deviation, which is what is wanted here - return 2. * TMath::RMS(nGenValues, &genValues[0]); -} - - -//____________________________________________________________________________________________________________________ -Double_t GetMuonFractionFromElectronFractionAndPt(Double_t pT, Double_t elFrac) -{ - if (muonFractionHandling == kMuonFracOverElFracTunedOnMCStandardTrackCuts) { -// return elFrac / (1. + 7.06909e+01 * TMath::Exp(-2.95078e+00 * TMath::Power(pT, 5.05016e-01))); - return elFrac / (1. + 2.01840e+10 * TMath::Exp(-2.50480e+01 * TMath::Power(pT, 5.89044e-02))); - } - else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCHybridTrackCuts) { - fMuonOverElFractionMC.SetParameters(-6.87241e-01, 4.19528e-02, 4.52095e+00, -6.20026e+00, 5.16629e-01, 2.88604e+00, 3.68058e-02, - 2.21086e+00, 5.75003e+00); - return elFrac * fMuonOverElFractionMC.Eval(pT); - } - else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) { - fMuonOverElFractionMC.SetParameters(-7.64548e-01, 2.47929e-02, 4.49057e+00, -2.06320e-01, 4.23339e-02, 1.19697e+02, 1.28832e-01, - -1.71895e-01, 6.00000e+00); - return elFrac * fMuonOverElFractionMC.Eval(pT); - } - else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCStandardTrackCutsPPb) { - // WITH PID cluster cut! - fMuonOverElFractionMC.SetParameters(-6.62149e-01, 4.89591e-02, 4.58356e+00, -6.04319e+00, 6.25368e-01, 3.27191e+00, 1.69933e-01, - 1.00004e+00, 2.61438e+00); - return elFrac * fMuonOverElFractionMC.Eval(pT); - } - else if (muonFractionHandling == kMuonFracEqualElFrac) { - return elFrac; - } - - return 0.; -} - - -//____________________________________________________________________________________________________________________ -Double_t GetCorrelatedError(const Double_t x, const Double_t y, const Double_t cov00, const Double_t cov11, const Double_t cov01) -{ - // Calculate the correlated error df of f: - // (cov00 cov01) (x) - //df^2 = (x, y) * (cov01 cov11) (y) = x^2 * cov00 + y^2 * cov11 + 2 * x * y * cov01 - // - // with f = f(p1, p2) = p1 / p2 - // and (x, y) = (\partial f / \partial p1, \partial f / \partial p2) - // = (f / p1, -f / p2) - - const Double_t df2 = x * x * cov00 + y * y * cov11 + 2. * x * y * cov01; - - if (df2 < epsilon) - return 0.; - - return TMath::Sqrt(df2); -} - - -//____________________________________________________________________________________________________________________ -void GetRatioWithCorrelatedError(const Double_t fractionA, const Double_t fractionB, - const Double_t fractionErrorA, const Double_t fractionErrorB, - const Double_t covMatrixElementAB, Double_t& ratio, Double_t& ratioError) -{ - // Given fractions A and B with corresponding errors and the off-diagonal covariance matrix element of - // these fractions, calculate the ratio A/B and the error taking into account the correlation. - // The results are stored in ratio and ratioError. - - if (fractionB < epsilon) { - ratio = -999.; - ratioError = 999.; - - return; - } - - if (fractionA < epsilon) { - ratio = 0.; - ratioError = 999.; - - return; - } - - ratio = fractionA / fractionB; - - const Double_t x = ratio / fractionA; - const Double_t y = -ratio / fractionB; - - // covMatrixElement(i, i) = error(i)^2 - ratioError = GetCorrelatedError(x, y, fractionErrorA * fractionErrorA, fractionErrorB * fractionErrorB, covMatrixElementAB); - - //printf("frationA %e\nfractionB %e\nfractionErrorA %e\nfractionErrorB %e\ncovMatrixElementAB %e\nratio %e\nx %e\ny %e\nratioError %e\n\n", - // fractionA, fractionB, fractionErrorA, fractionErrorB, covMatrixElementAB, ratio, x, y, ratioError); -} - - -//____________________________________________________________________________________________________________________ -void SetReasonableAxisRange(TAxis* axis, Int_t mode, Double_t pLow = -1, Double_t pHigh = -1) -{ - if (mode == kPMpT) - axis->SetRangeUser(TMath::Max(0.15, pLow - 0.1), TMath::Min(50., pHigh + 0.1)); - else if (mode == kPMz) - axis->SetRange(0, -1); - else if (mode == kPMxi) - axis->SetRange(0, -1); -} - -//____________________________________________________________________________________________________________________ -void SetReasonableXaxisRange(TH1* h, Int_t& binLow, Int_t& binHigh) -{ - binLow = TMath::Max(1, h->FindFirstBinAbove(0)); - binHigh = TMath::Min(h->GetNbinsX(), h->FindLastBinAbove(0)); - - h->GetXaxis()->SetRange(binLow, binHigh); - h->GetXaxis()->SetMoreLogLabels(kTRUE); - h->GetXaxis()->SetNoExponent(kTRUE); -} - - -//____________________________________________________________________________________________________________________ -Int_t FindMomentumBin(const Double_t* pTbins, const Double_t value, const Int_t numPtBins = nPtBins) -{ - for (Int_t bin = 0; bin < numPtBins; bin++) { - if (value >= pTbins[bin] && value < pTbins[bin + 1]) - return bin; - } - - return -1; -} - - -//____________________________________________________________________________________________________________________ -Double_t normaliseHist(TH1* h, Double_t scaleFactor = -1) -{ - // Scales the histogram with the scale factor. If the scale factor is < 0, - // the histogram is normalised to it's integral. - // In both cases, the normalisation factor is returned. - - Double_t normFactor = 1.; - - if (scaleFactor < 0) { - Double_t integralTemp = h->Integral(); - if (integralTemp > 0) { - normFactor = 1.0 / integralTemp; - h->Scale(normFactor); - } - } - else { - normFactor = scaleFactor; - h->Scale(normFactor); - } - - h->GetXaxis()->SetTitleOffset(1.0); - - return normFactor; -} - - -//____________________________________________________________________________________________________________________ -void normaliseYieldHist(TH1* h, Double_t numEvents, Double_t deta) -{ - // Yield histos are already normalised to dpT. Now normalise to 1/NeV 1/(2pi pT) 1/deta in addition - - if (numEvents <= 0) // Do not normalise - numEvents = 1; - - for (Int_t bin = 1; bin <= h->GetNbinsX(); bin++) { - Double_t normFactor = 1. / (numEvents * 2 * TMath::Pi() * h->GetXaxis()->GetBinCenter(bin) * deta); - h->SetBinContent(bin, h->GetBinContent(bin) * normFactor); - h->SetBinError(bin, h->GetBinError(bin) * normFactor); - } -} - - -//____________________________________________________________________________________________________________________ -void normaliseGenYieldMCtruthHist(TH1* h, Double_t numEvents, Double_t deta) -{ - // Yield histos are NOT normalised to dpT. Now normalise to 1/NeV 1/(2pi pT) 1/deta 1/dpT! - - if (numEvents <= 0) // Do not normalise - numEvents = 1; - - for (Int_t bin = 1; bin <= h->GetNbinsX(); bin++) { - Double_t normFactor = 1. / (numEvents * 2 * TMath::Pi() * h->GetXaxis()->GetBinCenter(bin) * h->GetXaxis()->GetBinWidth(bin) * deta); - h->SetBinContent(bin, h->GetBinContent(bin) * normFactor); - h->SetBinError(bin, h->GetBinError(bin) * normFactor); - } -} - - -//____________________________________________________________________________________________________________________ -void setUpFitFunction(TF1* fitFunc, Int_t nBins, Bool_t noShift = kFALSE) -{ - fitFunc->SetLineColor(kGray + 1); - fitFunc->SetLineWidth(2); - fitFunc->SetLineStyle(1); - fitFunc->SetNpx(nBins * 100); - fitFunc->SetParName(0, "Pion fraction"); - fitFunc->SetParName(1, "Kaon fraction"); - fitFunc->SetParName(2, "Proton fraction"); - fitFunc->SetParName(3, "Electron fraction"); - fitFunc->SetParName(4, "Muon fraction"); - fitFunc->SetParName(5, "Total yield"); - if (noShift == kFALSE) { - fitFunc->SetParName(6, "Shift of pion peak"); - fitFunc->SetParName(7, "Shift of kaon peak"); - fitFunc->SetParName(8, "Shift of proton peak"); - fitFunc->SetParName(9, "Shift of electron peak"); - fitFunc->SetParName(10, "Shift of muon peak"); - } -} - - -//____________________________________________________________________________________________________________________ -inline Int_t findBinWithinRange(const TAxis* axis, Double_t value) -{ - Int_t bin = axis->FindFixBin(value); - if (bin <= 0) - bin = 1; - if (bin > axis->GetNbins()) - bin = axis->GetNbins(); - - return bin; -} - - -//____________________________________________________________________________________________________________________ -Double_t linearInterpolation(const TH1* h, Double_t x, Double_t scaleFactor, Double_t shift, Double_t* error) -{ - // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters. - // The shift also introduces some uncertainty, which is rather hard to estimate. Therefore, just take the maximum error of the involved bins. - const Double_t xShifted = x - shift; - - // Just take value of bin, if beyond center of first/last bin - if (xShifted <= h->GetBinCenter(1)) { - if (error) - *error = h->GetBinError(1) * scaleFactor; - return h->GetBinContent(1) * scaleFactor; - } - else if(xShifted >= h->GetBinCenter(h->GetNbinsX())) { - if (error) - *error = h->GetBinError(h->GetNbinsX()) * scaleFactor; - return h->GetBinContent(h->GetNbinsX()) * scaleFactor; - } - else { - const Int_t xbin = h->FindFixBin(xShifted); - Double_t x0, x1, y0, y1; - - if(xShifted <= h->GetBinCenter(xbin)) { - y0 = h->GetBinContent(xbin - 1); - x0 = h->GetBinCenter(xbin - 1); - y1 = h->GetBinContent(xbin); - x1 = h->GetBinCenter(xbin); - - if (error) - *error = TMath::Max(h->GetBinError(xbin - 1), h->GetBinError(xbin)) * scaleFactor; - } - else { - y0 = h->GetBinContent(xbin); - x0 = h->GetBinCenter(xbin); - y1 = h->GetBinContent(xbin + 1); - x1 = h->GetBinCenter(xbin + 1); - - if (error) - *error = TMath::Max(h->GetBinError(xbin), h->GetBinError(xbin + 1)) * scaleFactor; - } - - return scaleFactor * (y0 + (xShifted - x0) * ((y1 - y0) / (x1 - x0))); - } - - return 0; - - /*Old version available for code bevor 03.05.2013*/ -} - - -//____________________________________________________________________________________________________________________ -void shiftHist(TH1D* h, Double_t shift, Bool_t useRegularisation = kFALSE) -{ - // Shift not available for regularisation. Just for convenience (can use the same code and only set one flag) - // call this functions and then do nothing. - // Actually, the shift is not availabe for simultaneous fitting also, but the parameter is just set to 0 there - if (!h || useRegularisation) - return; - - TString name = h->GetName(); - TH1D* hTemp = (TH1D*)h->Clone(Form("%s_clone", name.Data())); - h->Reset(); - - Double_t error = 0; - for (Int_t i = 1; i <= h->GetNbinsX(); i++) { - // linearInterpolation with scaleFactor = 1.0, since histo is assumed to be properly scaled - h->SetBinContent(i, linearInterpolation(hTemp, h->GetXaxis()->GetBinCenter(i), 1.0, shift, &error)); - h->SetBinError(i, error); - } - - delete hTemp; -} - - -//____________________________________________________________________________________________________________________ -Double_t multiGaussFitForSimultaneousFitting(const Double_t *xx, const Double_t *par, const Int_t offset) -{ - // Offset for reference histos for delta_Species - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - // parXbinIndex (fixed) will be used my mathfit to hold the pT bin index (needed for regularisation) - const Int_t xBinIndex = mathFit->GetXbinIndex(); - const Int_t numParsPerXbin = mathFit->GetNumParametersPerXbin(); - - const Int_t numRefHistosPerFit = numSimultaneousFits + (takeIntoAccountMuons ? 1 : 0); - const Int_t numRefHistosPerXbin = numRefHistosPerFit * numSimultaneousFits; - - const Int_t refHistOffset = offset * numRefHistosPerFit + xBinIndex * numRefHistosPerXbin; - - const TH1* hRefPi = mathFit->GetRefHisto(0 + refHistOffset); - const TH1* hRefKa = mathFit->GetRefHisto(1 + refHistOffset); - const TH1* hRefPr = mathFit->GetRefHisto(2 + refHistOffset); - const TH1* hRefEl = mathFit->GetRefHisto(3 + refHistOffset); - const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4 + refHistOffset) : 0x0; - - if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) - return 0; - - if (takeIntoAccountMuons && !hRefMu) - return 0; - - const Int_t parOffset = xBinIndex * numParsPerXbin; - const Int_t parPi = 0 + parOffset; - const Int_t parKa = 1 + parOffset; - const Int_t parPr = 2 + parOffset; - const Int_t parEl = 3 + parOffset; - const Int_t parMu = 4 + parOffset; - const Int_t parAll = 5 + parOffset; - - const Double_t scaleFactorPi = par[parAll] * (par[parPi] + (muonContamination ? par[parEl] : 0)); - const Double_t scaleFactorKa = par[parAll] * par[parKa]; - const Double_t scaleFactorPr = par[parAll] * par[parPr]; - const Double_t parElFraction = (par[parEl] < 0) ? GetElectronFraction(-par[parEl], par) : par[parEl]; - const Double_t scaleFactorEl = par[parAll] * parElFraction; - // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 - const Double_t scaleFactorMu = (par[parMu] < 0) - ? (par[parAll] * GetMuonFractionFromElectronFractionAndPt(-par[parMu], parElFraction)) - : (par[parAll] * par[parMu]); - - // Since one is looking at the same deltaSpecies for all considered species, the reference histograms have the same axes - // => Only need to search for the bin once - const Int_t binWithinRange = findBinWithinRange(hRefPi->GetXaxis(), xx[0]); - const Double_t countPi = scaleFactorPi * hRefPi->GetBinContent(binWithinRange); - const Double_t countKa = scaleFactorKa * hRefKa->GetBinContent(binWithinRange); - const Double_t countPr = scaleFactorPr * hRefPr->GetBinContent(binWithinRange); - const Double_t countEl = scaleFactorEl * hRefEl->GetBinContent(binWithinRange); - const Double_t countMu = takeIntoAccountMuons ? scaleFactorMu * hRefMu->GetBinContent(binWithinRange) : 0; - - const Double_t res = countPi + countKa + countPr + countEl + countMu; - - - return res; -} - - -//____________________________________________________________________________________________________________________ -inline Double_t multiGaussFitDeltaPi(const Double_t *xx, const Double_t *par) -{ - return multiGaussFitForSimultaneousFitting(xx, par, 0); -} - -//____________________________________________________________________________________________________________________ -inline Double_t multiGaussFitDeltaKa(const Double_t *xx, const Double_t *par) -{ - return multiGaussFitForSimultaneousFitting(xx, par, 1); -} - -//____________________________________________________________________________________________________________________ -inline Double_t multiGaussFitDeltaPr(const Double_t *xx, const Double_t *par) -{ - return multiGaussFitForSimultaneousFitting(xx, par, 2); -} - -//____________________________________________________________________________________________________________________ -inline Double_t multiGaussFitDeltaEl(const Double_t *xx, const Double_t *par) -{ - return multiGaussFitForSimultaneousFitting(xx, par, 3); -} - - -//____________________________________________________________________________________________________________________ -Double_t multiGaussFit(const Double_t *xx, const Double_t *par) -{ - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - const TH1* hRefPi = mathFit->GetRefHisto(0); - const TH1* hRefKa = mathFit->GetRefHisto(1); - const TH1* hRefPr = mathFit->GetRefHisto(2); - const TH1* hRefEl = mathFit->GetRefHisto(3); - const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4) : 0x0; - - if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) - return 0; - - if (takeIntoAccountMuons && !hRefMu) - return 0; - - // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters - const Double_t scaleFactorPi = par[5] * (par[0] + (muonContamination ? par[3] : 0)); - const Double_t scaleFactorKa = par[5] * par[1]; - const Double_t scaleFactorPr = par[5] * par[2]; - const Double_t parElFraction = (par[3] < 0) ? GetElectronFraction(-par[3], par) : par[3]; - const Double_t scaleFactorEl = par[5] * parElFraction; - // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 - const Double_t scaleFactorMu = (par[4] < 0) - ? (par[5] * GetMuonFractionFromElectronFractionAndPt(-par[4], parElFraction)) - : (par[5] * par[4]); - - const Double_t countPi = linearInterpolation(hRefPi, xx[0], scaleFactorPi, par[6], 0x0); - const Double_t countKa = linearInterpolation(hRefKa, xx[0], scaleFactorKa, par[7], 0x0); - const Double_t countPr = linearInterpolation(hRefPr, xx[0], scaleFactorPr, par[8], 0x0); - const Double_t countEl = linearInterpolation(hRefEl, xx[0], scaleFactorEl, par[9], 0x0); - const Double_t countMu = takeIntoAccountMuons ? linearInterpolation(hRefMu, xx[0], scaleFactorMu, par[10], 0x0) : 0; - - const Double_t res = countPi + countKa + countPr + countEl + countMu; - - /* - const Double_t countPi = linearInterpolation(hRefPi, xx[0], par[6], 0x0); - const Double_t countKa = linearInterpolation(hRefKa, xx[0], par[7], 0x0); - const Double_t countPr = linearInterpolation(hRefPr, xx[0], par[8], 0x0); - const Double_t countEl = linearInterpolation(hRefEl, xx[0], par[9], 0x0); - const Double_t countMu = takeIntoAccountMuons ? linearInterpolation(hRefMu, xx[0], par[10], 0x0) : 0; - - const Double_t res = par[5] * ((par[0] + (muonContamination ? par[3] : 0)) * countPi + par[1] * countKa - + par[2] * countPr + par[3] * countEl + par[4] * countMu); - - */ - - return res; -} - - -//____________________________________________________________________________________________________________________ -Double_t errorOfFitHistosForSimultaneousFitting(const Double_t *xx, const Double_t *par, const Int_t offset) -{ - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - Double_t summedError = 0; - - // parXbinIndex (fixed) will be used my mathfit to hold the pT bin index (needed for regularisation) - const Int_t xBinIndex = mathFit->GetXbinIndex(); - const Int_t numParsPerXbin = mathFit->GetNumParametersPerXbin(); - - const Int_t numRefHistosPerFit = numSimultaneousFits + (takeIntoAccountMuons ? 1 : 0); - const Int_t numRefHistosPerXbin = numRefHistosPerFit * numSimultaneousFits; - - const Int_t refHistOffset = offset * numRefHistosPerFit + xBinIndex * numRefHistosPerXbin; - - const TH1* hRefPi = mathFit->GetRefHisto(0 + refHistOffset); - const TH1* hRefKa = mathFit->GetRefHisto(1 + refHistOffset); - const TH1* hRefPr = mathFit->GetRefHisto(2 + refHistOffset); - const TH1* hRefEl = mathFit->GetRefHisto(3 + refHistOffset); - const TH1* hRefMu = takeIntoAccountMuons ? - mathFit->GetRefHisto(4 + refHistOffset) - : 0x0; - - if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) - return 0; - - if (takeIntoAccountMuons && !hRefMu) - return 0; - - const Int_t parOffset = xBinIndex * numParsPerXbin; - const Int_t parPi = 0 + parOffset; - const Int_t parKa = 1 + parOffset; - const Int_t parPr = 2 + parOffset; - const Int_t parEl = 3 + parOffset; - const Int_t parMu = 4 + parOffset; - const Int_t parAll = 5 + parOffset; - - const Double_t scaleFactorPi = par[parAll] * (par[parPi] + (muonContamination ? par[parEl] : 0)); - const Double_t scaleFactorKa = par[parAll] * par[parKa]; - const Double_t scaleFactorPr = par[parAll] * par[parPr]; - const Double_t scaleFactorEl = par[parAll] * ((par[parEl] < 0) ? GetElectronFraction(-par[parEl], par) : par[parEl]); - // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 - const Double_t scaleFactorMu = (par[parMu] < 0) ? - (scaleFactorEl * GetMuonFractionFromElectronFractionAndPt(-par[parMu], par[parEl]) / par[parEl]) - : (par[parAll] * par[parMu]); - - Double_t errorPi = 0, errorKa = 0, errorPr = 0, errorEl = 0, errorMu = 0; - - // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters - // Shift not implemented for simultaneous fit -> Just set all corresponding parameters to zero - linearInterpolation(hRefPi, xx[0], scaleFactorPi, 0, &errorPi); - linearInterpolation(hRefKa, xx[0], scaleFactorKa, 0, &errorKa); - linearInterpolation(hRefPr, xx[0], scaleFactorPr, 0, &errorPr); - linearInterpolation(hRefEl, xx[0], scaleFactorEl, 0, &errorEl); - if (takeIntoAccountMuons) - linearInterpolation(hRefMu, xx[0], scaleFactorMu, 0, &errorMu); - - summedError += TMath::Power(errorPi, 2); - summedError += TMath::Power(errorKa, 2); - summedError += TMath::Power(errorPr, 2); - summedError += TMath::Power(errorEl, 2); - if (takeIntoAccountMuons) - summedError += TMath::Power(errorMu, 2); - - return summedError; -} - - -//____________________________________________________________________________________________________________________ -inline Double_t errorOfFitHistosDeltaPi(const Double_t *xx, const Double_t *par) -{ - return errorOfFitHistosForSimultaneousFitting(xx, par, 0); -} - - -//____________________________________________________________________________________________________________________ -inline Double_t errorOfFitHistosDeltaKa(const Double_t *xx, const Double_t *par) -{ - return errorOfFitHistosForSimultaneousFitting(xx, par, 1); -} - - -//____________________________________________________________________________________________________________________ -inline Double_t errorOfFitHistosDeltaPr(const Double_t *xx, const Double_t *par) -{ - return errorOfFitHistosForSimultaneousFitting(xx, par, 2); -} - - -//____________________________________________________________________________________________________________________ -inline Double_t errorOfFitHistosDeltaEl(const Double_t *xx, const Double_t *par) -{ - return errorOfFitHistosForSimultaneousFitting(xx, par, 3); -} - - -//____________________________________________________________________________________________________________________ -Double_t errorOfFitHistos(const Double_t *xx, const Double_t *par) -{ - //TODO Error of shift is still not taken into account - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - Double_t summedError = 0; - - const TH1* hRefPi = mathFit->GetRefHisto(0); - const TH1* hRefKa = mathFit->GetRefHisto(1); - const TH1* hRefPr = mathFit->GetRefHisto(2); - const TH1* hRefEl = mathFit->GetRefHisto(3); - const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4) : 0x0; - - if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) - return 0; - - if (takeIntoAccountMuons && !hRefMu) - return 0; - - // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters - const Double_t scaleFactorPi = par[5] * (par[0] + (muonContamination ? par[3] : 0)); - const Double_t scaleFactorKa = par[5] * par[1]; - const Double_t scaleFactorPr = par[5] * par[2]; - const Double_t scaleFactorEl = par[5] * ((par[3] < 0) ? GetElectronFraction(-par[3], par) : par[3]); - // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 - const Double_t scaleFactorMu = (par[4] < 0) ? (scaleFactorEl * GetMuonFractionFromElectronFractionAndPt(-par[4], par[3]) / par[3]) - : (par[5] * par[4]); - - Double_t errorPi = 0, errorKa = 0, errorPr = 0, errorEl = 0, errorMu = 0; - - linearInterpolation(hRefPi, xx[0], scaleFactorPi, par[6], &errorPi); - linearInterpolation(hRefKa, xx[0], scaleFactorKa, par[7], &errorKa); - linearInterpolation(hRefPr, xx[0], scaleFactorPr, par[8], &errorPr); - linearInterpolation(hRefEl, xx[0], scaleFactorEl, par[9], &errorEl); - if (takeIntoAccountMuons) - linearInterpolation(hRefMu, xx[0], scaleFactorMu, par[10], &errorMu); // Assume same fraction as electron, i.e. same scale factor - - summedError += TMath::Power(errorPi, 2); - summedError += TMath::Power(errorKa, 2); - summedError += TMath::Power(errorPr, 2); - summedError += TMath::Power(errorEl, 2); - if (takeIntoAccountMuons) - summedError += TMath::Power(errorMu, 2); - - - /* - for (Int_t index = 0; index < mathFit->GetNrefHistos(); index++) { - TH1* HREF = mathFit->GetRefHisto(index); - Int_t bin = findBinWithinRange(HREF->GetXaxis(), xx[0]); - summedError += TMath::Power(HREF->GetBinError(bin) * par[index] * par[mathFit->GetNrefHistos()], 2); - } - */ - return summedError; -} - - -//____________________________________________________________________________________________________________________ -inline Double_t saveDivide(Double_t numerator, Double_t denominator) -{ - return ((denominator != 0) ? numerator/denominator : 0 ); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfPionIntegral(TMatrixDSym covMat) -{ - return TMath::Sqrt(covMat(0, 0) + covMat(12, 12) + 2 * covMat(0, 12)); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfElectronFraction(Double_t* par, TMatrixDSym covMat) -{ - Double_t g = saveDivide(par[3], (par[0] + par[1] + par[2] + 2 * par[3])); - Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); - Double_t s2 = TMath::Power(g, 2) * covMat(3, 3); - Double_t s3 = (4 * TMath::Power(g, 4) - 2 * TMath::Power(g, 3)) * (covMat(3, 2) + covMat(3, 1) + covMat(3, 0)); - Double_t s4 = TMath::Power(g, 4) * 2 * (covMat(2, 1) + covMat(2, 0) +covMat(1, 0)); - - return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[3]); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfKaonFraction(Double_t* par, TMatrixDSym covMat) -{ - Double_t g = saveDivide(par[1], (par[0] + par[1] + par[2] + 2 * par[3])); - Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); - Double_t s2 = TMath::Power(g, 2) * covMat(1, 1); - Double_t s3 = TMath::Power(g, 4) * (4 * covMat(3, 0) + 4 * covMat(3, 2) + 4 * covMat(3, 1) + - 2 * covMat(2, 1) + 2 * covMat(2, 0) + 2 * covMat(1, 0)); - Double_t s4 = TMath::Power(g, 3) * ((-4) * covMat(3, 1) - 2 * covMat(2, 1) - 2 * covMat(1, 0)); - - return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[1]); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfPionFraction(Double_t* par, TMatrixDSym covMat) -{ - Double_t g = saveDivide(par[0] + par[3], (par[0] + par[1] + par[2] + 2 * par[3])); - Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); - Double_t s2 = TMath::Power(g, 2) * (covMat(0, 0) + covMat(3, 3)); - Double_t s3 = TMath::Power(g, 4) * 2 * covMat(2, 1); - Double_t s4 = (4 * TMath::Power(g, 4) - 2 * TMath::Power(g, 3)) * (covMat(3, 2) + covMat(3, 1)); - Double_t s5 = 2 * covMat(3, 0) * (2 * TMath::Power(g, 4) - 3 * TMath::Power(g, 3) + TMath::Power(g, 2)); - Double_t s6 = 2 * (covMat(2, 0) + covMat(1, 0)) * (TMath::Power(g, 4) - TMath::Power(g, 3)); - - return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4 + s5 + s6), par[0] + par[3]); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfProtonFraction(Double_t* par, TMatrixDSym covMat) -{ - Double_t g = saveDivide(par[2], (par[0] + par[2] + par[1] + 2 * par[3])); - Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); - Double_t s2 = TMath::Power(g, 2) * covMat(2, 2); - Double_t s3 = TMath::Power(g, 4) * (4 * covMat(3, 0) + 4 * covMat(3, 2) + 4 * covMat(3, 1) + - 2 * covMat(2, 1) + 2 * covMat(2, 0) + 2 * covMat(1, 0)); - Double_t s4 = TMath::Power(g, 3) * ((-4) * covMat(3, 2) - 2 * covMat(2, 1) - 2 * covMat(2, 0)); - - return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[2]); -} - - -//____________________________________________________________________________________________________________________ -Double_t getErrorOfTotalIntegral(TMatrixDSym covMat) -{ - Double_t s1 = covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3); - Double_t s2 = 4 * (covMat(3, 0) + covMat(3, 1) + covMat(3, 2)); - Double_t s3 = 2 * (covMat(2, 1) + covMat(2, 0) + covMat(1, 0)); - - return TMath::Sqrt(s1 + s2 + s3); -} - - -//____________________________________________________________________________________________________________________ -Double_t getMedianOfNonZeros(Double_t input[4]) -{ - Double_t values[4] = {0,0,0,0}; - Int_t numNonZero = 0; - if (input[0] > 0) { - values[numNonZero] = input[0]; - numNonZero++; - } - if (input[1] > 0) { - values[numNonZero] = input[1]; - numNonZero++; - } - if (input[2] > 0) { - values[numNonZero] = input[2]; - numNonZero++; - } - if (input[3] > 0) { - values[numNonZero] = input[3]; - numNonZero++; - } - - return ((numNonZero > 0) ? TMath::Median(numNonZero, values) : 0); -} - - -//____________________________________________________________________________________________________________________ -TCanvas* drawFractionHistos(TString canvName, TString canvTitle, Int_t mode, Double_t pLow, Double_t pHigh, - TH1* histDeltaPion, TH1* histDeltaElectron, TH1* histDeltaKaon, TH1* histDeltaProton, TH1* histMC, - Bool_t plotIdentifiedSpectra) -{ - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridx(1); - canv->SetGridy(1); - canv->SetLogx(mode == kPMpT); - histDeltaPion->GetYaxis()->SetRangeUser(0.0, 1.0); - histDeltaPion->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaPion->GetXaxis(), mode, pLow, pHigh); - histDeltaPion->SetMarkerStyle(20); - histDeltaPion->GetXaxis()->SetMoreLogLabels(kTRUE); - histDeltaPion->GetXaxis()->SetNoExponent(kTRUE); - histDeltaPion->Draw("e p"); - histDeltaElectron->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaElectron->GetXaxis(), mode, pLow, pHigh); - histDeltaElectron->SetMarkerStyle(21); - histDeltaElectron->Draw("e p same"); - histDeltaKaon->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaKaon->GetXaxis(), mode, pLow, pHigh); - histDeltaKaon->SetMarkerStyle(22); - histDeltaKaon->Draw("e p same"); - histDeltaProton->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaProton->GetXaxis(), mode, pLow, pHigh); - histDeltaProton->SetMarkerStyle(29); - histDeltaProton->Draw("e p same"); - if (plotIdentifiedSpectra) { - histMC->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histMC->GetXaxis(), mode, pLow, pHigh); - histMC->SetMarkerStyle(24); - histMC->Draw("e p same"); - } - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - legend->AddEntry(histDeltaPion, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{#pi}}" : "_{#pi}"), "p"); - legend->AddEntry(histDeltaElectron, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{e}}" : "_{e}"), "p"); - legend->AddEntry(histDeltaKaon, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{K}}" : "_{K}"), "p"); - legend->AddEntry(histDeltaProton, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{p}}" : "_{p}"), "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(histMC, identifiedLabels[isMC].Data(), "p"); - legend->SetEntrySeparation(0.2); - legend->Draw(); - - ClearTitleFromHistoInCanvas(canv); - - return canv; -} - - -//____________________________________________________________________________________________________________________ -TCanvas* drawYieldHistos(TString canvName, TString canvTitle, Int_t mode, Double_t pLow, Double_t pHigh, - TH1* histDeltaPion, TH1* histDeltaElectron, TH1* histDeltaKaon, TH1* histDeltaProton, TH1* histMC, - Bool_t plotIdentifiedSpectra) -{ - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridx(1); - canv->SetGridy(1); - canv->SetLogx(mode == kPMpT); - canv->SetLogy(1); - histDeltaPion->GetYaxis()->SetRangeUser(histDeltaPion->GetBinContent(histDeltaPion->FindLastBinAbove(0.)) / 10., - histDeltaPion->GetBinContent(histDeltaPion->GetMaximumBin()) * 10.); - histDeltaPion->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaPion->GetXaxis(), mode, pLow, pHigh); - histDeltaPion->SetMarkerStyle(20); - histDeltaPion->GetXaxis()->SetMoreLogLabels(kTRUE); - histDeltaPion->GetXaxis()->SetNoExponent(kTRUE); - histDeltaPion->Draw("e p"); - histDeltaElectron->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaElectron->GetXaxis(), mode, pLow, pHigh); - histDeltaElectron->SetMarkerStyle(21); - histDeltaElectron->Draw("e p same"); - histDeltaKaon->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaKaon->GetXaxis(), mode, pLow, pHigh); - histDeltaKaon->SetMarkerStyle(22); - histDeltaKaon->Draw("e p same"); - histDeltaProton->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histDeltaProton->GetXaxis(), mode, pLow, pHigh); - histDeltaProton->SetMarkerStyle(29); - histDeltaProton->Draw("e p same"); - if (plotIdentifiedSpectra) { - histMC->GetYaxis()->SetTitle(canvTitle.Data()); - SetReasonableAxisRange(histMC->GetXaxis(), mode, pLow, pHigh); - histMC->SetMarkerStyle(24); - histMC->Draw("e p same"); - } - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - - legend->AddEntry(histDeltaPion, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{#pi}}" : "_{#pi}"), "p"); - legend->AddEntry(histDeltaElectron, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{e}}" : "_{e}"), "p"); - legend->AddEntry(histDeltaKaon, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{K}}" : "_{K}"), "p"); - legend->AddEntry(histDeltaProton, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{p}}" : "_{p}"), "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(histMC, identifiedLabels[isMC].Data(), "p"); - legend->SetEntrySeparation(0.2); - legend->Draw(); - - ClearTitleFromHistoInCanvas(canv); - - return canv; -} - - -//____________________________________________________________________________________________________________________ -Int_t doSimultaneousFitRegularised(Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, Double_t* covMatrix, - Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, Double_t& reducedChiSquare) -{ - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - Double_t chiSquare = -999; - Int_t ndf = -1; - - AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; - multiGaussFitArray[0] = multiGaussFitDeltaPi; - multiGaussFitArray[1] = multiGaussFitDeltaKa; - multiGaussFitArray[2] = multiGaussFitDeltaPr; - multiGaussFitArray[3] = multiGaussFitDeltaEl; - - AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; - errorOfFitHistosArray[0] = errorOfFitHistosDeltaPi; - errorOfFitHistosArray[1] = errorOfFitHistosDeltaKa; - errorOfFitHistosArray[2] = errorOfFitHistosDeltaPr; - errorOfFitHistosArray[3] = errorOfFitHistosDeltaEl; - - //TODO errorFunction for bin errors of fit histos? - Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, - chiSquare, ndf, stepSize, lowParLimits, upParLimits); - //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, - // chiSquare, ndf, stepSize, lowParLimits, upParLimits); - - std::cout << std::endl; - - for (Int_t xBin = 0; xBin < mathFit->GetNumXbinsRegularisation(); xBin++) { - std::cout << "x bin " << xBin << ":" << std::endl; - - Double_t sumFractions = 0; - - for (Int_t parIndex = xBin * mathFit->GetNumParametersPerXbin(); parIndex < (xBin + 1) * mathFit->GetNumParametersPerXbin(); - parIndex++) { - Int_t parIndexModulo = parIndex % mathFit->GetNumParametersPerXbin(); - - // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so - // the error from the matrix would be zero. - // parIndexModulo = 4 means muons, parIndexModulo = 3 means electrons, i.e. if parIndexModulo corresponds to muons, - // then parIndexModulo - 1 corresponds to electrons. - - // Set electron fraction to value evaluated from a function above some threshold. - // Fixed electron fraction < 0 does this job within the fitting functions - if (parIndexModulo == 3 && gausParams[parIndex] < 0) { - gausParams[parIndex] = GetElectronFraction(-gausParams[parIndex], &gausParams[0]); - parameterErrorsOut[parIndex] = GetElectronFractionError(); - } - // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, - // which should be a reasonable approximation: - // Fixed muon fraction < 0 does this job within the fitting functions - else if (parIndexModulo == 4 && gausParams[parIndex] < 0) { - gausParams[parIndex] = GetMuonFractionFromElectronFractionAndPt(-gausParams[parIndex], gausParams[parIndex - 1]); - parameterErrorsOut[parIndex] = parameterErrorsOut[parIndex - 1]; - } - - - std::cout << "par[" << parIndex << "]: " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; - - if (parIndexModulo <= 3 || ((muonContamination || takeIntoAccountMuons) && parIndexModulo == 4)) - sumFractions += gausParams[parIndex]; - } - - std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " - << sumFractions; std::cout << std::endl; - std::cout << std::endl << std::endl; - } - - if (errFlag == 0) - std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; - else - std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; - - reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; - - return errFlag; -} - - -//____________________________________________________________________________________________________________________ -Int_t doSimultaneousFit(TH1D** hDelta, Double_t xLow, Double_t xUp, Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, - Double_t* covMatrix, Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, Double_t& - reducedChiSquare) -{ - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - Double_t chiSquare = -999; - Int_t ndf = -1; - - //TODO: - // Using no error on x (next TODO line) and no errorFunction (next after next TODO line) sometimes gives good results. - // However, it can completely fail for low statistics for the fit histos. - // Using either an error on x or the errorFunction both gives reasonable results, but might be slightly worse results in some cases - // (shifted/distorted data). Maybe: Choose one method - the rest is for systematic errors of this fitting - - //TODO The next TODO marks are only relevant for chiSquare, but not for loglikelihood - //TODO Use error in x also -> If reference histos have low statistics, this will be very important - - for (Int_t i = 0; i < numSimultaneousFits; i++) { - mathFit->InputData(hDelta[i], 0, i, xLow, xUp, -1., kFALSE); - //mathFit->InputData(hDelta[i], 0, i, xLow, xUp, -1., kTRUE); - } - - AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; - multiGaussFitArray[0] = multiGaussFitDeltaPi; - multiGaussFitArray[1] = multiGaussFitDeltaKa; - multiGaussFitArray[2] = multiGaussFitDeltaPr; - multiGaussFitArray[3] = multiGaussFitDeltaEl; - - AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; - errorOfFitHistosArray[0] = errorOfFitHistosDeltaPi; - errorOfFitHistosArray[1] = errorOfFitHistosDeltaKa; - errorOfFitHistosArray[2] = errorOfFitHistosDeltaPr; - errorOfFitHistosArray[3] = errorOfFitHistosDeltaEl; - - //TODO errorFunction for bin errors of fit histos? - Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, - chiSquare, ndf, stepSize, lowParLimits, upParLimits); - //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, - // chiSquare, ndf, stepSize, lowParLimits, upParLimits); - - std::cout << std::endl; - - // If the electron fraction is fixed, evaluate the error of the extrapolation of the fixed value - if (TMath::Abs(lowParLimits[3] - upParLimits[3]) < epsilon) { - // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so - // the error from the matrix would be zero - parameterErrorsOut[3] = GetElectronFractionError(); - } - - // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, - // which should be a reasonable approximation: - // Fixed muon fraction < 0 does this job within the fitting functions - if (gausParams[4] < 0 ) { - // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so - // the error from the matrix would be zero - gausParams[4] = GetMuonFractionFromElectronFractionAndPt(-gausParams[4], gausParams[3]); - parameterErrorsOut[4] = parameterErrorsOut[3]; - } - - Double_t sumFractions = 0; - for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { - std::cout << "par[" << parIndex << "]: " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; - } - sumFractions = gausParams[0] + gausParams[1] + gausParams[2] + gausParams[3]; - // In case of muon contamination add muon fraction also - if (muonContamination || takeIntoAccountMuons) { - sumFractions += gausParams[4]; - } - - std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " << sumFractions; std::cout << std::endl; - - if (errFlag == 0) - std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; - else - std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; - - reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; - - return errFlag; -} - - -//____________________________________________________________________________________________________________________ -Int_t doFit(TH1D* hDelta, Double_t xLow, Double_t xUp, Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, Double_t* covMatrix, - Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, TF1* totalDeltaSpecies, Double_t& reducedChiSquare) -{ - AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); - - Double_t chiSquare = -999; - Int_t ndf = -1; - - //TODO: - // Using no error on x (next TODO line) and no errorFunction (next after next TODO line) sometimes gives good results. - // However, it can completely fail for low statistics for the fit histos. - // Using either an error on x or the errorFunction both gives reasonable results, but might be slightly worse results in some cases - // (shifted/distorted data). Maybe: Choose one method - the rest is for systematic errors of this fitting - - //TODO The next TODO marks are only relevant for chiSquare, but not for loglikelihood - //TODO Use error in x also -> If reference histos have low statistics, this will be very important - mathFit->InputData(hDelta, 0, 0, xLow, xUp, -1., kFALSE); - //mathFit->InputData(hDelta, 0, 0, xLow, xUp, -1., kTRUE); - - AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[1]; - multiGaussFitArray[0] = multiGaussFit; - - AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[1]; - errorOfFitHistosArray[0] = errorOfFitHistos; - - //TODO errorFunction for bin errors of fit histos? - Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, - chiSquare, ndf, stepSize, lowParLimits, upParLimits); - //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, - // chiSquare, ndf, stepSize, lowParLimits, upParLimits); - - // If the electron fraction is fixed, evaluate the error of the extrapolation of the fixed value - if (TMath::Abs(lowParLimits[3] - upParLimits[3]) < epsilon) { - // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so - // the error from the matrix would be zero - parameterErrorsOut[3] = GetElectronFractionError(); - } - - // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, which should be a reasonable approximation: - // Fixed muon fraction < 0 does this job within the fitting functions - if (gausParams[4] < 0 ) { - // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so - // the error from the matrix would be zero - gausParams[4] = GetMuonFractionFromElectronFractionAndPt(-gausParams[4], gausParams[3]); - parameterErrorsOut[4] = parameterErrorsOut[3]; - } - - Double_t sumFractions = 0; - for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { - std::cout << totalDeltaSpecies->GetParName(parIndex) << ": " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; - } - sumFractions = gausParams[0] + gausParams[1] + gausParams[2] + gausParams[3]; - // In case of muon contamination add muon fraction also - if (muonContamination || takeIntoAccountMuons) { - sumFractions += gausParams[4]; - } - - std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " << sumFractions; - std::cout << std::endl; - - if (errFlag == 0) - std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; - else - std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; - - for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { - totalDeltaSpecies->SetParameter(parIndex, gausParams[parIndex]); - totalDeltaSpecies->SetParError(parIndex, parameterErrorsOut[parIndex]); - } - - reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; - - return errFlag; -} - - -//____________________________________________________________________________________________________________________ -Double_t setFractionsAndYields(Int_t slice, Double_t inverseBinWidth, Double_t binWidthFitHisto, Int_t species, Double_t* parametersOut, - Double_t* parameterErrorsOut, TH1* hFractionSpecies, TH1* hFractionPionsDeltaSpecies, - TH1* hFractionElectronsDeltaSpecies, TH1* hFractionKaonsDeltaSpecies, TH1* hFractionProtonsDeltaSpecies, - TH1* hFractionMuonsDeltaSpecies, TH1* hYieldSpecies, TH1* hYieldPionsDeltaSpecies, - TH1* hYieldElectronsDeltaSpecies, TH1* hYieldKaonsDeltaSpecies, TH1* hYieldProtonsDeltaSpecies, - TH1* hYieldMuonsDeltaSpecies, - Bool_t normaliseFractions = kFALSE) -{ - // Set fraction and yields in corresponding histograms. If normaliseFractions is kTRUE, the fractions will be normalised to unity - // and the normalisation factor will be returned (i.e. 1./sumFraction) - - Double_t normalisationFactor = 1.0; - - // Since a log likelihood fit is anyway used, the normalisation should give a factor close to unity - if (normaliseFractions) { - Double_t sumFractions = parametersOut[0] + (muonContamination ? parametersOut[3] : 0) + parametersOut[1] + parametersOut[2] + - parametersOut[3] + (takeIntoAccountMuons ? parametersOut[4] : 0.); - if (sumFractions > 0) { - normalisationFactor = 1./sumFractions; - for (Int_t i = 0; i < 5; i++) { - parametersOut[i] *= normalisationFactor; - - // Do not introduce an error for the normalisation, i.e. just scale parameters and fractions with the same factor which is - // assumed to be exact. - // Note that correlations should already be included in the parameterError - parameterErrorsOut[i] *= normalisationFactor; - } - } - } - - Double_t sumOfParticles = inverseBinWidth * parametersOut[5] / binWidthFitHisto; // Divide by binWidthFitHisto since parametersOut includes this width - - if (species == kPi) { - hFractionSpecies->SetBinContent(slice + 1, (parametersOut[0]+(muonContamination ? parametersOut[3] : 0))); - hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[0]); - } - else if (species == kEl) { - hFractionSpecies->SetBinContent(slice + 1, parametersOut[3]); - hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[3]); - } - else if (species == kKa) { - hFractionSpecies->SetBinContent(slice + 1, parametersOut[1]); - hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[1]); - } - else if (species == kPr) { - hFractionSpecies->SetBinContent(slice + 1, parametersOut[2]); - hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[2]); - } - else if (species == kMu) { - if (takeIntoAccountMuons) { - hFractionSpecies->SetBinContent(slice + 1, parametersOut[4]); - hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[4]); - - hYieldSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionSpecies->GetBinContent(slice + 1)); - hYieldSpecies->SetBinError(slice + 1, sumOfParticles * hFractionSpecies->GetBinError(slice + 1)); - } - - // Only set these histos for muons. The DeltaSpecies histos for muons will be set together with all other species - return normalisationFactor; - } - - hFractionPionsDeltaSpecies->SetBinContent(slice + 1, (parametersOut[0]+(muonContamination ? parametersOut[3] : 0))); - hFractionPionsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[0]);//TODO What about error of parOut[3]? - hFractionElectronsDeltaSpecies->SetBinContent(slice + 1, parametersOut[3]); - hFractionElectronsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[3]); - hFractionKaonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[1]); - hFractionKaonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[1]); - hFractionProtonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[2]); - hFractionProtonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[2]); - if (takeIntoAccountMuons) { - hFractionMuonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[4]); - hFractionMuonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[4]); - } - - hYieldSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionSpecies->GetBinContent(slice + 1)); - hYieldSpecies->SetBinError(slice + 1, sumOfParticles * hFractionSpecies->GetBinError(slice + 1)); - - hYieldPionsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaSpecies->GetBinContent(slice + 1)); - hYieldPionsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaSpecies->GetBinError(slice + 1)); - hYieldElectronsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaSpecies->GetBinContent(slice + 1)); - hYieldElectronsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaSpecies->GetBinError(slice + 1)); - hYieldKaonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaSpecies->GetBinContent(slice + 1)); - hYieldKaonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaSpecies->GetBinError(slice + 1)); - hYieldProtonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaSpecies->GetBinContent(slice + 1)); - hYieldProtonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaSpecies->GetBinError(slice + 1)); - if (takeIntoAccountMuons) { - hYieldMuonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaSpecies->GetBinContent(slice + 1)); - hYieldMuonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaSpecies->GetBinError(slice + 1)); - } - - return normalisationFactor; -} - -//____________________________________________________________________________________________________________________ -Int_t PID(TString fileName, Double_t deta, Double_t pLow, Double_t pHigh, Bool_t isMCdataSet, Int_t fitMethod, - Int_t muonFractionHandlingParameter, //0 = no muons, 1 = muonFrac=elFrac, - //2(3) = muonFrac/elFrac tuned on MC for StandardTrackCuts(HybridTrackCuts) - Bool_t useIdentifiedGeneratedSpectra, Bool_t plotIdentifiedSpectra, Int_t mode/*0=pT,1=z,2=xi*/, - Int_t chargeMode /*kNegCharge = -1, kAllCharged = 0, kPosCharge = 1*/, - Double_t lowerCentrality /*= -2*/, Double_t upperCentrality /*= -2*/, - Double_t lowerJetPt /*= -1*/ , Double_t upperJetPt/* = -1*/, - Int_t rebin/* = 1 -> DON'T USE FOR PT (will not work since binsPt will and should be used!)*/, - Int_t rebinDeltaPrime/* = 1*/, - TString listName /* = "bhess_PID"*/, - Bool_t useLogLikelihood /*= kTRUE*/, Bool_t useWeightsForLogLikelihood /*= kFALSE*/, - Int_t regularisation /*= 0*/, - Double_t regularisationFactor /*= 1*/, - TString filePathNameFileWithInititalFractions /*= ""*/, - TString* filePathNameResults /*= 0x0*/) -{ - // Do all the fitting - - isMC = isMCdataSet; - - muonFractionHandling = muonFractionHandlingParameter; - - Int_t genAxis = useDeltaPrime ? kPidGenDeltaPrime : 1000/*kPidGenDelta*/; - if (!useDeltaPrime) { - std::cout << "ERROR: delta plots no longer available!" << std::endl; - return -1; - } - - if (listName == "") { - listName = fileName; - listName.Replace(0, listName.Last('/') + 1, ""); - listName.ReplaceAll(".root", ""); - } - - - if (rebin > 1 && mode == kPMpT) { - std::cout << "ERROR: Requested re-binning of pT-axis! Since binsPt will be used, re-binning the data histo will lead to " - << "unforeseen consequences!" << std::endl; - return -1; - } - - Int_t pSliceLow = -1; - Int_t pSliceHigh = -1; - - Int_t axisForMode = kPidPt; - Int_t axisGenForMode = kPidGenPt; - - std::cout << "Fitting \"" << fileName.Data() << "\" with settings:" << std::endl; - - std::cout << "Minimisation strategy: " << minimisationStrategy.Data() << std::endl; - if (useLogLikelihood) - std::cout << "Binned loglikelihood fit" << (useWeightsForLogLikelihood ? " (weighted)" : "") << std::endl; - else - std::cout << "ChiSquare fit" << std::endl; - std::cout << "Processing mode: "; - if (mode == kPMpT) - std::cout << "pT" << std::endl; - else if (mode == kPMz) { - std::cout << "z" << std::endl; - axisForMode = kPidZ; - axisGenForMode = kPidGenZ; - } - else if (mode == kPMxi) { - std::cout << "xi" << std::endl; - axisForMode = kPidXi; - axisGenForMode = kPidGenXi; - } - else { - std::cout << "Unknown -> ERROR" << std::endl; - return -1; - } - - std::cout << "Charge selection: "; - if (chargeMode == kAllCharged) - std::cout << "All charged particles" << std::endl; - else if (chargeMode == kNegCharge) - std::cout << "Negative particles only" << std::endl; - else if (chargeMode == kPosCharge) - std::cout << "Positive particles only" << std::endl; - else { - std::cout << "Unknown -> ERROR" << std::endl; - return -1; - } - - const Bool_t restrictCharge = (chargeMode != kAllCharged); - - if (regularisation > 0) - std::cout << "Regularisation with +-" << regularisation << " bins and factor " << regularisationFactor << " for penalty term." - << std::endl; - else - std::cout << "No regularisation" << std::endl; - - std::cout << "Assumption on muon fraction: "; - if (muonFractionHandlingParameter >= 0 && muonFractionHandlingParameter < kNumHandlings) - std::cout << muonFractionHandlingShortName[muonFractionHandlingParameter].Data() << std::endl; - /*if (muonFractionHandlingParameter == kNoMuons) - std::cout << "Identical zero" << std::endl; - else if (muonFractionHandlingParameter == kMuonFracEqualElFrac) - std::cout << "Equal electron fraction" << std::endl; - else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCStandardTrackCuts) - std::cout << "Ratio to electron fraction tuned on MC for standard track cuts" << std::endl; - else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCuts) - std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts" << std::endl; - else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) - std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts for jet particles" << std::endl; - else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) - std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts for jet particles" << std::endl;*/ - else { - std::cout << "Unknown -> ERROR" << std::endl; - return -1; - } - - if (mode == kPMpT) { - Int_t index = 0; - while (pLow >= binsPt[index] && index < nPtBins) - index++; - pSliceLow = index - 1; - - index = 0; - while (pHigh > binsPt[index] && index < nPtBins) - index++; - pSliceHigh = index - 1; - - Int_t numMomIntervals = pSliceHigh - pSliceLow + 1; - - if (numMomIntervals <= 0 || pSliceLow < 0 || pSliceHigh > nPtBins) { - std::cout << "Wrong choice of limits pLow/pHigh!" << std::endl; - return -1; - } - - pLow = binsPt[pSliceLow]; - pHigh = binsPt[pSliceHigh + 1]; // need upper edge, but binsPt holds lower edge - std::cout << "pLow/pHigh: "; - std::cout << pLow << " / " << pHigh << std::endl; - } - - Bool_t initialiseWithFractionsFromFile = kFALSE; - TFile* fInitialFractions = 0x0; - TH1 *hInitFracEl = 0x0, *hInitFracKa = 0x0, *hInitFracPi = 0x0, *hInitFracMu = 0x0, *hInitFracPr = 0x0; - - if (filePathNameFileWithInititalFractions != "") { - initialiseWithFractionsFromFile = kTRUE; - - std::cout << "Initialising fractions from file: " << filePathNameFileWithInititalFractions.Data() << std::endl; - } - else - std::cout << "Not initialising fractions from file" << std::endl; - - if (initialiseWithFractionsFromFile) { - fInitialFractions = TFile::Open(filePathNameFileWithInititalFractions.Data()); - if (!fInitialFractions) { - std::cout << std::endl; - std::cout << "Failed to open file with initial fractions \"" << filePathNameFileWithInititalFractions.Data() << "\"!" - << std::endl; - return -1; - } - - hInitFracEl = (TH1*)fInitialFractions->Get("hFractionElectrons"); - hInitFracKa = (TH1*)fInitialFractions->Get("hFractionKaons"); - hInitFracPi = (TH1*)fInitialFractions->Get("hFractionPions"); - hInitFracMu = (TH1*)fInitialFractions->Get("hFractionMuons"); - hInitFracPr = (TH1*)fInitialFractions->Get("hFractionProtons"); - - if (!hInitFracEl || ! hInitFracKa || ! hInitFracPi || ! hInitFracMu || ! hInitFracPr) { - std::cout << std::endl; - std::cout << "Failed to load initial fractions from file \"" << filePathNameFileWithInititalFractions.Data() << "\"!" - << std::endl; - - fInitialFractions->Close(); - return -1; - } - } - - - - TObjArray* histList = 0x0; - - TFile* f = TFile::Open(fileName.Data()); - if (!f) { - std::cout << std::endl; - std::cout << "Failed to open file \"" << fileName.Data() << "\"!" << std::endl; - return -1; - } - - //TString listName = fileName; - //listName = listName.ReplaceAll(".root", ""); - //listName = listName.Remove(1, listName.Last('/') + 1); - histList = (TObjArray*)(f->Get(listName.Data())); - if (!histList) { - std::cout << std::endl; - std::cout << "Failed to load list \"" << listName.Data() << "\"!" << std::endl; - return -1; - } - - // Extract the data histogram - THnSparse* hPIDdata = dynamic_cast(histList->FindObject("hPIDdataAll")); - if (!hPIDdata) { - std::cout << std::endl; - std::cout << "Failed to load data histo!" << std::endl; - return -1; - } - - // If desired, rebin considered axis - if (rebin > 1 || rebinDeltaPrime > 1) { - const Int_t nDimensions = hPIDdata->GetNdimensions(); - Int_t rebinFactor[nDimensions]; - - for (Int_t dim = 0; dim < nDimensions; dim++) { - if (dim == axisForMode && rebin > 1) - rebinFactor[dim] = rebin; - else if (dim == kPidDeltaPrime && rebinDeltaPrime > 1) - rebinFactor[dim] = rebinDeltaPrime; - else - rebinFactor[dim] = 1; - } - - THnSparse* temp = hPIDdata->Rebin(&rebinFactor[0]); - hPIDdata->Reset(); - hPIDdata = temp; - } - - // Set proper errors, if not yet calculated - if (!hPIDdata->GetCalculateErrors()) { - std::cout << "Re-calculating errors of " << hPIDdata->GetName() << "..." << std::endl; - hPIDdata->Sumw2(); - Long64_t nBinsTHnSparse = hPIDdata->GetNbins(); - Double_t binContent = 0; - - for (Long64_t bin = 0; bin < nBinsTHnSparse; bin++) { - binContent = hPIDdata->GetBinContent(bin); - hPIDdata->SetBinError(bin, TMath::Sqrt(binContent)); - } - } - - - // If desired, restrict centrality axis - Int_t lowerCentralityBinLimit = -1; - Int_t upperCentralityBinLimit = -1; - Bool_t restrictCentralityAxis = kFALSE; - Double_t actualLowerCentrality = -1.; - Double_t actualUpperCentrality = -1.; - - if (lowerCentrality >= -1 && upperCentrality >= -1) { - // Add subtract a very small number to avoid problems with values right on the border between to bins - lowerCentralityBinLimit = hPIDdata->GetAxis(kPidCentrality)->FindBin(lowerCentrality + 0.001); - upperCentralityBinLimit = hPIDdata->GetAxis(kPidCentrality)->FindBin(upperCentrality - 0.001); - - // Check if the values look reasonable - if (lowerCentralityBinLimit <= upperCentralityBinLimit && lowerCentralityBinLimit >= 1 - && upperCentralityBinLimit <= hPIDdata->GetAxis(kPidCentrality)->GetNbins()) { - actualLowerCentrality = hPIDdata->GetAxis(kPidCentrality)->GetBinLowEdge(lowerCentralityBinLimit); - actualUpperCentrality = hPIDdata->GetAxis(kPidCentrality)->GetBinUpEdge(upperCentralityBinLimit); - - restrictCentralityAxis = kTRUE; - } - else { - std::cout << std::endl; - std::cout << "Requested centrality range out of limits or upper and lower limit are switched!" << std::endl; - return -1; - } - } - - std::cout << "centrality: "; - if (restrictCentralityAxis) { - std::cout << actualLowerCentrality << " - " << actualUpperCentrality << std::endl; - } - else { - std::cout << "All" << std::endl; - } - - if (restrictCentralityAxis) { - hPIDdata->GetAxis(kPidCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); - } - - - - // If desired, restrict jetPt axis - Int_t lowerJetPtBinLimit = -1; - Int_t upperJetPtBinLimit = -1; - Bool_t restrictJetPtAxis = kFALSE; - Double_t actualLowerJetPt = -1.; - Double_t actualUpperJetPt = -1.; - - if (lowerJetPt >= 0 && upperJetPt >= 0) { - // Add subtract a very small number to avoid problems with values right on the border between to bins - lowerJetPtBinLimit = hPIDdata->GetAxis(kPidJetPt)->FindBin(lowerJetPt + 0.001); - upperJetPtBinLimit = hPIDdata->GetAxis(kPidJetPt)->FindBin(upperJetPt - 0.001); - - // Check if the values look reasonable - if (lowerJetPtBinLimit <= upperJetPtBinLimit && lowerJetPtBinLimit >= 1 && upperJetPtBinLimit <= hPIDdata->GetAxis(kPidJetPt)->GetNbins()) { - actualLowerJetPt = hPIDdata->GetAxis(kPidJetPt)->GetBinLowEdge(lowerJetPtBinLimit); - actualUpperJetPt = hPIDdata->GetAxis(kPidJetPt)->GetBinUpEdge(upperJetPtBinLimit); - - restrictJetPtAxis = kTRUE; - } - else { - std::cout << std::endl; - std::cout << "Requested jet pT range out of limits or upper and lower limit are switched!" << std::endl; - return -1; - } - } - - std::cout << "jet pT: "; - if (restrictJetPtAxis) { - std::cout << actualLowerJetPt << " - " << actualUpperJetPt << std::endl; - } - else { - std::cout << "All" << std::endl; - } - - if (restrictJetPtAxis) { - hPIDdata->GetAxis(kPidJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); - } - - - // If desired, restrict charge axis - const Int_t indexChargeAxisData = GetAxisByTitle(hPIDdata, "Charge (e_{0})"); - if (indexChargeAxisData < 0 && restrictCharge) { - std::cout << "Error: Charge axis not found for data histogram!" << std::endl; - return -1; - } - Int_t lowerChargeBinLimitData = -1; - Int_t upperChargeBinLimitData = -2; - Double_t actualLowerChargeData = -999; - Double_t actualUpperChargeData = -999; - - if (restrictCharge) { - // Add subtract a very small number to avoid problems with values right on the border between to bins - if (chargeMode == kNegCharge) { - lowerChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(-1. + 0.001); - upperChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(0. - 0.001); - } - else if (chargeMode == kPosCharge) { - lowerChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(0. + 0.001); - upperChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(1. - 0.001); - } - - // Check if the values look reasonable - if (lowerChargeBinLimitData <= upperChargeBinLimitData && lowerChargeBinLimitData >= 1 - && upperChargeBinLimitData <= hPIDdata->GetAxis(indexChargeAxisData)->GetNbins()) { - actualLowerChargeData = hPIDdata->GetAxis(indexChargeAxisData)->GetBinLowEdge(lowerChargeBinLimitData); - actualUpperChargeData = hPIDdata->GetAxis(indexChargeAxisData)->GetBinUpEdge(upperChargeBinLimitData); - - std::cout << "Charge range data: " << actualLowerChargeData << " - " << actualUpperChargeData << std::endl; - } - else { - std::cout << std::endl; - std::cout << "Requested charge range out of limits or upper and lower limit are switched!" << std::endl; - return -1; - } - - hPIDdata->GetAxis(indexChargeAxisData)->SetRange(lowerChargeBinLimitData, upperChargeBinLimitData); - } - - std::cout << std::endl; - - - - // Open file in which all the projections (= intermediate results) will be saved - TString saveInterFName = fileName; - TString chargeString = ""; - if (chargeMode == kPosCharge) - chargeString = "_posCharge"; - else if (chargeMode == kNegCharge) - chargeString = "_negCharge"; - - saveInterFName = Form("%s_Projections_%s_%d_%s%s%s%s%s.root", saveInterFName.ReplaceAll(".root", "").Data(), - modeShortName[mode].Data(), - fitMethod, muonFractionHandlingShortName[muonFractionHandlingParameter].Data(), - useIdentifiedGeneratedSpectra ? "_idSpectra" : "", - restrictCentralityAxis ? Form("_centrality%.0f_%.0f", actualLowerCentrality, actualUpperCentrality) : "", - restrictJetPtAxis ? Form("_jetPt%.1f_%.1f", actualLowerJetPt, actualUpperJetPt) : "", - chargeString.Data()); - TFile *saveInterF = TFile::Open(saveInterFName.Data(), "RECREATE"); - saveInterF->cd(); - - // TH1 hist with number of processed events - Double_t numEvents = -1; - TH1* hNumEvents = dynamic_cast(histList->FindObject("fhEventsProcessed")); - if (!hNumEvents) { - std::cout << std::endl; - std::cout << "Histo with number of processed events not found! Yields will NOT be normalised to this number!" << std::endl - << std::endl; - } - else { - numEvents = restrictCentralityAxis ? hNumEvents->Integral(lowerCentralityBinLimit, upperCentralityBinLimit) : - hNumEvents->Integral(); - - if (numEvents <= 0) { - numEvents = -1; - std::cout << std::endl; - std::cout << "Number of processed events < 1 in selected range! Yields will NOT be normalised to this number!" - << std::endl << std::endl; - } - } - - - // TH1D hist with total yield per pT bin (-> project to arbitrary selectSpecies to avoid multiple counting) - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); - TH1D* hYieldPt = hPIDdata->Projection(axisForMode, "e"); - hYieldPt->SetName(Form("hYield%s", modeShortName[mode].Data())); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); - - - // Fill \Delta\species histograms for each momentum slice - Int_t nBins = hPIDdata->GetAxis(dataAxis)->GetNbins(); - Double_t xLow = hPIDdata->GetAxis(dataAxis)->GetXmin(); - Double_t xUp = hPIDdata->GetAxis(dataAxis)->GetXmax(); - - const Int_t numSlices = (mode == kPMpT) ? nPtBins : hPIDdata->GetAxis(axisForMode)->GetNbins(); - - TH1D* hDeltaPi[numSlices]; - TH1D* hDeltaEl[numSlices]; - TH1D* hDeltaKa[numSlices]; - TH1D* hDeltaPr[numSlices]; - - TH1D* hDeltaPiFitQA[numSlices]; - TH1D* hDeltaElFitQA[numSlices]; - TH1D* hDeltaKaFitQA[numSlices]; - TH1D* hDeltaPrFitQA[numSlices]; - - const Int_t nMCbins = 5; - TH1D* hDeltaPiMC[numSlices][nMCbins]; - TH1D* hDeltaElMC[numSlices][nMCbins]; - TH1D* hDeltaKaMC[numSlices][nMCbins]; - TH1D* hDeltaPrMC[numSlices][nMCbins]; - - - TH2D* h2Delta[4]; - TH2D* h2DeltaMC[4][nMCbins]; - - for (Int_t i = 0; i < 4; i++) { - TString speciesLabel = hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(i + 1); - - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(i + 1, i + 1); - h2Delta[i] = hPIDdata->Projection(dataAxis, axisForMode, "e"); - h2Delta[i]->SetName(Form("h2Delta_%s", speciesLabel.Data())); - h2Delta[i]->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); - h2Delta[i]->GetYaxis()->SetTitle(Form("#Delta%s_{%s} = dE/dx %s _{%s} (arb. units)", useDeltaPrime ? "'" : "", speciesLabel.Data(), - useDeltaPrime ? "/" : "-", speciesLabel.Data())); - - for (Int_t species = 0; species < nMCbins; species++) { - hPIDdata->GetAxis(kPidMCpid)->SetRange(species + 1, species + 1); // Select MC species - h2DeltaMC[i][species] = hPIDdata->Projection(dataAxis, axisGenForMode, "e"); - h2DeltaMC[i][species]->SetName(Form("h2Delta_MC_%s", speciesLabel.Data())); - h2DeltaMC[i][species]->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisGenForMode)->GetTitle()); - h2DeltaMC[i][species]->GetYaxis()->SetTitle(h2Delta[i]->GetYaxis()->GetTitle()); - } - hPIDdata->GetAxis(kPidMCpid)->SetRange(0, -1); - } - - Int_t firstValidSlice = -1; - for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hPIDdata->GetAxis(axisForMode)->GetNbins(); slice++) { - if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) - continue; - - if (firstValidSlice < 0) - firstValidSlice = slice; - - // Add/subtract some very small offset to be sure not to sit on the bin boundary, when looking for the integration/projection limits. - // For modes different from pT, just take 1 bin - const Int_t pBinLowProjLimit = (mode == kPMpT) ? h2Delta[0]->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; - const Int_t pBinUpProjLimit = (mode == kPMpT) ? h2Delta[0]->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; - - const TString binInfo = (mode == kPMpT) ? Form("%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) - : Form("%.2f_%s_%.2f", hPIDdata->GetAxis(axisForMode)->GetBinLowEdge(pBinLowProjLimit), - modeShortName[mode].Data(), - hPIDdata->GetAxis(axisForMode)->GetBinUpEdge(pBinUpProjLimit)); - - hDeltaEl[slice] = h2Delta[0]->ProjectionY(Form("hDeltaEl_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaEl[slice]->GetXaxis()->SetTitle(h2Delta[0]->GetYaxis()->GetTitle()); - hDeltaEl[slice]->GetXaxis()->SetTitleOffset(1.0); - hDeltaEl[slice]->SetStats(kFALSE); - - hDeltaKa[slice] = h2Delta[1]->ProjectionY(Form("hDeltaKa_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaKa[slice]->SetName(Form("hDeltaKa_%s", binInfo.Data())); - hDeltaKa[slice]->GetXaxis()->SetTitle(h2Delta[1]->GetYaxis()->GetTitle()); - hDeltaKa[slice]->GetXaxis()->SetTitleOffset(1.0); - hDeltaKa[slice]->SetStats(kFALSE); - - hDeltaPi[slice] = h2Delta[2]->ProjectionY(Form("hDeltaPi_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaPi[slice]->SetName(Form("hDeltaPi_%s", binInfo.Data())); - hDeltaPi[slice]->GetXaxis()->SetTitle(h2Delta[2]->GetYaxis()->GetTitle()); - hDeltaPi[slice]->GetXaxis()->SetTitleOffset(1.0); - hDeltaPi[slice]->SetStats(kFALSE); - - hDeltaPr[slice] = h2Delta[3]->ProjectionY(Form("hDeltaPr_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaPr[slice]->SetName(Form("hDeltaPr_%s", binInfo.Data())); - hDeltaPr[slice]->GetXaxis()->SetTitle(h2Delta[3]->GetYaxis()->GetTitle()); - hDeltaPr[slice]->GetXaxis()->SetTitleOffset(1.0); - hDeltaPr[slice]->SetStats(kFALSE); - - if (plotIdentifiedSpectra) { - // If identified spectra are available (mainly useful in the MC case) and shall be used, - // create histos with signals from identified particles - - // DeltaEl - for (Int_t species = 0; species < nMCbins; species++) { - hDeltaElMC[slice][species] = h2DeltaMC[0][species]->ProjectionY(Form("hDeltaElMC_%s_species_%d", binInfo.Data(), species), - pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaElMC[slice][species]->SetLineColor(getLineColor(species + 1)); - hDeltaElMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); - hDeltaElMC[slice][species]->SetMarkerStyle(24); - hDeltaElMC[slice][species]->SetLineStyle(1); - hDeltaElMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[0][species]->GetYaxis()->GetTitle()); - hDeltaElMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); - hDeltaElMC[slice][species]->SetStats(kFALSE); - } - - // DeltaKa - for (Int_t species = 0; species < nMCbins; species++) { - hDeltaKaMC[slice][species] = h2DeltaMC[1][species]->ProjectionY(Form("hDeltaKaMC_%s_species_%d", binInfo.Data(), species), - pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaKaMC[slice][species]->SetLineColor(getLineColor(species + 1)); - hDeltaKaMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); - hDeltaKaMC[slice][species]->SetMarkerStyle(24); - hDeltaKaMC[slice][species]->SetLineStyle(1); - hDeltaKaMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[1][species]->GetYaxis()->GetTitle()); - hDeltaKaMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); - hDeltaKaMC[slice][species]->SetStats(kFALSE); - } - - // DeltaPi - for (Int_t species = 0; species < nMCbins; species++) { - hDeltaPiMC[slice][species] = h2DeltaMC[2][species]->ProjectionY(Form("hDeltaPiMC_%s_species_%d", binInfo.Data(), species), - pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaPiMC[slice][species]->SetLineColor(getLineColor(species + 1)); - hDeltaPiMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); - hDeltaPiMC[slice][species]->SetMarkerStyle(24); - hDeltaPiMC[slice][species]->SetLineStyle(1); - hDeltaPiMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[2][species]->GetYaxis()->GetTitle()); - hDeltaPiMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); - hDeltaPiMC[slice][species]->SetStats(kFALSE); - } - - // DeltaPr - for (Int_t species = 0; species < nMCbins; species++) { - hDeltaPrMC[slice][species] = h2DeltaMC[3][species]->ProjectionY(Form("hDeltaPrMC_%s_species_%d", binInfo.Data(), species), - pBinLowProjLimit, pBinUpProjLimit, "e"); - hDeltaPrMC[slice][species]->SetLineColor(getLineColor(species + 1)); - hDeltaPrMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); - hDeltaPrMC[slice][species]->SetMarkerStyle(24); - hDeltaPrMC[slice][species]->SetLineStyle(1); - hDeltaPrMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[3][species]->GetYaxis()->GetTitle()); - hDeltaPrMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); - hDeltaPrMC[slice][species]->SetStats(kFALSE); - } - } - } - hPIDdata->GetAxis(kPidMCpid)->SetRange(0, -1); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); - - hPIDdata->GetAxis(axisForMode)->SetRange(0, -1); - - /* - // TOF TODO - TCanvas* cTOF = new TCanvas("cTOF", "TOF PID",100,10,1200,800); - cTOF->Divide(4,1); - cTOF->cd(1); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); - TH2D* h2TOFel = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); - h2TOFel->SetName("h2TOFel"); - h2TOFel->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(1))); - h2TOFel->Draw("colz"); - - cTOF->cd(2); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(2, 2); - TH2D* h2TOFka = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); - h2TOFka->SetName("h2TOFka"); - h2TOFka->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(2))); - h2TOFka->Draw("colz"); - - cTOF->cd(3); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(3, 3); - TH2D* h2TOFpi = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); - h2TOFpi->SetName("h2TOFpi"); - h2TOFpi->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(3))); - h2TOFpi->Draw("colz"); - - cTOF->cd(4); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(4, 4); - TH2D* h2TOFpr = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); - h2TOFpr->SetName("h2TOFpr"); - h2TOFpr->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(4))); - h2TOFpr->Draw("colz"); - - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); - */ - - // Start fitting of slices - TCanvas* cSingleFit[numSlices][4]; - - TF1* fitFuncTotalDeltaPion[numSlices]; - TF1* fitFuncTotalDeltaElectron[numSlices]; - TF1* fitFuncTotalDeltaKaon[numSlices]; - TF1* fitFuncTotalDeltaProton[numSlices]; - - // Histos for particle fractions - TH1F* hFractionElectrons = 0x0; - if (mode == kPMpT) - hFractionElectrons = new TH1F("hFractionElectrons", "e", nPtBins, binsPt); - else { - const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); - if (histBins->fN == 0) - hFractionElectrons = new TH1F("hFractionElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), - hPIDdata->GetAxis(axisForMode)->GetXmax()); - else - hFractionElectrons = new TH1F("hFractionElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray); - } - - hFractionElectrons->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); - hFractionElectrons->GetYaxis()->SetTitle("Fraction"); - hFractionElectrons->SetLineColor(getLineColor(kEl)); - hFractionElectrons->SetMarkerColor(getLineColor(kEl)); - hFractionElectrons->SetMarkerStyle(20); - hFractionElectrons->Sumw2(); - hFractionElectrons->SetStats(kFALSE); - - TH1F* hFractionElectronsDeltaPion = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaPion"); - TH1F* hFractionElectronsDeltaElectron = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaElectron"); - TH1F* hFractionElectronsDeltaKaon = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaKaon"); - TH1F* hFractionElectronsDeltaProton = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaProton"); - - TH1F* hFractionKaons = (TH1F*)hFractionElectrons->Clone("hFractionKaons"); - hFractionKaons->SetTitle("K"); - hFractionKaons->SetLineColor(getLineColor(kKa)); - hFractionKaons->SetMarkerColor(getLineColor(kKa)); - - TH1F* hFractionKaonsDeltaPion = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaPion"); - TH1F* hFractionKaonsDeltaElectron = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaElectron"); - TH1F* hFractionKaonsDeltaKaon = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaKaon"); - TH1F* hFractionKaonsDeltaProton = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaProton"); - - TH1F* hFractionPions = (TH1F*)hFractionElectrons->Clone("hFractionPions"); - hFractionPions->SetTitle("#pi"); - hFractionPions->SetLineColor(getLineColor(kPi)); - hFractionPions->SetMarkerColor(getLineColor(kPi)); - - TH1F* hFractionPionsDeltaPion = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaPion"); - TH1F* hFractionPionsDeltaElectron = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaElectron"); - TH1F* hFractionPionsDeltaKaon = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaKaon"); - TH1F* hFractionPionsDeltaProton = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaProton"); - - TH1F* hFractionProtons = (TH1F*)hFractionElectrons->Clone("hFractionProtons"); - hFractionProtons->SetTitle("p"); - hFractionProtons->SetLineColor(getLineColor(kPr)); - hFractionProtons->SetMarkerColor(getLineColor(kPr)); - - TH1F* hFractionProtonsDeltaPion = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaPion"); - TH1F* hFractionProtonsDeltaElectron = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaElectron"); - TH1F* hFractionProtonsDeltaKaon = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaKaon"); - TH1F* hFractionProtonsDeltaProton = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaProton"); - - TH1F* hFractionMuons = (TH1F*)hFractionElectrons->Clone("hFractionMuons"); - hFractionMuons->SetTitle("#mu"); - hFractionMuons->SetLineColor(getLineColor(kMu)); - hFractionMuons->SetMarkerColor(getLineColor(kMu)); - - TH1F* hFractionMuonsDeltaPion = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaPion"); - TH1F* hFractionMuonsDeltaElectron = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaElectron"); - TH1F* hFractionMuonsDeltaKaon = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaKaon"); - TH1F* hFractionMuonsDeltaProton = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaProton"); - - TH1F* hFractionSummed = (TH1F*)hFractionProtons->Clone("hFractionSummed"); - hFractionSummed->SetTitle("Sum"); - hFractionSummed->SetLineColor(kBlack); - hFractionSummed->SetMarkerColor(kBlack); - - - // MC fractions - TH1F* hFractionElectronsMC = (TH1F*)hFractionElectrons->Clone("hFractionElectronsMC"); - hFractionElectronsMC->SetMarkerStyle(24); - TH1F* hFractionKaonsMC = (TH1F*)hFractionKaons->Clone("hFractionKaonsMC"); - hFractionKaonsMC->SetMarkerStyle(24); - TH1F* hFractionPionsMC = (TH1F*)hFractionPions->Clone("hFractionPionsMC"); - hFractionPionsMC->SetMarkerStyle(24); - TH1F* hFractionMuonsMC = (TH1F*)hFractionMuons->Clone("hFractionMuonsMC"); - hFractionMuonsMC->SetMarkerStyle(24); - TH1F* hFractionProtonsMC = (TH1F*)hFractionProtons->Clone("hFractionProtonsMC"); - hFractionProtonsMC->SetMarkerStyle(24); - - - // Comparison fit result<->MC - TString fractionComparisonTitle = Form("Fraction fit / fraction %s", identifiedLabels[isMC].Data()); - TH1F* hFractionComparisonElectrons = (TH1F*)hFractionElectrons->Clone("hFractionComparisonElectrons"); - hFractionComparisonElectrons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - TH1F* hFractionComparisonMuons = (TH1F*)hFractionMuons->Clone("hFractionComparisonMuons"); - hFractionComparisonMuons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - TH1F* hFractionComparisonKaons = (TH1F*)hFractionKaons->Clone("hFractionComparisonKaons"); - hFractionComparisonKaons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - TH1F* hFractionComparisonPions = (TH1F*)hFractionPions->Clone("hFractionComparisonPions"); - hFractionComparisonPions->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - TH1F* hFractionComparisonProtons = (TH1F*)hFractionProtons->Clone("hFractionComparisonProtons"); - hFractionComparisonProtons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - TH1F* hFractionComparisonTotal = (TH1F*)hFractionSummed->Clone("hFractionComparisonTotal"); - hFractionComparisonTotal->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); - - - - // Histos for particle yields - TH1F* hYieldElectrons = 0x0; - if (mode == kPMpT) - hYieldElectrons = new TH1F("hYieldElectrons", "e", nPtBins, binsPt); - else { - const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); - if (histBins->fN == 0) - hYieldElectrons = new TH1F("hYieldElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), - hPIDdata->GetAxis(axisForMode)->GetXmax()); - else - hYieldElectrons = new TH1F("hYieldElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray); - } - - hYieldElectrons->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); - hYieldElectrons->GetYaxis()->SetTitle(Form("%s1/(2#pi%s) d^{2}N/d#etad%s%s", numEvents > 0 ? "1/N_{ev} " : "", - modeLatexName[mode].Data(), modeLatexName[mode].Data(), - mode == kPMpT ? " (GeV/c)^{-2}" : 0)); - hYieldElectrons->SetLineColor(getLineColor(kEl)); - hYieldElectrons->SetMarkerColor(getLineColor(kEl)); - hYieldElectrons->SetMarkerStyle(20); - hYieldElectrons->Sumw2(); - hYieldElectrons->SetStats(kFALSE); - - TH1F* hYieldElectronsDeltaPion = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaPion"); - TH1F* hYieldElectronsDeltaElectron = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaElectron"); - TH1F* hYieldElectronsDeltaKaon = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaKaon"); - TH1F* hYieldElectronsDeltaProton = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaProton"); - - TH1F* hYieldKaons = (TH1F*)hYieldElectrons->Clone("hYieldKaons"); - hYieldKaons->SetTitle("K"); - hYieldKaons->SetLineColor(getLineColor(kKa)); - hYieldKaons->SetMarkerColor(getLineColor(kKa)); - - TH1F* hYieldKaonsDeltaPion = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaPion"); - TH1F* hYieldKaonsDeltaElectron = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaElectron"); - TH1F* hYieldKaonsDeltaKaon = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaKaon"); - TH1F* hYieldKaonsDeltaProton = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaProton"); - - TH1F* hYieldPions = (TH1F*)hYieldElectrons->Clone("hYieldPions"); - hYieldPions->SetTitle("#pi"); - hYieldPions->SetLineColor(getLineColor(kPi)); - hYieldPions->SetMarkerColor(getLineColor(kPi)); - - TH1F* hYieldPionsDeltaPion = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaPion"); - TH1F* hYieldPionsDeltaElectron = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaElectron"); - TH1F* hYieldPionsDeltaKaon = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaKaon"); - TH1F* hYieldPionsDeltaProton = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaProton"); - - TH1F* hYieldProtons = (TH1F*)hYieldElectrons->Clone("hYieldProtons"); - hYieldProtons->SetTitle("p"); - hYieldProtons->SetLineColor(getLineColor(kPr)); - hYieldProtons->SetMarkerColor(getLineColor(kPr)); - - TH1F* hYieldProtonsDeltaPion = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaPion"); - TH1F* hYieldProtonsDeltaElectron = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaElectron"); - TH1F* hYieldProtonsDeltaKaon = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaKaon"); - TH1F* hYieldProtonsDeltaProton = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaProton"); - - TH1F* hYieldMuons = (TH1F*)hYieldElectrons->Clone("hYieldMuons"); - hYieldMuons->SetTitle("#mu"); - hYieldMuons->SetLineColor(getLineColor(kMu)); - hYieldMuons->SetMarkerColor(getLineColor(kMu)); - - TH1F* hYieldMuonsDeltaPion = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaPion"); - TH1F* hYieldMuonsDeltaElectron = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaElectron"); - TH1F* hYieldMuonsDeltaKaon = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaKaon"); - TH1F* hYieldMuonsDeltaProton = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaProton"); - - // MC yields - TH1F* hYieldElectronsMC = (TH1F*)hYieldElectrons->Clone("hYieldElectronsMC"); - hYieldElectronsMC->SetMarkerStyle(24); - TH1F* hYieldMuonsMC = (TH1F*)hYieldElectrons->Clone("hYieldMuonsMC"); - hYieldMuonsMC->SetMarkerStyle(24); - hYieldMuonsMC->SetLineColor(getLineColor(kMu)); - hYieldMuonsMC->SetMarkerColor(getLineColor(kMu)); - TH1F* hYieldKaonsMC = (TH1F*)hYieldKaons->Clone("hYieldKaonsMC"); - hYieldKaonsMC->SetMarkerStyle(24); - TH1F* hYieldPionsMC = (TH1F*)hYieldPions->Clone("hYieldPionsMC"); - hYieldPionsMC->SetMarkerStyle(24); - TH1F* hYieldProtonsMC = (TH1F*)hYieldProtons->Clone("hYieldProtonsMC"); - hYieldProtonsMC->SetMarkerStyle(24); - TH1F* hYieldSummedMC = (TH1F*)hYieldProtonsMC->Clone("hYieldSummedMC"); - hYieldSummedMC->SetTitle("Sum"); - hYieldSummedMC->SetLineColor(kBlack); - hYieldSummedMC->SetMarkerColor(kBlack); - - // Comparison fit result<->MC (yields) - TString yieldComparisonTitle = Form("Yield fit / yield %s", identifiedLabels[isMC].Data()); - TH1F* hYieldComparisonElectrons = (TH1F*)hYieldElectrons->Clone("hYieldComparisonElectrons"); - hYieldComparisonElectrons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); - TH1F* hYieldComparisonMuons = (TH1F*)hYieldMuons->Clone("hYieldComparisonMuons"); - hYieldComparisonMuons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); - TH1F* hYieldComparisonKaons = (TH1F*)hYieldKaons->Clone("hYieldComparisonKaons"); - hYieldComparisonKaons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); - TH1F* hYieldComparisonPions = (TH1F*)hYieldPions->Clone("hYieldComparisonPions"); - hYieldComparisonPions->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); - TH1F* hYieldComparisonProtons = (TH1F*)hYieldProtons->Clone("hYieldComparisonProtons"); - hYieldComparisonProtons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); - - - // To-pi ratios - TString electronString[3] = { "e^{-}", "e^{+}+e^{-}", "e^{+}" }; - TString muonString[3] = { "#mu^{-}", "#mu^{+}+#mu^{-}", "#mu^{+}" }; - TString kaonString[3] = { "K^{-}", "K^{+}+K^{-}", "K^{+}" }; - TString pionString[3] = { "#pi^{-}", "#pi^{+}+#pi^{-}", "#pi^{+}" }; - TString protonString[3] = { "#bar{p}", "p+#bar{p}", "p" }; - - TH1F* hRatioToPiElectrons = (TH1F*)hYieldElectrons->Clone("hRatioToPiElectrons"); - hRatioToPiElectrons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", - electronString[chargeMode+1].Data(), - modeLatexName[mode].Data(), - pionString[chargeMode+1].Data(), - modeLatexName[mode].Data())); - hRatioToPiElectrons->SetTitle(Form("%s", chargeMode == 0 - ? Form("(%s)/(%s)", electronString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) - : Form("%s/%s", electronString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); - - - TH1F* hRatioToPiMuons = (TH1F*)hYieldMuons->Clone("hRatioToPiMuons"); - hRatioToPiMuons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", - muonString[chargeMode+1].Data(), - modeLatexName[mode].Data(), - pionString[chargeMode+1].Data(), - modeLatexName[mode].Data())); - hRatioToPiMuons->SetTitle(Form("%s", chargeMode == 0 - ? Form("(%s)/(%s)", muonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) - : Form("%s/%s", muonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); - - TH1F* hRatioToPiKaons = (TH1F*)hYieldKaons->Clone("hRatioToPiKaons"); - hRatioToPiKaons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", - kaonString[chargeMode+1].Data(), - modeLatexName[mode].Data(), - pionString[chargeMode+1].Data(), - modeLatexName[mode].Data())); - hRatioToPiKaons->SetTitle(Form("%s", chargeMode == 0 - ? Form("(%s)/(%s)", kaonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) - : Form("%s/%s", kaonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); - - TH1F* hRatioToPiProtons = (TH1F*)hYieldProtons->Clone("hRatioToPiProtons"); - hRatioToPiProtons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", - protonString[chargeMode+1].Data(), - modeLatexName[mode].Data(), - pionString[chargeMode+1].Data(), - modeLatexName[mode].Data())); - hRatioToPiProtons->SetTitle(Form("%s", chargeMode == 0 - ? Form("(%s)/(%s)", protonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) - : Form("%s/%s", protonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); - - // MC to-pi ratios - TH1F* hRatioToPiElectronsMC = (TH1F*)hRatioToPiElectrons->Clone("hRatioToPiElectronsMC"); - hRatioToPiElectronsMC->SetMarkerStyle(24); - TH1F* hRatioToPiMuonsMC = (TH1F*)hRatioToPiMuons->Clone("hRatioToPiMuonsMC"); - hRatioToPiMuonsMC->SetMarkerStyle(24); - hRatioToPiMuonsMC->SetLineColor(getLineColor(kMu)); - hRatioToPiMuonsMC->SetMarkerColor(getLineColor(kMu)); - TH1F* hRatioToPiKaonsMC = (TH1F*)hRatioToPiKaons->Clone("hRatioToPiKaonsMC"); - hRatioToPiKaonsMC->SetMarkerStyle(24); - TH1F* hRatioToPiProtonsMC = (TH1F*)hRatioToPiProtons->Clone("hRatioToPiProtonsMC"); - hRatioToPiProtonsMC->SetMarkerStyle(24); - - // Reduced Chi^2 of fits vs. pT for all Delta_Species - TH2F* hReducedChiSquarePt = 0x0; - if (mode == kPMpT) - hReducedChiSquarePt = new TH2F("hReducedChiSquarePt", "e", nPtBins, binsPt, 4, 0, 4); - else { - const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); - if (histBins->fN == 0) - hReducedChiSquarePt = new TH2F(Form("hReducedChiSquare%s", modeShortName[mode].Data()), "e", - hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), - hPIDdata->GetAxis(axisForMode)->GetXmax(), 4, 0, 4); - else - hReducedChiSquarePt = new TH2F(Form("hReducedChiSquare%s", modeShortName[mode].Data()), "e", - hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray, 4, 0, 4); - } - - hReducedChiSquarePt->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); - hReducedChiSquarePt->GetYaxis()->SetTitle("Delta_{Species}"); - hReducedChiSquarePt->GetYaxis()->SetBinLabel(1, "e"); - hReducedChiSquarePt->GetYaxis()->SetBinLabel(2, "K"); - hReducedChiSquarePt->GetYaxis()->SetBinLabel(3, "#pi"); - hReducedChiSquarePt->GetYaxis()->SetBinLabel(4, "p"); - hReducedChiSquarePt->SetMarkerColor(kRed); - hReducedChiSquarePt->SetMarkerStyle(20); - hReducedChiSquarePt->SetStats(kFALSE); - - // Obtain MC information about particle yields - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); // Do not count each particle more than once - TH2D* hMCdata = (TH2D*)hPIDdata->Projection(kPidMCpid, axisForMode, "e"); - hMCdata->SetName("hMCdata"); - hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); // Reset range - - - - // Extract the MC truth generated primary yields - THnSparse* hMCgeneratedYieldsPrimaries = isMCdataSet ? dynamic_cast(histList->FindObject("fhMCgeneratedYieldsPrimaries")) - : 0x0; - - TH1D* hMCgenYieldsPrimSpecies[AliPID::kSPECIES]; - for (Int_t i = 0; i < AliPID::kSPECIES; i++) - hMCgenYieldsPrimSpecies[i] = 0x0; - - if (hMCgeneratedYieldsPrimaries) { - // Set proper errors, if not yet calculated - if (!hMCgeneratedYieldsPrimaries->GetCalculateErrors()) { - std::cout << "Re-calculating errors of " << hMCgeneratedYieldsPrimaries->GetName() << "..." << std::endl; - - hMCgeneratedYieldsPrimaries->Sumw2(); - - Long64_t nBinsTHnSparseGenYield = hMCgeneratedYieldsPrimaries->GetNbins(); - Double_t binContentGenYield = 0; - for (Long64_t bin = 0; bin < nBinsTHnSparseGenYield; bin++) { - binContentGenYield = hMCgeneratedYieldsPrimaries->GetBinContent(bin); - hMCgeneratedYieldsPrimaries->SetBinError(bin, TMath::Sqrt(binContentGenYield)); - } - } - - if (restrictJetPtAxis) - hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); - - if (restrictCentralityAxis) - hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); - - - if (restrictCharge) { - const Int_t indexChargeAxisGenYield = GetAxisByTitle(hMCgeneratedYieldsPrimaries, "Charge (e_{0})"); - if (indexChargeAxisGenYield < 0) { - std::cout << "Error: Charge axis not found for gen yield histogram!" << std::endl; - return -1; - } - - Int_t lowerChargeBinLimitGenYield = -1; - Int_t upperChargeBinLimitGenYield = -2; - Double_t actualLowerChargeGenYield = -999; - Double_t actualUpperChargeGenYield = -999; - - // Add subtract a very small number to avoid problems with values right on the border between to bins - if (chargeMode == kNegCharge) { - lowerChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(-1. + 0.001); - upperChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(0. - 0.001); - } - else if (chargeMode == kPosCharge) { - lowerChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(0. + 0.001); - upperChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(1. - 0.001); - } - - // Check if the values look reasonable - if (lowerChargeBinLimitGenYield <= upperChargeBinLimitGenYield && lowerChargeBinLimitGenYield >= 1 - && upperChargeBinLimitGenYield <= hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetNbins()) { - actualLowerChargeGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetBinLowEdge(lowerChargeBinLimitGenYield); - actualUpperChargeGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetBinUpEdge(upperChargeBinLimitGenYield); - - if (TMath::Abs(actualLowerChargeGenYield - actualLowerChargeData) > 1e-4 || - TMath::Abs(actualUpperChargeGenYield - actualUpperChargeData) > 1e-4) { - std::cout << std::endl; - std::cout << "Error: Charge range gen yield: " << actualLowerChargeGenYield << " - " << actualUpperChargeGenYield - << std::endl << "differs from that of data: " << actualLowerChargeData << " - " << actualUpperChargeData - << std::endl; - return -1; - } - } - else { - std::cout << std::endl; - std::cout << "Requested charge range (gen yield) out of limits or upper and lower limit are switched!" << std::endl; - return -1; - } - - hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->SetRange(lowerChargeBinLimitGenYield, upperChargeBinLimitGenYield); - } - - for (Int_t MCid = 0; MCid < AliPID::kSPECIES; MCid++) { - hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldMCpid)->SetRange(MCid + 1, MCid + 1); - - hMCgenYieldsPrimSpecies[MCid] = hMCgeneratedYieldsPrimaries->Projection(kPidGenYieldPt, "e"); - hMCgenYieldsPrimSpecies[MCid]->SetName(Form("hMCgenYieldsPrimSpecies_%s", AliPID::ParticleShortName(MCid))); - hMCgenYieldsPrimSpecies[MCid]->SetTitle(Form("MC truth generated primary yield, %s", AliPID::ParticleName(MCid))); - - // Choose the same binning as for the fitted yields, i.e. rebin the histogram (Rebin will create a clone!) - TH1D* temp = (TH1D*)hMCgenYieldsPrimSpecies[MCid]->Rebin(nPtBins, hMCgenYieldsPrimSpecies[MCid]->GetName(), binsPt); - // Delete the old binned histo and take the new binned one - delete hMCgenYieldsPrimSpecies[MCid]; - hMCgenYieldsPrimSpecies[MCid] = temp; - - hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldMCpid)->SetRange(0, -1); - } - } - - - // Get expected shapes for pT bins - TString Ytitle = ""; - - // Array index 0 as unused dummy - TH2D* hGenDelta[6][6]; // DeltaSpecies (first index) for species (second index) - TH2D* hGenDeltaMCid[6][6]; // DeltaSpecies (first index) for species (second index) - - for (Int_t i = 0; i < 6; i++) { - for (Int_t j = 0; j < 6; j++) { - hGenDelta[i][j] = 0x0; - hGenDeltaMCid[i][j] = 0x0; - } - } - - THnSparse* current = 0x0; - - THnSparse* hGenEl = dynamic_cast(histList->FindObject("hGenEl")); - if (!hGenEl) { - std::cout << "Failed to load expected dEdx signal shape for: Electrons!" << std::endl; - return -1; - } - - THnSparse* hGenKa = dynamic_cast(histList->FindObject("hGenKa")); - if (!hGenKa) { - std::cout << "Failed to load expected dEdx signal shape for: Kaons!" << std::endl; - return -1; - } - - THnSparse* hGenPi = dynamic_cast(histList->FindObject("hGenPi")); - if (!hGenPi) { - std::cout << "Failed to load expected dEdx signal shape for: Pions!" << std::endl; - return -1; - } - - THnSparse* hGenMu = dynamic_cast(histList->FindObject("hGenMu")); - if (!hGenMu) { - std::cout << "Failed to load expected dEdx signal shape for: Muons! Treated muons as pions in the following." << std::endl; - takeIntoAccountMuons = kFALSE; - } - - THnSparse* hGenPr = dynamic_cast(histList->FindObject("hGenPr")); - if (!hGenPr) { - std::cout << "Failed to load expected dEdx signal shape for: Protons!" << std::endl; - return -1; - } - - for (Int_t MCid = kEl; MCid <= kPr; MCid++) { - if (MCid == kEl) - current = hGenEl; - else if (MCid == kKa) - current = hGenKa; - else if (MCid == kMu) { - if (takeIntoAccountMuons) - current = hGenMu; - else - continue; // No histo for muons in this case - } - else if (MCid == kPi) - current = hGenPi; - else if (MCid == kPr) - current = hGenPr; - else - break; - - // If desired, rebin considered axis - if (rebin > 1 || rebinDeltaPrime > 1) { - const Int_t nDimensions = current->GetNdimensions(); - Int_t rebinFactor[nDimensions]; - - for (Int_t dim = 0; dim < nDimensions; dim++) { - if (dim == axisGenForMode) - rebinFactor[dim] = rebin; - else if (dim == kPidGenDeltaPrime && rebinDeltaPrime > 1) - rebinFactor[dim] = rebinDeltaPrime; - else - rebinFactor[dim] = 1; - } - - THnSparse* temp = current->Rebin(&rebinFactor[0]); - current->Reset(); - current = temp; - } - - // Set proper errors, if not yet calculated - if (!current->GetCalculateErrors()) { - std::cout << "Re-calculating errors of " << current->GetName() << "..." << std::endl; - - current->Sumw2(); - - Long64_t nBinsTHnSparseGen = current->GetNbins(); - Double_t binContentGen = 0; - for (Long64_t bin = 0; bin < nBinsTHnSparseGen; bin++) { - binContentGen = current->GetBinContent(bin); - current->SetBinError(bin, TMath::Sqrt(binContentGen)); - } - } - - // If desired, restrict centrality range - if (restrictCentralityAxis) { - current->GetAxis(kPidGenCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); - } - - // If desired, restrict jet pT range - if (restrictJetPtAxis) { - current->GetAxis(kPidGenJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); - } - - // If desired, restrict charge range - if (restrictCharge) { - const Int_t indexChargeAxisGen = GetAxisByTitle(current, "Charge (e_{0})"); - if (indexChargeAxisGen < 0) { - std::cout << "Error: Charge axis not found for gen histogram!" << std::endl; - return -1; - } - - Int_t lowerChargeBinLimitGen = -1; - Int_t upperChargeBinLimitGen = -2; - Double_t actualLowerChargeGen = -999; - Double_t actualUpperChargeGen = -999; - - // Add subtract a very small number to avoid problems with values right on the border between to bins - if (chargeMode == kNegCharge) { - lowerChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(-1. + 0.001); - upperChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(0. - 0.001); - } - else if (chargeMode == kPosCharge) { - lowerChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(0. + 0.001); - upperChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(1. - 0.001); - } - - // Check if the values look reasonable - if (lowerChargeBinLimitGen <= upperChargeBinLimitGen && lowerChargeBinLimitGen >= 1 - && upperChargeBinLimitGen <= current->GetAxis(indexChargeAxisGen)->GetNbins()) { - actualLowerChargeGen = current->GetAxis(indexChargeAxisGen)->GetBinLowEdge(lowerChargeBinLimitGen); - actualUpperChargeGen = current->GetAxis(indexChargeAxisGen)->GetBinUpEdge(upperChargeBinLimitGen); - - if (TMath::Abs(actualLowerChargeGen - actualLowerChargeData) > 1e-4 || - TMath::Abs(actualUpperChargeGen - actualUpperChargeData) > 1e-4) { - std::cout << std::endl; - std::cout << "Error: Charge range gen: " << actualLowerChargeGen << " - " << actualUpperChargeGen - << std::endl << "differs from that of data: " << actualLowerChargeData << " - " << actualUpperChargeData - << std::endl; - return -1; - } - } - else { - std::cout << std::endl; - std::cout << "Requested charge range (gen) out of limits or upper and lower limit are switched!" << std::endl; - return -1; - } - - current->GetAxis(indexChargeAxisGen)->SetRange(lowerChargeBinLimitGen, upperChargeBinLimitGen); - } - - - - for (Int_t selectBin = 1; selectBin <= 4; selectBin++) { - Int_t selectMCid = (selectBin >= 3) ? (selectBin+1) : selectBin; - - current->GetAxis(kPidGenSelectSpecies)->SetRange(selectBin, selectBin); - - Ytitle = Form("#Delta%s_{%s} = dE/dx %s _{%s} (arb. units)", useDeltaPrime ? "'" : "", - partShortName[selectMCid - 1].Data(), useDeltaPrime ? "/" : "-", - partShortName[selectMCid - 1].Data()); - - TH2* hGenCurrent = 0x0; - if (!useIdentifiedGeneratedSpectra) { - hGenDelta[selectMCid][MCid] = current->Projection(genAxis, axisGenForMode, "e"); - hGenDelta[selectMCid][MCid]->SetName(Form("hGenDelta%sFor%s", partShortName[selectMCid - 1].Data(), - partShortName[MCid - 1].Data())); - hGenCurrent = hGenDelta[selectMCid][MCid]; - } - else { - current->GetAxis(kPidGenMCpid)->SetRange(MCid, MCid); - hGenDeltaMCid[selectMCid][MCid] = current->Projection(genAxis, axisGenForMode, "e"); - hGenDeltaMCid[selectMCid][MCid]->SetName(Form("hGenDelta%sForMCid%s", partShortName[selectMCid - 1].Data(), - partShortName[MCid - 1].Data())); - - hGenCurrent = hGenDeltaMCid[selectMCid][MCid]; - current->GetAxis(kPidGenMCpid)->SetRange(0, -1); - } - - hGenCurrent->GetYaxis()->SetTitle(Ytitle.Data()); - hGenCurrent->SetLineColor(getLineColor(MCid)); - hGenCurrent->SetMarkerColor(getLineColor(MCid)); - hGenCurrent->SetLineWidth(2); - hGenCurrent->SetLineStyle(2); - hGenCurrent->SetMarkerStyle(20); - hGenCurrent->GetXaxis()->SetTitleOffset(1.0); - } - - current->GetAxis(kPidGenSelectSpecies)->SetRange(0, -1); - } - - // Free a lot of memory for the following procedure. Histogram is not needed anymore (only its projections) - delete f; - - // Save intermediate results - //TODO save intermediate TOF results - saveInterF->cd(); - - if (hMCdata) - hMCdata->Write(); - - for (Int_t i = 0; i < 6; i++) { - for (Int_t j = 0; j < 6; j++) { - if (hGenDelta[i][j]) - hGenDelta[i][j]->Write(); - - if (hGenDeltaMCid[i][j]) - hGenDeltaMCid[i][j]->Write(); - } - } - - for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { - if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) - continue; - - if(hDeltaPi[slice]) - hDeltaPi[slice]->Write(); - if(hDeltaEl[slice]) - hDeltaEl[slice]->Write(); - if(hDeltaKa[slice]) - hDeltaKa[slice]->Write(); - if(hDeltaPr[slice]) - hDeltaPr[slice]->Write(); - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) { - hDeltaElMC[slice][species]->Write(); - hDeltaKaMC[slice][species]->Write(); - hDeltaPiMC[slice][species]->Write(); - hDeltaPrMC[slice][species]->Write(); - } - } - } - - // File may not be closed because the projections are needed in the following! - //saveInterF->Close(); - - // Save some first results for the final output - TString saveFName = fileName; - saveFName = Form("%s_results_%s__%s_%d_reg%d_regFac%.2f_%s%s%s%s%s.root", saveFName.ReplaceAll(".root", "").Data(), - useLogLikelihood ? (useWeightsForLogLikelihood ? "weightedLLFit" : "LLFit") : "ChiSquareFit", - modeShortName[mode].Data(), fitMethod, regularisation, regularisationFactor, - muonFractionHandlingShortName[muonFractionHandlingParameter].Data(), - useIdentifiedGeneratedSpectra ? "_idSpectra" : "", - restrictCentralityAxis ? Form("_centrality%.0f_%.0f", actualLowerCentrality, actualUpperCentrality) : "", - restrictJetPtAxis ? Form("_jetPt%.1f_%.1f", actualLowerJetPt, actualUpperJetPt) : "", - chargeString.Data()); - TFile *saveF = TFile::Open(saveFName.Data(), "RECREATE"); - saveF->cd(); - - if (hFractionElectrons) - hFractionElectrons->Write(0, TObject::kWriteDelete); - - if (hFractionKaons) - hFractionKaons->Write(0, TObject::kWriteDelete); - - if (hFractionPions) - hFractionPions->Write(0, TObject::kWriteDelete); - - if (hFractionProtons) - hFractionProtons->Write(0, TObject::kWriteDelete); - - if (hFractionMuons) - hFractionMuons->Write(0, TObject::kWriteDelete); - - if (hFractionSummed) - hFractionSummed->Write(0, TObject::kWriteDelete); - - if (hFractionElectronsMC) - hFractionElectronsMC->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsMC) - hFractionKaonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionPionsMC) - hFractionPionsMC->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsMC) - hFractionMuonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsMC) - hFractionProtonsMC->Write(0, TObject::kWriteDelete); - - - if (hYieldElectrons) - hYieldElectrons->Write(0, TObject::kWriteDelete); - - if (hYieldKaons) - hYieldKaons->Write(0, TObject::kWriteDelete); - - if (hYieldPions) - hYieldPions->Write(0, TObject::kWriteDelete); - - if (hYieldProtons) - hYieldProtons->Write(0, TObject::kWriteDelete); - - if (hYieldMuons) - hYieldMuons->Write(0, TObject::kWriteDelete); - - if (hYieldElectronsMC) - hYieldElectronsMC->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsMC) - hYieldMuonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsMC) - hYieldKaonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldPionsMC) - hYieldPionsMC->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsMC) - hYieldProtonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldSummedMC) - hYieldSummedMC->Write(0, TObject::kWriteDelete); - - - if (hRatioToPiElectrons) - hRatioToPiElectrons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiMuons) - hRatioToPiMuons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiKaons) - hRatioToPiKaons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiProtons) - hRatioToPiProtons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiElectronsMC) - hRatioToPiElectronsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiMuonsMC) - hRatioToPiMuonsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiKaonsMC) - hRatioToPiKaonsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiProtonsMC) - hRatioToPiProtonsMC->Write(0, TObject::kWriteDelete); - - - // Dummy histo to create generic legend entries from - TH1D* hMCmuonsAndPionsDummy = 0x0; - if (plotIdentifiedSpectra && firstValidSlice >= 0) { - hMCmuonsAndPionsDummy = new TH1D(*hDeltaPiMC[firstValidSlice][kPi]); - hMCmuonsAndPionsDummy->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPionsDummy->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPionsDummy->SetName("hMCmuonsAndPionsDummy"); - } - - - muonFractionThresholdForFitting = 0.;//OLD 0.295; - muonFractionThresholdBinForFitting = (mode == kPMpT) ? FindMomentumBin(binsPt, muonFractionThresholdForFitting) : -1; - - electronFractionThresholdForFitting = 9.; - electronFractionThresholdBinForFitting = (mode == kPMpT) ? FindMomentumBin(binsPt, electronFractionThresholdForFitting) : -1; - - lastPtForCallOfGetElectronFraction = pHigh + 10.; // Make sure that this value is higher than in any call during the fit - - fElectronFraction = new TF1("fElectronFraction", Form("[0]+(x<%f)*[1]*(x-%f)", electronFractionThresholdForFitting, - electronFractionThresholdForFitting), - pLow, pHigh); - fElectronFraction->SetParameters(0.01, 0.0); - - - - TString speciesLabel[4] = {"El", "Ka", "Pi", "Pr" }; - - const Double_t binWidthFitHisto = 1.0; // Not used any longer - - // In case of regularisation, the actual number of x bins and the (for pT: logs of their) bin centres are required - Int_t numXBins = 0; - Double_t* xBinCentres = 0x0; - Double_t* xBinStatisticalWeight = 0x0; - Double_t* xBinStatisticalWeightError = 0x0; - - // Set the number of parameters per x bin: - // Regularisation only implemented for simultaneous fit. - const Int_t numParamsPerXbin = AliPID::kSPECIES + 1; // Fractions of each species + total yield in x bin - - // Construct the array of all the parameters that are to be regularised, i.e. only the FREE fractions - // and NOT the total yields or the x bin - Int_t nParToRegulariseSimultaneousFit = 0; - Int_t* indexParametersToRegularise = 0x0; - Int_t* lastNotFixedIndexOfParameters = 0x0; - - if (regularisation > 0) { - Int_t xBinIndexTemp = 0; - Int_t internalParIndexTemp = 0; - - // Loop twice over data: Determine the number of bins in the first iteration, allocate the memory and fill in the 2. iteration - for (Int_t i = 0; i < 2; i++) { - if (i == 1) { - if (numXBins == 0) { - printf("No bins for fitting! Exiting...\n"); - - return -1; - } - if (nParToRegulariseSimultaneousFit == 0) { - printf("No parameters to regularise! Exiting...\n"); - - return -1; - } - - xBinCentres = new Double_t[numXBins]; - xBinStatisticalWeight = new Double_t[numXBins]; - xBinStatisticalWeightError = new Double_t[numXBins]; - - indexParametersToRegularise = new Int_t[nParToRegulariseSimultaneousFit]; - - lastNotFixedIndexOfParameters = new Int_t[numParamsPerXbin]; - - // Set last not fixed index of parameter to numXBins, i.e. a index larger than any existing index. - // This will not restrict the parameter regularisation range. In the following, the range for electrons - // and muons will be restricted - for (Int_t iPar = 0; iPar < numParamsPerXbin; iPar++) - lastNotFixedIndexOfParameters[iPar] = numXBins; - } - - - for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { - if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) - continue; - - // There won't (actually: shouldn't) be tracks with a pT larger than the jet pT - if (mode == kPMpT && restrictJetPtAxis && binsPt[slice] >= actualUpperJetPt) - continue; - - const Int_t pBinLowProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; - const Int_t pBinUpProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; - - // NOTE: In case of regularisation, only the simultaneous fit values will be used, i.e. totalYield and not allDeltaSpecies! - - // Also take into account bin width in delta(Prime) plots -> Multiply by binWidthFitHisto - Double_t totalYieldError = 0; - const Double_t totalYield = binWidthFitHisto * hYieldPt->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, totalYieldError); - totalYieldError *= binWidthFitHisto; - - if (totalYield <= 0) - continue; - - if (i == 1) { - if (mode == kPMpT) - // Take the logarithm in case of pT - xBinCentres[xBinIndexTemp] = TMath::Log((binsPt[slice + 1] + binsPt[slice]) / 2.); - else - xBinCentres[xBinIndexTemp] = hFractionPions->GetXaxis()->GetBinCenter(slice + 1); - - xBinStatisticalWeight[xBinIndexTemp] = totalYield; - - // NOTE: The total yield is a fact - a number w/o error. However, one assigns this error here to use it - // to calculate the effective weighting for the weighted likelihood fit (and the error is only used for this). - // So, it is more like a weighting than an error... - xBinStatisticalWeightError[xBinIndexTemp] = totalYieldError; - - - // Mark the fractions for all species except for electrons and muons in this bin for regularisation - for (Int_t speciesIndex = 0; speciesIndex < AliPID::kSPECIES - 2; speciesIndex++) - indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + speciesIndex; - - // Also mark electrons for regularisation in this bin, if not fixed - if( !(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) ) { - indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + 3; - } - else { - // Set the index of the last x bin in which the parameter is not fixed. - // If the parameter is fixed in all x bins, this index will be -1. - if (xBinIndexTemp - 1 < lastNotFixedIndexOfParameters[3]) - lastNotFixedIndexOfParameters[3] = xBinIndexTemp - 1; - } - - // Also mark muons for regularisation in this bin, if not fixed - if( !(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) ) { - indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + 4; - } - else { - // Set the index of the last x bin in which the parameter is not fixed. - // If the parameter is fixed in all x bins, this index will be -1. - if (xBinIndexTemp - 1 < lastNotFixedIndexOfParameters[4]) - lastNotFixedIndexOfParameters[4] = xBinIndexTemp - 1; - } - - xBinIndexTemp++; - } - - if (i == 0) { - nParToRegulariseSimultaneousFit += AliPID::kSPECIES - 2; // Fracs for all species in this bin except for electrons and muons - - if( !(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) ) - nParToRegulariseSimultaneousFit++; // Also regularise electrons in this bin (not fixed) - - if( !(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) ) - nParToRegulariseSimultaneousFit++; // Also regularise muons in this bin (not fixed) - - numXBins++; - } - } - } - } - AliTPCPIDmathFit* mathFit = 0x0; - - if (regularisation > 0) { - mathFit = (fitMethod == 2) ? AliTPCPIDmathFit::Instance(numXBins, 4, 1810) - : AliTPCPIDmathFit::Instance(numXBins, 1, 1810); - } - else { - mathFit = (fitMethod == 2) ? AliTPCPIDmathFit::Instance(1, 4, 1810) - : AliTPCPIDmathFit::Instance(1, 1, 1810); - } - - mathFit->SetDebugLevel(0); - mathFit->SetEpsilon(5e-05); - mathFit->SetMaxCalls(1e8); - - mathFit->SetMinimisationStrategy(minimisationStrategy); - - mathFit->SetUseLogLikelihood(useLogLikelihood); - mathFit->SetUseWeightsForLogLikelihood(useWeightsForLogLikelihood); - - if (fitMethod == 2) { - // If the deltaPrime range is large enough, we artificially get a factor 4 in statistics by looking at the four - // different deltaPrimeSpecies, which have (except for binning effects) the same information. - // Therefore, to get the "real" statistical error, we need to multiply the obtained error by sqrt(4) = 2 - mathFit->SetScaleFactorError(2.); - } - - mathFit->SetRegularisation(regularisation, regularisationFactor); - - // Number of parameters for fitting - const Int_t nPar = 11; - - // Fracs of each species + total yield in x bin - const Int_t nParSimultaneousFit = AliPID::kSPECIES + 1; - - // Fracs of each species in x bin + tot yield in x bin - const Int_t nParSimultaneousFitRegularised = numXBins * (AliPID::kSPECIES + 1); - - if (regularisation > 0) { - if (!mathFit->SetParametersToRegularise(nParToRegulariseSimultaneousFit, numParamsPerXbin, indexParametersToRegularise, - lastNotFixedIndexOfParameters, xBinCentres, xBinStatisticalWeight, - xBinStatisticalWeightError)) - return -1; - } - - delete xBinCentres; - xBinCentres = 0x0; - - delete xBinStatisticalWeight; - xBinStatisticalWeight = 0x0; - - delete xBinStatisticalWeightError; - xBinStatisticalWeight = 0x0; - - delete indexParametersToRegularise; - indexParametersToRegularise = 0x0; - - delete lastNotFixedIndexOfParameters; - lastNotFixedIndexOfParameters = 0x0; - - - - gFractionElectronsData = new TGraphErrors(numXBins); - - // Fit each slice with sum of 4/5 shapes with means and sigmas fixed from last fitting step - // For electrons: Fit up to certain pT bin and use constant value for higher momenta - - // Two iterations required for regularisation - Bool_t regularisedFitDone = kFALSE; - Double_t reducedChiSquareRegularisation = -1; - - Double_t gausParamsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; - Double_t parameterErrorsOutRegularised[nParSimultaneousFitRegularised]; - Double_t lowParLimitsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; - Double_t upParLimitsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; - Double_t stepSizeSimultaneousFitRegularised[nParSimultaneousFitRegularised]; - - for (Int_t i = 0; i < nParSimultaneousFitRegularised; i++) { - gausParamsSimultaneousFitRegularised[i] = 0; - parameterErrorsOutRegularised[i] = 0; - lowParLimitsSimultaneousFitRegularised[i] = 0; - upParLimitsSimultaneousFitRegularised[i] = 0; - stepSizeSimultaneousFitRegularised[i] = 0; - } - - mathFit->ClearRefHistos(); - - - const Int_t nParUsed = (fitMethod == 2) ? ((regularisation <= 0) ? nParSimultaneousFit: nParSimultaneousFitRegularised) : nPar; - Double_t parameterErrorsOut[nParUsed]; - Double_t covMatrix[nParUsed][nParUsed]; - - for (Int_t iter = 0; iter < 2; iter++) { - if (regularisation <= 0 && iter == 0) - continue; // Only one iteration w/o regularisation - - Int_t currXbin = 0; - - for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { - if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) - continue; - - // There won't (actually: shouldn't) be tracks with a pT larger than the jet pT - if (mode == kPMpT && restrictJetPtAxis && binsPt[slice] >= actualUpperJetPt) - continue; - - if (regularisation <= 0) { - if (mode == kPMpT) - std::cout << "Fitting range " << binsPt[slice] << " GeV/c < Pt < " << binsPt[slice + 1] << " GeV/c..." << std::endl; - else { - std::cout << "Fitting range " << hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1) << " < " << modeShortName[mode].Data() << " < "; - std::cout << hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1) << "..." << std::endl; - } - } - - // Add/subtract some very small offset to be sure not to sit on the bin boundary, when looking for the integration/projection limits. - const Int_t pBinLowProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; - const Int_t pBinUpProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; - - // Also take into account bin width in delta(Prime) plots -> Multiply by binWidthFitHisto - const Double_t totalYield = binWidthFitHisto * hYieldPt->Integral(pBinLowProjLimit, pBinUpProjLimit); - - if (totalYield <= 0) { - std::cout << "Skipped bin (yield is zero)!" << std::endl; - continue; - } - - const Double_t allDeltaPion = hDeltaPi[slice]->Integral(); - const Double_t allDeltaElectron = hDeltaEl[slice]->Integral(); - const Double_t allDeltaKaon = hDeltaKa[slice]->Integral(); - const Double_t allDeltaProton = hDeltaPr[slice]->Integral(); - - // inverseBinWidth = 1.0, if the raw yield for each bin is requested. - // If divided by the bin size, the histograms give "yield per unit pT in the corresponding bin" or dN/dpT - Double_t inverseBinWidth = (mode == kPMpT) ? 1.0 / (binsPt[slice + 1] - binsPt[slice]) - : 1.0 / hYieldPt->GetBinWidth(slice + 1); - - TH1D *hGenDeltaElForElProj = 0x0, *hGenDeltaKaForElProj = 0x0, *hGenDeltaPiForElProj = 0x0, *hGenDeltaPrForElProj = 0x0; - TH1D *hGenDeltaElForKaProj = 0x0, *hGenDeltaKaForKaProj = 0x0, *hGenDeltaPiForKaProj = 0x0, *hGenDeltaPrForKaProj = 0x0; - TH1D *hGenDeltaElForPiProj = 0x0, *hGenDeltaKaForPiProj = 0x0, *hGenDeltaPiForPiProj = 0x0, *hGenDeltaPrForPiProj = 0x0; - TH1D *hGenDeltaElForMuProj = 0x0, *hGenDeltaKaForMuProj = 0x0, *hGenDeltaPiForMuProj = 0x0, *hGenDeltaPrForMuProj = 0x0; - TH1D *hGenDeltaElForPrProj = 0x0, *hGenDeltaKaForPrProj = 0x0, *hGenDeltaPiForPrProj = 0x0, *hGenDeltaPrForPrProj = 0x0; - - TH2D* hGenDeltaUsed[6][6]; - if (useIdentifiedGeneratedSpectra) { - for (Int_t i = 0; i < 6; i++) { - for (Int_t j = 0; j < 6; j++) { - hGenDeltaUsed[i][j] = hGenDeltaMCid[i][j]; - } - } - } - else { - for (Int_t i = 0; i < 6; i++) { - for (Int_t j = 0; j < 6; j++) { - hGenDeltaUsed[i][j] = hGenDelta[i][j]; - } - } - } - - hGenDeltaElForElProj =(TH1D*)hGenDeltaUsed[kEl][kEl]->ProjectionY(Form("hGenDeltaElForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaKaForElProj =(TH1D*)hGenDeltaUsed[kKa][kEl]->ProjectionY(Form("hGenDeltaKaForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPiForElProj =(TH1D*)hGenDeltaUsed[kPi][kEl]->ProjectionY(Form("hGenDeltaPiForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPrForElProj =(TH1D*)hGenDeltaUsed[kPr][kEl]->ProjectionY(Form("hGenDeltaPrForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - - hGenDeltaElForKaProj =(TH1D*)hGenDeltaUsed[kEl][kKa]->ProjectionY(Form("hGenDeltaElForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaKaForKaProj =(TH1D*)hGenDeltaUsed[kKa][kKa]->ProjectionY(Form("hGenDeltaKaForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPiForKaProj =(TH1D*)hGenDeltaUsed[kPi][kKa]->ProjectionY(Form("hGenDeltaPiForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPrForKaProj =(TH1D*)hGenDeltaUsed[kPr][kKa]->ProjectionY(Form("hGenDeltaPrForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - - hGenDeltaElForPiProj =(TH1D*)hGenDeltaUsed[kEl][kPi]->ProjectionY(Form("hGenDeltaElForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaKaForPiProj =(TH1D*)hGenDeltaUsed[kKa][kPi]->ProjectionY(Form("hGenDeltaKaForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPiForPiProj =(TH1D*)hGenDeltaUsed[kPi][kPi]->ProjectionY(Form("hGenDeltaPiForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPrForPiProj =(TH1D*)hGenDeltaUsed[kPr][kPi]->ProjectionY(Form("hGenDeltaPrForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - - if (takeIntoAccountMuons) { - hGenDeltaElForMuProj =(TH1D*)hGenDeltaUsed[kEl][kMu]->ProjectionY(Form("hGenDeltaElForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaKaForMuProj =(TH1D*)hGenDeltaUsed[kKa][kMu]->ProjectionY(Form("hGenDeltaKaForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPiForMuProj =(TH1D*)hGenDeltaUsed[kPi][kMu]->ProjectionY(Form("hGenDeltaPiForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPrForMuProj =(TH1D*)hGenDeltaUsed[kPr][kMu]->ProjectionY(Form("hGenDeltaPrForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - } - - hGenDeltaElForPrProj =(TH1D*)hGenDeltaUsed[kEl][kPr]->ProjectionY(Form("hGenDeltaElForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaKaForPrProj =(TH1D*)hGenDeltaUsed[kKa][kPr]->ProjectionY(Form("hGenDeltaKaForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPiForPrProj =(TH1D*)hGenDeltaUsed[kPi][kPr]->ProjectionY(Form("hGenDeltaPiForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - hGenDeltaPrForPrProj =(TH1D*)hGenDeltaUsed[kPr][kPr]->ProjectionY(Form("hGenDeltaPrForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); - - - - if (fitMethod == 2) { - // Normalise generated histos to TOTAL number of GENERATED particles for this species (i.e. including - // entries that lie in the under or overflow bin), so that situations in which the generated spectra lie - // at least partly outside the histo are treated properly. To find the total number of generated particle - // species X, one can just take the integral of the generated histo for DeltaX (which should include all - // generated entries) and apply the same normalisation factor to all other DeltaSpecies. - // Also set some cosmetics - - // Generated electrons - Double_t normEl = normaliseHist(hGenDeltaElForElProj, -1); - normaliseHist(hGenDeltaKaForElProj, normEl); - normaliseHist(hGenDeltaPiForElProj, normEl); - normaliseHist(hGenDeltaPrForElProj, normEl); - - - // Generated kaons - Double_t normKa = normaliseHist(hGenDeltaKaForKaProj, -1); - normaliseHist(hGenDeltaElForKaProj, normKa); - normaliseHist(hGenDeltaPiForKaProj, normKa); - normaliseHist(hGenDeltaPrForKaProj, normKa); - - - // Generated pions - Double_t normPi = normaliseHist(hGenDeltaPiForPiProj, -1); - normaliseHist(hGenDeltaElForPiProj, normPi); - normaliseHist(hGenDeltaKaForPiProj, normPi); - normaliseHist(hGenDeltaPrForPiProj, normPi); - - - Double_t normMu = 1; - if (takeIntoAccountMuons) { - // Generated pions - // Since masses of muons and pions are so similar, the normalisation scheme should still work when looking at deltaPion instead - normMu = normaliseHist(hGenDeltaPiForMuProj, -1); - normaliseHist(hGenDeltaElForMuProj, normMu); - normaliseHist(hGenDeltaKaForMuProj, normMu); - normaliseHist(hGenDeltaPrForMuProj, normMu); - } - - - // Generated protons - Double_t normPr = normaliseHist(hGenDeltaPrForPrProj, -1); - normaliseHist(hGenDeltaElForPrProj, normPr); - normaliseHist(hGenDeltaKaForPrProj, normPr); - normaliseHist(hGenDeltaPiForPrProj, normPr); - } - else { - // Normalise generated histos to total number of particles for this delta - // and also set some cosmetics - - // DeltaEl - normaliseHist(hGenDeltaElForElProj); - normaliseHist(hGenDeltaElForKaProj); - normaliseHist(hGenDeltaElForPiProj); - if (takeIntoAccountMuons) - normaliseHist(hGenDeltaElForMuProj); - normaliseHist(hGenDeltaElForPrProj); - - // DeltaKa - normaliseHist(hGenDeltaKaForElProj); - normaliseHist(hGenDeltaKaForKaProj); - normaliseHist(hGenDeltaKaForPiProj); - if (takeIntoAccountMuons) - normaliseHist(hGenDeltaKaForMuProj); - normaliseHist(hGenDeltaKaForPrProj); - - // DeltaPi - normaliseHist(hGenDeltaPiForElProj); - normaliseHist(hGenDeltaPiForKaProj); - normaliseHist(hGenDeltaPiForPiProj); - if (takeIntoAccountMuons) - normaliseHist(hGenDeltaPiForMuProj); - normaliseHist(hGenDeltaPiForPrProj); - - // DeltaPr - normaliseHist(hGenDeltaPrForElProj); - normaliseHist(hGenDeltaPrForKaProj); - normaliseHist(hGenDeltaPrForPiProj); - if (takeIntoAccountMuons) - normaliseHist(hGenDeltaPrForMuProj); - normaliseHist(hGenDeltaPrForPrProj); - } - - - TF1* totalDeltaPion = 0x0; - TF1* totalDeltaKaon = 0x0; - TF1* totalDeltaProton = 0x0; - TF1* totalDeltaElectron = 0x0; - - TLegend* legend = 0x0; - - if (iter == 1) { // Only needed for second iteration (= the only iteration w/o regularisation) - // The number of parameters and their values will always be adjusted, such that using nPar parameters is fine - totalDeltaPion = new TF1(Form("totalDeltaPion_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaPi : multiGaussFit, - xLow, xUp, nPar); - setUpFitFunction(totalDeltaPion, nBins); - - totalDeltaKaon = new TF1(Form("totalDeltaKaon_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaKa : multiGaussFit, - xLow, xUp, nPar); - setUpFitFunction(totalDeltaKaon, nBins); - - totalDeltaProton = new TF1(Form("totalDeltaProton_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaPr : multiGaussFit, - xLow, xUp, nPar); - setUpFitFunction(totalDeltaProton, nBins); - - totalDeltaElectron = new TF1(Form("totalDeltaElectron_slice%d", slice), - (fitMethod == 2) ? multiGaussFitDeltaEl : multiGaussFit, - xLow, xUp, nPar); - setUpFitFunction(totalDeltaElectron, nBins); - - // Legend is the same for all \Delta "species" plots - legend = new TLegend(0.722126, 0.605932, 0.962069, 0.925932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - if (plotIdentifiedSpectra) - legend->SetNColumns(2); - legend->AddEntry((TObject*)0x0, "Fit", ""); - if (plotIdentifiedSpectra) - legend->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); - - legend->AddEntry(hDeltaPi[slice], "Data", "Lp"); - if (plotIdentifiedSpectra) - legend->AddEntry((TObject*)0x0, "", ""); - - legend->AddEntry(totalDeltaPion, "Multi-template fit", "L"); - if (plotIdentifiedSpectra) - legend->AddEntry(hMCmuonsAndPionsDummy, "#mu + #pi", "Lp"); - - if (takeIntoAccountMuons) - legend->AddEntry(hGenDeltaPiForMuProj, "#mu", "Lp"); - else if (plotIdentifiedSpectra) - legend->AddEntry((TObject*)0x0, "", ""); - if (plotIdentifiedSpectra) - legend->AddEntry(hDeltaPiMC[slice][kMu - 1], "#mu", "Lp"); - - legend->AddEntry(hGenDeltaPiForPiProj, takeIntoAccountMuons ? "#pi" : "#pi + #mu", "Lp"); - if (plotIdentifiedSpectra) - legend->AddEntry(hDeltaPiMC[slice][kPi - 1], "#pi", "Lp"); - - legend->AddEntry(hGenDeltaPiForKaProj, "K", "Lp"); - if (plotIdentifiedSpectra) - legend->AddEntry(hDeltaPiMC[slice][kKa - 1], "K", "Lp"); - - legend->AddEntry(hGenDeltaPiForPrProj, "p", "Lp"); - if (plotIdentifiedSpectra) - legend->AddEntry(hDeltaPiMC[slice][kPr - 1], "p", "Lp"); - - legend->AddEntry(hGenDeltaPiForElProj, "e", "Lp"); - if (plotIdentifiedSpectra) - legend->AddEntry(hDeltaPiMC[slice][kEl -1], "e", "Lp"); - } - - - // Allow tolerance of +-2% (for delta -> assume dEdx = 80 and take +-2%) - //const Double_t peakTolerance = (useDeltaPrime ? 0.8 : 1.0) / hGenDeltaElForElProj->GetXaxis()->GetBinWidth(1); - //const Double_t shiftStepSize = 0.01; - const Double_t peakTolerance = (useDeltaPrime ? 0.02 : 1.6); - const Double_t shiftStepSize = 0.01; - - // Assume fractions vs. pT to be smooth. Allow 1 sigma variations from bin to bin. For small pT, the error will be very small. - // Therefore, allow at least a change of some percent. - const Double_t nSigma = 1.; - const Double_t minChange = 1.0; // This disables the sigma restriction - - Double_t fractionPions = (muonContamination ? 0.87 : 0.88); - - Double_t fractionErrorUpPions = 1.; - Double_t fractionErrorLowPions = 0.; - - Int_t xBinInit = 0; - if (initialiseWithFractionsFromFile) { - Double_t xBinCentre = (mode == kPMpT) ? (binsPt[slice + 1] + binsPt[slice]) / 2. - : hYieldPt->GetXaxis()->GetBinCenter(slice + 1); - xBinInit = hInitFracPi->GetXaxis()->FindBin(xBinCentre); - fractionPions = hInitFracPi->GetBinContent(xBinInit) + (muonContamination ? hInitFracMu->GetBinContent(xBinInit) : 0.); - } - else { - // Set found fraction from last slice, if available. Note: Current bin for slice = slice + 1 - // => Bin for last slice = slice - if (hFractionPions->GetBinContent(slice) > 0 && hFractionPions->GetBinError(slice) > 0) { - fractionPions = hFractionPions->GetBinContent(slice); - fractionErrorUpPions = TMath::Min(1.0, fractionPions + TMath::Max(minChange, nSigma * hFractionPions->GetBinError(slice))); - fractionErrorLowPions = TMath::Max(0.0, fractionPions - TMath::Max(minChange, nSigma * hFractionPions->GetBinError(slice))); - } - } - - Double_t fractionKaons = 0.08; - Double_t fractionErrorUpKaons = 1.; - Double_t fractionErrorLowKaons = 0.; - - if (initialiseWithFractionsFromFile) { - fractionKaons = hInitFracKa->GetBinContent(xBinInit); - } - else { - if (hFractionKaons->GetBinContent(slice) > 0 && hFractionKaons->GetBinError(slice) > 0) { - fractionKaons = hFractionKaons->GetBinContent(slice); - fractionErrorUpKaons = TMath::Min(1.0, fractionKaons + TMath::Max(minChange, nSigma * hFractionKaons->GetBinError(slice))); - fractionErrorLowKaons = TMath::Max(0.0, fractionKaons - TMath::Max(minChange, nSigma * hFractionKaons->GetBinError(slice))); - } - } - - Double_t fractionProtons = 0.02; - Double_t fractionErrorUpProtons = 1.; - Double_t fractionErrorLowProtons = 0.; - - if (initialiseWithFractionsFromFile) { - fractionProtons = hInitFracPr->GetBinContent(xBinInit); - } - else { - if (hFractionProtons->GetBinContent(slice) > 0 && hFractionProtons->GetBinError(slice) > 0) { - fractionProtons = hFractionProtons->GetBinContent(slice); - fractionErrorUpProtons = TMath::Min(1.0, fractionProtons + - TMath::Max(minChange, nSigma * hFractionProtons->GetBinError(slice))); - fractionErrorLowProtons = TMath::Max(0.0, fractionProtons - - TMath::Max(minChange, nSigma * hFractionProtons->GetBinError(slice))); - } - } - - Double_t fractionElectrons = (takeIntoAccountMuons ? 0.01 : 0.02); - Double_t fractionErrorUpElectrons = 1.; - Double_t fractionErrorLowElectrons = 0.; - - if (initialiseWithFractionsFromFile) { - fractionElectrons = hInitFracEl->GetBinContent(xBinInit); - } - else { - if (hFractionElectrons->GetBinContent(slice) > 0 && hFractionElectrons->GetBinError(slice) > 0) { - fractionElectrons = hFractionElectrons->GetBinContent(slice); - fractionErrorUpElectrons = TMath::Min(1.0, fractionElectrons + - TMath::Max(minChange, nSigma * hFractionElectrons->GetBinError(slice))); - fractionErrorLowElectrons = TMath::Max(0.0, fractionElectrons - - TMath::Max(minChange, nSigma * hFractionElectrons->GetBinError(slice))); - } - } - - Double_t fractionMuons = (takeIntoAccountMuons ? 0.01 : 0.); - Double_t fractionErrorUpMuons = 1.; - Double_t fractionErrorLowMuons = 0.; - if (!takeIntoAccountMuons) { - fractionErrorUpMuons = 0.; - fractionErrorLowMuons = 0.; - } - else { - if (initialiseWithFractionsFromFile) { - fractionMuons = hInitFracMu->GetBinContent(xBinInit); - } - else { - if (hFractionMuons->GetBinContent(slice) > 0 && hFractionMuons->GetBinError(slice) > 0) { - fractionMuons = hFractionMuons->GetBinContent(slice); - fractionErrorUpMuons = TMath::Min(1.0, fractionMuons + TMath::Max(minChange, nSigma * hFractionMuons->GetBinError(slice))); - fractionErrorLowMuons = TMath::Max(0.0, fractionMuons - TMath::Max(minChange, nSigma * hFractionMuons->GetBinError(slice))); - } - } - } - - Double_t gausParamsPi[nPar] = { - fractionPions, - fractionKaons, - fractionProtons, - fractionElectrons, - fractionMuons, - allDeltaPion, - 0, - 0, - 0, - 0, - 0 - }; - - Double_t gausParamsEl[nPar] = { - fractionPions, - fractionKaons, - fractionProtons, - fractionElectrons, - fractionMuons, - allDeltaElectron, - 0, - 0, - 0, - 0, - 0 - }; - - Double_t gausParamsKa[nPar] = { - fractionPions, - fractionKaons, - fractionProtons, - fractionElectrons, - fractionMuons, - allDeltaKaon, - 0, - 0, - 0, - 0, - 0 - }; - - Double_t gausParamsPr[nPar] = { - fractionPions, - fractionKaons, - fractionProtons, - fractionElectrons, - fractionMuons, - allDeltaProton, - 0, - 0, - 0, - 0, - 0 - }; - - Double_t lowParLimitsPi[nPar] = { - fractionErrorLowPions, - fractionErrorLowKaons, - fractionErrorLowProtons, - fractionErrorLowElectrons, - fractionErrorLowMuons, - allDeltaPion, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance - }; - - Double_t lowParLimitsEl[nPar] = { - fractionErrorLowPions, - fractionErrorLowKaons, - fractionErrorLowProtons, - fractionErrorLowElectrons, - fractionErrorLowMuons, - allDeltaElectron, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance - }; - - Double_t lowParLimitsKa[nPar] = { - fractionErrorLowPions, - fractionErrorLowKaons, - fractionErrorLowProtons, - fractionErrorLowElectrons, - fractionErrorLowMuons, - allDeltaKaon, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance - }; - - Double_t lowParLimitsPr[nPar] = { - fractionErrorLowPions, - fractionErrorLowKaons, - fractionErrorLowProtons, - fractionErrorLowElectrons, - fractionErrorLowMuons, - allDeltaProton, - -peakTolerance, - -peakTolerance, - -peakTolerance, - -peakTolerance - -peakTolerance - }; - - - Double_t upParLimitsPi[nPar] = { - fractionErrorUpPions, - fractionErrorUpKaons, - fractionErrorUpProtons, - fractionErrorUpElectrons, - fractionErrorUpMuons, - allDeltaPion, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance - }; - - Double_t upParLimitsEl[nPar] = { - fractionErrorUpPions, - fractionErrorUpKaons, - fractionErrorUpProtons, - fractionErrorUpElectrons, - fractionErrorUpMuons, - allDeltaElectron, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance - }; - - Double_t upParLimitsKa[nPar] = { - fractionErrorUpPions, - fractionErrorUpKaons, - fractionErrorUpProtons, - fractionErrorUpElectrons, - fractionErrorUpMuons, - allDeltaKaon, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance - }; - - Double_t upParLimitsPr[nPar] = { - fractionErrorUpPions, - fractionErrorUpKaons, - fractionErrorUpProtons, - fractionErrorUpElectrons, - fractionErrorUpMuons, - allDeltaProton, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance, - peakTolerance, - }; - - Double_t stepSize[nPar] = { - 0.1, - 0.1, - 0.1, - 0.1, - (takeIntoAccountMuons ? 0.1 : 0.), - - 0.0, - - enableShift ? shiftStepSize : 0., - enableShift ? shiftStepSize : 0., - enableShift ? shiftStepSize : 0., - enableShift ? shiftStepSize : 0., - (enableShift && takeIntoAccountMuons) ? shiftStepSize : 0. - }; - - - Double_t gausParamsSimultaneousFit[nParSimultaneousFit] = { - fractionPions, - fractionKaons, - fractionProtons, - fractionElectrons, - fractionMuons, - totalYield - // No shifts because they do not make too much sense (different eta + possible deviations from Bethe-Bloch in one x-Bin) - }; - - Double_t lowParLimitsSimultaneousFit[nParSimultaneousFit] = { - fractionErrorLowPions, - fractionErrorLowKaons, - fractionErrorLowProtons, - fractionErrorLowElectrons, - fractionErrorLowMuons, - totalYield - }; - - Double_t upParLimitsSimultaneousFit[nParSimultaneousFit] = { - fractionErrorUpPions, - fractionErrorUpKaons, - fractionErrorUpProtons, - fractionErrorUpElectrons, - fractionErrorUpMuons, - totalYield - }; - - Double_t stepSizeSimultaneousFit[nParSimultaneousFit] = { - 0.1, - 0.1, - 0.1, - 0.1, - (takeIntoAccountMuons ? 0.1 : 0.), - - 0.0 - }; - - if (regularisation <= 0 && iter == 1) { - // In case of no regularisation, do the fit of the electron fraction here (compare comment below) - if (mode == kPMpT && slice == electronFractionThresholdBinForFitting) - hFractionElectrons->Fit(fElectronFraction, "N", "", lowFittingBoundElectronFraction, electronFractionThresholdForFitting); - } - - if ((regularisation > 0 && iter == 0) || (regularisation <= 0 && iter == 1)) { - // Set the electron fraction to the negative pT -> A function will be used - // to evaluate the electron fraction for each bin above the threshold - if(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) { - // In case of no regularisation, mathFit has no information about the fraction of other x bins. - // Thus, the electron fraction is evaluated and set here. For the case w/ regularisation, - // just "-pT" is set and the electron fraction will be evaluated during the fit. - Double_t fixElectronFraction = (regularisation <= 0) ? fElectronFraction->Eval((binsPt[slice + 1] + binsPt[slice]) / 2.) - : -(binsPt[slice + 1] + binsPt[slice]) / 2.; - - if (regularisation <= 0) { - fixElectronFraction = TMath::Min(1.0, fixElectronFraction); - fixElectronFraction = TMath::Max(0.0, fixElectronFraction); - } - - gausParamsPi[3] = fixElectronFraction; - lowParLimitsPi[3] = fixElectronFraction; - upParLimitsPi[3] = fixElectronFraction; - - gausParamsEl[3] = fixElectronFraction; - lowParLimitsEl[3] = fixElectronFraction; - upParLimitsEl[3] = fixElectronFraction; - - gausParamsKa[3] = fixElectronFraction; - lowParLimitsKa[3] = fixElectronFraction; - upParLimitsKa[3] = fixElectronFraction; - - gausParamsPr[3] = fixElectronFraction; - lowParLimitsPr[3] = fixElectronFraction; - upParLimitsPr[3] = fixElectronFraction; - - stepSize[3] = 0.0; - - gausParamsSimultaneousFit[3] = fixElectronFraction; - lowParLimitsSimultaneousFit[3] = fixElectronFraction; - upParLimitsSimultaneousFit[3] = fixElectronFraction; - - stepSizeSimultaneousFit[3] = 0.0; - } - - - // Set muon fraction equal to (some modified) electron fraction above some threshold, which should be a reasonable approximation: - // Fixed muon fraction < 0 does this job within the fitting functions - if(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) { - // "Abuse" the muon fraction to forward the pT, which can then be used to get some modified electron fraction - const Double_t fixedValue = -(binsPt[slice] + binsPt[slice + 1]) / 2.; - gausParamsPi[4] = fixedValue; - lowParLimitsPi[4] = fixedValue; - upParLimitsPi[4] = fixedValue; - - gausParamsEl[4] = fixedValue; - lowParLimitsEl[4] = fixedValue; - upParLimitsEl[4] = fixedValue; - - gausParamsKa[4] = fixedValue; - lowParLimitsKa[4] = fixedValue; - upParLimitsKa[4] = fixedValue; - - gausParamsPr[4] = fixedValue; - lowParLimitsPr[4] = fixedValue; - upParLimitsPr[4] = fixedValue; - - stepSize[4] = 0.; - - gausParamsSimultaneousFit[4] = fixedValue; - lowParLimitsSimultaneousFit[4] = fixedValue; - upParLimitsSimultaneousFit[4] = fixedValue; - - stepSizeSimultaneousFit[4] = 0.0; - } - } - - // iter 0 used for initialisation - if (regularisation > 0 && iter == 0) { - const Int_t offset = currXbin * mathFit->GetNumParametersPerXbin(); - for (Int_t i = 0; i < mathFit->GetNumParametersPerXbin(); i++) { - gausParamsSimultaneousFitRegularised[offset + i] = gausParamsSimultaneousFit[i]; - lowParLimitsSimultaneousFitRegularised[offset + i] = lowParLimitsSimultaneousFit[i]; - upParLimitsSimultaneousFitRegularised[offset + i] = upParLimitsSimultaneousFit[i]; - stepSizeSimultaneousFitRegularised[offset + i] = stepSizeSimultaneousFit[i]; - } - } - - - if (iter == 1) { - // The parameters are only used for fitMethod < 2. Thus, they can be set for these methods, - // although a different method is used - totalDeltaPion->SetParameters(gausParamsPi); - totalDeltaElectron->SetParameters(gausParamsEl); - totalDeltaKaon->SetParameters(gausParamsKa); - totalDeltaProton->SetParameters(gausParamsPr); - } - - const TString binInfo = (mode == kPMpT) ? Form("%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) - : Form("%.2f_%s_%.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), - modeShortName[mode].Data(), hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); - - const TString binInfoTitle = (mode == kPMpT) ? Form("%.2f < Pt <%.2f", binsPt[slice], binsPt[slice + 1]) - : Form("%.2f < %s < %.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), - modeShortName[mode].Data(), - hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); - - const TString fitFuncSuffix = (mode == kPMpT) ? Form("%.3f_Pt_%.3f", binsPt[slice], binsPt[slice + 1]) - : Form("%.3f_%s_%.3f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), - modeShortName[mode].Data(), - hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); - - if (iter == 1) { - for (Int_t species = 0; species < 4; species++) { - cSingleFit[slice][species] = new TCanvas(Form("cSingleFit_%s_%s", binInfo.Data(), speciesLabel[species].Data()), - Form("single fit for %s (%s)", binInfoTitle.Data(), speciesLabel[species].Data()), - 1366, 768); - cSingleFit[slice][species]->Divide(1, 2, 0.01, 0.); - cSingleFit[slice][species]->GetPad(1)->SetRightMargin(0.001); - cSingleFit[slice][species]->GetPad(2)->SetRightMargin(0.001); - cSingleFit[slice][species]->GetPad(1)->SetTopMargin(0.001); - cSingleFit[slice][species]->GetPad(2)->SetTopMargin(0.01); - cSingleFit[slice][species]->GetPad(1)->SetBottomMargin(0.01); - - cSingleFit[slice][species]->GetPad(1)->SetGridx(kTRUE); - cSingleFit[slice][species]->GetPad(2)->SetGridx(kTRUE); - cSingleFit[slice][species]->GetPad(1)->SetGridy(kTRUE); - cSingleFit[slice][species]->GetPad(2)->SetGridy(kTRUE); - - cSingleFit[slice][species]->GetPad(1)->SetLogy(kTRUE); - cSingleFit[slice][species]->GetPad(1)->SetLogx(kTRUE); - cSingleFit[slice][species]->GetPad(2)->SetLogx(kTRUE); - } - } - - // Problem: For p < 0.5 GeV/c, the fractions cannot be simply taken from the parameters because - // not all entries of the histogram are inside the considered range. - // Also: Small deviations of summed fractions from one if taking the fractions from different Delta species histos. - // Therefore: Add up the integrals of the individual fits (\Delta species) and take the fraction of the sum - Double_t integralTotal = 0; - Double_t integralPions = 0, integralKaons = 0, integralProtons = 0, integralElectrons = 0, integralMuons = 0; - - Double_t integralPionsDeltaPion = 0, integralPionsDeltaElectron = 0, integralPionsDeltaKaon = 0, integralPionsDeltaProton = 0; - Double_t integralElectronsDeltaPion = 0, integralElectronsDeltaElectron = 0, integralElectronsDeltaKaon = 0, - integralElectronsDeltaProton = 0; - Double_t integralKaonsDeltaPion = 0, integralKaonsDeltaElectron = 0, integralKaonsDeltaKaon = 0, integralKaonsDeltaProton = 0; - Double_t integralProtonsDeltaPion = 0, integralProtonsDeltaElectron = 0, integralProtonsDeltaKaon = 0, - integralProtonsDeltaProton = 0; - Double_t integralMuonsDeltaPion = 0, integralMuonsDeltaElectron = 0, integralMuonsDeltaKaon = 0, integralMuonsDeltaProton = 0; - - /* - Double_t integralErrorPions = 0, integralErrorKaons = 0, integralErrorProtons = 0, integralErrorElectrons = 0; - - Double_t integralErrorPionsDeltaPion = 0, integralErrorPionsDeltaElectron = 0, integralErrorPionsDeltaKaon = 0, - integralErrorPionsDeltaProton = 0; - Double_t integralErrorElectronsDeltaPion = 0, integralErrorElectronsDeltaElectron = 0, integralErrorElectronsDeltaKaon = 0, - integralErrorElectronsDeltaProton = 0; - Double_t integralErrorKaonsDeltaPion = 0, integralErrorKaonsDeltaElectron = 0, integralErrorKaonsDeltaKaon = 0, - integralErrorKaonsDeltaProton = 0; - Double_t integralErrorProtonsDeltaPion = 0, integralErrorProtonsDeltaElectron = 0, integralErrorProtonsDeltaKaon = 0, - integralErrorProtonsDeltaProton = 0; - - Double_t integralErrorTotalDeltaPion = 0, integralErrorTotalDeltaElectron = 0, integralErrorTotalDeltaKaon = 0; - Double_t integralErrorTotalDeltaProton = 0; - */ - - Int_t errFlag = 0; - - // Reset temp arrays for next slice - for (Int_t ind = 0; ind < nParUsed; ind++) - parameterErrorsOut[ind] = 0; - - // Do not reset, if regularisation is on and the fit is done because the covariance matrix - // will not be changed anymore in this case. On the other hand it will only be calculated once, - // so resetting it would mean that is not available anymore. - if (regularisation <= 0 || !regularisedFitDone) { - for (Int_t i = 0; i < nParUsed; i++) { - for (Int_t j = 0; j < nParUsed; j++) { - covMatrix[i][j] = 0; - } - } - } - - Double_t reducedChiSquare = -1; - - if (fitMethod == 2) { - if (regularisation <= 0 && iter == 1) - std::cout << "Fitting data simultaneously...." << std::endl << std::endl; - - // Add ref histos in initialisation step (w/ reg) or in the only loop (w/o reg) - if ((regularisation > 0 && iter == 0) || (regularisation <= 0 && iter == 1)) { - - if (regularisation <= 0) - mathFit->ClearRefHistos(); - - mathFit->AddRefHisto(hGenDeltaPiForPiProj); - mathFit->AddRefHisto(hGenDeltaPiForKaProj); - mathFit->AddRefHisto(hGenDeltaPiForPrProj); - mathFit->AddRefHisto(hGenDeltaPiForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPiForMuProj); - - mathFit->AddRefHisto(hGenDeltaKaForPiProj); - mathFit->AddRefHisto(hGenDeltaKaForKaProj); - mathFit->AddRefHisto(hGenDeltaKaForPrProj); - mathFit->AddRefHisto(hGenDeltaKaForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaKaForMuProj); - - mathFit->AddRefHisto(hGenDeltaPrForPiProj); - mathFit->AddRefHisto(hGenDeltaPrForKaProj); - mathFit->AddRefHisto(hGenDeltaPrForPrProj); - mathFit->AddRefHisto(hGenDeltaPrForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPrForMuProj); - - mathFit->AddRefHisto(hGenDeltaElForPiProj); - mathFit->AddRefHisto(hGenDeltaElForKaProj); - mathFit->AddRefHisto(hGenDeltaElForPrProj); - mathFit->AddRefHisto(hGenDeltaElForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaElForMuProj); - - // In reg case, fill in the data for this bin and continue with the nex bin - if (regularisation > 0) { - TH1D* hDeltaSpecies[numSimultaneousFits] = { hDeltaPi[slice], hDeltaKa[slice], hDeltaPr[slice], hDeltaEl[slice] }; - - for (Int_t i = 0; i < numSimultaneousFits; i++) { - mathFit->InputData(hDeltaSpecies[i], currXbin, i, xLow, xUp, -1., kFALSE); - } - - currXbin++; - continue; - } - } - - if (regularisation > 0 && iter == 1 && !regularisedFitDone) { - std::cout << "Fitting data simultaneously with regularisation...." << std::endl << std::endl; - - // TODO At the moment, the covariance matrix is NOT forwarded from TMinuit (has completely different dimensions) - // -> Since it is not used at the moment, this is not necessary. If it is to be used in future, - // this has to be implemented! But one has to be careful, since parameters from different bins then - // depend on each other! Furthermore, there will be no errors for fixed parameters like muon fraction or electron fraction - // above the corresponding threshold in the covariance matrix, but an estimated error will be set manually. - errFlag = errFlag | doSimultaneousFitRegularised(nParSimultaneousFitRegularised, gausParamsSimultaneousFitRegularised, - parameterErrorsOutRegularised, &covMatrix[0][0], - stepSizeSimultaneousFitRegularised, - lowParLimitsSimultaneousFitRegularised, - upParLimitsSimultaneousFitRegularised, reducedChiSquare); - if (errFlag != 0) - std::cout << "errFlag " << errFlag << std::endl << std::endl; - - reducedChiSquareRegularisation = reducedChiSquare; - - // Since everything is fitted in one go, only do this for the first x bin - // (more convenient to put the fitting in the x bin loop in order to intialise - // the parameters in the same way they are initialised for the fit w/o regularisation. - regularisedFitDone = kTRUE; - } - - if (regularisation > 0 && iter == 1) { - // To allow for an identical processing, just forward the parameter results for the current xBin to the - // array used by the standard simultaneous fit. The rest of the code is then the same for regularisation on and off - - for (Int_t i = 0; i < mathFit->GetNumParametersPerXbin(); i++) { - const Int_t iRegularised = i + currXbin * mathFit->GetNumParametersPerXbin(); - - gausParamsSimultaneousFit[i] = gausParamsSimultaneousFitRegularised[iRegularised]; - parameterErrorsOut[i] = parameterErrorsOutRegularised[iRegularised]; - } - - // Same reducedChiSquare for all bins, since only one fit - reducedChiSquare = reducedChiSquareRegularisation; - - - // Also clear reference histos and load those for the current bin - mathFit->ClearRefHistos(); - - mathFit->AddRefHisto(hGenDeltaPiForPiProj); - mathFit->AddRefHisto(hGenDeltaPiForKaProj); - mathFit->AddRefHisto(hGenDeltaPiForPrProj); - mathFit->AddRefHisto(hGenDeltaPiForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPiForMuProj); - - mathFit->AddRefHisto(hGenDeltaKaForPiProj); - mathFit->AddRefHisto(hGenDeltaKaForKaProj); - mathFit->AddRefHisto(hGenDeltaKaForPrProj); - mathFit->AddRefHisto(hGenDeltaKaForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaKaForMuProj); - - mathFit->AddRefHisto(hGenDeltaPrForPiProj); - mathFit->AddRefHisto(hGenDeltaPrForKaProj); - mathFit->AddRefHisto(hGenDeltaPrForPrProj); - mathFit->AddRefHisto(hGenDeltaPrForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPrForMuProj); - - mathFit->AddRefHisto(hGenDeltaElForPiProj); - mathFit->AddRefHisto(hGenDeltaElForKaProj); - mathFit->AddRefHisto(hGenDeltaElForPrProj); - mathFit->AddRefHisto(hGenDeltaElForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaElForMuProj); - } - - - if (regularisation <= 0) { - TH1D* hDeltaSpecies[numSimultaneousFits] = { hDeltaPi[slice], hDeltaKa[slice], hDeltaPr[slice], hDeltaEl[slice] }; - errFlag = errFlag | - doSimultaneousFit(hDeltaSpecies, xLow, xUp, nParSimultaneousFit, gausParamsSimultaneousFit, parameterErrorsOut, - &covMatrix[0][0], stepSizeSimultaneousFit, lowParLimitsSimultaneousFit, - upParLimitsSimultaneousFit, reducedChiSquare); - } - - // Forward parameters to single fits - for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { - // Fractions - if (parIndex <= 4) { - totalDeltaPion->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); - totalDeltaPion->SetParError(parIndex, parameterErrorsOut[parIndex]); - - totalDeltaKaon->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); - totalDeltaKaon->SetParError(parIndex, parameterErrorsOut[parIndex]); - - totalDeltaProton->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); - totalDeltaProton->SetParError(parIndex, parameterErrorsOut[parIndex]); - - totalDeltaElectron->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); - totalDeltaElectron->SetParError(parIndex, parameterErrorsOut[parIndex]); - } - // Total yield - else if (parIndex == 5) { - totalDeltaPion->SetParameter(parIndex, totalYield); - totalDeltaPion->SetParError(parIndex, 0); - - totalDeltaKaon->SetParameter(parIndex, totalYield); - totalDeltaKaon->SetParError(parIndex, 0); - - totalDeltaProton->SetParameter(parIndex, totalYield); - totalDeltaProton->SetParError(parIndex, 0); - - totalDeltaElectron->SetParameter(parIndex, totalYield); - totalDeltaElectron->SetParError(parIndex, 0); - } - // Hist shifts - else { - totalDeltaPion->SetParameter(parIndex, 0); - totalDeltaPion->SetParError(parIndex, 0); - - totalDeltaKaon->SetParameter(parIndex, 0); - totalDeltaKaon->SetParError(parIndex, 0); - - totalDeltaProton->SetParameter(parIndex, 0); - totalDeltaProton->SetParError(parIndex, 0); - - totalDeltaElectron->SetParameter(parIndex, 0); - totalDeltaElectron->SetParError(parIndex, 0); - } - } - - const Bool_t useRegularisation = regularisation > 0; - - // Plot single fits - - Int_t binLow = -1; - Int_t binHigh = -1; - - // DeltaPions - cSingleFit[slice][2]->cd(1); - - hDeltaPi[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaPi[slice], binLow, binHigh); - hDeltaPi[slice]->Draw("e"); - - fitFuncTotalDeltaPion[slice] = (TF1*)totalDeltaPion->Clone(Form("Fit_Total_DeltaPion_%s", fitFuncSuffix.Data())); - - hDeltaPiFitQA[slice] = (TH1D*)hDeltaPi[slice]->Clone(Form("hDeltaPiFitQA_%d", slice)); - hDeltaPiFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaPiFitQA[slice]->Add(fitFuncTotalDeltaPion[slice], -1); - hDeltaPiFitQA[slice]->Divide(hDeltaPi[slice]); - - hDeltaPi[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaPion[slice]); - fitFuncTotalDeltaPion[slice]->Draw("same"); - - Double_t* parametersOut = &totalDeltaPion->GetParameters()[0]; - - hGenDeltaPiForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); - shiftHist(hGenDeltaPiForPiProj, parametersOut[6], useRegularisation); - hGenDeltaPiForPiProj->Draw("same"); - - hGenDeltaPiForKaProj->Scale(parametersOut[5] * parametersOut[1]); - shiftHist(hGenDeltaPiForKaProj, parametersOut[7], useRegularisation); - hGenDeltaPiForKaProj->Draw("same"); - - hGenDeltaPiForPrProj->Scale(parametersOut[5] * parametersOut[2]); - shiftHist(hGenDeltaPiForPrProj, parametersOut[8], useRegularisation); - hGenDeltaPiForPrProj->Draw("same"); - - hGenDeltaPiForElProj->Scale(parametersOut[5] * parametersOut[3]); - shiftHist(hGenDeltaPiForElProj, parametersOut[9], useRegularisation); - hGenDeltaPiForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaPiForMuProj->Scale(parametersOut[5] * parametersOut[4]); - shiftHist(hGenDeltaPiForMuProj, parametersOut[10], useRegularisation); - hGenDeltaPiForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaPiMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPiMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaPiMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPiMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaPi[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][2]->cd(2); - hDeltaPiFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaPiFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 3, reducedChiSquare); - - // TMatrixDSym covMatrixPi(nParUsed, &covMatrix[0][0]); - - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPi, parametersOut, parameterErrorsOut, hFractionPions, - hFractionPionsDeltaPion, hFractionElectronsDeltaPion, hFractionKaonsDeltaPion, - hFractionProtonsDeltaPion, hFractionMuonsDeltaPion, hYieldPions, hYieldPionsDeltaPion, hYieldElectronsDeltaPion, - hYieldKaonsDeltaPion, hYieldProtonsDeltaPion, hYieldMuonsDeltaPion, normaliseResults); - - // Also set specific muon fractions and yields -> The deltaSpecies histos are not needed here: They will be set together with - // the fraction and yields for all other species - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kMu, parametersOut, parameterErrorsOut, hFractionMuons, - 0x0, 0x0, 0x0, 0x0, 0x0, hYieldMuons, 0x0, 0x0, 0x0, 0x0, 0x0, normaliseResults); - - - // DeltaElectrons - cSingleFit[slice][0]->cd(1); - - hDeltaEl[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaEl[slice], binLow, binHigh); - hDeltaEl[slice]->Draw("e"); - - fitFuncTotalDeltaElectron[slice] = (TF1*)totalDeltaElectron->Clone(Form("Fit_Total_DeltaElectron_%s", fitFuncSuffix.Data())); - - hDeltaElFitQA[slice] = (TH1D*)hDeltaEl[slice]->Clone(Form("hDeltaElFitQA_%d", slice)); - hDeltaElFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaElFitQA[slice]->Add(fitFuncTotalDeltaElectron[slice], -1); - hDeltaElFitQA[slice]->Divide(hDeltaEl[slice]); - - hDeltaEl[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaElectron[slice]); - fitFuncTotalDeltaElectron[slice]->Draw("same"); - - parametersOut = &totalDeltaElectron->GetParameters()[0]; - - hGenDeltaElForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); - shiftHist(hGenDeltaElForPiProj, parametersOut[6], useRegularisation); - hGenDeltaElForPiProj->Draw("same"); - - hGenDeltaElForKaProj->Scale(parametersOut[5] * parametersOut[1]); - shiftHist(hGenDeltaElForKaProj, parametersOut[7], useRegularisation); - hGenDeltaElForKaProj->Draw("same"); - - hGenDeltaElForPrProj->Scale(parametersOut[5] * parametersOut[2]); - shiftHist(hGenDeltaElForPrProj, parametersOut[8], useRegularisation); - hGenDeltaElForPrProj->Draw("same"); - - hGenDeltaElForElProj->Scale(parametersOut[5] * parametersOut[3]); - shiftHist(hGenDeltaElForElProj, parametersOut[9], useRegularisation); - hGenDeltaElForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaElForMuProj->Scale(parametersOut[5] * parametersOut[4]); - shiftHist(hGenDeltaElForMuProj, parametersOut[10], useRegularisation); - hGenDeltaElForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaElMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaElMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaElMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaElMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaEl[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][0]->cd(2); - hDeltaElFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaElFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 1, reducedChiSquare); - - //TMatrixDSym covMatrixEl(nParUsed, &covMatrix[0][0]); - - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kEl, parametersOut, parameterErrorsOut, hFractionElectrons, - hFractionPionsDeltaElectron, hFractionElectronsDeltaElectron, hFractionKaonsDeltaElectron, - hFractionProtonsDeltaElectron, hFractionMuonsDeltaElectron, hYieldElectrons, hYieldPionsDeltaElectron, - hYieldElectronsDeltaElectron, hYieldKaonsDeltaElectron, hYieldProtonsDeltaElectron, hYieldMuonsDeltaElectron, - normaliseResults); - - - - // DeltaKaons - cSingleFit[slice][1]->cd(1); - - hDeltaKa[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaKa[slice], binLow, binHigh); - hDeltaKa[slice]->Draw("e"); - - fitFuncTotalDeltaKaon[slice] = (TF1*)totalDeltaKaon->Clone(Form("Fit_Total_DeltaKaon_%s", fitFuncSuffix.Data())); - - hDeltaKaFitQA[slice] = (TH1D*)hDeltaKa[slice]->Clone(Form("hDeltaKaFitQA_%d", slice)); - hDeltaKaFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaKaFitQA[slice]->Add(fitFuncTotalDeltaKaon[slice], -1); - hDeltaKaFitQA[slice]->Divide(hDeltaKa[slice]); - - hDeltaKa[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaKaon[slice]); - fitFuncTotalDeltaKaon[slice]->Draw("same"); - - parametersOut = &totalDeltaKaon->GetParameters()[0]; - - hGenDeltaKaForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); - shiftHist(hGenDeltaKaForPiProj, parametersOut[6], useRegularisation); - hGenDeltaKaForPiProj->Draw("same"); - - hGenDeltaKaForKaProj->Scale(parametersOut[5] * parametersOut[1]); - shiftHist(hGenDeltaKaForKaProj, parametersOut[7], useRegularisation); - hGenDeltaKaForKaProj->Draw("same"); - - hGenDeltaKaForPrProj->Scale(parametersOut[5] * parametersOut[2]); - shiftHist(hGenDeltaKaForPrProj, parametersOut[8], useRegularisation); - hGenDeltaKaForPrProj->Draw("same"); - - hGenDeltaKaForElProj->Scale(parametersOut[5] * parametersOut[3]); - shiftHist(hGenDeltaKaForElProj, parametersOut[9], useRegularisation); - hGenDeltaKaForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaKaForMuProj->Scale(parametersOut[5] * parametersOut[4]); - shiftHist(hGenDeltaKaForMuProj, parametersOut[10], useRegularisation); - hGenDeltaKaForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaKaMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaKaMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaKaMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaKaMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaKa[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][1]->cd(2); - hDeltaKaFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaKaFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 2, reducedChiSquare); - - //TMatrixDSym covMatrixKa(nParUsed, &covMatrix[0][0]); - - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kKa, parametersOut, parameterErrorsOut, hFractionKaons, - hFractionPionsDeltaKaon, hFractionElectronsDeltaKaon, hFractionKaonsDeltaKaon, hFractionProtonsDeltaKaon, - hFractionMuonsDeltaKaon, hYieldKaons, hYieldPionsDeltaKaon, hYieldElectronsDeltaKaon, hYieldKaonsDeltaKaon, - hYieldProtonsDeltaKaon, hYieldMuonsDeltaKaon, normaliseResults); - - - - // DeltaProtons - cSingleFit[slice][3]->cd(1); - - hDeltaPr[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaPr[slice], binLow, binHigh); - hDeltaPr[slice]->Draw("e"); - - fitFuncTotalDeltaProton[slice] = (TF1*)totalDeltaProton->Clone(Form("Fit_Total_DeltaProton_%s", fitFuncSuffix.Data())); - - hDeltaPrFitQA[slice] = (TH1D*)hDeltaPr[slice]->Clone(Form("hDeltaPrFitQA_%d", slice)); - hDeltaPrFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaPrFitQA[slice]->Add(fitFuncTotalDeltaProton[slice], -1); - hDeltaPrFitQA[slice]->Divide(hDeltaPr[slice]); - - hDeltaPr[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaProton[slice]); - - fitFuncTotalDeltaProton[slice]->Draw("same"); - - parametersOut = &totalDeltaProton->GetParameters()[0]; - - hGenDeltaPrForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); - shiftHist(hGenDeltaPrForPiProj, parametersOut[6], useRegularisation); - hGenDeltaPrForPiProj->Draw("same"); - - hGenDeltaPrForKaProj->Scale(parametersOut[5] * parametersOut[1]); - shiftHist(hGenDeltaPrForKaProj, parametersOut[7], useRegularisation); - hGenDeltaPrForKaProj->Draw("same"); - - hGenDeltaPrForPrProj->Scale(parametersOut[5] * parametersOut[2]); - shiftHist(hGenDeltaPrForPrProj, parametersOut[8], useRegularisation); - hGenDeltaPrForPrProj->Draw("same"); - - hGenDeltaPrForElProj->Scale(parametersOut[5] * parametersOut[3]); - shiftHist(hGenDeltaPrForElProj, parametersOut[9], useRegularisation); - hGenDeltaPrForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaPrForMuProj->Scale(parametersOut[5] * parametersOut[4]); - shiftHist(hGenDeltaPrForMuProj, parametersOut[10], useRegularisation); - hGenDeltaPrForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaPrMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPrMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaPrMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPrMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaPr[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][3]->cd(2); - hDeltaPrFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaPrFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 4, reducedChiSquare); - - //TMatrixDSym covMatrixPr(nParUsed, &covMatrix[0][0]); - - Double_t normalisationFactor = 1.0; - normalisationFactor = setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPr, parametersOut, parameterErrorsOut, - hFractionProtons, hFractionPionsDeltaProton, hFractionElectronsDeltaProton, - hFractionKaonsDeltaProton, hFractionProtonsDeltaProton, hFractionMuonsDeltaProton, - hYieldProtons, hYieldPionsDeltaProton, hYieldElectronsDeltaProton, - hYieldKaonsDeltaProton, hYieldProtonsDeltaProton, hYieldMuonsDeltaProton, - normaliseResults); - - // Fractions are the same for all plots -> just take deltaPion as default - Double_t sumFractions = hFractionPionsDeltaPion->GetBinContent(slice + 1) + - hFractionElectronsDeltaPion->GetBinContent(slice + 1) + (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaPion->GetBinContent(slice + 1) + hFractionProtonsDeltaPion->GetBinContent(slice + 1); - - hFractionSummed->SetBinContent(slice + 1, sumFractions); - hFractionSummed->SetBinError(slice + 1, - TMath::Sqrt(TMath::Power(hFractionPionsDeltaPion->GetBinError(slice + 1), 2) + - TMath::Power(hFractionElectronsDeltaPion->GetBinError(slice + 1), 2) + - (takeIntoAccountMuons ? TMath::Power(hFractionMuonsDeltaPion->GetBinError(slice + 1), 2) : 0.) + - TMath::Power(hFractionKaonsDeltaPion->GetBinError(slice + 1), 2) + - TMath::Power(hFractionProtonsDeltaPion->GetBinError(slice + 1), 2))); - - for (Int_t species = 0; species < 4; species++) { - cSingleFit[slice][species]->Modified(); - cSingleFit[slice][species]->Update(); - } - - - // Compute the to-pi ratios with proper error for the current slice - // NOTE: error and covariance matrix are already scaled for the simultaneous fit - // by mathFit (it was checked that all (i.e. also off-diagonal) matrix elements grow by fScaleError^2 - // NOTE 2: take the fractions and error from the histogram (takes correct muon and electrons fractions with errors set manually - // in case of fixed fraction; the parameters are fixed, so the elements of the off-diagonal elements of the covariance matrix - // remain zero!). The fractions are then also scaled to sum up to 1 (but correction factor usually close to unity). - // The covariance matrix is NOT scaled like this. Therefore, scale the matrix elements accordingly. - // If the normalisation is not done for the fractions, then this factor is unity by construction. - - - - Double_t covMatrixElementToPiForEl = 0.; - Double_t covMatrixElementToPiForMu = 0.; - Double_t covMatrixElementToPiForKa = 0.; - Double_t covMatrixElementToPiForPr = 0.; - - // Get the correct covariance matrix elements and apply the normalisation factor - Int_t parOffset = 0; - - // In case of regularisation, there is an offset with respect to the current slice - if (useRegularisation) - parOffset = currXbin * numParamsPerXbin; - - - covMatrixElementToPiForEl = covMatrix[3 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; - covMatrixElementToPiForMu = covMatrix[4 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; - covMatrixElementToPiForKa = covMatrix[1 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; - covMatrixElementToPiForPr = covMatrix[2 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; - - Double_t ratio = -999.; - Double_t ratioError = 999.; - Double_t currFractionSpecies = 0.; - Double_t currFractionPions = 0.; - Double_t currFractionErrorSpecies = 0.; - Double_t currFractionErrorPions = 0.; - Double_t covMatrixElementAB = 0.; // NOTE that there is only one covariance matrix (simultaneous fit!) - - currFractionPions = hFractionPions->GetBinContent(slice + 1); - currFractionErrorPions = hFractionPions->GetBinError(slice + 1); - - // NOTE: Even in case of regularisation, when fractions of different bins become correlated, this does NOT change - // the formula. Only the covariance matrix element for the considered fraction in the SAME slice needs to be taken - // into account. Explanation: f = f(fracA_slice, fracB_slice), this means that \dell f / \dell fracA_slice+-1 = 0 (etc.). - // So, the formula is the same, although the correlation between different slices is contained in the covariance matrix. - - // el-to-pi ratio - currFractionSpecies = hFractionElectrons->GetBinContent(slice + 1); - currFractionErrorSpecies = hFractionElectrons->GetBinError(slice + 1); - covMatrixElementAB = covMatrixElementToPiForEl; - - GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, - covMatrixElementAB, ratio, ratioError); - - hRatioToPiElectrons->SetBinContent(slice + 1, ratio); - hRatioToPiElectrons->SetBinError(slice + 1, ratioError); - - // mu-to-pi ratio - currFractionSpecies = hFractionMuons->GetBinContent(slice + 1); - currFractionErrorSpecies = hFractionMuons->GetBinError(slice + 1); - covMatrixElementAB = covMatrixElementToPiForMu; - - GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, - covMatrixElementAB, ratio, ratioError); - - hRatioToPiMuons->SetBinContent(slice + 1, ratio); - hRatioToPiMuons->SetBinError(slice + 1, ratioError); - - - // K-to-pi ratio - currFractionSpecies = hFractionKaons->GetBinContent(slice + 1); - currFractionErrorSpecies = hFractionKaons->GetBinError(slice + 1); - covMatrixElementAB = covMatrixElementToPiForKa; - - GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, - covMatrixElementAB, ratio, ratioError); - - hRatioToPiKaons->SetBinContent(slice + 1, ratio); - hRatioToPiKaons->SetBinError(slice + 1, ratioError); - - - // p-to-pi ratio - currFractionSpecies = hFractionProtons->GetBinContent(slice + 1); - currFractionErrorSpecies = hFractionProtons->GetBinError(slice + 1); - covMatrixElementAB = covMatrixElementToPiForPr; - - GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, - covMatrixElementAB, ratio, ratioError); - - hRatioToPiProtons->SetBinContent(slice + 1, ratio); - hRatioToPiProtons->SetBinError(slice + 1, ratioError); - - /* - for (Int_t i = 0; i < nParUsed; i++) { - for (Int_t j = 0; j < nParUsed; j++) { - printf("\t%e", covMatrix[i][j]); - } - printf("\n"); - } - */ - - currXbin++; - } - //_____________________________________________________________________ - // Other methods without simultaneous fitting - else { - Int_t binLow = -1; - Int_t binHigh = -1; - - // DeltaPions - - std::cout << "Fitting deltaPion...." << std::endl << std::endl; - - cSingleFit[slice][2]->cd(1); - - mathFit->ClearRefHistos(); - mathFit->AddRefHisto(hGenDeltaPiForPiProj); - mathFit->AddRefHisto(hGenDeltaPiForKaProj); - mathFit->AddRefHisto(hGenDeltaPiForPrProj); - mathFit->AddRefHisto(hGenDeltaPiForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPiForMuProj); - - errFlag = errFlag | - doFit(hDeltaPi[slice], xLow, xUp, nPar, gausParamsPi, parameterErrorsOut, &covMatrix[0][0], - stepSize, lowParLimitsPi, upParLimitsPi, totalDeltaPion, reducedChiSquare); - - hDeltaPi[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaPi[slice], binLow, binHigh); - hDeltaPi[slice]->Draw("e"); - - fitFuncTotalDeltaPion[slice] = (TF1*)totalDeltaPion->Clone(Form("Fit_Total_DeltaPion_%s", fitFuncSuffix.Data())); - - hDeltaPiFitQA[slice] = (TH1D*)hDeltaPi[slice]->Clone(Form("hDeltaPiFitQA_%d", slice)); - hDeltaPiFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaPiFitQA[slice]->Add(fitFuncTotalDeltaPion[slice], -1); - hDeltaPiFitQA[slice]->Divide(hDeltaPi[slice]); - - hDeltaPi[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaPion[slice]); - fitFuncTotalDeltaPion[slice]->Draw("same"); - - Double_t* parametersOut = &gausParamsPi[0]; - - hGenDeltaPiForPiProj->Scale(gausParamsPi[5] * (gausParamsPi[0] + (muonContamination ? gausParamsPi[3] : 0))); - shiftHist(hGenDeltaPiForPiProj, gausParamsPi[6]); - hGenDeltaPiForPiProj->Draw("same"); - - hGenDeltaPiForKaProj->Scale(gausParamsPi[5] * gausParamsPi[1]); - shiftHist(hGenDeltaPiForKaProj, gausParamsPi[7]); - hGenDeltaPiForKaProj->Draw("same"); - - hGenDeltaPiForPrProj->Scale(gausParamsPi[5] * gausParamsPi[2]); - shiftHist(hGenDeltaPiForPrProj, gausParamsPi[8]); - hGenDeltaPiForPrProj->Draw("same"); - - hGenDeltaPiForElProj->Scale(gausParamsPi[5] * gausParamsPi[3]); - shiftHist(hGenDeltaPiForElProj, gausParamsPi[9]); - hGenDeltaPiForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaPiForMuProj->Scale(gausParamsPi[5] * gausParamsPi[4]); - shiftHist(hGenDeltaPiForMuProj, gausParamsPi[10]); - hGenDeltaPiForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaPiMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPiMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaPiMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPiMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaPi[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][2]->cd(2); - hDeltaPiFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaPiFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 3, reducedChiSquare); - - TMatrixDSym covMatrixPi(nParUsed, &covMatrix[0][0]); - - if (fitMethod == 1) { - // Histos are normalised => expression equals integral - integralPions = allDeltaPion * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); - integralTotal += integralPions; - if (takeIntoAccountMuons) { - integralMuons = allDeltaPion * parametersOut[4]; - integralTotal += integralMuons; - } - - /* - integralErrorTotalDeltaPion = getErrorOfTotalIntegral(covMatrixPi) * allDeltaPion; - - integralErrorPions = getErrorOfPionIntegral(covMatrixPi) * allDeltaPion; - */ - - integralPionsDeltaPion = integralPions; - - // Compare comment above - integralElectronsDeltaPion = allDeltaPion * parametersOut[3]; - integralKaonsDeltaPion = allDeltaPion * parametersOut[1]; - integralProtonsDeltaPion = allDeltaPion * parametersOut[2]; - integralMuonsDeltaPion = allDeltaPion * parametersOut[4]; - - /* - integralErrorPionsDeltaPion = integralErrorPions; - - integralErrorElectronsDeltaPion = allDeltaPion * parameterErrorsOut[3]; - integralErrorKaonsDeltaPion = allDeltaPion * parameterErrorsOut[1]; - integralErrorProtonsDeltaPion = allDeltaPion * parameterErrorsOut[2]; - */ - } - else { - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPi, parametersOut, parameterErrorsOut, hFractionPions, - hFractionPionsDeltaPion, hFractionElectronsDeltaPion, hFractionKaonsDeltaPion, - hFractionProtonsDeltaPion, hFractionMuonsDeltaPion, hYieldPions, hYieldPionsDeltaPion, hYieldElectronsDeltaPion, - hYieldKaonsDeltaPion, hYieldProtonsDeltaPion, hYieldMuonsDeltaPion); - - // Also set specific muon fractions and yields -> The deltaSpecies histos are not needed here: They will be set together with - // the fraction and yields for all other species - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kMu, parametersOut, parameterErrorsOut, hFractionMuons, - 0x0, 0x0, 0x0, 0x0, 0x0, hYieldMuons, 0x0, 0x0, 0x0, 0x0, 0x0); - } - - - std::cout << std::endl << std::endl; - - - // DeltaElectrons - - std::cout << "Fitting deltaElectron...." << std::endl << std::endl; - - cSingleFit[slice][0]->cd(1); - - mathFit->ClearRefHistos(); - mathFit->AddRefHisto(hGenDeltaElForPiProj); - mathFit->AddRefHisto(hGenDeltaElForKaProj); - mathFit->AddRefHisto(hGenDeltaElForPrProj); - mathFit->AddRefHisto(hGenDeltaElForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaElForMuProj); - - errFlag = errFlag | - doFit(hDeltaEl[slice], xLow, xUp, nPar, gausParamsEl, parameterErrorsOut, &covMatrix[0][0], - stepSize, lowParLimitsEl, upParLimitsEl, totalDeltaElectron, reducedChiSquare); - - hDeltaEl[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaEl[slice], binLow, binHigh); - hDeltaEl[slice]->Draw("e"); - - fitFuncTotalDeltaElectron[slice] = (TF1*)totalDeltaElectron->Clone(Form("Fit_Total_DeltaElectron_%s", fitFuncSuffix.Data())); - - hDeltaElFitQA[slice] = (TH1D*)hDeltaEl[slice]->Clone(Form("hDeltaElFitQA_%d", slice)); - hDeltaElFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaElFitQA[slice]->Add(fitFuncTotalDeltaElectron[slice], -1); - hDeltaElFitQA[slice]->Divide(hDeltaEl[slice]); - - hDeltaEl[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaElectron[slice]); - fitFuncTotalDeltaElectron[slice]->Draw("same"); - - parametersOut = &gausParamsEl[0]; - - hGenDeltaElForPiProj->Scale(gausParamsEl[5] * (gausParamsEl[0] + (muonContamination ? gausParamsEl[3] : 0))); - shiftHist(hGenDeltaElForPiProj, gausParamsEl[6]); - hGenDeltaElForPiProj->Draw("same"); - - hGenDeltaElForKaProj->Scale(gausParamsEl[5] * gausParamsEl[1]); - shiftHist(hGenDeltaElForKaProj, gausParamsEl[7]); - hGenDeltaElForKaProj->Draw("same"); - - hGenDeltaElForPrProj->Scale(gausParamsEl[5] * gausParamsEl[2]); - shiftHist(hGenDeltaElForPrProj, gausParamsEl[8]); - hGenDeltaElForPrProj->Draw("same"); - - hGenDeltaElForElProj->Scale(gausParamsEl[5] * gausParamsEl[3]); - shiftHist(hGenDeltaElForElProj, gausParamsEl[9]); - hGenDeltaElForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaElForMuProj->Scale(gausParamsEl[5] * gausParamsEl[4]); - shiftHist(hGenDeltaElForMuProj, gausParamsEl[10]); - hGenDeltaElForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaElMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaElMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaElMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaElMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaEl[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][0]->cd(2); - hDeltaElFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaElFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 1, reducedChiSquare); - - TMatrixDSym covMatrixEl(nParUsed, &covMatrix[0][0]); - - if (fitMethod == 1) { - integralElectrons = allDeltaElectron * parametersOut[3]; // Histos are normalised => expression equals integral - integralTotal += integralElectrons; - - /* - integralErrorTotalDeltaElectron = getErrorOfTotalIntegral(covMatrixEl) * allDeltaElectron; - - integralErrorElectrons = allDeltaElectron * parameterErrorsOut[3]; - */ - - // Factor 2 in case of takeIntoAccountMuons will be applied below - integralElectronsDeltaElectron = integralElectrons; - - // Compare comment above - integralPionsDeltaElectron = allDeltaElectron * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); - integralKaonsDeltaElectron = allDeltaElectron * parametersOut[1]; - integralProtonsDeltaElectron = allDeltaElectron * parametersOut[2]; - integralMuonsDeltaElectron = allDeltaElectron * parametersOut[4]; - - - /* - integralErrorElectronsDeltaElectron = integralErrorElectrons; - - integralErrorPionsDeltaElectron = getErrorOfPionIntegral(covMatrixEl) * allDeltaElectron; - integralErrorKaonsDeltaElectron = allDeltaElectron * parameterErrorsOut[1]; - integralErrorProtonsDeltaElectron = allDeltaElectron * parameterErrorsOut[2]; - */ - } - else { - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kEl, parametersOut, parameterErrorsOut, hFractionElectrons, - hFractionPionsDeltaElectron, hFractionElectronsDeltaElectron, hFractionKaonsDeltaElectron, - hFractionProtonsDeltaElectron, hFractionMuonsDeltaElectron, hYieldElectrons, hYieldPionsDeltaElectron, - hYieldElectronsDeltaElectron, hYieldKaonsDeltaElectron, hYieldProtonsDeltaElectron, hYieldMuonsDeltaElectron); - } - - std::cout << std::endl << std::endl; - - // DeltaKaons - - std::cout << "Fitting deltaKaon...." << std::endl << std::endl; - - cSingleFit[slice][1]->cd(1); - - mathFit->ClearRefHistos(); - mathFit->AddRefHisto(hGenDeltaKaForPiProj); - mathFit->AddRefHisto(hGenDeltaKaForKaProj); - mathFit->AddRefHisto(hGenDeltaKaForPrProj); - mathFit->AddRefHisto(hGenDeltaKaForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaKaForMuProj); - - errFlag = errFlag | - doFit(hDeltaKa[slice], xLow, xUp, nPar, gausParamsKa, parameterErrorsOut, &covMatrix[0][0], - stepSize, lowParLimitsKa, upParLimitsKa, totalDeltaKaon, reducedChiSquare); - - hDeltaKa[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaKa[slice], binLow, binHigh); - hDeltaKa[slice]->Draw("e"); - - fitFuncTotalDeltaKaon[slice] = (TF1*)totalDeltaKaon->Clone(Form("Fit_Total_DeltaKaon_%s", fitFuncSuffix.Data())); - - hDeltaKaFitQA[slice] = (TH1D*)hDeltaKa[slice]->Clone(Form("hDeltaKaFitQA_%d", slice)); - hDeltaKaFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaKaFitQA[slice]->Add(fitFuncTotalDeltaKaon[slice], -1); - hDeltaKaFitQA[slice]->Divide(hDeltaKa[slice]); - - hDeltaKa[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaKaon[slice]); - fitFuncTotalDeltaKaon[slice]->Draw("same"); - - parametersOut = &gausParamsKa[0]; - - hGenDeltaKaForPiProj->Scale(gausParamsKa[5] * (gausParamsKa[0] + (muonContamination ? gausParamsKa[3] : 0))); - shiftHist(hGenDeltaKaForPiProj, gausParamsKa[6]); - hGenDeltaKaForPiProj->Draw("same"); - - hGenDeltaKaForKaProj->Scale(gausParamsKa[5] * gausParamsKa[1]); - shiftHist(hGenDeltaKaForKaProj, gausParamsKa[7]); - hGenDeltaKaForKaProj->Draw("same"); - - hGenDeltaKaForPrProj->Scale(gausParamsKa[5] * gausParamsKa[2]); - shiftHist(hGenDeltaKaForPrProj, gausParamsKa[8]); - hGenDeltaKaForPrProj->Draw("same"); - - hGenDeltaKaForElProj->Scale(gausParamsKa[5] * gausParamsKa[3]); - shiftHist(hGenDeltaKaForElProj, gausParamsKa[9]); - hGenDeltaKaForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaKaForMuProj->Scale(gausParamsKa[5] * gausParamsKa[4]); - shiftHist(hGenDeltaKaForMuProj, gausParamsKa[10]); - hGenDeltaKaForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaKaMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaKaMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaKaMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaKaMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaKa[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][1]->cd(2); - hDeltaKaFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaKaFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 2, reducedChiSquare); - - TMatrixDSym covMatrixKa(nParUsed, &covMatrix[0][0]); - - if (fitMethod == 1) { - integralKaons = allDeltaKaon * parametersOut[1]; // Histos are normalised => expression equals integral - integralTotal += integralKaons; - /* - integralErrorTotalDeltaKaon = getErrorOfTotalIntegral(covMatrixKa) * allDeltaKaon; - - integralErrorKaons = allDeltaKaon * parameterErrorsOut[1]; - */ - - - integralKaonsDeltaKaon = integralKaons; - - // Compare comment above - integralPionsDeltaKaon = allDeltaKaon * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); - integralElectronsDeltaKaon = allDeltaKaon * parametersOut[3]; - integralProtonsDeltaKaon = allDeltaKaon * parametersOut[2]; - integralMuonsDeltaKaon = allDeltaKaon * parametersOut[4]; - - /* - integralErrorKaonsDeltaKaon = integralErrorKaons; - - integralErrorPionsDeltaKaon = getErrorOfPionIntegral(covMatrixKa) * allDeltaKaon; - integralErrorElectronsDeltaKaon = allDeltaKaon * parameterErrorsOut[3]; - integralErrorProtonsDeltaKaon = allDeltaKaon * parameterErrorsOut[2]; - */ - } - else { - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kKa, parametersOut, parameterErrorsOut, hFractionKaons, - hFractionPionsDeltaKaon, hFractionElectronsDeltaKaon, hFractionKaonsDeltaKaon, hFractionProtonsDeltaKaon, - hFractionMuonsDeltaKaon, hYieldKaons, hYieldPionsDeltaKaon, hYieldElectronsDeltaKaon, hYieldKaonsDeltaKaon, - hYieldProtonsDeltaKaon, hYieldMuonsDeltaKaon); - } - - std::cout << std::endl << std::endl; - - - // DeltaProtons - - std::cout << "Fitting deltaProton...." << std::endl << std::endl; - - cSingleFit[slice][3]->cd(1); - - mathFit->ClearRefHistos(); - mathFit->AddRefHisto(hGenDeltaPrForPiProj); - mathFit->AddRefHisto(hGenDeltaPrForKaProj); - mathFit->AddRefHisto(hGenDeltaPrForPrProj); - mathFit->AddRefHisto(hGenDeltaPrForElProj); - if (takeIntoAccountMuons) - mathFit->AddRefHisto(hGenDeltaPrForMuProj); - - errFlag = errFlag | - doFit(hDeltaPr[slice], xLow, xUp, nPar, gausParamsPr, parameterErrorsOut, &covMatrix[0][0], - stepSize, lowParLimitsPr, upParLimitsPr, totalDeltaProton, reducedChiSquare); - - hDeltaPr[slice]->SetTitle(""); - SetReasonableXaxisRange(hDeltaPr[slice], binLow, binHigh); - hDeltaPr[slice]->Draw("e"); - - fitFuncTotalDeltaProton[slice] = (TF1*)totalDeltaProton->Clone(Form("Fit_Total_DeltaProton_%s", fitFuncSuffix.Data())); - - hDeltaPrFitQA[slice] = (TH1D*)hDeltaPr[slice]->Clone(Form("hDeltaPrFitQA_%d", slice)); - hDeltaPrFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); - hDeltaPrFitQA[slice]->Add(fitFuncTotalDeltaProton[slice], -1); - hDeltaPrFitQA[slice]->Divide(hDeltaPr[slice]); - - hDeltaPr[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaProton[slice]); - - fitFuncTotalDeltaProton[slice]->Draw("same"); - - parametersOut = &gausParamsPr[0]; - - hGenDeltaPrForPiProj->Scale(gausParamsPr[5] * (gausParamsPr[0] + (muonContamination ? gausParamsPr[3] : 0))); - shiftHist(hGenDeltaPrForPiProj, gausParamsPr[6]); - hGenDeltaPrForPiProj->Draw("same"); - - hGenDeltaPrForKaProj->Scale(gausParamsPr[5] * gausParamsPr[1]); - shiftHist(hGenDeltaPrForKaProj, gausParamsPr[7]); - hGenDeltaPrForKaProj->Draw("same"); - - hGenDeltaPrForPrProj->Scale(gausParamsPr[5] * gausParamsPr[2]); - shiftHist(hGenDeltaPrForPrProj, gausParamsPr[8]); - hGenDeltaPrForPrProj->Draw("same"); - - hGenDeltaPrForElProj->Scale(gausParamsPr[5] * gausParamsPr[3]); - shiftHist(hGenDeltaPrForElProj, gausParamsPr[9]); - hGenDeltaPrForElProj->Draw("same"); - - if (takeIntoAccountMuons) { - hGenDeltaPrForMuProj->Scale(gausParamsPr[5] * gausParamsPr[4]); - shiftHist(hGenDeltaPrForMuProj, gausParamsPr[10]); - hGenDeltaPrForMuProj->Draw("same"); - } - - if (plotIdentifiedSpectra) { - for (Int_t species = 0; species < 5; species++) - hDeltaPrMC[slice][species]->Draw("same"); - - // Draw histo for sum of MC muons and pions - TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPrMC[slice][kPi - 1]); - hMCmuonsAndPions->Add(hDeltaPrMC[slice][kMu - 1]); - hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); - hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPrMC[slice][kPi - 1]->GetName())); - hMCmuonsAndPions->Draw("same"); - } - - hDeltaPr[slice]->Draw("esame"); - - legend->Draw(); - - cSingleFit[slice][3]->cd(2); - hDeltaPrFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); - hDeltaPrFitQA[slice]->Draw("e"); - - hReducedChiSquarePt->SetBinContent(slice + 1, 4, reducedChiSquare); - - TMatrixDSym covMatrixPr(nParUsed, &covMatrix[0][0]); - - if (fitMethod == 1) { - integralProtons = allDeltaProton * parametersOut[2]; // Histos are normalised => expression equals integral - integralTotal += integralProtons; - /* - integralErrorTotalDeltaProton = getErrorOfTotalIntegral(covMatrixPr) * allDeltaProton; - - integralErrorProtons = allDeltaProton * parameterErrorsOut[2]; - */ - - integralProtonsDeltaProton = integralProtons; - - // Compare comment above - integralPionsDeltaProton = allDeltaProton * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); - integralElectronsDeltaProton = allDeltaProton * parametersOut[3]; - integralKaonsDeltaProton = allDeltaProton * parametersOut[1]; - integralMuonsDeltaProton = allDeltaProton * parametersOut[4]; - - - /* - integralErrorProtonsDeltaProton = integralErrorProtons; - - integralErrorPionsDeltaProton = getErrorOfPionIntegral(covMatrixPr) * allDeltaProton; - integralErrorElectronsDeltaProton = allDeltaProton * parameterErrorsOut[3]; - integralErrorKaonsDeltaProton = allDeltaProton * parameterErrorsOut[1]; - */ - } - else { - setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPr, parametersOut, parameterErrorsOut, hFractionProtons, - hFractionPionsDeltaProton, hFractionElectronsDeltaProton, hFractionKaonsDeltaProton, - hFractionProtonsDeltaProton, hFractionMuonsDeltaProton, hYieldProtons, hYieldPionsDeltaProton, - hYieldElectronsDeltaProton, hYieldKaonsDeltaProton, hYieldProtonsDeltaProton, hYieldMuonsDeltaProton); - } - - std::cout << std::endl << std::endl; - - - if (fitMethod == 1) { - // Calculate fractions and yields for method 1 - if (integralTotal > 0) { - - Double_t sumOfParticles = 0; - - // Check fraction and yield determination for systematics - // DeltaPion - Double_t integralTotalDeltaPion = integralPionsDeltaPion + integralElectronsDeltaPion + - (takeIntoAccountMuons ? integralMuonsDeltaPion : 0.) + - integralKaonsDeltaPion + integralProtonsDeltaPion; - totalDeltaPion->GetParameters(parametersOut); - - Double_t pionFractionDeltaPion = saveDivide(integralPionsDeltaPion, integralTotalDeltaPion); - Double_t pionFractionErrorDeltaPion = getErrorOfPionFraction(parametersOut, covMatrixPi); - hFractionPionsDeltaPion->SetBinContent(slice + 1, pionFractionDeltaPion); - hFractionPionsDeltaPion->SetBinError(slice + 1, pionFractionErrorDeltaPion); - - Double_t electronFractionDeltaPion = saveDivide(integralElectronsDeltaPion, integralTotalDeltaPion); - Double_t electronFractionErrorDeltaPion = getErrorOfElectronFraction(parametersOut, covMatrixPi); - hFractionElectronsDeltaPion->SetBinContent(slice + 1, electronFractionDeltaPion); - hFractionElectronsDeltaPion->SetBinError(slice + 1, electronFractionErrorDeltaPion); - - Double_t kaonFractionDeltaPion = saveDivide(integralKaonsDeltaPion, integralTotalDeltaPion); - Double_t kaonFractionErrorDeltaPion = getErrorOfKaonFraction(parametersOut, covMatrixPi); - hFractionKaonsDeltaPion->SetBinContent(slice + 1, kaonFractionDeltaPion); - hFractionKaonsDeltaPion->SetBinError(slice + 1, kaonFractionErrorDeltaPion); - - Double_t protonFractionDeltaPion = saveDivide(integralProtonsDeltaPion, integralTotalDeltaPion); - Double_t protonFractionErrorDeltaPion = getErrorOfProtonFraction(parametersOut, covMatrixPi); - hFractionProtonsDeltaPion->SetBinContent(slice + 1, protonFractionDeltaPion); - hFractionProtonsDeltaPion->SetBinError(slice + 1, protonFractionErrorDeltaPion); - - Double_t muonFractionDeltaPion = saveDivide(integralMuonsDeltaPion, integralTotalDeltaPion); - // TODO Error is anyway not implemented correctly. Just take electron error as an approximation - Double_t muonFractionErrorDeltaPion = getErrorOfElectronFraction(parametersOut, covMatrixPi); - hFractionMuonsDeltaPion->SetBinContent(slice + 1, muonFractionDeltaPion); - hFractionMuonsDeltaPion->SetBinError(slice + 1, muonFractionErrorDeltaPion); - - sumOfParticles = inverseBinWidth * gausParamsPi[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width - - hYieldPionsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaPion->GetBinContent(slice + 1)); - hYieldPionsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaPion->GetBinError(slice + 1)); - hYieldElectronsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaPion->GetBinContent(slice + 1)); - hYieldElectronsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaPion->GetBinError(slice + 1)); - hYieldKaonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaPion->GetBinContent(slice + 1)); - hYieldKaonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaPion->GetBinError(slice + 1)); - hYieldProtonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaPion->GetBinContent(slice + 1)); - hYieldProtonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaPion->GetBinError(slice + 1)); - hYieldMuonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaPion->GetBinContent(slice + 1)); - hYieldMuonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaPion->GetBinError(slice + 1)); - - - // DeltaElectron - Double_t integralTotalDeltaElectron = integralPionsDeltaElectron + integralElectronsDeltaElectron + - (takeIntoAccountMuons ? integralMuonsDeltaElectron : 0.) + - integralKaonsDeltaElectron + integralProtonsDeltaElectron; - totalDeltaElectron->GetParameters(parametersOut); - - Double_t pionFractionDeltaElectron = saveDivide(integralPionsDeltaElectron, integralTotalDeltaElectron); - Double_t pionFractionErrorDeltaElectron = getErrorOfPionFraction(parametersOut, covMatrixEl); - hFractionPionsDeltaElectron->SetBinContent(slice + 1, pionFractionDeltaElectron); - hFractionPionsDeltaElectron->SetBinError(slice + 1, pionFractionErrorDeltaElectron); - - Double_t electronFractionDeltaElectron = saveDivide(integralElectronsDeltaElectron, integralTotalDeltaElectron); - Double_t electronFractionErrorDeltaElectron = getErrorOfElectronFraction(parametersOut, covMatrixEl); - hFractionElectronsDeltaElectron->SetBinContent(slice + 1, electronFractionDeltaElectron); - hFractionElectronsDeltaElectron->SetBinError(slice + 1, electronFractionErrorDeltaElectron); - - Double_t kaonFractionDeltaElectron = saveDivide(integralKaonsDeltaElectron, integralTotalDeltaElectron); - Double_t kaonFractionErrorDeltaElectron = getErrorOfKaonFraction(parametersOut, covMatrixEl); - hFractionKaonsDeltaElectron->SetBinContent(slice + 1, kaonFractionDeltaElectron); - hFractionKaonsDeltaElectron->SetBinError(slice + 1, kaonFractionErrorDeltaElectron); - - Double_t protonFractionDeltaElectron = saveDivide(integralProtonsDeltaElectron, integralTotalDeltaElectron); - Double_t protonFractionErrorDeltaElectron = getErrorOfProtonFraction(parametersOut, covMatrixEl); - hFractionProtonsDeltaElectron->SetBinContent(slice + 1, protonFractionDeltaElectron); - hFractionProtonsDeltaElectron->SetBinError(slice + 1, protonFractionErrorDeltaElectron); - - Double_t muonFractionDeltaElectron = saveDivide(integralMuonsDeltaElectron, integralTotalDeltaElectron); - // TODO Error is anyway not implemented correctly. Just take electron error as an approximation - Double_t muonFractionErrorDeltaElectron = getErrorOfElectronFraction(parametersOut, covMatrixEl); - hFractionMuonsDeltaElectron->SetBinContent(slice + 1, muonFractionDeltaElectron); - hFractionMuonsDeltaElectron->SetBinError(slice + 1, muonFractionErrorDeltaElectron); - - sumOfParticles = inverseBinWidth * gausParamsEl[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width - - hYieldPionsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaElectron->GetBinContent(slice + 1)); - hYieldPionsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaElectron->GetBinError(slice + 1)); - hYieldElectronsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaElectron->GetBinContent(slice + 1)); - hYieldElectronsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaElectron->GetBinError(slice + 1)); - hYieldKaonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaElectron->GetBinContent(slice + 1)); - hYieldKaonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaElectron->GetBinError(slice + 1)); - hYieldProtonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaElectron->GetBinContent(slice + 1)); - hYieldProtonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaElectron->GetBinError(slice + 1)); - hYieldMuonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaElectron->GetBinContent(slice + 1)); - hYieldMuonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaElectron->GetBinError(slice + 1)); - - - // DeltaKaon - Double_t integralTotalDeltaKaon = integralPionsDeltaKaon + integralElectronsDeltaKaon + - (takeIntoAccountMuons ? integralMuonsDeltaKaon : 0.) + - integralKaonsDeltaKaon + integralProtonsDeltaKaon; - totalDeltaKaon->GetParameters(parametersOut); - - Double_t pionFractionDeltaKaon = saveDivide(integralPionsDeltaKaon, integralTotalDeltaKaon); - Double_t pionFractionErrorDeltaKaon = getErrorOfPionFraction(parametersOut, covMatrixKa); - hFractionPionsDeltaKaon->SetBinContent(slice + 1, pionFractionDeltaKaon); - hFractionPionsDeltaKaon->SetBinError(slice + 1, pionFractionErrorDeltaKaon); - - Double_t electronFractionDeltaKaon = saveDivide(integralElectronsDeltaKaon, integralTotalDeltaKaon); - Double_t electronFractionErrorDeltaKaon = getErrorOfElectronFraction(parametersOut, covMatrixKa); - hFractionElectronsDeltaKaon->SetBinContent(slice + 1, electronFractionDeltaKaon); - hFractionElectronsDeltaKaon->SetBinError(slice + 1, electronFractionErrorDeltaKaon); - - Double_t kaonFractionDeltaKaon = saveDivide(integralKaonsDeltaKaon, integralTotalDeltaKaon); - Double_t kaonFractionErrorDeltaKaon = getErrorOfKaonFraction(parametersOut, covMatrixKa); - hFractionKaonsDeltaKaon->SetBinContent(slice + 1, kaonFractionDeltaKaon); - hFractionKaonsDeltaKaon->SetBinError(slice + 1, kaonFractionErrorDeltaKaon); - - Double_t protonFractionDeltaKaon = saveDivide(integralProtonsDeltaKaon, integralTotalDeltaKaon); - Double_t protonFractionErrorDeltaKaon = getErrorOfProtonFraction(parametersOut, covMatrixKa); - hFractionProtonsDeltaKaon->SetBinContent(slice + 1, protonFractionDeltaKaon); - hFractionProtonsDeltaKaon->SetBinError(slice + 1, protonFractionErrorDeltaKaon); - - Double_t muonFractionDeltaKaon = saveDivide(integralMuonsDeltaKaon, integralTotalDeltaKaon); - // TODO Error is anyway not implemented correctly. Just take electron error as an approximation - Double_t muonFractionErrorDeltaKaon = getErrorOfElectronFraction(parametersOut, covMatrixKa); - hFractionMuonsDeltaKaon->SetBinContent(slice + 1, muonFractionDeltaKaon); - hFractionMuonsDeltaKaon->SetBinError(slice + 1, muonFractionErrorDeltaKaon); - - sumOfParticles = inverseBinWidth * gausParamsKa[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width - - hYieldPionsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaKaon->GetBinContent(slice + 1)); - hYieldPionsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaKaon->GetBinError(slice + 1)); - hYieldElectronsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaKaon->GetBinContent(slice + 1)); - hYieldElectronsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaKaon->GetBinError(slice + 1)); - hYieldKaonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaKaon->GetBinContent(slice + 1)); - hYieldKaonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaKaon->GetBinError(slice + 1)); - hYieldProtonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaKaon->GetBinContent(slice + 1)); - hYieldProtonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaKaon->GetBinError(slice + 1)); - hYieldMuonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaKaon->GetBinContent(slice + 1)); - hYieldMuonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaKaon->GetBinError(slice + 1)); - - - - // DeltaProton - Double_t integralTotalDeltaProton = integralPionsDeltaProton + integralElectronsDeltaProton + - (takeIntoAccountMuons ? integralMuonsDeltaProton : 0.) + - integralKaonsDeltaProton + integralProtonsDeltaProton; - totalDeltaProton->GetParameters(parametersOut); - - Double_t pionFractionDeltaProton = saveDivide(integralPionsDeltaProton, integralTotalDeltaProton); - Double_t pionFractionErrorDeltaProton = getErrorOfPionFraction(parametersOut, covMatrixPr); - hFractionPionsDeltaProton->SetBinContent(slice + 1, pionFractionDeltaProton); - hFractionPionsDeltaProton->SetBinError(slice + 1, pionFractionErrorDeltaProton); - - Double_t electronFractionDeltaProton = saveDivide(integralElectronsDeltaProton, integralTotalDeltaProton); - Double_t electronFractionErrorDeltaProton = getErrorOfElectronFraction(parametersOut, covMatrixPr); - hFractionElectronsDeltaProton->SetBinContent(slice + 1, electronFractionDeltaProton); - hFractionElectronsDeltaProton->SetBinError(slice + 1, electronFractionErrorDeltaProton); - - Double_t kaonFractionDeltaProton = saveDivide(integralKaonsDeltaProton, integralTotalDeltaProton); - Double_t kaonFractionErrorDeltaProton = getErrorOfKaonFraction(parametersOut, covMatrixPr); - hFractionKaonsDeltaProton->SetBinContent(slice + 1, kaonFractionDeltaProton); - hFractionKaonsDeltaProton->SetBinError(slice + 1, kaonFractionErrorDeltaProton); - - Double_t protonFractionDeltaProton = saveDivide(integralProtonsDeltaProton, integralTotalDeltaProton); - Double_t protonFractionErrorDeltaProton = getErrorOfProtonFraction(parametersOut, covMatrixPr); - hFractionProtonsDeltaProton->SetBinContent(slice + 1, protonFractionDeltaProton); - hFractionProtonsDeltaProton->SetBinError(slice + 1, protonFractionErrorDeltaProton); - - Double_t muonFractionDeltaProton = saveDivide(integralMuonsDeltaProton, integralTotalDeltaProton); - // TODO Error is anyway not implemented correctly. Just take electron error as an approximation - Double_t muonFractionErrorDeltaProton = getErrorOfElectronFraction(parametersOut, covMatrixPr); - hFractionMuonsDeltaProton->SetBinContent(slice + 1, muonFractionDeltaProton); - hFractionMuonsDeltaProton->SetBinError(slice + 1, muonFractionErrorDeltaProton); - - sumOfParticles = inverseBinWidth * gausParamsPr[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width - - hYieldPionsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaProton->GetBinContent(slice + 1)); - hYieldPionsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaProton->GetBinError(slice + 1)); - hYieldElectronsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaProton->GetBinContent(slice + 1)); - hYieldElectronsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaProton->GetBinError(slice + 1)); - hYieldKaonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaProton->GetBinContent(slice + 1)); - hYieldKaonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaProton->GetBinError(slice + 1)); - hYieldProtonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaProton->GetBinContent(slice + 1)); - hYieldProtonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaProton->GetBinError(slice + 1)); - hYieldMuonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaProton->GetBinContent(slice + 1)); - hYieldMuonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaProton->GetBinError(slice + 1)); - - - - // Take for XXXXfractionError the median of XXXXfractionErrorYYYY and do not take into account errors - // with value zero, since the should correspond to a failed fit (but the other fits can still converge). - // Same for the yields - Double_t pionFraction = saveDivide(integralPions, integralTotal); - Double_t errorsPions[4] = { pionFractionErrorDeltaPion, pionFractionErrorDeltaElectron, - pionFractionErrorDeltaKaon, pionFractionErrorDeltaProton }; - Double_t pionFractionError = getMedianOfNonZeros(errorsPions); - - Double_t electronFraction = saveDivide(integralElectrons, integralTotal); - Double_t errorsElectrons[4] = { electronFractionErrorDeltaPion, electronFractionErrorDeltaElectron, - electronFractionErrorDeltaKaon, electronFractionErrorDeltaProton }; - Double_t electronFractionError = getMedianOfNonZeros(errorsElectrons); - - Double_t kaonFraction = saveDivide(integralKaons, integralTotal); - Double_t errorsKaons[4] = { kaonFractionErrorDeltaPion, kaonFractionErrorDeltaElectron, - kaonFractionErrorDeltaKaon, kaonFractionErrorDeltaProton }; - Double_t kaonFractionError = getMedianOfNonZeros(errorsKaons); - - Double_t protonFraction = saveDivide(integralProtons, integralTotal); - Double_t errorsProtons[4] = { protonFractionErrorDeltaPion, protonFractionErrorDeltaElectron, - protonFractionErrorDeltaKaon, protonFractionErrorDeltaProton }; - Double_t protonFractionError = getMedianOfNonZeros(errorsProtons); - - Double_t muonFraction = saveDivide(integralMuons, integralTotal); - Double_t errorsMuons[4] = { muonFractionErrorDeltaPion, muonFractionErrorDeltaElectron, - muonFractionErrorDeltaKaon, muonFractionErrorDeltaProton }; - Double_t muonFractionError = getMedianOfNonZeros(errorsMuons); - - hFractionPions->SetBinContent(slice + 1, pionFraction); - hFractionPions->SetBinError(slice + 1, pionFractionError); - hFractionElectrons->SetBinContent(slice + 1, electronFraction); - hFractionElectrons->SetBinError(slice + 1, electronFractionError); - hFractionKaons->SetBinContent(slice + 1, kaonFraction); - hFractionKaons->SetBinError(slice + 1, kaonFractionError); - hFractionProtons->SetBinContent(slice + 1, protonFraction); - hFractionProtons->SetBinError(slice + 1, protonFractionError); - hFractionMuons->SetBinContent(slice + 1, muonFraction); - hFractionMuons->SetBinError(slice + 1, muonFractionError); - - hFractionSummed->SetBinContent(slice + 1, pionFraction + electronFraction + (takeIntoAccountMuons ? muonFraction : 0.) + - kaonFraction + protonFraction); - hFractionSummed->SetBinError(slice + 1, - TMath::Sqrt(TMath::Power(pionFractionError, 2) + - TMath::Power(electronFractionError, 2) + - (takeIntoAccountMuons ? TMath::Power(muonFractionError, 2) : 0.) + - TMath::Power(kaonFractionError, 2) + - TMath::Power(protonFractionError, 2))); - - sumOfParticles = inverseBinWidth * integralTotal / binWidthFitHisto; // Divide by binWidthFitHisto, since integralTotal includes this width - - hYieldPions->SetBinContent(slice + 1, sumOfParticles * hFractionPions->GetBinContent(slice + 1)); - hYieldPions->SetBinError(slice + 1, sumOfParticles * hFractionPions->GetBinError(slice + 1)); - hYieldElectrons->SetBinContent(slice + 1, sumOfParticles * hFractionElectrons->GetBinContent(slice + 1)); - hYieldElectrons->SetBinError(slice + 1, sumOfParticles * hFractionElectrons->GetBinError(slice + 1)); - hYieldKaons->SetBinContent(slice + 1, sumOfParticles * hFractionKaons->GetBinContent(slice + 1)); - hYieldKaons->SetBinError(slice + 1, sumOfParticles * hFractionKaons->GetBinError(slice + 1)); - hYieldProtons->SetBinContent(slice + 1, sumOfParticles * hFractionProtons->GetBinContent(slice + 1)); - hYieldProtons->SetBinError(slice + 1, sumOfParticles * hFractionProtons->GetBinError(slice + 1)); - hYieldMuons->SetBinContent(slice + 1, sumOfParticles * hFractionMuons->GetBinContent(slice + 1)); - hYieldMuons->SetBinError(slice + 1, sumOfParticles * hFractionMuons->GetBinError(slice + 1)); - } - } - else { - Double_t SumFractionsDeltaElectron = hFractionPionsDeltaElectron->GetBinContent(slice + 1) + - hFractionElectronsDeltaElectron->GetBinContent(slice + 1) + - (takeIntoAccountMuons ? hFractionMuonsDeltaElectron->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaElectron->GetBinContent(slice + 1) + hFractionProtonsDeltaElectron->GetBinContent(slice + 1); - - Double_t SumFractionsDeltaKaon = hFractionPionsDeltaKaon->GetBinContent(slice + 1) + - hFractionElectronsDeltaKaon->GetBinContent(slice + 1) + - (takeIntoAccountMuons ? hFractionMuonsDeltaKaon->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaKaon->GetBinContent(slice + 1) + hFractionProtonsDeltaKaon->GetBinContent(slice + 1); - - Double_t SumFractionsDeltaPion = hFractionPionsDeltaPion->GetBinContent(slice + 1) + - hFractionElectronsDeltaPion->GetBinContent(slice + 1) + - (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaPion->GetBinContent(slice + 1) + hFractionProtonsDeltaPion->GetBinContent(slice + 1); - - Double_t SumFractionsDeltaProton = hFractionPionsDeltaProton->GetBinContent(slice + 1) + - hFractionElectronsDeltaProton->GetBinContent(slice + 1) + - (takeIntoAccountMuons ? hFractionMuonsDeltaProton->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaProton->GetBinContent(slice + 1) + hFractionProtonsDeltaProton->GetBinContent(slice + 1); - - Double_t SumFractionsUsed = hFractionPionsDeltaPion->GetBinContent(slice + 1) + - hFractionElectronsDeltaElectron->GetBinContent(slice + 1) + - (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + - hFractionKaonsDeltaKaon->GetBinContent(slice + 1) + hFractionProtonsDeltaProton->GetBinContent(slice + 1); - - hFractionSummed->SetBinContent(slice + 1, SumFractionsUsed); - hFractionSummed->SetBinError(slice + 1, - TMath::Sqrt(TMath::Power(hFractionPionsDeltaPion->GetBinError(slice + 1), 2) + - TMath::Power(hFractionElectronsDeltaElectron->GetBinError(slice + 1), 2) + - (takeIntoAccountMuons ? TMath::Power(hFractionMuonsDeltaPion->GetBinError(slice + 1), - 2) : 0.) + - TMath::Power(hFractionKaonsDeltaKaon->GetBinError(slice + 1), 2) + - TMath::Power(hFractionProtonsDeltaProton->GetBinError(slice + 1), 2))); - - - std::cout << "Sum Fractions DeltaElectron: " << SumFractionsDeltaElectron; - std::cout << (TMath::Abs(SumFractionsDeltaElectron - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; - - std::cout << "Sum Fractions DeltaKaon: " << SumFractionsDeltaKaon; - std::cout << (TMath::Abs(SumFractionsDeltaKaon - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; - - std::cout << "Sum Fractions DeltaPion: " << SumFractionsDeltaPion; - std::cout << (TMath::Abs(SumFractionsDeltaPion - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; - - std::cout << "Sum fractions DeltaProton: " << SumFractionsDeltaProton; - std::cout << (TMath::Abs(SumFractionsDeltaProton - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; - - std::cout << "Sum fractions used: " << SumFractionsUsed; - std::cout << (TMath::Abs(SumFractionsUsed - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; - } - - for (Int_t species = 0; species < 4; species++) { - cSingleFit[slice][species]->Modified(); - cSingleFit[slice][species]->Update(); - } - - - } - - if (regularisation <= 0) - std::cout << std::endl << std::endl; - - - // MC results - Double_t MCtotal = -1, MCelectrons = -1, MCkaons = -1, MCmuons = -1, MCpions = -1, MCprotons = -1; - Double_t MCelectronsErr = 0, MCkaonsErr = 0, MCmuonsErr = 0, MCpionsErr = 0, MCprotonsErr = 0; - - MCelectrons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 1, 1, MCelectronsErr) * inverseBinWidth; - MCkaons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 2, 2, MCkaonsErr) * inverseBinWidth; - MCmuons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 3, 3, MCmuonsErr) * inverseBinWidth; - MCpions = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 4, 4, MCpionsErr) * inverseBinWidth; - MCprotons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 5, 5, MCprotonsErr) * inverseBinWidth; - - MCelectronsErr *= inverseBinWidth; - MCkaonsErr *= inverseBinWidth; - MCmuonsErr *= inverseBinWidth; - MCpionsErr *= inverseBinWidth; - MCprotonsErr *= inverseBinWidth; - - MCtotal = MCelectrons + MCkaons + MCpions + MCprotons + MCmuons; - - if (MCtotal > 0) { - hYieldElectronsMC->SetBinContent(slice + 1, MCelectrons); - hYieldElectronsMC->SetBinError(slice + 1, MCelectronsErr); - - hYieldMuonsMC->SetBinContent(slice + 1, MCmuons); - hYieldMuonsMC->SetBinError(slice + 1, MCmuonsErr); - - hYieldKaonsMC->SetBinContent(slice + 1, MCkaons); - hYieldKaonsMC->SetBinError(slice + 1, MCkaonsErr); - - hYieldPionsMC->SetBinContent(slice + 1, MCpions); - hYieldPionsMC->SetBinError(slice + 1, MCpionsErr); - - hYieldProtonsMC->SetBinContent(slice + 1, MCprotons); - hYieldProtonsMC->SetBinError(slice + 1, MCprotonsErr); - - hYieldSummedMC->SetBinContent(slice + 1, hYieldElectronsMC->GetBinContent(slice + 1) + - hYieldKaonsMC->GetBinContent(slice + 1) + - hYieldPionsMC->GetBinContent(slice + 1) + - hYieldProtonsMC->GetBinContent(slice + 1) + - hYieldMuonsMC->GetBinContent(slice + 1)); - hYieldSummedMC->SetBinError(slice + 1, TMath::Sqrt(TMath::Power(hYieldPionsMC->GetBinError(slice + 1), 2) + - TMath::Power(hYieldElectronsMC->GetBinError(slice + 1), 2) + - TMath::Power(hYieldKaonsMC->GetBinError(slice + 1), 2) + - TMath::Power(hYieldProtonsMC->GetBinError(slice + 1), 2) + - TMath::Power(hYieldMuonsMC->GetBinError(slice + 1), 2))); - - // MCspecies and MCtotal are correlated. This can be taken into account via using the binomial error in the division - hFractionElectronsMC->Divide(hYieldElectronsMC, hYieldSummedMC, 1., 1., "B"); - hFractionMuonsMC->Divide(hYieldMuonsMC, hYieldSummedMC, 1., 1., "B"); - hFractionKaonsMC->Divide(hYieldKaonsMC, hYieldSummedMC, 1., 1., "B"); - hFractionPionsMC->Divide(hYieldPionsMC, hYieldSummedMC, 1., 1., "B"); - hFractionProtonsMC->Divide(hYieldProtonsMC, hYieldSummedMC, 1., 1., "B"); - } - - // Save further results - if (slice % 18 == 0 || slice == pSliceLow) { - saveF->cd(); - - if (hFractionElectrons) - hFractionElectrons->Write(0, TObject::kWriteDelete); - - if (hFractionKaons) - hFractionKaons->Write(0, TObject::kWriteDelete); - - if (hFractionPions) - hFractionPions->Write(0, TObject::kWriteDelete); - - if (hFractionProtons) - hFractionProtons->Write(0, TObject::kWriteDelete); - - if (hFractionMuons) - hFractionMuons->Write(0, TObject::kWriteDelete); - - if (hFractionSummed) - hFractionSummed->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaElectron) - hFractionElectronsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaElectron) - hFractionKaonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaElectron) - hFractionPionsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaElectron) - hFractionProtonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaElectron) - hFractionMuonsDeltaElectron->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaPion) - hFractionElectronsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaPion) - hFractionKaonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaPion) - hFractionPionsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaPion) - hFractionProtonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaPion) - hFractionMuonsDeltaPion->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaKaon) - hFractionElectronsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaKaon) - hFractionKaonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaKaon) - hFractionPionsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaKaon) - hFractionProtonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaKaon) - hFractionMuonsDeltaKaon->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaProton) - hFractionElectronsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaProton) - hFractionKaonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaProton) - hFractionPionsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaProton) - hFractionProtonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaProton) - hFractionMuonsDeltaProton->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsMC) - hFractionElectronsMC->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsMC) - hFractionKaonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionPionsMC) - hFractionPionsMC->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsMC) - hFractionMuonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsMC) - hFractionProtonsMC->Write(0, TObject::kWriteDelete); - - - - - if (hYieldElectrons) - hYieldElectrons->Write(0, TObject::kWriteDelete); - - if (hYieldKaons) - hYieldKaons->Write(0, TObject::kWriteDelete); - - if (hYieldPions) - hYieldPions->Write(0, TObject::kWriteDelete); - - if (hYieldProtons) - hYieldProtons->Write(0, TObject::kWriteDelete); - - if (hYieldMuons) - hYieldMuons->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaElectron) - hYieldElectronsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaElectron) - hYieldKaonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaElectron) - hYieldPionsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaElectron) - hYieldProtonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaElectron) - hYieldMuonsDeltaElectron->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaPion) - hYieldElectronsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaPion) - hYieldKaonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaPion) - hYieldPionsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaPion) - hYieldProtonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaPion) - hYieldMuonsDeltaPion->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaKaon) - hYieldElectronsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaKaon) - hYieldKaonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaKaon) - hYieldPionsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaKaon) - hYieldProtonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaKaon) - hYieldMuonsDeltaKaon->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaProton) - hYieldElectronsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaProton) - hYieldKaonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaProton) - hYieldPionsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaProton) - hYieldProtonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaProton) - hYieldMuonsDeltaProton->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsMC) - hYieldElectronsMC->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsMC) - hYieldKaonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldPionsMC) - hYieldPionsMC->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsMC) - hYieldMuonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsMC) - hYieldProtonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldSummedMC) - hYieldSummedMC->Write(0, TObject::kWriteDelete); - } - - TString saveDir = (mode == kPMpT) ? Form("SingleFit_%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) - : Form("SingleFit_%.2f_%s_%.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), - modeShortName[mode].Data(), hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); - saveF->mkdir(saveDir.Data()); - saveF->cd(saveDir.Data()); - - for (Int_t species = 0; species < 4; species++) { - if (cSingleFit[slice][species]) { - cSingleFit[slice][species]->Write(); - delete cSingleFit[slice][species]; - } - } - - if (hDeltaPi[slice]) - hDeltaPi[slice]->Write(); - - if (hDeltaEl[slice]) - hDeltaEl[slice]->Write(); - - if (hDeltaKa[slice]) - hDeltaKa[slice]->Write(); - - if (hDeltaPr[slice]) - hDeltaPr[slice]->Write(); - - - if (hDeltaPiFitQA[slice]) - hDeltaPiFitQA[slice]->Write(); - delete hDeltaPiFitQA[slice]; - - if (hDeltaElFitQA[slice]) - hDeltaElFitQA[slice]->Write(); - delete hDeltaElFitQA[slice]; - - if (hDeltaKaFitQA[slice]) - hDeltaKaFitQA[slice]->Write(); - delete hDeltaKaFitQA[slice]; - - if (hDeltaPrFitQA[slice]) - hDeltaPrFitQA[slice]->Write(); - delete hDeltaPrFitQA[slice]; - - if (hGenDeltaElForElProj) - hGenDeltaElForElProj->Write(); - delete hGenDeltaElForElProj; - - if (hGenDeltaElForKaProj) - hGenDeltaElForKaProj->Write(); - delete hGenDeltaElForKaProj; - - if (hGenDeltaElForPiProj) - hGenDeltaElForPiProj->Write(); - delete hGenDeltaElForPiProj; - - if (hGenDeltaElForPrProj) - hGenDeltaElForPrProj->Write(); - delete hGenDeltaElForPrProj; - - if (hGenDeltaElForMuProj) - hGenDeltaElForMuProj->Write(); - delete hGenDeltaElForMuProj; - - //if (fitFuncTotalDeltaElectron[slice]) - // fitFuncTotalDeltaElectron[slice]->Write(); - delete fitFuncTotalDeltaElectron[slice]; - - if (hGenDeltaKaForElProj) - hGenDeltaKaForElProj->Write(); - delete hGenDeltaKaForElProj; - - if (hGenDeltaKaForKaProj) - hGenDeltaKaForKaProj->Write(); - delete hGenDeltaKaForKaProj; - - if (hGenDeltaKaForPiProj) - hGenDeltaKaForPiProj->Write(); - delete hGenDeltaKaForPiProj; - - if (hGenDeltaKaForPrProj) - hGenDeltaKaForPrProj->Write(); - delete hGenDeltaKaForPrProj; - - if (hGenDeltaKaForMuProj) - hGenDeltaKaForMuProj->Write(); - delete hGenDeltaKaForMuProj; - - //if (fitFuncTotalDeltaKaon[slice]) - // fitFuncTotalDeltaKaon[slice]->Write(); - delete fitFuncTotalDeltaKaon[slice]; - - - if (hGenDeltaPiForElProj) - hGenDeltaPiForElProj->Write(); - delete hGenDeltaPiForElProj; - - if (hGenDeltaPiForKaProj) - hGenDeltaPiForKaProj->Write(); - delete hGenDeltaPiForKaProj; - - if (hGenDeltaPiForPiProj) - hGenDeltaPiForPiProj->Write(); - delete hGenDeltaPiForPiProj; - - if (hGenDeltaPiForPrProj) - hGenDeltaPiForPrProj->Write(); - delete hGenDeltaPiForPrProj; - - if (hGenDeltaPiForMuProj) - hGenDeltaPiForMuProj->Write(); - delete hGenDeltaPiForMuProj; - - //if (fitFuncTotalDeltaPion[slice]) - // fitFuncTotalDeltaPion[slice]->Write(); - delete fitFuncTotalDeltaPion[slice]; - - - if (hGenDeltaPrForElProj) - hGenDeltaPrForElProj->Write(); - delete hGenDeltaPrForElProj; - - if (hGenDeltaPrForKaProj) - hGenDeltaPrForKaProj->Write(); - delete hGenDeltaPrForKaProj; - - if (hGenDeltaPrForPiProj) - hGenDeltaPrForPiProj->Write(); - delete hGenDeltaPrForPiProj; - - if (hGenDeltaPrForPrProj) - hGenDeltaPrForPrProj->Write(); - delete hGenDeltaPrForPrProj; - - if (hGenDeltaPrForMuProj) - hGenDeltaPrForMuProj->Write(); - delete hGenDeltaPrForMuProj; - - //if (fitFuncTotalDeltaProton[slice]) - // fitFuncTotalDeltaProton[slice]->Write(); - delete fitFuncTotalDeltaProton[slice]; - - delete totalDeltaElectron; - delete totalDeltaKaon; - delete totalDeltaPion; - delete totalDeltaProton; - - delete legend; - - if (errFlag != 0) - std::cout << "errFlag " << errFlag << std::endl << std::endl; - } - } - - // Calculate MC to-pi ratios -> In MC the yields are uncorrelated, so just divide the histos to get the correct result - hRatioToPiElectronsMC->Divide(hYieldElectronsMC, hYieldPionsMC); - hRatioToPiMuonsMC->Divide(hYieldMuonsMC, hYieldPionsMC); - hRatioToPiKaonsMC->Divide(hYieldKaonsMC, hYieldPionsMC); - hRatioToPiProtonsMC->Divide(hYieldProtonsMC, hYieldPionsMC); - - - TCanvas* cFractions = new TCanvas("cFractions", "Particle fractions",100,10,1200,800); - cFractions->SetGridx(1); - cFractions->SetGridy(1); - cFractions->SetLogx(mode == kPMpT); - hFractionPions->GetYaxis()->SetRangeUser(0.0, 1.0); - SetReasonableAxisRange(hFractionPions->GetXaxis(), mode, pLow, pHigh); - hFractionPions->GetXaxis()->SetMoreLogLabels(kTRUE); - hFractionPions->GetXaxis()->SetNoExponent(kTRUE); - hFractionPions->Draw("e p"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hFractionPionsMC->GetXaxis(), mode, pLow, pHigh); - hFractionPionsMC->Draw("e p same"); - } - - SetReasonableAxisRange(hFractionKaons->GetXaxis(), mode, pLow, pHigh); - hFractionKaons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hFractionKaonsMC->GetXaxis(), mode, pLow, pHigh); - hFractionKaonsMC->Draw("e p same"); - } - - SetReasonableAxisRange(hFractionProtons->GetXaxis(), mode, pLow, pHigh); - hFractionProtons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hFractionProtonsMC->GetXaxis(), mode, pLow, pHigh); - hFractionProtonsMC->Draw("e p same"); - } - - SetReasonableAxisRange(hFractionElectrons->GetXaxis(), mode, pLow, pHigh); - hFractionElectrons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hFractionElectronsMC->GetXaxis(), mode, pLow, pHigh); - hFractionElectronsMC->Draw("e p same"); - } - - if (takeIntoAccountMuons) { - SetReasonableAxisRange(hFractionMuons->GetXaxis(), mode, pLow, pHigh); - hFractionMuons->Draw("e p same"); - } - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hFractionMuonsMC->GetXaxis(), mode, pLow, pHigh); - hFractionMuonsMC->Draw("e p same"); - } - - hFractionSummed->Draw("e p same"); - - if (mode == kPMpT) { - fElectronFraction->SetRange(lowFittingBoundElectronFraction, pHigh); - fElectronFraction->Draw("same"); - } - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - if (plotIdentifiedSpectra) - legend->SetNColumns(2); - if (plotIdentifiedSpectra) - legend->AddEntry((TObject*)0x0, "Fit", ""); - if (plotIdentifiedSpectra) - legend->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); - legend->AddEntry(hFractionPions, "#pi", "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(hFractionPionsMC, "#pi", "p"); - legend->AddEntry(hFractionKaons, "K", "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(hFractionKaonsMC, "K", "p"); - legend->AddEntry(hFractionProtons, "p", "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(hFractionProtonsMC, "p", "p"); - legend->AddEntry(hFractionElectrons, "e", "p"); - if (plotIdentifiedSpectra) - legend->AddEntry(hFractionElectronsMC, "e", "p"); - if (takeIntoAccountMuons) - legend->AddEntry(hFractionMuons, "#mu", "p"); - else - legend->AddEntry((TObject*)0x0, "", ""); - if (plotIdentifiedSpectra) - legend->AddEntry(hFractionMuonsMC, "#mu", "p"); - legend->AddEntry(hFractionSummed, "Total", "p"); - legend->Draw(); - - ClearTitleFromHistoInCanvas(cFractions); - - - // Compare data points with MC - for (Int_t i = 1; i <= hFractionComparisonPions->GetNbinsX(); i++) { - hFractionComparisonPions->SetBinContent(i, hFractionPions->GetBinContent(i)); - hFractionComparisonPions->SetBinError(i, hFractionPions->GetBinError(i)); - - hFractionComparisonElectrons->SetBinContent(i, hFractionElectrons->GetBinContent(i)); - hFractionComparisonElectrons->SetBinError(i, hFractionElectrons->GetBinError(i)); - - if (takeIntoAccountMuons) { - hFractionComparisonMuons->SetBinContent(i, hFractionMuons->GetBinContent(i)); - hFractionComparisonMuons->SetBinError(i, hFractionMuons->GetBinError(i)); - } - - hFractionComparisonKaons->SetBinContent(i, hFractionKaons->GetBinContent(i)); - hFractionComparisonKaons->SetBinError(i, hFractionKaons->GetBinError(i)); - - hFractionComparisonProtons->SetBinContent(i, hFractionProtons->GetBinContent(i)); - hFractionComparisonProtons->SetBinError(i, hFractionProtons->GetBinError(i)); - - hFractionComparisonTotal->SetBinContent(i, hFractionSummed->GetBinContent(i)); - hFractionComparisonTotal->SetBinError(i, hFractionSummed->GetBinError(i)); - } - - hFractionComparisonPions->Divide(hFractionPionsMC); - hFractionComparisonElectrons->Divide(hFractionElectronsMC); - if (takeIntoAccountMuons) - hFractionComparisonMuons->Divide(hFractionMuonsMC); - hFractionComparisonKaons->Divide(hFractionKaonsMC); - hFractionComparisonProtons->Divide(hFractionProtonsMC); - - - TCanvas* cFractionComparisons = new TCanvas("cFractionComparisons", "Particle fraction comparisons",100,10,1200,800); - cFractionComparisons->SetGridx(1); - cFractionComparisons->SetGridy(1); - cFractionComparisons->SetLogx(mode == kPMpT); - hFractionComparisonPions->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonPions->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonPions->GetXaxis()->SetMoreLogLabels(kTRUE); - hFractionComparisonPions->GetXaxis()->SetNoExponent(kTRUE); - hFractionComparisonPions->Draw("e p"); - - hFractionComparisonElectrons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonElectrons->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonElectrons->Draw("e p same"); - - if (takeIntoAccountMuons) { - hFractionComparisonMuons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonMuons->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonMuons->Draw("e p same"); - } - - hFractionComparisonKaons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonKaons->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonKaons->Draw("e p same"); - - hFractionComparisonProtons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonProtons->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonProtons->Draw("e p same"); - - hFractionComparisonTotal->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hFractionComparisonTotal->GetXaxis(), mode, pLow, pHigh); - hFractionComparisonTotal->Draw("e p same"); - - TLegend* legend2 = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend2->SetBorderSize(0); - legend2->SetFillColor(0); - legend2->SetNColumns(2); - legend2->AddEntry(hFractionComparisonPions, "#pi", "p"); - legend2->AddEntry(hFractionComparisonKaons, "K", "p"); - legend2->AddEntry(hFractionComparisonProtons, "p", "p"); - legend2->AddEntry(hFractionComparisonElectrons, "e", "p"); - if (takeIntoAccountMuons) - legend2->AddEntry(hFractionComparisonMuons, "#mu", "p"); - legend2->AddEntry(hFractionComparisonTotal, "Total", "p"); - legend2->Draw(); - - ClearTitleFromHistoInCanvas(cFractionComparisons); - - // Normalise the yields - normaliseYieldHist(hYieldPions, numEvents, deta); - normaliseYieldHist(hYieldPionsMC, numEvents, deta); - normaliseYieldHist(hYieldPionsDeltaElectron, numEvents, deta); - normaliseYieldHist(hYieldPionsDeltaPion, numEvents, deta); - normaliseYieldHist(hYieldPionsDeltaKaon, numEvents, deta); - normaliseYieldHist(hYieldPionsDeltaProton, numEvents, deta); - - normaliseYieldHist(hYieldElectrons, numEvents, deta); - normaliseYieldHist(hYieldElectronsMC, numEvents, deta); - normaliseYieldHist(hYieldElectronsDeltaElectron, numEvents, deta); - normaliseYieldHist(hYieldElectronsDeltaPion, numEvents, deta); - normaliseYieldHist(hYieldElectronsDeltaKaon, numEvents, deta); - normaliseYieldHist(hYieldElectronsDeltaProton, numEvents, deta); - - normaliseYieldHist(hYieldMuons, numEvents, deta); - normaliseYieldHist(hYieldMuonsMC, numEvents, deta); - normaliseYieldHist(hYieldMuonsDeltaElectron, numEvents, deta); - normaliseYieldHist(hYieldMuonsDeltaPion, numEvents, deta); - normaliseYieldHist(hYieldMuonsDeltaKaon, numEvents, deta); - normaliseYieldHist(hYieldMuonsDeltaProton, numEvents, deta); - - normaliseYieldHist(hYieldKaons, numEvents, deta); - normaliseYieldHist(hYieldKaonsMC, numEvents, deta); - normaliseYieldHist(hYieldKaonsDeltaElectron, numEvents, deta); - normaliseYieldHist(hYieldKaonsDeltaPion, numEvents, deta); - normaliseYieldHist(hYieldKaonsDeltaKaon, numEvents, deta); - normaliseYieldHist(hYieldKaonsDeltaProton, numEvents, deta); - - normaliseYieldHist(hYieldProtons, numEvents, deta); - normaliseYieldHist(hYieldProtonsMC, numEvents, deta); - normaliseYieldHist(hYieldProtonsDeltaElectron, numEvents, deta); - normaliseYieldHist(hYieldProtonsDeltaPion, numEvents, deta); - normaliseYieldHist(hYieldProtonsDeltaKaon, numEvents, deta); - normaliseYieldHist(hYieldProtonsDeltaProton, numEvents, deta); - - normaliseYieldHist(hYieldSummedMC, numEvents, deta); - - for (Int_t i = 0; i < AliPID::kSPECIES; i++) { - if (hMCgenYieldsPrimSpecies[i]) { - Int_t color = kBlack; - - switch (i) { - case AliPID::kElectron: - color = getLineColor(kEl); - break; - case AliPID::kKaon: - color = getLineColor(kKa); - break; - case AliPID::kMuon: - color = getLineColor(kMu); - break; - case AliPID::kPion: - color = getLineColor(kPi); - break; - case AliPID::kProton: - color = getLineColor(kPr); - break; - } - - hMCgenYieldsPrimSpecies[i]->SetLineColor(color); - hMCgenYieldsPrimSpecies[i]->SetMarkerColor(color); - hMCgenYieldsPrimSpecies[i]->SetMarkerStyle(28); - hMCgenYieldsPrimSpecies[i]->SetLineStyle(1); - hMCgenYieldsPrimSpecies[i]->GetXaxis()->SetTitleOffset(1.0); - hMCgenYieldsPrimSpecies[i]->SetStats(kFALSE); - - SetReasonableAxisRange(hMCgenYieldsPrimSpecies[i]->GetXaxis(), kPMpT, pLow, pHigh); - normaliseGenYieldMCtruthHist(hMCgenYieldsPrimSpecies[i], numEvents, deta); - } - } - - - // Compare data points with MC (yield) - for (Int_t i = 1; i <= hYieldComparisonPions->GetNbinsX(); i++) { - hYieldComparisonPions->SetBinContent(i, hYieldPions->GetBinContent(i)); - hYieldComparisonPions->SetBinError(i, hYieldPions->GetBinError(i)); - - hYieldComparisonElectrons->SetBinContent(i, hYieldElectrons->GetBinContent(i)); - hYieldComparisonElectrons->SetBinError(i, hYieldElectrons->GetBinError(i)); - - if (takeIntoAccountMuons) { - hYieldComparisonMuons->SetBinContent(i, hYieldMuons->GetBinContent(i)); - hYieldComparisonMuons->SetBinError(i, hYieldMuons->GetBinError(i)); - } - - hYieldComparisonKaons->SetBinContent(i, hYieldKaons->GetBinContent(i)); - hYieldComparisonKaons->SetBinError(i, hYieldKaons->GetBinError(i)); - - hYieldComparisonProtons->SetBinContent(i, hYieldProtons->GetBinContent(i)); - hYieldComparisonProtons->SetBinError(i, hYieldProtons->GetBinError(i)); - } - - hYieldComparisonPions->Divide(hYieldPionsMC); - hYieldComparisonElectrons->Divide(hYieldElectronsMC); - if (takeIntoAccountMuons) - hYieldComparisonMuons->Divide(hYieldMuonsMC); - hYieldComparisonKaons->Divide(hYieldKaonsMC); - hYieldComparisonProtons->Divide(hYieldProtonsMC); - - - TCanvas* cYieldComparisons = new TCanvas("cYieldComparisons", "Particle yield comparisons",100,10,1200,800); - cYieldComparisons->SetGridx(1); - cYieldComparisons->SetGridy(1); - cYieldComparisons->SetLogx(mode == kPMpT); - hYieldComparisonPions->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hYieldComparisonPions->GetXaxis(), mode, pLow, pHigh); - hYieldComparisonPions->GetXaxis()->SetMoreLogLabels(kTRUE); - hYieldComparisonPions->GetXaxis()->SetNoExponent(kTRUE); - hYieldComparisonPions->Draw("e p"); - - hYieldComparisonElectrons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hYieldComparisonElectrons->GetXaxis(), mode, pLow, pHigh); - hYieldComparisonElectrons->Draw("e p same"); - - if (takeIntoAccountMuons) { - hYieldComparisonMuons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hYieldComparisonMuons->GetXaxis(), mode, pLow, pHigh); - hYieldComparisonMuons->Draw("e p same"); - } - - hYieldComparisonKaons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hYieldComparisonKaons->GetXaxis(), mode, pLow, pHigh); - hYieldComparisonKaons->Draw("e p same"); - - hYieldComparisonProtons->GetYaxis()->SetRangeUser(0.0, 10.0); - SetReasonableAxisRange(hYieldComparisonProtons->GetXaxis(), mode, pLow, pHigh); - hYieldComparisonProtons->Draw("e p same"); - - TLegend* legend3 = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend3->SetBorderSize(0); - legend3->SetFillColor(0); - legend3->SetNColumns(2); - legend3->AddEntry(hYieldComparisonPions, "#pi", "p"); - legend3->AddEntry(hYieldComparisonKaons, "K", "p"); - legend3->AddEntry(hYieldComparisonProtons, "p", "p"); - legend3->AddEntry(hYieldComparisonElectrons, "e", "p"); - if (takeIntoAccountMuons) - legend3->AddEntry(hYieldComparisonMuons, "#mu", "p"); - legend3->Draw(); - - ClearTitleFromHistoInCanvas(cYieldComparisons); - - - - - TCanvas* cFractionsPions = drawFractionHistos("cFractionsPions", "Pion fractions", mode, pLow, pHigh, hFractionPionsDeltaPion, - hFractionPionsDeltaElectron, hFractionPionsDeltaKaon, hFractionPionsDeltaProton, - hFractionPionsMC, plotIdentifiedSpectra); - - - TCanvas* cFractionsElectrons = drawFractionHistos("cFractionsElectrons", "Electron fractions", mode, pLow, pHigh, - hFractionElectronsDeltaPion, hFractionElectronsDeltaElectron, - hFractionElectronsDeltaKaon, hFractionElectronsDeltaProton, hFractionElectronsMC, - plotIdentifiedSpectra); - - TCanvas* cFractionsKaons = drawFractionHistos("cFractionsKaons", "Kaon fractions", mode, pLow, pHigh, hFractionKaonsDeltaPion, - hFractionKaonsDeltaElectron, hFractionKaonsDeltaKaon, hFractionKaonsDeltaProton, - hFractionKaonsMC, plotIdentifiedSpectra); - - TCanvas* cFractionsProtons = drawFractionHistos("cFractionsProtons", "Proton fractions", mode, pLow, pHigh, hFractionProtonsDeltaPion, - hFractionProtonsDeltaElectron, hFractionProtonsDeltaKaon, hFractionProtonsDeltaProton, - hFractionProtonsMC, plotIdentifiedSpectra); - - TCanvas* cFractionsMuons = drawFractionHistos("cFractionsMuons", "Muon fractions", mode, pLow, pHigh, hFractionMuonsDeltaPion, - hFractionMuonsDeltaElectron, hFractionMuonsDeltaKaon, hFractionMuonsDeltaProton, - hFractionMuonsMC, plotIdentifiedSpectra); - - - - TCanvas* cYields = new TCanvas("cYields", "Particle yields",100,10,1200,800); - cYields->SetGridx(1); - cYields->SetGridy(1); - cYields->SetLogx(mode == kPMpT); - cYields->SetLogy(1); - hYieldPions->GetYaxis()->SetRangeUser(hYieldElectrons->GetBinContent(hYieldElectrons->FindLastBinAbove(0.)) / 10., - hYieldPions->GetBinContent(hYieldPions->GetMaximumBin()) * 10.); - SetReasonableAxisRange(hYieldPions->GetXaxis(), mode, pLow, pHigh); - hYieldPions->GetXaxis()->SetMoreLogLabels(kTRUE); - hYieldPions->GetXaxis()->SetNoExponent(kTRUE); - hYieldPions->Draw("e p"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hYieldPionsMC->GetXaxis(), mode, pLow, pHigh); - hYieldPionsMC->Draw("e p same"); - } - - SetReasonableAxisRange(hYieldKaons->GetXaxis(), mode, pLow, pHigh); - hYieldKaons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hYieldKaonsMC->GetXaxis(), mode, pLow, pHigh); - hYieldKaonsMC->Draw("e p same"); - } - - SetReasonableAxisRange(hYieldProtons->GetXaxis(), mode, pLow, pHigh); - hYieldProtons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hYieldProtonsMC->GetXaxis(), mode, pLow, pHigh); - hYieldProtonsMC->Draw("e p same"); - } - - if (takeIntoAccountMuons) { - SetReasonableAxisRange(hYieldMuons->GetXaxis(), mode, pLow, pHigh); - hYieldMuons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hYieldMuonsMC->GetXaxis(), mode, pLow, pHigh); - hYieldMuonsMC->Draw("e p same"); - } - } - - SetReasonableAxisRange(hYieldElectrons->GetXaxis(), mode, pLow, pHigh); - hYieldElectrons->Draw("e p same"); - if (plotIdentifiedSpectra) { - SetReasonableAxisRange(hYieldElectronsMC->GetXaxis(), mode, pLow, pHigh); - hYieldElectronsMC->Draw("e p same"); - } - - TLegend* legendYields = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legendYields->SetBorderSize(0); - legendYields->SetFillColor(0); - if (plotIdentifiedSpectra) - legendYields->SetNColumns(2); - if (plotIdentifiedSpectra) - legendYields->AddEntry((TObject*)0x0, "Fit", ""); - if (plotIdentifiedSpectra) - legendYields->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); - legendYields->AddEntry(hYieldPions, "#pi", "p"); - if (plotIdentifiedSpectra) - legendYields->AddEntry(hYieldPionsMC, "#pi", "p"); - legendYields->AddEntry(hYieldKaons, "K", "p"); - if (plotIdentifiedSpectra) - legendYields->AddEntry(hYieldKaonsMC, "K", "p"); - legendYields->AddEntry(hYieldProtons, "p", "p"); - if (plotIdentifiedSpectra) - legendYields->AddEntry(hYieldProtonsMC, "p", "p"); - legendYields->AddEntry(hYieldElectrons, "e", "p"); - if (plotIdentifiedSpectra) - legendYields->AddEntry(hYieldElectronsMC, "e", "p"); - if (takeIntoAccountMuons) - legendYields->AddEntry(hYieldMuons, "#mu", "p"); - else - legendYields->AddEntry((TObject*)0x0, "", ""); - if (plotIdentifiedSpectra) - legendYields->AddEntry(hYieldMuonsMC, "#mu", "p"); - legendYields->Draw(); - - ClearTitleFromHistoInCanvas(cYields); - - - TCanvas* cYieldsPions = drawYieldHistos("cYieldsPions", "Pion yields", mode, pLow, pHigh, hYieldPionsDeltaPion, hYieldPionsDeltaElectron, - hYieldPionsDeltaKaon, hYieldPionsDeltaProton, hYieldPionsMC, plotIdentifiedSpectra); - - - TCanvas* cYieldsElectrons = drawYieldHistos("cYieldsElectrons", "Electron yields", mode, pLow, pHigh, hYieldElectronsDeltaPion, - hYieldElectronsDeltaElectron, hYieldElectronsDeltaKaon, hYieldElectronsDeltaProton, hYieldElectronsMC, - plotIdentifiedSpectra); - - TCanvas* cYieldsKaons = drawYieldHistos("cYieldsKaons", "Kaon yields", mode, pLow, pHigh, hYieldKaonsDeltaPion, hYieldKaonsDeltaElectron, - hYieldKaonsDeltaKaon, hYieldKaonsDeltaProton, hYieldKaonsMC, plotIdentifiedSpectra); - - TCanvas* cYieldsProtons = drawYieldHistos("cYieldsProtons", "Proton yields", mode, pLow, pHigh, hYieldProtonsDeltaPion, hYieldProtonsDeltaElectron, - hYieldProtonsDeltaKaon, hYieldProtonsDeltaProton, hYieldProtonsMC, plotIdentifiedSpectra); - - TCanvas* cYieldsMuons = drawYieldHistos("cYieldsMuons", "Muon yields", mode, pLow, pHigh, hYieldMuonsDeltaPion, hYieldMuonsDeltaElectron, - hYieldMuonsDeltaKaon, hYieldMuonsDeltaProton, hYieldMuonsMC, plotIdentifiedSpectra); - - - // Save final results - saveF->cd(); - - if (fElectronFraction) - fElectronFraction->Write(); - - if (hFractionElectrons) - hFractionElectrons->Write(0, TObject::kWriteDelete); - - if (hFractionKaons) - hFractionKaons->Write(0, TObject::kWriteDelete); - - if (hFractionPions) - hFractionPions->Write(0, TObject::kWriteDelete); - - if (hFractionProtons) - hFractionProtons->Write(0, TObject::kWriteDelete); - - if (hFractionMuons) - hFractionMuons->Write(0, TObject::kWriteDelete); - - if (hFractionSummed) - hFractionSummed->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaElectron) - hFractionElectronsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaElectron) - hFractionKaonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaElectron) - hFractionPionsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaElectron) - hFractionProtonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaElectron) - hFractionMuonsDeltaElectron->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaPion) - hFractionElectronsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaPion) - hFractionKaonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaPion) - hFractionPionsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaPion) - hFractionProtonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaPion) - hFractionMuonsDeltaPion->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaKaon) - hFractionElectronsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaKaon) - hFractionKaonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaKaon) - hFractionPionsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaKaon) - hFractionProtonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaKaon) - hFractionMuonsDeltaKaon->Write(0, TObject::kWriteDelete); - - - if (hFractionElectronsDeltaProton) - hFractionElectronsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsDeltaProton) - hFractionKaonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionPionsDeltaProton) - hFractionPionsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsDeltaProton) - hFractionProtonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsDeltaProton) - hFractionMuonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hNumEvents) - hNumEvents->Write(); - - if (cFractions) - cFractions->Write(); - if (cFractionsPions) - cFractionsPions->Write(); - if (cFractionsElectrons) - cFractionsElectrons->Write(); - if (cFractionsKaons) - cFractionsKaons->Write(); - if (cFractionsProtons) - cFractionsProtons->Write(); - if (cFractionsMuons) - cFractionsMuons->Write(); - - - if (hFractionElectronsMC) - hFractionElectronsMC->Write(0, TObject::kWriteDelete); - - if (hFractionKaonsMC) - hFractionKaonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionPionsMC) - hFractionPionsMC->Write(0, TObject::kWriteDelete); - - if (hFractionMuonsMC) - hFractionMuonsMC->Write(0, TObject::kWriteDelete); - - if (hFractionProtonsMC) - hFractionProtonsMC->Write(0, TObject::kWriteDelete); - - - if (hFractionComparisonElectrons) - hFractionComparisonElectrons->Write(0, TObject::kWriteDelete); - - if (hFractionComparisonMuons) - hFractionComparisonMuons->Write(0, TObject::kWriteDelete); - - if (hFractionComparisonKaons) - hFractionComparisonKaons->Write(0, TObject::kWriteDelete); - - if (hFractionComparisonPions) - hFractionComparisonPions->Write(0, TObject::kWriteDelete); - - if (hFractionComparisonProtons) - hFractionComparisonProtons->Write(0, TObject::kWriteDelete); - - if (hFractionComparisonTotal) - hFractionComparisonTotal->Write(0, TObject::kWriteDelete); - - if (cFractionComparisons) - cFractionComparisons->Write(); - - - if (hYieldComparisonElectrons) - hYieldComparisonElectrons->Write(0, TObject::kWriteDelete); - - if (hYieldComparisonMuons) - hYieldComparisonMuons->Write(0, TObject::kWriteDelete); - - if (hYieldComparisonKaons) - hYieldComparisonKaons->Write(0, TObject::kWriteDelete); - - if (hYieldComparisonPions) - hYieldComparisonPions->Write(0, TObject::kWriteDelete); - - if (hYieldComparisonProtons) - hYieldComparisonProtons->Write(0, TObject::kWriteDelete); - - if (cYieldComparisons) - cYieldComparisons->Write(); - - - if (hYieldElectrons) - hYieldElectrons->Write(0, TObject::kWriteDelete); - - if (hYieldKaons) - hYieldKaons->Write(0, TObject::kWriteDelete); - - if (hYieldPions) - hYieldPions->Write(0, TObject::kWriteDelete); - - if (hYieldProtons) - hYieldProtons->Write(0, TObject::kWriteDelete); - - if (hYieldMuons) - hYieldMuons->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaElectron) - hYieldElectronsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaElectron) - hYieldKaonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaElectron) - hYieldPionsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaElectron) - hYieldProtonsDeltaElectron->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaElectron) - hYieldMuonsDeltaElectron->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaPion) - hYieldElectronsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaPion) - hYieldKaonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaPion) - hYieldPionsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaPion) - hYieldProtonsDeltaPion->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaPion) - hYieldMuonsDeltaPion->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaKaon) - hYieldElectronsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaKaon) - hYieldKaonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaKaon) - hYieldPionsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaKaon) - hYieldProtonsDeltaKaon->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaKaon) - hYieldMuonsDeltaKaon->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsDeltaProton) - hYieldElectronsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsDeltaProton) - hYieldKaonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldPionsDeltaProton) - hYieldPionsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsDeltaProton) - hYieldProtonsDeltaProton->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsDeltaProton) - hYieldMuonsDeltaProton->Write(0, TObject::kWriteDelete); - - - if (hYieldElectronsMC) - hYieldElectronsMC->Write(0, TObject::kWriteDelete); - - if (hYieldKaonsMC) - hYieldKaonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldPionsMC) - hYieldPionsMC->Write(0, TObject::kWriteDelete); - - if (hYieldMuonsMC) - hYieldMuonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldProtonsMC) - hYieldProtonsMC->Write(0, TObject::kWriteDelete); - - if (hYieldSummedMC) - hYieldSummedMC->Write(0, TObject::kWriteDelete); - - - if (hRatioToPiElectrons) - hRatioToPiElectrons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiMuons) - hRatioToPiMuons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiKaons) - hRatioToPiKaons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiProtons) - hRatioToPiProtons->Write(0, TObject::kWriteDelete); - - if (hRatioToPiElectronsMC) - hRatioToPiElectronsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiMuonsMC) - hRatioToPiMuonsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiKaonsMC) - hRatioToPiKaonsMC->Write(0, TObject::kWriteDelete); - - if (hRatioToPiProtonsMC) - hRatioToPiProtonsMC->Write(0, TObject::kWriteDelete); - - - - if (hReducedChiSquarePt) - hReducedChiSquarePt->Write(0, TObject::kWriteDelete); - - if (cYields) - cYields->Write(); - if (cYieldsPions) - cYieldsPions->Write(); - if (cYieldsElectrons) - cYieldsElectrons->Write(); - if (cYieldsKaons) - cYieldsKaons->Write(); - if (cYieldsProtons) - cYieldsProtons->Write(); - if (cYieldsMuons) - cYieldsMuons->Write(); - - for (Int_t i = 0; i < AliPID::kSPECIES; i++) { - if (hMCgenYieldsPrimSpecies[i]) - hMCgenYieldsPrimSpecies[i]->Write(); - } - - if (filePathNameResults) - *filePathNameResults = saveFName; - - if (TMath::Abs(mathFit->GetScaleFactorError() - 1.) > 1e-6) { - // If the deltaPrime range is large enough, we artificially get a factor 4 in statistics by looking at the four - // different deltaPrimeSpecies, which have (except for binning effects) the same information. - // Therefore, to get the "real" statistical error, we need to multiply the obtained error by sqrt(4) = 2 - std::cout << "NOTE: Errors multiplied by " << mathFit->GetScaleFactorError() - << " to take into account artificially higher statistics (by factor of 4) due to same information " - << "for all deltaPrimeSpecies (except for binning effects), if deltaPrimeRange sufficiently large!" << std::endl - << std::endl; - } - - if (fitMethod < 2) { - std::cout << "WARNING: Errors might be wrong! Especially, for the to-pi ratios there are no correlations taken into account!" - << std::endl; - } - - delete gFractionElectronsData; - delete fElectronFraction; - - delete mathFit; - - delete cFractions; - delete cFractionComparisons; - delete cYieldComparisons; - delete cFractionsPions; - delete cFractionsElectrons; - delete cFractionsKaons; - delete cFractionsProtons; - delete cFractionsMuons; - delete cYields; - delete cYieldsPions; - delete cYieldsKaons; - delete cYieldsMuons; - delete cYieldsProtons; - delete cYieldsElectrons; - - saveF->Close(); - - return 0; -} +#include "THnSparse.h" +#include "TH2D.h" +#include "TH1D.h" +#include "TProfile.h" +#include "TF1.h" +#include "TFitResultPtr.h" +#include "TFitResult.h" +#include "TCanvas.h" +#include "TStyle.h" +#include "TVirtualFitter.h" +#include "TObjArray.h" +#include "TString.h" +#include "TLegend.h" +#include "TFile.h" +#include "TGraphErrors.h" +#include "TGraph.h" +#include "TMath.h" +#include "TMatrixDSym.h" +#include "TRandom3.h" +#include "TROOT.h" + +#include +#include + +#include "AliPID.h" + +#include "THnSparseDefinitions.h" +#include "AliTPCPIDmathFit.h" + +enum processMode { kPMpT = 0, kPMz = 1, kPMxi = 2 }; +enum muonTreatment { kNoMuons = 0, kMuonFracEqualElFrac = 1, kMuonFracOverElFracTunedOnMCStandardTrackCuts = 2, + kMuonFracOverElFracTunedOnMCHybridTrackCuts = 3, kMuonFracOverElFracTunedOnMCHybridTrackCutsJets = 4, + kMuonFracOverElFracTunedOnMCStandardTrackCutsPPb = 5, + kNumHandlings = 6 }; + +const TString modeShortName[3] = { "Pt", "Z", "Xi" }; +const TString modeLatexName[3] = { "P_{T}", "z", "#xi" }; + +const TString muonFractionHandlingShortName[kNumHandlings] = + { "noMuons", "muonsEqualElectrons", "muonToElTunedOnMCStandardTrackCuts", "muonToElTunedOnMCHybridTrackCuts", + "muonToElTunedOnMCHybridTrackCutsJets", "muonToElTunedOnMCStandardTrackCutsPPB" }; + +const Double_t epsilon = 1e-10; +const TString identifiedLabels[2] = { "Most Probable PID", "MC" }; +Int_t isMC = 0; + +TString minimisationStrategy = "MIGRAD"; // "MINIMIZE" +Bool_t takeIntoAccountMuons = kTRUE; + +// 0 = no muons, 1 = muonFrac=elFrac, 2(3) = muonFrac/elFrac tuned on MC for DefaultTrackCuts (hybridTrackCuts), +// 4 = muonFrac/elFrac tuned on MC for hybridTrackCuts for jet particles, +Int_t muonFractionHandling = 3; + + +//TODO getErrorOf.... is COMPLETELY wrong now, since the parameter numbering has changed and the muons had come into play!!!!!! + +// TODO CAREFUL: fitMethod == 1 adds errors of electrons to pions, but not to muons (should be added to electron error instead!) +const Bool_t muonContamination = kFALSE;//TODO CAREFUL: fitMethod == 1 takes into account the muon contamination in the error calculation!!! + +const Bool_t normaliseResults = kTRUE; // Works only for fitMethod == 2 + +const Bool_t enableShift = kFALSE; +const Int_t dataAxis = kPidDeltaPrime;//kPidDelta; kPidDeltaPrime + +const Int_t numSimultaneousFits = 4; + +// Upper and lower axis bounds (y-axis) of (data - fit) / data QA histos +const Double_t fitQAaxisLowBound = -0.5; +const Double_t fitQAaxisUpBound = 0.5; + +Bool_t useDeltaPrime = (dataAxis == kPidDeltaPrime); + +// Will be set later +Double_t muonFractionThresholdForFitting = -1.; +Double_t muonFractionThresholdBinForFitting = -1; + +Double_t electronFractionThresholdForFitting = -1.; +Double_t electronFractionThresholdBinForFitting = -1; + + +TF1 fMuonOverElFractionMC("fMuonOverElFractionMC", "[0]+[1]/TMath::Min(x, [4])+[2]*TMath::Min(x, [4])+[3]*TMath::Min(x, [4])*TMath::Min(x, [4])+[5]*TMath::Min(x, [4])*TMath::Min(x, [4])*TMath::Min(x, [4])+[6]*(x>[7])*TMath::Min(x-[7], [8]-[7])", + 0.01, 50.); + +TF1* fElectronFraction = 0x0; +const Double_t lowFittingBoundElectronFraction = 3.0; + +TGraphErrors* gFractionElectronsData = 0x0; +Double_t lastPtForCallOfGetElectronFraction = -1; + + +//____________________________________________________________________________________________________________________ +Double_t GetElectronFraction(const Double_t pT, const Double_t *par) +{ + // During the fit (both, simultaneous and non-simultaneous), the algorithm will always start off from + // the low pT and go to higher pT. So, it is only necessary to do the fit once the first fixed bin is reached. + // Then the parameters for the electron fraction remain fixed until the next fit iteration. + // Since only for the case of regularisation the electron fractions of all x bins are stored in mathFit, + // the evaluation of this function is done here only in that case (only then the electron fraction will + // be set to "-pT". + + // NOTE 1: Electrons have index 3 per x bin + // NOTE 2: This function is only called for fitting vs. pT. In that case, xValue holds the LOG of pT! + + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + // lastPtForCallOfGetElectronFraction will be initialised with a value larger than any pT during the fit. + // So, if this function is called and the pT is smaller than lastPtForCallOfGetElectronFraction, the parameters + // must have changed and the electron fit needs to be re-done (also see comment above) + if (pT < lastPtForCallOfGetElectronFraction) { + for (Int_t xBin = 0; xBin < mathFit->GetNumXbinsRegularisation(); xBin++) { + + const Double_t xCoord = TMath::Exp(mathFit->GetXvaluesForRegularisation()[xBin]); + const Int_t parIndexWithFraction = 3 + xBin * mathFit->GetNumParametersPerXbin(); + + if (xCoord >= lowFittingBoundElectronFraction && xCoord <= electronFractionThresholdForFitting + && par[parIndexWithFraction] > epsilon) { // Skip zero values (usually due to failed fits) + gFractionElectronsData->SetPoint(xBin, TMath::Exp(mathFit->GetXvaluesForRegularisation()[xBin]), par[parIndexWithFraction]); + // Since the errors during the fitting are not reliable, use the following approximation on a statistical basis + // (which indeed turns out to be rather good!) + + // Bin effective weight required for weighted data sets. In case of no weighting, the weight error is sqrt(weight), + // i.e. effWeight is 1 + const Double_t effWeight = mathFit->GetXstatisticalWeightError()[xBin] * mathFit->GetXstatisticalWeightError()[xBin] + / mathFit->GetXstatisticalWeight()[xBin]; + gFractionElectronsData->SetPointError(xBin, 0, effWeight * TMath::Sqrt(par[parIndexWithFraction] + / mathFit->GetXstatisticalWeight()[xBin])); + } + else { + gFractionElectronsData->SetPoint(xBin, -1, 0); + gFractionElectronsData->SetPointError(xBin, 0, 0); + } + } + + gFractionElectronsData->Fit(fElectronFraction, "Ex0NQ", "", lowFittingBoundElectronFraction, electronFractionThresholdForFitting); + } + + lastPtForCallOfGetElectronFraction = pT; + + // Catch cases in which the fit function yields invalid fractions (i.e. < 0 or > 1) + return TMath::Max(0.0, TMath::Min(1.0, fElectronFraction->Eval(pT))); +} + + +//____________________________________________________________________________________________________________________ +Double_t GetElectronFractionError() +{ + // This function estimates the error of the electron fraction for the fixed values via using the parameter errors of + // the electron fraction function. Note that the parameters (and errors) must be set before calling this function. + + // Produce several values via setting the parameters to a random value, which is distributed with a gaussian with mean = parValue + // and sigma = parError and then take the 2*RMS as the error + const Int_t nGenValues = 1000; + Double_t genValues[nGenValues]; + + const Int_t nPars = fElectronFraction->GetNpar(); + Double_t par[nPars]; + + TRandom3 rnd(0); // 0 means random seed + + const Double_t x = electronFractionThresholdForFitting + 1.; // Some value above the threshold to obtain a fixed value + for (Int_t i = 0 ; i < nGenValues; i++) { + for (Int_t iPar = 0; iPar < nPars; iPar++) + par[iPar] = rnd.Gaus(fElectronFraction->GetParameter(iPar), fElectronFraction->GetParError(iPar)); + + genValues[i] = fElectronFraction->EvalPar(&x, &par[0]); + } + + // NOTE: RMS is not really the root mean square, is it rather the sigma deviation, which is what is wanted here + return 2. * TMath::RMS(nGenValues, &genValues[0]); +} + + +//____________________________________________________________________________________________________________________ +Double_t GetMuonFractionFromElectronFractionAndPt(Double_t pT, Double_t elFrac) +{ + if (muonFractionHandling == kMuonFracOverElFracTunedOnMCStandardTrackCuts) { +// return elFrac / (1. + 7.06909e+01 * TMath::Exp(-2.95078e+00 * TMath::Power(pT, 5.05016e-01))); + return elFrac / (1. + 2.01840e+10 * TMath::Exp(-2.50480e+01 * TMath::Power(pT, 5.89044e-02))); + } + else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCHybridTrackCuts) { + fMuonOverElFractionMC.SetParameters(-6.87241e-01, 4.19528e-02, 4.52095e+00, -6.20026e+00, 5.16629e-01, 2.88604e+00, 3.68058e-02, + 2.21086e+00, 5.75003e+00); + return elFrac * fMuonOverElFractionMC.Eval(pT); + } + else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) { + fMuonOverElFractionMC.SetParameters(-7.64548e-01, 2.47929e-02, 4.49057e+00, -2.06320e-01, 4.23339e-02, 1.19697e+02, 1.28832e-01, + -1.71895e-01, 6.00000e+00); + return elFrac * fMuonOverElFractionMC.Eval(pT); + } + else if (muonFractionHandling == kMuonFracOverElFracTunedOnMCStandardTrackCutsPPb) { + // WITH PID cluster cut! + fMuonOverElFractionMC.SetParameters(-6.62149e-01, 4.89591e-02, 4.58356e+00, -6.04319e+00, 6.25368e-01, 3.27191e+00, 1.69933e-01, + 1.00004e+00, 2.61438e+00); + return elFrac * fMuonOverElFractionMC.Eval(pT); + } + else if (muonFractionHandling == kMuonFracEqualElFrac) { + return elFrac; + } + + return 0.; +} + + +//____________________________________________________________________________________________________________________ +Double_t GetCorrelatedError(const Double_t x, const Double_t y, const Double_t cov00, const Double_t cov11, const Double_t cov01) +{ + // Calculate the correlated error df of f: + // (cov00 cov01) (x) + //df^2 = (x, y) * (cov01 cov11) (y) = x^2 * cov00 + y^2 * cov11 + 2 * x * y * cov01 + // + // with f = f(p1, p2) = p1 / p2 + // and (x, y) = (\partial f / \partial p1, \partial f / \partial p2) + // = (f / p1, -f / p2) + + const Double_t df2 = x * x * cov00 + y * y * cov11 + 2. * x * y * cov01; + + if (df2 < epsilon) + return 0.; + + return TMath::Sqrt(df2); +} + + +//____________________________________________________________________________________________________________________ +void GetRatioWithCorrelatedError(const Double_t fractionA, const Double_t fractionB, + const Double_t fractionErrorA, const Double_t fractionErrorB, + const Double_t covMatrixElementAB, Double_t& ratio, Double_t& ratioError) +{ + // Given fractions A and B with corresponding errors and the off-diagonal covariance matrix element of + // these fractions, calculate the ratio A/B and the error taking into account the correlation. + // The results are stored in ratio and ratioError. + + if (fractionB < epsilon) { + ratio = -999.; + ratioError = 999.; + + return; + } + + if (fractionA < epsilon) { + ratio = 0.; + ratioError = 999.; + + return; + } + + ratio = fractionA / fractionB; + + const Double_t x = ratio / fractionA; + const Double_t y = -ratio / fractionB; + + // covMatrixElement(i, i) = error(i)^2 + ratioError = GetCorrelatedError(x, y, fractionErrorA * fractionErrorA, fractionErrorB * fractionErrorB, covMatrixElementAB); + + //printf("frationA %e\nfractionB %e\nfractionErrorA %e\nfractionErrorB %e\ncovMatrixElementAB %e\nratio %e\nx %e\ny %e\nratioError %e\n\n", + // fractionA, fractionB, fractionErrorA, fractionErrorB, covMatrixElementAB, ratio, x, y, ratioError); +} + + +//____________________________________________________________________________________________________________________ +void SetReasonableAxisRange(TAxis* axis, Int_t mode, Double_t pLow = -1, Double_t pHigh = -1) +{ + if (mode == kPMpT) + axis->SetRangeUser(TMath::Max(0.15, pLow - 0.1), TMath::Min(50., pHigh + 0.1)); + else if (mode == kPMz) + axis->SetRange(0, -1); + else if (mode == kPMxi) + axis->SetRange(0, -1); +} + +//____________________________________________________________________________________________________________________ +void SetReasonableXaxisRange(TH1* h, Int_t& binLow, Int_t& binHigh) +{ + binLow = TMath::Max(1, h->FindFirstBinAbove(0)); + binHigh = TMath::Min(h->GetNbinsX(), h->FindLastBinAbove(0)); + + h->GetXaxis()->SetRange(binLow, binHigh); + h->GetXaxis()->SetMoreLogLabels(kTRUE); + h->GetXaxis()->SetNoExponent(kTRUE); +} + + +//____________________________________________________________________________________________________________________ +Int_t FindMomentumBin(const Double_t* pTbins, const Double_t value, const Int_t numPtBins = nPtBins) +{ + for (Int_t bin = 0; bin < numPtBins; bin++) { + if (value >= pTbins[bin] && value < pTbins[bin + 1]) + return bin; + } + + return -1; +} + + +//____________________________________________________________________________________________________________________ +Double_t normaliseHist(TH1* h, Double_t scaleFactor = -1) +{ + // Scales the histogram with the scale factor. If the scale factor is < 0, + // the histogram is normalised to it's integral. + // In both cases, the normalisation factor is returned. + + Double_t normFactor = 1.; + + if (scaleFactor < 0) { + Double_t integralTemp = h->Integral(); + if (integralTemp > 0) { + normFactor = 1.0 / integralTemp; + h->Scale(normFactor); + } + } + else { + normFactor = scaleFactor; + h->Scale(normFactor); + } + + h->GetXaxis()->SetTitleOffset(1.0); + + return normFactor; +} + + +//____________________________________________________________________________________________________________________ +void normaliseYieldHist(TH1* h, Double_t numEvents, Double_t deta) +{ + // Yield histos are already normalised to dpT. Now normalise to 1/NeV 1/(2pi pT) 1/deta in addition + + if (numEvents <= 0) // Do not normalise + numEvents = 1; + + for (Int_t bin = 1; bin <= h->GetNbinsX(); bin++) { + Double_t normFactor = 1. / (numEvents * 2 * TMath::Pi() * h->GetXaxis()->GetBinCenter(bin) * deta); + h->SetBinContent(bin, h->GetBinContent(bin) * normFactor); + h->SetBinError(bin, h->GetBinError(bin) * normFactor); + } +} + + +//____________________________________________________________________________________________________________________ +void normaliseGenYieldMCtruthHist(TH1* h, Double_t numEvents, Double_t deta) +{ + // Yield histos are NOT normalised to dpT. Now normalise to 1/NeV 1/(2pi pT) 1/deta 1/dpT! + + if (numEvents <= 0) // Do not normalise + numEvents = 1; + + for (Int_t bin = 1; bin <= h->GetNbinsX(); bin++) { + Double_t normFactor = 1. / (numEvents * 2 * TMath::Pi() * h->GetXaxis()->GetBinCenter(bin) * h->GetXaxis()->GetBinWidth(bin) * deta); + h->SetBinContent(bin, h->GetBinContent(bin) * normFactor); + h->SetBinError(bin, h->GetBinError(bin) * normFactor); + } +} + + +//____________________________________________________________________________________________________________________ +void setUpFitFunction(TF1* fitFunc, Int_t nBins, Bool_t noShift = kFALSE) +{ + fitFunc->SetLineColor(kGray + 1); + fitFunc->SetLineWidth(2); + fitFunc->SetLineStyle(1); + fitFunc->SetNpx(nBins * 100); + fitFunc->SetParName(0, "Pion fraction"); + fitFunc->SetParName(1, "Kaon fraction"); + fitFunc->SetParName(2, "Proton fraction"); + fitFunc->SetParName(3, "Electron fraction"); + fitFunc->SetParName(4, "Muon fraction"); + fitFunc->SetParName(5, "Total yield"); + if (noShift == kFALSE) { + fitFunc->SetParName(6, "Shift of pion peak"); + fitFunc->SetParName(7, "Shift of kaon peak"); + fitFunc->SetParName(8, "Shift of proton peak"); + fitFunc->SetParName(9, "Shift of electron peak"); + fitFunc->SetParName(10, "Shift of muon peak"); + } +} + + +//____________________________________________________________________________________________________________________ +inline Int_t findBinWithinRange(const TAxis* axis, Double_t value) +{ + Int_t bin = axis->FindFixBin(value); + if (bin <= 0) + bin = 1; + if (bin > axis->GetNbins()) + bin = axis->GetNbins(); + + return bin; +} + + +//____________________________________________________________________________________________________________________ +Double_t linearInterpolation(const TH1* h, Double_t x, Double_t scaleFactor, Double_t shift, Double_t* error) +{ + // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters. + // The shift also introduces some uncertainty, which is rather hard to estimate. Therefore, just take the maximum error of the involved bins. + const Double_t xShifted = x - shift; + + // Just take value of bin, if beyond center of first/last bin + if (xShifted <= h->GetBinCenter(1)) { + if (error) + *error = h->GetBinError(1) * scaleFactor; + return h->GetBinContent(1) * scaleFactor; + } + else if(xShifted >= h->GetBinCenter(h->GetNbinsX())) { + if (error) + *error = h->GetBinError(h->GetNbinsX()) * scaleFactor; + return h->GetBinContent(h->GetNbinsX()) * scaleFactor; + } + else { + const Int_t xbin = h->FindFixBin(xShifted); + Double_t x0, x1, y0, y1; + + if(xShifted <= h->GetBinCenter(xbin)) { + y0 = h->GetBinContent(xbin - 1); + x0 = h->GetBinCenter(xbin - 1); + y1 = h->GetBinContent(xbin); + x1 = h->GetBinCenter(xbin); + + if (error) + *error = TMath::Max(h->GetBinError(xbin - 1), h->GetBinError(xbin)) * scaleFactor; + } + else { + y0 = h->GetBinContent(xbin); + x0 = h->GetBinCenter(xbin); + y1 = h->GetBinContent(xbin + 1); + x1 = h->GetBinCenter(xbin + 1); + + if (error) + *error = TMath::Max(h->GetBinError(xbin), h->GetBinError(xbin + 1)) * scaleFactor; + } + + return scaleFactor * (y0 + (xShifted - x0) * ((y1 - y0) / (x1 - x0))); + } + + return 0; + + /*Old version available for code bevor 03.05.2013*/ +} + + +//____________________________________________________________________________________________________________________ +void shiftHist(TH1D* h, Double_t shift, Bool_t useRegularisation = kFALSE) +{ + // Shift not available for regularisation. Just for convenience (can use the same code and only set one flag) + // call this functions and then do nothing. + // Actually, the shift is not availabe for simultaneous fitting also, but the parameter is just set to 0 there + if (!h || useRegularisation) + return; + + TString name = h->GetName(); + TH1D* hTemp = (TH1D*)h->Clone(Form("%s_clone", name.Data())); + h->Reset(); + + Double_t error = 0; + for (Int_t i = 1; i <= h->GetNbinsX(); i++) { + // linearInterpolation with scaleFactor = 1.0, since histo is assumed to be properly scaled + h->SetBinContent(i, linearInterpolation(hTemp, h->GetXaxis()->GetBinCenter(i), 1.0, shift, &error)); + h->SetBinError(i, error); + } + + delete hTemp; +} + + +//____________________________________________________________________________________________________________________ +Double_t multiGaussFitForSimultaneousFitting(const Double_t *xx, const Double_t *par, const Int_t offset) +{ + // Offset for reference histos for delta_Species + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + // parXbinIndex (fixed) will be used my mathfit to hold the pT bin index (needed for regularisation) + const Int_t xBinIndex = mathFit->GetXbinIndex(); + const Int_t numParsPerXbin = mathFit->GetNumParametersPerXbin(); + + const Int_t numRefHistosPerFit = numSimultaneousFits + (takeIntoAccountMuons ? 1 : 0); + const Int_t numRefHistosPerXbin = numRefHistosPerFit * numSimultaneousFits; + + const Int_t refHistOffset = offset * numRefHistosPerFit + xBinIndex * numRefHistosPerXbin; + + const TH1* hRefPi = mathFit->GetRefHisto(0 + refHistOffset); + const TH1* hRefKa = mathFit->GetRefHisto(1 + refHistOffset); + const TH1* hRefPr = mathFit->GetRefHisto(2 + refHistOffset); + const TH1* hRefEl = mathFit->GetRefHisto(3 + refHistOffset); + const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4 + refHistOffset) : 0x0; + + if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) + return 0; + + if (takeIntoAccountMuons && !hRefMu) + return 0; + + const Int_t parOffset = xBinIndex * numParsPerXbin; + const Int_t parPi = 0 + parOffset; + const Int_t parKa = 1 + parOffset; + const Int_t parPr = 2 + parOffset; + const Int_t parEl = 3 + parOffset; + const Int_t parMu = 4 + parOffset; + const Int_t parAll = 5 + parOffset; + + const Double_t scaleFactorPi = par[parAll] * (par[parPi] + (muonContamination ? par[parEl] : 0)); + const Double_t scaleFactorKa = par[parAll] * par[parKa]; + const Double_t scaleFactorPr = par[parAll] * par[parPr]; + const Double_t parElFraction = (par[parEl] < 0) ? GetElectronFraction(-par[parEl], par) : par[parEl]; + const Double_t scaleFactorEl = par[parAll] * parElFraction; + // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 + const Double_t scaleFactorMu = (par[parMu] < 0) + ? (par[parAll] * GetMuonFractionFromElectronFractionAndPt(-par[parMu], parElFraction)) + : (par[parAll] * par[parMu]); + + // Since one is looking at the same deltaSpecies for all considered species, the reference histograms have the same axes + // => Only need to search for the bin once + const Int_t binWithinRange = findBinWithinRange(hRefPi->GetXaxis(), xx[0]); + const Double_t countPi = scaleFactorPi * hRefPi->GetBinContent(binWithinRange); + const Double_t countKa = scaleFactorKa * hRefKa->GetBinContent(binWithinRange); + const Double_t countPr = scaleFactorPr * hRefPr->GetBinContent(binWithinRange); + const Double_t countEl = scaleFactorEl * hRefEl->GetBinContent(binWithinRange); + const Double_t countMu = takeIntoAccountMuons ? scaleFactorMu * hRefMu->GetBinContent(binWithinRange) : 0; + + const Double_t res = countPi + countKa + countPr + countEl + countMu; + + + return res; +} + + +//____________________________________________________________________________________________________________________ +inline Double_t multiGaussFitDeltaPi(const Double_t *xx, const Double_t *par) +{ + return multiGaussFitForSimultaneousFitting(xx, par, 0); +} + +//____________________________________________________________________________________________________________________ +inline Double_t multiGaussFitDeltaKa(const Double_t *xx, const Double_t *par) +{ + return multiGaussFitForSimultaneousFitting(xx, par, 1); +} + +//____________________________________________________________________________________________________________________ +inline Double_t multiGaussFitDeltaPr(const Double_t *xx, const Double_t *par) +{ + return multiGaussFitForSimultaneousFitting(xx, par, 2); +} + +//____________________________________________________________________________________________________________________ +inline Double_t multiGaussFitDeltaEl(const Double_t *xx, const Double_t *par) +{ + return multiGaussFitForSimultaneousFitting(xx, par, 3); +} + + +//____________________________________________________________________________________________________________________ +Double_t multiGaussFit(const Double_t *xx, const Double_t *par) +{ + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + const TH1* hRefPi = mathFit->GetRefHisto(0); + const TH1* hRefKa = mathFit->GetRefHisto(1); + const TH1* hRefPr = mathFit->GetRefHisto(2); + const TH1* hRefEl = mathFit->GetRefHisto(3); + const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4) : 0x0; + + if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) + return 0; + + if (takeIntoAccountMuons && !hRefMu) + return 0; + + // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters + const Double_t scaleFactorPi = par[5] * (par[0] + (muonContamination ? par[3] : 0)); + const Double_t scaleFactorKa = par[5] * par[1]; + const Double_t scaleFactorPr = par[5] * par[2]; + const Double_t parElFraction = (par[3] < 0) ? GetElectronFraction(-par[3], par) : par[3]; + const Double_t scaleFactorEl = par[5] * parElFraction; + // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 + const Double_t scaleFactorMu = (par[4] < 0) + ? (par[5] * GetMuonFractionFromElectronFractionAndPt(-par[4], parElFraction)) + : (par[5] * par[4]); + + const Double_t countPi = linearInterpolation(hRefPi, xx[0], scaleFactorPi, par[6], 0x0); + const Double_t countKa = linearInterpolation(hRefKa, xx[0], scaleFactorKa, par[7], 0x0); + const Double_t countPr = linearInterpolation(hRefPr, xx[0], scaleFactorPr, par[8], 0x0); + const Double_t countEl = linearInterpolation(hRefEl, xx[0], scaleFactorEl, par[9], 0x0); + const Double_t countMu = takeIntoAccountMuons ? linearInterpolation(hRefMu, xx[0], scaleFactorMu, par[10], 0x0) : 0; + + const Double_t res = countPi + countKa + countPr + countEl + countMu; + + /* + const Double_t countPi = linearInterpolation(hRefPi, xx[0], par[6], 0x0); + const Double_t countKa = linearInterpolation(hRefKa, xx[0], par[7], 0x0); + const Double_t countPr = linearInterpolation(hRefPr, xx[0], par[8], 0x0); + const Double_t countEl = linearInterpolation(hRefEl, xx[0], par[9], 0x0); + const Double_t countMu = takeIntoAccountMuons ? linearInterpolation(hRefMu, xx[0], par[10], 0x0) : 0; + + const Double_t res = par[5] * ((par[0] + (muonContamination ? par[3] : 0)) * countPi + par[1] * countKa + + par[2] * countPr + par[3] * countEl + par[4] * countMu); + + */ + + return res; +} + + +//____________________________________________________________________________________________________________________ +Double_t errorOfFitHistosForSimultaneousFitting(const Double_t *xx, const Double_t *par, const Int_t offset) +{ + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + Double_t summedError = 0; + + // parXbinIndex (fixed) will be used my mathfit to hold the pT bin index (needed for regularisation) + const Int_t xBinIndex = mathFit->GetXbinIndex(); + const Int_t numParsPerXbin = mathFit->GetNumParametersPerXbin(); + + const Int_t numRefHistosPerFit = numSimultaneousFits + (takeIntoAccountMuons ? 1 : 0); + const Int_t numRefHistosPerXbin = numRefHistosPerFit * numSimultaneousFits; + + const Int_t refHistOffset = offset * numRefHistosPerFit + xBinIndex * numRefHistosPerXbin; + + const TH1* hRefPi = mathFit->GetRefHisto(0 + refHistOffset); + const TH1* hRefKa = mathFit->GetRefHisto(1 + refHistOffset); + const TH1* hRefPr = mathFit->GetRefHisto(2 + refHistOffset); + const TH1* hRefEl = mathFit->GetRefHisto(3 + refHistOffset); + const TH1* hRefMu = takeIntoAccountMuons ? + mathFit->GetRefHisto(4 + refHistOffset) + : 0x0; + + if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) + return 0; + + if (takeIntoAccountMuons && !hRefMu) + return 0; + + const Int_t parOffset = xBinIndex * numParsPerXbin; + const Int_t parPi = 0 + parOffset; + const Int_t parKa = 1 + parOffset; + const Int_t parPr = 2 + parOffset; + const Int_t parEl = 3 + parOffset; + const Int_t parMu = 4 + parOffset; + const Int_t parAll = 5 + parOffset; + + const Double_t scaleFactorPi = par[parAll] * (par[parPi] + (muonContamination ? par[parEl] : 0)); + const Double_t scaleFactorKa = par[parAll] * par[parKa]; + const Double_t scaleFactorPr = par[parAll] * par[parPr]; + const Double_t scaleFactorEl = par[parAll] * ((par[parEl] < 0) ? GetElectronFraction(-par[parEl], par) : par[parEl]); + // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 + const Double_t scaleFactorMu = (par[parMu] < 0) ? + (scaleFactorEl * GetMuonFractionFromElectronFractionAndPt(-par[parMu], par[parEl]) / par[parEl]) + : (par[parAll] * par[parMu]); + + Double_t errorPi = 0, errorKa = 0, errorPr = 0, errorEl = 0, errorMu = 0; + + // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters + // Shift not implemented for simultaneous fit -> Just set all corresponding parameters to zero + linearInterpolation(hRefPi, xx[0], scaleFactorPi, 0, &errorPi); + linearInterpolation(hRefKa, xx[0], scaleFactorKa, 0, &errorKa); + linearInterpolation(hRefPr, xx[0], scaleFactorPr, 0, &errorPr); + linearInterpolation(hRefEl, xx[0], scaleFactorEl, 0, &errorEl); + if (takeIntoAccountMuons) + linearInterpolation(hRefMu, xx[0], scaleFactorMu, 0, &errorMu); + + summedError += TMath::Power(errorPi, 2); + summedError += TMath::Power(errorKa, 2); + summedError += TMath::Power(errorPr, 2); + summedError += TMath::Power(errorEl, 2); + if (takeIntoAccountMuons) + summedError += TMath::Power(errorMu, 2); + + return summedError; +} + + +//____________________________________________________________________________________________________________________ +inline Double_t errorOfFitHistosDeltaPi(const Double_t *xx, const Double_t *par) +{ + return errorOfFitHistosForSimultaneousFitting(xx, par, 0); +} + + +//____________________________________________________________________________________________________________________ +inline Double_t errorOfFitHistosDeltaKa(const Double_t *xx, const Double_t *par) +{ + return errorOfFitHistosForSimultaneousFitting(xx, par, 1); +} + + +//____________________________________________________________________________________________________________________ +inline Double_t errorOfFitHistosDeltaPr(const Double_t *xx, const Double_t *par) +{ + return errorOfFitHistosForSimultaneousFitting(xx, par, 2); +} + + +//____________________________________________________________________________________________________________________ +inline Double_t errorOfFitHistosDeltaEl(const Double_t *xx, const Double_t *par) +{ + return errorOfFitHistosForSimultaneousFitting(xx, par, 3); +} + + +//____________________________________________________________________________________________________________________ +Double_t errorOfFitHistos(const Double_t *xx, const Double_t *par) +{ + //TODO Error of shift is still not taken into account + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + Double_t summedError = 0; + + const TH1* hRefPi = mathFit->GetRefHisto(0); + const TH1* hRefKa = mathFit->GetRefHisto(1); + const TH1* hRefPr = mathFit->GetRefHisto(2); + const TH1* hRefEl = mathFit->GetRefHisto(3); + const TH1* hRefMu = takeIntoAccountMuons ? mathFit->GetRefHisto(4) : 0x0; + + if (!hRefEl || !hRefKa || !hRefPi || !hRefPr) + return 0; + + if (takeIntoAccountMuons && !hRefMu) + return 0; + + // Do linear interpolation between 2 bins to handle non-integer values of the shift parameters + const Double_t scaleFactorPi = par[5] * (par[0] + (muonContamination ? par[3] : 0)); + const Double_t scaleFactorKa = par[5] * par[1]; + const Double_t scaleFactorPr = par[5] * par[2]; + const Double_t scaleFactorEl = par[5] * ((par[3] < 0) ? GetElectronFraction(-par[3], par) : par[3]); + // Fix muon fraction to electron fraction (or some modified electron fraction) if desired, i.e. corresponding par < 0 + const Double_t scaleFactorMu = (par[4] < 0) ? (scaleFactorEl * GetMuonFractionFromElectronFractionAndPt(-par[4], par[3]) / par[3]) + : (par[5] * par[4]); + + Double_t errorPi = 0, errorKa = 0, errorPr = 0, errorEl = 0, errorMu = 0; + + linearInterpolation(hRefPi, xx[0], scaleFactorPi, par[6], &errorPi); + linearInterpolation(hRefKa, xx[0], scaleFactorKa, par[7], &errorKa); + linearInterpolation(hRefPr, xx[0], scaleFactorPr, par[8], &errorPr); + linearInterpolation(hRefEl, xx[0], scaleFactorEl, par[9], &errorEl); + if (takeIntoAccountMuons) + linearInterpolation(hRefMu, xx[0], scaleFactorMu, par[10], &errorMu); // Assume same fraction as electron, i.e. same scale factor + + summedError += TMath::Power(errorPi, 2); + summedError += TMath::Power(errorKa, 2); + summedError += TMath::Power(errorPr, 2); + summedError += TMath::Power(errorEl, 2); + if (takeIntoAccountMuons) + summedError += TMath::Power(errorMu, 2); + + + /* + for (Int_t index = 0; index < mathFit->GetNrefHistos(); index++) { + TH1* HREF = mathFit->GetRefHisto(index); + Int_t bin = findBinWithinRange(HREF->GetXaxis(), xx[0]); + summedError += TMath::Power(HREF->GetBinError(bin) * par[index] * par[mathFit->GetNrefHistos()], 2); + } + */ + return summedError; +} + + +//____________________________________________________________________________________________________________________ +inline Double_t saveDivide(Double_t numerator, Double_t denominator) +{ + return ((denominator != 0) ? numerator/denominator : 0 ); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfPionIntegral(TMatrixDSym covMat) +{ + return TMath::Sqrt(covMat(0, 0) + covMat(12, 12) + 2 * covMat(0, 12)); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfElectronFraction(Double_t* par, TMatrixDSym covMat) +{ + Double_t g = saveDivide(par[3], (par[0] + par[1] + par[2] + 2 * par[3])); + Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); + Double_t s2 = TMath::Power(g, 2) * covMat(3, 3); + Double_t s3 = (4 * TMath::Power(g, 4) - 2 * TMath::Power(g, 3)) * (covMat(3, 2) + covMat(3, 1) + covMat(3, 0)); + Double_t s4 = TMath::Power(g, 4) * 2 * (covMat(2, 1) + covMat(2, 0) +covMat(1, 0)); + + return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[3]); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfKaonFraction(Double_t* par, TMatrixDSym covMat) +{ + Double_t g = saveDivide(par[1], (par[0] + par[1] + par[2] + 2 * par[3])); + Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); + Double_t s2 = TMath::Power(g, 2) * covMat(1, 1); + Double_t s3 = TMath::Power(g, 4) * (4 * covMat(3, 0) + 4 * covMat(3, 2) + 4 * covMat(3, 1) + + 2 * covMat(2, 1) + 2 * covMat(2, 0) + 2 * covMat(1, 0)); + Double_t s4 = TMath::Power(g, 3) * ((-4) * covMat(3, 1) - 2 * covMat(2, 1) - 2 * covMat(1, 0)); + + return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[1]); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfPionFraction(Double_t* par, TMatrixDSym covMat) +{ + Double_t g = saveDivide(par[0] + par[3], (par[0] + par[1] + par[2] + 2 * par[3])); + Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); + Double_t s2 = TMath::Power(g, 2) * (covMat(0, 0) + covMat(3, 3)); + Double_t s3 = TMath::Power(g, 4) * 2 * covMat(2, 1); + Double_t s4 = (4 * TMath::Power(g, 4) - 2 * TMath::Power(g, 3)) * (covMat(3, 2) + covMat(3, 1)); + Double_t s5 = 2 * covMat(3, 0) * (2 * TMath::Power(g, 4) - 3 * TMath::Power(g, 3) + TMath::Power(g, 2)); + Double_t s6 = 2 * (covMat(2, 0) + covMat(1, 0)) * (TMath::Power(g, 4) - TMath::Power(g, 3)); + + return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4 + s5 + s6), par[0] + par[3]); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfProtonFraction(Double_t* par, TMatrixDSym covMat) +{ + Double_t g = saveDivide(par[2], (par[0] + par[2] + par[1] + 2 * par[3])); + Double_t s1 = TMath::Power(g, 4) * (covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3)); + Double_t s2 = TMath::Power(g, 2) * covMat(2, 2); + Double_t s3 = TMath::Power(g, 4) * (4 * covMat(3, 0) + 4 * covMat(3, 2) + 4 * covMat(3, 1) + + 2 * covMat(2, 1) + 2 * covMat(2, 0) + 2 * covMat(1, 0)); + Double_t s4 = TMath::Power(g, 3) * ((-4) * covMat(3, 2) - 2 * covMat(2, 1) - 2 * covMat(2, 0)); + + return saveDivide(TMath::Sqrt(s1 + s2 + s3 + s4), par[2]); +} + + +//____________________________________________________________________________________________________________________ +Double_t getErrorOfTotalIntegral(TMatrixDSym covMat) +{ + Double_t s1 = covMat(0, 0) + covMat(1, 1) + covMat(2, 2) + 4 * covMat(3, 3); + Double_t s2 = 4 * (covMat(3, 0) + covMat(3, 1) + covMat(3, 2)); + Double_t s3 = 2 * (covMat(2, 1) + covMat(2, 0) + covMat(1, 0)); + + return TMath::Sqrt(s1 + s2 + s3); +} + + +//____________________________________________________________________________________________________________________ +Double_t getMedianOfNonZeros(Double_t input[4]) +{ + Double_t values[4] = {0,0,0,0}; + Int_t numNonZero = 0; + if (input[0] > 0) { + values[numNonZero] = input[0]; + numNonZero++; + } + if (input[1] > 0) { + values[numNonZero] = input[1]; + numNonZero++; + } + if (input[2] > 0) { + values[numNonZero] = input[2]; + numNonZero++; + } + if (input[3] > 0) { + values[numNonZero] = input[3]; + numNonZero++; + } + + return ((numNonZero > 0) ? TMath::Median(numNonZero, values) : 0); +} + + +//____________________________________________________________________________________________________________________ +TCanvas* drawFractionHistos(TString canvName, TString canvTitle, Int_t mode, Double_t pLow, Double_t pHigh, + TH1* histDeltaPion, TH1* histDeltaElectron, TH1* histDeltaKaon, TH1* histDeltaProton, TH1* histMC, + Bool_t plotIdentifiedSpectra) +{ + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridx(1); + canv->SetGridy(1); + canv->SetLogx(mode == kPMpT); + histDeltaPion->GetYaxis()->SetRangeUser(0.0, 1.0); + histDeltaPion->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaPion->GetXaxis(), mode, pLow, pHigh); + histDeltaPion->SetMarkerStyle(20); + histDeltaPion->GetXaxis()->SetMoreLogLabels(kTRUE); + histDeltaPion->GetXaxis()->SetNoExponent(kTRUE); + histDeltaPion->Draw("e p"); + histDeltaElectron->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaElectron->GetXaxis(), mode, pLow, pHigh); + histDeltaElectron->SetMarkerStyle(21); + histDeltaElectron->Draw("e p same"); + histDeltaKaon->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaKaon->GetXaxis(), mode, pLow, pHigh); + histDeltaKaon->SetMarkerStyle(22); + histDeltaKaon->Draw("e p same"); + histDeltaProton->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaProton->GetXaxis(), mode, pLow, pHigh); + histDeltaProton->SetMarkerStyle(29); + histDeltaProton->Draw("e p same"); + if (plotIdentifiedSpectra) { + histMC->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histMC->GetXaxis(), mode, pLow, pHigh); + histMC->SetMarkerStyle(24); + histMC->Draw("e p same"); + } + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + legend->AddEntry(histDeltaPion, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{#pi}}" : "_{#pi}"), "p"); + legend->AddEntry(histDeltaElectron, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{e}}" : "_{e}"), "p"); + legend->AddEntry(histDeltaKaon, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{K}}" : "_{K}"), "p"); + legend->AddEntry(histDeltaProton, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{p}}" : "_{p}"), "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(histMC, identifiedLabels[isMC].Data(), "p"); + legend->SetEntrySeparation(0.2); + legend->Draw(); + + ClearTitleFromHistoInCanvas(canv); + + return canv; +} + + +//____________________________________________________________________________________________________________________ +TCanvas* drawYieldHistos(TString canvName, TString canvTitle, Int_t mode, Double_t pLow, Double_t pHigh, + TH1* histDeltaPion, TH1* histDeltaElectron, TH1* histDeltaKaon, TH1* histDeltaProton, TH1* histMC, + Bool_t plotIdentifiedSpectra) +{ + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridx(1); + canv->SetGridy(1); + canv->SetLogx(mode == kPMpT); + canv->SetLogy(1); + histDeltaPion->GetYaxis()->SetRangeUser(histDeltaPion->GetBinContent(histDeltaPion->FindLastBinAbove(0.)) / 10., + histDeltaPion->GetBinContent(histDeltaPion->GetMaximumBin()) * 10.); + histDeltaPion->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaPion->GetXaxis(), mode, pLow, pHigh); + histDeltaPion->SetMarkerStyle(20); + histDeltaPion->GetXaxis()->SetMoreLogLabels(kTRUE); + histDeltaPion->GetXaxis()->SetNoExponent(kTRUE); + histDeltaPion->Draw("e p"); + histDeltaElectron->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaElectron->GetXaxis(), mode, pLow, pHigh); + histDeltaElectron->SetMarkerStyle(21); + histDeltaElectron->Draw("e p same"); + histDeltaKaon->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaKaon->GetXaxis(), mode, pLow, pHigh); + histDeltaKaon->SetMarkerStyle(22); + histDeltaKaon->Draw("e p same"); + histDeltaProton->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histDeltaProton->GetXaxis(), mode, pLow, pHigh); + histDeltaProton->SetMarkerStyle(29); + histDeltaProton->Draw("e p same"); + if (plotIdentifiedSpectra) { + histMC->GetYaxis()->SetTitle(canvTitle.Data()); + SetReasonableAxisRange(histMC->GetXaxis(), mode, pLow, pHigh); + histMC->SetMarkerStyle(24); + histMC->Draw("e p same"); + } + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + + legend->AddEntry(histDeltaPion, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{#pi}}" : "_{#pi}"), "p"); + legend->AddEntry(histDeltaElectron, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{e}}" : "_{e}"), "p"); + legend->AddEntry(histDeltaKaon, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{K}}" : "_{K}"), "p"); + legend->AddEntry(histDeltaProton, Form("#Delta%s", useDeltaPrime ? "'_{#lower[-0.5]{p}}" : "_{p}"), "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(histMC, identifiedLabels[isMC].Data(), "p"); + legend->SetEntrySeparation(0.2); + legend->Draw(); + + ClearTitleFromHistoInCanvas(canv); + + return canv; +} + + +//____________________________________________________________________________________________________________________ +Int_t doSimultaneousFitRegularised(Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, Double_t* covMatrix, + Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, Double_t& reducedChiSquare) +{ + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + Double_t chiSquare = -999; + Int_t ndf = -1; + + AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; + multiGaussFitArray[0] = multiGaussFitDeltaPi; + multiGaussFitArray[1] = multiGaussFitDeltaKa; + multiGaussFitArray[2] = multiGaussFitDeltaPr; + multiGaussFitArray[3] = multiGaussFitDeltaEl; + + AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; + errorOfFitHistosArray[0] = errorOfFitHistosDeltaPi; + errorOfFitHistosArray[1] = errorOfFitHistosDeltaKa; + errorOfFitHistosArray[2] = errorOfFitHistosDeltaPr; + errorOfFitHistosArray[3] = errorOfFitHistosDeltaEl; + + //TODO errorFunction for bin errors of fit histos? + Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, + chiSquare, ndf, stepSize, lowParLimits, upParLimits); + //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, + // chiSquare, ndf, stepSize, lowParLimits, upParLimits); + + std::cout << std::endl; + + for (Int_t xBin = 0; xBin < mathFit->GetNumXbinsRegularisation(); xBin++) { + std::cout << "x bin " << xBin << ":" << std::endl; + + Double_t sumFractions = 0; + + for (Int_t parIndex = xBin * mathFit->GetNumParametersPerXbin(); parIndex < (xBin + 1) * mathFit->GetNumParametersPerXbin(); + parIndex++) { + Int_t parIndexModulo = parIndex % mathFit->GetNumParametersPerXbin(); + + // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so + // the error from the matrix would be zero. + // parIndexModulo = 4 means muons, parIndexModulo = 3 means electrons, i.e. if parIndexModulo corresponds to muons, + // then parIndexModulo - 1 corresponds to electrons. + + // Set electron fraction to value evaluated from a function above some threshold. + // Fixed electron fraction < 0 does this job within the fitting functions + if (parIndexModulo == 3 && gausParams[parIndex] < 0) { + gausParams[parIndex] = GetElectronFraction(-gausParams[parIndex], &gausParams[0]); + parameterErrorsOut[parIndex] = GetElectronFractionError(); + } + // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, + // which should be a reasonable approximation: + // Fixed muon fraction < 0 does this job within the fitting functions + else if (parIndexModulo == 4 && gausParams[parIndex] < 0) { + gausParams[parIndex] = GetMuonFractionFromElectronFractionAndPt(-gausParams[parIndex], gausParams[parIndex - 1]); + parameterErrorsOut[parIndex] = parameterErrorsOut[parIndex - 1]; + } + + + std::cout << "par[" << parIndex << "]: " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; + + if (parIndexModulo <= 3 || ((muonContamination || takeIntoAccountMuons) && parIndexModulo == 4)) + sumFractions += gausParams[parIndex]; + } + + std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " + << sumFractions; std::cout << std::endl; + std::cout << std::endl << std::endl; + } + + if (errFlag == 0) + std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; + else + std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; + + reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; + + return errFlag; +} + + +//____________________________________________________________________________________________________________________ +Int_t doSimultaneousFit(TH1D** hDelta, Double_t xLow, Double_t xUp, Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, + Double_t* covMatrix, Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, Double_t& + reducedChiSquare) +{ + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + Double_t chiSquare = -999; + Int_t ndf = -1; + + //TODO: + // Using no error on x (next TODO line) and no errorFunction (next after next TODO line) sometimes gives good results. + // However, it can completely fail for low statistics for the fit histos. + // Using either an error on x or the errorFunction both gives reasonable results, but might be slightly worse results in some cases + // (shifted/distorted data). Maybe: Choose one method - the rest is for systematic errors of this fitting + + //TODO The next TODO marks are only relevant for chiSquare, but not for loglikelihood + //TODO Use error in x also -> If reference histos have low statistics, this will be very important + + for (Int_t i = 0; i < numSimultaneousFits; i++) { + mathFit->InputData(hDelta[i], 0, i, xLow, xUp, -1., kFALSE); + //mathFit->InputData(hDelta[i], 0, i, xLow, xUp, -1., kTRUE); + } + + AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; + multiGaussFitArray[0] = multiGaussFitDeltaPi; + multiGaussFitArray[1] = multiGaussFitDeltaKa; + multiGaussFitArray[2] = multiGaussFitDeltaPr; + multiGaussFitArray[3] = multiGaussFitDeltaEl; + + AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[numSimultaneousFits]; + errorOfFitHistosArray[0] = errorOfFitHistosDeltaPi; + errorOfFitHistosArray[1] = errorOfFitHistosDeltaKa; + errorOfFitHistosArray[2] = errorOfFitHistosDeltaPr; + errorOfFitHistosArray[3] = errorOfFitHistosDeltaEl; + + //TODO errorFunction for bin errors of fit histos? + Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, + chiSquare, ndf, stepSize, lowParLimits, upParLimits); + //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, + // chiSquare, ndf, stepSize, lowParLimits, upParLimits); + + std::cout << std::endl; + + // If the electron fraction is fixed, evaluate the error of the extrapolation of the fixed value + if (TMath::Abs(lowParLimits[3] - upParLimits[3]) < epsilon) { + // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so + // the error from the matrix would be zero + parameterErrorsOut[3] = GetElectronFractionError(); + } + + // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, + // which should be a reasonable approximation: + // Fixed muon fraction < 0 does this job within the fitting functions + if (gausParams[4] < 0 ) { + // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so + // the error from the matrix would be zero + gausParams[4] = GetMuonFractionFromElectronFractionAndPt(-gausParams[4], gausParams[3]); + parameterErrorsOut[4] = parameterErrorsOut[3]; + } + + Double_t sumFractions = 0; + for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { + std::cout << "par[" << parIndex << "]: " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; + } + sumFractions = gausParams[0] + gausParams[1] + gausParams[2] + gausParams[3]; + // In case of muon contamination add muon fraction also + if (muonContamination || takeIntoAccountMuons) { + sumFractions += gausParams[4]; + } + + std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " << sumFractions; std::cout << std::endl; + + if (errFlag == 0) + std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; + else + std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; + + reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; + + return errFlag; +} + + +//____________________________________________________________________________________________________________________ +Int_t doFit(TH1D* hDelta, Double_t xLow, Double_t xUp, Int_t nPar, Double_t* gausParams, Double_t* parameterErrorsOut, Double_t* covMatrix, + Double_t* stepSize, Double_t* lowParLimits, Double_t* upParLimits, TF1* totalDeltaSpecies, Double_t& reducedChiSquare) +{ + AliTPCPIDmathFit* mathFit = AliTPCPIDmathFit::Instance(); + + Double_t chiSquare = -999; + Int_t ndf = -1; + + //TODO: + // Using no error on x (next TODO line) and no errorFunction (next after next TODO line) sometimes gives good results. + // However, it can completely fail for low statistics for the fit histos. + // Using either an error on x or the errorFunction both gives reasonable results, but might be slightly worse results in some cases + // (shifted/distorted data). Maybe: Choose one method - the rest is for systematic errors of this fitting + + //TODO The next TODO marks are only relevant for chiSquare, but not for loglikelihood + //TODO Use error in x also -> If reference histos have low statistics, this will be very important + mathFit->InputData(hDelta, 0, 0, xLow, xUp, -1., kFALSE); + //mathFit->InputData(hDelta, 0, 0, xLow, xUp, -1., kTRUE); + + AliTPCPIDmathFit::FitFunc_t* multiGaussFitArray = new AliTPCPIDmathFit::FitFunc_t[1]; + multiGaussFitArray[0] = multiGaussFit; + + AliTPCPIDmathFit::FitFunc_t* errorOfFitHistosArray = new AliTPCPIDmathFit::FitFunc_t[1]; + errorOfFitHistosArray[0] = errorOfFitHistos; + + //TODO errorFunction for bin errors of fit histos? + Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, 0x0, nPar, gausParams, parameterErrorsOut, covMatrix, + chiSquare, ndf, stepSize, lowParLimits, upParLimits); + //Int_t errFlag = mathFit->MinuitFit(multiGaussFitArray, errorOfFitHistosArray, nPar, gausParams, parameterErrorsOut, covMatrix, + // chiSquare, ndf, stepSize, lowParLimits, upParLimits); + + // If the electron fraction is fixed, evaluate the error of the extrapolation of the fixed value + if (TMath::Abs(lowParLimits[3] - upParLimits[3]) < epsilon) { + // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so + // the error from the matrix would be zero + parameterErrorsOut[3] = GetElectronFractionError(); + } + + // Set muon fraction equal to electron fraction (or some modified electron fraction) above some threshold, which should be a reasonable approximation: + // Fixed muon fraction < 0 does this job within the fitting functions + if (gausParams[4] < 0 ) { + // NOTE: Covariance matrix is NOT set. But this doesn't matter since the parameter is fixed anyway, so + // the error from the matrix would be zero + gausParams[4] = GetMuonFractionFromElectronFractionAndPt(-gausParams[4], gausParams[3]); + parameterErrorsOut[4] = parameterErrorsOut[3]; + } + + Double_t sumFractions = 0; + for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { + std::cout << totalDeltaSpecies->GetParName(parIndex) << ": " << gausParams[parIndex] << " +- " << parameterErrorsOut[parIndex] << std::endl; + } + sumFractions = gausParams[0] + gausParams[1] + gausParams[2] + gausParams[3]; + // In case of muon contamination add muon fraction also + if (muonContamination || takeIntoAccountMuons) { + sumFractions += gausParams[4]; + } + + std::cout << "Sum of fractions" << (muonContamination || takeIntoAccountMuons ? "(including muon contamination)" : "") << ": " << sumFractions; + std::cout << std::endl; + + if (errFlag == 0) + std::cout << std::endl << "***Fit operation completed successfully***" << std::endl << std::endl; + else + std::cout << std::endl << "***Fit operation completed, but with errors***" << std::endl << std::endl; + + for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { + totalDeltaSpecies->SetParameter(parIndex, gausParams[parIndex]); + totalDeltaSpecies->SetParError(parIndex, parameterErrorsOut[parIndex]); + } + + reducedChiSquare = (ndf > 0) ? chiSquare / ndf : -1; + + return errFlag; +} + + +//____________________________________________________________________________________________________________________ +Double_t setFractionsAndYields(Int_t slice, Double_t inverseBinWidth, Double_t binWidthFitHisto, Int_t species, Double_t* parametersOut, + Double_t* parameterErrorsOut, TH1* hFractionSpecies, TH1* hFractionPionsDeltaSpecies, + TH1* hFractionElectronsDeltaSpecies, TH1* hFractionKaonsDeltaSpecies, TH1* hFractionProtonsDeltaSpecies, + TH1* hFractionMuonsDeltaSpecies, TH1* hYieldSpecies, TH1* hYieldPionsDeltaSpecies, + TH1* hYieldElectronsDeltaSpecies, TH1* hYieldKaonsDeltaSpecies, TH1* hYieldProtonsDeltaSpecies, + TH1* hYieldMuonsDeltaSpecies, + Bool_t normaliseFractions = kFALSE) +{ + // Set fraction and yields in corresponding histograms. If normaliseFractions is kTRUE, the fractions will be normalised to unity + // and the normalisation factor will be returned (i.e. 1./sumFraction) + + Double_t normalisationFactor = 1.0; + + // Since a log likelihood fit is anyway used, the normalisation should give a factor close to unity + if (normaliseFractions) { + Double_t sumFractions = parametersOut[0] + (muonContamination ? parametersOut[3] : 0) + parametersOut[1] + parametersOut[2] + + parametersOut[3] + (takeIntoAccountMuons ? parametersOut[4] : 0.); + if (sumFractions > 0) { + normalisationFactor = 1./sumFractions; + for (Int_t i = 0; i < 5; i++) { + parametersOut[i] *= normalisationFactor; + + // Do not introduce an error for the normalisation, i.e. just scale parameters and fractions with the same factor which is + // assumed to be exact. + // Note that correlations should already be included in the parameterError + parameterErrorsOut[i] *= normalisationFactor; + } + } + } + + Double_t sumOfParticles = inverseBinWidth * parametersOut[5] / binWidthFitHisto; // Divide by binWidthFitHisto since parametersOut includes this width + + if (species == kPi) { + hFractionSpecies->SetBinContent(slice + 1, (parametersOut[0]+(muonContamination ? parametersOut[3] : 0))); + hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[0]); + } + else if (species == kEl) { + hFractionSpecies->SetBinContent(slice + 1, parametersOut[3]); + hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[3]); + } + else if (species == kKa) { + hFractionSpecies->SetBinContent(slice + 1, parametersOut[1]); + hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[1]); + } + else if (species == kPr) { + hFractionSpecies->SetBinContent(slice + 1, parametersOut[2]); + hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[2]); + } + else if (species == kMu) { + if (takeIntoAccountMuons) { + hFractionSpecies->SetBinContent(slice + 1, parametersOut[4]); + hFractionSpecies->SetBinError(slice + 1, parameterErrorsOut[4]); + + hYieldSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionSpecies->GetBinContent(slice + 1)); + hYieldSpecies->SetBinError(slice + 1, sumOfParticles * hFractionSpecies->GetBinError(slice + 1)); + } + + // Only set these histos for muons. The DeltaSpecies histos for muons will be set together with all other species + return normalisationFactor; + } + + hFractionPionsDeltaSpecies->SetBinContent(slice + 1, (parametersOut[0]+(muonContamination ? parametersOut[3] : 0))); + hFractionPionsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[0]);//TODO What about error of parOut[3]? + hFractionElectronsDeltaSpecies->SetBinContent(slice + 1, parametersOut[3]); + hFractionElectronsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[3]); + hFractionKaonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[1]); + hFractionKaonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[1]); + hFractionProtonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[2]); + hFractionProtonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[2]); + if (takeIntoAccountMuons) { + hFractionMuonsDeltaSpecies->SetBinContent(slice + 1, parametersOut[4]); + hFractionMuonsDeltaSpecies->SetBinError(slice + 1, parameterErrorsOut[4]); + } + + hYieldSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionSpecies->GetBinContent(slice + 1)); + hYieldSpecies->SetBinError(slice + 1, sumOfParticles * hFractionSpecies->GetBinError(slice + 1)); + + hYieldPionsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaSpecies->GetBinContent(slice + 1)); + hYieldPionsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaSpecies->GetBinError(slice + 1)); + hYieldElectronsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaSpecies->GetBinContent(slice + 1)); + hYieldElectronsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaSpecies->GetBinError(slice + 1)); + hYieldKaonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaSpecies->GetBinContent(slice + 1)); + hYieldKaonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaSpecies->GetBinError(slice + 1)); + hYieldProtonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaSpecies->GetBinContent(slice + 1)); + hYieldProtonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaSpecies->GetBinError(slice + 1)); + if (takeIntoAccountMuons) { + hYieldMuonsDeltaSpecies->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaSpecies->GetBinContent(slice + 1)); + hYieldMuonsDeltaSpecies->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaSpecies->GetBinError(slice + 1)); + } + + return normalisationFactor; +} + +//____________________________________________________________________________________________________________________ +Int_t PID(TString fileName, Double_t deta, Double_t pLow, Double_t pHigh, Bool_t isMCdataSet, Int_t fitMethod, + Int_t muonFractionHandlingParameter, //0 = no muons, 1 = muonFrac=elFrac, + //2(3) = muonFrac/elFrac tuned on MC for StandardTrackCuts(HybridTrackCuts) + Bool_t useIdentifiedGeneratedSpectra, Bool_t plotIdentifiedSpectra, Int_t mode/*0=pT,1=z,2=xi*/, + Int_t chargeMode /*kNegCharge = -1, kAllCharged = 0, kPosCharge = 1*/, + Double_t lowerCentrality /*= -2*/, Double_t upperCentrality /*= -2*/, + Double_t lowerJetPt /*= -1*/ , Double_t upperJetPt/* = -1*/, + Int_t rebin/* = 1 -> DON'T USE FOR PT (will not work since binsPt will and should be used!)*/, + Int_t rebinDeltaPrime/* = 1*/, + TString listName /* = "bhess_PID"*/, + Bool_t useLogLikelihood /*= kTRUE*/, Bool_t useWeightsForLogLikelihood /*= kFALSE*/, + Int_t regularisation /*= 0*/, + Double_t regularisationFactor /*= 1*/, + TString filePathNameFileWithInititalFractions /*= ""*/, + TString* filePathNameResults /*= 0x0*/) +{ + // Do all the fitting + + isMC = isMCdataSet; + + muonFractionHandling = muonFractionHandlingParameter; + + Int_t genAxis = useDeltaPrime ? kPidGenDeltaPrime : 1000/*kPidGenDelta*/; + if (!useDeltaPrime) { + std::cout << "ERROR: delta plots no longer available!" << std::endl; + return -1; + } + + if (listName == "") { + listName = fileName; + listName.Replace(0, listName.Last('/') + 1, ""); + listName.ReplaceAll(".root", ""); + } + + + if (rebin > 1 && mode == kPMpT) { + std::cout << "ERROR: Requested re-binning of pT-axis! Since binsPt will be used, re-binning the data histo will lead to " + << "unforeseen consequences!" << std::endl; + return -1; + } + + Int_t pSliceLow = -1; + Int_t pSliceHigh = -1; + + Int_t axisForMode = kPidPt; + Int_t axisGenForMode = kPidGenPt; + + std::cout << "Fitting \"" << fileName.Data() << "\" with settings:" << std::endl; + + std::cout << "Minimisation strategy: " << minimisationStrategy.Data() << std::endl; + if (useLogLikelihood) + std::cout << "Binned loglikelihood fit" << (useWeightsForLogLikelihood ? " (weighted)" : "") << std::endl; + else + std::cout << "ChiSquare fit" << std::endl; + std::cout << "Processing mode: "; + if (mode == kPMpT) + std::cout << "pT" << std::endl; + else if (mode == kPMz) { + std::cout << "z" << std::endl; + axisForMode = kPidZ; + axisGenForMode = kPidGenZ; + } + else if (mode == kPMxi) { + std::cout << "xi" << std::endl; + axisForMode = kPidXi; + axisGenForMode = kPidGenXi; + } + else { + std::cout << "Unknown -> ERROR" << std::endl; + return -1; + } + + std::cout << "Charge selection: "; + if (chargeMode == kAllCharged) + std::cout << "All charged particles" << std::endl; + else if (chargeMode == kNegCharge) + std::cout << "Negative particles only" << std::endl; + else if (chargeMode == kPosCharge) + std::cout << "Positive particles only" << std::endl; + else { + std::cout << "Unknown -> ERROR" << std::endl; + return -1; + } + + const Bool_t restrictCharge = (chargeMode != kAllCharged); + + if (regularisation > 0) + std::cout << "Regularisation with +-" << regularisation << " bins and factor " << regularisationFactor << " for penalty term." + << std::endl; + else + std::cout << "No regularisation" << std::endl; + + std::cout << "Assumption on muon fraction: "; + if (muonFractionHandlingParameter >= 0 && muonFractionHandlingParameter < kNumHandlings) + std::cout << muonFractionHandlingShortName[muonFractionHandlingParameter].Data() << std::endl; + /*if (muonFractionHandlingParameter == kNoMuons) + std::cout << "Identical zero" << std::endl; + else if (muonFractionHandlingParameter == kMuonFracEqualElFrac) + std::cout << "Equal electron fraction" << std::endl; + else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCStandardTrackCuts) + std::cout << "Ratio to electron fraction tuned on MC for standard track cuts" << std::endl; + else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCuts) + std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts" << std::endl; + else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) + std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts for jet particles" << std::endl; + else if (muonFractionHandlingParameter == kMuonFracOverElFracTunedOnMCHybridTrackCutsJets) + std::cout << "Ratio to electron fraction tuned on MC for hybrid track cuts for jet particles" << std::endl;*/ + else { + std::cout << "Unknown -> ERROR" << std::endl; + return -1; + } + + if (mode == kPMpT) { + Int_t index = 0; + while (pLow >= binsPt[index] && index < nPtBins) + index++; + pSliceLow = index - 1; + + index = 0; + while (pHigh > binsPt[index] && index < nPtBins) + index++; + pSliceHigh = index - 1; + + Int_t numMomIntervals = pSliceHigh - pSliceLow + 1; + + if (numMomIntervals <= 0 || pSliceLow < 0 || pSliceHigh > nPtBins) { + std::cout << "Wrong choice of limits pLow/pHigh!" << std::endl; + return -1; + } + + pLow = binsPt[pSliceLow]; + pHigh = binsPt[pSliceHigh + 1]; // need upper edge, but binsPt holds lower edge + std::cout << "pLow/pHigh: "; + std::cout << pLow << " / " << pHigh << std::endl; + } + + Bool_t initialiseWithFractionsFromFile = kFALSE; + TFile* fInitialFractions = 0x0; + TH1 *hInitFracEl = 0x0, *hInitFracKa = 0x0, *hInitFracPi = 0x0, *hInitFracMu = 0x0, *hInitFracPr = 0x0; + + if (filePathNameFileWithInititalFractions != "") { + initialiseWithFractionsFromFile = kTRUE; + + std::cout << "Initialising fractions from file: " << filePathNameFileWithInititalFractions.Data() << std::endl; + } + else + std::cout << "Not initialising fractions from file" << std::endl; + + if (initialiseWithFractionsFromFile) { + fInitialFractions = TFile::Open(filePathNameFileWithInititalFractions.Data()); + if (!fInitialFractions) { + std::cout << std::endl; + std::cout << "Failed to open file with initial fractions \"" << filePathNameFileWithInititalFractions.Data() << "\"!" + << std::endl; + return -1; + } + + hInitFracEl = (TH1*)fInitialFractions->Get("hFractionElectrons"); + hInitFracKa = (TH1*)fInitialFractions->Get("hFractionKaons"); + hInitFracPi = (TH1*)fInitialFractions->Get("hFractionPions"); + hInitFracMu = (TH1*)fInitialFractions->Get("hFractionMuons"); + hInitFracPr = (TH1*)fInitialFractions->Get("hFractionProtons"); + + if (!hInitFracEl || ! hInitFracKa || ! hInitFracPi || ! hInitFracMu || ! hInitFracPr) { + std::cout << std::endl; + std::cout << "Failed to load initial fractions from file \"" << filePathNameFileWithInititalFractions.Data() << "\"!" + << std::endl; + + fInitialFractions->Close(); + return -1; + } + } + + + + TObjArray* histList = 0x0; + + TFile* f = TFile::Open(fileName.Data()); + if (!f) { + std::cout << std::endl; + std::cout << "Failed to open file \"" << fileName.Data() << "\"!" << std::endl; + return -1; + } + + //TString listName = fileName; + //listName = listName.ReplaceAll(".root", ""); + //listName = listName.Remove(1, listName.Last('/') + 1); + histList = (TObjArray*)(f->Get(listName.Data())); + if (!histList) { + std::cout << std::endl; + std::cout << "Failed to load list \"" << listName.Data() << "\"!" << std::endl; + return -1; + } + + // Extract the data histogram + THnSparse* hPIDdata = dynamic_cast(histList->FindObject("hPIDdataAll")); + if (!hPIDdata) { + std::cout << std::endl; + std::cout << "Failed to load data histo!" << std::endl; + return -1; + } + + // If desired, rebin considered axis + if (rebin > 1 || rebinDeltaPrime > 1) { + const Int_t nDimensions = hPIDdata->GetNdimensions(); + Int_t rebinFactor[nDimensions]; + + for (Int_t dim = 0; dim < nDimensions; dim++) { + if (dim == axisForMode && rebin > 1) + rebinFactor[dim] = rebin; + else if (dim == kPidDeltaPrime && rebinDeltaPrime > 1) + rebinFactor[dim] = rebinDeltaPrime; + else + rebinFactor[dim] = 1; + } + + THnSparse* temp = hPIDdata->Rebin(&rebinFactor[0]); + hPIDdata->Reset(); + hPIDdata = temp; + } + + // Set proper errors, if not yet calculated + if (!hPIDdata->GetCalculateErrors()) { + std::cout << "Re-calculating errors of " << hPIDdata->GetName() << "..." << std::endl; + hPIDdata->Sumw2(); + Long64_t nBinsTHnSparse = hPIDdata->GetNbins(); + Double_t binContent = 0; + + for (Long64_t bin = 0; bin < nBinsTHnSparse; bin++) { + binContent = hPIDdata->GetBinContent(bin); + hPIDdata->SetBinError(bin, TMath::Sqrt(binContent)); + } + } + + + // If desired, restrict centrality axis + Int_t lowerCentralityBinLimit = -1; + Int_t upperCentralityBinLimit = -1; + Bool_t restrictCentralityAxis = kFALSE; + Double_t actualLowerCentrality = -1.; + Double_t actualUpperCentrality = -1.; + + if (lowerCentrality >= -1 && upperCentrality >= -1) { + // Add subtract a very small number to avoid problems with values right on the border between to bins + lowerCentralityBinLimit = hPIDdata->GetAxis(kPidCentrality)->FindBin(lowerCentrality + 0.001); + upperCentralityBinLimit = hPIDdata->GetAxis(kPidCentrality)->FindBin(upperCentrality - 0.001); + + // Check if the values look reasonable + if (lowerCentralityBinLimit <= upperCentralityBinLimit && lowerCentralityBinLimit >= 1 + && upperCentralityBinLimit <= hPIDdata->GetAxis(kPidCentrality)->GetNbins()) { + actualLowerCentrality = hPIDdata->GetAxis(kPidCentrality)->GetBinLowEdge(lowerCentralityBinLimit); + actualUpperCentrality = hPIDdata->GetAxis(kPidCentrality)->GetBinUpEdge(upperCentralityBinLimit); + + restrictCentralityAxis = kTRUE; + } + else { + std::cout << std::endl; + std::cout << "Requested centrality range out of limits or upper and lower limit are switched!" << std::endl; + return -1; + } + } + + std::cout << "centrality: "; + if (restrictCentralityAxis) { + std::cout << actualLowerCentrality << " - " << actualUpperCentrality << std::endl; + } + else { + std::cout << "All" << std::endl; + } + + if (restrictCentralityAxis) { + hPIDdata->GetAxis(kPidCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); + } + + + + // If desired, restrict jetPt axis + Int_t lowerJetPtBinLimit = -1; + Int_t upperJetPtBinLimit = -1; + Bool_t restrictJetPtAxis = kFALSE; + Double_t actualLowerJetPt = -1.; + Double_t actualUpperJetPt = -1.; + + if (lowerJetPt >= 0 && upperJetPt >= 0) { + // Add subtract a very small number to avoid problems with values right on the border between to bins + lowerJetPtBinLimit = hPIDdata->GetAxis(kPidJetPt)->FindBin(lowerJetPt + 0.001); + upperJetPtBinLimit = hPIDdata->GetAxis(kPidJetPt)->FindBin(upperJetPt - 0.001); + + // Check if the values look reasonable + if (lowerJetPtBinLimit <= upperJetPtBinLimit && lowerJetPtBinLimit >= 1 && upperJetPtBinLimit <= hPIDdata->GetAxis(kPidJetPt)->GetNbins()) { + actualLowerJetPt = hPIDdata->GetAxis(kPidJetPt)->GetBinLowEdge(lowerJetPtBinLimit); + actualUpperJetPt = hPIDdata->GetAxis(kPidJetPt)->GetBinUpEdge(upperJetPtBinLimit); + + restrictJetPtAxis = kTRUE; + } + else { + std::cout << std::endl; + std::cout << "Requested jet pT range out of limits or upper and lower limit are switched!" << std::endl; + return -1; + } + } + + std::cout << "jet pT: "; + if (restrictJetPtAxis) { + std::cout << actualLowerJetPt << " - " << actualUpperJetPt << std::endl; + } + else { + std::cout << "All" << std::endl; + } + + if (restrictJetPtAxis) { + hPIDdata->GetAxis(kPidJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); + } + + + // If desired, restrict charge axis + const Int_t indexChargeAxisData = GetAxisByTitle(hPIDdata, "Charge (e_{0})"); + if (indexChargeAxisData < 0 && restrictCharge) { + std::cout << "Error: Charge axis not found for data histogram!" << std::endl; + return -1; + } + Int_t lowerChargeBinLimitData = -1; + Int_t upperChargeBinLimitData = -2; + Double_t actualLowerChargeData = -999; + Double_t actualUpperChargeData = -999; + + if (restrictCharge) { + // Add subtract a very small number to avoid problems with values right on the border between to bins + if (chargeMode == kNegCharge) { + lowerChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(-1. + 0.001); + upperChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(0. - 0.001); + } + else if (chargeMode == kPosCharge) { + lowerChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(0. + 0.001); + upperChargeBinLimitData = hPIDdata->GetAxis(indexChargeAxisData)->FindBin(1. - 0.001); + } + + // Check if the values look reasonable + if (lowerChargeBinLimitData <= upperChargeBinLimitData && lowerChargeBinLimitData >= 1 + && upperChargeBinLimitData <= hPIDdata->GetAxis(indexChargeAxisData)->GetNbins()) { + actualLowerChargeData = hPIDdata->GetAxis(indexChargeAxisData)->GetBinLowEdge(lowerChargeBinLimitData); + actualUpperChargeData = hPIDdata->GetAxis(indexChargeAxisData)->GetBinUpEdge(upperChargeBinLimitData); + + std::cout << "Charge range data: " << actualLowerChargeData << " - " << actualUpperChargeData << std::endl; + } + else { + std::cout << std::endl; + std::cout << "Requested charge range out of limits or upper and lower limit are switched!" << std::endl; + return -1; + } + + hPIDdata->GetAxis(indexChargeAxisData)->SetRange(lowerChargeBinLimitData, upperChargeBinLimitData); + } + + std::cout << std::endl; + + + + // Open file in which all the projections (= intermediate results) will be saved + TString saveInterFName = fileName; + TString chargeString = ""; + if (chargeMode == kPosCharge) + chargeString = "_posCharge"; + else if (chargeMode == kNegCharge) + chargeString = "_negCharge"; + + saveInterFName = Form("%s_Projections_%s_%d_%s%s%s%s%s.root", saveInterFName.ReplaceAll(".root", "").Data(), + modeShortName[mode].Data(), + fitMethod, muonFractionHandlingShortName[muonFractionHandlingParameter].Data(), + useIdentifiedGeneratedSpectra ? "_idSpectra" : "", + restrictCentralityAxis ? Form("_centrality%.0f_%.0f", actualLowerCentrality, actualUpperCentrality) : "", + restrictJetPtAxis ? Form("_jetPt%.1f_%.1f", actualLowerJetPt, actualUpperJetPt) : "", + chargeString.Data()); + TFile *saveInterF = TFile::Open(saveInterFName.Data(), "RECREATE"); + saveInterF->cd(); + + // TH1 hist with number of processed events + Double_t numEvents = -1; + TH1* hNumEvents = dynamic_cast(histList->FindObject("fhEventsProcessed")); + if (!hNumEvents) { + std::cout << std::endl; + std::cout << "Histo with number of processed events not found! Yields will NOT be normalised to this number!" << std::endl + << std::endl; + } + else { + numEvents = restrictCentralityAxis ? hNumEvents->Integral(lowerCentralityBinLimit, upperCentralityBinLimit) : + hNumEvents->Integral(); + + if (numEvents <= 0) { + numEvents = -1; + std::cout << std::endl; + std::cout << "Number of processed events < 1 in selected range! Yields will NOT be normalised to this number!" + << std::endl << std::endl; + } + } + + + // TH1D hist with total yield per pT bin (-> project to arbitrary selectSpecies to avoid multiple counting) + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); + TH1D* hYieldPt = hPIDdata->Projection(axisForMode, "e"); + hYieldPt->SetName(Form("hYield%s", modeShortName[mode].Data())); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); + + + // Fill \Delta\species histograms for each momentum slice + Int_t nBins = hPIDdata->GetAxis(dataAxis)->GetNbins(); + Double_t xLow = hPIDdata->GetAxis(dataAxis)->GetXmin(); + Double_t xUp = hPIDdata->GetAxis(dataAxis)->GetXmax(); + + const Int_t numSlices = (mode == kPMpT) ? nPtBins : hPIDdata->GetAxis(axisForMode)->GetNbins(); + + TH1D* hDeltaPi[numSlices]; + TH1D* hDeltaEl[numSlices]; + TH1D* hDeltaKa[numSlices]; + TH1D* hDeltaPr[numSlices]; + + TH1D* hDeltaPiFitQA[numSlices]; + TH1D* hDeltaElFitQA[numSlices]; + TH1D* hDeltaKaFitQA[numSlices]; + TH1D* hDeltaPrFitQA[numSlices]; + + const Int_t nMCbins = 5; + TH1D* hDeltaPiMC[numSlices][nMCbins]; + TH1D* hDeltaElMC[numSlices][nMCbins]; + TH1D* hDeltaKaMC[numSlices][nMCbins]; + TH1D* hDeltaPrMC[numSlices][nMCbins]; + + + TH2D* h2Delta[4]; + TH2D* h2DeltaMC[4][nMCbins]; + + for (Int_t i = 0; i < 4; i++) { + TString speciesLabel = hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(i + 1); + + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(i + 1, i + 1); + h2Delta[i] = hPIDdata->Projection(dataAxis, axisForMode, "e"); + h2Delta[i]->SetName(Form("h2Delta_%s", speciesLabel.Data())); + h2Delta[i]->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); + h2Delta[i]->GetYaxis()->SetTitle(Form("#Delta%s_{%s} = dE/dx %s _{%s} (arb. units)", useDeltaPrime ? "'" : "", speciesLabel.Data(), + useDeltaPrime ? "/" : "-", speciesLabel.Data())); + + for (Int_t species = 0; species < nMCbins; species++) { + hPIDdata->GetAxis(kPidMCpid)->SetRange(species + 1, species + 1); // Select MC species + h2DeltaMC[i][species] = hPIDdata->Projection(dataAxis, axisGenForMode, "e"); + h2DeltaMC[i][species]->SetName(Form("h2Delta_MC_%s", speciesLabel.Data())); + h2DeltaMC[i][species]->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisGenForMode)->GetTitle()); + h2DeltaMC[i][species]->GetYaxis()->SetTitle(h2Delta[i]->GetYaxis()->GetTitle()); + } + hPIDdata->GetAxis(kPidMCpid)->SetRange(0, -1); + } + + Int_t firstValidSlice = -1; + for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hPIDdata->GetAxis(axisForMode)->GetNbins(); slice++) { + if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) + continue; + + if (firstValidSlice < 0) + firstValidSlice = slice; + + // Add/subtract some very small offset to be sure not to sit on the bin boundary, when looking for the integration/projection limits. + // For modes different from pT, just take 1 bin + const Int_t pBinLowProjLimit = (mode == kPMpT) ? h2Delta[0]->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; + const Int_t pBinUpProjLimit = (mode == kPMpT) ? h2Delta[0]->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; + + const TString binInfo = (mode == kPMpT) ? Form("%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) + : Form("%.2f_%s_%.2f", hPIDdata->GetAxis(axisForMode)->GetBinLowEdge(pBinLowProjLimit), + modeShortName[mode].Data(), + hPIDdata->GetAxis(axisForMode)->GetBinUpEdge(pBinUpProjLimit)); + + hDeltaEl[slice] = h2Delta[0]->ProjectionY(Form("hDeltaEl_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaEl[slice]->GetXaxis()->SetTitle(h2Delta[0]->GetYaxis()->GetTitle()); + hDeltaEl[slice]->GetXaxis()->SetTitleOffset(1.0); + hDeltaEl[slice]->SetStats(kFALSE); + + hDeltaKa[slice] = h2Delta[1]->ProjectionY(Form("hDeltaKa_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaKa[slice]->SetName(Form("hDeltaKa_%s", binInfo.Data())); + hDeltaKa[slice]->GetXaxis()->SetTitle(h2Delta[1]->GetYaxis()->GetTitle()); + hDeltaKa[slice]->GetXaxis()->SetTitleOffset(1.0); + hDeltaKa[slice]->SetStats(kFALSE); + + hDeltaPi[slice] = h2Delta[2]->ProjectionY(Form("hDeltaPi_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaPi[slice]->SetName(Form("hDeltaPi_%s", binInfo.Data())); + hDeltaPi[slice]->GetXaxis()->SetTitle(h2Delta[2]->GetYaxis()->GetTitle()); + hDeltaPi[slice]->GetXaxis()->SetTitleOffset(1.0); + hDeltaPi[slice]->SetStats(kFALSE); + + hDeltaPr[slice] = h2Delta[3]->ProjectionY(Form("hDeltaPr_%s", binInfo.Data()), pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaPr[slice]->SetName(Form("hDeltaPr_%s", binInfo.Data())); + hDeltaPr[slice]->GetXaxis()->SetTitle(h2Delta[3]->GetYaxis()->GetTitle()); + hDeltaPr[slice]->GetXaxis()->SetTitleOffset(1.0); + hDeltaPr[slice]->SetStats(kFALSE); + + if (plotIdentifiedSpectra) { + // If identified spectra are available (mainly useful in the MC case) and shall be used, + // create histos with signals from identified particles + + // DeltaEl + for (Int_t species = 0; species < nMCbins; species++) { + hDeltaElMC[slice][species] = h2DeltaMC[0][species]->ProjectionY(Form("hDeltaElMC_%s_species_%d", binInfo.Data(), species), + pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaElMC[slice][species]->SetLineColor(getLineColor(species + 1)); + hDeltaElMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); + hDeltaElMC[slice][species]->SetMarkerStyle(24); + hDeltaElMC[slice][species]->SetLineStyle(1); + hDeltaElMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[0][species]->GetYaxis()->GetTitle()); + hDeltaElMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); + hDeltaElMC[slice][species]->SetStats(kFALSE); + } + + // DeltaKa + for (Int_t species = 0; species < nMCbins; species++) { + hDeltaKaMC[slice][species] = h2DeltaMC[1][species]->ProjectionY(Form("hDeltaKaMC_%s_species_%d", binInfo.Data(), species), + pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaKaMC[slice][species]->SetLineColor(getLineColor(species + 1)); + hDeltaKaMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); + hDeltaKaMC[slice][species]->SetMarkerStyle(24); + hDeltaKaMC[slice][species]->SetLineStyle(1); + hDeltaKaMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[1][species]->GetYaxis()->GetTitle()); + hDeltaKaMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); + hDeltaKaMC[slice][species]->SetStats(kFALSE); + } + + // DeltaPi + for (Int_t species = 0; species < nMCbins; species++) { + hDeltaPiMC[slice][species] = h2DeltaMC[2][species]->ProjectionY(Form("hDeltaPiMC_%s_species_%d", binInfo.Data(), species), + pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaPiMC[slice][species]->SetLineColor(getLineColor(species + 1)); + hDeltaPiMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); + hDeltaPiMC[slice][species]->SetMarkerStyle(24); + hDeltaPiMC[slice][species]->SetLineStyle(1); + hDeltaPiMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[2][species]->GetYaxis()->GetTitle()); + hDeltaPiMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); + hDeltaPiMC[slice][species]->SetStats(kFALSE); + } + + // DeltaPr + for (Int_t species = 0; species < nMCbins; species++) { + hDeltaPrMC[slice][species] = h2DeltaMC[3][species]->ProjectionY(Form("hDeltaPrMC_%s_species_%d", binInfo.Data(), species), + pBinLowProjLimit, pBinUpProjLimit, "e"); + hDeltaPrMC[slice][species]->SetLineColor(getLineColor(species + 1)); + hDeltaPrMC[slice][species]->SetMarkerColor(getLineColor(species + 1)); + hDeltaPrMC[slice][species]->SetMarkerStyle(24); + hDeltaPrMC[slice][species]->SetLineStyle(1); + hDeltaPrMC[slice][species]->GetXaxis()->SetTitle(h2DeltaMC[3][species]->GetYaxis()->GetTitle()); + hDeltaPrMC[slice][species]->GetXaxis()->SetTitleOffset(1.0); + hDeltaPrMC[slice][species]->SetStats(kFALSE); + } + } + } + hPIDdata->GetAxis(kPidMCpid)->SetRange(0, -1); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); + + hPIDdata->GetAxis(axisForMode)->SetRange(0, -1); + + /* + // TOF TODO + TCanvas* cTOF = new TCanvas("cTOF", "TOF PID",100,10,1200,800); + cTOF->Divide(4,1); + cTOF->cd(1); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); + TH2D* h2TOFel = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); + h2TOFel->SetName("h2TOFel"); + h2TOFel->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(1))); + h2TOFel->Draw("colz"); + + cTOF->cd(2); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(2, 2); + TH2D* h2TOFka = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); + h2TOFka->SetName("h2TOFka"); + h2TOFka->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(2))); + h2TOFka->Draw("colz"); + + cTOF->cd(3); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(3, 3); + TH2D* h2TOFpi = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); + h2TOFpi->SetName("h2TOFpi"); + h2TOFpi->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(3))); + h2TOFpi->Draw("colz"); + + cTOF->cd(4); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(4, 4); + TH2D* h2TOFpr = hPIDdata->Projection(kPidDeltaTOF, kPidPvertex); + h2TOFpr->SetName("h2TOFpr"); + h2TOFpr->GetYaxis()->SetTitle(Form("#DeltaTOF_{%s} (ps)", hPIDdata->GetAxis(kPidSelectSpecies)->GetBinLabel(4))); + h2TOFpr->Draw("colz"); + + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); + */ + + // Start fitting of slices + TCanvas* cSingleFit[numSlices][4]; + + TF1* fitFuncTotalDeltaPion[numSlices]; + TF1* fitFuncTotalDeltaElectron[numSlices]; + TF1* fitFuncTotalDeltaKaon[numSlices]; + TF1* fitFuncTotalDeltaProton[numSlices]; + + // Histos for particle fractions + TH1F* hFractionElectrons = 0x0; + if (mode == kPMpT) + hFractionElectrons = new TH1F("hFractionElectrons", "e", nPtBins, binsPt); + else { + const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); + if (histBins->fN == 0) + hFractionElectrons = new TH1F("hFractionElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), + hPIDdata->GetAxis(axisForMode)->GetXmax()); + else + hFractionElectrons = new TH1F("hFractionElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray); + } + + hFractionElectrons->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); + hFractionElectrons->GetYaxis()->SetTitle("Fraction"); + hFractionElectrons->SetLineColor(getLineColor(kEl)); + hFractionElectrons->SetMarkerColor(getLineColor(kEl)); + hFractionElectrons->SetMarkerStyle(20); + hFractionElectrons->Sumw2(); + hFractionElectrons->SetStats(kFALSE); + + TH1F* hFractionElectronsDeltaPion = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaPion"); + TH1F* hFractionElectronsDeltaElectron = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaElectron"); + TH1F* hFractionElectronsDeltaKaon = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaKaon"); + TH1F* hFractionElectronsDeltaProton = (TH1F*)hFractionElectrons->Clone("hFractionElectronsDeltaProton"); + + TH1F* hFractionKaons = (TH1F*)hFractionElectrons->Clone("hFractionKaons"); + hFractionKaons->SetTitle("K"); + hFractionKaons->SetLineColor(getLineColor(kKa)); + hFractionKaons->SetMarkerColor(getLineColor(kKa)); + + TH1F* hFractionKaonsDeltaPion = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaPion"); + TH1F* hFractionKaonsDeltaElectron = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaElectron"); + TH1F* hFractionKaonsDeltaKaon = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaKaon"); + TH1F* hFractionKaonsDeltaProton = (TH1F*)hFractionKaons->Clone("hFractionKaonsDeltaProton"); + + TH1F* hFractionPions = (TH1F*)hFractionElectrons->Clone("hFractionPions"); + hFractionPions->SetTitle("#pi"); + hFractionPions->SetLineColor(getLineColor(kPi)); + hFractionPions->SetMarkerColor(getLineColor(kPi)); + + TH1F* hFractionPionsDeltaPion = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaPion"); + TH1F* hFractionPionsDeltaElectron = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaElectron"); + TH1F* hFractionPionsDeltaKaon = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaKaon"); + TH1F* hFractionPionsDeltaProton = (TH1F*)hFractionPions->Clone("hFractionPionsDeltaProton"); + + TH1F* hFractionProtons = (TH1F*)hFractionElectrons->Clone("hFractionProtons"); + hFractionProtons->SetTitle("p"); + hFractionProtons->SetLineColor(getLineColor(kPr)); + hFractionProtons->SetMarkerColor(getLineColor(kPr)); + + TH1F* hFractionProtonsDeltaPion = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaPion"); + TH1F* hFractionProtonsDeltaElectron = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaElectron"); + TH1F* hFractionProtonsDeltaKaon = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaKaon"); + TH1F* hFractionProtonsDeltaProton = (TH1F*)hFractionProtons->Clone("hFractionProtonsDeltaProton"); + + TH1F* hFractionMuons = (TH1F*)hFractionElectrons->Clone("hFractionMuons"); + hFractionMuons->SetTitle("#mu"); + hFractionMuons->SetLineColor(getLineColor(kMu)); + hFractionMuons->SetMarkerColor(getLineColor(kMu)); + + TH1F* hFractionMuonsDeltaPion = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaPion"); + TH1F* hFractionMuonsDeltaElectron = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaElectron"); + TH1F* hFractionMuonsDeltaKaon = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaKaon"); + TH1F* hFractionMuonsDeltaProton = (TH1F*)hFractionMuons->Clone("hFractionMuonsDeltaProton"); + + TH1F* hFractionSummed = (TH1F*)hFractionProtons->Clone("hFractionSummed"); + hFractionSummed->SetTitle("Sum"); + hFractionSummed->SetLineColor(kBlack); + hFractionSummed->SetMarkerColor(kBlack); + + + // MC fractions + TH1F* hFractionElectronsMC = (TH1F*)hFractionElectrons->Clone("hFractionElectronsMC"); + hFractionElectronsMC->SetMarkerStyle(24); + TH1F* hFractionKaonsMC = (TH1F*)hFractionKaons->Clone("hFractionKaonsMC"); + hFractionKaonsMC->SetMarkerStyle(24); + TH1F* hFractionPionsMC = (TH1F*)hFractionPions->Clone("hFractionPionsMC"); + hFractionPionsMC->SetMarkerStyle(24); + TH1F* hFractionMuonsMC = (TH1F*)hFractionMuons->Clone("hFractionMuonsMC"); + hFractionMuonsMC->SetMarkerStyle(24); + TH1F* hFractionProtonsMC = (TH1F*)hFractionProtons->Clone("hFractionProtonsMC"); + hFractionProtonsMC->SetMarkerStyle(24); + + + // Comparison fit result<->MC + TString fractionComparisonTitle = Form("Fraction fit / fraction %s", identifiedLabels[isMC].Data()); + TH1F* hFractionComparisonElectrons = (TH1F*)hFractionElectrons->Clone("hFractionComparisonElectrons"); + hFractionComparisonElectrons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + TH1F* hFractionComparisonMuons = (TH1F*)hFractionMuons->Clone("hFractionComparisonMuons"); + hFractionComparisonMuons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + TH1F* hFractionComparisonKaons = (TH1F*)hFractionKaons->Clone("hFractionComparisonKaons"); + hFractionComparisonKaons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + TH1F* hFractionComparisonPions = (TH1F*)hFractionPions->Clone("hFractionComparisonPions"); + hFractionComparisonPions->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + TH1F* hFractionComparisonProtons = (TH1F*)hFractionProtons->Clone("hFractionComparisonProtons"); + hFractionComparisonProtons->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + TH1F* hFractionComparisonTotal = (TH1F*)hFractionSummed->Clone("hFractionComparisonTotal"); + hFractionComparisonTotal->GetYaxis()->SetTitle(fractionComparisonTitle.Data()); + + + + // Histos for particle yields + TH1F* hYieldElectrons = 0x0; + if (mode == kPMpT) + hYieldElectrons = new TH1F("hYieldElectrons", "e", nPtBins, binsPt); + else { + const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); + if (histBins->fN == 0) + hYieldElectrons = new TH1F("hYieldElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), + hPIDdata->GetAxis(axisForMode)->GetXmax()); + else + hYieldElectrons = new TH1F("hYieldElectrons", "e", hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray); + } + + hYieldElectrons->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); + hYieldElectrons->GetYaxis()->SetTitle(Form("%s1/(2#pi%s) d^{2}N/d#etad%s%s", numEvents > 0 ? "1/N_{ev} " : "", + modeLatexName[mode].Data(), modeLatexName[mode].Data(), + mode == kPMpT ? " (GeV/c)^{-2}" : 0)); + hYieldElectrons->SetLineColor(getLineColor(kEl)); + hYieldElectrons->SetMarkerColor(getLineColor(kEl)); + hYieldElectrons->SetMarkerStyle(20); + hYieldElectrons->Sumw2(); + hYieldElectrons->SetStats(kFALSE); + + TH1F* hYieldElectronsDeltaPion = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaPion"); + TH1F* hYieldElectronsDeltaElectron = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaElectron"); + TH1F* hYieldElectronsDeltaKaon = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaKaon"); + TH1F* hYieldElectronsDeltaProton = (TH1F*)hYieldElectrons->Clone("hYieldElectronsDeltaProton"); + + TH1F* hYieldKaons = (TH1F*)hYieldElectrons->Clone("hYieldKaons"); + hYieldKaons->SetTitle("K"); + hYieldKaons->SetLineColor(getLineColor(kKa)); + hYieldKaons->SetMarkerColor(getLineColor(kKa)); + + TH1F* hYieldKaonsDeltaPion = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaPion"); + TH1F* hYieldKaonsDeltaElectron = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaElectron"); + TH1F* hYieldKaonsDeltaKaon = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaKaon"); + TH1F* hYieldKaonsDeltaProton = (TH1F*)hYieldKaons->Clone("hYieldKaonsDeltaProton"); + + TH1F* hYieldPions = (TH1F*)hYieldElectrons->Clone("hYieldPions"); + hYieldPions->SetTitle("#pi"); + hYieldPions->SetLineColor(getLineColor(kPi)); + hYieldPions->SetMarkerColor(getLineColor(kPi)); + + TH1F* hYieldPionsDeltaPion = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaPion"); + TH1F* hYieldPionsDeltaElectron = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaElectron"); + TH1F* hYieldPionsDeltaKaon = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaKaon"); + TH1F* hYieldPionsDeltaProton = (TH1F*)hYieldPions->Clone("hYieldPionsDeltaProton"); + + TH1F* hYieldProtons = (TH1F*)hYieldElectrons->Clone("hYieldProtons"); + hYieldProtons->SetTitle("p"); + hYieldProtons->SetLineColor(getLineColor(kPr)); + hYieldProtons->SetMarkerColor(getLineColor(kPr)); + + TH1F* hYieldProtonsDeltaPion = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaPion"); + TH1F* hYieldProtonsDeltaElectron = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaElectron"); + TH1F* hYieldProtonsDeltaKaon = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaKaon"); + TH1F* hYieldProtonsDeltaProton = (TH1F*)hYieldProtons->Clone("hYieldProtonsDeltaProton"); + + TH1F* hYieldMuons = (TH1F*)hYieldElectrons->Clone("hYieldMuons"); + hYieldMuons->SetTitle("#mu"); + hYieldMuons->SetLineColor(getLineColor(kMu)); + hYieldMuons->SetMarkerColor(getLineColor(kMu)); + + TH1F* hYieldMuonsDeltaPion = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaPion"); + TH1F* hYieldMuonsDeltaElectron = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaElectron"); + TH1F* hYieldMuonsDeltaKaon = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaKaon"); + TH1F* hYieldMuonsDeltaProton = (TH1F*)hYieldMuons->Clone("hYieldMuonsDeltaProton"); + + // MC yields + TH1F* hYieldElectronsMC = (TH1F*)hYieldElectrons->Clone("hYieldElectronsMC"); + hYieldElectronsMC->SetMarkerStyle(24); + TH1F* hYieldMuonsMC = (TH1F*)hYieldElectrons->Clone("hYieldMuonsMC"); + hYieldMuonsMC->SetMarkerStyle(24); + hYieldMuonsMC->SetLineColor(getLineColor(kMu)); + hYieldMuonsMC->SetMarkerColor(getLineColor(kMu)); + TH1F* hYieldKaonsMC = (TH1F*)hYieldKaons->Clone("hYieldKaonsMC"); + hYieldKaonsMC->SetMarkerStyle(24); + TH1F* hYieldPionsMC = (TH1F*)hYieldPions->Clone("hYieldPionsMC"); + hYieldPionsMC->SetMarkerStyle(24); + TH1F* hYieldProtonsMC = (TH1F*)hYieldProtons->Clone("hYieldProtonsMC"); + hYieldProtonsMC->SetMarkerStyle(24); + TH1F* hYieldSummedMC = (TH1F*)hYieldProtonsMC->Clone("hYieldSummedMC"); + hYieldSummedMC->SetTitle("Sum"); + hYieldSummedMC->SetLineColor(kBlack); + hYieldSummedMC->SetMarkerColor(kBlack); + + // Comparison fit result<->MC (yields) + TString yieldComparisonTitle = Form("Yield fit / yield %s", identifiedLabels[isMC].Data()); + TH1F* hYieldComparisonElectrons = (TH1F*)hYieldElectrons->Clone("hYieldComparisonElectrons"); + hYieldComparisonElectrons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); + TH1F* hYieldComparisonMuons = (TH1F*)hYieldMuons->Clone("hYieldComparisonMuons"); + hYieldComparisonMuons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); + TH1F* hYieldComparisonKaons = (TH1F*)hYieldKaons->Clone("hYieldComparisonKaons"); + hYieldComparisonKaons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); + TH1F* hYieldComparisonPions = (TH1F*)hYieldPions->Clone("hYieldComparisonPions"); + hYieldComparisonPions->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); + TH1F* hYieldComparisonProtons = (TH1F*)hYieldProtons->Clone("hYieldComparisonProtons"); + hYieldComparisonProtons->GetYaxis()->SetTitle(yieldComparisonTitle.Data()); + + + // To-pi ratios + TString electronString[3] = { "e^{-}", "e^{+}+e^{-}", "e^{+}" }; + TString muonString[3] = { "#mu^{-}", "#mu^{+}+#mu^{-}", "#mu^{+}" }; + TString kaonString[3] = { "K^{-}", "K^{+}+K^{-}", "K^{+}" }; + TString pionString[3] = { "#pi^{-}", "#pi^{+}+#pi^{-}", "#pi^{+}" }; + TString protonString[3] = { "#bar{p}", "p+#bar{p}", "p" }; + + TH1F* hRatioToPiElectrons = (TH1F*)hYieldElectrons->Clone("hRatioToPiElectrons"); + hRatioToPiElectrons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", + electronString[chargeMode+1].Data(), + modeLatexName[mode].Data(), + pionString[chargeMode+1].Data(), + modeLatexName[mode].Data())); + hRatioToPiElectrons->SetTitle(Form("%s", chargeMode == 0 + ? Form("(%s)/(%s)", electronString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) + : Form("%s/%s", electronString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); + + + TH1F* hRatioToPiMuons = (TH1F*)hYieldMuons->Clone("hRatioToPiMuons"); + hRatioToPiMuons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", + muonString[chargeMode+1].Data(), + modeLatexName[mode].Data(), + pionString[chargeMode+1].Data(), + modeLatexName[mode].Data())); + hRatioToPiMuons->SetTitle(Form("%s", chargeMode == 0 + ? Form("(%s)/(%s)", muonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) + : Form("%s/%s", muonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); + + TH1F* hRatioToPiKaons = (TH1F*)hYieldKaons->Clone("hRatioToPiKaons"); + hRatioToPiKaons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", + kaonString[chargeMode+1].Data(), + modeLatexName[mode].Data(), + pionString[chargeMode+1].Data(), + modeLatexName[mode].Data())); + hRatioToPiKaons->SetTitle(Form("%s", chargeMode == 0 + ? Form("(%s)/(%s)", kaonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) + : Form("%s/%s", kaonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); + + TH1F* hRatioToPiProtons = (TH1F*)hYieldProtons->Clone("hRatioToPiProtons"); + hRatioToPiProtons->GetYaxis()->SetTitle(Form("d^{2}N_{%s}/d#etad%s / d^{2}N_{%s}/d#etad%s", + protonString[chargeMode+1].Data(), + modeLatexName[mode].Data(), + pionString[chargeMode+1].Data(), + modeLatexName[mode].Data())); + hRatioToPiProtons->SetTitle(Form("%s", chargeMode == 0 + ? Form("(%s)/(%s)", protonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()) + : Form("%s/%s", protonString[chargeMode+1].Data(), pionString[chargeMode+1].Data()))); + + // MC to-pi ratios + TH1F* hRatioToPiElectronsMC = (TH1F*)hRatioToPiElectrons->Clone("hRatioToPiElectronsMC"); + hRatioToPiElectronsMC->SetMarkerStyle(24); + TH1F* hRatioToPiMuonsMC = (TH1F*)hRatioToPiMuons->Clone("hRatioToPiMuonsMC"); + hRatioToPiMuonsMC->SetMarkerStyle(24); + hRatioToPiMuonsMC->SetLineColor(getLineColor(kMu)); + hRatioToPiMuonsMC->SetMarkerColor(getLineColor(kMu)); + TH1F* hRatioToPiKaonsMC = (TH1F*)hRatioToPiKaons->Clone("hRatioToPiKaonsMC"); + hRatioToPiKaonsMC->SetMarkerStyle(24); + TH1F* hRatioToPiProtonsMC = (TH1F*)hRatioToPiProtons->Clone("hRatioToPiProtonsMC"); + hRatioToPiProtonsMC->SetMarkerStyle(24); + + // Reduced Chi^2 of fits vs. pT for all Delta_Species + TH2F* hReducedChiSquarePt = 0x0; + if (mode == kPMpT) + hReducedChiSquarePt = new TH2F("hReducedChiSquarePt", "e", nPtBins, binsPt, 4, 0, 4); + else { + const TArrayD* histBins = hPIDdata->GetAxis(axisForMode)->GetXbins(); + if (histBins->fN == 0) + hReducedChiSquarePt = new TH2F(Form("hReducedChiSquare%s", modeShortName[mode].Data()), "e", + hPIDdata->GetAxis(axisForMode)->GetNbins(), hPIDdata->GetAxis(axisForMode)->GetXmin(), + hPIDdata->GetAxis(axisForMode)->GetXmax(), 4, 0, 4); + else + hReducedChiSquarePt = new TH2F(Form("hReducedChiSquare%s", modeShortName[mode].Data()), "e", + hPIDdata->GetAxis(axisForMode)->GetNbins(), histBins->fArray, 4, 0, 4); + } + + hReducedChiSquarePt->GetXaxis()->SetTitle(hPIDdata->GetAxis(axisForMode)->GetTitle()); + hReducedChiSquarePt->GetYaxis()->SetTitle("Delta_{Species}"); + hReducedChiSquarePt->GetYaxis()->SetBinLabel(1, "e"); + hReducedChiSquarePt->GetYaxis()->SetBinLabel(2, "K"); + hReducedChiSquarePt->GetYaxis()->SetBinLabel(3, "#pi"); + hReducedChiSquarePt->GetYaxis()->SetBinLabel(4, "p"); + hReducedChiSquarePt->SetMarkerColor(kRed); + hReducedChiSquarePt->SetMarkerStyle(20); + hReducedChiSquarePt->SetStats(kFALSE); + + // Obtain MC information about particle yields + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(1, 1); // Do not count each particle more than once + TH2D* hMCdata = (TH2D*)hPIDdata->Projection(kPidMCpid, axisForMode, "e"); + hMCdata->SetName("hMCdata"); + hPIDdata->GetAxis(kPidSelectSpecies)->SetRange(0, -1); // Reset range + + + + // Extract the MC truth generated primary yields + THnSparse* hMCgeneratedYieldsPrimaries = isMCdataSet ? dynamic_cast(histList->FindObject("fhMCgeneratedYieldsPrimaries")) + : 0x0; + + TH1D* hMCgenYieldsPrimSpecies[AliPID::kSPECIES]; + for (Int_t i = 0; i < AliPID::kSPECIES; i++) + hMCgenYieldsPrimSpecies[i] = 0x0; + + if (hMCgeneratedYieldsPrimaries) { + // Set proper errors, if not yet calculated + if (!hMCgeneratedYieldsPrimaries->GetCalculateErrors()) { + std::cout << "Re-calculating errors of " << hMCgeneratedYieldsPrimaries->GetName() << "..." << std::endl; + + hMCgeneratedYieldsPrimaries->Sumw2(); + + Long64_t nBinsTHnSparseGenYield = hMCgeneratedYieldsPrimaries->GetNbins(); + Double_t binContentGenYield = 0; + for (Long64_t bin = 0; bin < nBinsTHnSparseGenYield; bin++) { + binContentGenYield = hMCgeneratedYieldsPrimaries->GetBinContent(bin); + hMCgeneratedYieldsPrimaries->SetBinError(bin, TMath::Sqrt(binContentGenYield)); + } + } + + if (restrictJetPtAxis) + hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); + + if (restrictCentralityAxis) + hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); + + + if (restrictCharge) { + const Int_t indexChargeAxisGenYield = GetAxisByTitle(hMCgeneratedYieldsPrimaries, "Charge (e_{0})"); + if (indexChargeAxisGenYield < 0) { + std::cout << "Error: Charge axis not found for gen yield histogram!" << std::endl; + return -1; + } + + Int_t lowerChargeBinLimitGenYield = -1; + Int_t upperChargeBinLimitGenYield = -2; + Double_t actualLowerChargeGenYield = -999; + Double_t actualUpperChargeGenYield = -999; + + // Add subtract a very small number to avoid problems with values right on the border between to bins + if (chargeMode == kNegCharge) { + lowerChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(-1. + 0.001); + upperChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(0. - 0.001); + } + else if (chargeMode == kPosCharge) { + lowerChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(0. + 0.001); + upperChargeBinLimitGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->FindBin(1. - 0.001); + } + + // Check if the values look reasonable + if (lowerChargeBinLimitGenYield <= upperChargeBinLimitGenYield && lowerChargeBinLimitGenYield >= 1 + && upperChargeBinLimitGenYield <= hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetNbins()) { + actualLowerChargeGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetBinLowEdge(lowerChargeBinLimitGenYield); + actualUpperChargeGenYield = hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->GetBinUpEdge(upperChargeBinLimitGenYield); + + if (TMath::Abs(actualLowerChargeGenYield - actualLowerChargeData) > 1e-4 || + TMath::Abs(actualUpperChargeGenYield - actualUpperChargeData) > 1e-4) { + std::cout << std::endl; + std::cout << "Error: Charge range gen yield: " << actualLowerChargeGenYield << " - " << actualUpperChargeGenYield + << std::endl << "differs from that of data: " << actualLowerChargeData << " - " << actualUpperChargeData + << std::endl; + return -1; + } + } + else { + std::cout << std::endl; + std::cout << "Requested charge range (gen yield) out of limits or upper and lower limit are switched!" << std::endl; + return -1; + } + + hMCgeneratedYieldsPrimaries->GetAxis(indexChargeAxisGenYield)->SetRange(lowerChargeBinLimitGenYield, upperChargeBinLimitGenYield); + } + + for (Int_t MCid = 0; MCid < AliPID::kSPECIES; MCid++) { + hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldMCpid)->SetRange(MCid + 1, MCid + 1); + + hMCgenYieldsPrimSpecies[MCid] = hMCgeneratedYieldsPrimaries->Projection(kPidGenYieldPt, "e"); + hMCgenYieldsPrimSpecies[MCid]->SetName(Form("hMCgenYieldsPrimSpecies_%s", AliPID::ParticleShortName(MCid))); + hMCgenYieldsPrimSpecies[MCid]->SetTitle(Form("MC truth generated primary yield, %s", AliPID::ParticleName(MCid))); + + // Choose the same binning as for the fitted yields, i.e. rebin the histogram (Rebin will create a clone!) + TH1D* temp = (TH1D*)hMCgenYieldsPrimSpecies[MCid]->Rebin(nPtBins, hMCgenYieldsPrimSpecies[MCid]->GetName(), binsPt); + // Delete the old binned histo and take the new binned one + delete hMCgenYieldsPrimSpecies[MCid]; + hMCgenYieldsPrimSpecies[MCid] = temp; + + hMCgeneratedYieldsPrimaries->GetAxis(kPidGenYieldMCpid)->SetRange(0, -1); + } + } + + + // Get expected shapes for pT bins + TString Ytitle = ""; + + // Array index 0 as unused dummy + TH2D* hGenDelta[6][6]; // DeltaSpecies (first index) for species (second index) + TH2D* hGenDeltaMCid[6][6]; // DeltaSpecies (first index) for species (second index) + + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { + hGenDelta[i][j] = 0x0; + hGenDeltaMCid[i][j] = 0x0; + } + } + + THnSparse* current = 0x0; + + THnSparse* hGenEl = dynamic_cast(histList->FindObject("hGenEl")); + if (!hGenEl) { + std::cout << "Failed to load expected dEdx signal shape for: Electrons!" << std::endl; + return -1; + } + + THnSparse* hGenKa = dynamic_cast(histList->FindObject("hGenKa")); + if (!hGenKa) { + std::cout << "Failed to load expected dEdx signal shape for: Kaons!" << std::endl; + return -1; + } + + THnSparse* hGenPi = dynamic_cast(histList->FindObject("hGenPi")); + if (!hGenPi) { + std::cout << "Failed to load expected dEdx signal shape for: Pions!" << std::endl; + return -1; + } + + THnSparse* hGenMu = dynamic_cast(histList->FindObject("hGenMu")); + if (!hGenMu) { + std::cout << "Failed to load expected dEdx signal shape for: Muons! Treated muons as pions in the following." << std::endl; + takeIntoAccountMuons = kFALSE; + } + + THnSparse* hGenPr = dynamic_cast(histList->FindObject("hGenPr")); + if (!hGenPr) { + std::cout << "Failed to load expected dEdx signal shape for: Protons!" << std::endl; + return -1; + } + + for (Int_t MCid = kEl; MCid <= kPr; MCid++) { + if (MCid == kEl) + current = hGenEl; + else if (MCid == kKa) + current = hGenKa; + else if (MCid == kMu) { + if (takeIntoAccountMuons) + current = hGenMu; + else + continue; // No histo for muons in this case + } + else if (MCid == kPi) + current = hGenPi; + else if (MCid == kPr) + current = hGenPr; + else + break; + + // If desired, rebin considered axis + if (rebin > 1 || rebinDeltaPrime > 1) { + const Int_t nDimensions = current->GetNdimensions(); + Int_t rebinFactor[nDimensions]; + + for (Int_t dim = 0; dim < nDimensions; dim++) { + if (dim == axisGenForMode) + rebinFactor[dim] = rebin; + else if (dim == kPidGenDeltaPrime && rebinDeltaPrime > 1) + rebinFactor[dim] = rebinDeltaPrime; + else + rebinFactor[dim] = 1; + } + + THnSparse* temp = current->Rebin(&rebinFactor[0]); + current->Reset(); + current = temp; + } + + // Set proper errors, if not yet calculated + if (!current->GetCalculateErrors()) { + std::cout << "Re-calculating errors of " << current->GetName() << "..." << std::endl; + + current->Sumw2(); + + Long64_t nBinsTHnSparseGen = current->GetNbins(); + Double_t binContentGen = 0; + for (Long64_t bin = 0; bin < nBinsTHnSparseGen; bin++) { + binContentGen = current->GetBinContent(bin); + current->SetBinError(bin, TMath::Sqrt(binContentGen)); + } + } + + // If desired, restrict centrality range + if (restrictCentralityAxis) { + current->GetAxis(kPidGenCentrality)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit); + } + + // If desired, restrict jet pT range + if (restrictJetPtAxis) { + current->GetAxis(kPidGenJetPt)->SetRange(lowerJetPtBinLimit, upperJetPtBinLimit); + } + + // If desired, restrict charge range + if (restrictCharge) { + const Int_t indexChargeAxisGen = GetAxisByTitle(current, "Charge (e_{0})"); + if (indexChargeAxisGen < 0) { + std::cout << "Error: Charge axis not found for gen histogram!" << std::endl; + return -1; + } + + Int_t lowerChargeBinLimitGen = -1; + Int_t upperChargeBinLimitGen = -2; + Double_t actualLowerChargeGen = -999; + Double_t actualUpperChargeGen = -999; + + // Add subtract a very small number to avoid problems with values right on the border between to bins + if (chargeMode == kNegCharge) { + lowerChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(-1. + 0.001); + upperChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(0. - 0.001); + } + else if (chargeMode == kPosCharge) { + lowerChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(0. + 0.001); + upperChargeBinLimitGen = current->GetAxis(indexChargeAxisGen)->FindBin(1. - 0.001); + } + + // Check if the values look reasonable + if (lowerChargeBinLimitGen <= upperChargeBinLimitGen && lowerChargeBinLimitGen >= 1 + && upperChargeBinLimitGen <= current->GetAxis(indexChargeAxisGen)->GetNbins()) { + actualLowerChargeGen = current->GetAxis(indexChargeAxisGen)->GetBinLowEdge(lowerChargeBinLimitGen); + actualUpperChargeGen = current->GetAxis(indexChargeAxisGen)->GetBinUpEdge(upperChargeBinLimitGen); + + if (TMath::Abs(actualLowerChargeGen - actualLowerChargeData) > 1e-4 || + TMath::Abs(actualUpperChargeGen - actualUpperChargeData) > 1e-4) { + std::cout << std::endl; + std::cout << "Error: Charge range gen: " << actualLowerChargeGen << " - " << actualUpperChargeGen + << std::endl << "differs from that of data: " << actualLowerChargeData << " - " << actualUpperChargeData + << std::endl; + return -1; + } + } + else { + std::cout << std::endl; + std::cout << "Requested charge range (gen) out of limits or upper and lower limit are switched!" << std::endl; + return -1; + } + + current->GetAxis(indexChargeAxisGen)->SetRange(lowerChargeBinLimitGen, upperChargeBinLimitGen); + } + + + + for (Int_t selectBin = 1; selectBin <= 4; selectBin++) { + Int_t selectMCid = (selectBin >= 3) ? (selectBin+1) : selectBin; + + current->GetAxis(kPidGenSelectSpecies)->SetRange(selectBin, selectBin); + + Ytitle = Form("#Delta%s_{%s} = dE/dx %s _{%s} (arb. units)", useDeltaPrime ? "'" : "", + partShortName[selectMCid - 1].Data(), useDeltaPrime ? "/" : "-", + partShortName[selectMCid - 1].Data()); + + TH2* hGenCurrent = 0x0; + if (!useIdentifiedGeneratedSpectra) { + hGenDelta[selectMCid][MCid] = current->Projection(genAxis, axisGenForMode, "e"); + hGenDelta[selectMCid][MCid]->SetName(Form("hGenDelta%sFor%s", partShortName[selectMCid - 1].Data(), + partShortName[MCid - 1].Data())); + hGenCurrent = hGenDelta[selectMCid][MCid]; + } + else { + current->GetAxis(kPidGenMCpid)->SetRange(MCid, MCid); + hGenDeltaMCid[selectMCid][MCid] = current->Projection(genAxis, axisGenForMode, "e"); + hGenDeltaMCid[selectMCid][MCid]->SetName(Form("hGenDelta%sForMCid%s", partShortName[selectMCid - 1].Data(), + partShortName[MCid - 1].Data())); + + hGenCurrent = hGenDeltaMCid[selectMCid][MCid]; + current->GetAxis(kPidGenMCpid)->SetRange(0, -1); + } + + hGenCurrent->GetYaxis()->SetTitle(Ytitle.Data()); + hGenCurrent->SetLineColor(getLineColor(MCid)); + hGenCurrent->SetMarkerColor(getLineColor(MCid)); + hGenCurrent->SetLineWidth(2); + hGenCurrent->SetLineStyle(2); + hGenCurrent->SetMarkerStyle(20); + hGenCurrent->GetXaxis()->SetTitleOffset(1.0); + } + + current->GetAxis(kPidGenSelectSpecies)->SetRange(0, -1); + } + + // Free a lot of memory for the following procedure. Histogram is not needed anymore (only its projections) + delete f; + + // Save intermediate results + //TODO save intermediate TOF results + saveInterF->cd(); + + if (hMCdata) + hMCdata->Write(); + + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { + if (hGenDelta[i][j]) + hGenDelta[i][j]->Write(); + + if (hGenDeltaMCid[i][j]) + hGenDeltaMCid[i][j]->Write(); + } + } + + for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { + if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) + continue; + + if(hDeltaPi[slice]) + hDeltaPi[slice]->Write(); + if(hDeltaEl[slice]) + hDeltaEl[slice]->Write(); + if(hDeltaKa[slice]) + hDeltaKa[slice]->Write(); + if(hDeltaPr[slice]) + hDeltaPr[slice]->Write(); + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) { + hDeltaElMC[slice][species]->Write(); + hDeltaKaMC[slice][species]->Write(); + hDeltaPiMC[slice][species]->Write(); + hDeltaPrMC[slice][species]->Write(); + } + } + } + + // File may not be closed because the projections are needed in the following! + //saveInterF->Close(); + + // Save some first results for the final output + TString saveFName = fileName; + saveFName = Form("%s_results_%s__%s_%d_reg%d_regFac%.2f_%s%s%s%s%s.root", saveFName.ReplaceAll(".root", "").Data(), + useLogLikelihood ? (useWeightsForLogLikelihood ? "weightedLLFit" : "LLFit") : "ChiSquareFit", + modeShortName[mode].Data(), fitMethod, regularisation, regularisationFactor, + muonFractionHandlingShortName[muonFractionHandlingParameter].Data(), + useIdentifiedGeneratedSpectra ? "_idSpectra" : "", + restrictCentralityAxis ? Form("_centrality%.0f_%.0f", actualLowerCentrality, actualUpperCentrality) : "", + restrictJetPtAxis ? Form("_jetPt%.1f_%.1f", actualLowerJetPt, actualUpperJetPt) : "", + chargeString.Data()); + TFile *saveF = TFile::Open(saveFName.Data(), "RECREATE"); + saveF->cd(); + + if (hFractionElectrons) + hFractionElectrons->Write(0, TObject::kWriteDelete); + + if (hFractionKaons) + hFractionKaons->Write(0, TObject::kWriteDelete); + + if (hFractionPions) + hFractionPions->Write(0, TObject::kWriteDelete); + + if (hFractionProtons) + hFractionProtons->Write(0, TObject::kWriteDelete); + + if (hFractionMuons) + hFractionMuons->Write(0, TObject::kWriteDelete); + + if (hFractionSummed) + hFractionSummed->Write(0, TObject::kWriteDelete); + + if (hFractionElectronsMC) + hFractionElectronsMC->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsMC) + hFractionKaonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionPionsMC) + hFractionPionsMC->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsMC) + hFractionMuonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsMC) + hFractionProtonsMC->Write(0, TObject::kWriteDelete); + + + if (hYieldElectrons) + hYieldElectrons->Write(0, TObject::kWriteDelete); + + if (hYieldKaons) + hYieldKaons->Write(0, TObject::kWriteDelete); + + if (hYieldPions) + hYieldPions->Write(0, TObject::kWriteDelete); + + if (hYieldProtons) + hYieldProtons->Write(0, TObject::kWriteDelete); + + if (hYieldMuons) + hYieldMuons->Write(0, TObject::kWriteDelete); + + if (hYieldElectronsMC) + hYieldElectronsMC->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsMC) + hYieldMuonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsMC) + hYieldKaonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldPionsMC) + hYieldPionsMC->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsMC) + hYieldProtonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldSummedMC) + hYieldSummedMC->Write(0, TObject::kWriteDelete); + + + if (hRatioToPiElectrons) + hRatioToPiElectrons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiMuons) + hRatioToPiMuons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiKaons) + hRatioToPiKaons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiProtons) + hRatioToPiProtons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiElectronsMC) + hRatioToPiElectronsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiMuonsMC) + hRatioToPiMuonsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiKaonsMC) + hRatioToPiKaonsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiProtonsMC) + hRatioToPiProtonsMC->Write(0, TObject::kWriteDelete); + + + // Dummy histo to create generic legend entries from + TH1D* hMCmuonsAndPionsDummy = 0x0; + if (plotIdentifiedSpectra && firstValidSlice >= 0) { + hMCmuonsAndPionsDummy = new TH1D(*hDeltaPiMC[firstValidSlice][kPi]); + hMCmuonsAndPionsDummy->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPionsDummy->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPionsDummy->SetName("hMCmuonsAndPionsDummy"); + } + + + muonFractionThresholdForFitting = 0.;//OLD 0.295; + muonFractionThresholdBinForFitting = (mode == kPMpT) ? FindMomentumBin(binsPt, muonFractionThresholdForFitting) : -1; + + electronFractionThresholdForFitting = 9.; + electronFractionThresholdBinForFitting = (mode == kPMpT) ? FindMomentumBin(binsPt, electronFractionThresholdForFitting) : -1; + + lastPtForCallOfGetElectronFraction = pHigh + 10.; // Make sure that this value is higher than in any call during the fit + + fElectronFraction = new TF1("fElectronFraction", Form("[0]+(x<%f)*[1]*(x-%f)", electronFractionThresholdForFitting, + electronFractionThresholdForFitting), + pLow, pHigh); + fElectronFraction->SetParameters(0.01, 0.0); + + + + TString speciesLabel[4] = {"El", "Ka", "Pi", "Pr" }; + + const Double_t binWidthFitHisto = 1.0; // Not used any longer + + // In case of regularisation, the actual number of x bins and the (for pT: logs of their) bin centres are required + Int_t numXBins = 0; + Double_t* xBinCentres = 0x0; + Double_t* xBinStatisticalWeight = 0x0; + Double_t* xBinStatisticalWeightError = 0x0; + + // Set the number of parameters per x bin: + // Regularisation only implemented for simultaneous fit. + const Int_t numParamsPerXbin = AliPID::kSPECIES + 1; // Fractions of each species + total yield in x bin + + // Construct the array of all the parameters that are to be regularised, i.e. only the FREE fractions + // and NOT the total yields or the x bin + Int_t nParToRegulariseSimultaneousFit = 0; + Int_t* indexParametersToRegularise = 0x0; + Int_t* lastNotFixedIndexOfParameters = 0x0; + + if (regularisation > 0) { + Int_t xBinIndexTemp = 0; + Int_t internalParIndexTemp = 0; + + // Loop twice over data: Determine the number of bins in the first iteration, allocate the memory and fill in the 2. iteration + for (Int_t i = 0; i < 2; i++) { + if (i == 1) { + if (numXBins == 0) { + printf("No bins for fitting! Exiting...\n"); + + return -1; + } + if (nParToRegulariseSimultaneousFit == 0) { + printf("No parameters to regularise! Exiting...\n"); + + return -1; + } + + xBinCentres = new Double_t[numXBins]; + xBinStatisticalWeight = new Double_t[numXBins]; + xBinStatisticalWeightError = new Double_t[numXBins]; + + indexParametersToRegularise = new Int_t[nParToRegulariseSimultaneousFit]; + + lastNotFixedIndexOfParameters = new Int_t[numParamsPerXbin]; + + // Set last not fixed index of parameter to numXBins, i.e. a index larger than any existing index. + // This will not restrict the parameter regularisation range. In the following, the range for electrons + // and muons will be restricted + for (Int_t iPar = 0; iPar < numParamsPerXbin; iPar++) + lastNotFixedIndexOfParameters[iPar] = numXBins; + } + + + for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { + if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) + continue; + + // There won't (actually: shouldn't) be tracks with a pT larger than the jet pT + if (mode == kPMpT && restrictJetPtAxis && binsPt[slice] >= actualUpperJetPt) + continue; + + const Int_t pBinLowProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; + const Int_t pBinUpProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; + + // NOTE: In case of regularisation, only the simultaneous fit values will be used, i.e. totalYield and not allDeltaSpecies! + + // Also take into account bin width in delta(Prime) plots -> Multiply by binWidthFitHisto + Double_t totalYieldError = 0; + const Double_t totalYield = binWidthFitHisto * hYieldPt->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, totalYieldError); + totalYieldError *= binWidthFitHisto; + + if (totalYield <= 0) + continue; + + if (i == 1) { + if (mode == kPMpT) + // Take the logarithm in case of pT + xBinCentres[xBinIndexTemp] = TMath::Log((binsPt[slice + 1] + binsPt[slice]) / 2.); + else + xBinCentres[xBinIndexTemp] = hFractionPions->GetXaxis()->GetBinCenter(slice + 1); + + xBinStatisticalWeight[xBinIndexTemp] = totalYield; + + // NOTE: The total yield is a fact - a number w/o error. However, one assigns this error here to use it + // to calculate the effective weighting for the weighted likelihood fit (and the error is only used for this). + // So, it is more like a weighting than an error... + xBinStatisticalWeightError[xBinIndexTemp] = totalYieldError; + + + // Mark the fractions for all species except for electrons and muons in this bin for regularisation + for (Int_t speciesIndex = 0; speciesIndex < AliPID::kSPECIES - 2; speciesIndex++) + indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + speciesIndex; + + // Also mark electrons for regularisation in this bin, if not fixed + if( !(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) ) { + indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + 3; + } + else { + // Set the index of the last x bin in which the parameter is not fixed. + // If the parameter is fixed in all x bins, this index will be -1. + if (xBinIndexTemp - 1 < lastNotFixedIndexOfParameters[3]) + lastNotFixedIndexOfParameters[3] = xBinIndexTemp - 1; + } + + // Also mark muons for regularisation in this bin, if not fixed + if( !(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) ) { + indexParametersToRegularise[internalParIndexTemp++] = numParamsPerXbin * xBinIndexTemp + 4; + } + else { + // Set the index of the last x bin in which the parameter is not fixed. + // If the parameter is fixed in all x bins, this index will be -1. + if (xBinIndexTemp - 1 < lastNotFixedIndexOfParameters[4]) + lastNotFixedIndexOfParameters[4] = xBinIndexTemp - 1; + } + + xBinIndexTemp++; + } + + if (i == 0) { + nParToRegulariseSimultaneousFit += AliPID::kSPECIES - 2; // Fracs for all species in this bin except for electrons and muons + + if( !(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) ) + nParToRegulariseSimultaneousFit++; // Also regularise electrons in this bin (not fixed) + + if( !(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) ) + nParToRegulariseSimultaneousFit++; // Also regularise muons in this bin (not fixed) + + numXBins++; + } + } + } + } + AliTPCPIDmathFit* mathFit = 0x0; + + if (regularisation > 0) { + mathFit = (fitMethod == 2) ? AliTPCPIDmathFit::Instance(numXBins, 4, 1810) + : AliTPCPIDmathFit::Instance(numXBins, 1, 1810); + } + else { + mathFit = (fitMethod == 2) ? AliTPCPIDmathFit::Instance(1, 4, 1810) + : AliTPCPIDmathFit::Instance(1, 1, 1810); + } + + mathFit->SetDebugLevel(0); + mathFit->SetEpsilon(5e-05); + mathFit->SetMaxCalls(1e8); + + mathFit->SetMinimisationStrategy(minimisationStrategy); + + mathFit->SetUseLogLikelihood(useLogLikelihood); + mathFit->SetUseWeightsForLogLikelihood(useWeightsForLogLikelihood); + + if (fitMethod == 2) { + // If the deltaPrime range is large enough, we artificially get a factor 4 in statistics by looking at the four + // different deltaPrimeSpecies, which have (except for binning effects) the same information. + // Therefore, to get the "real" statistical error, we need to multiply the obtained error by sqrt(4) = 2 + mathFit->SetScaleFactorError(2.); + } + + mathFit->SetRegularisation(regularisation, regularisationFactor); + + // Number of parameters for fitting + const Int_t nPar = 11; + + // Fracs of each species + total yield in x bin + const Int_t nParSimultaneousFit = AliPID::kSPECIES + 1; + + // Fracs of each species in x bin + tot yield in x bin + const Int_t nParSimultaneousFitRegularised = numXBins * (AliPID::kSPECIES + 1); + + if (regularisation > 0) { + if (!mathFit->SetParametersToRegularise(nParToRegulariseSimultaneousFit, numParamsPerXbin, indexParametersToRegularise, + lastNotFixedIndexOfParameters, xBinCentres, xBinStatisticalWeight, + xBinStatisticalWeightError)) + return -1; + } + + delete xBinCentres; + xBinCentres = 0x0; + + delete xBinStatisticalWeight; + xBinStatisticalWeight = 0x0; + + delete xBinStatisticalWeightError; + xBinStatisticalWeight = 0x0; + + delete indexParametersToRegularise; + indexParametersToRegularise = 0x0; + + delete lastNotFixedIndexOfParameters; + lastNotFixedIndexOfParameters = 0x0; + + + + gFractionElectronsData = new TGraphErrors(numXBins); + + // Fit each slice with sum of 4/5 shapes with means and sigmas fixed from last fitting step + // For electrons: Fit up to certain pT bin and use constant value for higher momenta + + // Two iterations required for regularisation + Bool_t regularisedFitDone = kFALSE; + Double_t reducedChiSquareRegularisation = -1; + + Double_t gausParamsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; + Double_t parameterErrorsOutRegularised[nParSimultaneousFitRegularised]; + Double_t lowParLimitsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; + Double_t upParLimitsSimultaneousFitRegularised[nParSimultaneousFitRegularised]; + Double_t stepSizeSimultaneousFitRegularised[nParSimultaneousFitRegularised]; + + for (Int_t i = 0; i < nParSimultaneousFitRegularised; i++) { + gausParamsSimultaneousFitRegularised[i] = 0; + parameterErrorsOutRegularised[i] = 0; + lowParLimitsSimultaneousFitRegularised[i] = 0; + upParLimitsSimultaneousFitRegularised[i] = 0; + stepSizeSimultaneousFitRegularised[i] = 0; + } + + mathFit->ClearRefHistos(); + + + const Int_t nParUsed = (fitMethod == 2) ? ((regularisation <= 0) ? nParSimultaneousFit: nParSimultaneousFitRegularised) : nPar; + Double_t parameterErrorsOut[nParUsed]; + Double_t covMatrix[nParUsed][nParUsed]; + + for (Int_t iter = 0; iter < 2; iter++) { + if (regularisation <= 0 && iter == 0) + continue; // Only one iteration w/o regularisation + + Int_t currXbin = 0; + + for (Int_t slice = 0; (mode == kPMpT) ? slice < nPtBins : slice < hFractionPions->GetXaxis()->GetNbins(); slice++) { + if (mode == kPMpT && (slice < pSliceLow || slice > pSliceHigh)) + continue; + + // There won't (actually: shouldn't) be tracks with a pT larger than the jet pT + if (mode == kPMpT && restrictJetPtAxis && binsPt[slice] >= actualUpperJetPt) + continue; + + if (regularisation <= 0) { + if (mode == kPMpT) + std::cout << "Fitting range " << binsPt[slice] << " GeV/c < Pt < " << binsPt[slice + 1] << " GeV/c..." << std::endl; + else { + std::cout << "Fitting range " << hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1) << " < " << modeShortName[mode].Data() << " < "; + std::cout << hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1) << "..." << std::endl; + } + } + + // Add/subtract some very small offset to be sure not to sit on the bin boundary, when looking for the integration/projection limits. + const Int_t pBinLowProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice] + 1e-5) : slice + 1; + const Int_t pBinUpProjLimit = (mode == kPMpT) ? hYieldPt->GetXaxis()->FindBin(binsPt[slice + 1]- 1e-5) : slice + 1; + + // Also take into account bin width in delta(Prime) plots -> Multiply by binWidthFitHisto + const Double_t totalYield = binWidthFitHisto * hYieldPt->Integral(pBinLowProjLimit, pBinUpProjLimit); + + if (totalYield <= 0) { + std::cout << "Skipped bin (yield is zero)!" << std::endl; + continue; + } + + const Double_t allDeltaPion = hDeltaPi[slice]->Integral(); + const Double_t allDeltaElectron = hDeltaEl[slice]->Integral(); + const Double_t allDeltaKaon = hDeltaKa[slice]->Integral(); + const Double_t allDeltaProton = hDeltaPr[slice]->Integral(); + + // inverseBinWidth = 1.0, if the raw yield for each bin is requested. + // If divided by the bin size, the histograms give "yield per unit pT in the corresponding bin" or dN/dpT + Double_t inverseBinWidth = (mode == kPMpT) ? 1.0 / (binsPt[slice + 1] - binsPt[slice]) + : 1.0 / hYieldPt->GetBinWidth(slice + 1); + + TH1D *hGenDeltaElForElProj = 0x0, *hGenDeltaKaForElProj = 0x0, *hGenDeltaPiForElProj = 0x0, *hGenDeltaPrForElProj = 0x0; + TH1D *hGenDeltaElForKaProj = 0x0, *hGenDeltaKaForKaProj = 0x0, *hGenDeltaPiForKaProj = 0x0, *hGenDeltaPrForKaProj = 0x0; + TH1D *hGenDeltaElForPiProj = 0x0, *hGenDeltaKaForPiProj = 0x0, *hGenDeltaPiForPiProj = 0x0, *hGenDeltaPrForPiProj = 0x0; + TH1D *hGenDeltaElForMuProj = 0x0, *hGenDeltaKaForMuProj = 0x0, *hGenDeltaPiForMuProj = 0x0, *hGenDeltaPrForMuProj = 0x0; + TH1D *hGenDeltaElForPrProj = 0x0, *hGenDeltaKaForPrProj = 0x0, *hGenDeltaPiForPrProj = 0x0, *hGenDeltaPrForPrProj = 0x0; + + TH2D* hGenDeltaUsed[6][6]; + if (useIdentifiedGeneratedSpectra) { + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { + hGenDeltaUsed[i][j] = hGenDeltaMCid[i][j]; + } + } + } + else { + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { + hGenDeltaUsed[i][j] = hGenDelta[i][j]; + } + } + } + + hGenDeltaElForElProj =(TH1D*)hGenDeltaUsed[kEl][kEl]->ProjectionY(Form("hGenDeltaElForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaKaForElProj =(TH1D*)hGenDeltaUsed[kKa][kEl]->ProjectionY(Form("hGenDeltaKaForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPiForElProj =(TH1D*)hGenDeltaUsed[kPi][kEl]->ProjectionY(Form("hGenDeltaPiForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPrForElProj =(TH1D*)hGenDeltaUsed[kPr][kEl]->ProjectionY(Form("hGenDeltaPrForElProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + + hGenDeltaElForKaProj =(TH1D*)hGenDeltaUsed[kEl][kKa]->ProjectionY(Form("hGenDeltaElForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaKaForKaProj =(TH1D*)hGenDeltaUsed[kKa][kKa]->ProjectionY(Form("hGenDeltaKaForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPiForKaProj =(TH1D*)hGenDeltaUsed[kPi][kKa]->ProjectionY(Form("hGenDeltaPiForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPrForKaProj =(TH1D*)hGenDeltaUsed[kPr][kKa]->ProjectionY(Form("hGenDeltaPrForKaProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + + hGenDeltaElForPiProj =(TH1D*)hGenDeltaUsed[kEl][kPi]->ProjectionY(Form("hGenDeltaElForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaKaForPiProj =(TH1D*)hGenDeltaUsed[kKa][kPi]->ProjectionY(Form("hGenDeltaKaForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPiForPiProj =(TH1D*)hGenDeltaUsed[kPi][kPi]->ProjectionY(Form("hGenDeltaPiForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPrForPiProj =(TH1D*)hGenDeltaUsed[kPr][kPi]->ProjectionY(Form("hGenDeltaPrForPiProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + + if (takeIntoAccountMuons) { + hGenDeltaElForMuProj =(TH1D*)hGenDeltaUsed[kEl][kMu]->ProjectionY(Form("hGenDeltaElForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaKaForMuProj =(TH1D*)hGenDeltaUsed[kKa][kMu]->ProjectionY(Form("hGenDeltaKaForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPiForMuProj =(TH1D*)hGenDeltaUsed[kPi][kMu]->ProjectionY(Form("hGenDeltaPiForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPrForMuProj =(TH1D*)hGenDeltaUsed[kPr][kMu]->ProjectionY(Form("hGenDeltaPrForMuProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + } + + hGenDeltaElForPrProj =(TH1D*)hGenDeltaUsed[kEl][kPr]->ProjectionY(Form("hGenDeltaElForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaKaForPrProj =(TH1D*)hGenDeltaUsed[kKa][kPr]->ProjectionY(Form("hGenDeltaKaForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPiForPrProj =(TH1D*)hGenDeltaUsed[kPi][kPr]->ProjectionY(Form("hGenDeltaPiForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + hGenDeltaPrForPrProj =(TH1D*)hGenDeltaUsed[kPr][kPr]->ProjectionY(Form("hGenDeltaPrForPrProj%d", slice), pBinLowProjLimit, pBinUpProjLimit, "e"); + + + + if (fitMethod == 2) { + // Normalise generated histos to TOTAL number of GENERATED particles for this species (i.e. including + // entries that lie in the under or overflow bin), so that situations in which the generated spectra lie + // at least partly outside the histo are treated properly. To find the total number of generated particle + // species X, one can just take the integral of the generated histo for DeltaX (which should include all + // generated entries) and apply the same normalisation factor to all other DeltaSpecies. + // Also set some cosmetics + + // Generated electrons + Double_t normEl = normaliseHist(hGenDeltaElForElProj, -1); + normaliseHist(hGenDeltaKaForElProj, normEl); + normaliseHist(hGenDeltaPiForElProj, normEl); + normaliseHist(hGenDeltaPrForElProj, normEl); + + + // Generated kaons + Double_t normKa = normaliseHist(hGenDeltaKaForKaProj, -1); + normaliseHist(hGenDeltaElForKaProj, normKa); + normaliseHist(hGenDeltaPiForKaProj, normKa); + normaliseHist(hGenDeltaPrForKaProj, normKa); + + + // Generated pions + Double_t normPi = normaliseHist(hGenDeltaPiForPiProj, -1); + normaliseHist(hGenDeltaElForPiProj, normPi); + normaliseHist(hGenDeltaKaForPiProj, normPi); + normaliseHist(hGenDeltaPrForPiProj, normPi); + + + Double_t normMu = 1; + if (takeIntoAccountMuons) { + // Generated pions + // Since masses of muons and pions are so similar, the normalisation scheme should still work when looking at deltaPion instead + normMu = normaliseHist(hGenDeltaPiForMuProj, -1); + normaliseHist(hGenDeltaElForMuProj, normMu); + normaliseHist(hGenDeltaKaForMuProj, normMu); + normaliseHist(hGenDeltaPrForMuProj, normMu); + } + + + // Generated protons + Double_t normPr = normaliseHist(hGenDeltaPrForPrProj, -1); + normaliseHist(hGenDeltaElForPrProj, normPr); + normaliseHist(hGenDeltaKaForPrProj, normPr); + normaliseHist(hGenDeltaPiForPrProj, normPr); + } + else { + // Normalise generated histos to total number of particles for this delta + // and also set some cosmetics + + // DeltaEl + normaliseHist(hGenDeltaElForElProj); + normaliseHist(hGenDeltaElForKaProj); + normaliseHist(hGenDeltaElForPiProj); + if (takeIntoAccountMuons) + normaliseHist(hGenDeltaElForMuProj); + normaliseHist(hGenDeltaElForPrProj); + + // DeltaKa + normaliseHist(hGenDeltaKaForElProj); + normaliseHist(hGenDeltaKaForKaProj); + normaliseHist(hGenDeltaKaForPiProj); + if (takeIntoAccountMuons) + normaliseHist(hGenDeltaKaForMuProj); + normaliseHist(hGenDeltaKaForPrProj); + + // DeltaPi + normaliseHist(hGenDeltaPiForElProj); + normaliseHist(hGenDeltaPiForKaProj); + normaliseHist(hGenDeltaPiForPiProj); + if (takeIntoAccountMuons) + normaliseHist(hGenDeltaPiForMuProj); + normaliseHist(hGenDeltaPiForPrProj); + + // DeltaPr + normaliseHist(hGenDeltaPrForElProj); + normaliseHist(hGenDeltaPrForKaProj); + normaliseHist(hGenDeltaPrForPiProj); + if (takeIntoAccountMuons) + normaliseHist(hGenDeltaPrForMuProj); + normaliseHist(hGenDeltaPrForPrProj); + } + + + TF1* totalDeltaPion = 0x0; + TF1* totalDeltaKaon = 0x0; + TF1* totalDeltaProton = 0x0; + TF1* totalDeltaElectron = 0x0; + + TLegend* legend = 0x0; + + if (iter == 1) { // Only needed for second iteration (= the only iteration w/o regularisation) + // The number of parameters and their values will always be adjusted, such that using nPar parameters is fine + totalDeltaPion = new TF1(Form("totalDeltaPion_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaPi : multiGaussFit, + xLow, xUp, nPar); + setUpFitFunction(totalDeltaPion, nBins); + + totalDeltaKaon = new TF1(Form("totalDeltaKaon_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaKa : multiGaussFit, + xLow, xUp, nPar); + setUpFitFunction(totalDeltaKaon, nBins); + + totalDeltaProton = new TF1(Form("totalDeltaProton_slice%d", slice), (fitMethod == 2) ? multiGaussFitDeltaPr : multiGaussFit, + xLow, xUp, nPar); + setUpFitFunction(totalDeltaProton, nBins); + + totalDeltaElectron = new TF1(Form("totalDeltaElectron_slice%d", slice), + (fitMethod == 2) ? multiGaussFitDeltaEl : multiGaussFit, + xLow, xUp, nPar); + setUpFitFunction(totalDeltaElectron, nBins); + + // Legend is the same for all \Delta "species" plots + legend = new TLegend(0.722126, 0.605932, 0.962069, 0.925932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + if (plotIdentifiedSpectra) + legend->SetNColumns(2); + legend->AddEntry((TObject*)0x0, "Fit", ""); + if (plotIdentifiedSpectra) + legend->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); + + legend->AddEntry(hDeltaPi[slice], "Data", "Lp"); + if (plotIdentifiedSpectra) + legend->AddEntry((TObject*)0x0, "", ""); + + legend->AddEntry(totalDeltaPion, "Multi-template fit", "L"); + if (plotIdentifiedSpectra) + legend->AddEntry(hMCmuonsAndPionsDummy, "#mu + #pi", "Lp"); + + if (takeIntoAccountMuons) + legend->AddEntry(hGenDeltaPiForMuProj, "#mu", "Lp"); + else if (plotIdentifiedSpectra) + legend->AddEntry((TObject*)0x0, "", ""); + if (plotIdentifiedSpectra) + legend->AddEntry(hDeltaPiMC[slice][kMu - 1], "#mu", "Lp"); + + legend->AddEntry(hGenDeltaPiForPiProj, takeIntoAccountMuons ? "#pi" : "#pi + #mu", "Lp"); + if (plotIdentifiedSpectra) + legend->AddEntry(hDeltaPiMC[slice][kPi - 1], "#pi", "Lp"); + + legend->AddEntry(hGenDeltaPiForKaProj, "K", "Lp"); + if (plotIdentifiedSpectra) + legend->AddEntry(hDeltaPiMC[slice][kKa - 1], "K", "Lp"); + + legend->AddEntry(hGenDeltaPiForPrProj, "p", "Lp"); + if (plotIdentifiedSpectra) + legend->AddEntry(hDeltaPiMC[slice][kPr - 1], "p", "Lp"); + + legend->AddEntry(hGenDeltaPiForElProj, "e", "Lp"); + if (plotIdentifiedSpectra) + legend->AddEntry(hDeltaPiMC[slice][kEl -1], "e", "Lp"); + } + + + // Allow tolerance of +-2% (for delta -> assume dEdx = 80 and take +-2%) + //const Double_t peakTolerance = (useDeltaPrime ? 0.8 : 1.0) / hGenDeltaElForElProj->GetXaxis()->GetBinWidth(1); + //const Double_t shiftStepSize = 0.01; + const Double_t peakTolerance = (useDeltaPrime ? 0.02 : 1.6); + const Double_t shiftStepSize = 0.01; + + // Assume fractions vs. pT to be smooth. Allow 1 sigma variations from bin to bin. For small pT, the error will be very small. + // Therefore, allow at least a change of some percent. + const Double_t nSigma = 1.; + const Double_t minChange = 1.0; // This disables the sigma restriction + + Double_t fractionPions = (muonContamination ? 0.87 : 0.88); + + Double_t fractionErrorUpPions = 1.; + Double_t fractionErrorLowPions = 0.; + + Int_t xBinInit = 0; + if (initialiseWithFractionsFromFile) { + Double_t xBinCentre = (mode == kPMpT) ? (binsPt[slice + 1] + binsPt[slice]) / 2. + : hYieldPt->GetXaxis()->GetBinCenter(slice + 1); + xBinInit = hInitFracPi->GetXaxis()->FindBin(xBinCentre); + fractionPions = hInitFracPi->GetBinContent(xBinInit) + (muonContamination ? hInitFracMu->GetBinContent(xBinInit) : 0.); + } + else { + // Set found fraction from last slice, if available. Note: Current bin for slice = slice + 1 + // => Bin for last slice = slice + if (hFractionPions->GetBinContent(slice) > 0 && hFractionPions->GetBinError(slice) > 0) { + fractionPions = hFractionPions->GetBinContent(slice); + fractionErrorUpPions = TMath::Min(1.0, fractionPions + TMath::Max(minChange, nSigma * hFractionPions->GetBinError(slice))); + fractionErrorLowPions = TMath::Max(0.0, fractionPions - TMath::Max(minChange, nSigma * hFractionPions->GetBinError(slice))); + } + } + + Double_t fractionKaons = 0.08; + Double_t fractionErrorUpKaons = 1.; + Double_t fractionErrorLowKaons = 0.; + + if (initialiseWithFractionsFromFile) { + fractionKaons = hInitFracKa->GetBinContent(xBinInit); + } + else { + if (hFractionKaons->GetBinContent(slice) > 0 && hFractionKaons->GetBinError(slice) > 0) { + fractionKaons = hFractionKaons->GetBinContent(slice); + fractionErrorUpKaons = TMath::Min(1.0, fractionKaons + TMath::Max(minChange, nSigma * hFractionKaons->GetBinError(slice))); + fractionErrorLowKaons = TMath::Max(0.0, fractionKaons - TMath::Max(minChange, nSigma * hFractionKaons->GetBinError(slice))); + } + } + + Double_t fractionProtons = 0.02; + Double_t fractionErrorUpProtons = 1.; + Double_t fractionErrorLowProtons = 0.; + + if (initialiseWithFractionsFromFile) { + fractionProtons = hInitFracPr->GetBinContent(xBinInit); + } + else { + if (hFractionProtons->GetBinContent(slice) > 0 && hFractionProtons->GetBinError(slice) > 0) { + fractionProtons = hFractionProtons->GetBinContent(slice); + fractionErrorUpProtons = TMath::Min(1.0, fractionProtons + + TMath::Max(minChange, nSigma * hFractionProtons->GetBinError(slice))); + fractionErrorLowProtons = TMath::Max(0.0, fractionProtons - + TMath::Max(minChange, nSigma * hFractionProtons->GetBinError(slice))); + } + } + + Double_t fractionElectrons = (takeIntoAccountMuons ? 0.01 : 0.02); + Double_t fractionErrorUpElectrons = 1.; + Double_t fractionErrorLowElectrons = 0.; + + if (initialiseWithFractionsFromFile) { + fractionElectrons = hInitFracEl->GetBinContent(xBinInit); + } + else { + if (hFractionElectrons->GetBinContent(slice) > 0 && hFractionElectrons->GetBinError(slice) > 0) { + fractionElectrons = hFractionElectrons->GetBinContent(slice); + fractionErrorUpElectrons = TMath::Min(1.0, fractionElectrons + + TMath::Max(minChange, nSigma * hFractionElectrons->GetBinError(slice))); + fractionErrorLowElectrons = TMath::Max(0.0, fractionElectrons - + TMath::Max(minChange, nSigma * hFractionElectrons->GetBinError(slice))); + } + } + + Double_t fractionMuons = (takeIntoAccountMuons ? 0.01 : 0.); + Double_t fractionErrorUpMuons = 1.; + Double_t fractionErrorLowMuons = 0.; + if (!takeIntoAccountMuons) { + fractionErrorUpMuons = 0.; + fractionErrorLowMuons = 0.; + } + else { + if (initialiseWithFractionsFromFile) { + fractionMuons = hInitFracMu->GetBinContent(xBinInit); + } + else { + if (hFractionMuons->GetBinContent(slice) > 0 && hFractionMuons->GetBinError(slice) > 0) { + fractionMuons = hFractionMuons->GetBinContent(slice); + fractionErrorUpMuons = TMath::Min(1.0, fractionMuons + TMath::Max(minChange, nSigma * hFractionMuons->GetBinError(slice))); + fractionErrorLowMuons = TMath::Max(0.0, fractionMuons - TMath::Max(minChange, nSigma * hFractionMuons->GetBinError(slice))); + } + } + } + + Double_t gausParamsPi[nPar] = { + fractionPions, + fractionKaons, + fractionProtons, + fractionElectrons, + fractionMuons, + allDeltaPion, + 0, + 0, + 0, + 0, + 0 + }; + + Double_t gausParamsEl[nPar] = { + fractionPions, + fractionKaons, + fractionProtons, + fractionElectrons, + fractionMuons, + allDeltaElectron, + 0, + 0, + 0, + 0, + 0 + }; + + Double_t gausParamsKa[nPar] = { + fractionPions, + fractionKaons, + fractionProtons, + fractionElectrons, + fractionMuons, + allDeltaKaon, + 0, + 0, + 0, + 0, + 0 + }; + + Double_t gausParamsPr[nPar] = { + fractionPions, + fractionKaons, + fractionProtons, + fractionElectrons, + fractionMuons, + allDeltaProton, + 0, + 0, + 0, + 0, + 0 + }; + + Double_t lowParLimitsPi[nPar] = { + fractionErrorLowPions, + fractionErrorLowKaons, + fractionErrorLowProtons, + fractionErrorLowElectrons, + fractionErrorLowMuons, + allDeltaPion, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance + }; + + Double_t lowParLimitsEl[nPar] = { + fractionErrorLowPions, + fractionErrorLowKaons, + fractionErrorLowProtons, + fractionErrorLowElectrons, + fractionErrorLowMuons, + allDeltaElectron, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance + }; + + Double_t lowParLimitsKa[nPar] = { + fractionErrorLowPions, + fractionErrorLowKaons, + fractionErrorLowProtons, + fractionErrorLowElectrons, + fractionErrorLowMuons, + allDeltaKaon, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance + }; + + Double_t lowParLimitsPr[nPar] = { + fractionErrorLowPions, + fractionErrorLowKaons, + fractionErrorLowProtons, + fractionErrorLowElectrons, + fractionErrorLowMuons, + allDeltaProton, + -peakTolerance, + -peakTolerance, + -peakTolerance, + -peakTolerance + -peakTolerance + }; + + + Double_t upParLimitsPi[nPar] = { + fractionErrorUpPions, + fractionErrorUpKaons, + fractionErrorUpProtons, + fractionErrorUpElectrons, + fractionErrorUpMuons, + allDeltaPion, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance + }; + + Double_t upParLimitsEl[nPar] = { + fractionErrorUpPions, + fractionErrorUpKaons, + fractionErrorUpProtons, + fractionErrorUpElectrons, + fractionErrorUpMuons, + allDeltaElectron, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance + }; + + Double_t upParLimitsKa[nPar] = { + fractionErrorUpPions, + fractionErrorUpKaons, + fractionErrorUpProtons, + fractionErrorUpElectrons, + fractionErrorUpMuons, + allDeltaKaon, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance + }; + + Double_t upParLimitsPr[nPar] = { + fractionErrorUpPions, + fractionErrorUpKaons, + fractionErrorUpProtons, + fractionErrorUpElectrons, + fractionErrorUpMuons, + allDeltaProton, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance, + peakTolerance, + }; + + Double_t stepSize[nPar] = { + 0.1, + 0.1, + 0.1, + 0.1, + (takeIntoAccountMuons ? 0.1 : 0.), + + 0.0, + + enableShift ? shiftStepSize : 0., + enableShift ? shiftStepSize : 0., + enableShift ? shiftStepSize : 0., + enableShift ? shiftStepSize : 0., + (enableShift && takeIntoAccountMuons) ? shiftStepSize : 0. + }; + + + Double_t gausParamsSimultaneousFit[nParSimultaneousFit] = { + fractionPions, + fractionKaons, + fractionProtons, + fractionElectrons, + fractionMuons, + totalYield + // No shifts because they do not make too much sense (different eta + possible deviations from Bethe-Bloch in one x-Bin) + }; + + Double_t lowParLimitsSimultaneousFit[nParSimultaneousFit] = { + fractionErrorLowPions, + fractionErrorLowKaons, + fractionErrorLowProtons, + fractionErrorLowElectrons, + fractionErrorLowMuons, + totalYield + }; + + Double_t upParLimitsSimultaneousFit[nParSimultaneousFit] = { + fractionErrorUpPions, + fractionErrorUpKaons, + fractionErrorUpProtons, + fractionErrorUpElectrons, + fractionErrorUpMuons, + totalYield + }; + + Double_t stepSizeSimultaneousFit[nParSimultaneousFit] = { + 0.1, + 0.1, + 0.1, + 0.1, + (takeIntoAccountMuons ? 0.1 : 0.), + + 0.0 + }; + + if (regularisation <= 0 && iter == 1) { + // In case of no regularisation, do the fit of the electron fraction here (compare comment below) + if (mode == kPMpT && slice == electronFractionThresholdBinForFitting) + hFractionElectrons->Fit(fElectronFraction, "N", "", lowFittingBoundElectronFraction, electronFractionThresholdForFitting); + } + + if ((regularisation > 0 && iter == 0) || (regularisation <= 0 && iter == 1)) { + // Set the electron fraction to the negative pT -> A function will be used + // to evaluate the electron fraction for each bin above the threshold + if(mode == kPMpT && slice >= electronFractionThresholdBinForFitting) { + // In case of no regularisation, mathFit has no information about the fraction of other x bins. + // Thus, the electron fraction is evaluated and set here. For the case w/ regularisation, + // just "-pT" is set and the electron fraction will be evaluated during the fit. + Double_t fixElectronFraction = (regularisation <= 0) ? fElectronFraction->Eval((binsPt[slice + 1] + binsPt[slice]) / 2.) + : -(binsPt[slice + 1] + binsPt[slice]) / 2.; + + if (regularisation <= 0) { + fixElectronFraction = TMath::Min(1.0, fixElectronFraction); + fixElectronFraction = TMath::Max(0.0, fixElectronFraction); + } + + gausParamsPi[3] = fixElectronFraction; + lowParLimitsPi[3] = fixElectronFraction; + upParLimitsPi[3] = fixElectronFraction; + + gausParamsEl[3] = fixElectronFraction; + lowParLimitsEl[3] = fixElectronFraction; + upParLimitsEl[3] = fixElectronFraction; + + gausParamsKa[3] = fixElectronFraction; + lowParLimitsKa[3] = fixElectronFraction; + upParLimitsKa[3] = fixElectronFraction; + + gausParamsPr[3] = fixElectronFraction; + lowParLimitsPr[3] = fixElectronFraction; + upParLimitsPr[3] = fixElectronFraction; + + stepSize[3] = 0.0; + + gausParamsSimultaneousFit[3] = fixElectronFraction; + lowParLimitsSimultaneousFit[3] = fixElectronFraction; + upParLimitsSimultaneousFit[3] = fixElectronFraction; + + stepSizeSimultaneousFit[3] = 0.0; + } + + + // Set muon fraction equal to (some modified) electron fraction above some threshold, which should be a reasonable approximation: + // Fixed muon fraction < 0 does this job within the fitting functions + if(mode != kPMpT || slice >= muonFractionThresholdBinForFitting) { + // "Abuse" the muon fraction to forward the pT, which can then be used to get some modified electron fraction + const Double_t fixedValue = -(binsPt[slice] + binsPt[slice + 1]) / 2.; + gausParamsPi[4] = fixedValue; + lowParLimitsPi[4] = fixedValue; + upParLimitsPi[4] = fixedValue; + + gausParamsEl[4] = fixedValue; + lowParLimitsEl[4] = fixedValue; + upParLimitsEl[4] = fixedValue; + + gausParamsKa[4] = fixedValue; + lowParLimitsKa[4] = fixedValue; + upParLimitsKa[4] = fixedValue; + + gausParamsPr[4] = fixedValue; + lowParLimitsPr[4] = fixedValue; + upParLimitsPr[4] = fixedValue; + + stepSize[4] = 0.; + + gausParamsSimultaneousFit[4] = fixedValue; + lowParLimitsSimultaneousFit[4] = fixedValue; + upParLimitsSimultaneousFit[4] = fixedValue; + + stepSizeSimultaneousFit[4] = 0.0; + } + } + + // iter 0 used for initialisation + if (regularisation > 0 && iter == 0) { + const Int_t offset = currXbin * mathFit->GetNumParametersPerXbin(); + for (Int_t i = 0; i < mathFit->GetNumParametersPerXbin(); i++) { + gausParamsSimultaneousFitRegularised[offset + i] = gausParamsSimultaneousFit[i]; + lowParLimitsSimultaneousFitRegularised[offset + i] = lowParLimitsSimultaneousFit[i]; + upParLimitsSimultaneousFitRegularised[offset + i] = upParLimitsSimultaneousFit[i]; + stepSizeSimultaneousFitRegularised[offset + i] = stepSizeSimultaneousFit[i]; + } + } + + + if (iter == 1) { + // The parameters are only used for fitMethod < 2. Thus, they can be set for these methods, + // although a different method is used + totalDeltaPion->SetParameters(gausParamsPi); + totalDeltaElectron->SetParameters(gausParamsEl); + totalDeltaKaon->SetParameters(gausParamsKa); + totalDeltaProton->SetParameters(gausParamsPr); + } + + const TString binInfo = (mode == kPMpT) ? Form("%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) + : Form("%.2f_%s_%.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), + modeShortName[mode].Data(), hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); + + const TString binInfoTitle = (mode == kPMpT) ? Form("%.2f < Pt <%.2f", binsPt[slice], binsPt[slice + 1]) + : Form("%.2f < %s < %.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), + modeShortName[mode].Data(), + hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); + + const TString fitFuncSuffix = (mode == kPMpT) ? Form("%.3f_Pt_%.3f", binsPt[slice], binsPt[slice + 1]) + : Form("%.3f_%s_%.3f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), + modeShortName[mode].Data(), + hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); + + if (iter == 1) { + for (Int_t species = 0; species < 4; species++) { + cSingleFit[slice][species] = new TCanvas(Form("cSingleFit_%s_%s", binInfo.Data(), speciesLabel[species].Data()), + Form("single fit for %s (%s)", binInfoTitle.Data(), speciesLabel[species].Data()), + 1366, 768); + cSingleFit[slice][species]->Divide(1, 2, 0.01, 0.); + cSingleFit[slice][species]->GetPad(1)->SetRightMargin(0.001); + cSingleFit[slice][species]->GetPad(2)->SetRightMargin(0.001); + cSingleFit[slice][species]->GetPad(1)->SetTopMargin(0.001); + cSingleFit[slice][species]->GetPad(2)->SetTopMargin(0.01); + cSingleFit[slice][species]->GetPad(1)->SetBottomMargin(0.01); + + cSingleFit[slice][species]->GetPad(1)->SetGridx(kTRUE); + cSingleFit[slice][species]->GetPad(2)->SetGridx(kTRUE); + cSingleFit[slice][species]->GetPad(1)->SetGridy(kTRUE); + cSingleFit[slice][species]->GetPad(2)->SetGridy(kTRUE); + + cSingleFit[slice][species]->GetPad(1)->SetLogy(kTRUE); + cSingleFit[slice][species]->GetPad(1)->SetLogx(kTRUE); + cSingleFit[slice][species]->GetPad(2)->SetLogx(kTRUE); + } + } + + // Problem: For p < 0.5 GeV/c, the fractions cannot be simply taken from the parameters because + // not all entries of the histogram are inside the considered range. + // Also: Small deviations of summed fractions from one if taking the fractions from different Delta species histos. + // Therefore: Add up the integrals of the individual fits (\Delta species) and take the fraction of the sum + Double_t integralTotal = 0; + Double_t integralPions = 0, integralKaons = 0, integralProtons = 0, integralElectrons = 0, integralMuons = 0; + + Double_t integralPionsDeltaPion = 0, integralPionsDeltaElectron = 0, integralPionsDeltaKaon = 0, integralPionsDeltaProton = 0; + Double_t integralElectronsDeltaPion = 0, integralElectronsDeltaElectron = 0, integralElectronsDeltaKaon = 0, + integralElectronsDeltaProton = 0; + Double_t integralKaonsDeltaPion = 0, integralKaonsDeltaElectron = 0, integralKaonsDeltaKaon = 0, integralKaonsDeltaProton = 0; + Double_t integralProtonsDeltaPion = 0, integralProtonsDeltaElectron = 0, integralProtonsDeltaKaon = 0, + integralProtonsDeltaProton = 0; + Double_t integralMuonsDeltaPion = 0, integralMuonsDeltaElectron = 0, integralMuonsDeltaKaon = 0, integralMuonsDeltaProton = 0; + + /* + Double_t integralErrorPions = 0, integralErrorKaons = 0, integralErrorProtons = 0, integralErrorElectrons = 0; + + Double_t integralErrorPionsDeltaPion = 0, integralErrorPionsDeltaElectron = 0, integralErrorPionsDeltaKaon = 0, + integralErrorPionsDeltaProton = 0; + Double_t integralErrorElectronsDeltaPion = 0, integralErrorElectronsDeltaElectron = 0, integralErrorElectronsDeltaKaon = 0, + integralErrorElectronsDeltaProton = 0; + Double_t integralErrorKaonsDeltaPion = 0, integralErrorKaonsDeltaElectron = 0, integralErrorKaonsDeltaKaon = 0, + integralErrorKaonsDeltaProton = 0; + Double_t integralErrorProtonsDeltaPion = 0, integralErrorProtonsDeltaElectron = 0, integralErrorProtonsDeltaKaon = 0, + integralErrorProtonsDeltaProton = 0; + + Double_t integralErrorTotalDeltaPion = 0, integralErrorTotalDeltaElectron = 0, integralErrorTotalDeltaKaon = 0; + Double_t integralErrorTotalDeltaProton = 0; + */ + + Int_t errFlag = 0; + + // Reset temp arrays for next slice + for (Int_t ind = 0; ind < nParUsed; ind++) + parameterErrorsOut[ind] = 0; + + // Do not reset, if regularisation is on and the fit is done because the covariance matrix + // will not be changed anymore in this case. On the other hand it will only be calculated once, + // so resetting it would mean that is not available anymore. + if (regularisation <= 0 || !regularisedFitDone) { + for (Int_t i = 0; i < nParUsed; i++) { + for (Int_t j = 0; j < nParUsed; j++) { + covMatrix[i][j] = 0; + } + } + } + + Double_t reducedChiSquare = -1; + + if (fitMethod == 2) { + if (regularisation <= 0 && iter == 1) + std::cout << "Fitting data simultaneously...." << std::endl << std::endl; + + // Add ref histos in initialisation step (w/ reg) or in the only loop (w/o reg) + if ((regularisation > 0 && iter == 0) || (regularisation <= 0 && iter == 1)) { + + if (regularisation <= 0) + mathFit->ClearRefHistos(); + + mathFit->AddRefHisto(hGenDeltaPiForPiProj); + mathFit->AddRefHisto(hGenDeltaPiForKaProj); + mathFit->AddRefHisto(hGenDeltaPiForPrProj); + mathFit->AddRefHisto(hGenDeltaPiForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPiForMuProj); + + mathFit->AddRefHisto(hGenDeltaKaForPiProj); + mathFit->AddRefHisto(hGenDeltaKaForKaProj); + mathFit->AddRefHisto(hGenDeltaKaForPrProj); + mathFit->AddRefHisto(hGenDeltaKaForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaKaForMuProj); + + mathFit->AddRefHisto(hGenDeltaPrForPiProj); + mathFit->AddRefHisto(hGenDeltaPrForKaProj); + mathFit->AddRefHisto(hGenDeltaPrForPrProj); + mathFit->AddRefHisto(hGenDeltaPrForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPrForMuProj); + + mathFit->AddRefHisto(hGenDeltaElForPiProj); + mathFit->AddRefHisto(hGenDeltaElForKaProj); + mathFit->AddRefHisto(hGenDeltaElForPrProj); + mathFit->AddRefHisto(hGenDeltaElForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaElForMuProj); + + // In reg case, fill in the data for this bin and continue with the nex bin + if (regularisation > 0) { + TH1D* hDeltaSpecies[numSimultaneousFits] = { hDeltaPi[slice], hDeltaKa[slice], hDeltaPr[slice], hDeltaEl[slice] }; + + for (Int_t i = 0; i < numSimultaneousFits; i++) { + mathFit->InputData(hDeltaSpecies[i], currXbin, i, xLow, xUp, -1., kFALSE); + } + + currXbin++; + continue; + } + } + + if (regularisation > 0 && iter == 1 && !regularisedFitDone) { + std::cout << "Fitting data simultaneously with regularisation...." << std::endl << std::endl; + + // TODO At the moment, the covariance matrix is NOT forwarded from TMinuit (has completely different dimensions) + // -> Since it is not used at the moment, this is not necessary. If it is to be used in future, + // this has to be implemented! But one has to be careful, since parameters from different bins then + // depend on each other! Furthermore, there will be no errors for fixed parameters like muon fraction or electron fraction + // above the corresponding threshold in the covariance matrix, but an estimated error will be set manually. + errFlag = errFlag | doSimultaneousFitRegularised(nParSimultaneousFitRegularised, gausParamsSimultaneousFitRegularised, + parameterErrorsOutRegularised, &covMatrix[0][0], + stepSizeSimultaneousFitRegularised, + lowParLimitsSimultaneousFitRegularised, + upParLimitsSimultaneousFitRegularised, reducedChiSquare); + if (errFlag != 0) + std::cout << "errFlag " << errFlag << std::endl << std::endl; + + reducedChiSquareRegularisation = reducedChiSquare; + + // Since everything is fitted in one go, only do this for the first x bin + // (more convenient to put the fitting in the x bin loop in order to intialise + // the parameters in the same way they are initialised for the fit w/o regularisation. + regularisedFitDone = kTRUE; + } + + if (regularisation > 0 && iter == 1) { + // To allow for an identical processing, just forward the parameter results for the current xBin to the + // array used by the standard simultaneous fit. The rest of the code is then the same for regularisation on and off + + for (Int_t i = 0; i < mathFit->GetNumParametersPerXbin(); i++) { + const Int_t iRegularised = i + currXbin * mathFit->GetNumParametersPerXbin(); + + gausParamsSimultaneousFit[i] = gausParamsSimultaneousFitRegularised[iRegularised]; + parameterErrorsOut[i] = parameterErrorsOutRegularised[iRegularised]; + } + + // Same reducedChiSquare for all bins, since only one fit + reducedChiSquare = reducedChiSquareRegularisation; + + + // Also clear reference histos and load those for the current bin + mathFit->ClearRefHistos(); + + mathFit->AddRefHisto(hGenDeltaPiForPiProj); + mathFit->AddRefHisto(hGenDeltaPiForKaProj); + mathFit->AddRefHisto(hGenDeltaPiForPrProj); + mathFit->AddRefHisto(hGenDeltaPiForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPiForMuProj); + + mathFit->AddRefHisto(hGenDeltaKaForPiProj); + mathFit->AddRefHisto(hGenDeltaKaForKaProj); + mathFit->AddRefHisto(hGenDeltaKaForPrProj); + mathFit->AddRefHisto(hGenDeltaKaForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaKaForMuProj); + + mathFit->AddRefHisto(hGenDeltaPrForPiProj); + mathFit->AddRefHisto(hGenDeltaPrForKaProj); + mathFit->AddRefHisto(hGenDeltaPrForPrProj); + mathFit->AddRefHisto(hGenDeltaPrForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPrForMuProj); + + mathFit->AddRefHisto(hGenDeltaElForPiProj); + mathFit->AddRefHisto(hGenDeltaElForKaProj); + mathFit->AddRefHisto(hGenDeltaElForPrProj); + mathFit->AddRefHisto(hGenDeltaElForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaElForMuProj); + } + + + if (regularisation <= 0) { + TH1D* hDeltaSpecies[numSimultaneousFits] = { hDeltaPi[slice], hDeltaKa[slice], hDeltaPr[slice], hDeltaEl[slice] }; + errFlag = errFlag | + doSimultaneousFit(hDeltaSpecies, xLow, xUp, nParSimultaneousFit, gausParamsSimultaneousFit, parameterErrorsOut, + &covMatrix[0][0], stepSizeSimultaneousFit, lowParLimitsSimultaneousFit, + upParLimitsSimultaneousFit, reducedChiSquare); + } + + // Forward parameters to single fits + for (Int_t parIndex = 0; parIndex < nPar; parIndex++) { + // Fractions + if (parIndex <= 4) { + totalDeltaPion->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); + totalDeltaPion->SetParError(parIndex, parameterErrorsOut[parIndex]); + + totalDeltaKaon->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); + totalDeltaKaon->SetParError(parIndex, parameterErrorsOut[parIndex]); + + totalDeltaProton->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); + totalDeltaProton->SetParError(parIndex, parameterErrorsOut[parIndex]); + + totalDeltaElectron->SetParameter(parIndex, gausParamsSimultaneousFit[parIndex]); + totalDeltaElectron->SetParError(parIndex, parameterErrorsOut[parIndex]); + } + // Total yield + else if (parIndex == 5) { + totalDeltaPion->SetParameter(parIndex, totalYield); + totalDeltaPion->SetParError(parIndex, 0); + + totalDeltaKaon->SetParameter(parIndex, totalYield); + totalDeltaKaon->SetParError(parIndex, 0); + + totalDeltaProton->SetParameter(parIndex, totalYield); + totalDeltaProton->SetParError(parIndex, 0); + + totalDeltaElectron->SetParameter(parIndex, totalYield); + totalDeltaElectron->SetParError(parIndex, 0); + } + // Hist shifts + else { + totalDeltaPion->SetParameter(parIndex, 0); + totalDeltaPion->SetParError(parIndex, 0); + + totalDeltaKaon->SetParameter(parIndex, 0); + totalDeltaKaon->SetParError(parIndex, 0); + + totalDeltaProton->SetParameter(parIndex, 0); + totalDeltaProton->SetParError(parIndex, 0); + + totalDeltaElectron->SetParameter(parIndex, 0); + totalDeltaElectron->SetParError(parIndex, 0); + } + } + + const Bool_t useRegularisation = regularisation > 0; + + // Plot single fits + + Int_t binLow = -1; + Int_t binHigh = -1; + + // DeltaPions + cSingleFit[slice][2]->cd(1); + + hDeltaPi[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaPi[slice], binLow, binHigh); + hDeltaPi[slice]->Draw("e"); + + fitFuncTotalDeltaPion[slice] = (TF1*)totalDeltaPion->Clone(Form("Fit_Total_DeltaPion_%s", fitFuncSuffix.Data())); + + hDeltaPiFitQA[slice] = (TH1D*)hDeltaPi[slice]->Clone(Form("hDeltaPiFitQA_%d", slice)); + hDeltaPiFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaPiFitQA[slice]->Add(fitFuncTotalDeltaPion[slice], -1); + hDeltaPiFitQA[slice]->Divide(hDeltaPi[slice]); + + hDeltaPi[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaPion[slice]); + fitFuncTotalDeltaPion[slice]->Draw("same"); + + Double_t* parametersOut = &totalDeltaPion->GetParameters()[0]; + + hGenDeltaPiForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); + shiftHist(hGenDeltaPiForPiProj, parametersOut[6], useRegularisation); + hGenDeltaPiForPiProj->Draw("same"); + + hGenDeltaPiForKaProj->Scale(parametersOut[5] * parametersOut[1]); + shiftHist(hGenDeltaPiForKaProj, parametersOut[7], useRegularisation); + hGenDeltaPiForKaProj->Draw("same"); + + hGenDeltaPiForPrProj->Scale(parametersOut[5] * parametersOut[2]); + shiftHist(hGenDeltaPiForPrProj, parametersOut[8], useRegularisation); + hGenDeltaPiForPrProj->Draw("same"); + + hGenDeltaPiForElProj->Scale(parametersOut[5] * parametersOut[3]); + shiftHist(hGenDeltaPiForElProj, parametersOut[9], useRegularisation); + hGenDeltaPiForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaPiForMuProj->Scale(parametersOut[5] * parametersOut[4]); + shiftHist(hGenDeltaPiForMuProj, parametersOut[10], useRegularisation); + hGenDeltaPiForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaPiMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPiMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaPiMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPiMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaPi[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][2]->cd(2); + hDeltaPiFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaPiFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 3, reducedChiSquare); + + // TMatrixDSym covMatrixPi(nParUsed, &covMatrix[0][0]); + + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPi, parametersOut, parameterErrorsOut, hFractionPions, + hFractionPionsDeltaPion, hFractionElectronsDeltaPion, hFractionKaonsDeltaPion, + hFractionProtonsDeltaPion, hFractionMuonsDeltaPion, hYieldPions, hYieldPionsDeltaPion, hYieldElectronsDeltaPion, + hYieldKaonsDeltaPion, hYieldProtonsDeltaPion, hYieldMuonsDeltaPion, normaliseResults); + + // Also set specific muon fractions and yields -> The deltaSpecies histos are not needed here: They will be set together with + // the fraction and yields for all other species + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kMu, parametersOut, parameterErrorsOut, hFractionMuons, + 0x0, 0x0, 0x0, 0x0, 0x0, hYieldMuons, 0x0, 0x0, 0x0, 0x0, 0x0, normaliseResults); + + + // DeltaElectrons + cSingleFit[slice][0]->cd(1); + + hDeltaEl[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaEl[slice], binLow, binHigh); + hDeltaEl[slice]->Draw("e"); + + fitFuncTotalDeltaElectron[slice] = (TF1*)totalDeltaElectron->Clone(Form("Fit_Total_DeltaElectron_%s", fitFuncSuffix.Data())); + + hDeltaElFitQA[slice] = (TH1D*)hDeltaEl[slice]->Clone(Form("hDeltaElFitQA_%d", slice)); + hDeltaElFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaElFitQA[slice]->Add(fitFuncTotalDeltaElectron[slice], -1); + hDeltaElFitQA[slice]->Divide(hDeltaEl[slice]); + + hDeltaEl[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaElectron[slice]); + fitFuncTotalDeltaElectron[slice]->Draw("same"); + + parametersOut = &totalDeltaElectron->GetParameters()[0]; + + hGenDeltaElForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); + shiftHist(hGenDeltaElForPiProj, parametersOut[6], useRegularisation); + hGenDeltaElForPiProj->Draw("same"); + + hGenDeltaElForKaProj->Scale(parametersOut[5] * parametersOut[1]); + shiftHist(hGenDeltaElForKaProj, parametersOut[7], useRegularisation); + hGenDeltaElForKaProj->Draw("same"); + + hGenDeltaElForPrProj->Scale(parametersOut[5] * parametersOut[2]); + shiftHist(hGenDeltaElForPrProj, parametersOut[8], useRegularisation); + hGenDeltaElForPrProj->Draw("same"); + + hGenDeltaElForElProj->Scale(parametersOut[5] * parametersOut[3]); + shiftHist(hGenDeltaElForElProj, parametersOut[9], useRegularisation); + hGenDeltaElForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaElForMuProj->Scale(parametersOut[5] * parametersOut[4]); + shiftHist(hGenDeltaElForMuProj, parametersOut[10], useRegularisation); + hGenDeltaElForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaElMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaElMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaElMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaElMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaEl[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][0]->cd(2); + hDeltaElFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaElFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 1, reducedChiSquare); + + //TMatrixDSym covMatrixEl(nParUsed, &covMatrix[0][0]); + + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kEl, parametersOut, parameterErrorsOut, hFractionElectrons, + hFractionPionsDeltaElectron, hFractionElectronsDeltaElectron, hFractionKaonsDeltaElectron, + hFractionProtonsDeltaElectron, hFractionMuonsDeltaElectron, hYieldElectrons, hYieldPionsDeltaElectron, + hYieldElectronsDeltaElectron, hYieldKaonsDeltaElectron, hYieldProtonsDeltaElectron, hYieldMuonsDeltaElectron, + normaliseResults); + + + + // DeltaKaons + cSingleFit[slice][1]->cd(1); + + hDeltaKa[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaKa[slice], binLow, binHigh); + hDeltaKa[slice]->Draw("e"); + + fitFuncTotalDeltaKaon[slice] = (TF1*)totalDeltaKaon->Clone(Form("Fit_Total_DeltaKaon_%s", fitFuncSuffix.Data())); + + hDeltaKaFitQA[slice] = (TH1D*)hDeltaKa[slice]->Clone(Form("hDeltaKaFitQA_%d", slice)); + hDeltaKaFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaKaFitQA[slice]->Add(fitFuncTotalDeltaKaon[slice], -1); + hDeltaKaFitQA[slice]->Divide(hDeltaKa[slice]); + + hDeltaKa[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaKaon[slice]); + fitFuncTotalDeltaKaon[slice]->Draw("same"); + + parametersOut = &totalDeltaKaon->GetParameters()[0]; + + hGenDeltaKaForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); + shiftHist(hGenDeltaKaForPiProj, parametersOut[6], useRegularisation); + hGenDeltaKaForPiProj->Draw("same"); + + hGenDeltaKaForKaProj->Scale(parametersOut[5] * parametersOut[1]); + shiftHist(hGenDeltaKaForKaProj, parametersOut[7], useRegularisation); + hGenDeltaKaForKaProj->Draw("same"); + + hGenDeltaKaForPrProj->Scale(parametersOut[5] * parametersOut[2]); + shiftHist(hGenDeltaKaForPrProj, parametersOut[8], useRegularisation); + hGenDeltaKaForPrProj->Draw("same"); + + hGenDeltaKaForElProj->Scale(parametersOut[5] * parametersOut[3]); + shiftHist(hGenDeltaKaForElProj, parametersOut[9], useRegularisation); + hGenDeltaKaForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaKaForMuProj->Scale(parametersOut[5] * parametersOut[4]); + shiftHist(hGenDeltaKaForMuProj, parametersOut[10], useRegularisation); + hGenDeltaKaForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaKaMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaKaMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaKaMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaKaMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaKa[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][1]->cd(2); + hDeltaKaFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaKaFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 2, reducedChiSquare); + + //TMatrixDSym covMatrixKa(nParUsed, &covMatrix[0][0]); + + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kKa, parametersOut, parameterErrorsOut, hFractionKaons, + hFractionPionsDeltaKaon, hFractionElectronsDeltaKaon, hFractionKaonsDeltaKaon, hFractionProtonsDeltaKaon, + hFractionMuonsDeltaKaon, hYieldKaons, hYieldPionsDeltaKaon, hYieldElectronsDeltaKaon, hYieldKaonsDeltaKaon, + hYieldProtonsDeltaKaon, hYieldMuonsDeltaKaon, normaliseResults); + + + + // DeltaProtons + cSingleFit[slice][3]->cd(1); + + hDeltaPr[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaPr[slice], binLow, binHigh); + hDeltaPr[slice]->Draw("e"); + + fitFuncTotalDeltaProton[slice] = (TF1*)totalDeltaProton->Clone(Form("Fit_Total_DeltaProton_%s", fitFuncSuffix.Data())); + + hDeltaPrFitQA[slice] = (TH1D*)hDeltaPr[slice]->Clone(Form("hDeltaPrFitQA_%d", slice)); + hDeltaPrFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaPrFitQA[slice]->Add(fitFuncTotalDeltaProton[slice], -1); + hDeltaPrFitQA[slice]->Divide(hDeltaPr[slice]); + + hDeltaPr[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaProton[slice]); + + fitFuncTotalDeltaProton[slice]->Draw("same"); + + parametersOut = &totalDeltaProton->GetParameters()[0]; + + hGenDeltaPrForPiProj->Scale(parametersOut[5] * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0))); + shiftHist(hGenDeltaPrForPiProj, parametersOut[6], useRegularisation); + hGenDeltaPrForPiProj->Draw("same"); + + hGenDeltaPrForKaProj->Scale(parametersOut[5] * parametersOut[1]); + shiftHist(hGenDeltaPrForKaProj, parametersOut[7], useRegularisation); + hGenDeltaPrForKaProj->Draw("same"); + + hGenDeltaPrForPrProj->Scale(parametersOut[5] * parametersOut[2]); + shiftHist(hGenDeltaPrForPrProj, parametersOut[8], useRegularisation); + hGenDeltaPrForPrProj->Draw("same"); + + hGenDeltaPrForElProj->Scale(parametersOut[5] * parametersOut[3]); + shiftHist(hGenDeltaPrForElProj, parametersOut[9], useRegularisation); + hGenDeltaPrForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaPrForMuProj->Scale(parametersOut[5] * parametersOut[4]); + shiftHist(hGenDeltaPrForMuProj, parametersOut[10], useRegularisation); + hGenDeltaPrForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaPrMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPrMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaPrMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPrMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaPr[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][3]->cd(2); + hDeltaPrFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaPrFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 4, reducedChiSquare); + + //TMatrixDSym covMatrixPr(nParUsed, &covMatrix[0][0]); + + Double_t normalisationFactor = 1.0; + normalisationFactor = setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPr, parametersOut, parameterErrorsOut, + hFractionProtons, hFractionPionsDeltaProton, hFractionElectronsDeltaProton, + hFractionKaonsDeltaProton, hFractionProtonsDeltaProton, hFractionMuonsDeltaProton, + hYieldProtons, hYieldPionsDeltaProton, hYieldElectronsDeltaProton, + hYieldKaonsDeltaProton, hYieldProtonsDeltaProton, hYieldMuonsDeltaProton, + normaliseResults); + + // Fractions are the same for all plots -> just take deltaPion as default + Double_t sumFractions = hFractionPionsDeltaPion->GetBinContent(slice + 1) + + hFractionElectronsDeltaPion->GetBinContent(slice + 1) + (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaPion->GetBinContent(slice + 1) + hFractionProtonsDeltaPion->GetBinContent(slice + 1); + + hFractionSummed->SetBinContent(slice + 1, sumFractions); + hFractionSummed->SetBinError(slice + 1, + TMath::Sqrt(TMath::Power(hFractionPionsDeltaPion->GetBinError(slice + 1), 2) + + TMath::Power(hFractionElectronsDeltaPion->GetBinError(slice + 1), 2) + + (takeIntoAccountMuons ? TMath::Power(hFractionMuonsDeltaPion->GetBinError(slice + 1), 2) : 0.) + + TMath::Power(hFractionKaonsDeltaPion->GetBinError(slice + 1), 2) + + TMath::Power(hFractionProtonsDeltaPion->GetBinError(slice + 1), 2))); + + for (Int_t species = 0; species < 4; species++) { + cSingleFit[slice][species]->Modified(); + cSingleFit[slice][species]->Update(); + } + + + // Compute the to-pi ratios with proper error for the current slice + // NOTE: error and covariance matrix are already scaled for the simultaneous fit + // by mathFit (it was checked that all (i.e. also off-diagonal) matrix elements grow by fScaleError^2 + // NOTE 2: take the fractions and error from the histogram (takes correct muon and electrons fractions with errors set manually + // in case of fixed fraction; the parameters are fixed, so the elements of the off-diagonal elements of the covariance matrix + // remain zero!). The fractions are then also scaled to sum up to 1 (but correction factor usually close to unity). + // The covariance matrix is NOT scaled like this. Therefore, scale the matrix elements accordingly. + // If the normalisation is not done for the fractions, then this factor is unity by construction. + + + + Double_t covMatrixElementToPiForEl = 0.; + Double_t covMatrixElementToPiForMu = 0.; + Double_t covMatrixElementToPiForKa = 0.; + Double_t covMatrixElementToPiForPr = 0.; + + // Get the correct covariance matrix elements and apply the normalisation factor + Int_t parOffset = 0; + + // In case of regularisation, there is an offset with respect to the current slice + if (useRegularisation) + parOffset = currXbin * numParamsPerXbin; + + + covMatrixElementToPiForEl = covMatrix[3 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; + covMatrixElementToPiForMu = covMatrix[4 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; + covMatrixElementToPiForKa = covMatrix[1 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; + covMatrixElementToPiForPr = covMatrix[2 + parOffset][0 + parOffset] * normalisationFactor * normalisationFactor; + + Double_t ratio = -999.; + Double_t ratioError = 999.; + Double_t currFractionSpecies = 0.; + Double_t currFractionPions = 0.; + Double_t currFractionErrorSpecies = 0.; + Double_t currFractionErrorPions = 0.; + Double_t covMatrixElementAB = 0.; // NOTE that there is only one covariance matrix (simultaneous fit!) + + currFractionPions = hFractionPions->GetBinContent(slice + 1); + currFractionErrorPions = hFractionPions->GetBinError(slice + 1); + + // NOTE: Even in case of regularisation, when fractions of different bins become correlated, this does NOT change + // the formula. Only the covariance matrix element for the considered fraction in the SAME slice needs to be taken + // into account. Explanation: f = f(fracA_slice, fracB_slice), this means that \dell f / \dell fracA_slice+-1 = 0 (etc.). + // So, the formula is the same, although the correlation between different slices is contained in the covariance matrix. + + // el-to-pi ratio + currFractionSpecies = hFractionElectrons->GetBinContent(slice + 1); + currFractionErrorSpecies = hFractionElectrons->GetBinError(slice + 1); + covMatrixElementAB = covMatrixElementToPiForEl; + + GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, + covMatrixElementAB, ratio, ratioError); + + hRatioToPiElectrons->SetBinContent(slice + 1, ratio); + hRatioToPiElectrons->SetBinError(slice + 1, ratioError); + + // mu-to-pi ratio + currFractionSpecies = hFractionMuons->GetBinContent(slice + 1); + currFractionErrorSpecies = hFractionMuons->GetBinError(slice + 1); + covMatrixElementAB = covMatrixElementToPiForMu; + + GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, + covMatrixElementAB, ratio, ratioError); + + hRatioToPiMuons->SetBinContent(slice + 1, ratio); + hRatioToPiMuons->SetBinError(slice + 1, ratioError); + + + // K-to-pi ratio + currFractionSpecies = hFractionKaons->GetBinContent(slice + 1); + currFractionErrorSpecies = hFractionKaons->GetBinError(slice + 1); + covMatrixElementAB = covMatrixElementToPiForKa; + + GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, + covMatrixElementAB, ratio, ratioError); + + hRatioToPiKaons->SetBinContent(slice + 1, ratio); + hRatioToPiKaons->SetBinError(slice + 1, ratioError); + + + // p-to-pi ratio + currFractionSpecies = hFractionProtons->GetBinContent(slice + 1); + currFractionErrorSpecies = hFractionProtons->GetBinError(slice + 1); + covMatrixElementAB = covMatrixElementToPiForPr; + + GetRatioWithCorrelatedError(currFractionSpecies, currFractionPions, currFractionErrorSpecies, currFractionErrorPions, + covMatrixElementAB, ratio, ratioError); + + hRatioToPiProtons->SetBinContent(slice + 1, ratio); + hRatioToPiProtons->SetBinError(slice + 1, ratioError); + + /* + for (Int_t i = 0; i < nParUsed; i++) { + for (Int_t j = 0; j < nParUsed; j++) { + printf("\t%e", covMatrix[i][j]); + } + printf("\n"); + } + */ + + currXbin++; + } + //_____________________________________________________________________ + // Other methods without simultaneous fitting + else { + Int_t binLow = -1; + Int_t binHigh = -1; + + // DeltaPions + + std::cout << "Fitting deltaPion...." << std::endl << std::endl; + + cSingleFit[slice][2]->cd(1); + + mathFit->ClearRefHistos(); + mathFit->AddRefHisto(hGenDeltaPiForPiProj); + mathFit->AddRefHisto(hGenDeltaPiForKaProj); + mathFit->AddRefHisto(hGenDeltaPiForPrProj); + mathFit->AddRefHisto(hGenDeltaPiForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPiForMuProj); + + errFlag = errFlag | + doFit(hDeltaPi[slice], xLow, xUp, nPar, gausParamsPi, parameterErrorsOut, &covMatrix[0][0], + stepSize, lowParLimitsPi, upParLimitsPi, totalDeltaPion, reducedChiSquare); + + hDeltaPi[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaPi[slice], binLow, binHigh); + hDeltaPi[slice]->Draw("e"); + + fitFuncTotalDeltaPion[slice] = (TF1*)totalDeltaPion->Clone(Form("Fit_Total_DeltaPion_%s", fitFuncSuffix.Data())); + + hDeltaPiFitQA[slice] = (TH1D*)hDeltaPi[slice]->Clone(Form("hDeltaPiFitQA_%d", slice)); + hDeltaPiFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaPiFitQA[slice]->Add(fitFuncTotalDeltaPion[slice], -1); + hDeltaPiFitQA[slice]->Divide(hDeltaPi[slice]); + + hDeltaPi[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaPion[slice]); + fitFuncTotalDeltaPion[slice]->Draw("same"); + + Double_t* parametersOut = &gausParamsPi[0]; + + hGenDeltaPiForPiProj->Scale(gausParamsPi[5] * (gausParamsPi[0] + (muonContamination ? gausParamsPi[3] : 0))); + shiftHist(hGenDeltaPiForPiProj, gausParamsPi[6]); + hGenDeltaPiForPiProj->Draw("same"); + + hGenDeltaPiForKaProj->Scale(gausParamsPi[5] * gausParamsPi[1]); + shiftHist(hGenDeltaPiForKaProj, gausParamsPi[7]); + hGenDeltaPiForKaProj->Draw("same"); + + hGenDeltaPiForPrProj->Scale(gausParamsPi[5] * gausParamsPi[2]); + shiftHist(hGenDeltaPiForPrProj, gausParamsPi[8]); + hGenDeltaPiForPrProj->Draw("same"); + + hGenDeltaPiForElProj->Scale(gausParamsPi[5] * gausParamsPi[3]); + shiftHist(hGenDeltaPiForElProj, gausParamsPi[9]); + hGenDeltaPiForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaPiForMuProj->Scale(gausParamsPi[5] * gausParamsPi[4]); + shiftHist(hGenDeltaPiForMuProj, gausParamsPi[10]); + hGenDeltaPiForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaPiMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPiMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaPiMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPiMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaPi[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][2]->cd(2); + hDeltaPiFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaPiFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 3, reducedChiSquare); + + TMatrixDSym covMatrixPi(nParUsed, &covMatrix[0][0]); + + if (fitMethod == 1) { + // Histos are normalised => expression equals integral + integralPions = allDeltaPion * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); + integralTotal += integralPions; + if (takeIntoAccountMuons) { + integralMuons = allDeltaPion * parametersOut[4]; + integralTotal += integralMuons; + } + + /* + integralErrorTotalDeltaPion = getErrorOfTotalIntegral(covMatrixPi) * allDeltaPion; + + integralErrorPions = getErrorOfPionIntegral(covMatrixPi) * allDeltaPion; + */ + + integralPionsDeltaPion = integralPions; + + // Compare comment above + integralElectronsDeltaPion = allDeltaPion * parametersOut[3]; + integralKaonsDeltaPion = allDeltaPion * parametersOut[1]; + integralProtonsDeltaPion = allDeltaPion * parametersOut[2]; + integralMuonsDeltaPion = allDeltaPion * parametersOut[4]; + + /* + integralErrorPionsDeltaPion = integralErrorPions; + + integralErrorElectronsDeltaPion = allDeltaPion * parameterErrorsOut[3]; + integralErrorKaonsDeltaPion = allDeltaPion * parameterErrorsOut[1]; + integralErrorProtonsDeltaPion = allDeltaPion * parameterErrorsOut[2]; + */ + } + else { + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPi, parametersOut, parameterErrorsOut, hFractionPions, + hFractionPionsDeltaPion, hFractionElectronsDeltaPion, hFractionKaonsDeltaPion, + hFractionProtonsDeltaPion, hFractionMuonsDeltaPion, hYieldPions, hYieldPionsDeltaPion, hYieldElectronsDeltaPion, + hYieldKaonsDeltaPion, hYieldProtonsDeltaPion, hYieldMuonsDeltaPion); + + // Also set specific muon fractions and yields -> The deltaSpecies histos are not needed here: They will be set together with + // the fraction and yields for all other species + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kMu, parametersOut, parameterErrorsOut, hFractionMuons, + 0x0, 0x0, 0x0, 0x0, 0x0, hYieldMuons, 0x0, 0x0, 0x0, 0x0, 0x0); + } + + + std::cout << std::endl << std::endl; + + + // DeltaElectrons + + std::cout << "Fitting deltaElectron...." << std::endl << std::endl; + + cSingleFit[slice][0]->cd(1); + + mathFit->ClearRefHistos(); + mathFit->AddRefHisto(hGenDeltaElForPiProj); + mathFit->AddRefHisto(hGenDeltaElForKaProj); + mathFit->AddRefHisto(hGenDeltaElForPrProj); + mathFit->AddRefHisto(hGenDeltaElForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaElForMuProj); + + errFlag = errFlag | + doFit(hDeltaEl[slice], xLow, xUp, nPar, gausParamsEl, parameterErrorsOut, &covMatrix[0][0], + stepSize, lowParLimitsEl, upParLimitsEl, totalDeltaElectron, reducedChiSquare); + + hDeltaEl[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaEl[slice], binLow, binHigh); + hDeltaEl[slice]->Draw("e"); + + fitFuncTotalDeltaElectron[slice] = (TF1*)totalDeltaElectron->Clone(Form("Fit_Total_DeltaElectron_%s", fitFuncSuffix.Data())); + + hDeltaElFitQA[slice] = (TH1D*)hDeltaEl[slice]->Clone(Form("hDeltaElFitQA_%d", slice)); + hDeltaElFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaElFitQA[slice]->Add(fitFuncTotalDeltaElectron[slice], -1); + hDeltaElFitQA[slice]->Divide(hDeltaEl[slice]); + + hDeltaEl[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaElectron[slice]); + fitFuncTotalDeltaElectron[slice]->Draw("same"); + + parametersOut = &gausParamsEl[0]; + + hGenDeltaElForPiProj->Scale(gausParamsEl[5] * (gausParamsEl[0] + (muonContamination ? gausParamsEl[3] : 0))); + shiftHist(hGenDeltaElForPiProj, gausParamsEl[6]); + hGenDeltaElForPiProj->Draw("same"); + + hGenDeltaElForKaProj->Scale(gausParamsEl[5] * gausParamsEl[1]); + shiftHist(hGenDeltaElForKaProj, gausParamsEl[7]); + hGenDeltaElForKaProj->Draw("same"); + + hGenDeltaElForPrProj->Scale(gausParamsEl[5] * gausParamsEl[2]); + shiftHist(hGenDeltaElForPrProj, gausParamsEl[8]); + hGenDeltaElForPrProj->Draw("same"); + + hGenDeltaElForElProj->Scale(gausParamsEl[5] * gausParamsEl[3]); + shiftHist(hGenDeltaElForElProj, gausParamsEl[9]); + hGenDeltaElForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaElForMuProj->Scale(gausParamsEl[5] * gausParamsEl[4]); + shiftHist(hGenDeltaElForMuProj, gausParamsEl[10]); + hGenDeltaElForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaElMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaElMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaElMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaElMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaEl[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][0]->cd(2); + hDeltaElFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaElFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 1, reducedChiSquare); + + TMatrixDSym covMatrixEl(nParUsed, &covMatrix[0][0]); + + if (fitMethod == 1) { + integralElectrons = allDeltaElectron * parametersOut[3]; // Histos are normalised => expression equals integral + integralTotal += integralElectrons; + + /* + integralErrorTotalDeltaElectron = getErrorOfTotalIntegral(covMatrixEl) * allDeltaElectron; + + integralErrorElectrons = allDeltaElectron * parameterErrorsOut[3]; + */ + + // Factor 2 in case of takeIntoAccountMuons will be applied below + integralElectronsDeltaElectron = integralElectrons; + + // Compare comment above + integralPionsDeltaElectron = allDeltaElectron * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); + integralKaonsDeltaElectron = allDeltaElectron * parametersOut[1]; + integralProtonsDeltaElectron = allDeltaElectron * parametersOut[2]; + integralMuonsDeltaElectron = allDeltaElectron * parametersOut[4]; + + + /* + integralErrorElectronsDeltaElectron = integralErrorElectrons; + + integralErrorPionsDeltaElectron = getErrorOfPionIntegral(covMatrixEl) * allDeltaElectron; + integralErrorKaonsDeltaElectron = allDeltaElectron * parameterErrorsOut[1]; + integralErrorProtonsDeltaElectron = allDeltaElectron * parameterErrorsOut[2]; + */ + } + else { + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kEl, parametersOut, parameterErrorsOut, hFractionElectrons, + hFractionPionsDeltaElectron, hFractionElectronsDeltaElectron, hFractionKaonsDeltaElectron, + hFractionProtonsDeltaElectron, hFractionMuonsDeltaElectron, hYieldElectrons, hYieldPionsDeltaElectron, + hYieldElectronsDeltaElectron, hYieldKaonsDeltaElectron, hYieldProtonsDeltaElectron, hYieldMuonsDeltaElectron); + } + + std::cout << std::endl << std::endl; + + // DeltaKaons + + std::cout << "Fitting deltaKaon...." << std::endl << std::endl; + + cSingleFit[slice][1]->cd(1); + + mathFit->ClearRefHistos(); + mathFit->AddRefHisto(hGenDeltaKaForPiProj); + mathFit->AddRefHisto(hGenDeltaKaForKaProj); + mathFit->AddRefHisto(hGenDeltaKaForPrProj); + mathFit->AddRefHisto(hGenDeltaKaForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaKaForMuProj); + + errFlag = errFlag | + doFit(hDeltaKa[slice], xLow, xUp, nPar, gausParamsKa, parameterErrorsOut, &covMatrix[0][0], + stepSize, lowParLimitsKa, upParLimitsKa, totalDeltaKaon, reducedChiSquare); + + hDeltaKa[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaKa[slice], binLow, binHigh); + hDeltaKa[slice]->Draw("e"); + + fitFuncTotalDeltaKaon[slice] = (TF1*)totalDeltaKaon->Clone(Form("Fit_Total_DeltaKaon_%s", fitFuncSuffix.Data())); + + hDeltaKaFitQA[slice] = (TH1D*)hDeltaKa[slice]->Clone(Form("hDeltaKaFitQA_%d", slice)); + hDeltaKaFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaKaFitQA[slice]->Add(fitFuncTotalDeltaKaon[slice], -1); + hDeltaKaFitQA[slice]->Divide(hDeltaKa[slice]); + + hDeltaKa[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaKaon[slice]); + fitFuncTotalDeltaKaon[slice]->Draw("same"); + + parametersOut = &gausParamsKa[0]; + + hGenDeltaKaForPiProj->Scale(gausParamsKa[5] * (gausParamsKa[0] + (muonContamination ? gausParamsKa[3] : 0))); + shiftHist(hGenDeltaKaForPiProj, gausParamsKa[6]); + hGenDeltaKaForPiProj->Draw("same"); + + hGenDeltaKaForKaProj->Scale(gausParamsKa[5] * gausParamsKa[1]); + shiftHist(hGenDeltaKaForKaProj, gausParamsKa[7]); + hGenDeltaKaForKaProj->Draw("same"); + + hGenDeltaKaForPrProj->Scale(gausParamsKa[5] * gausParamsKa[2]); + shiftHist(hGenDeltaKaForPrProj, gausParamsKa[8]); + hGenDeltaKaForPrProj->Draw("same"); + + hGenDeltaKaForElProj->Scale(gausParamsKa[5] * gausParamsKa[3]); + shiftHist(hGenDeltaKaForElProj, gausParamsKa[9]); + hGenDeltaKaForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaKaForMuProj->Scale(gausParamsKa[5] * gausParamsKa[4]); + shiftHist(hGenDeltaKaForMuProj, gausParamsKa[10]); + hGenDeltaKaForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaKaMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaKaMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaKaMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaKaMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaKa[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][1]->cd(2); + hDeltaKaFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaKaFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 2, reducedChiSquare); + + TMatrixDSym covMatrixKa(nParUsed, &covMatrix[0][0]); + + if (fitMethod == 1) { + integralKaons = allDeltaKaon * parametersOut[1]; // Histos are normalised => expression equals integral + integralTotal += integralKaons; + /* + integralErrorTotalDeltaKaon = getErrorOfTotalIntegral(covMatrixKa) * allDeltaKaon; + + integralErrorKaons = allDeltaKaon * parameterErrorsOut[1]; + */ + + + integralKaonsDeltaKaon = integralKaons; + + // Compare comment above + integralPionsDeltaKaon = allDeltaKaon * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); + integralElectronsDeltaKaon = allDeltaKaon * parametersOut[3]; + integralProtonsDeltaKaon = allDeltaKaon * parametersOut[2]; + integralMuonsDeltaKaon = allDeltaKaon * parametersOut[4]; + + /* + integralErrorKaonsDeltaKaon = integralErrorKaons; + + integralErrorPionsDeltaKaon = getErrorOfPionIntegral(covMatrixKa) * allDeltaKaon; + integralErrorElectronsDeltaKaon = allDeltaKaon * parameterErrorsOut[3]; + integralErrorProtonsDeltaKaon = allDeltaKaon * parameterErrorsOut[2]; + */ + } + else { + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kKa, parametersOut, parameterErrorsOut, hFractionKaons, + hFractionPionsDeltaKaon, hFractionElectronsDeltaKaon, hFractionKaonsDeltaKaon, hFractionProtonsDeltaKaon, + hFractionMuonsDeltaKaon, hYieldKaons, hYieldPionsDeltaKaon, hYieldElectronsDeltaKaon, hYieldKaonsDeltaKaon, + hYieldProtonsDeltaKaon, hYieldMuonsDeltaKaon); + } + + std::cout << std::endl << std::endl; + + + // DeltaProtons + + std::cout << "Fitting deltaProton...." << std::endl << std::endl; + + cSingleFit[slice][3]->cd(1); + + mathFit->ClearRefHistos(); + mathFit->AddRefHisto(hGenDeltaPrForPiProj); + mathFit->AddRefHisto(hGenDeltaPrForKaProj); + mathFit->AddRefHisto(hGenDeltaPrForPrProj); + mathFit->AddRefHisto(hGenDeltaPrForElProj); + if (takeIntoAccountMuons) + mathFit->AddRefHisto(hGenDeltaPrForMuProj); + + errFlag = errFlag | + doFit(hDeltaPr[slice], xLow, xUp, nPar, gausParamsPr, parameterErrorsOut, &covMatrix[0][0], + stepSize, lowParLimitsPr, upParLimitsPr, totalDeltaProton, reducedChiSquare); + + hDeltaPr[slice]->SetTitle(""); + SetReasonableXaxisRange(hDeltaPr[slice], binLow, binHigh); + hDeltaPr[slice]->Draw("e"); + + fitFuncTotalDeltaProton[slice] = (TF1*)totalDeltaProton->Clone(Form("Fit_Total_DeltaProton_%s", fitFuncSuffix.Data())); + + hDeltaPrFitQA[slice] = (TH1D*)hDeltaPr[slice]->Clone(Form("hDeltaPrFitQA_%d", slice)); + hDeltaPrFitQA[slice]->GetYaxis()->SetTitle("(Data - Fit) / Data"); + hDeltaPrFitQA[slice]->Add(fitFuncTotalDeltaProton[slice], -1); + hDeltaPrFitQA[slice]->Divide(hDeltaPr[slice]); + + hDeltaPr[slice]->GetListOfFunctions()->Add(fitFuncTotalDeltaProton[slice]); + + fitFuncTotalDeltaProton[slice]->Draw("same"); + + parametersOut = &gausParamsPr[0]; + + hGenDeltaPrForPiProj->Scale(gausParamsPr[5] * (gausParamsPr[0] + (muonContamination ? gausParamsPr[3] : 0))); + shiftHist(hGenDeltaPrForPiProj, gausParamsPr[6]); + hGenDeltaPrForPiProj->Draw("same"); + + hGenDeltaPrForKaProj->Scale(gausParamsPr[5] * gausParamsPr[1]); + shiftHist(hGenDeltaPrForKaProj, gausParamsPr[7]); + hGenDeltaPrForKaProj->Draw("same"); + + hGenDeltaPrForPrProj->Scale(gausParamsPr[5] * gausParamsPr[2]); + shiftHist(hGenDeltaPrForPrProj, gausParamsPr[8]); + hGenDeltaPrForPrProj->Draw("same"); + + hGenDeltaPrForElProj->Scale(gausParamsPr[5] * gausParamsPr[3]); + shiftHist(hGenDeltaPrForElProj, gausParamsPr[9]); + hGenDeltaPrForElProj->Draw("same"); + + if (takeIntoAccountMuons) { + hGenDeltaPrForMuProj->Scale(gausParamsPr[5] * gausParamsPr[4]); + shiftHist(hGenDeltaPrForMuProj, gausParamsPr[10]); + hGenDeltaPrForMuProj->Draw("same"); + } + + if (plotIdentifiedSpectra) { + for (Int_t species = 0; species < 5; species++) + hDeltaPrMC[slice][species]->Draw("same"); + + // Draw histo for sum of MC muons and pions + TH1D* hMCmuonsAndPions = new TH1D(*hDeltaPrMC[slice][kPi - 1]); + hMCmuonsAndPions->Add(hDeltaPrMC[slice][kMu - 1]); + hMCmuonsAndPions->SetLineColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetMarkerColor(getLineColor(kMuPlusPi)); + hMCmuonsAndPions->SetName(Form("%s_muonsAdded", hDeltaPrMC[slice][kPi - 1]->GetName())); + hMCmuonsAndPions->Draw("same"); + } + + hDeltaPr[slice]->Draw("esame"); + + legend->Draw(); + + cSingleFit[slice][3]->cd(2); + hDeltaPrFitQA[slice]->GetYaxis()->SetRangeUser(fitQAaxisLowBound, fitQAaxisUpBound); + hDeltaPrFitQA[slice]->Draw("e"); + + hReducedChiSquarePt->SetBinContent(slice + 1, 4, reducedChiSquare); + + TMatrixDSym covMatrixPr(nParUsed, &covMatrix[0][0]); + + if (fitMethod == 1) { + integralProtons = allDeltaProton * parametersOut[2]; // Histos are normalised => expression equals integral + integralTotal += integralProtons; + /* + integralErrorTotalDeltaProton = getErrorOfTotalIntegral(covMatrixPr) * allDeltaProton; + + integralErrorProtons = allDeltaProton * parameterErrorsOut[2]; + */ + + integralProtonsDeltaProton = integralProtons; + + // Compare comment above + integralPionsDeltaProton = allDeltaProton * (parametersOut[0] + (muonContamination ? parametersOut[3] : 0)); + integralElectronsDeltaProton = allDeltaProton * parametersOut[3]; + integralKaonsDeltaProton = allDeltaProton * parametersOut[1]; + integralMuonsDeltaProton = allDeltaProton * parametersOut[4]; + + + /* + integralErrorProtonsDeltaProton = integralErrorProtons; + + integralErrorPionsDeltaProton = getErrorOfPionIntegral(covMatrixPr) * allDeltaProton; + integralErrorElectronsDeltaProton = allDeltaProton * parameterErrorsOut[3]; + integralErrorKaonsDeltaProton = allDeltaProton * parameterErrorsOut[1]; + */ + } + else { + setFractionsAndYields(slice, inverseBinWidth, binWidthFitHisto, kPr, parametersOut, parameterErrorsOut, hFractionProtons, + hFractionPionsDeltaProton, hFractionElectronsDeltaProton, hFractionKaonsDeltaProton, + hFractionProtonsDeltaProton, hFractionMuonsDeltaProton, hYieldProtons, hYieldPionsDeltaProton, + hYieldElectronsDeltaProton, hYieldKaonsDeltaProton, hYieldProtonsDeltaProton, hYieldMuonsDeltaProton); + } + + std::cout << std::endl << std::endl; + + + if (fitMethod == 1) { + // Calculate fractions and yields for method 1 + if (integralTotal > 0) { + + Double_t sumOfParticles = 0; + + // Check fraction and yield determination for systematics + // DeltaPion + Double_t integralTotalDeltaPion = integralPionsDeltaPion + integralElectronsDeltaPion + + (takeIntoAccountMuons ? integralMuonsDeltaPion : 0.) + + integralKaonsDeltaPion + integralProtonsDeltaPion; + totalDeltaPion->GetParameters(parametersOut); + + Double_t pionFractionDeltaPion = saveDivide(integralPionsDeltaPion, integralTotalDeltaPion); + Double_t pionFractionErrorDeltaPion = getErrorOfPionFraction(parametersOut, covMatrixPi); + hFractionPionsDeltaPion->SetBinContent(slice + 1, pionFractionDeltaPion); + hFractionPionsDeltaPion->SetBinError(slice + 1, pionFractionErrorDeltaPion); + + Double_t electronFractionDeltaPion = saveDivide(integralElectronsDeltaPion, integralTotalDeltaPion); + Double_t electronFractionErrorDeltaPion = getErrorOfElectronFraction(parametersOut, covMatrixPi); + hFractionElectronsDeltaPion->SetBinContent(slice + 1, electronFractionDeltaPion); + hFractionElectronsDeltaPion->SetBinError(slice + 1, electronFractionErrorDeltaPion); + + Double_t kaonFractionDeltaPion = saveDivide(integralKaonsDeltaPion, integralTotalDeltaPion); + Double_t kaonFractionErrorDeltaPion = getErrorOfKaonFraction(parametersOut, covMatrixPi); + hFractionKaonsDeltaPion->SetBinContent(slice + 1, kaonFractionDeltaPion); + hFractionKaonsDeltaPion->SetBinError(slice + 1, kaonFractionErrorDeltaPion); + + Double_t protonFractionDeltaPion = saveDivide(integralProtonsDeltaPion, integralTotalDeltaPion); + Double_t protonFractionErrorDeltaPion = getErrorOfProtonFraction(parametersOut, covMatrixPi); + hFractionProtonsDeltaPion->SetBinContent(slice + 1, protonFractionDeltaPion); + hFractionProtonsDeltaPion->SetBinError(slice + 1, protonFractionErrorDeltaPion); + + Double_t muonFractionDeltaPion = saveDivide(integralMuonsDeltaPion, integralTotalDeltaPion); + // TODO Error is anyway not implemented correctly. Just take electron error as an approximation + Double_t muonFractionErrorDeltaPion = getErrorOfElectronFraction(parametersOut, covMatrixPi); + hFractionMuonsDeltaPion->SetBinContent(slice + 1, muonFractionDeltaPion); + hFractionMuonsDeltaPion->SetBinError(slice + 1, muonFractionErrorDeltaPion); + + sumOfParticles = inverseBinWidth * gausParamsPi[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width + + hYieldPionsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaPion->GetBinContent(slice + 1)); + hYieldPionsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaPion->GetBinError(slice + 1)); + hYieldElectronsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaPion->GetBinContent(slice + 1)); + hYieldElectronsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaPion->GetBinError(slice + 1)); + hYieldKaonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaPion->GetBinContent(slice + 1)); + hYieldKaonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaPion->GetBinError(slice + 1)); + hYieldProtonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaPion->GetBinContent(slice + 1)); + hYieldProtonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaPion->GetBinError(slice + 1)); + hYieldMuonsDeltaPion->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaPion->GetBinContent(slice + 1)); + hYieldMuonsDeltaPion->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaPion->GetBinError(slice + 1)); + + + // DeltaElectron + Double_t integralTotalDeltaElectron = integralPionsDeltaElectron + integralElectronsDeltaElectron + + (takeIntoAccountMuons ? integralMuonsDeltaElectron : 0.) + + integralKaonsDeltaElectron + integralProtonsDeltaElectron; + totalDeltaElectron->GetParameters(parametersOut); + + Double_t pionFractionDeltaElectron = saveDivide(integralPionsDeltaElectron, integralTotalDeltaElectron); + Double_t pionFractionErrorDeltaElectron = getErrorOfPionFraction(parametersOut, covMatrixEl); + hFractionPionsDeltaElectron->SetBinContent(slice + 1, pionFractionDeltaElectron); + hFractionPionsDeltaElectron->SetBinError(slice + 1, pionFractionErrorDeltaElectron); + + Double_t electronFractionDeltaElectron = saveDivide(integralElectronsDeltaElectron, integralTotalDeltaElectron); + Double_t electronFractionErrorDeltaElectron = getErrorOfElectronFraction(parametersOut, covMatrixEl); + hFractionElectronsDeltaElectron->SetBinContent(slice + 1, electronFractionDeltaElectron); + hFractionElectronsDeltaElectron->SetBinError(slice + 1, electronFractionErrorDeltaElectron); + + Double_t kaonFractionDeltaElectron = saveDivide(integralKaonsDeltaElectron, integralTotalDeltaElectron); + Double_t kaonFractionErrorDeltaElectron = getErrorOfKaonFraction(parametersOut, covMatrixEl); + hFractionKaonsDeltaElectron->SetBinContent(slice + 1, kaonFractionDeltaElectron); + hFractionKaonsDeltaElectron->SetBinError(slice + 1, kaonFractionErrorDeltaElectron); + + Double_t protonFractionDeltaElectron = saveDivide(integralProtonsDeltaElectron, integralTotalDeltaElectron); + Double_t protonFractionErrorDeltaElectron = getErrorOfProtonFraction(parametersOut, covMatrixEl); + hFractionProtonsDeltaElectron->SetBinContent(slice + 1, protonFractionDeltaElectron); + hFractionProtonsDeltaElectron->SetBinError(slice + 1, protonFractionErrorDeltaElectron); + + Double_t muonFractionDeltaElectron = saveDivide(integralMuonsDeltaElectron, integralTotalDeltaElectron); + // TODO Error is anyway not implemented correctly. Just take electron error as an approximation + Double_t muonFractionErrorDeltaElectron = getErrorOfElectronFraction(parametersOut, covMatrixEl); + hFractionMuonsDeltaElectron->SetBinContent(slice + 1, muonFractionDeltaElectron); + hFractionMuonsDeltaElectron->SetBinError(slice + 1, muonFractionErrorDeltaElectron); + + sumOfParticles = inverseBinWidth * gausParamsEl[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width + + hYieldPionsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaElectron->GetBinContent(slice + 1)); + hYieldPionsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaElectron->GetBinError(slice + 1)); + hYieldElectronsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaElectron->GetBinContent(slice + 1)); + hYieldElectronsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaElectron->GetBinError(slice + 1)); + hYieldKaonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaElectron->GetBinContent(slice + 1)); + hYieldKaonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaElectron->GetBinError(slice + 1)); + hYieldProtonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaElectron->GetBinContent(slice + 1)); + hYieldProtonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaElectron->GetBinError(slice + 1)); + hYieldMuonsDeltaElectron->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaElectron->GetBinContent(slice + 1)); + hYieldMuonsDeltaElectron->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaElectron->GetBinError(slice + 1)); + + + // DeltaKaon + Double_t integralTotalDeltaKaon = integralPionsDeltaKaon + integralElectronsDeltaKaon + + (takeIntoAccountMuons ? integralMuonsDeltaKaon : 0.) + + integralKaonsDeltaKaon + integralProtonsDeltaKaon; + totalDeltaKaon->GetParameters(parametersOut); + + Double_t pionFractionDeltaKaon = saveDivide(integralPionsDeltaKaon, integralTotalDeltaKaon); + Double_t pionFractionErrorDeltaKaon = getErrorOfPionFraction(parametersOut, covMatrixKa); + hFractionPionsDeltaKaon->SetBinContent(slice + 1, pionFractionDeltaKaon); + hFractionPionsDeltaKaon->SetBinError(slice + 1, pionFractionErrorDeltaKaon); + + Double_t electronFractionDeltaKaon = saveDivide(integralElectronsDeltaKaon, integralTotalDeltaKaon); + Double_t electronFractionErrorDeltaKaon = getErrorOfElectronFraction(parametersOut, covMatrixKa); + hFractionElectronsDeltaKaon->SetBinContent(slice + 1, electronFractionDeltaKaon); + hFractionElectronsDeltaKaon->SetBinError(slice + 1, electronFractionErrorDeltaKaon); + + Double_t kaonFractionDeltaKaon = saveDivide(integralKaonsDeltaKaon, integralTotalDeltaKaon); + Double_t kaonFractionErrorDeltaKaon = getErrorOfKaonFraction(parametersOut, covMatrixKa); + hFractionKaonsDeltaKaon->SetBinContent(slice + 1, kaonFractionDeltaKaon); + hFractionKaonsDeltaKaon->SetBinError(slice + 1, kaonFractionErrorDeltaKaon); + + Double_t protonFractionDeltaKaon = saveDivide(integralProtonsDeltaKaon, integralTotalDeltaKaon); + Double_t protonFractionErrorDeltaKaon = getErrorOfProtonFraction(parametersOut, covMatrixKa); + hFractionProtonsDeltaKaon->SetBinContent(slice + 1, protonFractionDeltaKaon); + hFractionProtonsDeltaKaon->SetBinError(slice + 1, protonFractionErrorDeltaKaon); + + Double_t muonFractionDeltaKaon = saveDivide(integralMuonsDeltaKaon, integralTotalDeltaKaon); + // TODO Error is anyway not implemented correctly. Just take electron error as an approximation + Double_t muonFractionErrorDeltaKaon = getErrorOfElectronFraction(parametersOut, covMatrixKa); + hFractionMuonsDeltaKaon->SetBinContent(slice + 1, muonFractionDeltaKaon); + hFractionMuonsDeltaKaon->SetBinError(slice + 1, muonFractionErrorDeltaKaon); + + sumOfParticles = inverseBinWidth * gausParamsKa[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width + + hYieldPionsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaKaon->GetBinContent(slice + 1)); + hYieldPionsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaKaon->GetBinError(slice + 1)); + hYieldElectronsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaKaon->GetBinContent(slice + 1)); + hYieldElectronsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaKaon->GetBinError(slice + 1)); + hYieldKaonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaKaon->GetBinContent(slice + 1)); + hYieldKaonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaKaon->GetBinError(slice + 1)); + hYieldProtonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaKaon->GetBinContent(slice + 1)); + hYieldProtonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaKaon->GetBinError(slice + 1)); + hYieldMuonsDeltaKaon->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaKaon->GetBinContent(slice + 1)); + hYieldMuonsDeltaKaon->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaKaon->GetBinError(slice + 1)); + + + + // DeltaProton + Double_t integralTotalDeltaProton = integralPionsDeltaProton + integralElectronsDeltaProton + + (takeIntoAccountMuons ? integralMuonsDeltaProton : 0.) + + integralKaonsDeltaProton + integralProtonsDeltaProton; + totalDeltaProton->GetParameters(parametersOut); + + Double_t pionFractionDeltaProton = saveDivide(integralPionsDeltaProton, integralTotalDeltaProton); + Double_t pionFractionErrorDeltaProton = getErrorOfPionFraction(parametersOut, covMatrixPr); + hFractionPionsDeltaProton->SetBinContent(slice + 1, pionFractionDeltaProton); + hFractionPionsDeltaProton->SetBinError(slice + 1, pionFractionErrorDeltaProton); + + Double_t electronFractionDeltaProton = saveDivide(integralElectronsDeltaProton, integralTotalDeltaProton); + Double_t electronFractionErrorDeltaProton = getErrorOfElectronFraction(parametersOut, covMatrixPr); + hFractionElectronsDeltaProton->SetBinContent(slice + 1, electronFractionDeltaProton); + hFractionElectronsDeltaProton->SetBinError(slice + 1, electronFractionErrorDeltaProton); + + Double_t kaonFractionDeltaProton = saveDivide(integralKaonsDeltaProton, integralTotalDeltaProton); + Double_t kaonFractionErrorDeltaProton = getErrorOfKaonFraction(parametersOut, covMatrixPr); + hFractionKaonsDeltaProton->SetBinContent(slice + 1, kaonFractionDeltaProton); + hFractionKaonsDeltaProton->SetBinError(slice + 1, kaonFractionErrorDeltaProton); + + Double_t protonFractionDeltaProton = saveDivide(integralProtonsDeltaProton, integralTotalDeltaProton); + Double_t protonFractionErrorDeltaProton = getErrorOfProtonFraction(parametersOut, covMatrixPr); + hFractionProtonsDeltaProton->SetBinContent(slice + 1, protonFractionDeltaProton); + hFractionProtonsDeltaProton->SetBinError(slice + 1, protonFractionErrorDeltaProton); + + Double_t muonFractionDeltaProton = saveDivide(integralMuonsDeltaProton, integralTotalDeltaProton); + // TODO Error is anyway not implemented correctly. Just take electron error as an approximation + Double_t muonFractionErrorDeltaProton = getErrorOfElectronFraction(parametersOut, covMatrixPr); + hFractionMuonsDeltaProton->SetBinContent(slice + 1, muonFractionDeltaProton); + hFractionMuonsDeltaProton->SetBinError(slice + 1, muonFractionErrorDeltaProton); + + sumOfParticles = inverseBinWidth * gausParamsPr[5] / binWidthFitHisto; // Divide by binWidthFitHisto, since gausParamsXX includes this width + + hYieldPionsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionPionsDeltaProton->GetBinContent(slice + 1)); + hYieldPionsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionPionsDeltaProton->GetBinError(slice + 1)); + hYieldElectronsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionElectronsDeltaProton->GetBinContent(slice + 1)); + hYieldElectronsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionElectronsDeltaProton->GetBinError(slice + 1)); + hYieldKaonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionKaonsDeltaProton->GetBinContent(slice + 1)); + hYieldKaonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionKaonsDeltaProton->GetBinError(slice + 1)); + hYieldProtonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionProtonsDeltaProton->GetBinContent(slice + 1)); + hYieldProtonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionProtonsDeltaProton->GetBinError(slice + 1)); + hYieldMuonsDeltaProton->SetBinContent(slice + 1, sumOfParticles * hFractionMuonsDeltaProton->GetBinContent(slice + 1)); + hYieldMuonsDeltaProton->SetBinError(slice + 1, sumOfParticles * hFractionMuonsDeltaProton->GetBinError(slice + 1)); + + + + // Take for XXXXfractionError the median of XXXXfractionErrorYYYY and do not take into account errors + // with value zero, since the should correspond to a failed fit (but the other fits can still converge). + // Same for the yields + Double_t pionFraction = saveDivide(integralPions, integralTotal); + Double_t errorsPions[4] = { pionFractionErrorDeltaPion, pionFractionErrorDeltaElectron, + pionFractionErrorDeltaKaon, pionFractionErrorDeltaProton }; + Double_t pionFractionError = getMedianOfNonZeros(errorsPions); + + Double_t electronFraction = saveDivide(integralElectrons, integralTotal); + Double_t errorsElectrons[4] = { electronFractionErrorDeltaPion, electronFractionErrorDeltaElectron, + electronFractionErrorDeltaKaon, electronFractionErrorDeltaProton }; + Double_t electronFractionError = getMedianOfNonZeros(errorsElectrons); + + Double_t kaonFraction = saveDivide(integralKaons, integralTotal); + Double_t errorsKaons[4] = { kaonFractionErrorDeltaPion, kaonFractionErrorDeltaElectron, + kaonFractionErrorDeltaKaon, kaonFractionErrorDeltaProton }; + Double_t kaonFractionError = getMedianOfNonZeros(errorsKaons); + + Double_t protonFraction = saveDivide(integralProtons, integralTotal); + Double_t errorsProtons[4] = { protonFractionErrorDeltaPion, protonFractionErrorDeltaElectron, + protonFractionErrorDeltaKaon, protonFractionErrorDeltaProton }; + Double_t protonFractionError = getMedianOfNonZeros(errorsProtons); + + Double_t muonFraction = saveDivide(integralMuons, integralTotal); + Double_t errorsMuons[4] = { muonFractionErrorDeltaPion, muonFractionErrorDeltaElectron, + muonFractionErrorDeltaKaon, muonFractionErrorDeltaProton }; + Double_t muonFractionError = getMedianOfNonZeros(errorsMuons); + + hFractionPions->SetBinContent(slice + 1, pionFraction); + hFractionPions->SetBinError(slice + 1, pionFractionError); + hFractionElectrons->SetBinContent(slice + 1, electronFraction); + hFractionElectrons->SetBinError(slice + 1, electronFractionError); + hFractionKaons->SetBinContent(slice + 1, kaonFraction); + hFractionKaons->SetBinError(slice + 1, kaonFractionError); + hFractionProtons->SetBinContent(slice + 1, protonFraction); + hFractionProtons->SetBinError(slice + 1, protonFractionError); + hFractionMuons->SetBinContent(slice + 1, muonFraction); + hFractionMuons->SetBinError(slice + 1, muonFractionError); + + hFractionSummed->SetBinContent(slice + 1, pionFraction + electronFraction + (takeIntoAccountMuons ? muonFraction : 0.) + + kaonFraction + protonFraction); + hFractionSummed->SetBinError(slice + 1, + TMath::Sqrt(TMath::Power(pionFractionError, 2) + + TMath::Power(electronFractionError, 2) + + (takeIntoAccountMuons ? TMath::Power(muonFractionError, 2) : 0.) + + TMath::Power(kaonFractionError, 2) + + TMath::Power(protonFractionError, 2))); + + sumOfParticles = inverseBinWidth * integralTotal / binWidthFitHisto; // Divide by binWidthFitHisto, since integralTotal includes this width + + hYieldPions->SetBinContent(slice + 1, sumOfParticles * hFractionPions->GetBinContent(slice + 1)); + hYieldPions->SetBinError(slice + 1, sumOfParticles * hFractionPions->GetBinError(slice + 1)); + hYieldElectrons->SetBinContent(slice + 1, sumOfParticles * hFractionElectrons->GetBinContent(slice + 1)); + hYieldElectrons->SetBinError(slice + 1, sumOfParticles * hFractionElectrons->GetBinError(slice + 1)); + hYieldKaons->SetBinContent(slice + 1, sumOfParticles * hFractionKaons->GetBinContent(slice + 1)); + hYieldKaons->SetBinError(slice + 1, sumOfParticles * hFractionKaons->GetBinError(slice + 1)); + hYieldProtons->SetBinContent(slice + 1, sumOfParticles * hFractionProtons->GetBinContent(slice + 1)); + hYieldProtons->SetBinError(slice + 1, sumOfParticles * hFractionProtons->GetBinError(slice + 1)); + hYieldMuons->SetBinContent(slice + 1, sumOfParticles * hFractionMuons->GetBinContent(slice + 1)); + hYieldMuons->SetBinError(slice + 1, sumOfParticles * hFractionMuons->GetBinError(slice + 1)); + } + } + else { + Double_t SumFractionsDeltaElectron = hFractionPionsDeltaElectron->GetBinContent(slice + 1) + + hFractionElectronsDeltaElectron->GetBinContent(slice + 1) + + (takeIntoAccountMuons ? hFractionMuonsDeltaElectron->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaElectron->GetBinContent(slice + 1) + hFractionProtonsDeltaElectron->GetBinContent(slice + 1); + + Double_t SumFractionsDeltaKaon = hFractionPionsDeltaKaon->GetBinContent(slice + 1) + + hFractionElectronsDeltaKaon->GetBinContent(slice + 1) + + (takeIntoAccountMuons ? hFractionMuonsDeltaKaon->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaKaon->GetBinContent(slice + 1) + hFractionProtonsDeltaKaon->GetBinContent(slice + 1); + + Double_t SumFractionsDeltaPion = hFractionPionsDeltaPion->GetBinContent(slice + 1) + + hFractionElectronsDeltaPion->GetBinContent(slice + 1) + + (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaPion->GetBinContent(slice + 1) + hFractionProtonsDeltaPion->GetBinContent(slice + 1); + + Double_t SumFractionsDeltaProton = hFractionPionsDeltaProton->GetBinContent(slice + 1) + + hFractionElectronsDeltaProton->GetBinContent(slice + 1) + + (takeIntoAccountMuons ? hFractionMuonsDeltaProton->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaProton->GetBinContent(slice + 1) + hFractionProtonsDeltaProton->GetBinContent(slice + 1); + + Double_t SumFractionsUsed = hFractionPionsDeltaPion->GetBinContent(slice + 1) + + hFractionElectronsDeltaElectron->GetBinContent(slice + 1) + + (takeIntoAccountMuons ? hFractionMuonsDeltaPion->GetBinContent(slice + 1) : 0.) + + hFractionKaonsDeltaKaon->GetBinContent(slice + 1) + hFractionProtonsDeltaProton->GetBinContent(slice + 1); + + hFractionSummed->SetBinContent(slice + 1, SumFractionsUsed); + hFractionSummed->SetBinError(slice + 1, + TMath::Sqrt(TMath::Power(hFractionPionsDeltaPion->GetBinError(slice + 1), 2) + + TMath::Power(hFractionElectronsDeltaElectron->GetBinError(slice + 1), 2) + + (takeIntoAccountMuons ? TMath::Power(hFractionMuonsDeltaPion->GetBinError(slice + 1), + 2) : 0.) + + TMath::Power(hFractionKaonsDeltaKaon->GetBinError(slice + 1), 2) + + TMath::Power(hFractionProtonsDeltaProton->GetBinError(slice + 1), 2))); + + + std::cout << "Sum Fractions DeltaElectron: " << SumFractionsDeltaElectron; + std::cout << (TMath::Abs(SumFractionsDeltaElectron - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; + + std::cout << "Sum Fractions DeltaKaon: " << SumFractionsDeltaKaon; + std::cout << (TMath::Abs(SumFractionsDeltaKaon - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; + + std::cout << "Sum Fractions DeltaPion: " << SumFractionsDeltaPion; + std::cout << (TMath::Abs(SumFractionsDeltaPion - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; + + std::cout << "Sum fractions DeltaProton: " << SumFractionsDeltaProton; + std::cout << (TMath::Abs(SumFractionsDeltaProton - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; + + std::cout << "Sum fractions used: " << SumFractionsUsed; + std::cout << (TMath::Abs(SumFractionsUsed - 1) >= 0.001 ? " WARNING: Deviation >= 0.001" : "") << std::endl; + } + + for (Int_t species = 0; species < 4; species++) { + cSingleFit[slice][species]->Modified(); + cSingleFit[slice][species]->Update(); + } + + + } + + if (regularisation <= 0) + std::cout << std::endl << std::endl; + + + // MC results + Double_t MCtotal = -1, MCelectrons = -1, MCkaons = -1, MCmuons = -1, MCpions = -1, MCprotons = -1; + Double_t MCelectronsErr = 0, MCkaonsErr = 0, MCmuonsErr = 0, MCpionsErr = 0, MCprotonsErr = 0; + + MCelectrons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 1, 1, MCelectronsErr) * inverseBinWidth; + MCkaons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 2, 2, MCkaonsErr) * inverseBinWidth; + MCmuons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 3, 3, MCmuonsErr) * inverseBinWidth; + MCpions = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 4, 4, MCpionsErr) * inverseBinWidth; + MCprotons = hMCdata->IntegralAndError(pBinLowProjLimit, pBinUpProjLimit, 5, 5, MCprotonsErr) * inverseBinWidth; + + MCelectronsErr *= inverseBinWidth; + MCkaonsErr *= inverseBinWidth; + MCmuonsErr *= inverseBinWidth; + MCpionsErr *= inverseBinWidth; + MCprotonsErr *= inverseBinWidth; + + MCtotal = MCelectrons + MCkaons + MCpions + MCprotons + MCmuons; + + if (MCtotal > 0) { + hYieldElectronsMC->SetBinContent(slice + 1, MCelectrons); + hYieldElectronsMC->SetBinError(slice + 1, MCelectronsErr); + + hYieldMuonsMC->SetBinContent(slice + 1, MCmuons); + hYieldMuonsMC->SetBinError(slice + 1, MCmuonsErr); + + hYieldKaonsMC->SetBinContent(slice + 1, MCkaons); + hYieldKaonsMC->SetBinError(slice + 1, MCkaonsErr); + + hYieldPionsMC->SetBinContent(slice + 1, MCpions); + hYieldPionsMC->SetBinError(slice + 1, MCpionsErr); + + hYieldProtonsMC->SetBinContent(slice + 1, MCprotons); + hYieldProtonsMC->SetBinError(slice + 1, MCprotonsErr); + + hYieldSummedMC->SetBinContent(slice + 1, hYieldElectronsMC->GetBinContent(slice + 1) + + hYieldKaonsMC->GetBinContent(slice + 1) + + hYieldPionsMC->GetBinContent(slice + 1) + + hYieldProtonsMC->GetBinContent(slice + 1) + + hYieldMuonsMC->GetBinContent(slice + 1)); + hYieldSummedMC->SetBinError(slice + 1, TMath::Sqrt(TMath::Power(hYieldPionsMC->GetBinError(slice + 1), 2) + + TMath::Power(hYieldElectronsMC->GetBinError(slice + 1), 2) + + TMath::Power(hYieldKaonsMC->GetBinError(slice + 1), 2) + + TMath::Power(hYieldProtonsMC->GetBinError(slice + 1), 2) + + TMath::Power(hYieldMuonsMC->GetBinError(slice + 1), 2))); + + // MCspecies and MCtotal are correlated. This can be taken into account via using the binomial error in the division + hFractionElectronsMC->Divide(hYieldElectronsMC, hYieldSummedMC, 1., 1., "B"); + hFractionMuonsMC->Divide(hYieldMuonsMC, hYieldSummedMC, 1., 1., "B"); + hFractionKaonsMC->Divide(hYieldKaonsMC, hYieldSummedMC, 1., 1., "B"); + hFractionPionsMC->Divide(hYieldPionsMC, hYieldSummedMC, 1., 1., "B"); + hFractionProtonsMC->Divide(hYieldProtonsMC, hYieldSummedMC, 1., 1., "B"); + } + + // Save further results + if (slice % 18 == 0 || slice == pSliceLow) { + saveF->cd(); + + if (hFractionElectrons) + hFractionElectrons->Write(0, TObject::kWriteDelete); + + if (hFractionKaons) + hFractionKaons->Write(0, TObject::kWriteDelete); + + if (hFractionPions) + hFractionPions->Write(0, TObject::kWriteDelete); + + if (hFractionProtons) + hFractionProtons->Write(0, TObject::kWriteDelete); + + if (hFractionMuons) + hFractionMuons->Write(0, TObject::kWriteDelete); + + if (hFractionSummed) + hFractionSummed->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaElectron) + hFractionElectronsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaElectron) + hFractionKaonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaElectron) + hFractionPionsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaElectron) + hFractionProtonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaElectron) + hFractionMuonsDeltaElectron->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaPion) + hFractionElectronsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaPion) + hFractionKaonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaPion) + hFractionPionsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaPion) + hFractionProtonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaPion) + hFractionMuonsDeltaPion->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaKaon) + hFractionElectronsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaKaon) + hFractionKaonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaKaon) + hFractionPionsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaKaon) + hFractionProtonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaKaon) + hFractionMuonsDeltaKaon->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaProton) + hFractionElectronsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaProton) + hFractionKaonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaProton) + hFractionPionsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaProton) + hFractionProtonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaProton) + hFractionMuonsDeltaProton->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsMC) + hFractionElectronsMC->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsMC) + hFractionKaonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionPionsMC) + hFractionPionsMC->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsMC) + hFractionMuonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsMC) + hFractionProtonsMC->Write(0, TObject::kWriteDelete); + + + + + if (hYieldElectrons) + hYieldElectrons->Write(0, TObject::kWriteDelete); + + if (hYieldKaons) + hYieldKaons->Write(0, TObject::kWriteDelete); + + if (hYieldPions) + hYieldPions->Write(0, TObject::kWriteDelete); + + if (hYieldProtons) + hYieldProtons->Write(0, TObject::kWriteDelete); + + if (hYieldMuons) + hYieldMuons->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaElectron) + hYieldElectronsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaElectron) + hYieldKaonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaElectron) + hYieldPionsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaElectron) + hYieldProtonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaElectron) + hYieldMuonsDeltaElectron->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaPion) + hYieldElectronsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaPion) + hYieldKaonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaPion) + hYieldPionsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaPion) + hYieldProtonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaPion) + hYieldMuonsDeltaPion->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaKaon) + hYieldElectronsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaKaon) + hYieldKaonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaKaon) + hYieldPionsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaKaon) + hYieldProtonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaKaon) + hYieldMuonsDeltaKaon->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaProton) + hYieldElectronsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaProton) + hYieldKaonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaProton) + hYieldPionsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaProton) + hYieldProtonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaProton) + hYieldMuonsDeltaProton->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsMC) + hYieldElectronsMC->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsMC) + hYieldKaonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldPionsMC) + hYieldPionsMC->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsMC) + hYieldMuonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsMC) + hYieldProtonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldSummedMC) + hYieldSummedMC->Write(0, TObject::kWriteDelete); + } + + TString saveDir = (mode == kPMpT) ? Form("SingleFit_%.2f_Pt_%.2f", binsPt[slice], binsPt[slice + 1]) + : Form("SingleFit_%.2f_%s_%.2f", hFractionPions->GetXaxis()->GetBinLowEdge(slice + 1), + modeShortName[mode].Data(), hFractionPions->GetXaxis()->GetBinUpEdge(slice + 1)); + saveF->mkdir(saveDir.Data()); + saveF->cd(saveDir.Data()); + + for (Int_t species = 0; species < 4; species++) { + if (cSingleFit[slice][species]) { + cSingleFit[slice][species]->Write(); + delete cSingleFit[slice][species]; + } + } + + if (hDeltaPi[slice]) + hDeltaPi[slice]->Write(); + + if (hDeltaEl[slice]) + hDeltaEl[slice]->Write(); + + if (hDeltaKa[slice]) + hDeltaKa[slice]->Write(); + + if (hDeltaPr[slice]) + hDeltaPr[slice]->Write(); + + + if (hDeltaPiFitQA[slice]) + hDeltaPiFitQA[slice]->Write(); + delete hDeltaPiFitQA[slice]; + + if (hDeltaElFitQA[slice]) + hDeltaElFitQA[slice]->Write(); + delete hDeltaElFitQA[slice]; + + if (hDeltaKaFitQA[slice]) + hDeltaKaFitQA[slice]->Write(); + delete hDeltaKaFitQA[slice]; + + if (hDeltaPrFitQA[slice]) + hDeltaPrFitQA[slice]->Write(); + delete hDeltaPrFitQA[slice]; + + if (hGenDeltaElForElProj) + hGenDeltaElForElProj->Write(); + delete hGenDeltaElForElProj; + + if (hGenDeltaElForKaProj) + hGenDeltaElForKaProj->Write(); + delete hGenDeltaElForKaProj; + + if (hGenDeltaElForPiProj) + hGenDeltaElForPiProj->Write(); + delete hGenDeltaElForPiProj; + + if (hGenDeltaElForPrProj) + hGenDeltaElForPrProj->Write(); + delete hGenDeltaElForPrProj; + + if (hGenDeltaElForMuProj) + hGenDeltaElForMuProj->Write(); + delete hGenDeltaElForMuProj; + + //if (fitFuncTotalDeltaElectron[slice]) + // fitFuncTotalDeltaElectron[slice]->Write(); + delete fitFuncTotalDeltaElectron[slice]; + + if (hGenDeltaKaForElProj) + hGenDeltaKaForElProj->Write(); + delete hGenDeltaKaForElProj; + + if (hGenDeltaKaForKaProj) + hGenDeltaKaForKaProj->Write(); + delete hGenDeltaKaForKaProj; + + if (hGenDeltaKaForPiProj) + hGenDeltaKaForPiProj->Write(); + delete hGenDeltaKaForPiProj; + + if (hGenDeltaKaForPrProj) + hGenDeltaKaForPrProj->Write(); + delete hGenDeltaKaForPrProj; + + if (hGenDeltaKaForMuProj) + hGenDeltaKaForMuProj->Write(); + delete hGenDeltaKaForMuProj; + + //if (fitFuncTotalDeltaKaon[slice]) + // fitFuncTotalDeltaKaon[slice]->Write(); + delete fitFuncTotalDeltaKaon[slice]; + + + if (hGenDeltaPiForElProj) + hGenDeltaPiForElProj->Write(); + delete hGenDeltaPiForElProj; + + if (hGenDeltaPiForKaProj) + hGenDeltaPiForKaProj->Write(); + delete hGenDeltaPiForKaProj; + + if (hGenDeltaPiForPiProj) + hGenDeltaPiForPiProj->Write(); + delete hGenDeltaPiForPiProj; + + if (hGenDeltaPiForPrProj) + hGenDeltaPiForPrProj->Write(); + delete hGenDeltaPiForPrProj; + + if (hGenDeltaPiForMuProj) + hGenDeltaPiForMuProj->Write(); + delete hGenDeltaPiForMuProj; + + //if (fitFuncTotalDeltaPion[slice]) + // fitFuncTotalDeltaPion[slice]->Write(); + delete fitFuncTotalDeltaPion[slice]; + + + if (hGenDeltaPrForElProj) + hGenDeltaPrForElProj->Write(); + delete hGenDeltaPrForElProj; + + if (hGenDeltaPrForKaProj) + hGenDeltaPrForKaProj->Write(); + delete hGenDeltaPrForKaProj; + + if (hGenDeltaPrForPiProj) + hGenDeltaPrForPiProj->Write(); + delete hGenDeltaPrForPiProj; + + if (hGenDeltaPrForPrProj) + hGenDeltaPrForPrProj->Write(); + delete hGenDeltaPrForPrProj; + + if (hGenDeltaPrForMuProj) + hGenDeltaPrForMuProj->Write(); + delete hGenDeltaPrForMuProj; + + //if (fitFuncTotalDeltaProton[slice]) + // fitFuncTotalDeltaProton[slice]->Write(); + delete fitFuncTotalDeltaProton[slice]; + + delete totalDeltaElectron; + delete totalDeltaKaon; + delete totalDeltaPion; + delete totalDeltaProton; + + delete legend; + + if (errFlag != 0) + std::cout << "errFlag " << errFlag << std::endl << std::endl; + } + } + + // Calculate MC to-pi ratios -> In MC the yields are uncorrelated, so just divide the histos to get the correct result + hRatioToPiElectronsMC->Divide(hYieldElectronsMC, hYieldPionsMC); + hRatioToPiMuonsMC->Divide(hYieldMuonsMC, hYieldPionsMC); + hRatioToPiKaonsMC->Divide(hYieldKaonsMC, hYieldPionsMC); + hRatioToPiProtonsMC->Divide(hYieldProtonsMC, hYieldPionsMC); + + + TCanvas* cFractions = new TCanvas("cFractions", "Particle fractions",100,10,1200,800); + cFractions->SetGridx(1); + cFractions->SetGridy(1); + cFractions->SetLogx(mode == kPMpT); + hFractionPions->GetYaxis()->SetRangeUser(0.0, 1.0); + SetReasonableAxisRange(hFractionPions->GetXaxis(), mode, pLow, pHigh); + hFractionPions->GetXaxis()->SetMoreLogLabels(kTRUE); + hFractionPions->GetXaxis()->SetNoExponent(kTRUE); + hFractionPions->Draw("e p"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hFractionPionsMC->GetXaxis(), mode, pLow, pHigh); + hFractionPionsMC->Draw("e p same"); + } + + SetReasonableAxisRange(hFractionKaons->GetXaxis(), mode, pLow, pHigh); + hFractionKaons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hFractionKaonsMC->GetXaxis(), mode, pLow, pHigh); + hFractionKaonsMC->Draw("e p same"); + } + + SetReasonableAxisRange(hFractionProtons->GetXaxis(), mode, pLow, pHigh); + hFractionProtons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hFractionProtonsMC->GetXaxis(), mode, pLow, pHigh); + hFractionProtonsMC->Draw("e p same"); + } + + SetReasonableAxisRange(hFractionElectrons->GetXaxis(), mode, pLow, pHigh); + hFractionElectrons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hFractionElectronsMC->GetXaxis(), mode, pLow, pHigh); + hFractionElectronsMC->Draw("e p same"); + } + + if (takeIntoAccountMuons) { + SetReasonableAxisRange(hFractionMuons->GetXaxis(), mode, pLow, pHigh); + hFractionMuons->Draw("e p same"); + } + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hFractionMuonsMC->GetXaxis(), mode, pLow, pHigh); + hFractionMuonsMC->Draw("e p same"); + } + + hFractionSummed->Draw("e p same"); + + if (mode == kPMpT) { + fElectronFraction->SetRange(lowFittingBoundElectronFraction, pHigh); + fElectronFraction->Draw("same"); + } + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + if (plotIdentifiedSpectra) + legend->SetNColumns(2); + if (plotIdentifiedSpectra) + legend->AddEntry((TObject*)0x0, "Fit", ""); + if (plotIdentifiedSpectra) + legend->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); + legend->AddEntry(hFractionPions, "#pi", "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(hFractionPionsMC, "#pi", "p"); + legend->AddEntry(hFractionKaons, "K", "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(hFractionKaonsMC, "K", "p"); + legend->AddEntry(hFractionProtons, "p", "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(hFractionProtonsMC, "p", "p"); + legend->AddEntry(hFractionElectrons, "e", "p"); + if (plotIdentifiedSpectra) + legend->AddEntry(hFractionElectronsMC, "e", "p"); + if (takeIntoAccountMuons) + legend->AddEntry(hFractionMuons, "#mu", "p"); + else + legend->AddEntry((TObject*)0x0, "", ""); + if (plotIdentifiedSpectra) + legend->AddEntry(hFractionMuonsMC, "#mu", "p"); + legend->AddEntry(hFractionSummed, "Total", "p"); + legend->Draw(); + + ClearTitleFromHistoInCanvas(cFractions); + + + // Compare data points with MC + for (Int_t i = 1; i <= hFractionComparisonPions->GetNbinsX(); i++) { + hFractionComparisonPions->SetBinContent(i, hFractionPions->GetBinContent(i)); + hFractionComparisonPions->SetBinError(i, hFractionPions->GetBinError(i)); + + hFractionComparisonElectrons->SetBinContent(i, hFractionElectrons->GetBinContent(i)); + hFractionComparisonElectrons->SetBinError(i, hFractionElectrons->GetBinError(i)); + + if (takeIntoAccountMuons) { + hFractionComparisonMuons->SetBinContent(i, hFractionMuons->GetBinContent(i)); + hFractionComparisonMuons->SetBinError(i, hFractionMuons->GetBinError(i)); + } + + hFractionComparisonKaons->SetBinContent(i, hFractionKaons->GetBinContent(i)); + hFractionComparisonKaons->SetBinError(i, hFractionKaons->GetBinError(i)); + + hFractionComparisonProtons->SetBinContent(i, hFractionProtons->GetBinContent(i)); + hFractionComparisonProtons->SetBinError(i, hFractionProtons->GetBinError(i)); + + hFractionComparisonTotal->SetBinContent(i, hFractionSummed->GetBinContent(i)); + hFractionComparisonTotal->SetBinError(i, hFractionSummed->GetBinError(i)); + } + + hFractionComparisonPions->Divide(hFractionPionsMC); + hFractionComparisonElectrons->Divide(hFractionElectronsMC); + if (takeIntoAccountMuons) + hFractionComparisonMuons->Divide(hFractionMuonsMC); + hFractionComparisonKaons->Divide(hFractionKaonsMC); + hFractionComparisonProtons->Divide(hFractionProtonsMC); + + + TCanvas* cFractionComparisons = new TCanvas("cFractionComparisons", "Particle fraction comparisons",100,10,1200,800); + cFractionComparisons->SetGridx(1); + cFractionComparisons->SetGridy(1); + cFractionComparisons->SetLogx(mode == kPMpT); + hFractionComparisonPions->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonPions->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonPions->GetXaxis()->SetMoreLogLabels(kTRUE); + hFractionComparisonPions->GetXaxis()->SetNoExponent(kTRUE); + hFractionComparisonPions->Draw("e p"); + + hFractionComparisonElectrons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonElectrons->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonElectrons->Draw("e p same"); + + if (takeIntoAccountMuons) { + hFractionComparisonMuons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonMuons->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonMuons->Draw("e p same"); + } + + hFractionComparisonKaons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonKaons->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonKaons->Draw("e p same"); + + hFractionComparisonProtons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonProtons->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonProtons->Draw("e p same"); + + hFractionComparisonTotal->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hFractionComparisonTotal->GetXaxis(), mode, pLow, pHigh); + hFractionComparisonTotal->Draw("e p same"); + + TLegend* legend2 = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend2->SetBorderSize(0); + legend2->SetFillColor(0); + legend2->SetNColumns(2); + legend2->AddEntry(hFractionComparisonPions, "#pi", "p"); + legend2->AddEntry(hFractionComparisonKaons, "K", "p"); + legend2->AddEntry(hFractionComparisonProtons, "p", "p"); + legend2->AddEntry(hFractionComparisonElectrons, "e", "p"); + if (takeIntoAccountMuons) + legend2->AddEntry(hFractionComparisonMuons, "#mu", "p"); + legend2->AddEntry(hFractionComparisonTotal, "Total", "p"); + legend2->Draw(); + + ClearTitleFromHistoInCanvas(cFractionComparisons); + + // Normalise the yields + normaliseYieldHist(hYieldPions, numEvents, deta); + normaliseYieldHist(hYieldPionsMC, numEvents, deta); + normaliseYieldHist(hYieldPionsDeltaElectron, numEvents, deta); + normaliseYieldHist(hYieldPionsDeltaPion, numEvents, deta); + normaliseYieldHist(hYieldPionsDeltaKaon, numEvents, deta); + normaliseYieldHist(hYieldPionsDeltaProton, numEvents, deta); + + normaliseYieldHist(hYieldElectrons, numEvents, deta); + normaliseYieldHist(hYieldElectronsMC, numEvents, deta); + normaliseYieldHist(hYieldElectronsDeltaElectron, numEvents, deta); + normaliseYieldHist(hYieldElectronsDeltaPion, numEvents, deta); + normaliseYieldHist(hYieldElectronsDeltaKaon, numEvents, deta); + normaliseYieldHist(hYieldElectronsDeltaProton, numEvents, deta); + + normaliseYieldHist(hYieldMuons, numEvents, deta); + normaliseYieldHist(hYieldMuonsMC, numEvents, deta); + normaliseYieldHist(hYieldMuonsDeltaElectron, numEvents, deta); + normaliseYieldHist(hYieldMuonsDeltaPion, numEvents, deta); + normaliseYieldHist(hYieldMuonsDeltaKaon, numEvents, deta); + normaliseYieldHist(hYieldMuonsDeltaProton, numEvents, deta); + + normaliseYieldHist(hYieldKaons, numEvents, deta); + normaliseYieldHist(hYieldKaonsMC, numEvents, deta); + normaliseYieldHist(hYieldKaonsDeltaElectron, numEvents, deta); + normaliseYieldHist(hYieldKaonsDeltaPion, numEvents, deta); + normaliseYieldHist(hYieldKaonsDeltaKaon, numEvents, deta); + normaliseYieldHist(hYieldKaonsDeltaProton, numEvents, deta); + + normaliseYieldHist(hYieldProtons, numEvents, deta); + normaliseYieldHist(hYieldProtonsMC, numEvents, deta); + normaliseYieldHist(hYieldProtonsDeltaElectron, numEvents, deta); + normaliseYieldHist(hYieldProtonsDeltaPion, numEvents, deta); + normaliseYieldHist(hYieldProtonsDeltaKaon, numEvents, deta); + normaliseYieldHist(hYieldProtonsDeltaProton, numEvents, deta); + + normaliseYieldHist(hYieldSummedMC, numEvents, deta); + + for (Int_t i = 0; i < AliPID::kSPECIES; i++) { + if (hMCgenYieldsPrimSpecies[i]) { + Int_t color = kBlack; + + switch (i) { + case AliPID::kElectron: + color = getLineColor(kEl); + break; + case AliPID::kKaon: + color = getLineColor(kKa); + break; + case AliPID::kMuon: + color = getLineColor(kMu); + break; + case AliPID::kPion: + color = getLineColor(kPi); + break; + case AliPID::kProton: + color = getLineColor(kPr); + break; + } + + hMCgenYieldsPrimSpecies[i]->SetLineColor(color); + hMCgenYieldsPrimSpecies[i]->SetMarkerColor(color); + hMCgenYieldsPrimSpecies[i]->SetMarkerStyle(28); + hMCgenYieldsPrimSpecies[i]->SetLineStyle(1); + hMCgenYieldsPrimSpecies[i]->GetXaxis()->SetTitleOffset(1.0); + hMCgenYieldsPrimSpecies[i]->SetStats(kFALSE); + + SetReasonableAxisRange(hMCgenYieldsPrimSpecies[i]->GetXaxis(), kPMpT, pLow, pHigh); + normaliseGenYieldMCtruthHist(hMCgenYieldsPrimSpecies[i], numEvents, deta); + } + } + + + // Compare data points with MC (yield) + for (Int_t i = 1; i <= hYieldComparisonPions->GetNbinsX(); i++) { + hYieldComparisonPions->SetBinContent(i, hYieldPions->GetBinContent(i)); + hYieldComparisonPions->SetBinError(i, hYieldPions->GetBinError(i)); + + hYieldComparisonElectrons->SetBinContent(i, hYieldElectrons->GetBinContent(i)); + hYieldComparisonElectrons->SetBinError(i, hYieldElectrons->GetBinError(i)); + + if (takeIntoAccountMuons) { + hYieldComparisonMuons->SetBinContent(i, hYieldMuons->GetBinContent(i)); + hYieldComparisonMuons->SetBinError(i, hYieldMuons->GetBinError(i)); + } + + hYieldComparisonKaons->SetBinContent(i, hYieldKaons->GetBinContent(i)); + hYieldComparisonKaons->SetBinError(i, hYieldKaons->GetBinError(i)); + + hYieldComparisonProtons->SetBinContent(i, hYieldProtons->GetBinContent(i)); + hYieldComparisonProtons->SetBinError(i, hYieldProtons->GetBinError(i)); + } + + hYieldComparisonPions->Divide(hYieldPionsMC); + hYieldComparisonElectrons->Divide(hYieldElectronsMC); + if (takeIntoAccountMuons) + hYieldComparisonMuons->Divide(hYieldMuonsMC); + hYieldComparisonKaons->Divide(hYieldKaonsMC); + hYieldComparisonProtons->Divide(hYieldProtonsMC); + + + TCanvas* cYieldComparisons = new TCanvas("cYieldComparisons", "Particle yield comparisons",100,10,1200,800); + cYieldComparisons->SetGridx(1); + cYieldComparisons->SetGridy(1); + cYieldComparisons->SetLogx(mode == kPMpT); + hYieldComparisonPions->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hYieldComparisonPions->GetXaxis(), mode, pLow, pHigh); + hYieldComparisonPions->GetXaxis()->SetMoreLogLabels(kTRUE); + hYieldComparisonPions->GetXaxis()->SetNoExponent(kTRUE); + hYieldComparisonPions->Draw("e p"); + + hYieldComparisonElectrons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hYieldComparisonElectrons->GetXaxis(), mode, pLow, pHigh); + hYieldComparisonElectrons->Draw("e p same"); + + if (takeIntoAccountMuons) { + hYieldComparisonMuons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hYieldComparisonMuons->GetXaxis(), mode, pLow, pHigh); + hYieldComparisonMuons->Draw("e p same"); + } + + hYieldComparisonKaons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hYieldComparisonKaons->GetXaxis(), mode, pLow, pHigh); + hYieldComparisonKaons->Draw("e p same"); + + hYieldComparisonProtons->GetYaxis()->SetRangeUser(0.0, 10.0); + SetReasonableAxisRange(hYieldComparisonProtons->GetXaxis(), mode, pLow, pHigh); + hYieldComparisonProtons->Draw("e p same"); + + TLegend* legend3 = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend3->SetBorderSize(0); + legend3->SetFillColor(0); + legend3->SetNColumns(2); + legend3->AddEntry(hYieldComparisonPions, "#pi", "p"); + legend3->AddEntry(hYieldComparisonKaons, "K", "p"); + legend3->AddEntry(hYieldComparisonProtons, "p", "p"); + legend3->AddEntry(hYieldComparisonElectrons, "e", "p"); + if (takeIntoAccountMuons) + legend3->AddEntry(hYieldComparisonMuons, "#mu", "p"); + legend3->Draw(); + + ClearTitleFromHistoInCanvas(cYieldComparisons); + + + + + TCanvas* cFractionsPions = drawFractionHistos("cFractionsPions", "Pion fractions", mode, pLow, pHigh, hFractionPionsDeltaPion, + hFractionPionsDeltaElectron, hFractionPionsDeltaKaon, hFractionPionsDeltaProton, + hFractionPionsMC, plotIdentifiedSpectra); + + + TCanvas* cFractionsElectrons = drawFractionHistos("cFractionsElectrons", "Electron fractions", mode, pLow, pHigh, + hFractionElectronsDeltaPion, hFractionElectronsDeltaElectron, + hFractionElectronsDeltaKaon, hFractionElectronsDeltaProton, hFractionElectronsMC, + plotIdentifiedSpectra); + + TCanvas* cFractionsKaons = drawFractionHistos("cFractionsKaons", "Kaon fractions", mode, pLow, pHigh, hFractionKaonsDeltaPion, + hFractionKaonsDeltaElectron, hFractionKaonsDeltaKaon, hFractionKaonsDeltaProton, + hFractionKaonsMC, plotIdentifiedSpectra); + + TCanvas* cFractionsProtons = drawFractionHistos("cFractionsProtons", "Proton fractions", mode, pLow, pHigh, hFractionProtonsDeltaPion, + hFractionProtonsDeltaElectron, hFractionProtonsDeltaKaon, hFractionProtonsDeltaProton, + hFractionProtonsMC, plotIdentifiedSpectra); + + TCanvas* cFractionsMuons = drawFractionHistos("cFractionsMuons", "Muon fractions", mode, pLow, pHigh, hFractionMuonsDeltaPion, + hFractionMuonsDeltaElectron, hFractionMuonsDeltaKaon, hFractionMuonsDeltaProton, + hFractionMuonsMC, plotIdentifiedSpectra); + + + + TCanvas* cYields = new TCanvas("cYields", "Particle yields",100,10,1200,800); + cYields->SetGridx(1); + cYields->SetGridy(1); + cYields->SetLogx(mode == kPMpT); + cYields->SetLogy(1); + hYieldPions->GetYaxis()->SetRangeUser(hYieldElectrons->GetBinContent(hYieldElectrons->FindLastBinAbove(0.)) / 10., + hYieldPions->GetBinContent(hYieldPions->GetMaximumBin()) * 10.); + SetReasonableAxisRange(hYieldPions->GetXaxis(), mode, pLow, pHigh); + hYieldPions->GetXaxis()->SetMoreLogLabels(kTRUE); + hYieldPions->GetXaxis()->SetNoExponent(kTRUE); + hYieldPions->Draw("e p"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hYieldPionsMC->GetXaxis(), mode, pLow, pHigh); + hYieldPionsMC->Draw("e p same"); + } + + SetReasonableAxisRange(hYieldKaons->GetXaxis(), mode, pLow, pHigh); + hYieldKaons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hYieldKaonsMC->GetXaxis(), mode, pLow, pHigh); + hYieldKaonsMC->Draw("e p same"); + } + + SetReasonableAxisRange(hYieldProtons->GetXaxis(), mode, pLow, pHigh); + hYieldProtons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hYieldProtonsMC->GetXaxis(), mode, pLow, pHigh); + hYieldProtonsMC->Draw("e p same"); + } + + if (takeIntoAccountMuons) { + SetReasonableAxisRange(hYieldMuons->GetXaxis(), mode, pLow, pHigh); + hYieldMuons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hYieldMuonsMC->GetXaxis(), mode, pLow, pHigh); + hYieldMuonsMC->Draw("e p same"); + } + } + + SetReasonableAxisRange(hYieldElectrons->GetXaxis(), mode, pLow, pHigh); + hYieldElectrons->Draw("e p same"); + if (plotIdentifiedSpectra) { + SetReasonableAxisRange(hYieldElectronsMC->GetXaxis(), mode, pLow, pHigh); + hYieldElectronsMC->Draw("e p same"); + } + + TLegend* legendYields = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legendYields->SetBorderSize(0); + legendYields->SetFillColor(0); + if (plotIdentifiedSpectra) + legendYields->SetNColumns(2); + if (plotIdentifiedSpectra) + legendYields->AddEntry((TObject*)0x0, "Fit", ""); + if (plotIdentifiedSpectra) + legendYields->AddEntry((TObject*)0x0, identifiedLabels[isMC].Data(), ""); + legendYields->AddEntry(hYieldPions, "#pi", "p"); + if (plotIdentifiedSpectra) + legendYields->AddEntry(hYieldPionsMC, "#pi", "p"); + legendYields->AddEntry(hYieldKaons, "K", "p"); + if (plotIdentifiedSpectra) + legendYields->AddEntry(hYieldKaonsMC, "K", "p"); + legendYields->AddEntry(hYieldProtons, "p", "p"); + if (plotIdentifiedSpectra) + legendYields->AddEntry(hYieldProtonsMC, "p", "p"); + legendYields->AddEntry(hYieldElectrons, "e", "p"); + if (plotIdentifiedSpectra) + legendYields->AddEntry(hYieldElectronsMC, "e", "p"); + if (takeIntoAccountMuons) + legendYields->AddEntry(hYieldMuons, "#mu", "p"); + else + legendYields->AddEntry((TObject*)0x0, "", ""); + if (plotIdentifiedSpectra) + legendYields->AddEntry(hYieldMuonsMC, "#mu", "p"); + legendYields->Draw(); + + ClearTitleFromHistoInCanvas(cYields); + + + TCanvas* cYieldsPions = drawYieldHistos("cYieldsPions", "Pion yields", mode, pLow, pHigh, hYieldPionsDeltaPion, hYieldPionsDeltaElectron, + hYieldPionsDeltaKaon, hYieldPionsDeltaProton, hYieldPionsMC, plotIdentifiedSpectra); + + + TCanvas* cYieldsElectrons = drawYieldHistos("cYieldsElectrons", "Electron yields", mode, pLow, pHigh, hYieldElectronsDeltaPion, + hYieldElectronsDeltaElectron, hYieldElectronsDeltaKaon, hYieldElectronsDeltaProton, hYieldElectronsMC, + plotIdentifiedSpectra); + + TCanvas* cYieldsKaons = drawYieldHistos("cYieldsKaons", "Kaon yields", mode, pLow, pHigh, hYieldKaonsDeltaPion, hYieldKaonsDeltaElectron, + hYieldKaonsDeltaKaon, hYieldKaonsDeltaProton, hYieldKaonsMC, plotIdentifiedSpectra); + + TCanvas* cYieldsProtons = drawYieldHistos("cYieldsProtons", "Proton yields", mode, pLow, pHigh, hYieldProtonsDeltaPion, hYieldProtonsDeltaElectron, + hYieldProtonsDeltaKaon, hYieldProtonsDeltaProton, hYieldProtonsMC, plotIdentifiedSpectra); + + TCanvas* cYieldsMuons = drawYieldHistos("cYieldsMuons", "Muon yields", mode, pLow, pHigh, hYieldMuonsDeltaPion, hYieldMuonsDeltaElectron, + hYieldMuonsDeltaKaon, hYieldMuonsDeltaProton, hYieldMuonsMC, plotIdentifiedSpectra); + + + // Save final results + saveF->cd(); + + if (fElectronFraction) + fElectronFraction->Write(); + + if (hFractionElectrons) + hFractionElectrons->Write(0, TObject::kWriteDelete); + + if (hFractionKaons) + hFractionKaons->Write(0, TObject::kWriteDelete); + + if (hFractionPions) + hFractionPions->Write(0, TObject::kWriteDelete); + + if (hFractionProtons) + hFractionProtons->Write(0, TObject::kWriteDelete); + + if (hFractionMuons) + hFractionMuons->Write(0, TObject::kWriteDelete); + + if (hFractionSummed) + hFractionSummed->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaElectron) + hFractionElectronsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaElectron) + hFractionKaonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaElectron) + hFractionPionsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaElectron) + hFractionProtonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaElectron) + hFractionMuonsDeltaElectron->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaPion) + hFractionElectronsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaPion) + hFractionKaonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaPion) + hFractionPionsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaPion) + hFractionProtonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaPion) + hFractionMuonsDeltaPion->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaKaon) + hFractionElectronsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaKaon) + hFractionKaonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaKaon) + hFractionPionsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaKaon) + hFractionProtonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaKaon) + hFractionMuonsDeltaKaon->Write(0, TObject::kWriteDelete); + + + if (hFractionElectronsDeltaProton) + hFractionElectronsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsDeltaProton) + hFractionKaonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionPionsDeltaProton) + hFractionPionsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsDeltaProton) + hFractionProtonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsDeltaProton) + hFractionMuonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hNumEvents) + hNumEvents->Write(); + + if (cFractions) + cFractions->Write(); + if (cFractionsPions) + cFractionsPions->Write(); + if (cFractionsElectrons) + cFractionsElectrons->Write(); + if (cFractionsKaons) + cFractionsKaons->Write(); + if (cFractionsProtons) + cFractionsProtons->Write(); + if (cFractionsMuons) + cFractionsMuons->Write(); + + + if (hFractionElectronsMC) + hFractionElectronsMC->Write(0, TObject::kWriteDelete); + + if (hFractionKaonsMC) + hFractionKaonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionPionsMC) + hFractionPionsMC->Write(0, TObject::kWriteDelete); + + if (hFractionMuonsMC) + hFractionMuonsMC->Write(0, TObject::kWriteDelete); + + if (hFractionProtonsMC) + hFractionProtonsMC->Write(0, TObject::kWriteDelete); + + + if (hFractionComparisonElectrons) + hFractionComparisonElectrons->Write(0, TObject::kWriteDelete); + + if (hFractionComparisonMuons) + hFractionComparisonMuons->Write(0, TObject::kWriteDelete); + + if (hFractionComparisonKaons) + hFractionComparisonKaons->Write(0, TObject::kWriteDelete); + + if (hFractionComparisonPions) + hFractionComparisonPions->Write(0, TObject::kWriteDelete); + + if (hFractionComparisonProtons) + hFractionComparisonProtons->Write(0, TObject::kWriteDelete); + + if (hFractionComparisonTotal) + hFractionComparisonTotal->Write(0, TObject::kWriteDelete); + + if (cFractionComparisons) + cFractionComparisons->Write(); + + + if (hYieldComparisonElectrons) + hYieldComparisonElectrons->Write(0, TObject::kWriteDelete); + + if (hYieldComparisonMuons) + hYieldComparisonMuons->Write(0, TObject::kWriteDelete); + + if (hYieldComparisonKaons) + hYieldComparisonKaons->Write(0, TObject::kWriteDelete); + + if (hYieldComparisonPions) + hYieldComparisonPions->Write(0, TObject::kWriteDelete); + + if (hYieldComparisonProtons) + hYieldComparisonProtons->Write(0, TObject::kWriteDelete); + + if (cYieldComparisons) + cYieldComparisons->Write(); + + + if (hYieldElectrons) + hYieldElectrons->Write(0, TObject::kWriteDelete); + + if (hYieldKaons) + hYieldKaons->Write(0, TObject::kWriteDelete); + + if (hYieldPions) + hYieldPions->Write(0, TObject::kWriteDelete); + + if (hYieldProtons) + hYieldProtons->Write(0, TObject::kWriteDelete); + + if (hYieldMuons) + hYieldMuons->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaElectron) + hYieldElectronsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaElectron) + hYieldKaonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaElectron) + hYieldPionsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaElectron) + hYieldProtonsDeltaElectron->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaElectron) + hYieldMuonsDeltaElectron->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaPion) + hYieldElectronsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaPion) + hYieldKaonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaPion) + hYieldPionsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaPion) + hYieldProtonsDeltaPion->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaPion) + hYieldMuonsDeltaPion->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaKaon) + hYieldElectronsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaKaon) + hYieldKaonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaKaon) + hYieldPionsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaKaon) + hYieldProtonsDeltaKaon->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaKaon) + hYieldMuonsDeltaKaon->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsDeltaProton) + hYieldElectronsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsDeltaProton) + hYieldKaonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldPionsDeltaProton) + hYieldPionsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsDeltaProton) + hYieldProtonsDeltaProton->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsDeltaProton) + hYieldMuonsDeltaProton->Write(0, TObject::kWriteDelete); + + + if (hYieldElectronsMC) + hYieldElectronsMC->Write(0, TObject::kWriteDelete); + + if (hYieldKaonsMC) + hYieldKaonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldPionsMC) + hYieldPionsMC->Write(0, TObject::kWriteDelete); + + if (hYieldMuonsMC) + hYieldMuonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldProtonsMC) + hYieldProtonsMC->Write(0, TObject::kWriteDelete); + + if (hYieldSummedMC) + hYieldSummedMC->Write(0, TObject::kWriteDelete); + + + if (hRatioToPiElectrons) + hRatioToPiElectrons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiMuons) + hRatioToPiMuons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiKaons) + hRatioToPiKaons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiProtons) + hRatioToPiProtons->Write(0, TObject::kWriteDelete); + + if (hRatioToPiElectronsMC) + hRatioToPiElectronsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiMuonsMC) + hRatioToPiMuonsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiKaonsMC) + hRatioToPiKaonsMC->Write(0, TObject::kWriteDelete); + + if (hRatioToPiProtonsMC) + hRatioToPiProtonsMC->Write(0, TObject::kWriteDelete); + + + + if (hReducedChiSquarePt) + hReducedChiSquarePt->Write(0, TObject::kWriteDelete); + + if (cYields) + cYields->Write(); + if (cYieldsPions) + cYieldsPions->Write(); + if (cYieldsElectrons) + cYieldsElectrons->Write(); + if (cYieldsKaons) + cYieldsKaons->Write(); + if (cYieldsProtons) + cYieldsProtons->Write(); + if (cYieldsMuons) + cYieldsMuons->Write(); + + for (Int_t i = 0; i < AliPID::kSPECIES; i++) { + if (hMCgenYieldsPrimSpecies[i]) + hMCgenYieldsPrimSpecies[i]->Write(); + } + + if (filePathNameResults) + *filePathNameResults = saveFName; + + if (TMath::Abs(mathFit->GetScaleFactorError() - 1.) > 1e-6) { + // If the deltaPrime range is large enough, we artificially get a factor 4 in statistics by looking at the four + // different deltaPrimeSpecies, which have (except for binning effects) the same information. + // Therefore, to get the "real" statistical error, we need to multiply the obtained error by sqrt(4) = 2 + std::cout << "NOTE: Errors multiplied by " << mathFit->GetScaleFactorError() + << " to take into account artificially higher statistics (by factor of 4) due to same information " + << "for all deltaPrimeSpecies (except for binning effects), if deltaPrimeRange sufficiently large!" << std::endl + << std::endl; + } + + if (fitMethod < 2) { + std::cout << "WARNING: Errors might be wrong! Especially, for the to-pi ratios there are no correlations taken into account!" + << std::endl; + } + + delete gFractionElectronsData; + delete fElectronFraction; + + delete mathFit; + + delete cFractions; + delete cFractionComparisons; + delete cYieldComparisons; + delete cFractionsPions; + delete cFractionsElectrons; + delete cFractionsKaons; + delete cFractionsProtons; + delete cFractionsMuons; + delete cYields; + delete cYieldsPions; + delete cYieldsKaons; + delete cYieldsMuons; + delete cYieldsProtons; + delete cYieldsElectrons; + + saveF->Close(); + + return 0; +} diff --git a/PWGJE/macros/PID/SystematicErrorEstimation.C b/PWGJE/macros/PID/SystematicErrorEstimation.C index 0585f56c25b..9577db8ba4d 100644 --- a/PWGJE/macros/PID/SystematicErrorEstimation.C +++ b/PWGJE/macros/PID/SystematicErrorEstimation.C @@ -1,517 +1,517 @@ -#include "TCanvas.h" -#include "TFile.h" -#include "TGraphErrors.h" -#include "TGraphAsymmErrors.h" -#include "TGraph.h" -#include "TF1.h" -#include "TH1D.h" -#include "TLegend.h" -#include "TMath.h" -#include "TString.h" -#include "TStyle.h" - -#include "AliPID.h" - -#include -#include - -#include "SystematicErrorUtils.h" - -const Int_t numSpecies = 5; - -//________________________________________________________ -TCanvas* calculateSystematics(TString canvName, TString canvTitle, TH1F** histos, Int_t numHistos, Int_t speciesID, Double_t /*nSigma*/, - const TString* systematicsHistosName, Int_t reference, TH1F** hSystematics, TGraphAsymmErrors** gr, - Bool_t ignoreSigmaErrors) -{ - // For every bin: - // Since the method with the root finding already takes into account the statistical error, - // there is no need to use nSigma > 0. - // If the statistical error is ignored, nevertheless don't use nSigma > 0 because this might - // give zero systematic error for high pT, which is usually not accepted by people, although - // the natural point of view "no systematic visible for given statistical error" is reasonable to me. - - Double_t ymax = 0; - Double_t ymin = 0; - - - // Just for drawing - for (Int_t j = 0; j < numHistos; j++) { - hSystematics[j] = new TH1F(*histos[j]); - hSystematics[j]->SetName(Form("%s_%s", systematicsHistosName[j].Data(), AliPID::ParticleName(speciesID))); - hSystematics[j]->Reset(); - hSystematics[j]->GetXaxis()->SetRange(0, -1); - - for (Int_t bin = 1; bin <= histos[j]->GetNbinsX(); bin++) { - hSystematics[j]->SetBinContent(bin, histos[reference]->GetBinContent(bin) - histos[j]->GetBinContent(bin)); - hSystematics[j]->SetBinError(bin, TMath::Sqrt(TMath::Abs(TMath::Power(histos[reference]->GetBinError(bin), 2) - - TMath::Power(histos[j]->GetBinError(bin), 2)))); - - if (hSystematics[j]->GetBinError(bin) == 0) - hSystematics[j]->SetBinError(bin, 1e-10); - Double_t temp = hSystematics[j]->GetBinContent(bin) + hSystematics[j]->GetBinError(bin); - if (temp > ymax) - ymax = temp; - - temp = hSystematics[j]->GetBinContent(bin) - hSystematics[j]->GetBinError(bin); - if (temp < ymin) - ymin = temp; - } - } - - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridy(1); - - hSystematics[reference]->Draw("e p"); - hSystematics[reference]->GetYaxis()->SetRangeUser(ymin, ymax); - for (Int_t j = 0; j < numHistos; j++) { - if (j == reference) - continue; - - hSystematics[j]->SetMarkerStyle(20 + j); - hSystematics[j]->Draw("e p same"); - } - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - - for (Int_t j = 0; j < numHistos; j++) { - legend->AddEntry(hSystematics[j], Form("%s", systematicsHistosName[j].Data()), "p"); - } - legend->Draw(); - - - const Int_t nBins = histos[reference]->GetNbinsX(); - Double_t x[nBins]; - Double_t y[nBins]; - Double_t xerr[nBins]; - Double_t yerrl[nBins]; - Double_t yerrh[nBins]; - - Double_t meansForFit[numHistos]; - Double_t sigmasForFit[numHistos]; - - for (Int_t bin = 0; bin < nBins; bin++) { - x[bin] = histos[reference]->GetBinCenter(bin + 1); - xerr[bin] = histos[reference]->GetBinWidth(bin + 1) / 2.; - y[bin] = histos[reference]->GetBinContent(bin + 1); - - for (Int_t j = 0; j < numHistos; j++) { - meansForFit[j] = histos[j]->GetBinContent(bin + 1); - sigmasForFit[j] = histos[j]->GetBinError(bin + 1); - } - - yerrl[bin] = yerrh[bin] = findSystematicError(numHistos, meansForFit, sigmasForFit, ignoreSigmaErrors); - } - - TGraphAsymmErrors* gTemp = new TGraphAsymmErrors(nBins, x, y, xerr, xerr, yerrl, yerrh); - *gr = gTemp; - (*gr)->SetName(Form("systematicError_%s", AliPID::ParticleName(speciesID))); - (*gr)->SetLineColor(hSystematics[0]->GetMarkerColor()); - //(*gr)->SetFillColor(kGray); - (*gr)->SetFillStyle(0);//3004 + reference); - - return canv; -} - - -/*OLD -//________________________________________________________ -TCanvas* calculateSystematics(TString canvName, TString canvTitle, TH1F** histos, Int_t numHistos, Int_t speciesID, Double_t nSigma, - const TString* systematicsHistosName, Int_t reference, TH1F** hSystematics, TGraphAsymmErrors** gr) -{ - Double_t ymax = 0; - Double_t ymin = 0; - - for (Int_t j = 0; j < numHistos; j++) { - hSystematics[j] = new TH1F(*histos[j]); - hSystematics[j]->SetName(Form("%s_%s", systematicsHistosName[j].Data(), AliPID::ParticleName(speciesID))); - hSystematics[j]->Reset(); - hSystematics[j]->GetXaxis()->SetRange(0, -1); - - for (Int_t bin = 1; bin <= histos[j]->GetNbinsX(); bin++) { - hSystematics[j]->SetBinContent(bin, histos[reference]->GetBinContent(bin) - histos[j]->GetBinContent(bin)); - hSystematics[j]->SetBinError(bin, TMath::Sqrt(TMath::Abs(TMath::Power(histos[reference]->GetBinError(bin), 2) - - TMath::Power(histos[j]->GetBinError(bin), 2)))); - - if (hSystematics[j]->GetBinError(bin) == 0) - hSystematics[j]->SetBinError(bin, 1e-10); - Double_t temp = hSystematics[j]->GetBinContent(bin) + hSystematics[j]->GetBinError(bin); - if (temp > ymax) - ymax = temp; - - temp = hSystematics[j]->GetBinContent(bin) - hSystematics[j]->GetBinError(bin); - if (temp < ymin) - ymin = temp; - } - } - - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridy(1); - - hSystematics[reference]->Draw("e p"); - hSystematics[reference]->GetYaxis()->SetRangeUser(ymin, ymax); - for (Int_t j = 0; j < numHistos; j++) { - if (j == reference) - continue; - - hSystematics[j]->SetMarkerStyle(20 + j); - hSystematics[j]->Draw("e p same"); - } - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - - for (Int_t j = 0; j < numHistos; j++) { - legend->AddEntry(hSystematics[j], Form("%s", systematicsHistosName[j].Data()), "p"); - } - legend->Draw(); - - - const Int_t nBins = histos[reference]->GetNbinsX(); - Double_t x[nBins]; - Double_t y[nBins]; - Double_t xerr[nBins]; - Double_t yerrl[nBins]; - Double_t yerrh[nBins]; - - for (Int_t bin = 0; bin < nBins; bin++) { - x[bin] = histos[reference]->GetBinCenter(bin + 1); - xerr[bin] = histos[reference]->GetBinWidth(bin + 1) / 2.; - y[bin] = histos[reference]->GetBinContent(bin + 1); - - // Take all points that are more than nSigma sigma away from 0. - // If there are at least 2 such points, take the difference between - // the extreme values (i.e. maximum and minimum) as a measure of - // the systematics - Int_t count = 0; - Double_t deltaMin = 0; - Double_t deltaMax = 0; - - for (Int_t j = 0; j < numHistos; j++) { - if (hSystematics[j]->GetBinError(bin + 1) == 0) // Per definition always true for reference histo - continue; - - Double_t delta = hSystematics[j]->GetBinContent(bin + 1); - if (TMath::Abs(delta / hSystematics[j]->GetBinError(bin + 1)) > nSigma) { - //if (count == 0) { - // deltaMin = delta; - // deltaMax = delta; - //} - //else { - if (delta < deltaMin) - deltaMin = delta; - if (delta > deltaMax) - deltaMax = delta; - //} - count++; - } - } - - //if (deltaMax > 0.) - // yerrh[bin] = deltaMax; - //else - // yerrh[bin] = 0.; - // - //if (deltaMin < 0.) - // yerrl[bin] = -deltaMin; - //else - // yerrl[bin] = 0.; - - if (count < 1) // Reference histo is not counted. One can only do systematics if there is at least one other histogram - yerrl[bin] = yerrh[bin] = 0.; - else - yerrl[bin] = yerrh[bin] = (deltaMax - deltaMin) / TMath::Sqrt(2); - - } - - TGraphAsymmErrors* gTemp = new TGraphAsymmErrors(nBins, x, y, xerr, xerr, yerrl, yerrh); - *gr = gTemp; - (*gr)->SetName(Form("systematicError_%s", AliPID::ParticleName(speciesID))); - (*gr)->SetLineColor(hSystematics[0]->GetMarkerColor()); - //(*gr)->SetFillColor(kGray); - (*gr)->SetFillStyle(0);//3004 + reference); - - return canv; -}*/ - - -//________________________________________________________ -TCanvas* DrawFractionHistos(TString canvName, TString canvTitle, Double_t pLow, Double_t pHigh, TH1F*** hist, Int_t reference, - TGraphAsymmErrors** gr) -{ - TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); - canv->SetGridx(1); - canv->SetGridy(1); - canv->SetLogx(1); - for (Int_t i = 0; i < numSpecies; i++) { - hist[i][reference]->GetYaxis()->SetRangeUser(0.0, 1.0); - hist[i][reference]->GetYaxis()->SetTitle(canvTitle.Data()); - hist[i][reference]->GetXaxis()->SetRangeUser(pLow, pHigh); - //hist[i][reference]->SetFillStyle(3004 + i); - //hist[i][reference]->SetFillColor(kGray); - hist[i][reference]->SetFillStyle(0); - hist[i][reference]->SetFillColor(hist[i][reference]->GetMarkerColor()); - hist[i][reference]->SetLineColor(hist[i][reference]->GetMarkerColor()); - } - hist[2][reference]->SetMarkerStyle(20); - hist[2][reference]->Draw("e p"); - hist[0][reference]->SetMarkerStyle(21); - hist[0][reference]->Draw("e p same"); - hist[1][reference]->SetMarkerStyle(22); - hist[1][reference]->Draw("e p same"); - hist[3][reference]->SetMarkerStyle(29); - hist[3][reference]->Draw("e p same"); - hist[4][reference]->SetMarkerStyle(30); - hist[4][reference]->Draw("e p same"); - - gr[0]->Draw("2 same"); - gr[1]->Draw("2 same"); - gr[2]->Draw("2 same"); - gr[3]->Draw("2 same"); - gr[4]->Draw("2 same"); - - TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); - legend->SetBorderSize(0); - legend->SetFillColor(0); - legend->AddEntry(hist[2][reference], "#pi", "flp"); - legend->AddEntry(hist[0][reference], "e", "flp"); - legend->AddEntry(hist[1][reference], "K", "flp"); - legend->AddEntry(hist[3][reference], "p", "flp"); - legend->AddEntry(hist[4][reference], "#mu", "flp"); - legend->Draw(); - - return canv; -} - - -//________________________________________________________ -TH1F* loadHisto(const TString histName, TFile* f) -{ - if (!f) { - std::cout << "No file. Cannot load hist \"" << histName.Data() << "\n!" << std::endl; - return 0x0; - } - - TH1F* hTemp = dynamic_cast(f->Get(histName.Data())); - if (!hTemp) { - std::cout << "Failed to load histo \"" << histName.Data() << "\"!" << std::endl; - return 0x0; - } - - return hTemp; -} - - -//________________________________________________________ -Int_t SystematicErrorEstimation(const TString path, const TString outFileTitle, const TString* fileNames, const TString* histTitles, - const Int_t numFiles, const Double_t nSigma, const Bool_t ignoreSigmaErrors) -{ - if (!fileNames || numFiles < 1) - return -1; - - TFile* f[numFiles]; - TH1F** hFractions[numSpecies]; - for (Int_t i = 0; i < numSpecies; i++) - hFractions[i] = new TH1F*[numFiles]; - - const Int_t reference = 0; - TH1F* hYields[numSpecies]; // Only the reference yields - - const TString histNames[numSpecies] = {"hFractionElectrons", "hFractionKaons", "hFractionPions", "hFractionProtons", "hFractionMuons" }; - - const TString histNamesYields[numSpecies] = {"hYieldElectrons", "hYieldKaons", "hYieldPions", "hYieldProtons", "hYieldMuons" }; - - for (Int_t iFile = 0; iFile < numFiles; iFile++) { - f[iFile] = TFile::Open(fileNames[iFile].Data()); - if (!f[iFile]) { - std::cout << "Failed to open file \"" << fileNames[iFile].Data() << "\"!" << std::endl; - return -1; - } - - // Extract the data histograms - for (Int_t i = 0; i < numSpecies; i++) { - hFractions[i][iFile] = loadHisto(histNames[i], f[iFile]); - if (!hFractions[i][iFile]) - return -1; - - if (iFile == reference) { - hYields[i] = loadHisto(histNamesYields[i], f[iFile]); - if (!hYields[i]) - return -1; - } - } - } - - - TGraphAsymmErrors* grSysErrors[numSpecies] = {0x0,}; - TGraphAsymmErrors* grSysErrorsYields[numSpecies] = {0x0,}; - - TH1F* hSystematicsPions[numFiles]; - TCanvas* cSystematicsPions = calculateSystematics("cSystematicsPions", "Systematics Pions", hFractions[2], numFiles, - AliPID::kPion, nSigma, - histTitles, reference, hSystematicsPions, &grSysErrors[2], ignoreSigmaErrors); - - TH1F* hSystematicsElectrons[numFiles]; - TCanvas* cSystematicsElectrons = calculateSystematics("cSystematicsElectrons", "Systematics Electrons", hFractions[0], numFiles, - AliPID::kElectron, - nSigma, histTitles, reference, hSystematicsElectrons, - &grSysErrors[0], ignoreSigmaErrors); - - TH1F* hSystematicsKaons[numFiles]; - TCanvas* cSystematicsKaons = calculateSystematics("cSystematicsKaons", "Systematics Kaons", hFractions[1], numFiles, AliPID::kKaon, nSigma, - histTitles, reference, hSystematicsKaons, &grSysErrors[1], ignoreSigmaErrors); - - TH1F* hSystematicsProtons[numFiles]; - TCanvas* cSystematicsProtons = calculateSystematics("cSystematicsProtons", "Systematics Protons", hFractions[3], numFiles, - AliPID::kProton, nSigma, - histTitles, reference, hSystematicsProtons, &grSysErrors[3], ignoreSigmaErrors); - - TH1F* hSystematicsMuons[numFiles]; - TCanvas* cSystematicsMuons = calculateSystematics("cSystematicsMuons", "Systematics Muons", hFractions[4], numFiles, - AliPID::kMuon, nSigma, - histTitles, reference, hSystematicsMuons, &grSysErrors[4], ignoreSigmaErrors); - - Double_t pLow = 0.15; - Double_t pHigh = 50.; - TCanvas* cFractionsWithSystematicError = DrawFractionHistos("cFractionsWithSystematicError", "Particle fractions", pLow, pHigh, hFractions, reference, - grSysErrors); - - - //TODO At the moment, the error of the fractions and the yield is just a constant factor (number of tracks in that bin) - // (-> But this can change in future (I have to think about it a little bit more carefully)). - // Thus, the relative errors are the same for fractions and yields and I can just use this fact to - // transform the errors from the fractions to those of the yields. - // However, this causes trouble in case of fraction = 0. Therefore, sum up the yields to the total yield and use this for scaling - for (Int_t i = 0; i < numSpecies; i++) { - grSysErrorsYields[i] = new TGraphAsymmErrors(*grSysErrors[i]); - TString name = grSysErrors[i]->GetName(); - name.ReplaceAll("systematicError_", "systematicErrorYields_"); - grSysErrorsYields[i]->SetName(name.Data()); - - for (Int_t ind = 0; ind < grSysErrorsYields[i]->GetN(); ind++) { - Double_t totalYield = 0; - for (Int_t j = 0; j < numSpecies; j++) - totalYield += hYields[j]->GetBinContent(ind + 1); - - const Double_t yield = hYields[i]->GetBinContent(ind + 1); - const Double_t sysErrorLow = grSysErrors[i]->GetErrorYlow(ind); - const Double_t sysErrorHigh = grSysErrors[i]->GetErrorYhigh(ind); - - grSysErrorsYields[i]->SetPoint(ind, grSysErrorsYields[i]->GetX()[ind], yield); - grSysErrorsYields[i]->SetPointEYhigh(ind, totalYield * sysErrorHigh); - grSysErrorsYields[i]->SetPointEYlow(ind, totalYield * sysErrorLow); - - /* - Double_t totalYield = 0; - for (Int_t j = 0; j < numSpecies; j++) - totalYield += hYields[j]->GetBinContent(ind + 1); - - const Double_t yield = hYields[i]->GetBinContent(ind + 1); - const Double_t fraction = hFractions[i][reference]->GetBinContent(ind + 1); - const Double_t sysErrorLow = grSysErrors[i]->GetErrorYlow(ind); - const Double_t sysErrorHigh = grSysErrors[i]->GetErrorYhigh(ind); - - if (fraction <= 0.) { - printf("Error: Fraction = 0 for species %d. Cannot transform error....\n", i); - return -1; - } - const Double_t sysErrorLowRel = sysErrorLow / fraction; - const Double_t sysErrorHighRel = sysErrorHigh / fraction; - - grSysErrorsYields[i]->SetPoint(ind, grSysErrorsYields[i]->GetX()[ind], yield); - grSysErrorsYields[i]->SetPointEYhigh(ind, sysErrorHighRel * yield); - grSysErrorsYields[i]->SetPointEYlow(ind, sysErrorLowRel * yield); - */ - } - } - - - // Output file - TFile* fSave = 0x0; - TDatime daTime; - TString saveFileName; - - saveFileName = Form("outputSystematics_%s_nSigma%.1f__%04d_%02d_%02d.root", outFileTitle.Data(), nSigma, daTime.GetYear(), - daTime.GetMonth(), daTime.GetDay()); - - fSave = TFile::Open(Form("%s/%s", path.Data(), saveFileName.Data()), "recreate"); - if (!fSave) { - std::cout << "Failed to open save file \"" << Form("%s/%s", path.Data(), saveFileName.Data()) << "\"!" << std::endl; - return -1; - } - - // Save final results - fSave->cd(); - - for (Int_t i = 0; i < numFiles; i++) { - if (hSystematicsElectrons[i]) - hSystematicsElectrons[i]->Write(); - - if (hSystematicsPions[i]) - hSystematicsPions[i]->Write(); - - if (hSystematicsKaons[i]) - hSystematicsKaons[i]->Write(); - - if (hSystematicsProtons[i]) - hSystematicsProtons[i]->Write(); - if (hSystematicsMuons[i]) - hSystematicsMuons[i]->Write(); - } - - if (cSystematicsElectrons) - cSystematicsElectrons->Write(); - - if (cSystematicsPions) - cSystematicsPions->Write(); - - if (cSystematicsKaons) - cSystematicsKaons->Write(); - - if (cSystematicsProtons) - cSystematicsProtons->Write(); - - if (cSystematicsMuons) - cSystematicsMuons->Write(); - - if (cFractionsWithSystematicError) - cFractionsWithSystematicError->Write(); - - for (Int_t i = 0; i < numSpecies; i++) { - if (hFractions[i][reference]) - hFractions[i][reference]->Write(); - - if (grSysErrors[i]) - grSysErrors[i]->Write(); - - if (hYields[i]) - hYields[i]->Write(); - - if (grSysErrorsYields[i]) - grSysErrorsYields[i]->Write(); - } - - // Save list of file names in output file - TString listOfFileNames = ""; - for (Int_t i = 0; i < numFiles; i++) { - listOfFileNames.Append(Form("%s%d: %s", i == 0 ? "" : ", ", i, fileNames[i].Data())); - } - - TNamed* settings = new TNamed(Form("Used files for systematics: %s\n", listOfFileNames.Data()), - Form("Used files for systematics: %s\n", listOfFileNames.Data())); - settings->Write(); - - fSave->Close(); - - delete cSystematicsElectrons; - delete cSystematicsPions; - delete cSystematicsKaons; - delete cSystematicsMuons; - delete cSystematicsProtons; - delete cFractionsWithSystematicError; - - return 0; -} +#include "TCanvas.h" +#include "TFile.h" +#include "TGraphErrors.h" +#include "TGraphAsymmErrors.h" +#include "TGraph.h" +#include "TF1.h" +#include "TH1D.h" +#include "TLegend.h" +#include "TMath.h" +#include "TString.h" +#include "TStyle.h" + +#include "AliPID.h" + +#include +#include + +#include "SystematicErrorUtils.h" + +const Int_t numSpecies = 5; + +//________________________________________________________ +TCanvas* calculateSystematics(TString canvName, TString canvTitle, TH1F** histos, Int_t numHistos, Int_t speciesID, Double_t /*nSigma*/, + const TString* systematicsHistosName, Int_t reference, TH1F** hSystematics, TGraphAsymmErrors** gr, + Bool_t ignoreSigmaErrors) +{ + // For every bin: + // Since the method with the root finding already takes into account the statistical error, + // there is no need to use nSigma > 0. + // If the statistical error is ignored, nevertheless don't use nSigma > 0 because this might + // give zero systematic error for high pT, which is usually not accepted by people, although + // the natural point of view "no systematic visible for given statistical error" is reasonable to me. + + Double_t ymax = 0; + Double_t ymin = 0; + + + // Just for drawing + for (Int_t j = 0; j < numHistos; j++) { + hSystematics[j] = new TH1F(*histos[j]); + hSystematics[j]->SetName(Form("%s_%s", systematicsHistosName[j].Data(), AliPID::ParticleName(speciesID))); + hSystematics[j]->Reset(); + hSystematics[j]->GetXaxis()->SetRange(0, -1); + + for (Int_t bin = 1; bin <= histos[j]->GetNbinsX(); bin++) { + hSystematics[j]->SetBinContent(bin, histos[reference]->GetBinContent(bin) - histos[j]->GetBinContent(bin)); + hSystematics[j]->SetBinError(bin, TMath::Sqrt(TMath::Abs(TMath::Power(histos[reference]->GetBinError(bin), 2) - + TMath::Power(histos[j]->GetBinError(bin), 2)))); + + if (hSystematics[j]->GetBinError(bin) == 0) + hSystematics[j]->SetBinError(bin, 1e-10); + Double_t temp = hSystematics[j]->GetBinContent(bin) + hSystematics[j]->GetBinError(bin); + if (temp > ymax) + ymax = temp; + + temp = hSystematics[j]->GetBinContent(bin) - hSystematics[j]->GetBinError(bin); + if (temp < ymin) + ymin = temp; + } + } + + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridy(1); + + hSystematics[reference]->Draw("e p"); + hSystematics[reference]->GetYaxis()->SetRangeUser(ymin, ymax); + for (Int_t j = 0; j < numHistos; j++) { + if (j == reference) + continue; + + hSystematics[j]->SetMarkerStyle(20 + j); + hSystematics[j]->Draw("e p same"); + } + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + + for (Int_t j = 0; j < numHistos; j++) { + legend->AddEntry(hSystematics[j], Form("%s", systematicsHistosName[j].Data()), "p"); + } + legend->Draw(); + + + const Int_t nBins = histos[reference]->GetNbinsX(); + Double_t x[nBins]; + Double_t y[nBins]; + Double_t xerr[nBins]; + Double_t yerrl[nBins]; + Double_t yerrh[nBins]; + + Double_t meansForFit[numHistos]; + Double_t sigmasForFit[numHistos]; + + for (Int_t bin = 0; bin < nBins; bin++) { + x[bin] = histos[reference]->GetBinCenter(bin + 1); + xerr[bin] = histos[reference]->GetBinWidth(bin + 1) / 2.; + y[bin] = histos[reference]->GetBinContent(bin + 1); + + for (Int_t j = 0; j < numHistos; j++) { + meansForFit[j] = histos[j]->GetBinContent(bin + 1); + sigmasForFit[j] = histos[j]->GetBinError(bin + 1); + } + + yerrl[bin] = yerrh[bin] = findSystematicError(numHistos, meansForFit, sigmasForFit, ignoreSigmaErrors); + } + + TGraphAsymmErrors* gTemp = new TGraphAsymmErrors(nBins, x, y, xerr, xerr, yerrl, yerrh); + *gr = gTemp; + (*gr)->SetName(Form("systematicError_%s", AliPID::ParticleName(speciesID))); + (*gr)->SetLineColor(hSystematics[0]->GetMarkerColor()); + //(*gr)->SetFillColor(kGray); + (*gr)->SetFillStyle(0);//3004 + reference); + + return canv; +} + + +/*OLD +//________________________________________________________ +TCanvas* calculateSystematics(TString canvName, TString canvTitle, TH1F** histos, Int_t numHistos, Int_t speciesID, Double_t nSigma, + const TString* systematicsHistosName, Int_t reference, TH1F** hSystematics, TGraphAsymmErrors** gr) +{ + Double_t ymax = 0; + Double_t ymin = 0; + + for (Int_t j = 0; j < numHistos; j++) { + hSystematics[j] = new TH1F(*histos[j]); + hSystematics[j]->SetName(Form("%s_%s", systematicsHistosName[j].Data(), AliPID::ParticleName(speciesID))); + hSystematics[j]->Reset(); + hSystematics[j]->GetXaxis()->SetRange(0, -1); + + for (Int_t bin = 1; bin <= histos[j]->GetNbinsX(); bin++) { + hSystematics[j]->SetBinContent(bin, histos[reference]->GetBinContent(bin) - histos[j]->GetBinContent(bin)); + hSystematics[j]->SetBinError(bin, TMath::Sqrt(TMath::Abs(TMath::Power(histos[reference]->GetBinError(bin), 2) - + TMath::Power(histos[j]->GetBinError(bin), 2)))); + + if (hSystematics[j]->GetBinError(bin) == 0) + hSystematics[j]->SetBinError(bin, 1e-10); + Double_t temp = hSystematics[j]->GetBinContent(bin) + hSystematics[j]->GetBinError(bin); + if (temp > ymax) + ymax = temp; + + temp = hSystematics[j]->GetBinContent(bin) - hSystematics[j]->GetBinError(bin); + if (temp < ymin) + ymin = temp; + } + } + + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridy(1); + + hSystematics[reference]->Draw("e p"); + hSystematics[reference]->GetYaxis()->SetRangeUser(ymin, ymax); + for (Int_t j = 0; j < numHistos; j++) { + if (j == reference) + continue; + + hSystematics[j]->SetMarkerStyle(20 + j); + hSystematics[j]->Draw("e p same"); + } + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + + for (Int_t j = 0; j < numHistos; j++) { + legend->AddEntry(hSystematics[j], Form("%s", systematicsHistosName[j].Data()), "p"); + } + legend->Draw(); + + + const Int_t nBins = histos[reference]->GetNbinsX(); + Double_t x[nBins]; + Double_t y[nBins]; + Double_t xerr[nBins]; + Double_t yerrl[nBins]; + Double_t yerrh[nBins]; + + for (Int_t bin = 0; bin < nBins; bin++) { + x[bin] = histos[reference]->GetBinCenter(bin + 1); + xerr[bin] = histos[reference]->GetBinWidth(bin + 1) / 2.; + y[bin] = histos[reference]->GetBinContent(bin + 1); + + // Take all points that are more than nSigma sigma away from 0. + // If there are at least 2 such points, take the difference between + // the extreme values (i.e. maximum and minimum) as a measure of + // the systematics + Int_t count = 0; + Double_t deltaMin = 0; + Double_t deltaMax = 0; + + for (Int_t j = 0; j < numHistos; j++) { + if (hSystematics[j]->GetBinError(bin + 1) == 0) // Per definition always true for reference histo + continue; + + Double_t delta = hSystematics[j]->GetBinContent(bin + 1); + if (TMath::Abs(delta / hSystematics[j]->GetBinError(bin + 1)) > nSigma) { + //if (count == 0) { + // deltaMin = delta; + // deltaMax = delta; + //} + //else { + if (delta < deltaMin) + deltaMin = delta; + if (delta > deltaMax) + deltaMax = delta; + //} + count++; + } + } + + //if (deltaMax > 0.) + // yerrh[bin] = deltaMax; + //else + // yerrh[bin] = 0.; + // + //if (deltaMin < 0.) + // yerrl[bin] = -deltaMin; + //else + // yerrl[bin] = 0.; + + if (count < 1) // Reference histo is not counted. One can only do systematics if there is at least one other histogram + yerrl[bin] = yerrh[bin] = 0.; + else + yerrl[bin] = yerrh[bin] = (deltaMax - deltaMin) / TMath::Sqrt(2); + + } + + TGraphAsymmErrors* gTemp = new TGraphAsymmErrors(nBins, x, y, xerr, xerr, yerrl, yerrh); + *gr = gTemp; + (*gr)->SetName(Form("systematicError_%s", AliPID::ParticleName(speciesID))); + (*gr)->SetLineColor(hSystematics[0]->GetMarkerColor()); + //(*gr)->SetFillColor(kGray); + (*gr)->SetFillStyle(0);//3004 + reference); + + return canv; +}*/ + + +//________________________________________________________ +TCanvas* DrawFractionHistos(TString canvName, TString canvTitle, Double_t pLow, Double_t pHigh, TH1F*** hist, Int_t reference, + TGraphAsymmErrors** gr) +{ + TCanvas* canv = new TCanvas(canvName.Data(), canvTitle.Data(),100,10,1200,800); + canv->SetGridx(1); + canv->SetGridy(1); + canv->SetLogx(1); + for (Int_t i = 0; i < numSpecies; i++) { + hist[i][reference]->GetYaxis()->SetRangeUser(0.0, 1.0); + hist[i][reference]->GetYaxis()->SetTitle(canvTitle.Data()); + hist[i][reference]->GetXaxis()->SetRangeUser(pLow, pHigh); + //hist[i][reference]->SetFillStyle(3004 + i); + //hist[i][reference]->SetFillColor(kGray); + hist[i][reference]->SetFillStyle(0); + hist[i][reference]->SetFillColor(hist[i][reference]->GetMarkerColor()); + hist[i][reference]->SetLineColor(hist[i][reference]->GetMarkerColor()); + } + hist[2][reference]->SetMarkerStyle(20); + hist[2][reference]->Draw("e p"); + hist[0][reference]->SetMarkerStyle(21); + hist[0][reference]->Draw("e p same"); + hist[1][reference]->SetMarkerStyle(22); + hist[1][reference]->Draw("e p same"); + hist[3][reference]->SetMarkerStyle(29); + hist[3][reference]->Draw("e p same"); + hist[4][reference]->SetMarkerStyle(30); + hist[4][reference]->Draw("e p same"); + + gr[0]->Draw("2 same"); + gr[1]->Draw("2 same"); + gr[2]->Draw("2 same"); + gr[3]->Draw("2 same"); + gr[4]->Draw("2 same"); + + TLegend* legend = new TLegend(0.622126, 0.605932, 0.862069, 0.855932); + legend->SetBorderSize(0); + legend->SetFillColor(0); + legend->AddEntry(hist[2][reference], "#pi", "flp"); + legend->AddEntry(hist[0][reference], "e", "flp"); + legend->AddEntry(hist[1][reference], "K", "flp"); + legend->AddEntry(hist[3][reference], "p", "flp"); + legend->AddEntry(hist[4][reference], "#mu", "flp"); + legend->Draw(); + + return canv; +} + + +//________________________________________________________ +TH1F* loadHisto(const TString histName, TFile* f) +{ + if (!f) { + std::cout << "No file. Cannot load hist \"" << histName.Data() << "\n!" << std::endl; + return 0x0; + } + + TH1F* hTemp = dynamic_cast(f->Get(histName.Data())); + if (!hTemp) { + std::cout << "Failed to load histo \"" << histName.Data() << "\"!" << std::endl; + return 0x0; + } + + return hTemp; +} + + +//________________________________________________________ +Int_t SystematicErrorEstimation(const TString path, const TString outFileTitle, const TString* fileNames, const TString* histTitles, + const Int_t numFiles, const Double_t nSigma, const Bool_t ignoreSigmaErrors) +{ + if (!fileNames || numFiles < 1) + return -1; + + TFile* f[numFiles]; + TH1F** hFractions[numSpecies]; + for (Int_t i = 0; i < numSpecies; i++) + hFractions[i] = new TH1F*[numFiles]; + + const Int_t reference = 0; + TH1F* hYields[numSpecies]; // Only the reference yields + + const TString histNames[numSpecies] = {"hFractionElectrons", "hFractionKaons", "hFractionPions", "hFractionProtons", "hFractionMuons" }; + + const TString histNamesYields[numSpecies] = {"hYieldElectrons", "hYieldKaons", "hYieldPions", "hYieldProtons", "hYieldMuons" }; + + for (Int_t iFile = 0; iFile < numFiles; iFile++) { + f[iFile] = TFile::Open(fileNames[iFile].Data()); + if (!f[iFile]) { + std::cout << "Failed to open file \"" << fileNames[iFile].Data() << "\"!" << std::endl; + return -1; + } + + // Extract the data histograms + for (Int_t i = 0; i < numSpecies; i++) { + hFractions[i][iFile] = loadHisto(histNames[i], f[iFile]); + if (!hFractions[i][iFile]) + return -1; + + if (iFile == reference) { + hYields[i] = loadHisto(histNamesYields[i], f[iFile]); + if (!hYields[i]) + return -1; + } + } + } + + + TGraphAsymmErrors* grSysErrors[numSpecies] = {0x0,}; + TGraphAsymmErrors* grSysErrorsYields[numSpecies] = {0x0,}; + + TH1F* hSystematicsPions[numFiles]; + TCanvas* cSystematicsPions = calculateSystematics("cSystematicsPions", "Systematics Pions", hFractions[2], numFiles, + AliPID::kPion, nSigma, + histTitles, reference, hSystematicsPions, &grSysErrors[2], ignoreSigmaErrors); + + TH1F* hSystematicsElectrons[numFiles]; + TCanvas* cSystematicsElectrons = calculateSystematics("cSystematicsElectrons", "Systematics Electrons", hFractions[0], numFiles, + AliPID::kElectron, + nSigma, histTitles, reference, hSystematicsElectrons, + &grSysErrors[0], ignoreSigmaErrors); + + TH1F* hSystematicsKaons[numFiles]; + TCanvas* cSystematicsKaons = calculateSystematics("cSystematicsKaons", "Systematics Kaons", hFractions[1], numFiles, AliPID::kKaon, nSigma, + histTitles, reference, hSystematicsKaons, &grSysErrors[1], ignoreSigmaErrors); + + TH1F* hSystematicsProtons[numFiles]; + TCanvas* cSystematicsProtons = calculateSystematics("cSystematicsProtons", "Systematics Protons", hFractions[3], numFiles, + AliPID::kProton, nSigma, + histTitles, reference, hSystematicsProtons, &grSysErrors[3], ignoreSigmaErrors); + + TH1F* hSystematicsMuons[numFiles]; + TCanvas* cSystematicsMuons = calculateSystematics("cSystematicsMuons", "Systematics Muons", hFractions[4], numFiles, + AliPID::kMuon, nSigma, + histTitles, reference, hSystematicsMuons, &grSysErrors[4], ignoreSigmaErrors); + + Double_t pLow = 0.15; + Double_t pHigh = 50.; + TCanvas* cFractionsWithSystematicError = DrawFractionHistos("cFractionsWithSystematicError", "Particle fractions", pLow, pHigh, hFractions, reference, + grSysErrors); + + + //TODO At the moment, the error of the fractions and the yield is just a constant factor (number of tracks in that bin) + // (-> But this can change in future (I have to think about it a little bit more carefully)). + // Thus, the relative errors are the same for fractions and yields and I can just use this fact to + // transform the errors from the fractions to those of the yields. + // However, this causes trouble in case of fraction = 0. Therefore, sum up the yields to the total yield and use this for scaling + for (Int_t i = 0; i < numSpecies; i++) { + grSysErrorsYields[i] = new TGraphAsymmErrors(*grSysErrors[i]); + TString name = grSysErrors[i]->GetName(); + name.ReplaceAll("systematicError_", "systematicErrorYields_"); + grSysErrorsYields[i]->SetName(name.Data()); + + for (Int_t ind = 0; ind < grSysErrorsYields[i]->GetN(); ind++) { + Double_t totalYield = 0; + for (Int_t j = 0; j < numSpecies; j++) + totalYield += hYields[j]->GetBinContent(ind + 1); + + const Double_t yield = hYields[i]->GetBinContent(ind + 1); + const Double_t sysErrorLow = grSysErrors[i]->GetErrorYlow(ind); + const Double_t sysErrorHigh = grSysErrors[i]->GetErrorYhigh(ind); + + grSysErrorsYields[i]->SetPoint(ind, grSysErrorsYields[i]->GetX()[ind], yield); + grSysErrorsYields[i]->SetPointEYhigh(ind, totalYield * sysErrorHigh); + grSysErrorsYields[i]->SetPointEYlow(ind, totalYield * sysErrorLow); + + /* + Double_t totalYield = 0; + for (Int_t j = 0; j < numSpecies; j++) + totalYield += hYields[j]->GetBinContent(ind + 1); + + const Double_t yield = hYields[i]->GetBinContent(ind + 1); + const Double_t fraction = hFractions[i][reference]->GetBinContent(ind + 1); + const Double_t sysErrorLow = grSysErrors[i]->GetErrorYlow(ind); + const Double_t sysErrorHigh = grSysErrors[i]->GetErrorYhigh(ind); + + if (fraction <= 0.) { + printf("Error: Fraction = 0 for species %d. Cannot transform error....\n", i); + return -1; + } + const Double_t sysErrorLowRel = sysErrorLow / fraction; + const Double_t sysErrorHighRel = sysErrorHigh / fraction; + + grSysErrorsYields[i]->SetPoint(ind, grSysErrorsYields[i]->GetX()[ind], yield); + grSysErrorsYields[i]->SetPointEYhigh(ind, sysErrorHighRel * yield); + grSysErrorsYields[i]->SetPointEYlow(ind, sysErrorLowRel * yield); + */ + } + } + + + // Output file + TFile* fSave = 0x0; + TDatime daTime; + TString saveFileName; + + saveFileName = Form("outputSystematics_%s_nSigma%.1f__%04d_%02d_%02d.root", outFileTitle.Data(), nSigma, daTime.GetYear(), + daTime.GetMonth(), daTime.GetDay()); + + fSave = TFile::Open(Form("%s/%s", path.Data(), saveFileName.Data()), "recreate"); + if (!fSave) { + std::cout << "Failed to open save file \"" << Form("%s/%s", path.Data(), saveFileName.Data()) << "\"!" << std::endl; + return -1; + } + + // Save final results + fSave->cd(); + + for (Int_t i = 0; i < numFiles; i++) { + if (hSystematicsElectrons[i]) + hSystematicsElectrons[i]->Write(); + + if (hSystematicsPions[i]) + hSystematicsPions[i]->Write(); + + if (hSystematicsKaons[i]) + hSystematicsKaons[i]->Write(); + + if (hSystematicsProtons[i]) + hSystematicsProtons[i]->Write(); + if (hSystematicsMuons[i]) + hSystematicsMuons[i]->Write(); + } + + if (cSystematicsElectrons) + cSystematicsElectrons->Write(); + + if (cSystematicsPions) + cSystematicsPions->Write(); + + if (cSystematicsKaons) + cSystematicsKaons->Write(); + + if (cSystematicsProtons) + cSystematicsProtons->Write(); + + if (cSystematicsMuons) + cSystematicsMuons->Write(); + + if (cFractionsWithSystematicError) + cFractionsWithSystematicError->Write(); + + for (Int_t i = 0; i < numSpecies; i++) { + if (hFractions[i][reference]) + hFractions[i][reference]->Write(); + + if (grSysErrors[i]) + grSysErrors[i]->Write(); + + if (hYields[i]) + hYields[i]->Write(); + + if (grSysErrorsYields[i]) + grSysErrorsYields[i]->Write(); + } + + // Save list of file names in output file + TString listOfFileNames = ""; + for (Int_t i = 0; i < numFiles; i++) { + listOfFileNames.Append(Form("%s%d: %s", i == 0 ? "" : ", ", i, fileNames[i].Data())); + } + + TNamed* settings = new TNamed(Form("Used files for systematics: %s\n", listOfFileNames.Data()), + Form("Used files for systematics: %s\n", listOfFileNames.Data())); + settings->Write(); + + fSave->Close(); + + delete cSystematicsElectrons; + delete cSystematicsPions; + delete cSystematicsKaons; + delete cSystematicsMuons; + delete cSystematicsProtons; + delete cFractionsWithSystematicError; + + return 0; +} diff --git a/PWGLF/QATasks/AliAnalysisTaskQAHighPtDeDx.cxx b/PWGLF/QATasks/AliAnalysisTaskQAHighPtDeDx.cxx index 7390a840673..270a69626ad 100644 --- a/PWGLF/QATasks/AliAnalysisTaskQAHighPtDeDx.cxx +++ b/PWGLF/QATasks/AliAnalysisTaskQAHighPtDeDx.cxx @@ -1,2040 +1,2040 @@ - /************************************************************************* -* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * -* * -* Author: The ALICE Off-line Project. * -* Contributors are mentioned in the code where appropriate. * -* * -* Permission to use, copy, modify and distribute this software and its * -* documentation strictly for non-commercial purposes is hereby granted * -* without fee, provided that the above copyright notice appears in all * -* copies and that both the copyright notice and this permission notice * -* appear in the supporting documentation. The authors make no claims * -* about the suitability of this software for any purpose. It is * -* provided "as is" without express or implied warranty. * **************************************************************************/ - - -#include "AliAnalysisTaskQAHighPtDeDx.h" - -// ROOT includes -#include -#include -#include -#include -#include -#include -#include -#include - -// AliRoot includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include "AliCentrality.h" -#include -#include -#include - -#include -#include -#include - - -// STL includes -#include -using namespace std; - - -// -// Responsible: -// Antonio Ortiz (Lund) -// Peter Christiansen (Lund) -// - - - - - - - - -const Double_t AliAnalysisTaskQAHighPtDeDx::fgkClight = 2.99792458e-2; -Float_t magf = -1; -TF1* cutLow = new TF1("StandardPhiCutLow", "0.1/x/x+pi/18.0-0.025", 0, 50); -TF1* cutHigh = new TF1("StandardPhiCutHigh", "0.12/x+pi/18.0+0.035", 0, 50); -Double_t DeDxMIPMin = 30; -Double_t DeDxMIPMax = 65; -const Int_t nHists = 9; -Float_t centralityGlobal = -10; -Int_t etaLow[nHists] = {-8, -8, -6, -4, -2, 0, 2, 4, 6}; -Int_t etaHigh[nHists] = { 8, -6, -4, -2, 0, 2, 4, 6, 8}; - -Int_t nDeltaPiBins = 80; -Double_t deltaPiLow = 20; -Double_t deltaPiHigh = 100; -const Char_t *Pid[7]={"Ch","Pion","Kaon","Proton","Electron","Muon","Oher"}; -ClassImp(AliAnalysisTaskQAHighPtDeDx) -//_____________________________________________________________________________ -//AliAnalysisTaskQAHighPtDeDx::AliAnalysisTaskQAHighPtDeDx(const char *name): -AliAnalysisTaskQAHighPtDeDx::AliAnalysisTaskQAHighPtDeDx(): - AliAnalysisTaskSE(), - fESD(0x0), - fAOD(0x0), - fMC(0x0), - fMCStack(0x0), - fMCArray(0x0), - fTrackFilterGolden(0x0), - fTrackFilterTPC(0x0), - fCentEst("V0M"), - fAnalysisType("ESD"), - fAnalysisMC(kFALSE), - fAnalysisPbPb(kFALSE), - ftrigBit(0x0), - fRandom(0x0), - fPileUpRej(kFALSE), - fVtxCut(10.0), - fEtaCut(0.9), - fMinCent(0.0), - fMaxCent(100.0), - fStoreMcIn(kFALSE),// - fMcProcessType(-999), - fTriggeredEventMB(-999), - fVtxStatus(-999), - fZvtx(-999), - fZvtxMC(-999), - fRun(-999), - fEventId(-999), - fListOfObjects(0), - fEvents(0x0), fVtx(0x0), fVtxMC(0x0), fVtxBeforeCuts(0x0), fVtxAfterCuts(0x0), - fn1(0x0), - fcent(0x0), - hMIPVsEta(0x0), - pMIPVsEta(0x0), - hMIPVsEtaV0s(0x0), - pMIPVsEtaV0s(0x0), - hPlateauVsEta(0x0), - pPlateauVsEta(0x0), - hPhi(0x0) - - -{ - //default constructor -} - - -AliAnalysisTaskQAHighPtDeDx::AliAnalysisTaskQAHighPtDeDx(const char *name): - AliAnalysisTaskSE(name), - fESD(0x0), - fAOD(0x0), - fMC(0x0), - fMCStack(0x0), - fMCArray(0x0), - fTrackFilterGolden(0x0), - fTrackFilterTPC(0x0), - fCentEst("V0M"), - fAnalysisType("ESD"), - fAnalysisMC(kFALSE), - fAnalysisPbPb(kFALSE), - ftrigBit(0x0), - fRandom(0x0), - fPileUpRej(kFALSE), - fVtxCut(10.0), - fEtaCut(0.9), - fMinCent(0.0), - fMaxCent(100.0), - fStoreMcIn(kFALSE),// - fMcProcessType(-999), - fTriggeredEventMB(-999), - fVtxStatus(-999), - fZvtx(-999), - fZvtxMC(-999), - fRun(-999), - fEventId(-999), - fListOfObjects(0), - fEvents(0x0), fVtx(0x0), fVtxMC(0x0), fVtxBeforeCuts(0x0), fVtxAfterCuts(0x0), - fn1(0x0), - fcent(0x0), - hMIPVsEta(0x0), - pMIPVsEta(0x0), - hMIPVsEtaV0s(0x0), - pMIPVsEtaV0s(0x0), - hPlateauVsEta(0x0), - pPlateauVsEta(0x0), - hPhi(0x0) - - -{ - // Default constructor (should not be used) - for(Int_t i=0;i<9;++i){ - - hMIPVsNch[i]=0;//TH2D, MIP vs Nch for different eta intervals - pMIPVsNch[i]=0;//TProfile, MIP vs Nch for different eta intervals - hMIPVsPhi[i]=0;//TH2D, MIP vs phi for different eta intervals - pMIPVsPhi[i]=0;//TProfile, MIP vs phi for different eta intervals - hPlateauVsPhi[i]=0;//TH2D, dE/dx vs Phi, electrons 0.41 - histpPiTof[i]=0;//TH1D, for a "clean" sample of pions, beta>1 - histEV0[i]=0; - - for(Int_t pid=0;pid<7;++pid){ - hMcIn[pid][i]=0; - hMcOut[pid][i]=0; - } - - } - DefineOutput(1, TList::Class());//esto es nuevo -} - - - - -AliAnalysisTaskQAHighPtDeDx::~AliAnalysisTaskQAHighPtDeDx() { - // - // Destructor - // - -} - - - - - - - - -//______________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::UserCreateOutputObjects() -{ - // This method is called once per worker node - // Here we define the output: histograms and debug tree if requested - // We also create the random generator here so it might get different seeds... - fRandom = new TRandom(0); // 0 means random seed - - - - //OpenFile(1); - fListOfObjects = new TList(); - fListOfObjects->SetOwner(); - - - - - // - // Histograms - // - fEvents = new TH1I("fEvents","Number of analyzed events; Events; Counts", 3, 0, 3); - fListOfObjects->Add(fEvents); - - fn1=new TH1F("fn1","fn1",11,-1,10); - fListOfObjects->Add(fn1); - - fcent=new TH1F("fcent","fcent",104,-2,102); - fListOfObjects->Add(fcent); - - fVtx = new TH1I("fVtx","Vtx info (0=no, 1=yes); Vtx; Counts", 2, -0.5, 1.5); - fListOfObjects->Add(fVtx); - - fVtxBeforeCuts = new TH1F("fVtxBeforeCuts", "Vtx distribution (before cuts); Vtx z [cm]; Counts", 120, -30, 30); - fListOfObjects->Add(fVtxBeforeCuts); - - fVtxAfterCuts = new TH1F("fVtxAfterCuts", "Vtx distribution (before cuts); Vtx z [cm]; Counts", 120, -30, 30); - fListOfObjects->Add(fVtxAfterCuts); - - - const Int_t nPtBinsV0s = 25; - Double_t ptBinsV0s[nPtBinsV0s+1] = { 0.0 , 0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1.0 , - 1.2 , 1.4 , 1.6 , 1.8 , 2.0 , 2.5 , 3.0 , 3.5 , 4.0 , 5.0 , 7.0 , - 9.0 , 12.0, 15.0, 20.0 }; - - - - - const Char_t* ending[nHists] = {"", "86", "64", "42", "20", "02", "24", "46", "68"}; - - const Char_t* LatexEta[nHists] = { - "|#eta|<0.8", "-0.8<#eta<-0.6", "-0.6<#eta<-0.4", "-0.4<#eta<-0.2", "-0.2<#eta<0", - "0<#eta<0.2", "0.2<#eta<0.4", "0.4<#eta<0.6", "0.6<#eta<0.8" - }; - hPhi = new TH2D("histPhi", "pt; #phi'", nPtBinsV0s, ptBinsV0s, 90, -0.05, 0.4); - //dE/dx vs phi, pions at the MIP - fListOfObjects->Add(hPhi); - - - - - Int_t nPhiBins = 36; - - for(Int_t i = 0; i < nHists; i++) { - - - hMIPVsPhi[i] = new TH2D(Form("hMIPVsPhi%s", ending[i]), Form("%s; #phi (rad); dE/dx MIP",LatexEta[i]), nPhiBins, 0, 2*TMath::Pi(), - DeDxMIPMax-DeDxMIPMin, DeDxMIPMin, DeDxMIPMax); - hMIPVsPhi[i]->Sumw2(); - - pMIPVsPhi[i] = new TProfile(Form("pMIPVsPhi%s", ending[i]), Form("%s; #phi (rad); dE/dx MIP",LatexEta[i]), nPhiBins, 0, 2*TMath::Pi(), - DeDxMIPMin, DeDxMIPMax); - pMIPVsPhi[i]->SetMarkerStyle(20); - pMIPVsPhi[i]->SetMarkerColor(1); - pMIPVsPhi[i]->SetLineColor(1); - pMIPVsPhi[i]->Sumw2(); - - fListOfObjects->Add(hMIPVsPhi[i]); - fListOfObjects->Add(pMIPVsPhi[i]); - - hPlateauVsPhi[i] = new TH2D(Form("hPlateauVsPhi%s", ending[i]), Form("%s; #phi (rad); dE/dx Plateau",LatexEta[i]), nPhiBins, 0, 2*TMath::Pi(), - 95-DeDxMIPMax, DeDxMIPMax, 95); - hPlateauVsPhi[i]->Sumw2(); - - pPlateauVsPhi[i] = new TProfile(Form("pPlateauVsPhi%s", ending[i]), Form("%s; #phi (rad); dE/dx Plateau",LatexEta[i]), nPhiBins, 0, 2*TMath::Pi(), - DeDxMIPMax, 95); - pPlateauVsPhi[i]->SetMarkerStyle(20); - pPlateauVsPhi[i]->SetMarkerColor(1); - pPlateauVsPhi[i]->SetLineColor(1); - pPlateauVsPhi[i]->Sumw2(); - - fListOfObjects->Add(hPlateauVsPhi[i]); - fListOfObjects->Add(pPlateauVsPhi[i]); - - - hMIPVsNch[i] = new TH2D(Form("hMIPVsNch%s", ending[i]), Form("%s; TPC track mult. |#eta|<0.8; dE/dx MIP",LatexEta[i]), 400, 1, 2001, - DeDxMIPMax-DeDxMIPMin, DeDxMIPMin, DeDxMIPMax); - hMIPVsNch[i]->Sumw2(); - - pMIPVsNch[i] = new TProfile(Form("pMIPVsNch%s", ending[i]), Form("%s; TPC track mult. |#eta|<0.8; dE/dx MIP",LatexEta[i]), 400, 1, 2001, DeDxMIPMin, DeDxMIPMax); - pMIPVsNch[i]->SetMarkerStyle(20); - pMIPVsNch[i]->SetMarkerColor(1); - pMIPVsNch[i]->SetLineColor(1); - pMIPVsNch[i]->Sumw2(); - - fListOfObjects->Add(hMIPVsNch[i]); - fListOfObjects->Add(pMIPVsNch[i]); - - //two dimmesional distributions dE/dx vs p for secondary pions - histPiV0[i] = new TH2D(Form("histPiV0%s", ending[i]), "Pions id by V0", nPtBinsV0s, ptBinsV0s, nDeltaPiBins, deltaPiLow, deltaPiHigh); - histPiV0[i]->Sumw2(); - fListOfObjects->Add(histPiV0[i]); - - histpPiV0[i] = new TH1D(Form("histPiV01D%s", ending[i]), "Pions id by V0; #it{p} (GeV/#it{c}); counts", 200, 0, 20); - histpPiV0[i]->Sumw2(); - fListOfObjects->Add(histpPiV0[i]); - - //two dimmesional distributions dE/dx vs p for secondary protons - histPV0[i] = new TH2D(Form("histPV0%s", ending[i]), "Protons id by V0", nPtBinsV0s, ptBinsV0s, nDeltaPiBins, deltaPiLow, deltaPiHigh); - histPV0[i]->Sumw2(); - fListOfObjects->Add(histPV0[i]); - - histpPV0[i] = new TH1D(Form("histPV01D%s", ending[i]), "Protons id by V0; #it{p} (GeV/#it{c}); counts", 200, 0, 20); - histpPV0[i]->Sumw2(); - fListOfObjects->Add(histpPV0[i]); - - //two dimmesional distributions dE/dx vs p for primary pions - histPiTof[i] = new TH2D(Form("histPiTof%s", ending[i]), "all charged", nPtBinsV0s, ptBinsV0s, nDeltaPiBins, deltaPiLow, deltaPiHigh); - histPiTof[i]->Sumw2(); - - histpPiTof[i] = new TH1D(Form("histPiTof1D%s", ending[i]), "Protons id by V0; #it{p} (GeV/#it{c}); counts", 200, 0, 20); - histpPiTof[i]->Sumw2(); - fListOfObjects->Add(histpPiTof[i]); - - - histAllCh[i] = new TH2D(Form("histAllCh%s", ending[i]), "Pions id by TOF", nPtBinsV0s, ptBinsV0s, nDeltaPiBins, deltaPiLow, deltaPiHigh); - histAllCh[i]->Sumw2(); - - fListOfObjects->Add(histPiTof[i]); - fListOfObjects->Add(histAllCh[i]); - - histEV0[i] = new TH2D(Form("histEV0%s", ending[i]), "Electrons id by V0", nPtBinsV0s, ptBinsV0s, nDeltaPiBins, deltaPiLow, deltaPiHigh); - histEV0[i]->Sumw2(); - fListOfObjects->Add(histEV0[i]); - - - - } - - - hMIPVsEta = new TH2D("hMIPVsEta","; #eta; dE/dx_{MIP, primary tracks}",16,-0.8,0.8,DeDxMIPMax-DeDxMIPMin, DeDxMIPMin, DeDxMIPMax); - pMIPVsEta = new TProfile("pMIPVsEta","; #eta; #LT dE/dx #GT_{MIP, primary tracks}",16,-0.8,0.8, DeDxMIPMin, DeDxMIPMax); - hMIPVsEtaV0s = new TH2D("hMIPVsEtaV0s","; #eta; dE/dx_{MIP, secondary tracks}",16,-0.8,0.8,DeDxMIPMax-DeDxMIPMin, DeDxMIPMin, DeDxMIPMax); - pMIPVsEtaV0s = new TProfile("pMIPVsEtaV0s","; #eta; #LT dE/dx #GT_{MIP, secondary tracks}",16,-0.8,0.8,DeDxMIPMin, DeDxMIPMax); - - hPlateauVsEta = new TH2D("hPlateauVsEta","; #eta; dE/dx_{Plateau, primary tracks}",16,-0.8,0.8,95-DeDxMIPMax, DeDxMIPMax, 95); - pPlateauVsEta = new TProfile("pPlateauVsEta","; #eta; #LT dE/dx #GT_{Plateau, primary tracks}",16,-0.8,0.8, DeDxMIPMax, 95); - - fListOfObjects->Add(hMIPVsEta); - fListOfObjects->Add(pMIPVsEta); - fListOfObjects->Add(hMIPVsEtaV0s); - fListOfObjects->Add(pMIPVsEtaV0s); - fListOfObjects->Add(hPlateauVsEta); - fListOfObjects->Add(pPlateauVsEta); - - - - - - - if (fAnalysisMC) { - for(Int_t i = 0; i < nHists; i++) { - for(Int_t pid = 0; pid < 7; pid++) { - - hMcIn[pid][i] = new TH1D(Form("hIn%s%s", Pid[pid],ending[i]), Form("MC in (pid %s)", Pid[pid]), - nPtBinsV0s, ptBinsV0s); - fListOfObjects->Add(hMcIn[pid][i]); - - hMcOut[pid][i] = new TH1D(Form("hMcOut%s%s", Pid[pid],ending[i]), Form("MC out (pid %s)", Pid[pid]), - nPtBinsV0s, ptBinsV0s); - fListOfObjects->Add(hMcOut[pid][i]); - - - } - } - - fVtxMC = new TH1F("fVtxMC","mc vtx", 120, -30, 30); - fListOfObjects->Add(fVtxMC); - - } - - // Post output data. - PostData(1, fListOfObjects); -} - -//______________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::UserExec(Option_t *) -{ - // Main loop - - // - // First we make sure that we have valid input(s)! - // - - - - AliVEvent *event = InputEvent(); - if (!event) { - Error("UserExec", "Could not retrieve event"); - return; - } - - - - if (fAnalysisType == "ESD"){ - fESD = dynamic_cast(event); - if(!fESD){ - Printf("%s:%d ESDEvent not found in Input Manager",(char*)__FILE__,__LINE__); - this->Dump(); - return; - } - } else { - fAOD = dynamic_cast(event); - if(!fAOD){ - Printf("%s:%d AODEvent not found in Input Manager",(char*)__FILE__,__LINE__); - this->Dump(); - return; - } - } - - - - if (fAnalysisMC) { - - if (fAnalysisType == "ESD"){ - fMC = dynamic_cast(MCEvent()); - if(!fMC){ - Printf("%s:%d MCEvent not found in Input Manager",(char*)__FILE__,__LINE__); - this->Dump(); - return; - } - - fMCStack = fMC->Stack(); - - if(!fMCStack){ - Printf("%s:%d MCStack not found in Input Manager",(char*)__FILE__,__LINE__); - this->Dump(); - return; - } - } else { // AOD - - fMC = dynamic_cast(MCEvent()); - if(fMC) - fMC->Dump(); - - fMCArray = (TClonesArray*)fAOD->FindListObject("mcparticles"); - if(!fMCArray){ - Printf("%s:%d AOD MC array not found in Input Manager",(char*)__FILE__,__LINE__); - this->Dump(); - return; - } - } - } - - - // Get trigger decision - fTriggeredEventMB = 0; //init - - fn1->Fill(0); - - if(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler())) - ->IsEventSelected() & ftrigBit ){ - fTriggeredEventMB = 1; //event triggered as minimum bias - } - - // Get process type for MC - fMcProcessType = 0; // -1=invalid, 0=data, 1=ND, 2=SD, 3=DD - - // real data that are not triggered we skip - if(!fAnalysisMC && !fTriggeredEventMB) - return; - - fn1->Fill(1); - - - if (fAnalysisMC) { - - - - if (fAnalysisType == "ESD"){ - - - - AliHeader* headerMC = fMC->Header(); - if (headerMC) { - - AliGenEventHeader* genHeader = headerMC->GenEventHeader(); - TArrayF vtxMC(3); // primary vertex MC - vtxMC[0]=9999; vtxMC[1]=9999; vtxMC[2]=9999; //initialize with dummy - if (genHeader) { - genHeader->PrimaryVertex(vtxMC); - } - fZvtxMC = vtxMC[2]; - - // PYTHIA: - AliGenPythiaEventHeader* pythiaGenHeader = - dynamic_cast(headerMC->GenEventHeader()); - if (pythiaGenHeader) { //works only for pythia - fMcProcessType = GetPythiaEventProcessType(pythiaGenHeader->ProcessType()); - } - // PHOJET: - AliGenDPMjetEventHeader* dpmJetGenHeader = - dynamic_cast(headerMC->GenEventHeader()); - if (dpmJetGenHeader) { - fMcProcessType = GetDPMjetEventProcessType(dpmJetGenHeader->ProcessType()); - } - } - } else { // AOD - - - - AliAODMCHeader* mcHeader = dynamic_cast(fAOD->FindListObject("mcHeader")); - - - if(mcHeader) { - fZvtxMC = mcHeader->GetVtxZ(); - - - - if(strstr(mcHeader->GetGeneratorName(), "Pythia")) { - fMcProcessType = GetPythiaEventProcessType(mcHeader->GetEventType()); - } else { - fMcProcessType = GetDPMjetEventProcessType(mcHeader->GetEventType()); - } - } - } - - - } - - - - if (fAnalysisType == "ESD"){ - - const AliESDVertex *vtxESD = fESD->GetPrimaryVertexTracks(); - if(vtxESD->GetNContributors()<1) { - // SPD vertex - vtxESD = fESD->GetPrimaryVertexSPD(); - /* quality checks on SPD-vertex */ - TString vertexType = vtxESD->GetTitle(); - if (vertexType.Contains("vertexer: Z") && (vtxESD->GetDispersion() > 0.04 || vtxESD->GetZRes() > 0.25)) - fZvtx = -1599; //vertex = 0x0; // - else if (vtxESD->GetNContributors()<1) - fZvtx = -999; //vertex = 0x0; // - else - fZvtx = vtxESD->GetZ(); - } - else - fZvtx = vtxESD->GetZ(); - - } - else // AOD - fZvtx = GetVertex(fAOD); - - fVtxBeforeCuts->Fill(fZvtx); - - //cut on the z position of vertex - if (TMath::Abs(fZvtx) > fVtxCut) { - return; - } - fn1->Fill(2); - - - - - - - Float_t centrality = -10; - - // only analyze triggered events - if(fTriggeredEventMB) { - - if (fAnalysisType == "ESD"){ - if(fAnalysisPbPb){ - AliCentrality *centObject = fESD->GetCentrality(); - centrality = centObject->GetCentralityPercentile(fCentEst); - centralityGlobal = centrality; - if((centrality>fMaxCent)||(centralityFill(centrality); - fn1->Fill(3); - if(fAnalysisMC){ - if(TMath::Abs(fZvtxMC)Fill(fZvtxMC); - } - } - AnalyzeESD(fESD); - } else { // AOD - if(fAnalysisPbPb){ - AliCentrality *centObject = fAOD->GetCentrality(); - if(centObject){ - centrality = centObject->GetCentralityPercentile(fCentEst); - } - //cout<<"centrality="<fMaxCent)||(centralityFill(centrality); - fn1->Fill(3); - if(fAnalysisMC){ - if(TMath::Abs(fZvtxMC)Fill(fZvtxMC); - } - } - AnalyzeAOD(fAOD); - } - } - - fVtxAfterCuts->Fill(fZvtx); - - - - - // Post output data. - PostData(1, fListOfObjects); -} - -//________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::AnalyzeESD(AliESDEvent* esdEvent) -{ - fRun = esdEvent->GetRunNumber(); - fEventId = 0; - if(esdEvent->GetHeader()) - fEventId = GetEventIdAsLong(esdEvent->GetHeader()); - - cout << "centrality=" << centralityGlobal << endl; - - - Bool_t isPileup = esdEvent->IsPileupFromSPD(); - if(fPileUpRej) - if(isPileup) - return; - fn1->Fill(4); - - - // Int_t event = esdEvent->GetEventNumberInFile(); - //UInt_t time = esdEvent->GetTimeStamp(); - // ULong64_t trigger = esdEvent->GetTriggerMask(); - magf = esdEvent->GetMagneticField(); - - - - - - if(fTriggeredEventMB) {// Only MC case can we have not triggered events - - // accepted event - fEvents->Fill(0); - - - //Change, 10/04/13. Now accept all events to do a correct normalization - //if(fVtxStatus!=1) return; // accepted vertex - //Int_t nESDTracks = esdEvent->GetNumberOfTracks(); - - ProduceArrayTrksESD( esdEvent );//produce array with global track parameters - ProduceArrayV0ESD( esdEvent );//v0's - - - fEvents->Fill(1); - - - - - } // end if triggered - - -} - -//________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::AnalyzeAOD(AliAODEvent* aodEvent) -{ - fRun = aodEvent->GetRunNumber(); - fEventId = 0; - if(aodEvent->GetHeader()) - fEventId = GetEventIdAsLong(aodEvent->GetHeader()); - - //UInt_t time = 0; // Missing AOD info? aodEvent->GetTimeStamp(); - magf = aodEvent->GetMagneticField(); - - //Int_t trackmult = 0; // no pt cuts - //Int_t nadded = 0; - - Bool_t isPileup = aodEvent->IsPileupFromSPD(); - if(fPileUpRej) - if(isPileup) - return; - fn1->Fill(4); - - - - if(fTriggeredEventMB) {// Only MC case can we have not triggered events - - // accepted event - fEvents->Fill(0); - - //if(fVtxStatus!=1) return; // accepted vertex - //Int_t nAODTracks = aodEvent->GetNumberOfTracks(); - - ProduceArrayTrksAOD( aodEvent ); - ProduceArrayV0AOD( aodEvent ); - - fEvents->Fill(1); - - - - - } // end if triggered - -} - -//_____________________________________________________________________________ -Float_t AliAnalysisTaskQAHighPtDeDx::GetVertex(const AliVEvent* event) const -{ - Float_t zvtx = -999; - - const AliVVertex* primaryVertex = event->GetPrimaryVertex(); - - if(primaryVertex->GetNContributors()>0) - zvtx = primaryVertex->GetZ(); - - return zvtx; -} - -//_____________________________________________________________________________ -Short_t AliAnalysisTaskQAHighPtDeDx::GetPidCode(Int_t pdgCode) const -{ - // return our internal code for pions, kaons, and protons - - Short_t pidCode = 6; - - switch (TMath::Abs(pdgCode)) { - case 211: - pidCode = 1; // pion - break; - case 321: - pidCode = 2; // kaon - break; - case 2212: - pidCode = 3; // proton - break; - case 11: - pidCode = 4; // electron - break; - case 13: - pidCode = 5; // muon - break; - default: - pidCode = 6; // something else? - }; - - return pidCode; -} - -//_____________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::ProcessMCTruthESD() -{ - // Fill the special MC histogram with the MC truth info - - const Int_t nTracksMC = fMCStack->GetNtrack(); - - for (Int_t iTracks = 0; iTracks < nTracksMC; iTracks++) { - - //Cuts - if(!(fMCStack->IsPhysicalPrimary(iTracks))) - continue; - - TParticle* trackMC = fMCStack->Particle(iTracks); - - TParticlePDG* pdgPart = trackMC ->GetPDG(); - Double_t chargeMC = pdgPart->Charge(); - - if(chargeMC==0) - continue; - - if (TMath::Abs(trackMC->Eta()) > fEtaCut ) - continue; - - Double_t etaMC = trackMC->Eta(); - Int_t pdgCode = trackMC->GetPdgCode(); - Short_t pidCodeMC = 0; - pidCodeMC = GetPidCode(pdgCode); - - - for(Int_t nh = 0; nh < 9; nh++) { - - if( etaMC > etaHigh[nh]/10.0 || etaMC < etaLow[nh]/10.0 ) - continue; - - hMcIn[0][nh]->Fill(trackMC->Pt()); - hMcIn[pidCodeMC][nh]->Fill(trackMC->Pt()); - - - } - - }//MC track loop - - - -} - -//_____________________________________________________________________________ -void AliAnalysisTaskQAHighPtDeDx::ProcessMCTruthAOD() -{ - // Fill the special MC histogram with the MC truth info - - - const Int_t nTracksMC = fMCArray->GetEntriesFast(); - - for (Int_t iTracks = 0; iTracks < nTracksMC; iTracks++) { - - AliAODMCParticle* trackMC = dynamic_cast(fMCArray->At(iTracks)); - - if(!trackMC){ - AliError("Cannot get MC particle"); - continue; - } - - //Cuts - if(!(trackMC->IsPhysicalPrimary())) - continue; - - - Double_t chargeMC = trackMC->Charge(); - if(chargeMC==0) - continue; - - - if (TMath::Abs(trackMC->Eta()) > fEtaCut ) - continue; - - Double_t etaMC = trackMC->Eta(); - Int_t pdgCode = trackMC->GetPdgCode(); - Short_t pidCodeMC = 0; - pidCodeMC = GetPidCode(pdgCode); - - //cout<<"pidcode="< etaHigh[nh]/10.0 || etaMC < etaLow[nh]/10.0 ) - continue; - - hMcIn[0][nh]->Fill(trackMC->Pt()); - hMcIn[pidCodeMC][nh]->Fill(trackMC->Pt()); - - - } - - }//MC track loop - - -} - - -//_____________________________________________________________________________ -Short_t AliAnalysisTaskQAHighPtDeDx::GetPythiaEventProcessType(Int_t pythiaType) { - // - // Get the process type of the event. PYTHIA - // - // source PWG0 dNdpt - - Short_t globalType = -1; //init - - if(pythiaType==92||pythiaType==93){ - globalType = 2; //single diffractive - } - else if(pythiaType==94){ - globalType = 3; //double diffractive - } - //else if(pythiaType != 91){ // also exclude elastic to be sure... CKB?? - else { - globalType = 1; //non diffractive - } - return globalType; -} - -//_____________________________________________________________________________ -Short_t AliAnalysisTaskQAHighPtDeDx::GetDPMjetEventProcessType(Int_t dpmJetType) { - // - // get the process type of the event. PHOJET - // - //source PWG0 dNdpt - // can only read pythia headers, either directly or from cocktalil header - Short_t globalType = -1; - - if (dpmJetType == 1 || dpmJetType == 4) { // explicitly inelastic plus central diffraction - globalType = 1; - } - else if (dpmJetType==5 || dpmJetType==6) { - globalType = 2; - } - else if (dpmJetType==7) { - globalType = 3; - } - return globalType; -} - -//_____________________________________________________________________________ -ULong64_t AliAnalysisTaskQAHighPtDeDx::GetEventIdAsLong(AliVHeader* header) const -{ - // To have a unique id for each event in a run! - // Modified from AliRawReader.h - return ((ULong64_t)header->GetBunchCrossNumber()+ - (ULong64_t)header->GetOrbitNumber()*3564+ - (ULong64_t)header->GetPeriodNumber()*16777215*3564); -} - - -//____________________________________________________________________ -TParticle* AliAnalysisTaskQAHighPtDeDx::FindPrimaryMother(AliStack* stack, Int_t label) -{ - // - // Finds the first mother among the primary particles of the particle identified by