]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
authorfnoferin@cern.ch <noferini@boalicetof.bo.infn.it>
Fri, 27 Dec 2013 11:10:40 +0000 (12:10 +0100)
committerfnoferin@cern.ch <noferini@boalicetof.bo.infn.it>
Fri, 27 Dec 2013 11:10:40 +0000 (12:10 +0100)
408 files changed:
.gitignore
ANALYSIS/ANALYSISaliceLinkDef.h
ANALYSIS/AliAnalysisAlien.cxx
ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisManager.h
ANALYSIS/AliAnalysisTaskMCParticleFilter.cxx
ANALYSIS/AliAnalysisTaskMCParticleFilter.h
ANALYSIS/AliAnalysisTaskPIDResponse.cxx
ANALYSIS/AliTRDTriggerAnalysis.cxx
ANALYSIS/AliTRDTriggerAnalysis.h
ANALYSIS/CMakelibANALYSISalice.pkg
ANALYSIS/CMakelibESDfilter.pkg [new file with mode: 0644]
ANALYSIS/ESDfilter/AliAnalysisTaskESDfilter.cxx [moved from ANALYSIS/AliAnalysisTaskESDfilter.cxx with 98% similarity]
ANALYSIS/ESDfilter/AliAnalysisTaskESDfilter.h [moved from ANALYSIS/AliAnalysisTaskESDfilter.h with 99% similarity]
ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C [moved from ANALYSIS/macros/AddTaskESDFilter.C with 100% similarity]
ANALYSIS/ESDfilterLinkDef.h [new file with mode: 0644]
ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx
ANALYSIS/TenderSupplies/AliTRDTenderSupply.cxx
ANALYSIS/macros/AddTaskCentrality.C
ANALYSIS/macros/AddTaskPIDResponse.C
ANALYSIS/macros/train/AddMCGenHijing.C [new file with mode: 0644]
ANALYSIS/macros/train/AddMCGeneratorHandler.C [new file with mode: 0644]
CMakeLists.txt
EMCAL/AliEMCALRecoUtils.cxx
EMCAL/AliEMCALRecoUtils.h
HIJING/hijing1_36/hijing.F
HLT/CMakelibAliHLTTrigger.pkg
HLT/CMakelibHLTrec.pkg
HLT/JET/AliHLTJETReader.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONFullTracker.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONFullTracker.h
HLT/RCU/AliHLTAltroGenerator.cxx
HLT/RCU/AliHLTAltroGenerator.h
HLT/TPCLib/AliHLTTPCClusterFinder.cxx
HLT/TPCLib/AliHLTTPCHWCFSpacePointContainer.cxx
HLT/TPCLib/AliHLTTPCRawSpacePointContainer.cxx
HLT/TPCLib/tracking-ca/AliTPCtrackerCA.cxx
HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx
HLT/global/AliHLTGlobalEsdConverterComponent.cxx
HLT/rec/AliHLTMiscImplementation.cxx
ITS/AliITS.cxx
ITS/AliITSInitGeometry.cxx
ITS/AliITSInitGeometry.h
ITS/AliITSQASDDChecker.cxx
ITS/AliITStrackV2.cxx
ITS/AliITStrackerMI.cxx
ITS/AliITSv11.cxx
ITS/AliITSv11.h
ITS/UPGRADE/AliITSUGeomTGeo.cxx
ITS/UPGRADE/AliITSUGeomTGeo.h
ITS/UPGRADE/AliITSUInitGeometry.cxx [deleted file]
ITS/UPGRADE/AliITSUInitGeometry.h [deleted file]
ITS/UPGRADE/AliITSUv0.cxx
ITS/UPGRADE/AliITSUv11.cxx [deleted file]
ITS/UPGRADE/AliITSUv11.h [deleted file]
ITS/UPGRADE/AliITSUv11Layer.cxx [deleted file]
ITS/UPGRADE/AliITSUv11Layer.h [deleted file]
ITS/UPGRADE/CMakelibITSUpgradeSim.pkg
ITS/UPGRADE/ITSUpgradeSimLinkDef.h
ITS/UPGRADE/testITSU/CreateITSUsinglesegm.C [new file with mode: 0644]
JETAN/AliAnalysisTaskJetCluster.cxx
JETAN/AliAnalysisTaskJetCluster.h
JETAN/AliFastJetBkg.cxx
JETAN/AliFastJetBkg.h
JETAN/AliJetBkg.cxx
JETAN/AliJetBkg.h
JETAN/AliJetFillCalTrkEvent.h
MUON/AliMUONCalibrationData.cxx
MUON/AliMUONCalibrationData.h
MUON/AliMUONDigitMaker.cxx
MUON/AliMUONLocalTriggerBoard.cxx
MUON/AliMUONLocalTriggerBoard.h
MUON/AliMUONRawStreamTriggerHP.h
MUON/AliMUONTrackerConditionDataMaker.cxx
MUON/AliMUONTriggerCrateStore.cxx
MUON/AliMUONTriggerElectronics.cxx
MUON/AliMUONTriggerElectronics.h
MUON/AliMUONTriggerQADataMakerRec.cxx
MUON/AliMUONTriggerStoreV1.cxx
MUON/AliMUONTriggerUtilities.cxx
OADB/COMMON/CENTRALITY/data/centrality.root
OADB/COMMON/PID/data/TPCPIDResponse.root
OADB/COMMON/PID/data/TPCetaMaps.root
PWG/CMakelibPWGEMCAL.pkg
PWG/CMakelibPWGmuon.pkg
PWG/CaloTrackCorrBase/AliCaloPID.h
PWG/CaloTrackCorrBase/AliCaloTrackMCReader.cxx
PWG/CaloTrackCorrBase/AliCaloTrackReader.cxx
PWG/CaloTrackCorrBase/AliCaloTrackReader.h
PWG/CaloTrackCorrBase/AliCalorimeterUtils.cxx
PWG/EMCAL/AliAnalysisTaskEmcal.cxx
PWG/EMCAL/AliAnalysisTaskEmcal.h
PWG/EMCAL/AliEmcalAodTrackFilterTask.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalAodTrackFilterTask.h [new file with mode: 0644]
PWG/EMCAL/AliEmcalClusTrackMatcherTask.cxx
PWG/EMCAL/AliEmcalClusTrackMatcherTask.h
PWG/EMCAL/AliEmcalContainer.h
PWG/EMCAL/AliEmcalEsdTrackFilterTask.cxx [moved from PWG/EMCAL/AliEmcalEsdTpcTrackTask.cxx with 78% similarity]
PWG/EMCAL/AliEmcalEsdTrackFilterTask.h [moved from PWG/EMCAL/AliEmcalEsdTpcTrackTask.h with 54% similarity]
PWG/EMCAL/AliEmcalParticle.h
PWG/EMCAL/AliEmcalParticleMaker.cxx
PWG/EMCAL/AliEmcalPicoTrackMaker.cxx
PWG/EMCAL/AliEmcalPicoTrackMaker.h
PWG/EMCAL/AliEmcalSetupTask.cxx
PWG/EMCAL/AliEmcalSetupTask.h
PWG/EMCAL/AliEmcalTrackPropagatorTask.cxx
PWG/EMCAL/AliEmcalTrackPropagatorTask.h
PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.h [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerMaker.cxx
PWG/EMCAL/AliEmcalTriggerPatchInfo.cxx
PWG/EMCAL/AliEmcalTriggerPatchInfo.h
PWG/EMCAL/AliParticleContainer.cxx
PWG/EMCAL/AliParticleContainer.h
PWG/EMCAL/AliPicoTrack.cxx
PWG/EMCAL/AliPicoTrack.h
PWG/EMCAL/macros/AddTaskAodTrackFilter.C [new file with mode: 0644]
PWG/EMCAL/macros/AddTaskEMCALTenderUsingDatasetDef.C [new file with mode: 0644]
PWG/EMCAL/macros/AddTaskEmcalEsdTrackFilter.C [moved from PWG/EMCAL/macros/AddTaskEmcalEsdTpcTrack.C with 95% similarity]
PWG/EMCAL/macros/AddTaskEmcalSetup.C
PWG/EMCAL/macros/AddTaskEmcalTrackPropagatorAOD.C [new file with mode: 0644]
PWG/FLOW/Tasks/AliAnalysisTaskFlowStrange.cxx
PWG/FLOW/Tasks/AliAnalysisTaskFlowStrange.h
PWG/FLOW/Tasks/AliAnalysisTaskPhiFlow.cxx
PWG/FLOW/Tasks/AliAnalysisTaskPhiFlow.h
PWG/FLOW/Tasks/AliFlowTrackCuts.cxx
PWG/FLOW/Tasks/AliJetFlowTools.cxx
PWG/FLOW/Tasks/AliJetFlowTools.h
PWG/Glauber/AliGlauberMC.cxx
PWG/Glauber/AliGlauberMC.h
PWG/Glauber/AliGlauberNucleon.h
PWG/PWGEMCALLinkDef.h
PWG/PWGmuonLinkDef.h
PWG/Tools/AliHelperPID.cxx
PWG/muon/AddTaskMuMu.C
PWG/muon/AliAnalysisMuMuBase.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuBase.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuBinning.cxx
PWG/muon/AliAnalysisMuMuBinning.h
PWG/muon/AliAnalysisMuMuCutCombination.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuCutCombination.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuCutElement.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuCutElement.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuCutRegistry.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuCutRegistry.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuEventCutter.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuEventCutter.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuGlobal.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuGlobal.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuMinv.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuMinv.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuNch.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuNch.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuSingle.cxx [new file with mode: 0644]
PWG/muon/AliAnalysisMuMuSingle.h [new file with mode: 0644]
PWG/muon/AliAnalysisMuonUtility.cxx
PWG/muon/AliAnalysisMuonUtility.h
PWG/muon/AliAnalysisTaskMuMu.cxx
PWG/muon/AliAnalysisTaskMuMu.h
PWG/muon/AliAnalysisTaskSingleMu.cxx
PWG/muon/AliAnalysisTaskSingleMu.h
PWG/muon/AliMergeableCollection.cxx
PWG/muon/AliMergeableCollection.h
PWG/muon/AliMuonEventCuts.cxx
PWG/muon/AliMuonEventCuts.h
PWG/muon/AliUtilityMuonAncestor.cxx
PWG/muon/Doxyfile [new file with mode: 0644]
PWG/muon/DoxygenLayout.xml [new file with mode: 0644]
PWG/muon/runMuMu.C [new file with mode: 0755]
PWG/muondep/AliAnalysisMuMu.cxx
PWG/muondep/AliAnalysisMuMuSpectra.cxx
PWG/muondep/AliAnalysisTriggerScalers.cxx
PWG/muondep/AliAnalysisTriggerScalers.h
PWGCF/CMakelibPWGCFCorrelationsDPhi.pkg
PWGCF/Correlations/Base/AliAnalyseLeadingTrackUE.cxx
PWGCF/Correlations/Base/AliUEHist.cxx
PWGCF/Correlations/Base/AliUEHist.h
PWGCF/Correlations/Base/AliUEHistograms.cxx
PWGCF/Correlations/Base/AliUEHistograms.h
PWGCF/Correlations/DPhi/AliAnalysisTaskPhiCorrelations.cxx
PWGCF/Correlations/DPhi/AliAnalysisTaskPhiCorrelations.h
PWGCF/Correlations/DPhi/AliDptDptInMC.cxx [new file with mode: 0644]
PWGCF/Correlations/DPhi/AliDptDptInMC.h [new file with mode: 0644]
PWGCF/Correlations/DPhi/DiHadronPID/AliAODTrackCutsDiHadronPID.cxx
PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.cxx
PWGCF/Correlations/DPhi/DiHadronPID/AliAnalysisTaskCompareAODTrackCuts.h
PWGCF/Correlations/DPhi/DiHadronPID/AliFunctionsDiHadronPID.cxx
PWGCF/Correlations/DPhi/DiHadronPID/AliFunctionsDiHadronPID.h
PWGCF/Correlations/DPhi/DiHadronPID/AliTrackDiHadronPID.cxx
PWGCF/Correlations/DPhi/DiHadronPID/AliTrackDiHadronPID.h
PWGCF/Correlations/macros/dptdptcorrelations/AddTaskCorrMC.C [new file with mode: 0644]
PWGCF/Correlations/macros/dptdptcorrelations/AddTaskWeightMC.C [new file with mode: 0644]
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEffContBF.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEffContBF.h
PWGCF/EBYE/BalanceFunctions/AliBalancePsi.cxx
PWGCF/EBYE/BalanceFunctions/Corrections/CorrectionMaps_PbPb_768.root
PWGCF/EBYE/macros/AddTaskBalanceEffCont.C
PWGCF/EBYE/macros/drawBalanceFunction2DPsi.C
PWGCF/EBYE/macros/drawBalanceFunctionPsi.C
PWGCF/FEMTOSCOPY/AliFemto/AliFemtoEventReaderAOD.cxx
PWGCF/FEMTOSCOPY/AliFemto/AliFemtoEventReaderAOD.h
PWGCF/FEMTOSCOPY/Chaoticity/AliThreePionRadii.cxx
PWGCF/FEMTOSCOPY/Chaoticity/AliThreePionRadii.h
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0Analysis.cxx
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0Analysis.h
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0EventCollection.cxx
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0EventCollection.h
PWGCF/FEMTOSCOPY/macros/AddTaskK0Femto.C
PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/AddTaskFemtoKchHBT0010.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/ConfigFemtoAnalysis.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/AddTaskFemtoKchHBT0010.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/ConfigFemtoAnalysis.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/DcaTpcOnlyTTC2/central/ConfigFemtoAnalysis.C
PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/DcaTpcOnlyTTC2/central18/ConfigFemtoAnalysis.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/DcaTpcOnlyTTCeta015phi045/central/ConfigFemtoAnalysis.C
PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/FlatCent/ConfigFemtoAnalysis.C [new file with mode: 0644]
PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/NoFlatCent/ConfigFemtoAnalysis.C [new file with mode: 0644]
PWGCF/FLOW/Documentation/examples/runGlauberMC.C
PWGCF/FLOW/Documentation/examples/runGlauberMCpPb.C
PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C
PWGCF/FLOW/macros/AddTaskFlowStrange.C
PWGCF/FLOW/macros/jetFlowTools.C
PWGCF/PWGCFCorrelationsDPhiLinkDef.h
PWGDQ/dielectron/AliDielectron.cxx
PWGDQ/dielectron/AliDielectron.h
PWGDQ/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.cxx
PWGDQ/dielectron/AliDielectronEventCuts.cxx
PWGDQ/dielectron/AliDielectronEventCuts.h
PWGDQ/dielectron/AliDielectronPID.cxx
PWGDQ/dielectron/AliDielectronPID.h
PWGDQ/dielectron/AliDielectronPair.cxx
PWGDQ/dielectron/AliDielectronPair.h
PWGDQ/dielectron/AliDielectronVarManager.cxx
PWGDQ/dielectron/AliDielectronVarManager.h
PWGDQ/dielectron/macrosJPSI/AddTask_mfigueredo_JPsi.C
PWGDQ/dielectron/macrosJPSI/ConfigJpsi_jb_PbPb.C
PWGDQ/dielectron/macrosJPSI/ConfigJpsi_mf_PbPb.C
PWGGA/CMakelibPWGGAEMCALTasks.pkg
PWGGA/CaloTasks/AliAnalysisTaskCaloFilter.cxx
PWGGA/CaloTrackCorrelations/AliAnaCalorimeterQA.cxx
PWGGA/CaloTrackCorrelations/AliAnaElectron.cxx
PWGGA/CaloTrackCorrelations/AliAnaPhotonConvInCalo.cxx
PWGGA/CaloTrackCorrelations/AliAnaPi0.cxx
PWGGA/CaloTrackCorrelations/AliAnaPi0EbE.cxx
PWGGA/CaloTrackCorrelations/macros/QA/DrawAnaCaloTrackQA.C
PWGGA/CaloTrackCorrelations/macros/QA/DrawProductionComparison.C [new file with mode: 0644]
PWGGA/EMCALTasks/AliAnalysisTaskEMCALClusterize.cxx
PWGGA/EMCALTasks/AliAnalysisTaskEMCALTriggerQA.cxx
PWGGA/GammaConv/AliAnalysisTaskGammaConvV1.cxx
PWGGA/GammaConv/AliAnalysisTaskGammaConvV1.h
PWGGA/GammaConv/AliAnalysisTaskdPhi.cxx
PWGGA/GammaConv/AliConversionCuts.cxx
PWGGA/GammaConv/AliConversionCuts.h
PWGGA/GammaConv/AliConversionTrackCuts.cxx
PWGGA/GammaConv/AliConversionTrackCuts.h
PWGGA/GammaConv/macros/AddTask_GammaConvV1_PbPb.C
PWGGA/GammaConv/macros/AddTask_GammaConvV1_pPb.C
PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx
PWGHF/correlationHF/AliHFAssociatedTrackCuts.h
PWGHF/hfe/AliHFEpidTRD.cxx
PWGHF/hfe/AliHFEpidTRD.h
PWGHF/hfe/AliHFEtrdPIDqaV1.cxx
PWGHF/hfe/AliHFEtrdPIDqaV1.h
PWGHF/hfe/macros/AddTaskHFEnpepPb.C
PWGHF/hfe/macros/AddTaskHFEpPb.C
PWGHF/hfe/macros/configs/PbPb/ConfigHFEnpePbPb.C
PWGHF/hfe/macros/configs/pPb/ConfigHFEnpepPb.C
PWGHF/hfe/macros/configs/pPb/ConfigHFEpPb.C
PWGHF/hfe/macros/configs/pPb/ConfigHFEpPbTRD.C
PWGHF/vertexingHF/AliAnalysisTaskSEHFQA.cxx
PWGHF/vertexingHF/AliHFSystErr.cxx
PWGHF/vertexingHF/AliRDHFCuts.h
PWGHF/vertexingHF/AliRDHFCutsDStartoKpipi.cxx
PWGHF/vertexingHF/AliRDHFCutsDStartoKpipi.h
PWGHF/vertexingHF/macros/DrawQAoutput.C
PWGHF/vertexingHF/upgrade/AliAnalysisTaskCountLcEta.cxx
PWGHF/vertexingHF/upgrade/AliAnalysisTaskCountLcEta.h
PWGJE/AliAnaChargedJetResponseMaker.cxx
PWGJE/AliAnalysisTaskJetCore.cxx
PWGJE/AliAnalysisTaskJetCore.h
PWGJE/EMCALJetTasks/AliHadCorrTask.cxx
PWGJE/EMCALJetTasks/AliHadCorrTask.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalDiJetAna.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalDiJetAna.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalDiJetBase.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalDiJetBase.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskFullpAJets.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskFullpAJets.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskFullppJet.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetMatching.cxx
PWGJE/EMCALJetTasks/macros/AddTaskJetPreparation.C
PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.cxx
PWGJE/UserTasks/AliAnalysisTaskIDFragmentationFunction.cxx
PWGJE/UserTasks/AliAnalysisTaskJetHBOM.h
PWGJE/UserTasks/AliAnalysisTaskJetsTriggerTRD.h
PWGJE/UserTasks/AliAnalysisTaskPID.cxx
PWGJE/UserTasks/AliAnalysisTaskPID.h
PWGJE/UserTasks/AliAnalysisTaskPIDV0base.cxx
PWGJE/UserTasks/AliAnalysisTaskPIDV0base.h
PWGJE/macros/AddTaskJetCore.C
PWGLF/CMakelibPWGLFforward2.pkg
PWGLF/FORWARD/analysis2/AddTaskForwardFlowQC.C [moved from PWGLF/FORWARD/analysis2/AddTaskForwardFlow.C with 56% similarity]
PWGLF/FORWARD/analysis2/AliAODForwardHeader.cxx [new file with mode: 0644]
PWGLF/FORWARD/analysis2/AliAODForwardHeader.h [new file with mode: 0644]
PWGLF/FORWARD/analysis2/AliAODForwardMult.h
PWGLF/FORWARD/analysis2/AliBaseAODTask.cxx
PWGLF/FORWARD/analysis2/AliBaseESDTask.cxx
PWGLF/FORWARD/analysis2/AliBaseESDTask.h
PWGLF/FORWARD/analysis2/AliBasedNdetaTask.cxx
PWGLF/FORWARD/analysis2/AliCentralMultiplicityTask.cxx
PWGLF/FORWARD/analysis2/AliCopyHeaderTask.h
PWGLF/FORWARD/analysis2/AliFMDCorrELossFit.cxx
PWGLF/FORWARD/analysis2/AliFMDDensityCalculator.cxx
PWGLF/FORWARD/analysis2/AliFMDDensityCalculator.h
PWGLF/FORWARD/analysis2/AliFMDEventInspector.cxx
PWGLF/FORWARD/analysis2/AliFMDHistCollector.cxx
PWGLF/FORWARD/analysis2/AliFMDHistCollector.h
PWGLF/FORWARD/analysis2/AliFMDSharingFilter.cxx
PWGLF/FORWARD/analysis2/AliFMDSharingFilter.h
PWGLF/FORWARD/analysis2/AliForwardFlowTaskQC.cxx
PWGLF/FORWARD/analysis2/AliForwardFlowTaskQC.h
PWGLF/FORWARD/analysis2/AliForwardMCFlowTaskQC.cxx
PWGLF/FORWARD/analysis2/AliForwardMCFlowTaskQC.h
PWGLF/FORWARD/analysis2/AliForwardMultDists.cxx
PWGLF/FORWARD/analysis2/AliForwardMultDists.h
PWGLF/FORWARD/analysis2/AliForwardMultiplicityTask.cxx
PWGLF/FORWARD/analysis2/AliForwardUtil.cxx
PWGLF/FORWARD/analysis2/AliForwardUtil.h
PWGLF/FORWARD/analysis2/AliOADBForward.cxx
PWGLF/FORWARD/analysis2/AliOADBForward.h
PWGLF/FORWARD/analysis2/AliPoissonCalculator.cxx
PWGLF/FORWARD/analysis2/AliPoissonCalculator.h
PWGLF/FORWARD/analysis2/ForwardAODConfig.C
PWGLF/FORWARD/analysis2/MakeFlow.C
PWGLF/FORWARD/analysis2/corrs/CorrDrawer.C
PWGLF/FORWARD/analysis2/doc/Trains.C
PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C
PWGLF/FORWARD/analysis2/scripts/SummaryDrawer.C
PWGLF/FORWARD/analysis2/trains/ELossTimeTask.C [new file with mode: 0644]
PWGLF/FORWARD/analysis2/trains/ELossTimeTrain.C [new file with mode: 0644]
PWGLF/FORWARD/analysis2/trains/EventTimeTask.C [new file with mode: 0644]
PWGLF/FORWARD/analysis2/trains/EventTimeTrain.C [new file with mode: 0644]
PWGLF/FORWARD/analysis2/trains/MakeAODTrain.C
PWGLF/FORWARD/analysis2/trains/MakeFlowTrain.C
PWGLF/FORWARD/analysis2/trains/MakeMultDistsTrain.C
PWGLF/FORWARD/doc/Doxyfile
PWGLF/FORWARD/doc/layout.xml [new file with mode: 0644]
PWGLF/FORWARD/trains/ChainBuilder.C
PWGLF/FORWARD/trains/CreateFileCollection.C
PWGLF/FORWARD/trains/CreateIndex.C [new file with mode: 0644]
PWGLF/FORWARD/trains/LiteHelper.C
PWGLF/FORWARD/trains/MyAnalysis.C
PWGLF/FORWARD/trains/ParUtilities.C
PWGLF/FORWARD/trains/ProofHelper.C
PWGLF/FORWARD/trains/TrainSetup.C
PWGLF/FORWARD/trains/trainMain.cxx
PWGLF/PWGLFforward2LinkDef.h
PWGLF/RESONANCES/AliRsnCutSetDaughterParticle.cxx
PWGLF/RESONANCES/AliRsnCutSetDaughterParticle.h
PWGLF/RESONANCES/AliRsnCutTrackQuality.cxx
PWGLF/RESONANCES/AliRsnCutTrackQuality.h
PWGLF/RESONANCES/macros/lego_train/AddRsnDaughterCutsPhiNsigma.C
PWGLF/RESONANCES/macros/mini/ConfigTOFanalysisKStar.C
PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysisPbPbAOD.cxx
PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysisPbPbAOD.h
PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysispPb.h
PWGLF/SPECTRA/ChargedHadrons/dNdPt/macros/AddTask_dNdPt_PbPbAOD.C
PWGLF/SPECTRA/Nuclei/masses/AddTaskNuclei.C
PWGLF/SPECTRA/Nuclei/masses/AliAnalysisNucleiMass.cxx
PWGLF/SPECTRA/Nuclei/masses/AliAnalysisNucleiMass.h
PWGLF/SPECTRA/PiKaPr/TestAOD/AddTaskSpectraAllChAOD.C
PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraAllChAOD.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODEventCuts.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODEventCuts.h
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODTrackCuts.cxx
PWGLF/STRANGENESS/Correlations/AliAnalysisTaskLambdaOverK0sJets.cxx
PWGPP/ITS/AliAnalysisTaskITSAlignQA.cxx
PWGPP/TOF/AddTaskTOFqaID.C
PWGPP/TOF/AliAnalysisTaskTOFqaID.cxx
PWGPP/TOF/AliAnalysisTaskTOFqaID.h
PWGPP/TRD/AliTRDcheckESD.cxx
PWGPP/TRD/AliTRDcheckESD.h
PWGPP/TRD/macros/AddTRDcheckESD.C
PWGPP/pid/AliPIDperfContainer.cxx
PWGPP/pid/AliPIDperfContainer.h
PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonBase.cxx
PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonBase.h
PWGUD/UPC/AliAnalysisTaskUpcPsi2s.cxx
PWGUD/UPC/AliAnalysisTaskUpcPsi2s.h
STEER/STEERBase/AliExternalTrackParam.cxx
STEER/STEERBase/AliPIDResponse.cxx
STEER/STEERBase/AliPIDResponse.h
STEER/STEERBase/AliTPCPIDResponse.cxx
STEER/STEERBase/AliTPCPIDResponse.h
STEER/STEERBase/AliTRDPIDResponse.cxx
STEER/STEERBase/AliVTrack.h
TRD/AliTRDReconstructor.cxx
TRD/AliTRDgtuSim.cxx
TRD/AliTRDgtuTMU.cxx
TRD/AliTRDgtuTMU.h
TRD/AliTRDtrackGTU.cxx
TRD/AliTRDtrapConfig.cxx
TRD/AliTRDtrapConfig.h
cmake/CMakeDA.cmake

index 011221d5458a74be10a587213a6517addaf4ff91..4e12e800cecf5009f4d84adac71537df3723640e 100644 (file)
@@ -1,5 +1,54 @@
+# Compiled Object files
+*.slo
+*.lo
+*.o
+
+# Compiled Dynamic libraries
+*.so
+*.so.[0-9]*
+*.dylib
+*.dll
+*.libs
+*.lib
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+
+# Dictionary source files
+G__*.c
+G__*.cxx
+G__*.h
+
+# Other Stuff
+*.d
+*.pyc
+*.pyo
+*.pdb
+*.obj
+*.def
+*.exp
+*.manifest
+*.rootmap
+CMakeLists.txt
+
+# Backup files from common editors
+*.swp
+*~
+
+# /
 /bin
 /lib
 /include
 /tmp
 
+# /test/
+/test/*/*.root
+/test/*/*.log
+/test/*/*.ps
+/test/*/*.dat
+/test/*/GRP
+/test/*/*/*.root
+/test/*/*/*.log
+/test/*/*/*.ps
index 34fbb298ac1f89fab9dd4d5e07881c2b0de2f0ac..b323efd05082aeb3262bae8c3dbbd5b08bb72e5b 100644 (file)
@@ -6,7 +6,6 @@
 
 #pragma link C++ class  AliAnalysisTaskSE+;
 #pragma link C++ class  AliAnalysisTaskME+;
-#pragma link C++ class  AliAnalysisTaskESDfilter+;
 #pragma link C++ class  AliAnalysisTaskMCParticleFilter+;
 #pragma link C++ class  AliAnalysisTaskTagCreator+;
 #pragma link C++ class  AliKineTrackCuts+;
index 226b6fdcf2f6104ae73b7854bf479e96c5f3d168..b390d9122100400d78b7cd604791c7bdbd204fa4 100644 (file)
@@ -1640,7 +1640,7 @@ Bool_t AliAnalysisAlien::CreateJDL()
    workdir += fGridWorkingDir;
    if (generate) {
       TObjString *os;
-      if (!fInputFiles) {
+      if (!fInputFiles && !fMCLoop) {
          Error("CreateJDL()", "Define some input files for your analysis.");
          error = kTRUE;
       }
@@ -1676,13 +1676,16 @@ Bool_t AliAnalysisAlien::CreateJDL()
       if (!fUser.IsNull()) {
          fGridJDL->SetValue("User", Form("\"%s\"", fUser.Data()));
          fMergingJDL->SetValue("User", Form("\"%s\"", fUser.Data()));
-      }   
-      fGridJDL->SetExecutable(fExecutable, "This is the startup script");
-      TString mergeExec = fExecutable;
+      }
+      TString executable = fExecutable;
+      if (!executable.BeginsWith("/")) 
+         executable.Prepend(Form("%s/", workdir.Data()));
+      fGridJDL->SetExecutable(executable, "This is the startup script");
+      TString mergeExec = executable;
       mergeExec.ReplaceAll(".sh", "_merge.sh");
       fMergingJDL->SetExecutable(mergeExec, "This is the startup script");
       mergeExec.ReplaceAll(".sh", ".C");
-      fMergingJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(),mergeExec.Data()), "List of input files to be uploaded to workers");
+      fMergingJDL->AddToInputSandbox(Form("LF:%s", mergeExec.Data()), "List of input files to be uploaded to workers");
       if (!fArguments.IsNull())
          fGridJDL->SetArguments(fArguments, "Arguments for the executable command");
       if (IsOneStageMerging()) fMergingJDL->SetArguments(fGridOutputDir);
@@ -1700,7 +1703,7 @@ Bool_t AliAnalysisAlien::CreateJDL()
          fGridJDL->SetValue("MaxInitFailed", Form("\"%d\"",fMaxInitFailed));
          fGridJDL->SetDescription("MaxInitFailed", "Maximum number of first failing jobs to abort the master job");
       }   
-      if (fSplitMaxInputFileNumber > 0) {
+      if (fSplitMaxInputFileNumber > 0 && !fMCLoop) {
          fGridJDL->SetValue("SplitMaxInputFileNumber", Form("\"%d\"", fSplitMaxInputFileNumber));
          fGridJDL->SetDescription("SplitMaxInputFileNumber", "Maximum number of input files to be processed per subjob");
       }
@@ -1739,8 +1742,10 @@ Bool_t AliAnalysisAlien::CreateJDL()
          }   
          delete arr;   
       }   
-      fGridJDL->SetInputDataListFormat(fInputFormat, "Format of input data");
-      fGridJDL->SetInputDataList("wn.xml", "Collection name to be processed on each worker node");
+      if (!fMCLoop) {
+         fGridJDL->SetInputDataListFormat(fInputFormat, "Format of input data");
+         fGridJDL->SetInputDataList("wn.xml", "Collection name to be processed on each worker node");
+      }   
       fMergingJDL->SetInputDataListFormat(fInputFormat, "Format of input data");
       fMergingJDL->SetInputDataList("wn.xml", "Collection name to be processed on each worker node");
       fGridJDL->AddToInputSandbox(Form("LF:%s/%s", workdir.Data(), fAnalysisMacro.Data()), "List of input files to be uploaded to workers");
@@ -1947,7 +1952,7 @@ Bool_t AliAnalysisAlien::WriteJDL(Bool_t copy)
 // Writes one or more JDL's corresponding to findex. If findex is negative,
 // all run numbers are considered in one go (jdl). For non-negative indices
 // they correspond to the indices in the array fInputFiles.
-   if (!fInputFiles) return kFALSE;
+   if (!fInputFiles && !fMCLoop) return kFALSE;
    TObject *os;
    TString workdir;
    if (!fProductionMode && !fGridWorkingDir.BeginsWith("/alice")) workdir = gGrid->GetHomeDirectory();
@@ -4553,6 +4558,16 @@ void AliAnalysisAlien::WriteMergingMacro()
       if (fIncludePath.Length()) out << "   gSystem->AddIncludePath(\"" << fIncludePath.Data() << "\");" << endl;
       out << "   gROOT->ProcessLine(\".include $ALICE_ROOT/include\");" << endl;
       out << "   printf(\"Include path: %s\\n\", gSystem->GetIncludePath());" << endl << endl;
+      if (fMCLoop && !fGeneratorLibs.IsNull()) {
+         out << "// MC generator libraries" << endl;
+         TObjArray *list = fGeneratorLibs.Tokenize(" ");
+         TIter next(list);
+         TObjString *str;
+         while((str=(TObjString*)next())) {
+            out << "   gSystem->Load(\"" << str->GetName() << "\");" << endl;
+         }
+         delete list;
+      }
       if (fAdditionalLibs.Length()) {
          out << "// Add aditional AliRoot libraries" << endl;
          TString additionalLibs = fAdditionalLibs;
@@ -4828,13 +4843,10 @@ void AliAnalysisAlien::WriteExecutable()
    if (copy) {
       CdWork();
       TString workdir = gGrid->GetHomeDirectory();
-      TString bindir = Form("%s/bin", workdir.Data());
-      if (!DirectoryExists(bindir)) gGrid->Mkdir(bindir,"-p");
       workdir += fGridWorkingDir;
-      TString executable = Form("%s/bin/%s", gGrid->GetHomeDirectory(), fExecutable.Data());
+      TString executable = TString::Format("%s/%s", workdir.Data(), fExecutable.Data());
       if (FileExists(executable)) gGrid->Rm(executable);
       Info("WriteExecutable", "\n#####   Copying executable file <%s> to your AliEn bin directory", fExecutable.Data());
-//      TFile::Cp(Form("file:%s",fExecutable.Data()), Form("alien://%s", executable.Data()));
       if (!copyLocal2Alien("WriteExecutable",fExecutable.Data(), 
           executable.Data())) Fatal("","Terminating");
    } 
@@ -4905,15 +4917,12 @@ void AliAnalysisAlien::WriteMergeExecutable()
    if (copy) {
       CdWork();
       TString workdir = gGrid->GetHomeDirectory();
-      TString bindir = Form("%s/bin", workdir.Data());
-      if (!DirectoryExists(bindir)) gGrid->Mkdir(bindir,"-p");
       workdir += fGridWorkingDir;
-      TString executable = Form("%s/bin/%s", gGrid->GetHomeDirectory(), mergeExec.Data());
+      TString executable = TString::Format("%s/%s", workdir.Data(), mergeExec.Data());
       if (FileExists(executable)) gGrid->Rm(executable);
       Info("WriteMergeExecutable", "\n#####   Copying executable file <%s> to your AliEn bin directory", mergeExec.Data());
-//      TFile::Cp(Form("file:%s",mergeExec.Data()), Form("alien://%s", executable.Data()));
-      if (!copyLocal2Alien("WriteMergeExecutable",
-          mergeExec.Data(), executable.Data())) Fatal("","Terminating");
+      if (!copyLocal2Alien("WriteMergeExecutable",mergeExec.Data(), 
+          executable.Data())) Fatal("","Terminating");
    } 
 }
 
index e32806b8e0bfb9917f91357e38d8382ae7402072..93cbd6e2306d9e7dcbadf93667dee2ecb4beda02 100644 (file)
@@ -329,6 +329,7 @@ Bool_t AliAnalysisManager::EventLoop(Long64_t nevents)
       ExecAnalysis();
    TList dummyList;
    PackOutput(&dummyList);
+   fIsRemote = kTRUE;
    Terminate();
    return kTRUE;
 }
@@ -445,7 +446,10 @@ Bool_t AliAnalysisManager::Init(TTree *tree)
    if (!fInitOK) return kFALSE;
    fTree = tree;
    if (fMode != kProofAnalysis) CreateReadCache();
-   fTable.Rehash(100);
+   else {
+     // cholm - here we should re-add to the table or branches 
+     fTable.Clear();
+   }
    AliAnalysisDataContainer *top = fCommonInput;
    if (!top) top = (AliAnalysisDataContainer*)fInputs->At(0);
    if (!top) {
@@ -454,6 +458,7 @@ Bool_t AliAnalysisManager::Init(TTree *tree)
    }
    top->SetData(tree);
    CheckBranches(kFALSE);
+   fTable.Rehash(100);
    if (fDebug > 1) {
       printf("<-AliAnalysisManager::Init(%s)\n", tree->GetName());
    }
@@ -1638,8 +1643,8 @@ void AliAnalysisManager::CheckBranches(Bool_t load)
             Error("CheckBranches", "Could not find branch %s",obj->GetName());
             continue;
          }
+         fTable.Add(br);
       }   
-      fTable.Add(br);
       if (load && br->GetReadEntry()!=GetCurrentEntry()) {
          br->GetEntry(GetCurrentEntry());
       }      
@@ -2845,7 +2850,7 @@ void AliAnalysisManager::ApplyDebugOptions()
 }
 
 //______________________________________________________________________________
-Bool_t AliAnalysisManager::IsMacroLoaded(const char filename)
+Bool_t AliAnalysisManager::IsMacroLoaded(const char filename)
 {
 // Check if a macro was loaded.
    return fgMacroNames.Contains(filename);
index 538e8fa99c13885038b1a75470f1093f26530111..b3ab9eb71996ed95ce0d1a5e1c26b87e7acbcc43 100644 (file)
@@ -133,7 +133,7 @@ enum EAliAnalysisFlags {
    static Int_t        GetGlobalInt(const char *key, Bool_t &valid);
    static Double_t     GetGlobalDbl(const char *key, Bool_t &valid);
    TMap               *GetGlobals()               {return fGlobals;}
-   static Bool_t       IsMacroLoaded(const char filename);
+   static Bool_t       IsMacroLoaded(const char filename);
    Bool_t              IsMCLoop() const           {return fMCLoop;}
    static Bool_t       IsPipe(std::ostream &out);
    Bool_t              IsProofMode() const        {return (fMode==kProofAnalysis)?kTRUE:kFALSE;}
index 7f6bae2200d94548dfdb49a254ff58e2f26d8fc5..f699ef145350e32ea7ea7e606dc8a7dcba0affae 100644 (file)
 #include "AliGenPythiaEventHeader.h"
 #include "AliGenCocktailEventHeader.h"
 #include "AliGenEventHeaderTunedPbPb.h"
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliAODPid.h"
+#include "AliESDpid.h"
 
 #include "AliLog.h"
 
index d47f2844d0fb5a5a728b89ad8d5f263cf565092b..99579668aea946c578f0ecb5a94684dd60aeb356 100644 (file)
@@ -18,6 +18,11 @@ class AliAODMCHeader;
 class AliMCParticle;
 class TClonesArray;
 
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliAODPid.h"
+#include "AliESDpid.h"
+
 class AliAnalysisTaskMCParticleFilter : public AliAnalysisTaskSE
 {
  public:
index 441437a871eae8d7bdc810a6344efb68bd6d8612..a9a436ff6980df5941bc235f343dbddc2a4668d9 100644 (file)
@@ -46,8 +46,8 @@ fRecoPass(0),
 fIsTunedOnData(kFALSE),
 fTunedOnDataMask(0),
 fRecoPassTuned(0),
-fUseTPCEtaCorrection(kFALSE),                 //TODO: In future, default kTRUE 
-fUseTPCMultiplicityCorrection(kFALSE),        //TODO: In future, default kTRUE  
+fUseTPCEtaCorrection(kTRUE),
+fUseTPCMultiplicityCorrection(kTRUE),
 fUserDataRecoPass(-1)
 {
   //
@@ -69,8 +69,8 @@ fRecoPass(0),
 fIsTunedOnData(kFALSE),
 fTunedOnDataMask(0),
 fRecoPassTuned(0),
-fUseTPCEtaCorrection(kFALSE),//TODO: In future, default kTRUE
-fUseTPCMultiplicityCorrection(kFALSE),//TODO: In future, default kTRUE  
+fUseTPCEtaCorrection(kTRUE),
+fUseTPCMultiplicityCorrection(kTRUE),  
 fUserDataRecoPass(-1)
 {
   //
index 94852fb7e1e16a40408983191f6572c295636b43..f1fb13eb65f9e891968d90c378aef9e267ca9de3 100644 (file)
 #include "AliLog.h"
 #include "AliVTrack.h"
 #include "AliVEvent.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
 #include "AliVTrdTrack.h"
+#include "AliESDTrdTrigger.h"
 
 #include "AliTRDTriggerAnalysis.h"
 
 AliTRDTriggerAnalysis::AliTRDTriggerAnalysis() :
   TObject(),
-  fTriggerFlags(0),
+  fTriggerFlags(),
   fTriggerInputs(0),
   fTriggerClasses(0),
+  fVerbosity(0),
   fRequireMatch(kFALSE),
-  fRequireMatchElectron(kTRUE),
-  fRequireInTime(kFALSE),
+  fRequireMatchElectron(kFALSE),
+  fRequireInTime(kTRUE),
+  fTRDlayerMaskEl(0x1),
+  fTRDnTrackletsEl(5),
   fTRDptHSE(3.),
   fTRDpidHSE(144),
   fTRDptHQU(2.),
@@ -47,6 +53,8 @@ AliTRDTriggerAnalysis::AliTRDTriggerAnalysis() :
   fTRDnHJT(3)
 {
   // ctor
+
+  memset(fTriggerFlags, 0, sizeof(fTriggerFlags));
 }
 
 AliTRDTriggerAnalysis::~AliTRDTriggerAnalysis()
@@ -54,6 +62,14 @@ AliTRDTriggerAnalysis::~AliTRDTriggerAnalysis()
   // dtor
 }
 
+void AliTRDTriggerAnalysis::ResetTriggers()
+{
+  // reset internal cache of trigger status
+
+  memset(fTriggerFlags, 0, sizeof(fTriggerFlags));
+  fTriggerInputs = fTriggerClasses = 0;
+}
+
 Bool_t AliTRDTriggerAnalysis::CalcTriggers(const AliVEvent *event)
 {
   // evaluate the TRD trigger conditions,
@@ -66,20 +82,115 @@ Bool_t AliTRDTriggerAnalysis::CalcTriggers(const AliVEvent *event)
     return kFALSE;
   }
 
-  TString trgClasses = event->GetFiredTriggerClasses();
-  // UInt_t  trgInputs  = event->GetHeader()->GetL1TriggerInputs();
+  // GTU information
+  UInt_t header = 0x0;
+
+  if (fVerbosity > 0)
+    printf("******************************************************************\n");
+  const AliESDEvent *esdEvent = dynamic_cast<const AliESDEvent*> (event);
+  if (esdEvent) {
+    AliESDTrdTrigger* trdTriggerInfo = esdEvent->GetTrdTrigger();
+
+    for (Int_t iSector = 0; iSector < 18; ++iSector) {
+      UInt_t  trgFlags = trdTriggerInfo->GetFlags(iSector);
+
+      UInt_t trgContribs = fTriggerContribs[iSector] = trgFlags & 0xfff;
+      header |= trgContribs;
+      if (fVerbosity > 0)
+       printf("sector %2i: %5s %5s %5s %5s %5s %5s %5s %5s (0x%03x)\n", iSector,
+              trgContribs & (1 << 7) ? "TO" : "--",
+              trgContribs & (1 << 6) ? "E2" : "--",
+              trgContribs & (1 << 5) ? "E1" : "--",
+              trgContribs & (1 << 4) ? "J1" : "--",
+              trgContribs & (1 << 3) ? "H2" : "--",
+              trgContribs & (1 << 2) ? "H1" : "--",
+              trgContribs & (1 << 1) ? "E3" : "--",
+              trgContribs & (1 << 0) ? "M1" : "--",
+              trgContribs);
+
+      // trackingDoneTimeSMU = ((trgFlags >> 12) & 0x3ff) * 1./120.;
+
+      // for (Int_t iStack = 0; iStack < 5; ++iStack) {
+      //   trackingDoneTMU = ((trgFlags >> 27) & (1 << iStack)) ? kTRUE : kFALSE;  // TMU-level tracking done flag
+      //   trackingDoneSMUStack = ((trgFlags >> 22) & (1 << iStack)) ? kTRUE : kFALSE;  // SMU-level stack-related tracking done flag
+
+      //   lmeFlags = trdTriggerInfo->GetLME(iStack) & 0xffffff;
+      //   crcErrorFlags = (~(trdTriggerInfo->GetLME(iStack) >> 24)) & 0x3;
+      // }
+    }
+    if (fVerbosity > 0) {
+      printf("------------------------------------------------------------------\n");
+      printf("total    : %5s %5s %5s %5s %5s %5s %5s %5s (0x%03x)\n",
+            header & (1 << 7) ? "TO" : "--",
+            header & (1 << 6) ? "E2" : "--",
+            header & (1 << 5) ? "E1" : "--",
+            header & (1 << 4) ? "J1" : "--",
+            header & (1 << 3) ? "H2" : "--",
+            header & (1 << 2) ? "H1" : "--",
+            header & (1 << 1) ? "E3" : "--",
+            header & (1 << 0) ? "M1" : "--",
+            header);
+    }
+  }
 
+  // evaluate trigger classes
+  TString trgClasses = event->GetFiredTriggerClasses();
+  if (trgClasses.Contains("TRDCO2"))
+    MarkClass(kHCO);
+  if (trgClasses.Contains("WUHJT"))
+    MarkClass(kHJT);
+  if (trgClasses.Contains("WUHSE"))
+    MarkClass(kHSE);
+  if (trgClasses.Contains("WUHQU"))
+    MarkClass(kHQU);
+  if (trgClasses.Contains("WUHEE"))
+    MarkClass(kHEE);
+
+  // evaluate trigger inputs
+  UInt_t  trgInputs = 0;
+  if (esdEvent)
+    trgInputs  = esdEvent->GetHeader()->GetL1TriggerInputs();
+  else if (const AliAODEvent *aodEvent = dynamic_cast<const AliAODEvent*> (event))
+    trgInputs  = aodEvent->GetHeader()->GetL1TriggerInputs();
+  else
+    AliError("failed to retrieve L1 trigger inputs");
+
+  if (trgInputs & (1 <<  8))
+    MarkInput(kHCO);
+  if (trgInputs & (1 <<  9))
+    MarkInput(kHJT);
+  if (trgInputs & (1 << 10))
+    MarkInput(kHSE);
+  if (trgInputs & (1 << 12))
+    MarkInput(kHQU);
+  if (trgInputs & (1 << 13))
+    MarkInput(kHEE);
+
+  // evaluate TRD GTU tracks
   Int_t nTracks[90]      = { 0 }; // stack-wise counted number of tracks above pt threshold
 
   Int_t nTrdTracks = event->GetNumberOfTrdTracks();
 
-  if (nTrdTracks > 0)
-    Fire(kHCO);
-
   for (Int_t iTrack = 0; iTrack < nTrdTracks; ++iTrack) {
     AliVTrdTrack *trdTrack = event->GetTrdTrack(iTrack);
-    if (!trdTrack)
+    if (!trdTrack) {
+      AliError(Form("Failed to get track %i", iTrack));
       continue;
+    }
+
+    Int_t globalStack = 5*trdTrack->GetSector() + trdTrack->GetStack();
+
+    MarkCondition(kHCO, globalStack);
+
+    for (Int_t iLayer = 0; iLayer < 6; ++iLayer) {
+      if (trdTrack->GetLayerMask() & (1 << iLayer)) {
+       AliVTrdTracklet *trkl = trdTrack->GetTracklet(iLayer);
+       if (!trkl) {
+         AliError(Form("no tracklet in layer %i where one should be for track %i",
+                  iLayer, iTrack));
+       }
+      }
+    }
 
     // ignore the track if it was not in time
     // (if required)
@@ -95,10 +206,8 @@ Bool_t AliTRDTriggerAnalysis::CalcTriggers(const AliVEvent *event)
     if (fRequireMatch && !match)
       continue;
 
-    Int_t globalStack = 5*trdTrack->GetSector() + trdTrack->GetStack();
-
     // stack-wise counting of tracks above pt threshold for jet trigger
-    if (TMath::Abs(trdTrack->GetPt()) >= fTRDptHJT) {
+    if (TMath::Abs(trdTrack->Pt()) >= fTRDptHJT) {
       ++nTracks[globalStack];
     }
 
@@ -108,21 +217,28 @@ Bool_t AliTRDTriggerAnalysis::CalcTriggers(const AliVEvent *event)
     if (fRequireMatchElectron && !match)
       continue;
 
-    if ((TMath::Abs(trdTrack->Pt()) > fTRDptHQU) && (trdTrack->GetPID() > fTRDpidHQU))
-      Fire(kHQU);
+    // ignore the track for the electron triggers
+    // if it does not fulfill the tracklet requirement
+    if (trdTrack->GetNTracklets() < fTRDnTrackletsEl)
+      continue;
+    if ((trdTrack->GetLayerMask() & fTRDlayerMaskEl) != fTRDlayerMaskEl)
+      continue;
+
+    if ((TMath::Abs(trdTrack->Pt()) >= fTRDptHQU) && (trdTrack->GetPID() >= fTRDpidHQU))
+      MarkCondition(kHQU, globalStack);
 
-    if ((TMath::Abs(trdTrack->Pt()) > fTRDptHSE) && (trdTrack->GetPID() > fTRDpidHSE))
-      Fire(kHSE);
+    if ((TMath::Abs(trdTrack->Pt()) >= fTRDptHSE) && (trdTrack->GetPID() >= fTRDpidHSE))
+      MarkCondition(kHSE, globalStack);
 
     if ((trdTrack->GetSector() >= fTRDminSectorHEE) && (trdTrack->GetSector() <= fTRDmaxSectorHEE) &&
-       (TMath::Abs(trdTrack->Pt()) > fTRDptHSE) && (trdTrack->GetPID() > fTRDpidHSE))
-      Fire(kHEE);
+       (TMath::Abs(trdTrack->Pt()) >= fTRDptHEE) && (trdTrack->GetPID() >= fTRDpidHEE))
+      MarkCondition(kHEE, globalStack);
   }
 
   // check if HJT condition is fulfilled in any stack
   for (Int_t iStack = 0; iStack < 90; ++iStack) {
     if (nTracks[iStack] >= fTRDnHJT) {
-      Fire(kHJT);
+      MarkCondition(kHJT, iStack);
       break;
     }
   }
index adf2ae94664a0abe8691f6b5bb857976024196e3..3156f5293cd8e1d9d9bf764a3e8b78c454d7b66f 100644 (file)
@@ -19,20 +19,69 @@ public:
   AliTRDTriggerAnalysis();
   ~AliTRDTriggerAnalysis();
 
-  enum TRDTrigger_t { kHCO = 0, kHJT, kHSE, kHQU, kHEE };
+  enum TRDTrigger_t { kHCO = 0, kHJT, kHSE, kHQU, kHEE, kHlast };
 
-  void ResetTriggers() { fTriggerFlags = fTriggerInputs = fTriggerClasses = 0; }
+  void ResetTriggers();
   Bool_t CalcTriggers(const AliVEvent* event);
 
-  Bool_t IsFired(TRDTrigger_t trg) const { return (fTriggerFlags & (1 << trg)); }
+  Bool_t IsFired(TRDTrigger_t trg) const {
+    Obsolete("IsFired(...) is deprecated, use CheckCondition instead",
+            "now", "asap");
+    return CheckCondition(trg);
+  }
+
+  Bool_t HasTriggeredConfirmed(TRDTrigger_t trg) const {
+    return (HasTriggered(trg) && CheckCondition(trg));
+  }
+  Bool_t HasTriggered(TRDTrigger_t trg) const {
+    return (fTriggerClasses & (1 << trg));
+  }
+  Bool_t HasFired(TRDTrigger_t trg) const {
+    return (fTriggerInputs & (1 << trg));
+  }
+  Bool_t CheckCondition(TRDTrigger_t trg) const {
+    return (fTriggerFlags[2 * trg] | fTriggerFlags[2 * trg + 1]);
+  }
+  Bool_t CheckCondition(TRDTrigger_t trg, Int_t stack) const {
+    Int_t idx = 2 * trg + (stack / 64);
+    Int_t bit = stack % 64;
+    return (fTriggerFlags[idx] & (1ULL << bit));
+  }
+
+  Bool_t CheckTrgFlags(Int_t bit, Int_t sector) const {
+    return (fTriggerContribs[sector] & (1 << bit));
+  }
+
+  void SetRequireMatch(Bool_t val) { fRequireMatch = val; }
+  Bool_t GetRequireMatch() const { return fRequireMatch; }
+
+  void SetRequireMatchElectron(Bool_t val) { fRequireMatchElectron = val; }
+  Bool_t GetRequireMatchElectron() const { return fRequireMatchElectron; }
+
+  void SetRequireInTime(Bool_t val) { fRequireInTime = val; }
+  Bool_t GetRequireInTime() const { return fRequireInTime; }
+
+  void SetVerbosity(UChar_t val) { fVerbosity = val; }
+  UChar_t GetVerbosity() const { return fVerbosity; }
 
 protected:
-  void Fire(TRDTrigger_t trg) { fTriggerFlags |= (1 << trg); }
+  void MarkClass(TRDTrigger_t trg) { fTriggerClasses |= (1 << trg); }
+  void MarkInput(TRDTrigger_t trg) { fTriggerInputs |= (1 << trg); }
+   void MarkCondition(TRDTrigger_t trg, Int_t stack)
+  {
+    Int_t idx = 2 * trg + (stack / 64);
+    Int_t bit = stack % 64;
+    fTriggerFlags[idx] |= (1ULL << bit);
+  }
+
+
+  static const Int_t fgkNstacks = 90; // no. of TRD stacks (global)
+  ULong64_t fTriggerFlags[2 * kHlast];   //! internal representation of condition checks
+  UChar_t fTriggerInputs;  //! internal representation of trigger inputs
+  UChar_t fTriggerClasses; //! internal representation of trigger classes
 
   // configuration
-  UChar_t fTriggerFlags;   // internal representation of trigger decisions
-  UChar_t fTriggerInputs;  // internal representation of trigger decisions
-  UChar_t fTriggerClasses; // internal representation of trigger decisions
+  UChar_t fVerbosity;      // verbosity level
   Bool_t fRequireMatch;           // require a matched global track
                           // for all conditions
   Bool_t fRequireMatchElectron;        // require a matched global track
@@ -40,6 +89,8 @@ protected:
   Bool_t fRequireInTime;       // require the tracks to be in time
 
   // trigger thresholds
+  UChar_t fTRDlayerMaskEl;      // mask for tracklet requirements
+  UChar_t fTRDnTrackletsEl;     // min. number of tracklets
   Float_t fTRDptHSE;            // pt threshold for HSE trigger
   UChar_t fTRDpidHSE;           // PID threshold for HSE trigger
   Float_t fTRDptHQU;            // pt threshold for HQU trigger
@@ -51,6 +102,8 @@ protected:
   Float_t fTRDptHJT;            // pt threshold for HJT trigger
   UChar_t fTRDnHJT;             // no of track threshold for HJT trigger
 
+  UInt_t fTriggerContribs[18]; // temporary for debugging !!!
+
   ClassDef(AliTRDTriggerAnalysis, 1);
 };
 
index ee8f339fdb354f3eff17336042e45db7e7b904fc..c3b91077bd415ec956adf4dce59e0c72f6f08388 100644 (file)
@@ -29,7 +29,6 @@
 set ( SRCS     
     AliAnalysisTaskSE.cxx 
     AliAnalysisTaskME.cxx 
-    AliAnalysisTaskESDfilter.cxx 
     AliAnalysisTaskMCParticleFilter.cxx 
     AliKineTrackCuts.cxx 
     AliESDtrackCuts.cxx 
diff --git a/ANALYSIS/CMakelibESDfilter.pkg b/ANALYSIS/CMakelibESDfilter.pkg
new file mode 100644 (file)
index 0000000..439b11c
--- /dev/null
@@ -0,0 +1,39 @@
+# -*- mode: Makefile -*-
+#--------------------------------------------------------------------------------#
+# Package File for PWGmuon                                                      #
+# Author : Johny Jose (johny.jose@cern.ch)                                       #
+# Variables Defined :                                                            #
+#                                                                                #
+# SRCS - C++ source files                                                        #
+# HDRS - C++ header files                                                        #
+# DHDR - ROOT Dictionary Linkdef header file                                     #
+# CSRCS - C source files                                                         #
+# CHDRS - C header files                                                         #
+# EINCLUDE - Include directories                                                 #
+# EDEFINE - Compiler definitions                                                 #
+# ELIBS - Extra libraries to link                                                #
+# ELIBSDIR - Extra library directories                                           #
+# PACKFFLAGS - Fortran compiler flags for package                                #
+# PACKCXXFLAGS - C++ compiler flags for package                                  #
+# PACKCFLAGS - C compiler flags for package                                      #
+# PACKSOFLAGS - Shared library linking flags                                     #
+# PACKLDFLAGS - Module linker flags                                              #
+# PACKBLIBS - Libraries to link (Executables only)                               #
+# EXPORT - Header files to be exported                                           #
+# CINTHDRS - Dictionary header files                                             #
+# CINTAUTOLINK - Set automatic dictionary generation                             #
+# ARLIBS - Archive Libraries and objects for linking (Executables only)          #
+# SHLIBS - Shared Libraries and objects for linking (Executables only)           #
+#--------------------------------------------------------------------------------#
+
+set ( SRCS 
+    ESDfilter/AliAnalysisTaskESDfilter.cxx
+)
+
+string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
+
+string ( REPLACE ".cxx" ".h" EXPORT "${SRCS}" )
+
+set ( DHDR  ESDfilterLinkDef.h)
+
+set ( EINCLUDE ANALYSIS/ESDfilter EMCAL OADB STEER/AOD STEER/ESD STEER/STEERBase ANALYSIS)
similarity index 98%
rename from ANALYSIS/AliAnalysisTaskESDfilter.cxx
rename to ANALYSIS/ESDfilter/AliAnalysisTaskESDfilter.cxx
index dd1e8bc23646f6437484fcec68729f7e310f626c..3ccdef218a0cd6c74a7228e907974e9ce12edc93 100644 (file)
@@ -15,6 +15,7 @@
 
 /* $Id$ */
  
+#include <Riostream.h>
 #include <TChain.h>
 #include <TTree.h>
 #include <TList.h>
@@ -23,6 +24,7 @@
 #include <TRandom.h>
 #include <TParticle.h>
 #include <TFile.h>
+#include <TVector3.h>
 
 #include "AliAnalysisTaskESDfilter.h"
 #include "AliAnalysisManager.h"
 #include "AliAODHMPIDrings.h"
 #include "AliV0vertexer.h"
 #include "AliCascadeVertexer.h"
-#include "Riostream.h"
 #include "AliExternalTrackParam.h"
 #include "AliTrackerBase.h"
-#include "TVector3.h"
 #include "AliTPCdEdxInfo.h"
 
 #include "AliESDTrdTrack.h"
 #include "AliESDTrdTracklet.h"
 #include "AliAODTrdTrack.h"
 #include "AliAODTrdTracklet.h"
+#include "AliEMCALRecoUtils.h"
 
 using std::cout;
 using std::endl;
@@ -995,6 +996,7 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
            aodTrack->SetTPCNCrossedRows(UShort_t(esdV0Pos->GetTPCCrossedRows()));
            aodTrack->SetIntegratedLength(esdV0Pos->GetIntegratedLength());
            aodTrack->SetTOFLabel(tofLabel);
+           CopyCaloProps(esdV0Pos,aodTrack);
            fAODTrackRefs->AddAt(aodTrack,posFromV0);
            //      if (fDebug > 0) printf("-------------------Bo: pos track from original pt %.3f \n",aodTrack->Pt());
            if (esdV0Pos->GetSign() > 0) ++fNumberOfPositiveTracks;
@@ -1044,6 +1046,7 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
            aodTrack->SetTPCNCrossedRows(UShort_t(esdV0Neg->GetTPCCrossedRows()));
            aodTrack->SetIntegratedLength(esdV0Neg->GetIntegratedLength());
            aodTrack->SetTOFLabel(tofLabel);
+           CopyCaloProps(esdV0Neg,aodTrack);
            fAODTrackRefs->AddAt(aodTrack,negFromV0);
            //      if (fDebug > 0) printf("-------------------Bo: neg track from original pt %.3f \n",aodTrack->Pt());
            if (esdV0Neg->GetSign() > 0) ++fNumberOfPositiveTracks;
@@ -1255,10 +1258,8 @@ void AliAnalysisTaskESDfilter::ConvertTPCOnlyTracks(const AliESDEvent& esd)
     aodTrack->SetTPCNCrossedRows(UShort_t(track->GetTPCCrossedRows()));
     aodTrack->SetIntegratedLength(track->GetIntegratedLength());
     aodTrack->SetTOFLabel(tofLabel);
-    //Perform progagation of tracks if needed
-    if(fDoPropagateTrackToEMCal) PropagateTrackToEMCal(esdTrack);
-    aodTrack->SetTrackPhiEtaPtOnEMCal(esdTrack->GetTrackPhiOnEMCal(),esdTrack->GetTrackEtaOnEMCal(),esdTrack->GetTrackPtOnEMCal());
-
+    CopyCaloProps(track,aodTrack);
+  
     // do not duplicate PID information 
     //    aodTrack->ConvertAliPIDtoAODPID();
     //    SetAODPID(esdTrack,aodTrack,detpid);
@@ -1394,27 +1395,22 @@ void AliAnalysisTaskESDfilter::ConvertGlobalConstrainedTracks(const AliESDEvent&
     aodTrack->SetTPCClusterMap(esdTrack->GetTPCClusterMap());
     aodTrack->SetTPCSharedMap (esdTrack->GetTPCSharedMap());
     aodTrack->SetChi2perNDF(Chi2perNDF(esdTrack));
-    
 
     // set the DCA values to the AOD track
     aodTrack->SetPxPyPzAtDCA(pDCA[0],pDCA[1],pDCA[2]);
     aodTrack->SetXYAtDCA(rDCA[0],rDCA[1]);
     aodTrack->SetDCA(dDCA[0],dDCA[1]);
-
     aodTrack->SetFlags(esdTrack->GetStatus());
     aodTrack->SetTPCPointsF(esdTrack->GetTPCNclsF());
     aodTrack->SetTPCNCrossedRows(UShort_t(esdTrack->GetTPCCrossedRows()));
     aodTrack->SetIntegratedLength(esdTrack->GetIntegratedLength());
     aodTrack->SetTOFLabel(tofLabel);
+    CopyCaloProps(esdTrack,aodTrack);
     if(isHybridGC){
       // only copy AOD information for hybrid, no duplicate information
       aodTrack->ConvertAliPIDtoAODPID();
       SetAODPID(esdTrack,aodTrack,detpid);
     }
-
-    //Perform progagation of tracks if needed
-    if(fDoPropagateTrackToEMCal) PropagateTrackToEMCal(esdTrack);
-    aodTrack->SetTrackPhiEtaPtOnEMCal(esdTrack->GetTrackPhiOnEMCal(),esdTrack->GetTrackEtaOnEMCal(),esdTrack->GetTrackPtOnEMCal());
   } // end of loop on tracks
   
 }
@@ -1484,16 +1480,10 @@ void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)
     aodTrack->SetTPCNCrossedRows(UShort_t(esdTrack->GetTPCCrossedRows()));
     aodTrack->SetIntegratedLength(esdTrack->GetIntegratedLength());
     aodTrack->SetTOFLabel(tofLabel);
-    if(esdTrack->IsEMCAL()) aodTrack->SetEMCALcluster(esdTrack->GetEMCALcluster());
-    if(esdTrack->IsPHOS())  aodTrack->SetPHOScluster(esdTrack->GetPHOScluster());
-
-    //Perform progagation of tracks if needed
-    if(fDoPropagateTrackToEMCal) PropagateTrackToEMCal(esdTrack);
-    aodTrack->SetTrackPhiEtaPtOnEMCal(esdTrack->GetTrackPhiOnEMCal(),esdTrack->GetTrackEtaOnEMCal(),esdTrack->GetTrackPtOnEMCal());
+    CopyCaloProps(esdTrack,aodTrack);
 
     fAODTrackRefs->AddAt(aodTrack, nTrack);
     
-    
     if (esdTrack->GetSign() > 0) ++fNumberOfPositiveTracks;
     aodTrack->SetFlags(esdTrack->GetStatus());
     aodTrack->ConvertAliPIDtoAODPID();
@@ -1501,32 +1491,6 @@ void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)
   } // end of loop on tracks
 }
 
-//______________________________________________________________________________
-void AliAnalysisTaskESDfilter::PropagateTrackToEMCal(AliESDtrack *esdTrack)
-{
-  Double_t trkPos[3] = {0.,0.,0.};
-  Double_t EMCalEta=-999, EMCalPhi=-999, EMCalPt=-999;
-  Double_t trkphi = esdTrack->Phi()*TMath::RadToDeg();
-  if(TMath::Abs(esdTrack->Eta())<0.9 && trkphi > 10 && trkphi < 250 )
-    {
-      AliExternalTrackParam *trkParam = const_cast<AliExternalTrackParam*>(esdTrack->GetInnerParam());
-      if(trkParam)
-       {
-         AliExternalTrackParam trkParamTmp(*trkParam);
-         if(AliTrackerBase::PropagateTrackToBxByBz(&trkParamTmp, fEMCalSurfaceDistance, esdTrack->GetMass(), 20, kTRUE, 0.8, -1))
-           {
-             trkParamTmp.GetXYZ(trkPos);
-             TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
-             EMCalEta = trkPosVec.Eta();
-             EMCalPhi = trkPosVec.Phi();
-             EMCalPt = trkParamTmp.Pt();
-             if(EMCalPhi<0)  EMCalPhi += 2*TMath::Pi();
-             esdTrack->SetTrackPhiEtaPtOnEMCal(EMCalPhi,EMCalEta,EMCalPt);
-           }
-       }
-    }
-}
-
 //______________________________________________________________________________
 void AliAnalysisTaskESDfilter::ConvertPmdClusters(const AliESDEvent& esd)
 {
@@ -1869,6 +1833,7 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
            mother->SetTPCNCrossedRows(UShort_t(esdTrackM->GetTPCCrossedRows()));
            mother->SetIntegratedLength(esdTrackM->GetIntegratedLength());
            mother->SetTOFLabel(tofLabel);
+           CopyCaloProps(esdTrackM,mother);
             fAODTrackRefs->AddAt(mother, imother);
             
             if (esdTrackM->GetSign() > 0) ++fNumberOfPositiveTracks;
@@ -1936,6 +1901,7 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
            daughter->SetTPCNCrossedRows(UShort_t(esdTrackD->GetTPCCrossedRows()));
            daughter->SetIntegratedLength(esdTrackD->GetIntegratedLength());
            daughter->SetTOFLabel(tofLabel);
+           CopyCaloProps(esdTrackD,daughter);
             fAODTrackRefs->AddAt(daughter, idaughter);
             
             if (esdTrackD->GetSign() > 0) ++fNumberOfPositiveTracks;
@@ -2286,7 +2252,8 @@ void AliAnalysisTaskESDfilter::ConvertTRD(const AliESDEvent& esd)
          aodTrkMatch->SetTPCPointsF(esdTrkMatch->GetTPCNclsF());
          aodTrkMatch->SetTPCNCrossedRows(UShort_t(esdTrkMatch->GetTPCCrossedRows()));
          aodTrkMatch->SetIntegratedLength(esdTrkMatch->GetIntegratedLength());
-         fAODTrackRefs->AddAt(aodTrkMatch,idx);
+         CopyCaloProps(esdTrkMatch,aodTrkMatch);
+         fAODTrackRefs->AddAt(aodTrkMatch,idx);
          if (esdTrkMatch->GetSign() > 0) ++fNumberOfPositiveTracks;
          aodTrkMatch->ConvertAliPIDtoAODPID();
          aodTrkMatch->SetFlags(esdTrkMatch->GetStatus());
@@ -2326,6 +2293,14 @@ void AliAnalysisTaskESDfilter::ConvertESDtoAOD()
     lCascVtxer.V0sTracks2CascadeVertices(esd);
   }
 
+  // Perform progagation of tracks if needed
+  if (fDoPropagateTrackToEMCal) {
+    const Int_t ntrack = esd->GetNumberOfTracks();
+    for (Int_t i=0;i<ntrack;++i) {
+      AliESDtrack *t = esd->GetTrack(i);
+      AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(t,fEMCalSurfaceDistance);
+    }
+  }
  
   fNumberOfTracks = 0;
   fNumberOfPositiveTracks = 0;
@@ -2642,5 +2617,16 @@ void  AliAnalysisTaskESDfilter::PrintMCInfo(AliStack *pStack,Int_t label){
   Printf("########################");
 }
 
-//______________________________________________________
+//______________________________________________________________________________
+void  AliAnalysisTaskESDfilter::CopyCaloProps(AliESDtrack *tre, AliAODTrack *tra) {
+  //Copy calo properties from ESD track to AOD track
+
+  tra->SetTrackPhiEtaPtOnEMCal(tre->GetTrackPhiOnEMCal(),tre->GetTrackEtaOnEMCal(),tre->GetTrackPtOnEMCal());
+  if(tre->IsEMCAL()) tra->SetEMCALcluster(tre->GetEMCALcluster());
+  if(tre->IsPHOS())  tra->SetPHOScluster(tre->GetPHOScluster());
+
+}
+
+//______________________________________________________________________________
+
 
similarity index 99%
rename from ANALYSIS/AliAnalysisTaskESDfilter.h
rename to ANALYSIS/ESDfilter/AliAnalysisTaskESDfilter.h
index 7a32eae03cf77d3204bea6f25ea5e99fcc59676d..6a4832141d9c50b7120264055975b5f64c706211 100644 (file)
@@ -117,7 +117,7 @@ private:
   void ConvertZDC(const AliESDEvent& esd);
   Int_t ConvertHMPID(const AliESDEvent& esd);
   void ConvertTRD(const AliESDEvent& esd);
-  void PropagateTrackToEMCal(AliESDtrack *esdTrack);
+  void CopyCaloProps(AliESDtrack *esdt, AliAODTrack *aodt);
 
   TClonesArray& Tracks();
   TClonesArray& V0s();
diff --git a/ANALYSIS/ESDfilterLinkDef.h b/ANALYSIS/ESDfilterLinkDef.h
new file mode 100644 (file)
index 0000000..920f3cf
--- /dev/null
@@ -0,0 +1,9 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliAnalysisTaskESDfilter+;
+
+#endif
index f3654622a6fb7e6c3535223c1b01386676a0500f..6cfd8a3de1bc40f99a5d4f4562dfcb4e6b18e756 100644 (file)
@@ -16,9 +16,9 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
-// TOF tender: - load updated calibrations (for TOF and T0)
-//             - set tofHeader if missing in ESDs (2010 data)
-//             - re-apply PID 
+// TOF tender: for a description of what this tender does see
+//             https://twiki.cern.ch/twiki/bin/viewauth/ALICE/TOF
+//             It has to be used on LHC2010 data (and old MC productions)
 //             
 // Contacts: Pietro.Antonioli@bo.infn.it                                     //
 //           Francesco.Noferini@bo.infn.it                                   //
@@ -171,6 +171,7 @@ void AliTOFTenderSupply::Init()
       fLHC10dPatch=kFALSE;
       fT0IntercalibrationShift = 0;
       fT0DetectorAdjust=kFALSE;   // it was kTRUE
+      if (fIsMC) fT0DetectorAdjust=kTRUE;   // this will add smearing because LHC10b doesn't have start_time simulated
     }
     else if (run>=118503&&run<=121040) { //period="LHC10C";
       if (fRecoPass == 2) {fCorrectExpTimes=kTRUE; fCorrectTRDBug=kFALSE;}
@@ -178,18 +179,26 @@ void AliTOFTenderSupply::Init()
       fLHC10dPatch=kFALSE;
       fT0IntercalibrationShift = 0;
       fT0DetectorAdjust=kFALSE;
+      if (fIsMC) fT0DetectorAdjust=kTRUE;   // this will add smearing because LHC10b doesn't have start_time simulated
     }
     else if (run>=122195&&run<=126437) { //period="LHC10D";
-      fCorrectExpTimes=kFALSE;
-      fLHC10dPatch=kTRUE;
+      if (!fIsMC) {
+        fCorrectExpTimes=kFALSE;
+        fLHC10dPatch=kTRUE;
+      } else {
+        fCorrectExpTimes=kTRUE;    // for old MC the expected times bug was there
+        fLHC10dPatch=kFALSE;       // but not the fake geometry
+      }
       fT0IntercalibrationShift = 0;
       fT0DetectorAdjust=kFALSE;     // it was kTRUE
+      if (fIsMC) fT0DetectorAdjust=kTRUE;
     }
     else if (run>=127719&&run<=130850) { //period="LHC10E";
       fCorrectExpTimes=kFALSE;
       fLHC10dPatch=kFALSE;
       fT0IntercalibrationShift = 30.;
       fT0DetectorAdjust=kFALSE;      // it was kTRUE
+      if (fIsMC) fT0DetectorAdjust=kTRUE;
     }
     else if (run>=133004&&run<=135029) { //period="LHC10F";
       fTenderNoAction=kTRUE;
@@ -254,7 +263,7 @@ void AliTOFTenderSupply::Init()
   AliInfo(Form("|    LHC10d patch                   :  %d               |",fLHC10dPatch));
   AliInfo(Form("|    TOF resolution for TOFT0 maker :  %5.2f (ps)     |",fTOFPIDParams->GetTOFresolution()));
   AliInfo(Form("|    MC flag                        :  %d               |",fIsMC));
-  //  AliInfo(Form("|    T0 detector offsets applied    :  %d               |",fT0DetectorAdjust));
+  AliInfo(Form("|    T0 detector offsets applied    :  %d               |",fT0DetectorAdjust));
   //  AliInfo(Form("|    TOF/T0 intercalibration shift   :  %5.2f (ps)     |",fT0IntercalibrationShift));
   AliInfo("|******************************************************|");
 
@@ -279,6 +288,7 @@ void AliTOFTenderSupply::ProcessEvent()
   if (fTender->RunChanged()){ 
 
     Init();
+
     if (fTenderNoAction) return;            
     Int_t versionNumber = GetOCDBVersion(fTender->GetRun());
     fTOFCalib->SetRunParamsSpecificVersion(versionNumber);
index 5c8b2743e8129853f819ee1cabab4e19ba3ff89b..8b83a53edd8e8173794be5314269d33bba9631ef 100644 (file)
@@ -611,7 +611,7 @@ Bool_t AliTRDTenderSupply::GetTRDchamberID(AliESDtrack * const track, Int_t *det
     Double_t secAlpha = 2 * TMath::Pi() / 18.;
    
     Int_t sector = static_cast<Int_t>(trackAlpha/secAlpha);
-
+/*
     if(fDebugMode){
       // Compare to simple propagation without magnetic field
       AliExternalTrackParam workparam1(*trueparam); // Do calculation on working Copy
@@ -629,7 +629,7 @@ Bool_t AliTRDTenderSupply::GetTRDchamberID(AliESDtrack * const track, Int_t *det
       AliDebug(2, Form("Alpha: Old %f, New %f, diff %f", trackAlpha, trackAlpha1, trackAlpha-trackAlpha1));
       AliDebug(2, Form("Sector: Old %d, New %d", sector, sector1));
     }
-
+*/
     Double_t etaTrack = track->Eta();
     Int_t stack = -1;
     for(Int_t istack = 0; istack < 5; istack++){
index aeb24963cd943c89f6617c2f887110bf9e029abe..52d4452531456fef3f95e7759e95a1b279bba5c9 100644 (file)
@@ -17,6 +17,10 @@ AliCentralitySelectionTask *AddTaskCentrality(Bool_t fillHistos=kTRUE, Bool_t ao
     ::Error("AddTaskCentrality", "This task works only on ESD analysis");
     return NULL;
   }
+  //
+  AliInputEventHandler* hdl = (AliInputEventHandler*)mgr->GetInputEventHandler();
+  if (hdl) hdl->SetNeedField(); 
+  //
   AliCentralitySelectionTask *centralityTask = new AliCentralitySelectionTask("CentralitySelection");
   centralityTask->SetInput(inputDataType);
   centralityTask->SelectCollisionCandidates(AliVEvent::kAny);
index 9ce86fd4d28be304cdf149c366d15ac9791fa0f3..be2ae89988ee3a632729760d21c39be702f6c55b 100644 (file)
@@ -1,9 +1,9 @@
 AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
                                     Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
                                     Bool_t cachePID=kFALSE, TString detResponse="",
-                                    Bool_t useTPCEtaCorrection = kTRUE,
-                                    Bool_t useTPCMultiplicityCorrection = kFALSE,
-                                   Int_t  recoDataPass = -1)
+                                    Bool_t useTPCEtaCorrection = kTRUE,/*Please use default value! Otherwise splines can be off*/
+                                    Bool_t useTPCMultiplicityCorrection = kTRUE,/*Please use default value! Otherwise splines can be off*/
+                                    Int_t  recoDataPass = -1)
 {
 // Macro to connect a centrality selection task to an existing analysis manager.
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
diff --git a/ANALYSIS/macros/train/AddMCGenHijing.C b/ANALYSIS/macros/train/AddMCGenHijing.C
new file mode 100644 (file)
index 0000000..9e00550
--- /dev/null
@@ -0,0 +1,34 @@
+AliGenerator *AddMCGenHijing()
+{  
+// User defined generator  
+  gSystem->Load("liblhapdf.so");      // Parton density functions
+  gSystem->Load("libEGPythia6.so");   // TGenerator interface
+  gSystem->Load("libpythia6.so");     // Pythia
+  gSystem->Load("libAliPythia6.so");  // ALICE specific implementations
+  gSystem->Load("libhijing");       
+  gSystem->Load("libTHijing");
+  AliGenHijing* gener = new AliGenHijing(-1);
+  // centre of mass energy 
+  gener->SetEnergyCMS(2760.);
+  gener->SetImpactParameterRange(0, 20);  
+  // reference frame
+  gener->SetReferenceFrame("CMS");
+  // projectile
+  gener->SetProjectile("A", 208, 82);
+  gener->SetTarget    ("A", 208, 82);
+  // tell hijing to keep the full parent child chain
+  gener->KeepFullEvent();
+
+  // enable shadowing
+  gener->SetShadowing(1);
+  // Don't track spectators
+  gener->SetSpectators(0);
+  // kinematic selection
+  gener->SetSelectAll(0);   
+
+  gener->SetJetQuenching(0);   
+  gener->SetPtHardMin (2.3);
+  return gener;
+}
+  
+  
diff --git a/ANALYSIS/macros/train/AddMCGeneratorHandler.C b/ANALYSIS/macros/train/AddMCGeneratorHandler.C
new file mode 100644 (file)
index 0000000..73c1333
--- /dev/null
@@ -0,0 +1,35 @@
+void AddMCGeneratorHandler()
+{
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) ::Fatal("handlers", "No analysis manager");
+  AliAnalysisAlien *plugin = (AliAnalysisAlien*)mgr->GetGridHandler();
+  if (!plugin) ::Fatal("handlers", "The method should be called via: AliAnalysisAlien::CreateAnalysisManager()");
+  mgr->SetInputEventHandler(new AliDummyHandler());
+  AliMCGenHandler* mcInputHandler = new AliMCGenHandler();
+
+  TString macroPath;
+  macroPath.Form("$ALICE_ROOT/%s", gSystem->Getenv("GEN_MACRO_PATH"));
+  macroPath = gSystem->ExpandPathName(macroPath.Data());
+
+  TString macroParameters(gSystem->Getenv("GEN_PARAMETERS"));
+
+  TString newlibs;
+  Long64_t retval = AliAnalysisAlien::RunMacroAndExtractLibs(macroPath, macroParameters, newlibs);
+  if (retval<0) {
+    ::Error(Form("The macro %s did not return a valid generator", macroPath.Data()));
+    return;
+  }
+  AliGenerator *gener = reinterpret_cast<AliGenerator*>(retval);
+
+  // customization from LEGO train
+  gROOT->LoadMacro("generator_customization.C");
+  generator_customization(gener);
+
+  mcInputHandler->SetGenerator(gener);
+  mcInputHandler->SetSeedMode(3);
+
+  newlibs += " ";
+  newlibs += gSystem->Getenv("GEN_LIBRARIES");
+  plugin->SetGeneratorLibs(newlibs);
+  mgr->SetMCtruthEventHandler(mcInputHandler);
+}
index 45182fc645cf5ce0ed9217b2ce183c8060f7a7da..decf52ea6941d736cc37848b8943abf6856c9075 100644 (file)
@@ -178,14 +178,23 @@ set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
 #If the sources were taken from Git
 if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
  include(GetGitRevisionDescription)
  find_package(Git)
  if(GIT_FOUND)
   get_git_head_revision(GIT_REFSPEC GIT_SHA1)
-  message(STATUS "Aliroot Revision - ${GIT_SHA1} Branch - ${GIT_REFSPEC}")
+  message(STATUS "Aliroot branch - ${GIT_REFSPEC} Revision - ${GIT_SHA1} ")
+
+  STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
+  
+  if(BRANCH_TYPE STREQUAL "heads")
+   set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
+  else()
+   set(ALIROOT_REVISION ${GIT_SHA1})
+  endif()
 
   STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
 
-  set(ALIROOT_REVISION ${GIT_SHA1})
   set(ALIROOT_BRANCH ${SHORT_BRANCH})
 
  else()
@@ -231,8 +240,7 @@ add_custom_command(TARGET htmldoc
                   COMMAND mkdir -p html
                   COMMAND rm -rf html/roothtml
                   COMMAND rm -f html/picts
-                  COMMAND cd html &&
-                           aliroot -q -b \"mkhtml.C(0,1)\"
+                  COMMAND cd html && aliroot -q -b mkhtml.C\\\(0,1\\\)
                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
 # Include Vc, which provides the static libVc and the relevant CMake macros
@@ -406,7 +414,7 @@ COMMAND @echo "the AliRoot one." >> ${ALIMDCSPECFILE}
 COMMAND @echo "" >> ${ALIMDCSPECFILE}
 COMMAND @echo '\# list of files to be installed' >> ${ALIMDCSPECFILE}
 COMMAND @echo "%files" >> ${ALIMDCSPECFILE}
-COMMAND @echo '%defattr (-,root,root)' >> ${ALIMDCSPECFILE}
+COMMAND @echo "%defattr (-,root,root)" >> ${ALIMDCSPECFILE}
 COMMAND @echo "%{prefix}/lib/libAliMDC.a" >> ${ALIMDCSPECFILE}
 COMMAND @echo "%{prefix}/lib/libRoot.a" >> ${ALIMDCSPECFILE}
 COMMAND @echo "%{prefix}/lib/libpcre.a" >> ${ALIMDCSPECFILE}
index 8a6751492ca8523c876395a84607abfca96a86e0..066ab29c97b025bad50ed767447896b67a435de9 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id: AliEMCALRecoUtils.cxx 33808 2009-07-15 09:48:08Z gconesab $ */
+/* $Id: AliEMCALRecoUtils.cxx | Sun Dec 8 06:56:48 2013 +0100 | Constantin Loizides  $ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //
@@ -332,7 +332,7 @@ AliEMCALRecoUtils::~AliEMCALRecoUtils()
 }
 
 //_______________________________________________________________________________
-Bool_t AliEMCALRecoUtils::AcceptCalibrateCell(const Int_t absID, const Int_t bc,
+Bool_t AliEMCALRecoUtils::AcceptCalibrateCell(Int_t absID, Int_t bc,
                                               Float_t  & amp,    Double_t & time, 
                                               AliVCaloCells* cells) 
 {
@@ -461,7 +461,7 @@ Bool_t AliEMCALRecoUtils::CheckCellFiducialRegion(const AliEMCALGeometry* geom,
 //_______________________________________________________________________________
 Bool_t AliEMCALRecoUtils::ClusterContainsBadChannel(const AliEMCALGeometry* geom, 
                                                     const UShort_t* cellList, 
-                                                    const Int_t nCells)
+                                                    Int_t nCells)
 {
   // Check that in the cluster cells, there is no bad channel of those stored 
   // in fEMCALBadChannelMap or fPHOSBadChannelMap
@@ -492,8 +492,8 @@ Bool_t AliEMCALRecoUtils::ClusterContainsBadChannel(const AliEMCALGeometry* geom
 
 
 //___________________________________________________________________________
-Float_t AliEMCALRecoUtils::GetECross(const Int_t absID, const Double_t tcell,
-                                     AliVCaloCells* cells, const Int_t bc)
+Float_t AliEMCALRecoUtils::GetECross(Int_t absID, Double_t tcell,
+                                     AliVCaloCells* cells, Int_t bc)
 {
   //Calculate the energy in the cross around the energy given cell
   
@@ -568,7 +568,7 @@ Float_t AliEMCALRecoUtils::GetECross(const Int_t absID, const Double_t tcell,
 }
 
 //_____________________________________________________________________________________________
-Bool_t AliEMCALRecoUtils::IsExoticCell(const Int_t absID, AliVCaloCells* cells, const Int_t bc)
+Bool_t AliEMCALRecoUtils::IsExoticCell(Int_t absID, AliVCaloCells* cells, Int_t bc)
 {
   // Look to cell neighbourhood and reject if it seems exotic
   // Do before recalibrating the cells
@@ -598,7 +598,7 @@ Bool_t AliEMCALRecoUtils::IsExoticCell(const Int_t absID, AliVCaloCells* cells,
 //___________________________________________________________________
 Bool_t AliEMCALRecoUtils::IsExoticCluster(const AliVCluster *cluster, 
                                           AliVCaloCells *cells, 
-                                          const Int_t bc) 
+                                          Int_t bc) 
 {
   // Check if the cluster highest energy tower is exotic
   
@@ -873,9 +873,9 @@ void AliEMCALRecoUtils::InitNonLinearityParam()
 }
 
 //_________________________________________________________
-Float_t  AliEMCALRecoUtils::GetDepth(const Float_t energy, 
-                                     const Int_t iParticle, 
-                                     const Int_t iSM) const 
+Float_t  AliEMCALRecoUtils::GetDepth(Float_t energy, 
+                                     Int_t iParticle, 
+                                     Int_t iSM) const 
 {
   //Calculate shower depth for a given cluster energy and particle type
 
@@ -1175,7 +1175,7 @@ void AliEMCALRecoUtils::InitEMCALBadChannelStatusMap()
 void AliEMCALRecoUtils::RecalibrateClusterEnergy(const AliEMCALGeometry* geom, 
                                                  AliVCluster * cluster, 
                                                  AliVCaloCells * cells, 
-                                                 const Int_t bc)
+                                                 Int_t bc)
 {
   // Recalibrate the cluster energy and Time, considering the recalibration map 
   // and the energy of the cells and time that compose the cluster.
@@ -1248,7 +1248,7 @@ void AliEMCALRecoUtils::RecalibrateClusterEnergy(const AliEMCALGeometry* geom,
 
 //_____________________________________________________________
 void AliEMCALRecoUtils::RecalibrateCells(AliVCaloCells * cells,
-                                         const Int_t bc)
+                                         Int_t bc)
 {
   // Recalibrate the cells time and energy, considering the recalibration map and the energy 
   // of the cells that compose the cluster.
@@ -1291,7 +1291,7 @@ void AliEMCALRecoUtils::RecalibrateCells(AliVCaloCells * cells,
 }
 
 //_______________________________________________________________________________________________________
-void AliEMCALRecoUtils::RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & celltime) const
+void AliEMCALRecoUtils::RecalibrateCellTime(Int_t absId, Int_t bc, Double_t & celltime) const
 {
   // Recalibrate time of cell with absID  considering the recalibration map 
   // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
@@ -1829,19 +1829,7 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
   // init the magnetic field if not already on
   if(!TGeoGlobalMagField::Instance()->GetField())
   {
-    AliInfo("Init the magnetic field\n");
-    if     (esdevent) 
-    {
-      esdevent->InitMagneticField();
-    }
-    else if(aodevent)
-    {
-      Double_t curSol = 30000*aodevent->GetMagneticField()/5.00668;
-      Double_t curDip = 6000 *aodevent->GetMuonMagFieldScale();
-      AliMagF *field  = AliMagF::CreateFieldMap(curSol,curDip);
-      TGeoGlobalMagField::Instance()->SetField(field);
-    }
-    else
+    if (!event->InitMagneticField())
     {
       AliInfo("Mag Field not initialized, null esd/aod evetn pointers");
     }
@@ -1862,16 +1850,16 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
   }
 
   TObjArray *clusterArray = 0x0;
-  if(!clusterArr)
-    {
-      clusterArray = new TObjArray(event->GetNumberOfCaloClusters());
-      for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++)
+  if(!clusterArr) 
   {
-    AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
-    if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;
-    clusterArray->AddAt(cluster,icl);
-  }
+    clusterArray = new TObjArray(event->GetNumberOfCaloClusters());
+    for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++) 
+    {
+      AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
+      if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;
+      clusterArray->AddAt(cluster,icl);
     }
+  }
   
   Int_t    matched=0;
   Double_t cv[21];
@@ -1937,10 +1925,10 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
     {
       printf("Wrong input data type! Should be \"AOD\" or \"ESD\"\n");
       if(clusterArray)
-  {
-    clusterArray->Clear();
-    delete clusterArray;
-  }
+      {
+       clusterArray->Clear();
+       delete clusterArray;
+      }
       return;
     }
     
@@ -1950,36 +1938,30 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
     AliExternalTrackParam emcalParam(*trackParam);
     Float_t eta, phi, pt;
     if(!ExtrapolateTrackToEMCalSurface(&emcalParam, fEMCalSurfaceDistance, fMass, fStepSurface, eta, phi, pt)) 
-      {
-  if(aodevent && trackParam) delete trackParam;
-  if(fITSTrackSA && trackParam) delete trackParam;
-  continue;
-      }
-
-//    if(esdevent)
-//      {
-//  esdTrack->SetOuterParam(&emcalParam,AliExternalTrackParam::kMultSec);
-//      }
+    {
+      if(aodevent && trackParam) delete trackParam;
+      if(fITSTrackSA && trackParam) delete trackParam;
+      continue;
+    }
 
     if(TMath::Abs(eta)>0.75 || (phi) < 70*TMath::DegToRad() || (phi) > 190*TMath::DegToRad())
-      {
-  if(aodevent && trackParam) delete trackParam;
-  if(fITSTrackSA && trackParam) delete trackParam;
-  continue;
-      }
-
+    {
+      if(aodevent && trackParam) delete trackParam;
+      if(fITSTrackSA && trackParam) delete trackParam;
+      continue;
+    }
 
     //Find matched clusters
     Int_t index = -1;
     Float_t dEta = -999, dPhi = -999;
     if(!clusterArr)
-      {
-  index = FindMatchedClusterInClusterArr(&emcalParam, &emcalParam, clusterArray, dEta, dPhi);  
-      }
+    {
+      index = FindMatchedClusterInClusterArr(&emcalParam, &emcalParam, clusterArray, dEta, dPhi);  
+    } 
     else
-      {
-  index = FindMatchedClusterInClusterArr(&emcalParam, &emcalParam, clusterArr, dEta, dPhi);  
-      }  
+    {
+      index = FindMatchedClusterInClusterArr(&emcalParam, &emcalParam, clusterArr, dEta, dPhi);  
+    }  
     
     if(index>-1)
     {
@@ -1994,10 +1976,10 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
   }//track loop
 
   if(clusterArray)
-    {
-      clusterArray->Clear();
-      delete clusterArray;
-    }
+  {
+    clusterArray->Clear();
+    delete clusterArray;
+  }
   
   AliDebug(2,Form("Number of matched pairs = %d !\n",matched));
   
@@ -2073,43 +2055,43 @@ Int_t  AliEMCALRecoUtils::FindMatchedClusterInClusterArr(const AliExternalTrackP
 
   Float_t clsPos[3] = {0.,0.,0.};
   for(Int_t icl=0; icl<clusterArr->GetEntriesFast(); icl++)
+  {
+    AliVCluster *cluster = dynamic_cast<AliVCluster*> (clusterArr->At(icl)) ;
+    if(!cluster || !cluster->IsEMCAL()) continue;
+    cluster->GetPosition(clsPos);
+    Double_t dR = TMath::Sqrt(TMath::Power(exPos[0]-clsPos[0],2)+TMath::Power(exPos[1]-clsPos[1],2)+TMath::Power(exPos[2]-clsPos[2],2));
+    if(dR > fClusterWindow) continue;
+    
+    AliExternalTrackParam trkPamTmp (*trkParam);//Retrieve the starting point every time before the extrapolation
+    if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, fMass, fStepCluster, tmpEta, tmpPhi)) continue;
+    if(fCutEtaPhiSum)
     {
-      AliVCluster *cluster = dynamic_cast<AliVCluster*> (clusterArr->At(icl)) ;
-      if(!cluster || !cluster->IsEMCAL()) continue;
-      cluster->GetPosition(clsPos);
-      Double_t dR = TMath::Sqrt(TMath::Power(exPos[0]-clsPos[0],2)+TMath::Power(exPos[1]-clsPos[1],2)+TMath::Power(exPos[2]-clsPos[2],2));
-      if(dR > fClusterWindow) continue;
-
-      AliExternalTrackParam trkPamTmp (*trkParam);//Retrieve the starting point every time before the extrapolation
-      if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, fMass, fStepCluster, tmpEta, tmpPhi)) continue;
-      if(fCutEtaPhiSum)
-        {
-          Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
-          if(tmpR<dRMax)
+      Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
+      if(tmpR<dRMax)
       {
         dRMax=tmpR;
         dEtaMax=tmpEta;
         dPhiMax=tmpPhi;
         index=icl;
       }
-        }
-      else if(fCutEtaPhiSeparate)
-        {
-          if(TMath::Abs(tmpEta)<TMath::Abs(dEtaMax) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMax))
+    }
+    else if(fCutEtaPhiSeparate)
+    {
+      if(TMath::Abs(tmpEta)<TMath::Abs(dEtaMax) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMax))
       {
         dEtaMax = tmpEta;
         dPhiMax = tmpPhi;
         index=icl;
       }
-        }
-      else
-        {
-          printf("Error: please specify your cut criteria\n");
-          printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
-          printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
-          return index;
-        }
     }
+    else
+    {
+      printf("Error: please specify your cut criteria\n");
+      printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
+      printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
+      return index;
+    }
+  }
 
   dEta=dEtaMax;
   dPhi=dPhiMax;
@@ -2117,11 +2099,78 @@ Int_t  AliEMCALRecoUtils::FindMatchedClusterInClusterArr(const AliExternalTrackP
   return index;
 }
 
+//------------------------------------------------------------------------------------
+Bool_t AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(AliVTrack *track,
+                                                        Double_t emcalR, Double_t mass, Double_t step)
+{ 
+  // Extrpolate track to EMCAL surface
+
+  track->SetTrackPhiEtaPtOnEMCal(-999, -999, -999);
+
+  if (track->Pt()<0.350) 
+    return kFALSE;
+
+  Double_t phi = track->Phi()*TMath::RadToDeg();
+  if (TMath::Abs(track->Eta())>0.9 || phi <= 10 || phi >= 250) 
+    return kFALSE;
+
+  AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(track);
+  AliAODTrack *aodt = 0;
+  if (!esdt) {
+    aodt = dynamic_cast<AliAODTrack*>(track);
+    if (!aodt)
+      return kFALSE;
+  }
+
+  if (mass<0) {
+    Bool_t onlyTPC = kFALSE;
+    if (mass==-99)
+      onlyTPC=kTRUE;
+    if (esdt)
+      mass = esdt->GetMass(onlyTPC);
+    else 
+      mass = aodt->M();
+  }
+
+  AliExternalTrackParam *trackParam = 0;
+  if (esdt) {
+    const AliExternalTrackParam *in = esdt->GetInnerParam();
+    if (!in)
+      return kFALSE;
+    trackParam = new AliExternalTrackParam(*in);
+  } else {
+    Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
+    aodt->PxPyPz(pxpypz);  
+    aodt->XvYvZv(xyz);
+    aodt->GetCovarianceXYZPxPyPz(cv);  
+    trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,aodt->Charge());
+  }
+  if (!trackParam)
+    return kFALSE;
+
+  Float_t etaout=-999, phiout=-999, ptout=-999;
+  Bool_t ret = ExtrapolateTrackToEMCalSurface(trackParam, 
+                                             emcalR,
+                                             mass,
+                                             step,
+                                             etaout, 
+                                             phiout,
+                                             ptout);
+  delete trackParam;
+  if (!ret)
+    return kFALSE;
+  if (TMath::Abs(etaout)>0.75 || (phiout<70*TMath::DegToRad()) || (phiout>190*TMath::DegToRad()))
+    return kFALSE;
+  track->SetTrackPhiEtaPtOnEMCal(phiout, etaout, ptout);
+  return kTRUE;
+}
+
+
 //------------------------------------------------------------------------------------
 Bool_t AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *trkParam, 
-                                                         const Double_t emcalR,
-                                                         const Double_t mass, 
-                                                         const Double_t step, 
+                                                         Double_t emcalR,
+                                                         Double_t mass, 
+                                                         Double_t step, 
                                                          Float_t &eta, 
                                                          Float_t &phi,
                                                         Float_t &pt)
@@ -2177,8 +2226,8 @@ Bool_t AliEMCALRecoUtils::ExtrapolateTrackToPosition(AliExternalTrackParam *trkP
 //----------------------------------------------------------------------------------
 Bool_t AliEMCALRecoUtils::ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, 
                                                     const AliVCluster *cluster, 
-                                                    const Double_t mass, 
-                                                    const Double_t step, 
+                                                    Double_t mass, 
+                                                    Double_t step, 
                                                     Float_t &tmpEta, 
                                                     Float_t &tmpPhi)
 {
@@ -2209,7 +2258,7 @@ Bool_t AliEMCALRecoUtils::ExtrapolateTrackToCluster(AliExternalTrackParam *trkPa
 }
 
 //_______________________________________________________________________
-void AliEMCALRecoUtils::GetMatchedResiduals(const Int_t clsIndex, 
+void AliEMCALRecoUtils::GetMatchedResiduals(Int_t clsIndex, 
                                             Float_t &dEta, Float_t &dPhi)
 {
   //Given a cluster index as in AliESDEvent::GetCaloCluster(clsIndex)
@@ -2346,7 +2395,7 @@ UInt_t AliEMCALRecoUtils::FindMatchedPosForTrack(Int_t trkIndex) const
 //__________________________________________________________________________
 Bool_t AliEMCALRecoUtils::IsGoodCluster(AliVCluster *cluster, 
                                         const AliEMCALGeometry *geom, 
-                                        AliVCaloCells* cells,const Int_t bc)
+                                        AliVCaloCells* cells, Int_t bc)
 {
   // check if the cluster survives some quality cut
   //
index 8d896f567e0442aa2bc1f5b5ab55241df288c4b3..f063fe4298a8e0335f03dcdba050a8cd1294e2b6 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ALIEMCALRECOUTILS_H
 #define ALIEMCALRECOUTILS_H
 
-/* $Id: AliEMCALRecoUtils.h 33808 2009-07-15 09:48:08Z gconesab $ */
+/* $Id: AliEMCALRecoUtils.h | Tue Jul 23 09:11:15 2013 +0000 | gconesab  $ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //
@@ -34,6 +34,7 @@ class AliEMCALGeometry;
 class AliEMCALPIDUtils;
 class AliESDtrack;
 class AliExternalTrackParam;
+class AliVTrack;
 
 class AliEMCALRecoUtils : public TNamed {
   
@@ -63,31 +64,31 @@ public:
   void     RecalculateClusterPositionFromTowerIndex (const AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
   void     RecalculateClusterPositionFromTowerGlobal(const AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
   
-  Float_t  GetCellWeight(const Float_t eCell, const Float_t eCluster) const { if (eCell > 0 && eCluster > 0) return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster )) ;
+  Float_t  GetCellWeight(Float_t eCell, Float_t eCluster) const { if (eCell > 0 && eCluster > 0) return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster )) ;
                                                                               else                           return 0.                                                    ; }
   
-  Float_t  GetDepth(const Float_t eCluster, const Int_t iParticle, const Int_t iSM) const ; 
+  Float_t  GetDepth(Float_t eCluster, Int_t iParticle, Int_t iSM) const ; 
   
   void     GetMaxEnergyCell(const AliEMCALGeometry *geom, AliVCaloCells* cells, const AliVCluster* clu, 
                             Int_t & absId,  Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared);
   
-  Float_t  GetMisalTransShift(const Int_t i)       const { if(i < 15 ) { return fMisalTransShift[i] ; }
+  Float_t  GetMisalTransShift(Int_t i)       const { if(i < 15 ) { return fMisalTransShift[i] ; }
                                                            else        { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; 
                                                                          return 0.                  ; } }
   Float_t* GetMisalTransShiftArray()                     { return fMisalTransShift ; }
 
-  void     SetMisalTransShift(const Int_t i, const Float_t shift) {
+  void     SetMisalTransShift(Int_t i, Float_t shift) {
                                                            if(i < 15 ) { fMisalTransShift[i] = shift ; }
                                                            else        { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; } }
   void     SetMisalTransShiftArray(Float_t * misal)               { for(Int_t i = 0; i < 15; i++) fMisalTransShift[i] = misal[i]  ; }
 
-  Float_t  GetMisalRotShift(const Int_t i)         const { if(i < 15 ) { return fMisalRotShift[i]    ; }
+  Float_t  GetMisalRotShift(Int_t i)         const { if(i < 15 ) { return fMisalRotShift[i]    ; }
                                                            else        { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; 
                                                                          return 0.                   ; } }
   
   Float_t* GetMisalRotShiftArray()                       { return fMisalRotShift                     ; }
   
-  void     SetMisalRotShift(const Int_t i, const Float_t shift) {
+  void     SetMisalRotShift(Int_t i, Float_t shift) {
                                                            if(i < 15 ) { fMisalRotShift[i] = shift   ; }
                                                            else        { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; } }
   
@@ -108,10 +109,10 @@ public:
 
   Float_t  CorrectClusterEnergyLinearity(AliVCluster* clu) ;
   
-  Float_t  GetNonLinearityParam(const Int_t i)     const { if(i < 7 && i >=0 ){ return fNonLinearityParams[i]  ; }
+  Float_t  GetNonLinearityParam(Int_t i)     const { if(i < 7 && i >=0 ){ return fNonLinearityParams[i]  ; }
                                                    else  { AliInfo(Form("Index %d larger than 6 or negative, do nothing\n",i)) ;
                                                                        return 0.                     ; } }
-  void     SetNonLinearityParam(const Int_t i, const Float_t param) {
+  void     SetNonLinearityParam(Int_t i, Float_t param) {
                                                            if(i < 7 && i >=0 ){ fNonLinearityParams[i] = param ; }
                                                            else { AliInfo(Form("Index %d larger than 6 or negative, do nothing\n",i)) ; } }
   void     InitNonLinearityParam();
@@ -135,10 +136,10 @@ public:
   //-----------------------------------------------------
   // Recalibration
   //-----------------------------------------------------
-  Bool_t   AcceptCalibrateCell(const Int_t absId, const Int_t bc,
+  Bool_t   AcceptCalibrateCell(Int_t absId, Int_t bc,
                                Float_t & amp, Double_t & time, AliVCaloCells* cells) ; // Energy and Time
   void     RecalibrateCells(AliVCaloCells * cells, Int_t bc) ; // Energy and Time
-  void     RecalibrateClusterEnergy(const AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells, const Int_t bc=-1) ; // Energy and time
+  void     RecalibrateClusterEnergy(const AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells, Int_t bc=-1) ; // Energy and time
   void     ResetCellsCalibrated()                        { fCellsRecalibrated = kFALSE; }
 
   // Energy recalibration
@@ -169,7 +170,7 @@ public:
   void     SwitchOnRunDepCorrection()                    { fUseRunCorrectionFactors = kTRUE  ; 
                                                            SwitchOnRecalibration()           ; }      
   // Time Recalibration  
-  void     RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & time) const;
+  void     RecalibrateCellTime(Int_t absId, Int_t bc, Double_t & time) const;
   
   Bool_t   IsTimeRecalibrationOn()                 const { return fTimeRecalibration   ; }
   void     SwitchOffTimeRecalibration()                  { fTimeRecalibration = kFALSE ; }
@@ -178,18 +179,18 @@ public:
   void     InitEMCALTimeRecalibrationFactors() ;
   TObjArray* GetEMCALTimeRecalibrationFactorsArray() const { return fEMCALTimeRecalibrationFactors ; }
 
-  Float_t  GetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID) const { 
+  Float_t  GetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID) const { 
     if(fEMCALTimeRecalibrationFactors) 
       return (Float_t) ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->GetBinContent(absID); 
     else return 0 ; } 
        
-  void     SetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID, Double_t c = 0) { 
+  void     SetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID, Double_t c = 0) { 
     if(!fEMCALTimeRecalibrationFactors) InitEMCALTimeRecalibrationFactors() ;
     ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->SetBinContent(absID,c) ; }  
   
-  TH1F *   GetEMCALChannelTimeRecalibrationFactors(const Int_t bc)const       { return (TH1F*)fEMCALTimeRecalibrationFactors->At(bc) ; }       
+  TH1F *   GetEMCALChannelTimeRecalibrationFactors(Int_t bc)const       { return (TH1F*)fEMCALTimeRecalibrationFactors->At(bc) ; }     
   void     SetEMCALChannelTimeRecalibrationFactors(TObjArray *map)            { fEMCALTimeRecalibrationFactors = map                 ; }
-  void     SetEMCALChannelTimeRecalibrationFactors(const Int_t bc , TH1F* h)  { fEMCALTimeRecalibrationFactors->AddAt(h,bc)          ; }
+  void     SetEMCALChannelTimeRecalibrationFactors(Int_t bc , TH1F* h)  { fEMCALTimeRecalibrationFactors->AddAt(h,bc)          ; }
   
   //-----------------------------------------------------
   // Modules fiducial region, remove clusters in borders
@@ -198,7 +199,7 @@ public:
   Bool_t   CheckCellFiducialRegion(const AliEMCALGeometry* geom, 
                                    const AliVCluster* cluster, 
                                    AliVCaloCells* cells) ;
-  void     SetNumberOfCellsFromEMCALBorder(const Int_t n){ fNCellsFromEMCALBorder = n      ; }
+  void     SetNumberOfCellsFromEMCALBorder(Int_t n){ fNCellsFromEMCALBorder = n      ; }
   Int_t    GetNumberOfCellsFromEMCALBorder()      const  { return fNCellsFromEMCALBorder   ; }
     
   void     SwitchOnNoFiducialBorderInEMCALEta0()         { fNoEMCALBorderAtEta0 = kTRUE    ; }
@@ -234,7 +235,7 @@ public:
   void     SetEMCALChannelStatusMap(TObjArray *map)      { fEMCALBadChannelMap = map                  ; }
   void     SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALBadChannelMap->AddAt(h,iSM)          ; }
 
-  Bool_t   ClusterContainsBadChannel(const AliEMCALGeometry* geom, const UShort_t* cellList, const Int_t nCells);
+  Bool_t   ClusterContainsBadChannel(const AliEMCALGeometry* geom, const UShort_t* cellList, Int_t nCells);
  
   //-----------------------------------------------------
   // Recalculate other cluster parameters
@@ -263,29 +264,32 @@ public:
                                           AliExternalTrackParam *trkParam, 
                                           const TObjArray * clusterArr, 
                                           Float_t &dEta, Float_t &dPhi);
+
+  static Bool_t ExtrapolateTrackToEMCalSurface(AliVTrack *track, /*note, on success the call will change the track*/
+                                               Double_t emcalR=440, Double_t mass=0.1396, Double_t step=20); 
   
   static Bool_t ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *trkParam, 
-                                               const Double_t emcalR, const Double_t mass, const Double_t step, 
+                                               Double_t emcalR, Double_t mass, Double_t step, 
                                                Float_t &eta, Float_t &phi, Float_t &pt);
   static Bool_t ExtrapolateTrackToPosition(AliExternalTrackParam *trkParam, const Float_t *clsPos, 
-                                           const Double_t mass, const Double_t step, 
+                                           Double_t mass, Double_t step, 
                                            Float_t &tmpEta, Float_t &tmpPhi);
   static Bool_t ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, const AliVCluster *cluster, 
-                                           const Double_t mass, const Double_t step,
+                                           Double_t mass, Double_t step,
                                            Float_t &tmpEta, Float_t &tmpPhi);
   Bool_t        ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, const AliVCluster *cluster, 
                                            Float_t &tmpEta, Float_t &tmpPhi);
 
-  UInt_t   FindMatchedPosForCluster(const Int_t clsIndex) const;
-  UInt_t   FindMatchedPosForTrack  (const Int_t trkIndex) const;
+  UInt_t   FindMatchedPosForCluster(Int_t clsIndex) const;
+  UInt_t   FindMatchedPosForTrack  (Int_t trkIndex) const;
   
-  void     GetMatchedResiduals       (const Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
-  void     GetMatchedClusterResiduals(const Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
+  void     GetMatchedResiduals       (Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
+  void     GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
   Int_t    GetMatchedTrackIndex(Int_t clsIndex);
   Int_t    GetMatchedClusterIndex(Int_t trkIndex);
   
-  Bool_t   IsClusterMatched(const Int_t clsIndex)         const;
-  Bool_t   IsTrackMatched  (const Int_t trkIndex)         const;
+  Bool_t   IsClusterMatched(Int_t clsIndex)         const;
+  Bool_t   IsTrackMatched  (Int_t trkIndex)         const;
 
   void     SetClusterMatchedToTrack (const AliVEvent *event);
   void     SetTracksMatchedToCluster(const AliVEvent *event);  
@@ -317,13 +321,13 @@ public:
   
   // Exotic cells / clusters
   
-  Bool_t   IsExoticCell(const Int_t absId, AliVCaloCells* cells, const Int_t bc =-1) ;
+  Bool_t   IsExoticCell(Int_t absId, AliVCaloCells* cells, Int_t bc =-1) ;
   void     SwitchOnRejectExoticCell()                 { fRejectExoticCells = kTRUE     ; }
   void     SwitchOffRejectExoticCell()                { fRejectExoticCells = kFALSE    ; } 
   Bool_t   IsRejectExoticCell()                 const { return fRejectExoticCells      ; }
    
-  Float_t  GetECross(const Int_t absID, const Double_t tcell,
-                     AliVCaloCells* cells, const Int_t bc);
+  Float_t  GetECross(Int_t absID, Double_t tcell,
+                     AliVCaloCells* cells, Int_t bc);
   
   Float_t  GetExoticCellFractionCut()           const { return fExoticCellFraction     ; }
   Float_t  GetExoticCellDiffTimeCut()           const { return fExoticCellDiffTime     ; }
@@ -333,7 +337,7 @@ public:
   void     SetExoticCellDiffTimeCut(Float_t dt)       { fExoticCellDiffTime     = dt   ; }
   void     SetExoticCellMinAmplitudeCut(Float_t ma)   { fExoticCellMinAmplitude = ma   ; }
   
-  Bool_t   IsExoticCluster(const AliVCluster *cluster, AliVCaloCells* cells, const Int_t bc=0) ;
+  Bool_t   IsExoticCluster(const AliVCluster *cluster, AliVCaloCells* cells, Int_t bc=0) ;
   void     SwitchOnRejectExoticCluster()              { fRejectExoticCluster = kTRUE   ;
                                                         fRejectExoticCells   = kTRUE   ; }
   void     SwitchOffRejectExoticCluster()             { fRejectExoticCluster = kFALSE  ; }
@@ -341,7 +345,7 @@ public:
   
   //Cluster cut
   Bool_t   IsGoodCluster(AliVCluster *cluster, const AliEMCALGeometry *geom, 
-                         AliVCaloCells* cells, const Int_t bc =-1);
+                         AliVCaloCells* cells, Int_t bc =-1);
 
   //Track Cuts 
   Bool_t   IsAccepted(AliESDtrack *track);
index 07db9ceb025dd87e8454cdf3b87c414cd853e03f..75610273184fa3b2e361c2c13d7c2b865843d9af 100644 (file)
@@ -296,6 +296,12 @@ c*********************************
 
 C********************
 24     MISS=-1
+C****  BB IS THE ABSOLUTE VALUE OF IMPACT PARAMETER,BB**2 IS 
+C       RANDOMLY GENERATED AND ITS ORIENTATION IS RANDOMLY SET 
+C       BY THE ANGLE PHI  FOR EACH COLLISION.******************
+C
+       BB=SQRT(BMIN**2+RLU_HIJING(0)*(BMAX**2-BMIN**2))
+       PHI=2.0*HIPR1(40)*RLU_HIJING(0)
 
 50     MISS=MISS+1
        IF(MISS.GT.50) THEN
@@ -326,12 +332,6 @@ C                  ********Initialize for a new event
         NPSPECT=0
         NNSPECT=0 
 
-C****  BB IS THE ABSOLUTE VALUE OF IMPACT PARAMETER,BB**2 IS 
-C       RANDOMLY GENERATED AND ITS ORIENTATION IS RANDOMLY SET 
-C       BY THE ANGLE PHI  FOR EACH COLLISION.******************
-C
-       BB=SQRT(BMIN**2+RLU_HIJING(0)*(BMAX**2-BMIN**2))
-       PHI=2.0*HIPR1(40)*RLU_HIJING(0)
        BBX=BB*COS(PHI)
        BBY=BB*SIN(PHI)
        HINT1(19)=BB
@@ -395,26 +395,24 @@ c *** cl glauber ***
         xm2=0D0
         ym2=0D0
         xym=0D0
-
+c
        IF(NCOLT>0) THEN 
            DO 1110 JP=1,IHNT2(1)
-              YP(1,JP)=YP(1,JP)+BBX
-              YP(2,JP)=YP(2,JP)+BBY
-              xmeana=xmeana+YP(1,JP)
-              ymeana=ymeana+YP(2,JP)
+              xmeana=xmeana+YP(1,JP)+BBX
+              ymeana=ymeana+YP(2,JP)+BBY
               DO 1120 JT=1,IHNT2(3)
                  IF(SCIP2(JP,JT).LT.2.0D0) THEN
                     npart=npart+1
-                    xmeanp=xmeanp+YP(1,JP)
-                    ymeanp=ymeanp+YP(2,JP)
-                    xm2=xm2+YP(1,JP)*YP(1,JP)
-                    ym2=ym2+YP(2,JP)*YP(2,JP)
-                    xym=xym+YP(1,JP)*YP(2,JP)
+                    xmeanp=xmeanp+YP(1,JP)+BBX
+                    ymeanp=ymeanp+YP(2,JP)+BBY
+                    xm2=xm2+(YP(1,JP)+BBX)*(YP(1,JP)+BBX)
+                    ym2=ym2+(YP(2,JP)+BBY)*(YP(2,JP)+BBY)
+                    xym=xym+(YP(1,JP)+BBX)*(YP(2,JP)+BBY)
                     goto 1110
                  end if
  1120         continue
  1110      continue
-
+c
            DO 1130 JT=1,IHNT2(3)
               xmeanb=xmeanb+YT(1,JT)
               ymeanb=ymeanb+YT(2,JT)
@@ -441,11 +439,11 @@ c *** cl glauber ***
               xm2=xm2/npart
               ym2=ym2/npart
               xym=xym/npart
-
+c
               sx2=xm2-xmeanp*xmeanp
               sy2=ym2-ymeanp*ymeanp
               sxy=xym-xmeanp*ymeanp
-           
+c           
               delx=xmeanb-xmeana
               dely=ymeanb-ymeana
               dtmp=delx**2+dely**2
@@ -457,18 +455,20 @@ c *** cl glauber ***
               eccpart=sqrt(dtmp)/(sx2+sy2)
               eccmc=(sy2-sx2)/(sy2+sx2)
               write(*,*),'HOUT: ',bb,' ',bbtrue,' ',ncolt,' ',npart,
-     1             ' ',eccrp,' ',eccpart
+     1             ' ',eccrp,' ',eccpart, bbx, bby
            end if
         end if
-
+c
 C              ********total number interactions proj and targ has
 C                              suffered
 
        IF(NCOLT.EQ.0) THEN
           NLOP=NLOP+1
            IF(NLOP.LE.20.OR.
-     &           (IHNT2(1).EQ.1.AND.IHNT2(3).EQ.1)) GO TO 60
-
+     &          (IHNT2(1).EQ.1.AND.IHNT2(3).EQ.1)) THEN 
+              BB=SQRT(BMIN**2+RLU_HIJING(0)*(BMAX**2-BMIN**2))
+              GO TO 60
+           ENDIF
 
            RETURN
        ENDIF
index 58fb114684bac01d965f69f40d7ff3e8396ea108..08d371be273fec20476fdf74926aff1f88f5c829 100644 (file)
@@ -81,7 +81,10 @@ set ( MODULE_HDRS    ${CLASS_HDRS})
 
 set ( MODULE_DHDR      AliHLTTriggerLinkDef.h)
 
-set ( EINCLUDE HLT/BASE HLT/BASE/util HLT/trigger HLT/TPCLib HLT/TRD TRD HLT/ITS HLT/MUON MUON HLT/FJWrapper ${FASTJETENV}/include ${FASTJETENV}/include/fastjet ${FASTJETENV}/include/fastjet/internal STEER/ESD STEER/STEERBase STEER/STEER)
+set ( EINCLUDE HLT/BASE HLT/BASE/util HLT/trigger HLT/TPCLib HLT/TRD TRD HLT/ITS HLT/MUON MUON HLT/FJWrapper STEER/ESD STEER/STEERBase STEER/STEER)
+if(FASTJETENV)
+  set ( EINCLUDE ${EINCLUDE} ${FASTJETENV}/include ${FASTJETENV}/include/fastjet ${FASTJETENV}/include/fastjet/internal)
+endif(FASTJETENV)
 
 set ( ELIBS  "HLTbase AliHLTTRD AliHLTMUON AliHLTUtil")
 
@@ -109,4 +112,4 @@ set ( PACKCXXFLAGS  ${HLTCXXFLAGS})
 set ( PACKCFLAGS  ${HLTCLFAGS})
 set ( PACKDCXXFLAGS  ${HLTDCXXFLAGS})
 set ( PACKSOFLAGS ${HLTSOFLAGS})
-set ( EXPORT trigger/AliHLTGlobalTrigger.h)
\ No newline at end of file
+set ( EXPORT trigger/AliHLTGlobalTrigger.h)
index be74b5ff7ad2d4a4ed3483c87660f7f6c88482ab..6f69cfcaa8c171361c09e0a56aaa8de25378cfcc 100644 (file)
@@ -49,7 +49,7 @@ set ( MODULE_DHDR )
 
 set ( EINCLUDE  "HLT/rec HLT/BASE HLT/BASE/HOMER RAW STEER/STEER STEER/ESD STEER/STEERBase")
 
-set ( ELIBS  "HLTbase CDB ESD STEERBase STEER RAWDatarec RAWDatabase")
+set ( ELIBS  "HLTbase CDB ESD STEERBase STEER RAWDatarec RAWDatabase ANALYSIS")
 
 include ("CMakehlt.conf")
 
index 6b144e66b47a634767676e8e511a4eb9c54511ff..3aa10b2526f499b2d481ba617456ce9112a1c980 100644 (file)
@@ -508,7 +508,7 @@ Bool_t AliHLTJETReader::FillGridMC() {
     if ( ! fTrackCuts->IsSelected(particle) )
       continue;
 
-    const Float_t aEtaPhi[]  = { particle->Eta(), particle->Phi(), particle->Pt() }; 
+    const Float_t aEtaPhi[]  = { static_cast<Float_t>(particle->Eta()), static_cast<Float_t>(particle->Phi()), static_cast<Float_t>(particle->Pt()) }; 
           Int_t   aGridIdx[] = { -1, -1, -1, -1, -1 };
 
     fGrid->FillTrack(particle, aEtaPhi, aGridIdx);
@@ -557,7 +557,7 @@ Bool_t AliHLTJETReader::FillGridHLTMC() {
     if ( ! fTrackCuts->IsSelected(particle) )
       continue;
 
-    const Float_t aEtaPhi[]  = { particle->Eta(), particle->Phi(), particle->Pt() }; 
+    const Float_t aEtaPhi[]  = { static_cast<Float_t>(particle->Eta()), static_cast<Float_t>(particle->Phi()), static_cast<Float_t>(particle->Pt()) }; 
           Int_t   aGridIdx[] = { -1, -1, -1, -1, -1 };
 
     // -- Fill grid
@@ -615,7 +615,7 @@ Bool_t AliHLTJETReader::FillGridESD() {
     if ( ! fTrackCuts->IsSelected(esdTrack) )
       continue;
 
-    const Float_t aEtaPhi[]  = { esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt() }; 
+    const Float_t aEtaPhi[]  = { static_cast<Float_t>(esdTrack->Eta()), static_cast<Float_t>(esdTrack->Phi()), static_cast<Float_t>(esdTrack->Pt()) }; 
           Int_t   aGridIdx[] = { -1, -1, -1, -1, -1 };
 
     // -- Fill grid
index 57fa935047a446ce4c6a1cd6bacae782202e035c..b26f5a4e0f5ccb819e8f3d7f57b7d8b4255cf4da 100644 (file)
@@ -90,7 +90,7 @@ class TMap;
 
 class AliHLTMUONFullTracker;
 
-const Float_t AliHLTMUONFullTracker::fgkTrackDetCoordinate[3] = {
+const Double_t AliHLTMUONFullTracker::fgkTrackDetCoordinate[3] = {
   155.179+20.0,  166.234+20.0, 
   (AliMUONConstants::DefaultChamberZ(4)+ AliMUONConstants::DefaultChamberZ(5))/2.0
 };
index e1814a93f23827abf2a80a5f87acac242b749bc9..10519c6dfa792e0f7b2377ec8c8eff68b4cc9e9b 100644 (file)
@@ -113,7 +113,7 @@ class AliHLTMUONFullTracker : public AliHLTLogging
     Int_t fCharge;       /// charge
   }; 
 
-  static const Float_t fgkTrackDetCoordinate[3]; /// set the constant value for third station position and size
+  static const Double_t fgkTrackDetCoordinate[3]; /// set the constant value for third station position and size
   
   static const Double_t fgkAbsoedge[4] ;     /// edge of the absorber
   static const Double_t fgkRadLen[3] ;       /// radiation length of the main three matirials of the front absorber
index c7b00af09a4ffdaba0e17b5f808fd444eb1af99d..d4bc2bbe4fb4bc11ada30d9ea4abccda68460c03 100644 (file)
@@ -116,7 +116,7 @@ int AliHLTAltroGenerator::Generate()
     HLTDebug("simulate channel %d: address %d", channel, channelAddress);
 
     // save beginning of this channel for better navigation
-    AliChannelPosition position={channelAddress, dataPos, 0};
+    AliChannelPosition position={static_cast<AliHLTUInt16_t>(channelAddress), dataPos, 0};
 
     // add channel address and bunch count at the beginning
     if (fpSimData->GetSize()<dataPos+2) fpSimData->Set(dataPos+2);
index 35375305bce1e78cdd46dc0274bd84d6ac2c8640..ddba74733dcb39fb0274cb483c0d4d32a4b28151 100644 (file)
@@ -24,7 +24,7 @@
 #include <vector>
 #include <ostream>
 
-class AliRawDataHeader;
+struct AliRawDataHeader;
 class TArrayS;
 class TArrayC;
 class TRandom;
index d582f80682239d42f93aededa1c92d254dd78066..c131c40bea8600f9c2c614ef157442788640ca88 100644 (file)
@@ -1213,7 +1213,7 @@ void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliClusterData *list)
          fSpacePointData[counter].fZ = xyz[2];
        }
        else{
-         Double_t x[3]={thisrow,fpad+.5,ftime}; 
+         Double_t x[3]={static_cast<Double_t>(thisrow),fpad+.5,ftime}; 
          Int_t iSector[1]={thissector};
          fOfflineTransform->Transform(x,iSector,0,1);
          double y[3] = {x[0], x[1], x[2] };      
index 1f9eed51838d72a3a0dda2a5d2bb700072716e07..433b4b6ac19f70fd044db44278abacc6a0fb6302 100644 (file)
@@ -463,7 +463,7 @@ void AliHLTTPCHWCFSpacePointContainer::Print(ostream& out, Option_t */*option*/)
        cl!=fClusters.end(); cl++) {
     str << " 0x" << hex << setw(8) << setfill('0') << cl->first << dec << cl->second << endl;
   }
-  out << str;
+  out << str.str();
 }
 
 AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMask(AliHLTUInt32_t mask, bool /*bAlloc*/) const
@@ -888,7 +888,7 @@ void AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::Print(
       << " " << setw(5) << decoder->GetCharge(fIndex) 
       << " " << setw(5) << decoder->GetQMax(fIndex)
       << " " << fTrackId << " " << fMCId << " " << fUsed;
-  out << str;
+  out << str.str();
 }
 
 ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p)
index b8b79c2aa9f2e2c8ba9d9627d4c2a174ff6d167a..92751a51016d4dba00240e3b101f2aa557de5de8 100644 (file)
@@ -433,7 +433,7 @@ void AliHLTTPCRawSpacePointContainer::Print(ostream& out, Option_t */*option*/)
        cl!=fClusters.end(); cl++) {
     str << " 0x" << hex << setw(8) << setfill('0') << cl->first << dec << cl->second << endl;
   }
-  out << str;
+  out << str.rdbuf();
 }
 
 AliHLTSpacePointContainer* AliHLTTPCRawSpacePointContainer::SelectByMask(AliHLTUInt32_t mask, bool /*bAlloc*/) const
@@ -860,7 +860,7 @@ void AliHLTTPCRawSpacePointContainer::AliHLTTPCRawSpacePointProperties::Print(os
       << " " << setw(5) << fpCluster->GetCharge() 
       << " " << setw(5) << fpCluster->GetQMax()
       << " " << fTrackId << " " << fMCId << " " << fUsed;
-  out << str;
+  out << str.rdbuf();
 }
 
 ostream& operator<<(ostream &out, const AliHLTTPCRawSpacePointContainer::AliHLTTPCRawSpacePointProperties& p)
index 1ec9bbb268f02e80bc12828ba5fc80e2e62c82ef..3556530a3582fd423531c7e7dbfae21203c85193 100644 (file)
@@ -312,7 +312,7 @@ int AliTPCtrackerCA::LoadClusters ( TTree * fromTree )
       }
 
       transform->SetCurrentRecoParam((AliTPCRecoParam*)AliTPCReconstructor::GetRecoParam());
-      double xx[3] = {cluster->GetRow(), cluster->GetPad(), cluster->GetTimeBin()};
+      double xx[3] = {static_cast<double>(cluster->GetRow()), cluster->GetPad(), cluster->GetTimeBin()};
       int id[1] = {cluster->GetDetector()};
       transform->Transform( xx, id, 0, 1 );
 
index 0014ab6c31ad98a9933d24c6c5b00886b28bb654..6eadb91584fc50fd23c5505930d3888ab93a295e 100644 (file)
@@ -217,8 +217,9 @@ Int_t AliHLTTPCFastTransform::SetCurrentTimeStamp( Long_t TimeStamp )
   Int_t nTimeBins = tpcParam->GetMaxTBin();
   Int_t is[]={0};
   bool sign = 0;
-  for( fLastTimeBin=0; fLastTimeBin<nTimeBins; fLastTimeBin++){  
-    Double_t xx[]={0,0,fLastTimeBin};
+  for( fLastTimeBin=0; fLastTimeBin<nTimeBins; fLastTimeBin++){
+    // static cast is okay since fLastTimeBin has limited value range  
+    Double_t xx[]={0,0,static_cast<Double_t>(fLastTimeBin)};
     fOrigTransform->Transform(xx,is,0,1);
     bool s = (xx[2]>=0);
     if( fLastTimeBin==0 ) sign = s;
@@ -275,7 +276,7 @@ Int_t AliHLTTPCFastTransform::InitRow( Int_t iSector, Int_t iRow )
     for( Int_t j=0; j<fRows[iSector][iRow]->fSpline[i].GetNPoints(); j++){
       Float_t pad, time;
       fRows[iSector][iRow]->fSpline[i].GetAB(j,pad,time);
-      Double_t xx[]={iRow,pad,time};
+      Double_t xx[]={static_cast<Double_t>(iRow),pad,time};
       fOrigTransform->Transform(xx,is,0,1);
       fRows[iSector][iRow]->fSpline[i].Fill(j,xx);    
     }
index fc5cb03b6e74e0064d54e0b3636e89efe41bdd90..b3b318b0b79841a4f7fdf46c464c06eaea2418f5 100644 (file)
@@ -462,10 +462,10 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
       for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
           element!=tracks.end(); element++) {
        Float_t points[4] = {
-         element->GetX(),
-         element->GetY(),
-         element->GetLastPointX(),
-         element->GetLastPointY()
+         static_cast<Float_t>(element->GetX()),
+         static_cast<Float_t>(element->GetY()),
+         static_cast<Float_t>(element->GetLastPointX()),
+         static_cast<Float_t>(element->GetLastPointY())
        };
 
        Int_t mcLabel = -1;
index fa36a0b7a39538821fa82ff500071ab014546f5e..aef91488cc2ca984af313029473f3ca97250eae6 100644 (file)
@@ -246,7 +246,33 @@ AliHLTUInt32_t AliHLTMiscImplementation::GetEventType(AliRawReader* rawReader) c
   if (!rawReader) return 0;
   const AliRawEventHeaderBase* eventHeader = rawReader->GetEventHeader();
   if (!eventHeader) return 0;
-  return eventHeader->Get("Type");
+  UInt_t daqType = eventHeader->Get("Type");
+  switch(daqType){
+  case AliRawEventHeaderBase::kStartOfRun:
+  case AliRawEventHeaderBase::kStartOfData:
+    return gkAliEventTypeStartOfRun;
+
+  case AliRawEventHeaderBase::kEndOfRun:
+  case AliRawEventHeaderBase::kEndOfData:
+    return gkAliEventTypeEndOfRun;
+
+  case AliRawEventHeaderBase::kPhysicsEvent:
+    return gkAliEventTypeData;
+
+  case AliRawEventHeaderBase::kCalibrationEvent:
+    return gkAliEventTypeCalibration;
+
+  case AliRawEventHeaderBase::kFormatError:
+    return gkAliEventTypeCorruptID;
+
+  case AliRawEventHeaderBase::kSystemSoftwareTriggerEvent:
+  case AliRawEventHeaderBase::kDetectorSoftwareTriggerEvent:
+    return gkAliEventTypeSoftware;
+
+    // TODO: Sync Event Type not implemented!
+    //case AliRawEventHeaderBase::kSyncEvent:
+  }
+  return gkAliEventTypeUnknown;
 }
 
 const char* AliHLTMiscImplementation::GetBeamTypeFromGRP() const
index 3485d1fd44a76e89325122e31fdc2aee76990241..d62eebdcaef61f7fe0071c8c354c20d13bff004b 100644 (file)
@@ -1398,9 +1398,8 @@ void AliITS::UpdateInternalGeometry(){
 //   AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
 
   AliITSVersion_t version = (AliITSVersion_t)IsVersion();
-  Int_t minor = 0;
   AliITSInitGeometry initgeom;
-  AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
+  AliITSgeom* geom = initgeom.CreateAliITSgeom(version);
   SetITSgeom(geom);
 }
 //______________________________________________________________________
index 6cfc2943f5292aaaa6c139e2a17656f770a7e797..3e87df9cd0a6cb46d68bd84c8b6f603819987f8e 100644 (file)
@@ -53,21 +53,10 @@ $Id$
 
 ClassImp(AliITSInitGeometry)
 
-const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSDDcone   = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSSDcone   = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSPDshield = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSDDshield = kTRUE;
-const Bool_t AliITSInitGeometry::fgkOldSSDshield = kTRUE;
-const Bool_t AliITSInitGeometry::fgkOldServices  = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSupports  = kFALSE;
 //______________________________________________________________________
 AliITSInitGeometry::AliITSInitGeometry():
 TObject(),                   // Base Class
 fName(0),                    // Geometry name
-fMinorVersion(-1),           // Minor version number/type
 fMajorVersion(kvDefault),    // Major versin number
 fTiming(kFALSE),             // Flag to start inilization timing
 fSegGeom(kFALSE),            // Flag to switch between the old use of
@@ -86,12 +75,10 @@ fDebug(0){                   // Debug flag
     fName = "Undefined";
 }
 //______________________________________________________________________
-AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version,
-                                       Int_t minorversion):
+AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version):
 TObject(),                   // Base Class
 fName(0),                    // Geometry name
-fMinorVersion(minorversion), // Minor version number/type
-fMajorVersion(version),      // Major versin number
+fMajorVersion(version),      // Major version number
 fTiming(kFALSE),             // Flag to start inilization timing
 fSegGeom(kFALSE),            // Flag to switch between the old use of
                              // AliITSgeomS?D class, or AliITSsegmentation
@@ -112,8 +99,7 @@ fDebug(0){                   // Debug flag
        break;
     case kvDefault:
     default:
-        AliFatal(Form("Undefined geometry: fMajorVersion=%d, "
-                      "fMinorVersion= %d",(Int_t)fMajorVersion,fMinorVersion));
+        AliFatal(Form("Undefined geometry: fMajorVersion=%d, ",(Int_t)fMajorVersion));
         fName = "Undefined";
        break;
     } // switch
@@ -142,25 +128,24 @@ AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
     return 0;
   }// end if
   const Char_t *title = itsV->GetTitle();
-  if(!ReadVersionString(title,(Int_t)strlen(title),version,minor,
-                       datetime))
+  if(!ReadVersionString(title,version))
     Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
   SetTiming(kFALSE);
   SetSegGeom(kFALSE);
   SetDecoding(kFALSE);
-  AliITSgeom *geom = CreateAliITSgeom(version,minor);
+  AliITSgeom *geom = CreateAliITSgeom(version);
   AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
   return geom;
 }
 //______________________________________________________________________
-AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
+AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major){
     // Creates and Initilizes the geometry transformation class AliITSgeom
     // to values appropreate to this specific geometry. Now that
     // the segmentation is part of AliITSgeom, the detector
     // segmentations are also defined here.
     // Inputs:
     //   Int_t major   major version, see AliITSVersion_t
-    //   Int_t minor   minor version
+    //   
     // Outputs:
     //   none.
     // Return:
@@ -170,12 +155,12 @@ AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
     switch(major){
     case kv11:
         SetGeometryName("AliITSv11");
-        SetVersion(kv11,minor);
+        SetVersion(kv11);
         break;
     case kvDefault:
     default:
         SetGeometryName("Undefined");
-        SetVersion(kvDefault,minor);
+        SetVersion(kvDefault);
         break;
     } // end switch
     AliITSgeom *geom = new AliITSgeom();
@@ -851,137 +836,47 @@ void AliITSInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
 }
 
 //______________________________________________________________________
-Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
-                        AliITSVersion_t maj,Int_t min,
-                        const Char_t *cvsDate,const Char_t *cvsRevision)const{
-    // fills the string str with the major and minor version number
+Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,AliITSVersion_t maj)const{
+    // fills the string str with the major version number
     // Inputs:
-    //   Char_t *str          The character string to hold the major 
-    //                        and minor version numbers in
+    //   Char_t *str          The character string to hold the major version number
     //   Int_t  length        The maximum number of characters which 
-    //                        can be accomidated by this string. 
-    //                        str[length-1] must exist and will be set to zero
+    //                        can be accommodated by this string. 
+    //                        str[length-1] must exist
     //   AliITSVersion_t maj  The major number
-    //   Int_t           min  The minor number
-    //   Char_t *cvsDate      The date string from cvs
-    //   Char_t *cvsRevision  The Revision string from cvs
-    // Outputs:
-    //   Char_t *str          The character string holding the major and minor
-    //                        version numbers. str[length-1] must exist
-    //                        and will be set to zero
-    // Return:
-    //   kTRUE if no errors
-    Char_t cvslikedate[30];
-    Int_t i,n,cvsDateLength,cvsRevisionLength;
-
-    cvsDateLength = (Int_t)strlen(cvsDate);
-    if(cvsDateLength>30){ // svn string, make a cvs like string
-        i=0;n=0;
-        do{
-            cvslikedate[i] = cvsDate[i];
-            if(cvsDate[i]=='+' || cvsDate[i++]=='-'){
-                n++; // count number of -
-                cvslikedate[i-1] = '/'; // replace -'s by /'s.
-            } // end if
-        } while(n<3&&i<30); // once additonal - of time zone reach exit
-        cvslikedate[i-1] = '$'; // put $ at end then zero.
-        for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off.
-    }else{
-        for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i];
-    }// end if
-    cvsDateLength = (Int_t)strlen(cvslikedate);
-    cvsRevisionLength = (Int_t)strlen(cvsRevision);
-    i = (Int_t)maj;
-    n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
-        (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
-        +cvsDateLength-6+cvsRevisionLength-10;
-    if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
-                        "length=%d major=%d minor=%d cvsDate=%s[%d] "
-                        "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
-                        cvsDateLength,cvsRevision,cvsRevisionLength,n);
-    if(i<0) n++;
-    if(min<0) n++;
-    if(length<n){// not enough space to write in output string.
-        Warning("WriteVersionString","Output string not long enough "
-                "lenght=%d must be at least %d long\n",length,n);
-        return kFALSE;
-    } // end if length<n
-    char *cvsrevision = new char[cvsRevisionLength-10];
-    char *cvsdate = new char[cvsDateLength-6];
-    for(i=0;i<cvsRevisionLength-10;i++)
-        if(10+i<cvsRevisionLength-1)
-            cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
-    for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
-        cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0;
-    for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
-    i = (Int_t)maj;
-    snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate);
-    /* this gives compilation warnings on some compilers: descriptor zu
-    if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
-                       "n=%d str=%s revision[%zu] date[%zu]\n",
-                       n,str,strlen(cvsrevision),strlen(cvsdate));
-    */
-    delete[] cvsrevision;
-    delete[] cvsdate;
+
+
+    Int_t i = (Int_t)maj;
+    snprintf(str,length-1,"Major Version= %d",i);
     return kTRUE;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
-                                             AliITSVersion_t &maj,Int_t &min,
-                                             TDatime &dt)const{
+Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,AliITSVersion_t &maj)const{
     // fills the string str with the major and minor version number
     // Inputs:
-    //   Char_t *str   The character string to holding the major and minor
-    //                 version numbers in
+    //   Char_t *str   The character string to holding the major version number
     //   Int_t  length The maximum number of characters which can be
-    //                 accomidated by this string. str[length-1] must exist
+    //                 accommodated by this string. str[length-1] must exist
     // Outputs:
-    //   Char_t *str   The character string holding the major and minor
-    //                 version numbers unchanged. str[length-1] must exist.
     //   AliITSVersion_t maj  The major number
-    //   Int_t           min  The minor number
-    //   TDatime         dt   The date and time of the cvs commit
+
     // Return:
     //   kTRUE if no errors
-    Bool_t ok;
-    Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
-    Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
-    memset(cvsRevision,0,10*sizeof(Char_t));
-    memset(cvsDate,0,11*sizeof(Char_t));    
-    memset(cvsTime,0,9*sizeof(Char_t));
-
-    if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString:"
-                       "str=%s length=%d\n",
-                       str,length);
-    if(n<35) return kFALSE; // not enough space for numbers
-    m = sscanf(str,"Major Version= %d  Minor Version= %d Revision: %9s "
-               "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime);
-
-    // v11Hybrid geometry is treated as a v11 geometry
-    if(i == 110)i=11;
-
-    ok = m==5;
-    if(!ok) return !ok;
-    m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
-    ok = m==3;
-    if(!ok) return !ok;
-    m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
-    ok = m==3;
-    if(!ok) return !ok;
-    dt.Set(year,month,day,hours,minuits,seconds);
-    if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d "
-                     "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
-                       i,min,cvsRevision,cvsDate,cvsTime,m);
-    if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
-                       " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
-                       year,month,day,hours,minuits,seconds);
-    switch (i){
-    case kv11:{
-        maj = kv11;
-    } break;
-    default:{
-        maj = kvDefault;
-    } break;
-    } // end switch
-    return ok;
+
+  Bool_t retcode=kFALSE;
+  Int_t n=strlen(str);
+  if(n<15) return retcode; // not enough space for numbers
+  Int_t m,i;
+  m = sscanf(str,"Major Version= %d",&i);
+  maj = kvDefault;
+  if(m>0){
+    retcode = kTRUE;
+    if(i==11){
+      maj = kv11;
+    }
+  }
+  return retcode;
 }
+
+
index 6b24e57a9908a2cd182cf3c5dc540e68c67fe2d6..4da8e3bce7a47f07f764b65dadaeff558effb77d 100644 (file)
@@ -29,22 +29,20 @@ class AliITSInitGeometry : public TObject{
  public:
 
     AliITSInitGeometry();//Default Constructor
-    AliITSInitGeometry(AliITSVersion_t version,
-                      Int_t minorversion=2);//Standard Constructor
+    AliITSInitGeometry(AliITSVersion_t version);//Standard Constructor
     //virtual ~AliITSInitGeometry(); // Destructor
     //
     // Create and initialize geometry from TGeo
     AliITSgeom* CreateAliITSgeom();
-    AliITSgeom* CreateAliITSgeom(Int_t major,Int_t minor); 
+    AliITSgeom* CreateAliITSgeom(Int_t major); 
     Bool_t InitAliITSgeom(AliITSgeom *geom);//Initilize geometry from gGeoManager
     // Getters and Setters
     // Getters and Setters
-    void    SetVersion(AliITSVersion_t maj,Int_t min) {// Set Major and Minor versions
-        fMajorVersion=maj;fMinorVersion=min;}
+    void    SetVersion(AliITSVersion_t maj) {// Set version
+        fMajorVersion=maj;}
     TString GetGeometryName()const {return fName;}// Return geometry name
     void    SetGeometryName(const Char_t *name){fName = name;}// Set Geometry name
     Int_t   GetMajorVersion()const {return (Int_t)fMajorVersion;} // Return geometry major version
-    Int_t   GetMinorVersion()const{return fMinorVersion;}// Return geometry minor version
     Bool_t  GetTiming()const{return fTiming;} // return routine timing flag
     void    SetTiming(Bool_t time=kTRUE){fTiming=time;}// Set routine timing (on)
     Bool_t  GetSegGeom()const{return fSegGeom;} // return flag indecating the use of AliITSsegmentation or AliITSgeomS?D class in fShape.
@@ -62,27 +60,14 @@ class AliITSInitGeometry : public TObject{
                         Int_t cpn1,Int_t cpn2) const;
     // Given module number, find copy numbers.
     void RecodeDetector(Int_t mod,Int_t &cpn0,Int_t &cpn1,Int_t &cpn2);
-   // fills the string str with the major and minor version number
+   // fills the string str with the version number
     Bool_t WriteVersionString(Char_t *str,Int_t length,
-                              AliITSVersion_t maj,Int_t min,
-                              const Char_t *cvsDate,const Char_t *cvsRev)const;
-    // decodes the string str with the major and minor version number
-    Bool_t ReadVersionString(const Char_t *str,Int_t length,
-                             AliITSVersion_t &maj,Int_t &min,TDatime &dt)const;
-
-    static Bool_t SPDIsTGeoNative() {return !fgkOldSPDbarrel;}
-    static Bool_t SDDIsTGeoNative() {return !fgkOldSDDbarrel;}
-    static Bool_t SSDIsTGeoNative() {return !fgkOldSSDbarrel;}
-
-    static Bool_t SDDconeIsTGeoNative()   {return ! fgkOldSDDcone;} 
-    static Bool_t SSDconeIsTGeoNative()   {return ! fgkOldSSDcone;}
-    static Bool_t SPDshieldIsTGeoNative() {return ! fgkOldSPDshield;}
-    static Bool_t SDDshieldIsTGeoNative() {return ! fgkOldSDDshield; }
-    static Bool_t SSDshieldIsTGeoNative() {return ! fgkOldSSDshield;}
-    static Bool_t ServicesAreTGeoNative() {return ! fgkOldServices;}
-    static Bool_t SupportIsTGeoNative()   {return ! fgkOldSupports;}
+                              AliITSVersion_t maj)const;
 
  private:
+    // decodes the string str with the version number
+    Bool_t ReadVersionString(const Char_t *str,AliITSVersion_t &maj)const;
+
     // Decode module number into old layer, ladder, and detector numbers
     void DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
                                 Int_t &lad,Int_t &det);
@@ -99,7 +84,6 @@ class AliITSInitGeometry : public TObject{
     void TransposeTGeoHMatrix(TGeoHMatrix *m) const;
 
     TString         fName;         // Geometry name
-    Int_t           fMinorVersion; // Geometry minor version
     AliITSVersion_t fMajorVersion; // Geometry swich value
     Bool_t          fTiming;       // Flag to start inilization timing
     Bool_t          fSegGeom;      // Flag to switch between the old use of
@@ -108,16 +92,6 @@ class AliITSInitGeometry : public TObject{
     Bool_t          fDecode;       // Flag for new/old decoding
     Int_t           fDebug;        // Debug flag
 
-    static const Bool_t fgkOldSPDbarrel;   // use old geo for SPD ?
-    static const Bool_t fgkOldSDDbarrel;   // use old geo for SDD ?
-    static const Bool_t fgkOldSSDbarrel;   // use old geo for SSD ?
-    static const Bool_t fgkOldSDDcone;    // use old geo for SDD cone ?
-    static const Bool_t fgkOldSSDcone;    // use old geo for SSD cone?
-    static const Bool_t fgkOldSPDshield;  // use old geo for SPD shield ?
-    static const Bool_t fgkOldSDDshield;  // use old geo for SDD shield ?
-    static const Bool_t fgkOldSSDshield;  // use old geo for SDD shield ?
-    static const Bool_t fgkOldServices;  // use old geo for services ?
-    static const Bool_t fgkOldSupports;  // use old geo for supports ?
 
     ClassDef(AliITSInitGeometry,0) // create/Init AliITSgeom
     // 0 in ClassDef indicates that this class will not be "saved" in a file.
index 8b038df0c59af76c8f23f8c94ee7ec545c9577fc..e74f8c3472d2dff450ea445fef1f8e3e21ca770a 100644 (file)
@@ -1282,7 +1282,18 @@ Bool_t  AliITSQASDDChecker::MakeSDDImage( TObjArray ** list, AliQAv1::TASKINDEX_
     }
     break;
     case AliQAv1::kNULLTASKINDEX:; case  AliQAv1::kNTASKINDEX: 
-      {AliWarning(Form("No histograms for this task ( %s ) \n", AliQAv1::GetTaskName(task).Data())); rval=kFALSE;}
+      {
+       Int_t ts=(Int_t)task;
+       TString str;
+       if(ts>-1 && ts <9){
+         str= AliQAv1::GetTaskName(task);
+       }
+       else {
+         str="UNDEFINED";
+       }
+       AliWarning(Form("No histograms for this task ( %s ) \n", str.Data())); 
+       rval=kFALSE;
+      }
       break;
     }
 return rval;  
index a4d86770e9bf142c443f69aa886ca6869fda3ff4..ae71822d02f0d7b1480dc6cd4392aea2bbc8b784 100644 (file)
@@ -65,7 +65,7 @@ AliITStrackV2::AliITStrackV2(AliESDtrack& t,Bool_t c):
   }
   Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
 
-  SetLabel(t.GetLabel());
+  SetLabel(t.GetITSLabel());
   SetMass(t.GetMass());
   SetNumberOfClusters(t.GetITSclusters(fIndex));
 
@@ -94,6 +94,19 @@ void AliITStrackV2::ResetClusters() {
 void AliITStrackV2::UpdateESDtrack(ULong_t flags) const {
   // Update track params
   fESDtrack->UpdateTrackParams(this,flags);
+  //
+  // set correctly the global label
+  if (fESDtrack->IsOn(AliESDtrack::kTPCin)) { 
+    // for global track the GetLabel should be negative if
+    // 1) GetTPCLabel<0
+    // 2) this->GetLabel()<0
+    // 3) GetTPCLabel() != this->GetLabel()
+    int label = fESDtrack->GetTPCLabel();
+    int itsLabel = GetLabel();
+    if (label<0 || itsLabel<0 || itsLabel!=label) label = -TMath::Abs(label);
+    fESDtrack->SetLabel(label);
+  }
+  //
   // copy the module indices
   Int_t i;
   for(i=0;i<2*AliITSgeomTGeo::kNLayers;i++) {
index b7d73309eae1a60234cb4962097a36d76ef496c2..e6877423890f984ae72da0a0bd2281b0fae54c15 100644 (file)
@@ -752,9 +752,9 @@ Int_t AliITStrackerMI::PropagateBack(AliESDEvent *event) {
      fTrackToFollow.ResetCovariance(10.); fTrackToFollow.ResetClusters();
      if (RefitAt(AliITSRecoParam::GetrInsideITSscreen(),&fTrackToFollow,&t)) {
        if (!CorrectForTPCtoITSDeadZoneMaterial(&fTrackToFollow)) continue;
-       fTrackToFollow.SetLabel(t.GetLabel());
+       //       fTrackToFollow.SetLabel(t.GetLabel());              // why do we neet this
        //fTrackToFollow.CookdEdx();
-       CookLabel(&fTrackToFollow,0.); //For comparison only
+       CookLabel(&fTrackToFollow,0.); //For comparison only // why do we need this?
        fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout);
        //UseClusters(&fTrackToFollow);
        ntrk++;
@@ -833,7 +833,7 @@ Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) {
        //       fTrackToFollow.CookdEdx();
        CookdEdx(&fTrackToFollow);
 
-       CookLabel(&fTrackToFollow,0.0); //For comparison only
+       CookLabel(&fTrackToFollow,0.0); //For comparison only // RS why do we need this?
 
        //The beam pipe
        if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) {
@@ -3986,6 +3986,64 @@ void AliITStrackerMI::FlagFakes(const TObjArray &itsTracks)
   for (int i=6;i--;) delete refArr[i];
 }
 
+
+
+//------------------------------------------------------------------------
+void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const {
+  //--------------------------------------------------------------------
+  //This function "cooks" a track label. If label<0, this track is fake.
+  //--------------------------------------------------------------------
+  const int kMaxLbPerCl = 3;
+  int lbID[36],lbStat[36];
+  Int_t nLab=0, nCl = track->GetNumberOfClusters();
+  //
+  //  track->SetLabel(-1);
+  //  track->SetFakeRatio(0);
+  //
+  for (Int_t i=0;i<nCl;i++) { // fill all labels
+    Int_t cindex = track->GetClusterIndex(i);
+    //    Int_t l=(cindex & 0xf0000000) >> 28;
+    AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex);
+    //
+    for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
+      int trLb = cl->GetLabel(imc);
+      if (trLb<0) break;
+      // search this mc track in already accounted ones
+      int iLab;
+      for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
+      if (iLab<nLab) lbStat[iLab]++;
+      else {
+       lbID[nLab] = trLb;
+       lbStat[nLab++] = 1;
+      }
+    } // loop over given cluster's labels   
+  } // loop over clusters
+  //
+  if (nLab<1) return; // no labels at all
+  //
+  Int_t tpcLabel=-1; 
+  if (track->GetESDtrack() && track->GetESDtrack()->IsOn(AliESDtrack::kTPCin)){
+    tpcLabel = TMath::Abs(track->GetESDtrack()->GetTPCLabel());
+  }
+  //
+  // find majority label
+  if (nCl && nLab) {
+    int maxLab=0,tpcLabID=-1;
+    for (int ilb=nLab;ilb--;) {
+      int st = lbStat[ilb];
+      if (lbStat[maxLab]<st) maxLab = ilb;
+      if (lbID[ilb] == tpcLabel) tpcLabID = ilb;
+    }
+    // if there is an equal choice, prefer ITS label consistent with TPC label
+    if (tpcLabel>0 && (tpcLabID!=maxLab) && lbStat[maxLab]==lbStat[tpcLabID]) maxLab=tpcLabID;
+                                                                              
+    track->SetFakeRatio(1.-float(lbStat[maxLab])/nCl);
+    track->SetLabel( lbStat[maxLab]>=nCl-wrong ? lbID[maxLab] : -lbID[maxLab]);
+  }
+  //
+}
+
+/*
 //------------------------------------------------------------------------
 void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const {
   //--------------------------------------------------------------------
@@ -4020,9 +4078,10 @@ void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const {
    } else {
      track->SetLabel(tpcLabel);
    }
-   AliDebug(2,Form(" nls %d wrong %d  label %d  tpcLabel %d\n",nclusters,nwrong,track->GetLabel(),tpcLabel));
-   
+   AliDebug(2,Form(" nls %d wrong %d  label %d  tpcLabel %d\n",nclusters,nwrong,track->GetLabel(),tpcLabel)); 
 }
+*/
+
 //------------------------------------------------------------------------
 void AliITStrackerMI::CookdEdx(AliITStrackMI* track){
   //
@@ -5334,3 +5393,4 @@ Int_t AliITStrackerMI::AliITSlayer::FindClusterForLabel(Int_t label, Int_t *stor
   }
   return nfound;
 }
+
index 55fd6eb1e15190b417cad67304bb7af1db15fc33..091df0679d6e4b9d08c62c51863d662b026be9d7 100644 (file)
@@ -71,10 +71,8 @@ ClassImp(AliITSv11)
 //______________________________________________________________________
 AliITSv11::AliITSv11():
   fByThick(kTRUE),
-  fMajorVersion(IsVersion()),
-  fMinorVersion(-1),
   fIDMother(0),
-  fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
+  fInitGeom(kv11),
   fSPDgeom(0),
   fSDDgeom(0),
   fSSDgeom(0),
@@ -93,10 +91,8 @@ AliITSv11::AliITSv11():
 AliITSv11::AliITSv11(const char *title) 
   : AliITS("ITS", title),
     fByThick(kTRUE),
-    fMajorVersion(IsVersion()),
-    fMinorVersion(1),
     fIDMother(0),
-    fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
+    fInitGeom(kv11),
     fSPDgeom(0),
     fSDDgeom(0),
     fSSDgeom(0),
@@ -139,10 +135,8 @@ AliITSv11::AliITSv11(const char *title)
 AliITSv11::AliITSv11(const char *name, const char *title) 
   : AliITS("ITS", title),
     fByThick(kTRUE),
-    fMajorVersion(IsVersion()),
-    fMinorVersion(1),
     fIDMother(0),
-    fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
+    fInitGeom(kv11),
     fSPDgeom(0),
     fSDDgeom(0),
     fSSDgeom(0),
@@ -613,12 +607,9 @@ void AliITSv11::CreateGeometry()
   vALIC->AddNode(vITSS, 1, 0);
 
   //
-  const Char_t *cvsDate="$Date: 2013-07-05 15:19:21 +0200 (Fri, 05 Jul 2013) $";
-  const Char_t *cvsRevision="$Revision: 63353 $";
   const Int_t kLength=100;
   Char_t vstrng[kLength];
-  if(fInitGeom.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion(),
-                            fMinorVersion,cvsDate,cvsRevision)) {
+  if(fInitGeom.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion())){
     vITSV->SetTitle(vstrng);
     vITSS->SetTitle(vstrng);
   }
@@ -1566,8 +1557,6 @@ void AliITSv11::Init()
     // Return:
     //   none.
 
-    AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
-                fMinorVersion));
     UpdateInternalGeometry();
     AliITS::Init();
 
index 70537ac2992a25c2add3f0cbfac8f75a34dd3484..66df286d0afcc47b2a18a6a797254d422975423e 100644 (file)
@@ -53,18 +53,13 @@ class AliITSv11 : public AliITS {
     virtual void   Init(); 
     virtual void   SetDefaults();
     virtual void   StepManager();
-    virtual void   SetMinorVersion(Int_t v=2){ // Choose between existing minor versions
-       fMinorVersion = v;}
     virtual void SetDensityServicesByThickness(){// uses services density
        // calculation based on the thickness of the services.
        fByThick = kTRUE;}
     virtual void SetDensityServicesByMass(){// uses services density
        // calculation based on the Mass of the services.
        fByThick = kFALSE;}
-    virtual Int_t GetMajorVersion() const {// return Major Version Number
-       return fMajorVersion;}
-    virtual Int_t GetMinorVersion() const {// return Major Version Number
-       return fMinorVersion;}
+
 
  protected:
     void SetT2Lmatrix(Int_t uid, Double_t yShift,
@@ -76,8 +71,6 @@ class AliITSv11 : public AliITS {
 
     Bool_t fByThick;          // Flag to use services materials by thickness
                               // ture, or mass false.
-    Int_t  fMajorVersion;     // Major version number == IsVersion
-    Int_t  fMinorVersion;     // Minor version number
     Int_t  fIDMother;         //! ITS Mother Volume id.
 
     AliITSInitGeometry fInitGeom;   //! Get access to decoding and AliITSgeom init functions
@@ -86,7 +79,7 @@ class AliITSv11 : public AliITS {
     AliITSv11GeometrySSD     *fSSDgeom; //! SSD Geometry
     AliITSv11GeometrySupport *fSupgeom; //! Support Geometry
 
-    ClassDef(AliITSv11,3)  // ITS version 11 
+    ClassDef(AliITSv11,4)  // ITS version 11 
 };
  
 #endif
index 5fa6806ec5a062591d238141fca3ac354c9e9dab..16d32899d2cd29fa84db38c33157b816ed7d65d5 100644 (file)
@@ -44,7 +44,7 @@ using namespace TMath;
 
 ClassImp(AliITSUGeomTGeo)
 
-
+UInt_t AliITSUGeomTGeo::fgUIDShift = 16;                // bit shift to go from mod.id to modUUID for TGeo
 const char* AliITSUGeomTGeo::fgkITSVolName = "ITSV";
 const char* AliITSUGeomTGeo::fgkITSLrName  = "ITSULayer";
 const char* AliITSUGeomTGeo::fgkITSLadName = "ITSULadder";
@@ -525,9 +525,9 @@ TGeoPNEntry* AliITSUGeomTGeo::GetPNEntry(Int_t index) const
     AliError("Can't get the matrix! gGeoManager doesn't exist or it is still opened!");
     return NULL;
   }
-
-  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index));
-  if (!pne) AliError(Form("The symbolic volume name %s does not correspond to a physical entry!",GetSymName(index)));
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( ModuleVolUID(index) );
+  //  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index));
+  if (!pne) AliError(Form("The index %d does not correspond to a physical entry!",index));
   //
   return pne;
 }
@@ -574,6 +574,7 @@ Int_t AliITSUGeomTGeo::ExtractNumberOfLayers()
   //
   TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName);
   if (!itsV) AliFatal(Form("ITS volume %s is not in the geometry",fgkITSVolName));
+  SetUIDShift(itsV->GetUniqueID());
   //
   // Loop on all ITSV nodes, count Layer volumes by checking names
   // Build on the fly layer - wrapper correspondence
index 81c7459e22d3f8d6437bda4b6f631b6911f9b23f..1b6dbfc6278cae57584b8b69e19a33b425cca45c 100644 (file)
@@ -111,7 +111,10 @@ class AliITSUGeomTGeo : public TObject {
   const AliITSsegmentation* GetSegmentation(Int_t lr)                        const;
   TObjArray*          GetSegmentations()                                     const {return (TObjArray*)fSegm;}
   virtual void Print(Option_t *opt="")  const;
-
+  //
+  static      UInt_t GetUIDShift()                                      {return fgUIDShift;}
+  static      void   SetUIDShift(UInt_t s=16)                           {fgUIDShift = s<16 ? s:16;}
+  //
   static const char* GetITSVolPattern()                                 {return fgkITSVolName;}
   static const char* GetITSLayerPattern()                               {return fgkITSLrName;}
   static const char* GetITSWrapVolPattern()                             {return fgkITSWrapVolName;}
@@ -129,8 +132,8 @@ class AliITSUGeomTGeo : public TObject {
   static const char *ComposeSymNameModule(Int_t lr, Int_t lad, int det);
   //
   // hack to avoid using AliGeomManager
-  Int_t              LayerToVolUID(Int_t lay,int detInLay)        const {return GetModuleIndex(lay,detInLay);}
-  static Int_t       ModuleVolUID(Int_t mod)                            {return mod;}
+  Int_t              LayerToVolUID(Int_t lay,int detInLay)        const {return ModuleVolUID(GetModuleIndex(lay,detInLay));}
+  static Int_t       ModuleVolUID(Int_t mod)                            {return (mod&0xffff)<<fgUIDShift;}
   //
  protected:
   void         FetchMatrices();
@@ -161,6 +164,7 @@ class AliITSUGeomTGeo : public TObject {
   TObjArray* fMatT2L;          // Tracking to Local matrices pointers in the geometry
   TObjArray* fSegm;            // segmentations
   //
+  static       UInt_t fgUIDShift;                // bit shift to go from mod.id to modUUID for TGeo
   static const char*  fgkITSVolName;             // ITS mother volume name
   static const char*  fgkITSLrName;              // ITS Layer name
   static const char*  fgkITSLadName;             // ITS Ladder name 
@@ -171,7 +175,7 @@ class AliITSUGeomTGeo : public TObject {
   //
   static TString      fgITSsegmFileName;         // file name for segmentations
   //
-  ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
+  ClassDef(AliITSUGeomTGeo, 2) // ITS geometry based on TGeo
 };
 
 //_____________________________________________________________________________________________
diff --git a/ITS/UPGRADE/AliITSUInitGeometry.cxx b/ITS/UPGRADE/AliITSUInitGeometry.cxx
deleted file mode 100644 (file)
index c7dfa71..0000000
+++ /dev/null
@@ -1,1285 +0,0 @@
-/**************************************************************************
- * 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.                  *
- **************************************************************************/
-
-/*
-$Id: AliITSUInitGeometry.cxx $
-*/
-////////////////////////////////////////////////////////////////
-//  This class initializes the class AliITSgeom
-//  The initialization is done starting from 
-//  a geometry coded by means of the ROOT geometrical modeler
-//  This initialization can be used both for simulation and reconstruction
-///////////////////////////////////////////////////////////////
-
-#include <TArrayD.h>
-#include <TArrayF.h>
-#include <TStopwatch.h>
-#include <TGeoManager.h>
-#include <TGeoMatrix.h>
-#include <TGeoVolume.h>
-#include <TGeoShape.h>
-#include <TGeoBBox.h>
-#include <TGeoTrd1.h>
-#include <TGeoTrd2.h>
-#include <TGeoArb8.h>
-#include <TGeoTube.h>
-#include <TGeoCone.h>
-#include <TGeoSphere.h>
-#include <TGeoPara.h>
-#include <TGeoPgon.h>
-#include <TGeoPcon.h>
-#include <TGeoEltu.h>
-#include <TGeoHype.h>
-#include <TMath.h>
-
-#include "AliLog.h"
-#include "AliITSUGeomTGeo.h"
-#include "AliITSUInitGeometry.h"
-#include <TDatime.h>
-using namespace TMath;
-
-ClassImp(AliITSUInitGeometry)
-
-//______________________________________________________________________
-AliITSUInitGeometry::AliITSUInitGeometry()
-: TObject()
-  ,fName(0)
-  ,fTiming(kFALSE)
-  ,fDebug(0)
-{  
-}
-
-//______________________________________________________________________
-AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom()
-{
-  // Creates and Initilizes the geometry transformation class AliITSgeom
-  // to values appropreate to this specific geometry. Now that
-  // the segmentation is part of AliITSgeom, the detector
-  // segmentations are also defined here.
-  //
-
-  AliITSVersion_t version = kvDefault;
-  Int_t minor = 0;
-  TDatime datetime;
-  TGeoVolume *itsV = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
-  if(!itsV){
-    Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
-    return 0;
-  }// end if
-
-  SetTiming(kFALSE);
-  SetSegGeom(kFALSE);
-  SetDecoding(kFALSE);
-  AliITSgeom *geom = CreateAliITSgeom(version,minor);
-  AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
-  return geom;
-}
-
-//______________________________________________________________________
-AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
-    // Creates and Initilizes the geometry transformation class AliITSgeom
-    // to values appropreate to this specific geometry. Now that
-    // the segmentation is part of AliITSgeom, the detector
-    // segmentations are also defined here.
-    // Inputs:
-    //   Int_t major   major version, see AliITSVersion_t
-    //   Int_t minor   minor version
-    // Outputs:
-    //   none.
-    // Return:
-    //   A pointer to a new properly inilized AliITSgeom class. If
-    //   pointer = 0 then failed to init.
-
-    switch(major){
-    case kv11:
-        SetGeometryName("AliITSv11");
-        SetVersion(kv11,minor);
-        break;
-    case kvUpgrade:
-        SetGeometryName("AliITSUv11");
-        SetVersion(kvUpgrade,minor);
-        break;
-    case kvDefault:
-    default:
-        SetGeometryName("Undefined");
-        SetVersion(kvDefault,minor);
-        break;
-    } // end switch
-    AliITSgeom *geom = new AliITSgeom();
-    if(!InitAliITSgeom(geom)){ // Error initilization failed
-       delete geom;
-       geom = 0;
-    } // end if
-    return geom;
-}
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::InitAliITSgeom(AliITSgeom *geom){
-  // Initilizes the geometry transformation class AliITSgeom
-  // to values appropreate to this specific geometry. Now that
-  // the segmentation is part of AliITSgeom, the detector
-  // segmentations are also defined here.
-  // Inputs:
-  //   AliITSgeom *geom  A pointer to the AliITSgeom class
-  // Outputs:
-  //   AliITSgeom *geom  This pointer recreated and properly inilized.
-  // Return:
-  //   none.
-
-    if(!gGeoManager){
-        AliFatal("The geometry manager has not been initialized (e.g. "
-                 "TGeoManager::Import(\"geometry.root\")should be "
-                 "called in advance) - exit forced");
-        return kFALSE;
-    } // end if
-    switch(fMajorVersion) {
-    case kv11: {
-        return InitAliITSgeomV11(geom);
-    } break; // end case
-    case kvUpgrade: {
-        return InitAliITSgeomVUpgrade(geom);
-    } break; // end case
-    case kvDefault: default: {
-        AliFatal("Undefined geometry");
-        return kFALSE;
-    } break; // end case
-    } // end switch
-    return kFALSE;
-}
-//______________________________________________________________________
-void AliITSUInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
-    // Transpose the rotation matrix part of a TGeoHMatrix. This
-    // is needed because TGeo stores the transpose of the rotation
-    // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
-    // Inputs:
-    //    TGeoHMatrix *m  The matrix to be transposed
-    // Outputs:
-    //    TGEoHMatrix *m  The transposed matrix
-    // Return:
-    //    none.
-    Int_t i;
-    Double_t r[9];
-
-    if(m==0) return; // no matrix to transpose.
-    for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
-    r[1] = m->GetRotationMatrix()[3];
-    r[2] = m->GetRotationMatrix()[6];
-    r[3] = m->GetRotationMatrix()[1];
-    r[5] = m->GetRotationMatrix()[7];
-    r[6] = m->GetRotationMatrix()[2];
-    r[7] = m->GetRotationMatrix()[5];
-    m->SetRotation(r);
-    return;
-}
-
-
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
-  // Initilizes the geometry transformation class AliITSgeom
-  // Now that the segmentation is part of AliITSgeom, the detector
-  // segmentations are also defined here.
-  //
-  // Inputs:
-  //   AliITSgeom *geom  A pointer to the AliITSgeom class
-  // Outputs:
-  //   AliITSgeom *geom  This pointer recreated and properly inilized.
-  // LG
-
-  const Int_t kItype  = 0; // Type of transformation defined 0=> Geant
-  const Int_t klayers = 6; // number of layers in the ITS
-  const Int_t kladders[klayers]   = {20,40,14,22,34,38}; // Number of ladders
-  const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
-  const AliITSDetector kIdet[6]   = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
-  const TString kPathbase = "/ALIC_1/ITSV_1/";
-
-  const char *pathSPDsens1, *pathSPDsens2;
-  pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
-  pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
-
-  const char *pathSDDsens1, *pathSDDsens2;
-  pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
-  pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
-
-  const char *pathSSDsens1, *pathSSDsens2;
-  pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
-  pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
-
-  const TString kNames[klayers] = {
-    pathSPDsens1, // lay=1
-    pathSPDsens2, // lay=2
-    pathSDDsens1, // lay=3
-    pathSDDsens2, // lay=4
-    pathSSDsens1, // lay=5
-    pathSSDsens2};// Lay=6
-  
-  Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
-  Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
-  TArrayD shapePar;
-  TString path, shapeName;
-  TGeoHMatrix matrix;
-  Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
-  TStopwatch *time = 0x0;
-  if(fTiming) time = new TStopwatch();
-
-  if(fTiming) time->Start();
-  for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
-  geom->Init(kItype,klayers,kladders,kdetectors,nmods);
-
-  for(mod=0; mod<nmods; mod++) {
-
-    DecodeDetectorLayers(mod,lay,lad,det);
-    geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
-    RecodeDetector(mod,cpn0,cpn1,cpn2);
-
-    if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
-      if (det<3) cpnHS = 0; else cpnHS = 1;
-      path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
-    } else {
-      path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
-    };
-
-    geom->GetGeomMatrix(mod)->SetPath(path);
-    GetTransformation(path.Data(),matrix);
-    geom->SetTrans(mod,matrix.GetTranslation());
-    TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
-    geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
-    if(initSeg[kIdet[lay-1]]) continue;
-    GetShape(path,shapeName,shapePar);
-    if(shapeName.CompareTo("BOX")){
-      Error("InitITSgeom","Geometry changed without proper code update"
-           "or error in reading geometry. Shape is not BOX.");
-      return kFALSE;
-    } // end if
-  } // end for module
-
-  if(fTiming){
-    time->Stop();
-    time->Print();
-    delete time;
-  } // end if
-  return kTRUE;
-}
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::InitAliITSgeomVUpgrade(AliITSgeom *geom){
-  // Initilizes the geometry transformation class AliITSgeom
-  // Now that the segmentation is part of AliITSgeom, the detector
-  // segmentations are also defined here.
-  //
-  // Inputs:
-  //   AliITSgeom *geom  A pointer to the AliITSgeom class
-  // Outputs:
-  //   AliITSgeom *geom  This pointer recreated and properly inilized.
-  // LG
-
-  const Int_t kItype  = 0; // Type of transformation defined 0=> Geant
-  const Int_t klayers = GetNumberOfLayers(); // Number of layers in the ITS
-  const AliITSDetector kIdet = AliITSDetector(0); //kUPG; RS temporary
-  if (klayers <= 0) {
-    AliError("No layers found in ITSV");
-    return kFALSE;
-  }
-
-  Int_t *kladders = new Int_t[klayers];      // Number of ladders
-  Int_t *kdetectors = new Int_t[klayers];    // Number of detectors/ladder
-
-  for (Int_t j=0; j<klayers; j++) {
-    kladders[j] = GetNumberOfLadders(j);
-    kdetectors[j] = GetNumberOfModules(j);
-  }
-  const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern());
-  const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
-                             ,AliITSUGeomTGeo::GetITSLayerPattern()
-                             ,AliITSUGeomTGeo::GetITSLadderPattern()
-                             ,AliITSUGeomTGeo::GetITSModulePattern()
-                             ,AliITSUGeomTGeo::GetITSSensorPattern()
-                             );
-  Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2;
-  Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
-  TArrayD shapePar;
-  TString path, shapeName;
-  TGeoHMatrix matrix;
-//  Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
-  TStopwatch *time = 0x0;
-  if(fTiming) time = new TStopwatch();
-
-  if(fTiming) time->Start();
-  for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
-  geom->Init(kItype,klayers,kladders,kdetectors,nmods);
-
-  for(mod=0; mod<nmods; mod++) {
-
-    DecodeDetectorLayers(mod,lay,lad,det);
-    geom->CreateMatrix(mod,lay,lad,det,kIdet,tran,rot);
-    RecodeDetector(mod,cpn0,cpn1,cpn2);
-
-    path.Form(kNames.Data(),kPathBase.Data(),lay,lay,cpn0,lay,cpn1,lay,cpn2);
-
-    geom->GetGeomMatrix(mod)->SetPath(path);
-    GetTransformation(path.Data(),matrix);
-    geom->SetTrans(mod,matrix.GetTranslation());
-    TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
-    geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
-//    if(initSeg[kIdet[lay-1]]) continue;
-    GetShape(path,shapeName,shapePar);
-    if(shapeName.CompareTo("BOX")){
-      Error("InitITSgeom","Geometry changed without proper code update"
-           "or error in reading geometry. Shape is not BOX.");
-      return kFALSE;
-    } // end if
-  } // end for module
-
-  if(fTiming){
-    time->Stop();
-    time->Print();
-    delete time;
-  } // end if
-  return kTRUE;
-}
-
-//_______________________________________________________________________
-Bool_t AliITSUInitGeometry::GetTransformation(const TString &volumePath,
-                                            TGeoHMatrix &mat){
-    // Returns the Transformation matrix between the volume specified
-    // by the path volumePath and the Top or mater volume. The format
-    // of the path volumePath is as follows (assuming ALIC is the Top volume)
-    // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
-    // or master volume which has only 1 instance of. Of all of the daughter
-    // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
-    // the daughter volume of DDIP is S05I copy #2 and so on.
-    // Inputs:
-    //   TString& volumePath  The volume path to the specific volume
-    //                        for which you want the matrix. Volume name
-    //                        hierarchy is separated by "/" while the
-    //                        copy number is appended using a "_".
-    // Outputs:
-    //  TGeoHMatrix &mat      A matrix with its values set to those
-    //                        appropriate to the Local to Master transformation
-    // Return:
-    //   A logical value if kFALSE then an error occurred and no change to
-    //   mat was made.
-
-    // We have to preserve the modeler state
-
-    // Preserve the modeler state.
-    gGeoManager->PushPath();
-    if (!gGeoManager->cd(volumePath.Data())) {
-      gGeoManager->PopPath();
-      Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
-      return kFALSE;
-    } // end if !gGeoManager
-    mat = *gGeoManager->GetCurrentMatrix();
-    // Retstore the modeler state.
-    gGeoManager->PopPath();
-    return kTRUE;
-}
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::GetShape(const TString &volumePath,
-                                   TString &shapeType,TArrayD &par){
-    // Returns the shape and its parameters for the volume specified
-    // by volumeName.
-    // Inputs:
-    //   TString& volumeName  The volume name
-    // Outputs:
-    //   TString &shapeType   Shape type
-    //   TArrayD &par         A TArrayD of parameters with all of the
-    //                        parameters of the specified shape.
-    // Return:
-    //   A logical indicating whether there was an error in getting this
-    //   information
-    Int_t npar;
-    gGeoManager->PushPath();
-    if (!gGeoManager->cd(volumePath.Data())) {
-       gGeoManager->PopPath();
-       return kFALSE;
-    }
-    TGeoVolume * vol = gGeoManager->GetCurrentVolume();
-    gGeoManager->PopPath();
-    if (!vol) return kFALSE;
-    TGeoShape *shape = vol->GetShape();
-    TClass *classType = shape->IsA();
-    if (classType==TGeoBBox::Class()) {
-       shapeType = "BOX";
-       npar = 3;
-       par.Set(npar);
-       TGeoBBox *box = (TGeoBBox*)shape;
-       par.AddAt(box->GetDX(),0);
-       par.AddAt(box->GetDY(),1);
-       par.AddAt(box->GetDZ(),2);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoTrd1::Class()) {
-       shapeType = "TRD1";
-       npar = 4;
-       par.Set(npar);
-       TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
-       par.AddAt(trd1->GetDx1(),0);
-       par.AddAt(trd1->GetDx2(),1);
-       par.AddAt(trd1->GetDy(), 2);
-       par.AddAt(trd1->GetDz(), 3);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoTrd2::Class()) {
-       shapeType = "TRD2";
-       npar = 5;
-       par.Set(npar);
-       TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
-       par.AddAt(trd2->GetDx1(),0);
-       par.AddAt(trd2->GetDx2(),1);
-       par.AddAt(trd2->GetDy1(),2);
-       par.AddAt(trd2->GetDy2(),3);
-       par.AddAt(trd2->GetDz(), 4);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoTrap::Class()) {
-       shapeType = "TRAP";
-       npar = 11;
-       par.Set(npar);
-       TGeoTrap *trap = (TGeoTrap*)shape;
-       Double_t tth = Tan(trap->GetTheta()*DegToRad());
-       par.AddAt(trap->GetDz(),0);
-       par.AddAt(tth*Cos(trap->GetPhi()*DegToRad()),1);
-       par.AddAt(tth*Sin(trap->GetPhi()*DegToRad()),2);
-       par.AddAt(trap->GetH1(),3);
-       par.AddAt(trap->GetBl1(),4);
-       par.AddAt(trap->GetTl1(),5);
-       par.AddAt(Tan(trap->GetAlpha1()*DegToRad()),6);
-       par.AddAt(trap->GetH2(),7);
-       par.AddAt(trap->GetBl2(),8);
-       par.AddAt(trap->GetTl2(),9);
-       par.AddAt(Tan(trap->GetAlpha2()*DegToRad()),10);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoTube::Class()) {
-       shapeType = "TUBE";
-       npar = 3;
-       par.Set(npar);
-       TGeoTube *tube = (TGeoTube*)shape;
-       par.AddAt(tube->GetRmin(),0);
-       par.AddAt(tube->GetRmax(),1);
-       par.AddAt(tube->GetDz(),2);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoTubeSeg::Class()) {
-       shapeType = "TUBS";
-       npar = 5;
-       par.Set(npar);
-       TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
-       par.AddAt(tubs->GetRmin(),0);
-       par.AddAt(tubs->GetRmax(),1);
-       par.AddAt(tubs->GetDz(),2);
-       par.AddAt(tubs->GetPhi1(),3);
-       par.AddAt(tubs->GetPhi2(),4);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoCone::Class()) {
-       shapeType = "CONE";
-       npar = 5;
-       par.Set(npar);
-       TGeoCone *cone = (TGeoCone*)shape;
-       par.AddAt(cone->GetDz(),0);
-       par.AddAt(cone->GetRmin1(),1);
-       par.AddAt(cone->GetRmax1(),2);
-       par.AddAt(cone->GetRmin2(),3);
-       par.AddAt(cone->GetRmax2(),4);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoConeSeg::Class()) {
-       shapeType = "CONS";
-       npar = 7;
-       par.Set(npar);
-       TGeoConeSeg *cons = (TGeoConeSeg*)shape;
-       par.AddAt(cons->GetDz(),0);
-       par.AddAt(cons->GetRmin1(),1);
-       par.AddAt(cons->GetRmax1(),2);
-       par.AddAt(cons->GetRmin2(),3);
-       par.AddAt(cons->GetRmax2(),4);
-       par.AddAt(cons->GetPhi1(),5);
-       par.AddAt(cons->GetPhi2(),6);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoSphere::Class()) {
-       shapeType = "SPHE";
-       npar = 6;
-       par.Set(npar);
-       
-       TGeoSphere *sphe = (TGeoSphere*)shape;
-       par.AddAt(sphe->GetRmin(),0);
-       par.AddAt(sphe->GetRmax(),1);
-       par.AddAt(sphe->GetTheta1(),2);
-       par.AddAt(sphe->GetTheta2(),3);
-       par.AddAt(sphe->GetPhi1(),4);
-       par.AddAt(sphe->GetPhi2(),5);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoPara::Class()) {
-       shapeType = "PARA";
-       npar = 6;
-       par.Set(npar);
-       TGeoPara *para = (TGeoPara*)shape;
-       par.AddAt(para->GetX(),0);
-       par.AddAt(para->GetY(),1);
-       par.AddAt(para->GetZ(),2);
-       par.AddAt(para->GetTxy(),3);
-       par.AddAt(para->GetTxz(),4);
-       par.AddAt(para->GetTyz(),5);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoPgon::Class()) {
-       shapeType = "PGON";
-       TGeoPgon *pgon = (TGeoPgon*)shape;
-       Int_t nz = pgon->GetNz();
-       const Double_t *rmin = pgon->GetRmin();
-       const Double_t *rmax = pgon->GetRmax();
-       const Double_t *z = pgon->GetZ();
-       npar = 4 + 3*nz;
-       par.Set(npar);
-       par.AddAt(pgon->GetPhi1(),0);
-       par.AddAt(pgon->GetDphi(),1);
-       par.AddAt(pgon->GetNedges(),2);
-       par.AddAt(pgon->GetNz(),3);
-       for (Int_t i=0; i<nz; i++) {
-           par.AddAt(z[i], 4+3*i);
-           par.AddAt(rmin[i], 4+3*i+1);
-           par.AddAt(rmax[i], 4+3*i+2);
-       }
-       return kTRUE;
-    } // end if
-    if (classType==TGeoPcon::Class()) {
-       shapeType = "PCON";
-       TGeoPcon *pcon = (TGeoPcon*)shape;
-       Int_t nz = pcon->GetNz();
-       const Double_t *rmin = pcon->GetRmin();
-       const Double_t *rmax = pcon->GetRmax();
-       const Double_t *z = pcon->GetZ();
-       npar = 3 + 3*nz;
-       par.Set(npar);
-       par.AddAt(pcon->GetPhi1(),0);
-       par.AddAt(pcon->GetDphi(),1);
-       par.AddAt(pcon->GetNz(),2);
-       for (Int_t i=0; i<nz; i++) {
-           par.AddAt(z[i], 3+3*i);
-           
-           par.AddAt(rmin[i], 3+3*i+1);
-           par.AddAt(rmax[i], 3+3*i+2);
-       }
-       return kTRUE;
-    } // end if
-    if (classType==TGeoEltu::Class()) {
-       shapeType = "ELTU";
-       npar = 3;
-       par.Set(npar);
-       TGeoEltu *eltu = (TGeoEltu*)shape;
-       par.AddAt(eltu->GetA(),0);
-       par.AddAt(eltu->GetB(),1);
-       par.AddAt(eltu->GetDz(),2);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoHype::Class()) {
-       shapeType = "HYPE";
-       npar = 5;
-       par.Set(npar);
-       TGeoHype *hype = (TGeoHype*)shape;
-       par.AddAt(Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
-       par.AddAt(Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
-       par.AddAt(hype->GetDZ(),2);
-       par.AddAt(hype->GetStIn(),3);
-       par.AddAt(hype->GetStOut(),4);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoGtra::Class()) {
-       shapeType = "GTRA";
-       npar = 12;
-       par.Set(npar);
-       TGeoGtra *trap = (TGeoGtra*)shape;
-       Double_t tth = Tan(trap->GetTheta()*DegToRad());
-       par.AddAt(trap->GetDz(),0);
-       par.AddAt(tth*Cos(trap->GetPhi()*DegToRad()),1);
-       par.AddAt(tth*Sin(trap->GetPhi()*DegToRad()),2);
-       par.AddAt(trap->GetH1(),3);
-       par.AddAt(trap->GetBl1(),4);
-       par.AddAt(trap->GetTl1(),5);
-       par.AddAt(Tan(trap->GetAlpha1()*DegToRad()),6);
-       par.AddAt(trap->GetH2(),7);
-       par.AddAt(trap->GetBl2(),8);
-       par.AddAt(trap->GetTl2(),9);
-       par.AddAt(Tan(trap->GetAlpha2()*DegToRad()),10);
-       par.AddAt(trap->GetTwistAngle(),11);
-       return kTRUE;
-    } // end if
-    if (classType==TGeoCtub::Class()) {
-       shapeType = "CTUB";
-       npar = 11;
-       par.Set(npar);
-       TGeoCtub *ctub = (TGeoCtub*)shape;
-       const Double_t *lx = ctub->GetNlow();
-       const Double_t *tx = ctub->GetNhigh();
-       par.AddAt(ctub->GetRmin(),0);
-       par.AddAt(ctub->GetRmax(),1);
-       par.AddAt(ctub->GetDz(),2);
-       par.AddAt(ctub->GetPhi1(),3);
-       par.AddAt(ctub->GetPhi2(),4);
-       par.AddAt(lx[0],5);
-       par.AddAt(lx[1],6);
-       par.AddAt(lx[2],7);
-       par.AddAt(tx[0],8);
-       par.AddAt(tx[1],9);
-       par.AddAt(tx[2],10);
-       return kTRUE;
-    } // end if
-    Error("GetShape","Getting shape parameters for shape %s not implemented",
-         shape->ClassName());
-    shapeType = "Unknown";
-    return kFALSE;
-}
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetector(
-    Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
-    // decode geometry into detector module number. There are two decoding
-    // Scheams. Old which does not follow the ALICE coordinate system
-    // requirements, and New which dose.
-    // Inputs:
-    //    Int_t layer    The ITS layer
-    //    Int_t cpn0     The lowest copy number
-    //    Int_t cpn1     The middle copy number
-    //    Int_t cpn2     the highest copy number
-    // Output:
-    //    Int_t &mod     The module number assoicated with this set
-    //                   of copy numbers.
-    // Return:
-    //    none.
-
-    // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't 
-    // like them but I see not better way for the moment.
-    switch (fMajorVersion){
-    case kvDefault:{
-        Error("DecodeDetector","Major version = kvDefault, not supported");
-    }break;
-    case kv11:{
-        return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
-    }break;
-    case kvUpgrade:{
-        return DecodeDetectorvUpgrade(mod,layer,cpn0,cpn1,cpn2);
-    }break;
-    default:{
-        Error("DecodeDetector","Major version = %d, not supported",
-              (Int_t)fMajorVersion);
-        return;
-    }break;
-    } // end switch
-    return;
-}
-//______________________________________________________________________
-void AliITSUInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
-                                        Int_t &cpn1,Int_t &cpn2){
-    // decode geometry into detector module number. There are two decoding
-    // Scheams. Old which does not follow the ALICE coordinate system
-    // requirements, and New which dose.
-    // Inputs:
-    //    Int_t mod      The module number assoicated with this set
-    //                   of copy numbers.
-    // Output:
-    //    Int_t cpn0     The lowest copy number
-    //    Int_t cpn1     The middle copy number
-    //    Int_t cpn2     the highest copy number
-    // Return:
-    //    none.
-
-    // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't 
-    // like them but I see not better way for the moment.
-    switch (fMajorVersion){
-    case kvDefault:{
-        Error("RecodeDetector","Major version = kvDefault, not supported");
-        return;
-    }
-    case kv11:{
-        return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
-    }break;
-    case kvUpgrade:{
-        return RecodeDetectorvUpgrade(mod,cpn0,cpn1,cpn2);
-    }break;
-    default:{
-        Error("RecodeDetector","Major version = %d, not supported",
-              (Int_t)fMajorVersion);
-        return;
-    }break;
-    } // end switch
-    return;
-}
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
-                                              Int_t &lad,Int_t &det){
-    // decode geometry into detector module number. There are two decoding
-    // Scheams. Old which does not follow the ALICE coordinate system
-    // requirements, and New which dose. Note, this use of layer ladder
-    // and detector numbers are strictly for internal use of this
-    // specific code. They do not represent the "standard" layer ladder
-    // or detector numbering except in a very old and obsoleate sence.
-    // Inputs:
-    //    Int_t mod      The module number assoicated with this set
-    //                   of copy numbers.
-    // Output:
-    //    Int_t lay     The layer number
-    //    Int_t lad     The ladder number
-    //    Int_t det     the dettector number
-    // Return:
-    //    none.
-
-    // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't 
-    // like them but I see not better way for the moment.
-    switch (fMajorVersion) {
-    case kvDefault:{
-        Error("DecodeDetectorLayers",
-              "Major version = kvDefault, not supported");
-        return;
-    }break;
-    case kv11:{
-        return DecodeDetectorLayersv11(mod,layer,lad,det);
-    }break;
-    case kvUpgrade:{
-        return DecodeDetectorLayersvUpgrade(mod,layer,lad,det);
-    }break;
-    default:{
-        Error("DecodeDetectorLayers","Major version = %d, not supported",
-              (Int_t)fMajorVersion);
-        return;
-    }break;
-    } // end switch
-    return;
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
-                                 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
-    // decode geometry into detector module number
-    // Inputs:
-    //    Int_t layer    The ITS layer
-    //    Int_t cpn0     The lowest copy number
-    //    Int_t cpn1     The middle copy number
-    //    Int_t cpn2     the highest copy number
-    // Output:
-    //    Int_t &mod     The module number assoicated with this set
-    //                   of copy numbers.
-    // Return:
-    //    none.
-  const Int_t kDetPerLadderSPD[2]={2,4};
-  const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
-  const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
-  Int_t lad=-1,det=-1;
-  
-  switch(layer) {
-  case 1: case 2:{
-    lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
-    det = cpn2;
-  } break;
-  case 3: case 4:{
-    lad = cpn0+1;
-    det = cpn1+1;
-  } break;
-  case 5: case 6:{
-    lad = cpn0+1;
-    det = cpn1+1;
-  } break;
-  default:{
-  } break;
-  } // end switch
-  mod = 0;
-  for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
-  mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
-  return;
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer,
-                                 Int_t cpn0,Int_t cpn1,Int_t /*cpn2*/) const {
-    // decode geometry into detector module number
-    // Inputs:
-    //    Int_t layer    The ITS layer
-    //    Int_t cpn0     The lowest copy number
-    //    Int_t cpn1     The middle copy number
-    //    Int_t cpn2     the highest copy number
-    // Output:
-    //    Int_t &mod     The module number assoicated with this set
-    //                   of copy numbers.
-    // Return:
-    //    none.
-    // MS 23jun11
-  Int_t lad=-1,det=-1;
-  layer--; // starts from 1!
-  lad = cpn0;
-  det = cpn1;
-  mod = 0;
-  for(Int_t i=0;i<layer;i++) mod += GetNumberOfLadders(i)*GetNumberOfModules(i);
-  mod += GetNumberOfModules(layer)*(lad-1)+det-1;// module start at zero.
-  return;
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
-                                          Int_t &cpn1,Int_t &cpn2) {
-    // decode geometry into detector module number using the new decoding
-    // Scheme.
-    // Inputs:
-    //    Int_t mod      The module number assoicated with this set
-    //                   of copy numbers.
-    // Output:
-    //    Int_t cpn0     The lowest copy number  (SPD sector or SDD/SSD ladder)
-    //    Int_t cpn1     The middle copy number  (SPD stave or SDD/SSD module)
-    //    Int_t cpn2     the highest copy number (SPD ladder or 1 for SDD/SSD)
-    // Return:
-    //    none.
-    const Int_t kDetPerLadderSPD[2]={2,4};
-    Int_t lay,lad,det;
-
-    DecodeDetectorLayersv11(mod,lay,lad,det);
-    if (lay<3) { // SPD
-        cpn2 = det;     // Detector 1-4
-        cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
-        cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
-    } else { // SDD and SSD
-        cpn2 = 1;
-        cpn1 = det;
-        cpn0 = lad;
-        if (lay<5) { // SDD
-         cpn1--;
-         cpn0--;
-        } else { //SSD
-         cpn1--;
-         cpn0--;
-        } // end if Lay<5/else
-    } // end if lay<3/else
-    /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
-           "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
-           mod,lay,lad,det,cpn0,cpn1,cpn2);*/
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,
-                                               Int_t &cpn1,Int_t &cpn2) {
-    // decode geometry into detector module number using the new decoding
-    // Scheme.
-    // Inputs:
-    //    Int_t mod      The module number assoicated with this set
-    //                   of copy numbers.
-    // Output:
-    //    Int_t cpn0     The lowest copy number  (ladder)
-    //    Int_t cpn1     The middle copy number  (module)
-    //    Int_t cpn2     the highest copy number (sensor - always 1 for now)
-    // Return:
-    //    none.
-    // MS - 23jun11 - cross your fingers and hope for the best
-    Int_t lay,lad,det;
-
-    DecodeDetectorLayersvUpgrade(mod,lay,lad,det);
-    cpn2 = 1;
-    cpn1 = det;
-    cpn0 = lad;
-//    cpn1--;
-//    cpn0--;
-    /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
-           "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
-           mod,lay,lad,det,cpn0,cpn1,cpn2);*/
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
-                                                Int_t &lad,Int_t &det) {
-
-  // decode module number into detector indices for v11
-  // mod starts from 0
-  // lay, lad, det start from 1
-
-  // Inputs:
-  //    Int_t mod      The module number associated with this set
-  //                   of copy numbers.
-  // Output:
-  //    Int_t lay     The layer number
-  //    Int_t lad     The ladder number
-  //    Int_t det     the dettector number
-
-  const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
-  const Int_t kLadPerLayer[6]  = {20,40,14,22,34,38};
-  
-  Int_t mod2 = 0;
-  lay  = 0;
-  
-  do {
-    mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
-    lay++;
-  } while(mod2<=mod); // end while
-  if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
-
-  mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
-  lad = mod2/kDetPerLadder[lay-1];
-
-  if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
-                                     "lad=%d not in the correct range",lad);
-  det = (mod2 - lad*kDetPerLadder[lay-1])+1;
-  if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
-                                     "det=%d not in the correct range",det);
-  lad++;
-}
-
-//______________________________________________________________________
-void AliITSUInitGeometry::DecodeDetectorLayersvUpgrade(Int_t  mod,Int_t &lay,
-                                                     Int_t &lad,Int_t &det){
-
-  // decode module number into detector indices for vUpgrade
-  // mod starts from 0
-  // lay, lad, det start from 1
-
-  // Inputs:
-  //    Int_t mod      The module number associated with this set
-  //                   of copy numbers.
-  // Output:
-  //    Int_t lay     The layer number
-  //    Int_t lad     The ladder number
-  //    Int_t det     the dettector number
-  // MS - 22jun11
-
-  const Int_t kLayers = GetNumberOfLayers();
-  
-  Int_t mod2 = 0;
-  lay  = 0;
-  
-  do {
-    mod2 += GetNumberOfLadders(lay)*GetNumberOfModules(lay);
-    lay++;
-  } while(mod2<=mod); // end while
-  if(lay>kLayers) Error("DecodeDetectorLayers","lay=%d>%d",lay,kLayers);
-
-  mod2 = GetNumberOfLadders(lay-1)*GetNumberOfModules(lay-1) - mod2+mod;
-  lad = mod2/GetNumberOfModules(lay-1);
-
-  if(lad>=GetNumberOfLadders(lay-1)||lad<0) Error("DecodeDetectorLayers",
-                                     "lad=%d not in the correct range",lad);
-  det = (mod2 - lad*GetNumberOfModules(lay-1))+1;
-  if(det>GetNumberOfModules(lay-1)||det<1) Error("DecodeDetectorLayers",
-
-                                     "det=%d not in the correct range",det);
-  //  lay--;
-  lad++;
-}
-
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::WriteVersionString(Char_t *str,Int_t length,
-                        AliITSVersion_t maj,Int_t min,
-                        const Char_t *cvsDate,const Char_t *cvsRevision)const{
-    // fills the string str with the major and minor version number
-    // Inputs:
-    //   Char_t *str          The character string to hold the major 
-    //                        and minor version numbers in
-    //   Int_t  length        The maximum number of characters which 
-    //                        can be accomidated by this string. 
-    //                        str[length-1] must exist and will be set to zero
-    //   AliITSVersion_t maj  The major number
-    //   Int_t           min  The minor number
-    //   Char_t *cvsDate      The date string from cvs
-    //   Char_t *cvsRevision  The Revision string from cvs
-    // Outputs:
-    //   Char_t *str          The character string holding the major and minor
-    //                        version numbers. str[length-1] must exist
-    //                        and will be set to zero
-    // Return:
-    //   kTRUE if no errors
-    Char_t cvslikedate[30];
-    Int_t i,n,cvsDateLength,cvsRevisionLength;
-
-    cvsDateLength = (Int_t)strlen(cvsDate);
-    if(cvsDateLength>30){ // svn string, make a cvs like string
-        i=0;n=0;
-        do{
-            cvslikedate[i] = cvsDate[i];
-            if(cvsDate[i]=='+' || cvsDate[i++]=='-'){
-                n++; // count number of -
-                cvslikedate[i-1] = '/'; // replace -'s by /'s.
-            } // end if
-        } while(n<3&&i<30); // once additonal - of time zone reach exit
-        cvslikedate[i-1] = '$'; // put $ at end then zero.
-        for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off.
-    }else{
-        for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i];
-    }// end if
-    cvsDateLength = (Int_t)strlen(cvslikedate);
-    cvsRevisionLength = (Int_t)strlen(cvsRevision);
-    i = (Int_t)maj;
-    n = 50+(Int_t)(Log10(Abs((Double_t)i)))+1+
-        (Int_t)(Log10(Abs((Double_t)min)))+1
-        +cvsDateLength-6+cvsRevisionLength-10;
-    if(GetDebug()>1) printf("AliITSUInitGeometry::WriteVersionString:"
-                        "length=%d major=%d minor=%d cvsDate=%s[%d] "
-                        "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
-                        cvsDateLength,cvsRevision,cvsRevisionLength,n);
-    if(i<0) n++;
-    if(min<0) n++;
-    if(length<n){// not enough space to write in output string.
-        Warning("WriteVersionString","Output string not long enough "
-                "lenght=%d must be at least %d long\n",length,n);
-        return kFALSE;
-    } // end if length<n
-    char *cvsrevision = new char[cvsRevisionLength-10];
-    char *cvsdate = new char[cvsDateLength-6];
-    for(i=0;i<cvsRevisionLength-10;i++)
-        if(10+i<cvsRevisionLength-1)
-            cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
-    for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
-        cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0;
-    for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
-    i = (Int_t)maj;
-    snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate);
-    /* this gives compilation warnings on some compilers: descriptor zu
-    if(GetDebug()>1)printf("AliITSUInitGeometry::WriteVersionString: "
-                       "n=%d str=%s revision[%zu] date[%zu]\n",
-                       n,str,strlen(cvsrevision),strlen(cvsdate));
-    */
-    delete[] cvsrevision;
-    delete[] cvsdate;
-    return kTRUE;
-}
-//______________________________________________________________________
-Bool_t AliITSUInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
-                                             AliITSVersion_t &maj,Int_t &min,
-                                             TDatime &dt)const{
-    // fills the string str with the major and minor version number
-    // Inputs:
-    //   Char_t *str   The character string to holding the major and minor
-    //                 version numbers in
-    //   Int_t  length The maximum number of characters which can be
-    //                 accomidated by this string. str[length-1] must exist
-    // Outputs:
-    //   Char_t *str   The character string holding the major and minor
-    //                 version numbers unchanged. str[length-1] must exist.
-    //   AliITSVersion_t maj  The major number
-    //   Int_t           min  The minor number
-    //   TDatime         dt   The date and time of the cvs commit
-    // Return:
-    //   kTRUE if no errors
-    Bool_t ok;
-    Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
-    Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
-    memset(cvsRevision,0,10*sizeof(Char_t));
-    memset(cvsDate,0,11*sizeof(Char_t));    
-    memset(cvsTime,0,9*sizeof(Char_t));
-
-    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString:"
-                       "str=%s length=%d\n",
-                       str,length);
-    if(n<35) return kFALSE; // not enough space for numbers
-    m = sscanf(str,"Major Version= %d  Minor Version= %d Revision: %9s "
-               "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime);
-    ok = m==5;
-    if(!ok) return !ok;
-    m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
-    ok = m==3;
-    if(!ok) return !ok;
-    m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
-    ok = m==3;
-    if(!ok) return !ok;
-    dt.Set(year,month,day,hours,minuits,seconds);
-    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: i=%d "
-                     "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
-                       i,min,cvsRevision,cvsDate,cvsTime,m);
-    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: year=%d"
-                       " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
-                       year,month,day,hours,minuits,seconds);
-    switch (i){
-    case kv11:{
-        maj = kv11;
-    } break;
-    case kvUpgrade:{
-        maj = kvUpgrade;
-    } break;
-    default:{
-        maj = kvDefault;
-    } break;
-    } // end switch
-    return ok;
-}
-//______________________________________________________________________
-Int_t AliITSUInitGeometry::GetNumberOfLayers(){
-  // Determines the number of layers in the Upgrade Geometry
-  //
-  // Inputs:
-  //   none
-  // Outputs:
-  //   none
-  // Return:
-  //   the number of layers in the current geometry
-  //   -1 if not Upgrade Geometry
-  // MS
-
-    Int_t numberOfLayers = 0;
-
-    if (fMajorVersion != kvUpgrade) {
-      AliError("Not Upgrade Geometry!");
-      return -1;
-    }
-
-    // This checks should be redundant, but let's do things neatly
-    if (!gGeoManager) {
-      AliError("gGeoManager is null");
-      return 0;
-    }
-
-    if (!gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())) {
-      AliError(Form("can't find %s volume",AliITSUGeomTGeo::GetITSVolPattern()));
-      return 0;
-    }
-
-    // Loop on all ITSV nodes, count Layer volumes by checking names
-    Int_t nNodes = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->GetEntries();
-
-    if (nNodes == 0)
-      return 0;
-
-    for (Int_t j=0; j<nNodes; j++)
-      if (strstr(gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->At(j)->GetName(),
-                AliITSUGeomTGeo::GetITSLayerPattern()))
-       numberOfLayers++;
-
-
-    return numberOfLayers;
-}
-
-//______________________________________________________________________
-Int_t AliITSUInitGeometry::GetNumberOfLadders(const Int_t lay) const {
-  // Determines the number of layers in the Upgrade Geometry
-  //
-  // Inputs:
-  //   lay: layer number
-  // Outputs:
-  //   none
-  // Return:
-  //   the number of ladders in layer lay
-  //   -1 if not Upgrade Geometry
-  // MS
-
-    Int_t numberOfLadders = 0;
-
-    if (fMajorVersion != kvUpgrade) {
-      AliError("Not Upgrade Geometry!");
-      return -1;
-    }
-
-    // This checks should be redundant, but let's do things neatly
-    if (!gGeoManager) {
-      AliError("gGeoManager is null");
-      return 0;
-    }
-
-    char laynam[15];
-    snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
-    if (!gGeoManager->GetVolume(laynam)) {
-      AliError(Form("can't find %s volume",laynam));
-      return 0;
-    }
-
-    // Loop on all layer nodes, count Ladder volumes by checking names
-    Int_t nNodes = gGeoManager->GetVolume(laynam)->GetNodes()->GetEntries();
-
-    if (nNodes == 0)
-      return 0;
-
-    for (Int_t j=0; j<nNodes; j++)
-      if (strstr(gGeoManager->GetVolume(laynam)->GetNodes()->At(j)->GetName(),
-                AliITSUGeomTGeo::GetITSLadderPattern()))
-       numberOfLadders++;
-
-
-    return numberOfLadders;
-}
-
-//______________________________________________________________________
-Int_t AliITSUInitGeometry::GetLayerDetTypeID(const Int_t lay) const 
-{
-  // Determines the layers det. type in the Upgrade Geometry
-  //
-  // Inputs:
-  //   lay: layer number
-  // Outputs:
-  //   none
-  // Return:
-  //   det id
-  //   -1 if not Upgrade Geometry
-  // MS
-  
-  if (fMajorVersion != kvUpgrade) {
-    AliError("Not Upgrade Geometry!");
-    return -1;
-  }
-  
-  // This checks should be redundant, but let's do things neatly
-  if (!gGeoManager) {
-    AliError("gGeoManager is null");
-    return 0;
-  }
-  
-  char laynam[15];
-  snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
-  TGeoVolume* volLr = gGeoManager->GetVolume(laynam);
-  if (!volLr) {
-    AliError(Form("can't find %s volume",laynam));
-    return -1;
-  }
-  //
-  return volLr->GetUniqueID();
-  //
-}
-
-//______________________________________________________________________
-Int_t AliITSUInitGeometry::GetNumberOfModules(const Int_t lay) const {
-  // Determines the number of layers in the Upgrade Geometry
-  //
-  // Inputs:
-  //   lay: layer number
-  // Outputs:
-  //   none
-  // Return:
-  //   the number of modules per ladder in layer lay
-  //   -1 if not Upgrade Geometry
-  // MS
-
-    Int_t numberOfModules = 0;
-
-    if (fMajorVersion != kvUpgrade) {
-      AliError("Not Upgrade Geometry!");
-      return -1;
-    }
-
-    // This checks should be redundant, but let's do things neatly
-    if (!gGeoManager) {
-      AliError("gGeoManager is null");
-      return 0;
-    }
-
-    char laddnam[15];
-    snprintf(laddnam, 15, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(),lay+1);
-    if (!gGeoManager->GetVolume(laddnam)) {
-      AliError(Form("can't find %s volume",laddnam));
-      return 0;
-    }
-
-    // Loop on all ladder nodes, count Module volumes by checking names
-    Int_t nNodes = gGeoManager->GetVolume(laddnam)->GetNodes()->GetEntries();
-
-    if (nNodes == 0)
-      return 0;
-
-    for (Int_t j=0; j<nNodes; j++)
-      if (strstr(gGeoManager->GetVolume(laddnam)->GetNodes()->At(j)->GetName(),
-                AliITSUGeomTGeo::GetITSModulePattern()))
-       numberOfModules++;
-
-
-    return numberOfModules;
-}
diff --git a/ITS/UPGRADE/AliITSUInitGeometry.h b/ITS/UPGRADE/AliITSUInitGeometry.h
deleted file mode 100644 (file)
index 7bf8244..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef ALIITSUINITGEOMETRY_H
-#define ALIITSUINITGEOMETRY_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/*
-$Id: AliITSUInitGeometry.h $
-*/
-
-/////////////////////////////////////////////////////////////////////
-// Class to inilize AliITSgeom and the like for both simulation
-//  and reconstruction.
-/////////////////////////////////////////////////////////////////////
-
-#include <TObject.h>
-#include <TString.h>
-#include "AliITSgeom.h"
-
-class TArrayD;
-class TGeoHMatrix;
-class TDatime;
-
-class AliITSUInitGeometry : public TObject{
- public:
-
-    AliITSUInitGeometry();//Default Constructor
-    AliITSUInitGeometry(AliITSVersion_t version,Int_t minorversion=2);//Standard Constructor
-    //virtual ~AliITSUInitGeometry(); // Destructor
-    //
-    // Create and initialize geometry from TGeo
-    AliITSgeom* CreateAliITSgeom();
-    AliITSgeom* CreateAliITSgeom(Int_t major,Int_t minor); 
-    Bool_t InitAliITSgeom(AliITSgeom *geom);//Initilize geometry from gGeoManager
-    TString GetGeometryName()const {return fName;}// Return geometry name
-    void    SetGeometryName(const Char_t *name){fName = name;}// Set Geometry name
-    Bool_t  GetTiming()const{return fTiming;} // return routine timing flag
-    void    SetTiming(Bool_t time=kTRUE){fTiming=time;}// Set routine timing (on)
-    void    SetDebug(Int_t debug=0){fDebug=debug;};
-    // Retrun debug value
-    Int_t   GetDebug()const{return fDebug;};
-    // Decode module number into old layer, ladder, and detector numbers
-    void DecodeDetectorLayers(Int_t mod,Int_t &lay,Int_t &lad,Int_t &det);
-    // find module number by layer, and copy numbers
-    void  DecodeDetector(Int_t &mod,Int_t lay,Int_t cpn0,
-                        Int_t cpn1,Int_t cpn2) const;
-    // Given module number, find copy numbers.
-    void  RecodeDetector(Int_t mod,Int_t &cpn0,Int_t &cpn1,Int_t &cpn2);
-    Int_t GetNumberOfLayers();
-    Int_t GetNumberOfLadders(const Int_t lay) const;
-    Int_t GetNumberOfModules(const Int_t lay) const;
-    Int_t GetLayerDetTypeID(const Int_t lay) const;
-    //
- private:
-    // Decode module number into old layer, ladder, and detector numbers
-    void DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
-                                Int_t &lad,Int_t &det);
-    // find module number by layer, and copy numbers
-    void DecodeDetectorv11(Int_t &mod,Int_t lay,Int_t cpn0,Int_t cpn1,
-                          Int_t cpn2)const;
-    // Given module number, find copy numbers.
-    void RecodeDetectorv11(Int_t mod,Int_t &cpn0,Int_t &cpn1,
-                          Int_t &cpn2);
-    // Decode module number into old layer, ladder, and detector numbers
-    void DecodeDetectorvUpgrade(Int_t &mod,Int_t lay,Int_t cpn0,Int_t cpn1,
-                                    Int_t cpn2)const;
-    // find module number by layer, and copy numbers
-    void RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,Int_t &cpn1,
-                                    Int_t &cpn2);
-    // Given module number, find copy numbers.
-    void DecodeDetectorLayersvUpgrade(Int_t mod,Int_t &lay,Int_t &lad,
-                                    Int_t &det);
-                  
-    // Virtual MC code 
-    Bool_t InitAliITSgeomV11(AliITSgeom *geom);
-    Bool_t InitAliITSgeomVUpgrade(AliITSgeom *geom);
-    Bool_t GetTransformation(const TString &volumePath,TGeoHMatrix &mat);
-    Bool_t GetShape(const TString &volumePath,TString &shapeType,TArrayD &par);
-    void TransposeTGeoHMatrix(TGeoHMatrix *m) const;
-
-    TString         fName;         // Geometry name
-    Bool_t          fTiming;       // Flag to start inilization timing
-    Int_t           fDebug;        // Debug flag
-
-    ClassDef(AliITSUInitGeometry,0) // create/Init AliITSgeom
-    // 0 in ClassDef indicates that this class will not be "saved" in a file.
-};
-
-#endif
-
index f3d02d24f66256b25ddf8418ca663aa2bf6956e6..3206cadae6f0927712c3a0177a0a0a4a7ff99d2c 100644 (file)
@@ -273,8 +273,8 @@ void AliITSUv0::CreateGeometry() {
 
   new TGeoVolumeAssembly(AliITSUGeomTGeo::GetITSVolPattern());
   TGeoVolume *vITSV = geoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
+  vITSV->SetUniqueID(AliITSUGeomTGeo::GetUIDShift()); // store modID -> midUUID bitshift
   vALIC->AddNode(vITSV, 2, 0);  // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT
-
   //
   const Int_t kLength=100;
   Char_t vstrng[kLength] = "xxxRS"; //?
diff --git a/ITS/UPGRADE/AliITSUv11.cxx b/ITS/UPGRADE/AliITSUv11.cxx
deleted file mode 100644 (file)
index 16597b3..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-/**************************************************************************
- * Copyright(c) 2007-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.                  *
- **************************************************************************/
-
-
-/* $Id: AliITSUv11.cxx */
-
-
-//========================================================================
-//
-//        Geometry for the Upgrade of the Inner Tracking System
-//
-// Mario Sitta (sitta@to.infn.it)
-//
-//========================================================================
-
-
-
-// $Log: AliITSUv11.cxx,v $
-
-#include <TClonesArray.h>
-#include <TGeoGlobalMagField.h>
-#include <TGeoManager.h>
-#include <TGeoMatrix.h>
-#include <TGeoPhysicalNode.h>
-#include <TGeoVolume.h>
-#include <TGeoXtru.h>
-#include <TLorentzVector.h>
-#include <TString.h>
-#include <TVirtualMC.h>
-
-#include "AliITSU.h"
-#include "AliITSUHit.h"
-#include "AliLog.h"
-#include "AliMC.h"
-#include "AliMagF.h"
-#include "AliRun.h"
-#include "AliTrackReference.h"
-#include "AliITSv11Geometry.h"
-#include "AliITSUv11Layer.h"
-#include "AliITSUv11.h"
-#include "AliITSUGeomTGeo.h"
-#include "AliGeomManager.h"
-using namespace TMath;
-
-
-ClassImp(AliITSUv11)
-
-//______________________________________________________________________
-AliITSUv11::AliITSUv11()
-:  fLayTurbo(0)
-  ,fLayPhi0(0)
-  ,fLayRadii(0)
-  ,fLayZLength(0)
-  ,fLaddPerLay(0)
-  ,fModPerLadd(0)
-  ,fLadThick(0)
-  ,fLadWidth(0)
-  ,fLadTilt(0)
-  ,fDetThick(0)
-  ,fDetTypeID(0)
-  ,fUpGeom(0)
-{
-  //    Standard default constructor
-  // Inputs:
-  //   none.
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-}
-
-//______________________________________________________________________
-AliITSUv11::AliITSUv11(const char *title,const Int_t nlay)
-  :AliITSU(title,nlay)
-  ,fLayTurbo(0)
-  ,fLayPhi0(0)
-  ,fLayRadii(0)
-  ,fLayZLength(0)
-  ,fLaddPerLay(0)
-  ,fModPerLadd(0)
-  ,fLadThick(0)
-  ,fLadWidth(0)
-  ,fLadTilt(0)
-  ,fDetThick(0)
-  ,fDetTypeID(0)
-  ,fUpGeom(0)
-{
-  //    Standard constructor for the Upgrade geometry.
-  // Inputs:
-  //   const char * name   Ignored, set to "ITS"
-  //   const char * title  Arbitrary title
-  //   const Int_t nlay    Number of layers
-  //
-  fLayerName = new TString[fNLayers];
-  //
-  for (Int_t j=0; j<fNLayers; j++) fLayerName[j].Form("%s%d",AliITSUGeomTGeo::GetITSSensorPattern(),j); // See AliITSUv11Layer
-  //
-  fLayTurbo   = new Bool_t[fNLayers];
-  fLayPhi0    = new Double_t[fNLayers];
-  fLayRadii   = new Double_t[fNLayers];
-  fLayZLength = new Double_t[fNLayers];
-  fLaddPerLay = new Int_t[fNLayers];
-  fModPerLadd = new Int_t[fNLayers];
-  fLadThick   = new Double_t[fNLayers];
-  fLadWidth   = new Double_t[fNLayers];
-  fLadTilt    = new Double_t[fNLayers];
-  fDetThick   = new Double_t[fNLayers];
-  fDetTypeID  = new UInt_t[fNLayers];
-
-  fUpGeom = new AliITSUv11Layer*[fNLayers];
-  
-  if (fNLayers > 0) { // if not, we'll Fatal-ize in CreateGeometry
-    for (Int_t j=0; j<fNLayers; j++) {
-      fLayPhi0[j] = 0;
-      fLayRadii[j] = 0.;
-      fLayZLength[j] = 0.;
-      fLaddPerLay[j] = 0;
-      fModPerLadd[j] = 0;
-      fLadWidth[j] = 0.;
-      fDetThick[j] = 0.;
-      fDetTypeID[j] = 0;
-      fUpGeom[j] = 0;
-    }
-  }
-}
-
-//______________________________________________________________________
-AliITSUv11::~AliITSUv11() {
-  //    Standard destructor
-  // Inputs:
-  //   none.
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-  delete [] fLayTurbo;
-  delete [] fLayPhi0;
-  delete [] fLayRadii;
-  delete [] fLayZLength;
-  delete [] fLaddPerLay;
-  delete [] fModPerLadd;
-  delete [] fLadThick;
-  delete [] fLadWidth;
-  delete [] fLadTilt;
-  delete [] fDetThick;
-  delete [] fDetTypeID;
-  delete [] fUpGeom;
-}
-
-//______________________________________________________________________
-void AliITSUv11::AddAlignableVolumes() const{
-  // Creates entries for alignable volumes associating the symbolic volume
-  // name with the corresponding volume path.
-  // 
-  // Records in the alignable entries the transformation matrices converting
-  // TGeo local coordinates (in the RS of alignable volumes) to the tracking
-  // system
-  // For this, this function has to run before the misalignment because we
-  // are using the ideal positions in the AliITSgeom object.
-  // Inputs:
-  //   none.
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-
-  AliInfo("Add ITS alignable volumes");
-
-  if (!gGeoManager) { AliFatal("TGeoManager doesn't exist !"); return;  }
-  TString pth;
-  //
-  pth = Form("ALIC_1/%s_2",AliITSUGeomTGeo::GetITSVolPattern());
-  // RS: to be checked with MS
-  if( !gGeoManager->SetAlignableEntry(AliITSUGeomTGeo::ComposeSymNameITS(),pth.Data()) )
-    AliFatal(Form("Unable to set alignable entry ! %s :: %s","ITS",pth.Data()));    
-  //
-  int modNum = 0;
-  //
-  for (int lr=0; lr<fNLayers; lr++) {
-    //
-    pth = Form("ALIC_1/%s_2/%s%d_1",AliITSUGeomTGeo::GetITSVolPattern(),AliITSUGeomTGeo::GetITSLayerPattern(),lr);
-    //printf("SetAlignable: %s %s\n",snm.Data(),pth.Data());
-    gGeoManager->SetAlignableEntry(AliITSUGeomTGeo::ComposeSymNameLayer(lr),pth.Data());
-    //
-    for (int ld=0; ld<fLaddPerLay[lr]; ld++) {
-      //
-      TString pthL = Form("%s/%s%d_%d",pth.Data(),AliITSUGeomTGeo::GetITSLadderPattern(),lr,ld);
-      //printf("SetAlignable: %s %s\n",snmL.Data(),pthL.Data());
-      gGeoManager->SetAlignableEntry(AliITSUGeomTGeo::ComposeSymNameLadder(lr,ld),pthL.Data());
-      //
-      for (int md=0; md<fModPerLadd[lr]; md++) {
-       //
-       TString pthM = Form("%s/%s%d_%d",pthL.Data(),AliITSUGeomTGeo::GetITSModulePattern(),lr,md);
-       //
-       // RS: Attention, this is a hack: AliGeomManager cannot accomodate all ITSU modules w/o
-       // conflicts with TPC. For this reason we define the UID of the module to be simply its ID
-       //      int modUID = AliGeomManager::LayerToVolUID(lr+1,modNum++); // here modNum would be module within the layer
-       int modUID = AliITSUGeomTGeo::ModuleVolUID( modNum++ );
-       // 
-       gGeoManager->SetAlignableEntry(AliITSUGeomTGeo::ComposeSymNameModule(lr,ld,md),pthM.Data(),modUID);
-       //
-      }
-    }
-  }
-  //
-}
-
-//______________________________________________________________________
-void AliITSUv11::CreateGeometry() {
-
-  // Create the geometry and insert it in the mother volume ITSV
-  TGeoManager *geoManager = gGeoManager;
-
-  TGeoVolume *vALIC = geoManager->GetVolume("ALIC");
-
-  new TGeoVolumeAssembly(AliITSUGeomTGeo::GetITSVolPattern());
-  TGeoVolume *vITSV = geoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
-  vALIC->AddNode(vITSV, 2, 0);  // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT
-
-  //
-  const Int_t kLength=100;
-  Char_t vstrng[kLength] = "xxxRS"; //?
-  vITSV->SetTitle(vstrng);
-  //
-  // Check that we have all needed parameters
-  if (fNLayers <= 0) AliFatal(Form("Wrong number of layers (%d)",fNLayers));
-  //
-  for (Int_t j=0; j<fNLayers; j++) {
-    if (fLayRadii[j] <= 0)                 AliFatal(Form("Wrong layer radius for layer %d (%f)",j,fLayRadii[j]));
-    if (fLayZLength[j] <= 0)               AliFatal(Form("Wrong layer length for layer %d (%f)",j,fLayZLength[j]));
-    if (fLaddPerLay[j] <= 0)               AliFatal(Form("Wrong number of ladders for layer %d (%d)",j,fLaddPerLay[j]));
-    if (fModPerLadd[j] <= 0)               AliFatal(Form("Wrong number of modules for layer %d (%d)",j,fModPerLadd[j]));
-    if (fLadThick[j] < 0)                  AliFatal(Form("Wrong ladder thickness for layer %d (%f)",j,fLadThick[j]));
-    if (fLayTurbo[j] && fLadWidth[j] <= 0) AliFatal(Form("Wrong ladder width for layer %d (%f)",j,fLadWidth[j]));
-    if (fDetThick[j] < 0)                  AliFatal(Form("Wrong module thickness for layer %d (%f)",j,fDetThick[j]));
-    //
-    if (j > 0) {
-      if (fLayRadii[j]<=fLayRadii[j-1])    AliFatal(Form("Layer %d radius (%f) is smaller than layer %d radius (%f)",
-                                                        j,fLayRadii[j],j-1,fLayRadii[j-1]));
-    } // if (j > 0)
-
-    if (fLadThick[j] == 0) AliInfo(Form("Ladder thickness for layer %d not set, using default",j));
-    if (fDetThick[j] == 0) AliInfo(Form("Module thickness for layer %d not set, using default",j));
-
-  } // for (Int_t j=0; j<fNLayers; j++)
-
-  // Now create the actual geometry
-  for (Int_t j=0; j<fNLayers; j++) {
-    if (fLayTurbo[j]) {
-      fUpGeom[j] = new AliITSUv11Layer(j,kTRUE,kFALSE);
-      fUpGeom[j]->SetLadderWidth(fLadWidth[j]);
-      fUpGeom[j]->SetLadderTilt(fLadTilt[j]);
-    }
-    else fUpGeom[j] = new AliITSUv11Layer(j,kFALSE);
-    //
-    fUpGeom[j]->SetPhi0(fLayPhi0[j]);
-    fUpGeom[j]->SetRadius(fLayRadii[j]);
-    fUpGeom[j]->SetZLength(fLayZLength[j]);
-    fUpGeom[j]->SetNLadders(fLaddPerLay[j]);
-    fUpGeom[j]->SetNModules(fModPerLadd[j]);
-    fUpGeom[j]->SetDetType(fDetTypeID[j]);
-    //
-    if (fLadThick[j] != 0) fUpGeom[j]->SetLadderThick(fLadThick[j]);
-    if (fDetThick[j] != 0) fUpGeom[j]->SetSensorThick(fDetThick[j]);
-    fUpGeom[j]->CreateLayer(vITSV);
-  }
-  //
-}
-
-//______________________________________________________________________
-void AliITSUv11::CreateMaterials() {
-  // Create ITS materials
-  //     This function defines the default materials used in the Geant
-  // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
-  // AliITSv11Hybrid.
-  // In general it is automatically replaced by
-  // the CreateMaterials routine defined in AliITSv?. Should the function
-  // CreateMaterials not exist for the geometry version you are using this
-  // one is used. See the definition found in AliITSv5 or the other routine
-  // for a complete definition.
-  // Inputs:
-  //   none.
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-
-  Int_t   ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
-  Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
-
-  Float_t tmaxfd = 0.1; // 1.0; // Degree
-  Float_t stemax = 1.0; // cm
-  Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
-  Float_t epsil  = 1.0E-4; // 1.0; // cm
-  Float_t stmin  = 0.0; // cm "Default value used"
-
-  Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
-  Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
-  Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
-  Float_t epsilSi  = 1.0E-4;// .10000E+01;
-  Float_t stminSi  = 0.0; // cm "Default value used"
-
-  Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
-  Float_t stemaxAir = .10000E+01; // cm
-  Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
-  Float_t epsilAir  = 1.0E-4;// .10000E+01;
-  Float_t stminAir  = 0.0; // cm "Default value used"
-
-  // AIR
-  Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
-  Float_t zAir[4]={6.,7.,8.,18.};
-  Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
-  Float_t dAir = 1.20479E-3;
-
-
-  AliMaterial(1,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
-  AliMedium(1,"SI$",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
-
-  AliMixture(5,"AIR$",aAir,zAir,dAir,4,wAir);
-  AliMedium(5,"AIR$",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
-
-  AliMaterial(8,"BERILLIUM$",9.01, 4., 1.848, 35.3, 36.7);// From AliPIPEv3
-  AliMedium(8,"BERILLIUM$",8,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
-    
-}
-
-//______________________________________________________________________
-void AliITSUv11::DefineLayer(const Int_t nlay, const double phi0, const Double_t r,
-                                const Double_t zlen, const Int_t nladd,
-                                const Int_t nmod, const Double_t lthick,
-                                const Double_t dthick, const UInt_t dettypeID)
-{
-  //     Sets the layer parameters
-  // Inputs:
-  //          nlay    layer number
-  //          phi0    layer phi0
-  //          r       layer radius
-  //          zlen    layer length
-  //          nladd   number of ladders
-  //          nmod    number of modules per ladder
-  //          lthick  ladder thickness (if omitted, defaults to 0)
-  //          dthick  detector thickness (if omitted, defaults to 0)
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-  
-  if (nlay >= fNLayers || nlay < 0) {
-    AliError(Form("Wrong layer number (%d)",nlay));
-    return;
-  }
-  
-  fLayTurbo[nlay] = kFALSE;
-  fLayPhi0[nlay] = phi0;
-  fLayRadii[nlay] = r;
-  fLayZLength[nlay] = zlen;
-  fLaddPerLay[nlay] = nladd;
-  fModPerLadd[nlay] = nmod;
-  fLadThick[nlay] = lthick;
-  fDetThick[nlay] = dthick;
-  fDetTypeID[nlay] = dettypeID;
-    
-}
-
-//______________________________________________________________________
-void AliITSUv11::DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd,
-                                 Int_t nmod, Double_t width, Double_t tilt,
-                                 Double_t lthick,Double_t dthick,
-                                 UInt_t dettypeID)
-{
-  //     Sets the layer parameters for a "turbo" layer
-  //     (i.e. a layer whose ladders overlap in phi)
-  // Inputs:
-  //          nlay    layer number
-  //          phi0    phi of 1st ladder
-  //          r       layer radius
-  //          zlen    layer length
-  //          nladd   number of ladders
-  //          nmod    number of modules per ladder
-  //          width   ladder width
-  //          tilt    layer tilt angle (degrees)
-  //          lthick  ladder thickness (if omitted, defaults to 0)
-  //          dthick  detector thickness (if omitted, defaults to 0)
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-
-  if (nlay >= fNLayers || nlay < 0) {
-    AliError(Form("Wrong layer number (%d)",nlay));
-    return;
-  }
-
-  fLayTurbo[nlay] = kTRUE;
-  fLayPhi0[nlay] = phi0;
-  fLayRadii[nlay] = r;
-  fLayZLength[nlay] = zlen;
-  fLaddPerLay[nlay] = nladd;
-  fModPerLadd[nlay] = nmod;
-  fLadThick[nlay] = lthick;
-  fLadWidth[nlay] = width;
-  fLadTilt[nlay] = tilt;
-  fDetThick[nlay] = dthick;
-  fDetTypeID[nlay] = dettypeID;
-  //
-}
-
-//______________________________________________________________________
-void AliITSUv11::GetLayerParameters(Int_t nlay, Double_t &phi0,
-                                   Double_t &r, Double_t &zlen,
-                                   Int_t &nladd, Int_t &nmod,
-                                   Double_t &width, Double_t &tilt,
-                                   Double_t &lthick, Double_t &dthick) const
-{
-  //     Gets the layer parameters
-  // Inputs:
-  //          nlay    layer number
-  // Outputs:
-  //          phi0    phi of 1st ladder
-  //          r       layer radius
-  //          zlen    layer length
-  //          nladd   number of ladders
-  //          nmod    number of modules per ladder
-  //          width   ladder width
-  //          tilt    ladder tilt angle
-  //          lthick  ladder thickness
-  //          dthick  detector thickness
-  // Return:
-  //   none.
-
-  if (nlay >= fNLayers || nlay < 0) {
-    AliError(Form("Wrong layer number (%d)",nlay));
-    return;
-  }
-  
-  phi0   = fLayPhi0[nlay];
-  r      = fLayRadii[nlay];
-  zlen   = fLayZLength[nlay];
-  nladd  = fLaddPerLay[nlay];
-  nmod   = fModPerLadd[nlay];
-  width  = fLadWidth[nlay];
-  tilt   = fLadTilt[nlay];
-  lthick = fLadThick[nlay];
-  dthick = fDetThick[nlay];
-}
-
-//______________________________________________________________________
-void AliITSUv11::Init()
-{
-  //     Initialise the ITS after it has been created.
-  UpdateInternalGeometry();
-  AliITSU::Init();
-  //  
-}
-
-//______________________________________________________________________
-Bool_t AliITSUv11::IsLayerTurbo(Int_t nlay)
-{
-  //     Returns true if the layer is a "turbo" layer
-  if ( nlay < 0 || nlay > fNLayers ) {
-    AliError(Form("Wrong layer number %d",nlay));
-    return kFALSE;
-  } 
-  else return fUpGeom[nlay]->IsTurbo();
-}
-
-//______________________________________________________________________
-void AliITSUv11::SetDefaults()
-{
-  // sets the default segmentation, response, digit and raw cluster classes
-}
-
-//______________________________________________________________________
-void AliITSUv11::StepManager()
-{
-  //    Called for every step in the ITS, then calles the AliITSUHit class
-  // creator with the information to be recoreded about that hit.
-  //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
-  // printing of information to a file which can be used to create a .det
-  // file read in by the routine CreateGeometry(). If set to 0 or any other
-  // value except 1, the default behavior, then no such file is created nor
-  // it the extra variables and the like used in the printing allocated.
-  // Inputs:
-  //   none.
-  // Outputs:
-  //   none.
-  // Return:
-  //   none.
-  if(!(this->IsActive())) return;
-  if(!(gMC->TrackCharge())) return;
-  //
-  Int_t copy, lay = 0;
-  Int_t id = gMC->CurrentVolID(copy);
-
-  Bool_t notSens = kFALSE;
-  while ((lay<fNLayers)  && (notSens = (id!=fIdSens[lay]))) ++lay;
-  //printf("R: %.1f | Lay: %d  NotSens: %d\n",positionRS.Pt(), lay, notSens);
-          
-  if (notSens) return;
-
-  if(gMC->IsTrackExiting()) {
-    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
-  } // if Outer ITS mother Volume
-
-  static TLorentzVector position, momentum; // Saves on calls to construtors
-  static AliITSUHit hit;// Saves on calls to constructors
-
-  TClonesArray &lhits = *(Hits());
-  Int_t   cpn0, cpn1, mod, status = 0;
-  //
-  // Track status
-  if(gMC->IsTrackInside())      status +=  1;
-  if(gMC->IsTrackEntering())    status +=  2;
-  if(gMC->IsTrackExiting())     status +=  4;
-  if(gMC->IsTrackOut())         status +=  8;
-  if(gMC->IsTrackDisappeared()) status += 16;
-  if(gMC->IsTrackStop())        status += 32;
-  if(gMC->IsTrackAlive())       status += 64;
-
-  //
-  // retrieve the indices with the volume path
-  //
-  if (lay < 0 || lay >= fNLayers) {
-    AliError(Form("Invalid value: lay=%d. Not an ITS sensitive volume",lay));
-    return; // not an ITS sensitive volume.
-  } else {
-    copy = 1;
-    gMC->CurrentVolOffID(1,cpn1);
-    gMC->CurrentVolOffID(2,cpn0);
-  } //
-
-  mod = fGeomTGeo->GetModuleIndex(lay,cpn0,cpn1);
-  //RS2DEL  fInitGeom.DecodeDetector(mod,lay+1,cpn0,cpn1,copy);
-  //
-  // Fill hit structure.
-  //
-  hit.SetModule(mod);
-  hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
-  gMC->TrackPosition(position);
-  gMC->TrackMomentum(momentum);
-  hit.SetPosition(position);
-  hit.SetTime(gMC->TrackTime());
-  hit.SetMomentum(momentum);
-  hit.SetStatus(status);
-  hit.SetEdep(gMC->Edep());
-  hit.SetShunt(GetIshunt());
-  if(gMC->IsTrackEntering()){
-    hit.SetStartPosition(position);
-    hit.SetStartTime(gMC->TrackTime());
-    hit.SetStartStatus(status);
-    return; // don't save entering hit.
-  } // end if IsEntering
-    // Fill hit structure with this new hit.
-    //Info("StepManager","Calling Copy Constructor");
-  new(lhits[fNhits++]) AliITSUHit(hit); // Use Copy Construtor.
-  // Save old position... for next hit.
-  hit.SetStartPosition(position);
-  hit.SetStartTime(gMC->TrackTime());
-  hit.SetStartStatus(status);
-
-  return;
-}
-
-//______________________________________________________________________
-void AliITSUv11::SetLayerDetTypeID(Int_t lr, UInt_t id)
-{
-  // set det type
-  if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
-  fDetTypeID[lr] = id;
-}
-
-//______________________________________________________________________
-Int_t AliITSUv11::GetLayerDetTypeID(Int_t lr)
-{
-  // set det type
-  if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
-  return fDetTypeID[lr];
-}
diff --git a/ITS/UPGRADE/AliITSUv11.h b/ITS/UPGRADE/AliITSUv11.h
deleted file mode 100644 (file)
index c3cce85..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef ALIITSVUPGRADE_H
-#define ALIITSVUPGRADE_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-//========================================================================
-//
-//        Geometry for the Upgrade of the Inner Tracking System
-//
-// Mario Sitta (sitta@to.infn.it)
-//
-//========================================================================
-
-
-// $Id: AliITSUv11.h 
-
-#include "AliITSU.h"
-
-class  AliITSUv11Layer;
-class  AliITSv11GeomBeamPipe;
-class  TGeoVolume;
-class  TGeoVolumeAssembly;
-
-class AliITSUv11 : public AliITSU {
-
- public:
-  AliITSUv11();
-  AliITSUv11(const char *title, const Int_t nlay);
-  virtual       ~AliITSUv11() ;
-  
-  virtual void   AddAlignableVolumes() const;
-  virtual void   CreateGeometry();
-  virtual void   CreateMaterials();
-  virtual void   DefineLayer(Int_t nlay,Double_t phi0,Double_t r,Double_t zlen,Int_t nladd,
-                            Int_t nmod, Double_t lthick=0.,Double_t dthick=0.,UInt_t detType=0);
-  virtual void   DefineLayerTurbo(Int_t nlay,Double_t phi0,Double_t r,Double_t zlen,Int_t nladd,
-                                 Int_t nmod,Double_t width,Double_t tilt,
-                                 Double_t lthick = 0.,Double_t dthick = 0.,UInt_t detType=0);
-  virtual void   GetLayerParameters(Int_t nlay, Double_t &phi0,Double_t &r, Double_t &zlen,
-                                   Int_t &nladd, Int_t &nmod,
-                                   Double_t &width, Double_t &tilt,
-                                   Double_t &lthick, Double_t &mthick) const;
-  virtual void   Init(); 
-  virtual Bool_t IsLayerTurbo(Int_t nlay);
-  virtual Int_t  IsVersion()                 const { return 20;}  // vUpgrade ? do we need this
-  virtual void   SetDefaults();
-  virtual void   StepManager();
-  virtual void   SetLayerDetTypeID(Int_t lr, UInt_t id);
-  virtual Int_t  GetLayerDetTypeID(Int_t lr);
-  //
- private:
-  AliITSUv11(const AliITSUv11 &source); // copy constructor
-  AliITSUv11& operator=(const AliITSUv11 &source); // assignment operator
-  //
-  Bool_t   *fLayTurbo;       // True for "turbo" layers
-  Double_t *fLayPhi0;        // Vector of layer's 1st ladder phi in lab
-  Double_t *fLayRadii;       // Vector of layer radii
-  Double_t *fLayZLength;     // Vector of layer length along Z
-  Int_t    *fLaddPerLay;     // Vector of number of ladders per layer
-  Int_t    *fModPerLadd;     // Vector of number of modules per ladder
-  Double_t *fLadThick;       // Vector of ladder thicknesses
-  Double_t *fLadWidth;       // Vector of ladder width (only used for turbo)
-  Double_t *fLadTilt;        // Vector of ladder tilt (only used for turbo)
-  Double_t *fDetThick;       // Vector of detector thicknesses
-  UInt_t   *fDetTypeID;      // Vector of detector type id
-  //  
-  AliITSUv11Layer **fUpGeom; //! Geometry
-  
-  // Parameters for the Upgrade geometry
-  
-  ClassDef(AliITSUv11,0)                          
-};
-#endif
diff --git a/ITS/UPGRADE/AliITSUv11Layer.cxx b/ITS/UPGRADE/AliITSUv11Layer.cxx
deleted file mode 100644 (file)
index b825160..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-/**************************************************************************
- * 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.                  *
- **************************************************************************/
-
-//*************************************************************************
-// This class Defines the Geometry for the ITS Upgrade using TGeo
-// This is a work class used to study different configurations
-// during the development of the new ITS structure.
-//
-//  Mario Sitta <sitta@to.infn.it>
-//*************************************************************************
-
-
-/* $Id: AliITSUv11Layer.cxx  */
-// General Root includes
-#include <TMath.h>
-// Root Geometry includes
-//#include <AliLog.h>
-#include <TGeoManager.h>
-#include <TGeoVolume.h>
-#include <TGeoPcon.h>
-#include <TGeoCone.h>
-#include <TGeoTube.h> // contaings TGeoTubeSeg
-#include <TGeoArb8.h>
-#include <TGeoXtru.h>
-#include <TGeoCompositeShape.h>
-#include <TGeoMatrix.h>
-#include "AliITSUv11Layer.h"
-#include "AliITSUGeomTGeo.h"
-using namespace TMath;
-
-const Double_t AliITSUv11Layer::fgkDefaultSensorThick = 300*fgkmicron;
-const Double_t AliITSUv11Layer::fgkDefaultLadderThick =   1*fgkcm;
-
-ClassImp(AliITSUv11Layer)
-
-#define SQ(A) (A)*(A)
-
-//________________________________________________________________________
-AliITSUv11Layer::AliITSUv11Layer(): 
-  AliITSv11Geometry(),
-  fLayerNumber(0),
-  fPhi0(0),
-  fLayRadius(0),
-  fZLength(0),
-  fSensorThick(0),
-  fLadderThick(0),
-  fLadderWidth(0),
-  fLadderTilt(0),
-  fNLadders(0),
-  fNModules(0),
-  fDetTypeID(0),
-  fIsTurbo(0)
-{
-  //
-  // Standard constructor
-  //
-}
-
-//________________________________________________________________________
-AliITSUv11Layer::AliITSUv11Layer(Int_t debug): 
-  AliITSv11Geometry(debug),
-  fLayerNumber(0),
-  fPhi0(0),
-  fLayRadius(0),
-  fZLength(0),
-  fSensorThick(0),
-  fLadderThick(0),
-  fLadderWidth(0),
-  fLadderTilt(0),
-  fNLadders(0),
-  fNModules(0),
-  fDetTypeID(0),
-  fIsTurbo(0)
-{
-  //
-  // Constructor setting debugging level
-  //
-}
-
-//________________________________________________________________________
-AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Int_t debug): 
-  AliITSv11Geometry(debug),
-  fLayerNumber(lay),
-  fPhi0(0),
-  fLayRadius(0),
-  fZLength(0),
-  fSensorThick(0),
-  fLadderThick(0),
-  fLadderWidth(0),
-  fLadderTilt(0),
-  fNLadders(0),
-  fNModules(0),
-  fDetTypeID(0),
-  fIsTurbo(0)
-{
-  //
-  // Constructor setting layer number and debugging level
-  //
-}
-
-//________________________________________________________________________
-AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Bool_t turbo, Int_t debug): 
-  AliITSv11Geometry(debug),
-  fLayerNumber(lay),
-  fPhi0(0),
-  fLayRadius(0),
-  fZLength(0),
-  fSensorThick(0),
-  fLadderThick(0),
-  fLadderWidth(0),
-  fLadderTilt(0),
-  fNLadders(0),
-  fNModules(0),
-  fDetTypeID(0),
-  fIsTurbo(turbo)
-{
-  //
-  // Constructor setting layer number and debugging level
-  // for a "turbo" layer (i.e. where ladders overlap in phi)
-  //
-}
-
-//________________________________________________________________________
-AliITSUv11Layer::AliITSUv11Layer(const AliITSUv11Layer &s):
-  AliITSv11Geometry(s.GetDebug()),
-  fLayerNumber(s.fLayerNumber),
-  fPhi0(s.fPhi0),
-  fLayRadius(s.fLayRadius),
-  fZLength(s.fZLength),
-  fSensorThick(s.fSensorThick),
-  fLadderThick(s.fLadderThick),
-  fLadderWidth(s.fLadderWidth),
-  fLadderTilt(s.fLadderTilt),
-  fNLadders(s.fNLadders),
-  fNModules(s.fNModules),
-  fDetTypeID(0),
-  fIsTurbo(s.fIsTurbo)
-{
-  //
-  // Copy constructor
-  //
-}
-
-//________________________________________________________________________
-AliITSUv11Layer& AliITSUv11Layer::operator=(const AliITSUv11Layer &s)
-{
-  //
-  // Assignment operator 
-  //
-  if(&s == this) return *this;
-
-  fLayerNumber = s.fLayerNumber;
-  fPhi0        = s.fPhi0;
-  fLayRadius   = s.fLayRadius;
-  fZLength     = s.fZLength;
-  fSensorThick = s.fSensorThick;
-  fLadderThick = s.fLadderThick;
-  fLadderWidth = s.fLadderWidth;
-  fLadderTilt  = s.fLadderTilt;
-  fNLadders    = s.fNLadders;
-  fNModules    = s.fNModules;
-  fIsTurbo     = s.fIsTurbo;
-  fDetTypeID   = s.fDetTypeID;
-  return *this;
-}
-
-//________________________________________________________________________
-AliITSUv11Layer::~AliITSUv11Layer() {
-  //
-  // Destructor
-  //
-}
-
-//________________________________________________________________________
-void AliITSUv11Layer::CreateLayer(TGeoVolume *moth,const TGeoManager *mgr){
-//
-// Creates the actual Layer and places inside its mother volume
-//
-// Input:
-//         moth : the TGeoVolume owing the volume structure
-//         mgr  : the GeoManager (used only to get the proper material)
-//
-// Output:
-//
-// Return:
-//
-// Created:      17 Jun 2011  Mario Sitta
-// Updated:      08 Jul 2011  Mario Sitta
-//
-  // Local variables
-  char volname[30];
-  Double_t rmin, rmax;
-  Double_t xpos, ypos, zpos;
-  Double_t alpha;
-
-
-  // Check if the user set the proper parameters
-  if (fLayRadius <= 0) AliFatal(Form("Wrong layer radius (%f)",fLayRadius));
-  if (fZLength   <= 0) AliFatal(Form("Wrong layer length (%f)",fZLength));
-  if (fNLadders  <= 0) AliFatal(Form("Wrong number of ladders (%d)",fNLadders));
-  if (fNModules  <= 0) AliFatal(Form("Wrong number of modules (%d)",fNModules));
-
-  if (fLadderThick <= 0) {
-    AliInfo(Form("Ladder thickness wrong or not set (%f), using default (%f)",
-                fLadderThick,fgkDefaultLadderThick));
-    fLadderThick = fgkDefaultLadderThick;
-  }
-
-  if (fSensorThick <= 0) {
-    AliInfo(Form("Sensor thickness wrong or not set (%f), using default (%f)",
-                fSensorThick,fgkDefaultSensorThick));
-    fSensorThick = fgkDefaultSensorThick;
-  }
-
-  if (fSensorThick > fLadderThick) {
-    AliWarning(Form("Sensor thickness (%f) is greater than ladder thickness (%f), fixing",
-                fSensorThick,fLadderThick));
-    fSensorThick = fLadderThick;
-  }
-
-
-  // If a Turbo layer is requested, do it and exit
-  if (fIsTurbo) {
-    CreateLayerTurbo(moth, mgr);
-    return;
-  }
-
-
-  // First create the ladder container
-  alpha = (360./(2*fNLadders))*DegToRad();
-
-  //  fLadderWidth = fLayRadius*Tan(alpha);
-
-  rmin = 0.98*fLayRadius;
-  rmax = 1.02*Sqrt( fLadderWidth*fLadderWidth +
-                         (rmin+fLadderThick)*(rmin+fLadderThick) );
-
-  TGeoTube *layer = new TGeoTube(rmin, rmax, 0.5*fZLength);
-
-
-  // We have all shapes: now create the real volumes
-  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
-
-  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
-  TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
-  layVol->SetUniqueID(fDetTypeID);
-
-//  layVol->SetVisibility(kFALSE);
-  layVol->SetVisibility(kTRUE);
-  layVol->SetLineColor(1);
-
-  TGeoVolume *laddVol = CreateLadder();
-
-
-  // Now build up the layer
-  alpha = 360./fNLadders;
-  Double_t r = fLayRadius + ((TGeoBBox*)laddVol->GetShape())->GetDY();
-  for (Int_t j=0; j<fNLadders; j++) {
-    Double_t phi = j*alpha + fPhi0;
-    xpos = r*CosD(phi);// r*SinD(-phi);
-    ypos = r*SinD(phi);// r*CosD(-phi);
-    zpos = 0.;
-    phi += 90;
-    layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
-                                                   new TGeoRotation("",phi,0,0)));
-  }
-
-
-  // Finally put everything in the mother volume
-  moth->AddNode(layVol, 1, 0);
-
-
-  // Upgrade geometry is served
-  return;
-}
-
-//________________________________________________________________________
-void AliITSUv11Layer::CreateLayerTurbo(TGeoVolume *moth,
-                                         const TGeoManager *mgr){
-//
-// Creates the actual Layer and places inside its mother volume
-// A so-called "turbo" layer is a layer where ladders overlap in phi
-// User can set width and tilt angle, no check is performed here
-// to avoid volume overlaps
-//
-// Input:
-//         moth : the TGeoVolume owing the volume structure
-//         mgr  : the GeoManager (used only to get the proper material)
-//
-// Output:
-//
-// Return:
-//
-// Created:      08 Jul 2011  Mario Sitta
-// Updated:      08 Mar 2012  Mario Sitta  Correct way to compute container R
-//
-
-
-  // Local variables
-  char volname[30];
-  Double_t rmin, rmax, rladd, rcont, d;
-  Double_t xpos, ypos, zpos;
-  Double_t alpha, gamma;
-
-
-  // Check if the user set the proper (remaining) parameters
-  if (fLadderWidth <= 0)
-    AliFatal(Form("Wrong ladder width (%f)",fLadderWidth));
-  if (Abs(fLadderTilt) > 45)
-    AliWarning(Form("Ladder tilt angle (%f) greater than 45deg",fLadderTilt));
-
-
-  // First create the ladder container
-  // d is half the diagonal of the ladder section
-  // rladd is the radius at the ladder's center-of-gravity
-  // alpha here is the angle between the diagonal and rladd
-  d = 0.5*Sqrt(fLadderThick*fLadderThick + fLadderWidth*fLadderWidth);
-  alpha = ACos(0.5*fLadderThick/d)*RadToDeg();
-  gamma = alpha - fLadderTilt;
-  rladd = fLayRadius + 0.5*fLadderThick;
-
-  // rcont is the radius of the air container
-  rcont = RadiusOfTurboContainer();
-  
-  if (rcont > 0)
-    rmin = 0.98*rcont;
-  else
-    rmin = 0.98*Sqrt( rladd*rladd + d*d - 2*rladd*d*CosD(gamma) );
-  
-  rmax = 1.02*Sqrt( rladd*rladd + d*d + 2*rladd*d*CosD(gamma) );
-  
-  TGeoTube *layer = new TGeoTube(rmin, rmax, 0.5*fZLength);
-
-
-  // We have all shapes: now create the real volumes
-  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
-
-  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
-  TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
-  layVol->SetUniqueID(fDetTypeID);
-  layVol->SetVisibility(kTRUE);
-  layVol->SetLineColor(1);
-  TGeoVolume *laddVol = CreateLadder();
-
-
-  // Now build up the layer
-
-
-  // Now build up the layer
-  alpha = 360./fNLadders;
-  Double_t r = fLayRadius + ((TGeoBBox*)laddVol->GetShape())->GetDY();
-  for (Int_t j=0; j<fNLadders; j++) {
-    Double_t phi = j*alpha + fPhi0;
-    xpos = r*CosD(phi);// r*SinD(-phi);
-    ypos = r*SinD(phi);// r*CosD(-phi);
-    zpos = 0.;
-    phi += 90;
-    layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
-                                                   new TGeoRotation("", phi-fLadderTilt,0,0)));
-  }
-
-
-  // Finally put everything in the mother volume
-  moth->AddNode(layVol, 1, 0);
-
-  return;
-}
-
-//________________________________________________________________________
-TGeoVolume* AliITSUv11Layer::CreateLadder(const TGeoManager *mgr){
-//
-// Creates the actual Ladder
-//
-// Input:
-//         mgr  : the GeoManager (used only to get the proper material)
-//
-// Output:
-//
-// Return:
-//
-// Created:      22 Jun 2011  Mario Sitta
-//
-
-  char volname[30];
-  Double_t xlen, ylen, zlen;
-  Double_t xpos, ypos, zpos, zmod;
-  Double_t alpha;
-
-
-  // First create all needed shapes
-  alpha = (360./(2*fNLadders))*DegToRad();
-
-  // The ladder
-  xlen = fLayRadius*Tan(alpha);
-  if (fIsTurbo) xlen = 0.5*fLadderWidth;
-  ylen = 0.5*fLadderThick;
-  zlen = 0.5*fZLength;
-
-  TGeoBBox *ladder = new TGeoBBox(xlen, ylen, zlen);
-
-
-  // We have all shapes: now create the real volumes
-  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
-
-  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
-  TGeoVolume *laddVol = new TGeoVolume(volname, ladder, medAir);
-
-//  laddVol->SetVisibility(kFALSE);
-  laddVol->SetVisibility(kTRUE);
-  laddVol->SetLineColor(2);
-  TGeoVolume *modVol = CreateModule(ladder->GetDX(), ladder->GetDY(),
-                                   ladder->GetDZ());
-
-
-  // Now build up the ladder
-  zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
-  for (Int_t j=0; j<fNModules; j++) {
-    xpos = 0.;
-    ypos = 0.;
-    zpos = -ladder->GetDZ() + j*2*zmod + zmod;
-    laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
-  }
-
-
-  // Done, return the ladder
-  return laddVol;
-}
-
-//________________________________________________________________________
-TGeoVolume* AliITSUv11Layer::CreateModule(const Double_t xlad,
-                                                  const Double_t ylad,
-                                                  const Double_t zlad,
-                                                  const TGeoManager *mgr){
-//
-// Creates the actual Module
-//
-// Input:
-//         xlad,ylad,zlad : the ladder dimensions
-//         mgr  : the GeoManager (used only to get the proper material)
-//
-// Output:
-//
-// Return:
-//
-// Created:      22 Jun 2011  Mario Sitta
-//
-
-  char volname[30];
-  Double_t xlen, ylen, zlen;
-  Double_t xpos, ypos, zpos;
-
-
-  // First create all needed shapes
-
-  // The module
-  TGeoBBox *module = new TGeoBBox(xlad, ylad, zlad/fNModules);
-
-  // The sensor
-  xlen = module->GetDX();
-  ylen = 0.5*fSensorThick;
-  zlen = module->GetDZ();
-  TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
-
-
-  // We have all shapes: now create the real volumes
-  //  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
-  TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
-
-  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern() ,fLayerNumber);
-  //  TGeoVolume *modVol = new TGeoVolume(volname, module, medAir);
-  TGeoVolume *modVol = new TGeoVolume(volname, module, medSi);
-  modVol->SetVisibility(kFALSE);
-  modVol->SetLineColor(1);
-
-  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
-  TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
-  sensVol->SetVisibility(kTRUE);
-  sensVol->SetLineColor(8);
-  sensVol->SetLineWidth(1);
-  sensVol->SetFillColor(sensVol->GetLineColor());
-  sensVol->SetFillStyle(4000); // 0% transparent
-
-
-  // Now build up the module
-  xpos = 0.;
-  ypos = -module->GetDY() + sensor->GetDY();
-  zpos = 0.;
-
-  modVol->AddNode(sensVol, 1, new TGeoTranslation(xpos, ypos, zpos));
-
-
-  // Done, return the module
-  return modVol;
-}
-
-//________________________________________________________________________
-Double_t AliITSUv11Layer::RadiusOfTurboContainer(){
-//
-// Computes the inner radius of the air container for the Turbo configuration
-// as the radius of either the circle tangent to the ladder or the circle
-// passing for the ladder's lower vertex
-//
-// Input:
-//         none (all needed parameters are class members)
-//
-// Output:
-//
-// Return:
-//        the radius of the container if >0, else flag to use the lower vertex
-//
-// Created:      08 Mar 2012  Mario Sitta
-//
-
-  Double_t rr, delta, z, lladd, rladd;
-
-  if (fLadderThick > 89.) // Very big angle: avoid overflows since surely
-    return -1;            // the radius from lower vertex is the right value
-
-  rladd = fLayRadius + 0.5*fLadderThick;
-  delta = (0.5*fLadderThick)/CosD(fLadderTilt);
-  z     = (0.5*fLadderThick)*TanD(fLadderTilt);
-
-  rr = rladd - delta;
-  lladd = (0.5*fLadderWidth) - z;
-
-  if ( (rr*SinD(fLadderTilt) < lladd) )
-    return (rr*CosD(fLadderTilt));
-  else
-    return -1;
-}
-
-//________________________________________________________________________
-void AliITSUv11Layer::SetLadderTilt(const Double_t t)
-{
-//
-// Sets the Ladder tilt angle (for turbo layers only)
-//
-// Input:
-//         t :  the ladder tilt angle
-//
-// Output:
-//
-// Return:
-//
-// Created:      08 Jul 2011  Mario Sitta
-//
-
-  if (fIsTurbo)
-    fLadderTilt = t;
-  else
-    AliError("Not a Turbo layer");
-
-}
-
-//________________________________________________________________________
-void AliITSUv11Layer::SetLadderWidth(const Double_t w){
-//
-// Sets the Ladder width (for turbo layers only)
-//
-// Input:
-//         w :  the ladder width
-//
-// Output:
-//
-// Return:
-//
-// Created:      08 Jul 2011  Mario Sitta
-//
-
-  if (fIsTurbo)
-    fLadderWidth = w;
-  else
-    AliError("Not a Turbo layer");
-
-}
diff --git a/ITS/UPGRADE/AliITSUv11Layer.h b/ITS/UPGRADE/AliITSUv11Layer.h
deleted file mode 100644 (file)
index 7fa38ee..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef ALIITSV11GEOMETRYUPGRADE_H
-#define ALIITSV11GEOMETRYUPGRADE_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-
-//*************************************************************************
-// This class Defines the Geometry for the ITS Upgrade using TGeo
-// This is a work class used to study different configurations
-// during the development of the new ITS structure.
-//
-//  Mario Sitta <sitta@to.infn.it>
-//*************************************************************************
-
-
-/*
-  $Id: AliITSUv11Layer.h
- */
-
-#include "AliITSv11Geometry.h"
-#include <TGeoManager.h>
-#include <TGeoCompositeShape.h>
-#include <TGeoXtru.h>
-
-class TGeoVolume;
-
-class AliITSUv11Layer : public AliITSv11Geometry {
-  public:
-    AliITSUv11Layer();
-    AliITSUv11Layer(Int_t debug);
-    AliITSUv11Layer(Int_t lay, Int_t debug);
-    AliITSUv11Layer(Int_t lay, Bool_t turbo, Int_t debug);
-    AliITSUv11Layer(const AliITSUv11Layer &source);
-    AliITSUv11Layer& operator=(const AliITSUv11Layer &source);
-    virtual ~AliITSUv11Layer();
-    //
-    Bool_t    IsTurbo() {return fIsTurbo;};
-
-    Double_t  GetLadderThick() const {return fLadderThick;};
-    Double_t  GetLadderTilt()  const {return fLadderTilt;};
-    Double_t  GetLadderWidth() const {return fLadderWidth;};
-    Double_t  GetSensorThick() const {return fSensorThick;};
-    Double_t  GetNLadders()    const {return fNLadders;};
-    Double_t  GetNModules()    const {return fNModules;};
-    Double_t  GetRadius()      const {return fLayRadius;};
-    Double_t  GetPhi0()        const {return fPhi0;};
-    Double_t  GetZLength()     const {return fZLength;};
-    Int_t     GetDetType()     const {return fDetTypeID;}
-    //
-    void      SetLadderThick(Double_t t)    {fLadderThick = t;};
-    void      SetLadderTilt(Double_t t);
-    void      SetLadderWidth(Double_t w);
-    void      SetSensorThick(Double_t t)    {fSensorThick = t;};
-    void      SetNLadders(Int_t n)          {fNLadders = n;};
-    void      SetNModules(Int_t m)          {fNModules = m;};
-    void      SetRadius(Double_t r)         {fLayRadius = r;};
-    void      SetPhi0(Double_t phi)         {fPhi0 = phi;}
-    void      SetZLength(Double_t z)        {fZLength   = z;};
-    void      SetDetType(Int_t tp)          {fDetTypeID = tp;}
-    virtual void CreateLayer(TGeoVolume *moth,const TGeoManager *mgr=gGeoManager);
-
-  private:
-    void CreateLayerTurbo(TGeoVolume *moth,const TGeoManager *mgr=gGeoManager);
-
-    Double_t RadiusOfTurboContainer();
-
-    TGeoVolume* CreateLadder(const TGeoManager *mgr=gGeoManager);
-    TGeoVolume* CreateModule(Double_t x,Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
-
-    Int_t     fLayerNumber; // Current layer number
-    Double_t  fPhi0;        // lab phi of 1st ladder, in degrees!!!
-    Double_t  fLayRadius;   // Inner radius of this layer
-    Double_t  fZLength;     // Z length of this layer
-    Double_t  fSensorThick; // Sensor thickness
-    Double_t  fLadderThick; // Ladder thickness
-    Double_t  fLadderWidth; // Ladder width (for turbo layers only)
-    Double_t  fLadderTilt;  // Ladder tilt angle (for turbo layers only) in degrees
-    Int_t     fNLadders;    // Number of ladders in this layer
-    Int_t     fNModules;    // Number of modules per ladder in this layer
-    UInt_t    fDetTypeID;   // detector type id
-    Bool_t    fIsTurbo;     // True if this layer is a "turbo" layer
-  // Parameters for the Upgrade geometry
-
-    static const Double_t fgkDefaultSensorThick; // Default sensor thickness
-    static const Double_t fgkDefaultLadderThick; // Default ladder thickness
-
-  ClassDef(AliITSUv11Layer,0) // ITS v11 Upgrade geometry
-};
-
-#endif
index f2c6e0c29c544d947e4216a720c17371ef11575e..55846edf6f1aa3c1dc051eb8fab75a6560eba636 100644 (file)
 set ( SRCS     
 #v0/AliITSupgrade.cxx 
 #v0/AliITSupgradeDigitizer.cxx 
+#AliITSUv11.cxx 
+#AliITSUv11Layer.cxx 
 #
 AliITSU.cxx 
 AliITSUv0.cxx 
 AliITSUv0Layer.cxx 
-AliITSUv11.cxx 
-AliITSUv11Layer.cxx 
 AliITSUModule.cxx
 AliITSUSimuParam.cxx
 AliITSUSimulation.cxx
index e74c21a83cbf72370d45caaa2fa934ca755db063..c49c7a8cef048d8c38cd302caaca09bef34df650 100644 (file)
@@ -20,8 +20,8 @@
 #pragma link C++ class  AliITSU+;
 #pragma link C++ class  AliITSUv0+;
 #pragma link C++ class  AliITSUv0Layer+;
-#pragma link C++ class  AliITSUv11+;
-#pragma link C++ class  AliITSUv11Layer+;
+//#pragma link C++ class  AliITSUv11+;       // obsolete
+//#pragma link C++ class  AliITSUv11Layer+;  // obsolete
 #pragma link C++ class  AliITSUModule+;
 #pragma link C++ class  AliITSUSimuParam+;
 #pragma link C++ class  AliITSUSimulation+;
diff --git a/ITS/UPGRADE/testITSU/CreateITSUsinglesegm.C b/ITS/UPGRADE/testITSU/CreateITSUsinglesegm.C
new file mode 100644 (file)
index 0000000..2575357
--- /dev/null
@@ -0,0 +1,138 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TSystem.h>
+#include <TMath.h>
+#endif
+
+//---------------------------------------
+double radii2Turbo(double rMin,double rMid,double rMax, double sensW)
+{
+  // compute turbo angle from radii and sensor width
+  return TMath::ASin((rMax*rMax-rMin*rMin)/(2*rMid*sensW))*TMath::RadToDeg();
+}
+
+double radii2Phi(double rMin,double rMid,double rMax, double sensW)
+{
+  // compute phi coverage
+  return 2*TMath::ACos((rMax+rMin)*
+                      (rMid*rMid+rMin*rMax-sensW*sensW/4.)/
+                      (4.*rMid*rMax*rMin));
+}
+
+void CreateITSUsinglesegm()
+{
+  //
+  gSystem->Load("libITSUpgradeBase.so");
+  gSystem->Load("libITSUpgradeSim.so");
+
+
+  // build ITS upgrade detector
+  // sensitive area 13x15mm (X,Z) with 20x20 micron pitch, 2mm dead zone on readout side and 50 micron guardring
+  const double kSensThick = 18e-4;
+  const double kPitchX = 20e-4;
+  const double kPitchZ = 20e-4;
+  const int    kNRow   = 650; 
+  const int    kNCol   = 750;
+  const int    kNChips = 2;
+  const double kLrThick03 = 120e-4;   // -> effective thickness for ~0.3%X layers
+  const double kLrThick08 = 600e-4;   // -> effective thickness for ~0.8%X layers
+  //
+  const double kReadOutEdge = 0.2;   // width of the readout edge (passive bottom)
+  const double kGuardRing   = 50e-4; // width of passive area on left/right/top of the sensor
+  //
+  const int kNLr = 7;
+  const int kNLrInner = 3;
+  enum {kRmn,kRmd,kRmx,kNModPerStave,kPhi0,kNStave,kNPar};
+  const double tdr5dat[kNLr][kNPar] = { 
+    {2.24, 2.34, 2.67,  9., 16.37, 12}, // for each inner layer: rMin,rMid,rMax,NMod/Stave,phi0, nStave
+    {3.01, 3.15, 3.46,  9., 12.03, 16},
+    {3.78, 3.93, 4.21,  9., 10.02, 20},
+    {-1,   19.4, -1,    28., 0.  ,  0},  // for others: -, rMid, -, NMod/Stave, phi0, nStave
+    {-1,   24.7, -1,    28., 0.  ,  0},
+    {-1,   35.32,-1,    49., 0.  ,  0},
+    {-1,   40.52,-1,    49., 0.  ,  0}
+  };
+
+  // create segmentations:
+  AliITSUSegmentationPix* seg0 = new AliITSUSegmentationPix(0,        // segID (0:9)
+                                                           kNChips,  // chips per module
+                                                           kNChips*kNCol,    // ncols (total for module)
+                                                           kNRow,    // nrows
+                                                           kPitchX,  // default row pitch in cm
+                                                           kPitchZ,  // default col pitch in cm
+                                                           kSensThick,  // sensor thickness in cm
+                                                           -1,     // no special left col between chips
+                                                           -1,     // no special right col between chips
+                                                           kGuardRing, // left
+                                                           kGuardRing, // right
+                                                           kGuardRing, // top
+                                                           kReadOutEdge  // bottom
+                                                           );    // see AliITSUSegmentationPix.h for extra options
+  seg0->Store(AliITSUGeomTGeo::GetITSsegmentationFileName());
+  seg0->Print();
+  //
+  const double kMinOvl = 0.01; // require active zones overlap
+  const double kTilt = -10.; // tilt in degrees for outer layers
+  double dzLr,rLr,phi0,turbo,thick;
+  AliITSUSegmentationPix* seg=0;
+  int nStaveLr,nModPerStaveLr,idLr;
+  //      virtual void   DefineLayerTurbo(const Int_t nlay, const Double_t r,  const Double_t zlen, const Int_t nladd,   const Int_t nmod, const Double_t width,
+  //                             const Double_t tilt,   const Double_t lthick = 0.,    const Double_t dthick = 0.,   const UInt_t detType=0);
+  AliITSUv0 *ITS  = new AliITSUv0("ITS Upgrade",7);
+  ITS->SetStaveModel(AliITSUv0::kModel22);
+  //
+  const int kNWrapVol = 3;
+  const double wrpRMin[kNWrapVol]  = { 2.1, 15.0, 32.0};
+  const double wrpRMax[kNWrapVol]  = { 7.0, 27.0, 43.0};
+  const double wrpZSpan[kNWrapVol] = {28.0, 86.0, 150.0};
+  ITS->SetNWrapVolumes(kNWrapVol); // define wrapper volumes for layers
+  for (int iw=0;iw<kNWrapVol;iw++) ITS->DefineWrapVolume(iw,wrpRMin[iw],wrpRMax[iw],wrpZSpan[iw]);
+  //
+  for (int idLr=0;idLr<kNLr;idLr++) {
+    rLr   = tdr5dat[idLr][kRmd];
+    phi0  = tdr5dat[idLr][kPhi0]; 
+    if (idLr<kNLrInner) {
+      seg = seg0;
+      turbo = -radii2Turbo(tdr5dat[idLr][kRmn],rLr,tdr5dat[idLr][kRmx],seg->Dx());     
+      thick = kLrThick03;
+    }
+    else {
+      seg   = seg0;
+      turbo = kTilt;
+      thick = kLrThick08;
+    }
+    nStaveLr = TMath::Nint(tdr5dat[idLr][kNStave]);
+    if (nStaveLr<1) nStaveLr = getNStaves(seg,kTilt,rLr,kMinOvl); // calculate automatically
+    nModPerStaveLr =  TMath::Nint(tdr5dat[idLr][kNModPerStave]);
+    ITS->DefineLayerTurbo(idLr, phi0, rLr, nModPerStaveLr*seg->Dz(), nStaveLr, nModPerStaveLr, 
+                         seg->Dx(), turbo, thick, seg->Dy(), seg->GetDetTypeID());
+    printf("Add Lr%d: R=%6.2f DZ:%6.2f Turbo:%+6.2f Staves:%3d NMod/Stave:%3d\n",idLr,rLr,nModPerStaveLr*seg->Dz(),turbo,nStaveLr,nModPerStaveLr);
+    //
+  }
+  //  
+}
+
+Int_t getNStaves(AliITSUSegmentationPix* seg, double tilt, double r0, double minOvl)
+{
+  double dphi = (90.-tilt)*TMath::DegToRad();
+  double cs = TMath::Cos(dphi);
+  double sn = TMath::Sin(dphi);  
+  double dx = seg->Dx();
+  double tL = -dx/2 + seg->GetGuardBot();
+  double tU =  dx/2 - seg->GetGuardTop();
+  //
+  double xL = r0 + cs*tL;
+  double yL =      sn*tL;
+  double xU = r0 + cs*tU;
+  double yU =      sn*tU;
+  double phiL = TMath::ATan2(yL,xL);
+  double phiU = TMath::ATan2(yU,xU);
+  double dphi = TMath::Abs(phiL-phiU);
+  if (dphi>TMath::Pi()) dphi = TMath::Abs(dphi-TMath::Pi()*2);
+  double span = dphi*r0;
+  //
+  double ov = -1;
+  int nStaveLr = 1 + r0*TMath::Pi()*2/span;
+  do { ov = 1.-r0*TMath::Pi()*2/nStaveLr/span; } while ( minOvl>=0 && ov<minOvl && nStaveLr++ );
+  printf("Reccommend %2d staves for R=%5.2f, ActiveOvl=%5.2f\% (%6.f micron)\n",nStaveLr,r0,ov*100,ov*span*1e4);
+  return nStaveLr;
+}
index 270b6140abd53242c739aaca74e0cefc4ef904a4..6e5f04b399a20b24d2b3173c27cc12a27b3421f0 100644 (file)
@@ -119,6 +119,7 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster():
   fExternalWeight(1),
   fTrackEtaWindow(0.9),    
   fRequireITSRefit(0),
+  fApplySharedClusterCut(0),
   fRecEtaWindow(0.5),
   fTrackPtCut(0.),                                                     
   fJetOutputMinPt(0.150),
@@ -287,6 +288,7 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(const char* name):
   fExternalWeight(1),    
   fTrackEtaWindow(0.9),    
   fRequireITSRefit(0),
+  fApplySharedClusterCut(0),
   fRecEtaWindow(0.5),
   fTrackPtCut(0.),                                                     
   fJetOutputMinPt(0.150),
@@ -1888,6 +1890,10 @@ Int_t  AliAnalysisTaskJetCluster::GetListOfTracks(TList *list,Int_t type){
          continue;
        }
         if(fRequireITSRefit){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+        if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(tr->GetTPCnclsS()) /Double_t(tr->GetTPCncls());
+           if (frac > 0.4) continue;
+        } 
        if(TMath::Abs(tr->Eta())>fTrackEtaWindow){
          if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks());     
          continue;
index 7b21770378b5f1b1a2797e64f41fc5155389edd0..849f83708f1672acd4a751c3d4d69cedba732353 100644 (file)
@@ -63,6 +63,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     virtual void SetAODMCInput(Bool_t b){fUseAODMCInput = b;}
     virtual void SetEventSelection(Bool_t b){fEventSelection = b;}
     virtual void SetRequireITSRefit(Int_t i){fRequireITSRefit=i;}
+    virtual void SetSharedClusterCut(Int_t docut){fApplySharedClusterCut=docut;}
     virtual void SetRecEtaWindow(Float_t f){fRecEtaWindow = f;}
     virtual void SetTrackEtaWindow(Float_t f){fTrackEtaWindow = f;}
     virtual void SetTrackTypeGen(Int_t i){fTrackTypeGen = i;}
@@ -181,6 +182,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     Float_t       fExternalWeight;        // external weight
     Float_t       fTrackEtaWindow;        // eta window used for corraltion plots between rec and gen 
     Int_t         fRequireITSRefit;       // to select hybrids with ITS refit only
+    Int_t         fApplySharedClusterCut; // flag to apply shared cluster cut (needed for some AODs where this cut was not applied in the filtering)
     Float_t       fRecEtaWindow;          // eta window used for corraltion plots between rec and gen 
     Float_t       fTrackPtCut;            // minimum track pt to be accepted
     Float_t       fJetOutputMinPt;        // minimum p_t for jets to be written out
@@ -344,7 +346,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     TList *fHistList; //!leading tracks to be skipped in the randomized event Output list
    
 
-    ClassDef(AliAnalysisTaskJetCluster, 25
+    ClassDef(AliAnalysisTaskJetCluster, 26
 };
  
 #endif
index 6527ad1517272b8a99680c2184b2642dce879c87..0db86f3c6387199659dcc6566cb3540eaca2a114 100644 (file)
@@ -536,7 +536,7 @@ Double_t  AliFastJetBkg::BkgFunction(Double_t */*x*/,Double_t */*par*/)
 }
 
 //___________________________________________________________________
-Bool_t AliFastJetBkg::EmcalAcceptance(const Float_t eta, const Float_t phi, const Float_t radius) const
+Bool_t AliFastJetBkg::EmcalAcceptance(Float_t eta, Float_t phi, Float_t radius) const
 {
   // Apply emcal acceptance cuts
   // To be updated
index 4722beb387328044b691b4585c32f90af535f856..c776d7e5b6a87c84f47a53df0321714bb59861ee 100644 (file)
@@ -39,7 +39,7 @@ class AliFastJetBkg : public TObject
   Float_t          BkgStat();
   Float_t          BkgFastJetCone(TClonesArray* fAODJets);
 
-  Bool_t           EmcalAcceptance(const Float_t eta, const Float_t phi, const Float_t radius) const;
+  Bool_t           EmcalAcceptance(Float_t eta, Float_t phi, Float_t radius) const;
   static Double_t  BkgFunction(Double_t *x,Double_t *par);
     
  private:
index 27188f38641916d5805c8b282fb2838fee82a35f..30e7a9b8f2ac46a7e3851262dd3bc88c0428216f 100644 (file)
@@ -104,7 +104,7 @@ Bool_t AliJetBkg::SignalCutPass(Int_t id, Int_t nTracks)
 }
 
 //----------------------------------------------------------------
-Float_t AliJetBkg::CalcJetAreaEtaCut(Float_t radius, const Float_t etaJet)
+Float_t AliJetBkg::CalcJetAreaEtaCut(Float_t radius, Float_t etaJet)
 {
   // Calculate jet area taking into account an acceptance cut in eta
   AliUA1JetHeader* header = (AliUA1JetHeader*) fHeader;
@@ -125,7 +125,7 @@ Float_t AliJetBkg::CalcJetAreaEtaCut(Float_t radius, const Float_t etaJet)
 }
 
 //----------------------------------------------------------------
-void AliJetBkg::CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t radius, const Int_t nJets, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut)
+void AliJetBkg::CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t radius, Int_t nJets, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut)
 {
   // Calculate jet and bacground areas taking into account an acceptance cut in eta
 
index 2b5068eeaaa60a2121b196e5096666b179cb3153..1761f1c44055c7c1cf77fce8589cabd2280696c3 100644 (file)
@@ -28,8 +28,8 @@ class AliJetBkg : public TObject
   void    SetCalTrkEvent(AliJetCalTrkEvent *evt)  {fEvent=evt;}
   Bool_t  PtCutPass(Int_t id, Int_t nTracks);
   Bool_t  SignalCutPass(Int_t id, Int_t nTracks);
-  Float_t CalcJetAreaEtaCut(Float_t radius, const Float_t etaJet);
-  void    CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t rc, const Int_t nJ, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut);
+  Float_t CalcJetAreaEtaCut(Float_t radius, Float_t etaJet);
+  void    CalcJetAndBckgAreaEtaCut(Bool_t calcOutsideArea, Float_t rc, Int_t nJ, const Float_t* etaJet, Float_t* &areaJet, Float_t &areaOut);
  
   void    SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t&EtbgTotalN, Float_t&sigmaN, 
                        const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, 
index e526882317fbefd6ee64eea3cb4394c2843ef93f..b6d73b11149de794148e1979363e8fc35680ccf7 100644 (file)
@@ -48,7 +48,7 @@ class AliJetFillCalTrkEvent
   virtual AliJetCalTrkEvent* GetCalTrkEvent() const {return fCalTrkEvent;}
 
   // Other
-  virtual void          Exec(Option_t* const /*option*/) {;}
+  virtual void          Exec(Option_t* /*option*/) {;}
   virtual Float_t       EtaToTheta(Float_t arg);
 
  protected:
index 9517a3a71be4eeaa439b603b3300e3ba478aab24..eedd6f99629d93514ca929190c220f3540f7f78b 100644 (file)
@@ -13,7 +13,7 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-// $Id$
+// $Id: AliMUONCalibrationData.cxx 59486 2012-11-07 22:06:24Z laphecet $
 
 #include "AliMUONCalibrationData.h"
 
@@ -63,7 +63,9 @@ ClassImp(AliMUONCalibrationData)
 AliMUONVStore* AliMUONCalibrationData::fgBypassPedestals(0x0);
 AliMUONVStore* AliMUONCalibrationData::fgBypassGains(0x0);
 
-namespace  
+UInt_t AliMUONCalibrationData::fgkDCSSt1Flag(42);
+
+namespace
 {
   void MarkForDeletion(Int_t* indices, Int_t first, Int_t last)
   {
@@ -615,6 +617,92 @@ Bool_t AliMUONCalibrationData::PatchHVValues(TObjArray& values,
   return hvCase=="OTHER" ? kFALSE : kTRUE;
 }
 
+//_____________________________________________________________________________
+void AliMUONCalibrationData::AddToMap(const TMap& sourceMap,
+                                      TMap& destMap,
+                                      const TString& key,
+                                      const char* source,
+                                      const char* dest)
+{
+  /// Remap
+  
+  TString newkey(key);
+  
+  newkey.ReplaceAll(source,dest);
+
+  TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
+
+  destMap.Add(new TObjString(newkey.Data()),pair->Value());
+}
+
+//_____________________________________________________________________________
+void AliMUONCalibrationData::PatchSt1DCSAliases(TMap& hvMap)
+{
+  /// It was discovered (in sept. 2013) that the DCS aliases for St1 was
+  /// wrongly assigned (in the hardware), so the correspondence between DCS channels
+  /// and actual HV channels is wrong for St1 in the DCS (and thus in the DCS archive,
+  /// and so in the OCDB HV object).
+  ///
+  /// It affects all the OCDB object written in 2010-2013.
+  ///
+  /// This method fixes that.
+  
+  if ( hvMap.GetUniqueID() == fgkDCSSt1Flag )
+  {
+    // already clean object. Do nothing
+    return;
+  }
+
+  TIter next(&hvMap);
+  TObjString* hvChannelName;
+  
+  TMap newmap;
+  newmap.SetOwnerKeyValue(kTRUE,kFALSE);
+  
+  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
+  {
+    TString name(hvChannelName->String());
+    TString newname(name);
+    
+    // the problem is limited to St1 = ch1+ch2 (or, in DCS parlance, ch0+ch1)
+    // do it "by hand" as we "only" have 8 names to change
+    
+    if ( name.Contains("Chamber00Left") )
+    {
+      if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
+      
+      if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
+      if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
+      
+      if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
+      if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
+      if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
+    }
+    else if ( name.Contains("Chamber01Left"))
+    {
+      if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
+      if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
+    }
+    else
+    {
+      AddToMap(hvMap,newmap,name,name,name);
+    }
+  }
+  
+  // copy newmap to hvMap
+  
+  TIter nextNewMap(&newmap);
+  while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
+  {
+    TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
+    TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
+      
+    TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
+      
+    oldPair->SetValue(newValues);
+  }
+}
+
 //_____________________________________________________________________________
 TMap*
 AliMUONCalibrationData::CreateHV(Int_t runNumber, 
@@ -633,6 +721,8 @@ AliMUONCalibrationData::CreateHV(Int_t runNumber,
   TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
 
   if (!hvMap) return 0x0;
+
+  PatchSt1DCSAliases(*hvMap);
   
   if (patched)
   {
index aa4049459d4c7350fd36d95b6183288befe6cc5d..23e98dad371f964c9e44a375b6ae60cced06df86 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */
 
-// $Id$
+// $Id: AliMUONCalibrationData.h 59457 2012-11-06 12:36:48Z laphecet $
 
 /// \ingroup calib
 /// \class AliMUONCalibrationData
@@ -143,7 +143,7 @@ public:
   static void Check(Int_t runNumber);
 
   static void BypassStores(AliMUONVStore* ped, AliMUONVStore* gain);
-  
+
 protected:
   /// Not implemented
   AliMUONCalibrationData(const AliMUONCalibrationData& other);
@@ -154,7 +154,15 @@ protected:
   
   static Bool_t CheckHVGroup(TObjArray& values, Int_t first, Int_t last, Double_t& value,
                              Int_t& slope, TString* msg);
-  
+
+  static void PatchSt1DCSAliases(TMap& hvMap);
+
+  static void AddToMap(const TMap& sourceMap,
+                       TMap& destMap,
+                       const TString& key,
+                       const char* source,
+                       const char* dest);
+
 private:
   mutable Bool_t fIsValid; ///<  Whether we were able to correctly initialize
   Int_t fRunNumber; ///<  The run number for which we hold calibrations
@@ -180,7 +188,9 @@ private:
   
   mutable AliMUONVStore* fConfig; //!< configuration of the tracker
   
-  ClassDef(AliMUONCalibrationData,13) // Storage for all MUON calibration data.
+  static UInt_t fgkDCSSt1Flag; //!< flag to indicate that the DCS alias naming is not messed up in St1
+  
+  ClassDef(AliMUONCalibrationData,14) // Storage for all MUON calibration data.
 };
 
 #endif
index 3463933c7784c5c92cefefc97d0de6947f16554b..0d78f303138698642c9e227a3a536b9fbd7d134a 100644 (file)
@@ -360,21 +360,16 @@ AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
         // if card exist
         if (localStruct) {
           
-         loCircuit = crate->GetLocalBoardId(localStruct->GetId());
-
-         if ( !loCircuit ) continue; // empty slot
-
-         AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, kTRUE);
-
-         // skip copy cards
-         if( !localBoard->IsNotified()) 
-            continue;
+          loCircuit = crate->GetLocalBoardId(localStruct->GetId());
+          
+          if ( !loCircuit ) continue; // empty slot
+          
           
           if (fTriggerStore)
           {
             // fill local trigger
             AliMUONLocalTrigger localTrigger;
-           localTrigger.SetLocalStruct(loCircuit, *localStruct);
+            localTrigger.SetLocalStruct(loCircuit, *localStruct);
             fTriggerStore->Add(localTrigger);
           }
           
@@ -383,8 +378,8 @@ AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
             //FIXEME should find something better than a TArray
             TArrayS xyPattern[2];
             
-           localStruct->GetXPattern(xyPattern[0]);
-           localStruct->GetYPattern(xyPattern[1]);
+            localStruct->GetXPattern(xyPattern[0]);
+            localStruct->GetYPattern(xyPattern[1]);
             
             TriggerDigits(loCircuit, xyPattern, *fDigitStore);
           }
@@ -408,6 +403,13 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
   Int_t detElemId;
 
   AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard);
+  
+  if ( ! localBoard->IsNotified() ) {
+    // Copy board
+    // The mapping is not correct for copy boards
+    // Use the one of corresponding phyiscal board
+    nBoard = localBoard->GetInputXfrom();
+  }
 
   Int_t n,b;
 
index 25fc4be82cf0a5e7edf09fb329eab98440ec3a17..5566d951350df9f53f03c69502e47c778545c972 100644 (file)
@@ -206,17 +206,6 @@ AliMUONLocalTriggerBoard::~AliMUONLocalTriggerBoard()
 }
 
 
-//___________________________________________
-Int_t AliMUONLocalTriggerBoard::GetNumber() const 
-{
-/// return board number for notified boards
-
-    if (fMpLocalBoard->IsNotified())
-       return fMpLocalBoard->GetId();
-    else 
-       return 0;
-}
-
 //___________________________________________
 void AliMUONLocalTriggerBoard::Reset()
 {
@@ -249,50 +238,12 @@ void AliMUONLocalTriggerBoard::ResetResponse()
 }
 
 
-//___________________________________________
-void AliMUONLocalTriggerBoard::Setbit(Int_t strip, Int_t cathode, Int_t chamber)
-{
-/// 0 .. LBS   :   N-1 .. MSB
-   TBits w, m;
-
-   UShort_t xy = fXY[cathode][chamber], mask = fMask[cathode][chamber];
-
-   w.Set(16,&xy);
-   m.Set(16,&mask);
-
-   Int_t s = strip - int(strip / 16) * 16;
-
-   w.SetBitNumber(s);
-   
-   w &= m;
-
-   UShort_t value;
-
-   w.Get(&value);
-
-   fXY[cathode][chamber] = value;
-}
-
 //___________________________________________
 void AliMUONLocalTriggerBoard::SetbitM(Int_t strip, Int_t cathode, Int_t chamber)
 {
 /// 0 .. LBS   :   N-1 .. MSB
-   TBits w, m;
-
-   UShort_t xy = fXY[cathode][chamber], mask = fMask[cathode][chamber];
-
-   w.Set(16,&xy);
-   m.Set(16,&mask);
-
-   w.SetBitNumber(strip);
-   
-   w &= m;
-
-   UShort_t value;
-
-   w.Get(&value);
-
-   fXY[cathode][chamber] = value;
+  UShort_t stripBit = ( (1<<strip) & 0xFFFF );
+  fXY[cathode][chamber] |= ( stripBit & fMask[cathode][chamber] );
 }
 
 
index eb6f9c4e1eeee7cba03c3c92c9c7ae832c21b96a..f3c4c4bbafe55ac3cad39003634c4da51dc29bce 100644 (file)
@@ -32,8 +32,7 @@ class AliMUONLocalTriggerBoard : public AliMUONTriggerBoard
       void             SetLUT(AliMUONTriggerLut* lut) { fLUT = lut; }
                        /// Set Coinc 44 (0/1 = coinc34/coinc44)
       void             SetCoinc44(Int_t coinc44=0) { fCoinc44 = coinc44; }
-      
-      virtual void     Setbit(Int_t strip, Int_t cathode, Int_t chamber);
+    
       virtual void     SetbitM(Int_t strip, Int_t cathode, Int_t chamber);
 
       virtual void     Pattern(const Option_t *option = "X Y") const; // default option displays X then Y bp
@@ -49,24 +48,14 @@ class AliMUONLocalTriggerBoard : public AliMUONTriggerBoard
       virtual Bool_t   GetTC() const {return fMpLocalBoard->GetTC();}
 
                        /// Return Board number
-      virtual Int_t    GetNumber() const;
+      virtual Int_t    GetNumber() const { return fMpLocalBoard->GetId(); }
+    
+      /// Is notified (copy boards are not)
+      virtual Bool_t    IsNotified() const { return fMpLocalBoard->IsNotified(); }
 
                        /// Return Crate name
       virtual TString  GetCrate() const {return fMpLocalBoard->GetCrate();}
 
-
-                       /// Return X34
-      virtual void     GetX34(UShort_t *X) const {for (Int_t i=0;i<2;i++) X[i] = fXY[0][i+2];}
-
-                       /// Set X34
-      virtual void     SetX34(UShort_t *X) {for (Int_t i=0;i<2;i++) fXY[0][i+2] = X[i];}
-
-                       /// Return Y
-      virtual void     GetY(UShort_t *Y) const {for (Int_t i=0;i<4;i++) Y[i] = fXY[1][i];}
-
-                       /// Set Y
-      virtual void     SetY(UShort_t *Y) {for (Int_t i=0;i<4;i++) fXY[1][i] = Y[i];}
-
                        /// Return XY
       virtual void     GetXY(UShort_t XY[2][4]) const {for (Int_t i=0;i<2;i++) for (Int_t j=0;j<4;j++) XY[i][j] = fXY[i][j];}
 
index 31857550f256b272f41f2159fbeac32ec01c71c5..4cd7d69c27772c2bb66424733fda05d1796dd463 100644 (file)
@@ -440,14 +440,14 @@ public:
                /// return X pattern array
                void GetXPattern(TArrayS& array) const
                {
-                       Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
+                       Short_t vec[4] = {static_cast<Short_t>(GetX1()), static_cast<Short_t>(GetX2()), static_cast<Short_t>(GetX3()), static_cast<Short_t>(GetX4())};
                        array.Set(4, vec);
                }
        
                /// return Y pattern array
                void GetYPattern(TArrayS& array) const
                {
-                       Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
+                       Short_t vec[4] = {static_cast<Short_t>(GetY1()), static_cast<Short_t>(GetY2()), static_cast<Short_t>(GetY3()), static_cast<Short_t>(GetY4())};
                        array.Set(4, vec);
                }
        
index beaf3c1ec2a469ff63e9d6fcfdf0aa0f526d3ecf..64ccdb0f455f97a2ee20f915a14fef6012b0656f 100644 (file)
@@ -107,7 +107,16 @@ fIsOwnerOfData(kTRUE)
     {
       fData = CreateData(type,*store,startOfValidity);
     }
-    // we do not delete the store, as it's supposedly part of the OCDB cache...
+    delete store;
+  }
+
+  if ( fData )
+  {
+    TString name(fData->GetName());
+    name += "(";
+    name += ocdbPath;
+    name += ")";
+    fData->SetName(name);
   }
   
   AliCDBManager::Instance()->SetDefaultStorage(storage);
index 28ec0bc0049edc78bcc96cff37505e2ae340fa5d..39bb4208c02cfd3f6585c4fc9e13532e37c9d1e9 100644 (file)
@@ -256,9 +256,7 @@ AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData)
       board->SetLUT(lut);
 
       
-       if (localBoardMapping->IsNotified()) {
-         fLocalBoards->Add(localBoardId, board);
-       }
+    fLocalBoards->Add(localBoardId, board);
       
        crate->AddBoard(board, slot);
       
index 13fc26cc12a883baa82ce9884f2b1546cd7610b3..9104af8f87ebe7d6d98132fcc22d3d137c7e2018 100644 (file)
@@ -79,12 +79,6 @@ AliMUONTriggerElectronics::AliMUONTriggerElectronics(AliMUONCalibrationData* cal
  /// CONSTRUCTOR
 ///
 
-  for (Int_t i = 0; i < 2; ++i) {
-    fCopyXInput[i] = new TList();
-    fCopyXInput[i]->SetOwner();
-    fCopyYInput[i] = new TList();
-    fCopyYInput[i]->SetOwner();
-  }
 
   // force loading of mapping if not already done
   if ( !AliMpDDLStore::Instance(kFALSE) )
@@ -92,7 +86,6 @@ AliMUONTriggerElectronics::AliMUONTriggerElectronics(AliMUONCalibrationData* cal
     AliMpCDB::LoadDDLStore();
   }
   
-  SetCopyInput();
   
   Factory(calibData);
   LoadMasks(calibData); 
@@ -105,61 +98,7 @@ AliMUONTriggerElectronics::~AliMUONTriggerElectronics()
 ///
   delete fGlobalTriggerBoard;
   delete fCrates;
-  for (Int_t i = 0; i < 2; ++i) {
-    delete fCopyXInput[i];
-    delete fCopyYInput[i];
-  }
-
-}
-
-//___________________________________________
-void AliMUONTriggerElectronics::SetCopyInput()
-{  
-  /// set list of copy input
-  
-    for (Int_t iDDL = 0; iDDL < 2; ++iDDL) { 
     
-      for(Int_t iReg = 0; iReg < 8; ++iReg){   //reg loop
-      
-       AliMpTriggerCrate* crateMapping = AliMpDDLStore::Instance()->GetTriggerCrate(iDDL, iReg);
-      
-       for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) { 
-        
-         Int_t localBoardFromId = crateMapping->GetLocalBoardId(iLocal);
-         if (!localBoardFromId) continue; //empty slot, should not happen
-        
-          AliMpLocalBoard* localBoardFrom = AliMpDDLStore::Instance()->GetLocalBoard(localBoardFromId);
-         Int_t localBoardToId;
-         if ((localBoardToId = localBoardFrom->GetInputXto())) {
-             AliMpLocalBoard* localBoardTo = AliMpDDLStore::Instance()->GetLocalBoard(localBoardToId);
-             TString crateFrom = localBoardFrom->GetCrate();
-             Int_t   slotFrom  = localBoardFrom->GetSlot();
-             TString crateTo   = localBoardTo->GetCrate();
-             Int_t   slotTo    = localBoardTo->GetSlot();
-          
-             fCopyXInput[0]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateFrom), slotFrom));
-             fCopyXInput[1]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateTo), slotTo));
-             AliDebug(3, Form("copy xInputs from local  %s_%d to %s_%d\n", crateFrom.Data(), slotFrom, 
-                              crateTo.Data(), slotTo));
-         }
-        
-         if ((localBoardToId = localBoardFrom->GetInputYto())) {
-             AliMpLocalBoard* localBoardTo = AliMpDDLStore::Instance()->GetLocalBoard(localBoardToId);
-             TString crateFrom = localBoardFrom->GetCrate();
-             Int_t   slotFrom  = localBoardFrom->GetSlot();
-             TString crateTo   = localBoardTo->GetCrate();
-             Int_t   slotTo    = localBoardTo->GetSlot();
-          
-             fCopyYInput[0]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateFrom), slotFrom));
-             fCopyYInput[1]->Add(new AliMpIntPair(AliMpExMap::GetIndex(crateTo), slotTo));
-             AliDebug(3, Form("copy yInputs from local  %s_%d to %s_%d\n", crateFrom.Data(), slotFrom, 
-                              crateTo.Data(), slotTo));
-          
-         }
-       }
-      }
-    }
 }
 
 //___________________________________________
@@ -220,6 +159,17 @@ void AliMUONTriggerElectronics::Feed(const AliMUONVDigitStore& digitStore)
           if (cathode && b->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) ibitxy += 8;
           
           b->SetbitM(ibitxy,cathode,ichamber-10);
+          
+          if ( cathode == 0 ) {
+            // Particular case of the columns with 22 local boards (2R(L) 3R(L))
+            // Fill copy boards
+            AliMpLocalBoard* mpLocalBoard = AliMpDDLStore::Instance()->GetLocalBoard(nboard);
+            Int_t nboardCopy = mpLocalBoard->GetInputXto();
+            if ( nboardCopy > 0 ) {
+              AliMUONLocalTriggerBoard* copyBoard = fCrates->LocalBoard(nboardCopy);
+              copyBoard->SetbitM(ibitxy,cathode,ichamber-10);
+            }
+          }
         }
         else
         {
@@ -240,58 +190,6 @@ void AliMUONTriggerElectronics::FeedCopyNeighbours()
   /// Feed the local copies
   /// and complete the feed with the information of neighbours
   //
-
-  // Particular case of the columns with 22 local boards (2R(L) 3R(L))   
-  // fill copy input from mapping instead of hardcoded valued (Ch.F)
-  AliMUONTriggerCrate *crate = 0x0; TObjArray *bs = 0x0;
-
-  for (Int_t i = 0; i < fCopyXInput[0]->GetEntries(); ++i) 
-  {
-    AliMpIntPair* pair = (AliMpIntPair*)fCopyXInput[0]->At(i);
-    TString crateFrom  =  AliMpExMap::GetString(pair->GetFirst());
-    Int_t   slotFrom   =  pair->GetSecond();
-
-    pair = (AliMpIntPair*)fCopyXInput[1]->At(i);
-    TString crateTo  =  AliMpExMap::GetString(pair->GetFirst());
-    Int_t   slotTo   =  pair->GetSecond();
-
-    AliDebug(3, Form("copy xInputs from local  %s_%d to %s_%d\n", crateFrom.Data(), slotFrom, 
-                    crateTo.Data(), slotTo));
-
-    UShort_t cX[2];
-    crate = fCrates->Crate(crateFrom); 
-    bs = crate->Boards();
-    AliMUONLocalTriggerBoard *fromxb = (AliMUONLocalTriggerBoard*)bs->At(slotFrom);
-    crate = fCrates->Crate(crateTo); 
-    bs = crate->Boards();
-    AliMUONLocalTriggerBoard *desxb = (AliMUONLocalTriggerBoard*)bs->At(slotTo);
-    fromxb->GetX34(cX); desxb->SetX34(cX);
-
-
-  }
-
-  for (Int_t i = 0; i < fCopyYInput[0]->GetEntries(); ++i) 
-  {
-    AliMpIntPair* pair = (AliMpIntPair*)fCopyYInput[0]->At(i);
-    TString crateFrom  =  AliMpExMap::GetString(pair->GetFirst());
-    Int_t   slotFrom   =  pair->GetSecond();
-
-    pair = (AliMpIntPair*)fCopyYInput[1]->At(i);
-    TString crateTo  =  AliMpExMap::GetString(pair->GetFirst());
-    Int_t   slotTo   =  pair->GetSecond();
-
-    AliDebug(3, Form("copy yInputs from local  %s_%d to %s_%d\n", crateFrom.Data(), slotFrom, 
-                    crateTo.Data(), slotTo));
-
-    UShort_t cY[4];
-    crate = fCrates->Crate(crateFrom); 
-    bs = crate->Boards();
-    AliMUONLocalTriggerBoard *fromyb = (AliMUONLocalTriggerBoard*)bs->At(slotFrom);
-    crate = fCrates->Crate(crateTo); 
-    bs = crate->Boards();
-    AliMUONLocalTriggerBoard *desyb = (AliMUONLocalTriggerBoard*)bs->At(slotTo);
-    fromyb->GetY(cY); desyb->SetY(cY);
-  }
   
   // FILL UP/DOWN OF CURRENT BOARD (DONE VIA J3 BUS IN REAL LIFE)
   AliMUONTriggerCrate* cr;
@@ -467,7 +365,7 @@ void AliMUONTriggerElectronics::LoadMasks(AliMUONCalibrationData* calibData)
       
       Int_t cardNumber = b->GetNumber();
       
-      if (cardNumber) // interface board are not interested
+      if (cardNumber) // skip empty slots
       {
         AliMUONVCalibParam* localBoardMasks = calibData->LocalTriggerBoardMasks(cardNumber);
         for ( Int_t i = 0; i < localBoardMasks->Size(); ++i )
@@ -527,7 +425,7 @@ void AliMUONTriggerElectronics::LocalResponse()
        UShort_t response = board->GetResponse();            
         
        // CRATE CONTAINING INTERFACE BOARD
-       if (board->GetNumber() == 0) // copy boards
+  if (!board->IsNotified()) // copy boards
        {
          if ( response != 0 ) 
            AliWarning(Form("Interface board %s in slot %d of crate %s has a non zero response",
@@ -657,8 +555,6 @@ void AliMUONTriggerElectronics::Digits2Trigger(const AliMUONVDigitStore& digitSt
           //     {
           
           Int_t icirc = board->GetNumber();
-          if (icirc != 0) { // pcrochet 181206: MOOD needs ALL boards
-            
             localTrigger.SetLoCircuit(icirc);
             localTrigger.SetLoStripX(board->GetStripX11());
             localTrigger.SetLoDev(board->GetDev());
@@ -696,7 +592,6 @@ void AliMUONTriggerElectronics::Digits2Trigger(const AliMUONVDigitStore& digitSt
             triggerStore.Add(localTrigger);  
             
           }
-          }
         }
       pRegTrig.SetId(iReg + 8*iSide);
       pRegTrig.SetLocalOutput(regInpLpt, 0);
index 4bf9692071965bd986709e1344b83ff70c79e6ce..4ee8ae9b5a69626dac1f70f855af260d5de625ce 100644 (file)
@@ -72,13 +72,9 @@ class AliMUONTriggerElectronics : public TObject
       AliMUONTriggerElectronics&  operator = (const AliMUONTriggerElectronics& right);
 
       void FeedCopyNeighbours();
-     
-      /// set copy card array
-      void SetCopyInput();
+    
 
    private:
-      TList*                     fCopyXInput[2];         ///< list of copy X input from local to local board
-      TList*                     fCopyYInput[2];         ///< list of copy Y input from local to local board
       AliMUONTriggerCrateStore  *fCrates;             ///< Crate array
       AliMUONGlobalTriggerBoard *fGlobalTriggerBoard; ///< Global trigger board
       
index 6327301a0493b9d127240c3226a17146fa6a56e9..ae4bd54b6b2184a67f9bdddf0e89eb29a6ec7160 100644 (file)
@@ -693,16 +693,12 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
          Int_t loCircuit = crate->GetLocalBoardId(localStruct->GetId());
 
          if ( !loCircuit ) continue; // empty slot
-
+    
          AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
 
          nBoardsInReg++; // Not necessary when regional output will work
          countAllBoards++;
 
-         // skip copy cards
-         if( !localBoard->IsNotified()) 
-           continue;
-
          AliMUONLocalTrigger inputLocalTrigger;
          inputLocalTrigger.SetLocalStruct(loCircuit, *localStruct);
          fTriggerStoreFromRaw->Add(inputLocalTrigger);
@@ -717,6 +713,8 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
          //Get regional inputs -> not checked, hardware read-out doesn't work
          //fTriggerInputRegionalDataLPt[0][loCircuit]=Int_t(((regHeader->GetInput(0))>>(2*iLocal))&1);
          //fTriggerInputRegionalDataLPt[1][loCircuit]=Int_t(((regHeader->GetInput(1))>>((2*iLocal)+1))&1);
+    
+    if ( ! localBoard->IsNotified() ) continue;
 
          //Get local in/outputs
          if (Int_t(localStruct->GetDec())!=0){
@@ -1232,6 +1230,8 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal()
   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {  
     loCircuit = recoLocalTrigger->LoCircuit();
+    // FIXME: skip copy boards for the moment
+    if ( loCircuit > AliMUONConstants::NTriggerCircuit() ) continue;
     Int_t iboard = loCircuit - 1;
 
     FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest,loCircuit);
@@ -1273,6 +1273,8 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal()
   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {  
     loCircuit = recoLocalTrigger->LoCircuit();
+    // FIXME: skip copy boards for the moment
+    if ( loCircuit > AliMUONConstants::NTriggerCircuit() ) continue;
     Int_t iboard = loCircuit - 1;
     
     AliMUONLocalTrigger* inputLocalTrigger = fTriggerStoreFromRaw->FindLocal(loCircuit);
index b6a7f7ed118cf52f463e83d0e80a9aea1f20fe6b..eaf5bc45e49f17d64c57d74828cd5d7989e9792e 100644 (file)
@@ -43,10 +43,10 @@ ClassImp(AliMUONTriggerStoreV1)
 
 //_____________________________________________________________________________
 AliMUONTriggerStoreV1::AliMUONTriggerStoreV1() : AliMUONVTriggerStore(),
-fLocal(new TClonesArray("AliMUONLocalTrigger",234)),
+fLocal(new TClonesArray("AliMUONLocalTrigger",242)),
 fRegional(new TClonesArray("AliMUONRegionalTrigger",16)),
 fGlobal(new TClonesArray("AliMUONGlobalTrigger",1)),
-fEmptyLocal(new TClonesArray("AliMUONLocalTrigger",234))
+fEmptyLocal(new TClonesArray("AliMUONLocalTrigger",242))
 {
   /// ctor
   fLocal->SetOwner(kTRUE);
@@ -176,7 +176,7 @@ AliMUONTriggerStoreV1::FindLocal(Int_t boardNumber) const
     }
   }
   
-  if ( boardNumber>=1 && boardNumber<=234 ) 
+  if ( boardNumber>=1 && boardNumber<=242 )
   {
     AliMUONLocalTrigger empty;
     empty.SetLoCircuit(boardNumber);
index e50aa8653514d533c8c6a46cabb166cd59ac3aad..ada746ae23fd1d8bb53a03a50aeab2e59761882d 100644 (file)
@@ -75,7 +75,6 @@ Bool_t AliMUONTriggerUtilities::Init()
   AliMUONDigitStoreV2R digitStore, digitStorePart;
   AliMUONTriggerStoreV1 triggerStore, triggerStorePart;
 
-//  // In the trigger logic, when the regional input is masked in the
   TArrayI activeBoards(AliMUONConstants::NTriggerCircuit());
 //  for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
 //  {
@@ -140,14 +139,30 @@ Bool_t AliMUONTriggerUtilities::Init()
     Int_t detElemId = dig->DetElemId();
     Int_t board = dig->ManuId();
     Int_t strip = dig->ManuChannel();
-    AliMUONVDigit* currDigit = 0x0;
-    if ( activeBoards[board-1] == 1 ) currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
+    AliMUONVDigit* currDigit = digitStoreMasked.FindObject(detElemId, board, strip, cath);
+    Int_t ich = detElemId/100-11;
+    const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath));
+    AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
     Bool_t isMasked = ( currDigit ) ? kFALSE : kTRUE;
+    
+    if ( currDigit ) {
+      // Check if board is active
+      // For the non-bending plane the digit is created for the first board only
+      // The first board may be masked, but there may be some boards which are not.
+      // If so, the strip won't be masked, so we should keep it
+      Bool_t allBoardsMasked = kTRUE;
+      for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
+        Int_t currBoard = pad.GetLocalBoardId(iloc);
+        if ( activeBoards[currBoard-1] == 1 ) {
+          allBoardsMasked = kFALSE;
+          break;
+        }
+      }
+      isMasked = allBoardsMasked;
+    }
+    
     if ( isMasked ) fMaskedDigitsStore->Add(*((AliMUONVDigit*)dig->Clone()), AliMUONVDigitStore::kDeny);
     else {
-      Int_t ich = detElemId/100-11;
-      const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cath));
-      AliMpPad pad = seg->PadByIndices(dig->PadX(), dig->PadY(), kTRUE);
       for (Int_t iloc=0; iloc<pad.GetNofLocations(); iloc++) {
         Int_t currBoard = pad.GetLocalBoardId(iloc);
         Int_t arrayIndex = GetArrayIndex(cath, ich, currBoard);
index 0c2bff6d4f0e46a0aa6258035e85d20464701dcd..917e954b824edcdbf458cbeb4a0d343e015808ac 100644 (file)
Binary files a/OADB/COMMON/CENTRALITY/data/centrality.root and b/OADB/COMMON/CENTRALITY/data/centrality.root differ
index e268c9d6f943d88d3017350a82f0fe3fa7611639..07e5468365be8a6b0403056ff308a08f77ee562b 100644 (file)
Binary files a/OADB/COMMON/PID/data/TPCPIDResponse.root and b/OADB/COMMON/PID/data/TPCPIDResponse.root differ
index ddccbad0d350b7af8cd06ffd96231b14dfa7750c..02032253f8e32e9dca9a723886f5933312433151 100644 (file)
Binary files a/OADB/COMMON/PID/data/TPCetaMaps.root and b/OADB/COMMON/PID/data/TPCetaMaps.root differ
index fceabbc3bdd90f460c9010d2aa3605bbf04f5583..b98069c4d4d23d00905c5b4177653e06d251c3b9 100644 (file)
@@ -34,16 +34,18 @@ set ( SRCS
  EMCAL/AliEmcalClusTrackMatcherTask.cxx
  EMCAL/AliEmcalCompatTask.cxx
  EMCAL/AliEmcalContainer.cxx
- EMCAL/AliEmcalEsdTpcTrackTask.cxx
+ EMCAL/AliEmcalEsdTrackFilterTask.cxx
  EMCAL/AliEmcalMCTrackSelector.cxx
  EMCAL/AliEmcalParticle.cxx
  EMCAL/AliEmcalParticleMaker.cxx
  EMCAL/AliEmcalPhysicsSelection.cxx
  EMCAL/AliEmcalPhysicsSelectionTask.cxx
  EMCAL/AliEmcalPicoTrackMaker.cxx
+ EMCAL/AliEmcalAodTrackFilterTask.cxx
  EMCAL/AliEmcalSetupTask.cxx
  EMCAL/AliEmcalTenderTask.cxx
  EMCAL/AliEmcalTrackPropagatorTask.cxx
+ EMCAL/AliEmcalTrackPropagatorTaskAOD.cxx
  EMCAL/AliEsdSkimTask.cxx
  EMCAL/AliEsdTrackExt.cxx
  EMCAL/AliParticleContainer.cxx
index 2acbe24fa73e677a7da6f17e5b101da5e092f19e..f76c44aa7ebfa6e3f40a2b51bdff8e9e77ee6ed0 100644 (file)
@@ -68,6 +68,16 @@ set ( SRCS
     muon/AliAnalysisNonMuonTrackCuts.cxx
     muon/AliAnalysisNonPrimaryVertices.cxx
     muon/AliAnalysisTaskAOD2MuonAOD.cxx
+    muon/AliAnalysisTaskMuMu.cxx
+    muon/AliAnalysisMuMuBase.cxx
+    muon/AliAnalysisMuMuGlobal.cxx
+    muon/AliAnalysisMuMuCutRegistry.cxx
+    muon/AliAnalysisMuMuCutElement.cxx
+    muon/AliAnalysisMuMuEventCutter.cxx
+    muon/AliAnalysisMuMuCutCombination.cxx
+    muon/AliAnalysisMuMuSingle.cxx
+    muon/AliAnalysisMuMuMinv.cxx
+    muon/AliAnalysisMuMuNch.cxx
     )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
@@ -76,7 +86,7 @@ string ( REPLACE ".cxx" ".h" EXPORT "${SRCS}" )
 
 set ( DHDR  PWGmuonLinkDef.h)
 
-set ( EINCLUDE  PWG/muon ANALYSIS STEER/AOD STEER/ESD STEER/STEERBase)
+set ( EINCLUDE  RooUnfold/src  PWG/muon ANALYSIS STEER/AOD STEER/ESD STEER/STEERBase)
 
 if( ALICE_TARGET STREQUAL "win32gcc")
         set ( PACKSOFLAGS  ${SOFLAGS} )
index 71adde5c207a2e8cde43c74dbfda02980535c752..50cd4777e760d88ab7eff9241a5427019e48cf6d 100755 (executable)
@@ -242,7 +242,7 @@ class AliCaloPID : public TObject {
   
   void    SetSplitWidthSigma(Float_t s)        { fSplitWidthSigma        = s  ; }
 
-  void    SetPi0MassShiftHighECell(Float_t s)  { s = fMassShiftHighECell      ; }
+  void    SetPi0MassShiftHighECell(Float_t s)  { fMassShiftHighECell     = s  ; }
   
   void    SetPi0MassSelectionParameters    (Int_t inlm, Int_t iparam, Float_t param)
   { if(iparam < 6 ) fMassPi0Param[inlm][iparam] = param ; }
index 91683bd06b9056a6f978a75fe1c4589e7ba329e8..817b9a5706117e9de8855a7e8a86c5706a6570b0 100755 (executable)
@@ -189,7 +189,7 @@ void  AliCaloTrackMCReader::FillCalorimeters(Int_t & iParticle,
     
     Char_t ttype= AliVCluster::kPHOSNeutral;   
     Int_t labels[] = {index};
-    Float_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};
+    Double_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};
     //Create object and write it to file
     AliAODCaloCluster *calo = new AliAODCaloCluster(index,1,labels,momentum.E(), x, NULL, ttype, 0);
     
@@ -214,7 +214,7 @@ void  AliCaloTrackMCReader::FillCalorimeters(Int_t & iParticle,
     
     Char_t ttype= AliVCluster::kEMCALClusterv1;
     Int_t labels[] = {index};
-    Float_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};
+    Double_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};
     //Create object and write it to file
     AliAODCaloCluster *calo = new AliAODCaloCluster(iParticle,1,labels,momentum.E(), x, NULL, ttype, 0);
     
index 24b30addaf9da16efbe37be679c4f7aa0e210a4f..e1cd4743cf7776cc41ecef599962173c4663ede1 100755 (executable)
@@ -88,7 +88,8 @@ fRecalculateClusters(kFALSE),fCorrectELinearity(kTRUE),
 fSelectEmbeddedClusters(kFALSE),
 fTrackStatus(0),             fTrackFilterMask(0),             fTrackFilterMaskComplementary(0),
 fESDtrackCuts(0),            fESDtrackComplementaryCuts(0),   fConstrainTrack(kFALSE),
-fSelectHybridTracks(0),      fSelectPrimaryTracks(0),         fSelectSPDHitTracks(kFALSE),
+fSelectHybridTracks(0),      fSelectPrimaryTracks(0),
+fSelectSPDHitTracks(0),      fSelectFractionTPCSharedClusters(0), fCutTPCSharedClustersFraction(0),
 fTrackMult(0),               fTrackMultEtaCut(0.9),
 fReadStack(kFALSE),          fReadAODMCParticles(kFALSE),
 fDeltaAODFileName(""),       fFiredTriggerClassName(""),
@@ -660,6 +661,9 @@ void AliCaloTrackReader::InitParameters()
   fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
   fTrackFilterMaskComplementary = 0; // in case of hybrid tracks, without using the standard method
   
+  fSelectFractionTPCSharedClusters = kTRUE;
+  fCutTPCSharedClustersFraction = 0.4,
+  
   fESDtrackCuts = 0;
   fESDtrackComplementaryCuts = 0;
   
@@ -1494,12 +1498,26 @@ void AliCaloTrackReader::FillInputCTS()
           if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
         }
         
-        if ( fSelectPrimaryTracks )
+        if ( fSelectFractionTPCSharedClusters )
         {
-          if ( aodtrack->GetType()!= AliAODTrack::kPrimary ) continue ;
+          Double_t frac = Double_t(aodtrack->GetTPCnclsS()) / Double_t(aodtrack->GetTPCncls());
+          if (frac > fCutTPCSharedClustersFraction)
+          {
+             if (fDebug > 2 )printf("\t Reject track, shared cluster fraction %f > %f\n",frac, fCutTPCSharedClustersFraction);
+            continue ;
+          }
         }
         
-        if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
+        if ( fSelectPrimaryTracks )
+        {
+          if ( aodtrack->GetType()!= AliAODTrack::kPrimary )
+          {
+             if (fDebug > 2 ) printf("\t Remove not primary track\n");
+            continue ;
+          }
+        }
+
+        if (fDebug > 2 ) printf("\t accepted track! \n");
         
         //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
         // info stored here
@@ -2200,7 +2218,7 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
   Bool_t  badClMax    = kFALSE;
   Bool_t  badCeMax    = kFALSE;
   Bool_t  exoMax      = kFALSE;
-  Int_t   absIdMaxTrig= -1;
+//  Int_t   absIdMaxTrig= -1;
   Int_t   absIdMaxMax = -1;
   
   Int_t   nOfHighECl  = 0 ;
@@ -2229,7 +2247,7 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
     
     Bool_t   badCluster = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),
                                                                                          clus->GetCellsAbsId(),clus->GetNCells());
-    UShort_t cellMax[]  = {absIdMax};
+    UShort_t cellMax[]  = {(UShort_t) absIdMax};
     Bool_t   badCell    = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),cellMax,1);
     
     // if cell is bad, it can happen that time calibration is not available,
@@ -2303,7 +2321,7 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
               fTriggerClusterIndex = iclus;
               fTriggerClusterId    = idclus;
               fIsTriggerMatch      = kTRUE;
-              absIdMaxTrig         = absIdMax;
+//              absIdMaxTrig         = absIdMax;
             }
           }
         }// cell patch loop
index 3b2da754b54159123c361c86e70339d41b3386b6..d5b4a591a05b31f3ba964cade5a7e10b77446cc9 100755 (executable)
@@ -221,7 +221,7 @@ public:
   virtual Bool_t   FillInputEvent(Int_t iEntry, const char *currentFileName)  ;
   virtual void     FillInputCTS() ;
   virtual void     FillInputEMCAL() ;
-  virtual void     FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) ;
+  virtual void     FillInputEMCALAlgorithm(AliVCluster * clus, Int_t iclus) ;
   virtual void     FillInputPHOS() ;
   virtual void     FillInputEMCALCells() ;
   virtual void     FillInputPHOSCells() ;
@@ -423,6 +423,12 @@ public:
   
   void             SwitchOnTrackHitSPDSelection()          { fSelectSPDHitTracks = kTRUE  ; }
   void             SwitchOffTrackHitSPDSelection()         { fSelectSPDHitTracks = kFALSE ; }
+
+  void             SwitchOnAODTrackSharedClusterSelection() { fSelectFractionTPCSharedClusters = kTRUE  ; }
+  void             SwitchOffAODTrackSharedClusterSelection(){ fSelectFractionTPCSharedClusters = kFALSE ; }
+
+  void             SetTPCSharedClusterFraction(Float_t fr) { fCutTPCSharedClustersFraction = fr   ; }
+  Float_t          GetTPCSharedClusterFraction() const     { return fCutTPCSharedClustersFraction ; }
   
   Int_t            GetTrackMultiplicity()            const { return fTrackMult            ; }
   Float_t          GetTrackMultiplicityEtaCut()      const { return fTrackMultEtaCut      ; }
@@ -548,7 +554,7 @@ public:
   virtual Float_t  GetPtHardAndClusterFactor()               const { return  fPtHardAndClusterPtFactor    ; }
   virtual void     SetPtHardAndClusterPtFactor(Float_t factor)     { fPtHardAndClusterPtFactor = factor   ; }          
   
-  virtual Bool_t   IsHIJINGLabel(const Int_t label);
+  virtual Bool_t   IsHIJINGLabel(Int_t label);
   void             SetGeneratorMinMaxParticles();
   void             SwitchOnAcceptOnlyHIJINGLabels()          { fAcceptOnlyHIJINGLabels = kTRUE  ; }
   void             SwitchOffAcceptOnlyHIJINGLabels()         { fAcceptOnlyHIJINGLabels = kFALSE ; }
@@ -644,6 +650,8 @@ public:
   Bool_t           fSelectHybridTracks ;       // Select CTS tracks of type hybrid (only for AODs)
   Bool_t           fSelectPrimaryTracks ;      // Select CTS tracks of type hybrid (only for AODs)
   Bool_t           fSelectSPDHitTracks ;       // Ensure that track hits SPD layers
+  Bool_t           fSelectFractionTPCSharedClusters; // Accept only TPC tracks with over a given fraction of shared clusters
+  Float_t          fCutTPCSharedClustersFraction;    // Fraction of TPC shared clusters to be accepted.
   Int_t            fTrackMult          ;       // Track multiplicity
   Float_t          fTrackMultEtaCut    ;       // Track multiplicity eta cut
   Bool_t           fReadStack          ;       // Access kine information from stack
@@ -764,7 +772,7 @@ public:
   AliCaloTrackReader(              const AliCaloTrackReader & r) ; // cpy ctor
   AliCaloTrackReader & operator = (const AliCaloTrackReader & r) ; // cpy assignment
   
-  ClassDef(AliCaloTrackReader,63)
+  ClassDef(AliCaloTrackReader,64)
   
 } ;
 
index 464e38679a07a08cecaab9059c41d12a351b99d3..70769423eda3eef84739b5e7576240252fb1e37a 100755 (executable)
@@ -1550,11 +1550,14 @@ void AliCalorimeterUtils::SplitEnergy(Int_t absId1, Int_t absId2,
     {
       //printf("iDigit %d, absId %d, Ecell %f\n",iDigit,absIdList[iDigit], cells->GetCellAmplitude(absIdList[iDigit]));
       sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ;
-      if(icol > maxCol) maxCol = icol;
-      if(icol < minCol) minCol = icol;
-      if(irow > maxRow) maxRow = irow;
-      if(irow < minRow) minRow = irow;
-      hClusterMap->Fill(icol,irow,ec);
+      if(sm > -1 && sm  < 12) // just to avoid compilation warning
+      {
+        if(icol > maxCol) maxCol = icol;
+        if(icol < minCol) minCol = icol;
+        if(irow > maxRow) maxRow = irow;
+        if(irow < minRow) minRow = irow;
+        hClusterMap->Fill(icol,irow,ec);
+      }
     }
     
   }
index 132f3ca6ce7714a3a7dc4ba33e21cf03d569d97b..93f36d1e3a2c7f990b09d0c0212c1b265e4d6ee4 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: AliAnalysisTaskEmcal.cxx 64518 2013-10-14 12:44:52Z loizides $
+// $Id$
 //
 // Emcal base analysis task.
 //
@@ -400,7 +400,7 @@ void AliAnalysisTaskEmcal::UserExec(Option_t *)
 }
 
 //________________________________________________________________________
-Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, const Int_t c) const
+Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster *clus, Int_t c) const
 {
   // Return true if cluster is accepted.
 
@@ -1040,7 +1040,7 @@ AliClusterContainer* AliAnalysisTaskEmcal::AddClusterContainer(const char *n) {
 }
 
 //________________________________________________________________________
-AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(const Int_t i) const {
+AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(Int_t i) const {
   // Get i^th particle container
 
   if(i<0 || i>fParticleCollArray.GetEntriesFast()) return 0;
@@ -1049,7 +1049,7 @@ AliParticleContainer* AliAnalysisTaskEmcal::GetParticleContainer(const Int_t i)
 }
 
 //________________________________________________________________________
-AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(const Int_t i) const {
+AliClusterContainer* AliAnalysisTaskEmcal::GetClusterContainer(Int_t i) const {
   // Get i^th cluster container
 
   if(i<0 || i>fClusterCollArray.GetEntriesFast()) return 0;
index e9d785f8015bffa206917cfce8999c3102b8261e..2891c4e6c0696fa88b60092f1be68791d67efb11 100644 (file)
@@ -89,8 +89,8 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   void                        RemoveParticleContainer(Int_t i=0)                      { fParticleCollArray.RemoveAt(i);} 
   void                        RemoveClusterContainer(Int_t i=0)                       { fClusterCollArray.RemoveAt(i);} 
 
-  AliParticleContainer       *GetParticleContainer(const Int_t i=0)   const;
-  AliClusterContainer        *GetClusterContainer(const Int_t i=0)    const;
+  AliParticleContainer       *GetParticleContainer(Int_t i=0)   const;
+  AliClusterContainer        *GetClusterContainer(Int_t i=0)    const;
   AliParticleContainer       *GetParticleContainer(const char* name)  const;
   AliClusterContainer        *GetClusterContainer(const char* name)   const;
 
@@ -102,8 +102,8 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   TClonesArray               *GetArrayFromEvent(const char *name, const char *clname=0);
   Bool_t                      PythiaInfoFromFile(const char* currFile, Float_t &fXsec, Float_t &fTrials, Int_t &pthard);
 
-  TClonesArray               *GetParticleArray(const Int_t i=0)                  const;
-  TClonesArray               *GetClusterArray(const Int_t i=0)                   const;
+  TClonesArray               *GetParticleArray(Int_t i=0)                  const;
+  TClonesArray               *GetClusterArray(Int_t i=0)                   const;
 
   AliVParticle               *GetAcceptParticleFromArray(Int_t p, Int_t c=0)     const;
   AliVCluster                *GetAcceptClusterFromArray(Int_t cl, Int_t c=0)     const;
diff --git a/PWG/EMCAL/AliEmcalAodTrackFilterTask.cxx b/PWG/EMCAL/AliEmcalAodTrackFilterTask.cxx
new file mode 100644 (file)
index 0000000..ee59e3c
--- /dev/null
@@ -0,0 +1,205 @@
+// $Id: AliEmcalAodTrackFilterTask.cxx | Fri Dec 6 10:29:20 2013 +0100 | Constantin Loizides  $
+//
+// Class to filter Aod tracks
+//
+// Author: C.Loizides
+
+#include <TClonesArray.h>
+#include <TRandom3.h>
+#include <AliAODEvent.h>
+#include <AliAODTrack.h>
+#include <AliAnalysisManager.h>
+#include <AliLog.h>
+#include <AliEMCALRecoUtils.h>
+#include "AliEmcalAodTrackFilterTask.h"
+
+ClassImp(AliEmcalAodTrackFilterTask)
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask() : 
+  AliAnalysisTaskSE("AliEmcalAodTrackFilterTask"),
+  fTracksOutName("PicoTracks"),
+  fTracksInName("tracks"),
+  fMinTrackPt(0),
+  fMaxTrackPt(1000),
+  fMinTrackEta(-10),
+  fMaxTrackEta(10),
+  fMinTrackPhi(-10),
+  fMaxTrackPhi(10),
+  fTrackEfficiency(1),
+  fIncludeNoITS(kTRUE),
+  fUseNegativeLabels(kTRUE),
+  fIsMC(kFALSE),
+  fCutMaxFrShTPCClus(0.4),
+  fModifyTrack(kTRUE),
+  fDoPropagation(kFALSE),
+  fDist(440),
+  fTracksIn(0),
+  fTracksOut(0)
+{
+  // Constructor.
+
+  fAODfilterBits[0] = -1;
+  fAODfilterBits[1] = -1;
+}
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask(const char *name) : 
+  AliAnalysisTaskSE(name),
+  fTracksOutName("PicoTracks"),
+  fTracksInName("tracks"),
+  fMinTrackPt(0),
+  fMaxTrackPt(1000),
+  fMinTrackEta(-10),
+  fMaxTrackEta(10),
+  fMinTrackPhi(-10),
+  fMaxTrackPhi(10),
+  fTrackEfficiency(1),
+  fIncludeNoITS(kTRUE),
+  fUseNegativeLabels(kTRUE),
+  fIsMC(kFALSE),
+  fCutMaxFrShTPCClus(0.4),
+  fModifyTrack(kTRUE),
+  fDoPropagation(kFALSE),
+  fDist(440),
+  fTracksIn(0),
+  fTracksOut(0)
+{
+  // Constructor.
+
+  fAODfilterBits[0] = -1;
+  fAODfilterBits[1] = -1;
+  fBranchNames = "AOD:tracks";
+}
+
+//________________________________________________________________________
+AliEmcalAodTrackFilterTask::~AliEmcalAodTrackFilterTask()
+{
+  // Destructor.
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::UserCreateOutputObjects()
+{
+  // Create my user objects.
+
+  fTracksOut = new TClonesArray("AliAODTrack");
+  fTracksOut->SetName(fTracksOutName);
+}
+
+//________________________________________________________________________
+void AliEmcalAodTrackFilterTask::UserExec(Option_t *) 
+{
+  // Main loop, called for each event.
+
+  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+  if (!am) {
+    AliError("Manager zero, returning");
+    return;
+  }
+
+  // retrieve tracks from input.
+  if (!fTracksIn) { 
+    fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName));
+    if (!fTracksIn) {
+      AliError(Form("Could not retrieve tracks %s!", fTracksInName.Data())); 
+      return;
+    }
+    if (!fTracksIn->GetClass()->GetBaseClass("AliVParticle")) {
+      AliError(Form("%s: Collection %s does not contain AliVParticle objects!", GetName(), fTracksInName.Data())); 
+      return;
+    }
+  }
+
+  // add tracks to event if not yet there
+  fTracksOut->Delete();
+  if (!(InputEvent()->FindListObject(fTracksOutName))) {
+    InputEvent()->AddObject(fTracksOut);
+  }
+
+  // loop over tracks
+  const Int_t Ntracks = fTracksIn->GetEntriesFast();
+  for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) {
+
+    AliAODTrack *track = static_cast<AliAODTrack*>(fTracksIn->At(iTracks));
+
+    if (!track)
+      continue;
+
+    if (track->Pt() > fMaxTrackPt || track->Pt() < fMinTrackPt)
+      continue;
+
+    if (track->Eta() < fMinTrackEta || track->Eta() > fMaxTrackEta || 
+       track->Phi() < fMinTrackPhi || track->Phi() > fMaxTrackPhi)
+      continue;
+
+    Int_t type = -1;
+
+    if (fAODfilterBits[0] < 0) {
+      if (track->IsHybridGlobalConstrainedGlobal())
+       type = 3;
+      else /*not a good track*/
+       continue;
+    } else {
+      if (track->TestFilterBit(fAODfilterBits[0])) {
+       type = 0;
+      } else if (track->TestFilterBit(fAODfilterBits[1])) {
+       if ((track->GetStatus()&AliVTrack::kITSrefit)==0) {
+         if (fIncludeNoITS)
+           type = 2;
+         else
+           continue;
+       } else {
+         type = 1;
+       }
+      }
+      else {/*not a good track*/
+       continue;
+      }
+    }
+
+    if (fCutMaxFrShTPCClus > 0) {
+      Double_t frac = Double_t(track->GetTPCnclsS()) / Double_t(track->GetTPCncls());
+      if (frac > fCutMaxFrShTPCClus) 
+       continue;
+    }
+
+    if (fTrackEfficiency < 1) {
+      Double_t r = gRandom->Rndm();
+      if (fTrackEfficiency < r) 
+       continue;
+    }
+
+    Int_t label = 0;
+    if (fIsMC) {
+      if (fUseNegativeLabels)
+       label = track->GetLabel();
+      else 
+       label = TMath::Abs(track->GetLabel());
+    
+      if (label == 0) 
+       AliDebug(2,Form("Track %d with label==0", iTracks));
+    }
+
+    AliAODTrack *newt = new ((*fTracksOut)[nacc]) AliAODTrack(*track);
+    if (fDoPropagation)
+      AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(newt,fDist);
+    if (fModifyTrack) {
+      newt->SetLabel(label);
+      if (type==0) {
+        newt->SetBit(BIT(27),0);
+        newt->SetBit(BIT(28),0);
+      } else if (type==1) {
+        newt->SetBit(BIT(27),1);
+        newt->SetBit(BIT(28),0);
+      } else if (type==2) {
+        newt->SetBit(BIT(27),1);
+        newt->SetBit(BIT(28),1);
+      } else if (type==3) {
+        newt->SetBit(BIT(27),0);
+        newt->SetBit(BIT(28),1);
+      }
+    }
+    ++nacc;
+  }
+}
diff --git a/PWG/EMCAL/AliEmcalAodTrackFilterTask.h b/PWG/EMCAL/AliEmcalAodTrackFilterTask.h
new file mode 100644 (file)
index 0000000..27e0bac
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef ALIEMCALAODTRACKFILTERTASK_H
+#define ALIEMCALAODTRACKFILTERTASK_H
+
+// $Id$
+
+class TClonesArray;
+class AliVEvent;
+class AliVTrack;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalAodTrackFilterTask : public AliAnalysisTaskSE {
+ public:
+  AliEmcalAodTrackFilterTask();
+  AliEmcalAodTrackFilterTask(const char *name);
+  virtual ~AliEmcalAodTrackFilterTask();
+
+  void UserCreateOutputObjects();
+  void UserExec(Option_t *option);
+
+  void SetAODfilterBits(Int_t b0 = 0, Int_t b1 = 0)         { fAODfilterBits[0]  = b0  ; fAODfilterBits[1] = b1  ; }
+  void SetCutMaxFractionSharedTPCClusters(Double_t c = 0.4) { fCutMaxFrShTPCClus = c   ; }
+  void SetDist(Double_t d)                                  { fDist              = d   ; }
+  void SetDoPropagation(Bool_t b)                           { fDoPropagation     = b   ; }
+  void SetIncludeNoITS(Bool_t f)                            { fIncludeNoITS      = f   ; }
+  void SetMC(Bool_t a)                                      { fIsMC              = a   ; }
+  void SetModifyTrack(Bool_t b)                             { fModifyTrack       = b;    }
+  void SetTrackEfficiency(Double_t eff = 0.95)              { fTrackEfficiency   = eff ; }
+  void SetTrackEtaLimits(Double_t min, Double_t max)        { fMaxTrackEta       = max ; fMinTrackEta      = min ; }
+  void SetTrackPhiLimits(Double_t min, Double_t max)        { fMaxTrackPhi       = max ; fMinTrackPhi      = min ; }
+  void SetTrackPtLimits(Double_t min, Double_t max)         { fMaxTrackPt        = max ; fMinTrackPt       = min ; }
+  void SetTracksInName(const char *name)                    { fTracksInName      = name; }
+  void SetTracksOutName(const char *name)                   { fTracksOutName     = name; }
+  void SetUseNegativeLabels(Bool_t f)                       { fUseNegativeLabels = f   ; }
+
+ protected:
+  Int_t              fAODfilterBits[2];     // AOD track filter bit map
+  TString            fTracksOutName;        // name of output track array
+  TString            fTracksInName;         // name of input track array
+  Double_t           fMinTrackPt;           // mix pt of tracks
+  Double_t           fMaxTrackPt;           // max pt of tracks
+  Double_t           fMinTrackEta;          // cut on track eta
+  Double_t           fMaxTrackEta;          // cut on track eta
+  Double_t           fMinTrackPhi;          // cut on track phi
+  Double_t           fMaxTrackPhi;          // cut on track phi
+  Double_t           fTrackEfficiency;      // track efficiency
+  Bool_t             fIncludeNoITS;         // includes tracks with failed ITS refit
+  Bool_t             fUseNegativeLabels;    // whether or not should use negative MC labels
+  Bool_t             fIsMC;                 // whether it is a MC event or not
+  Double_t           fCutMaxFrShTPCClus;    // max fraction of shared TPC clusters
+  Bool_t             fModifyTrack;          // if true then overwrite some fields in AodTrack
+  Bool_t             fDoPropagation;        // if true then propagate all hybrid tracks to EMCal surface
+  Double_t           fDist;                 // distance to surface (440cm default)
+  TClonesArray      *fTracksIn;             //!track array in
+  TClonesArray      *fTracksOut;            //!track array out
+
+ private:
+  AliEmcalAodTrackFilterTask(const AliEmcalAodTrackFilterTask&);            // not implemented
+  AliEmcalAodTrackFilterTask &operator=(const AliEmcalAodTrackFilterTask&); // not implemented
+
+  ClassDef(AliEmcalAodTrackFilterTask, 1); // Task to filter Aod tracks
+};
+#endif
index f8d79bcdc7e66785ab41d50e7298ad405929e9f7..469ff4f6feb6a853661daf37724b9bb286756211 100644 (file)
@@ -20,7 +20,9 @@ ClassImp(AliEmcalClusTrackMatcherTask)
 //________________________________________________________________________
 AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask() : 
   AliAnalysisTaskEmcal("AliEmcalClusTrackMatcherTask",kFALSE),
-  fMaxDistance(0.06)
+  fMaxDistance(0.06),
+  fHistMatchEtaAll(0),
+  fHistMatchPhiAll(0)
 {
   // Constructor.
 
@@ -37,7 +39,9 @@ AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask() :
 //________________________________________________________________________
 AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask(const char *name, Bool_t histo) : 
   AliAnalysisTaskEmcal(name,histo),
-  fMaxDistance(0.06)
+  fMaxDistance(0.06),
+  fHistMatchEtaAll(0),
+  fHistMatchPhiAll(0)
 {
   // Standard constructor.
 
@@ -87,6 +91,11 @@ void AliEmcalClusTrackMatcherTask::UserCreateOutputObjects()
 
   const Int_t nCentChBins = fNcentBins * 2;
 
+  fHistMatchEtaAll = new TH1F("fHistMatchEtaAll", "fHistMatchEtaAll", 400, -0.2, 0.2);
+  fHistMatchPhiAll = new TH1F("fHistMatchPhiAll", "fHistMatchPhiAll", 400, -0.2, 0.2);
+  fOutput->Add(fHistMatchEtaAll);
+  fOutput->Add(fHistMatchPhiAll);
+
   for(Int_t icent=0; icent<nCentChBins; ++icent) {
     for(Int_t ipt=0; ipt<9; ++ipt) {
       for(Int_t ieta=0; ieta<2; ++ieta) {
@@ -174,11 +183,12 @@ Bool_t AliEmcalClusTrackMatcherTask::Run()
            
        fHistMatchEta[centbinch][mombin][etabin]->Fill(deta);
        fHistMatchPhi[centbinch][mombin][etabin]->Fill(dphi);
+        fHistMatchEtaAll->Fill(deta);
+        fHistMatchPhiAll->Fill(dphi);
       }
     }
   }
 
-
   clusters->ResetCurrentID();
   while ((partC = static_cast<AliEmcalParticle*>(clusters->GetNextAcceptParticle()))) {
     if (partC->GetNumberOfMatchedObj() <= 0)
index c4fa8bbba177237a8fbab89861dcefdcfc049cf2..e057fbabaa85ee6a2b294380d21f277292c788ab 100644 (file)
@@ -11,17 +11,17 @@ class AliEmcalClusTrackMatcherTask : public AliAnalysisTaskEmcal {
   AliEmcalClusTrackMatcherTask(const char *name, Bool_t histo=kFALSE);
   virtual ~AliEmcalClusTrackMatcherTask();
 
-  void         UserCreateOutputObjects();
-
   void         SetMaxDistance(Double_t d)       { fMaxDistance = d; }
+  void         UserCreateOutputObjects();
 
  protected:
   void         ExecOnce()                 ;
-  Bool_t       Run();
   Int_t        GetMomBin(Double_t p) const;
+  Bool_t       Run();
 
   Double_t     fMaxDistance            ;// maximum distance to match clusters and tracks
-
+  TH1         *fHistMatchEtaAll        ;//!deta distribution
+  TH1         *fHistMatchPhiAll        ;//!dphi distribution
   TH1         *fHistMatchEta[8][9][2]  ;//!deta distribution
   TH1         *fHistMatchPhi[8][9][2]  ;//!dphi distribution
 
index 74b1c47feef1f53b4ddfe3a4df115d1763e485db..f745fc516441f20f359007f3842a83d759ab00bd 100644 (file)
@@ -18,26 +18,23 @@ class AliEmcalContainer : public TNamed {
   AliEmcalContainer(const char *name); 
   virtual ~AliEmcalContainer(){;}
 
-  void                        SetArrayName(const char *n)         { fClArrayName = n                  ; }
   TClonesArray               *GetArray()                          { return fClArray                   ; }
-  Int_t                       GetNEntries()                 const { return fClArray->GetEntriesFast() ; }
   const TString&              GetArrayName()                const { return fClArrayName               ; }
   Int_t                       GetCurrentID()                const { return fCurrentID-1               ; }
-  void                        SortArray()                         { fClArray->Sort()                  ; }
-  void                        ResetCurrentID(Int_t i=0)           { fCurrentID = i                    ; }
-  void                        SetIsParticleLevel(Bool_t b)        { fIsParticleLevel = b              ; }
   Bool_t                      GetIsParticleLevel()          const { return fIsParticleLevel           ; }
-
+  Int_t                       GetIndexFromLabel(Int_t lab)  const;
+  Int_t                       GetNEntries()                 const { return fClArray->GetEntriesFast() ; }
   virtual void                GetMomentum(TLorentzVector &mom, Int_t i) const = 0;
+  void                        ResetCurrentID(Int_t i=0)           { fCurrentID = i                    ; }
   virtual void                SetArray(AliVEvent *event);
-  Int_t                       GetIndexFromLabel(Int_t lab)  const;
+  void                        SetArrayName(const char *n)         { fClArrayName = n                  ; }
+  void                        SetIsParticleLevel(Bool_t b)        { fIsParticleLevel = b              ; }
+  void                        SortArray()                         { fClArray->Sort()                  ; }
 
  protected:
-
   TString                     fClArrayName;             // name of branch
   TString                     fClassName;               // name of the class in the TClonesArray
   Bool_t                      fIsParticleLevel;         // whether or not it is a particle level object collection
-
   TClonesArray               *fClArray;                 //!TClonesArray
   Int_t                       fCurrentID;               //!current ID for automatic loops
   AliNamedArrayI             *fLabelMap;                //!Label-Index map
@@ -48,8 +45,5 @@ class AliEmcalContainer : public TNamed {
   AliEmcalContainer& operator=(const AliEmcalContainer& other); // assignment
 
   ClassDef(AliEmcalContainer,3);
-
 };
-
 #endif
-
similarity index 78%
rename from PWG/EMCAL/AliEmcalEsdTpcTrackTask.cxx
rename to PWG/EMCAL/AliEmcalEsdTrackFilterTask.cxx
index 1c8c1a9824786c7b053e076c7096a6c4a118c5d2..7e4854670a33fa7c962b9b73b926a6884e99632f 100644 (file)
@@ -1,27 +1,32 @@
 // $Id$
 //
-// Task to constrain TPC tracks to SPD vertex.
+// Task to filter Esd tracks and propagate to Emcal surface.
 //
 // Author: C.Loizides
 
 #include <TClonesArray.h>
 #include <TGeoGlobalMagField.h>
-#include "AliAnalysisManager.h"
-#include "AliESDEvent.h"
-#include "AliESDtrackCuts.h"
-#include "AliEmcalEsdTpcTrackTask.h"
-#include "AliMagF.h"
+#include <AliAnalysisManager.h>
+#include <AliESDEvent.h>
+#include <AliESDtrackCuts.h>
+#include <AliMagF.h>
+#include <AliTrackerBase.h>
+#include <AliEMCALRecoUtils.h>
 
-ClassImp(AliEmcalEsdTpcTrackTask)
+#include "AliEmcalEsdTrackFilterTask.h"
+
+ClassImp(AliEmcalEsdTrackFilterTask)
 
 //________________________________________________________________________
-AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask() : 
-  AliAnalysisTaskSE("TpcSpdVertexConstrainedTracks"),
+AliEmcalEsdTrackFilterTask::AliEmcalEsdTrackFilterTask() : 
+  AliAnalysisTaskSE("AliEmcalEsdTrackFilterTask"),
   fEsdTrackCuts(0),
   fDoSpdVtxCon(0),
   fHybridTrackCuts(0),
   fTracksName(),
   fIncludeNoITS(kTRUE),
+  fDoPropagation(kFALSE),
+  fDist(440),
   fEsdEv(0),
   fTracks(0)
 {
@@ -29,13 +34,15 @@ AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask() :
 }
 
 //________________________________________________________________________
-AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask(const char *name) : 
+AliEmcalEsdTrackFilterTask::AliEmcalEsdTrackFilterTask(const char *name) : 
   AliAnalysisTaskSE(name),
   fEsdTrackCuts(0),
   fDoSpdVtxCon(0),
   fHybridTrackCuts(0),
-  fTracksName("TpcSpdVertexConstrainedTracks"),
+  fTracksName("EsdTracksOut"),
   fIncludeNoITS(kTRUE),
+  fDoPropagation(kFALSE),
+  fDist(440),
   fEsdEv(0),
   fTracks(0)
 {
@@ -50,7 +57,7 @@ AliEmcalEsdTpcTrackTask::AliEmcalEsdTpcTrackTask(const char *name) :
 }
 
 //________________________________________________________________________
-AliEmcalEsdTpcTrackTask::~AliEmcalEsdTpcTrackTask()
+AliEmcalEsdTrackFilterTask::~AliEmcalEsdTrackFilterTask()
 {
   //Destructor
 
@@ -58,7 +65,7 @@ AliEmcalEsdTpcTrackTask::~AliEmcalEsdTpcTrackTask()
 }
 
 //________________________________________________________________________
-void AliEmcalEsdTpcTrackTask::UserCreateOutputObjects()
+void AliEmcalEsdTrackFilterTask::UserCreateOutputObjects()
 {
   // Create histograms.
 
@@ -73,7 +80,7 @@ void AliEmcalEsdTpcTrackTask::UserCreateOutputObjects()
 }
 
 //________________________________________________________________________
-void AliEmcalEsdTpcTrackTask::UserExec(Option_t *) 
+void AliEmcalEsdTrackFilterTask::UserExec(Option_t *) 
 {
   // Main loop, called for each event.
 
@@ -158,29 +165,40 @@ void AliEmcalEsdTpcTrackTask::UserExec(Option_t *)
     Int_t ntr = fEsdEv->GetNumberOfTracks();
     for (Int_t i=0, ntrnew=0; i<ntr; ++i) {
       AliESDtrack *etrack = fEsdEv->GetTrack(i);
-      if (!etrack)
-        continue;
+      if (!etrack) 
+       continue;
+
       if (fEsdTrackCuts->AcceptTrack(etrack)) {
+
         new ((*fTracks)[ntrnew]) AliESDtrack(*etrack);
         AliESDtrack *newTrack = static_cast<AliESDtrack*>(fTracks->At(ntrnew));
-        newTrack->SetTRDNchamberdEdx(0);
+       if (fDoPropagation) 
+         AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(newTrack,fDist);
+        newTrack->SetBit(BIT(27),0);
+        newTrack->SetBit(BIT(28),0);
         ++ntrnew;
       } else if (fHybridTrackCuts->AcceptTrack(etrack)) {
+
        UInt_t status = etrack->GetStatus();
         if (etrack->GetConstrainedParam() && ((status&AliESDtrack::kITSrefit)!=0 || fIncludeNoITS)) {
           new ((*fTracks)[ntrnew]) AliESDtrack(*etrack);
           AliESDtrack *newTrack = static_cast<AliESDtrack*>(fTracks->At(ntrnew));
-          ++ntrnew;
           const AliExternalTrackParam* constrainParam = etrack->GetConstrainedParam();
           newTrack->Set(constrainParam->GetX(),
                         constrainParam->GetAlpha(),
                         constrainParam->GetParameter(),
                         constrainParam->GetCovariance());
-          if ((status&AliESDtrack::kITSrefit)==0)
-            newTrack->SetTRDNchamberdEdx(2);
-          else
-            newTrack->SetTRDNchamberdEdx(1);
-        }
+         if ((status&AliESDtrack::kITSrefit)==0) {
+            newTrack->SetBit(BIT(27),1);
+            newTrack->SetBit(BIT(28),0);
+          } else {
+            newTrack->SetBit(BIT(27),1);
+            newTrack->SetBit(BIT(28),1);
+          }
+         if (fDoPropagation)   
+           AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(newTrack,fDist);
+          ++ntrnew;
+       }
       }
     }
   }
similarity index 54%
rename from PWG/EMCAL/AliEmcalEsdTpcTrackTask.h
rename to PWG/EMCAL/AliEmcalEsdTrackFilterTask.h
index 184e60e5d8331d89ba110b0314da50a90a884c6c..1fcf90db353bf24b8b74474b685f027d17d8e61f 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef ALIEMCALESDTPCTRACKTASK_H
-#define ALIEMCALESDTPCTRACKTASK_H
+#ifndef ALIEMCALESDTRACKFILTERTASK_H
+#define ALIEMCALESDTRACKFILTERTASK_H
 
 // $Id$
 
@@ -7,23 +7,27 @@ class TClonesArray;
 class AliESDEvent;
 class AliESDtrack;
 class AliESDtrackCuts;
+class AliEMCALRecoUtils;
 
 #include "AliAnalysisTaskSE.h"
+#include "AliESDtrackCuts.h"
 
-class AliEmcalEsdTpcTrackTask : public AliAnalysisTaskSE {
+class AliEmcalEsdTrackFilterTask : public AliAnalysisTaskSE {
  public:
-  AliEmcalEsdTpcTrackTask();
-  AliEmcalEsdTpcTrackTask(const char *name);
-  virtual ~AliEmcalEsdTpcTrackTask();
+  AliEmcalEsdTrackFilterTask();
+  AliEmcalEsdTrackFilterTask(const char *name);
+  virtual ~AliEmcalEsdTrackFilterTask();
 
   void UserCreateOutputObjects();
   void UserExec(Option_t *option);
    
+  void SetDist(Double_t d)                       { fDist             = d;    }
+  void SetDoPropagation(Bool_t b)                { fDoPropagation    = b;    }
   void SetDoSpdVtxConstrain(Bool_t b)            { fDoSpdVtxCon      = b;    }
   void SetHybridTrackCuts(AliESDtrackCuts *cuts) { fHybridTrackCuts  = cuts; }
+  void SetIncludeNoITS(Bool_t f)                 { fIncludeNoITS     = f;    }
   void SetTrackCuts(AliESDtrackCuts *cuts)       { fEsdTrackCuts     = cuts; }
   void SetTracksName(const char *name)           { fTracksName       = name; }
-  void SetIncludeNoITS(Bool_t f)                 { fIncludeNoITS     = f;    }
 
  protected:
   AliESDtrackCuts   *fEsdTrackCuts;      // esd track cuts
@@ -31,14 +35,16 @@ class AliEmcalEsdTpcTrackTask : public AliAnalysisTaskSE {
   AliESDtrackCuts   *fHybridTrackCuts;   // hybrid track cuts
   TString            fTracksName;        // name of tracks 
   Bool_t             fIncludeNoITS;      // includes tracks with failed ITS refit
+  Bool_t             fDoPropagation;     // propagate all hybrid tracks to EMCal surface
+  Double_t           fDist;              // distance to surface (440cm default)
   AliESDEvent       *fEsdEv;             //!esd event
   TClonesArray      *fTracks;            //!track array
 
  private:
-  AliEmcalEsdTpcTrackTask(const AliEmcalEsdTpcTrackTask&);            // not implemented
-  AliEmcalEsdTpcTrackTask &operator=(const AliEmcalEsdTpcTrackTask&); // not implemented
+  AliEmcalEsdTrackFilterTask(const AliEmcalEsdTrackFilterTask&);            // not implemented
+  AliEmcalEsdTrackFilterTask &operator=(const AliEmcalEsdTrackFilterTask&); // not implemented
 
-  ClassDef(AliEmcalEsdTpcTrackTask, 2); // Class to constrain TPC tracks to SPD vertex
+  ClassDef(AliEmcalEsdTrackFilterTask, 1); // Class to constrain TPC tracks to SPD vertex
 };
 
 #endif
index 66b0d3d626f13b4d2b665a00ee34482ca58d25b2..2031ee3a27023ba2a1f83437a6974c0777633130 100644 (file)
@@ -36,9 +36,9 @@ class AliEmcalParticle: public AliVParticle {
   Double_t          Eta()       const { return fEta; }
   Double_t          Y()         const { if (fTrack) return fTrack->Y(); return fEta; }
   Short_t           Charge()    const { if (fTrack) return fTrack->Charge(); else return 0; }
-  Int_t   GetLabel()    const { if (fTrack) return fTrack->GetLabel(); return fCluster->GetLabel(); }
-  Int_t   PdgCode()     const { return 0; }
-  const Double_t *PID() const { return 0; }
+  Int_t             GetLabel()  const { if (fTrack) return fTrack->GetLabel(); return fCluster->GetLabel(); }
+  Int_t             PdgCode()   const { return 0; }
+  const Double_t   *PID()       const { return 0; }
 
   AliVCluster*      GetCluster()           const { return fCluster                                                  ; }
   Int_t             GetMatchedObjId(UShort_t i = 0)         const { return fNMatched > i ? fMatchedIds[i]  : -1     ; }
@@ -49,7 +49,7 @@ class AliEmcalParticle: public AliVParticle {
   Double_t          GetTrackEtaOnEMCal()   const { if (fTrack) return fTrack->GetTrackEtaOnEMCal(); else return -999; }
   Int_t             IdInCollection()       const { return fId                                                       ; }
   Bool_t            IsCluster()            const { return (Bool_t) fCluster != 0                                    ; }
-  Bool_t            IsEMCAL()              const { if (fCluster) return kTRUE
+  Bool_t            IsEMCAL()              const { if (fCluster) return fCluster->IsEMCAL()
                                                    if (fTrack)   return fTrack->IsEMCAL(); 
                                                    return kFALSE; }
   Bool_t            IsTrack()              const { return (Bool_t) fTrack   != 0                                    ; }
index f6742ed8f8a25815b4a2f9768e4c01252d19473e..8b74f903e0f8c79f339b8bf5640128c831e59684 100644 (file)
@@ -92,11 +92,8 @@ Bool_t AliEmcalParticleMaker::Run()
   if (fTracks && fTracksOut) {
     // clear container (normally a null operation as the event should clean it already)
     fTracksOut->Delete();
-
-    // loop over tracks
     const Int_t Ntracks = fTracks->GetEntries();
     for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
-      
       AliVTrack *track = static_cast<AliVTrack*>(fTracks->At(iTracks));
       new ((*fTracksOut)[iTracks]) AliEmcalParticle(track, iTracks);
     }
@@ -105,13 +102,13 @@ Bool_t AliEmcalParticleMaker::Run()
   if (fCaloClusters && fCaloClustersOut) {
     // clear container (normally a null operation as the event should clean it already)
     fCaloClustersOut->Delete();
-
-    // loop over clusters
     const Int_t Nclusters = fCaloClusters->GetEntries();
     for (Int_t iClusters = 0, iN=0; iClusters < Nclusters; ++iClusters) {
       AliVCluster *cluster = static_cast<AliVCluster*>(fCaloClusters->At(iClusters));
-      if (!cluster->IsEMCAL())
-       continue;
+      /* commented because for simplicity prefer to keep indices aligned (CL)
+        if (!cluster->IsEMCAL())
+        continue;
+      */
       new ((*fCaloClustersOut)[iN++]) AliEmcalParticle(cluster, iClusters, fVertex[0], fVertex[1], fVertex[2]);
     }
   }
index 3ada68855db54e1474ed1042e92076453a78964f..bed6cda38a2682a75dcf0d30dbadfd144a8c5388 100644 (file)
@@ -116,9 +116,6 @@ void AliEmcalPicoTrackMaker::UserExec(Option_t *)
     InputEvent()->AddObject(fTracksOut);
   }
 
-  // clear container (normally a null operation as the event should clean it already)
-  fTracksOut->Clear();
-
   // test if we are in ESD or AOD mode
   Bool_t esdMode = kTRUE;
   if (dynamic_cast<AliAODEvent*>(InputEvent())!=0)
@@ -146,10 +143,19 @@ void AliEmcalPicoTrackMaker::UserExec(Option_t *)
       AliESDtrack *esdtrack = static_cast<AliESDtrack*>(track);
       if (fESDtrackCuts && !fESDtrackCuts->AcceptTrack(esdtrack))
        continue;
-      type = esdtrack->GetTRDNchamberdEdx();
+      type = 0;
+      if (esdtrack->TestBit(BIT(27))) {
+        if (esdtrack->TestBit(BIT(28)))
+          type = 2;
+        else 
+          type =1;
+      }
       if (!fIncludeNoITS && (type==2))
        continue;
-      isEmc = track->IsEMCAL();
+      if (TMath::Abs(esdtrack->GetTrackEtaOnEMCal()) < 0.75 && 
+         esdtrack->GetTrackPhiOnEMCal() > 70 * TMath::DegToRad() &&
+         esdtrack->GetTrackPhiOnEMCal() < 190 * TMath::DegToRad())
+       isEmc = kTRUE;
     } else {
       AliAODTrack *aodtrack = static_cast<AliAODTrack*>(track);
       if (fAODfilterBits[0] < 0) {
index 3dab8203f93c5f6a187032cc02f94b4ef82dd759..5402f2745e7dccff1b93e3f9e7f857b9a4274ea4 100644 (file)
@@ -20,17 +20,17 @@ class AliEmcalPicoTrackMaker : public AliAnalysisTaskSE {
   void UserExec(Option_t *option);
 
   void SetAODfilterBits(Int_t b0 = 0, Int_t b1 = 0)      { fAODfilterBits[0] = b0  ; fAODfilterBits[1] = b1  ; }
+  void SetCutMaxFractionSharedTPCClusters(Double_t c = 0.4)        { fCutMaxFractionSharedTPCClusters  = c ; }
   void SetESDtrackCuts(AliESDtrackCuts *cuts)            { fESDtrackCuts     = cuts; }
-  void SetTracksInName(const char *name)                 { fTracksInName     = name; }
-  void SetTracksOutName(const char *name)                { fTracksOutName    = name; }
-  void SetTrackPtLimits(Double_t min, Double_t max)      { fMaxTrackPt       = max ; fMinTrackPt       = min ; }
+  void SetIncludeNoITS(Bool_t f)                         { fIncludeNoITS     = f   ; }
+  void SetMC(Bool_t a)                                   { fIsMC             = a   ; }
+  void SetTrackEfficiency(Double_t eff = 0.95)           { fTrackEfficiency  = eff ; }
   void SetTrackEtaLimits(Double_t min, Double_t max)     { fMaxTrackEta      = max ; fMinTrackEta      = min ; }
   void SetTrackPhiLimits(Double_t min, Double_t max)     { fMaxTrackPhi      = max ; fMinTrackPhi      = min ; }
-  void SetTrackEfficiency(Double_t eff = 0.95)           { fTrackEfficiency  = eff ; }
-  void SetIncludeNoITS(Bool_t f)                         { fIncludeNoITS     = f   ; }
+  void SetTrackPtLimits(Double_t min, Double_t max)      { fMaxTrackPt       = max ; fMinTrackPt       = min ; }
+  void SetTracksInName(const char *name)                 { fTracksInName     = name; }
+  void SetTracksOutName(const char *name)                { fTracksOutName    = name; }
   void SetUseNegativeLabels(Bool_t f)                    { fUseNegativeLabels= f   ; }
-  void SetMC(Bool_t a)                                   { fIsMC             = a   ; }
-  void SetCutMaxFractionSharedTPCClusters(Double_t c = 0.4)        { fCutMaxFractionSharedTPCClusters  = c ; }
 
  protected:
   Int_t              fAODfilterBits[2];     // AOD track filter bit map
index b8a4c3f9df3c1b3592791bcf2169e7853dc9e837..5feb5eb1211fbc6e168175501762c683411cc55d 100644 (file)
@@ -13,6 +13,7 @@
 #include "AliCDBManager.h"
 #include "AliEMCALGeometry.h"
 #include "AliESDEvent.h"
+#include "AliGRPManager.h"
 #include "AliGeomManager.h"
 #include "AliMagF.h"
 #include "AliOADBContainer.h"
@@ -24,7 +25,8 @@ AliEmcalSetupTask::AliEmcalSetupTask() :
   AliAnalysisTaskSE(),
   fOcdbPath(),
   fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
-  fGeoPath("."),
+  fGeoPath("$ALICE_ROOT/OADB/EMCAL"),
+  fObjs("GRP ITS TPC TRD EMCAL"),
   fIsInit(kFALSE)
 {
   // Constructor.
@@ -36,6 +38,7 @@ AliEmcalSetupTask::AliEmcalSetupTask(const char *name) :
   fOcdbPath(),
   fOadbPath("$ALICE_ROOT/OADB/EMCAL"),
   fGeoPath("$ALICE_ROOT/OADB/EMCAL"),
+  fObjs("GRP ITS TPC TRD EMCAL"),
   fIsInit(kFALSE)
 {
   // Constructor.
@@ -84,11 +87,29 @@ void AliEmcalSetupTask::UserExec(Option_t *)
   }
 
   AliCDBManager *man = 0;
-  if (fOcdbPath.Length()>0) {
-    AliInfo(Form("Setting up OCDB"));
-    man = AliCDBManager::Instance();
-    man->SetDefaultStorage(fOcdbPath);
-    man->SetRun(runno);
+  man = AliCDBManager::Instance();
+  if (!man->IsDefaultStorageSet()) {
+    if (fOcdbPath.Length()>0) {
+      AliInfo(Form("Setting up OCDB"));
+      man->SetDefaultStorage(fOcdbPath);
+      man->SetRun(runno);
+    } else {
+      man = 0;
+    }
+  } else {
+    if (man->GetRun()!=runno)
+      man->SetRun(runno);
+  }
+  
+  if (man) {
+    AliInfo(Form("Loading grp data from OCDB"));
+    AliGRPManager GRPManager;
+    GRPManager.ReadGRPEntry();
+    GRPManager.SetMagField();
+    AliInfo(Form("Loading geometry from OCDB"));
+    AliGeomManager::LoadGeometry();
+    if (!fObjs.IsNull())
+      AliGeomManager::ApplyAlignObjsFromCDB(fObjs);
   }
 
   TGeoManager *geo = AliGeomManager::GetGeometry();
@@ -97,31 +118,16 @@ void AliEmcalSetupTask::UserExec(Option_t *)
     if (gSystem->AccessPathName(fname)==0) {
       AliInfo(Form("Loading geometry from %s", fname.Data()));
       AliGeomManager::LoadGeometry(fname);
-    } else if (man) {
-      AliInfo(Form("Loading geometry from OCDB"));
-      AliGeomManager::LoadGeometry();
+      geo = AliGeomManager::GetGeometry();
     }
   }
   if (geo) {
-    AliGeomManager::ApplyAlignObjsFromCDB("EMCAL");
     AliInfo(Form("Locking geometry"));
     geo->LockGeometry();
   }
 
   if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
-    AliESDEvent *esdEv = dynamic_cast<AliESDEvent*>(InputEvent());
-    if (esdEv) {
-      AliInfo("Constructing field map from ESD run info");
-      esdEv->InitMagneticField();
-    } else {
-      AliAODEvent *aodEv = dynamic_cast<AliAODEvent*>(InputEvent());
-      if (aodEv) {
-        Double_t curSol = 30000*aodEv->GetMagneticField()/5.00668;
-        Double_t curDip = 6000 *aodEv->GetMuonMagFieldScale();
-        AliMagF *field  = AliMagF::CreateFieldMap(curSol,curDip);
-        TGeoGlobalMagField::Instance()->SetField(field);
-      }
-    }
+    InputEvent()->InitMagneticField();
   }
 
   if (fOadbPath.Length()>0) {
index b07366730f0516f26d2e500395b24705ac5baff6..07c435479f53db199392125b4d42e5e8dbe75254 100644 (file)
@@ -16,22 +16,24 @@ class AliEmcalSetupTask : public AliAnalysisTaskSE {
   AliEmcalSetupTask(const char *name);
   virtual ~AliEmcalSetupTask();
 
-  void UserExec(Option_t *option);
   void SetGeoPath(const char *n)  { fGeoPath  = n; }
   void SetOadbPath(const char *n) { fOadbPath = n; }
   void SetOcdbPath(const char *n) { fOcdbPath = n; }
+  void SetObjs(const char *n)     { fObjs     = n; }
+  void UserExec(Option_t *option);
 
  protected:
   TString            fOcdbPath;        // path to ocdb (def=none)
   TString            fOadbPath;        // path to oadb
   TString            fGeoPath;         // path to geometry
+  TString            fObjs;            // string of objects for alignment to apply
   Bool_t             fIsInit;          //!=true then already initialized 
 
  private:
   AliEmcalSetupTask(const AliEmcalSetupTask&);            // not implemented
   AliEmcalSetupTask &operator=(const AliEmcalSetupTask&); // not implemented
 
-  ClassDef(AliEmcalSetupTask, 2); // Class to setup geometry for EMCal
+  ClassDef(AliEmcalSetupTask, 3); // Class to setup geometry for EMCal
 };
 
 #endif
index 408368b30d4094d08a92716aebf7502408db63f7..4d47ebc4df046df627f39cc86ae408b5c3aa0a8d 100644 (file)
@@ -17,10 +17,12 @@ AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask() :
   AliAnalysisTaskSE("AliEmcalTrackPropagatorTask"),
   fRecoUtils(0),
   fTracksName(),
-  fDist(430),
+  fDist(440),
   fMinPtCut(0.35),
   fEsdEv(0),
-  fTracks(0)
+  fTracks(0),
+  fUseGlobalTrackParam(kFALSE),
+  fUseOuterTrackParam(kFALSE)
 {
   // Constructor.
 }
@@ -30,10 +32,12 @@ AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask(const char *name) :
   AliAnalysisTaskSE("AliEmcalTrackPropagatorTask"),
   fRecoUtils(0),
   fTracksName("TpcSpdVertexConstrainedTracks"),
-  fDist(430),
+  fDist(440),
   fMinPtCut(0.35),
   fEsdEv(0),
-  fTracks(0)
+  fTracks(0),
+  fUseGlobalTrackParam(kFALSE),
+  fUseOuterTrackParam(kFALSE)
 {
   // Constructor.
 
@@ -60,7 +64,7 @@ void AliEmcalTrackPropagatorTask::UserCreateOutputObjects()
 
   if (!fRecoUtils) {
     fRecoUtils = new AliEMCALRecoUtils;
-    fRecoUtils->SetStep(25);
+    fRecoUtils->SetStep(20);
     AliInfo("No reco utils given, creating default utils");
   }
 }
@@ -101,18 +105,27 @@ void AliEmcalTrackPropagatorTask::UserExec(Option_t *)
     if(eTrack->Pt()<fMinPtCut) 
       continue;
     Double_t phi = eTrack->Phi()*TMath::RadToDeg();
-    if (TMath::Abs(eTrack->Eta())>0.8 || phi <= 20 || phi >= 240) 
+    if (TMath::Abs(eTrack->Eta())>0.9 || phi <= 10 || phi >= 250) 
       continue;
-    AliExternalTrackParam *trackParam =  const_cast<AliExternalTrackParam*>(eTrack->GetInnerParam());
-    if(!trackParam) 
+    AliExternalTrackParam *trackParam;
+    if(fUseGlobalTrackParam) 
+      trackParam = dynamic_cast<AliExternalTrackParam*>(eTrack);
+    else if(fUseOuterTrackParam) 
+      trackParam =  const_cast<AliExternalTrackParam*>(eTrack->GetOuterParam());
+    else
+      trackParam =  const_cast<AliExternalTrackParam*>(eTrack->GetInnerParam());
+    if(!trackParam) {
+      Printf("trackParam not available");
       continue;
+    }
 
     // Extrapolate the track to EMCal surface
     AliExternalTrackParam emcalParam(*trackParam);
+
     Float_t etaout=-999, phiout=-999, ptout=-999;
     Bool_t ret = fRecoUtils->ExtrapolateTrackToEMCalSurface(&emcalParam, 
                                                             fDist, 
-                                                            fRecoUtils->GetMass(), 
+                                                            eTrack->GetMass(), 
                                                             fRecoUtils->GetStepSurface(), 
                                                             etaout, 
                                                             phiout,
index e4e606ce492b8735c5b3e3b557ad5b8aab070f85..85b4b53967f3fe781368a5649239d6a6f5811d4f 100644 (file)
@@ -23,14 +23,18 @@ class AliEmcalTrackPropagatorTask : public AliAnalysisTaskSE {
   void SetMinPt(Double_t pt)               { fMinPtCut = pt;     }
   void SetRecoUtils(AliEMCALRecoUtils *ru) { fRecoUtils  = ru;   }
   void SetTracksName(const char *name)     { fTracksName = name; }
+  void SetUseGlobalTrackParam(Bool_t b)    { fUseGlobalTrackParam = b; }
+  void SetUseOuterTrackParam(Bool_t b)    { fUseOuterTrackParam = b; }
 
  protected:
   AliEMCALRecoUtils *fRecoUtils;         // esd reco utils
   TString            fTracksName;        // name of tracks 
-  Double_t           fDist;              // distance to surface (430cm default)
-  Double_t           fMinPtCut;          // minimum track pt cut (500 MeV/c default)
+  Double_t           fDist;              // distance to surface (440cm default)
+  Double_t           fMinPtCut;          // minimum track pt cut (350 MeV/c default)
   AliESDEvent       *fEsdEv;             //!esd event
   TClonesArray      *fTracks;            //!track array
+  Bool_t             fUseGlobalTrackParam; // use global track param in propagation
+  Bool_t             fUseOuterTrackParam; // use global track param in propagation
 
  private:
   AliEmcalTrackPropagatorTask(const AliEmcalTrackPropagatorTask&);            // not implemented
diff --git a/PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.cxx b/PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.cxx
new file mode 100644 (file)
index 0000000..fbe897e
--- /dev/null
@@ -0,0 +1,112 @@
+// $Id$
+//
+// Task to propagate AOD tracks to EMCAL surface.
+//
+// Author: C.Loizides
+
+#include <TClonesArray.h>
+#include "AliAnalysisManager.h"
+#include "AliEMCALRecoUtils.h"
+#include "AliAODEvent.h"
+#include "AliAODTrack.h"
+#include "AliExternalTrackParam.h"
+#include <AliMagF.h>
+#include <AliTrackerBase.h>
+#include <AliEMCALRecoUtils.h>
+
+#include "AliEmcalTrackPropagatorTaskAOD.h"
+
+ClassImp(AliEmcalTrackPropagatorTaskAOD)
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTaskAOD::AliEmcalTrackPropagatorTaskAOD() : 
+  AliAnalysisTaskSE("AliEmcalTrackPropagatorTaskAOD"),
+  fRecoUtils(0),
+  fTracksName(),
+  fDist(430),
+  fMinPtCut(0.35),
+  fAodEv(0),
+  fTracks(0)
+{
+  // Constructor.
+}
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTaskAOD::AliEmcalTrackPropagatorTaskAOD(const char *name) : 
+  AliAnalysisTaskSE("AliEmcalTrackPropagatorTaskAOD"),
+  fRecoUtils(0),
+  fTracksName("TpcSpdVertexConstrainedTracks"),
+  fDist(430),
+  fMinPtCut(0.35),
+  fAodEv(0),
+  fTracks(0)
+{
+  // Constructor.
+
+  if (!name)
+    return;
+
+  SetName(name);
+
+  //  fBranchNames = "ESD:AliESDHeader.,Tracks";
+}
+
+//________________________________________________________________________
+AliEmcalTrackPropagatorTaskAOD::~AliEmcalTrackPropagatorTaskAOD()
+{
+  // Destructor.
+
+  delete fRecoUtils;
+}
+
+//________________________________________________________________________
+void AliEmcalTrackPropagatorTaskAOD::UserCreateOutputObjects()
+{
+  // Create histograms.
+
+  if (!fRecoUtils) {
+    fRecoUtils = new AliEMCALRecoUtils;
+    fRecoUtils->SetStep(20);
+    AliInfo("No reco utils given, creating default utils");
+  }
+}
+
+//________________________________________________________________________
+void AliEmcalTrackPropagatorTaskAOD::UserExec(Option_t *) 
+{
+  // Main loop, called for each event.
+
+  fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
+  if (!fAodEv) {
+    AliError("Task works only on AOD events, returning");
+    return;
+  }
+
+  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+  if (!am) {
+    AliError("Manager zero, returning");
+    return;
+  }
+
+  // get tracks from event if not yet there
+  if (fTracksName == "tracks")
+    am->LoadBranch("tracks");
+
+  fTracks = dynamic_cast<TClonesArray*>((InputEvent()->FindListObject(fTracksName)));
+  if (!fTracks) {
+    AliError(Form("Could not get tracks %s, returning", fTracksName.Data()));
+    return;
+  }
+
+  // Loop over all tracks
+  const Int_t ntr = fTracks->GetEntries();
+  for (Int_t i=0; i<ntr; ++i) {
+    AliAODTrack *aodTrack = static_cast<AliAODTrack*>(fTracks->At(i));
+    if (!aodTrack)
+      continue;
+    if(aodTrack->Pt()<fMinPtCut || aodTrack->GetTrackPtOnEMCal()>0) 
+      continue;
+
+    AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(aodTrack,fDist);
+  }
+}
diff --git a/PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.h b/PWG/EMCAL/AliEmcalTrackPropagatorTaskAOD.h
new file mode 100644 (file)
index 0000000..b79ef64
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef ALIEMCALTRACKPROPAGATORTASKAOD_H
+#define ALIEMCALTRACKPROPAGATORTASKAOD_H
+
+// $Id$
+
+class TClonesArray;
+class AliEMCALRecoUtils;
+class AliAODEvent;
+class AliAODtrack;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliEmcalTrackPropagatorTaskAOD : public AliAnalysisTaskSE {
+ public:
+  AliEmcalTrackPropagatorTaskAOD();
+  AliEmcalTrackPropagatorTaskAOD(const char *name);
+  virtual ~AliEmcalTrackPropagatorTaskAOD();
+
+  void UserCreateOutputObjects();
+  void UserExec(Option_t *option);
+   
+  void SetDist(Double_t d)                 { fDist       = d;    }
+  void SetMinPt(Double_t pt)               { fMinPtCut = pt;     }
+  void SetRecoUtils(AliEMCALRecoUtils *ru) { fRecoUtils  = ru;   }
+  void SetTracksName(const char *name)     { fTracksName = name; }
+
+ protected:
+  AliEMCALRecoUtils *fRecoUtils;         // esd reco utils
+  TString            fTracksName;        // name of tracks 
+  Double_t           fDist;              // distance to surface (430cm default)
+  Double_t           fMinPtCut;          // minimum track pt cut (500 MeV/c default)
+  AliAODEvent       *fAodEv;             //!aod event
+  TClonesArray      *fTracks;            //!track array
+
+ private:
+  AliEmcalTrackPropagatorTaskAOD(const AliEmcalTrackPropagatorTaskAOD&);            // not implemented
+  AliEmcalTrackPropagatorTaskAOD &operator=(const AliEmcalTrackPropagatorTaskAOD&); // not implemented
+
+  ClassDef(AliEmcalTrackPropagatorTaskAOD, 1); // Class to propagate and store track parameters at EMCAL surface
+};
+
+#endif
index 4c92fac2be5c550e8ca73876e7650557cf83da82..a12ba3ded615c6ae55faf2b1186ce0863173badf 100644 (file)
@@ -146,17 +146,7 @@ Bool_t AliEmcalTriggerMaker::Run()
     AliError(Form("V0 container %s not available.", fV0InName.Data()));
     return kTRUE;
   }
-  
-//   // do not process, if sooner than 11h period
-//   if( InputEvent()->GetRunNumber() < 167693 )
-//     return kTRUE;
-// 
-//   // do not process any MC, since no MC was generated with correct
-//   // EMCal trigger L1 jet trigger simulation, yet
-//   // productions will be enabled, once some correct once are produced
-//   if( MCEvent() != 0 )
-//     return kTRUE;
-  
+
   // must reset before usage, or the class will fail 
   fCaloTriggers->Reset();
   for (i=0; i<2; i++) {
@@ -166,6 +156,10 @@ Bool_t AliEmcalTriggerMaker::Run()
   // first run over the patch array to compose a map of 2x2 patch energies
   // which is then needed to construct the full patch ADC energy
   // class is not empty
+  Int_t isMC = 0;
+  if (MCEvent()) isMC = 1;
+  Int_t offSet = (1 - isMC) * kTriggerTypeEnd;
+
   if( fCaloTriggers->GetEntries() > 0 ){
                
     // zero the array
@@ -187,10 +181,6 @@ Bool_t AliEmcalTriggerMaker::Run()
       
       fCaloTriggers->GetTriggerBits( tBits );
       
-      Int_t isMC = 0;
-      if (MCEvent()) isMC = 1;
-      
-      Int_t offSet = (1 - isMC) * kTriggerTypeEnd;
       if (tBits) {
         if ((tBits >> (offSet + kL1GammaHigh)) & 1 ) fEGA[0] = 1;
         if ((tBits >> (offSet + kL1GammaLow )) & 1 ) fEGA[1] = 1;
@@ -272,17 +262,16 @@ Bool_t AliEmcalTriggerMaker::Run()
 
     // go throuth the trigger channels, real first, then offline
     while( NextTrigger( isOfflineSimple ) ){
-      
       // check if jet trigger low or high
       if( ! isOfflineSimple )
-      fCaloTriggers->GetTriggerBits( tBits );
+       fCaloTriggers->GetTriggerBits( tBits );
       else
         fSimpleOfflineTriggers->GetTriggerBits( tBits );
       
       jetTrigger = 0;
-      if(( tBits >> ( kTriggerTypeEnd + kL1JetLow )) & 1 )
+      if(( tBits >> ( offSet + kL1JetLow )) & 1 )
         jetTrigger = 1;
-      if(( tBits >> ( kTriggerTypeEnd + kL1JetHigh )) & 1)
+      if(( tBits >> ( offSet + kL1JetHigh )) & 1)
         jetTrigger = jetTrigger | 2;
       
       if( jetTrigger == 0 )
@@ -291,7 +280,7 @@ Bool_t AliEmcalTriggerMaker::Run()
       // get position in global 2x2 tower coordinates
       // A0 left bottom (0,0)
       if( ! isOfflineSimple )
-      fCaloTriggers->GetPosition( globCol, globRow );
+       fCaloTriggers->GetPosition( globCol, globRow );
       else
         fSimpleOfflineTriggers->GetPosition( globCol, globRow );
 
@@ -390,7 +379,8 @@ Bool_t AliEmcalTriggerMaker::Run()
       trigger->SetADCAmp( adcAmp );
       trigger->SetTriggerBits( tBits );
       trigger->SetEdgeCell( globCol*2, globRow*2 ); // from triggers to cells
-      
+      trigger->SetOffSet(offSet);
+
       // check if more energetic than others for main patch marking
       if( ! isOfflineSimple && eMain < amp ){
         eMain = amp;
@@ -400,16 +390,6 @@ Bool_t AliEmcalTriggerMaker::Run()
         eMainSimple = amp;
         iMainSimple = iTriggers - 1;
       }
-      
-//       cout << " pi:" << trigger->GetPhiMin() << " px:" << trigger->GetPhiMax();
-//       cout << " pg:" << trigger->GetPhiGeo() << " " << (trigger->GetPhiMin()+trigger->GetPhiMax()) / 2.;
-//       cout << " pc:" << trigger->GetPhiCM();
-//       cout << " ei:" << trigger->GetEtaMin() << " ex:" << trigger->GetEtaMax();
-//       cout << " eg:" << trigger->GetEtaGeo() << " " << (trigger->GetEtaMin()+trigger->GetEtaMax()) / 2.;
-//       cout << " ec:" << trigger->GetEtaCM();
-//       cout << " e:" << trigger->GetPatchE();
-//       cout << " jl:" << trigger->IsJetLow() << " jh:" << trigger->IsJetHigh() << endl;
-      
     } // triggers
     
     // mark the most energetic patch as main
@@ -442,6 +422,10 @@ void AliEmcalTriggerMaker::RunSimpleOfflineTrigger()
   Int_t i, j, k, l, tBits, tSum;
   TArrayI tBitsArray, rowArray, colArray;
   
+  Int_t isMC = 0;
+  if (MCEvent()) isMC = 1;
+  Int_t offSet = (1 - isMC) * kTriggerTypeEnd;
+
   // 0 thresholds = no processing
   if( fCaloTriggerSetupOut->GetThresholdJetLowSimple() == 0 &&
     fCaloTriggerSetupOut->GetThresholdJetHighSimple() == 0 )
@@ -461,9 +445,9 @@ void AliEmcalTriggerMaker::RunSimpleOfflineTrigger()
       
       // check thresholds
       if( tSum > fCaloTriggerSetupOut->GetThresholdJetLowSimple() )
-        tBits = tBits | ( 1 << ( kTriggerTypeEnd + kL1JetLow ));
+        tBits = tBits | ( 1 << ( offSet + kL1JetLow ));
       if( tSum > fCaloTriggerSetupOut->GetThresholdJetHighSimple() )
-        tBits = tBits | ( 1 << ( kTriggerTypeEnd + kL1JetHigh ));
+        tBits = tBits | ( 1 << ( offSet + kL1JetHigh ));
       
       // add trigger values
       if( tBits != 0 ){
index 8be5524153aeb0ef91cbc17c5036442b64c24d4e..9f91da1276f01bb8ff7ac05a315c40424949d221 100644 (file)
@@ -17,7 +17,8 @@ AliEmcalTriggerPatchInfo::AliEmcalTriggerPatchInfo() :
   fEdge1(),
   fEdge2(),
   fADCAmp(0),
-  fTriggerBits(0)
+  fTriggerBits(0),
+  fOffSet(kTriggerTypeEnd)
 {
   // Default constructor.
   fEdgeCell[0] = -1;
@@ -33,7 +34,8 @@ AliEmcalTriggerPatchInfo::AliEmcalTriggerPatchInfo(const AliEmcalTriggerPatchInf
   fEdge1(p.fEdge1),
   fEdge2(p.fEdge2),
   fADCAmp(p.fADCAmp),
-  fTriggerBits(p.fTriggerBits)
+  fTriggerBits(p.fTriggerBits),
+  fOffSet(p.fOffSet)
 {
   // Copy constructor.
   fEdgeCell[0] = p.fEdgeCell[0];
index 404bfa30340bc8c208a9b86f24ccc18cf1a249e3..b3839bc2c3934154ff16dda16f0b44aad692e76e 100644 (file)
@@ -37,11 +37,11 @@ class AliEmcalTriggerPatchInfo: public TObject {
   Int_t    GetEdgeCellY() const { return fEdgeCell[1]; }
   void     GetCellIndices( AliEMCALGeometry *geom, TArrayI *cells );
   
-  Bool_t   IsJetLow() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetLow))&(!(fTriggerBits >> 25))&1); }
-  Bool_t   IsJetHigh() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetHigh))&(!(fTriggerBits >> 25))&1); }
+  Bool_t   IsJetLow() const { return (Bool_t)((fTriggerBits >> (fOffSet + kL1JetLow))&(!(fTriggerBits >> 25))&1); }
+  Bool_t   IsJetHigh() const { return (Bool_t)((fTriggerBits >> (fOffSet + kL1JetHigh))&(!(fTriggerBits >> 25))&1); }
   Bool_t   IsMainTrigger() const { return (Bool_t)((fTriggerBits >> 24)&(!(fTriggerBits >> 25))&1); }
-  Bool_t   IsJetLowSimple() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetLow))&(fTriggerBits >> 25)&1); }
-  Bool_t   IsJetHighSimple() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetHigh))&(fTriggerBits >> 25)&1); }
+  Bool_t   IsJetLowSimple() const { return (Bool_t)((fTriggerBits >> (fOffSet + kL1JetLow))&(fTriggerBits >> 25)&1); }
+  Bool_t   IsJetHighSimple() const { return (Bool_t)((fTriggerBits >> (fOffSet + kL1JetHigh))&(fTriggerBits >> 25)&1); }
   Bool_t   IsMainTriggerSimple() const { return (Bool_t)((fTriggerBits >> 24)&(fTriggerBits >> 25)&1); }
   Bool_t   IsOfflineSimple() const { return (Bool_t)((fTriggerBits >> 25)&1); }
   
@@ -60,6 +60,8 @@ class AliEmcalTriggerPatchInfo: public TObject {
 
   void SetTriggerBits( Int_t i ) { fTriggerBits = i; }
 
+  void SetOffSet(Int_t i)        { fOffSet      = i; }
+
 
  protected:
   TLorentzVector   &GetLorentzVector(const Double_t *vertex = 0)  const;
@@ -71,7 +73,8 @@ class AliEmcalTriggerPatchInfo: public TObject {
   Int_t             fADCAmp;                        // online ADC amplitude
   Int_t             fTriggerBits;                   //trigger bit mask
   Int_t             fEdgeCell[2];                   // cell "bottom lower" edge (min phi, max eta)
+  Int_t             fOffSet;                        // offset of bit (different in data and MC)
 
-  ClassDef(AliEmcalTriggerPatchInfo, 3) // Emcal particle class
+  ClassDef(AliEmcalTriggerPatchInfo, 4) // Emcal particle class
 };
 #endif
index 88d17b82c8e522d925b135dd92a93fa0638a8195..af3c98020974b5c0a4e56b274b644a5e05188e39 100644 (file)
@@ -77,8 +77,8 @@ AliVParticle* AliParticleContainer::GetLeadingParticle(const char* opt)
 }
 
 //________________________________________________________________________
-AliVParticle* AliParticleContainer::GetParticle(Int_t i) const {
-
+AliVParticle* AliParticleContainer::GetParticle(Int_t i) const 
+{
   //Get i^th jet in array
 
   if(i<0 || i>fClArray->GetEntriesFast()) return 0;
@@ -103,8 +103,8 @@ AliVParticle* AliParticleContainer::GetAcceptParticle(Int_t i) const {
 }
 
 //________________________________________________________________________
-AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const {
-
+AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const 
+{
   //Get particle with label lab in array
   
   Int_t i = GetIndexFromLabel(lab);
@@ -112,8 +112,8 @@ AliVParticle* AliParticleContainer::GetParticleWithLabel(Int_t lab) const {
 }
 
 //________________________________________________________________________
-AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) const {
-
+AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) const 
+{
   //Get particle with label lab in array
   
   Int_t i = GetIndexFromLabel(lab);
@@ -121,8 +121,8 @@ AliVParticle* AliParticleContainer::GetAcceptParticleWithLabel(Int_t lab) const
 }
 
 //________________________________________________________________________
-AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i) {
-
+AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i) 
+{
   //Get next accepted particle; if i >= 0 (re)start counter from i; return 0 if no accepted particle could be found
 
   if (i>=0) fCurrentID = i;
@@ -138,8 +138,8 @@ AliVParticle* AliParticleContainer::GetNextAcceptParticle(Int_t i) {
 }
 
 //________________________________________________________________________
-AliVParticle* AliParticleContainer::GetNextParticle(Int_t i) {
-
+AliVParticle* AliParticleContainer::GetNextParticle(Int_t i) 
+{
   //Get next particle; if i >= 0 (re)start counter from i; return 0 if no particle could be found
 
   if (i>=0) fCurrentID = i;
@@ -197,6 +197,7 @@ Bool_t AliParticleContainer::AcceptParticle(AliVParticle *vp) const
 //________________________________________________________________________
 Int_t AliParticleContainer::GetNAcceptedParticles()
 {
+  // Get number of accepted particles
 
   Int_t nPart = 0;
 
index 8a4a3c17df99e2c2148bc2038a7b93fb679f1cc4..228deabf8ba07d1e3a158dcf51e366f07ebce870 100644 (file)
@@ -14,13 +14,7 @@ class AliParticleContainer : public AliEmcalContainer {
   AliParticleContainer(const char *name); 
   virtual ~AliParticleContainer(){;}
 
-  void  SetParticlePtCut(Double_t cut)                    { fParticlePtCut = cut ; }
-  void  SetParticleEtaLimits(Double_t min, Double_t max)  { fParticleMaxEta = max ; fParticleMinEta = min ; }
-  void  SetParticlePhiLimits(Double_t min, Double_t max)  { fParticleMaxPhi = max ; fParticleMinPhi = min ; }
-  void  SetTrackBitMap(UInt_t m)                          { fTrackBitMap     = m ; }
-  void  SetMCTrackBitMap(UInt_t m)                        { fMCTrackBitMap   = m ; }
-  void  SetMinMCLabel(Int_t s)                            { fMinMCLabel      = s ; }
-
+  Bool_t                      AcceptParticle(AliVParticle         *vp)  const;
   Double_t                    GetParticlePtCut()                        const   { return fParticlePtCut; }
   Double_t                    GetParticleEtaMin()                       const   { return fParticleMinEta; }
   Double_t                    GetParticleEtaMax()                       const   { return fParticleMaxEta; }
@@ -34,10 +28,15 @@ class AliParticleContainer : public AliEmcalContainer {
   AliVParticle               *GetNextAcceptParticle(Int_t i=-1)              ;
   AliVParticle               *GetNextParticle(Int_t i=-1)                    ;
   void                        GetMomentum(TLorentzVector &mom, Int_t i) const;
-  Bool_t                      AcceptParticle(AliVParticle         *vp)  const;
   Int_t                       GetNParticles()                           const   {return GetNEntries();}
   Int_t                       GetNAcceptedParticles()                   ;
   void                        SetClassName(const char *clname);
+  void                        SetMCTrackBitMap(UInt_t m)                        { fMCTrackBitMap   = m ; }
+  void                        SetMinMCLabel(Int_t s)                            { fMinMCLabel      = s ; }
+  void                        SetParticlePtCut(Double_t cut)                    { fParticlePtCut = cut ; }
+  void                        SetParticleEtaLimits(Double_t min, Double_t max)  { fParticleMaxEta = max ; fParticleMinEta = min ; }
+  void                        SetParticlePhiLimits(Double_t min, Double_t max)  { fParticleMaxPhi = max ; fParticleMinPhi = min ; }
+  void                        SetTrackBitMap(UInt_t m)                          { fTrackBitMap     = m ; }
 
  protected:
   Double_t                    fParticlePtCut;                 // cut on particle pt
index bee93b0aa9679bd098e3285ce2be74954a27576f..443de061c810a746e3bd8be9ff4a9ac2ae7e4cd1 100644 (file)
 //_________________________________________________________________________________________________
 AliPicoTrack::AliPicoTrack() :
   AliVTrack(),
-  fPt(0), fEta(0), fPhi(0), fQ(0), fLabel(-1), fTrackType(0), fEtaEmc(0), fPhiEmc(0), fPtEmc(0), fEmcal(0), fClusId(-1)
+  fPt(0), fEta(0), fPhi(0), fM(0.13957), fQ(0), fLabel(-1), fTrackType(0), fEtaEmc(0), fPhiEmc(0), fPtEmc(0), fEmcal(0), fClusId(-1)
 {
   // Default constructor.
 }
 
 //_________________________________________________________________________________________________
 AliPicoTrack::AliPicoTrack(Double_t pt, Double_t eta, Double_t phi, Byte_t q, Int_t lab, Byte_t type,
-                           Double_t etaemc, Double_t phiemc, Double_t ptemc, Bool_t ise) :
+                           Double_t etaemc, Double_t phiemc, Double_t ptemc, Bool_t ise, Double_t mass) :
   AliVTrack(),
-  fPt(pt), fEta(eta), fPhi(phi), fQ(q), fLabel(lab), fTrackType(type), 
+  fPt(pt), fEta(eta), fPhi(phi), fM(mass), fQ(q), fLabel(lab), fTrackType(type), 
   fEtaEmc(etaemc), fPhiEmc(phiemc), fPtEmc(ptemc), fEmcal(ise), fClusId(-1)
 {
   // Constructor.
@@ -30,7 +30,7 @@ AliPicoTrack::AliPicoTrack(Double_t pt, Double_t eta, Double_t phi, Byte_t q, In
 //_________________________________________________________________________________________________
 AliPicoTrack::AliPicoTrack(const AliPicoTrack &pc) :
   AliVTrack(pc),
-  fPt(pc.fPt), fEta(pc.fEta), fPhi(pc.fPhi), 
+  fPt(pc.fPt), fEta(pc.fEta), fPhi(pc.fPhi), fM(pc.fM),
   fQ(pc.fQ), fLabel(pc.fLabel), fTrackType(pc.fTrackType),  
   fEtaEmc(pc.fEtaEmc), fPhiEmc(pc.fPhiEmc), fPtEmc(pc.fPtEmc), fEmcal(pc.fEmcal),
   fClusId(pc.fClusId)
@@ -48,6 +48,7 @@ AliPicoTrack &AliPicoTrack::operator=(const AliPicoTrack &pc)
     fPt     = pc.fPt;
     fEta    = pc.fEta;
     fPhi    = pc.fPhi;
+    fM      = pc.fM;
     fQ      = pc.fQ;
     fLabel  = pc.fLabel;
     fTrackType = pc.fTrackType;
index c05c84d1f3481155d61f50d7b6dcb29a73603f03..28103ee3c14e2f5f431bbb4e08bfe4d25d677b60 100644 (file)
@@ -11,7 +11,7 @@ class AliPicoTrack: public AliVTrack {
  public:
   AliPicoTrack();
   AliPicoTrack(Double_t pt, Double_t eta, Double_t phi, Byte_t q, Int_t label, Byte_t type,
-               Double_t etaemc=0, Double_t phiemc=0, Double_t ptemc=0, Bool_t ise=0);
+               Double_t etaemc=0, Double_t phiemc=0, Double_t ptemc=0, Bool_t ise=0, Double_t mass=0.13957);
   ~AliPicoTrack() {;}
   AliPicoTrack(const AliPicoTrack &pc); 
   AliPicoTrack &operator=(const AliPicoTrack &pc);
@@ -31,7 +31,7 @@ class AliPicoTrack: public AliVTrack {
   Double_t Phi()                       const { return fPhi;    }
   Double_t Theta()                     const { return 2*TMath::ATan(TMath::Exp(-fEta));         }
   Double_t E()                         const { Double_t p=P(); return TMath::Sqrt(M()*M()+p*p); }
-  Double_t M()                         const { return 0.13957; }
+  Double_t M()                         const { return fM; }
   Double_t Eta()                       const { return fEta;    }
   Double_t Y()                         const { return 0.5*TMath::Log((E()+Pz())/(E()-Pz()));  }
   Short_t  Charge()                    const { return (char)fQ;}
@@ -69,6 +69,7 @@ class AliPicoTrack: public AliVTrack {
   Double32_t       fPt;       //[0,0,12]   pt at vertex
   Double32_t       fEta;      //[-1,1,12]  eta at vertex
   Double32_t       fPhi;      //[0,6.3,12] phi at vertex
+  Double32_t       fM;        //           mass
   Byte_t           fQ;        //           charge
   Int_t            fLabel;    //           label  
   Byte_t           fTrackType;//           0=global track; 1=w/o SPD, w/ ITS refit; 2=w/o SPD, w/o ITS refit
@@ -79,6 +80,6 @@ class AliPicoTrack: public AliVTrack {
   Short_t          fClusId;   //!          cluster id of matched cluster; -1 if not set
 
 
-  ClassDef(AliPicoTrack, 5) // Pico track class
+  ClassDef(AliPicoTrack, 6) // Pico track class
 };
 #endif
diff --git a/PWG/EMCAL/macros/AddTaskAodTrackFilter.C b/PWG/EMCAL/macros/AddTaskAodTrackFilter.C
new file mode 100644 (file)
index 0000000..be44a28
--- /dev/null
@@ -0,0 +1,97 @@
+// $Id$
+
+AliAodTrackFilterTask* AddTaskAodTrackFilter(
+  const char *name         = "filtertracks",
+  const char *inname       = "tracks",
+  const char *runperiod    = "",
+  Double_t ptmin           = 0,
+  Double_t ptmax           = 1000,
+  Double_t etamin          = -10,
+  Double_t etamax          = +10,
+  Double_t phimin          = -10,
+  Double_t phimax          = +10,
+  Double_t trackeff        = 1.0,
+  Bool_t   modTracks       = kTRUE,
+  const char *taskName     = "AliAodTrackFilterTask"
+)
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+  {
+    ::Error("AddTaskAodTrackFilter", "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("AddTaskAodTrackFilter", "This task requires an input event handler");
+    return NULL;
+  }
+
+  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+  if (inputDataType != "AOD")) {
+    ::Error("AddTaskAodTrackFilter", "This task works only on AOD analysis");
+    return NULL;
+  }
+  
+  //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+
+  AliAodTrackFilterTask *eTask = new AliAodTrackFilterTask(taskName);
+  eTask->SetTracksOutName(name);
+  eTask->SetTracksInName(inname);
+  eTask->SetTrackPtLimits(ptmin, ptmax);
+  eTask->SetTrackEtaLimits(etamin, etamax);
+  eTask->SetTrackPhiLimits(phimin, phimax);
+  eTask->SetTrackEfficiency(trackeff);
+  eTask->SetModifyTrack(modTracks);
+
+  TString runPeriod(runperiod);
+  Bool_t includeNoITS = kFALSE;
+  runPeriod.ToLower();
+  if (runPeriod == "lhc11h" || runPeriod == "lhc13b" || runPeriod == "lhc13c" || runPeriod == "lhc13d" || runPeriod == "lhc13e" || runPeriod == "lhc13f" || runPeriod == "lhc13g" || runPeriod == "lhc12g" || runPeriod == "lhc10h") {
+    eTask->SetAODfilterBits(256,512); // hybrid tracks for LHC11h
+    eTask->SetMC(kFALSE);
+    if(runPeriod == "lhc10h")
+      includeNoITS = kTRUE;
+  } else if (runPeriod == "lhc12a15e" || runPeriod == "lhc13b4" || runPeriod == "lhc13b4_fix" || runPeriod == "lhc12a15f") {
+    eTask->SetAODfilterBits(256,512); // hybrid tracks for LHC12a15e, LHC13b4, and LHC12a15f
+    eTask->SetMC(kTRUE);
+  } else if (runPeriod == "lhc11a" || runPeriod == "lhc10hold") {
+    eTask->SetAODfilterBits(256,16); // hybrid tracks for LHC11a
+    eTask->SetMC(kFALSE);
+    includeNoITS = kTRUE;
+  } else if (runPeriod.Contains("lhc12a15a")) {
+    eTask->SetAODfilterBits(256,16); // hybrid tracks for LHC12a15a
+    eTask->SetMC(kTRUE);
+    includeNoITS = kTRUE;
+  } else if (runPeriod.Contains(":")) {
+    TObjArray *arr = runPeriod.Tokenize(":");
+    TString arg1(arr->At(0)->GetName());
+    TString arg2("-1");
+    if (arr->GetEntries()>1)
+      arg2 = arr->At(1)->GetName();
+    eTask->SetAODfilterBits(arg1.Atoi(),arg2.Atoi());
+    delete arr;
+  } else {
+    if (!runPeriod.IsNull())
+      ::Warning("Run period %s not known. It will use IsHybridGlobalConstrainedGlobal.", runPeriod.Data());
+  }
+  eTask->SetIncludeNoITS(includeNoITS);
+
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+  mgr->AddTask(eTask);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
+  mgr->ConnectInput  (eTask, 0,  cinput1 );
+  
+  return eTask;
+}
diff --git a/PWG/EMCAL/macros/AddTaskEMCALTenderUsingDatasetDef.C b/PWG/EMCAL/macros/AddTaskEMCALTenderUsingDatasetDef.C
new file mode 100644 (file)
index 0000000..21ff735
--- /dev/null
@@ -0,0 +1,37 @@
+// $Id$
+
+AliAnalysisTaskSE *AddTaskEMCALTenderUsingDatasetDef(
+  const char *dstr    = "LHC11h",
+  const char *pass    = 0 /*should not be needed*/
+) 
+{
+  gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEMCALTender.C");
+
+  Bool_t distBC         = kTRUE;   //distance to bad channel
+  Bool_t recalibClus    = kTRUE;   //recalibrate cluster energy
+  Bool_t recalcClusPos  = kTRUE;   //recalculate cluster position
+  Bool_t nonLinearCorr  = kTRUE;   //apply non-linearity
+  Bool_t remExotic      = kTRUE;   //remove exotic cells
+  Bool_t fidRegion      = kFALSE;  //apply fiducial cuts
+  Bool_t calibEnergy    = kTRUE;   //calibrate energy
+  Bool_t calibTime      = kTRUE,   //calibrate timing
+  Bool_t remBC          = kTRUE,   //remove bad channels
+  UInt_t nonLinFunct    = AliEMCALRecoUtils::kBeamTestCorrected;
+  Bool_t reclusterize   = kFALSE,  //reclusterize
+  Float_t seedthresh    = 0.3,     //seed threshold
+  Float_t cellthresh    = 0.05,    //cell threshold
+  UInt_t clusterizer    = AliEMCALRecParam::kClusterizerv2,
+  Bool_t trackMatch     = kFALSE,  //track matching
+  Bool_t updateCellOnly = kFALSE,  //only change if you run your own clusterizer task
+  Float_t timeMin       = 100e-9,  //minimum time of physical signal in a cell/digit (s)
+  Float_t timeMax       = 900e-9,  //maximum time of physical signal in a cell/digit (s)
+  Float_t timeCut       = 50e-9,   //maximum time difference between the digits inside EMC cluster (s)
+
+
+AliAnalysisTaskSE *task = AddTaskEMCALTender(
+  "tothink",distBC,recalibClus,recalcClusPos,nonLinearCorr,remExotic,fidRegion,calibEnergy,calibTime,
+  remBC, nonLinFunct, reclusterize, seedthresh, cellthresh, clusterizer, trackMatch, updateCellOnly,
+  timeMin, timeMax, timeCut, 0);
+
+  return et;
+}
similarity index 95%
rename from PWG/EMCAL/macros/AddTaskEmcalEsdTpcTrack.C
rename to PWG/EMCAL/macros/AddTaskEmcalEsdTrackFilter.C
index 0412c3117a89dcee4e0b0574296f412b61e108fb..5aa6211ee4af0041f5ee92c2b6a3adcfe0ceb1d1 100644 (file)
@@ -1,7 +1,7 @@
 // $Id$
 
-AliEmcalEsdTpcTrackTask* AddTaskEmcalEsdTpcTrack(
-  const char *name              = "TpcSpdVertexConstrainedTracks",
+AliEmcalEsdTrackFilterTask* AddTaskEmcalEsdTrackFilter(
+  const char *name              = "AliEmcalEsdTrackFilter",
   const char *trackCuts         = "Hybrid_LHC11h"
 )
 { 
@@ -119,7 +119,7 @@ AliEmcalEsdTpcTrackTask* AddTaskEmcalEsdTpcTrack(
 
   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C");
   Bool_t includeNoITS = kFALSE;
-  AliEmcalEsdTpcTrackTask *eTask = new AliEmcalEsdTpcTrackTask(); // default is TPC only tracks constrained to the vertex
+  AliEmcalEsdTrackFilterTask *eTask = new AliEmcalEsdTrackFilterTask(); // default is TPC only tracks constrained to the vertex
 
   if ((dataSet == kLHC11c && cutsType == kHybrid) ||
       (dataSet == kLHC11d && cutsType == kHybrid) ||
index f8eb8ea95280a2d4986b6347cdfdfabfaeb72139..0b2ffad84dc6eb9eefe3ac95654222ac9baf1c02 100644 (file)
@@ -3,7 +3,8 @@
 AliEmcalSetupTask* AddTaskEmcalSetup(
   const char *geop = 0,
   const char *oadp = 0,
-  const char *ocdp = 0 
+  const char *ocdp = 0, 
+  const char *objs = 0
 )
 {  
   // Get the pointer to the existing analysis manager via the static access method.
@@ -30,6 +31,7 @@ AliEmcalSetupTask* AddTaskEmcalSetup(
   if (geop) eTask->SetGeoPath(geop);
   if (oadp) eTask->SetOadbPath(oadp);
   if (ocdp) eTask->SetOcdbPath(ocdp);
+  if (objs) eTask->SetObjs(objs);
 
   //-------------------------------------------------------
   // Final settings, pass to manager and set the containers
diff --git a/PWG/EMCAL/macros/AddTaskEmcalTrackPropagatorAOD.C b/PWG/EMCAL/macros/AddTaskEmcalTrackPropagatorAOD.C
new file mode 100644 (file)
index 0000000..fb1970d
--- /dev/null
@@ -0,0 +1,48 @@
+// $Id$
+
+AliEmcalTrackPropagatorTaskAOD* AddTaskEmcalTrackPropagatorAOD(
+  const char *name         = "Tracks",
+  const Double_t d         = -1,
+  const Double_t pt        = -1
+)
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskEmcalTrackPropagatorAOD", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  AliVEventHandler *evhand = mgr->GetInputEventHandler();
+  if (!evhand) {
+    ::Error("AddTaskEmcalTrackPropagatorAOD", "This task requires an input event handler");
+    return NULL;
+  }
+  
+  if (!evhand->InheritsFrom("AliAODInputHandler")) {
+    ::Info("AddTaskEmcalTrackPropagatorAOD", "This task is only needed for AOD analysis. No task added.");
+    return NULL;
+  }
+
+  //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+  AliEmcalTrackPropagatorTaskAOD* propagator = new AliEmcalTrackPropagatorTaskAOD();
+  propagator->SetTracksName(name);
+  if (d > -1) propagator->SetDist(d);
+  if (pt > -1) propagator->SetMinPt(pt);
+
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+  mgr->AddTask(propagator);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
+  mgr->ConnectInput  (propagator, 0,  cinput1 );
+  
+  return propagator;
+}
index 9f7822c5389f48cc099e09dc3e9ae3c559d6b7db..4b23f8c06d480b92d6be435e68b994f421841b6b 100644 (file)
@@ -92,6 +92,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fQAlevel(0),
   fReadESD(kFALSE),
   fReadMC(kFALSE),
+  fPostMatched(0),
   fAvoidExec(kFALSE),
   fSkipSelection(kFALSE),
   fSkipFlow(kFALSE),
@@ -104,6 +105,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fCentPerMin(0),
   fCentPerMax(100),
   fThisCent(-1.0),
+  fVertexZcut(10.0),
   fExcludeTPCEdges(kFALSE),
   fSpecie(0),
   fOnline(kFALSE),
@@ -124,6 +126,8 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fMassBins(0),
   fMinMass(0.0),
   fMaxMass(0.0),
+  fMinMassX(-1.0),
+  fMaxMassX(-1.0),
   fRFPFilterBit(1),
   fRFPminPt(0.2),
   fRFPmaxPt(5.0),
@@ -145,9 +149,18 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fDecayAlpha(0.0),
   fDecayRapidity(0.0),
   fDecayProductIPXY(0.0),
+  fDecayIPneg(0.0),
+  fDecayIPpos(0.0),
+  fDecayXneg(0.0),
+  fDecayXpos(0.0),
   fDecayIDneg(-1),
   fDecayIDpos(-1),
   fDecayID(-1),
+  fDecayMatchOrigin(0.0),
+  fDecayMatchPhi(0.0),
+  fDecayMatchEta(0.0),
+  fDecayMatchPt(0.0),
+  fDecayMatchRadXY(0.0),
   fDecayMinEta(0.0),
   fDecayMaxEta(0.0),
   fDecayMinPt(0.0),
@@ -171,8 +184,14 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fDaughterImpactParameterXY(0.0),
   fDaughterImpactParameterZ(0.0),
   fDaughterStatus(0),
+  fDaughterITScm(0),
   fDaughterNSigmaPID(0.0),
   fDaughterKinkIndex(0),
+  fDaughterMatchPhi(0.0),
+  fDaughterMatchEta(0.0),
+  fDaughterMatchPt(0.0),
+  fDaughterMatchImpactParameterXY(0.0),
+  fDaughterMatchImpactParameterZ(0.0),
   fDaughterUnTag(kTRUE),
   fDaughterMinEta(0.0),
   fDaughterMaxEta(0.0),
@@ -184,6 +203,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
   fDaughterMinImpactParameterXY(0.0),
   fDaughterMaxNSigmaPID(0.0) {
   //ctor
+  for(Int_t i=0; i!=6; ++i) fDaughterITSConfig[i]=-1;
 }
 //=======================================================================
 AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
@@ -200,6 +220,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fQAlevel(0),
   fReadESD(kFALSE),
   fReadMC(kFALSE),
+  fPostMatched(0),
   fAvoidExec(kFALSE),
   fSkipSelection(kFALSE),
   fSkipFlow(kFALSE),
@@ -212,6 +233,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fCentPerMin(0),
   fCentPerMax(100),
   fThisCent(-1.0),
+  fVertexZcut(10.0),
   fExcludeTPCEdges(kFALSE),
   fSpecie(0),
   fOnline(kFALSE),
@@ -232,6 +254,8 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fMassBins(0),
   fMinMass(0.0),
   fMaxMass(0.0),
+  fMinMassX(-1.0),
+  fMaxMassX(-1.0),
   fRFPFilterBit(1),
   fRFPminPt(0.2),
   fRFPmaxPt(5.0),
@@ -253,9 +277,18 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fDecayAlpha(0.0),
   fDecayRapidity(0.0),
   fDecayProductIPXY(0.0),
+  fDecayIPneg(0.0),
+  fDecayIPpos(0.0),
+  fDecayXneg(0.0),
+  fDecayXpos(0.0),
   fDecayIDneg(-1),
   fDecayIDpos(-1),
   fDecayID(-1),
+  fDecayMatchOrigin(0.0),
+  fDecayMatchPhi(0.0),
+  fDecayMatchEta(0.0),
+  fDecayMatchPt(0.0),
+  fDecayMatchRadXY(0.0),
   fDecayMinEta(0.0),
   fDecayMaxEta(0.0),
   fDecayMinPt(0.0),
@@ -279,8 +312,14 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fDaughterImpactParameterXY(0.0),
   fDaughterImpactParameterZ(0.0),
   fDaughterStatus(0),
+  fDaughterITScm(0),
   fDaughterNSigmaPID(0.0),
   fDaughterKinkIndex(0),
+  fDaughterMatchPhi(0.0),
+  fDaughterMatchEta(0.0),
+  fDaughterMatchPt(0.0),
+  fDaughterMatchImpactParameterXY(0.0),
+  fDaughterMatchImpactParameterZ(0.0),
   fDaughterUnTag(kTRUE),
   fDaughterMinEta(0.0),
   fDaughterMaxEta(0.0),
@@ -292,6 +331,7 @@ AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
   fDaughterMinImpactParameterXY(0.0),
   fDaughterMaxNSigmaPID(0.0) {
   //ctor
+  for(Int_t i=0; i!=6; ++i) fDaughterITSConfig[i]=-1;
   DefineInput( 0,TChain::Class());
   DefineOutput(1,TList::Class());
   DefineOutput(2,AliFlowEventSimple::Class()); // TPC object
@@ -325,6 +365,22 @@ void AliAnalysisTaskFlowStrange::UserCreateOutputObjects() {
   cc->SetMassMin(fMinMass);
   cc->SetMassMax(fMaxMass);
 
+  if(fMinMassX<0) {
+    if(fSpecie==0) {
+      fMinMassX = 0.494;
+      fMaxMassX = 0.502;
+      //      double lowEdge[14]={0.398, 0.420, 0.444, 0.468, 0.486,
+      //                         0.490, 0.494, 0.498, 0.502, 0.506, 
+      //                         0.524, 0.548, 0.572, 0.598};
+    } else {
+      fMinMassX = 1.114;
+      fMaxMassX = 1.118;
+      //      double lowEdge[13]={1.084, 1.094, 1.104, 1.110, 1.114,
+      //                         1.116, 1.118, 1.122, 1.128, 1.138,
+      //                         1.148, 1.158, 1.168};} else {
+    }
+  }
+
   //loading pid response
   AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
@@ -386,24 +442,23 @@ void AliAnalysisTaskFlowStrange::AddQAEvents() {
   tH1D = new TH1D("UNTAG","UNTAG;Untagged Daughters",800,0,800);tQAEvents->Add(tH1D);
   tH1D = new TH1D("RealTime","RealTime;LogT sec",2000,-10,+10); tQAEvents->Add(tH1D);
   fList->Add(tQAEvents);
-  AddEventSpy();
+  AddEventSpy("EventsReached");
+  AddEventSpy("EventsSelected");
   AddMakeQSpy();
 }
 //=======================================================================
-void AliAnalysisTaskFlowStrange::AddEventSpy() {
+void AliAnalysisTaskFlowStrange::AddEventSpy(TString name) {
   TH1D *tH1D;
   TH2D *tH2D;
   TList *tList=new TList();
-  tList->SetName("EventSpy");
+  tList->SetName(name.Data());
   tList->SetOwner();
-  if(fQAlevel>0) {
-    tH2D = new TH2D("VTXZ","VTXZ;Global||SPD;SPD",60,-25,+25,60,-25,+25); tList->Add( tH2D );
-    tH2D = new TH2D("CCCC","CCCC;V0M;TRK",60,-10,110,60,-10,110);         tList->Add( tH2D );
-    tH2D = new TH2D("REFM","REFM;TPC;GLOBAL",100,0,3000,100,0,3000);      tList->Add( tH2D );
-    if(fReadMC) {
-      tH1D = new TH1D("MCCC","MCCC;Xsection",100,-10,110); tList->Add( tH1D );
-      tH1D = new TH1D("MCEP","MCEP;MCEP",100,-TMath::TwoPi(),TMath::TwoPi()); tList->Add( tH1D );
-    }
+  tH2D = new TH2D("VTXZ","VTXZ;Global||SPD;SPD",60,-25,+25,60,-25,+25); tList->Add( tH2D );
+  tH2D = new TH2D("CCCC","CCCC;V0M;TRK",60,-10,110,60,-10,110);         tList->Add( tH2D );
+  tH2D = new TH2D("REFM","REFM;TPC;GLOBAL",100,0,3000,100,0,3000);      tList->Add( tH2D );
+  if(fReadMC) {
+    tH1D = new TH1D("MCCC","MCCC;Xsection",100,-10,110); tList->Add( tH1D );
+    tH1D = new TH1D("MCEP","MCEP;MCEP",100,-TMath::TwoPi(),TMath::TwoPi()); tList->Add( tH1D );
   }
   fList->Add(tList);
 }
@@ -418,6 +473,8 @@ void AliAnalysisTaskFlowStrange::AddMakeQSpy() {
   tList->SetOwner();
   tH1D = new TH1D("RFPTPC","TPC Refrence Multiplicity;multiplicity",3000,0,3000);     tList->Add( tH1D );
   tH1D = new TH1D("RFPVZE","VZERO Reference Multiplicity;multiplicity",3000,0,30000); tList->Add( tH1D );
+  tH1D = new TH1D("QmTPC","TPC Normalized Q vector;|Q|/M",3000,0,1);   tList->Add( tH1D );
+  tH1D = new TH1D("QmVZE","VZERO Normalized Q vector;|Q|/M",3000,0,1); tList->Add( tH1D );
   tH2D = new TH2D("TPCAllPhiEta","TPCall;Phi;Eta",180,0,TMath::TwoPi(),80,-0.9,+0.9); tList->Add( tH2D );
   tH2D = new TH2D("VZEAllPhiEta","VZEall;Phi;Eta",20,0,TMath::TwoPi(),40,-4.0,+6.0);  tList->Add( tH2D );
   tH1D = new TH1D("TPCPSI","TPCPSI;PSI",72,0,TMath::Pi()); tList->Add( tH1D );
@@ -481,19 +538,25 @@ void AliAnalysisTaskFlowStrange::AddQACandidates() {
   }
   //match
   if(fReadMC) {
-    tList=new TList(); tList->SetName("RecMth"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
-    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);
-    tH2D = new TH2D("PTRes", "PTRes;MCPt;DAT-MC/MC",  100,   0,  20,100,-0.2,+0.2); tList->Add(tH2D);
-    tH2D = new TH2D("ETARes","ETARes;MCETA;DAT-MC/MC", 16,   0, 0.8,100,-0.5,+0.5); tList->Add(tH2D);
-    tH2D = new TH2D("RXYRes","RXYRes;MCRXY;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);
-    tH2D = new TH2D("DLERes","DLERes;MCDLE;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);
-    tH2D = new TH2D("RAPRes","RAPRes;MCRAP;DAT-MC/MC", 10,   0, 0.5,100,-0.5,+0.5); tList->Add(tH2D);
-    tH2D = new TH2D("APARes","APARes;MCAPA;DAT-MC/MC", 24,-1.2, 1.2,100,-0.5,+0.5); tList->Add(tH2D);
-    tH2D = new TH2D("APQRes","APQRes;MCAPQ;DAT-MC/MC", 25,   0,0.25,100,-0.3,+0.3); tList->Add(tH2D);
+    tList=new TList(); tList->SetName("STATMC"); tList->SetOwner(); fList->Add(tList);
+    tH1D = new TH1D("Events", "Events",5,0.5,5.5); tList->Add(tH1D);
+    tH1D->GetXaxis()->SetBinLabel(1,"Selected events");
+    tH1D->GetXaxis()->SetBinLabel(2,"Stack found");
+    tH1D->GetXaxis()->SetBinLabel(3,"Daughters in stack");
+    tH1D->GetXaxis()->SetBinLabel(4,"Correspond to decay");
+    tH1D->GetXaxis()->SetBinLabel(5,"Decay has mother");
+
+    tList=new TList(); tList->SetName("RecMth"); tList->SetOwner(); AddCandidatesSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("TrkMth"); tList->SetOwner(); AddTracksSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("RecUNMth"); tList->SetOwner(); AddCandidatesSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("TrkUNMth"); tList->SetOwner(); AddTracksSpy(tList,true); fList->Add(tList);
+
+    tList=new TList(); tList->SetName("NegNegMth"); tList->SetOwner(); AddCandidatesSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("NegPosMth"); tList->SetOwner(); AddCandidatesSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("TrkNegMth"); tList->SetOwner(); AddTracksSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("TrkPosMth"); tList->SetOwner(); AddTracksSpy(tList,true); fList->Add(tList);
+    tList=new TList(); tList->SetName("MthFDW"); tList->SetOwner(); AddCandidatesSpy(tList,true); fList->Add(tList);
 
-    tList=new TList(); tList->SetName("TrkMth"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);
-    tList=new TList(); tList->SetName("MthFDW"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
-    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);
   }
   //stack
   if(fReadMC) {
@@ -558,10 +621,14 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliESDEvent *tESD) {
   fThisCent = cent->GetCentralityPercentile( mycent );
   acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
   acceptEvent = TMath::Abs(tTPCVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
-  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  acceptEvent = TMath::Abs(tTPCVtxZ)>fVertexZcut?kFALSE:acceptEvent;
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("CCCC"))->Fill( cc1, cc2 );
   // EndOfCuts
+  if(acceptEvent) {
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  }
   return acceptEvent;
 }
 //=======================================================================
@@ -604,17 +671,24 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliAODEvent *tAOD) {
 
   acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
   acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
-  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;
-  if(fQAlevel>0) {
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("REFM"))->Fill( tpc, glo );
+  acceptEvent = TMath::Abs(tVtxZ)>fVertexZcut?kFALSE:acceptEvent;
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("REFM"))->Fill( tpc, glo );
+  if(fReadMC) {
+    ((TH1D*)((TList*)fList->FindObject("EventsReached"))->FindObject("MCCC"))->Fill( xsec );
+    ((TH1D*)((TList*)fList->FindObject("EventsReached"))->FindObject("MCEP"))->Fill( fMCEP );
+  }
+  // EndOfCuts
+  if(acceptEvent) {
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("REFM"))->Fill( tpc, glo );
     if(fReadMC) {
-      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCCC"))->Fill( xsec );
-      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCEP"))->Fill( fMCEP );
+      ((TH1D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("MCCC"))->Fill( xsec );
+      ((TH1D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("MCEP"))->Fill( fMCEP );
     }
   }
-  // EndOfCuts
   return acceptEvent;
 }
 //=======================================================================
@@ -633,10 +707,14 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptPPEvent(AliAODEvent *tAOD) {
   //for pp i use fCentPerXXX to select on multiplicity
   acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
   acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
-  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  acceptEvent = TMath::Abs(tVtxZ)>fVertexZcut?kFALSE:acceptEvent;
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("CCCC"))->Fill( cc1, cc2 );
   // EndOfCuts
+  if(acceptEvent) {
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  }
   return acceptEvent;
 }
 //=======================================================================
@@ -691,10 +769,14 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptPAEvent(AliAODEvent *tAOD) {
   if(fCentMethod.Contains("V0MTRK")) fCentMethod = "V0M";
   fThisCent = cent->GetCentralityPercentile( fCentMethod );
   acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
-  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tTPCVtxZ)>fVertexZcut?kFALSE:acceptEvent;
   // EndOfCuts
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+  ((TH2D*)((TList*)fList->FindObject("EventsReached"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  if(acceptEvent) {
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+    ((TH2D*)((TList*)fList->FindObject("EventsSelected"))->FindObject("CCCC"))->Fill( cc1, cc2 );    
+  }
   return acceptEvent;
 }
 //=======================================================================
@@ -1072,7 +1154,7 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
     ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
     fDaughterImpactParameterXY = ip[0];
     fDaughterImpactParameterZ = ip[1];
-    Double_t dD0P = fDaughterImpactParameterXY; //ieT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
+    fDecayIPpos = fDaughterImpactParameterXY; //ieT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
     if(!AcceptDaughter()) continue;
 
     jT=(AliAODTrack*) myV0->GetDaughter(iNeg); // negative
@@ -1085,14 +1167,14 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
     jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
     fDaughterImpactParameterXY = ip[0];
     fDaughterImpactParameterZ = ip[1];
-    Double_t dD0N = fDaughterImpactParameterXY; //jeT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
+    fDecayIPneg = fDaughterImpactParameterXY; //jeT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
     if(!AcceptDaughter()) continue;
+
     if( fExcludeTPCEdges ) {
       if( IsAtTPCEdge(iT->Phi(),iT->Pt(),+1,tAOD->GetMagneticField()) ) continue;
       if( IsAtTPCEdge(jT->Phi(),jT->Pt(),-1,tAOD->GetMagneticField()) ) continue;
     }
-    Double_t xa, xb;
-    ieT.GetDCA(&jeT,tAOD->GetMagneticField(),xa,xb);
+    ieT.GetDCA(&jeT,tAOD->GetMagneticField(),fDecayXpos,fDecayXneg);
     /*
     // cutting out population close to TPC edges :: strange excess saw in 2010
     if( fExcludeTPCEdges ) {
@@ -1113,7 +1195,7 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
     fDecayPt = myV0->Pt();
     fDecayPhi = myV0->Phi();
     fDecayEta = myV0->Eta();
-    fDecayProductIPXY = dD0P*dD0N;
+    fDecayProductIPXY = fDecayIPpos*fDecayIPneg;
     fDecayQt = myV0->PtArmV0();
     fDecayAlpha = myV0->AlphaV0(); // AlphaV0 -> AODRecoDecat::Alpha -> return 1.-2./(1.+QlProng(0)/QlProng(1));
     if(myV0->ChargeProng(iPos)<0) fDecayAlpha = -fDecayAlpha; // protects for a change in convention
@@ -1141,8 +1223,6 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
       else FillCandidateSpy("RecAllIP");
     }
     FillCandidateSpy("RecAll");
-    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );
-    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
     if(!AcceptCandidate()) continue;
     //PID for lambda::proton
     if( fSpecie>0 )
@@ -1158,11 +1238,15 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
       else FillCandidateSpy("RecSelIP");
     }
     FillCandidateSpy("RecSel");
-    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );
-    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
-    fDecayIDneg = iT->GetID();
-    fDecayIDpos = jT->GetID();
-    MakeTrack();
+    // ============================
+    // Posting for FlowAnalysis
+    if(!fPostMatched) {
+      fDecayIDneg = iT->GetID();
+      fDecayIDpos = jT->GetID();
+      MakeTrack();
+    }
+    // ============================
+
     LoadTrack(&ieT,iT->Chi2perNDF());
     ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
     fDaughterImpactParameterXY = ip[0];
@@ -1173,18 +1257,18 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
     fDaughterImpactParameterXY = ip[0];
     fDaughterImpactParameterZ = ip[1];
     FillTrackSpy("TrkDau");
-    //===== BEGIN OF MCMATCH                                                                                                                         
+    //===== BEGIN OF MCMATCH
+    if(fReadMC) ((TH1D*)((TList*)fList->FindObject("STATMC"))->FindObject("Events"))->Fill( 1 ); // Selected event
     if(mcArray) {
+      ((TH1D*)((TList*)fList->FindObject("STATMC"))->FindObject("Events"))->Fill( 2 ); // Stack found
       bool matched = false;
       bool feeddown = false;
       Int_t labelpos = iT->GetLabel();
       Int_t labelneg = jT->GetLabel();
-      Double_t rOri=-1;
-      Double_t mcPt=-1, mcEta=-1, mcRap=-1, mcRxy=-1, mcDle=-1, mcApa=-100, mcApq=-1;
-      Double_t resPt=-1, resEta=-1, resRap=-1, resRxy=-1, resDle=-1, resApa=-1, resApq=-1;
-      if( labelpos>0 && labelneg>0 ) {
-        AliAODMCParticle *mcpos = (AliAODMCParticle*) mcArray->At( labelpos );
-        AliAODMCParticle *mcneg = (AliAODMCParticle*) mcArray->At( labelneg );
+      AliAODMCParticle *mcpos = (AliAODMCParticle*) mcArray->At( TMath::Abs(labelpos) );
+      AliAODMCParticle *mcneg = (AliAODMCParticle*) mcArray->At( TMath::Abs(labelneg) );
+      if( mcpos && mcneg ) {
+        ((TH1D*)((TList*)fList->FindObject("STATMC"))->FindObject("Events"))->Fill( 3 ); // Daughters in stack
         Int_t pdgRecPos = mcpos->GetPdgCode();
         Int_t pdgRecNeg = mcneg->GetPdgCode();
         int pospdg=211, negpdg=211;
@@ -1199,72 +1283,88 @@ void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
           }
         }
         if( TMath::Abs(pdgRecPos)==pospdg&&TMath::Abs(pdgRecNeg)==negpdg )
-          if(mcpos->GetMother()>0)
+          if(mcpos->GetMother()>-1)
             if( mcpos->GetMother()==mcneg->GetMother() ) {
               AliAODMCParticle *mcmot = (AliAODMCParticle*) mcArray->At( mcpos->GetMother() );
-              rOri = TMath::Sqrt( mcmot->Xv()*mcmot->Xv() + mcmot->Yv()*mcmot->Yv() );
-              mcPt = mcmot->Pt();
-              mcEta = TMath::Abs( mcmot->Eta() );
-              mcRap = TMath::Abs( mcmot->Y() );
-              if(!TMath::AreEqualAbs(mcPt,0,1e-6))  resPt = (fDecayPt - mcPt) / mcPt;
-              if(!TMath::AreEqualAbs(mcEta,0,1e-6)) resEta = (fDecayEta - mcEta) / mcEta;
-              if(!TMath::AreEqualAbs(mcRap,0,1e-6)) resRap = (fDecayRapidity - mcRap) / mcRap;
+              fDecayMatchOrigin = TMath::Sqrt( mcmot->Xv()*mcmot->Xv() + mcmot->Yv()*mcmot->Yv() );
+              fDecayMatchPt = mcmot->Pt();
+              fDecayMatchEta = mcmot->Eta();
+              fDecayMatchPhi = mcmot->Phi();
               if( TMath::Abs(mcmot->GetPdgCode())==mompdg) {
                 if(mcmot->GetNDaughters()==2) {
+                 ((TH1D*)((TList*)fList->FindObject("STATMC"))->FindObject("Events"))->Fill( 4 ); // Correspond to decay
                   matched=true;
                   Double_t dx = mcmot->Xv() - mcpos->Xv();
                   Double_t dy = mcmot->Yv() - mcpos->Yv();
-                  Double_t dz = mcmot->Zv() - mcpos->Zv();
-                  Double_t mcGamma = mcmot->E() / mcmot->GetCalcMass();
-                  mcRxy = TMath::Sqrt( dx*dx + dy*dy );
-                  mcDle = TMath::Sqrt(dx*dx+dy*dy+dz*dz)/mcGamma;
-                  if(!TMath::AreEqualAbs(mcRxy,0,1e-6)) resRxy = (fDecayRadXY - mcRxy) / mcRxy;
-                  if(!TMath::AreEqualAbs(mcDle,0,1e-6)) resDle = (fDecayDecayLength - mcDle) / mcDle;
-                  TVector3 momPos(mcpos->Px(),mcpos->Py(),mcpos->Pz());
-                  TVector3 momNeg(mcneg->Px(),mcneg->Py(),mcneg->Pz());
-                  TVector3 momTot(mcmot->Px(),mcmot->Py(),mcmot->Pz());
-                  Double_t qlpos = momPos.Dot(momTot)/momTot.Mag();
-                  Double_t qlneg = momNeg.Dot(momTot)/momTot.Mag();
-                  mcApq = momPos.Perp(momTot);
-                  mcApa = 1.-2./(1.+qlpos/qlneg);
-                  if(!TMath::AreEqualAbs(mcApq,0,1e-6)) resApq = (fDecayQt - mcApq) / mcApq;
-                  if(!TMath::AreEqualAbs(mcApa,0,1e-6)) resApa = (fDecayAlpha - mcApa) / mcApa;
+                  fDecayMatchRadXY = TMath::Sqrt( dx*dx + dy*dy );
                 }
-                if(mcmot->GetMother()>0) {
+                if(mcmot->GetMother()>-1) {
+                 ((TH1D*)((TList*)fList->FindObject("STATMC"))->FindObject("Events"))->Fill( 5 ); // Decay has mother
                   AliAODMCParticle *mcfdw = (AliAODMCParticle*) mcArray->At( mcmot->GetMother() );
                   if( TMath::Abs(mcfdw->GetPdgCode())==fdwpdg)
                     feeddown=true;
                 } // k0/lda have mother
               } // mother matches k0/lda
             } // both have same mother
-      } // match to MCparticles
+      }
       if(matched) {
-        FillCandidateSpy("RecMth");
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
-        ((TH1D*)((TList*)fList->FindObject("RecMth"))->FindObject("MCOrigin"))->Fill( rOri );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("PTRes"))->Fill( mcPt, resPt );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("ETARes"))->Fill( mcEta, resEta );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RAPRes"))->Fill( mcRap, resRap );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RXYRes"))->Fill( mcRxy, resRxy );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("DLERes"))->Fill( mcDle, resDle );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APARes"))->Fill( mcApa, resApa );
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APQRes"))->Fill( mcApq, resApq );
+        FillCandidateSpy("RecMth",true);
+       if(fPostMatched>0) {
+         fDecayIDneg = iT->GetID();
+         fDecayIDpos = jT->GetID();
+         MakeTrack();
+       }
+       if(labelpos<0&&labelneg<0) {
+         FillCandidateSpy("NegNegMth",true);
+       } else if(labelpos*labelneg<0) {
+         FillCandidateSpy("NegPosMth",true);
+       }
         LoadTrack(&ieT,iT->Chi2perNDF());
+       fDaughterMatchPhi=mcpos->Phi();
+       fDaughterMatchEta=mcpos->Eta();
+       fDaughterMatchPt=mcpos->Pt();
         ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
         fDaughterImpactParameterXY = ip[0];
         fDaughterImpactParameterZ = ip[1];
-        FillTrackSpy("TrkMth");
+        FillTrackSpy("TrkMth",true);
+       if(labelpos<0||labelneg<0) FillTrackSpy("TrkNegMth",true);
+       else FillTrackSpy("TrkPosMth",true);
         LoadTrack(&jeT,jT->Chi2perNDF());
+       fDaughterMatchPhi=mcneg->Phi();
+       fDaughterMatchEta=mcneg->Eta();
+       fDaughterMatchPt=mcneg->Pt();
         jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
         fDaughterImpactParameterXY = ip[0];
         fDaughterImpactParameterZ = ip[1];
-        FillTrackSpy("TrkMth");
+        FillTrackSpy("TrkMth",true);
+       if(labelpos<0||labelneg<0) FillTrackSpy("TrkNegMth",true);
+       else FillTrackSpy("TrkPosMth",true);
+      } else {
+        FillCandidateSpy("RecUNMth",true);
+       if(fPostMatched<0) {
+         fDecayIDneg = iT->GetID();
+         fDecayIDpos = jT->GetID();
+         MakeTrack();
+       }
+        LoadTrack(&ieT,iT->Chi2perNDF());
+       fDaughterMatchPhi=mcpos->Phi();
+       fDaughterMatchEta=mcpos->Eta();
+       fDaughterMatchPt=mcpos->Pt();
+        ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+        fDaughterImpactParameterXY = ip[0];
+        fDaughterImpactParameterZ = ip[1];
+        FillTrackSpy("TrkUNMth",true);
+        LoadTrack(&jeT,jT->Chi2perNDF());
+       fDaughterMatchPhi=mcneg->Phi();
+       fDaughterMatchEta=mcneg->Eta();
+       fDaughterMatchPt=mcneg->Pt();
+        jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+        fDaughterImpactParameterXY = ip[0];
+        fDaughterImpactParameterZ = ip[1];
+        FillTrackSpy("TrkUNMth",true);
       }
       if(feeddown) {
-        FillCandidateSpy("MthFDW");
-        ((TH2D*)((TList*)fList->FindObject("MthFDW"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );
-        ((TH1D*)((TList*)fList->FindObject("MthFDW"))->FindObject("MCOrigin"))->Fill( rOri );
+        FillCandidateSpy("MthFDW",true);
       }
     }
     //===== END OF MCMATCH
@@ -1474,6 +1574,10 @@ void AliAnalysisTaskFlowStrange::MakeQVectors() {
   //=>loading event
   MakeQVZE(InputEvent(),vzeqax,vzeqay,vzeqaw,vzeqbx,vzeqby,vzeqbw);
   MakeQTPC(InputEvent(),tpcqax,tpcqay,tpcqaw,tpcqbx,tpcqby,tpcqbw);
+  if(fReadMC) {
+    fVZEevent->SetMCReactionPlaneAngle( fMCEP );    
+    fTPCevent->SetMCReactionPlaneAngle( fMCEP );    
+  }
   //=>computing psi
   //VZERO
   Double_t vqx, vqy;
@@ -1511,11 +1615,13 @@ void AliAnalysisTaskFlowStrange::MakeQVectors() {
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIA"))->Fill( psivzea );
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIB"))->Fill( psivzeb );
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPVZE"))->Fill( vzew );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("QmVZE"))->Fill( TMath::Sqrt(vqx*vqx+vqy*vqy)/vzew );
   //------
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSI"))->Fill( psitpc );
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIA"))->Fill( psitpca );
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIB"))->Fill( psitpcb );
   ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPTPC"))->Fill( tpcw );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("QmTPC"))->Fill( TMath::Sqrt(tqx*tqx+tqy*tqy)/tpcw );
   //------
   ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 1., tpcqay/tpcqaw, tpcqaw );
   ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 2., tpcqax/tpcqaw, tpcqaw );
@@ -1742,7 +1848,7 @@ void AliAnalysisTaskFlowStrange::MakeQTPC(AliAODEvent *tAOD,
     eta = track->Eta();
     w = 1;
     //=>subevents
-    if(eta<0) {
+    if(eta<0.5*(fRFPminEta+fRFPmaxEta)) {
       qxa += w*TMath::Cos(2*phi);
       qya += w*TMath::Sin(2*phi);
       qwa += w;
@@ -1802,11 +1908,13 @@ void AliAnalysisTaskFlowStrange::MakeQTPC(AliESDEvent *tESD,
 void AliAnalysisTaskFlowStrange::AddMCParticleSpy(TList *me) {
   TH1D *tH1D;
   TH2D *tH2D;
+  TProfile *tPro;
   tH1D = new TH1D("Pt",   "Pt",   100,0.0,20);  me->Add(tH1D);
   tH1D = new TH1D("Phi",  "Phi",  100,0,TMath::TwoPi()); me->Add(tH1D);
   tH1D = new TH1D("Eta",  "Eta",  100,-1,+1);   me->Add(tH1D);
   tH1D = new TH1D("Rad2", "Rad2", 1000,0,+100); me->Add(tH1D);
   tH2D = new TH2D("Dphi", "phi-MCEP;pt;dphi",100,0,20, 72,0,TMath::Pi()); me->Add(tH2D);
+  tPro = new TProfile("Cos2dphi","Cos2dphi",100,0,20); me->Add(tPro);
   return;
 }
 //=======================================================================
@@ -1817,6 +1925,7 @@ void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, AliAODMCPar
   ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Rad2" ))->Fill( TMath::Sqrt( p->Xv()*p->Xv() +
                                                                                                 p->Yv()*p->Yv() ) );
   ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Dphi" ))->Fill( p->Pt(), GetMCDPHI(p->Phi()) );
+  ((TProfile*)((TList*)fList->FindObject(listName.Data()))->FindObject("Cos2dphi" ))->Fill( p->Pt(), TMath::Cos( 2*GetMCDPHI(p->Phi()) ), 1 );
   return;
 }
 //=======================================================================
@@ -1836,8 +1945,11 @@ void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, TParticle *
   return;
 }
 //=======================================================================
-void AliAnalysisTaskFlowStrange::AddCandidatesSpy(TList *me) {
+void AliAnalysisTaskFlowStrange::AddCandidatesSpy(TList *me,Bool_t res) {
+  TH1D *tH1D;
   TH2D *tH2D;
+  TProfile *tPro;
+  TProfile2D *tPro2;
   tH2D = new TH2D("PhiEta",  "PhiEta;Phi;Eta", 100,0,TMath::TwoPi(),100,-1,+1); me->Add(tH2D);
   tH2D = new TH2D("PtRAP",   "PtRAP;Pt;Y",          100,0,20,100,-2.0,+2.0);  me->Add(tH2D);
   tH2D = new TH2D("PtDCA",   "PtDCA;Pt;DCA",        100,0,20,100,0,10);       me->Add(tH2D);
@@ -1850,11 +1962,24 @@ void AliAnalysisTaskFlowStrange::AddCandidatesSpy(TList *me) {
   tH2D = new TH2D("APPOS",   "APPOS;alphaPOS;QtPOS",100,-2,+2,100,0,0.3);     me->Add(tH2D);
   tH2D = new TH2D("D0PD0N",  "D0PD0N;D0P;D0N",      200,-10,+10,200,-10,+10); me->Add(tH2D);
   tH2D = new TH2D("XPOSXNEG","XPOSXNEG;XPOS;XNEG",  200,-50,+50,200,-50,+50); me->Add(tH2D);
-  tH2D = new TH2D("PTDPHIMC","PtDPHIMC;Pt;PHI-MCEP",100,0,20,72,0,TMath::Pi()); me->Add(tH2D);
+
+  if(fReadMC) {
+    if(res) {
+      tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,50); me->Add(tH1D);
+      tH2D = new TH2D("PHIRes","PHIRes;PHI;MC-DAT", 72,   0, TMath::TwoPi(),100,-0.12,+0.12); me->Add(tH2D);
+      tH2D = new TH2D("ETARes","ETARes;ETA;MC-DAT", 16,-0.8,           +0.8,100,-0.2,+0.2);   me->Add(tH2D);
+      tH2D = new TH2D("PTRes", "PTRes;Pt;MC-DAT",  100,   0,             20,100,-0.4,+0.4);   me->Add(tH2D);
+      tH2D = new TH2D("RXYRes","RXYRes;RXY;MC-DAT",100,   0,             50,100,-4.0,+4.0);   me->Add(tH2D);
+    }
+    tH2D = new TH2D("PTDPHIMC","PtDPHIMC;Pt;PHI-MCEP",100,0,20,72,0,TMath::Pi()); me->Add(tH2D);
+    tPro = new TProfile("Cos2dphiMC",  "Cos2dphiMC",100,0,20); me->Add(tPro);
+    tPro = new TProfile("Cos2dphiMCPK","Cos2dphiMC PK",100,0,20); me->Add(tPro);
+    tPro2=new TProfile2D("C2DPHIMCMASS","C2DPHIMCMASS",100,0,20,fMassBins,fMinMass,fMaxMass); me->Add(tPro2);
+  }
   return;
 }
 //=======================================================================
-void AliAnalysisTaskFlowStrange::FillCandidateSpy(TString listName) {
+void AliAnalysisTaskFlowStrange::FillCandidateSpy(TString listName, Bool_t fillRes) {
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PhiEta"))->Fill( fDecayPhi, fDecayEta );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtRAP" ))->Fill( fDecayPt, fDecayRapidity );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDCA" ))->Fill( fDecayPt, fDecayDCAdaughters );
@@ -1864,7 +1989,23 @@ void AliAnalysisTaskFlowStrange::FillCandidateSpy(TString listName) {
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDL"  ))->Fill( fDecayPt, fDecayDecayLength );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtMASS"))->Fill( fDecayPt, fDecayMass );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("APPOS" ))->Fill( fDecayAlpha, fDecayQt );
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTDPHIMC" ))->Fill( fDecayPt, GetMCDPHI( fDecayPhi ) );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("D0PD0N"))->Fill( fDecayIPpos, fDecayIPneg );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("XPOSXNEG"))->Fill( fDecayXpos, fDecayXneg );
+  if(fReadMC) {
+    ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTDPHIMC" ))->Fill( fDecayPt, GetMCDPHI( fDecayPhi ) );
+    ((TProfile*)((TList*)fList->FindObject(listName.Data()))->FindObject("Cos2dphiMC" ))->Fill( fDecayPt, TMath::Cos( 2*GetMCDPHI(fDecayPhi) ), 1 );
+    if( fDecayMass>fMinMassX && fDecayMass<fMaxMassX ) {
+      ((TProfile*)((TList*)fList->FindObject(listName.Data()))->FindObject("Cos2dphiMCPK" ))->Fill( fDecayPt, TMath::Cos( 2*GetMCDPHI(fDecayPhi) ), 1 );
+    }
+    ((TProfile2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("C2DPHIMCMASS" ))->Fill(fDecayPt,fDecayMass,TMath::Cos(2*GetMCDPHI(fDecayPhi)), 1 );
+    if(fillRes) {
+      ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("MCOrigin"))->Fill( fDecayMatchOrigin );
+      ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PHIRes"))->Fill( fDecayPhi, fDecayMatchPhi-fDecayPhi );
+      ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("ETARes"))->Fill( fDecayEta, fDecayMatchEta-fDecayEta );
+      ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTRes"))->Fill( fDecayPt, fDecayMatchPt-fDecayPt );
+      ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("RXYRes"))->Fill( fDecayRadXY, fDecayMatchRadXY-fDecayRadXY );
+    }
+  }
 }
 //=======================================================================
 Bool_t AliAnalysisTaskFlowStrange::AcceptCandidate() {
@@ -1875,7 +2016,6 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptCandidate() {
   if(fDecayDCAdaughters>fDecayMaxDCAdaughters) return kFALSE;
   if(fDecayCosinePointingAngleXY<fDecayMinCosinePointingAngleXY) return kFALSE;
   if(fDecayRadXY<fDecayMinRadXY) return kFALSE;
-  if(fDecayDecayLength>fDecayMaxDecayLength*2.6842) return kFALSE;
   if(TMath::Abs(fDecayRapidity)>fDecayMaxRapidity) return kFALSE;
   if(fSpecie==0) {
     if(fDecayAPCutPie) {
@@ -1883,37 +2023,67 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptCandidate() {
     } else {
       if(fDecayQt<fDecayMinQt) return kFALSE;
     }
+    if(fDecayDecayLength>fDecayMaxDecayLength*2.6842) return kFALSE;
+  } else {
+    if(fDecayDecayLength>fDecayMaxDecayLength*7.89) return kFALSE;
   }
   if(fSpecie==1) if(fDecayAlpha>0) return kFALSE;
   if(fSpecie==2) if(fDecayAlpha<0) return kFALSE;
   return kTRUE;
 }
 //=======================================================================
-void AliAnalysisTaskFlowStrange::AddTracksSpy(TList *me) {
+void AliAnalysisTaskFlowStrange::AddTracksSpy(TList *me,Bool_t res) {
   TH2D *tH2D;
   tH2D = new TH2D("PHIETA",       "PHIETA;PHI;ETA",               100,0,TMath::TwoPi(),100,-2,2); me->Add(tH2D);
   tH2D = new TH2D("IPXYIPZ",      "IPXYIPZ;IPXY;IPZ",             1000,-20,+20,1000,-20,+20); me->Add(tH2D);
   tH2D = new TH2D("PTTPCNCLS",    "PTTPCNCLS;PT;NCLS",            100,0,20,170,0,170);  me->Add(tH2D);
+  tH2D = new TH2D("PTITSLAY",     "PTITSLAY;PT;ITSLAYER",         100,0,20,6,-0.5,+5.5);me->Add(tH2D);
+  tH2D = new TH2D("PTITSTPCrefit","PTITSTPCrefit;PT",             100,0,20,2,-0.5,+1.5);me->Add(tH2D);
+  tH2D->GetYaxis()->SetBinLabel(1,"ITS refit");
+  tH2D->GetYaxis()->SetBinLabel(2,"TPC refit");
+
   tH2D = new TH2D("POSTPCNCLCHI2","POSTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);
   tH2D = new TH2D("POSTPCNFCLNXR","POSTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);
   tH2D = new TH2D("POSTPCNCLNFCL","POSTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);
   tH2D = new TH2D("POSTPCNCLNSCL","POSTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);
+
   tH2D = new TH2D("NEGTPCNCLCHI2","NEGTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);
   tH2D = new TH2D("NEGTPCNFCLNXR","NEGTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);
   tH2D = new TH2D("NEGTPCNCLNFCL","NEGTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);
   tH2D = new TH2D("NEGTPCNCLNSCL","NEGTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);
+
+  if(res) {
+    tH2D = new TH2D("PHIRes", "PHIRes;PHI;MC-DAT",   72,   0, TMath::TwoPi(),100,-0.12,+0.12); me->Add(tH2D);
+    tH2D = new TH2D("ETARes", "ETARes;ETA;MC-DAT",   16,-0.8,           +0.8,100,-0.2,+0.2);   me->Add(tH2D);
+    tH2D = new TH2D("PTRes",  "PTRes;Pt;MC-DAT",    100,   0,             20,100,-0.4,+0.4);   me->Add(tH2D);
+  }
 }
 //=======================================================================
-void AliAnalysisTaskFlowStrange::FillTrackSpy(TString listName) {
+void AliAnalysisTaskFlowStrange::FillTrackSpy(TString listName,Bool_t res) {
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PHIETA" ))->Fill( fDaughterPhi, fDaughterEta );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "IPXYIPZ" ))->Fill( fDaughterImpactParameterXY, fDaughterImpactParameterZ );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTTPCNCLS" ))->Fill( fDaughterPt, fDaughterNClsTPC );
+  if( TESTBIT(fDaughterITScm,0) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 0 );
+  if( TESTBIT(fDaughterITScm,1) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 1 );
+  if( TESTBIT(fDaughterITScm,2) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 2 );
+  if( TESTBIT(fDaughterITScm,3) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 3 );
+  if( TESTBIT(fDaughterITScm,4) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 4 );
+  if( TESTBIT(fDaughterITScm,5) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSLAY" ))->Fill( fDaughterPt, 5 );
+  if( (fDaughterStatus&AliESDtrack::kITSrefit) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSTPCrefit" ))->Fill( fDaughterPt, 0 );
+  if( (fDaughterStatus&AliESDtrack::kTPCrefit) ) ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTITSTPCrefit" ))->Fill( fDaughterPt, 1 );
+
   TString ch="NEG";
   if(fDaughterCharge>0) ch="POS";
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLCHI2",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterChi2PerNClsTPC );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNFCLNXR",ch.Data()) ))->Fill( fDaughterNFClsTPC, fDaughterXRows );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNFCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNFClsTPC );
   ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNSCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNSClsTPC );
+
+  if(res) {
+    ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PHIRes"))->Fill( fDaughterPhi, fDaughterMatchPhi-fDaughterPhi );
+    ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("ETARes"))->Fill( fDaughterEta, fDaughterMatchEta-fDaughterEta );
+    ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTRes"))->Fill( fDaughterPt, fDaughterMatchPt-fDaughterPt );
+  }
 }
 //=======================================================================
 void AliAnalysisTaskFlowStrange::LoadTrack(AliESDtrack *myTrack, Double_t aodChi2NDF) {
@@ -1929,6 +2099,7 @@ void AliAnalysisTaskFlowStrange::LoadTrack(AliESDtrack *myTrack, Double_t aodChi
   }
   myTrack->GetImpactParameters(fDaughterImpactParameterXY,fDaughterImpactParameterZ);
   fDaughterStatus = myTrack->GetStatus();
+  fDaughterITScm = myTrack->GetITSClusterMap();
   fDaughterPhi = myTrack->Phi();
   fDaughterEta = myTrack->Eta();
   fDaughterPt = myTrack->Pt();
@@ -1947,6 +2118,14 @@ Bool_t AliAnalysisTaskFlowStrange::AcceptDaughter() {
   if(fDaughterChi2PerNClsTPC>fDaughterMaxChi2PerNClsTPC) return kFALSE;
   if(TMath::Abs(fDaughterImpactParameterXY)<fDaughterMinImpactParameterXY) return kFALSE;
   if(fDaughterXRows<fDaughterMinXRowsOverNClsFTPC*fDaughterNFClsTPC) return kFALSE;
+  for(Int_t lay=0; lay!=6; ++lay)
+    if(fDaughterITSConfig[lay]>-0.5) {
+      if(fDaughterITSConfig[lay]) {
+       if(!TESTBIT(fDaughterITScm,lay)) return kFALSE;
+      } else {
+       if(TESTBIT(fDaughterITScm,lay)) return kFALSE;
+      }
+    }
   return kTRUE;
 }
 //=======================================================================
index 1540aad91f6ce13f9e36e86bf0f1676b787d4dec..05e485efc2c3360742656b22636b2810ccc0d0f8 100644 (file)
@@ -57,11 +57,13 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   void SetCentralityRange(TString val, Int_t m, Int_t M) {fCentMethod=val; fCentPerMin=m; fCentPerMax=M;}
   void SetReadESD(Bool_t val) {fReadESD=val;}
   void SetReadMC(Bool_t val) {fReadMC=val;}
+  void SetPostMatched(Int_t val) {fPostMatched=val;}
   void SetAvoidExec(Bool_t val) {fAvoidExec=val;}
   void SetSkipSelection(Bool_t val) {fSkipSelection=val;}
   void SetSkipFlow(Bool_t val) {fSkipFlow=val;}
   void SetUseFlowPackage(Bool_t val) {fUseFP=val;}
   void SetExtraEventRejection(Bool_t val) {fExtraEventRejection=val;}
+  void SetVertexZcut(Double_t val) {fVertexZcut=val;}
 
   void SetWhichPsi(Int_t val) {fWhichPsi=val;}
   void SetStoreVZEResponse(Bool_t val) {fVZEsave=val;}
@@ -82,6 +84,7 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   void SetDauMinXRows(Int_t val) {fDaughterMinXRows=val;}
   void SetDauMaxChi2PerNClsTPC(Double_t val) {fDaughterMaxChi2PerNClsTPC=val;}
   void SetDauMinXRowsOverNClsFTPC(Double_t val) {fDaughterMinXRowsOverNClsFTPC=val;}
+  void SetDauITSLayer(Int_t layer, Int_t config) {fDaughterITSConfig[layer]=config;}
   void SetDauMinEta(Double_t val) {fDaughterMinEta=val;}
   void SetDauMaxEta(Double_t val) {fDaughterMaxEta=val;}
   void SetDauMinPt(Double_t val) {fDaughterMinPt=val;}
@@ -110,7 +113,7 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Bool_t CalibrateEvent();
   void Publish();
   
-  void AddEventSpy();
+  void AddEventSpy(TString name);
   Bool_t AcceptAAEvent(AliESDEvent *tESD);
   Bool_t AcceptAAEvent(AliAODEvent *tAOD);
   Bool_t AcceptPPEvent(AliAODEvent *tAOD);
@@ -151,11 +154,11 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   void FillMCParticleSpy(TString listName, AliAODMCParticle *par);
   void FillMCParticleSpy(TString listName, TParticle *par);
 
-  void AddCandidatesSpy(TList *val);
-  void FillCandidateSpy(TString listName);
+  void AddCandidatesSpy(TList *val, Bool_t fillRes=kFALSE);
+  void FillCandidateSpy(TString listName, Bool_t fillRes=kFALSE);
 
-  void AddTracksSpy(TList *val);
-  void FillTrackSpy(TString listName);
+  void AddTracksSpy(TList *val, Bool_t fillRes=kFALSE);
+  void FillTrackSpy(TString listName, Bool_t fillRes=kFALSE);
 
   void MakeFilterBits();
   Bool_t PassesFilterBit(AliESDtrack *me);
@@ -197,6 +200,7 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
 
   Bool_t fReadESD;       // move back to ESD
   Bool_t fReadMC;        // read MC files
+  Int_t fPostMatched;    // post only (un)matched particles
   Bool_t fAvoidExec;     // avoids Exec
   Bool_t fSkipSelection; // skip decay finder
   Bool_t fSkipFlow;      // skip flow-wise code
@@ -210,6 +214,8 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Int_t    fCentPerMax; // CC
   Double_t fThisCent;   // CC
 
+  Double_t fVertexZcut; // cut on main vertex Z
+
   Bool_t fExcludeTPCEdges; // exclude TPC edges from single track selection
 
   Int_t  fSpecie;   // K0=>0 L0=>1
@@ -235,6 +241,8 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Int_t    fMassBins; // opens
   Double_t fMinMass;  // mass
   Double_t fMaxMass;  // window
+  Double_t fMinMassX; // HP window
+  Double_t fMaxMassX; // HP window
 
   Int_t fRFPFilterBit;    // RFP TPC
   Double_t fRFPminPt;     // RFP TPC
@@ -258,10 +266,20 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Double_t fDecayAlpha;                 // DECAY
   Double_t fDecayRapidity;              // DECAY
   Double_t fDecayProductIPXY;           // DECAY
+  Double_t fDecayIPneg;                 // DECAY
+  Double_t fDecayIPpos;                 // DECAY
+  Double_t fDecayXneg;                  // DECAY
+  Double_t fDecayXpos;                  // DECAY
   Int_t    fDecayIDneg;                 // DECAY
   Int_t    fDecayIDpos;                 // DECAY
   Int_t    fDecayID;                    // DECAY
 
+  Double_t fDecayMatchOrigin;  // MC DECAY
+  Double_t fDecayMatchPhi;     // MC DECAY
+  Double_t fDecayMatchEta;     // MC DECAY
+  Double_t fDecayMatchPt;      // MC DECAY
+  Double_t fDecayMatchRadXY;   // MC DECAY
+
   Double_t fDecayMinEta;                   // DECAY CUTS
   Double_t fDecayMaxEta;                   // DECAY CUTS
   Double_t fDecayMinPt;                    // DECAY CUTS
@@ -278,6 +296,7 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Double_t fDaughterEta;               // DAUGHTER
   Double_t fDaughterPt;                // DAUGHTER
   Int_t    fDaughterNClsTPC;           // DAUGHTER
+  Int_t    fDaughterITSConfig[6];      // DAUGHTER
   Int_t    fDaughterCharge;            // DAUGHTER
   Int_t    fDaughterNFClsTPC;          // DAUGHTER
   Int_t    fDaughterNSClsTPC;          // DAUGHTER
@@ -286,9 +305,16 @@ class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
   Float_t  fDaughterImpactParameterXY; // DAUGHTER
   Float_t  fDaughterImpactParameterZ;  // DAUGHTER
   UInt_t   fDaughterStatus;            // DAUGHTER
+  UChar_t  fDaughterITScm;             // DAUGHTER
   Double_t fDaughterNSigmaPID;         // DAUGHTER
   Int_t    fDaughterKinkIndex;         // DAUGHTER
 
+  Double_t fDaughterMatchPhi;               // MC DAUGHTER
+  Double_t fDaughterMatchEta;               // MC DAUGHTER
+  Double_t fDaughterMatchPt;                // MC DAUGHTER
+  Float_t  fDaughterMatchImpactParameterXY; // MC DAUGHTER
+  Float_t  fDaughterMatchImpactParameterZ;  // MC DAUGHTER
+
   Bool_t   fDaughterUnTag;             // UNTAG PROCEDURE
 
   Double_t fDaughterMinEta;               // DAUGHTER CUTS
index 09c88e50d8dcd517c3319fae73888b885b7be248..b00b66102253b45145ff726f707d9170c3cb5422 100644 (file)
 // new in this version (use with caution): vzero event plane, event mixing
 
 #include "TChain.h"
-#include "TTree.h"
 #include "TH1.h"
 #include "TH1F.h"
 #include "TH2F.h"
-#include "TCanvas.h"
 #include "TMath.h"
 #include "TObjArray.h"
-#include "AliAnalysisTask.h"
 #include "AliAnalysisTaskSE.h"
 #include "AliAnalysisManager.h"
-#include "AliESDEvent.h"
 #include "AliAODEvent.h"
-#include "AliESDInputHandler.h"
 #include "AliAODInputHandler.h"
 #include "AliCentrality.h"
-#include "AliVEvent.h"
 #include "AliAnalysisTaskPhiFlow.h"
 #include "AliFlowBayesianPID.h"
-#include "AliStack.h"
-#include "AliESDtrackCuts.h"
+#include "AliPIDCombined.h"
 #include "AliMCEvent.h"
 #include "TProfile.h"
 #include "AliFlowCandidateTrack.h"
@@ -49,9 +42,7 @@
 #include "AliFlowCommonConstants.h"
 #include "AliFlowEvent.h"
 #include "TVector3.h"
-#include "AliESDVZERO.h"
 #include "AliAODVZERO.h"
-#include "AliPID.h"
 #include "AliPIDResponse.h"
 #include "AliAODMCParticle.h"
 #include "AliAnalysisTaskVnV0.h"
@@ -66,7 +57,7 @@ ClassImp(AliAnalysisTaskPhiFlow)
 ClassImp(AliPhiMesonHelperTrack)
 
 AliAnalysisTaskPhiFlow::AliAnalysisTaskPhiFlow() : AliAnalysisTaskSE(),
-   fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fAODAnalysis(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fOldTrackParam(0), fRequireTPCStandAlone(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fNPtBins(18), fCentrality(999), fVertex(999), fESD(0), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0),fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fPOICuts(0), fVertexRange(0), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0), fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0), fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0)
+   fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fNPtBins(18), fCentrality(999), fVertex(999), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0),fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fPOICuts(0), fVertexRange(0), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0)/*, fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0)*/, fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0), fSkipEventSelection(0), fUsePidResponse(0), fPIDCombined(0)
 {
    // Default constructor
    for(Int_t i(0); i < 7; i++) fPIDConfig[i] = 0.;
@@ -83,7 +74,7 @@ AliAnalysisTaskPhiFlow::AliAnalysisTaskPhiFlow() : AliAnalysisTaskSE(),
 }
 //_____________________________________________________________________________
 AliAnalysisTaskPhiFlow::AliAnalysisTaskPhiFlow(const char *name) : AliAnalysisTaskSE(name),
-   fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fAODAnalysis(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fOldTrackParam(0), fRequireTPCStandAlone(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fNPtBins(18), fCentrality(999), fVertex(999), fESD(0), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0), fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fPOICuts(0), fVertexRange(0), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0), fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0), fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0)
+   fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fNPtBins(18), fCentrality(999), fVertex(999), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0), fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fPOICuts(0), fVertexRange(0), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0)/*, fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0)*/, fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0), fSkipEventSelection(0), fUsePidResponse(0), fPIDCombined(0)
 {
    // Constructor
    for(Int_t i(0); i < 7; i++) fPIDConfig[i] = 0.;
@@ -112,6 +103,7 @@ AliAnalysisTaskPhiFlow::~AliAnalysisTaskPhiFlow()
    if (fFlowEvent) delete fFlowEvent;
    if (fBayesianResponse) delete fBayesianResponse;
    if (fEventMixing) delete fPoolManager;
+   if (fPIDCombined) delete fPIDCombined;
    if (fDebug > 0) cout << " === Deleted instance of AliAnalysisTaskPhiFlow === " << endl;
 }
 //_____________________________________________________________________________
@@ -255,6 +247,13 @@ void AliAnalysisTaskPhiFlow::UserCreateOutputObjects()
    if(fDebug > 0) cout << " *** UserCreateOutputObjects() *** " << endl;
    fNullCuts = new AliFlowTrackCuts("null_cuts");
    fBayesianResponse = new AliFlowBayesianPID();
+      // combined pid
+   fPIDCombined = new AliPIDCombined;
+   fPIDCombined->SetDefaultTPCPriors();
+   fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
+
+   // flag to mc
+   if(fSkipEventSelection || fIsMC) fBayesianResponse->SetMC(kTRUE);
    Double_t t(0);
    for(Int_t i = 0; i < 7; i++) t+=TMath::Abs(fPIDConfig[i]);
    if(t < 0.1) AliFatal("No valid PID procedure recognized -- terminating analysis !!!");
@@ -266,7 +265,7 @@ void AliAnalysisTaskPhiFlow::UserCreateOutputObjects()
    cc->SetNbinsMass(fMassBins);  cc->SetNbinsEta(200);           (fMassBins == 1) ? cc->SetNbinsPt(15) : cc->SetNbinsPt(100); // high pt
    cc->SetMassMin(fMinMass);     cc->SetEtaMin(-5.0);            cc->SetPtMin(0);
    cc->SetMassMax(fMaxMass);     cc->SetEtaMax(+5.0);            (fMassBins == 1) ? cc->SetPtMax(15) : cc->SetPtMax(10); // high pt
-   if (!fOldTrackParam) fBayesianResponse->SetNewTrackParam();
+   fBayesianResponse->SetNewTrackParam();
    AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
    if (man) {
       AliInputEventHandler* inputHandler = (AliInputEventHandler*)(man->GetInputEventHandler());
@@ -324,6 +323,7 @@ template <typename T> Double_t AliAnalysisTaskPhiFlow::InvariantMass(const T* tr
    return TMath::Sqrt((es - (pxs + pys + pzs)));
 }
 //_____________________________________________________________________________
+/*
 template <typename T> Double_t AliAnalysisTaskPhiFlow::DeltaDipAngle(const T* track1, const T* track2) const
 {
    // Calculate the delta dip angle between two particles
@@ -339,6 +339,7 @@ template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckDeltaDipAngle(const T*
    if ((TMath::Abs(DeltaDipAngle(track1, track2)) < fDeltaDipAngle) && (PhiPt(track1, track2) < fDeltaDipPt)) return kFALSE;
    return kTRUE;
 }
+*/
 //_____________________________________________________________________________
 template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckCandidateEtaPtCut(const T* track1, const T* track2) const
 {
@@ -357,6 +358,7 @@ template <typename T> Bool_t AliAnalysisTaskPhiFlow::EventCut(T* event)
    // Impose event cuts
    if(fDebug > 0) cout << " *** EventCut() *** " << endl;
    if (!event) return kFALSE;
+   if (fSkipEventSelection) return kTRUE;
    if (!CheckVertex(event)) return kFALSE;
    if (!CheckCentrality(event)) return kFALSE;
    if(fQA) PlotMultiplcities(event);
@@ -522,7 +524,11 @@ Bool_t AliAnalysisTaskPhiFlow::IsKaon(AliAODTrack* track) const
 {
    // Kaon identification routine, based on multiple detectors and approaches
    if(fDebug > 1) cout << " *** IsKaon() *** " << endl;
-   if(fRequireTPCStandAlone && (!track->TestFilterBit(1))) return kFALSE;
+   if(fUsePidResponse) {
+       Double_t prob[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+       fPIDCombined->ComputeProbabilities(track, fPIDResponse, prob);
+       if(prob[3] > fPIDConfig[6])  return kTRUE;
+   }
    if(!PassesDCACut(track)) return kFALSE;
    if(fQA) {fNOPID->Fill(track->P(), track->GetTPCsignal());fNOPIDTOF->Fill(track->P(), track->GetTOFsignal());}
    if(track->Pt() < fPIDConfig[1]) {
@@ -699,7 +705,6 @@ void AliAnalysisTaskPhiFlow::UserExec(Option_t *)
    }
    fAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // check for aod data type
    if (fAOD) {
-      fAODAnalysis = kTRUE;
       if (!EventCut(fAOD)) return; // check for event cuts
       InitializeBayesianPID(fAOD); // init event objects
       SetNullCuts(fAOD);
@@ -737,7 +742,7 @@ void AliAnalysisTaskPhiFlow::UserExec(Option_t *)
       }
       for (Int_t pTracks = 0; pTracks < unp ; pTracks++) { // perform analysis
          for (Int_t nTracks = 0; nTracks < unn ; nTracks++) {
-            if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], un[nTracks]))) continue;
+//            if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], un[nTracks]))) continue;
             if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(up[pTracks], un[nTracks]))) continue;
             PtSelector(0, up[pTracks], un[nTracks]);
             Double_t pt = PhiPt(up[pTracks], un[nTracks]);
@@ -780,14 +785,14 @@ void AliAnalysisTaskPhiFlow::UserExec(Option_t *)
       if(!fEventMixing) { // combinatorial background
           for (Int_t pTracks = 0; pTracks < unp ; pTracks++) {
              for (Int_t nTracks = pTracks + 1; nTracks < unp ; nTracks++) {
-                if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], up[nTracks]))) continue;
+//                if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], up[nTracks]))) continue;
                 if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(up[pTracks], up[nTracks]))) continue;
                 PtSelector(1, up[pTracks], up[nTracks]);
              }
           }
           for (Int_t nTracks = 0; nTracks < unn ; nTracks++) {
              for (Int_t pTracks = nTracks + 1; pTracks < unn ; pTracks++) {
-                if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(un[nTracks], un[pTracks]))) continue;
+//                if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(un[nTracks], un[pTracks]))) continue;
                 if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(un[nTracks], un[pTracks]))) continue;
                 PtSelector(2, un[nTracks], un[pTracks]);
              }
@@ -797,7 +802,14 @@ void AliAnalysisTaskPhiFlow::UserExec(Option_t *)
       PostData(1, fOutputList);
       PostData(2, fFlowEvent);
    }
-   if (fESD) AliFatal(" ESD analysis no longer supported ! " );
+}
+//_____________________________________________________________________________
+void AliAnalysisTaskPhiFlow::Exec(Option_t* c)
+{
+    // skip the event selection for SE task (e.g. for MC productions)
+    if(fSkipEventSelection) AliAnalysisTaskPhiFlow::UserExec(c);
+    // exec of task se will do event selection and call UserExec 
+    else AliAnalysisTaskSE::Exec(c);
 }
 //_____________________________________________________________________________
 void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCandidates) const
@@ -852,7 +864,7 @@ void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCand
                 if(!fTypeMixing) { // mix with like-sign kaons
                     for(Int_t pBuf = 0; pBuf < buffer_unp; pBuf++) {
                         if(fDebug > 1 ) cout << Form(" buffered k+ track %d", pBuf) << endl;
-                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_up[pBuf]))) continue;
+//                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_up[pBuf]))) continue;
                         if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_up[pMix], buffer_up[pBuf]))) continue;
                         PtSelector(1, mix_up[pMix], buffer_up[pBuf]);
                     }
@@ -860,7 +872,7 @@ void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCand
                 else if(fTypeMixing) { // mix with unlike-sign kaons
                     for(Int_t nBuf = 0; nBuf < buffer_unn; nBuf++) {
                         if(fDebug > 1 ) cout << Form(" buffered k- track %d", nBuf) << endl;
-                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_un[nBuf]))) continue;
+//                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_un[nBuf]))) continue;
                         if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_up[pMix], buffer_un[nBuf]))) continue;
                         PtSelector(2, mix_up[pMix], buffer_un[nBuf]);
                     }
@@ -871,7 +883,7 @@ void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCand
                 if(!fTypeMixing) { // mix with like-sign kaons
                     for(Int_t nBuf = 0; nBuf < buffer_unn; nBuf++) {
                         if(fDebug > 1 ) cout << Form(" buffered k- track %d", nBuf) << endl;
-                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_un[nBuf]))) continue;
+//                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_un[nBuf]))) continue;
                         if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_un[nMix], buffer_un[nBuf]))) continue;
                         PtSelector(2, mix_un[nMix], buffer_un[nBuf]);
                     }
@@ -879,7 +891,7 @@ void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCand
                 else if(fTypeMixing) { // mix with unlike-sign kaons
                     for(Int_t pBuf = 0; pBuf < buffer_unp; pBuf++) {
                         if(fDebug > 1 ) cout << Form(" buffered k+ track %d", pBuf) << endl;
-                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_up[pBuf]))) continue;
+//                        if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_up[pBuf]))) continue;
                         if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_un[nMix], buffer_up[pBuf]))) continue;
                         PtSelector(1, mix_un[nMix], buffer_up[pBuf]);
                     }
index 64937e27090532e231d26ea39bb4d9c3b3bcde03..89992e20884734893d44fd266c3056def791f6dd 100644 (file)
@@ -19,6 +19,7 @@ class AliFlowEvent;
 class AliFlowCandidateTrack;
 class AliFlowBayesianPID;
 class AliEventPoolManager;
+class AliPIDCombined;
 
 #include "AliAnalysisTaskSE.h"
 
@@ -67,8 +68,8 @@ public:
    AliEventPoolManager*                 InitializeEventMixing();
    void                                 SetPtBins(Float_t bin[19], Int_t n) { for(Int_t i = 0; i < n+1; i++) fPtBins[i] = bin[i]; fNPtBins = n; }
    template <typename T> Double_t       InvariantMass(const T* track1, const T* track2) const;
-   template <typename T> Double_t       DeltaDipAngle(const T* track1, const T* track2) const;
-   template <typename T> Bool_t         CheckDeltaDipAngle(const T* track1, const T* track2) const;
+//   template <typename T> Double_t       DeltaDipAngle(const T* track1, const T* track2) const;
+//   template <typename T> Bool_t         CheckDeltaDipAngle(const T* track1, const T* track2) const;
    template <typename T> Bool_t         CheckCandidateEtaPtCut(const T* track1, const T* track2) const;
    void                                 SetCentralityParameters(Double_t min, Double_t max, const char* a, const char* b, Bool_t c, Bool_t d) { 
                                                                                           fCentralityMin = min; 
@@ -77,16 +78,17 @@ public:
                                                                                           fkCentralityMethodB = b;
                                                                                           fCentralityCut2010 = c; 
                                                                                           fCentralityCut2011 = d;}
+   void                                 SetCurrentCentralityBin(Double_t c) {fCentrality = c; }
    Double_t                             GetCenMin() const {return fCentralityMin; }
    Double_t                             GetCenMax() const {return fCentralityMax; }
    const char*                          GetCentralityMethod() const {return fkCentralityMethodA; }
    void                                 SetVertexZ(Float_t z) { fVertexRange = z; }
    Float_t                              GetVertexZ() const { return fVertexRange; }
-   void                                 SetMaxDeltaDipAngleAndPt(Float_t a, Float_t pt) { fDeltaDipAngle = a;
-                                                                                          fDeltaDipPt = pt;
-                                                                                          fApplyDeltaDipCut = kTRUE; };
-   Float_t                              GetDeltaDipAngle() const {return fDeltaDipAngle; }
-   Float_t                              GetDeltaDipPt() const {return fDeltaDipPt; }
+//   void                                 SetMaxDeltaDipAngleAndPt(Float_t a, Float_t pt) { fDeltaDipAngle = a;
+//                                                                                          fDeltaDipPt = pt;
+//                                                                                          fApplyDeltaDipCut = kTRUE; };
+//   Float_t                              GetDeltaDipAngle() const {return fDeltaDipAngle; }
+//   Float_t                              GetDeltaDipPt() const {return fDeltaDipPt; }
    template <typename T> Bool_t         EventCut(T* event);
    template <typename T> void           PlotMultiplcities(const T* event) const;
    template <typename T> Bool_t         CheckVertex(const T* event);
@@ -102,14 +104,13 @@ public:
    void                                 PrepareFlowEvent(Int_t iMulti);
    void                                 VZEROSubEventAnalysis();
    virtual void                         UserExec(Option_t *option);
+   virtual void                         Exec(Option_t *);
    void                                 ReconstructionWithEventMixing(TObjArray* MixingCandidates) const;
    virtual void                         Terminate(Option_t *);
    void                                 SetPOICuts(AliFlowTrackCuts *cutsPOI) { fPOICuts = cutsPOI; }
    void                                 SetRPCuts(AliFlowTrackCuts *cutsRP) { fCutsRP = cutsRP; }
    AliFlowTrackCuts*                    GetPOICuts() const {return fPOICuts;}
    AliFlowTrackCuts*                    GetRPCuts() const {return fCutsRP;}
-   void                                 SetRequireTPCStandAloneKaons() { fRequireTPCStandAlone = kTRUE; }
-   void                                 SetOlderThanPbPbPass2() { fOldTrackParam = kTRUE; }
    void                                 SetPIDConfiguration(Double_t prob[7]) { for(Int_t i = 0; i < 7; i++) fPIDConfig[i] = prob[i]; }
    void                                 GetPIDConfiguration(Double_t prob[7]) const {for(Int_t i = 0; i < 7; i++) prob[i] = fPIDConfig[i]; }
    void                                 SetPOIDCAXYZ(Double_t dca[5]) { for(Int_t i = 0; i < 5; i++) fDCAConfig[i] = dca[i]; }
@@ -132,6 +133,11 @@ public:
                                                                                                                         fMaxMass= maxMass; }
    void                                 IsMC();
    Bool_t                               SetQA(Bool_t qa) {fQA = qa; return fQA;}
+   void                                 SetSkipEventSelection(Bool_t s) {
+       fSkipEventSelection = s;
+       fUsePidResponse = kTRUE; // bayesian pid object will require some event info
+       fCentrality = 5.;}        // should be set by user, skipping event selection will also forego centrality selection
+   void                                 SetUsePidResponse(Bool_t s)     {fUsePidResponse = s;}
 
 private:
 
@@ -141,7 +147,6 @@ private:
    Bool_t               fTypeMixing; // select type: kTRUE for unlike sign background, kFALSE for like sign background
    Bool_t               fQA; // make qa plots
    Bool_t               fV0; // use three subevents including vzero
-   Bool_t               fAODAnalysis; // set aod analysis
    Int_t                fMassBins; // mass bins
    Double_t             fMinMass; // mass range
    Double_t             fMaxMass; // mass range
@@ -151,8 +156,6 @@ private:
    AliFlowEvent         *fFlowEvent; //! flow events (one for each inv mass band)
    AliFlowBayesianPID   *fBayesianResponse; //!PID response object
    TObjArray            *fCandidates; // candidate array
-   Bool_t               fOldTrackParam; // set to true if data is older than pbpb pass 2 production
-   Bool_t               fRequireTPCStandAlone; // set TPC standalone cut for kaon selection
    Bool_t               fCandidateEtaPtCut; // set eta and pt cut for candidate tracks and combinatorial background
    Double_t             fCandidateMinEta; // minimum eta for candidates
    Double_t             fCandidateMaxEta; // maximum eta for candidates
@@ -167,7 +170,6 @@ private:
    Int_t                fNPtBins; // no of pt bins + 1
    Double_t             fCentrality; // event centrality
    Double_t             fVertex; // event vertex z 
-   AliESDEvent          *fESD;    //! ESD object
    AliAODEvent          *fAOD;    //! AOD oject
    AliEventPoolManager  *fPoolManager; //! event pool manager
    TList                *fOutputList; // ! Output list
@@ -202,9 +204,9 @@ private:
    TH1F                 *fVZEROA; //! QA plot vzeroa multiplicity (all tracks in event)
    TH1F                 *fVZEROC; //! QA plot vzeroc multiplicity (all tracks in event)
    TH1F                 *fTPCM; //! QA plot TPC multiplicity (tracks used for event plane estimation)
-   Float_t              fDeltaDipAngle; // absolute value of delta dip angle to be excluded
-   Float_t              fDeltaDipPt; // upper value of pt range in which delta dip angle must be applied
-   Bool_t               fApplyDeltaDipCut; // enforce delta dip cut
+//   Float_t              fDeltaDipAngle; // absolute value of delta dip angle to be excluded
+//   Float_t              fDeltaDipPt; // upper value of pt range in which delta dip angle must be applied
+//   Bool_t               fApplyDeltaDipCut; // enforce delta dip cut
    TH2F                 *fDCAAll;//! qa dca of all charged particles
    TH1F                 *fDCAXYQA; //! qa plot of dca xz
    TH1F                 *fDCAZQA; //!qa plot of dca z
@@ -213,12 +215,14 @@ private:
    TH2F                 *fDCAMaterial; //!dca material (mc) all (data)
    TProfile             *fSubEventDPhiv2; //! subevent resolution info for v2
    TProfile             *fV0Data[18][2]; //! profiles for vzero vn(minv)
-
+   Bool_t               fSkipEventSelection;// skip event selection and set bayesian pid object to MC mode
+   Bool_t               fUsePidResponse;//use pid response instead of aliflowbayesianpid object for pid
+   AliPIDCombined*      fPIDCombined;   // pid combined
    AliAnalysisTaskPhiFlow(const AliAnalysisTaskPhiFlow&); // Not implemented
    AliAnalysisTaskPhiFlow& operator=(const AliAnalysisTaskPhiFlow&); // Not implemented
    void                 MakeTrack(Double_t, Double_t, Double_t, Double_t, Int_t , Int_t[]) const;
 
-   ClassDef(AliAnalysisTaskPhiFlow, 6);
+   ClassDef(AliAnalysisTaskPhiFlow, 7);
 };
 
 #endif
index 8d976c56893a94dfce32482e1e1325496b7db93e..2ac0c4a6dccd877ace6868df6ff3e22771f1673f 100644 (file)
@@ -100,8 +100,8 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fCutNClustersITS(kFALSE),
   fNClustersITSMax(INT_MAX),
   fNClustersITSMin(INT_MIN),  
-  fUseAODFilterBit(kFALSE),
-  fAODFilterBit(0),
+  fUseAODFilterBit(kTRUE),
+  fAODFilterBit(1),
   fCutDCAToVertexXY(kFALSE),
   fCutDCAToVertexZ(kFALSE),
   fCutMinimalTPCdedx(kFALSE),
@@ -193,8 +193,8 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fCutNClustersITS(kFALSE),
   fNClustersITSMax(INT_MAX),
   fNClustersITSMin(INT_MIN),
-  fUseAODFilterBit(kFALSE),
-  fAODFilterBit(0),
+  fUseAODFilterBit(kTRUE),
+  fAODFilterBit(1),
   fCutDCAToVertexXY(kFALSE),
   fCutDCAToVertexZ(kFALSE),
   fCutMinimalTPCdedx(kFALSE),
index 3fcca7cfcb7b47ee3bf6f65220f9ccf9d32b0a31..f3590a908140c2bc7ea452068c3407695f1e39d0 100644 (file)
@@ -25,9 +25,8 @@
 //   used to construct the detector response function
 // and unfolds jet spectra with respect to the event plane. The user can choose
 // different alrogithms for unfolding which are available in (ali)root. RooUnfold 
-// libraries must be present on the system (see http://hepunx.rl.ac.uk/~adye/software/unfold/RooUnfold.html).
-// A test mode is available in which the spectrum is unfolded with a generated unity response
-// matrix.
+// libraries must be present on the system 
+// ( see http://hepunx.rl.ac.uk/~adye/software/unfold/RooUnfold.html ).
 // 
 // The weak spot of this class is the function PrepareForUnfolding, which will read
 // output from two output files and expects histograms with certain names and binning. 
@@ -41,7 +40,6 @@
 #include "TF1.h"
 #include "TH1D.h"
 #include "TH2D.h"
-#include "THStack.h"
 #include "TGraph.h"
 #include "TGraphErrors.h"
 #include "TCanvas.h"
@@ -66,6 +64,7 @@
 #include "RooUnfold.h"
 #include "RooUnfoldResponse.h"
 #include "RooUnfoldSvd.h"
+#include "RooUnfoldBayes.h"
 #include "TSVDUnfold.h"
 
 using namespace std;
@@ -85,6 +84,10 @@ AliJetFlowTools::AliJetFlowTools() :
     fJetFindingEff      (0x0),
     fBetaIn             (.1),
     fBetaOut            (.1),
+    fBayesianIterIn     (4),
+    fBayesianIterOut    (4),
+    fBayesianSmoothIn   (0.),
+    fBayesianSmoothOut  (0.),
     fAvoidRoundingError (kFALSE),
     fUnfoldingAlgorithm (kChi2),
     fPrior              (kPriorMeasured),
@@ -97,17 +100,19 @@ AliJetFlowTools::AliJetFlowTools() :
     fSVDToy             (kTRUE),
     fJetRadius          (0.3),
     fEventCount         (-1),
-    fNormalizeSpectra   (kTRUE),
-    fSmoothenSpectrum   (kTRUE),
+    fNormalizeSpectra   (kFALSE),
+    fSmoothenPrior      (kFALSE),
     fFitMin             (60.),
-    fFitMax             (105.),
+    fFitMax             (300.),
     fFitStart           (75.),
+    fSmoothenCounts     (kTRUE),
     fTestMode           (kFALSE),
-    fNoDphi             (kFALSE),
     fRawInputProvided   (kFALSE),
     fEventPlaneRes      (.63),
     fUseDetectorResponse(kTRUE),
+    fUseDptResponse     (kTRUE),
     fTrainPower         (kTRUE),
+    fInOutUnfolding     (kTRUE),
     fRMSSpectrumIn      (0x0),
     fRMSSpectrumOut     (0x0),
     fRMSRatio           (0x0),
@@ -121,10 +126,8 @@ AliJetFlowTools::AliJetFlowTools() :
     fDptIn              (0x0),
     fDptOut             (0x0),
     fFullResponseIn     (0x0),
-    fFullResponseOut    (0x0),
-    fUnfoldedIn         (0x0),
-    fUnfoldedOut        (0x0) { // class constructor
-    // create response maker weight function
+    fFullResponseOut    (0x0) { // class constructor
+    // create response maker weight function (tuned to PYTHIA spectrum)
     fResponseMaker->SetRMMergeWeightFunction(new TF1("weightFunction", "x*TMath::Power(1.+(1./(8.*0.9))*x, -8.)", 0 ,200));
 }
 //_____________________________________________________________________________
@@ -145,22 +148,32 @@ void AliJetFlowTools::Make() {
     }
     // 1a) resize the jet spectrum according to the binning scheme in fBinsTrue
     //     parts of the spectrum can end up in over or underflow bins
-    TH1D* resizedJetPtIn  = RebinTH1D(fSpectrumIn, fBinsRec, TString("resized_in_"), kFALSE);
-    TH1D* resizedJetPtOut = RebinTH1D(fSpectrumOut, fBinsRec, TString("resized_out_"), kFALSE);
+    TH1D* measuredJetSpectrumIn  = RebinTH1D(fSpectrumIn, fBinsRec, TString("resized_in_"), kFALSE);
+    TH1D* measuredJetSpectrumOut = RebinTH1D(fSpectrumOut, fBinsRec, TString("resized_out_"), kFALSE);
 
-    // 1b) get the unfolding template
+    // 1b) resize the jet spectrum to 'true' bins. can serve as a prior and as a template for unfolding
     // the template will be used as a prior for the chi2 unfolding
-    // it holds thie rec spectrum, but is rebinned to the gen binning scheme
-    TH1D* unfoldingTemplateIn  = RebinTH1D(fSpectrumIn, fBinsTrue, TString("in"), kFALSE);
-    TH1D* unfoldingTemplateOut = RebinTH1D(fSpectrumOut, fBinsTrue, TString("out"), kFALSE);
+    TH1D* measuredJetSpectrumTrueBinsIn  = RebinTH1D(fSpectrumIn, fBinsTrue, TString("in"), kFALSE);
+    TH1D* measuredJetSpectrumTrueBinsOut = RebinTH1D(fSpectrumOut, fBinsTrue, TString("out"), kFALSE);
 
     // get the full response matrix from the dpt and the detector response
     fDetectorResponse = NormalizeTH2D(fDetectorResponse);
     // get the full response matrix. if test mode is chosen, the full response is replace by a unity matrix
     // so that unfolding should return the initial spectrum
     if(!fTestMode) {
-        fFullResponseIn  = (fUseDetectorResponse) ? MatrixMultiplication(fDptIn, fDetectorResponse) : fDptIn;
-        fFullResponseOut = (fUseDetectorResponse) ? MatrixMultiplication(fDptOut, fDetectorResponse) : fDptOut;
+        if(fUseDptResponse && fUseDetectorResponse) {
+            fFullResponseIn = MatrixMultiplication(fDptIn, fDetectorResponse);
+            fFullResponseOut = MatrixMultiplication(fDptOut, fDetectorResponse);
+        } else if (fUseDptResponse && !fUseDetectorResponse) {
+            fFullResponseIn = fDptIn;
+            fFullResponseOut = fDptOut;
+        } else if (!fUseDptResponse && fUseDetectorResponse) {
+            fFullResponseIn = fDetectorResponse;
+            fFullResponseOut = fDetectorResponse;
+        } else if (!fUseDptResponse && !fUseDetectorResponse && !fUnfoldingAlgorithm == AliJetFlowTools::kNone) {
+            printf(" > No response, exiting ! < \n" );
+            return;
+        }
     } else {
         fFullResponseIn = GetUnityResponse(fBinsTrue, fBinsRec, TString("in"));
         fFullResponseOut = GetUnityResponse(fBinsTrue, fBinsRec, TString("out"));
@@ -169,12 +182,12 @@ void AliJetFlowTools::Make() {
     NormalizeTH2D(fFullResponseIn);
     NormalizeTH2D(fFullResponseOut);
     // resize to desired binning scheme
-    TH2D* resizedResonseIn  = RebinTH2D(fFullResponseIn, fBinsTrue, fBinsRec, TString("in"));
-    TH2D* resizedResonseOut = RebinTH2D(fFullResponseOut, fBinsTrue, fBinsRec, TString("out"));
+    TH2D* resizedResponseIn  = RebinTH2D(fFullResponseIn, fBinsTrue, fBinsRec, TString("in"));
+    TH2D* resizedResponseOut = RebinTH2D(fFullResponseOut, fBinsTrue, fBinsRec, TString("out"));
     // get the kinematic efficiency
-    TH1D* kinematicEfficiencyIn  = resizedResonseIn->ProjectionX();
+    TH1D* kinematicEfficiencyIn  = resizedResponseIn->ProjectionX();
     kinematicEfficiencyIn->SetNameTitle("kin_eff_IN","kin_eff_IN");
-    TH1D* kinematicEfficiencyOut = resizedResonseOut->ProjectionX();
+    TH1D* kinematicEfficiencyOut = resizedResponseOut->ProjectionX();
     kinematicEfficiencyOut->SetNameTitle("kin_eff_OUT", "kin_eff_OUT");
     // suppress the errors 
     for(Int_t i(0); i < kinematicEfficiencyOut->GetXaxis()->GetNbins(); i++) {
@@ -188,51 +201,56 @@ void AliJetFlowTools::Make() {
         jetFindingEfficiency = RebinTH1D(jetFindingEfficiency, fBinsTrue);
     }
     // 2, 3) call the actual unfolding. results and transient objects are stored in a dedicated TDirectoryFile
-    Bool_t convergedIn(kFALSE), convergedOut(kFALSE);
+    TH1D* unfoldedJetSpectrumIn(0x0);
+    TH1D* unfoldedJetSpectrumOut(0x0); 
     fActiveDir->cd();                   // select active dir
     TDirectoryFile* dirIn = new TDirectoryFile(Form("InPlane___%s", fActiveString.Data()), Form("InPlane___%s", fActiveString.Data()));
     dirIn->cd();                        // select inplane subdir
     // select the unfolding method
     switch (fUnfoldingAlgorithm) {
         case kChi2 : {
-            convergedIn = UnfoldSpectrumChi2(       // do the inplane unfolding
-                resizedJetPtIn,
-                resizedResonseIn,
+            unfoldedJetSpectrumIn = UnfoldSpectrumChi2(       // do the inplane unfolding
+                measuredJetSpectrumIn,
+                resizedResponseIn,
                 kinematicEfficiencyIn,
-                unfoldingTemplateIn,
-                fUnfoldedIn, 
+                measuredJetSpectrumTrueBinsIn,
                 TString("in"),
                 jetFindingEfficiency);
             printf(" > Spectrum (in plane) unfolded using kChi2 unfolding < \n");
         } break;
-        case kSVD : {
-            convergedIn = UnfoldSpectrumSVD(       // do the inplane unfolding
-                resizedJetPtIn,
-                resizedResonseIn,
+        case kBayesian : {
+            unfoldedJetSpectrumIn = UnfoldSpectrumBayesian(       // do the inplane unfolding
+                measuredJetSpectrumIn,
+                resizedResponseIn,
                 kinematicEfficiencyIn,
-                unfoldingTemplateIn,
-                fUnfoldedIn, 
+                measuredJetSpectrumTrueBinsIn,
                 TString("in"),
                 jetFindingEfficiency);
-            printf(" > Spectrum (in plane) unfolded using kSVD unfolding < \n");
+            printf(" > Spectrum (in plane) unfolded using kBayesian unfolding < \n");
+        } break;
+        case kBayesianAli : {
+            unfoldedJetSpectrumIn = UnfoldSpectrumBayesianAli(       // do the inplane unfolding
+                measuredJetSpectrumIn,
+                resizedResponseIn,
+                kinematicEfficiencyIn,
+                measuredJetSpectrumTrueBinsIn,
+                TString("in"),
+                jetFindingEfficiency);
+            printf(" > Spectrum (in plane) unfolded using kBayesianAli unfolding < \n");
         } break;
-        case kSVDlegacy : {
-            convergedIn = UnfoldSpectrumSVDlegacy(       // do the inplane unfolding
-                resizedJetPtIn,
-                resizedResonseIn,
+        case kSVD : {
+            unfoldedJetSpectrumIn = UnfoldSpectrumSVD(       // do the inplane unfolding
+                measuredJetSpectrumIn,
+                resizedResponseIn,
                 kinematicEfficiencyIn,
-                unfoldingTemplateIn,
-                fUnfoldedIn, 
+                measuredJetSpectrumTrueBinsIn,
                 TString("in"),
                 jetFindingEfficiency);
             printf(" > Spectrum (in plane) unfolded using kSVD unfolding < \n");
         } break;
-        case kNone : {  // do nothing, just rebin and optionally smooothen the spectrum
-            resizedResonseIn->SetNameTitle("measuredSpectrumIn", "measured spectrum, in plane");
-            if(fSmoothenSpectrum) resizedJetPtIn = SmoothenSpectrum(resizedJetPtIn, fPower, fFitMin, fFitMin, fFitStart);
-            fUnfoldedIn = ProtectHeap(resizedJetPtIn, kTRUE, TString("in"));
-            convergedIn = kTRUE;
+        case kNone : {  // do nothing 
+            resizedResponseIn->SetNameTitle("measuredSpectrumIn", "measured spectrum, in plane");
+            unfoldedJetSpectrumIn = ProtectHeap(measuredJetSpectrumIn, kTRUE, TString("in"));
         } break;
         
         default : {
@@ -240,11 +258,11 @@ void AliJetFlowTools::Make() {
             return;
         }
     }
-    resizedResonseIn->SetNameTitle("ResponseMatrixIn", "response matrix in plane");
-    resizedResonseIn->SetXTitle("p_{T}^{true} [GeV/c]");
-    resizedResonseIn->SetYTitle("p_{T}^{rec} [GeV/c]");
-    resizedResonseIn = ProtectHeap(resizedResonseIn);
-    resizedResonseIn->Write();
+    resizedResponseIn->SetNameTitle("ResponseMatrixIn", "response matrix in plane");
+    resizedResponseIn->SetXTitle("p_{T}^{true} [GeV/c]");
+    resizedResponseIn->SetYTitle("p_{T}^{rec} [GeV/c]");
+    resizedResponseIn = ProtectHeap(resizedResponseIn);
+    resizedResponseIn->Write();
     kinematicEfficiencyIn->SetNameTitle("KinematicEfficiencyIn","Kinematic efficiency, in plane");
     kinematicEfficiencyIn = ProtectHeap(kinematicEfficiencyIn);
     kinematicEfficiencyIn->Write();
@@ -263,134 +281,141 @@ void AliJetFlowTools::Make() {
         fFullResponseIn->Write();
     }
     fActiveDir->cd();
-    TDirectoryFile* dirOut = new TDirectoryFile(Form("OutOfPlane___%s", fActiveString.Data()), Form("OutOfPlane___%s", fActiveString.Data()));
-    dirOut->cd();
-    switch (fUnfoldingAlgorithm) {
-        case kChi2 : {
-            convergedOut = UnfoldSpectrumChi2(
-                resizedJetPtOut,
-                resizedResonseOut,
-                kinematicEfficiencyOut,
-                unfoldingTemplateOut,
-                fUnfoldedOut,
-                TString("out"),
-                jetFindingEfficiency);
-            printf(" > Spectrum (out of plane) unfolded using kChi2 < \n");
-        } break;
-        case kSVD : {
-            convergedOut = UnfoldSpectrumSVD(
-                resizedJetPtOut,
-                resizedResonseOut,
-                kinematicEfficiencyOut,
-                unfoldingTemplateOut,
-                fUnfoldedOut,
-                TString("out"),
-                jetFindingEfficiency);
-            printf(" > Spectrum (out of plane) unfolded using kSVD < \n");
-        } break;
-        case kSVDlegacy : {
-            convergedOut = UnfoldSpectrumSVDlegacy(
-                resizedJetPtOut,
-                resizedResonseOut,
-                kinematicEfficiencyOut,
-                unfoldingTemplateOut,
-                fUnfoldedOut,
-                TString("out"),
-                jetFindingEfficiency);
-            printf(" > Spectrum (out of plane) unfolded using kSVD < \n");
-        } break;
-        case kNone : {  // do nothing, just rebin and optionally smooothen the spectrum
-            resizedResonseOut->SetNameTitle("measuredSpectrumOut", "measured spectrum, out plane");
-            if(fSmoothenSpectrum) resizedJetPtOut = SmoothenSpectrum(resizedJetPtOut, fPower, fFitMin, fFitMin, fFitStart);
-            fUnfoldedOut = ProtectHeap(resizedJetPtOut, kTRUE, TString("out"));
-            convergedOut = kTRUE;
-        } break;
-        default : {
-            printf(" > Selected unfolding method is not implemented yet ! \n");
-            return;
-        }
-    }
-    resizedResonseOut->SetNameTitle("ResponseMatrixOut", "response matrix in plane");
-    resizedResonseOut->SetXTitle("p_{T}^{true} [GeV/c]");
-    resizedResonseOut->SetYTitle("p_{T}^{rec} [GeV/c]");
-    resizedResonseOut = ProtectHeap(resizedResonseOut);
-    resizedResonseOut->Write();
-    kinematicEfficiencyOut->SetNameTitle("KinematicEfficiencyOut","Kinematic efficiency, Out plane");
-    kinematicEfficiencyOut = ProtectHeap(kinematicEfficiencyOut);
-    kinematicEfficiencyOut->Write();
-    fDetectorResponse->SetNameTitle("DetectorResponse", "Detector response matrix");
-    fDetectorResponse = ProtectHeap(fDetectorResponse, kFALSE);
-    fDetectorResponse->Write();
-    if(jetFindingEfficiency) jetFindingEfficiency->Write();
-    // optional histograms
-    if(fSaveFull) {
-        fSpectrumOut->SetNameTitle("[ORIG]JetSpectrum", "[INPUT]Jet spectrum, Out plane");
-        fSpectrumOut->Write();
-        fDptOutDist->SetNameTitle("[ORIG]DeltaPt", "#delta p_{T} distribution, Out plane");
-        fDptOutDist->Write();
-        fDptOut->SetNameTitle("[ORIG]DeltaPtMatrix","#delta p_{T} matrix, Out plane");
-        fDptOut->Write();
-        fFullResponseOut->SetNameTitle("[ORIG]ResponseMatrix", "Response matrix, Out plane");
-        fFullResponseOut->Write();
-    }
-
-    // write general output histograms to file
-    fActiveDir->cd();
-    if(convergedIn && convergedOut && fUnfoldedIn && fUnfoldedOut) {
-        TGraphErrors* ratio(GetRatio((TH1D*)fUnfoldedIn->Clone("unfoldedLocal_in"), (TH1D*)fUnfoldedOut->Clone("unfoldedLocal_out")));
-        if(ratio) {
-            ratio->SetNameTitle("RatioInOutPlane", "Ratio in plane, out of plane jet spectrum");
-            ratio->GetXaxis()->SetTitle("p_{T} [GeV/c]");
-            ratio->GetYaxis()->SetTitle("yield IN / yield OUT");
-            ratio = ProtectHeap(ratio);
-            ratio->Write();
-            // write histo values to RMS files if both routines converged
-            // input values are weighted by their uncertainty
-            for(Int_t i(0); i < ratio->GetXaxis()->GetNbins(); i++) {
-                if(fUnfoldedIn->GetBinError(i+1) > 0) fRMSSpectrumIn->Fill(fRMSSpectrumIn->GetBinCenter(i+1), fUnfoldedIn->GetBinContent(i+1), 1./TMath::Power(fUnfoldedIn->GetBinError(i+1), 2.));
-                if(fUnfoldedOut->GetBinError(i+1) > 0) fRMSSpectrumOut->Fill(fRMSSpectrumOut->GetBinCenter(i+1), fUnfoldedOut->GetBinContent(i+1), 1./TMath::Power(fUnfoldedOut->GetBinError(i+1), 2.));
-                if(fUnfoldedOut->GetBinContent(i+1) > 0) fRMSRatio->Fill(fRMSSpectrumIn->GetBinCenter(i+1), fUnfoldedIn->GetBinContent(i+1) / fUnfoldedOut->GetBinContent(i+1));
-           }
-        }
-        TGraphErrors* v2(GetV2((TH1D*)fUnfoldedIn->Clone("unfoldedLocal_inv2"), (TH1D*)fUnfoldedOut->Clone("unfoldedLocal_outv2")));
-        if(v2) {
-            v2->SetNameTitle("v2", "v_{2} from different in, out of plane yield");
-            v2->GetXaxis()->SetTitle("p_{T} [GeV/c]");
-            v2->GetYaxis()->SetTitle("v_{2}");
-            v2 = ProtectHeap(v2);
-            v2->Write();
+    if(fInOutUnfolding) {
+        TDirectoryFile* dirOut = new TDirectoryFile(Form("OutOfPlane___%s", fActiveString.Data()), Form("OutOfPlane___%s", fActiveString.Data()));
+        dirOut->cd();
+        switch (fUnfoldingAlgorithm) {
+            case kChi2 : {
+                unfoldedJetSpectrumOut = UnfoldSpectrumChi2(
+                    measuredJetSpectrumOut,
+                    resizedResponseOut,
+                    kinematicEfficiencyOut,
+                    measuredJetSpectrumTrueBinsOut,
+                    TString("out"),
+                    jetFindingEfficiency);
+                printf(" > Spectrum (out of plane) unfolded using kChi2 < \n");
+            } break;
+            case kBayesian : {
+                unfoldedJetSpectrumOut = UnfoldSpectrumBayesian(
+                    measuredJetSpectrumOut,
+                    resizedResponseOut,
+                    kinematicEfficiencyOut,
+                    measuredJetSpectrumTrueBinsOut,
+                    TString("out"),
+                    jetFindingEfficiency);
+                printf(" > Spectrum (out of plane) unfolded using kBayesian < \n");
+            } break;
+            case kBayesianAli : {
+                unfoldedJetSpectrumOut = UnfoldSpectrumBayesianAli(
+                    measuredJetSpectrumOut,
+                    resizedResponseOut,
+                    kinematicEfficiencyOut,
+                    measuredJetSpectrumTrueBinsOut,
+                    TString("out"),
+                    jetFindingEfficiency);
+                printf(" > Spectrum (out of plane) unfolded using kBayesianAli < \n");
+            } break;
+            case kSVD : {
+                unfoldedJetSpectrumOut = UnfoldSpectrumSVD(
+                    measuredJetSpectrumOut,
+                    resizedResponseOut,
+                    kinematicEfficiencyOut,
+                    measuredJetSpectrumTrueBinsOut,
+                    TString("out"),
+                    jetFindingEfficiency);
+                printf(" > Spectrum (out of plane) unfolded using kSVD < \n");
+            } break;
+            case kNone : {  // do nothing
+                resizedResponseOut->SetNameTitle("measuredSpectrumOut", "measured spectrum, out plane");
+                unfoldedJetSpectrumOut = ProtectHeap(measuredJetSpectrumOut, kTRUE, TString("out"));
+            } break;
+            default : {
+                printf(" > Selected unfolding method is not implemented yet ! \n");
+                return;
+            }
         }
-    } else if (fUnfoldedOut && fUnfoldedIn) {
-        TGraphErrors* ratio(GetRatio((TH1D*)fUnfoldedIn->Clone("unfoldedLocal_in"), (TH1D*)fUnfoldedOut->Clone("unfoldedLocal_out"), TString(""), kTRUE, fBinsRec->At(fBinsRec->GetSize()-1)));
-        if(ratio) {
-            ratio->SetNameTitle("[NC]RatioInOutPlane", "[NC]Ratio in plane, out of plane jet spectrum");
-            ratio->GetXaxis()->SetTitle("p_{T} [GeV/c]");
-            ratio->GetYaxis()->SetTitle("yield IN / yield OUT");
-            ratio = ProtectHeap(ratio);
-            ratio->Write();
+        resizedResponseOut->SetNameTitle("ResponseMatrixOut", "response matrix in plane");
+        resizedResponseOut->SetXTitle("p_{T}^{true} [GeV/c]");
+        resizedResponseOut->SetYTitle("p_{T}^{rec} [GeV/c]");
+        resizedResponseOut = ProtectHeap(resizedResponseOut);
+        resizedResponseOut->Write();
+        kinematicEfficiencyOut->SetNameTitle("KinematicEfficiencyOut","Kinematic efficiency, Out plane");
+        kinematicEfficiencyOut = ProtectHeap(kinematicEfficiencyOut);
+        kinematicEfficiencyOut->Write();
+        fDetectorResponse->SetNameTitle("DetectorResponse", "Detector response matrix");
+        fDetectorResponse = ProtectHeap(fDetectorResponse, kFALSE);
+        fDetectorResponse->Write();
+        if(jetFindingEfficiency) jetFindingEfficiency->Write();
+        // optional histograms
+        if(fSaveFull) {
+            fSpectrumOut->SetNameTitle("[ORIG]JetSpectrum", "[INPUT]Jet spectrum, Out plane");
+            fSpectrumOut->Write();
+            fDptOutDist->SetNameTitle("[ORIG]DeltaPt", "#delta p_{T} distribution, Out plane");
+            fDptOutDist->Write();
+            fDptOut->SetNameTitle("[ORIG]DeltaPtMatrix","#delta p_{T} matrix, Out plane");
+            fDptOut->Write();
+            fFullResponseOut->SetNameTitle("[ORIG]ResponseMatrix", "Response matrix, Out plane");
+            fFullResponseOut->Write();
         }
-        TGraphErrors* v2(GetV2((TH1D*)fUnfoldedIn->Clone("unfoldedLocal_inv2"), (TH1D*)fUnfoldedOut->Clone("unfoldedLocal_outv2")));
-         if(v2) {
-            v2->SetNameTitle("v2", "v_{2} from different in, out of plane yield");
-            v2->GetXaxis()->SetTitle("p_{T} [GeV/c]");
-            v2->GetYaxis()->SetTitle("v_{2}");
-            v2 = ProtectHeap(v2);
-            v2->Write();
+
+        // write general output histograms to file
+        fActiveDir->cd();
+        if(unfoldedJetSpectrumIn && unfoldedJetSpectrumOut && unfoldedJetSpectrumIn && unfoldedJetSpectrumOut) {
+            TGraphErrors* ratio(GetRatio((TH1D*)unfoldedJetSpectrumIn->Clone("unfoldedLocal_in"), (TH1D*)unfoldedJetSpectrumOut->Clone("unfoldedLocal_out")));
+            if(ratio) {
+                ratio->SetNameTitle("RatioInOutPlane", "Ratio in plane, out of plane jet spectrum");
+                ratio->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+                ratio->GetYaxis()->SetTitle("yield IN / yield OUT");
+                ratio = ProtectHeap(ratio);
+                ratio->Write();
+                // write histo values to RMS files if both routines converged
+                // input values are weighted by their uncertainty
+                for(Int_t i(0); i < ratio->GetXaxis()->GetNbins(); i++) {
+                    if(unfoldedJetSpectrumIn->GetBinError(i+1) > 0) fRMSSpectrumIn->Fill(fRMSSpectrumIn->GetBinCenter(i+1), unfoldedJetSpectrumIn->GetBinContent(i+1), 1./TMath::Power(unfoldedJetSpectrumIn->GetBinError(i+1), 2.));
+                    if(unfoldedJetSpectrumOut->GetBinError(i+1) > 0) fRMSSpectrumOut->Fill(fRMSSpectrumOut->GetBinCenter(i+1), unfoldedJetSpectrumOut->GetBinContent(i+1), 1./TMath::Power(unfoldedJetSpectrumOut->GetBinError(i+1), 2.));
+                    if(unfoldedJetSpectrumOut->GetBinContent(i+1) > 0) fRMSRatio->Fill(fRMSSpectrumIn->GetBinCenter(i+1), unfoldedJetSpectrumIn->GetBinContent(i+1) / unfoldedJetSpectrumOut->GetBinContent(i+1));
+               }
+            }
+            TGraphErrors* v2(GetV2((TH1D*)unfoldedJetSpectrumIn->Clone("unfoldedLocal_inv2"), (TH1D*)unfoldedJetSpectrumOut->Clone("unfoldedLocal_outv2")));
+            if(v2) {
+                v2->SetNameTitle("v2", "v_{2} from different in, out of plane yield");
+                v2->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+                v2->GetYaxis()->SetTitle("v_{2}");
+                v2 = ProtectHeap(v2);
+                v2->Write();
+            }
+        } else if (unfoldedJetSpectrumOut && unfoldedJetSpectrumIn) {
+            TGraphErrors* ratio(GetRatio((TH1D*)unfoldedJetSpectrumIn->Clone("unfoldedLocal_in"), (TH1D*)unfoldedJetSpectrumOut->Clone("unfoldedLocal_out"), TString(""), kTRUE, fBinsRec->At(fBinsRec->GetSize()-1)));
+            if(ratio) {
+                ratio->SetNameTitle("[NC]RatioInOutPlane", "[NC]Ratio in plane, out of plane jet spectrum");
+                ratio->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+                ratio->GetYaxis()->SetTitle("yield IN / yield OUT");
+                ratio = ProtectHeap(ratio);
+                ratio->Write();
+            }
+            TGraphErrors* v2(GetV2((TH1D*)unfoldedJetSpectrumIn->Clone("unfoldedLocal_inv2"), (TH1D*)unfoldedJetSpectrumOut->Clone("unfoldedLocal_outv2")));
+             if(v2) {
+                v2->SetNameTitle("v2", "v_{2} from different in, out of plane yield");
+                v2->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+                v2->GetYaxis()->SetTitle("v_{2}");
+                v2 = ProtectHeap(v2);
+                v2->Write();
+            }
         }
-    }
+    }   // end of if(fInOutUnfolding)
     fDeltaPtDeltaPhi->Write();
     fJetPtDeltaPhi->Write();
-    SaveConfiguration(convergedIn, convergedOut);
+    // save the current state of the unfolding object
+    SaveConfiguration(unfoldedJetSpectrumIn ? kTRUE : kFALSE, unfoldedJetSpectrumOut ? kTRUE : kFALSE);
 }
 //_____________________________________________________________________________
-Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
-        TH1D* resizedJetPt,             // truncated raw jets (same binning as pt rec of response) 
-        TH2D* resizedResonse,           // response matrix
-        TH1D* kinematicEfficiency,      // kinematic efficiency
-        TH1D* unfoldingTemplate,        // unfolding template: same binning is pt gen of response
-        TH1D *&unfolded,                // will point to the unfolded spectrum
-        TString suffix,                 // suffix (in or out of plane)
-        TH1D* jetFindingEfficiency)     // jet finding efficiency (optional)
+TH1D* AliJetFlowTools::UnfoldSpectrumChi2(
+        const TH1D* measuredJetSpectrum,      // truncated raw jets (same binning as pt rec of response) 
+        const TH2D* resizedResponse,           // response matrix
+        const TH1D* kinematicEfficiency,      // kinematic efficiency
+        const TH1D* measuredJetSpectrumTrueBins,        // unfolding template: same binning is pt gen of response
+        const TString suffix,                 // suffix (in or out of plane)
+        const TH1D* jetFindingEfficiency)     // jet finding efficiency (optional)
 {
     // unfold the spectrum using chi2 minimization
 
@@ -404,21 +429,23 @@ Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
     else if(!strcmp("prior_out", suffix.Data())) AliUnfolding::SetChi2Regularization(AliUnfolding::kLogLog, fBetaOut);
     AliUnfolding::SetNbins(fBinsRec->GetSize()-1, fBinsTrue->GetSize()-1);
 
-    // step 1) clone all input histograms. 
+    // step 1) clone all input histograms. the histograms are cloned to make sure that the original histograms
+    // stay intact. a local copy of a histogram (which only exists in the scope of this function) is 
+    // denoted by the suffix 'Local'
     
-    // resizedJetPtLocal holds the spectrum that needs to be unfolded
-    TH1D *resizedJetPtLocal = (TH1D*)resizedJetPt->Clone(Form("resizedJetPtLocal_%s", suffix.Data()));
-    if(fSmoothenSpectrum) resizedJetPtLocal = SmoothenSpectrum(resizedJetPtLocal, fPower, fFitMin, fFitMax, fFitStart);
+    // measuredJetSpectrumLocal holds the spectrum that needs to be unfolded
+    TH1D *measuredJetSpectrumLocal = (TH1D*)measuredJetSpectrum->Clone(Form("measuredJetSpectrumLocal_%s", suffix.Data()));
     // unfolded local will be filled with the result of the unfolding
     TH1D *unfoldedLocal(new TH1D(Form("unfoldedLocal_%s", suffix.Data()), Form("unfoldedLocal_%s", suffix.Data()), fBinsTrue->GetSize()-1, fBinsTrue->GetArray()));
 
     // full response matrix and kinematic efficiency
-    TH2D* resizedResponseLocal = (TH2D*)resizedResonse->Clone(Form("resizedResponseLocal_%s", suffix.Data()));
+    TH2D* resizedResponseLocal = (TH2D*)resizedResponse->Clone(Form("resizedResponseLocal_%s", suffix.Data()));
     TH1D* kinematicEfficiencyLocal = (TH1D*)kinematicEfficiency->Clone(Form("kinematicEfficiencyLocal_%s", suffix.Data()));
 
     // the initial guess for the unfolded pt spectrum, equal to the folded spectrum, but in 'true' bins
-    TH1D *priorLocal = (TH1D*)unfoldingTemplate->Clone(Form("priorLocal_%s", suffix.Data()));
-    if(fSmoothenSpectrum) priorLocal = SmoothenSpectrum(priorLocal, fPower, fFitMin, fFitMax, fFitStart);
+    TH1D *priorLocal = (TH1D*)measuredJetSpectrumTrueBins->Clone(Form("priorLocal_%s", suffix.Data()));
+    // optionally, the prior can be smoothened by extrapolating the spectrum using a power law fit
+    if(fSmoothenPrior) priorLocal = SmoothenPrior(priorLocal, fPower, fFitMin, fFitMax, fFitStart, kTRUE, fSmoothenCounts);
 
     // step 2) start the unfolding
     Int_t status(-1), i(0);
@@ -429,7 +456,7 @@ Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
         status = AliUnfolding::Unfold(
                 resizedResponseLocal,           // response matrix
                 kinematicEfficiencyLocal,       // efficiency applied on the unfolded spectrum (can be NULL)
-                resizedJetPtLocal,              // measured spectrum
+                measuredJetSpectrumLocal,              // measured spectrum
                 priorLocal,                     // initial conditions (set NULL to use measured spectrum)
                 unfoldedLocal);                 // results
         // status holds the minuit fit status (where 0 means convergence)
@@ -453,7 +480,7 @@ Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
     TH1D *foldedLocal(fResponseMaker->MultiplyResponseGenerated(unfoldedLocal, resizedResponseLocal,kinematicEfficiencyLocal));
     foldedLocal->SetNameTitle(Form("RefoldedSpectrum_%s", suffix.Data()), Form("Refolded jet spectrum, %s plane", suffix.Data()));
     unfoldedLocal->SetNameTitle(Form("UnfoldedSpectrum_%s", suffix.Data()), Form("Unfolded jet spectrum, %s plane", suffix.Data()));
-    TGraphErrors* ratio(GetRatio(foldedLocal, resizedJetPtLocal, TString(""), kTRUE, fBinsTrue->At(fBinsTrue->GetSize()-1)));
+    TGraphErrors* ratio(GetRatio(foldedLocal, measuredJetSpectrumLocal, TString(""), kTRUE, fBinsTrue->At(fBinsTrue->GetSize()-1)));
     if(ratio) {
         ratio->SetNameTitle("RatioRefoldedMeasured", Form("Ratio measured, re-folded %s ", suffix.Data()));
         ratio->GetYaxis()->SetTitle("ratio measured / re-folded");
@@ -463,9 +490,9 @@ Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
 
     // step 4) write histograms to file. to ensure that these have unique identifiers on the heap, 
     // objects are cloned using 'ProtectHeap()'
-    resizedJetPtLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("InputSpectrum_%s", suffix.Data()));
-    resizedJetPtLocal = ProtectHeap(resizedJetPtLocal);
-    resizedJetPtLocal->Write(); 
+    measuredJetSpectrumLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("InputSpectrum_%s", suffix.Data()));
+    measuredJetSpectrumLocal = ProtectHeap(measuredJetSpectrumLocal);
+    measuredJetSpectrumLocal->Write(); 
 
     resizedResponseLocal = ProtectHeap(resizedResponseLocal);
     resizedResponseLocal->Write();
@@ -491,108 +518,42 @@ Bool_t AliJetFlowTools::UnfoldSpectrumChi2(
     fitStatus->SetBinContent(4, (!strcmp(suffix.Data(), "in")) ? fBetaIn : fBetaOut);
     fitStatus->GetXaxis()->SetBinLabel(4, (!strcmp(suffix.Data(), "in")) ? "fBetaIn" : "fBetaOut");
     fitStatus->Write();
-    unfolded = unfoldedLocal;
-    return (status == 0) ? kTRUE : kFALSE;
+    return unfoldedLocal;
 }
 //_____________________________________________________________________________
-Bool_t AliJetFlowTools::UnfoldSpectrumSVDlegacy(
-        TH1D* resizedJetPt,                     // jet pt in pt rec bins 
-        TH2D* resizedResonse,                   // full response matrix, normalized in slides of pt true
-        TH1D* kinematicEfficiency,              // kinematic efficiency
-        TH1D* unfoldingTemplate,                // jet pt in pt true bins, also the prior when measured is chosen as prior
-        TH1D *&unfolded,                        // will point to result. temporarily holds prior when chi2 is chosen as prior
-        TString suffix,                         // suffix (in, out)
-        TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
+TH1D* AliJetFlowTools::UnfoldSpectrumSVD(
+        const TH1D* measuredJetSpectrum,              // jet pt in pt rec bins 
+        const TH2D* resizedResponse,                   // full response matrix, normalized in slides of pt true
+        const TH1D* kinematicEfficiency,              // kinematic efficiency
+        const TH1D* measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        const TString suffix,                         // suffix (in, out)
+        const TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
 {
-    // use SVD (singular value decomposition) method to unfold spectra
-    
-    // 1) get a prior for unfolding. 
-    // this can be either an unfolded spectrum from e.g. chi2 unfolding or the measured spectrum
-    TDirectoryFile* dirOut = new TDirectoryFile(Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()), Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()));
-    dirOut->cd();
-    switch (fPrior) {    // select the prior for unfolding
-        case kPriorChi2 : {
-            if(fBinsTruePrior && fBinsRecPrior) {       // if set, use different binning for the prior
-                TArrayD* tempArrayTrue(fBinsTrue);      // temporarily cache the original (SVD) binning
-                fBinsTrue = fBinsTruePrior;             // switch binning schemes (will be used in UnfoldSpectrumChi2())
-                TArrayD* tempArrayRec(fBinsRec);
-                fBinsRec = fBinsRecPrior;
-                TH1D* resizedJetPtChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsRec, TString("resized_chi2"), kFALSE);
-                TH1D* unfoldingTemplateChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsTruePrior, TString("out"), kFALSE);
-                TH2D* resizedResonseChi2(RebinTH2D((!strcmp("in", suffix.Data())) ? fFullResponseIn : fFullResponseOut,fBinsTruePrior, fBinsRec, TString("chi2")));
-                TH1D* kinematicEfficiencyChi2(resizedResonseChi2->ProjectionX());
-                kinematicEfficiencyChi2->SetNameTitle("kin_eff_chi2","kin_eff_chi2");
-                for(Int_t i(0); i < kinematicEfficiencyChi2->GetXaxis()->GetNbins(); i++) kinematicEfficiencyChi2->SetBinError(1+i, 0.);
-                if(! UnfoldSpectrumChi2(
-                            resizedJetPtChi2,
-                            resizedResonseChi2,
-                            kinematicEfficiencyChi2,
-                            unfoldingTemplateChi2,  // prior for chi2 unfolding (measured)
-                            unfolded,               // will hold the result from chi2 (is prior for SVD)
-                            TString(Form("prior_%s", suffix.Data()))) ) {
-                    printf(" > UnfoldSVD:: panic, couldn't get prior from Chi2 unfolding! \n");
-                    printf("               probably Chi2 unfolding did not converge < \n");
-                    return kFALSE;
-                }
-                fBinsTrue = tempArrayTrue;  // reset bins borders
-                fBinsRec = tempArrayRec;
-                unfolded = RebinTH1D(unfolded, fBinsTrue, TString(Form("unfoldedChi2Prior_%s", suffix.Data())));     // rebin unfolded
-            } else if(! UnfoldSpectrumChi2(
-                        resizedJetPt,
-                        resizedResonse,
-                        kinematicEfficiency,
-                        unfoldingTemplate,      // prior for chi2 unfolding (measured)
-                        unfolded,               // will hold the result from chi2 (is prior for SVD)
-                        TString(Form("prior_%s", suffix.Data()))) ) {
-                printf(" > UnfoldSVD:: panic, couldn't get prior from Chi2 unfolding! \n");
-                printf("               probably Chi2 unfolding did not converge < \n");
-                return kFALSE;
-            }
-            if(!unfolded) {
-                printf(" > UnfoldSVD:: panic, Chi2 unfolding converged but the prior is NULL ! < " );
-                return kFALSE;
-            }
-            break;
-        }
-        case kPriorMeasured : { 
-            unfolded = (TH1D*)unfoldingTemplate->Clone(Form("kPriorMeasured_%s", suffix.Data()));       // copy template to unfolded to use as prior
-            if(fSmoothenSpectrum) {     // optionally smoothen the measured prior
-                unfolded->Sumw2();
-                TFitResultPtr r = unfolded->Fit(fPower, "QWILS", "", fFitMin, fFitMax);
-                if((int)r == 0) {
-                    for(Int_t i(1); i < unfolded->GetNbinsX() + 1; i++) {
-                        if(unfolded->GetBinCenter(i) > fFitStart) {     // from this pt value use extrapolation
-                            unfolded->SetBinContent(i,fPower->Integral(unfolded->GetXaxis()->GetBinLowEdge(i),unfolded->GetXaxis()->GetBinUpEdge(i))/unfolded->GetXaxis()->GetBinWidth(i));
-                        }
-                    }
-                }else printf(" > PANIC, SMOOTHENING FAILED < \n");
-            }
-        }
-        default : break;
-    }
-    // note: true and measured spectrum must have same binning for SVD unfolding
-    // a sane starting point for regularization is nbins / 2 (but the user has to set this ! ) 
-    if(unfoldingTemplate->GetXaxis()->GetNbins() != resizedJetPt->GetXaxis()->GetNbins()) {
-        printf(" > UnfoldSpectrumSVD:: PANIC, true and measured spectrum must have same numer of bins ! < \n ");
-    }
+
+    TH1D* priorLocal( GetPrior(
+        measuredJetSpectrum,              // jet pt in pt rec bins 
+        resizedResponse,                  // full response matrix, normalized in slides of pt true
+        kinematicEfficiency,              // kinematic efficiency
+        measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        suffix,                           // suffix (in, out)
+        jetFindingEfficiency));           // jet finding efficiency (optional)
+    if(!priorLocal) {
+        printf(" > couldn't find prior ! < \n");
+        return 0x0;
+    } else printf(" 1) retrieved prior \n");
+
+    // go back to the 'root' directory of this instance of the SVD unfolding routine
     (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) : fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-    cout << " 1) retrieved prior " << endl;
 
     // 2) setup all the necessary input for the unfolding routine. all input histograms are copied locally
-    // prior 
-    if(jetFindingEfficiency) unfolded->Divide(jetFindingEfficiency);
-    TH1D *unfoldedLocal((TH1D*)unfolded->Clone(Form("priorUnfolded_%s", suffix.Data())));
-    // raw jets in pt rec binning
-    TH1D *cachedRawJetLocal((TH1D*)resizedJetPt->Clone(Form("jets_%s", suffix.Data())));
-    // raw jets in pt true binning
-    TH1D *cachedRawJetLocalCoarse((TH1D*)unfoldingTemplate->Clone(Form("unfoldingTemplate_%s", suffix.Data())));
-    // copy of raw jets in pt true binning 
-    TH1D *cachedRawJetLocalCoarseOrig((TH1D*)cachedRawJetLocalCoarse->Clone(Form("cachedRawJetLocalCoarseOrig_%s", suffix.Data())));
-    // local copies response matrix
-    TH2D *cachedResponseLocal((TH2D*)resizedResonse->Clone(Form("cachedResponseLocal_%s", suffix.Data())));
-    // local copy of response matrix, all true slides normalized to 1 (correction for the efficiency)
-    TH2D *cachedResponseLocalNorm((TH2D*)resizedResonse->Clone(Form("cachedResponseLocalNorm_%s", suffix.Data())));
-    cachedResponseLocalNorm = NormalizeTH2D(cachedResponseLocalNorm);
+    // measured jets in pt rec binning
+    TH1D *measuredJetSpectrumLocal((TH1D*)measuredJetSpectrum->Clone(Form("jets_%s", suffix.Data())));
+    // local copie of the response matrix
+    TH2D *resizedResponseLocal((TH2D*)resizedResponse->Clone(Form("resizedResponseLocal_%s", suffix.Data())));
+    // local copy of response matrix, all true slides normalized to 1 
+    // this response matrix will eventually be used in the re-folding routine
+    TH2D *resizedResponseLocalNorm((TH2D*)resizedResponse->Clone(Form("resizedResponseLocalNorm_%s", suffix.Data())));
+    resizedResponseLocalNorm = NormalizeTH2D(resizedResponseLocalNorm);
     // kinematic efficiency
     TH1D *kinematicEfficiencyLocal((TH1D*)kinematicEfficiency->Clone(Form("kinematicEfficiency_%s", suffix.Data())));
     // place holder histos
@@ -601,50 +562,37 @@ Bool_t AliJetFlowTools::UnfoldSpectrumSVDlegacy(
     cout << " 2) setup necessary input " << endl;
     // 3) configure routine
     RooUnfold::ErrorTreatment errorTreatment = (fSVDToy) ? RooUnfold::kCovToy : RooUnfold::kCovariance;
-    // prior: use fit for where the histogram is sparsely filled 
-    if(fSmoothenSpectrum) cachedRawJetLocalCoarse = SmoothenSpectrum(cachedRawJetLocalCoarse, fPower, fFitMin, fFitMax, fFitStart);
-    if(fSmoothenSpectrum) cachedRawJetLocal = SmoothenSpectrum(cachedRawJetLocal, fPower, fFitMin, fFitMax, fFitStart);
-    if(fSmoothenSpectrum) unfoldedLocal = SmoothenSpectrum(unfoldedLocal, fPower, fFitMin, fFitMax, fFitStart);
     cout << " step 3) configured routine " << endl;
 
     // 4) get transpose matrices
-    // a) get the transpose matrix for the prior
-    TH2* responseMatrixLocalTransposePrior(fResponseMaker->GetTransposeResponsMatrix(cachedResponseLocal));
+    // a) get the transpose of the full response matrix
+    TH2* responseMatrixLocalTransposePrior(fResponseMaker->GetTransposeResponsMatrix(resizedResponseLocal));
     responseMatrixLocalTransposePrior->SetNameTitle(Form("prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()),Form("prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()));
-    // normalize it with the prior
-    responseMatrixLocalTransposePrior = fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, unfoldedLocal);
-    cout << " 4a) retrieved first transpose matrix " << endl;
-    // b) prior norm
-    TH2* responseMatrixLocalTransposePriorNorm(fResponseMaker->GetTransposeResponsMatrix(cachedResponseLocalNorm));
-    responseMatrixLocalTransposePriorNorm->SetNameTitle(Form("prior_%s_%s", responseMatrixLocalTransposePriorNorm->GetName(), suffix.Data()),Form("prior_%s_%s", responseMatrixLocalTransposePriorNorm->GetName(), suffix.Data()));
-    // normalize with the prior
-    responseMatrixLocalTransposePriorNorm = fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePriorNorm, unfoldedLocal);
-    cout << " 4b) retrieved second transpose matrix " << endl;
+    // normalize it with the prior. this will ensure that high statistics bins will constrain the
+    // end result most strenuously than bins with limited number of counts
+    responseMatrixLocalTransposePrior = fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, priorLocal);
+    cout << " 4) retrieved first transpose matrix " << endl;
  
     // 5) get response for SVD unfolding
     RooUnfoldResponse responseSVD(0, 0, responseMatrixLocalTransposePrior, Form("respCombinedSVD_%s", suffix.Data()), Form("respCombinedSVD_%s", suffix.Data()));
-
-    // change to inplane dir
-    (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) :fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-
     cout << " 5) retrieved roo unfold response object " << endl;
+
     // 6) actualy unfolding loop
-    RooUnfoldSvd unfoldSVD(&responseSVD, cachedRawJetLocal, (!strcmp(suffix.Data(), "in")) ? fSVDRegIn : fSVDRegOut);
+    RooUnfoldSvd unfoldSVD(&responseSVD, measuredJetSpectrumLocal, (!strcmp(suffix.Data(), "in")) ? fSVDRegIn : fSVDRegOut);
     unfoldedLocalSVD = (TH1D*)unfoldSVD.Hreco(errorTreatment);
+    // correct the spectrum for the kinematic efficiency
+    unfoldedLocalSVD->Divide(kinematicEfficiencyLocal);
+
+    // get the pearson coefficients from the covariance matrix
     TMatrixD covarianceMatrix = unfoldSVD.Ereco(errorTreatment);
     TMatrixD *pearson = (TMatrixD*)CalculatePearsonCoefficients(&covarianceMatrix);
-    cout << " Pearson coeffs" << endl;
-    // create the unfolding qa plots
-    cout << " 6) unfolded spectrum " << endl;
     if(pearson) {
-        TH2D* hPearson = new TH2D(*pearson);
+        TH2D* hPearson(new TH2D(*pearson));
         pearson->Print();
         hPearson->SetNameTitle(Form("PearsonCoefficients_%s", suffix.Data()), Form("Pearson coefficients_%s", suffix.Data()));
         hPearson = ProtectHeap(hPearson);
         hPearson->Write();
-    } else return kFALSE;       // return if unfolding didn't converge
-    // correct for the efficiency
-    unfoldedLocalSVD->Divide(kinematicEfficiencyLocal);
+    } else return 0x0;       // return if unfolding didn't converge
 
     // plot singular values and d_i vector
     TSVDUnfold* svdUnfold(unfoldSVD.Impl());
@@ -659,19 +607,19 @@ Bool_t AliJetFlowTools::UnfoldSpectrumSVDlegacy(
     cout << " plotted singular values and d_i vector " << endl;
 
     // 7) refold the unfolded spectrum
-    foldedLocalSVD = fResponseMaker->MultiplyResponseGenerated(unfoldedLocalSVD, cachedResponseLocalNorm,kinematicEfficiencyLocal);
-    TGraphErrors* ratio(GetRatio(cachedRawJetLocal, foldedLocalSVD, "ratio  measured / re-folded", kTRUE));
+    foldedLocalSVD = fResponseMaker->MultiplyResponseGenerated(unfoldedLocalSVD, resizedResponseLocalNorm, kinematicEfficiencyLocal);
+    TGraphErrors* ratio(GetRatio(measuredJetSpectrumLocal, foldedLocalSVD, "ratio  measured / re-folded", kTRUE));
     ratio->SetNameTitle(Form("RatioRefoldedMeasured_%s", fActiveString.Data()), Form("Ratio measured / re-folded %s", fActiveString.Data()));
     ratio->GetXaxis()->SetTitle("p_{t}^{rec, rec} [GeV/ c]");
     ratio->GetYaxis()->SetTitle("ratio measured / re-folded");
     ratio->Write();
     cout << " 7) refolded the unfolded spectrum " << endl;
 
-    // write to output
-    cachedRawJetLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("input spectrum (measured) %s", suffix.Data()));
-    cachedRawJetLocal = ProtectHeap(cachedRawJetLocal);
-    cachedRawJetLocal->SetXTitle("p_{t}^{rec} [GeV/c]");
-    cachedRawJetLocal->Write(); // input spectrum
+    // write the measured, unfolded and re-folded spectra to the output directory
+    measuredJetSpectrumLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("input spectrum (measured) %s", suffix.Data()));
+    measuredJetSpectrumLocal = ProtectHeap(measuredJetSpectrumLocal);
+    measuredJetSpectrumLocal->SetXTitle("p_{t}^{rec} [GeV/c]");
+    measuredJetSpectrumLocal->Write(); // input spectrum
     unfoldedLocalSVD->SetNameTitle(Form("UnfoldedSpectrum_%s",suffix.Data()), Form("unfolded spectrum %s", suffix.Data()));
     unfoldedLocalSVD = ProtectHeap(unfoldedLocalSVD);
     if(jetFindingEfficiency) unfoldedLocalSVD->Divide(jetFindingEfficiency);
@@ -680,27 +628,17 @@ Bool_t AliJetFlowTools::UnfoldSpectrumSVDlegacy(
     foldedLocalSVD = ProtectHeap(foldedLocalSVD);
     foldedLocalSVD->Write();    // re-folded spectrum
 
-    // switch back to active root directory
-    (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) :fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-    responseMatrixLocalTransposePrior->SetNameTitle("TransposeResponseMatrix", "Transpose of response matrix");
+    // save more general bookkeeeping histograms to the output directory
+    responseMatrixLocalTransposePrior->SetNameTitle("TransposeResponseMatrix", "Transpose of response matrix, normalize with prior");
     responseMatrixLocalTransposePrior->SetXTitle("p_{T}^{true} [GeV/c]");
     responseMatrixLocalTransposePrior->SetYTitle("p_{T}^{rec} [GeV/c]");
     responseMatrixLocalTransposePrior->Write();
-    responseMatrixLocalTransposePriorNorm->SetNameTitle("TransposeResponseMatrixNorm", "Transpose of response matrix normalized with prior");
-    responseMatrixLocalTransposePriorNorm->SetXTitle("p_{T}^{true} [GeV/c]");
-    responseMatrixLocalTransposePriorNorm->SetYTitle("p_{T}^{rec} [GeV/c]");
-    responseMatrixLocalTransposePriorNorm->Write();
-    cachedRawJetLocal->SetNameTitle("PriorOriginal", "Prior, original");
-    cachedRawJetLocal->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarse->SetNameTitle("PriorSmoothened", "Prior, smoothened");
-    cachedRawJetLocalCoarse->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarse->Write();
-    cachedRawJetLocalCoarseOrig->SetNameTitle("Prior", "Prior");
-    cachedRawJetLocalCoarseOrig->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarseOrig->Write();
-    unfolded = unfoldedLocalSVD; 
-    cachedResponseLocalNorm = ProtectHeap(cachedResponseLocalNorm);
-    cachedResponseLocalNorm->Write();
+    priorLocal->SetNameTitle("PriorOriginal", "Prior, original");
+    priorLocal->SetXTitle("p_{t} [GeV/c]");
+    priorLocal = ProtectHeap(priorLocal);
+    priorLocal->Write();
+    resizedResponseLocalNorm = ProtectHeap(resizedResponseLocalNorm);
+    resizedResponseLocalNorm->Write();
 
     // save some info 
     TH1F* fitStatus(new TH1F(Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), 1, -0.5, 0.5));
@@ -708,197 +646,235 @@ Bool_t AliJetFlowTools::UnfoldSpectrumSVDlegacy(
     fitStatus->GetXaxis()->SetBinLabel(1, (!strcmp(suffix.Data(), "in")) ? "fSVDRegIn" : "fSVDRegOut");
     fitStatus->Write();
 
-    return (unfoldedLocalSVD) ? kTRUE : kFALSE;
+    return unfoldedLocalSVD;
 }
 //_____________________________________________________________________________
-Bool_t AliJetFlowTools::UnfoldSpectrumSVD(
-        TH1D* resizedJetPt,                     // jet pt in pt rec bins 
-        TH2D* resizedResonse,                   // full response matrix, normalized in slides of pt true
-        TH1D* kinematicEfficiency,              // kinematic efficiency
-        TH1D* unfoldingTemplate,                // jet pt in pt true bins, also the prior when measured is chosen as prior
-        TH1D *&unfolded,                        // will point to result. temporarily holds prior when chi2 is chosen as prior
-        TString suffix,                         // suffix (in, out)
-        TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
+TH1D* AliJetFlowTools::UnfoldSpectrumBayesianAli(
+        const TH1D* measuredJetSpectrum,              // jet pt in pt rec bins 
+        const TH2D* resizedResponse,                  // full response matrix, normalized in slides of pt true
+        const TH1D* kinematicEfficiency,              // kinematic efficiency
+        const TH1D* measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        const TString suffix,                         // suffix (in, out)
+        const TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
 {
-    // use SVD (singular value decomposition) method to unfold spectra
-    
-    // 1) get a prior for unfolding. 
-    // this can be either an unfolded spectrum from e.g. chi2 unfolding or the measured spectrum
-    TDirectoryFile* dirOut = new TDirectoryFile(Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()), Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()));
-    dirOut->cd();
-    switch (fPrior) {    // select the prior for unfolding
-        case kPriorChi2 : {
-            if(fBinsTruePrior && fBinsRecPrior) {       // if set, use different binning for the prior
-                TArrayD* tempArrayTrue(fBinsTrue);      // temporarily cache the original (SVD) binning
-                fBinsTrue = fBinsTruePrior;             // switch binning schemes (will be used in UnfoldSpectrumChi2())
-                TArrayD* tempArrayRec(fBinsRec);
-                fBinsRec = fBinsRecPrior;
-                TH1D* resizedJetPtChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsRec, TString("resized_chi2"), kFALSE);
-                TH1D* unfoldingTemplateChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsTruePrior, TString("out"), kFALSE);
-                TH2D* resizedResonseChi2(RebinTH2D((!strcmp("in", suffix.Data())) ? fFullResponseIn : fFullResponseOut,fBinsTruePrior, fBinsRec, TString("chi2")));
-                TH1D* kinematicEfficiencyChi2(resizedResonseChi2->ProjectionX());
-                kinematicEfficiencyChi2->SetNameTitle("kin_eff_chi2","kin_eff_chi2");
-                for(Int_t i(0); i < kinematicEfficiencyChi2->GetXaxis()->GetNbins(); i++) kinematicEfficiencyChi2->SetBinError(1+i, 0.);
-                if(! UnfoldSpectrumChi2(
-                            resizedJetPtChi2,
-                            resizedResonseChi2,
-                            kinematicEfficiencyChi2,
-                            unfoldingTemplateChi2,  // prior for chi2 unfolding (measured)
-                            unfolded,               // will hold the result from chi2 (is prior for SVD)
-                            TString(Form("prior_%s", suffix.Data()))) ) {
-                    printf(" > UnfoldSVD:: panic, couldn't get prior from Chi2 unfolding! \n");
-                    printf("               probably Chi2 unfolding did not converge < \n");
-                    return kFALSE;
-                }
-                fBinsTrue = tempArrayTrue;  // reset bins borders
-                fBinsRec = tempArrayRec;
-                unfolded = RebinTH1D(unfolded, fBinsTrue, TString(Form("unfoldedChi2Prior_%s", suffix.Data())));     // rebin unfolded
-            } else if(! UnfoldSpectrumChi2(
-                        resizedJetPt,
-                        resizedResonse,
-                        kinematicEfficiency,
-                        unfoldingTemplate,      // prior for chi2 unfolding (measured)
-                        unfolded,               // will hold the result from chi2 (is prior for SVD)
-                        TString(Form("prior_%s", suffix.Data()))) ) {
-                printf(" > UnfoldSVD:: panic, couldn't get prior from Chi2 unfolding! \n");
-                printf("               probably Chi2 unfolding did not converge < \n");
-                return kFALSE;
-            }
-            if(!unfolded) {
-                printf(" > UnfoldSVD:: panic, Chi2 unfolding converged but the prior is NULL ! < " );
-                return kFALSE;
-            }
-            break;
-        }
-        case kPriorMeasured : { 
-            unfolded = (TH1D*)unfoldingTemplate->Clone(Form("kPriorMeasured_%s", suffix.Data()));       // copy template to unfolded to use as prior
-            if(fSmoothenSpectrum) unfolded = SmoothenSpectrum(unfolded, fPower, fFitMin, fFitMax, fFitStart);
-        }
-        default : break;
+    // unfold the spectrum using the bayesian unfolding impelmented in AliUnfolding
+    // FIXME careful, not tested yet ! (06122013) FIXME
+
+    // step 0) setup the static members of AliUnfolding
+    ResetAliUnfolding();                // reset from previous iteration
+                                        // also deletes and re-creates the global TVirtualFitter
+    AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
+    if(!strcmp("in", suffix.Data())) AliUnfolding::SetBayesianParameters(fBayesianSmoothIn, fBayesianIterIn);
+    else if(!strcmp("out", suffix.Data())) AliUnfolding::SetBayesianParameters(fBayesianSmoothOut, fBayesianIterOut);
+    else if(!strcmp("prior_in", suffix.Data())) AliUnfolding::SetBayesianParameters(fBayesianSmoothIn, fBayesianIterIn);
+    else if(!strcmp("prior_out", suffix.Data())) AliUnfolding::SetBayesianParameters(fBayesianSmoothOut, fBayesianIterOut);
+    AliUnfolding::SetNbins(fBinsRec->GetSize()-1, fBinsTrue->GetSize()-1);
+
+    // 1) get a prior for unfolding and clone all the input histograms
+    TH1D* priorLocal( GetPrior(
+        measuredJetSpectrum,              // jet pt in pt rec bins 
+        resizedResponse,                  // full response matrix, normalized in slides of pt true
+        kinematicEfficiency,              // kinematic efficiency
+        measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        suffix,                           // suffix (in, out)
+        jetFindingEfficiency));           // jet finding efficiency (optional)
+    if(!priorLocal) {
+        printf(" > couldn't find prior ! < \n");
+        return 0x0;
+    } else printf(" 1) retrieved prior \n");
+    // switch back to root dir of this unfolding procedure
+    (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) : fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
+
+    // measuredJetSpectrumLocal holds the spectrum that needs to be unfolded
+    TH1D *measuredJetSpectrumLocal = (TH1D*)measuredJetSpectrum->Clone(Form("measuredJetSpectrumLocal_%s", suffix.Data()));
+    // unfolded local will be filled with the result of the unfolding
+    TH1D *unfoldedLocal(new TH1D(Form("unfoldedLocal_%s", suffix.Data()), Form("unfoldedLocal_%s", suffix.Data()), fBinsTrue->GetSize()-1, fBinsTrue->GetArray()));
+
+    // full response matrix and kinematic efficiency
+    TH2D* resizedResponseLocal = (TH2D*)resizedResponse->Clone(Form("resizedResponseLocal_%s", suffix.Data()));
+    TH1D* kinematicEfficiencyLocal = (TH1D*)kinematicEfficiency->Clone(Form("kinematicEfficiencyLocal_%s", suffix.Data()));
+
+    // step 2) start the unfolding
+    Int_t status(-1), i(0);
+    while(status < 0 && i < 100) {
+        // i > 0 means that the first iteration didn't converge. in that case, the result of the first
+        // iteration (stored in unfoldedLocal) is cloned and used as a starting point for the 
+        if (i > 0) priorLocal = (TH1D*)unfoldedLocal->Clone(Form("priorLocal_%s_%i", suffix.Data(), i));
+        status = AliUnfolding::Unfold(
+                resizedResponseLocal,           // response matrix
+                kinematicEfficiencyLocal,       // efficiency applied on the unfolded spectrum (can be NULL)
+                measuredJetSpectrumLocal,              // measured spectrum
+                priorLocal,                     // initial conditions (set NULL to use measured spectrum)
+                unfoldedLocal);                 // results
+        // status holds the minuit fit status (where 0 means convergence)
+        i++;
     }
+    // get the status of TMinuit::mnhess(), fISW[1] == 3 means the hessian matrix was calculated succesfully
+    if(status == 0 && gMinuit->fISW[1] == 3) {
+        // if the unfolding converged and the hessian matrix is reliable, plot the pearson coefficients
+        TVirtualFitter *fitter(TVirtualFitter::GetFitter());
+        if(gMinuit) gMinuit->Command("SET COV");
+        TMatrixD covarianceMatrix(fBinsTrue->GetSize()-1, fBinsTrue->GetSize()-1, fitter->GetCovarianceMatrix());
+        TMatrixD *pearson((TMatrixD*)CalculatePearsonCoefficients(&covarianceMatrix));
+        pearson->Print();
+        TH2D *hPearson(new TH2D(*pearson));
+        hPearson->SetNameTitle(Form("PearsonCoefficients_%s", suffix.Data()), Form("Pearson coefficients, %s plane", suffix.Data()));
+        hPearson = ProtectHeap(hPearson);
+        hPearson->Write();
+    } else status = -1; 
+
+    // step 3) refold the unfolded spectrum and save the ratio measured / refolded
+    TH1D *foldedLocal(fResponseMaker->MultiplyResponseGenerated(unfoldedLocal, resizedResponseLocal,kinematicEfficiencyLocal));
+    foldedLocal->SetNameTitle(Form("RefoldedSpectrum_%s", suffix.Data()), Form("Refolded jet spectrum, %s plane", suffix.Data()));
+    unfoldedLocal->SetNameTitle(Form("UnfoldedSpectrum_%s", suffix.Data()), Form("Unfolded jet spectrum, %s plane", suffix.Data()));
+    TGraphErrors* ratio(GetRatio(foldedLocal, measuredJetSpectrumLocal, TString(""), kTRUE, fBinsTrue->At(fBinsTrue->GetSize()-1)));
+    if(ratio) {
+        ratio->SetNameTitle("RatioRefoldedMeasured", Form("Ratio measured, re-folded %s ", suffix.Data()));
+        ratio->GetYaxis()->SetTitle("ratio measured / re-folded");
+        ratio = ProtectHeap(ratio);
+        ratio->Write();
+    }
+
+    // step 4) write histograms to file. to ensure that these have unique identifiers on the heap, 
+    // objects are cloned using 'ProtectHeap()'
+    measuredJetSpectrumLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("InputSpectrum_%s", suffix.Data()));
+    measuredJetSpectrumLocal = ProtectHeap(measuredJetSpectrumLocal);
+    measuredJetSpectrumLocal->Write(); 
+
+    resizedResponseLocal = ProtectHeap(resizedResponseLocal);
+    resizedResponseLocal->Write();
+
+    unfoldedLocal = ProtectHeap(unfoldedLocal);
+    if(jetFindingEfficiency) unfoldedLocal->Divide(jetFindingEfficiency);
+    unfoldedLocal->Write();
+
+    foldedLocal = ProtectHeap(foldedLocal);
+    foldedLocal->Write();
+    
+    priorLocal = ProtectHeap(priorLocal);
+    priorLocal->Write();
+
+    // step 5) save the fit status (penalty value, degrees of freedom, chi^2 value)
+    TH1F* fitStatus(new TH1F(Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), 4, -0.5, 3.5));
+    fitStatus->SetBinContent(1, AliUnfolding::fChi2FromFit);
+    fitStatus->GetXaxis()->SetBinLabel(1, "fChi2FromFit");
+    fitStatus->SetBinContent(2, AliUnfolding::fPenaltyVal);
+    fitStatus->GetXaxis()->SetBinLabel(2, "fPenaltyVal");
+    fitStatus->SetBinContent(3, fBinsRec->GetSize()-fBinsTrue->GetSize());
+    fitStatus->GetXaxis()->SetBinLabel(3, "DOF");
+    fitStatus->SetBinContent(4, (!strcmp(suffix.Data(), "in")) ? fBetaIn : fBetaOut);
+    fitStatus->GetXaxis()->SetBinLabel(4, (!strcmp(suffix.Data(), "in")) ? "fBetaIn" : "fBetaOut");
+    fitStatus->Write();
+    return unfoldedLocal;
+}
+//_____________________________________________________________________________
+TH1D* AliJetFlowTools::UnfoldSpectrumBayesian(
+        const TH1D* measuredJetSpectrum,              // jet pt in pt rec bins 
+        const TH2D* resizedResponse,                  // full response matrix, normalized in slides of pt true
+        const TH1D* kinematicEfficiency,              // kinematic efficiency
+        const TH1D* measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        const TString suffix,                         // suffix (in, out)
+        const TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
+{
+    // use bayesian unfolding from the RooUnfold package to unfold jet spectra
+    
+    // 1) get a prior for unfolding.
+    TH1D* priorLocal( GetPrior(
+        measuredJetSpectrum,              // jet pt in pt rec bins 
+        resizedResponse,                  // full response matrix, normalized in slides of pt true
+        kinematicEfficiency,              // kinematic efficiency
+        measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        suffix,                           // suffix (in, out)
+        jetFindingEfficiency));           // jet finding efficiency (optional)
+    if(!priorLocal) {
+        printf(" > couldn't find prior ! < \n");
+        return 0x0;
+    } else printf(" 1) retrieved prior \n");
     (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) : fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-    cout << " 1) retrieved prior " << endl;
 
     // 2) setup all the necessary input for the unfolding routine. all input histograms are copied locally
-    // prior 
-    if(jetFindingEfficiency) unfolded->Divide(jetFindingEfficiency);
-    TH1D *unfoldedLocal((TH1D*)unfolded->Clone(Form("priorUnfolded_%s", suffix.Data())));
-    // raw jets in pt rec binning
-    TH1D *cachedRawJetLocal((TH1D*)resizedJetPt->Clone(Form("jets_%s", suffix.Data())));
-    // raw jets in pt true binning
-    TH1D *cachedRawJetLocalCoarse((TH1D*)unfoldingTemplate->Clone(Form("unfoldingTemplate_%s", suffix.Data())));
-    // copy of raw jets in pt true binning 
-    TH1D *cachedRawJetLocalCoarseOrig((TH1D*)cachedRawJetLocalCoarse->Clone(Form("cachedRawJetLocalCoarseOrig_%s", suffix.Data())));
-    // local copies response matrix
-    TH2D *cachedResponseLocal((TH2D*)resizedResonse->Clone(Form("cachedResponseLocal_%s", suffix.Data())));
+    // measured jets in pt rec binning
+    TH1D *measuredJetSpectrumLocal((TH1D*)measuredJetSpectrum->Clone(Form("jets_%s", suffix.Data())));
+    // local copie of the response matrix
+    TH2D *resizedResponseLocal((TH2D*)resizedResponse->Clone(Form("resizedResponseLocal_%s", suffix.Data())));
+    // local copy of response matrix, all true slides normalized to 1 
+    // this response matrix will eventually be used in the re-folding routine
+    TH2D *resizedResponseLocalNorm((TH2D*)resizedResponse->Clone(Form("resizedResponseLocalNorm_%s", suffix.Data())));
+    resizedResponseLocalNorm = NormalizeTH2D(resizedResponseLocalNorm);
     // kinematic efficiency
     TH1D *kinematicEfficiencyLocal((TH1D*)kinematicEfficiency->Clone(Form("kinematicEfficiency_%s", suffix.Data())));
     // place holder histos
-    TH1D *unfoldedLocalSVD(0x0);
-    TH1D *foldedLocalSVD(0x0);
+    TH1D *unfoldedLocalBayes(0x0);
+    TH1D *foldedLocalBayes(0x0);
     cout << " 2) setup necessary input " << endl;
-    // 3) configure routine
-    RooUnfold::ErrorTreatment errorTreatment = (fSVDToy) ? RooUnfold::kCovToy : RooUnfold::kCovariance;
-    // prior: use fit for where the histogram is sparsely filled 
-    if(fSmoothenSpectrum) cachedRawJetLocalCoarse = SmoothenSpectrum(cachedRawJetLocalCoarse, fPower, fFitMin, fFitMax, fFitStart);
-    if(fSmoothenSpectrum) cachedRawJetLocal = SmoothenSpectrum(cachedRawJetLocal, fPower, fFitMin, fFitMax, fFitStart);
-    if(fSmoothenSpectrum) unfoldedLocal = SmoothenSpectrum(unfoldedLocal, fPower, fFitMin, fFitMax, fFitStart);
-    cout << " 3) configured routine " << endl;
-    
-    // 4) get transpose matrices, where the y-axis corresponds to the true binning 
-    // and the x-axis to the measured binning
-    TH2* responseMatrixLocalTransposePrior(fResponseMaker->GetTransposeResponsMatrix(cachedResponseLocal));
+    // 4) get transpose matrices
+    // a) get the transpose of the full response matrix
+    TH2* responseMatrixLocalTransposePrior(fResponseMaker->GetTransposeResponsMatrix(resizedResponseLocal));
     responseMatrixLocalTransposePrior->SetNameTitle(Form("prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()),Form("prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()));
-    // normalize the transpose matrix with the prior in the y-direction (truth)
-    TH1D* tempUnfoldedLocal = static_cast<TH1D*>(unfoldedLocal->Clone("temp"));
-    tempUnfoldedLocal->Multiply(kinematicEfficiency);
-    responseMatrixLocalTransposePrior = fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, tempUnfoldedLocal);
-    delete tempUnfoldedLocal;
+    // normalize it with the prior. this will ensure that high statistics bins will constrain the
+    // end result most strenuously than bins with limited number of counts
+    responseMatrixLocalTransposePrior = fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, priorLocal);
+    // 3) get response for Bayesian unfolding
+    RooUnfoldResponse responseBayes(0, 0, responseMatrixLocalTransposePrior, Form("respCombinedBayes_%s", suffix.Data()), Form("respCombinedBayes_%s", suffix.Data()));
 
-    // get the jet spectrum response matrix in the form of a RooUnfoldResponse object
-    RooUnfoldResponse responseSVD(0, unfoldedLocal, responseMatrixLocalTransposePrior, Form("respCombinedSVD_%s", suffix.Data()), Form("respCombinedSVD_%s", suffix.Data()));
-
-    // change to inplane dir
-    (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) :fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-    cout << " 5) retrieved roo unfold response object " << endl;
-
-    RooUnfoldSvd unfoldSVD(&responseSVD, cachedRawJetLocal, (!strcmp(suffix.Data(), "in")) ? fSVDRegIn : fSVDRegOut);
-    unfoldedLocalSVD = (TH1D*)unfoldSVD.Hreco(errorTreatment);
-
-    TMatrixD covarianceMatrix = unfoldSVD.Ereco(errorTreatment);
+    // 4) actualy unfolding loop
+    RooUnfoldBayes unfoldBayes(&responseBayes, measuredJetSpectrumLocal, (!strcmp("in", suffix.Data())) ? fBayesianIterIn : fBayesianIterOut);
+    RooUnfold::ErrorTreatment errorTreatment = (fSVDToy) ? RooUnfold::kCovToy : RooUnfold::kCovariance;
+    unfoldedLocalBayes = (TH1D*)unfoldBayes.Hreco(errorTreatment);
+    // correct the spectrum for the kinematic efficiency
+    unfoldedLocalBayes->Divide(kinematicEfficiencyLocal);
+    // get the pearson coefficients from the covariance matrix
+    TMatrixD covarianceMatrix = unfoldBayes.Ereco(errorTreatment);
     TMatrixD *pearson = (TMatrixD*)CalculatePearsonCoefficients(&covarianceMatrix);
-    cout << " Pearson coeffs" << endl;
-    // create the unfolding qa plots
-    cout << " 6) unfolded spectrum " << endl;
     if(pearson) {
-        TH2D* hPearson = new TH2D(*pearson);
+        TH2D* hPearson(new TH2D(*pearson));
         pearson->Print();
         hPearson->SetNameTitle(Form("PearsonCoefficients_%s", suffix.Data()), Form("Pearson coefficients_%s", suffix.Data()));
         hPearson = ProtectHeap(hPearson);
         hPearson->Write();
-    } else return kFALSE;       // return if unfolding didn't converge
-    // correct for the efficiency
-    unfoldedLocalSVD->Divide(kinematicEfficiencyLocal);
-    // plot singular values and d_i vector
-    TSVDUnfold* svdUnfold(unfoldSVD.Impl());
-    TH1* hSVal(svdUnfold->GetSV());
-    TH1D* hdi(svdUnfold->GetD());
-    hSVal->SetNameTitle("SingularValuesOfAC", "Singular values of AC^{-1}");
-    hSVal->SetXTitle("singular values");
-    hSVal->Write();
-    hdi->SetNameTitle("dVector", "d vector after orthogonal transformation");
-    hdi->SetXTitle("|d_{i}^{kreg}|");
-    hdi->Write();
-    cout << " plotted singular values and d_i vector " << endl;
+    } else return 0x0;       // return if unfolding didn't converge
 
-    // 7 refold the unfolded spectrum with the RooUnfold object
-    TH1D* unfolded_eff = static_cast<TH1D*>(unfoldedLocalSVD->Clone("unfolded_eff"));
-    unfolded_eff->Multiply(kinematicEfficiencyLocal);
-    RooUnfoldResponse rooRefold(0, 0, responseMatrixLocalTransposePrior, Form("rooRefold_%s", suffix.Data()), Form("rooRefold_%s", suffix.Data()));
-    foldedLocalSVD = static_cast<TH1D*>(rooRefold.ApplyToTruth(unfolded_eff, "refolded"));
-    delete unfolded_eff;
-    TGraphErrors* ratio(GetRatio(cachedRawJetLocal, foldedLocalSVD, "ratio  measured / re-folded", kTRUE));
-    ratio->SetName(Form("RatioRefoldedMeasured_%s", fActiveString.Data()));
+    // 5) refold the unfolded spectrum
+    foldedLocalBayes = fResponseMaker->MultiplyResponseGenerated(unfoldedLocalBayes, resizedResponseLocalNorm, kinematicEfficiencyLocal);
+    TGraphErrors* ratio(GetRatio(measuredJetSpectrumLocal, foldedLocalBayes, "ratio  measured / re-folded", kTRUE));
+    ratio->SetNameTitle(Form("RatioRefoldedMeasured_%s", fActiveString.Data()), Form("Ratio measured / re-folded %s", fActiveString.Data()));
     ratio->GetXaxis()->SetTitle("p_{t}^{rec, rec} [GeV/ c]");
     ratio->GetYaxis()->SetTitle("ratio measured / re-folded");
     ratio->Write();
     cout << " 7) refolded the unfolded spectrum " << endl;
 
-    // write to output
-    cachedRawJetLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("input spectrum (measured) %s", suffix.Data()));
-    cachedRawJetLocal = ProtectHeap(cachedRawJetLocal);
-    cachedRawJetLocal->SetXTitle("p_{t}^{rec} [GeV/c]");
-    cachedRawJetLocal->Write(); // input spectrum
-    unfoldedLocalSVD->SetNameTitle(Form("UnfoldedSpectrum_%s",suffix.Data()), Form("unfolded spectrum %s", suffix.Data()));
-    unfoldedLocalSVD = ProtectHeap(unfoldedLocalSVD);
-    if(jetFindingEfficiency) unfoldedLocalSVD->Divide(jetFindingEfficiency);
-    unfoldedLocalSVD->Write();  // unfolded spectrum
-    foldedLocalSVD->SetNameTitle(Form("RefoldedSpectrum_%s", suffix.Data()), Form("refoldedSpectrum_%s", suffix.Data()));
-    foldedLocalSVD = ProtectHeap(foldedLocalSVD);
-    foldedLocalSVD->Write();    // re-folded spectrum
-   // switch back to active root directory
-    (!strcmp(suffix.Data(), "in")) ? fActiveDir->cd(Form("InPlane___%s", fActiveString.Data())) :fActiveDir->cd(Form("OutOfPlane___%s", fActiveString.Data()));
-    responseMatrixLocalTransposePrior->SetNameTitle("TransposeResponseMatrix", "Transpose of response matrix");
+    // write the measured, unfolded and re-folded spectra to the output directory
+    measuredJetSpectrumLocal->SetNameTitle(Form("InputSpectrum_%s", suffix.Data()), Form("input spectrum (measured) %s", suffix.Data()));
+    measuredJetSpectrumLocal = ProtectHeap(measuredJetSpectrumLocal);
+    measuredJetSpectrumLocal->SetXTitle("p_{t}^{rec} [GeV/c]");
+    measuredJetSpectrumLocal->Write(); // input spectrum
+    unfoldedLocalBayes->SetNameTitle(Form("UnfoldedSpectrum_%s",suffix.Data()), Form("unfolded spectrum %s", suffix.Data()));
+    unfoldedLocalBayes = ProtectHeap(unfoldedLocalBayes);
+    if(jetFindingEfficiency) unfoldedLocalBayes->Divide(jetFindingEfficiency);
+    unfoldedLocalBayes->Write();  // unfolded spectrum
+    foldedLocalBayes->SetNameTitle(Form("RefoldedSpectrum_%s", suffix.Data()), Form("refoldedSpectrum_%s", suffix.Data()));
+    foldedLocalBayes = ProtectHeap(foldedLocalBayes);
+    foldedLocalBayes->Write();    // re-folded spectrum
+
+    // save more general bookkeeeping histograms to the output directory
+    responseMatrixLocalTransposePrior->SetNameTitle("TransposeResponseMatrix", "Transpose of response matrix, normalize with prior");
     responseMatrixLocalTransposePrior->SetXTitle("p_{T}^{true} [GeV/c]");
     responseMatrixLocalTransposePrior->SetYTitle("p_{T}^{rec} [GeV/c]");
     responseMatrixLocalTransposePrior->Write();
-    cachedRawJetLocal->SetNameTitle("PriorOriginal", "Prior, original");
-    cachedRawJetLocal->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarse->SetNameTitle("PriorSmoothened", "Prior, smoothened");
-    cachedRawJetLocalCoarse->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarse->Write();
-    cachedRawJetLocalCoarseOrig->SetNameTitle("Prior", "Prior");
-    cachedRawJetLocalCoarseOrig->SetXTitle("p_{t} [GeV/c]");
-    cachedRawJetLocalCoarseOrig->Write();
-    unfolded = unfoldedLocalSVD; 
+    priorLocal->SetNameTitle("PriorOriginal", "Prior, original");
+    priorLocal->SetXTitle("p_{t} [GeV/c]");
+    priorLocal = ProtectHeap(priorLocal);
+    priorLocal->Write();
+    resizedResponseLocalNorm = ProtectHeap(resizedResponseLocalNorm);
+    resizedResponseLocalNorm->Write();
 
     // save some info 
     TH1F* fitStatus(new TH1F(Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), Form("fitStatus_%s_%s", fActiveString.Data(), suffix.Data()), 1, -0.5, 0.5));
-    fitStatus->SetBinContent(1, (!strcmp(suffix.Data(), "in")) ? fSVDRegIn : fSVDRegOut);
-    fitStatus->GetXaxis()->SetBinLabel(1, (!strcmp(suffix.Data(), "in")) ? "fSVDRegIn" : "fSVDRegOut");
+    fitStatus->SetBinContent(1, (!strcmp(suffix.Data(), "in")) ? fBayesianIterIn : fBayesianIterOut);
+    fitStatus->GetXaxis()->SetBinLabel(1, (!strcmp(suffix.Data(), "in")) ? "fBayesianIterIn" : "fBayesianIterOut");
     fitStatus->Write();
 
-    return (unfoldedLocalSVD) ? kTRUE : kFALSE;
+    return  unfoldedLocalBayes; 
 }
 //_____________________________________________________________________________
 Bool_t AliJetFlowTools::PrepareForUnfolding()
@@ -909,22 +885,20 @@ Bool_t AliJetFlowTools::PrepareForUnfolding()
         printf(" AliJetFlowTools::PrepareForUnfolding() fInputList not found \n - Set a list using AliJetFlowTools::SetInputList() \n");
         return kFALSE;
     }
-    if(!fDetectorResponse) {
-        printf(" AliJetFlowTools::PrepareForUnfolding() fDetectorResponse not found \n - Set detector response using AliJetFlowTools::SetDetectorResponse() \n ");
-        return kFALSE;
-    }
+    if(!fDetectorResponse) printf(" WARNING, no detector response supplied ! May be ok (depending on what you want to do) \n ");
     // check if the pt bin for true and rec have been set
     if(!fBinsTrue || !fBinsRec) {
         printf(" AliJetFlowTools::PrepareForUnfolding() no true or rec bins set, aborting ! \n");
         return kFALSE;
     }
-    if(!fRMSSpectrumIn) { // initialie the profiles which will hold the RMS values. if binning changes in between unfolding
+    if(!fRMSSpectrumIn && fInOutUnfolding) { // initialie the profiles which will hold the RMS values. if binning changes in between unfolding
                           // procedures, these profiles will be nonsensical, user is responsible
         fRMSSpectrumIn = new TProfile("fRMSSpectrumIn", "fRMSSpectrumIn", fBinsTrue->GetSize()-1, fBinsTrue->GetArray());
         fRMSSpectrumOut = new TProfile("fRMSSpectrumOut", "fRMSSpectrumOut", fBinsTrue->GetSize()-1, fBinsTrue->GetArray());
         fRMSRatio = new TProfile("fRMSRatio", "fRMSRatio", fBinsTrue->GetSize()-1, fBinsTrue->GetArray());
     }
     if(!fTrainPower) {
+        // clear minuit state to avoid constraining the fit with the results of the previous iteration
         for(Int_t i(0); i < fPower->GetNpar(); i++) fPower->SetParameter(i, 0.);
     }
     // extract the spectra
@@ -936,15 +910,15 @@ Bool_t AliJetFlowTools::PrepareForUnfolding()
     }
     fJetPtDeltaPhi = ProtectHeap(fJetPtDeltaPhi, kFALSE);
     // in plane spectrum
-    if(fNoDphi) {
-        fSpectrumIn = fJetPtDeltaPhi->ProjectionY(Form("_py_in_%s", spectrumName.Data()), 1, 40);
-        fSpectrumOut = fJetPtDeltaPhi->ProjectionY(Form("_py_out_%s", spectrumName.Data()), 1, 40);
+    if(!fInOutUnfolding) {
+        fSpectrumIn = fJetPtDeltaPhi->ProjectionY(Form("_py_in_%s", spectrumName.Data()), 1, 40, "e");
+        fSpectrumOut = fJetPtDeltaPhi->ProjectionY(Form("_py_out_%s", spectrumName.Data()), 1, 40, "e");
     } else {
-        fSpectrumIn = fJetPtDeltaPhi->ProjectionY(Form("_py_ina_%s", spectrumName.Data()), 1, 10);
-        fSpectrumIn->Add(fJetPtDeltaPhi->ProjectionY(Form("_py_inb_%s", spectrumName.Data()), 31, 40));
+        fSpectrumIn = fJetPtDeltaPhi->ProjectionY(Form("_py_ina_%s", spectrumName.Data()), 1, 10, "e");
+        fSpectrumIn->Add(fJetPtDeltaPhi->ProjectionY(Form("_py_inb_%s", spectrumName.Data()), 31, 40, "e"));
         fSpectrumIn = ProtectHeap(fSpectrumIn);
         // out of plane spectrum
-        fSpectrumOut = fJetPtDeltaPhi->ProjectionY(Form("_py_out_%s", spectrumName.Data()), 11, 30);
+        fSpectrumOut = fJetPtDeltaPhi->ProjectionY(Form("_py_out_%s", spectrumName.Data()), 11, 30, "e");
         fSpectrumOut = ProtectHeap(fSpectrumOut);
     }
     // normalize spectra to event count if requested
@@ -978,21 +952,24 @@ Bool_t AliJetFlowTools::PrepareForUnfolding()
         if(normalizeToFullSpectrum) fEventCount = -1;
     }
     // extract the delta pt matrices
-    TString deltaptName(Form("fHistDeltaPtDeltaPhi2_%i", fCentralityBin));
+    TString deltaptName(Form("fHistDeltaPtDeltaPhi2ExLJ_%i", fCentralityBin));
     fDeltaPtDeltaPhi = ((TH2D*)fInputList->FindObject(deltaptName.Data()));
     if(!fDeltaPtDeltaPhi) {
         printf(" Couldn't find delta pt matrix %s ! \n", deltaptName.Data());
+        printf(" > may be ok, depending no what you want to do < \n");
+        fRefreshInput = kTRUE;
+        return kTRUE;
     }
     fDeltaPtDeltaPhi = ProtectHeap(fDeltaPtDeltaPhi, kFALSE);
     // in plane delta pt distribution
-    if(fNoDphi) {
-        fDptInDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_in_%s", deltaptName.Data()), 1, 40);
-        fDptOutDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_out_%s", deltaptName.Data()), 1, 40);
+    if(!fInOutUnfolding) {
+        fDptInDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_in_%s", deltaptName.Data()), 1, 40, "e");
+        fDptOutDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_out_%s", deltaptName.Data()), 1, 40, "e");
     } else {
-        fDptInDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_ina_%s", deltaptName.Data()), 1, 10);
-        fDptInDist->Add(fDeltaPtDeltaPhi->ProjectionY(Form("_py_inb_%s", deltaptName.Data()), 31, 40));
+        fDptInDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_ina_%s", deltaptName.Data()), 1, 10, "e");
+        fDptInDist->Add(fDeltaPtDeltaPhi->ProjectionY(Form("_py_inb_%s", deltaptName.Data()), 31, 40, "e"));
         // out of plane delta pt distribution
-        fDptOutDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_out_%s", deltaptName.Data()), 11, 30);
+        fDptOutDist = fDeltaPtDeltaPhi->ProjectionY(Form("_py_out_%s", deltaptName.Data()), 11, 30, "e");
         fDptInDist = ProtectHeap(fDptInDist);
         fDptOutDist = ProtectHeap(fDptOutDist);
         // TODO get dpt response matrix from ConstructDPtResponseFromTH1D
@@ -1030,6 +1007,75 @@ Bool_t AliJetFlowTools::PrepareForUnfolding()
     return kTRUE;
 }
 //_____________________________________________________________________________
+TH1D* AliJetFlowTools::GetPrior(
+        const TH1D* measuredJetSpectrum,              // jet pt in pt rec bins 
+        const TH2D* resizedResponse,                  // full response matrix, normalized in slides of pt true
+        const TH1D* kinematicEfficiency,              // kinematic efficiency
+        const TH1D* measuredJetSpectrumTrueBins,      // jet pt in pt true bins, also the prior when measured is chosen as prior
+        const TString suffix,                         // suffix (in, out)
+        const TH1D* jetFindingEfficiency)             // jet finding efficiency (optional)
+{
+    // 1) get a prior for unfolding. 
+    // this can be either an unfolded spectrum from e.g. chi2 unfolding or the measured spectrum
+    TH1D* unfolded(0x0);
+    TDirectoryFile* dirOut = new TDirectoryFile(Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()), Form("Prior_%s___%s", suffix.Data(), fActiveString.Data()));
+    dirOut->cd();
+    switch (fPrior) {    // select the prior for unfolding
+        case kPriorChi2 : {
+            if(fBinsTruePrior && fBinsRecPrior) {       // if set, use different binning for the prior
+                TArrayD* tempArrayTrue(fBinsTrue);      // temporarily cache the original binning
+                fBinsTrue = fBinsTruePrior;             // switch binning schemes (will be used in UnfoldSpectrumChi2())
+                TArrayD* tempArrayRec(fBinsRec);
+                fBinsRec = fBinsRecPrior;
+                TH1D* measuredJetSpectrumChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsRec, TString("resized_chi2"), kFALSE);
+                TH1D* measuredJetSpectrumTrueBinsChi2 = RebinTH1D((!strcmp("in", suffix.Data())) ? fSpectrumIn : fSpectrumOut, fBinsTruePrior, TString("out"), kFALSE);
+                TH2D* resizedResponseChi2(RebinTH2D((!strcmp("in", suffix.Data())) ? fFullResponseIn : fFullResponseOut,fBinsTruePrior, fBinsRec, TString("chi2")));
+                TH1D* kinematicEfficiencyChi2(resizedResponseChi2->ProjectionX());
+                kinematicEfficiencyChi2->SetNameTitle("kin_eff_chi2","kin_eff_chi2");
+                for(Int_t i(0); i < kinematicEfficiencyChi2->GetXaxis()->GetNbins(); i++) kinematicEfficiencyChi2->SetBinError(1+i, 0.);
+                unfolded= UnfoldSpectrumChi2(
+                            measuredJetSpectrumChi2,
+                            resizedResponseChi2,
+                            kinematicEfficiencyChi2,
+                            measuredJetSpectrumTrueBinsChi2,    // prior for chi2 unfolding (measured)
+                            TString(Form("prior_%s", suffix.Data())));
+               if(!unfolded) {
+                    printf(" > GetPrior:: panic, couldn't get prior from Chi2 unfolding! \n");
+                    printf("               probably Chi2 unfolding did not converge < \n");
+                    return 0x0;
+                }
+                fBinsTrue = tempArrayTrue;  // reset bins borders
+                fBinsRec = tempArrayRec;
+                // if the chi2 prior has a different binning, rebin to the true binning for the  unfolding
+                unfolded = RebinTH1D(unfolded, fBinsTrue, TString(Form("unfoldedChi2Prior_%s", suffix.Data())));     // rebin unfolded
+            } else {
+                unfolded = UnfoldSpectrumChi2(
+                            measuredJetSpectrum,
+                            resizedResponse,
+                            kinematicEfficiency,
+                            measuredJetSpectrumTrueBins,        // prior for chi2 unfolding (measured)
+                            TString(Form("prior_%s", suffix.Data())));
+                if(!unfolded) {
+                    printf(" > GetPrior:: panic, couldn't get prior from Chi2 unfolding! \n");
+                    printf("               probably Chi2 unfolding did not converge < \n");
+                    return 0x0;
+                }
+            }
+            break;
+        }
+        case kPriorMeasured : { 
+            unfolded = (TH1D*)measuredJetSpectrumTrueBins->Clone(Form("kPriorMeasured_%s", suffix.Data()));       // copy template to unfolded to use as prior
+        }
+        default : break;
+    }
+    // it can be important that the prior is smooth, this can be achieved by 
+    // extrapolating the spectrum with a fitted power law when bins are sparsely filed 
+    if(jetFindingEfficiency) unfolded->Divide(jetFindingEfficiency);
+    TH1D *priorLocal((TH1D*)unfolded->Clone(Form("priorUnfolded_%s", suffix.Data())));
+    if(fSmoothenPrior) priorLocal = SmoothenPrior(priorLocal, fPower, fFitMin, fFitMax, fFitStart, kTRUE, fSmoothenCounts);
+    return priorLocal;
+}
+//_____________________________________________________________________________
 TH1D* AliJetFlowTools::ResizeXaxisTH1D(TH1D* histo, Int_t low, Int_t up, TString suffix) {
     // resize the x-axis of a th1d
     if(!histo) {
@@ -1075,7 +1121,7 @@ TH2D* AliJetFlowTools::ResizeYaxisTH2D(TH2D* histo, TArrayD* x, TArrayD* y, TStr
     return resized;
 }
 //_____________________________________________________________________________
-TH2D* AliJetFlowTools::NormalizeTH2D(TH2D* histo) {
+TH2D* AliJetFlowTools::NormalizeTH2D(TH2D* histo, Bool_t noError) {
     // general method to normalize all vertical slices of a th2 to unity
     // i.e. get a probability matrix
     if(!histo) {
@@ -1094,7 +1140,8 @@ TH2D* AliJetFlowTools::NormalizeTH2D(TH2D* histo) {
         for(Int_t j(0); j < binsY; j++) {
             if (weight <= 0 ) continue;
             histo->SetBinContent(1+i, j+1, histo->GetBinContent(1+i, j+1)/weight);
-            histo->SetBinError(  1+i, j+1, histo->GetBinError(  1+i, j+1)/weight);
+            if(noError) histo->SetBinError(  1+i, j+1, 0.);
+            else histo->SetBinError(  1+i, j+1, histo->GetBinError(  1+i, j+1)/weight);
         }
     }
     return histo;
@@ -1143,6 +1190,7 @@ TH2D* AliJetFlowTools::MatrixMultiplication(TH2D* a, TH2D* b, TString name)
                val += a->GetBinContent(x1, y1) * b->GetBinContent(x2, y2);
             }
             c->SetBinContent(x2, y1, val);
+            c->SetBinError(x2, y1, 0.);
         }
     }
     if(strcmp(name.Data(), "")) c->SetNameTitle(name.Data(), name.Data());
@@ -1176,15 +1224,17 @@ TMatrixD* AliJetFlowTools::CalculatePearsonCoefficients(TMatrixD* covarianceMatr
     return pearsonCoefficients;
 }
 //_____________________________________________________________________________
-TH1D* AliJetFlowTools::SmoothenSpectrum(TH1D* spectrum, TF1* function, Double_t min, Double_t max, Double_t start, Bool_t kill, Bool_t counts) {
+TH1D* AliJetFlowTools::SmoothenPrior(TH1D* spectrum, TF1* function, Double_t min, Double_t max, Double_t start, Bool_t kill, Bool_t counts) {
     // smoothen the spectrum using a user defined function
     // returns a clone of the original spectrum if fitting failed
     // if kill is kTRUE the input spectrum will be deleted from the heap
     // if 'count' is selected, bins are filled with integers (necessary if the 
     // histogram is interpreted in a routine which accepts only counts)
+    if(!spectrum || !function) return 0x0;
+    if(start > max) printf(" > cannot extrapolate fit beyond fit range ! < " );
     TH1D* temp = (TH1D*)spectrum->Clone(Form("%s_smoothened", spectrum->GetName()));
     temp->Sumw2();      // if already called on the original, this will give off a warning but do nothing
-    TFitResultPtr r = temp->Fit(function, "QWILS", "", min, max);
+    TFitResultPtr r = temp->Fit(function, "WLIS", "", min, max);
     if((int)r == 0) {   // MINUIT status
         for(Int_t i(0); i < temp->GetNbinsX() + 1; i++) {
             if(temp->GetBinCenter(i) > start) {     // from this pt value use extrapolation
@@ -1334,7 +1384,7 @@ void AliJetFlowTools::Style(TGraph* h, EColor col, histoType type)
     }
 }
 //_____________________________________________________________________________
-void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t columns) 
+void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t columns) const
 {
    // go through the output file and perform post processing routines
    // can either be performed in one go with the unfolding, or at a later stage
@@ -1353,17 +1403,23 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
    }
    // prepare necessary canvasses
    TCanvas* canvasIn(new TCanvas("PearsonIn", "PearsonIn"));
-   TCanvas* canvasOut(new TCanvas("PearsonOut", "PearsonOut"));
+   TCanvas* canvasOut(0x0);
+   if(fInOutUnfolding) canvasOut = new TCanvas("PearsonOut", "PearsonOut");
    TCanvas* canvasRatioMeasuredRefoldedIn(new TCanvas("RefoldedIn", "RefoldedIn"));
-   TCanvas* canvasRatioMeasuredRefoldedOut(new TCanvas("RefoldedOut", "RefoldedOut"));
+   TCanvas* canvasRatioMeasuredRefoldedOut(0x0);
+   if(fInOutUnfolding) canvasRatioMeasuredRefoldedOut = new TCanvas("RefoldedOut", "RefoldedOut");
    TCanvas* canvasSpectraIn(new TCanvas("SpectraIn", "SpectraIn")); 
-   TCanvas* canvasSpectraOut(new TCanvas("SpectraOut", "SpectraOut"));
-   TCanvas* canvasRatio(new TCanvas("Ratio", "Ratio"));
-   TCanvas* canvasV2(new TCanvas("V2", "V2"));
+   TCanvas* canvasSpectraOut(0x0);
+   if(fInOutUnfolding) canvasSpectraOut = new TCanvas("SpectraOut", "SpectraOut");
+   TCanvas* canvasRatio(0x0);
+   if(fInOutUnfolding) canvasRatio = new TCanvas("Ratio", "Ratio");
+   TCanvas* canvasV2(0x0);
+   if(fInOutUnfolding) canvasV2 = new TCanvas("V2", "V2");
    TCanvas* canvasMISC(new TCanvas("MISC", "MISC"));
    TCanvas* canvasMasterIn(new TCanvas("defaultIn", "defaultIn"));
-   TCanvas* canvasMasterOut(new TCanvas("defaultOut", "defaultOut"));
-   canvasMISC->Divide(4, 2);
+   TCanvas* canvasMasterOut(0x0);
+   if(fInOutUnfolding) canvasMasterOut = new TCanvas("defaultOut", "defaultOut");
+   (fInOutUnfolding) ? canvasMISC->Divide(4, 2) : canvasMISC->Divide(4, 1);
    TDirectoryFile* defDir(0x0);
    
    // get an estimate of the number of outputs and find the default set
@@ -1374,30 +1430,26 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
            cacheMe++;
        }
    }
-   Int_t rows(TMath::Floor(cacheMe/(float)columns)+((cacheMe%4)>0));
+   Int_t rows(TMath::Floor(cacheMe/(float)columns)/*+((cacheMe%4)>0)*/);
    canvasIn->Divide(columns, rows);
-   canvasOut->Divide(columns, rows);
+   if(canvasOut) canvasOut->Divide(columns, rows);
    canvasRatioMeasuredRefoldedIn->Divide(columns, rows);
-   canvasRatioMeasuredRefoldedOut->Divide(columns, rows);
+   if(canvasRatioMeasuredRefoldedOut) canvasRatioMeasuredRefoldedOut->Divide(columns, rows);
    canvasSpectraIn->Divide(columns, rows);
-   canvasSpectraOut->Divide(columns, rows);
-   canvasRatio->Divide(columns, rows);
-   canvasV2->Divide(columns, rows);
+   if(canvasSpectraOut) canvasSpectraOut->Divide(columns, rows);
+   if(canvasRatio) canvasRatio->Divide(columns, rows);
+   if(canvasV2) canvasV2->Divide(columns, rows);
 
    canvasMasterIn->Divide(columns, rows);
-   canvasMasterOut->Divide(columns, rows);
+   if(canvasMasterOut) canvasMasterOut->Divide(columns, rows);
    // extract the default output 
-   TH1D* defUnfoldedIn(0x0);
-   TH1D* defUnfoldedOut(0x0);
-   THStack stackIn("StackRatioIn","StackRatioIn");
-   THStack stackOut("StackRatioOut", "StackRatioOut");
+   TH1D* deunfoldedJetSpectrumIn(0x0);
+   TH1D* deunfoldedJetSpectrumOut(0x0);
    if(defDir) {
        TDirectoryFile* defDirIn = (TDirectoryFile*)defDir->Get(Form("InPlane___%s", def.Data()));
        TDirectoryFile* defDirOut = (TDirectoryFile*)defDir->Get(Form("OutOfPlane___%s", def.Data()));
-       if(defDirIn) defUnfoldedIn = (TH1D*)defDirIn->Get(Form("UnfoldedSpectrum_in_%s", def.Data()));
-       if(defUnfoldedIn) stackIn.Add(defUnfoldedIn);
-       if(defDirOut) defUnfoldedOut = (TH1D*)defDirOut->Get(Form("UnfoldedSpectrum_out_%s", def.Data()));
-       if(defUnfoldedOut) stackOut.Add(defUnfoldedOut);
+       if(defDirIn) deunfoldedJetSpectrumIn = (TH1D*)defDirIn->Get(Form("UnfoldedSpectrum_in_%s", def.Data()));
+       if(defDirOut) deunfoldedJetSpectrumOut = (TH1D*)defDirOut->Get(Form("UnfoldedSpectrum_out_%s", def.Data()));
        printf(" > succesfully extracted default results < \n");
    }
  
@@ -1461,8 +1513,8 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
            TH1D* unfoldedSpectrum((TH1D*)tempIn->Get(Form("UnfoldedSpectrum_in_%s", dirName.Data())));
            TH1D* refoldedSpectrum((TH1D*)tempIn->Get(Form("RefoldedSpectrum_in_%s", dirName.Data())));
            if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
-               if(defUnfoldedIn) {
-                   TH1D* temp((TH1D*)defUnfoldedIn->Clone(Form("defUnfoldedIn_%s", dirName.Data())));
+               if(deunfoldedJetSpectrumIn) {
+                   TH1D* temp((TH1D*)deunfoldedJetSpectrumIn->Clone(Form("deunfoldedJetSpectrumIn_%s", dirName.Data())));
                    temp->Divide(unfoldedSpectrum);
                    temp->SetTitle(Form("ratio default unfolded / %s", dirName.Data()));
                    temp->GetXaxis()->SetTitle("p_{T} [GeV/c]");
@@ -1531,10 +1583,10 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
                } else if(rm && eff) {
                    Style(rm);
                    Style(eff);
-                   canvasMISC->cd(3);
+                   canvasMISC->cd(7);
                    Style(gPad, "PEARSON");
                    rm->DrawCopy("colz");
-                   canvasMISC->cd(4);
+                   canvasMISC->cd(8);
                    eff->DrawCopy();
                }
            }
@@ -1542,8 +1594,8 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
            TH1D* unfoldedSpectrum((TH1D*)tempOut->Get(Form("UnfoldedSpectrum_out_%s", dirName.Data())));
            TH1D* refoldedSpectrum((TH1D*)tempOut->Get(Form("RefoldedSpectrum_out_%s", dirName.Data())));
            if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
-               if(defUnfoldedOut) {
-                   TH1D* temp((TH1D*)defUnfoldedOut->Clone(Form("defUnfoldedOut_%s", dirName.Data())));
+               if(deunfoldedJetSpectrumOut) {
+                   TH1D* temp((TH1D*)deunfoldedJetSpectrumOut->Clone(Form("deunfoldedJetSpectrumOut_%s", dirName.Data())));
                    temp->Divide(unfoldedSpectrum);
                    temp->SetTitle(Form("ratio default unfolded / %s", dirName.Data()));
                    temp->GetXaxis()->SetTitle("p_{T} [GeV/c]");
@@ -1575,30 +1627,53 @@ void AliJetFlowTools::PostProcess(TString def, TString in, TString out, Int_t co
                }
            }
        }
-       canvasRatio->cd(j);
-       TGraphErrors* ratioYield((TGraphErrors*)tempDir->Get(Form("RatioInOutPlane_%s", dirName.Data())));
-       if(ratioYield) {
-           Style(ratioYield);
-           ratioYield->Draw("ac");
-       }
-       canvasV2->cd(j);
-       TGraphErrors* ratioV2((TGraphErrors*)tempDir->Get(Form("v2_%s", dirName.Data())));
-       if(ratioV2) {
-           Style(ratioV2);
-           ratioV2->Draw("ac");
+       if(canvasRatio && canvasV2) {
+           canvasRatio->cd(j);
+           TGraphErrors* ratioYield((TGraphErrors*)tempDir->Get(Form("RatioInOutPlane_%s", dirName.Data())));
+           if(ratioYield) {
+               Style(ratioYield);
+               ratioYield->GetYaxis()->SetRangeUser(-1., 3.);
+               ratioYield->Draw("ac");
+           }
+           canvasV2->cd(j);
+           TGraphErrors* ratioV2((TGraphErrors*)tempDir->Get(Form("v2_%s", dirName.Data())));
+           if(ratioV2) {
+               Style(ratioV2);
+               ratioV2->GetYaxis()->SetRangeUser(-.25, .75);
+               ratioV2->Draw("ac");
+           }
        }
    }
    TFile output(out.Data(), "RECREATE");
+   SavePadToPDF(canvasIn);
    canvasIn->Write();
-   canvasOut->Write();
+   if(canvasOut) {
+       SavePadToPDF(canvasOut);
+       canvasOut->Write();
+   }
+   SavePadToPDF(canvasRatioMeasuredRefoldedIn);
    canvasRatioMeasuredRefoldedIn->Write();
-   canvasRatioMeasuredRefoldedOut->Write();
+   if(canvasRatioMeasuredRefoldedOut) {
+       SavePadToPDF(canvasRatioMeasuredRefoldedOut);
+       canvasRatioMeasuredRefoldedOut->Write();
+   }
+   SavePadToPDF(canvasSpectraIn);
    canvasSpectraIn->Write();
-   canvasSpectraOut->Write();
-   canvasRatio->Write();
-   canvasV2->Write();
+   if(canvasSpectraOut) {
+       SavePadToPDF(canvasSpectraOut);
+       canvasSpectraOut->Write();
+       SavePadToPDF(canvasRatio);
+       canvasRatio->Write();
+       SavePadToPDF(canvasV2);
+       canvasV2->Write();
+   }
+   SavePadToPDF(canvasMasterIn);
    canvasMasterIn->Write();
-   canvasMasterOut->Write();
+   if(canvasMasterOut) {
+       SavePadToPDF(canvasMasterOut);
+       canvasMasterOut->Write();
+   }
+   SavePadToPDF(canvasMISC);
    canvasMISC->Write();
    output.Write();
    output.Close();
@@ -1704,7 +1779,8 @@ TGraphErrors* AliJetFlowTools::GetV2(TH1 *h1, TH1* h2, Double_t r, TString name)
 {
     // get v2 from difference of in plane, out of plane yield
     // h1 must hold the in-plane yield, h2 holds the out of plane  yield
-    // different binning is allowed
+    // different binning is allowed but will mean that the error
+    // propagation is unreliable
     // r is the event plane resolution for the chosen centrality
     if(!(h1 && h2) ) {
         printf(" GetV2 called with NULL argument(s) \n ");
@@ -1725,7 +1801,7 @@ TGraphErrors* AliJetFlowTools::GetV2(TH1 *h1, TH1* h2, Double_t r, TString name)
             out = h2->GetBinContent(j);
             eout = h2->GetBinError(j);
             ratio = pre*((in-out)/(in+out));
-            error2 = (r*4.)/(TMath::Pi())*((out*out/(TMath::Power(in+out, 4)))*ein*ein+(in*in/(TMath::Power(in+out, 4)))*eout*eout);
+            error2 =((r*4.)/(TMath::Pi()))*((4.*out*out/(TMath::Power(in+out, 4)))*ein*ein+(4.*in*in/(TMath::Power(in+out, 4)))*eout*eout);
             if(error2 > 0) error2 = TMath::Sqrt(error2);
             gr->SetPoint(gr->GetN(),binCent,ratio);
             gr->SetPointError(gr->GetN()-1,0.5*binWidth,error2);
@@ -1735,13 +1811,18 @@ TGraphErrors* AliJetFlowTools::GetV2(TH1 *h1, TH1* h2, Double_t r, TString name)
     return gr;
 }
 //_____________________________________________________________________________
-void AliJetFlowTools::WriteObject(TObject* object) {
-    // write object with unique identifier to active TDirectoryFile
+void AliJetFlowTools::WriteObject(TObject* object, TString suffix, Bool_t kill) {
+    // write object, if a unique identifier is given the object is cloned
+    // and the clone is saved. setting kill to true will delete the original obect from the heap
     if(!object) {
         printf(" > WriteObject:: called with NULL arguments \n ");
         return;
-    } else object->Write();
-    // FIXME to be implememnted
+    } else if(!strcmp("", suffix.Data())) object->Write();
+    else {
+        TObject* newObject(object->Clone(Form("%s_%s", object->GetName(), suffix.Data())));
+        newObject->Write();
+    }
+    if(kill) delete object;
 }
 //_____________________________________________________________________________
 TH2D* AliJetFlowTools::ConstructDPtResponseFromTH1D(TH1D* dpt, Bool_t AvoidRoundingError) {
@@ -1783,9 +1864,9 @@ TH2D* AliJetFlowTools::GetUnityResponse(TArrayD* binsTrue, TArrayD* binsRec, TSt
     return unity;
 }
 //_____________________________________________________________________________
-void AliJetFlowTools::SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut) {
+void AliJetFlowTools::SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut) const {
     // save configuration parameters to histogram
-    TH1F* summary = new TH1F("UnfoldingConfiguration","UnfoldingConfiguration", 16, -.5, 16.5);
+    TH1F* summary = new TH1F("UnfoldingConfiguration","UnfoldingConfiguration", 20, -.5, 19.5);
     summary->SetBinContent(1, fBetaIn);
     summary->GetXaxis()->SetBinLabel(1, "fBetaIn");
     summary->SetBinContent(2, fBetaOut);
@@ -1812,13 +1893,20 @@ void AliJetFlowTools::SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut)
     summary->GetXaxis()->SetBinLabel(12, "fJetRadius");
     summary->SetBinContent(13, (int)fNormalizeSpectra);
     summary->GetXaxis()->SetBinLabel(13, "fNormalizeSpectra");
-    summary->SetBinContent(14, (int)fSmoothenSpectrum);
-    summary->GetXaxis()->SetBinLabel(14, "fSmoothenSpectrum");
+    summary->SetBinContent(14, (int)fSmoothenPrior);
+    summary->GetXaxis()->SetBinLabel(14, "fSmoothenPrior");
     summary->SetBinContent(15, (int)fTestMode);
     summary->GetXaxis()->SetBinLabel(15, "fTestMode");
     summary->SetBinContent(16, (int)fUseDetectorResponse);
     summary->GetXaxis()->SetBinLabel(16, "fUseDetectorResponse");
-    summary->Write();
+    summary->SetBinContent(17, fBayesianIterIn);
+    summary->GetXaxis()->SetBinLabel(17, "fBayesianIterIn");
+    summary->SetBinContent(18, fBayesianIterOut);
+    summary->GetXaxis()->SetBinLabel(18, "fBayesianIterOut");
+    summary->SetBinContent(19, fBayesianSmoothIn);
+    summary->GetXaxis()->SetBinLabel(19, "fBayesianSmoothIn");
+    summary->SetBinContent(20, fBayesianSmoothOut);
+    summary->GetXaxis()->SetBinLabel(20, "fBayesianSmoothOut");
 }
 //_____________________________________________________________________________
 void AliJetFlowTools::ResetAliUnfolding() {
@@ -1913,4 +2001,3 @@ TGraphErrors* AliJetFlowTools::ProtectHeap(TGraphErrors* protect, Bool_t kill, T
     return p;
 }
 //_____________________________________________________________________________
-
index 381d4b86b4476c8283d7aa9b87543628c7ae76fc..f220cef544871e379f74af0a96b3f54f7221feb4 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef AliJetFlowTools_H
 #define AliJetFlowTools_H
 
-// root forward declaration
+// root forward declarations
 class TF1;
 class TH1D;
 class TH2D;
@@ -38,22 +38,22 @@ class AliJetFlowTools {
                                 // since most (or all) of the objects are owned by the input and output files
     public:
         // enumerators
-        enum unfoldingAlgorithm {
-            kChi2,
-            kBayesian,
-            kSVD,
-            kSVDlegacy,         // first implementation
-            kNone };            // type of unfolding algorithm
-        enum prior {
-            kPriorChi2,
-            kPriorMeasured };   // used prior for svd unfolding
-        enum histoType {
+        enum unfoldingAlgorithm {       // type of unfolding alrogithm
+            kChi2,                      // chi^2 unfolding, implemented in AliUnfolding
+            kBayesian,                  // Bayesian unfolding, implemented in RooUnfold
+            kBayesianAli,               // Bayesian unfolding, implemented in AliUnfolding
+            kSVD,                       // SVD unfolding, implemented in RooUnfold
+            kNone };                    // no unfolding
+        enum prior {                    // prior that is used for unfolding
+            kPriorChi2,                 // prior from chi^2 method
+            kPriorMeasured };           // use measured spectrum as prior
+        enum histoType {                // histogram identifier, only used internally
             kInPlaneSpectrum,
             kOutPlaneSpectrum,
             kUnfoldedSpectrum,
             kFoldedSpectrum,
             kMeasuredSpectrum,
-            kEmpty };           // histo types (used for styling)
+            kEmpty };
         // setters, interface to the class
         void            SetSaveFull(Bool_t b)           {fSaveFull              = b;}
         void            SetInputList(TList* list)       {
@@ -73,49 +73,55 @@ class AliJetFlowTools {
             fActiveDir = new TDirectoryFile(fActiveString.Data(), fActiveString.Data());
             fActiveDir->cd();
         }
-        void            SetCentralityBin(Int_t bin)     {fCentralityBin         = bin;}
-        void            SetDetectorResponse(TH2D* dr)   {fDetectorResponse      = dr;}
-        void            SetJetFindingEfficiency(TH1D* e)                {fJetFindingEff         = e;}
-        void            SetBinsTrue(TArrayD* bins)      {fBinsTrue              = bins;}
-        void            SetBinsRec(TArrayD* bins)       {fBinsRec               = bins;}
-        void            SetBinsTruePrior(TArrayD* bins) {fBinsTruePrior         = bins;}
-        void            SetBinsRecPrior(TArrayD* bins)  {fBinsRecPrior          = bins;}
-        void            SetSVDReg(Int_t r)              {fSVDRegIn = r; fSVDRegOut = r;}
-        void            SetSVDReg(Int_t in, Int_t out)  {fSVDRegIn = in; fSVDRegOut = out;}
-        void            SetSVDToy(Bool_t b, Float_t r)  {fSVDToy = b; fJetRadius = r;}
-        void            SetBeta(Double_t b)             {fBetaIn = b; fBetaOut = b;}
-        void            SetBeta(Double_t i, Double_t o) {fBetaIn = i; fBetaOut = o;}
-        void            SetAvoidRoundingError(Bool_t r) {fAvoidRoundingError    = r;}
-        void            SetUnfoldingAlgorithm(unfoldingAlgorithm ua)    {fUnfoldingAlgorithm    = ua;}
-        void            SetPrior(prior p)                               {fPrior                 = p;}
-        void            SetNormalizeSpectra(Bool_t b)   {fNormalizeSpectra      = b;}
-        void            SetNormalizeSpectra(Int_t e)    { // use to normalize to this no of events
-            fEventCount = e;
-            fNormalizeSpectra = kFALSE;
+        void            SetCentralityBin(Int_t bin)             {fCentralityBin         = bin;}
+        void            SetDetectorResponse(TH2D* dr)           {fDetectorResponse      = dr;}
+        void            SetJetFindingEfficiency(TH1D* e)        {fJetFindingEff         = e;}
+        void            SetBinsTrue(TArrayD* bins)              {fBinsTrue              = bins;}
+        void            SetBinsRec(TArrayD* bins)               {fBinsRec               = bins;}
+        void            SetBinsTruePrior(TArrayD* bins)         {fBinsTruePrior         = bins;}
+        void            SetBinsRecPrior(TArrayD* bins)          {fBinsRecPrior          = bins;}
+        void            SetSVDReg(Int_t r)                      {fSVDRegIn              = r; fSVDRegOut         = r;}
+        void            SetSVDReg(Int_t in, Int_t out)          {fSVDRegIn              = in; fSVDRegOut        = out;}
+        void            SetSVDToy(Bool_t b, Float_t r)          {fSVDToy                = b; fJetRadius         = r;}
+        void            SetBeta(Double_t b)                     {fBetaIn                = b; fBetaOut           = b;}
+        void            SetBeta(Double_t i, Double_t o)         {fBetaIn                = i; fBetaOut           = o;}
+        void            SetBayesianIter(Int_t i)                {fBayesianIterIn        = i; fBayesianIterOut    = i;}
+        void            SetBayesianIter(Int_t i, Int_t o)       {fBayesianIterIn        = i; fBayesianIterOut    = o;}
+        void            SetBayesianSmooth(Float_t s)            {fBayesianSmoothIn      = s; fBayesianSmoothOut = s;}
+        void            SetBayesianSmooth(Float_t i, Float_t o) {fBayesianSmoothIn      = i; fBayesianSmoothOut = o;}
+        void            SetAvoidRoundingError(Bool_t r)         {fAvoidRoundingError    = r;}
+        void            SetUnfoldingAlgorithm(unfoldingAlgorithm ua)    {fUnfoldingAlgorithm                    = ua;}
+        void            SetPrior(prior p)                       {fPrior                 = p;}
+        void            SetNormalizeSpectra(Bool_t b)           {fNormalizeSpectra      = b;}
+        void            SetNormalizeSpectra(Int_t e)            { // use to normalize to this no of events
+            fEventCount         = e;
+            fNormalizeSpectra   = kFALSE;
         }
-        void            SetSmoothenSpectrum(Bool_t b, Float_t min = 50., Float_t max = 100., Float_t start= 75.) {
-            fSmoothenSpectrum   = b;
+        void            SetSmoothenPrior(Bool_t b, Float_t min = 50., Float_t max = 100., Float_t start= 75., Bool_t counts = kTRUE) {
+            fSmoothenPrior      = b;
             fFitMin             = min;
             fFitMax             = max;
             fFitStart           = start;
+            fSmoothenCounts     = counts;
         }
-        void            SetTestMode(Bool_t t)           {fTestMode                      = t;}
-        void            SetNoDphi(Bool_t n)             {fNoDphi                        = n;}
+        void            SetTestMode(Bool_t t)                   {fTestMode              = t;}
         void            SetEventPlaneResolution(Double_t r)     {fEventPlaneRes         = r;}
         void            SetUseDetectorResponse(Bool_t r)        {fUseDetectorResponse   = r;}
-        void            SetTrainPowerFit(Bool_t t)      {fTrainPower                    = t;}
+        void            SetUseDptResponse(Bool_t r)             {fUseDptResponse        = r;}
+        void            SetTrainPowerFit(Bool_t t)              {fTrainPower            = t;}
+        void            SetUnfoldInOutPlane(Bool_t i)           {fInOutUnfolding        = i;}
         void            Make();
         void            Finish() {
             fOutputFile->cd();
-            fRMSSpectrumIn->Write();
-            fRMSSpectrumOut->Write();
-            fRMSRatio->Write();
+            if(fRMSSpectrumIn)  fRMSSpectrumIn->Write();
+            if(fRMSSpectrumOut) fRMSSpectrumOut->Write();
+            if(fRMSRatio)       fRMSRatio->Write();
             fOutputFile->Close();}
         void            PostProcess(
                 TString def,
                 TString in = "UnfoldedSpectra.root", 
                 TString out = "ProcessedSpectra.root", 
-                Int_t columns = 4);
+                Int_t columns = 4) const;
         Bool_t          SetRawInput (
                 TH2D* detectorResponse, // detector response matrix
                 TH1D* jetPtIn,          // in plane jet spectrum
@@ -126,19 +132,19 @@ class AliJetFlowTools {
         // static const helper functions, mainly histogram manipulation
         static TH1D*    ResizeXaxisTH1D(TH1D* histo, Int_t low, Int_t up, TString suffix = "");
         static TH2D*    ResizeYaxisTH2D(TH2D* histo, TArrayD* x, TArrayD* y, TString suffix = "");
-        static TH2D*    NormalizeTH2D(TH2D* histo);
+        static TH2D*    NormalizeTH2D(TH2D* histo, Bool_t noError = kTRUE);
         static TH1D*    RebinTH1D(TH1D* histo, TArrayD* bins, TString suffix = "", Bool_t kill = kTRUE);
         TH2D*           RebinTH2D(TH2D* histo, TArrayD* binsTrue, TArrayD* binsRec, TString suffix = "");
         static TH2D*    MatrixMultiplication(TH2D* a, TH2D* b, TString name = "CombinedResponse");
         static TH1D*    NormalizeTH1D(TH1D* histo, Double_t scale = 1.);
         static TGraphErrors*    GetRatio(TH1 *h1 = 0x0, TH1* h2 = 0x0, TString name = "", Bool_t appendFit = kFALSE, Int_t xmax = -1);
-        static TGraphErrors*    GetV2(TH1* h1 = 0x0, TH1* h2 = 0x0, Double_t r = .63, TString name = "");
-        static void     WriteObject(TObject* object);
+        static TGraphErrors*    GetV2(TH1* h1 = 0x0, TH1* h2 = 0x0, Double_t r = .7, TString name = "");
+        static void     WriteObject(TObject* object, TString suffix = "", Bool_t kill = kTRUE);
         static TH2D*    ConstructDPtResponseFromTH1D(TH1D* dpt, Bool_t AvoidRoundingError);
         static TH2D*    GetUnityResponse(TArrayD* binsTrue, TArrayD* binsRec, TString suffix = "");
-        void            SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut);
+        void            SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut) const;
         static TMatrixD*        CalculatePearsonCoefficients(TMatrixD* covmat);
-        static TH1D*    SmoothenSpectrum(TH1D* spectrum, TF1* function, Double_t min, Double_t max, Double_t start, Bool_t kill = kTRUE, Bool_t counts = kTRUE);
+        static TH1D*    SmoothenPrior(TH1D* spectrum, TF1* function, Double_t min, Double_t max, Double_t start, Bool_t kill = kTRUE, Bool_t counts = kTRUE);
         // set styles
         static void     Style(TCanvas* c, TString style = "PEARSON");
         static void     Style(TVirtualPad* c, TString style = "SPECTRUM");
@@ -146,6 +152,7 @@ class AliJetFlowTools {
         static void     Style(TH1* h, EColor col = kBlue, histoType = kEmpty);
         static void     Style(TGraph* h, EColor col = kBlue, histoType = kEmpty);
         static TLegend* AddLegend(TVirtualPad* p)       {return p->BuildLegend(.27, .61, .88, .88);}
+        static void     SavePadToPDF(TVirtualPad* pad)  {pad->SaveAs(Form("%s.pdf", pad->GetName()));}
         // interface to AliUnfolding, not necessary but nice to have all parameters in one place
         static void     SetMinuitStepSize(Float_t s)    {AliUnfolding::SetMinuitStepSize(s);}
         static void     SetMinuitPrecision(Float_t s)   {AliUnfolding::SetMinuitPrecision(s);}
@@ -154,29 +161,36 @@ class AliJetFlowTools {
         static void     SetDebug(Int_t d)               {AliUnfolding::SetDebug(d);}
     private:
         Bool_t          PrepareForUnfolding(); 
-        void            GetPrior()                      {; /* FIXME implement */};
-        Bool_t          UnfoldSpectrumChi2(             TH1D* resizedJetPt, 
-                                                        TH2D* resizedResonse,
-                                                        TH1D* kinematicEfficiency,
-                                                        TH1D* unfoldingTemplate,
-                                                        TH1D *&unfolded,        // careful, pointer reference
-                                                        TString suffix,
-                                                        TH1D* jetFindingEfficiency = 0x0);
-        Bool_t          UnfoldSpectrumBayesian()        {return kFALSE;}
-        Bool_t          UnfoldSpectrumSVDlegacy(        TH1D* resizedJetPt, 
-                                                        TH2D* resizedResonse,
-                                                        TH1D* kinematicEfficiency,
-                                                        TH1D* unfoldingTemplate,
-                                                        TH1D *&unfolded,        // careful, pointer reference
-                                                        TString suffix,
-                                                        TH1D* jetFindingEfficiency = 0x0);
-        Bool_t          UnfoldSpectrumSVD(              TH1D* resizedJetPt, 
-                                                        TH2D* resizedResonse,
-                                                        TH1D* kinematicEfficiency,
-                                                        TH1D* unfoldingTemplate,
-                                                        TH1D *&unfolded,        // careful, pointer reference
-                                                        TString suffix,
-                                                        TH1D* jetFindingEfficiency = 0x0);
+        TH1D*           GetPrior(                       const TH1D* measuredJetSpectrum,
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency);
+        TH1D*           UnfoldSpectrumChi2(             const TH1D* measuredJetSpectrum, 
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency = 0x0);
+        TH1D*           UnfoldSpectrumSVD(              const TH1D* measuredJetSpectrum, 
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency = 0x0);
+        TH1D*           UnfoldSpectrumBayesianAli(      const TH1D* measuredJetSpectrum, 
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency = 0x0);
+        TH1D*           UnfoldSpectrumBayesian(         const TH1D* measuredJetSpectrum, 
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency = 0x0);
         static void     ResetAliUnfolding();
         // give object a unique name via the 'protect heap' functions. 
         // may seem redundant, but some internal functions of root (e.g.
@@ -199,6 +213,10 @@ class AliJetFlowTools {
         TH1D*                   fJetFindingEff;         // jet finding efficiency
         Double_t                fBetaIn;                // regularization strength, in plane unfolding
         Double_t                fBetaOut;               // regularization strength, out of plane unfoldign
+        Int_t                   fBayesianIterIn;        // bayesian regularization parameter, in plane unfolding
+        Int_t                   fBayesianIterOut;       // bayesian regularization parameter, out plane unfolding
+        Float_t                 fBayesianSmoothIn;      // bayesian smoothening parameter (AliUnfolding)
+        Float_t                 fBayesianSmoothOut;     // bayesian smoothening parameter (AliUnfolding)
         Bool_t                  fAvoidRoundingError;    // set dpt to zero for small values far from the diagonal
         unfoldingAlgorithm      fUnfoldingAlgorithm;    // algorithm used for unfolding
         prior                   fPrior;                 // prior for unfolding
@@ -212,18 +230,21 @@ class AliJetFlowTools {
         Float_t                 fJetRadius;             // jet radius (for SVD toy)
         Int_t                   fEventCount;            // number of events
         Bool_t                  fNormalizeSpectra;      // normalize spectra to event count
-        Bool_t                  fSmoothenSpectrum;      // smoothen the tail of the measured spectrum using a powerlaw fit
+        Bool_t                  fSmoothenPrior;         // smoothen the tail of the measured spectrum using a powerlaw fit
         Float_t                 fFitMin;                // lower bound of smoothening fit
         Float_t                 fFitMax;                // upper bound of smoothening fit
         Float_t                 fFitStart;              // from this value, use smoothening
+        Bool_t                  fSmoothenCounts;        // fill smoothened spectrum with counts
         Bool_t                  fTestMode;              // unfold with unity response for testing
         Bool_t                  fNoDphi;                // no dphi dependence in unfolding
         Bool_t                  fRawInputProvided;      // input histograms provided, not read from file
         Double_t                fEventPlaneRes;         // event plane resolution for current centrality
         Bool_t                  fUseDetectorResponse;   // add detector response to unfolding
+        Bool_t                  fUseDptResponse;        // add dpt response to unfolding
         Bool_t                  fTrainPower;            // don't clear the params of fPower for call to Make
                                                         // might give more stable results, but also introduces
                                                         // a bias / dependency on previous iterations
+        Bool_t                  fInOutUnfolding;        // do the unfolding in in and out of plane orientation
         // members, set internally
         TProfile*               fRMSSpectrumIn;         // rms of in plane spectra of converged unfoldings
         TProfile*               fRMSSpectrumOut;        // rms of out of plane spectra of converged unfoldings
@@ -239,8 +260,6 @@ class AliJetFlowTools {
         TH2D*                   fDptOut;                // out plane dpt matrix
         TH2D*                   fFullResponseIn;        // full response matrix, in plane
         TH2D*                   fFullResponseOut;       // full response matrix, out of plane
-        TH1D*                   fUnfoldedIn;            // unfolded in plane spectrum
-        TH1D*                   fUnfoldedOut;           // unfolded out ofplane spectrum
         // copy and assignment 
         AliJetFlowTools(const AliJetFlowTools&);             // not implemented
         AliJetFlowTools& operator=(const AliJetFlowTools&);  // not implemented
index 16b2ddc55327cc757978bf5a918d21fa40d2a57b..374eef001b566f4219fe79cc09e4909063aa4077 100644 (file)
@@ -99,6 +99,7 @@ AliGlauberMC::AliGlauberMC(Option_t* NA, Option_t* NB, Double_t xsect) :
   fONcom(0),
   fNpart(0),
   fNcoll(0),
+  fNcollw(0),
   fNcom(0),
   fMeanr2(0),
   fMeanr3(0),
@@ -459,6 +460,15 @@ AliGlauberMC& AliGlauberMC::operator=(const AliGlauberMC& in)
 Bool_t AliGlauberMC::CalcEvent(Double_t bgen)
 {
   // prepare event
+
+  if (fDoFluc) {
+    if (!fSigFluc) {
+      fSigFluc = new TF1("fSigFluc","[0]*x/[3]/(x/[3]+[1])*exp(-((x/[1]/[3]-1)/[2])^2)",0,250);
+      fSigFluc->SetParameters(1,fSig0,fOmega,fLambda);
+      cout << "Setting fluc: " << fSig0 << " " << fOmega << " " << fLambda << endl;
+    }
+  }
+
   fANucleus.ThrowNucleons(-bgen/2.);
   fNucleonsA = fANucleus.GetNucleons();
   fAN = fANucleus.GetN();
@@ -468,6 +478,9 @@ Bool_t AliGlauberMC::CalcEvent(Double_t bgen)
   {
     AliGlauberNucleon *nucleonA=(AliGlauberNucleon*)(fNucleonsA->UncheckedAt(i));
     nucleonA->SetInNucleusA();
+    nucleonA->SetSigNN(fXSect);
+    if (fDoFluc)
+      nucleonA->SetSigNN(fSigFluc->GetRandom());
   }
   fBNucleus.ThrowNucleons(bgen/2.);
   fNucleonsB = fBNucleus.GetNucleons();
@@ -478,6 +491,9 @@ Bool_t AliGlauberMC::CalcEvent(Double_t bgen)
   {
     AliGlauberNucleon *nucleonB=(AliGlauberNucleon*)(fNucleonsB->UncheckedAt(i));
     nucleonB->SetInNucleusB();
+    nucleonB->SetSigNN(fXSect);
+    if (fDoFluc)
+      nucleonB->SetSigNN(fSigFluc->GetRandom());
   }
 
   if (fDoFluc) {
@@ -491,8 +507,10 @@ Bool_t AliGlauberMC::CalcEvent(Double_t bgen)
   // "ball" diameter = distance at which two balls interact
   Double_t d2 = (Double_t)fXSect/(TMath::Pi()*10); // in fm^2
 
-  Double_t bNN = 0;
-  Double_t Nco = 0;
+  Double_t bNN   = 0;
+  Double_t Nco   = 0;
+  Double_t Ncohc = 0; // hard core
+
   // for each of the A nucleons in nucleus B
   for (Int_t i = 0; i<fBN; i++)
   {
@@ -503,15 +521,32 @@ Bool_t AliGlauberMC::CalcEvent(Double_t bgen)
       Double_t dx = nucleonB->GetX()-nucleonA->GetX();
       Double_t dy = nucleonB->GetY()-nucleonA->GetY();
       Double_t dij = dx*dx+dy*dy;
+      if (fDoFluc) {
+       //fXSect = nucleonA->GetSigNN();
+       //fXSect = (nucleonA->GetSigNN()+nucleonB->GetSigNN())/2.;
+       fXSect = TMath::Max(nucleonA->GetSigNN(),nucleonB->GetSigNN());
+       d2 = (Double_t)fXSect/(TMath::Pi()*10); // in fm^2
+      }
       if (dij < d2)
       {
        bNN += dij;
        ++Nco;
         nucleonB->Collide();
         nucleonA->Collide();
+       if (dij<d2/4)
+         ++Ncohc;
       }
     }
   }
+
+  if (Nco>0) {
+    fNcollw = Ncohc;
+    fBNN = bNN/Nco;
+  } else {
+    fNcollw = 0;
+    fBNN    = 0.;
+  }
+
   if (Nco>0)
     fBNN = bNN/Nco;
   else
@@ -1656,7 +1691,7 @@ void AliGlauberMC::Run(Int_t nevents)
   if (fnt == 0)
   {
     fnt = new TNtuple(name,title,
-                      "Npart:Ncoll:B:MeanX:MeanY:MeanX2:MeanY2:MeanXY:VarX:VarY:VarXY:MeanXSystem:MeanYSystem:MeanXA:MeanYA:MeanXB:MeanYB:VarE:Stoa:VarEColl:VarECom:VarEPart:VarEPartColl:VarEPartCom:dNdEta:dNdEtaGBW:dNdEtaTwoNBD:xsect:tAA:Epsl2:Epsl3:Epsl4:Epsl5:E2Coll:E3Coll:E4Coll:E5Coll:E2Com:E3Com:E4Com:E5Com:Psi2:Psi3:Psi4:Psi5:BNN:signn");
+                      "Npart:Ncoll:B:MeanX:MeanY:MeanX2:MeanY2:MeanXY:VarX:VarY:VarXY:MeanXSystem:MeanYSystem:MeanXA:MeanYA:MeanXB:MeanYB:VarE:Stoa:VarEColl:VarECom:VarEPart:VarEPartColl:VarEPartCom:dNdEta:dNdEtaGBW:dNdEtaTwoNBD:xsect:tAA:Epsl2:Epsl3:Epsl4:Epsl5:E2Coll:E3Coll:E4Coll:E5Coll:E2Com:E3Com:E4Com:E5Com:Psi2:Psi3:Psi4:Psi5:BNN:signn:Ncollw");
     fnt->SetDirectory(0);
   }
   Int_t q = 0;
@@ -1671,7 +1706,7 @@ void AliGlauberMC::Run(Int_t nevents)
     }
 
     q++;
-    Float_t v[47];
+    Float_t v[48];
     v[0]  = GetNpart();
     v[1]  = GetNcoll();
     v[2]  = fBMC;
@@ -1732,6 +1767,8 @@ void AliGlauberMC::Run(Int_t nevents)
     v[44] = GetPsi5();
     v[45] = fBNN;
     v[46] = fXSect;
+    v[47] = fNcollw;
+
     //always at the end
     fnt->Fill(v);
 
index 948bfbe43b08b370677b71ee6e4ff28564312893..08e270fbb9b138a5991dc8de418884d2d15fd419 100644 (file)
@@ -176,6 +176,7 @@ private:
    Double_t     fONcom; 
    Int_t        fNpart;          //Number of wounded (participating) nucleons in current event   
    Int_t        fNcoll;          //Number of binary collisions in current event
+   Int_t        fNcollw;         //Number of binary collisions in current event
    Double_t     fNcom;
    Double_t     fMeanr2;         //----------<r^2> of wounded nucleons
    Double_t     fMeanr3;         //----------<r^3> of wounded nucleons
index deb6be81cd6cffcee25f1934ef14ea4163221914..a8de085cb803b346b444dbd10fe4f91b218e34f6 100644 (file)
@@ -24,6 +24,7 @@ private:
    Double32_t fZ;            //Position of nucleon
    Bool_t     fInNucleusA;   //=1 from nucleus A, =0 from nucleus B
    Int_t      fNColl;        //Number of binary collisions
+   Double32_t fSigNN;        //Interaction cross section of this Nucleon
 
 public:
    AliGlauberNucleon();
@@ -31,6 +32,7 @@ public:
 
    void       Collide()            {fNColl++;}
    Int_t      GetNColl()     const {return fNColl;}
+   Double_t   GetSigNN()     const {return fSigNN;}
    Double_t   GetX()         const {return fX;}
    Double_t   GetY()         const {return fY;}
    Double_t   GetZ()         const {return fZ;}
@@ -41,9 +43,10 @@ public:
    void       Reset()              {fNColl=0;}
    void       SetInNucleusA()      {fInNucleusA=1;}
    void       SetInNucleusB()      {fInNucleusA=0;}
+   void       SetSigNN(Double_t s) {fSigNN=s;}
    void       SetXYZ(Double_t x, Double_t y, Double_t z) {fX=x; fY=y; fZ=z;}
 
-   ClassDef(AliGlauberNucleon,1)
+   ClassDef(AliGlauberNucleon,2)
 };
 
 #endif
index e1473b9de92e784b67504385a083b72da7c89bf5..2693ea431d9c36e0bc8aaf85b3b30952c319fc93 100644 (file)
 #pragma link C++ class AliEmcalClusTrackMatcherTask+;
 #pragma link C++ class AliEmcalCompatTask+;
 #pragma link C++ class AliEmcalContainer+;
-#pragma link C++ class AliEmcalEsdTpcTrackTask+;
+#pragma link C++ class AliEmcalEsdTrackFilterTask;
 #pragma link C++ class AliEmcalMCTrackSelector+;
 #pragma link C++ class AliEmcalParticle+;
 #pragma link C++ class AliEmcalParticleMaker+;
 #pragma link C++ class AliEmcalPhysicsSelection+;
 #pragma link C++ class AliEmcalPhysicsSelectionTask+;
 #pragma link C++ class AliEmcalPicoTrackMaker+;
+#pragma link C++ class AliEmcalAodTrackFilterTask+;
 #pragma link C++ class AliEmcalSetupTask+;
 #pragma link C++ class AliEmcalTenderTask+;
 #pragma link C++ class AliEmcalTrackPropagatorTask+;
+#pragma link C++ class AliEmcalTrackPropagatorTaskAOD+;
 #pragma link C++ class AliEsdSkimTask+;
 #pragma link C++ class AliEsdTrackExt+;
 #pragma link C++ class AliParticleContainer+;
index ef507e4670e2930d652ce045c5f629a6c557f901..8fb12e97bee496fc946456c198f5d5c8d5ce5cbf 100644 (file)
@@ -34,8 +34,6 @@
 #pragma link C++ class AliHistogramCollectionIterator+;
 #pragma link C++ class AliAnalysisTaskMuonCollisionMultiplicity+;
 #pragma link C++ class AliCFMuonResUpsilon+;
-#pragma link C++ class AliAnalysisTaskMuMu+;
-#pragma link C++ class AliAnalysisTaskMuMu::PairCut+;
 #pragma link C++ class AliMuonEventCuts+;
 #pragma link C++ class AliMuonTrackCuts+;
 #pragma link C++ class AliMuonPairCuts+;
 #pragma link C++ class AliAnalysisMuonUtility+;
 #pragma link C++ class AliUtilityMuonAncestor+;
 #pragma link C++ class AliOADBMuonTrackCutsParam+;
-#pragma link C++ class AliAnalysisMuMuBinning+;
-#pragma link C++ class AliAnalysisMuMuBinning::Range+;
 #pragma link C++ class AliAnalysisTaskAOD2MuonAOD+;
 #pragma link C++ class AliAnalysisNonMuonTrackCuts+;
 #pragma link C++ class AliAnalysisNonPrimaryVertices+;
 
+#pragma link C++ class AliAnalysisTaskMuMu+;
+#pragma link C++ class AliAnalysisMuMuBinning+;
+#pragma link C++ class AliAnalysisMuMuBinning::Range+;
+#pragma link C++ class AliAnalysisMuMuBase+;
+#pragma link C++ class AliAnalysisMuMuGlobal+;
+#pragma link C++ class AliAnalysisMuMuCutRegistry+;
+#pragma link C++ class AliAnalysisMuMuCutElement+;
+#pragma link C++ class AliAnalysisMuMuCutElementBar+;
+#pragma link C++ class AliAnalysisMuMuCutCombination+;
+#pragma link C++ class AliAnalysisMuMuEventCutter+;
+#pragma link C++ class AliAnalysisMuMuSingle+;
+#pragma link C++ class AliAnalysisMuMuMinv+;
+#pragma link C++ class AliAnalysisMuMuNch+;
+//#pragma link C++ class AliAnalysisMuMuMeanPt+;
+
 #endif
 
index 4f3191ca4d48c2b66b56e01ce34115c586fcbc81..875a97dca7a43357e67bbadb16eb57e45c0241b3 100644 (file)
@@ -427,7 +427,7 @@ Int_t AliHelperPID::FindMinNSigma(AliVTrack * trk,Bool_t FillQAHistos){
 Bool_t* AliHelperPID::GetDoubleCounting(AliVTrack * trk,Bool_t FIllQAHistos){ 
   //if a particle has double counting set fHasDoubleCounting[ipart]=kTRUE
   //fill DC histos
-  for(Int_t ipart=0;ipart<=kNSpecies;ipart++)fHasDoubleCounting[ipart]=kFALSE;//array with kTRUE for second (or third) identity of the track
+  for(Int_t ipart=0;ipart<kNSpecies;ipart++)fHasDoubleCounting[ipart]=kFALSE;//array with kTRUE for second (or third) identity of the track
   
   Int_t MinNSigma=FindMinNSigma(trk,kFALSE);//not filling the NSigmaRec histos
   
index 13a9d4a1f72202eb571efe5ef0076920251fa7af..9ac7c8192b4d31e7f30d3b2226402b7cff7c2573 100644 (file)
@@ -1,14 +1,13 @@
 ///
-/// Configure a task to get invariant mass spectrum of dimuons
+/// Configuration example of a task to get invariant mass spectrum of dimuons
 ///
-/// author: L. Aphecetche (Subatech) (laurent.aphecetche - at - subatech.in2p3.fr)
+/// \author: L. Aphecetche (Subatech) (laurent.aphecetche - at - subatech.in2p3.fr)
 ///
 
 AliAnalysisTask* AddTaskMuMu(const char* outputname, 
-                                                        TList* triggerClassesToConsider, 
-                                                        const char* beamYear, 
-                                                        TArrayF* centralities,
-                                                        Bool_t simulations)                                    
+                             TList* triggerClassesToConsider,
+                             const char* beamYear,
+                             Bool_t simulations)
 {
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
@@ -27,186 +26,203 @@ AliAnalysisTask* AddTaskMuMu(const char* outputname,
   
   // Configure analysis
   //===========================================================================  
-  
-  AliAnalysisTaskMuMu* task;
-  
+
   if (simulations && triggerClassesToConsider )
   {
-    triggerClassesToConsider->Add(new TObjString("CMULLO-B-NOPF-MUON"));
-       triggerClassesToConsider->Add(new TObjString("CMSNGL-B-NOPF-MUON"));
-       triggerClassesToConsider->Add(new TObjString("ANY"));
+//    triggerClassesToConsider->Add(new TObjString("CMULLO-B-NOPF-MUON"));
+//    triggerClassesToConsider->Add(new TObjString("CMSNGL-B-NOPF-MUON"));
+    triggerClassesToConsider->Add(new TObjString("ANY"));
+
+//    triggerClassesToConsider->Add(new TObjString("MB1"));
+//    triggerClassesToConsider->Add(new TObjString("C0T0A"));
+
+    //    triggerClassesToConsider->Add(new TObjString("MULow"));
+//    triggerClassesToConsider->Add(new TObjString("V0L"));
+//    triggerClassesToConsider->Add(new TObjString("V0R"));
+//
+// for dpmjet simulations (at least) we have the following "triggers" :
+//    C0T0A,C0T0C,MB1,MBBG1,V0L,V0R,MULow,EMPTY,MBBG3,MULL,MULU,MUHigh
   }
+
+  AliAnalysisTaskMuMu* task = new AliAnalysisTaskMuMu;
   
-  if ( triggerClassesToConsider ) 
-  {
-    task = new AliAnalysisTaskMuMu((inputDataType=="ESD"),triggerClassesToConsider,beamYear,centralities);    
-  }
-  else 
-  {
-    task = new AliAnalysisTaskMuMu((inputDataType=="ESD"),beamYear,centralities);    
-  }
+  AliAnalysisMuMuEventCutter* eventCutter = new AliAnalysisMuMuEventCutter(triggerClassesToConsider);
   
-  task->AddEventCut("ALL",AliAnalysisTaskMuMu::kEventAll);
+  AliAnalysisMuMuCutRegistry* cr = task->CutRegistry();
+  
+  AliAnalysisMuMuCutElement* eventTrue = cr->AddEventCut(*eventCutter,"IsTrue","const AliVEvent&","");
 
-if (!simulations) 
-  {
-       task->AddEventCut("PSALL",AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventPS);  
-//     task->AddEventCut("OFFLINE1",AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventPS | AliAnalysisTaskMuMu::kEventOFFLINEMUL1);  
-//     task->AddEventCut("REJECTED",AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventREJECTED);  
-   }
-  
-//  task->AddEventCut("PSALLNOTZEROPILEUP",AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventPS | AliAnalysisTaskMuMu::kEventNOTZEROPILEUP);  
-
-//  task->AddEventCut("PSALLMUL1", AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventPS | AliAnalysisTaskMuMu::kEventOFFLINEMUL1);
-
-//  task->AddEventCut("PSALLMUL2", AliAnalysisTaskMuMu::kEventAll | AliAnalysisTaskMuMu::kEventPS | AliAnalysisTaskMuMu::kEventOFFLINEMUL2);
-
-//   task->AddSingleCut("MATCHLOWRABSDCA",
-//                      AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kDCA);
-// 
-   task->AddSingleCut("MATCHLOWRABS",
-                      AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs);
-
-   task->AddSingleCut("MATCHLOWRABSETA",
-                      AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs);
-
-  task->AddSingleCut("MATCHLOWRABSETADCA",
-                     AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kEta|AliAnalysisTaskMuMu::kDCA);
-
-
-//  task->AddPairCut("ALL",AliAnalysisTaskMuMu::kAll);
-
-   task->AddPairCut("MATCHLOWRABSBOTH",
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs,
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs);
-
-   task->AddPairCut("MATCHLOWRABSETABOTH",
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kEta,
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kEta);
-
-   task->AddPairCut("MATCHLOWRABSETADCABOTH",
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kEta|AliAnalysisTaskMuMu::kDCA,
-                    AliAnalysisTaskMuMu::kAll|AliAnalysisTaskMuMu::kMatchedLow|AliAnalysisTaskMuMu::kRabs|AliAnalysisTaskMuMu::kEta|AliAnalysisTaskMuMu::kDCA);
-
-// igor binning
-
-task->AddBin("psi","pt", 0.0, 0.5,"IGOR");
-task->AddBin("psi","pt", 0.5, 1.0,"IGOR");
-task->AddBin("psi","pt", 1.0, 1.5,"IGOR");
-task->AddBin("psi","pt", 1.5, 2.0,"IGOR");
-task->AddBin("psi","pt", 2.0, 2.5,"IGOR");
-task->AddBin("psi","pt", 2.5, 3.0,"IGOR");
-task->AddBin("psi","pt", 3.0, 3.5,"IGOR");
-task->AddBin("psi","pt", 3.5, 4.0,"IGOR");
-task->AddBin("psi","pt", 4.0, 4.5,"IGOR");
-task->AddBin("psi","pt", 4.5, 5.0,"IGOR");
-task->AddBin("psi","pt", 5.0, 6.0,"IGOR");
-task->AddBin("psi","pt", 6.0, 7.0,"IGOR");
-task->AddBin("psi","pt", 7.0, 8.0,"IGOR");
-task->AddBin("psi","pt", 8.0, 9.0,"IGOR");
-task->AddBin("psi","pt", 9.0,11.0,"IGOR");
-task->AddBin("psi","pt",11.0,13.0,"IGOR");
-task->AddBin("psi","pt",13.0,15.0,"IGOR");
-
-// roberta binning
-task->AddBin("psi","pt",0.0,1.0,"ROBERTA");
-task->AddBin("psi","pt",1.0,2.0,"ROBERTA");
-task->AddBin("psi","pt",2.0,3.0,"ROBERTA");
-task->AddBin("psi","pt",3.0,4.0,"ROBERTA");
-task->AddBin("psi","pt",4.0,5.0,"ROBERTA");
-task->AddBin("psi","pt",5.0,6.0,"ROBERTA");
-task->AddBin("psi","pt",6.0,8.0,"ROBERTA");
-
-/*
-
-  for ( Int_t i = 0; i < 10; ++i ) 
+  AliAnalysisMuMuCutElement* ps = eventTrue;
+  
+  if (!simulations)
   {
-    Double_t xmin = i*1.0;
-    
-       task->AddBin("psi","pt",xmin,xmin+1.0);
+    ps = cr->AddEventCut(*eventCutter,"IsPhysicsSelected","const AliInputEventHandler&","");
   }
 
-  for ( Int_t i = 0; i < 5; ++i ) 
-  {
-    Double_t xmin = 10+i*2.0;
-    
-       task->AddBin("psi","pt",xmin,xmin+2.0);
-  }
+  AliAnalysisMuMuCutElement* triggerSelection = cr->AddTriggerClassCut(*eventCutter,"SelectTriggerClass","const TString&,TString&,UInt_t,UInt_t,UInt_t","");
 
-  for ( Int_t i = 0; i < 6; ++i ) 
+  cr->AddCutCombination(triggerSelection);
+  
+//  AliAnalysisMuMuCutElement* cutVDM = cr->AddEventCut(*eventCutter,"IsPhysicsSelectedVDM","const AliVEvent&","");
+//
+//  AliAnalysisMuMuCutElement* cutTZEROPileUp = cr->AddEventCut(*eventCutter,"IsTZEROPileUp","const AliVEvent&","");
+//
+//  AliAnalysisMuMuCutElement* notTZEROPileUp = cr->Not(*cutTZEROPileUp);
+
+  cr->AddCutCombination(ps);
+
+  task->SetBeamYear(beamYear);
+
+  AliAnalysisMuMuGlobal* globalAnalysis = 0x0;//new AliAnalysisMuMuGlobal;
+  
+  AliAnalysisMuMuSingle* singleAnalysis = new AliAnalysisMuMuSingle;
+  
+  AliAnalysisMuMuMinv* minvAnalysis = new AliAnalysisMuMuMinv;
+
+//  TFile f("$HOME/Downloads/ResponseMatrix_QASPDZPSALL_ANY.root");
+//  TH2* h = static_cast<TH2*>(f.Get("ResponseMatrix"));
+  
+  AliAnalysisMuMuNch* nchAnalysis = new AliAnalysisMuMuNch; // (0x0,-2,2,-40,40);
+  
+//  AliAnalysisMuMuNch(TH2* spdCorrection=0x0,
+//                     Int_t nbinsEta=10, Double_t etaMin=-0.5, Double_t etaMax=0.5,
+//                     Int_t nbinsZ=320, Double_t zmin=-40, Double_t zmax=40);
+
+
+  if ( globalAnalysis )
   {
-    Double_t xmin = -4+i*0.25;
+    AliAnalysisMuMuCutElement* triggerAll = cr->AddTriggerClassCut(*globalAnalysis,"SelectAnyTriggerClass","const TString&,TString&","");
+    
+    cr->AddCutCombination(triggerAll);
     
-       task->AddBin("psi","y",xmin,xmin+0.25);
+    task->AdoptSubAnalysis(globalAnalysis);
   }
-
-  Int_t nphiSteps = 18;
   
-  for ( Int_t i = 0; i < nphiSteps; ++i ) 
+  if ( nchAnalysis )
   {
-    Double_t xstep = 2*TMath::Pi()/nphiSteps;
-    Double_t xmin = -TMath::Pi() + i*xstep;
+//    AliAnalysisMuMuCutElement* trketa2 = cr->AddEventCut(*nchAnalysis,"HasAtLeastNTrackletsInEtaRange","const AliVEvent&,Int_t, Double_t& , Double_t& ","1,-2.0,2.0");
+//    AliAnalysisMuMuCutElement* trketa1 = cr->AddEventCut(*nchAnalysis,"HasAtLeastNTrackletsInEtaRange","const AliVEvent&,Int_t, Double_t& , Double_t& ","1,-1.0,1.0");
+//    AliAnalysisMuMuCutElement* trk5eta1 = cr->AddEventCut(*nchAnalysis,"HasAtLeastNTrackletsInEtaRange","const AliVEvent&,Int_t, Double_t& , Double_t& ","5,-1.0,1.0");
+//    
+//    cr->AddCutCombination(ps,trketa1);
+//    cr->AddCutCombination(ps,trk5eta1);
+//    cr->AddCutCombination(ps,trketa2);
+    
+    AliAnalysisMuMuCutElement* cutZ18= cr->AddEventCut(*eventCutter,"IsAbsZBelowValue","const AliVEvent&,Double_t","18");
+    
+    AliAnalysisMuMuCutElement* cutZ10 = cr->AddEventCut(*eventCutter,"IsAbsZBelowValue","const AliVEvent&,Double_t","10");
     
-       task->AddBin("psi","phi",xmin,xmin+xstep);
+    cr->AddCutCombination(ps,cutZ18);
+    cr->AddCutCombination(ps,cutZ10);
+    
+    task->AdoptSubAnalysis(nchAnalysis);
   }
   
-  */
-  
-  Double_t ymin(-4.0);
-  Double_t ymax(-3.43);
+  if ( singleAnalysis )
+  {
+    AliAnalysisMuMuCutElement* trackTrue = cr->AddTrackCut(*cr,"AlwaysTrue","const AliVParticle&","");
+    AliAnalysisMuMuCutElement* rabs = cr->AddTrackCut(*singleAnalysis,"IsRabsOK","const AliVParticle&","");
+    AliAnalysisMuMuCutElement* eta = cr->AddTrackCut(*singleAnalysis,"IsEtaInRange","const AliVParticle&,Double_t&,Double_t&","-4.0,-2.5");
+    
+    cr->AddCutCombination(trackTrue);
 
-  Double_t ymin(-4.0);
-  Double_t ymax(-3.43);
+    cr->AddCutCombination(rabs);
+    
+    cr->AddCutCombination(eta);
+
+    cr->AddCutCombination(rabs,eta);
 
-  task->AddBin("psi","y",-4,-2.5,"ILAB");
+    task->AdoptSubAnalysis(singleAnalysis);
+
+    if ( minvAnalysis )
+    {
+      AliAnalysisMuMuCutElement* pairTrue = cr->AddTrackPairCut(*cr,"AlwaysTrue","const AliVParticle&, const AliVParticle&","");
+      
+      AliAnalysisMuMuCutElement* pairy = cr->AddTrackPairCut(*minvAnalysis,"IsRapidityInRange","const AliVParticle&,const AliVParticle&,Double_t&,Double_t&","-4,-2.5");
   
-  task->AddBin("psi","y",ymin,ymax,"ICOMMON");
+      cr->AddCutCombination(rabs,eta,pairy);
 
-  for ( Int_t i = 0; i < 6; ++i ) 
-  {
-    Double_t y = -4+i*0.25;
-    
-    task->AddBin("psi","y",y,y+0.25,"6PACK");
-  }
+      cr->AddCutCombination(rabs,pairy);
 
-/*  
-  for ( Int_t i = 0; i < 20; ++i ) 
-  {
-    Double_t xmin = i*0.25;
-    
-       task->AddBin("psi","y vs pt",xmin,xmin+0.25,ymin,ymax);
+      cr->AddCutCombination(pairy);
+
+      cr->AddCutCombination(pairTrue);
+
+      task->AdoptSubAnalysis(minvAnalysis);
+    }
   }
+  
+  /// below are the kind of configurations that can be performed :
+  /// - adding cuts (at event, track or pair level)
+  /// - adding bins (in pt, y, centrality, etc...) for minv (and meanpt)
 
-  for ( Int_t i = 0; i < 4; ++i ) 
+  AliAnalysisMuMuBinning* binning = task->Binning();
+  
+  if (minvAnalysis)
   {
-    Double_t xmin = 5+i*1.0;
+    binning->AddBin("psi","pt");
+    
+    // pt binning
+    
+    binning->AddBin("psi","pt", 0.0, 1.0,"IGOR");
+    binning->AddBin("psi","pt", 1.0, 2.0,"IGOR");
+    binning->AddBin("psi","pt", 2.0, 3.0,"IGOR");
+    binning->AddBin("psi","pt", 3.0, 4.0,"IGOR");
+    binning->AddBin("psi","pt", 4.0, 5.0,"IGOR");
+    binning->AddBin("psi","pt", 5.0, 6.0,"IGOR");
+    binning->AddBin("psi","pt", 6.0, 7.0,"IGOR");
+    binning->AddBin("psi","pt", 7.0, 9.0,"IGOR");
+    binning->AddBin("psi","pt", 9.0,11.0,"IGOR");
+    binning->AddBin("psi","pt",11.0,15.0,"IGOR");
+    binning->AddBin("psi","pt",15.0,25.0,"IGOR");
+    
+    // y binning
     
-       task->AddBin("psi","y vs pt",xmin,xmin+1.0,ymin,ymax);
+    binning->AddBin("psi","y",-4,-2.5,"ILAB");
+    
+    for ( Int_t i = 0; i < 6; ++i )
+    {
+      Double_t y = -4+i*0.25;
+      
+      binning->AddBin("psi","y",y,y+0.25,"6PACK");
+    }
+    
+    // nch binning
+    if (nchAnalysis)
+    {
+      binning->AddBin("psi","nch",0.0,30.0,"JAVI"); // 0 - 29
+      binning->AddBin("psi","nch",29.0,42.0,"JAVI"); // 30 - 41
+      binning->AddBin("psi","nch",41.0,56.0,"JAVI"); // 42 - 55
+      binning->AddBin("psi","nch",55.0,72.0,"JAVI"); // 56 - 72
+      binning->AddBin("psi","nch",72.0,301.0,"JAVI"); // 73 - 300
+    }
   }
+  
+  // v0 centrality binning
+  
+  binning->AddBin("centrality","v0a");
+//  binning->AddBin("centrality","v0a",0,5);
+//  binning->AddBin("centrality","v0a",5,10);
+//  binning->AddBin("centrality","v0a",10,20);
+//  binning->AddBin("centrality","v0a",20,40);
+//  binning->AddBin("centrality","v0a",40,60);
+//  binning->AddBin("centrality","v0a",60,80);
+//  binning->AddBin("centrality","v0a",80,100);
 
-*/
-/*
-  task->CreateMesh("psi","pt","y");
-*/
-
+  // disable some histograms if we don't want them
   task->DisableHistograms("^V02D");
   task->DisableHistograms("^dca");
   task->DisableHistograms("^Chi12");
   task->DisableHistograms("^Rabs12");
-  
+
+  // add the configured task to the analysis manager
   mgr->AddTask(task);  
   
-  static int n(0);
-  
-  ++n;
-  
-  if ( n > 1 ) containerName += Form("%d",n);
-  
   // Create containers for input/output
   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();  
 
   AliAnalysisDataContainer *coutputHC = 
-  mgr->CreateContainer("HC",AliMergeableCollection::Class(),AliAnalysisManager::kOutputContainer,outputname);
+  mgr->CreateContainer("OC",AliMergeableCollection::Class(),AliAnalysisManager::kOutputContainer,outputname);
 
   AliAnalysisDataContainer *coutputCC = 
   mgr->CreateContainer("CC",AliCounterCollection::Class(),AliAnalysisManager::kOutputContainer,outputname);
diff --git a/PWG/muon/AliAnalysisMuMuBase.cxx b/PWG/muon/AliAnalysisMuMuBase.cxx
new file mode 100644 (file)
index 0000000..a6a5330
--- /dev/null
@@ -0,0 +1,416 @@
+#include "AliAnalysisMuMuBase.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuBase
+ *
+ * Defines the interface of a sub-analysis to be steered by AliAnalysisTaskMuMu
+ *
+ * Daugther class has to implement one method :
+ *
+ * - \ref DefineHistogramCollection
+ *
+ * It may implement one or several of the FillHistosForXXX methods :
+ *
+ * - \ref FillHistosForEvent to fill histograms for one event
+ * - \ref FillHistosForMCEvent to fill histograms for one MC event
+ * - \ref FillHistosForTrack to fill histograms for one track
+ * - \ref FillHistosForPair to fill histograms for one muon track pair
+ *
+ * More rarely it may also implement :
+ *
+ * - \ref SetRun to do some changes when run number changes
+ * - \ref Terminate to finalize before ending
+ * - \ref SetEvent to e.g. append information to VEvent
+ *
+ * Daugther class can use the following methods :
+ *
+ * - \ref HasMC to know if MC information is available in the analyzed data
+ * - \ref Event to access the current event
+ * - \ref MCEvent to access to current MC event (if available)
+ *
+ * A few trivial cut methods (\ref AlwaysTrue and \ref AlwaysFalse) are defined as well and
+ * can be used to register some control cut combinations (see \ref AliAnalysisMuMuCutCombination)
+ *
+ */
+
+#include "AliMergeableCollection.h"
+#include "AliCounterCollection.h"
+#include "TList.h"
+#include "TObjString.h"
+#include "TMath.h"
+#include "TObjArray.h"
+#include "AliLog.h"
+#include "AliAnalysisMuMuBinning.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TProfile.h"
+#include "TRegexp.h"
+#include "AliVEvent.h"
+#include "AliAODEvent.h"
+#include "AliESDEvent.h"
+#include "AliLog.h"
+#include "AliAnalysisMuMuCutCombination.h"
+#include "AliAnalysisMuMuCutRegistry.h"
+
+ClassImp(AliAnalysisMuMuBase)
+
+namespace
+{
+    const char* MCINPUTPREFIX = "MCINPUT";
+};
+
+//_____________________________________________________________________________
+AliAnalysisMuMuBase::AliAnalysisMuMuBase()
+:
+TObject(),
+fEventCounters(0x0),
+fHistogramCollection(0x0),
+fBinning(0x0),
+fCutRegistry(0x0),
+fEvent(0x0),
+fMCEvent(0x0),
+fHistogramToDisable(0x0),
+fHasMC(kFALSE)
+{
+ /// default ctor
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuBase::CreateEventHistos(UInt_t dataType,
+                                       const char* what,
+                                       const char* hname, const char* htitle,
+                                       Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                       Int_t nbinsy, Double_t ymin, Double_t ymax) const
+{
+  /** Append histograms at the event level. Depending on dataType the created histograms
+   * are for real data only, MC data only, or both
+   */
+  
+  if ( IsHistogramDisabled(hname) ) return;
+  
+  TObjArray pathNames;
+  pathNames.SetOwner(kTRUE);
+  
+  if ( dataType & kHistoForData )
+  {
+    pathNames.Add(new TObjString(Form("/%s",what)));
+  }
+  if ( ( dataType & kHistoForMCInput ) && HasMC() )
+  {
+    pathNames.Add(new TObjString(Form("/%s/%s",MCINPUTPREFIX,what)));
+  }
+  
+  CreateHistos(pathNames,hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuBase::CreateEventHistos(UInt_t dataType,
+                                       const char* eventSelection,
+                                       const char* triggerClassName,
+                                       const char* centrality,
+                                       const char* hname, const char* htitle,
+                                       Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                       Int_t nbinsy, Double_t ymin, Double_t ymax) const
+{
+  /** Append histograms at the event level. Depending on dataType the created histograms
+   * are for real data only, MC data only, or both
+   */
+  
+  if ( IsHistogramDisabled(hname) ) return;
+  
+  TObjArray pathNames;
+  pathNames.SetOwner(kTRUE);
+
+  if ( dataType & kHistoForData )
+  {
+    pathNames.Add(new TObjString(Form("/%s/%s/%s",eventSelection,triggerClassName,centrality)));
+  }
+  if ( ( dataType & kHistoForMCInput ) && HasMC() )
+  {
+    pathNames.Add(new TObjString(Form("/%s/%s/%s/%s",MCINPUTPREFIX,eventSelection,triggerClassName,centrality)));
+  }
+  
+  CreateHistos(pathNames,hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuBase::CreateHistos(const TObjArray& paths,
+                                  const char* hname, const char* htitle,
+                                  Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                  Int_t nbinsy, Double_t ymin, Double_t ymax) const
+{
+  /// Create multiple copies of histogram hname, one per path
+  
+  if ( IsHistogramDisabled(hname) ) return;
+
+  StdoutToAliDebug(1,paths.Print(););
+  
+  TIter next(&paths);
+  TObjString* pathName;
+
+  while ( ( pathName = static_cast<TObjString*>(next()) ) )
+  {
+    TH1* h(0x0);
+    
+    if ( nbinsy > 0 )
+    {
+      AliDebug(1,Form("Created TH2F %s/%s",pathName->String().Data(),hname));
+      h = new TH2F(hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+    }
+    else if ( nbinsy == 0 )
+    {
+      AliDebug(1,Form("Created TProfile %s/%s",pathName->String().Data(),hname));
+      h = new TProfile(hname,htitle,nbinsx,xmin,xmax,ymin,ymax);
+      h->Sumw2();
+    }
+    else
+    {
+      AliDebug(1,Form("Created TH1F %s/%s",pathName->String().Data(),hname));
+      h = new TH1F(hname,htitle,nbinsx,xmin,xmax);
+      
+      if ( nbinsy < -1 )
+      {
+        h->Sumw2();
+      }
+    }
+    
+    HistogramCollection()->Adopt(pathName->String().Data(),h);
+  }
+  
+  StdoutToAliDebug(1,HistogramCollection()->Print("*"););
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuBase::CreateTrackHistos(const char* eventSelection,
+                                       const char* triggerClassName,
+                                       const char* centrality,
+                                       const char* hname, const char* htitle,
+                                       Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                       Int_t nbinsy, Double_t ymin, Double_t ymax) const
+{
+  /// Create n copies of an histogram (with name=hname, title=htitle, etc..)
+  /// where n = # of track cut combinations defined
+  /// see also CreateHistos
+  
+  
+  if ( IsHistogramDisabled(hname) ) return;
+  
+  TObjArray pathNames;
+  pathNames.SetOwner(kTRUE);
+  
+  TIter nextCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kTrack));
+  AliAnalysisMuMuCutCombination* cutCombination;
+  
+  while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination())) )
+  {
+    pathNames.Add(new TObjString(Form("/%s/%s/%s/%s",eventSelection,triggerClassName,centrality,cutCombination->GetName())));
+  }
+  
+  CreateHistos(pathNames,hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuBase::CreatePairHistos(const char* eventSelection,
+                                       const char* triggerClassName,
+                                       const char* centrality,
+                                       const char* hname, const char* htitle,
+                                       Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                       Int_t nbinsy, Double_t ymin, Double_t ymax) const
+{
+  /// Create n copies of an histogram (with name=hname, title=htitle, etc..)
+  /// where n = # of track *pair* cut combinations defined
+  /// see also CreateHistos
+  
+  
+  if ( IsHistogramDisabled(hname) ) return;
+  
+  TObjArray pathNames;
+  pathNames.SetOwner(kTRUE);
+  
+  TIter nextCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kTrackPair));
+  AliAnalysisMuMuCutCombination* cutCombination;
+  
+  while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination())) )
+  {
+    pathNames.Add(new TObjString(Form("/%s/%s/%s/%s",eventSelection,triggerClassName,centrality,cutCombination->GetName())));
+  }
+  
+  CreateHistos(pathNames,hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuBase::DisableHistograms(const char* pattern)
+{
+  /// Disable the histogramming of all the histograms matching the pattern
+  
+  TString spattern(pattern);
+  if (spattern=="*")
+  {
+    delete fHistogramToDisable;
+    fHistogramToDisable = 0x0;
+  }
+  
+  if (!fHistogramToDisable)
+  {
+    fHistogramToDisable = new TList;
+    fHistogramToDisable->SetOwner(kTRUE);
+  }
+  
+  fHistogramToDisable->Add(new TObjString(spattern));
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuBase::GetNbins(Double_t xmin, Double_t xmax, Double_t xstep)
+{
+  /// Compute number of bins to get a given step between each values in the xmin,xmax range
+  if ( TMath::AreEqualRel(xstep,0.0,1E-9) ) return 1;
+  
+  return TMath::Nint(TMath::Abs((xmax-xmin)/xstep));
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::Histo(const char* eventSelection, const char* triggerClassName, const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s",eventSelection,triggerClassName,histoname)) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::Histo(const char* eventSelection, const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(eventSelection,histoname) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::Histo(const char* eventSelection,
+                                const char* triggerClassName,
+                                const char* cent,
+                                const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s",eventSelection,triggerClassName,cent),histoname) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::Histo(const char* eventSelection,
+                                const char* triggerClassName,
+                                const char* cent,
+                                const char* what,
+                                const char* histoname)
+{
+  /// Get one histo back
+  
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s/%s",eventSelection,triggerClassName,cent,what),histoname) : 0x0;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuBase::Init(AliCounterCollection& cc,
+                               AliMergeableCollection& hc,
+                               const AliAnalysisMuMuBinning& binning,
+                               const AliAnalysisMuMuCutRegistry& registry)
+{
+  /// Set the internal references
+  fEventCounters = &cc;
+  fHistogramCollection = &hc;
+  fBinning = &binning;
+  fCutRegistry = &registry;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuBase::IsHistogramDisabled(const char* hname) const
+{
+  /// Whether or not a given histogram (identified by its name)
+  /// is disabled or not
+  
+  if ( !fHistogramToDisable )
+  {
+    return kFALSE;
+  }
+  TString shname(hname);
+  TIter next(fHistogramToDisable);
+  TObjString* str(0x0);
+  
+  while ( ( str = static_cast<TObjString*>(next()) ) )
+  {
+    if ( shname.Contains(TRegexp(str->String()) ) )
+    {
+      return kTRUE;
+    }
+  }
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuBase::IsHistogrammingDisabled() const
+{
+  /// Whether or not *all* histograms are disabled
+  
+  if ( fHistogramToDisable && fHistogramToDisable->GetEntries()==1 )
+  {
+    TObjString* r = static_cast<TObjString*>(fHistogramToDisable->First());
+    if ( r->String() == "*" )
+    {
+      return kTRUE;
+    }
+  }
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::MCHisto(const char* eventSelection, const char* triggerClassName, const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s/%s",MCINPUTPREFIX,eventSelection,triggerClassName,histoname)) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::MCHisto(const char* eventSelection, const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s",MCINPUTPREFIX,eventSelection,histoname)) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::MCHisto(const char* eventSelection,
+                                  const char* triggerClassName,
+                                  const char* cent,
+                                  const char* histoname)
+{
+  /// Get one histo back
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s/%s",MCINPUTPREFIX,eventSelection,triggerClassName,cent),histoname) : 0x0;
+}
+
+//_____________________________________________________________________________
+TH1* AliAnalysisMuMuBase::MCHisto(const char* eventSelection,
+                                  const char* triggerClassName,
+                                  const char* cent,
+                                  const char* what,
+                                  const char* histoname)
+{
+  /// Get one histo back
+  
+  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s/%s/%s",MCINPUTPREFIX,eventSelection,triggerClassName,cent,what),histoname) : 0x0;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuBase::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
+{
+  /// Set pointers to event (and mcEvent)
+  /// This is the place where a sub analysis might (if really needed)
+  /// append things to the event. Please DO NOT alter the original content,
+  /// only add to it. Unless of course you want to shoot yourself in the
+  /// foot...
+  
+  fEvent = event;
+  fMCEvent = mcEvent;
+}
+
diff --git a/PWG/muon/AliAnalysisMuMuBase.h b/PWG/muon/AliAnalysisMuMuBase.h
new file mode 100644 (file)
index 0000000..e8e672a
--- /dev/null
@@ -0,0 +1,169 @@
+#ifndef ALIANALYSISMUMUBASE_H
+#define ALIANALYSISMUMUBASE_H
+
+/**
+ *
+ * \class AliAnalysisMuMuBase
+ *
+ * \brief Base class of the sub-analysis for AliAnalysisTaskMuMu
+ *
+ * \author L. Aphecetche (Subatech)
+ */
+
+#include "TObject.h"
+#include "TString.h"
+
+class AliCounterCollection;
+class AliAnalysisMuMuBinning;
+class AliMergeableCollection;
+class AliVParticle;
+class AliVEvent;
+class AliMCEvent;
+class TH1;
+class AliInputEventHandler;
+class AliAnalysisMuMuCutRegistry;
+
+class AliAnalysisMuMuBase : public TObject
+{
+public:
+
+  AliAnalysisMuMuBase();
+  virtual ~AliAnalysisMuMuBase() {}
+
+  /** Define the histograms needed for the path starting at eventSelection/triggerClassName/centrality.
+   * This method has to ensure the histogram creation is performed only once !
+   */
+  virtual void DefineHistogramCollection(const char* eventSelection,
+                                         const char* triggerClassName,
+                                         const char* centrality) = 0;
+
+  /** Fill histograms for one event */
+  virtual void FillHistosForEvent(const char* /*eventSelection*/,const char* /*triggerClassName*/,const char* /*centrality*/) {}
+
+  /** Fill histograms for one MC event */
+  virtual void FillHistosForMCEvent(const char* /*eventSelection*/,const char* /*triggerClassName*/,const char* /*centrality*/) {}
+  
+  /** Fill histograms for one track */
+  virtual void FillHistosForTrack(const char* /*eventSelection*/,const char* /*triggerClassName*/,const char* /*centrality*/,
+                                  const char* /*trackCutName*/,
+                                  const AliVParticle& /*part*/) {}
+
+  /** Fill histograms for one track pair */
+  virtual void FillHistosForPair(const char* /*eventSelection*/,const char* /*triggerClassName*/,const char* /*centrality*/,
+                                 const char* /*pairCutName*/,
+                                 const AliVParticle& /*part1*/,
+                                 const AliVParticle& /*part2*/) {}
+  
+  virtual void Init(AliCounterCollection& cc,
+                    AliMergeableCollection& hc,
+                    const AliAnalysisMuMuBinning& binning,
+                    const AliAnalysisMuMuCutRegistry& cutRegister);
+
+  virtual void SetEvent(AliVEvent* event, AliMCEvent* mcEvent=0x0);
+
+  virtual Bool_t IsHistogramDisabled(const char* hname) const;
+  
+  virtual Bool_t IsHistogrammingDisabled() const;
+  
+  virtual void DisableHistograms(const char* pattern="*");
+  
+  AliVEvent* Event() const { return fEvent; }
+  
+  AliMCEvent* MCEvent() const { return fMCEvent; }
+  
+  /// Called at each new run
+  void SetRun(const AliInputEventHandler* /*eventHandler*/) {}
+
+  void Terminate(Option_t* /*opt*/="") {}
+  
+  enum EDataType
+  {
+    kHistoForMCInput = (1<<0),
+    kHistoForData = (1<<1)
+  };
+  
+  void SetMC() { fHasMC = kTRUE; }
+  
+  Bool_t HasMC() const { return fHasMC; }
+  
+  Bool_t AlwaysTrue(const AliVEvent& /*event*/) const { return kTRUE; }
+  Bool_t AlwaysTrue(const AliVParticle& /*particle*/) const { return kTRUE; }
+  Bool_t AlwaysTrue(const AliVParticle& /*particle*/, const AliVParticle& /*particle*/) const { return kTRUE; }
+  void NameOfAlwaysTrue(TString& name) const { name = "ALL"; }
+
+  Bool_t AlwaysFalse(const AliVEvent& /*event*/) const { return kFALSE; }
+  Bool_t AlwaysFalse(const AliVParticle& /*particle*/) const { return kFALSE; }
+  Bool_t AlwaysFalse(const AliVParticle& /*particle*/, const AliVParticle& /*particle*/) const { return kFALSE; }
+  void NameOfAlwaysFalse(TString& name) const { name = "NONE"; }
+  
+protected:
+
+  void CreateHistos(const TObjArray& paths,
+                    const char* hname, const char* htitle,
+                    Int_t nbinsx, Double_t xmin, Double_t xmax,
+                    Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
+
+  void CreateEventHistos(UInt_t dataType,
+                         const char* what,
+                         const char* hname, const char* htitle,
+                         Int_t nbinsx, Double_t xmin, Double_t xmax,
+                         Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
+
+  void CreateEventHistos(UInt_t dataType,
+                         const char* eventSelection,
+                         const char* triggerClassName,
+                         const char* centrality,
+                         const char* hname, const char* htitle,
+                         Int_t nbinsx, Double_t xmin, Double_t xmax,
+                         Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
+  
+  
+  void CreateTrackHistos(const char* eventSelection,
+                         const char* triggerClassName,
+                         const char* centrality,
+                         const char* hname, const char* htitle,
+                         Int_t nbinsx, Double_t xmin, Double_t xmax,
+                         Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
+  
+  void CreatePairHistos(const char* eventSelection,
+                        const char* triggerClassName,
+                        const char* centrality,
+                        const char* hname, const char* htitle,
+                        Int_t nbinsx, Double_t xmin, Double_t xmax,
+                        Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
+
+  TH1* Histo(const char* eventSelection, const char* histoname);
+  TH1* Histo(const char* eventSelection, const char* triggerClassName, const char* histoname);
+  TH1* Histo(const char* eventSelection, const char* triggerClassName, const char* cent, const char* histoname);
+  TH1* Histo(const char* eventSelection, const char* triggerClassName, const char* cent,
+             const char* what, const char* histoname);
+
+  TH1* MCHisto(const char* eventSelection, const char* histoname);
+  TH1* MCHisto(const char* eventSelection, const char* triggerClassName, const char* histoname);
+  TH1* MCHisto(const char* eventSelection, const char* triggerClassName, const char* cent, const char* histoname);
+  TH1* MCHisto(const char* eventSelection, const char* triggerClassName, const char* cent,
+             const char* what, const char* histoname);
+
+  Int_t GetNbins(Double_t xmin, Double_t xmax, Double_t xstep);
+
+  AliCounterCollection* CounterCollection() const { return fEventCounters; }
+  AliMergeableCollection* HistogramCollection() const { return fHistogramCollection; }
+  const AliAnalysisMuMuBinning* Binning() const { return fBinning; }
+  const AliAnalysisMuMuCutRegistry* CutRegistry() const { return fCutRegistry; }
+  
+private:
+  
+  AliCounterCollection* fEventCounters; //! event counters
+  AliMergeableCollection* fHistogramCollection; //! collection of histograms
+  const AliAnalysisMuMuBinning* fBinning; //! binning for particles
+  const AliAnalysisMuMuCutRegistry* fCutRegistry; //! registry of cut combinations
+  AliVEvent* fEvent; //! current event
+  AliMCEvent* fMCEvent; //! current MC event
+  TList* fHistogramToDisable; // list of regexp of histo name to disable
+  Bool_t fHasMC; // whether or not we're dealing with MC data
+  
+  ClassDef(AliAnalysisMuMuBase,1) // base class for a companion class to AliAnalysisMuMu
+};
+
+#endif
+
index 00451fe9cf313d456ea6a71332e645ba05df3bee..3d4eb92e28533eaf5e62dd2baf2d776697ab0093 100644 (file)
@@ -75,62 +75,62 @@ AliAnalysisMuMuBinning::~AliAnalysisMuMuBinning()
 void AliAnalysisMuMuBinning::AddBin(const AliAnalysisMuMuBinning::Range& bin)
 {
   /// add one bin
-  AddBin(bin.Particle().Data(),bin.Type().Data(),
+  AddBin(bin.What().Data(),bin.Quantity().Data(),
          bin.Xmin(),bin.Xmax(),
          bin.Ymin(),bin.Ymax(),bin.Flavour());
 }
 
 //______________________________________________________________________________
-void AliAnalysisMuMuBinning::AddBin(const char* particle, const char* type,
+void AliAnalysisMuMuBinning::AddBin(const char* what, const char* quantity,
                                     Double_t xmin, Double_t xmax,
                                     Double_t ymin, Double_t ymax,
                                     const char* flavour)
 {
   /// Add a bin
-  /// Note that particle and type are not case sensitive.
+  /// Note that what and Quantity are not case sensitive.
   if (!fBins)
   {
     fBins = new TMap;
     fBins->SetOwnerKeyValue(kTRUE,kTRUE);
   }
   
-  TString sparticle(particle);
-  sparticle.ToUpper();
+  TString swhat(what);
+  swhat.ToUpper();
   
-  TString stype(type);
-  stype.ToUpper();
+  TString sQuantity(quantity);
+  sQuantity.ToUpper();
   
-  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(sparticle.Data()));
+  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(swhat.Data()));
   if (!b)
   {
     b = new TObjArray;
     b->SetOwner(kTRUE);
-    fBins->Add(new TObjString(sparticle),b);
+    fBins->Add(new TObjString(swhat),b);
   }
 
-  Range* r = new Range(sparticle.Data(),stype.Data(),xmin,xmax,ymin,ymax,flavour);
+  Range* r = new Range(swhat.Data(),sQuantity.Data(),xmin,xmax,ymin,ymax,flavour);
   
   if ( b->FindObject(r) )
   {
-    AliDebug(1,"Trying to add an already existing bin. Not doing it.");
+    AliDebug(1,Form("Trying to add an already existing bin : %s. Not doing it.",r->AsString().Data()));
     delete r;
   }
   else
   {
     b->Add(r);
     
-    TString btype(Form("%s-%s",sparticle.Data(),stype.Data()));
+    TString bQuantity(Form("%s-%s",swhat.Data(),sQuantity.Data()));
     
     TString name(GetName());
     
-    if ( !name.Contains(btype) )
+    if ( !name.Contains(bQuantity) )
     {
       if (name.Length()>0)
       {
         name += " ";
       }
         
-      name += btype;
+      name += bQuantity;
       SetName(name);
     }
   }
@@ -174,12 +174,12 @@ TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray() const
   TObjArray* a = new TObjArray;
   a->SetOwner(kTRUE);
 
-  TIter nextParticle(fBins);
-  TObjString* particle;
+  TIter nextwhat(fBins);
+  TObjString* what;
   
-  while ( ( particle = static_cast<TObjString*>(nextParticle()) ) )
+  while ( ( what = static_cast<TObjString*>(nextwhat()) ) )
   {
-    TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(particle->String().Data()));
+    TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(what->String().Data()));
     TIter next(b);
     Range* r;
   
@@ -198,9 +198,9 @@ TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray() const
 }
 
 //______________________________________________________________________________
-TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* particle) const
+TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* what) const
 {
-  /// Get the list of bins for a given particle 
+  /// Get the list of bins for a given what 
   /// The returned array must be deleted by the user
   
   if (!fBins) return 0x0;
@@ -208,10 +208,10 @@ TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* particle) const
   TObjArray* a = new TObjArray;
   a->SetOwner(kTRUE);
   
-  TString sparticle(particle);
-  sparticle.ToUpper();
+  TString swhat(what);
+  swhat.ToUpper();
   
-  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(sparticle.Data()));
+  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(swhat.Data()));
   if (!b) return 0x0;
   
   TIter next(b);
@@ -232,39 +232,39 @@ TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* particle) const
 
 
 //______________________________________________________________________________
-TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* particle, const char* type, const char* flavour) const
+TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* what, const char* quantity, const char* flavour) const
 {
-  /// Get the list of bins for a given particle and given type
+  /// Get the list of bins for a given what and given Quantity
   /// The returned array must be deleted by the user
-  /// Type can be a single type or several types separated by comma
+  /// Quantity can be a single Quantity or several Quantitys separated by comma
   
   TObjArray* a = new TObjArray;
   a->SetOwner(kTRUE);
   
-  TString sparticle(particle);
-  sparticle.ToUpper();
+  TString swhat(what);
+  swhat.ToUpper();
 
-  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(sparticle.Data()));
+  TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(swhat.Data()));
   if (!b) return 0x0;
   
   TIter next(b);
   Range* r;
 
-  TString stype(type);
-  stype.ToUpper();
+  TString sQuantity(quantity);
+  sQuantity.ToUpper();
 
   TString sflavour(flavour);
   
-  TObjArray* types = stype.Tokenize(",");
-  TObjString* onetype;
-  TIter nextType(types);
+  TObjArray* Quantitys = sQuantity.Tokenize(",");
+  TObjString* oneQuantity;
+  TIter nextQuantity(Quantitys);
   
   while ( ( r = static_cast<Range*>(next()) ) )
   {
-    nextType.Reset();
-    while ( ( onetype = static_cast<TObjString*>(nextType()) ) )
+    nextQuantity.Reset();
+    while ( ( oneQuantity = static_cast<TObjString*>(nextQuantity()) ) )
     {
-      if ( r->Type() == onetype->String() &&
+      if ( r->Quantity() == oneQuantity->String() &&
           ( ( sflavour.Length() > 0 && r->Flavour() == sflavour.Data() ) || sflavour.Length()==0 ) )
       {
         a->Add(r->Clone());
@@ -278,31 +278,31 @@ TObjArray* AliAnalysisMuMuBinning::CreateBinObjArray(const char* particle, const
     a = 0x0;
   }
   
-  delete types;
+  delete Quantitys;
   return a;
 }
 
 //______________________________________________________________________________
-void AliAnalysisMuMuBinning::CreateMesh(const char* particle,
-                                        const char* type1, const char* type2,
+void AliAnalysisMuMuBinning::CreateMesh(const char* what,
+                                        const char* quantity1, const char* quantity2,
                                         const char* flavour,
                                         Bool_t remove12)
 {
-  /// Create 2D bins from existing 1d ones of type1 and type2
-  TObjArray* a1 = CreateBinObjArray(particle,type1,flavour);
+  /// Create 2D bins from existing 1d ones of Quantity1 and Quantity2
+  TObjArray* a1 = CreateBinObjArray(what,quantity1,flavour);
   if (!a1)
   {
-    AliError(Form("No bin for type %s. Done nothing.",type1));
+    AliError(Form("No bin for Quantity %s. Done nothing.",quantity1));
     return;
   }
-  TObjArray* a2 = CreateBinObjArray(particle,type2,flavour);
+  TObjArray* a2 = CreateBinObjArray(what,quantity2,flavour);
   if (!a2)
   {
-    AliError(Form("No bin for type %s. Done nothing.",type2));
+    AliError(Form("No bin for Quantity %s. Done nothing.",quantity2));
     return;
   }
   
-  TString meshType(Form("%s VS %s - %s",type1,type2,flavour));
+  TString meshQuantity(Form("%s VS %s - %s",quantity1,quantity2,flavour));
   
   for ( Int_t i1 = 0; i1 <= a1->GetLast(); ++i1 )
   {
@@ -312,7 +312,7 @@ void AliAnalysisMuMuBinning::CreateMesh(const char* particle,
     {
       Range* r2 = static_cast<Range*>(a2->At(i2));
       
-      AddBin(particle,meshType,r2->Xmin(),r2->Xmax(),r1->Xmin(),r1->Xmax(),Form("%s VS %s",r1->Flavour().Data(),r2->Flavour().Data()));
+      AddBin(what,meshQuantity,r2->Xmin(),r2->Xmax(),r1->Xmin(),r1->Xmax(),Form("%s VS %s",r1->Flavour().Data(),r2->Flavour().Data()));
     }
   }
   
@@ -321,19 +321,19 @@ void AliAnalysisMuMuBinning::CreateMesh(const char* particle,
 
   if ( remove12 )
   {
-    TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(particle));
+    TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(what));
     TIter next(b);
     Range* r;
-    TString stype1(type1);
-    TString stype2(type2);
+    TString sQuantity1(quantity1);
+    TString sQuantity2(quantity2);
 
-    stype1.ToUpper();
-    stype2.ToUpper();
+    sQuantity1.ToUpper();
+    sQuantity2.ToUpper();
     
     while ( ( r = static_cast<Range*>(next())) )
     {
-      if ( r->Type() == type1 ||
-           r->Type() == type2 )
+      if ( r->Quantity() == quantity1 ||
+           r->Quantity() == quantity2 )
       {
         b->Remove(r);
       }
@@ -342,60 +342,60 @@ void AliAnalysisMuMuBinning::CreateMesh(const char* particle,
 }
 
 //______________________________________________________________________________
-TObjArray* AliAnalysisMuMuBinning::CreateParticleArray() const
+TObjArray* AliAnalysisMuMuBinning::CreateWhatArray() const
 {
-  /// Create a TObjString array with the names of the particle we're holding results for
+  /// Create a TObjString array with the names of the what we're holding results for
   /// Returned array must be delete by user
   
-  TObjArray* particleArray(0x0);
+  TObjArray* whatArray(0x0);
   
-  TIter nextParticle(fBins);
-  TObjString* particle;
+  TIter nextwhat(fBins);
+  TObjString* what;
 
-  while ( ( particle = static_cast<TObjString*>(nextParticle()) ) )
+  while ( ( what = static_cast<TObjString*>(nextwhat()) ) )
   {
-    if (!particleArray)
+    if (!whatArray)
     {
-      particleArray = new TObjArray;
-      particleArray->SetOwner(kTRUE);
+      whatArray = new TObjArray;
+      whatArray->SetOwner(kTRUE);
     }
-    particleArray->Add(new TObjString(*particle));
+    whatArray->Add(new TObjString(*what));
   }
-  return particleArray;
+  return whatArray;
 }
 
 //______________________________________________________________________________
-TObjArray* AliAnalysisMuMuBinning::CreateTypeArray() const
+TObjArray* AliAnalysisMuMuBinning::CreateQuantityArray() const
 {
-  /// Create a TObjString array with the names of the binning types
+  /// Create a TObjString array with the names of the binning Quantitys
   /// Returned array must be delete by user
 
-  TObjArray* typeArray(0x0);
+  TObjArray* QuantityArray(0x0);
   
-  TIter nextParticle(fBins);
-  TObjString* particle;
+  TIter nextwhat(fBins);
+  TObjString* what;
   
-  while ( ( particle = static_cast<TObjString*>(nextParticle()) ) )
+  while ( ( what = static_cast<TObjString*>(nextwhat()) ) )
   {
-    TObjArray* particles = static_cast<TObjArray*>(fBins->GetValue(particle->String()));
+    TObjArray* whats = static_cast<TObjArray*>(fBins->GetValue(what->String()));
     
-    TIter next(particles);
+    TIter next(whats);
     Range* r;
     
     while ( ( r = static_cast<Range*>(next())) )
     {
-      if (!typeArray)
+      if (!QuantityArray)
       {
-        typeArray = new TObjArray;
-        typeArray->SetOwner(kTRUE);
+        QuantityArray = new TObjArray;
+        QuantityArray->SetOwner(kTRUE);
       }
-      if ( !typeArray->FindObject(r->Type()) )
+      if ( !QuantityArray->FindObject(r->Quantity()) )
       {
-        typeArray->Add(new TObjString(r->Type()));
+        QuantityArray->Add(new TObjString(r->Quantity()));
       }
     }
   }
-  return typeArray;
+  return QuantityArray;
 }
 
 //______________________________________________________________________________
@@ -489,23 +489,27 @@ Long64_t AliAnalysisMuMuBinning::Merge(TCollection* list)
 
 //______________________________________________________________________________
 AliAnalysisMuMuBinning*
-AliAnalysisMuMuBinning::Project(const char* particle, const char* type, const char* flavour) const
+AliAnalysisMuMuBinning::Project(const char* what, const char* quantity, const char* flavour) const
 {
-  /// Create a sub-binning object with only the bins pertaining to (particle,type)
+  /// Create a sub-binning object with only the bins pertaining to (what,Quantity)
   
-  TObjArray* bins = CreateBinObjArray(particle,type,flavour);
+  TObjArray* bins = CreateBinObjArray(what,quantity,flavour);
   if (!bins) return 0x0;
   AliAnalysisMuMuBinning* p = new AliAnalysisMuMuBinning;
   TIter next(bins);
   AliAnalysisMuMuBinning::Range* bin;
-  TString stype(type);
-  stype.ToUpper();
+  TString sQuantity(quantity);
+  sQuantity.ToUpper();
   
   while ( ( bin = static_cast<AliAnalysisMuMuBinning::Range*>(next())) )
   {
-    assert  (bin->Type()==stype && bin->Flavour()==flavour);
+    if  (bin->Quantity()!=sQuantity || bin->Flavour()!=flavour)
     {
-      p->AddBin(particle,bin->Type(),bin->Xmin(),bin->Xmax(),bin->Ymin(),bin->Ymax(),bin->Flavour().Data());
+      AliDebug(1,Form("sQuantity=%s flavour=%s bin=%s => skip",sQuantity.Data(),flavour,bin->AsString().Data()));
+      continue;
+    }
+    {
+      p->AddBin(what,bin->Quantity(),bin->Xmin(),bin->Xmax(),bin->Ymin(),bin->Ymax(),bin->Flavour().Data());
     }
   }
   
@@ -525,12 +529,12 @@ void AliAnalysisMuMuBinning::Print(Option_t* /*opt*/) const
     return;
   }
   
-  TIter nextParticle(fBins);
+  TIter nextwhat(fBins);
   TObjString* str;
   
-  while ( ( str = static_cast<TObjString*>(nextParticle()) ) )
+  while ( ( str = static_cast<TObjString*>(nextwhat()) ) )
   {
-    std::cout << "Particle : " << str->String().Data() << std::endl;
+    std::cout << "what : " << str->String().Data() << std::endl;
     TObjArray* b = static_cast<TObjArray*>(fBins->GetValue(str->String()));
     TIter next(b);
     Range* r(0x0);
@@ -550,17 +554,17 @@ void AliAnalysisMuMuBinning::Print(Option_t* /*opt*/) const
 //______________________________________________________________________________
 
 //______________________________________________________________________________
-AliAnalysisMuMuBinning::Range::Range(const char* particle, const char* type,
+AliAnalysisMuMuBinning::Range::Range(const char* what, const char* quantity,
                                      Double_t xmin, Double_t xmax,
                                      Double_t ymin, Double_t ymax,
                                      const char* flavour)
-: TObject(), fParticle(particle), fType(type),
+: TObject(), fWhat(what), fQuantity(quantity),
   fXmin(xmin), fXmax(xmax), fYmin(ymin), fYmax(ymax),
   fFlavour(flavour)
 {
   /// ctor
-  fParticle.ToUpper();
-  fType.ToUpper();
+  fWhat.ToUpper();
+  fQuantity.ToUpper();
 }
 
 //______________________________________________________________________________
@@ -568,17 +572,17 @@ TString AliAnalysisMuMuBinning::Range::AsString() const
 {
   /// Return a string representation of this range
   
-  if ( IsNullObject()) return "";
+  if ( IsIntegrated()) return Quantity().Data();
   
   TString s;
   
   if ( fFlavour.Length() > 0 )
   {
-    s.Form("%s_%s_%05.2f_%05.2f",Type().Data(),Flavour().Data(),Xmin(),Xmax());
+    s.Form("%s_%s_%05.2f_%05.2f",Quantity().Data(),Flavour().Data(),Xmin(),Xmax());
   }
   else
   {
-    s.Form("%s_%05.2f_%05.2f",Type().Data(),Xmin(),Xmax());
+    s.Form("%s_%05.2f_%05.2f",Quantity().Data(),Xmin(),Xmax());
   }
   
   if (Is2D())
@@ -600,11 +604,11 @@ Int_t     AliAnalysisMuMuBinning::Range::Compare(const TObject* obj) const
   // than obj, 0 if objects are equal and 1 if this is larger than obj.
   const Range* other = static_cast<const Range*>(obj);
   
-  int s = strcmp(Particle().Data(),other->Particle().Data());
+  int s = strcmp(What().Data(),other->What().Data());
   
   if ( s ) return s;
   
-  s = strcmp(Type().Data(),other->Type().Data());
+  s = strcmp(Quantity().Data(),other->Quantity().Data());
   
   if (s) return s;
   
@@ -612,7 +616,7 @@ Int_t       AliAnalysisMuMuBinning::Range::Compare(const TObject* obj) const
   
   if (s) return s;
   
-  if ( IsNullObject() ) return 0;
+//  if ( IsIntegrated() && other->IsIntegrated() ) return 0;
   
   if ( Xmin() < other->Xmin() )
   {
@@ -651,7 +655,7 @@ Int_t       AliAnalysisMuMuBinning::Range::Compare(const TObject* obj) const
         {
           return 1;
         }
-      }        
+      }
     }
   }
   return 0;
@@ -663,7 +667,7 @@ Bool_t AliAnalysisMuMuBinning::Range::IsInRange(Double_t x, Double_t y) const
   /// If Range is 1D, returns true if x is in range
   /// If Range is 2D, returns true if (x,y) is in range
   
-  if ( IsNullObject() )
+  if ( IsIntegrated() )
   {
     return kTRUE;
   }
@@ -671,19 +675,19 @@ Bool_t AliAnalysisMuMuBinning::Range::IsInRange(Double_t x, Double_t y) const
   {
     if ( Is2D() )
     {
-      return ( x > Xmin() && x < Xmax() && y > Ymin() && y < Ymax());
+      return ( x >= Xmin() && x < Xmax() && y >= Ymin() && y < Ymax());
     }
     else
     {
-      return ( x > Xmin() && x < Xmax() );
+      return ( x >= Xmin() && x < Xmax() );
     }
   }
 }
 
 //______________________________________________________________________________
-Bool_t AliAnalysisMuMuBinning::Range::IsNullObject() const
+Bool_t AliAnalysisMuMuBinning::Range::IsIntegrated() const
 {
-  /// Whether we're a null object or not
+  /// Whether we're a null object (aka integrated) or not
   return
   Xmin() >= TMath::Limits<Double_t>::Max() &&
   Ymin() >= TMath::Limits<Double_t>::Max() &&
@@ -697,14 +701,14 @@ void AliAnalysisMuMuBinning::Range::Print(Option_t* /*opt*/) const
 {
   /// Output to stdout
   
-  if (IsNullObject())
+  if (IsIntegrated())
   {
-    std::cout << Form("%s : %s : NullObject",Particle().Data(),Type().Data()) << std::endl;
+    std::cout << Form("%s : %s : INTEGRATED",What().Data(),Quantity().Data()) << std::endl;
   
     return;
   }
   
-  std::cout << Form("%s : %s : %5.2f : %5.2f",Particle().Data(),Type().Data(),Xmin(),Xmax());
+  std::cout << Form("%s : %s : %5.2f : %5.2f",What().Data(),Quantity().Data(),Xmin(),Xmax());
   
   if (Is2D())
   {
index ccf111bcb726b08d58a94781e27ff7695ff4fa5f..2f06c080e5ce0777a8e2551e5704f52a0672f26c 100644 (file)
@@ -30,28 +30,34 @@ public:
   
   void AddBin(const AliAnalysisMuMuBinning::Range& bin);
 
-  void AddBin(const char* particle, const char* type,
+  void AddBin(const char* what, const char* quantity,
               Double_t xmin=TMath::Limits<Double_t>::Max(),
               Double_t xmax=TMath::Limits<Double_t>::Max(),
-              Double_t ymin=TMath::Limits<Double_t>::Max(),
-              Double_t ymax=TMath::Limits<Double_t>::Max(),
+              const char* flavour="")
+  { AddBin(what,quantity,xmin,xmax,TMath::Limits<Double_t>::Max(),TMath::Limits<Double_t>::Max(),flavour); }
+
+  void AddBin(const char* what, const char* quantity,
+              Double_t xmin,
+              Double_t xmax,
+              Double_t ymin,
+              Double_t ymax,
               const char* flavour="");
 
-  TObjArray* CreateParticleArray() const;
+  TObjArray* CreateWhatArray() const;
 
-  TObjArray* CreateTypeArray() const;
+  TObjArray* CreateQuantityArray() const;
   
   Double_t* CreateBinArray() const;
 
   TObjArray* CreateBinObjArray() const;
-  TObjArray* CreateBinObjArray(const char* particle) const;
-  TObjArray* CreateBinObjArray(const char* particle, const char* type, const char* flavour) const;
+  TObjArray* CreateBinObjArray(const char* what) const;
+  TObjArray* CreateBinObjArray(const char* what, const char* quantity, const char* flavour) const;
   
-  AliAnalysisMuMuBinning* Project(const char* particle, const char* type, const char* flavour="") const;
+  AliAnalysisMuMuBinning* Project(const char* what, const char* quantity, const char* flavour="") const;
   
   virtual void Print(Option_t* opt="") const;
   
-  void CreateMesh(const char* particle, const char* type1, const char* type2, const char* flavour="", Bool_t remove12=kFALSE);
+  void CreateMesh(const char* what, const char* quantity1, const char* quantity2, const char* flavour="", Bool_t remove12=kFALSE);
 
   Long64_t Merge(TCollection* list);
 
@@ -61,7 +67,7 @@ public:
     
   public:
     
-    Range(const char* particle="",const char* type="",
+    Range(const char* what="",const char* quantity="",
           Double_t xmin=TMath::Limits<Double_t>::Max(),
           Double_t xmax=TMath::Limits<Double_t>::Max(),
           Double_t ymin=TMath::Limits<Double_t>::Max(),
@@ -78,10 +84,10 @@ public:
 
     bool operator!=(const Range& other) const { return !(*this==other); }
 
-    Bool_t IsNullObject() const;
-    
-    TString Type() const { return fType; }
-    TString Particle() const { return fParticle; }
+    Bool_t IsIntegrated() const;
+
+    TString Quantity() const { return fQuantity; }
+    TString What() const { return fWhat; }
     Double_t Xmin() const { return fXmin; }
     Double_t Xmax() const { return fXmax; }
     Double_t Ymin() const { return fYmin; }
@@ -93,7 +99,7 @@ public:
     
     Bool_t Is2D() const { return fYmax > fYmin; }
     
-    const char* GetName() const { return Type().Data(); }
+    const char* GetName() const { return What().Data(); }
     
     TString AsString() const;
     
@@ -104,23 +110,23 @@ public:
     TString Flavour() const { return fFlavour; }
     
   private:
-    TString fParticle; // particle
-    TString fType; // binning type (e.g. pt, y, phi)
+    TString fWhat; // what this range is about (e.g. J/psi particle, event, etc...)
+    TString fQuantity; // binning type (e.g. pt, y, phi)
     Double_t fXmin; // x-min of the range
     Double_t fXmax; // x-max of the range
     Double_t fYmin; // x-min of the range
     Double_t fYmax; // x-max of the range
     TString fFlavour; // flavour (if any) this range, e.g. coarse, fine, etc...
     
-    ClassDef(AliAnalysisMuMuBinning::Range,2)
+    ClassDef(AliAnalysisMuMuBinning::Range,3)
   };
   
 
  private:
 
-  TMap* fBins; // list of bins (particle -> list of bins) = (TObjString -> TObjArray)
+  TMap* fBins; // list of bins (what -> list of bins) = (TObjString -> TObjArray)
   
-  ClassDef(AliAnalysisMuMuBinning,1) // custom binning for MuMu analysis
+  ClassDef(AliAnalysisMuMuBinning,2) // custom binning for MuMu analysis
 };
 
 #endif
diff --git a/PWG/muon/AliAnalysisMuMuCutCombination.cxx b/PWG/muon/AliAnalysisMuMuCutCombination.cxx
new file mode 100644 (file)
index 0000000..068c821
--- /dev/null
@@ -0,0 +1,307 @@
+#include "AliAnalysisMuMuCutCombination.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuCutCombination
+ *
+ * A cut combination is the real cut class that is used in the sub-analysis. It is composed
+ * of one or several AliAnalysisMuMuCutElement.
+ *
+ * Unlike the cut elements, it can be of several types at the same time (i.e. it can
+ * be an event cutter and a track cutter for instance). The work is done in the
+ * Pass method(s).
+ *
+ */
+
+#include "AliAnalysisMuMuCutElement.h"
+#include "TList.h"
+#include "Riostream.h"
+#include "AliInputEventHandler.h"
+#include "AliLog.h"
+
+ClassImp(AliAnalysisMuMuCutCombination)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutCombination::AliAnalysisMuMuCutCombination()
+: TObject(), fCuts(0x0), fName(""),
+fIsEventCutter(kFALSE), fIsEventHandlerCutter(kFALSE),
+fIsTrackCutter(kFALSE), fIsTrackPairCutter(kFALSE),
+fIsTriggerClassCutter(kFALSE)
+{
+  /// Default ctor.
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutCombination::~AliAnalysisMuMuCutCombination()
+{
+  /// Dtor
+  delete fCuts;
+}
+  
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutCombination::Add(AliAnalysisMuMuCutElement* ce)
+{
+  /** Add a cut element to this combination, if the cut is not void and
+   *  not already part of the combination
+   */
+  
+  if (!ce || !ce->IsValid()) return;
+  
+  if (!fCuts)
+  {
+    fCuts = new TObjArray;
+    fCuts->SetOwner(kFALSE);
+    fIsEventCutter = ce->IsEventCutter();
+    fIsEventHandlerCutter = ce->IsEventHandlerCutter();
+    fIsTrackCutter = ce->IsTrackCutter();
+    fIsTrackPairCutter = ce->IsTrackPairCutter();
+    fIsTriggerClassCutter = ce->IsTriggerClassCutter();
+  }
+  
+  if (!fCuts->FindObject(ce))
+  {
+    fCuts->Add(ce);
+    fName += ce->GetName();
+    
+    fIsEventCutter = fIsEventCutter || ce->IsEventCutter();
+    fIsEventHandlerCutter = fIsEventHandlerCutter || ce->IsEventHandlerCutter();
+    fIsTrackCutter = fIsTrackCutter || ce->IsTrackCutter();
+    fIsTrackPairCutter = fIsTrackPairCutter || ce->IsTrackPairCutter();
+    fIsTriggerClassCutter = fIsTriggerClassCutter || ce->IsTriggerClassCutter();
+
+  }
+  
+  // update the name
+  
+  if ( IsTrackPairCutter() )
+  {
+    if ( fName[0] == 's' )
+    {
+      fName[0] = 'p';
+    }
+    else if ( fName[0] == 'p')
+    {
+      // already ok
+    }
+    else
+    {
+      TString tmp = fName;
+      fName = "p";
+      fName += tmp;
+    }
+  }
+  else if ( IsTrackCutter() )
+  {
+    if ( fName[0] == 's')
+    {
+      // already ok
+    }
+    else
+    {
+      TString tmp = fName;
+      fName = "s";
+      fName += tmp;
+    }
+  }
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutCombination::IsEqual(const TObject* obj) const
+{
+  /// Whether or not we are the same cut combination as obj
+  
+  if ( obj->IsA() != AliAnalysisMuMuCutCombination::Class() )
+  {
+    return kFALSE;
+  }
+  
+  const AliAnalysisMuMuCutCombination* other = static_cast<const AliAnalysisMuMuCutCombination*>(obj);
+
+  if ( IsEventCutter() != other->IsEventCutter() ) return kFALSE;
+  if ( IsTrackCutter() != other->IsTrackCutter() ) return kFALSE;
+  if ( IsTrackPairCutter() != other->IsTrackPairCutter() ) return kFALSE;
+  if ( IsTriggerClassCutter() != other->IsTriggerClassCutter() ) return kFALSE;
+  
+  if ( fCuts && !other->fCuts ) return kFALSE;
+  if ( !fCuts && other->fCuts ) return kFALSE;
+  
+  if ( fCuts->GetEntries() != other->fCuts->GetEntries() ) return kFALSE;
+  
+  // ok, looks similar so far, now have compute the set of cuts in common
+  // (whatever the order) to see if they really are the same combination or not
+  
+  Int_t n1in2(0);
+  Int_t n2in1(0);
+  
+  for ( Int_t i = 0; i <= fCuts->GetLast(); ++i )
+  {
+    AliAnalysisMuMuCutElement* thisCuti = static_cast<AliAnalysisMuMuCutElement*>(fCuts->At(i));
+  
+    if ( other->fCuts->FindObject(thisCuti) )
+    {
+      ++n1in2;
+    }
+  }
+
+  for ( Int_t i = 0; i <= fCuts->GetLast(); ++i )
+  {
+    AliAnalysisMuMuCutElement* otherCuti = static_cast<AliAnalysisMuMuCutElement*>(other->fCuts->At(i));
+    
+    if ( fCuts->FindObject(otherCuti) )
+    {
+      ++n2in1;
+    }
+  }
+
+  return (n1in2==n2in1 && n1in2==fCuts->GetLast()+1);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutCombination::Pass(const AliInputEventHandler& eventHandler) const
+{
+  /// Whether or not the event handler is passing the cut
+  
+  if (!fCuts) return kFALSE;
+  TIter next(fCuts);
+  AliAnalysisMuMuCutElement* ce;
+  
+  const AliVEvent* event = eventHandler.GetEvent();
+  
+  Bool_t passEvent(kTRUE);
+  Bool_t passEventHandler(kTRUE);
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    if ( ce->IsEventCutter() && !ce->Pass(*event) )
+    {
+      passEvent = kFALSE;
+    }
+
+    if ( ce->IsEventHandlerCutter() && !ce->Pass(eventHandler) )
+    {
+      passEventHandler = kFALSE;
+    }
+  }
+  
+  if ( IsEventCutter() && IsEventHandlerCutter() )
+  {
+    return passEvent && passEventHandler;
+  }
+
+  if ( IsEventHandlerCutter() )
+  {
+    return passEventHandler;
+  }
+
+  if ( IsEventCutter() )
+  {
+    return passEvent;
+  }
+  
+  return kFALSE;
+}
+  
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutCombination::Pass(const AliVParticle& particle) const
+{
+  /// Whether or not the particle is passing the cut
+
+  if (!fCuts) return kFALSE;
+  TIter next(fCuts);
+  AliAnalysisMuMuCutElement* ce;
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    if (ce->IsTrackCutter() && !ce->Pass(particle))
+    {
+      return kFALSE;
+    }
+  }
+
+  return kTRUE;
+}
+  
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutCombination::Pass(const AliVParticle& p1, const AliVParticle& p2) const
+{
+  /// Whether or not the particle pair is passing the cut
+
+  if (!fCuts) return kFALSE;
+  TIter next(fCuts);
+  AliAnalysisMuMuCutElement* ce;
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    if (ce->IsTrackPairCutter() && !ce->Pass(p1,p2))
+    {
+      return kFALSE;
+    }
+  }
+  
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutCombination::Pass(const TString& firedTriggerClasses,
+                                           TString& acceptedTriggerClasses,
+                                           UInt_t L0, UInt_t L1, UInt_t L2) const
+{
+  /** Whether or not the firedTriggerClasses pass the cut.
+   * \param firedTriggerClasses (input) list of fired trigger classes (separated by space)
+   * \param acceptedTriggerClasses (output) list of accepted classes
+   * \param L0 (input, optional) level 0 trigger mask
+   * \param L1 (input, optional) level 1 trigger mask
+   * \param L2 (input, optional) level 2 trigger mask
+   */
+
+  if (!fCuts) return kFALSE;
+  TIter next(fCuts);
+  AliAnalysisMuMuCutElement* ce;
+  Bool_t rv(kFALSE);
+  
+  // contrary to the other cut types, here we make a full loop on all
+  // the cuts, as we need to give each cut a chance to update the acceptedTriggerClasses
+  // string
+  
+  acceptedTriggerClasses = "";
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    TString tmp;
+    
+    if (ce->IsTriggerClassCutter() && ce->Pass(firedTriggerClasses,tmp,L0,L1,L2))
+    {
+      acceptedTriggerClasses += tmp;
+      acceptedTriggerClasses += " ";
+      rv = kTRUE;
+    }
+  }
+  
+  return rv;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutCombination::Print(Option_t* space) const
+{
+  /// Printout of the cut combination
+  std::cout << Form("%s(%p) [",GetName(),this);
+  if ( IsEventCutter() ) std::cout << " E";
+  if ( IsEventHandlerCutter() ) std::cout << " EH";
+  if ( IsTrackCutter() ) std::cout << " T";
+  if ( IsTrackPairCutter() ) std::cout << " TP";
+  if ( IsTriggerClassCutter() ) std::cout << " TC";
+  std::cout << " ]" << std::endl;
+  
+  TIter next(fCuts);
+  AliAnalysisMuMuCutElement* ce;
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    std::cout << space;
+    ce->Print();
+  }
+}
+
diff --git a/PWG/muon/AliAnalysisMuMuCutCombination.h b/PWG/muon/AliAnalysisMuMuCutCombination.h
new file mode 100644 (file)
index 0000000..de53645
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef ALIANALYSISMUMUCUTCOMBINATION_H
+#define ALIANALYSISMUMUCUTCOMBINATION_H
+
+/**
+ *
+ * \class AliAnalysisMuMuCutCombination
+ *
+ * \brief Defines a cut by combining several cut elements
+ *
+ * \author L. Aphecetche (Subatech)
+ */
+
+#include "TObject.h"
+#include "TString.h"
+
+class AliAnalysisMuMuCutElement;
+class AliVEvent;
+class AliInputEventHandler;
+class AliVParticle;
+
+class AliAnalysisMuMuCutCombination : public TObject
+{
+public:
+  AliAnalysisMuMuCutCombination();
+  virtual ~AliAnalysisMuMuCutCombination();
+  
+  void Add(AliAnalysisMuMuCutElement* ce);
+
+  Bool_t Pass(const AliInputEventHandler& eventHandler) const;
+  
+  Bool_t Pass(const AliVParticle& particle) const;
+  
+  Bool_t Pass(const AliVParticle& p1, const AliVParticle& p2) const;
+  
+  Bool_t Pass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses,
+              UInt_t L0, UInt_t L1, UInt_t L2) const;
+  
+  const char* GetName() const { return fName.Data(); }
+  
+  Bool_t IsEventCutter() const { return fIsEventCutter; }
+  Bool_t IsEventHandlerCutter() const { return fIsEventHandlerCutter; }
+  Bool_t IsTrackCutter() const { return fIsTrackCutter; }
+  Bool_t IsTrackPairCutter() const { return fIsTrackPairCutter; }
+  Bool_t IsTriggerClassCutter() const { return fIsTriggerClassCutter; }
+
+  void Print(Option_t* opt="") const;
+  
+  Bool_t IsEqual(const TObject* obj) const;
+  
+private:
+  /// not implemented on purpose
+  AliAnalysisMuMuCutCombination(const AliAnalysisMuMuCutCombination& rhs);
+  /// not implemented on purpose
+  AliAnalysisMuMuCutCombination& operator=(const AliAnalysisMuMuCutCombination& rhs);
+  
+private:
+  TObjArray* fCuts; // array of cut elements that form this cut combination
+  TString fName; // name of the combination
+  Bool_t fIsEventCutter; // whether or not the combination cuts on event
+  Bool_t fIsEventHandlerCutter; // whether or not the combination cuts on event handler
+  Bool_t fIsTrackCutter; // whether or not the combination cuts on track
+  Bool_t fIsTrackPairCutter; // whether or not the combination cuts on track pairs
+  Bool_t fIsTriggerClassCutter; // whether or not the combination cuts on trigger class
+  
+  ClassDef(AliAnalysisMuMuCutCombination,1) // combination of 1 or more individual cuts
+};
+
+#endif
+
diff --git a/PWG/muon/AliAnalysisMuMuCutElement.cxx b/PWG/muon/AliAnalysisMuMuCutElement.cxx
new file mode 100644 (file)
index 0000000..e2991a3
--- /dev/null
@@ -0,0 +1,602 @@
+#include "AliAnalysisMuMuCutElement.h"
+
+/**
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuCutElement
+ *
+ * An AliAnalysisMuMuCutElement is an interface/proxy to another method (see ctor)
+ *
+ * A cut has a type (event cut, track cut, etc..., see ECutType and the IsXXX methods),
+ * a name, and offers a Pass method. A cut can be of one type only. 
+ * Generally a real cut is made of several cut elements, 
+ * see \ref AliAnalysisMuMuCutCombination
+ *
+ *  \author L. Aphecetche (Subatech)
+ */
+
+#include "TMethodCall.h"
+#include "AliLog.h"
+#include "Riostream.h"
+#include "AliVParticle.h"
+
+ClassImp(AliAnalysisMuMuCutElement)
+ClassImp(AliAnalysisMuMuCutElementBar)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement::AliAnalysisMuMuCutElement()
+: TObject(), fName(""), fIsEventCutter(kFALSE), fIsEventHandlerCutter(kFALSE),
+fIsTrackCutter(kFALSE), fIsTrackPairCutter(kFALSE), fIsTriggerClassCutter(kFALSE),
+fCutObject(0x0), fCutMethodName(""), fCutMethodPrototype(""),
+fDefaultParameters(""), fNofParams(0), fCutMethod(0x0), fCallParams()
+{
+  /// Default ctor, leading to an invalid cut object
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement::AliAnalysisMuMuCutElement(ECutType expectedType,
+                                                     TObject& cutObject,
+                                                     const char* cutMethodName,
+                                                     const char* cutMethodPrototype,
+                                                     const char* defaultParameters)
+: TObject(), fName(""), fIsEventCutter(kFALSE), fIsEventHandlerCutter(kFALSE),
+fIsTrackCutter(kFALSE), fIsTrackPairCutter(kFALSE), fIsTriggerClassCutter(kFALSE),
+fCutObject(&cutObject), fCutMethodName(cutMethodName),
+fCutMethodPrototype(cutMethodPrototype),fDefaultParameters(defaultParameters),
+fNofParams(0), fCutMethod(0x0), fCallParams()
+{
+  /**
+   * Construct a cut, which is a proxy to another method of (most probably) another object
+   *
+   * \param expectedType the type of cut which is expected (this cut will be invalidated if
+   * the actual method does not comply with this type)
+   * \param cutObject the object which has the cut method
+   * \param cutMethodName the name of the method of cutObject that should do the cut work
+   * \param cutMethodPrototype the prototype (i.e. list of arguments) of cutMethod
+   * \param defaultParameters values of the default parameters (if any) of the cutMethod
+   *
+   * See the \ref Init method for details.
+   */
+
+  Init(expectedType);
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement::~AliAnalysisMuMuCutElement()
+{
+  /// Dtor
+  delete fCutMethod;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::CallCutMethod(Long_t p) const
+{
+  /// Call the cut method with one parameter
+  if (!fCutMethod)
+  {
+    Init();
+    if (!fCutMethod) return kFALSE;
+  }
+  
+  fCallParams[0] = p;
+
+  fCutMethod->SetParamPtrs(&fCallParams[0]);
+  Long_t result;
+  fCutMethod->Execute(fCutObject,result);
+  
+  return (result!=0);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::CallCutMethod(Long_t p1, Long_t p2) const
+{
+  /// Call the cut method with two parameters
+
+  if (!fCutMethod)
+  {
+    Init();
+    if (!fCutMethod) return kFALSE;
+  }
+
+  fCallParams[0] = p1;
+  fCallParams[1] = p2;
+  
+  fCutMethod->SetParamPtrs(&fCallParams[0]);
+  Long_t result;
+  fCutMethod->Execute(fCutObject,result);
+  
+  return (result!=0);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutElement::CountOccurences(const TString& prototype, const char* search) const
+{
+  /// Count the number of times "search" is found in prototype
+  
+  TObjArray* a = prototype.Tokenize(",");
+  TObjString* str;
+  TIter next(a);
+  
+  Int_t n(0);
+  
+  while ( ( str = static_cast<TObjString*>(next()) ) )
+  {
+    if  ( str->String().Contains(search) )
+    {
+      ++n;
+    }
+  }
+  delete a;
+  return n;
+}
+
+//_____________________________________________________________________________
+const char* AliAnalysisMuMuCutElement::CutTypeName(ECutType type)
+{
+  /// Convert the enum into a string
+  
+  if ( type == kEvent )
+  {
+    return "Event";
+  }
+  if ( type == kTrack )
+  {
+    return "Track";
+  }
+  if ( type == kTrackPair )
+  {
+    return "TrackPair";
+  }
+  if ( type == kTriggerClass )
+  {
+    return "TriggerClass";
+  }
+  return "Any";
+}
+
+//_____________________________________________________________________________
+const char* AliAnalysisMuMuCutElement::GetCallMethodName() const
+{
+  /// Return the cut method name
+  return ( fCutMethod ? fCutMethod->GetMethodName() : "");
+}
+
+//_____________________________________________________________________________
+const char* AliAnalysisMuMuCutElement::GetCallMethodProto() const
+{
+  /// Return the cut method prototype
+  return ( fCutMethod ? fCutMethod->GetProto() : "");
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutElement::Init(ECutType expectedType) const
+{
+  /** Build the non-persistent members (TMethodCalls)
+    *
+    * Each cut method XXXX must have
+    * a companion method, called NameOfXXXX(TString& nameOfCut) which fills the nameOfCut
+    * string with the name of cut (using the default parameter values if need be to distinguish
+    * different cuts using the same method).
+    * The cut method we're proxy-ing can not be of any kind. We basically only recognize the
+    * following prototypes (more or less based on the Pass() method prototypes). The checks
+    * performed below to ensure that are far from being bullet-proof though... You've been
+    * warned !
+    *
+    * For event cutters (3 or them instead of just one because of the, imo, 
+    * improper event/eventhandler interfaces we currently have in AliRoot)
+    *
+    * Bool_t XXXX(const AliVEvent&, ...)
+    * Bool_t XXXX(const AliVEventHandler&, ...)
+    * Bool_t XXXX(const AliInputEventHandler&, ...)
+    * 
+    * For track cutters :
+    *
+    * Bool_t XXXX(const AliVParticle&, ...)
+    *
+    * For track pairs cutters :
+    *
+    * Bool_t XXXX(const AliVParticle&, const AliVParticle&, ...)
+    *
+    * For trigger class cutters :
+    *
+    * Bool_t XXXX(const TString& firedTriggerClasses, TString& acceptedTriggerClasses)
+    *
+    * where ... stands for optional arguments (different from VEvent VParticle, etc...), 
+    * which can have default values
+    * 
+    * Note that Root reflexion does not allow (yet?) to check for constness of the arguments,
+    * so AliVEvent& and const AliVEvent& will be the same.
+    *
+    *
+   */
+  
+  TString scutMethodPrototype(fCutMethodPrototype);
+  
+  // some basic checks first
+  
+  TObjArray* tmp = fCutMethodPrototype.Tokenize(",");
+  fNofParams = tmp->GetEntries();
+  delete tmp;
+  
+  Int_t nVEvent = CountOccurences(fCutMethodPrototype,"AliVEvent");
+  Int_t nVEventHandler = CountOccurences(fCutMethodPrototype,"AliVEventHandler");
+  Int_t nInputHandler = CountOccurences(fCutMethodPrototype,"AliInputEventHandler");
+  Int_t nparticles = CountOccurences(fCutMethodPrototype,"AliVParticle");
+  Int_t nstrings = CountOccurences(fCutMethodPrototype,"TString");
+  
+  if ( expectedType == kEvent && ( nVEvent == 0 && nVEventHandler == 0 && nInputHandler == 0 ) )
+  {
+    AliError(Form("Cut not of the expected %s type : did not find required prototype arguments AliVEvent, AliVEventHandler or AliInputEventHandler",CutTypeName(kEvent)));
+    return;
+  }
+  
+  if ( expectedType == kTrack && ( nparticles != 1 ) )
+  {
+    AliError(Form("Cut not of the expected %s type : did not find the required prototype argument AliVParticle (one and only one required)",CutTypeName(kTrack)));
+    return;
+  }
+
+  if ( expectedType == kTrackPair && ( nparticles != 2 ) )
+  {
+    AliError(Form("Cut not of the expected %s type : did not find the required prototype arguments AliVParticle (2 of them required)",CutTypeName(kTrackPair)));
+    return;
+  }
+
+  if ( expectedType == kTriggerClass && ( nstrings != 2 ) )
+  {
+    AliError(Form("Cut not of the expected %stype : did not find the required prototype arguments TString& (2 of them required)",CutTypeName(kTriggerClass)));
+    return;
+  }
+  
+  // OK, at least the prototype seems to match what we require. Let's continue...
+  
+  scutMethodPrototype.ReplaceAll("  ","");
+  
+  fCutMethod = new TMethodCall;
+  
+  fCutMethod->InitWithPrototype(fCutObject->IsA(),fCutMethodName.Data(),scutMethodPrototype.Data());
+  
+  if (!fCutMethod->IsValid())
+  {
+    AliError(Form("Could not find method %s(%s) in class %s",fCutMethodName.Data(),
+                  scutMethodPrototype.Data(),fCutObject->ClassName()));
+    delete fCutMethod;
+    fCutMethod=0x0;
+    return;
+  }
+  
+  TMethodCall nameOfMethod;
+  
+  TString prototype("TString&");
+  
+  Int_t nMainPar = 0;
+  
+  if ( scutMethodPrototype.Contains("AliVEvent") )
+  {
+    fIsEventCutter=kTRUE;
+    ++nMainPar;
+  }
+  if ( scutMethodPrototype.Contains("AliInputEventHandler") )
+  {
+    fIsEventHandlerCutter=kTRUE;
+    ++nMainPar;
+  }
+
+  if ( nMainPar > 1 )
+  {
+    AliError(Form("Got an invalid prototype %s (more than one main parameter)",scutMethodPrototype.Data()));
+    delete fCutMethod;
+    fCutMethod=0x0;
+    return;
+  }
+  
+  if ( nparticles == 1 )
+  {
+    fIsTrackCutter=kTRUE;
+  }
+  else if ( nparticles == 2 )
+  {
+    fIsTrackPairCutter=kTRUE;
+  }
+  else if ( nstrings == 2 )
+  {
+    fIsTriggerClassCutter = kTRUE;
+  }
+  
+  nMainPar += nparticles;
+  nMainPar += nstrings;
+  
+  if ( nMainPar > 2 )
+  {
+    AliError(Form("Got an invalid prototype %s (more than two main parameters)",scutMethodPrototype.Data()));
+    delete fCutMethod;
+    fCutMethod=0x0;
+    return;
+  }
+  
+  if ( nMainPar == 0 )
+  {
+    AliError(Form("Got an invalid prototype %s (no main parameter found)",scutMethodPrototype.Data()));
+    delete fCutMethod;
+    fCutMethod=0x0;
+    return;
+  }
+  
+  if ( !fIsTriggerClassCutter )
+  {
+    scutMethodPrototype.ReplaceAll("const AliVEvent&","");
+    scutMethodPrototype.ReplaceAll("const AliVParticle&","");
+    scutMethodPrototype.ReplaceAll("const AliInputEventHandler&","");
+    
+    prototype += scutMethodPrototype;
+    
+    nameOfMethod.InitWithPrototype(fCutObject->IsA(),Form("NameOf%s",fCutMethodName.Data()),prototype);
+    
+    if (!nameOfMethod.IsValid())
+    {
+      AliError(Form("Could not find method NameOf%s(%s) in class %s",fCutMethodName.Data(),
+                    prototype.Data(),fCutObject->ClassName()));
+      delete fCutMethod;
+      fCutMethod=0x0;
+      return;
+    }
+    
+    // Now check if we have some default parameters for the NameOf method
+    // Note that the only supported types for those default parameters
+    // are Int_t and Double_t (which must be then of the form const Double_t&,
+    // note the reference).
+    
+    prototype.ReplaceAll("TString&","");
+    
+    TObjArray* paramTypes = prototype.Tokenize(",");
+    TObjArray* paramValues = fDefaultParameters.Tokenize(",");
+    
+    fDoubleParams.resize(paramValues->GetEntries());
+    
+    Int_t nparams = paramValues->GetEntries();
+    
+    // first parameter is always the TString&, i.e. the "output" of the NameOf
+    // method
+    
+    fCallParams.resize(nparams+nMainPar);
+    
+    if ( nMainPar == 2 )
+    {
+      fCallParams[0] = 0;
+      fCallParams[1] = reinterpret_cast<Long_t>(&fName);
+    }
+    else
+    {
+      fCallParams[0] = reinterpret_cast<Long_t>(&fName);
+    }
+    
+    for ( Int_t i = 0; i < nparams; ++i )
+    {
+      TString pValue = static_cast<TObjString*>(paramValues->At(i))->String();
+      TString pType = static_cast<TObjString*>(paramTypes->At(i))->String();
+      
+      if ( pType.Contains("Double_t"))
+      {
+        fDoubleParams[i] = pValue.Atof();
+        fCallParams[i+nMainPar] = reinterpret_cast<Long_t>(&fDoubleParams[i]);
+      }
+      else if ( pType.Contains("Int_t") )
+      {
+        fCallParams[i+nMainPar] = pValue.Atoi();
+      }
+      else
+      {
+        AliError(Form("Got a parameter of type %s which I don't exactly know how to deal with. Expect something bad to happen...",pType.Data()));
+        fCallParams[i+nMainPar] = reinterpret_cast<Long_t>(&pValue);
+      }
+    }
+    
+    nameOfMethod.SetParamPtrs(&fCallParams[0+nMainPar-1]);
+    
+    nameOfMethod.Execute(fCutObject);
+    
+    delete paramTypes;
+    delete paramValues;
+  }
+  else
+  {
+      // check whether we have the input bit masks as well
+    Int_t nuint = CountOccurences(scutMethodPrototype,"UInt_t");
+    
+    Bool_t ok =
+     ( nuint == 3 && nstrings == 2 && ( nuint + nstrings ) == fNofParams ) ||
+    ( nuint == 0 && nstrings == 2 && nstrings == fNofParams );
+    
+    if (!ok)
+    {
+      AliError("Incorrect prototype for a trigger class cutter");
+      delete fCutMethod;
+      fCutMethod=0x0;
+      return;
+    }
+  }
+  
+  // Final consistency ross-check
+  
+  if ( expectedType == kEvent && ! (fIsEventCutter || fIsEventHandlerCutter) )
+  {
+    AliError("No, it's not an event cutter. Invalidate");
+    delete fCutMethod;
+    fCutMethod=0x0;
+  }
+
+  if ( expectedType == kTrack && !fIsTrackCutter )
+  {
+    AliError("No, it's not a track cutter. Invalidate");
+    delete fCutMethod;
+    fCutMethod=0x0;
+  }
+
+  if ( expectedType == kTrackPair && !fIsTrackPairCutter )
+  {
+    AliError("No, it's not a track pair cutter. Invalidate");
+    delete fCutMethod;
+    fCutMethod=0x0;
+  }
+
+  if ( expectedType == kTriggerClass && !fIsTriggerClassCutter )
+  {
+    AliError("No, it's not a trigger class cutter. Invalidate");
+    delete fCutMethod;
+    fCutMethod=0x0;
+  }
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::IsEqual(const TObject* obj) const
+{
+  /// Whether we're the same cut as obj
+  
+  if ( obj->IsA() != IsA() ) return kFALSE;
+  
+  const AliAnalysisMuMuCutElement* cut = static_cast<const AliAnalysisMuMuCutElement*>(obj);
+  
+  return ( fName == cut->fName &&
+    fIsEventCutter == cut->fIsEventCutter &&
+    fIsEventHandlerCutter == cut->fIsEventHandlerCutter &&
+    fIsTrackCutter == cut->fIsTrackCutter &&
+    fIsTrackPairCutter == cut->fIsTrackPairCutter &&
+    fIsTriggerClassCutter == cut->fIsTriggerClassCutter &&
+    fCutMethodName == cut->fCutMethodName &&
+    fCutMethodPrototype == cut->fCutMethodPrototype &&
+    fDefaultParameters == cut->fDefaultParameters &&
+    fCutObject == cut->fCutObject /* CHECK: should we really impose object equality or class equality would be enough ? */
+  );
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::Pass(const AliVEvent& event) const
+{
+  /// Whether the event pass this cut
+  return CallCutMethod(reinterpret_cast<Long_t>(&event));
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::Pass(const AliInputEventHandler& eventHandler) const
+{
+  /// Whether the eventHandler pass this cut
+  return CallCutMethod(reinterpret_cast<Long_t>(&eventHandler));
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::Pass(const AliVParticle& part) const
+{
+  /// Whether the particle pass this cut
+  return CallCutMethod(reinterpret_cast<Long_t>(&part));
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::Pass(const AliVParticle& p1, const AliVParticle& p2) const
+{
+  /// Whether the particle pair pass this cut
+  return CallCutMethod(reinterpret_cast<Long_t>(&p1),reinterpret_cast<Long_t>(&p2));
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuCutElement::Pass(const TString& firedTriggerClasses,
+                                       TString& acceptedTriggerClasses,
+                                       UInt_t L0, UInt_t L1, UInt_t L2) const
+{
+  /** Whether the firedTriggerClasses pass the cut.
+   * \param firedTriggerClasses (input) list of fired trigger classes (separated by space)
+   * \param acceptedTriggerClasses (output) list of accepted classes
+   * \param L0 (input, optional) level 0 trigger mask
+   * \param L1 (input, optional) level 1 trigger mask
+   * \param L2 (input, optional) level 2 trigger mask
+   */
+  
+  if (!fCutMethod)
+  {
+    Init();
+    if (!fCutMethod) return kFALSE;
+  }
+  
+  acceptedTriggerClasses = "";
+  
+  Long_t result;
+  Long_t params[] = { reinterpret_cast<Long_t>(&firedTriggerClasses),
+    reinterpret_cast<Long_t>(&acceptedTriggerClasses),
+    L0,L1,L2 };
+  
+  fCutMethod->SetParamPtrs(params);
+  fCutMethod->Execute(fCutObject,result);
+  return (result!=0);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutElement::Print(Option_t* /*opt*/) const
+{
+  /// Printout of the cut information
+  if ( !fCutMethod )
+  {
+    Init();
+  }
+  
+  std::cout << Form("Cut %s(%p) %s(%p)::%s(%s) [",
+                    fName.Data(),this,
+                    fCutObject->ClassName(),
+                    fCutObject,
+                    GetCallMethodName(),
+                    GetCallMethodProto());
+  
+  if ( IsEventCutter() ) std::cout << " E";
+  if ( IsEventHandlerCutter() ) std::cout << " EH";
+  if ( IsTrackCutter() ) std::cout << " T";
+  if ( IsTrackPairCutter() ) std::cout << " TP";
+  if ( IsTriggerClassCutter() ) std::cout << " TC";
+
+  std::cout << " ]" << std::endl;
+}
+
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+
+/**
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuCutElementBar
+ *
+ * \brief The negation of an AliAnalysisMuMuCutElement
+ *
+ *  \author L. Aphecetche (Subatech)
+ */
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElementBar::AliAnalysisMuMuCutElementBar() : AliAnalysisMuMuCutElement(),
+fCutElement(0x0)
+{
+  /// default ctor
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElementBar::AliAnalysisMuMuCutElementBar(const AliAnalysisMuMuCutElement& ce)
+: AliAnalysisMuMuCutElement(), fCutElement(&ce)
+{
+  /// ctor
+  fIsEventCutter = ce.IsEventCutter();
+  fIsEventHandlerCutter = ce.IsEventHandlerCutter();
+  fIsTrackCutter = ce.IsTrackCutter();
+  fIsTrackPairCutter = ce.IsTrackPairCutter();
+  fName = TString::Format("NOT%s",ce.GetName());
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElementBar::~AliAnalysisMuMuCutElementBar()
+{
+  /// dtor (nop as we're not the owner of fCutElement)
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutElementBar::Print(Option_t* /*opt*/) const
+{
+  /// Printout of the cut information
+  std::cout << Form("Cut %s(%p) : negation of %s(%p)",GetName(),this,fCutElement->GetName(),fCutElement)
+  << std::endl;
+}
+
diff --git a/PWG/muon/AliAnalysisMuMuCutElement.h b/PWG/muon/AliAnalysisMuMuCutElement.h
new file mode 100644 (file)
index 0000000..7e476cd
--- /dev/null
@@ -0,0 +1,147 @@
+#ifndef ALIANALYSISMUMUCUTELEMENT_H
+#define ALIANALYSISMUMUCUTELEMENT_H
+
+/**
+ *
+ * \class AliAnalysisMuMuCutElement
+ *
+ * \brief Describes an elementary cut (either event cut, track cut, pair cut, or trigger class cut)
+ *
+ */
+
+#include "TObject.h"
+#include "TString.h"
+
+#include <vector>
+
+class TMethodCall;
+class AliVEvent;
+class AliInputEventHandler;
+class AliVParticle;
+
+class AliAnalysisMuMuCutElement : public TObject
+{
+public:
+  
+  enum ECutType
+  {
+    kEvent=0, // a cut on event
+    kTrack=1, // a cut on track
+    kTrackPair=2, // a cut on track pair
+    kTriggerClass=3, // a cut on trigger class
+    kAny=4 // must be the last one
+  };
+  
+  static const char* CutTypeName(ECutType type);
+  
+  AliAnalysisMuMuCutElement();
+  
+  AliAnalysisMuMuCutElement(ECutType expectedType,
+                            TObject& cutObject,
+                            const char* cutMethodName,
+                            const char* cutMethodPrototype,
+                            const char* defaultParameters);
+  
+  virtual ~AliAnalysisMuMuCutElement();
+  
+  virtual Bool_t IsValid() const { return (fCutMethod != 0x0); }
+  
+  const char* GetName() const { return fName.Data(); }
+  
+  virtual Bool_t Pass(const AliVEvent& event) const;
+
+  virtual Bool_t Pass(const AliInputEventHandler& eventHandler) const;
+
+  virtual Bool_t Pass(const AliVParticle& particle) const;
+  
+  virtual Bool_t Pass(const AliVParticle& p1, const AliVParticle& p2) const;
+  
+  virtual Bool_t Pass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses,
+                      UInt_t L0, UInt_t L1, UInt_t L2) const;
+  
+  virtual void Print(Option_t* opt="") const;
+  
+  Bool_t IsEventCutter() const { return fIsEventCutter; }
+  Bool_t IsEventHandlerCutter() const { return fIsEventHandlerCutter; }
+  Bool_t IsTrackCutter() const { return fIsTrackCutter; }
+  Bool_t IsTrackPairCutter() const { return fIsTrackPairCutter; }
+  Bool_t IsTriggerClassCutter() const { return fIsTriggerClassCutter; }
+  
+  TObject* GetCutObject() const { return fCutObject; }
+  
+  const Long_t* GetCallParams() const { return &fCallParams[0]; }
+  
+  const char* GetCallMethodName() const;
+  const char* GetCallMethodProto() const;
+  
+  Bool_t IsEqual(const TObject* obj) const;
+  
+private:
+  
+  void Init(ECutType type=kAny) const;
+  
+  Bool_t CallCutMethod(Long_t p) const;
+  Bool_t CallCutMethod(Long_t p1, Long_t p2) const;
+  
+  Int_t CountOccurences(const TString& prototype, const char* search) const;
+
+  /// not implemented on purpose
+  AliAnalysisMuMuCutElement(const AliAnalysisMuMuCutElement& rhs);
+  /// not implemented on purpose
+  AliAnalysisMuMuCutElement& operator=(const AliAnalysisMuMuCutElement& rhs);
+  
+protected:
+  TString fName; // name of the cut
+  mutable Bool_t fIsEventCutter; // whether or not the cut is an event cutter
+  mutable Bool_t fIsEventHandlerCutter; // whether or not the cut is an event handler cutter
+  mutable Bool_t fIsTrackCutter; // whether or not the cut is a track cutter
+  mutable Bool_t fIsTrackPairCutter; // whether or not the cut is a track pair cutter
+  mutable Bool_t fIsTriggerClassCutter; // whether or not the cut is a trigger class cutter
+private:
+  
+  TObject* fCutObject; // pointer (not owner) to the object doing the actual cut work
+  TString fCutMethodName; // method (of fCutObject) to be called to do the cut
+  TString fCutMethodPrototype; // prototype of the method to be called to do the cut
+  TString fDefaultParameters; // default parameters of the cut method (might be empty)
+  mutable Int_t fNofParams; // number of parameters
+  mutable TMethodCall* fCutMethod; //! cut method
+  
+  mutable std::vector<Long_t> fCallParams; //! vector of parameters for the fCutMethod
+  mutable std::vector<Double_t> fDoubleParams; //! temporary vector to hold the references
+
+  ClassDef(AliAnalysisMuMuCutElement,1) // One piece of a cut combination
+};
+
+class AliAnalysisMuMuCutElementBar : public AliAnalysisMuMuCutElement
+{
+public:
+  AliAnalysisMuMuCutElementBar();
+  
+  AliAnalysisMuMuCutElementBar(const AliAnalysisMuMuCutElement& ce);
+  
+  virtual ~AliAnalysisMuMuCutElementBar();
+  
+  Bool_t IsValid() const { return fCutElement && fCutElement->IsValid(); }
+  
+  Bool_t Pass(const AliVEvent& event) const { return !fCutElement->Pass(event); }
+  
+  Bool_t Pass(const AliInputEventHandler& eventHandler) const { return !fCutElement->Pass(eventHandler); }
+  
+  Bool_t Pass(const AliVParticle& particle) const { return !fCutElement->Pass(particle); }
+  
+  Bool_t Pass(const AliVParticle& p1, const AliVParticle& p2) const { return !fCutElement->Pass(p1,p2); }
+  
+  Bool_t Pass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses,
+              UInt_t L0, UInt_t L1, UInt_t L2) const
+  { return fCutElement->Pass(firedTriggerClasses,acceptedTriggerClasses,L0,L1,L2); }
+
+  void Print(Option_t* opt="") const;
+  
+private:
+  const AliAnalysisMuMuCutElement* fCutElement; // the cut element we're the negation of
+  
+  ClassDef(AliAnalysisMuMuCutElementBar,1) // opposite of cut element (i.e. !cutelement)
+};
+
+#endif
+
diff --git a/PWG/muon/AliAnalysisMuMuCutRegistry.cxx b/PWG/muon/AliAnalysisMuMuCutRegistry.cxx
new file mode 100644 (file)
index 0000000..414b0e5
--- /dev/null
@@ -0,0 +1,431 @@
+#include "AliAnalysisMuMuCutRegistry.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuCutRegistry
+ * The cut elements and cut combinations are stored per type, i.e. there's a set for
+ * event cuts/combinations, a set for track cuts/combinations, and a set for track pair cuts/combinations.
+ *
+ * To define a new cut use the AddEventCut, AddTrackCut, AndTrackPairCut and AddTriggerClassCut methods.
+ *
+ * To add an existing cut see AddCutElement.
+ *
+ * To define the negation of a cut, use the Not method.
+ *
+ * To add a new combination use one of the AddCutCombination methods, depending on the number
+ * of cut element(s) the combination is made of.
+ *
+ * Note that what the sub-analysis are really concerned with are cut combinations (i.e. if
+ * you fail to define any combination, nothing will be cut, whatever the number of cut elements
+ * you've defined).
+ *
+ * This class also defines a few default control cut elements aptly named AlwaysTrue.
+ *
+ */
+
+#include <utility>
+#include "AliLog.h"
+#include "TMethodCall.h"
+#include "AliVEvent.h"
+#include <set>
+#include "AliAnalysisMuMuCutElement.h"
+#include "AliAnalysisMuMuCutCombination.h"
+#include "TObjArray.h"
+#include "Riostream.h"
+#include "TList.h"
+
+ClassImp(AliAnalysisMuMuCutRegistry)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutRegistry::AliAnalysisMuMuCutRegistry()
+: TObject(),
+fCutElements(0x0),
+fCutCombinations(0x0)
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutRegistry::~AliAnalysisMuMuCutRegistry()
+{
+  /// dtor
+  
+  delete fCutElements;
+  delete fCutCombinations;
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(const TObjArray& cutElements)
+{
+  /// Add a cut combination composed of the cuts in the cutElements array.
+  ///
+  /// \return 1 in case of success, 0 if already there, -1 failure
+  
+  if ( cutElements.IsEmpty() ) return -1;
+  
+  AliAnalysisMuMuCutCombination* cutCombination = new AliAnalysisMuMuCutCombination;
+  
+  TIter next(&cutElements);
+  AliAnalysisMuMuCutElement* ce;
+  
+  while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
+  {
+    cutCombination->Add(ce);
+  }
+  
+  if ( GetCutCombinations(AliAnalysisMuMuCutElement::kAny)->FindObject(cutCombination) )
+  {
+    delete cutCombination;
+    return 0;
+  }
+  
+  GetCutCombinations(AliAnalysisMuMuCutElement::kAny)->Add(cutCombination);
+  
+  if ( cutCombination->IsEventCutter() || cutCombination->IsEventHandlerCutter() )
+  {
+    GetCutCombinations(AliAnalysisMuMuCutElement::kEvent)->Add(cutCombination);
+  }
+
+  if ( cutCombination->IsTrackCutter() )
+  {
+    GetCutCombinations(AliAnalysisMuMuCutElement::kTrack)->Add(cutCombination);
+  }
+
+  if ( cutCombination->IsTrackPairCutter() )
+  {
+    GetCutCombinations(AliAnalysisMuMuCutElement::kTrackPair)->Add(cutCombination);
+  }
+
+  if ( cutCombination->IsTriggerClassCutter() )
+  {
+    GetCutCombinations(AliAnalysisMuMuCutElement::kTriggerClass)->Add(cutCombination);
+  }
+
+  return 1;
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1)
+{
+  /// Convenience method to create a cut combination made of a single cut
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  return AddCutCombination(cutElements);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1,
+                                                    AliAnalysisMuMuCutElement* ce2)
+{
+  /// Convenience method to create a cut combination made of 2 cuts
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  if ( ce2 ) cutElements.Add(ce2);
+  return AddCutCombination(cutElements);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1,
+                                                    AliAnalysisMuMuCutElement* ce2,
+                                                    AliAnalysisMuMuCutElement* ce3)
+{
+  /// Convenience method to create a cut combination made of 3 cuts
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  if ( ce2 ) cutElements.Add(ce2);
+  if ( ce3 ) cutElements.Add(ce3);
+  return AddCutCombination(cutElements);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2, AliAnalysisMuMuCutElement* ce3,
+                        AliAnalysisMuMuCutElement* ce4)
+{
+  /// Convenience method to create a cut combination made of 4 cuts
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  if ( ce2 ) cutElements.Add(ce2);
+  if ( ce3 ) cutElements.Add(ce3);
+  if ( ce4 ) cutElements.Add(ce4);
+  return AddCutCombination(cutElements);
+}
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2, AliAnalysisMuMuCutElement* ce3,
+                        AliAnalysisMuMuCutElement* ce4, AliAnalysisMuMuCutElement* ce5)
+{
+  /// Convenience method to create a cut combination made of 5 cuts
+
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  if ( ce2 ) cutElements.Add(ce2);
+  if ( ce3 ) cutElements.Add(ce3);
+  if ( ce4 ) cutElements.Add(ce4);
+  if ( ce5 ) cutElements.Add(ce5);
+  return AddCutCombination(cutElements);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuCutRegistry::AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2, AliAnalysisMuMuCutElement* ce3,
+                        AliAnalysisMuMuCutElement* ce4, AliAnalysisMuMuCutElement* ce5, AliAnalysisMuMuCutElement* ce6)
+{
+  /// Convenience method to create a cut combination made of 6 cuts
+
+  TObjArray cutElements;
+  if ( ce1 ) cutElements.Add(ce1);
+  if ( ce2 ) cutElements.Add(ce2);
+  if ( ce3 ) cutElements.Add(ce3);
+  if ( ce4 ) cutElements.Add(ce4);
+  if ( ce5 ) cutElements.Add(ce5);
+  if ( ce6 ) cutElements.Add(ce6);
+  return AddCutCombination(cutElements);
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement*
+AliAnalysisMuMuCutRegistry::CreateCutElement(AliAnalysisMuMuCutElement::ECutType type,
+                                             TObject& cutClass,
+                                             const char* cutMethodName,
+                                             const char* cutMethodPrototype,
+                                             const char* defaultParameters)
+{
+  /** Create a cut element. See the ctor of AliAnalysisMuMuCutElement for the meaning
+   * of the parameters.
+   */
+  
+  AliAnalysisMuMuCutElement* ce = new AliAnalysisMuMuCutElement(type,cutClass,cutMethodName,cutMethodPrototype,defaultParameters);
+
+  AliAnalysisMuMuCutElement* added = AddCutElement(ce);
+  
+  if (!added)
+  {
+    delete ce;
+  }
+  
+  return added;
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement*
+AliAnalysisMuMuCutRegistry::AddCutElement(AliAnalysisMuMuCutElement* ce)
+{
+  /// Add an existing cut element to the registry if it is valid
+  
+  if ( ce && ce->IsValid() )
+  {
+    if (!GetCutElements(AliAnalysisMuMuCutElement::kAny)->FindObject(ce))
+    {
+      GetCutElements(AliAnalysisMuMuCutElement::kAny)->Add(ce);
+      if ( ce->IsEventCutter() || ce->IsEventHandlerCutter() )
+      {
+        GetCutElements(AliAnalysisMuMuCutElement::kEvent)->Add(ce);
+      }
+      else if ( ce->IsTrackCutter() )
+      {
+        GetCutElements(AliAnalysisMuMuCutElement::kTrack)->Add(ce);
+      }
+      else if ( ce->IsTrackPairCutter() )
+      {
+        GetCutElements(AliAnalysisMuMuCutElement::kTrackPair)->Add(ce);
+      }
+      else if ( ce->IsTriggerClassCutter() )
+      {
+        GetCutElements(AliAnalysisMuMuCutElement::kTriggerClass)->Add(ce);
+      }
+    }
+    return ce;
+  }
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement* AliAnalysisMuMuCutRegistry::AddEventCut(TObject& cutClass,
+                                       const char* cutMethodName,
+                                       const char* cutMethodPrototype,
+                                       const char* defaultParameters)
+{
+  /// Shortcut method to create a cut element of type kEvent
+  return CreateCutElement(AliAnalysisMuMuCutElement::kEvent,cutClass,cutMethodName,
+                          cutMethodPrototype,defaultParameters);
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement* AliAnalysisMuMuCutRegistry::AddTrackCut(TObject& cutClass,
+                                       const char* cutMethodName,
+                                       const char* cutMethodPrototype,
+                                       const char* defaultParameters)
+{
+  /// Shortcut method to create a cut element of type kTrack
+  return CreateCutElement(AliAnalysisMuMuCutElement::kTrack,cutClass,cutMethodName,
+                          cutMethodPrototype,defaultParameters);
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement* AliAnalysisMuMuCutRegistry::AddTrackPairCut(TObject& cutClass,
+                                        const char* cutMethodName,
+                                        const char* cutMethodPrototype,
+                                        const char* defaultParameters)
+{
+  /// Shortcut method to create a cut element of type kTrackPair
+  return CreateCutElement(AliAnalysisMuMuCutElement::kTrackPair,cutClass,cutMethodName,
+                          cutMethodPrototype,defaultParameters);
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement* AliAnalysisMuMuCutRegistry::AddTriggerClassCut(TObject& cutClass,
+                                              const char* cutMethodName,
+                                              const char* cutMethodPrototype,
+                                              const char* defaultParameters)
+{
+  /// Shortcut method to create a cut element of type kTriggerClass
+  return CreateCutElement(AliAnalysisMuMuCutElement::kTriggerClass,cutClass,cutMethodName,
+                          cutMethodPrototype,defaultParameters);
+}
+
+//_____________________________________________________________________________
+const TObjArray* AliAnalysisMuMuCutRegistry::GetCutCombinations(AliAnalysisMuMuCutElement::ECutType type) const
+{
+  /// Get (and create if not already done) the array of cut combinations of the given type
+
+  if (!fCutCombinations) return 0x0;
+  
+  return static_cast<TObjArray*>(fCutCombinations->At(type));
+}
+
+//_____________________________________________________________________________
+TObjArray* AliAnalysisMuMuCutRegistry::GetCutCombinations(AliAnalysisMuMuCutElement::ECutType type)
+{
+  /// Get (and create if not already done) the array of cut combinations of the given type
+
+  if (!fCutCombinations)
+  {
+    // the fCutCombinations array will be the owner of all the cut combinations
+  
+    Int_t N = AliAnalysisMuMuCutElement::kAny + 1;
+    
+    fCutCombinations = new TObjArray(N);
+    fCutCombinations->SetOwner(kTRUE);
+  
+    for ( Int_t i = 0; i < N; ++i )
+    {
+      TObjArray* array = new TObjArray;
+      array->SetOwner(kFALSE);
+      if (i==AliAnalysisMuMuCutElement::kAny)
+      {
+        // only the first array, containing all the combinations
+        // is the owner of the combinations
+        // the other arrays are just pointing to those
+        array->SetOwner(kTRUE);
+      }
+      fCutCombinations->AddAt(array,i);
+    }
+  }
+  return static_cast<TObjArray*>(fCutCombinations->At(type));
+}
+
+//_____________________________________________________________________________
+const TObjArray* AliAnalysisMuMuCutRegistry::GetCutElements(AliAnalysisMuMuCutElement::ECutType type) const
+{
+  /// Get the array of cut elements of the given type. Return 0x0 if the array does not exist yet
+
+  if (!fCutElements) return 0x0;
+  
+  return static_cast<TObjArray*>(fCutElements->At(type));
+}
+
+//_____________________________________________________________________________
+TObjArray* AliAnalysisMuMuCutRegistry::GetCutElements(AliAnalysisMuMuCutElement::ECutType type)
+{
+  /// Get (and create if not already done) the array of cut elements of the given type
+  
+  if (!fCutElements)
+  {
+    // owner of all the cut elements
+    Int_t N = AliAnalysisMuMuCutElement::kAny + 1;
+    fCutElements = new TObjArray(N);
+    fCutElements->SetOwner(kTRUE);
+  
+    for ( Int_t i = 0; i < N; ++i )
+    {
+      TObjArray* array = new TObjArray;
+      array->SetOwner(kFALSE);
+      if (i == AliAnalysisMuMuCutElement::kAny )
+      {
+        // only the first array is the owner of the cuts
+        // the other ones are just pointing to this one
+        array->SetOwner(kTRUE);
+      }
+      fCutElements->AddAt(array,i);
+    }
+  }
+  return static_cast<TObjArray*>(fCutElements->At(type));
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuCutElement* AliAnalysisMuMuCutRegistry::Not(const AliAnalysisMuMuCutElement& cutElement)
+{
+  /// Create a cut which is the opposite of cutElement, and adds it.
+  
+  AliAnalysisMuMuCutElementBar* bar = new AliAnalysisMuMuCutElementBar(cutElement);
+  
+  AliAnalysisMuMuCutElement* added = AddCutElement(bar);
+  
+  if (!added)
+  {
+    delete bar;
+  }
+  
+  return added;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuCutRegistry::Print(Option_t* opt) const
+{
+  /// Printout
+  
+  TString sopt(opt);
+  sopt.ToUpper();
+  
+  std::cout << "++++ Cut combinations defined : " << std::endl;
+  
+  AliAnalysisMuMuCutElement::ECutType cutTypes[] = { AliAnalysisMuMuCutElement::kEvent, AliAnalysisMuMuCutElement::kTrack,
+    AliAnalysisMuMuCutElement::kTrackPair, AliAnalysisMuMuCutElement::kTriggerClass };
+
+  Int_t i(1);
+
+  for ( Int_t iCutType = 0; iCutType < 4; ++iCutType )
+  {
+    if (GetCutElements(cutTypes[iCutType])->IsEmpty()) continue;
+    std::cout << "  Cutting on " << AliAnalysisMuMuCutElement::CutTypeName(cutTypes[iCutType]) << std::endl;
+    TIter next(GetCutCombinations(cutTypes[iCutType]));
+    AliAnalysisMuMuCutCombination* cutCombination;
+  
+    while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(next())) )
+    {
+      std::cout << Form("    %4d ",i);
+      cutCombination->Print("            ");
+      ++i;
+    }
+  }
+  
+  if ( sopt.Contains("FULL") || sopt.Contains("ALL") )
+  {
+    std::cout << "++++ Individual cuts defined : " << std::endl;
+    
+    for ( Int_t iCutType = 0; iCutType < 4; ++iCutType )
+    {
+      if (GetCutElements(cutTypes[iCutType])->IsEmpty()) continue;
+      std::cout << "  Cutting on " << AliAnalysisMuMuCutElement::CutTypeName(cutTypes[iCutType]) << std::endl;
+      TIter nextCutRef(GetCutElements(cutTypes[iCutType]));
+      AliAnalysisMuMuCutElement* ce;
+      i = 1;
+      while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(nextCutRef()) ) )
+      {
+        std::cout << Form("%4d ",i);
+        ce->Print();
+        ++i;
+      }
+    }
+  }
+}
diff --git a/PWG/muon/AliAnalysisMuMuCutRegistry.h b/PWG/muon/AliAnalysisMuMuCutRegistry.h
new file mode 100644 (file)
index 0000000..0675d50
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef ALIANALYSISMUMUCUTREGISTRY_H
+#define ALIANALYSISMUMUCUTREGISTRY_H
+
+/**
+ *
+ * \class AliAnalysisMuMuCutRegistry
+ *
+ * \brief Container of AliAnalysisMuMuCutElement and AliAnalysisMuMuCutCombination objects.
+ *
+ * \author L. Aphecetche (Subatech)
+ *
+ */
+
+#include "TObject.h"
+#include "TString.h"
+#include "TMethodCall.h"
+#include "AliAnalysisMuMuCutElement.h"
+
+class AliVEvent;
+class AliAnalysisMuMuCutCombination;
+class AliVParticle;
+class AliVEventHandler;
+
+class AliAnalysisMuMuCutRegistry : public TObject
+{
+public:
+  AliAnalysisMuMuCutRegistry();
+  virtual ~AliAnalysisMuMuCutRegistry();
+
+  AliAnalysisMuMuCutElement* AddEventCut(TObject& cutClass,
+                                         const char* cutMethodName,
+                                         const char* cutMethodPrototype,
+                                         const char* defaultParameters);
+  
+  AliAnalysisMuMuCutElement* AddTrackCut(TObject& cutClass,
+                                         const char* cutMethodName,
+                                         const char* cutMethodPrototype,
+                                         const char* defaultParameters);
+  
+  AliAnalysisMuMuCutElement* AddTrackPairCut(TObject& cutClass,
+                                             const char* cutMethodName,
+                                             const char* cutMethodPrototype,
+                                             const char* defaultParameters);
+  
+  AliAnalysisMuMuCutElement* AddTriggerClassCut(TObject& cutClass,
+                                                const char* cutMethodName,
+                                                const char* cutMethodPrototype,
+                                                const char* defaultParameters);
+  
+  AliAnalysisMuMuCutElement* Not(const AliAnalysisMuMuCutElement& cutElement);
+
+  AliAnalysisMuMuCutElement* AddCutElement(AliAnalysisMuMuCutElement* ce);
+
+  Int_t AddCutCombination(const TObjArray& cutElements);
+  
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1);
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2);
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2,
+                          AliAnalysisMuMuCutElement* ce3);
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2,
+                          AliAnalysisMuMuCutElement* ce3, AliAnalysisMuMuCutElement* ce4);
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2,
+                          AliAnalysisMuMuCutElement* ce3, AliAnalysisMuMuCutElement* ce4,
+                          AliAnalysisMuMuCutElement* ce5);
+  Int_t AddCutCombination(AliAnalysisMuMuCutElement* ce1, AliAnalysisMuMuCutElement* ce2,
+                          AliAnalysisMuMuCutElement* ce3, AliAnalysisMuMuCutElement* ce4,
+                          AliAnalysisMuMuCutElement* ce5, AliAnalysisMuMuCutElement* ce6);
+
+  const TObjArray* GetCutCombinations(AliAnalysisMuMuCutElement::ECutType type) const;
+  TObjArray* GetCutCombinations(AliAnalysisMuMuCutElement::ECutType type);
+
+  const TObjArray* GetCutElements(AliAnalysisMuMuCutElement::ECutType type) const;
+  TObjArray* GetCutElements(AliAnalysisMuMuCutElement::ECutType type);
+
+  virtual void Print(Option_t* opt="") const;
+  
+  Bool_t AlwaysTrue(const AliVEvent& /*event*/) const { return kTRUE; }
+  void NameOfAlwaysTrue(TString& name) const { name="ALL"; }
+  Bool_t AlwaysTrue(const AliVEventHandler& /*eventHandler*/) const { return kTRUE; }
+  Bool_t AlwaysTrue(const AliVParticle& /*part*/) const { return kTRUE; }
+  Bool_t AlwaysTrue(const AliVParticle& /*p1*/, const AliVParticle& /*p2*/) const { return kTRUE; }
+  
+private:
+  
+  /// not implemented on purpose
+  AliAnalysisMuMuCutRegistry(const AliAnalysisMuMuCutRegistry& rhs);
+  /// not implemented on purpose
+  AliAnalysisMuMuCutRegistry& operator=(const AliAnalysisMuMuCutRegistry& rhs);
+  
+  AliAnalysisMuMuCutElement* CreateCutElement(AliAnalysisMuMuCutElement::ECutType expectedType,
+                                              TObject& cutClass,
+                                              const char* cutMethodName,
+                                              const char* cutMethodPrototype,
+                                              const char* defaultParameters);
+  
+private:
+  
+  mutable TObjArray* fCutElements; // cut elements
+  mutable TObjArray* fCutCombinations; // cut combinations
+  
+  ClassDef(AliAnalysisMuMuCutRegistry,1) // storage for cut pointers
+};
+
+#endif
diff --git a/PWG/muon/AliAnalysisMuMuEventCutter.cxx b/PWG/muon/AliAnalysisMuMuEventCutter.cxx
new file mode 100644 (file)
index 0000000..e710679
--- /dev/null
@@ -0,0 +1,291 @@
+#include "AliAnalysisMuMuEventCutter.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuEventCutter
+ *
+ * We're grouping here various event cut methods that can be used
+ * as AliAnalysisMuMuCutElement. For instance :
+ *
+ * - \ref IsPhysicsSelected this is the normal physics selection check
+ * - \ref IsPhysicsSelectedVDM version of the physics selection used for VdM analysis
+ * - \ref IsSPDzVertexInRange selects event with a SPDvertex in a given range
+ * - \ref IsAbsZBelowValue selects event with |Zvertex| (being SPD or not) below a given value
+ * - \ref IsAbsZBelowValue as above but requesting explicitely the SPD vertex
+ * - \ref IsSPDzQA whether the SPD vertex is a good one
+ */
+
+#include "TObjString.h"
+#include "AliLog.h"
+#include "AliMuonEventCuts.h"
+#include "TList.h"
+#include "Riostream.h"
+#include "AliVVertex.h"
+#include "AliAODVertex.h"
+#include "AliVVZERO.h"
+#include "AliInputEventHandler.h"
+#include "AliVEvent.h"
+#include "TMath.h"
+#include "AliESDTZERO.h"
+#include "AliAODTZERO.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+
+ClassImp(AliAnalysisMuMuEventCutter)
+
+//______________________________________________________________________________
+AliAnalysisMuMuEventCutter::AliAnalysisMuMuEventCutter(TList* triggerClasses)
+: TObject(), fMuonEventCuts(0x0)
+{
+  /// ctor
+  TString tclasses;
+  
+  if ( !triggerClasses )
+  {
+    tclasses = "ANY";
+  }
+  else
+  {
+    TObjString* tname;
+    TIter next(triggerClasses);
+    
+    while ( ( tname = static_cast<TObjString*>(next()) ) )
+    {
+      if (tclasses.Length()>0)
+      {
+        tclasses += ",";
+      }
+      
+      tclasses += tname->String();
+    }
+  }
+  
+  MuonEventCuts()->SetTrigClassPatterns(tclasses);
+}
+
+//______________________________________________________________________________
+AliAnalysisMuMuEventCutter::~AliAnalysisMuMuEventCutter()
+{
+  /// dtor
+  delete fMuonEventCuts;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::SelectTriggerClass(const TString& firedTriggerClasses,
+                                                      TString& acceptedClasses,
+                                                      UInt_t L0, UInt_t L1, UInt_t L2) const
+{
+  /// Forward the trigger class selection to MuonEventCuts::GetSelectedTrigClassesInEvent
+  acceptedClasses = "";
+  
+  TIter next(MuonEventCuts()->GetSelectedTrigClassesInEvent(firedTriggerClasses,L0,L1,L2));
+  TObjString* str;
+  
+  while ( ( str = static_cast<TObjString*>(next()) ) )
+  {
+    acceptedClasses += str->String();
+    acceptedClasses += " ";
+  }
+  return (acceptedClasses.Length()>0);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsPhysicsSelected(const AliInputEventHandler& eventHandler) const
+{
+  /// Whether or not the event is physics selected
+  return const_cast<AliInputEventHandler&>(eventHandler).IsEventSelected() & AliVEvent::kAny;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsPhysicsSelectedVDM(const AliVEvent& event) const
+{
+  // cut used in vdM scans
+  
+  AliVVZERO* vzero = event.GetVZEROData();
+  
+  if (vzero)
+  {
+    Float_t v0a = vzero->GetV0ATime();
+    Float_t v0c = vzero->GetV0CTime();
+    
+    Float_t v0diff = v0a-v0c;
+    Float_t v0sum = v0a+v0c;
+    
+    if ( ( v0sum > 10.5 && v0sum < 18 ) && ( v0diff > 4 && v0diff < 12 ) )
+    {
+      return kTRUE;
+    }
+  }
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsAbsZBelowValue(const AliVEvent& event, const Double_t& z) const
+{
+  // Checks if the absolute value of the Z component of the primary vertex is below a certain value
+  
+  const AliVVertex* vertex = event.GetPrimaryVertex();
+  return (TMath::Abs(vertex->GetZ())<=z);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsAbsZSPDBelowValue(const AliVEvent& event, const Double_t& z) const
+{
+  // Checks if the absolute value of the SPD Z component of the given vertex is below a certain value
+  AliAODVertex* SPDVertex = static_cast<const AliAODEvent*>(&event)->GetPrimaryVertexSPD();
+  
+  if ( !SPDVertex )
+  {
+    AliError("SPD |z| cut requested and no SPD vertex found in the event");
+    return kFALSE;
+  }
+  
+  else return (TMath::Abs(SPDVertex->GetZ())<=z);
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsSPDzVertexInRange(AliVEvent& event, const Double_t& zMin, const Double_t& zMax) const
+{
+  /// Whether or not the SPD Z vertex is in the range [zMin,zMax[
+  
+  AliAODVertex* SPDVertex = static_cast<AliAODEvent*>(&event)->GetPrimaryVertexSPD();
+  
+  if ( !SPDVertex )
+  {
+    AliError("Cut on SPD z Vertex requested for an event with no SPD vertex info");
+    return kFALSE;
+  }
+  Double_t zV = SPDVertex->GetZ();
+  
+  if ( zV >= zMin && zV < zMax ) return kTRUE;
+  else return kFALSE;
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::HasSPDVertex(AliVEvent& event) const
+{
+  /// Does the event have a SPD vertex ?
+  AliAODVertex* SPDVertex = static_cast<AliAODEvent*>(&event)->GetPrimaryVertexSPD();
+  if ( SPDVertex && SPDVertex->GetNContributors() > 0) return kTRUE;
+  else return kFALSE;
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsSPDzQA(const AliVEvent& event, /*const AliVVertex& vertex2Test,*/ const Double_t& zResCut, const Double_t& zDifCut) const
+{
+  // Checks if the value of the Z component of the given vertex fullfills the quality assurance condition
+  
+  const AliVVertex* vertex = event.GetPrimaryVertex();
+  const AliAODVertex* vertex2Test = static_cast<const AliAODEvent*>(&event)->GetPrimaryVertexSPD();
+  
+  Double_t cov[6]={0};
+  vertex2Test->GetCovarianceMatrix(cov);
+  Double_t zRes = TMath::Sqrt(cov[5]);
+  
+  if ( (zRes < zResCut) && TMath::Abs(vertex2Test->GetZ() - vertex->GetZ()) <= zDifCut )
+  {
+    return kTRUE;
+  }
+  else return kFALSE;
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsMeandNchdEtaInRange(AliVEvent& event, const Double_t& dNchdEtaMin, const Double_t& dNchdEtaMax) const
+{
+  TList* nchList = static_cast<TList*>(event.FindListObject("NCH"));
+  
+  if (!nchList || nchList->IsEmpty())
+  {
+    AliFatal("No NCH information found in event. Nch analysis MUST be executed to apply a NCH cut");
+    return kFALSE;
+  }
+  
+  Int_t i(0);
+  
+  while ( nchList->At(i)->IsA() != TObjString::Class() ) //Asign a name to find it by name
+  {
+    i++;
+  }
+  
+  TObjString* value = static_cast<TObjString*>(nchList->At(i));
+  Double_t meandNchdEta = value->String().Atof();
+  
+  if ( meandNchdEta >= dNchdEtaMin && meandNchdEta < dNchdEtaMax ) return kTRUE;
+  else return kFALSE;
+}
+
+
+//_____________________________________________________________________________
+AliMuonEventCuts*
+AliAnalysisMuMuEventCutter::MuonEventCuts() const
+{
+  /// Return the single instance of AliMuonEventCuts object we're using
+  
+  if (!fMuonEventCuts)
+  {
+    fMuonEventCuts = new AliMuonEventCuts("EventCut","");
+  }
+  return fMuonEventCuts;
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuEventCutter::NameOfIsSPDzVertexInRange(TString& name, const Double_t& zMin, const Double_t& zMax) const
+{
+  name.Form("SPDZBTW%3.2f_%3.2f",zMin,zMax);
+}
+//_____________________________________________________________________________
+void AliAnalysisMuMuEventCutter::NameOfIsAbsZBelowValue(TString& name, const Double_t& z) const
+{
+  name.Form("ABSZLT%3.2f",z);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuEventCutter::NameOfIsAbsZSPDBelowValue(TString& name, const Double_t& z) const
+{
+  name.Form("SPDABSZLT%3.2f",z);
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuEventCutter::NameOfIsSPDzQA(TString& name, const Double_t& zResCut, const Double_t& zDifCut) const
+{
+  name.Form("SPDZQA_RES%3.2f_ZDIF%3.2f",zResCut,zDifCut);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuEventCutter::NameOfIsMeandNchdEtaInRange(TString& name, const Double_t& dNchdEtaMin, const Double_t& dNchdEtaMax) const
+{
+  name.Form("MEANDNDETABTW%3.2f_%3.2f",dNchdEtaMin,dNchdEtaMax);
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuEventCutter::IsTZEROPileUp(const AliVEvent& event) const
+{
+  Bool_t pileupFlag(kFALSE);
+  
+  if ( event.IsA() == AliESDEvent::Class() )
+  {
+    const AliESDTZERO* tzero = static_cast<AliESDEvent&>(const_cast<AliVEvent&>(event)).GetESDTZERO();
+    if ( tzero )
+    {
+      pileupFlag = tzero->GetPileupFlag();
+    }
+  }
+  else if ( event.IsA() == AliAODEvent::Class() )
+  {
+    AliAODTZERO* tzero = static_cast<const AliAODEvent&>(event).GetTZEROData();
+    if ( tzero )
+    {
+      pileupFlag = tzero->GetPileupFlag();
+    }
+  }
+  return pileupFlag;
+}
diff --git a/PWG/muon/AliAnalysisMuMuEventCutter.h b/PWG/muon/AliAnalysisMuMuEventCutter.h
new file mode 100644 (file)
index 0000000..c107bc6
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef ALIANALYSISMUMUEVENTCUTTER_H
+#define ALIANALYSISMUMUEVENTCUTTER_H
+
+/**
+ * 
+ * \class AliAnalysisMuMuEventCutter
+ *
+ * \brief Various event cuts used in AliAnalysisTaskMuMu
+ *
+ * \author L. Aphecetche and J. Martin-Bianco
+ *
+ */
+
+#include "TObject.h"
+#include "TString.h"
+
+class AliMuonEventCuts;
+class TList;
+class AliVEvent;
+class AliVVertex;
+class AliInputEventHandler;
+
+class AliAnalysisMuMuEventCutter : public TObject
+{
+public:
+  AliAnalysisMuMuEventCutter(TList* triggerClassesToConsider=0x0);
+  virtual ~AliAnalysisMuMuEventCutter();
+  
+  Bool_t SelectTriggerClass(const TString& firedTriggerClasses, TString& acceptedClasses,
+                            UInt_t L0, UInt_t L1, UInt_t L2) const;
+  
+  Bool_t IsTrue(const AliVEvent& /*event*/) const { return kTRUE; }
+  void NameOfIsTrue(TString& name) const { name="ALL"; }
+
+  Bool_t IsFalse(const AliVEvent& /*event*/) const { return kFALSE; }
+  void NameOfIsFalse(TString& name) const { name="NONE"; }
+
+  Bool_t IsPhysicsSelected(const AliInputEventHandler& eventHandler) const;
+  void NameOfIsPhysicsSelected(TString& name) const { name="PSALL"; }
+
+  Bool_t IsPhysicsSelectedVDM(const AliVEvent& event) const;
+  void NameOfIsPhysicsSelectedVDM(TString& name) const { name="VDM"; }
+
+  Bool_t IsAbsZBelowValue(const AliVEvent& event, const Double_t& z) const;
+  void NameOfIsAbsZBelowValue(TString& name, const Double_t& z) const;
+  
+  Bool_t IsAbsZSPDBelowValue(const AliVEvent& event, const Double_t& z) const;
+  void NameOfIsAbsZSPDBelowValue(TString& name, const Double_t& z) const;
+  
+  Bool_t IsSPDzVertexInRange(AliVEvent& event, const Double_t& zMin, const Double_t& zMax) const;
+  void NameOfIsSPDzVertexInRange(TString& name, const Double_t& zMin, const Double_t& zMax) const;
+  
+  Bool_t IsSPDzQA(const AliVEvent& event/*, const AliVVertex& vertex2Test*/, const Double_t& zResCut, const Double_t& zDifCut) const;
+  void NameOfIsSPDzQA(TString& name, const Double_t& zResCut, const Double_t& zDifCut) const;
+  
+  Bool_t HasSPDVertex(AliVEvent& event) const;
+  void NameOfHasSPDVertex(TString& name) const { name = "HASSPD"; }
+  
+  Bool_t IsMeandNchdEtaInRange(AliVEvent& event, const Double_t& dNchdEtaMin, const Double_t& dNchdEtaMax) const;
+  void NameOfIsMeandNchdEtaInRange(TString& name, const Double_t& dNchdEtaMin, const Double_t& dNchdEtaMax) const;
+  
+  Bool_t IsTZEROPileUp(const AliVEvent& event) const;
+  void NameOfIsTZEROPileUp(TString& name) const { name="TZEROPILEUP"; }
+  
+  AliMuonEventCuts* MuonEventCuts() const;
+  
+//  enum EEventCut
+//  {
+//    kEventIR2PILEUP     = BIT( 6), /// events with pile-up (using AliAnalysisUtils::IsOutOfBunchPileUp)
+//    
+//    kEventGOODVERTEX    = BIT(10), /// events with a good vertex
+//    kEventZPOS          = BIT(14), /// events with z > 0
+//    kEventZNEG          = BIT(15), /// events with z < 0
+//    
+//    kEventTRKLETA1      = BIT(20), /// event with at least one tracklet in |eta| < fTrackletEtaCutValue[0]
+
+//    kEvent0TVX          = BIT(31), /// events with 0TVX L0 input
+//    kEventV0AND         = BIT(32), /// events with both 0V0C and 0V0A L0 inputs
+//    kEvent0SM2          = BIT(33), /// events with 0SM2 L0 input
+//    kEvent0MSL          = BIT(34), /// events with 0MSL input
+//  };
+  
+private:
+  
+  mutable AliMuonEventCuts* fMuonEventCuts; // common cuts for muon events (from Diego)
+  
+  ClassDef(AliAnalysisMuMuEventCutter,1) // default event cutters for AliAnalysisTaskMuMu
+};
+
+#endif
diff --git a/PWG/muon/AliAnalysisMuMuGlobal.cxx b/PWG/muon/AliAnalysisMuMuGlobal.cxx
new file mode 100644 (file)
index 0000000..8294abf
--- /dev/null
@@ -0,0 +1,334 @@
+#include "AliAnalysisMuMuGlobal.h"
+
+/**
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuGlobal
+ *
+ * Very simple histogramming analysis for global event properties, like vertex, bunch-crossing,
+ * background, etc...
+ *
+ * Warning : not really ready for prime-time
+ *
+ */
+
+#include "TH1.h"
+#include "AliVVertex.h"
+#include "AliVEvent.h"
+#include "AliAODEvent.h"
+#include "AliAnalysisMuonUtility.h"
+#include "AliAODTZERO.h"
+#include "AliESDEvent.h"
+#include "AliAnalysisMuMuBinning.h"
+#include <set>
+#include "AliMergeableCollection.h"
+#include "AliAnalysisMuonUtility.h"
+
+ClassImp(AliAnalysisMuMuGlobal)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuGlobal::AliAnalysisMuMuGlobal() : AliAnalysisMuMuBase()
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuGlobal::DefineHistogramCollection(const char* eventSelection,
+                                                      const char* triggerClassName,
+                                                      const char* centrality)
+{
+  /// Actually create the histograms for phyics/triggerClassName
+  
+  //  AliInfo(Form("%s %s %s %d",eventSelection,triggerClassName,centrality,hasMC));
+  
+  if (HistogramCollection()->Histo(Form("/%s/%s/%s/Zvertex",eventSelection,triggerClassName,centrality)))
+  {
+    return;
+  }
+  
+  Double_t xmin = -40;
+  Double_t xmax = +40;
+  Int_t nbins = GetNbins(xmin,xmax,0.5);
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Zvertex","z vertex",nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"T0Zvertex","T0 zvertex",nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,
+                    "RecZvertexVsMCZvertex","Reconstructed vertex (w/ Ncontrib>=1) vs MC vertex",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  xmin = -5;
+  xmax = 5;
+  nbins = GetNbins(xmin,xmax,0.01);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"ZvertexMinusZvertexSPD","Primary vertex z - SPD vertex",nbins,xmin,xmax);
+  
+  xmin = -1;
+  xmax = 50;
+  nbins = GetNbins(xmin,xmax,1);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"ZvertexNContributors","z vertex nof contributors",nbins,xmin,xmax);
+  
+  xmin = -2;
+  xmax = 2;
+  nbins = GetNbins(xmin,xmax,0.01);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Xvertex","x vertex",nbins,xmin,xmax);
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Yvertex","y vertex",nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Nevents","number of events",2,-0.5,1.5);
+  
+  CreateEventHistos(kHistoForMCInput | kHistoForData,eventSelection,triggerClassName,centrality,
+                    "VertexType","Type of vertexer used",10,0,10);
+  
+  
+  xmin = 0;
+  xmax = 3564;
+  nbins = GetNbins(xmin,xmax,1.0);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"BCX","bunch-crossing ids",nbins,xmin-0.5,xmax-0.5);
+  
+  
+  xmin = -30;
+  xmax = +30;
+  nbins = GetNbins(xmin,xmax,0.1);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02D","V0C+V0A versus V0A-V0C;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0BB","V0C+V0A versus V0A-V0C with T0 BB;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0BG","V0C+V0A versus V0A-V0C with T0 background flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0PU","V0C+V0A versus V0A-V0C with T0 pile up flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0SAT","V0C+V0A versus V0A-V0C with T0 satellite flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
+  
+  xmin = 0;
+  xmax = 600;
+  nbins = GetNbins(xmin,xmax,1);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V0AMult","V0A multiplicity",nbins,xmin,xmax);
+  
+  if ( !IsHistogramDisabled("Centrality") )
+  {
+    TObjArray* centralities = Binning()->CreateBinObjArray("centrality");
+    TIter next(centralities);
+    AliAnalysisMuMuBinning::Range* r;
+    std::set<std::string> estimators;
+    
+    while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next())) )
+    {
+      estimators.insert(r->Quantity().Data());
+    }
+    
+    std::set<std::string>::const_iterator it;
+    
+    for ( it = estimators.begin(); it != estimators.end(); ++it )
+    {
+      TH1* h = new TH1F("Centrality","Centrality",12,-10,110);
+      HistogramCollection()->Adopt(Form("/%s/%s/%s",eventSelection,triggerClassName,it->c_str()),h);
+    }
+    
+    delete centralities;
+  }
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"PileUpEstimators","pile up estimators",10,0,10);
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuGlobal::FillHistosForEvent(const char* eventSelection,
+                                               const char* triggerClassName,
+                                               const char* centrality)
+{
+  // Fill event-wise histograms
+  
+  if (!IsHistogramDisabled("BCX"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,"BCX")->Fill(1.0*Event()->GetBunchCrossNumber());
+  }
+  if (!IsHistogramDisabled("Nevents"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,"Nevents")->Fill(1.0);
+  }
+  
+  const AliVVertex* vertex = Event()->GetPrimaryVertex();
+  const AliVVertex* vertexFromSPD = AliAnalysisMuonUtility::GetVertexSPD(Event());
+  
+  if ( vertex && vertexFromSPD )
+  {
+    if ( vertex->GetNContributors() > 0 )
+    {
+      if (!IsHistogramDisabled("Xvertex"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,"Xvertex")->Fill(vertex->GetX());
+      }
+      if (!IsHistogramDisabled("Yvertex"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,"Yvertex")->Fill(vertex->GetY());
+      }
+      if (!IsHistogramDisabled("Zvertex"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,"Zvertex")->Fill(vertex->GetZ());
+      }
+      if (!IsHistogramDisabled("ZvertexMinusZvertexSPD"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,"ZvertexMinusZvertexSPD")->Fill(vertexFromSPD->GetZ()-vertex->GetZ());
+      }
+      if (!IsHistogramDisabled("VertexType"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,"VertexType")->Fill(vertex->GetTitle(),1.0);
+      }
+    }
+    if (!IsHistogramDisabled("ZvertexNContributors"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,"ZvertexNContributors")->Fill(vertex->GetNContributors());
+    }
+  }
+  
+  if ( AliAnalysisMuonUtility::IsAODEvent(Event()) )
+  {
+    const AliAODTZERO* tzero = static_cast<const AliAODEvent*>(Event())->GetTZEROData();
+    
+    if (tzero && !IsHistogramDisabled("T0Zvertex"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0VertexRaw());
+    }
+  }
+  else
+  {
+    const AliESDTZERO* tzero = static_cast<const AliESDEvent*>(Event())->GetESDTZERO();
+    
+    if (tzero && !IsHistogramDisabled("T0Zvertex"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0zVertex());
+    }
+  }
+  
+  AliVVZERO* vzero = Event()->GetVZEROData();
+  
+  if (vzero)
+  {
+    Float_t v0a = vzero->GetV0ATime();
+    Float_t v0c = vzero->GetV0CTime();
+    
+    Float_t x = v0a-v0c;
+    Float_t y = v0a+v0c;
+    
+    if (!IsHistogramDisabled("V0A"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,"V0AMult")->Fill(vzero->GetMTotV0A());
+    }
+    if (!IsHistogramDisabled("V02D"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,"V02D")->Fill(x,y);
+    }
+    
+    Bool_t background,pileup,satellite;
+    
+    Bool_t tzero = AliAnalysisMuonUtility::EAGetTZEROFlags(Event(),background,pileup,satellite);
+    
+    if (tzero)
+    {
+      if ( background )
+      {
+        if (!IsHistogramDisabled("V02DwT0BG"))
+        {
+          Histo(eventSelection,triggerClassName,centrality,"V02DwT0BG")->Fill(x,y);
+        }
+      }
+      
+      if ( pileup )
+      {
+        if (!IsHistogramDisabled("V02DwT0PU"))
+        {
+          Histo(eventSelection,triggerClassName,centrality,"V02DwT0PU")->Fill(x,y);
+        }
+        
+        if ( !IsHistogramDisabled("PileUpEstimators") )
+        {
+          Histo(eventSelection,triggerClassName,centrality,"PileUpEstimators")->Fill("TZERO",1.0);
+        }
+      }
+      
+      if ( satellite )
+      {
+        if (!IsHistogramDisabled("V02DwT0SAT"))
+        {
+          Histo(eventSelection,triggerClassName,centrality,"V02DwT0SAT")->Fill(x,y);
+        }
+      }
+      
+      if ( !background && !pileup && !satellite )
+      {
+        if (!IsHistogramDisabled("V02DwT0BB"))
+        {
+          Histo(eventSelection,triggerClassName,centrality,"V02DwT0BB")->Fill(x,y);
+        }
+      }
+    }
+  }
+  
+  //  /* FIXME : how to properly get multiplicity from AOD and ESD consistently ?
+  //   is is doable at all ?
+  
+  TH1* hpileup = Histo(eventSelection,triggerClassName,centrality,"PileUpEstimators");
+  
+  
+  //  virtual Bool_t  IsPileupFromSPD(Int_t minContributors=3, Double_t minZdist=0.8, Double_t nSigmaZdist=3., Double_t nSigmaDiamXY=2., Double_t nSigmaDiamZ=5.) const;
+  
+  const Double_t nSigmaZdist=3.0;
+  const Double_t nSigmaDiamXY=2.0;
+  const Double_t nSigmaDiamZ=5.0;
+  
+  for ( Int_t minContributors = 3; minContributors <= 6; ++minContributors )
+  {
+    for ( double minZdist = 0.6; minZdist <= 0.8; minZdist += 0.2 )
+    {
+      if ( Event()->IsPileupFromSPD(minContributors,minZdist,nSigmaZdist,nSigmaDiamXY,nSigmaDiamZ) )
+      {
+        hpileup->Fill(Form("SPD:n%dd%d",minContributors,static_cast<Int_t>(10*minZdist)),1);
+      }
+    }
+  }
+  
+  
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuGlobal::FillHistosForMCEvent(const char* eventSelection,
+                                                 const char* triggerClassName,
+                                                 const char* centrality)
+{
+  // Fill MCEvent-wise histograms
+  
+  Double_t Zvertex = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent());
+  
+  if (!IsHistogramDisabled("Zvertex"))
+  {
+    MCHisto(eventSelection,triggerClassName,centrality,"Zvertex")->Fill(Zvertex);
+  }
+
+  if (!IsHistogramDisabled("RecZvertexVsMCZvertex"))
+  {
+    const AliVVertex* vertex = Event()->GetPrimaryVertex();
+    if  (vertex && vertex->GetNContributors()>0)
+    {
+      MCHisto(eventSelection,triggerClassName,centrality,"RecZvertexVsMCZvertex")->Fill(Zvertex,vertex->GetZ());
+    }
+  }
+  
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuGlobal::SelectAnyTriggerClass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses) const
+{
+  /// Accept all trigger classes
+  if ( firedTriggerClasses.Length()>0)
+  {
+    acceptedTriggerClasses = "NOTRIGGERSELECTION";
+    return kTRUE;
+  }
+  return kFALSE;
+}
+
diff --git a/PWG/muon/AliAnalysisMuMuGlobal.h b/PWG/muon/AliAnalysisMuMuGlobal.h
new file mode 100644 (file)
index 0000000..f39eb71
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef ALIANALYSISMUMUGLOBAL_H
+#define ALIANALYSISMUMUGLOBAL_H
+
+/**
+ * \class AliAnalysisMuMuGlobal
+ * \brief Basic histogramming of global event properties (vertex, pile-up, background)
+ * \author L. Aphecetche (Subatech)
+ */
+
+#include "AliAnalysisMuMuBase.h"
+
+class AliAnalysisMuMuGlobal : public AliAnalysisMuMuBase
+{
+public:
+  AliAnalysisMuMuGlobal();
+  virtual ~AliAnalysisMuMuGlobal() {}
+  
+  void FillHistosForEvent(const char* eventSelection, const char* triggerClassName,
+                          const char* centrality);
+
+  void FillHistosForMCEvent(const char* eventSelection, const char* triggerClassName,
+                            const char* centrality);
+
+  virtual void DefineHistogramCollection(const char* eventSelection, const char* triggerClassName,
+                                         const char* centrality);
+
+  Bool_t SelectAnyTriggerClass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses) const;
+  
+
+private:
+  ClassDef(AliAnalysisMuMuGlobal,1) // implementation of AliAnalysisMuMuBase for global event properties
+};
+
+#endif
diff --git a/PWG/muon/AliAnalysisMuMuMinv.cxx b/PWG/muon/AliAnalysisMuMuMinv.cxx
new file mode 100644 (file)
index 0000000..179433d
--- /dev/null
@@ -0,0 +1,544 @@
+#include "AliAnalysisMuMuMinv.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuMinv
+ * 
+ * Analysis which fills a bunch of histograms for invariant mass analysis of J/psi 
+ *
+ * Can be used on real data and/or simulated (for instance to get Acc x Eff)
+ *
+ * Can optionally use as input an already computed Acc x Eff matrix that will be applied
+ * when filling the invariant mass histograms.
+ *
+ */
+
+#include "TH2F.h"
+#include "AliLog.h"
+#include "TObjArray.h"
+#include "AliAnalysisMuMuBinning.h"
+#include "TString.h"
+#include "TLorentzVector.h"
+#include "TString.h"
+#include "AliMCEvent.h"
+#include "AliMergeableCollection.h"
+#include "AliAnalysisMuonUtility.h"
+#include "TParameter.h"
+#include <cassert>
+
+ClassImp(AliAnalysisMuMuMinv)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuMinv::AliAnalysisMuMuMinv()
+: AliAnalysisMuMuBase(),
+fAccEffHisto(0x0)
+{
+  // FIXME : find the AccxEff histogram from HistogramCollection()->Histo("/EXCHANGE/JpsiAccEff")
+  
+//  if ( accEff )
+//  {
+//    fAccEffHisto = static_cast<TH2F*>(accEff->Clone());
+//    fAccEffHisto->SetDirectory(0);
+//  }
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuMinv::~AliAnalysisMuMuMinv()
+{
+  /// dtor
+  delete fAccEffHisto;
+}
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuMinv::DefineHistogramCollection(const char* eventSelection,
+                                               const char* triggerClassName,
+                                               const char* centrality)
+{
+  /// Define the histograms this analysis will use
+  
+  if ( Histo(eventSelection,triggerClassName,centrality,"AliAnalysisMuMuMinv") )
+  {
+    return;
+  }
+  
+  // dummy histogram to signal that we already defined all our histograms (see above)
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"AliAnalysisMuMuMinv","Dummy semaphore",1,0,1);
+
+  /// Create invariant mass histograms
+  
+  Double_t minvMin = 0;
+  Double_t minvMax = 16;
+  Int_t nMinvBins = GetNbins(minvMin,minvMax,0.025);
+  
+  Int_t nMCMinvBins = GetNbins(minvMin,minvMax,0.1);
+  
+  //  TObjArray* bins = fBinning->CreateBinObjArray("psi","y vs pt,integrated,pt,y,phi","");
+  TObjArray* bins = Binning()->CreateBinObjArray("psi");
+  
+  CreatePairHistos(eventSelection,triggerClassName,centrality,"Pt","#mu+#mu- Pt distribution",
+                  200,0,20);
+
+  Int_t nbinsy = 6;
+  Double_t ymin = -4.0;
+  Double_t ymax = -2.5;
+  
+  CreatePairHistos(eventSelection,triggerClassName,centrality,"y","#mu+#mu- y distribution",nbinsy,ymin,ymax);
+
+  //  CreatePairHistos(eventSelection,triggerClassName,centrality,"BinFlowPt","#mu+#mu- BinFlowPt distribution",
+  //                  200,0,20);
+  
+  CreatePairHistos(eventSelection,triggerClassName,centrality,"PtRecVsSim","#mu+#mu- Pt distribution rec vs sim",
+                  200,0,20,200,0,20);
+  
+  if (!Histo("INPUT","ALL","Pt"))
+  {
+    HistogramCollection()->Adopt("/INPUT/ALL",new TH1F("Pt","Pt",200,0,20));
+    HistogramCollection()->Adopt("/INPUT/INYRANGE",new TH1F("Pt","Pt",200,0,20));
+    HistogramCollection()->Adopt("/INPUT/ALL",new TH1F("Y","Y",nbinsy,ymin,ymax));
+    HistogramCollection()->Adopt("/INPUT/INYRANGE",new TH1F("Y","Y",nbinsy,ymin,ymax));
+  }
+  
+  TIter next(bins);
+  AliAnalysisMuMuBinning::Range* r;
+  Int_t nb(0);
+  
+  while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) )
+  {
+    TString minvName(GetMinvHistoName(*r,ShouldCorrectDimuonForAccEff()));
+    
+    if ( IsHistogramDisabled(minvName.Data()) ) continue;
+    
+    ++nb;
+    
+    AliDebug(1,Form("bin %d %s histoname = %s",nb,r->AsString().Data(),minvName.Data()));
+    
+    CreatePairHistos(eventSelection,triggerClassName,centrality,minvName.Data(),
+                     Form("#mu+#mu- inv. mass %s %s;M_{#mu^+#mu^-} (GeV/c^2)",
+                          ShouldCorrectDimuonForAccEff() ? "(AccxEff corrected)":"",
+                          r->AsString().Data()),
+                     nMinvBins,minvMin,minvMax);
+    
+    TString hname(GetMinvHistoName(*r,kFALSE));
+    
+    TH1* h = HistogramCollection()->Histo("/INPUT/ALL",hname.Data());
+    if (!h)
+    {
+      h = new TH1F(hname.Data(),Form("MC #mu+#mu- inv. mass %s",r->AsString().Data()),
+                   nMCMinvBins,minvMin,minvMax);
+      
+      HistogramCollection()->Adopt("/INPUT/ALL",h);
+      
+      HistogramCollection()->Adopt("/INPUT/INYRANGE",static_cast<TH1*>(h->Clone()));
+    }
+  }
+  
+  delete bins;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuMinv::FillHistosForPair(const char* eventSelection, const char* triggerClassName,
+                                            const char* centrality, const char* pairCutName,
+                                            const AliVParticle& tracki,
+                                            const AliVParticle& trackj)
+{
+  /** Fill histograms for muon track pairs
+   */
+  
+  if (!AliAnalysisMuonUtility::IsMuonTrack(&tracki) ) return;
+  if (!AliAnalysisMuonUtility::IsMuonTrack(&trackj) ) return;
+
+  TLorentzVector pi(tracki.Px(),tracki.Py(),tracki.Pz(),
+                    TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+tracki.P()*tracki.P()));
+  
+  
+  TLorentzVector pair4Momentum(trackj.Px(),trackj.Py(),trackj.Pz(),
+                               TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+trackj.P()*trackj.P()));
+  
+  pair4Momentum += pi;
+  
+  
+  if (!IsHistogramDisabled("Chi12"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,pairCutName,"Chi12")
+    ->Fill(
+           AliAnalysisMuonUtility::GetChi2perNDFtracker(&tracki),
+           AliAnalysisMuonUtility::GetChi2perNDFtracker(&trackj));
+  }
+  
+  if (!IsHistogramDisabled("Rabs12"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,pairCutName,"Rabs12")
+    ->Fill(AliAnalysisMuonUtility::GetRabs(&tracki),
+           AliAnalysisMuonUtility::GetRabs(&trackj));
+  }
+  
+  if ( ( tracki.Charge() != trackj.Charge() ) )
+  {
+    if ( !IsHistogramDisabled("Pt") )
+    {
+      Histo(eventSelection,triggerClassName,centrality,pairCutName,"Pt")->Fill(pair4Momentum.Pt());
+    }
+
+    if ( !IsHistogramDisabled("y") )
+    {
+      Histo(eventSelection,triggerClassName,centrality,pairCutName,"y")->Fill(pair4Momentum.Y());
+    }
+
+    if ( HasMC() )
+    {
+      Int_t labeli = tracki.GetLabel();
+      Int_t labelj = trackj.GetLabel();
+      
+      if ( labeli < 0 || labelj < 0 )
+      {
+        AliError("Got negative labels!");
+      }
+      else
+      {
+        AliVParticle* mcTracki = MCEvent()->GetTrack(labeli);
+        AliVParticle* mcTrackj = MCEvent()->GetTrack(labelj);
+        
+        TLorentzVector mcpi(mcTracki->Px(),mcTracki->Py(),mcTracki->Pz(),
+                            TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+mcTracki->P()*mcTracki->P()));
+        TLorentzVector mcpj(mcTrackj->Px(),mcTrackj->Py(),mcTrackj->Pz(),
+                            TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+mcTrackj->P()*mcTrackj->P()));
+        
+        mcpj += mcpi;
+        
+        Histo(eventSelection,triggerClassName,centrality,pairCutName,"PtRecVsSim")->Fill(mcpj.Pt(),pair4Momentum.Pt());
+        
+      }
+    }
+    
+
+    TObjArray* bins = Binning()->CreateBinObjArray("psi","ptvsy,yvspt,pt,y,phi","");
+    TIter nextBin(bins);
+    AliAnalysisMuMuBinning::Range* r;
+    
+    while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
+    {
+      Bool_t ok(kFALSE);
+      
+      if ( r->IsIntegrated() )
+      {
+        ok = kTRUE;
+      }
+      else if ( r->Is2D() )
+      {
+        if ( r->AsString().BeginsWith("PTVSY") )
+        {
+          ok = r->IsInRange(pair4Momentum.Rapidity(),pair4Momentum.Pt());
+        }
+        else if ( r->AsString().BeginsWith("YVSPT") )
+        {
+          ok = r->IsInRange(pair4Momentum.Pt(),pair4Momentum.Rapidity());
+        }
+        else
+        {
+          AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
+        }
+      }
+      else
+      {
+        if ( r->Quantity() == "PT" )
+        {
+          ok = r->IsInRange(pair4Momentum.Pt());
+        }
+        else if ( r->Quantity() == "Y" )
+        {
+          ok = r->IsInRange(pair4Momentum.Rapidity());
+        }
+        else if ( r->Quantity() == "PHI" )
+        {
+          ok = r->IsInRange(pair4Momentum.Phi());
+        }
+        else if ( r->Quantity() == "NCH" )
+        {
+          TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
+          if (list)
+          {
+            TIter next(list);
+            TParameter<Double_t>* p;
+            
+            while ( ( p = static_cast<TParameter<Double_t>*>(next())) )
+            {
+              if (TString(eventSelection).Contains(p->GetName()))
+              {
+                ok = r->IsInRange(p->GetVal());
+                break;
+              }
+            }
+          }
+        }
+      }
+      
+      if ( ok )
+      {
+        TString minvName = GetMinvHistoName(*r,kFALSE);
+        
+        if (!IsHistogramDisabled(minvName.Data()))
+        {
+          TH1* h = Histo(eventSelection,triggerClassName,centrality,pairCutName,minvName.Data());
+          
+          if (!h)
+          {
+            AliError(Form("Could not get %s",minvName.Data()));
+            continue;
+          }
+          h->Fill(pair4Momentum.M());
+          
+          if ( fAccEffHisto )
+          {
+            // FIXME : fill Minv with weight = 1/AccxEff
+          }
+        }
+      }
+    }
+    
+    delete bins;
+  }
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuMinv::FillHistosForMCEvent(const char* /*eventSelection*/,
+                                               const char* /*triggerClassName*/,
+                                               const char* /*centrality*/)
+{
+  /** Fill histograms for MC event
+   *
+   * FIXME: this is here we should streamline a bit the code to carefully
+   * compute the measured and truth values for Pt, Y, and (Pt,Y), in order
+   * to be able to investigate unfolding techniques later on...
+   */
+  
+  Int_t nMCTracks = MCEvent()->GetNumberOfTracks();
+
+  for ( Int_t i = 0; i < nMCTracks; ++i )
+  {
+    AliVParticle* part = MCEvent()->GetTrack(i);
+    
+    if  ( AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) &&
+          AliAnalysisMuonUtility::GetMotherIndex(part)==-1 )
+    {
+            Histo("INPUT","ALL","Pt")->Fill(part->Pt());
+            Histo("INPUT","ALL","Y")->Fill(part->Y());
+            if ( part->Y() < -2.5 && part->Y() > -4.0 )
+            {
+              Histo("INPUT","INYRANGE","Pt")->Fill(part->Pt());
+              Histo("INPUT","INYRANGE","Y")->Fill(part->Y());
+            }
+
+    }
+    
+  }
+  
+//  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
+//
+//  Double_t measuredY(0.0);
+//  
+//  for (Int_t i = 0; i < nTracks; ++i)
+//  {
+//    AliVParticle* tracki = AliAnalysisMuonUtility::GetTrack(i,Event());
+//
+//    if (!AliAnalysisMuonUtility::IsMuonTrack(tracki) ) continue;
+//
+//    for (Int_t j = i+1; j < nTracks; ++j )
+//    {
+//      AliVParticle* trackj = AliAnalysisMuonUtility::GetTrack(j,Event());
+//      
+//      if (!AliAnalysisMuonUtility::IsMuonTrack(trackj) ) continue;
+//
+//      TLorentzVector pi(tracki->Px(),tracki->Py(),tracki->Pz(),
+//                        TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+tracki->P()*tracki->P()));
+//      
+//      TLorentzVector pair4Momentum(trackj->Px(),trackj->Py(),trackj->Pz(),
+//                                   TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+trackj->P()*trackj->P()));
+//      
+//      pair4Momentum += pi;
+//      
+//      measuredY = pi.Y();
+//      
+//      rur->Fill(measuredY,trueY); // FIXME : is this working if more than one pair is found in the reconstructed tracks ???
+//      // should we try to find the closest one in minv and assign the other(s)
+//      // to rur->Fake() ?
+//    }
+//    
+//  }
+//
+//  if ( ! ( measuredY < 0.0 ) )
+//  {
+//    rur->Miss(trueY);
+//  }
+}
+
+////_____________________________________________________________________________
+//void AliAnalysisMuMuMinv::FillMC()
+//{
+//  // Fill the input Monte-Carlo histograms related to muons
+//  
+//  // Specific things for MC
+//  if (!Histo("INPUT","ALL","Pt"))
+//  {
+//    HistogramCollection()->Adopt("/INPUT/ALL",new TH1F("Pt","Pt",200,0,20));
+//    HistogramCollection()->Adopt("/INPUT/INYRANGE",new TH1F("Pt","Pt",200,0,20));
+//    
+//    Double_t rapidityMin = -5;
+//    Double_t rapidityMax = -2;
+//    Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
+//    
+//    HistogramCollection()->Adopt("/INPUT/ALL",new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
+//    HistogramCollection()->Adopt("/INPUT/INYRANGE",new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
+//    
+//    Double_t etaMin = -5;
+//    Double_t etaMax = -2;
+//    Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
+//    
+//    HistogramCollection()->Adopt("/INPUT/ALL",new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
+//    HistogramCollection()->Adopt("/INPUT/INYRANGE",new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
+//  }
+//  
+//  Int_t nMCTracks = MCEvent()->GetNumberOfTracks();
+//  
+//  TObjArray* bins = Binning()->CreateBinObjArray("psi","ptvsy,yvspt,pt,y,phi","");
+//  TIter nextBin(bins);
+//  AliAnalysisMuMuBinning::Range* r;
+//  
+//  for ( Int_t i = 0; i < nMCTracks; ++i )
+//  {
+//    AliVParticle* part = MCEvent()->GetTrack(i);
+//    
+//    //    std::cout << "part " << i << " isprimary=" << AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) << " motherindex=" << AliAnalysisMuonUtility::GetMotherIndex(part) << std::endl;
+//    //
+//    //    part->Print();
+//    
+//    if  (AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) &&
+//         AliAnalysisMuonUtility::GetMotherIndex(part)==-1)
+//    {
+//      
+//      Histo("INPUT","ALL","Pt")->Fill(part->Pt());
+//      Histo("INPUT","ALL","Y")->Fill(part->Y());
+//      Histo("INPUT","ALL","Eta")->Fill(part->Eta());
+//      
+//      if ( part->Y() < -2.5 && part->Y() > -4.0 )
+//      {
+//        Histo("INPUT","INYRANGE","Pt")->Fill(part->Pt());
+//        Histo("INPUT","INYRANGE","Y")->Fill(part->Y());
+//        Histo("INPUT","INYRANGE","Eta")->Fill(part->Eta());
+//      }
+//      
+//      nextBin.Reset();
+//      
+//      while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
+//      {
+//        Bool_t ok(kFALSE);
+//        
+//        if ( r->IsIntegrated() )
+//        {
+//          ok = kTRUE;
+//        }
+//        else if ( r->Is2D() )
+//        {
+//          if ( r->AsString().BeginsWith("PTVSY") )
+//          {
+//            ok = r->IsInRange(part->Y(),part->Pt());
+//          }
+//          else if ( r->AsString().BeginsWith("YVSPT") )
+//          {
+//            ok = r->IsInRange(part->Pt(),part->Y());
+//          }
+//          else
+//          {
+//            AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
+//          }
+//        }
+//        else
+//        {
+//          if ( r->Quantity() == "PT" )
+//          {
+//            ok = r->IsInRange(part->Pt());
+//          }
+//          else if ( r->Quantity() == "Y" )
+//          {
+//            ok = r->IsInRange(part->Y());
+//          }
+//          else if ( r->Quantity() == "PHI" )
+//          {
+//            ok = r->IsInRange(part->Phi());
+//          }
+//        }
+//        
+//        if ( ok )
+//        {
+//          TString hname = GetMinvHistoName(*r,kFALSE);
+//          
+//          if (!IsHistogramDisabled(hname.Data()))
+//          {
+//            
+//            TH1* h = Histo("INPUT","ALL",hname.Data());
+//            
+//            if (!h)
+//            {
+//              AliError(Form("Could not get ALL %s",hname.Data()));
+//              continue;
+//            }
+//            
+//            h->Fill(part->M());
+//            
+//            if ( part->Y() < -2.5 && part->Y() > -4.0 )
+//            {
+//              h = Histo("INPUT","INYRANGE",hname.Data());
+//              if (!h)
+//              {
+//                AliError(Form("Could not get INYRANGE %s",hname.Data()));
+//                continue;
+//              }
+//              h->Fill(part->M());
+//            }
+//            
+//          }
+//          
+//        }
+//      }
+//    }
+//  }
+//  
+//  delete bins;
+//}
+//
+
+//_____________________________________________________________________________
+TString AliAnalysisMuMuMinv::GetMinvHistoName(const AliAnalysisMuMuBinning::Range& r, Bool_t accEffCorrected) const
+{
+  /// Get the invariant mass histogram name
+  return TString::Format("MinvUS%s%s",r.AsString().Data(),
+                         accEffCorrected ? "_AccEffCorr" : "");
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuMinv::IsRapidityInRange(const AliVParticle& t1, const AliVParticle& t2, Double_t& ymin, Double_t& ymax) const
+{
+  /// Whether the particle pair has its rapidity within [ymin,ymax[
+  
+  TLorentzVector p1(t1.Px(),t1.Py(),t1.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t1.P()*t1.P()));
+  TLorentzVector p2(t2.Px(),t2.Py(),t2.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t2.P()*t2.P()));
+  
+  TLorentzVector total(p1+p2);
+  
+  Double_t y = total.Rapidity();
+
+  return  ( y < ymax && y > ymin );
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuMinv::NameOfIsRapidityInRange(TString& name, Double_t& ymin, Double_t& ymax) const
+{
+  /** Get the name of the rapidity range (making the IsRapidityInRange method useable as an
+   * AliAnalysisMuMuCutElement
+   */
+  
+  name.Form("PAIRYIN%2.1f-%2.1f",ymin,ymax);
+}
+
diff --git a/PWG/muon/AliAnalysisMuMuMinv.h b/PWG/muon/AliAnalysisMuMuMinv.h
new file mode 100644 (file)
index 0000000..ca41935
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef ALIANALYSISMUMUMINV_H
+#define ALIANALYSISMUMUMINV_H
+
+/**
+ * \class AliAnalysisMuMuMinv
+ * \brief Invariant mass analysis of muon pairs
+ * \author L. Aphecetche (Subatech)
+ */
+
+#include "AliAnalysisMuMuBase.h"
+#include "AliAnalysisMuMuBinning.h"
+#include "TString.h"
+
+class TH2F;
+class AliVParticle;
+
+class AliAnalysisMuMuMinv : public AliAnalysisMuMuBase
+{
+public:
+
+  AliAnalysisMuMuMinv();
+  virtual ~AliAnalysisMuMuMinv();
+  
+  Bool_t IsRapidityInRange(const AliVParticle& t1, const AliVParticle& t2,
+                           Double_t& ymin, Double_t& ymax) const;
+
+  virtual void FillHistosForMCEvent(const char* /*eventSelection*/,const char* /*triggerClassName*/,const char* /*centrality*/);
+
+  void NameOfIsRapidityInRange(TString& name, Double_t& ymin, Double_t& ymax) const;
+
+  Bool_t ShouldCorrectDimuonForAccEff() const { return (fAccEffHisto != 0x0); }
+  
+  void DefineHistogramCollection(const char* eventSelection, const char* triggerClassName,
+                                 const char* centrality);
+
+  virtual void FillHistosForPair(const char* eventSelection,const char* triggerClassName,
+                                 const char* centrality,
+                                 const char* pairCutName,
+                                 const AliVParticle& part,
+                                 const AliVParticle& part2);
+  
+private:
+  
+  /// not implemented on purpose
+  AliAnalysisMuMuMinv(const AliAnalysisMuMuMinv& rhs);
+  /// not implemented on purpose
+  AliAnalysisMuMuMinv& operator=(const AliAnalysisMuMuMinv& rhs);
+  
+  void CreateMinvHistograms(const char* eventSelection, const char* triggerClassName, const char* centrality);
+  
+  TString GetMinvHistoName(const AliAnalysisMuMuBinning::Range& r, Bool_t accEffCorrected) const;
+  
+
+private:
+  TH2F* fAccEffHisto; // input Acc x Eff (optional)
+  
+  ClassDef(AliAnalysisMuMuMinv,1) // implementation of AliAnalysisMuMuBase for muon pairs
+};
+
+#endif
+
diff --git a/PWG/muon/AliAnalysisMuMuNch.cxx b/PWG/muon/AliAnalysisMuMuNch.cxx
new file mode 100644 (file)
index 0000000..792634c
--- /dev/null
@@ -0,0 +1,1135 @@
+#include "AliAnalysisMuMuNch.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuNch
+ *
+ * SPD tracklet to Nch analysis
+ *
+ * The idea is that this sub-analysis is used first (within the AliAnalysisTaskMuMu sub-framework)
+ * in order to compute the number of charged particles within an event, so that information
+ * can be used in subsequent sub-analysis, like the invariant mass or mean pt ones.
+ *
+ */
+
+#include "AliAODTracklets.h"
+#include "AliAnalysisMuonUtility.h"
+#include "AliLog.h"
+#include "AliAODEvent.h"
+#include "AliESDUtils.h"
+#include "TMath.h"
+#include "AliAnalysisMuMuCutRegistry.h"
+#include "AliAnalysisMuMuCutElement.h"
+#include "Riostream.h"
+#include "TParameter.h"
+#include <set>
+#include <utility>
+#include "AliMergeableCollection.h"
+#include "AliMCEvent.h"
+#include "AliAODMCParticle.h"
+#include "TAxis.h"
+#include "TCanvas.h"
+#include "TH2F.h"
+#include "TF1.h"
+#include "TProfile.h"
+#include "TObjString.h"
+
+
+namespace {
+
+  Double_t SPDgeomR(Double_t* x,Double_t* par) // Eta position of the SPD right edge eta as "seen" from a z vertex position
+  {
+    // par[0] = radius of SPD layer
+    
+    Double_t d = x[0];
+    Double_t z(0.);
+    Double_t theta(0.);
+    
+    if( d < 14.09999 )
+    {
+      z = 14.1 - d;
+      theta = TMath::ATan(par[0]/z);
+    }
+    
+    else if( d > 14.09999 )
+    {
+      z = d - 14.1;
+      theta = TMath::Pi() - TMath::ATan(par[0]/z);
+    }
+    
+    return -TMath::Log(TMath::Tan(theta/2.));
+  }
+  
+  Double_t SPDgeomL(Double_t* x,Double_t* par) // Eta position of the SPD left edge eta as "seen" from a z vertex position
+  {
+    // par[0] = radius of SPD layer
+    
+    Double_t d = x[0];
+    Double_t z(0.);
+    Double_t theta(0.);
+    
+    if( d > -14.09999 )
+    {
+      z = 14.1 + d;
+      theta = TMath::Pi() - TMath::ATan(par[0]/z);
+    }
+    
+    if( d < -14.09999 )
+    {
+      z = -14.1 - d;
+      theta = TMath::ATan(par[0]/z);
+    }
+    
+    return -TMath::Log(TMath::Tan(theta/2.));
+  }
+
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuNch::AliAnalysisMuMuNch(TH2* spdCorrection, Double_t etaMin, Double_t etaMax
+                                      , Double_t zMin, Double_t zMax,Bool_t disableHistos, Bool_t computeResolution)
+: AliAnalysisMuMuBase(),
+fSPDCorrection(0x0),
+fEtaAxis(new TAxis(TMath::Nint(10./0.1),-5.,5.)),
+fZAxis(new TAxis(TMath::Nint(80/0.25),-40.,40.)),
+fCurrentEvent(0x0),
+fEtaMin(etaMin),
+fEtaMax(etaMax),
+fZMin(zMin),
+fZMax(zMax),
+fResolution(computeResolution)
+{
+  if ( spdCorrection )
+  {
+    fSPDCorrection = static_cast<TH2F*>(spdCorrection->Clone());
+    fSPDCorrection->SetDirectory(0);
+  }
+  DefineSPDAcceptance();
+  
+  if ( disableHistos )
+  {
+    DisableHistograms("*");
+  }
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuNch::~AliAnalysisMuMuNch()
+{
+  delete fSPDCorrection;
+  delete fEtaAxis;
+  delete fZAxis;
+  delete fSPD1LR;
+  delete fSPD1LL;
+  delete fSPD2LR;
+  delete fSPD2LL;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::DefineHistogramCollection(const char* eventSelection,
+                                                   const char* triggerClassName,
+                                                   const char* centrality)
+{
+  // Define multiplicity histos
+  
+  if ( Histo(eventSelection,triggerClassName,centrality,"AliAnalysisMuMuNch") )
+  {
+    return;
+  }
+
+  // dummy histogram to signal that we already defined all our histograms (see above)
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"AliAnalysisMuMuNch","Dummy semaphore",1,0,1);
+
+  Double_t multMin = 0.;  //Tracklets multiplicity range
+  Double_t multMax = 500.;
+  Int_t nbinsMult = GetNbins(multMin,multMax,1.);
+  
+  Double_t phimin = 0.; //Phi range
+  Double_t phimax = 2*TMath::Pi();
+  Int_t nphibins = GetNbins(phimin,phimax,0.05);
+  
+  if ( !fSPDCorrection && fResolution ) // Resolution histos
+  {
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaRes","#eta resolution;#eta_{Reco} - #eta_{MC};Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiRes","#phi resolution;#phi_{Reco} - #phi_{MC};Counts",nphibins*2,-phimax,phimax);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResShifted","#phi resolution;#phi_{Reco} - #phi_{MC};Counts",nphibins*4,-phimax/4,phimax/4);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaResVsZ","#eta resolution vs MC Zvertex;ZVertex (cm);#eta_{Reco} - #eta_{MC}",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),(fEtaAxis->GetNbins())*8,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResVsZ","#phi resolution vs MC Zvertex;ZVertex (cm);#phi_{Reco} - #phi_{MC}",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins*4,-phimax/4,phimax/4);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaResVsnC","#eta resolution vs Nof contributors to SPD vertex;NofContributors;#eta_{Reco} - #eta_{MC}",200,0,200,(fEtaAxis->GetNbins())*8,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResVsnC","#phi resolution vs Nof contributors to SPD vertex;NofContributors;#phi_{Reco} - #phi_{MC}",200,0,200,nphibins*4,-phimax/4,phimax/4);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"SPDZvResVsnC","SPD Zvertex resolution vs Nof contributors;NofContributors;Zvertex_{Reco} - Zvertex_{MC} (cm)",200,0,200,(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"SPDZvResVsMCz","SPD Zvertex resolution vs MC z vertex;MC Zvertex (cm);Zvertex_{Reco} - Zvertex_{MC} (cm)",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),(fZAxis->GetNbins())*10,fZAxis->GetXmin(),fZAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Phi","Reco #phi distribution;#phi;Counts",nphibins,phimin,phimax);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"MCPhi","MC #phi distribution;#phi;Counts",nphibins,phimin,phimax);
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Eta","Reco #eta distribution;#phi;Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+    
+    CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"MCEta","MC #eta distribution;#phi;Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+    
+    return; // When computing resolutions we don't want to create the rest of histos
+  }
+
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi","Number of tracklets vs Z vertex vs #phi;Z vertex;#phi",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins,phimin,phimax);
+  AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi");// Attach the SPD acc curves
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta","Number of tracklets vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+  AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta");
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Tracklets","Number of tracklets distribution;N_{Tracklets};N_{events}",nbinsMult,multMin,multMax);
+    
+  CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta","Number of background tracklets vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+  AttachSPDAcceptance(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta");
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta","Number of charged particles vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+  AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta");
+  
+  CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsPhi","Number of charged particles vs ZVertex vs #phi;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins,phimin,phimax);
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta","Effective number of events vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax()); // Fill 1 unit in each "touched" eta bin per event (represents the eta bins in which each event contributes)
+  AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta");
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Nch","Number of charged particles distribution;N_{ch};N_{events}",nbinsMult,multMin,multMax);
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"dNchdEta","<dNchdEta> distribution;dN_{ch}/d#eta;N_{events}",nbinsMult,multMin,multMax);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"TrackletsVsNch","Number of tracklets vs Number of charged particles;N_{ch};N_{tracklets}",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax); //Response matrix
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"V0AMultVsNch","V0A multiplicity vs Number of charged particles;N_{ch};V0A Mult",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax);
+  
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"V0CMultVsNch","V0C multiplicity vs Number of charged particles;N_{ch};V0C Mult",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax);
+  
+  // profile histograms
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"MeanTrackletsVsEta","Mean number of tracklets vs #eta;#eta;<N_{Tracklets}>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax(),0);
+  
+  CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"MeanTrackletsVsZVertex","Mean number of tracklets vs Z vertex;Z vertex;<N_{Tracklets}>",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),0);
+
+  CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"MeanNchVsEta","Mean number of charged particles vs #eta;#eta;<N_{ch}>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax(),0); // Each bin has to be divided by the binwidth to became dNch/dEta (Done in the terminate and stored in MeandNchdEta histo)
+  
+   CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"MeanNchVsZVertex","Mean number of charged particles vs Z vertex;Z vertex;<N_{ch}>",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),0);
+    
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::DefineSPDAcceptance()
+{
+  // Defines the functions ( eta = f(z) )of the edges (right/left) of the inner and outer SPD layers
+  // R_in = 3.9 cm ; R_out = 7.6 cm
+  fSPD1LR = new TF1("fSPD1LR",SPDgeomR,-40,40,1);
+  fSPD1LR->SetParameter(0,3.9);
+  fSPD1LL = new TF1("fSPD1LL",SPDgeomL,-40,40,1);
+  fSPD1LL->SetParameter(0,3.9);
+  fSPD2LR = new TF1("fSPD2LR",SPDgeomR,-40,40,1);
+  fSPD2LR->SetParameter(0,7.6);
+  fSPD2LL = new TF1("fSPD2LL",SPDgeomL,-40,40,1);
+  fSPD2LL->SetParameter(0,7.6);
+  
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::AddHisto(const char* eventSelection,
+                                  const char* triggerClassName,
+                                  const char* centrality,
+                                  const char* histoname,
+                                  Double_t z,
+                                  TH1* h,Bool_t isMC)
+{
+  // Adds the content of a 1D histo to a 2D histo a the z position
+  
+  Int_t zbin = fZAxis->FindBin(z);
+  TH2F* h2;
+  if (isMC) h2 = static_cast<TH2F*>(MCHisto(eventSelection,triggerClassName,centrality,histoname));
+  else h2 = static_cast<TH2F*>(Histo(eventSelection,triggerClassName,centrality,histoname));
+  
+  for ( Int_t i = 1; i <= h->GetXaxis()->GetNbins(); ++i )
+  {
+    Double_t content = h2->GetCellContent(zbin,i);
+    
+    if ( h->GetBinContent(i) >  0 )
+    {
+      h2->SetCellContent(zbin,i,content + h->GetBinContent(i));
+    }
+  }
+  
+  h2->SetEntries(h2->GetSumOfWeights());
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::AttachSPDAcceptance(UInt_t dataType,
+                                             const char* eventSelection,
+                                             const char* triggerClassName,
+                                             const char* centrality,const char* histoname)
+{
+  if ( dataType & kHistoForData )
+  {
+    if( !Histo(eventSelection,triggerClassName,centrality,histoname) )
+    {
+      AliError(Form("ERROR: SPD Acceptance curves attach failed. Histo /%s/%s/%s/%s not found",eventSelection,triggerClassName,centrality,histoname));
+      return;
+    }
+    
+    Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LR);
+    Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LL);
+    Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LR);
+    Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LL);
+  }
+  if ( dataType & kHistoForMCInput )
+  {
+    if( !MCHisto(eventSelection,triggerClassName,centrality,histoname) )
+    {
+      AliError(Form("ERROR: SPD Acceptance curves attach failed. MC Histo /%s/%s/%s/%s not found",eventSelection,triggerClassName,centrality,histoname));
+      return;
+    }
+    
+    MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LR);
+    MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LL);
+    MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LR);
+    MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LL);
+  }
+  
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::FillHistosForEvent(const char* eventSelection,
+                                            const char* triggerClassName,
+                                            const char* centrality)
+{
+  // Fills the data (or reco if simu) multiplicity histos
+  
+  if ( IsHistogrammingDisabled() ) return;
+  
+  if ( fResolution ) return; //When computing resolutions we skip this method
+
+  if ( !AliAnalysisMuonUtility::IsAODEvent(Event()) )
+  {
+    AliError("Don't know how to deal with ESDs...");
+    return;
+  }
+  
+  if ( HasMC() && !fSPDCorrection ) // We have MC but no correction (SPD correction computation mode)so we skip the method
+  {
+    return;
+  }
+
+  AliAODEvent* aod = static_cast<AliAODEvent*>(Event());
+
+  AliVVertex* vertex = aod->GetPrimaryVertexSPD();
+  
+  TList* nchList = static_cast<TList*>(Event()->FindListObject("NCH"));
+  
+  if (!nchList || nchList->IsEmpty() ) // Empty NCH means that there is no SPD vertex ( see SetEvent() ) when runing on data.
+  {
+    return;
+  }
+  
+  Double_t SPDZv;
+  
+  if ( !vertex || vertex->GetZ() == 0.0 ) // Running in Simu the spdZ == 0 means no SPD info. In data, avoid breaks in events w/o SPD vertex
+  {
+    SPDZv = -40.;
+  } 
+  
+  else SPDZv = vertex->GetZ();
+  
+  TH1* hSPDcorrectionVsEta = static_cast<TH1*>(nchList->FindObject("SPDcorrectionVsEta"));
+  TH1* hNTrackletVsEta = static_cast<TH1*>(nchList->FindObject("NTrackletVsEta"));
+  TH1* hNTrackletVsPhi = static_cast<TH1*>(nchList->FindObject("NTrackletVsPhi"));
+  
+  TH1* hNchVsEta =static_cast<TH1*>(hNTrackletVsEta->Clone("NchVsEta"));
+  
+  TProfile* hMeanTrackletsVsEta = static_cast<TProfile*>(Histo(eventSelection,triggerClassName,centrality,"MeanTrackletsVsEta"));
+  TProfile* hMeanNchVsEta = static_cast<TProfile*>(Histo(eventSelection,triggerClassName,centrality,"MeanNchVsEta"));
+
+  TH2* hEventsVsZVertexVsEta = static_cast<TH2*>(Histo(eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta"));
+    
+  Int_t nBins(0);
+
+  Double_t nch(0.0);
+  Double_t nTracklets(0.0);
+  
+  for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) // Loop over eta bins
+  {
+    Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
+    
+    Double_t eta = fEtaAxis->GetBinCenter(j);
+    
+    if ( correction < 0 ) continue;
+    else if ( correction == 0.0 ) // No tracklets found in this eta bin.
+    {
+      correction = GetSPDCorrection(SPDZv,eta);
+
+      if ( correction == 0. || correction > 2.5) continue; // We need to know if the eta bin is in a region we want to take into account to count or not the zero
+    }
+  
+    Double_t ntr = hNTrackletVsEta->GetBinContent(j); // Tracklets in eta bin
+    
+    nch += ntr * correction; // Number of charged particles (corrected tracklets)
+    
+    nTracklets += ntr;
+    
+    hMeanTrackletsVsEta->Fill(eta,ntr); // Fill the number of tracklets of each eta bin in the profile
+
+    hMeanNchVsEta->Fill(eta,ntr*correction);
+
+    ++nBins; // We sum up the number of bins entering in the computation
+    
+    // Fill the number of charged particles of each eta bin in the profile
+    hNchVsEta->SetBinContent( j, hNchVsEta->GetBinContent(j) * correction );
+    
+    hEventsVsZVertexVsEta->Fill(SPDZv,eta,1.0); // Fill 1 count each eta bin where the events contributes
+  }
+  
+  AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi",SPDZv,hNTrackletVsPhi);
+  AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta",SPDZv,hNTrackletVsEta);
+
+  AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta",SPDZv,hNchVsEta);
+  
+  Histo(eventSelection,triggerClassName,centrality,"Tracklets")->Fill(nTracklets);
+  Histo(eventSelection,triggerClassName,centrality,"MeanTrackletsVsZVertex")->Fill(SPDZv,nTracklets);
+  Histo(eventSelection,triggerClassName,centrality,"MeanNchVsZVertex")->Fill(SPDZv,nch);
+  
+  Histo(eventSelection,triggerClassName,centrality,"TrackletsVsNch")->Fill(nTracklets,nch);
+  Histo(eventSelection,triggerClassName,centrality,"Nch")->Fill(nch);
+  
+  Double_t V0AMult = 0.;
+  Double_t V0CMult = 0.;
+  
+  AliVVZERO* vzero = aod->GetVZEROData();
+  if (vzero)
+  {
+    Double_t multV0A = vzero->GetMTotV0A();
+    V0AMult = AliESDUtils::GetCorrV0A(multV0A,SPDZv);
+    Double_t multV0C = vzero->GetMTotV0C();
+    V0CMult = AliESDUtils::GetCorrV0C(multV0C,SPDZv);
+    
+    Histo(eventSelection,triggerClassName,centrality,"V0AMultVsNch")->Fill(V0AMult,nch);
+    Histo(eventSelection,triggerClassName,centrality,"V0CMultVsNch")->Fill(V0CMult,nch);
+
+  }
+
+  
+  delete hNchVsEta;
+  
+  // Mean dNch/dEta computation
+  Double_t meandNchdEta(0.);
+  
+  if ( nBins >  0 )
+  {
+    meandNchdEta = nch / (nBins*fEtaAxis->GetBinWidth(5)); // Divide by nBins to get the mean and by the binWidht to get the d/dEta
+  }
+  
+  Histo(eventSelection,triggerClassName,centrality,"dNchdEta")->Fill(meandNchdEta);
+  
+  
+  
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::FillHistosForMCEvent(const char* eventSelection,const char* triggerClassName,const char* centrality)
+{
+  /// Fill input MC multiplicity histos
+  
+  if ( IsHistogrammingDisabled() ) return;
+  
+  TList* nchList = static_cast<TList*>(Event()->FindListObject("NCH"));
+  
+  if (!nchList || nchList->IsEmpty())
+  {
+    return;
+  }
+
+  Double_t MCZv = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent()); // Definition of MC generated z vertex
+  AliVVertex* vertex = static_cast<AliAODEvent*>(Event())->GetPrimaryVertexSPD();
+  
+  Double_t SPDZv(0.);
+  
+  //____Resolution Histos___
+  if ( !fSPDCorrection && fResolution )
+  {
+    Int_t nContributors(0);
+    if ( vertex )
+    {
+      nContributors  = vertex->GetNContributors();
+      SPDZv = vertex->GetZ();
+    }
+    MCHisto(eventSelection,triggerClassName,centrality,"SPDZvResVsnC")->Fill(nContributors,SPDZv - MCZv);
+    MCHisto(eventSelection,triggerClassName,centrality,"SPDZvResVsMCz")->Fill(MCZv,SPDZv - MCZv);
+    
+    Double_t EtaReco(0.),EtaMC(0.),PhiReco(0.),PhiMC(0.);
+    Int_t i(-1),labelEtaReco(-1),labelEtaMC(-1),labelPhiReco(-1),labelPhiMC(-1);
+    
+    while ( i < nchList->GetEntries() - 1 )
+    {
+      i++;
+      while ( nchList->At(i)->IsA() != TObjString::Class() ) // In case there is a diferent object, just to skip it
+      {
+        i++;
+      }
+      
+      TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(nchList->At(i));
+
+      
+         //Eta Resolution
+      if ( TString(p->GetName()).Contains("EtaReco") ) // We take the reco eta
+      {
+        sscanf(p->GetName(),"EtaReco%d",&labelEtaReco);
+        EtaReco = p->GetVal();
+        MCHisto(eventSelection,triggerClassName,centrality,"Eta")->Fill(EtaReco);
+      }
+      else if ( TString(p->GetName()).Contains("EtaMC") ) // We take the generated eta
+      {
+        sscanf(p->GetName(),"EtaMC%d",&labelEtaMC);
+        EtaMC = p->GetVal();
+        MCHisto(eventSelection,triggerClassName,centrality,"MCEta")->Fill(EtaMC);
+      }
+      if ( labelEtaReco > 0 && labelEtaReco == labelEtaMC ) // To be sure we compute the difference for the same particle
+      {
+        labelEtaReco = -1; // Restart of the label value to avoid double count the eta difference when computing the phi one 
+        Double_t EtaDif = EtaReco - EtaMC;
+        MCHisto(eventSelection,triggerClassName,centrality,"EtaRes")->Fill(EtaDif);
+        MCHisto(eventSelection,triggerClassName,centrality,"EtaResVsZ")->Fill(MCZv,EtaDif);
+        MCHisto(eventSelection,triggerClassName,centrality,"EtaResVsnC")->Fill(nContributors,EtaDif);
+      }
+      
+         //Phi Resolution
+      else if ( TString(p->GetName()).Contains("PhiReco") ) // We take the reco phi
+      {
+        sscanf(p->GetName(),"PhiReco%d",&labelPhiReco);
+        PhiReco = p->GetVal();
+        MCHisto(eventSelection,triggerClassName,centrality,"Phi")->Fill(PhiReco);
+      }
+      else if ( TString(p->GetName()).Contains("PhiMC") ) // We take the generated phi
+      {
+        sscanf(p->GetName(),"PhiMC%d",&labelPhiMC);
+        PhiMC = p->GetVal();
+        MCHisto(eventSelection,triggerClassName,centrality,"MCPhi")->Fill(PhiMC);
+      }
+      
+      if ( labelPhiReco > 0 && labelPhiReco == labelPhiMC ) // To be sure we compute the difference for the same particle
+      {
+        labelPhiReco = -1; // Restart of the label value to avoid double count the phi difference when computing the eta one
+        Double_t PhiDif = PhiReco - PhiMC;
+        MCHisto(eventSelection,triggerClassName,centrality,"PhiRes")->Fill(PhiDif);
+        
+        //___With the following algorithm we refer the differences to the interval [-Pi/2,Pi/2]
+        if ( PhiDif < -TMath::PiOver2() && PhiDif > -TMath::Pi() )
+        {
+          PhiDif = -TMath::Pi() - PhiDif;
+        }
+        else if ( PhiDif < -TMath::Pi() )
+        {
+          PhiDif = -2.*TMath::Pi() - PhiDif;
+          if ( PhiDif < -TMath::PiOver2() )
+          {
+            PhiDif = -TMath::Pi() - PhiDif;
+          }
+        }
+        
+        else if ( PhiDif > TMath::PiOver2() && PhiDif < TMath::Pi() )
+        {
+          PhiDif = TMath::Pi() - PhiDif;
+        }  
+        else if ( PhiDif > TMath::Pi() )
+        {
+          PhiDif = 2.*TMath::Pi() - PhiDif;
+          if ( PhiDif > TMath::PiOver2() )
+          {
+            PhiDif = TMath::Pi() - PhiDif;
+          }
+        }
+        //___
+        
+        MCHisto(eventSelection,triggerClassName,centrality,"PhiResVsZ")->Fill(MCZv,PhiDif);
+        MCHisto(eventSelection,triggerClassName,centrality,"PhiResShifted")->Fill(PhiDif);
+        MCHisto(eventSelection,triggerClassName,centrality,"PhiResVsnC")->Fill(nContributors,PhiDif);
+      }
+    }
+    
+    return; // When computing resolutions we skip the rest of the method
+  }
+  //_____
+  
+  
+  //___Multiplicity histos (just when not computing resolutions)___
+  TH1* hSPDcorrectionVsEta = static_cast<TH1*>(nchList->FindObject("MCSPDcorrectionVsEta"));
+  TH1* hNBkgTrackletsVSEta = static_cast<TH1*>(nchList->FindObject("NBkgTrackletsVSEta"));
+  TH1* hNchVsPhi = static_cast<TH1*>(nchList->FindObject("MCNchVsPhi"));
+  TH1* hNchVsEta = static_cast<TH1*>(nchList->FindObject("MCNchVsEta"));
+  TH1* hNTrackletVsEta = static_cast<TH1*>(nchList->FindObject("MCNTrackletVsEta"));
+  TH1* hNTrackletVsPhi = static_cast<TH1*>(nchList->FindObject("MCNTrackletVsPhi"));
+  
+  TProfile* hMeanNchVsEta = static_cast<TProfile*>(MCHisto(eventSelection,triggerClassName,centrality,"MeanNchVsEta"));
+  
+  TH2* hEventsVsZVertexVsEta = static_cast<TH2*>(MCHisto(eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta"));
+  
+  Int_t nBins(0);
+  
+  Double_t nchSum(0.),nTracklets(0.);
+  for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) //Loop over eta bins
+  {
+    Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
+    
+    if ( correction < 0 ) continue; // We count just the particles in the SPD acceptance.
+    
+    nTracklets += hNTrackletVsEta->GetBinContent(j); // Reco tracklets
+    
+    ++nBins; // We sum up the number of bins entering in the computation
+    
+    Double_t eta = fEtaAxis->GetBinCenter(j);
+    Double_t nch = hNchVsEta->GetBinContent(j); // Generated particles
+    
+    nchSum += nch;
+    
+    hMeanNchVsEta->Fill(eta,nch); // Fill the number of charged particles of each eta bin in the profile
+    
+    hEventsVsZVertexVsEta->Fill(MCZv,eta,1.0); // Fill 1 count each eta bin where the events contributes
+  }
+  
+  MCHisto(eventSelection,triggerClassName,centrality,"Tracklets")->Fill(nTracklets);
+  
+  if ( vertex )
+  {
+    SPDZv = vertex->GetZ();
+  }
+
+  Bool_t isMChisto = kTRUE; // Used to get the MC histos in the Add method
+  
+  AddHisto(eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta",SPDZv,hNBkgTrackletsVSEta,isMChisto);
+  AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsPhi",MCZv,hNchVsPhi,isMChisto);
+  AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta",MCZv,hNchVsEta,isMChisto);
+  AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta",SPDZv,hNTrackletVsEta,isMChisto);
+  AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi",SPDZv,hNTrackletVsPhi,isMChisto);
+  
+  MCHisto(eventSelection,triggerClassName,centrality,"MeanNchVsZVertex")->Fill(MCZv,nchSum);
+  MCHisto(eventSelection,triggerClassName,centrality,"Nch")->Fill(nchSum);
+  
+  
+  // Mean dNch/dEta computation
+  Double_t meandNchdEta(0.);
+  
+  if ( nBins >  0 )
+  {
+    meandNchdEta = nchSum / (nBins*fEtaAxis->GetBinWidth(5)); // Divide by nBins to get the mean and by the binWidht to get the d/dEta
+  }
+  
+  MCHisto(eventSelection,triggerClassName,centrality,"dNchdEta")->Fill(meandNchdEta);
+  
+  Double_t V0AMult = 0.;
+  Double_t V0CMult = 0.;
+  
+  AliVVZERO* vzero = Event()->GetVZEROData();
+  if (vzero)
+  {
+    Double_t multV0A = vzero->GetMTotV0A();
+    V0AMult = AliESDUtils::GetCorrV0A(multV0A,MCZv);
+    Double_t multV0C = vzero->GetMTotV0C();
+    V0CMult = AliESDUtils::GetCorrV0C(multV0C,MCZv);
+    
+    MCHisto(eventSelection,triggerClassName,centrality,"V0AMultVsNch")->Fill(V0AMult,nchSum);
+    MCHisto(eventSelection,triggerClassName,centrality,"V0CMultVsNch")->Fill(V0CMult,nchSum);
+    
+  }
+  //____
+}
+
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::GetEtaRangeSPD(Double_t spdZVertex, Double_t etaRange[])
+{
+  // Returns the SPD eta range for a given z vertex.
+  
+  Double_t etaMax(fEtaMax),etaMin(fEtaMin);
+  
+  Double_t vf1LR = fSPD1LR->Eval(spdZVertex); //Eta values for the z vertex over the SPD acceptance curves
+  Double_t vf2LR = fSPD2LR->Eval(spdZVertex);
+  Double_t vf1LL = fSPD1LL->Eval(spdZVertex);
+  Double_t vf2LL = fSPD2LL->Eval(spdZVertex);
+  
+  //____We start by asigning the eta range as the eta values in the SPD acceptance curve
+  if ( spdZVertex < 0. )
+  {
+    etaMax = vf2LR;
+    etaMin = TMath::Max(vf1LL,vf2LL);
+  }
+  else
+  {
+    etaMax = TMath::Min(vf1LR,vf2LR);
+    etaMin = vf2LL;
+  }
+  //____
+  
+  
+  //____Algorithm to avoid taking bins which are crossed by the SPD acceptance curves
+  Int_t binYMin = fEtaAxis->FindBin(etaMin); // Find the corresponding bins for eta max & min and z vertex
+  Int_t binYMax = fEtaAxis->FindBin(etaMax);
+  Int_t binX = fZAxis->FindBin(spdZVertex);
+  
+  // Define the values for the relevant edges of the eta and z bins
+  Double_t upEdge = fEtaAxis->GetBinUpEdge(binYMax);  // up edge of the top eta bin
+  Double_t lowEdge = fEtaAxis->GetBinLowEdge(binYMin); // low edge of the bottom eta bin
+  Double_t leftEdge = fZAxis->GetBinLowEdge(binX); // left edge of the z bin
+  Double_t rightEdge = fZAxis->GetBinUpEdge(binX); // right edge of the z bin
+  
+  Double_t etaMaxTemp(0.),etaMinTemp(0.);
+  if ( spdZVertex < 0. )
+  {
+    etaMaxTemp = fSPD2LR->Eval(rightEdge); // Define the temporary eta max as the value of the curve int the righ edge of the bin
+    etaMinTemp = TMath::Max(fSPD1LL->Eval(leftEdge),fSPD2LL->Eval(leftEdge));
+  }
+  else
+  {
+    etaMaxTemp = TMath::Min(fSPD1LR->Eval(rightEdge),fSPD2LR->Eval(rightEdge));
+    etaMinTemp = fSPD2LL->Eval(leftEdge);
+  }
+  
+  while ( upEdge > etaMaxTemp ) //We take eta max as the up edge of the 1st bin which is inside the SPD acceptance but not crossed by the curve
+  {
+    binYMax = binYMax - 1; // Since the up edge of the current bin is bigger than the SPD acc curve we move 1 bin below
+    upEdge = fEtaAxis->GetBinUpEdge(binYMax); // Take the up edge of the new bin
+    etaMax = upEdge - 1E-6; // We substract 1E-6 cause the up edge of the a bin belongs to the bin+1
+    
+  }
+  
+  //We take eta min as the low edge of the 1st bin which is inside the SPD acceptance but not crossed by the curve
+  while ( lowEdge < etaMinTemp )
+  {
+    binYMin = binYMin + 1; // Since the low edge of the current bin is smaller than the SPD acc curve we move 1 bin above
+    lowEdge = fEtaAxis->GetBinLowEdge(binYMin); // Take the low edge of the new bin
+    etaMin = lowEdge + 1E-6;
+  }
+  //____
+  
+  // In case the eta range we want (given in the constructor) is smaller than the one found by the algorithm (max range) we redefine the values
+  if ( etaMin < fEtaMin ) etaMin = fEtaMin + 1E-6;
+  if ( etaMax > fEtaMax ) etaMax = fEtaMax - 1E-6;
+  
+  etaRange[0] = etaMin;
+  etaRange[1] = etaMax;
+}
+
+//_____________________________________________________________________________
+Double_t AliAnalysisMuMuNch::GetSPDCorrection(Double_t zvert, Double_t eta) const
+{
+  if (!fSPDCorrection)
+  {
+    AliFatal("ERROR: No SPD Correction");
+    return 0;
+  }
+  Int_t bin = fSPDCorrection->FindBin(zvert,eta);
+  return fSPDCorrection->GetBinContent(bin);
+}
+
+
+//==============================These methods are useless here, anyway they should go in the EventCutterClass=================
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuNch::HasAtLeastNTrackletsInEtaRange(const AliVEvent& event, Int_t n, Double_t& etaMin, Double_t& etaMax) const
+{
+  if ( event.IsA() != AliAODEvent::Class() )
+  {
+    return kFALSE;
+  }
+  
+  AliAODTracklets* tracklets = static_cast<const AliAODEvent&>(event).GetTracklets();
+  
+  if (!tracklets)
+  {
+    return kFALSE;
+  }
+  
+  Int_t nTrackletsInRange(0);
+  
+  Int_t nTracklets = tracklets->GetNumberOfTracklets();
+  
+  for (Int_t i = 0 ; i < nTracklets && nTrackletsInRange < n; i++)
+  {
+    Double_t eta = -TMath::Log(TMath::Tan(tracklets->GetTheta(i)/2.0));
+    
+    if ( eta > etaMin && eta < etaMax )
+    {
+      ++nTrackletsInRange;
+    }
+  }
+  
+  return (nTrackletsInRange>=n);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::NameOfHasAtLeastNTrackletsInEtaRange(TString& name, Int_t n, Double_t& etaMin, Double_t& etaMax) const
+{
+  if ( TMath::AreEqualAbs(TMath::Abs(etaMin),TMath::Abs(etaMax),1E-9 ) )
+  {
+    name.Form("ATLEAST%dTRKLINABSETALT%3.1f",n,TMath::Abs(etaMin));
+  }
+  else
+  {
+    name.Form("ATLEAST%dTRKLINETA%3.1f-%3.1f",n,etaMin,etaMax);
+  }
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
+{
+  /// Set the event, compute multiplicities and add them to the event
+
+  if ( event->IsA() != AliAODEvent::Class() )
+  {
+    AliError("Only working for AODs for the moment.");
+    return;
+  }
+  
+  AliAnalysisMuMuBase::SetEvent(event,mcEvent); // To have Event() and MCEvent() method working
+  
+  TList* nchList = static_cast<TList*>(event->FindListObject("NCH")); // Define the list with the NCH info for each event
+  if (!nchList)
+  {
+    nchList = new TList;
+    nchList->SetOwner(kTRUE);
+    nchList->SetName("NCH");
+    event->AddObject(nchList);
+  }
+  
+  const AliAODVertex* vertexSPD = static_cast<const AliAODEvent*>(Event())->GetPrimaryVertexSPD(); // SPD vertex object
+  AliAODTracklets* tracklets = static_cast<const AliAODEvent*>(Event())->GetTracklets(); // Tracklets object
+  
+  TH1* hSPDcorrectionVsEta(0x0); // Pointers for the individual event histos
+  TH1* hNchVsEta(0x0);
+  TH1* hNTrackletVsEta(0x0);
+  TH1* hNTrackletVsPhi(0x0);
+  
+  //_______Create once the histos with the individual event "properties" (cleared at the beginning of each new event)_______
+  if ( !fResolution ) // When computing resolutions we dont do anything else
+  {
+    if ( !Histo("AliAnalysisMuMuNch","SPDcorrectionVsEta") )
+    {
+      CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","SPDcorrectionVsEta","SPD correction-like vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+      
+      CreateEventHistos(kHistoForMCInput,"AliAnalysisMuMuNch","NchVsEta","Nch vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+
+      CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","NTrackletVsEta","Ntracklet vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+      
+      CreateEventHistos(kHistoForData,"AliAnalysisMuMuNch","NBkgTrackletsVSEta","NBkg Tracklets vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+      
+      Double_t phimin = 0.; //Phi range
+      Double_t phimax = 2*TMath::Pi();
+      Int_t nphibins = GetNbins(phimin,phimax,0.05);
+      
+      CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","NTrackletVsPhi","Ntracklet vs #phi;#phi",nphibins,phimin,phimax);
+      
+      CreateEventHistos(kHistoForMCInput,"AliAnalysisMuMuNch","NchVsPhi","Nch vs #phi;#phi",nphibins,phimin,phimax);
+      
+      CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","test","test",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+      
+      Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD1LR);
+      Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD1LL);
+      Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD2LR);
+      Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD2LL);
+    }
+    //_________
+    
+    
+    hSPDcorrectionVsEta = Histo("AliAnalysisMuMuNch","SPDcorrectionVsEta"); // Set the individual event histos
+    hNTrackletVsEta = Histo("AliAnalysisMuMuNch","NTrackletVsEta");
+    hNTrackletVsPhi = Histo("AliAnalysisMuMuNch","NTrackletVsPhi");
+    
+    
+    hSPDcorrectionVsEta->Reset(); // Reset of the individual event histos
+    hNTrackletVsEta->Reset();
+    hNTrackletVsPhi->Reset();
+  }
+  
+  Double_t etaRange[2]; // Variables we will use in the multiplicity computation
+  Int_t binMin,binMax;
+  Int_t nTracklets(0);
+  Double_t thetaTracklet(0.),phiTracklet(0.),etaTracklet(0.);
+  Double_t nch(0.0);
+  Int_t nBins(0);
+  
+  
+  //____Data (or Reco if simu) multiplicity computation___
+  if ( fSPDCorrection && !fResolution ) // When computing resolutions we dont do anything else
+  {
+    if ( tracklets && vertexSPD )
+    {
+      Double_t SPDZv = vertexSPD->GetZ();
+
+      GetEtaRangeSPD(SPDZv,etaRange);
+      
+      Histo("AliAnalysisMuMuNch","test")->Fill(SPDZv,etaRange[1]);
+      Histo("AliAnalysisMuMuNch","test")->Fill(SPDZv,etaRange[0]);
+      
+      nTracklets = tracklets->GetNumberOfTracklets();
+      
+      Double_t SPDr;
+      for (Int_t i = 0 ; i < nTracklets ; i++)
+      {
+        thetaTracklet = tracklets->GetTheta(i);
+        etaTracklet = -TMath::Log(TMath::Tan(thetaTracklet/2.));
+        if ( etaTracklet < etaRange[0] || etaTracklet > etaRange[1] ) continue; // Avoid tracklets out of the eta SPD acceptance or out of the eta cut
+        
+        SPDr = GetSPDCorrection(SPDZv,etaTracklet);
+        
+        Int_t bin = fEtaAxis->FindBin(etaTracklet);
+        
+        if ( SPDr!=0. && SPDr <= 2.5) // Threshold to reduce border effects
+        {
+          hSPDcorrectionVsEta->SetBinContent(bin,SPDr);
+          hNTrackletVsEta->Fill(etaTracklet);
+          hNTrackletVsPhi->Fill(tracklets->GetPhi(i));
+        }
+        else // If the correction is above the threshold we store a -1 in the correction to skip this eta bin int the fill method
+        {
+          hSPDcorrectionVsEta->SetBinContent(bin,-1.0);
+        }
+      }
+      
+      //___ Fill the out-of-eta-range bins with -1.0
+      
+      binMin = fEtaAxis->FindBin(etaRange[0]);
+      binMax = fEtaAxis->FindBin(etaRange[1]);
+      
+      for ( Int_t i = 1; i < binMin; ++i )
+      {
+        hSPDcorrectionVsEta->SetBinContent(i,-1.0);
+      }
+      for ( Int_t i = binMax + 1 ; i <= fEtaAxis->GetNbins(); ++i )
+      {
+        hSPDcorrectionVsEta->SetBinContent(i,-1.0);
+      }
+      //____
+      nchList->Clear(); // We clear the NCH list for this new event
+      
+      if ( !IsHistogrammingDisabled() )
+      {
+        nchList->Add(hSPDcorrectionVsEta->Clone());
+        nchList->Add(hNTrackletVsEta->Clone());
+        nchList->Add(hNTrackletVsPhi->Clone());
+      }
+      
+          //----- Mean dNchdEta computation to set it into the event
+      for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) // Loop over eta bins
+      {
+        Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
+        
+        Double_t eta = fEtaAxis->GetBinCenter(j);
+        
+        if ( correction < 0 ) continue; // If the correction is < 0 we skip that eta bin 
+        else if ( correction == 0.0 ) // If the correction is 0 we have no tracklets in that eta bin
+        {
+          Double_t spdCorrection = GetSPDCorrection(SPDZv,eta);
+          if ( spdCorrection == 0. || spdCorrection > 2.5) continue; // If the correction in the eta bin is not within the threshold we do not count the "0"(that eta bin will not count for nBins)
+        }
+        
+        nch += hNTrackletVsEta->GetBinContent(j) * correction; // Number of charged particles (tracklets*SPDcorrection)
+        
+        ++nBins; // We sum up the number of bins entering in the computation
+      }
+      
+      Double_t meandNchdEta(0.); // We compute the mean dNch/dEta in the event
+      if ( nBins >  0 ) 
+      {
+        meandNchdEta = nch / (nBins*fEtaAxis->GetBinWidth(5));
+      }
+      
+      nchList->Add(new TParameter<Double_t>("MeandNchdEta",meandNchdEta)); // We add the mean dNch/dEta to the event. It will serve us as a multiplicity estimator.
+      //------
+      
+    }
+    
+    else  nchList->Clear(); //To clear the NCH list for MC in case the event has no reconstructed SPD vertex
+  }
+  //_______
+  
+  else nchList->Clear(); // To clear the NCH list for MC in case we have MC and no correction (SPD correction computation mode)
+
+  
+  //____Input MC multiplicity computation ___
+  if ( HasMC() )
+  {
+    if ( !fResolution ) //When computing resolutions we dont do anything else
+    {
+      Double_t MCZv = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent());
+      GetEtaRangeSPD(MCZv,etaRange);
+      
+      hNchVsEta = MCHisto("AliAnalysisMuMuNch","NchVsEta");
+      hSPDcorrectionVsEta = MCHisto("AliAnalysisMuMuNch","SPDcorrectionVsEta");
+      TH1* hNchVsPhi = MCHisto("AliAnalysisMuMuNch","NchVsPhi");
+      hNTrackletVsEta = MCHisto("AliAnalysisMuMuNch","NTrackletVsEta");
+      hNTrackletVsPhi = MCHisto("AliAnalysisMuMuNch","NTrackletVsPhi");
+      
+      hNTrackletVsEta->Reset();
+      hNchVsEta->Reset();
+      hNchVsPhi->Reset();
+      hSPDcorrectionVsEta->Reset();
+      hNTrackletVsPhi->Reset();
+      
+      //___ Fill the out-of-eta-range bins with -1.0
+      binMin = fEtaAxis->FindBin(etaRange[0]);
+      binMax = fEtaAxis->FindBin(etaRange[1]);
+      
+      for ( Int_t i = 1; i < binMin; ++i )
+      {
+        hSPDcorrectionVsEta->SetBinContent(i,-1.0);
+      }
+      for ( Int_t i = binMax + 1 ; i <= fEtaAxis->GetNbins(); ++i )
+      {
+        hSPDcorrectionVsEta->SetBinContent(i,-1.0);
+      }
+      for ( Int_t i = binMin; i <= binMax; ++i ) // Fill the bins inside the eta range with +1
+      {
+        hSPDcorrectionVsEta->SetBinContent(i,1.0);
+      }
+      //___
+      
+      Int_t nMCTracks = MCEvent()->GetNumberOfTracks(); // MC number of MC tracks
+      
+      for ( Int_t i = 0; i < nMCTracks ; ++i ) //Loop over generated tracks
+      {
+        AliAODMCParticle* AODpart = static_cast<AliAODMCParticle*>(mcEvent->GetTrack(i));
+        
+        if ( AODpart->IsPhysicalPrimary() ) // We take only particles produced in the collision (Particles produced in the collision including products of strong and electromagnetic decay and excluding feed-down from weak decays of strange particles)
+        {
+          if ( AODpart->Charge()!=0 ) // We take only charged particles
+          {
+            hNchVsEta->Fill(AODpart->Eta());
+            hNchVsPhi->Fill(AODpart->Phi());
+            
+          }
+        }
+      }
+      
+      nchList->Add(hNchVsEta->Clone("MCNchVsEta"));
+      nchList->Add(hNchVsPhi->Clone("MCNchVsPhi"));
+      nchList->Add(hSPDcorrectionVsEta->Clone("MCSPDcorrectionVsEta"));
+    }
+              //__Bkg tracklets and Resolution estimation __
+    if ( tracklets ) // We can compute the Bkg tracklets and resolution only if we have the tracklets object in the event
+    {
+      TH1* hNBkgTrackletsVSEta(0x0); // Pointer for the Bkg histo
+      if ( !fResolution )
+      {
+        hNBkgTrackletsVSEta = Histo("AliAnalysisMuMuNch","NBkgTrackletsVSEta");
+        
+        hNBkgTrackletsVSEta->Reset();
+      }
+      
+      nTracklets = tracklets->GetNumberOfTracklets();
+      
+      for (Int_t i = 0 ; i < nTracklets ; i++) // Loop over tracklets to check if they come or not from the same MC particle
+      {
+        thetaTracklet = tracklets->GetTheta(i);
+        etaTracklet = -TMath::Log(TMath::Tan(thetaTracklet/2.));
+        phiTracklet = tracklets->GetPhi(i);
+        
+        
+        if ( !fResolution )
+        {
+          hNTrackletVsEta->Fill(etaTracklet);
+          hNTrackletVsPhi->Fill(phiTracklet);
+        }
+        
+        Int_t label1 = tracklets->GetLabel(i,0);
+        Int_t label2 = tracklets->GetLabel(i,1);  
+        
+        if (label1 != label2 ) // Tracklets not comming from the same MC particle are Bkg
+        {
+         if (!fResolution ) hNBkgTrackletsVSEta->Fill(etaTracklet);
+        }
+        else if ( !fSPDCorrection && fResolution ) // Compute the resolutions with the tracklets comming from the same MC particle
+        {
+          AliAODMCParticle* AODpartMC = static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(label1));
+          Double_t etaTrackletMC = AODpartMC->Eta();
+          Double_t phiTrackletMC = AODpartMC->Phi();
+          
+          // Resolution variables
+          nchList->Add(new TParameter<Double_t>(Form("EtaReco%d",label1),etaTracklet));
+          nchList->Add(new TParameter<Double_t>(Form("EtaMC%d",label1),etaTrackletMC));
+          
+          nchList->Add(new TParameter<Double_t>(Form("PhiReco%d",label1),phiTracklet));
+          nchList->Add(new TParameter<Double_t>(Form("PhiMC%d",label1),phiTrackletMC));
+                 
+        }
+      }
+      
+      if (!fResolution )
+      {
+        nchList->Add(hNTrackletVsEta->Clone("MCNTrackletVsEta"));
+        nchList->Add(hNTrackletVsPhi->Clone("MCNTrackletVsPhi"));
+        nchList->Add(hNBkgTrackletsVSEta->Clone());
+      }
+      
+    }
+    
+  }
+  //_______
+  
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuNch::Terminate(Option_t *)
+{
+  /// Called once at the end of the query
+  if ( !HistogramCollection() ) return;
+
+  if ( HistogramCollection()->FindObject("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsEta") )
+  {
+    HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsEta");
+    HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsPhi");
+    HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NchVsEta");
+    HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NchVsPhi");
+    HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/SPDcorrectionVsEta");
+    HistogramCollection()->Remove("/AliAnalysisMuMuNch/NBkgTrackletsVSEta");
+  }
+  
+  if ( HistogramCollection()->FindObject("/AliAnalysisMuMuNch/NTrackletVsEta") )
+  {
+    HistogramCollection()->Remove("/AliAnalysisMuMuNch/NTrackletVsEta");
+    HistogramCollection()->Remove("/AliAnalysisMuMuNch/test");
+    HistogramCollection()->Remove("/AliAnalysisMuMuNch/NTrackletVsPhi");
+    HistogramCollection()->Remove("/AliAnalysisMuMuNch/SPDcorrectionVsEta");
+  }
+  //____ Compute dNchdEta histo
+  TObjArray* idArr =  HistogramCollection()->SortAllIdentifiers();
+
+  TIter next(idArr);
+  TObjString* id;
+  
+  while ( (id = static_cast<TObjString*>(next())) )
+  {
+    TProfile* p = static_cast<TProfile*>(HistogramCollection()->FindObject(Form("%s%s",id->GetName(),"MeanNchVsEta")));
+
+    if ( !p ) continue;
+    
+    TH1* h = new TH1F("MeandNchdEta","Event averaged dN_{ch}/d#eta ;#eta;<dN_{ch}/d#eta>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
+
+    if ( p->GetNbinsX() != h->GetNbinsX() || p->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin() || p->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax() )
+    {
+      AliError("ERROR: Cannot compute MeandNchdEta since the binning doesn't match with MeanNchVsEta histo");
+      continue;
+    }
+    
+    for ( Int_t i = 1 ; i < h->GetNbinsX() ; i++ )
+    {
+      h->SetBinContent(i,p->GetBinContent(i)/p->GetBinWidth(i));
+      h->SetBinError(i,p->GetBinError(i)/p->GetBinWidth(i));
+      h->SetEntries(p->GetEntries());
+    }
+  
+    HistogramCollection()->Adopt(Form("%s",id->GetName()),h);
+  }
+    
+  delete idArr;
+  //___
+}
diff --git a/PWG/muon/AliAnalysisMuMuNch.h b/PWG/muon/AliAnalysisMuMuNch.h
new file mode 100644 (file)
index 0000000..429dc25
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef ALIANALYSISMUMUNCH_H
+#define ALIANALYSISMUMUNCH_H
+
+/**
+ *
+ * \class AliAnalysisMuMuNch
+ * \brief Charged particle multiplicity analysis (for plotting muon variables against it)
+ * \author L. Aphecetche and J. Martin-Bianco (Subatech)
+ */
+
+#include "AliAnalysisMuMuBase.h"
+
+class TH2F;
+class TH2;
+class AliVEvent;
+class TAxis;
+class TF1;
+class AliAODVertex;
+
+class AliAnalysisMuMuNch : public AliAnalysisMuMuBase
+{
+public:
+  
+  AliAnalysisMuMuNch(TH2* spdCorrection=0x0, Double_t etaMin=-0.5, Double_t etaMax=0.5
+                     , Double_t zmin=-40, Double_t zmax=40,Bool_t disableHistos=kFALSE,
+                     Bool_t computeResolution=kFALSE);
+  virtual ~AliAnalysisMuMuNch();
+  
+  Bool_t HasAtLeastNTrackletsInEtaRange(const AliVEvent& event, Int_t n,
+                                        Double_t& etaMin, Double_t& etaMax) const;
+
+  void NameOfHasAtLeastNTrackletsInEtaRange(TString& name, Int_t n,
+                                            Double_t& etaMin, Double_t& etaMax) const;
+  
+  virtual void SetEvent(AliVEvent* event, AliMCEvent* mcEvent=0x0);
+
+  virtual void Terminate(Option_t* /*opt*/="");
+
+protected:
+
+  void AddHisto(const char* eventSelection,
+                const char* triggerClassName,
+                const char* centrality,
+                const char* histoname,
+                Double_t z,
+                TH1* h,
+                Bool_t isMC=kFALSE);
+  
+  void AttachSPDAcceptance(UInt_t dataType,
+                           const char* eventSelection,
+                           const char* triggerClassName,
+                           const char* centrality,const char* histoname);
+
+
+  void FillHistosForMCEvent(const char* eventSelection, const char* triggerClassName,
+              const char* centrality);
+  
+
+  void FillHistosForEvent(const char* eventSelection, const char* triggerClassName,
+                          const char* centrality);
+  
+  virtual void DefineHistogramCollection(const char* eventSelection, const char* triggerClassName,
+                                         const char* centrality);
+
+  void DefineSPDAcceptance();
+  
+  void GetEtaRangeSPD(Double_t spdZVertex, Double_t etaRange[]);
+
+  Double_t GetSPDCorrection(Double_t zvert, Double_t eta) const;
+
+private:
+  TH2F* fSPDCorrection; // Nch/Tracklets_SPD (eta vs z)
+  TAxis* fEtaAxis; // Eta axis used for the histos
+  TAxis* fZAxis;  // Z vertex axis used for the histos
+  AliVEvent* fCurrentEvent; //! cache of the current event
+  Double_t fEtaMin; // Minimum tracklet eta value 
+  Double_t fEtaMax; // Maximum tracklet eta value 
+  Double_t fZMin; // Minimum z vertex value 
+  Double_t fZMax; // Maximum z vertex value 
+  Bool_t fResolution; // Flag to set the resolution computation
+  
+  TF1* fSPD1LR; // SPD acceptance shape
+  TF1* fSPD1LL; // SPD acceptance shape
+  TF1* fSPD2LR; // SPD acceptance shape
+  TF1* fSPD2LL; // SPD acceptance shape
+  
+  ClassDef(AliAnalysisMuMuNch,1) // implementation of AliAnalysisMuMuBase for Nch analysis
+};
+
+#endif
diff --git a/PWG/muon/AliAnalysisMuMuSingle.cxx b/PWG/muon/AliAnalysisMuMuSingle.cxx
new file mode 100644 (file)
index 0000000..5fdd212
--- /dev/null
@@ -0,0 +1,359 @@
+#include "AliAnalysisMuMuSingle.h"
+
+/**
+ *
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisMuMuSingle
+ *
+ * Histogramming of single muon tracks. Mostly to get control plots for
+ * the AliAnalysisMuMuMinv sub-analysis, with respect to track cuts used, 
+ * like Rabs, p x DCA, etc...
+ *
+ */
+
+
+#include "TH2F.h"
+#include "AliMuonTrackCuts.h"
+#include "AliAnalysisMuonUtility.h"
+#include "TMath.h"
+#include "AliLog.h"
+#include "AliVParticle.h"
+#include "TLorentzVector.h"
+#include "AliAnalysisMuMuCutCombination.h"
+#include "AliAnalysisMuMuCutRegistry.h"
+#include "AliMergeableCollection.h"
+
+ClassImp(AliAnalysisMuMuSingle)
+
+//_____________________________________________________________________________
+AliAnalysisMuMuSingle::AliAnalysisMuMuSingle()
+: AliAnalysisMuMuBase(),
+fMuonTrackCuts(0x0),
+fShouldSeparatePlusAndMinus(kFALSE),
+fAccEffHisto(0x0)
+{
+  /// ctor
+}
+
+//_____________________________________________________________________________
+AliAnalysisMuMuSingle::~AliAnalysisMuMuSingle()
+{
+  /// dtor
+  delete fMuonTrackCuts;
+  delete fAccEffHisto;
+}
+
+
+//_____________________________________________________________________________
+void
+AliAnalysisMuMuSingle::CreateTrackHisto(const char* eventSelection,
+                                        const char* triggerClassName,
+                                        const char* centrality,
+                                        const char* hname, const char* htitle,
+                                        Int_t nbinsx, Double_t xmin, Double_t xmax,
+                                        Int_t nbinsy, Double_t ymin, Double_t ymax,
+                                        Bool_t separatePlusAndMinus) const
+{
+  /// Append histograms for single track to our histogram collection
+  
+  if ( IsHistogramDisabled(hname) ) return;
+  
+  if ( separatePlusAndMinus )
+  {
+    const char* suffix[] = { "Plus", "Minus" };
+    const char* symbol[] = { "+", "-" };
+    
+    for ( Int_t i = 0; i < 2; ++i )
+    {
+      TString shtitle(htitle);
+      TString shname(hname);
+      
+      shtitle.ReplaceAll("#mu",Form("#mu^{%s}",symbol[i]));
+      
+      shname += suffix[i];
+      
+      CreateTrackHistos(eventSelection,triggerClassName,centrality,shname.Data(),shtitle.Data(),
+                        nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+    }
+  }
+  else
+  {
+    CreateTrackHistos(eventSelection,triggerClassName,centrality,hname,htitle,
+                nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+  }
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuSingle::IsRabsOK(const AliVParticle& part) const
+{
+  Double_t thetaAbsEndDeg = AliAnalysisMuonUtility::GetThetaAbsDeg(&part);
+  
+  return ( thetaAbsEndDeg > 2. && thetaAbsEndDeg < 10. );
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisMuMuSingle::IsEtaInRange(const AliVParticle& part, Double_t& etamin, Double_t& etamax) const
+{
+  return (part.Eta() >= etamin && part.Eta() <= etamax);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuSingle::SetRun(const AliInputEventHandler* eventHandler)
+{
+  MuonTrackCuts()->SetRun(eventHandler);
+}
+
+//_____________________________________________________________________________
+Int_t AliAnalysisMuMuSingle::EAGetNumberOfMuonTracks() const
+{
+  // Get the number of muon tracks *that are not ghosts*
+  
+  Int_t ntracks = AliAnalysisMuonUtility::GetNTracks(Event());
+  
+  for ( Int_t i = 0; i < ntracks; ++i )
+  {
+    AliVParticle* track = AliAnalysisMuonUtility::GetTrack(i,Event());
+    if (AliAnalysisMuonUtility::IsMuonGhost(track)) --ntracks;
+  }
+  
+  return ntracks;
+}
+
+////_____________________________________________________________________________
+//Int_t AliAnalysisMuMuSingle::EAGetNumberOfSelectMuonTracks() const
+//{
+//  // Get the number of "very good" muon tracks :
+//  // Rabs + DCA + pT > 1.5 Gev/C
+//  
+//  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
+//  
+//  UInt_t check = kAll | kMatched | kRabs | kDCA | kEta | kPt1dot5;
+//  
+//  Int_t nGood(0);
+//  
+//  for ( Int_t i = 0; i < nTracks; ++i )
+//  {
+//    ULong64_t m = GetTrackMask(i);
+//    if ( ( m & check ) == check )
+//    {
+//      ++nGood;
+//    }
+//  }
+//  return nGood;
+//}
+
+//_____________________________________________________________________________
+Double_t AliAnalysisMuMuSingle::EAGetTrackDCA(const AliVParticle& track) const
+{
+  // Get track DCA
+  
+  Double_t xdca = AliAnalysisMuonUtility::GetXatDCA(&track);
+  Double_t ydca = AliAnalysisMuonUtility::GetYatDCA(&track);
+  
+  return TMath::Sqrt(xdca*xdca+ydca*ydca);
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuSingle::DefineHistogramCollection(const char* eventSelection,
+                                                      const char* triggerClassName,
+                                                      const char* centrality)
+{
+  /// Actually create the histograms for phyics/triggerClassName
+  if ( Histo(eventSelection,triggerClassName,centrality,"AliAnalysisMuMuSingle") )
+  {
+    return;
+  }
+
+  AliAnalysisMuMuBase::EDataType dt = AliAnalysisMuMuBase::kHistoForData;
+  
+  // dummy histogram to signal that we already defined all our histograms (see above)
+  CreateEventHistos(dt,eventSelection,triggerClassName,centrality,"AliAnalysisMuMuSingle","Dummy semaphore",1,0,1);
+  
+  Double_t ptMin = 0;
+  Double_t ptMax = 12*3;
+  Int_t nbinsPt = GetNbins(ptMin,ptMax,0.5);
+  Double_t pMin = 0;
+  Double_t pMax = 100*3;
+  Int_t nbinsP = GetNbins(pMin,pMax,2.0);
+  Double_t etaMin = -5;
+  Double_t etaMax = -2;
+  Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
+  
+  Double_t rapidityMin = -5;
+  Double_t rapidityMax = -2;
+  Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
+  
+  Double_t phiMin = -TMath::Pi();
+  Double_t phiMax = TMath::Pi();
+  Int_t nbinsPhi = GetNbins(phiMin,phiMax,0.05);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"Chi2MatchTrigger","Chi2 Match Trigger",72,0,72);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"EtaRapidityMu", "Eta distribution vs Rapidity for #mu", nbinsRapidity,rapidityMin,rapidityMax,nbinsEta,etaMin,etaMax, fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"PtEtaMu", "P_{T} distribution vs Eta for #mu", nbinsEta,etaMin,etaMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"PtRapidityMu", "P_{T} distribution vs Rapidity for #mu", nbinsRapidity,rapidityMin,rapidityMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"PtPhiMu", "P_{T} distribution vs phi for #mu", nbinsPhi,phiMin,phiMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
+  
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"PEtaMu", "P distribution for #mu",nbinsEta,etaMin,etaMax,nbinsP,pMin,pMax,fShouldSeparatePlusAndMinus);
+  
+  Double_t chi2min = 0;
+  Double_t chi2max = 20;
+  Int_t nbinchi2 = GetNbins(chi2min,chi2max,0.05);
+  
+  CreateTrackHisto(eventSelection, triggerClassName, centrality, "Chi2Mu", "chisquare per NDF #mu", nbinchi2, chi2min, chi2max,-1, 0.0, 0.0, fShouldSeparatePlusAndMinus);
+  
+  Double_t xmin = 0;
+  Double_t xmax = 150;
+  Int_t nbins = GetNbins(xmin,xmax,2.0);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"dcaP23Mu","#mu DCA vs P for 2-3 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"dcaP310Mu","#mu DCA vs P for 3-10 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"dcaPwPtCut23Mu","#mu DCA vs P for 2-3 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);
+  
+  CreateTrackHisto(eventSelection,triggerClassName,centrality,"dcaPwPtCut310Mu","#mu DCA vs P for 3-10 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);
+  
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuSingle::FillHistosForTrack(const char* eventSelection,
+                                               const char* triggerClassName,
+                                               const char* centrality,
+                                               const char* trackCutName,
+                                               const AliVParticle& track)
+{
+  /// Fill histograms for one track
+  
+  if (!AliAnalysisMuonUtility::IsMuonTrack(&track) ) return;
+  
+  if ( HasMC() )
+  {
+    MuonTrackCuts()->SetIsMC();
+  }
+  
+  TLorentzVector p(track.Px(),track.Py(),track.Pz(),
+                   TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+track.P()*track.P()));
+  
+  
+  TString charge("");
+  
+  if ( ShouldSeparatePlusAndMinus() )
+  {
+    if ( track.Charge() < 0 )
+    {
+      charge = "Minus";
+    }
+    else
+    {
+      charge = "Plus";
+    }
+  }
+  
+  Double_t dca = EAGetTrackDCA(track);
+  
+  Double_t theta = AliAnalysisMuonUtility::GetThetaAbsDeg(&track);
+  
+  if (!IsHistogramDisabled("Chi2MatchTrigger"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,"Chi2MatchTrigger")->Fill(AliAnalysisMuonUtility::GetChi2MatchTrigger(&track));
+  }
+  
+  if (!IsHistogramDisabled("EtaRapidityMu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("EtaRapidityMu%s",charge.Data()))->Fill(p.Rapidity(),p.Eta());
+  }
+  
+  if (!IsHistogramDisabled("PtEtaMu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("PtEtaMu%s",charge.Data()))->Fill(p.Eta(),p.Pt());
+  }
+  
+  if (!IsHistogramDisabled("PtRapidityMu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("PtRapidityMu%s",charge.Data()))->Fill(p.Rapidity(),p.Pt());
+  }
+  
+  if (!IsHistogramDisabled("PEtaMu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("PEtaMu%s",charge.Data()))->Fill(p.Eta(),p.P());
+  }
+  
+  if (!IsHistogramDisabled("PtPhiMu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("PtPhiMu%s",charge.Data()))->Fill(p.Phi(),p.Pt());
+  }
+  
+  if (!IsHistogramDisabled("Chi2Mu*"))
+  {
+    Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("Chi2Mu%s",charge.Data()))->Fill(AliAnalysisMuonUtility::GetChi2perNDFtracker(&track));
+  }
+  
+  if ( theta >= 2.0 && theta < 3.0 )
+  {
+    
+    if (!IsHistogramDisabled("dcaP23Mu*"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("dcaP23Mu%s",charge.Data()))->Fill(p.P(),dca);
+    }
+    
+    if ( p.Pt() > 2 )
+    {
+      if (!IsHistogramDisabled("dcaPwPtCut23Mu*"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("dcaPwPtCut23Mu%s",charge.Data()))->Fill(p.P(),dca);
+      }
+    }
+  }
+  else if ( theta >= 3.0 && theta < 10.0 )
+  {
+    if (!IsHistogramDisabled("dcaP310Mu*"))
+    {
+      Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("dcaP310Mu%s",charge.Data()))->Fill(p.P(),dca);
+    }
+    if ( p.Pt() > 2 )
+    {
+      if (!IsHistogramDisabled("dcaPwPtCut310Mu*"))
+      {
+        Histo(eventSelection,triggerClassName,centrality,trackCutName,Form("dcaPwPtCut310Mu%s",charge.Data()))->Fill(p.P(),dca);
+      }
+    }
+  }
+}
+
+//_____________________________________________________________________________
+AliMuonTrackCuts* AliAnalysisMuMuSingle::MuonTrackCuts()
+{
+  /// Get (and create the first time) our internal track cuts
+  if (!fMuonTrackCuts)
+  {
+    fMuonTrackCuts = new AliMuonTrackCuts;
+    
+    fMuonTrackCuts->SetAllowDefaultParams(kTRUE);
+    
+    fMuonTrackCuts->SetFilterMask(AliMuonTrackCuts::kMuEta |
+                                  AliMuonTrackCuts::kMuThetaAbs |
+                                  AliMuonTrackCuts::kMuPdca |
+                                  AliMuonTrackCuts::kMuMatchApt |
+                                  AliMuonTrackCuts::kMuMatchLpt |
+                                  AliMuonTrackCuts::kMuMatchHpt |
+                                  AliMuonTrackCuts::kMuTrackChiSquare);
+    
+  }
+  
+  return fMuonTrackCuts;
+}
+
+//_____________________________________________________________________________
+void AliAnalysisMuMuSingle::SetMuonTrackCuts(const AliMuonTrackCuts& trackCuts)
+{
+  /// Set our muontrackcuts from external source
+  delete fMuonTrackCuts;
+  fMuonTrackCuts = static_cast<AliMuonTrackCuts*>(trackCuts.Clone());
+}
diff --git a/PWG/muon/AliAnalysisMuMuSingle.h b/PWG/muon/AliAnalysisMuMuSingle.h
new file mode 100644 (file)
index 0000000..a8b7988
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef ALIANALYSISMUMUSINGLE_H
+#define ALIANALYSISMUMUSINGLE_H
+
+/**
+ *
+ * \class AliAnalysisMuMuSingle
+ * 
+ * \brief Histogramming of single muon tracks.
+ *
+ * \author L. Aphecetche (Subatech)
+ *
+ */
+
+#include "AliAnalysisMuMuBase.h"
+
+class AliMuonTrackCuts;
+class TH2F;
+class TObjArray;
+
+class AliAnalysisMuMuSingle : public AliAnalysisMuMuBase
+{
+public:
+  
+  AliAnalysisMuMuSingle();
+  virtual ~AliAnalysisMuMuSingle();
+  
+  virtual void ShouldSeparatePlusAndMinus(Bool_t value) { fShouldSeparatePlusAndMinus = value; }
+  
+  virtual Bool_t ShouldSeparatePlusAndMinus() const { return fShouldSeparatePlusAndMinus; }
+
+  AliMuonTrackCuts* MuonTrackCuts();
+  
+  void SetMuonTrackCuts(const AliMuonTrackCuts& trackCuts);
+  
+  Bool_t IsRabsOK(const AliVParticle& part) const;
+  void NameOfIsRabsOK(TString& name) const { name = "RABS"; }
+
+  Bool_t IsEtaInRange(const AliVParticle& part, Double_t& etamin, Double_t& etamax) const;
+  void NameOfIsEtaInRange(TString& name, Double_t& etamin, Double_t& etamax) const
+  { name.Form("ETA%3.1f-%3.1f",etamin,etamax); }
+
+  void SetRun(const AliInputEventHandler* eventHandler);
+
+protected:
+  
+  void DefineHistogramCollection(const char* eventSelection, const char* triggerClassName,
+                                 const char* centrality);
+
+  virtual void FillHistosForTrack(const char* eventSelection, const char* triggerClassName,
+                                  const char* centrality,
+                                  const char* trackCutName,
+                                  const AliVParticle& part);
+
+private:
+  
+  void CreateTrackHisto(const char* eventSelection,
+                        const char* triggerClassName,
+                        const char* centrality,
+                        const char* hname, const char* htitle,
+                        Int_t nbinsx, Double_t xmin, Double_t xmax,
+                        Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0,
+                        Bool_t separatePlusAndMinus=kFALSE) const;
+
+  Double_t GetTrackTheta(const AliVParticle& particle) const;
+  
+  /* methods prefixed with EA should really not exist at all. They are there
+   only because the some of our base interfaces are shamelessly incomplete or
+   inadequate...
+   */
+  
+  Int_t EAGetNumberOfMuonTracks() const;
+  
+//  Int_t EAGetNumberOfSelectMuonTracks() const;
+  
+  Double_t EAGetTrackDCA(const AliVParticle& particle) const;
+     
+private:
+  AliMuonTrackCuts* fMuonTrackCuts; //! common cuts for muon tracks (from Diego)
+  Bool_t fShouldSeparatePlusAndMinus; // whether or not to histogram mu+ and mu- separately
+  TH2F* fAccEffHisto; // dimuon acc x eff (y vs pt)
+  
+  ClassDef(AliAnalysisMuMuSingle,1) // implementation of AliAnalysisMuMuBase for single mu analysis
+};
+
+#endif
index 3fdf1e6d19fe6a24432a4a9491c44e43c4db9d61..8689795a73bf38e9126591c1404b1b52ba29647d 100644 (file)
 #include "TFile.h"
 
 // STEER includes
-#include "AliInputEventHandler.h"
-#include "AliAODHeader.h"
 #include "AliAODEvent.h"
-#include "AliAODTrack.h"
+#include "AliAODHeader.h"
 #include "AliAODMCHeader.h"
 #include "AliAODMCParticle.h"
-#include "AliMCEvent.h"
-#include "AliMCParticle.h"
+#include "AliAODTrack.h"
+#include "AliAODTZERO.h"
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
-#include "AliVVertex.h"
+#include "AliESDTZERO.h"
+#include "AliInputEventHandler.h"
 #include "AliLog.h"
+#include "AliMCEvent.h"
+#include "AliMCParticle.h"
+#include "AliVVertex.h"
 #include "AliStack.h"
 
 // CORRFW includes
@@ -548,6 +550,43 @@ TString AliAnalysisMuonUtility::GetTrackHistory ( const AliVParticle* track, con
   return trackHistory;
 }
 
+//________________________________________________________________________
+Bool_t AliAnalysisMuonUtility::EAGetTZEROFlags(const AliVEvent* event, Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag)
+{
+  // get the TZERO decisions
+  // return false if there's no tzero information in this event
+  
+  Bool_t rv(kFALSE);
+  
+  if ( event->IsA() == AliESDEvent::Class() )
+  {
+    const AliESDTZERO* tzero = static_cast<AliESDEvent*>(const_cast<AliVEvent*>(event))->GetESDTZERO();
+    if ( tzero )
+    {
+      backgroundFlag = tzero->GetBackgroundFlag();
+      pileupFlag = tzero->GetPileupFlag();
+      satelliteFlag = tzero->GetSatellite();
+      rv = kTRUE;
+    }
+  }
+  else if ( event->IsA() == AliAODEvent::Class() )
+  {
+    AliAODTZERO* tzero = static_cast<const AliAODEvent*>(event)->GetTZEROData();
+    if ( tzero )
+    {
+      backgroundFlag = tzero->GetBackgroundFlag();
+      pileupFlag = tzero->GetPileupFlag();
+      satelliteFlag = tzero->GetSatellite();
+      rv = kTRUE;
+    }
+  }
+  else
+  {
+    AliErrorClass(Form("Unknown class for the event = %s",event->ClassName()));
+  }
+  
+  return rv;
+}
 
 //_______________________________________________________________________
 Bool_t AliAnalysisMuonUtility::SetSparseRange(AliCFGridSparse* gridSparse,
index 7c35271b02c576e030ec1c4639fd41ea786cc096..9f9661fdba3f39aa1a524ca2e1093c6383617e07 100644 (file)
@@ -73,6 +73,8 @@ class AliAnalysisMuonUtility : public TObject {
   static UInt_t GetMCProcess ( const AliVParticle* mcParticle );
   static UInt_t GetStatusCode ( const AliVParticle* mcParticle );
   
+  static Bool_t EAGetTZEROFlags(const AliVEvent* event, Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag);
+
   // A useful constant
   static Double_t MuonMass2();
   
index 622f853fd3c4496a102a6822bac0aa280127e090..ee6bb24f69505c04376c107a91ddf41a2ce5a32a 100644 (file)
@@ -3,6 +3,7 @@
 #include "AliAnalysisManager.h"
 #include "AliAnalysisMuMuBinning.h"
 #include "AliAnalysisMuonUtility.h"
+#include "AliAnalysisUtils.h"
 #include "AliAODEvent.h"
 #include "AliAODMCParticle.h"
 #include "AliAODTrack.h"
@@ -11,7 +12,6 @@
 #include "AliCodeTimer.h"
 #include "AliCounterCollection.h"
 #include "AliESDEvent.h"
-#include "AliESDMuonTrack.h"
 #include "AliESDTZERO.h"
 #include "AliInputEventHandler.h"
 #include "AliLog.h" 
 #include "TMath.h"
 #include "TObjString.h"
 #include "TPaveText.h"
+#include "TProfile.h"
 #include "TRegexp.h"
 #include "TROOT.h"
 #include <algorithm>
 #include <cassert>
-
-//
-// AliAnalysisTaskMuMu : base class for mu pairs analysis 
-//
-// Mainly invariant mass (for J/psi and Upsilon) but also 
-// some single control histograms.
-//
-// This base class contains common things for ESD-based
-// and AOD-based analysis
-//
-// The output contains an AliHistogramCollection and
-// an AliCounterCollection
-//
-// author: L. Aphecetche (Subatech)
-//
+#include "AliAnalysisMuMuBase.h"
+#include "AliInputEventHandler.h"
+#include "AliAnalysisMuMuCutRegistry.h"
+#include "AliAnalysisMuMuCutElement.h"
+#include "AliAnalysisMuMuCutCombination.h"
+#include <set>
+
+/**
+ * \class AliAnalysisTaskMuMu
+ * 
+ * This class steers the work of one or more sub-analysis deriving from AliAnalysisMuMuBase
+ * The output contains an AliHistogramCollection, an AliCounterCollection 
+ * and an AliAnalysisMuMuBinning
+ * This task must be configured a bit before being used. For instance
+ * you can select various event cuts, single muon track cuts and
+ *  muon pairs cut, as well as defining various bins (for minv and mean pt
+ * histograms) in pt,y,phi etc...
+ *
+ * Note that it's also possible to disable some (or all) histograms
+ * (to save speed/memory), using DisableHistograms() method.
+ *
+ * For an example of such configuration, \see AddTaskMuMu.C
+ */
 
 using std::cout;
 using std::endl;
 
 ClassImp(AliAnalysisTaskMuMu)
-ClassImp(AliAnalysisTaskMuMu::PairCut)
-
-namespace
-{
-  Int_t GetNbins(Double_t xmin, Double_t xmax, Double_t xstep)
-  {
-    if ( TMath::AreEqualRel(xstep,0.0,1E-9) ) return 1;
-    
-    return TMath::Nint(TMath::Abs((xmax-xmin)/xstep));
-  }
-  
-  TObjArray* GetMuonTriggerList()
-  {
-    TObjArray* a = new TObjArray;
-    a->SetOwner(kTRUE);
-    
-    a->Add(new TObjString("CMUL"));
-    a->Add(new TObjString("CMLL"));
-    a->Add(new TObjString("C0MUL"));
-    a->Add(new TObjString("CMSL"));
-    a->Add(new TObjString("CMSH"));
-    
-    return a;
-  }
-
-  TObjArray* GetEmcalTriggerList()
-  {
-    TObjArray* a = new TObjArray;
-    a->SetOwner(kTRUE);
-    
-    a->Add(new TObjString("CEMC"));
-    
-    return a;
-  }
-
-  TObjArray* GetMBTriggerList()
-  {
-    TObjArray* a = new TObjArray;
-    a->SetOwner(kTRUE);
-    
-    a->Add(new TObjString("CINT7-S-"));
-    a->Add(new TObjString("CINT7-B-"));
-    a->Add(new TObjString("CINT8-S-"));
-    
-    return a;
-  }
-  
-  TString GetMinvHistoName(const AliAnalysisMuMuBinning::Range& r)
-  {
-    return TString::Format("MinvUS%s",r.AsString().Data());
-  }
-
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::PairCut::Print(Option_t* /*opt*/) const
-{
-  std::cout << Form("PAIR   CUT %20s SINGLE MASK %x PAIR MASK %x",GetName(),MaskForOneOrBothTrack(),MaskForTrackPair())
-  << std::endl;
-}
-
-//_____________________________________________________________________________
-AliAnalysisTaskMuMu::AliAnalysisTaskMuMu() : AliAnalysisTaskSE("AliAnalysisTaskMuMu"),
-fHistogramCollection(0),
-fEventCounters(0),
-fMuonTrackCuts(0x0),
-fPrecomputedTrackMasks(),
-fIsFromESD(kFALSE),
-fShouldSeparatePlusAndMinus(kFALSE),
-fBeamYear("pp"),
-fSingleTrackCutNames(0x0),
-fPairTrackCutNames(0x0),
-fCentralityNames(0x0),
-fEventCutNames(0x0),
-fUseBackgroundTriggers(kFALSE),
-fTriggerInputBitMap(),
-fBinning(0x0),
-fHistogramToDisable(0x0),
-fBinArray(0x0),
-fHasMC(kFALSE),
-fEventCuts(0x0)
-{
-  /// default ctor
-}
-
-//_____________________________________________________________________________
-AliAnalysisTaskMuMu::AliAnalysisTaskMuMu(Bool_t fromESD, const char* beamYear, TArrayF* centralities)
-: AliAnalysisTaskSE(Form("AliAnalysisTaskMuMu-from%s",fromESD ? "ESD":"AOD")),
-fHistogramCollection(0),
-fEventCounters(0),
-fMuonTrackCuts(0x0),
-fPrecomputedTrackMasks(),
-fIsFromESD(fromESD),
-fShouldSeparatePlusAndMinus(kFALSE),
-fBeamYear(beamYear),
-fSingleTrackCutNames(0x0),
-fPairTrackCutNames(0x0),
-fCentralityNames(new TObjArray),
-fEventCutNames(0x0),
-fUseBackgroundTriggers(kFALSE),
-fTriggerInputBitMap(),
-fBinning(0x0),
-fHistogramToDisable(0x0),
-fBinArray(0x0),
-fHasMC(kFALSE),
-fEventCuts(0x0)
-{
-  /// Constructor
-  /// The list of triggers to be considered will be updated on the fly
-  
-  DefineOutput(1,AliMergeableCollection::Class());
-  DefineOutput(2,AliCounterCollection::Class());
-  DefineOutput(3,AliAnalysisMuMuBinning::Class());
-  
-  DefineDefaultBinning();
-
-  DefineCentralityClasses(centralities);
-}
 
 //_____________________________________________________________________________
-AliAnalysisTaskMuMu::AliAnalysisTaskMuMu(Bool_t fromESD, TList* triggerClasses, const char* beamYear, TArrayF* centralities)
-: AliAnalysisTaskSE(Form("AliAnalysisTaskMuMu-from%s",fromESD ? "ESD":"AOD")),
+AliAnalysisTaskMuMu::AliAnalysisTaskMuMu()
+: AliAnalysisTaskSE("AliAnalysisTaskMuMu"),
 fHistogramCollection(0),
 fEventCounters(0),
-fMuonTrackCuts(0x0),
-fPrecomputedTrackMasks(),
-fIsFromESD(fromESD),
-fShouldSeparatePlusAndMinus(kFALSE),
-fBeamYear(beamYear),
-fSingleTrackCutNames(0x0),
-fPairTrackCutNames(0x0),
-fCentralityNames(new TObjArray),
-fEventCutNames(0x0),
-fUseBackgroundTriggers(kFALSE),
-fTriggerInputBitMap(),
 fBinning(0x0),
+fCutRegistry(0x0),
+fBeamYear(""),
 fHistogramToDisable(0x0),
-fBinArray(0x0),
-fHasMC(kFALSE),
-fEventCuts(0x0)
+fSubAnalysisVector(0x0)
 {
   /// Constructor with a predefined list of triggers to consider
+  /// Note that we take ownership of cutRegister
+  ///
+  
+//  fBranchNames = "AOD:header,tracks,vertices,tracklets,AliAODTZERO,AliAODVZERO";
 
   DefineOutput(1,AliMergeableCollection::Class());
   DefineOutput(2,AliCounterCollection::Class());
   DefineOutput(3,AliAnalysisMuMuBinning::Class());
-  
-  TObjString* tname;
-  TIter next(triggerClasses);
-  TString tclasses;
-  
-  while ( ( tname = static_cast<TObjString*>(next()) ) )
-  {
-    if (tclasses.Length()>0)
-    {
-      tclasses += ",";
-    }
-    
-    tclasses += tname->String();    
-  }
-
-  EventCuts()->SetTrigClassPatterns(tclasses);
-  
-  DefineDefaultBinning();
-  
-  DefineCentralityClasses(centralities);
 }
 
 //_____________________________________________________________________________
@@ -243,368 +107,36 @@ AliAnalysisTaskMuMu::~AliAnalysisTaskMuMu()
     delete fBinning;
   }
 
-  delete fMuonTrackCuts;
-
-  delete fSingleTrackCutNames;
-  delete fPairTrackCutNames;
-  delete fCentralityNames;
-  delete fEventCutNames;
   delete fHistogramToDisable;
-  delete fBinArray;
-  delete fEventCuts;
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::AddBin(const char* particle, const char* type,
-                                 Double_t xmin, Double_t xmax,
-                                 Double_t ymin, Double_t ymax,
-                                 const char* flavour)
-{
-  /// Add one bin
-  fBinning->AddBin(particle,type,xmin,xmax,ymin,ymax,flavour);
-
-  // invalidate cached bins, if any
-  if (fBinArray)
-  {
-    delete fBinArray;
-    fBinArray = 0x0;
-  }
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::AddPairCut(const char* cutName, UInt_t maskForOneOrBothTrack, UInt_t maskForTrackPair)
-{
-  /// Add a cut for a pair.
-  /// maskForOneOrBothTrack is the mask of cuts that at least one track must satisfy
-  /// maskForTrackPair is the mask of cuts that *both* tracks must satisfy.
-  /// if maskForTrackPair is 0, then no (extra) condition is applied to the pair
-  
-  if ( !fPairTrackCutNames ) 
-  {
-    fPairTrackCutNames = new TObjArray;
-    fPairTrackCutNames->SetOwner(kTRUE);
-  }
-  fPairTrackCutNames->Add(new AliAnalysisTaskMuMu::PairCut(cutName,maskForOneOrBothTrack,maskForTrackPair));
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::AddSingleCut(const char* name, UInt_t mask)
-{
-  /// Add a cut for single tracks
-  if ( !fSingleTrackCutNames ) 
-  {
-    fSingleTrackCutNames = new TObjArray;
-    fSingleTrackCutNames->SetOwner(kTRUE);
-  }
-  TObjString* oname = new TObjString(Form("s%s",name));
-  oname->SetUniqueID(mask);
-  fSingleTrackCutNames->Add(oname);
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::AddEventCut(const char* name, UInt_t mask)
-{
-  /// Add a cut at event level
-  if ( !fEventCutNames )
-  {
-    fEventCutNames = new TObjArray;
-    fEventCutNames->SetOwner(kTRUE);
-  }
-  TObjString* oname = new TObjString(Form("%s",name));
-  oname->SetUniqueID(mask);
-  fEventCutNames->Add(oname);
-}
-
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::AssertHistogramCollection(const char* physics, const char* triggerClassName)
-{
-  // insure that a given set of histogram is created
-  if (!fHistogramCollection->Histo(Form("/%s/%s/%s/Zvertex",physics,triggerClassName,DefaultCentralityName())))
-  {
-    FillHistogramCollection(physics,triggerClassName);
-  }
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::BeautifyHistos()
-{
-  /// Put the titles, marker sizes, color, etc...
-  
-  TIter next(fHistogramCollection->CreateIterator());
-  TH1* h;
-  
-  while ( ( h = static_cast<TH1*>(next()) ) )
-  {
-    TString name(h->GetName());
-    
-    if ( name.Contains("Plus") ) 
-    {
-      h->SetMarkerStyle(kFullCircle);
-      h->SetMarkerColor(kBlue);
-      h->SetLineColor(kBlue);        
-    }
-    else if ( name.Contains("Minus") )
-    {
-      h->SetMarkerStyle(kOpenCircle);
-      h->SetMarkerColor(kRed);
-      h->SetLineColor(kRed);        
-    }      
-  }
-}
-
-//_____________________________________________________________________________
-const char* 
-AliAnalysisTaskMuMu::CentralityName(Double_t centrality) const
-{
-  /// Get centrality name corresponding to the floating ^point value
-  
-  if ( centrality > 0 && centrality <= 100.0 ) 
-  {
-    return Form("CENT%02d",TMath::Nint(centrality));
-  }
-  else
-  {
-    return DefaultCentralityName();
-  }
-}
-
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::ComputeTrackMask(const AliVParticle& track, Int_t trackIndex)
-{
-  // Compute the track mask
-  UInt_t m(kAll);
   
-  UInt_t selectionMask = MuonTrackCuts()->GetSelectionMask(&track);
+  delete fCutRegistry;
   
-  if ( ( selectionMask & AliMuonTrackCuts::kMuThetaAbs ) == AliMuonTrackCuts::kMuThetaAbs ) m |= kRabs;
-  
-  Double_t angle = AliAnalysisMuonUtility::GetThetaAbsDeg(&track);
-  
-  if ( angle >= 2.0 && angle < 3.0 ) m |= kDeg23;
-  
-  if ( angle >= 3.0 && angle < 10.0 ) m |= kDeg310;
-  
-  if ( selectionMask & AliMuonTrackCuts::kMuEta ) m |= kEta;
-  
-  Double_t pt = track.Pt();
-  
-  if ( pt >  1.0 ) m |= kPt1;
-  if ( pt >  1.2 ) m |= kPt1dot2;
-  if ( pt >  1.5 ) m |= kPt1dot5;
-  if ( pt >  2.0 ) m |= kPt2;
-  
-  if ( track.P() > 10.0 ) m |= kP10;
-  
-  if ( pt < 4.0 ) m |= kBelowPt;
-  
-  if ( ( selectionMask & AliMuonTrackCuts::kMuMatchApt ) == AliMuonTrackCuts::kMuMatchApt ) m |= kMatched;
-  
-  if ( ( selectionMask & AliMuonTrackCuts::kMuMatchLpt ) == AliMuonTrackCuts::kMuMatchLpt ) m |= kMatchedLow;
-  
-  if ( ( selectionMask & AliMuonTrackCuts::kMuMatchHpt ) == AliMuonTrackCuts::kMuMatchHpt) m |= kMatchedHigh;
-  
-  if ( ( selectionMask & AliMuonTrackCuts::kMuTrackChiSquare ) ==  AliMuonTrackCuts::kMuTrackChiSquare ) m |= kChi2;
-  
-  if ( ( selectionMask & AliMuonTrackCuts::kMuPdca ) == AliMuonTrackCuts::kMuPdca ) m |= kDCA;
-  
-  if ( AliAnalysisMuonUtility::GetChi2MatchTrigger(&track) < 16.0 ) m |= kChi2MatchTrigger;
-  
-  fPrecomputedTrackMasks.SetAt(m,trackIndex);
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::CreateMesh(const char* particle, const char* type1, const char* type2, const char* flavour, Bool_t remove12)
-{
-  /// Create a 2d binning from 2 1d binning.
-  /// WARNING : not fully tested yet
-  
-  if (!fBinning)
-  {
-    AliError("Cannot create a mesh as I have no bin at all !");
-    return;
-  }
-  fBinning->CreateMesh(particle,type1,type2,flavour,remove12);
+  delete fSubAnalysisVector;
 }
 
 //_____________________________________________________________________________
-void
-AliAnalysisTaskMuMu::CreateMinvHistograms(const char* physics,
-                                          const char* triggerClassName)
+void AliAnalysisTaskMuMu::AdoptSubAnalysis(AliAnalysisMuMuBase* analysis)
 {
-  /// Create invariant mass histograms
-  
-  Double_t minvMin = 0;
-  Double_t minvMax = 16;
-  Int_t nMinvBins = GetNbins(minvMin,minvMax,0.025);
-
-  Int_t nMCMinvBins = GetNbins(minvMin,minvMax,0.1);
-
-  TObjArray* bins = fBinning->CreateBinObjArray("psi","y vs pt,integrated,pt,y,phi","");
-  
-  CreatePairHisto(physics,triggerClassName,"Pt","#mu+#mu- Pt distribution",
-                  200,0,20);
-
-//  CreatePairHisto(physics,triggerClassName,"BinFlowPt","#mu+#mu- BinFlowPt distribution",
-//                  200,0,20);
-
-  CreatePairHisto(physics,triggerClassName,"PtRecVsSim","#mu+#mu- Pt distribution rec vs sim",
-                  200,0,20,200,0,20);
-
-  TIter next(bins);
-  AliAnalysisMuMuBinning::Range* r;
-  while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) )
-  {
-    TString hname(GetMinvHistoName(*r));    
-    
-    if ( IsHistogramDisabled(hname.Data()) ) continue;
-    
-    AliDebug(1,Form("histoname = %s",hname.Data()));
-    
-    CreatePairHisto(physics,triggerClassName,hname.Data(),
-                    Form("#mu+#mu- inv. mass %s",r->AsString().Data()),
-                    nMinvBins,minvMin,minvMax);
-
-    TH1* h = fHistogramCollection->Histo("/INPUT/ALL",hname.Data());
-    if (!h)
-    {
-      h = new TH1F(hname.Data(),Form("MC #mu+#mu- inv. mass %s",r->AsString().Data()),
-                   nMCMinvBins,minvMin,minvMax);
-
-      fHistogramCollection->Adopt("/INPUT/ALL",h);
-
-      fHistogramCollection->Adopt("/INPUT/INYRANGE",static_cast<TH1*>(h->Clone()));
-    }
-  }
-  
-  
-  delete bins;
-}
-
-//_____________________________________________________________________________
-void 
-AliAnalysisTaskMuMu::CreateSingleHisto(const char* physics,
-                                       const char* triggerClassName,
-                                       const char* hname, const char* htitle,
-                                       Int_t nbinsx, Double_t xmin, Double_t xmax,
-                                       Int_t nbinsy, Double_t ymin, Double_t ymax,
-                                       Bool_t separatePlusAndMinus) const
-{  
-  /// Append histograms for single track to our histogram collection
-  
-  if ( IsHistogramDisabled(hname) ) return;
-  
-  if ( separatePlusAndMinus ) 
+  if (!fSubAnalysisVector)
   {
-    const char* suffix[] = { "Plus", "Minus" };
-    const char* symbol[] = { "+", "-" };
-
-    for ( Int_t i = 0; i < 2; ++i )
-    {
-      TString shtitle(htitle);
-      TString shname(hname);
-      
-      shtitle.ReplaceAll("#mu",Form("#mu^{%s}",symbol[i]));
-      
-      shname += suffix[i];
-      
-      CreateHisto(fSingleTrackCutNames,physics,triggerClassName,shname.Data(),shtitle.Data(),
-                  nbinsx,xmin,xmax,nbinsy,ymin,ymax);
-    }
+    fSubAnalysisVector = new TObjArray;
+    fSubAnalysisVector->SetOwner(kTRUE);
   }
-  else 
+  if ( !fSubAnalysisVector->FindObject(analysis) )
   {
-    CreateHisto(fSingleTrackCutNames,physics,triggerClassName,hname,htitle,
-                nbinsx,xmin,xmax,nbinsy,ymin,ymax);
+    fSubAnalysisVector->Add(analysis);
   }
 }
 
 //_____________________________________________________________________________
-void 
-AliAnalysisTaskMuMu::CreatePairHisto(const char* physics,
-                                     const char* triggerClassName,
-                                     const char* hname, const char* htitle,
-                                     Int_t nbinsx, Double_t xmin, Double_t xmax,
-                                     Int_t nbinsy, Double_t ymin, Double_t ymax) const
-{
-  /// Append histograms for track pairs to our histogram collection
-
-  if ( IsHistogramDisabled(hname) ) return;
-
-  CreateHisto(fPairTrackCutNames,physics,triggerClassName,hname,htitle,
-              nbinsx,xmin,xmax,nbinsy,ymin,ymax);
-}
-
-//_____________________________________________________________________________
-void 
-AliAnalysisTaskMuMu::CreateEventHisto(const char* physics,
-                                      const char* triggerClassName,
-                                      const char* hname, const char* htitle,
-                                      Int_t nbinsx, Double_t xmin, Double_t xmax,
-                                      Int_t nbinsy, Double_t ymin, Double_t ymax) const
+AliAnalysisMuMuCutRegistry* AliAnalysisTaskMuMu::CutRegistry() const
 {
-  /// Append histograms at the event level
-  
-  if ( IsHistogramDisabled(hname) ) return;
-
-  TIter next(fCentralityNames);
-  TObjString* cent;
-  
-  while ( ( cent = static_cast<TObjString*>(next()) ) )
+    /// Return (and create if not yet there) our cut registry
+  if (!fCutRegistry)
   {
-    TH1* h(0x0);
-    
-    if ( nbinsy > 0 )
-    {  
-      h = new TH2F(hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
-    }
-    else
-    {
-      h = new TH1F(hname,htitle,nbinsx,xmin,xmax);
-    }
-    
-    fHistogramCollection->Adopt(Form("/%s/%s/%s/",physics,triggerClassName,cent->String().Data()),h);
+    fCutRegistry = new AliAnalysisMuMuCutRegistry;
   }
-}
-
-//_____________________________________________________________________________
-void 
-AliAnalysisTaskMuMu::CreateHisto(TObjArray* array,
-                                 const char* physics,
-                                 const char* triggerClassName,
-                                 const char* hname, const char* htitle,
-                                 Int_t nbinsx, Double_t xmin, Double_t xmax,
-                                 Int_t nbinsy, Double_t ymin, Double_t ymax) const
-{
-  /// Create a bunch of histograms for all centralities
-  /// FIXME: have a way to specify the histo precision (i.e. F vs I vs S ...)
-  
-  if ( IsHistogramDisabled(hname) ) return;
-
-  TIter next(array);
-  TObjString* tcn;
-  while ( ( tcn = static_cast<TObjString*>(next()) ) )
-  {
-    TIter nextCent(fCentralityNames);
-    TObjString* cent;
-    
-    while ( ( cent = static_cast<TObjString*>(nextCent()) ) )
-    {
-      TH1* h(0x0);
-    
-      if ( nbinsy > 0 )
-      {  
-        h = new TH2F(hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
-      }
-      else
-      {
-        h = new TH1F(hname,htitle,nbinsx,xmin,xmax);
-      }
-    
-      fHistogramCollection->Adopt(Form("/%s/%s/%s/%s",physics,triggerClassName,cent->String().Data(),tcn->String().Data()),h);
-    }
-  }      
+  return fCutRegistry;
 }
 
 //_____________________________________________________________________________
@@ -616,1302 +148,216 @@ AliAnalysisTaskMuMu::DefaultCentralityName() const
   else return "PP";
 }
 
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::DefineCentralityClasses(TArrayF* centralities)
-{
-  /// Define the default centrality classes that will be used.
-  
-  if ( !fBeamYear.Contains("pp") ) 
-  {
-    if ( !centralities ) 
-    {
-//      // default values
-//      fCentralityLimits.push_back(10.0);
-//      fCentralityLimits.push_back(30.0);
-//      fCentralityLimits.push_back(50.0);
-//      fCentralityLimits.push_back(80.0);
-    }
-    else
-    {
-      for ( Int_t i = 0; i < centralities->GetSize(); ++i ) 
-      {
-//        fCentralityLimits.push_back(centralities->At(i));
-      }
-    }
-  }
-  
-//  for ( std::vector<double>::size_type i = 0; i < fCentralityLimits.size(); ++i )
-//  {
-//    Double_t limit = fCentralityLimits[i];
-//    fCentralityNames->Add(new TObjString(CentralityName(limit)));
-//  }
-  
-  fCentralityNames->Add(new TObjString(DefaultCentralityName()));
-  fCentralityNames->SetOwner(kTRUE);
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::DefineDefaultBinning()
-{
-  fBinning = new AliAnalysisMuMuBinning("BIN");
-  fBinning->AddBin("psi","integrated");
-}
-
 //_____________________________________________________________________________
 void AliAnalysisTaskMuMu::DisableHistograms(const char* pattern)
 {
   /// Disable the histogramming of all the histograms matching the pattern
   
-  TString spattern(pattern);
-  if (spattern=="*")
-  {
-    delete fHistogramToDisable;
-    fHistogramToDisable = 0x0;
-  }
-  
-  if (!fHistogramToDisable)
-  {
-    fHistogramToDisable = new TList;
-    fHistogramToDisable->SetOwner(kTRUE);
-  }
-    
-  fHistogramToDisable->Add(new TObjString(spattern));
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::EAComputeTrackMasks()
-{
-  // compute the track masks for the event
-  
-  fPrecomputedTrackMasks.Reset();
-  Int_t n = AliAnalysisMuonUtility::GetNTracks(Event()); //EAGetNumberOfMuonTracks();
-  fPrecomputedTrackMasks.Set(n);
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* a;
   
-  for ( Int_t i = 0; i < n; ++i )
+  while ( ( a = static_cast<AliAnalysisMuMuBase*>(next()) ) )
   {
-    AliVParticle* track = AliAnalysisMuonUtility::GetTrack(i,Event());
-    ComputeTrackMask(*track,i);
+    a->DisableHistograms(pattern);
   }
 }
 
 //_____________________________________________________________________________
-Int_t AliAnalysisTaskMuMu::EAGetNumberOfMuonTracks() const
+AliVEvent*
+AliAnalysisTaskMuMu::Event() const
 {
-  // Get the number of muon tracks *that are not ghosts*
-  
-  Int_t ntracks = AliAnalysisMuonUtility::GetNTracks(Event());
-  
-  for ( Int_t i = 0; i < ntracks; ++i )
-  {
-    AliVParticle* track = AliAnalysisMuonUtility::GetTrack(i,Event());
-    if (AliAnalysisMuonUtility::IsMuonGhost(track)) --ntracks;
-  }
-  
-  return ntracks;
+  // some const-dirty-dancing
+  return const_cast<AliAnalysisTaskMuMu*>(this)->InputEvent();
 }
 
 //_____________________________________________________________________________
-Int_t AliAnalysisTaskMuMu::EAGetNumberOfSelectMuonTracks() const
-{
-  // Get the number of "very good" muon tracks :
-  // Rabs + DCA + pT > 1.5 Gev/C
-  // must be called after EAComputeTrackMasks
-  
-  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
-
-  UInt_t check = kAll | kMatched | kRabs | kDCA | kEta | kPt1dot5;
-  
-  Int_t nGood(0);
-  
-  for ( Int_t i = 0; i < nTracks; ++i )
-  {
-    UInt_t m = GetTrackMask(i);
-    if ( ( m & check ) == check )
-    {
-      ++nGood;
-    }
-  }  
-  return nGood;
-}
-
-//_____________________________________________________________________________
-Double_t AliAnalysisTaskMuMu::EAGetTrackDCA(const AliVParticle& track) const
-{
-  // Get track DCA
-  
-  Double_t xdca = AliAnalysisMuonUtility::GetXatDCA(&track);
-  Double_t ydca = AliAnalysisMuonUtility::GetYatDCA(&track);
-  
-  return TMath::Sqrt(xdca*xdca+ydca*ydca);
-}
-
-//_____________________________________________________________________________
-Bool_t AliAnalysisTaskMuMu::EAGetTZEROFlags(Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag) const
-{
-  // get the TZERO decisions
-  // return false if there's no tzero information in this event
-  
-  Bool_t rv(kFALSE);
-  
-  if ( Event()->IsA() == AliESDEvent::Class() )
-  {
-    const AliESDTZERO* tzero = static_cast<AliESDEvent*>(const_cast<AliVEvent*>(Event()))->GetESDTZERO();
-    if ( tzero )
-    {
-      backgroundFlag = tzero->GetBackgroundFlag();
-      pileupFlag = tzero->GetPileupFlag();
-      satelliteFlag = tzero->GetSatellite();
-      rv = kTRUE;
-    }    
-  }
-  else if ( Event()->IsA() == AliAODEvent::Class() )
-  {
-    AliAODTZERO* tzero = static_cast<const AliAODEvent*>(Event())->GetTZEROData();
-    if ( tzero )
-    {
-      backgroundFlag = tzero->GetBackgroundFlag();
-      pileupFlag = tzero->GetPileupFlag();
-      satelliteFlag = tzero->GetSatellite();
-      rv = kTRUE;
-    }
-  }
-  else
-  {
-    AliError(Form("Unknown class for the event = %s",Event()->ClassName()));
-  }  
-  
-  return rv;
-
-}
-
-//_____________________________________________________________________________
-AliVEvent*
-AliAnalysisTaskMuMu::Event() const
-{
-  // some const-dirty-dancing
-  return const_cast<AliAnalysisTaskMuMu*>(this)->InputEvent();
-}
-
-//_____________________________________________________________________________
-AliMuonEventCuts*
-AliAnalysisTaskMuMu::EventCuts() const
-{
-  /// Return the single instance of AliMuonEventCuts object we're using
-  
-  if (!fEventCuts)
-  {
-    fEventCuts = new AliMuonEventCuts("EventCut","");
-  }
-  return fEventCuts;
-}
-
-//_____________________________________________________________________________
-Bool_t
-AliAnalysisTaskMuMu::AtLeastOneMBTrigger(const TString& firedTriggerClasses) const
-{
-  // whether or not we have a least one MB trigger in the fired trigger classes
-  static TObjArray* triggerList = GetMBTriggerList();
-  TIter next(triggerList);
-  TObjString* str;
-  
-  while ( ( str = static_cast<TObjString*>(next())))
-  {
-    if ( firedTriggerClasses.Contains(str->String().Data())) return kTRUE;
-  }
-  
-  return kFALSE;
-}
-
-//_____________________________________________________________________________
-Bool_t
-AliAnalysisTaskMuMu::AtLeastOneMuonTrigger(const TString& firedTriggerClasses) const
-{
-  // whether or not we have a least one muon trigger in the fired trigger classes
-  static TObjArray* triggerList = GetMuonTriggerList();
-  TIter next(triggerList);
-  TObjString* str;
-  
-  while ( ( str = static_cast<TObjString*>(next())))
-  {
-    if ( firedTriggerClasses.Contains(str->String().Data())) return kTRUE;
-  }
-  
-  return kFALSE;
-}
-
-//_____________________________________________________________________________
-Bool_t
-AliAnalysisTaskMuMu::AtLeastOneEmcalTrigger(const TString& firedTriggerClasses) const
-{
-  // whether or not we have a least one emcal trigger in the fired trigger classes
-  static TObjArray* triggerList = GetEmcalTriggerList();
-  TIter next(triggerList);
-  TObjString* str;
-  
-  while ( ( str = static_cast<TObjString*>(next())))
-  {
-    if ( firedTriggerClasses.Contains(str->String().Data())) return kTRUE;
-  }
-  
-  return kFALSE;
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FillMC()
-{
-  // Fill the input MC histograms
-  
-  if (!HasMC()) return;
-
-  // Specific things for MC
-  if (!Histo("INPUT","ALL","Pt"))
-  {
-    fHistogramCollection->Adopt("/INPUT/ALL",new TH1F("Pt","Pt",200,0,20));
-    fHistogramCollection->Adopt("/INPUT/INYRANGE",new TH1F("Pt","Pt",200,0,20));
-    
-    Double_t rapidityMin = -5;
-    Double_t rapidityMax = -2;
-    Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
-    
-    fHistogramCollection->Adopt("/INPUT/ALL",new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
-    fHistogramCollection->Adopt("/INPUT/INYRANGE",new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
-    
-    Double_t etaMin = -5;
-    Double_t etaMax = -2;
-    Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
-    
-    fHistogramCollection->Adopt("/INPUT/ALL",new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
-    fHistogramCollection->Adopt("/INPUT/INYRANGE",new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
-  }
-
-  Int_t nMCTracks = MCEvent()->GetNumberOfTracks();
-
-  if (!fBinArray)
-  {
-    fBinArray = fBinning->CreateBinObjArray("psi","y vs pt,integrated,pt,y","");
-  }
-
-  TIter nextBin(fBinArray);
-  AliAnalysisMuMuBinning::Range* r;
-  
-  for ( Int_t i = 0; i < nMCTracks; ++i )
-  {
-    AliVParticle* part = MCEvent()->GetTrack(i);
-    
-//    std::cout << "part " << i << " isprimary=" << AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) << " motherindex=" << AliAnalysisMuonUtility::GetMotherIndex(part) << std::endl;
-//    
-//    part->Print();
-    
-    if  (AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) &&
-         AliAnalysisMuonUtility::GetMotherIndex(part)==-1)
-    {
-      
-      Histo("INPUT","ALL","Pt")->Fill(part->Pt());
-      Histo("INPUT","ALL","Y")->Fill(part->Y());
-      Histo("INPUT","ALL","Eta")->Fill(part->Eta());
-      
-      if ( part->Y() < -2.5 && part->Y() > -4.0 )
-      {
-        Histo("INPUT","INYRANGE","Pt")->Fill(part->Pt());
-        Histo("INPUT","INYRANGE","Y")->Fill(part->Y());
-        Histo("INPUT","INYRANGE","Eta")->Fill(part->Eta());
-      }
-      
-      nextBin.Reset();
-      
-      while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
-      {
-        Bool_t ok(kFALSE);
-        
-        if ( r->IsNullObject() )
-        {
-          ok = kTRUE;
-        }
-        else if ( r->Is2D() )
-        {
-          if ( r->AsString().BeginsWith("PTVSY") )
-          {
-            ok = r->IsInRange(part->Y(),part->Pt());
-          }
-          else if ( r->AsString().BeginsWith("YVSPT") )
-          {
-            ok = r->IsInRange(part->Pt(),part->Y());
-          }
-          else
-          {
-            AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
-          }
-        }
-        else
-        {
-          if ( r->Type() == "PT" )
-          {
-            ok = r->IsInRange(part->Pt());
-          }
-          else if ( r->Type() == "Y" )
-          {
-            ok = r->IsInRange(part->Y());
-          }
-          else if ( r->Type() == "PHI" )
-          {
-            ok = r->IsInRange(part->Phi());
-          }
-        }
-        
-        if ( ok )
-        {
-          TString hname = GetMinvHistoName(*r);
-          
-          if (!IsHistogramDisabled(hname.Data()))
-          {
-            TH1* h = Histo("INPUT","ALL",hname.Data());
-            
-            if (!h)
-            {
-              AliError(Form("Could not get ALL %s",hname.Data()));
-              continue;
-            }
-            
-            h->Fill(part->M());
-            
-            if ( part->Y() < -2.5 && part->Y() > -4.0 )
-            {
-              h = Histo("INPUT","INYRANGE",hname.Data());
-              if (!h)
-              {
-                AliError(Form("Could not get INYRANGE %s",hname.Data()));
-                continue;
-              }
-              h->Fill(part->M());
-            }
-            
-          }
-
-        }
-      }
-    }
-  }
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::Fill(const char* eventtype,
-                           TObjString* tname,
-                           const char* centrality,
-                           float fcent)
-{
-  // Fill one set of histograms
-  
-  TString seventtype(eventtype);
-  seventtype.ToLower();
-  
-  fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", seventtype.Data(), tname->GetName(), fCurrentRunNumber));
-
-  if ( !IsHistogrammingDisabled() )
-  {
-    AssertHistogramCollection(eventtype,tname->String().Data());
-    FillHistos(eventtype,tname->String().Data(),centrality);
-    if (!IsHistogramDisabled("Centrality"))
-    {
-      fHistogramCollection->Histo(Form("/%s/%s/Centrality",eventtype,tname->String().Data()))->Fill(fcent);
-    }
-  }
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FillEventHistos(const char* physics, const char* triggerClassName,
-                                          const char* centrality)
-{
-  // Fill event-wise histograms
-  
-//  AliCodeTimerAuto("",0);
-  
-  if (!IsHistogramDisabled("BCX"))
-  {
-    Histo(physics,triggerClassName,centrality,"BCX")->Fill(1.0*Event()->GetBunchCrossNumber());
-  }
-  
-  if (!IsHistogramDisabled("Nevents"))
-  {
-    Histo(physics,triggerClassName,centrality,"Nevents")->Fill(1.0);
-  }
-  
-  const AliVVertex* vertex = Event()->GetPrimaryVertex();
-  
-  if ( vertex )
-  {
-    if (!IsHistogramDisabled("Xvertex"))
-    {
-      Histo(physics,triggerClassName,centrality,"Xvertex")->Fill(vertex->GetX());
-    }
-    if (!IsHistogramDisabled("Yvertex"))
-    {
-      Histo(physics,triggerClassName,centrality,"Yvertex")->Fill(vertex->GetY());
-    }
-    if (!IsHistogramDisabled("Zvertex"))
-    {
-      Histo(physics,triggerClassName,centrality,"Zvertex")->Fill(vertex->GetZ());
-    }
-  }
-  
-  if ( !fIsFromESD )
-  {
-    const AliAODTZERO* tzero = static_cast<const AliAODEvent*>(Event())->GetTZEROData();
-    
-    if (tzero && !IsHistogramDisabled("T0Zvertex"))
-    {
-      Histo(physics,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0VertexRaw());
-    }
-  }
-  else
-  {
-    const AliESDTZERO* tzero = static_cast<const AliESDEvent*>(Event())->GetESDTZERO();
-    
-    if (tzero && !IsHistogramDisabled("T0Zvertex"))
-    {
-      Histo(physics,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0zVertex());
-    }
-  }
-  
-  AliVVZERO* vzero = Event()->GetVZEROData();
-  
-  if (vzero)
-  {
-    Float_t v0a = vzero->GetV0ATime();
-    Float_t v0c = vzero->GetV0CTime();
-    
-    Float_t x = v0a-v0c;
-    Float_t y = v0a+v0c;
-    
-    if (!IsHistogramDisabled("V02D"))
-    {
-      Histo(physics,triggerClassName,centrality,"V02D")->Fill(x,y);
-    }
-    
-    Bool_t background,pileup,satellite;
-    
-    Bool_t tzero = EAGetTZEROFlags(background,pileup,satellite);
-    
-    if (tzero)
-    {
-      if ( background )
-      {
-        if (!IsHistogramDisabled("V02DwT0BG"))
-        {
-          Histo(physics,triggerClassName,centrality,"V02DwT0BG")->Fill(x,y);
-        }
-      }
-      
-      if ( pileup )
-      {
-        if (!IsHistogramDisabled("V02DwT0PU"))
-        {
-          Histo(physics,triggerClassName,centrality,"V02DwT0PU")->Fill(x,y);
-        }
-      }
-      
-      if ( satellite )
-      {
-        if (!IsHistogramDisabled("V02DwT0SAT"))
-        {
-          Histo(physics,triggerClassName,centrality,"V02DwT0SAT")->Fill(x,y);
-        }
-      }
-      
-      if ( !background && !pileup && !satellite )
-      {
-        if (!IsHistogramDisabled("V02DwT0BB"))
-        {
-          Histo(physics,triggerClassName,centrality,"V02DwT0BB")->Fill(x,y);
-        }
-      }
-    }
-  }
-  
-  /* FIXME : how to properly get multiplicity from AOD and ESD consistently ?
-   is is doable at all ?
-   Int_t ntracklets(0);
-   AliAODTracklets* tracklets = aod.GetTracklets();
-   if ( tracklets )
-   {
-   ntracklets = tracklets->GetNumberOfTracklets();
-   }
-   Histo(physics,triggerClassName,centrality,"Tracklets")->Fill(ntracklets);
-   */
-
-}
-
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FillHistogramCollection(const char* physics, const char* triggerClassName)
-{
-  /// Actually create the histograms for phyics/triggerClassName
-  
-  AliDebug(1,Form("(%s,%s)",physics,triggerClassName));
-  
-  Double_t ptMin = 0;
-  Double_t ptMax = 12*3;
-  Int_t nbinsPt = GetNbins(ptMin,ptMax,0.5);
-  Double_t pMin = 0;
-  Double_t pMax = 100*3;
-  Int_t nbinsP = GetNbins(pMin,pMax,2.0);
-  Double_t etaMin = -5;
-  Double_t etaMax = -2;
-  Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
-  
-  Double_t rapidityMin = -5;
-  Double_t rapidityMax = -2;
-  Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
-  
-  Double_t phiMin = -TMath::Pi();
-  Double_t phiMax = TMath::Pi();
-  Int_t nbinsPhi = GetNbins(phiMin,phiMax,0.05);
-  
-  CreateSingleHisto(physics,triggerClassName,"Chi2MatchTrigger","Chi2 Match Trigger",72,0,72);
-
-  CreateSingleHisto(physics,triggerClassName,"EtaRapidityMu", "Eta distribution vs Rapidity for #mu", nbinsRapidity,rapidityMin,rapidityMax,nbinsEta,etaMin,etaMax, fShouldSeparatePlusAndMinus);
-
-  CreateSingleHisto(physics,triggerClassName,"PtEtaMu", "P_{T} distribution vs Eta for #mu", nbinsEta,etaMin,etaMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
-
-  CreateSingleHisto(physics,triggerClassName,"PtRapidityMu", "P_{T} distribution vs Rapidity for #mu", nbinsRapidity,rapidityMin,rapidityMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
-
-  CreateSingleHisto(physics,triggerClassName,"PtPhiMu", "P_{T} distribution vs phi for #mu", nbinsPhi,phiMin,phiMax, nbinsPt,ptMin,ptMax,fShouldSeparatePlusAndMinus);
-  
-
-  CreateSingleHisto(physics,triggerClassName,"PEtaMu", "P distribution for #mu",nbinsEta,etaMin,etaMax,nbinsP,pMin,pMax,fShouldSeparatePlusAndMinus);
-
-  Double_t chi2min = 0;
-  Double_t chi2max = 20;
-  Int_t nbinchi2 = GetNbins(chi2min,chi2max,0.05);
-  
-  CreateSingleHisto(physics, triggerClassName, "Chi2Mu", "chisquare per NDF #mu", nbinchi2, chi2min, chi2max,fShouldSeparatePlusAndMinus);
-  
-  CreateMinvHistograms(physics,triggerClassName);
-  
-  CreatePairHisto(physics,triggerClassName,"Chi12","Chi2MatchTrigger of muon 1 vs muon 2",72,0,72,72,0,72);
-  CreatePairHisto(physics,triggerClassName,"Rabs12","Rabs of muon 1 vs muon ",100,0,100,100,0,100);
-
-  Double_t xmin = -40;
-  Double_t xmax = +40;
-  Int_t nbins = GetNbins(xmin,xmax,0.5);
-  
-  CreateEventHisto(physics,triggerClassName,"Zvertex","z vertex",nbins,xmin,xmax);  
-
-  CreateEventHisto(physics,triggerClassName,"T0Zvertex","T0 zvertex",nbins,xmin,xmax);
-
-  xmin = -5;
-  xmax = 5;
-  nbins = GetNbins(xmin,xmax,0.01);
-
-  CreateEventHisto(physics,triggerClassName,"Xvertex","x vertex",nbins,xmin,xmax);  
-  CreateEventHisto(physics,triggerClassName,"Yvertex","y vertex",nbins,xmin,xmax);  
-  
-//  CreateEventHisto(physics,triggerClassName,"YXvertex","y vs x vertex",nbins,xmin,xmax,nbins,xmin,xmax);  
-  
-//  if (!fIsFromESD)
-//  {
-//    
-//    CreateEventHisto(physics,triggerClassName,"PileUpZvertex","pileup z vertex",nbins,xmin,xmax);  
-//    
-//    CreateEventHisto(physics,triggerClassName,"PileUpXvertex","pileup x vertex",nbins,xmin,xmax);  
-//    CreateEventHisto(physics,triggerClassName,"PileUpYvertex","pileup y vertex",nbins,xmin,xmax);  
-//    
-//    CreateEventHisto(physics,triggerClassName,"PileUpYXvertex","pileup y vs x vertex",nbins,xmin,xmax,
-//                     nbins,xmin,xmax);  
-//    
-//  }
-
-  CreateEventHisto(physics,triggerClassName,"Nevents","number of events",2,-0.5,1.5);  
-
-  xmin = 0;
-  xmax = 3564;
-  nbins = GetNbins(xmin,xmax,1.0);
-  
-  CreateEventHisto(physics,triggerClassName,"BCX","bunch-crossing ids",nbins,xmin-0.5,xmax-0.5);
-
-  CreateEventHisto(physics,triggerClassName,"BCXD","bunch-crossing distances",nbins,xmin-0.5,xmax-0.5);
-
-  xmin = -200;
-  xmax = +200;
-  nbins = GetNbins(xmin,xmax,1.0);
-  
-  xmin = 0;
-  xmax = 150;
-  nbins = GetNbins(xmin,xmax,2.0);
-  
-  CreateSingleHisto(physics,triggerClassName,"dcaP23Mu","#mu DCA vs P for 2-3 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);  
-
-  CreateSingleHisto(physics,triggerClassName,"dcaP310Mu","#mu DCA vs P for 3-10 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);  
-
-  CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut23Mu","#mu DCA vs P for 2-3 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);  
-
-  CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut310Mu","#mu DCA vs P for 3-10 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax,fShouldSeparatePlusAndMinus);  
-  
-  xmin = -30;
-  xmax = +30;
-  nbins = GetNbins(xmin,xmax,0.1);
-  
-  CreateEventHisto(physics,triggerClassName,"V02D","V0C+V0A versus V0A-V0C;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-
-  CreateEventHisto(physics,triggerClassName,"V02DwT0BB","V0C+V0A versus V0A-V0C with T0 BB;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-  
-  CreateEventHisto(physics,triggerClassName,"V02DwT0BG","V0C+V0A versus V0A-V0C with T0 background flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-
-  CreateEventHisto(physics,triggerClassName,"V02DwT0PU","V0C+V0A versus V0A-V0C with T0 pile up flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-
-  CreateEventHisto(physics,triggerClassName,"V02DwT0SAT","V0C+V0A versus V0A-V0C with T0 satellite flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-
-  /*
-  CreateEventHisto(physics,triggerClassName,"T02D","(T0C+T0A)/2 versus (T0A-T0C)/2;Time (T0A-T0C)/2 (ns);Time (T0A+T0C)/2 (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
-   CreateEventHisto(physics,triggerClassName,"T0Flags","T0 flags",3,0,3);
-   */
-
-  
-  if ( !IsHistogramDisabled("Centrality") )
-  {
-    TH1* h = new TH1F("Centrality","Centrality",12,-10,110);
-
-    fHistogramCollection->Adopt(Form("/%s/%s",physics,triggerClassName),h);
-  }
-  
-  xmin = 0;
-  xmax = 5000;
-  nbins = GetNbins(xmin,xmax,10);
-  
-  CreateEventHisto(physics,triggerClassName,"Tracklets","Number of tracklets",nbins,xmin,xmax);
-  
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FillHistosForTrack(const char* physics,
-                                             const char* triggerClassName, 
-                                             const char* centrality,
-                                             const AliVParticle& track,
-                                             Int_t trackIndex)
-{
-  /// Fill histograms for one track
-  
-//  AliCodeTimerAuto("",0);
-  
-  TLorentzVector p(track.Px(),track.Py(),track.Pz(),
-                   TMath::Sqrt(MuonMass2()+track.P()*track.P()));
-  
-  
-  TString charge("");
-  
-  if ( ShouldSeparatePlusAndMinus() ) 
-  { 
-    if ( track.Charge() < 0 ) 
-    {
-      charge = "Minus";
-    }
-    else
-    {
-      charge = "Plus";
-    }
-  }
-  
-  UInt_t mask = GetTrackMask(trackIndex);
-  
-  Double_t dca = EAGetTrackDCA(track);
-  
-  Double_t theta = AliAnalysisMuonUtility::GetThetaAbsDeg(&track);
-  
-  TIter next(fSingleTrackCutNames);
-  TObjString* str;
-  
-  while ( ( str = static_cast<TObjString*>(next()) ) )
-  {
-    Bool_t test = ( ( str->GetUniqueID() & mask ) == str->GetUniqueID() );
-    
-    if ( test ) 
-    {
-      if (!IsHistogramDisabled("Chi2MatchTrigger"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),"Chi2MatchTrigger")->Fill(AliAnalysisMuonUtility::GetChi2MatchTrigger(&track));
-      }
-      
-      if (!IsHistogramDisabled("EtaRapidityMu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("EtaRapidityMu%s",charge.Data()))->Fill(p.Rapidity(),p.Eta());
-      }
-      
-      if (!IsHistogramDisabled("PtEtaMu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("PtEtaMu%s",charge.Data()))->Fill(p.Eta(),p.Pt());
-      }
-      
-      if (!IsHistogramDisabled("PtRapidityMu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("PtRapidityMu%s",charge.Data()))->Fill(p.Rapidity(),p.Pt());
-      }
-      
-      if (!IsHistogramDisabled("PEtaMu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("PEtaMu%s",charge.Data()))->Fill(p.Eta(),p.P());
-      }
-      
-      if (!IsHistogramDisabled("PtPhiMu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("PtPhiMu%s",charge.Data()))->Fill(p.Phi(),p.Pt());
-      }
-      
-      if (!IsHistogramDisabled("Chi2Mu*"))
-      {
-        Histo(physics,triggerClassName,centrality,str->String().Data(),Form("Chi2Mu%s",charge.Data()))->Fill(AliAnalysisMuonUtility::GetChi2perNDFtracker(&track));
-      }
-      
-      if ( theta >= 2.0 && theta < 3.0 )
-      {
-        
-        if (!IsHistogramDisabled("dcaP23Mu*"))
-        {
-          Histo(physics,triggerClassName,centrality,str->String().Data(),Form("dcaP23Mu%s",charge.Data()))->Fill(p.P(),dca);
-        }
-
-        if ( p.Pt() > 2 )
-        {
-          if (!IsHistogramDisabled("dcaPwPtCut23Mu*"))
-          {
-            Histo(physics,triggerClassName,centrality,str->String().Data(),Form("dcaPwPtCut23Mu%s",charge.Data()))->Fill(p.P(),dca);
-          }
-        }
-      }
-      else if ( theta >= 3.0 && theta < 10.0 )
-      {
-        if (!IsHistogramDisabled("dcaP310Mu*"))
-        {
-          Histo(physics,triggerClassName,centrality,str->String().Data(),Form("dcaP310Mu%s",charge.Data()))->Fill(p.P(),dca);
-        }
-        if ( p.Pt() > 2 )
-        {
-          if (!IsHistogramDisabled("dcaPwPtCut310Mu*"))
-          {
-            Histo(physics,triggerClassName,centrality,str->String().Data(),Form("dcaPwPtCut310Mu%s",charge.Data()))->Fill(p.P(),dca);
-          }
-        }
-      }
-    }
-  }
-  
-  
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FillHistos(const char* physics, const char* triggerClassName, 
-                                      const char* centrality)
-{
-  /// Fill histograms for /physics/triggerClassName/centrality
-  
-//  AliCodeTimerAuto("",0);
-
-  FillEventHistos(physics,triggerClassName,centrality);
-  
-  // Track loop
-  
-  if (!fBinArray)
-  {
-    fBinArray = fBinning->CreateBinObjArray("psi","y vs pt,integrated,pt,y,phi","");
-  }
-  
-  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
-  
-  for (Int_t i = 0; i < nTracks; ++i)
-  {
-    AliVParticle* tracki = AliAnalysisMuonUtility::GetTrack(i,Event());
-    
-    if (!tracki) continue;
-    
-    FillHistosForTrack(physics,triggerClassName,centrality,*tracki,i);
-    
-    TLorentzVector pi(tracki->Px(),tracki->Py(),tracki->Pz(),
-                      TMath::Sqrt(MuonMass2()+tracki->P()*tracki->P()));
-    
-    for (Int_t j = i+1; j < nTracks; ++j)
-    {
-      AliVParticle* trackj = AliAnalysisMuonUtility::GetTrack(j,Event());
-      
-      if (!trackj) continue;
-      
-      TLorentzVector pj(trackj->Px(),trackj->Py(),trackj->Pz(),
-                        TMath::Sqrt(MuonMass2()+trackj->P()*trackj->P()));
-      
-      pj += pi;
-      
-      TIter next(fPairTrackCutNames);
-      AliAnalysisTaskMuMu::PairCut* str;
-      
-      UInt_t maski(0),maskj(0),maskij(0);
-      
-      GetPairMask(*tracki,*trackj,i,j,maski,maskj,maskij);
-      
-      while ( ( str = static_cast<AliAnalysisTaskMuMu::PairCut*>(next()) ) )
-      {
-        UInt_t singleTrackMask = str->MaskForOneOrBothTrack();
-        UInt_t pairMask = str->MaskForTrackPair();
-        
-        Bool_t testi = ( ( maski & singleTrackMask ) == singleTrackMask ) ;
-        Bool_t testj = ( ( maskj & singleTrackMask ) == singleTrackMask ) ;
-        Bool_t testij(kTRUE);
-        
-        if (pairMask>0) testij = ( ( maskij & pairMask ) == pairMask ) ;
-        
-        if ( ( testi || testj ) && testij )
-        {
-          if (!IsHistogramDisabled("Chi12"))
-          {
-            Histo(physics,triggerClassName,centrality,str->GetName(),"Chi12")
-            ->Fill(
-                   AliAnalysisMuonUtility::GetChi2perNDFtracker(tracki),
-                   AliAnalysisMuonUtility::GetChi2perNDFtracker(trackj));
-          }
-          
-          if (!IsHistogramDisabled("Rabs12"))
-          {
-            Histo(physics,triggerClassName,centrality,str->GetName(),"Rabs12")
-            ->Fill(AliAnalysisMuonUtility::GetRabs(tracki),
-                   AliAnalysisMuonUtility::GetRabs(trackj));
-          }
-          
-          if ( ( tracki->Charge() != trackj->Charge() ) )
-          {
-            TIter nextBin(fBinArray);
-            AliAnalysisMuMuBinning::Range* r;
-            
-            Histo(physics,triggerClassName,centrality,str->GetName(),"Pt")->Fill(pj.Pt());
-
-            if ( HasMC() )
-            {
-              Int_t labeli = tracki->GetLabel();
-              Int_t labelj = trackj->GetLabel();
-            
-              if ( labeli < 0 || labelj < 0 )
-              {
-                AliError("Got negative labels!");
-              }
-              else
-              {
-                AliVParticle* mcTracki = MCEvent()->GetTrack(labeli);
-                AliVParticle* mcTrackj = MCEvent()->GetTrack(labelj);
-                
-                TLorentzVector mcpi(mcTracki->Px(),mcTracki->Py(),mcTracki->Pz(),
-                                  TMath::Sqrt(MuonMass2()+mcTracki->P()*mcTracki->P()));
-                TLorentzVector mcpj(mcTrackj->Px(),mcTrackj->Py(),mcTrackj->Pz(),
-                                  TMath::Sqrt(MuonMass2()+mcTrackj->P()*mcTrackj->P()));
-
-                mcpj += mcpi;
-                
-                Histo(physics,triggerClassName,centrality,str->GetName(),"PtRecVsSim")->Fill(mcpj.Pt(),pj.Pt());
-                
-              }
-            }
-            
-            while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
-            {
-//              AliInfo(Form("%s y %e pt %e ok1 %d ok2 %d",
-//                           r->AsString().Data(),
-//                           pj.Rapidity(),
-//                           pj.Pt(),
-//                           r->IsInRange(pj.Rapidity(),pj.Pt()),
-//                           r->IsInRange(pj.Pt(),pj.Rapidity())));
-              
-                           
-              Bool_t ok(kFALSE);
-              
-              if ( r->IsNullObject() )
-              {
-                ok = kTRUE;
-              }
-              else if ( r->Is2D() )
-              {
-                if ( r->AsString().BeginsWith("PTVSY") )
-                {
-                  ok = r->IsInRange(pj.Rapidity(),pj.Pt());                  
-                }
-                else if ( r->AsString().BeginsWith("YVSPT") )
-                {
-                  ok = r->IsInRange(pj.Pt(),pj.Rapidity());
-                }
-                else
-                {
-                  AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
-                }
-              }
-              else
-              {
-                if ( r->Type() == "PT" )
-                {
-                  ok = r->IsInRange(pj.Pt());
-                }
-                else if ( r->Type() == "Y" )
-                {
-                  ok = r->IsInRange(pj.Rapidity());
-                }
-                else if ( r->Type() == "PHI" )
-                {
-                  ok = r->IsInRange(pj.Phi());
-                }
-              }
-              
-              if ( ok )
-              {
-                TString hname = GetMinvHistoName(*r);
-              
-                if (!IsHistogramDisabled(hname.Data()))
-                {
-                  TH1* h = Histo(physics,triggerClassName,centrality,str->GetName(),hname.Data());
-                
-                  if (!h)
-                  {
-                    AliError(Form("Could not get %s",hname.Data()));
-                  }
-                  h->Fill(pj.M());
-                }
-              }
-            }
-              
-          }
-        }
-      }
-    }
-  } //track loop
-  
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::FinishTaskOutput()
-{
-  /// prune empty histograms BEFORE mergin, in order to save some bytes...
-  
-  if ( fHistogramCollection )
-  {
-    fHistogramCollection->PruneEmptyObjects();
-  }
-}
-
-//_____________________________________________________________________________
-UInt_t AliAnalysisTaskMuMu::GetEventMask() const
-{
-  /// Compute the event mask
-  
-  /*
-  
-  kEventAll = all events
-  kEventPS = physics selected events
-  kEventTVX = events with 0TVX input present
-  kEventV0AND = events with 0VBA and 0VBC present
-  kEventV0UP = a check of events within a narrow square range of v0a+c vs v0a-c
-  kEventZSPD = events with a vertex computed by SPD
-  kEventZ7 = events with | zvertex | < 7cm
-  kEventZ10 = events with | zvertex | < 10 cm
-  kEventSD2 = events with 0SD2 input present (was for PbPb 2010)
-  kEventMSL = events with 0MSL input present
-  kEventNOPILEUP = events with the T0 pile-up flag not present
-  kEventREJECTED = events not physics selected
-   */
-  
-//  AliCodeTimerAuto("",0);
-  
-  UInt_t eMask = EventCuts()->GetSelectionMask(fInputHandler);
-
-  UInt_t m(AliAnalysisTaskMuMu::kEventAll);
-
-  if ( eMask & AliMuonEventCuts::kPhysicsSelected )
-  {
-    m |= AliAnalysisTaskMuMu::kEventPS;
-  }
-  else
-  {
-    m |= AliAnalysisTaskMuMu::kEventREJECTED;
-  }
-  
-  UInt_t trigger = AliAnalysisMuonUtility::GetL0TriggerInputs(Event());
-  
-  UInt_t l0TVXBIT = GetTriggerInputBitMaskFromInputName("0TVX");
-  
-  if ( ( trigger & (l0TVXBIT) ) == l0TVXBIT )
-  {
-    m |= AliAnalysisTaskMuMu::kEventTVX;
-  }
-  
-  UInt_t l0VBABIT = GetTriggerInputBitMaskFromInputName("0VBA");
-  UInt_t l0VBCBIT = GetTriggerInputBitMaskFromInputName("0VBC");
-  
-  if ( ( ( trigger & (l0VBABIT ) ) == l0VBABIT ) && 
-      ( ( trigger & (l0VBCBIT ) ) == l0VBCBIT ) )
-  {
-    m |= AliAnalysisTaskMuMu::kEventV0AND;
-  }
-  
-  UInt_t l0MSLBIT = GetTriggerInputBitMaskFromInputName("0MSL");
-  
-  if ( ( trigger & (l0MSLBIT) ) == l0MSLBIT )
-  {
-    m |= AliAnalysisTaskMuMu::kEventMSL;
-  }
-  
-  if ( fBeamYear == "PbPb2010" ) 
-  {
-    // consider only events with OSM2 fired
-    UInt_t sd2 = GetTriggerInputBitMaskFromInputName("0SM2");
-    if ( ( trigger & sd2 ) == sd2 )
-    {
-      m |= AliAnalysisTaskMuMu::kEventSD2;
-    }
-  }
-  
-  //  Bool_t hasPileUp = aod->IsPileupFromSPD(3,0.8);
-  //  Bool_t hasPileUp2 = aod->IsPileupFromSPD(5,0.8);  
-  //  Bool_t isIsolated = ( aod->GetBunchCrossNumber() > 1000 && aod->GetBunchCrossNumber() < 2900 );
-  
-  //  Bool_t hasPileUp2 = aod->IsPileupFromSPDInMultBins();
-  
-  //  TIter nextV(aod->GetVertices());
-  //  AliAODVertex* v;
-  //  while ( ( v = static_cast<AliAODVertex*>(nextV())) && !hasPileUp2 )
-  //  {
-  //    if ( v->GetType() == AliAODVertex::kPileupSPD ) hasPileUp2 = kTRUE;
-  //  }
-  
-  //  Bool_t isIsolated = false;//( aod->GetClosestBunchCrossingDistance() > 10 );
-  
-  const AliVVertex* vertex = Event()->GetPrimaryVertex();
-  
-  if ( vertex->IsA() == AliAODVertex::Class() )
-  {
-    AliAODVertex* spdVertex = static_cast<const AliAODEvent*>(Event())->GetPrimaryVertexSPD();
-
-    if ( spdVertex && spdVertex->GetNContributors() > 0 ) 
-    {
-      m |= AliAnalysisTaskMuMu::kEventZSPD;
-    }
-  }
-  
-  if ( TMath::Abs(vertex->GetZ()) < 10.0 )
-  {
-    m |= AliAnalysisTaskMuMu::kEventZ10;
-  }
-  
-  if ( TMath::Abs(vertex->GetZ()) < 7.0 )
-  {
-    m |= AliAnalysisTaskMuMu::kEventZ7;
-  }
-  
-//  AliVVZERO* vzero = Event()->GetVZEROData();
-//  
-//  if (vzero)
-//  {
-//    Float_t v0a = vzero->GetV0ATime();
-//    Float_t v0c = vzero->GetV0CTime();
-//    
-//    Float_t x = v0a-v0c;
-//    Float_t y = v0a+v0c;
-//    
-//    if ( ( x > 6 && x < 10 ) && y > 20 )
-//    {
-//      m |= AliAnalysisTaskMuMu::kEventV0UP;
-//    }
-//  }
-  
-  Bool_t backgroundFlag(kFALSE);
-  Bool_t pileupFlag(kFALSE);
-  Bool_t satelliteFlag(kFALSE);
-  
-  EAGetTZEROFlags(backgroundFlag,pileupFlag,satelliteFlag);
-  
-  if ( !pileupFlag )
-  {
-    m |= AliAnalysisTaskMuMu::kEventNOTZEROPILEUP;
-  }
-  
-  int nmu = EAGetNumberOfSelectMuonTracks();
-
-  if ( nmu >=1 )
-  {
-    m |= AliAnalysisTaskMuMu::kEventOFFLINEMUL1;
-  }
-
-  if ( nmu >=2 )
-  {
-    m |= AliAnalysisTaskMuMu::kEventOFFLINEMUL2;
-  }
-
-  return m;
-}
-
-//_____________________________________________________________________________
-UInt_t AliAnalysisTaskMuMu::GetTriggerInputBitMaskFromInputName(const char* inputName) const
-{
-  // Get trigger input bit from its name
-  // FIXME : this should really come directly from the trigger configuration
-  // object, if only this one would be available in a more convenient
-  // way than the OCDB (e.g. in RunBasedContainer ?)
-  //
-
-  if ( fTriggerInputBitMap.empty() )
-  {
-    // nothing given to us, use the bad bad hard-coded values !
-    
-    TString sInputName(inputName);
-
-    if ( sInputName == "0SM2" ) return (1<<12);
-
-    
-    if ( sInputName == "0VBA" ) return (1<<0);
-    if ( sInputName == "0VBC" ) return (1<<1);
-    if ( sInputName == "0SMB" ) return (1<<2);
-    if ( sInputName == "0TVX" ) return (1<<3);
-    if ( sInputName == "0VGC" ) return (1<<4);
-    if ( sInputName == "0VGA" ) return (1<<5);
-    if ( sInputName == "0SH1" ) return (1<<6);
-    if ( sInputName == "0SH2" ) return (1<<7);
-    if ( sInputName == "0HPT" ) return (1<<8);
-    if ( sInputName == "0AMU" ) return (1<<9);
-    if ( sInputName == "0OB0" ) return (1<<10);
-    if ( sInputName == "0ASL" ) return (1<<11);
-
-    /*
-    if ( sInputName == "0MSL" ) return (1<<12);
-
-//    if ( sInputName == "0MSH" ) return (1<<13);
-    if ( sInputName == "0MSH" ) return (1<<8);
-    
-    if ( sInputName == "0MUL" ) return (1<<14);
-    if ( sInputName == "0MLL" ) return (1<<15);
-     */
-    
-    if ( sInputName == "0MSL") return (1<<12);
-    if ( sInputName == "0MSH") return (1<<13);
-    if ( sInputName == "0MUL") return (1<<14);
-    if ( sInputName == "0MLL") return (1<<15);
-    
-    if ( sInputName == "0EMC" ) return (1<<16);
-    if ( sInputName == "0PH0" ) return (1<<17);
-    if ( sInputName == "0HWU" ) return (1<<18);
-    if ( sInputName == "0LSR" ) return (1<<19);
-    if ( sInputName == "0T0A" ) return (1<<20);
-    if ( sInputName == "0BPA" ) return (1<<21);
-    if ( sInputName == "0BPC" ) return (1<<22);
-    if ( sInputName == "0T0C" ) return (1<<23);
+void AliAnalysisTaskMuMu::Fill(const char* eventSelection, const char* triggerClassName)
+{
+  // Fill one set of histograms (only called for events which pass the eventSelection cut)
+  
+  TString seventSelection(eventSelection);
+  seventSelection.ToLower();
+  
+  fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", seventSelection.Data(), triggerClassName, "ALL", fCurrentRunNumber));
 
-    if ( sInputName == "1EJE" ) return (1<<0);
-    if ( sInputName == "1EGA" ) return (1<<1);
-    if ( sInputName == "1EJ2" ) return (1<<2);
-    if ( sInputName == "1EG2" ) return (1<<3);
-    if ( sInputName == "1PHL" ) return (1<<4);
-    if ( sInputName == "1PHM" ) return (1<<5);
-    if ( sInputName == "1PHH" ) return (1<<6);
-    if ( sInputName == "1HCO" ) return (1<<8);
-    if ( sInputName == "1HJT" ) return (1<<9);
-    if ( sInputName == "1HSE" ) return (1<<10);
-    if ( sInputName == "1DUM" ) return (1<<11);
-    if ( sInputName == "1HQU" ) return (1<<12);
-    if ( sInputName == "1H14" ) return (1<<13);
-    if ( sInputName == "1ZMD" ) return (1<<14);
-    if ( sInputName == "1ZMB" ) return (1<<16);
-    if ( sInputName == "1ZED" ) return (1<<17);
-    if ( sInputName == "1ZAC" ) return (1<<18);
-    if ( sInputName == "1EJE" ) return (1<<19);
+  if ( !IsHistogrammingDisabled() )
+  {
+    TObjArray* centralities = fBinning->CreateBinObjArray("centrality");
     
-    AliError(Form("Don't know this input %s",inputName));
+    TIter next(centralities);
+    AliAnalysisMuMuBinning::Range* r;
     
-    return (1<<31);
-  }
-  else
-  {
-    std::map<std::string,int>::const_iterator it = fTriggerInputBitMap.find(inputName);
-    if ( it != fTriggerInputBitMap.end() )
+    while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) )
     {
-      return ( 1 << it->second );
-    }
-    else
-    {
-      AliError(Form("Don't know this input %s",inputName));
+      TString estimator = r->Quantity();
       
-      return (1<<31);
+      Float_t fcent = Event()->GetCentrality()->GetCentralityPercentile(estimator.Data());
+      if ( fcent < 0.) FillHistos(eventSelection,triggerClassName,"MV0");
+      if ( fcent == 0.) FillHistos(eventSelection,triggerClassName,"0V0");
+      if ( r->IsInRange(fcent) )
+      {
+        FillHistos(eventSelection,triggerClassName,r->AsString());
+      }
     }
+    delete centralities;
   }
 }
 
 //_____________________________________________________________________________
-void AliAnalysisTaskMuMu::GetPairMask(const AliVParticle& t1, const AliVParticle& t2,
-                                      Int_t trackIndex1, Int_t trackIndex2,
-                                      UInt_t& mask1, UInt_t& mask2,
-                                      UInt_t& mask12) const
+void AliAnalysisTaskMuMu::FillHistos(const char* eventSelection,
+                                     const char* triggerClassName,
+                                     const char* centrality)
 {
-  /// Get the mask of the track pair
+  /// Fill histograms for /physics/triggerClassName/centrality
   
-  mask1 = GetTrackMask(trackIndex1);
-  mask2 = GetTrackMask(trackIndex2);
+  AliCodeTimerAuto("",0);
   
-  mask12 = mask1 & mask2;
+  TIter nextAnalysis(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
   
-  if ( PairRapidityCut(t1,t2) ) mask12 |= kPairRapidity;
-}
-
-//_____________________________________________________________________________
-UInt_t AliAnalysisTaskMuMu::GetTrackMask(Int_t trackIndex) const
-{
-  /// Get the mask of all the cuts this track pass
+  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
   
-  return static_cast<UInt_t>(fPrecomputedTrackMasks.At(trackIndex));
-}
+  fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", eventSelection, triggerClassName, centrality, fCurrentRunNumber));
+  
+  TIter nextTrackCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrack));
+  TIter nextPairCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrackPair));
+  
+  // loop on single tracks (whatever the type of tracks
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) )
+  {
+    analysis->DefineHistogramCollection(eventSelection,triggerClassName,centrality);
+    
+    AliCodeTimerAuto(Form("%s (FillHistosForEvent)",analysis->ClassName()),1);
 
-//_____________________________________________________________________________
-TH1* AliAnalysisTaskMuMu::Histo(const char* physics, const char* triggerClassName, const char* histoname)
-{
-  /// Get one histo back
-  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s",physics,triggerClassName,histoname)) : 0x0;
-}
+    if ( MCEvent() != 0x0 )
+    {
+      analysis->FillHistosForMCEvent(eventSelection,triggerClassName,centrality);
+    }
 
-//_____________________________________________________________________________
-TH1* AliAnalysisTaskMuMu::Histo(const char* physics, const char* histoname)
-{
-  /// Get one histo back
-  return fHistogramCollection ? fHistogramCollection->Histo(physics,histoname) : 0x0;
+    analysis->FillHistosForEvent(eventSelection,triggerClassName,centrality);
+    
+    for (Int_t i = 0; i < nTracks; ++i)
+    {
+      AliVParticle* tracki = AliAnalysisMuonUtility::GetTrack(i,Event());
+      
+      nextTrackCut.Reset();
+      AliAnalysisMuMuCutCombination* trackCut;
+      
+      while ( ( trackCut = static_cast<AliAnalysisMuMuCutCombination*>(nextTrackCut()) ) )
+      {
+        if ( trackCut->Pass(*tracki) )
+        {
+          analysis->FillHistosForTrack(eventSelection,triggerClassName,centrality,trackCut->GetName(),*tracki);
+        }
+      }
+      
+      if (!AliAnalysisMuonUtility::IsMuonTrack(tracki) ) continue;
+      
+      // loop on track pairs (here we only consider muon pairs)
+      
+      for (Int_t j = i+1; j < nTracks; ++j)
+      {
+        AliVParticle* trackj = AliAnalysisMuonUtility::GetTrack(j,Event());
+        
+        if (!AliAnalysisMuonUtility::IsMuonTrack(trackj) ) continue;
+        
+        nextPairCut.Reset();
+        AliAnalysisMuMuCutCombination* pairCut;
+        
+        while ( ( pairCut = static_cast<AliAnalysisMuMuCutCombination*>(nextPairCut()) ) )
+        {
+          Bool_t testi = (pairCut->IsTrackCutter()) ? pairCut->Pass(*tracki) : kTRUE;
+          Bool_t testj = (pairCut->IsTrackCutter()) ? pairCut->Pass(*trackj) : kTRUE;
+          Bool_t testij = pairCut->Pass(*tracki,*trackj);
+          
+          if ( ( testi || testj ) && testij )
+          {
+            analysis->FillHistosForPair(eventSelection,triggerClassName,centrality,pairCut->GetName(),*tracki,*trackj);
+          }
+        }
+      }
+    }
+  }
 }
 
 //_____________________________________________________________________________
-TH1* AliAnalysisTaskMuMu::Histo(const char* physics,
-                            const char* triggerClassName, 
-                            const char* what,
-                            const char* histoname)
+void AliAnalysisTaskMuMu::FinishTaskOutput()
 {
-  /// Get one histo back
-  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s",physics,triggerClassName,what),histoname) : 0x0;
+  /// prune empty histograms BEFORE mergin, in order to save some bytes...
+  
+  if ( fHistogramCollection )
+  {
+    fHistogramCollection->PruneEmptyObjects();
+  }
 }
 
 //_____________________________________________________________________________
-TH1* AliAnalysisTaskMuMu::Histo(const char* physics,
-                            const char* triggerClassName, 
-                            const char* cent,
-                            const char* what,
-                            const char* histoname)
+void AliAnalysisTaskMuMu::GetSelectedTrigClassesInEvent(const AliVEvent* event, TObjArray& array)
 {
-  /// Get one histo back
+  /// Fills the array with a list of TObjString of the trigger classes that the various
+  /// cuts accept for this event
+  
+  array.Clear();
+  
+  if (!event)
+  {
+    AliError("Will get a hard time selecting trigger classes with an empty event...");
+    return;
+  }
+  
+  TString firedTriggerClasses = event->GetFiredTriggerClasses();
+  UInt_t l0 = AliAnalysisMuonUtility::GetL0TriggerInputs(event);
+  UInt_t l1 = AliAnalysisMuonUtility::GetL1TriggerInputs(event);
+  UInt_t l2 = AliAnalysisMuonUtility::GetL2TriggerInputs(event);
 
-  return fHistogramCollection ? fHistogramCollection->Histo(Form("/%s/%s/%s/%s",physics,triggerClassName,cent,what),histoname) : 0x0;
+  std::set<std::string> tmpArray;
+  
+  TIter nextCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kTriggerClass));
+  AliAnalysisMuMuCutCombination* cutCombination;
+  
+  while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination()) ) )
+  {
+    TString acceptedTriggerClasses;
+    
+    if ( cutCombination->Pass(firedTriggerClasses,acceptedTriggerClasses,l0,l1,l2) )
+    {
+      TObjArray* split = acceptedTriggerClasses.Tokenize(" ");
+      TIter next(split);
+      TObjString* str;
+      while ( ( str = static_cast<TObjString*>(next()) ) )
+      {
+        tmpArray.insert(str->String().Data());
+      }
+      delete split;
+    }
+  }
+  
+  std::set<std::string>::const_iterator it;
+  
+  for ( it = tmpArray.begin(); it != tmpArray.end(); ++it )
+  {
+    array.Add(new TObjString(it->c_str()));
+  }
 }
 
+
 //_____________________________________________________________________________
 Bool_t AliAnalysisTaskMuMu::IsHistogramDisabled(const char* hname) const
 {
   /// Whether or not a given histogram (identified by its name)
   /// is disabled or not
-  if ( !fHistogramToDisable )
-  {
-    return kFALSE;
-  }
-  TString shname(hname);
-  TIter next(fHistogramToDisable);
-  TObjString* str(0x0);
   
-  while ( ( str = static_cast<TObjString*>(next()) ) )
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
+  
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )
   {
-    if ( shname.Contains(TRegexp(str->String()) ) )
+    if ( analysis->IsHistogramDisabled(hname) )
     {
       return kTRUE;
     }
   }
+  
   return kFALSE;
 }
 
@@ -1920,15 +366,17 @@ Bool_t AliAnalysisTaskMuMu::IsHistogrammingDisabled() const
 {
   /// Whether or not *all* histograms are disabled
   
-  if ( fHistogramToDisable && fHistogramToDisable->GetEntries()==1 )
+  Bool_t disabled(kTRUE);
+  
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
+
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )
   {
-    TObjString* r = static_cast<TObjString*>(fHistogramToDisable->First());
-    if ( r->String() == "*" )
-    {
-      return kTRUE;
-    }
+    disabled = disabled && analysis->IsHistogrammingDisabled();
   }
-  return kFALSE;
+
+  return disabled;
 }
 
 //_____________________________________________________________________________
@@ -1938,107 +386,6 @@ Bool_t AliAnalysisTaskMuMu::IsPP() const
   return fBeamYear.Contains("pp");
 }
 
-//_____________________________________________________________________________
-//void AliAnalysisTaskMuMu::MergeCentralities(AliHistogramCollection* histogramCollection)
-//{
-  /// FIXME : Reimplement using AliMergeableCollection::GetSum ?
-  
-  /// Merge CENT10 + CENT20 + ... into CENTMB
-  
-//  TList* listA = histogramCollection->CreateListOfKeysA();
-//  TList* listB = histogramCollection->CreateListOfKeysB();
-//  TList* listC = histogramCollection->CreateListOfKeysC();
-//  TList* listD = histogramCollection->CreateListOfKeysD();
-//  
-//  if (!listA) 
-//  {
-//    AliErrorClass("listA=0x0");
-//    return;
-//  }
-//  
-//  if (!listB) 
-//  {
-//    AliErrorClass("listB=0x0");
-//    return;
-//  }
-//  
-//  if (!listC) 
-//  {
-//    AliErrorClass("listC=0x0");
-//    return;
-//  }
-//  
-//  if (!listD) 
-//  {
-//    AliErrorClass("listD=0x0");
-//    return;
-//  }
-//  
-//  for ( Int_t id = 0; id <= listD->GetLast(); ++id ) 
-//  {
-//    TString keyD = static_cast<TObjString*>(listD->At(id))->String();
-//    
-//    for ( Int_t ia = 0; ia <= listA->GetLast(); ++ia )
-//    {
-//      TString keyA = static_cast<TObjString*>(listA->At(ia))->String();
-//      
-//      for ( Int_t ib = 0; ib <= listB->GetLast(); ++ib ) 
-//      {
-//        TString keyB = static_cast<TObjString*>(listB->At(ib))->String();
-//        
-//        TList* list = new TList;
-//        list->SetOwner(kTRUE);
-//        
-//        AliHistogramCollection* hmerge(0x0);
-//        
-//        for ( Int_t ic = 0; ic <= listC->GetLast(); ++ic ) 
-//        {
-//          TString keyC = static_cast<TObjString*>(listC->At(ic))->String();
-//          
-//          if ( keyC != "CENTX" && keyC != "CENTMB" )
-//          {
-//            AliHistogramCollection* hc = histogramCollection->Project(keyA.Data(),keyB.Data(),keyC.Data(),keyD.Data());
-//            if (!hmerge) 
-//            {
-//              hmerge = hc;
-//            }
-//            else
-//            {
-//              list->Add(hc);
-//            }
-//          }
-//        }
-//        if (hmerge)
-//        {
-//          hmerge->Merge(list);
-//          TIter next(hmerge->CreateIterator());
-//          TH1* h;
-//          while ( ( h = static_cast<TH1*>(next()) ) )
-//          {
-//            histogramCollection->Adopt(keyA.Data(),keyB.Data(),"CENTMB",keyD.Data(),static_cast<TH1*>(h->Clone()));
-//          }
-//        }
-//        delete list;
-//        delete hmerge;
-//      }      
-//    }
-//  }
-//  
-//  delete listA;
-//  delete listB;
-//  delete listC;
-//  delete listD;
-//}
-
-//_____________________________________________________________________________
-Double_t AliAnalysisTaskMuMu::MuonMass2() const
-{
-  /// A usefull constant
-  static Double_t m2 = 1.11636129640000012e-02; // using a constant here as the line below is a problem for CINT...
-  //  static Double_t m2 = TDatabasePDG::Instance()->GetParticle("mu-")->Mass()*TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
-  return m2;
-}
-
 //_____________________________________________________________________________
 void AliAnalysisTaskMuMu::NotifyRun()
 {
@@ -2046,143 +393,113 @@ void AliAnalysisTaskMuMu::NotifyRun()
   
   AliDebug(1,Form("Run %09d File %s",fCurrentRunNumber,CurrentFileName()));
  
-  MuonTrackCuts()->SetRun(fInputHandler);
-}
-
-//_____________________________________________________________________________
-Bool_t AliAnalysisTaskMuMu::PairRapidityCut(const AliVParticle& t1, const AliVParticle& t2) const
-{
-  /// Whether the pair passes the rapidity cut
-  
-  TLorentzVector p1(t1.Px(),t1.Py(),t1.Pz(),TMath::Sqrt(MuonMass2()+t1.P()*t1.P()));
-  TLorentzVector p2(t2.Px(),t2.Py(),t2.Pz(),TMath::Sqrt(MuonMass2()+t2.P()*t2.P()));
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
   
-  TLorentzVector total(p1+p2);
-  
-  Double_t y = total.Rapidity();
-  
-  return  ( y < -2.5 && y > -4.0 );
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )
+  {
+    analysis->SetRun(fInputHandler);
+  }
 }
 
 //_____________________________________________________________________________
 void 
-AliAnalysisTaskMuMu::Print(Option_t* /*opt*/) const
+AliAnalysisTaskMuMu::Print(Option_t* opt) const
 {
   /// Print the definition of this analysis
   
   cout << ClassName() << " - " << GetName() << " - " << fBeamYear.Data() << endl;
+
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
   
-  if  ( !fSingleTrackCutNames || !fSingleTrackCutNames )
-  {
-    cout << "No single track cut defined yet" << endl;    
-  }
-  else
-  {
-    TIter next(fSingleTrackCutNames);
-    TObjString* str;
-    
-    while ( ( str = static_cast<TObjString*>(next()) ) )
-    {
-      cout << Form("SINGLE CUT %20s MASK %x",str->String().Data(),str->GetUniqueID()) << endl;
-    }
-  }
-  
-  if  ( !fPairTrackCutNames || !fPairTrackCutNames )
-  {
-    cout << "No track pair cut defined yet" << endl;    
-  }
-  else
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )
   {
-    TIter next2(fPairTrackCutNames);
-    AliAnalysisTaskMuMu::PairCut* str;
-
-    while ( ( str = static_cast<AliAnalysisTaskMuMu::PairCut*>(next2()) ) )
-    {
-      str->Print();
-    }
+    analysis->Print(opt);
   }
 
-  if ( !fEventCutNames )
-  {
-    cout << "No event cut defined yet" << endl;
-  }
-  else
-  {
-    TIter nextEventCutName(fEventCutNames);
-    TObjString* eventCutName;
-    
-    while ( ( eventCutName = static_cast<TObjString*>(nextEventCutName()) ) )
-    {
-      cout << Form("EVENT  CUT %s MASK %x",eventCutName->String().Data(),eventCutName->GetUniqueID()) << endl;
-    }
-  }
+  fCutRegistry->Print("ALL");
   
   if ( fBinning )
   {
-    cout << "Binning for Minv plots" << endl;
+    cout << "Binning" << endl;
     fBinning->Print();
   }
 }
 
 //_____________________________________________________________________________
 void
-AliAnalysisTaskMuMu::Terminate(Option_t *)
+AliAnalysisTaskMuMu::Terminate(Option_t* opt)
 {
   /// Called once at the end of the query
   /// Just a simple printout of the stat we analyse and how many histograms
   /// we got
   
+  TIter next(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
+  
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )
+  {
+    analysis->Terminate(opt);
+  }
+
   fHistogramCollection = dynamic_cast<AliMergeableCollection*>(GetOutputData(1));
 
   if (!fHistogramCollection)
   {
     AliError("Could not find back histogram collection in output...");
-    return;
   }
-  
-  fHistogramCollection->PruneEmptyObjects();
-
-  UInt_t size2 = fHistogramCollection->EstimateSize();
+  else
+  {
+    // Removes empty objects and also the event histos of the Nch task
+    fHistogramCollection->PruneEmptyObjects();
+    
+    UInt_t size2 = fHistogramCollection->EstimateSize();
 
-  AliInfo(Form("size after prune histograms = %5.1f MB",size2/1024.0/1024.0));
-  
-//  if ( !IsPP() && fCentralityLimits.size() > 1 ) 
-//  {
-//    MergeCentralities(fHistogramCollection);    
-//  }
+    TIter nextHistogram(fHistogramCollection->CreateIterator());
+    TObject* object;
+    
+    while ( ( object = nextHistogram() ) )
+    {
+      if ( object->IsA()->InheritsFrom(TH1::Class()) )
+      {
+        TH1* h = static_cast<TH1*>(object);
+        if ( h->GetXaxis()->GetLabels() )
+        {
+          h->LabelsDeflate("X");
+        }
+      }
+    }
+    
+    AliInfo(Form("size after prune histograms = %5.1f MB",size2/1024.0/1024.0));
   
-  BeautifyHistos();
-
-  fHistogramCollection->Print("^MinvUS$");
+    fHistogramCollection->Print("-");
+  }
   
   fEventCounters = dynamic_cast<AliCounterCollection*>(GetOutputData(2));
   
   if (!fEventCounters)
   {
     AliError("Could not find back counters in output...");
-    return;
   }
-  
-  fEventCounters->Print("trigger");
+  else
+  {
+    fEventCounters->Print("trigger/event");
+  }
   
   // post param container(s)
   PostData(3,fBinning);
 }
 
 //_____________________________________________________________________________
-Bool_t AliAnalysisTaskMuMu::TriggerSBACECondition(const TString& triggerName) const
+AliAnalysisMuMuBinning* AliAnalysisTaskMuMu::Binning() const
 {
-  // check the beam condition in the trigger name
+  // Return our binning (making a default one if not already created
+  if ( fBinning ) return fBinning;
   
-  if ( triggerName.Contains("-S-") ) return kTRUE;
-
-  if ( triggerName.Contains("-B-") ) return kTRUE;
-
-  if ( fUseBackgroundTriggers )
-  {
-    if ( triggerName.Contains("-ACE-") ) return kTRUE;
-  }
-  return kFALSE;
+  fBinning = new AliAnalysisMuMuBinning("BIN");
+  
+  return fBinning;
 }
 
 //_____________________________________________________________________________
@@ -2190,112 +507,82 @@ void AliAnalysisTaskMuMu::UserExec(Option_t* /*opt*/)
 {
   /// Executed at each event
   
-//  AliCodeTimerAuto("",0);
-  
-  fHasMC = (MCEvent()!=0x0);
-
-  if ( HasMC() )
-  {
-    MuonTrackCuts()->SetIsMC();
-  }
-  
-  TString firedTriggerClasses(AliAnalysisMuonUtility::GetFiredTriggerClasses(Event()));
-
-  TString centrality(DefaultCentralityName());
-  
-  Float_t fcent(EventCuts()->GetCentrality(Event()));
+//  static Int_t n(0);
+//  AliInfo(Form("EVENT %10d Event()=%p MCEvent()=%p",n,Event(),MCEvent()));
+//  ++n;
+//  
+  AliCodeTimerAuto("",0);
   
-  Double_t cent(-100);
+  Binning(); // insure we have a binning...
   
-  if ( fcent > 0 )
+  //  if ( MCEvent() )
+  //  {
+  TIter nextAnalysis(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;  
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) )
   {
-//    for ( std::vector<double>::size_type i = 0 ; i < fCentralityLimits.size() && cent < 0 ; ++i )
-//    {
-//      if ( fcent < fCentralityLimits[i] ) 
-//      {
-//        cent = fCentralityLimits[i];
-//      }
-//    }
+    if ( MCEvent() ) // Set the MC flag for all analysis (prior to call anything from them
+      // (e.g. any trigger class selection that might behave differently for
+      // MC and real trigger classes)
+    {
+      analysis->SetMC();
+    }
+    analysis->SetEvent(Event(),MCEvent()); // Set the new event properties derived in the analysis
   }
+  //  }
   
-  if ( cent > -1 ) 
-  {
-    centrality = CentralityName(cent);
-  }
   
-  int nmu = EAGetNumberOfMuonTracks();
+  TString firedTriggerClasses(AliAnalysisMuonUtility::GetFiredTriggerClasses(Event()));
   
-  EAComputeTrackMasks();
-
   // first loop to count things not associated to a specific trigger
-  TIter nextEventCut(fEventCutNames);
-  TObjString* et;
+  TIter nextEventCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent));
+  AliAnalysisMuMuCutCombination* cutCombination;
   
-  UInt_t mask = GetEventMask();
-
-//  TString eventType;
-//  eventType.Form("EVENTTYPE%d",event->GetEventType());
-
-  while ( ( et = static_cast<TObjString*>(nextEventCut()) ) )
+  while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination())))
   {
-    Bool_t test = ( ( et->GetUniqueID() & mask ) == et->GetUniqueID() );
-    
-    if ( test )
+    if ( cutCombination->Pass(*fInputHandler) )
     {
-      fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "EVERYTHING", fCurrentRunNumber));
+      fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", cutCombination->GetName(), "EVERYTHING",  "ALL", fCurrentRunNumber));
 
-      if ( HasMC() )
-      {
-        fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "HASMC", fCurrentRunNumber));
-      }
-      
       if ( firedTriggerClasses == "" )
       {
-        fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "EMPTY", fCurrentRunNumber));
-      }
-      
-      if (nmu)
-      {
-        fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "ATLEASTONEMUONTRACK", fCurrentRunNumber));
-      }
-
-      if ( AtLeastOneMuonTrigger(firedTriggerClasses) )
-      {
-        fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "ATLEASTONEMUONTRIGGER", fCurrentRunNumber));
-        if ( AtLeastOneMBTrigger(firedTriggerClasses) )
-        {
-          fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "ATLEASTONEMUONORMBTRIGGER", fCurrentRunNumber));
-        }
-      }
-
-      if ( AtLeastOneMBTrigger(firedTriggerClasses) )
-      {
-        fEventCounters->Count(Form("event:%s/trigger:%s/run:%d", et->String().Data(), "ATLEASTONEMBTRIGGER", fCurrentRunNumber));
+        fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", cutCombination->GetName(), "EMPTY", "ALL", fCurrentRunNumber));
       }
     }
   }
 
   // second loop to count only the triggers we're interested in
+  TObjArray selectedTriggerClasses;
 
-  TIter next(EventCuts()->GetSelectedTrigClassesInEvent(Event()));
-  TObjString* tname;
+  GetSelectedTrigClassesInEvent(Event(),selectedTriggerClasses);
   
+  TIter next(&selectedTriggerClasses);
+  TObjString* tname;
+//  Bool_t hasSetEventBeenCalled(kFALSE);
+
   while ( ( tname = static_cast<TObjString*>(next()) ) )
   {
-    nextEventCut.Reset();
-    
-    while ( ( et = static_cast<TObjString*>(nextEventCut()) ) )
+    nextEventCutCombination.Reset();
+
+    while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination())) )
     {
-      Bool_t test = ( ( et->GetUniqueID() & mask ) == et->GetUniqueID() );
-      
-      if ( test ) 
+      if ( cutCombination->Pass(*fInputHandler) )
       {
-        Fill(et->String().Data(),tname,centrality,fcent);
+//        if (!hasSetEventBeenCalled)
+//        {
+//          TIter nextAnalysis(fSubAnalysisVector);
+//          AliAnalysisMuMuBase* analysis;
+//          
+//          while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) )
+//          {
+//            analysis->SetEvent(Event(),MCEvent());
+//          }
+//          hasSetEventBeenCalled = kTRUE;
+//        }
+        Fill(cutCombination->GetName(),tname->String().Data());
       }
     }
   }
-
-  FillMC();
   
   // Post output data.
   PostData(1, fHistogramCollection);
@@ -2306,31 +593,54 @@ void AliAnalysisTaskMuMu::UserExec(Option_t* /*opt*/)
 //_____________________________________________________________________________
 void AliAnalysisTaskMuMu::UserCreateOutputObjects()
 {
-  // Create histograms
-  // Called once
+  /// Create histograms
+  /// Called once
   
   OpenFile(1);
   
-  fHistogramCollection = new AliMergeableCollection("MC");
+  AliInfo(Form("fCutRegistry=%p",fCutRegistry));
   
-  // initialize event counters
+  if ( fCutRegistry )
+  {
+    fCutRegistry->Print();
+  }
+  
+  fHistogramCollection = new AliMergeableCollection("OC");
+
   fEventCounters = new AliCounterCollection("CC");
 
-  TIter nextEventCutName(fEventCutNames);
-  TObjString* str;
+  // initialize event counters
+
   TString eventRubric;
-  while ( ( str = static_cast<TObjString*>(nextEventCutName()) ) )
+  TIter next(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent));
+  AliAnalysisMuMuCutCombination* cutCombination;
+  
+  while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(next())) )
   {
-    if ( eventRubric.Length() > 0 ) eventRubric += "/"; 
-    eventRubric += str->String();
+    TString cutName = cutCombination->GetName();
+    if ( eventRubric.Length() > 0 ) eventRubric += "/";
+    eventRubric += cutName;
   }
   
   fEventCounters->AddRubric("event", eventRubric.Data());
   
   fEventCounters->AddRubric("trigger", 100);
   
+  fEventCounters->AddRubric("centrality", 100);
+  
   fEventCounters->AddRubric("run", 1000000);
   
+  // Initialize our subtasks, if any...
+  
+  TIter nextAnalysis(fSubAnalysisVector);
+  AliAnalysisMuMuBase* analysis;
+  
+  while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) )
+  {
+    analysis->Init(*fEventCounters,*fHistogramCollection,*fBinning,*fCutRegistry);
+  }
+
+  // finally end the counters initialization
   fEventCounters->Init();
   
   // Post output data.
@@ -2338,32 +648,3 @@ void AliAnalysisTaskMuMu::UserCreateOutputObjects()
   PostData(2,fEventCounters);
   PostData(3,fBinning);
 }
-
-//_____________________________________________________________________________
-AliMuonTrackCuts* AliAnalysisTaskMuMu::MuonTrackCuts()
-{
-  if (!fMuonTrackCuts)
-  {
-    fMuonTrackCuts = new AliMuonTrackCuts;
-    
-    fMuonTrackCuts->SetAllowDefaultParams(kTRUE);
-    
-    fMuonTrackCuts->SetFilterMask(AliMuonTrackCuts::kMuEta |
-                                  AliMuonTrackCuts::kMuThetaAbs |
-                                  AliMuonTrackCuts::kMuPdca |
-                                  AliMuonTrackCuts::kMuMatchApt |
-                                  AliMuonTrackCuts::kMuMatchLpt |
-                                  AliMuonTrackCuts::kMuMatchHpt |
-                                  AliMuonTrackCuts::kMuTrackChiSquare);
-    
-  }
-
-  return fMuonTrackCuts;
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskMuMu::SetMuonTrackCuts(const AliMuonTrackCuts& trackCuts)
-{
-  delete fMuonTrackCuts;
-  fMuonTrackCuts = static_cast<AliMuonTrackCuts*>(trackCuts.Clone());
-}
index 861b276011effe68bd92fe15fed710c7f9230d5a..a42100ebdd0ad4fed759ce84a3e90171a4cf10c0 100644 (file)
@@ -1,24 +1,34 @@
 #ifndef ALIANALYSISTASKMUMU_H
 #define ALIANALYSISTASKMUMU_H
 
-//
-// AliAnalysisTaskMuMu : base class for mu pairs analysis 
-// Contains common things for ESD-based and AOD-based analysis
-//
-// author: L. Aphecetche (Subatech)
-//
+/**
+ * \defgroup pwg-muon-mumu pwg-muon-mumu
+ *
+ * \brief Small sub-framework to analyse muon pairs and more...
+ *
+ * Started as a simple invariant mass analysis and grew into a bit more general thing...
+ *
+ * Can now compute the charged particle multiplicy (from SPD tracklets only) in order
+ * to be able to correlate it with e.g. J/psi or single mu.
+ */
+
+/**
+ * \ingroup pwg-muon-mumu
+ *
+ * \class AliAnalysisTaskMuMu 
+ *
+ * \brief Steering class for mu pairs analysis (and more...)
+ *
+ * This class acts as a small sub-framework to steer various sub-analysis which 
+ * share the same MergeableCollection and the same CounterCollection.
+ *
+ *  \author: L. Aphecetche (Subatech)
+ */
 
 #ifndef ALIANALYSISTASKSE_H
 #  include "AliAnalysisTaskSE.h"
 #endif
 
-#include <set>
-#include <vector>
-
-#ifndef ROOT_TArrayI
-#  include "TArrayI.h"
-#endif
-
 #ifndef ROOT_TMath
 #  include "TMath.h"
 #endif
 class AliAnalysisMuMuBinning;
 class AliCounterCollection;
 class AliMergeableCollection;
-class AliMuonTrackCuts;
-class AliMuonEventCuts;
 class AliVParticle;
-class TArrayF;
 class TList;
 class TObjArray;
+class AliAnalysisMuMuBase;
+class AliAnalysisMuMuCutRegistry;
 
 class AliAnalysisTaskMuMu : public AliAnalysisTaskSE
 {
 public:
-  
-  enum ETrackCut
-  {
-    kAll=BIT(0),
-    kPt1=BIT(1),
-    kRabs=BIT(2),
-    kMatched=BIT(3),
-    kMatchedLow=BIT(4),
-    kMatchedHigh=BIT(5),
-    kEta=BIT(6),
-    kChi2=BIT(7),
-    kDCA=BIT(8),
-    kPairRapidity=BIT(9),
-    kBelowPt=BIT(10),
-    kPt1dot2=BIT(11),
-    kPt1dot5=BIT(12),
-    kPt2=BIT(13),
-    kDeg23=BIT(14),
-    kDeg310=BIT(15),
-    kP10=BIT(16),
-    kChi2MatchTrigger=BIT(17)
-  };
-  
-  enum EEventCut
-  {
-    kEventAll=BIT(0),
-    kEventPS=BIT(1),
-    kEventTVX=BIT(2),
-    kEventV0AND=BIT(3),
-    kEventV0UP=BIT(4),
-    kEventZSPD=BIT(5),
-    kEventZ7=BIT(7),    
-    kEventNOTZEROPILEUP=BIT(8),
-    kEventOFFLINEMUL1=BIT(9),
-    kEventZ10=BIT(10),
-    kEventOFFLINEMUL2=BIT(11),
-    kEventSD2=BIT(16),
-    kEventMSL=BIT(17),
-    kEventREJECTED=BIT(18),
-    kEventPSTS=BIT(19)
-  };
-  
   AliAnalysisTaskMuMu();
-  AliAnalysisTaskMuMu(Bool_t fromESD, TList* triggerClassesToConsider, const char* beamYear=0x0, TArrayF* centralities=0x0);
-  AliAnalysisTaskMuMu(Bool_t fromESD, const char* beamYear, TArrayF* centralities=0x0);
   virtual ~AliAnalysisTaskMuMu();
 
-  void AddBin(const char* particle, const char* type,
-              Double_t xmin, Double_t xmax,
-              Double_t ymin,
-              Double_t ymax,
-              const char* flavour="");
-
-  void AddBin(const char* particle, const char* type,
-              Double_t xmin, Double_t xmax,
-              const char* flavour="") { AddBin(particle,type,xmin,xmax,TMath::Limits<Double_t>::Max(),TMath::Limits<Double_t>::Max(),flavour); }
-  
-  void CreateMesh(const char* particle, const char* type1, const char* type2, const char* flavour="", Bool_t remove12=kFALSE);
-  
-  virtual void AddEventCut(const char* cutName, UInt_t mask);
-  
-  virtual void AddPairCut(const char* cutName, UInt_t maskForOneOrBothTrack, UInt_t maskForTrackPair=0);
+  AliAnalysisMuMuCutRegistry* CutRegistry() const;
   
-  virtual void AddSingleCut(const char* cutName, UInt_t mask);
+  AliAnalysisMuMuBinning* Binning() const;
+
+  void AdoptSubAnalysis(AliAnalysisMuMuBase* analysis);
   
   virtual void DisableHistograms(const char* pattern="*");
-  
-  AliMuonEventCuts* EventCuts() const;
+
+  void SetBeamYear(const char* beamYear) { fBeamYear = beamYear; }
   
   virtual void FinishTaskOutput();
   
-  Bool_t IsPP() const;
-
-  Bool_t IsHistogrammingDisabled() const;
-
-  virtual Bool_t IsHistogramDisabled(const char* hname) const;
-
   virtual void NotifyRun();
   
   virtual void Print(Option_t* opt="") const;
   
-  virtual void ShouldSeparatePlusAndMinus(Bool_t value) { fShouldSeparatePlusAndMinus = value; }
-  
-  virtual Bool_t ShouldSeparatePlusAndMinus() const { return fShouldSeparatePlusAndMinus; }
-  
   virtual void Terminate(Option_t *);
   
-  void UseBackgroundTriggers(Bool_t value=kTRUE) { fUseBackgroundTriggers = value; }
-
   void UserCreateOutputObjects();
 
   virtual void UserExec(Option_t* opt);
   
-  AliMuonTrackCuts* MuonTrackCuts();
-  
-  void SetMuonTrackCuts(const AliMuonTrackCuts& trackCuts);
-  
-  class PairCut : public TObject {
-  public:
-    PairCut(const char* name="", UInt_t maskForOneOrBothTrack=0, UInt_t maskForTrackPair=0)
-    : TObject(), fName("p"),fMaskForOneOrBothTrack(maskForOneOrBothTrack),fMaskForTrackPair(maskForTrackPair)
-    {
-      fName += name;
-    }
-    const char* GetName() const { return fName.Data(); }
-    UInt_t MaskForOneOrBothTrack() const { return fMaskForOneOrBothTrack; }
-    UInt_t MaskForTrackPair() const { return fMaskForTrackPair; }
-    void Print(Option_t* opt="") const;
-    
-  private:
-    TString fName; // name of the cut
-    UInt_t fMaskForOneOrBothTrack; // mask for the cut that at least of the two tracks should match
-    UInt_t fMaskForTrackPair; // mask for the cut both tracks should match
-    
-    ClassDef(AliAnalysisTaskMuMu::PairCut,1); // a simple wrapper for two masks
-  };
-  
-  
 private:
-
-  virtual void FillHistos(const char* physics, const char* triggerClassName, const char* centrality);
-
-  void FillHistosForTrack(const char* physics, const char* triggerClassName, const char* centrality, const AliVParticle& track, Int_t trackIndex);
-
-  void FillHistogramCollection(const char* physics, const char* triggerClassName);
   
-  void FillEventHistos(const char* physics, const char* triggerClassName,
-                       const char* centrality);
-  
-  void Fill(const char* eventtype, TObjString* tname, const char* centrality, float fcent);
-
-  void FillMC();
-
-  void AssertHistogramCollection(const char* physics, const char* triggerClassName);
-
-  void BeautifyHistos();
-
-  void CreateMinvHistograms(const char* physics, const char* triggerClassName);
-
-   void CreateHisto(TObjArray* array,
-                   const char* physics,
-                   const char* triggerClassName,
-                   const char* hname, const char* htitle, 
-                   Int_t nbinsx, Double_t xmin, Double_t xmax,
-                   Int_t nbinsy, Double_t ymin, Double_t ymax) const;
-  
-  void CreateEventHisto(const char* physics,
+  void CreateTrackHisto(const char* eventSelection,
                         const char* triggerClassName,
-                        const char* hname, const char* htitle, 
+                        const char* hname, const char* htitle,
                         Int_t nbinsx, Double_t xmin, Double_t xmax,
-                        Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0) const;
+                        Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0,
+                        Bool_t separatePlusAndMinus=kFALSE) const;
   
-  void CreateSingleHisto(const char* physics,
-                         const char* triggerClassName,
-                         const char* hname, const char* htitle, 
-                         Int_t nbinsx, Double_t xmin, Double_t xmax,
-                         Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0,
-                         Bool_t separatePlusAndMinus=kFALSE) const;
-
-  void CreatePairHisto(const char* physics,
+  void CreatePairHisto(const char* eventSelection,
                        const char* triggerClassName,
-                       const char* hname, const char* htitle, 
+                       const char* hname, const char* htitle,
                        Int_t nbinsx, Double_t xmin, Double_t xmax,
-                       Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0) const;
+                       Int_t nbinsy=-1, Double_t ymin=0.0, Double_t ymax=0.0) const;
   
-   void DefineCentralityClasses(TArrayF* centralities);
-  
-  UInt_t GetTriggerInputBitMaskFromInputName(const char* inputName) const;
-
-  TH1* Histo(const char* physics, const char* histoname);
-  
-  TH1* Histo(const char* physics, const char* triggerClassName, const char* histoname);
-  
-  TH1* Histo(const char* physics, const char* triggerClassName, const char* what, const char* histoname);
-
-  TH1* Histo(const char* physics, const char* triggerClassName, const char* cent, const char* what, const char* histoname);
+  const char* DefaultCentralityName() const;
 
-  Double_t MuonMass2() const;
+  AliVEvent* Event() const;
   
-  const char* DefaultCentralityName() const;
+  void FillHistos(const char* eventSelection, const char* triggerClassName, const char* centrality);
   
-  const char* CentralityName(Double_t centrality) const;
+  void Fill(const char* eventSelection, const char* triggerClassName);
   
-  Bool_t HasMC() const { return fHasMC; }
+  void FillMC();
   
-  void ComputeTrackMask(const AliVParticle& track, Int_t trackIndex);
-
-  UInt_t GetEventMask() const;
+  void GetSelectedTrigClassesInEvent(const AliVEvent* event, TObjArray& array);
 
-  void GetPairMask(const AliVParticle& t1, const AliVParticle& t2,
-                   Int_t trackIndex1, Int_t trackIndex2,
-                   UInt_t& mask1, UInt_t& mask2,
-                   UInt_t& mask12) const;
+  Bool_t IsHistogrammingDisabled() const;
   
-  UInt_t GetTrackMask(Int_t trackIndex) const;
+  virtual Bool_t IsHistogramDisabled(const char* hname) const;
   
-  Double_t GetTrackTheta(const AliVParticle& particle) const;
+  Bool_t IsPP() const;
   
-  Bool_t PairRapidityCut(const AliVParticle& t1, const AliVParticle& t2) const;
-
-  /* methods prefixed with EA should really not exist at all. They are there
-   only because the some of our base interfaces are shamelessly incomplete or
-   inadequate...
-   */
+private:
   
-  void EAComputeTrackMasks();
-
-  Int_t EAGetNumberOfMuonTracks() const;
-
-  Int_t EAGetNumberOfSelectMuonTracks() const;
-
-  Double_t EAGetTrackDCA(const AliVParticle& particle) const;
-
-  Bool_t EAGetTZEROFlags(Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag) const;
-
-  Bool_t AtLeastOneMuonTrigger(const TString& firedTriggerClasses) const;
-
-  Bool_t AtLeastOneEmcalTrigger(const TString& firedTriggerClasses) const;
-
-  Bool_t AtLeastOneMBTrigger(const TString& firedTriggerClasses) const;
-
-  Bool_t TriggerSBACECondition(const TString& triggerName) const;
+  AliAnalysisTaskMuMu(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
+  AliAnalysisTaskMuMu& operator=(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
 
-  void DefineDefaultBinning();
-  
-  AliVEvent* Event() const;
-  
 private:
   
   AliMergeableCollection* fHistogramCollection; //! collection of histograms
   AliCounterCollection* fEventCounters; //! event counters
-  
-  AliMuonTrackCuts* fMuonTrackCuts; //! common cuts for muon tracks (from Diego)
-  TArrayI fPrecomputedTrackMasks; //! track masks
+  mutable AliAnalysisMuMuBinning* fBinning; // binning for particles
 
-  Bool_t fIsFromESD; // whether we read from ESD or AOD
-  Bool_t fShouldSeparatePlusAndMinus; // whether or not to histogram mu+ and mu- separately
-  TString fBeamYear; // beam and year
-  
-  TObjArray* fSingleTrackCutNames; // cut on single tracks (array of TObjString)
-  TObjArray* fPairTrackCutNames; // cut on track pairs (array of TObjString)
-  TObjArray* fCentralityNames; // names to create histograms
-  TObjArray* fEventCutNames; // cut at event level (array of TObjString)
-  
-  Bool_t fUseBackgroundTriggers; // whether or not we should use the ACE triggers
-  
-  std::map<std::string,int> fTriggerInputBitMap; // map of L0 input name to bit
-  
-  AliAnalysisMuMuBinning* fBinning; // binning for particles
+  mutable AliAnalysisMuMuCutRegistry* fCutRegistry; // cuts (owner)
   
-  TList* fHistogramToDisable; // list of regexp of histo name to disable
-
-  TObjArray* fBinArray; //!  cache for the bins
-  Bool_t fHasMC; //! current event has MC information
+  TString fBeamYear; // beam and year
   
-  mutable AliMuonEventCuts* fEventCuts; // common cuts for muon events (from Diego)
+  TList* fHistogramToDisable; // list of regexp of histo name(s) to disable
   
-  AliAnalysisTaskMuMu(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
-  AliAnalysisTaskMuMu& operator=(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
+  TObjArray* fSubAnalysisVector; // list of companion analysis
   
-  ClassDef(AliAnalysisTaskMuMu,24) // a class to analyse muon pairs (and single also ;-) )
+  ClassDef(AliAnalysisTaskMuMu,26) // a class to analyse muon pairs (and single also ;-) )
 };
 
 #endif
index d6c9c5b3658a191f7fdda4c3db646f57bd1a40aa..72cab6db9b49b2adaae058e78f01d4f43f50e51a 100644 (file)
@@ -85,7 +85,8 @@ ClassImp(AliAnalysisTaskSingleMu) // Class implementation in ROOT context
 //________________________________________________________________________
 AliAnalysisTaskSingleMu::AliAnalysisTaskSingleMu() :
   AliVAnalysisMuon(),
-  fThetaAbsKeys(0x0)
+  fThetaAbsKeys(0x0),
+  fCutOnDimu(kFALSE)
 {
   /// Default ctor.
 }
@@ -93,7 +94,8 @@ AliAnalysisTaskSingleMu::AliAnalysisTaskSingleMu() :
 //________________________________________________________________________
 AliAnalysisTaskSingleMu::AliAnalysisTaskSingleMu(const char *name, const AliMuonTrackCuts& cuts) :
   AliVAnalysisMuon(name, cuts),
-  fThetaAbsKeys(0x0)
+  fThetaAbsKeys(0x0),
+  fCutOnDimu(kFALSE)
 {
   //
   /// Constructor.
@@ -185,6 +187,22 @@ void AliAnalysisTaskSingleMu::MyUserCreateOutputObjects()
   
   AddObjectToCollection(cfContainer, kTrackContainer);
   
+  histoName = "hRecoDimu";
+  TH2* histoDimu = new TH2F(histoName.Data(), histoName.Data(), 24, 0., 120., 30, 0., 150.);
+  histoDimu->SetXTitle("min. p_{T}^{#mu} (GeV/c)");
+  histoDimu->SetYTitle("M_{#mu#mu} (GeV/c^{2})");
+  AddObjectToCollection(histoDimu, kNobjectTypes);
+  
+  histoName = "hGeneratedZ";
+  AddObjectToCollection(histoDimu->Clone(histoName.Data()), kNobjectTypes+1);
+  
+  
+  histoName = "hZmuEtaCorr";
+  histoDimu = new TH2F(histoName.Data(), histoName.Data(), 160, -8., 8., 160,-8., 8.);
+  histoDimu->SetXTitle("#eta_{#mu-}");
+  histoDimu->SetYTitle("#eta_{#mu+}");
+  AddObjectToCollection(histoDimu, kNobjectTypes+2);
+  
   fMuonTrackCuts->Print("mask");
 }
 
@@ -212,34 +230,79 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
   Int_t nSteps = MCEvent() ? 2 : 1;
   for ( Int_t istep = 0; istep<nSteps; ++istep ) {
     Int_t nTracks = ( istep == kStepReconstructed ) ? AliAnalysisMuonUtility::GetNTracks(InputEvent()) : MCEvent()->GetNumberOfTracks();
+    
+    TObjArray selectedTracks(nTracks);
+    TArrayI trackSources(nTracks);
     for (Int_t itrack = 0; itrack < nTracks; itrack++) {
       track = ( istep == kStepReconstructed ) ? AliAnalysisMuonUtility::GetTrack(itrack,InputEvent()) : MCEvent()->GetTrack(itrack);
       
-      Bool_t isSelected = ( istep == kStepReconstructed ) ? fMuonTrackCuts->IsSelected(track) : ( TMath::Abs(track->PdgCode()) == 13 );
+      // In case of MC we usually ask that the particle is a muon
+      // However, in W or Z simulations, Pythia stores both the initial muon
+      // (before ISR, FSR and kt kick) and the final state one.
+      // The first muon is of course there only for information and should be rejected.
+      // The Pythia code for initial state particles is 21
+      Bool_t isSelected = ( istep == kStepReconstructed ) ? fMuonTrackCuts->IsSelected(track) : ( TMath::Abs(track->PdgCode()) == 13 && AliAnalysisMuonUtility::GetStatusCode(track) != 21 );
       if ( ! isSelected ) continue;
       
-      // In W simulations with Pythia, sometimes muon is stored twice.
-      // Remove muon in case it has another muon as daugther
-      if ( istep == kStepGeneratedMC ) {
-        Int_t firstDaughter = AliAnalysisMuonUtility::GetDaughterIndex(track, 0);
-        if ( firstDaughter >= 0 ) {
-          Bool_t hasMuonDaughter = kFALSE;
-          Int_t lastDaughter = AliAnalysisMuonUtility::GetDaughterIndex(track, 1);
-          for ( Int_t idaugh=firstDaughter; idaugh<=lastDaughter; idaugh++ ) {
-            AliVParticle* currTrack = MCEvent()->GetTrack(idaugh);
-            if ( currTrack->PdgCode() == track->PdgCode() ) {
-              hasMuonDaughter = kTRUE;
-              break;
+      selectedTracks.AddAt(track,itrack);
+      trackSources[itrack] = GetParticleType(track);
+      
+    } // loop on tracks
+    
+    // Loop on selected tracks
+    TArrayI rejectTrack(nTracks);
+    for ( Int_t itrack=0; itrack<nTracks; itrack++) {
+      track = static_cast<AliVParticle*>(selectedTracks.At(itrack));
+      if ( ! track ) continue;
+      
+      if ( istep == kStepGeneratedMC || fCutOnDimu ) {
+        // Check dimuons
+        for ( Int_t jtrack=itrack+1; jtrack<nTracks; jtrack++ ) {
+          AliVParticle* auxTrack = static_cast<AliVParticle*>(selectedTracks.At(jtrack));
+          if ( ! auxTrack ) continue;
+          if ( track->Charge() * auxTrack->Charge() >= 0 ) continue;
+          
+          TLorentzVector dimuPair = AliAnalysisMuonUtility::GetTrackPair(track,auxTrack);
+          Double_t ptMin = TMath::Min(track->Pt(),auxTrack->Pt());
+          Double_t invMass = dimuPair.M();
+          if ( istep == kStepReconstructed ) {
+            if ( invMass > 60. && invMass < 120. ) {
+              rejectTrack[itrack] = 1;
+              rejectTrack[jtrack] = 1;
             }
+            for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
+              TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
+              if ( ! fMuonTrackCuts->TrackPtCutMatchTrigClass(track, fMuonEventCuts->GetTrigClassPtCutLevel(trigClassName)) || ! fMuonTrackCuts->TrackPtCutMatchTrigClass(auxTrack, fMuonEventCuts->GetTrigClassPtCutLevel(trigClassName)) ) continue;
+              ((TH2*)GetMergeableObject(physSel, trigClassName, centrality, "hRecoDimu"))->Fill(ptMin,invMass);
+            } // loop on triggers
           }
-          if ( hasMuonDaughter ) {
-            AliDebug(1, Form("Current muon (%i) has muon daughter: rejecting it", itrack));
-            continue;
-          }
-        }
-      }
-      
-      Int_t trackSrc = GetParticleType(track);
+          else {
+            if ( trackSources[itrack] == kZbosonMu && trackSources[jtrack] == kZbosonMu ) {
+              Bool_t isAccepted = kTRUE;
+              AliVParticle* muDaughter[2] = {0x0, 0x0};
+              for ( Int_t imu=0; imu<2; imu++ ) {
+                AliVParticle* currPart = ( imu == 0 ) ? track : auxTrack;
+                if ( currPart->Charge() < 0. ) muDaughter[0] = currPart;
+                else muDaughter[1] = currPart;
+                if ( currPart->Eta() < -4.5 || currPart->Eta() > -2. ) {
+                  isAccepted = kFALSE;
+                }
+              } // loop on muons in the pair
+              
+              Double_t pairRapidity = dimuPair.Rapidity();
+              if ( pairRapidity < -4. || pairRapidity > -2.5 ) isAccepted = kFALSE;
+              //printf("Rapidity Z %g  pair %g\n",track->Y(), pairRapidity);
+              
+              for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
+                TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
+                if ( isAccepted )  ((TH2*)GetMergeableObject(physSel, trigClassName, centrality, "hGeneratedZ"))->Fill(ptMin,invMass);
+                ((TH2*)GetMergeableObject(physSel, trigClassName, centrality, "hZmuEtaCorr"))->Fill(muDaughter[0]->Eta(),muDaughter[1]->Eta());
+              } // loop on selected trig
+            } // both muons from Z
+          } // kStepGeneratedMC
+        } // loop on auxiliary tracks
+      } // apply cut on dimu
+      if ( rejectTrack[itrack] > 0 ) continue;
       
       Double_t thetaAbsEndDeg = 0;
       if ( istep == kStepReconstructed ) {
@@ -256,7 +319,7 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
       containerInput[kHvarVz]         = ( istep == kStepReconstructed ) ? ipVz : ipVzMC;
       containerInput[kHvarCharge]     = track->Charge()/3.;
       containerInput[kHvarThetaAbs]   = (Double_t)thetaAbsBin;
-      containerInput[kHvarMotherType] = (Double_t)trackSrc;
+      containerInput[kHvarMotherType] = (Double_t)trackSources[itrack];
       
       for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
         TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
index 4d36974aba074da96f2ad122c450e574ec7277fe..bcf743c36011e8c7b6b82d0e0786964da286ede5 100644 (file)
@@ -28,6 +28,8 @@ class AliAnalysisTaskSingleMu : public AliVAnalysisMuon {
   void MyUserCreateOutputObjects();
   void ProcessEvent(TString physSel, const TObjArray& selectTrigClasses, TString centrality);
   
+  void SetCutDimu ( Bool_t cutOnDimu = kTRUE ) { fCutOnDimu = cutOnDimu; }
+  
   enum {
     kIPVz,           ///< Interaction point vertex distribution
     kTrackContainer, ///< CF container for tracks
@@ -63,8 +65,9 @@ class AliAnalysisTaskSingleMu : public AliVAnalysisMuon {
   AliAnalysisTaskSingleMu& operator=(const AliAnalysisTaskSingleMu&);
 
   TObjArray* fThetaAbsKeys;    ///< Name of theta at absorber end
+  Bool_t fCutOnDimu;           ///< Cut on dimuons
 
-  ClassDef(AliAnalysisTaskSingleMu, 3); // Single muon analysis
+  ClassDef(AliAnalysisTaskSingleMu, 4); // Single muon analysis
 };
 
 #endif
index 4577b94a5b0b7acecf4e43022a0a70d4916025fa..3daace6c25c03ab4c2b45fefe320439470b7c7e3 100644 (file)
@@ -413,6 +413,13 @@ TH1*
 AliMergeableCollection::Histo(const char* identifier,
                               const char* objectName) const
 {
+  /// Get histogram key1/key2/.../objectName:action
+  /// action is used for 2D histograms :
+  /// might be px for projection along x-axis
+  /// py for projection along y-axis
+  /// pfx for profile along x-axis
+  /// pfy for profile along y-axis
+  
   TObject* o = GetObject(identifier,objectName);
   
   TObjArray* arr = TString(objectName).Tokenize(":");
@@ -469,6 +476,71 @@ AliMergeableCollection::HistoWithAction(const char* identifier, TObject* o, cons
   return static_cast<TH1*>(o);
 }
 
+//_____________________________________________________________________________
+TH2*
+AliMergeableCollection::H2(const char* fullIdentifier) const
+{
+  /// Short-cut method to grab a 2D histogram
+  /// Will return 0x0 if the object if not a TH2xxx
+
+  TObject* o = GetObject(fullIdentifier);
+  
+  if (o->IsA()->InheritsFrom(TH2::Class()))
+  {
+    return static_cast<TH2*>(o);
+  }
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+TH2*
+AliMergeableCollection::H2(const char* identifier,
+                           const char* objectName) const
+{
+  /// Short-cut method to grab a 2D histogram
+  /// Will return 0x0 if the object if not a TH2xxx
+  
+  TObject* o = GetObject(identifier,objectName);
+  
+  if (o->IsA()->InheritsFrom(TH2::Class()))
+  {
+    return static_cast<TH2*>(o);
+  }
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+TProfile*
+AliMergeableCollection::Prof(const char* fullIdentifier) const
+{
+  /// Short-cut method to grab a TProfile histogram
+  /// Will return 0x0 if the object if not a TProfile
+  
+  TObject* o = GetObject(fullIdentifier);
+  
+  if (o->IsA()->InheritsFrom(TProfile::Class()))
+  {
+    return static_cast<TProfile*>(o);
+  }
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+TProfile*
+AliMergeableCollection::Prof(const char* identifier,
+                           const char* objectName) const
+{
+  /// Short-cut method to grab a TProfile histogram
+  /// Will return 0x0 if the object if not a TProfile
+  
+  TObject* o = GetObject(identifier,objectName);
+  
+  if (o->IsA()->InheritsFrom(TProfile::Class()))
+  {
+    return static_cast<TProfile*>(o);
+  }
+  return 0x0;
+}
 
 //_____________________________________________________________________________
 TObject* 
@@ -492,7 +564,6 @@ AliMergeableCollection::GetObject(const char* fullIdentifier) const
   }
 }
 
-
 //_____________________________________________________________________________
 TObject* 
 AliMergeableCollection::GetObject(const char* identifier, 
@@ -632,12 +703,7 @@ Bool_t AliMergeableCollection::InternalAdopt(const char* identifier, TObject* ob
   if ( obj->IsA()->InheritsFrom(TH1::Class()) ) (static_cast<TH1*> ( obj ))->SetDirectory(0);  
   
   hlist->AddLast(obj);
-  
-  // invalidate the TFolder structure, if any, so it will
-  // be recomputed next time Browse() is called
-  delete fFolders;
-  fFolders = 0x0;
-  
+    
   return kTRUE;
   
 }
@@ -932,8 +998,8 @@ AliMergeableCollection::Print(Option_t* option) const
   /// output to only those objects matching a given classname pattern
   ///
   
-  cout << Form("AliMergeableCollection(%s,%s) : %d keys and %d objects",
-               GetName(),GetTitle(),
+  cout << Form("AliMergeableCollection(%s,%s)[%p] : %d keys and %d objects",
+               GetName(),GetTitle(),this,
                NumberOfKeys(), NumberOfObjects()) << endl;
   
   if (!strlen(option)) return;
@@ -960,7 +1026,7 @@ AliMergeableCollection::Print(Option_t* option) const
   
   TObjArray* identifiers = SortAllIdentifiers();
   
-  printf("identifiers entries %i\n", identifiers->GetEntries());
+  std::cout << Form("Number of identifiers %d", identifiers->GetEntries()) << std::endl;
     
   TIter nextIdentifier(identifiers);
   
@@ -1097,7 +1163,8 @@ AliMergeableCollection::EstimateSize(Bool_t show) const
   while ( ( obj = next() ) )
   {
     UInt_t thissize=0;
-    if ( obj->IsA()->InheritsFrom(TH1::Class()) ) {
+    if ( obj->IsA()->InheritsFrom(TH1::Class()) || obj->IsA()->InheritsFrom(TProfile::Class()) )
+    {
       TH1* histo = static_cast<TH1*> (obj);
       Int_t nbins = (histo->GetNbinsX()+2);
     
@@ -1122,6 +1189,7 @@ AliMergeableCollection::EstimateSize(Bool_t show) const
       if (cname.Contains(TRegexp("I$")) ) nbytesPerBin = sizeof(Int_t);
       if (cname.Contains(TRegexp("F$")) ) nbytesPerBin = sizeof(Float_t);
       if (cname.Contains(TRegexp("D$")) ) nbytesPerBin = sizeof(Double_t);
+      if (cname=="TProfile") nbytesPerBin = sizeof(Double_t);
         
       if (!nbytesPerBin)
       {
@@ -1134,6 +1202,14 @@ AliMergeableCollection::EstimateSize(Bool_t show) const
       + strlen(histo->GetTitle());
       
       if ( hasErrors) thissize += nbins*8;
+      
+      if ( obj->IsA()->InheritsFrom(TProfile::Class()) )
+      {
+        TProfile* prof = static_cast<TProfile*>(obj);
+        TArrayD* d = prof->GetBinSumw2();
+        thissize += d->GetSize()*8*2; // 2 TArrayD
+        thissize += sizeof(prof) - sizeof(histo);
+      }
     }
     else if ( obj->IsA()->InheritsFrom(THnSparse::Class()) ) {
       THnSparse* sparse = static_cast<THnSparse*> (obj);
index b8a04dea1e53c25bc5dd9af9d36161e287fbdde5..4da06f58efb7cae0c99306cc5301dcc079d7b587 100644 (file)
@@ -37,6 +37,8 @@
 class TMap;
 class AliMergeableCollectionIterator;
 class TH1;
+class TH2;
+class TProfile;
 
 class AliMergeableCollection : public TFolder
 {
@@ -74,6 +76,15 @@ public:
   TH1* Histo(const char* fullIdentifier) const;
   TH1* Histo(const char* identifier, const char* objectName) const;
 
+  TH1* H1(const char* fullIdentifier) const { return Histo(fullIdentifier); }
+  TH1* H1(const char* identifier, const char* objectName) const { return Histo(identifier,objectName); }
+
+  TH2* H2(const char* fullIdentifier) const;
+  TH2* H2(const char* identifier, const char* objectName) const;
+
+  TProfile* Prof(const char* fullIdentifier) const;
+  TProfile* Prof(const char* identifier, const char* objectName) const;
+
   virtual TIterator* CreateIterator(Bool_t dir = kIterForward) const;
   
   virtual TList* CreateListOfKeys(Int_t index) const;
@@ -143,7 +154,7 @@ private:
   mutable Int_t fMapVersion; /// internal version of map (to avoid custom streamer...)
   mutable std::map<std::string,int> fMessages; //! log messages
   
-  ClassDef(AliMergeableCollection,3) /// A collection of mergeable objects
+  ClassDef(AliMergeableCollection,4) /// A collection of mergeable objects
 };
 
 class AliMergeableCollectionIterator : public TIterator
index d9fcc033a688ef320063e764c99e7f4bd856f37e..7859ec60514bb6cb6f135dd629902d911098ff32 100644 (file)
@@ -439,6 +439,26 @@ void AliMuonEventCuts::SetTrigClassLevels ( TString pattern )
   delete fullList;
 }
 
+//________________________________________________________________________
+UInt_t AliMuonEventCuts::GetTriggerInputBitMaskFromInputName(const char* inputName) const
+{
+  // Get trigger input bit from its name
+  
+  if (!fTrigInputsMap)
+  {
+    AliError("No Inputs Map available");
+    return TMath::Limits<UInt_t>::Max();
+  }
+  
+  TObjString* s = static_cast<TObjString*>(fTrigInputsMap->FindObject(inputName));
+  if (!s)
+  {
+    AliError(Form("Did not find input %s",inputName));
+    return TMath::Limits<UInt_t>::Max();    
+  }
+  return s->GetUniqueID();
+}
+
 //________________________________________________________________________
 TArrayI AliMuonEventCuts::GetTrigClassPtCutLevel ( const TString trigClassName ) const
 {
@@ -546,6 +566,20 @@ void AliMuonEventCuts::SetDefaultTrigInputsMap ()
   SetTrigInputsMap(trigInputsMap);
 }
 
+//________________________________________________________________________
+const TObjArray*
+AliMuonEventCuts::GetSelectedTrigClassesInEvent(const TString& firedTriggerClasses,
+                                                UInt_t l0Inputs, UInt_t l1Inputs,
+                                                UInt_t l2Inputs)
+{
+  /// Return the selected trigger classes in the fired trigger classes
+  /// give also the L0,L1,L2 input bit masks
+  
+  BuildTriggerClasses(firedTriggerClasses,l0Inputs,l1Inputs,l2Inputs);
+
+  return fSelectedTrigClassesInEvent;
+}
+
 //________________________________________________________________________
 const TObjArray* AliMuonEventCuts::GetSelectedTrigClassesInEvent( const AliVEvent* event )
 {
index fdc048156e6582be98bd836329cb1c2d8cbc81c5..c2843baf21b459b10e46dceb543ac6abaadd0e94 100644 (file)
@@ -47,8 +47,11 @@ class AliMuonEventCuts : public AliAnalysisCuts
   /// Get trigger classes found in run
   TList* GetAllSelectedTrigClasses () const { return fAllSelectedTrigClasses; }
   const TObjArray* GetSelectedTrigClassesInEvent ( const AliVEvent* event );
+  const TObjArray* GetSelectedTrigClassesInEvent(const TString& firedTriggerClasses,
+                                                 UInt_t l0Inputs, UInt_t l1Inputs, UInt_t l2Inputs);
+
+  UInt_t GetTriggerInputBitMaskFromInputName(const char* inputName) const;
 
-  
   // Handle centrality
   void SetCentralityClasses(Int_t nCentralityBins = -1, Double_t* centralityBins = 0x0);
   /// Get centrality classes
index aa87b39d028cec449ab97af48f8d4b6a347b46a9..968a10a34644a6b02f1356accda31052f28f1c68 100644 (file)
@@ -52,7 +52,7 @@ fPx(0.),
 fPy(0.),\r
 fPz(0.),\r
 fMask(0),\r
-fAncestor(-999.)\r
+fAncestor(-999)\r
 {\r
   /// Default constructor\r
 }\r
diff --git a/PWG/muon/Doxyfile b/PWG/muon/Doxyfile
new file mode 100644 (file)
index 0000000..efdb7ec
--- /dev/null
@@ -0,0 +1,1938 @@
+# Doxyfile 1.8.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed
+# in front of the TAG it is preceding .
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME           = "PWG/muon"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER         = "PWG/muon"
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = "Classes relevant to muon analyses"
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = $(ALICE_INSTALL)
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Latvian, Lithuanian, Norwegian, Macedonian,
+# Persian, Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic,
+# Slovak, Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip. Note that you specify absolute paths here, but also
+# relative paths, which will be relative from the directory where doxygen is
+# started.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS           = NO
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding
+# "class=itcl::class" will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST              =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension,
+# and language is one of the parsers supported by doxygen: IDL, Java,
+# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C,
+# C++. For instance to make doxygen treat .inc files as Fortran files (default
+# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note
+# that for custom extensions you also need to set FILE_PATTERNS otherwise the
+# files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
+# comments according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you
+# can mix doxygen, HTML, and XML commands with Markdown formatting.
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT       = YES
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by by putting a % sign in front of the word
+# or globally by setting AUTOLINK_SUPPORT to NO.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES (the
+# default) will make doxygen replace the get and set methods by a property in
+# the documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields or simple typedef fields will be shown
+# inline in the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO (the default), structs, classes, and unions are shown on a separate
+# page (for HTML and Man pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can
+# be an expensive process and often the same symbol appear multiple times in
+# the code, doxygen keeps a cache of pre-resolved symbols. If the cache is too
+# small doxygen will become slower. If the cache is too large, memory is wasted.
+# The cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid
+# range is 0..9, the default is 0, corresponding to a cache size of 2^16 = 65536
+# symbols.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = YES
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# scope will be included in the documentation.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS       = NO
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if section-label ... \endif
+# and \cond section-label ... \endcond blocks.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            = DoxygenLayout.xml
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path. Do not use
+# file names with spaces, bibtex cannot handle them.
+
+CITE_BIB_FILES         =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE           =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+# for the moment we are very specific (instead of just giving the full PWG/muon directory
+# as input ...) as many classes have no doxygen comments at all
+
+INPUT                  = \
+AliAnalysisMuMuBase.cxx \
+AliAnalysisMuMuBase.h \
+AliAnalysisMuMuBinning.cxx \
+AliAnalysisMuMuBinning.h \
+AliAnalysisMuMuCutCombination.cxx \
+AliAnalysisMuMuCutCombination.h \
+AliAnalysisMuMuCutElement.cxx \
+AliAnalysisMuMuCutElement.h \
+AliAnalysisMuMuCutRegistry.cxx \
+AliAnalysisMuMuCutRegistry.h \
+AliAnalysisMuMuEventCutter.cxx \
+AliAnalysisMuMuEventCutter.h \
+AliAnalysisMuMuGlobal.cxx \
+AliAnalysisMuMuGlobal.h \
+AliAnalysisMuMuMinv.cxx \
+AliAnalysisMuMuMinv.h \
+AliAnalysisMuMuNch.cxx \
+AliAnalysisMuMuNch.h \
+AliAnalysisMuMuSingle.cxx \
+AliAnalysisMuMuSingle.h \
+AliAnalysisMuonUtility.cxx \
+AliAnalysisMuonUtility.h \
+AliAnalysisTaskMuMu.cxx \
+AliAnalysisTaskMuMu.h \
+AliMergeableCollection.cxx \
+AliMergeableCollection.h \
+AliMuonEventCuts.cxx \
+AliMuonEventCuts.h \
+AliMuonTrackCuts.cxx \
+AliMuonTrackCuts.h
+
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = "G__*"
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH             = .
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be ignored.
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = NO
+
+# If CLANG_ASSISTED_PARSING is set to YES, then doxygen will use the clang parser
+# for more acurate parsing at the cost of reduced performance. This can be
+# particularly helpful with template rich C++ code for which doxygen's built-in
+# parser lacks the necessairy type information.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified at INPUT and INCLUDE_PATH.
+
+CLANG_OPTIONS          =
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 2
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = Ali
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+#  for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is advised to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If left blank doxygen will
+# generate a default style sheet. Note that it is recommended to use
+# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this
+# tag will in the future become obsolete.
+
+HTML_STYLESHEET        =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional
+# user-defined cascading style sheet that is included after the standard
+# style sheets created by doxygen. Using this option one can overrule
+# certain style aspects. This is preferred over using HTML_STYLESHEET
+# since it does not replace the standard style sheet and is therefor more
+# robust against future updates. Doxygen will copy the style sheet file to
+# the output directory.
+
+HTML_EXTRA_STYLESHEET  =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the style sheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely
+# identify the documentation publisher. This should be a reverse domain-name
+# style string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE               =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
+# at top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it. Since the tabs have the same information as the
+# navigation tree you can set this option to NO if you already set
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+# Since the tree basically has the same information as the tab index you
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you may also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and
+# SVG. The default value is HTML-CSS, which is slower, but has the best
+# compatibility.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to
+# the MathJax Content Delivery Network so you can quickly see the result without
+# installing MathJax.
+# However, it is strongly recommended to install a local
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript
+# pieces of code that will be used on startup of the MathJax code.
+
+MATHJAX_CODEFILE       =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript.
+# There are two flavours of web server based search depending on the
+# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for
+# searching and an index file used by the script. When EXTERNAL_SEARCH is
+# enabled the indexing and searching needs to be provided by external tools.
+# See the manual for details.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain
+# the search results. Doxygen ships with an example indexer (doxyindexer) and
+# search engine (doxysearch.cgi) which are based on the open source search
+# engine library Xapian. See the manual for configuration details.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will returned the search results when EXTERNAL_SEARCH is enabled.
+# Doxygen ships with an example search engine (doxysearch) which is based on
+# the open source search engine library Xapian. See the manual for configuration
+# details.
+
+SEARCHENGINE_URL       =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+
+EXTERNAL_SEARCH_ID     =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id
+# of to a relative location where the documentation can be found.
+# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...
+
+EXTRA_SEARCH_MAPPINGS  =
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4 will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images
+# or other source files which should be copied to the LaTeX output directory.
+# Note that the files will be copied as-is; there are no commands or markers
+# available.
+
+LATEX_EXTRA_FILES      =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA             =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES Doxygen will generate DOCBOOK files
+# that can be used to generate PDF.
+
+GENERATE_DOCBOOK       = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the DOCBOOK pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it. If left blank docbook will be used as the default path.
+
+DOCBOOK_OUTPUT         = docbook
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH           =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED             =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each
+# tag file the location of the external documentation should be added. The
+# format of a tag file without this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths
+# or URLs. Note that each tag file must have a unique name (where the name does
+# NOT include the path). If a tag file is not located in the directory in which
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed
+# in the related pages index. If set to NO, only the current project's
+# pages will be listed.
+
+EXTERNAL_PAGES         = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = NO
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will use the Helvetica font for all dot files that
+# doxygen generates. When you want a differently looking font you can specify
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find
+# the font, which can be done by putting it in a standard location or by setting
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
+# directory containing the font.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the Helvetica font.
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
+# set the path where dot can find it.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = NO
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside
+# the class node. If there are many fields or methods and many nodes the
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
+# threshold limits the number of items for each type to make the size more
+# manageable. Set this to 0 for no limit. Note that the threshold may be
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used. If you choose svg you need to set
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+# Note that this requires a modern browser other than Internet Explorer.
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG        = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS           =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS           =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/PWG/muon/DoxygenLayout.xml b/PWG/muon/DoxygenLayout.xml
new file mode 100644 (file)
index 0000000..531dfca
--- /dev/null
@@ -0,0 +1,196 @@
+<doxygenlayout version="1.0">
+  <!-- Generated by doxygen 1.8.4 -->
+  <!-- Navigation index tabs for HTML output -->
+  <navindex>
+    <tab type="mainpage" visible="yes" title=""/>
+    <tab type="pages" visible="yes" title="" intro=""/>
+    <tab type="modules" visible="yes" title="" intro=""/>
+    <tab type="namespaces" visible="yes" title="">
+      <tab type="namespacelist" visible="yes" title="" intro=""/>
+      <tab type="namespacemembers" visible="yes" title="" intro=""/>
+    </tab>
+    <tab type="classes" visible="yes" title="">
+      <tab type="classlist" visible="yes" title="" intro=""/>
+      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> 
+      <tab type="hierarchy" visible="yes" title="" intro=""/>
+      <tab type="classmembers" visible="yes" title="" intro=""/>
+    </tab>
+    <tab type="files" visible="yes" title="">
+      <tab type="filelist" visible="yes" title="" intro=""/>
+      <tab type="globals" visible="yes" title="" intro=""/>
+    </tab>
+    <tab type="examples" visible="yes" title="" intro=""/>
+    <tab type="user" url="http://aliweb.cern.ch/Offline/" title="Alice Offline Pages"/>
+    <tab type="user" url="http://git.cern.ch/pubweb/AliRoot.git/tree" title="AliRoot git web"/>
+  </navindex>
+
+  <!-- Layout definition for a class page -->
+  <class>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <inheritancegraph visible="$CLASS_GRAPH"/>
+    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+    <detaileddescription title=""/>
+    <memberdecl>
+      <nestedclasses visible="yes" title=""/>
+      <publictypes title=""/>
+      <services title=""/>
+      <interfaces title=""/>
+      <publicslots title=""/>
+      <signals title=""/>
+      <publicmethods title=""/>
+      <publicstaticmethods title=""/>
+      <publicattributes title=""/>
+      <publicstaticattributes title=""/>
+      <protectedtypes title=""/>
+      <protectedslots title=""/>
+      <protectedmethods title=""/>
+      <protectedstaticmethods title=""/>
+      <protectedattributes title=""/>
+      <protectedstaticattributes title=""/>
+      <packagetypes title=""/>
+      <packagemethods title=""/>
+      <packagestaticmethods title=""/>
+      <packageattributes title=""/>
+      <packagestaticattributes title=""/>
+      <properties title=""/>
+      <events title=""/>
+      <privatetypes title=""/>
+      <privateslots title=""/>
+      <privatemethods title=""/>
+      <privatestaticmethods title=""/>
+      <privateattributes title=""/>
+      <privatestaticattributes title=""/>
+      <friends title=""/>
+      <related title="" subtitle=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <inlineclasses title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <services title=""/>
+      <interfaces title=""/>
+      <constructors title=""/>
+      <functions title=""/>
+      <related title=""/>
+      <variables title=""/>
+      <properties title=""/>
+      <events title=""/>
+    </memberdef>
+    <allmemberslink visible="yes"/>
+    <usedfiles visible="$SHOW_USED_FILES"/>
+    <authorsection visible="yes"/>
+  </class>
+
+  <!-- Layout definition for a namespace page -->
+  <namespace>
+    <briefdescription visible="yes"/>
+    <memberdecl>
+      <nestednamespaces visible="yes" title=""/>
+      <constantgroups visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <inlineclasses title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </namespace>
+
+  <!-- Layout definition for a file page -->
+  <file>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <includegraph visible="$INCLUDE_GRAPH"/>
+    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+    <sourcelink visible="yes"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <constantgroups visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <inlineclasses title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection/>
+  </file>
+
+  <!-- Layout definition for a group page -->
+  <group>
+    <briefdescription visible="yes"/>
+    <groupgraph visible="$GROUP_GRAPHS"/>
+    <memberdecl>
+      <nestedgroups visible="yes" title=""/>
+      <dirs visible="yes" title=""/>
+      <files visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <pagedocs/>
+      <inlineclasses title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </group>
+
+  <!-- Layout definition for a directory page -->
+  <directory>
+    <briefdescription visible="yes"/>
+    <directorygraph visible="yes"/>
+    <memberdecl>
+      <dirs visible="yes"/>
+      <files visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+  </directory>
+</doxygenlayout>
diff --git a/PWG/muon/runMuMu.C b/PWG/muon/runMuMu.C
new file mode 100755 (executable)
index 0000000..a7f2dd9
--- /dev/null
@@ -0,0 +1,381 @@
+///
+/// Example macro to run the AliAnalysisTaskMuMu task
+///
+/// \author L. Aphecetche
+///
+
+//______________________________________________________________________________
+void LoadLocalLibs(Bool_t localAnalysis=kTRUE)
+{
+  gSystem->Load("libVMC");
+  gSystem->Load("libMinuit");
+  gSystem->Load("libTree");
+  gSystem->Load("libProofPlayer");
+  gSystem->Load("libXMLParser");
+  gSystem->Load("libSTEERBase");
+  gSystem->Load("libESD");
+  gSystem->Load("libAOD");
+  gSystem->Load("libANALYSIS");
+  gSystem->Load("libANALYSISalice");
+
+  if (!localAnalysis)
+  {
+    gSystem->Load("libCORRFW");
+  }
+  else
+  {
+       gROOT->LoadMacro("AliOADBMuonTrackCutsParam.cxx+g");
+       gROOT->LoadMacro("AliAnalysisMuonUtility.cxx+g");
+       gROOT->LoadMacro("AliMuonTrackCuts.cxx+g");
+       gROOT->LoadMacro("AliMergeableCollection.cxx+g");
+       gROOT->LoadMacro("AliAnalysisMuMuBinning.cxx+g");
+       gROOT->LoadMacro("AliMuonEventCuts.cxx+g");
+    
+    gROOT->LoadMacro("AliAnalysisMuMuCutElement.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuCutCombination.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuCutRegistry.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuEventCutter.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuBase.cxx+g");
+
+    gROOT->LoadMacro("AliAnalysisTaskMuMu.cxx+g");
+
+    gROOT->LoadMacro("AliAnalysisMuMuGlobal.cxx+g");
+
+    gROOT->LoadMacro("AliAnalysisMuMuMinv.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuSingle.cxx+g");
+    gROOT->LoadMacro("AliAnalysisMuMuNch.cxx+g");
+
+  }
+}
+
+//______________________________________________________________________________
+TChain* CreateLocalChain(const char* filelist)
+{
+       TChain* c = new TChain("aodTree");
+       
+       char line[1024];
+       
+       ifstream in(filelist);
+       while ( in.getline(line,1024,'\n') )
+       {
+               c->Add(line);
+       }
+       return c;
+}
+
+//______________________________________________________________________________
+TString GetInputType(const TString& sds, TProof* p)
+{
+   if (sds.Length()==0 ) return "AOD";
+
+   if (sds.Contains("SIM_JPSI")) return "AOD";
+   
+   if (sds.Contains("AOD")) return "AOD";
+   if (sds.Contains("ESD")) return "ESD";
+   
+   if ( gSystem->AccessPathName(gSystem->ExpandPathName(sds.Data())) )
+   {
+       // dataset is not a local file so it must be a dataset name
+       if (!p) return "NOPROOF";
+       
+       TFileCollection* fc = p->GetDataSet(sds.Data());
+    if (!fc) return "NODATASET";
+    
+    TIter next(fc->GetList());
+    TFileInfo* fi;
+    while ( ( fi = static_cast<TFileInfo*>(next()) ) )
+    {
+      TUrl url(*(fi->GetFirstUrl()));
+         TString surl(url.GetUrl());
+         
+         if (surl.Contains("AOD")) return "AOD";
+         if (surl.Contains("AliESD")) return "ESD";      
+    }      
+
+   }
+   else
+   {
+   std::cout << "Will use datasets from file " << sds.Data() << std::endl;
+   
+   // dataset is a local text file containing a list of dataset names
+       std::ifstream in(sds.Data());
+       char line[1014];
+   
+       while (in.getline(line,1023,'\n'))
+       {
+         TString sline(line);
+       sline.ToUpper();
+       if ( sline.Contains("SIM_JPSI") ) return "AOD";
+       if ( sline.Contains("AOD") ) return "AOD";
+       if ( sline.Contains("ESD") ) return "ESD";
+       }
+   }
+   
+   return "BUG";   
+}
+
+//______________________________________________________________________________
+AliAnalysisTask* runMuMu(const char* dataset="SIM_JPSI_LHC13f_CynthiaTuneWithRejectList_000197388",
+                         Bool_t simulations=kTRUE,
+                         Bool_t baseline=kFALSE,
+                         const char* where="laphecet@nansafmaster.in2p3.fr/?N")
+{
+  // Create the analysis manager
+  
+  Bool_t prooflite = (strlen(where)==0) || TString(where).Contains("workers");
+
+  TString sds(dataset);
+  
+//  if (!prooflite && sds.Length()>0) TProof::Mgr(where)->SetROOTVersion("VO_ALICE@ROOT::v5-34-05");
+  
+  TProof* p(0x0);
+  TString alirootMode("");
+  TString workers("workers=8x");
+
+  if (TString(where).Contains("alice-caf"))
+  {
+    workers="workers=1x";
+  }
+  if (TString(where).Contains("localhost:2093"))
+  {
+    workers="workers=8x";
+  }
+  
+  if (prooflite)
+  {
+    cout << "Will work in LITE mode" << endl;
+  }
+  
+  if ( sds.Length()>0 )
+  {
+    p = TProof::Open(where,workers.Data());
+    
+    if (!p)
+    {
+      cout << "Cannot connect to Proof : " << where << endl;
+      return 0;
+    }
+    
+    alirootMode.ToUpper();
+    
+    if ( alirootMode == "PAR" ) 
+    {
+      cout << "Will work with PAR files" << endl;
+      
+      std::vector<std::string> pars;
+      
+      pars.push_back("STEERBase");
+      pars.push_back("ESD");
+      pars.push_back("AOD");
+      pars.push_back("ANALYSIS");
+      pars.push_back("OADB");
+      pars.push_back("ANALYSISalice");
+      //       pars.push_back("CORRFW");
+      //       pars.push_back("PWGmuon");
+      
+      Bool_t ok(kTRUE);
+      
+      for ( std::vector<std::string>::size_type i = 0; i < pars.size(); ++i )
+      {
+        std::string package = pars[i];
+        
+        if ( gProof->UploadPackage(package.c_str()) ) 
+        {
+          ok = kFALSE;
+        }
+        
+        if ( gProof->EnablePackage(package.c_str(),"",kTRUE) ) 
+        {
+          ok = kFALSE;
+        }
+        
+        if (!ok) 
+        {
+          cout << "Problem with PAR " << package.c_str() << endl;
+          return 0;           
+        }
+      }
+    }
+    else 
+    {
+      TList* list = new TList();
+      
+      //       list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "PWG3base"));
+      //       list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES", "PWG3"));
+      //       list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "PWG3base"));//:CORRFW:PWG3muon"));
+      //       list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES", "PWG3/base"));//:PWG3/muon"));
+      
+      //    list->Add(new TNamed("ALIROOT_ENABLE_ALIEN", "1"));
+      
+      if (!alirootMode.IsNull())
+      {
+        list->Add(new TNamed("ALIROOT_MODE", alirootMode.Data()));  
+      }
+      else
+      {
+        list->Add(new TNamed("ALIROOT_MODE",""));
+      }
+      
+      if (!prooflite)
+      {
+//        p->SetParameter("PROOF_UseTreeCache", 0);
+        p->EnablePackage("VO_ALICE@AliRoot::v5-04-65-AN", list, kTRUE);
+      }
+      else
+      {
+        //      list->Add(new TNamed("ALIROOT_LOCAL_PATH",gSystem->Getenv("ALICE_ROOT")));       
+        p->UploadPackage("$ALICE_ROOT/ANALYSIS/macros/AliRootProofLite.par");
+        if (p->EnablePackage("AliRootProofLite",list)) return 0;
+      }
+    }
+    
+    // compile task on workers
+    if ( alirootMode != "PAR" )
+    {
+      p->Load("AliOADBMuonTrackCutsParam.cxx+");
+      p->Load("AliAnalysisMuonUtility.cxx+");
+      p->Load("AliMuonTrackCuts.cxx+");
+      p->Load("AliMergeableCollection.cxx+");
+      p->Load("AliAnalysisMuMuBinning.cxx+");
+      p->Load("AliMuonEventCuts.cxx+");
+       p->Load("AliAnalysisMuMuCutElement.cxx+");
+       p->Load("AliAnalysisMuMuCutCombination.cxx+");       
+       p->Load("AliAnalysisMuMuCutRegistry.cxx+");
+      p->Load("AliAnalysisMuMuBase.cxx+");      
+      p->Load("AliAnalysisTaskMuMu.cxx+");
+       p->Load("AliAnalysisMuMuEventCutter.cxx+");       
+     p->Load("AliAnalysisMuMuGlobal.cxx+");
+     p->Load("AliAnalysisMuMuNch.cxx+");
+     p->Load("AliAnalysisMuMuSingle.cxx+");
+     p->Load("AliAnalysisMuMuMinv.cxx+");
+       }
+  }
+  
+  LoadLocalLibs(kTRUE);
+  
+  AliAnalysisManager *mgr = new AliAnalysisManager("MuMu");
+  
+  AliInputEventHandler* input(0x0);
+
+  TString inputType = GetInputType(sds,p);
+  
+  if ( inputType == "AOD" ) 
+  {
+    input = new AliAODInputHandler;
+  }
+  else if ( inputType == "ESD" ) 
+  {
+    input = new AliESDInputHandler;
+  }
+  else
+  {
+       std::cout << "Cannot get input type !" << std::endl;
+       return 0;
+  }
+
+  mgr->SetInputEventHandler(input);
+  
+  TList* triggers = new TList;
+  triggers->SetOwner(kTRUE);
+
+  if (!simulations)
+  {
+    triggers->Add(new TObjString("CINT7-B-NOPF-ALLNOTRD"));
+
+//   triggers->Add(new TObjString("CINT7-B-NOPF-ALLNOTRD & 0MUL"));
+//   triggers->Add(new TObjString("CINT7-B-NOPF-ALLNOTRD & 0MSL"));
+//   triggers->Add(new TObjString("CINT7-B-NOPF-ALLNOTRD & 0MSH"));
+//   triggers->Add(new TObjString("CMSL7-B-NOPF-MUON & 0MUL"));
+//   triggers->Add(new TObjString("CMSL7-B-NOPF-MUON & 0MSH"));
+// 
+//   triggers->Add(new TObjString("CMSL7-B-NOPF-MUON"));
+//   triggers->Add(new TObjString("CMSH7-B-NOPF-MUON"));
+//    triggers->Add(new TObjString("CMUL7-B-NOPF-MUON"));
+  // below for MB periods only
+//  triggers->Add(new TObjString("CMSL7-B-NOPF-ALLNOTRD"));
+//   triggers->Add(new TObjString("CMSH7-B-NOPF-ALLNOTRD"));
+  triggers->Add(new TObjString("CMUL7-B-NOPF-ALLNOTRD"));
+  triggers->Add(new TObjString("CMUL7-B-NOPF-MUON"));
+//   triggers->Add(new TObjString("CMSL7-B-NOPF-ALLNOTRD & 0MUL"));
+//   triggers->Add(new TObjString("CMSL7-B-NOPF-ALLNOTRD & 0MSH"));
+  }
+
+  TString outputname("test.MuMu.AOD.1.root");
+  
+  if ( sds.Length()>0 ) 
+  {
+       TString af("local");
+       
+       if ( gProof )
+       {
+         af="unknown";
+         TString master(gProof->GetSessionTag());
+      if (master.Contains("lx")) af = "caf";
+      if (master.Contains("nansaf")) af = "saf";
+      if (master.Contains("skaf")) af = "skaf";
+      if (master.Contains("localhost:2093")) af="laf";
+       }
+       outputname = Form("%s.%s.root",gSystem->BaseName(sds.Data()),af.Data());
+    outputname.ReplaceAll("|","-");
+       cout << outputname << endl;
+  }
+
+  AliAnalysisTask* task(0x0);
+
+  if (!baseline)
+  {  
+       gROOT->LoadMacro("AddTaskMuMu.C");
+
+       task = AddTaskMuMu(outputname.Data(),triggers,"pA",simulations);
+  }
+  else
+  {
+       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddTaskBaseLine.C");
+       task = AddTaskBaseLine();
+  }
+  
+  if (!mgr->InitAnalysis()) 
+  {
+       cout << "Could not InitAnalysis" << endl;
+    return 0;
+  }
+  
+  if ( sds.Length()>0 )
+  {
+    TStopwatch timer;
+    
+    mgr->StartAnalysis("proof",sds.Data());
+    
+    timer.Print();
+  }
+  else
+  {
+    mgr->PrintStatus();
+  
+       task->Print();
+       
+//     return task;
+       
+    TChain* c = CreateLocalChain("list.aod.txt");
+//     mgr->SetNSysInfo(10);
+    TStopwatch timer;
+//    mgr->SetDebugLevel(10);
+    mgr->StartAnalysis("local",c);
+    timer.Print();
+//    mgr->ProfileTask("AliAnalysisTaskMuMu");
+//    if (baseline) mgr->ProfileTask("baseline");
+  }
+  
+  AliCodeTimer::Instance()->Print();
+  
+  if (alirootMode=="PAR")
+  {
+    TProofLog *pl = TProof::Mgr(where)->GetSessionLogs(); pl->Save("*","aod.log");
+  }
+  
+  delete triggers;
+  
+  return task;
+}
+
index e0ee87bdff4399598f42f3482bb4a3a979be42da..13d00109d7ae626946b6ec96534bf67e22f90502 100644 (file)
@@ -1574,7 +1574,7 @@ AliAnalysisMuMu::FitParticle(const char* particle,
     
     if (!hminv)
     {
-      if (!fBinning && bin->IsNullObject() )
+      if (!fBinning && bin->IsIntegrated() )
       {
         // old file, we only had MinvUSPt
         hminv = fMergeableCollection->Histo(Form("/%s/%s/%s/%s",eventType,trigger,centrality,pairCut),"MinvUSPt:py");
@@ -1665,11 +1665,11 @@ AliAnalysisMuMu::GetMCCB2Tails(const AliAnalysisMuMuBinning::Range& bin) const
   }
 
 
-  AliAnalysisMuMuSpectra* s = static_cast<AliAnalysisMuMuSpectra*>(SIM()->GetSpectra(bin.Type().Data(),bin.Flavour().Data()));
+  AliAnalysisMuMuSpectra* s = static_cast<AliAnalysisMuMuSpectra*>(SIM()->GetSpectra(bin.Quantity().Data(),bin.Flavour().Data()));
   
   if (!s)
   {
-    AliError(Form("Could not find spectra %s,%s for associated simulation",bin.Type().Data(),bin.Flavour().Data()));
+    AliError(Form("Could not find spectra %s,%s for associated simulation",bin.Quantity().Data(),bin.Flavour().Data()));
     fAssociatedSimulation->MC()->Print("*:Ali*");
     return par;
   }
@@ -3274,7 +3274,7 @@ AliAnalysisMuMuSpectra* AliAnalysisMuMu::RABy(const char* realFile, const char*
     Double_t ylowcms, yhighcms;
     Double_t ylownorm, yhighnorm;
     
-    if ( bin->IsNullObject() )
+    if ( bin->IsIntegrated() )
     {
       ylowlab = -4;
       yhighlab = -2.5;
@@ -3330,7 +3330,7 @@ AliAnalysisMuMuSpectra* AliAnalysisMuMu::RABy(const char* realFile, const char*
     r->Set("NofInputJpsi",rsim->GetValue("NofInputJpsi",accEffSubResultName),rsim->GetErrorStat("NofInputJpsi",accEffSubResultName));
     r->Set("AccEffJpsi",rsim->GetValue("AccEffJpsi",accEffSubResultName),rsim->GetErrorStat("AccEffJpsi",accEffSubResultName));
     
-    AliAnalysisMuMuBinning::Range* bincm = new AliAnalysisMuMuBinning::Range(bin->Particle(),bin->Type(),ylowcms,yhighcms);
+    AliAnalysisMuMuBinning::Range* bincm = new AliAnalysisMuMuBinning::Range(bin->What(),bin->Quantity(),ylowcms,yhighcms);
     
     r->SetBin(*bincm);
         
index ac8673a2616cd9b95360e452d37ef2995a2c19d4..eadabaee310611449b99755c5a523531caabf706 100644 (file)
@@ -151,8 +151,8 @@ Bool_t AliAnalysisMuMuSpectra::Correct(const AliAnalysisMuMuSpectra& accEff, con
     return kFALSE;
   }
   
-  TObjArray* particles = fBinning->CreateParticleArray();
-  TObjArray* types = fBinning->CreateTypeArray();
+  TObjArray* particles = fBinning->CreateWhatArray();
+  TObjArray* types = fBinning->CreateQuantityArray();
   
   if (particles->GetEntries()!=1 || types->GetEntries()!=1 )
   {
index 4207b8a3211df3c006c2b76c9706a29147d281a2..1dfd7b3a122a41828d4e058b4c927c1601db4aeb 100644 (file)
@@ -1778,7 +1778,7 @@ void AliAnalysisTriggerScalers::Print(Option_t* /* opt */) const
 
 //______________________________________________________________________________
 void AliAnalysisTriggerScalers::PrintIntegers(const std::vector<int>& integers,
-                                              const char sep,
+                                              char sep,
                                               std::ostream& out)
 {
   /// print a list of integers
index 2d94ce8dd71e656c640dd6336a24928323cc259d..29debe7c4f4a2d588be2e78a7b50e376dc41c053 100644 (file)
@@ -122,7 +122,7 @@ public:
   
   static void ReadIntegers(const char* filename, std::vector<int>& integers, Bool_t resetVector=kTRUE);
   
-  static void PrintIntegers(const std::vector<int>& integers, const char sep = '\n',
+  static void PrintIntegers(const std::vector<int>& integers, char sep = '\n',
                             std::ostream& out = std::cout);
   
   
index a53a29014b20876edd45534527f32d4d0cf26eca..1b6ef84245901e251694828695e88cb9d5140488 100644 (file)
@@ -28,6 +28,7 @@
 
 set ( SRCS  
     Correlations/DPhi/AliAnalysisTaskDptDptCorrelations.cxx
+    Correlations/DPhi/AliDptDptInMC.cxx
     Correlations/DPhi/AliAnalysisTask3PCorrelations.cxx 
     Correlations/DPhi/AliAnalysisTaskPhiCorrelations.cxx 
     Correlations/DPhi/AliPhiCorrelationsQATask.cxx 
index 97d2177ba0994b21a72c7776b40ebdf32b0ff084..1f9262596b0ad78904389f08ab61283c5d152faf 100644 (file)
@@ -153,6 +153,7 @@ void AliAnalyseLeadingTrackUE::DefineESDCuts(Int_t filterbit) {
     fEsdTrackCuts->SetDCAToVertex2D(kTRUE);
     fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
     fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
+    fEsdTrackCuts->SetMaxFractionSharedTPCClusters(0.4);
 
     // Add SPD requirement 
     fEsdTrackCutsExtra1 = new AliESDtrackCuts("SPD", "Require 1 cluster in SPD");
index fcd1fde8e96d4d711e517a6c6cdcfc9dc4e166ac..15a38bc070f6715b9ce58ad5f29d4aaf46ee3d9d 100644 (file)
@@ -886,8 +886,10 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
   
   THnBase* trackSameAll = 0;
   THnBase* trackMixedAll = 0;
+  THnBase* trackMixedAllStep6 = 0;
   TH2* eventSameAll = 0;
   TH2* eventMixedAll = 0;
+  TH2* eventMixedAllStep6 = 0;
   
   Long64_t totalEvents = 0;
   Int_t nCorrelationFunctions = 0;
@@ -895,6 +897,16 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
   GetHistsZVtxMult(step, region, ptLeadMin, ptLeadMax, &trackSameAll, &eventSameAll);
   mixed->GetHistsZVtxMult(step, region, ptLeadMin, ptLeadMax, &trackMixedAll, &eventMixedAll);
   
+  // If we ask for histograms from step8 (TTR cut applied) there is a hole at 0,0; so this cannot be used for the
+  // mixed-event normalization. If step6 is available, the normalization factor is read out from that one.
+  // If step6 is not available we fallback to taking the normalization along all delta phi (WARNING requires a
+  // flat delta phi distribution)
+  if (step == kCFStepBiasStudy && mixed->fEventHist->GetGrid(kCFStepReconstructed)->GetEntries() > 0 && !fSkipScaleMixedEvent)
+  {
+    Printf("Using mixed-event normalization factors from step %d", kCFStepReconstructed);
+    mixed->GetHistsZVtxMult(kCFStepReconstructed, region, ptLeadMin, ptLeadMax, &trackMixedAllStep6, &eventMixedAllStep6);
+  }
+  
 //   Printf("%f %f %f %f", trackSameAll->GetEntries(), eventSameAll->GetEntries(), trackMixedAll->GetEntries(), eventMixedAll->GetEntries());
   
 //   TH1* normParameters = new TH1F("normParameters", "", 100, 0, 2);
@@ -913,6 +925,8 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
   {
     trackSameAll->GetAxis(3)->SetRange(multBin, multBin);
     trackMixedAll->GetAxis(3)->SetRange(multBin, multBin);
+    if (trackMixedAllStep6)
+      trackMixedAllStep6->GetAxis(3)->SetRange(multBin, multBin);
 
     Double_t mixedNorm = 1;
     Double_t mixedNormError = 0;
@@ -920,17 +934,27 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
     if (!fSkipScaleMixedEvent)
     {
       // get mixed normalization correction factor: is independent of vertex bin if scaled with number of triggers
-      trackMixedAll->GetAxis(2)->SetRange(0, -1);
-      TH2* tracksMixed = trackMixedAll->Projection(1, 0, "E");
+      TH2* tracksMixed = 0;
+      if (trackMixedAllStep6)
+      {
+       trackMixedAllStep6->GetAxis(2)->SetRange(0, -1);
+       tracksMixed = trackMixedAllStep6->Projection(1, 0, "E");
+      }
+      else
+      {
+       trackMixedAll->GetAxis(2)->SetRange(0, -1);
+       tracksMixed = trackMixedAll->Projection(1, 0, "E");
+      }
   //     Printf("%f", tracksMixed->Integral());
       Float_t binWidthEta = tracksMixed->GetYaxis()->GetBinWidth(1);
     
-      if (1)
+      if (step == kCFStepBiasStudy && !trackMixedAllStep6)
       {
        // get mixed event normalization by assuming full acceptance at deta at 0 (integrate over dphi), excluding (0, 0)
-       mixedNorm = tracksMixed->IntegralAndError(1, tracksMixed->GetYaxis()->FindBin(-0.01)-1, tracksMixed->GetYaxis()->FindBin(-0.01), tracksMixed->GetYaxis()->FindBin(0.01), mixedNormError);
+       Float_t phiExclude = 0.41;
+       mixedNorm = tracksMixed->IntegralAndError(1, tracksMixed->GetXaxis()->FindBin(-phiExclude)-1, tracksMixed->GetYaxis()->FindBin(-0.01), tracksMixed->GetYaxis()->FindBin(0.01), mixedNormError);
        Double_t mixedNormError2 = 0;
-       Double_t mixedNorm2 = tracksMixed->IntegralAndError(tracksMixed->GetYaxis()->FindBin(0.01)+1, tracksMixed->GetNbinsX(), tracksMixed->GetYaxis()->FindBin(-0.01), tracksMixed->GetYaxis()->FindBin(0.01), mixedNormError2);
+       Double_t mixedNorm2 = tracksMixed->IntegralAndError(tracksMixed->GetXaxis()->FindBin(phiExclude)+1, tracksMixed->GetNbinsX(), tracksMixed->GetYaxis()->FindBin(-0.01), tracksMixed->GetYaxis()->FindBin(0.01), mixedNormError2);
       
        if (mixedNormError == 0 || mixedNormError2 == 0)
        {
@@ -938,11 +962,11 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
          continue;
        }
        
-       Int_t nBinsMixedNorm = (tracksMixed->GetYaxis()->FindBin(-0.01) - 1 - 1 + 1) * (tracksMixed->GetYaxis()->FindBin(0.01) - tracksMixed->GetYaxis()->FindBin(-0.01) + 1);
+       Int_t nBinsMixedNorm = (tracksMixed->GetXaxis()->FindBin(-phiExclude) - 1 - 1 + 1) * (tracksMixed->GetYaxis()->FindBin(0.01) - tracksMixed->GetYaxis()->FindBin(-0.01) + 1);
        mixedNorm /= nBinsMixedNorm;
        mixedNormError /= nBinsMixedNorm;
 
-       Int_t nBinsMixedNorm2 = (tracksMixed->GetNbinsX() - tracksMixed->GetYaxis()->FindBin(0.01) - 1 + 1) * (tracksMixed->GetYaxis()->FindBin(0.01) - tracksMixed->GetYaxis()->FindBin(-0.01) + 1);
+       Int_t nBinsMixedNorm2 = (tracksMixed->GetNbinsX() - tracksMixed->GetXaxis()->FindBin(phiExclude) - 1 + 1) * (tracksMixed->GetYaxis()->FindBin(0.01) - tracksMixed->GetYaxis()->FindBin(-0.01) + 1);
        mixedNorm2 /= nBinsMixedNorm2;
        mixedNormError2 /= nBinsMixedNorm2;
 
@@ -1006,8 +1030,16 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
 //     normParameters->Fill(mixedNorm);
       
     TAxis* vertexAxis = trackSameAll->GetAxis(2);
-    for (Int_t vertexBin = 1; vertexBin <= vertexAxis->GetNbins(); vertexBin++)
-//     for (Int_t vertexBin = 5; vertexBin <= 6; vertexBin++)
+    Int_t vertexBinBegin = 1;
+    Int_t vertexBinEnd = vertexAxis->GetNbins();
+    
+    if (fZVtxMax > fZVtxMin)
+    {
+      vertexBinBegin = vertexAxis->FindBin(fZVtxMin);
+      vertexBinEnd = vertexAxis->FindBin(fZVtxMax);
+    }
+    
+    for (Int_t vertexBin = vertexBinBegin; vertexBin <= vertexBinEnd; vertexBin++)
     {
       trackSameAll->GetAxis(2)->SetRange(vertexBin, vertexBin);
       trackMixedAll->GetAxis(2)->SetRange(vertexBin, vertexBin);
@@ -1120,8 +1152,10 @@ TH2* AliUEHist::GetSumOfRatios2(AliUEHist* mixed, AliUEHist::CFStep step, AliUEH
   
   delete trackSameAll;
   delete trackMixedAll;
+  delete trackMixedAllStep6;
   delete eventSameAll;
   delete eventMixedAll;
+  delete eventMixedAllStep6;
   
 //   new TCanvas; normParameters->Draw();
   
@@ -1140,6 +1174,12 @@ TH1* AliUEHist::GetTriggersAsFunctionOfMultiplicity(AliUEHist::CFStep step, Floa
   Int_t lastBin = fEventHist->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(ptLeadMax);
   Printf("Using pT range %d --> %d", firstBin, lastBin);
   fEventHist->GetGrid(step)->GetGrid()->GetAxis(0)->SetRange(firstBin, lastBin);
+
+  if (fZVtxMax > fZVtxMin)
+  {
+    fEventHist->GetGrid(step)->GetGrid()->GetAxis(2)->SetRangeUser(fZVtxMin, fZVtxMax);
+    Printf("Restricting z-vtx: %f-%f", fZVtxMin, fZVtxMax);
+  }
   
   TH1* eventHist = fEventHist->GetGrid(step)->Project(1);
 
index afe7547444553219dcb2edf039a7d8e1d74f09ca..edb83065683f02617066882d81ccd39b6fe8b707 100644 (file)
@@ -143,8 +143,8 @@ protected:
   void WeightHistogram(TH3* hist1, TH1* hist2);
   void MultiplyHistograms(THnSparse* grid, THnSparse* target, TH1* histogram, Int_t var1, Int_t var2);
 
-  AliCFContainer* fTrackHist[4];      // container for track level distributions in four regions (toward, away, min, max) and at four analysis steps
-  AliCFContainer* fEventHist;         // container for event level distribution at four analysis steps
+  AliCFContainer* fTrackHist[4];      // container for track level distributions in four regions (toward, away, min, max) and at all analysis steps
+  AliCFContainer* fEventHist;         // container for event level distribution at all analysis steps
   AliCFContainer* fTrackHistEfficiency; // container for tracking efficiency and contamination (all particles filled including leading one): axes: eta, pT, particle species
   TH3F* fFakePt;
  
index e4bb3c7dccfa8741d732ff4878050ecbb731d249..61b896f22f9cb708df5eb6fecb1d029f6d5edeab 100644 (file)
@@ -52,6 +52,7 @@ AliUEHistograms::AliUEHistograms(const char* name, const char* histograms, const
   fCorrelationLeading2Phi(0),
   fCorrelationMultiplicity(0),
   fYields(0),
+  fInvYield2(0),
   fEventCount(0),
   fEventCountDifferential(0),
   fVertexContributors(0),
@@ -178,6 +179,7 @@ AliUEHistograms::AliUEHistograms(const char* name, const char* histograms, const
   fCorrelationLeading2Phi = new TH2F("fCorrelationLeading2Phi", ";#Delta #varphi;p_{T,lead} (MC)", 200, -TMath::Pi(), TMath::Pi(), 200, 0, 50);
   fCorrelationMultiplicity = new TH2F("fCorrelationMultiplicity", ";MC tracks;Reco tracks", 100, -0.5, 99.5, 100, -0.5, 99.5);
   fYields = new TH3F("fYields", ";centrality;pT;eta", 100, 0, 100, 40, 0, 20, 100, -1, 1);
+  fInvYield2 = new TH2F("fInvYield2", ";centrality;pT;1/pT dNch/dpT", 100, 0, 100, 80, 0, 20);
 
   if (!histogramsStr.Contains("4") && !histogramsStr.Contains("5") && !histogramsStr.Contains("6"))
   {
@@ -224,6 +226,7 @@ AliUEHistograms::AliUEHistograms(const AliUEHistograms &c) :
   fCorrelationLeading2Phi(0),
   fCorrelationMultiplicity(0),
   fYields(0),
+  fInvYield2(0),
   fEventCount(0),
   fEventCountDifferential(0),
   fVertexContributors(0),
@@ -328,6 +331,12 @@ void AliUEHistograms::DeleteContainers()
     fYields = 0;
   }
   
+  if (fInvYield2)
+  {
+    delete fInvYield2;
+    fInvYield2 = 0;
+  }
+  
   if (fEventCount)
   {
     delete fEventCount;
@@ -931,6 +940,10 @@ void AliUEHistograms::FillCorrelations(Double_t centrality, Float_t zVtx, AliUEH
          effVars[3] = fEfficiencyCorrectionTriggers->GetAxis(3)->FindBin(vars[2]); //zVtx
          useWeight *= fEfficiencyCorrectionTriggers->GetBinContent(effVars);
        }
+
+       if (TMath::Abs(triggerEta) < 0.8 && triggerParticle->Pt() > 0)
+         fInvYield2->Fill(centrality, triggerParticle->Pt(), useWeight / triggerParticle->Pt());
+
        if (fWeightPerEvent)
        {
          // leads effectively to a filling of one entry per filled trigger particle pT bin
@@ -946,7 +959,7 @@ void AliUEHistograms::FillCorrelations(Double_t centrality, Float_t zVtx, AliUEH
         fCorrelationEta->Fill(centrality, triggerEta);
         fCorrelationPhi->Fill(centrality, triggerParticle->Phi());
        fYields->Fill(centrality, triggerParticle->Pt(), triggerEta);
-
+       
 /*        if (dynamic_cast<AliAODTrack*>(triggerParticle))
           fITSClusterMap->Fill(((AliAODTrack*) triggerParticle)->GetITSClusterMap(), centrality, triggerParticle->Pt());*/
       }
@@ -1195,6 +1208,9 @@ void AliUEHistograms::Copy(TObject& c) const
   if (fYields)
     target.fYields = dynamic_cast<TH3F*> (fYields->Clone());
   
+  if (fInvYield2)
+    target.fInvYield2 = dynamic_cast<TH2F*> (fInvYield2->Clone());
+  
   if (fEventCount)
     target.fEventCount = dynamic_cast<TH2F*> (fEventCount->Clone());
 
@@ -1259,7 +1275,7 @@ Long64_t AliUEHistograms::Merge(TCollection* list)
   TObject* obj;
 
   // collections of objects
-  const Int_t kMaxLists = 19;
+  const Int_t kMaxLists = 20;
   TList* lists[kMaxLists];
   
   for (Int_t i=0; i<kMaxLists; i++)
@@ -1297,8 +1313,10 @@ Long64_t AliUEHistograms::Merge(TCollection* list)
       lists[16]->Add(entry->fCentralityCorrelation);
     if (entry->fYields)
       lists[17]->Add(entry->fYields);
+    if (entry->fInvYield2)
+      lists[18]->Add(entry->fInvYield2);
     if (entry->fControlConvResoncances)
-      lists[18]->Add(entry->fControlConvResoncances);
+      lists[19]->Add(entry->fControlConvResoncances);
 
     fMergeCount += entry->fMergeCount;
 
@@ -1330,8 +1348,10 @@ Long64_t AliUEHistograms::Merge(TCollection* list)
     fCentralityCorrelation->Merge(lists[16]);
   if (fYields && lists[17]->GetEntries() > 0)
     fYields->Merge(lists[17]);
-  if (fControlConvResoncances && lists[18]->GetEntries() > 0)
-    fControlConvResoncances->Merge(lists[18]);
+  if (fInvYield2 && lists[18]->GetEntries() > 0)
+    fInvYield2->Merge(lists[18]);
+  if (fControlConvResoncances && lists[19]->GetEntries() > 0)
+    fControlConvResoncances->Merge(lists[19]);
   
   for (Int_t i=0; i<kMaxLists; i++)
     delete lists[i];
@@ -1382,6 +1402,7 @@ void AliUEHistograms::Scale(Double_t factor)
   list.Add(fCorrelationLeading2Phi);
   list.Add(fCorrelationMultiplicity);
   list.Add(fYields);
+  list.Add(fInvYield2);
   list.Add(fEventCount);
   list.Add(fEventCountDifferential);
   list.Add(fVertexContributors);
index 5c969b8ca543d4abc39bad830fed88510292a56a..8748088a2f195cdd3e30919361152cdd5576e53e 100644 (file)
@@ -61,6 +61,7 @@ class AliUEHistograms : public TNamed
   TH2F* GetCorrelationLeading2Phi() { return fCorrelationLeading2Phi; }
   TH2F* GetCorrelationMultiplicity() { return fCorrelationMultiplicity; }
   TH3F* GetYield() { return fYields; }
+  TH2F* GetInvYield() { return fInvYield2; }
   
   TH2F* GetEventCount()     { return fEventCount; }
   TH3F* GetEventCountDifferential() { return fEventCountDifferential; }
@@ -124,6 +125,7 @@ protected:
   TH2F* fCorrelationLeading2Phi;// delta phi (true vs reco) vs pT,lead,MC
   TH2F* fCorrelationMultiplicity; // number of mc particls vs reco particles (for pT > 0.5 GeV/c)
   TH3F* fYields;                // centrality vs pT vs eta
+  TH2F* fInvYield2;            // invariant yield as cross check of tracking
   
   TH2F* fEventCount;            // event count as function of step, (for pp: event type (plus additional step -1 for all events without vertex range even in MC)) (for PbPb: centrality)
   TH3F* fEventCountDifferential;// event count as function of leading pT, step, event type
@@ -157,7 +159,7 @@ protected:
   
   Int_t fMergeCount;           // counts how many objects have been merged together
   
-  ClassDef(AliUEHistograms, 27)  // underlying event histogram container
+  ClassDef(AliUEHistograms, 29)  // underlying event histogram container
 };
 
 Float_t AliUEHistograms::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)
index 1509fe3ee4b7fa4ae4ab9657c343d9036b2f84a4..496de0e1d966ab5c00f5ce988b74b14fa969bd25 100644 (file)
@@ -100,6 +100,7 @@ fUseVtxAxis(kFALSE),
 fCourseCentralityBinning(kFALSE),
 fSkipTrigger(kFALSE),
 fInjectedSignals(kFALSE),
+fRandomizeReactionPlane(kFALSE),
 fHelperPID(0x0),
 fAnalysisUtils(0x0),
 fMap(0x0),
@@ -430,7 +431,8 @@ void  AliAnalysisTaskPhiCorrelations::AddSettingsTree()
   settingsTree->Branch("fFillpT", &fFillpT,"FillpT/O");
   settingsTree->Branch("fMixingTracks", &fMixingTracks,"MixingTracks/I");
   settingsTree->Branch("fSkipTrigger", &fSkipTrigger,"SkipTrigger/O");
-  settingsTree->Branch("fInjectedSignals", &fInjectedSignals,"SkipTrigger/O");
+  settingsTree->Branch("fInjectedSignals", &fInjectedSignals,"InjectedSignals/O");
+  settingsTree->Branch("fRandomizeReactionPlane", &fRandomizeReactionPlane,"RandomizeReactionPlane/O");
   settingsTree->Branch("fRejectCentralityOutliers", &fRejectCentralityOutliers,"RejectCentralityOutliers/O");
   settingsTree->Branch("fRejectZeroTrackEvents", &fRejectZeroTrackEvents,"RejectZeroTrackEvents/O");
   settingsTree->Branch("fRemoveWeakDecays", &fRemoveWeakDecays,"RemoveWeakDecays/O");
@@ -606,6 +608,13 @@ void  AliAnalysisTaskPhiCorrelations::AnalyseCorrectionMode()
     AliInfo(Form("Injected signals in this event (%d headers). Keeping particles/tracks of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
   }
   
+  if (fCentralityWeights && !AcceptEventCentralityWeight(centrality))
+  {
+    AliInfo(Form("Rejecting event because of centrality weighting: %f", centrality));
+    fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
+    return;
+  }
+  
   // Get MC primaries
   // triggers
   TObjArray* tmpList = fAnalyseUE->GetAcceptedParticles(mc, 0, kTRUE, fParticleSpeciesTrigger, kTRUE);
@@ -623,6 +632,16 @@ void  AliAnalysisTaskPhiCorrelations::AnalyseCorrectionMode()
     delete tmpList;
   }
   
+  if (fRandomizeReactionPlane)
+  {
+    Double_t centralityDigits = centrality*1000. - (Int_t)(centrality*1000.);
+    Double_t angle = TMath::TwoPi() * centralityDigits;
+    AliInfo(Form("Shifting phi of all tracks by %f (digits %f)", angle, centralityDigits));
+    ShiftTracks(tracksMC, angle);
+    if (tracksCorrelateMC != tracksMC)
+      ShiftTracks(tracksCorrelateMC, angle);
+  }
+  
   if (fFillOnlyStep0)
     zVtx = 0;
   
@@ -1410,3 +1429,21 @@ Bool_t AliAnalysisTaskPhiCorrelations::AcceptEventCentralityWeight(Double_t cent
   
   return result;
 }
+
+//____________________________________________________________________
+void AliAnalysisTaskPhiCorrelations::ShiftTracks(TObjArray* tracks, Double_t angle)
+{
+  // shifts the phi angle of all tracks by angle
+  // 0 <= angle <= 2pi
+  
+  for (Int_t i=0; i<tracks->GetEntriesFast(); ++i) 
+  {
+    AliDPhiBasicParticle* part = (AliDPhiBasicParticle*) tracks->At(i);
+    Double_t newAngle = part->Phi() + angle; 
+    if (newAngle >= TMath::TwoPi())
+      newAngle -= TMath::TwoPi();
+    
+    part->SetPhi(newAngle);
+  }
+}
+  
\ No newline at end of file
index 045c6eef2aeca0a3c1c9d1d1f14711cdcc27bbe0..9434945dd7c33dacdbd32d034a8a45651f89843e 100644 (file)
@@ -76,6 +76,7 @@ class  AliAnalysisTaskPhiCorrelations : public AliAnalysisTask
     virtual    void    SetCourseCentralityBinning(Bool_t flag) { fCourseCentralityBinning = flag; }
     virtual     void    SetSkipTrigger(Bool_t flag) { fSkipTrigger = flag; }
     virtual     void    SetInjectedSignals(Bool_t flag) { fInjectedSignals = flag; }
+    void SetRandomizeReactionPlane(Bool_t flag) { fRandomizeReactionPlane = flag; }
     
     // histogram settings
     void SetEfficiencyCorrectionTriggers(THnF* hist) { fEfficiencyCorrectionTriggers = hist; }
@@ -144,12 +145,13 @@ class  AliAnalysisTaskPhiCorrelations : public AliAnalysisTask
     void SelectCharge(TObjArray* tracks);
     AliGenEventHeader* GetFirstHeader();
     Bool_t AcceptEventCentralityWeight(Double_t centrality);
+    void ShiftTracks(TObjArray* tracks, Double_t angle);
 
     // General configuration
     Int_t               fDebug;           //  Debug flag
     Int_t              fMode;            //  fMode = 0: data-like analysis 
                                          //  fMode = 1: corrections analysis   
-    Bool_t             fReduceMemoryFootprint; // reduce memory consumption by writing less debug histograms
+    Bool_t              fReduceMemoryFootprint; // reduce memory consumption by writing less debug histograms
     Bool_t             fFillMixed;             // enable event mixing (default: ON)
     Int_t              fMixingTracks;          // size of track buffer for event mixing
     Bool_t             fTwoTrackEfficiencyStudy; // two-track efficiency study on
@@ -159,6 +161,7 @@ class  AliAnalysisTaskPhiCorrelations : public AliAnalysisTask
     Bool_t             fCourseCentralityBinning; // less centrality bins
     Bool_t             fSkipTrigger;             // skip trigger selection
     Bool_t             fInjectedSignals;         // check header to skip injected signals in MC
+    Bool_t             fRandomizeReactionPlane;  // change the orientation of the RP by a random value by shifting all tracks
     
     AliHelperPID*     fHelperPID;      // points to class for PID
     AliAnalysisUtils*     fAnalysisUtils;      // points to class with common analysis utilities
@@ -228,7 +231,7 @@ class  AliAnalysisTaskPhiCorrelations : public AliAnalysisTask
     
     Bool_t fFillpT;                // fill sum pT instead of number density
     
-    ClassDef(AliAnalysisTaskPhiCorrelations, 41); // Analysis task for delta phi correlations
+    ClassDef(AliAnalysisTaskPhiCorrelations, 42); // Analysis task for delta phi correlations
   };
 
 class AliDPhiBasicParticle : public AliVParticle
@@ -272,6 +275,8 @@ class AliDPhiBasicParticle : public AliVParticle
     
     virtual Bool_t IsEqual(const TObject* obj) const { return (obj->GetUniqueID() == GetUniqueID()); }
     
+    virtual void SetPhi(Double_t phi) { fPhi = phi; }
+    
   private:
     Float_t fEta;      // eta
     Float_t fPhi;      // phi
diff --git a/PWGCF/Correlations/DPhi/AliDptDptInMC.cxx b/PWGCF/Correlations/DPhi/AliDptDptInMC.cxx
new file mode 100644 (file)
index 0000000..4b2a63b
--- /dev/null
@@ -0,0 +1,2247 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/* $Id:$ */
+
+#include "TChain.h"
+#include "TList.h"
+#include "TFile.h"
+#include "TTree.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TH3D.h"
+#include "THnSparse.h"
+#include "TCanvas.h"
+
+#include <TROOT.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TMath.h>
+#include <TTree.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TH3F.h>
+#include <TProfile.h>
+#include <TH1D.h>
+#include <TH2D.h>
+#include <TH3D.h>
+#include <TRandom.h>
+#include "AliAnalysisManager.h"
+
+#include "AliAODHandler.h"
+#include "AliAODInputHandler.h"
+#include "AliInputEventHandler.h"
+#include "AliLog.h"
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMultiplicity.h"
+#include "AliCentrality.h"
+#include "AliDptDptInMC.h"
+
+#include "AliPID.h"
+#include "AliPIDResponse.h"
+
+#include "AliESDVertex.h"
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliAODEvent.h"
+#include "AliAODTrack.h"
+#include "AliAODInputHandler.h"
+#include "AliESD.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliStack.h"
+#include "AliESDtrackCuts.h"
+#include "AliAODMCHeader.h"
+#include "AliAODMCParticle.h"
+#include "AliAODMCParticle.h"
+#include "AliAODMCHeader.h"
+#include "AliAODHeader.h"
+
+#include "AliGenHijingEventHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliPID.h"
+#include "AliAODPid.h"
+#include "AliPIDResponse.h"
+#include "AliAODpidUtil.h"
+#include "AliPIDCombined.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliDptDptInMC)
+
+AliDptDptInMC::AliDptDptInMC()
+: AliAnalysisTaskSE(),
+fAODEvent(0), 
+fESDEvent(0),             //! ESD Event
+fInputHandler(0),
+fPIDResponse(0x0),
+_outputHistoList(0),
+fArrayMC (0),
+_twoPi         ( 2.0 * 3.1415927),
+_eventCount    ( 0), 
+_debugLevel    ( 0),
+_singlesOnly   ( 0), 
+_useWeights    ( 0), 
+_sameFilter    ( false),
+_rejectPileup  ( 1), 
+_rejectPairConversion ( 0), 
+_vertexZMin           ( -10), 
+_vertexZMax           (  10), 
+_vertexXYMin          ( -10),
+_vertexXYMax          (  10),
+_centralityMethod     (  4),
+_centralityMin        (  0.),
+_centralityMax        (  0.),
+_requestedCharge_1    (   1),
+_requestedCharge_2    (  -1),
+_dcaZMin              ( -3), 
+_dcaZMax              (  3.), 
+_dcaXYMin             ( -2.4), 
+_dcaXYMax             (  2.4),
+_dedxMin              ( 0),
+_dedxMax              ( 100000),
+_nClusterMin          ( 80), 
+_trackFilterBit       (0),
+fNSigmaCut            (3.),
+fAnalysisType ("AOD"),
+fExcludeResonancesInMC (kFALSE),
+fExcludeElectronsInMC (kFALSE), 
+_field    ( 1.),
+_nTracks  ( 0 ),
+_mult0    ( 0 ),
+_mult1    ( 0 ),
+_mult2    ( 0 ),
+_mult3    ( 0 ),
+_mult4    ( 0 ),
+_mult4a    ( 0 ),
+_mult5    ( 0 ),
+_mult6    ( 0 ),
+arraySize ( 2000),
+_id_1(0),       
+_charge_1(0),    
+_iEtaPhi_1(0),    
+_iPt_1(0),     
+_pt_1(0),       
+_px_1(0),      
+_py_1(0),      
+_pz_1(0),      
+_correction_1(0),   
+_dedx_1(0),   
+_id_2(0),      
+_charge_2(0),    
+_iEtaPhi_2(0),    
+_iPt_2(0),     
+_pt_2(0),      
+_px_2(0),      
+_py_2(0),      
+_pz_2(0),      
+_correction_2(0),   
+_dedx_2(0),   
+_correctionWeight_1(0),   
+_correctionWeight_2(0),
+_nBins_M0(500),       _min_M0(0),        _max_M0(10000),          _width_M0(20),
+_nBins_M1(500),       _min_M1(0),        _max_M1(10000),          _width_M1(20),
+_nBins_M2(500),       _min_M2(0),        _max_M2(10000),          _width_M2(20),
+_nBins_M3(500),       _min_M3(0),        _max_M3(10000),          _width_M3(20),
+_nBins_M4(100),       _min_M4(0),        _max_M4(1),              _width_M4(0.01),
+_nBins_M5(100),       _min_M5(0),        _max_M5(1),              _width_M5(0.01),
+_nBins_M6(100),       _min_M6(0),        _max_M6(1),              _width_M6(0.01),
+_nBins_vertexZ(40),   _min_vertexZ(-10), _max_vertexZ(10),        _width_vertexZ(0.5),
+
+_nBins_pt_1(18),      _min_pt_1(0.2),    _max_pt_1(2.0),          _width_pt_1(0.1),
+_nBins_phi_1(72),     _min_phi_1(0),     _max_phi_1(2.*3.1415927),_width_phi_1(2.*3.1415927/72.),
+//_nBins_eta_1(18),    
+//_min_eta_1(-0.9),  _max_eta_1(0.9),           _width_eta_1(0.1),
+  _nBins_eta_1(0),    
+  _min_eta_1(0),  _max_eta_1(0),           _width_eta_1(0.1),
+
+_nBins_etaPhi_1(0), 
+_nBins_etaPhiPt_1(0),
+_nBins_zEtaPhiPt_1(0),
+
+_nBins_pt_2(18),     _min_pt_2(0.2),     _max_pt_2(2.0),          _width_pt_2(0.1),
+_nBins_phi_2(72),    _min_phi_2(0),      _max_phi_2(2.*3.1415927),_width_phi_2(2.*3.1415927/72),
+//_nBins_eta_2(18),    
+//_min_eta_2(-0.9),     _max_eta_2(0.9),           _width_eta_2(0.1),
+  _nBins_eta_2(0),    
+  _min_eta_2(0),     _max_eta_2(0),           _width_eta_2(0.1),
+
+
+
+_nBins_etaPhi_2(0), 
+_nBins_etaPhiPt_2(0),
+_nBins_zEtaPhiPt_2(0),
+_nBins_etaPhi_12(0),
+__n1_1(0),
+__n1_2(0),
+__n2_12(0),   
+__s1pt_1(0),
+__s1pt_2(0),
+__s2ptpt_12(0),
+__s2NPt_12(0),
+__s2PtN_12(0),
+__n1Nw_1(0),
+__n1Nw_2(0),
+__n2Nw_12(0),   
+__s1ptNw_1(0),
+__s1ptNw_2(0),
+__s2ptptNw_12(0),
+__s2NPtNw_12(0),
+__s2PtNNw_12(0),
+__n1_1_vsPt(0),
+__n1_1_vsEtaPhi(0), 
+__s1pt_1_vsEtaPhi(0),
+__n1_1_vsZEtaPhiPt(0),
+__n1_2_vsPt(0),
+__n1_2_vsEtaPhi(0), 
+__s1pt_2_vsEtaPhi(0),
+__n1_2_vsZEtaPhiPt(0),
+__n2_12_vsPtPt(0),
+__n2_12_vsEtaPhi(0),
+__s2ptpt_12_vsEtaPhi(0),
+__s2PtN_12_vsEtaPhi(0),
+__s2NPt_12_vsEtaPhi(0),
+_weight_1      ( 0    ),
+_weight_2      ( 0    ),
+_eventAccounting ( 0),
+_m0 ( 0),
+_m1 ( 0),
+_m2 ( 0),
+_m3 ( 0),
+_m4 ( 0),
+_m5 ( 0),
+_m6 ( 0),
+_vertexZ ( 0),
+  
+_Ncluster1  ( 0),
+_Ncluster2  ( 0),
+_etadis ( 0),
+_phidis ( 0),
+_dcaz   ( 0),
+_dcaxy  ( 0),
+_n1_1_vsPt         ( 0),         
+_n1_1_vsEtaVsPhi   ( 0),
+_s1pt_1_vsEtaVsPhi ( 0), 
+_n1_1_vsZVsEtaVsPhiVsPt ( 0),
+_n1_1_vsM          ( 0),  // w/ weight
+_s1pt_1_vsM        ( 0),
+_n1Nw_1_vsM        ( 0), // w/o weight
+_s1ptNw_1_vsM      ( 0),
+_dedxVsP_1         ( 0),
+_corrDedxVsP_1     ( 0),
+_betaVsP_1         ( 0),
+_n1_2_vsPt         ( 0),       
+_n1_2_vsEtaVsPhi   ( 0),
+_s1pt_2_vsEtaVsPhi ( 0),
+_n1_2_vsZVsEtaVsPhiVsPt ( 0), 
+_n1_2_vsM          ( 0),
+_s1pt_2_vsM        ( 0),
+_n1Nw_2_vsM        ( 0),
+_s1ptNw_2_vsM      ( 0),
+_dedxVsP_2         ( 0),
+_corrDedxVsP_2     ( 0),
+_betaVsP_2         ( 0),
+_n2_12_vsEtaPhi    ( 0),  
+_n2_12_vsPtVsPt    ( 0),
+_s2PtPt_12_vsEtaPhi( 0),    
+_s2PtN_12_vsEtaPhi ( 0),       
+_s2NPt_12_vsEtaPhi ( 0),     
+_n2_12_vsM         ( 0),        
+_s2PtPt_12_vsM     ( 0),    
+_s2PtN_12_vsM      ( 0),       
+_s2NPt_12_vsM      ( 0), 
+_n2Nw_12_vsM       ( 0),        
+_s2PtPtNw_12_vsM   ( 0),    
+_s2PtNNw_12_vsM    ( 0),       
+_s2NPtNw_12_vsM    ( 0), 
+_invMass           ( 0),
+_invMassElec       ( 0),
+n1Name("NA"),
+n1NwName("NA"),
+n2Name("NA"),
+n2NwName("NA"),
+n3Name("NA"),
+n1n1Name("NA"),
+n1n1n1Name("NA"),
+n2n1Name("NA"),
+r1Name("NA"),
+r2Name("NA"),
+r3Name("NA"),
+r2r1Name("NA"),
+c2Name("NA"),
+c3Name("NA"),
+d3Name("NA"),
+p3Name("NA"),
+cName("NA"),
+
+intR2Name("NA"),
+binCorrName("NA"),
+intBinCorrName("NA"),
+
+countsName("NA"),
+part_1_Name("NA"),
+part_2_Name("NA"),
+part_3_Name("NA"),
+pair_12_Name("NA"),
+pair_13_Name("NA"),
+pair_23_Name("NA"),
+tripletName("NA"),
+
+avg("NA"),
+avgName("NA"),
+sumName("NA"),
+s1ptName("NA"),
+s1ptNwName("NA"),
+s1DptName("NA"),
+
+s2PtPtName("NA"),
+s2NPtName("NA"),
+s2PtNName("NA"),
+s2DptDptName("NA"),
+
+s2PtPtNwName("NA"),
+s2NPtNwName("NA"),
+s2PtNNwName("NA"),
+
+ptName("NA"),
+ptptName("NA"),
+pt1pt1Name("NA"),
+DptName("NA"),
+DptDptName("NA"),
+RDptDptName("NA"),
+nPtName("NA"),
+ptNName("NA"),
+seanName("NA"),
+
+_title_counts("NA"),
+
+_title_m0("NA"),
+_title_m1("NA"),
+_title_m2("NA"),
+_title_m3("NA"),
+_title_m4("NA"),
+_title_m5("NA"),
+_title_m6("NA"),
+
+_title_eta_1("NA"),
+_title_phi_1("NA"),
+_title_pt_1("NA"),
+_title_etaPhi_1("NA"),
+_title_n_1("NA"),
+_title_SumPt_1("NA"),
+_title_AvgPt_1("NA"),
+_title_AvgN_1("NA"),
+_title_AvgSumPt_1("NA"),
+
+_title_eta_2("NA"),
+_title_phi_2("NA"),
+_title_pt_2("NA"),
+_title_etaPhi_2("NA"),
+_title_n_2("NA"),
+_title_SumPt_2("NA"),
+_title_AvgPt_2("NA"),
+_title_AvgN_2("NA"),
+_title_AvgSumPt_2("NA"),
+
+_title_etaPhi_12("NA"),
+
+_title_AvgN2_12("NA"),
+_title_AvgSumPtPt_12("NA"),
+_title_AvgSumPtN_12("NA"),
+_title_AvgNSumPt_12("NA"),
+
+vsZ("NA"),
+vsM("NA"),
+vsPt("NA"),
+vsPhi("NA"), 
+vsEta("NA"), 
+vsEtaPhi("NA"), 
+vsPtVsPt("NA")
+{
+  printf("Default constructor called \n");
+  
+  printf("passed \n ");
+  
+}
+
+AliDptDptInMC::AliDptDptInMC(const TString & name)
+: AliAnalysisTaskSE(name),
+fAODEvent(0), 
+fESDEvent(0),  
+fInputHandler(0),
+fPIDResponse(0),
+_outputHistoList(0),
+_twoPi         ( 2.0 * 3.1415927),
+_eventCount    ( 0), 
+_debugLevel    ( 0),
+_singlesOnly   ( 0), 
+_useWeights    ( 0), 
+_sameFilter    ( false),
+_rejectPileup  ( 1), 
+_rejectPairConversion ( 0), 
+_vertexZMin           ( -10.), 
+_vertexZMax           (  10.), 
+_vertexXYMin          ( -10.),
+_vertexXYMax          (  10.),
+_centralityMethod     (  4),
+_centralityMin        (  0.),
+_centralityMax        (  1.),
+_requestedCharge_1    (   1),
+_requestedCharge_2    (  -1),
+_dcaZMin              ( -3), 
+_dcaZMax              (  3.), 
+_dcaXYMin             ( -2.4), 
+_dcaXYMax             (  2.4),
+_dedxMin              ( 0),
+_dedxMax              ( 100000),
+_nClusterMin          ( 80), 
+_trackFilterBit       ( 0),
+fNSigmaCut            ( 3.),
+_field    ( 1.),
+_nTracks  ( 0 ),
+_mult0    ( 0 ),
+_mult1    ( 0 ),
+_mult2    ( 0 ),
+_mult3    ( 0 ),
+_mult4    ( 0 ),
+_mult4a    ( 0 ),
+_mult5    ( 0 ),
+_mult6    ( 0 ),
+arraySize ( 2000),
+_id_1(0),       
+_charge_1(0),    
+_iEtaPhi_1(0),    
+_iPt_1(0),     
+_pt_1(0),       
+_px_1(0),      
+_py_1(0),      
+_pz_1(0),      
+_correction_1(0),   
+_dedx_1(0),   
+_id_2(0),      
+_charge_2(0),    
+_iEtaPhi_2(0),    
+_iPt_2(0),     
+_pt_2(0),      
+_px_2(0),      
+_py_2(0),      
+_pz_2(0),      
+_correction_2(0),   
+_dedx_2(0),   
+_correctionWeight_1(0),   
+_correctionWeight_2(0),
+_nBins_M0(500),       _min_M0(0),        _max_M0(10000),          _width_M0(20),
+_nBins_M1(500),       _min_M1(0),        _max_M1(10000),          _width_M1(20),
+_nBins_M2(500),       _min_M2(0),        _max_M2(10000),          _width_M2(20),
+_nBins_M3(500),       _min_M3(0),        _max_M3(10000),          _width_M3(20),
+_nBins_M4(100),       _min_M4(0),        _max_M4(1),              _width_M4(0.01),
+_nBins_M5(100),       _min_M5(0),        _max_M5(1),              _width_M5(0.01),
+_nBins_M6(100),       _min_M6(0),        _max_M6(1),              _width_M6(0.01),
+_nBins_vertexZ(40),   _min_vertexZ(-10), _max_vertexZ(10),        _width_vertexZ(0.5),
+
+_nBins_pt_1(18),      _min_pt_1(0.2),    _max_pt_1(2.0),          _width_pt_1(0.1),
+_nBins_phi_1(72),     _min_phi_1(0),     _max_phi_1(2.*3.1415927),_width_phi_1(2.*3.1415927/72.),
+  //_nBins_eta_1(18),     
+  //_min_eta_1(-0.9),    _max_eta_1(0.9),           _width_eta_1(0.1),
+  _nBins_eta_1(0),     
+  _min_eta_1(0),    _max_eta_1(0),           _width_eta_1(0.1),
+
+_nBins_etaPhi_1(0), 
+_nBins_etaPhiPt_1(0),
+_nBins_zEtaPhiPt_1(0),
+
+_nBins_pt_2(18),     _min_pt_2(0.2),     _max_pt_2(2.0),          _width_pt_2(0.1),
+_nBins_phi_2(72),    _min_phi_2(0),      _max_phi_2(2.*3.1415927),_width_phi_2(2.*3.1415927/72),
+  //_nBins_eta_2(18),   
+  //_min_eta_2(-0.9),     _max_eta_2(0.9),           _width_eta_2(0.1),
+  _nBins_eta_2(0),   
+  _min_eta_2(0),     _max_eta_2(0),           _width_eta_2(0.1),
+
+
+_nBins_etaPhi_2(0), 
+_nBins_etaPhiPt_2(0),
+_nBins_zEtaPhiPt_2(0),
+_nBins_etaPhi_12(0),
+__n1_1(0),
+__n1_2(0),
+__n2_12(0),   
+__s1pt_1(0),
+__s1pt_2(0),
+__s2ptpt_12(0),
+__s2NPt_12(0),
+__s2PtN_12(0),
+__n1Nw_1(0),
+__n1Nw_2(0),
+__n2Nw_12(0),   
+__s1ptNw_1(0),
+__s1ptNw_2(0),
+__s2ptptNw_12(0),
+__s2NPtNw_12(0),
+__s2PtNNw_12(0),
+__n1_1_vsPt(0),
+__n1_1_vsEtaPhi(0), 
+__s1pt_1_vsEtaPhi(0),
+__n1_1_vsZEtaPhiPt(0),
+__n1_2_vsPt(0),
+__n1_2_vsEtaPhi(0), 
+__s1pt_2_vsEtaPhi(0),
+__n1_2_vsZEtaPhiPt(0),
+__n2_12_vsPtPt(0),
+__n2_12_vsEtaPhi(0),
+__s2ptpt_12_vsEtaPhi(0),
+__s2PtN_12_vsEtaPhi(0),
+__s2NPt_12_vsEtaPhi(0),
+_weight_1        ( 0    ),
+_weight_2        ( 0    ),
+_eventAccounting ( 0),
+_m0 ( 0),
+_m1 ( 0),
+_m2 ( 0),
+_m3 ( 0),
+_m4 ( 0),
+_m5 ( 0),
+_m6 ( 0),
+_vertexZ ( 0),
+_Ncluster1  ( 0),
+_Ncluster2  ( 0),
+_etadis ( 0),
+_phidis ( 0),
+
+_dcaz ( 0),
+_dcaxy ( 0),
+_n1_1_vsPt         ( 0),         
+_n1_1_vsEtaVsPhi   ( 0),
+_s1pt_1_vsEtaVsPhi ( 0), 
+_n1_1_vsZVsEtaVsPhiVsPt ( 0),
+_n1_1_vsM          ( 0),  // w/ weight
+_s1pt_1_vsM        ( 0),
+_n1Nw_1_vsM        ( 0), // w/o weight
+_s1ptNw_1_vsM      ( 0),
+_dedxVsP_1         ( 0),
+_corrDedxVsP_1     ( 0),
+_betaVsP_1         ( 0),
+_n1_2_vsPt         ( 0),       
+_n1_2_vsEtaVsPhi   ( 0),
+_s1pt_2_vsEtaVsPhi ( 0),
+_n1_2_vsZVsEtaVsPhiVsPt ( 0), 
+_n1_2_vsM          ( 0),
+_s1pt_2_vsM        ( 0),
+_n1Nw_2_vsM        ( 0),
+_s1ptNw_2_vsM      ( 0),
+_dedxVsP_2         ( 0),
+_corrDedxVsP_2     ( 0),
+_betaVsP_2         ( 0),
+_n2_12_vsEtaPhi    ( 0),  
+_n2_12_vsPtVsPt    ( 0),
+_s2PtPt_12_vsEtaPhi( 0),    
+_s2PtN_12_vsEtaPhi ( 0),       
+_s2NPt_12_vsEtaPhi ( 0),     
+_n2_12_vsM         ( 0),        
+_s2PtPt_12_vsM     ( 0),    
+_s2PtN_12_vsM      ( 0),       
+_s2NPt_12_vsM      ( 0), 
+_n2Nw_12_vsM       ( 0),        
+_s2PtPtNw_12_vsM   ( 0),    
+_s2PtNNw_12_vsM    ( 0),       
+_s2NPtNw_12_vsM    ( 0), 
+_invMass           ( 0),
+_invMassElec       ( 0),
+n1Name("NA"),
+n1NwName("NA"),
+n2Name("NA"),
+n2NwName("NA"),
+n3Name("NA"),
+n1n1Name("NA"),
+n1n1n1Name("NA"),
+n2n1Name("NA"),
+r1Name("NA"),
+r2Name("NA"),
+r3Name("NA"),
+r2r1Name("NA"),
+c2Name("NA"),
+c3Name("NA"),
+d3Name("NA"),
+p3Name("NA"),
+cName("NA"),
+
+intR2Name("NA"),
+binCorrName("NA"),
+intBinCorrName("NA"),
+
+countsName("NA"),
+part_1_Name("NA"),
+part_2_Name("NA"),
+part_3_Name("NA"),
+pair_12_Name("NA"),
+pair_13_Name("NA"),
+pair_23_Name("NA"),
+tripletName("NA"),
+
+avg("NA"),
+avgName("NA"),
+sumName("NA"),
+s1ptName("NA"),
+s1ptNwName("NA"),
+s1DptName("NA"),
+
+s2PtPtName("NA"),
+s2NPtName("NA"),
+s2PtNName("NA"),
+s2DptDptName("NA"),
+
+s2PtPtNwName("NA"),
+s2NPtNwName("NA"),
+s2PtNNwName("NA"),
+
+ptName("NA"),
+ptptName("NA"),
+pt1pt1Name("NA"),
+DptName("NA"),
+DptDptName("NA"),
+RDptDptName("NA"),
+nPtName("NA"),
+ptNName("NA"),
+seanName("NA"),
+
+_title_counts("NA"),
+
+_title_m0("NA"),
+_title_m1("NA"),
+_title_m2("NA"),
+_title_m3("NA"),
+_title_m4("NA"),
+_title_m5("NA"),
+_title_m6("NA"),
+
+_title_eta_1("NA"),
+_title_phi_1("NA"),
+_title_pt_1("NA"),
+_title_etaPhi_1("NA"),
+_title_n_1("NA"),
+_title_SumPt_1("NA"),
+_title_AvgPt_1("NA"),
+_title_AvgN_1("NA"),
+_title_AvgSumPt_1("NA"),
+
+_title_eta_2("NA"),
+_title_phi_2("NA"),
+_title_pt_2("NA"),
+_title_etaPhi_2("NA"),
+_title_n_2("NA"),
+_title_SumPt_2("NA"),
+_title_AvgPt_2("NA"),
+_title_AvgN_2("NA"),
+_title_AvgSumPt_2("NA"),
+
+_title_etaPhi_12("NA"),
+
+_title_AvgN2_12("NA"),
+_title_AvgSumPtPt_12("NA"),
+_title_AvgSumPtN_12("NA"),
+_title_AvgNSumPt_12("NA"),
+
+vsZ("NA"),
+vsM("NA"),
+vsPt("NA"),
+vsPhi("NA"), 
+vsEta("NA"), 
+vsEtaPhi("NA"), 
+vsPtVsPt("NA")
+{
+  printf("2nd constructor called ");
+  
+  DefineOutput(0, TList::Class());
+  
+  printf("passed  ");
+  
+}
+
+AliDptDptInMC::~AliDptDptInMC()
+{
+  /*
+   delete _id_1;
+   delete _charge_1; 
+   delete _iEtaPhi_1; 
+   delete _iPt_1;  
+   delete _pt_1;    
+   delete _px_1;   
+   delete _py_1;   
+   delete _pz_1;   
+   delete _correction_1;
+   delete _dedx_1;
+   delete __n1_1_vsPt;
+   delete __n1_1_vsEtaPhi;
+   delete __s1pt_1_vsEtaPhi;
+   delete __n1_1_vsZEtaPhiPt; 
+   if (_correctionWeight_1) delete _correctionWeight_1;
+   
+   if (!_sameFilter)
+   {
+   delete _id_2;
+   delete _charge_2; 
+   delete _iEtaPhi_2; 
+   delete _iPt_2;  
+   delete _pt_2;    
+   delete _px_2;   
+   delete _py_2;   
+   delete _pz_2;   
+   delete _correction_2;
+   delete _dedx_2;
+   delete __n1_2_vsPt;
+   delete __n1_2_vsEtaPhi;
+   delete __s1pt_2_vsEtaPhi;
+   delete __n1_2_vsZEtaPhiPt; 
+   if (_correctionWeight_2) delete _correctionWeight_2;
+   }
+   
+   if (!_singlesOnly)
+   {
+   delete __n2_12_vsPtPt;
+   delete __n2_12_vsEtaPhi;
+   delete __s2ptpt_12_vsEtaPhi;
+   delete __s2PtN_12_vsEtaPhi;
+   delete __s2NPt_12_vsEtaPhi;
+   }
+   */
+}
+
+void AliDptDptInMC::UserCreateOutputObjects()
+{
+  //cout<< "AliDptDptInMC::CreateOutputObjects() Starting " << endl;
+  OpenFile(0);
+  _outputHistoList = new TList();
+  _outputHistoList->SetOwner();
+  
+  //if (_useWeights) DefineInput(2, TList::Class());
+  
+  //Setup the parameters of the histograms
+  _nBins_M0 = 500; _min_M0   = 0.;    _max_M0    = 5000.;  _width_M0 = (_max_M0-_min_M0)/_nBins_M0;
+  _nBins_M1 = 500; _min_M1   = 0.;    _max_M1    = 5000.;  _width_M1 = (_max_M1-_min_M1)/_nBins_M1;
+  _nBins_M2 = 500; _min_M2   = 0.;    _max_M2    = 5000.;  _width_M2 = (_max_M2-_min_M2)/_nBins_M2;
+  _nBins_M3 = 500; _min_M3   = 0.;    _max_M3    = 5000.;  _width_M3 = (_max_M3-_min_M3)/_nBins_M3;
+  _nBins_M4 = 100; _min_M4   = 0.;    _max_M4    = 100.;   _width_M4 = (_max_M4-_min_M4)/_nBins_M4;
+  _nBins_M5 = 100; _min_M5   = 0.;    _max_M5    = 100.;   _width_M5 = (_max_M5-_min_M5)/_nBins_M5;
+  _nBins_M6 = 100; _min_M6   = 0.;    _max_M6    = 100.;   _width_M6 = (_max_M6-_min_M6)/_nBins_M6;
+  
+  _min_vertexZ       = _vertexZMin;  
+  _max_vertexZ       = _vertexZMax;  
+  _width_vertexZ     = 0.5;
+  _nBins_vertexZ     = int(0.5+ (_max_vertexZ - _min_vertexZ)/_width_vertexZ); 
+  _nBins_pt_1        = int(0.5+ (_max_pt_1 -_min_pt_1 )/_width_pt_1); 
+  _nBins_eta_1       = int(0.5+ (_max_eta_1-_min_eta_1)/_width_eta_1);  
+  _width_phi_1       = (_max_phi_1  - _min_phi_1)  /_nBins_phi_1;
+  _nBins_etaPhi_1    = _nBins_phi_1    * _nBins_eta_1;
+  _nBins_etaPhiPt_1  = _nBins_etaPhi_1 * _nBins_pt_1;
+  _nBins_zEtaPhiPt_1 = _nBins_vertexZ  * _nBins_etaPhiPt_1;
+  
+  _nBins_pt_2        =  int(0.5+ (_max_pt_2 -_min_pt_2 )/_width_pt_2);  
+  _nBins_eta_2       = int(0.5+ (_max_eta_2-_min_eta_2)/_width_eta_2); 
+  _width_phi_2       = (_max_phi_2  - _min_phi_2)  /_nBins_phi_2;
+  _nBins_etaPhi_2    = _nBins_phi_2    * _nBins_eta_2;
+  _nBins_etaPhiPt_2  = _nBins_etaPhi_2 * _nBins_pt_2;
+  _nBins_zEtaPhiPt_2 = _nBins_vertexZ  * _nBins_etaPhiPt_2;
+  _nBins_etaPhi_12   = _nBins_etaPhi_1 * _nBins_etaPhi_2;
+  
+  //setup the work arrays
+  
+  _id_1       = new int[arraySize];   
+  _charge_1   = new int[arraySize]; 
+  //_iPhi_1 = new int[arraySize]; 
+  //_iEta_1 = new int[arraySize]; 
+  _iEtaPhi_1  = new int[arraySize]; 
+  _iPt_1      = new int[arraySize];  
+  _pt_1       = new float[arraySize];    
+  _px_1       = new float[arraySize];   
+  _py_1       = new float[arraySize];   
+  _pz_1       = new float[arraySize];   
+  //_phi_1 = new float[arraySize];  
+  //_eta_1 = new float[arraySize];  
+  _correction_1 = new float[arraySize];
+  //_dedx_1     = new float[arraySize];
+  
+  __n1_1_vsPt              = getDoubleArray(_nBins_pt_1,        0.);
+  __n1_1_vsEtaPhi          = getDoubleArray(_nBins_etaPhi_1,    0.);
+  __s1pt_1_vsEtaPhi        = getDoubleArray(_nBins_etaPhi_1,    0.);
+  __n1_1_vsZEtaPhiPt       = getFloatArray(_nBins_zEtaPhiPt_1,  0.);
+  
+  //cout << "==========================================================================================" << endl;
+  //cout << "=============== Booking for particle 1 done." << endl;
+  //cout << "_requestedCharge_1: " << _requestedCharge_1 << endl;
+  //cout << "_requestedCharge_2: " << _requestedCharge_2 << endl;
+  
+  if (_requestedCharge_2!=_requestedCharge_1)
+    {
+      //cout << " creating arrays for particle 2 with size: " << arraySize << endl;
+    _sameFilter = 0;
+    //particle 2
+    _id_2       = new int[arraySize];   
+    _charge_2   = new int[arraySize]; 
+    //_iPhi_2   = new int[arraySize]; 
+    //_iEta_2   = new int[arraySize]; 
+    _iEtaPhi_2  = new int[arraySize]; 
+    _iPt_2      = new int[arraySize];  
+    _pt_2       = new float[arraySize];   
+    _px_2       = new float[arraySize];   
+    _py_2       = new float[arraySize];   
+    _pz_2       = new float[arraySize];   
+    //_phi_2    = new float[arraySize];  
+    //_eta_2    = new float[arraySize];  
+    _correction_2 = new float[arraySize];
+    //_dedx_2       = new float[arraySize];
+    
+    __n1_2_vsPt              = getDoubleArray(_nBins_pt_2,        0.);
+    __n1_2_vsEtaPhi          = getDoubleArray(_nBins_etaPhi_2,    0.);
+    __s1pt_2_vsEtaPhi        = getDoubleArray(_nBins_etaPhi_2,    0.);
+    __n1_2_vsZEtaPhiPt       = getFloatArray(_nBins_zEtaPhiPt_2, 0.);
+    
+    }
+  
+  __n2_12_vsPtPt           = getDoubleArray(_nBins_pt_1*_nBins_pt_2,0.);
+  __n2_12_vsEtaPhi         = getFloatArray(_nBins_etaPhi_12,       0.);
+  __s2ptpt_12_vsEtaPhi     = getFloatArray(_nBins_etaPhi_12,       0.);
+  __s2PtN_12_vsEtaPhi      = getFloatArray(_nBins_etaPhi_12,       0.);
+  __s2NPt_12_vsEtaPhi      = getFloatArray(_nBins_etaPhi_12,       0.);
+  
+  // Setup all the labels needed.
+  
+  part_1_Name   = "_1";
+  part_2_Name   = "_2";
+  pair_12_Name  = "_12";
+  
+  n1Name     = "n1";
+  n2Name     = "n2";
+  n1NwName   = "n1Nw";
+  n2NwName   = "n2Nw";
+  r1Name     = "r1";
+  r2Name     = "r2";
+  r3Name     = "r3";
+  r2r1Name   = "r2r1";
+  c2Name     = "c2";
+  c3Name     = "c3";
+  d3Name     = "d3";
+  p3Name     = "p3";
+  cName      = "sean";
+  
+  intR2Name       = "intR2";
+  binCorrName     = "binCorr";
+  intBinCorrName  = "intBinCorr";
+  
+  avgName      = "avg";
+  sumName      = "sum";
+  s1ptName     = "sumPt";
+  s1ptNwName   = "sumPtNw";
+  s1DptName    = "sumDpt";
+  s2PtPtName   = "sumPtPt";
+  s2PtPtNwName = "sumPtPtNw";
+  s2DptDptName = "sumDptDpt";
+  s2NPtName    = "sumNPt";
+  s2NPtNwName  = "sumNPtNw";
+  s2PtNName    = "sumPtN";
+  s2NPtNwName  = "sumNPtNw";
+  s2PtNNwName  = "sumPtNNw";
+  ptName       = "avgPt";
+  ptptName     = "avgPtPt";
+  pt1pt1Name   = "avgPtavgPt";
+  DptName      = "avgDpt";
+  DptDptName   = "avgDptDpt";
+  RDptDptName  = "relDptDpt"; // ratio of avgDptDpt by avgPt*avgPt
+  nPtName      = "avgNpt";
+  ptNName      = "avgPtN";
+  seanName     = "seanC";
+  
+  _title_counts = "yield";
+  
+  _title_m0     = "M_{0}";
+  _title_m1     = "M_{1}";
+  _title_m2     = "M_{2}";
+  _title_m3     = "M_{3}";
+  _title_m4     = "V0Centrality";
+  _title_m5     = "TrkCentrality";
+  _title_m6     = "SpdCentrality";
+  
+  _title_eta_1       = "#eta_{1}";
+  _title_phi_1       = "#varphi_{1} (radian)";
+  _title_etaPhi_1    = "#eta_{1}#times#varphi_{1}";
+  _title_pt_1        = "p_{t,1} (GeV/c)";
+  _title_n_1         = "n_{1}";
+  _title_SumPt_1     = "#Sigma p_{t,1} (GeV/c)";
+  _title_AvgPt_1     = "#LT p_{t,1} #GT (GeV/c)";
+  _title_AvgN_1      = "#LT n_{1} #GT";
+  _title_AvgSumPt_1  = "#LT #Sigma p_{t,1} #GT (GeV/c)";
+  
+  _title_eta_2       = "#eta_{2}";
+  _title_phi_2       = "#varphi_{2} (radian)";
+  _title_etaPhi_2    = "#eta_{2}#times#varphi_{2}";
+  _title_pt_2        = "p_{t,2} (GeV/c)";
+  _title_n_2         = "n_{2}";
+  _title_SumPt_2     = "#Sigma p_{t,1} (GeV/c)";
+  _title_AvgPt_2     = "#LT p_{t,2} #GT (GeV/c)";
+  _title_AvgN_2      = "#LT n_{2} #GT";
+  _title_AvgSumPt_2  = "#LT #Sigma p_{t,2} #GT (GeV/c)";
+  
+  _title_etaPhi_12   = "#eta_{1}#times#varphi_{1}#times#eta_{2}#times#varphi_{2}";
+  
+  _title_AvgN2_12       = "#LT n_{2} #GT";;
+  _title_AvgSumPtPt_12  = "#LT #Sigma p_{t,1}p_{t,2} #GT";;
+  _title_AvgSumPtN_12   = "#LT #Sigma p_{t,1}N #GT";;
+  _title_AvgNSumPt_12   = "#LT N#Sigma p_{t,2} #GT";;
+  
+  
+  vsZ         = "_vsZ";
+  vsM         = "_vsM";
+  vsPt         = "_vsPt";
+  vsPhi        = "_vsPhi"; 
+  vsEta        = "_vsEta"; 
+  vsEtaPhi     = "_vsEtaPhi"; 
+  vsPtVsPt     = "_vsPtVsPt";
+  
+  
+  if (_useWeights)
+    {
+    int iZ, iEtaPhi, iPt;
+    int iZ1,iEtaPhi1,iPt1;
+    int a, b;
+    if (_weight_1)
+      {
+      _correctionWeight_1 = new float[_nBins_vertexZ*_nBins_etaPhi_1*_nBins_pt_1];
+      a = _nBins_pt_1;
+      b = _nBins_etaPhi_1*_nBins_pt_1;
+      for (iZ=0,iZ1=1; iZ<_nBins_vertexZ; iZ++, iZ1++)
+        {
+        for (iEtaPhi=0,iEtaPhi1=1; iEtaPhi<_nBins_etaPhi_1; iEtaPhi++, iEtaPhi1++)
+          {
+          for (iPt=0,iPt1=1; iPt<_nBins_pt_1; iPt++, iPt1++)
+            {
+            _correctionWeight_1[iZ*b+iEtaPhi*a+iPt] = _weight_1->GetBinContent(iZ1,iEtaPhi1,iPt1);
+            }      
+          }
+        }
+      } // _weight_1
+    else
+      {
+      AliError("AliDptDptInMC:: _weight_1 is a null pointer.");
+      return;
+      }
+    if (!_sameFilter) 
+      {
+      if (_weight_2)
+        {
+        _correctionWeight_2 = new float[_nBins_vertexZ*_nBins_etaPhi_2*_nBins_pt_2];
+        a = _nBins_pt_2;
+        b = _nBins_etaPhi_2*_nBins_pt_2;
+        for (iZ=0,iZ1=1; iZ<_nBins_vertexZ; iZ++, iZ1++)
+          {
+          for (iEtaPhi=0,iEtaPhi1=1; iEtaPhi<_nBins_etaPhi_2; iEtaPhi++, iEtaPhi1++)
+            {
+            for (iPt=0,iPt1=1; iPt<_nBins_pt_2; iPt++, iPt1++)
+              {
+              _correctionWeight_2[iZ*b+iEtaPhi*a+iPt] = _weight_2->GetBinContent(iZ1,iEtaPhi1,iPt1);
+              }      
+            }
+          }
+        } // _weight_2
+      else
+        {
+        AliError("AliDptDptInMC:: _weight_1 is a null pointer.");
+        return;
+        }
+      }
+    }
+  
+  createHistograms();
+  PostData(0,_outputHistoList);
+  
+  //cout<< "AliDptDptInMC::CreateOutputObjects() DONE " << endl;
+  
+}
+
+void  AliDptDptInMC::createHistograms()
+{
+  AliInfo(" AliDptDptInMC::createHistoHistograms() Creating Event Histos");
+  TString name;
+  
+  name = "eventAccounting";
+  
+  // bin index : what it is...
+  //         0 :  number of event submitted
+  //         1 :  number accepted by centrality cut
+  //         2 :  number accepted by centrality cut and z cut
+  //         3 :  total number of particles that satisfied filter 1
+  //         4 :  total number of particles that satisfied filter 2
+  _eventAccounting      = createHisto1D(name,name,10, -0.5, 9.5, "event Code", _title_counts);
+  
+  name = "m0"; _m0      = createHisto1D(name,name,_nBins_M1, _min_M1, _max_M1, _title_m0, _title_counts);
+  name = "m1"; _m1      = createHisto1D(name,name,_nBins_M1, _min_M1, _max_M1, _title_m1, _title_counts);
+  name = "m2"; _m2      = createHisto1D(name,name,_nBins_M2, _min_M2, _max_M2, _title_m2, _title_counts);
+  name = "m3"; _m3      = createHisto1D(name,name,_nBins_M3, _min_M3, _max_M3, _title_m3, _title_counts);
+  name = "m4"; _m4      = createHisto1D(name,name,_nBins_M4, _min_M4, _max_M4, _title_m4, _title_counts);
+  name = "m5"; _m5      = createHisto1D(name,name,_nBins_M5, _min_M5, _max_M5, _title_m5, _title_counts);
+  name = "m6"; _m6      = createHisto1D(name,name,_nBins_M6, _min_M6, _max_M6, _title_m6, _title_counts);
+  name = "zV"; _vertexZ = createHisto1D(name,name,_nBins_vertexZ, _min_vertexZ, _max_vertexZ, "z-Vertex (cm)", _title_counts);
+  
+
+  name = "Eta";     _etadis   = createHisto1F(name,name, 200, -1.0, 1.0, "#eta","counts");
+  name = "Phi";     _phidis   = createHisto1F(name,name, 360, 0.0, 6.4, "#phi","counts");
+  name = "DCAz";    _dcaz     = createHisto1F(name,name, 500, -5.0, 5.0, "dcaZ","counts");
+  name = "DCAxy";   _dcaxy    = createHisto1F(name,name, 500, -5.0, 5.0, "dcaXY","counts");
+  
+  /*name = "dedxVsP_1"; _dedxVsP_1  = createHisto2D(name,name,1000,-10.,10.,1000,0.,1000.,"p (GeV/c)", "dedx", "counts");                          
+  name = "dedxVsP_2"; _dedxVsP_2  = createHisto2D(name,name,1000,-10.,10.,1000,0.,1000.,"p (GeV/c)", "dedx", "counts");     
+  name = "corrDedxVsP_1"; _corrDedxVsP_1 = createHisto2D(name,name,1000,-10.,10.,1000,0.,500,"p (GeV/c)", "dedx", "counts");  
+  name = "corrDedxVsP_2"; _corrDedxVsP_2 = createHisto2D(name,name,1000,-10.,10.,1000,0.,500,"p (GeV/c)", "dedx", "counts"); 
+  */
+  name = "Nclus1";   _Ncluster1    = createHisto1F(name,name, 200, 0, 200, "Ncluster1","counts");
+  name = "Nclus2";   _Ncluster2    = createHisto1F(name,name, 200, 0, 200, "Ncluster2","counts");
+  
+  if (_singlesOnly)
+    {
+    name = n1Name+part_1_Name+vsPt;              _n1_1_vsPt              = createHisto1F(name,name, _nBins_pt_1,  _min_pt_1,  _max_pt_1,   _title_pt_1,  _title_AvgN_1);
+    name = n1Name+part_1_Name+vsZ+vsEtaPhi+vsPt; _n1_1_vsZVsEtaVsPhiVsPt = createHisto3F(name,name, _nBins_vertexZ,_min_vertexZ,_max_vertexZ, _nBins_etaPhi_1, 0., double(_nBins_etaPhi_1), _nBins_pt_1, _min_pt_1, _max_pt_1, "zVertex", _title_etaPhi_1,  _title_pt_1);
+    //name = "dedxVsP_1";                          _dedxVsP_1              = createHisto2F(name,name,400,-2.,2.,120,0.,120.,"p (GeV/c)", "dedx", "counts");
+    //name = "corrDedxVsP_1";                      _corrDedxVsP_1          = createHisto2F(name,name,400,-2.,2.,120,0.,120.,"p (GeV/c)", "dedx", "counts");
+    //name = "betaVsP_1";                          _betaVsP_1              = createHisto2F(name,name,400,-2.,2.,120,0.5,1.1,"p (GeV/c)", "beta", "counts");
+
+    name = n1Name+part_2_Name+vsPt;              _n1_2_vsPt              = createHisto1F(name,name, _nBins_pt_2,  _min_pt_2,  _max_pt_2,   _title_pt_2,  _title_AvgN_2);
+    name = n1Name+part_2_Name+vsZ+vsEtaPhi+vsPt; _n1_2_vsZVsEtaVsPhiVsPt = createHisto3F(name,name, _nBins_vertexZ,_min_vertexZ,_max_vertexZ, _nBins_etaPhi_2, 0., double(_nBins_etaPhi_2), _nBins_pt_2, _min_pt_2, _max_pt_2, "zVertex", _title_etaPhi_2,  _title_pt_2);
+    //name = "dedxVsP_2";                          _dedxVsP_2              = createHisto2F(name,name,400,-2.,2.,120,0.,120.,"p (GeV/c)", "dedx", "counts");
+    //name = "corrDedxVsP_2";                      _corrDedxVsP_2          = createHisto2F(name,name,400,-2.,2.,120,0.,120.,"p (GeV/c)", "dedx", "counts");
+    //name = "betaVsP_2";                          _betaVsP_2              = createHisto2F(name,name,400,-2.,2.,120,0.5,1.1,"p (GeV/c)", "beta", "counts");
+
+    }
+  else
+    {
+    name = n1Name+part_1_Name+vsEtaPhi;       _n1_1_vsEtaVsPhi      = createHisto2F(name,name, _nBins_eta_1, _min_eta_1, _max_eta_1,  _nBins_phi_1, _min_phi_1, _max_phi_1,  _title_eta_1,  _title_phi_1,  _title_AvgN_1);
+    name = s1ptName+part_1_Name+vsEtaPhi;     _s1pt_1_vsEtaVsPhi    = createHisto2F(name,name, _nBins_eta_1, _min_eta_1, _max_eta_1,  _nBins_phi_1, _min_phi_1, _max_phi_1,  _title_eta_1,  _title_phi_1,  _title_AvgSumPt_1);
+    name = n1Name+part_1_Name+vsM;            _n1_1_vsM             = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN_1);
+    name = s1ptName+part_1_Name+vsM;          _s1pt_1_vsM           = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPt_1);
+    name = n1NwName+part_1_Name+vsM;          _n1Nw_1_vsM           = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN_1);
+    name = s1ptNwName+part_1_Name+vsM;        _s1ptNw_1_vsM         = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPt_1);
+
+    name = n1Name+part_2_Name+vsEtaPhi;       _n1_2_vsEtaVsPhi      = createHisto2F(name,name, _nBins_eta_2, _min_eta_2, _max_eta_2,  _nBins_phi_2, _min_phi_2, _max_phi_2,  _title_eta_2,  _title_phi_2,  _title_AvgN_2);
+    name = s1ptName+part_2_Name+vsEtaPhi;     _s1pt_2_vsEtaVsPhi    = createHisto2F(name,name, _nBins_eta_2, _min_eta_2, _max_eta_2,  _nBins_phi_2, _min_phi_2, _max_phi_2,  _title_eta_2,  _title_phi_2,  _title_AvgSumPt_2);
+    name = n1Name+part_2_Name + vsM;          _n1_2_vsM             = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN_2);
+    name = s1ptName+part_2_Name + vsM;        _s1pt_2_vsM           = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPt_2);
+    name = n1NwName+part_2_Name+vsM;          _n1Nw_2_vsM           = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN_1);
+    name = s1ptNwName+part_2_Name+vsM;        _s1ptNw_2_vsM         = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPt_1);
+
+    name = n2Name+pair_12_Name+vsEtaPhi;      _n2_12_vsEtaPhi       = createHisto1F(name,name, _nBins_etaPhi_12, 0.,        double(_nBins_etaPhi_12), _title_etaPhi_12, _title_AvgN2_12);        
+    name = s2PtPtName+pair_12_Name + vsEtaPhi;_s2PtPt_12_vsEtaPhi   = createHisto1F(name,name, _nBins_etaPhi_12, 0.,        double(_nBins_etaPhi_12), _title_etaPhi_12,  _title_AvgSumPtPt_12);    
+    name = s2PtNName+pair_12_Name + vsEtaPhi; _s2PtN_12_vsEtaPhi    = createHisto1F(name,name, _nBins_etaPhi_12, 0.,        double(_nBins_etaPhi_12), _title_etaPhi_12,  _title_AvgSumPtN_12);    
+    name = s2NPtName+pair_12_Name + vsEtaPhi; _s2NPt_12_vsEtaPhi    = createHisto1F(name,name, _nBins_etaPhi_12, 0.,        double(_nBins_etaPhi_12), _title_etaPhi_12,  _title_AvgNSumPt_12);    
+    name = n2Name+pair_12_Name+vsPtVsPt;      _n2_12_vsPtVsPt       = createHisto2F(name,name, _nBins_pt_1, _min_pt_1, _max_pt_1, _nBins_pt_2, _min_pt_2, _max_pt_2, _title_pt_1, _title_pt_2, _title_AvgN2_12);        
+    
+    name = n2Name+pair_12_Name + vsM;         _n2_12_vsM            = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN2_12);        
+    name = s2PtPtName+pair_12_Name + vsM;     _s2PtPt_12_vsM        = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPtPt_12);    
+    name = s2PtNName+pair_12_Name + vsM;      _s2PtN_12_vsM         = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPtN_12);       
+    name = s2NPtName+pair_12_Name + vsM;      _s2NPt_12_vsM         = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgNSumPt_12);     
+    
+    name = n2NwName+pair_12_Name + vsM;       _n2Nw_12_vsM          = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgN2_12);        
+    name = s2PtPtNwName+pair_12_Name + vsM;   _s2PtPtNw_12_vsM      = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPtPt_12);    
+    name = s2PtNNwName+pair_12_Name + vsM;    _s2PtNNw_12_vsM       = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgSumPtN_12);       
+    name = s2NPtNwName+pair_12_Name + vsM;    _s2NPtNw_12_vsM       = createProfile(name,name, _nBins_M4, _min_M4, _max_M4, _title_m4, _title_AvgNSumPt_12);     
+    
+    name = "mInv";     _invMass     = createHisto1F(name,name, 500, 0., 1.000, "M_{inv}","counts"); 
+    name = "mInvElec"; _invMassElec = createHisto1F(name,name, 500, 0., 1.000, "M_{inv}","counts"); 
+    }
+  
+  AliInfo(" AliDptDptInMC::createHistoHistograms() All Done"); 
+}
+//-----------------------//
+
+void  AliDptDptInMC::finalizeHistograms()
+{
+  
+  AliInfo("AliDptDptInMC::finalizeHistograms() starting");
+  AliInfo(Form("CorrelationAnalyzers::finalizeHistograms()   _eventCount : %d",int(_eventCount)));
+  if (_singlesOnly)
+    {
+    if (_sameFilter)
+      {
+      fillHistoWithArray(_n1_1_vsPt,              __n1_1_vsPt,        _nBins_pt_1);
+      fillHistoWithArray(_n1_1_vsZVsEtaVsPhiVsPt, __n1_1_vsZEtaPhiPt, _nBins_vertexZ, _nBins_etaPhi_1, _nBins_pt_1);
+      fillHistoWithArray(_n1_2_vsPt,              __n1_1_vsPt,        _nBins_pt_1);
+      fillHistoWithArray(_n1_2_vsZVsEtaVsPhiVsPt, __n1_1_vsZEtaPhiPt, _nBins_vertexZ, _nBins_etaPhi_1, _nBins_pt_1);
+      }
+    else
+      {
+      fillHistoWithArray(_n1_1_vsPt,              __n1_1_vsPt,        _nBins_pt_1);
+      fillHistoWithArray(_n1_1_vsZVsEtaVsPhiVsPt, __n1_1_vsZEtaPhiPt, _nBins_vertexZ, _nBins_etaPhi_1, _nBins_pt_1);
+      fillHistoWithArray(_n1_2_vsPt,              __n1_2_vsPt,        _nBins_pt_2);
+      fillHistoWithArray(_n1_2_vsZVsEtaVsPhiVsPt, __n1_2_vsZEtaPhiPt, _nBins_vertexZ, _nBins_etaPhi_2, _nBins_pt_2);
+      }
+    }
+  else
+    {
+    if (_sameFilter)
+      {
+      fillHistoWithArray(_n1_1_vsEtaVsPhi,        __n1_1_vsEtaPhi,    _nBins_eta_1,   _nBins_phi_1);
+      fillHistoWithArray(_s1pt_1_vsEtaVsPhi,      __s1pt_1_vsEtaPhi,  _nBins_eta_1,   _nBins_phi_1);
+      fillHistoWithArray(_n1_2_vsEtaVsPhi,        __n1_1_vsEtaPhi,    _nBins_eta_1,   _nBins_phi_1);
+      fillHistoWithArray(_s1pt_2_vsEtaVsPhi,      __s1pt_1_vsEtaPhi,  _nBins_eta_1,   _nBins_phi_1);
+      }
+    else
+      {
+      fillHistoWithArray(_n1_1_vsEtaVsPhi,        __n1_1_vsEtaPhi,    _nBins_eta_1,   _nBins_phi_1);
+      fillHistoWithArray(_s1pt_1_vsEtaVsPhi,      __s1pt_1_vsEtaPhi,  _nBins_eta_1,   _nBins_phi_1);
+      fillHistoWithArray(_n1_2_vsEtaVsPhi,        __n1_2_vsEtaPhi,    _nBins_eta_2,   _nBins_phi_2);
+      fillHistoWithArray(_s1pt_2_vsEtaVsPhi,      __s1pt_2_vsEtaPhi,  _nBins_eta_2,   _nBins_phi_2);
+      }
+    fillHistoWithArray(_n2_12_vsEtaPhi,     __n2_12_vsEtaPhi,     _nBins_etaPhi_12);
+    fillHistoWithArray(_s2PtPt_12_vsEtaPhi, __s2ptpt_12_vsEtaPhi, _nBins_etaPhi_12);
+    fillHistoWithArray(_s2PtN_12_vsEtaPhi,  __s2PtN_12_vsEtaPhi,  _nBins_etaPhi_12);
+    fillHistoWithArray(_s2NPt_12_vsEtaPhi,  __s2NPt_12_vsEtaPhi,  _nBins_etaPhi_12);
+    fillHistoWithArray(_n2_12_vsPtVsPt,     __n2_12_vsPtPt,       _nBins_pt_1,    _nBins_pt_2);
+
+    }  
+  AliInfo("AliDptDptInMC::finalizeHistograms()  Done ");
+}
+//--------------//
+
+
+void  AliDptDptInMC::UserExec(Option_t */*option*/)
+{
+  
+
+  int    k1,k2;
+  int    iPhi, iEta, iEtaPhi, iPt, charge;
+  float  q, phi, pt, eta, corr, corrPt, px, py, pz;
+  int    ij;
+  int    id_1, q_1, iEtaPhi_1, iPt_1;
+  float  pt_1, px_1, py_1, pz_1, corr_1;
+  int    id_2, q_2, iEtaPhi_2, iPt_2;
+  float  pt_2, px_2, py_2, pz_2, corr_2;
+  float  ptpt;
+  int    iVertex, iVertexP1, iVertexP2;
+  int    iZEtaPhiPt;
+  float  massElecSq = 2.5e-7;
+  const  AliAODVertex*  vertex;
+  //int    nClus;                                                                                                                           
+  bool   bitOK;
+
+  AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();
+  if (!manager) {
+    //cout<<"ERROR: Analysis manager not found."<<endl;                                                                                     
+    return;
+  }
+  //coneect to the inputHandler------------                                                                                                 
+  AliAODInputHandler* inputHandler = dynamic_cast<AliAODInputHandler*> (manager->GetInputEventHandler());
+  if (!inputHandler) {
+    return;
+  }
+
+  fAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());
+  if (!fAODEvent)
+    {
+      return;
+    }
+  fPIDResponse =inputHandler->GetPIDResponse();
+  if (!fPIDResponse){
+    AliFatal("This Task needs the PID response attached to the inputHandler");
+    return;
+  }
+  // count all events looked at here                                                                                                        
+  _eventCount++;
+
+  if (_eventAccounting)
+    {
+      _eventAccounting->Fill(0);// count all calls to this function                                                                         
+    }
+  else
+    {
+      return;
+    }
+
+  _eventAccounting->Fill(1);// count all calls to this function with a valid pointer                                                        
+  //reset single particle counters                                                                                                          
+  k1 = k2 = 0;
+  __n1_1 = __n1_2 = __s1pt_1 = __s1pt_2 = __n1Nw_1 = __n1Nw_2 = __s1ptNw_1 = __s1ptNw_2 = 0;
+
+  float v0Centr  = -999.;
+  float v0ACentr  = -999.;
+  float trkCentr = -999.;
+  float spdCentr = -999.;
+  float vertexX  = -999;
+  float vertexY  = -999;
+  float vertexZ  = -999;
+  float vertexXY = -999;
+
+  float centrality = -999;
+  //Double_t nSigma =-999;  
+  if(fAODEvent)
+    {
+
+      //Centrality                                                                                                                          
+      //AliAODHeader* centralityObject = fAODEvent->GetHeader()->GetCentralityP();                                                          
+      AliCentrality* centralityObject =  fAODEvent->GetHeader()->GetCentralityP();
+      if (centralityObject)
+        {
+          v0Centr  = centralityObject->GetCentralityPercentile("V0M");
+          v0ACentr  = centralityObject->GetCentralityPercentile("V0A");
+          trkCentr = centralityObject->GetCentralityPercentile("TRK");
+          spdCentr = centralityObject->GetCentralityPercentile("CL1");
+
+        }
+
+      _mult4    = v0Centr;
+      _mult4a   = v0ACentr;
+      _mult5    = trkCentr;
+      _mult6    = spdCentr;
+      _field    = fAODEvent->GetMagneticField();
+      //_centralityMethod                                                                                                                   
+      switch (_centralityMethod)
+        {
+        case 0: centrality = _mult0; break;
+        case 1: centrality = _mult1; break;
+        case 2: centrality = _mult2; break;
+        case 3: centrality = _mult3; break;
+       case 4: centrality = _mult4; break;
+        case 5: centrality = _mult5; break;
+        case 6: centrality = _mult6; break;
+        case 7: centrality = _mult4a; break;
+        }
+
+      if ( centrality < _centralityMin ||  centrality > _centralityMax ) return;
+
+      _eventAccounting->Fill(2);// count all events with right centrality                                                                   
+
+      vertex = (AliAODVertex*) fAODEvent->GetPrimaryVertex();
+
+      if(vertex->GetNContributors() > 0)
+        {
+          vertexX = vertex->GetX();
+          vertexY = vertex->GetY();
+          vertexZ = vertex->GetZ();
+          vertexXY = sqrt(vertexX*vertexX+vertexY*vertexY);
+        }
+      if (vertexZ  < _vertexZMin  || vertexZ  > _vertexZMax ) return;
+
+      iVertex = int((vertexZ-_min_vertexZ)/_width_vertexZ);
+      iVertexP1 = iVertex*_nBins_etaPhiPt_1;
+      iVertexP2 = iVertex*_nBins_etaPhiPt_2;
+      if (iVertex<0 || iVertex>=_nBins_vertexZ)
+        {
+          AliError("AliTaskDptCorrMC::Exec(Option_t *option) iVertex<0 || iVertex>=_nBins_vertexZ ");
+          return;
+        }
+      _eventAccounting->Fill(3);// count all calls to this function with a valid pointer                                                    
+      //======================                 
+      if(fAnalysisType == "MCAOD")
+        { //Data AOD                                                                                                                        
+          fArrayMC = dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+          if (!fArrayMC) {
+            Printf("Error: MC particles branch not found!\n");
+            return;
+          }
+
+          AliAODMCHeader *mcHdr=0;
+          mcHdr=(AliAODMCHeader*)fAODEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+          if(!mcHdr) {
+            Printf("MC header branch not found!\n");
+            return;
+          }
+
+         //cout<<"********MCAOD Events loop for Prabhat *********"<<endl;
+          AliMCEvent* mcEvent = MCEvent();
+          _nTracks = mcEvent->GetNumberOfTracks();
+          _mult3    = _nTracks;
+         //loop over tracks starts here                                                                                                    
+          for (int iTrack=0; iTrack< _nTracks; iTrack++)
+            {
+              AliAODMCParticle *t = (AliAODMCParticle*) mcEvent->GetTrack(iTrack);
+
+              if (!t)
+                {
+                  AliError(Form("AliTaskDptCorrMC::Exec(Option_t *option) No track ofr iTrack=%d", iTrack));
+                  continue;
+               }
+
+              if(!t->IsPhysicalPrimary()) continue;                                                                                      
+              // Remove neutral tracks                                      
+              if(t->Charge() == 0) continue;                                                                                              
+             //Exclude Weak Decay Resonances                                                                                                          
+             if(fExcludeResonancesInMC)
+               {
+                 //cout<<"***************Prabhat on Weak Decay Particles ************"<<endl;                                             
+                 Int_t gMotherIndex = t->GetMother();
+                 if(gMotherIndex != -1) {
+                   AliAODMCParticle* motherTrack = dynamic_cast<AliAODMCParticle *>(mcEvent->GetTrack(gMotherIndex));
+                   if(motherTrack) {
+                     Int_t pdgCodeOfMother = motherTrack->GetPdgCode();
+
+                     if(pdgCodeOfMother == 311   ||
+                          pdgCodeOfMother == -311  ||
+                          pdgCodeOfMother == 3122  ||
+                        pdgCodeOfMother == -3122) continue;
+
+                   }
+                 }
+               }
+
+             //Exclude electrons with PDG                                                                                                 
+             if(fExcludeElectronsInMC) {
+               if(TMath::Abs(t->GetPdgCode()) == 11) continue;
+             }
+
+             //===================================                                                                                         
+              q      = t->Charge();
+              charge = int(q);
+              phi    = t->Phi();
+              pt     = t->Pt();
+              px     = t->Px();
+              py     = t->Py();
+              pz     = t->Pz();
+              eta    = t->Eta();
+             //Particle 1                                                                                                                  
+              if (t->Charge() > 0 && eta > _min_eta_1 && eta < _max_eta_1 && pt > _min_pt_1 && pt < _max_pt_1)
+                {
+
+                  _etadis->Fill(eta);
+                  _phidis->Fill(phi);
+
+                  iPhi   = int( phi/_width_phi_1);
+
+                  if (iPhi<0 || iPhi>=_nBins_phi_1 )
+                    {
+                      AliWarning("AliTaskDptCorrMC::analyze() iPhi<0 || iPhi>=_nBins_phi_1");
+                      return;
+                    }
+
+                  iEta    = int((eta-_min_eta_1)/_width_eta_1);
+                  if (iEta<0 || iEta>=_nBins_eta_1)
+                    {
+                      AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iEta: %d", iEta));
+                      continue;
+                    }
+
+                 iPt     = int((pt -_min_pt_1 )/_width_pt_1 );
+                  if (iPt<0  || iPt >=_nBins_pt_1)
+                    {
+                      AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iPt: %d",iPt));
+                     continue;
+                    }
+                  iEtaPhi = iEta*_nBins_phi_1+iPhi;
+                  iZEtaPhiPt = iVertexP1 + iEtaPhi*_nBins_pt_1 + iPt;
+
+                  if (_correctionWeight_1)
+                    corr = _correctionWeight_1[iZEtaPhiPt];
+                  else
+                    corr = 1;
+                  if (iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_1)
+                    {
+                      AliWarning("AliTaskDptCorrMC::analyze(AliceEvent * event) iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_1");
+                      continue;
+                    }
+
+                 if (_singlesOnly)
+                    {
+
+                      __n1_1_vsPt[iPt]               += corr;          //cout << "step 15" << endl;                                         
+                      __n1_1_vsZEtaPhiPt[iZEtaPhiPt] += corr;       //cout << "step 12" << endl;                                            
+
+                    }
+
+                 else
+                    {
+                      corrPt                      = corr*pt;
+                      _id_1[k1]                   = iTrack;
+                      _charge_1[k1]               = charge;
+                      _iEtaPhi_1[k1]              = iEtaPhi;
+                      _iPt_1[k1]                  = iPt;
+                      _pt_1[k1]                   = pt;
+                      _px_1[k1]                   = px;
+                      _py_1[k1]                   = py;
+                      _pz_1[k1]                   = pz;
+                      _correction_1[k1]           = corr;
+                      __n1_1                      += corr;
+                      __n1_1_vsEtaPhi[iEtaPhi]    += corr;
+                      __s1pt_1                    += corrPt;
+                      __s1pt_1_vsEtaPhi[iEtaPhi]  += corrPt;
+                      __n1Nw_1                    += 1;
+                      __s1ptNw_1                  += pt;
+                      ++k1;
+                      if (k1>=arraySize)
+                        {
+                          AliError(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) k1 >=arraySize; arraySize: %d",arraySize));
+                          return;
+                        }
+                    }
+                }
+
+             if (t->Charge() < 0 && eta > _min_eta_2 && eta < _max_eta_2 && pt > _min_pt_2 && pt < _max_pt_2)
+
+                {
+                  iPhi   = int( phi/_width_phi_2);
+
+                  if (iPhi<0 || iPhi>=_nBins_phi_2 )
+                    {
+                      AliWarning("AliTaskDptCorrMC::analyze() iPhi<0 || iPhi>=_nBins_phi_1");
+                      return;
+                    }
+
+                  iEta    = int((eta-_min_eta_2)/_width_eta_2);
+                  if (iEta<0 || iEta>=_nBins_eta_2)
+                    {
+                      AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iEta: %d", iEta));
+                      continue;
+                    }
+                 iPt     = int((pt -_min_pt_2 )/_width_pt_2 );
+                 if (iPt<0  || iPt >=_nBins_pt_2)
+                    {
+                      AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iPt: %d",iPt));
+                      continue;
+                    }
+
+                  iEtaPhi = iEta*_nBins_phi_2+iPhi;
+                  iZEtaPhiPt = iVertexP2 + iEtaPhi*_nBins_pt_2 + iPt;
+                  if (iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_2)
+                    {
+                      AliWarning("AliTaskDptCorrMC::analyze(AliceEvent * event) iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_2");
+                      continue;
+                    }
+
+
+                 if (_correctionWeight_2)
+                    corr = _correctionWeight_2[iZEtaPhiPt];
+                  else
+                    corr = 1;
+                  //dpt = pt - (charge>0) ? _avgPt_vsEtaPhi_2p[iEtaPhi] : _avgPt_vsEtaPhi_2m[iEtaPhi];                                      
+
+                  if (_singlesOnly)
+                    {
+                      __n1_2_vsPt[iPt]               += corr;          //cout << "step 15" << endl;                                         
+                      __n1_2_vsZEtaPhiPt[iZEtaPhiPt] += corr;       //cout << "step 12" << endl;                                            
+                    }
+                 else
+                    {
+                      corrPt                      = corr*pt;
+                      _id_2[k2]                   = iTrack;         //cout << "step 1" << endl;                                             
+                      _charge_2[k2]               = charge;         //cout << "step 2" << endl;                                             
+                      _iEtaPhi_2[k2]              = iEtaPhi;        //cout << "step 3" << endl;                                             
+                      _iPt_2[k2]                  = iPt;            //cout << "step 4" << endl;                                             
+                      _pt_2[k2]                   = pt;             //cout << "step 5" << endl;                                             
+                      _px_2[k2]                   = px;             //cout << "step 6" << endl;                                             
+                      _py_2[k2]                   = py;             //cout << "step 7" << endl;                                             
+                      _pz_2[k2]                   = pz;             //cout << "step 8" << endl;                                             
+                      _correction_2[k2]           = corr;           //cout << "step 9" << endl;                                             
+                      __n1_2                      += corr;          //cout << "step 10" << endl;                                            
+                      __s1pt_2                    += corrPt;        //cout << "step 13" << endl;                                            
+                      __n1Nw_2                    += 1;
+                      __n1_2_vsEtaPhi[iEtaPhi]    += corr;          //cout << "step 11" << endl;                                            
+                      __s1pt_2_vsEtaPhi[iEtaPhi]  += corrPt;        //cout << "step 14" << endl;                                            
+                      __s1ptNw_2                  += pt;
+                      ++k2;
+                      if (k2>=arraySize)
+                        {
+                          AliWarning(Form("-W- k2 >=arraySize; arraySize: %d",arraySize));
+                          return;
+                        }
+                    }
+
+                 //cout << "done with track" << endl;                                                                                      
+                } //iTrack                                                                                                                  
+            } //data aod loop                                                                                                               
+        } //MC AOD loop ends 
+  
+      if(fAnalysisType == "MCAODreco")
+
+        //cout<<"Prabhat here is working for MC AOD reconstructed events"<<endl;                                                            
+
+       {
+         TExMap *trackMap = new TExMap();//Mapping                                                                                           
+         _nTracks = fAODEvent->GetNumberOfTracks();
+
+         for(Int_t i = 0; i < _nTracks; i++)
+           {
+             AliAODTrack* aodTrack = dynamic_cast<AliAODTrack *>(fAODEvent->GetTrack(i));
+             if(!aodTrack) {
+               AliError(Form("ERROR: Could not retrieve AODtrack %d",i));
+               continue;
+             }
+             Int_t gID = aodTrack->GetID();
+             if (aodTrack->TestFilterBit(1)) trackMap->Add(gID, i);//Global tracks                                      
+           }
+
+         _mult3    = _nTracks;
+
+         AliAODTrack* newAodTrack;
+         //loop over tracks starts here                                                                                                      
+         for (int iTrack=0; iTrack< _nTracks; iTrack++)
+           {
+
+             AliAODTrack *t = dynamic_cast<AliAODTrack *>(fAODEvent->GetTrack(iTrack));
+
+             if(!t) {
+               AliError(Form("ERROR: Could not retrieve AODtrack %d",iTrack));
+               continue;
+             }
+
+             bitOK  = t->TestFilterBit(_trackFilterBit);
+             if (!bitOK) continue;
+
+             Int_t gID = t->GetID();
+             newAodTrack = gID >= 0 ?t : fAODEvent->GetTrack(trackMap->GetValue(-1-gID));
+
+             q      = t->Charge();
+             charge = int(q);
+             phi    = t->Phi();
+             pt     = t->Pt();
+             px     = t->Px();
+             py     = t->Py();
+             pz     = t->Pz();
+             eta    = t->Eta();
+             
+             Double_t nsigmaelectron = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(newAodTrack,(AliPID::EParticleType)AliPID::kElectron));
+             Double_t nsigmapion = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(newAodTrack,(AliPID::EParticleType)AliPID::kPion));
+             Double_t nsigmakaon = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(newAodTrack,(AliPID::EParticleType)AliPID::kKaon));
+             Double_t nsigmaproton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(newAodTrack,(AliPID::EParticleType)AliPID::kProton));
+             
+             if(nsigmaelectron  < fNSigmaCut &&
+                nsigmapion      > fNSigmaCut &&
+                nsigmakaon      > fNSigmaCut &&
+                nsigmaproton    > fNSigmaCut ) continue;
+
+
+             //Particle 1                                                                                                                  
+             if (t->Charge() > 0 && t->Eta() > _min_eta_1 && t->Eta() < _max_eta_1 && t->Pt() > _min_pt_1 && t->Pt() < _max_pt_1)
+               {
+
+                 _etadis->Fill(eta);
+                 _phidis->Fill(phi);
+
+                 iPhi   = int( phi/_width_phi_1);
+
+                 if (iPhi<0 || iPhi>=_nBins_phi_1 )
+                   {
+                     AliWarning("AliTaskDptCorrMC::analyze() iPhi<0 || iPhi>=_nBins_phi_1");
+                     return;
+                   }
+
+                 iEta    = int((eta-_min_eta_1)/_width_eta_1);
+                 if (iEta<0 || iEta>=_nBins_eta_1)
+                   {
+                     AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iEta: %d", iEta));
+                     continue;
+                   }
+                 iPt     = int((pt -_min_pt_1 )/_width_pt_1 );
+                 if (iPt<0  || iPt >=_nBins_pt_1)
+                   {
+                     AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iPt: %d",iPt));
+                     continue;
+                   }
+                 iEtaPhi = iEta*_nBins_phi_1+iPhi;
+                 iZEtaPhiPt = iVertexP1 + iEtaPhi*_nBins_pt_1 + iPt;
+
+                 if (_correctionWeight_1)
+                   corr = _correctionWeight_1[iZEtaPhiPt];
+                 else
+                   corr = 1;
+                 if (iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_1)
+                   {
+                     AliWarning("AliTaskDptCorrMC::analyze(AliceEvent * event) iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_1");
+                     continue;
+                   }
+
+
+                 if (_singlesOnly)
+                   {
+
+                     __n1_1_vsPt[iPt]               += corr;          //cout << "step 15" << endl;                                           
+                     __n1_1_vsZEtaPhiPt[iZEtaPhiPt] += corr;       //cout << "step 12" << endl;                                              
+
+                   }
+
+                 else
+                   {
+                     corrPt                      = corr*pt;
+                     _id_1[k1]                   = iTrack;
+                     _charge_1[k1]               = charge;
+                     _iEtaPhi_1[k1]              = iEtaPhi;
+                     _iPt_1[k1]                  = iPt;
+                     _pt_1[k1]                   = pt;
+                     _px_1[k1]                   = px;
+                     _py_1[k1]                   = py;
+                     _pz_1[k1]                   = pz;
+                     _correction_1[k1]           = corr;
+                     __n1_1                      += corr;
+                     __n1_1_vsEtaPhi[iEtaPhi]    += corr;
+                     __s1pt_1                    += corrPt;
+                     __s1pt_1_vsEtaPhi[iEtaPhi]  += corrPt;
+                     __n1Nw_1                    += 1;
+                     __s1ptNw_1                  += pt;
+                     ++k1;
+                     if (k1>=arraySize)
+                       {
+                         AliError(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) k1 >=arraySize; arraySize: %d",arraySize));
+                         return;
+                       }
+                   }
+               }
+
+             if (t->Charge() < 0 && t->Eta() > _min_eta_2 && t->Eta() < _max_eta_2 && t->Pt() > _min_pt_2 &&
+                 t->Pt() < _max_pt_2)
+               {
+                 //===================================                                                                                       
+
+                 iPhi   = int( phi/_width_phi_2);
+
+                 if (iPhi<0 || iPhi>=_nBins_phi_2 )
+                   {
+                     AliWarning("AliTaskDptCorrMC::analyze() iPhi<0 || iPhi>=_nBins_phi_1");
+                     return;
+                   }
+
+                 iEta    = int((eta-_min_eta_2)/_width_eta_2);
+                 if (iEta<0 || iEta>=_nBins_eta_2)
+                   {
+                     AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iEta: %d", iEta));
+                     continue;
+                   }
+                 iPt     = int((pt -_min_pt_2 )/_width_pt_2 );
+                 if (iPt<0  || iPt >=_nBins_pt_2)
+                   {
+                     AliWarning(Form("AliTaskDptCorrMC::analyze(AliceEvent * event) Mismatched iPt: %d",iPt));
+                     continue;
+                   }
+
+                 iEtaPhi = iEta*_nBins_phi_2+iPhi;
+                 iZEtaPhiPt = iVertexP2 + iEtaPhi*_nBins_pt_2 + iPt;
+                 if (iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_2)
+                   {
+                     AliWarning("AliTaskDptCorrMC::analyze(AliceEvent * event) iZEtaPhiPt<0 || iZEtaPhiPt>=_nBins_zEtaPhiPt_2");
+                     continue;
+                   }
+
+
+                 if (_correctionWeight_2)
+                   corr = _correctionWeight_2[iZEtaPhiPt];
+                 else
+                   corr = 1;
+                 //dpt = pt - (charge>0) ? _avgPt_vsEtaPhi_2p[iEtaPhi] : _avgPt_vsEtaPhi_2m[iEtaPhi];                                        
+
+                 if (_singlesOnly)
+                   {
+                     __n1_2_vsPt[iPt]               += corr;          //cout << "step 15" << endl;                                           
+                     __n1_2_vsZEtaPhiPt[iZEtaPhiPt] += corr;       //cout << "step 12" << endl;                                              
+                   }
+
+                 else
+                   {
+                     corrPt                      = corr*pt;
+                     _id_2[k2]                   = iTrack;         //cout << "step 1" << endl;                                               
+                     _charge_2[k2]               = charge;         //cout << "step 2" << endl;                                               
+                     _iEtaPhi_2[k2]              = iEtaPhi;        //cout << "step 3" << endl;                                               
+                     _iPt_2[k2]                  = iPt;            //cout << "step 4" << endl;                                               
+                     _pt_2[k2]                   = pt;             //cout << "step 5" << endl;                                               
+                     _px_2[k2]                   = px;             //cout << "step 6" << endl;                                               
+                     _py_2[k2]                   = py;             //cout << "step 7" << endl;                                               
+                     _pz_2[k2]                   = pz;             //cout << "step 8" << endl;                                               
+                     _correction_2[k2]           = corr;           //cout << "step 9" << endl;                                               
+                     __n1_2                      += corr;          //cout << "step 10" << endl;                                              
+                     __s1pt_2                    += corrPt;        //cout << "step 13" << endl;                                              
+                     __n1Nw_2                    += 1;
+                     __n1_2_vsEtaPhi[iEtaPhi]    += corr;          //cout << "step 11" << endl;                                              
+                     __s1pt_2_vsEtaPhi[iEtaPhi]  += corrPt;        //cout << "step 14" << endl;                                              
+                     __s1ptNw_2                  += pt;
+                     ++k2;
+
+                     if (k2>=arraySize)
+                       {
+                         AliWarning(Form("-W- k2 >=arraySize; arraySize: %d",arraySize));
+                         return;
+                       }
+                   }
+
+                 //cout << "done with track" << endl;                                                                                        
+               } //iTrack                                                                                                                    
+           } //data aod loop                                                                                                                 
+       } //MC AOD loop ends                                                                                                                  
+
+      //---------------------------------                                                                                                   
+    } //AOD events             
+  //cout << "Filling histograms now" << endl;                                                                                               
+  _m0->Fill(_mult0);
+  _m1->Fill(_mult1);
+  _m2->Fill(_mult2);
+  _m3->Fill(_mult3);
+  _m4->Fill(_mult4);
+  _m5->Fill(_mult5);
+  _m6->Fill(_mult6);
+  _vertexZ->Fill(vertexZ);
+
+  if (_singlesOnly)
+    {
+      // nothing to do here.                                                                                                                
+    }
+  else
+    {
+      if (_sameFilter)
+        {
+          _n1_1_vsM->Fill(centrality,      __n1_1);
+          _s1pt_1_vsM->Fill(centrality,    __s1pt_1);
+          _n1Nw_1_vsM->Fill(centrality,    __n1Nw_1);
+          _s1ptNw_1_vsM->Fill(centrality,  __s1ptNw_1);
+          _n1_2_vsM->Fill(centrality,      __n1_1);
+          _s1pt_2_vsM->Fill(centrality,    __s1pt_1);
+          _n1Nw_2_vsM->Fill(centrality,    __n1Nw_1);
+          _s1ptNw_2_vsM->Fill(centrality,  __s1ptNw_1);
+          // reset pair counters                                                                                                            
+          __n2_12   = __s2ptpt_12   = __s2NPt_12    = __s2PtN_12    = 0;
+          __n2Nw_12 = __s2ptptNw_12 = __s2NPtNw_12  = __s2PtNNw_12  = 0;
+         if (_field>0)
+            {
+              for (int i1=0; i1<k1; i1++)
+                {
+                  ////cout << "         i1:" << i1 << endl;                                                                                 
+                  id_1      = _id_1[i1];           ////cout << "       id_1:" << id_1 << endl;                                              
+                  q_1       = _charge_1[i1];       ////cout << "        q_1:" << q_1 << endl;                                               
+                  iEtaPhi_1 = _iEtaPhi_1[i1];      ////cout << "  iEtaPhi_1:" << iEtaPhi_1 << endl;                                         
+                  iPt_1     = _iPt_1[i1];          ////cout << "      iPt_1:" << iPt_1 << endl;                                             
+                  corr_1    = _correction_1[i1];   ////cout << "     corr_1:" << corr_1 << endl;                                            
+                  pt_1      = _pt_1[i1];           ////cout << "       pt_1:" << pt_1 << endl;                                              
+
+
+                 //1 and 2                                                                                                                 
+                  for (int i2=i1+1; i2<k1; i2++)
+                    {
+                      ////cout << "         i2:" << i2 << endl;                                                                             
+                      id_2      = _id_1[i2];              ////cout << "       id_2:" << id_2 << endl;                                       
+                      if (id_1!=id_2)
+                        {
+                          q_2       = _charge_1[i2];     ////cout << "        q_1:" << q_1 << endl;                                         
+                          iEtaPhi_2 = _iEtaPhi_1[i2];    ////cout << "  iEtaPhi_1:" << iEtaPhi_1 << endl;                                   
+                          iPt_2     = _iPt_1[i2];        ////cout << "      iPt_1:" << iPt_1 << endl;                                       
+                          corr_2    = _correction_1[i2]; ////cout << "     corr_1:" << corr_1 << endl;                                      
+                          pt_2      = _pt_1[i2];         ////cout << "       pt_1:" << pt_1 << endl;                                        
+
+                          corr      = corr_1*corr_2;
+                          if (q_2>q_1 || (q_1>0 && q_2>0 && pt_2<=pt_1) || (q_1<0 && q_2<0 && pt_2>=pt_1))
+                            {
+                              ij = iEtaPhi_1*_nBins_etaPhi_1 + iEtaPhi_2;   ////cout << " ij:" << ij<< endl;                                
+                            }
+                          else // swap particles                                                                                            
+                            {
+                              ij = iEtaPhi_2*_nBins_etaPhi_1 + iEtaPhi_1;   ////cout << " ij:" << ij<< endl;                                
+                            }
+
+                         __n2_12                  += corr;
+                          __n2_12_vsEtaPhi[ij]     += corr;
+                          ptpt                     = pt_1*pt_2;
+                          __s2ptpt_12              += corr*ptpt;
+                          __s2PtN_12               += corr*pt_1;
+                          __s2NPt_12               += corr*pt_2;
+                          __s2ptpt_12_vsEtaPhi[ij] += corr*ptpt;
+                          __s2PtN_12_vsEtaPhi[ij]  += corr*pt_1;
+                          __s2NPt_12_vsEtaPhi[ij]  += corr*pt_2;
+                          __n2_12_vsPtPt[iPt_1*_nBins_pt_2 + iPt_2] += corr;
+
+                          __n2Nw_12                  += 1;
+                          __s2ptptNw_12              += ptpt;
+                          __s2PtNNw_12               += pt_1;
+                          __s2NPtNw_12               += pt_2;
+
+                        }
+                    } //i2                                                                                                                  
+                } //i1                                                                                                                      
+            }
+
+         else // field<0                                                                                                                   
+            {
+              for (int i1=0; i1<k1; i1++)
+                {
+                  ////cout << "         i1:" << i1 << endl;                                                                                 
+                  id_1      = _id_1[i1];           ////cout << "       id_1:" << id_1 << endl;                                              
+                  q_1       = _charge_1[i1];       ////cout << "        q_1:" << q_1 << endl;                                               
+                  iEtaPhi_1 = _iEtaPhi_1[i1];      ////cout << "  iEtaPhi_1:" << iEtaPhi_1 << endl;                                         
+                  iPt_1     = _iPt_1[i1];          ////cout << "      iPt_1:" << iPt_1 << endl;                                             
+                  corr_1    = _correction_1[i1];   ////cout << "     corr_1:" << corr_1 << endl;                                            
+                  pt_1      = _pt_1[i1];           ////cout << "       pt_1:" << pt_1 << endl;                                              
+
+                 //1 and 2                                                                                                                 
+                  for (int i2=i1+1; i2<k1; i2++)
+                    {
+                      ////cout << "         i2:" << i2 << endl;                                                                             
+                      id_2      = _id_1[i2];              ////cout << "       id_2:" << id_2 << endl;                                       
+                      if (id_1!=id_2)
+                        {
+                          q_2       = _charge_1[i2];     ////cout << "        q_2:" << q_2 << endl;                                         
+                          iEtaPhi_2 = _iEtaPhi_1[i2];    ////cout << "  iEtaPhi_2:" << iEtaPhi_2 << endl;                                   
+                          iPt_2     = _iPt_1[i2];        ////cout << "      iPt_2:" << iPt_2 << endl;                                       
+                          corr_2    = _correction_1[i2]; ////cout << "     corr_2:" << corr_2 << endl;                                      
+                          pt_2      = _pt_1[i2];         ////cout << "       pt_2:" << pt_2 << endl;                                        
+                          corr      = corr_1*corr_2;
+                          if ( q_2<q_1 || (q_1>0 && q_2>0 && pt_2>=pt_1) || (q_1<0 && q_2<0 && pt_2<=pt_1))
+                            {
+                              ij = iEtaPhi_1*_nBins_etaPhi_1 + iEtaPhi_2;   ////cout << " ij:" << ij<< endl;                                
+                            }
+                          else // swap particles                                                                                            
+                            {
+                              ij = iEtaPhi_2*_nBins_etaPhi_1 + iEtaPhi_1;   ////cout << " ij:" << ij<< endl;                                
+                            }
+
+                         __n2_12                  += corr;
+                          __n2_12_vsEtaPhi[ij]     += corr;
+                          ptpt                     = pt_1*pt_2;
+                          __s2ptpt_12              += corr*ptpt;
+                          __s2PtN_12               += corr*pt_1;
+                          __s2NPt_12               += corr*pt_2;
+                          __s2ptpt_12_vsEtaPhi[ij] += corr*ptpt;
+                          __s2PtN_12_vsEtaPhi[ij]  += corr*pt_1;
+                          __s2NPt_12_vsEtaPhi[ij]  += corr*pt_2;
+                          __n2_12_vsPtPt[iPt_1*_nBins_pt_2 + iPt_2] += corr;
+
+                          __n2Nw_12                  += 1;
+                          __s2ptptNw_12              += ptpt;
+                          __s2PtNNw_12               += pt_1;
+                          __s2NPtNw_12               += pt_2;
+
+                       }
+                    } //i2                                                                                                                  
+                } //i1                                                                                                                      
+            }
+        }
+      else  // filter 1 and 2 are different -- must do all particle pairs...                                                                
+        {
+          _n1_1_vsM->Fill(centrality,      __n1_1);
+          _s1pt_1_vsM->Fill(centrality,    __s1pt_1);
+          _n1Nw_1_vsM->Fill(centrality,    __n1Nw_1);
+          _s1ptNw_1_vsM->Fill(centrality,  __s1ptNw_1);
+          _n1_2_vsM->Fill(centrality,      __n1_2);
+          _s1pt_2_vsM->Fill(centrality,    __s1pt_2);
+          _n1Nw_2_vsM->Fill(centrality,    __n1Nw_2);
+          _s1ptNw_2_vsM->Fill(centrality,  __s1ptNw_2);
+          // reset pair counters                                  
+         __n2_12   = __s2ptpt_12   = __s2NPt_12    = __s2PtN_12    = 0;
+          __n2Nw_12 = __s2ptptNw_12 = __s2NPtNw_12  = __s2PtNNw_12  = 0;
+          for (int i1=0; i1<k1; i1++)
+            {
+              ////cout << "         i1:" << i1 << endl;                                                                                     
+              id_1      = _id_1[i1];           ////cout << "       id_1:" << id_1 << endl;                                                  
+              q_1       = _charge_1[i1];       ////cout << "        q_1:" << q_1 << endl;                                                   
+              iEtaPhi_1 = _iEtaPhi_1[i1];      ////cout << "  iEtaPhi_1:" << iEtaPhi_1 << endl;                                             
+              iPt_1     = _iPt_1[i1];          ////cout << "      iPt_1:" << iPt_1 << endl;                                                 
+              corr_1    = _correction_1[i1];   ////cout << "     corr_1:" << corr_1 << endl;                                                
+              pt_1      = _pt_1[i1];           ////cout << "       pt_1:" << pt_1 << endl;                                                  
+              px_1      = _px_1[i1];          ////cout << "      px_1:" << px_1 << endl;                                                    
+              py_1      = _py_1[i1];          ////cout << "      py_1:" << py_1 << endl;                                                    
+              pz_1      = _pz_1[i1];          ////cout << "      pz_1:" << pz_1 << endl;                        
+             //1 and 2                                                                                                                     
+              for (int i2=0; i2<k2; i2++)
+                {
+                  ////cout << "         i2:" << i2 << endl;                                                                                 
+                  id_2   = _id_2[i2];              ////cout << "       id_2:" << id_2 << endl;                                              
+                  if (id_1!=id_2)  // exclude auto correlation                                                                              
+                    {
+                      q_2       = _charge_2[i2];     ////cout << "        q_2:" << q_2 << endl;                                             
+                      iEtaPhi_2 = _iEtaPhi_2[i2];    ////cout << "  iEtaPhi_2:" << iEtaPhi_2 << endl;                                       
+                      iPt_2     = _iPt_2[i2];        ////cout << "      iPt_2:" << iPt_2 << endl;                                           
+                      corr_2    = _correction_2[i2]; ////cout << "     corr_2:" << corr_2 << endl;                                          
+                      pt_2      = _pt_2[i2];         ////cout << "       pt_2:" << pt_2 << endl;                                            
+                      px_2      = _px_2[i2];          ////cout << "      px_2:" << px_2 << endl;                                            
+                      py_2      = _py_2[i2];          ////cout << "      py_2:" << py_2 << endl;                                            
+                      pz_2      = _pz_2[i2];          ////cout << "      pz_2:" << pz_2 << endl;                                            
+
+
+                     if (_rejectPairConversion)
+                        {
+                          float e1Sq = massElecSq + pt_1*pt_1 + pz_1*pz_1;
+                          float e2Sq = massElecSq + pt_2*pt_2 + pz_2*pz_2;
+                          float mInvSq = 2*(massElecSq + sqrt(e1Sq*e2Sq) - px_1*px_2 - py_1*py_2 - pz_1*pz_2 );
+                          float mInv = sqrt(mInvSq);
+                          _invMass->Fill(mInv);
+                        }
+
+                     corr      = corr_1*corr_2;
+                      ij        = iEtaPhi_1*_nBins_etaPhi_1 + iEtaPhi_2;   ////cout << " ij:" << ij<< endl;                                 
+                      __n2_12                  += corr;
+                      __n2_12_vsEtaPhi[ij]     += corr;
+                      ptpt                     = pt_1*pt_2;
+                      __s2ptpt_12              += corr*ptpt;
+                      __s2PtN_12               += corr*pt_1;
+                      __s2NPt_12               += corr*pt_2;
+                      __s2ptpt_12_vsEtaPhi[ij] += corr*ptpt;
+                      __s2PtN_12_vsEtaPhi[ij]  += corr*pt_1;
+                      __s2NPt_12_vsEtaPhi[ij]  += corr*pt_2;
+                      __n2_12_vsPtPt[iPt_1*_nBins_pt_2 + iPt_2] += corr;
+                      __n2Nw_12                  += 1;
+                      __s2ptptNw_12              += ptpt;
+                      __s2PtNNw_12               += pt_1;
+                      __s2NPtNw_12               += pt_2;
+
+                    }
+                } //i2                                                                                                                      
+            } //i1                                                                                                                          
+        }
+
+      _n2_12_vsM->Fill(centrality,     __n2_12);
+      _s2PtPt_12_vsM->Fill(centrality, __s2ptpt_12);
+      _s2PtN_12_vsM->Fill(centrality,  __s2NPt_12);
+      _s2NPt_12_vsM->Fill(centrality,  __s2PtN_12);
+
+      _n2Nw_12_vsM->Fill(centrality,     __n2Nw_12);
+      _s2PtPtNw_12_vsM->Fill(centrality, __s2ptptNw_12);
+      _s2PtNNw_12_vsM->Fill(centrality,  __s2NPtNw_12);
+      _s2NPtNw_12_vsM->Fill(centrality,  __s2PtNNw_12);
+
+    }
+
+
+  AliInfo("AliTaskDptCorrMC::UserExec()   -----------------Event Done ");
+  PostData(0,_outputHistoList);
+
+} //End of UserExec     
+
+
+
+
+void   AliDptDptInMC::FinishTaskOutput()
+{
+  AliInfo("AliDptDptInMC::FinishTaskOutput() Starting.");
+  Printf("= 0 ====================================================================");
+  finalizeHistograms();
+  AliInfo("= 1 ====================================================================");
+  PostData(0,_outputHistoList);
+  AliInfo("= 2 ====================================================================");
+  AliInfo("AliDptDptInMC::FinishTaskOutput() Done.");
+}
+
+void   AliDptDptInMC::Terminate(Option_t* /*option*/)
+{
+  AliInfo("AliDptDptInMC::Terminate() Starting/Done.");
+}
+
+
+//Tools
+//===================================================================================================
+void  AliDptDptInMC::fillHistoWithArray(TH1 * h, float * array, int size)
+{
+  int i, i1;
+  float v1, ev1, v2, ev2, sum, esum;
+  for (i=0, i1=1; i<size; ++i,++i1)
+    {
+    v1  = array[i]; ev1 = sqrt(v1);
+    v2  = h->GetBinContent(i1);
+    ev2 = h->GetBinError(i1);
+    sum = v1 + v2;
+    esum = sqrt(ev1*ev1+ev2*ev2);
+    h->SetBinContent(i1,sum);
+    h->SetBinError(i1,esum);
+    }
+}
+
+void  AliDptDptInMC::fillHistoWithArray(TH2 * h, float * array, int size1, int size2)
+{
+  int i, i1;
+  int j, j1;
+  float v1, ev1, v2, ev2, sum, esum;
+  for (i=0, i1=1; i<size1; ++i,++i1)
+    {
+    for (j=0, j1=1; j<size2; ++j,++j1)
+      {
+      v1  = array[i*size2+j]; ev1 = sqrt(v1);
+      v2  = h->GetBinContent(i1,j1);
+      ev2 = h->GetBinError(i1,j1);
+      sum = v1 + v2;
+      esum = sqrt(ev1*ev1+ev2*ev2);
+      h->SetBinContent(i1,j1,sum);
+      h->SetBinError(i1,j1,esum);
+      }
+    }
+}
+
+void  AliDptDptInMC::fillHistoWithArray(TH3 * h, float * array, int size1, int size2, int size3)
+{
+  int i, i1;
+  int j, j1;
+  int k, k1;
+  float v1, ev1, v2, ev2, sum, esum;
+  int size23 = size2*size3;
+  for (i=0, i1=1; i<size1; ++i,++i1)
+    {
+    for (j=0, j1=1; j<size2; ++j,++j1)
+      {
+      for (k=0, k1=1; k<size3; ++k,++k1)
+        {
+        v1  = array[i*size23+j*size3+k]; ev1 = sqrt(v1);
+        v2  = h->GetBinContent(i1,j1,k1);
+        ev2 = h->GetBinError(i1,j1,k1);
+        sum = v1 + v2;
+        esum = sqrt(ev1*ev1+ev2*ev2);
+        h->SetBinContent(i1,j1,k1,sum);
+        h->SetBinError(i1,j1,k1,esum);
+        }
+      }
+    }
+}
+
+void  AliDptDptInMC::fillHistoWithArray(TH1 * h, double * array, int size)
+{
+  int i, i1;
+  double v1, ev1, v2, ev2, sum, esum;
+  for (i=0, i1=1; i<size; ++i,++i1)
+    {
+    v1  = array[i]; ev1 = sqrt(v1);
+    v2  = h->GetBinContent(i1);
+    ev2 = h->GetBinError(i1);
+    sum = v1 + v2;
+    esum = sqrt(ev1*ev1+ev2*ev2);
+    h->SetBinContent(i1,sum);
+    h->SetBinError(i1,esum);
+    }
+}
+
+void  AliDptDptInMC::fillHistoWithArray(TH2 * h, double * array, int size1, int size2)
+{
+  int i, i1;
+  int j, j1;
+  double v1, ev1, v2, ev2, sum, esum;
+  for (i=0, i1=1; i<size1; ++i,++i1)
+    {
+    for (j=0, j1=1; j<size2; ++j,++j1)
+      {
+      v1  = array[i*size2+j]; ev1 = sqrt(v1);
+      v2  = h->GetBinContent(i1,j1);
+      ev2 = h->GetBinError(i1,j1);
+      sum = v1 + v2;
+      esum = sqrt(ev1*ev1+ev2*ev2);
+      h->SetBinContent(i1,j1,sum);
+      h->SetBinError(i1,j1,esum);
+      }
+    }
+}
+
+void  AliDptDptInMC::fillHistoWithArray(TH3 * h, double * array, int size1, int size2, int size3)
+{
+  int i, i1;
+  int j, j1;
+  int k, k1;
+  double v1, ev1, v2, ev2, sum, esum;
+  int size23 = size2*size3;
+  for (i=0, i1=1; i<size1; ++i,++i1)
+    {
+    for (j=0, j1=1; j<size2; ++j,++j1)
+      {
+      for (k=0, k1=1; k<size3; ++k,++k1)
+        {
+        v1  = array[i*size23+j*size3+k]; ev1 = sqrt(v1);
+        v2  = h->GetBinContent(i1,j1,k1);
+        ev2 = h->GetBinError(i1,j1,k1);
+        sum = v1 + v2;
+        esum = sqrt(ev1*ev1+ev2*ev2);
+        h->SetBinContent(i1,j1,k1,sum);
+        h->SetBinError(i1,j1,k1,esum);
+        }
+      }
+    }
+}
+
+//________________________________________________________________________
+double *  AliDptDptInMC::getDoubleArray(int size, double v)
+{
+  /// Allocate an array of type double with n values
+  /// Initialize the array to the given value
+  double * array = new double [size];
+  for (int i=0;i<size;++i) array[i]=v;
+  return array;
+}
+
+//________________________________________________________________________
+float *  AliDptDptInMC::getFloatArray(int size, float v)
+{
+  /// Allocate an array of type float with n values
+  /// Initialize the array to the given value
+  float * array = new float [size];
+  for (int i=0;i<size;++i) array[i]=v;
+  return array;
+}
+
+
+//________________________________________________________________________
+TH1D * AliDptDptInMC::createHisto1D(const TString &  name, const TString &  title, 
+                                                      int n, double xMin, double xMax, 
+                                                      const TString &  xTitle, const TString &  yTitle)
+{
+  //CreateHisto new 1D historgram
+  AliInfo(Form("createHisto 1D histo %s   nBins: %d  xMin: %f   xMax: %f",name.Data(),n,xMin,xMax));
+  TH1D * h = new TH1D(name,title,n,xMin,xMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TH1D * AliDptDptInMC::createHisto1D(const TString &  name, const TString &  title, 
+                                                      int n, double * bins, 
+                                                      const TString &  xTitle, const TString &  yTitle)
+{
+  AliInfo(Form("createHisto 1D histo %s   with %d non uniform nBins",name.Data(),n));
+  TH1D * h = new TH1D(name,title,n,bins);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TH2D * AliDptDptInMC::createHisto2D(const TString &  name, const TString &  title, 
+                                                      int nx, double xMin, double xMax, int ny, double yMin, double yMax, 
+                                                      const TString &  xTitle, const TString &  yTitle, const TString &  zTitle)
+{
+  AliInfo(Form("createHisto 2D histo %s  nx: %d  xMin: %f10.4 xMax: %f10.4  ny: %d   yMin: %f10.4 yMax: %f10.4",name.Data(),nx,xMin,xMax,ny,yMin,yMax));
+  TH2D * h = new TH2D(name,title,nx,xMin,xMax,ny,yMin,yMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  h->GetZaxis()->SetTitle(zTitle);
+  addToList(h);
+  return h;
+}
+
+//________________________________________________________________________
+TH2D * AliDptDptInMC::createHisto2D(const TString &  name, const TString &  title, 
+                                                      int nx, double* xbins, int ny, double yMin, double yMax, 
+                                                      const TString &  xTitle, const TString &  yTitle, const TString &  zTitle)
+{
+  AliInfo(Form("createHisto 2D histo %s   with %d non uniform nBins",name.Data(),nx));
+  TH2D * h;
+  h = new TH2D(name,title,nx,xbins,ny,yMin,yMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  h->GetZaxis()->SetTitle(zTitle);
+  addToList(h);
+  return h;
+}
+
+//// F /////
+//________________________________________________________________________
+TH1F * AliDptDptInMC::createHisto1F(const TString &  name, const TString &  title, 
+                                                        int n, double xMin, double xMax, 
+                                                        const TString &  xTitle, const TString &  yTitle)
+{
+  //CreateHisto new 1D historgram
+  AliInfo(Form("createHisto 1D histo %s   nBins: %d  xMin: %f   xMax: %f",name.Data(),n,xMin,xMax));
+  TH1F * h = new TH1F(name,title,n,xMin,xMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TH1F * AliDptDptInMC::createHisto1F(const TString &  name, const TString &  title, 
+                                                        int n, double * bins, 
+                                                        const TString &  xTitle, const TString &  yTitle)
+{
+  AliInfo(Form("createHisto 1D histo %s   with %d non uniform nBins",name.Data(),n));
+  TH1F * h = new TH1F(name,title,n,bins);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TH2F * AliDptDptInMC::createHisto2F(const TString &  name, const TString &  title, 
+                                                        int nx, double xMin, double xMax, int ny, double yMin, double yMax, 
+                                                        const TString &  xTitle, const TString &  yTitle, const TString &  zTitle)
+{
+  AliInfo(Form("createHisto 2D histo %s  nx: %d  xMin: %f10.4 xMax: %f10.4  ny: %d   yMin: %f10.4 yMax: %f10.4",name.Data(),nx,xMin,xMax,ny,yMin,yMax));
+  TH2F * h = new TH2F(name,title,nx,xMin,xMax,ny,yMin,yMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  h->GetZaxis()->SetTitle(zTitle);
+  addToList(h);
+  return h;
+}
+
+//________________________________________________________________________
+TH2F * AliDptDptInMC::createHisto2F(const TString &  name, const TString &  title, 
+                                                        int nx, double* xbins, int ny, double yMin, double yMax, 
+                                                        const TString &  xTitle, const TString &  yTitle, const TString &  zTitle)
+{
+  AliInfo(Form("createHisto 2D histo %s   with %d non uniform nBins",name.Data(),nx));
+  TH2F * h;
+  h = new TH2F(name,title,nx,xbins,ny,yMin,yMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  h->GetZaxis()->SetTitle(zTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TH3F * AliDptDptInMC::createHisto3F(const TString &  name, const TString &  title, 
+                                                      int nx, double xMin, double xMax, 
+                                                      int ny, double yMin, double yMax, 
+                                                      int nz, double zMin, double zMax, 
+                                                      const TString &  xTitle, const TString &  yTitle, const TString &  zTitle)
+{
+  AliInfo(Form("createHisto 2D histo %s  nx: %d  xMin: %f10.4 xMax: %f10.4  ny: %d   yMin: %f10.4 yMax: %f10.4 nz: %d   zMin: %f10.4 zMax: %f10.4",name.Data(),nx,xMin,xMax,ny,yMin,yMax,nz,zMin,zMax));
+  TH3F * h = new TH3F(name,title,nx,xMin,xMax,ny,yMin,yMax,nz,zMin,zMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  h->GetZaxis()->SetTitle(zTitle);
+  addToList(h);
+  return h;
+}
+
+
+//________________________________________________________________________
+TProfile * AliDptDptInMC::createProfile(const TString & name, const TString & description, 
+                                                            int nx,double xMin,double xMax,
+                                                            const TString &  xTitle, const TString &  yTitle)
+{
+  AliInfo(Form("createHisto 1D profile %s   nBins: %d  xMin: %f10.4 xMax: %f10.4",name.Data(),nx,xMin,xMax));
+  TProfile * h = new TProfile(name,description,nx,xMin,xMax);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;  
+}
+
+//________________________________________________________________________
+TProfile * AliDptDptInMC::createProfile(const TString &  name,const TString &  description, 
+                                                            int nx,  double* bins,
+                                                            const TString &  xTitle, const TString &  yTitle)
+{
+  AliInfo(Form("createHisto 1D profile %s  with %d non uniform bins",name.Data(),nx));
+  TProfile * h = new TProfile(name,description,nx,bins);
+  h->GetXaxis()->SetTitle(xTitle);
+  h->GetYaxis()->SetTitle(yTitle);
+  addToList(h);
+  return h;
+}
+
+
+void   AliDptDptInMC::addToList(TH1 *h)
+{
+  if (_outputHistoList)
+    {
+    _outputHistoList->Add(h);
+    }
+  else
+    AliInfo("addToList(TH1 *h) _outputHistoList is null!!!!! Should abort ship");
+
+}
+
+
+
diff --git a/PWGCF/Correlations/DPhi/AliDptDptInMC.h b/PWGCF/Correlations/DPhi/AliDptDptInMC.h
new file mode 100644 (file)
index 0000000..870043b
--- /dev/null
@@ -0,0 +1,479 @@
+#ifndef AliDptDptInMC_H_Included
+#define AliDptDptInMC_H_Included
+
+#include "AliAnalysisTaskSE.h"
+#include "TString.h"
+#include "AliLog.h"
+
+#include "AliPID.h"
+#include "AliPIDResponse.h"
+
+class AliAODEvent;
+class AliESDEvent;
+class AliInputEventHandler;
+class TH1;
+class TH2;
+class TH2;
+class TH3;
+class TH1F;
+class TH2F;
+class TH2F;
+class TH3F;
+class TH1D;
+class TH2D;
+class TH2D;
+class TH3D;
+class TProfile;
+
+
+
+class AliDptDptInMC : public AliAnalysisTaskSE
+{
+public:
+  AliDptDptInMC();  
+  AliDptDptInMC(const TString & name);
+  
+private:
+  AliDptDptInMC(const  AliDptDptInMC&);
+  const AliDptDptInMC& operator=(const  AliDptDptInMC&);
+
+public:
+  virtual ~AliDptDptInMC();
+
+  // Implementation of interace methods
+  //virtual void   ConnectInputData(Option_t *);
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   FinishTaskOutput();
+  virtual void   Terminate(Option_t* );   
+  virtual void   createHistograms();
+  virtual void   finalizeHistograms();
+  
+  virtual void   addToList(TH1 *h);
+
+  TH1D * createHisto1D(const TString &  name, const TString &  title,int n, double xmin, double xmax,const TString &  xTitle, const TString &  yTitle);
+  TH1D * createHisto1D(const TString &  name, const TString &  title,int n, double * bins,const TString &  xTitle, const TString &  yTitle);
+  TH2D * createHisto2D(const TString &  name, const TString &  title, 
+                       int nx, double xmin, double xmax, int ny, double ymin, double ymax, const TString &  xTitle, const TString &  yTitle, const TString &  zTitle);
+  TH2D * createHisto2D(const TString &  name, const TString &  title, int nx, double* xbins, int ny, double ymin, double ymax, 
+                       const TString &  xTitle, const TString &  yTitle, const TString &  zTitle);
+
+  TH1F * createHisto1F(const TString &  name, const TString &  title,int n, double xmin, double xmax,const TString &  xTitle, const TString &  yTitle);
+  TH1F * createHisto1F(const TString &  name, const TString &  title,int n, double * bins,const TString &  xTitle, const TString &  yTitle);
+  TH2F * createHisto2F(const TString &  name, const TString &  title, 
+                       int nx, double xmin, double xmax, int ny, double ymin, double ymax, const TString &  xTitle, const TString &  yTitle, const TString &  zTitle);
+  TH2F * createHisto2F(const TString &  name, const TString &  title, int nx, double* xbins, int ny, double ymin, double ymax, 
+                       const TString &  xTitle, const TString &  yTitle, const TString &  zTitle);
+  TH3F * createHisto3F(const TString &  name, const TString &  title, 
+                       int nx, double xmin, double xmax, int ny, double ymin, double ymax, int nz, double zmin, double zmax, 
+                       const TString &  xTitle, const TString &  yTitle, const TString &  zTitle);  
+  TProfile * createProfile(const TString &  title,const TString &  description, int n,  double xMin,double xMax,
+                           const TString &  xTitle, const TString &  yTitle);
+  TProfile * createProfile(const TString &  name,const TString &  description, 
+                           int nx,  double* bins,
+                           const TString &  xTitle, const TString &  yTitle);
+  
+  //________________________________________________________________________
+  
+  float  * getFloatArray(int size, float v);
+  double * getDoubleArray(int size, double v);
+  void fillHistoWithArray(TH1 * h, double * array, int size);
+  void fillHistoWithArray(TH2 * h, double * array, int size1, int size2);
+  void fillHistoWithArray(TH3 * h, double * array, int size1, int size2, int size3);
+  void fillHistoWithArray(TH1 * h, float * array, int size);
+  void fillHistoWithArray(TH2 * h, float * array, int size1, int size2);
+  void fillHistoWithArray(TH3 * h, float * array, int size1, int size2, int size3);
+
+
+
+  
+  virtual     void    SetDebugLevel( int v )              { _debugLevel   = v; }
+  virtual     void    SetSinglesOnly(int v)               { _singlesOnly  = v; } 
+  virtual     void    SetUseWeights(int v)                { _useWeights   = v; } 
+  virtual     void    SetSameFilter(int v)                { _sameFilter   = v; }
+  
+  virtual     void    SetRejectPileup(int v)              { _rejectPileup         = v; } 
+  virtual     void    SetRejectPairConversion(int v)      { _rejectPairConversion = v; } 
+  virtual     void    SetVertexZMin(double v)             { _vertexZMin           = v; } 
+  virtual     void    SetVertexZMax(double v)             { _vertexZMax           = v; } 
+  virtual     void    SetVertexXYMin(double v)            { _vertexXYMin          = v; } 
+  virtual     void    SetVertexXYMax(double v)            { _vertexXYMax          = v; } 
+  virtual     void    SetCentralityMethod(int v)          { _centralityMethod     = v; }
+  virtual     void    SetCentrality(double centralityMin, double centralityMax)
+  {
+    _centralityMin = centralityMin;
+    _centralityMax = centralityMax;
+  }
+  virtual     void    SetRequestedCharge_1(int v)     { _requestedCharge_1 = v; }
+  virtual     void    SetRequestedCharge_2(int v)     { _requestedCharge_2 = v; }
+  virtual     void    SetPtMin1( double v)            { _min_pt_1          = v; } 
+  virtual     void    SetPtMax1( double v)            { _max_pt_1          = v; } 
+  virtual     void    SetEtaMin1(double v)            { _min_eta_1         = v; } 
+  virtual     void    SetEtaMax1(double v)            { _max_eta_1         = v; } 
+  virtual     void    SetPtMin2( double v)            { _min_pt_2          = v; } 
+  virtual     void    SetPtMax2( double v)            { _max_pt_2          = v; } 
+  virtual     void    SetEtaMin2(double v)            { _min_eta_2         = v; } 
+  virtual     void    SetEtaMax2(double v)            { _max_eta_2         = v; } 
+  virtual     void    SetDcaZMin(double v)            { _dcaZMin           = v; } 
+  virtual     void    SetDcaZMax(double v)            { _dcaZMax           = v; } 
+  virtual     void    SetDcaXYMin(double v)           { _dcaXYMin          = v; } 
+  virtual     void    SetDcaXYMax(double v)           { _dcaXYMax          = v; } 
+  virtual     void    SetDedxMin(double v)            { _dedxMin           = v; } 
+  virtual     void    SetDedxMax(double v)            { _dedxMax           = v; } 
+  virtual     void    SetNClusterMin(int v)           { _nClusterMin       = v; } 
+  virtual     void    SetTrackFilterBit(int v)        { _trackFilterBit    = v; }
+  virtual     void    SetWeigth_1(TH3F * v)           { _weight_1          = v; }
+  virtual     void    SetWeigth_2(TH3F * v)           { _weight_2          = v; }
+  
+  void SetNSigmaCut(Double_t nsigma){ fNSigmaCut = nsigma;}
+
+  void SetAnalysisType(const char* analysisType) {fAnalysisType = analysisType;}
+  void SetResonancesCut( Bool_t NoResonances ){ fExcludeResonancesInMC = NoResonances;}
+  void SetElectronCut( Bool_t NoElectron ){ fExcludeElectronsInMC = NoElectron;}
+  
+protected:      
+  
+  // Handlers and events
+  AliAODEvent*             fAODEvent;             //! AOD Event 
+  AliESDEvent*             fESDEvent;             //! ESD Event 
+  AliInputEventHandler*    fInputHandler;    //! Generic InputEventHandler 
+  
+  AliPIDResponse*          fPIDResponse;
+
+  // Histogram settings
+  //TList*              _inputHistoList;
+  TList*              _outputHistoList;
+  //int _outputSlot;
+  
+  TClonesArray          *fArrayMC;  
+  double   _twoPi;
+  long     _eventCount;
+  
+  //configuration variables and filters
+  int      _debugLevel;
+  int      _singlesOnly; 
+  int      _useWeights; 
+  int      _sameFilter;
+  int      _rejectPileup; 
+  int      _rejectPairConversion; 
+  double   _vertexZMin; 
+  double   _vertexZMax; 
+  double   _vertexXYMin; 
+  double   _vertexXYMax; 
+  int      _centralityMethod;
+  double   _centralityMin;
+  double   _centralityMax;
+  int      _requestedCharge_1;
+  int      _requestedCharge_2;
+  double   _dcaZMin; 
+  double   _dcaZMax; 
+  double   _dcaXYMin; 
+  double   _dcaXYMax;
+  double   _dedxMin;
+  double   _dedxMax;
+  int      _nClusterMin; 
+  int      _trackFilterBit;
+  Double_t fNSigmaCut;  
+
+  //double _min_eta_1;
+  //double _max_eta_1;
+  //double _min_eta_2;
+  //double _max_eta_2;
+  TString      fAnalysisType;
+
+  Bool_t fExcludeResonancesInMC;
+  Bool_t fExcludeElectronsInMC;
+  // event and track wise variables
+  
+  double _field;
+  int    _nTracks;
+  double _mult0;
+  double _mult1;
+  double _mult2;
+  double _mult3;
+  double _mult4;
+  double _mult4a;
+  double _mult5;
+  double _mult6;
+  
+  //particle 1
+  int     arraySize;
+  int    *_id_1;               //!
+  int    *_charge_1;           //! 
+  //int  *  _iPhi_1;            //!
+  //int  *  _iEta_1;            //!
+  int    *_iEtaPhi_1;            //!
+  int    *_iPt_1;             //!
+  float  *_pt_1;               //!
+  float  *_px_1;              //!
+  float  *_py_1;              //!
+  float  *_pz_1;              //!
+ //float * _phi_1;             //!
+  //float*  _eta_1;             //!
+  float  *_correction_1;           //!
+  float  *_dedx_1;           //!
+  
+  //particle 2
+  int    *_id_2;              //!
+  int    *_charge_2;            //!
+  //int    *_iPhi_2;            //!
+  //int    *_iEta_2;            //!
+  int    *_iEtaPhi_2;            //!
+  int    *_iPt_2;             //!
+  float  *_pt_2;              //!
+  float  *_px_2;              //!
+  float  *_py_2;              //!
+  float  *_pz_2;              //!
+  //float  *_phi_2;             //!
+  //float  *_eta_2;             //!
+  float  *_correction_2;           //!
+  float  *_dedx_2;           //!
+  
+  float * _correctionWeight_1;           //!
+  float * _correctionWeight_2;           //!
+  
+  //histograming
+  int _nBins_M0;       double _min_M0;       double _max_M0;       double _width_M0;
+  int _nBins_M1;       double _min_M1;       double _max_M1;       double _width_M1;
+  int _nBins_M2;       double _min_M2;       double _max_M2;       double _width_M2;
+  int _nBins_M3;       double _min_M3;       double _max_M3;       double _width_M3;
+  int _nBins_M4;       double _min_M4;       double _max_M4;       double _width_M4;
+  int _nBins_M5;       double _min_M5;       double _max_M5;       double _width_M5;
+  int _nBins_M6;       double _min_M6;       double _max_M6;       double _width_M6;
+  
+  int _nBins_vertexZ;  double _min_vertexZ;  double _max_vertexZ;  double _width_vertexZ;
+  
+  int _nBins_pt_1;     double _min_pt_1;     double _max_pt_1;     double _width_pt_1;
+  int _nBins_phi_1;    double _min_phi_1;    double _max_phi_1;    double _width_phi_1;
+  int _nBins_eta_1;    double _min_eta_1;    double _max_eta_1;    double _width_eta_1;
+  int _nBins_etaPhi_1; 
+  int _nBins_etaPhiPt_1;
+  int _nBins_zEtaPhiPt_1;
+  
+  int _nBins_pt_2;     double _min_pt_2;     double _max_pt_2;     double _width_pt_2;
+  int _nBins_phi_2;    double _min_phi_2;    double _max_phi_2;    double _width_phi_2;
+  int _nBins_eta_2;    double _min_eta_2;    double _max_eta_2;    double _width_eta_2;
+  int _nBins_etaPhi_2; 
+  int _nBins_etaPhiPt_2;
+  int _nBins_zEtaPhiPt_2;
+  
+  int _nBins_etaPhi_12;
+    
+  double __n1_1;
+  double __n1_2;
+  double __n2_12;   
+  double __s1pt_1;
+  double __s1pt_2;
+  double __s2ptpt_12;
+  double __s2NPt_12;
+  double __s2PtN_12;
+  
+  double __n1Nw_1;
+  double __n1Nw_2;
+  double __n2Nw_12;   
+  double __s1ptNw_1;
+  double __s1ptNw_2;
+  double __s2ptptNw_12;
+  double __s2NPtNw_12;
+  double __s2PtNNw_12;
+  
+  double * __n1_1_vsPt;   //!
+  double * __n1_1_vsEtaPhi;     //! 
+  double * __s1pt_1_vsEtaPhi;    //!
+  float  * __n1_1_vsZEtaPhiPt;    //!
+    
+  double * __n1_2_vsPt;   //!
+  double * __n1_2_vsEtaPhi;     //! 
+  double * __s1pt_2_vsEtaPhi;    //!
+  float  * __n1_2_vsZEtaPhiPt;    //!
+  
+  //double * __n2_12_vsPtPt;
+  //double * __n2_12_vsEtaPhi;
+  //double * __s2ptpt_12_vsEtaPhi;
+  //double * __s2PtN_12_vsEtaPhi;
+  //double * __s2NPt_12_vsEtaPhi;
+  
+  double * __n2_12_vsPtPt;   //!
+  float  * __n2_12_vsEtaPhi;   //!
+  float  * __s2ptpt_12_vsEtaPhi;   //!
+  float  * __s2PtN_12_vsEtaPhi;   //!
+  float  * __s2NPt_12_vsEtaPhi;   //!
+  
+  TH3F * _weight_1;
+  TH3F * _weight_2;
+  TH1D * _eventAccounting;
+  TH1D * _m0;
+  TH1D * _m1;
+  TH1D * _m2;
+  TH1D * _m3;
+  TH1D * _m4;
+  TH1D * _m5;
+  TH1D * _m6;
+  TH1D * _vertexZ;
+
+  TH1F * _Ncluster1;
+  TH1F * _Ncluster2;
+  TH1F * _etadis;
+  TH1F * _phidis;
+  TH1F * _dcaz;
+  TH1F * _dcaxy;  
+
+
+  // PARTICLE 1 (satisfies filter 1)
+  // Primary filled quantities
+  TH1F      *  _n1_1_vsPt;         
+  TH2F      *  _n1_1_vsEtaVsPhi;
+  TH2F      *  _s1pt_1_vsEtaVsPhi; 
+  TH3F      *  _n1_1_vsZVsEtaVsPhiVsPt;
+  TProfile *  _n1_1_vsM;  // w/ weight
+  TProfile *  _s1pt_1_vsM;
+  TProfile *  _n1Nw_1_vsM; // w/o weight
+  TProfile *  _s1ptNw_1_vsM;
+  TH2D      *  _dedxVsP_1;
+  TH2D      *  _corrDedxVsP_1;
+  TH2F      *  _betaVsP_1;
+  
+  // PARTICLE 2 (satisfies filter 2)
+  // Primary filled quantities
+  TH1F      *  _n1_2_vsPt;         
+  TH2F      *  _n1_2_vsEtaVsPhi;
+  TH2F      *  _s1pt_2_vsEtaVsPhi;
+  TH3F      *  _n1_2_vsZVsEtaVsPhiVsPt; 
+  TProfile *  _n1_2_vsM;
+  TProfile *  _s1pt_2_vsM;
+  TProfile *  _n1Nw_2_vsM; // w/o weight
+  TProfile *  _s1ptNw_2_vsM;
+  TH2D      *  _dedxVsP_2;
+  TH2D      *  _corrDedxVsP_2;
+  TH2F      *  _betaVsP_2;
+  
+  // Pairs 1 & 2  
+  TH1F      * _n2_12_vsEtaPhi;        
+  TH2F      * _n2_12_vsPtVsPt;
+  TH1F      * _s2PtPt_12_vsEtaPhi;    
+  TH1F      * _s2PtN_12_vsEtaPhi;       
+  TH1F      * _s2NPt_12_vsEtaPhi;     
+  
+  TProfile * _n2_12_vsM;        
+  TProfile * _s2PtPt_12_vsM;    
+  TProfile * _s2PtN_12_vsM;       
+  TProfile * _s2NPt_12_vsM; 
+  TProfile * _n2Nw_12_vsM;        
+  TProfile * _s2PtPtNw_12_vsM;    
+  TProfile * _s2PtNNw_12_vsM;       
+  TProfile * _s2NPtNw_12_vsM; 
+  
+  TH1F      * _invMass;
+  TH1F      * _invMassElec;
+  
+  TString n1Name;
+  TString n1NwName;
+  TString n2Name;
+  TString n2NwName;
+  TString n3Name;
+  TString n1n1Name;
+  TString n1n1n1Name;
+  TString n2n1Name;
+  TString r1Name;
+  TString r2Name;
+  TString r3Name;
+  TString r2r1Name;
+  TString c2Name;
+  TString c3Name;
+  TString d3Name;
+  TString p3Name;
+  TString cName;
+  
+  TString intR2Name;
+  TString binCorrName;
+  TString intBinCorrName;
+  
+  TString countsName;
+  TString part_1_Name;
+  TString part_2_Name;
+  TString part_3_Name;
+  TString pair_12_Name;
+  TString pair_13_Name;
+  TString pair_23_Name;
+  TString tripletName;
+  
+  TString avg;
+  TString avgName;
+  TString sumName;
+  TString s1ptName;
+  TString s1ptNwName;
+  TString s1DptName;
+  
+  TString s2PtPtName;
+  TString s2NPtName;
+  TString s2PtNName;
+  TString s2DptDptName;
+  TString s2PtPtNwName;
+  TString s2NPtNwName;
+  TString s2PtNNwName;
+  
+  TString ptName;
+  TString ptptName;
+  TString pt1pt1Name;
+  TString DptName;
+  TString DptDptName;
+  TString RDptDptName;
+  TString nPtName;
+  TString ptNName;
+  TString seanName;
+  
+  TString _title_counts;
+  
+  TString _title_m0;
+  TString _title_m1;
+  TString _title_m2;
+  TString _title_m3;
+  TString _title_m4;
+  TString _title_m5;
+  TString _title_m6;
+  
+  TString _title_eta_1;
+  TString _title_phi_1;
+  TString _title_pt_1;
+  TString _title_etaPhi_1;
+  TString _title_n_1;
+  TString _title_SumPt_1;
+  TString _title_AvgPt_1;
+  TString _title_AvgN_1;
+  TString _title_AvgSumPt_1;
+  
+  TString _title_eta_2;
+  TString _title_phi_2;
+  TString _title_pt_2;
+  TString _title_etaPhi_2;
+  TString _title_n_2;
+  TString _title_SumPt_2;
+  TString _title_AvgPt_2;
+  TString _title_AvgN_2;
+  TString _title_AvgSumPt_2;
+  
+  TString _title_etaPhi_12;
+  
+  TString _title_AvgN2_12;
+  TString _title_AvgSumPtPt_12;
+  TString _title_AvgSumPtN_12;
+  TString _title_AvgNSumPt_12;
+  
+  TString vsZ;
+  TString vsM;
+  TString vsPt;
+  TString vsPhi; 
+  TString vsEta; 
+  TString vsEtaPhi; 
+  TString vsPtVsPt;
+
+  
+  ClassDef(AliDptDptInMC,1)
+}; 
+
+
+#endif
+
+
index 6e22d6c8f204425a31646497cf6c02c019f899c8..3b991f6cef2b1cb4e23262a74838667d24cab3db 100644 (file)
@@ -44,6 +44,7 @@ using namespace std;
 
 #include "AliTrackDiHadronPID.h"
 #include "AliHistToolsDiHadronPID.h"
+#include "AliFunctionsDiHadronPID.h"
 
 ClassImp(AliAODTrackCutsDiHadronPID);
 
@@ -1743,7 +1744,7 @@ void AliAODTrackCutsDiHadronPID::SetXaxisAcceptedFilterBits() {
 
        while (((Int_t)fFilterMask) >= (1<<(largestBit)) ) {
                if ((((Int_t)fFilterMask)&(1<<largestBit))==(1<<largestBit)) {
-                       fullArraySizeTmp += TMath::Power(2, baseArraySizeTmp);
+                       fullArraySizeTmp += AliFunctionsDiHadronPID::Power(2, baseArraySizeTmp);
                        baseArraySizeTmp++;
                }
                largestBit++;
@@ -1772,7 +1773,7 @@ void AliAODTrackCutsDiHadronPID::SetXaxisAcceptedFilterBits() {
        Int_t iFullArray = 1;
 
        for (Int_t ii = 1; ii < baseArraySize; ++ii) {
-               Int_t range = (iFullArray + TMath::Power(2,ii));
+               Int_t range = (iFullArray + AliFunctionsDiHadronPID::Power(2,ii));
                for (Int_t jj = iFullArray; jj < range; ++jj) {
                        
                        fullArray[jj] = baseArray[ii];
@@ -1783,7 +1784,7 @@ void AliAODTrackCutsDiHadronPID::SetXaxisAcceptedFilterBits() {
                        }
 
                }
-               iFullArray += TMath::Power(2,ii);
+               iFullArray += AliFunctionsDiHadronPID::Power(2,ii);
 
        }
 
index 1423c3de3368d11b4856391f8d17875a90b8f763..61b9e5e64dcbad21ed7414bbd5400ff7afcf4eac 100644 (file)
@@ -577,5 +577,3 @@ void AliAnalysisTaskCompareAODTrackCuts::Terminate(Option_t*) {
        }
 
 }
-
-// -----------------------------------------------------------------------
\ No newline at end of file
index c7047a12e7bd7573ba900559983bd5c7d3777722..16311ebebd975f49a22faef227a2a95257febc07 100644 (file)
@@ -84,4 +84,4 @@ private:
 
 };
 
-#endif
\ No newline at end of file
+#endif
index 9de1c402ff677fe92403bfc8331dfa4675096861..284631f190d9df4837d482be99798ca3ddcb202b 100644 (file)
@@ -44,21 +44,26 @@ AliFunctionsDiHadronPID::~AliFunctionsDiHadronPID()
        // Destructor.
 
 } 
-/*
-// -----------------------------------------------------------------------
-Double_t AliFunctionsDiHadronPID::Gaussian1D(Double_t *x, Double_t *par) {
 
-       //  - Gaussian, I is the integral -
-       // f(x) = I/(Sqrt(2*pi)*sigma) * exp{-(x-mu)^2/2sigma^2}
-       // par = {I,mu,sigma}
+// -----------------------------------------------------------------------
+Int_t AliFunctionsDiHadronPID::Power(Int_t base, Int_t power) {
 
-       Double_t norm = par[0]/(TMath::Sqrt(2.*TMath::Pi())*par[2]);
-       Double_t gaussian = TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/(2.*par[2]*par[2]));
+       // Power function for integers (not available in TMath).
 
-       return (norm*gaussian);
+       if (power > 0) {
+               Int_t result = 1;
+               for (Int_t ii = 0; ii < power; ++ii) {result *= base;}
+               return result;
+       } else {
+               if (power == 0) {return 1;}
+               else {
+                       cout << Form("%s::%s -> WARNING: Method doesn't work for negative powers.",__FILE__,__func__) << endl;
+                       return -999;
+               }
+       }
 
 }
-*/
+
 // -----------------------------------------------------------------------
 Double_t AliFunctionsDiHadronPID::Gaussian1D(Double_t xx, Double_t integral, Double_t mu, Double_t sigma, Double_t binwidth) {
 
@@ -69,34 +74,7 @@ Double_t AliFunctionsDiHadronPID::Gaussian1D(Double_t xx, Double_t integral, Dou
        return (norm*gaussian);
 
 }
-/*
-// -----------------------------------------------------------------------
-Double_t AliFunctionsDiHadronPID::Gaussian1DTail(Double_t *x,const  Double_t *par) {
-
-       // Gaussian with exponential tail on the right, I is the integral.
-       // For function definition see: FitFunctions.nb
 
-       Double_t integral = par[0];
-       Double_t mu = par[1];           // Top of the gaussian.
-       Double_t kappa = par[1] + par[2];       // Point at which the gaussian becomes an exponential (w.r.t. to mu).
-       Double_t sigma_x = par[3];
-
-       if (mu >= kappa) return 0.;     // Function becomes ill-defined.
-
-       Double_t beta = sigma_x*sigma_x/(kappa-mu);
-       Double_t BB = TMath::Exp( (kappa*kappa-mu*mu)/(2.*sigma_x*sigma_x) );
-       Double_t norm1 = beta*TMath::Exp( -(mu-kappa)*(mu-kappa)/(2.*sigma_x*sigma_x) );
-       Double_t norm2 = TMath::Sqrt(TMath::Pi()/2.)*sigma_x*TMath::Erfc( (mu-kappa)/(TMath::Sqrt2()*sigma_x) );
-       Double_t norm = norm1 + norm2;
-
-       Double_t funcleft = (integral/norm)*TMath::Exp(-(x[0]-mu)*(x[0]-mu)/(2.*sigma_x*sigma_x));
-       Double_t funcright = (integral/norm)*BB*TMath::Exp(-x[0]/beta);
-
-       if (x[0] <= kappa) return funcleft;
-       else return funcright;
-
-}
-*/
 // -----------------------------------------------------------------------
 Double_t AliFunctionsDiHadronPID::Gaussian1DTail(Double_t xx, Double_t integral, Double_t mu, Double_t sigma, Double_t tail, Double_t binwidth) {
 
@@ -171,38 +149,8 @@ Double_t AliFunctionsDiHadronPID::Gaussian2DTailXY(Double_t xx, Double_t yy, Dou
 
        return integral * GaussianTailX * GaussianTailY;
 
-}
-/*
-// -----------------------------------------------------------------------
-Double_t AliFunctionsDiHadronPID::Exponent(Double_t *x, Double_t *par) {
-
-       // f(x) = A * Exp(bx)
-       // par = {A,b}
-
-       return par[0]*TMath::Exp(par[1]*x[0]); 
-
 }
 
-// -----------------------------------------------------------------------
-//  COMBINED FUNCTIONS
-// -----------------------------------------------------------------------
-Double_t AliFunctionsDiHadronPID::SimpleTOFfit(Double_t *x, Double_t *par) {
-
-       // Signal fitted with a Gaussian, mismatches by an exponent.
-       return (Gaussian1D(x,&par[0]) + Exponent(x,&par[3]));
-
-}
-
-// -----------------------------------------------------------------------
-Double_t AliFunctionsDiHadronPID::SimpleTOFfitWithTail(Double_t *x, Double_t *par) {
-
-       // Signal fitted with a Gaussian with a tail, mismatches by an exponent.
-       return (Gaussian1D(x,&par[0]) + Exponent(x,&par[4]));
-
-}
-*/
-// -----------------------------------------------------------------------
-//  PENALTY FUNCTIONS
 // -----------------------------------------------------------------------
 Double_t AliFunctionsDiHadronPID::PolyPenalty(Double_t xx, Double_t center, Double_t flatwidth, const Int_t polyorder) {
 
@@ -232,8 +180,6 @@ TCanvas* AliFunctionsDiHadronPID::TestPolyPenalty(Double_t range, Double_t cente
 
 }
 
-// -----------------------------------------------------------------------
-//  PID Expected signal functions.
 // -----------------------------------------------------------------------
 Double_t AliFunctionsDiHadronPID::TOFExpTime(Double_t pT, Double_t eta, Double_t mass) {
 
index b68b70864bbcdd4b75692b8e7c4c6ae0a7edd278..989a605c9b0f664db70d24f4f85e38c3a4c5b34f 100644 (file)
@@ -18,6 +18,9 @@ protected:
        ~AliFunctionsDiHadronPID();
 
 public:
+       // Math.
+       static Int_t Power(Int_t base, Int_t power);
+
        // Natural constants.
        static Double_t Charge() {return 1.60217646e-19;}       // (C)
        static Double_t C() {return 2.99792458e+8;}                     // (m/s)
@@ -63,14 +66,6 @@ public:
                Double_t mux, Double_t muy, Double_t sigmax, Double_t sigmay, 
                Double_t tailx, Double_t taily, Double_t binwidthx = 1., Double_t binwidthy = 1.);
 
-       // FUNCTIONS THAT ARE NOT BEING USED ANYMORE.
-/*
-       static Double_t Gaussian1D(Double_t *x, Double_t *par);
-       static Double_t Gaussian1DTail(Double_t *x, Double_t *par);     
-       static Double_t Exponent(Double_t *x, Double_t *par);
-       static Double_t SimpleTOFfit(Double_t *x, Double_t *par);
-       static Double_t SimpleTOFfitWithTail(Double_t *x, Double_t *par);
-*/
        // Penalty Functions.
        static Double_t PolyPenalty(Double_t xx, Double_t center, Double_t flatwidth, Int_t polyorder);
        static TCanvas* TestPolyPenalty(Double_t range = 3., Double_t center = 1., Double_t flatwidth = 1., Int_t polyorder = 3);
index 1d96e9b9a3f1e01a5b7cd333354cb88616e377d5..242d54ea706775aed4b00a4aeb28479a117067ee 100644 (file)
@@ -319,22 +319,23 @@ Bool_t AliTrackDiHadronPID::CopyITSInfo() {
 Bool_t AliTrackDiHadronPID::CopyTPCInfo() {
 
        //
-       // Copies TPC info. (needs global track and pid response)
+       // Copies TPC info. (needs global track and pid response).
+       // See https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PIDInAnalysis#Signal_Deltas
+       // for more info!
        //
 
        if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}  
 
-    // Get TPC signal.
-    fTPCsignal = fAODGlobalTrack->GetTPCsignal();
+       // Get TPC signal and momentum.
+       fTPCsignal = fAODGlobalTrack->GetTPCsignal();
+       fTPCmomentum = fAODGlobalTrack->GetTPCmomentum();
 
-    // Compute expected TPC signal under pi/K/p mass assumption.
-    AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
-    fTPCmomentum = fAODGlobalTrack->GetTPCmomentum();
-
-       fTPCsignalMinusExpected[0] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kPion);
-       fTPCsignalMinusExpected[1] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kKaon);
-       fTPCsignalMinusExpected[2] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kProton);
+       // Obtaining (signal - expected).
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTPC, fAODGlobalTrack, AliPID::kPion, fTPCsignalMinusExpected[0], kFALSE);
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTPC, fAODGlobalTrack, AliPID::kKaon, fTPCsignalMinusExpected[1], kFALSE);
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTPC, fAODGlobalTrack, AliPID::kProton, fTPCsignalMinusExpected[2], kFALSE);
 
+       // Obtaining nSigma.
        fTPCNsigma[0] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kPion);
        fTPCNsigma[1] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kKaon);
        fTPCNsigma[2] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kProton);
@@ -349,26 +350,34 @@ Bool_t AliTrackDiHadronPID::CopyTOFInfo() {
 
        //
        // Copies TOF info. (needs global track)
+       // See https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PIDInAnalysis#Signal_Deltas
+       // for more info!       
        //
 
        if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
 
-    // Get TOF signal.
-    fTOFsignal = fAODGlobalTrack->GetTOFsignal();
+    // Get TOF signal minus the start time.
+       fTOFsignal = fAODGlobalTrack->GetTOFsignal();
 
-    // Compute expected TOF signal under pi/K/p mass assumption.
-    Double_t times[AliPID::kSPECIES];
-    fAODGlobalTrack->GetIntegratedTimes(times);
-    fTOFsignalMinusExpected[0] = fTOFsignal - times[AliPID::kPion];
-       fTOFsignalMinusExpected[1] = fTOFsignal - times[AliPID::kKaon];
-       fTOFsignalMinusExpected[2] = fTOFsignal - times[AliPID::kProton];
+       // Get the expected times.
+       Double_t expectedTimes[AliPID::kSPECIES];
+       fAODGlobalTrack->GetIntegratedTimes(expectedTimes);
+/*
+       // Get the exptected TOF resolution.
+       AliTOFHeader* tofH = (AliTOFHeader*)ev->GetTOFHeader();
+       Double_t TOFpidRes[AliPID::kSPECIES];
+       tr->GetDetPid()->GetTOFpidResolution(TOFpidRes);
+*/
+       // Obtaining (signal - expected).
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTOF, fAODGlobalTrack, AliPID::kPion, fTOFsignalMinusExpected[0], kFALSE);
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTOF, fAODGlobalTrack, AliPID::kKaon, fTOFsignalMinusExpected[1], kFALSE);
+       fPIDResponse->GetSignalDelta(AliPIDResponse::kTOF, fAODGlobalTrack, AliPID::kProton, fTOFsignalMinusExpected[2], kFALSE);
 
+       // Obtaining nSigma.
        fTOFNsigma[0] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kPion);
        fTOFNsigma[1] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kKaon);
        fTOFNsigma[2] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kProton);      
 
-       fTOFInfoAvailable = kTRUE;
-
        // Q: what do the different TOF labels mean?
        // It seems that in AOD090 the TOF labels aren't copied properly.
        //Int_t TOFlabeltmp[3] = {0};
@@ -385,6 +394,7 @@ Bool_t AliTrackDiHadronPID::CopyTOFInfo() {
        else if (fLabel == fTOFLabel[0]) {fTOFMatchingStatus = 0;}      // TPC Track was correctly matched to a TOF hit.
        else {fTOFMatchingStatus = 1;}                                                          // TPC Track was mismatched.
 
+       fTOFInfoAvailable = kTRUE;
        return fTOFInfoAvailable;
 
 }
index b0e880bfe0e9ab94ac501ff97cc887048e659f72..ac8df437d74654132a3b85aa9a483eacb9b5e2ec 100644 (file)
@@ -69,6 +69,7 @@ public:
        Double_t GetZAtDCA() const {return fDCAz;}
        Double_t GetXYAtDCA() const {return fDCAxy;}
 
+       // TOF related Getters.
        Double_t GetTOFsignal() const {return fTOFsignal;}
        Double_t GetTOFsignalMinusExpected(Int_t species) const {
                if (UnknownSpecies(species)) {return -10e10;}
@@ -87,10 +88,6 @@ public:
                if (UnknownSpecies(species)) {return -10e10;}
                return fTOFNsigma[species];
        }
-       Double_t GetNumberOfSigmasTPC(Int_t species) const {
-               if (UnknownSpecies(species)) {return -10e10;}
-               return fTPCNsigma[species];
-       }
        Int_t GetTOFMatchingStatus() const {return fTOFMatchingStatus;}
        Bool_t IsTOFMismatch() const {
                if (fTOFMatchingStatus==1) {return kTRUE;}
@@ -100,6 +97,10 @@ public:
        Double_t GetTPCsignal() const {return fTPCsignal;}
        Double_t GetTPCsignalMinusExpected(Int_t species) const {return fTPCsignalMinusExpected[species];}
        Double_t GetTPCmomentum() const {return fTPCmomentum;}
+       Double_t GetNumberOfSigmasTPC(Int_t species) const {
+               if (UnknownSpecies(species)) {return -10e10;}
+               return fTPCNsigma[species];
+       }
 
        Char_t GetITSClusterMap() const {return fITSClusterMap;}
        Bool_t HasPointOnITSLayer(Int_t layer) const {
@@ -180,14 +181,14 @@ private:
        Double_t                        fDCAxy;                         // xy at DCA.
 
 // PID Info.
-       Double_t                        fTOFsignal;
+       Double_t                        fTOFsignal;                     
        Double_t                        fTOFsignalMinusExpected[3];
        Double_t                        fTOFNsigma[3];
        Int_t                           fTOFMatchingStatus;             // 0 -> match, 1 -> mismatch, 2 -> no TOF hit.
-       Double_t                        fTPCsignal;
+       Double_t                        fTPCsignal;                     
        Double_t                        fTPCsignalMinusExpected[3];
        Double_t                        fTPCNsigma[3];
-       Double_t                        fTPCmomentum;
+       Double_t                        fTPCmomentum;           
        UChar_t                         fITSClusterMap;
        Bool_t                          fITSHits[6];
 
diff --git a/PWGCF/Correlations/macros/dptdptcorrelations/AddTaskCorrMC.C b/PWGCF/Correlations/macros/dptdptcorrelations/AddTaskCorrMC.C
new file mode 100644 (file)
index 0000000..88bd3a8
--- /dev/null
@@ -0,0 +1,279 @@
+//
+// Macro designed for use with the AliDptDptInMC task.
+//
+// Author: Prabhat Pujahari & Claude Pruneau, Wayne State
+// 
+//           system:  0: PbPb                 1: pPb
+//      singlesOnly:  0: full correlations    1: singles only
+//       useWeights:  0: no                   1: yes
+// centralityMethod:  3: track count  4: V0 centrality  7: V0A centrality for pPb
+//        chargeSet:  0: ++    1: +-    2: -+    3: --
+/////////////////////////////////////////////////////////////////////////////////
+
+AliDptDptInMC *AddTaskCorrMC
+(int    singlesOnly            = 0,
+ int    useWeights             = 1,
+ int    centralityMethod       = 4,
+ int    chargeSet              = 1,
+ int    trackFilterBit         = 128,
+ double etaMin                 = -0.8,
+ double etaMax                 =  0.8,
+ double dcaZMin                = -3.0,
+ double dcaZMax                =  3.0,
+ double dcaXYMin               = -2.4,
+ double dcaXYMax               =  2.4,
+ int nCentrality               =  3, 
+ TString anadata               = "MCAOD",
+ Bool_t NoResonances           =  kTRUE,
+ Bool_t NoElectron             =  kTRUE,
+ const char* taskname          = "NoWeakDecay",
+ char *inputHistogramFileName  = "alien:///alice/cern.ch/user/p/prabhat/MCCalib/MCTruthCaalib.root")
+{
+  // Set Default Configuration of this analysis
+  // ==========================================
+  int    debugLevel             = 0;
+  int    rejectPileup           = 1;
+  int    rejectPairConversion   = 1;
+  int    sameFilter             = 1;
+
+  
+  //int    nCentrality;
+  double minCentrality[10];
+  double maxCentrality[10];
+  
+      
+      if (centralityMethod == 4)
+       {
+         
+         minCentrality[0] = 10.0; maxCentrality[0] = 20.0; 
+         minCentrality[1] = 30.0; maxCentrality[1] = 40.0;
+         minCentrality[2] = 60.0; maxCentrality[2] = 70.0;
+         
+       }
+      else
+       {
+         cout << "-F- AddTaskDptDptCorrelations() system:" << system << ". centralityMethod:" << centralityMethod << " Option NOT AVAILABLE. ABORT."
+           return 0;
+       }
+    
+  
+  double zMin                   = -10.;
+  double zMax                   =  10.;
+  double ptMin                  =  0.2;
+  double ptMax                  =  2.0;
+  double dedxMin                =  0.0;
+  double dedxMax                =  20000.0;
+  int    requestedCharge1       =  1; //default
+  int    requestedCharge2       = -1; //default
+  
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  // ==============================================================================
+  AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
+  
+  if (!analysisManager) 
+    {
+    ::Error("AddTaskDptDptCorrelations", "No analysis manager to connect to.");
+    return NULL;
+    }  
+  
+  TString part1Name;
+  TString part2Name;
+  TString eventName;
+  TString prefixName        = "Corr_";
+  TString pileupRejecSuffix = "_PileupRejec";
+  TString pairRejecSuffix   = "_PairRejec";
+  TString calibSuffix       = "_calib";
+  TString singlesOnlySuffix = "_SO";
+  TString suffix;
+  
+  TString inputPath         = ".";
+  TString outputPath        = ".";
+  TString baseName;
+  TString listName;
+  TString taskName;
+  //TString inputHistogramFileName;
+  TString outputHistogramFileName;
+  
+  // Create the task and add subtask.
+  // ===========================================================================
+  int iTask = 0; // task counter
+  AliAnalysisDataContainer *taskInputContainer;
+  AliAnalysisDataContainer *taskOutputContainer;
+  AliDptDptInMC* task;
+  
+  for (int iCentrality=0; iCentrality < nCentrality; ++iCentrality)
+    {
+      switch (chargeSet)
+        {
+          case 0: part1Name = "P_"; part2Name = "P_"; requestedCharge1 =  1; requestedCharge2 =  1; sameFilter = 1; break;
+          case 1: part1Name = "P_"; part2Name = "M_"; requestedCharge1 =  1; requestedCharge2 = -1; sameFilter = 0;   break;
+          case 2: part1Name = "M_"; part2Name = "P_"; requestedCharge1 = -1; requestedCharge2 =  1; sameFilter = 0;   break;
+          case 3: part1Name = "M_"; part2Name = "M_"; requestedCharge1 = -1; requestedCharge2 = -1; sameFilter = 1;   break;
+        }
+      //part1Name += int(1000*etaMin);                                                                                        
+      part1Name += "eta";
+      part1Name += int(1000*etaMax);
+      part1Name += "_";
+      part1Name += int(1000*ptMin);
+      part1Name += "pt";
+      part1Name += int(1000*ptMax);
+      part1Name += "_";
+      part1Name += int(1000*dcaZMin);
+      part1Name += "DCA";
+      part1Name += int(1000*dcaZMax);
+      part1Name += "_";
+
+
+      //part2Name += int(1000*etaMin);                                                                                        
+      part2Name += "eta";
+      part2Name += int(1000*etaMax);
+      part2Name += "_";
+      part2Name += int(1000*ptMin);
+      part2Name += "pt";
+      part2Name += int(1000*ptMax);
+      part2Name += "_";
+      part2Name += int(1000*dcaZMin);
+      part2Name += "DCA";
+      part2Name += int(1000*dcaZMax);
+      part2Name += "_";
+
+      eventName =  "";
+      eventName += int(10.*minCentrality[iCentrality] );
+      eventName += "Vo";
+      eventName += int(10.*maxCentrality[iCentrality] );
+      
+
+      baseName     =   prefixName;
+      baseName     +=  part1Name;
+      baseName     +=  part2Name;
+      baseName     +=  eventName;
+      listName     =   baseName;
+      taskName     =   baseName;
+      
+      
+      outputHistogramFileName = baseName;
+      if (singlesOnly) outputHistogramFileName += singlesOnlySuffix;
+      outputHistogramFileName += ".root";
+      
+    
+      TFile  * inputFile  = 0;
+      TList  * histoList  = 0;
+      TH3F   * weight_1   = 0;
+      TH3F   * weight_2   = 0;
+      if (useWeights)
+        {
+        TGrid::Connect("alien:");
+        inputFile = TFile::Open(inputHistogramFileName,"OLD");
+        if (!inputFile)
+          {
+          cout << "Requested file:" << inputHistogramFileName << " was not opened. ABORT." << endl;
+          return;
+          }
+        TString nameHistoBase = "correction_";
+        TString nameHisto;
+        nameHistoBase += eventName;
+        if (requestedCharge1 == 1)
+          {
+          nameHisto = nameHistoBase + "_p";
+          cout << "Input Histogram named: " << nameHisto << endl;
+          weight_1 = (TH3F *) inputFile->Get(nameHisto);
+          }
+        else
+          {
+          nameHisto = nameHistoBase + "_m";
+          cout << "Input Histogram named: " << nameHisto << endl;
+          weight_1 = (TH3F *) inputFile->Get(nameHisto);
+          }
+        if (!weight_1) 
+          {
+          cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
+          return 0;
+          }
+        
+        if (!sameFilter)
+          {
+          weight_2 = 0;
+          if (requestedCharge2 == 1)
+            {
+            nameHisto = nameHistoBase + "_p";
+            cout << "Input Histogram named: " << nameHisto << endl;
+            weight_2 = (TH3F *) inputFile->Get(nameHisto);
+            }
+          else
+            {
+            nameHisto = nameHistoBase + "_m";
+            cout << "Input Histogram named: " << nameHisto << endl;
+            weight_2 = (TH3F *) inputFile->Get(nameHisto);
+            }
+          if (!weight_2) 
+            {
+            cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
+            return 0;
+            }
+          }  
+        }
+
+      task = new  AliDptDptInMC(taskName);
+      //configure my task
+      task->SetDebugLevel(          debugLevel      ); 
+      task->SetSameFilter(          sameFilter      );
+      task->SetSinglesOnly(         singlesOnly     ); 
+      task->SetUseWeights(          useWeights      ); 
+      task->SetRejectPileup(        rejectPileup    ); 
+      task->SetRejectPairConversion(rejectPairConversion); 
+      task->SetVertexZMin(          zMin            ); 
+      task->SetVertexZMax(          zMax            ); 
+      task->SetVertexXYMin(         -1.            ); 
+      task->SetVertexXYMax(          1.            ); 
+      task->SetCentralityMethod(    centralityMethod);
+      task->SetCentrality(          minCentrality[iCentrality], maxCentrality[iCentrality]);
+      task->SetPtMin1(              ptMin           ); 
+      task->SetPtMax1(              ptMax           ); 
+      task->SetEtaMin1(             etaMin          ); 
+      task->SetEtaMax1(             etaMax          ); 
+      task->SetPtMin2(              ptMin           ); 
+      task->SetPtMax2(              ptMax           ); 
+      task->SetEtaMin2(             etaMin          ); 
+      task->SetEtaMax2(             etaMax          ); 
+      task->SetDcaZMin(             dcaZMin         ); 
+      task->SetDcaZMax(             dcaZMax         ); 
+      task->SetDcaXYMin(            dcaXYMin        ); 
+      task->SetDcaXYMax(            dcaXYMax        ); 
+      task->SetDedxMin(             dedxMin         ); 
+      task->SetDedxMax(             dedxMax         ); 
+      //task->SetNClusterMin(         nClusterMin     ); 
+      task->SetTrackFilterBit(      trackFilterBit  );
+      task->SetRequestedCharge_1(   requestedCharge1); 
+      task->SetRequestedCharge_2(   requestedCharge2); 
+      task->SetWeigth_1(            weight_1        );
+      task->SetWeigth_2(            weight_2        );
+      task->SetAnalysisType(anadata);
+      
+      task->SelectCollisionCandidates(AliVEvent::kMB);
+
+      task->SetResonancesCut(NoResonances);
+      task->SetElectronCut(NoElectron);
+            
+      cout << "Creating task output container" << endl;
+      
+      taskOutputContainer = analysisManager->CreateContainer(listName, 
+                                                             TList::Class(),    
+                                                             AliAnalysisManager::kOutputContainer, 
+                                                             Form("%s:%s", AliAnalysisManager::GetCommonFileName(),taskname));
+      cout << "Add task to analysis manager and connect it to input and output containers" << endl;
+           
+
+      analysisManager->AddTask(task);
+      analysisManager->ConnectInput( task,  0, analysisManager->GetCommonInputContainer());
+      analysisManager->ConnectOutput(task,  0, taskOutputContainer );
+      cout << "Task added ...." << endl;
+      
+      iTask++;
+    
+    }
+  
+  return task;
+}
diff --git a/PWGCF/Correlations/macros/dptdptcorrelations/AddTaskWeightMC.C b/PWGCF/Correlations/macros/dptdptcorrelations/AddTaskWeightMC.C
new file mode 100644 (file)
index 0000000..4b22e5d
--- /dev/null
@@ -0,0 +1,278 @@
+//
+// Macro designed for use with the AliDptDptInMC task.
+//
+// Author: Prabhat Pujahari & Claude Pruneau, Wayne State
+// 
+//           system:  0: PbPb                 1: pPb
+//      singlesOnly:  0: full correlations    1: singles only
+//       useWeights:  0: no                   1: yes
+// centralityMethod:  3: track count  4: V0 centrality  7: V0A centrality for pPb
+//        chargeSet:  0: ++    1: +-    2: -+    3: --
+/////////////////////////////////////////////////////////////////////////////////
+
+AliDptDptInMC *AddTaskWeightMC
+(int    singlesOnly            = 1,
+ int    useWeights             = 0,
+ int    centralityMethod       = 4,
+ int    chargeSet              = 1,
+ int    trackFilterBit         = 128,
+ double etaMin                 = -0.8,
+ double etaMax                 =  0.8,
+ double dcaZMin                = -3.0,
+ double dcaZMax                =  3.0,
+ double dcaXYMin               = -2.4,
+ double dcaXYMax               =  2.4,
+ int nCentrality               =  3, 
+ TString anadata               = "MCAOD",
+ Bool_t NoResonances           = kTRUE,
+ Bool_t NoElectron             = kTRUE,
+ const char* taskname          = "NoWeakDecay")
+  
+{
+  
+  // Set Default Configuration of this analysis
+  // ==========================================
+  int    debugLevel             = 0;
+  int    rejectPileup           = 1;
+  int    rejectPairConversion   = 1;
+  int    sameFilter             = 1;
+
+  
+  //int    nCentrality;
+  double minCentrality[10];
+  double maxCentrality[10];
+  
+      
+      if (centralityMethod == 4)
+       {
+         
+         minCentrality[0] = 10.0; maxCentrality[0] = 20.0; 
+         minCentrality[1] = 30.0; maxCentrality[1] = 40.;
+         minCentrality[2] = 60.; maxCentrality[2] = 70.;
+         
+       }
+      else
+       {
+         cout << "-F- AddTaskDptDptCorrelations() system:" << system << ". centralityMethod:" << centralityMethod << " Option NOT AVAILABLE. ABORT."
+           return 0;
+       }
+    
+  
+  double zMin                   = -10.;
+  double zMax                   =  10.;
+  double ptMin                  =  0.2;
+  double ptMax                  =  2.0;
+  double dedxMin                =  0.0;
+  double dedxMax                =  20000.0;
+  int    requestedCharge1       =  1; //default
+  int    requestedCharge2       = -1; //default
+  
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  // ==============================================================================
+  AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
+  
+  if (!analysisManager) 
+    {
+    ::Error("AddTaskDptDptCorrelations", "No analysis manager to connect to.");
+    return NULL;
+    }  
+  
+  TString part1Name;
+  TString part2Name;
+  TString eventName;
+  TString prefixName        = "Corr_";
+  TString pileupRejecSuffix = "_PileupRejec";
+  TString pairRejecSuffix   = "_PairRejec";
+  TString calibSuffix       = "_calib";
+  TString singlesOnlySuffix = "_SO";
+  TString suffix;
+  
+  TString inputPath         = ".";
+  TString outputPath        = ".";
+  TString baseName;
+  TString listName;
+  TString taskName;
+  TString inputHistogramFileName;
+  TString outputHistogramFileName;
+  
+  // Create the task and add subtask.
+  // ===========================================================================
+  int iTask = 0; // task counter
+  AliAnalysisDataContainer *taskInputContainer;
+  AliAnalysisDataContainer *taskOutputContainer;
+  AliDptDptInMC* task;
+  
+  for (int iCentrality=0; iCentrality < nCentrality; ++iCentrality)
+    {
+      switch (chargeSet)
+        {
+          case 0: part1Name = "P_"; part2Name = "P_"; requestedCharge1 =  1; requestedCharge2 =  1; sameFilter = 1; break;
+          case 1: part1Name = "P_"; part2Name = "M_"; requestedCharge1 =  1; requestedCharge2 = -1; sameFilter = 0;   break;
+          case 2: part1Name = "M_"; part2Name = "P_"; requestedCharge1 = -1; requestedCharge2 =  1; sameFilter = 0;   break;
+          case 3: part1Name = "M_"; part2Name = "M_"; requestedCharge1 = -1; requestedCharge2 = -1; sameFilter = 1;   break;
+        }
+      //part1Name += int(1000*etaMin);                                                                                        
+      part1Name += "eta";
+      part1Name += int(1000*etaMax);
+      part1Name += "_";
+      part1Name += int(1000*ptMin);
+      part1Name += "pt";
+      part1Name += int(1000*ptMax);
+      part1Name += "_";
+      part1Name += int(1000*dcaZMin);
+      part1Name += "DCA";
+      part1Name += int(1000*dcaZMax);
+      part1Name += "_";
+
+
+      //part2Name += int(1000*etaMin);                                                                                        
+      part2Name += "eta";
+      part2Name += int(1000*etaMax);
+      part2Name += "_";
+      part2Name += int(1000*ptMin);
+      part2Name += "pt";
+      part2Name += int(1000*ptMax);
+      part2Name += "_";
+      part2Name += int(1000*dcaZMin);
+      part2Name += "DCA";
+      part2Name += int(1000*dcaZMax);
+      part2Name += "_";
+
+      eventName =  "";
+      eventName += int(10.*minCentrality[iCentrality] );
+      eventName += "Vo";
+      eventName += int(10.*maxCentrality[iCentrality] );
+      
+
+      baseName     =   prefixName;
+      baseName     +=  part1Name;
+      baseName     +=  part2Name;
+      baseName     +=  eventName;
+      listName     =   baseName;
+      taskName     =   baseName;
+      
+      
+      outputHistogramFileName = baseName;
+      if (singlesOnly) outputHistogramFileName += singlesOnlySuffix;
+      outputHistogramFileName += ".root";
+      
+    
+      TFile  * inputFile  = 0;
+      TList  * histoList  = 0;
+      TH3F   * weight_1   = 0;
+      TH3F   * weight_2   = 0;
+      if (useWeights)
+        {
+        TGrid::Connect("alien:");
+        inputFile = TFile::Open(inputHistogramFileName,"OLD");
+        if (!inputFile)
+          {
+          cout << "Requested file:" << inputHistogramFileName << " was not opened. ABORT." << endl;
+          return;
+          }
+        TString nameHistoBase = "correction_";
+        TString nameHisto;
+        nameHistoBase += eventName;
+        if (requestedCharge1 == 1)
+          {
+          nameHisto = nameHistoBase + "_p";
+          cout << "Input Histogram named: " << nameHisto << endl;
+          weight_1 = (TH3F *) inputFile->Get(nameHisto);
+          }
+        else
+          {
+          nameHisto = nameHistoBase + "_m";
+          cout << "Input Histogram named: " << nameHisto << endl;
+          weight_1 = (TH3F *) inputFile->Get(nameHisto);
+          }
+        if (!weight_1) 
+          {
+          cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
+          return 0;
+          }
+        
+        if (!sameFilter)
+          {
+          weight_2 = 0;
+          if (requestedCharge2 == 1)
+            {
+            nameHisto = nameHistoBase + "_p";
+            cout << "Input Histogram named: " << nameHisto << endl;
+            weight_2 = (TH3F *) inputFile->Get(nameHisto);
+            }
+          else
+            {
+            nameHisto = nameHistoBase + "_m";
+            cout << "Input Histogram named: " << nameHisto << endl;
+            weight_2 = (TH3F *) inputFile->Get(nameHisto);
+            }
+          if (!weight_2) 
+            {
+            cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
+            return 0;
+            }
+          }  
+        }
+
+      task = new  AliDptDptInMC(taskName);
+      //configure my task
+      task->SetDebugLevel(          debugLevel      ); 
+      task->SetSameFilter(          sameFilter      );
+      task->SetSinglesOnly(         singlesOnly     ); 
+      task->SetUseWeights(          useWeights      ); 
+      task->SetRejectPileup(        rejectPileup    ); 
+      task->SetRejectPairConversion(rejectPairConversion); 
+      task->SetVertexZMin(          zMin            ); 
+      task->SetVertexZMax(          zMax            ); 
+      task->SetVertexXYMin(         -1.            ); 
+      task->SetVertexXYMax(          1.            ); 
+      task->SetCentralityMethod(    centralityMethod);
+      task->SetCentrality(          minCentrality[iCentrality], maxCentrality[iCentrality]);
+      task->SetPtMin1(              ptMin           ); 
+      task->SetPtMax1(              ptMax           ); 
+      task->SetEtaMin1(             etaMin          ); 
+      task->SetEtaMax1(             etaMax          ); 
+      task->SetPtMin2(              ptMin           ); 
+      task->SetPtMax2(              ptMax           ); 
+      task->SetEtaMin2(             etaMin          ); 
+      task->SetEtaMax2(             etaMax          ); 
+      task->SetDcaZMin(             dcaZMin         ); 
+      task->SetDcaZMax(             dcaZMax         ); 
+      task->SetDcaXYMin(            dcaXYMin        ); 
+      task->SetDcaXYMax(            dcaXYMax        ); 
+      task->SetDedxMin(             dedxMin         ); 
+      task->SetDedxMax(             dedxMax         ); 
+      //task->SetNClusterMin(         nClusterMin     ); 
+      task->SetTrackFilterBit(      trackFilterBit  );
+      task->SetRequestedCharge_1(   requestedCharge1); 
+      task->SetRequestedCharge_2(   requestedCharge2); 
+      task->SetWeigth_1(            weight_1        );
+      task->SetWeigth_2(            weight_2        );
+      task->SetAnalysisType(anadata);
+      
+      task->SelectCollisionCandidates(AliVEvent::kMB);
+
+      task->SetResonancesCut(NoResonances);
+      task->SetElectronCut(NoElectron);
+            
+      cout << "Creating task output container" << endl;
+      
+      taskOutputContainer = analysisManager->CreateContainer(listName, 
+                                                             TList::Class(),    
+                                                             AliAnalysisManager::kOutputContainer, 
+                                                             Form("%s:%s", AliAnalysisManager::GetCommonFileName(),taskname));
+      cout << "Add task to analysis manager and connect it to input and output containers" << endl;
+           
+
+      analysisManager->AddTask(task);
+      analysisManager->ConnectInput( task,  0, analysisManager->GetCommonInputContainer());
+      analysisManager->ConnectOutput(task,  0, taskOutputContainer );
+      cout << "Task added ...." << endl;
+      
+      iTask++;
+    
+    }
+  
+  return task;
+}
index dfa26be842f20b4f19987da9efa17e2023459dc0..cb077fcbd8be63c1ebbe3d18f6c8ee40c005db44 100755 (executable)
@@ -119,6 +119,7 @@ AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name)
   fHistdEdxVsPTPCafterPIDelectron(NULL), //+++++++\r
   fHistNSigmaTPCvsPtafterPIDelectron(NULL), //+++++++\r
   fCentralityArrayBinsForCorrections(kCENTRALITY),\r
+  fCentralityWeights(0x0),\r
   fPIDResponse(0x0),\r
   fPIDCombined(0x0),\r
   fParticleOfInterest(kPion),\r
@@ -909,6 +910,13 @@ Double_t AliAnalysisTaskBFPsi::IsEventAccepted(AliVEvent *event){
                  // take only events inside centrality class\r
                  if(fUseCentrality) {\r
                    if((gRefMultiplicity > fCentralityPercentileMin) && (gRefMultiplicity < fCentralityPercentileMax)){\r
+\r
+                     // centrality weighting (optional for 2011 if central and semicentral triggers are used)\r
+                     if (fCentralityWeights && !AcceptEventCentralityWeight(gRefMultiplicity)){\r
+                       AliInfo(Form("Rejecting event because of centrality weighting: %f", gRefMultiplicity));\r
+                       return -1;\r
+                     }\r
+                     \r
                      fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality\r
                      return gRefMultiplicity;          \r
                    }//centrality class\r
@@ -2301,6 +2309,28 @@ Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run,
   return 1.0;\r
 }\r
 \r
+//____________________________________________________________________\r
+Bool_t AliAnalysisTaskBFPsi::AcceptEventCentralityWeight(Double_t centrality)\r
+{\r
+  // copied from AliAnalysisTaskPhiCorrelations\r
+  //\r
+  // rejects "randomly" events such that the centrality gets flat\r
+  // uses fCentralityWeights histogram\r
+\r
+  // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening\r
+  \r
+  Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality));\r
+  Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.);\r
+  \r
+  Bool_t result = kFALSE;\r
+  if (centralityDigits < weight) \r
+    result = kTRUE;\r
+  \r
+  AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result));\r
+  \r
+  return result;\r
+}\r
+\r
 //________________________________________________________________________\r
 void  AliAnalysisTaskBFPsi::FinishTaskOutput(){\r
   //Printf("END BF");\r
index 335cc7a1f428da564d5ab0e6de959f05526609f2..06e5a2cbfea0a861466a2d788b10882de6be66e1 100755 (executable)
@@ -133,6 +133,9 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   void CheckPileUp() {fCheckPileUp = kTRUE;}\r
   void CheckPrimaryFlagAOD() {fCheckPrimaryFlagAOD = kTRUE;}\r
   void UseMCforKinematics() {fUseMCforKinematics = kTRUE;}\r
+  void SetCentralityWeights(TH1* hist) { fCentralityWeights = hist; }\r
+  Bool_t AcceptEventCentralityWeight(Double_t centrality);\r
+\r
   \r
   //Acceptance filter\r
   void SetAcceptanceParameterization(TF1 *parameterization) {\r
@@ -276,6 +279,8 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   Double_t fCentralityArrayForCorrections[kCENTRALITY];\r
   Int_t fCentralityArrayBinsForCorrections;\r
 \r
+  TH1* fCentralityWeights;                  // for centrality flattening\r
+\r
   AliPIDResponse *fPIDResponse;     //! PID response object\r
   AliPIDCombined       *fPIDCombined;     //! combined PID object\r
   \r
index 6b1084f87501ec67ced18da0dec56b92bdd4c727..24c32bcef6d14c0faa963211e97de1c2b3c68b16 100644 (file)
 #include "AliAODEvent.h" 
 #include "AliAODInputHandler.h"
 #include "AliAODMCParticle.h"
+#include "AliAODMCHeader.h"
 #include "AliCentrality.h"
+#include "AliGenEventHeader.h"
 
+#include "AliLog.h"
 #include "AliAnalysisTaskEffContBF.h"
 
 // ---------------------------------------------------------------------
@@ -311,6 +314,38 @@ void AliAnalysisTaskEffContBF::UserExec(Option_t *) {
     AliError("ERROR: Could not retrieve MC event");
     return;
   }
+
+  // ==============================================================================================
+  // Copy from AliAnalysisTaskPhiCorrelations:
+  // 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 only
+    AliAODMCHeader* header = (AliAODMCHeader*) fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+    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.");
+       return;
+      }
+    
+    skipParticlesAbove = eventHeader->NProduced();
+    AliInfo(Form("Injected signals in this event (%d headers). Keeping particles/tracks of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove)); 
+  }
+  // ==============================================================================================
+
   
   // arrays for 2 particle histograms
   Int_t nMCLabelCounter         = 0;
@@ -391,6 +426,44 @@ void AliAnalysisTaskEffContBF::UserExec(Option_t *) {
                //if (!(AODmcTrack->IsPhysicalPrimary())) {
                //fHistContaminationSecondaries->Fill(track->Eta(),track->Pt(),phiDeg);
                //}
+
+               // ==============================================================================================
+               // Partial copy from AliAnalyseLeadingTrackUE::RemoveInjectedSignals:
+               // Skip tracks that come from injected signals
+               if (fInjectedSignals)
+                 {    
+     
+                   AliAODMCParticle* mother = AODmcTrack;
+                   
+                   // find the primary mother (if not already physical primary)
+                   while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
+                     {
+                       if (((AliAODMCParticle*)mother)->GetMother() < 0)
+                         {
+                           mother = 0;
+                           break;
+                         }
+                       
+                       mother = (AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother());
+                       if (!mother)
+                         break;
+                     }
+                   
+                   
+                   if (!mother)
+                     {
+                       AliError(Form("WARNING: No mother found for particle %d:", AODmcTrack->GetLabel()));
+                       continue;
+                     }
+
+                   if (mother->GetLabel() >= skipParticlesAbove)
+                     {
+                       //AliInfo(Form("Remove particle %d (>= %d)",mother->GetLabel(),skipParticlesAbove));
+                       continue;
+                     }
+                 }
+               // ==============================================================================================
+
                if (AODmcTrack->IsPhysicalPrimary()) {
                  if(gAODmcCharge > 0){
                    fHistContaminationPrimariesPlus->Fill(track->Eta(),track->Pt(),phiRad);
index 95f8ec328a6d5da64ba3015840a178048a699250..db7d49f6a02d1a1c75bd19812b66f27bc12e00bf 100644 (file)
@@ -58,6 +58,7 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
     fCentralityEstimator("V0M"), 
     fCentralityPercentileMin(0.0), 
     fCentralityPercentileMax(5.0), 
+    fInjectedSignals(kFALSE),
     fVxMax(3.0), 
     fVyMax(3.0), 
     fVzMax(10.), 
@@ -106,6 +107,9 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
     fCentralityPercentileMax=max;
   }
 
+  //Injected signals
+  void SetRejectInjectedSignals() {fInjectedSignals = kTRUE;}
+
   //Track cuts
   void SetMinNumberOfTPCClusters(Double_t min) {
     fMinNumberOfTPCClusters = min;}
@@ -186,6 +190,8 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
   TString fCentralityEstimator;//"V0M","TRK","TKL","ZDC","FMD"
   Float_t fCentralityPercentileMin, fCentralityPercentileMax; //min-max centrality percentile
 
+  Bool_t fInjectedSignals;//Flag for using the rejection of injected signals
+
   Double_t fVxMax;//vxmax
   Double_t fVyMax;//vymax
   Double_t fVzMax;//vzmax
index 23da226aea32c653b89d1e439fe7f22573e56583..81c286fac52d0bbd1f7065b9bbfa98ed2aaea3eb 100644 (file)
@@ -953,23 +953,69 @@ TH1D *AliBalancePsi::GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
       //Printf("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0));
       
       // Project into the wanted space (1st: analysis step, 2nd: axis)
-      TH1D* hTemp1 = (TH1D*)fHistPN->Project(0,iVariablePair);
-      TH1D* hTemp2 = (TH1D*)fHistNP->Project(0,iVariablePair);
-      TH1D* hTemp3 = (TH1D*)fHistPP->Project(0,iVariablePair);
-      TH1D* hTemp4 = (TH1D*)fHistNN->Project(0,iVariablePair);
+      TH1D* hTempHelper1 = (TH1D*)fHistPN->Project(0,iVariablePair);
+      TH1D* hTempHelper2 = (TH1D*)fHistNP->Project(0,iVariablePair);
+      TH1D* hTempHelper3 = (TH1D*)fHistPP->Project(0,iVariablePair);
+      TH1D* hTempHelper4 = (TH1D*)fHistNN->Project(0,iVariablePair);
       TH1D* hTemp5 = (TH1D*)fHistP->Project(0,iVariableSingle);
       TH1D* hTemp6 = (TH1D*)fHistN->Project(0,iVariableSingle);
       
       // ============================================================================================
       // the same for event mixing
-      TH1D* hTemp1Mix = (TH1D*)fHistPNMix->Project(0,iVariablePair);
-      TH1D* hTemp2Mix = (TH1D*)fHistNPMix->Project(0,iVariablePair);
-      TH1D* hTemp3Mix = (TH1D*)fHistPPMix->Project(0,iVariablePair);
-      TH1D* hTemp4Mix = (TH1D*)fHistNNMix->Project(0,iVariablePair);
+      TH1D* hTempHelper1Mix = (TH1D*)fHistPNMix->Project(0,iVariablePair);
+      TH1D* hTempHelper2Mix = (TH1D*)fHistNPMix->Project(0,iVariablePair);
+      TH1D* hTempHelper3Mix = (TH1D*)fHistPPMix->Project(0,iVariablePair);
+      TH1D* hTempHelper4Mix = (TH1D*)fHistNNMix->Project(0,iVariablePair);
       TH1D* hTemp5Mix = (TH1D*)fHistPMix->Project(0,iVariableSingle);
       TH1D* hTemp6Mix = (TH1D*)fHistNMix->Project(0,iVariableSingle);
       // ============================================================================================
-      
+
+      hTempHelper1->Sumw2();
+      hTempHelper2->Sumw2();
+      hTempHelper3->Sumw2();
+      hTempHelper4->Sumw2();
+      hTemp5->Sumw2();
+      hTemp6->Sumw2();
+      hTempHelper1Mix->Sumw2();
+      hTempHelper2Mix->Sumw2();
+      hTempHelper3Mix->Sumw2();
+      hTempHelper4Mix->Sumw2();
+      hTemp5Mix->Sumw2();
+      hTemp6Mix->Sumw2();
+
+      // first put everything on positive x - axis (to be comparable with published data) --> ONLY IN THIS OPTION!
+
+      Double_t helperEndBin = 1.6;
+      if(iVariablePair==2) helperEndBin = TMath::Pi();
+
+      TH1D* hTempPos1 = new TH1D(Form("hTempPos1_%d_%d",iBinPsi,iBinVertex),Form("hTempPos1_%d_%d",iBinPsi,iBinVertex),hTempHelper1->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos2 = new TH1D(Form("hTempPos2_%d_%d",iBinPsi,iBinVertex),Form("hTempPos2_%d_%d",iBinPsi,iBinVertex),hTempHelper2->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos3 = new TH1D(Form("hTempPos3_%d_%d",iBinPsi,iBinVertex),Form("hTempPos3_%d_%d",iBinPsi,iBinVertex),hTempHelper3->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos4 = new TH1D(Form("hTempPos4_%d_%d",iBinPsi,iBinVertex),Form("hTempPos4_%d_%d",iBinPsi,iBinVertex),hTempHelper4->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos1Mix = new TH1D(Form("hTempPos1Mix_%d_%d",iBinPsi,iBinVertex),Form("hTempPos1Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper1Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos2Mix = new TH1D(Form("hTempPos2Mix_%d_%d",iBinPsi,iBinVertex),Form("hTempPos2Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper2Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos3Mix = new TH1D(Form("hTempPos3Mix_%d_%d",iBinPsi,iBinVertex),Form("hTempPos3Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper3Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTempPos4Mix = new TH1D(Form("hTempPos4Mix_%d_%d",iBinPsi,iBinVertex),Form("hTempPos4Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper4Mix->GetNbinsX()/2,0,helperEndBin);
+
+      TH1D* hTemp1 = new TH1D(Form("hTemp1_%d_%d",iBinPsi,iBinVertex),Form("hTemp1_%d_%d",iBinPsi,iBinVertex),hTempHelper1->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp2 = new TH1D(Form("hTemp2_%d_%d",iBinPsi,iBinVertex),Form("hTemp2_%d_%d",iBinPsi,iBinVertex),hTempHelper2->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp3 = new TH1D(Form("hTemp3_%d_%d",iBinPsi,iBinVertex),Form("hTemp3_%d_%d",iBinPsi,iBinVertex),hTempHelper3->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp4 = new TH1D(Form("hTemp4_%d_%d",iBinPsi,iBinVertex),Form("hTemp4_%d_%d",iBinPsi,iBinVertex),hTempHelper4->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp1Mix = new TH1D(Form("hTemp1Mix_%d_%d",iBinPsi,iBinVertex),Form("hTemp1Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper1Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp2Mix = new TH1D(Form("hTemp2Mix_%d_%d",iBinPsi,iBinVertex),Form("hTemp2Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper2Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp3Mix = new TH1D(Form("hTemp3Mix_%d_%d",iBinPsi,iBinVertex),Form("hTemp3Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper3Mix->GetNbinsX()/2,0,helperEndBin);
+      TH1D* hTemp4Mix = new TH1D(Form("hTemp4Mix_%d_%d",iBinPsi,iBinVertex),Form("hTemp4Mix_%d_%d",iBinPsi,iBinVertex),hTempHelper4Mix->GetNbinsX()/2,0,helperEndBin);
+
+
+      hTempPos1->Sumw2();
+      hTempPos2->Sumw2();
+      hTempPos3->Sumw2();
+      hTempPos4->Sumw2();
+      hTempPos1Mix->Sumw2();
+      hTempPos2Mix->Sumw2();
+      hTempPos3Mix->Sumw2();
+      hTempPos4Mix->Sumw2();
+
       hTemp1->Sumw2();
       hTemp2->Sumw2();
       hTemp3->Sumw2();
@@ -978,7 +1024,122 @@ TH1D *AliBalancePsi::GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
       hTemp2Mix->Sumw2();
       hTemp3Mix->Sumw2();
       hTemp4Mix->Sumw2();
-      
+
+
+      for(Int_t i=0;i<hTempHelper1->GetNbinsX();i++){
+
+       Double_t binCenter  = hTempHelper1->GetXaxis()->GetBinCenter(i+1);
+
+       if(iVariablePair==1){
+         if(binCenter>0){
+           hTempPos1->SetBinContent(hTempPos1->FindBin(binCenter),hTempHelper1->GetBinContent(i+1));
+           hTempPos2->SetBinContent(hTempPos2->FindBin(binCenter),hTempHelper2->GetBinContent(i+1));
+           hTempPos3->SetBinContent(hTempPos3->FindBin(binCenter),hTempHelper3->GetBinContent(i+1));
+           hTempPos4->SetBinContent(hTempPos4->FindBin(binCenter),hTempHelper4->GetBinContent(i+1));
+           hTempPos1Mix->SetBinContent(hTempPos1Mix->FindBin(binCenter),hTempHelper1Mix->GetBinContent(i+1));
+           hTempPos2Mix->SetBinContent(hTempPos2Mix->FindBin(binCenter),hTempHelper2Mix->GetBinContent(i+1));
+           hTempPos3Mix->SetBinContent(hTempPos3Mix->FindBin(binCenter),hTempHelper3Mix->GetBinContent(i+1));
+           hTempPos4Mix->SetBinContent(hTempPos4Mix->FindBin(binCenter),hTempHelper4Mix->GetBinContent(i+1));
+
+           hTempPos1->SetBinError(hTempPos1->FindBin(binCenter),hTempHelper1->GetBinError(i+1));
+           hTempPos2->SetBinError(hTempPos2->FindBin(binCenter),hTempHelper2->GetBinError(i+1));
+           hTempPos3->SetBinError(hTempPos3->FindBin(binCenter),hTempHelper3->GetBinError(i+1));
+           hTempPos4->SetBinError(hTempPos4->FindBin(binCenter),hTempHelper4->GetBinError(i+1));
+           hTempPos1Mix->SetBinError(hTempPos1Mix->FindBin(binCenter),hTempHelper1Mix->GetBinError(i+1));
+           hTempPos2Mix->SetBinError(hTempPos2Mix->FindBin(binCenter),hTempHelper2Mix->GetBinError(i+1));
+           hTempPos3Mix->SetBinError(hTempPos3Mix->FindBin(binCenter),hTempHelper3Mix->GetBinError(i+1));
+           hTempPos4Mix->SetBinError(hTempPos4Mix->FindBin(binCenter),hTempHelper4Mix->GetBinError(i+1));
+         }
+         else{
+           hTemp1->SetBinContent(hTemp1->FindBin(-binCenter),hTempHelper1->GetBinContent(i+1));
+           hTemp2->SetBinContent(hTemp2->FindBin(-binCenter),hTempHelper2->GetBinContent(i+1));
+           hTemp3->SetBinContent(hTemp3->FindBin(-binCenter),hTempHelper3->GetBinContent(i+1));
+           hTemp4->SetBinContent(hTemp4->FindBin(-binCenter),hTempHelper4->GetBinContent(i+1));
+           hTemp1Mix->SetBinContent(hTemp1Mix->FindBin(-binCenter),hTempHelper1Mix->GetBinContent(i+1));
+           hTemp2Mix->SetBinContent(hTemp2Mix->FindBin(-binCenter),hTempHelper2Mix->GetBinContent(i+1));
+           hTemp3Mix->SetBinContent(hTemp3Mix->FindBin(-binCenter),hTempHelper3Mix->GetBinContent(i+1));
+           hTemp4Mix->SetBinContent(hTemp4Mix->FindBin(-binCenter),hTempHelper4Mix->GetBinContent(i+1));
+
+           hTemp1->SetBinError(hTemp1->FindBin(-binCenter),hTempHelper1->GetBinError(i+1));
+           hTemp2->SetBinError(hTemp2->FindBin(-binCenter),hTempHelper2->GetBinError(i+1));
+           hTemp3->SetBinError(hTemp3->FindBin(-binCenter),hTempHelper3->GetBinError(i+1));
+           hTemp4->SetBinError(hTemp4->FindBin(-binCenter),hTempHelper4->GetBinError(i+1));
+           hTemp1Mix->SetBinError(hTemp1Mix->FindBin(-binCenter),hTempHelper1Mix->GetBinError(i+1));
+           hTemp2Mix->SetBinError(hTemp2Mix->FindBin(-binCenter),hTempHelper2Mix->GetBinError(i+1));
+           hTemp3Mix->SetBinError(hTemp3Mix->FindBin(-binCenter),hTempHelper3Mix->GetBinError(i+1));
+           hTemp4Mix->SetBinError(hTemp4Mix->FindBin(-binCenter),hTempHelper4Mix->GetBinError(i+1));
+         }
+       }
+       else if(iVariablePair==2){
+         if(binCenter>0 && binCenter<TMath::Pi()){
+           hTempPos1->SetBinContent(hTempPos1->FindBin(binCenter),hTempHelper1->GetBinContent(i+1));
+           hTempPos2->SetBinContent(hTempPos2->FindBin(binCenter),hTempHelper2->GetBinContent(i+1));
+           hTempPos3->SetBinContent(hTempPos3->FindBin(binCenter),hTempHelper3->GetBinContent(i+1));
+           hTempPos4->SetBinContent(hTempPos4->FindBin(binCenter),hTempHelper4->GetBinContent(i+1));
+           hTempPos1Mix->SetBinContent(hTempPos1Mix->FindBin(binCenter),hTempHelper1Mix->GetBinContent(i+1));
+           hTempPos2Mix->SetBinContent(hTempPos2Mix->FindBin(binCenter),hTempHelper2Mix->GetBinContent(i+1));
+           hTempPos3Mix->SetBinContent(hTempPos3Mix->FindBin(binCenter),hTempHelper3Mix->GetBinContent(i+1));
+           hTempPos4Mix->SetBinContent(hTempPos4Mix->FindBin(binCenter),hTempHelper4Mix->GetBinContent(i+1));
+
+           hTempPos1->SetBinError(hTempPos1->FindBin(binCenter),hTempHelper1->GetBinError(i+1));
+           hTempPos2->SetBinError(hTempPos2->FindBin(binCenter),hTempHelper2->GetBinError(i+1));
+           hTempPos3->SetBinError(hTempPos3->FindBin(binCenter),hTempHelper3->GetBinError(i+1));
+           hTempPos4->SetBinError(hTempPos4->FindBin(binCenter),hTempHelper4->GetBinError(i+1));
+           hTempPos1Mix->SetBinError(hTempPos1Mix->FindBin(binCenter),hTempHelper1Mix->GetBinError(i+1));
+           hTempPos2Mix->SetBinError(hTempPos2Mix->FindBin(binCenter),hTempHelper2Mix->GetBinError(i+1));
+           hTempPos3Mix->SetBinError(hTempPos3Mix->FindBin(binCenter),hTempHelper3Mix->GetBinError(i+1));
+           hTempPos4Mix->SetBinError(hTempPos4Mix->FindBin(binCenter),hTempHelper4Mix->GetBinError(i+1));
+         }
+         else if(binCenter<0){
+           hTemp1->SetBinContent(hTemp1->FindBin(-binCenter),hTempHelper1->GetBinContent(i+1));
+           hTemp2->SetBinContent(hTemp2->FindBin(-binCenter),hTempHelper2->GetBinContent(i+1));
+           hTemp3->SetBinContent(hTemp3->FindBin(-binCenter),hTempHelper3->GetBinContent(i+1));
+           hTemp4->SetBinContent(hTemp4->FindBin(-binCenter),hTempHelper4->GetBinContent(i+1));
+           hTemp1Mix->SetBinContent(hTemp1Mix->FindBin(-binCenter),hTempHelper1Mix->GetBinContent(i+1));
+           hTemp2Mix->SetBinContent(hTemp2Mix->FindBin(-binCenter),hTempHelper2Mix->GetBinContent(i+1));
+           hTemp3Mix->SetBinContent(hTemp3Mix->FindBin(-binCenter),hTempHelper3Mix->GetBinContent(i+1));
+           hTemp4Mix->SetBinContent(hTemp4Mix->FindBin(-binCenter),hTempHelper4Mix->GetBinContent(i+1));
+
+           hTemp1->SetBinError(hTemp1->FindBin(-binCenter),hTempHelper1->GetBinError(i+1));
+           hTemp2->SetBinError(hTemp2->FindBin(-binCenter),hTempHelper2->GetBinError(i+1));
+           hTemp3->SetBinError(hTemp3->FindBin(-binCenter),hTempHelper3->GetBinError(i+1));
+           hTemp4->SetBinError(hTemp4->FindBin(-binCenter),hTempHelper4->GetBinError(i+1));
+           hTemp1Mix->SetBinError(hTemp1Mix->FindBin(-binCenter),hTempHelper1Mix->GetBinError(i+1));
+           hTemp2Mix->SetBinError(hTemp2Mix->FindBin(-binCenter),hTempHelper2Mix->GetBinError(i+1));
+           hTemp3Mix->SetBinError(hTemp3Mix->FindBin(-binCenter),hTempHelper3Mix->GetBinError(i+1));
+           hTemp4Mix->SetBinError(hTemp4Mix->FindBin(-binCenter),hTempHelper4Mix->GetBinError(i+1));
+         }
+         else{
+           hTemp1->SetBinContent(hTemp1->FindBin(TMath::Pi()-binCenter),hTempHelper1->GetBinContent(i+1));
+           hTemp2->SetBinContent(hTemp2->FindBin(TMath::Pi()-binCenter),hTempHelper2->GetBinContent(i+1));
+           hTemp3->SetBinContent(hTemp3->FindBin(TMath::Pi()-binCenter),hTempHelper3->GetBinContent(i+1));
+           hTemp4->SetBinContent(hTemp4->FindBin(TMath::Pi()-binCenter),hTempHelper4->GetBinContent(i+1));
+           hTemp1Mix->SetBinContent(hTemp1Mix->FindBin(TMath::Pi()-binCenter),hTempHelper1Mix->GetBinContent(i+1));
+           hTemp2Mix->SetBinContent(hTemp2Mix->FindBin(TMath::Pi()-binCenter),hTempHelper2Mix->GetBinContent(i+1));
+           hTemp3Mix->SetBinContent(hTemp3Mix->FindBin(TMath::Pi()-binCenter),hTempHelper3Mix->GetBinContent(i+1));
+           hTemp4Mix->SetBinContent(hTemp4Mix->FindBin(TMath::Pi()-binCenter),hTempHelper4Mix->GetBinContent(i+1));
+
+           hTemp1->SetBinError(hTemp1->FindBin(TMath::Pi()-binCenter),hTempHelper1->GetBinError(i+1));
+           hTemp2->SetBinError(hTemp2->FindBin(TMath::Pi()-binCenter),hTempHelper2->GetBinError(i+1));
+           hTemp3->SetBinError(hTemp3->FindBin(TMath::Pi()-binCenter),hTempHelper3->GetBinError(i+1));
+           hTemp4->SetBinError(hTemp4->FindBin(TMath::Pi()-binCenter),hTempHelper4->GetBinError(i+1));
+           hTemp1Mix->SetBinError(hTemp1Mix->FindBin(TMath::Pi()-binCenter),hTempHelper1Mix->GetBinError(i+1));
+           hTemp2Mix->SetBinError(hTemp2Mix->FindBin(TMath::Pi()-binCenter),hTempHelper2Mix->GetBinError(i+1));
+           hTemp3Mix->SetBinError(hTemp3Mix->FindBin(TMath::Pi()-binCenter),hTempHelper3Mix->GetBinError(i+1));
+           hTemp4Mix->SetBinError(hTemp4Mix->FindBin(TMath::Pi()-binCenter),hTempHelper4Mix->GetBinError(i+1));
+         }
+       }
+      }
+
+      hTemp1->Add(hTempPos1);
+      hTemp2->Add(hTempPos2);
+      hTemp3->Add(hTempPos3);
+      hTemp4->Add(hTempPos4);
+      hTemp1Mix->Add(hTempPos1Mix);
+      hTemp2Mix->Add(hTempPos2Mix);
+      hTemp3Mix->Add(hTempPos3Mix);
+      hTemp4Mix->Add(hTempPos4Mix);
+
       hTemp1->Scale(1./hTemp5->GetEntries());
       hTemp3->Scale(1./hTemp5->GetEntries());
       hTemp2->Scale(1./hTemp6->GetEntries());
@@ -1011,6 +1172,23 @@ TH1D *AliBalancePsi::GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
        h4->Add(hTemp4);
       }
 
+      delete hTemp1;
+      delete hTemp2;
+      delete hTemp3;
+      delete hTemp4;
+      delete hTemp1Mix;
+      delete hTemp2Mix;
+      delete hTemp3Mix;
+      delete hTemp4Mix;
+
+      delete hTempPos1;
+      delete hTempPos2;
+      delete hTempPos3;
+      delete hTempPos4;
+      delete hTempPos1Mix;
+      delete hTempPos2Mix;
+      delete hTempPos3Mix;
+      delete hTempPos4Mix;
     }
   }
 
index bbd63a87b53d0a32bd4f79b395ce2ae40d49449a..aa561bc4aa46e1e5cc1f3b9b4ddcbaaba1d4ddde 100644 (file)
Binary files a/PWGCF/EBYE/BalanceFunctions/Corrections/CorrectionMaps_PbPb_768.root and b/PWGCF/EBYE/BalanceFunctions/Corrections/CorrectionMaps_PbPb_768.root differ
index 5c97a52c12c8c4245b82acade01883725eb53b47..7227870868d57daa4152e097bd4771cf79297e0d 100644 (file)
@@ -39,6 +39,7 @@ AliAnalysisTaskEffContBF *AddTaskBalanceEffCont( TString  centralityEstimator="V
 
   // centrality
   if(centralityEstimator) {
+    taskEffContBF->UseCentrality();
     taskEffContBF->SetCentralityEstimator(centralityEstimator);
     taskEffContBF->SetCentralityPercentileRange(centrMin,centrMax);
   }
index 9a156bf65b6b0576660d724438343403f7f54ab6..1e5b83db5f8d0618626d69456a05ffb917409d51 100644 (file)
@@ -932,7 +932,8 @@ void drawProjections(TH2D *gHistBalanceFunction2D = 0x0,
                     Bool_t k2pMethod = kTRUE,
                     TString eventClass = "Centrality",
                     Bool_t bRootMoments = kFALSE,
-                    Bool_t kUseZYAM = kFALSE) {
+                    Bool_t kUseZYAM = kFALSE,
+                    Bool_t bReduceRangeForMoments = kFALSE) {
   //Macro that draws the balance functions PROJECTIONS 
   //for each centrality bin for the different pT of trigger and 
   //associated particles
@@ -1097,6 +1098,20 @@ void drawProjections(TH2D *gHistBalanceFunction2D = 0x0,
     // need to restrict to near side in case of dphi
     if(!kProjectInEta) gHistBalanceFunctionSubtracted->GetXaxis()->SetRangeUser(-TMath::Pi()/2,TMath::Pi()/2);
 
+    if(bReduceRangeForMoments){
+
+      // default (for 2<pT,assoc<3<pT,trig<4)
+      Double_t rangeReduced = 1.0;
+
+      //for 3<pT,assoc<8<pT,trig<15
+      if(ptTriggerMax>10){
+       rangeReduced = 0.4;
+      }
+
+      cout<<"Use reduced range = "<<rangeReduced<<endl;
+      gHistBalanceFunctionSubtracted->GetXaxis()->SetRangeUser(-rangeReduced,rangeReduced);
+    }
+
     meanLatex = "#mu = "; 
     meanLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetMean());
     meanLatex += " #pm "; 
@@ -1169,7 +1184,7 @@ void drawProjections(TH2D *gHistBalanceFunction2D = 0x0,
     fileKurtosis.close();
 
     if(!kProjectInEta) gHistBalanceFunctionSubtracted->GetXaxis()->SetRangeUser(-TMath::Pi()/2,3.*TMath::Pi()/2);
-
+    else               gHistBalanceFunctionSubtracted->GetXaxis()->SetRangeUser(-1.6,1.6);
   }
   // calculate the moments by hand
   else{
@@ -1257,7 +1272,12 @@ void drawProjections(TH2D *gHistBalanceFunction2D = 0x0,
 
   // Weighted mean as calculated for 1D analysis
   Double_t weightedMean, weightedMeanError;
-  GetWeightedMean1D(gHistBalanceFunctionSubtracted,kProjectInEta,1,-1,weightedMean,weightedMeanError);
+  if(bReduceRangeForMoments){
+    GetWeightedMean1D(gHistBalanceFunctionSubtracted,kProjectInEta,1,-1,weightedMean,weightedMeanError,rangeReduced);
+  }
+  else{
+    GetWeightedMean1D(gHistBalanceFunctionSubtracted,kProjectInEta,1,-1,weightedMean,weightedMeanError,-1.);
+  }
   Printf("Weighted Mean: %lf - Error: %lf",weightedMean, weightedMeanError);
  
   // store in txt files
@@ -1318,7 +1338,9 @@ void drawBFPsi2DFromCorrelationFunctions(const char* lhcPeriod = "LHC10h",
                                         Double_t ptAssociatedMin = -1.,
                                         Double_t ptAssociatedMax = -1.,
                                         TString eventClass = "Multiplicity",
-                                        Bool_t bRootMoments = kFALSE
+                                        Bool_t bRootMoments = kFALSE,
+                                        Bool_t bFullPhiForEtaProjection = kFALSE,
+                                        Bool_t bReduceRangeForMoments = kFALSE
 ) {
   //Macro that draws the BF distributions for each centrality bin
   //for reaction plane dependent analysis
@@ -1443,16 +1465,36 @@ void drawBFPsi2DFromCorrelationFunctions(const char* lhcPeriod = "LHC10h",
 
   c0->SaveAs(pngName.Data());
 
+ // do the full range for the projection on eta (for cross checking with published results)
+ if(bFullPhiForEtaProjection){
+   
+   drawProjections(gHistBalanceFunction2D,
+                  kTRUE,
+                  1,72,
+                  gCentrality,
+                  psiMin,psiMax,
+                  ptTriggerMin,ptTriggerMax,
+                  ptAssociatedMin,ptAssociatedMax,
+                  kTRUE,
+                  eventClass.Data(),
+                  bRootMoments,
+                  kFALSE,
+                  bReduceRangeForMoments);
+ }
+ else{
   drawProjections(gHistBalanceFunction2D,
-                 kTRUE,
-                 1,36,
-                 gCentrality,
-                 psiMin,psiMax,
-                 ptTriggerMin,ptTriggerMax,
-                 ptAssociatedMin,ptAssociatedMax,
-                 kTRUE,
-                 eventClass,
-                 bRootMoments);
+                  kTRUE,
+                  1,36,
+                  gCentrality,
+                  psiMin,psiMax,
+                  ptTriggerMin,ptTriggerMax,
+                  ptAssociatedMin,ptAssociatedMax,
+                  kTRUE,
+                  eventClass.Data(),
+                 bRootMoments,
+                 kFALSE,
+                 bReduceRangeForMoments);
+ }
 
   drawProjections(gHistBalanceFunction2D,
                  kFALSE,
@@ -1463,7 +1505,9 @@ void drawBFPsi2DFromCorrelationFunctions(const char* lhcPeriod = "LHC10h",
                  ptAssociatedMin,ptAssociatedMax,
                  kTRUE,
                  eventClass.Data(),
-                 bRootMoments);
+                 bRootMoments,
+                 kFALSE,
+                 bReduceRangeForMoments);
 
   TString outFileName = filename;
   outFileName.ReplaceAll("correlationFunction","balanceFunction2D");
@@ -1487,7 +1531,8 @@ void mergeBFPsi2D(TString momDirectory = "./",
                  Double_t ptTriggerMin = -1.,
                  Double_t ptTriggerMax = -1.,
                  Double_t ptAssociatedMin = -1.,
-                 Double_t ptAssociatedMax = -1.
+                 Double_t ptAssociatedMax = -1.,
+                 Bool_t bReduceRangeForMoments = kFALSE
 ) {
   //Macro that draws the BF distributions for each centrality bin
   //for reaction plane dependent analysis
@@ -1594,8 +1639,8 @@ sFileName[iDir] += momDirectory;
 
  // scaling with all entries
  hBFOut->Scale(1./entriesOut);
-  
 drawProjections(hBFOut,
+
+ drawProjections(hBFOut,
                  kTRUE,
                  1,36,
                  gCentrality,
@@ -1604,7 +1649,9 @@ sFileName[iDir] += momDirectory;
                  ptAssociatedMin,ptAssociatedMax,
                  kTRUE,
                  eventClass,
-                 kTRUE);
+                 kTRUE,
+                 kFALSE,
+                 bReduceRangeForMoments);
 
   drawProjections(hBFOut,
                  kFALSE,
@@ -1615,7 +1662,9 @@ sFileName[iDir] += momDirectory;
                  ptAssociatedMin,ptAssociatedMax,
                  kTRUE,
                  eventClass.Data(),
-                 kTRUE);
+                 kTRUE,
+                 kFALSE,
+                 bReduceRangeForMoments);
 
  // output
  TString outFileName = "balanceFunction2D.";
@@ -1655,7 +1704,7 @@ sFileName[iDir] += momDirectory;
 }
 
 //____________________________________________________________________//
-void GetWeightedMean1D(TH1D *gHistBalance, Bool_t kProjectInEta = kTRUE, Int_t fStartBin = 1, Int_t fStopBin = -1, Double_t &WM, Double_t &WME) {
+void GetWeightedMean1D(TH1D *gHistBalance, Bool_t kProjectInEta = kTRUE, Int_t fStartBin = 1, Int_t fStopBin = -1, Double_t &WM, Double_t &WME,Double_t rangeReduced = -1.) {
 
   //Prints the calculated width of the BF and its error
   Double_t gSumXi = 0.0, gSumBi = 0.0, gSumBiXi = 0.0;
@@ -1682,6 +1731,9 @@ void GetWeightedMean1D(TH1D *gHistBalance, Bool_t kProjectInEta = kTRUE, Int_t f
       if(currentBinCenter > TMath::Pi()) currentBinCenter = 2 * TMath::Pi() - currentBinCenter;
     }
 
+    if(rangeReduced > 0 && currentBinCenter > rangeReduced )
+      continue;
+
     gSumXi += currentBinCenter;
     gSumBi += gHistBalance->GetBinContent(i);
     gSumBiXi += gHistBalance->GetBinContent(i)*currentBinCenter;
index 37d1b2f6c898504da46496c298ce881d161c460b..eb50ce1028c5cf3f41e3ceee55a42606f88290b6 100644 (file)
@@ -221,7 +221,7 @@ void draw(TList *listBF, TList *listBFShuffled, TList *listBFMixed,
   SetPlotStyle();
   gStyle->SetPalette(1,0);
   
-  const Int_t gRebin = gDeltaEtaDeltaPhi; //rebin by 2 the Delta phi projection
+  const Int_t gRebin = 1.;//gDeltaEtaDeltaPhi; //rebin by 2 the Delta phi projection (old)
 
   //balance function
   AliTHn *hP = NULL;
@@ -569,7 +569,66 @@ void draw(TList *listBF, TList *listBFShuffled, TList *listBFMixed,
     Printf("RMS: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetRMS(),gHistBalanceFunctionSubtracted->GetRMSError());
     Printf("Skeweness: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetSkewness(1),gHistBalanceFunctionSubtracted->GetSkewness(11));
     Printf("Kurtosis: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetKurtosis(1),gHistBalanceFunctionSubtracted->GetKurtosis(11));
+
+    // store in txt files
+
+    Bool_t kProjectInEta = kFALSE;
+    if(gDeltaEtaDeltaPhi==1) //Delta eta
+      kProjectInEta = kTRUE;
+
+    TString meanFileName = "";
+    if(kProjectInEta) 
+      meanFileName= "deltaEtaProjection_Mean.txt";
+    else              
+      meanFileName = "deltaPhiProjection_Mean.txt";
+    ofstream fileMean(meanFileName.Data(),ios::app);
+    fileMean << " " << gHistBalanceFunctionSubtracted->GetMean() << " " <<gHistBalanceFunctionSubtracted->GetMeanError()<<endl;
+    fileMean.close();
+
+    TString rmsFileName = "";
+    if(kProjectInEta) 
+      rmsFileName = "deltaEtaProjection_Rms.txt";
+    else              
+      rmsFileName = "deltaPhiProjection_Rms.txt";
+    ofstream fileRms(rmsFileName.Data(),ios::app);
+    fileRms << " " << gHistBalanceFunctionSubtracted->GetRMS() << " " <<gHistBalanceFunctionSubtracted->GetRMSError()<<endl;
+    fileRms.close();
+
+    TString skewnessFileName = "";
+    if(kProjectInEta) 
+      skewnessFileName = "deltaEtaProjection_Skewness.txt";
+    else              
+      skewnessFileName = "deltaPhiProjection_Skewness.txt";
+    ofstream fileSkewness(skewnessFileName.Data(),ios::app);
+    fileSkewness << " " << gHistBalanceFunctionSubtracted->GetSkewness(1) << " " <<gHistBalanceFunctionSubtracted->GetSkewness(11)<<endl;
+    fileSkewness.close();
+
+    TString kurtosisFileName = "";
+    if(kProjectInEta) 
+      kurtosisFileName = "deltaEtaProjection_Kurtosis.txt";
+    else
+      kurtosisFileName = "deltaPhiProjection_Kurtosis.txt";              
+    ofstream fileKurtosis(kurtosisFileName.Data(),ios::app);
+    fileKurtosis << " " << gHistBalanceFunctionSubtracted->GetKurtosis(1) << " " <<gHistBalanceFunctionSubtracted->GetKurtosis(11)<<endl;
+    fileKurtosis.close();
+
+    // Weighted mean as calculated for 1D analysis
+    Double_t weightedMean, weightedMeanError;
+    GetWeightedMean1D(gHistBalanceFunctionSubtracted,kProjectInEta,1,-1,weightedMean,weightedMeanError);
+    Printf("Weighted Mean: %lf - Error: %lf",weightedMean, weightedMeanError);
+    
+    // store in txt files
+    TString weightedMeanFileName = "";
+    if(kProjectInEta) 
+      weightedMeanFileName = "deltaEtaProjection_WeightedMean.txt";
+    else              
+      weightedMeanFileName = "deltaPhiProjection_WeightedMean.txt";
+    ofstream fileWeightedMean(weightedMeanFileName.Data(),ios::app);
+    fileWeightedMean << " " << weightedMean << " " <<weightedMeanError<<endl;
+    fileWeightedMean.close();
+  
   }
+
   // calculate the moments by hand
   else{
 
@@ -1028,3 +1087,54 @@ void drawBFPsi(const char* lhcPeriod = "LHC10h",
 
   c2->SaveAs(pngName.Data());
 }
+
+//____________________________________________________________________//
+void GetWeightedMean1D(TH1D *gHistBalance, Bool_t kProjectInEta = kTRUE, Int_t fStartBin = 1, Int_t fStopBin = -1, Double_t &WM, Double_t &WME) {
+
+  //Prints the calculated width of the BF and its error
+  Double_t gSumXi = 0.0, gSumBi = 0.0, gSumBiXi = 0.0;
+  Double_t gSumBiXi2 = 0.0, gSumBi2Xi2 = 0.0;
+  Double_t gSumDeltaBi2 = 0.0, gSumXi2DeltaBi2 = 0.0;
+  Double_t deltaBalP2 = 0.0, integral = 0.0;
+  Double_t deltaErrorNew = 0.0;
+
+  //Retrieve this variables from Histogram
+  Int_t fNumberOfBins = gHistBalance->GetNbinsX();
+  if(fStopBin > -1)   fNumberOfBins = fStopBin;
+  Double_t fP2Step    = gHistBalance->GetBinWidth(1); // assume equal binning!
+  Double_t currentBinCenter = 0.;
+
+  for(Int_t i = fStartBin; i <= fNumberOfBins; i++) {
+
+    // in order to recover the |abs| in the 1D analysis
+    currentBinCenter = gHistBalance->GetBinCenter(i);
+    if(kProjectInEta){
+      if(currentBinCenter < 0) currentBinCenter = -currentBinCenter;
+    }
+    else{
+      if(currentBinCenter < 0) currentBinCenter = -currentBinCenter;
+      if(currentBinCenter > TMath::Pi()) currentBinCenter = 2 * TMath::Pi() - currentBinCenter;
+    }
+
+    gSumXi += currentBinCenter;
+    gSumBi += gHistBalance->GetBinContent(i);
+    gSumBiXi += gHistBalance->GetBinContent(i)*currentBinCenter;
+    gSumBiXi2 += gHistBalance->GetBinContent(i)*TMath::Power(currentBinCenter,2);
+    gSumBi2Xi2 += TMath::Power(gHistBalance->GetBinContent(i),2)*TMath::Power(currentBinCenter,2);
+    gSumDeltaBi2 +=  TMath::Power(gHistBalance->GetBinError(i),2);
+    gSumXi2DeltaBi2 += TMath::Power(currentBinCenter,2) * TMath::Power(gHistBalance->GetBinError(i),2);
+    
+    deltaBalP2 += fP2Step*TMath::Power(gHistBalance->GetBinError(i),2);
+    integral += fP2Step*gHistBalance->GetBinContent(i);
+  }
+  for(Int_t i = fStartBin; i < fNumberOfBins; i++)
+    deltaErrorNew += gHistBalance->GetBinError(i)*(currentBinCenter*gSumBi - gSumBiXi)/TMath::Power(gSumBi,2);
+  
+  Double_t integralError = TMath::Sqrt(deltaBalP2);
+  
+  Double_t delta = gSumBiXi / gSumBi;
+  Double_t deltaError = (gSumBiXi / gSumBi) * TMath::Sqrt(TMath::Power((TMath::Sqrt(gSumXi2DeltaBi2)/gSumBiXi),2) + TMath::Power((gSumDeltaBi2/gSumBi),2) );
+  
+  WM  = delta;
+  WME = deltaError;
+}
index 61c3d5f9b508ed4eff06072c3269f1b832115836..6481b2ff8e55839e1fca5aaeb9927e2a7908b90f 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "TFile.h"
 #include "TTree.h"
+#include "TRandom3.h"
 #include "AliAODEvent.h"
 #include "AliAODTrack.h"
 #include "AliAODVertex.h"
@@ -62,7 +63,8 @@ AliFemtoEventReaderAOD::AliFemtoEventReaderAOD():
   fMagFieldSign(1),
   fisEPVZ(kTRUE),
   fpA2013(kFALSE),
-  fDCAglobalTrack(kFALSE)
+  fDCAglobalTrack(kFALSE),
+  fFlatCent(kFALSE)
 {
   // default constructor
   fAllTrue.ResetAllBits(kTRUE);
@@ -93,7 +95,8 @@ AliFemtoEventReaderAOD::AliFemtoEventReaderAOD(const AliFemtoEventReaderAOD &aRe
   fMagFieldSign(1),
   fisEPVZ(kTRUE),
   fpA2013(kFALSE),
-  fDCAglobalTrack(kFALSE)
+  fDCAglobalTrack(kFALSE),
+  fFlatCent(kFALSE)
 {
   // copy constructor
   fReadMC = aReader.fReadMC;
@@ -159,6 +162,7 @@ AliFemtoEventReaderAOD& AliFemtoEventReaderAOD::operator=(const AliFemtoEventRea
   fEstEventMult = aReader.fEstEventMult;
   fpA2013 = aReader.fpA2013;
   fDCAglobalTrack = aReader.fDCAglobalTrack;
+  fFlatCent= aReader.fFlatCent;
 
   return *this;
 }
@@ -358,6 +362,14 @@ void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent)
     }
   }
 
+  float percent = cent->GetCentralityPercentile("V0M");
+//flatten centrality dist.
+  if(percent < 9){
+    if(fFlatCent){
+      if(RejectEventCentFlat(fEvent->GetMagneticField(),percent)) return;
+    }
+  }
+
   int realnofTracks=0;   // number of track which we use in a analysis
   int tracksPrim=0;
 
@@ -542,7 +554,7 @@ void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent)
                 if (aodtrack->Eta() < 0.8)
                   tNormMult++;
       }
-     }
+    }
 
     CopyAODtoFemtoTrack(aodtrack, trackCopy);
 
@@ -696,7 +708,7 @@ void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent)
     }
     //    }
 
-   tEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis
+    tEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis
     realnofTracks++;//real number of tracks
   }
 
@@ -1442,3 +1454,25 @@ void AliFemtoEventReaderAOD::SetDCAglobalTrack(Bool_t dcagt)
   fDCAglobalTrack = dcagt;
 }
 
+
+bool AliFemtoEventReaderAOD::RejectEventCentFlat(float MagField, float CentPercent)
+{ // to flatten centrality distribution
+  bool RejectEvent = kFALSE;
+  int weightBinSign;
+  TRandom3* fRandomNumber = new TRandom3();  //for 3D, random sign switching
+  fRandomNumber->SetSeed(0);
+
+  if(MagField > 0) weightBinSign = 0;
+  else weightBinSign = 1;
+  float kCentWeight[2][9] = {{.878,.876,.860,.859,.859,.88,.873,.879,.894},
+                             {.828,.793,.776,.772,.775,.796,.788,.804,.839}};
+  int weightBinCent = (int) CentPercent;
+  if(fRandomNumber->Rndm() > kCentWeight[weightBinSign][weightBinCent]) RejectEvent = kTRUE;
+
+  return RejectEvent;
+}
+
+void AliFemtoEventReaderAOD::SetCentralityFlattening(Bool_t dcagt)
+{
+  fFlatCent = dcagt;
+}
index 44fc40d17e631ff70f7221f56dd17cebe3a7ac27..3c4dddb60b7763a7d9b94f11900ac297f4f8bc1f 100644 (file)
@@ -58,6 +58,9 @@ class AliFemtoEventReaderAOD : public AliFemtoEventReader
   void SetpA2013(Bool_t pa2013);
   void SetDCAglobalTrack(Bool_t dcagt);
 
+  bool RejectEventCentFlat(float MagField, float CentPercent);
+  void SetCentralityFlattening(Bool_t flat);
+
  protected:
   virtual void CopyAODtoFemtoEvent(AliFemtoEvent *tEvent);
   virtual void CopyAODtoFemtoTrack( AliAODTrack *tAodTrack,
@@ -98,6 +101,8 @@ class AliFemtoEventReaderAOD : public AliFemtoEventReader
   Bool_t fpA2013; // analysis on pA 2013 data
   Bool_t fDCAglobalTrack; // to get DCA from global tracks instead of TPC-only
 
+  bool fFlatCent;
+
 
 #ifdef __ROOT__
   ClassDef(AliFemtoEventReaderAOD, 11)
@@ -106,5 +111,3 @@ class AliFemtoEventReaderAOD : public AliFemtoEventReader
 };
 
 #endif
-
-
index 9442aea0675ebe7fdf102c3fe272a79e7444da85..08c666b84f9042bc8f3d7f418afda78acd59c4aa 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliAODInputHandler.h"
 #include "AliAODMCParticle.h"
 #include "AliAODTracklets.h"
+#include "AliAnalysisUtils.h"
 
 #include "AliThreePionRadii.h"
 
@@ -769,6 +770,33 @@ void AliThreePionRadii::UserCreateOutputObjects()
   TH3D *fAllMCPionPairs = new TH3D("fAllMCPionPairs","",fMbins,.5,fMbins+.5, 20,0,1, 20,0,0.2);
   if(fMCcase) fOutputList->Add(fAllMCPionPairs);
 
+  TH3D *fMuonContamSmearedNum2 = new TH3D("fMuonContamSmearedNum2","",2,-0.5,1.5, 20,0,1, 40,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamSmearedNum2);
+  TH3D *fMuonContamSmearedDen2 = new TH3D("fMuonContamSmearedDen2","",2,-0.5,1.5, 20,0,1, 40,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamSmearedDen2);
+  TH3D *fMuonContamIdealNum2 = new TH3D("fMuonContamIdealNum2","",2,-0.5,1.5, 20,0,1, 40,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamIdealNum2);
+  TH3D *fMuonContamIdealDen2 = new TH3D("fMuonContamIdealDen2","",2,-0.5,1.5, 20,0,1, 40,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamIdealDen2);
+  //
+  TH3D *fMuonContamSmearedNum3 = new TH3D("fMuonContamSmearedNum3","",2,-0.5,1.5, 2,-0.5,1.5, 20,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamSmearedNum3);
+  TH3D *fMuonContamSmearedDen3 = new TH3D("fMuonContamSmearedDen3","",2,-0.5,1.5, 2,-0.5,1.5, 20,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamSmearedDen3);
+  TH3D *fMuonContamIdealNum3 = new TH3D("fMuonContamIdealNum3","",2,-0.5,1.5, 2,-0.5,1.5, 20,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamIdealNum3);
+  TH3D *fMuonContamIdealDen3 = new TH3D("fMuonContamIdealDen3","",2,-0.5,1.5, 2,-0.5,1.5, 20,0,0.2);
+  if(fMCcase) fOutputList->Add(fMuonContamIdealDen3);
+  //
+  TH1D *fMuonParents = new TH1D("fMuonParents","",500,0.5,500.5);
+  if(fMCcase) fOutputList->Add(fMuonParents);
+  TH1D *fSecondaryMuonParents = new TH1D("fSecondaryMuonParents","",500,0.5,500.5);
+  if(fMCcase) fOutputList->Add(fSecondaryMuonParents);
+  TH3D *fMuonPionDeltaQinv = new TH3D("fMuonPionDeltaQinv","",2,-0.5,1.5, 20,0,1, 100,-0.2,0.2);
+  if(fMCcase) fOutputList->Add(fMuonPionDeltaQinv);
+  TH1D *fPionCandidates = new TH1D("fPionCandidates","",500,0.5,500.5);
+  if(fMCcase) fOutputList->Add(fPionCandidates);
+  //
   TProfile *fAvgMult = new TProfile("fAvgMult","",fMbins,.5,fMbins+.5, 0,1500,"");
   fOutputList->Add(fAvgMult);
   TH2D *fAvgMultHisto2D = new TH2D("fAvgMultHisto2D","",fMbins,.5,fMbins+.5, 1000,0.5,2000.5);
@@ -1041,7 +1069,7 @@ void AliThreePionRadii::UserCreateOutputObjects()
 }
 
 //________________________________________________________________________
-void AliThreePionRadii::Exec(Option_t *) 
+void AliThreePionRadii::UserExec(Option_t *) 
 {
   // Main loop
   // Called for each event
@@ -1125,7 +1153,6 @@ void AliThreePionRadii::Exec(Option_t *)
   Int_t zbin=0;
   Double_t zstep=2*10/Double_t(fZvertexBins), zstart=-10.;
   /////////////////////////////////////////////////
-
   
   Float_t centralityPercentile=0;
   //Float_t cStep=5.0, cStart=0;
@@ -1143,8 +1170,10 @@ void AliThreePionRadii::Exec(Option_t *)
       //cout<<"AOD multiplicity = "<<fAOD->GetNumberOfTracks()<<endl;
     }
     
-
-    
+    AliAnalysisUtils *AnaUtil=new AliAnalysisUtils();
+    if(fAOD->GetRunNumber() >= 195344 && fAOD->GetRunNumber() <= 195873) AnaUtil->SetUseMVPlpSelection(kTRUE);// use Multi-Vertex tool for pPb
+    Bool_t pileUpCase=AnaUtil->IsPileUpEvent(fAOD); 
+    if(pileUpCase) return;
     
     ////////////////////////////////
     // Vertexing
@@ -1401,6 +1430,16 @@ void AliThreePionRadii::Exec(Option_t *)
 
       myTracks++;
       
+      if(fMCcase){// muon mothers
+       AliAODMCParticle *tempMCTrack=(AliAODMCParticle*)mcArray->At(abs(aodtrack->GetLabel()));
+       if(abs(tempMCTrack->GetPdgCode())==13 && tempMCTrack->GetMother()>0){// muons
+         AliAODMCParticle *parent=(AliAODMCParticle*)mcArray->At(tempMCTrack->GetMother());
+         if(parent->IsPhysicalPrimary()){
+           ((TH1D*)fOutputList->FindObject("fMuonParents"))->Fill(abs(parent->GetPdgCode()));
+         }else ((TH1D*)fOutputList->FindObject("fSecondaryMuonParents"))->Fill(abs(parent->GetPdgCode()));
+       }
+       ((TH1D*)fOutputList->FindObject("fPionCandidates"))->Fill(abs(tempMCTrack->GetPdgCode()));
+      }
     }
   }else {// ESD tracks
     cout<<"ESDs not supported currently"<<endl;
@@ -1569,11 +1608,10 @@ void AliThreePionRadii::Exec(Option_t *)
        (fEvt)->fMCtracks[i].fPy = tempMCTrack->Py();
        (fEvt)->fMCtracks[i].fPz = tempMCTrack->Pz();
        (fEvt)->fMCtracks[i].fPtot = sqrt(pow(tempMCTrack->Px(),2)+pow(tempMCTrack->Py(),2)+pow(tempMCTrack->Pz(),2));
-      }        
+      }
     }
   }
-    
-  
+
   
   Float_t qinv12=0, qinv13=0, qinv23=0;
   Float_t qout=0, qside=0, qlong=0;
@@ -1705,7 +1743,7 @@ void AliThreePionRadii::Exec(Option_t *)
     // Start the pairing process
     // P11 pairing
     // 1st Particle
-   
+  
     for (Int_t i=0; i<myTracks; i++) {
          
       Int_t en2=0;
@@ -1883,9 +1921,118 @@ void AliThreePionRadii::Exec(Option_t *)
            
            Charge1[bin1].Charge2[bin2].SC[fillIndex2].MB[fMbin].EDB[fEDbin].TwoPT[en2].fPIDpurityNum->Fill(SCNumber, transK12, qinv12);
            
-           
-
-
+           ///////////////////////
+           // muon contamination
+           if(qinv12 < fQcut[0] && ((fEvt)->fTracks[i].fLabel != (fEvt+en2)->fTracks[j].fLabel)){
+             if(abs(mcParticle1->GetPdgCode())==13 || abs(mcParticle2->GetPdgCode())==13){// muon check
+               Float_t Pparent1[4]={pVect1MC[0],pVect1MC[1],pVect1MC[2],pVect1MC[3]}; 
+               Float_t Pparent2[4]={pVect2MC[0],pVect2MC[1],pVect2MC[2],pVect2MC[3]};
+               Bool_t pionParent1=kFALSE, pionParent2=kFALSE;
+               if(abs(mcParticle1->GetPdgCode())==13) {
+                 AliAODMCParticle *parent1=(AliAODMCParticle*)mcArray->At(mcParticle1->GetMother());
+                 if(abs(parent1->GetPdgCode())==211) {
+                   pionParent1=kTRUE;
+                   Pparent1[1] = parent1->Px(); Pparent1[2] = parent1->Py(); Pparent1[3] = parent1->Pz();
+                   Pparent1[0] = sqrt(pow(Pparent1[1],2)+pow(Pparent1[2],2)+pow(Pparent1[3],2)+pow(fTrueMassPi,2));
+                 }
+               }
+               // 
+               if(abs(mcParticle2->GetPdgCode())==13) {
+                 AliAODMCParticle *parent2=(AliAODMCParticle*)mcArray->At(mcParticle2->GetMother());
+                 if(abs(parent2->GetPdgCode())==211) {
+                   pionParent2=kTRUE;
+                   Pparent2[1] = parent2->Px(); Pparent2[2] = parent2->Py(); Pparent2[3] = parent2->Pz();
+                   Pparent2[0] = sqrt(pow(Pparent2[1],2)+pow(Pparent2[2],2)+pow(Pparent2[3],2)+pow(fTrueMassPi,2));
+                 }
+               }
+               Float_t parentQinv12 = GetQinv(0, Pparent1, Pparent2);
+               Float_t WInput = 1.0;
+               if(parentQinv12 > 0.001 && parentQinv12 < 0.2) WInput = MCWeight(ch1,ch2, 10, 10, parentQinv12);
+               Int_t ChComb=0;
+               if(ch1 != ch2) ChComb=1;
+               if(pionParent1 || pionParent2){
+                 ((TH3D*)fOutputList->FindObject("fMuonContamSmearedNum2"))->Fill(ChComb, transK12, qinv12MC, WInput);
+                 ((TH3D*)fOutputList->FindObject("fMuonContamSmearedDen2"))->Fill(ChComb, transK12, qinv12MC);
+                 ((TH3D*)fOutputList->FindObject("fMuonContamIdealNum2"))->Fill(ChComb, transK12, parentQinv12, WInput);
+                 ((TH3D*)fOutputList->FindObject("fMuonContamIdealDen2"))->Fill(ChComb, transK12, parentQinv12);
+                 ((TH3D*)fOutputList->FindObject("fMuonPionDeltaQinv"))->Fill(ChComb, transK12, qinv12MC-parentQinv12);
+               }
+               ////////////////////////////////////
+               // 3rd particle
+               Int_t en3=0;
+               for (Int_t k=j+1; k<(fEvt+en3)->fNtracks; k++) {
+                 pVect3[0]=(fEvt+en3)->fTracks[k].fEaccepted;
+                 pVect3[1]=(fEvt+en3)->fTracks[k].fP[0];
+                 pVect3[2]=(fEvt+en3)->fTracks[k].fP[1];
+                 pVect3[3]=(fEvt+en3)->fTracks[k].fP[2];
+                 //
+                 qinv13 = GetQinv(0, pVect1, pVect3);
+                 qinv23 = GetQinv(0, pVect2, pVect3);
+                 if(qinv13 > fQcut[0] || qinv23 > fQcut[0]) continue;
+                 
+                 if(qinv13 < fQLowerCut || qinv23 < fQLowerCut) continue;// remove unwanted low-q pairs (also a type of track splitting/merging cut)
+                 if(ch1 == ch3 && !fGeneratorOnly){
+                   if(!AcceptPair(&((fEvt)->fTracks[i]), &((fEvt+en3)->fTracks[k]))) {
+                     continue;
+                   }
+                 }
+                 if(ch2 == ch3 && !fGeneratorOnly){
+                   if(!AcceptPair(&((fEvt+en2)->fTracks[j]), &((fEvt+en3)->fTracks[k]))) {
+                     continue;
+                   }
+                 }
+                 
+                 if((fEvt+en3)->fTracks[k].fLabel < (fEvt+en3)->fMCarraySize){
+                   AliAODMCParticle *mcParticle3 = (AliAODMCParticle*)mcArray->At(abs((fEvt+en3)->fTracks[k].fLabel));
+                   
+                   ch3 = Int_t(((fEvt+en3)->fTracks[k].fCharge + 1)/2.);
+                   pVect3MC[0]=sqrt(pow((fEvt+en3)->fMCtracks[abs((fEvt+en3)->fTracks[k].fLabel)].fPtot,2)+pow(fTrueMassPi,2)); 
+                   pVect3MC[1]=(fEvt+en3)->fMCtracks[abs((fEvt+en3)->fTracks[k].fLabel)].fPx;
+                   pVect3MC[2]=(fEvt+en3)->fMCtracks[abs((fEvt+en3)->fTracks[k].fLabel)].fPy;
+                   pVect3MC[3]=(fEvt+en3)->fMCtracks[abs((fEvt+en3)->fTracks[k].fLabel)].fPz;
+                   qinv13MC = GetQinv(0, pVect1MC, pVect3MC);
+                   qinv23MC = GetQinv(0, pVect2MC, pVect3MC);
+                   
+                   q3MC = sqrt(pow(qinv12MC,2)+pow(qinv13MC,2)+pow(qinv23MC,2));
+                   transK3 = sqrt( pow(pVect1[1]+pVect2[1]+pVect3[1],2) + pow(pVect1[2]+pVect2[2]+pVect3[2],2))/3.;
+                   Int_t K3index=0;
+                   if(transK3>0.3) K3index=1;
+
+                   Float_t Pparent3[4]={pVect3MC[0],pVect3MC[1],pVect3MC[2],pVect3MC[3]}; 
+                   Bool_t pionParent3=kFALSE;
+                   if(abs(mcParticle3->GetPdgCode())==13){// muon check
+                     AliAODMCParticle *parent=(AliAODMCParticle*)mcArray->At(mcParticle3->GetMother());
+                     if(abs(parent->GetPdgCode())==211) {
+                       pionParent3=kTRUE;
+                       Pparent3[1] = parent->Px(); Pparent3[2] = parent->Py(); Pparent3[3] = parent->Pz();
+                       Pparent3[0] = sqrt(pow(Pparent3[1],2)+pow(Pparent3[2],2)+pow(Pparent3[3],2)+pow(fTrueMassPi,2));
+                     }
+                   }
+                   Float_t parentQinv13 = GetQinv(0, Pparent1, Pparent3);
+                   Float_t parentQinv23 = GetQinv(0, Pparent2, Pparent3);
+                   if(parentQinv12 < 0.001 || parentQinv12 > 0.2) continue;
+                   if(parentQinv13 < 0.001 || parentQinv13 > 0.2) continue;
+                   if(parentQinv23 < 0.001 || parentQinv23 > 0.2) continue;
+                   if(!pionParent1 && !pionParent2 && !pionParent3) continue;// want at least one pion-->muon
+                   Float_t parentQ3 = sqrt(pow(parentQinv12,2) + pow(parentQinv13,2) + pow(parentQinv23,2));
+                   Int_t ChCombtriplet=0;
+                   if(ch1!=ch2 || ch1!=ch3 || ch2!=ch3) ChCombtriplet=1;
+                   Float_t WInput3=1.0;
+                   if(ChCombtriplet==0) WInput3 = MCWeight3D(kTRUE, 1, 10, parentQinv12, parentQinv13, parentQinv23);
+                   else{
+                     if(ch1==ch2) WInput3 = MCWeight3D(kFALSE, 1, 10, parentQinv12, parentQinv13, parentQinv23);
+                     else if(ch1==ch3) WInput3 = MCWeight3D(kFALSE, 1, 10, parentQinv13, parentQinv12, parentQinv23);
+                     else WInput3 = MCWeight3D(kFALSE, 1, 10, parentQinv23, parentQinv12, parentQinv13);
+                   }
+                   ((TH3D*)fOutputList->FindObject("fMuonContamSmearedNum3"))->Fill(ChCombtriplet, K3index, q3MC, WInput3);
+                   ((TH3D*)fOutputList->FindObject("fMuonContamSmearedDen3"))->Fill(ChCombtriplet, K3index, q3MC);
+                   ((TH3D*)fOutputList->FindObject("fMuonContamIdealNum3"))->Fill(ChCombtriplet, K3index, parentQ3, WInput3);
+                   ((TH3D*)fOutputList->FindObject("fMuonContamIdealDen3"))->Fill(ChCombtriplet, K3index, parentQ3);
+                   
+                 }//label check of 3
+               }// 3rd particle
+             }// muon code check of 1 and 2
+           }// qinv12 cut
          }// label check 2
        }// MC case
        
@@ -2001,7 +2148,7 @@ void AliThreePionRadii::Exec(Option_t *)
       }// j particle
     }// i particle
     
-
+    
     
     //////////////////////////////////////////////
     // P12 pairing
@@ -2055,8 +2202,7 @@ void AliThreePionRadii::Exec(Option_t *)
                Charge1[bin1].Charge2[bin2].SC[fillIndex2].MB[fMbin].EDB[fEDbin].TwoPT[1].fSmeared->Fill(denIndex, qinv12);
              }
            }
-         
-           
+          
            /////////////////////////////////////////////////////
            if(qinv12 <= fQcut[qCutBin]) {// 3-particle MRC
              
@@ -2090,7 +2236,7 @@ void AliThreePionRadii::Exec(Option_t *)
                  q3MC = sqrt(pow(qinv12MC,2)+pow(qinv13MC,2)+pow(qinv23MC,2));
                  transK3 = sqrt( pow(pVect1[1]+pVect2[1]+pVect3[1],2) + pow(pVect1[2]+pVect2[2]+pVect3[2],2))/3.;
                  
-                 if(qinv12 < fQLowerCut) continue;// remove unwanted low-q pairs (also a type of track splitting/merging cut)
+                 if(qinv12 < fQLowerCut) continue;
                  if(qinv13 < fQLowerCut) continue;
                  if(qinv23 < fQLowerCut) continue;
                  if(ch1 == ch2){
index 14193678be71a854f70ef362e5cd4b86d6ecdff3..f4da90467e0ae6f763f121317ba294c93828c5ea 100644 (file)
@@ -42,7 +42,7 @@ class AliThreePionRadii : public AliAnalysisTaskSE {
   
 
   virtual void   UserCreateOutputObjects();
-  virtual void   Exec(Option_t *option);
+  virtual void   UserExec(Option_t *option);
   virtual void   Terminate(Option_t *);
 
   enum {
index 9997fda348a4f05fa75058b6b7495f1d825037e3..6f847980f5c6183a2608663ca037422f5d1581df 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-//\r
-//  This class is used to perform femtoscopic analysis on K0s particles, \r
-//  which are reconstructed using the AliAODv0 class.  \r
-//\r
-//  authors: Matthew Steinpreis (matthew.steinpreis@cern.ch)\r
-//   \r
-//  Change log:\r
-//     - TOF mismatch function calls changed (4/18/13)\r
-//     - added minimum decay length cut (rarely used though) (3/28/13)\r
-//     - K0 multiplicity histogram now filled with "unskippedCount" instead\r
-//       of k0Count (which included skipped k0s with shared daughters) \r
-//       (3/25/13)\r
-//     - added hists for 3D mom. in LF and PRF (3/28/13) \r
-//     - changed calling of PIDResponse (should be same actions) (3/28/13)\r
-//     - keep "side" K0s for mass plot (4/18)\r
-//             - tweaked loading and skipping appropriately\r
-//             - use merit test to skip sides (against good and side K0s)\r
-//             - a good K0 cant be skipped by a side\r
-//     - moved TPC propagation (via Hans' method) up to v0 level, which now\r
-//       uses an AliAODTrack(AliVTrack) instead of AliESDtrack (5/31/13)\r
-//     - added primary vertex subtraction in TPC propagation   (5/31/13)\r
-//     - removed all instances of AliESDtrack usage    (5/31/13)\r
-//     - removed old separation method/histograms      (5/31/13)\r
-//     - tidied up LCMS boost                                                  (6/10/13)\r
-//     - added new boosting prescription, get q out-side-long for LCMS and PRF (6/24/13)\r
-//             - added histograms and values for LCMS momenta (for simulation)\r
-//     - added random particle order switch in correlations (9/09/13)\r
-//     - added more bins for 3D OSL analysis (9/19/13)\r
-//     - added merit cut choice, pass as argument (10/16/13)\r
-//             - 1-mass, 2-v0dca, 3-dddca, 4-combination (used to be v0dca)\r
-//     - added passable argument for two-track minimum separation (10/16/13)\r
-//     - added boolean to turn off field-sign dependence for train (10/30/13)\r
-//     - changed destructors to minimize lost memory (11/27/13)\r
-//     - added Case3D to switch off all 3D objects (11/27/13)\r
-////////////////////////////////////////////////////////////////////////////////\r
-\r
-\r
\r
-#include <iostream>\r
-#include <math.h>\r
-#include "TMath.h"\r
-#include "TChain.h"\r
-#include "TFile.h"\r
-#include "TKey.h"\r
-#include "TObject.h"\r
-#include "TObjString.h"\r
-#include "TList.h"\r
-#include "TTree.h"\r
-#include "TH1F.h"\r
-#include "TH1D.h"\r
-#include "TH2D.h"\r
-#include "TH3D.h"\r
-#include "TProfile.h"\r
-#include "TCanvas.h"\r
-#include "TRandom3.h"\r
-\r
-#include "AliAnalysisTask.h"\r
-#include "AliAnalysisManager.h"\r
-\r
-#include "AliAODEvent.h"\r
-#include "AliAODInputHandler.h"\r
-#include "AliAODMCParticle.h"\r
-#include "AliAODv0.h"\r
-#include "AliAODRecoDecay.h"\r
-#include "AliCentrality.h"\r
-\r
-#include "AliFemtoK0Analysis.h"\r
-\r
-#define PI 3.1415927\r
-\r
-\r
-// Author: Matt Steinpreis, adapted from Dhevan Gangadharan\r
-\r
-ClassImp(AliFemtoK0Analysis)\r
-\r
-//________________________________________________________________________\r
-AliFemtoK0Analysis::AliFemtoK0Analysis():\r
-AliAnalysisTaskSE(),\r
-  fSignDep(kFALSE),\r
-  fFieldPos(kTRUE),\r
-  fOnlineCase(kTRUE),\r
-  fMeritCase(kTRUE),\r
-  fCase3D(kFALSE),\r
-  fMinDecayLength(0.0),\r
-  fMeritCutChoice(0),\r
-  fMinSep(0.0),\r
-  fFlatCent(kFALSE),\r
-  fEventCount(0),\r
-  fEC(0x0),\r
-  fEvt(0X0),\r
-  fRandomNumber(0x0),\r
-  fName(0x0),\r
-  fAOD(0x0),\r
-  fOutputList(0x0),\r
-  fPidAOD(0x0)\r
-{\r
-}\r
-//________________________________________________________________________\r
-AliFemtoK0Analysis::AliFemtoK0Analysis(const char *name, bool SignDep, bool FieldPositive, bool OnlineCase, bool MeritCase, bool Case3D, float MinDL, int MeritCutChoice, float MinSep, bool FlatCent) \r
-: AliAnalysisTaskSE(name),\r
-  fSignDep(SignDep),\r
-  fFieldPos(FieldPositive),\r
-  fOnlineCase(OnlineCase),\r
-  fMeritCase(MeritCase),\r
-  fCase3D(Case3D),\r
-  fMinDecayLength(MinDL),\r
-  fMeritCutChoice(MeritCutChoice),\r
-  fMinSep(MinSep),\r
-  fFlatCent(FlatCent),\r
-  fEventCount(0),\r
-  fEC(0x0),\r
-  fEvt(0X0),\r
-  fRandomNumber(0x0),\r
-  fName(name),\r
-  fAOD(0x0),\r
-  fOutputList(0x0),\r
-  fPidAOD(0x0)\r
-{\r
-  //main constructor\r
-  fSignDep             = SignDep;\r
-  fFieldPos    = FieldPositive;\r
-  fOnlineCase  = OnlineCase;\r
-  fMeritCase   = MeritCase;\r
-  fCase3D              = Case3D;\r
-  fMinDecayLength = MinDL;\r
-  fMeritCutChoice = MeritCutChoice;\r
-  fMinSep              = MinSep;\r
-  fFlatCent            = FlatCent;\r
-\r
-  // Define output slots here \r
-  // Output slot #1\r
-  DefineOutput(1, TList::Class());\r
-  \r
-}\r
-//________________________________________________________________________\r
-AliFemtoK0Analysis::AliFemtoK0Analysis(const AliFemtoK0Analysis &obj)\r
-: AliAnalysisTaskSE(obj.fName),\r
-  fSignDep(obj.fSignDep),\r
-  fFieldPos(obj.fFieldPos),\r
-  fOnlineCase(obj.fOnlineCase),\r
-  fMeritCase(obj.fMeritCase),\r
-  fCase3D(obj.fCase3D),\r
-  fMinDecayLength(obj.fMinDecayLength),\r
-  fMeritCutChoice(obj.fMeritCutChoice),\r
-  fMinSep(obj.fMinSep),\r
-  fFlatCent(obj.fFlatCent),\r
-  fEventCount(obj.fEventCount),\r
-  fEC(obj.fEC),\r
-  fEvt(obj.fEvt),\r
-  fRandomNumber(obj.fRandomNumber),\r
-  fName(obj.fName),\r
-  fAOD(obj.fAOD),\r
-  fOutputList(obj.fOutputList),\r
-  fPidAOD(obj.fPidAOD)\r
-{\r
-}\r
-//________________________________________________________________________\r
-AliFemtoK0Analysis &AliFemtoK0Analysis::operator=(const AliFemtoK0Analysis &obj)\r
-{\r
- //Assignment operator\r
- if (this == &obj) return *this;\r
\r
- fSignDep   = obj.fSignDep;\r
- fFieldPos     = obj.fFieldPos;\r
- fOnlineCase   = obj.fOnlineCase;\r
- fMeritCase    = obj.fMeritCase;\r
- fCase3D               = obj.fCase3D;\r
- fMinDecayLength= obj.fMinDecayLength;\r
- fMeritCutChoice= obj.fMeritCutChoice;\r
- fMinSep               = obj.fMinSep;\r
- fFlatCent             = obj.fFlatCent;\r
- fEventCount   = obj.fEventCount;\r
- fEC           = obj.fEC;\r
- fEvt          = obj.fEvt;\r
- fRandomNumber         = obj.fRandomNumber;\r
- fName                 = obj.fName;\r
- fAOD          = obj.fAOD;\r
- fOutputList   = obj.fOutputList;\r
- fPidAOD       = obj.fPidAOD;\r
-\r
- return (*this);\r
-}\r
-//________________________________________________________________________\r
-AliFemtoK0Analysis::~AliFemtoK0Analysis()\r
-{\r
-  // Destructor\r
-  for(unsigned short i=0; i<kZVertexBins; i++)\r
-  {\r
-    for(unsigned short j=0; j<kCentBins; j++)\r
-    {\r
-      fEC[i][j]->~AliFemtoK0EventCollection();\r
-      fEC[i][j] = NULL;\r
-    }\r
-    delete[] fEC[i]; fEC[i] = NULL;\r
-  }\r
-  delete[] fEC; fEC = NULL;\r
-\r
-  if(fEC){ delete fEC; fEC = NULL;}\r
-  if(fRandomNumber){ delete fRandomNumber; fRandomNumber = NULL;}\r
-  if(fAOD){ delete fAOD; fAOD = NULL;}\r
-  if(fOutputList){ delete fOutputList; fOutputList = NULL;}\r
-  if(fPidAOD){ delete fPidAOD; fPidAOD = NULL;}\r
-}\r
-//________________________________________________________________________\r
-void AliFemtoK0Analysis::MyInit()\r
-{\r
-\r
-  // One can set global variables here\r
-  fEventCount = 0;  \r
-\r
-  fEC = new AliFemtoK0EventCollection **[kZVertexBins];\r
-  for(unsigned short i=0; i<kZVertexBins; i++)\r
-  {\r
-    fEC[i] = new AliFemtoK0EventCollection *[kCentBins];\r
-    \r
-    for(unsigned short j=0; j<kCentBins; j++)\r
-    {\r
-      fEC[i][j] = new AliFemtoK0EventCollection(kEventsToMix+1, kMultLimit);\r
-    }\r
-  }\r
-\r
-  AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
-  fPidAOD = aodH->GetPIDResponse();\r
-\r
-  fRandomNumber = new TRandom3();  //for 3D, random sign switching\r
-  fRandomNumber->SetSeed(0);\r
-\r
-}\r
-//________________________________________________________________________\r
-void AliFemtoK0Analysis::UserCreateOutputObjects()\r
-{\r
-  // Create histograms\r
-  // Called once\r
-  \r
-  MyInit();// Initialize my settings\r
-\r
-  fOutputList = new TList();\r
-  fOutputList->SetOwner();\r
-\r
-  TH1F *fHistCent = new TH1F("fHistCent","",100,0,100);\r
-  fOutputList->Add(fHistCent);\r
-  TH1F *fHistCentFlat = new TH1F("fHistCentFlat","",100,0,100);\r
-  fOutputList->Add(fHistCentFlat);\r
-  TH1F *fHistCentUsed = new TH1F("fHistCentUsed","",100,0,100);\r
-  fOutputList->Add(fHistCentUsed);\r
\r
-  //pion parameters\r
-  TH1F* fHistDCAPiPlus = new TH1F("fHistDCAPiPlus","",100,0,10);\r
-  fOutputList->Add(fHistDCAPiPlus);\r
-  TH1F* fHistDCAPiMinus = new TH1F("fHistDCAPiMinus","",100,0,10);\r
-  fOutputList->Add(fHistDCAPiMinus);\r
-  TH1F* fHistDCADaughters = new TH1F("fHistDCADaughters", "DCA of pions to each other", 50, 0., 0.5);\r
-  fOutputList->Add(fHistDCADaughters);\r
-  TH2F* fHistK0PiPlusPt = new TH2F("fHistK0PiPlusPt", "", kCentBins, .5,kCentBins+.5, 40,0.,4.);\r
-  fOutputList->Add(fHistK0PiPlusPt);\r
-  TH2F* fHistK0PiMinusPt = new TH2F("fHistK0PiMinusPt", "", kCentBins, .5,kCentBins+.5, 40,0.,4.);\r
-  fOutputList->Add(fHistK0PiMinusPt);\r
-  TH1F* fHistDaughterPhi = new TH1F("fHistDaughterPhi","",180,-PI,PI);\r
-  fOutputList->Add(fHistDaughterPhi);\r
-\r
-  //K0 parameters\r
-  TH1F* fHistMultK0 = new TH1F("fHistMultK0", "K0 multiplicity", 51, -0.5, 51-0.5);\r
-  fOutputList->Add(fHistMultK0);\r
-  TH2F* fHistPtK0 = new TH2F("fHistPtK0", "K0 pt distribution",kCentBins,.5,kCentBins+.5, 100, 0., 10.);\r
-  fOutputList->Add(fHistPtK0);\r
-  TH1F* fHistDecayLengthK0 = new TH1F("fHistDecayLengthK0", "K0 decay length", 100, 0., 100.);\r
-  fOutputList->Add(fHistDecayLengthK0);\r
-  TH1F* fHistDCAK0 = new TH1F("fHistDCAK0", "DCA of K0 to primary vertex", 40, 0., 0.4);\r
-  fOutputList->Add(fHistDCAK0);\r
-  TH2F* fHistKtK0 = new TH2F("fHistKtK0", "Kt distribution of K0 pairs", kCentBins, .5, kCentBins+.5, 300, 0., 3.);\r
-  fOutputList->Add(fHistKtK0);\r
-\r
-  TH1F* fHistPx = new TH1F("fHistPx","",200,0,2);\r
-  TH1F* fHistPy = new TH1F("fHistPy","",200,0,2);\r
-  TH1F* fHistPz = new TH1F("fHistPz","",200,0,2);\r
-  TH1F* fHistPxCM = new TH1F("fHistPxCM","",200,0,2);\r
-  TH1F* fHistPyCM = new TH1F("fHistPyCM","",200,0,2);\r
-  TH1F* fHistPzCM = new TH1F("fHistPzCM","",200,0,2);\r
-  TH1F* fHistKsCM = new TH1F("fHistKsCM","",200,0,2);\r
-  fOutputList->Add(fHistPx);\r
-  fOutputList->Add(fHistPy);\r
-  fOutputList->Add(fHistPz);\r
-  fOutputList->Add(fHistPxCM);\r
-  fOutputList->Add(fHistPyCM);\r
-  fOutputList->Add(fHistPzCM);\r
-  fOutputList->Add(fHistKsCM);\r
-\r
-  TH1F* fHistPOutLCMS = new TH1F("fHistPOutLCMS","",200,0,2);\r
-  TH1F* fHistPSideLCMS = new TH1F("fHistPSideLCMS","",200,0,2);\r
-  TH1F* fHistPLongLCMS = new TH1F("fHistPLongLCMS","",200,0,2);\r
-  fOutputList->Add(fHistPOutLCMS);\r
-  fOutputList->Add(fHistPSideLCMS);\r
-  fOutputList->Add(fHistPLongLCMS);\r
-\r
-  //pair gamma (LCMS to PRF, OSL)\r
-  TH2F* fHistGamma = new TH2F("fHistGamma","Gamma from LCMS to PRF",500,1,5,100,0,1);\r
-  fOutputList->Add(fHistGamma);\r
-\r
-  //invariant mass distributions\r
-  TH3F* fHistMass = new TH3F("fHistMass","",kCentBins,.5,kCentBins+.5,50,0.,5.,400,.3,.7);\r
-  fOutputList->Add(fHistMass);\r
-  //TH3F* fHistMassPtCFK0 = new TH3F("fHistMassPtCFK0","",kCentBins,.5,kCentBins+.5,50,0.,5.,200,.4,.6);\r
-  //fOutputList->Add(fHistMassPtCFK0);\r
-  //TH3F* fHistMassPtCFBkgK0 = new TH3F("fHistMassPtCFBkgK0","",kCentBins,.5,kCentBins+.5,50,0.,5.,200,.4,.6);\r
-  //fOutputList->Add(fHistMassPtCFBkgK0);\r
-  //TH3F* fHistMassQKt = new TH3F("fHistMassQKt","",100,0,1,200,0,2,200,.4,.6);\r
-  //fOutputList->Add(fHistMassQKt);\r
-  //TH3F* fHistMassKtK0 = new TH3F("fHistMassKtK0","",kCentBins,.5,kCentBins+.5,300,0.,3.,200,.4,.6);\r
-  //fOutputList->Add(fHistMassKtK0);\r
-  //TH3F* fHistMassKtBkgK0 = new TH3F("fHistMassKtBkgK0","",kCentBins,.5,kCentBins+.5,300,0.,3.,200,.4,.6);\r
-  //fOutputList->Add(fHistMassKtBkgK0);\r
-\r
-  //separation studies\r
-  TH1F* fHistSepNumPos = new TH1F("fHistSepNumPos","",200,0,20);\r
-  fOutputList->Add(fHistSepNumPos);\r
-  TH1F* fHistSepDenPos = new TH1F("fHistSepDenPos","",200,0,20);\r
-  fOutputList->Add(fHistSepDenPos);\r
-  TH1F* fHistSepNumNeg = new TH1F("fHistSepNumNeg","",200,0,20);\r
-  fOutputList->Add(fHistSepNumNeg);\r
-  TH1F* fHistSepDenNeg = new TH1F("fHistSepDenNeg","",200,0,20);\r
-  fOutputList->Add(fHistSepDenNeg);\r
-  \r
-  TH2F* fHistSepNumPos2 = new TH2F("fHistSepNumPos2","",100,0,20,100,0,20);\r
-  TH2F* fHistSepDenPos2 = new TH2F("fHistSepDenPos2","",100,0,20,100,0,20);\r
-  TH2F* fHistSepNumNeg2 = new TH2F("fHistSepNumNeg2","",100,0,20,100,0,20);\r
-  TH2F* fHistSepDenNeg2 = new TH2F("fHistSepDenNeg2","",100,0,20,100,0,20);\r
-  fOutputList->Add(fHistSepNumPos2);\r
-  fOutputList->Add(fHistSepDenPos2);\r
-  fOutputList->Add(fHistSepNumNeg2);\r
-  fOutputList->Add(fHistSepDenNeg2);\r
-\r
-\r
-  TH2F* fHistSepDPC = new TH2F("fHistSepDPC","",200,-1,1,50,0,10);\r
-  TH2F* fHistSepDPCBkg = new TH2F("fHistSepDPCBkg","",200,-1,1,50,0,10);\r
-  fOutputList->Add(fHistSepDPC);\r
-  fOutputList->Add(fHistSepDPCBkg);  \r
-\r
-/////////Signal Distributions///////////////////\r
-\r
-  //1D Q invariant\r
-  TH3F* fHistQinvSignal = new TH3F("fHistQinvSignal","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  fOutputList->Add(fHistQinvSignal);\r
-  TH3F* fHistQinvBkg = new TH3F("fHistQinvBkg","Mixed Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1.);\r
-  fOutputList->Add(fHistQinvBkg);\r
-\r
-  //mass bins within peak\r
-  //TH3F* fHistCLCLSignal = new TH3F("fHistCLCLSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistCLCLBkg = new TH3F("fHistCLCLBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistCLCRSignal = new TH3F("fHistCLCRSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistCLCRBkg = new TH3F("fHistCLCRBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistCRCRSignal = new TH3F("fHistCRCRSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistCRCRBkg = new TH3F("fHistCRCRBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //fOutputList->Add(fHistCLCLSignal);\r
-  //fOutputList->Add(fHistCLCLBkg);\r
-  //fOutputList->Add(fHistCLCRSignal);\r
-  //fOutputList->Add(fHistCLCRBkg);\r
-  //fOutputList->Add(fHistCRCRSignal);\r
-  //fOutputList->Add(fHistCRCRBkg);\r
-  \r
-  //3D out-side-long\r
-  TH3F *fHist3DOSLSignal[10][4];\r
-  TH3F *fHist3DOSLBkg[10][4];\r
-  \r
-  if(fCase3D){\r
-   for(int i3D=0;i3D<10;i3D++){\r
-    for(int j3D=0;j3D<4;j3D++){\r
-     TString *histname = new TString("fHist3DOSL");\r
-     *histname += i3D;\r
-     *histname += j3D;\r
-     histname->Append("Signal");\r
-     fHist3DOSLSignal[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-     fOutputList->Add(fHist3DOSLSignal[i3D][j3D]);\r
-     histname->Replace(12,6,"Bkg");\r
-     fHist3DOSLBkg[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-     fOutputList->Add(fHist3DOSLBkg[i3D][j3D]);\r
-    }\r
-   }\r
-  }\r
-\r
-  //3D Spherical Harmonics\r
-  //TH3F* fHistSHCentLowKt = new TH3F("fHistSHCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHCentHighKt = new TH3F("fHistSHCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHSemiCentLowKt = new TH3F("fHistSHSemiCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHSemiCentHighKt = new TH3F("fHistSHSemiCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHCentLowKtBkg = new TH3F("fHistSHCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHCentHighKtBkg = new TH3F("fHistSHCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHSemiCentLowKtBkg = new TH3F("fHistSHSemiCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //TH3F* fHistSHSemiCentHighKtBkg = new TH3F("fHistSHSemiCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  //fOutputList->Add(fHistSHCentLowKt);\r
-  //fOutputList->Add(fHistSHCentHighKt);\r
-  //fOutputList->Add(fHistSHSemiCentLowKt);\r
-  //fOutputList->Add(fHistSHSemiCentHighKt);\r
-  //fOutputList->Add(fHistSHCentLowKtBkg);\r
-  //fOutputList->Add(fHistSHCentHighKtBkg);\r
-  //fOutputList->Add(fHistSHSemiCentLowKtBkg);\r
-  //fOutputList->Add(fHistSHSemiCentHighKtBkg);\r
-\r
-  //side-side\r
-  //TH3F* fHistLeftLeftSignal = new TH3F("fHistLeftLeftSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistLeftRightSignal = new TH3F("fHistLeftRightSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistRightRightSignal = new TH3F("fHistRightRightSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistLeftLeftBkg = new TH3F("fHistLeftLeftBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistLeftRightBkg = new TH3F("fHistLeftRightBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //TH3F* fHistRightRightBkg = new TH3F("fHistRightRightBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //fOutputList->Add(fHistLeftLeftSignal);\r
-  //fOutputList->Add(fHistLeftRightSignal);\r
-  //fOutputList->Add(fHistRightRightSignal);\r
-  //fOutputList->Add(fHistLeftLeftBkg);\r
-  //fOutputList->Add(fHistLeftRightBkg);\r
-  //fOutputList->Add(fHistRightRightBkg);\r
-\r
-  //TH3F* fHistSplitK0Sides = new TH3F("fHistSplitK0Sides","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //fOutputList->Add(fHistSplitK0Sides);\r
-  //TH3F* fHistSplitK0Centers = new TH3F("fHistSplitK0Centers","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //fOutputList->Add(fHistSplitK0Centers);\r
-  //TH3F* fHistQinvSignalNoSplit = new TH3F("fHistQinvSignalNoSplit","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
-  //fOutputList->Add(fHistQinvSignalNoSplit);\r
-\r
-  PostData(1, fOutputList);\r
-\r
-}\r
-\r
-//________________________________________________________________________\r
-void AliFemtoK0Analysis::Exec(Option_t *) \r
-{\r
-  // Main loop\r
-  // Called for each event\r
-  //cout<<"===========  Event # "<<fEventCount+1<<"  ==========="<<endl;\r
-  fEventCount++;\r
-  fAOD = dynamic_cast<AliAODEvent*> (InputEvent());\r
-  if (!fAOD) {Printf("ERROR: fAOD not available"); return;}\r
-\r
-  Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral));\r
-  bool isCentral = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kCentral);\r
-  //Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);\r
-  if(!isSelected) {\r
-   //cout << "Failed trigger selection." << endl; \r
-   return;\r
-  }\r
-  \r
-  ///////////////////////////////////////////////////////////\r
-\r
-  unsigned int statusPos=0;\r
-  unsigned int statusNeg=0;\r
-\r
-  float bField=0;\r
-  bField = fAOD->GetMagneticField();\r
-  if(bField == 0) return;\r
-  if(fSignDep){\r
-   if(fFieldPos && bField < 0) return;\r
-   if(!fFieldPos && bField > 0) return;\r
-  }\r
-\r
-  \r
-  int zBin=0;\r
-  double zStep=2*10/double(kZVertexBins), zstart=-10.;\r
-\r
-  /////////////////////////////////////////////////\r
-\r
-\r
-  //Centrality selection\r
-\r
-  AliCentrality *centrality = fAOD->GetCentrality();\r
-  float percent = centrality->GetCentralityPercentile("V0M");\r
-  int centBin=0;\r
-  //Printf("Centrality percent = %f", percent);\r
-  \r
-  AliAODVZERO *aodV0 = fAOD->GetVZEROData();\r
-  float multV0A=aodV0->GetMTotV0A();\r
-  float multV0C=aodV0->GetMTotV0C();\r
-\r
-  if(percent < 0) {\r
-   //Printf("No centrality info"); \r
-   return;\r
-  }\r
-  if(percent < 0.1 && (multV0A + multV0C < 19500)){\r
-   //Printf("No centrality info"); \r
-   return;\r
-  }\r
-  else if(percent <= 5)   centBin=15;\r
-  else if(percent <= 10)  centBin=14;\r
-  else if(percent <= 15)  centBin=13;\r
-  else if(percent <= 20)  centBin=12;\r
-  else if(percent <= 25)  centBin=11;\r
-  else if(percent <= 30)  centBin=10;\r
-  else if(percent <= 35)  centBin=9;\r
-  else if(percent <= 40)  centBin=8;\r
-  else if(percent <= 45)  centBin=7;\r
-  else if(percent <= 50)  centBin=6;\r
-  else if(percent <= 55)  centBin=5;\r
-  else if(percent <= 60)  centBin=4;\r
-  else if(percent <= 65)  centBin=3;\r
-  else if(percent <= 70)  centBin=2;\r
-  else if(percent <= 75)  centBin=1;\r
-  else if(percent <= 80)  centBin=0;\r
-  else {\r
-   //Printf("Skipping Peripheral Event"); \r
-   return;\r
-  }\r
-  if(percent > 10 && isCentral) return;\r
-  ((TH1F*)fOutputList->FindObject("fHistCent"))->Fill(percent);\r
-  \r
-  //flatten centrality dist.\r
-  if(percent < 9){ \r
-   if(fFlatCent){\r
-    if(RejectEventCentFlat(bField,percent)) return; \r
-   }\r
-  }\r
-  ((TH1F*)fOutputList->FindObject("fHistCentFlat"))->Fill(percent);\r
-  \r
-  //Vertexing\r
-  AliAODVertex *primaryVertex;\r
-  double vertex[3]={0};\r
-  primaryVertex = fAOD->GetPrimaryVertex();\r
-  vertex[0]=primaryVertex->GetX(); \r
-  vertex[1]=primaryVertex->GetY(); \r
-  vertex[2]=primaryVertex->GetZ();\r
-  if(vertex[0]<10e-5 && vertex[1]<10e-5 &&  vertex[2]<10e-5) return;\r
-  if(fabs(vertex[2]) > 10) return; // Z-vertex Cut\r
-\r
-  for(int i=0; i<kZVertexBins; i++)\r
-  {\r
-    if((vertex[2] > zstart+i*zStep) && (vertex[2] < zstart+(i+1)*zStep))\r
-    {\r
-      zBin=i;\r
-      break;\r
-    }\r
-  }\r
-\r
-////////////////////////////////////////////////////////////////\r
-//Cut Values and constants\r
-\r
-  //const bool kMCCase = kFALSE;                     //switch for MC analysis\r
-  const int kMaxNumK0 = 300;                       //maximum number of K0s, array size\r
-  const float kMinDCAPrimaryPion = 0.4;            //minimum dca of pions to primary\r
-  const float kMaxDCADaughtersK0 = 0.3;            //maximum dca of pions to each other - 3D\r
-  const float kMaxDCAK0 = 0.3;                     //maximum dca of K0 to primary\r
-  const float kMaxDLK0 = 30.0;                     //maximum decay length of K0\r
-  const float kMinDLK0 = fMinDecayLength;         //minimum decay length of K0\r
-  const float kEtaCut = 0.8;                       //maximum |pseudorapidity|\r
-  const float kMinCosAngle = 0.99;                 //minimum cosine of K0 pointing angle     \r
-  \r
-  const float kMinSeparation = fMinSep;                //minimum daughter (pair) separation\r
-                 \r
-  const float kTOFLow = 0.8;                       //boundary for TOF usage\r
-  const float kMaxTOFSigmaPion = 3.0;              //TOF # of sigmas\r
-  const float kMaxTPCSigmaPion = 3.0;              //TPC # of sigmas\r
-\r
-  //const float kMassPion = .13957;\r
-  const float kMassK0Short = .497614;       //true PDG masses\r
-\r
-////////////////////////////////////////////////////////////////  \r
-  //v0 tester\r
-////////////////////////////////////////////////////////////////\r
-  int v0Count = 0;     //number of v0s (entries in array)\r
-  int k0Count = 0;     //number of good K0s\r
-\r
-  AliFemtoK0Particle *tempK0 = new AliFemtoK0Particle[kMultLimit];\r
-\r
-  //for daughter sharing studies\r
-  //int idArray[100] = {0};\r
-  //int idCount = 0;\r
-\r
-  //for MC\r
-  //TClonesArray *mcArray = 0x0;\r
-  //if(kMCCase){\r
-  //mcArray = (TClonesArray*)fAOD->FindListObject(AliAODMCParticle::StdBranchName());\r
-  //if(!mcArray){cout<<"No MC particle branch found"<<endl;return;}}\r
-\r
-  for(int i = 0; i < fAOD->GetNumberOfV0s(); i++)\r
-  {\r
-    bool goodK0 = kFALSE;\r
-    bool goodPiPlus = kFALSE;\r
-    bool goodPiMinus = kFALSE;\r
-    \r
-    //load v0 track\r
-    AliAODv0* v0 = fAOD->GetV0(i);\r
-    if(!v0) continue;\r
-    if(fOnlineCase){\r
-     if(!(v0->GetOnFlyStatus())) continue;\r
-    } //for online\r
-    else{\r
-     if((v0->GetOnFlyStatus())) continue; //for offline\r
-    }\r
\r
-    //for on-the-fly ordering\r
-    AliAODTrack* tempTrack = (AliAODTrack*)v0->GetDaughter(0);\r
-    short int pos0or1;\r
-    short int neg0or1;\r
-    bool orderswitch = kFALSE;\r
-    if(tempTrack->Charge() > 0) {pos0or1 = 0; neg0or1 = 1;}\r
-    else {pos0or1 = 1; neg0or1 = 0; orderswitch = kTRUE;}\r
-\r
-    //load daughter tracks\r
-    AliAODTrack* prongTrackPos = (AliAODTrack*)v0->GetDaughter(pos0or1);\r
-    AliAODTrack* prongTrackNeg = (AliAODTrack*)v0->GetDaughter(neg0or1);\r
-    if(!prongTrackPos) continue;\r
-    if(!prongTrackNeg) continue;\r
-\r
-    //daughter cuts\r
-    if(v0->PtProng(pos0or1) < .15) continue;\r
-    if(v0->PtProng(neg0or1) < .15) continue;\r
-    if(fabs(v0->EtaProng(pos0or1)) > .8) continue;\r
-    if(fabs(v0->EtaProng(neg0or1)) > .8) continue;\r
-\r
-    //load status for PID\r
-    statusPos=prongTrackPos->GetStatus();\r
-    if((statusPos&AliESDtrack::kTPCrefit)==0) continue;\r
-    prongTrackPos->SetAODEvent(fAOD);\r
-    statusNeg=prongTrackNeg->GetStatus();\r
-    if((statusNeg&AliESDtrack::kTPCrefit)==0) continue;\r
-    prongTrackNeg->SetAODEvent(fAOD);\r
-\r
-    //TPC PID\r
-    if(fabs(fPidAOD->NumberOfSigmasTPC(prongTrackPos,AliPID::kPion)) < kMaxTPCSigmaPion) goodPiPlus = kTRUE;\r
-    if(fabs(fPidAOD->NumberOfSigmasTPC(prongTrackNeg,AliPID::kPion)) < kMaxTPCSigmaPion) goodPiMinus = kTRUE;\r
-   \r
-    //Positive daughter identification TOF\r
-    float probMis;\r
-    AliPIDResponse::EDetPidStatus statusPosTOF = fPidAOD->CheckPIDStatus(AliPIDResponse::kTOF, prongTrackPos);\r
-    double Ppos = v0->PProng(pos0or1);\r
-    if(Ppos > kTOFLow) //PiPlus\r
-    {\r
-     //if( (statusPos&AliESDtrack::kTOFpid)!=0 && (statusPos&AliESDtrack::kTIME)!=0 && (statusPos&AliESDtrack::kTOFout)!=0 && (statusPos&AliESDtrack::kTOFmismatch)<=0) (OBSOLETE; NEW CALL BELOW)\r
-     if(AliPIDResponse::kDetPidOk == statusPosTOF)\r
-     {\r
-      probMis = fPidAOD->GetTOFMismatchProbability(prongTrackPos);\r
-      if(probMis < 0.01) //avoid TOF-TPC mismatch\r
-      {\r
-       if(fabs(fPidAOD->NumberOfSigmasTOF(prongTrackPos,AliPID::kPion)) < kMaxTOFSigmaPion) goodPiPlus = kTRUE;\r
-       else goodPiPlus = kFALSE;\r
-      }  \r
-     }\r
-    }\r
-    //Negative daughter identification TOF\r
-    AliPIDResponse::EDetPidStatus statusNegTOF = fPidAOD->CheckPIDStatus(AliPIDResponse::kTOF, prongTrackNeg);\r
-    double Pneg = v0->PProng(neg0or1);\r
-    if(Pneg > kTOFLow) //PiMinus\r
-    {\r
-     //if( (statusNeg&AliESDtrack::kTOFpid)!=0 && (statusNeg&AliESDtrack::kTIME)!=0 && (statusNeg&AliESDtrack::kTOFout)!=0 && (statusNeg&AliESDtrack::kTOFmismatch)<=0) (OBSOLETE; NEW CALL BELOW)\r
-     if(AliPIDResponse::kDetPidOk == statusNegTOF)\r
-     {\r
-      probMis = fPidAOD->GetTOFMismatchProbability(prongTrackPos);\r
-      if(probMis < 0.01) //avoid TOF-TPC mismatch\r
-      {\r
-       if(fabs(fPidAOD->NumberOfSigmasTOF(prongTrackNeg,AliPID::kPion)) < kMaxTOFSigmaPion) goodPiMinus = kTRUE;\r
-       else goodPiMinus = kFALSE;\r
-      }\r
-     }\r
-    }\r
-    \r
-    //K0 cuts\r
-    if(v0->Eta() > kEtaCut)                                    continue;    \r
-    if(v0->CosPointingAngle(primaryVertex) < kMinCosAngle)     continue;\r
-    if(v0->MassK0Short() < .2 || v0->MassK0Short() > .8)       continue;\r
-    if(v0->DcaNegToPrimVertex() < kMinDCAPrimaryPion)          continue;\r
-    if(v0->DcaPosToPrimVertex() < kMinDCAPrimaryPion)          continue;  \r
-    if(v0->DecayLength(primaryVertex) > kMaxDLK0)              continue;\r
-    if(v0->DecayLength(primaryVertex) < kMinDLK0)                      continue;\r
-    if(v0->DcaV0Daughters() > kMaxDCADaughtersK0)              continue;\r
-    double v0Dca = v0->DcaV0ToPrimVertex();\r
-    if(v0Dca > kMaxDCAK0)                                                      continue;        \r
-    if(!goodPiMinus || !goodPiPlus)                            continue; \r
-    \r
-    //EVERYTHING BELOW HERE PASSES SINGLE PARTICLE CUTS, PION PID, and LOOSE MASS CUT\r
-\r
-    //for MC\r
-    //bool MCgood = kFALSE;\r
-    //if(kMCCase){\r
-    //AliAODMCParticle* mck0dp = (AliAODMCParticle*)mcArray->At(abs(prongTrackPos->GetLabel()));\r
-    //AliAODMCParticle* mck0dn = (AliAODMCParticle*)mcArray->At(abs(prongTrackNeg->GetLabel()));   \r
-    //if(mck0dp->GetMother() >= 0){ \r
-     //if(mck0dp->GetMother() == mck0dn->GetMother()){\r
-      //if(abs(mck0dp->GetPdgCode()) == 211 && abs(mck0dn->GetPdgCode()) == 211){\r
-       //AliAODMCParticle* mck0 = (AliAODMCParticle*)mcArray->At(mck0dp->GetMother());\r
-       //if(abs(mck0->GetPdgCode()) == 310){\r
-        //MCgood = kTRUE;     \r
-       //}\r
-      //}\r
-     //}\r
-    //}\r
-    //}// if kMCCase\r
-    \r
-    if(v0->MassK0Short() > .48 && v0->MassK0Short() < .515) goodK0 = kTRUE;\r
-    //else continue; //removed, Apr 18\r
-     \r
-    //Check for shared daughters, using v0 DCA to judge\r
-    bool v0JudgeNew; //true if new v0 beats old\r
-    tempK0[v0Count].fSkipShared = kFALSE;\r
-    double newV0Pars[3] = {fabs(v0->MassK0Short()-kMassK0Short),v0Dca,v0->DcaV0Daughters()}; //parameters used in merit cut\r
-    if(fMeritCase){\r
-     for(int iID = 0; iID<v0Count; iID++){\r
-      if(tempK0[iID].fSkipShared == kFALSE){           //if old is already skipped, go to next old\r
-       if(tempK0[iID].fDaughterID1 == prongTrackPos->GetID() || tempK0[iID].fDaughterID2 == prongTrackNeg->GetID()){\r
-        double oldV0Pars[3] = {fabs(tempK0[iID].fMass-kMassK0Short), tempK0[iID].fV0Dca, tempK0[iID].fDDDca}; \r
-        v0JudgeNew = CheckMeritCutWinner(fMeritCutChoice, oldV0Pars, newV0Pars); //true if new wins\r
-        if(!v0JudgeNew){               //if old beats new...\r
-         if(!tempK0[iID].fK0 && goodK0) continue;      //if bad old beats new good, do nothing...                              \r
-         else{                                         //but if bad old beats new bad, or good old beats anything, skip new\r
-          tempK0[v0Count].fSkipShared = kTRUE;         //skip new\r
-          break;                                       //no need to keep checking others\r
-         }\r
-        }\r
-        else{                                          //if new beats old...\r
-         if(tempK0[iID].fK0 && !goodK0) continue;      //if bad new beats good old, do nothing...\r
-         else{                                         //but if bad new beats bad old, or good new beats anything, skip old\r
-             tempK0[iID].fSkipShared = kTRUE;          //skip old      \r
-             if(tempK0[iID].fK0) k0Count--;            //if good old gets skipped, subtract from number of K0s (new one will be added later, if it succeeds)\r
-         }\r
-        }\r
-       }\r
-      }\r
-     }\r
-     if(tempK0[v0Count].fSkipShared) continue;         //if new K0 is skipped, don't load; go to next v0\r
-    }//if MeritCase                    \r
-       \r
-    //load parameters into temporary class instance\r
-    if(v0Count < kMaxNumK0)\r
-    {\r
-       if(goodK0){\r
-         tempK0[v0Count].fK0 = kTRUE;\r
-         k0Count++;\r
-        }\r
-        else tempK0[v0Count].fK0 = kFALSE; \r
-\r
-        //if(v0->MassK0Short() > .45 && v0->MassK0Short() < .48) tempK0[v0Count].fSideLeft = kTRUE;\r
-        //else tempK0[v0Count].fSideLeft = kFALSE;\r
-        //if(v0->MassK0Short() > .515 && v0->MassK0Short() < .545) tempK0[v0Count].fSideRight = kTRUE;\r
-        //else tempK0[v0Count].fSideRight = kFALSE;\r
-           //if(!goodK0) continue; //no sides, speed up analysis (REDUNDANT RIGHT NOW)\r
-\r
-        tempK0[v0Count].fDaughterID1    = prongTrackPos->GetID();\r
-        tempK0[v0Count].fDaughterID2    = prongTrackNeg->GetID();\r
-        tempK0[v0Count].fMomentum[0]           = v0->Px();\r
-        tempK0[v0Count].fMomentum[1]           = v0->Py();\r
-        tempK0[v0Count].fMomentum[2]           = v0->Pz();\r
-        tempK0[v0Count].fPt            = v0->Pt();\r
-        tempK0[v0Count].fMass          = v0->MassK0Short();\r
-        tempK0[v0Count].fV0Dca         = v0Dca;\r
-\r
-        //for hists\r
-        tempK0[v0Count].fDDDca         = v0->DcaV0Daughters();\r
-           tempK0[v0Count].fDecayLength        = v0->DecayLength(primaryVertex);\r
-        tempK0[v0Count].fPosPt         = v0->PtProng(pos0or1);\r
-        tempK0[v0Count].fNegPt         = v0->PtProng(neg0or1);\r
-        tempK0[v0Count].fPosPhi                = v0->PhiProng(pos0or1);\r
-        tempK0[v0Count].fNegPhi                = v0->PhiProng(neg0or1);\r
-           if(!orderswitch){\r
-         tempK0[v0Count].fPosDca       = v0->DcaPosToPrimVertex();\r
-         tempK0[v0Count].fNegDca       = v0->DcaNegToPrimVertex();\r
-           }\r
-        else{\r
-         tempK0[v0Count].fPosDca       = v0->DcaNegToPrimVertex();\r
-         tempK0[v0Count].fNegDca       = v0->DcaPosToPrimVertex();\r
-           } \r
-        \r
-        //for separation\r
-        GetGlobalPositionAtGlobalRadiiThroughTPC(prongTrackPos, bField, tempK0[v0Count].fPosXYZ, vertex);\r
-           GetGlobalPositionAtGlobalRadiiThroughTPC(prongTrackNeg, bField, tempK0[v0Count].fNegXYZ, vertex);\r
-        //for DPC\r
-        prongTrackPos->GetPxPyPz(tempK0[v0Count].fPPos);\r
-        prongTrackNeg->GetPxPyPz(tempK0[v0Count].fPNeg);\r
-\r
-        //if(idCount < 50){\r
-        // if(goodK0){\r
-        //  idArray[idCount*2]   = prongTrackPos->GetID();\r
-        //  idArray[idCount*2+1] = prongTrackNeg->GetID();\r
-        //  idCount++;\r
-        //}} \r
-\r
-        v0Count++;\r
-    }\r
-\r
-  }//v0\r
-   \r
-  if(k0Count<2) return;  //only keep events with more than 1 good K0\r
-\r
-  //Add Event to buffer - this is for event mixing\r
-  fEC[zBin][centBin]->FIFOShift();\r
-  (fEvt) = fEC[zBin][centBin]->fEvt;\r
-  (fEvt)->fFillStatus = 1;\r
-  int unskippedCount = 0;\r
-  for(int i=0;i<v0Count;i++)\r
-  {\r
-   if(!tempK0[i].fSkipShared)                          //don't include skipped v0s (from shared daughters)\r
-   {\r
-    ((TH3F*)fOutputList->FindObject("fHistMass"))->Fill(centBin+1,tempK0[i].fPt,tempK0[i].fMass);\r
-    if(tempK0[i].fK0)                                  //make sure particle is good (mass)\r
-    {\r
-     (fEvt)->fK0Particle[unskippedCount] = tempK0[i];  //load good, unskipped K0s\r
-     unskippedCount++;                                 //count good, unskipped K0s\r
-    }\r
-   }\r
-  }\r
-  (fEvt)->fNumV0s = unskippedCount;\r
-  //Printf("Number of v0s: %d", v0Count);\r
-  //Printf("Number of K0s: %d", k0Count);\r
-  delete [] tempK0; tempK0 = NULL;\r
-\r
-  ((TH1F*)fOutputList->FindObject("fHistMultK0"))->Fill(unskippedCount);       // changed 3/25, used to be "k0Count"\r
-  ((TH1F*)fOutputList->FindObject("fHistCentUsed"))->Fill(percent);\r
-\r
-  //Printf("Reconstruction Finished. Starting pair studies.");\r
-\r
-  //////////////////////////////////////////////////////////////////////\r
-  // Correlations\r
-  //////////////////////////////////////////////////////////////////////\r
-\r
-  float px1, py1, pz1, px2, py2, pz2;                  //single kaon values\r
-  float en1, en2;                                                              //single kaon values \r
-  //float pt1, pt2;                                                            //single kaon values\r
-  float pairPx, pairPy, pairPz, pairP0;                        //pair momentum values\r
-  float pairPt, pairMt, pairKt;                        //pair momentum values\r
-  float pairMInv, pairPDotQ;\r
-  float qinv, q0, qx, qy, qz;                          //pair q values\r
-  //float qLength, thetaSH, thetaSHCos, phiSH;            //Spherical Harmonics values\r
-  float am12, epm, h1, p12, p112, ppx, ppy, ppz, ks;   //PRF\r
-  //float qOutLCMS;\r
-  float qOutPRF, qSide, qLong;                         //relative momentum in LCMS/PRF frame\r
-  float betasq, gamma;\r
-  float p1LCMSOut, p1LCMSSide, p1LCMSLong, en1LCMS;\r
-  float p2LCMSOut, p2LCMSSide, p2LCMSLong, en2LCMS;\r
-\r
-\r
-  for(int i=0; i<(fEvt)->fNumV0s; i++) // Current event V0\r
-  {\r
-    //single particle histograms (done here to avoid "skipped" v0s\r
-     ((TH1F*)fOutputList->FindObject("fHistDCADaughters"))     ->Fill((fEvt)->fK0Particle[i].fDDDca);\r
-     ((TH1F*)fOutputList->FindObject("fHistDecayLengthK0"))    ->Fill((fEvt)->fK0Particle[i].fDecayLength);\r
-     ((TH1F*)fOutputList->FindObject("fHistDCAK0"))            ->Fill((fEvt)->fK0Particle[i].fV0Dca);\r
-     ((TH1F*)fOutputList->FindObject("fHistDCAPiMinus"))       ->Fill((fEvt)->fK0Particle[i].fNegDca);\r
-     ((TH1F*)fOutputList->FindObject("fHistDCAPiPlus"))                ->Fill((fEvt)->fK0Particle[i].fPosDca);\r
-     ((TH2F*)fOutputList->FindObject("fHistPtK0"))             ->Fill(centBin+1, (fEvt)->fK0Particle[i].fPt);\r
-     ((TH2F*)fOutputList->FindObject("fHistK0PiPlusPt"))       ->Fill(centBin+1, (fEvt)->fK0Particle[i].fPosPt);\r
-     ((TH2F*)fOutputList->FindObject("fHistK0PiMinusPt"))      ->Fill(centBin+1, (fEvt)->fK0Particle[i].fNegPt);\r
-     ((TH1F*)fOutputList->FindObject("fHistDaughterPhi"))      ->Fill((fEvt)->fK0Particle[i].fPosPhi);\r
-     ((TH1F*)fOutputList->FindObject("fHistDaughterPhi"))      ->Fill((fEvt)->fK0Particle[i].fNegPhi);\r
-     \r
-     ((TH1F*)fOutputList->FindObject("fHistPx"))               ->Fill((fEvt)->fK0Particle[i].fMomentum[0]);\r
-     ((TH1F*)fOutputList->FindObject("fHistPy"))               ->Fill((fEvt)->fK0Particle[i].fMomentum[1]);\r
-     ((TH1F*)fOutputList->FindObject("fHistPz"))               ->Fill((fEvt)->fK0Particle[i].fMomentum[2]);\r
-\r
-    for(int evnum=0; evnum<kEventsToMix+1; evnum++)// Event buffer loop: evnum=0 is the current event, all other evnum's are past events\r
-    {\r
-      int startbin=0;\r
-      if(evnum==0) startbin=i+1;\r
-      \r
-      for(int j=startbin; j<(fEvt+evnum)->fNumV0s; j++) // Past event V0\r
-      {\r
-        if(evnum==0)  // Get rid of shared tracks\r
-        {\r
-          if((fEvt)->fK0Particle[i].fDaughterID1 == (fEvt+evnum)->fK0Particle[j].fDaughterID1) continue;\r
-                 if((fEvt)->fK0Particle[i].fDaughterID1 == (fEvt+evnum)->fK0Particle[j].fDaughterID2) continue;\r
-             if((fEvt)->fK0Particle[i].fDaughterID2 == (fEvt+evnum)->fK0Particle[j].fDaughterID1) continue;\r
-             if((fEvt)->fK0Particle[i].fDaughterID2 == (fEvt+evnum)->fK0Particle[j].fDaughterID2) continue;\r
-           }\r
-            \r
-        px1 = (fEvt)->fK0Particle[i].fMomentum[0];\r
-               py1 = (fEvt)->fK0Particle[i].fMomentum[1];\r
-               pz1 = (fEvt)->fK0Particle[i].fMomentum[2];\r
-        //pt1 = (fEvt)->fK0Particle[i].fPt;\r
-               px2 = (fEvt+evnum)->fK0Particle[j].fMomentum[0];\r
-               py2 = (fEvt+evnum)->fK0Particle[j].fMomentum[1];\r
-               pz2 = (fEvt+evnum)->fK0Particle[j].fMomentum[2];\r
-        //pt2 = (fEvt+evnum)->fK0Particle[j].fPt;\r
-        if(fRandomNumber->Rndm() < .5){        //switch particle order for 3D qout bias\r
-                double tempvar;\r
-         tempvar = px1; px1 = px2; px2 = tempvar;\r
-         tempvar = py1; py1 = py2; py2 = tempvar;\r
-         tempvar = pz1; pz1 = pz2; pz2 = tempvar;\r
-               }\r
-\r
-               en1  = sqrt(pow(px1,2)+pow(py1,2)+pow(pz1,2)+pow(kMassK0Short,2));\r
-               en2  = sqrt(pow(px2,2)+pow(py2,2)+pow(pz2,2)+pow(kMassK0Short,2));\r
-\r
-        q0 = en1 - en2;\r
-        qx = px1 - px2;\r
-        qy = py1 - py2;\r
-        qz = pz1 - pz2;\r
-        qinv = sqrt(pow(qx,2) + pow(qy,2) + pow(qz,2) - pow(q0,2));\r
-\r
-        pairPx = px1 + px2;\r
-               pairPy = py1 + py2;\r
-               pairPz = pz1 + pz2;\r
-        pairP0 = en1 + en2;\r
-               pairPt = sqrt(pairPx*pairPx + pairPy*pairPy);\r
-        pairKt = pairPt/2.;                                                                    //used for KT binning\r
-        pairMt = sqrt(pairP0*pairP0 - pairPz*pairPz);          //used for LCMS (not plots)\r
-               pairMInv = sqrt(pow(pairP0,2)-pow(pairPx,2)-pow(pairPy,2)-pow(pairPz,2));//used for PRF\r
-        pairPDotQ = pairP0*q0-pairPx*qx-pairPy*qy-pairPz*qz;   //used for PRF\r
-\r
-           //PRF (this section will probably be removed in favor of later boosting section)\r
-        p12 = sqrt(pow(pairPx,2)+pow(pairPy,2)+pow(pairPz,2)); //pair momentum length\r
-        am12 = sqrt(pow(en1+en2,2)-p12*p12);                                   //sqrt(s)=|p1+p2|(4vec)\r
-        epm = en1+en2+am12;                                                                            //"energy plus mass"\r
-        p112 = px1*pairPx+py1*pairPy+pz1*pairPz;                               //proj. of p1 on pairP\r
-        if(am12 == 0) continue;\r
-        h1 = (p112/epm - en1)/am12;\r
-        ppx = px1+pairPx*h1;                                                                   //px in PRF\r
-        ppy = py1+pairPy*h1;                                                                   //py in PRF     \r
-        ppz = pz1+pairPz*h1;                                                                   //pz in PRF\r
-        ks = sqrt(ppx*ppx+ppy*ppy+ppz*ppz);                                            //k*\r
-        ((TH1F*)fOutputList->FindObject("fHistPxCM"))->Fill(ppx);\r
-        ((TH1F*)fOutputList->FindObject("fHistPyCM"))->Fill(ppy);\r
-        ((TH1F*)fOutputList->FindObject("fHistPzCM"))->Fill(ppz);\r
-        ((TH1F*)fOutputList->FindObject("fHistKsCM"))->Fill(ks);\r
-        \r
-        //relative momentum in out-side-long for LCMS and PRF\r
-        if(pairMt == 0 || pairPt == 0) continue;\r
-        qLong = (pairP0*qz - pairPz*q0)/pairMt;        //same for both frames\r
-        qSide = (pairPx*qy - pairPy*qx)/pairPt;        //same for both frames\r
-        //qOutLCMS = (pairPx*qx + pairPy*qy)/pairPt;\r
-               qOutPRF  = pairMInv*(pairPx*qx+pairPy*qy)/pairMt/pairPt - pairPt*pairPDotQ/pairMt/pairMInv;\r
-        \r
-               //finding gamma for gamma binning/hists (likely will be removed after tests)\r
-               p1LCMSOut  = (pairPx*px1+pairPy*py1)/pairPt;\r
-               p1LCMSSide = (pairPx*py1-pairPy*px1)/pairPt;\r
-               p1LCMSLong = (pairP0*pz1-pairPz*en1)/pairMt;\r
-               p2LCMSOut  = (pairPx*px2+pairPy*py2)/pairPt;\r
-               p2LCMSSide = (pairPx*py2-pairPy*px2)/pairPt;\r
-               p2LCMSLong = (pairP0*pz2-pairPz*en2)/pairMt;\r
-               en1LCMS = sqrt(pow(p1LCMSOut,2)+pow(p1LCMSSide,2)+pow(p1LCMSLong,2)+pow(kMassK0Short,2));\r
-               en2LCMS = sqrt(pow(p2LCMSOut,2)+pow(p2LCMSSide,2)+pow(p2LCMSLong,2)+pow(kMassK0Short,2));               \r
-               betasq = pow((p1LCMSOut+p2LCMSOut)/(en1LCMS+en2LCMS),2);\r
-               gamma = 1./sqrt(1-betasq);\r
-               ((TH2F*)fOutputList->FindObject("fHistGamma"))->Fill(gamma,qinv);\r
-               ((TH1F*)fOutputList->FindObject("fHistPOutLCMS"))->Fill(p1LCMSOut);\r
-               ((TH1F*)fOutputList->FindObject("fHistPSideLCMS"))->Fill(p1LCMSSide);\r
-               ((TH1F*)fOutputList->FindObject("fHistPLongLCMS"))->Fill(p1LCMSLong);\r
-               ((TH1F*)fOutputList->FindObject("fHistPOutLCMS"))->Fill(p2LCMSOut);\r
-               ((TH1F*)fOutputList->FindObject("fHistPSideLCMS"))->Fill(p2LCMSSide);\r
-               ((TH1F*)fOutputList->FindObject("fHistPLongLCMS"))->Fill(p2LCMSLong);\r
-               //getting bin numbers and names for 3D histogram\r
-        TString *histname3D = new TString("fHist3DOSL");\r
-        int ktBin;\r
-        if(pairKt < 0.6) ktBin = 0;\r
-               else if(pairKt < 0.8) ktBin = 1;\r
-               else if(pairKt < 1.0) ktBin = 2;\r
-               else ktBin = 3;\r
-               *histname3D += centBin-6; //centBins: [6,15] -> array bins: [0,9]\r
-               *histname3D += ktBin;\r
-\r
-        //Spherical harmonics\r
-        //qLength = sqrt(qLong*qLong + qSide*qSide + qOutPRF*qOutPRF);\r
-        //thetaSHCos = qLong/qLength;\r
-        //thetaSH = acos(thetaSHCos);\r
-        //phiSH = acos(qOutPRF/(qLength*sin(thetaSH)));\r
-\r
-        //Finding average separation of daughters throughout TPC - two-track cut\r
-        float posPositions1[9][3] = {{0}};\r
-        float negPositions1[9][3] = {{0}};\r
-        float posPositions2[9][3] = {{0}};\r
-        float negPositions2[9][3] = {{0}};\r
-        for(int iPos = 0; iPos < 9; iPos++){\r
-         for(int jPos = 0; jPos < 3; jPos++){\r
-           posPositions1[iPos][jPos] = (fEvt)->fK0Particle[i].fPosXYZ[iPos][jPos];\r
-           negPositions1[iPos][jPos] = (fEvt)->fK0Particle[i].fNegXYZ[iPos][jPos];\r
-           posPositions2[iPos][jPos] = (fEvt+evnum)->fK0Particle[j].fPosXYZ[iPos][jPos];\r
-           negPositions2[iPos][jPos] = (fEvt+evnum)->fK0Particle[j].fNegXYZ[iPos][jPos];\r
-         }\r
-        }    \r
-        float pMean = 0.;      //average separation for positive daughters\r
-        float nMean = 0.;      //average separation for negative daughters\r
-        float pDiff;           \r
-        float nDiff;\r
-        float pMin = 9999.;    //minimum separation (updates) - pos\r
-        float nMin = 9999.;    //minimum separation (updates) - neg\r
-        double pCount=0;       //counter for number of points used - pos\r
-        double nCount=0;       //counter for number of points used - neg\r
-        for(int ss=0;ss<9;ss++){\r
-         if(posPositions1[ss][0] != -9999 && posPositions2[ss][0] != -9999){          \r
-          pCount++;\r
-          pDiff = sqrt(pow(posPositions1[ss][0]-posPositions2[ss][0],2)+pow(posPositions1[ss][1]-posPositions2[ss][1],2)+pow(posPositions1[ss][2]-posPositions2[ss][2],2));\r
-          pMean = pMean + pDiff;\r
-          if(pDiff < pMin) pMin = pDiff;\r
-         }\r
-         if(negPositions1[ss][0] != -9999 && negPositions1[ss][0] != -9999){\r
-          nCount++;\r
-          nDiff = sqrt(pow(negPositions1[ss][0]-negPositions2[ss][0],2)+pow(negPositions1[ss][1]-negPositions2[ss][1],2)+pow(negPositions1[ss][2]-negPositions2[ss][2],2));     \r
-          nMean = nMean + nDiff;\r
-          if(nDiff < nMin) nMin = nDiff;\r
-         }\r
-        }\r
-        pMean = pMean/pCount; \r
-        nMean = nMean/nCount;     \r
-\r
-        if(evnum==0){ \r
-         ((TH1F*)fOutputList->FindObject("fHistSepNumPos"))->Fill(pMean); \r
-         ((TH1F*)fOutputList->FindObject("fHistSepNumNeg"))->Fill(nMean);\r
-         ((TH2F*)fOutputList->FindObject("fHistSepNumPos2"))->Fill(pMean,pMin);\r
-         ((TH2F*)fOutputList->FindObject("fHistSepNumNeg2"))->Fill(nMean,nMin);\r
-        }\r
-        else{\r
-         ((TH1F*)fOutputList->FindObject("fHistSepDenPos"))->Fill(pMean); \r
-         ((TH1F*)fOutputList->FindObject("fHistSepDenNeg"))->Fill(nMean);\r
-         ((TH2F*)fOutputList->FindObject("fHistSepDenPos2"))->Fill(pMean,pMin);\r
-         ((TH2F*)fOutputList->FindObject("fHistSepDenNeg2"))->Fill(nMean,nMin);\r
-        }\r
-\r
-        //Decay plane coincidence\r
-        //daughter momenta\r
-        float a1 = (fEvt)->fK0Particle[i].fPPos[0];\r
-        float b1 = (fEvt)->fK0Particle[i].fPPos[1];\r
-        float c1 = (fEvt)->fK0Particle[i].fPPos[2];\r
-        float d1 = (fEvt)->fK0Particle[i].fPNeg[0];\r
-        float e1 = (fEvt)->fK0Particle[i].fPNeg[1];\r
-        float f1 = (fEvt)->fK0Particle[i].fPNeg[2];\r
-        float a2 = (fEvt+evnum)->fK0Particle[j].fPPos[0];\r
-        float b2 = (fEvt+evnum)->fK0Particle[j].fPPos[1];\r
-        float c2 = (fEvt+evnum)->fK0Particle[j].fPPos[2];\r
-        float d2 = (fEvt+evnum)->fK0Particle[j].fPNeg[0];\r
-        float e2 = (fEvt+evnum)->fK0Particle[j].fPNeg[1];\r
-        float f2 = (fEvt+evnum)->fK0Particle[j].fPNeg[2];\r
\r
-        float cross1[3];\r
-        float cross2[3];\r
-        cross1[0] = b1*f1-c1*e1;\r
-        cross1[1] = c1*d1-a1*f1;\r
-        cross1[2] = a1*e1-b1*d1;\r
-        cross2[0] = b2*f2-c2*e2;\r
-        cross2[1] = c2*d2-a2*f2;\r
-        cross2[2] = a2*e2-b2*d2;\r
-        float crosslength1 = sqrt(pow(cross1[0],2)+pow(cross1[1],2)+pow(cross1[2],2));\r
-        float crosslength2 = sqrt(pow(cross2[0],2)+pow(cross2[1],2)+pow(cross2[2],2));\r
-        float dpc = (cross1[0]*cross2[0]+cross1[1]*cross2[1]+cross1[2]*cross2[2])/(crosslength1*crosslength2);\r
-\r
-        if(evnum==0)((TH2F*)fOutputList->FindObject("fHistSepDPC"))->Fill(dpc,pMean);\r
-        else ((TH2F*)fOutputList->FindObject("fHistSepDPCBkg"))->Fill(dpc,pMean);\r
-       \r
-        if(pMean < kMinSeparation || nMean < kMinSeparation) continue; //using the "new" method (ala Hans)\r
-        //end separation studies\r
-\r
-        //Fill Histograms\r
-        bool center1K0   = kFALSE;  //accepted mass K0\r
-           bool center2K0   = kFALSE;\r
-        if((fEvt)->fK0Particle[i].fK0) center1K0=kTRUE;\r
-        if((fEvt+evnum)->fK0Particle[j].fK0) center2K0=kTRUE;\r
-        //bool CL1 = kFALSE;\r
-        //bool CL2 = kFALSE;\r
-        //bool CR1 = kFALSE;\r
-        //bool CR2 = kFALSE;\r
-        //if(center1K0 && center2K0){\r
-        // if((fEvt)->fK0Particle[i].fMass < kMassK0Short) CL1 = kTRUE;\r
-        // else CR1 = kTRUE;\r
-        // if((fEvt+evnum)->fK0Particle[j].fMass < kMassK0Short) CL2 = kTRUE;\r
-        // else CR2 = kTRUE;\r
-        //}\r
-       \r
-        //bool SideLeft1 = kFALSE;\r
-        //bool SideLeft2 = kFALSE;\r
-        //bool SideRight1 = kFALSE;\r
-        //bool SideRight2 = kFALSE;\r
-        //if((fEvt)->fK0Particle[i].fSideLeft) SideLeft1 = kTRUE;\r
-        //else if((fEvt)->fK0Particle[i].fSideRight) SideRight1 = kTRUE;\r
-        //if((fEvt+evnum)->fK0Particle[j].fSideLeft) SideLeft2 = kTRUE;\r
-        //else if((fEvt+evnum)->fK0Particle[j].fSideRight) SideRight2 = kTRUE;\r
-       \r
-\r
-        if(evnum==0) //Same Event\r
-        {     \r
-          //((TH3F*)fOutputList->FindObject("fHistMassQKt"))->Fill(qinv, pairKt, (fEvt)->fK0Particle[i].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassQKt"))->Fill(qinv, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassKtK0"))->Fill(centBin+1, pairKt, (fEvt)->fK0Particle[i].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassKtK0"))->Fill(centBin+1, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassPtCFK0"))->Fill(centBin+1, pt1, (fEvt)->fK0Particle[i].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassPtCFK0"))->Fill(centBin+1, pt2, (fEvt+evnum)->fK0Particle[j].fMass);\r
-\r
-          if(center1K0 && center2K0){\r
-           //1D\r
-           ((TH3F*)fOutputList->FindObject("fHistQinvSignal"))->Fill(centBin+1, pairKt, qinv);\r
-           //if(!splitK0centers)((TH3F*)fOutputList->FindObject("fHistQinvSignalNoSplit"))->Fill(centBin+1, pairKt, qinv);\r
-           ((TH2F*)fOutputList->FindObject("fHistKtK0"))->Fill(centBin+1, pairKt);\r
-           \r
-           //for mass bin study\r
-           //if(CL1 && CL2) ((TH3F*)fOutputList->FindObject("fHistCLCLSignal"))->Fill(centBin+1, pairKt, qinv);           \r
-           //else if ((CL1 && CR2) || (CR1 && CL2)) ((TH3F*)fOutputList->FindObject("fHistCLCRSignal"))->Fill(centBin+1, pairKt, qinv);\r
-           //else ((TH3F*)fOutputList->FindObject("fHistCRCRSignal"))->Fill(centBin+1, pairKt, qinv);\r
-\r
-           //3D\r
-           if(fCase3D){\r
-            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
-                    histname3D->Append("Signal");\r
-                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
-                   }\r
-           }  \r
-           /*if(pairKt < 1.0){\r
-            if(centBin > 13){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKt"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHCentLowKt"))->Fill(qLength,thetaSHCos,phiSH);}\r
-            else if(centBin > 9){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentLowKt"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentLowKt"))->Fill(qLength,thetaSHCos,phiSH);}}            \r
-           else if(pairKt < 2.0){\r
-            if(centBin > 13){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLCentHighKt"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHCentHighKt"))->Fill(qLength,thetaSHCos, phiSH);}\r
-            else if(centBin > 9){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentHighKt"))->Fill(qOutPRF,qSide,qLong);\r
-\r
-             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentHighKt"))->Fill(qLength, thetaSHCos, phiSH);}}*/                  \r
-\r
-          }//centercenter\r
-\r
-          //side-side correlations\r
-          //if(!splitK0sides){\r
-          // if(SideLeft1 && SideLeft2) ((TH3F*)fOutputList->FindObject("fHistLeftLeftSignal"))->Fill(centBin+1, pairKt, qinv);\r
-           //else if((SideLeft1 && SideRight2) || (SideRight1 && SideLeft2)) ((TH3F*)fOutputList->FindObject("fHistLeftRightSignal"))->Fill(centBin+1, pairKt, qinv);\r
-           //else if(SideRight1 && SideRight2) ((TH3F*)fOutputList->FindObject("fHistRightRightSignal"))->Fill(centBin+1, pairKt, qinv);\r
-         //}\r
-\r
-        }//same event\r
-\r
-        else //Mixed Events\r
-        {\r
-          //((TH3F*)fOutputList->FindObject("fHistMassKtBkgK0"))->Fill(centBin+1, pairKt, (fEvt)->fK0Particle[i].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassKtBkgK0"))->Fill(centBin+1, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassPtCFBkgK0"))->Fill(centBin+1, pt1, (fEvt)->fK0Particle[i].fMass);\r
-          //((TH3F*)fOutputList->FindObject("fHistMassPtCFBkgK0"))->Fill(centBin+1, pt2, (fEvt+evnum)->fK0Particle[j].fMass);\r
-\r
-          if(center1K0 && center2K0){\r
-           //1D\r
-           ((TH3F*)fOutputList->FindObject("fHistQinvBkg"))->Fill(centBin+1, pairKt, qinv);\r
-\r
-           //for mass bin study\r
-           //if(CL1 && CL2) ((TH3F*)fOutputList->FindObject("fHistCLCLBkg"))->Fill(centBin+1, pairKt, qinv);      \r
-           //else if ((CL1 && CR2) || (CR1 && CL2)) ((TH3F*)fOutputList->FindObject("fHistCLCRBkg"))->Fill(centBin+1, pairKt, qinv);\r
-           //else ((TH3F*)fOutputList->FindObject("fHistCRCRBkg"))->Fill(centBin+1, pairKt, qinv);\r
-\r
-           //3D\r
-           if(fCase3D){\r
-            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
-                    histname3D->Replace(12,6,"Bkg");\r
-                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
-                   }\r
-           }\r
-           /*if(pairKt < 1.0){\r
-            if(centBin > 13){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKtBkg"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHCentLowKtBkg"))->Fill(qLength,thetaSHCos,phiSH);}\r
-            else if(centBin > 9){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentLowKtBkg"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentLowKtBkg"))->Fill(qLength,thetaSHCos,phiSH);}}\r
-           else if(pairKt < 2.0){\r
-            if(centBin > 13){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLCentHighKtBkg"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHCentHighKtBkg"))->Fill(qLength, thetaSHCos, phiSH);}\r
-            else if(centBin > 9){\r
-             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentHighKtBkg"))->Fill(qOutPRF,qSide,qLong);\r
-             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentHighKtBkg"))->Fill(qLength, thetaSHCos, phiSH);}}*/\r
-          }\r
-\r
-          //side-side correlations\r
-          //if(SideLeft1 && SideLeft2) ((TH3F*)fOutputList->FindObject("fHistLeftLeftBkg"))->Fill(centBin+1, pairKt, qinv);\r
-          //else if((SideLeft1 && SideRight2) || (SideRight1 && SideLeft2)) ((TH3F*)fOutputList->FindObject("fHistLeftRightBkg"))->Fill(centBin+1, pairKt, qinv);\r
-          //else if(SideRight1 && SideRight2) ((TH3F*)fOutputList->FindObject("fHistRightRightBkg"))->Fill(centBin+1, pairKt, qinv);\r
-\r
-        }//Mixed Events\r
\r
-      }//past event\r
-    }//event buffer\r
-  }//current event\r
-\r
-  // Post output data.\r
-  PostData(1, fOutputList);\r
-  \r
-  }\r
-//________________________________________________________________________\r
-void AliFemtoK0Analysis::Terminate(Option_t *) \r
-{\r
-  // Called once at the end of the query\r
-  cout<<"Done"<<endl;\r
-\r
-}\r
-\r
-//_________________________________________________________________________\r
-void AliFemtoK0Analysis::GetGlobalPositionAtGlobalRadiiThroughTPC(const AliAODTrack *track, const Float_t bfield, Float_t globalPositionsAtRadii[9][3], double PrimaryVertex[3]){\r
-  // Gets the global position of the track at nine different radii in the TPC\r
-  // track is the track you want to propagate\r
-  // bfield is the magnetic field of your event\r
-  // globalPositionsAtRadii is the array of global positions in the radii and xyz\r
-  \r
-  // Initialize the array to something indicating there was no propagation\r
-  for(Int_t i=0;i<9;i++){\r
-    for(Int_t j=0;j<3;j++){\r
-      globalPositionsAtRadii[i][j]=-9999.;\r
-    }\r
-  }\r
-\r
-   // Make a copy of the track to not change parameters of the track\r
-  AliExternalTrackParam etp; etp.CopyFromVTrack(track);\r
-  //printf("\nAfter CopyFromVTrack\n");\r
-  //etp.Print();\r
\r
-  // The global position of the the track\r
-  Double_t xyz[3]={-9999.,-9999.,-9999.};  \r
-\r
-  // Counter for which radius we want\r
-  Int_t iR=0; \r
-  // The radii at which we get the global positions\r
-  // IROC (OROC) from 84.1 cm to 132.1 cm (134.6 cm to 246.6 cm)\r
-  Float_t Rwanted[9]={85.,105.,125.,145.,165.,185.,205.,225.,245.}; \r
-  // The global radius we are at\r
-  Float_t globalRadius=0;\r
-\r
-  // Propagation is done in local x of the track\r
-  for (Float_t x = etp.GetX();x<247.;x+=1.){ // GetX returns local coordinates\r
-    // Starts at the tracks fX and goes outwards. x = 245 is the outer radial limit\r
-    // of the TPC when the track is straight, i.e. has inifinite pt and doesn't get bent.\r
-    // If the track's momentum is smaller than infinite, it will develop a y-component, which\r
-    // adds to the global radius\r
-\r
-    // Stop if the propagation was not succesful. This can happen for low pt tracks\r
-    // that don't reach outer radii\r
-    if(!etp.PropagateTo(x,bfield))break;\r
-    etp.GetXYZ(xyz); // GetXYZ returns global coordinates\r
-    globalRadius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); //Idea to speed up: compare squared radii\r
-\r
-    // Roughly reached the radius we want\r
-    if(globalRadius > Rwanted[iR]){\r
-      \r
-      // Bigger loop has bad precision, we're nearly one centimeter too far, go back in small steps.\r
-      while (globalRadius>Rwanted[iR]){\r
-        x-=.1;\r
-        //      printf("propagating to x %5.2f\n",x);\r
-        if(!etp.PropagateTo(x,bfield))break;\r
-        etp.GetXYZ(xyz); // GetXYZ returns global coordinates\r
-        globalRadius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); //Idea to speed up: compare squared radii\r
-      }\r
-      //printf("At Radius:%05.2f (local x %5.2f). Setting position to x %4.1f y %4.1f z %4.1f\n",globalRadius,x,xyz[0],xyz[1],xyz[2]);\r
-      globalPositionsAtRadii[iR][0]=xyz[0];\r
-      globalPositionsAtRadii[iR][1]=xyz[1];\r
-      globalPositionsAtRadii[iR][2]=xyz[2];\r
-      //subtract primary vertex, "zero" track for correct mixed-event comparison\r
-      globalPositionsAtRadii[iR][0] -= PrimaryVertex[0];\r
-      globalPositionsAtRadii[iR][1] -= PrimaryVertex[1];\r
-      globalPositionsAtRadii[iR][2] -= PrimaryVertex[2];\r
-\r
-      // Indicate we want the next radius    \r
-      iR+=1;\r
-    }\r
-    if(iR>=8){\r
-      // TPC edge reached\r
-      return;\r
-    }\r
-  }\r
-}\r
-\r
-bool AliFemtoK0Analysis::CheckMeritCutWinner(int cutChoice, double oldPars[3], double newPars[3]){\r
- //performs "merit cut" judgement check on v0s with shared daughters, using one of three criteria.\r
- //if cutChoice = 4, it uses all three criteria, needed 2 of 3 'points'\r
-\r
- bool newV0Wins = kFALSE;\r
- double pardiff[3] = {newPars[0]-oldPars[0],\r
-                      newPars[1]-oldPars[1],\r
-                      newPars[2]-oldPars[2]};\r
- if(cutChoice > 0 && cutChoice < 4){\r
-  if(pardiff[cutChoice] <= 0.) newV0Wins = kTRUE;\r
- }\r
- else if(cutChoice == 4){\r
-  int newWinCount = 0;\r
-  for(int i=0;i<3;i++){if(pardiff[i+1] <= 0) newWinCount++;}\r
-  if(newWinCount > 1) newV0Wins = kTRUE;  \r
- }\r
- else{};\r
- return newV0Wins;\r
-}\r
-\r
-bool AliFemtoK0Analysis::RejectEventCentFlat(float MagField, float CentPercent)\r
-{ // to flatten centrality distribution\r
- bool RejectEvent = kFALSE;\r
- int weightBinSign;\r
- if(MagField > 0) weightBinSign = 0;\r
- else weightBinSign = 1;\r
- float kCentWeight[2][9] = {{.878,.876,.860,.859,.859,.88,.873,.879,.894},\r
-                                                {.828,.793,.776,.772,.775,.796,.788,.804,.839}};\r
- int weightBinCent = (int) CentPercent;\r
- if(fRandomNumber->Rndm() > kCentWeight[weightBinSign][weightBinCent]) RejectEvent = kTRUE;\r
-\r
- return RejectEvent;\r
-}\r
-  \r
-\r
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////
+//
+//  This class is used to perform femtoscopic analysis on K0s particles, 
+//  which are reconstructed using the AliAODv0 class.  
+//
+//  authors: Matthew Steinpreis (matthew.steinpreis@cern.ch)
+//   
+//  Change log:
+//     - TOF mismatch function calls changed (4/18/13)
+//     - added minimum decay length cut (rarely used though) (3/28/13)
+//     - K0 multiplicity histogram now filled with "unskippedCount" instead
+//       of k0Count (which included skipped k0s with shared daughters) 
+//       (3/25/13)
+//     - added hists for 3D mom. in LF and PRF (3/28/13) 
+//     - changed calling of PIDResponse (should be same actions) (3/28/13)
+//     - keep "side" K0s for mass plot (4/18)
+//             - tweaked loading and skipping appropriately
+//             - use merit test to skip sides (against good and side K0s)
+//             - a good K0 cant be skipped by a side
+//     - moved TPC propagation (via Hans' method) up to v0 level, which now
+//       uses an AliAODTrack(AliVTrack) instead of AliESDtrack (5/31/13)
+//     - added primary vertex subtraction in TPC propagation   (5/31/13)
+//     - removed all instances of AliESDtrack usage    (5/31/13)
+//     - removed old separation method/histograms      (5/31/13)
+//     - tidied up LCMS boost                                                  (6/10/13)
+//     - added new boosting prescription, get q out-side-long for LCMS and PRF (6/24/13)
+//             - added histograms and values for LCMS momenta (for simulation)
+//     - added random particle order switch in correlations (9/09/13)
+//     - added more bins for 3D OSL analysis (9/19/13)
+//     - added merit cut choice, pass as argument (10/16/13)
+//             - 1-mass, 2-v0dca, 3-dddca, 4-combination (used to be v0dca)
+//     - added passable argument for two-track minimum separation (10/16/13)
+//     - added boolean to turn off field-sign dependence for train (10/30/13)
+//     - changed destructors to minimize lost memory (11/27/13)
+//     - added Case3D to switch off all 3D objects (11/27/13)
+//     - added centrality flattening routine (and switch) (12/04/13)
+//     - added event plane stuff (12/11/13)
+////////////////////////////////////////////////////////////////////////////////
+
+
+#include <iostream>
+#include <math.h>
+#include "TMath.h"
+#include "TChain.h"
+#include "TFile.h"
+#include "TKey.h"
+#include "TObject.h"
+#include "TObjString.h"
+#include "TList.h"
+#include "TTree.h"
+#include "TH1F.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TH3D.h"
+#include "TProfile.h"
+#include "TCanvas.h"
+#include "TRandom3.h"
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+
+#include "AliAODEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliAODMCParticle.h"
+#include "AliAODv0.h"
+#include "AliAODRecoDecay.h"
+#include "AliCentrality.h"
+
+#include "AliFemtoK0Analysis.h"
+
+#define PI 3.1415927
+
+
+// Author: Matt Steinpreis, adapted from Dhevan Gangadharan
+
+ClassImp(AliFemtoK0Analysis)
+
+//________________________________________________________________________
+AliFemtoK0Analysis::AliFemtoK0Analysis():
+AliAnalysisTaskSE(),
+  fSignDep(kFALSE),
+  fFieldPos(kTRUE),
+  fOnlineCase(kTRUE),
+  fMeritCase(kTRUE),
+  fCase3D(kFALSE),
+  fMinDecayLength(0.0),
+  fMeritCutChoice(0),
+  fMinSep(0.0),
+  fFlatCent(kFALSE),
+  fPsiBinning(kFALSE),
+  fEventCount(0),
+  fEC(0x0),
+  fEvt(0X0),
+  fRandomNumber(0x0),
+  fName(0x0),
+  fAOD(0x0),
+  fOutputList(0x0),
+  fPidAOD(0x0)
+{
+}
+//________________________________________________________________________
+AliFemtoK0Analysis::AliFemtoK0Analysis(const char *name, bool SignDep, bool FieldPositive, bool OnlineCase, bool MeritCase, bool Case3D, float MinDL, int MeritCutChoice, float MinSep, bool FlatCent, bool PsiBinning) 
+: AliAnalysisTaskSE(name),
+  fSignDep(SignDep),
+  fFieldPos(FieldPositive),
+  fOnlineCase(OnlineCase),
+  fMeritCase(MeritCase),
+  fCase3D(Case3D),
+  fMinDecayLength(MinDL),
+  fMeritCutChoice(MeritCutChoice),
+  fMinSep(MinSep),
+  fFlatCent(FlatCent),
+  fPsiBinning(PsiBinning),
+  fEventCount(0),
+  fEC(0x0),
+  fEvt(0X0),
+  fRandomNumber(0x0),
+  fName(name),
+  fAOD(0x0),
+  fOutputList(0x0),
+  fPidAOD(0x0)
+{
+  //main constructor
+  fSignDep             = SignDep;
+  fFieldPos    = FieldPositive;
+  fOnlineCase  = OnlineCase;
+  fMeritCase   = MeritCase;
+  fCase3D              = Case3D;
+  fMinDecayLength = MinDL;
+  fMeritCutChoice = MeritCutChoice;
+  fMinSep              = MinSep;
+  fFlatCent            = FlatCent;
+  fPsiBinning  = PsiBinning;
+
+  // Define output slots here 
+  // Output slot #1
+  DefineOutput(1, TList::Class());
+  
+}
+//________________________________________________________________________
+AliFemtoK0Analysis::AliFemtoK0Analysis(const AliFemtoK0Analysis &obj)
+: AliAnalysisTaskSE(obj.fName),
+  fSignDep(obj.fSignDep),
+  fFieldPos(obj.fFieldPos),
+  fOnlineCase(obj.fOnlineCase),
+  fMeritCase(obj.fMeritCase),
+  fCase3D(obj.fCase3D),
+  fMinDecayLength(obj.fMinDecayLength),
+  fMeritCutChoice(obj.fMeritCutChoice),
+  fMinSep(obj.fMinSep),
+  fFlatCent(obj.fFlatCent),
+  fPsiBinning(obj.fPsiBinning),
+  fEventCount(obj.fEventCount),
+  fEC(obj.fEC),
+  fEvt(obj.fEvt),
+  fRandomNumber(obj.fRandomNumber),
+  fName(obj.fName),
+  fAOD(obj.fAOD),
+  fOutputList(obj.fOutputList),
+  fPidAOD(obj.fPidAOD)
+{
+}
+//________________________________________________________________________
+AliFemtoK0Analysis &AliFemtoK0Analysis::operator=(const AliFemtoK0Analysis &obj)
+{
+ //Assignment operator
+ if (this == &obj) return *this;
+ fSignDep   = obj.fSignDep;
+ fFieldPos     = obj.fFieldPos;
+ fOnlineCase   = obj.fOnlineCase;
+ fMeritCase    = obj.fMeritCase;
+ fCase3D               = obj.fCase3D;
+ fMinDecayLength= obj.fMinDecayLength;
+ fMeritCutChoice= obj.fMeritCutChoice;
+ fMinSep               = obj.fMinSep;
+ fFlatCent             = obj.fFlatCent;
+ fPsiBinning   = obj.fPsiBinning;
+ fEventCount   = obj.fEventCount;
+ fEC           = obj.fEC;
+ fEvt          = obj.fEvt;
+ fRandomNumber         = obj.fRandomNumber;
+ fName                 = obj.fName;
+ fAOD          = obj.fAOD;
+ fOutputList   = obj.fOutputList;
+ fPidAOD       = obj.fPidAOD;
+
+ return (*this);
+}
+//________________________________________________________________________
+AliFemtoK0Analysis::~AliFemtoK0Analysis()
+{
+  // Destructor
+  for(unsigned short i=0; i<kZVertexBins; i++)
+  {
+    for(unsigned short j=0; j<kCentBins; j++)
+    {
+         for(unsigned short k=0; k<kPsiBins; k++)
+         {
+        fEC[i][j][k]->~AliFemtoK0EventCollection();
+        fEC[i][j][k] = NULL;
+      }
+      delete [] fEC[i][j]; fEC[i][j] = NULL;
+    }
+    delete[] fEC[i]; fEC[i] = NULL;
+  }
+  delete[] fEC; fEC = NULL;
+
+  if(fEC){ delete fEC; fEC = NULL;}
+  if(fRandomNumber){ delete fRandomNumber; fRandomNumber = NULL;}
+  if(fAOD){ delete fAOD; fAOD = NULL;}
+  if(fOutputList){ delete fOutputList; fOutputList = NULL;}
+  if(fPidAOD){ delete fPidAOD; fPidAOD = NULL;}
+}
+//________________________________________________________________________
+void AliFemtoK0Analysis::MyInit()
+{
+
+  // One can set global variables here
+  fEventCount = 0;  
+
+  fEC = new AliFemtoK0EventCollection ***[kZVertexBins];
+  for(unsigned short i=0; i<kZVertexBins; i++)
+  {
+    fEC[i] = new AliFemtoK0EventCollection **[kCentBins];
+    
+    for(unsigned short j=0; j<kCentBins; j++)
+    {
+      fEC[i][j] = new AliFemtoK0EventCollection *[kPsiBins];
+
+      for(unsigned short k=0; k<kPsiBins; k++)
+         {
+           fEC[i][j][k] = new AliFemtoK0EventCollection(kEventsToMix+1, kMultLimit);
+      }
+    }
+  }
+
+  AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  fPidAOD = aodH->GetPIDResponse();
+
+  fRandomNumber = new TRandom3();  //for 3D, random sign switching
+  fRandomNumber->SetSeed(0);
+
+}
+//________________________________________________________________________
+void AliFemtoK0Analysis::UserCreateOutputObjects()
+{
+  // Create histograms
+  // Called once
+  
+  MyInit();// Initialize my settings
+
+  fOutputList = new TList();
+  fOutputList->SetOwner();
+
+  TH1F *fHistCent = new TH1F("fHistCent","",100,0,100);
+  fOutputList->Add(fHistCent);
+  TH1F *fHistCentFlat = new TH1F("fHistCentFlat","",100,0,100);
+  fOutputList->Add(fHistCentFlat);
+  TH1F *fHistCentUsed = new TH1F("fHistCentUsed","",100,0,100);
+  fOutputList->Add(fHistCentUsed);
+  //pion parameters
+  TH1F* fHistDCAPiPlus = new TH1F("fHistDCAPiPlus","",100,0,10);
+  fOutputList->Add(fHistDCAPiPlus);
+  TH1F* fHistDCAPiMinus = new TH1F("fHistDCAPiMinus","",100,0,10);
+  fOutputList->Add(fHistDCAPiMinus);
+  TH1F* fHistDCADaughters = new TH1F("fHistDCADaughters", "DCA of pions to each other", 50, 0., 0.5);
+  fOutputList->Add(fHistDCADaughters);
+  TH2F* fHistK0PiPlusPt = new TH2F("fHistK0PiPlusPt", "", kCentBins, .5,kCentBins+.5, 40,0.,4.);
+  fOutputList->Add(fHistK0PiPlusPt);
+  TH2F* fHistK0PiMinusPt = new TH2F("fHistK0PiMinusPt", "", kCentBins, .5,kCentBins+.5, 40,0.,4.);
+  fOutputList->Add(fHistK0PiMinusPt);
+  TH1F* fHistDaughterPhi = new TH1F("fHistDaughterPhi","",180,-PI,PI);
+  fOutputList->Add(fHistDaughterPhi);
+
+  //K0 parameters
+  TH1F* fHistMultK0 = new TH1F("fHistMultK0", "K0 multiplicity", 51, -0.5, 51-0.5);
+  fOutputList->Add(fHistMultK0);
+  TH2F* fHistPtK0 = new TH2F("fHistPtK0", "K0 pt distribution",kCentBins,.5,kCentBins+.5, 100, 0., 10.);
+  fOutputList->Add(fHistPtK0);
+  TH1F* fHistDecayLengthK0 = new TH1F("fHistDecayLengthK0", "K0 decay length", 100, 0., 100.);
+  fOutputList->Add(fHistDecayLengthK0);
+  TH1F* fHistDCAK0 = new TH1F("fHistDCAK0", "DCA of K0 to primary vertex", 40, 0., 0.4);
+  fOutputList->Add(fHistDCAK0);
+  TH2F* fHistKtK0 = new TH2F("fHistKtK0", "Kt distribution of K0 pairs", kCentBins, .5, kCentBins+.5, 300, 0., 3.);
+  fOutputList->Add(fHistKtK0);
+
+  TH1F* fHistPx = new TH1F("fHistPx","",200,0,2);
+  TH1F* fHistPy = new TH1F("fHistPy","",200,0,2);
+  TH1F* fHistPz = new TH1F("fHistPz","",200,0,2);
+  TH1F* fHistPxCM = new TH1F("fHistPxCM","",200,0,2);
+  TH1F* fHistPyCM = new TH1F("fHistPyCM","",200,0,2);
+  TH1F* fHistPzCM = new TH1F("fHistPzCM","",200,0,2);
+  TH1F* fHistKsCM = new TH1F("fHistKsCM","",200,0,2);
+  fOutputList->Add(fHistPx);
+  fOutputList->Add(fHistPy);
+  fOutputList->Add(fHistPz);
+  fOutputList->Add(fHistPxCM);
+  fOutputList->Add(fHistPyCM);
+  fOutputList->Add(fHistPzCM);
+  fOutputList->Add(fHistKsCM);
+
+  TH1F* fHistPOutLCMS = new TH1F("fHistPOutLCMS","",200,0,2);
+  TH1F* fHistPSideLCMS = new TH1F("fHistPSideLCMS","",200,0,2);
+  TH1F* fHistPLongLCMS = new TH1F("fHistPLongLCMS","",200,0,2);
+  fOutputList->Add(fHistPOutLCMS);
+  fOutputList->Add(fHistPSideLCMS);
+  fOutputList->Add(fHistPLongLCMS);
+
+  //pair gamma (LCMS to PRF, OSL)
+  TH2F* fHistGamma = new TH2F("fHistGamma","Gamma from LCMS to PRF",500,1,5,100,0,1);
+  fOutputList->Add(fHistGamma);
+
+  //invariant mass distributions
+  TH3F* fHistMass = new TH3F("fHistMass","",kCentBins,.5,kCentBins+.5,50,0.,5.,400,.3,.7);
+  fOutputList->Add(fHistMass);
+  //TH3F* fHistMassPtCFK0 = new TH3F("fHistMassPtCFK0","",kCentBins,.5,kCentBins+.5,50,0.,5.,200,.4,.6);
+  //fOutputList->Add(fHistMassPtCFK0);
+  //TH3F* fHistMassPtCFBkgK0 = new TH3F("fHistMassPtCFBkgK0","",kCentBins,.5,kCentBins+.5,50,0.,5.,200,.4,.6);
+  //fOutputList->Add(fHistMassPtCFBkgK0);
+  //TH3F* fHistMassQKt = new TH3F("fHistMassQKt","",100,0,1,200,0,2,200,.4,.6);
+  //fOutputList->Add(fHistMassQKt);
+  //TH3F* fHistMassKtK0 = new TH3F("fHistMassKtK0","",kCentBins,.5,kCentBins+.5,300,0.,3.,200,.4,.6);
+  //fOutputList->Add(fHistMassKtK0);
+  //TH3F* fHistMassKtBkgK0 = new TH3F("fHistMassKtBkgK0","",kCentBins,.5,kCentBins+.5,300,0.,3.,200,.4,.6);
+  //fOutputList->Add(fHistMassKtBkgK0);
+
+  //separation studies
+  TH1F* fHistSepNumPos = new TH1F("fHistSepNumPos","",200,0,20);
+  fOutputList->Add(fHistSepNumPos);
+  TH1F* fHistSepDenPos = new TH1F("fHistSepDenPos","",200,0,20);
+  fOutputList->Add(fHistSepDenPos);
+  TH1F* fHistSepNumNeg = new TH1F("fHistSepNumNeg","",200,0,20);
+  fOutputList->Add(fHistSepNumNeg);
+  TH1F* fHistSepDenNeg = new TH1F("fHistSepDenNeg","",200,0,20);
+  fOutputList->Add(fHistSepDenNeg);
+  
+  TH2F* fHistSepNumPos2 = new TH2F("fHistSepNumPos2","",100,0,20,100,0,20);
+  TH2F* fHistSepDenPos2 = new TH2F("fHistSepDenPos2","",100,0,20,100,0,20);
+  TH2F* fHistSepNumNeg2 = new TH2F("fHistSepNumNeg2","",100,0,20,100,0,20);
+  TH2F* fHistSepDenNeg2 = new TH2F("fHistSepDenNeg2","",100,0,20,100,0,20);
+  fOutputList->Add(fHistSepNumPos2);
+  fOutputList->Add(fHistSepDenPos2);
+  fOutputList->Add(fHistSepNumNeg2);
+  fOutputList->Add(fHistSepDenNeg2);
+
+  TH2F* fHistSepDPC = new TH2F("fHistSepDPC","",200,-1,1,50,0,10);
+  TH2F* fHistSepDPCBkg = new TH2F("fHistSepDPCBkg","",200,-1,1,50,0,10);
+  fOutputList->Add(fHistSepDPC);
+  fOutputList->Add(fHistSepDPCBkg);
+
+  TH1F *fHistPsi = new TH1F("fHistPsi","",90,-PI/2,PI/2);
+  fOutputList->Add(fHistPsi);
+  TH2F *fHistPhiPsi = new TH2F("fHistPhiPsi","",kCentBins,.5,kCentBins+.5,180,0,2*PI);
+  fOutputList->Add(fHistPhiPsi);
+
+/////////Pair Distributions///////////////////
+
+  //1D Q invariant
+  TH3F* fHistQinvSignal = new TH3F("fHistQinvSignal","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  fOutputList->Add(fHistQinvSignal);
+  TH3F* fHistQinvBkg = new TH3F("fHistQinvBkg","Mixed Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1.);
+  fOutputList->Add(fHistQinvBkg);
+
+  //event plane
+  TH3F* fHistQinvSignalEPIn = new TH3F("fHistQinvSignalEPIn","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  fOutputList->Add(fHistQinvSignalEPIn);
+  TH3F* fHistQinvBkgEPIn = new TH3F("fHistQinvBkgEPIn","Mixed Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1.);
+  fOutputList->Add(fHistQinvBkgEPIn);
+  TH3F* fHistQinvSignalEPOut = new TH3F("fHistQinvSignalEPOut","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  fOutputList->Add(fHistQinvSignalEPOut);
+  TH3F* fHistQinvBkgEPOut = new TH3F("fHistQinvBkgEPOut","Mixed Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1.);
+  fOutputList->Add(fHistQinvBkgEPOut);
+
+  //mass bins within peak
+  //TH3F* fHistCLCLSignal = new TH3F("fHistCLCLSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistCLCLBkg = new TH3F("fHistCLCLBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistCLCRSignal = new TH3F("fHistCLCRSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistCLCRBkg = new TH3F("fHistCLCRBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistCRCRSignal = new TH3F("fHistCRCRSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistCRCRBkg = new TH3F("fHistCRCRBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //fOutputList->Add(fHistCLCLSignal);
+  //fOutputList->Add(fHistCLCLBkg);
+  //fOutputList->Add(fHistCLCRSignal);
+  //fOutputList->Add(fHistCLCRBkg);
+  //fOutputList->Add(fHistCRCRSignal);
+  //fOutputList->Add(fHistCRCRBkg);
+  
+  //3D out-side-long
+  TH3F *fHist3DOSLSignal[10][4];
+  TH3F *fHist3DOSLBkg[10][4];
+  
+  if(fCase3D){
+   for(int i3D=0;i3D<10;i3D++){
+    for(int j3D=0;j3D<4;j3D++){
+     TString *histname = new TString("fHist3DOSL");
+     *histname += i3D;
+     *histname += j3D;
+     histname->Append("Signal");
+     fHist3DOSLSignal[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);
+     fOutputList->Add(fHist3DOSLSignal[i3D][j3D]);
+     histname->Replace(12,6,"Bkg");
+     fHist3DOSLBkg[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);
+     fOutputList->Add(fHist3DOSLBkg[i3D][j3D]);
+    }
+   }
+  }
+
+  //3D Spherical Harmonics
+  //TH3F* fHistSHCentLowKt = new TH3F("fHistSHCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHCentHighKt = new TH3F("fHistSHCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHSemiCentLowKt = new TH3F("fHistSHSemiCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHSemiCentHighKt = new TH3F("fHistSHSemiCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHCentLowKtBkg = new TH3F("fHistSHCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHCentHighKtBkg = new TH3F("fHistSHCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHSemiCentLowKtBkg = new TH3F("fHistSHSemiCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //TH3F* fHistSHSemiCentHighKtBkg = new TH3F("fHistSHSemiCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);
+  //fOutputList->Add(fHistSHCentLowKt);
+  //fOutputList->Add(fHistSHCentHighKt);
+  //fOutputList->Add(fHistSHSemiCentLowKt);
+  //fOutputList->Add(fHistSHSemiCentHighKt);
+  //fOutputList->Add(fHistSHCentLowKtBkg);
+  //fOutputList->Add(fHistSHCentHighKtBkg);
+  //fOutputList->Add(fHistSHSemiCentLowKtBkg);
+  //fOutputList->Add(fHistSHSemiCentHighKtBkg);
+
+  //side-side
+  //TH3F* fHistLeftLeftSignal = new TH3F("fHistLeftLeftSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistLeftRightSignal = new TH3F("fHistLeftRightSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistRightRightSignal = new TH3F("fHistRightRightSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistLeftLeftBkg = new TH3F("fHistLeftLeftBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistLeftRightBkg = new TH3F("fHistLeftRightBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //TH3F* fHistRightRightBkg = new TH3F("fHistRightRightBkg","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //fOutputList->Add(fHistLeftLeftSignal);
+  //fOutputList->Add(fHistLeftRightSignal);
+  //fOutputList->Add(fHistRightRightSignal);
+  //fOutputList->Add(fHistLeftLeftBkg);
+  //fOutputList->Add(fHistLeftRightBkg);
+  //fOutputList->Add(fHistRightRightBkg);
+
+  //TH3F* fHistSplitK0Sides = new TH3F("fHistSplitK0Sides","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //fOutputList->Add(fHistSplitK0Sides);
+  //TH3F* fHistSplitK0Centers = new TH3F("fHistSplitK0Centers","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //fOutputList->Add(fHistSplitK0Centers);
+  //TH3F* fHistQinvSignalNoSplit = new TH3F("fHistQinvSignalNoSplit","Same Event Pair Distribution", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);
+  //fOutputList->Add(fHistQinvSignalNoSplit);
+
+  PostData(1, fOutputList);
+
+}
+
+//________________________________________________________________________
+void AliFemtoK0Analysis::Exec(Option_t *) 
+{
+  // Main loop
+  // Called for each event
+  //cout<<"===========  Event # "<<fEventCount+1<<"  ==========="<<endl;
+  fEventCount++;
+  fAOD = dynamic_cast<AliAODEvent*> (InputEvent());
+  if (!fAOD) {Printf("ERROR: fAOD not available"); return;}
+
+  Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral));
+  bool isCentral = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kCentral);
+  //Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
+  if(!isSelected) {
+   //cout << "Failed trigger selection." << endl; 
+   return;
+  }
+  
+  ///////////////////////////////////////////////////////////
+
+  unsigned int statusPos=0;
+  unsigned int statusNeg=0;
+
+  float bField=0;
+  bField = fAOD->GetMagneticField();
+  if(bField == 0) return;
+  if(fSignDep){
+   if(fFieldPos && bField < 0) return;
+   if(!fFieldPos && bField > 0) return;
+  }
+
+  
+  int zBin=0;
+  double zStep=2*10/double(kZVertexBins), zstart=-10.;
+
+  /////////////////////////////////////////////////
+
+
+  //Centrality selection
+
+  AliCentrality *centrality = fAOD->GetCentrality();
+  float percent = centrality->GetCentralityPercentile("V0M");
+  int centBin=0;
+  //Printf("Centrality percent = %f", percent);
+  
+  AliAODVZERO *aodV0 = fAOD->GetVZEROData();
+  float multV0A=aodV0->GetMTotV0A();
+  float multV0C=aodV0->GetMTotV0C();
+
+  if(percent < 0) {
+   //Printf("No centrality info"); 
+   return;
+  }
+  if(percent < 0.1 && (multV0A + multV0C < 19500)){
+   //Printf("No centrality info"); 
+   return;
+  }
+  else if(percent <= 5)   centBin=15;
+  else if(percent <= 10)  centBin=14;
+  else if(percent <= 15)  centBin=13;
+  else if(percent <= 20)  centBin=12;
+  else if(percent <= 25)  centBin=11;
+  else if(percent <= 30)  centBin=10;
+  else if(percent <= 35)  centBin=9;
+  else if(percent <= 40)  centBin=8;
+  else if(percent <= 45)  centBin=7;
+  else if(percent <= 50)  centBin=6;
+  else if(percent <= 55)  centBin=5;
+  else if(percent <= 60)  centBin=4;
+  else if(percent <= 65)  centBin=3;
+  else if(percent <= 70)  centBin=2;
+  else if(percent <= 75)  centBin=1;
+  else if(percent <= 80)  centBin=0;
+  else {
+   //Printf("Skipping Peripheral Event"); 
+   return;
+  }
+  if(percent > 10 && isCentral) return;
+  ((TH1F*)fOutputList->FindObject("fHistCent"))->Fill(percent);
+  
+  //flatten centrality dist.
+  if(percent < 9){ 
+   if(fFlatCent){
+    if(RejectEventCentFlat(bField,percent)) return; 
+   }
+  }
+  ((TH1F*)fOutputList->FindObject("fHistCentFlat"))->Fill(percent);
+  
+  //Vertexing
+  AliAODVertex *primaryVertex;
+  double vertex[3]={0};
+  primaryVertex = fAOD->GetPrimaryVertex();
+  vertex[0]=primaryVertex->GetX(); 
+  vertex[1]=primaryVertex->GetY(); 
+  vertex[2]=primaryVertex->GetZ();
+  if(vertex[0]<10e-5 && vertex[1]<10e-5 &&  vertex[2]<10e-5) return;
+  if(fabs(vertex[2]) > 10) return; // Z-vertex Cut
+
+  for(int i=0; i<kZVertexBins; i++)
+  {
+    if((vertex[2] > zstart+i*zStep) && (vertex[2] < zstart+(i+1)*zStep))
+    {
+      zBin=i;
+      break;
+    }
+  }
+  
+  //Event plane
+  int psiBin = 0;
+  AliEventplane *eventplane = fAOD->GetEventplane();
+  if(fPsiBinning && !eventplane) return;
+  double psiEP = eventplane->GetEventplane("V0",fAOD,2); //[-PI/2,PI/2]
+  if(psiEP < -0.25*PI) psiBin = 0;
+  else if(psiEP < 0.0) psiBin = 1;
+  else if(psiEP < 0.25*PI) psiBin = 2;
+  else psiBin = 3;
+  if(!fPsiBinning) psiBin = 0;
+  ((TH1F*)fOutputList->FindObject("fHistPsi"))->Fill(psiEP);
+
+////////////////////////////////////////////////////////////////
+//Cut Values and constants
+
+  //const bool kMCCase = kFALSE;                     //switch for MC analysis
+  const int kMaxNumK0 = 300;                       //maximum number of K0s, array size
+  const float kMinDCAPrimaryPion = 0.4;            //minimum dca of pions to primary
+  const float kMaxDCADaughtersK0 = 0.3;            //maximum dca of pions to each other - 3D
+  const float kMaxDCAK0 = 0.3;                     //maximum dca of K0 to primary
+  const float kMaxDLK0 = 30.0;                     //maximum decay length of K0
+  const float kMinDLK0 = fMinDecayLength;         //minimum decay length of K0
+  const float kEtaCut = 0.8;                       //maximum |pseudorapidity|
+  const float kMinCosAngle = 0.99;                 //minimum cosine of K0 pointing angle     
+  
+  const float kMinSeparation = fMinSep;                //minimum daughter (pair) separation
+                 
+  const float kTOFLow = 0.8;                       //boundary for TOF usage
+  const float kMaxTOFSigmaPion = 3.0;              //TOF # of sigmas
+  const float kMaxTPCSigmaPion = 3.0;              //TPC # of sigmas
+
+  //const float kMassPion = .13957;
+  const float kMassK0Short = .497614;       //true PDG masses
+
+////////////////////////////////////////////////////////////////  
+  //v0 tester
+////////////////////////////////////////////////////////////////
+  int v0Count = 0;     //number of v0s (entries in array)
+  int k0Count = 0;     //number of good K0s
+
+  AliFemtoK0Particle *tempK0 = new AliFemtoK0Particle[kMultLimit];
+
+  //for daughter sharing studies
+  //int idArray[100] = {0};
+  //int idCount = 0;
+
+  //for MC
+  //TClonesArray *mcArray = 0x0;
+  //if(kMCCase){
+  //mcArray = (TClonesArray*)fAOD->FindListObject(AliAODMCParticle::StdBranchName());
+  //if(!mcArray){cout<<"No MC particle branch found"<<endl;return;}}
+
+  for(int i = 0; i < fAOD->GetNumberOfV0s(); i++)
+  {
+    bool goodK0 = kFALSE;
+    bool goodPiPlus = kFALSE;
+    bool goodPiMinus = kFALSE;
+    
+    //load v0 track
+    AliAODv0* v0 = fAOD->GetV0(i);
+    if(!v0) continue;
+    if(fOnlineCase){
+     if(!(v0->GetOnFlyStatus())) continue;
+    } //for online
+    else{
+     if((v0->GetOnFlyStatus())) continue; //for offline
+    }
+    //for on-the-fly ordering
+    AliAODTrack* tempTrack = (AliAODTrack*)v0->GetDaughter(0);
+    short int pos0or1;
+    short int neg0or1;
+    bool orderswitch = kFALSE;
+    if(tempTrack->Charge() > 0) {pos0or1 = 0; neg0or1 = 1;}
+    else {pos0or1 = 1; neg0or1 = 0; orderswitch = kTRUE;}
+
+    //load daughter tracks
+    AliAODTrack* prongTrackPos = (AliAODTrack*)v0->GetDaughter(pos0or1);
+    AliAODTrack* prongTrackNeg = (AliAODTrack*)v0->GetDaughter(neg0or1);
+    if(!prongTrackPos) continue;
+    if(!prongTrackNeg) continue;
+
+    //daughter cuts
+    if(v0->PtProng(pos0or1) < .15) continue;
+    if(v0->PtProng(neg0or1) < .15) continue;
+    if(fabs(v0->EtaProng(pos0or1)) > .8) continue;
+    if(fabs(v0->EtaProng(neg0or1)) > .8) continue;
+
+    //load status for PID
+    statusPos=prongTrackPos->GetStatus();
+    if((statusPos&AliESDtrack::kTPCrefit)==0) continue;
+    prongTrackPos->SetAODEvent(fAOD);
+    statusNeg=prongTrackNeg->GetStatus();
+    if((statusNeg&AliESDtrack::kTPCrefit)==0) continue;
+    prongTrackNeg->SetAODEvent(fAOD);
+
+    //TPC PID
+    if(fabs(fPidAOD->NumberOfSigmasTPC(prongTrackPos,AliPID::kPion)) < kMaxTPCSigmaPion) goodPiPlus = kTRUE;
+    if(fabs(fPidAOD->NumberOfSigmasTPC(prongTrackNeg,AliPID::kPion)) < kMaxTPCSigmaPion) goodPiMinus = kTRUE;
+   
+    //Positive daughter identification TOF
+    float probMis;
+    AliPIDResponse::EDetPidStatus statusPosTOF = fPidAOD->CheckPIDStatus(AliPIDResponse::kTOF, prongTrackPos);
+    double Ppos = v0->PProng(pos0or1);
+    if(Ppos > kTOFLow) //PiPlus
+    {
+     //if( (statusPos&AliESDtrack::kTOFpid)!=0 && (statusPos&AliESDtrack::kTIME)!=0 && (statusPos&AliESDtrack::kTOFout)!=0 && (statusPos&AliESDtrack::kTOFmismatch)<=0) (OBSOLETE; NEW CALL BELOW)
+     if(AliPIDResponse::kDetPidOk == statusPosTOF)
+     {
+      probMis = fPidAOD->GetTOFMismatchProbability(prongTrackPos);
+      if(probMis < 0.01) //avoid TOF-TPC mismatch
+      {
+       if(fabs(fPidAOD->NumberOfSigmasTOF(prongTrackPos,AliPID::kPion)) < kMaxTOFSigmaPion) goodPiPlus = kTRUE;
+       else goodPiPlus = kFALSE;
+      }  
+     }
+    }
+    //Negative daughter identification TOF
+    AliPIDResponse::EDetPidStatus statusNegTOF = fPidAOD->CheckPIDStatus(AliPIDResponse::kTOF, prongTrackNeg);
+    double Pneg = v0->PProng(neg0or1);
+    if(Pneg > kTOFLow) //PiMinus
+    {
+     //if( (statusNeg&AliESDtrack::kTOFpid)!=0 && (statusNeg&AliESDtrack::kTIME)!=0 && (statusNeg&AliESDtrack::kTOFout)!=0 && (statusNeg&AliESDtrack::kTOFmismatch)<=0) (OBSOLETE; NEW CALL BELOW)
+     if(AliPIDResponse::kDetPidOk == statusNegTOF)
+     {
+      probMis = fPidAOD->GetTOFMismatchProbability(prongTrackPos);
+      if(probMis < 0.01) //avoid TOF-TPC mismatch
+      {
+       if(fabs(fPidAOD->NumberOfSigmasTOF(prongTrackNeg,AliPID::kPion)) < kMaxTOFSigmaPion) goodPiMinus = kTRUE;
+       else goodPiMinus = kFALSE;
+      }
+     }
+    }
+    
+    //K0 cuts
+    if(v0->Eta() > kEtaCut)                                    continue;    
+    if(v0->CosPointingAngle(primaryVertex) < kMinCosAngle)     continue;
+    if(v0->MassK0Short() < .2 || v0->MassK0Short() > .8)       continue;
+    if(v0->DcaNegToPrimVertex() < kMinDCAPrimaryPion)          continue;
+    if(v0->DcaPosToPrimVertex() < kMinDCAPrimaryPion)          continue;  
+    if(v0->DecayLength(primaryVertex) > kMaxDLK0)              continue;
+    if(v0->DecayLength(primaryVertex) < kMinDLK0)                      continue;
+    if(v0->DcaV0Daughters() > kMaxDCADaughtersK0)              continue;
+    double v0Dca = v0->DcaV0ToPrimVertex();
+    if(v0Dca > kMaxDCAK0)                                                      continue;        
+    if(!goodPiMinus || !goodPiPlus)                            continue; 
+    
+    //EVERYTHING BELOW HERE PASSES SINGLE PARTICLE CUTS, PION PID, and LOOSE MASS CUT
+
+    //for MC
+    //bool MCgood = kFALSE;
+    //if(kMCCase){
+    //AliAODMCParticle* mck0dp = (AliAODMCParticle*)mcArray->At(abs(prongTrackPos->GetLabel()));
+    //AliAODMCParticle* mck0dn = (AliAODMCParticle*)mcArray->At(abs(prongTrackNeg->GetLabel()));   
+    //if(mck0dp->GetMother() >= 0){ 
+     //if(mck0dp->GetMother() == mck0dn->GetMother()){
+      //if(abs(mck0dp->GetPdgCode()) == 211 && abs(mck0dn->GetPdgCode()) == 211){
+       //AliAODMCParticle* mck0 = (AliAODMCParticle*)mcArray->At(mck0dp->GetMother());
+       //if(abs(mck0->GetPdgCode()) == 310){
+        //MCgood = kTRUE;     
+       //}
+      //}
+     //}
+    //}
+    //}// if kMCCase
+    
+    if(v0->MassK0Short() > .48 && v0->MassK0Short() < .515) goodK0 = kTRUE;
+    //else continue; //removed, Apr 18
+     
+    //Check for shared daughters, using v0 DCA to judge
+    bool v0JudgeNew; //true if new v0 beats old
+    tempK0[v0Count].fSkipShared = kFALSE;
+    double newV0Pars[3] = {fabs(v0->MassK0Short()-kMassK0Short),v0Dca,v0->DcaV0Daughters()}; //parameters used in merit cut
+    if(fMeritCase){
+     for(int iID = 0; iID<v0Count; iID++){
+      if(tempK0[iID].fSkipShared == kFALSE){           //if old is already skipped, go to next old
+       if(tempK0[iID].fDaughterID1 == prongTrackPos->GetID() || tempK0[iID].fDaughterID2 == prongTrackNeg->GetID()){
+        double oldV0Pars[3] = {fabs(tempK0[iID].fMass-kMassK0Short), tempK0[iID].fV0Dca, tempK0[iID].fDDDca}; 
+        v0JudgeNew = CheckMeritCutWinner(fMeritCutChoice, oldV0Pars, newV0Pars); //true if new wins
+        if(!v0JudgeNew){               //if old beats new...
+         if(!tempK0[iID].fK0 && goodK0) continue;      //if bad old beats new good, do nothing...                              
+         else{                                         //but if bad old beats new bad, or good old beats anything, skip new
+          tempK0[v0Count].fSkipShared = kTRUE;         //skip new
+          break;                                       //no need to keep checking others
+         }
+        }
+        else{                                          //if new beats old...
+         if(tempK0[iID].fK0 && !goodK0) continue;      //if bad new beats good old, do nothing...
+         else{                                         //but if bad new beats bad old, or good new beats anything, skip old
+             tempK0[iID].fSkipShared = kTRUE;          //skip old      
+             if(tempK0[iID].fK0) k0Count--;            //if good old gets skipped, subtract from number of K0s (new one will be added later, if it succeeds)
+         }
+        }
+       }
+      }
+     }
+     if(tempK0[v0Count].fSkipShared) continue;         //if new K0 is skipped, don't load; go to next v0
+    }//if MeritCase                    
+       
+    //load parameters into temporary class instance
+    if(v0Count < kMaxNumK0)
+    {
+       if(goodK0){
+         tempK0[v0Count].fK0 = kTRUE;
+         k0Count++;
+        }
+        else tempK0[v0Count].fK0 = kFALSE; 
+
+        //if(v0->MassK0Short() > .45 && v0->MassK0Short() < .48) tempK0[v0Count].fSideLeft = kTRUE;
+        //else tempK0[v0Count].fSideLeft = kFALSE;
+        //if(v0->MassK0Short() > .515 && v0->MassK0Short() < .545) tempK0[v0Count].fSideRight = kTRUE;
+        //else tempK0[v0Count].fSideRight = kFALSE;
+           //if(!goodK0) continue; //no sides, speed up analysis (REDUNDANT RIGHT NOW)
+
+        tempK0[v0Count].fDaughterID1    = prongTrackPos->GetID();
+        tempK0[v0Count].fDaughterID2    = prongTrackNeg->GetID();
+        tempK0[v0Count].fMomentum[0]           = v0->Px();
+        tempK0[v0Count].fMomentum[1]           = v0->Py();
+        tempK0[v0Count].fMomentum[2]           = v0->Pz();
+        tempK0[v0Count].fPt            = v0->Pt();
+        tempK0[v0Count].fMass          = v0->MassK0Short();
+        tempK0[v0Count].fV0Dca         = v0Dca;
+
+        //for hists
+        tempK0[v0Count].fDDDca         = v0->DcaV0Daughters();
+           tempK0[v0Count].fDecayLength        = v0->DecayLength(primaryVertex);
+        tempK0[v0Count].fPosPt         = v0->PtProng(pos0or1);
+        tempK0[v0Count].fNegPt         = v0->PtProng(neg0or1);
+        tempK0[v0Count].fPosPhi                = v0->PhiProng(pos0or1);
+        tempK0[v0Count].fNegPhi                = v0->PhiProng(neg0or1);
+           if(!orderswitch){
+         tempK0[v0Count].fPosDca       = v0->DcaPosToPrimVertex();
+         tempK0[v0Count].fNegDca       = v0->DcaNegToPrimVertex();
+           }
+        else{
+         tempK0[v0Count].fPosDca       = v0->DcaNegToPrimVertex();
+         tempK0[v0Count].fNegDca       = v0->DcaPosToPrimVertex();
+        }
+
+               //for psi studies
+        double v0Phi = v0->Phi(); //between [0,2pi]
+        double v0PhiPsi = v0Phi-psiEP;
+        if(v0PhiPsi < 0) v0PhiPsi += 2.*PI;
+        else if (v0PhiPsi > 2.*PI) v0PhiPsi -= 2.*PI;
+               else{};
+        tempK0[v0Count].fPhiPsi = v0PhiPsi; 
+        
+        //for separation
+        GetGlobalPositionAtGlobalRadiiThroughTPC(prongTrackPos, bField, tempK0[v0Count].fPosXYZ, vertex);
+           GetGlobalPositionAtGlobalRadiiThroughTPC(prongTrackNeg, bField, tempK0[v0Count].fNegXYZ, vertex);
+        //for DPC
+        prongTrackPos->GetPxPyPz(tempK0[v0Count].fPPos);
+        prongTrackNeg->GetPxPyPz(tempK0[v0Count].fPNeg);
+
+        //if(idCount < 50){
+        // if(goodK0){
+        //  idArray[idCount*2]   = prongTrackPos->GetID();
+        //  idArray[idCount*2+1] = prongTrackNeg->GetID();
+        //  idCount++;
+        //}} 
+
+        v0Count++;
+    }
+
+  }//v0
+   
+  if(k0Count<2) return;  //only keep events with more than 1 good K0
+
+  //Add Event to buffer - this is for event mixing
+  fEC[zBin][centBin][psiBin]->FIFOShift();
+  (fEvt) = fEC[zBin][centBin][psiBin]->fEvt;
+  (fEvt)->fFillStatus = 1;
+  int unskippedCount = 0;
+  for(int i=0;i<v0Count;i++)
+  {
+   if(!tempK0[i].fSkipShared)                          //don't include skipped v0s (from shared daughters)
+   {
+    ((TH3F*)fOutputList->FindObject("fHistMass"))->Fill(centBin+1,tempK0[i].fPt,tempK0[i].fMass);
+    if(tempK0[i].fK0)                                  //make sure particle is good (mass)
+    {
+     (fEvt)->fK0Particle[unskippedCount] = tempK0[i];  //load good, unskipped K0s
+     unskippedCount++;                                 //count good, unskipped K0s
+    }
+   }
+  }
+  (fEvt)->fNumV0s = unskippedCount;
+  //Printf("Number of v0s: %d", v0Count);
+  //Printf("Number of K0s: %d", k0Count);
+  delete [] tempK0; tempK0 = NULL;
+
+  ((TH1F*)fOutputList->FindObject("fHistMultK0"))->Fill(unskippedCount);       // changed 3/25, used to be "k0Count"
+  ((TH1F*)fOutputList->FindObject("fHistCentUsed"))->Fill(percent);
+
+  //Printf("Reconstruction Finished. Starting pair studies.");
+
+  //////////////////////////////////////////////////////////////////////
+  // Correlations
+  //////////////////////////////////////////////////////////////////////
+
+  float px1, py1, pz1, px2, py2, pz2;                  //single kaon values
+  float en1, en2;                                                              //single kaon values 
+  //float pt1, pt2;                                                            //single kaon values
+  float pairPx, pairPy, pairPz, pairP0;                        //pair momentum values
+  float pairPt, pairMt, pairKt;                        //pair momentum values
+  float pairMInv, pairPDotQ;
+  float qinv, q0, qx, qy, qz;                          //pair q values
+  //float qLength, thetaSH, thetaSHCos, phiSH;            //Spherical Harmonics values
+  float am12, epm, h1, p12, p112, ppx, ppy, ppz, ks;   //PRF
+  //float qOutLCMS;
+  float qOutPRF, qSide, qLong;                         //relative momentum in LCMS/PRF frame
+  float betasq, gamma;
+  float p1LCMSOut, p1LCMSSide, p1LCMSLong, en1LCMS;
+  float p2LCMSOut, p2LCMSSide, p2LCMSLong, en2LCMS;
+
+
+  for(int i=0; i<(fEvt)->fNumV0s; i++) // Current event V0
+  {
+    //single particle histograms (done here to avoid "skipped" v0s
+    ((TH1F*)fOutputList->FindObject("fHistDCADaughters"))      ->Fill((fEvt)->fK0Particle[i].fDDDca);
+    ((TH1F*)fOutputList->FindObject("fHistDecayLengthK0"))     ->Fill((fEvt)->fK0Particle[i].fDecayLength);
+    ((TH1F*)fOutputList->FindObject("fHistDCAK0"))             ->Fill((fEvt)->fK0Particle[i].fV0Dca);
+    ((TH1F*)fOutputList->FindObject("fHistDCAPiMinus"))        ->Fill((fEvt)->fK0Particle[i].fNegDca);
+    ((TH1F*)fOutputList->FindObject("fHistDCAPiPlus"))         ->Fill((fEvt)->fK0Particle[i].fPosDca);
+    ((TH2F*)fOutputList->FindObject("fHistPtK0"))              ->Fill(centBin+1, (fEvt)->fK0Particle[i].fPt);
+    ((TH2F*)fOutputList->FindObject("fHistK0PiPlusPt"))        ->Fill(centBin+1, (fEvt)->fK0Particle[i].fPosPt);
+    ((TH2F*)fOutputList->FindObject("fHistK0PiMinusPt"))       ->Fill(centBin+1, (fEvt)->fK0Particle[i].fNegPt);
+    ((TH1F*)fOutputList->FindObject("fHistDaughterPhi"))       ->Fill((fEvt)->fK0Particle[i].fPosPhi);
+    ((TH1F*)fOutputList->FindObject("fHistDaughterPhi"))       ->Fill((fEvt)->fK0Particle[i].fNegPhi);
+    
+    ((TH1F*)fOutputList->FindObject("fHistPx"))                ->Fill((fEvt)->fK0Particle[i].fMomentum[0]);
+    ((TH1F*)fOutputList->FindObject("fHistPy"))                ->Fill((fEvt)->fK0Particle[i].fMomentum[1]);
+    ((TH1F*)fOutputList->FindObject("fHistPz"))                ->Fill((fEvt)->fK0Particle[i].fMomentum[2]);
+
+    ((TH2F*)fOutputList->FindObject("fHistPhiPsi"))    ->Fill(centBin+1,(fEvt)->fK0Particle[i].fPhiPsi);
+
+    for(int evnum=0; evnum<kEventsToMix+1; evnum++)// Event buffer loop: evnum=0 is the current event, all other evnum's are past events
+    {
+      int startbin=0;
+      if(evnum==0) startbin=i+1;
+      
+      for(int j=startbin; j<(fEvt+evnum)->fNumV0s; j++) // Past event V0
+      {
+        if(evnum==0)  // Get rid of shared tracks
+        {
+          if((fEvt)->fK0Particle[i].fDaughterID1 == (fEvt+evnum)->fK0Particle[j].fDaughterID1) continue;
+                 if((fEvt)->fK0Particle[i].fDaughterID1 == (fEvt+evnum)->fK0Particle[j].fDaughterID2) continue;
+             if((fEvt)->fK0Particle[i].fDaughterID2 == (fEvt+evnum)->fK0Particle[j].fDaughterID1) continue;
+             if((fEvt)->fK0Particle[i].fDaughterID2 == (fEvt+evnum)->fK0Particle[j].fDaughterID2) continue;
+           }
+            
+        px1 = (fEvt)->fK0Particle[i].fMomentum[0];
+               py1 = (fEvt)->fK0Particle[i].fMomentum[1];
+               pz1 = (fEvt)->fK0Particle[i].fMomentum[2];
+        //pt1 = (fEvt)->fK0Particle[i].fPt;
+               px2 = (fEvt+evnum)->fK0Particle[j].fMomentum[0];
+               py2 = (fEvt+evnum)->fK0Particle[j].fMomentum[1];
+               pz2 = (fEvt+evnum)->fK0Particle[j].fMomentum[2];
+        //pt2 = (fEvt+evnum)->fK0Particle[j].fPt;
+        if(fRandomNumber->Rndm() < .5){        //switch particle order for 3D qout bias
+                double tempvar;
+         tempvar = px1; px1 = px2; px2 = tempvar;
+         tempvar = py1; py1 = py2; py2 = tempvar;
+         tempvar = pz1; pz1 = pz2; pz2 = tempvar;
+               }
+
+               en1  = sqrt(pow(px1,2)+pow(py1,2)+pow(pz1,2)+pow(kMassK0Short,2));
+               en2  = sqrt(pow(px2,2)+pow(py2,2)+pow(pz2,2)+pow(kMassK0Short,2));
+
+        q0 = en1 - en2;
+        qx = px1 - px2;
+        qy = py1 - py2;
+        qz = pz1 - pz2;
+        qinv = sqrt(pow(qx,2) + pow(qy,2) + pow(qz,2) - pow(q0,2));
+
+        pairPx = px1 + px2;
+               pairPy = py1 + py2;
+               pairPz = pz1 + pz2;
+        pairP0 = en1 + en2;
+               pairPt = sqrt(pairPx*pairPx + pairPy*pairPy);
+        pairKt = pairPt/2.;                                                                    //used for KT binning
+        pairMt = sqrt(pairP0*pairP0 - pairPz*pairPz);          //used for LCMS (not plots)
+               pairMInv = sqrt(pow(pairP0,2)-pow(pairPx,2)-pow(pairPy,2)-pow(pairPz,2));//used for PRF
+        pairPDotQ = pairP0*q0-pairPx*qx-pairPy*qy-pairPz*qz;   //used for PRF
+
+           //PRF (this section will probably be removed in favor of later boosting section)
+        p12 = sqrt(pow(pairPx,2)+pow(pairPy,2)+pow(pairPz,2)); //pair momentum length
+        am12 = sqrt(pow(en1+en2,2)-p12*p12);                                   //sqrt(s)=|p1+p2|(4vec)
+        epm = en1+en2+am12;                                                                            //"energy plus mass"
+        p112 = px1*pairPx+py1*pairPy+pz1*pairPz;                               //proj. of p1 on pairP
+        if(am12 == 0) continue;
+        h1 = (p112/epm - en1)/am12;
+        ppx = px1+pairPx*h1;                                                                   //px in PRF
+        ppy = py1+pairPy*h1;                                                                   //py in PRF     
+        ppz = pz1+pairPz*h1;                                                                   //pz in PRF
+        ks = sqrt(ppx*ppx+ppy*ppy+ppz*ppz);                                            //k*
+        ((TH1F*)fOutputList->FindObject("fHistPxCM"))->Fill(ppx);
+        ((TH1F*)fOutputList->FindObject("fHistPyCM"))->Fill(ppy);
+        ((TH1F*)fOutputList->FindObject("fHistPzCM"))->Fill(ppz);
+        ((TH1F*)fOutputList->FindObject("fHistKsCM"))->Fill(ks);
+        
+        //relative momentum in out-side-long for LCMS and PRF
+        if(pairMt == 0 || pairPt == 0) continue;
+        qLong = (pairP0*qz - pairPz*q0)/pairMt;        //same for both frames
+        qSide = (pairPx*qy - pairPy*qx)/pairPt;        //same for both frames
+        //qOutLCMS = (pairPx*qx + pairPy*qy)/pairPt;
+               qOutPRF  = pairMInv*(pairPx*qx+pairPy*qy)/pairMt/pairPt - pairPt*pairPDotQ/pairMt/pairMInv;
+        
+               //finding gamma for gamma binning/hists (likely will be removed after tests)
+               p1LCMSOut  = (pairPx*px1+pairPy*py1)/pairPt;
+               p1LCMSSide = (pairPx*py1-pairPy*px1)/pairPt;
+               p1LCMSLong = (pairP0*pz1-pairPz*en1)/pairMt;
+               p2LCMSOut  = (pairPx*px2+pairPy*py2)/pairPt;
+               p2LCMSSide = (pairPx*py2-pairPy*px2)/pairPt;
+               p2LCMSLong = (pairP0*pz2-pairPz*en2)/pairMt;
+               en1LCMS = sqrt(pow(p1LCMSOut,2)+pow(p1LCMSSide,2)+pow(p1LCMSLong,2)+pow(kMassK0Short,2));
+               en2LCMS = sqrt(pow(p2LCMSOut,2)+pow(p2LCMSSide,2)+pow(p2LCMSLong,2)+pow(kMassK0Short,2));               
+               betasq = pow((p1LCMSOut+p2LCMSOut)/(en1LCMS+en2LCMS),2);
+               gamma = 1./sqrt(1-betasq);
+               ((TH2F*)fOutputList->FindObject("fHistGamma"))->Fill(gamma,qinv);
+               ((TH1F*)fOutputList->FindObject("fHistPOutLCMS"))->Fill(p1LCMSOut);
+               ((TH1F*)fOutputList->FindObject("fHistPSideLCMS"))->Fill(p1LCMSSide);
+               ((TH1F*)fOutputList->FindObject("fHistPLongLCMS"))->Fill(p1LCMSLong);
+               ((TH1F*)fOutputList->FindObject("fHistPOutLCMS"))->Fill(p2LCMSOut);
+               ((TH1F*)fOutputList->FindObject("fHistPSideLCMS"))->Fill(p2LCMSSide);
+               ((TH1F*)fOutputList->FindObject("fHistPLongLCMS"))->Fill(p2LCMSLong);
+               //getting bin numbers and names for 3D histogram
+        TString *histname3D = new TString("fHist3DOSL");
+        int ktBin;
+        if(pairKt < 0.6) ktBin = 0;
+               else if(pairKt < 0.8) ktBin = 1;
+               else if(pairKt < 1.0) ktBin = 2;
+               else ktBin = 3;
+               *histname3D += centBin-6; //centBins: [6,15] -> array bins: [0,9]
+               *histname3D += ktBin;
+
+        //Spherical harmonics
+        //qLength = sqrt(qLong*qLong + qSide*qSide + qOutPRF*qOutPRF);
+        //thetaSHCos = qLong/qLength;
+        //thetaSH = acos(thetaSHCos);
+        //phiSH = acos(qOutPRF/(qLength*sin(thetaSH)));
+
+        //Finding average separation of daughters throughout TPC - two-track cut
+        float posPositions1[9][3] = {{0}};
+        float negPositions1[9][3] = {{0}};
+        float posPositions2[9][3] = {{0}};
+        float negPositions2[9][3] = {{0}};
+        for(int iPos = 0; iPos < 9; iPos++){
+         for(int jPos = 0; jPos < 3; jPos++){
+           posPositions1[iPos][jPos] = (fEvt)->fK0Particle[i].fPosXYZ[iPos][jPos];
+           negPositions1[iPos][jPos] = (fEvt)->fK0Particle[i].fNegXYZ[iPos][jPos];
+           posPositions2[iPos][jPos] = (fEvt+evnum)->fK0Particle[j].fPosXYZ[iPos][jPos];
+           negPositions2[iPos][jPos] = (fEvt+evnum)->fK0Particle[j].fNegXYZ[iPos][jPos];
+         }
+        }    
+        float pMean = 0.;      //average separation for positive daughters
+        float nMean = 0.;      //average separation for negative daughters
+        float pDiff;           
+        float nDiff;
+        float pMin = 9999.;    //minimum separation (updates) - pos
+        float nMin = 9999.;    //minimum separation (updates) - neg
+        double pCount=0;       //counter for number of points used - pos
+        double nCount=0;       //counter for number of points used - neg
+        for(int ss=0;ss<9;ss++){
+         if(posPositions1[ss][0] != -9999 && posPositions2[ss][0] != -9999){          
+          pCount++;
+          pDiff = sqrt(pow(posPositions1[ss][0]-posPositions2[ss][0],2)+pow(posPositions1[ss][1]-posPositions2[ss][1],2)+pow(posPositions1[ss][2]-posPositions2[ss][2],2));
+          pMean = pMean + pDiff;
+          if(pDiff < pMin) pMin = pDiff;
+         }
+         if(negPositions1[ss][0] != -9999 && negPositions1[ss][0] != -9999){
+          nCount++;
+          nDiff = sqrt(pow(negPositions1[ss][0]-negPositions2[ss][0],2)+pow(negPositions1[ss][1]-negPositions2[ss][1],2)+pow(negPositions1[ss][2]-negPositions2[ss][2],2));     
+          nMean = nMean + nDiff;
+          if(nDiff < nMin) nMin = nDiff;
+         }
+        }
+        pMean = pMean/pCount; 
+        nMean = nMean/nCount;     
+
+        if(evnum==0){ 
+         ((TH1F*)fOutputList->FindObject("fHistSepNumPos"))->Fill(pMean); 
+         ((TH1F*)fOutputList->FindObject("fHistSepNumNeg"))->Fill(nMean);
+         ((TH2F*)fOutputList->FindObject("fHistSepNumPos2"))->Fill(pMean,pMin);
+         ((TH2F*)fOutputList->FindObject("fHistSepNumNeg2"))->Fill(nMean,nMin);
+        }
+        else{
+         ((TH1F*)fOutputList->FindObject("fHistSepDenPos"))->Fill(pMean); 
+         ((TH1F*)fOutputList->FindObject("fHistSepDenNeg"))->Fill(nMean);
+         ((TH2F*)fOutputList->FindObject("fHistSepDenPos2"))->Fill(pMean,pMin);
+         ((TH2F*)fOutputList->FindObject("fHistSepDenNeg2"))->Fill(nMean,nMin);
+        }
+
+        //Decay plane coincidence
+        //daughter momenta
+        float a1 = (fEvt)->fK0Particle[i].fPPos[0];
+        float b1 = (fEvt)->fK0Particle[i].fPPos[1];
+        float c1 = (fEvt)->fK0Particle[i].fPPos[2];
+        float d1 = (fEvt)->fK0Particle[i].fPNeg[0];
+        float e1 = (fEvt)->fK0Particle[i].fPNeg[1];
+        float f1 = (fEvt)->fK0Particle[i].fPNeg[2];
+        float a2 = (fEvt+evnum)->fK0Particle[j].fPPos[0];
+        float b2 = (fEvt+evnum)->fK0Particle[j].fPPos[1];
+        float c2 = (fEvt+evnum)->fK0Particle[j].fPPos[2];
+        float d2 = (fEvt+evnum)->fK0Particle[j].fPNeg[0];
+        float e2 = (fEvt+evnum)->fK0Particle[j].fPNeg[1];
+        float f2 = (fEvt+evnum)->fK0Particle[j].fPNeg[2];
+        float cross1[3];
+        float cross2[3];
+        cross1[0] = b1*f1-c1*e1;
+        cross1[1] = c1*d1-a1*f1;
+        cross1[2] = a1*e1-b1*d1;
+        cross2[0] = b2*f2-c2*e2;
+        cross2[1] = c2*d2-a2*f2;
+        cross2[2] = a2*e2-b2*d2;
+        float crosslength1 = sqrt(pow(cross1[0],2)+pow(cross1[1],2)+pow(cross1[2],2));
+        float crosslength2 = sqrt(pow(cross2[0],2)+pow(cross2[1],2)+pow(cross2[2],2));
+        float dpc = (cross1[0]*cross2[0]+cross1[1]*cross2[1]+cross1[2]*cross2[2])/(crosslength1*crosslength2);
+
+        if(evnum==0)((TH2F*)fOutputList->FindObject("fHistSepDPC"))->Fill(dpc,pMean);
+        else ((TH2F*)fOutputList->FindObject("fHistSepDPCBkg"))->Fill(dpc,pMean);
+       
+        if(pMean < kMinSeparation || nMean < kMinSeparation) continue; //using the "new" method (ala Hans)
+        //end separation studies
+
+        //Fill Histograms
+        bool center1K0   = kFALSE;  //accepted mass K0
+           bool center2K0   = kFALSE;
+        if((fEvt)->fK0Particle[i].fK0) center1K0=kTRUE;
+        if((fEvt+evnum)->fK0Particle[j].fK0) center2K0=kTRUE;
+        //bool CL1 = kFALSE;
+        //bool CL2 = kFALSE;
+        //bool CR1 = kFALSE;
+        //bool CR2 = kFALSE;
+        //if(center1K0 && center2K0){
+        // if((fEvt)->fK0Particle[i].fMass < kMassK0Short) CL1 = kTRUE;
+        // else CR1 = kTRUE;
+        // if((fEvt+evnum)->fK0Particle[j].fMass < kMassK0Short) CL2 = kTRUE;
+        // else CR2 = kTRUE;
+        //}
+       
+        //bool SideLeft1 = kFALSE;
+        //bool SideLeft2 = kFALSE;
+        //bool SideRight1 = kFALSE;
+        //bool SideRight2 = kFALSE;
+        //if((fEvt)->fK0Particle[i].fSideLeft) SideLeft1 = kTRUE;
+        //else if((fEvt)->fK0Particle[i].fSideRight) SideRight1 = kTRUE;
+        //if((fEvt+evnum)->fK0Particle[j].fSideLeft) SideLeft2 = kTRUE;
+        //else if((fEvt+evnum)->fK0Particle[j].fSideRight) SideRight2 = kTRUE;
+
+        //for psi binning
+               float phipsi1 = (fEvt)->fK0Particle[i].fPhiPsi;
+        float phipsi2 = (fEvt+evnum)->fK0Particle[j].fPhiPsi;
+        bool inPlane1 = kFALSE;
+        bool inPlane2 = kFALSE; 
+        if(phipsi1 > PI) phipsi1 = phipsi1-PI;
+        if(phipsi2 > PI) phipsi2 = phipsi2-PI;
+        if(phipsi1 < 0.25*PI || phipsi1 > 0.75*PI) inPlane1 = kTRUE;
+        if(phipsi2 < 0.25*PI || phipsi2 > 0.75*PI) inPlane2 = kTRUE;
+       
+
+        if(evnum==0) //Same Event
+        {     
+          //((TH3F*)fOutputList->FindObject("fHistMassQKt"))->Fill(qinv, pairKt, (fEvt)->fK0Particle[i].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassQKt"))->Fill(qinv, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassKtK0"))->Fill(centBin+1, pairKt, (fEvt)->fK0Particle[i].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassKtK0"))->Fill(centBin+1, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassPtCFK0"))->Fill(centBin+1, pt1, (fEvt)->fK0Particle[i].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassPtCFK0"))->Fill(centBin+1, pt2, (fEvt+evnum)->fK0Particle[j].fMass);
+
+          if(center1K0 && center2K0){
+           //1D
+           ((TH3F*)fOutputList->FindObject("fHistQinvSignal"))->Fill(centBin+1, pairKt, qinv);
+           //if(!splitK0centers)((TH3F*)fOutputList->FindObject("fHistQinvSignalNoSplit"))->Fill(centBin+1, pairKt, qinv);
+           ((TH2F*)fOutputList->FindObject("fHistKtK0"))->Fill(centBin+1, pairKt);
+
+                  //eventplane
+           if(inPlane1 && inPlane2)
+             ((TH3F*)fOutputList->FindObject("fHistQinvSignalEPIn"))->Fill(centBin+1, pairKt, qinv);
+           else if(!inPlane1 && !inPlane2)
+             ((TH3F*)fOutputList->FindObject("fHistQinvSignalEPOut"))->Fill(centBin+1, pairKt, qinv);
+           
+           //for mass bin study
+           //if(CL1 && CL2) ((TH3F*)fOutputList->FindObject("fHistCLCLSignal"))->Fill(centBin+1, pairKt, qinv);           
+           //else if ((CL1 && CR2) || (CR1 && CL2)) ((TH3F*)fOutputList->FindObject("fHistCLCRSignal"))->Fill(centBin+1, pairKt, qinv);
+           //else ((TH3F*)fOutputList->FindObject("fHistCRCRSignal"))->Fill(centBin+1, pairKt, qinv);
+
+           //3D
+           if(fCase3D){
+            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){
+                    histname3D->Append("Signal");
+                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);
+                   }
+           }  
+           /*if(pairKt < 1.0){
+            if(centBin > 13){
+             ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKt"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHCentLowKt"))->Fill(qLength,thetaSHCos,phiSH);}
+            else if(centBin > 9){
+             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentLowKt"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentLowKt"))->Fill(qLength,thetaSHCos,phiSH);}}            
+           else if(pairKt < 2.0){
+            if(centBin > 13){
+             ((TH3F*)fOutputList->FindObject("fHistOSLCentHighKt"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHCentHighKt"))->Fill(qLength,thetaSHCos, phiSH);}
+            else if(centBin > 9){
+             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentHighKt"))->Fill(qOutPRF,qSide,qLong);
+
+             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentHighKt"))->Fill(qLength, thetaSHCos, phiSH);}}*/                  
+
+          }//centercenter
+
+          //side-side correlations
+          //if(!splitK0sides){
+          // if(SideLeft1 && SideLeft2) ((TH3F*)fOutputList->FindObject("fHistLeftLeftSignal"))->Fill(centBin+1, pairKt, qinv);
+           //else if((SideLeft1 && SideRight2) || (SideRight1 && SideLeft2)) ((TH3F*)fOutputList->FindObject("fHistLeftRightSignal"))->Fill(centBin+1, pairKt, qinv);
+           //else if(SideRight1 && SideRight2) ((TH3F*)fOutputList->FindObject("fHistRightRightSignal"))->Fill(centBin+1, pairKt, qinv);
+         //}
+
+        }//same event
+
+        else //Mixed Events
+        {
+          //((TH3F*)fOutputList->FindObject("fHistMassKtBkgK0"))->Fill(centBin+1, pairKt, (fEvt)->fK0Particle[i].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassKtBkgK0"))->Fill(centBin+1, pairKt, (fEvt+evnum)->fK0Particle[j].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassPtCFBkgK0"))->Fill(centBin+1, pt1, (fEvt)->fK0Particle[i].fMass);
+          //((TH3F*)fOutputList->FindObject("fHistMassPtCFBkgK0"))->Fill(centBin+1, pt2, (fEvt+evnum)->fK0Particle[j].fMass);
+
+          if(center1K0 && center2K0){
+           //1D
+           ((TH3F*)fOutputList->FindObject("fHistQinvBkg"))->Fill(centBin+1, pairKt, qinv);
+
+                  //eventplane
+           if(inPlane1 && inPlane2)
+             ((TH3F*)fOutputList->FindObject("fHistQinvBkgEPIn"))->Fill(centBin+1, pairKt, qinv);
+           else if(!inPlane1 && !inPlane2)
+             ((TH3F*)fOutputList->FindObject("fHistQinvBkgEPOut"))->Fill(centBin+1, pairKt, qinv);
+
+           //for mass bin study
+           //if(CL1 && CL2) ((TH3F*)fOutputList->FindObject("fHistCLCLBkg"))->Fill(centBin+1, pairKt, qinv);      
+           //else if ((CL1 && CR2) || (CR1 && CL2)) ((TH3F*)fOutputList->FindObject("fHistCLCRBkg"))->Fill(centBin+1, pairKt, qinv);
+           //else ((TH3F*)fOutputList->FindObject("fHistCRCRBkg"))->Fill(centBin+1, pairKt, qinv);
+
+           //3D
+           if(fCase3D){
+            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){
+                    histname3D->Replace(12,6,"Bkg");
+                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);
+                   }
+           }
+           /*if(pairKt < 1.0){
+            if(centBin > 13){
+             ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKtBkg"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHCentLowKtBkg"))->Fill(qLength,thetaSHCos,phiSH);}
+            else if(centBin > 9){
+             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentLowKtBkg"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentLowKtBkg"))->Fill(qLength,thetaSHCos,phiSH);}}
+           else if(pairKt < 2.0){
+            if(centBin > 13){
+             ((TH3F*)fOutputList->FindObject("fHistOSLCentHighKtBkg"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHCentHighKtBkg"))->Fill(qLength, thetaSHCos, phiSH);}
+            else if(centBin > 9){
+             ((TH3F*)fOutputList->FindObject("fHistOSLSemiCentHighKtBkg"))->Fill(qOutPRF,qSide,qLong);
+             ((TH3F*)fOutputList->FindObject("fHistSHSemiCentHighKtBkg"))->Fill(qLength, thetaSHCos, phiSH);}}*/
+          }
+
+          //side-side correlations
+          //if(SideLeft1 && SideLeft2) ((TH3F*)fOutputList->FindObject("fHistLeftLeftBkg"))->Fill(centBin+1, pairKt, qinv);
+          //else if((SideLeft1 && SideRight2) || (SideRight1 && SideLeft2)) ((TH3F*)fOutputList->FindObject("fHistLeftRightBkg"))->Fill(centBin+1, pairKt, qinv);
+          //else if(SideRight1 && SideRight2) ((TH3F*)fOutputList->FindObject("fHistRightRightBkg"))->Fill(centBin+1, pairKt, qinv);
+
+        }//Mixed Events
+      }//past event
+    }//event buffer
+  }//current event
+
+  // Post output data.
+  PostData(1, fOutputList);
+  
+  }
+//________________________________________________________________________
+void AliFemtoK0Analysis::Terminate(Option_t *) 
+{
+  // Called once at the end of the query
+  cout<<"Done"<<endl;
+
+}
+
+//_________________________________________________________________________
+void AliFemtoK0Analysis::GetGlobalPositionAtGlobalRadiiThroughTPC(const AliAODTrack *track, const Float_t bfield, Float_t globalPositionsAtRadii[9][3], double PrimaryVertex[3]){
+  // Gets the global position of the track at nine different radii in the TPC
+  // track is the track you want to propagate
+  // bfield is the magnetic field of your event
+  // globalPositionsAtRadii is the array of global positions in the radii and xyz
+  
+  // Initialize the array to something indicating there was no propagation
+  for(Int_t i=0;i<9;i++){
+    for(Int_t j=0;j<3;j++){
+      globalPositionsAtRadii[i][j]=-9999.;
+    }
+  }
+
+   // Make a copy of the track to not change parameters of the track
+  AliExternalTrackParam etp; etp.CopyFromVTrack(track);
+  //printf("\nAfter CopyFromVTrack\n");
+  //etp.Print();
+  // The global position of the the track
+  Double_t xyz[3]={-9999.,-9999.,-9999.};  
+
+  // Counter for which radius we want
+  Int_t iR=0; 
+  // The radii at which we get the global positions
+  // IROC (OROC) from 84.1 cm to 132.1 cm (134.6 cm to 246.6 cm)
+  Float_t Rwanted[9]={85.,105.,125.,145.,165.,185.,205.,225.,245.}; 
+  // The global radius we are at
+  Float_t globalRadius=0;
+
+  // Propagation is done in local x of the track
+  for (Float_t x = etp.GetX();x<247.;x+=1.){ // GetX returns local coordinates
+    // Starts at the tracks fX and goes outwards. x = 245 is the outer radial limit
+    // of the TPC when the track is straight, i.e. has inifinite pt and doesn't get bent.
+    // If the track's momentum is smaller than infinite, it will develop a y-component, which
+    // adds to the global radius
+
+    // Stop if the propagation was not succesful. This can happen for low pt tracks
+    // that don't reach outer radii
+    if(!etp.PropagateTo(x,bfield))break;
+    etp.GetXYZ(xyz); // GetXYZ returns global coordinates
+    globalRadius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); //Idea to speed up: compare squared radii
+
+    // Roughly reached the radius we want
+    if(globalRadius > Rwanted[iR]){
+      
+      // Bigger loop has bad precision, we're nearly one centimeter too far, go back in small steps.
+      while (globalRadius>Rwanted[iR]){
+        x-=.1;
+        //      printf("propagating to x %5.2f\n",x);
+        if(!etp.PropagateTo(x,bfield))break;
+        etp.GetXYZ(xyz); // GetXYZ returns global coordinates
+        globalRadius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); //Idea to speed up: compare squared radii
+      }
+      //printf("At Radius:%05.2f (local x %5.2f). Setting position to x %4.1f y %4.1f z %4.1f\n",globalRadius,x,xyz[0],xyz[1],xyz[2]);
+      globalPositionsAtRadii[iR][0]=xyz[0];
+      globalPositionsAtRadii[iR][1]=xyz[1];
+      globalPositionsAtRadii[iR][2]=xyz[2];
+      //subtract primary vertex, "zero" track for correct mixed-event comparison
+      globalPositionsAtRadii[iR][0] -= PrimaryVertex[0];
+      globalPositionsAtRadii[iR][1] -= PrimaryVertex[1];
+      globalPositionsAtRadii[iR][2] -= PrimaryVertex[2];
+
+      // Indicate we want the next radius    
+      iR+=1;
+    }
+    if(iR>=8){
+      // TPC edge reached
+      return;
+    }
+  }
+}
+
+bool AliFemtoK0Analysis::CheckMeritCutWinner(int cutChoice, double oldPars[3], double newPars[3]){
+ //performs "merit cut" judgement check on v0s with shared daughters, using one of three criteria.
+ //if cutChoice = 4, it uses all three criteria, needed 2 of 3 'points'
+
+ bool newV0Wins = kFALSE;
+ double pardiff[3] = {newPars[0]-oldPars[0],
+                      newPars[1]-oldPars[1],
+                      newPars[2]-oldPars[2]};
+ if(cutChoice > 0 && cutChoice < 4){
+  if(pardiff[cutChoice] <= 0.) newV0Wins = kTRUE;
+ }
+ else if(cutChoice == 4){
+  int newWinCount = 0;
+  for(int i=0;i<3;i++){if(pardiff[i+1] <= 0) newWinCount++;}
+  if(newWinCount > 1) newV0Wins = kTRUE;  
+ }
+ else{};
+ return newV0Wins;
+}
+
+bool AliFemtoK0Analysis::RejectEventCentFlat(float MagField, float CentPercent)
+{ // to flatten centrality distribution
+ bool RejectEvent = kFALSE;
+ int weightBinSign;
+ if(MagField > 0) weightBinSign = 0;
+ else weightBinSign = 1;
+ float kCentWeight[2][9] = {{.878,.876,.860,.859,.859,.88,.873,.879,.894},
+                                                {.828,.793,.776,.772,.775,.796,.788,.804,.839}};
+ int weightBinCent = (int) CentPercent;
+ if(fRandomNumber->Rndm() > kCentWeight[weightBinSign][weightBinCent]) RejectEvent = kTRUE;
+
+ return RejectEvent;
+}
index b29b321c3b983c8ce6300df538c7cb4dadf460ea..56f08e2b654f735b29cee1d84e0a8151246651fb 100644 (file)
@@ -1,84 +1,87 @@
-#ifndef ALIFEMTOK0ANALYSIS_H\r
-#define ALIFEMTOK0ANALYSIS_H\r
-\r
-//\r
-// Class AliFemtoK0Analysis\r
-//\r
-// AliFemtoK0Analysis\r
-// author:\r
-//        Matthew Steinpreis (matthew.steinpreis@cern.ch)\r
-//\r
-\r
-class TH1F;\r
-class TH1D;\r
-class TH2D;\r
-class TH3D;\r
-class TProfile;\r
-class TRandom3;\r
-\r
-class AliESDEvent;\r
-class AliAODEvent;\r
-class AliESDtrackCuts;\r
-class AliESDpid;\r
-\r
-#include "AliAnalysisTask.h"\r
-#include "AliAnalysisTaskSE.h"\r
-#include "AliFemtoK0EventCollection.h"\r
-#include "AliAODpidUtil.h"\r
-#include "AliESDpid.h"\r
-\r
-class AliFemtoK0Analysis : public AliAnalysisTaskSE {\r
- public:\r
-  AliFemtoK0Analysis();\r
-  AliFemtoK0Analysis(const char *name, bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, bool Case3D = kFALSE, float MinDL = 0.0, int MeritCutChoice = 2, float MinSep = 5.0, bool FlatCent = kFALSE);\r
-  virtual ~AliFemtoK0Analysis();\r
-  AliFemtoK0Analysis(const AliFemtoK0Analysis&);\r
-  AliFemtoK0Analysis& operator=(const AliFemtoK0Analysis&);\r
-\r
- private:\r
-  \r
-  virtual void   UserCreateOutputObjects();\r
-  virtual void   Exec(Option_t *option);\r
-  virtual void   Terminate(Option_t *);  \r
-\r
-  void MyInit();\r
-  void GetGlobalPositionAtGlobalRadiiThroughTPC(const AliAODTrack *track, const Float_t bfield, Float_t globalPositionsAtRadii[9][3], double PrimaryVertex[3]);\r
-  bool CheckMeritCutWinner(int cutChoice, double oldPars[3], double newPars[3]);\r
-  bool RejectEventCentFlat(float MagField, float CentPercent);\r
-  \r
-  enum \r
-  {\r
-    kCentBins    = 16,\r
-    kZVertexBins = 10,\r
-    kEventsToMix =  5,\r
-    kMultLimit   = 300,              //maximum number of v0s, array size\r
\r
-    ncthetabins = 36,\r
-    nphibins    = 72\r
-  };\r
-\r
-  bool fSignDep;\r
-  bool fFieldPos;\r
-  bool fOnlineCase;\r
-  bool fMeritCase;\r
-  bool fCase3D;\r
-  float fMinDecayLength;\r
-  int fMeritCutChoice;\r
-  float fMinSep;\r
-  bool fFlatCent;\r
-  int fEventCount;\r
-\r
-  AliFemtoK0EventCollection ***fEC; //!\r
-  AliFemtoK0Event *fEvt; //!\r
-\r
-  TRandom3* fRandomNumber; //!\r
-  \r
-  const char     *fName;\r
-  AliAODEvent    *fAOD; //!    // AOD object\r
-  TList          *fOutputList; //! Compact Output list\r
-  AliPIDResponse *fPidAOD; //!\r
-  \r
-  ClassDef(AliFemtoK0Analysis, 1); \r
-};\r
-\r
-#endif\r
+#ifndef ALIFEMTOK0ANALYSIS_H
+#define ALIFEMTOK0ANALYSIS_H
+
+//
+// Class AliFemtoK0Analysis
+//
+// AliFemtoK0Analysis
+// author:
+//        Matthew Steinpreis (matthew.steinpreis@cern.ch)
+//
+
+class TH1F;
+class TH1D;
+class TH2D;
+class TH3D;
+class TProfile;
+class TRandom3;
+
+class AliESDEvent;
+class AliAODEvent;
+class AliESDtrackCuts;
+class AliESDpid;
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliFemtoK0EventCollection.h"
+#include "AliAODpidUtil.h"
+#include "AliESDpid.h"
+
+class AliFemtoK0Analysis : public AliAnalysisTaskSE {
+ public:
+  AliFemtoK0Analysis();
+  AliFemtoK0Analysis(const char *name, bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, bool Case3D = kFALSE, float MinDL = 0.0, int MeritCutChoice = 2, float MinSep = 5.0, bool FlatCent = kFALSE, bool PsiBinning = kFALSE);
+  virtual ~AliFemtoK0Analysis();
+  AliFemtoK0Analysis(const AliFemtoK0Analysis&);
+  AliFemtoK0Analysis& operator=(const AliFemtoK0Analysis&);
+
+ private:
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);  
+
+  void MyInit();
+  void GetGlobalPositionAtGlobalRadiiThroughTPC(const AliAODTrack *track, const Float_t bfield, Float_t globalPositionsAtRadii[9][3], double PrimaryVertex[3]);
+  bool CheckMeritCutWinner(int cutChoice, double oldPars[3], double newPars[3]);
+  bool RejectEventCentFlat(float MagField, float CentPercent);
+  
+  enum 
+  {
+    kCentBins    = 16,
+    kZVertexBins = 10,
+    kPsiBins    = 4,
+    kEventsToMix =  5,
+    kMultLimit   = 300,              //maximum number of v0s, array size
+    ncthetabins = 36,
+    nphibins    = 72
+  };
+
+  bool fSignDep;
+  bool fFieldPos;
+  bool fOnlineCase;
+  bool fMeritCase;
+  bool fCase3D;
+  float fMinDecayLength;
+  int fMeritCutChoice;
+  float fMinSep;
+  bool fFlatCent;
+  bool fPsiBinning;
+
+  int fEventCount;
+
+  AliFemtoK0EventCollection ****fEC; //!
+  AliFemtoK0Event *fEvt; //!
+
+  TRandom3* fRandomNumber; //!
+  
+  const char     *fName;
+  AliAODEvent    *fAOD; //!    // AOD object
+  TList          *fOutputList; //! Compact Output list
+  AliPIDResponse *fPidAOD; //!
+  
+  ClassDef(AliFemtoK0Analysis, 1); 
+};
+
+#endif
index c3db0a1d5fe98523437330eec8cafe013b5112d5..a963694445df3e32a29aab3dc66c15458918ac3f 100644 (file)
@@ -46,7 +46,8 @@ AliFemtoK0Particle::AliFemtoK0Particle() :
  fPPos(),
  fPNeg(),
  fPosXYZ(),
- fNegXYZ()
+ fNegXYZ(),
+ fPhiPsi(0)
 {
   //Default constructor
 }
@@ -73,7 +74,8 @@ AliFemtoK0Particle::AliFemtoK0Particle(const AliFemtoK0Particle &obj) :
  fPPos(),
  fPNeg(),
  fPosXYZ(),
- fNegXYZ()
+ fNegXYZ(),
+ fPhiPsi()
 
 {
   // copy constructor
@@ -112,6 +114,7 @@ AliFemtoK0Particle &AliFemtoK0Particle::operator=(const AliFemtoK0Particle &obj)
    fNegXYZ[j][i] = obj.fNegXYZ[j][i];
   }
  }
+ fPhiPsi = obj.fPhiPsi;
  return (*this);
 }
 //_____________________________________________________________________________
@@ -232,4 +235,3 @@ void AliFemtoK0EventCollection::FIFOShift(){ //Shift elements in FIFO by one and
   (fEvt)->fFillStatus=0;
 
 }
-
index 121517b8bc2d77ee01a329be1394eb703a688c0b..860144e4ccc66bc40b966e1ff498c40bd8c46610 100644 (file)
@@ -58,6 +58,9 @@ class AliFemtoK0Particle  // Reconstructed K0s parameters needed for correlation
   float fPosXYZ[9][3]; //corrected daughter TPC positions
   float fNegXYZ[9][3]; //corrected daughter TPC positions
 
+  //for event plane
+  double fPhiPsi;
+
   ClassDef(AliFemtoK0Particle, 1);
 };
 
@@ -96,4 +99,3 @@ class AliFemtoK0EventCollection
     ClassDef(AliFemtoK0EventCollection, 1);
 };
 #endif
-
index 2e303d4598855db24a62508724b7526a0b332768..3418439545cb143a6d93a7ac719d76754ad1cc81 100644 (file)
@@ -1,4 +1,4 @@
-AliFemtoK0Analysis *AddTaskK0Femto(bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, bool Case3D = kFALSE, float MinDL = 0.0, int MeritCutChoice = 4, float MinSep = 5.0, float FlatCent = kTRUE, TString nameSpec = "NoSpec"){
+AliFemtoK0Analysis *AddTaskK0Femto(bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, bool Case3D = kFALSE, float MinDL = 0.0, int MeritCutChoice = 4, float MinSep = 5.0, bool FlatCent = kFALSE, bool PsiBinning = kFALSE, TString nameSpec = "NoSpec"){
 
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
@@ -6,7 +6,7 @@ AliFemtoK0Analysis *AddTaskK0Femto(bool SignDep = kFALSE, bool FieldPositive = k
     return NULL;
   }
 
-  AliFemtoK0Analysis *K0Task = new AliFemtoK0Analysis("K0Task", SignDep, FieldPositive, OnlineCase, MeritCase, Case3D, MinDL, MeritCutChoice, MinSep, FlatCent);
+  AliFemtoK0Analysis *K0Task = new AliFemtoK0Analysis("K0Task", SignDep, FieldPositive, OnlineCase, MeritCase, Case3D, MinDL, MeritCutChoice, MinSep, FlatCent, PsiBinning);
   if(!K0Task) exit(-1);
   mgr->AddTask(K0Task);
 
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/AddTaskFemtoKchHBT0010.C b/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/AddTaskFemtoKchHBT0010.C
new file mode 100644 (file)
index 0000000..2303749
--- /dev/null
@@ -0,0 +1,80 @@
+//=============================================================================
+//
+// *** AddTaskFemto.C ***
+// ---train version ---
+// This macro initialize a complete AnalysisTask object for femtoscopy.
+// from:
+// alicepc100/cern/users/erogocha/PbPb2.76/2011/AOD115_0-10_newPID/to_alien_newtag/AddTaskFemto.C
+// ---modified to train---
+//  KM: March 25, 2013
+//=============================================================================
+
+//this line for local: AliAnalysisTaskFemto *AddTaskFemtoKchHBT(const char *configMacroName="ConfigFemtoAnalysis.C", const char *configMacroParameters="" )
+
+AliAnalysisTaskFemto *AddTaskFemtoKchHBT0010(TString configMacroName, const char *containerName="femtolist", const char *configMacroParameters="" )
+{
+// Creates a proton analysis task and adds it to the analysis manager.
+  
+  // A. Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFemto", "No analysis manager to connect to.");
+    return NULL;
+  }  
+
+  // B. Check the analysis type using the event handlers connected to the analysis
+  //    manager. The availability of MC handler cann also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFemto", "This task requires an input event handler");
+    return NULL;
+  }  
+  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+  cout << "Found " <<type << " event handler" << endl;
+
+  // C. Create the task, add it to manager.
+  //===========================================================================
+//  gSystem->SetIncludePath("-I$ROOTSYS/include  -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser -I$ALICE_ROOT/include");
+
+  if (TProofMgr::GetListOfManagers()->GetEntries()) {
+//     if (dynamic_cast<TProofLite *> gProof) {
+//       char *macrocommand[10000];
+//       sprintf(macrocommand, ".L %s", configMacroName);
+//       gProof->Exec(macrocommand);
+//     }
+//     else
+    gProof->Load(configMacroName);
+  }  
+  //  gROOT->LoadMacro("ConfigFemtoAnalysis.C++");
+
+  //was befere aliroot 5.04.33: AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName);
+  //  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName,kFALSE);
+  //March 2013:
+  //to check localy before new tag I did symbolic link on my laplot
+  //in $ALICE_ROOT/PWGCF/FEMTOSCOPY/macros/Train/
+  //[root@alicethinks Train]# ln -s /scratch/AliWork/PbPb2.76/Train2013/KchHBT KchHBT
+  //
+  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto","$ALICE_ROOT/"+configMacroName,configMacroParameters,kFALSE);
+  taskfemto->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);// this a new line for train
+  mgr->AddTask(taskfemto);
+
+  // D. Configure the analysis task. Extra parameters can be used via optional
+  // arguments of the AddTaskXXX() function.
+  //===========================================================================
+  
+  // E. 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 outputfile = AliAnalysisManager::GetCommonFileName();  
+  outputfile += ":PWG2FEMTO";
+  AliAnalysisDataContainer *cout_femto  = mgr->CreateContainer("femtolist18",  TList::Class(),
+                                                              AliAnalysisManager::kOutputContainer,outputfile);
+
+
+   mgr->ConnectInput(taskfemto, 0, mgr->GetCommonInputContainer());
+   mgr->ConnectOutput(taskfemto, 0, cout_femto);
+
+   // Return task pointer at the end
+   return taskfemto;
+}
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/0108/ConfigFemtoAnalysis.C
new file mode 100644 (file)
index 0000000..a33333e
--- /dev/null
@@ -0,0 +1,444 @@
+
+/*********************************************************************
+ *                                                                   *
+ * 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 "AliFemtoPairCutRadialDistanceKK.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 "AliFemtoKTPairCut.h"
+#endif
+
+//________________________________________________________________________
+AliFemtoManager* ConfigFemtoAnalysis() {
+
+  double PionMass = 0.13956995;
+  double KaonMass = 0.493677;
+  const int cMu=4;
+  const int cKt=8;
+
+  //-------Single track cuts------------------------------------------------->
+  double DCAxy=2.4;//cm // our standard is 0.20 cm; super narrow was 0.015cm
+  double DCAz =3.0;//cm // our standard is 0.15 cm;
+  //-------Single track cuts-------------------------------------------------<
+  //=======Double track cuts=================================================>
+  //Dhevan's : PhiStarDifferenceMinimum=0.06; EtaDifferenceMinimum=0.02;
+  double PhiStarDifferenceMinimum=0.017; //[radian]
+  double EtaDifferenceMinimum=0.015; //[radian]
+  //=======Double track cuts=================================================<
+
+  // Switches for QA analyses
+  // int runmults[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+  // int multbins[11] = {30, 70, 150, 310, 590, 990, 1570, 2370, 2370, 2370, 6500};
+
+  int runmults[cMu] = {1, 0, 0, 0};
+  //int multbins[11] = {0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+  //Orig Kch in PbPb
+  //int multbins[cMu+1] = {0, 100, 300, 500, 900};
+  //Test for flat part of centrality distribution....
+  int multbins[cMu+1] = {10, 80, 300, 500, 900};
+  //.................................................
+
+  int runch[2] = {1, 1};
+  const char *chrgs[2] = { "Kp", "Km"};
+  
+  
+  int runktdep = 1;
+  double ktrng[cKt+1] = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0, 1.3};
+// double ktrng[8] = {0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 2.0};
+
+  int run3d = 0;
+  int runshlcms = 0;
+
+  int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner
+  int isrealdata = 1;
+
+  //   AliFemtoEventReaderESDChainKine* Reader=new AliFemtoEventReaderESDChainKine();
+  //   Reader->SetConstrained(true);
+  //   Reader->SetUseTPCOnly(false);
+
+  double shqmax;
+  double shqmaxSH;
+  int nbinssh = 100;
+
+//ml  if (runshlcms) shqmax = 0.25;
+//  else shqmax = 0.9;
+  
+
+  if (runshlcms) shqmaxSH = 0.25;
+  shqmax = 0.9;
+  
+
+  // AliFemtoEventReaderESDChain* Reader=new AliFemtoEventReaderESDChain();
+  // Reader->SetConstrained(true);
+  // Reader->SetUseTPCOnly(false);
+  // Reader->SetReadTPCInner(false);
+  // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality);
+
+  // if (runtype == 0)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kGlobal);
+  // else if (runtype == 1)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kITSOnly);
+  // else if (runtype == 2)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kTPCOnly);
+  // if (isrealdata)
+  //   Reader->SetUsePhysicsSelection(kTRUE);
+  // else
+  //   Reader->SetUsePhysicsSelection(kFALSE);
+
+  // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality);
+
+  AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain();
+    Reader->SetFilterBit(7);
+    Reader->SetCentralityPreSelection(0, 100);
+    Reader->SetDCAglobalTrack(kTRUE);//option the DCA information from global tracks (ITS+TPC)
+    
+  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];
+  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];
+//    AliFemtoShareQualityTPCEntranceSepPairCut      *sqpcetaphitpc[20];
+  //AliFemtoPairCutRadialDistance      *sqpcetaphitpc[20];//AliFemto dphi* cut
+  AliFemtoPairCutRadialDistanceKK      *sqpcetaphitpc[20];//Dhevan's dphi* cut
+  AliFemtoCorrFctnDirectYlm     *cylmetaphitpc[20];
+  AliFemtoCorrFctnDEtaDPhi      *cdedpetaphi[20*10];//20->20*10 due to kT
+  AliFemtoChi2CorrFctn          *cchiqinvetaphitpc[20];
+  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];
+
+  // *** Third QA task - HBT analysis with all pair cuts off, TPC only ***
+  // *** Begin Kaon-Kaon (positive) analysis ***
+  int aniter = 0;
+
+  for (int imult=0; imult<cMu/*4*/; imult++) {
+    if (runmults[imult]) {
+      for (int ichg=0; ichg<2; ichg++) {
+       if (runch[ichg]) {
+         aniter = ichg*5+imult;
+
+         anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(4, -8.0, 8.0, 5, multbins[imult], multbins[imult+1]);
+         anetaphitpc[aniter]->SetNumEventsToMix(3);
+         anetaphitpc[aniter]->SetMinSizePartCollection(1);
+
+         mecetaphitpc[aniter] = new AliFemtoBasicEventCut();
+         mecetaphitpc[aniter]->SetEventMult(0,100000);
+         mecetaphitpc[aniter]->SetVertZPos(-8.0,8.0);
+         /* //was in aliroot 5.03.76
+         if (isrealdata)
+            mecetaphitpc[aniter]->SetAcceptOnlyPhysics(kTRUE);
+         */
+         //    mecetaphitpc->SetAcceptBadVertex(kTRUE);
+         
+         cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult));
+         cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult));
+         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]);
+         
+         dtc1etaphitpc[aniter] = new AliFemtoKKTrackCut();
+//       dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut();
+         //     dtc1etaphitpc[aniter]->SetPidProbPion(0.0,1.001);
+         //     dtc1etaphitpc[aniter]->SetPidProbMuon(0.0,1.0);
+         //     dtc1etaphitpc[aniter]->SetPidProbKaon(0.0,1.0);
+         //     dtc1etaphitpc[aniter]->SetPidProbProton(0.0,1.0);
+         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]->SetEta(-1.2,1.2);
+         dtc1etaphitpc[aniter]->SetEta(-0.8,0.8);
+         //    //    dtc1etaphitpc[aniter]->SetEta(-0.5,0.5);
+///      dtc1etaphitpc[aniter]->SetMass(PionMass);
+         dtc1etaphitpc[aniter]->SetMass(KaonMass);
+         
+         
+         ////    dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                 
+///////   ----!!!!!!      
+         dtc1etaphitpc[aniter]->SetMostProbableKaon();  //!!!!!!
+         //------------------- November 2013 -----------------------------------< 
+         //New class in AliFemo: PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoKKTrackCut.cxx
+         dtc1etaphitpc[aniter]->SetNsigmaTPCle250(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC250_400(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC400_450(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC450_500(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPCge500(3.0);
+         // new cuts are stronger, better separation of pion in TOF 
+         // when momentum is greater then 800 MeV/c
+         dtc1etaphitpc[aniter]->SetNsigmaTOF500_800(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTOF800_1000(1.5);
+         dtc1etaphitpc[aniter]->SetNsigmaTOFge1000(1.0);
+         //------------------- November 2013 ----------------------------------->
+
+////             dtc1etaphitpc[aniter]->SetMostProbablePion();
+         //    // Track quality cuts
+         if (runtype == 0) {
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetminTPCncls(80);
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           //Poland: dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+         else if (runtype == 1) {
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA);
+           //      dtc1etaphitpc[aniter]->SetminTPCncls(70);
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           //      dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+         else if (runtype == 2) {
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetminTPCncls(80); //was "0"
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           //dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);  //3.0
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+
+         
+
+         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),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 AliFemtoShareQualityTPCEntranceSepPairCut();
+         
+          if (ichg < 2) {
+           //sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance();//AliFemto dphi* cut
+         sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistanceKK();  //Dhevan's dphi* cut
+         if (runtype == 0) {
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                   //ml sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5);
+//ml       sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03);
+//ml       sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+
+        
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+          //////////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+         
+        
+           
+         }
+         else if (runtype == 1) {
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(1.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                   //ml sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0);
+//         sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03);
+//         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+
+//  void SetPhiStarDifferenceMinimum(double dtpc);
+//  void SetEtaDifferenceMinimum(double etpc);
+//  void SetMinimumRadius(double minrad);
+//  void SetMagneticFieldSign(int magsign);
+
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+         /////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+     //sqpcetaphitpc[aniter]->SetMagneticFieldSign(1.0);
+
+
+         }
+         else if (runtype == 2) {
+            sqpcetaphitpc[aniter]->SetDataType(AliFemtoPairCut::kAOD);
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+               //ml    sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(0.0);
+//ml       sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.045);
+//ml       sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016);
+
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+           ////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+        
+
+         }
+         }        
+
+         
+         anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]);
+         anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+         anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]);
+         anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]);
+         
+        //       cylmetaphitpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),3,nbinssh,0.0,shqmaxSH,runshlcms);
+         ///     anetaphitpc[aniter]->AddCorrFctn(cylmetaphitpc[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<cKt/*8*/; ikt++) {
+             ktm = aniter*cKt/*8*/ + 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,
+//////                                                      (imult>6)?shqmaxSH*2.5:shqmaxSH,
+/////                                                       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,(imult>6)?shqmax*2.5:shqmax);
+//           cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,0.5);
+             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]);
+
+//---- Correlation Function vs Delta_Eta and Delta_Phi (not Phi*)---->>>
+             cdedpetaphi[ktm] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%ikT%i", chrgs[ichg], imult, ikt),100,100);
+             anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[ktm]);
+//---- Correlation Function vs Delta_Eta and Delta_Phi (not Phi*)----<<<
+
+             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),50,0.5);
+               cq3dlcmskttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+               anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]);
+             }
+           }
+         }
+         
+         // cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),24, 24);
+         // anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]);
+         
+         Manager->AddAnalysis(anetaphitpc[aniter]);    
+       }
+      }
+    }
+  }
+  // *** End Kaon-Kaon (positive) analysis
+
+  return Manager;
+}                         
+                      
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/AddTaskFemtoKchHBT0010.C b/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/AddTaskFemtoKchHBT0010.C
new file mode 100644 (file)
index 0000000..62af1b0
--- /dev/null
@@ -0,0 +1,80 @@
+//=============================================================================
+//
+// *** AddTaskFemto.C ***
+// ---train version ---
+// This macro initialize a complete AnalysisTask object for femtoscopy.
+// from:
+// alicepc100/cern/users/erogocha/PbPb2.76/2011/AOD115_0-10_newPID/to_alien_newtag/AddTaskFemto.C
+// ---modified to train---
+//  KM: March 25, 2013
+//=============================================================================
+
+//this line for local: AliAnalysisTaskFemto *AddTaskFemtoKchHBT(const char *configMacroName="ConfigFemtoAnalysis.C", const char *configMacroParameters="" )
+
+AliAnalysisTaskFemto *AddTaskFemtoKchHBT0010(TString configMacroName, const char *containerName="femtolist", const char *configMacroParameters="" )
+{
+// Creates a proton analysis task and adds it to the analysis manager.
+  
+  // A. Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFemto", "No analysis manager to connect to.");
+    return NULL;
+  }  
+
+  // B. Check the analysis type using the event handlers connected to the analysis
+  //    manager. The availability of MC handler cann also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFemto", "This task requires an input event handler");
+    return NULL;
+  }  
+  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+  cout << "Found " <<type << " event handler" << endl;
+
+  // C. Create the task, add it to manager.
+  //===========================================================================
+//  gSystem->SetIncludePath("-I$ROOTSYS/include  -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser -I$ALICE_ROOT/include");
+
+  if (TProofMgr::GetListOfManagers()->GetEntries()) {
+//     if (dynamic_cast<TProofLite *> gProof) {
+//       char *macrocommand[10000];
+//       sprintf(macrocommand, ".L %s", configMacroName);
+//       gProof->Exec(macrocommand);
+//     }
+//     else
+    gProof->Load(configMacroName);
+  }  
+  //  gROOT->LoadMacro("ConfigFemtoAnalysis.C++");
+
+  //was befere aliroot 5.04.33: AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName);
+  //  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName,kFALSE);
+  //March 2013:
+  //to check localy before new tag I did symbolic link on my laplot
+  //in $ALICE_ROOT/PWGCF/FEMTOSCOPY/macros/Train/
+  //[root@alicethinks Train]# ln -s /scratch/AliWork/PbPb2.76/Train2013/KchHBT KchHBT
+  //
+  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto","$ALICE_ROOT/"+configMacroName,configMacroParameters,kFALSE);
+  taskfemto->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);// this a new line for train
+  mgr->AddTask(taskfemto);
+
+  // D. Configure the analysis task. Extra parameters can be used via optional
+  // arguments of the AddTaskXXX() function.
+  //===========================================================================
+  
+  // E. 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 outputfile = AliAnalysisManager::GetCommonFileName();  
+  outputfile += ":PWG2FEMTO";
+  AliAnalysisDataContainer *cout_femto  = mgr->CreateContainer("femtolistFLAT",  TList::Class(),
+                                                              AliAnalysisManager::kOutputContainer,outputfile);
+
+
+   mgr->ConnectInput(taskfemto, 0, mgr->GetCommonInputContainer());
+   mgr->ConnectOutput(taskfemto, 0, cout_femto);
+
+   // Return task pointer at the end
+   return taskfemto;
+}
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/KchHBT_Eta0015Phi0017_DCAxy2.4_DCAz3_ITSTPC_flattening/flat/ConfigFemtoAnalysis.C
new file mode 100644 (file)
index 0000000..58fd2a7
--- /dev/null
@@ -0,0 +1,450 @@
+
+/*********************************************************************
+ *                                                                   *
+ * 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 "AliFemtoPairCutRadialDistanceKK.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 "AliFemtoKTPairCut.h"
+#endif
+
+//________________________________________________________________________
+AliFemtoManager* ConfigFemtoAnalysis() {
+
+  double PionMass = 0.13956995;
+  double KaonMass = 0.493677;
+  const int cMu=4;
+  const int cKt=8;
+
+  //-------Single track cuts------------------------------------------------->
+  double DCAxy=2.4;//cm // our standard is 0.20 cm; super narrow was 0.015cm
+  double DCAz =3.0;//cm // our standard is 0.15 cm;
+  //-------Single track cuts-------------------------------------------------<
+  //=======Double track cuts=================================================>
+  //Dhevan's : PhiStarDifferenceMinimum=0.06; EtaDifferenceMinimum=0.02;
+  double PhiStarDifferenceMinimum=0.017; //[radian]
+  double EtaDifferenceMinimum=0.015; //[radian]
+  //=======Double track cuts=================================================<
+
+  // Switches for QA analyses
+  // int runmults[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+  // int multbins[11] = {30, 70, 150, 310, 590, 990, 1570, 2370, 2370, 2370, 6500};
+
+  int runmults[cMu] = {1, 0, 0, 0};
+  //int multbins[11] = {0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+  //Orig Kch in PbPb
+  int multbins[cMu+1] = {0, 100, 300, 500, 900};
+  //.................................................
+
+  int runch[2] = {1, 1};
+  const char *chrgs[2] = { "Kp", "Km"};
+  
+  
+  int runktdep = 1;
+  double ktrng[cKt+1] = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0, 1.3};
+// double ktrng[8] = {0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 2.0};
+
+  int run3d = 0;
+  int runshlcms = 0;
+
+  int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner
+  int isrealdata = 1;
+
+  //   AliFemtoEventReaderESDChainKine* Reader=new AliFemtoEventReaderESDChainKine();
+  //   Reader->SetConstrained(true);
+  //   Reader->SetUseTPCOnly(false);
+
+  double shqmax;
+  double shqmaxSH;
+  int nbinssh = 100;
+
+//ml  if (runshlcms) shqmax = 0.25;
+//  else shqmax = 0.9;
+  
+
+  if (runshlcms) shqmaxSH = 0.25;
+  shqmax = 0.9;
+  
+
+  // AliFemtoEventReaderESDChain* Reader=new AliFemtoEventReaderESDChain();
+  // Reader->SetConstrained(true);
+  // Reader->SetUseTPCOnly(false);
+  // Reader->SetReadTPCInner(false);
+  // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality);
+
+  // if (runtype == 0)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kGlobal);
+  // else if (runtype == 1)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kITSOnly);
+  // else if (runtype == 2)
+  //   Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kTPCOnly);
+  // if (isrealdata)
+  //   Reader->SetUsePhysicsSelection(kTRUE);
+  // else
+  //   Reader->SetUsePhysicsSelection(kFALSE);
+
+  // Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality);
+
+  AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain();
+    Reader->SetFilterBit(7);
+    Reader->SetCentralityPreSelection(0, 100);
+    Reader->SetDCAglobalTrack(kTRUE);//option the DCA information from global tracks (ITS+TPC)
+    //December 2013. Maciej:.........................................>
+    //I have committed on Friday AliFemtoEventReaderAOD class with 
+    //the function for centrality flattening which Matt created. 
+    //To use it, please specify in config macro:
+
+    Reader->SetCentralityFlattening(kTRUE);
+
+    //................................................................<
+
+  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];
+  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];
+//    AliFemtoShareQualityTPCEntranceSepPairCut      *sqpcetaphitpc[20];
+  //AliFemtoPairCutRadialDistance      *sqpcetaphitpc[20];//AliFemto dphi* cut
+  AliFemtoPairCutRadialDistanceKK      *sqpcetaphitpc[20];//Dhevan's dphi* cut
+  AliFemtoCorrFctnDirectYlm     *cylmetaphitpc[20];
+  AliFemtoCorrFctnDEtaDPhi      *cdedpetaphi[20*10];//20->20*10 due to kT
+  AliFemtoChi2CorrFctn          *cchiqinvetaphitpc[20];
+  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];
+
+  // *** Third QA task - HBT analysis with all pair cuts off, TPC only ***
+  // *** Begin Kaon-Kaon (positive) analysis ***
+  int aniter = 0;
+
+  for (int imult=0; imult<cMu/*4*/; imult++) {
+    if (runmults[imult]) {
+      for (int ichg=0; ichg<2; ichg++) {
+       if (runch[ichg]) {
+         aniter = ichg*5+imult;
+
+         anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(4, -8.0, 8.0, 5, multbins[imult], multbins[imult+1]);
+         anetaphitpc[aniter]->SetNumEventsToMix(3);
+         anetaphitpc[aniter]->SetMinSizePartCollection(1);
+
+         mecetaphitpc[aniter] = new AliFemtoBasicEventCut();
+         mecetaphitpc[aniter]->SetEventMult(0,100000);
+         mecetaphitpc[aniter]->SetVertZPos(-8.0,8.0);
+         /* //was in aliroot 5.03.76
+         if (isrealdata)
+            mecetaphitpc[aniter]->SetAcceptOnlyPhysics(kTRUE);
+         */
+         //    mecetaphitpc->SetAcceptBadVertex(kTRUE);
+         
+         cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult));
+         cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult));
+         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]);
+         
+         dtc1etaphitpc[aniter] = new AliFemtoKKTrackCut();
+//       dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut();
+         //     dtc1etaphitpc[aniter]->SetPidProbPion(0.0,1.001);
+         //     dtc1etaphitpc[aniter]->SetPidProbMuon(0.0,1.0);
+         //     dtc1etaphitpc[aniter]->SetPidProbKaon(0.0,1.0);
+         //     dtc1etaphitpc[aniter]->SetPidProbProton(0.0,1.0);
+         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]->SetEta(-1.2,1.2);
+         dtc1etaphitpc[aniter]->SetEta(-0.8,0.8);
+         //    //    dtc1etaphitpc[aniter]->SetEta(-0.5,0.5);
+///      dtc1etaphitpc[aniter]->SetMass(PionMass);
+         dtc1etaphitpc[aniter]->SetMass(KaonMass);
+         
+         
+         ////    dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                 
+///////   ----!!!!!!      
+         dtc1etaphitpc[aniter]->SetMostProbableKaon();  //!!!!!!
+         //------------------- November 2013 -----------------------------------< 
+         //New class in AliFemo: PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoKKTrackCut.cxx
+         dtc1etaphitpc[aniter]->SetNsigmaTPCle250(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC250_400(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC400_450(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPC450_500(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTPCge500(3.0);
+         // new cuts are stronger, better separation of pion in TOF 
+         // when momentum is greater then 800 MeV/c
+         dtc1etaphitpc[aniter]->SetNsigmaTOF500_800(2.0);
+         dtc1etaphitpc[aniter]->SetNsigmaTOF800_1000(1.5);
+         dtc1etaphitpc[aniter]->SetNsigmaTOFge1000(1.0);
+         //------------------- November 2013 ----------------------------------->
+
+////             dtc1etaphitpc[aniter]->SetMostProbablePion();
+         //    // Track quality cuts
+         if (runtype == 0) {
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetminTPCncls(80);
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           //Poland: dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+         else if (runtype == 1) {
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA);
+           //      dtc1etaphitpc[aniter]->SetminTPCncls(70);
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           //      dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+         else if (runtype == 2) {
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+           //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+           //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+           dtc1etaphitpc[aniter]->SetminTPCncls(80); //was "0"
+           dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+           dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+           //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+           dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+           dtc1etaphitpc[aniter]->SetMaxImpactXY(DCAxy);
+           //dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+           dtc1etaphitpc[aniter]->SetMaxImpactZ(DCAz);  //3.0
+           //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+         }
+
+         
+
+         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),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 AliFemtoShareQualityTPCEntranceSepPairCut();
+         
+          if (ichg < 2) {
+           //sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance();//AliFemto dphi* cut
+         sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistanceKK();  //Dhevan's dphi* cut
+         if (runtype == 0) {
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                   //ml sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5);
+//ml       sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03);
+//ml       sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+
+        
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+          //////////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+         
+        
+           
+         }
+         else if (runtype == 1) {
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(1.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                   //ml sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0);
+//         sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03);
+//         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+
+//  void SetPhiStarDifferenceMinimum(double dtpc);
+//  void SetEtaDifferenceMinimum(double etpc);
+//  void SetMinimumRadius(double minrad);
+//  void SetMagneticFieldSign(int magsign);
+
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+         /////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+     //sqpcetaphitpc[aniter]->SetMagneticFieldSign(1.0);
+
+
+         }
+         else if (runtype == 2) {
+            sqpcetaphitpc[aniter]->SetDataType(AliFemtoPairCut::kAOD);
+           sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+           sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+           sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+           // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+           // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+               //ml    sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(0.0);
+//ml       sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.045);
+//ml       sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.016);
+
+          //--------- km:  eta-phi* Dhevan's custs ----------->>>>
+           sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(PhiStarDifferenceMinimum);
+            sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(EtaDifferenceMinimum);
+           //sqpcetaphitpc[aniter]->SetMinimumRadius(0.8);//not need for AliFemtoPairCutRadialDistanceKK()
+          //--------- km:  eta-phi* Dhevan's custs -----------<<<
+
+           ////////sqpcetaphitpc[aniter]->SetMagneticFieldSign(1);
+        
+
+         }
+         }        
+
+         
+         anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]);
+         anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+         anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]);
+         anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]);
+         
+        //       cylmetaphitpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),3,nbinssh,0.0,shqmaxSH,runshlcms);
+         ///     anetaphitpc[aniter]->AddCorrFctn(cylmetaphitpc[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<cKt/*8*/; ikt++) {
+             ktm = aniter*cKt/*8*/ + 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,
+//////                                                      (imult>6)?shqmaxSH*2.5:shqmaxSH,
+/////                                                       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,(imult>6)?shqmax*2.5:shqmax);
+//           cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0,0.5);
+             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]);
+
+//---- Correlation Function vs Delta_Eta and Delta_Phi (not Phi*)---->>>
+             cdedpetaphi[ktm] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%ikT%i", chrgs[ichg], imult, ikt),100,100);
+             anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[ktm]);
+//---- Correlation Function vs Delta_Eta and Delta_Phi (not Phi*)----<<<
+
+             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),50,0.5);
+               cq3dlcmskttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+               anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]);
+             }
+           }
+         }
+         
+         // cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),24, 24);
+         // anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]);
+         
+         Manager->AddAnalysis(anetaphitpc[aniter]);    
+       }
+      }
+    }
+  }
+  // *** End Kaon-Kaon (positive) analysis
+
+  return Manager;
+}                         
+                      
index 12b33e3815f71b54066502605a2c30bafb72310e..1d76a91fd05e59cfb31e27054bccbbcb3f40c774 100644 (file)
@@ -98,6 +98,7 @@ AliFemtoManager* ConfigFemtoAnalysis() {
   Reader->SetFilterBit(7);
   Reader->SetCentralityPreSelection(0.001, 310);
   Reader->SetEPVZERO(kTRUE);
+  Reader->SetCentralityFlattening(kTRUE);
 
   AliFemtoManager* Manager = new AliFemtoManager();
   Manager->SetEventReader(Reader);
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/DcaTpcOnlyTTC2/central18/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/DcaTpcOnlyTTC2/central18/ConfigFemtoAnalysis.C
new file mode 100644 (file)
index 0000000..d43dc17
--- /dev/null
@@ -0,0 +1,448 @@
+/*********************************************************************
+ *                                                                   *
+ * 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 "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 "AliFemtoCorrFctnNonIdDR.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 "AliFemtoAvgSepCorrFctn.h"
+#endif
+
+//________________________________________________________________________
+AliFemtoManager* ConfigFemtoAnalysis() {
+
+  double PionMass = 0.13956995;
+  double KaonMass = 0.493677;
+  double ProtonMass = 0.938272013;
+
+  // double psi = TMath::Pi()/2.;
+  // double psid = TMath::Pi()/6.;
+
+  // int runepvzero[7] = {1, 1, 1, 1, 1, 1, 1};
+  // double epvzerobins[7] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid, -psi+4*psid, -psi+5*psid, -psi+6*psid};
+
+  double psi = TMath::Pi()/2.;
+  double psid = TMath::Pi()/3.;
+
+  int runepvzero[4] = {0, 0, 0, 1};
+  double epvzerobins[4] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid};
+
+  int runmults[10] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+  int multbins[11] = {10, 80, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+
+  int runch[3] = {1, 1, 1};
+  const char *chrgs[3] = { "PP", "APAP", "PAP" };
+
+  int runktdep = 1;
+  double ktrng[3] = {0.01, 1.0, 5.0};
+
+  int numOfMultBins = 10;
+  int numOfChTypes = 3;
+  int numOfkTbins = 2;
+  int numOfEPvzero = 4;
+
+  int runqinv = 1;
+  int runshlcms = 0;// 0:PRF(PAP), 1:LCMS(PP,APAP)
+
+  int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner
+  int isrealdata = 1;
+
+  //  int gammacut = 1;
+
+  double shqmax = 1.0;
+  int nbinssh = 100;
+
+  AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain();
+  Reader->SetFilterBit(7);
+  Reader->SetCentralityPreSelection(0.001, 310);
+  Reader->SetEPVZERO(kTRUE);
+  Reader->SetCentralityFlattening(kTRUE);
+
+  AliFemtoManager* Manager = new AliFemtoManager();
+  Manager->SetEventReader(Reader);
+
+  AliFemtoVertexMultAnalysis    *anetaphitpc[10*3*2];
+  AliFemtoBasicEventCut         *mecetaphitpc[10*3*2];
+  AliFemtoCutMonitorEventMult   *cutPassEvMetaphitpc[50];
+  AliFemtoCutMonitorEventMult   *cutFailEvMetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[50];
+  AliFemtoESDTrackCut           *dtc1etaphitpc[50];
+  AliFemtoESDTrackCut           *dtc2etaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[50];
+  //   AliFemtoPairCutAntiGamma      *sqpcetaphitpcdiff[10*3];
+  //   AliFemtoShareQualityTPCEntranceSepPairCut      *sqpcetaphitpcsame[10*3];
+  //AliFemtoPairCutAntiGamma      *sqpcetaphitpc[10*3];
+  AliFemtoPairCutRadialDistance      *sqpcetaphitpc[50];
+  //  AliFemtoChi2CorrFctn          *cchiqinvetaphitpc[20*2];
+  AliFemtoKTPairCut             *ktpcuts[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmtpc[50];
+  AliFemtoCorrFctnDirectYlm     *cylmkttpc[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmetaphitpc[10*3];
+  AliFemtoQinvCorrFctn          *cqinvkttpc[50*2];
+  AliFemtoQinvCorrFctn          *cqinvtpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstartpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstarkttpc[50*2];
+  AliFemtoCorrFctnDEtaDPhi      *cdedpetaphi[50*2];
+  AliFemtoAvgSepCorrFctn          *cAvgSeptpc[50];
+
+  //   AliFemtoCorrFctn3DLCMSSym     *cq3dlcmskttpc[20*2];
+  //   AliFemtoCorrFctnTPCNcls       *cqinvnclstpc[20];
+  //   AliFemtoShareQualityCorrFctn  *cqinvsqtpc[20*10];
+  //   AliFemtoChi2CorrFctn          *cqinvchi2tpc[20];
+    AliFemtoTPCInnerCorrFctn      *cqinvinnertpc[50];
+
+  // *** Third QA task - HBT analysis with all pair cuts off, TPC only ***
+  // *** Begin pion-pion (positive) analysis ***
+  int aniter = 0;
+
+  for (int imult = 0; imult < numOfMultBins; imult++) {
+    if (runmults[imult]) {
+
+      for (int ichg = 0; ichg < numOfChTypes; ichg++) {
+        if (runch[ichg]) {
+
+          for (int iepvzero = 0; iepvzero < numOfEPvzero; iepvzero++) {
+            if (runepvzero[iepvzero]) {
+
+              aniter = imult * numOfChTypes + ichg * numOfEPvzero + iepvzero;
+              // aniter = ichg * numOfMultBins + imult * numOfEPvzero + iepvzero;
+
+              // cout << "aniter = " << aniter << endl;
+              //        aniter = ichg * numOfMultBins + imult;
+
+              // if (ichg == 2)
+              //       runshlcms = 0;
+              // else
+              //       runshlcms = 1;
+
+
+              //________________________
+
+              anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(8, -8.0, 8.0, 4, multbins[imult], multbins[imult+1]);
+              anetaphitpc[aniter]->SetNumEventsToMix(10);
+              anetaphitpc[aniter]->SetMinSizePartCollection(1);
+              anetaphitpc[aniter]->SetVerboseMode(kFALSE);
+
+              mecetaphitpc[aniter] = new AliFemtoBasicEventCut();
+              mecetaphitpc[aniter]->SetEventMult(0.001,100000);
+              mecetaphitpc[aniter]->SetVertZPos(-8,8);
+
+              if (iepvzero == 3)
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[0],epvzerobins[3]);
+              else
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[iepvzero],epvzerobins[iepvzero+1]);
+
+              // if (isrealdata)
+              //     mecetaphitpc[aniter]->SetAcceptOnlyPhysics(kTRUE);
+
+              // cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              // cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              // 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]);
+
+              dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut();
+              dtc2etaphitpc[aniter] = new AliFemtoESDTrackCut();
+
+              if (ichg == 0) {
+                dtc1etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 1) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 2) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc2etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+                dtc2etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+
+              dtc1etaphitpc[aniter]->SetEta(-0.8,0.8);
+              dtc1etaphitpc[aniter]->SetMass(ProtonMass);
+              dtc1etaphitpc[aniter]->SetMostProbableProton();
+              dtc1etaphitpc[aniter]->SetNsigma(3.0);
+              //dtc1etaphitpc[aniter]->SetNsigma(2.0);
+              dtc1etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+              //dtc1etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              if (ichg == 2) {
+                dtc2etaphitpc[aniter]->SetEta(-0.8,0.8);
+                dtc2etaphitpc[aniter]->SetMass(ProtonMass);
+                dtc2etaphitpc[aniter]->SetMostProbableProton();
+                dtc2etaphitpc[aniter]->SetNsigma(3.0);
+                //dtc2etaphitpc[aniter]->SetNsigma(2.0);
+                dtc2etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+                //dtc2etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              }
+
+              // Track quality cuts
+
+              if (runtype == 0) {
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                //            dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.15);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 1) {
+                //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA);
+                //      dtc1etaphitpc[aniter]->SetminTPCncls(70);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                //      dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.25);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 2) {
+                //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+
+                if (ichg == 2) {
+                  //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                  dtc2etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                  dtc2etaphitpc[aniter]->SetminTPCncls(80);
+                  dtc2etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                  dtc2etaphitpc[aniter]->SetLabel(kFALSE);
+                  dtc2etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                  dtc2etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                  // dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                  //dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                  dtc2etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+                }
+
+              }
+
+              cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]);
+
+              cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2);//0-pion,1-kaon,2-proton
+              cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult , iepvzero),2);
+              dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]);
+
+              // if (ichg == 2){
+              //     cutPass2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass2%stpcM%i", chrgs[ichg], imult),2);//0-pion,1-kaon,2-proton
+              //     cutFail2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail2%stpcM%i", chrgs[ichg], imult),2);
+              //     dtc2etaphitpc[aniter]->AddCutMonitor(cutPass2PIDetaphitpc[aniter], cutFail2PIDetaphitpc[aniter]);
+              // }
+
+              // sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma();
+              sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance();
+
+              if (runtype == 0) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 1) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(1.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 2) {
+                //sqpcetaphitpc[aniter]->SetUseAOD(kTRUE);
+
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+
+                //         if (gammacut == 0) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //}
+                //else if (gammacut == 1) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //}
+
+                // sqpcetaphitpc[aniter]->SetMagneticFieldSign(-1); // field1 -1, field3 +1
+                // sqpcetaphitpc[aniter]->SetMinimumRadius(0.8); // biggest inefficiency for R=1.1 m (checked on small sample)
+
+                sqpcetaphitpc[aniter]->SetMinimumRadius(1.2); //0.8
+                sqpcetaphitpc[aniter]->SetPhiStarMin(kFALSE);
+                sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.045); // 0.012 - pions, 0.017 - kaons, 0.018
+                sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.01); // 0.017 - pions, 0.015 - kaons
+
+              }
+
+              anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]);
+
+              if (ichg == 2) {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc2etaphitpc[aniter]);
+              }
+              else {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]);
+              }
+
+              anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]);
+
+
+              if (ichg == 2) {
+                ckstartpc[aniter] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),nbinssh,0.0,shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(ckstartpc[aniter]);
+              }
+              else {
+
+                cqinvtpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2*nbinssh,0.0,2*shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(cqinvtpc[aniter]);
+
+              }
+
+              cylmtpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),2,nbinssh, 0.0,shqmax,runshlcms);
+              anetaphitpc[aniter]->AddCorrFctn(cylmtpc[aniter]);
+
+
+              // cAvgSeptpc[aniter] = new AliFemtoAvgSepCorrFctn(Form("cAvgSep%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),4*nbinssh,0.0,200);
+              // anetaphitpc[aniter]->AddCorrFctn(cAvgSeptpc[aniter]);
+
+              cqinvinnertpc[aniter] = new AliFemtoTPCInnerCorrFctn(Form("cqinvinner%stpcM%d", chrgs[ichg], imult),nbinssh,0.0,shqmax);
+              cqinvinnertpc[aniter]->SetRadius(1.2);
+              anetaphitpc[aniter]->AddCorrFctn(cqinvinnertpc[aniter]);
+
+
+              if (runktdep) {
+                int ktm;
+                for (int ikt=0; ikt<numOfkTbins; ikt++) {
+
+                  ktm = aniter * numOfkTbins + ikt;
+                  ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]);
+
+
+                  cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%ikT%i", chrgs[ichg], imult, ikt),2,nbinssh,0.0,shqmax,runshlcms);
+                  cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                  anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]);
+
+                  if (ichg == 2) {
+                    ckstarkttpc[ktm] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),nbinssh,0.0,shqmax);
+                    ckstarkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                    anetaphitpc[aniter]->AddCorrFctn(ckstarkttpc[ktm]);
+
+
+                  }
+                  else {
+                    cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),2*nbinssh,0.0,2*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]->SetPairSelectionCut(ktpcuts[ktm]);
+                  //           anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]);
+                  //         }
+                }
+              }
+
+              // cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),240, 240);
+              // anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]);
+
+              Manager->AddAnalysis(anetaphitpc[aniter]);
+            }
+          }
+        }
+      }
+    }
+  }
+
+
+// *** End pion-pion (positive) analysis
+
+
+  return Manager;
+}
index 9bd0296b6ee6e91138adcd7544d2f77ea5b1d226..2b38f6d1d0bb4163430d1fbf212c970a22ade1e4 100644 (file)
@@ -69,8 +69,8 @@ AliFemtoManager* ConfigFemtoAnalysis() {
   int runepvzero[4] = {0, 0, 0, 1};
   double epvzerobins[4] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid};
 
-  int runmults[10] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
-  int multbins[11] = {0.001, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+  int runmults[10] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+  int multbins[11] = {10, 80, 100, 200, 300, 400, 500, 600, 700, 800, 900};
 
   int runch[3] = {1, 1, 1};
   const char *chrgs[3] = { "PP", "APAP", "PAP" };
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/FlatCent/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/FlatCent/ConfigFemtoAnalysis.C
new file mode 100644 (file)
index 0000000..56edb89
--- /dev/null
@@ -0,0 +1,450 @@
+/*********************************************************************
+ *                                                                   *
+ * 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 "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 "AliFemtoCorrFctnNonIdDR.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 "AliFemtoAvgSepCorrFctn.h"
+#endif
+
+//________________________________________________________________________
+AliFemtoManager* ConfigFemtoAnalysis() {
+
+  double PionMass = 0.13956995;
+  double KaonMass = 0.493677;
+  double ProtonMass = 0.938272013;
+
+  // double psi = TMath::Pi()/2.;
+  // double psid = TMath::Pi()/6.;
+
+  // int runepvzero[7] = {1, 1, 1, 1, 1, 1, 1};
+  // double epvzerobins[7] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid, -psi+4*psid, -psi+5*psid, -psi+6*psid};
+
+  double psi = TMath::Pi()/2.;
+  double psid = TMath::Pi()/3.;
+
+  int runepvzero[4] = {0, 0, 0, 1};
+  double epvzerobins[4] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid};
+
+  int runmults[10] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
+  int multbins[11] = {0.001, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+
+  int runch[3] = {1, 1, 1};
+  const char *chrgs[3] = { "PP", "APAP", "PAP" };
+
+  int runktdep = 0;
+  double ktrng[3] = {0.01, 1.0, 5.0};
+
+  int numOfMultBins = 10;
+  int numOfChTypes = 3;
+  int numOfkTbins = 2;
+  int numOfEPvzero = 4;
+
+  int runqinv = 1;
+  int runshlcms = 0;// 0:PRF(PAP), 1:LCMS(PP,APAP)
+
+  int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner
+  int isrealdata = 1;
+
+  //  int gammacut = 1;
+
+  double shqmax = 1.0;
+  int nbinssh = 100;
+
+  AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain();
+  Reader->SetFilterBit(7);
+  Reader->SetCentralityPreSelection(0.001, 310);
+  Reader->SetEPVZERO(kTRUE);
+  Reader->SetCentralityFlattening(kTRUE);
+  // Reader->SetDCAglobalTrack(kTRUE);
+
+  AliFemtoManager* Manager = new AliFemtoManager();
+  Manager->SetEventReader(Reader);
+
+  AliFemtoVertexMultAnalysis    *anetaphitpc[10*3*2];
+  AliFemtoBasicEventCut         *mecetaphitpc[10*3*2];
+  AliFemtoCutMonitorEventMult   *cutPassEvMetaphitpc[50];
+  AliFemtoCutMonitorEventMult   *cutFailEvMetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[50];
+  AliFemtoESDTrackCut           *dtc1etaphitpc[50];
+  AliFemtoESDTrackCut           *dtc2etaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[50];
+  //   AliFemtoPairCutAntiGamma      *sqpcetaphitpcdiff[10*3];
+  //   AliFemtoShareQualityTPCEntranceSepPairCut      *sqpcetaphitpcsame[10*3];
+  //AliFemtoPairCutAntiGamma      *sqpcetaphitpc[10*3];
+  AliFemtoPairCutRadialDistance      *sqpcetaphitpc[50];
+  //  AliFemtoChi2CorrFctn          *cchiqinvetaphitpc[20*2];
+  AliFemtoKTPairCut             *ktpcuts[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmtpc[50];
+  AliFemtoCorrFctnDirectYlm     *cylmkttpc[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmetaphitpc[10*3];
+  AliFemtoQinvCorrFctn          *cqinvkttpc[50*2];
+  AliFemtoQinvCorrFctn          *cqinvtpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstartpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstarkttpc[50*2];
+  AliFemtoCorrFctnDEtaDPhi      *cdedpetaphi[50*2];
+  AliFemtoAvgSepCorrFctn          *cAvgSeptpc[50];
+
+  //   AliFemtoCorrFctn3DLCMSSym     *cq3dlcmskttpc[20*2];
+  //   AliFemtoCorrFctnTPCNcls       *cqinvnclstpc[20];
+  //   AliFemtoShareQualityCorrFctn  *cqinvsqtpc[20*10];
+  //   AliFemtoChi2CorrFctn          *cqinvchi2tpc[20];
+    AliFemtoTPCInnerCorrFctn      *cqinvinnertpc[50];
+
+  // *** Third QA task - HBT analysis with all pair cuts off, TPC only ***
+  // *** Begin pion-pion (positive) analysis ***
+  int aniter = 0;
+
+  for (int imult = 0; imult < numOfMultBins; imult++) {
+    if (runmults[imult]) {
+
+      for (int ichg = 0; ichg < numOfChTypes; ichg++) {
+        if (runch[ichg]) {
+
+          for (int iepvzero = 0; iepvzero < numOfEPvzero; iepvzero++) {
+            if (runepvzero[iepvzero]) {
+
+              aniter = imult * numOfChTypes + ichg * numOfEPvzero + iepvzero;
+              // aniter = ichg * numOfMultBins + imult * numOfEPvzero + iepvzero;
+
+              // cout << "aniter = " << aniter << endl;
+              //        aniter = ichg * numOfMultBins + imult;
+
+              // if (ichg == 2)
+              //       runshlcms = 0;
+              // else
+              //       runshlcms = 1;
+
+
+              //________________________
+
+              anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(8, -8.0, 8.0, 4, multbins[imult], multbins[imult+1]);
+              anetaphitpc[aniter]->SetNumEventsToMix(10);
+              anetaphitpc[aniter]->SetMinSizePartCollection(1);
+              anetaphitpc[aniter]->SetVerboseMode(kFALSE);
+
+              mecetaphitpc[aniter] = new AliFemtoBasicEventCut();
+              mecetaphitpc[aniter]->SetEventMult(0.001,100000);
+              mecetaphitpc[aniter]->SetVertZPos(-8,8);
+
+              if (iepvzero == 3)
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[0],epvzerobins[3]);
+              else
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[iepvzero],epvzerobins[iepvzero+1]);
+
+              // if (isrealdata)
+              //     mecetaphitpc[aniter]->SetAcceptOnlyPhysics(kTRUE);
+
+              cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              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]);
+
+              dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut();
+              dtc2etaphitpc[aniter] = new AliFemtoESDTrackCut();
+
+              if (ichg == 0) {
+                dtc1etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 1) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 2) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc2etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+                dtc2etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+
+              dtc1etaphitpc[aniter]->SetEta(-0.8,0.8);
+              dtc1etaphitpc[aniter]->SetMass(ProtonMass);
+              dtc1etaphitpc[aniter]->SetMostProbableProton();
+              dtc1etaphitpc[aniter]->SetNsigma(3.0);
+              //dtc1etaphitpc[aniter]->SetNsigma(2.0);
+              dtc1etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+              //dtc1etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              if (ichg == 2) {
+                dtc2etaphitpc[aniter]->SetEta(-0.8,0.8);
+                dtc2etaphitpc[aniter]->SetMass(ProtonMass);
+                dtc2etaphitpc[aniter]->SetMostProbableProton();
+                dtc2etaphitpc[aniter]->SetNsigma(3.0);
+                //dtc2etaphitpc[aniter]->SetNsigma(2.0);
+                dtc2etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+                //dtc2etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              }
+
+              // Track quality cuts
+
+              if (runtype == 0) {
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                //            dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.15);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 1) {
+                //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA);
+                //      dtc1etaphitpc[aniter]->SetminTPCncls(70);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                //      dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.25);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 2) {
+                //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+
+                if (ichg == 2) {
+                  //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                  dtc2etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                  dtc2etaphitpc[aniter]->SetminTPCncls(80);
+                  dtc2etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                  dtc2etaphitpc[aniter]->SetLabel(kFALSE);
+                  dtc2etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                  dtc2etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                  // dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                  //dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                  dtc2etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+                }
+
+              }
+
+              // cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              // cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              // dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]);
+
+              // cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2);//0-pion,1-kaon,2-proton
+              // cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult , iepvzero),2);
+              // dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]);
+
+              // if (ichg == 2){
+              //     cutPass2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass2%stpcM%i", chrgs[ichg], imult),2);//0-pion,1-kaon,2-proton
+              //     cutFail2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail2%stpcM%i", chrgs[ichg], imult),2);
+              //     dtc2etaphitpc[aniter]->AddCutMonitor(cutPass2PIDetaphitpc[aniter], cutFail2PIDetaphitpc[aniter]);
+              // }
+
+              // sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma();
+              sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance();
+
+              if (runtype == 0) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 1) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(1.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 2) {
+                //sqpcetaphitpc[aniter]->SetUseAOD(kTRUE);
+
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+
+                //         if (gammacut == 0) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //}
+                //else if (gammacut == 1) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //}
+
+                // sqpcetaphitpc[aniter]->SetMagneticFieldSign(-1); // field1 -1, field3 +1
+                // sqpcetaphitpc[aniter]->SetMinimumRadius(0.8); // biggest inefficiency for R=1.1 m (checked on small sample)
+
+                sqpcetaphitpc[aniter]->SetMinimumRadius(1.2); //0.8
+                sqpcetaphitpc[aniter]->SetPhiStarMin(kFALSE);
+                sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.045); // 0.012 - pions, 0.017 - kaons, 0.018
+                sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.15); // 0.017 - pions, 0.015 - kaons
+
+              }
+
+              anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]);
+
+              if (ichg == 2) {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc2etaphitpc[aniter]);
+              }
+              else {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]);
+              }
+
+              anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]);
+
+
+              if (ichg == 2) {
+                ckstartpc[aniter] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),nbinssh,0.0,shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(ckstartpc[aniter]);
+              }
+              else {
+
+                cqinvtpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2*nbinssh,0.0,2*shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(cqinvtpc[aniter]);
+
+              }
+
+              // cylmtpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),2,nbinssh, 0.0,shqmax,runshlcms);
+              // anetaphitpc[aniter]->AddCorrFctn(cylmtpc[aniter]);
+
+
+              // cAvgSeptpc[aniter] = new AliFemtoAvgSepCorrFctn(Form("cAvgSep%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),4*nbinssh,0.0,200);
+              // anetaphitpc[aniter]->AddCorrFctn(cAvgSeptpc[aniter]);
+
+              // cqinvinnertpc[aniter] = new AliFemtoTPCInnerCorrFctn(Form("cqinvinner%stpcM%d", chrgs[ichg], imult),nbinssh,0.0,shqmax);
+              // cqinvinnertpc[aniter]->SetRadius(1.2);
+              // anetaphitpc[aniter]->AddCorrFctn(cqinvinnertpc[aniter]);
+
+
+              if (runktdep) {
+                int ktm;
+                for (int ikt=0; ikt<numOfkTbins; ikt++) {
+
+                  ktm = aniter * numOfkTbins + ikt;
+                  ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]);
+
+
+                  cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%ikT%i", chrgs[ichg], imult, ikt),2,nbinssh,0.0,shqmax,runshlcms);
+                  cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                  anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]);
+
+                  if (ichg == 2) {
+                    ckstarkttpc[ktm] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),nbinssh,0.0,shqmax);
+                    ckstarkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                    anetaphitpc[aniter]->AddCorrFctn(ckstarkttpc[ktm]);
+
+
+                  }
+                  else {
+                    cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),2*nbinssh,0.0,2*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]->SetPairSelectionCut(ktpcuts[ktm]);
+                  //           anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]);
+                  //         }
+                }
+              }
+
+              // cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),240, 240);
+              // anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]);
+
+              Manager->AddAnalysis(anetaphitpc[aniter]);
+            }
+          }
+        }
+      }
+    }
+  }
+
+
+// *** End pion-pion (positive) analysis
+
+
+  return Manager;
+}
diff --git a/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/NoFlatCent/ConfigFemtoAnalysis.C b/PWGCF/FEMTOSCOPY/macros/Train/ProtonFemtoscopy/NoFlatCent/ConfigFemtoAnalysis.C
new file mode 100644 (file)
index 0000000..b109aad
--- /dev/null
@@ -0,0 +1,450 @@
+/*********************************************************************
+ *                                                                   *
+ * 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 "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 "AliFemtoCorrFctnNonIdDR.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 "AliFemtoAvgSepCorrFctn.h"
+#endif
+
+//________________________________________________________________________
+AliFemtoManager* ConfigFemtoAnalysis() {
+
+  double PionMass = 0.13956995;
+  double KaonMass = 0.493677;
+  double ProtonMass = 0.938272013;
+
+  // double psi = TMath::Pi()/2.;
+  // double psid = TMath::Pi()/6.;
+
+  // int runepvzero[7] = {1, 1, 1, 1, 1, 1, 1};
+  // double epvzerobins[7] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid, -psi+4*psid, -psi+5*psid, -psi+6*psid};
+
+  double psi = TMath::Pi()/2.;
+  double psid = TMath::Pi()/3.;
+
+  int runepvzero[4] = {0, 0, 0, 1};
+  double epvzerobins[4] = {-psi, -psi+psid, -psi+2*psid, -psi+3*psid};
+
+  int runmults[10] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
+  int multbins[11] = {0.001, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900};
+
+  int runch[3] = {1, 1, 1};
+  const char *chrgs[3] = { "PP", "APAP", "PAP" };
+
+  int runktdep = 0;
+  double ktrng[3] = {0.01, 1.0, 5.0};
+
+  int numOfMultBins = 10;
+  int numOfChTypes = 3;
+  int numOfkTbins = 2;
+  int numOfEPvzero = 4;
+
+  int runqinv = 1;
+  int runshlcms = 0;// 0:PRF(PAP), 1:LCMS(PP,APAP)
+
+  int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner
+  int isrealdata = 1;
+
+  //  int gammacut = 1;
+
+  double shqmax = 1.0;
+  int nbinssh = 100;
+
+  AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain();
+  Reader->SetFilterBit(7);
+  Reader->SetCentralityPreSelection(0.001, 310);
+  Reader->SetEPVZERO(kTRUE);
+  // Reader->SetCentralityFlattening(kTRUE);
+  // Reader->SetDCAglobalTrack(kTRUE);
+
+  AliFemtoManager* Manager = new AliFemtoManager();
+  Manager->SetEventReader(Reader);
+
+  AliFemtoVertexMultAnalysis    *anetaphitpc[10*3*2];
+  AliFemtoBasicEventCut         *mecetaphitpc[10*3*2];
+  AliFemtoCutMonitorEventMult   *cutPassEvMetaphitpc[50];
+  AliFemtoCutMonitorEventMult   *cutFailEvMetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[50];
+  // AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[50];
+  AliFemtoESDTrackCut           *dtc1etaphitpc[50];
+  AliFemtoESDTrackCut           *dtc2etaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[50];
+  AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[50];
+  //   AliFemtoPairCutAntiGamma      *sqpcetaphitpcdiff[10*3];
+  //   AliFemtoShareQualityTPCEntranceSepPairCut      *sqpcetaphitpcsame[10*3];
+  //AliFemtoPairCutAntiGamma      *sqpcetaphitpc[10*3];
+  AliFemtoPairCutRadialDistance      *sqpcetaphitpc[50];
+  //  AliFemtoChi2CorrFctn          *cchiqinvetaphitpc[20*2];
+  AliFemtoKTPairCut             *ktpcuts[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmtpc[50];
+  AliFemtoCorrFctnDirectYlm     *cylmkttpc[50*2];
+  AliFemtoCorrFctnDirectYlm     *cylmetaphitpc[10*3];
+  AliFemtoQinvCorrFctn          *cqinvkttpc[50*2];
+  AliFemtoQinvCorrFctn          *cqinvtpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstartpc[50];
+  AliFemtoCorrFctnNonIdDR       *ckstarkttpc[50*2];
+  AliFemtoCorrFctnDEtaDPhi      *cdedpetaphi[50*2];
+  AliFemtoAvgSepCorrFctn          *cAvgSeptpc[50];
+
+  //   AliFemtoCorrFctn3DLCMSSym     *cq3dlcmskttpc[20*2];
+  //   AliFemtoCorrFctnTPCNcls       *cqinvnclstpc[20];
+  //   AliFemtoShareQualityCorrFctn  *cqinvsqtpc[20*10];
+  //   AliFemtoChi2CorrFctn          *cqinvchi2tpc[20];
+    AliFemtoTPCInnerCorrFctn      *cqinvinnertpc[50];
+
+  // *** Third QA task - HBT analysis with all pair cuts off, TPC only ***
+  // *** Begin pion-pion (positive) analysis ***
+  int aniter = 0;
+
+  for (int imult = 0; imult < numOfMultBins; imult++) {
+    if (runmults[imult]) {
+
+      for (int ichg = 0; ichg < numOfChTypes; ichg++) {
+        if (runch[ichg]) {
+
+          for (int iepvzero = 0; iepvzero < numOfEPvzero; iepvzero++) {
+            if (runepvzero[iepvzero]) {
+
+              aniter = imult * numOfChTypes + ichg * numOfEPvzero + iepvzero;
+              // aniter = ichg * numOfMultBins + imult * numOfEPvzero + iepvzero;
+
+              // cout << "aniter = " << aniter << endl;
+              //        aniter = ichg * numOfMultBins + imult;
+
+              // if (ichg == 2)
+              //       runshlcms = 0;
+              // else
+              //       runshlcms = 1;
+
+
+              //________________________
+
+              anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(8, -8.0, 8.0, 4, multbins[imult], multbins[imult+1]);
+              anetaphitpc[aniter]->SetNumEventsToMix(10);
+              anetaphitpc[aniter]->SetMinSizePartCollection(1);
+              anetaphitpc[aniter]->SetVerboseMode(kFALSE);
+
+              mecetaphitpc[aniter] = new AliFemtoBasicEventCut();
+              mecetaphitpc[aniter]->SetEventMult(0.001,100000);
+              mecetaphitpc[aniter]->SetVertZPos(-8,8);
+
+              if (iepvzero == 3)
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[0],epvzerobins[3]);
+              else
+                mecetaphitpc[aniter]->SetEPVZERO(epvzerobins[iepvzero],epvzerobins[iepvzero+1]);
+
+              // if (isrealdata)
+              //     mecetaphitpc[aniter]->SetAcceptOnlyPhysics(kTRUE);
+
+              cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero));
+              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]);
+
+              dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut();
+              dtc2etaphitpc[aniter] = new AliFemtoESDTrackCut();
+
+              if (ichg == 0) {
+                dtc1etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 1) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+              else if (ichg == 2) {
+                dtc1etaphitpc[aniter]->SetCharge(-1.0);
+                dtc2etaphitpc[aniter]->SetCharge(1.0);
+                dtc1etaphitpc[aniter]->SetPt(0.7,4.0);
+                dtc2etaphitpc[aniter]->SetPt(0.7,4.0);
+              }
+
+              dtc1etaphitpc[aniter]->SetEta(-0.8,0.8);
+              dtc1etaphitpc[aniter]->SetMass(ProtonMass);
+              dtc1etaphitpc[aniter]->SetMostProbableProton();
+              dtc1etaphitpc[aniter]->SetNsigma(3.0);
+              //dtc1etaphitpc[aniter]->SetNsigma(2.0);
+              dtc1etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+              //dtc1etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              if (ichg == 2) {
+                dtc2etaphitpc[aniter]->SetEta(-0.8,0.8);
+                dtc2etaphitpc[aniter]->SetMass(ProtonMass);
+                dtc2etaphitpc[aniter]->SetMostProbableProton();
+                dtc2etaphitpc[aniter]->SetNsigma(3.0);
+                //dtc2etaphitpc[aniter]->SetNsigma(2.0);
+                dtc2etaphitpc[aniter]->SetNsigmaTPCTOF(kTRUE);
+                //dtc2etaphitpc[aniter]->SetNsigmaTPConly(kTRUE);
+
+              }
+
+              // Track quality cuts
+
+              if (runtype == 0) {
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                //            dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.15);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 1) {
+                //      dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                //    dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit);
+                //         dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA);
+                //      dtc1etaphitpc[aniter]->SetminTPCncls(70);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                //    dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0);
+                //      dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2);
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(0.25);
+                //      dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0);
+              }
+              else if (runtype == 2) {
+                //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                dtc1etaphitpc[aniter]->SetminTPCncls(80);
+                dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                dtc1etaphitpc[aniter]->SetLabel(kFALSE);
+                dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                dtc1etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+
+                if (ichg == 2) {
+                  //dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit);
+                  dtc2etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin);
+                  dtc2etaphitpc[aniter]->SetminTPCncls(80);
+                  dtc2etaphitpc[aniter]->SetRemoveKinks(kTRUE);
+                  dtc2etaphitpc[aniter]->SetLabel(kFALSE);
+                  dtc2etaphitpc[aniter]->SetMaxTPCChiNdof(4.0);
+                  dtc2etaphitpc[aniter]->SetMaxImpactXY(2.4); // 2.4 0.1
+                  // dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0205, 0.035, -1.1);     //      DCA xy
+                  //dtc2etaphitpc[aniter]->SetMaxImpactXYPtDep(0.018, 0.035, -1.01);     //      DCA xy
+                  dtc2etaphitpc[aniter]->SetMaxImpactZ(3.2); // 2.0 0.1
+                }
+
+              }
+
+              // cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              // cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),ProtonMass);
+              // dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]);
+
+              // cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2);//0-pion,1-kaon,2-proton
+              // cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%iPsi%i", chrgs[ichg], imult , iepvzero),2);
+              // dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]);
+
+              // if (ichg == 2){
+              //     cutPass2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass2%stpcM%i", chrgs[ichg], imult),2);//0-pion,1-kaon,2-proton
+              //     cutFail2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail2%stpcM%i", chrgs[ichg], imult),2);
+              //     dtc2etaphitpc[aniter]->AddCutMonitor(cutPass2PIDetaphitpc[aniter], cutFail2PIDetaphitpc[aniter]);
+              // }
+
+              // sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma();
+              sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance();
+
+              if (runtype == 0) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 1) {
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(1.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+                // sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                // sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //         sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0);
+                //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03);
+                //         sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02);
+              }
+              else if (runtype == 2) {
+                //sqpcetaphitpc[aniter]->SetUseAOD(kTRUE);
+
+                sqpcetaphitpc[aniter]->SetShareQualityMax(1.0);
+                sqpcetaphitpc[aniter]->SetShareFractionMax(0.05);
+                sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE);
+
+                //         if (gammacut == 0) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0);
+                //}
+                //else if (gammacut == 1) {
+                //sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002);
+                //sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008);
+                //}
+
+                // sqpcetaphitpc[aniter]->SetMagneticFieldSign(-1); // field1 -1, field3 +1
+                // sqpcetaphitpc[aniter]->SetMinimumRadius(0.8); // biggest inefficiency for R=1.1 m (checked on small sample)
+
+                sqpcetaphitpc[aniter]->SetMinimumRadius(1.2); //0.8
+                sqpcetaphitpc[aniter]->SetPhiStarMin(kFALSE);
+                sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.045); // 0.012 - pions, 0.017 - kaons, 0.018
+                sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.15); // 0.017 - pions, 0.015 - kaons
+
+              }
+
+              anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]);
+
+              if (ichg == 2) {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc2etaphitpc[aniter]);
+              }
+              else {
+                anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]);
+                anetaphitpc[aniter]->SetSecondParticleCut(dtc1etaphitpc[aniter]);
+              }
+
+              anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]);
+
+
+              if (ichg == 2) {
+                ckstartpc[aniter] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),nbinssh,0.0,shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(ckstartpc[aniter]);
+              }
+              else {
+
+                cqinvtpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),2*nbinssh,0.0,2*shqmax);
+                anetaphitpc[aniter]->AddCorrFctn(cqinvtpc[aniter]);
+
+              }
+
+              // cylmtpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),2,nbinssh, 0.0,shqmax,runshlcms);
+              // anetaphitpc[aniter]->AddCorrFctn(cylmtpc[aniter]);
+
+
+              // cAvgSeptpc[aniter] = new AliFemtoAvgSepCorrFctn(Form("cAvgSep%stpcM%iPsi%i", chrgs[ichg], imult, iepvzero),4*nbinssh,0.0,200);
+              // anetaphitpc[aniter]->AddCorrFctn(cAvgSeptpc[aniter]);
+
+              // cqinvinnertpc[aniter] = new AliFemtoTPCInnerCorrFctn(Form("cqinvinner%stpcM%d", chrgs[ichg], imult),nbinssh,0.0,shqmax);
+              // cqinvinnertpc[aniter]->SetRadius(1.2);
+              // anetaphitpc[aniter]->AddCorrFctn(cqinvinnertpc[aniter]);
+
+
+              if (runktdep) {
+                int ktm;
+                for (int ikt=0; ikt<numOfkTbins; ikt++) {
+
+                  ktm = aniter * numOfkTbins + ikt;
+                  ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]);
+
+
+                  cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%ikT%i", chrgs[ichg], imult, ikt),2,nbinssh,0.0,shqmax,runshlcms);
+                  cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                  anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]);
+
+                  if (ichg == 2) {
+                    ckstarkttpc[ktm] = new AliFemtoCorrFctnNonIdDR(Form("ckstar%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),nbinssh,0.0,shqmax);
+                    ckstarkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]);
+                    anetaphitpc[aniter]->AddCorrFctn(ckstarkttpc[ktm]);
+
+
+                  }
+                  else {
+                    cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%iPsi%ikT%i", chrgs[ichg], imult, iepvzero, ikt),2*nbinssh,0.0,2*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]->SetPairSelectionCut(ktpcuts[ktm]);
+                  //           anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]);
+                  //         }
+                }
+              }
+
+              // cdedpetaphi[aniter] = new AliFemtoCorrFctnDEtaDPhi(Form("cdedp%stpcM%i", chrgs[ichg], imult),240, 240);
+              // anetaphitpc[aniter]->AddCorrFctn(cdedpetaphi[aniter]);
+
+              Manager->AddAnalysis(anetaphitpc[aniter]);
+            }
+          }
+        }
+      }
+    }
+  }
+
+
+// *** End pion-pion (positive) analysis
+
+
+  return Manager;
+}
index c55dd8f648f78a04cfd6e4e9e1e8a2796440e4f0..a5e6a7cf9bd90e34b7adfbb56eceae8b5abf9609 100644 (file)
@@ -1,4 +1,4 @@
-void runGlauberMC()
+void runGlauberMC(Bool_t doPartProd=0,Int_t option=0,Int_t N=250000)
 {
   //load libraries
   gSystem->Load("libVMC");
@@ -11,7 +11,7 @@ void runGlauberMC()
   Int_t seed = time.GetSec();
   gRandom->SetSeed(seed);
 
-  Int_t nevents = 1000000; // number of events to simulate 
+  Int_t nevents = N; // number of events to simulate 
   // supported systems are e.g. "p", "d", "Si", "Au", "Pb", "U" 
   Option_t *sysA="Pb"; 
   Option_t *sysB="Pb";
@@ -30,7 +30,11 @@ void runGlauberMC()
   mcg.SetMinDistance(mind);
   mcg.Setr(r);
   mcg.Seta(a);
-  mcg.SetDoPartProduction(kTRUE);
+  if (option==1) 
+    mcg.SetDoFluc(0.55,78.5*0.92,0.82,kTRUE);
+  else if (option==2) 
+    mcg.SetDoFluc(1.01,72.5*0.92,0.74,kTRUE);
+  mcg.SetDoPartProduction(doPartProd);
   
   //////////////////
   mcg.SetdNdEtaType(AliGlauberMC::kNBDSV);
index 4a90a3c5bec53448f53957ef5fcefe38dfa12652..2170a661cc7e94027a8bd272d40d1b69c53b0ff7 100644 (file)
@@ -31,9 +31,9 @@ void runGlauberMCpPb(Int_t option=0,Int_t N=250000)
   mcg.Setr(r);
   mcg.Seta(a);
   if (option==1) 
-    mcg.SetDoFluc(0.55,72.5,0.85,kTRUE);
+    mcg.SetDoFluc(0.55,78.5,0.82,kTRUE);
   else if (option==2) 
-    mcg.SetDoFluc(1.01,72.5,0.7,kTRUE);
+    mcg.SetDoFluc(1.01,72.5,0.74,kTRUE);
   mcg.SetDoPartProduction(kFALSE);
   
   //////////////////
index d8f8e08f411af73b494a3f8d93c5ccf1fbf8b9df..150751a7bf969ef0a7ef8755cc260b1f9b4944d7 100644 (file)
@@ -299,17 +299,17 @@ void AddTaskFlowHigherOrdersAllPID(Int_t triggerSelectionString,
     mgr->AddTask(taskQC[i]);
   }
   }
-  if(doPIDQA){
-     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
-     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");    
+//  if(doPIDQA){
+//     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
+//     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");    
 //     taskPIDQA = new AliAnalysisTaskPIDqa(Form("TaskPIDQA_%s",QASlotName.Data()));
 //     taskPIDQA->SelectCollisionCandidates(triggerSelectionString);
-     AddTaskPIDResponse(kFALSE);
-     AddTaskPIDqa();     
+//     AddTaskPIDResponse(kFALSE);
//    AddTaskPIDqa();     
 //     mgr->AddTask(taskPIDQA);
 
      
-  }
+//  }
 
   // Create the output container for the data produced by the task
   // Connect to the input and output containers
index 6bdb8ed74d76b46800c7b1f042808202252080bd..adb22c62fc174195d52f1eb7237b10fa49518f9e 100644 (file)
@@ -53,6 +53,7 @@ Bool_t SFT_gbSPVZE;
 Bool_t SFT_gbSPTPC;
 Bool_t SFT_gbSPVZEhalf;
 Bool_t SFT_gbQCTPC;
+Bool_t SFT_gbMCEP;
 Int_t SFT_gbHarmonic;
 TString SFT_gbVZEload;
 Bool_t SFT_gbVZEsave;
@@ -64,6 +65,8 @@ Int_t SFT_gbV0ARingMin;
 Int_t SFT_gbV0ARingMax;
 
 Bool_t SFT_gbUntagDaughter;
+Int_t SFT_gbPostMatched;
+Double_t SFT_gbVertexZcut;
 
 void AddTaskFlowStrange(TString configFile, TString alienaddress,
                        Int_t VZECm=0, Int_t VZECM=3, Int_t VZEAm=0, Int_t VZEAM=3) {
@@ -122,6 +125,7 @@ void AddTaskFlowStrange() {
   AliAnalysisTaskFlowStrange *taskSel = new AliAnalysisTaskFlowStrange(Form("FS_%s",SFT_gbStamp.Data()) );
   taskSel->SelectCollisionCandidates(SFT_gbTrigger);
   taskSel->SetReadESD(SFT_gbReadESD);
+  taskSel->SetPostMatched(SFT_gbPostMatched);
   taskSel->SetReadMC(SFT_gbReadMC);
   taskSel->SetAvoidExec(SFT_gbAvoidExec);
   taskSel->SetSkipSelection(SFT_gbSkipSelection);
@@ -149,6 +153,7 @@ void AddTaskFlowStrange() {
   taskSel->SetRFPMinTPCCls(SFT_gbRFPTPCncls);
 
   taskSel->SetDauUnTagProcedure(SFT_gbUntagDaughter);
+  taskSel->SetVertexZcut(SFT_gbVertexZcut);
 
   taskSel->SetDauMinNClsTPC(SFT_gbMinNClsTPC);
   taskSel->SetDauMinXRows(SFT_gbMinXRows);
@@ -207,17 +212,22 @@ void AddTaskFlowStrange() {
   if( (!SFT_gbQCTPC) && (!SFT_gbSPVZE) && (!SFT_gbSPTPC) ) return;
   //-------------------FLOWPACKAGE TASKS----------------------------
   AliFlowTrackSimpleCuts *filter[20], *filterhf[20][2]; // MASS BANDS
-  for(int mb=0; mb!=SFT_MassBands(SFT_gbSpecie); ++mb) {
+  int mbs = SFT_MassBands(SFT_gbSpecie);
+  if(SFT_gbPostMatched) mbs = 1;
+  for(int mb=0; mb!=mbs; ++mb) {
     filter[mb] = new AliFlowTrackSimpleCuts( Form("Filter_MB%d",mb) );
     filter[mb]->SetEtaMin( -0.8 ); filter[mb]->SetEtaMax( +0.8 );
-    filter[mb]->SetMassMin( SFT_MassBandLowEdge(SFT_gbSpecie,mb) ); filter[mb]->SetMassMax( SFT_MassBandLowEdge(SFT_gbSpecie,mb+1) );
+    Double_t minmass = SFT_MassBandLowEdge(SFT_gbSpecie,mb);
+    Double_t maxmass = SFT_MassBandLowEdge(SFT_gbSpecie,mb+1);
+    if(SFT_gbPostMatched) maxmass = SFT_MassBandLowEdge(SFT_gbSpecie,SFT_MassBands(SFT_gbSpecie));
+    filter[mb]->SetMassMin( minmass ); filter[mb]->SetMassMax( maxmass );
     //half window for POIs
     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( SFT_MassBandLowEdge(SFT_gbSpecie,mb) ); filterhf[mb][0]->SetMassMax( SFT_MassBandLowEdge(SFT_gbSpecie,mb+1) );
+    filterhf[mb][0]->SetMassMin( minmass ); filterhf[mb][0]->SetMassMax( maxmass );
     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( SFT_MassBandLowEdge(SFT_gbSpecie,mb) ); filterhf[mb][1]->SetMassMax( SFT_MassBandLowEdge(SFT_gbSpecie,mb+1) );
+    filterhf[mb][1]->SetMassMin( minmass ); filterhf[mb][1]->SetMassMax( maxmass );
     if(SFT_gbQCTPC) {
       SFT_AddQCmethod( Form("QCTPCMB%d",mb), exc_TPC, filter[mb]); // QC TPC
     }
@@ -229,6 +239,9 @@ void AddTaskFlowStrange() {
       SFT_AddSPmethod( Form("SPTPC4MB%d",mb), exc_TPC, filterhf[mb][0], "Qa", 0.4 ); // SP TPC Qa
       SFT_AddSPmethod( Form("SPTPC4MB%d",mb), exc_TPC, filterhf[mb][1], "Qb", 0.4 ); // SP TPC Qb
     }
+    if(SFT_gbMCEP) {
+      SFT_AddMCEPmethod( Form("MCEPMB%d",mb), exc_TPC, filter[mb]); // MCEP TPC
+    }
     if(SFT_gbSPVZE) {
       if(SFT_gbSPVZEhalf) {
        SFT_AddSPmethod( Form("SPVZEMB%d",mb), exc_VZE, filterhf[mb][0], "Qa", 1.0 ); // SP VZE Qa
@@ -240,6 +253,27 @@ void AddTaskFlowStrange() {
     }
   }
 }
+void SFT_AddMCEPmethod(char *name, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI=NULL) {
+  TString fileName = AliAnalysisManager::GetCommonFileName();
+  TString myFolder = Form("%sv%d",SFT_gbFolder.Data(),SFT_gbHarmonic);
+  TString myName = Form("%sv%d_%s",name,SFT_gbHarmonic,SFT_gbSuffix.Data());
+  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:FlowStrange_MCEP_%s",fileName.Data(),myFolder.Data()) );
+  AliAnalysisTaskMCEventPlane *tskQC = new AliAnalysisTaskMCEventPlane( Form("TaskMCEP_%s",myName.Data()) );
+  tskQC->SetHarmonic(SFT_gbHarmonic);
+  mgr->AddTask(tskQC);
+  mgr->ConnectInput( tskQC,0,flowEvent2);
+  mgr->ConnectOutput(tskQC,1,outQC);
+}
 void SFT_AddQCmethod(char *name, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI=NULL) {
   TString fileName = AliAnalysisManager::GetCommonFileName();
   TString myFolder = Form("%sv%d",SFT_gbFolder.Data(),SFT_gbHarmonic);
@@ -289,6 +323,8 @@ void SFT_AddSPmethod(char *name, AliAnalysisDataContainer *flowEvent, AliFlowTra
   mgr->ConnectOutput(tskSP,1,outSP);
 }
 double SFT_MassBandLowEdge( int nv0, int mb ) {
+  if(nv0>10&&mb==0) return -5;
+  if(nv0>10&&mb==1) return +5;
   switch(nv0) {
   case(0):
     double lowEdge[14]={0.398, 0.420, 0.444, 0.468, 0.486,
@@ -301,8 +337,6 @@ double SFT_MassBandLowEdge( int nv0, int mb ) {
                        1.148, 1.158, 1.168};
     break;
   }
-  if(nv0>10&&mb==0) return -5;
-  if(nv0>10&&mb==1) return +5;
   return lowEdge[mb];
 }
 int SFT_MassBands( int nv0 ) {
@@ -346,10 +380,12 @@ void SFT_PrintConfig() {
   printf("* AVOIDEXEC  %3d                  *\n", SFT_gbAvoidExec );
   printf("* ESD  %3d                        *\n", SFT_gbReadESD );
   printf("* MC  %3d                         *\n", SFT_gbReadMC );
+  printf("* POSTMATCHED  %3d                *\n", SFT_gbPostMatched );
   printf("* EXTRAEVENTCUT  %3d              *\n", SFT_gbExtraEventCut );
   printf("* CENTMETHOD  %8s                 *\n", SFT_gbCentMethod.Data() );
   printf("* CENTPERMIN  %3d                 *\n", SFT_gbCentPerMin );
   printf("* CENTPERMAX  %3d                 *\n", SFT_gbCentPerMax );
+  printf("* VERTEXZ  %+9.6f             *\n", SFT_gbVertexZcut );
   printf("* SPECIE  %3d                     *\n", SFT_gbSpecie );
   printf("* HOMEMADE  %3d                   *\n", SFT_gbHomemade );
   printf("* ONLINE  %3d                     *\n", SFT_gbOnline );
@@ -380,6 +416,7 @@ void SFT_PrintConfig() {
   printf("* SPVZEHALF  %3d                  *\n", SFT_gbSPVZEhalf );
   printf("* SPTPC  %3d                      *\n", SFT_gbSPTPC );
   printf("* QCTPC  %3d                      *\n", SFT_gbQCTPC );
+  printf("* MCEP  %3d                       *\n", SFT_gbMCEP );
   printf("* SHRINKFP  %3d                   *\n", SFT_gbShrinkFP );
   printf("* RFFILTERBIT  %3d                *\n", SFT_gbRFPFilterBit );
   printf("* RFMINPT  %+9.6f             *\n", SFT_gbRFPminPt );
@@ -390,6 +427,7 @@ void SFT_PrintConfig() {
   printf("* RFMAXIPXY  %+9.6f           *\n", SFT_gbRFPmaxIPxy );
   printf("* RFMAXIPZ  %+9.6f            *\n", SFT_gbRFPmaxIPz );
   printf("* RFTPCNCLS  %3d                  *\n", SFT_gbRFPTPCncls );
+  printf("* WHICHPSI  %3d                   *\n", SFT_gbWhichPsi );
   printf("* VZELOAD  %8s            *\n", SFT_gbVZEload.Data() );
   printf("* VZELINEAR  %3d                  *\n", SFT_gbVZEmb );
   printf("* VZEPERDISK  %3d                 *\n", SFT_gbVZEpdisk );
@@ -489,8 +527,10 @@ void SFT_ReadConfig(TString ipf) {
       input >> SFT_gbSPVZEhalf;
     } else if(!varname.CompareTo("QCTPC")) {
       input >> SFT_gbQCTPC;
+    } else if(!varname.CompareTo("MCEP")) {
+      input >> SFT_gbMCEP;
     } else if(!varname.CompareTo("SHRINKFP")) {
-      input >> SFT_ShrinkFP;
+      input >> SFT_gbShrinkFP;
     } else if(!varname.CompareTo("RFFILTERBIT")) {
       input >> SFT_gbRFPFilterBit;
     } else if(!varname.CompareTo("RFMINPT")) {
@@ -521,6 +561,12 @@ void SFT_ReadConfig(TString ipf) {
       input >> SFT_gbAllCC;
     } else if(!varname.CompareTo("UNTAG")) {
       input >> SFT_gbUntagDaughter;
+    } else if(!varname.CompareTo("POSTMATCHED")) {
+      input >> SFT_gbPostMatched;
+    } else if(!varname.CompareTo("VERTEXZ")) {
+      input >> SFT_gbVertexZcut;
+    } else if(!varname.CompareTo("WHICHPSI")) {
+      input >> SFT_gbWhichPsi;
     } else {
       printf("I dont understand %s\n",varname.Data());
     }
@@ -580,11 +626,14 @@ void SFT_ResetVars() {
   SFT_gbSPVZEhalf=kFALSE;
   SFT_gbSPTPC=0;
   SFT_gbQCTPC=0;
+  SFT_gbMCEP=0;
   SFT_gbHarmonic=2;
   SFT_gbVZEload="no";
   SFT_gbVZEsave=0;
   SFT_gbVZEmb=0;
   SFT_gbVZEpdisk=0;
   SFT_gbUntagDaughter=kTRUE;
+  SFT_gbPostMatched=kFALSE;
   SFT_gbShrinkFP=kTRUE;
+  SFT_gbVertexZcut=10.0;
 }
index 7a3c5c8d2358b4021a6843e874cf993dbeba6362..ae6fca7414453093b492f48159724b369fa013f8 100644 (file)
@@ -1,9 +1,15 @@
 void jetFlowTools() {
     // load and compile the libraries
+    // make sure that you have ROOUNFOLD available on your machine,
+    // (see http://hepunx.rl.ac.uk/~adye/software/unfold/RooUnfold.html ).
+    // and make sure that the Load() function knows where to find
+    // the libraries
     Load();
 
-   // read detector response from output of matching taks
+    // read detector response from output of matching task
     // AliAnalysisTaskJetMatching
+    // the detector response can also be set manually by
+    // calling AliJetFlowTools::SetDetectorResponse(TH2D*)
     TString drInputName = "response.root";
     printf("- Reading file %s ... \n", drInputName.Data());
     TFile drInput(drInputName.Data());          // detector response input matrix
@@ -18,6 +24,10 @@ void jetFlowTools() {
     } else printf(" > Found detector response < \n");
 
     // get a TList from the AliAnalysisRhoVnModulation task
+    // this will be used as input for the unfolding (jet spectra, dpt distribution)
+    // input can also be set manually, by calling
+    // AliJetFlowTools::SetRawInput() see the header of AliJetFlowTools.h for a full
+    // list of necessary input histograms
     TFile f("AnalysisResults.root");
     if(f.IsZombie()) {
         printf(" > read error ! < \n");
@@ -29,15 +39,17 @@ void jetFlowTools() {
         return;
     }
     // create an instance of the Tools class
+    // one instance will do all the unfolding
     AliJetFlowTools* tools = new AliJetFlowTools();
-    // set some common variables
-    tools->SetCentralityBin(2);
+    // set some common variables 
+    tools->SetCentralityBin(2); // bin only makes sense when output is taken from AliAnalysisRhoVnModulation
     tools->SetDetectorResponse(detres);
 
     // set the true (unfolded) bins
     Double_t binsTrue[] = {5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150};
     tools->SetBinsTrue(new TArrayD(sizeof(binsTrue)/sizeof(binsTrue[0]), binsTrue));
     // set the same binning scheme to be used when chi2 is taken as a prior
+    // if not set, binsTrue is used
     tools->SetBinsTruePrior(new TArrayD(sizeof(binsTrue)/sizeof(binsTrue[0]), binsTrue));
 
 
@@ -48,10 +60,11 @@ void jetFlowTools() {
     // set the same binning scheme to be used when chi2 is taken as a prior
     tools->SetBinsRecPrior(new TArrayD(sizeof(binsRec)/sizeof(binsRec[0]), binsRec));
 
-    // connect input
+    // connect input (when using output from AliAnalysisRhoVnModulation)
     tools->SetInputList(l);
     // unfold using different parameters
 
+    // configuration. for all avaialble options, see AliJetFlowTools.h
     tools->SetSmoothenSpectrum(kTRUE, 50, 100, 70);
     tools->SetNormalizeSpectra(10000);
     tools->SetUseDetectorResponse(kTRUE);
@@ -61,20 +74,7 @@ void jetFlowTools() {
     tools->CreateOutputList(TString("do_nothing"));
     tools->Make();
     tools->SetTestMode(kTRUE);
-/* 
-    // do some chi2 unfolding in test mode
-    tools->SetUnfoldingAlgorithm(AliJetFlowTools::kChi2);
-    Double_t b = 0.05;
-    tools->CreateOutputList(TString(Form("test_beta%.2f", b)));
-    tools->SetBeta(b);
-    tools->Make();
-    b = 0.1;
-    tools->CreateOutputList(TString(Form("test_beta%.2f", b)));
-    tools->SetBeta(b);
-    tools->Make();
-*/
-   
-    tools->SetTestMode(kFALSE);
     // do some chi2 unfolding
     tools->SetUnfoldingAlgorithm(AliJetFlowTools::kChi2);
     Double_t b = 0.05;
@@ -93,17 +93,26 @@ void jetFlowTools() {
     // svd unfolding prefers diffefrent binning
     Double_t binsRec2[] = {25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 95};
     tools->SetBinsRec(new TArrayD(sizeof(binsRec2)/sizeof(binsRec2[0]), binsRec2));
-
     for(Int_t j(3); j < 7; j++) {
         tools->CreateOutputList(TString(Form("SVD_kreg_%i", j)));
         tools->SetSVDReg(j);
         tools->Make();
     }
-    // finish the unfolding
-    // will write the output to file
-    
-    tools->Finish();
+   
+    // bayesian unfolding, different number of iterations
+   for(Int_t k(1); k < 5; k++) {
+      tools->SetUnfoldingAlgorithm(AliJetFlowTools::kBayesian);
+      tools->SetBayesianIter(k);
+      tools->CreateOutputList(TString(Form("Bayes iter %i", k)));
+      tools->Make();
+   }
+   // finish the unfolding
+   // will write the output to file
+   tools->Finish();
+
+   // do some post processing (compares unfolding results from different methods, etc)
+   tools->PostProcess(TString("SVD kReg 4"));
+
 }
 
 //_____________________________________________________________________________
@@ -143,6 +152,6 @@ void Load() {
     gSystem->AddIncludePath("-I/home/redmer/Documents/CERN/alice/BUILDS/ROOUNFOLD/RooUnfold-1.1.1/src/");
     // compile unfolding class
     
-    gROOT->LoadMacro("$ALICE_ROOT/PWG/FLOW/Tasks/AliJetFlowTools.cxx++g");
+    gROOT->LoadMacro("$ALICE_ROOT/PWG/FLOW/Tasks/AliJetFlowTools.cxx+");
 }
 //_____________________________________________________________________________
index 86102d11e8745e924dd82cefbc7cd1f3f3a6e2af..3ac67151f37349e571b019f85a64b4948741138a 100644 (file)
@@ -5,6 +5,7 @@
 #pragma link off all functions;
 
 #pragma link C++ class AliAnalysisTaskDptDptCorrelations+;
+#pragma link C++ class AliDptDptInMC+;
 #pragma link C++ class AliAnalysisTask3PCorrelations+;
 #pragma link C++ class AliAnalysisTaskPhiCorrelations+;
 #pragma link C++ class AliDPhiBasicParticle+;
index e5097250cbbf7b65f6211088b6ef3a4a65bbb419..bd8ccad718a2cf4bc56b7f75c55ad3d23409d742 100644 (file)
@@ -46,6 +46,7 @@ The names are available via the function PairClassName(Int_t i)
 #include <TList.h>
 #include <TMath.h>
 #include <TObject.h>
+#include <TGrid.h>
 
 #include <AliKFParticle.h>
 
@@ -66,6 +67,7 @@ The names are available via the function PairClassName(Int_t i)
 #include "AliDielectronSignalMC.h"
 #include "AliDielectronMixingHandler.h"
 #include "AliDielectronV0Cuts.h"
+#include "AliDielectronPID.h"
 
 #include "AliDielectron.h"
 
@@ -97,6 +99,8 @@ AliDielectron::AliDielectron() :
   TNamed("AliDielectron","AliDielectron"),
   fCutQA(kFALSE),
   fQAmonitor(0x0),
+  fPostPIDCntrdCorr(0x0),
+  fPostPIDWdthCorr(0x0),
   fEventFilter("EventFilter"),
   fTrackFilter("TrackFilter"),
   fPairPreFilter("PairPreFilter"),
@@ -127,7 +131,10 @@ AliDielectron::AliDielectron() :
   fEstimatorFilename(""),
   fTRDpidCorrectionFilename(""),
   fVZEROCalibrationFilename(""),
-  fVZERORecenteringFilename("")
+  fVZERORecenteringFilename(""),
+  fEffMapFilename(""),
+  fZDCRecenteringFilename("")
+
 {
   //
   // Default constructor
@@ -140,6 +147,8 @@ AliDielectron::AliDielectron(const char* name, const char* title) :
   TNamed(name,title),
   fCutQA(kFALSE),
   fQAmonitor(0x0),
+  fPostPIDCntrdCorr(0x0),
+  fPostPIDWdthCorr(0x0),
   fEventFilter("EventFilter"),
   fTrackFilter("TrackFilter"),
   fPairPreFilter("PairPreFilter"),
@@ -170,7 +179,9 @@ AliDielectron::AliDielectron(const char* name, const char* title) :
   fEstimatorFilename(""),
   fTRDpidCorrectionFilename(""),
   fVZEROCalibrationFilename(""),
-  fVZERORecenteringFilename("")
+  fVZERORecenteringFilename(""),
+  fEffMapFilename(""),
+  fZDCRecenteringFilename("")
 {
   //
   // Named constructor
@@ -185,6 +196,8 @@ AliDielectron::~AliDielectron()
   // Default destructor
   //
   if (fQAmonitor) delete fQAmonitor;
+  if (fPostPIDCntrdCorr) delete fPostPIDCntrdCorr;
+  if (fPostPIDWdthCorr) delete fPostPIDWdthCorr;
   if (fHistos) delete fHistos;
   if (fPairCandidates) delete fPairCandidates;
   if (fDebugTree) delete fDebugTree;
@@ -214,17 +227,31 @@ void AliDielectron::Init()
     fTrackRotator->SetPdgLegs(fPdgLeg1,fPdgLeg2);
   }
   if (fDebugTree) fDebugTree->SetDielectron(this);
-  if(fEstimatorFilename.Contains(".root")) AliDielectronVarManager::InitEstimatorAvg(fEstimatorFilename.Data());
+
+  TString allfiles = fEstimatorFilename;
+  allfiles+=fTRDpidCorrectionFilename;
+  allfiles+=fVZEROCalibrationFilename;
+  allfiles+=fVZERORecenteringFilename;
+  allfiles+=fEffMapFilename;
+  allfiles+=fZDCRecenteringFilename;
+  if(allfiles.Contains("alien://")) TGrid::Connect("alien://",0,0,"t");
+
+  if(fEstimatorFilename.Contains(".root"))        AliDielectronVarManager::InitEstimatorAvg(fEstimatorFilename.Data());
   if(fTRDpidCorrectionFilename.Contains(".root")) AliDielectronVarManager::InitTRDpidEffHistograms(fTRDpidCorrectionFilename.Data());
   if(fVZEROCalibrationFilename.Contains(".root")) AliDielectronVarManager::SetVZEROCalibrationFile(fVZEROCalibrationFilename.Data());
   if(fVZERORecenteringFilename.Contains(".root")) AliDielectronVarManager::SetVZERORecenteringFile(fVZERORecenteringFilename.Data());
-  
+  if(fEffMapFilename.Contains(".root"))           AliDielectronVarManager::InitEffMap(fEffMapFilename.Data());
+  if(fZDCRecenteringFilename.Contains(".root")) AliDielectronVarManager::SetZDCRecenteringFile(fZDCRecenteringFilename.Data());
+
   if (fMixing) fMixing->Init(this);
   if (fHistoArray) {
     fHistoArray->SetSignalsMC(fSignalsMC);
     fHistoArray->Init();
   }
 
+  if(fPostPIDCntrdCorr) AliDielectronPID::SetCentroidCorrFunction(fPostPIDCntrdCorr);
+  if(fPostPIDWdthCorr)  AliDielectronPID::SetWidthCorrFunction(fPostPIDWdthCorr);
+
   if (fCutQA) {
     fQAmonitor = new AliDielectronCutQA(Form("QAcuts_%s",GetName()),"QAcuts");
     fQAmonitor->AddTrackFilter(&fTrackFilter);
@@ -1357,3 +1384,20 @@ void AliDielectron::FillMCHistograms(const AliVEvent *ev) {
   } //loop: MCsignals
 
 }
+
+//______________________________________________
+void AliDielectron::SetCentroidCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary, UInt_t varz)
+{
+  fun->GetHistogram()->GetXaxis()->SetUniqueID(varx);
+  fun->GetHistogram()->GetYaxis()->SetUniqueID(vary);
+  fun->GetHistogram()->GetZaxis()->SetUniqueID(varz);
+  fPostPIDCntrdCorr=fun;
+}
+//______________________________________________
+void AliDielectron::SetWidthCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary, UInt_t varz)
+{
+  fun->GetHistogram()->GetXaxis()->SetUniqueID(varx);
+  fun->GetHistogram()->GetYaxis()->SetUniqueID(vary);
+  fun->GetHistogram()->GetZaxis()->SetUniqueID(varz);
+  fPostPIDWdthCorr=fun;
+}
index 4a133de36673daff66a20d0a9d24cad187f821b5..909fa86cc5554c1da84ff2900bbc9a715cf1a37e 100644 (file)
@@ -129,6 +129,12 @@ public:
   void SetTRDcorrectionFilename(const Char_t* filename) {fTRDpidCorrectionFilename = filename;}
   void SetVZEROCalibrationFilename(const Char_t* filename) {fVZEROCalibrationFilename = filename;}
   void SetVZERORecenteringFilename(const Char_t* filename) {fVZERORecenteringFilename = filename;}
+  void SetEffMapFilename(const Char_t* filename) {fEffMapFilename = filename;}
+
+  void SetZDCRecenteringFilename(const Char_t* filename) {fZDCRecenteringFilename = filename;}
+
+  void SetCentroidCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary=0, UInt_t varz=0);
+  void SetWidthCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary=0, UInt_t varz=0);
 
   void SaveDebugTree();
 
@@ -136,6 +142,8 @@ private:
 
   Bool_t fCutQA;                    // monitor cuts
   AliDielectronCutQA *fQAmonitor;   // monitoring of cuts
+  TF1 *fPostPIDCntrdCorr;   // post pid correction object for centroids
+  TF1 *fPostPIDWdthCorr;    // post pid correction object for widths
   AliAnalysisFilter fEventFilter;    // Event cuts
   AliAnalysisFilter fTrackFilter;    // leg cuts
   AliAnalysisFilter fPairPreFilter;  // pair prefilter cuts
@@ -200,6 +208,8 @@ private:
   TString fTRDpidCorrectionFilename;         // name for the file containing the single particle TRD pid corrections
   TString fVZEROCalibrationFilename;         // file containing VZERO channel-by-channel calibration
   TString fVZERORecenteringFilename;         // file containing VZERO Q-vector recentering averages
+  TString fEffMapFilename;                   // file containing single electron efficiencies
+  TString fZDCRecenteringFilename;         // file containing ZDCQ-vector recentering averages
 
   void ProcessMC(AliVEvent *ev1);
   
@@ -215,7 +225,7 @@ private:
   AliDielectron(const AliDielectron &c);
   AliDielectron &operator=(const AliDielectron &c);
   
-  ClassDef(AliDielectron,6);
+  ClassDef(AliDielectron,7);
 };
 
 inline void AliDielectron::InitPairCandidateArrays()
index 03adbaec3bef236ee8511d7f23e7f9eece006846..42ac5414dfdfe1ea086bee53bd9d3190d7ebeaf6 100644 (file)
@@ -48,6 +48,7 @@ void CDFFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t i
 AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler():
        fIsParamFixed(49),
        fPrintStatus(kFALSE),
+        fParamStartValues(),
        fUp(0),
        fX(0x0),
        fM(0x0),
@@ -69,6 +70,7 @@ AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler(D
                Double_t* invariantmass, Double_t *pt,Int_t *type, Int_t ncand) :
        fIsParamFixed(49),
        fPrintStatus(kFALSE),
+        fParamStartValues(),
        fUp(0),
        fX(decaytime),
        fM(invariantmass),
@@ -148,6 +150,7 @@ AliDielectronBtoJPSItoEleCDFfitHandler& AliDielectronBtoJPSItoEleCDFfitHandler::
        if (this!=&c) {
                fIsParamFixed = c.fIsParamFixed;
                fPrintStatus  = c.fPrintStatus;
+                for (Int_t i=0; i<49; ++i) fParamStartValues[i]=c.fParamStartValues[i];
                fUp           = c.fUp;
                fX            = c.fX;
                fM            = c.fM;
@@ -167,6 +170,7 @@ AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler(c
        TNamed(c),
        fIsParamFixed(c.fIsParamFixed),
        fPrintStatus(c.fPrintStatus),
+        fParamStartValues(),
        fUp(c.fUp),
        fX(c.fX),
        fM(c.fM),
@@ -182,6 +186,7 @@ AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler(c
        //
        // Copy Constructor
        //
+        for (Int_t i=0; i<49; ++i) fParamStartValues[i]=c.fParamStartValues[i];
 }
 //_______________________________________________________________________________________
 AliDielectronBtoJPSItoEleCDFfitHandler::~AliDielectronBtoJPSItoEleCDFfitHandler()
index b5c1c3f83374ee55f7b994d22d57996cb432a355..322507862d08e8542ae4c7785ec0361af0912701 100644 (file)
@@ -45,6 +45,7 @@ const char* AliDielectronEventCuts::fgkVtxNames[AliDielectronEventCuts::kVtxTrac
 
 AliDielectronEventCuts::AliDielectronEventCuts() :
   AliAnalysisCuts(),
+  fRun(),
   fVtxZmin(0.),
   fVtxZmax(0.),
   fRequireVtx(kFALSE),
@@ -74,6 +75,7 @@ AliDielectronEventCuts::AliDielectronEventCuts() :
 //______________________________________________
 AliDielectronEventCuts::AliDielectronEventCuts(const char* name, const char* title) :
   AliAnalysisCuts(name, title),
+  fRun(),
   fVtxZmin(0.),
   fVtxZmax(0.),
   fRequireVtx(kFALSE),
@@ -232,6 +234,14 @@ Bool_t AliDielectronEventCuts::IsSelectedAOD(TObject* event)
   AliAODEvent *ev=dynamic_cast<AliAODEvent*>(event);
   if (!ev) return kFALSE;
 
+  // run rejection
+  Int_t run = ev->GetRunNumber();
+  if(fRun.GetNrows()) {
+    for(Int_t irun=0; irun<fRun.GetNrows(); irun++) {
+      if(fRun(irun)==run) return kFALSE;
+    }
+  }
+
   if (fCentMin<fCentMax){
     AliCentrality *centrality=ev->GetCentrality();
     Double_t centralityF=-1;
index be0d0954f1f7649647c3e0b02e76f93547868d92..fe844baa29669eb7ab9a4222e3948b21fafaacf8 100644 (file)
@@ -20,6 +20,7 @@
 //#############################################################
 
 #include <TF1.h>
+#include <TVectorD.h>
 
 #include <AliAnalysisUtils.h>
 #include <AliAnalysisCuts.h>
@@ -38,7 +39,7 @@ public:
 
   virtual ~AliDielectronEventCuts();
 
-
+  void SetRunRejection(const TVectorD * vec)    { fRun.Use(vec->GetNrows(),vec->GetMatrixArray()); }
   void SetVertexType(EVtxType type)             { fVtxType=type;                }
   void SetVertexZ(Double_t zmin, Double_t zmax) { fVtxZmin=zmin; fVtxZmax=zmax; }
   void SetRequireVertex(Bool_t req=kTRUE)       { fRequireVtx=req;              }
@@ -61,6 +62,7 @@ public:
 
 private:
   static const char* fgkVtxNames[AliDielectronEventCuts::kVtxTracksOrSPD+1];  //vertex names
+  TVectorD fRun;                    // run rejection vector
   Double_t fVtxZmin;                // minimum z vertex position
   Double_t fVtxZmax;                // maximum z vertex position
   Bool_t   fRequireVtx;             // require a vertex
@@ -89,7 +91,7 @@ private:
   AliDielectronEventCuts &operator=(const AliDielectronEventCuts &c);
 
   
-  ClassDef(AliDielectronEventCuts,2)         // Dielectron EventCuts
+  ClassDef(AliDielectronEventCuts,3)         // Dielectron EventCuts
 };
 
 
index 0253771885b0c88ee38f61c8d88193b364e1c5e9..059cda48c56d6357f050c878f18e375f5702b71e 100644 (file)
@@ -46,13 +46,13 @@ Detailed description
 
 ClassImp(AliDielectronPID)
 
-TGraph *AliDielectronPID::fgFitCorr=0x0;
+TGraph  *AliDielectronPID::fgFitCorr=0x0;
 Double_t AliDielectronPID::fgCorr=0.0;
 Double_t AliDielectronPID::fgCorrdEdx=1.0;
-TF1 *AliDielectronPID::fgFunEtaCorr=0x0;
-TF1 *AliDielectronPID::fgFunCntrdCorr=0x0;
-TF1 *AliDielectronPID::fgFunWdthCorr=0x0;
-TGraph *AliDielectronPID::fgdEdxRunCorr=0x0;
+TF1     *AliDielectronPID::fgFunEtaCorr=0x0;
+TF1     *AliDielectronPID::fgFunCntrdCorr=0x0;
+TF1     *AliDielectronPID::fgFunWdthCorr=0x0;
+TGraph  *AliDielectronPID::fgdEdxRunCorr=0x0;
 
 AliDielectronPID::AliDielectronPID() :
   AliAnalysisCuts(),
@@ -659,23 +659,6 @@ Double_t AliDielectronPID::GetEtaCorr(const AliVTrack *track)
   return fgFunEtaCorr->Eval(track->Eta());
 }
 
-//______________________________________________
-void AliDielectronPID::SetCentroidCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary, UInt_t varz)
-{
-  fun->GetHistogram()->GetXaxis()->SetUniqueID(varx);
-  fun->GetHistogram()->GetYaxis()->SetUniqueID(vary);
-  fun->GetHistogram()->GetZaxis()->SetUniqueID(varz);
-  fgFunCntrdCorr=fun;
-}
-//______________________________________________
-void AliDielectronPID::SetWidthCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary, UInt_t varz)
-{
-  fun->GetHistogram()->GetXaxis()->SetUniqueID(varx);
-  fun->GetHistogram()->GetYaxis()->SetUniqueID(vary);
-  fun->GetHistogram()->GetZaxis()->SetUniqueID(varz);
-  fgFunWdthCorr=fun;
-}
-
 //______________________________________________
 Double_t AliDielectronPID::GetPIDCorr(const AliVTrack *track, TF1 *fun)
 {
@@ -693,6 +676,6 @@ Double_t AliDielectronPID::GetPIDCorr(const AliVTrack *track, TF1 *fun)
   if(dim>1) var[1] = values[fun->GetHistogram()->GetYaxis()->GetUniqueID()];
   if(dim>2) var[2] = values[fun->GetHistogram()->GetZaxis()->GetUniqueID()];
   Double_t corr = fun->Eval(var[0],var[1],var[2]);
-  // printf(" %d-dim CORR value: %f (track %p) \n",dim,corr,track);
+  //  printf("%d-dim CORR value: %f (track %p) \n",dim,corr,track);
   return corr;
 }
index cc99ac86628164160850aa0c26e3392ee6031340..459724126d467b5cf17be09dfa6416ca338917d0 100644 (file)
@@ -79,8 +79,8 @@ public:
   static TGraph *GetCorrGraphdEdx()  { return fgdEdxRunCorr; }
 
   static void SetEtaCorrFunction(TF1 *fun) {fgFunEtaCorr=fun;}
-  static void SetCentroidCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary=0, UInt_t varz=0);
-  static void SetWidthCorrFunction(TF1 *fun, UInt_t varx, UInt_t vary=0, UInt_t varz=0);
+  static void SetCentroidCorrFunction(TF1 *fun) { fgFunCntrdCorr=fun; }
+  static void SetWidthCorrFunction(TF1 *fun) { fgFunWdthCorr=fun; }
   static TF1* GetEtaCorrFunction() { return fgFunEtaCorr; }
   static TF1* GetCentroidCorrFunction() { return fgFunCntrdCorr; }
   static TF1* GetWidthCorrFunction() { return fgFunWdthCorr; }
@@ -117,8 +117,8 @@ private:
   static Double_t fgCorrdEdx;     //!dEdx correction value for current run. Set if fgFitCorr is set and SetCorrVal(run)
                                   // was called
   static TF1    *fgFunEtaCorr;    //function for eta correction of electron sigma
-  static TF1    *fgFunCntrdCorr;  //!function for correction of electron sigma (centroid)
-  static TF1    *fgFunWdthCorr;   //!function for correction of electron sigma (width)
+  static TF1    *fgFunCntrdCorr;  //function for correction of electron sigma (centroid)
+  static TF1    *fgFunWdthCorr;   //function for correction of electron sigma (width)
   static TGraph *fgdEdxRunCorr;   //run by run correction for dEdx
 
   static Double_t GetPIDCorr(const AliVTrack *track, TF1 *fun);
index 2ce04a40e95172be4edca8d331f9352582cce966..d9b12bfd7c9fa40c734157a46325b796adc8c1f9 100644 (file)
@@ -316,7 +316,7 @@ Double_t AliDielectronPair::PsiPair(Double_t MagField) const
 
 //______________________________________________
 Double_t AliDielectronPair::ThetaPhiCM(const AliVParticle* d1, const AliVParticle* d2, 
-                                       const Bool_t isHE, const Bool_t isTheta)
+                                       Bool_t isHE, Bool_t isTheta)
 {
   // The function calculates theta and phi in the mother rest frame with
   // respect to the helicity coordinate system and Collins-Soper coordinate system
@@ -373,7 +373,7 @@ Double_t AliDielectronPair::ThetaPhiCM(const AliVParticle* d1, const AliVParticl
 }
 
 //______________________________________________
-Double_t AliDielectronPair::ThetaPhiCM(const Bool_t isHE, const Bool_t isTheta) const {
+Double_t AliDielectronPair::ThetaPhiCM(Bool_t isHE, Bool_t isTheta) const {
   // The function calculates theta and phi in the mother rest frame with 
   // respect to the helicity coordinate system and Collins-Soper coordinate system
   // TO DO: generalize for different decays (only J/Psi->e+e- now)
@@ -443,10 +443,10 @@ Double_t AliDielectronPair::GetCosPointingAngle(const AliVVertex *primVtx) const
   deltaPos[1] = fPair.GetY() - primVtx->GetY();
   deltaPos[2] = fPair.GetZ() - primVtx->GetZ();
 
-  Double_t momV02    = fPair.GetPx()*fPair.GetPx() + fPair.GetPy()*fPair.GetPy() + fPair.GetPz()*fPair.GetPz();
+  Double_t momV02    = Px()*Px() + Py()*Py() + Pz()*Pz();
   Double_t deltaPos2 = deltaPos[0]*deltaPos[0] + deltaPos[1]*deltaPos[1] + deltaPos[2]*deltaPos[2];
 
-  Double_t cosinePointingAngle = (deltaPos[0]*fPair.GetPx() + deltaPos[1]*fPair.GetPy() + deltaPos[2]*fPair.GetPz()) / TMath::Sqrt(momV02 * deltaPos2);
+  Double_t cosinePointingAngle = (deltaPos[0]*Px() + deltaPos[1]*Py() + deltaPos[2]*Pz()) / TMath::Sqrt(momV02 * deltaPos2);
   
   return TMath::Abs(cosinePointingAngle);
 
@@ -490,6 +490,22 @@ Double_t AliDielectronPair::GetArmPt() const
   return (momNeg.Perp(momTot));
 }
 
+//______________________________________________
+void AliDielectronPair::GetDCA(const AliVVertex *primVtx, Double_t d0z0[2]) const
+{
+  //
+  // Calculate the dca of the mother with respect to the primary vertex
+  //
+  if(!primVtx) return;
+
+  d0z0[0] = TMath::Sqrt(TMath::Power(Xv()-primVtx->GetX(),2) +
+                       TMath::Power(Yv()-primVtx->GetY(),2) );
+
+  d0z0[1] = Zv() - primVtx->GetZ();
+  return;
+
+}
+
 // //______________________________________________
 // Double_t AliDielectronPair::GetLXY(const AliVVertex * const vtx) const
 // {
@@ -614,7 +630,7 @@ Double_t AliDielectronPair::PhivPair(Double_t MagField) const
 }
 
 //______________________________________________
-Double_t AliDielectronPair::GetPairPlaneAngle(const Double_t v0rpH2,const Int_t VariNum)const
+Double_t AliDielectronPair::GetPairPlaneAngle(Double_t v0rpH2, Int_t VariNum)const
 {
 
   // Calculate the angle between electron pair plane and variables
@@ -722,6 +738,52 @@ Double_t AliDielectronPair::GetPairPlaneAngle(const Double_t v0rpH2,const Int_t
 }
 
 
+//_______________________________________________
+Double_t AliDielectronPair::PairPlaneMagInnerProduct(Double_t ZDCrpH1) const
+{
+
+  // Calculate inner product of the strong magnetic field and electron pair plane
+
+  if(ZDCrpH1 == 0.) return -9999.;
+
+  Double_t px1=-9999.,py1=-9999.,pz1=-9999.;
+  Double_t px2=-9999.,py2=-9999.,pz2=-9999.;
+
+  px1 = fD1.GetPx();
+  py1 = fD1.GetPy();
+  pz1 = fD1.GetPz();
+
+
+  px2 = fD2.GetPx();
+  py2 = fD2.GetPy();
+  pz2 = fD2.GetPz();
+
+  // normal vector of ee plane
+  Double_t pnorx = py2*pz1 - pz2*py1;
+  Double_t pnory = pz2*px1 - px2*pz1;
+  Double_t pnorz = px2*py1 - py2*px1;
+  Double_t pnor  = TMath::Sqrt( pnorx*pnorx + pnory*pnory + pnorz*pnorz );
+
+  //unit vector
+  Double_t upnx = -9999.;
+  Double_t upny = -9999.;
+  //Double_t upnz = -9999.;
+
+  if (pnor == 0) return -9999.;
+  upnx= pnorx/pnor;
+  upny= pnory/pnor;
+  //upnz= pnorz/pnor;
+
+  //direction of strong magnetic field
+  Double_t magx = TMath::Cos(ZDCrpH1+(TMath::Pi()/2));
+  Double_t magy = TMath::Sin(ZDCrpH1+(TMath::Pi()/2));
+
+  //inner product of strong magnetic field and  ee plane
+  Double_t upnmag = upnx*magx + upny*magy;
+
+  return upnmag;
+}
+
 
 //______________________________________________
 void AliDielectronPair::SetBeamEnergy(AliVEvent *ev, Double_t beamEbyHand)
index b71c73db149d114b68209349feba35fbea073ce3..6797755b57b4b961a31250ca7331b3b14e052956 100644 (file)
@@ -130,17 +130,22 @@ public:
 
   Double_t ThetaPhiCM(Bool_t isHE, Bool_t isTheta) const;
   static Double_t ThetaPhiCM(const AliVParticle* d1, const AliVParticle* d2, 
-                                              const Bool_t isHE, const Bool_t isTheta);
+                                              Bool_t isHE, Bool_t isTheta);
 
   Double_t PsiPair(Double_t MagField)const; //Angle cut w.r.t. to magnetic field
   Double_t PhivPair(Double_t MagField)const; //Angle of ee plane w.r.t. to magnetic field
-\r
-  //Calculate the angle between ee decay plane and variables\r
-  Double_t GetPairPlaneAngle(const Double_t kv0CrpH2, const Int_t VariNum) const;\r
+
+  //Calculate the angle between ee decay plane and variables
+  Double_t GetPairPlaneAngle(Double_t kv0CrpH2, Int_t VariNum) const;
 
   Double_t GetCosPointingAngle(const AliVVertex *primVtx) const;
   Double_t GetArmAlpha() const;
   Double_t GetArmPt()    const;
+  void GetDCA(const AliVVertex *primVtx, Double_t d0z0[2]) const;
+
+  // Calculate inner product of strong magnetic field and ee plane
+  Double_t PairPlaneMagInnerProduct(Double_t ZDCrpH1) const;
+
 
   // internal KF particle
   const AliKFParticle& GetKFParticle()       const { return fPair; }
index a6097a1ff7fb4861e87199fbecd7a6f380f2ae37..cb04aa458de8df4462f45b2603a63f7e2665979c 100644 (file)
@@ -172,8 +172,11 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   {"PairPlaneAngle2Ran",     "#Phi_{2Ran}",                                        "(rad.)"},
   {"PairPlaneAngle3Ran",     "#Phi_{3Ran}",                                        "(rad.)"},
   {"PairPlaneAngle4Ran",     "#Phi_{4Ran}",                                        "(rad.)"},
-  {"RandomRP",               "random",                                             ""},
-  {"DeltaPhiRandomRP",       "#Phi_{RanRP}",                                       "(rad.)"},
+  {"RandomRP",               "#Phi_{RanRP}",                                       "(rad.)"},
+  {"DeltaPhiRandomRP",       "#Delta #Phi_{RanRP}",                                ""},
+
+  {"PairPlaneMagInPro",      "cos(#Phi)"                                           ""},
+
   {"Cos2PhiCS",              "cos(2#phi_{CS})",                                    ""},
   {"CosTilPhiCS",            "cos(#phi_{CS})",                                     ""},
   {"CosPhiH2",               "cos(2#phi)",                                         ""},
@@ -366,6 +369,12 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   {"TPCsub2rpH2uc",          "#Psi^{TPCsub2} (uncorr.)",                           ""},
   {"TPCsub12DiffH2uc",       "cos(2(#Psi^{TPCsub1}-#Psi^{TPCsub2})) (uncorr.)",    ""},
 
+  {"ZDCArpH1",               "#Psi^{ZDCA}"                                         ""},
+  {"ZDCCrpH1",               "#Psi^{ZDCA}"                                         ""},
+  {"ZDCACrpH1",              "#Psi^{ZDCA}"                                         ""},
+  {"kZDCrpResH1",            ""                                                    ""},
+  {"kv0ZDCrpRes",            ""                                                    ""},
+
   {"NTrk",                   "N_{trk}",                                            ""},
   {"Tracks",                 "tracks/per event",                                             ""},
   {"NVtxContrib",            "N_{vtx. contrib.}",                                  ""},
@@ -419,8 +428,10 @@ THnBase*        AliDielectronVarManager::fgEffMap           = 0x0;
 Double_t        AliDielectronVarManager::fgTRDpidEffCentRanges[10][4] = {{0.0}};
 TString         AliDielectronVarManager::fgVZEROCalibrationFile = "";
 TString         AliDielectronVarManager::fgVZERORecenteringFile = "";
+TString         AliDielectronVarManager::fgZDCRecenteringFile = "";
 TProfile2D*     AliDielectronVarManager::fgVZEROCalib[64] = {0x0};
 TProfile2D*     AliDielectronVarManager::fgVZERORecentering[2][2] = {{0x0,0x0},{0x0,0x0}};
+TProfile3D*     AliDielectronVarManager::fgZDCRecentering[3][2] = {{0x0,0x0},{0x0,0x0},{0x0,0x0}};
 Int_t           AliDielectronVarManager::fgCurrentRun = -1;
 Double_t        AliDielectronVarManager::fgData[AliDielectronVarManager::kNMaxValues] = {0.};
 //________________________________________________________________
@@ -440,6 +451,9 @@ AliDielectronVarManager::AliDielectronVarManager() :
   for(Int_t i=0; i<2; ++i) {
     for(Int_t j=0; j<2; ++j) fgVZERORecentering[i][j] = 0x0;
   }
+  for(Int_t i=0; i<3; ++i)
+    for(Int_t j=0; j<2; ++j) fgZDCRecentering[i][j] = 0x0;
+
   gRandom->SetSeed();
 }
 
@@ -460,6 +474,10 @@ AliDielectronVarManager::AliDielectronVarManager(const char* name, const char* t
   for(Int_t i=0; i<2; ++i)
     for(Int_t j=0; j<2; ++j) 
       fgVZERORecentering[i][j] = 0x0;
+  for(Int_t i=0; i<3; ++i)
+    for(Int_t j=0; j<2; ++j) fgZDCRecentering[i][j] = 0x0;
+
+
   gRandom->SetSeed();
 }
 
@@ -480,6 +498,10 @@ AliDielectronVarManager::~AliDielectronVarManager()
   for(Int_t i=0; i<2; ++i)
     for(Int_t j=0; j<2; ++j) 
       if(fgVZERORecentering[i][j]) delete fgVZERORecentering[i][j]; 
+  for(Int_t i=0; i<3; ++i)
+    for(Int_t j=0; j<2; ++j)
+      if(fgZDCRecentering[i][j]) delete fgZDCRecentering[i][j];
+
 }
 
 //________________________________________________________________
index 5eab983fd00173f91631c5d2cd754e502fb33ca2..25cc44077e69daf1e22c4bc1df7f2e80a148fe7e 100644 (file)
@@ -23,6 +23,7 @@
 #include <TNamed.h>
 #include <TProfile.h>
 #include <TProfile2D.h>
+#include <TProfile3D.h>
 #include <TH3D.h>
 #include <THnBase.h>
 #include <TFile.h>
@@ -216,26 +217,27 @@ public:
     kThetaSqCS,              // squared value of kThetaCS
     kPsiPair,                // phi in mother's rest frame in Collins-Soper picture
        kPhivPair,               // angle between ee plane and the magnetic field (can be useful for conversion rejection)
-       \r
-    kPairPlaneAngle1A,         // angle between ee decay plane and x'-z reaction plane by using V0-A\r
-    kPairPlaneAngle2A,         // angle between ee decay plane and (p1+p2) rot ez\r
-    kPairPlaneAngle3A,         // angle between ee decay plane and (p1+p2) rot (p1+p2)x'z\r
-    kPairPlaneAngle4A,         // angle between ee decay plane and x'-y' plane\r
-    kPairPlaneAngle1C,         // using v0-C\r
-    kPairPlaneAngle2C,\r
-    kPairPlaneAngle3C,\r
-    kPairPlaneAngle4C,\r
-    kPairPlaneAngle1AC,        // using v0-AC\r
-    kPairPlaneAngle2AC,\r
-    kPairPlaneAngle3AC,\r
-    kPairPlaneAngle4AC,\r
-    kPairPlaneAngle1Ran,       // using random reaction plane\r
-    kPairPlaneAngle2Ran,\r
-    kPairPlaneAngle3Ran,\r
-    kPairPlaneAngle4Ran,\r
-    kRandomRP,                //Random reaction plane\r
-    kDeltaPhiRandomRP,        //delta phi of the pair\r
-\r
+       
+    kPairPlaneAngle1A,         // angle between ee decay plane and x'-z reaction plane by using V0-A
+    kPairPlaneAngle2A,         // angle between ee decay plane and (p1+p2) rot ez
+    kPairPlaneAngle3A,         // angle between ee decay plane and (p1+p2) rot (p1+p2)x'z
+    kPairPlaneAngle4A,         // angle between ee decay plane and x'-y' plane
+    kPairPlaneAngle1C,         // using v0-C
+    kPairPlaneAngle2C,
+    kPairPlaneAngle3C,
+    kPairPlaneAngle4C,
+    kPairPlaneAngle1AC,        // using v0-AC
+    kPairPlaneAngle2AC,
+    kPairPlaneAngle3AC,
+    kPairPlaneAngle4AC,
+    kPairPlaneAngle1Ran,       // using random reaction plane
+    kPairPlaneAngle2Ran,
+    kPairPlaneAngle3Ran,
+    kPairPlaneAngle4Ran,
+    kRandomRP,                //Random reaction plane
+    kDeltaPhiRandomRP,        //delta phi of the pair
+
+    kPairPlaneMagInPro,     // Inner Product of strong magnetic field and ee plane
        kCos2PhiCS,              // Cosine of 2*phi in mother's rest frame in the Collins-Soper picture
     kCosTilPhiCS,            // Shifted phi depending on kThetaCS
     kCosPhiH2,               // cosine of pair phi for 2nd harmonic
@@ -315,6 +317,8 @@ public:
     kMultV0A,                // VZERO multiplicity and ADC amplitudes
     kMultV0C,
     kMultV0,
+    kEqMultV0A,              // equalized VZERO multiplicity
+    kEqMultV0C,
     kAdcV0A,
     kAdcV0C,
     kAdcV0,
@@ -369,6 +373,15 @@ public:
     kTPCsub2rpH2uc,             // TPC reaction plane of the Q vector for 2nd harmonic (uncorrected, sub event 2)
     kTPCsub12DiffH2uc,          // TPC reaction plane difference of sub event 1,2 for 2nd harmonic (uncorrected)
 
+    //ZDC reaction plane(v1 plane) quantities
+
+    kZDCArpH1,                  // ZDC-A reaction plane of the Q vector for 1st harmonic
+    kZDCCrpH1,                  // ZDC-C reaction plane of the Q vector for 1st harmonic
+    kZDCACrpH1,                  // ZDC-AC reaction plane of the Q vector for 1st harmonic
+    kZDCrpResH1,                  // 1st harmonic reaction plane resolution for ZDC
+    kv0ZDCrpRes,                //ZDC reaction plane for 1st harmonic and VZERO reaction plane for 2nd harmonic correlation
+
+
     kNTrk,                   // number of tracks (or tracklets) TODO: ambiguous
     kTracks,                 // track after all cuts
     kNVtxContrib,             // number of primary vertex contibutors
@@ -428,10 +441,11 @@ public:
   static void InitAODpidUtil(Int_t type=0);
   static void InitEstimatorAvg(const Char_t* filename);
   static void InitTRDpidEffHistograms(const Char_t* filename);
-  static void InitEffMap(const Char_t* filename);
+  static Bool_t InitEffMap(const Char_t* filename);
   static void SetVZEROCalibrationFile(const Char_t* filename) {fgVZEROCalibrationFile = filename;}
   
   static void SetVZERORecenteringFile(const Char_t* filename) {fgVZERORecenteringFile = filename;}
+  static void SetZDCRecenteringFile(const Char_t* filename) {fgZDCRecenteringFile = filename;}
   static void SetPIDResponse(AliPIDResponse *pidResponse) {fgPIDResponse=pidResponse;}
   static AliPIDResponse* GetPIDResponse() { return fgPIDResponse; }
   static void SetEvent(AliVEvent * const ev);
@@ -439,6 +453,7 @@ public:
   static Bool_t GetDCA(const AliAODTrack *track, Double_t d0z0[2]);
   static void SetTPCEventPlane(AliEventplane *const evplane);
   static void GetVzeroRP(const AliVEvent* event, Double_t* qvec, Int_t sideOption);      // 0- V0A; 1- V0C; 2- V0A+V0C
+  static void GetZDCRP(const AliVEvent* event, Double_t qvec[][2]);
   static AliAODVertex* GetVertex(const AliAODEvent *event, AliAODVertex::AODVtx_t vtype);
 
   static TProfile* GetEstimatorHistogram(Int_t period, Int_t type) {return fgMultEstimatorAvg[period][type];}
@@ -477,7 +492,8 @@ private:
 
   static void InitVZEROCalibrationHistograms(Int_t runNo);
   static void InitVZERORecenteringHistograms(Int_t runNo);
-  
+  static void InitZDCRecenteringHistograms(Int_t runNo);
+
   static AliPIDResponse  *fgPIDResponse;        // PID response object
   static AliVEvent       *fgEvent;              // current event pointer
   static AliEventplane   *fgTPCEventPlane;      // current event tpc plane pointer
@@ -492,6 +508,9 @@ private:
   static TProfile2D      *fgVZERORecentering[2][2];   // 2 VZERO sides x 2 Q-vector components
   static Int_t            fgCurrentRun;               // current run number
   
+  static TString          fgZDCRecenteringFile; // file with ZDC Q-vector averages needed for event plane recentering
+  static TProfile3D      *fgZDCRecentering[3][2];   // 2 VZERO sides x 2 Q-vector components
+
   static Double_t fgData[kNMaxValues];        //! data
   
   AliDielectronVarManager(const AliDielectronVarManager &c);
@@ -856,7 +875,8 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
   values[AliDielectronVarManager::kTOFnSigmaKao]=0;
   values[AliDielectronVarManager::kTOFnSigmaPro]=0;
   
-  values[AliDielectronVarManager::kITSclusterMap]   =   particle->GetITSClusterMap();
+  values[AliDielectronVarManager::kITSsignal]        =   particle->GetITSsignal();
+  values[AliDielectronVarManager::kITSclusterMap]    =   particle->GetITSClusterMap();
   values[AliDielectronVarManager::kITSLayerFirstCls] = -1.;
   for (Int_t iC=0; iC<6; iC++) {
     if (((particle->GetITSClusterMap()) & (1<<(iC))) > 0) {
@@ -891,6 +911,12 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
     values[AliDielectronVarManager::kTPCnSigmaKao]=tpcNsigmaKao;
     values[AliDielectronVarManager::kTPCnSigmaPro]=tpcNsigmaPro;
     
+    values[AliDielectronVarManager::kITSnSigmaEle]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kElectron);
+    values[AliDielectronVarManager::kITSnSigmaPio]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kPion);
+    values[AliDielectronVarManager::kITSnSigmaMuo]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kMuon);
+    values[AliDielectronVarManager::kITSnSigmaKao]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kKaon);
+    values[AliDielectronVarManager::kITSnSigmaPro]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kProton);
+
     Double_t prob[AliPID::kSPECIES];
     fgPIDResponse->ComputeTRDProbability(particle,AliPID::kSPECIES,prob);
     values[AliDielectronVarManager::kTRDprobEle]      = prob[AliPID::kElectron];
@@ -913,26 +939,20 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
     }
     else {
       t *= 1e-12; //ps -> s
-      
+
       Double_t v = l / t;
       Float_t beta = v / TMath::C();
       values[AliDielectronVarManager::kTOFbeta]=beta;
     }
 
-    Double_t tofNsigmaEle=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kElectron);
-    Double_t tofNsigmaPio=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kPion);
-    Double_t tofNsigmaMuo=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kMuon);
-    Double_t tofNsigmaKao=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kKaon);
-    Double_t tofNsigmaPro=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kProton);
-    
-    values[AliDielectronVarManager::kTOFnSigmaEle]=tofNsigmaEle;
-    values[AliDielectronVarManager::kTOFnSigmaPio]=tofNsigmaPio;
-    values[AliDielectronVarManager::kTOFnSigmaMuo]=tofNsigmaMuo;
-    values[AliDielectronVarManager::kTOFnSigmaKao]=tofNsigmaKao;
-    values[AliDielectronVarManager::kTOFnSigmaPro]=tofNsigmaPro;
+    values[AliDielectronVarManager::kTOFnSigmaEle]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kElectron);
+    values[AliDielectronVarManager::kTOFnSigmaPio]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kPion);
+    values[AliDielectronVarManager::kTOFnSigmaMuo]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kMuon);
+    values[AliDielectronVarManager::kTOFnSigmaKao]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kKaon);
+    values[AliDielectronVarManager::kTOFnSigmaPro]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kProton);
 
     values[AliDielectronVarManager::kTOFmismProb] = fgPIDResponse->GetTOFMismatchProbability(particle);
-  
+
     pid->SetTPCsignal(origdEdx);
   }
 
@@ -1268,6 +1288,14 @@ inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPa
   // values[AliDielectronVarManager::kPseudoProperTime] = fgEvent ? pair->GetPseudoProperTime(fgEvent->GetPrimaryVertex()): -1e10;
   values[AliDielectronVarManager::kPseudoProperTimeErr] = (errPseudoProperTime2 > 0) ? TMath::Sqrt(errPseudoProperTime2) : -1e10;
 
+  // impact parameter
+  Double_t d0z0[2];
+  d0z0[0]=-999.;
+  d0z0[1]=-999.;
+  if(fgEvent) pair->GetDCA(fgEvent->GetPrimaryVertex(), d0z0);
+  values[AliDielectronVarManager::kImpactParXY]   = d0z0[0];
+  values[AliDielectronVarManager::kImpactParZ]    = d0z0[1];
+
  
   if (!(pair->GetKFUsage())) {
        //if KF Pairing is not enabled, overwrite values that can be easily derived from legs
@@ -1428,36 +1456,39 @@ inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPa
   if ( values[AliDielectronVarManager::kDeltaPhiTPCrpH2] < -1.*TMath::Pi() )
     values[AliDielectronVarManager::kDeltaPhiTPCrpH2] += TMath::TwoPi(); 
 
-  //Calculate the angle between electrons decay plane and variables 1-4\r
-  values[AliDielectronVarManager::kPairPlaneAngle1A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],1);\r
-  values[AliDielectronVarManager::kPairPlaneAngle2A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],2);\r
-  values[AliDielectronVarManager::kPairPlaneAngle3A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],3);\r
-  values[AliDielectronVarManager::kPairPlaneAngle4A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],4);\r
-\r
-  values[AliDielectronVarManager::kPairPlaneAngle1C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],1);\r
-  values[AliDielectronVarManager::kPairPlaneAngle2C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],2);\r
-  values[AliDielectronVarManager::kPairPlaneAngle3C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],3);\r
-  values[AliDielectronVarManager::kPairPlaneAngle4C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],4);\r
-\r
-  values[AliDielectronVarManager::kPairPlaneAngle1AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],1);\r
-  values[AliDielectronVarManager::kPairPlaneAngle2AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],2);\r
-  values[AliDielectronVarManager::kPairPlaneAngle3AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],3);\r
-  values[AliDielectronVarManager::kPairPlaneAngle4AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],4);\r
-\r
-  //Random reaction plane\r
-  values[AliDielectronVarManager::kRandomRP] = (TMath::Pi()/2.0)*((Double_t)rand()/RAND_MAX * 2.0 -1.0 );\r
-  //delta phi of pair fron random reaction plane\r
-  values[AliDielectronVarManager::kDeltaPhiRandomRP] = values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kRandomRP];\r
-  // keep the interval [-pi,+pi]\r
-  if ( values[AliDielectronVarManager::kDeltaPhiRandomRP] > TMath::Pi() )\r
-    values[AliDielectronVarManager::kDeltaPhiRandomRP] -= TMath::TwoPi();\r
-\r
-  values[AliDielectronVarManager::kPairPlaneAngle1Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],1);\r
-  values[AliDielectronVarManager::kPairPlaneAngle2Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],2);\r
-  values[AliDielectronVarManager::kPairPlaneAngle3Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],3);\r
-  values[AliDielectronVarManager::kPairPlaneAngle4Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],4);\r
-\r
-\r
+  //calculate inner product of strong Mag and ee plane 
+  values[AliDielectronVarManager::kPairPlaneMagInPro] = pair->PairPlaneMagInnerProduct(values[AliDielectronVarManager::kZDCACrpH1]);
+
+  //Calculate the angle between electrons decay plane and variables 1-4
+  values[AliDielectronVarManager::kPairPlaneAngle1A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],1);
+  values[AliDielectronVarManager::kPairPlaneAngle2A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],2);
+  values[AliDielectronVarManager::kPairPlaneAngle3A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],3);
+  values[AliDielectronVarManager::kPairPlaneAngle4A] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ArpH2],4);
+
+  values[AliDielectronVarManager::kPairPlaneAngle1C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],1);
+  values[AliDielectronVarManager::kPairPlaneAngle2C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],2);
+  values[AliDielectronVarManager::kPairPlaneAngle3C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],3);
+  values[AliDielectronVarManager::kPairPlaneAngle4C] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0CrpH2],4);
+
+  values[AliDielectronVarManager::kPairPlaneAngle1AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],1);
+  values[AliDielectronVarManager::kPairPlaneAngle2AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],2);
+  values[AliDielectronVarManager::kPairPlaneAngle3AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],3);
+  values[AliDielectronVarManager::kPairPlaneAngle4AC] = pair->GetPairPlaneAngle(values[AliDielectronVarManager::kv0ACrpH2],4);
+
+  //Random reaction plane
+  values[AliDielectronVarManager::kRandomRP] = gRandom->Uniform(-TMath::Pi()/2.0,TMath::Pi()/2.0);
+  //delta phi of pair fron random reaction plane
+  values[AliDielectronVarManager::kDeltaPhiRandomRP] = values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kRandomRP];
+  // keep the interval [-pi,+pi]
+  if ( values[AliDielectronVarManager::kDeltaPhiRandomRP] > TMath::Pi() )
+    values[AliDielectronVarManager::kDeltaPhiRandomRP] -= TMath::TwoPi();
+
+  values[AliDielectronVarManager::kPairPlaneAngle1Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],1);
+  values[AliDielectronVarManager::kPairPlaneAngle2Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],2);
+  values[AliDielectronVarManager::kPairPlaneAngle3Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],3);
+  values[AliDielectronVarManager::kPairPlaneAngle4Ran]= pair->GetPairPlaneAngle(values[AliDielectronVarManager::kRandomRP],4);
+
+
 
 
   AliDielectronMC *mc=AliDielectronMC::Instance();
@@ -1609,6 +1640,7 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
   if(fgCurrentRun!=event->GetRunNumber()) {
     if(fgVZEROCalibrationFile.Contains(".root")) InitVZEROCalibrationHistograms(event->GetRunNumber());
     if(fgVZERORecenteringFile.Contains(".root")) InitVZERORecenteringHistograms(event->GetRunNumber());
+    if(fgZDCRecenteringFile.Contains(".root")) InitZDCRecenteringHistograms(event->GetRunNumber());
     fgCurrentRun=event->GetRunNumber();
   }
   values[AliDielectronVarManager::kMixingBin]=0;
@@ -1730,6 +1762,8 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
   AliVVZERO* vzeroData = event->GetVZEROData();
   values[AliDielectronVarManager::kMultV0A] = 0.0;
   values[AliDielectronVarManager::kMultV0C] = 0.0;
+  values[AliDielectronVarManager::kEqMultV0A] = 0.0;
+  values[AliDielectronVarManager::kEqMultV0C] = 0.0;
   values[AliDielectronVarManager::kAdcV0A]  = 0.0;
   values[AliDielectronVarManager::kAdcV0C]  = 0.0;
   for(Int_t i=0; i<32; ++i) {
@@ -1739,6 +1773,8 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
     //values[AliDielectronVarManager::kVZEROchMult+32+i] = event->GetVZEROEqMultiplicity(i+32);
     values[AliDielectronVarManager::kMultV0A] += vzeroData->GetMultiplicityV0A(i);
     values[AliDielectronVarManager::kMultV0C] += vzeroData->GetMultiplicityV0C(i);
+    values[AliDielectronVarManager::kEqMultV0A] += event->GetVZEROEqMultiplicity(i);
+    values[AliDielectronVarManager::kEqMultV0C] += event->GetVZEROEqMultiplicity(i+32);
     //values[AliDielectronVarManager::kAdcV0A] += vzeroData->GetAdcV0A(i);
     //values[AliDielectronVarManager::kAdcV0C] += vzeroData->GetAdcV0C(i);
   }
@@ -1807,6 +1843,18 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
   values[AliDielectronVarManager::kv0C0v0C3DiffH2] = TMath::Cos( 2.*(values[AliDielectronVarManager::kv0C0rpH2] - 
                                                                     values[AliDielectronVarManager::kv0C3rpH2]) ); 
 
+  Double_t ZDCqvec[3][2];
+  memset(ZDCqvec, 0, sizeof(ZDCqvec));
+  GetZDCRP(event, ZDCqvec);
+
+  values[AliDielectronVarManager::kZDCArpH1] = TMath::ATan2(ZDCqvec[0][1], ZDCqvec[0][0]);
+  values[AliDielectronVarManager::kZDCCrpH1] = TMath::ATan2(ZDCqvec[1][1], ZDCqvec[1][0]);
+  values[AliDielectronVarManager::kZDCACrpH1] = TMath::ATan2(ZDCqvec[2][1], ZDCqvec[2][0]);
+
+
+  values[AliDielectronVarManager::kv0ZDCrpRes] = cos(2*(values[AliDielectronVarManager::kZDCArpH1] - values[AliDielectronVarManager::kv0ArpH2]));
+  values[AliDielectronVarManager::kZDCrpResH1] = cos(values[AliDielectronVarManager::kZDCArpH1] - values[AliDielectronVarManager::kZDCCrpH1]);
+
 
 }
 
@@ -2172,21 +2220,24 @@ inline void AliDielectronVarManager::InitTRDpidEffHistograms(const Char_t* filen
   }
 }
 
-inline void AliDielectronVarManager::InitEffMap(const Char_t* filename) {
+inline Bool_t AliDielectronVarManager::InitEffMap(const Char_t* filename) {
   //
   // init an efficiency object for on-the-fly correction calculations
   //
   fgEffMap=0x0;
   TFile* file=TFile::Open(filename);
+  if(!file) return 0;
   THnBase *hGen = (THnBase*) file->Get("hGenerated");
   THnBase *hFnd = (THnBase*) file->Get("hFound");
-  if(!hFnd || !hGen) return;
+  if(!hFnd || !hGen) return 0;
 
   fgEffMap  = (THnBase*) hFnd->Clone("effMap");
   fgEffMap->Reset();
   fgEffMap->Sumw2();
   fgEffMap->Divide(hFnd, hGen);//, 1, 1, "");  //assume uncorrelated err, otherwise give option "B"
-  if(fgEffMap) printf("[I] AliDielectronVarManager::InitEffMap efficiency maps loaded! \n");
+  printf("[I] AliDielectronVarManager::InitEffMap efficiency maps loaded! \n");
+  return 1;
+  
 }
 
 inline Double_t AliDielectronVarManager::GetSingleLegEff(Double_t * const values) {
@@ -2200,11 +2251,12 @@ inline Double_t AliDielectronVarManager::GetSingleLegEff(Double_t * const values
   for(Int_t idim=0; idim<dim; idim++) {
     UInt_t var = GetValueType(fgEffMap->GetAxis(idim)->GetName());
     idx[idim] = fgEffMap->GetAxis(idim)->FindBin(values[var]);
-    if(idx[idim] < 0 || idx[idim]>fgEffMap->GetAxis(idim)->GetNbins()) 
-      printf(" [E] AliDielectronVarManager::GetSingleLegEff values %f for %s not found in axis range \n",values[var],fgEffMap->GetAxis(idim)->GetName());
+    /* if(idx[idim] < 0 || idx[idim]>fgEffMap->GetAxis(idim)->GetNbins()) */
+    /*   printf(" [E] AliDielectronVarManager::GetSingleLegEff values %f for %s not found in axis range \n",values[var],fgEffMap->GetAxis(idim)->GetName()); */
     //    printf(" (%d,%f,%s) \t",idx[idim],values[var],fgEffMap->GetAxis(idim)->GetName());
   }
   //  printf(" bin content %f+-%f \n",fgEffMap->GetBinContent(idx), fgEffMap->GetBinError(idx));
+  if(fgEffMap->GetBinContent(idx)<0.01 || fgEffMap->GetBinError(idx)/fgEffMap->GetBinContent(idx)>0.2) return 0.0;
   return (fgEffMap->GetBinContent(idx));
 }
 
@@ -2262,6 +2314,38 @@ inline void AliDielectronVarManager::InitVZERORecenteringHistograms(Int_t runNo)
   
 }
 
+inline void AliDielectronVarManager::InitZDCRecenteringHistograms(Int_t runNo) {
+
+  //initialize only once
+  if(fgZDCRecentering[0][0]) return;
+
+  for(Int_t i=0; i<2; ++i)
+    for(Int_t j=0; j<2; ++j)
+      if(fgZDCRecentering[i][j]) {
+        delete fgZDCRecentering[i][j];
+        fgZDCRecentering[i][j] = 0x0;
+      }
+
+  TFile file(fgZDCRecenteringFile.Data());
+  if (!file.IsOpen()) return;
+  cout << fgZDCRecenteringFile << endl;
+  fgZDCRecentering[0][0] = (TProfile3D*)file.Get(Form("RUN%06d_QxA_Recent", runNo));
+  fgZDCRecentering[0][1] = (TProfile3D*)file.Get(Form("RUN%06d_QyA_Recent", runNo));
+  fgZDCRecentering[1][0] = (TProfile3D*)file.Get(Form("RUN%06d_QxC_Recent", runNo));
+  fgZDCRecentering[1][1] = (TProfile3D*)file.Get(Form("RUN%06d_QyC_Recent", runNo));
+  fgZDCRecentering[2][0] = (TProfile3D*)file.Get(Form("RUN%06d_QxAC_Recent", runNo));
+  fgZDCRecentering[2][1] = (TProfile3D*)file.Get(Form("RUN%06d_QyAC_Recent", runNo));
+
+
+  if (fgZDCRecentering[0][0]) fgZDCRecentering[0][0]->SetDirectory(0x0);
+  if (fgZDCRecentering[0][1]) fgZDCRecentering[0][1]->SetDirectory(0x0);
+  if (fgZDCRecentering[1][0]) fgZDCRecentering[1][0]->SetDirectory(0x0);
+  if (fgZDCRecentering[1][1]) fgZDCRecentering[1][1]->SetDirectory(0x0);
+  if (fgZDCRecentering[2][0]) fgZDCRecentering[2][0]->SetDirectory(0x0);
+  if (fgZDCRecentering[2][1]) fgZDCRecentering[2][1]->SetDirectory(0x0);
+
+}
+
 
 inline Double_t AliDielectronVarManager::GetTRDpidEfficiency(Int_t runNo, Double_t centrality, 
                                                             Double_t eta, Double_t trdPhi, Double_t pout,
@@ -2469,6 +2553,97 @@ inline void AliDielectronVarManager::GetVzeroRP(const AliVEvent* event, Double_t
   if(TMath::Abs(qvec[0])>1.0e-10)
     qvec[2] = TMath::ATan2(qvec[1],qvec[0])/2.0;
 }
+inline void AliDielectronVarManager::GetZDCRP(const AliVEvent* event, Double_t qvec[][2]) {
+
+  //
+  // Get the reaction plane from the ZDC detector for first harmonic
+  //
+  //  Q{x,y} = SUM{ri(x,y)*Ei} / SUM{Ei}
+  //
+
+  const Int_t   nZDCSides  = 2;
+  const Int_t   nZDCplanes = 3;
+  const Int_t   Aside = 0, Cside = 1, ACside = 2;
+  const Int_t   nZDCTowers = 4;// number of ZDCtowers
+  const Double_t ZDCTowerCenters[nZDCTowers][2] = { {-1.75, -1.75}, { 1.75, -1.75},
+                                                    {-1.75,  1.75}, { 1.75,  1.75} };
+
+  Double_t   *ZDCTEnergy[nZDCSides]; //reco E in 5 ZDC sectors - high gain chain
+  Double_t    qvecNUM[nZDCplanes][2];
+  Double_t    qvecDEN[nZDCplanes];
+  memset(   qvecNUM,    0,     sizeof(qvecNUM));  //format
+  memset(qvecDEN,     0,     sizeof(qvecDEN));  //format
+
+  Double_t TPCRefMulti = 999, vtxX = 999, vtxY = 999;
+  Int_t multiBin = 0, vtxXBin = 0, vtxYBin = 0;
+  Double_t recentdim[3][3] = { { 50, 0, 2500},   //multiplicity nbin, min, max
+                               { 20, 0.04, 0.08},   //    vertex x nbin, min, max
+                               { 20, 0.25, 0.29} }; //    vertex y nbin, min, max
+
+  AliVZDC* aliZDC = event->GetZDCData();
+  ZDCTEnergy[Aside] = (Double_t *)aliZDC -> GetZNATowerEnergy();
+  ZDCTEnergy[Cside] = (Double_t *)aliZDC -> GetZNCTowerEnergy();
+
+  for(int j = 0;  j < nZDCSides   ; j++){
+    for(int k = 0;   k < nZDCTowers ; k++){
+      qvecNUM[j][0] += ZDCTowerCenters[k][0]*ZDCTEnergy[j][k+1]; //    zdcQ += xE
+      qvecNUM[j][1] += ZDCTowerCenters[k][1]*ZDCTEnergy[j][k+1]; //    zdcQ += yE
+      qvecDEN[j]    += ZDCTEnergy[j][k+1];                   // zdcQsum +=  E
+
+    }
+    if(j == Aside){
+      qvecNUM[j][0] = -qvecNUM[j][0];
+    }
+
+    if(j == Cside){
+      qvecNUM[j][0] = -qvecNUM[j][0];
+      qvecNUM[j][1] = -qvecNUM[j][1];
+    }
+
+
+    qvecNUM[ACside][0] += qvecNUM[j][0];
+    qvecNUM[ACside][1] += qvecNUM[j][1];
+    qvecDEN[ACside] += qvecDEN[j];
+
+  }
+
+  for(int j = 0; j < nZDCplanes; j++){
+    if(qvecDEN[j] != 0){
+      qvec[j][0] = (qvecNUM[j][0] / qvecDEN[j]);
+      qvec[j][1] = (qvecNUM[j][1] / qvecDEN[j]);
+    }
+    else if(qvecDEN[j] == 0) {
+      qvec[j][0] = 999;
+      qvec[j][1] = 999;
+    }
+
+  }
+
+  if(fgZDCRecentering[0][0]){
+    const AliAODEvent* aodEv = static_cast<const AliAODEvent*>(event);
+    AliAODHeader *header = aodEv->GetHeader();
+    if(!header) return;
+    TPCRefMulti = header -> GetTPConlyRefMultiplicity();
+
+    const AliVVertex *primVtx = event->GetPrimaryVertex();
+    if(!primVtx) return;
+    vtxX = primVtx->GetX();
+    vtxY = primVtx->GetY();
+
+    multiBin = (Int_t)((TPCRefMulti-recentdim[0][1])*recentdim[0][0] / (recentdim[0][2] - recentdim[0][1])) + 1;
+    vtxXBin  = (Int_t)((vtxX-recentdim[1][1])*recentdim[1][0] / (recentdim[1][2] - recentdim[1][1])) + 1;
+    vtxYBin  = (Int_t)((vtxY-recentdim[2][1])*recentdim[2][0] / (recentdim[2][2] - recentdim[2][1])) + 1;
+
+    for(int j = 0; j < nZDCplanes; j++)
+      if(qvecDEN[j] != 0){
+        qvec[j][0] -= fgZDCRecentering[j][0] -> GetBinContent(multiBin, vtxXBin, vtxYBin);
+        qvec[j][1] -= fgZDCRecentering[j][1] -> GetBinContent(multiBin, vtxXBin, vtxYBin);
+      }
+  }
+
+}
+
+
 
 //______________________________________________________________________________                                                                                                                                                                                     
 inline AliAODVertex* AliDielectronVarManager::GetVertex(const AliAODEvent* event, AliAODVertex::AODVtx_t vtype) {
index fc0ebfb97c259ced12f9e22ed85e9b5607cf39d6..fbedcbfffc1d614385a06b8511ce727d8b17a37d 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliVEvent::kEMCEGA  | AliVEvent::kEMCEJE){
+AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliVEvent::kEMCEGA  | AliVEvent::kEMCEJE | AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB){
   
   //get the current analysis manager
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
@@ -35,12 +35,12 @@ AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliV
 //   AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDie");
  
   // trigger selection
-  ULong64_t triggerSets[]={AliVEvent::kEMCEGA ,AliVEvent::kEMCEJE};
-  const char* triggerNames[]={"EMCEGA","EMCEJE"};
+  ULong64_t triggerSets[]={AliVEvent::kEMCEGA ,AliVEvent::kEMCEJE,AliVEvent::kCentral , AliVEvent::kSemiCentral , AliVEvent::kMB};
+  const char* triggerNames[]={"EMCEGA","EMCEJE","Central","SemiCentral","MB"};
 
   // find out the configured triggers
   Int_t j=0;
-  for(j=0; j<2; j++) {
+  for(j=0; j<5; j++) {
     if(triggers!=triggerSets[j]) continue;
     else break;
   }
@@ -49,8 +49,6 @@ AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliV
   printf("production: %s MC: %d \n",  list.Data(),hasMC);
   printf("triggers:   %s \n",         triggerNames[j]  );
 
-  task = new AliAnalysisTaskMultiDielectron((Form("MultiDieData_%s",triggerNames[j])));
-   
   //load dielectron configuration file
   TString checkconfig="ConfigJpsi_mf_pp";
   if (!gROOT->GetListOfGlobalFunctions()->FindObject(checkconfig.Data()))
@@ -59,11 +57,13 @@ AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliV
   //add dielectron analysis with different cuts to the task
   for (Int_t i=0; i<nDie; ++i){ //nDie defined in config file
     AliDielectron *jpsi; 
-    jpsi=ConfigJpsi_mf_PbPb(i,isAOD);
-    if (jpsi) task->AddDielectron(jpsi);
-    if (jpsi ) printf(" %s added\n",jpsi->GetName());
-  }
+    jpsi=ConfigJpsi_mf_PbPb(i,isAOD,triggerNames[j]);
 
+    // create unique title
+       TString unitit = Form("%s_%s",triggerNames[j],jpsi->GetName()); // as in Julian's addtask
+       task = new AliAnalysisTaskMultiDielectron(Form("MultiDieMF_%s",unitit.Data()));
+    if (jpsi) task->AddDielectron(jpsi);
+  
   //Add event filter
   AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0");
   if(isAOD) eventCuts->SetVertexType(AliDielectronEventCuts::kVtxAny);
@@ -84,31 +84,32 @@ AliAnalysisTask *AddTask_mfigueredo_JPsi(TString prod="",ULong64_t triggers=AliV
   //create data containers
   //----------------------
 
-  //create output container
-  TString containerName = "JPSI.root";
-  AliAnalysisDataContainer *cOutputHist1 =
-    mgr->CreateContainer(Form("mfigueredo_QA_%s",triggerNames[j]),
+        //create output container
+       TString containerName = "JPSI.root";
+       AliAnalysisDataContainer *cOutputHist1 =
+    mgr->CreateContainer(Form("mfigueredo_QA_%s",unitit.Data()),
                         TList::Class(),
                         AliAnalysisManager::kOutputContainer,
                         containerName.Data());
 
-  AliAnalysisDataContainer *cOutputHist2 =
-    mgr->CreateContainer(Form("mfigueredo_CF_%s",triggerNames[j]),
+       AliAnalysisDataContainer *cOutputHist2 =
+        mgr->CreateContainer(Form("mfigueredo_CF_%s",unitit.Data()),
                         TList::Class(),
                         AliAnalysisManager::kOutputContainer,
                         containerName.Data());
 
-  AliAnalysisDataContainer *cOutputHist3 =
-    mgr->CreateContainer(Form("mfigueredo_EventStat_%s",triggerNames[j]),
+        AliAnalysisDataContainer *cOutputHist3 =
+       mgr->CreateContainer(Form("mfigueredo_EventStat_%s",unitit.Data()),
                         TH1D::Class(),
                         AliAnalysisManager::kOutputContainer,
                         containerName.Data());
   
  
-  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
-  mgr->ConnectOutput(task, 1, cOutputHist1);
-  mgr->ConnectOutput(task, 2, cOutputHist2);
-  mgr->ConnectOutput(task, 3, cOutputHist3);
-  
+       mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+       mgr->ConnectOutput(task, 1, cOutputHist1);
+       mgr->ConnectOutput(task, 2, cOutputHist2);
+       mgr->ConnectOutput(task, 3, cOutputHist3);
+    printf(" %s added\n",jpsi->GetName());
+  }
   return task;
 }
index 04ed9bda637727421998563f101af2dfcdda9677..b5855379ad13e7673661db91fa06ec471455e9c3 100644 (file)
@@ -1,4 +1,8 @@
 void InitHistograms(AliDielectron *die, Int_t cutDefinition);
+void AddQAHistsPID(AliDielectron *die);
+void AddQAHistsEP(AliDielectron *die);
+void AddHistsEleEff(AliDielectron *die);
+
 void InitCF(AliDielectron* die, Int_t cutDefinition);
 void InitHF(AliDielectron* die, Int_t cutDefinition);
 
@@ -13,10 +17,11 @@ void ConfigBgrd(    AliDielectron *die,  Int_t cutDefinition);
 void AddMCSignals(AliDielectron *die,  Int_t cutDefinition);
 void SetEtaCorrection(AliDielectron *die);
 TVectorD *GetRunNumbers2011();
+TVectorD *GetPDGcodes();
 TVectorD *GetDeltaPhiBins();
 
-TString names=("Event;Rec;TPC;TOF;TRD;Ionut;TPC-TOF-TRD;NOPID;NOPIDeta;avgPt;LegEff");
-enum { kEvent, kRec, kTPC, kTOF, kTRD, kIonut, kTPCTOFTRD, kNoPID, kNoPIDEta, kAvgPt, kLegEff };
+TString names=("Event;PIDqa;Flow;avgPt;Rec;TPC;TOF;TRD;Ionut;TPC-TOF-TRD;NOPID;LegEff;SysPt;SysEta;SysEle;SysPro;SysSPD;SysMC;SysMCele");
+enum { kEvent, kPIDqa, kFlow, kAvgPt, kRec, kTPC, kTOF, kTRD, kIonut, kTPCTOFTRD, kNoPID, kLegEff, kSysPt, kSysEta, kSysEle, kSysPro, kSysSPD, kSysMC,kSysMCele, kPIDQA };
 
 TObjArray *arrNames=names.Tokenize(";");
 const Int_t nDie=arrNames->GetEntries();
@@ -37,7 +42,7 @@ AliDielectron* ConfigJpsi_jb_PbPb(Int_t cutDefinition, Bool_t hasMC=kFALSE, ULon
     // find mc or not?
     if( list.IsNull()) list=prod;
     if( list.Contains("LHC10h")   || list.Contains("LHC11h")   ) hasMC=kFALSE;
-    if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ) hasMC=kTRUE;
+    if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ||  list.Contains("LHC13c7")) hasMC=kTRUE;
   }
 
   //ESD handler?
@@ -46,27 +51,37 @@ AliDielectron* ConfigJpsi_jb_PbPb(Int_t cutDefinition, Bool_t hasMC=kFALSE, ULon
   // switch configurations ON and OFF
   if(hasMC) { // MONTE CARLO
     switch(cutDefinition) {
-    case kEvent:   /* */ break;
-      //    case kRec: /* */ break;
+    case kEvent:   /* */ break;          // event quantities (mult, ep, trigger, ...)
+      //    case kPIDqa:   /* */ break;          // post calibration and validation of TPC PID
+      //    case kRec:     /* */ break;          // to calculate partial efficiencies, in particular the geom. acceptance
+      //    case kLegEff:  /* */ break;          // single electron efficiency calculation
+    case kAvgPt:   /* */ break;          // mean pt analysis
       //    case kTPC:   /* */ break;
       //    case kTOF:   /* */ break;
       //    case kTRD:   /* */ break;
-    case kIonut: /* */ break;
-    case kLegEff: /* */ break;
+      //    case kIonut: /* */ break;
+      //    case kSysMC: /* */ break;
+      //    case kSysMCele: /* */ break;
       //    case kNoPID: /* */ break;
     default:         return 0x0;
     }
   } else { // COLLISION DATA
     switch(cutDefinition) {
-    case kEvent:   /* */ break;
+    case kEvent:   /* */ break;          // event quantities (mult, ep, trigger, ...)
+      //case kPIDqa:   /* */ break;          // for post calibration and validation of TPC PID 
+      //    case kFlow:    /* */ break;          // flow calculation
       //    case kNoPID: /* */ break;
-      //case kNoPIDEta: /* */ break;
       //    case kTPC:   /* */ break;
       //    case kTOF:   /* */ break;
       //    case kTRD:   /* */ break;
-    case kIonut:       /* */ break;
+      //    case kIonut:       /* */ break;
       //    case kTPCTOFTRD:   /* */ break;
-      //    case kAvgPt:       /* */ break;
+    case kAvgPt:       /* */ break;
+      //    case kSysPt:       /* */ break;
+      // case kSysEta:       /* */ break;
+      // case kSysEle:       /* */ break;
+      // case kSysPro:       /* */ break;
+      //    case kSysSPD:       /* */ break;
     default:         return 0x0;
     }
   }
@@ -89,32 +104,31 @@ AliDielectron* ConfigJpsi_jb_PbPb(Int_t cutDefinition, Bool_t hasMC=kFALSE, ULon
   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv MISC vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
   // Monte Carlo Signals
   if(hasMC)  AddMCSignals(die, cutDefinition);
-  // PID eta correction
-  if(cutDefinition!=kNoPID && cutDefinition!=kEvent) SetEtaCorrection(die);
+  // PID post calibartion
+  if(cutDefinition!=kEvent) SetEtaCorrection(die); ///////////////////ATTENTION
   // bgrd estimators
-  if(!hasMC) ConfigBgrd(die,cutDefinition);
+  ////  if(!hasMC) 
+  ConfigBgrd(die,cutDefinition);
   // tpc event plane configuration
-  if(!hasMC) ConfigEvtPlane(die,cutDefinition);
+  //  if(!hasMC) 
+  ConfigEvtPlane(die,cutDefinition);
   // prefilter settings
-  if(cutDefinition==kEvent || cutDefinition==kNoPID || cutDefinition==kNoPIDEta)
+  if(cutDefinition==kEvent || cutDefinition==kNoPID || cutDefinition==kPIDqa || cutDefinition==kLegEff)
     die->SetNoPairing();
   else
     die->SetPreFilterAllSigns();
   //die->SetPreFilterUnlikeOnly();
   // load single electron effieciency map ATTENTION
   if(!hasMC && 0) AliDielectronVarManager::InitEffMap("/home/aliceexp/jbook/gsi-train-trunk/jbook_jpsi/effMap.root");
-  if(!hasMC && 1) AliDielectronVarManager::InitEffMap("/sw/alice/gsi-svn/testtrain/effMap.root");
+  if(cutDefinition==kAvgPt) AliDielectronVarManager::InitEffMap("/sw/alice/gsi-svn/testtrain/effMap.root");
 
   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv OUTPUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
   // histogram setup
   InitHistograms(die,cutDefinition);
   // histogram grid setup
-  /*if(!hasMC)*/
-  if(cutDefinition!=kEvent && cutDefinition!=kNoPID && cutDefinition!=kNoPIDEta && cutDefinition!=kLegEff)
-    InitHF(die,cutDefinition);
+  InitHF(die,cutDefinition);
   // CF container setup
-  if(hasMC && cutDefinition!=kEvent && cutDefinition!=kLegEff)
-    InitCF(die,cutDefinition);
+  InitCF(die,cutDefinition);
 
   // cut QA
   die->SetCutQA();
@@ -140,6 +154,8 @@ void SetupEventCuts(AliDielectron *die, ULong64_t triggers, Int_t cutDefinition)
     }
   }
   //  if(cutDefinition >= kEtaGap01) {minCent=20.; maxCent=50.;} // v2 analysis
+  if(cutDefinition == kSysMC) {minCent=0.; maxCent=50.;}
+  if(cutDefinition == kSysMCele) {minCent=0.; maxCent=50.;}
 
   // VZERO multiplicity vs. number ob global tracks cut
   TF1 *fMean  = new TF1("fMean", "pol1",               0,25e+3);
@@ -147,13 +163,14 @@ void SetupEventCuts(AliDielectron *die, ULong64_t triggers, Int_t cutDefinition)
   TF1 *fSigma = new TF1("fSigma","[0]+sqrt([1]*x+[2])",0,25e+3);
   fSigma->SetParameters(-83.6599, 36.7677, 69530.7);
 
-  AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","eventCuts");
+  AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("vertex","vertex");
   if(!isESD) eventCuts->SetVertexType(AliDielectronEventCuts::kVtxAny);
   eventCuts->SetRequireVertex();
   eventCuts->SetMinVtxContributors(1);
   eventCuts->SetVertexZ(-10.,+10.);
   eventCuts->SetCentralityRange(minCent,maxCent);
   //  eventCuts->SetCutOnV0MultipicityNTrks(fMean, fSigma, 4.0);
+  //  eventCuts->SetRunRejection(AliDielectronHelper::MakeArbitraryBinning("170592,170593,170594"));
   eventCuts->Print();
   die->GetEventFilter().AddCuts(eventCuts);
 
@@ -184,15 +201,20 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
 
   // config specific cuts
   switch(cutDefinition) {
+  case kPIDqa:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 1e30);
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    break;
   case kEvent:
+  case kFlow:
   case kRec:
   case kIonut:
   case kTRD:
   case kTPCTOFTRD:
   case kAvgPt:
   case kNoPID:
-  case kNoPIDEta:
-    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 20./*1e30*/); ///ATTENTION
+  case kSysMCele:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 1e30); ///ATTENTION
     varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.8,   0.8); ////ATTENTION
   case kLegEff:
     varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
@@ -208,6 +230,38 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
     varRecCuts->AddCut(AliDielectronVarManager::kNclsTPC,     70.0, 160.0);
     trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 7); // ITS-3 = 1+2+4
     break;
+    ///////////////////////////////////////////////////////////////////////////////////////////// systematics
+  case kSysPt:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           1.1, 20./*1e30*/); ///ATTENTION
+    varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.8,   0.8); ////ATTENTION
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
+    break;
+  case kSysEta:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 20./*1e30*/); ///ATTENTION
+    varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9); ////ATTENTION
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
+    break;
+  case kSysEle:
+  case kSysPro:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 20./*1e30*/); ///ATTENTION
+    varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.8,   0.8); ////ATTENTION
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
+    break;
+  case kSysSPD:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 20./*1e30*/); ///ATTENTION
+    varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.8,   0.8); ////ATTENTION
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 1); // SPD any
+    break;
+  case kSysMC:
+    varAccCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 20./*1e30*/); ///ATTENTION
+    varAccCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9); ////ATTENTION
+    varRecCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
+    trkRecCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
+    break;
   }
 
   // standrad reconstruction cuts
@@ -229,7 +283,7 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
   AliDielectronPID *pidCuts        = new AliDielectronPID("PIDCuts","PIDCuts");
 
   switch(cutDefinition) {
-  case kNoPIDEta:
+  case kPIDqa:
     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-10.,10.);
     break;
   case kTOF:
@@ -245,6 +299,7 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
     pidCuts->AddCut(AliDielectronPID::kTRDeleEff,AliPID::kElectron,.95,1.,pidSelCuts,
                    kFALSE, AliDielectronPID::kIfAvailable);
   case kEvent:
+  case kFlow:
   case kIonut:
   case kLegEff:
   case kAvgPt:
@@ -276,6 +331,37 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
     pidCuts->AddCut(AliDielectronPID::kTRDeleEff,AliPID::kElectron,.95,1.,pidSelCuts,
                    kFALSE, AliDielectronPID::kIfAvailable);
     break;
+    ///////////////////////////////////////////////////////////////////////////////////////////// systematics
+  case kSysPt:
+  case kSysEta:
+  case kSysSPD:
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5.,3.);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.9,3.0,-0.5,+0.5,kFALSE,
+                   AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,4.0,0.,0.,kTRUE);
+    break;
+  case kSysEle:
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,+0.7.,3.);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,4.0,0.,0.,kTRUE);
+    break;
+  case kSysPro:
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5.,3.);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.9,3.0,-0.5,+0.5,kFALSE,
+                   AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,3.5,0.,0.,kTRUE);
+    break;
+  case kSysMC:
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5.,3.);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.9,3.0,-0.5,+0.5,kFALSE,
+                   AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,3.5,0.,0.,kTRUE);
+    break;
+  case kSysMCele:
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5.,3.);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-0.9,3.0,-0.5,+0.5,kFALSE,
+                   AliDielectronPID::kRequire,AliDielectronVarManager::kEta);
+    pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,4.0,0.,0.,kTRUE);
+    break;
   }
 
   // mc identification
@@ -294,7 +380,14 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
   // activate the cut sets (order might be CPU timewise important)
   switch(cutDefinition) {
   case kNoPID:
-  case kNoPIDEta:
+  case kPIDqa:
+    die->GetTrackFilter().AddCuts(varAccCuts);
+    grpRecCuts->AddCut(trkRecCuts);
+    grpRecCuts->AddCut(varRecCuts);
+    die->GetTrackFilter().AddCuts(grpRecCuts);
+    /// NOTE should be changed to get ride of itsfirst but what about the pt cut?????????
+    //    die->GetTrackFilter().AddCuts(varRecCuts); 
+    break;
   case kRec:
     die->GetTrackFilter().AddCuts(varAccCuts);
     grpRecCuts->AddCut(trkRecCuts);
@@ -302,6 +395,7 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
     die->GetTrackFilter().AddCuts(grpRecCuts);
     break;
   case kEvent:
+  case kFlow:
   case kIonut:
   case kLegEff:
   case kTRD:
@@ -309,6 +403,13 @@ void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
   case kAvgPt:
   case kTOF:
   case kTPC:
+  case kSysPt:
+  case kSysEta:
+  case kSysEle:
+  case kSysPro:
+  case kSysSPD:
+  case kSysMC:
+  case kSysMCele:
     die->GetTrackFilter().AddCuts(varAccCuts);
     grpRecCuts->AddCut(trkRecCuts);
     grpRecCuts->AddCut(varRecCuts);
@@ -331,26 +432,32 @@ void SetupV0Cuts(AliDielectron *die, Int_t cutDefinition)
   // Setup the V0 cuts
   //
 
-  // Quality cuts (add the gamma filter to the cut group)
-  // TIter next(die->GetTrackFilter().GetCuts());
-  // AliAnalysisCuts *cuts;
-  // while((cuts = (AliAnalysisCuts*)next())) {
-  //   if(cuts->IsA() == AliDielectronCutGroup::Class())  break;
-  // }
+  switch(cutDefinition) {
+  case kEvent:  return;
+  case kLegEff: return;
+  }
+
+  Bool_t bRej  = kTRUE;
+  Int_t defPID = 16;
+  if(cutDefinition==kPIDqa) {
+    bRej   = kFALSE;
+    defPID = 13;
+  }
 
   AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("V0","V0");
+  gammaV0Cuts->SetV0finder(AliDielectronV0Cuts::kOnTheFly);
   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->SetDefaultPID(defPID);
+  gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.05),   1.0,  kFALSE); //0.02 -- 0.05
   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->AddCut(AliDielectronVarManager::kArmAlpha,                     -0.35,  0.35, kFALSE);
+  gammaV0Cuts->AddCut(AliDielectronVarManager::kM,                             0.0,   0.1,  kFALSE); //0.05 -- 0.1
+  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.2,  kFALSE); //0.05 -- 0.2
+  //  gammaV0Cuts->AddCut(AliDielectronVarManager::kOpeningAngle,              0.0,   0.1,  kFALSE);
+  gammaV0Cuts->SetExcludeTracks(bRej);
   gammaV0Cuts->Print();
 
  //  const Double_t |cutAlphaG| < 0.35; &&  const Double_t cutQTG < 0.05;
@@ -371,12 +478,13 @@ void SetupPairCuts(AliDielectron *die, Int_t cutDefinition)
   Bool_t hasMC=die->GetHasMC();
 
   // rap and mass rejection
-  Double_t gCut=0.05, yCut=0.9;
+  Double_t gCut=0.05, yCut=0.9, eCut=0.01;
   switch(cutDefinition) {
   case kEvent:      yCut=0.0;  break;
+  case kPIDqa:      return;
+  case kFlow:       yCut=0.8;  break;
   case kRec:        yCut=0.9;  break;
   case kNoPID:      return;
-  case kNoPIDEta:   return;
   case kTPC:        yCut=0.9;  break;
   case kTOF:        yCut=0.9;  break;
   case kTRD:        yCut=0.8;  break;
@@ -384,6 +492,14 @@ void SetupPairCuts(AliDielectron *die, Int_t cutDefinition)
   case kLegEff:     return;
   case kTPCTOFTRD:  yCut=0.8;  break;
   case kAvgPt:      yCut=0.8;  break;
+  case kSysMC:      yCut=0.9;  break;
+  case kSysMCele:   yCut=0.8;  break;
+  case kSysEta:     yCut=0.9;  break;
+  case kSysPt:
+  case kSysEle:
+  case kSysPro:
+  case kSysSPD:
+    yCut=0.8;                  break;
     //  default: gCut=0.05;       // default
   }
 
@@ -400,6 +516,32 @@ void SetupPairCuts(AliDielectron *die, Int_t cutDefinition)
   gammaCuts->AddCut(AliDielectronVarManager::kM,            0.0,   gCut);
   die->GetPairPreFilter().AddCuts(gammaCuts);
 
+  // pair efficiency cut
+  if(cutDefinition==kAvgPt && !hasMC) {
+    AliDielectronVarCuts *effCut=new AliDielectronVarCuts(Form("(Axe)>%.2f",eCut),Form("(Axe)>%.2f",eCut));
+    effCut->AddCut(AliDielectronVarManager::kPairEff,0.0,eCut,kTRUE);
+    die->GetPairFilter().AddCuts(effCut);
+  }
+
+  // random signal rejection
+  AliDielectronCutGroup *grpRNDMCuts = new AliDielectronCutGroup("RNDM","RNDM",AliDielectronCutGroup::kCompOR);
+  AliDielectronVarCuts *exclCutCEN=new AliDielectronVarCuts("exclCEN","exclCEN");
+  exclCutCEN->SetCutType(AliDielectronVarCuts::kAll); // all criteria need to be fullfilled
+  exclCutCEN->AddCut(AliDielectronVarManager::kRndmPair,0.0,1./40);
+  exclCutCEN->AddCut(AliDielectronVarManager::kPdgCode,443);
+  exclCutCEN->AddCut(AliDielectronVarManager::kCentrality,0.,10.);
+  AliDielectronVarCuts *exclCutSEMI=new AliDielectronVarCuts("exclSEMI","exclSEMI");
+  exclCutSEMI->SetCutType(AliDielectronVarCuts::kAll); // all criteria need to be fullfilled
+  exclCutSEMI->AddCut(AliDielectronVarManager::kRndmPair,0.0,1./20);
+  exclCutSEMI->AddCut(AliDielectronVarManager::kPdgCode,443);
+  exclCutSEMI->AddCut(AliDielectronVarManager::kCentrality,10.,90.);
+  AliDielectronVarCuts *inclCut=new AliDielectronVarCuts("incl","incl");
+  inclCut->AddCut(AliDielectronVarManager::kPdgCode,443,443,kTRUE);
+  grpRNDMCuts->AddCut(exclCutCEN);
+  grpRNDMCuts->AddCut(exclCutSEMI);
+  grpRNDMCuts->AddCut(inclCut);
+  if(hasMC && cutDefinition==kIonut && 0) die->GetPairFilter().AddCuts(grpRNDMCuts); //ATTENTION
+
 }
 
 //______________________________________________________________________________________
@@ -413,8 +555,9 @@ void ConfigBgrd(AliDielectron *die, Int_t cutDefinition)
   switch(cutDefinition) {
   case kEvent:
   case kNoPID:
-  case kNoPIDEta:
+  case kPIDqa:
   case kRec:
+  case kLegEff:
     return;
   }
 
@@ -455,9 +598,11 @@ void ConfigEvtPlane(AliDielectron *die, Int_t cutDefinition)
   //
 
   switch(cutDefinition) {
+    //  case kEvent:
   case kNoPID:
-  case kNoPIDEta:
-  case kRec:
+  case kPIDqa:
+    //  case kRec:   // TOTHINK: might be needed when checking efficiencies versus dPhi
+  case kLegEff:
     return;
   }
 
@@ -492,18 +637,19 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
   Bool_t hasMC=die->GetHasMC();
 
   // booleans for histo selection
-  Bool_t bHistTrackQA=kFALSE, bHistEvts = kFALSE, bHistPair = kFALSE, bHistPairME = kFALSE, bHistFlow = kFALSE, bHistFlowQA=kFALSE, bHistPID=kFALSE;
+  Bool_t bHistTrackQA=kFALSE, bHistEvts=kFALSE, bHistPair=kFALSE, bHistTrk=kFALSE, bHistPairME=kFALSE, bHistFlow=kFALSE, bHistFlowQA=kFALSE, bHistPID=kFALSE;
   switch (cutDefinition) {
   case kEvent: bHistEvts=kTRUE; break;
-  case kRec:
-  case kNoPID:
-  case kNoPIDEta:
+  case kPIDqa: bHistTrk=kTRUE; break;
+  case kNoPID: bHistTrk=kTRUE; break;
+  case kRec:   /* */ break;
   case kTPC:
   case kTOF:   //bHistEvts=kTRUE; //bHistFlow=kTRUE;
   case kTRD:   ///bHistEvts=kTRUE; //bHistFlow=kTRUE;
+  case kAvgPt: 
   case kIonut: ///*bHistEvts=kTRUE;*/ bHistPair=kTRUE; break; //bHistPairME=kTRUE;
-  case kTPCTOFTRD: bHistPair=kTRUE; bHistPID=kTRUE; break; //bHistPairME=kTRUE;
-  case kAvgPt: /* */ break;
+  case kTPCTOFTRD: bHistPair=kTRUE; bHistTrk=kTRUE; bHistPID=kTRUE; break; //bHistPairME=kTRUE;
+  case kSysMCele: bHistPair=kTRUE; bHistPID=kFALSE; break; //bHistPairME=kTRUE;
   }
   if(hasMC) {
     bHistPID=kFALSE;
@@ -511,134 +657,66 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
 
   //Setup histogram Manager
   AliDielectronHistos *histos=new AliDielectronHistos(die->GetName(),die->GetTitle());
+  die->SetHistogramManager(histos);
+
+  //Initialise histogram classes
+  histos->SetReservedWords("Track;Pair");
 
   //add histograms to event class
   histos->AddClass("Event");
   Int_t maxMixBins = (die->GetMixingHandler() ? die->GetMixingHandler()->GetNumberOfBins() : 0);
   histos->UserHistogram("Event","","", 100, 0.0, 100.0,   AliDielectronVarManager::kCentrality);
-  if(!hasMC && die->GetMixingHandler() )
+  if(die->GetMixingHandler() )
     histos->UserHistogram("Event","","", maxMixBins, 0, maxMixBins, AliDielectronVarManager::kMixingBin);
+  // candidates monitoring
+  histos->UserProfile("Event","","", AliDielectronVarManager::kTracks, GetRunNumbers2011(), AliDielectronVarManager::kRunNumber);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kPairs, GetRunNumbers2011(), AliDielectronVarManager::kRunNumber);
+
+
+  //event plane histograms
+  if(cutDefinition==kFlow) {
+    if(!hasMC) AddQAHistsEP(die);
+    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiv0ArpH2);
+    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiv0CrpH2);
+    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiTPCrpH2);
+  }
 
   ////// EVENT HISTOS /////
   if(bHistEvts) {
-    histos->UserHistogram("Event","","", 100,0.,100.,    AliDielectronVarManager::kNTrk);
-    //    histos->UserHistogram("Event","","", 100,0.,100.,      AliDielectronVarManager::kNacc);
     histos->UserHistogram("Event","","", GetRunNumbers2011(), AliDielectronVarManager::kRunNumber);
     histos->UserHistogram("Event","","", 300,-15.,15.,   AliDielectronVarManager::kZvPrim);
+    //    histos->UserHistogram("Event","","", 300,0.,15000.,    AliDielectronVarManager::kRefMult);
+    histos->UserHistogram("Event","","", 300,0.,3000.,   AliDielectronVarManager::kRefMultTPConly);
+
+    //    histos->UserHistogram("Event","","", 100,0.,100.,      AliDielectronVarManager::kRefMultTPConly);
     histos->UserHistogram("Event","","", GetRunNumbers2011(), AliDielectronHelper::MakeLinBinning(3000, 0., 3000.),
-                         AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kNacc);
+                         AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kRefMultTPConly);
     histos->UserHistogram("Event","","", AliDielectronHelper::MakeLinBinning(90, 0., 90.), AliDielectronHelper::MakeLinBinning(3000, 0., 3000.),
-                         AliDielectronVarManager::kCentrality, AliDielectronVarManager::kNacc);
-    histos->UserProfile(  "Event","","", AliDielectronVarManager::kNacc,        90, 0., 90.,  AliDielectronVarManager::kCentrality);
+                         AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRefMultTPConly);
+    histos->UserProfile(  "Event","","", AliDielectronVarManager::kRefMultTPConly,        90, 0., 90.,  AliDielectronVarManager::kCentrality);
     histos->UserProfile(  "Event","","", AliDielectronVarManager::kNVtxContrib, 90, 0., 90.,  AliDielectronVarManager::kCentrality);
 
+    // event plane histograms
+    if(!hasMC) AddQAHistsEP(die);
+    // trigger histograms
     if(!hasMC) {
-      // event plane resolutions
-      TObjArray *limits  = new TObjArray();
-      limits->Add(AliDielectronHelper::MakeLinBinning( 18,  0.,    90.));
-      //    limits->Add(GetRunNumbers2011());
-      limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
-      limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
-      limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
-
-      UInt_t var[4]={AliDielectronVarManager::kCentrality,
-                    //            AliDielectronVarManager::kRunNumber,
-                    AliDielectronVarManager::kv0ATPCDiffH2,
-                    AliDielectronVarManager::kv0CTPCDiffH2,
-                    AliDielectronVarManager::kv0Av0CDiffH2 };
-      histos->UserSparse("Event", 4, limits, var);
-
-      // // event plane flattening
-      TObjArray *limits2  = new TObjArray();
-      limits2->Add(AliDielectronHelper::MakeLinBinning( 18,   0.,    90.));
-      //limits2->Add(GetRunNumbers2011());
-      limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6,   1.6));
-      limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6,   1.6));
-      limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6.,  1.6));
-
-      UInt_t var2[4]={AliDielectronVarManager::kCentrality,
-                     //                    AliDielectronVarManager::kRunNumber,
-                     AliDielectronVarManager::kv0ArpH2,
-                     AliDielectronVarManager::kv0CrpH2,
-                     AliDielectronVarManager::kTPCrpH2 };
-      //    histos->UserSparse("Event", 4, limits2, var2);
-    } //end: hasMC
+      histos->UserHistogram("Event","","", 29,0.,29.,    AliDielectronVarManager::kTriggerInclONL);
+      histos->UserHistogram("Event","","", 29,0.,29.,    AliDielectronVarManager::kTriggerInclOFF);
+      histos->UserHistogram("Event","","", 29,0.,29.,    AliDielectronVarManager::kTriggerExclOFF);
+      histos->UserHistogram("Event","","", 100,0.,100.,29,0.,29., 
+                           AliDielectronVarManager::kCentrality,AliDielectronVarManager::kTriggerInclONL);
+      histos->UserHistogram("Event","","", 100,0.,100.,29,0.,29., 
+                           AliDielectronVarManager::kCentrality,AliDielectronVarManager::kTriggerExclOFF);
+      histos->UserHistogram("Event","","", 300,0.,3000.,29,0.,29., 
+                           AliDielectronVarManager::kRefMultTPConly,AliDielectronVarManager::kTriggerExclOFF);
+      histos->UserHistogram("Event","","", 300,0.,3000.,29,0.,29., 
+                           AliDielectronVarManager::kRefMultTPConly,AliDielectronVarManager::kTriggerInclOFF);
+    }
 
   } //hist: event
 
-  ////// FLOW //////
-  if(bHistFlow) {
-    histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCxH2);
-    histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCyH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kTPCrpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0ArpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0CrpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0ACrpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0A0rpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0C0rpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0A3rpH2);
-    histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0C3rpH2);
-    // EP resolution calculation centrality dependence
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0ATPCDiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0CTPCDiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0CDiffH2);
-  } // hist: flow
-
-  // DEBUG
-  if(bHistFlowQA) {
-    // TPC event plane
-    histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCxH2uc);
-    histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCyH2uc);
-    histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCrpH2uc);
-    histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub1rpH2);
-    histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub2rpH2);
-    histos->UserHistogram("Event","","", 100,   -1.,   1., AliDielectronVarManager::kTPCsub12DiffH2);
-    // detector effects
-    histos->UserHistogram("Event","","", 10,0.,100., 300,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kTPCsub12DiffH2Sin);
-    // recentering stuff
-    histos->UserProfile("Event","","", AliDielectronVarManager::kTPCxH2,
-                       AliDielectronHelper::MakeLinBinning(8, 0.,80.), GetRunNumbers2011(),
-                       AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
-    histos->UserProfile("Event","","", AliDielectronVarManager::kTPCyH2,
-                       AliDielectronHelper::MakeLinBinning(8, 0.,80.), GetRunNumbers2011(),
-                       AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
-    // EP resolution calculation
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0ATPCDiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0CTPCDiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0Av0CDiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kTPCsub12DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0Av0C0DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0Av0C3DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0Cv0A0DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0Cv0A3DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0A0v0A3DiffH2);
-    histos->UserHistogram("Event","","", 200,-1.0,1.0,  AliDielectronVarManager::kv0C0v0C3DiffH2);
-    // EP resolution calculation centrality dependence
-    histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0ATPCDiffH2);
-    histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0CTPCDiffH2);
-    histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0CDiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kTPCsub12DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0C0DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Av0C3DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Cv0A0DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0Cv0A3DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0A0v0A3DiffH2);
-    // histos->UserHistogram("Event","","", 18,0.,90., 100,-1.0,1.0, AliDielectronVarManager::kCentrality, AliDielectronVarManager::kv0C0v0C3DiffH2);
-    // EP angle correlation
-    histos->UserHistogram("Event","","", 320,-3.2.,3.2, 320,-3.2.,3.2, 
-                         AliDielectronVarManager::kTPCrpH2uc,AliDielectronVarManager::kv0ACrpH2);
-    // EP Qvector magnitudes // TODO move to QA
-    histos->UserHistogram("Event","","", 200,0.,200., AliDielectronVarManager::kTPCmagH2uc);
-    histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0ACmagH2);
-    histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0AmagH2);
-    histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0CmagH2);
-  } //hist: flowQA
-
-
   ///// PAIR HISTOS /////
   if(bHistPair) {
-    //Initialise histogram classes
-    histos->SetReservedWords("Track;Pair");
 
     //Pair classes
     // to fill also mixed event histograms loop until 7 or 10
@@ -647,21 +725,50 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
     }
     //add MC signal histograms to pair class
     if(die->GetMCSignals()) {
-      for (Int_t i=0; i<die->GetMCSignals()->GetEntriesFast(); ++i)
+      for (Int_t i=0; i<die->GetMCSignals()->GetEntriesFast(); ++i) {
        histos->AddClass(Form("Pair_%s",die->GetMCSignals()->At(i)->GetName()));
+       //      histos->AddClass(Form("Pair_%s_MCtruth",die->GetMCSignals()->At(i)->GetName()));
+      }
     }
 
+    ///// Pair classes /////
+    histos->UserHistogram("Pair","","",  125,.0,125*0.04, AliDielectronVarManager::kM); // 40MeV bins, 12GeV/c2
+    histos->UserHistogram("Pair","","",  100,-1.,1.,      AliDielectronVarManager::kY);
+    histos->UserHistogram("Pair","","",  400,0,20.,       AliDielectronVarManager::kPt);
+    histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kOpeningAngle);
+    histos->UserHistogram("Pair","","",  100,0.,20,       AliDielectronVarManager::kChi2NDF);
+    histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kPsiPair);
+    histos->UserHistogram("Pair","","",  200,0.,100.,     AliDielectronVarManager::kR);
+    histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDist);
+    histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDistXY);
+    histos->UserHistogram("Pair","","", 210,-1.05,1.05, 100,0.,2.5, 
+                         AliDielectronVarManager::kArmAlpha,AliDielectronVarManager::kArmPt);
+    ;
+    if(!hasMC && die->GetMixingHandler() )
+      histos->UserHistogram("Pair","","", maxMixBins, 0, maxMixBins, AliDielectronVarManager::kMixingBin);
+
+    histos->UserHistogram("Pair","","",  100,.0,1., AliDielectronVarManager::kRndmPair);
+    // histos->UserHistogram("Pair","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCode);
+    // histos->UserHistogram("Pair","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCodeMother);
+    // histos->UserHistogram("Pair","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCodeGrandMother);
+
+  } //hist: pairs
+
+
+  ///// TRACK HISTOS /////
+  if(bHistTrk) {
     //Track classes
     //legs from pair (fill SE)
     for (Int_t i=1; i<2; ++i){
-      histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(i)));
+      if(bHistPair) histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(i)));
     }
     //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)));
     histos->AddClass(Form("Track_%s",     AliDielectron::PairClassName(AliDielectron::kEv1PM)));
 
+    // PID post calibration
+    if(cutDefinition==kPIDqa) AddQAHistsPID(die);
 
-    ////// TRACK HISTOS /////
     // Vertex
     // histos->UserHistogram("Track","","", 500,-1.,1., AliDielectronVarManager::kImpactParXY);
     // histos->UserHistogram("Track","","", 600,-3.,3., AliDielectronVarManager::kImpactParZ);
@@ -676,10 +783,10 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
     // TRD
     histos->UserHistogram("Track","","",   8,-0.5,  7.5, AliDielectronVarManager::kTRDpidQuality);
     // PID
-    // histos->UserHistogram("Track","","", 400,0.2,20.,200,0.,200., AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
-    // histos->UserHistogram("Track","","", 400,0.2,20.,200,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+    histos->UserHistogram("Track","","", 400,0.2,20.,200,0.,200., AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
+    histos->UserHistogram("Track","","", 400,0.2,20.,200,-10.,10.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
     histos->UserHistogram("Track","","", 250,0.0,5.0,300,0.,1.2,  AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta,kTRUE);
-    //    histos->UserHistogram("Track","","", 100,-1.,+1.,200,-10.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+    histos->UserHistogram("Track","","", 100,-1.,+1.,200,-10.,10.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
 
     histos->UserHistogram("Track","","", 100,0.2,10.,100,0.,200.,
                          AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
@@ -699,124 +806,47 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
                          AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle);
     histos->UserHistogram("Track","","", 100,-1.,+1.,100,-5.,+5.,
                          AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEleRaw);
-    
-    if(!hasMC) histos->UserHistogram("Track","","", 150,0.0,1.5, AliDielectronVarManager::kLegEff);
-    if(!hasMC) histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 18,0.0,90.0, AliDielectronVarManager::kCentrality);
-    if(!hasMC) histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 100,0.0,20.0, AliDielectronVarManager::kPt);
-    if(!hasMC) histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 20,0.0,TMath::TwoPi(), AliDielectronVarManager::kPhi);
-    if(!hasMC) histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 20,-1.,+1., AliDielectronVarManager::kEta);
-
-    // TPC PID (detailed) //
-    if(bHistPID) {
-      // arbitrary binning for variables
-      TVectorD *vcen = AliDielectronHelper::MakeLinBinning( 21,  0.,    52.5);
-      (*vcen)[21] = 90.;
-
-      TObjArray *limits  = new TObjArray();
-      limits->Add(AliDielectronHelper::MakeLinBinning( 75,-10.,     5.));
-      //  limits->Add(AliDielectronHelper::MakeLinBinning(100,  0.,   200.));
-      limits->Add(AliDielectronHelper::MakeLinBinning(60,   0.,    1.2));
-      limits->Add(AliDielectronHelper::MakeLinBinning(100,  0.,  4000.));
-      limits->Add(AliDielectronHelper::MakeLinBinning( 50,  0.,    10.));
-      limits->Add(vcen);
-      //    limits->Add(AliDielectronHelper::MakeLinBinning( 36,  0.,    90.));
-      limits->Add(AliDielectronHelper::MakeLinBinning( 20, -1.,     1.));
-      //  limits->Add(GetRunNumbers());
-      UInt_t var[6]={AliDielectronVarManager::kTPCnSigmaEle,
-                    AliDielectronVarManager::kTOFbeta,
-                    //              AliDielectronVarManager::kTPCsignal,
-                    AliDielectronVarManager::kRefMultTPConly,
-                    AliDielectronVarManager::kPIn,
-                    AliDielectronVarManager::kCentrality,
-                    AliDielectronVarManager::kEta
-                    //      AliDielectronVarManager::kRunNumber
-      };
-      histos->UserSparse(Form("Track_%s",     AliDielectron::PairClassName(AliDielectron::kEv1PM)), 6, limits, var);      
-    }
-
-    ///// Pair classes /////
-    histos->UserHistogram("Pair","","",  125,.0,125*0.04, AliDielectronVarManager::kM); // 40MeV bins, 12GeV/c2
-    histos->UserHistogram("Pair","","",  100,-1.,1.,      AliDielectronVarManager::kY);
-    histos->UserHistogram("Pair","","",  400,0,20.,       AliDielectronVarManager::kPt);
-    histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kOpeningAngle);
-    histos->UserHistogram("Pair","","",  100,0.,20,       AliDielectronVarManager::kChi2NDF);
-    histos->UserHistogram("Pair","","",  100,0.,3.15,     AliDielectronVarManager::kPsiPair);
-    histos->UserHistogram("Pair","","",  200,0.,100.,     AliDielectronVarManager::kR);
-    histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDist);
-    histos->UserHistogram("Pair","","",   50,0.,5.,       AliDielectronVarManager::kLegDistXY);
-    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiv0ArpH2);
-    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiv0CrpH2);
-    histos->UserHistogram("Pair","","", 100,-1*TMath::Pi(),+1*TMath::Pi(), AliDielectronVarManager::kDeltaPhiTPCrpH2);
-    //    histos->UserHistogram("Pair","","", 210,-1.05,1.05, 100,0.,2.5, AliDielectronVarManager::kArmAlpha,AliDielectronVarManager::kArmPt);
-    if(!hasMC) histos->UserProfile("Pair","","", AliDielectronVarManager::kPairEff, 125,.0,125*0.04, AliDielectronVarManager::kM);
-    if(!hasMC) histos->UserProfile("Pair","","", AliDielectronVarManager::kPairEff, 100,.0,15.0,     AliDielectronVarManager::kPt);
-
-    if(!hasMC && die->GetMixingHandler() )
-      histos->UserHistogram("Pair","","", maxMixBins, 0, maxMixBins, AliDielectronVarManager::kMixingBin);
-
+  } //hist: tracks
 
-  } //hist: pair
 
+  if(!hasMC && cutDefinition==kAvgPt) {
+    // add single electron efficiency histograms
+    AddHistsEleEff(die);
+  }
 
   ////// MONTE CARLO //////
-  if(hasMC && cutDefinition==kLegEff && 1) { ////////ATTENTION
-
-    //Initialise histogram classes
-    histos->SetReservedWords("Track");
+  if(cutDefinition==kLegEff) {
 
     //add MC signal histograms to track class
     if(die->GetMCSignals()) {
-      TString className = Form("Track_%s_%s",AliDielectron::PairClassName(AliDielectron::kEv1PM),die->GetMCSignals()->Last()->GetName());
-      histos->AddClass(Form("%s_MCtruth",className.Data()));
-      histos->AddClass(className.Data());
-
-      //workaround for AN-09 dummy
-      for(Int_t isig=0; isig<die->GetMCSignals()->GetEntriesFast(); isig++) {
-       histos->AddClass(Form("Pair_%s",die->GetMCSignals()->At(isig)->GetName()));
-       histos->AddClass(Form("Pair_%s_MCtruth",die->GetMCSignals()->At(isig)->GetName()));
-       // histos->AddClass(Form("Track_Legs_%s",die->GetMCSignals()->At(isig)->GetName()));
-       // histos->AddClass(Form("Track_Legs_%s_MCtruth",die->GetMCSignals()->At(isig)->GetName()));
-       histos->AddClass(Form("Track_%s_%s",AliDielectron::PairClassName(AliDielectron::kEv1PM),die->GetMCSignals()->At(isig)->GetName()));
-       histos->AddClass(Form("Track_%s_%s_MCtruth",AliDielectron::PairClassName(AliDielectron::kEv1PM),die->GetMCSignals()->At(isig)->GetName()));
-      }
-
-      // single leg efficiency //
-      // arbitrary binning for variables
-      // TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 41,  0.0,    10.25);
-      // (*vpt)[41] = 20.;
-
-      TObjArray *limEpm  = new TObjArray();
-      //    limEpm->Add(AliDielectronHelper::MakeLinBinning( 75,-10.,     5.));
-      limEpm->Add(AliDielectronHelper::MakeLinBinning( 18,  0.,    90.));
-      limEpm->Add(AliDielectronHelper::MakeLinBinning( 80,  0.,    20.));
-      //      limEpm->Add(vpt);
-      limEpm->Add(AliDielectronHelper::MakeLinBinning( 20,  0.,   TMath::TwoPi()));
-      limEpm->Add(AliDielectronHelper::MakeLinBinning( 20, -1.,    +1.));
-      //      limEpm->Add(AliDielectronHelper::MakeLinBinning( 20, -2.,    +2.));
-      //  limEpm->Add(GetRunNumbers());
-      UInt_t varEpm[]={//AliDielectronVarManager::kTPCnSigmaEle,
-       AliDielectronVarManager::kCentrality
-       ,AliDielectronVarManager::kPt
-       ,AliDielectronVarManager::kPhi
-       ,AliDielectronVarManager::kEta
-       //      ,AliDielectronVarManager::kY
-       //      ,AliDielectronVarManager::kRunNumber
-      };
-
-      histos->UserSparse("Track", limEpm->GetEntriesFast(), limEpm, varEpm);
-    }
-  } //end: hasMC
 
+      TString className="";
+      for (Int_t i=0; i<die->GetMCSignals()->GetEntriesFast(); ++i) {
+       TString sigMCname = die->GetMCSignals()->At(i)->GetName();
+
+       // mc truth
+       //      histos->AddClass(Form("Pair_%s_MCtruth",      sigMCname.Data()));
+       // histos->AddClass(Form("Track_Legs_%s_MCtruth",sigMCname.Data()));
+       // mc reconstructed
+       // histos->AddClass(Form("Pair_%s",              sigMCname.Data()));
+       // histos->AddClass(Form("Track_Legs_%s",        sigMCname.Data()));
+       // tracks
+       histos->AddClass(Form("Track_%s_%s",AliDielectron::PairClassName(AliDielectron::kEv1PM),sigMCname.Data()));
+       histos->AddClass(Form("Track_%s_%s_MCtruth",AliDielectron::PairClassName(AliDielectron::kEv1PM),sigMCname.Data()));
+      } //end: loop signals
+    } //end: has signals
+
+    // add single electron histograms
+    AddHistsEleEff(die);
+    // pdg codes
+    //    histos->UserHistogram("Track","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCode);
+    //    histos->UserHistogram("Track","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCodeMother);
+    //    histos->UserHistogram("Track","","",  GetPDGcodes(), AliDielectronVarManager::kPdgCodeGrandMother);
+    //    histos->UserHistogram("Track","","",  GetPDGcodes(), GetPDGcodes(),
+    //                           AliDielectronVarManager::kPdgCodeMother, AliDielectronVarManager::kPdgCodeGrandMother);
+  }
 
 
-  /*
-    if(cutDefinition == kTOFTRD && hasMC) {
-    histos->AddClass("MCEvent");
-    histos->UserHistogram("MCEvent","Cent_NJPsis","Centrality vs. generated incl. J/#psi per event;centrality (%);N_{J/#psi}",
-    10,0.,100., 21,-0.5,20.5,
-    AliDielectronVarManager::kCentrality,AliDielectronVarManager::kNumberOfJPsis);
-    }
-  */
 
   die->SetHistogramManager(histos);
 
@@ -828,6 +858,258 @@ void InitHistograms(AliDielectron *die, Int_t cutDefinition)
     //printf(" [D] HistogramManger: Class %s: Histograms: %04d \n", l->GetName(), l->GetEntries());
   }
 
+} //end: init histograms
+
+void AddQAHistsPID(AliDielectron *die) {
+  //
+  // add histograms for PID validation, comparison, post calibration aso.
+  //
+
+  Bool_t hasMC=die->GetHasMC();
+  AliDielectronHistos *histos = die->GetHistoManager();
+
+  // add MC signal tracks
+  if(hasMC && die->GetMCSignals()) {
+    TString sigMCname = die->GetMCSignals()->Last()->GetName();
+    histos->AddClass(Form("Track_%s_%s",AliDielectron::PairClassName(AliDielectron::kEv1PM),sigMCname.Data()));
+  }
+
+
+  // for TPC post calibration
+
+  // arbitrary binning for variables
+  TVectorD *vcen = AliDielectronHelper::MakeLinBinning( 11,  0.,    55.);
+  (*vcen)[21] = 90.;
+
+  // array of bin limits
+  TObjArray *limits  = new TObjArray();
+  limits->Add(AliDielectronHelper::MakeLinBinning( 75,-10.,     5.));
+  limits->Add(AliDielectronHelper::MakeLinBinning( 75,-10.,     5.));
+  //  limits->Add(AliDielectronHelper::MakeLinBinning(100,  0.,   200.));
+  //  limits->Add(AliDielectronHelper::MakeLinBinning(60,   0.,    1.2));
+  limits->Add(AliDielectronHelper::MakeLinBinning( 50,  0.,  4000.));
+  limits->Add(AliDielectronHelper::MakeLinBinning( 50,  0.,    10.));
+  //  limits->Add(vcen);
+  //    limits->Add(AliDielectronHelper::MakeLinBinning( 36,  0.,    90.));
+  limits->Add(AliDielectronHelper::MakeLinBinning( 20, -1.,     1.));
+  limits->Add(GetRunNumbers2011());
+  UInt_t var[]={AliDielectronVarManager::kTPCnSigmaEleRaw,  // NOTE: raw nsigma w/o corr
+               AliDielectronVarManager::kTPCnSigmaEle,
+               //              AliDielectronVarManager::kTOFbeta,
+               // AliDielectronVarManager::kTPCsignal,
+               AliDielectronVarManager::kRefMultTPConly,
+               AliDielectronVarManager::kPIn,
+               // AliDielectronVarManager::kCentrality,
+               AliDielectronVarManager::kEta,
+               AliDielectronVarManager::kRunNumber
+  };
+  // add merged track histogram
+  histos->UserSparse("Track", limits->GetEntriesFast(), limits, var);
+
+  // run dependence of nisgma electron
+  histos->UserHistogram("Track","","", GetRunNumbers2011(),AliDielectronHelper::MakeLinBinning(100,-5.,+5.),
+                       AliDielectronVarManager::kRunNumber,AliDielectronVarManager::kTPCnSigmaEleRaw);
+  histos->UserHistogram("Track","","", GetRunNumbers2011(),AliDielectronHelper::MakeLinBinning(100,-5.,+5.),
+                       AliDielectronVarManager::kRunNumber,AliDielectronVarManager::kTPCnSigmaEle);
+
+  // post calibration check
+  histos->UserHistogram("Track","","", 100,0.2,10.,100,-5.,+5.,
+                       AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEleRaw,kTRUE);
+  histos->UserHistogram("Track","","", 100,0.2,10.,100,-5.,+5.,
+                       AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+
+  // TPC number of points used for nsigma calculation
+  histos->UserHistogram("Track","","", 160,-0.5,159.5, AliDielectronVarManager::kTPCsignalN);
+}
+
+void AddQAHistsEP(AliDielectron *die) {
+  //
+  // add histograms for event plane flattening aso.
+  //
+
+  Bool_t hasMC=die->GetHasMC();
+  AliDielectronHistos *histos = die->GetHistoManager();
+
+  // event plane resolutions
+  TObjArray *limits  = new TObjArray();
+  limits->Add(AliDielectronHelper::MakeLinBinning( 18,  0.,    90.));
+  //    limits->Add(GetRunNumbers2011());
+  limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
+  limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
+  limits->Add(AliDielectronHelper::MakeLinBinning(100,  -1.,    1.));
+
+  UInt_t var[]={AliDielectronVarManager::kCentrality,
+               //                 AliDielectronVarManager::kRunNumber,
+               AliDielectronVarManager::kv0ATPCDiffH2,
+               AliDielectronVarManager::kv0CTPCDiffH2,
+               AliDielectronVarManager::kv0Av0CDiffH2 };
+  //  histos->UserSparse("Event", 4, limits, var);
+
+  // event plane angles
+  TObjArray *limits2  = new TObjArray();
+  limits2->Add(AliDielectronHelper::MakeLinBinning( 18,   0.,    90.));
+  //  limits2->Add(GetRunNumbers2011());
+  limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6,   1.6));
+  limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6,   1.6));
+  limits2->Add(AliDielectronHelper::MakeLinBinning(100,  -1.6.,  1.6));
+
+  UInt_t var2[]={AliDielectronVarManager::kCentrality,
+                //              AliDielectronVarManager::kRunNumber,
+                AliDielectronVarManager::kv0ArpH2,
+                AliDielectronVarManager::kv0CrpH2,
+                AliDielectronVarManager::kTPCrpH2 };
+  histos->UserSparse("Event", limits2->GetEntriesFast(), limits2, var2);
+
+  // VZERO event plane angles (sub rings)
+  histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0A0rpH2);
+  histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0C0rpH2);
+  histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0A3rpH2);
+  histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0C3rpH2);
+  histos->UserHistogram("Event","","", 100,-2.,2., AliDielectronVarManager::kv0ACrpH2); // combined A+C
+
+  // run dependence of the angles
+  histos->UserHistogram("Event","","", GetRunNumbers2011(), AliDielectronHelper::MakeLinBinning(100,-1.6,1.6),
+                       AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kv0ArpH2);
+  histos->UserHistogram("Event","","", GetRunNumbers2011(), AliDielectronHelper::MakeLinBinning(100,-1.6,1.6),
+                       AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kv0CrpH2);
+  histos->UserHistogram("Event","","", GetRunNumbers2011(), AliDielectronHelper::MakeLinBinning(100,-1.6,1.6),
+                       AliDielectronVarManager::kRunNumber, AliDielectronVarManager::kTPCrpH2);
+
+
+  // TPC q vector components
+  histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCxH2);
+  histos->UserHistogram("Event","","", 100,-1500.,1500., AliDielectronVarManager::kTPCyH2);
+  // histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub1rpH2);
+  // histos->UserHistogram("Event","","", 100,   -2.,   2., AliDielectronVarManager::kTPCsub2rpH2);
+  // histos->UserHistogram("Event","","", 100,   -1.,   1., AliDielectronVarManager::kTPCsub12DiffH2);
+
+  // further event plane resolutions (used in 3 sub event method)
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0ATPCDiffH2,   18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0CTPCDiffH2,   18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0Av0CDiffH2,   18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kTPCsub12DiffH2, 18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0Av0C0DiffH2,  18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0Av0C3DiffH2,  18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0Cv0A0DiffH2,  18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0Cv0A3DiffH2,  18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0A0v0A3DiffH2, 18, 0.,90., AliDielectronVarManager::kCentrality);
+  histos->UserProfile("Event","","", AliDielectronVarManager::kv0C0v0C3DiffH2, 18, 0.,90., AliDielectronVarManager::kCentrality);
+
+  // EP angle correlation (range of phi angle)
+  // histos->UserHistogram("Event","","", 320,-3.2.,3.2, 320,-3.2.,3.2,
+  //                   AliDielectronVarManager::kTPCrpH2,AliDielectronVarManager::kv0ACrpH2);
+
+  // EP Qvector magnitudes
+  histos->UserHistogram("Event","","", 200,0.,200., AliDielectronVarManager::kTPCmagH2);
+  histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0ACmagH2);
+  histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0AmagH2);
+  histos->UserHistogram("Event","","", 200,0.,800., AliDielectronVarManager::kv0CmagH2);
+
+  // detector effects checks
+  histos->UserHistogram("Event","","", 10,0.,100., 300,-1.0,1.0,
+                       AliDielectronVarManager::kCentrality, AliDielectronVarManager::kTPCsub12DiffH2Sin);
+
+  // TPC recentering
+  // histos->UserProfile("Event","","", AliDielectronVarManager::kTPCxH2,
+  //                 AliDielectronHelper::MakeLinBinning(9, 0.,90.), GetRunNumbers2011(),
+  //                 AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
+  // histos->UserProfile("Event","","", AliDielectronVarManager::kTPCyH2,
+  //                 AliDielectronHelper::MakeLinBinning(9, 0.,90.), GetRunNumbers2011(),
+  //                 AliDielectronVarManager::kCentrality, AliDielectronVarManager::kRunNumber);
+
+}
+
+void AddHistsEleEff(AliDielectron *die) {
+  //
+  // adding histograms for single electron efficiencies
+  //
+
+  Bool_t hasMC=die->GetHasMC();
+  AliDielectronHistos *histos = die->GetHistoManager();
+
+  // applied efficiencies in collision data
+  if(!hasMC) {
+    histos->UserHistogram("Track","","", 101,-0.01,1.0, AliDielectronVarManager::kLegEff);
+    histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 18,0.0,90.0,  AliDielectronVarManager::kCentrality);
+    histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 100,0.0,20.0, AliDielectronVarManager::kPt);
+    histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 20,0.0,TMath::TwoPi(), AliDielectronVarManager::kPhi);
+    histos->UserProfile("Track","","", AliDielectronVarManager::kLegEff, 20,-1.,+1.,   AliDielectronVarManager::kEta);
+
+    histos->UserHistogram("Pair","","", 101,-0.01,1.0, AliDielectronVarManager::kPairEff);
+    histos->UserProfile("Pair","","", AliDielectronVarManager::kPairEff, 125,.0,125*0.04, AliDielectronVarManager::kM);
+    histos->UserProfile("Pair","","", AliDielectronVarManager::kPairEff, 100,.0,10.0,     AliDielectronVarManager::kPt);
+    histos->UserProfile("Pair","","", AliDielectronVarManager::kPairEff, 18,0.0,90.0,     AliDielectronVarManager::kCentrality);
+
+    histos->UserHistogram("Pair","","", 125,.0,125*0.04, 101,-0.01,1.0, 
+                         AliDielectronVarManager::kM, AliDielectronVarManager::kPairEff);
+
+    histos->UserProfile("Pair","","", AliDielectronVarManager::kPt,125,.0,125*0.04, AliDielectronVarManager::kM);
+    //weighted
+    histos->UserHistogram("Pair","","", AliDielectronHelper::MakeLinBinning(125,.0,125*0.04),
+                         AliDielectronVarManager::kM, AliDielectronVarManager::kOneOverPairEff);
+    histos->UserProfile("Pair", "","", AliDielectronVarManager::kPt,AliDielectronHelper::MakeLinBinning(125,.0,125*0.04),
+                       AliDielectronVarManager::kM, "", AliDielectronVarManager::kOneOverPairEff);
+  }
+
+  // single electron efficiecy
+
+  // arbitrary binning for variables
+  // TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 41,  0.0,    10.25);
+  // (*vpt)[41] = 20.;
+  TVectorD *vpt1 = AliDielectronHelper::MakeLinBinning( (int)(( 3. - 0.)/0.10),    0.,     3.); //steps of 100MeV
+  TVectorD *vpt2 = AliDielectronHelper::MakeLinBinning( (int)(( 10.- 3.25)/0.25),  3.25,  10.); //steps of 250MeV
+  TVectorD *vpt3 = AliDielectronHelper::MakeLinBinning( (int)((100.-20.)/10.0),   20.,   100.); //steps of 10GeV
+  TVectorD *vpt  = new TVectorD(vpt1->GetNrows()+vpt2->GetNrows()+vpt3->GetNrows());
+  for(Int_t i=0; i<vpt1->GetNrows(); i++) (*vpt)[i]                                   = (*vpt1)[i];
+  for(Int_t i=0; i<vpt2->GetNrows(); i++) (*vpt)[vpt1->GetNrows()+i]                  = (*vpt2)[i];
+  for(Int_t i=0; i<vpt3->GetNrows(); i++) (*vpt)[vpt1->GetNrows()+vpt2->GetNrows()+i] = (*vpt3)[i];
+  //vpt->Print();
+
+  // array of bin limits
+  TObjArray *limEpm  = new TObjArray();
+  //    limEpm->Add(AliDielectronHelper::MakeLinBinning( 75,-10.,     5.));
+  limEpm->Add(AliDielectronHelper::MakeLinBinning( 18,  0.,    90.));
+  limEpm->Add(vpt);
+  //  limEpm->Add(AliDielectronHelper::MakeLinBinning( 20,  0.,   TMath::TwoPi()));
+  limEpm->Add(AliDielectronHelper::MakeLinBinning( 20, -1.,    +1.));
+  limEpm->Add(AliDielectronHelper::MakeLinBinning(  1, -1.,    +1.));
+  limEpm->Add(AliDielectronHelper::MakeLinBinning(  1, -1.,    +1.));
+  limEpm->Add(GetRunNumbers2011());
+  limEpm->Add(GetPDGcodes());
+  //  limEpm->Add(GetPDGcodes());
+  UInt_t varEpm[]={//AliDielectronVarManager::kTPCnSigmaEle,
+    AliDielectronVarManager::kCentrality
+    ,AliDielectronVarManager::kPt
+    //    ,AliDielectronVarManager::kPhi
+    ,AliDielectronVarManager::kEta
+    ,AliDielectronVarManager::kImpactParXY
+    ,AliDielectronVarManager::kImpactParZ
+    ,AliDielectronVarManager::kRunNumber
+    ,AliDielectronVarManager::kPdgCodeMother
+    //    ,AliDielectronVarManager::kPdgCodeGrandMother
+  };
+  // adding histogram
+  if(hasMC) histos->UserSparse("Track", limEpm->GetEntriesFast(), limEpm, varEpm);
+
+  histos->UserHistogram("Track","","", 500,-1.,1., AliDielectronVarManager::kImpactParXY);
+  histos->UserHistogram("Track","","", 600,-3.,3., AliDielectronVarManager::kImpactParZ);
+
+  // polarisation //
+  // array of bin limits
+  TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 21,  0.0,    10.5);
+  (*vpt)[21] = 100.;
+  TObjArray *limPair  = new TObjArray();
+  limPair->Add(AliDielectronHelper::MakeLinBinning( 18,  0.,    90.));
+  limPair->Add(AliDielectronHelper::MakeLinBinning( 20, -1.,    +1.));
+  limPair->Add(vpt);
+  //  limPair->Add(GetPDGcodes());
+  UInt_t varPair[]={
+    AliDielectronVarManager::kCentrality
+    ,AliDielectronVarManager::kThetaCS
+    ,AliDielectronVarManager::kPt
+    //    ,AliDielectronVarManager::kPdgCodeMother
+  };
+  //  if(hasMC) histos->UserSparse("Pair", limPair->GetEntriesFast(), limPair, varPair); // TAKES 4ever
 
 }
 
@@ -836,50 +1118,55 @@ void InitHF(AliDielectron* die, Int_t cutDefinition)
   //
   // Setup the HF arrays
   //
-  Bool_t hasMC=die->GetHasMC();
+  // do not fill
+  switch(cutDefinition) {
+  case kEvent:
+  case kPIDqa:
+  case kLegEff:
+  case kNoPID:
+  case kRec:
+    return;
+  }
 
+  // has mc
+  Bool_t hasMC=die->GetHasMC();
   // booleans for histo selection
-  Bool_t bHistFlow = kTRUE, bHistPt = kTRUE, bHistEff = kTRUE; //ATTENTION
-  switch (cutDefinition) {
-  case kAvgPt:  bHistFlow=kFALSE;; break;
-    //  default:      bHistPt=kTRUE; bHistFlow = kTRUE; bHistEff=kTRUE; break;
-  }
+  Bool_t bHistEff = kFALSE; //ATTENTION
+  // mixing
+  AliDielectronMixingHandler *mixH=die->GetMixingHandler();
+  Int_t maxMixBins = (mixH ? mixH->GetNumberOfBins() : 0);
 
+  // container
   AliDielectronHF *hf=new AliDielectronHF(die->GetName(),die->GetTitle());
   // define pair types and sources
   if(hasMC) hf->SetStepForMCGenerated();
-  //  else
-  if(hasMC)  hf->SetPairTypes(AliDielectronHF::kOSandMIX);
-    //  hf->SetPairTypes(AliDielectronHF::kOSonly);
-  if(!hasMC) hf->SetPairTypes(AliDielectronHF::kAll);
+  hf->SetPairTypes(AliDielectronHF::kOSandMIX);
+  //  hf->SetPairTypes(AliDielectronHF::kMConly); // only mc truth
+  //  hf->SetPairTypes(AliDielectronHF::kAll);    // all pair types
 
-  //// define output objects ////
+  //// define the grid size and granularity /////
+  hf->AddCutVariable(AliDielectronVarManager::kCentrality,               9, 0., 90.);
+  TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 21,  0.0,    10.5);
+  (*vpt)[21] = 100.;
+  hf->AddCutVariable(AliDielectronVarManager::kPt, vpt);
+  hf->AddCutVariable(AliDielectronVarManager::kY,  1, -0.8,  0.8);
 
   // defaults
   hf->UserHistogram("Pair", AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
   // for mixed event weighting
-  Int_t maxMixBins = (die->GetMixingHandler() ? die->GetMixingHandler()->GetNumberOfBins() : 0);
-  //  if(maxMixBins)  hf->UserHistogram("Pair", AliDielectronHelper::MakeLinBinning(maxMixBins,0,maxMixBins), AliDielectronVarManager::kMixingBin);
+  // if(mixH) hf->UserHistogram("Pair", AliDielectronHelper::MakeLinBinning(maxMixBins,0,maxMixBins), AliDielectronVarManager::kMixingBin);
 
   // mean pt analysis
-  if(bHistPt) {
+  if(cutDefinition==kAvgPt) {
+    hf->AddCutVariable(AliDielectronVarManager::kPairEff,  AliDielectronHelper::MakeArbitraryBinning(".0,.01,.02,.03,.05,.1,1."));
     hf->UserProfile("Pair", AliDielectronVarManager::kPt,
                    AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
-  }
-
-  // on the fly efficienies
-  if(bHistEff && !hasMC) {
-    hf->UserProfile("Pair", AliDielectronVarManager::kPairEff, 
+    hf->UserProfile("Pair", AliDielectronVarManager::kPtSq,
                    AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
-    hf->UserProfile("Pair", AliDielectronVarManager::kPt,
-                   AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM, 
-                   "", AliDielectronVarManager::kOneOverPairEff);
-    hf->UserHistogram("Pair", AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM,
-                     AliDielectronVarManager::kOneOverPairEff);
   }
 
   // flow analysis
-  if(bHistFlow && !hasMC) {  
+  if(cutDefinition==kFlow && !hasMC) {
     // flow versus minv
     hf->UserProfile("Pair", AliDielectronVarManager::kv0ArpH2FlowV2,
                    AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
@@ -898,16 +1185,38 @@ void InitHF(AliDielectron* die, Int_t cutDefinition)
                    AliDielectronHelper::MakeLinBinning(1,.0,125*0.04), AliDielectronVarManager::kM);
     hf->UserProfile("Pair", AliDielectronVarManager::kTPCrpH2FlowV2Sin,
                    AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
+
+    // variables
+    hf->AddCutVariable(AliDielectronVarManager::kDeltaPhiv0ArpH2, GetDeltaPhiBins());
+    hf->AddCutVariable(AliDielectronVarManager::kDeltaPhiv0CrpH2, GetDeltaPhiBins());
+    hf->AddCutVariable(AliDielectronVarManager::kDeltaPhiTPCrpH2, GetDeltaPhiBins());
+  }
+
+  // on the fly efficienies
+  if(cutDefinition==kAvgPt && (!hasMC || 0)) {
+    hf->UserProfile("Pair", AliDielectronVarManager::kPairEff, 
+                   AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM);
+    hf->UserHistogram("Pair", AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM,
+                     AliDielectronVarManager::kOneOverPairEff);
+    //weighted
+    hf->UserProfile("Pair", AliDielectronVarManager::kPt,
+                   AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM, 
+                   "", AliDielectronVarManager::kOneOverPairEff);
+    hf->UserProfile("Pair", AliDielectronVarManager::kPtSq,
+                   AliDielectronHelper::MakeLinBinning(125,.0,125*0.04), AliDielectronVarManager::kM, 
+                   "", AliDielectronVarManager::kOneOverPairEff);
   }
 
-  //// define the grid size and granularity /////
-  // event variables //
-  //  hf->AddCutVariable(AliDielectronVarManager::kCentrality, AliDielectronHelper::MakeArbitraryBinning("0,10,50,90")); // flow only
-  if(hasMC) hf->AddCutVariable(AliDielectronVarManager::kCentrality,               18, 0., 90.);
-  else      hf->AddCutVariable(AliDielectronVarManager::kCentrality,               9, 0., 90.);
-  //  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kRunNumber, GetRunNumbers2011() );
-  //  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kNacc,        3000,0.,3000.);
-  //  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kNVtxContrib,   20,0.,4000.);
+
+  /*
+//// define the grid size and granularity /////
+// event variables //
+//  hf->AddCutVariable(AliDielectronVarManager::kCentrality, AliDielectronHelper::MakeArbitraryBinning("0,10,50,90")); // flow only
+if(hasMC) hf->AddCutVariable(AliDielectronVarManager::kCentrality,               18, 0., 90.);
+else      hf->AddCutVariable(AliDielectronVarManager::kCentrality,               9, 0., 90.);
+//  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kRunNumber, GetRunNumbers2011() );
+//  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kNacc,        3000,0.,3000.);
+//  if(hasMC)  hf->AddCutVariable(AliDielectronVarManager::kNVtxContrib,   20,0.,4000.);
 
   // pair variables //ATTENTION
   if(hasMC && 0) hf->AddCutVariable(AliDielectronVarManager::kY,  18, -0.9,  0.9);
@@ -946,29 +1255,63 @@ void InitCF(AliDielectron* die, Int_t cutDefinition)
   //
   // Setup the CF Manager if needed
   //
+  // do not fill
+  switch(cutDefinition) {
+  case kEvent:
+  case kPIDqa:
+  case kLegEff:
+  case kNoPID:
+    return;
+  }
+
+  // has mc
   Bool_t hasMC=die->GetHasMC();
 
+  // mixing
+  AliDielectronMixingHandler *mixH=die->GetMixingHandler();
+  Int_t maxMixBins = (mixH ? mixH->GetNumberOfBins() : 0);
+
+  // container
   AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
 
   //event variables
+  //cf->AddVariable(AliDielectronVarManager::kCentrality,"0.,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,50.0");
   cf->AddVariable(AliDielectronVarManager::kCentrality,"0.,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,50.0,60.0,70.0,80.,90.");
-  cf->AddVariable(AliDielectronVarManager::kRunNumber, GetRunNumbers2011() );
+  //  cf->AddVariable(AliDielectronVarManager::kRunNumber, GetRunNumbers2011() );
+  if(mixH)  cf->AddVariable(AliDielectronVarManager::kMixingBin, AliDielectronHelper::MakeLinBinning(maxMixBins,0,maxMixBins));
 
   //pair variables
-  cf->AddVariable(AliDielectronVarManager::kPt,100,0.0,100*0.2);
-  
+  TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 21,  0.0,    10.5);
+  (*vpt)[21] = 100.;
+  cf->AddVariable(AliDielectronVarManager::kPt, vpt);
+  // TVectorD *vpt = AliDielectronHelper::MakeLinBinning( 41,  0.0,    10.25);
+  // (*vpt)[41] = 100.;
+  //  cf->AddVariable(AliDielectronVarManager::kPt,vpt);
+  //  cf->AddVariable(AliDielectronVarManager::kPt,80,0.0,100*0.25);
+
   //  cf->AddVariable(AliDielectronVarManager::kY,"-5,-1,-0.9,-0.8,-0.5,0.5,0.8,0.9,1.0,5");
-  cf->AddVariable(AliDielectronVarManager::kY,36,-0.9,+0.9);
+  cf->AddVariable(AliDielectronVarManager::kY,"-0.9,-0.8,-0.7,+0.7,+0.8,+0.9");
+  //  cf->AddVariable(AliDielectronVarManager::kY,18,-0.9,+0.9);
   cf->AddVariable(AliDielectronVarManager::kM,125,0.,125*.04); //40Mev Steps
-  cf->AddVariable(AliDielectronVarManager::kPairType,1,1,1);
+  //  cf->AddVariable(AliDielectronVarManager::kPairType,1,1,1);
+  cf->AddVariable(AliDielectronVarManager::kPairType,11,0,11);
   //  cf->AddVariable(AliDielectronVarManager::kThetaCS,20,-1.,+1.);
   //  cf->AddVariable(AliDielectronVarManager::kThetaHE,20,-1.,+1.);
   //  cf->AddVariable(AliDielectronVarManager::kPhiCS,20,-3.2,+3.2);
   //  cf->AddVariable(AliDielectronVarManager::kPhiHE,20,-3.2,+3.2);
+  cf->AddVariable(AliDielectronVarManager::kDeltaPhiTPCrpH2,GetDeltaPhiBins());
   //leg variables
-  cf->AddVariable(AliDielectronVarManager::kPt,"0.0, 0.75, 0.80, 0.85, 1.0, 1.1, 100.0",kTRUE);
-  //  cf->AddVariable(AliDielectronVarManager::kNclsTPC,"0, 70, 80, 90, 100, 120, 160",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kEta,"-0.9,-0.85,-0.8,-0.75,-0.70,0.70,0.75,0.8,0.85,0.9",kTRUE);
+  if(cutDefinition!=kSysMCele && 0) { //ATTENTION
+    cf->AddVariable(AliDielectronVarManager::kPt,"0.85, 1.1, 100.0",kTRUE);
+    //  cf->AddVariable(AliDielectronVarManager::kNclsTPC,"0, 70, 80, 90, 100, 120, 160",kTRUE);
+    cf->AddVariable(AliDielectronVarManager::kEta,"-0.9,-0.85,-0.8,-0.75,-0.70,0.70,0.75,0.8,0.85,0.9",kTRUE);
+    cf->AddVariable(AliDielectronVarManager::kITSLayerFirstCls,3,-1.5,1.5,kTRUE);
+    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPro,"3.5,4.0,4.5,100",kTRUE);
+    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,"-1.5,-1.0,-0.6,3.0",kTRUE);
+  }
+  else if(0){
+    cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,"-3.0,-1.5,-1.0,-0.6,3.0",kTRUE);
+  }
   /*
   // event variables
   cf->AddVariable(AliDielectronVarManager::kCentrality,               18,0.,  90.);
@@ -1005,15 +1348,16 @@ void InitCF(AliDielectron* die, Int_t cutDefinition)
   */
   // mc steps
   if(hasMC) {
-    //if(cutDefinition==kRec) 
     cf->SetStepForMCtruth();
     //    cf->SetStepForNoCutsMCmotherPid();
     //    cf->SetStepForAfterAllCuts();
     //    cf->SetStepsForEachCut();
     //    cf->SetStepsForSignal();
-    //    cf->SetStepsForBackground(); 
-    cf->SetStepsForMCtruthOnly();
+    //    cf->SetStepsForBackground();
+    //cf->SetStepsForMCtruthOnly();
   }
+  else
+    cf->SetStepsForSignal();
 
   die->SetCFManagerPair(cf);
 }
@@ -1099,9 +1443,49 @@ void AddMCSignals(AliDielectron *die, Int_t cutDefinition){
   electrons->SetLegPDGs(11,1);  //dummy second leg (never MCtrue)
   electrons->SetCheckBothChargesLegs(kTRUE,kTRUE);
   electrons->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  //  electrons->SetGrandMotherPDGs(500,500,kTRUE,kTRUE); // exclude non-prompt jpsi eletrons
   electrons->SetFillPureMCStep(kTRUE);
   //  electrons->SetMothersRelation(AliDielectronSignalMC::kSame);
 
+  AliDielectronSignalMC* directElec = new AliDielectronSignalMC("directElec","directElec");
+  directElec->SetLegPDGs(11,11);  //dummy second leg (never MCtrue)
+  directElec->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  directElec->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  //  directElec->SetGrandMotherPDGs(-1103,-1103);
+  directElec->SetFillPureMCStep(kTRUE);
+  directElec->SetMothersRelation(AliDielectronSignalMC::kSame);
+  directElec->SetMotherSources(AliDielectronSignalMC::kDirect, AliDielectronSignalMC::kDirect);
+
+
+  AliDielectronSignalMC* elecPrim = new AliDielectronSignalMC("elecPrim","elecPrim");
+  elecPrim->SetLegPDGs(11,1);  //dummy second leg (never MCtrue)
+  elecPrim->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  elecPrim->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  elecPrim->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  elecPrim->SetMotherPDGs(902,902,kTRUE,kTRUE); // exclude non-prompt jpsi eletrons
+  elecPrim->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
+  elecPrim->SetGrandMotherPDGs(902,902,kTRUE,kTRUE); // exclude non-prompt jpsi eletrons
+  elecPrim->SetFillPureMCStep(kTRUE);
+
+  // add direct di lepton resonances
+  /*
+  AliDielectronSignalMC* directP[7];
+  TParticlePDG *ap;
+  Int_t pdg[] = {111, 113, 221, 223, 331, 333, 443};
+  for(Int_t i=0; i<7; i++) {
+    ap = TDatabasePDG::Instance()->GetParticle(pdg[i]);
+    directP[i] = new AliDielectronSignalMC(Form("direct%s",ap->GetName()),Form("direct%s",ap->GetName()));
+    directP[i]->SetLegPDGs(11,-11);
+    directP[i]->SetMotherPDGs(pdg[i],pdg[i]);
+    directP[i]->SetMothersRelation(AliDielectronSignalMC::kSame);
+    directP[i]->SetFillPureMCStep(kTRUE);
+    directP[i]->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+    directP[i]->SetMotherSources(AliDielectronSignalMC::kDirect, AliDielectronSignalMC::kDirect);
+    // directP[i]->SetCheckBothChargesLegs(kTRUE,kTRUE);
+    // directP[i]->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  }
+  */
+
   /*
   AliDielectronSignalMC* eleHijing = new AliDielectronSignalMC("eleHijing","eleHijing");
   eleHijing->SetLegPDGs(11,1);  //dummy second leg (never MCtrue)
@@ -1121,6 +1505,9 @@ void AddMCSignals(AliDielectron *die, Int_t cutDefinition){
 
   // selection
   switch(cutDefinition) {
+  case kPIDqa:
+    die->AddSignalMC(directElec);
+    break;
   case kRec:
     die->AddSignalMC(inclusiveJpsi);
     die->AddSignalMC(directJpsi);
@@ -1135,11 +1522,16 @@ void AddMCSignals(AliDielectron *die, Int_t cutDefinition){
     //  die->AddSignalMC(gammaConversion);
     break;
   case kLegEff:
+    // die->AddSignalMC(directJpsi);
+    // die->AddSignalMC(inclusiveJpsi);
+    // die->AddSignalMC(electrons);
+    // die->AddSignalMC(elecPrim);
+    die->AddSignalMC(directElec);
+    //for(Int_t i=0; i<7; i++) die->AddSignalMC(directP[i]);
+    break;
+  default:
     die->AddSignalMC(directJpsi);
-    die->AddSignalMC(inclusiveJpsi);
-    die->AddSignalMC(electrons);
     break;
-  default:         return;
   }
 
 
@@ -1212,6 +1604,31 @@ TVectorD *GetRunNumbers2011() {
   return vec;
 }
 
+TVectorD *GetPDGcodes() {
+  //
+  // array of pdgcodes stored in TDatabasePDG
+  //
+  TDatabasePDG *pdg = new TDatabasePDG();
+  pdg->ReadPDGTable();
+  TGraph *gr = new TGraph();
+  TIter next(pdg->ParticleList());
+  TParticlePDG *p;
+  Int_t i=0;
+  while ((p = (TParticlePDG *)next())) {
+    if(TMath::Abs(p->PdgCode()) < 1e+6) {
+      //      printf("%s -> %d \n",p->GetName(),p->PdgCode());
+      gr->SetPoint(i++, p->PdgCode(),1.);
+    }
+  }
+  gr->Sort();
+  TVectorD *vec = new TVectorD(gr->GetN(), gr->GetX());
+  //  vec->Print();
+  delete pdg;
+  delete gr;
+  return vec;
+
+}
+
 TVectorD *GetDeltaPhiBins() {
   //
   // for in and out of event plane bins
index 554964074c73b4faed19e6577b64b40cb1a5fe56..965ec59a938d64d18cd0a56e9f99c97f8c357cc1 100644 (file)
@@ -1,6 +1,6 @@
 void SetupTrackCutsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD);
 void SetupPairCutsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD);
-void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD);
+void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD,const char* triggerName);
 void InitCFDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD);
 void AddMCSignals(AliDielectron *diele);
 AliESDtrackCuts *SetupESDtrackCutsDieleData(Int_t cutDefinition);
@@ -11,7 +11,7 @@ Bool_t hasMC=kFALSE;
 TString list  = gSystem->Getenv("LIST");
 const Int_t nDie=arrNamesDieleData->GetEntries();
 
-AliDielectron* ConfigJpsi_mf_PbPb(Int_t cutDefinition, Bool_t isAOD=kFALSE)
+AliDielectron* ConfigJpsi_mf_PbPb(Int_t cutDefinition, Bool_t isAOD=kFALSE,const char* triggerName)
 {
   //
   // Setup the instance of AliDielectron
@@ -183,11 +183,16 @@ AliESDtrackCuts *SetupESDtrackCutsDieleData(Int_t cutDefinition)
 
 
 //______________________________________________________________________________________
-void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD)
+void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD,const char* triggerName)
 {
   //
   // Initialise the histograms
   //
+  TString uniname;
+  if(cutDefinition==0)      uniname="TPC";
+  else if(cutDefinition==1) uniname="EMC";
+  else                                     uniname="Cuts";
+  
   
   //Setup histogram Manager
   AliDielectronHistos *histos=new AliDielectronHistos(diele->GetName(),diele->GetTitle());
@@ -223,76 +228,72 @@ void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t i
   //add histograms to event class
   if (cutDefinition==0) {
     histos->AddClass("Event");
-    histos->UserHistogram("Event","VtxZ","Vertex Z;Z[cm]",300,-15.,15.,AliDielectronVarManager::kZvPrim);
-    histos->UserHistogram("Event","Centrality","Centrality;Cent(%)",100,0.,100.,AliDielectronVarManager::kCentrality);
-    histos->UserHistogram("Event","Multiplicity","Multiplicity V0;Multiplicity V0",500,0.,25000.,AliDielectronVarManager::kMultV0);
-    histos->UserHistogram("Event","Multiplicity_cent","Multiplicity V0 x Cent;Cent(%);Multiplicity V0",10,0,100.,500,0.,25000.,AliDielectronVarManager::kCentrality,AliDielectronVarManager::kMultV0);
+    histos->UserHistogram("Event",Form("VtxZ_%s",triggerName),"Vertex Z;Z[cm]",300,-15.,15.,AliDielectronVarManager::kZvPrim);
+    histos->UserHistogram("Event",Form("Centrality_%s",triggerName),"Centrality;Cent(%)",100,0.,100.,AliDielectronVarManager::kCentrality);
+    histos->UserHistogram("Event",Form("Multiplicity_%s",triggerName),"Multiplicity V0;Multiplicity V0",500,0.,25000.,AliDielectronVarManager::kMultV0);
+    histos->UserHistogram("Event",Form("Multiplicity_cent_%s",triggerName),"Multiplicity V0 x Cent;Cent(%);Multiplicity V0",10,0,100.,500,0.,25000.,AliDielectronVarManager::kCentrality,AliDielectronVarManager::kMultV0);
   }
   
    //add histograms to Track classes
-  histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",100,0,20.,AliDielectronVarManager::kPt);
-  histos->UserHistogram("Track","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",160,-0.5,159.5,AliDielectronVarManager::kNclsTPC);
-  
-  histos->UserHistogram("Track","dXY","dXY;dXY [cm];#tracks",200,-1.,1.,AliDielectronVarManager::kImpactParXY);
-  histos->UserHistogram("Track","dZ","dZ;dZ [cm];#tracks",200,-3.,3.,AliDielectronVarManager::kImpactParZ);
-  histos->UserHistogram("Track","Eta_Phi","Eta Phi Map; Eta; Phi;#tracks",
+       histos->UserHistogram("Track",Form("Pt_%s_%s",uniname.Data(),triggerName),"Pt;Pt [GeV];#tracks",100,0,20.,AliDielectronVarManager::kPt);
+       histos->UserHistogram("Track",Form("TPCnCls_%s_%s",uniname.Data(),triggerName),"Number of Clusters TPC;TPC number clusteres;#tracks",160,-0.5,159.5,AliDielectronVarManager::kNclsTPC);
+       histos->UserHistogram("Track",Form("dXY_%s_%s",uniname.Data(),triggerName),"dXY;dXY [cm];#tracks",200,-1.,1.,AliDielectronVarManager::kImpactParXY);
+       histos->UserHistogram("Track",Form("dZ_%s_%s",uniname.Data(),triggerName),"dZ;dZ [cm];#tracks",200,-3.,3.,AliDielectronVarManager::kImpactParZ);
+       histos->UserHistogram("Track",Form("Eta_Phi_%s_%s",uniname.Data(),triggerName),"Eta Phi Map; Eta; Phi;#tracks",
                         100,-1,1,144,0,6.285,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
+       histos->UserHistogram("Track",Form("dEdx_P_%s_%s",uniname.Data(),triggerName),"dEdx_P;P [GeV];TPC signal (arb units);#tracks",
+                        200,0.2,20.,800,20.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal);
 
-  histos->UserHistogram("Track","dEdx_P","dEdx;P [GeV];TPC signal (arb units);#tracks",
-                        200,0.2,20.,800,20.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
-
-  histos->UserHistogram("Track","dEdx_Pt","dEdx;Pt [GeV];TPC signal (arb units);#tracks",
-                        200,0.2,20.,800,20.,200.,AliDielectronVarManager::kPt,AliDielectronVarManager::kTPCsignal,kTRUE);
+       histos->UserHistogram("Track",Form("dEdx_Pt_%s_%s",uniname.Data(),triggerName),"dEdx;Pt [GeV];TPC signal (arb units);#tracks",
+                        200,0.2,20.,800,20.,200.,AliDielectronVarManager::kPt,AliDielectronVarManager::kTPCsignal);
 
-  histos->UserHistogram("Track","TPCnSigmaPion_P","TPCnSigmaPion;P [GeV];TPCnSigmaEle;#tracks",
-                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
+        histos->UserHistogram("Track",Form("TPCnSigmaPion_P_%s_%s",uniname.Data(),triggerName),"TPCnSigmaPion;P [GeV];TPCnSigmaEle;#tracks",
+                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio);
   
-  histos->UserHistogram("Track","TPCnSigmaEle_P","TPCnSigmaEle;P [GeV];TPCnSigmaEle;#tracks",
-                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+       histos->UserHistogram("Track",Form("TPCnSigmaEle_P_%s_%s",uniname.Data(),triggerName),"TPCnSigmaEle;P [GeV];TPCnSigmaEle;#tracks",
+                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle);
   
-  histos->UserHistogram("Track","TPCnSigmaEle_Pt","TPCnSigmaEle;Pt [GeV];TPCnSigmaEle;#tracks",
-                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPt,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+       histos->UserHistogram("Track",Form("TPCnSigmaEle_Pt_%s_%s",uniname.Data(),triggerName),"TPCnSigmaEle;Pt [GeV];TPCnSigmaEle;#tracks",
+                        200,0.2,20.,800,-12.,12.,AliDielectronVarManager::kPt,AliDielectronVarManager::kTPCnSigmaEle);
 
-  histos->UserHistogram("Track","TPCnSigmaEle_Phi","TPCnSigmaEle;#phi [rad];TPCnSigmaEle;#tracks",
-                        200,0.,2*TMath::Pi(),800,-12.,12.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
-  
-  histos->UserHistogram("Track","TPCnSigmaEle_Eta","TPCnSigmaEle;#eta;TPCnSigmaEle;#tracks",
-                        200,-1.,1.,800,-12.,12.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
     
+    histos->UserHistogram("Track",Form("TPCnSigmaEle_Eta_%s_%s",uniname.Data(),triggerName),"TPCnSigmaEle;#eta;TPCnSigmaEle;#tracks",
+                        200,-1.,1.,800,-12.,12.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCnSigmaEle);
 
+  
+    histos->UserHistogram("Track",Form("TPCnSigmaEle_Phi_%s_%s",uniname.Data(),triggerName),"TPCnSigmaEle;#phi [rad];TPCnSigmaEle;#tracks",
+                        AliDielectronHelper::MakeLinBinning(200,0.,2*TMath::Pi()),AliDielectronHelper::MakeLinBinning(800,20.,200.),AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCnSigmaEle);
+  
 
-  histos->UserHistogram("Track","dEdx_Phi","dEdx;#phi [rad];TPC signal (arb units);#tracks",
-                        200,0.,2*TMath::Pi(),800,20.,200.,AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCsignal,kTRUE);
-
-  histos->UserHistogram("Track","dEdx_Eta","dEdx;#eta;TPC signal (arb units);#tracks",
-                        200,-1.,1.,800,20.,200.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCsignal,kTRUE);
-
+    histos->UserHistogram("Track",Form("dEdx_Phi_%s_%s",uniname.Data(),triggerName),"dEdx;#phi [rad];TPC signal (arb units);#tracks",
+                        AliDielectronHelper::MakeLinBinning(200,0.,2*TMath::Pi()),AliDielectronHelper::MakeLinBinning(800,20.,200.),AliDielectronVarManager::kPhi,AliDielectronVarManager::kTPCsignal);
 
+    histos->UserHistogram("Track",Form("dEdx_Eta_%s_%s",uniname.Data(),triggerName),"dEdx;#eta;TPC signal (arb units);#tracks",
+                        200,-1.,1.,800,20.,200.,AliDielectronVarManager::kEta,AliDielectronVarManager::kTPCsignal);
 
-  histos->UserHistogram("Track","dEdx_nSigmaEMCal","dEdx;NsigmaEmcal;TPC signal (arb units);NSigmaEMCAL",
-                        200,-5.,5.,800,20.,200.,AliDielectronVarManager::kEMCALnSigmaEle,AliDielectronVarManager::kTPCsignal,kTRUE);
+    histos->UserHistogram("Track",Form("dEdx_nSigmaEMCal_%s_%s",uniname.Data(),triggerName),"dEdx;NsigmaEmcal;TPC signal (arb units);NSigmaEMCAL",
+                        200,-5.,5.,800,20.,200.,AliDielectronVarManager::kEMCALnSigmaEle,AliDielectronVarManager::kTPCsignal);
 
-  histos->UserHistogram("Track","dEdx_TPCnSigmaEle","dEdx;TPC signal (arbunits);TPC number of sigmas Electrons;TPC signal (a.u.);#tracks",
-                        100,-10.,10.,800,20.,200.,AliDielectronVarManager::kTPCnSigmaEle,AliDielectronVarManager::kTPCsignal,kTRUE);
+    histos->UserHistogram("Track",Form("dEdx_TPCnSigmaEle_%s_%s",uniname.Data(),triggerName),"dEdx;TPC signal (arbunits);TPC number of sigmas Electrons;TPC signal (a.u.);#tracks",
+                        100,-10.,10.,800,20.,200.,AliDielectronVarManager::kTPCnSigmaEle,AliDielectronVarManager::kTPCsignal);
 
-  histos->UserHistogram("Track","dEdx_EoverP","dEdx;EoverP;TPC signal (arbunits);E/P",100,0.,5.,800,20.,200.,AliDielectronVarManager::kEMCALEoverP,AliDielectronVarManager::kTPCsignal,kTRUE);
+    histos->UserHistogram("Track",Form("dEdx_EoverP_%s_%s",uniname.Data(),triggerName),"dEdx;EoverP;TPC signal (arbunits);E/P",100,0.,5.,800,20.,200.,AliDielectronVarManager::kEMCALEoverP,AliDielectronVarManager::kTPCsignal);
   
-  histos->UserHistogram("Track","nSigmaEMCal_EoverP","NsigmaEmcal;EoverP;NSigmaEMCAL;E/P",100,0.,5.,200,-5.,5.,AliDielectronVarManager::kEMCALEoverP,AliDielectronVarManager::kEMCALnSigmaEle,kTRUE);
+    histos->UserHistogram("Track",Form("nSigmaEMCal_EoverP_%s_%s",uniname.Data(),triggerName),"NsigmaEmcal;EoverP;NSigmaEMCAL;E/P",100,0.,5.,200,-5.,5.,AliDielectronVarManager::kEMCALEoverP,AliDielectronVarManager::kEMCALnSigmaEle);
  
-  histos->UserHistogram("Track","EMCal_E","EmcalE;Cluster Energy [GeV];#Clusters",200,0.,40.,AliDielectronVarManager::kEMCALE,kTRUE);
+       histos->UserHistogram("Track",Form("EMCal_E_%s_%s",uniname.Data(),triggerName),"EmcalE;Cluster Energy [GeV];#Clusters",200,0.,40.,AliDielectronVarManager::kEMCALE);
 
-  histos->UserHistogram("Track","EMCal_E_nCells","EmcalE_nCells;# cells;Cluster Energy [GeV]",200,0.,40.,AliDielectronVarManager::kEMCALNCells,AliDielectronVarManager::kEMCALE,kTRUE);
+       histos->UserHistogram("Track",Form("EMCal_E_nCells_%s_%s",uniname.Data(),triggerName),"EmcalE_nCells;# cells;Cluster Energy [GeV]",20,0,20,200,0.,40.,AliDielectronVarManager::kEMCALNCells,AliDielectronVarManager::kEMCALE);  
+       histos->UserHistogram("Track",Form("ITS_FirstCls_%s_%s",uniname.Data(),triggerName),"ITS First Layer;ITS First Layer;#Entries",AliDielectronHelper::MakeLinBinning(6,0.,6.),AliDielectronVarManager::kITSLayerFirstCls);
   
-  histos->UserHistogram("Track","ITS_FirstCls","ITS First Layer;ITS First Layer;#Entries",6,0.,6.,AliDielectronVarManager::kITSLayerFirstCls,kTRUE);
-
   //add histograms to Pair classes
-  histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs",
+  histos->UserHistogram("Pair",Form("InvMass_%s_%s",uniname.Data(),triggerName),"Inv.Mass;Inv. Mass [GeV];#pairs",
                         251,-.01,5.01,AliDielectronVarManager::kM);
-  histos->UserHistogram("Pair","InvMass2D","Inv.Mass;Pt [GeV]; Inv. Mass [GeV]",
+  histos->UserHistogram("Pair",Form("InvMass2D_%s_%s",uniname.Data(),triggerName),"Inv.Mass;Pt [GeV]; Inv. Mass [GeV]",
                         20,0.,20.,251,-.01,5.01,AliDielectronVarManager::kPt,AliDielectronVarManager::kM);
-  histos->UserHistogram("Pair","Rapidity","Rapidity;Rapidity;#pairs",
+  histos->UserHistogram("Pair",Form("Rapidity_%s_%s",uniname.Data(),triggerName),"Rapidity;Rapidity;#pairs",
                         100,-1.,1.,AliDielectronVarManager::kY);
-  histos->UserHistogram("Pair","OpeningAngle","Opening angle;angle",
+  histos->UserHistogram("Pair",Form("OpeningAngle_%s_%s",uniname.Data(),triggerName),"Opening angle;angle",
                         100,0.,3.15,AliDielectronVarManager::kOpeningAngle);
   
   diele->SetHistogramManager(histos);
@@ -317,13 +318,13 @@ void InitCFDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD)
 //   cf->AddVariable(AliDielectronVarManager::kP,"0.0, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 10.0, 100.0",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kNclsTPC,"80, 85, 90, 95, 100, 110, 120, 160",kTRUE);
 //   cf->AddVariable(AliDielectronVarManager::kEta,"-5.0,-1.0,-0.9,-0.7,0.7,0.9,1.0,5.0",kTRUE);
-//   cf->AddVariable(AliDielectronVarManager::kPhi,"0.0,1.0,2.0,3.0,4.0,5.0,6.0",kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kPhi,"0.0,1.0,2.0,3.0,4.0,5.0,6.0",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kEMCALE,"1.0,2.0, 3.0, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0,11.0,12.0,16.0,100.0",kTRUE); 
   cf->AddVariable(AliDielectronVarManager::kEMCALnSigmaEle,"-3.5,-3.0,-2.0,-1.0,1.0,2.0,3.0,4.0,5.0",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kEMCALNCells,25,0,25,kTRUE);
   cf->AddVariable(AliDielectronVarManager::kEMCALEoverP,"0.6, 0.65,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.8,2.0,2.1",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,"-3.5,-3.0,-2.5,-2.0,-1.5,-1.0,0.0,1.0,2.0,3.0,3.5,4.0",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPio,"2.,2.5,3.0,3.5,4.0,4.5,100",kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPio,"2.,2.5,3.0,3.5,4.0,4.5,5.0,5.5,100",kTRUE);
   //event variables
   cf->AddVariable(AliDielectronVarManager::kCentrality,20,0.,100.);
   cf->AddVariable(AliDielectronVarManager::kMultV0,26,0.,26000.);
index 0100ad17f2f7d7349c14a76c895a6e79ac699d8e..62c341065753a8bd137f325b4c1a452822cb97f1 100644 (file)
@@ -49,4 +49,4 @@ set ( DHDR  PWGGAEMCALTasksLinkDef.h)
 
 string ( REPLACE ".cxx" ".h" EXPORT "${SRCS}" )
 
-set ( EINCLUDE PWGGA/PWGGAUtils PWGGA/EMCALTasks PWGGA/PHOSTasks/PHOS_PbPb PWG/EMCAL EMCAL OADB STEER/STEER STEER/AOD STEER/ESD STEER/STEERBase ANALYSIS)
+set ( EINCLUDE PWGGA/PWGGAUtils PWGGA/EMCALTasks PWGGA/PHOSTasks/PHOS_PbPb PWG/EMCAL EMCAL OADB STEER/STEER STEER/AOD STEER/ESD STEER/STEERBase ANALYSIS ANALYSIS/ESDfilter)
index 54978278efea38418796e167483344cca3d63cca..7850b824430af90dc8ad1299769fb684a87fe10b 100644 (file)
@@ -678,7 +678,7 @@ void AliAnalysisTaskCaloFilter::FillAODHeader()
   header->SetZDCP2Energy(fEvent->GetZDCP2Energy());
   header->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0),fEvent->GetZDCEMEnergy(1));
   
-  Float_t diamxy[2]={fEvent->GetDiamondX(),fEvent->GetDiamondY()};
+  Float_t diamxy[2]={(Float_t)fEvent->GetDiamondX(),(Float_t)fEvent->GetDiamondY()};
   Float_t diamcov[3];
   fEvent->GetDiamondCovXY(diamcov);
   header->SetDiamond(diamxy,diamcov);
index ff53ab98e70acd15c72c2598229f789b6e103d2a..9dd0d60c4dc6de89e38fdc33e4ae7e82abb6e26a 100755 (executable)
@@ -302,7 +302,7 @@ void AliAnaCalorimeterQA::CalculateAverageTime(AliVCluster *clus,
   // First recalculate energy in case non linearity was applied
   Float_t  energy = 0;
   Float_t  ampMax = 0, amp = 0;
-  Int_t    absIdMax =-1;
+//  Int_t    absIdMax =-1;
   for (Int_t ipos = 0; ipos < clus->GetNCells(); ipos++) 
   {
     Int_t id       = clus->GetCellsAbsId()[ipos];
@@ -316,7 +316,7 @@ void AliAnaCalorimeterQA::CalculateAverageTime(AliVCluster *clus,
     if(amp> ampMax) 
     {
       ampMax   = amp;
-      absIdMax = id;
+//      absIdMax = id;
     }
     
   } // energy loop       
@@ -1016,7 +1016,8 @@ Bool_t AliAnaCalorimeterQA::ClusterMCHistograms(TLorentzVector mom, Bool_t match
   
   Int_t pdg0  =-1;Int_t status = -1; Int_t iMother = -1; Int_t iParent = -1;
   Float_t vxMC= 0; Float_t vyMC = 0;   
-  Float_t eMC = 0; Float_t ptMC= 0; Float_t phiMC =0; Float_t etaMC = 0;
+  Float_t eMC = 0; //Float_t ptMC= 0;
+  Float_t phiMC =0; Float_t etaMC = 0;
   Int_t charge = 0;    
   
   //Check the origin.
@@ -1121,7 +1122,7 @@ Bool_t AliAnaCalorimeterQA::ClusterMCHistograms(TLorentzVector mom, Bool_t match
     }
     
     eMC    = primary->Energy();
-    ptMC   = primary->Pt();
+    //ptMC   = primary->Pt();
     phiMC  = primary->Phi();
     etaMC  = primary->Eta();
     pdg    = TMath::Abs(primary->GetPdgCode());
@@ -1226,7 +1227,7 @@ Bool_t AliAnaCalorimeterQA::ClusterMCHistograms(TLorentzVector mom, Bool_t match
     
     status = aodprimary->IsPrimary();
     eMC    = aodprimary->E();
-    ptMC   = aodprimary->Pt();
+    //ptMC   = aodprimary->Pt();
     phiMC  = aodprimary->Phi();
     etaMC  = aodprimary->Eta();
     pdg    = TMath::Abs(aodprimary->GetPdgCode());
index 96d731f8fbcd6ebf7df0b9856d34f317c53d7c01..6338f1822e91437a50c727a41a992502f3d3dc41 100755 (executable)
@@ -332,14 +332,10 @@ void  AliAnaElectron::FillShowerShapeHistograms(AliVCluster* cluster, Int_t mcTa
       
     }  // embedded fraction    
     
-    // Get the fraction of the cluster energy that carries the cell with highest energy
-    Int_t absID             =-1 ;
-    Float_t maxCellFraction = 0.;
-    Int_t index             = 0 ;
-    absID = GetCaloUtils()->GetMaxEnergyCell(cells, cluster,maxCellFraction);
-    
     // Check the origin and fill histograms
-    if( GetMCAnalysisUtils()->CheckTagBit(mcTag,AliMCAnalysisUtils::kMCPhoton) && 
+    Int_t index = -1;
+
+    if( GetMCAnalysisUtils()->CheckTagBit(mcTag,AliMCAnalysisUtils::kMCPhoton) &&
        !GetMCAnalysisUtils()->CheckTagBit(mcTag,AliMCAnalysisUtils::kMCConversion) &&
        !GetMCAnalysisUtils()->CheckTagBit(mcTag,AliMCAnalysisUtils::kMCPi0) &&
        !GetMCAnalysisUtils()->CheckTagBit(mcTag,AliMCAnalysisUtils::kMCEta))
@@ -376,7 +372,7 @@ void  AliAnaElectron::FillShowerShapeHistograms(AliVCluster* cluster, Int_t mcTa
           fhMCElectronELambda0NOverlap   ->Fill(energy, lambda0);
         }
         else {
-          printf("AliAnaElectron::FillShowerShapeHistogram() - n overlaps = %d!!", noverlaps);
+          printf("AliAnaElectron::FillShowerShapeHistogram() - n overlaps = %d for ancestor %d!!", noverlaps, ancLabel);
         }
       }//No embedding
       
@@ -427,11 +423,9 @@ void  AliAnaElectron::FillShowerShapeHistograms(AliVCluster* cluster, Int_t mcTa
       fhMCEDispPhi        [pidIndex][index]-> Fill(energy,dPhi);
       fhMCESumEtaPhi      [pidIndex][index]-> Fill(energy,sEtaPhi);
       fhMCEDispEtaPhiDiff [pidIndex][index]-> Fill(energy,dPhi-dEta);
-      if(dEta+dPhi>0)fhMCESphericity     [pidIndex][index]-> Fill(energy,(dPhi-dEta)/(dEta+dPhi));  
-      
+      if(dEta+dPhi>0)fhMCESphericity     [pidIndex][index]-> Fill(energy,(dPhi-dEta)/(dEta+dPhi));
     }
     
-    
   }//MC data
   
 }
@@ -1367,11 +1361,10 @@ void  AliAnaElectron::MakeAnalysisFillAOD()
                               aodpart.Pt(), aodpart.GetIdentifiedParticleType());
     
     //FIXME, this to MakeAnalysisFillHistograms ...
-    Int_t absID             = 0; 
     Float_t maxCellFraction = 0;
     
-    absID = GetCaloUtils()->GetMaxEnergyCell(cells, calo,maxCellFraction);
-    fhMaxCellDiffClusterE[pidIndex]->Fill(aodpart.E(),maxCellFraction);
+    Int_t absID = GetCaloUtils()->GetMaxEnergyCell(cells, calo,maxCellFraction);
+    if(absID>=0)fhMaxCellDiffClusterE[pidIndex]->Fill(aodpart.E(),maxCellFraction);
     fhNCellsE[pidIndex]            ->Fill(aodpart.E(),calo->GetNCells());
     fhNLME[pidIndex]               ->Fill(aodpart.E(),nMaxima);
     fhTimeE[pidIndex]              ->Fill(aodpart.E(),calo->GetTOF()*1.e9);
@@ -1474,7 +1467,7 @@ void  AliAnaElectron::MakeAnalysisFillHistograms()
       }
       
       Float_t eprim   = 0;
-      Float_t ptprim  = 0;
+      //Float_t ptprim  = 0;
       if(GetReader()->ReadStack()){
         
         if(label >=  stack->GetNtrack()) {
@@ -1489,7 +1482,7 @@ void  AliAnaElectron::MakeAnalysisFillHistograms()
         }
         
         eprim   = primary->Energy();
-        ptprim  = primary->Pt();               
+        //ptprim  = primary->Pt();
         
       }
       else if(GetReader()->ReadAODMCParticles()){
@@ -1512,7 +1505,7 @@ void  AliAnaElectron::MakeAnalysisFillHistograms()
         }
         
         eprim   = aodprimary->E();
-        ptprim  = aodprimary->Pt();
+        //ptprim  = aodprimary->Pt();
         
       }
       
index a5004c0b54617aa38ebe898a8e4bb9eca22f9471..415f81f117121170df242a5be439bbad424863ec 100755 (executable)
@@ -774,8 +774,8 @@ void  AliAnaPhotonConvInCalo::MakeAnalysisFillHistograms()
           continue;
         }
         
-        Float_t eprim   = 0;
-        Float_t ptprim  = 0;
+        //Float_t eprim   = 0;
+        //Float_t ptprim  = 0;
         if(GetReader()->ReadStack()){
           
           if(label >=  stack->GetNtrack()) {
@@ -788,8 +788,8 @@ void  AliAnaPhotonConvInCalo::MakeAnalysisFillHistograms()
             printf("AliAnaPhotonConvInCalo::MakeAnalysisFillHistograms() *** no primary ***:  label %d \n", label);
             continue;
           }
-          eprim   = primary->Energy();
-          ptprim  = primary->Pt();             
+          //eprim   = primary->Energy();
+          //ptprim  = primary->Pt();
           
         }
         else if(GetReader()->ReadAODMCParticles()){
@@ -811,8 +811,8 @@ void  AliAnaPhotonConvInCalo::MakeAnalysisFillHistograms()
             continue;
           }
           
-          eprim   = aodprimary->E();
-          ptprim  = aodprimary->Pt();
+          //eprim   = aodprimary->E();
+          //ptprim  = aodprimary->Pt();
           
         }
         
index e3d3c409d0920ac09b8c183973ebbfa218f499d4..feb81764c282e684179d4a3c7b6279bcbc657490 100755 (executable)
@@ -1605,8 +1605,6 @@ void AliAnaPi0::FillArmenterosThetaStar(Int_t pdg,             TLorentzVector me
   if(en > 20)             ebin = 3;
   if(ebin < 0 || ebin > 3) return ;
   
-  Float_t asym = 0;
-  if(daugh1.E()+daugh2.E() > 0) asym = TMath::Abs(daugh1.E()-daugh2.E())/(daugh1.E()+daugh2.E());
   
   if(pdg==111)
   {
@@ -1619,10 +1617,15 @@ void AliAnaPi0::FillArmenterosThetaStar(Int_t pdg,             TLorentzVector me
     fhArmPrimEta[ebin]->Fill(alphaArm,pTArm);
   }
   
-  if(GetDebug() > 2 ) printf("AliAnaPi0::FillArmenterosThetaStar() - E %f, alphaArm %f, pTArm %f, cos(theta*) %f\n",en,alphaArm,pTArm,cosThStar);
-  
-}
+  if(GetDebug() > 2 )
+  {
+    Float_t asym = 0;
+    if(daugh1.E()+daugh2.E() > 0) asym = TMath::Abs(daugh1.E()-daugh2.E())/(daugh1.E()+daugh2.E());
 
+    printf("AliAnaPi0::FillArmenterosThetaStar() - E %f, alphaArm %f, pTArm %f, cos(theta*) %f, asymmetry %1.3f\n",
+         en,alphaArm,pTArm,cosThStar,asym);
+  }
+}
 
 //_______________________________________________________________________________________
 void AliAnaPi0::FillMCVersusRecDataHistograms(Int_t index1,  Int_t index2,
index 300c2a3f33b35f177a016c5a95b5e08d0205fdb4..196c6c83bbba197e43a3717673ded2930f6f6620 100755 (executable)
@@ -2959,15 +2959,6 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       noverlaps = GetMCAnalysisUtils()->GetNOverlaps(calo->GetLabels(), nlabels,tag,mesonLabel,GetReader(),overpdg);
     }
     
-    Int_t inlm = 2;
-    if     ( nMaxima == 1 ) inlm = 0;
-    else if( nMaxima == 2 ) inlm = 1;
-    else if( nMaxima < 1 )
-    {
-      Info("MakeShowerShapeIdentification","Wrong number of maxima %d\n",nMaxima);
-      return;
-    }
-    
     //mass of all clusters
     fhMass       ->Fill(mom.E() ,mass);
     fhMassPt     ->Fill(mom.Pt(),mass);
index 9cac8d23ccfff351e96e260f19b0f7d466182c2c..70a09b631d378b2eccd8430a5f03c538993c8d78 100644 (file)
@@ -795,6 +795,10 @@ void MCQA()
   TH1F* hPrimPi0Phi = (TH1F*) h2PrimPi0Phi->ProjectionY("PrimPi0Phi",binMin,1000);
   TH1F* hPrimEtaPhi = (TH1F*) h2PrimEtaPhi->ProjectionY("PrimEtaPhi",binMin,1000);
 
+  hPrimPhoPhi->Sumw2();
+  hPrimPi0Phi->Sumw2();
+  hPrimEtaPhi->Sumw2();
+
   hPrimPhoPhi->Scale(1./hPrimPhoPhi->Integral(0,1000));
   hPrimPi0Phi->Scale(1./hPrimPi0Phi->Integral(0,1000));
   hPrimEtaPhi->Scale(1./hPrimEtaPhi->Integral(0,1000));
@@ -814,20 +818,16 @@ void MCQA()
   hPrimPi0Phi->SetYTitle("1/total entries dN/d#phi");
   hPrimPi0Phi->SetTitle("Generated particles #phi for E > 3 GeV");
   hPrimPi0Phi->SetTitleOffset(1.6,"Y");
-  hPrimPi0Phi->Sumw2();
   hPrimPi0Phi->SetMarkerColor(4);
   hPrimPi0Phi->SetMarkerStyle(21);
   hPrimPi0Phi->Draw("");
   
-  hPrimPhoPhi->Sumw2();
   hPrimPhoPhi->SetMarkerColor(1);
   hPrimPhoPhi->SetMarkerStyle(20);
   Float_t scale = TMath::RadToDeg();
   ScaleXaxis(hPrimPhoPhi, TMath::RadToDeg());
   hPrimPhoPhi->Draw("same");
 
-
-  hPrimEtaPhi->Sumw2();
   hPrimEtaPhi->SetMarkerColor(2);
   hPrimEtaPhi->SetMarkerStyle(22);
   hPrimEtaPhi->Draw("same");
@@ -839,6 +839,10 @@ void MCQA()
   TH2F* h2PrimPi0Eta = (TH2F*) GetHisto("AnaPi0_hPrimPi0Rapidity");
   TH2F* h2PrimEtaEta = (TH2F*) GetHisto("AnaPi0_hPrimEtaRapidity");
   
+  hPrimPhoEta->Sumw2();
+  hPrimEtaEta->Sumw2();
+  hPrimPi0Eta->Sumw2();
+  
   Int_t binMin = hPrimPho->FindBin(3);
   
   TH1F* hPrimPhoEta = (TH1F*) h2PrimPhoEta->ProjectionY("PrimPhoEta",binMin,1000);
@@ -864,18 +868,15 @@ void MCQA()
   hPrimPi0Eta->SetYTitle("1/total entries dN/d#eta");
   hPrimPi0Eta->SetTitle("Generated particles #eta for E > 3 GeV");
   hPrimPi0Eta->SetTitleOffset(1.6,"Y");
-  hPrimPi0Eta->Sumw2();
   hPrimPi0Eta->SetMarkerColor(4);
   hPrimPi0Eta->SetMarkerStyle(21);
   hPrimPi0Eta->Draw("");
   
-  hPrimPhoEta->Sumw2();
   hPrimPhoEta->SetMarkerColor(1);
   hPrimPhoEta->SetMarkerStyle(20);
   Float_t scale = TMath::RadToDeg();
   hPrimPhoEta->Draw("same");
   
-  hPrimEtaEta->Sumw2();
   hPrimEtaEta->SetMarkerColor(2);
   hPrimEtaEta->SetMarkerStyle(22);
   hPrimEtaEta->Draw("same");
diff --git a/PWGGA/CaloTrackCorrelations/macros/QA/DrawProductionComparison.C b/PWGGA/CaloTrackCorrelations/macros/QA/DrawProductionComparison.C
new file mode 100644 (file)
index 0000000..cacb333
--- /dev/null
@@ -0,0 +1,765 @@
+///////////////////////////////////////////
+//
+// Macro to plot comparison of different
+// distributions (spectra, correlations)
+// produced in QA trains but different data
+// Based on the plots provided by DrawAnaCaloTrackQA.C
+//
+// To execute: root -q -b -l DrawProductionComparison.C'("Pi0IM_GammaTrackCorr_EMCAL_default","AnalysisResults.root")'
+// The input files must be placed in different directoried,
+// each one defined in the string array "prod"
+//     TString prod[] = {"AOD142","AOD115","ESD"};
+// that has to be modified inside the macro.
+// The number of productions has to be specified
+//     const Int_t nProd = 3;
+// There is no limitation to the amount of productions
+//
+// Author: Gustavo.Conesa.Balbastre@cern.ch
+//
+//
+
+// Some global variables
+const Int_t nProd = 3;
+TString prod[] = {"AOD142","AOD115","ESD"};
+
+TList *list[nProd];
+TFile *file[nProd];
+TString histoTag = "";
+Int_t color[]={kBlack,kRed,kBlue,kOrange+1,kYellow+1,kGreen+2,kCyan+1,kViolet,kMagenta+2,kGray};
+
+Float_t nEvents[nProd] = 0;
+
+//_______________________________________________________________________
+void DrawProductionComparison(TString listName = "Pi0IM_GammaTrackCorr_EMCAL_default",
+                              TString fileName = "AnalysisResults.root")
+{
+
+  printf("Open <%s>; Get List : <%s>\n",fileName.Data(),listName.Data());
+  
+  histoTag = listName;
+  
+  //Access the file and list of histograms, global variables
+  GetFileAndList(fileName, listName);
+  
+  gStyle->SetOptTitle(1);
+  gStyle->SetOptStat(0);
+  gStyle->SetOptFit(000000);
+  gStyle->SetPadRightMargin(0.15);
+  //gStyle->SetPadTopMargin(0.02);
+  //gStyle->SetPadLeftMargin(0.15);
+  gStyle->SetTitleFontSize(0.06);
+  
+  // Declare the different histograms, arrays input is production
+  TH1F* hRaw [nProd];
+  TH1F* hCorr[nProd];
+  TH1F* hTM  [nProd];
+  TH1F* hShSh[nProd];
+  
+  TH1F* hRatRaw [nProd-1];
+  TH1F* hRatCorr[nProd-1];
+  TH1F* hRatTM  [nProd-1];
+  TH1F* hRatShSh[nProd-1];
+
+  TH1F* hCen   [nProd];
+  TH1F* hRatCen[nProd-1];
+  
+  TH1F* hVertex[3][nProd];
+  TH1F* hRatVertex[3][nProd-1];
+
+  TH2F* h2TrackMatchResEtaNeg[nProd];
+  TH2F* h2TrackMatchResEtaPos[nProd];
+  TH2F* h2TrackMatchResPhiNeg[nProd];
+  TH2F* h2TrackMatchResPhiPos[nProd];
+  
+  TH1F* hTrackMatchResEtaNeg[nProd];
+  TH1F* hTrackMatchResEtaPos[nProd];
+  TH1F* hTrackMatchResPhiNeg[nProd];
+  TH1F* hTrackMatchResPhiPos[nProd];
+  
+  TH1F* hRatTrackMatchResEtaNeg[nProd-1];
+  TH1F* hRatTrackMatchResEtaPos[nProd-1];
+  TH1F* hRatTrackMatchResPhiNeg[nProd-1];
+  TH1F* hRatTrackMatchResPhiPos[nProd-1];
+
+  TH1F * hTrackPt[nProd] ;
+  TH1F * hTrackPtSPD[nProd] ;
+  TH1F * hTrackPtNoSPD[nProd] ;
+  TH1F * hRatTrackPt[nProd-1] ;
+  TH1F * hRatTrackPtSPD[nProd-1] ;
+  TH1F * hRatTrackPtNoSPD[nProd-1] ;
+  
+  TH2F * hTrackEtaPhi[nProd] ;
+  TH2F * hTrackEtaPhiSPD[nProd] ;
+  TH2F * hTrackEtaPhiNoSPD[nProd] ;
+  TH1F * hTrackPhi[nProd] ;
+  TH1F * hTrackPhiSPD[nProd] ;
+  TH1F * hTrackPhiNoSPD[nProd] ;
+  TH1F * hRatTrackPhi[nProd-1] ;
+  TH1F * hRatTrackPhiSPD[nProd-1] ;
+  TH1F * hRatTrackPhiNoSPD[nProd-1] ;
+  
+  TH2F* h2XE[nProd];
+  TH2F* h2XEUE[nProd];
+  TH1F* hXE[nProd];
+  TH1F* hXEUE[nProd];
+  TH1F* hRatXE[nProd-1];
+  TH1F* hRatXEUE[nProd-1];
+
+  
+  // Fill the histograms array for each of the productions, do the comparison ratios
+  for(Int_t iprod = 0; iprod <  nProd; iprod++)
+  {
+    // Calorimeter Clusters
+    {
+      hRaw [iprod] = (TH1F*) GetHisto("AnaPhoton_hCut_0_Open"    ,iprod);
+      hCorr[iprod] = (TH1F*) GetHisto("AnaPhoton_hCut_4_NCells"  ,iprod);
+      hTM  [iprod] = (TH1F*) GetHisto("AnaPhoton_hCut_7_Matching",iprod);
+      hShSh[iprod] = (TH1F*) GetHisto("AnaPhoton_hCut_9_PID"     ,iprod);
+
+      hRaw [iprod]->Sumw2();
+      hCorr[iprod]->Sumw2();
+      hTM  [iprod]->Sumw2();
+      hShSh[iprod]->Sumw2();
+      
+      hRaw [iprod]->Scale(1./nEvents[iprod]);
+      hCorr[iprod]->Scale(1./nEvents[iprod]);
+      hTM  [iprod]->Scale(1./nEvents[iprod]);
+      hShSh[iprod]->Scale(1./nEvents[iprod]);
+      
+      hRaw[iprod]->SetMarkerColor(color[iprod]);
+      hRaw[iprod]->SetMarkerStyle(24);
+      
+      hCorr[iprod]->SetTitle("Cluster spectra with/out cuts");
+      hCorr[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
+      hCorr[iprod]->SetTitleOffset(1.5,"Y");
+      hCorr[iprod]->SetMarkerColor(color[iprod]);
+      hCorr[iprod]->SetMarkerStyle(20);
+      hCorr[iprod]->SetAxisRange(0.,30.,"X");
+      //hCorr[iprod]->SetMaximum(1.1);
+      //hCorr[iprod]->SetMinimum(0);
+      
+      hTM  [iprod]->SetMarkerColor(color[iprod]);
+      hTM  [iprod]->SetMarkerStyle(21);
+      
+      hShSh[iprod]->SetMarkerColor(color[iprod]);
+      hShSh[iprod]->SetMarkerStyle(22);
+      
+      hRaw [iprod]->SetTitleOffset(1.5,"Y");
+      hTM  [iprod]->SetTitleOffset(1.5,"Y");
+      hShSh[iprod]->SetTitleOffset(1.5,"Y");
+      hCorr[iprod]->SetTitleOffset(1.5,"Y");
+      
+      if(iprod > 0)
+      {
+        hRatRaw [iprod-1] = (TH1F*)hRaw [iprod]->Clone(Form("hRatRaw%s" ,prod[iprod].Data()));
+        hRatCorr[iprod-1] = (TH1F*)hCorr[iprod]->Clone(Form("hRatCorr%s",prod[iprod].Data()));
+        hRatTM  [iprod-1] = (TH1F*)hTM  [iprod]->Clone(Form("hRatTM%s"  ,prod[iprod].Data()));
+        hRatShSh[iprod-1] = (TH1F*)hShSh[iprod]->Clone(Form("hRatShSh%s",prod[iprod].Data()));
+        
+        hRatRaw [iprod-1]->Divide(hRatRaw [iprod-1],hRaw [0],1.000,1,"B");
+        hRatCorr[iprod-1]->Divide(hRatCorr[iprod-1],hCorr[0],0.975,1,"B");
+        hRatTM  [iprod-1]->Divide(hRatTM  [iprod-1],hTM  [0],0.950,1,"B");
+        hRatShSh[iprod-1]->Divide(hRatShSh[iprod-1],hShSh[0],0.925,1,"B");
+      }
+    }
+    
+    // Cluster-Track Matching Residuals
+    {
+      h2TrackMatchResEtaNeg[iprod] = (TH2F*) GetHisto("QA_hTrackMatchedDEta"   ,iprod);
+      h2TrackMatchResEtaPos[iprod] = (TH2F*) GetHisto("QA_hTrackMatchedDEtaPos",iprod);
+      h2TrackMatchResPhiNeg[iprod] = (TH2F*) GetHisto("QA_hTrackMatchedDPhi"   ,iprod);
+      h2TrackMatchResPhiPos[iprod] = (TH2F*) GetHisto("QA_hTrackMatchedDPhiPos",iprod);
+      
+      h2TrackMatchResEtaNeg[iprod]->Add(h2TrackMatchResEtaPos[iprod],-1);
+      h2TrackMatchResPhiNeg[iprod]->Add(h2TrackMatchResPhiPos[iprod],-1);
+      
+      Float_t binMin = hCorr[iprod]->FindBin(0.5);
+      Float_t binMax = hCorr[iprod]->FindBin(2);
+      hTrackMatchResEtaNeg[iprod] = (TH1F*) h2TrackMatchResEtaNeg[iprod]->ProjectionY(Form("TMProjEtaNeg%s",prod[iprod].Data()),binMin, binMax);
+      hTrackMatchResEtaPos[iprod] = (TH1F*) h2TrackMatchResEtaPos[iprod]->ProjectionY(Form("TMProjEtaPos%s",prod[iprod].Data()),binMin, binMax);
+      hTrackMatchResPhiNeg[iprod] = (TH1F*) h2TrackMatchResPhiNeg[iprod]->ProjectionY(Form("TMProjPhiNeg%s",prod[iprod].Data()),binMin, binMax);
+      hTrackMatchResPhiPos[iprod] = (TH1F*) h2TrackMatchResPhiPos[iprod]->ProjectionY(Form("TMProjPhiPos%s",prod[iprod].Data()),binMin, binMax);
+      
+      hTrackMatchResEtaNeg[iprod]->SetXTitle("#Delta #eta");
+      hTrackMatchResEtaNeg[iprod]->SetYTitle("entries / N events");
+      hTrackMatchResEtaNeg[iprod]->SetTitle("Track-cluster #eta residuals, 0.5 < E < 2 GeV");
+      hTrackMatchResEtaNeg[iprod]->SetAxisRange(-0.05,0.05,"X");
+      hTrackMatchResEtaNeg[iprod]->Sumw2();
+      hTrackMatchResEtaNeg[iprod]->SetMarkerStyle(24);
+      hTrackMatchResEtaNeg[iprod]->SetMarkerColor(color[iprod]);
+      
+      hTrackMatchResEtaPos[iprod]->Sumw2();
+      hTrackMatchResEtaPos[iprod]->SetAxisRange(-0.05,0.05,"X");
+      hTrackMatchResEtaPos[iprod]->SetMarkerStyle(25);
+      hTrackMatchResEtaPos[iprod]->SetMarkerColor(color[iprod]);
+      
+      hTrackMatchResPhiNeg[iprod]->SetXTitle("#Delta #phi");
+      hTrackMatchResPhiNeg[iprod]->SetTitle("Track-cluster #phi residuals, 0.5 < E < 2 GeV");
+      hTrackMatchResPhiNeg[iprod]->SetYTitle("entries / N events");
+      hTrackMatchResPhiNeg[iprod]->SetAxisRange(-0.05,0.05,"X");
+      hTrackMatchResPhiNeg[iprod]->Sumw2();
+      hTrackMatchResPhiNeg[iprod]->SetMarkerStyle(24);
+      hTrackMatchResPhiNeg[iprod]->SetMarkerColor(color[iprod]);
+      
+      hTrackMatchResPhiPos[iprod]->Sumw2();
+      hTrackMatchResPhiPos[iprod]->SetAxisRange(-0.05,0.05,"X");
+      hTrackMatchResPhiPos[iprod]->SetMarkerStyle(25);
+      hTrackMatchResPhiPos[iprod]->SetMarkerColor(color[iprod]);
+      
+      hTrackMatchResEtaNeg[iprod]->Scale(1./nEvents[iprod]);
+      hTrackMatchResEtaPos[iprod]->Scale(1./nEvents[iprod]);
+      hTrackMatchResPhiNeg[iprod]->Scale(1./nEvents[iprod]);
+      hTrackMatchResPhiPos[iprod]->Scale(1./nEvents[iprod]);
+
+      hTrackMatchResEtaNeg[iprod]->SetTitleOffset(1.5,"Y");
+      hTrackMatchResEtaPos[iprod]->SetTitleOffset(1.5,"Y");
+      hTrackMatchResPhiNeg[iprod]->SetTitleOffset(1.5,"Y");
+      hTrackMatchResPhiPos[iprod]->SetTitleOffset(1.5,"Y");
+      
+      if(iprod > 0)
+      {
+        hRatTrackMatchResPhiPos[iprod-1] = (TH1F*)hTrackMatchResPhiPos[iprod]->Clone(Form("hRatPhiPos%s",prod[iprod].Data()));
+        hRatTrackMatchResPhiNeg[iprod-1] = (TH1F*)hTrackMatchResPhiNeg[iprod]->Clone(Form("hRatPhiNeg%s",prod[iprod].Data()));
+        hRatTrackMatchResEtaPos[iprod-1] = (TH1F*)hTrackMatchResEtaPos[iprod]->Clone(Form("hRatEtaPos%s",prod[iprod].Data()));
+        hRatTrackMatchResEtaNeg[iprod-1] = (TH1F*)hTrackMatchResEtaNeg[iprod]->Clone(Form("hRatEtaNeg%s",prod[iprod].Data()));
+        
+        hRatTrackMatchResPhiPos[iprod-1]->Divide(hRatTrackMatchResPhiPos[iprod-1],hTrackMatchResPhiPos[0],1.000,1,"B");
+        hRatTrackMatchResPhiNeg[iprod-1]->Divide(hRatTrackMatchResPhiNeg[iprod-1],hTrackMatchResPhiNeg[0],1.000,1,"B");
+        hRatTrackMatchResEtaPos[iprod-1]->Divide(hRatTrackMatchResEtaPos[iprod-1],hTrackMatchResEtaPos[0],1.000,1,"B");
+        hRatTrackMatchResEtaNeg[iprod-1]->Divide(hRatTrackMatchResEtaNeg[iprod-1],hTrackMatchResEtaNeg[0],1.000,1,"B");
+      }
+    }
+    
+    // Hybrid Tracks
+    {
+      hTrackPt         [iprod] = (TH1F*) GetHisto("AnaHadrons_hPt"                  ,iprod);
+      hTrackPtSPD      [iprod] = (TH1F*) GetHisto("AnaHadrons_hPtSPDRefit"          ,iprod);
+      hTrackPtNoSPD    [iprod] = (TH1F*) GetHisto("AnaHadrons_hPtNoSPDRefit"        ,iprod);
+      hTrackEtaPhiSPD  [iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiSPDRefitPt02"  ,iprod);
+      hTrackEtaPhiNoSPD[iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNoSPDRefitPt02",iprod);
+      hTrackEtaPhi     [iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiPositive"      ,iprod);
+      hTrackEtaPhi     [iprod]->Add((TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative"   ,iprod));
+      
+      hTrackPhiSPD     [iprod] = (TH1F*)hTrackEtaPhiSPD  [iprod]->ProjectionY(Form("hTrackPhiSPD%s"  ,prod[iprod].Data()),0,1000);
+      hTrackPhiNoSPD   [iprod] = (TH1F*)hTrackEtaPhiNoSPD[iprod]->ProjectionY(Form("hTrackPhiNoSPD%s",prod[iprod].Data()),0,1000);
+      hTrackPhi        [iprod] = (TH1F*)hTrackEtaPhi     [iprod]->ProjectionY(Form("hTrackPhi%s"     ,prod[iprod].Data()),0,1000);
+      
+      hTrackPt     [iprod]->Sumw2();
+      hTrackPtSPD  [iprod]->Sumw2();
+      hTrackPtNoSPD[iprod]->Sumw2();
+      
+      hTrackPt     [iprod]->Scale(1./nEvents[iprod]);
+      hTrackPtSPD  [iprod]->Scale(1./nEvents[iprod]);
+      hTrackPtNoSPD[iprod]->Scale(1./nEvents[iprod]);
+      
+      hTrackPhi     [iprod]->Sumw2();
+      hTrackPhiSPD  [iprod]->Sumw2();
+      hTrackPhiNoSPD[iprod]->Sumw2();
+
+      hTrackPhi     [iprod]->Scale(1./nEvents[iprod]);
+      hTrackPhiSPD  [iprod]->Scale(1./nEvents[iprod]);
+      hTrackPhiNoSPD[iprod]->Scale(1./nEvents[iprod]);
+      
+      hTrackPt[iprod]->SetTitle("Track spectra with/out SPD");
+      hTrackPt[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
+      hTrackPt[iprod]->SetTitleOffset(1.5,"Y");
+      hTrackPt[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPt[iprod]->SetMarkerStyle(20);
+      hTrackPt[iprod]->SetAxisRange(0.,30.,"X");
+      //hTrackPt[iprod]->SetMaximum(1.1);
+      //hTrackPt[iprod]->SetMinimum(0);
+      
+      hTrackPtSPD[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPtSPD[iprod]->SetMarkerStyle(26);
+      
+      hTrackPtNoSPD[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPtNoSPD[iprod]->SetMarkerStyle(25);
+      
+      hTrackPhi[iprod]->SetTitle("Track #phi with/out SPD");
+      hTrackPhi[iprod]->SetYTitle("1/N_{events} dN/d#phi");
+      hTrackPhi[iprod]->SetTitleOffset(1.5,"Y");
+      hTrackPhi[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPhi[iprod]->SetMarkerStyle(20);
+      hTrackPhi[iprod]->SetAxisRange(0.,30.,"X");
+      //hTrackPhi[iprod]->SetMaximum(1.1);
+      //hTrackPhi[iprod]->SetMinimum(0);
+      
+      hTrackPhiSPD[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPhiSPD[iprod]->SetMarkerStyle(26);
+      
+      hTrackPhiNoSPD[iprod]->SetMarkerColor(color[iprod]);
+      hTrackPhiNoSPD[iprod]->SetMarkerStyle(25);
+      
+      if(iprod > 0)
+      {
+        hRatTrackPhi     [iprod-1] = (TH1F*)hTrackPhi     [iprod]->Clone(Form("hRatTrackPhi%s"     ,prod[iprod].Data()));
+        hRatTrackPhiNoSPD[iprod-1] = (TH1F*)hTrackPhiNoSPD[iprod]->Clone(Form("hRatTrackPhiNoSPD%s",prod[iprod].Data()));
+        hRatTrackPhiSPD  [iprod-1] = (TH1F*)hTrackPhiSPD  [iprod]->Clone(Form("hRatTrackPhiSPD%s"  ,prod[iprod].Data()));
+        
+        hRatTrackPhi     [iprod-1]->Divide(hRatTrackPhi     [iprod-1],hTrackPhi     [0],1.000,1,"B");
+        hRatTrackPhiSPD  [iprod-1]->Divide(hRatTrackPhiSPD  [iprod-1],hTrackPhiSPD  [0],1.000,1,"B");
+        hRatTrackPhiNoSPD[iprod-1]->Divide(hRatTrackPhiNoSPD[iprod-1],hTrackPhiNoSPD[0],1.000,1,"B");
+        
+        hRatTrackPt     [iprod-1] = (TH1F*)hTrackPt     [iprod]->Clone(Form("hRatTrackPt%s"     ,prod[iprod].Data()));
+        hRatTrackPtNoSPD[iprod-1] = (TH1F*)hTrackPtNoSPD[iprod]->Clone(Form("hRatTrackPtNoSPD%s",prod[iprod].Data()));
+        hRatTrackPtSPD  [iprod-1] = (TH1F*)hTrackPtSPD  [iprod]->Clone(Form("hRatTrackPtSPD%s"  ,prod[iprod].Data()));
+        
+        hRatTrackPt     [iprod-1]->Divide(hRatTrackPt     [iprod-1],hTrackPt     [0],1.000,1,"B");
+        hRatTrackPtSPD  [iprod-1]->Divide(hRatTrackPtSPD  [iprod-1],hTrackPtSPD  [0],1.000,1,"B");
+        hRatTrackPtNoSPD[iprod-1]->Divide(hRatTrackPtNoSPD[iprod-1],hTrackPtNoSPD[0],1.000,1,"B");
+      }
+    }
+  
+    // photon-track correlation
+    {
+      h2XE   [iprod]= (TH2F*) GetHisto("AnaPhotonHadronCorr_hXECharged",iprod);
+      h2XEUE [iprod]= (TH2F*) GetHisto("AnaPhotonHadronCorr_hXEUeCharged",iprod);
+      
+      Float_t minClusterE = 8;
+      TH1F * hLeading = (TH1F*) GetHisto("AnaPhotonHadronCorr_hPtLeading",iprod);
+      Int_t minClusterEBin = hLeading->FindBin(minClusterE);
+      Float_t nTrig = hLeading->Integral(minClusterE,100000);
+      
+      hXE  [iprod] = (TH1F*)h2XE  [iprod]->ProjectionY(Form("hXE%s"  ,prod[iprod].Data()),minClusterEBin,1000);
+      hXEUE[iprod] = (TH1F*)h2XEUE[iprod]->ProjectionY(Form("hXEUE%s",prod[iprod].Data()),minClusterEBin,1000);
+      
+      hXE  [iprod]->Sumw2();
+      hXEUE[iprod]->Sumw2();
+      
+      hXE  [iprod]->Scale(1./nTrig);
+      hXEUE[iprod]->Scale(1./nTrig);
+      
+      hXE[iprod]->SetTitle(Form("#gamma-hadron x_{E}, p_{T,Trig}>%2.1f GeV/c",minClusterE));
+      hXE[iprod]->SetYTitle("1/N_{trigger} dN/dx_{E}");
+      hXE[iprod]->SetTitleOffset(1.5,"Y");
+      hXE[iprod]->SetMarkerColor(color[iprod]);
+      hXE[iprod]->SetMarkerStyle(20);
+      hXE[iprod]->SetAxisRange(0.,1.,"X");
+      //hXE[iprod]->SetMaximum(1.1);
+      //hXE[iprod]->SetMinimum(0);
+      
+      hXEUE[iprod]->SetMarkerColor(color[iprod]);
+      hXEUE[iprod]->SetMarkerStyle(25);
+      
+      if(iprod > 0)
+      {
+        hRatXE  [iprod-1] = (TH1F*)hXE  [iprod]->Clone(Form("hRatXE%s"  ,prod[iprod].Data()));
+        hRatXEUE[iprod-1] = (TH1F*)hXEUE[iprod]->Clone(Form("hRatXEUE%s",prod[iprod].Data()));
+        
+        hRatXE  [iprod-1]->Divide(hRatXE  [iprod-1],hXE  [0],1.000,1,"B");
+        hRatXEUE[iprod-1]->Divide(hRatXEUE[iprod-1],hXEUE[0],1.000,1,"B");
+      }
+    }
+
+    //Centrality
+    {
+      hCen[iprod] = (TH1F*) GetHisto("hCentrality",iprod);
+      
+      hCen[iprod]->Sumw2();
+      
+      hCen[iprod]->Scale(1./nEvents[iprod]);
+      
+      hCen[iprod]->SetTitle("Centrality");
+      hCen[iprod]->SetYTitle("1/N_{events} dN/d centrality");
+      hCen[iprod]->SetTitleOffset(1.5,"Y");
+      hCen[iprod]->SetMarkerColor(color[iprod]);
+      hCen[iprod]->SetMarkerStyle(20);
+      //hCen[iprod]->SetAxisRange(0.,30.,"X");
+      //hCen[iprod]->SetMaximum(1.1);
+      //hCen[iprod]->SetMinimum(0);
+      
+      if(iprod > 0)
+      {
+        hRatCen[iprod-1] = (TH1F*)hCen[iprod]->Clone(Form("hRatCen%s" ,prod[iprod].Data()));
+        
+        hRatCen[iprod-1]->Divide(hRatCen[iprod-1],hCen [0],1.000,1,"B");
+       }
+    }
+
+    //Vertex
+    {
+      hVertex[0][iprod] = (TH1F*) GetHisto("hZVertex",iprod);
+      hVertex[1][iprod] = (TH1F*) GetHisto("hYVertex",iprod);
+      hVertex[2][iprod] = (TH1F*) GetHisto("hXVertex",iprod);
+      
+      for(Int_t ivertex = 0; ivertex < 3; ivertex++)
+      {
+        //hVertex[ivertex][iprod]->Sumw2();
+        
+        hVertex[ivertex][iprod]->Scale(1./nEvents[iprod]);
+        
+        //hVertex[ivertex][iprod]->SetTitle("Centrality");
+        hVertex[ivertex][iprod]->SetYTitle("1/N_{events} dN/ d vertex");
+        hVertex[ivertex][iprod]->SetTitleOffset(1.5,"Y");
+        hVertex[ivertex][iprod]->SetMarkerColor(color[iprod]);
+        hVertex[ivertex][iprod]->SetLineColor(color[iprod]);
+        hVertex[ivertex][iprod]->SetMarkerStyle(20);
+        hVertex[ivertex][iprod]->SetAxisRange(-15,15.,"X");
+        //hVertex[ivertex][iprod]->SetMaximum(1.1);
+        //hVertex[ivertex][iprod]->SetMinimum(0);
+        
+        if(iprod > 0)
+        {
+          hRatVertex[ivertex][iprod-1] = (TH1F*)hVertex[ivertex][iprod]->Clone(Form("hRatVertex%s_%d" ,prod[iprod].Data(),ivertex));
+          
+          hRatVertex[ivertex][iprod-1]->Divide(hRatVertex[ivertex][iprod-1],hVertex[ivertex][0],1.000,1,"B");
+        }
+      }
+    }
+
+  }
+  
+  /////////////////
+  // Make the plots
+  /////////////////
+  
+  //Legend for productions
+  TLegend lprod(0.3,0.475,0.84,0.675);
+  lprod.SetTextSize(0.04);
+  lprod.SetBorderSize(0);
+  lprod.SetFillColor(0);
+  
+  //Calimeter Cluster
+  {
+    TCanvas * ccalo = new TCanvas(Form("Cluster_%s",histoTag.Data()),"",1000,500);
+    ccalo->Divide(2,1);
+    
+    ccalo->cd(1);
+    gPad->SetLogy();
+    
+    hCorr[0]->Draw();
+    for(Int_t iprod = 0; iprod <  nProd; iprod++)
+    {
+      hRaw [iprod]->Draw("same");
+      hCorr[iprod]->Draw("same");
+      hTM  [iprod]->Draw("same");
+      hShSh[iprod]->Draw("same");
+      
+      lprod.AddEntry(hRaw[iprod],prod[iprod],"P");
+    }
+    
+    lprod.Draw();
+    
+    TLegend lcl(0.35,0.7,0.84,0.89);
+    lcl.SetTextSize(0.04);
+    lcl.SetBorderSize(0);
+    lcl.SetFillColor(0);
+    lcl.AddEntry(hRaw [0],"Raw","P");
+    lcl.AddEntry(hCorr[0],"No Exotics + non lin.","P");
+    lcl.AddEntry(hTM  [0],  "+ Track matching","P");
+    lcl.AddEntry(hShSh[0],"+ #lambda^{2}_{0} < 0.4","P");
+    lcl.Draw();
+    
+    ccalo->cd(2);
+    //gPad->SetLogy();
+    
+    hRatCorr[0]->SetTitle("Cluster spectra ratio");
+    hRatCorr[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    hRatCorr[0]->SetMinimum(0.850);
+    hRatCorr[0]->SetMaximum(1.025);
+    hRatCorr[0]->Draw("");
+    
+    for(Int_t iprod = 0; iprod <  nProd-1; iprod++)
+    {
+      hRatRaw [iprod]->Draw("same");
+      hRatCorr[iprod]->Draw("same");
+      hRatTM  [iprod]->Draw("same");
+      hRatShSh[iprod]->Draw("same");
+    }
+    
+    TLine l1(0,1,30,1);
+    TLine l2(0,0.975,30,0.975);
+    TLine l3(0,0.95,30,0.95);
+    TLine l4(0,0.925,30,0.925);
+    
+    l1.Draw("same");
+    l2.Draw("same");
+    l3.Draw("same");
+    l4.Draw("same");
+    
+    ccalo->Print(Form("%s_ClusterSpectraComp.eps",histoTag.Data()));
+  }
+  
+  //Cluster-Track Matching Residual
+  {
+    TLine l0(0,hTrackMatchResEtaNeg[0]->GetMinimum(),0,hTrackMatchResEtaNeg[0]->GetMaximum()*1.2);
+    
+    TLegend lres(0.6,0.75,0.84,0.89);
+    lres.SetTextSize(0.04);
+    //lres.SetBorderSize(0);
+    lres.SetFillColor(0);
+    lres.AddEntry(hTrackMatchResEtaNeg[0],"Negative","P");
+    lres.AddEntry(hTrackMatchResEtaPos[0],"Positive","P");
+    lres.Draw();
+    
+    TCanvas * ccalo2 = new TCanvas(Form("MatchingResiduals_%s",histoTag.Data()),"",500,500);
+    ccalo2->Divide(2,2);
+    
+    ccalo2->cd(1);
+    //gPad->SetLogy();
+    
+    hTrackMatchResEtaPos[0]->Draw("");
+    for(Int_t iprod = 0; iprod < nProd; iprod++)
+    {
+      hTrackMatchResEtaNeg[iprod]->Draw("same");
+      hTrackMatchResEtaPos[iprod]->Draw("same");
+    }
+    
+    l0.Draw("same");
+    lres.Draw();
+    lprod.Draw();
+    ccalo2->cd(2);
+    
+    hTrackMatchResPhiPos[0]->Draw("");
+    for(Int_t iprod = 0; iprod < nProd; iprod++)
+    {
+      hTrackMatchResPhiNeg[iprod]->Draw("same");
+      hTrackMatchResPhiPos[iprod]->Draw("same");
+    }
+    
+    l0.Draw("same");
+    
+    ccalo2->cd(3);
+    //gPad->SetLogy();
+    
+    hRatTrackMatchResEtaPos[0]->SetMaximum(1.25);
+    hRatTrackMatchResEtaPos[0]->SetMinimum(0.98);
+    hRatTrackMatchResEtaPos[0]->Draw("");
+    hRatTrackMatchResEtaPos[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    for(Int_t iprod = 0; iprod < nProd-1; iprod++)
+    {
+      hRatTrackMatchResEtaNeg[iprod]->Draw("same");
+      hRatTrackMatchResEtaPos[iprod]->Draw("same");
+    }
+    
+    //l0.Draw("same");
+    
+    ccalo2->cd(4);
+    
+    hRatTrackMatchResPhiPos[0]->SetMaximum(1.05);
+    hRatTrackMatchResPhiPos[0]->SetMinimum(0.98);
+    hRatTrackMatchResPhiPos[0]->Draw("");
+    hRatTrackMatchResPhiPos[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    for(Int_t iprod = 0; iprod < nProd-1; iprod++)
+    {
+      hRatTrackMatchResPhiNeg[iprod]->Draw("same");
+      hRatTrackMatchResPhiPos[iprod]->Draw("same");
+    }
+    
+    ccalo2->Print(Form("%s_MatchingResidualsComp.eps",histoTag.Data()));
+  }
+  
+  // Hybrid tracks
+  {
+    TLegend ltrack(0.6,0.75,0.84,0.89);
+    ltrack.SetTextSize(0.04);
+    //ltrack.SetBorderSize(0);
+    ltrack.SetFillColor(0);
+    ltrack.AddEntry(hTrackPt     [0],"All","P");
+    ltrack.AddEntry(hTrackPtSPD  [0],"SPD","P");
+    ltrack.AddEntry(hTrackPtNoSPD[0],"No SPD","P");
+    
+    TCanvas * ctrack = new TCanvas(Form("TrackHisto_%s",histoTag.Data()),"",1500,1500);
+    ctrack->Divide(2,2);
+    ctrack->cd(1);
+    gPad->SetLogy();
+    hTrackPt[0]->Draw("");
+    for(Int_t iprod = 0; iprod < nProd; iprod++)
+    {
+      hTrackPt     [iprod]->Draw("same");
+      hTrackPtSPD  [iprod]->Draw("same");
+      hTrackPtNoSPD[iprod]->Draw("same");
+    }
+    
+    ltrack.Draw();
+    lprod.Draw();
+    
+    ctrack->cd(2);
+    
+    hRatTrackPt[0]->SetMaximum(1.05);
+    hRatTrackPt[0]->SetMinimum(0.95);
+    hRatTrackPt[0]->Draw("");
+    hRatTrackPt[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    for(Int_t iprod = 0; iprod < nProd-1; iprod++)
+    {
+      hRatTrackPt     [iprod]->Draw("same");
+      hRatTrackPtSPD  [iprod]->Draw("same");
+      hRatTrackPtNoSPD[iprod]->Draw("same");
+    }
+    
+    ctrack->cd(3);
+    hTrackPhi[0]->SetMaximum(3.);
+    hTrackPhi[0]->SetMinimum(0.);
+    hTrackPhi[0]->Draw("");
+    for(Int_t iprod = 0; iprod < nProd; iprod++)
+    {
+      hTrackPhi     [iprod]->Draw("same");
+      hTrackPhiSPD  [iprod]->Draw("same");
+      hTrackPhiNoSPD[iprod]->Draw("same");
+    }
+    
+    ctrack->cd(4);
+    //gPad->SetLogy();
+    
+    hRatTrackPhi[0]->SetMaximum(1.05);
+    hRatTrackPhi[0]->SetMinimum(0.95);
+    hRatTrackPhi[0]->Draw("");
+    hRatTrackPhi[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    for(Int_t iprod = 0; iprod < nProd-1; iprod++)
+    {
+      hRatTrackPhi     [iprod]->Draw("same");
+      hRatTrackPhiSPD  [iprod]->Draw("same");
+      hRatTrackPhiNoSPD[iprod]->Draw("same");
+    }
+    
+    ctrack->Print(Form("%s_TrackComp.eps",histoTag.Data()));
+  }
+  
+  // XE
+  {
+    TLegend lxe(0.6,0.75,0.84,0.89);
+    lxe.SetTextSize(0.04);
+    //lxe.SetBorderSize(0);
+    lxe.SetFillColor(0);
+    lxe.AddEntry(hXE  [0],"Signal+bkg","P");
+    lxe.AddEntry(hXEUE[0],"Und. Event","P");
+    
+    TCanvas * cxe = new TCanvas(Form("XEHisto_%s",histoTag.Data()),"",1000,500);
+    cxe->Divide(2,1);
+    cxe->cd(1);
+    gPad->SetLogy();
+    hXE[0]->Draw("");
+    for(Int_t iprod = 0; iprod < nProd; iprod++)
+    {
+      hXE  [iprod]->Draw("same");
+      hXEUE[iprod]->Draw("same");
+    }
+    
+    lxe.Draw();
+    lprod.Draw();
+    
+    cxe->cd(2);
+    
+    hRatXE[0]->SetMaximum(1.05);
+    hRatXE[0]->SetMinimum(0.95);
+    hRatXE[0]->Draw("");
+    hRatXE[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    for(Int_t iprod = 0; iprod < nProd-1; iprod++)
+    {
+      hRatXE  [iprod]->Draw("same");
+      hRatXEUE[iprod]->Draw("same");
+    }
+    
+    cxe->Print(Form("%s_XEComp.eps",histoTag.Data()));
+  }
+  
+  // Centrality
+  {
+    TCanvas * ccen = new TCanvas(Form("Centrality_%s",histoTag.Data()),"",1000,500);
+    ccen->Divide(2,1);
+    
+    ccen->cd(1);
+    //gPad->SetLogy();
+    
+    hCen[0]->Draw();
+    for(Int_t iprod = 0; iprod <  nProd; iprod++)
+    {
+      hCen[iprod]->Draw("same");
+    }
+    
+    lprod.Draw();
+    
+    ccen->cd(2);
+    //gPad->SetLogy();
+    
+    hRatCen[0]->SetTitle("Centrality");
+    hRatCen[0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+    hRatCen[0]->SetMinimum(0.95);
+    hRatCen[0]->SetMaximum(1.05);
+    hRatCen[0]->Draw("");
+    
+    for(Int_t iprod = 0; iprod <  nProd-1; iprod++)
+    {
+      hRatCen [iprod]->Draw("same");
+    }
+    
+    TLine l1(0,1,100,1);
+    
+    l1.Draw("same");
+
+    ccen->Print(Form("%s_CentralityComp.eps",histoTag.Data()));
+  }
+
+  // Vertex
+  {
+    TCanvas * cvertex = new TCanvas(Form("Vertex_%s",histoTag.Data()),"",3*500,2*500);
+    cvertex->Divide(3,2);
+    Int_t npannel = 1;
+    for(Int_t ivertex = 0; ivertex < 3; ivertex++)
+    {
+      cvertex->cd(npannel);
+      //gPad->SetLogy();
+      
+      hVertex[ivertex][0]->Draw();
+      for(Int_t iprod = 0; iprod <  nProd; iprod++)
+      {
+        hVertex[ivertex][iprod]->Draw("same");
+      }
+      
+      lprod.Draw();
+      
+      cvertex->cd(npannel+3);
+      //gPad->SetLogy();
+      
+      //hRatVertex[ivertex][0]->SetTitle("");
+      hRatVertex[ivertex][0]->SetYTitle(Form("data X / %s",prod[0].Data()));
+//      hRatVertex[ivertex][0]->SetMinimum(0.95);
+//      hRatVertex[ivertex][0]->SetMaximum(1.05);
+      hRatVertex[ivertex][0]->Draw("");
+      
+      for(Int_t iprod = 0; iprod <  nProd-1; iprod++)
+      {
+        hRatVertex[ivertex][iprod]->Draw("same");
+      }
+
+      npannel++;
+    }
+    cvertex->Print(Form("%s_VertexComp.eps",histoTag.Data()));
+  }
+
+  
+}
+
+//_____________________________________________________
+void GetFileAndList(TString fileName, TString listName)
+{
+
+  for(Int_t iprod = 0; iprod < nProd; iprod++)
+  {
+    file[iprod]  = new TFile(Form("%s/%s",prod[iprod].Data(),fileName.Data()),"read");
+    if(file[iprod]->Get("hNEvents"))
+    {
+      nEvents[iprod] = ((TH1F*)file[iprod]->Get("hNEvents"))->GetEntries();
+      printf("%s: nEvents %e\n",prod[iprod].Data(),nEvents[iprod]);
+    }
+
+    TDirectory * dir = (TDirectory*) file[iprod]->Get(listName);
+    if(dir)
+    {
+      list[iprod] = (TList*) dir->Get(listName);
+      nEvents[iprod] = ((TH1F*)list[iprod]->FindObject("hNEvents"))->GetEntries();
+      printf("%s: nEvents %e\n",prod[iprod],nEvents[iprod]);
+    }
+    else list[iprod] = 0;
+  }
+  
+}
+
+//___________________________________
+TObject * GetHisto(TString histoName, Int_t iprod)
+{
+  // Check if the list is available, if not get the histo directly from file
+  
+  if(list[iprod]) return list[iprod]->FindObject(histoName);
+  else            return file[iprod]->Get       (histoName);
+}
index 4a09571d666eb3737cf0a5e1984e58ddefbf0228..a34c0ab5a7e6c8839343b4052b834705022eff13 100644 (file)
@@ -907,7 +907,7 @@ void AliAnalysisTaskEMCALClusterize::FillAODHeader()
   header->SetZDCP2Energy(fEvent->GetZDCP2Energy());
   header->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0),fEvent->GetZDCEMEnergy(1));
   
-  Float_t diamxy[2]={fEvent->GetDiamondX(),fEvent->GetDiamondY()};
+  Float_t diamxy[2]={(Float_t)fEvent->GetDiamondX(),(Float_t)fEvent->GetDiamondY()};
   Float_t diamcov[3];
   fEvent->GetDiamondCovXY(diamcov);
   header->SetDiamond(diamxy,diamcov);
index 0ed83de26a8e081c36bbbf33514c411662ef7299..5bbfbf9398de213cb7b7820e1b734248b6464749 100644 (file)
@@ -952,11 +952,11 @@ void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
   
   //map for cells and patches
   
-  Double_t emcalCell     [fgkFALTRORows][fgkFALTROCols], emcalCellL1G  [fgkFALTRORows][fgkFALTROCols],emcalCellL1G2 [fgkFALTRORows][fgkFALTROCols],emcalCellL1G_ [fgkFALTRORows][fgkFALTROCols];
+  Double_t emcalCell     [fgkFALTRORows][fgkFALTROCols], emcalCellL1G  [fgkFALTRORows][fgkFALTROCols],emcalCellL1G2 [fgkFALTRORows][fgkFALTROCols];
   Double_t emcalCellL1J  [fgkFALTRORows][fgkFALTROCols], emcalCellL1J2 [fgkFALTRORows][fgkFALTROCols],emcalTrigL0   [fgkFALTRORows][fgkFALTROCols];
   Double_t emcalTrigL0L1G[fgkFALTRORows][fgkFALTROCols], emcalTrigL0L1J[fgkFALTRORows][fgkFALTROCols];
   Double_t emcalTrigL1G  [fgkFALTRORows][fgkFALTROCols], emcalTrigL1G2 [fgkFALTRORows][fgkFALTROCols],emcalTrigL1J  [fgkFALTRORows][fgkFALTROCols], emcalTrigL1J2 [fgkFALTRORows][fgkFALTROCols],emcalTrigL1  [fgkFALTRORows][fgkFALTROCols];
-  Double_t emcalPatchL0  [fgkFALTRORows][fgkFALTROCols], emcalPatchL1G [fgkFALTRORows][fgkFALTROCols],emcalPatchL1G2[fgkFALTRORows][fgkFALTROCols], emcalPatchL1J[fgkFALTRORows][fgkFALTROCols], emcalPatchL1J2[fgkFALTRORows][fgkFALTROCols];
+  //Double_t emcalPatchL0  [fgkFALTRORows][fgkFALTROCols], emcalPatchL1G [fgkFALTRORows][fgkFALTROCols],emcalPatchL1G2[fgkFALTRORows][fgkFALTROCols], emcalPatchL1J[fgkFALTRORows][fgkFALTROCols], emcalPatchL1J2[fgkFALTRORows][fgkFALTROCols];
   
   for (Int_t i = 0; i < fgkFALTRORows; i++)
   {
@@ -973,14 +973,13 @@ void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
       emcalCell[i][j]      = 0.;
       emcalCellL1G[i][j]   = 0.;
       emcalCellL1G2[i][j]  = 0.;
-      emcalCellL1G_[i][j]  = 0.;
       emcalCellL1J[i][j]   = 0.;
       emcalCellL1J2[i][j]  = 0.;
-      emcalPatchL0[i][j]   = 0.;
-      emcalPatchL1G[i][j]  = 0.;
-      emcalPatchL1G2[i][j] = 0.;
-      emcalPatchL1J[i][j]  = 0.;
-      emcalPatchL1J2[i][j] = 0.;
+//      emcalPatchL0[i][j]   = 0.;
+//      emcalPatchL1G[i][j]  = 0.;
+//      emcalPatchL1G2[i][j] = 0.;
+//      emcalPatchL1J[i][j]  = 0.;
+//      emcalPatchL1J2[i][j] = 0.;
     }
   }
   
@@ -1088,7 +1087,7 @@ void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
       if (l0fired)
       {
          nL0Patch += nTimes;
-         emcalPatchL0[posY][posX] = 1.;
+         //emcalPatchL0[posY][posX] = 1.;
          fhL0Patch->Fill(posX,posY);
       }
                        
@@ -1107,7 +1106,7 @@ void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
       {
 //     cout << "(bit >> fBitEGA) & 0x1"<<endl;
         nL1Patch ++;
-        emcalPatchL1G[posY][posX] = 1.;
+        //emcalPatchL1G[posY][posX] = 1.;
         if( bL1G  ) fhL1GPatch ->Fill(posX,posY);
         if( bL1G2 ) fhL1G2Patch->Fill(posX,posY);
         if (ts > 0 && bL1G)  emcalTrigL1G [posY][posX] = ts;
@@ -1118,7 +1117,7 @@ void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
       if (bit >> fBitEJE & 0x1)
       {
         nL1Patch ++;
-        emcalPatchL1J[posY][posX] = 1.;
+        //emcalPatchL1J[posY][posX] = 1.;
         if( bL1J  ) fhL1JPatch ->Fill(posX,posY);
         if( bL1J2 ) fhL1J2Patch->Fill(posX,posY);
         if (ts > 0 && bL1J ) emcalTrigL1J [posY][posX] = ts;
index b5832198b5526a9d576d505bdea9dba927f6c2b0..0955548f5c514f996c3daac4298c017f0c47acce 100644 (file)
@@ -100,10 +100,8 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    hESDMotherEtaPtY(NULL),
    hESDMotherPi0PtAlpha(NULL),
    hESDMotherEtaPtAlpha(NULL),
-   hESDMotherPi0YEtaLowPtGamma(NULL),
-   hESDMotherPi0YEtaHighPtGamma(NULL),
-   hESDMotherEtaYEtaLowPtGamma(NULL),
-   hESDMotherEtaYEtaHighPtGamma(NULL),
+   hESDMotherPi0PtOpenAngle(NULL),
+   hESDMotherEtaPtOpenAngle(NULL),
    hMCHeaders(NULL),
    hMCAllGammaPt(NULL),
    hMCDecayGammaPi0Pt(NULL),
@@ -119,6 +117,7 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    hMCPi0Pt(NULL),
    hMCPi0WOWeightPt(NULL),
    hMCEtaPt(NULL),
+   hMCEtaWOWeightPt(NULL),
    hMCPi0InAccPt(NULL),
    hMCEtaInAccPt(NULL),
    hMCPi0PtY(NULL),
@@ -143,10 +142,8 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    hESDTrueEtaPtY(NULL),
    hESDTruePi0PtAlpha(NULL),
    hESDTrueEtaPtAlpha(NULL),
-   hESDTruePi0YEtaLowPtGamma(NULL),
-   hESDTruePi0YEtaHighPtGamma(NULL),
-   hESDTrueEtaYEtaLowPtGamma(NULL),
-   hESDTrueEtaYEtaHighPtGamma(NULL),
+   hESDTruePi0PtOpenAngle(NULL),
+   hESDTrueEtaPtOpenAngle(NULL),
    hESDTrueMotherDalitzInvMassPt(NULL),
    hESDTrueConvGammaPt(NULL),
    hESDCombinatorialPt(NULL),
@@ -237,10 +234,8 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    hESDMotherEtaPtY(NULL),
    hESDMotherPi0PtAlpha(NULL),
    hESDMotherEtaPtAlpha(NULL),
-   hESDMotherPi0YEtaLowPtGamma(NULL),
-   hESDMotherPi0YEtaHighPtGamma(NULL),
-   hESDMotherEtaYEtaLowPtGamma(NULL),
-   hESDMotherEtaYEtaHighPtGamma(NULL),
+   hESDMotherPi0PtOpenAngle(NULL),
+   hESDMotherEtaPtOpenAngle(NULL),
    hMCHeaders(NULL),
    hMCAllGammaPt(NULL),
    hMCDecayGammaPi0Pt(NULL),
@@ -256,6 +251,7 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    hMCPi0Pt(NULL),
    hMCPi0WOWeightPt(NULL),
    hMCEtaPt(NULL),
+   hMCEtaWOWeightPt(NULL),
    hMCPi0InAccPt(NULL),
    hMCEtaInAccPt(NULL),
    hMCPi0PtY(NULL),
@@ -280,10 +276,8 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    hESDTrueEtaPtY(NULL),
    hESDTruePi0PtAlpha(NULL),
    hESDTrueEtaPtAlpha(NULL),
-   hESDTruePi0YEtaLowPtGamma(NULL),
-   hESDTruePi0YEtaHighPtGamma(NULL),
-   hESDTrueEtaYEtaLowPtGamma(NULL),
-   hESDTrueEtaYEtaHighPtGamma(NULL),
+   hESDTruePi0PtOpenAngle(NULL),
+   hESDTrueEtaPtOpenAngle(NULL),
    hESDTrueMotherDalitzInvMassPt(NULL),
    hESDTrueConvGammaPt(NULL),
    hESDCombinatorialPt(NULL),
@@ -467,10 +461,8 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
          hESDMotherEtaPtY =  new TH2F*[fnCuts];
          hESDMotherPi0PtAlpha =  new TH2F*[fnCuts];
          hESDMotherEtaPtAlpha =  new TH2F*[fnCuts];
-         hESDMotherPi0YEtaLowPtGamma =  new TH2F*[fnCuts];
-         hESDMotherPi0YEtaHighPtGamma =  new TH2F*[fnCuts];
-         hESDMotherEtaYEtaLowPtGamma =  new TH2F*[fnCuts];
-         hESDMotherEtaYEtaHighPtGamma =  new TH2F*[fnCuts];
+         hESDMotherPi0PtOpenAngle =  new TH2F*[fnCuts];
+         hESDMotherEtaPtOpenAngle =  new TH2F*[fnCuts];
       }   
    }
 
@@ -572,26 +564,24 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
               
          }
          if (fDoMesonQA > 0 ){
-            hESDMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",250,0.03,25.,150,-1.5,1.5);            
+            hESDMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);            
             SetLogBinningXTH2(hESDMotherPi0PtY[iCut]);
             fESDList[iCut]->Add(hESDMotherPi0PtY[iCut]);
-            hESDMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+            hESDMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
             SetLogBinningXTH2(hESDMotherEtaPtY[iCut]);
             fESDList[iCut]->Add(hESDMotherEtaPtY[iCut]);
-            hESDMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",250,0.03,25.,100,0,1);            
+            hESDMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",150,0.03,15.,100,0,1);            
             SetLogBinningXTH2(hESDMotherPi0PtAlpha[iCut]);
             fESDList[iCut]->Add(hESDMotherPi0PtAlpha[iCut]);
-            hESDMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",250,0.03,25.,100,0,1);
+            hESDMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",150,0.03,15.,100,0,1);
             SetLogBinningXTH2(hESDMotherEtaPtAlpha[iCut]);
             fESDList[iCut]->Add(hESDMotherEtaPtAlpha[iCut]);
-            hESDMotherPi0YEtaLowPtGamma[iCut] = new TH2F("ESD_MotherPi0_Y_EtaLowPtGamma","ESD_MotherPi0_Y_EtaLowPtGamma",150,-1.5,1.5,200,-2,2);            
-            fESDList[iCut]->Add(hESDMotherPi0YEtaLowPtGamma[iCut]);
-            hESDMotherPi0YEtaHighPtGamma[iCut] = new TH2F("ESD_MotherPi0_Y_EtaHighPtGamma","ESD_MotherPi0_Y_EtaHighPtGamma",150,-1.5,1.5,200,-2,2);            
-            fESDList[iCut]->Add(hESDMotherPi0YEtaHighPtGamma[iCut]);
-            hESDMotherEtaYEtaLowPtGamma[iCut] = new TH2F("ESD_MotherEta_Y_EtaLowPtGamma","ESD_MotherEta_Y_EtaLowPtGamma",150,-1.5,1.5,200,-2,2);            
-            fESDList[iCut]->Add(hESDMotherEtaYEtaLowPtGamma[iCut]);
-            hESDMotherEtaYEtaHighPtGamma[iCut] = new TH2F("ESD_MotherEta_Y_EtaHighPtGamma","ESD_MotherEta_Y_EtaHighPtGamma",150,-1.5,1.5,200,-2,2);            
-            fESDList[iCut]->Add(hESDMotherEtaYEtaHighPtGamma[iCut]);
+            hESDMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());            
+            SetLogBinningXTH2(hESDMotherPi0PtOpenAngle[iCut]);
+            fESDList[iCut]->Add(hESDMotherPi0PtOpenAngle[iCut]);
+            hESDMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());            
+            SetLogBinningXTH2(hESDMotherEtaPtOpenAngle[iCut]);
+            fESDList[iCut]->Add(hESDMotherEtaPtOpenAngle[iCut]);
          }
          
             
@@ -641,6 +631,7 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
          hMCPi0Pt = new TH1F*[fnCuts];
          hMCPi0WOWeightPt = new TH1F*[fnCuts];
          hMCEtaPt = new TH1F*[fnCuts];
+         hMCEtaWOWeightPt = new TH1F*[fnCuts];
          hMCPi0InAccPt = new TH1F*[fnCuts];
          hMCEtaInAccPt = new TH1F*[fnCuts];
 
@@ -668,10 +659,8 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
             hESDTrueEtaPtY = new TH2F*[fnCuts];
             hESDTruePi0PtAlpha = new TH2F*[fnCuts];
             hESDTrueEtaPtAlpha = new TH2F*[fnCuts];
-            hESDTruePi0YEtaLowPtGamma = new TH2F*[fnCuts];
-            hESDTruePi0YEtaHighPtGamma = new TH2F*[fnCuts];
-            hESDTrueEtaYEtaLowPtGamma = new TH2F*[fnCuts];
-            hESDTrueEtaYEtaHighPtGamma = new TH2F*[fnCuts];
+            hESDTruePi0PtOpenAngle = new TH2F*[fnCuts];
+            hESDTrueEtaPtOpenAngle = new TH2F*[fnCuts];
          }
       }
 
@@ -723,6 +712,9 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
             hMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
             hMCEtaPt[iCut]->Sumw2();
             fMCList[iCut]->Add(hMCEtaPt[iCut]);
+            hMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",250,0,25);
+            hMCEtaWOWeightPt[iCut]->Sumw2();
+            fMCList[iCut]->Add(hMCEtaWOWeightPt[iCut]);
             hMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
             hMCPi0InAccPt[iCut]->Sumw2();
             fMCList[iCut]->Add(hMCPi0InAccPt[iCut]);
@@ -730,21 +722,21 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
             hMCEtaInAccPt[iCut]->Sumw2();
             fMCList[iCut]->Add(hMCEtaInAccPt[iCut]);
             if (fDoMesonQA > 0){
-               hMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+               hMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
                hMCPi0PtY[iCut]->Sumw2();
                SetLogBinningXTH2(hMCPi0PtY[iCut]);
                fMCList[iCut]->Add(hMCPi0PtY[iCut]);
-               hMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+               hMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
                hMCEtaPtY[iCut]->Sumw2();
                SetLogBinningXTH2(hMCEtaPtY[iCut]);
                fMCList[iCut]->Add(hMCEtaPtY[iCut]);
-               hMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",250,0,25);
+               hMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",150,0,15);
                hMCK0sPt[iCut]->Sumw2();
                fMCList[iCut]->Add(hMCK0sPt[iCut]);
-               hMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",250,0,25);
+               hMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",150,0,15);
                hMCK0sWOWeightPt[iCut]->Sumw2();
                fMCList[iCut]->Add(hMCK0sWOWeightPt[iCut]);
-               hMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+               hMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",150,0.03,15.,150,-1.5,1.5);
                hMCK0sPtY[iCut]->Sumw2();
                SetLogBinningXTH2(hMCK0sPtY[iCut]);
                fMCList[iCut]->Add(hMCK0sPtY[iCut]);
@@ -791,11 +783,11 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
          fTrueList[iCut]->Add(hESDTrueSecondaryConvGammaFromXFromLambdaPt[iCut]);
 
          hESDTrueDalitzPsiPairDeltaPhi[iCut]
-            = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi_Pt", "ESD_TrueDalitzPsiPairDeltaPhi_Pt",400,-2,2,400,-2,2);
+            = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi_Pt", "ESD_TrueDalitzPsiPairDeltaPhi_Pt",100,-0.5,2,100,-0.5,0.5);
          fTrueList[iCut]->Add(hESDTrueDalitzPsiPairDeltaPhi[iCut]);
          
          hESDTrueGammaPsiPairDeltaPhi[iCut]
-            = new TH2F("ESD_TrueGammaPsiPairDeltaPhi_Pt", "ESD_TrueGammaPsiPairDeltaPhi_Pt",200,-2,2,400,-2,2);
+            = new TH2F("ESD_TrueGammaPsiPairDeltaPhi_Pt", "ESD_TrueGammaPsiPairDeltaPhi_Pt",100,-0.5,2,100,-0.5,0.5);
          fTrueList[iCut]->Add(hESDTrueGammaPsiPairDeltaPhi[iCut]);
 
          
@@ -847,27 +839,26 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
                fTrueList[iCut]->Add(hESDTrueK0sWithPi0DaughterMCPt[iCut]);
                hESDTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
                fTrueList[iCut]->Add(hESDTrueEtaWithPi0DaughterMCPt[iCut]);
-               hESDTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+               hESDTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
                SetLogBinningXTH2(hESDTruePi0PtY[iCut]);
                fTrueList[iCut]->Add(hESDTruePi0PtY[iCut]);
-               hESDTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",250,0.03,25.,150,-1.5,1.5);
+               hESDTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
                SetLogBinningXTH2(hESDTrueEtaPtY[iCut]);
                fTrueList[iCut]->Add(hESDTrueEtaPtY[iCut]);
-               hESDTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",250,0.03,25.,100,0,1);
+               hESDTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
                SetLogBinningXTH2(hESDTruePi0PtAlpha[iCut]);
                fTrueList[iCut]->Add(hESDTruePi0PtAlpha[iCut]);
-               hESDTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",250,0.03,25.,100,0,1);
+               hESDTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",150,0.03,15.,100,0,1);
                SetLogBinningXTH2(hESDTrueEtaPtAlpha[iCut]);
                fTrueList[iCut]->Add(hESDTrueEtaPtAlpha[iCut]);
                
-               hESDTruePi0YEtaLowPtGamma[iCut] = new TH2F("ESD_TruePi0_Y_EtaLowPtGamma","ESD_TruePi0_Y_EtaLowPtGamma",150,-1.5,1.5,200,-2,2);            
-               fTrueList[iCut]->Add(hESDTruePi0YEtaLowPtGamma[iCut]);
-               hESDTruePi0YEtaHighPtGamma[iCut] = new TH2F("ESD_TruePi0_Y_EtaHighPtGamma","ESD_TruePi0_Y_EtaHighPtGamma",150,-1.5,1.5,200,-2,2);            
-               fTrueList[iCut]->Add(hESDTruePi0YEtaHighPtGamma[iCut]);
-               hESDTrueEtaYEtaLowPtGamma[iCut] = new TH2F("ESD_TrueEta_Y_EtaLowPtGamma","ESD_TrueEta_Y_EtaLowPtGamma",150,-1.5,1.5,200,-2,2);            
-               fTrueList[iCut]->Add(hESDTrueEtaYEtaLowPtGamma[iCut]);
-               hESDTrueEtaYEtaHighPtGamma[iCut] = new TH2F("ESD_TrueEta_Y_EtaHighPtGamma","ESD_TrueEta_Y_EtaHighPtGamma",150,-1.5,1.5,200,-2,2);            
-               fTrueList[iCut]->Add(hESDTrueEtaYEtaHighPtGamma[iCut]);
+               hESDTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());            
+               SetLogBinningXTH2(hESDTruePi0PtOpenAngle[iCut]);
+               fTrueList[iCut]->Add(hESDTruePi0PtOpenAngle[iCut]);
+               hESDTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());            
+               SetLogBinningXTH2(hESDTrueEtaPtOpenAngle[iCut]);
+               fTrueList[iCut]->Add(hESDTrueEtaPtOpenAngle[iCut]);
+               
             }
          }
       }
@@ -1502,7 +1493,9 @@ void AliAnalysisTaskGammaConvV1::ProcessAODMCParticles()
             if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
                if (particle->Pt()>0.005){
                   weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, 0x0, fInputEvent);
-                  //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+//                   if(particle->GetPdgCode() == 221){
+//                      cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+//                   }
                }
             }
             Double_t mesonY = 10.;
@@ -1519,6 +1512,7 @@ void AliAnalysisTaskGammaConvV1::ProcessAODMCParticles()
                if (fDoMesonQA > 0) hMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
             } else if(particle->GetPdgCode() == 221){
                hMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
+               hMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
                if (fDoMesonQA > 0) hMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
             }
             
@@ -1618,7 +1612,9 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
             if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
                if (particle->Pt()>0.005){
                   weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
-                  //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+//                   if(particle->GetPdgCode() == 221){
+//                      cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+//                   }
                }
             }
             Double_t mesonY = 10.;
@@ -1635,6 +1631,7 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
                if (fDoMesonQA > 0) hMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
             } else if(particle->GetPdgCode() == 221){
                hMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
+               hMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
                if (fDoMesonQA > 0) hMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
             } 
 
@@ -1685,24 +1682,13 @@ void AliAnalysisTaskGammaConvV1::CalculatePi0Candidates(){
                   if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
                      hESDMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift());  
                      hESDMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());  
-                     if (gamma0->Pt() < gamma1->Pt()){
-                       hESDMotherPi0YEtaLowPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma0->Eta()); 
-                       hESDMotherPi0YEtaHighPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma1->Eta()); 
-                     } else {
-                       hESDMotherPi0YEtaLowPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma1->Eta()); 
-                       hESDMotherPi0YEtaHighPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma0->Eta()); 
-                     }   
+                     hESDMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle()); 
+                     
                   } 
                   if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
                      hESDMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift());  
                      hESDMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());  
-                     if (gamma0->Pt() < gamma1->Pt()){
-                       hESDMotherEtaYEtaLowPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma0->Eta()); 
-                       hESDMotherEtaYEtaHighPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma1->Eta()); 
-                     } else {
-                       hESDMotherEtaYEtaLowPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma1->Eta()); 
-                       hESDMotherEtaYEtaHighPtGamma[fiCut]->Fill(pi0cand->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),gamma0->Eta()); 
-                     }
+                     hESDMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());       
                   }
                }   
                if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
@@ -1853,25 +1839,13 @@ void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidates(AliAODConversionMoth
                   if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
                      hESDTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()); 
                      hESDTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha()); 
-                     if (TrueGammaCandidate0->Pt() < TrueGammaCandidate1->Pt()){
-                        hESDMotherPi0YEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                        hESDMotherPi0YEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                     } else {
-                        hESDMotherPi0YEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                        hESDMotherPi0YEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                     }   
+                     hESDTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle()); 
                   }
                } else if (isTrueEta){   
                   if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
                      hESDTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()); 
                      hESDTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha()); 
-                     if (TrueGammaCandidate0->Pt() < TrueGammaCandidate1->Pt()){
-                        hESDMotherEtaYEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                        hESDMotherEtaYEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                     } else {
-                        hESDMotherEtaYEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                        hESDMotherEtaYEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                     }
+                     hESDTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle()); 
                   }
                }
             }   
@@ -2044,25 +2018,13 @@ void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidatesAOD(AliAODConversionM
             if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
                hESDTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift());
                hESDTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha()); 
-               if (TrueGammaCandidate0->Pt() < TrueGammaCandidate1->Pt()){
-                  hESDTruePi0YEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                  hESDTruePi0YEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-               } else {
-                  hESDTruePi0YEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                  hESDTruePi0YEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-               }
+               hESDTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle()); 
             }
          } else if (isTrueEta){   
             if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
                hESDTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift()); 
                hESDTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha()); 
-               if (TrueGammaCandidate0->Pt() < TrueGammaCandidate1->Pt()){
-                  hESDTrueEtaYEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-                  hESDTrueEtaYEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-               } else {
-                  hESDTrueEtaYEtaLowPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate1->Eta()); 
-                  hESDTrueEtaYEtaHighPtGamma[fiCut]->Fill(Pi0Candidate->Rapidity()-((AliConversionCuts*)fCutArray->At(fiCut))->GetEtaShift(),TrueGammaCandidate0->Eta()); 
-               }
+               hESDTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle()); 
             }
          }
       }
@@ -2196,7 +2158,7 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                   if(fMoveParticleAccordingToVertex == kTRUE){
                      MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
                   }
-                  if(fIsHeavyIon){
+                  if(((AliConversionCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
                      RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
                   }
 
@@ -2230,7 +2192,7 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                      if(fMoveParticleAccordingToVertex == kTRUE){
                         MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
                      }
-                     if(fIsHeavyIon){
+                     if(((AliConversionCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
                         RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
                      }
 
index 99970bbdc5daef9aa52e3a0b2e953a5c231b16fb..8922bc7852b8818ed110fd5a684a27f6d35028ca 100644 (file)
@@ -115,10 +115,8 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TH2F **hESDMotherEtaPtY;
    TH2F **hESDMotherPi0PtAlpha;
    TH2F **hESDMotherEtaPtAlpha;
-   TH2F **hESDMotherPi0YEtaLowPtGamma;
-   TH2F **hESDMotherPi0YEtaHighPtGamma;
-   TH2F **hESDMotherEtaYEtaLowPtGamma;
-   TH2F **hESDMotherEtaYEtaHighPtGamma;
+   TH2F **hESDMotherPi0PtOpenAngle;
+   TH2F **hESDMotherEtaPtOpenAngle;
    TH1I **hMCHeaders;
    TH1F **hMCAllGammaPt;
    TH1F **hMCDecayGammaPi0Pt;
@@ -134,6 +132,7 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TH1F **hMCPi0Pt;
    TH1F **hMCPi0WOWeightPt;
    TH1F **hMCEtaPt;
+   TH1F **hMCEtaWOWeightPt;
    TH1F **hMCPi0InAccPt;
    TH1F **hMCEtaInAccPt;
    TH2F **hMCPi0PtY;
@@ -158,10 +157,8 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TH2F **hESDTrueEtaPtY;
    TH2F **hESDTruePi0PtAlpha;
    TH2F **hESDTrueEtaPtAlpha;
-   TH2F **hESDTruePi0YEtaLowPtGamma;
-   TH2F **hESDTruePi0YEtaHighPtGamma;
-   TH2F **hESDTrueEtaYEtaLowPtGamma;
-   TH2F **hESDTrueEtaYEtaHighPtGamma;
+   TH2F **hESDTruePi0PtOpenAngle;
+   TH2F **hESDTrueEtaPtOpenAngle;
    TH2F **hESDTrueMotherDalitzInvMassPt;
    TH1F **hESDTrueConvGammaPt;
    TH2F **hESDCombinatorialPt;
@@ -217,7 +214,7 @@ private:
    AliAnalysisTaskGammaConvV1 &operator=(const AliAnalysisTaskGammaConvV1&); // Prevent assignment
 
 
-   ClassDef(AliAnalysisTaskGammaConvV1, 8);
+   ClassDef(AliAnalysisTaskGammaConvV1, 9);
 };
 
 #endif
index 2642503edcdf395b3202519593285a5a453e198e..1414546e34a43c44cde9a8bfc59325e7ac4a9563 100644 (file)
@@ -689,8 +689,6 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
   Bool_t lpitmap[fAxistPt.GetNbins()][fMesonFilters[0].GetEntriesFast()];
   Bool_t upitmap[fAxistPt.GetNbins()][fMesonFilters[1].GetEntriesFast()];
   
-  
-
   for(Int_t igf = 0; igf < fV0Filters[0].GetEntriesFast(); igf++) {
     for(Int_t ptbin = 0; ptbin < fAxistPt.GetNbins(); ptbin++) {
       lv0tmap[ptbin][igf] = kFALSE;
@@ -899,10 +897,18 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
                  for(int ij = 0; ij < tracks->GetEntriesFast(); ij++) {
                    AliVTrack * track = static_cast<AliVTrack*>(tracks->At(ij));
                    Int_t tid = track->GetID();
-                 
-                   if((tid > 0) && (tid == tIDs[0] || tid == tIDs[1] || tid == tIDs[2] || tid == tIDs[3]) ) {
+
+
+                   if(tid == tIDs[0] || tid == tIDs[1] || tid == tIDs[2] || tid == tIDs[3])  {
                      continue;
                    }
+                   
+                   if(tid < 0) {
+                     if(-tid-1 == tIDs[0]+1 || -tid-1 == tIDs[1]+1 || -tid-1 == tIDs[2]+1 || -tid-1 == tIDs[3]+1)  {
+                       continue;
+                     }
+                   }
+                 
                  
                    dphivalues[0] = pion->Eta() - track->Eta();
                    dphivalues[1] = GetDPhi(pion->Phi() - track->Phi());
@@ -980,10 +986,16 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
                        AliVTrack * track = static_cast<AliVTrack*>(ttracks->At(ij));
                        Int_t tid = track->GetID();
                        
-                       if((tid > 0) && (tid == tIDs[0] || tid == tIDs[1] || tid == tIDs[2] || tid == tIDs[3]) ) {
+                       if(tid == tIDs[0] || tid == tIDs[1] || tid == tIDs[2] || tid == tIDs[3] ) {
                          continue;
                        }
-                       
+
+                       if(tid < 0) {
+                         if(-tid-1 == tIDs[0]+1 || -tid-1 == tIDs[1]+1 || -tid-1 == tIDs[2]+1 || -tid-1 == tIDs[3]+1)  {
+                           continue;
+                         }
+                       }
+                 
                        dphivalues[0] = pion->Eta() - track->Eta();
                        dphivalues[1] = GetDPhi(pion->Phi() - track->Phi());
                        dphivalues[3] = track->Pt();
@@ -1068,7 +1080,7 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
       for(Int_t iguf = 0; iguf < fV0Filters[1].GetEntriesFast(); iguf++) {
        if (uv0tmap[tbin][iguf] ) {
 
-         cout << "c vtx " <<  centrality << vertexz << endl;
+         //cout << "c vtx " <<  centrality << vertexz << endl;
 
          for(Int_t iTrack = 0; iTrack < ttracks->GetEntriesFast(); iTrack++) {
            AliVTrack * track = static_cast<AliVTrack*>(ttracks->At(iTrack));
@@ -1085,7 +1097,7 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
       for(Int_t ipuf = 0; ipuf < fMesonFilters[1].GetEntriesFast(); ipuf++) {
        if (upitmap[tbin][ipuf] ) {
 
-         cout << "c2 vtx2 " <<  centrality << vertexz << endl;
+         //cout << "c2 vtx2 " <<  centrality << vertexz << endl;
 
 
          for(Int_t iTrack = 0; iTrack < ttracks->GetEntriesFast(); iTrack++) {
@@ -1099,7 +1111,6 @@ void AliAnalysisTaskdPhi::UserExec(Option_t *) {
          }
        }
       }
-
     }
   }
 
index 5cf407e6cd36f2a54d61289d69108e9ff32d8a26..589befe9ff0972a5b0843c03efe1df7cae202222 100644 (file)
@@ -596,7 +596,7 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    }
    delete [] newBins;
 
-   hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",1000,0,100);
+   hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",100,0,100);
    fHistograms->Add(hCentrality);
    hCentralityVsNumberOfPrimaryTracks=new TH2F(Form("Centrality vs Primary Tracks %s",GetCutNumber().Data()),"Centrality vs Primary Tracks ",100,0,100,4000,0,4000);
    fHistograms->Add(hCentralityVsNumberOfPrimaryTracks);
@@ -1786,7 +1786,7 @@ Bool_t AliConversionCuts::InitializeCutsFromCutString(const TString analysisCutS
       if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
    }
 
-   //PrintCuts();
+   PrintCutsWithValues();
 
    return kTRUE;
 }
@@ -2013,6 +2013,69 @@ void AliConversionCuts::PrintCuts() {
       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
    }
 }
+
+void AliConversionCuts::PrintCutsWithValues() {
+   // Print out current Cut Selection with value
+   if (fIsHeavyIon == 0) {
+      printf("Running in pp mode \n");
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by V0OR will be analysed \n");
+      } else if (fSpecialTrigger == 1){
+        printf("\t only events triggered by V0AND will be analysed \n");
+      } else if (fSpecialTrigger == 2){
+         printf("\t only events where SDD was present will be analysed \n");
+      } else if (fSpecialTrigger == 3){
+         printf("\t only events where SDD was present will be analysed and triggered by VOAND\n");
+      } else if (fSpecialTrigger > 3){   
+         printf("\t only events triggered by %s \n", fSpecialTriggerName.Data());
+      }
+   } else if (fIsHeavyIon == 1){ 
+      printf("Running in PbPb mode \n");
+      if (fDetectorCentrality == 0){
+         printf("\t centrality selection based on V0M \n");
+      } else if (fDetectorCentrality == 1){
+         printf("\t centrality selection based on Cl1 \n");
+      }   
+      if (fModCentralityClass == 0){
+        printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
+      } else if ( fModCentralityClass == 1){ 
+        printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
+      } else if ( fModCentralityClass == 2){ 
+        printf("\t %d - %d \n", fCentralityMin*5+45, fCentralityMax*5+45);
+      } else if (fModCentralityClass == 3){
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
+      } else if ( fModCentralityClass == 4){ 
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
+      } else if ( fModCentralityClass == 5){ 
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5+45, fCentralityMax*5+45);
+      }
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by kMB, kCentral, kSemiCentral will be analysed \n");
+      } else if (fSpecialTrigger > 4){   
+         printf("\t only events triggered by %s \n", fSpecialTriggerName.Data());
+      }
+   } else if (fIsHeavyIon == 2){
+      printf("Running in pPb mode \n");
+      if (fDetectorCentrality == 0){
+         printf("\t centrality selection based on V0A \n");
+      } else if (fDetectorCentrality == 1){
+         printf("\t centrality selection based on Cl1 \n");
+      }   
+      if (fModCentralityClass == 0){
+        printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
+      }
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by kINT7 will be analysed \n");
+      } else if (fSpecialTrigger > 4){   
+         printf("\t only events triggered by %s \n", fSpecialTriggerName.Data());
+      }
+   }   
+   
+   
+   
+   
+}
+
 ///________________________________________________________________________
 Bool_t AliConversionCuts::SetIsHeavyIon(Int_t isHeavyIon)
 {   // Set Cut
@@ -3590,13 +3653,18 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
    AliGenCocktailEventHeader *cHeader = 0x0;
    AliAODMCHeader *cHeaderAOD = 0x0;
    Bool_t headerFound = kFALSE;
-
+   AliStack *fMCStack = 0x0;
+   TClonesArray *fMCStackAOD = 0x0;
    if(MCEvent->IsA()==AliMCEvent::Class()){
       cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
       if(cHeader) headerFound = kTRUE;
+      fMCStack = dynamic_cast<AliStack*>(dynamic_cast<AliMCEvent*>(MCEvent)->Stack());
    }
    if(MCEvent->IsA()==AliAODEvent::Class()){ // MCEvent is a AODEvent in case of AOD
       cHeaderAOD = dynamic_cast<AliAODMCHeader*>(MCEvent->FindListObject(AliAODMCHeader::StdBranchName()));
+      fMCStackAOD = dynamic_cast<TClonesArray*>(MCEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+      
+      
       if(cHeaderAOD) headerFound = kTRUE;
    }
 
@@ -3612,18 +3680,38 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
       }
       AliGenEventHeader* gh = 0;
       fnHeaders = 0;
+      Int_t firstindexA = 0;
+      Int_t lastindexA =  -1;
       if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
       if(rejection == 2){ // TList of Headers Names
          for(Int_t i = 0; i<genHeaders->GetEntries();i++){
             gh = (AliGenEventHeader*)genHeaders->At(i);
             TString GeneratorName = gh->GetName();
+            lastindexA = lastindexA + gh->NProduced();
+//             cout << i << "\t" << GeneratorName.Data() << endl;
             for(Int_t j = 0; j<HeaderList->GetEntries();j++){
                TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
                if(GeneratorName.CompareTo(GeneratorInList) == 0){
+                  if (GeneratorInList.CompareTo("PARAM") == 0){
+                     if(fMCStack){
+                        if (fMCStack->Particle(firstindexA)->GetPdgCode() == 111 || fMCStack->Particle(firstindexA)->GetPdgCode() == 221 ) {
+                           fnHeaders++;
+                           continue;
+                        }
+                     }   
+                     if ( fMCStackAOD){
+                        AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindexA));
+                        if (  aodMCParticle->GetPdgCode() == 111 || aodMCParticle->GetPdgCode() == 221 ){
+                           fnHeaders++;
+                           continue;
+                       }   
+                     }
+                  }
                   fnHeaders++;
                   continue;
                }
             }
+            firstindexA = firstindexA + gh->NProduced();
          }
       }
 
@@ -3640,7 +3728,7 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
 
       Int_t firstindex = 0;
       Int_t lastindex =  -1;
-      Int_t nummer = 0;
+      Int_t number = 0;
       for(Int_t i = 0; i<genHeaders->GetEntries();i++){
          gh = (AliGenEventHeader*)genHeaders->At(i);
          TString GeneratorName = gh->GetName();
@@ -3648,12 +3736,35 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
          for(Int_t j = 0; j<HeaderList->GetEntries();j++){
             TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
             if(GeneratorName.CompareTo(GeneratorInList) == 0){
-               fNotRejectedStart[nummer] = firstindex;
-               fNotRejectedEnd[nummer] = lastindex;
-               fGeneratorNames[nummer] = GeneratorName;
-               //cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
-               nummer++;
-               continue;
+               if (GeneratorInList.CompareTo("PARAM") == 0){
+                  if(fMCStack){
+                     if (fMCStack->Particle(firstindex)->GetPdgCode() == 111 || fMCStack->Particle(firstindex)->GetPdgCode() == 221 ) {
+                        fNotRejectedStart[number] = firstindex;
+                        fNotRejectedEnd[number] = lastindex;
+                        fGeneratorNames[number] = GeneratorName;
+                        number++;
+                        continue;
+                     }
+                  }   
+                  if ( fMCStackAOD){
+                     AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindex));
+                     if (  aodMCParticle->GetPdgCode() == 111 || aodMCParticle->GetPdgCode() == 221 ){
+                        fNotRejectedStart[number] = firstindex;
+                        fNotRejectedEnd[number] = lastindex;
+                        fGeneratorNames[number] = GeneratorName;
+                        number++;
+                        continue;
+                     }   
+                  }
+                     
+               } else {
+                  fNotRejectedStart[number] = firstindex;
+                  fNotRejectedEnd[number] = lastindex;
+                  fGeneratorNames[number] = GeneratorName;
+   //                cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
+                   number++;
+                  continue;
+               }
             }
          }
          firstindex = firstindex + gh->NProduced();
@@ -3754,7 +3865,8 @@ Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *Reade
 }
 //_________________________________________________________________________
 Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliStack *MCStack, AliVEvent *InputEvent){
-   if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 || period.CompareTo("LHC11a10a") == 0 || period.CompareTo("LHC11a10b") == 0 || period.CompareTo("LHC11a10b_bis") == 0 || period.CompareTo("LHC11a10a_bis") == 0 || period.CompareTo("LHC11a10b_plus") == 0 || period.Contains("LHC13d2"))) return 1.;
+   if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 || period.CompareTo("LHC11a10a") == 0 || period.CompareTo("LHC11a10b") == 0 || period.CompareTo("LHC11a10b_bis") == 0 || period.CompareTo("LHC11a10a_bis") == 0 || period.CompareTo("LHC11a10b_plus") == 0 || period.Contains("LHC13d2") || 
+   period.CompareTo("LHC13e7") == 0 || period.Contains("LHC13b2_efix"))) return 1.;
 
    Int_t kCaseGen = 0;
    for (Int_t i = 0; i < fnHeaders; i++){
@@ -3780,7 +3892,7 @@ Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliSta
          } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Hijing") == 0){
             kCaseGen = 3;
          }
-         if (period.Contains("LHC13d2")){
+         if (period.Contains("LHC13d2") || period.CompareTo("LHC13e7") == 0 || period.Contains("LHC13b2_efix") ){
             kCaseGen = 3;
          }
       }
@@ -3901,8 +4013,15 @@ Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliSta
       if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
          weight = functionResultData/functionResultMC;
          if ( kCaseGen == 3){
-            if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode ==  111)){
-               weight = 1.;
+            if (PDGCode ==  111){ 
+               if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode ==  111)){
+                  weight = 1.;
+               }
+            } 
+            if (PDGCode ==  221){ 
+               if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode ==  221)){
+                  weight = 1.;
+               }
             }
          }
          if (!isfinite(functionResultData)) weight = 1.;
index a53c5f30b530dff654edaee7af60ac3faaa0c2f0..97850e93ca35ff43c09126975febf59519bcea3c 100644 (file)
@@ -148,6 +148,7 @@ class AliConversionCuts : public AliAnalysisCuts {
    AliPIDResponse * GetPIDResponse() { return fPIDResponse;}
    
    void PrintCuts();
+   void PrintCutsWithValues();
 
    void InitCutHistograms(TString name="",Bool_t preCut = kTRUE);
    void SetFillCutHistograms(TString name="",Bool_t preCut = kTRUE){if(!fHistograms){InitCutHistograms(name,preCut);};}
index fa0495009f866b946f76e3d7308a3b3a92e857bc..47a6ef5136535ead03d880d344411cb67bca5bd6 100644 (file)
@@ -56,13 +56,14 @@ AliConversionTrackCuts::AliConversionTrackCuts() :
   fOwnedTracks(),
   fInitialized(kFALSE),
   fhPhi(NULL),
-  fhPt(NULL),
-  fhPhiPt(NULL),
+  //  fhPt(NULL),
+  //fhPhiPt(NULL),
   fhdcaxyPt(NULL),
   fhdcazPt(NULL),
   fhdca(NULL),
   fhnclpt(NULL),
   fhnclsfpt(NULL),
+  fhEtaPhi(NULL),
   fHistograms(NULL) 
 {
   //Constructor
@@ -81,13 +82,14 @@ AliConversionTrackCuts::AliConversionTrackCuts(TString name, TString title = "ti
   fOwnedTracks(),
   fInitialized(kFALSE),
   fhPhi(NULL),  
-  fhPt(NULL),
-  fhPhiPt(NULL),
+  //fhPt(NULL),
+  //fhPhiPt(NULL),
   fhdcaxyPt(NULL),
   fhdcazPt(NULL),
   fhdca(NULL),
   fhnclpt(NULL),
   fhnclsfpt(NULL),
+  fhEtaPhi(NULL),
   fHistograms(NULL)
 {
   //Constructor
@@ -275,57 +277,77 @@ Bool_t AliConversionTrackCuts::AcceptTrack(AliESDtrack * track) {
 
 Bool_t AliConversionTrackCuts::AcceptTrack(AliAODTrack * track) {
   //Check aod track
+
   FillHistograms(kPreCut, track);
-  if(!track->TestFilterBit(fFilterBit)) {
-    return kFALSE;
-  }
 
+  if(!track->IsHybridGlobalConstrainedGlobal()) return kFALSE;
 
+   if (!(track->GetStatus() & AliVTrack::kITSrefit)) {
+     return kFALSE;
+   }
 
 
-  ///Do dca xy cut!
-  FillHistograms(1, track);
-  return kTRUE;
+  //The cluster sharing cut can be done with:
+  Double_t frac = Double_t(track->GetTPCnclsS()) / Double_t(track->GetTPCncls());
+  if (frac > 0.4) return kFALSE;
 
 
-  // if (track->GetTPCNcls() < fTPCminNClusters) return kFALSE;
-  // FillHistograms(kCutNcls, track);
-
-  // if (track->Chi2perNDF() > fTPCmaxChi2) return kFALSE;
-  // FillHistograms(kCutNDF, track);
+  ///Do dca xy cut!
+  FillHistograms(1, track);
 
-  // AliAODVertex *vertex = track->GetProdVertex();
-  // if (vertex && fRejectKinkDaughters) {
-  //   if (vertex->GetType() == AliAODVertex::kKink) {
-  //     return kFALSE;
-  //   }
-  // }
-  // FillHistograms(kCutKinc, track);
+  ///DCA
+  Double_t dca[2] = { -999, -999};
+  //Bool_t dcaok = 
+  GetDCA(track, dca);
+  FillDCAHist(dca[1], dca[0], track);
   
-  // if(TMath::Abs(track->ZAtDCA()) > fDCAZmax) {
-  //   return kFALSE;
-  // }
-  // FillHistograms(kCutDCAZ, track);
-
-  // Float_t xatdca = track->XAtDCA();
-  // Float_t yatdca = track->YAtDCA();
-  // Float_t xy = xatdca*xatdca + yatdca*yatdca;
-  // if(xy > fDCAXYmax) {
-  //   return kFALSE;
-  // }
-
-  // FillHistograms(kCutDCAXY, track);
-
-
-  // fhnclpt->Fill(track->Pt(), track->GetTPCNcls());
-  // if(track->GetTPCNclsF() > 0) fhnclsfpt->Fill(track->Pt(), ((Double_t) track->GetTPCNcls())/track->GetTPCNclsF());
-  // FillDCAHist(track->ZAtDCA(), TMath::Sqrt(track->XAtDCA()*track->XAtDCA() + track->YAtDCA()*track->YAtDCA()), track);
 
+  if(track->IsGlobalConstrained()) {
+    FillHistograms(3, track);
+  } else {
+    FillHistograms(2, track);
+  }
+  
+  if(fhEtaPhi) fhEtaPhi->Fill(track->Eta(), track->Phi());
 
+  return kTRUE;
 }
 
+///______________________________________________________________________________
+Bool_t AliConversionTrackCuts::GetDCA(const AliAODTrack *track, Double_t dca[2]) {
+  if(track->TestBit(AliAODTrack::kIsDCA)){
+    dca[0]=track->DCA();
+    dca[1]=track->ZAtDCA();
+    return kTRUE;
+  }
+  
+  Bool_t ok=kFALSE;
+  if(fEvent) {
+    Double_t covdca[3];
+    //AliAODTrack copy(*track);
+    AliExternalTrackParam etp; etp.CopyFromVTrack(track);
+    
+    Float_t xstart = etp.GetX();
+    if(xstart>3.) {
+      dca[0]=-999.;
+    dca[1]=-999.;
+    //printf("This method can be used only for propagation inside the beam pipe \n");
+    return kFALSE;
+    }
 
 
+    AliAODVertex *vtx =(AliAODVertex*)(fEvent->GetPrimaryVertex());
+    Double_t fBzkG = fEvent->GetMagneticField(); // z componenent of field in kG
+    ok = etp.PropagateToDCA(vtx,fBzkG,kVeryBig,dca,covdca);
+    //ok = copy.PropagateToDCA(vtx,fBzkG,kVeryBig,dca,covdca);
+  }
+  if(!ok){
+    dca[0]=-999.;
+    dca[1]=-999.;
+  }
+  return ok;
+}
 
 
 
@@ -345,6 +367,8 @@ TList * AliConversionTrackCuts::CreateHistograms() {
   fHistograms->Add(fhPhi);
   
 
+  fhEtaPhi = new TH2F("etahpi", "etaphi", 36, -0.9, 0.9, 32, 0, TMath::TwoPi());
+  fHistograms->Add(fhEtaPhi);
 
   // fhPt = new TH2F("pt", "pt", kNCuts+2, kPreCut -0.5, kNCuts + 0.5, 
   //                             20, 0., 20.);
@@ -357,14 +381,18 @@ TList * AliConversionTrackCuts::CreateHistograms() {
   //  fhPhiPt = new TH2F("phipt", "phipt", 100, 0, 100, 64, 0, TMath::TwoPi());
   //fHistograms->Add(fhPhiPt);
 
-  // fhdcaxyPt = new TH2F("dcaxypt", "dcaxypt", 20, 0, 20, 50, 0, 5);
-  // fHistograms->Add(fhdcaxyPt);
+  fhdcaxyPt = new TH2F("dcaxypt", "dcaxypt", 20, 0, 20, 50, -2.5, 2.5);
+  fHistograms->Add(fhdcaxyPt);
 
-  // fhdcazPt = new TH2F("dcazpt", "dcazpt", 20, 0, 20, 50, 0, 5);
-  // fHistograms->Add(fhdcazPt);
+  fhdcazPt = new TH2F("dcazpt", "dcazpt", 20, 0, 20, 70, -3.5, 3.5);
+  fHistograms->Add(fhdcazPt);
 
-  // fhdca = new TH2F("dca", "dca", 60, -3, 3, 60, -3, 3);
-  // fHistograms->Add(fhdca);
+  fhdca = new TH2F("dca", "dca", 70, -3.5, 3.5, 50, -2.5, 2.5);
+  fhdca->SetXTitle("dca z");
+  fhdca->SetYTitle("dca xy");
+
+  
+  fHistograms->Add(fhdca);
 
   // fhnclpt = new TH2F("nclstpcvspt", "nclstpcvspt", 20, 0, 20, 50, 0, 100);
   // fHistograms->Add(fhnclpt);
index 195cd00781c4954c29bd86d67f8df555b202a774..03a3f930eceae7f677b76f8e3f4e805d93e98b7c 100644 (file)
@@ -42,6 +42,8 @@ public:
   Bool_t IsSelected(TList * /*list*/) { return kFALSE; }
   Bool_t AcceptTrack(AliAODTrack * track);
   Bool_t AcceptTrack(AliESDtrack * track);
+  Bool_t GetDCA(const AliAODTrack * track, Double_t dca[2]);
+
 
   void DeleteTracks() { fOwnedTracks.Delete(); }
   void FillDCAHist(Float_t dcaz, Float_t dcaxy, AliVTrack * track);
@@ -82,20 +84,21 @@ protected :
   Bool_t fInitialized;
 
   TH2F * fhPhi;
-  TH2F * fhPt;
-  TH2F * fhPhiPt;
+  //TH2F * fhPt;
+  //TH2F * fhPhiPt;
   TH2F * fhdcaxyPt;
   TH2F * fhdcazPt;
   TH2F * fhdca;
   TH2F * fhnclpt;
   TH2F * fhnclsfpt;
+  TH2F * fhEtaPhi;
   
   TList * fHistograms;
 
   AliConversionTrackCuts(const AliConversionTrackCuts&); // not implemented
   AliConversionTrackCuts& operator=(const AliConversionTrackCuts&); // not implemented
 
-  ClassDef(AliConversionTrackCuts,3)
+  ClassDef(AliConversionTrackCuts,4)
 };
 
 #endif
index 9efde781770e02499a10aaf0b396943e13537c48..70f6e574d4070cf6a020327c98c408174188674a 100644 (file)
@@ -4,7 +4,8 @@ void AddTask_GammaConvV1_PbPb(  Int_t trainConfig = 1,  //change different set o
                               Int_t enableQAPhotonTask = 0, // enable additional QA task
                               TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
                               Bool_t doWeighting = kFALSE,  //enable Weighting
-                              TString cutnumberAODBranch = "1000000060084000001500000" 
+                              TString cutnumberAODBranch = "1000000060084000001500000",
+                              TString periodName = "LHC13d2"
                            ) {
 
    // ================= Load Librariers =================================
@@ -444,6 +445,24 @@ void AddTask_GammaConvV1_PbPb(  Int_t trainConfig = 1,  //change different set o
       cutarray[ 2] = "5450001002092970028250400000"; mesonCutArray[ 2] = "01525065009000"; // 40-50% 
       cutarray[ 3] = "5560001002092970028250400000"; mesonCutArray[ 3] = "01525065009000"; // 50-60% 
       cutarray[ 4] = "5670001002092970028250400000"; mesonCutArray[ 4] = "01525065009000"; // 60-70%                
+   } else if ( trainConfig == 59){ // cleaner cuts
+      cutarray[ 0] = "6010002002092970028250400000"; mesonCutArray[ 0] = "01525065009000"; // 0-5%
+      cutarray[ 1] = "6120002002092970028250400000"; mesonCutArray[ 1] = "01525065009000"; // 5-10%
+      cutarray[ 2] = "5010002002092970028250400000"; mesonCutArray[ 2] = "01525065009000"; // 0-10%
+      cutarray[ 3] = "5120002002092970028250400000"; mesonCutArray[ 3] = "01525065009000"; // 10-20%
+      cutarray[ 4] = "5020002002092970028250400000"; mesonCutArray[ 4] = "01525065009000"; // 0-20%
+   } else if ( trainConfig == 60) { // cleaner cuts
+      cutarray[ 0] = "5240002002092970028250400000"; mesonCutArray[ 0] = "01525065009000"; // 20-40%
+      cutarray[ 1] = "5460002002092970028250400000"; mesonCutArray[ 1] = "01525065009000"; // 40-60%
+      cutarray[ 2] = "5680002002092970028250400000"; mesonCutArray[ 2] = "01525065009000"; // 60-80%
+      cutarray[ 3] = "5480002002092970028250400000"; mesonCutArray[ 3] = "01525065009000"; // 40-80%
+      cutarray[ 4] = "5350002002092970028250400000"; mesonCutArray[ 4] = "01525065009000"; // 30-50%  
+   } else if ( trainConfig == 61){ // cleaner cuts
+      cutarray[ 0] = "5230002002092970028250400000"; mesonCutArray[ 0] = "01525065009000"; // 20-30% 
+      cutarray[ 1] = "5340002002092970028250400000"; mesonCutArray[ 1] = "01525065009000"; // 30-40% 
+      cutarray[ 2] = "5450002002092970028250400000"; mesonCutArray[ 2] = "01525065009000"; // 40-50% 
+      cutarray[ 3] = "5560002002092970028250400000"; mesonCutArray[ 3] = "01525065009000"; // 50-60% 
+      cutarray[ 4] = "5670002002092970028250400000"; mesonCutArray[ 4] = "01525065009000"; // 60-70%                   
    } else {
       Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
       return;
@@ -453,10 +472,16 @@ void AddTask_GammaConvV1_PbPb(  Int_t trainConfig = 1,  //change different set o
    TList *MesonCutList = new TList();
 
    TList *HeaderList = new TList();
-   TObjString *Header1 = new TObjString("pi0_1");
-   HeaderList->Add(Header1);
-//    TObjString *Header3 = new TObjString("eta_2");
-//    HeaderList->Add(Header3);
+   if (periodName.CompareTo("LHC13d2")==0){
+      TObjString *Header1 = new TObjString("pi0_1");
+      HeaderList->Add(Header1);
+   //    TObjString *Header3 = new TObjString("eta_2");
+   //    HeaderList->Add(Header3);
+
+   } else if (periodName.CompareTo("LHC12a17x_fix")==0){
+      TObjString *Header1 = new TObjString("PARAM");
+      HeaderList->Add(Header1);
+   }
    
    ConvCutList->SetOwner(kTRUE);
    AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
index 66f47e7c4672606e70d5f157d8263c5acc026aba..9cc9beb89344018feef526dfbd1717e84733de2f 100644 (file)
@@ -3,6 +3,8 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
                               Int_t enableQAMesonTask = 0, //enable QA in AliAnalysisTaskGammaConvV1
                               Int_t enableQAPhotonTask = 0, // enable additional QA task
                               TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
+                              Bool_t doWeighting = kFALSE,  //enable Weighting
+                              TString generatorName = "DPMJET",
                               TString cutnumberAODBranch = "8000000060084000001500000" // cutnumber for AOD branch
                            ) {
  
@@ -103,76 +105,96 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
       // Shifting in pPb direction
       doEtaShiftIndCuts = kTRUE;
       stringShift = "pPb";
-      cutarray[ 0] = "8000001082093172003290000000"; mesonCutArray[ 0] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 1] = "8020001082093172003290000000"; mesonCutArray[ 1] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 2] = "8240001082093172003290000000"; mesonCutArray[ 2] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 3] = "8460001082093172003290000000"; mesonCutArray[ 3] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 4] = "8680001082093172003290000000"; mesonCutArray[ 4] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 5] = "8600001082093172003290000000"; mesonCutArray[ 5] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 0] = "8000011082093172003290000000"; mesonCutArray[ 0] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 1] = "8020011082093172003290000000"; mesonCutArray[ 1] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 2] = "8240011082093172003290000000"; mesonCutArray[ 2] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 3] = "8460011082093172003290000000"; mesonCutArray[ 3] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 4] = "8680011082093172003290000000"; mesonCutArray[ 4] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 5] = "8600011082093172003290000000"; mesonCutArray[ 5] = "01629045009000";  //standard cut Pi0 pPb
    } else if (trainConfig == 2) {
      // doEtaShiftIndCuts = kTRUE;
      // stringShift = "pPb";
-      cutarray[ 0] = "8000001072093172003290000000"; mesonCutArray[ 0] = "01627045009000"; 
-      cutarray[ 1] = "8020001072093172003290000000"; mesonCutArray[ 1] = "01627045009000"; 
-      cutarray[ 2] = "8240001072093172003290000000"; mesonCutArray[ 2] = "01627045009000"; 
-      cutarray[ 3] = "8460001072093172003290000000"; mesonCutArray[ 3] = "01627045009000"; 
-      cutarray[ 4] = "8680001072093172003290000000"; mesonCutArray[ 4] = "01627045009000"; 
-      cutarray[ 5] = "8600001072093172003290000000"; mesonCutArray[ 5] = "01627045009000"; 
+      cutarray[ 0] = "8000011072093172003290000000"; mesonCutArray[ 0] = "01627045009000"; 
+      cutarray[ 1] = "8020011072093172003290000000"; mesonCutArray[ 1] = "01627045009000"; 
+      cutarray[ 2] = "8240011072093172003290000000"; mesonCutArray[ 2] = "01627045009000"; 
+      cutarray[ 3] = "8460011072093172003290000000"; mesonCutArray[ 3] = "01627045009000"; 
+      cutarray[ 4] = "8680011072093172003290000000"; mesonCutArray[ 4] = "01627045009000"; 
+      cutarray[ 5] = "8600011072093172003290000000"; mesonCutArray[ 5] = "01627045009000"; 
    } else if (trainConfig == 3) {
      // doEtaShiftIndCuts = kTRUE;
      //  stringShift = "pPb";
-      cutarray[ 0] = "8000001002093172003290000000"; mesonCutArray[ 0] = "01621035009000"; 
-      cutarray[ 1] = "8020001002093172003290000000"; mesonCutArray[ 1] = "01621035009000"; 
-      cutarray[ 2] = "8240001002093172003290000000"; mesonCutArray[ 2] = "01621035009000"; 
-      cutarray[ 3] = "8460001002093172003290000000"; mesonCutArray[ 3] = "01621035009000"; 
-      cutarray[ 4] = "8680001002093172003290000000"; mesonCutArray[ 4] = "01621035009000"; 
-      cutarray[ 5] = "8600001002093172003290000000"; mesonCutArray[ 5] = "01621035009000"; 
+      cutarray[ 0] = "8000011002093172003290000000"; mesonCutArray[ 0] = "01621035009000"; 
+      cutarray[ 1] = "8020011002093172003290000000"; mesonCutArray[ 1] = "01621035009000"; 
+      cutarray[ 2] = "8240011002093172003290000000"; mesonCutArray[ 2] = "01621035009000"; 
+      cutarray[ 3] = "8460011002093172003290000000"; mesonCutArray[ 3] = "01621035009000"; 
+      cutarray[ 4] = "8680011002093172003290000000"; mesonCutArray[ 4] = "01621035009000"; 
+      cutarray[ 5] = "8600011002093172003290000000"; mesonCutArray[ 5] = "01621035009000"; 
    } else if(trainConfig == 4){
       // Shifting in pPb direction
       doEtaShiftIndCuts = kTRUE;
       stringShift = "pPb";
-      cutarray[ 0] = "8000002082093172003290000000"; mesonCutArray[ 0] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 1] = "8020002082093172003290000000"; mesonCutArray[ 1] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 2] = "8240002082093172003290000000"; mesonCutArray[ 2] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 3] = "8460002082093172003290000000"; mesonCutArray[ 3] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 4] = "8680002082093172003290000000"; mesonCutArray[ 4] = "01629045009000";  //standard cut Pi0 pPb
-      cutarray[ 5] = "8600002082093172003290000000"; mesonCutArray[ 5] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 0] = "8000012082093172003290000000"; mesonCutArray[ 0] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 1] = "8020012082093172003290000000"; mesonCutArray[ 1] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 2] = "8240012082093172003290000000"; mesonCutArray[ 2] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 3] = "8460012082093172003290000000"; mesonCutArray[ 3] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 4] = "8680012082093172003290000000"; mesonCutArray[ 4] = "01629045009000";  //standard cut Pi0 pPb
+      cutarray[ 5] = "8600012082093172003290000000"; mesonCutArray[ 5] = "01629045009000";  //standard cut Pi0 pPb
    } else if (trainConfig == 5) {
      // doEtaShiftIndCuts = kTRUE;
      // stringShift = "pPb";
-      cutarray[ 0] = "8000002072093172003290000000"; mesonCutArray[ 0] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 1] = "8020002072093172003290000000"; mesonCutArray[ 1] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 2] = "8240002072093172003290000000"; mesonCutArray[ 2] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 3] = "8460002072093172003290000000"; mesonCutArray[ 3] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 4] = "8680002072093172003290000000"; mesonCutArray[ 4] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 5] = "8600002072093172003290000000"; mesonCutArray[ 5] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 0] = "8000012072093172003290000000"; mesonCutArray[ 0] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 1] = "8020012072093172003290000000"; mesonCutArray[ 1] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 2] = "8240012072093172003290000000"; mesonCutArray[ 2] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 3] = "8460012072093172003290000000"; mesonCutArray[ 3] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 4] = "8680012072093172003290000000"; mesonCutArray[ 4] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 5] = "8600012072093172003290000000"; mesonCutArray[ 5] = "01627045009000";  //standard cut Pi0 pPb Single pT Cut changed
    } else if (trainConfig == 6) {
      // doEtaShiftIndCuts = kTRUE;
      //  stringShift = "pPb";
-      cutarray[ 0] = "8000002002093172003290000000"; mesonCutArray[ 0] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 1] = "8020002002093172003290000000"; mesonCutArray[ 1] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 2] = "8240002002093172003290000000"; mesonCutArray[ 2] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 3] = "8460002002093172003290000000"; mesonCutArray[ 3] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 4] = "8680002002093172003290000000"; mesonCutArray[ 4] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
-      cutarray[ 5] = "8600002002093172003290000000"; mesonCutArray[ 5] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 0] = "8000012002093172003290000000"; mesonCutArray[ 0] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 1] = "8020012002093172003290000000"; mesonCutArray[ 1] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 2] = "8240012002093172003290000000"; mesonCutArray[ 2] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 3] = "8460012002093172003290000000"; mesonCutArray[ 3] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 4] = "8680012002093172003290000000"; mesonCutArray[ 4] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
+      cutarray[ 5] = "8600012002093172003290000000"; mesonCutArray[ 5] = "01621035009000";  //standard cut Pi0 pPb Single pT Cut changed
    } else if (trainConfig == 7) {
      // doEtaShiftIndCuts = kTRUE;
      //  stringShift = "pPb";
-      cutarray[ 0] = "8000001002092970023220000000"; mesonCutArray[ 0] = "01621035009000"; 
-      cutarray[ 1] = "8000001002093663003800000000"; mesonCutArray[ 1] = "01621035009000"; 
-      cutarray[ 2] = "8000001002093260003800000000"; mesonCutArray[ 2] = "01621035009000"; 
-      cutarray[ 3] = "8000001002092370023220000000"; mesonCutArray[ 3] = "01621035009000";                       
-      cutarray[ 4] = "8000001002092770023220000000"; mesonCutArray[ 4] = "01621035009000";                       
-      cutarray[ 5] = "8000001002092551023220000000"; mesonCutArray[ 5] = "01621035009000";                       
+      cutarray[ 0] = "8000011002092970023220000000"; mesonCutArray[ 0] = "01621035009000"; 
+      cutarray[ 1] = "8000011002093663003800000000"; mesonCutArray[ 1] = "01621035009000"; 
+      cutarray[ 2] = "8000011002093260003800000000"; mesonCutArray[ 2] = "01621035009000"; 
+      cutarray[ 3] = "8000011002092370023220000000"; mesonCutArray[ 3] = "01621035009000";                       
+      cutarray[ 4] = "8000011002092770023220000000"; mesonCutArray[ 4] = "01621035009000";                       
+      cutarray[ 5] = "8000011002092551023220000000"; mesonCutArray[ 5] = "01621035009000";                       
    } else if (trainConfig == 8) {
      // doEtaShiftIndCuts = kTRUE;
      //  stringShift = "pPb";
-      cutarray[ 0] = "8000002002092970023220000000"; mesonCutArray[ 0] = "01621035009000"; 
-      cutarray[ 1] = "8000002002093663003800000000"; mesonCutArray[ 1] = "01621035009000"; 
-      cutarray[ 2] = "8000002002093260003800000000"; mesonCutArray[ 2] = "01621035009000"; 
-      cutarray[ 3] = "8000002002092370023220000000"; mesonCutArray[ 3] = "01621035009000";                       
-      cutarray[ 4] = "8000002002092770023220000000"; mesonCutArray[ 4] = "01621035009000";                       
-      cutarray[ 5] = "8000002002092551023220000000"; mesonCutArray[ 5] = "01621035009000";                          
+      cutarray[ 0] = "8000012002092970023220000000"; mesonCutArray[ 0] = "01621035009000"; 
+      cutarray[ 1] = "8000012002093663003800000000"; mesonCutArray[ 1] = "01621035009000"; 
+      cutarray[ 2] = "8000012002093260003800000000"; mesonCutArray[ 2] = "01621035009000"; 
+      cutarray[ 3] = "8000012002092370023220000000"; mesonCutArray[ 3] = "01621035009000";                       
+      cutarray[ 4] = "8000012002092770023220000000"; mesonCutArray[ 4] = "01621035009000";                       
+      cutarray[ 5] = "8000012002092551023220000000"; mesonCutArray[ 5] = "01621035009000";                          
+   } else if (trainConfig == 9) {
+     // doEtaShiftIndCuts = kTRUE;
+     //  stringShift = "pPb";
+      cutarray[ 0] = "8000011002092170003220000000"; mesonCutArray[ 0] = "01621035009000"; //just tighten Psi pair
+      cutarray[ 1] = "8000011002092170003260000000"; mesonCutArray[ 1] = "01621035009000"; //tighten Psi pair and chi2 in 2D
+      cutarray[ 2] = "8000011002092170008220000000"; mesonCutArray[ 2] = "01621035009000"; //tighten psi pair and qt in 2D
+      cutarray[ 3] = "8000011002092170008260000000"; mesonCutArray[ 3] = "01621035009000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+      cutarray[ 4] = "8000011002092170008220400000"; mesonCutArray[ 4] = "01621035009000"; //clean cuts
+      cutarray[ 5] = "8000011002092170008260400000"; mesonCutArray[ 5] = "01621035009000"; //clean cuts
+      
+   } else if (trainConfig == 10) {
+     // doEtaShiftIndCuts = kTRUE;
+     //  stringShift = "pPb";
+      cutarray[ 0] = "8000012002092170003220000000"; mesonCutArray[ 0] = "01621035009000"; //just tighten Psi pair
+      cutarray[ 1] = "8000012002092170003260000000"; mesonCutArray[ 1] = "01621035009000"; //tighten Psi pair and chi2 in 2D
+      cutarray[ 2] = "8000012002092170008220000000"; mesonCutArray[ 2] = "01621035009000"; //tighten psi pair and qt in 2D
+      cutarray[ 3] = "8000012002092170008260000000"; mesonCutArray[ 3] = "01621035009000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+      cutarray[ 4] = "8000012002092170008220400000"; mesonCutArray[ 4] = "01621035009000"; //clean cuts
+      cutarray[ 5] = "8000012002092170008260400000"; mesonCutArray[ 5] = "01621035009000"; //clean cuts
+            
    } else {
       Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
       return;
@@ -196,6 +218,89 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
    for(Int_t i = 0; i<numberOfCuts; i++){
      
       analysisCuts[i] = new AliConversionCuts();
+      if (trainConfig == 1 ||trainConfig == 2 || trainConfig == 3 ){
+         if (i == 0 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+            }
+         }
+         if (i == 1 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_0020V0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_0020V0A", "","Pi0_Fit_Data_pPb_5023GeV_0020V0A","Eta_Fit_Data_pPb_5023GeV_0020V0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_0020V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_0020V0A", "","Pi0_Fit_Data_pPb_5023GeV_0020V0A","Eta_Fit_Data_pPb_5023GeV_0020V0A");
+            }
+         }
+         if (i == 2 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_2040V0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_2040V0A", "","Pi0_Fit_Data_pPb_5023GeV_2040V0A","Eta_Fit_Data_pPb_5023GeV_2040V0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_2040V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_2040V0A", "","Pi0_Fit_Data_pPb_5023GeV_2040V0A","Eta_Fit_Data_pPb_5023GeV_2040V0A");
+            }
+         }
+         if (i == 3 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_4060V0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_4060V0A", "","Pi0_Fit_Data_pPb_5023GeV_4060V0A","Eta_Fit_Data_pPb_5023GeV_4060V0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_4060V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_4060V0A", "","Pi0_Fit_Data_pPb_5023GeV_4060V0A","Eta_Fit_Data_pPb_5023GeV_4060V0A");
+            }
+         }
+         if (i == 4 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_6080V0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_6080V0A", "","Pi0_Fit_Data_pPb_5023GeV_6080V0A","Eta_Fit_Data_pPb_5023GeV_6080V0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_6080V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_6080V0A", "","Pi0_Fit_Data_pPb_5023GeV_6080V0A","Eta_Fit_Data_pPb_5023GeV_6080V0A");
+            }
+         }
+         if (i == 5 && doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_60100V0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_60100V0A", "","Pi0_Fit_Data_pPb_5023GeV_60100V0A","Eta_Fit_Data_pPb_5023GeV_60100V0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_60100V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_60100V0A", "","Pi0_Fit_Data_pPb_5023GeV_60100V0A","Eta_Fit_Data_pPb_5023GeV_60100V0A");
+            }
+         }
+      }
+      if (trainConfig == 4 ||trainConfig == 5 || trainConfig == 6 ){
+         if (i == 0 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+           
+         }
+         if (i == 1 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_0020V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_0020V0A", "","Pi0_Fit_Data_pPb_5023GeV_0020V0A","Eta_Fit_Data_pPb_5023GeV_0020V0A");
+            
+         }
+         if (i == 2 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_2040V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_2040V0A", "","Pi0_Fit_Data_pPb_5023GeV_2040V0A","Eta_Fit_Data_pPb_5023GeV_2040V0A");
+            
+         }
+         if (i == 3 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_4060V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_4060V0A", "","Pi0_Fit_Data_pPb_5023GeV_4060V0A","Eta_Fit_Data_pPb_5023GeV_4060V0A");
+         }
+         if (i == 4 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_6080V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_6080V0A", "","Pi0_Fit_Data_pPb_5023GeV_6080V0A","Eta_Fit_Data_pPb_5023GeV_6080V0A");
+         }
+         if (i == 5 && doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_60100V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_60100V0A", "","Pi0_Fit_Data_pPb_5023GeV_60100V0A","Eta_Fit_Data_pPb_5023GeV_60100V0A");
+         }
+      }
+      if (trainConfig == 7 || trainConfig == 9 ){
+         if (doWeighting){
+            if (generatorName.CompareTo("DPMJET")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+            } else if (generatorName.CompareTo("HIJING")==0){
+               analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+            }
+         }
+      }   
+      if (trainConfig == 8 || trainConfig == 10){
+         if (doWeighting){
+            analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
+         }
+         
+      }   
+         
       analysisCuts[i]->InitializeCutsFromCutString(cutarray[i].Data());
       if (doEtaShiftIndCuts) {
          analysisCuts[i]->DoEtaShift(doEtaShiftIndCuts);
index 5ea146d935a8a1a1dc2140e7bc29cd489cb59827..8877e0c3b44cda795eae16988a0d4fe53d044817 100644 (file)
@@ -230,7 +230,7 @@ Bool_t AliHFAssociatedTrackCuts::IsInAcceptance()
        return kFALSE;\r
 }\r
 //--------------------------------------------------------------------------\r
-Bool_t AliHFAssociatedTrackCuts::IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary,const Double_t magfield)\r
+Bool_t AliHFAssociatedTrackCuts::IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary, Double_t magfield)\r
 {\r
   \r
   AliESDtrack esdtrack(track);\r
index 0669a8e6c20f5c7fb5555a4ce896a1240c63fa81..ec8961a2c372726389958d625c57a2fe289c4203 100644 (file)
@@ -54,7 +54,7 @@ class AliHFAssociatedTrackCuts : public AliAnalysisCuts
        Bool_t IsSelected(TList*  list) {if(list) return kTRUE; return kFALSE;};\r
        Bool_t IsSelected(TObject*  obj) {if(obj) return kTRUE; return kFALSE;};\r
        Bool_t IsInAcceptance();\r
-       Bool_t IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary=0x0,const Double_t magfield=0);\r
+       Bool_t IsHadronSelected(AliAODTrack * track,const AliESDVertex *primary=0x0, Double_t magfield=0);\r
        Bool_t CheckHadronKinematic(Double_t pt, Double_t d0); \r
        Bool_t Charge(Short_t charge, AliAODTrack* track);\r
        Bool_t CheckKaonCompatibility(AliAODTrack * track, Bool_t useMc, TClonesArray* mcArray, Int_t method=1);\r
index 6cb69e06463ce530dbab59b0ce62e175eaea2e8a..295e45fa40ed16cd33abd18033444d1b6f8ab74d 100644 (file)
@@ -53,6 +53,7 @@ AliHFEpidTRD::AliHFEpidTRD() :
   , fRunNumber(0)
   , fElectronEfficiency(0.90)
   , fTotalChargeInSlice0(kFALSE)
+  , fTRDOldPIDMethod(kFALSE)
   , fTRD2DPID(kFALSE)
 {
   //
@@ -71,6 +72,7 @@ AliHFEpidTRD::AliHFEpidTRD(const char* name) :
   , fRunNumber(0)
   , fElectronEfficiency(0.91)
   , fTotalChargeInSlice0(kFALSE)
+  , fTRDOldPIDMethod(kFALSE)
   , fTRD2DPID(kFALSE)
 {
   //
@@ -89,6 +91,7 @@ AliHFEpidTRD::AliHFEpidTRD(const AliHFEpidTRD &ref):
   , fRunNumber(ref.fRunNumber)
   , fElectronEfficiency(ref.fElectronEfficiency)
   , fTotalChargeInSlice0(ref.fTotalChargeInSlice0)
+  , fTRDOldPIDMethod(ref.fTRDOldPIDMethod)
   , fTRD2DPID(ref.fTRD2DPID)
 {
   //
@@ -121,6 +124,7 @@ void AliHFEpidTRD::Copy(TObject &ref) const {
   target.fCutNTracklets = fCutNTracklets;
   target.fRunNumber = fRunNumber;
   target.fTotalChargeInSlice0 = fTotalChargeInSlice0;
+  target.fTRDOldPIDMethod = fTRDOldPIDMethod;
   target.fTRD2DPID = fTRD2DPID;
   target.fElectronEfficiency = fElectronEfficiency;
   memcpy(target.fThreshParams, fThreshParams, sizeof(Double_t) * kThreshParams);
@@ -141,9 +145,8 @@ Bool_t AliHFEpidTRD::InitializePID(Int_t run){
   //
   //
 
-  //if(fTRD2DPID) return Initialize2D(run);
-  if(fTRD2DPID) return kTRUE;
-  else return Initialize1D(run);
+  if(fTRDOldPIDMethod) return Initialize1D(run);
+  else return kTRUE;
 
 
 
@@ -187,8 +190,8 @@ Int_t AliHFEpidTRD::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager
   //
   //
 
-    if(fTRD2DPID) return IsSelected2D(track, pidqa);
-    else return IsSelected1D(track, pidqa);
+   if(fTRDOldPIDMethod) return IsSelected1D(track, pidqa);
+   else return IsSelectedTRDPID(track, pidqa);
 
 
 }
@@ -256,7 +259,7 @@ Int_t AliHFEpidTRD::IsSelected1D(const AliHFEpidObject *track, AliHFEpidQAmanage
 }
 
 //______________________________________________________
-Int_t AliHFEpidTRD::IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const {
+Int_t AliHFEpidTRD::IsSelectedTRDPID(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const {
   //
   // 2D TRD PID
   // 
@@ -298,8 +301,11 @@ Int_t AliHFEpidTRD::IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanage
   if(centralitybin>=0) centrality=fCentralityLimitsdefault[centralitybin]+1;
   AliDebug(2, Form("Just before cutting Electron effi: %f %i %i %f\n", fElectronEfficiency,track->GetCentrality(),centralitybin,centrality));
 
-  if(fkPIDResponse->IdentifiedAsElectronTRD(track->GetRecTrack(),fElectronEfficiency,centrality,AliTRDPIDResponse::kLQ2D)){
-      AliDebug(2, Form("Electron effi: %f %i %i %f\n", fElectronEfficiency,track->GetCentrality(),centralitybin,centrality));
+  AliTRDPIDResponse::ETRDPIDMethod fTRDPIDMethod = AliTRDPIDResponse::kLQ1D;
+  if(fTRD2DPID) fTRDPIDMethod = AliTRDPIDResponse::kLQ2D;
+
+ if(fkPIDResponse->IdentifiedAsElectronTRD(track->GetRecTrack(),fElectronEfficiency,centrality,fTRDPIDMethod)){
+      AliDebug(2, Form("Electron effi: %f %i %i %f %i\n", fElectronEfficiency,track->GetCentrality(),centralitybin,centrality,fTRDPIDMethod));
       if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTRDpid, AliHFEdetPIDqa::kAfterPID); 
       AliDebug(1,"PID qa done for step after\n");
       return 11;
index d2ed491625a0489f7ab12e58c980a8f6f734bb7e..ae9ae8eaf6337c94efe8aabeafe3358a58896f5a 100644 (file)
@@ -32,6 +32,7 @@ class AliMCParticle;
 class AliOADBContainer;
 class AliVParticle;
 class AliVTrack;
+class AliTRDPIDResponse;
 class TList;
 class TH2F;
 
@@ -63,7 +64,7 @@ class AliHFEpidTRD : public AliHFEpidBase{
     //virtual Bool_t Initialize2D(Int_t run);
     virtual Int_t  IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const;
     virtual Int_t  IsSelected1D(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const;
-    virtual Int_t  IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const;
+    virtual Int_t  IsSelectedTRDPID(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const;
 
     Double_t GetTRDSignalV1(const AliESDtrack *track, Float_t truncation = 0.7) const;
     Double_t GetTRDSignalV2(const AliESDtrack *track, Float_t trucation = 0.7) const;
@@ -73,6 +74,7 @@ class AliHFEpidTRD : public AliHFEpidBase{
     void SelectCutOnTheFly(Bool_t onFly = kTRUE) { if(onFly) SetBit(kSelectCutOnTheFly, kTRUE); else SetBit(kSelectCutOnTheFly, kFALSE);}
     void SetOADBThresholds(AliOADBContainer *cont) { fOADBThresholds = cont; }
     void SetTotalChargeInSlice0() { fTotalChargeInSlice0 = kTRUE; }
+    void SetTRDOldPIDMethod() { fTRDOldPIDMethod = kTRUE; }
     void SetTRD2DPID() { fTRD2DPID = kTRUE; }
     void SetRenormalizeElPi(Bool_t doRenorm = kTRUE) { if(doRenorm) SetBit(kTRDrenormalize, kTRUE); else SetBit(kTRDrenormalize, kFALSE);}
     void SetElectronEfficiency(Double_t electronEfficiency) { fElectronEfficiency = electronEfficiency; }
@@ -113,6 +115,7 @@ class AliHFEpidTRD : public AliHFEpidBase{
     Double_t fElectronEfficiency;                           // Cut on electron efficiency
     Double_t fThreshParams[kThreshParams];                  // Threshold parametrisation
     Bool_t   fTotalChargeInSlice0;                          // Flag for foreward/backward compatibility for the TRD total charge
+    Bool_t   fTRDOldPIDMethod;                              // Flag for old 1D PID method
     Bool_t   fTRD2DPID;                                     // Flag for 2D PID
   ClassDef(AliHFEpidTRD, 1)     // TRD electron ID class
 };
index 0eec5b7d26f73fd5bfe7a9829877d9cf935372a5..49278f0dfcb93ba108ae7a3b48493210880f30d4 100644 (file)
@@ -89,7 +89,14 @@ AliHFEtrdPIDqaV1 &AliHFEtrdPIDqaV1::operator=(const AliHFEtrdPIDqaV1 &o){
   
   return *this;
 }
+//____________________________________________________________
+AliHFEtrdPIDqaV1::~AliHFEtrdPIDqaV1(){
+  //
+  // Deconstructor
+  //
+  if(fHistos) delete fHistos;
 
+}
 //_________________________________________________________
 Long64_t AliHFEtrdPIDqaV1::Merge(TCollection *coll){
   //
index 922c383adf1e0712cfa4baaf88b0bc8de2698df6..6218bd2c2de068fbd9cc22840f1c25f3d67c327d 100644 (file)
@@ -37,7 +37,7 @@ class AliHFEtrdPIDqaV1 : public AliHFEdetPIDqa{
     AliHFEtrdPIDqaV1(const Char_t *name);
     AliHFEtrdPIDqaV1(const AliHFEtrdPIDqaV1 &c);
     AliHFEtrdPIDqaV1 &operator=(const AliHFEtrdPIDqaV1 &o);
-    ~AliHFEtrdPIDqaV1(){}
+    ~AliHFEtrdPIDqaV1();
     virtual Long64_t Merge(TCollection *coll);
     virtual void Browse(TBrowser *b);
     virtual Bool_t IsFolder() const { return kTRUE; };
index 5899aaca154747decfbde3dd2424fe133c1e38ef..3a1501604ac3b1a06b232809426436a580565335 100644 (file)
@@ -1,10 +1,11 @@
-AliAnalysisTask *AddTaskHFEnpepPb(Bool_t MCthere, 
+AliAnalysisTask *AddTaskHFEnpepPb(Bool_t MCthere,
                                   Bool_t isAOD, 
-                                  Bool_t kNPERef = kTRUE, 
-                                  Bool_t kNPEkAny = kFALSE, 
+                                  Bool_t kNPERef = kTRUE,
+                                  Bool_t kNPERefTPConly = kTRUE,
+                                  Bool_t kNPEkAny = kFALSE,
                                   Bool_t kNPEsystematics = kFALSE,
                                   Bool_t kNPEpidsys = kFALSE
-  ){
+){
 
   // Default settings (TOF-TPC pPb)
   const int    kDefTPCcl       = 110;
@@ -76,10 +77,28 @@ AliAnalysisTask *AddTaskHFEnpepPb(Bool_t MCthere,
     // Reference task
     //
     // **************************************************************
-    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax,
-                    kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kTRUE);
-    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax,
-                    kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE);
+    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, 
+                        AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+                        kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kTRUE);
+    /*RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, 
+     *                    AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+     *                    kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE);
+     */
+  }
+
+  if(kNPERefTPConly){
+    // **************************************************************
+    // 
+    // Reference task for TPC-only on the inclusive leg
+    //
+    // **************************************************************
+    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, 0, 
+                        AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+                        kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kTRUE);
+    /*RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, 
+     *                    AliHFEextraCuts::kBoth, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+     *                    kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE);
+     */
   }
 
   if(kNPEkAny){
@@ -88,10 +107,13 @@ AliAnalysisTask *AddTaskHFEnpepPb(Bool_t MCthere,
     // task for kAny instead of kBoth
     //
     // **************************************************************
-    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kAny, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax,
-                    kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kTRUE);
-    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, AliHFEextraCuts::kAny, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax,
-                    kassETAm, kassETAp, kassITS, kassTPCcl, kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE);
+    RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, 
+                        AliHFEextraCuts::kAny, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+                        kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kTRUE);
+    /*RegisterTaskNPEpPb( MCthere, isAOD, kDefTPCcl, kDefTPCclPID, kDefITScl, kDefDCAr, kDefDCAz, tpcl1, dEdxhm, kDefTOFs, 
+     *                    AliHFEextraCuts::kAny, kHFEV0A, kDefEtaIncMin, kDefEtaIncMax, kassETAm, kassETAp, kassITS, kassTPCcl, 
+     *                    kassTPCPIDcl, kassDCAr, kassDCAz, dEdxaclm, dEdxachm, kTRUE, kFALSE);
+     */
   }
 
   if(kNPEsystematics){
@@ -162,27 +184,34 @@ AliAnalysisTask *RegisterTaskNPEpPb(Bool_t useMC, Bool_t isAOD,
                Double_t *assTPCSminus = NULL, Double_t *assTPCSplus=NULL,
                Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE)
 {
+  //
+  // 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 iassETAm = (Int_t)(assETAm*10);
-  Int_t iassETAp = (Int_t)(assETAp*10);
+  //
+  // Cuts on the associated leg
+  //
   Int_t iassDCAr = (Int_t)(assDCAr*10);
   Int_t iassDCAz = (Int_t)(assDCAz*10);
-  Int_t iassTPCSminus = assTPCSminus ? (Int_t)(assTPCSminus[0]*10) : 0;
-  Int_t iassTPCSplus  = assTPCSplus ? (Int_t)(assTPCSplus[0]*10) : 0;
-  Int_t ipixelany = itshitpixel;
-  Int_t icat1 = useCat1Tracks ? 1 : 0;
-  Int_t icat2 = useCat2Tracks ? 1 : 0;
+  Int_t iassTPCSminus = assTPCSplus ? (Int_t)(assTPCSplus[0]*1000.) : 0;
 
+  printf("Argument passed to function to determine the centrality estimator %i\n", icent);
   if (icent == 2) TString cesti("V0M");
   else if (icent == 3) TString cesti("CL1");
   else if (icent == 4) TString cesti("ZNA");
   else TString cesti("V0A");
+  printf("Centrality estimator %s\n", cesti.Data());
 
-  TString appendix(TString::Format("PhotonicSPD%dEtam%dEtap%dITS%dTPCcl%dTPCPIDcl%dDCAr%dDCAz%dTPCSminus%dTPCSplus%d%sCA%dCB%d", ipixelany, iassETAm, iassETAp, assITS, assTPCcl,
-                                  assTPCPIDcl, iassDCAr, iassDCAz, iassTPCSminus, iassTPCSplus, cesti.Data(), icat1, icat2));
+  TString appendix(TString::Format("SPD%d_incTPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%d_photTPCc%dTPCp%dITS%dDCAr%dDCAz%dTPCs%dce%s",ipixelany,tpcCls,tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,assTPCcl,assTPCPIDcl,assITS,iassDCAr,iassDCAz,iassTPCSminus,cesti.Data()));
   printf("Add macro appendix %s\n", appendix.Data());
 
-  gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/ConfigHFEnpepPb.C");
if(!gROOT->GetListOfGlobalFunctions()->FindObject("ConfigHFEnpepPb")) gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/ConfigHFEnpepPb.C");
 
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
index d673e18e67e444dbdabda1d9dc4ffaf3b676f819..7fce9c960e1a2a7a6495804786380f0fa92ebf36 100644 (file)
@@ -8,7 +8,8 @@ AliAnalysisTask *AddTaskHFEpPb(Bool_t MCthere = kFALSE,
                                Bool_t kITS_Sys = kFALSE,
                                Bool_t kTPCTOFTRD_Ref = kFALSE,
                                Bool_t kTPCTOFTRD_mbPID = kFALSE,
-                               Bool_t kTPCTOFTRD_PID = kFALSE,
+                              Bool_t kTPCTOFTRD_PID1 = kFALSE,
+                               Bool_t kTPCTOFTRD_PID2 = kFALSE,
                                int TRDtrigger = 0
   ){
   //get the current analysis manager
@@ -152,12 +153,20 @@ AliAnalysisTask *AddTaskHFEpPb(Bool_t MCthere = kFALSE,
     RegisterTaskPID2mbTRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,TRDtrigger,5,2,"TRD,TPC",etacut);
   }
 
-  if(kTPCTOFTRD_PID){
+  if(kTPCTOFTRD_PID1){
     // without TOF
-    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,5,4,"TRD,TPC");
-    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,5,4,"TPC,TRD");
-    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,6,4,"TRD,TPC");
-    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,6,4,"TPC,TRD");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,1,5,4,"TRD,TPC");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,1,5,4,"TPC,TRD");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,1,6,4,"TRD,TPC");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,1,6,4,"TPC,TRD");
+  }
+
+  if(kTPCTOFTRD_PID2){
+    // without TOF
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,2,5,4,"TRD,TPC");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,2,5,4,"TPC,TRD");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,2,6,4,"TRD,TPC");
+    RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,&tpcl1[0],&dEdxhm[0],0,0,AliHFEextraCuts::kBoth,1,TRDtrigger,2,6,4,"TPC,TRD");
   }
 
   return NULL;
@@ -363,7 +372,7 @@ AliAnalysisTask *RegisterTaskPID2TRD(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=12
                                     Double_t *tpcdEdxcuthigh=NULL,
                                     Double_t tofs=3., Int_t tofm=0,
                                     Int_t itshitpixel = AliHFEextraCuts::kBoth, Int_t icent=1,
-                                    Int_t TRDtrigger=0,Int_t trdl=6, Int_t trde=4,TString detector){
+                                    Int_t TRDtrigger=0,Int_t trdpidmethod=1, Int_t trdl=6, Int_t trde=4,TString detector){
 
   gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/ConfigHFEpPbTRD.C");
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
@@ -385,12 +394,12 @@ AliAnalysisTask *RegisterTaskPID2TRD(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=12
   Int_t itofs = (Int_t)(tofs*10.);
   Int_t ipixelany = itshitpixel;
 
-  TString appendix(TString::Format("TPCc%dp%dITS%dr%dz%dTPCs%dTOFs%dm%ipa%dTRDt%dl%ie%i%sc%s",tpcCls,
-                   tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,tofm,ipixelany,TRDtrigger,trdl,trde,detused.Data(),cesti.Data()));
+  TString appendix(TString::Format("TPCc%dp%dITS%dr%dz%dTPCs%dTOFs%dm%ipa%dTRDt%dm%il%ie%i%sc%s",tpcCls,
+                   tpcClsPID,itsCls,idcaxy,idcaz,tpclow,itofs,tofm,ipixelany,TRDtrigger,trdpidmethod,trdl,trde,detused.Data(),cesti.Data()));
   printf("Add macro appendix %s\n", appendix.Data());
 
   AliAnalysisTaskHFE *task = ConfigHFEpPbTRD(useMC, isAOD, appendix, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz,
-                             tpcdEdxcutlow,tpcdEdxcuthigh, tofs, tofm, itshitpixel, icent, -0.8, 0.8, TRDtrigger,trdl,trde,detector);
+                             tpcdEdxcutlow,tpcdEdxcuthigh, tofs, tofm, itshitpixel, icent, -0.8, 0.8, TRDtrigger,trdpidmethod,trdl,trde,detector);
 
   if(isAOD)
     task->SetAODAnalysis();
index f6f9857343f324fa93766f5a8ffca4a00780120c..86d23a97cfd1319be49205007bd97276f41b5223 100755 (executable)
@@ -95,6 +95,7 @@ AliAnalysisTaskHFE* ConfigHFEnpePbPb(Bool_t useMC, Bool_t isAOD, TString appendi
     printf("CONFIGURATION FILE: TOF is used \n");
     hfecuts->SetTOFPIDStep(kTRUE);
     if(useMC) hfecuts->SetMatchTOFLabel(kTRUE);
+    //if(useMC) hfecuts->SetMatchTOFLabel(kFALSE);
     printf("CONFIGURATION FILE: TOF PID step is requested !!!! \n");
     if (TOFmis>0){
       kTOFmis = kTRUE;
index df7b3ac9ac0f36db549fa265ccfc567a1d9b0023..84f173e8a09276fdadfbb5886450b48a19c43950 100644 (file)
@@ -22,7 +22,7 @@ AliAnalysisTaskHFE* ConfigHFEnpepPb(Bool_t useMC, Bool_t isAOD, TString appendix
                 Double_t* tpcdEdxcutlow=NULL, Double_t* tpcdEdxcuthigh=NULL, 
                 Double_t TOFs=3., Int_t TOFmis=0, 
                 Int_t itshitpixel = 0, Int_t icent, 
-                           Double_t etami=-0.8, Double_t etama=0.8,
+               Double_t etami=-0.8, Double_t etama=0.8,
                 Double_t assETAm=-0.8, Double_t assETAp=0.8,
                 Int_t assITS=2, 
                 Int_t assTPCcl=100, Int_t assTPCPIDcl=80, 
@@ -30,7 +30,8 @@ AliAnalysisTaskHFE* ConfigHFEnpepPb(Bool_t useMC, Bool_t isAOD, TString appendix
                 Double_t *assTPCSminus=NULL, Double_t *assTPCSplus=NULL, 
                 Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE)
 {
-  Bool_t kAnalyseTaggedTracks = kTRUE;
+  Bool_t kAnalyseTaggedTracks = kFALSE;
+  Bool_t kApplyPreselection = kFALSE;
 
   //***************************************//
   //        Setting up the HFE cuts        //
@@ -238,7 +239,7 @@ AliAnalysisTaskHFE* ConfigHFEnpepPb(Bool_t useMC, Bool_t isAOD, TString appendix
     pidbackground->ConfigureTPCcentralityCut(a,cutmodelAssoc,tpcparamlow,tpcparamhigh);
   }
   pidbackground->ConfigureTPCdefaultCut(cutmodelAssoc,paramsTPCdEdxcutlowAssoc,paramsTPCdEdxcuthighAssoc[0]); // After introducing the pPb flag, pPb is merged with pp and this line defines the cut
-  backe->GetPIDBackgroundQAManager()->SetHighResolutionHistos();
+  //backe->GetPIDBackgroundQAManager()->SetHighResolutionHistos();
   backe->SetHFEBackgroundCuts(hfeBackgroundCuts);
 
   // Selection of associated tracks for the pool
index 15fbc938472776d8d3fc86d9ae7d118fab3dfa48..350d64c015f8a4a8057a67dc73308d5abf8dcf85 100644 (file)
@@ -22,9 +22,10 @@ AliAnalysisTaskHFE* ConfigHFEpPb(Bool_t useMC, Bool_t isAOD, TString appendix,
                                 Double_t* tpcdEdxcutlow=NULL,Double_t* tpcdEdxcuthigh=NULL,
                                 Double_t TOFs=3., Int_t TOFmis=0,
                                 Int_t itshitpixel = 0, Int_t icent=1,
-                                Double_t etami=-0.8, Double_t etama=0.8){
+                                Double_t etami=-0.8, Double_t etama=0.8, Bool_t esdPreselection = kFALSE){
   
   Bool_t kAnalyseTaggedTracks = kTRUE;
+  Bool_t kApplyPreselection = isAOD ? kFALSE : esdPreselection;
 
   //***************************************//
   //        Setting up the HFE cuts        //
@@ -41,6 +42,8 @@ AliAnalysisTaskHFE* ConfigHFEpPb(Bool_t useMC, Bool_t isAOD, TString appendix,
   hfecuts->SetCutITSpixel(itshitpixel);
   hfecuts->SetCheckITSLayerStatus(kFALSE);
   hfecuts->SetEtaRange(etami,etama);
+  hfecuts->SetRejectKinkDaughters();
+  hfecuts->SetAcceptKinkMothers();
   if(isAOD) hfecuts->SetAODFilterBit(4);
   
   //if((iPixelAny==AliHFEextraCuts::kAny) || (iPixelAny==AliHFEextraCuts::kSecond))     
@@ -79,6 +82,7 @@ AliAnalysisTaskHFE* ConfigHFEpPb(Bool_t useMC, Bool_t isAOD, TString appendix,
   task->SetRemovePileUp(kFALSE);
   task->SetHFECuts(hfecuts);
   task->GetPIDQAManager()->SetHighResolutionHistos();
+  task->SetRejectKinkMother(kFALSE);
 
   // Determine the centrality estimator
   task->SetCentralityEstimator("V0A");
@@ -86,6 +90,29 @@ AliAnalysisTaskHFE* ConfigHFEpPb(Bool_t useMC, Bool_t isAOD, TString appendix,
   else if (icent == 3) task->SetCentralityEstimator("CL1");
   else if (icent == 4) task->SetCentralityEstimator("ZNA");
 
+  //***************************************//
+  //        Prepare preselection           //
+  // This mimics the ESD->AOD filter in    //
+  // case of the ESD analysis and selects  //
+  // only tracks which will be selected in //
+  // the AOD analysis with the given filter//
+  // bit. Not to be applied for AODS.      //
+  // For pPb the cuts used are (bit 4)     //
+  // esdTrackCutsHG0 from file $ALICE_ROOT///
+  // ANALYSIS/macros/AddTaskESDFilter.C    //
+  //***************************************//
+  
+  if(kApplyPreselection){
+    AliESDtrackCuts* esdfilter = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
+    esdfilter->SetMaxDCAToVertexXY(2.4);
+    esdfilter->SetMaxDCAToVertexZ(3.2);
+    esdfilter->SetDCAToVertex2D(kTRUE);
+
+    task->SetHFECutsPreselect(esdfilter);
+    printf("Put a preselection cut\n");
+    task->SetFillNoCuts(kTRUE);
+  }
+
   //***************************************//
   //          Variable manager             //
   //***************************************//
index 0e02d7c075b34e20c626a007c96ea6714d8d5c02..b611c13d80b14b91e0a8b873f02cd0b28a798157 100644 (file)
@@ -28,7 +28,7 @@ AliAnalysisTaskHFE* ConfigHFEpPbTRD(Bool_t useMC, Bool_t isAOD, TString appendix
                                 Double_t TOFs=3., Int_t TOFmis=0,
                                 Int_t itshitpixel = 0, Int_t icent=1,
                                 Double_t etami=-0.8, Double_t etama=0.8,
-                                Int_t TRDtrigger=1, Int_t TRDtl=6, Int_t TRDeff=4,
+                                Int_t TRDtrigger=1, Int_t trdpidmethod=1, Int_t TRDtl=6, Int_t TRDeff=4,
                                 TString detector){
   
     Bool_t kAnalyseTaggedTracks = kTRUE;
@@ -187,7 +187,7 @@ AliAnalysisTaskHFE* ConfigHFEpPbTRD(Bool_t useMC, Bool_t isAOD, TString appendix
 
   if(TRDtl>0){
       AliHFEpidTRD *trdpid = pid->GetDetPID(AliHFEpid::kTRDpid);
-      trdpid->SetTRD2DPID();
+      if(trdpidmethod==2) trdpid->SetTRD2DPID();
       trdpid->SetElectronEfficiency(eeff[TRDeff]);   // efficiency
       trdpid->SetNTracklets(TRDtl);      // ntracklets threshold
       trdpid->SetCutNTracklets(TRDtl, kTRUE);
index 2a093015103a45da5e38dcbb9c999d81c282ccb5..8f0fa04b5695a908d3ae55c37d402b7c7a6cb65a 100644 (file)
@@ -582,7 +582,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       TH2F *hNITSclsvsEtaDaughters=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the daughter tracks;#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
 
       hname="hSPDclsDaughters";
-      TH1I *hSPDclsDaughters = new TH1I(hname.Data(),"N SPD points distribution;;Entries",4,0,4);
+      TH1I *hSPDclsDaughters = new TH1I(hname.Data(),"N SPD points distribution;;Entries",4,-0.5,3.5);
       hSPDclsDaughters->GetXaxis()->SetBinLabel(1, "no SPD");
       hSPDclsDaughters->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
       hSPDclsDaughters->GetXaxis()->SetBinLabel(3, "kOnlySecond");
@@ -637,7 +637,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       TH2F *hNITSclsvsEtaAllTracks=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the AOD tracks (ID>0);#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
 
       hname="hSPDclsAllTracks";
-      TH1I *hSPDclsAllTracks = new TH1I(hname.Data(),"N SPD points distribution AOD tracks (ID>0);;Entries",4,0,4);
+      TH1I *hSPDclsAllTracks = new TH1I(hname.Data(),"N SPD points distribution AOD tracks (ID>0);;Entries",4,-0.5,3.5);
       hSPDclsAllTracks->GetXaxis()->SetBinLabel(1, "no SPD");
       hSPDclsAllTracks->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
       hSPDclsAllTracks->GetXaxis()->SetBinLabel(3, "kOnlySecond");
index f0c49a635e40e0e72398e40062906abc6d1d9be6..a251fd64f57f40d390a59adf82e8c4a503f37714 100644 (file)
@@ -610,33 +610,31 @@ void AliHFSystErr::InitD0toKpi2013pPb0100(){
   // Raw yield extraction
   fRawYield = new TH1F("fRawYield","fRawYield",24,0,24);
   fRawYield->SetBinContent(1,0.0);
-  fRawYield->SetBinContent(2,0.08);
-  fRawYield->SetBinContent(3,0.02);
-  fRawYield->SetBinContent(4,0.05);
-  for(Int_t i=5;i<=6;i++) fRawYield->SetBinContent(i,0.02);
-  for(Int_t i=7;i<=12;i++) fRawYield->SetBinContent(i,0.05);
-  for(Int_t i=13;i<=24;i++) fRawYield->SetBinContent(i,0.08);
+  fRawYield->SetBinContent(2,0.07);
+  for(Int_t i=3;i<=6;i++) fRawYield->SetBinContent(i,0.02);
+  fRawYield->SetBinContent(7,0.03);
+  fRawYield->SetBinContent(8,0.05);
+  for(Int_t i=9;i<=12;i++) fRawYield->SetBinContent(i,0.02);
+  for(Int_t i=13;i<=16;i++) fRawYield->SetBinContent(i,0.05);
+  for(Int_t i=17;i<=24;i++) fRawYield->SetBinContent(i,0.1);
   
   // Cuts efficiency (from cuts variation)
   fCutsEff = new TH1F("fCutsEff","fCutsEff",24,0,24);
   fCutsEff->SetBinContent(1,0.0);
-  fCutsEff->SetBinContent(2,0.10);
+  fCutsEff->SetBinContent(2,0.08);
   for(Int_t i=3;i<=24;i++) fCutsEff->SetBinContent(i,0.05);
 
   // PID efficiency (from PID/noPID)
   fPIDEff = new TH1F("fPIDEff","fPIDEff",24,0,24);
   fPIDEff->SetBinContent(1,0.0);
-  fPIDEff->SetBinContent(2,0.05);
-  for(Int_t i=3;i<=12;i++) fPIDEff->SetBinContent(i,0.00);
-  for(Int_t i=13;i<=24;i++) fPIDEff->SetBinContent(i,0.05);
+  fPIDEff->SetBinContent(2,0.1);
+  for(Int_t i=3;i<=24;i++) fPIDEff->SetBinContent(i,0.00);
 
   // MC dN/dpt  
   fMCPtShape = new TH1F("fMCPtShape","fMCPtShape",24,0,24);
   fMCPtShape->SetBinContent(1,0.0);
   fMCPtShape->SetBinContent(2,0.02);
-  fMCPtShape->SetBinContent(3,0.02);
-  for(Int_t i=4;i<=6;i++) fMCPtShape->SetBinContent(i,0.0);
-  for(Int_t i=7;i<=24;i++) fMCPtShape->SetBinContent(i,0.02);
+  for(Int_t i=3;i<=24;i++) fMCPtShape->SetBinContent(i,0.0);
 
   // particle-antiparticle
   /*
index 12d1ddab18ead164bcb22a5cd28646fef2d85de5..4aa5b7cf7296b2e441815ed12202552a29e9c547 100644 (file)
@@ -116,70 +116,70 @@ class AliRDHFCuts : public AliAnalysisCuts
   }
   //
   //  Setters (helpers) for pp 2012 data
-  void SetUseInt1TriggerExclusivelyPP2012(){
+  void SetUseInt1TriggerPP2012(){
     fTriggerMask=AliVEvent::kMB;
     fTriggerClass[0]="CINT1";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseInt7TriggerExclusivelyPP2012(){
+  void SetUseInt7TriggerPP2012(){
     fTriggerMask=AliVEvent::kINT7;
     fTriggerClass[0]="CINT7";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseInt8TriggerExclusivelyPP2012(){
+  void SetUseInt8TriggerPP2012(){
     fTriggerMask=AliVEvent::kINT8;
     fTriggerClass[0]="CINT8";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCAL7TriggerExclusivelyPP2012(){
+  void SetUseEMCAL7TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMC7;
     fTriggerClass[0]="CEMC7";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCAL8TriggerExclusivelyPP2012(){
+  void SetUseEMCAL8TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMC8;
     fTriggerClass[0]="CEMC8";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCALJET7TriggerExclusivelyPP2012(){
+  void SetUseEMCALJET7TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMCEJE;
     fTriggerClass[0]="CEMC7EJE";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCALJET8TriggerExclusivelyPP2012(){
+  void SetUseEMCALJET8TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMCEJE;
     fTriggerClass[0]="CEMC8EJE";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCALGA7TriggerExclusivelyPP2012(){
+  void SetUseEMCALGA7TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMCEGA;
     fTriggerClass[0]="CEMC7EGA";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseEMCALGA8TriggerExclusivelyPP2012(){
+  void SetUseEMCALGA8TriggerPP2012(){
     fTriggerMask=AliVEvent::kEMCEGA;
     fTriggerClass[0]="CEMC8EGA";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseSPI7TriggerExclusivelyPP2012(){
+  void SetUseSPI7TriggerPP2012(){
     fTriggerMask=AliVEvent::kSPI7;
     fTriggerClass[0]="CSPI7";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseSPI8TriggerExclusivelyPP2012(){
+  void SetUseSPI8TriggerPP2012(){
     fTriggerMask=AliVEvent::kSPI;
     fTriggerClass[0]="CSPI8";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseHighMult7TriggerExclusivelyPP2012(){
+  void SetUseHighMult7TriggerPP2012(){
     fTriggerMask=AliVEvent::kHighMult;
     fTriggerClass[0]="CSHM7";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
-  void SetUseHighMult8TriggerExclusivelyPP2012(){
+  void SetUseHighMult8TriggerPP2012(){
     fTriggerMask=AliVEvent::kHighMult;
     fTriggerClass[0]="CSHM8";
-    fUseOnlyOneTrigger=kTRUE;
+    fUseOnlyOneTrigger=kFALSE;
   }
 
   void SetMaxDifferenceTRKV0Centraltity(Double_t maxd=5.) {fMaxDiffTRKV0Centr=maxd;}
index 088c1fcb25b11ec7a9ba32d0ef8f1f0964fdf005..666e07193eae17c4a1dece0ed490e445e87f67d3 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+/* $Id: AliRDHFCutsDStartoKpipi.cxx 61203 2013-03-02 22:52:17Z fprino $ */
 
 /////////////////////////////////////////////////////////////
 //
@@ -27,7 +27,6 @@
 
 #include <TDatabasePDG.h>
 #include <Riostream.h>
-
 #include "AliAODRecoDecayHF2Prong.h"
 #include "AliAODRecoCascadeHF.h"
 #include "AliRDHFCutsD0toKpi.h"
@@ -162,7 +161,8 @@ void AliRDHFCutsDStartoKpipi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *var
 
   AliAODRecoDecayHF2Prong* dd = (AliAODRecoDecayHF2Prong*)dstarD0pi->Get2Prong();
   
-   Int_t iter=-1;
+
+  Int_t iter=-1;
   if(fVarsForOpt[0]){
     iter++;
     if(TMath::Abs(pdgdaughters[0])==211) {
@@ -259,10 +259,10 @@ void AliRDHFCutsDStartoKpipi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *var
   return;
 }
 //---------------------------------------------------------------------------
-Int_t AliRDHFCutsDStartoKpipi::IsSelected(TObject* obj,Int_t selectionLevel) {
+Int_t AliRDHFCutsDStartoKpipi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod) {
   //
   // Apply selection for D*.
-  //
+  // Added functionality to remove the D0 daughters from primary vertex (not dafult) 
 
   fIsSelectedCuts=0;
   fIsSelectedPID=0;
@@ -305,8 +305,8 @@ Int_t AliRDHFCutsDStartoKpipi::IsSelected(TObject* obj,Int_t selectionLevel) {
      selectionLevel==AliRDHFCuts::kCandidate) {
     
     Double_t pt=d->Pt();
-    Int_t ptbin=PtBin(pt);
+    Int_t ptbin=PtBin(pt);    
+    
     // DStarMass and D0mass
     Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
     Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
@@ -325,7 +325,7 @@ Int_t AliRDHFCutsDStartoKpipi::IsSelected(TObject* obj,Int_t selectionLevel) {
     if(d->AngleD0dkpPisoft() > fCutsRD[GetGlobalIndex(13,ptbin)]) return 0;
   
     // select D0 that passes D* cuts
-    returnvalue = IsD0FromDStarSelected(pt,dd,selectionLevel);
+    returnvalue = IsD0FromDStarSelected(pt,dd,selectionLevel, aod);
     if((b->Charge()==+1 && returnvalue==2) || (b->Charge()==-1 && returnvalue==1)) return 0; 
     
   }
@@ -360,10 +360,11 @@ Int_t AliRDHFCutsDStartoKpipi::IsSelected(TObject* obj,Int_t selectionLevel) {
 
 }
 //_________________________________________________________________________________________________
-Int_t AliRDHFCutsDStartoKpipi::IsD0FromDStarSelected(Double_t pt, TObject* obj,Int_t selectionLevel) const {
+Int_t AliRDHFCutsDStartoKpipi::IsD0FromDStarSelected(Double_t pt, TObject* obj,Int_t selectionLevel, AliAODEvent* aod) const {
   //
   // Apply selection for D0 from D*. The selection in on D0 prongs
-  //
+  // added functionality to recalculate the primary vertex without D0 prongs (not default)
+  // 
   
   if(!fCutsRD){
     cout<<"Cut matrice not inizialized. Exit..."<<endl;
@@ -389,7 +390,30 @@ Int_t AliRDHFCutsDStartoKpipi::IsD0FromDStarSelected(Double_t pt, TObject* obj,I
     Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
     // delta mass PDG
  
+    // add vertex recalculation without daughters
+    AliAODVertex *origownvtx=0x0;
+    if(fRemoveDaughtersFromPrimary  && !fUseMCVertex) {
+      if(dd->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*dd->GetOwnPrimaryVtx());
+      if(!RecalcOwnPrimaryVtx(dd,aod)) { 
+       CleanOwnPrimaryVtx(dd,aod,origownvtx);
+       return 0;
+      }
+    }
+    
+    
+    if(fUseMCVertex) {
+      if(dd->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*dd->GetOwnPrimaryVtx());
+      if(!SetMCPrimaryVtx(dd,aod)) {
+       CleanOwnPrimaryVtx(dd,aod,origownvtx);
+       return 0;
+      }
+    }
+    
     Int_t ptbin=PtBin(pt);
+    if (ptbin==-1) {
+      CleanOwnPrimaryVtx(dd,aod,origownvtx);
+      return 0;
+    }
     
     Double_t mD0,mD0bar,ctsD0,ctsD0bar;
   
@@ -400,38 +424,42 @@ Int_t AliRDHFCutsDStartoKpipi::IsD0FromDStarSelected(Double_t pt, TObject* obj,I
     if(dd->PtProng(1) < fCutsRD[GetGlobalIndex(3,ptbin)] || dd->PtProng(0) < fCutsRD[GetGlobalIndex(4,ptbin)]) okD0 = 0;
     if(dd->PtProng(0) < fCutsRD[GetGlobalIndex(3,ptbin)] || dd->PtProng(1) < fCutsRD[GetGlobalIndex(4,ptbin)]) okD0bar = 0;
     
-    if(!okD0 && !okD0bar) return 0;
+    if(!okD0 && !okD0bar) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
     if(TMath::Abs(dd->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(5,ptbin)] || 
        TMath::Abs(dd->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)]) okD0 = 0;
     if(TMath::Abs(dd->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)] ||
        TMath::Abs(dd->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(5,ptbin)]) okD0bar = 0;
-    if(!okD0 && !okD0bar) return 0;
+    if(!okD0 && !okD0bar) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
-    if(dd->GetDCA() > fCutsRD[GetGlobalIndex(1,ptbin)]) return 0;
+    if(dd->GetDCA() > fCutsRD[GetGlobalIndex(1,ptbin)]) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
     dd->InvMassD0(mD0,mD0bar);
     if(TMath::Abs(mD0-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0 = 0;
     if(TMath::Abs(mD0bar-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0bar = 0;
-    if(!okD0 && !okD0bar) return 0;
+    if(!okD0 && !okD0bar) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
     dd->CosThetaStarD0(ctsD0,ctsD0bar);
     if(TMath::Abs(ctsD0) > fCutsRD[GetGlobalIndex(2,ptbin)]) okD0 = 0;
     if(TMath::Abs(ctsD0bar) > fCutsRD[GetGlobalIndex(2,ptbin)]) okD0bar = 0;
-    if(!okD0 && !okD0bar) return 0;
+    if(!okD0 && !okD0bar) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
-    if(dd->Prodd0d0() > fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
+    if(dd->Prodd0d0() > fCutsRD[GetGlobalIndex(7,ptbin)]) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
     
-    if(dd->CosPointingAngle() < fCutsRD[GetGlobalIndex(8,ptbin)]) return 0;
+    if(dd->CosPointingAngle() < fCutsRD[GetGlobalIndex(8,ptbin)]) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
 
-    if(TMath::Abs(dd->CosPointingAngleXY()) < fCutsRD[GetGlobalIndex(14,ptbin)])  return 0;
+    if(TMath::Abs(dd->CosPointingAngleXY()) < fCutsRD[GetGlobalIndex(14,ptbin)]) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
        
     Double_t normalDecayLengXY=(dd->NormalizedDecayLengthXY()*(dd->P()/dd->Pt()));
-    if (normalDecayLengXY < fCutsRD[GetGlobalIndex(15, ptbin)]) return 0;
+    if (normalDecayLengXY < fCutsRD[GetGlobalIndex(15, ptbin)]) {CleanOwnPrimaryVtx(dd,aod,origownvtx); return 0;}
 
     if (okD0) returnvalue=1; //cuts passed as D0
     if (okD0bar) returnvalue=2; //cuts passed as D0bar
     if (okD0 && okD0bar) returnvalue=3; //both
+
+    // unset recalculated primary vertex when not needed any more
+    CleanOwnPrimaryVtx(dd,aod,origownvtx);
+
   }
  
   return returnvalue;
@@ -788,15 +816,279 @@ void  AliRDHFCutsDStartoKpipi::SetStandardCutsPbPb2010(){
 
 //_____________________________________________________________________________
 void  AliRDHFCutsDStartoKpipi::SetStandardCutsPbPb2011(){
+  //
+  // Not implemented !!
+  //
+  SetStandardCutsPbPb2011DStar(0);
+  return;
+}
+//_________________________________here the PbPb vs pt _________________________________________
+void  AliRDHFCutsDStartoKpipi::SetStandardCutsPbPb2011DStar(TH1F *hfl){
 
   // Default 2010 PbPb cut object
-  SetStandardCutsPbPb2010();
 
-  // Enable all 2011 PbPb run triggers
-  //  
+  SetName("DStartoD0piCutsStandard2011");
+  SetTitle("Standard Cuts for D* analysis in PbPb 2011");
+
+  // EVENT CUTS
+  SetMinVtxContr(1);
+  // MAX Z-VERTEX CUT
+  SetMaxVtxZ(10.);
+
   SetTriggerClass("");
   ResetMaskAndEnableMBTrigger();
   EnableCentralTrigger();
   EnableSemiCentralTrigger();
 
+  // CENTRALITY SELECTION
+  SetMinCentrality(0.);
+  SetMaxCentrality(10.);
+  SetUseCentrality(AliRDHFCuts::kCentV0M);
+
+  // CUTS ON SINGLE TRACKS
+  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
+  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+  esdTrackCuts->SetRequireTPCRefit(kTRUE);
+  esdTrackCuts->SetRequireITSRefit(kTRUE);
+  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
+  esdTrackCuts->SetMinDCAToVertexXY(0.);
+  esdTrackCuts->SetEtaRange(-0.8,0.8);
+  esdTrackCuts->SetPtRange(0.3,1.e10);
+  
+  esdTrackCuts->SetMaxDCAToVertexXY(1.);  
+  esdTrackCuts->SetMaxDCAToVertexZ(1.);
+
+
+  // CUTS on SOFT PION
+  AliESDtrackCuts* esdSoftPicuts=new AliESDtrackCuts();
+  esdSoftPicuts->SetRequireSigmaToVertex(kFALSE);
+  esdSoftPicuts->SetRequireTPCRefit(kTRUE);
+  esdSoftPicuts->SetRequireITSRefit(kTRUE);
+  esdSoftPicuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+                                         AliESDtrackCuts::kAny); //test d0 asimmetry
+  esdSoftPicuts->SetPtRange(0.1,10);
+
+  esdSoftPicuts->SetMaxDCAToVertexXY(1.);  
+  esdSoftPicuts->SetMaxDCAToVertexZ(1.);
+
+  SetSelectCandTrackSPDFirst(kTRUE, 4);
+
+  //nothing below 3 GeV/c, speed up the calculation
+  SetMinPtCandidate(3.0);
+
+  AddTrackCuts(esdTrackCuts);
+  AddTrackCutsSoftPi(esdSoftPicuts);
+
+  const Int_t nptbins =14;
+  const Double_t ptmax = 36.;
+  const Int_t nvars=16;
+  Float_t ptbins[nptbins+1];
+  ptbins[0]=0.5;       
+  ptbins[1]=1.;
+  ptbins[2]=2.;
+  ptbins[3]=3.;
+  ptbins[4]=4.;
+  ptbins[5]=5.;
+  ptbins[6]=6.;
+  ptbins[7]=7.;
+  ptbins[8]=8.;
+  ptbins[9]=10.;
+  ptbins[10]=12.;
+  ptbins[11]=16.;
+  ptbins[12]=20.;
+  ptbins[13]=24.;
+  ptbins[14]=ptmax;
+
+  SetGlobalIndex(nvars,nptbins);
+  SetPtBins(nptbins+1,ptbins);
+  
+  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.032,220.*1E-4,0.9,0.5,0.5,500.*1E-4,500.*1E-4,-16000.*1E-8,0.85,0.3,0.1,0.05,100,0.5,-1.,9.},/* 0.5<pt<1*/
+                                                 {0.032,350.*1E-4,0.9,0.5,0.5,800.*1E-4,800.*1E-4,-20000.*1E-8,0.96,0.3,0.15,0.05,100,0.5,0.99,10.},/* 1<pt<2 */
+                                                 {0.032,300.*1E-4,0.9,0.5,0.5,900.*1E-4,900.*1E-4,-42000.*1E-8,0.96,0.3,0.15,0.05,100,0.5,0.99,9.},/* 2<pt<3 */
+                                                 {0.036,300.*1E-4,0.8,0.8,0.8,900.*1E-4,900.*1E-4,-39000.*1E-8,0.99,0.3,0.15,0.05,100,0.5,0.998,8.},/* 3<pt<4 */
+                                                 {0.038,225.*1E-4,0.8,1.0,1.0,1000.*1E-4,1000.*1E-4,-30000.*1E-8,0.99,0.3,0.15,0.05,100,0.5,0.998,7.5},/* 4<pt<5 */
+                                                 {0.045,200.*1E-4,1.0,1.0,1.0,1000.*1E-4,1000.*1E-4,-23000.*1E-8,0.99,0.3,0.15,0.05,100,0.5,0.998,7.},/* 5<pt<6 */
+                                                 {0.045,210.*1E-4,1.0,1.0,1.0,1000.*1E-4,1000.*1E-4,-10000.*1E-8,0.982,0.3,0.15,0.05,100,0.5,0.998,6.4},/* 6<pt<7 */
+                                                 {0.050,230.*1E-4,1.0,1.0,1.0,1000.*1E-4,1000.*1E-4,-12700.*1E-8,0.98,0.3,0.15,0.05,100,0.5,0.998,6.4},/* 7<pt<8 */
+                                                 {0.060,200.*1E-4,1.0,0.9,0.9,1000.*1E-4,1000.*1E-4,-7500.*1E-8,0.98,0.3,0.15,0.05,100,0.5,0.998,4.7},/* 8<pt<10 */
+                                                 {0.060,200.*1E-4,1.0,0.9,0.9,1000.*1E-4,1000.*1E-4,-7500.*1E-8,0.97,0.3,0.15,0.05,100,1.0,0.998,4.7},/* 10<pt<12 */
+                                                 {0.074,200.*1E-4,1.0,0.5,0.5,1500.*1E-4,1500.*1E-4,-7500.*1E-8,0.95,0.3,0.15,0.05,100,1.0,0.998,3},/* 12<pt<16 */
+                                                 {0.074,210.*1E-4,1.0,0.5,0.5,1500.*1E-4,1500.*1E-4,-5000.*1E-8,0.95,0.3,0.15,0.05,100,1.0,0.998,2.},/* 16<pt<20 */
+                                                  {0.074,220.*1E-4,1.0,0.5,0.5,1500.*1E-4,1500.*1E-4,-5000.*1E-8,0.93,0.3,0.15,0.05,100,1.0,0.995,2.},/* 20<pt<24 */
+                                                 {0.074,400.*1E-4,1.0,0.5,0.5,2000.*1E-4,2000.*1E-4,40000.*1E-8,0.7,0.3,0.15,0.05,100,1.0,0.9,1.}};/* 24<pt<36 */
+  
+  
+  //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
+  Float_t **cutsMatrixTransposeStand=new Float_t*[nvars];
+  for(Int_t iv=0;iv<nvars;iv++)cutsMatrixTransposeStand[iv]=new Float_t[nptbins];
+  
+  for (Int_t ibin=0;ibin<nptbins;ibin++){
+    for (Int_t ivar = 0; ivar<nvars; ivar++){
+      cutsMatrixTransposeStand[ivar][ibin]=cutsMatrixD0toKpiStand[ibin][ivar];      
+    }
+  }
+  
+  SetCuts(nvars,nptbins,cutsMatrixTransposeStand);
+
+  for(Int_t iv=0;iv<nvars;iv++) delete [] cutsMatrixTransposeStand[iv];
+  delete [] cutsMatrixTransposeStand;
+  cutsMatrixTransposeStand=NULL;
+  
+  // PID SETTINGS // --- 
+  AliAODPidHF* pidObj=new AliAODPidHF();
+  // pidObj->SetName("pid4DSatr");
+  Int_t mode=1;
+
+  pidObj->SetMatch(mode);
+  pidObj->SetSigma(0,3); // TPC -- 2 sigma for pt < 4
+  pidObj->SetSigma(3,3); // TOF
+  pidObj->SetTPC(kTRUE);
+  pidObj->SetTOF(kTRUE);
+  pidObj->SetOldPid(kFALSE);
+  
+  SetPidHF(pidObj);
+  SetUsePID(kTRUE);
+
+  // PID off for tracks with pt above 4 GeV/c
+  SetOffHighPtPIDinTPC(4.0);
+  SetRemoveDaughtersFromPrim(kFALSE);
+  // flattening
+  SetHistoForCentralityFlattening(hfl,0.,10,0.,0);
+
+  PrintAll();
+
+  delete pidObj;
+  pidObj=NULL;
+
+
+  return;
+}
+//-----------------------------------Here the multiplicity pp--------------------------------
+
+void  AliRDHFCutsDStartoKpipi::SetStandardCutsPP2010DStarMult(Bool_t rec){
+
+
+ //
+  // STANDARD CUTS USED FOR 2010 pp analysis (multiplicity)
+  //                                           
+  //
+
+  SetName("DStartoD0piCutsStandard");
+  SetTitle("Standard Cuts for D* analysis pp mult");
+  
+  // PILE UP REJECTION
+  SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
+
+  // EVENT CUTS
+  SetMinVtxContr(1);
+   // MAX Z-VERTEX CUT
+  SetMaxVtxZ(10.);
+
+  // CUTS ON SINGLE TRACKS
+  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
+  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+  esdTrackCuts->SetRequireTPCRefit(kTRUE);
+  esdTrackCuts->SetRequireITSRefit(kTRUE);
+  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
+  esdTrackCuts->SetMinDCAToVertexXY(0.);
+  esdTrackCuts->SetEtaRange(-0.8,0.8);
+  esdTrackCuts->SetPtRange(0.3,1.e10);
+
+  esdTrackCuts->SetMaxDCAToVertexXY(1.);  
+  esdTrackCuts->SetMaxDCAToVertexZ(1.);
+
+  
+  // CUTS on SOFT PION
+  AliESDtrackCuts* esdSoftPicuts=new AliESDtrackCuts();
+  esdSoftPicuts->SetRequireSigmaToVertex(kFALSE);
+  esdSoftPicuts->SetRequireTPCRefit(kFALSE);
+  esdSoftPicuts->SetRequireITSRefit(kTRUE);
+  esdSoftPicuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+                                         AliESDtrackCuts::kAny); 
+  esdSoftPicuts->SetPtRange(0.08,1.e10);
+  SetUseCentrality(kFALSE);
+
+  AddTrackCuts(esdTrackCuts);
+  AddTrackCutsSoftPi(esdSoftPicuts);
+
+  const Int_t nptbins =14;
+  const Double_t ptmax = 9999.;
+  const Int_t nvars=16;
+  Float_t ptbins[nptbins+1];
+  ptbins[0]=0.;
+  ptbins[1]=0.5;       
+  ptbins[2]=1.;
+  ptbins[3]=2.;
+  ptbins[4]=3.;
+  ptbins[5]=4.;
+  ptbins[6]=5.;
+  ptbins[7]=6.;
+  ptbins[8]=7.;
+  ptbins[9]=8.;
+  ptbins[10]=10.;
+  ptbins[11]=12.;
+  ptbins[12]=16.;
+  ptbins[13]=20.;
+  ptbins[14]=ptmax;
+
+  SetGlobalIndex(nvars,nptbins);
+  SetPtBins(nptbins+1,ptbins);
+  
+  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.026,220.*1E-4,0.7,0.21,0.21,500.*1E-4,500.*1E-4,-2000.*1E-8,0.85,0.3,0.1,0.05,100,0.5,-1.,0.},/* pt<0.5*/
+                                                 {0.039,300.*1E-4,0.7,0.21,0.21,500.*1E-4,500.*1E-4,-16000.*1E-8,0.85,0.3,0.1,0.05,100,0.5,-1.,0.},/* 0.5<pt<1*/
+                                                 {0.022,400.*1E-4,0.8,0.7,0.7,800.*1E-4,800.*1E-4,-20000.*1E-8,0.8,0.3,0.3,0.05,100,0.5,-1.,0.},/* 1<pt<2 */
+                                                 {0.032,350.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-13000.*1E-8,0.9,0.3,0.3,0.05,100,0.8,-1.,0.},/* 2<pt<3 */
+                                                 {0.032,500.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.9,0.3,0.3,0.05,100,0.8,-1.,0.},/* 3<pt<4 */
+                                                 {0.032,700.*1E-4,0.9,0.9,0.9,1000.*1E-4,1000.*1E-4,10000.*1E-8,0.9,0.3,0.3,0.05,100,1.0,-1.,0.},/* 4<pt<5 */
+                                                 {0.036,1000.*1E-4,1.0,0.8,0.8,1000.*1E-4,1000.*1E-4,50000.*1E-8,0.9,0.3,0.3,0.05,100,1.0,-1.,0.},/* 5<pt<6 */
+                                                 {0.036,1000.*1E-4,1.0,0.8,0.8,1000.*1E-4,1000.*1E-4,100000.*1E-8,0.7,0.3,0.3,0.05,100,1.0,-1.,0.},/* 6<pt<7 */
+                                                 {0.036,1000.*1E-4,1.0,0.8,0.8,1200.*1E-4,1200.*1E-4,100000.*1E-8,0.6,0.3,0.3,0.05,100,1.0,-1.,0.},/* 7<pt<8 */
+                                                 {0.065,2000.*1E-4,1.0,0.3,0.3,2000.*1E-4,2000.*1E-4,1000000.*1E-8,0.5,0.3,0.3,0.05,100,1.0,-1.,0.},/* 8<pt<10 */
+                                                 {0.075,2000.*1E-4,1.0,0.3,0.3,2000.*1E-4,2000.*1E-4,1000000.*1E-8,0.3,0.3,0.3,0.05,100,1.0,-1.,0.},/* 10<pt<12 */
+                                                 {0.084,6000.*1E-4,1.0,0.3,0.3,1500.*1E-4,1500.*1E-4,1000000.*1E-8,0.1,0.3,0.1,0.05,100,1.0,-1.,0.},/* 12<pt<16 */
+                                                 {0.084,1000.*1E-4,1.0,1.0,1.0,1500.*1E-4,1500.*1E-4,1000000.*1E-8,0.7,0.3,0.1,0.05,100,1.0,-1.,0.},/* 16<pt<20 */
+                                                 {0.7,1000.*1E-4,1.0,1.0,1.0,1500.*1E-4,1500.*1E-4,1000000.*1E-8,0.7,0.3,0.1,0.05,100,1.0,-1.,0.}};/* pt>24 */
+  
+  
+  //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
+  Float_t **cutsMatrixTransposeStand=new Float_t*[nvars];
+  for(Int_t iv=0;iv<nvars;iv++)cutsMatrixTransposeStand[iv]=new Float_t[nptbins];
+  
+  for (Int_t ibin=0;ibin<nptbins;ibin++){
+    for (Int_t ivar = 0; ivar<nvars; ivar++){
+      cutsMatrixTransposeStand[ivar][ibin]=cutsMatrixD0toKpiStand[ibin][ivar];      
+    }
+  }
+  
+  SetCuts(nvars,nptbins,cutsMatrixTransposeStand);
+
+  for(Int_t iv=0;iv<nvars;iv++) delete [] cutsMatrixTransposeStand[iv];
+  delete [] cutsMatrixTransposeStand;
+  cutsMatrixTransposeStand=NULL;
+
+  // remove daughters from primary vertex
+  SetRemoveDaughtersFromPrim(rec);
+
+  // PID SETTINGS FOR D* analysis
+  AliAODPidHF* pidObj=new AliAODPidHF();
+  //pidObj->SetName("pid4DSatr");
+  Int_t mode=1;
+  pidObj->SetMatch(mode);
+  pidObj->SetSigma(0,3); // TPC
+  pidObj->SetSigma(3,3); // TOF
+  pidObj->SetTPC(kTRUE);
+  pidObj->SetTOF(kTRUE);
+  
+  SetPidHF(pidObj);
+  SetUsePID(kTRUE);
+  pidObj->SetOldPid(kTRUE);
+
+  PrintAll();
+
+  delete pidObj;
+  pidObj=NULL;
+
+  return;
+
+
 }
index c6bb9782ce791eb177864bd9ccd6a73a81037864..1f6ba3efb6c790924c8520fafcc541ad49c9d339 100644 (file)
@@ -31,16 +31,28 @@ class AliRDHFCutsDStartoKpipi : public AliRDHFCuts
   virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters);
 
   using AliRDHFCuts::IsSelected;
-  virtual Int_t IsSelected(TObject* obj,Int_t selectionLevel);
-  Int_t IsD0FromDStarSelected(Double_t pt, TObject* obj,Int_t selectionLevel) const; 
+  virtual Int_t IsSelected(TObject* obj, Int_t selectionLevel, AliAODEvent* aod);
+  virtual Int_t IsSelected(TObject* obj, Int_t selectionLevel) {return IsSelected(obj,selectionLevel,0);}
+
+  Int_t IsD0FromDStarSelected(Double_t pt, TObject* obj,Int_t selectionLevel, AliAODEvent* aod) const;
+  Int_t IsD0FromDStarSelected(Double_t pt, TObject* obj,Int_t selectionLevel) {return IsD0FromDStarSelected(pt,obj,selectionLevel,0);};
+
   virtual Int_t IsSelectedPID(AliAODRecoDecayHF *rd);
   virtual Int_t SelectPID(AliAODTrack *track, Int_t type);
   virtual Bool_t IsInFiducialAcceptance(Double_t pt,Double_t y) const;
   Float_t GetMassCut(Int_t iPtBin=0) const { return (GetCuts() ? fCutsRD[GetGlobalIndex(9,iPtBin)] : 1.e6);} // for the Dstar
   Float_t GetDCACut(Int_t iPtBin=0) const { return (GetCuts() ? fCutsRD[GetGlobalIndex(1,iPtBin)] : 1.e6);} // for the D0
+
+  // standard cuts
   virtual void SetStandardCutsPP2010();
   virtual void SetStandardCutsPbPb2010();
-  virtual void SetStandardCutsPbPb2011();  
+  virtual void SetStandardCutsPbPb2011();
+
+  // standard cuts 
+  void SetStandardCutsPbPb2011DStar(TH1F *hfl);
+  void SetStandardCutsPP2010DStarMult(Bool_t rec = kFALSE);
+
+  
   void SetMaxPtPid(Float_t maxPt){fMaxPtPid = maxPt;}
 
   void SetOffHighPtPIDinTPC(Float_t TPCrem =999.){fTPCflag = TPCrem;}
index e81352dddca7b4de24d6563a1131f0f1a871a08a..471054b9292aee24564bbdf16afd496551dedb0c 100644 (file)
@@ -1,5 +1,6 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 #include <Riostream.h>
+#include <fstream>
 #include <TFile.h>
 #include <TString.h>
 #include <TH2F.h>
@@ -30,6 +31,9 @@ Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TSt
 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root", TString dirname="PWG3_D2H_QA");
 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid, Int_t set);
 void TPCBetheBloch(Int_t set);
+Bool_t ReadFilesForCompilation(TString inputtextfile, TList**& lists, Int_t&numb, TString*& legend);
+void CompilationEvSelection(Int_t n,TList** lists, TString* legend);
+void CompilationTrackSelection(Int_t n,TList** lists, TString* legend);
 
 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename, TString dirname){
 
@@ -371,7 +375,7 @@ void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsig
   Double_t nsigmaTPC[3]={},plimTPC[2]={};
 
   if(mode==1){
-    Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path,filename,dirname);
+    Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname+suffixdir,path,filename,dirname);
     if(!isRead) return;
     if(!list || !hstat){
       cout<<":-( null pointers..."<<endl;
@@ -390,7 +394,7 @@ void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsig
     aodpid->GetPLimit(plimTPC);
 
   }else{
-    Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
+    Bool_t isRead=ReadFile(list,hstat,listname,partname+suffixdir,path,filename,dirname);
     if(!isRead) return;
     if(!list || !hstat){
       cout<<":-( null pointers..."<<endl;
@@ -1329,4 +1333,464 @@ void DrawEventSelection(TString partname="D0", TString path="./",TString suffixd
 
   delete [] words;
 
+  //draw number of events per trigger
+  TH2F* hTrigMul=(TH2F*)list->FindObject("hTrigMul");
+
+  TH1F *hnEvPerTrig=(TH1F*)hTrigMul->ProjectionX("hnEvPerTrig");
+  hnEvPerTrig->SetTitle("Number of events per trigger");
+  TCanvas* cnev=new TCanvas("cnev","Number of events",1400,800);
+  cnev->cd();
+  hnEvPerTrig->Draw("htext0");
+  cnev->SaveAs(Form("%s.pdf",cnev->GetName()));
+  cnev->SaveAs(Form("%s.eps",cnev->GetName()));
+
+  //draw number of events selected per trigger
+  TH2F* hTrigMulSel=(TH2F*)list->FindObject("hTrigMulSel");
+
+  TH1F *hnEvPerTrigSel=(TH1F*)hTrigMulSel->ProjectionX("hnEvPerTrigSel");
+  hnEvPerTrigSel->SetTitle("Number of events selected per trigger");
+  TCanvas* cnevs=new TCanvas("cnevs","Number of events selected",1400,800);
+  cnevs->cd();
+  hnEvPerTrigSel->Draw("htext0");
+  cnevs->SaveAs(Form("%s%s.pdf",cnevs->GetName(),suffixdir.Data()));
+  cnevs->SaveAs(Form("%s%s.eps",cnevs->GetName(),suffixdir.Data()));
+
+  TH1F* hnEvSelPerc=(TH1F*)hnEvPerTrigSel->Clone("hnEvSelFrac");
+  hnEvSelPerc->SetTitle("Fraction of event selected per trigger");
+  hnEvSelPerc->Divide(hnEvPerTrig);
+  TCanvas* cnevsp=new TCanvas("cnevsp","Fraction of events selected",1400,800);
+  cnevsp->cd();
+  hnEvSelPerc->Draw("htext0");
+  cnevsp->SaveAs(Form("%s%s.pdf",cnevsp->GetName(),suffixdir.Data()));
+  cnevsp->SaveAs(Form("%s%s.eps",cnevsp->GetName(),suffixdir.Data()));
 }
+
+void WriteTextFileForCompilation(TString inputtextfile, Int_t analysistype){
+   //This method writes a text file with the name given in input containing the path of the QA output file, the directories and the lists of histograms to be read to perform a comparison of QA outputs
+   // analysistype = 1 is the OutputTrack
+   // analysistype = 2 is the OutputEventSelection
+   // other outputs can be implemented
+
+   // The paths and trigger type (or more in general the suffix of the directories to be read have to be set in this method)
+   // The legend is set either equal to the trigger type if they are different, or it should be set manually
+   // Run this methos before CompilationOfTriggeredEvents unless the text file has been already produced
+   
+  Printf("WARNING! Did you customize the parameters in the macro?");
+  const Int_t n=8; //customize this
+  TString prepath="/data/Work/HFQA/LHC12QATrainOutputs/";//"./";
+  TString pathname[n]={"LHC12a/Train165/","LHC12b/Train166/","LHC12d/Train168/","LHC12e/Train170/","LHC12f/Train171/","LHC12g/Train172/"};
+
+  TString dirname[n];
+  TString listname[n];
+  ofstream myfile;
+  myfile.open(inputtextfile);
+  myfile<<n<<endl;
+
+  TString filename="AnalysisResults.root";
+  TString basedirname="PWG3_D2H_QA";
+  TString trgnames[n];//={"INT7","EMC7","EMCJET7","EMCGAMMA7","INT8","EMC8","EMCJET8","EMCGAMMA8"}; //customize this
+  TString baselistname="", partname="D00100";
+  TString legend[n]={"LHC12a165","LHC12b166","LHC12d168","LHC12e170","LHC12f171","LHC12g172"}; //Customize this if want it to be different from trgnames
+  if(analysistype==1) baselistname="outputTrack";
+  if(analysistype==2) baselistname="outputEvSel";
+  //... others could be added
+
+  //All in the same directory on your computer
+  for(Int_t i=0;i<n;i++){
+    //set
+    pathname[i]=prepath+pathname[i];//"./";
+    trgnames[i]="EMC7";
+    dirname[i]=basedirname+trgnames[i];
+    listname[i]=baselistname+partname+trgnames[i];
+    if(legend[i]=="") legend[i]=trgnames[i];
+    
+    //Printf("Trigger name is %s",trgnames[i].Data());
+    //Printf("Legend is %s",legend[i].Data());
+    
+    //write text file
+    myfile<<endl;
+    myfile<<endl;
+    myfile<<pathname[i].Data()<<filename.Data()<<endl;
+    myfile<<dirname[i].Data()<<endl;
+    myfile<<listname[i].Data()<<endl;
+    myfile<<legend[i].Data()<<endl;
+      
+  }
+  myfile.close();
+
+}
+
+Bool_t ReadFilesForCompilation(TString inputtextfile, TList**& lists, Int_t& numb, TString*& legend){
+
+   //Method to read the QA files indicated in the text file in input (to be written with WriteTextFileForCompilation() method)
+  ifstream myfile;
+  myfile.open(inputtextfile);
+  if(!myfile.is_open()) Printf("No files found, did you make it correctly?");
+  Int_t n; 
+  myfile >> n;
+  lists=new TList*[n];
+  legend= new TString[n];
+  numb=n;
+
+  Int_t k=0;
+
+  while(myfile){
+   
+    TString filename;
+    myfile>>filename;
+    //Printf("Filename = %s",filename.Data());
+    TFile *fin=new TFile(filename);
+    if(!fin->IsOpen()){
+      Printf("File %s not found",filename.Data());
+      return kFALSE;
+    }
+   
+    TString dirname;
+    myfile>>dirname;
+    //Printf("Dirname = %s",dirname.Data());
+    TDirectoryFile* dir=(TDirectoryFile*)fin->Get(dirname);
+    if(!dir){
+      Printf("Directory %s not found in %s",dirname.Data(),filename.Data());
+      fin->ls();
+      return kFALSE;
+    }
+   
+    TString listname;
+    myfile>>listname;
+    //Printf("Listname = %s",listname.Data());
+    lists[k]=(TList*)dir->Get(listname);
+    if(!lists[k]){
+      Printf("List %s not found in %s",listname.Data(),dirname.Data());
+      dir->ls();
+      return kFALSE;
+    }
+    
+    TString temp;
+    myfile>>temp;
+    legend[k]=temp;
+    Printf("Legend = %s",legend[k].Data());
+    if(!legend[k]){
+      Printf("Legend %s not found",filename.Data());
+      return kFALSE;
+    }
+    
+
+    k++;
+    if(k==n)return kTRUE;// Needed as the while loop does not always realise the end is reached. 
+  }
+  return kTRUE;
+}
+
+void CompilationOfTriggeredEvents(TString inputtextfile,Int_t analysistype){
+   //This method draws the histograms superimposed
+
+   // analysistype = 1 is the OutputTrack
+   // analysistype = 2 is the OutputEventSelection
+   // other outputs can be implemented
+
+  TList **lists=0x0;
+  Int_t n;
+  TString* legend=0x0;
+  Bool_t okread=ReadFilesForCompilation(inputtextfile,lists,n,legend);
+  if(!okread){
+    Printf("Did you write %s with  WriteTextFileForCompilation(%s)?",inputtextfile.Data(),inputtextfile.Data());
+    return;
+  }
+
+  if(analysistype==2){CompilationEvSelection(n,lists,legend);}
+  if(analysistype==1){CompilationTrackSelection(n,lists,legend);}
+}
+
+void CompilationEvSelection(Int_t n,TList** lists, TString* legend){
+   // Specific method for EventSelection output (2)
+
+  TCanvas *cnevs=new TCanvas("cnevs","Number of events selected",1400,800);
+  TCanvas *cnevsp=new TCanvas("cnevsp","Fraction of events selected",1400,800);
+  TH1F** hnEvPerTrig=new TH1F*[n];
+  TH1F** hnEvPerTrigSel=new TH1F*[n];
+  TH1F** hnEvSelPerc=new TH1F*[n];
+  
+  TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
+  leg->SetFillStyle(0);
+  leg->SetBorderSize(0);
+  
+  Bool_t first=kTRUE;
+  Int_t nentriesl=lists[0]->GetEntries();
+  TCanvas** c=new TCanvas*[nentriesl];
+  Int_t nth1f=0;
+  
+  for(Int_t i=0;i<n;i++){
+   
+    TH2F* hTrigMul=(TH2F*)lists[i]->FindObject("hTrigMul");
+
+    hnEvPerTrig[i]=(TH1F*)hTrigMul->ProjectionX(Form("hnEvPerTrig%d",i));
+    hnEvPerTrig[i]->SetTitle("Number of events selected per trigger");
+   
+
+    TH2F* hTrigMulSel=(TH2F*)lists[i]->FindObject("hTrigMulSel");
+    
+    hnEvPerTrigSel[i]=(TH1F*)hTrigMulSel->ProjectionX(Form("hnEvPerTrigSel%d",i));
+    hnEvPerTrigSel[i]->SetTitle("Number of events selected per trigger");
+    hnEvPerTrigSel[i]->SetLineColor(i+1);
+    hnEvPerTrigSel[i]->SetLineWidth(2);
+
+    cnevs->cd();
+    if(i==0) hnEvPerTrigSel[i]->Draw();
+    else  hnEvPerTrigSel[i]->Draw("sames");
+
+    hnEvSelPerc[i]=(TH1F*)hnEvPerTrigSel[i]->Clone(Form("hnEvSelFrac%d",i));
+    hnEvSelPerc[i]->SetTitle("Fraction of event selected per trigger");
+    hnEvSelPerc[i]->SetLineColor(i+1);
+    hnEvSelPerc[i]->SetLineWidth(2);
+    hnEvSelPerc[i]->Divide(hnEvPerTrig[i]);
+    cnevsp->cd();
+    if(i==0) hnEvSelPerc[i]->Draw("htext0");
+    else  hnEvSelPerc[i]->Draw("htext0sames");
+    nth1f=0; //restart counting per each file 
+    
+    //fill legend
+    leg->AddEntry(hnEvSelPerc[i],legend[i],"L"); 
+    
+    for(Int_t j=0; j<nentriesl; j++){
+       TClass* objtype=lists[i]->At(j)->IsA();
+       TString tpname=objtype->GetName();
+       
+       if (tpname=="TH1F"){
+                 TH1F* htmp=(TH1F*)lists[i]->At(j);
+                 
+                 htmp->SetLineColor(1+i);
+                 if(htmp->Integral()>0) htmp->Scale(1./htmp->Integral());
+
+                 if(first) {
+                    c[nth1f]=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));                  
+                    c[nth1f]->cd();
+                    htmp->Draw();
+                      
+                 }
+                 else {
+                    c[nth1f]->cd();
+                    htmp->Draw("sames");
+                 }
+                 nth1f++;
+       }
+    }
+
+    first=kFALSE;
+  }
+  
+  for(Int_t j=0;j<nth1f;j++){
+     c[j]->cd();
+     leg->Draw();
+     c[j]->SaveAs(Form("%s.pdf",c[j]->GetName()));
+     c[j]->SaveAs(Form("%s.eps",c[j]->GetName()));
+  }
+  
+  cnevs->cd();
+  leg->Draw();
+  cnevs->SaveAs(Form("%s.eps",cnevs->GetName()));
+  cnevs->SaveAs(Form("%s.pdf",cnevs->GetName()));
+  
+  cnevsp->cd();
+  leg->Draw();
+  cnevsp->SaveAs(Form("%s.eps",cnevsp->GetName()));
+  cnevsp->SaveAs(Form("%s.pdf",cnevsp->GetName()));
+  TCanvas *test=new TCanvas();
+  test->cd(); leg->Draw();
+}
+
+
+void CompilationTrackSelection(Int_t n,TList** lists,TString* legend)
+{
+   // Specific method for Track output (1)
+
+  for(Int_t i=0;i<lists[0]->GetEntries();i++){
+    TObjArray* plotseth=new TObjArray();
+    TObjArray* plotsethr=new TObjArray();
+    
+    for(Int_t j=0; j<n; j++){
+      TH1F* temph=(TH1F*)lists[j]->At(i);
+      TH1F * temphr=0x0;
+      TH1F * ploto=0x0; //0th plot to divide by
+      
+      // plot ratios and scale all plots to integral
+      temphr= (TH1F*)temph->Clone(Form("%s_ratio",temph->GetName()));
+      if(j==0)ploto = temphr;
+      else ploto = (TH1F*)plotseth->At(0);
+      temphr->Divide(ploto);
+      if(temphr->Integral()>0){temphr-> Scale(1./temphr->Integral());}// take out for nonscaled ratios
+      if(temph->Integral()>0){ temph-> Scale(1./temph->Integral());}
+      
+      plotseth->AddLast(new TH1F(*temph));
+      plotsethr->AddLast(new TH1F(*temphr));
+    }
+
+    
+    TH1F *h = (TH1F*)plotseth->At(0);
+    TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
+    c->cd();
+    c->SetGrid();
+    TString hname=h->GetName();
+    
+    if(!hname.Contains("nCls")){
+      c->SetLogy();
+      if(hname.Contains("Layer")){
+       for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
+         h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
+       }
+       h->GetXaxis()->SetLabelSize(0.06);
+       h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
+      }
+      //h->SetMinimum(1);
+      h->Draw();
+      
+      TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
+      leg->SetFillStyle(0);
+      leg->SetBorderSize(0);
+      leg->AddEntry(h,legend[0],"L");
+      
+      for(Int_t j=1; j<n; j++){
+       TH1F * h2 = (TH1F*)plotseth->At(j);
+       h2->SetLineColor(1+j);
+       h2->Draw("sames");
+       leg->AddEntry(h2,legend[j],"L");
+      }
+      
+      leg->Draw();
+      
+      TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
+      c2->cd();
+      c2->SetGrid();
+      TH1F *hr = (TH1F*)plotsethr->At(1);
+      hr->SetLineColor(2);
+      hr->Draw();
+      TLegend* leg2=new TLegend(0.15,0.5,0.45,0.78);
+      leg2->SetFillStyle(0);
+      leg2->SetBorderSize(0);
+      
+      TString ratioleg;
+      ratioleg+=legend[1];
+      ratioleg+="/";
+      ratioleg+=legend[0];
+    
+      leg2->AddEntry(hr,ratioleg,"L");
+      
+      for(Int_t j=2; j<n; j++){
+       TH1F * hr2 = (TH1F*)plotsethr->At(j);
+       hr2->SetLineColor(1+j);
+       hr2->Draw("sames");
+      
+       TString ratioleg2;
+       ratioleg2+=legend[j];
+       ratioleg2+="/";
+       ratioleg2+=legend[0];
+
+       leg2->AddEntry(hr2,ratioleg2,"L");
+      }
+      leg2->Draw();
+      c2->SaveAs(Form("%s%s%sRatio.pdf",c->GetName(),legend[0].Data(), legend[n-1].Data()));
+      c2->SaveAs(Form("%s%s%sRatio.eps",c->GetName(),legend[0].Data(), legend[n-1].Data()));
+    } 
+    else {
+      h->Draw("htext0");
+    
+      TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
+      leg->SetFillStyle(0);
+      leg->SetBorderSize(0);
+      leg->AddEntry(h,legend[0],"L");
+      
+      for(Int_t j=1; j<n; j++){
+       TH1F * h2 = (TH1F*)plotseth->At(j);
+       h2->SetLineColor(1+j);
+       leg->AddEntry(h2,legend[j],"L");
+       h2->Draw("htext0sames");
+      }
+      
+      leg->Draw();
+    }
+    c->cd();
+    c->SaveAs(Form("%s%s%s.eps",c->GetName(),legend[0].Data(), legend[n-1].Data()));
+    c->SaveAs(Form("%s%s%s.pdf",c->GetName(),legend[0].Data(), legend[n-1].Data()));           
+  }
+  
+  Int_t check=0;
+  Int_t maxfa=1;
+  if(n<=10)maxfa=n;
+  else cout<<"Warning: To many files for combinationplot, show only original"<<endl;
+  TLegend* leg3=new TLegend(0.15,0.5,0.45,0.78);
+  leg3->SetFillStyle(0);
+  leg3->SetBorderSize(0);
+  TCanvas* ctrsel=new TCanvas("ctrsel","Track Sel");
+  ctrsel->SetLogy();
+  for(Int_t i=0; i<maxfa; i++){
+    TH1F* hd0fb4=(TH1F*)lists[i]->FindObject("hd0TracksFilterBit4");
+    TH1F* hd0SPD1=(TH1F*)lists[i]->FindObject("hd0TracksSPDin");
+    TH1F* hd0SPDany=(TH1F*)lists[i]->FindObject("hd0TracksSPDany");
+    TH1F* hd0TPCITScuts=(TH1F*)lists[i]->FindObject("hd0TracksTPCITSSPDany");
+    if(hd0fb4 && hd0SPD1 && hd0SPDany && hd0TPCITScuts){
+      if(i==0){check=1;}
+      else{if(check==0)return;}
+      ctrsel->cd();
+      hd0SPD1->SetLineColor(kCyan+3);
+      hd0SPDany->SetLineColor(4);
+      hd0TPCITScuts->SetLineColor(kGreen+1);
+      hd0fb4->SetLineColor(2);
+      if(i==0){
+       hd0SPD1->Draw();
+       ctrsel->Update();
+       TPaveStats *st1=(TPaveStats*)hd0SPD1->GetListOfFunctions()->FindObject("stats");
+       st1->SetTextColor(kCyan+3);
+       st1->SetY1NDC(0.71);
+       st1->SetY2NDC(0.9);
+       hd0SPDany->Draw("sames");
+       ctrsel->Update();
+       TPaveStats *st2=(TPaveStats*)hd0SPDany->GetListOfFunctions()->FindObject("stats");
+       st2->SetY1NDC(0.51);
+       st2->SetY2NDC(0.7);
+       st2->SetTextColor(4);
+       hd0fb4->Draw("sames");
+       ctrsel->Update();
+       TPaveStats *st3=(TPaveStats*)hd0fb4->GetListOfFunctions()->FindObject("stats");
+       st3->SetY1NDC(0.31);
+       st3->SetY2NDC(0.5);
+       st3->SetTextColor(2);
+       hd0TPCITScuts->Draw("sames");
+       ctrsel->Update();
+       TPaveStats *st4=(TPaveStats*)hd0TPCITScuts->GetListOfFunctions()->FindObject("stats");
+       st4->SetY1NDC(0.71);
+       st4->SetY2NDC(0.9);
+       st4->SetX1NDC(0.55);
+       st4->SetX2NDC(0.75);
+       st4->SetTextColor(kGreen+1);
+       ctrsel->Modified();
+       leg3->AddEntry(hd0SPD1,"kITSrefit+SPD inner","L");
+       leg3->AddEntry(hd0SPDany,"kITSrefit+SPD any","L");
+       leg3->AddEntry(hd0TPCITScuts,"TPC+ITS cuts+SPD any","L");
+       leg3->AddEntry(hd0fb4,"Filter Bit 4","L");
+       leg3->AddEntry(hd0SPD1, legend[i], "L");
+      }
+     else{     
+       hd0SPD1->SetStats(0);
+       hd0SPD1->SetLineStyle(i+1);
+       hd0SPD1->Draw("sames"); 
+       hd0SPDany->SetStats(0);
+       hd0SPDany->SetLineStyle(i+1);
+       hd0TPCITScuts->SetStats(0);
+       hd0TPCITScuts->SetLineStyle(i+1);
+       hd0fb4->SetStats(0);
+       hd0fb4->SetLineStyle(i+1);
+       ctrsel->cd();
+       hd0SPD1->Draw("sames");
+       hd0SPDany->Draw("sames");
+       hd0TPCITScuts->Draw("sames");
+       hd0fb4->Draw("sames");
+       leg3->AddEntry(hd0SPD1, legend[i], "L");                                
+     }
+     
+    }
+  }
+  leg3->Draw();
+  ctrsel->SaveAs("ImpactParameterTrackSel.eps");
+  ctrsel->SaveAs("ImpactParameterTrackSel.pdf");
+}
+
index 5314bf97904060ce27069261ce06d44045d4ce64..f5f0d13ba030c50b2a0671a4b371310a447a0b6c 100644 (file)
@@ -43,7 +43,7 @@ ClassImp(AliAnalysisTaskCountLcEta) // adding the class to ROOT
 
 
 //__________________________________________________________________
-AliAnalysisTaskCountLcEta::AliAnalysisTaskCountLcEta(const char *name,const Int_t ncuts,Double_t *cuts)
+AliAnalysisTaskCountLcEta::AliAnalysisTaskCountLcEta(const char *name, Int_t ncuts,Double_t *cuts)
 : AliAnalysisTaskSE(name)
   , fESD(0)
   , fAOD(0)
index d8f3accd0f516cfc3b3ceac484b6c311c53eb078..ac0ba95b1db5f18a1cdd217f8a821ae460f2c045 100644 (file)
@@ -38,9 +38,9 @@ public:
    Float_t GetEtaAbs() const {return fEtaAbs;}
    void SetEtaAbsMax(Float_t eta){fEtaAbsMax=eta;}
    Float_t GetEtaAbsMax() const {return fEtaAbsMax;}
-   void SetCuts(const Int_t ncuts, Double_t* cuts){fNcuts=ncuts; fCuts=cuts;}
+   void SetCuts(Int_t ncuts, Double_t* cuts){fNcuts=ncuts; fCuts=cuts;}
    Double_t* GetCuts() const {return fCuts;}
-   void SetCutNames(const Int_t ncuts, TString* cutnames){if (ncuts!=fNcuts) {Printf("ERROR! %d names, expected %d",ncuts,fNcuts); return;} else fCutNames=cutnames;}
+   void SetCutNames(Int_t ncuts, TString* cutnames){if (ncuts!=fNcuts) {Printf("ERROR! %d names, expected %d",ncuts,fNcuts); return;} else fCutNames=cutnames;}
    TString* GetCutNames() const {return fCutNames;}
    
    void SetInvMassCut(Double_t mass){fInvMassCut=mass;}
index 91ef3856d2d9faa5bf8676a2558aaaa309cc9173..2882c99e6f74735a5efc330d926f0195c3efe03e 100644 (file)
@@ -190,8 +190,6 @@ void AliAnaChargedJetResponseMaker::SetMeasuredSpectrum(TH1D *hPtMeasured)
   int bin[1] = {0};
   bin[0] = 0;
   for(int i = hPtMeasured->FindBin(fPtMin); i<hPtMeasured->FindBin(fPtMax); i++) {
-    double pT[1]; 
-    pT[0]= hPtMeasured->GetBinCenter(i);
     fPtMeasured->SetBinContent(bin,(Double_t)hPtMeasured->GetBinContent(i));
     fPtMeasured->SetBinError(bin,(Double_t)hPtMeasured->GetBinError(i));
     bin[0]++;
@@ -462,7 +460,7 @@ void AliAnaChargedJetResponseMaker::InitializeResponseMatrixFine() {
   Int_t nbinsFine[fDimensions*2];
   Double_t xminFine[fDimensions*2];
   Double_t xmaxFine[fDimensions*2];
-  Double_t pTarrayFine[fDimensions*2];
+  // Double_t pTarrayFine[fDimensions*2];
 
   nbinsFine[fDimRec] = fResponseMatrix->GetAxis(fDimRec)->GetNbins()*fFineFrac; 
   nbinsFine[fDimGen] = fResponseMatrix->GetAxis(fDimRec)->GetNbins()*fFineFrac; 
@@ -470,8 +468,8 @@ void AliAnaChargedJetResponseMaker::InitializeResponseMatrixFine() {
   xminFine[fDimGen] = TMath::Min(fPtMin,0.);
   xmaxFine[fDimRec] = fResponseMatrix->GetAxis(fDimGen)->GetXmax();//+40.;
   xmaxFine[fDimGen] = fResponseMatrix->GetAxis(fDimGen)->GetXmax();//+40.;
-  pTarrayFine[fDimRec] = 0.;
-  pTarrayFine[fDimGen] = 0.;
+  // pTarrayFine[fDimRec] = 0.;
+  // pTarrayFine[fDimGen] = 0.;
 
   Double_t binWidth[2];
   binWidth[fDimRec] = fResponseMatrix->GetAxis(fDimRec)->GetBinWidth(1);
@@ -582,16 +580,16 @@ void AliAnaChargedJetResponseMaker::FillResponseMatrixFineAndMerge() {
   TAxis *recAxis = fResponseMatrixFine->GetAxis(fDimRec);
 
   Int_t nbinsFine[fDimensions*2];
-  Double_t xminFine[fDimensions*2]; 
-  Double_t xmaxFine[fDimensions*2];
+  //Double_t xminFine[fDimensions*2]; 
+  //Double_t xmaxFine[fDimensions*2];
   Double_t pTarrayFine[fDimensions*2];
 
   nbinsFine[fDimGen] = genAxis->GetNbins();
   nbinsFine[fDimRec] = recAxis->GetNbins();
-  xminFine[fDimGen]  = genAxis->GetXmin();
-  xminFine[fDimRec]  = recAxis->GetXmin();
-  xmaxFine[fDimGen]  = genAxis->GetXmax();
-  xmaxFine[fDimRec]  = recAxis->GetXmax();
+  //  xminFine[fDimGen]  = genAxis->GetXmin();
+  //  xminFine[fDimRec]  = recAxis->GetXmin();
+  //  xmaxFine[fDimGen]  = genAxis->GetXmax();
+  //  xmaxFine[fDimRec]  = recAxis->GetXmax();
   pTarrayFine[fDimGen] = 0.;
   pTarrayFine[fDimRec] = 0.;
 
index b2e1ca5cc5e79dec733a93d944b1355d75eb302c..273710f53dfa22879e56db499918fa5fe6bc2feb 100644 (file)
@@ -83,6 +83,7 @@ fCentMax(100.),
 fNInputTracksMin(0),
 fNInputTracksMax(-1),
 fRequireITSRefit(0),
+fApplySharedClusterCut(0),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0), 
@@ -213,6 +214,7 @@ fCentMax(100.),
 fNInputTracksMin(0),
 fNInputTracksMax(-1),
 fRequireITSRefit(0),
+fApplySharedClusterCut(0),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0),
@@ -1158,9 +1160,13 @@ Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
       else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal();
       else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal();    
       if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
-      if(fRequireITSRefit==0){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+      if(fRequireITSRefit==1){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
       if(bGood==false) continue;
-      if(TMath::Abs(tr->Eta())>0.9)continue;
+      if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(tr->GetTPCnclsS()) /Double_t(tr->GetTPCncls());
+           if (frac > 0.4) continue;
+      }
+     if(TMath::Abs(tr->Eta())>0.9)continue;
       if(tr->Pt()<0.15)continue;
       list->Add(tr);
       iCount++;
@@ -1218,8 +1224,12 @@ Int_t  AliAnalysisTaskJetCore::SelectTrigger(TList *list,Double_t minT,Double_t
       else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal();
       else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal();
       if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
-       if(fRequireITSRefit==0){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+       if(fRequireITSRefit==1){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
       if(bGood==false) continue;
+      if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(tr->GetTPCnclsS()) /Double_t(tr->GetTPCncls());
+           if (frac > 0.4) continue;
+      }
       if(TMath::Abs(tr->Eta())>0.9)continue;
       if(tr->Pt()<0.15)continue;
       list->Add(tr);
index 802955926605f2328c7d10ce9f09f34c3a4ae55b..2d68707b2bf61b0ce2bb2415f8b5488bd0c1aef5 100644 (file)
@@ -79,6 +79,7 @@ public:
    virtual void     SetNInputTracksMin(Int_t nTr) { fNInputTracksMin = nTr; }
    virtual void     SetNInputTracksMax(Int_t nTr) { fNInputTracksMax = nTr; }
    virtual void     SetRequireITSRefit(Int_t nref) {fRequireITSRefit=nref;}
+   virtual void     SetSharedClusterCut(Int_t docut){fApplySharedClusterCut=docut;}
    virtual void     SetAngStructCloseTracks(Int_t yesno){fAngStructCloseTracks=yesno;}
    virtual void     SetCheckMethods(Int_t yesno){fCheckMethods=yesno;}
    virtual void     SetEventMixing(Int_t yesno){fDoEventMixing=yesno;}
@@ -144,6 +145,7 @@ private:
    Int_t   fNInputTracksMin;  // lower bound of nb. of input tracks
    Int_t   fNInputTracksMax;  // upper bound of nb. of input tracks
    Int_t   fRequireITSRefit;
+   Int_t   fApplySharedClusterCut; // flag to apply shared cluster cut (needed for some AODs where this cut was not applied in the filtering)
    Int_t   fAngStructCloseTracks;//only constituents or all tracks with R<0.8 for the angular structure
    Int_t   fCheckMethods;     //to look into more detail into the core
    Int_t   fDoEventMixing;
index db809ff863a8ba4f02a9ddf66495b2f4c3f32753..8655fb19d15829c4e0c5ecc2b0bc4d9232a2b6c8 100644 (file)
@@ -32,12 +32,15 @@ AliHadCorrTask::AliHadCorrTask() :
   fOutCaloName(),
   fPhiMatch(0.05),
   fEtaMatch(0.025),
-  fDoTrackClus(0),
+  fDoTrackClus(kTRUE),
   fHadCorr(0),
   fEexclCell(0),
   fDoExact(kFALSE),
   fEsdMode(kTRUE),
   fOutClusters(0),
+  fHistMatchEtaPhiAll(0),
+  fHistMatchEtaPhiAllTr(0),
+  fHistMatchEtaPhiAllCl(0),
   fHistNclusvsCent(0),
   fHistNclusMatchvsCent(0),
   fHistEbefore(0),
@@ -81,12 +84,15 @@ AliHadCorrTask::AliHadCorrTask(const char *name, Bool_t histo) :
   fOutCaloName("CaloClustersCorr"),
   fPhiMatch(0.05),
   fEtaMatch(0.025),
-  fDoTrackClus(1),
+  fDoTrackClus(kTRUE),
   fHadCorr(0),
   fEexclCell(0),
   fDoExact(kFALSE),
   fEsdMode(kTRUE),
   fOutClusters(0),
+  fHistMatchEtaPhiAll(0),
+  fHistMatchEtaPhiAllTr(0),
+  fHistMatchEtaPhiAllCl(0),
   fHistNclusvsCent(0),
   fHistNclusMatchvsCent(0),
   fHistEbefore(0),
@@ -372,14 +378,23 @@ void AliHadCorrTask::UserCreateOutputObjects()
 {
   // Create my user objects.
 
-  if (!fCreateHisto) return;
-
   AliAnalysisTaskEmcal::UserCreateOutputObjects();
 
+  if (!fCreateHisto) return;
+
   TString name;
 
   const Int_t nCentChBins = fNcentBins * 2;
 
+  fHistMatchEtaPhiAll = new TH2F("fHistMatchEtaPhiAll", "fHistMatchEtaPhiAll", fNbins, -0.1, 0.1, fNbins, -0.1, 0.1);
+  fOutput->Add(fHistMatchEtaPhiAll);
+
+  fHistMatchEtaPhiAllTr = new TH2F("fHistMatchEtaPhiAllTr", "fHistMatchEtaPhiAllTr", fNbins, -0.1, 0.1, fNbins, -0.1, 0.1);
+  fOutput->Add(fHistMatchEtaPhiAllTr);
+
+  fHistMatchEtaPhiAllCl = new TH2F("fHistMatchEtaPhiAllCl", "fHistMatchEtaPhiAllCl", fNbins, -0.1, 0.1, fNbins, -0.1, 0.1);
+  fOutput->Add(fHistMatchEtaPhiAllCl);
+
   for(Int_t icent=0; icent<nCentChBins; ++icent) {
     for(Int_t ipt=0; ipt<9; ++ipt) {
       for(Int_t ieta=0; ieta<2; ++ieta) {
@@ -517,6 +532,8 @@ void AliHadCorrTask::ExecOnce()
 //________________________________________________________________________
 void AliHadCorrTask::DoTrackLoop() 
 {
+  // Loop over tracks to provide some QA
   AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
   AliParticleContainer *clusters = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
 
@@ -540,7 +557,8 @@ void AliHadCorrTask::DoTrackLoop()
     Int_t Nclus = emctrack->GetNumberOfMatchedObj();
 
     for (Int_t iClus = 0; iClus < Nclus; ++iClus) {
-      AliEmcalParticle *emccluster = static_cast<AliEmcalParticle*>(clusters->GetAcceptParticle(emctrack->GetMatchedObjId(iClus)));
+      AliEmcalParticle *emccluster = 
+        static_cast<AliEmcalParticle*>(clusters->GetAcceptParticle(emctrack->GetMatchedObjId(iClus)));
       if (!emccluster) continue;
 
       AliVCluster *cluster = emccluster->GetCluster();
@@ -550,6 +568,7 @@ void AliHadCorrTask::DoTrackLoop()
       Double_t etadiff = 999;
       Double_t phidiff = 999;
       AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff);
+      fHistMatchEtaPhiAllTr->Fill(etadiff,phidiff);
 
       if (TMath::Abs(phidiff) < fPhiMatch && TMath::Abs(etadiff) < fEtaMatch) NmatchClus++;
     }
@@ -558,34 +577,34 @@ void AliHadCorrTask::DoTrackLoop()
 }
 
 //________________________________________________________________________
-void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches) 
+void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, 
+                                         Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches) 
 {
   // Do the loop over matched tracks for cluster emccluster.
 
   AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
-
   AliVCluster *cluster = emccluster->GetCluster();
   Int_t iClus = emccluster->IdInCollection();
-  Double_t energyclus = cluster->E();
 
   // loop over matched tracks
   const Int_t Ntrks = emccluster->GetNumberOfMatchedObj();
   for (Int_t i = 0; i < Ntrks; ++i) {
     Int_t    iTrack = emccluster->GetMatchedObjId(i);
-    Double_t dR     = emccluster->GetMatchedObjDistance(i);
     
     AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(tracks->GetAcceptParticle(iTrack));
     if (!emctrack) continue;
 
-    // check if track also points to cluster
-    if (fDoTrackClus && (emctrack->GetMatchedObjId(0)) != iClus) continue;
-
     AliVTrack *track = emctrack->GetTrack();
     if (!track) continue;
 
     Double_t etadiff = 999;
     Double_t phidiff = 999;
     AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff);
+    if (fCreateHisto)
+      fHistMatchEtaPhiAllCl->Fill(etadiff, phidiff);
+
+    // check if track also points to cluster
+    if (fDoTrackClus && (emctrack->GetMatchedObjId(0)) != iClus) continue;
 
     Double_t mom       = track->P();
     UInt_t   mombin    = GetMomBin(mom); 
@@ -597,6 +616,7 @@ void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t
       Int_t etabin = 0;
       if(track->Eta() > 0) etabin=1;
       fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(etadiff, phidiff);
+      fHistMatchEtaPhiAll->Fill(etadiff, phidiff);
     }
     
     Double_t etaCut   = 0.0;
@@ -627,6 +647,8 @@ void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t
 
       if (fCreateHisto) {
         if (fHadCorr > 1) {
+          Double_t dR         = emccluster->GetMatchedObjDistance(i);
+          Double_t energyclus = cluster->E();
           fHistMatchdRvsEP[fCentBin]->Fill(dR, energyclus / mom);
         }
       }
@@ -645,6 +667,7 @@ Bool_t AliHadCorrTask::Run()
   AliParticleContainer *clusters = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
   AliEmcalParticle *emccluster = 0;
   
+  // provide some additional histograms
   if (fCreateHisto)
     DoTrackLoop();
 
@@ -719,20 +742,21 @@ Double_t AliHadCorrTask::ApplyHadCorrOneTrack(AliEmcalParticle *emccluster, Doub
   AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(tracks->GetParticle(iMin));
   if (!emctrack) return energyclus;
 
-  // check if track also points to cluster
-  Int_t cid = emctrack->GetMatchedObjId();
-  if (fDoTrackClus && (cid!=emccluster->IdInCollection())) return energyclus;
-
   AliVTrack *track = emctrack->GetTrack();
   if (!track) return energyclus;
 
   Double_t mom = track->P();
   if (mom < 1e-6) return energyclus;
 
-  Double_t dRmin      = emccluster->GetMatchedObjDistance();
   Double_t dEtaMin    = 1e9;
   Double_t dPhiMin    = 1e9;
   AliPicoTrack::GetEtaPhiDiff(track, cluster, dPhiMin, dEtaMin);
+  if (fCreateHisto)
+    fHistMatchEtaPhiAllCl->Fill(dEtaMin, dPhiMin);
+
+  // check if track also points to cluster
+  Int_t cid = emctrack->GetMatchedObjId();
+  if (fDoTrackClus && (cid!=emccluster->IdInCollection())) return energyclus;
 
   UInt_t mombin = GetMomBin(mom);
   Int_t centbinch = fCentBin;
@@ -745,8 +769,10 @@ Double_t AliHadCorrTask::ApplyHadCorrOneTrack(AliEmcalParticle *emccluster, Doub
       etabin = 1;
            
     fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(dEtaMin, dPhiMin);
+    fHistMatchEtaPhiAll->Fill(dEtaMin, dPhiMin);
     
     if (mom > 0) {
+      Double_t dRmin      = emccluster->GetMatchedObjDistance();
       fHistMatchEvsP[fCentBin]->Fill(energyclus, energyclus / mom);
       fHistEoPCent->Fill(fCent, energyclus / mom);
       fHistMatchdRvsEP[fCentBin]->Fill(dRmin, energyclus / mom);
@@ -812,18 +838,18 @@ Double_t AliHadCorrTask::ApplyHadCorrAllTracks(AliEmcalParticle *emccluster, Dou
   if ((energyclus - Esub) < clusEexcl) Esub = (energyclus - clusEexcl);
 
   // embedding
-  Double_t EsubMC = 0;
-  Double_t EsubBkg = 0;
-  Double_t EclusMC = 0;
-  Double_t EclusBkg = 0;
-  Double_t EclusCorr = 0;
-  Double_t EclusMCcorr = 0;
+  Double_t EsubMC       = 0;
+  Double_t EsubBkg      = 0;
+  Double_t EclusMC      = 0;
+  Double_t EclusBkg     = 0;
+  Double_t EclusCorr    = 0;
+  Double_t EclusMCcorr  = 0;
   Double_t EclusBkgcorr = 0;
   Double_t overSub = 0;
   if (fIsEmbedded) {
-    EsubMC = hadCorr * totalTrkP * trkPMCfrac;
-    EsubBkg = hadCorr * totalTrkP - EsubMC;
-    EclusMC = energyclus * cluster->GetMCEnergyFraction();
+    EsubMC   = hadCorr * totalTrkP * trkPMCfrac;
+    EsubBkg  = hadCorr * totalTrkP - EsubMC;
+    EclusMC  = energyclus * cluster->GetMCEnergyFraction();
     EclusBkg = energyclus - EclusMC;
  
     if (energyclus > Esub)
@@ -866,7 +892,6 @@ Double_t AliHadCorrTask::ApplyHadCorrAllTracks(AliEmcalParticle *emccluster, Dou
          if (track) {
            Int_t centbinchm = fCentBin;
            if (track->Charge()<0) centbinchm += fNcentBins;
-           
            fHistEsubPchRat[centbinchm]->Fill(totalTrkP, Esub / totalTrkP);
            fHistEsubPch[centbinchm]->Fill(totalTrkP, Esub);
          }
index 4149108709990bae5ea920aa236ed5349d868eed..db7d0389c05ecb0e7b2b2be196420c009dafe1cb 100644 (file)
@@ -56,6 +56,9 @@ class AliHadCorrTask : public AliAnalysisTaskEmcal {
 
   // QA plots
   TH2                   *fHistMatchEtaPhi[8][9][2];  //!deta vs. dphi of matched cluster-track pairs
+  TH2                   *fHistMatchEtaPhiAll;        //!deta vs. dphi of matched cluster-track pairs
+  TH2                   *fHistMatchEtaPhiAllTr;      //!deta vs. dphi of all cluster-track pairs (tr loop)
+  TH2                   *fHistMatchEtaPhiAllCl;      //!deta vs. dphi of all cluster-track pairs (cl loop)
   TH2                   *fHistMatchEvsP[4];          //!cluster energy vs. track momentum of matched pairs
   TH2                   *fHistNMatchEnergy[4];       //!n matches vs. cluster energy
   TH2                   *fHistNCellsEnergy[4][4];    //!n cells vs. cluster energy
@@ -70,8 +73,6 @@ class AliHadCorrTask : public AliAnalysisTaskEmcal {
   TH1                   *fHistEsubPch[8];            //!Esub vs. total momentum of matched tracks (only 1 match)
   TH2                   *fHistEsubPchRat[8];         //!Esub/momentum of matched tracks vs. total momentum of matched tracks (only 1 match)
   TH2                   *fHistEsubPchRatAll[8];      //!Esub/momentum of matched tracks vs. total momentum of matched tracks (all number of matches)
-
-  // Embedding QA plots
   TH2                   *fHistEmbTrackMatchesOversub[4];    //!Over-subtracted energy / cluster energy with embedded track matches (non-embedded matches < 5%)
   TH2                   *fHistNonEmbTrackMatchesOversub[4]; //!Over-subtracted energy / cluster energy with non-embedded track matches (embedded matches < 5%)
   TH2                   *fHistOversubMCClusters[4];         //!Over-subtracted energy / cluster energy (cluster MC energy fraction > 95%)
@@ -82,6 +83,6 @@ class AliHadCorrTask : public AliAnalysisTaskEmcal {
   AliHadCorrTask(const AliHadCorrTask&);            // not implemented
   AliHadCorrTask &operator=(const AliHadCorrTask&); // not implemented
 
-  ClassDef(AliHadCorrTask, 13) // Hadronic correction task
+  ClassDef(AliHadCorrTask, 14) // Hadronic correction task
 };
 #endif
index 5754afee6824f0962a69f63c4747fa65dbfcfec3..196cf97026527249321fc13964391c5bc2d62819 100644 (file)
@@ -38,6 +38,8 @@ ClassImp(AliAnalysisTaskEmcalDiJetAna)
 AliAnalysisTaskEmcalDiJetAna::AliAnalysisTaskEmcalDiJetAna() : 
   AliAnalysisTaskEmcalDiJetBase("AliAnalysisTaskEmcalDiJetAna"),
   fDoMatchFullCharged(kTRUE),
+  fNDiJetEtaBins(1),
+  fNAjBins(1),
   fh2CentRhoCh(0),
   fh2CentRhoScaled(0),
   fh3PtEtaPhiJetFull(0),
@@ -70,6 +72,8 @@ AliAnalysisTaskEmcalDiJetAna::AliAnalysisTaskEmcalDiJetAna() :
 AliAnalysisTaskEmcalDiJetAna::AliAnalysisTaskEmcalDiJetAna(const char *name) : 
   AliAnalysisTaskEmcalDiJetBase(name),
   fDoMatchFullCharged(kTRUE),
+  fNDiJetEtaBins(1),
+  fNAjBins(1),
   fh2CentRhoCh(0),
   fh2CentRhoScaled(0),
   fh3PtEtaPhiJetFull(0),
@@ -157,14 +161,14 @@ void AliAnalysisTaskEmcalDiJetAna::UserCreateOutputObjects()
   const Int_t nBinsSparse0 = 7;
   const Int_t nBinsPtW      = 30;
   const Int_t nBinsDPhi     = 72;
-  const Int_t nBinsKt       = 50;
-  const Int_t nBinsDiJetEta = 40;
+  const Int_t nBinsKt       = 30;
+  const Int_t nBinsDiJetEta = fNDiJetEtaBins;//40;
   const Int_t nBinsCentr    = fNcentBins;
-  const Int_t nBinsAj       = 20;
+  const Int_t nBinsAj       = fNAjBins;//20
   const Int_t nBins0[nBinsSparse0] = {nBinsPtW,nBinsPtW,nBinsDPhi,nBinsKt,nBinsDiJetEta,nBinsCentr,nBinsAj};
   //pT1, pT2, deltaPhi, kT
   const Double_t xmin0[nBinsSparse0]  = {  minPt, minPt, -0.5*TMath::Pi(),   0.,-1.,0.  , 0.};
-  const Double_t xmax0[nBinsSparse0]  = {  maxPt, maxPt,  1.5*TMath::Pi(), 100., 1.,100., 1.};
+  const Double_t xmax0[nBinsSparse0]  = {  maxPt, maxPt,  1.5*TMath::Pi(), 120., 1.,100., 1.};
   const Double_t centArrayBins[8] = {0.,2.,5.,10.,20.,40.,60.,100.};
 
   if(fDoChargedCharged) {
@@ -190,38 +194,38 @@ void AliAnalysisTaskEmcalDiJetAna::UserCreateOutputObjects()
     fOutput->Add(fhnDiJetVarsFull);
   }
 
-  fh3PtTrigKt1Kt2Ch = new TH3F("fh3PtTrigKt1Kt2Ch","fh3PtTrigKt1Kt2Ch;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsKt,-100.,100.,nBinsKt,-100.,100.);
+  fh3PtTrigKt1Kt2Ch = new TH3F("fh3PtTrigKt1Kt2Ch","fh3PtTrigKt1Kt2Ch;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsKt,0.,120.,nBinsKt,0.,120.);
   fOutput->Add(fh3PtTrigKt1Kt2Ch);  
 
-  fh3PtTrigKt1Kt2FuCh = new TH3F("fh3PtTrigKt1Kt2FuCh","fh3PtTrigKt1Kt2FuCh;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsKt,-100.,100.,nBinsKt,-100.,100.);
+  fh3PtTrigKt1Kt2FuCh = new TH3F("fh3PtTrigKt1Kt2FuCh","fh3PtTrigKt1Kt2FuCh;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsKt,0.,120.,nBinsKt,0.,120.);
   fOutput->Add(fh3PtTrigKt1Kt2FuCh); 
 
-  fh3PtTrigDPhi1DPhi2Ch = new TH3F("fh3PtTrigDPhi1DPhi2Ch","fh3PtTrigDPhi1DPhi2Ch;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsDPhi,-0.5*TMath::Pi(),1.5*TMath::Pi(),nBinsDPhi,-0.5*TMath::Pi(),1.5*TMath::Pi());
+  fh3PtTrigDPhi1DPhi2Ch = new TH3F("fh3PtTrigDPhi1DPhi2Ch","fh3PtTrigDPhi1DPhi2Ch;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,36,-0.5*TMath::Pi(),1.5*TMath::Pi(),36,-0.5*TMath::Pi(),1.5*TMath::Pi());
   fOutput->Add(fh3PtTrigDPhi1DPhi2Ch);  
 
-  fh3PtTrigDPhi1DPhi2FuCh = new TH3F("fh3PtTrigDPhi1DPhi2FuCh","fh3PtTrigDPhi1DPhi2FuCh;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,nBinsDPhi,-0.5*TMath::Pi(),1.5*TMath::Pi(),nBinsDPhi,-0.5*TMath::Pi(),1.5*TMath::Pi());
+  fh3PtTrigDPhi1DPhi2FuCh = new TH3F("fh3PtTrigDPhi1DPhi2FuCh","fh3PtTrigDPhi1DPhi2FuCh;#it{p}_{T,1} (GeV/#it{c});#it{k}_{T,1};#it{k}_{T,2}",nBinsPt,minPt,maxPt,36,-0.5*TMath::Pi(),1.5*TMath::Pi(),36,-0.5*TMath::Pi(),1.5*TMath::Pi());
   fOutput->Add(fh3PtTrigDPhi1DPhi2FuCh);  
  
 
   for(Int_t i=0; i<4; i++) {
     TString histoName = Form("fh3DiJetKtNEFPtAssoc_TrigBin%d",i);
-    fh3DiJetKtNEFPtAssoc[i] = new TH3F(histoName.Data(),histoName.Data(),nBinsKt,-100.,100.,50,0.,1.,nBinsPt,minPt,maxPt);
+    fh3DiJetKtNEFPtAssoc[i] = new TH3F(histoName.Data(),histoName.Data(),nBinsKt,0.,120.,50,0.,1.,nBinsPt,minPt,maxPt);
     fOutput->Add(fh3DiJetKtNEFPtAssoc[i]);
 
     histoName = Form("fCentCorrPtAssocCh_TrigBin%d",i);
-    fCentCorrPtAssocCh[i]  = new TH3F(histoName.Data(),histoName.Data(),100,0.,100.,100,0.,100.,nBinsPt,minPt,maxPt);
+    fCentCorrPtAssocCh[i]  = new TH3F(histoName.Data(),histoName.Data(),10,0.,100.,10,0.,100.,nBinsPt,minPt,maxPt);
     fOutput->Add(fCentCorrPtAssocCh[i]);
 
     histoName = Form("fCentCorrPtAssocFuCh_TrigBin%d",i);
-    fCentCorrPtAssocFuCh[i]  = new TH3F(histoName.Data(),histoName.Data(),100,0.,100.,100,0.,100.,nBinsPt,minPt,maxPt);
+    fCentCorrPtAssocFuCh[i]  = new TH3F(histoName.Data(),histoName.Data(),10,0.,100.,10,0.,100.,nBinsPt,minPt,maxPt);
     fOutput->Add(fCentCorrPtAssocFuCh[i]);
 
     histoName = Form("fAjPtAssocCentCh_TrigBin%d",i);
-    fAjPtAssocCentCh[i]  = new TH3F(histoName.Data(),histoName.Data(),100,0.,1.,nBinsPt,minPt,maxPt,100,0.,100.);
+    fAjPtAssocCentCh[i]  = new TH3F(histoName.Data(),histoName.Data(),50,0.,1.,nBinsPt,minPt,maxPt,20,0.,100.);
     fOutput->Add(fAjPtAssocCentCh[i]);
 
     histoName = Form("fAjPtAssocCentFuCh_TrigBin%d",i);
-    fAjPtAssocCentFuCh[i]  = new TH3F(histoName.Data(),histoName.Data(),100,0.,1.,nBinsPt,minPt,maxPt,100,0.,100.);
+    fAjPtAssocCentFuCh[i]  = new TH3F(histoName.Data(),histoName.Data(),50,0.,1.,nBinsPt,minPt,maxPt,20,0.,100.);
     fOutput->Add(fAjPtAssocCentFuCh[i]);
 
     histoName = Form("fh3PtAssoc1PtAssoc2DPhi23Ch_TrigBin%d",i);
@@ -241,7 +245,7 @@ void AliAnalysisTaskEmcalDiJetAna::UserCreateOutputObjects()
   const Int_t nBinsType = 3;
   const Int_t nBinsMatch[nBinsSparseMatch] = {nBinsPt,nBinsPt,nBinsDPhiMatch,nBinsDEtaMatch,nBinsDR,nBinsFraction,nBinsType};
   //pTfull, pTch, deltaPhi, deltaEta, deltaR, fraction, jet type (leading,subleading,other)
-  const Double_t xminMatch[nBinsSparseMatch]  = { minPt, minPt, -0.5,-0.5, 0.,0.  ,0};
+  const Double_t xminMatch[nBinsSparseMatch]  = { minPt, minPt, -0.5,-0.5, 0. ,0.  ,0};
   const Double_t xmaxMatch[nBinsSparseMatch]  = { maxPt, maxPt,  0.5, 0.5, 0.5,1.05,3};
   if(fDoMatchFullCharged) {
     fhnMatchingFullCharged = new THnSparseF("fhnMatchingFullCharged","fhnMatchingFullCharged;#it{p}_{T,full} (GeV/#it{c});#it{p}_{T,ch} (GeV/#it{c});#Delta#varphi;#Delta#eta;#Delta R;f_{ch};type",
@@ -276,7 +280,6 @@ Bool_t AliAnalysisTaskEmcalDiJetAna::FillHistograms()
   fh2CentRhoCh->Fill(fCent,fRhoChVal);
   fh2CentRhoScaled->Fill(fCent,fRhoFullVal);
 
-
   Int_t nJetsFull = GetNJets(fContainerFull);
   for(Int_t ij=0; ij<nJetsFull; ij++) {
     AliEmcalJet *jet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ij, fContainerFull));
@@ -284,7 +287,6 @@ Bool_t AliAnalysisTaskEmcalDiJetAna::FillHistograms()
 
     Double_t jetPt = GetJetPt(jet,0);
     fh3PtEtaPhiJetFull->Fill(jetPt,jet->Eta(),jet->Phi());
-    
   }
 
   Int_t nJetsCh = GetNJets(fContainerCharged);
@@ -294,9 +296,7 @@ Bool_t AliAnalysisTaskEmcalDiJetAna::FillHistograms()
 
       Double_t jetPt = GetJetPt(jet,1);
       fh3PtEtaPhiJetCharged->Fill(jetPt,jet->Eta(),jet->Phi());
-    
   }
-  
 
   return kTRUE;
 }
@@ -377,17 +377,7 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateTwoJets(const Int_t type) {
     return;
   }
 
-  Int_t nJetsTrig  = 0;
-  if(type==0) {
-    nJetsTrig  = GetNJets(fContainerFull);
-  }
-  else if(type==1) {
-    nJetsTrig  = GetNJets(fContainerCharged);
-  }
-  else if(type==2) {
-    nJetsTrig  = GetNJets(fContainerFull);
-  }
-
+  Int_t nJetsTrig  = GetNJets(typet);
   for(Int_t ijt=0; ijt<nJetsTrig; ijt++) {
 
     AliEmcalJet *jetTrig = NULL; 
@@ -399,7 +389,6 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateTwoJets(const Int_t type) {
     else
       jetTrig = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ijt, typet));
 
-
     if(!jetTrig)
       continue; //jet not selected
     
@@ -425,7 +414,6 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateTwoJets(const Int_t type) {
       FillThreeJetHistos(jetTrig,jetAssoc,jetAssoc2,type);
     
   }
-
 }
 
 //________________________________________________________________________
@@ -445,7 +433,6 @@ AliEmcalJet* AliAnalysisTaskEmcalDiJetAna::GetLeadingJet(const Int_t type) {
   Double_t ptLead = -999;
   Int_t    iJetLead = -1;
   for(Int_t ij=0; ij<nJets; ij++) {
-
     AliEmcalJet *jet = NULL;
     if(type==0) {
       jet = static_cast<AliEmcalJet*>(GetJetFromArray(ij, cont));
@@ -464,13 +451,11 @@ AliEmcalJet* AliAnalysisTaskEmcalDiJetAna::GetLeadingJet(const Int_t type) {
       ptLead = jetPt;
       iJetLead = ij;
     }
-
   }
 
   AliEmcalJet *jetLead = static_cast<AliEmcalJet*>(GetJetFromArray(iJetLead, cont));
 
   return jetLead;
-
 }
 
 //________________________________________________________________________
@@ -489,7 +474,6 @@ AliEmcalJet* AliAnalysisTaskEmcalDiJetAna::GetLeadingAssociatedJet(const Int_t t
   AliEmcalJet *jetAssocLead = GetLeadingJetOppositeHemisphere(type, typea, jetTrig);
   
   return jetAssocLead;
-
 }
 
 //________________________________________________________________________
@@ -508,7 +492,6 @@ AliEmcalJet* AliAnalysisTaskEmcalDiJetAna::GetSecondLeadingAssociatedJet(const I
   AliEmcalJet *jetAssocLead2 = GetSecondLeadingJetOppositeHemisphere(type, typea, jetTrig);
   
   return jetAssocLead2;
-
 }
 
 //________________________________________________________________________
@@ -536,23 +519,10 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateAllJets(const Int_t type) {
     return;
   }
 
-  Int_t nJetsTrig  = 0;
-  Int_t nJetsAssoc = 0;
-  if(type==0) {
-    nJetsTrig  = GetNJets(fContainerFull);
-    nJetsAssoc = nJetsTrig;
-  }
-  else if(type==1) {
-    nJetsTrig  = GetNJets(fContainerCharged);
-    nJetsAssoc = nJetsTrig;
-  }
-  else if(type==2) {
-    nJetsTrig  = GetNJets(fContainerFull);
-    nJetsAssoc = GetNJets(fContainerCharged);
-  }
+  Int_t nJetsTrig  = GetNJets(typet);
+  Int_t nJetsAssoc = GetNJets(typea);
 
   for(Int_t ijt=0; ijt<nJetsTrig; ijt++) {
-
     AliEmcalJet *jetTrig = NULL; 
     if(type==0) {
       jetTrig = static_cast<AliEmcalJet*>(GetJetFromArray(ijt, typet));
@@ -562,7 +532,6 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateAllJets(const Int_t type) {
     else
       jetTrig = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ijt, typet));
 
-
     if(!jetTrig)
       continue; //jet not selected
     
@@ -621,7 +590,7 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateLeadingSubleadingJets(const Int_t ty
     return;
   }
 
-  AliEmcalJet *jetTrig = GetLeadingJet(type);
+  AliEmcalJet *jetTrig = GetLeadingJet(typet);
   if(!jetTrig)
     return;
 
@@ -634,10 +603,7 @@ void AliAnalysisTaskEmcalDiJetAna::CorrelateLeadingSubleadingJets(const Int_t ty
   if(!jetAssoc)
     return;
   
-
   FillDiJetHistos(jetTrig,jetAssoc, type);
-  
-
 }
 
 //________________________________________________________________________
@@ -651,17 +617,17 @@ void AliAnalysisTaskEmcalDiJetAna::FillDiJetHistos(const AliEmcalJet *jet1, cons
 
   Int_t typet = 0;
   Int_t typea = 0;
-  if(mode==0) {
-    typet = 0;
-    typea = 0;
+  if(mode==0) { //full-full
+    typet = fContainerFull;
+    typea = fContainerFull;
   }
-  else if(mode==1) {
-    typet = 1;
-    typea = 1;
+  else if(mode==1) { //charged-charged
+    typet = fContainerCharged;
+    typea = fContainerCharged;
   }
-  else if(mode==2) {
-    typet = 0;
-    typea = 1;
+  else if(mode==2) { //full-charged
+    typet = fContainerFull;
+    typea = fContainerCharged;
   }
   else {
     AliWarning(Form("%s: mode %d of dijet correlation not defined!",GetName(),mode));
@@ -672,13 +638,13 @@ void AliAnalysisTaskEmcalDiJetAna::FillDiJetHistos(const AliEmcalJet *jet1, cons
   Double_t jetAssocPt = GetJetPt(jet2,typea);
 
   Double_t deltaPhi = GetDeltaPhi(jet1->Phi(),jet2->Phi());
-  if(fDebug>10) Printf("deltaPhi:%.2f",deltaPhi);
 
   Double_t kT = TMath::Abs(jetTrigPt*TMath::Sin(deltaPhi));
 
   Double_t dijetEta = (jet1->Eta()+jet2->Eta())/2.;
 
-  Double_t aj = (jetTrigPt-jetAssocPt)/(jetTrigPt+jetAssocPt);
+  Double_t aj = 0.;
+  if((jetTrigPt+jetAssocPt)>0.) aj = (jetTrigPt-jetAssocPt)/(jetTrigPt+jetAssocPt);
 
   Double_t diJetVars[7] = {jetTrigPt,jetAssocPt,deltaPhi,kT,dijetEta,fCent,aj};
 
@@ -704,7 +670,6 @@ void AliAnalysisTaskEmcalDiJetAna::FillDiJetHistos(const AliEmcalJet *jet1, cons
   AliCentrality *aliCent = InputEvent()->GetCentrality();
   if (aliCent) {
     centZNA = aliCent->GetCentralityPercentile("ZNA");
-    
     if(trigBin>-1 && trigBin<4) {
       if(deltaPhi>dPhiMin && deltaPhi<dPhiMax) {
        if(mode==1) {
@@ -732,17 +697,17 @@ void AliAnalysisTaskEmcalDiJetAna::FillThreeJetHistos(const AliEmcalJet *jet1, c
 
   Int_t typet = 0;
   Int_t typea = 0;
-  if(mode==0) {
-    typet = 0;
-    typea = 0;
+  if(mode==0) { //full-full
+    typet = fContainerFull;
+    typea = fContainerFull;
   }
-  else if(mode==1) {
-    typet = 1;
-    typea = 1;
+  else if(mode==1) { //charged-charged
+    typet = fContainerCharged;
+    typea = fContainerCharged;
   }
-  else if(mode==2) {
-    typet = 0;
-    typea = 1;
+  else if(mode==2) { //full-charged
+    typet = fContainerFull;
+    typea = fContainerCharged;
   }
   else {
     AliWarning(Form("%s: mode %d of dijet correlation not defined!",GetName(),mode));
@@ -781,7 +746,6 @@ void AliAnalysisTaskEmcalDiJetAna::FillThreeJetHistos(const AliEmcalJet *jet1, c
       else if(mode==2)
        fh3PtTrigKt1Kt2FuCh->Fill(jetTrigPt,kT12,kT13);
     }
-  
   }
 
 }
@@ -800,7 +764,6 @@ Int_t AliAnalysisTaskEmcalDiJetAna::GetPtTriggerBin(Double_t pt) {
     binTrig = 3;
 
   return binTrig;
-
 }
 
 //________________________________________________________________________
@@ -811,7 +774,7 @@ void AliAnalysisTaskEmcalDiJetAna::FillMatchFullChargedHistos(Int_t cFull,Int_t
 
   Int_t match = MatchFullAndChargedJets(cFull,cCharged);
   if(match==0) {
-    if(fDebug>1) AliWarning(Form("%s: matching failed",GetName()));
+    AliDebug(11,Form("%s: matching failed",GetName()));
     return;
   }
   
@@ -823,7 +786,6 @@ void AliAnalysisTaskEmcalDiJetAna::FillMatchFullChargedHistos(Int_t cFull,Int_t
     if(!jetCh) continue;
 
     Double_t shFraction = GetFractionSharedPt(jetFull,jetCh);
-    if(fDebug>10) Printf("shared charged pT:%.2f",shFraction);
     Double_t matchVars[7] = {
       jetFull->Pt(),
       jetCh->Pt(),
@@ -846,12 +808,12 @@ Int_t AliAnalysisTaskEmcalDiJetAna::MatchFullAndChargedJets(Int_t cFull, Int_t c
   //
 
   if(GetNJets(cFull)<1) {
-    if(fDebug>1) AliInfo(Form("%s: no full jets: %d", GetName(),GetNJets(cFull)));
+    AliDebug(2,Form("%s: no full jets: %d", GetName(),GetNJets(cFull)));
     return 0;
   }
 
   if(GetNJets(cCharged)<1) {
-    if(fDebug>1) AliInfo(Form("%s: no charged jets: %d", GetName(),GetNJets(cCharged)));
+    AliDebug(2,Form("%s: no charged jets: %d", GetName(),GetNJets(cCharged)));
     return 0;
   }
 
@@ -859,21 +821,20 @@ Int_t AliAnalysisTaskEmcalDiJetAna::MatchFullAndChargedJets(Int_t cFull, Int_t c
   TClonesArray *cJetsCharged = GetJetArray(cCharged);
 
   if(!cJetsFull) {
-    if(fDebug>1) AliInfo(Form("%s: no full jet array",GetName()));
+    AliDebug(2,Form("%s: no full jet array",GetName()));
     return 0;
   }
 
   if(!cJetsCharged) {
-    if(fDebug>1)  AliInfo(Form("%s: no charged jet array",GetName()));
+    AliDebug(2,Form("%s: no charged jet array",GetName()));
     return 0;
   }
 
-
   if(!fMatchingDone) {
-      MatchJetsGeo(cFull, cCharged, fDebug);
+      MatchJetsGeo(cFull, cCharged, 0);
       return 1;  
   } else {
-    if(fDebug>1) AliInfo(Form("%s: Matching already done before",GetName()));
+    AliDebug(11,Form("%s: Matching already done before",GetName()));
     return 1;
   }
 
index dd1b55e63282c56ad8975d499bc10a7686d5fa7c..e092c8cfdf7c7e6ddde040bd5374b321a968ac68 100644 (file)
@@ -26,6 +26,8 @@ class AliAnalysisTaskEmcalDiJetAna : public AliAnalysisTaskEmcalDiJetBase {
 
   //Setters
   void                        SetMatchFullCharged(Bool_t b)        { fDoMatchFullCharged = b;}
+  void                        SetNDiJetEtaBins(Int_t n)            { fNDiJetEtaBins = n;     }
+  void                        SetNAjBins(Int_t n)                  { fNAjBins = n;           }
 
 
   //Getters
@@ -51,6 +53,8 @@ class AliAnalysisTaskEmcalDiJetAna : public AliAnalysisTaskEmcalDiJetBase {
 
  private:
   Bool_t            fDoMatchFullCharged;                  //  do full-charged matching histos
+  Int_t             fNDiJetEtaBins;                       // nbins in dijet eta axis
+  Int_t             fNAjBins;                             // nbins in Aj axis
   TH2F             *fh2CentRhoCh;                         //! cent vs rho charged
   TH2F             *fh2CentRhoScaled;                     //! cent vs rho scaled
   TH3F             *fh3PtEtaPhiJetFull;                   //! pt,eta,phi of full jets
@@ -81,6 +85,6 @@ class AliAnalysisTaskEmcalDiJetAna : public AliAnalysisTaskEmcalDiJetBase {
   AliAnalysisTaskEmcalDiJetAna(const AliAnalysisTaskEmcalDiJetAna&);            // not implemented
   AliAnalysisTaskEmcalDiJetAna &operator=(const AliAnalysisTaskEmcalDiJetAna&); // not implemented
 
-  ClassDef(AliAnalysisTaskEmcalDiJetAna, 9) // dijet analysis task
+  ClassDef(AliAnalysisTaskEmcalDiJetAna, 10) // dijet analysis task
 };
 #endif
index ea9ca519d6c14c8219fe17a26b4b5352f8e84986..b4176af141a743f19a36509957aa755e94c0e9d2 100644 (file)
@@ -113,13 +113,18 @@ Bool_t AliAnalysisTaskEmcalDiJetBase::SelectEvent() {
   if(!fTriggerClass.IsNull()) {
     //Check if requested trigger was fired
     TString firedTrigClass = InputEvent()->GetFiredTriggerClasses();
+
     if(!firedTrigClass.Contains(fTriggerClass))
       return kFALSE;
-    if(fTriggerClass.Contains("J2") && firedTrigClass.Contains("J1")) //only accept J2 triggers which were not fired by J1 as well
+    else if(fTriggerClass.Contains("J1") && fTriggerClass.Contains("J2")) { //if events with J1&&J2 are requested
+      if(!firedTrigClass.Contains("J1") || !firedTrigClass.Contains("J2") ) //check if both are fired
+        return kFALSE;
+    }
+    else if(fTriggerClass.Contains("J1") && firedTrigClass.Contains("J2")) //if J2 is requested also add triggers which have J1&&J2. Reject if J1 is requested and J2 is fired
       return kFALSE;
   }
-
-   fhNEvents->Fill(1.5);
+  
+  fhNEvents->Fill(1.5);
 
   fHistTrialsSelEvents->Fill(fPtHardBin, fNTrials);
   
@@ -152,7 +157,7 @@ void AliAnalysisTaskEmcalDiJetBase::UserCreateOutputObjects()
 }
 
 //________________________________________________________________________
-Bool_t AliAnalysisTaskEmcalDiJetBase::IsSameJet(const Int_t ijt, const Int_t ija, const Int_t type, const Bool_t isMC) {
+Bool_t AliAnalysisTaskEmcalDiJetBase::IsSameJet(Int_t ijt, Int_t ija, Int_t type, Bool_t isMC) {
    //check if two jets are the same one
 
    Bool_t bSame = kFALSE;
@@ -193,7 +198,7 @@ Bool_t AliAnalysisTaskEmcalDiJetBase::IsSameJet(const Int_t ijt, const Int_t ija
 
 
 //________________________________________________________________________
-Double_t AliAnalysisTaskEmcalDiJetBase::GetJetPt(const AliEmcalJet *jet, const Int_t type) {
+Double_t AliAnalysisTaskEmcalDiJetBase::GetJetPt(const AliEmcalJet *jet, Int_t type) {
 
   if(!jet) return -99;
 
@@ -215,7 +220,7 @@ Double_t AliAnalysisTaskEmcalDiJetBase::GetZ(const AliVParticle *trk, const AliE
 }
 
 //________________________________________________________________________
-Double_t AliAnalysisTaskEmcalDiJetBase::GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const
+Double_t AliAnalysisTaskEmcalDiJetBase::GetZ(Double_t trkPx, Double_t trkPy, Double_t trkPz, Double_t jetPx, Double_t jetPy, Double_t jetPz) const
 {
   // 
   // Get the z of a constituent inside of a jet
@@ -282,7 +287,7 @@ Double_t AliAnalysisTaskEmcalDiJetBase::GetFractionSharedPt(const AliEmcalJet *j
  
   if(jetPtCh>0) {
 
-    if(fDebug>10)  AliInfo(Form("%s: nConstituents: %d, ch: %d  chne: %d ne: %d",GetName(),jetFull->GetNumberOfConstituents(),jetCharged->GetNumberOfTracks(),jetFull->GetNumberOfTracks(),jetFull->GetNumberOfClusters()));
+    AliDebug(11,Form("%s: nConstituents: %d, ch: %d  chne: %d ne: %d",GetName(),jetFull->GetNumberOfConstituents(),jetCharged->GetNumberOfTracks(),jetFull->GetNumberOfTracks(),jetFull->GetNumberOfClusters()));
     
     Double_t sumPt = 0.;
     AliVParticle *vpf = 0x0;
@@ -305,7 +310,7 @@ Double_t AliAnalysisTaskEmcalDiJetBase::GetFractionSharedPt(const AliEmcalJet *j
     fraction = sumPt/jetPtCh;
   }
 
-  if(fDebug>10) AliInfo(Form("%s: charged shared fraction: %.2f",GetName(),fraction));
+  AliDebug(11,Form("%s: charged shared fraction: %.2f",GetName(),fraction));
 
   return fraction;
 
@@ -432,7 +437,7 @@ void AliAnalysisTaskEmcalDiJetBase::MatchJetsGeo(Int_t cFull, Int_t cCharged,
   // check for "true" correlations
   for(int ifu = 0;ifu<nFullJets;ifu++){
     for(int ich = 0;ich<nChJets;ich++){
-      if(iDebug>10) AliInfo(Form("%s: Flag[%d][%d] %d ",GetName(),ifu,ich,iFlag[ifu*nChJets+ich]));
+      AliDebug(11,Form("%s: Flag[%d][%d] %d ",GetName(),ifu,ich,iFlag[ifu*nChJets+ich]));
       
       if(kMode==3){
         // we have a uniqe correlation
@@ -442,7 +447,7 @@ void AliAnalysisTaskEmcalDiJetBase::MatchJetsGeo(Int_t cFull, Int_t cCharged,
          AliEmcalJet *fullJet = static_cast<AliEmcalJet*>(GetJetFromArray(ifu, cFull));
          Double_t dR = GetDeltaR(fullJet,chJet); 
 
-         if(iDebug>10) Printf("closest jets %d  %d  dR =  %f",ich,ifu,dR);
+         AliDebug(11,Form("closest jets %d  %d  dR =  %f",ich,ifu,dR));
 
          chJet->SetClosestJet(fullJet,dR);
          fullJet->SetClosestJet(chJet,dR);
@@ -533,7 +538,7 @@ void AliAnalysisTaskEmcalDiJetBase::SetChargedFractionIndexMC() {
 }
 
 //_______________________________________________________________________
-AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig) {
+AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetLeadingJetOppositeHemisphere(Int_t type, Int_t typea, const AliEmcalJet *jetTrig) {
 
   // Get leading jet in opposite hemisphere from trigger jet
   // type = correlation type
@@ -580,7 +585,7 @@ AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetLeadingJetOppositeHemisphere(cons
 }
 
 //_______________________________________________________________________
-AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetSecondLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig) {
+AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetSecondLeadingJetOppositeHemisphere(Int_t type, Int_t typea, const AliEmcalJet *jetTrig) {
 
   // Get leading jet in opposite hemisphere from trigger jet
   // type = correlation type
index 3cff151a8d9ed625a079a7aeab4600b0dfb06795..0bdb91dba9837c08110590ac7a6538f42d58931f 100644 (file)
@@ -66,16 +66,16 @@ class AliAnalysisTaskEmcalDiJetBase : public AliAnalysisTaskEmcalJet {
   Double_t GetDeltaR(const AliEmcalJet* jet1, const AliEmcalJet* jet2) const;
 
   Double_t GetZ(const AliVParticle *trk, const AliEmcalJet *jet)       const;
-  Double_t GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const;
+  Double_t GetZ(Double_t trkPx, Double_t trkPy, Double_t trkPz, Double_t jetPx, Double_t jetPy, Double_t jetPz) const;
 
-  AliEmcalJet* GetLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig);
-  AliEmcalJet* GetSecondLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig);
+  AliEmcalJet* GetLeadingJetOppositeHemisphere(Int_t type, Int_t typea, const AliEmcalJet *jetTrig);
+  AliEmcalJet* GetSecondLeadingJetOppositeHemisphere(Int_t type, Int_t typea, const AliEmcalJet *jetTrig);
 
  protected:
   virtual Bool_t                      RetrieveEventObjects();
 
-  Bool_t                      IsSameJet(const Int_t jt, const Int_t ja, const Int_t type, const Bool_t isMC = kFALSE);
-  Double_t                    GetJetPt(const AliEmcalJet *jet, const Int_t type);
+  Bool_t                      IsSameJet(Int_t jt, Int_t ja, Int_t type, Bool_t isMC = kFALSE);
+  Double_t                    GetJetPt(const AliEmcalJet *jet, Int_t type);
 
   void                        MatchJetsGeo(Int_t cFull, Int_t cCharged,
                                           Int_t iDebug = 0, Float_t maxDist = 0.3, Int_t type = 0);
index 8ed995a86d1ff8fd5479bdae675bda8a046de1bd..8065d7ad3eb123a3f0e08b3549e337bb28d43ba0 100644 (file)
@@ -25,6 +25,7 @@
 #include "AliParticleContainer.h"
 #include "AliEmcalTriggerPatchInfo.h"
 #include "AliAODHeader.h"
+#include "AliPicoTrack.h"
 
 #include "AliAnalysisTaskEmcalJetTriggerQA.h"
 
@@ -44,6 +45,8 @@ AliAnalysisTaskEmcalJetTriggerQA::AliAnalysisTaskEmcalJetTriggerQA() :
   fNFastOR(16),
   fhNEvents(0),
   fh3PtEtaPhiTracks(0),
+  fh3PtEtaPhiTracksOnEmcal(0),
+  fh3PtEtaPhiTracksProp(0),
   fh3PtEtaPhiJetFull(0),
   fh3PtEtaPhiJetCharged(0),
   fh2NJetsPtFull(0),
@@ -92,6 +95,8 @@ AliAnalysisTaskEmcalJetTriggerQA::AliAnalysisTaskEmcalJetTriggerQA(const char *n
   fNFastOR(16),
   fhNEvents(0),
   fh3PtEtaPhiTracks(0),
+  fh3PtEtaPhiTracksOnEmcal(0),
+  fh3PtEtaPhiTracksProp(0),
   fh3PtEtaPhiJetFull(0),
   fh3PtEtaPhiJetCharged(0),
   fh2NJetsPtFull(0),
@@ -143,20 +148,17 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::SelectEvent() {
   if(!fTriggerClass.IsNull()) {
     //Check if requested trigger was fired
     TString firedTrigClass = InputEvent()->GetFiredTriggerClasses();
-    
-     if(fTriggerClass.Contains("J1") && fTriggerClass.Contains("J2")) {
-      if(!firedTrigClass.Contains("J1") || !firedTrigClass.Contains("J2") )
+
+    if(fTriggerClass.Contains("J1") && fTriggerClass.Contains("J2")) { //if events with J1&&J2 are requested
+      if(!firedTrigClass.Contains("J1") || !firedTrigClass.Contains("J2") ) //check if both are fired
         return kFALSE;
     }
     else {
       if(!firedTrigClass.Contains(fTriggerClass))
-        return kFALSE;
-      if(fTriggerClass.Contains("J2") && firedTrigClass.Contains("J1")) //only accept J2 triggers which were not fired by J1 as well
-        return kFALSE;
-      else if(fTriggerClass.Contains("J1") && firedTrigClass.Contains("J2")) //only accept J2 triggers which were not fired by J1 as well
-        return kFALSE;
+       return kFALSE;
+      else if(fTriggerClass.Contains("J1") && firedTrigClass.Contains("J2")) //if J2 is requested also add triggers which have J1&&J2. Reject if J1 is requested and J2 is fired
+       return kFALSE;
     }
-     
   }
 
   fhNEvents->Fill(1.5);
@@ -168,26 +170,25 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::SelectEvent() {
 //________________________________________________________________________
 void AliAnalysisTaskEmcalJetTriggerQA::FindTriggerPatch() {
 
-  //Code to get position of trigger
+  //Fill trigger patch histos for main trigger
 
   AliEmcalTriggerPatchInfo *patch = GetMainTriggerPatch();
   if(patch) {
     fMaxPatchEnergy = patch->GetPatchE();
     Double_t patchADCGeV = patch->GetADCAmpGeVRough();
-    if(patch->IsJetLow() && !patch->IsJetHigh()) {
+    if(patch->IsJetLow() && !patch->IsJetHigh()) { //main patch only fired low threshold trigger
       fh3PatchEnergyEtaPhiCenterJ2->Fill(patch->GetPatchE(),patch->GetEtaGeo(),patch->GetPhiGeo());
       fh3PatchADCEnergyEtaPhiCenterJ2->Fill(patchADCGeV,patch->GetEtaGeo(),patch->GetPhiGeo());
     }
-    else if(patch->IsJetHigh() && !patch->IsJetLow()) {
+    else if(patch->IsJetHigh() && !patch->IsJetLow()) { //main patch only fired high threshold trigger - should never happen
       fh3PatchEnergyEtaPhiCenterJ1->Fill(patch->GetPatchE(),patch->GetEtaGeo(),patch->GetPhiGeo());
       fh3PatchADCEnergyEtaPhiCenterJ1->Fill(patchADCGeV,patch->GetEtaGeo(),patch->GetPhiGeo());
     }
-    else if(patch->IsJetHigh() && patch->IsJetLow()) {
+    else if(patch->IsJetHigh() && patch->IsJetLow()) { //main patch fired both triggers
       fh3PatchEnergyEtaPhiCenterJ1J2->Fill(patch->GetPatchE(),patch->GetEtaGeo(),patch->GetPhiGeo());
       fh3PatchADCEnergyEtaPhiCenterJ1J2->Fill(patchADCGeV,patch->GetEtaGeo(),patch->GetPhiGeo());
     }
   }
-
 }
 
 //________________________________________________________________________
@@ -233,7 +234,7 @@ void AliAnalysisTaskEmcalJetTriggerQA::UserCreateOutputObjects()
   Double_t *binsConst = new Double_t[fgkNConstBins+1];
   for(Int_t i=0; i<=fgkNConstBins; i++) binsConst[i]=(Double_t)kMinConst + (kMaxConst-kMinConst)/fgkNConstBins*(Double_t)i ;
 
-  Int_t fgkNMeanPtBins = 200;
+  Int_t fgkNMeanPtBins = 100;
   Float_t kMinMeanPt   = 0.;
   Float_t kMaxMeanPt   = 20.;
   Double_t *binsMeanPt = new Double_t[fgkNMeanPtBins+1];
@@ -257,9 +258,9 @@ void AliAnalysisTaskEmcalJetTriggerQA::UserCreateOutputObjects()
   Double_t *binsJetType = new Double_t[fgkNJetTypeBins+1];
   for(Int_t i=0; i<=fgkNJetTypeBins; i++) binsJetType[i]=(Double_t)kMinJetType + (kMaxJetType-kMinJetType)/fgkNJetTypeBins*(Double_t)i ;
 
-  Int_t fgkNTimeBins = 700;
-  Float_t kMinTime   = -400.;
-  Float_t kMaxTime   = 1000;
+  Int_t fgkNTimeBins = 100;
+  Float_t kMinTime   = -200.;
+  Float_t kMaxTime   = 200;
   Double_t *binsTime = new Double_t[fgkNTimeBins+1];
   for(Int_t i=0; i<=fgkNTimeBins; i++) binsTime[i]=(Double_t)kMinTime + (kMaxTime-kMinTime)/fgkNTimeBins*(Double_t)i ;
 
@@ -292,6 +293,12 @@ void AliAnalysisTaskEmcalJetTriggerQA::UserCreateOutputObjects()
   fh3PtEtaPhiTracks = new TH3F("fh3PtEtaPhiTracks","fh3PtEtaPhiTracks;#it{p}_{T}^{track};#eta;#varphi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PtEtaPhiTracks);
 
+  fh3PtEtaPhiTracksOnEmcal = new TH3F("fh3PtEtaPhiTracksOnEmcal","fh3PtEtaPhiTracksOnEmcal;#it{p}_{T}^{track};#eta;#varphi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fOutput->Add(fh3PtEtaPhiTracksOnEmcal);
+
+  fh3PtEtaPhiTracksProp = new TH3F("fh3PtEtaPhiTracksProp","fh3PtEtaPhiTracksProp;#it{p}_{T}^{track};#eta;#varphi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fOutput->Add(fh3PtEtaPhiTracksProp);
+
   fh3PtEtaPhiJetFull = new TH3F("fh3PtEtaPhiJetFull","fh3PtEtaPhiJetFull;#it{p}_{T}^{jet};#eta;#varphi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PtEtaPhiJetFull);
 
@@ -351,22 +358,22 @@ void AliAnalysisTaskEmcalJetTriggerQA::UserCreateOutputObjects()
   fh3PtLeadJet2VsPatchEnergy = new TH3F("fh3PtLeadJet2VsPatchEnergy","fh3PtLeadJet2VsPatchEnergy;#it{p}_{T}^{jet 1};Amplitude_{patch};trig type",fgkNPtBins,binsPt,fgkNPtBins,binsPt,fgkNJetTypeBins,binsJetType);
   fOutput->Add(fh3PtLeadJet2VsPatchEnergy);
 
-  fh3PatchEnergyEtaPhiCenterJ1 = new TH3F("fh3PatchEnergyEtaPhiCenterJ1","fh3PatchEnergyEtaPhiCenterJ1;E_{patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchEnergyEtaPhiCenterJ1 = new TH3F("fh3PatchEnergyEtaPhiCenterJ1","fh3PatchEnergyEtaPhiCenterJ1;E_{patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchEnergyEtaPhiCenterJ1);
 
-  fh3PatchEnergyEtaPhiCenterJ2 = new TH3F("fh3PatchEnergyEtaPhiCenterJ2","fh3PatchEnergyEtaPhiCenterJ2;E_{patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchEnergyEtaPhiCenterJ2 = new TH3F("fh3PatchEnergyEtaPhiCenterJ2","fh3PatchEnergyEtaPhiCenterJ2;E_{patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchEnergyEtaPhiCenterJ2);
 
-  fh3PatchEnergyEtaPhiCenterJ1J2 = new TH3F("fh3PatchEnergyEtaPhiCenterJ1J2","fh3PatchEnergyEtaPhiCenterJ1J2;E_{patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchEnergyEtaPhiCenterJ1J2 = new TH3F("fh3PatchEnergyEtaPhiCenterJ1J2","fh3PatchEnergyEtaPhiCenterJ1J2;E_{patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchEnergyEtaPhiCenterJ1J2);
 
-  fh3PatchADCEnergyEtaPhiCenterJ1 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ1","fh3PatchADCEnergyEtaPhiCenterJ1;E_{ADC,patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchADCEnergyEtaPhiCenterJ1 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ1","fh3PatchADCEnergyEtaPhiCenterJ1;E_{ADC,patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchADCEnergyEtaPhiCenterJ1);
 
-  fh3PatchADCEnergyEtaPhiCenterJ2 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ2","fh3PatchADCEnergyEtaPhiCenterJ2;E_{ADC,patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchADCEnergyEtaPhiCenterJ2 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ2","fh3PatchADCEnergyEtaPhiCenterJ2;E_{ADC,patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchADCEnergyEtaPhiCenterJ2);
 
-  fh3PatchADCEnergyEtaPhiCenterJ1J2 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ1J2","fh3PatchADCEnergyEtaPhiCenterJ1J2;E_{ADC,patch};#eta;#phi",fgkNPtBins,binsPt,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
+  fh3PatchADCEnergyEtaPhiCenterJ1J2 = new TH3F("fh3PatchADCEnergyEtaPhiCenterJ1J2","fh3PatchADCEnergyEtaPhiCenterJ1J2;E_{ADC,patch};#eta;#phi",fgkNEnBins,binsEn,fgkNEtaBins,binsEta,fgkNPhiBins,binsPhi);
   fOutput->Add(fh3PatchADCEnergyEtaPhiCenterJ1J2);
 
   fh2CellEnergyVsTime = new TH2F("fh2CellEnergyVsTime","fh2CellEnergyVsTime;E_{cell};time",fgkNEnBins,binsEn,fgkNTimeBins,binsTime);
@@ -420,16 +427,25 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
 {
   // Fill histograms.
 
+  //Tracks
   AliParticleContainer *partCont = GetParticleContainer(0);
   if (partCont) {
-    AliVParticle *track = partCont->GetNextAcceptParticle(0);
+    Int_t i = 0;
+    AliPicoTrack *track = dynamic_cast<AliPicoTrack*>(partCont->GetNextAcceptParticle(0));
     while(track) {
+      Double_t trkphi = track->Phi()*TMath::RadToDeg();
       fh3PtEtaPhiTracks->Fill(track->Pt(),track->Eta(),track->Phi());
-      track = partCont->GetNextAcceptParticle();
+      fh3PtEtaPhiTracksOnEmcal->Fill(track->GetTrackPtOnEMCal(),track->GetTrackEtaOnEMCal(),track->GetTrackPhiOnEMCal());
+      if(track->IsEMCAL()) {
+       i++;
+       if(TMath::Abs(track->Eta())<0.9 && trkphi > 10 && trkphi < 250 )
+         fh3PtEtaPhiTracksProp->Fill(track->Pt(),track->Eta(),track->Phi());
+      }
+      track = dynamic_cast<AliPicoTrack*>(partCont->GetNextAcceptParticle());
     }
   }
 
-
+  //Clusters
   AliClusterContainer  *clusCont = GetClusterContainer(0);
   if (clusCont) {
     Int_t nclusters = clusCont->GetNClusters();
@@ -447,10 +463,7 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
 
       TLorentzVector lp;
       cluster->GetMomentum(lp, const_cast<Double_t*>(fVertex));
-
-      //Fill eta,phi,E of clusters here
       fh3EEtaPhiCluster->Fill(lp.E(),lp.Eta(),lp.Phi());
-
       if(fCaloCells) {
        Double_t leadCellE = GetEnergyLeadingCell(cluster);
        Double_t leadCellT = cluster->GetTOF();
@@ -459,6 +472,7 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
     }
   }
 
+  //cells
   if(fCaloCells) {
     const Short_t nCells   = fCaloCells->GetNumberOfCells();
 
@@ -517,18 +531,15 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
       if(jet->GetNumberOfTracks()>0)
        fh2PtMeanPtConstituentsCharged->Fill(jetPt,sumPtCh/(double)(jet->GetNumberOfTracks()) );
 
-
       AliVCluster *vc = 0x0;
       Double_t sumPtNe = 0.;
       if (clusCont) {
        for(Int_t icc=0; icc<jet->GetNumberOfClusters(); icc++) {
          vc = static_cast<AliVCluster*>(clusCont->GetCluster(icc));
          if(!vc) continue;
-
          TLorentzVector lp;
          vc->GetMomentum(lp, const_cast<Double_t*>(fVertex));
          sumPtNe+=lp.Pt();
-         
        }
 
        if(jet->GetNumberOfClusters()>0)
@@ -540,7 +551,6 @@ Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
       Int_t nJetsInEvent = nJetsArr->At(i);
       fh2NJetsPtFull->Fill(nJetsInEvent,fh2NJetsPtFull->GetYaxis()->GetBinCenter(i));
     }
-
   }
 
   //Reset array to zero to also count charged jets
@@ -615,7 +625,6 @@ void AliAnalysisTaskEmcalJetTriggerQA::Terminate(Option_t *)
 Double_t AliAnalysisTaskEmcalJetTriggerQA::GetZ(const AliVParticle *trk, const AliEmcalJet *jet)          const
 {  
   // Get Z of constituent trk
-
   return GetZ(trk->Px(),trk->Py(),trk->Pz(),jet->Px(),jet->Py(),jet->Pz());
 }
 
@@ -625,9 +634,7 @@ Double_t AliAnalysisTaskEmcalJetTriggerQA::GetZ(const Double_t trkPx, const Doub
   // 
   // Get the z of a constituent inside of a jet
   //
-
   Double_t pJetSq = jetPx*jetPx+jetPy*jetPy+jetPz*jetPz;
-
   if(pJetSq>0.)
     return (trkPx*jetPx+trkPy*jetPy+trkPz*jetPz)/pJetSq;
   else {
@@ -671,7 +678,6 @@ Double_t AliAnalysisTaskEmcalJetTriggerQA::GetEnergyLeadingCell(const AliVCluste
     return fCaloCells->GetCellAmplitude(absID);
   else 
     return -1.;
-
 }
 
 //________________________________________________________________________
index 8e0088cbaba5c29b295bead0cfbc5128e2abaf5f..987e12859c7210cb3cba8a907688228baca612b7 100644 (file)
@@ -61,6 +61,8 @@ class AliAnalysisTaskEmcalJetTriggerQA : public AliAnalysisTaskEmcalJet {
 
   TH1F  *fhNEvents;                         //! Histo number of events
   TH3F  *fh3PtEtaPhiTracks;                 //! pt,eta,phi of tracks
+  TH3F  *fh3PtEtaPhiTracksOnEmcal;          //! pt,eta,phi of tracks
+  TH3F  *fh3PtEtaPhiTracksProp;             //! pt,eta,phi of tracks
   TH3F  *fh3PtEtaPhiJetFull;                //! pt,eta,phi of full jets
   TH3F  *fh3PtEtaPhiJetCharged;             //! pt,eta,phi of charged jets
   TH2F  *fh2NJetsPtFull;                    //! NJets per event vs pT,jet
@@ -94,6 +96,6 @@ class AliAnalysisTaskEmcalJetTriggerQA : public AliAnalysisTaskEmcalJet {
   AliAnalysisTaskEmcalJetTriggerQA(const AliAnalysisTaskEmcalJetTriggerQA&);            // not implemented
   AliAnalysisTaskEmcalJetTriggerQA &operator=(const AliAnalysisTaskEmcalJetTriggerQA&); // not implemented
 
-  ClassDef(AliAnalysisTaskEmcalJetTriggerQA, 6)
+  ClassDef(AliAnalysisTaskEmcalJetTriggerQA, 8)
 };
 #endif
index 2ad22c463d28a0f57bb7ca74108362cdcaef84d8..c1b1fd86718d2ac8a294695c3a35dd28afcb30f8 100644 (file)
@@ -8,6 +8,7 @@
 #include <TH1D.h>
 #include <TH2D.h>
 #include <TH3D.h>
+#include <THnSparse.h>
 #include <TCanvas.h>
 #include <TList.h>
 #include <TLorentzVector.h>
@@ -77,11 +78,6 @@ AliAnalysisTaskFullpAJets::AliAnalysisTaskFullpAJets() :
     fhTPCEventMult(0),
     fhEMCalTrackEventMult(0),
 
-    fhTrackEtaPhiPt(0),
-    fhGlobalTrackEtaPhiPt(0),
-    fhComplementaryTrackEtaPhiPt(0),
-    fhClusterEtaPhiPt(0),
-
     fpEMCalEventMult(0),
     fpTPCEventMult(0),
 
@@ -241,11 +237,6 @@ AliAnalysisTaskFullpAJets::AliAnalysisTaskFullpAJets(const char *name) :
     fhTPCEventMult(0),
     fhEMCalTrackEventMult(0),
 
-    fhTrackEtaPhiPt(0),
-    fhGlobalTrackEtaPhiPt(0),
-    fhComplementaryTrackEtaPhiPt(0),
-    fhClusterEtaPhiPt(0),
-
     fpEMCalEventMult(0),
     fpTPCEventMult(0),
 
@@ -508,13 +499,7 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         fhTrackEtaPt->GetYaxis()->SetTitle("p_{T} (GeV/c)");
         fhTrackEtaPt->GetZaxis()->SetTitle("1/N_{Events} dN/d#etadp_{T}");
         fhTrackEtaPt->Sumw2();
-        
-        fhTrackEtaPhiPt = new TH3D("fhTrackEtaPhiPt","#eta-#varphi-p_{T} distribution of tracks in event",TCBins,fTPCEtaMin,fTPCEtaMax,TCBins,fTPCPhiMin,fTPCPhiMax,fParticlePtBins,fParticlePtLow,fParticlePtUp);
-        fhTrackEtaPhiPt->GetXaxis()->SetTitle("#eta");
-        fhTrackEtaPhiPt->GetYaxis()->SetTitle("#varphi");
-        fhTrackEtaPhiPt->GetZaxis()->SetTitle("p_{T} (GeV/c)");
-        fhTrackEtaPhiPt->Sumw2();
-        
+         
         // Global Tracks
         fhGlobalTrackPt = new TH1D("fhGlobalTrackPt","Global p_{T} distribution of tracks in event",10*fParticlePtBins,fParticlePtLow,fParticlePtUp);
         fhGlobalTrackPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
@@ -549,12 +534,6 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         fhGlobalTrackEtaPt->GetZaxis()->SetTitle("1/N_{Events} dN/d#etadp_{T}");
         fhGlobalTrackEtaPt->Sumw2();
         
-        fhGlobalTrackEtaPhiPt = new TH3D("fhGlobalTrackEtaPhiPt","Global #eta-#varphi-p_{T} distribution of tracks in event",TCBins,fTPCEtaMin,fTPCEtaMax,TCBins,fTPCPhiMin,fTPCPhiMax,fParticlePtBins,fParticlePtLow,fParticlePtUp);
-        fhGlobalTrackEtaPhiPt->GetXaxis()->SetTitle("#eta");
-        fhGlobalTrackEtaPhiPt->GetYaxis()->SetTitle("#varphi");
-        fhGlobalTrackEtaPhiPt->GetZaxis()->SetTitle("p_{T} (GeV/c)");
-        fhGlobalTrackEtaPhiPt->Sumw2();
-        
         // Complementary Tracks
         fhComplementaryTrackPt = new TH1D("fhComplementaryTrackPt","Complementary p_{T} distribution of tracks in event",10*fParticlePtBins,fParticlePtLow,fParticlePtUp);
         fhComplementaryTrackPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
@@ -589,12 +568,6 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         fhComplementaryTrackEtaPt->GetZaxis()->SetTitle("1/N_{Events} dN/d#etadp_{T}");
         fhComplementaryTrackEtaPt->Sumw2();
         
-        fhComplementaryTrackEtaPhiPt = new TH3D("fhComplementaryTrackEtaPhiPt","Complementary #eta-#varphi-p_{T} distribution of tracks in event",TCBins,fTPCEtaMin,fTPCEtaMax,TCBins,fTPCPhiMin,fTPCPhiMax,fParticlePtBins,fParticlePtLow,fParticlePtUp);
-        fhComplementaryTrackEtaPhiPt->GetXaxis()->SetTitle("#eta");
-        fhComplementaryTrackEtaPhiPt->GetYaxis()->SetTitle("#varphi");
-        fhComplementaryTrackEtaPhiPt->GetZaxis()->SetTitle("p_{T} (GeV/c)");
-        fhComplementaryTrackEtaPhiPt->Sumw2();
-        
         fhTPCEventMult = new TH2D("fhTPCEventMult","TPC Event Multiplcity vs Centrality",CentralityBinMult*fCentralityBins,fCentralityLow,fCentralityUp,multBins,multLow,multUp);
         fhTPCEventMult->GetXaxis()->SetTitle(fCentralityTag);
         fhTPCEventMult->GetYaxis()->SetTitle("Multiplicity");
@@ -623,21 +596,18 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         flTrack->Add(fhTrackEtaPhi);
         flTrack->Add(fhTrackPhiPt);
         flTrack->Add(fhTrackEtaPt);
-        flTrack->Add(fhTrackEtaPhiPt);
         flTrack->Add(fhGlobalTrackPt);
         flTrack->Add(fhGlobalTrackEta);
         flTrack->Add(fhGlobalTrackPhi);
         flTrack->Add(fhGlobalTrackEtaPhi);
         flTrack->Add(fhGlobalTrackPhiPt);
         flTrack->Add(fhGlobalTrackEtaPt);
-        flTrack->Add(fhGlobalTrackEtaPhiPt);
         flTrack->Add(fhComplementaryTrackPt);
         flTrack->Add(fhComplementaryTrackEta);
         flTrack->Add(fhComplementaryTrackPhi);
         flTrack->Add(fhComplementaryTrackEtaPhi);
         flTrack->Add(fhComplementaryTrackPhiPt);
         flTrack->Add(fhComplementaryTrackEtaPt);
-        flTrack->Add(fhComplementaryTrackEtaPhiPt);
         flTrack->Add(fhTPCEventMult);
         flTrack->Add(fhEMCalTrackEventMult);
         flTrack->Add(fpTPCEventMult);
@@ -682,13 +652,7 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         fhClusterEtaPt->GetYaxis()->SetTitle("p_{T} (GeV/c)");
         fhClusterEtaPt->GetZaxis()->SetTitle("1/N_{Events} dN/d#etadp_{T}");
         fhClusterEtaPt->Sumw2();
-        
-        fhClusterEtaPhiPt = new TH3D("fhClusterEtaPhiPt","#eta-#varphi-p_{T} distribution of clusters in event",TCBins,fEMCalEtaMin,fEMCalEtaMax,TCBins,fEMCalPhiMin,fEMCalPhiMax,fParticlePtBins,fParticlePtLow,fParticlePtUp);
-        fhClusterEtaPhiPt->GetXaxis()->SetTitle("#eta");
-        fhClusterEtaPhiPt->GetYaxis()->SetTitle("#varphi");
-        fhClusterEtaPhiPt->GetZaxis()->SetTitle("p_{T} (GeV/c)");
-        fhClusterEtaPhiPt->Sumw2();
-        
         fhEMCalEventMult = new TH2D("fhEMCalEventMult","EMCal Event Multiplcity vs Centrality",CentralityBinMult*fCentralityBins,fCentralityLow,fCentralityUp,multBins,multLow,multUp);
         fhEMCalEventMult->GetXaxis()->SetTitle(fCentralityTag);
         fhEMCalEventMult->GetYaxis()->SetTitle("Multiplicity");
@@ -715,7 +679,6 @@ void AliAnalysisTaskFullpAJets::UserCreateOutputObjects()
         flCluster->Add(fhClusterEtaPhi);
         flCluster->Add(fhClusterPhiPt);
         flCluster->Add(fhClusterEtaPt);
-        flCluster->Add(fhClusterEtaPhiPt);
         flCluster->Add(fhEMCalEventMult);
         flCluster->Add(fpEMCalEventMult);
         flCluster->Add(fpClusterPtProfile);
@@ -889,6 +852,12 @@ void AliAnalysisTaskFullpAJets::UserExec(Option_t *)
     // Reject any event that doesn't have any tracks, i.e. TPC is off
     if (fnTracks<1)
     {
+        if (fTrackQA==kTRUE)
+        {
+            fhTPCEventMult->Fill(fEventCentrality,0.0);
+            fpTPCEventMult->Fill(fEventCentrality,0.0);
+            fhEMCalTrackEventMult->Fill(fEventCentrality,0.0);
+        }
         AliWarning("No PicoTracks, Rejecting Event");
         return;
     }
@@ -905,6 +874,12 @@ void AliAnalysisTaskFullpAJets::UserExec(Option_t *)
         InitChargedJets();
         GenerateTPCRandomConesPt();
         
+        if (fClusterQA==kTRUE)
+        {
+            fhEMCalEventMult->Fill(fEventCentrality,0.0);
+            fpEMCalEventMult->Fill(fEventCentrality,0.0);
+        }
+
         // Rho's
         if (fCalculateRhoJet>=2)
         {
@@ -1048,7 +1023,6 @@ void AliAnalysisTaskFullpAJets::TrackHisto()
         fhTrackEtaPhi->Fill(vtrack->Eta(),vtrack->Phi());
         fhTrackPhiPt->Fill(vtrack->Phi(),vtrack->Pt());
         fhTrackEtaPt->Fill(vtrack->Eta(),vtrack->Pt());
-        fhTrackEtaPhiPt->Fill(vtrack->Eta(),vtrack->Phi(),vtrack->Pt());
         
         // Fill Associated Track Distributions for AOD QA Productions
         // Global Tracks
@@ -1060,7 +1034,6 @@ void AliAnalysisTaskFullpAJets::TrackHisto()
             fhGlobalTrackEtaPhi->Fill(vtrack->Eta(),vtrack->Phi());
             fhGlobalTrackPhiPt->Fill(vtrack->Phi(),vtrack->Pt());
             fhGlobalTrackEtaPt->Fill(vtrack->Eta(),vtrack->Pt());
-            fhGlobalTrackEtaPhiPt->Fill(vtrack->Eta(),vtrack->Phi(),vtrack->Pt());
         }
         // Complementary Tracks
         else if (vtrack->GetTrackType()==1)
@@ -1071,7 +1044,6 @@ void AliAnalysisTaskFullpAJets::TrackHisto()
             fhComplementaryTrackEtaPhi->Fill(vtrack->Eta(),vtrack->Phi());
             fhComplementaryTrackPhiPt->Fill(vtrack->Phi(),vtrack->Pt());
             fhComplementaryTrackEtaPt->Fill(vtrack->Eta(),vtrack->Pt());
-            fhComplementaryTrackEtaPhiPt->Fill(vtrack->Eta(),vtrack->Phi(),vtrack->Pt());
         }
         hdummypT->Fill(vtrack->Eta(),vtrack->Phi(),vtrack->Pt());
     }
@@ -1105,7 +1077,6 @@ void AliAnalysisTaskFullpAJets::ClusterHisto()
         fhClusterEtaPhi->Fill(cluster_vec->Eta(),cluster_vec->Phi());
         fhClusterPhiPt->Fill(cluster_vec->Phi(),cluster_vec->Pt());
         fhClusterEtaPt->Fill(cluster_vec->Eta(),cluster_vec->Pt());
-        fhClusterEtaPhiPt->Fill(cluster_vec->Eta(),cluster_vec->Phi(),cluster_vec->Pt());
         hdummypT->Fill(cluster_vec->Eta(),cluster_vec->Phi(),cluster_vec->Pt());
         fEMCALGeometry->GetAbsCellIdFromEtaPhi(cluster_vec->Eta(),cluster_vec->Phi(),myCellID);
         fhEMCalCellCounts->Fill(myCellID);
@@ -3377,28 +3348,16 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos() :
 
     fpRho(0),
     fpLJetRho(0),
-    fhJetConstituentPt(0),
     fhJetPtArea(0),
-
+    fhJetConstituentPt(0),
+    fhJetTracksPt(0),
+    fhJetClustersPt(0),
+    fhJetConstituentCounts(0),
+    fhJetTracksCounts(0),
+    fhJetClustersCounts(0),
     fNEFOutput(0),
-    fhNEF(0),
-    fhNEFSignal(0),
-    fhNEFJetPt(0),
-    fhNEFJetPtSignal(0),
-    fhNEFEtaPhi(0),
-    fhNEFEtaPhiSignal(0),
-    fhEtaPhiNEF(0),
-    fhNEFTotalMult(0),
-    fhNEFTotalMultSignal(0),
-    fhNEFNeutralMult(0),
-    fhNEFNeutralMultSignal(0),
     fhClusterShapeAll(0),
     fhClusterPtCellAll(0),
-    fhNEFJetPtFCross(0),
-    fhNEFZLeadingFCross(0),
-    fhNEFTimeCellCount(0),
-    fhNEFTimeDeltaTime(0),
-
     fName(0),
     fCentralityTag(0),
     fCentralityBins(0),
@@ -3428,6 +3387,8 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos() :
     fNEFBins(0),
     fNEFLow(0),
     fNEFUp(0),
+    fnDimJet(0),
+    fnDimCluster(0),
     fEMCalPhiMin(1.39626),
     fEMCalPhiMax(3.26377),
     fEMCalEtaMin(-0.7),
@@ -3472,28 +3433,16 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos(const char *name) :
 
     fpRho(0),
     fpLJetRho(0),
-    fhJetConstituentPt(0),
     fhJetPtArea(0),
-
+    fhJetConstituentPt(0),
+    fhJetTracksPt(0),
+    fhJetClustersPt(0),
+    fhJetConstituentCounts(0),
+    fhJetTracksCounts(0),
+    fhJetClustersCounts(0),
     fNEFOutput(0),
-    fhNEF(0),
-    fhNEFSignal(0),
-    fhNEFJetPt(0),
-    fhNEFJetPtSignal(0),
-    fhNEFEtaPhi(0),
-    fhNEFEtaPhiSignal(0),
-    fhEtaPhiNEF(0),
-    fhNEFTotalMult(0),
-    fhNEFTotalMultSignal(0),
-    fhNEFNeutralMult(0),
-    fhNEFNeutralMultSignal(0),
     fhClusterShapeAll(0),
     fhClusterPtCellAll(0),
-    fhNEFJetPtFCross(0),
-    fhNEFZLeadingFCross(0),
-    fhNEFTimeCellCount(0),
-    fhNEFTimeDeltaTime(0),
-
     fName(0),
     fCentralityTag(0),
     fCentralityBins(0),
@@ -3523,6 +3472,8 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos(const char *name) :
     fNEFBins(0),
     fNEFLow(0),
     fNEFUp(0),
+    fnDimJet(0),
+    fnDimCluster(0),
     fEMCalPhiMin(1.39626),
     fEMCalPhiMax(3.26377),
     fEMCalEtaMin(-0.7),
@@ -3579,28 +3530,16 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos(const char *name, cons
 
     fpRho(0),
     fpLJetRho(0),
-    fhJetConstituentPt(0),
     fhJetPtArea(0),
-
+    fhJetConstituentPt(0),
+    fhJetTracksPt(0),
+    fhJetClustersPt(0),
+    fhJetConstituentCounts(0),
+    fhJetTracksCounts(0),
+    fhJetClustersCounts(0),
     fNEFOutput(0),
-    fhNEF(0),
-    fhNEFSignal(0),
-    fhNEFJetPt(0),
-    fhNEFJetPtSignal(0),
-    fhNEFEtaPhi(0),
-    fhNEFEtaPhiSignal(0),
-    fhEtaPhiNEF(0),
-    fhNEFTotalMult(0),
-    fhNEFTotalMultSignal(0),
-    fhNEFNeutralMult(0),
-    fhNEFNeutralMultSignal(0),
     fhClusterShapeAll(0),
     fhClusterPtCellAll(0),
-    fhNEFJetPtFCross(0),
-    fhNEFZLeadingFCross(0),
-    fhNEFTimeCellCount(0),
-    fhNEFTimeDeltaTime(0),
-
     fName(0),
     fCentralityTag(0),
     fCentralityBins(0),
@@ -3630,6 +3569,8 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::AlipAJetHistos(const char *name, cons
     fNEFBins(0),
     fNEFLow(0),
     fNEFUp(0),
+    fnDimJet(0),
+    fnDimCluster(0),
     fEMCalPhiMin(1.39626),
     fEMCalPhiMax(3.26377),
     fEMCalEtaMin(-0.7),
@@ -3662,7 +3603,9 @@ AliAnalysisTaskFullpAJets::AlipAJetHistos::~AlipAJetHistos()
 
 void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
 {
+  Int_t i;
     // Initialize Private Variables
+  Int_t TCBins = 100;
     fEMCalPhiMin=(80/(double)360)*2*TMath::Pi();
     fEMCalPhiMax=(187/(double)360)*2*TMath::Pi();
     fEMCalEtaMin=-0.7;
@@ -3871,12 +3814,6 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
     fpLJetRho->GetXaxis()->SetTitle("Leading Jet p_{T}");
     fpLJetRho->GetYaxis()->SetTitle("p_{T}/Area (GeV/c)");
 
-    // Jet pT vs Constituent pT
-    fhJetConstituentPt = new TH2D("fhJetConstituentPt","Jet constituents p_{T} distribution",fPtBins,fPtLow,fPtUp,10*fPtBins,fPtLow,fPtUp);
-    fhJetConstituentPt->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
-    fhJetConstituentPt->GetYaxis()->SetTitle("Constituent p_{T} (GeV/c)");
-    fhJetConstituentPt->Sumw2();
-
     // Jet pT vs Area
     Int_t JetPtAreaBins=200;
     Double_t JetPtAreaLow=0.0;
@@ -3888,6 +3825,43 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
     fhJetPtArea->GetZaxis()->SetTitle("1/N_{Events} dN/dA_{jet}dp_{T}");
     fhJetPtArea->Sumw2();
 
+    // Jet pT vs Constituent pT
+    fhJetConstituentPt = new TH2D("fhJetConstituentPt","Jet constituents p_{T} distribution",fPtBins,fPtLow,fPtUp,10*fPtBins,fPtLow,fPtUp);
+    fhJetConstituentPt->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetConstituentPt->GetYaxis()->SetTitle("Constituent p_{T} (GeV/c)");
+    fhJetConstituentPt->Sumw2();
+
+    fhJetTracksPt = new TH2D("fhJetTracksPt","Jet constituents Tracks p_{T} distribution",fPtBins,fPtLow,fPtUp,10*fPtBins,fPtLow,fPtUp);
+    fhJetTracksPt->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetTracksPt->GetYaxis()->SetTitle("Constituent Track p_{T} (GeV/c)");
+    fhJetTracksPt->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T,jet}dp_{T,track}");
+    fhJetTracksPt->Sumw2();
+
+    fhJetClustersPt = new TH2D("fhJetClustersPt","Jet constituents Clusters p_{T} distribution",fPtBins,fPtLow,fPtUp,10*fPtBins,fPtLow,fPtUp);
+    fhJetClustersPt->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetClustersPt->GetYaxis()->SetTitle("Constituent Cluster p_{T} (GeV/c)");
+    fhJetClustersPt->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T,jet}dp_{T,cluster}");
+    fhJetClustersPt->Sumw2();
+
+    // Jet pT vs Constituent Counts
+    fhJetConstituentCounts = new TH2D("fhJetConstituentCounts","Jet constituents distribution",fPtBins,fPtLow,fPtUp,TCBins,0,(Double_t)TCBins);
+    fhJetConstituentCounts->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetConstituentCounts->GetYaxis()->SetTitle("Constituent Count");
+    fhJetConstituentCounts->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T,jet}dN_{constituent}");
+    fhJetConstituentCounts->Sumw2();
+    
+    fhJetTracksCounts = new TH2D("fhJetTracksCounts","Jet constituents Tracks distribution",fPtBins,fPtLow,fPtUp,TCBins,0,(Double_t)TCBins);
+    fhJetTracksCounts->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetTracksCounts->GetYaxis()->SetTitle("Constituent Track Count");
+    fhJetTracksCounts->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T,jet}dN_{track}");
+    fhJetTracksCounts->Sumw2();
+    
+    fhJetClustersCounts = new TH2D("fhJetClustersCounts","Jet constituents Clusters distribution",fPtBins,fPtLow,fPtUp,TCBins,0,(Double_t)TCBins);
+    fhJetClustersCounts->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
+    fhJetClustersCounts->GetYaxis()->SetTitle("Constituent Cluster Count");
+    fhJetClustersCounts->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T,jet}dN_{cluster}");
+    fhJetClustersCounts->Sumw2();
+
     // Neutral Energy Fraction Histograms & QA
     if (fDoNEFQAPlots==kTRUE)
     {
@@ -3895,72 +3869,82 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
         fNEFOutput->SetOwner();
         fNEFOutput->SetName("ListNEFQAPlots");
         
-        Int_t TCBins = 100;
-        fhNEF = new TH1D("fhNEF","Neutral Energy Fraction of All Jets",fNEFBins,fNEFLow,fNEFUp);
-        fhNEF->GetXaxis()->SetTitle("NEF");
-        fhNEF->GetYaxis()->SetTitle("1/N_{Events} dN/dNEF");
-        fhNEF->Sumw2();
-        
-        fhNEFSignal = new TH1D("fhNEFSignal","Neutral Energy Fraction of Signal Jets",fNEFBins,fNEFLow,fNEFUp);
-        fhNEFSignal->GetXaxis()->SetTitle("NEF");
-        fhNEFSignal->GetYaxis()->SetTitle("1/N_{Events} dN/dNEF");
-        fhNEFSignal->Sumw2();
-
-        fhNEFJetPt = new TH2D("fhNEFJetPt","Neutral Energy Fraction vs p_{T}^{jet}",fNEFBins,fNEFLow,fNEFUp,fPtBins,fPtLow,fPtUp);
-        fhNEFJetPt->GetXaxis()->SetTitle("NEF");
-        fhNEFJetPt->GetYaxis()->SetTitle("p_{T}^{jet} (GeV/c)");
-        fhNEFJetPt->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdp_{T}");
-        fhNEFJetPt->Sumw2();
-
-        fhNEFJetPtSignal = new TH2D("fhNEFJetPtSignal","Neutral Energy Fraction vs p_{T}^{jet}",fNEFBins,fNEFLow,fNEFUp,fPtBins,fPtLow,fPtUp);
-        fhNEFJetPtSignal->GetXaxis()->SetTitle("NEF");
-        fhNEFJetPtSignal->GetYaxis()->SetTitle("p_{T}^{jet} (GeV/c)");
-        fhNEFJetPtSignal->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdp_{T}");
-        fhNEFJetPtSignal->Sumw2();
-
-        // Eta-Phi Dependence
-        fhNEFEtaPhi = new TH2D("fhNEFEtaPhi","Neutral Energy Fraction #eta-#varphi",TCBins, fEMCalEtaMin,fEMCalEtaMax,TCBins,fEMCalPhiMin,fEMCalPhiMax);
-        fhNEFEtaPhi->GetXaxis()->SetTitle("#eta");
-        fhNEFEtaPhi->GetYaxis()->SetTitle("#varphi");
-        fhNEFEtaPhi->GetZaxis()->SetTitle("1/N{Events} dN/d#etad#varphi");
-        fhNEFEtaPhi->Sumw2();
-
-        fhNEFEtaPhiSignal = new TH2D("fhNEFEtaPhiSignal","Neutral Energy Fraction #eta-#varphi of Signal Jets",TCBins,fEMCalEtaMin,fEMCalEtaMax,TCBins,fEMCalPhiMin,fEMCalPhiMax);
-        fhNEFEtaPhiSignal->GetXaxis()->SetTitle("#eta");
-        fhNEFEtaPhiSignal->GetYaxis()->SetTitle("#varphi");
-        fhNEFEtaPhiSignal->GetZaxis()->SetTitle("1/N{Events} dN/d#etad#varphi");
-        fhNEFEtaPhiSignal->Sumw2();
-
-        fhEtaPhiNEF = new TH3D("fhEtaPhiNEF","Neutral Energy Fraction #eta-#varphi",TCBins, fEMCalEtaMin,fEMCalEtaMax,TCBins,fEMCalPhiMin,fEMCalPhiMax,fNEFBins,fNEFLow,fNEFUp);
-        fhEtaPhiNEF->GetXaxis()->SetTitle("#eta");
-        fhEtaPhiNEF->GetYaxis()->SetTitle("#varphi");
-        fhEtaPhiNEF->GetZaxis()->SetTitle("NEF");
-        fhEtaPhiNEF->Sumw2();
-
-        // Multiplicity Dependence
-        fhNEFTotalMult = new TH2D("fhNEFTotalMult","Total Multiplicity Distribution of Constituents",fNEFBins,fNEFLow,fNEFUp,TCBins,0,(Double_t)TCBins);
-        fhNEFTotalMult->GetXaxis()->SetTitle("NEF");
-        fhNEFTotalMult->GetYaxis()->SetTitle("Multiplicity");
-        fhNEFTotalMult->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdM");
-        fhNEFTotalMult->Sumw2();
-        
-        fhNEFTotalMultSignal = new TH2D("fhNEFTotalMultSignal","Total Multiplicity Distribution of Constituents of Signal Jets",fNEFBins,fNEFLow,fNEFUp,TCBins,0,(Double_t)TCBins);
-        fhNEFTotalMultSignal->GetXaxis()->SetTitle("NEF");
-        fhNEFTotalMultSignal->GetYaxis()->SetTitle("Multiplicity");
-        fhNEFTotalMultSignal->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdM");
-        fhNEFTotalMultSignal->Sumw2();
-        
-        fhNEFNeutralMult = new TH2D("fhNEFNeutralMult","Neutral Multiplicity Distribution of Constituents",fNEFBins,fNEFLow,fNEFUp,TCBins,0,(Double_t)TCBins);
-        fhNEFNeutralMult->GetXaxis()->SetTitle("NEF");
-        fhNEFNeutralMult->GetYaxis()->SetTitle("Multiplicity");
-        fhNEFNeutralMult->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdM");
-        fhNEFNeutralMult->Sumw2();
-        
-        fhNEFNeutralMultSignal = new TH2D("fhNEFNeutralMultSignal","Neutral Multiplicity Distribution of Constituents of Signal Jets",fNEFBins,fNEFLow,fNEFUp,TCBins,0,(Double_t)TCBins);
-        fhNEFNeutralMultSignal->GetXaxis()->SetTitle("NEF");
-        fhNEFNeutralMultSignal->GetYaxis()->SetTitle("Multiplicity");
-        fhNEFNeutralMultSignal->GetZaxis()->SetTitle("1/N_{Events} dN/dNEFdM");
-        fhNEFNeutralMultSignal->Sumw2();
+       SetNEFJetDimensions(8); // Order: nef,Jet Pt,Eta,Phi,Centrality,Constituent mult,Charged mult, Neutral mult
+        SetNEFClusterDimensions(10); // Order: nef,Jet Pt,Eta,Phi,Centrality,F_Cross,z_leading,t_cell,deltat_cell,Cell Count
+
+        Int_t dimJetBins[fnDimJet];
+        Double_t dimJetLow[fnDimJet];
+        Double_t dimJetUp[fnDimJet];
+
+        Int_t dimClusterBins[fnDimCluster];
+        Double_t dimClusterLow[fnDimCluster];
+        Double_t dimClusterUp[fnDimCluster];
+
+        // Establish dimensinality bin counts and bounds
+        // NEF
+        dimJetBins[0] = dimClusterBins[0] = fNEFBins;
+        dimJetLow[0] = dimClusterLow[0] = fNEFLow;
+        dimJetUp[0] = dimClusterUp[0] = fNEFUp;
+
+        // Jet Pt
+        dimJetBins[1] = dimClusterBins[1] = fPtBins;
+        dimJetLow[1] = dimClusterLow[1] = fPtLow;
+        dimJetUp[1] = dimClusterUp[1] = fPtUp;
+
+        // Eta-Phi
+        dimJetBins[2] = dimJetBins[3] = dimClusterBins[2] = dimClusterBins[3] = TCBins;
+        dimJetLow[2] = dimClusterLow[2] = fEMCalEtaMin;
+        dimJetUp[2] = dimClusterUp[2] = fEMCalEtaMax;
+        dimJetLow[3] = dimClusterLow[3] = fEMCalPhiMin;
+        dimJetUp[3] = dimClusterUp[3] = fEMCalPhiMax;
+       // Centrality
+        dimJetBins[4] = dimClusterBins[4] = fCentralityBins;
+        dimJetLow[4] = dimClusterLow[4] = fCentralityLow;
+        dimJetUp[4] = dimClusterUp[4] = fCentralityUp;
+         
+       // Jets Constituent Multiplicity Info {Total,Charged,Neutral}
+        for (i=5;i<8;i)
+        {
+            dimJetBins[i] = TCBins;
+            dimJetLow[i] = 0.0;
+            dimJetUp[i] = (Double_t)TCBins;
+        }
+
+       // Cluster F_Cross
+        dimClusterBins[5] = TCBins;
+        dimClusterLow[5] = 0.0;
+        dimClusterUp[5] = 1.0;
+
+        // Cluster z_leading
+        dimClusterBins[6] = TCBins;
+        dimClusterLow[6] = 0.0;
+        dimClusterUp[6] = 1.0;
+
+        // Cluster t_cell
+        dimClusterBins[7] = 400;
+        dimClusterLow[7] = -2e-07;
+        dimClusterUp[7] = 2e-07;
+
+        // Cluster delta t_cell
+        dimClusterBins[8] = 100;
+        dimClusterLow[8] = 0.0;
+        dimClusterUp[8] = 1e-07;
+         
+        // Cluster Cell Count
+        dimClusterBins[9] = TCBins;
+        dimClusterLow[9] = 0.0;
+        dimClusterUp[9] = 100.0;
+
+        fhJetNEFInfo = new THnSparseD("fhJetNEFInfo","Jet NEF Information Histogram",fnDimJet,dimJetBins,dimJetLow,dimJetUp);
+        fhJetNEFInfo->Sumw2();
+        fhJetNEFSignalInfo = new THnSparseD("fhJetNEFSignalInfo","Signal Jet NEF Information Histogram",fnDimJet,dimJetBins,dimJetLow,dimJetUp);
+        fhJetNEFSignalInfo->Sumw2();
+
+        fhClusterNEFInfo = new THnSparseD("fhClusterNEFInfo","Jet NEF Cluster Information Histogram",fnDimCluster,dimClusterBins,dimClusterLow,dimClusterUp);
+        fhClusterNEFInfo->Sumw2();
+        fhClusterNEFSignalInfo = new THnSparseD("fhClusterNEFSignalInfo","Signal Jet NEF Cluster Information Histogram",fnDimCluster,dimClusterBins,dimClusterLow,dimClusterUp);
+        fhClusterNEFSignalInfo->Sumw2();
         
         // Cluster Shape QA
         fhClusterShapeAll = new TH1D("fhClusterShapeAll","Cluster Shape of all CaloClustersCorr",10*TCBins,0,10*TCBins);
@@ -3973,49 +3957,14 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
         fhClusterPtCellAll->GetYaxis()->SetTitle("Cells");
         fhClusterPtCellAll->GetZaxis()->SetTitle("1/N_{Events} dN/dp_{T}dCells");
         fhClusterPtCellAll->Sumw2();
-
-        fhNEFJetPtFCross = new TH3D("fhNEFJetPtFCross","NEF vs p_{T}^{jet} vs F_{Cross}",fNEFBins,fNEFLow,fNEFUp,fPtBins,fPtLow,fPtUp,TCBins,0,1.0);
-        fhNEFJetPtFCross->GetXaxis()->SetTitle("NEF");
-        fhNEFJetPtFCross->GetYaxis()->SetTitle("p_{T}^{jet} (GeV/c)");
-        fhNEFJetPtFCross->GetZaxis()->SetTitle("F_{Cross}");
-        fhNEFJetPtFCross->Sumw2();
-
-        fhNEFZLeadingFCross = new TH3D("fhNEFZLeadingFCross","NEF vs z_{Leading} vs F_{Cross}",fNEFBins,fNEFLow,fNEFUp,TCBins,0,1.0,TCBins,0,1.0);
-        fhNEFZLeadingFCross->GetXaxis()->SetTitle("NEF");
-        fhNEFZLeadingFCross->GetYaxis()->SetTitle("z_{Leading}");
-        fhNEFZLeadingFCross->GetZaxis()->SetTitle("F_{Cross}");
-        fhNEFZLeadingFCross->Sumw2();
-
-        fhNEFTimeCellCount = new TH3D("fhNEFTimeCellCount","NEF vs t_{cell} vs Cell Count",fNEFBins,fNEFLow,fNEFUp,400,-2e-07,2e-07,TCBins,0,100);
-        fhNEFTimeCellCount->GetXaxis()->SetTitle("NEF");
-        fhNEFTimeCellCount->GetYaxis()->SetTitle("t_{cell} (s)");
-        fhNEFTimeCellCount->GetZaxis()->SetTitle("Cell Count");
-        fhNEFTimeCellCount->Sumw2();
-
-        fhNEFTimeDeltaTime = new TH3D("fhNEFTimeDeltaTime","NEF vs t_{cell} vs #Deltat",fNEFBins,fNEFLow,fNEFUp,400,-2e-07,2e-06,TCBins,0,1e-07);
-        fhNEFTimeDeltaTime->GetXaxis()->SetTitle("NEF");
-        fhNEFTimeDeltaTime->GetYaxis()->SetTitle("t_{cell} (s)");
-        fhNEFTimeDeltaTime->GetZaxis()->SetTitle("#Deltat");
-        fhNEFTimeDeltaTime->Sumw2();
         
-        fNEFOutput->Add(fhNEF);
-        fNEFOutput->Add(fhNEFSignal);
-        fNEFOutput->Add(fhNEFJetPt);
-        fNEFOutput->Add(fhNEFJetPtSignal);
-        fNEFOutput->Add(fhNEFEtaPhi);
-        fNEFOutput->Add(fhNEFEtaPhiSignal);
-        fNEFOutput->Add(fhEtaPhiNEF);
-        fNEFOutput->Add(fhNEFTotalMult);
-        fNEFOutput->Add(fhNEFTotalMultSignal);
-        fNEFOutput->Add(fhNEFNeutralMult);
-        fNEFOutput->Add(fhNEFNeutralMultSignal);
+       fNEFOutput->Add(fhJetNEFInfo);
+        fNEFOutput->Add(fhJetNEFSignalInfo);
+        fNEFOutput->Add(fhClusterNEFInfo);
+        fNEFOutput->Add(fhClusterNEFSignalInfo);
         fNEFOutput->Add(fhClusterShapeAll);
         fNEFOutput->Add(fhClusterPtCellAll);
-        fNEFOutput->Add(fhNEFJetPtFCross);
-        fNEFOutput->Add(fhNEFZLeadingFCross);
-        fNEFOutput->Add(fhNEFTimeCellCount);
-        fNEFOutput->Add(fhNEFTimeDeltaTime);
-        fOutput->Add(fNEFOutput);
+       fOutput->Add(fNEFOutput);
     }
     
     // Add Histos & Profiles to List
@@ -4049,8 +3998,13 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::Init()
     fOutput->Add(fhBckgFlucPtCen);
     fOutput->Add(fpRho);
     fOutput->Add(fpLJetRho);
-    fOutput->Add(fhJetConstituentPt);
     fOutput->Add(fhJetPtArea);
+    fOutput->Add(fhJetConstituentPt);
+    fOutput->Add(fhJetTracksPt);
+    fOutput->Add(fhJetClustersPt);
+    fOutput->Add(fhJetConstituentCounts);
+    fOutput->Add(fhJetTracksCounts);
+    fOutput->Add(fhJetClustersCounts);
 }
 
 void AliAnalysisTaskFullpAJets::AlipAJetHistos::SetName(const char *name)
@@ -4124,6 +4078,16 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::SetSignalTrackPtBias(Bool_t char
     fSignalTrackBias = chargedBias;
 }
 
+void AliAnalysisTaskFullpAJets::AlipAJetHistos::SetNEFJetDimensions(Int_t n)
+{
+    fnDimJet = n;
+}
+
+void AliAnalysisTaskFullpAJets::AlipAJetHistos::SetNEFClusterDimensions(Int_t n)
+{
+    fnDimCluster = n;
+}
+
 void AliAnalysisTaskFullpAJets::AlipAJetHistos::FillRho(Double_t eventCentrality, Double_t rho)
 {
     fRhoValue = rho;
@@ -4302,11 +4266,22 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::DoNEFAnalysis(Double_t nefCut, D
     }
     
     Int_t i,j,k;
+    
+    Double_t valJet[fnDimJet];
+    Double_t valCluster[fnDimJet];
+    for (i=0;i<fnDimJet;i)
+    {
+        valJet[i]=0.0;
+        valCluster[i]=0.0;
+    }
+    
     Double_t nef=0.0;
+    Double_t jetPt=0.0;
     Double_t tempChargedHighPt=0.0;
     Double_t eta=0.0;
     Double_t phi=0.0;
     Int_t totalMult=0;
+    Int_t chargedMult=0;
     Int_t neutralMult=0;
     Int_t iSupMod = -1, absId = -1, ieta = -1, iphi = -1;
     Bool_t shared = kFALSE;
@@ -4322,24 +4297,50 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::DoNEFAnalysis(Double_t nefCut, D
     Int_t tempCellID=0;
     Double_t tempCellTime=0.0;
     
+    Double_t event_centrality = event->GetCentrality()->GetCentralityPercentile(fCentralityTag);
+    valJet[4] = valCluster[4] = event_centrality;
+
     // First, do Jet QA
     for (i=0;i<nIndexJetList;i++)
     {
         AliEmcalJet *myJet = (AliEmcalJet*) jetList->At(indexJetList[i]);
         tempChargedHighPt = myJet->MaxTrackPt();
         nef=myJet->NEF();
+       jetPt=myJet->Pt();
         eta=myJet->Eta();
         phi=myJet->Phi();
         totalMult=myJet->GetNumberOfConstituents();
+       chargedMult = myJet->GetNumberOfTracks();
         neutralMult=myJet->GetNumberOfClusters();
         zLeading=myJet->MaxClusterPt()/myJet->Pt();
         
-        fhNEF->Fill(nef);
-        fhNEFJetPt->Fill(nef,myJet->Pt());
-        fhNEFEtaPhi->Fill(eta,phi);
-        fhEtaPhiNEF->Fill(eta,phi,nef);
-        fhNEFTotalMult->Fill(nef,totalMult);
-        fhNEFNeutralMult->Fill(nef,neutralMult);
+       valJet[0] = valCluster[0] = nef;
+        valJet[1] = valCluster[1] = jetPt;
+        valJet[2] = valCluster[2] = eta;
+        valJet[3] = valCluster[3] = phi;
+        
+        valJet[5] = totalMult;
+        valJet[6] = chargedMult;
+        valJet[7] = neutralMult;
+         
+        valCluster[6] = zLeading;
+
+        fhJetNEFInfo->Fill(valJet);
+        
+        if (fSignalTrackBias==kTRUE)
+        {
+            if (tempChargedHighPt>=signalCut && nef<=nefCut)
+            {
+                fhJetNEFSignalInfo->Fill(valJet);
+            }
+        }
+        else
+        {
+            if (jetPt>=signalCut && nef<=nefCut)
+            {
+                fhJetNEFSignalInfo->Fill(valJet);
+            }
+        }
         
         for (j=0;j<neutralMult;j++)
         {
@@ -4349,11 +4350,7 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::DoNEFAnalysis(Double_t nefCut, D
             tCell = cells->GetCellTime(absId);
             eCross = recoUtils->GetECross(absId,tCell,cells,event->GetBunchCrossNumber());
             FCross = 1 - eCross/eSeed;
-            
-            fhNEFJetPtFCross->Fill(nef,myJet->Pt(),FCross);
-            fhNEFZLeadingFCross->Fill(nef,zLeading,FCross);
-            fhNEFTimeCellCount->Fill(nef,tCell,vcluster->GetNCells());
-            
+           
             // Obtain Delta t of Cluster
             lowTime=9.99e99;
             upTime=-9.99e99;
@@ -4370,51 +4367,43 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::DoNEFAnalysis(Double_t nefCut, D
                     lowTime=tempCellTime;
                 }
             }
-            fhNEFTimeDeltaTime->Fill(nef,tCell,upTime-lowTime);
-            
-            tempCellID=0;
-            tempCellTime=0.0;
-            eSeed=0.0;
-            tCell=0.0;
-            eCross=0.0;
-            FCross=0.0;
-            iSupMod=-1,absId=-1,ieta=-1,iphi=-1;
-        }
 
-        if (fSignalTrackBias==kTRUE)
-        {
-            if (tempChargedHighPt>=signalCut)
-            {
-                if (nef<=nefCut)
+           valCluster[5] = FCross;
+            valCluster[7] = tCell;
+            valCluster[8] = upTime-lowTime;
+            valCluster[9] = vcluster->GetNCells();
+            
+           fhClusterNEFInfo->Fill(valCluster);
+            if (fSignalTrackBias==kTRUE)
+             {
+               if (tempChargedHighPt>=signalCut && nef<=nefCut)
                 {
-                    fhNEFSignal->Fill(nef);
-                    fhNEFJetPtSignal->Fill(nef,myJet->Pt());
-                    fhNEFEtaPhiSignal->Fill(eta,phi);
-                    fhNEFTotalMultSignal->Fill(nef,totalMult);
-                    fhNEFNeutralMultSignal->Fill(nef,neutralMult);
+                 fhClusterNEFSignalInfo->Fill(valCluster);
                 }
             }
-        }
-        else
-        {
-            if (myJet->Pt()>=signalCut)
+           else
             {
-                if (nef<=nefCut)
+             if (myJet->Pt()>=signalCut && nef<=nefCut)
                 {
-                    fhNEFSignal->Fill(nef);
-                    fhNEFJetPtSignal->Fill(nef,myJet->Pt());
-                    fhNEFEtaPhiSignal->Fill(eta,phi);
-                    fhNEFTotalMultSignal->Fill(nef,totalMult);
-                    fhNEFNeutralMultSignal->Fill(nef,neutralMult);
+                 fhClusterNEFSignalInfo->Fill(valCluster);
                 }
             }
+           tempCellID=0;
+            tempCellTime=0.0;
+            eSeed=0.0;
+            tCell=0.0;
+            eCross=0.0;
+            FCross=0.0;
+            iSupMod=-1,absId=-1,ieta=-1,iphi=-1;
         }
         nef=0.0;
+       jetPt=0.0;
         tempChargedHighPt=0.0;
         eta=0.0;
         phi=0.0;
         totalMult=0;
         neutralMult=0;
+       chargedMult=0;
         zLeading=0.0;
     }
     
@@ -4437,10 +4426,14 @@ void AliAnalysisTaskFullpAJets::AlipAJetHistos::FillMiscJetStats(TClonesArray *j
         AliEmcalJet *myJet = (AliEmcalJet*) jetList->At(indexJetList[i]);
 
         fhJetPtArea->Fill(myJet->Pt(),myJet->Area());
+       fhJetConstituentCounts->Fill(myJet->Pt(),myJet->GetNumberOfConstituents());
+        fhJetTracksCounts->Fill(myJet->Pt(),myJet->GetNumberOfTracks());
+        fhJetClustersCounts->Fill(myJet->Pt(),myJet->GetNumberOfClusters());
         for (j=0;j<myJet->GetNumberOfTracks();j++)
         {
             AliVTrack *vtrack = (AliVTrack*) myJet->TrackAt(j,trackList);
             fhJetConstituentPt->Fill(myJet->Pt(),vtrack->Pt());
+           fhJetTracksPt->Fill(myJet->Pt(),vtrack->Pt());
         }
         for (j=0;j<myJet->GetNumberOfClusters();j++)
         {
index fb5f2efa94dbe8d8c089352030f1299ef4c53218..9c6eb87b5c41a18f898e19d92ed70a28a2f11660 100644 (file)
@@ -5,6 +5,7 @@ class TString;
 class TH1D;
 class TH2D;
 class TH3D;
+class THnSparse;
 class TList;
 class TProfile;
 class TProfile2D;
@@ -53,7 +54,7 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
         void SetJetR(Double_t jetR);
         void SetNEF(Double_t nef);
         void SetSignalTrackPtBias(Bool_t chargedBias);
-        
+
         // Getters
         Int_t GetTotalEntries();
         Int_t GetTotalJets();
@@ -133,6 +134,8 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
         void SetLeadingChargedTrackPtRange(Int_t bins, Double_t low, Double_t up);
         void SetNEFRange(Int_t bins, Double_t low, Double_t up);
         void SetSignalTrackPtBias(Bool_t chargedBias);
+       void SetNEFJetDimensions(Int_t n);
+        void SetNEFClusterDimensions(Int_t n);     
 
         // User Defined Functions
         TList* GetOutputHistos();  //!
@@ -153,7 +156,6 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
         TH1D *fh80100BSPt; //!
         TH1D *fhBSPt; //!
         TH2D *fhBSPtCen; //!
-        //TH3D *fhBSPtCenLCT; //!
         
         // This set of Histograms is for filling the Background Subtracted Signal Jet Spectra
         TH1D *fh020BSPtSignal; //!
@@ -188,33 +190,24 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
         // Profiles
         TProfile *fpRho; //!
         TProfile *fpLJetRho; //!
-        TH2D *fhJetConstituentPt; //!
         TH2D *fhJetPtArea; //!
+        TH2D *fhJetConstituentPt; //!
+       TH2D *fhJetTracksPt; //!
+        TH2D *fhJetClustersPt; //!
+        TH2D *fhJetConstituentCounts; //!
+        TH2D *fhJetTracksCounts; //!
+        TH2D *fhJetClustersCounts; //!
         
         // Histograms for Neutral Energy Fraction
         TList *fNEFOutput; //! NEF QA Plots
-        
-        TH1D *fhNEF; //!
-        TH1D *fhNEFSignal; //!
-        TH2D *fhNEFJetPt; //!
-        TH2D *fhNEFJetPtSignal; //!
-        
-        TH2D *fhNEFEtaPhi; //!
-        TH2D *fhNEFEtaPhiSignal; //!
-        TH3D *fhEtaPhiNEF; //!
-        
-        TH2D *fhNEFTotalMult; //!
-        TH2D *fhNEFTotalMultSignal; //!
-
-        TH2D *fhNEFNeutralMult; //!
-        TH2D *fhNEFNeutralMultSignal; //!
 
-        TH1D *fhClusterShapeAll; //!
+       THnSparse *fhJetNEFInfo; //! Jet NEF Information Histogram
+        THnSparse *fhJetNEFSignalInfo; //! Signal Jet NEF Information Histogram
+        THnSparse *fhClusterNEFInfo; //! Cluster Jet NEF Information Histogram
+        THnSparse *fhClusterNEFSignalInfo; //! Cluster Signal Jet NEF Information Histogram
+        
+       TH1D *fhClusterShapeAll; //!
         TH2D *fhClusterPtCellAll; //!
-        TH3D *fhNEFJetPtFCross; //!
-        TH3D *fhNEFZLeadingFCross; //!
-        TH3D *fhNEFTimeCellCount; //!
-        TH3D *fhNEFTimeDeltaTime; //!
 
         // Variables
         const char *fName;  //!
@@ -256,7 +249,9 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
         Int_t fNEFBins;
         Double_t fNEFLow;
         Double_t fNEFUp;
-        
+        Int_t fnDimJet;
+        Int_t fnDimCluster;
+
         // These members are 'sourced' from the base class and are initalized in the constructor
         Double_t fEMCalPhiMin;
         Double_t fEMCalPhiMax;
@@ -462,11 +457,6 @@ class AliAnalysisTaskFullpAJets : public AliAnalysisTaskSE
     TH2D *fhTPCEventMult; //!
     TH2D *fhEMCalTrackEventMult; //!
     
-    TH3D *fhTrackEtaPhiPt;  //!
-    TH3D *fhGlobalTrackEtaPhiPt;  //!
-    TH3D *fhComplementaryTrackEtaPhiPt;  //!
-    TH3D *fhClusterEtaPhiPt;  //!
-    
     TProfile *fpEMCalEventMult;  //!
     TProfile *fpTPCEventMult;  //!
     
index b495a4c59a75f63091d00cd6db8b649b92c0e676..e21ce426ec3bf98d0d9d2aaa2cbe164d8c2dfc73 100644 (file)
@@ -34,9 +34,14 @@ class TParticle;
 
 #include "AliESDtrackCuts.h"
 #include "AliAnalysisTaskSE.h"
+#ifndef __CINT__
 #include "fastjet/JetDefinition.hh"
 #include "fastjet/PseudoJet.hh"
-
+#else
+namespace fastjet {
+  class PseudoJet;
+}
+#endif
 class AliAnalysisTaskFullppJet : public AliAnalysisTaskSE {
  public:
   AliAnalysisTaskFullppJet();
index c996d71681b33e6ddb6489102af550ded647b03c..e53cfe71b8744a61b9d4a2bb0c356218df0a4a9f 100644 (file)
@@ -1,3 +1,18 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
 // 
 // General task to match two sets of jets
 //
@@ -128,14 +143,14 @@ void AliAnalysisTaskJetMatching::UserCreateOutputObjects()
     fHistMatchedSourceJetPt = (fDoDetectorResponse) ? BookTH1F("fHistMatchedParticleLevelJetPt", "p_{t}^{gen} [GeV/c]", 150, -50, 250) : BookTH1F("fHistMatchedSourceJetPt", "p_{t} [GeV/c]", 150, -50, 250);
     fHistTargetJetPt = BookTH1F("fHistTargetJetPt", "p_{t} [GeV/c]", 150, -50, 250);
     fHistMatchedJetPt = (fDoDetectorResponse) ? BookTH1F("fHistDetectorLevelJet", "p_{t}^{rec}", 150, -50, 250) : BookTH1F("fHistMatchedJetPt", "p_{t} [GeV/c]", 150, -50, 250);
-    fHistSourceMatchedJetPt = (fDoDetectorResponse) ? BookTH2F("fHistPartDetJetPt", "particle level jet p_{t}^{gen} [GeV/c]", "detector level jet p_{t}^{rec} [GeV/c]", 300, -50, 250, 300, -50, 250) : BookTH2F("fHistSourceMatchedJetPt", "source jet p_{t} [GeV/c]", "matched jet p_{t} [GeV/c]", 300, -50, 250, 300, -50, 250);
-    fHistNoConstSourceJet = BookTH1F("fHistNoConstSourceJet", "number of constituents", 50, 0, 50);
-    fHistNoConstTargetJet = BookTH1F("fHistNoConstTargetJet", "number of constituents", 50, 0, 50);
-    fHistNoConstMatchJet = BookTH1F("fHistNoConstMatchJet", "number of constituents", 50, 0, 50);
+    fHistSourceMatchedJetPt = (fDoDetectorResponse) ? BookTH2F("fHistDetectorResponse", "particle level jet p_{t}^{gen} [GeV/c]", "detector level jet p_{t}^{rec} [GeV/c]", 300, -50, 250, 300, -50, 250) : BookTH2F("fHistSourceMatchedJetPt", "source jet p_{t} [GeV/c]", "matched jet p_{t} [GeV/c]", 300, -50, 250, 300, -50, 250);
+    fHistNoConstSourceJet = BookTH1F("fHistNoConstSourceJet", "number of constituents source jets", 50, 0, 50);
+    fHistNoConstTargetJet = BookTH1F("fHistNoConstTargetJet", "number of constituents target jets", 50, 0, 50);
+    fHistNoConstMatchJet = BookTH1F("fHistNoConstMatchJet", "number of constituents matched jets", 50, 0, 50);
     if(!fDoDetectorResponse) { // these observables cannot be measured in current detector response mode
-        fProfFracPtMatched = new TProfile("fProfFracPtMatched", "fProfFracPtMatched", 15, -50, 250);
+        fProfFracPtMatched = new TProfile("fProfFracPtMatched", "recovered target p_{T} / source p_{T}", 15, -50, 250);
         fOutputList->Add(fProfFracPtMatched);
-        fProfFracNoMatched = new TProfile("fProfFracNoMatched", "fProfFracNoMatched", 15, -50, 250);
+        fProfFracNoMatched = new TProfile("fProfFracNoMatched", "recovered target constituents / source constituents", 15, -50, 250);
         fOutputList->Add(fProfFracNoMatched);
     }
     // the analysis summary histo which stores all the analysis flags is always written to file
@@ -150,9 +165,9 @@ void AliAnalysisTaskJetMatching::UserCreateOutputObjects()
     fProfQA->GetXaxis()->SetBinLabel(2, "<#delta #eta>");
     fProfQA->GetXaxis()->SetBinLabel(3, "<#delta #varphi>");
     fOutputList->Add(fProfQA);
-    fProfFracPtJets = new TProfile("fProfFracPtJets", "fProfFracPtJets", 15, -50, 250);
+    fProfFracPtJets = new TProfile("fProfFracPtJets", "source p_{T} / target p_{T}", 15, -50, 250);
     fOutputList->Add(fProfFracPtJets);
-    fProfFracNoJets = new TProfile("fProfFracNoJets", "fProfFracNoJets", 15, -50, 250);
+    fProfFracNoJets = new TProfile("fProfFracNoJets", "source constituents / target constituents", 15, -50, 250);
     fOutputList->Add(fProfFracNoJets);
     fOutputList->Sort();
     PostData(1, fOutputList);
index 9af3d948afd223c2750462d0e9f44a1ebb05793c..500e746770b6983cf1ce022e48f2c9294dc78e0f 100644 (file)
@@ -18,7 +18,8 @@ AliAnalysisTaskSE* AddTaskJetPreparation(
   const Bool_t   makePicoTracks     = kTRUE,
   const Bool_t   makeTrigger        = kTRUE,
   const Bool_t   isEmcalTrain       = kFALSE,
-  const Double_t trackeff           = 1.0
+  const Double_t trackeff           = 1.0,
+  const Bool_t   doAODTrackProp     = kFALSE
 )
 {
   // Add task macros for all jet related helper tasks.
@@ -44,21 +45,25 @@ AliAnalysisTaskSE* AddTaskJetPreparation(
   if (makePicoTracks && (dType == "ESD" || dType == "AOD") )
   {
     TString inputTracks = "tracks";
-
+    const Double_t edist = 440;
     if (dType == "ESD")
     {
       inputTracks = "HybridTracks";
       TString trackCuts(Form("Hybrid_%s", period.Data()));
       // Hybrid tracks maker for ESD
-      gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalEsdTpcTrack.C");
-      AliEmcalEsdTpcTrackTask *hybTask = AddTaskEmcalEsdTpcTrack(inputTracks.Data(),trackCuts.Data());
+      gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalEsdTrackFilter.C");
+      AliEmcalEsdTrackFilterTask *hybTask = AddTaskEmcalEsdTrackFilter(inputTracks.Data(),trackCuts.Data());
+      hybTask->SetDoPropagation(kTRUE);
+      hybTask->SetDist(edist);
       hybTask->SelectCollisionCandidates(pSel);
-
-      // Track propagator to extend track to the TPC boundaries
-      gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalTrackPropagator.C");
-      AliEmcalTrackPropagatorTask *propTask = AddTaskEmcalTrackPropagator(inputTracks.Data(),440.);
+    } else if(dType == "AOD" && doAODTrackProp) {
+      // Track propagator to extend track to the EMCal surface
+      gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalTrackPropagatorAOD.C");
+      AliEmcalTrackPropagatorTaskAOD *propTask = AddTaskEmcalTrackPropagatorAOD(inputTracks.Data());
+      propTask->SetDist(edist);
       propTask->SelectCollisionCandidates(pSel);
     }
+
     // Produce PicoTracks 
     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C");
     AliEmcalPicoTrackMaker *pTrackTask = AddTaskEmcalPicoTrackMaker("PicoTracks", inputTracks.Data(), period.Data());
@@ -80,7 +85,7 @@ AliAnalysisTaskSE* AddTaskJetPreparation(
 
   // Relate tracks and clusters
   gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalClusTrackMatcher.C");
-  AliEmcalClusTrackMatcherTask *emcalClus =  AddTaskEmcalClusTrackMatcher("EmcalTracks","EmcalClusters",0.1);
+  AliEmcalClusTrackMatcherTask *emcalClus =  AddTaskEmcalClusTrackMatcher("EmcalTracks","EmcalClusters",0.1,doHistos);
   emcalClus->SelectCollisionCandidates(pSel);
   if (isEmcalTrain)
     RequestMemory(emcalClus,100*1024);
index 6a64fae8c9cd4acf9f8d5453dfc83eee950d289c..454881817934e2af0ebb074d080b504e0ca67d36 100644 (file)
@@ -790,6 +790,12 @@ void AliAnalysisTaskFlavourJetCorrelations::SideBandBackground(AliAODRecoCascade
    Double_t mPDGD0=TDatabasePDG::Instance()->GetParticle(421)->Mass();\r
    \r
    Int_t bin = fCuts->PtBin(candDstar->Pt());\r
+   if (bin < 0)\r
+     {\r
+       // coverity - issue related to /PWGHF/vertexingHF/AliRDHFCuts::PtBin(Double_t) const\r
+       AliFatal("bin < 0 used as an array index; check: /PWGHF/vertexingHF/AliRDHFCuts::PtBin(Double_t) const");\r
+       bin = 9999; // coverity - should be unreachable anyhow\r
+     }\r
    Float_t fourSigmal= mPDGD0-4.*fSigmaD0[bin] , sixSigmal= mPDGD0-8.*fSigmaD0[bin];\r
    Float_t fourSigmar= mPDGD0+4.*fSigmaD0[bin] , sixSigmar= mPDGD0+8.*fSigmaD0[bin];\r
    \r
index 0ab8e847b29ab6f8928358d0a8e5c297a47c282c..3d507fdedf6ed85c32b7166c22bd5336485b8798 100644 (file)
@@ -2749,6 +2749,7 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
               continue;
             
             Bool_t survivedTPCCutMIGeo = AliAnalysisTaskPID::TPCCutMIGeo(inclusiveaod, InputEvent());
+            Bool_t survivedTPCnclCut = AliAnalysisTaskPID::TPCnclCut(inclusiveaod);
             
             Int_t label = TMath::Abs(inclusiveaod->GetLabel());
             
@@ -2788,7 +2789,9 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
                                                                   centPercent,
                                                                   -1, -1, -1 };// no jet pT etc since inclusive spectrum 
               for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-                if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo())
+                if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                    (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                    (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut()))
                   fInclusivePIDtask[i]->FillEfficiencyContainer(value, AliAnalysisTaskPID::kStepRecWithGenCuts);
               }
                   
@@ -2796,7 +2799,9 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
                                                                       inclusiveaod->Charge(), centPercent,
                                                                       -1, -1, -1 };// no jet pT etc since inclusive spectrum 
               for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-                if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo())
+                if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                    (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                    (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut()))
                   fInclusivePIDtask[i]->FillEfficiencyContainer(valueMeas, AliAnalysisTaskPID::kStepRecWithGenCutsMeasuredObs);
               }
             }
@@ -2820,6 +2825,7 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
               continue;
             
             Bool_t survivedTPCCutMIGeo = AliAnalysisTaskPID::TPCCutMIGeo(inclusiveaod, InputEvent());
+            Bool_t survivedTPCnclCut = AliAnalysisTaskPID::TPCnclCut(inclusiveaod);
             
             Int_t label = TMath::Abs(inclusiveaod->GetLabel());
 
@@ -2831,7 +2837,9 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
               pdg = gentrack->GetPdgCode();
             
             for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-              if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo())
+              if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                  (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                  (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut()))
                 fInclusivePIDtask[i]->ProcessTrack(inclusiveaod, pdg, centPercent, -1); // no jet pT since inclusive spectrum 
             }
             
@@ -2841,13 +2849,17 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
                                                                             inclusiveaod->Charge(), centPercent,
                                                                             -1, -1, -1 };
               for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-                if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo())
+                if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                    (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                    (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut()))
                   fInclusivePIDtask[i]->FillEfficiencyContainer(valueRecAllCuts, AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObs);
               }
               
               Double_t weight = IsSecondaryWithStrangeMotherMC(gentrack) ? GetMCStrangenessFactorCMS(gentrack) : 1.0;
               for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-                if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo())
+                if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                    (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                    (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut()))
                   fInclusivePIDtask[i]->FillEfficiencyContainer(valueRecAllCuts, 
                                                                 AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObsStrangenessScaled,
                                                                 weight);
@@ -2863,7 +2875,9 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
                                                                                   gentrack->Charge() / 3., centPercent };
               
                 for (Int_t i = 0; i < fNumInclusivePIDtasks; i++) {
-                  if (survivedTPCCutMIGeo || !fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) {
+                  if ((!fInclusivePIDtask[i]->GetUseTPCCutMIGeo() && !fInclusivePIDtask[i]->GetUseTPCnclCut()) ||
+                      (survivedTPCCutMIGeo && fInclusivePIDtask[i]->GetUseTPCCutMIGeo()) ||
+                      (survivedTPCnclCut && fInclusivePIDtask[i]->GetUseTPCnclCut())) {
                     fInclusivePIDtask[i]->FillEfficiencyContainer(valueRecAllCuts, 
                                                                   AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObsPrimaries);
                     fInclusivePIDtask[i]->FillEfficiencyContainer(valueGenAllCuts, 
@@ -3133,6 +3147,7 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
           continue;
         
         Bool_t survivedTPCCutMIGeo = AliAnalysisTaskPID::TPCCutMIGeo(aodtrack, InputEvent());
+        Bool_t survivedTPCnclCut = AliAnalysisTaskPID::TPCnclCut(aodtrack);
             
         Int_t label = TMath::Abs(aodtrack->GetLabel());
 
@@ -3153,13 +3168,17 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
           Double_t valueRecAllCuts[AliAnalysisTaskPID::kEffNumAxes] = { mcID, pT, aodtrack->Eta(), aodtrack->Charge(),
                                                                         centPercent, jetPt, z, xi };
           for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-            if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo())
+            if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+                (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+                (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut()))
               fJetPIDtask[i]->FillEfficiencyContainer(valueRecAllCuts, AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObs);
           }
           
           Double_t weight = IsSecondaryWithStrangeMotherMC(gentrack) ? GetMCStrangenessFactorCMS(gentrack) : 1.0;
           for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-            if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo())
+            if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+                (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+                (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut()))
               fJetPIDtask[i]->FillEfficiencyContainer(valueRecAllCuts, 
                                                       AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObsStrangenessScaled,
                                                       weight);
@@ -3177,7 +3196,9 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
             Double_t valuePtResolution[AliAnalysisTaskPID::kPtResNumAxes] = { jetPt, genPt, pT, gentrack->Charge() / 3., centPercent };
             
             for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-              if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo()) {
+              if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+                  (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+                  (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut())) {
                 fJetPIDtask[i]->FillEfficiencyContainer(valueRecAllCuts,
                                                         AliAnalysisTaskPID::kStepRecWithRecCutsMeasuredObsPrimaries);
                 fJetPIDtask[i]->FillEfficiencyContainer(valueGenAllCuts,
@@ -3190,11 +3211,15 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
         }
         
         for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-          if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo())
+          if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+              (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+              (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut()))
             fJetPIDtask[i]->ProcessTrack(aodtrack, pdg, centPercent, jetPt);
         }
         
-        if (fIDFFMode && (survivedTPCCutMIGeo || !fJetPIDtask[0]->GetUseTPCCutMIGeo())) {
+        if (fIDFFMode && ((!fJetPIDtask[0]->GetUseTPCCutMIGeo() && !fJetPIDtask[0]->GetUseTPCnclCut()) ||
+            (survivedTPCCutMIGeo && fJetPIDtask[0]->GetUseTPCCutMIGeo()) ||
+            (survivedTPCnclCut && fJetPIDtask[0]->GetUseTPCnclCut()))) {
           // NOTE: Just take particle fraction from first task (should anyway be the same for all tasks)
           Int_t pidWeightedSpecies = fJetPIDtask[0]->GetRandomParticleTypeAccordingToParticleFractions(pT, jetPt,
                                                                                                        centPercent, kTRUE);
@@ -3242,14 +3267,18 @@ void AliAnalysisTaskIDFragmentationFunction::UserExec(Option_t *)
           Double_t value[AliAnalysisTaskPID::kEffNumAxes] = { mcID, genPt, gentrack->Eta(), gentrack->Charge() / 3.,
                                                               centPercent, jetPt, genZ, genXi };
           for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-            if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo())
+            if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+                (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+                (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut()))
               fJetPIDtask[i]->FillEfficiencyContainer(value, AliAnalysisTaskPID::kStepRecWithGenCuts);
           }
           
           Double_t valueMeas[AliAnalysisTaskPID::kEffNumAxes] = { mcID, measPt, aodtrack->Eta(), aodtrack->Charge(),
                                                                   centPercent, jetPt, measZ, measXi };
           for (Int_t i = 0; i < fNumJetPIDtasks; i++) {
-            if (survivedTPCCutMIGeo || !fJetPIDtask[i]->GetUseTPCCutMIGeo())
+            if ((!fJetPIDtask[i]->GetUseTPCCutMIGeo() && !fJetPIDtask[i]->GetUseTPCnclCut()) ||
+                (survivedTPCCutMIGeo && fJetPIDtask[i]->GetUseTPCCutMIGeo()) ||
+                (survivedTPCnclCut && fJetPIDtask[i]->GetUseTPCnclCut()))
               fJetPIDtask[i]->FillEfficiencyContainer(valueMeas, AliAnalysisTaskPID::kStepRecWithGenCutsMeasuredObs);
           }
         }
index 160724340bea4f49e38ab8a6d634b310c0a07c41..5eeb20f64b5a2f60f8584f4d1b150521ae82bbb3 100644 (file)
 
 #include  "AliAnalysisTaskSE.h"
 #include  "THnSparse.h" // cannot forward declare ThnSparseF
+#ifndef __CINT__
 #include "fastjet/ClusterSequenceArea.hh"
 #include "fastjet/AreaDefinition.hh"
 #include "fastjet/JetDefinition.hh"
 #include "fastjet/PseudoJet.hh"
+#else
+namespace fastjet {
+  class PseudoJet;
+  class GhostedAreaSpec;
+  class AreaType;
+  class JetDefinition;
+  class JetAlgorithm;
+  class Strategy;
+  class RecombinationScheme;
+}
+#endif
 #include "TH1F.h"
 #include "TH2D.h"
 
index 5217db05001d9cb6709f433a7638df538de9f1d1..5e155ac1241f021b49d96f153c7a20465f6ae4be 100644 (file)
@@ -30,7 +30,7 @@ public:
   void    SetJetPtBinMax(Float_t ptmax) { fJetPtBinMax = ptmax; }
   Float_t GetJetPtBinMax() const { return fJetPtBinMax; }
 
-  void SetJetBranchName(const char* const branchName) { strncpy(fJetBranchName, branchName, fgkStringLength-1); }
+  void SetJetBranchName(const char* branchName) { strncpy(fJetBranchName, branchName, fgkStringLength-1); }
   const char* GetJetBranchName() const { return fJetBranchName; }
 
   // histograms
@@ -90,7 +90,7 @@ protected:
   TH1  *fHist[kHistLast];      //! pointers to histogram
   const char *fShortTaskId;    //! short identifier for the task
 
-  TH1*&  GetHistogram(Hist_t hist, const Int_t idx = 0) { return fHist[hist + idx]; }
+  TH1*&  GetHistogram(Hist_t hist, Int_t idx = 0) { return fHist[hist + idx]; }
 
   TH1*   AddHistogram(Hist_t hist, const char *hid, TString title,
                       Int_t xbins, Float_t xmin, Float_t xmax, Int_t binType = 1);
index 64b6f8bc698a4db47a24f5a5de85b1ff684dba47..31e4b9873218ecb00b86a8c7ef1a966b28f2a468 100644 (file)
@@ -37,6 +37,10 @@ Contact: bhess@cern.ch
 
 ClassImp(AliAnalysisTaskPID)
 
+const Double_t AliAnalysisTaskPID::fgkEpsilon = 1e-8; // Double_t threshold above zero
+const Double_t AliAnalysisTaskPID::fgkOneOverSqrt2 = 0.707106781186547462; // = 1. / TMath::Sqrt2();
+const Double_t AliAnalysisTaskPID::fgkSigmaReferenceForTransitionPars = 0.05; // Reference sigma chosen to calculate transition parameters
+
 //________________________________________________________________________
 AliAnalysisTaskPID::AliAnalysisTaskPID()
   : AliAnalysisTaskPIDV0base()
@@ -905,9 +909,6 @@ void AliAnalysisTaskPID::UserExec(Option_t *)
     
     
     // Apply detector level track cuts
-    //if (track->GetTPCsignalN() < 60)
-    //  continue;
-    
     Double_t dEdxTPC = fPIDResponse->IsTunedOnData() ? fPIDResponse->GetTPCsignalTunedOnData(track) : track->GetTPCsignal();
     if (dEdxTPC <= 0)
       continue;
@@ -915,10 +916,14 @@ void AliAnalysisTaskPID::UserExec(Option_t *)
     if(fTrackFilter && !fTrackFilter->IsSelected(track))
       continue;
     
-    if (fUseTPCCutMIGeo) {
+    if (GetUseTPCCutMIGeo()) {
       if (!TPCCutMIGeo(track, fEvent))
         continue;
     }
+    else if (GetUseTPCnclCut()) {
+      if (!TPCnclCut(track))
+        continue;
+    }
     
     if(fUsePhiCut) {
       if (!PhiPrimeCut(track, magField))
@@ -1877,6 +1882,15 @@ void AliAnalysisTaskPID::PrintSettings(Bool_t printSystematicsSettings) const
   printf("Eta cut: %.2f <= |eta| <= %.2f\n", GetEtaAbsCutLow(), GetEtaAbsCutUp());
   printf("Phi' cut: %d\n", GetUsePhiCut());
   printf("TPCCutMIGeo: %d\n", GetUseTPCCutMIGeo());
+  if (GetUseTPCCutMIGeo()) {
+    printf("GetCutGeo: %f\n", GetCutGeo());
+    printf("GetCutNcr: %f\n", GetCutNcr());
+    printf("GetCutNcl: %f\n", GetCutNcl());
+  }
+  printf("TPCnclCut: %d\n", GetUseTPCnclCut());
+  if (GetUseTPCnclCut()) {
+    printf("GetCutPureNcl: %d\n", GetCutPureNcl());
+  }
   
   printf("\n");
   
index df9142a474ca1e13fe190cbd704660c003cbb252..ad53ea25c56b91a1dc3095a095747c47ee98af60 100644 (file)
@@ -223,11 +223,11 @@ class AliAnalysisTaskPID : public AliAnalysisTaskPIDV0base {
   virtual void SetUpPIDcombined();\r
   \r
   static const Int_t fgkNumJetAxes = 3; // Number of additional axes for jets\r
-  static const Double_t fgkEpsilon = 1e-8; // Double_t threshold above zero\r
+  static const Double_t fgkEpsilon; // Double_t threshold above zero\r
   static const Int_t fgkMaxNumGenEntries = 1000; // Maximum number of generated detector responses per track and delta(Prime) and associated species\r
 \r
  private:\r
-  static const Double_t fgkOneOverSqrt2 = 0.707106781186547462; // = 1. / TMath::Sqrt2();\r
+  static const Double_t fgkOneOverSqrt2; // = 1. / TMath::Sqrt2();\r
   \r
   AliPIDCombined* fPIDcombined; //! PID combined object\r
   \r
@@ -256,7 +256,7 @@ class AliAnalysisTaskPID : public AliAnalysisTaskPIDV0base {
   TF1* fConvolutedGausDeltaPrime; // Gaus convoluted with exponential tail to generate detector response (deltaPrime)\r
   \r
   Double_t fConvolutedGaussTransitionPars[3]; // Parameter for transition from gaussian parameters to asymmetric shape\r
-  static const Double_t fgkSigmaReferenceForTransitionPars = 0.05; // Reference sigma chosen to calculate transition parameters\r
+  static const Double_t fgkSigmaReferenceForTransitionPars; // Reference sigma chosen to calculate transition parameters\r
   \r
   Double_t fEtaAbsCutLow; // Lower cut value on |eta|\r
   Double_t fEtaAbsCutUp;  // Upper cut value on |eta|\r
index 49e0341eed0454447f870c76d60456514e2bc979..577900cd84b99c9cffbb0f3dbb063290df885962 100644 (file)
@@ -40,6 +40,8 @@ Double_t AliAnalysisTaskPIDV0base::fgCutGeo = 1.;
 Double_t AliAnalysisTaskPIDV0base::fgCutNcr = 0.85; 
 Double_t AliAnalysisTaskPIDV0base::fgCutNcl = 0.7;  
 
+UShort_t AliAnalysisTaskPIDV0base::fgCutPureNcl = 60;
+
 //________________________________________________________________________
 AliAnalysisTaskPIDV0base::AliAnalysisTaskPIDV0base()
   : AliAnalysisTaskSE()
@@ -50,7 +52,7 @@ AliAnalysisTaskPIDV0base::AliAnalysisTaskPIDV0base()
   , fV0KineCuts(0x0)
   , fIsPbpOrpPb(kFALSE)
   , fUsePhiCut(kFALSE)
-  , fUseTPCCutMIGeo(kFALSE)
+  , fTPCcutType(kNoCut)
   , fZvtxCutEvent(10.0)
   , fEtaCut(0.9)
   , fPhiCutLow(0x0)
@@ -84,7 +86,7 @@ AliAnalysisTaskPIDV0base::AliAnalysisTaskPIDV0base(const char *name)
   , fV0KineCuts(0x0)
   , fIsPbpOrpPb(kFALSE)
   , fUsePhiCut(kFALSE)
-  , fUseTPCCutMIGeo(kFALSE)
+  , fTPCcutType(kNoCut)
   , fZvtxCutEvent(10.0)
   , fEtaCut(0.9)
   , fPhiCutLow(0x0)
@@ -498,3 +500,17 @@ Bool_t AliAnalysisTaskPIDV0base::TPCCutMIGeo(const AliVTrack* track, const AliVE
   
   return kout;
 }
+
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskPIDV0base::TPCnclCut(const AliVTrack* track)
+{
+  //
+  // TPC Cut on TPCsignalN() only
+  //
+
+  if (!track)
+    return kFALSE;
+  
+  return (track->GetTPCsignalN() >= fgCutPureNcl);
+}
index 019b79675b70be0bf0953446876e6d87cda401b2..e0a64448a072e55f6e6f5fe56314270cea2813e0 100644 (file)
-#ifndef ALIANALYSISTASKPIDV0BASE_H\r
-#define ALIANALYSISTASKPIDV0BASE_H\r
-\r
-/*\r
-This class is a base class for all other\r
-analysis tasks that use V0's.\r
-It provides basics for V0 identification.\r
-In addition, some further basic functions are provided.\r
-\r
-Class written by Benjamin Hess.\r
-Contact: bhess@cern.ch\r
-*/\r
-\r
-class TF1;\r
-class TRandom3;\r
-class TObjArray;\r
-class AliVEvent;\r
-class AliESDEvent;\r
-class AliMCEvent;\r
-class AliPIDResponse;\r
-class AliESDv0KineCuts;\r
-class AliPID;\r
-class AliAnalysisFilter;\r
-class AliVTrack;\r
-\r
-#include <TTreeStream.h>\r
-#include "AliInputEventHandler.h"\r
-#include "AliTOFPIDResponse.h"\r
-#include "AliAnalysisTaskSE.h"\r
-\r
-class AliAnalysisTaskPIDV0base : public AliAnalysisTaskSE {\r
- public:\r
-  AliAnalysisTaskPIDV0base();\r
-  AliAnalysisTaskPIDV0base(const char *name);\r
-  virtual ~AliAnalysisTaskPIDV0base();\r
-  \r
-  virtual void   UserCreateOutputObjects();\r
-  virtual void   UserExec(Option_t *option);\r
-  virtual void   Terminate(const Option_t*);\r
-  \r
-  virtual Bool_t GetVertexIsOk(AliVEvent* event) const;\r
-  \r
-  virtual Bool_t GetIsPbpOrpPb() const { return fIsPbpOrpPb; };\r
-  virtual void SetIsPbpOrpPb(Bool_t newValue) { fIsPbpOrpPb = newValue; };\r
-  \r
-  virtual Double_t GetZvtxCutEvent() const { return fZvtxCutEvent; };\r
-  virtual void SetZvtxCutEvent(Double_t newValue) { fZvtxCutEvent = newValue; };\r
-  \r
-  virtual Bool_t GetUsePhiCut() const { return fUsePhiCut; };\r
-  virtual void SetUsePhiCut(Bool_t newValue) { fUsePhiCut = newValue; };\r
-  \r
-  virtual Bool_t GetUseTPCCutMIGeo() const { return fUseTPCCutMIGeo; };\r
-  virtual void SetUseTPCCutMIGeo(Bool_t newValue) { fUseTPCCutMIGeo = newValue; };\r
-  \r
-  virtual Double_t GetEtaCut() const { return fEtaCut; };     \r
-  virtual void  SetEtaCut(Double_t etaCut){ fEtaCut = etaCut; };\r
-  \r
-  virtual const AliAnalysisFilter* GetTrackFilter() const { return fTrackFilter; };\r
-  virtual void  SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;}\r
-  \r
-  virtual Char_t GetV0tag(Int_t trackIndex) const;\r
-  \r
-  virtual Bool_t GetStoreMotherIndex() const { return fStoreMotherIndex; };\r
-  virtual void SetStoreMotherIndex(Bool_t newValue) { fStoreMotherIndex = newValue; };\r
-  \r
-  virtual Int_t GetV0motherIndex(Int_t trackIndex) const;\r
-  \r
-  virtual Double_t GetPhiPrime(Double_t phi, Double_t magField, Int_t charge) const;\r
-  virtual Bool_t PhiPrimeCut(const AliVTrack* track, Double_t magField) const;\r
-  virtual Bool_t PhiPrimeCut(Double_t trackPt, Double_t trackPhi, Short_t trackCharge, Double_t magField) const;\r
-  virtual Float_t GetDeltaTOF(const AliVTrack *track, const AliTOFPIDResponse* tofPIDresponse, const Double_t* times, \r
-                              AliPID::EParticleType type) const;\r
-  \r
-  static Double_t GetCutGeo() { return fgCutGeo; };\r
-  static Double_t GetCutNcr() { return fgCutNcr; };\r
-  static Double_t GetCutNcl() { return fgCutNcl; };\r
-  \r
-  static void SetCutGeo(Double_t value) { fgCutGeo = value; };\r
-  static void SetCutNcr(Double_t value) { fgCutNcr = value; };\r
-  static void SetCutNcl(Double_t value) { fgCutNcl = value; };\r
-  \r
-  static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliVEvent* evt, TTreeStream* streamer = 0x0);\r
-  static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliInputEventHandler* evtHandler, TTreeStream* streamer = 0x0)\r
-    { if (!evtHandler) return kFALSE; return TPCCutMIGeo(track, evtHandler->GetEvent(), streamer); };\r
-  \r
- protected:\r
-  static Double_t fgCutGeo;   // Cut variable for TPCCutMIGeo concerning geometry\r
-  static Double_t fgCutNcr; // Cut variable for TPCCutMIGeo concerning num crossed rows\r
-  static Double_t fgCutNcl;  // Cut variable for TPCCutMIGeo concerning num clusters\r
-  \r
-  AliVEvent   *fEvent;    //! VEvent object\r
-  AliESDEvent *fESD;      //! ESDEvent object, if ESD\r
-  AliMCEvent  *fMC;       //! MC object\r
-\r
-  AliPIDResponse *fPIDResponse;    //! PID response Handler\r
-  AliESDv0KineCuts *fV0KineCuts;       //! ESD V0 kine cuts\r
-  \r
-  Bool_t fIsPbpOrpPb;       // Pbp/pPb collision or something else?\r
-  Bool_t fUsePhiCut;        // Use cut on phi (useful for TPC)\r
-  Bool_t fUseTPCCutMIGeo;   // Use geometrical cut for TPC \r
-  Double_t fZvtxCutEvent;   // Vertex z cut for the event (cm)\r
-  Double_t fEtaCut;         // Eta cut\r
-  \r
-  TF1* fPhiCutLow;          // phi prime cut, low\r
-  TF1* fPhiCutHigh;         // phi prime cut, high\r
-  \r
-  TRandom3* fRandom;        //! Can be used to statistically determine the shape in the pt bins e.g.\r
-  \r
-  AliAnalysisFilter* fTrackFilter; // Track Filter\r
-  \r
-\r
-  Int_t fNumTagsStored;     // Number of entries of fV0tags\r
-  Char_t* fV0tags;         //! Pointer to array with tags for identified particles from V0 decays\r
-  \r
-  Bool_t fStoreMotherIndex; // Switch on/off storing the mother indices of V0 daughters\r
-  Int_t* fV0motherIndex; //! Pointer to array with index of the mother V0\r
-  \r
- private:\r
-  void FillV0PIDlist(AliESDEvent* esdEvent = 0x0);\r
-  void ClearV0PIDlist();\r
-  \r
-  AliAnalysisTaskPIDV0base(const AliAnalysisTaskPIDV0base&); // not implemented\r
-  AliAnalysisTaskPIDV0base& operator=(const AliAnalysisTaskPIDV0base&); // not implemented\r
-  \r
-  ClassDef(AliAnalysisTaskPIDV0base, 1);\r
-};\r
-\r
-\r
-\r
-inline Float_t AliAnalysisTaskPIDV0base::GetDeltaTOF(const AliVTrack *track, const AliTOFPIDResponse* tofPIDresponse,\r
-                                                     const Double_t* times, AliPID::EParticleType type) const\r
-{\r
-  return (track->GetTOFsignal() - tofPIDresponse->GetStartTime(track->P()) - times[type]);\r
-}\r
-\r
-#endif\r
+#ifndef ALIANALYSISTASKPIDV0BASE_H
+#define ALIANALYSISTASKPIDV0BASE_H
+
+/*
+This class is a base class for all other
+analysis tasks that use V0's.
+It provides basics for V0 identification.
+In addition, some further basic functions are provided.
+
+Class written by Benjamin Hess.
+Contact: bhess@cern.ch
+*/
+
+class TF1;
+class TRandom3;
+class TObjArray;
+class AliVEvent;
+class AliESDEvent;
+class AliMCEvent;
+class AliPIDResponse;
+class AliESDv0KineCuts;
+class AliPID;
+class AliAnalysisFilter;
+class AliVTrack;
+
+#include <TTreeStream.h>
+#include "AliInputEventHandler.h"
+#include "AliTOFPIDResponse.h"
+#include "AliAnalysisTaskSE.h"
+
+class AliAnalysisTaskPIDV0base : public AliAnalysisTaskSE {
+ public:
+  enum TPCcutType { kNoCut = 0, kTPCCutMIGeo = 1, kTPCnclCut = 2 };
+  AliAnalysisTaskPIDV0base();
+  AliAnalysisTaskPIDV0base(const char *name);
+  virtual ~AliAnalysisTaskPIDV0base();
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(const Option_t*);
+  
+  virtual Bool_t GetVertexIsOk(AliVEvent* event) const;
+  
+  virtual Bool_t GetIsPbpOrpPb() const { return fIsPbpOrpPb; };
+  virtual void SetIsPbpOrpPb(Bool_t newValue) { fIsPbpOrpPb = newValue; };
+  
+  virtual Double_t GetZvtxCutEvent() const { return fZvtxCutEvent; };
+  virtual void SetZvtxCutEvent(Double_t newValue) { fZvtxCutEvent = newValue; };
+  
+  virtual Bool_t GetUsePhiCut() const { return fUsePhiCut; };
+  virtual void SetUsePhiCut(Bool_t newValue) { fUsePhiCut = newValue; };
+  
+  virtual TPCcutType GetTPCcutType() const { return fTPCcutType; };
+  virtual Bool_t GetUseTPCCutMIGeo() const { return (fTPCcutType == kTPCCutMIGeo); };
+  virtual Bool_t GetUseTPCnclCut() const { return (fTPCcutType == kTPCnclCut); };
+  
+  virtual void SetTPCcutType(TPCcutType newType) { fTPCcutType = newType; };
+  
+  virtual Double_t GetEtaCut() const { return fEtaCut; };     
+  virtual void  SetEtaCut(Double_t etaCut){ fEtaCut = etaCut; };
+  
+  virtual const AliAnalysisFilter* GetTrackFilter() const { return fTrackFilter; };
+  virtual void  SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;}
+  
+  virtual Char_t GetV0tag(Int_t trackIndex) const;
+  
+  virtual Bool_t GetStoreMotherIndex() const { return fStoreMotherIndex; };
+  virtual void SetStoreMotherIndex(Bool_t newValue) { fStoreMotherIndex = newValue; };
+  
+  virtual Int_t GetV0motherIndex(Int_t trackIndex) const;
+  
+  virtual Double_t GetPhiPrime(Double_t phi, Double_t magField, Int_t charge) const;
+  virtual Bool_t PhiPrimeCut(const AliVTrack* track, Double_t magField) const;
+  virtual Bool_t PhiPrimeCut(Double_t trackPt, Double_t trackPhi, Short_t trackCharge, Double_t magField) const;
+  virtual Float_t GetDeltaTOF(const AliVTrack *track, const AliTOFPIDResponse* tofPIDresponse, const Double_t* times, 
+                              AliPID::EParticleType type) const;
+  
+  static Double_t GetCutGeo() { return fgCutGeo; };
+  static Double_t GetCutNcr() { return fgCutNcr; };
+  static Double_t GetCutNcl() { return fgCutNcl; };
+  
+  static void SetCutGeo(Double_t value) { fgCutGeo = value; };
+  static void SetCutNcr(Double_t value) { fgCutNcr = value; };
+  static void SetCutNcl(Double_t value) { fgCutNcl = value; };
+  
+  static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliVEvent* evt, TTreeStream* streamer = 0x0);
+  static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliInputEventHandler* evtHandler, TTreeStream* streamer = 0x0)
+    { if (!evtHandler) return kFALSE; return TPCCutMIGeo(track, evtHandler->GetEvent(), streamer); };
+  
+  static UShort_t GetCutPureNcl() { return fgCutPureNcl; };
+  static void SetCutPureNcl(UShort_t value) { fgCutPureNcl = value; };
+  
+  static Bool_t TPCnclCut(const AliVTrack* track);
+  
+ protected:
+  static Double_t fgCutGeo;   // Cut variable for TPCCutMIGeo concerning geometry
+  static Double_t fgCutNcr; // Cut variable for TPCCutMIGeo concerning num crossed rows
+  static Double_t fgCutNcl;  // Cut variable for TPCCutMIGeo concerning num clusters
+  
+  static UShort_t fgCutPureNcl; // Cut variable for TPCnclCut
+  
+  AliVEvent   *fEvent;    //! VEvent object
+  AliESDEvent *fESD;      //! ESDEvent object, if ESD
+  AliMCEvent  *fMC;       //! MC object
+
+  AliPIDResponse *fPIDResponse;    //! PID response Handler
+  AliESDv0KineCuts *fV0KineCuts;       //! ESD V0 kine cuts
+  
+  Bool_t fIsPbpOrpPb;       // Pbp/pPb collision or something else?
+  Bool_t fUsePhiCut;        // Use cut on phi (useful for TPC)
+  TPCcutType fTPCcutType;   // Type of TPC cut to be used
+  Double_t fZvtxCutEvent;   // Vertex z cut for the event (cm)
+  Double_t fEtaCut;         // Eta cut
+  
+  TF1* fPhiCutLow;          // phi prime cut, low
+  TF1* fPhiCutHigh;         // phi prime cut, high
+  
+  TRandom3* fRandom;        //! Can be used to statistically determine the shape in the pt bins e.g.
+  
+  AliAnalysisFilter* fTrackFilter; // Track Filter
+  
+
+  Int_t fNumTagsStored;     // Number of entries of fV0tags
+  Char_t* fV0tags;         //! Pointer to array with tags for identified particles from V0 decays
+  
+  Bool_t fStoreMotherIndex; // Switch on/off storing the mother indices of V0 daughters
+  Int_t* fV0motherIndex; //! Pointer to array with index of the mother V0
+  
+ private:
+  void FillV0PIDlist(AliESDEvent* esdEvent = 0x0);
+  void ClearV0PIDlist();
+  
+  AliAnalysisTaskPIDV0base(const AliAnalysisTaskPIDV0base&); // not implemented
+  AliAnalysisTaskPIDV0base& operator=(const AliAnalysisTaskPIDV0base&); // not implemented
+  
+  ClassDef(AliAnalysisTaskPIDV0base, 1);
+};
+
+
+
+inline Float_t AliAnalysisTaskPIDV0base::GetDeltaTOF(const AliVTrack *track, const AliTOFPIDResponse* tofPIDresponse,
+                                                     const Double_t* times, AliPID::EParticleType type) const
+{
+  return (track->GetTOFsignal() - tofPIDresponse->GetStartTime(track->P()) - times[type]);
+}
+
+#endif
index f2ab78cb123e06c7c696fd229f18c7ef1c8ab315..c0aa7ec2dff174f74c5e81362feeec33d8fe3658 100644 (file)
@@ -1,6 +1,6 @@
 
 
-AliAnalysisTaskJetCore* AddTaskJetCore(const char* bRec1,const char* bRec2, UInt_t filterMask = 272 , Float_t ptTrackMin = 0.15, Int_t kTriggerMask=0, Int_t eventClassMin = 0, Int_t eventClassMax = 4,Int_t kHardest=1,Float_t kTTminr=11,Float_t kTTmaxr=13,Float_t kTTmins=15,Float_t kTTmaxs=19){
+AliAnalysisTaskJetCore* AddTaskJetCore(const char* bRec1,const char* bRec2, UInt_t filterMask = 272 , Float_t ptTrackMin = 0.15, Int_t kTriggerMask=0, Int_t eventClassMin = 0, Int_t eventClassMax = 4,Int_t kHardest=1,Float_t kTTminr=11,Float_t kTTmaxr=13,Float_t kTTmins=15,Float_t kTTmaxs=19,Int_t kPhiBkg=0){
 
    Printf("adding task jet response\n");
 
@@ -20,7 +20,7 @@ AliAnalysisTaskJetCore* AddTaskJetCore(const char* bRec1,const char* bRec2, UInt
   TString typeRec(bRec1);
   TString typeGen(bRec2);
       
-  AliAnalysisTaskJetCore *task = new AliAnalysisTaskJetCore(Form("JetCore_%s_%s_%d_%d_%f%f%f%f",bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs));
+  AliAnalysisTaskJetCore *task = new AliAnalysisTaskJetCore(Form("JetCore_%s_%s_%d_%d_%f%f%f%f_%f",bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs,kPhiBkg));
    
 
 
@@ -36,7 +36,7 @@ AliAnalysisTaskJetCore* AddTaskJetCore(const char* bRec1,const char* bRec2, UInt
    task->SetTTUpRef(kTTmaxr);
    task->SetTTLowSig(kTTmins);
    task->SetTTUpSig(kTTmaxs);
-   
+   task->SetFlagPhiBkg(kPhiBkg);   
    task->SetJetPtMin(0.);   
    //task->SetAngStructCloseTracks(1);
 
@@ -45,7 +45,7 @@ AliAnalysisTaskJetCore* AddTaskJetCore(const char* bRec1,const char* bRec2, UInt
    mgr->AddTask(task);
 
 
-   AliAnalysisDataContainer *coutputJetCore = mgr->CreateContainer(Form("pwgjejetcore_%s_%s_%d_%d_%f%f%f%f",bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWGJE_jetcore_%s_%s_%d_%d_%f%f%f%f",AliAnalysisManager::GetCommonFileName(),bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs));
+   AliAnalysisDataContainer *coutputJetCore = mgr->CreateContainer(Form("pwgjejetcore_%s_%s_%d_%d_%f%f%f%f_%f",bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs,kPhiBkg), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWGJE_jetcore_%s_%s_%d_%d_%f%f%f%f_%f",AliAnalysisManager::GetCommonFileName(),bRec1,bRec2,kTriggerMask,kHardest,kTTminr,kTTmaxr,kTTmins,kTTmaxs,kPhiBkg));
 
 
 
index ec058d30d9c0523d2f1c9f75d2fab427348a3d0a..930cc9741f7adbcec00c245109b7370aca6e8714 100644 (file)
 
 if((DEFINED ALIROOT_SVN_REVISION)) 
   add_definitions(-DALIROOT_SVN_REVISION=${ALIROOT_SVN_REVISION})
+elseif((DEFINED ALIROOT_REVISION)) 
+  add_definitions(-DALIROOT_REVISION=\"${ALIROOT_REVISION}\")
 endif((DEFINED ALIROOT_SVN_REVISION)) 
 if((DEFINED ALIROOT_SVN_BRANCH)) 
   add_definitions(-DALIROOT_SVN_BRANCH=\"${ALIROOT_SVN_BRANCH}\")
+elseif((DEFINED ALIROOT_BRANCH)) 
+  add_definitions(-DALIROOT_BRANCH=\"${ALIROOT_BRANCH}\")
 endif((DEFINED ALIROOT_SVN_BRANCH))
 
 set ( SRCS   
@@ -250,7 +254,7 @@ install ( FILES FORWARD/analysis2/AddTaskCentraldNdeta.C
                 FORWARD/analysis2/AddTaskCopyHeader.C
                FORWARD/analysis2/AddTaskFMDELoss.C
                FORWARD/analysis2/AddTaskFMDEventPlane.C
-               FORWARD/analysis2/AddTaskForwardFlow.C
+               FORWARD/analysis2/AddTaskForwardFlowQC.C
                FORWARD/analysis2/AddTaskForwardMCCorr.C
                 FORWARD/analysis2/AddTaskForwardMult.C
                 FORWARD/analysis2/AddTaskForwardMultDists.C
similarity index 56%
rename from PWGLF/FORWARD/analysis2/AddTaskForwardFlow.C
rename to PWGLF/FORWARD/analysis2/AddTaskForwardFlowQC.C
index c31695674922c7e47274ded83ca487c7b3c46ea0..a8255b3fe9dce0faf2376c3d18656c42f4fc7954 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * @file   AddTaskForwardFlow.C
+ * @file   AddTaskForwardFlowQC.C
  * @author Alexander Hansen alexander.hansen@cern.ch 
  * 
  * @brief  
 /** 
  * Add Flow task to train 
  * 
- * @param type          Which moments to do 
+ * @param maxMom        Max moment to do 
  * @param useEtaGap     Whehter to use @f$\eta@f$ gaps
- * @param etaGap        Size of @f$\eta@f$ gap
- * @param useCent       Whether to use centrality 
  * @param mc            Monte-carlo input
- * @param satVtx        Use satellite interactions 
  * @param outlierCutFMD Cut to remove events with outliers 
  * @param outlierCutSPD Cut to remove events with outliers 
+ * @param etaGap        Size of @f$\eta@f$ gap
+ * @param useCent       Whether to use centrality or impact parameter for MC 
+ * @param useMCVtx      Whether to use vertex info from MC header
+ * @param satVtx        Use satellite interactions 
  * @param addFlow       Afterburn what (MC only)
  * @param addFType      Afterburner parameterization
  * @param addFOrder     Afterburder order 
  *
  * @ingroup pwglf_forward_flow
  */
-void AddTaskForwardFlow(TString  type          = "234", 
-                        Bool_t   useEtaGap     = kFALSE,
-                        Bool_t   mc            = kFALSE,
-                       Double_t outlierCutFMD = 4.0, 
-                       Double_t outlierCutSPD = 0,
-                       Double_t etaGap        = 2.0,
-                       Bool_t   useCent       = kFALSE,
-                       Bool_t   satVtx        = kFALSE,
-                        TString  addFlow       = "",
-                        Int_t    addFType      = 0,
-                        Int_t    addFOrder     = 0)
+void AddTaskForwardFlowQC(Int_t    maxMom        = 5,
+                          TString  fwdDet        = "FMD",
+                          Bool_t   useEtaGap     = kFALSE,
+                          Bool_t   use3cor       = kFALSE,
+                          Bool_t   mc            = kFALSE,
+                         Double_t outlierCutFMD = 4.0, 
+                         Double_t outlierCutSPD = 4.0,
+                         Double_t etaGap        = 2.0,
+                         Bool_t   useTPCForRef  = kFALSE,
+                         Bool_t   useCent       = kFALSE,
+                         Bool_t   useMCVtx      = kFALSE,
+                         Bool_t   satVtx        = kFALSE,
+                         TString  addFlow       = "",
+                         Int_t    addFType      = 0,
+                         Int_t    addFOrder     = 0)
 {
   // --- Get analysis manager ----------------------------------------
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
@@ -58,12 +63,27 @@ void AddTaskForwardFlow(TString  type          = "234",
     Fatal("","The relevant tasks weren't added to the train");
 
   // --- For the selected flow tasks the input and output is set -----
-  const char* name = (useEtaGap ? "ForwardQCumulantsEtaGap", "ForwardQCumulants");
+  fwdDet.ToUpper();
+  
+  // --- Set flow flags --------------------------------------------
+  if (useEtaGap && use3cor) 
+    Fatal("", "You're doing it wrong! Cannot do both eta-gap and 3-sub");
+  UShort_t flags = AliForwardFlowTaskQC::kStdQC|AliForwardFlowTaskQC::kSymEta;
+  if (useEtaGap)              flags = AliForwardFlowTaskQC::kEtaGap;
+  if (use3cor)                flags = AliForwardFlowTaskQC::k3Cor;
+  if (satVtx)                 flags |= AliForwardFlowTaskQC::kSatVtx;
+  if (fwdDet.Contains("FMD")) flags |= AliForwardFlowTaskQC::kNUAcorr;
+  if      (fwdDet.Contains("FMD"))   flags |= AliForwardFlowTaskQC::kFMD;
+  else if (fwdDet.Contains("VZERO")) flags |= AliForwardFlowTaskQC::kVZERO;
+  if (useTPCForRef) flags |= AliForwardFlowTaskQC::kTPC;
+
+  const char* name = Form("ForwardFlowQC%s%s", fwdDet.Data(), AliForwardFlowTaskQC::GetQCType(flags, false));
   AliForwardFlowTaskQC* task = 0;
   // --- Set up adding flow to MC input ----------------------------
   if (mc) {
     AliForwardMCFlowTaskQC* mcTask = new AliForwardMCFlowTaskQC(name);
     mcTask->SetUseImpactParameter(!useCent);
+    mcTask->SetUseMCHeaderVertex(useMCVtx);
     if (addFlow.Data()[0] != '\0') {
       mcTask->AddFlow(addFlow);
       mcTask->AddFlowType(addFType);
@@ -75,32 +95,17 @@ void AddTaskForwardFlow(TString  type          = "234",
   else 
     task = new AliForwardFlowTaskQC(name);
   
-  mgr->AddTask(task); 
-
-  // --- Set flow flags --------------------------------------------
-  UShort_t flags = AliForwardFlowTaskQC::kSymEta;
-  if (useEtaGap)           flags |= AliForwardFlowTaskQC::kEtaGap;
-  if (satVtx)              flags |= AliForwardFlowTaskQC::kSatVtx;
-  if (useEtaGap || satVtx) flags ^= AliForwardFlowTaskQC::kSymEta;
+  mgr->AddTask(task);
+//  mgr->SetSkipTerminate(true);
+//  task->SelectCollisionCandidates(AliVEvent::kCentral);
   task->SetFlowFlags(flags);
   
   // --- Set eta gap value -----------------------------------------
   task->SetEtaGapValue(etaGap);
 
   // --- Check which harmonics to calculate --------------------------
-  const char* harm = type.Data();
-  Int_t i = 0;
-  std::cout << "Type string: " << type.Data();
-  std::cout << "\t harm string: " << harm << std::endl;
-  while (i < type.Length()) {
-    char c = harm[i];
-    std::cout << "Adding moment: " << c << std::endl;
-    Short_t n = atoi(&c);
-    std::cout << "Adding moment: " << n << std::endl;
-    task->AddFlowMoment(n);
-    i++;
-  }
-
+  task->SetMaxFlowMoment(maxMom);
+  
   // --- Set non-default axis for vertices ---------------------------
   TAxis* a = 0;
   if (satVtx) {
@@ -108,14 +113,23 @@ void AddTaskForwardFlow(TString  type          = "234",
   }
   else 
     a = new TAxis(20, -10, 10);
+//    a = new TAxis(10, -5, 5);
   task->SetVertexAxis(a);
 
+  // --- Set non-default axis for centrality -------------------------
+  Double_t cent[] = {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100 };
+  //Double_t cent[] = {0, 2.5, 15, 25, 50, 100 };
+  //Double_t cent[] = {0, 100};
+  Int_t nBins = sizeof(cent)/sizeof(Double_t) -1;
+  TAxis* centAxis = new TAxis(nBins, cent);
+  task->SetCentralityAxis(centAxis);
+
   // --- Set sigma cuts for outliers ---------------------------------
   task->SetDetectorCuts(outlierCutFMD, outlierCutSPD);
 
   // --- Create containers for output --------------------------------
-  const char* sumName = (useEtaGap ? "FlowQCSumsEtaGap" : "FlowQCSums");
-  const char* resName = (useEtaGap ? "FlowQCResultsEtaGap" : "FlowQCResults");
+  const char* sumName = Form("FlowQCSums%s%s", fwdDet.Data(), AliForwardFlowTaskQC::GetQCType(flags, false));
+  const char* resName = Form("FlowQCResults%s%s", fwdDet.Data(), AliForwardFlowTaskQC::GetQCType(flags, false));
   AliAnalysisDataContainer* sums = 
     mgr->CreateContainer(sumName, TList::Class(), 
                         AliAnalysisManager::kOutputContainer, 
diff --git a/PWGLF/FORWARD/analysis2/AliAODForwardHeader.cxx b/PWGLF/FORWARD/analysis2/AliAODForwardHeader.cxx
new file mode 100644 (file)
index 0000000..8cca9fd
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// Class that contains header information for each event.  
+//
+// Used by standalone PWGLF/Forward AOD productions 
+//
+#include "AliAODForwardHeader.h"
+#include <TBrowser.h>
+#include <iostream>
+#include <TMath.h>
+#include <TObjString.h>
+#include <TObjArray.h>
+#include "AliLog.h"
+ClassImp(AliAODForwardHeader)
+#ifdef DOXY_INPUT
+; // For Emacs 
+#endif
+
+//____________________________________________________________________
+const Float_t AliAODForwardHeader::fgkInvalidIpZ = 1e6;
+
+//____________________________________________________________________
+void
+AliAODForwardHeader::Clear(Option_t* /*option*/)
+{
+  // Clear (or reset) internal values 
+  // 
+  // Parameters: 
+  //  option   Passed to TH1::Reset 
+  // 
+  fTriggers   = 0;
+  fIpZ        = fgkInvalidIpZ;
+  fCentrality = -1;
+  fNClusters  = 0;
+}
+//____________________________________________________________________
+Bool_t
+AliAODForwardHeader::HasIpZ() const
+{
+  // Check if we have valid z coordinate of the interaction point 
+  // 
+  // Return:
+  //   true if the z coordinate of the interaction point is valid 
+  // 
+  return TMath::Abs(fIpZ - fgkInvalidIpZ) > 1;
+}
+//____________________________________________________________________
+void
+AliAODForwardHeader::Browse(TBrowser* b)
+{
+  // Browse this object 
+  // 
+  // Parameters: 
+  //   b   Browser to use 
+  static TObjString ipz;
+  static TObjString trg;
+  static TObjString cnt;
+  static TObjString ncl;
+  ipz = Form("ip_z=%fcm", fIpZ);
+  trg = GetTriggerString(fTriggers);
+  cnt = Form("%+6.1f%%", fCentrality);
+  ncl = Form("%d clusters", fNClusters);
+  b->Add(&fHist);
+  b->Add(&ipz);
+  b->Add(&trg);
+  b->Add(&cnt);
+  b->Add(&ncl);
+}
+
+namespace { 
+  void AppendAnd(TString& trg, const TString& what)
+  {
+    if (!trg.IsNull()) trg.Append(" & ");
+    trg.Append(what);
+  }
+}
+//____________________________________________________________________
+const Char_t*
+AliAODForwardHeader::GetTriggerString(UInt_t mask)
+{
+  // Get a string that describes the triggers 
+  // 
+  // Parameters: 
+  //   mask  Bit pattern of triggers 
+  // Return: 
+  //   Character string representation of mask 
+  static TString trg;
+  trg = "";
+  if ((mask & kInel)        != 0x0) AppendAnd(trg, "INEL");
+  if ((mask & kInelGt0)     != 0x0) AppendAnd(trg, "INEL>0");
+  if ((mask & kNSD)         != 0x0) AppendAnd(trg, "NSD");
+  if ((mask & kV0AND)       != 0x0) AppendAnd(trg, "V0AND");
+  if ((mask & kA)           != 0x0) AppendAnd(trg, "A");
+  if ((mask & kB)           != 0x0) AppendAnd(trg, "B");
+  if ((mask & kC)           != 0x0) AppendAnd(trg, "C");
+  if ((mask & kE)           != 0x0) AppendAnd(trg, "E");
+  if ((mask & kMCNSD)       != 0x0) AppendAnd(trg, "MCNSD");
+  if ((mask & kNClusterGt0) != 0x0) AppendAnd(trg, "NCluster>0");
+  if ((mask & kSatellite)   != 0x0) AppendAnd(trg, "Satellite");
+  return trg.Data();
+}
+//____________________________________________________________________
+TH1I*
+AliAODForwardHeader::MakeTriggerHistogram(const char* name, Int_t mask) 
+{
+  // 
+  // Make a histogram to record triggers in. 
+  //
+  // The bins defined by the trigger enumeration in this class.  One
+  // can use this enumeration to retrieve the number of triggers for
+  // each class.
+  // 
+  // Parameters:
+  //    name Name of the histogram 
+  // 
+  // Return:
+  //    Newly allocated histogram 
+  //
+  TString sel("");
+  TString andSel("");
+  if (mask > 0) {
+    sel    = GetTriggerString(mask);
+    andSel = GetTriggerString(mask & ~kB);
+    andSel.Prepend(" & ");
+  }
+  TH1I* ret = new TH1I(name, "Triggers", kAccepted+1, -.5, kAccepted+.5);
+  ret->SetYTitle("Events");
+  ret->SetFillColor(kRed+1);
+  ret->SetFillStyle(3001);
+  ret->GetXaxis()->SetBinLabel(kBinAll,         "All events");
+  ret->GetXaxis()->SetBinLabel(kBinB,           Form("B (Coll.)%s", 
+                                                    andSel.Data()));
+  ret->GetXaxis()->SetBinLabel(kBinA,           Form("A%s", andSel.Data()));
+  ret->GetXaxis()->SetBinLabel(kBinC,           Form("C%s", andSel.Data()));
+  ret->GetXaxis()->SetBinLabel(kBinE,           Form("E%s", andSel.Data()));
+  ret->GetXaxis()->SetBinLabel(kBinInel,        "Coll. & INEL");
+  ret->GetXaxis()->SetBinLabel(kBinInelGt0,     "Coll. & INEL>0");
+  ret->GetXaxis()->SetBinLabel(kBinNSD,         "Coll. & NSD");
+  ret->GetXaxis()->SetBinLabel(kBinV0AND,       "Coll. & V0AND");
+  ret->GetXaxis()->SetBinLabel(kBinMCNSD,       "NSD (MC truth)");
+  ret->GetXaxis()->SetBinLabel(kBinSatellite,   "Satellite");
+  ret->GetXaxis()->SetBinLabel(kBinPileUp,      "w/Pileup");
+  ret->GetXaxis()->SetBinLabel(kBinOffline,     "w/Offline");
+  ret->GetXaxis()->SetBinLabel(kBinNClusterGt0, "w/N_{cluster}>1");
+  ret->GetXaxis()->SetBinLabel(kWithVertex,     "w/Vertex");
+  ret->GetXaxis()->SetBinLabel(kWithTrigger,    Form("w/Selected trigger (%s)",
+                                                    sel.Data()));
+  ret->GetXaxis()->SetBinLabel(kAccepted,       "Accepted by cut");
+  ret->GetXaxis()->SetNdivisions(kAccepted, false);
+  ret->SetStats(0);
+
+  return ret;
+}
+
+//____________________________________________________________________
+TH1I*
+AliAODForwardHeader::MakeStatusHistogram(const char* name) 
+{
+  // 
+  // Make a histogram to record status in. 
+  //
+  // The bins defined by the status enumeration in this class.  
+  // 
+  // Parameters:
+  //    name Name of the histogram 
+  // 
+  // Return:
+  //    Newly allocated histogram 
+  //
+  TH1I* ret = new TH1I(name, "Event selection status", 
+                      kWrongVertex+1, -.5, kWrongVertex+.5);
+  ret->SetYTitle("Events");
+  ret->SetFillColor(kBlue+1);
+  ret->SetFillStyle(3001);
+  ret->GetXaxis()->SetBinLabel(kGoodEvent+1,       "Good");
+  ret->GetXaxis()->SetBinLabel(kWrongCentrality+1, "Out-of-range centrality");
+  ret->GetXaxis()->SetBinLabel(kWrongTrigger+1,    "Wrong trigger");
+  ret->GetXaxis()->SetBinLabel(kIsPileup+1,        "Pile-up");
+  ret->GetXaxis()->SetBinLabel(kNoVertex+1,        "No IP_{z}");
+  ret->GetXaxis()->SetBinLabel(kWrongVertex+1,     "Out-or-range IP_{z}");
+  ret->GetXaxis()->SetNdivisions(kWrongVertex, false);
+  ret->SetStats(0);
+  return ret;
+}
+//____________________________________________________________________
+UInt_t 
+AliAODForwardHeader::MakeTriggerMask(const char* what)
+{
+  UShort_t    trgMask = 0;
+  TString     trgs(what);
+  trgs.ToUpper();
+  TObjArray*  parts = trgs.Tokenize("&");
+  TObjString* trg;
+  TIter       next(parts);
+  while ((trg = static_cast<TObjString*>(next()))) { 
+    TString s(trg->GetString());
+    s.Strip(TString::kBoth, ' ');
+    s.ToUpper();
+    if      (s.IsNull()) continue;
+    if      (s.CompareTo("INEL")       == 0) trgMask |= kInel;
+    else if (s.CompareTo("INEL>0")     == 0) trgMask |= kInelGt0;
+    else if (s.CompareTo("INELGT0")    == 0) trgMask |= kInelGt0;
+    else if (s.CompareTo("NSD")        == 0) trgMask |= kNSD;
+    else if (s.CompareTo("V0AND")      == 0) trgMask |= kV0AND;
+    else if (s.CompareTo("MCNSD")      == 0) trgMask |= kMCNSD;
+    else if (s.CompareTo("B")          == 0) trgMask |= kB;
+    else if (s.CompareTo("A")          == 0) trgMask |= kA;
+    else if (s.CompareTo("C")          == 0) trgMask |= kC;
+    else if (s.CompareTo("SAT")        == 0) trgMask |= kSatellite;
+    else if (s.CompareTo("E")          == 0) trgMask |= kE;
+    else if (s.CompareTo("NCLUSTER>0") == 0) trgMask |= kNClusterGt0;
+    else 
+      AliWarningGeneral("MakeTriggerMask", 
+                       Form("Unknown trigger %s", s.Data()));
+  }
+  delete parts;
+  return trgMask;
+}
+//____________________________________________________________________
+Bool_t
+AliAODForwardHeader::CheckEvent(Int_t    triggerMask,
+                             Double_t vzMin, Double_t vzMax,
+                             UShort_t cMin,  UShort_t cMax, 
+                             TH1*     hist,  TH1*     status) const
+{
+  // 
+  // Check if event meets the passses requirements.   
+  //
+  // It returns true if @e all of the following is true 
+  //
+  // - The trigger is within the bit mask passed.
+  // - The vertex is within the specified limits. 
+  // - The centrality is within the specified limits, or if lower
+  //   limit is equal to or larger than the upper limit.
+  // 
+  // If a histogram is passed in the last parameter, then that
+  // histogram is filled with the trigger bits. 
+  // 
+  // Parameters:
+  //    triggerMask  Trigger mask
+  //    vzMin        Minimum @f$ v_z@f$ (in centimeters)
+  //    vzMax        Maximum @f$ v_z@f$ (in centimeters) 
+  //    cMin         Minimum centrality (in percent)
+  //    cMax         Maximum centrality (in percent)
+  //    hist         Histogram to fill 
+  // 
+  // Return:
+  //    @c true if the event meets the requirements 
+  //
+  if (cMin < cMax && (cMin > fCentrality || cMax <= fCentrality)) {
+    if (status) status->Fill(kWrongCentrality);
+    return false;
+  }
+
+  if (hist) { 
+    Int_t tmp = triggerMask & ~kB;
+    hist->AddBinContent(kBinAll);
+    if (IsTriggerBits(kB|tmp))          hist->AddBinContent(kBinB);
+    if (IsTriggerBits(kA|tmp))          hist->AddBinContent(kBinA);
+    if (IsTriggerBits(kC|tmp))          hist->AddBinContent(kBinC);
+    if (IsTriggerBits(kE|tmp))          hist->AddBinContent(kBinE);
+    if (IsTriggerBits(kB|kInel))        hist->AddBinContent(kBinInel);
+    if (IsTriggerBits(kB|kInelGt0))     hist->AddBinContent(kBinInelGt0);
+    if (IsTriggerBits(kB|kNSD))         hist->AddBinContent(kBinNSD);
+    if (IsTriggerBits(kB|kV0AND))       hist->AddBinContent(kBinV0AND);
+    if (IsTriggerBits(kPileUp))         hist->AddBinContent(kBinPileUp);
+    if (IsTriggerBits(kMCNSD))          hist->AddBinContent(kBinMCNSD);
+    if (IsTriggerBits(kOffline))        hist->AddBinContent(kBinOffline);
+    if (IsTriggerBits(kNClusterGt0))    hist->AddBinContent(kBinNClusterGt0);
+    if (IsTriggerBits(kSatellite))      hist->AddBinContent(kBinSatellite);
+    if (IsTriggerBits(triggerMask) && !IsTriggerBits(kB|tmp))
+      Warning("CheckEvent", "event: 0x%x, mask: 0x%x, tmp: 0x%x, tmp|b: 0x%x",
+            fTriggers, triggerMask, tmp, tmp|kB);
+  }
+  // Check if we have an event of interest. 
+  Int_t mask = triggerMask; //|kB
+  if (!IsTriggerBits(mask)) { 
+    if (status) status->Fill(kWrongTrigger);
+    return false;
+  }
+  
+  // Check for pileup
+  if (IsTriggerBits(kPileUp)) {
+    if (status) status->Fill(kIsPileup);
+    return false;
+  }
+  if (hist) hist->AddBinContent(kWithTrigger);
+  
+  // Check that we have a valid vertex
+  if (vzMin < vzMax && !HasIpZ()) {
+    if (status) status->Fill(kNoVertex);
+    return false;
+  }
+  if (hist) hist->AddBinContent(kWithVertex);
+
+  // Check that vertex is within cuts 
+  if (vzMin < vzMax && !InRange(vzMin, vzMax)) {
+    if (status) status->Fill(kWrongVertex);
+    return false;
+  }
+  if (hist) hist->AddBinContent(kAccepted);
+  
+  if (status) status->Fill(kGoodEvent);
+  return true;
+}
+
+//____________________________________________________________________
+void
+AliAODForwardHeader::Print(Option_t* option) const
+{
+  // Print this object 
+  // 
+  // Parameters: 
+  //  option   Passed to TH1::Print 
+  std::cout << "Ipz:         " << fIpZ << "cm " << (HasIpZ() ? "" : "in") 
+           << "valid\n"
+           << "Triggers:    " << GetTriggerString(fTriggers)  << "\n"
+           << "Centrality:  " << fCentrality << "%" 
+           << std::endl;
+}
+
+//____________________________________________________________________
+//
+// EOF
+//
diff --git a/PWGLF/FORWARD/analysis2/AliAODForwardHeader.h b/PWGLF/FORWARD/analysis2/AliAODForwardHeader.h
new file mode 100644 (file)
index 0000000..0e3f62a
--- /dev/null
@@ -0,0 +1,383 @@
+//
+// See implementation or Doxygen comments for more information
+//
+#ifndef ALIAODFORWARDHEADER_H
+#define ALIAODFORWARDHEADER_H
+/**
+ * @file   AliAODForwardHeader.h
+ * @author Christian Holm Christensen <cholm@nbi.dk>
+ * @date   Mon Dec  2 09:31:05 2013
+ * 
+ * @brief  Header for forward data in stand-alone AOD
+ * 
+ * @ingroup pwglf_forward_aod 
+ */
+#include <TObject.h>
+class TBrowser;
+
+class AliAODForwardHeader : public TObject
+{
+public:
+  /** 
+   * Bits of the trigger pattern
+   */
+  enum { 
+    /** In-elastic collision */
+    kInel        = 0x0001, 
+    /** In-elastic collision with at least one SPD tracklet */
+    kInelGt0     = 0x0002, 
+    /** Non-single diffractive collision */
+    kNSD         = 0x0004, 
+    /** Empty bunch crossing */
+    kEmpty       = 0x0008, 
+    /** A-side trigger */
+    kA           = 0x0010, 
+    /** B(arrel) trigger */
+    kB           = 0x0020, 
+    /** C-side trigger */
+    kC           = 0x0080,  
+    /** Empty trigger */
+    kE           = 0x0100,
+    /** pileup from SPD */
+    kPileUp      = 0x0200,    
+    /** true NSD from MC */
+    kMCNSD       = 0x0400,    
+    /** Offline MB triggered */
+    kOffline     = 0x0800,
+    /** At least one SPD cluster */ 
+    kNClusterGt0 = 0x1000,
+    /** V0-AND trigger */
+    kV0AND       = 0x2000, 
+    /** Satellite event */
+    kSatellite   = 0x4000
+  };
+  /** 
+   * Bin numbers in trigger histograms 
+   */
+  enum { 
+    kBinAll=1,
+    kBinInel, 
+    kBinInelGt0, 
+    kBinNSD, 
+    kBinV0AND,
+    kBinA, 
+    kBinB, 
+    kBinC, 
+    kBinE,
+    kBinSatellite,
+    kBinPileUp, 
+    kBinMCNSD,
+    kBinOffline,
+    kBinNClusterGt0,
+    kWithTrigger, 
+    kWithVertex, 
+    kAccepted
+  };
+  /**
+   * Return codes of CheckEvent 
+   */
+  enum ECheckStatus {
+    /** Event accepted by cuts */
+    kGoodEvent = 0, 
+    /** Event centrality not in range */
+    kWrongCentrality, 
+    /** Event trigger isn't in the supplied mask */
+    kWrongTrigger, 
+    /** Event is a pile-up event */
+    kIsPileup, 
+    /** Event has no interaction point information */
+    kNoVertex, 
+    /** Event interaction point is out of range */
+    kWrongVertex
+  };
+  /** 
+   * Constructor
+   */
+  AliForwardHeader() 
+    : fTriggers(0), fIpZ(fgkInvalidIpZ), fCentrality(-1), fNClusters(0)
+  {}
+
+  /** 
+   * @{ 
+   * @name Setters of data 
+   */
+  /** 
+   * Clear all data 
+   * 
+   * @param option  Not used
+   */
+  void Clear(Option_t* option="");
+  /** 
+   * Set the trigger mask 
+   * 
+   * @param trg Trigger mask
+   */
+  void SetTriggerMask(UInt_t trg) { fTriggers = trg; } // Set triggers 
+  /** 
+   * Set bit(s) in trigger mask 
+   * 
+   * @param bits bit(s) to set 
+   */
+  void SetTriggerBits(UInt_t bits) { fTriggers |= bits; } // Set trigger bits
+  /** 
+   * Set the z coordinate of the interaction point
+   * 
+   * @param ipZ Interaction point z coordinate
+   */
+  void SetIpZ(Float_t ipZ) { fIpZ = ipZ; } // Set Ip's Z coordinate
+  /** 
+   * Set the event centrality 
+   * 
+   * @param c Centrality 
+   */
+  void SetCentrality(Float_t c) { fCentrality = c; }
+  /** 
+   * Set the number of SPD clusters seen in @f$ |\eta|<1@f$ 
+   * 
+   * @param n Number of SPD clusters 
+   */
+  void SetNClusters(UShort_t n) { fNClusters = n; }
+  /* @} */
+
+  
+  /** 
+   * @{ 
+   * @name Tests 
+   */
+  /** 
+   * Check if all bit(s) are set in the trigger mask.  Note, this is
+   * an @e and between the bits.  If you need an @e or you should use
+   * the member function IsTriggerOrBits
+   * 
+   * @param bits Bits to test for 
+   * 
+   * @return true if all enabled bits in the argument is also set in
+   * the trigger word
+   */
+  Bool_t IsTriggerBits(UInt_t bits) const;
+  /** 
+   * Check if any of bit(s) are enabled in the trigger word.  This is
+   * an @e or between the selected bits.  If you need and @a and you
+   * should use the member function IsTriggerBits;
+   * 
+   * @param bits Bits to check for 
+   * 
+   * @return true if any of the enabled bits in the arguments are also
+   * enabled in the trigger mask
+   */
+  Bool_t IsTriggerOrBits(UInt_t bits) const;
+  /** 
+   * Whether we have any trigger bits 
+   *
+   * @return true if we have some trigger 
+   */
+  Bool_t HasTrigger() const { return fTriggers != 0; } // Check for triggers
+  /** 
+   * Check if we have a valid z coordinate of the interaction point
+   *
+   * @return True if we have a valid interaction point z coordinate
+   */
+  Bool_t HasIpZ() const;
+  /** 
+   * Check if the z coordinate of the interaction point is within the
+   * given limits.  Note that the convention used corresponds to the
+   * convention used in ROOTs TAxis.
+   * 
+   * @param low  Lower cut (inclusive)
+   * @param high Upper cut (exclusive)
+   * 
+   * @return true if @f$ low \ge ipz < high@f$ 
+   */
+  Bool_t InRange(Float_t low, Float_t high) const;
+  /** 
+   * Check if we have a valid centrality 
+   * 
+   * @return True if the centrality is set 
+   */
+  Bool_t  HasCentrality() const { return !(fCentrality  < 0); }
+  /** 
+   * Check if event meets the passses requirements.   
+   *
+   * It returns true if @e all of the following is true 
+   *
+   * - The trigger is within the bit mask passed.
+   * - The vertex is within the specified limits. 
+   * - The centrality is within the specified limits, or if lower
+   *   limit is equal to or larger than the upper limit.
+   * 
+   * Note, for data with out a centrality estimate (e.g., pp), one
+   * must pass equal centrality cuts, or no data will be accepted.  In
+   * other words, for pp data, always pass cMin=0, cMax=0
+   *
+   * If a histogram is passed in the last parameter, then that
+   * histogram is filled with the trigger bits. 
+   * 
+   * @param triggerMask  Trigger mask
+   * @param vzMin        Minimum @f$ v_z@f$ (in centimeters)
+   * @param vzMax        Maximum @f$ v_z@f$ (in centimeters) 
+   * @param cMin         Minimum centrality (in percent)
+   * @param cMax         Maximum centrality (in percent)
+   * @param hist         Histogram to fill 
+   * @param status       Histogram to fill 
+   * 
+   * 
+   * @return @c true if the event meets the requirements 
+   */
+  Bool_t CheckEvent(Int_t    triggerMask=kInel,
+                   Double_t vzMin=-10, Double_t vzMax=10,
+                   UShort_t cMin=0,    UShort_t cMax=100, 
+                   TH1*     hist=0,
+                   TH1*     status=0) const;
+  /* @} */
+
+  /** 
+   * @{ 
+   * @name Getters of data 
+   */
+  /** 
+   * Get the trigger bits 
+   * 
+   * @return Trigger bits 
+   */
+  UInt_t GetTriggerBits() const { return fTriggers; } // Get triggers
+  /** 
+   * Set the z coordinate of the interaction point
+   * 
+   * @return Interaction point z coordinate
+   */
+  Float_t GetIpZ() const { return fIpZ; } // Get Ip's Z coordinate 
+  /** 
+   * Get the event centrality 
+   * 
+   * @return The event centrality or -1 if not set
+   */
+  Float_t GetCentrality() const { return fCentrality; }
+  /** 
+   * Get the number of SPD clusters seen in @f$ |\eta|<1@f$ 
+   * 
+   * @return Number of SPD clusters seen
+   */
+  UShort_t GetNClusters() const { return fNClusters; }
+  /* @} */
+
+  /** 
+   * @{ 
+   * @name Standard TObject member functions 
+   */
+  /** 
+   * Print content 
+   * 
+   * @param option Passed verbatim to TH2::Print 
+   */
+  void Print(Option_t* option="") const;
+  /** 
+   * Get the name of the object 
+   * 
+   * @return Name of object 
+   */
+  const Char_t* GetName() const { return "ForwardHeader"; }
+  /** 
+   * browse this object 
+   * 
+   * @param b Browser 
+   */
+  void Browse(TBrowser* b);
+  /** 
+   * This is a folder 
+   * 
+   * @return Always true
+   */
+  Bool_t IsFolder() const { return kTRUE; } // Always true 
+  /* @} */
+  /** 
+   * @{
+   * @name Utility class functions 
+   */
+  /** 
+   * Get a string correspondig to the trigger mask
+   * 
+   * @param mask Trigger mask 
+   * 
+   * @return Static string (copy before use)
+   */
+  static const Char_t* GetTriggerString(UInt_t mask);
+  /** 
+   * Make a histogram to record triggers in. 
+   *
+   * The bins defined by the trigger enumeration in this class.  One
+   * can use this enumeration to retrieve the number of triggers for
+   * each class.
+   * 
+   * @param name Name of the histogram 
+   * @param mask Trigger mask 
+   * 
+   * @return Newly allocated histogram 
+   */
+  static TH1I* MakeTriggerHistogram(const char* name="triggers",
+                                   Int_t mask=0);
+  /** 
+   * Make a histogram to record status in. 
+   *
+   * The bins defined by the status enumeration in this class.  
+   * 
+   * @param name Name of the histogram 
+   * 
+   * @return Newly allocated histogram 
+   */
+  static TH1I* MakeStatusHistogram(const char* name="status");
+  /** 
+   * Utility function to make a trigger mask from the passed string. 
+   * 
+   * The string is a comma or space seperated list of case-insensitive
+   * strings
+   * 
+   * - INEL 
+   * - INEL>0
+   * - NSD 
+   * 
+   * @param what Which triggers to put in the mask. 
+   * 
+   * @return The generated trigger mask. 
+   */
+  static UInt_t MakeTriggerMask(const char* what);
+  /* @} */
+protected: 
+  /** Trigger bits */
+  UInt_t   fTriggers;   // Trigger bit mask 
+  /** Interaction point @f$z@f$ coordinate */
+  Float_t  fIpZ;        // Z coordinate of the interaction point
+  /** Centrality */
+  Float_t  fCentrality; // Event centrality 
+  /** Number of clusters in @f$|\eta|<1@f$ */
+  UShort_t fNClusters;  // Number of SPD clusters in |eta|<1
+  /** Invalid value for interaction point @f$z@f$ coordiante */
+  static const Float_t fgkInvalidIpZ; // Invalid IpZ value 
+  ClassDef(AliAODForwardHeader,1); // AOD forward header 
+};
+
+//____________________________________________________________________
+inline Bool_t
+AliAODForwardHeader::InRange(Float_t low, Float_t high) const 
+{
+  return HasIpZ() && fIpZ >= low && fIpZ < high;
+}
+
+//____________________________________________________________________
+inline Bool_t 
+AliAODForwardHeader::IsTriggerBits(UInt_t bits) const 
+{ 
+  return HasTrigger() && ((fTriggers & bits) == bits); 
+}
+//____________________________________________________________________
+inline Bool_t 
+AliAODForwardHeader::IsTriggerOrBits(UInt_t bits) const 
+{ 
+  return HasTrigger() && ((fTriggers & bits) != 0);
+}
+
+
+#endif
+// Local Variables:
+//  mode: C++
+// End:
+
index 50a2ec851df6f7cb98f54245cc0816be503d268e..4ac86ad3beeb619b72a3754c7d91cde83b22cff1 100644 (file)
@@ -8,7 +8,7 @@
  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
  * @date   Wed Mar 23 13:58:00 2011
  * 
- * @brief  
+ * @brief  Per-event @f$ N_{ch}@f$ per @f$(\eta,\varphi)@f$ bin 
  * 
  * @ingroup pwglf_forward_aod
  * 
index 8445df887ab13a9308ad0f1003528bdc6c746c3e..976927d1b50af67f8089d819e99351a49d65f767 100644 (file)
@@ -306,7 +306,8 @@ AliBaseAODTask::CheckEvent(const AliAODForwardMult& forward)
 {
   if (HasCentrality())
     return forward.CheckEvent(fTriggerMask, fMinIpZ, fMaxIpZ, 
-                             fCentAxis.GetXmin(), fCentAxis.GetXmax(), 
+                             UShort_t(fCentAxis.GetXmin()), 
+                             UShort_t(fCentAxis.GetXmax()), 
                              fTriggers, fEventStatus);
  return forward.CheckEvent(fTriggerMask, fMinIpZ, fMaxIpZ, 
                           0, 0, fTriggers, fEventStatus);
index edd88e63e49e75ad45493e4b72159a2d9281c72f..bc96a5addf2fe7cb523014c09120e922c6b7948f 100644 (file)
@@ -38,8 +38,8 @@ AliBaseESDTask::AliBaseESDTask(const char* name, const char* title,
 {
   SetTitle(title && title[0] != '\0' ? title : this->ClassName());
   fCorrManager = manager;
-  if (!manager) 
-    AliFatal("Must pass in a valid correction manager object!");
+  // if (!manager) 
+  //   AliFatal("Must pass in a valid correction manager object!");
   fBranchNames = 
     "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
     "AliESDFMD.,SPDVertex.,PrimaryVertex.";
@@ -95,6 +95,20 @@ AliBaseESDTask::Connect(const char* sumFile,
   return true;
 }
 
+//____________________________________________________________________
+TAxis*
+AliBaseESDTask::DefaultEtaAxis() const
+{
+  static TAxis* a = new TAxis(200, -4, 6);
+  return a;
+}
+//____________________________________________________________________
+TAxis*
+AliBaseESDTask::DefaultVertexAxis() const
+{
+  static TAxis* a = AliForwardUtil::MakeFullIpZAxis(20);
+  return a;
+}
 //____________________________________________________________________
 void
 AliBaseESDTask::SetDebug(Int_t dbg)
@@ -177,6 +191,9 @@ AliBaseESDTask::UserExec(Option_t*)
   // Call pre-event setup 
   PreEvent();
 
+  // Read in selected branches 
+  LoadBranches();
+
   // Get the input data 
   AliESDEvent* esd = GetESDEvent();
   if (!esd) return;
@@ -251,8 +268,15 @@ AliBaseESDTask::CheckCorrections(UInt_t what) const
   //    true if all present, false otherwise
   //  
   DGUARD(fDebug,1,"Checking corrections 0x%x", what);
+  if (what == 0) return true;
 
   AliCorrectionManagerBase* cm = GetManager();
+  if (!cm) {
+    AliErrorF("Check corrections=0x%x not null, "
+             "but no correction manager defined!", 
+             what);
+    return false;
+  }
   Bool_t ret = cm->CheckCorrections(what);
   return ret;
 }
@@ -268,8 +292,22 @@ AliBaseESDTask::ReadCorrections(const TAxis*& pe,
   //
   //
   UInt_t what = fNeededCorrections|fExtraCorrections;
+  
   DGUARD(fDebug,1,"Read corrections 0x%x", what);
+
   AliCorrectionManagerBase* cm = GetManager();
+  if (!cm && fNeededCorrections) {
+    AliErrorF("Needed/extra corrections=0x%x/0x%x not null, "
+             "but no correction manager defined!", 
+             fNeededCorrections, fExtraCorrections);
+    return false;
+  }
+  if (!cm || !what) {
+    // In case we have no needed corrections, we can return here 
+    if (!pe) pe = DefaultEtaAxis();
+    if (!pv) pv = DefaultVertexAxis();
+    return true;
+  }
   cm->EnableCorrections(what);
   if (!cm->InitCorrections(GetEventInspector().GetRunNumber(),
                           GetEventInspector().GetCollisionSystem(),
@@ -290,13 +328,11 @@ AliBaseESDTask::ReadCorrections(const TAxis*& pe,
   if (!pe) {
     pe = cm->GetEtaAxis();
     if (!pe) pe = DefaultEtaAxis();
-    if (!pe) AliFatal("No eta axis defined");
   }
   // Get the vertex axis from the secondary maps - if read in
   if (!pv) {
     pv = cm->GetVertexAxis();
     if (!pv) pv = DefaultVertexAxis();
-    if (!pv) AliFatal("No vertex axis defined");
   }
 
   return true;
@@ -353,6 +389,9 @@ AliBaseESDTask::GetESDEvent()
     SetZombie(true);
     return 0;
   }
+  Printf("Vertex axis: %p   Eta axis: %p", pv, pe);
+  if (!pv) AliFatal("No vertex axis defined");
+  if (!pe) AliFatal("No eta axis defined");
 
   // Initialize the event inspector 
   GetEventInspector().SetupForData(*pv);
@@ -407,9 +446,12 @@ AliBaseESDTask::Print(Option_t* option) const
   AliForwardUtil::PrintTask(*this);
   gROOT->IncreaseDirLevel();
   PF("Off-line trigger mask", "0x%0x", fOfflineTriggerMask);
-  if (fCorrManager) fCorrManager->Print(option);
-  else  PF("Correction manager not set yet","");
+  if (GetManager()) GetManager()->Print(option);
+  else  PF("No correction manager","");
 
   GetEventInspector().Print(option);
   gROOT->DecreaseDirLevel();
 }
+//
+// EOF
+//
index 16a0070288ccd4f1fca7b8b4abf211febc987915..96d34501bb68d0d3e3cf932a2ad4e5d508a75e55 100644 (file)
@@ -241,7 +241,7 @@ protected:
    * 
    * @return null
    */
-  virtual TAxis* DefaultEtaAxis() const { return 0; }
+  virtual TAxis* DefaultEtaAxis() const;
   /** 
    * Set the default eta axis to use in case we didn't get one from
    * the read-in corretions.  Override this if the sub class should go
@@ -250,7 +250,7 @@ protected:
    * 
    * @return null
    */
-  virtual TAxis* DefaultVertexAxis() const = 0;
+  virtual TAxis* DefaultVertexAxis() const;
   /** 
    * Get the correction mananger.  Derived class should overload this
    * to return the proper object.
index 736d91e5f0762c7319a64ebb50d6ccf4c468eb38..fa2337e378d69bcaf3c6601a743c6189f5a83664 100644 (file)
@@ -1592,7 +1592,7 @@ AliBasedNdetaTask::CentralityBin::Normalization(const TH1I& t,
        rhs.Append("/eps_V");
     } // Event-level
     if (scheme & kTriggerEfficiency) {
-      Int_t old =  ntotal;
+      Int_t old =  Int_t(ntotal);
       ntotal    /= trigEff;
       scaler    *= trigEff;
       DMSG(fDebug,0,"Correcting for trigger efficiency:\n"
index 90eea4bccc56eb60bacb3d0cad3b1d664067751e..0057783feeecad3a9ecfa8502598d9982bb1caf1 100644 (file)
@@ -136,12 +136,17 @@ AliCentralMultiplicityTask::PreData(const TAxis& vertex, const TAxis& eta)
   }
   fList->Add(hCoverage);
 
+  // Bins are 
+  TArrayD bins;
+  // N-bins, loweset order, higest order, return array
+  AliForwardUtil::MakeLogScale(300, 0, 5, bins);
   fNClusterTracklet = new TH2D("nClusterVsnTracklet", 
                               "Total number of cluster vs number of tracklets",
-                              100, 0, 10000, 100, 0, 10000);
+                              bins.GetSize()-1, bins.GetArray(),
+                              bins.GetSize()-1, bins.GetArray());
   fNClusterTracklet->SetDirectory(0);
-  fNClusterTracklet->SetXTitle("# of free clusters");
-  fNClusterTracklet->SetYTitle("# of tracklets");
+  fNClusterTracklet->SetXTitle("N_{free cluster}");
+  fNClusterTracklet->SetYTitle("N_{tracklet}");
   fNClusterTracklet->SetStats(0);
   fList->Add(fNClusterTracklet);
 
index d5b6328acb677d9446f215871926f800be30d91c..240c794901daedef6c809527597b9ce0c5318b92 100644 (file)
@@ -28,7 +28,7 @@ public:
   AliCopyHeaderTask(const char* name="header") 
     : AliAnalysisTaskSE(name)
   {
-    fBranchNames = "ESD:AliESDHeader.;AliESDRun.";
+    fBranchNames = "ESD:AliESDHeader.,AliESDRun.";
   }
   /** 
    * Copy constructor 
index e1abbd9311b233fd21f8dc3ddaece8bf5cfb9cf1..5c09bdd6c3f7d08a0fc226186deea4e21c70cc5f 100644 (file)
@@ -639,7 +639,7 @@ AliFMDCorrELossFit::ELossFit::CalculateQuality(Double_t maxChi2nu,
     Double_t red = fChi2 / fNu;
     if (red < maxChi2nu) qual += 4;
     else {
-      Int_t q = (maxChi2nu+decline - red) / decline * 4;
+      Int_t q = Int_t((maxChi2nu+decline - red) / decline * 4);
       if (q > 0) qual += q;
     }
   }
index 7eb52f8c94d47f958c5ef20c08942c5407372c74..e38faa40c6bc9a7b8150c61218bd5ef9cf3db913 100644 (file)
@@ -10,6 +10,7 @@
 #include "AliFMDCorrDoubleHit.h"
 #include "AliFMDCorrELossFit.h"
 #include "AliLog.h"
+#include "AliForwardUtil.h"
 #include <TH2D.h>
 #include <TProfile.h>
 #include <THStack.h>
@@ -57,7 +58,9 @@ AliFMDDensityCalculator::AliFMDDensityCalculator()
     fMinQuality(10),
     fCache(),
     fDoTiming(false),
-    fHTiming(0)
+  fHTiming(0), 
+  fMaxOutliers(0.05),
+  fOutlierCut(0.50)
 {
   // 
   // Constructor 
@@ -93,7 +96,9 @@ AliFMDDensityCalculator::AliFMDDensityCalculator(const char* title)
     fMinQuality(10),
     fCache(),
     fDoTiming(false),
-    fHTiming(0)
+    fHTiming(0), 
+  fMaxOutliers(0.05),
+  fOutlierCut(0.50)
 {
   // 
   // Constructor 
@@ -165,7 +170,9 @@ AliFMDDensityCalculator::AliFMDDensityCalculator(const
     fMinQuality(o.fMinQuality),
     fCache(o.fCache),
     fDoTiming(o.fDoTiming),
-    fHTiming(o.fHTiming)
+    fHTiming(o.fHTiming), 
+  fMaxOutliers(o.fMaxOutliers),
+  fOutlierCut(o.fOutlierCut)
 {
   // 
   // Copy constructor 
@@ -228,6 +235,8 @@ AliFMDDensityCalculator::operator=(const AliFMDDensityCalculator& o)
   fCache              = o.fCache;
   fDoTiming           = o.fDoTiming;
   fHTiming            = o.fHTiming;
+  fMaxOutliers        = o.fMaxOutliers;
+  fOutlierCut         = o.fOutlierCut;
 
   fRingHistos.Delete();
   TIter    next(&o.fRingHistos);
@@ -536,6 +545,8 @@ AliFMDDensityCalculator::Calculate(const AliESDFMD&        fmd,
       // --- Make diagnostics - eloss vs poisson ---------------------
       if (fDoTiming) timer.Start(true);
       Int_t nY = h->GetNbinsY();
+      Int_t nIn  = 0; // Count non-outliers
+      Int_t nOut = 0; // Count outliers
       for (Int_t ieta=1; ieta <= h->GetNbinsX(); ieta++) { 
        // Set the overflow bin to contain the phi acceptance 
        Double_t phiAcc  = rh->fGood->GetBinContent(ieta);
@@ -557,12 +568,29 @@ AliFMDDensityCalculator::Calculate(const AliESDFMD&        fmd,
            eLossV  = h->GetBinContent(ieta,iphi);
          }
          
-         rh->fELossVsPoisson->Fill(eLossV, poissonV);
-         rh->fDiffELossPoisson->Fill(poissonV < 1e-12 ? 0 : 
-                                     (eLossV - poissonV) / poissonV);
+         if (poissonV < 1e-12 && eLossV < 1e-12) 
+           // we do not care about trivially empty bins 
+           continue;
                                      
+         Bool_t   outlier = CheckOutlier(eLossV, poissonV, fOutlierCut);
+         Double_t rel     = eLossV < 1e-12 ? 0 : (poissonV - eLossV) / eLossV;
+         if (outlier) {
+           rh->fELossVsPoissonOut->Fill(eLossV, poissonV);
+           rh->fDiffELossPoissonOut->Fill(rel);
+           nOut++;
        }
-      }
+         else {
+           rh->fELossVsPoisson->Fill(eLossV, poissonV);
+           rh->fDiffELossPoisson->Fill(rel);
+           nIn++;
+         } // if (outlier)
+       } // for (iphi)
+      } // for (ieta)
+      Int_t    nTotal   = (nIn+nOut);
+      Double_t outRatio = (nTotal > 0 ? Double_t(nOut) / nTotal : 0);
+      rh->fOutliers->Fill(outRatio);
+      if (outRatio < fMaxOutliers) rh->fPoisson.FillDiagnostics();
+      else                         h->SetBit(AliForwardUtil::kSkipRing);
       if (fDoTiming) diagTime += timer.CpuTime();
       // delete hclone;
       
@@ -583,6 +611,16 @@ AliFMDDensityCalculator::Calculate(const AliESDFMD&        fmd,
   return kTRUE;
 }
 
+//_____________________________________________________________________
+Bool_t 
+AliFMDDensityCalculator::CheckOutlier(Double_t eloss, 
+                                     Double_t poisson,
+                                     Double_t cut) const
+{
+  if (eloss < 1e-6) return true;
+  Double_t diff = TMath::Abs(poisson - eloss) / eloss;
+  return diff > cut;
+}
 //_____________________________________________________________________
 Int_t
 AliFMDDensityCalculator::FindMaxWeight(const AliFMDCorrELossFit* cor,
@@ -1002,28 +1040,19 @@ AliFMDDensityCalculator::CreateOutputObjects(TList* dir)
   d->Add(fMaxWeights);
   d->Add(fLowCuts);
 
-  // TNamed* sigma  = new TNamed("sigma",
-  // (fIncludeSigma ? "included" : "excluded"));
-  TObject* maxP   = AliForwardUtil::MakeParameter("maxParticle", fMaxParticles);
-  TObject* method = AliForwardUtil::MakeParameter("method", fUsePoisson);
-  TObject* phiA   = AliForwardUtil::MakeParameter("phiAcceptance", 
-                                                 fUsePhiAcceptance);
-  TObject* etaL   = AliForwardUtil::MakeParameter("etaLumping", fEtaLumping);
-  TObject* phiL   = AliForwardUtil::MakeParameter("phiLumping", fPhiLumping);
-  TObject* reEt   = AliForwardUtil::MakeParameter("recalcEta", fRecalculateEta);
-  TObject* rePh   = AliForwardUtil::MakeParameter("recalcPhi", fRecalculatePhi);
-
   TParameter<int>* nFiles = new TParameter<int>("nFiles", 1);
   nFiles->SetMergeMode('+');
   
   // d->Add(sigma);
-  d->Add(maxP);
-  d->Add(method);
-  d->Add(phiA);
-  d->Add(etaL);
-  d->Add(phiL);
-  d->Add(reEt);
-  d->Add(rePh);
+  d->Add(AliForwardUtil::MakeParameter("maxParticle",  fMaxParticles));
+  d->Add(AliForwardUtil::MakeParameter("method",       fUsePoisson));
+  d->Add(AliForwardUtil::MakeParameter("phiAcceptance",fUsePhiAcceptance));
+  d->Add(AliForwardUtil::MakeParameter("etaLumping",   fEtaLumping));
+  d->Add(AliForwardUtil::MakeParameter("phiLumping",   fPhiLumping));
+  d->Add(AliForwardUtil::MakeParameter("recalcEta",    fRecalculateEta));
+  d->Add(AliForwardUtil::MakeParameter("recalcPhi",    fRecalculatePhi));
+  d->Add(AliForwardUtil::MakeParameter("maxOutliers",  fMaxOutliers));
+  d->Add(AliForwardUtil::MakeParameter("outlierCut",   fOutlierCut));
   d->Add(nFiles);
   // d->Add(nxi);
   fCuts.Output(d,"lCuts");
@@ -1147,6 +1176,9 @@ AliFMDDensityCalculator::RingHistos::RingHistos()
     fDensity(0),
     fELossVsPoisson(0),
     fDiffELossPoisson(0),
+    fELossVsPoissonOut(0),
+    fDiffELossPoissonOut(0),
+    fOutliers(0),
     fPoisson(),
     fELoss(0),
     fELossUsed(0),
@@ -1174,6 +1206,9 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
     fDensity(0),
     fELossVsPoisson(0),
     fDiffELossPoisson(0),
+    fELossVsPoissonOut(0),
+    fDiffELossPoissonOut(0),
+    fOutliers(0),
     fPoisson("ignored"),
     fELoss(0),
     fELossUsed(0),
@@ -1235,16 +1270,33 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
   fDensity->SetYTitle("#phi [radians]");
   fDensity->SetZTitle("Inclusive N_{ch} density");
 
+  // --- Create increasing sized bins --------------------------------
+  TArrayD bins;
+  // bins, lowest order, higest order, return array
+  const char* nchP = "N_{ch}^{Poisson}";
+  const char* nchE = "N_{ch}^{#Delta}";
+  AliForwardUtil::MakeLogScale(300, 0, 2, bins);
   fELossVsPoisson = new TH2D("elossVsPoisson", 
-                            "N_{ch} from energy loss vs from Poission",
-                            500, 0, 100, 500, 0, 100);
+                            "N_{ch} from energy loss vs from Poisson",
+                            bins.GetSize()-1, bins.GetArray(), 
+                            bins.GetSize()-1, bins.GetArray());
   fELossVsPoisson->SetDirectory(0);
-  fELossVsPoisson->SetXTitle("N_{ch} from #DeltaE");
-  fELossVsPoisson->SetYTitle("N_{ch} from Poisson");
+  fELossVsPoisson->SetXTitle(nchE);
+  fELossVsPoisson->SetYTitle(nchP);
   fELossVsPoisson->SetZTitle("Correlation");
+  fELossVsPoissonOut = 
+    static_cast<TH2D*>(fELossVsPoisson
+                      ->Clone(Form("%sOutlier", 
+                                   fELossVsPoisson->GetName())));
+  fELossVsPoissonOut->SetDirectory(0);
+  fELossVsPoissonOut->SetMarkerStyle(20);
+  fELossVsPoissonOut->SetMarkerSize(0.3);
+  fELossVsPoissonOut->SetMarkerColor(kBlack);
+  fELossVsPoissonOut->SetTitle(Form("%s for outliers", 
+                                   fELossVsPoisson->GetTitle()));
 
   fDiffELossPoisson = new TH1D("diffElossPoisson",
-                              "(N_{ch,#DeltaE}-N_{ch,Poisson})/N_{ch,Poisson}",
+                              Form("(%s-%s)/%s", nchP, nchE, nchE),
                               100, -1, 1);
   fDiffELossPoisson->SetDirectory(0);
   fDiffELossPoisson->SetXTitle(fDiffELossPoisson->GetTitle());
@@ -1254,6 +1306,24 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
   fDiffELossPoisson->SetFillStyle(3001);
   fDiffELossPoisson->Sumw2();
                               
+  fDiffELossPoissonOut = 
+    static_cast<TH1D*>(fDiffELossPoisson
+                      ->Clone(Form("%sOutlier",fDiffELossPoisson->GetName())));
+  fDiffELossPoissonOut->SetDirectory(0);
+  fDiffELossPoissonOut->SetTitle(Form("%s for outliers", 
+                                     fDiffELossPoisson->GetTitle()));
+  fDiffELossPoissonOut->SetMarkerColor(Color()-2);
+  fDiffELossPoissonOut->SetFillColor(Color()-2);
+  fDiffELossPoissonOut->SetFillStyle(3002);
+  
+  fOutliers = new TH1D("outliers", "Fraction of outliers", 100, 0, 1);
+  fOutliers->SetDirectory(0);
+  fOutliers->SetXTitle("N_{outlier}/(N_{outlier}+N_{inside})");
+  fOutliers->SetYTitle("#sum_{events}#sum_{bins}");
+  fOutliers->SetFillColor(Color());
+  fOutliers->SetFillStyle(3001);
+  fOutliers->SetLineColor(kBlack);
+
   fELoss = new TH1D("eloss", "#Delta/#Delta_{mip} in all strips", 
                    640, -1, 15);
   fELoss->SetXTitle("#Delta/#Delta_{mip} (selected)");
@@ -1262,7 +1332,7 @@ AliFMDDensityCalculator::RingHistos::RingHistos(UShort_t d, Char_t r)
   fELoss->SetFillStyle(3003);
   fELoss->SetLineColor(kBlack);
   fELoss->SetLineStyle(2);
-  fELoss->SetLineWidth(2);
+  fELoss->SetLineWidth(1);
   fELoss->SetDirectory(0);
 
   fELossUsed = static_cast<TH1D*>(fELoss->Clone("elossUsed"));
@@ -1299,6 +1369,9 @@ AliFMDDensityCalculator::RingHistos::RingHistos(const RingHistos& o)
     fDensity(o.fDensity),
     fELossVsPoisson(o.fELossVsPoisson),
     fDiffELossPoisson(o.fDiffELossPoisson),
+    fELossVsPoissonOut(o.fELossVsPoissonOut),
+    fDiffELossPoissonOut(o.fDiffELossPoissonOut),
+    fOutliers(o.fOutliers),
     fPoisson(o.fPoisson),
     fELoss(o.fELoss),
     fELossUsed(o.fELossUsed),
@@ -1355,6 +1428,9 @@ AliFMDDensityCalculator::RingHistos::operator=(const RingHistos& o)
   fDensity          = static_cast<TH2D*>(o.fDensity->Clone());
   fELossVsPoisson   = static_cast<TH2D*>(o.fELossVsPoisson->Clone());
   fDiffELossPoisson = static_cast<TH1D*>(o.fDiffELossPoisson->Clone());
+  fELossVsPoissonOut   = static_cast<TH2D*>(o.fELossVsPoisson->Clone());
+  fDiffELossPoissonOut = static_cast<TH1D*>(o.fDiffELossPoisson->Clone());
+  fOutliers            = static_cast<TH1D*>(o.fOutliers->Clone());
   fPoisson          = o.fPoisson;
   fELoss            = static_cast<TH1D*>(o.fELoss->Clone());
   fELossUsed        = static_cast<TH1D*>(o.fELossUsed->Clone());
@@ -1419,7 +1495,10 @@ AliFMDDensityCalculator::RingHistos::CreateOutputObjects(TList* dir)
   d->Add(fCorr);
   d->Add(fDensity);
   d->Add(fELossVsPoisson);
+  d->Add(fELossVsPoissonOut);
   d->Add(fDiffELossPoisson);
+  d->Add(fDiffELossPoissonOut);
+  d->Add(fOutliers);
   fPoisson.Output(d);
   fPoisson.GetOccupancy()->SetFillColor(Color());
   fPoisson.GetMean()->SetFillColor(Color());
@@ -1429,11 +1508,8 @@ AliFMDDensityCalculator::RingHistos::CreateOutputObjects(TList* dir)
   d->Add(fPhiBefore);
   d->Add(fPhiAfter);
 
-  Bool_t inner = (fRing == 'I' || fRing == 'i');
-  Int_t nStr = inner ? 512 : 256;
-  Int_t nSec = inner ?  20 :  40;
-  TAxis x(nStr, -.5, nStr-.5);
-  TAxis y(nSec, -.5, nSec-.5);
+  TAxis x(NStrip(), -.5, NStrip()-.5);
+  TAxis y(NSector(), -.5, NSector()-.5);
   x.SetTitle("strip");
   y.SetTitle("sector");
   fPoisson.Define(x, y);
index 478b5c6799541e8c8696590834c19c775fbfc26e..76d55dab68e89f12611a901040c763618677a52e 100644 (file)
@@ -199,6 +199,20 @@ public:
    * @param cut Cut value 
    */
   void SetMinQuality(UShort_t cut=10) { fMinQuality = cut; }
+  /** 
+   * Set the maximum ratio of outlier bins to the total number of bins
+   * with data.  
+   * 
+   * @param ratio Maximum ratio (number between 0 and 1) 
+   */
+  void SetMaxOutliers(Double_t ratio=0.10) { fMaxOutliers = ratio; }
+  /** 
+   * Set the maximum relative diviation between @f$N_{ch}^{Poisson}@f$
+   * and @f$N_{ch}^{\Delta}@f$
+   * 
+   * @param cut Relative cut (number between 0 and 1) 
+   */
+  void SetOutlierCut(Double_t cut=0.50) { fOutlierCut = cut; }
   /** 
    * Get the multiplicity cut.  If the user has set fMultCut (via
    * SetMultCut) then that value is used.  If not, then the lower
@@ -345,6 +359,23 @@ protected:
    * @return Newly allocated histogram of acceptance corrections
    */
   virtual TH1D*   GenerateAcceptanceCorrection(Char_t r) const;
+  /** 
+   * Check if, for a given region, whether this is an outlier 
+   * 
+   * The condition for an outlier event are 
+   * @f[
+   * |N_{ch}^{Poisson} - N_{ch}^{\Delta}| / N_{ch}^{\Delta} > c
+   * @f]
+   *
+   * @param eloss    @f$ N_{ch}^{\Delta}@f$ - number of charged particles
+   * @param poisson  @f$ N_{ch}^{Poisson}@f$ - number of charged particles
+   * @param cut      @f$ c@f$ - the cut 
+   * 
+   * @return true if the region reflects an outlier event 
+   */
+  virtual Bool_t CheckOutlier(Double_t eloss, 
+                             Double_t poisson,
+                             Double_t cut=0.5) const;
   /** 
    * Internal data structure to keep track of the histograms
    */
@@ -407,6 +438,9 @@ protected:
     TH2D*     fDensity;        // Distribution inclusive Nch
     TH2D*     fELossVsPoisson; // Correlation of energy loss vs Poisson N_ch
     TH1D*     fDiffELossPoisson;// Relative difference to Poisson
+    TH2D*     fELossVsPoissonOut; // Correlation of energy loss vs Poisson N_ch
+    TH1D*     fDiffELossPoissonOut;// Relative difference to Poisson
+    TH1D*     fOutliers;       // Fraction of outliers per event 
     AliPoissonCalculator fPoisson; // Calculate density using Poisson method
     TH1D*     fELoss;          // Energy loss as seen by this 
     TH1D*     fELossUsed;      // Energy loss in strips with signal 
@@ -416,7 +450,7 @@ protected:
     TH2D*     fPhiAcc;         // Phi acceptance vs IpZ
     TH1D*     fPhiBefore;      // Phi before re-calce 
     TH1D*     fPhiAfter;       // Phi after re-calc
-    ClassDef(RingHistos,9);
+    ClassDef(RingHistos,10);
   };
   /** 
    * Get the ring histogram container 
@@ -453,8 +487,10 @@ protected:
   AliForwardUtil::Histos fCache;
   Bool_t                 fDoTiming;
   TProfile*              fHTiming;
+  Double_t               fMaxOutliers; // Maximum ratio of outlier bins 
+  Double_t               fOutlierCut;  // Maximum relative diviation 
 
-  ClassDef(AliFMDDensityCalculator,13); // Calculate Nch density 
+  ClassDef(AliFMDDensityCalculator,14); // Calculate Nch density 
 };
 
 #endif
index 6c7bc5bd307c5d917fac4e483e6a23e7eb73e6ff..4fb6aa6b0945a739ac10b797af232b8052441486 100644 (file)
 #include "AliCollisionGeometry.h"
 #include "AliVVZERO.h"
 
+//====================================================================
+namespace {
+  AliPhysicsSelection* GetPhysicsSelection()
+  {
+    AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
+
+    // Get the input handler - should always be there 
+    AliInputEventHandler* ih = 
+      dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
+    if (!ih) { 
+      Warning("GetPhysicsSelection", "No input handler");
+      return 0;
+    }
+    // Get the physics selection - should always be there 
+    AliPhysicsSelection* ps = 
+      dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+    if (!ps) {
+      Warning("GetPhysicsSelection", "No physics selection");
+      return 0;
+    }
+    return ps;
+  }
+}
+
 //====================================================================
 const char* AliFMDEventInspector::fgkFolderName = "fmdEventInspector";
 
@@ -149,6 +173,14 @@ AliFMDEventInspector::AliFMDEventInspector(const char* name)
   //   name Name of object
   //
   DGUARD(fDebug,1,"Named CTOR of AliFMDEventInspector: %s", name);
+  if (!GetPhysicsSelection()) {
+    AliFatal("No physics selection defined in manager\n"
+            "=======================================================\n"
+            " The use of AliFMDEventInspector _requires_ a valid\n"
+            " AliPhysicsSelection registered with the input handler.\n\n"
+            " Please check our train setup\n"
+            "=======================================================\n");
+}
 }
 
 //____________________________________________________________________
@@ -301,18 +333,8 @@ AliFMDEventInspector::SetupForData(const TAxis& vtxAxis)
   //
   DGUARD(fDebug,1,"Initialize in AliFMDEventInspector");
 
-  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
-
-  // Get the input handler - should always be there 
-  AliInputEventHandler* ih = 
-    static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
-  if (!ih) { 
-    AliWarning("No input handler");
-    return;
-  }
   // Get the physics selection - should always be there 
-  AliPhysicsSelection* ps = 
-    static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+  AliPhysicsSelection* ps = GetPhysicsSelection();
   if (!ps) {
     AliWarning("No physics selection");
     return;
@@ -343,14 +365,18 @@ AliFMDEventInspector::SetupForData(const TAxis& vtxAxis)
   
   TArrayD limits;
   if ((fMinCent < 0 && fMaxCent < 0) || fMaxCent <= fMinCent) {
+    // Was:
     // -1.5 -0.5 0.5 1.5 ... 89.5 ... 100.5
     // ----- 92 number --------- ---- 1 ---
-    limits.Set(93);
-    for (Int_t i = 0; i < 92; i++) limits[i] = -1.5 + i;
-    limits[92] = 100.5;
+    // Now:
+    // -0.5 0.5 1.5 ... 89.5 ... 100.5
+    // ----- 91 number ---- ---- 1 ---
+    limits.Set(92);
+    for (Int_t i = 0; i < 91; i++) limits[i] = -.5 + i;
+    limits[91] = 100.5;
   }
   else {
-    Int_t n = fMaxCent-fMinCent+2;
+    Int_t n = Int_t(fMaxCent-fMinCent+2);
     limits.Set(n);
     for (Int_t i = 0; i < n; i++) { 
       limits[i] = fMinCent + i - .5;
@@ -495,7 +521,7 @@ AliFMDEventInspector::SetupForData(const TAxis& vtxAxis)
   fHCentVsQual->SetDirectory(0);
   fList->Add(fHCentVsQual);
 
-  fHStatus = new TH1I("status", "Status", 7, 1, 8);
+  fHStatus = new TH1I("status", "Status", 8, 1, 9);
   fHStatus->SetFillColor(kBlue+1);
   fHStatus->SetFillStyle(3001);
   fHStatus->SetStats(0);
@@ -508,6 +534,7 @@ AliFMDEventInspector::SetupForData(const TAxis& vtxAxis)
   xAxis->SetBinLabel(5, "No FMD");
   xAxis->SetBinLabel(6, "No vertex");
   xAxis->SetBinLabel(7, "Bad vertex");
+  xAxis->SetBinLabel(8, "No centrality");
   fList->Add(fHStatus);
 
   fHVtxStatus = new TH1I("vtxStatus","Vertex Status",
@@ -729,9 +756,10 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
  
   if(fMinCent > -0.0001 && cent < fMinCent) return  kNoEvent; 
   if(fMaxCent > -0.0001 && cent > fMaxCent) return  kNoEvent; 
-  fHCent->Fill(cent);
+  if (cent >= 0) fHCent->Fill(cent);
   if (qual == 0) fHCentVsQual->Fill(0., cent);
   else { 
+    fHStatus->Fill(8);
     for (UShort_t i = 0; i < 4; i++) 
       if (qual & (1 << i)) fHCentVsQual->Fill(Double_t(i+1), cent);
   }
index 214cc194544869f62e57c31ae6721b16c29c912d..5214229d4bf8f50c92f2d058216bd389952b1111 100644 (file)
@@ -44,6 +44,7 @@ AliFMDHistCollector::AliFMDHistCollector()
     fList(0),
     fSumRings(0),
     fCoverage(0),
+    fSkipped(0),
     fMergeMethod(kStraightMean),
     fFiducialMethod(kByCut),
     fSkipFMDRings(0),
@@ -64,6 +65,7 @@ AliFMDHistCollector::AliFMDHistCollector(const char* title)
     fList(0),
     fSumRings(0),
     fCoverage(0),
+    fSkipped(0),
     fMergeMethod(kStraightMean),
     fFiducialMethod(kByCut),
     fSkipFMDRings(0),
@@ -83,6 +85,7 @@ AliFMDHistCollector::AliFMDHistCollector(const AliFMDHistCollector& o)
     fList(o.fList),
     fSumRings(o.fSumRings),
     fCoverage(o.fCoverage),
+    fSkipped(o.fSkipped),
     fMergeMethod(o.fMergeMethod),
     fFiducialMethod(o.fFiducialMethod),
     fSkipFMDRings(o.fSkipFMDRings),
@@ -123,6 +126,7 @@ AliFMDHistCollector::operator=(const AliFMDHistCollector& o)
   fList           = o.fList;
   fSumRings       = o.fSumRings;
   fCoverage       = o.fCoverage;
+  fSkipped        = o.fSkipped;
   fMergeMethod    = o.fMergeMethod;
   fFiducialMethod = o.fFiducialMethod;
   fSkipFMDRings   = o.fSkipFMDRings;
@@ -170,6 +174,17 @@ AliFMDHistCollector::SetupForData(const TAxis& vtxAxis,
   fCoverage->SetZTitle("n_{bins}");
   fList->Add(fCoverage);
                       
+  fSkipped = new TH1D("skipped", "Rings skipped", 5, 1, 6);
+  fSkipped->SetDirectory(0);
+  fSkipped->SetFillColor(kRed+1);
+  fSkipped->SetFillStyle(3001);
+  fSkipped->SetYTitle("Events");
+  fSkipped->GetXaxis()->SetBinLabel(1,"FMD1i");
+  fSkipped->GetXaxis()->SetBinLabel(2,"FMD2i");
+  fSkipped->GetXaxis()->SetBinLabel(3,"FMD2o");
+  fSkipped->GetXaxis()->SetBinLabel(4,"FMD3i");
+  fSkipped->GetXaxis()->SetBinLabel(5,"FMD3o");
+  fList->Add(fSkipped);
 
   // --- Add parameters to output ------------------------------------
   fList->Add(AliForwardUtil::MakeParameter("nCutBins",fNCutBins));
@@ -474,7 +489,7 @@ AliFMDHistCollector::Collect(const AliForwardUtil::Histos& hists,
   // Double_t vMax    = vtxAxis->GetBinUpEdge(vtxbin);
   VtxBin*  bin     = GetVtxBin(vtxbin);
   if (!bin) return false;
-  Bool_t   ret     = bin->Collect(hists, sums, out, fSumRings, cent, 
+  Bool_t   ret     = bin->Collect(hists, sums, out, fSumRings, fSkipped, cent, 
                                  fMergeMethod, fSkipFMDRings,
                                  fByCent, eta2phi);
 
@@ -739,6 +754,7 @@ AliFMDHistCollector::VtxBin::Collect(const AliForwardUtil::Histos& hists,
                                     AliForwardUtil::Histos&       sums, 
                                     TH2D&                         out,
                                     TH2D*                         sumRings,
+                                    TH1D*                         skipped,
                                     Double_t                      cent,
                                     MergeMethod                   m,
                                     UShort_t                      skips,
@@ -749,12 +765,17 @@ AliFMDHistCollector::VtxBin::Collect(const AliForwardUtil::Histos& hists,
     UShort_t nr = (d == 1 ? 1 : 2);
     for (UShort_t q=0; q<nr; q++) { 
       Char_t      r = (q == 0 ? 'I' : 'O');
-      if (CheckSkip(d, r, skips)) continue;
-
+      Int_t       i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1));
       TH2D*       h = hists.Get(d,r);
+      if (CheckSkip(d, r, skips) || !h || 
+         h->TestBit(AliForwardUtil::kSkipRing)) {
+       // Skipping a ring - either because disable, not there, or
+       // because of flagged (too many outliers, ...)
+       skipped->Fill(i);
+       continue;
+      }
       TH2D*       o = sums.Get(d, r);
       TH2D*       t = static_cast<TH2D*>(h->Clone(Form("FMD%d%c_tmp",d,r)));
-      Int_t       i = (d == 1 ? 1 : 2*d + (q == 0 ? -2 : -1));
       
       // Get valid range 
       Int_t first = 0;
index efe503657abea635aa68b51138ef7bd5f3572b63..1003221d7f974fa7bfa09cfa649ac8184a854abd 100644 (file)
@@ -21,6 +21,7 @@
 class AliESDFMD;
 class TH2;
 class TH2D;
+class TH1D;
 class TObjArray;
 
 /** 
@@ -378,6 +379,7 @@ protected:
      * @param sums       Sum histograms
      * @param out        Per-event output histogram
      * @param sumRings   Sum per ring 
+     * @param skipped    Histogram of skipped rings 
      * @param cent       Event centrality
      * @param m          Merging method
      * @param skips      Which rings to skip
@@ -390,6 +392,7 @@ protected:
                   AliForwardUtil::Histos&       sums, 
                   TH2D&                         out,
                   TH2D*                         sumRings,
+                  TH1D*                         skipped,
                   Double_t                      cent,
                   MergeMethod                   m,
                   UShort_t                      skips,
@@ -495,6 +498,7 @@ protected:
   TList*      fList;           // Output list
   TH2D*       fSumRings;        // Sum per ring (on y-axis)
   TH2D*       fCoverage;        // Sum per ring (on y-axis)
+  TH1D*       fSkipped;         // Skipped rings
   MergeMethod fMergeMethod;     // Merge methiod for overlapping bins 
   FiducialMethod fFiducialMethod; // Fidicual method
   UShort_t    fSkipFMDRings;    // FMD rings to ignore     
index 9a0cd60929fe22753960e5d6471597f2885e2af7..204364148a55f542cf79790c8be98d6766357d4e 100644 (file)
@@ -394,6 +394,10 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
            mult = AliESDFMD::kInvalidMult;
          }
          
+         if (mult != AliESDFMD::kInvalidMult) 
+           // Always fill the ESD sum histogram 
+           histos->fSumESD->Fill(eta, phi, mult);
+
          // If no signal or dead strip, go on. 
          if (mult == AliESDFMD::kInvalidMult || mult == 0) {
            if (mult == 0) histos->fSum->Fill(eta,phi,mult);
@@ -675,6 +679,7 @@ AliFMDSharingFilter::Terminate(const TList* dir, TList* output, Int_t nEvents)
   TIter    next(&fRingHistos);
   RingHistos* o = 0;
   THStack* sums = new THStack("sums", "Sum of ring signals");
+  THStack* sumsESD = new THStack("sumsESD", "Sum of ring ESD signals");
   while ((o = static_cast<RingHistos*>(next()))) {
     o->Terminate(d, nEvents);
     if (!o->fSum) { 
@@ -685,10 +690,18 @@ AliFMDSharingFilter::Terminate(const TList* dir, TList* output, Int_t nEvents)
     sum->Scale(1., "width");
     sum->SetTitle(o->GetName());
     sum->SetDirectory(0);
-    sum->SetYTitle("#sum #Delta/#Delta_{mip}");
+    sum->SetYTitle("#sum_{c} #Delta/#Delta_{mip}");
     sums->Add(sum);
+
+    sum = o->fSumESD->ProjectionX(o->GetName(), 1, o->fSumESD->GetNbinsY(),"e");
+    sum->Scale(1., "width");
+    sum->SetTitle(o->GetName());
+    sum->SetDirectory(0);
+    sum->SetYTitle("#sum_{s} #Delta/#Delta_{mip}");
+    sumsESD->Add(sum);
   }
   out->Add(sums);
+  out->Add(sumsESD);
   output->Add(out);
 }
 
@@ -835,6 +848,7 @@ AliFMDSharingFilter::RingHistos::RingHistos()
     fBeforeAfter(0),
     fNeighborsBefore(0),
     fNeighborsAfter(0),
+    fSumESD(0),
     fSum(0) // ,
     // fHits(0),
     // fNHits(0)
@@ -859,6 +873,7 @@ AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
     fBeforeAfter(0),
     fNeighborsBefore(0),
     fNeighborsAfter(0),
+    fSumESD(0),
     fSum(0) //,
     // fHits(0),
     // fNHits(0)
@@ -957,16 +972,21 @@ AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
   fNeighborsAfter->SetTitle("Correlation of neighbors after");
   fNeighborsAfter->SetDirectory(0);
 
-  fSum = new TH2D("summed", "Summed signal", 200, -4, 6, 
-                 (fRing == 'I' || fRing == 'i' ? 20 : 40), 0, 2*TMath::Pi());
-  fSum->SetDirectory(0);
-  fSum->Sumw2();
-  fSum->SetMarkerColor(Color());
+  fSumESD = new TH2D("summedESD", "Summed ESD signal", 200, -4, 6, 
+                 NSector(), 0, 2*TMath::Pi());
+  fSumESD->SetDirectory(0);
+  fSumESD->Sumw2();
+  fSumESD->SetMarkerColor(Color());
   // fSum->SetFillColor(Color());
-  fSum->SetXTitle("#eta");
-  fSum->SetYTitle("#varphi [radians]");
-  fSum->SetZTitle("#sum #Delta/#Delta_{mip}(#eta,#varphi) ");
+  fSumESD->SetXTitle("#eta");
+  fSumESD->SetYTitle("#varphi [radians]");
+  fSumESD->SetZTitle("#sum_{strip} #Delta/#Delta_{mip}(#eta,#varphi) ");
 
+  fSum = static_cast<TH2D*>(fSumESD->Clone("summed"));
+  fSum->SetTitle("Summed cluster signal");
+  fSum->SetZTitle("#sum_{cluster} #Delta/#Delta_{mip}(#eta,#varphi) ");
+  fSum->SetDirectory(0);
+  
 #if 0  
   fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
   fHits->SetDirectory(0);
@@ -988,6 +1008,7 @@ AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
     fBeforeAfter(o.fBeforeAfter),
     fNeighborsBefore(o.fNeighborsBefore),
     fNeighborsAfter(o.fNeighborsAfter),
+    fSumESD(o.fSumESD), //,
     fSum(o.fSum) //,
     // fHits(o.fHits),
     // fNHits(o.fNHits)
@@ -1041,6 +1062,7 @@ AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
   fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
   fNeighborsAfter  = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
   // fHits            = static_cast<TH1D*>(o.fHits->Clone());
+  fSumESD          = static_cast<TH2D*>(o.fSumESD->Clone());
   fSum             = static_cast<TH2D*>(o.fSum->Clone());
 
   return *this;
@@ -1088,6 +1110,10 @@ AliFMDSharingFilter::RingHistos::Terminate(const TList* dir, Int_t nEvents)
   TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
   if (summed) summed->Scale(1./nEvents);
   fSum = summed;
+
+  TH2D* summedESD = static_cast<TH2D*>(l->FindObject("summedESD"));
+  if (summedESD) summedESD->Scale(1./nEvents);
+  fSumESD = summedESD;
 }
 
 //____________________________________________________________________
@@ -1114,6 +1140,7 @@ AliFMDSharingFilter::RingHistos::CreateOutputObjects(TList* dir)
   d->Add(fNeighborsBefore);
   d->Add(fNeighborsAfter);
   // d->Add(fHits);
+  d->Add(fSumESD);
   d->Add(fSum);
 
   // Removed to avoid doubly adding the list which destroys 
index 6f5db15625eae149ff9b8104c45551b0ac4db328..323ac2b62c967712ca9f635bed9a59b6f9e871db 100644 (file)
@@ -361,7 +361,8 @@ protected:
     TH2D*     fBeforeAfter;     // Correlation of before and after 
     TH2D*     fNeighborsBefore; // Correlation of neighbors 
     TH2D*     fNeighborsAfter;  // Correlation of neighbors 
-    TH2D*     fSum;             // Summed signal 
+    TH2D*     fSumESD;          // Summed ESD signal 
+    TH2D*     fSum;             // Summed cluster signal 
     ClassDef(RingHistos,3);
   };
   /** 
index ab1f58377cd4d82c004eb89f9a36be290c8b15ca..84c4b29e2de2d88a2e340a789c2636cd8ef09309 100644 (file)
@@ -6,29 +6,20 @@
 //  - AliAODEvent
 //
 // Outputs:
-//  - AnalysisResults.root
+//  - AnalysisResults.root or forward_flow.root
 //
-/**
- * @file   AliForwardFlowTaskQC.cxx
- * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
- * @date   Thu Feb  7 01:09:00 2013
- * 
- * @brief  
- * 
- * 
- * @ingroup pwglf_forward_flow
- */
 #include <TROOT.h>
 #include <TSystem.h>
 #include <TInterpreter.h>
 #include <TChain.h>
 #include <TFile.h>
 #include <TList.h>
-#include <iostream>
 #include <TMath.h>
 #include <TH3D.h>
 #include <TProfile2D.h>
 #include <TParameter.h>
+#include <TMatrixD.h>
+#include <TVectorD.h>
 #include <TGraph.h>
 #include "AliLog.h"
 #include "AliForwardFlowTaskQC.h"
 #include "AliAODCentralMult.h"
 #include "AliAODEvent.h"
 #include "AliForwardUtil.h"
+#include "AliAODVZERO.h"
+#include "AliAODVertex.h"
+#include "AliCentrality.h"
+#include "AliESDEvent.h"
+#include "AliVTrack.h"
+#include "AliESDtrackCuts.h"
+#include "AliAODTrack.h"
 
 ClassImp(AliForwardFlowTaskQC)
 #if 0
@@ -47,50 +45,62 @@ ClassImp(AliForwardFlowTaskQC)
 
 AliForwardFlowTaskQC::AliForwardFlowTaskQC()
   : AliAnalysisTaskSE(),
-    fVtxAxis(),         // Axis to contorl vertex binning
-    fFMDCut(-1),        // FMD sigma cut
-    fSPDCut(-1),        // SPD sigma cut
-    fFlowFlags(kSymEta),// Flow flags
-    fEtaGap(2.),        // Eta gap value
-    fBinsFMD(),         // List with FMD flow histos
-    fBinsSPD(),         // List with SPD flow histos
-    fSumList(0),       // Event sum list
-    fOutputList(0),    // Result output list
-    fAOD(0),           // AOD input event
-    fV(),               // Flow moments
-    fVtx(1111),                // Z vertex coordinate
-    fCent(-1),         // Centrality
-    fHistCent(),        // Histo for centrality
-    fHistVertexSel()    // Histo for selected vertices
+    fVtxAxis(),          // Axis to control vertex binning
+    fCentAxis(),         // Axis to control centrality/multiplicity binning
+    fFMDCut(-1),         // FMD sigma cut
+    fSPDCut(-1),         // SPD sigma cut
+    fFlowFlags(0),       // Flow flags
+    fEtaGap(-1),         // Eta gap value
+    fBinsForward(),      // List with forward flow hists
+    fBinsCentral(),      // List with central flow hists
+    fSumList(0),        // Event sum list
+    fOutputList(0),     // Result output list
+    fAOD(0),            // AOD input event
+    fESDTrackCuts(0),    // ESD track cuts
+    fMaxMoment(0),       // Max flow moment
+    fVtx(1111),                 // Z vertex coordinate
+    fCent(-1),          // Centrality
+    fHistdNdedpV0(),     // Hist for v0
+    fHistdNdedp3Cor(),   // Hist for combining detectors
+    fHistFMDSPDCorr(),   // FMD SPD correlation
+    fHistCent(),         // Hist for centrality
+    fHistVertexSel(),    // Hist for selected vertices
+    fHistEventSel()      // Hist for event selection
 {
   // 
-  // Default constructor
+  //  Default constructor
   //
 }
 //_____________________________________________________________________
 AliForwardFlowTaskQC::AliForwardFlowTaskQC(const char* name) 
   : AliAnalysisTaskSE(name),
-    fVtxAxis(),         // Axis to contorl vertex binning
+    fVtxAxis(),         // Axis to control vertex binning
+    fCentAxis(),        // Axis to control centrality/multiplicity binning
     fFMDCut(-1),        // FMD sigma cut
     fSPDCut(-1),        // SPD sigma cut
-    fFlowFlags(kSymEta),// Flow flags
+    fFlowFlags(kSymEta|kStdQC), // Flow flags
     fEtaGap(2.),        // Eta gap value
-    fBinsFMD(),         // List with FMD flow histos
-    fBinsSPD(),         // List with SPD flow histos
+    fBinsForward(),     // List with forward flow hists
+    fBinsCentral(),     // List with central flow hists
     fSumList(0),        // Event sum list           
     fOutputList(0),     // Result output list       
     fAOD(0),           // AOD input event          
-    fV(),               // Flow moments
+    fESDTrackCuts(0),   // ESD track cuts
+    fMaxMoment(4),      // Max flow moment
     fVtx(1111),         // Z vertex coordinate      
     fCent(-1),          // Centrality               
-    fHistCent(),        // Histo for centrality
-    fHistVertexSel()    // Histo for selected vertices
+    fHistdNdedpV0(),    // Histo for v0
+    fHistdNdedp3Cor(),  // Histo for combining detectors
+    fHistFMDSPDCorr(),  // FMD SPD correlation
+    fHistCent(),        // Hist for centrality
+    fHistVertexSel(),   // Hist for selected vertices
+    fHistEventSel()     // Hist for event selection
 {
   // 
-  // Constructor
+  //  Constructor
   //
-  // Parameters:
-  //  name: Name of task
+  //  Parameters:
+  //   name: Name of task
   //
   DefineOutput(1, TList::Class());
   DefineOutput(2, TList::Class());
@@ -98,27 +108,33 @@ AliForwardFlowTaskQC::AliForwardFlowTaskQC(const char* name)
 //_____________________________________________________________________
 AliForwardFlowTaskQC::AliForwardFlowTaskQC(const AliForwardFlowTaskQC& o)
   : AliAnalysisTaskSE(o),
-    fVtxAxis(o.fVtxAxis),              // Axis to contorl vertex binning
+    fVtxAxis(o.fVtxAxis),              // Axis to control vertex binning
+    fCentAxis(o.fCentAxis),            // Array to control centrality/multiplicity binning
     fFMDCut(o.fFMDCut),                // FMD sigma cut
     fSPDCut(o.fSPDCut),                // SPD sigma cut
     fFlowFlags(o.fFlowFlags),          // Flow flags
     fEtaGap(o.fEtaGap),                // Eta gap value
-    fBinsFMD(),                        // List with FMD flow histos
-    fBinsSPD(),                        // List with SPD flow histos
+    fBinsForward(),                    // List with forward flow hists
+    fBinsCentral(),                    // List with central flow hists
     fSumList(o.fSumList),              // Event sum list           
     fOutputList(o.fOutputList),        // Result output list       
     fAOD(o.fAOD),                     // AOD input event          
-    fV(o.fV),                          // Flow moments
+    fESDTrackCuts(o.fESDTrackCuts),    // ESD track cuts
+    fMaxMoment(o.fMaxMoment),          // Flow moments
     fVtx(o.fVtx),                      // Z vertex coordinate      
     fCent(o.fCent),                   // Centrality
-    fHistCent(o.fHistCent),            // Histo for centrality
-    fHistVertexSel(o.fHistVertexSel)   // Histo for selected vertices
+    fHistdNdedpV0(o.fHistdNdedpV0),    // Histo for v0
+    fHistdNdedp3Cor(o.fHistdNdedp3Cor),// Histo for combining detectors
+    fHistFMDSPDCorr(o.fHistFMDSPDCorr),// FMD SPD correlation
+    fHistCent(o.fHistCent),            // Hist for centrality
+    fHistVertexSel(o.fHistVertexSel),  // Hist for selected vertices
+    fHistEventSel(o.fHistEventSel)     // Hist for event selection
 {
   // 
-  // Copy constructor 
+  //  Copy constructor 
   // 
-  // Parameters:
-  //    o Object to copy from 
+  //  Parameters:
+  //   o: Object to copy from 
   //
 }
 //_____________________________________________________________________
@@ -126,53 +142,77 @@ AliForwardFlowTaskQC&
 AliForwardFlowTaskQC::operator=(const AliForwardFlowTaskQC& o)
 {
   // 
-  // Assignment operator 
+  //  Assignment operator 
   //
   if (&o == this) return *this;
-  fVtxAxis       = o.fVtxAxis;
-  fFMDCut        = o.fFMDCut;
-  fSPDCut        = o.fSPDCut;
-  fFlowFlags     = o.fFlowFlags;
-  fEtaGap        = o.fEtaGap;
-  fSumList       = o.fSumList;
-  fOutputList    = o.fOutputList;
-  fAOD           = o.fAOD;
-  fV             = o.fV;
-  fVtx           = o.fVtx;
-  fCent          = o.fCent;
-  fHistCent      = o.fHistCent;
-  fHistVertexSel = o.fHistVertexSel;
+  fVtxAxis        = o.fVtxAxis;
+  fCentAxis       = o.fCentAxis;
+  fFMDCut         = o.fFMDCut;
+  fSPDCut         = o.fSPDCut;
+  fFlowFlags      = o.fFlowFlags;
+  fEtaGap         = o.fEtaGap;
+  fSumList        = o.fSumList;
+  fOutputList     = o.fOutputList;
+  fAOD            = o.fAOD;
+  fESDTrackCuts   = o.fESDTrackCuts;
+  fMaxMoment      = o.fMaxMoment;
+  fVtx            = o.fVtx;
+  fCent           = o.fCent;
+  fHistdNdedpV0   = o.fHistdNdedpV0;
+  fHistdNdedp3Cor = o.fHistdNdedp3Cor;
+  fHistFMDSPDCorr = o.fHistFMDSPDCorr;
+  fHistCent       = o.fHistCent;
+  fHistVertexSel  = o.fHistVertexSel;
+  fHistEventSel   = o.fHistEventSel;
 
   return *this;
 }
 //_____________________________________________________________________
+void AliForwardFlowTaskQC::SetFlowFlags(UShort_t flags)
+{
+  //
+  //  Set flow flags, making sure the detector setup is right
+  //
+  //  Parameters:
+  //   flags: Flow flags
+  //
+  if ((flags & kFMD) && (flags & kVZERO)) 
+    AliFatal("Cannot do analysis on more than one forward detector!");
+  else if (!(flags & kFMD) && !(flags & kVZERO)) 
+    AliFatal("You need to add a forward detector!");
+  else fFlowFlags = flags;
+}
+//_____________________________________________________________________
 void AliForwardFlowTaskQC::UserCreateOutputObjects()
 {
   //
-  // Create output objects
+  //  Create output objects
   //
   InitVertexBins();
   InitHists();
+  if (fFlowFlags & kTPC) {
+    fESDTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
+  }
   PrintFlowSetup();
 
   PostData(1, fSumList);
-  PostData(2, fOutputList);
-
 }
 //_____________________________________________________________________
 void AliForwardFlowTaskQC::InitVertexBins()
 {
   // 
-  // Init vertexbin objects for FMD and SPD, and add them to the lists
-  //
-  Int_t moment = 0;
-  for(UShort_t n = 0; n < fV.GetSize(); n++) {
-    moment = fV.At(n);
-    for (Int_t v = 1; v <= fVtxAxis->GetNbins(); v++) {
-      Int_t vL = Int_t(fVtxAxis->GetBinLowEdge(v));
-      Int_t vH = Int_t(fVtxAxis->GetBinUpEdge(v));
-      fBinsFMD.Add(new VertexBin(vL, vH, moment, "FMD", fFlowFlags, fFMDCut, fEtaGap));
-      fBinsSPD.Add(new VertexBin(vL, vH, moment, "SPD", fFlowFlags, fSPDCut, fEtaGap));
+  //  Init vertexbin objects for forward and central detectors, and add them to the lists
+  //
+  for (Int_t v = 1; v <= fVtxAxis->GetNbins(); v++) {
+    Int_t vL = Int_t(fVtxAxis->GetBinLowEdge(v));
+    Int_t vH = Int_t(fVtxAxis->GetBinUpEdge(v));
+    if ((fFlowFlags & kFMD)) {
+      fBinsForward.Add(new VertexBin(vL, vH, fMaxMoment, "FMD", fFlowFlags, fFMDCut, fEtaGap));
+      if (!(fFlowFlags & k3Cor)) fBinsCentral.Add(new VertexBin(vL, vH, fMaxMoment, "SPD-FMD", fFlowFlags|kNUAcorr, fSPDCut, fEtaGap));
+    }
+    else if ((fFlowFlags & kVZERO)) {
+      fBinsForward.Add(new VertexBin(vL, vH, fMaxMoment, "VZERO", fFlowFlags, 0, fEtaGap));
+      if (!(fFlowFlags & k3Cor)) fBinsCentral.Add(new VertexBin(vL, vH, fMaxMoment, "SPD-VZERO", fFlowFlags|kNUAcorr, fSPDCut, fEtaGap));
     }
   }
 }
@@ -180,9 +220,8 @@ void AliForwardFlowTaskQC::InitVertexBins()
 void AliForwardFlowTaskQC::InitHists()
 {
   //
-  // Init histograms and add vertex bin histograms to the sum list
+  //  Init histograms and add vertex bin histograms to the sum list
   //
-  
   if (!fSumList)
     fSumList = new TList();
   fSumList->SetName("Sums");
@@ -190,36 +229,73 @@ void AliForwardFlowTaskQC::InitHists()
 
   if (!fVtxAxis) fVtxAxis = new TAxis(20, -10, 10);
   fVtxAxis->SetName("VtxAxis");
+  if (!fCentAxis) fCentAxis = new TAxis(20, 0, 100);
+  fVtxAxis->SetName("CentAxis");
+  
   fHistCent         = new TH1D("hCent", "Centralities", 100, 0, 100);
   fHistVertexSel    = new TH1D("hVertexSel", "Selected vertices", fVtxAxis->GetNbins(), fVtxAxis->GetXmin(), fVtxAxis->GetXmax());
+  fHistEventSel     = new TH1I("hEventSel", "Event Selection", kOK, 0.5, kOK+0.5);
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoEvent, "No AOD event");
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoForward, "No forward det");
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoCentral, "No central det");
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoTrigger, "Not triggered");
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoCent, "No centrality");
+  fHistEventSel->GetXaxis()->SetBinLabel(kInvCent, "Centrality outside range");
+  fHistEventSel->GetXaxis()->SetBinLabel(kNoVtx, "No vertex");
+  fHistEventSel->GetXaxis()->SetBinLabel(kInvVtx, "Vtx outside range");
+  fHistEventSel->GetXaxis()->SetBinLabel(kOK, "OK!");
+
+  fHistFMDSPDCorr = new TH2D("hFMDSPDCorr", "hFMDSPCCorr", 200, 0., 20000., 200, 0, 7500);
 
   TList* dList = new TList();
   dList->SetName("Diagnostics");
-//  dList->Add(fVtxAxis);
   dList->Add(fHistCent);
   dList->Add(fHistVertexSel);
+  dList->Add(fHistEventSel);
+  dList->Add(fHistFMDSPDCorr);
   fSumList->Add(dList);
 
-  TIter nextFMD(&fBinsFMD);
+  fHistdNdedp3Cor = TH2D(Form("hdNdedpCombined_%s", GetQCType(fFlowFlags)), Form("hdNdedpCombined_%s", GetQCType(fFlowFlags)), 
+                           200, -4., 6., 20, 0., TMath::TwoPi());
+  if ((fFlowFlags & kVZERO)) {
+    Double_t bins[12] = { -6, -3.7, -3.2, -2.7, -2.2, -1.7, 
+                         2.8, 3.4,  3.9,  4.5,  5.1, 6 };
+    fHistdNdedpV0 = TH2D(Form("hdNdedpv0%s", GetQCType(fFlowFlags)), Form("hdNdedpv0%s", GetQCType(fFlowFlags)),
+                   11, -6, 6, 8, 0, TMath::TwoPi());
+    fHistdNdedpV0.GetXaxis()->Set(11, bins);
+    if ((fFlowFlags & k3Cor)) {
+      Double_t bins2[20] = { -6, -3.7, -3.2, -2.7, -2.2, // VZERO
+                             -2.0, -1.5, -1.0, -0.5 , 0., 0.5, 1.0, 1.5, 2.0, // SPD
+                           2.8, 3.4,  3.9,  4.5,  5.1, 6 }; // VZERO
+      fHistdNdedp3Cor.GetXaxis()->Set(19, bins2);
+      fHistdNdedp3Cor.GetYaxis()->Set(8, 0., TMath::TwoPi());
+    }
+  }
+
+  TIter nextForward(&fBinsForward);
   VertexBin* bin = 0;
-  while ((bin = static_cast<VertexBin*>(nextFMD()))) {
-    bin->AddOutput(fSumList);
+  while ((bin = static_cast<VertexBin*>(nextForward()))) {
+    bin->AddOutput(fSumList, fCentAxis);
   }
-  TIter nextSPD(&fBinsSPD);
-  while ((bin = static_cast<VertexBin*>(nextSPD()))) {
-    bin->AddOutput(fSumList);
+  TIter nextCentral(&fBinsCentral);
+  while ((bin = static_cast<VertexBin*>(nextCentral()))) {
+    bin->AddOutput(fSumList, fCentAxis);
   }
 }
 //_____________________________________________________________________
 void AliForwardFlowTaskQC::UserExec(Option_t */*option*/)
 {
   //
-  // Calls the analyze function - called every event
+  //  Calls the analyze function - called every event
   //
-  // Parameters:
-  //  option: Not used
+  //  Parameters:
+  //   option: Not used
   //
   
+  // Reset data members
+  fCent = -1;
+  fVtx = 1111;
+
   Analyze();
   
   PostData(1, fSumList);
@@ -230,108 +306,285 @@ void AliForwardFlowTaskQC::UserExec(Option_t */*option*/)
 Bool_t AliForwardFlowTaskQC::Analyze()
 {
   // 
-  // Load FMD and SPD objects from aod tree and call the cumulants 
-  // calculation for the correct vertexbin
+  //  Load forward and central detector objects from aod tree and call the 
+  //  cumulants calculation for the correct vertex bin
+  //
+  //  Return: true on success
   //
-
-  // Reset data members
-  fCent = -1;
-  fVtx = 1111;
 
   // Get input event
-//  fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
   fAOD = dynamic_cast<AliAODEvent*>(AliForwardUtil::GetAODEvent(this));
-  if (!fAOD) return kFALSE;
+  if (!fAOD) {
+    fHistEventSel->Fill(kNoEvent);
+    return kFALSE;
+  }
 
-  const AliAODForwardMult* aodfmult = static_cast<AliAODForwardMult*>(fAOD->FindListObject("Forward"));
-  const AliAODCentralMult* aodcmult = static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClusters"));
-  if (!aodfmult) return kFALSE;
-  
-  // Check event for triggers, get centrality, vtx etc.
-  if (!CheckEvent(aodfmult)) return kFALSE;
-  Int_t vtx = fVtxAxis->FindBin(fVtx)-1;
+  // Get detector objects
+  AliAODForwardMult* aodfmult = static_cast<AliAODForwardMult*>(fAOD->FindListObject("Forward"));
+  AliAODCentralMult* aodcmult = static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClusters"));
+  AliAODVZERO* aodvzero = fAOD->GetVZEROData();
+  if ((fFlowFlags & kVZERO)) {
+    if (aodvzero) {
+      fHistdNdedpV0.Reset();
+      FillVZEROHist(aodvzero);
+    }
+  }
 
-  // If everything is OK: get histos and run analysis
-  const TH2D& fmddNdetadphi = aodfmult->GetHistogram();
-  if ((fFlowFlags & kEtaGap)) {
-    FillVtxBinListEtaGap(fBinsFMD, fmddNdetadphi, fmddNdetadphi, vtx);
-  } else {
-    FillVtxBinList(fBinsFMD, fmddNdetadphi, vtx);
+  // We make sure that the necessary forward object is there
+  if ((fFlowFlags & kFMD) && !aodfmult) {
+    fHistEventSel->Fill(kNoForward);
+    return kFALSE; 
+  }
+  else if ((fFlowFlags & kVZERO) && !aodvzero) {
+    fHistEventSel->Fill(kNoForward);
+    return kFALSE; 
   }
+  if (!aodcmult) fHistEventSel->Fill(kNoCentral);
 
+   // Check event for triggers, get centrality, vtx etc.
+  if (!CheckEvent(aodfmult)) return kFALSE;
+  Int_t vtx = fVtxAxis->FindBin(fVtx)-1;
+  
+  // Then we assign a reference to the forward histogram of interest
+  TH2D& forwarddNdedp = ((fFlowFlags & kFMD) ? aodfmult->GetHistogram() : fHistdNdedpV0);
+  TH2D& spddNdedp = aodcmult->GetHistogram();
+  if ((fFlowFlags & kStdQC)) {
+    FillVtxBinList(fBinsForward, forwarddNdedp, vtx);
+  } else if ((fFlowFlags & kEtaGap)) {
+    FillVtxBinListEtaGap(fBinsForward, forwarddNdedp, forwarddNdedp, vtx);
+  }
+  // At the moment only clusters are supported for the central region (some day add tracks?)
+  // So no extra checks necessary
   if (aodcmult) {
-    const TH2D& spddNdetadphi = aodcmult->GetHistogram();
-    if ((fFlowFlags & kEtaGap)) {
-      FillVtxBinListEtaGap(fBinsSPD, fmddNdetadphi, spddNdetadphi, vtx);
-    } else {
-      FillVtxBinList(fBinsSPD, spddNdetadphi, vtx);
+    if ((fFlowFlags & kStdQC)) {
+      FillVtxBinList(fBinsCentral, spddNdedp, vtx);
+    } else if ((fFlowFlags & kEtaGap)) {
+      FillVtxBinListEtaGap(fBinsCentral, forwarddNdedp, spddNdedp, vtx);
+    } else if ((fFlowFlags & k3Cor)) {
+      FillVtxBinList3Cor(fBinsForward, spddNdedp, forwarddNdedp, vtx);
+    }
+    // Diagnostics
+    if (aodfmult) {
+      Double_t totForward = forwarddNdedp.Integral(1, forwarddNdedp.GetNbinsX(), 1, forwarddNdedp.GetNbinsY());
+      Double_t totSPD = spddNdedp.Integral(1, spddNdedp.GetNbinsX(), 1, spddNdedp.GetNbinsY());
+      fHistFMDSPDCorr->Fill(totForward, totSPD);
     }
   }
 
   return kTRUE;
 }
 //_____________________________________________________________________
-Bool_t AliForwardFlowTaskQC::FillVtxBinList(const TList& list, const TH2D& h, Int_t vtx) const
+void AliForwardFlowTaskQC::FillVtxBinList(const TList& list, TH2D& h, Int_t vtx, UShort_t flags) const
 {
   //
-  // Loops over list of VtxBins, fills hists of bins for current vertex
-  // and runs analysis on those bins
+  //  Loops over list of VtxBins, fills hists of bins for current vertex
+  //  and runs analysis on those bins
   //
-  // Parameters:
-  //  list: list of VtxBins
-  //  h:    dN/detadphi histogram
-  //  vBin: current vertex bin
+  //  Parameters:
+  //   list:  list of VtxBins
+  //   h:     dN/detadphi histogram
+  //   vtx:   current vertex bin
+  //   flags: extra flags to handle calculations.
+  // 
+  //   Note: The while loop is used in this function and the next 2 for historical reasons,
+  //         as originally each moment had it's own VertexBin object.
+  VertexBin* bin = 0;
+  Int_t i = 0;
+  Int_t nVtxBins = fVtxAxis->GetNbins();
+  
+  while ((bin = static_cast<VertexBin*>(list.At(vtx+(nVtxBins*i))))) {
+    // If no tracks do things normally
+    if (!(fFlowFlags & kTPC) && !bin->FillHists(h, fCent, kFillBoth|flags|kReset)) return;
+    // if tracks things are more complicated
+    else if ((fFlowFlags & kTPC)) {
+      TObjArray* trList = GetTracks();
+      if (!trList) return;
+      Bool_t useEvent = bin->FillTracks(trList, kFillRef|kReset|flags);
+      // If esd input trList is a new object owned by this task and should be cleaned up
+      if (AliForwardUtil::CheckForAOD() == 2) delete trList;
+      if (!useEvent) return;
+      if (!bin->FillHists(h, fCent, kFillDiff|kReset|flags)) return;
+    }
+    bin->CumulantsAccumulate(fCent);
+    i++;
+  }
+
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::FillVtxBinListEtaGap(const TList& list, TH2D& href, 
+                                                  TH2D& hdiff, Int_t vtx, UShort_t flags) const
+{
+  //
+  //  Loops over list of VtxBins, fills hists of bins for current vertex
+  //  and runs analysis on those bins
   //
-  // return true on success
+  //  Parameters:
+  //   list:  list of VtxBins
+  //   href:  dN/detadphi histogram for ref. flow
+  //   hdiff: dN/detadphi histogram for diff. flow
+  //   vBin:  current vertex bin
+  //   flags: extra flags to handle calculations.
   //
   VertexBin* bin = 0;
   Int_t i = 0;
   Int_t nVtxBins = fVtxAxis->GetNbins();
 
   while ((bin = static_cast<VertexBin*>(list.At(vtx+(nVtxBins*i))))) {
-    Bool_t skipFourP = !bin->FillHists(h, fCent, kFillBoth);
-    bin->CumulantsAccumulate(fCent, skipFourP);
+    if (!bin->FillHists(href, fCent, kFillRef|flags|kReset)) return;
+    bin->FillHists(hdiff, fCent, kFillDiff|kReset);
+    bin->CumulantsAccumulate(fCent);
     i++;
   }
 
-  return kTRUE;
+  return;
 }
 //_____________________________________________________________________
-Bool_t AliForwardFlowTaskQC::FillVtxBinListEtaGap(const TList& list, const TH2D& href
-                                                  const TH2D& hdiff, Int_t vtx) const
+void AliForwardFlowTaskQC::FillVtxBinList3Cor(const TList& list, TH2D& hcent
+                                              TH2D& hfwd, Int_t vtx, UShort_t flags)
 {
   //
-  // Loops over list of VtxBins, fills hists of bins for current vertex
-  // and runs analysis on those bins
+  //  Loops over list of VtxBins, fills hists of bins for current vertex
+  //  and runs analysis on those bins
   //
-  // Parameters:
-  //  list: list of VtxBins
-  //  h:    dN/detadphi histogram
-  //  vBin: current vertex bin
-  //
-  // return true on success
+  //  Parameters:
+  //   list:  list of VtxBins
+  //   hcent: dN/detadphi histogram for central coverage
+  //   hfwd:  dN/detadphi histogram for forward coverage
+  //   vBin:  current vertex bin
+  //   flags: extra flags to handle calculations.
   //
   VertexBin* bin = 0;
   Int_t i = 0;
   Int_t nVtxBins = fVtxAxis->GetNbins();
 
+  TH2D& h = CombineHists(hcent, hfwd);
+
   while ((bin = static_cast<VertexBin*>(list.At(vtx+(nVtxBins*i))))) {
-    bin->FillHists(href, fCent, kFillRef);
-    bin->FillHists(hdiff, fCent, kFillDiff);
-    bin->CumulantsAccumulate(fCent);
+    if (!bin->FillHists(h, fCent, kFillBoth|flags|kReset)) return;
+    bin->CumulantsAccumulate3Cor(fCent);
     i++;
   }
 
-  return kTRUE;
+  return;
+}
+//_____________________________________________________________________
+TH2D& AliForwardFlowTaskQC::CombineHists(TH2D& hcent, TH2D& hfwd)
+{
+  // 
+  //  Combines a forward and central d^2N/detadphi histogram.
+  //  At some point it might need a flag to choose which histogram gets
+  //  priority when there is an overlap, at the moment the average is chosen
+  //
+  //  Parameters:
+  //    hcent: Central barrel detector
+  //    hfwd: Forward detector
+  //
+  //  Return: reference to combined hist
+  //
+
+  // If hists are the same (MC input) don't do anything
+  if (&hcent == &hfwd) return hcent;
+
+  fHistdNdedp3Cor.Reset();
+  // FMD, SPD input
+  if ((fFlowFlags & kFMD)) {
+    for (Int_t e = 1; e <= fHistdNdedp3Cor.GetNbinsX(); e++)  {
+      Double_t eta = fHistdNdedp3Cor.GetXaxis()->GetBinCenter(e);
+      Bool_t fwdCov = (hfwd.GetBinContent(e, 0) != 0);
+      Bool_t centCov = (hcent.GetBinContent(e, 0) != 0);
+      if (!fwdCov && !centCov) continue;
+      else fHistdNdedp3Cor.SetBinContent(e, 0, 1);
+      for (Int_t p = 1; p <= fHistdNdedp3Cor.GetNbinsY(); p++) {
+       Double_t phi = fHistdNdedp3Cor.GetYaxis()->GetBinCenter(p);
+       Int_t n = 0;
+       Double_t cont = 0.;
+       if (fwdCov) {
+         cont += hfwd.GetBinContent(e, p);
+         n++;
+       }
+       if (centCov) {
+         cont += hcent.GetBinContent(e, p);
+         n++;
+       }
+       if (cont == 0 || n == 0) continue;
+       cont /= n;
+       fHistdNdedp3Cor.Fill(eta, phi, cont);
+      }
+    }
+  // VZERO, SPD input, here we do not average but cut to avoid
+  // (too much) overlap.
+  } else if ((fFlowFlags & kVZERO)) {
+    // VZERO loop
+    for (Int_t eV = 1; eV <= hfwd.GetNbinsX(); eV++) {
+      Double_t eta = hfwd.GetXaxis()->GetBinLowEdge(eV)+0.1;
+      if (hfwd.GetBinContent(eV, 0) == 0) continue;
+      else { 
+        Int_t he = fHistdNdedp3Cor.GetXaxis()->FindBin(eta);
+       fHistdNdedp3Cor.SetBinContent(he, 0, 1);
+      }
+      for (Int_t p = 1; p <= hfwd.GetNbinsY(); p++) { 
+        Double_t phi = hfwd.GetYaxis()->GetBinCenter(p);
+        Double_t cont = hfwd.GetBinContent(eV, p);
+        fHistdNdedp3Cor.Fill(eta, phi, cont);
+      }
+    }
+    // SPD loop
+    Int_t eSs = hcent.GetXaxis()->FindBin(-1.99);
+    Int_t eSe = hcent.GetXaxis()->FindBin(1.99);
+    for (Int_t eS = eSs; eS <= eSe; eS++) {
+      Double_t eta = hcent.GetXaxis()->GetBinCenter(eS);
+      if (hcent.GetBinContent(eS, 0) == 0) continue;
+      else {
+        Int_t he = fHistdNdedp3Cor.GetXaxis()->FindBin(eta);
+       fHistdNdedp3Cor.SetBinContent(he, 0, 1);
+      }
+      for (Int_t p = 1; p <= hcent.GetNbinsY(); p++) {
+        Double_t phi = hcent.GetYaxis()->GetBinCenter(p);
+        Double_t cont = hcent.GetBinContent(eS, p);
+        fHistdNdedp3Cor.Fill(eta, phi, cont);
+      }
+    }
+  }
+  return fHistdNdedp3Cor;
+}
+//_____________________________________________________________________
+TObjArray* AliForwardFlowTaskQC::GetTracks() const
+{
+  // 
+  //  Get TPC tracks to use for reference flow.
+  //
+  //  Return: TObjArray with tracks
+  //
+  TObjArray* trList = 0;
+  // Get input type
+  UShort_t input = AliForwardUtil::CheckForAOD();
+  switch (input) {
+    // If AOD input, simply get the track array from the event
+    case 1: trList = static_cast<TObjArray*>(fAOD->GetTracks());
+           break;
+    case 2: {
+    // If ESD input get event, apply track cuts
+             AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
+             if (!esd) return 0;
+             // Warning! trList is now a new array, we need to delete it after use
+             // this is not a very good implementation!
+             trList = fESDTrackCuts->GetAcceptedTracks(esd, kTRUE);
+             break;
+           }
+    default: AliFatal("Neither ESD or AOD input. This should never happen");
+           break;
+  }
+  return trList;
 }
 //_____________________________________________________________________
 void AliForwardFlowTaskQC::Terminate(Option_t */*option*/)
 {
   //
-  // Calls the finalize function, done at the end of the analysis
+  //  Calls the finalize function, done at the end of the analysis
   //
-  // Parameters:
-  //  option: Not used
+  //  Parameters:
+  //   option: Not used
   //
 
   // Make sure pointers are set to the correct lists
@@ -349,47 +602,55 @@ void AliForwardFlowTaskQC::Terminate(Option_t */*option*/)
     TParameter<Double_t>* etaGap = new TParameter<Double_t>("EtaGap", fEtaGap);
     fOutputList->Add(etaGap);
   }
-
-  // We make summary histograms of accepted events.
-  TList* list = 0;
-  TH3D* hist = 0;
-  TH1D* cent = 0;
-  TObject* o = 0;
-  for (Int_t i = 1; i < fSumList->GetEntries(); i++) {
-    list = dynamic_cast<TList*>(fSumList->At(i));
-    if (!list) continue;
-    hist = dynamic_cast<TH3D*>(list->At(0));
-    if (!hist) continue;
-    const char* histname = hist->GetName();
-    TString name = "";
-    for (Int_t j = 0; ; j++) {
-      if (histname[j] == 'v') break;
-      name += histname[j];
-    }
-    if ((fFlowFlags & kEtaGap)) name += "_etaGap";
-    cent = (TH1D*)fOutputList->FindObject(name.Data());
-    if (!cent) {
-      cent = new TH1D(name.Data(), name.Data(), hist->GetNbinsY(), hist->GetYaxis()->GetXmin(), hist->GetYaxis()->GetXmax());
-      cent->GetXaxis()->Set(hist->GetNbinsY(), hist->GetYaxis()->GetXbins()->GetArray());
-      fOutputList->Add(cent);
-    }
-    for (Int_t k = 1; k <= hist->GetNbinsY(); k++) {
-      Double_t centrality = hist->GetYaxis()->GetBinCenter(k);
-      Double_t events = hist->GetBinContent(0, k, 0);
-      cent->Fill(centrality, events);
-    }
-    o = fOutputList->FindObject(Form("hQCQuality%s", name.Data()));
-    if (!o) MakeQualityHist(name);
-  }
+  // We only add axes in terminate, as TAxis object do not merge well,
+  // and so we get a mess when running on the grid if we put them in the sum list...
+  fVtxAxis->SetName("VtxAxis");
+  fOutputList->Add(fVtxAxis);
+  fCentAxis->SetName("CentAxis");
+  fOutputList->Add(fCentAxis);
 
   // Run finalize on VertexBins
   Finalize();
 
-  // Collect centralities
+  // Loop over output to get dN/deta hists - used for diagnostics
+  TIter next(fOutputList);
+  TObject* o = 0;
+  TString name;
+  TH2D* dNdeta = 0;
+  TH1D* cent = 0;
+  while ((o = next())) {
+    name = o->GetName();
+    if (name.Contains("dNdeta")) {
+      dNdeta = dynamic_cast<TH2D*>(o);
+      name.ReplaceAll("dNdeta", "cent");
+      name.ReplaceAll("Ref", "");
+      name.ReplaceAll("Diff", "");
+      cent = dynamic_cast<TH1D*>(fOutputList->FindObject(name.Data()));
+      if (!dNdeta || !cent) continue;
+      for (Int_t cBin = 1; cBin <= dNdeta->GetNbinsY(); cBin++) {
+        Double_t nEvents = cent->GetBinContent(cBin);
+        if (nEvents == 0) continue;
+       for (Int_t eBin = 1; eBin <= dNdeta->GetNbinsX(); eBin++) {
+         dNdeta->SetBinContent(eBin, cBin, dNdeta->GetBinContent(eBin, cBin)/nEvents);
+         dNdeta->SetBinError(eBin, cBin, dNdeta->GetBinError(eBin, cBin)/nEvents);
+       }
+      }
+    }
+  }   
+
+  // Loop over output and make 1D projections for fast look at results
   MakeCentralityHists(fOutputList);
   TList* vtxList = (TList*)fOutputList->FindObject("vtxList");
   if (vtxList) MakeCentralityHists(vtxList);
   TList* nuaList = (TList*)fOutputList->FindObject("NUATerms");
+  TIter nextNua(nuaList);
+  o = 0;
+  TH2D* h = 0;
+  while ((o = nextNua())) {
+    if (!(h = dynamic_cast<TH2D*>(o))) continue;
+    Double_t evts = h->GetBinContent(0, 0);
+    if (evts != 0) h->Scale(1./evts);
+  }
   if (nuaList) MakeCentralityHists(nuaList);
 
   PostData(2, fOutputList);
@@ -397,30 +658,19 @@ void AliForwardFlowTaskQC::Terminate(Option_t */*option*/)
   return;
 }
 //_____________________________________________________________________
-void AliForwardFlowTaskQC::AddFlowMoment(Short_t n)
-{
-    //
-    // Add a flow moment to be calculated
-    //
-    if (n > 10) AliFatal(Form("Too big moment added: %d (bug)", n));
-    Int_t size = fV.GetSize();
-    fV.Set(size+1);
-    fV.AddAt(n, size);
-}
-//_____________________________________________________________________
 void AliForwardFlowTaskQC::Finalize()
 {
   //
-  // Finalize command, called by Terminate()
+  //  Finalize command, called by Terminate()
   //
 
   // Reinitiate vertex bins if Terminate is called separately!
-  if (fBinsFMD.GetEntries() == 0) InitVertexBins();
+  if (fBinsForward.GetEntries() == 0) InitVertexBins();
 
   // Iterate over all vertex bins objects and finalize cumulants
   // calculations
-  EndVtxBinList(fBinsFMD);
-  EndVtxBinList(fBinsSPD);
+  EndVtxBinList(fBinsForward);
+  EndVtxBinList(fBinsCentral);
 
   return;
 } 
@@ -428,10 +678,10 @@ void AliForwardFlowTaskQC::Finalize()
 void AliForwardFlowTaskQC::EndVtxBinList(const TList& list) const
 {
   //
-  // Loop over VertexBin list and call terminate on each 
+  //  Loop over VertexBin list and call terminate on each 
   //
-  // Parameters:
-  //  list VertexBin list
+  //  Parameters:
+  //   list: VertexBin list
   //
   TIter next(&list);
   VertexBin* bin = 0;
@@ -441,22 +691,22 @@ void AliForwardFlowTaskQC::EndVtxBinList(const TList& list) const
   return;
 }
 // _____________________________________________________________________
-void AliForwardFlowTaskQC::MakeCentralityHists(TList* list)
+void AliForwardFlowTaskQC::MakeCentralityHists(TList* list) const
 {
   //
-  // Loop over a list containing a TProfile2D with flow results and project
+  // Loop over a list containing a TH2D with flow results
   // and project to TH1's in specific centrality bins
   //
   // Parameters:
-  //  list Flow results list
+  //  list: Flow results list
   //
-  TProfile2D* hist2D = 0;
+  TH2D* hist2D = 0;
   TList* centList = 0;
   TH1D* hist1D = 0;
   TObject* helper = 0;
-  TIter nextProfile(list);
-  while ((helper = dynamic_cast<TObject*>(nextProfile()))) {
-    if (!(hist2D = dynamic_cast<TProfile2D*>(helper))) continue;
+  TIter nextHist(list);
+  while ((helper = dynamic_cast<TObject*>(nextHist()))) {
+    if (!(hist2D = dynamic_cast<TH2D*>(helper))) continue;
     for (Int_t cBin = 1; cBin <= hist2D->GetNbinsY(); cBin++) {
       Int_t cMin = Int_t(hist2D->GetYaxis()->GetBinLowEdge(cBin));
       Int_t cMax = Int_t(hist2D->GetYaxis()->GetBinUpEdge(cBin));
@@ -478,27 +728,35 @@ void AliForwardFlowTaskQC::MakeCentralityHists(TList* list)
 Bool_t AliForwardFlowTaskQC::CheckEvent(const AliAODForwardMult* aodfm) 
 {
   // 
-  // Function to check that and AOD event meets the cuts
+  //  Function to check that an AOD event meets the cuts
   //
-  // Parameters: 
-  //  AliAODForwardMult: forward mult object with trigger and vertex info
+  //  Parameters: 
+  //   AliAODForwardMult: forward mult object with trigger and vertex info
   //
-  // Returns false if there is no trigger or if the centrality or vertex
-  // is out of range. Otherwise true.
+  //  Return: false if there is no trigger or if the centrality or vertex
+  //  is out of range. Otherwise true.
   //
 
   // First check for trigger
-  if (!CheckTrigger(aodfm)) return kFALSE;
+  if (!CheckTrigger(aodfm)) {
+    fHistEventSel->Fill(kNoTrigger);
+    return kFALSE;
+  }
 
   // Then check for centrality
-  if (!GetCentrality(aodfm)) return kFALSE;
+  if (!GetCentrality(aodfm)) {
+    return kFALSE;
+  }
 
   // And finally check for vertex
-  if (!GetVertex(aodfm)) return kFALSE;
+  if (!GetVertex(aodfm)) {
+    return kFALSE;
+  }
 
   // Ev. accepted - filling diag. hists
   fHistCent->Fill(fCent);
   fHistVertexSel->Fill(fVtx);
+  fHistEventSel->Fill(kOK);
   
   return kTRUE;
 }
@@ -506,88 +764,159 @@ Bool_t AliForwardFlowTaskQC::CheckEvent(const AliAODForwardMult* aodfm)
 Bool_t AliForwardFlowTaskQC::CheckTrigger(const AliAODForwardMult* aodfm) const 
 {
   //
-  // Function to look for a trigger string in the event.
+  //  Function to look for a trigger string in the event.
+  //  First check for info in forward mult object, if not there, use the AOD header
   //
-  // Parameters: 
-  //  AliAODForwardMult: forward mult object with trigger and vertex info
+  //  Parameters: 
+  //   AliAODForwardMult: forward mult object with trigger and vertex info
   //
-  // Returns true if offline trigger is present
+  //  Return: true if offline trigger is present
   //
-  return aodfm->IsTriggerBits(AliAODForwardMult::kOffline);
+  if (aodfm) return aodfm->IsTriggerBits(AliAODForwardMult::kOffline);
+  // this may need to be changed for 2011 data to handle kCentral and so on...
+  else return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))
+                 ->IsEventSelected() & AliVEvent::kMB);
 }
 // _____________________________________________________________________
 Bool_t AliForwardFlowTaskQC::GetCentrality(const AliAODForwardMult* aodfm) 
 {
   //
-  // Function to look get centrality of the event.
+  //  Function to look get centrality of the event.
+  //  First check for info in forward mult object, if not there, use the AOD header
   //
-  // Parameters: 
-  //  AliAODForwardMult: forward mult object with trigger and vertex info
+  //  Parameters: 
+  //   AliAODForwardMult: forward mult object with trigger and vertex info
   //
-  // Returns true if centrality determination is present
+  //  Return: true if centrality determination is present
   //
-  if (aodfm->HasCentrality()) {
-    fCent = (Double_t)aodfm->GetCentrality();
-    if (0. >= fCent || fCent >= 100.) return kFALSE;
-  }
-  else fCent = 97.5;
-
-  return kTRUE;
+  if (aodfm) {
+    if (aodfm->HasCentrality()) {
+      fCent = (Double_t)aodfm->GetCentrality();
+      if (fCentAxis->GetXmin() > fCent || fCent >= fCentAxis->GetXmax()) {
+       fHistEventSel->Fill(kInvCent);
+       return kFALSE;
+      }
+    }
+    else {
+      fCent = 97.5;
+      fHistEventSel->Fill(kNoCent);
+    }
+    return kTRUE;
+  } else {
+    AliCentrality* aodCent = fAOD->GetCentrality();
+    if (aodCent) {
+      fCent = (Double_t)aodCent->GetCentralityPercentile("V0M");
+      if (fCentAxis->GetXmin() > fCent || fCent >= fCentAxis->GetXmax()) {
+       fHistEventSel->Fill(kInvCent);
+       return kFALSE;
+      }
+    }
+    else {
+      fCent = 97.5;
+      fHistEventSel->Fill(kNoCent);
+    }
+    return kTRUE;
+  } 
 }
-// _____________________________________________________________________
+//_____________________________________________________________________
 Bool_t AliForwardFlowTaskQC::GetVertex(const AliAODForwardMult* aodfm) 
 {
   //
-  // Function to look for vertex determination in the event.
+  //  Function to look for vertex determination in the event.
+  //  First check for info in forward mult object, if not there, use the AOD header
   //
-  // Parameters: 
-  //  AliAODForwardMult: forward mult object with trigger and vertex info
+  //  Parameters: 
+  //   AliAODForwardMult: forward mult object with trigger and vertex info
   //
-  // Returns true if vertex is determined
+  //  Return: true if vertex is determined
   //
-  fVtx = aodfm->GetIpZ();
-  if (fVtx < fVtxAxis->GetXmin() || fVtx > fVtxAxis->GetXmax()) return kFALSE;
-
-  return kTRUE;
+  if (aodfm) {
+    if (aodfm->HasIpZ()) {
+      fVtx = aodfm->GetIpZ();
+      if (fVtx < fVtxAxis->GetXmin() || fVtx >= fVtxAxis->GetXmax()) {
+       fHistEventSel->Fill(kInvVtx);
+       return kFALSE;
+      }
+    } else {
+      fVtx = 9999;
+      fHistEventSel->Fill(kNoVtx);
+      return kFALSE;
+    }
+    return kTRUE;
+  } else {
+    AliAODVertex* aodVtx = fAOD->GetPrimaryVertex();
+    if (aodVtx) {
+      fVtx = aodVtx->GetZ();
+      if (fVtx < fVtxAxis->GetXmin() || fVtx >= fVtxAxis->GetXmax()) {
+       fHistEventSel->Fill(kInvVtx);
+       return kFALSE;
+      }
+    } else {
+      fVtx = 9999;
+      fHistEventSel->Fill(kNoVtx);
+      return kFALSE;
+    }
+    return kTRUE;
+  }
 }
-//_____________________________________________________________________
-void AliForwardFlowTaskQC::MakeQualityHist(const Char_t* name) const {
-  
-  TH1I* quality = new TH1I(Form("hQCQuality%s", name), 
-                     Form("hQCQuality%s", name),
-                     fV.GetSize()*8, 1, fV.GetSize()*8+1);
-  for (Int_t i = 0, j = 1; i < fV.GetSize(); i++) {
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{2} > 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{2} <= 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{2} > 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{2} <= 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{4} < 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{4} >= 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{4} < 0", fV.At(i)));
-    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{4} >= 0", fV.At(i)));
-  }
-
-  fOutputList->Add(quality);
+// _____________________________________________________________________
+void AliForwardFlowTaskQC::FillVZEROHist(AliAODVZERO* aodVZero)
+{
+  //
+  //  Loops over VZERO data object and fill up d^2N/detadphi histogram for flow analysis
+  //
+  //  Parameters:
+  //   aodVZero: VZERO AOD data object
+  //
+  Int_t ring = 0;
+  Int_t bin = 0;
+  Double_t eta = 0;
+  // Sort of right for 2010 data, do not use for 2011!
+  Double_t eq[64] = { 1.43536, 1.45727, 1.44993, 1.30051, 1.17425, 1.2335, 1.22247, 1.14362, 
+                     1.14647, 1.25208, 1.17681, 1.21642, 1.16604, 1.05532, 1.03212, 1.1032, 
+                     1.22941, 1.36986, 1.14652, 1.20056, 0.927086, 1.10809, 1.03343, 1.29472, 
+                     1.21204, 1.29217, 1.2003, 2.10382, 1.28513, 1.40558, 1.25784, 1.21848, 
+                     0.475162, 0.50421, 0.503617, 0.512471, 0.515276, 0.39831, 0.415199, 0.444664, 
+                     0.521922, 0.785915, 0.703658, 0.832479, 0.77461, 0.73129, 0.778697, 0.710265, 
+                     0.89686, 0.967688, 0.974225, 0.873445, 0.811096, 0.828493, 0.889609, 0.586056, 
+                     1.15877, 0.954656, 0.914557, 0.979028, 1.04907, 0.748518, 0.928043, 0.98175 };
+  for (Int_t i = 0; i < 64; i++) {
+    if (i % 8 == 0) {
+      ring++;
+      bin = (ring < 5 ? ring+1 : 15-ring);
+      eta = fHistdNdedpV0.GetXaxis()->GetBinCenter(bin);
+      fHistdNdedpV0.SetBinContent(bin, 0, 1);
+    }
+    Float_t amp = aodVZero->GetMultiplicity(i);
+    amp /= eq[i];
+    Double_t phi = TMath::Pi()/8.+TMath::TwoPi()*i/8.;
+    while (phi > TMath::TwoPi()) phi -= TMath::TwoPi();
+    fHistdNdedpV0.Fill(eta, phi, amp);
+  }
 }
 //_____________________________________________________________________
 AliForwardFlowTaskQC::VertexBin::VertexBin()
   : TNamed(),
-    fMoment(0),      // Flow moment for this vertexbin
-    fVzMin(0),       // Vertex z-coordinate min
-    fVzMax(0),       // Vertex z-coordinate max
+    fMaxMoment(0),   // Max flow moment for this vertexbin
+    fVzMin(0),       // Vertex z-coordinate min [cm]
+    fVzMax(0),       // Vertex z-coordinate max [cm]
     fType(),         // Data type name e.g., FMD/SPD/FMDTR/SPDTR/MC
-    fFlags(0),       // Use forward-backward symmetry, if detector allows it
+    fFlags(0),       // Flow flags
     fSigmaCut(-1),   // Sigma cut to remove outlier events
-    fEtaGap(2.),     // Eta gap value
+    fEtaGap(-1),     // Eta gap value
+    fEtaLims(),      // Limits for binning in 3Cor method
     fCumuRef(),      // Histogram for reference flow
     fCumuDiff(),     // Histogram for differential flow
-    fCumuHist(),     // Sum histogram for cumulants
-    fdNdedpAcc(),    // Diagnostics histogram to make acc. maps
+    fCumuHists(0,0), // CumuHists object for keeping track of results
+    fCumuNUARef(),   // Histogram for ref NUA terms
+    fCumuNUADiff(),  // Histogram for diff NUA terms
+    fdNdedpRefAcc(), // Diagnostics histogram for acc. maps
+    fdNdedpDiffAcc(),// Diagnostics histogram for acc. maps
     fOutliers(),     // Histogram for sigma distribution
     fDebug()         // Debug level
 {
   //
-  // Default constructor
+  //  Default constructor
   //
 }
 //_____________________________________________________________________
@@ -596,502 +925,737 @@ AliForwardFlowTaskQC::VertexBin::VertexBin(Int_t vLow, Int_t vHigh,
                                            UShort_t flags, Double_t cut,
                                            Double_t etaGap)
   : TNamed("", ""),
-    fMoment(moment),  // Flow moment for this vertexbin
-    fVzMin(vLow),     // Vertex z-coordinate min
-    fVzMax(vHigh),    // Vertex z-coordinate max
-    fType(name),      // Data type name e.g., FMD/SPD/FMDTR/SPDTR/MC
-    fFlags(flags),    // Use forward-backward symmetry, if detector allows it
-    fSigmaCut(cut),   // Sigma cut to remove outlier events
-    fEtaGap(etaGap),  // Eta gap value
-    fCumuRef(),       // Histogram for reference flow
-    fCumuDiff(),      // Histogram for differential flow
-    fCumuHist(),      // Sum histogram for cumulants
-    fdNdedpAcc(),     // Diagnostics histogram to make acc. maps
-    fOutliers(),      // Histogram for sigma distribution
-    fDebug(0)         // Debug level
+    fMaxMoment(moment),  // Max flow moment for this vertexbin
+    fVzMin(vLow),        // Vertex z-coordinate min [cm]
+    fVzMax(vHigh),       // Vertex z-coordinate max [cm]
+    fType(name),         // Data type name e.g., FMD/SPD/FMDTR/SPDTR/MC
+    fFlags(flags),       // Flow flags 
+    fSigmaCut(cut),      // Sigma cut to remove outlier events
+    fEtaGap(etaGap),     // Eta gap value
+    fEtaLims(),          // Limits for binning in 3Cor method
+    fCumuRef(),          // Histogram for reference flow
+    fCumuDiff(),         // Histogram for differential flow
+    fCumuHists(moment,0),// CumuHists object for keeping track of results
+    fCumuNUARef(),       // Histogram for ref NUA terms
+    fCumuNUADiff(),      // Histogram for diff NUA terms
+    fdNdedpRefAcc(),     // Diagnostics histogram for acc. maps
+    fdNdedpDiffAcc(),    // Diagnostics histogram for acc. maps
+    fOutliers(),         // Histogram for sigma distribution
+    fDebug(0)            // Debug level
 {
   //
-  // Constructor
+  //  Constructor
   //
-  // Parameters
-  //  vLow: min z-coordinate
-  //  vHigh: max z-coordinate
-  //  moment: flow moment
-  //  name: data type name (FMD/SPD/FMDTR/SPDTR/MC)
-  //  sym: data is symmetric in eta
+  //  Parameters
+  //   vLow: min z-coordinate
+  //   vHigh: max z-coordinate
+  //   moment: max flow moment
+  //   name: data type name (FMD/SPD/FMDTR/SPDTR/MC)
+  //   flags: flow flags
+  //   cut: sigma cut
+  //   etaGap: eta-gap value
   //
   fType.ToUpper();
 
-  SetName(Form("%svertexBin%d_%d_%d%s", fType.Data(), moment, vLow, vHigh, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  SetTitle(Form("%svertexBin%d_%d_%d%s", fType.Data(), moment, vLow, vHigh, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-
+  SetName(Form("%svertexBin%d_%d_%d%s", fType.Data(), moment, vLow, vHigh, GetQCType(fFlags)));
+  SetTitle(Form("%svertexBin%d_%d_%d%s", fType.Data(), moment, vLow, vHigh, GetQCType(fFlags)));
+  
   fDebug = AliAnalysisManager::GetAnalysisManager()->GetDebugLevel();
   if (fDebug > 0) Printf("AliForwardFlowTaskQC::VertexBin()\tDebugMode: %d", fDebug);
+
+  // Set limits for 3 correlator method
+  if ((fFlags & kFMD)) {
+    fEtaLims[0] = -6.;
+    fEtaLims[1] = -1.5;
+    fEtaLims[2] = -0.5;
+    fEtaLims[3] = 2.;
+    fEtaLims[4] = 3.;
+    fEtaLims[5] = 6.;
+  } else if ((fFlags & kVZERO)) {
+    fEtaLims[0] = -6;
+    fEtaLims[1] = -2.7;
+    fEtaLims[2] = -2.0;
+    fEtaLims[3] = 2.0;
+    fEtaLims[4] = 3.9;
+    fEtaLims[5] = 6;
+  }
 }
 //_____________________________________________________________________
 AliForwardFlowTaskQC::VertexBin&
 AliForwardFlowTaskQC::VertexBin::operator=(const AliForwardFlowTaskQC::VertexBin& o)
 {
   //
-  // Assignment operator
+  //  Assignment operator
   //
-  // Parameters
-  //  o: AliForwardFlowTaskQC::VertexBin
+  //  Parameters
+  //   o: AliForwardFlowTaskQC::VertexBin
   //
   if (&o == this) return *this;
-  fType         = o.fType;
-  fCumuRef      = o.fCumuRef;
-  fCumuDiff     = o.fCumuDiff;
-  fCumuHist     = o.fCumuHist;
-  fdNdedpAcc    = o.fdNdedpAcc;
-  fOutliers     = o.fOutliers;
-  fDebug        = o.fDebug;
+  fMaxMoment     = o.fMaxMoment;
+  fVzMin         = o.fVzMin;
+  fVzMax         = o.fVzMax;
+  fType          = o.fType;
+  fFlags         = o.fFlags;
+  fSigmaCut      = o.fSigmaCut;
+  fEtaGap        = o.fEtaGap;
+  fCumuRef       = o.fCumuRef;
+  fCumuDiff      = o.fCumuDiff;
+  fCumuHists     = o.fCumuHists;
+  fCumuNUARef    = o.fCumuNUARef;
+  fCumuNUADiff   = o.fCumuNUADiff;
+  fdNdedpRefAcc  = o.fdNdedpRefAcc;
+  fdNdedpDiffAcc = o.fdNdedpDiffAcc;
+  fOutliers      = o.fOutliers;
+  fDebug         = o.fDebug;
+  for (UInt_t i = 0; i < sizeof(fEtaLims)/sizeof(Int_t); i++) fEtaLims[i] = o.fEtaLims[i];
 
   return *this;
 }
 //_____________________________________________________________________
-void AliForwardFlowTaskQC::VertexBin::AddOutput(TList* outputlist)
+void AliForwardFlowTaskQC::VertexBin::AddOutput(TList* outputlist, TAxis* centAxis)
 {
   //
-  // Add histograms to outputlist
+  //  Add histograms to outputlist
   //
-  // Parameters
-  //  outputlist: list of histograms
+  //  Parameters
+  //   outputlist: list of histograms
+  //   centAxis: centrality axis
   //
 
   // First we try to find an outputlist for this vertexbin
-  TList* list = (TList*)outputlist->FindObject(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-
+  TList* list = (TList*)outputlist->FindObject(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
   // If it doesn't exist we make one
   if (!list) {
     list = new TList();
-    list->SetName(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")));
+    list->SetName(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
     outputlist->Add(list);
   }
 
+  // Get bin numbers and binning defined
+  Int_t nHBins = GetBinNumberSin();
+  Int_t nEtaBins = 48; 
+  if ((fFlags & k3Cor)) {
+    if ((fFlags & kFMD)) nEtaBins = 24;
+    else if ((fFlags & kVZERO)) nEtaBins = 19;
+  }
+  else if ((fFlags & kVZERO) && !fType.Contains("SPD")) nEtaBins = 11;
+  Double_t vzeroBins[12] = { -6, -3.7, -3.2, -2.7, -2.2, -1.7, 
+                             2.8, 3.4,  3.9,  4.5,  5.1, 6 };
+  Double_t vzeroBins2[20] = { -6, -3.7, -3.2, -2.7, -2.2, // VZERO
+                             -2.0, -1.5, -1.0, -0.5 , 0., 0.5, 1.0, 1.5, 2.0, // SPD
+                           2.8, 3.4,  3.9,  4.5,  5.1, 6 }; // VZERO
+  
   // We initiate the reference histogram
-  fCumuRef = new TH2D(Form("%s_v%d_%d_%d%s_ref", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                        Form("%s_v%d_%d_%d%s_ref", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                        2, -6., 6., 8, 0.5, 8.5);
-  fCumuRef->Sumw2();
-  //list->Add(fCumuRef);
+  fCumuRef = new TH2D(Form("%s_%d_%d%s_ref", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)), 
+                      Form("%s_%d_%d%s_ref", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)), 
+                       ((fFlags & k3Cor) ? 24 : ((fFlags & kEtaGap) || !(fFlags & kSymEta) ? 2 : 1)), -6., 6., 
+                        nHBins, 0.5, nHBins+0.5);
+  if ((fFlags & kVZERO) && (fFlags & k3Cor)) fCumuRef->GetXaxis()->Set(nEtaBins, vzeroBins2);
+  SetupNUALabels(fCumuRef->GetYaxis());
+  list->Add(fCumuRef);
 
   // We initiate the differential histogram
-  fCumuDiff = new TH2D(Form("%s_v%d_%d_%d%s_diff", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                       Form("%s_v%d_%d_%d%s_diff", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                       48, -6., 6., 8, 0.5, 8.5);
-  fCumuDiff->Sumw2();
-  //list->Add(fCumuDiff);
-
-  // Initiate the cumulant sum histogram
-  fCumuHist = new TH3D(Form("%sv%d_vertex_%d_%d%s_cumu", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                       Form("%sv%d_vertex_%d_%d%s_cumu", fType.Data(), fMoment, fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                       48, -6., 6., 20, 0., 100., 29, 0.5, 29.5);
-  fCumuHist->Sumw2();
-  SetupCentAxis(fCumuHist->GetYaxis());
-
-  list->Add(fCumuHist);
-
-  // We check for diagnostics histograms (only done per type and moment, not vertexbin)
-  // If they are not found we create them.
-  TList* dList = (TList*)outputlist->FindObject("Diagnostics");
-  if (!dList) AliFatal("No diagnostics list found, what kind of game are you running here?!?!");
-
-  // Acceptance hists are shared over all moments
-  fdNdedpAcc = (TH2F*)dList->FindObject(Form("h%sdNdedpAcc_%d_%d%s", fType.Data(), fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!fdNdedpAcc) {
-    fdNdedpAcc = new TH2F(Form("h%sdNdedpAcc_%d_%d%s", fType.Data(), fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")), 
-                          Form("%s acceptance map for %d cm < v_{z} < %d cm", fType.Data(), fVzMin, fVzMax),
-                          48, -6, 6, 20, 0, TMath::TwoPi());
-    fdNdedpAcc->Sumw2();
-    dList->Add(fdNdedpAcc);
+  fCumuDiff = new TH2D(Form("%s_%d_%d%s_diff", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                       Form("%s_%d_%d%s_diff", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                       nEtaBins, -6., 6., nHBins, 0.5, nHBins+0.5);
+  if ((fFlags & kVZERO)) {
+    if ((fFlags & k3Cor)) fCumuDiff->GetXaxis()->Set(nEtaBins, vzeroBins2);
+    else if (!fType.Contains("SPD")) fCumuDiff->GetXaxis()->Set(nEtaBins, vzeroBins);
+  }
+  SetupNUALabels(fCumuDiff->GetYaxis());
+  list->Add(fCumuDiff);
+
+  // Cumulants sum hists 
+  Int_t cBins = centAxis->GetNbins();
+  fCumuHists.ConnectList(Form("%sCumu_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)), list);
+  TH3D* cumuHist = 0;
+  Int_t nC2Bins = ((fFlags & kEtaGap) || (fFlags & k3Cor) ? kW2 : k3pWeight);
+  Int_t nC4Bins = ((fFlags & kEtaGap) ? kW2 : ((fFlags & k3Cor) ? kW4 : kSinphi1phi2phi3p));
+  for (Int_t n = 2; n <= fMaxMoment; n++) {
+    // Initiate the ref cumulant sum histogram
+    cumuHist = new TH3D(Form("%sv%d_vertex_%d_%d%s_cumuRef", fType.Data(), n, fVzMin, fVzMax, GetQCType(fFlags)),
+                       Form("%sv%d_vertex_%d_%d%s_cumuRef", fType.Data(), n, fVzMin, fVzMax, GetQCType(fFlags)), 
+                        ((fFlags & k3Cor) ? 24 : ((fFlags & kEtaGap) || !(fFlags & kSymEta) ? 2 : 1)), -6., 6., 
+                       cBins, 0., 100., nC2Bins, 0.5, nC2Bins+0.5);
+    if ((fFlags & kVZERO) && (fFlags & k3Cor)) cumuHist->GetXaxis()->Set(nEtaBins, vzeroBins2);
+    cumuHist->GetYaxis()->Set(cBins, centAxis->GetXbins()->GetArray());
+    fCumuHists.Add(cumuHist);
+    // Initiate the diff cumulant sum histogram
+    cumuHist = new TH3D(Form("%sv%d_vertex_%d_%d%s_cumuDiff", fType.Data(), n, fVzMin, fVzMax, GetQCType(fFlags)),
+                       Form("%sv%d_vertex_%d_%d%s_cumuDiff", fType.Data(), n, fVzMin, fVzMax, GetQCType(fFlags)),
+                       nEtaBins, -6., 6., cBins, 0., 100., nC4Bins, 0.5, nC4Bins+0.5);
+    if ((fFlags & kVZERO)) {
+      if ((fFlags & k3Cor)) cumuHist->GetXaxis()->Set(nEtaBins, vzeroBins2);
+      else if (!fType.Contains("SPD")) cumuHist->GetXaxis()->Set(nEtaBins, vzeroBins);
+    }
+    cumuHist->GetYaxis()->Set(cBins, centAxis->GetXbins()->GetArray());
+    fCumuHists.Add(cumuHist);
   }
 
-  if (!(fFlags & kEtaGap)) {
-    fOutliers = new TH2F(Form("hOutliers_%s_v%d_%d_%d", fType.Data(), fMoment, fVzMin, fVzMax),
-                       Form("Maximum #sigma from mean N_{ch} pr. bin - %s v_{%d}, %d < v_{z} < %d",
-                       fType.Data(), fMoment, fVzMin, fVzMax), 
-                       20, 0., 100., 500, 0., (fType.Contains("MC") ? 15. : 5.));
-    dList->Add(fOutliers);
+  // Common NUA histograms
+  fCumuNUARef = new TH3D(Form("%s_vertex_%d_%d%s_cumuNUARef", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                        Form("%s_vertex_%d_%d%s_cumuNUARef", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                        ((fFlags & k3Cor) ? 24 : ((fFlags & kEtaGap) || !(fFlags & kSymEta) ? 2 : 1)), -6., 6., 
+                          cBins, 0., 100., nHBins, 0.5, nHBins+0.5);
+  if ((fFlags & kVZERO) && (fFlags & k3Cor)) fCumuNUARef->GetXaxis()->Set(nEtaBins, vzeroBins2);
+  fCumuNUARef->GetYaxis()->Set(cBins, centAxis->GetXbins()->GetArray());
+  SetupNUALabels(fCumuNUARef->GetZaxis());
+  fCumuNUARef->Sumw2();
+  list->Add(fCumuNUARef);
+  
+  fCumuNUADiff = new TH3D(Form("%s_vertex_%d_%d%s_cumuNUADiff", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                          Form("%s_vertex_%d_%d%s_cumuNUADiff", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                          nEtaBins, -6., 6., cBins, 0., 100., nHBins, 0.5, nHBins+0.5);
+  if ((fFlags & kVZERO)) {
+    if ((fFlags & k3Cor)) fCumuNUADiff->GetXaxis()->Set(nEtaBins, vzeroBins2);
+    else if (!fType.Contains("SPD")) fCumuNUADiff->GetXaxis()->Set(nEtaBins, vzeroBins);
   }
+  fCumuNUADiff->GetYaxis()->Set(cBins, centAxis->GetXbins()->GetArray());
+  SetupNUALabels(fCumuNUADiff->GetZaxis());
+  fCumuNUADiff->Sumw2();
+  list->Add(fCumuNUADiff);
 
+  // We create diagnostic histograms.
+  TList* dList = (TList*)outputlist->FindObject("Diagnostics");
+  if (!dList) AliFatal("No diagnostics list found");
+
+  // Acceptance hist
+  Double_t nPhiBins = ((fFlags & kFMD) ? 20 : 8);
+  fdNdedpRefAcc = new TH2F(Form("h%sdNdedpRefAcc_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+    Form("%s reference flow acceptance map for %d cm < v_{z} < %d cm", fType.Data(), fVzMin, fVzMax),
+    nEtaBins, -6, 6, nPhiBins, 0, TMath::TwoPi());
+  if ((fFlags & kVZERO)) {
+    if ((fFlags & k3Cor)) fdNdedpRefAcc->GetXaxis()->Set(nEtaBins, vzeroBins2);
+    else if (!fType.Contains("SPD")) fdNdedpRefAcc->GetXaxis()->Set(nEtaBins, vzeroBins);
+  }
+  dList->Add(fdNdedpRefAcc);
+
+  fdNdedpDiffAcc = new TH2F(Form("h%sdNdedpDiffAcc_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+    Form("%s differential flow acceptance map for %d cm < v_{z} < %d cm", fType.Data(), fVzMin, fVzMax),
+    nEtaBins, -6, 6, nPhiBins, 0, TMath::TwoPi());
+  if ((fFlags & kVZERO)) {
+    if ((fFlags & k3Cor)) fdNdedpDiffAcc->GetXaxis()->Set(nEtaBins, vzeroBins2);
+    else if (!fType.Contains("SPD")) fdNdedpDiffAcc->GetXaxis()->Set(nEtaBins, vzeroBins);
+  }
+  dList->Add(fdNdedpDiffAcc);
+  
+  fOutliers = new TH2F(Form("hOutliers_%s_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)),
+                      Form("Maximum #sigma from mean N_{ch} pr. bin - %s, %d < v_{z} < %d",
+                      fType.Data(), fVzMin, fVzMax), 
+                      20, 0., 100., 500, 0., (fType.Contains("MC") ? 15. : 5.));
+  dList->Add(fOutliers);
+  
+  return;
 }
 //_____________________________________________________________________
-Bool_t AliForwardFlowTaskQC::VertexBin::FillHists(const TH2D& dNdetadphi, Double_t cent, EFillFlow mode) 
+Bool_t AliForwardFlowTaskQC::VertexBin::FillHists(TH2D& dNdetadphi, Double_t cent, UShort_t mode) 
 {
   // 
-  // Fill reference and differential eta-histograms
+  //  Fill reference and differential eta-histograms
   //
-  // Parameters:
-  //  dNdetadphi: 2D histogram with input data
+  //  Parameters:
+  //   dNdetadphi: 2D histogram with input data
+  //   cent: centrality
+  //   mode: filling mode: kFillRef/kFillDiff/kFillBoth
   //
-
   if (!fCumuRef) AliFatal("You have not called AddOutput() - Terminating!");
-
   Bool_t useEvent = kTRUE;
 
   // Fist we reset histograms
-  if ((mode & kFillRef)) fCumuRef->Reset();
-  fCumuDiff->Reset();
-
-  // Numbers to cut away bad events and acceptance.
-  Double_t runAvg = 0;
-  Double_t max = 0;
-  Int_t nInAvg = 0;
-  Double_t avgSqr = 0;
-  Int_t nBins = (dNdetadphi.GetNbinsX() * 6) / (fCumuDiff->GetNbinsX() * 5);
-  Int_t nInBin = 0;
-  Int_t nCurBin = 0, nPrevBin = 0;
-  Int_t nCurRefBin = 0, nPrevRefBin = 0;
-  Int_t nBadBins = 0;
-  Bool_t firstBin = kFALSE;
-  Double_t limit = 9999.;
-  Bool_t mc = fType.Contains("MC");
+  if ((mode & kReset)) {
+    if ((mode & kFillRef))  fCumuRef->Reset();
+    if ((mode & kFillDiff)) fCumuDiff->Reset();
+  }
 
   // Then we loop over the input and calculate sum cos(k*n*phi)
   // and fill it in the reference and differential histograms
-  Double_t eta, phi, weight;
-  Double_t dQnRe = 0, dQ2nRe = 0, dQnIm = 0, dQ2nIm = 0;
-
+  Int_t nBadBins = 0;
+  Double_t limit = 9999.;
   for (Int_t etaBin = 1; etaBin <= dNdetadphi.GetNbinsX(); etaBin++) {
-    eta = dNdetadphi.GetXaxis()->GetBinCenter(etaBin);
-    nCurBin = fCumuDiff->GetXaxis()->FindBin(eta);
-    nCurRefBin = fCumuRef->GetXaxis()->FindBin(eta);
-    // If we have moved to a new bin in the flow hist, and less than half the eta
-    // region has been covered by it we cut it away.
-    if (nPrevBin == 0) nPrevBin = nCurBin;
-    if (nPrevRefBin == 0) nPrevRefBin = nCurRefBin;
-    if (nCurBin != nPrevBin) {
-      if (nInBin <= nBins/2) {
-       for (Int_t qBin = 1; qBin <= fCumuDiff->GetNbinsY(); qBin++) {
-         Double_t removeContent = fCumuDiff->GetBinContent(nPrevBin, qBin);
-         Double_t removeEta = fCumuDiff->GetXaxis()->GetBinCenter(nPrevBin);
-         if (nCurRefBin != nPrevRefBin) {
-           if (!(fFlags & kEtaGap)) {
-             fCumuRef->Fill(removeEta, qBin, -removeContent);
-             if ((fFlags & kSymEta)) {
-               fCumuRef->Fill(-1.*removeEta, qBin, -removeContent);
-             }
-           }
-           if ((fFlags & kEtaGap)) {
-             switch(qBin) {
-               case kHmultA: fCumuRef->Fill(removeEta, qBin, removeContent);  break;
-               case kHQnReA: fCumuRef->Fill(removeEta, qBin, removeContent);  break;
-               case kHQnImA: fCumuRef->Fill(removeEta, qBin, removeContent);  break;
-               case kHmultB: fCumuRef->Fill(-removeEta, qBin, removeContent); break;
-               case kHQnReB: fCumuRef->Fill(-removeEta, qBin, removeContent); break;
-               case kHQnImB: fCumuRef->Fill(-removeEta, qBin, removeContent); break;
-               default: break;
-             }
-           }
-         }
-         fCumuDiff->SetBinContent(nPrevBin, qBin, 0);
-         fCumuDiff->SetBinError(nPrevBin, qBin, 0);
-       }
-      }
-      nInBin = 0;
-      nPrevBin = nCurBin;
-      if (nCurRefBin != nPrevRefBin) nPrevRefBin = nCurRefBin;
-    }
-    
-    Bool_t data = kFALSE;
+    Double_t eta = dNdetadphi.GetXaxis()->GetBinCenter(etaBin);
+    // Numbers to cut away bad events
+    Double_t runAvg = 0;
+    Double_t max = 0;
+    Int_t nInAvg = 0;
+    Double_t avgSqr = 0;
     for (Int_t phiBin = 0; phiBin <= dNdetadphi.GetNbinsY(); phiBin++) {
+      // Check for acceptance
       if (phiBin == 0) {
-       if (dNdetadphi.GetBinContent(etaBin, phiBin) == 0) break;
-       else data = kTRUE;
-       if ((fFlags & kEtaGap) && (mode & kFillRef) && TMath::Abs(eta) < fEtaGap) break;
+        if (dNdetadphi.GetBinContent(etaBin, 0) == 0) break;
+        // Central limit for eta gap break for reference flow
+       if ((fFlags & kEtaGap) && (mode & kFillRef) && 
+            TMath::Abs(eta) < fEtaGap) break;
+       // Backward and forward eta gap break for reference flow
        if ((fFlags & kEtaGap) && (mode & kFillRef) && TMath::Abs(eta) > TMath::Abs(limit)) break;
-       if (data && !firstBin) {
-         limit = dNdetadphi.GetXaxis()->GetBinLowEdge(etaBin);
-         firstBin = kTRUE;
-       }
+       if (limit > 1e3) limit = dNdetadphi.GetXaxis()->GetBinLowEdge(etaBin);
        continue;
-      }
-      phi = dNdetadphi.GetYaxis()->GetBinCenter(phiBin);
-      if ((fFlags & kEtaGap) && !mc && (phiBin == 7 || phiBin == 14 || phiBin == 15 || phiBin == 20)) continue;
-      weight = dNdetadphi.GetBinContent(etaBin, phiBin);
-
+      } // End of phiBin == 0
+      Double_t phi = dNdetadphi.GetYaxis()->GetBinCenter(phiBin);
+      Double_t weight = dNdetadphi.GetBinContent(etaBin, phiBin);
+        
       // We calculate the average Nch per. bin
       avgSqr += weight*weight;
       runAvg += weight;
       nInAvg++;
       if (weight == 0) continue;
       if (weight > max) max = weight;
-
-      dQnRe = weight*TMath::Cos(fMoment*phi);
-      dQnIm = weight*TMath::Sin(fMoment*phi);
-      dQ2nRe = weight*TMath::Cos(2.*fMoment*phi);
-      dQ2nIm = weight*TMath::Sin(2.*fMoment*phi);
-
-      // if we do not have an eta gap we fill the ref sums in eta
-      if (!(fFlags & kEtaGap)) {
-       if ((mode & kFillRef)){
-         fCumuRef->Fill(eta, kHmultA, weight);
-         fCumuRef->Fill(eta, kHQnReA, dQnRe);
-         fCumuRef->Fill(eta, kHQnImA, dQnIm);
-         fCumuRef->Fill(eta, kHmultB, weight);
-         fCumuRef->Fill(eta, kHQnReB, dQnRe);
-         fCumuRef->Fill(eta, kHQnImB, dQnIm);
-         
-         fCumuRef->Fill(eta, kHQ2nRe, dQ2nRe);
-         fCumuRef->Fill(eta, kHQ2nIm, dQ2nIm);
-       }
+      
+      // Fill into Cos() and Sin() hists
+      if ((mode & kFillRef)) {
+       fCumuRef->Fill(eta, 0., weight);// mult goes in underflowbin - no visual, but not needed?
+        fdNdedpRefAcc->Fill(eta, phi, weight);
       }
-      // if we have an eta gap or we symmetrize around eta = 0
-      // we fill in -eta
-      if ((fFlags & kEtaGap)){
-       if ((mode & kFillRef)){
-         fCumuRef->Fill(eta, kHmultA, weight);
-         fCumuRef->Fill(eta, kHQnReA, dQnRe);
-         fCumuRef->Fill(eta, kHQnImA, dQnIm);
-         
-         fCumuRef->Fill(-eta, kHmultB, weight);
-         fCumuRef->Fill(-eta, kHQnReB, dQnRe);
-         fCumuRef->Fill(-eta, kHQnImB, dQnIm);
-       }
+      if ((mode & kFillDiff)) {
+       fCumuDiff->Fill(eta, 0., weight);
+        fdNdedpDiffAcc->Fill(eta, phi, weight);
       }
-      
-      if ((fFlags & kSymEta)){
-       if ((mode & kFillRef)){
-         fCumuRef->Fill(-eta, kHmultA, weight);
-         fCumuRef->Fill(-eta, kHQnReA, dQnRe);
-         fCumuRef->Fill(-eta, kHQnImA, dQnIm);
-         fCumuRef->Fill(-eta, kHmultB, weight);
-         fCumuRef->Fill(-eta, kHQnReB, dQnRe);
-         fCumuRef->Fill(-eta, kHQnImB, dQnIm);
-         
-         fCumuRef->Fill(-eta, kHQ2nRe, dQ2nRe);
-         fCumuRef->Fill(-eta, kHQ2nIm, dQ2nIm);
+      for (Int_t n = 1; n <= 2*fMaxMoment; n++) {
+       Double_t cosBin = fCumuDiff->GetYaxis()->GetBinCenter(GetBinNumberCos(n));
+       Double_t sinBin = fCumuDiff->GetYaxis()->GetBinCenter(GetBinNumberSin(n));
+       Double_t cosnPhi = weight*TMath::Cos(n*phi);
+       Double_t sinnPhi = weight*TMath::Sin(n*phi);
+        // fill ref
+       if ((mode & kFillRef)) {
+         fCumuRef->Fill(eta, cosBin, cosnPhi);
+         fCumuRef->Fill(eta, sinBin, sinnPhi);
        }
-      }
-
-      // If we fill diff flow, we always fill it in eta
-      // This is filled always, to be able to remove edge effects
-      // It is reset both for kFillRef and kFillDiff to make the eta
-      // gap analysis work.
-      fCumuDiff->Fill(eta, kHmultA, weight);
-      fCumuDiff->Fill(eta, kHQnReA, dQnRe);
-      fCumuDiff->Fill(eta, kHQnImA, dQnIm);
-      fCumuDiff->Fill(eta, kHQ2nRe, dQ2nRe);
-      fCumuDiff->Fill(eta, kHQ2nIm, dQ2nIm);
-
-      // Fill acc. map
-      if ((mode & kFillDiff)) fdNdedpAcc->Fill(eta, phi, weight);
-    }
-    if (data) {
-      nInBin++;
-    }
+       // fill diff
+       if ((mode & kFillDiff)) {
+         fCumuDiff->Fill(eta, cosBin, cosnPhi);
+         fCumuDiff->Fill(eta, sinBin, sinnPhi);
+       }
+      } // End of NUA loop
+    } // End of phi loop
     // Outlier cut calculations
-    if (nInAvg > 3 && !(fFlags & kEtaGap)) {
+    if (nInAvg > 0) {
       runAvg /= nInAvg;
       avgSqr /= nInAvg;
-      Double_t stdev = TMath::Sqrt(nInAvg/(nInAvg-1))*TMath::Sqrt(avgSqr - runAvg*runAvg);
+      Double_t stdev = (nInAvg > 1 ? TMath::Sqrt(nInAvg/(nInAvg-1))*TMath::Sqrt(avgSqr - runAvg*runAvg) : 0);
       Double_t nSigma = (stdev == 0 ? 0 : (max-runAvg)/stdev);
-      if (fSigmaCut > 0. && nSigma >= fSigmaCut && cent <= 60) nBadBins++;
+      if (fSigmaCut > 0. && nSigma >= fSigmaCut && cent < 60) nBadBins++;
       else nBadBins = 0;
       fOutliers->Fill(cent, nSigma);
       // We still finish the loop, for fOutliers to make sense, 
-      // but we do no keep the event for analysis
+      // but we do no keep the event for analysis 
       if (nBadBins > 3) useEvent = kFALSE;
     }
-    runAvg = 0;
-    avgSqr = 0;
-    nInAvg = 0;
-    max = 0;
-  }
+  } // End of eta bin
 
   return useEvent;
 }
 //_____________________________________________________________________
-void AliForwardFlowTaskQC::VertexBin::CumulantsAccumulate(Double_t cent, Bool_t skipFourP
+Bool_t AliForwardFlowTaskQC::VertexBin::FillTracks(TObjArray* trList, UShort_t mode
 {
   // 
-  // Calculate the Q cumulant of order fMoment
+  //  Fill reference and differential eta-histograms
   //
-  // Parameters:
-  //  cent: Centrality of event
+  //  Parameters:
+  //   trList: list of tracks
+  //   mode: filling mode: kFillRef/kFillDiff/kFillBoth
   //
-
   if (!fCumuRef) AliFatal("You have not called AddOutput() - Terminating!");
 
-  // We create the objects needed for the analysis
-  Double_t dQnReA = 0, dQnImA = 0, multA; 
-  Double_t dQnReB = 0, dQnImB = 0, multB;
-  Double_t dQ2nRe = 0, dQ2nIm = 0;
-  Double_t pnRe = 0, p2nRe = 0, qnRe = 0, q2nRe = 0, pnIm = 0, p2nIm = 0, qnIm = 0, q2nIm = 0;
-  Double_t two = 0, four = 0, twoPrime = 0, fourPrime = 0;
-  Double_t cosPhi1Phi2 = 0, cosPhi1Phi2Phi3m = 0;
-  Double_t sinPhi1Phi2 = 0, sinPhi1Phi2Phi3m = 0;
-  Double_t cosPsi1Phi2 = 0, cosPsi1Phi2Phi3m = 0, cosPsi1Phi2Phi3p = 0;
-  Double_t sinPsi1Phi2 = 0, sinPsi1Phi2Phi3m = 0, sinPsi1Phi2Phi3p = 0;
-  Double_t eta = 0;
-  Double_t mp = 0, mq = 0;
-  Double_t w2 = 0, w4 = 0, w2p = 0, w4p = 0;
-  Int_t refEtaBin = 0;
+  // Fist we reset histograms
+  if ((mode & kReset)) {
+    if ((mode & kFillRef))  fCumuRef->Reset();
+    if ((mode & kFillDiff)) fCumuDiff->Reset();
+  }
 
-  // We loop over the data 1 time!
-  for (Int_t etaBin = 1; etaBin <= fCumuDiff->GetNbinsX(); etaBin++) {
-    eta = fCumuDiff->GetXaxis()->GetBinCenter(etaBin);
-    refEtaBin = fCumuRef->GetXaxis()->FindBin(eta);
-    // The values for each individual etaBin bins are reset
-    multA = 0;
-    multB = 0;
-    dQnReA = 0;
-    dQnImA = 0;
-    dQnReB = 0;
-    dQnImB = 0;
-    dQ2nRe = 0;
-    dQ2nIm = 0;
-    
-    mp = 0;
-    pnRe = 0;
-    pnIm = 0;
-    p2nRe = 0;
-    p2nIm = 0;
-
-    mq = 0;
-    qnRe = 0;
-    qnIm = 0;
-    q2nRe = 0;
-    q2nIm = 0;
-
-    // Reference flow
-    multA  = fCumuRef->GetBinContent(refEtaBin, kHmultA);
-    multB  = fCumuRef->GetBinContent(refEtaBin, kHmultB);
-    dQnReA = fCumuRef->GetBinContent(refEtaBin, kHQnReA);
-    dQnImA = fCumuRef->GetBinContent(refEtaBin, kHQnImA);
-    dQnReB = fCumuRef->GetBinContent(refEtaBin, kHQnReB);
-    dQnImB = fCumuRef->GetBinContent(refEtaBin, kHQnImB);
-    dQ2nRe = fCumuRef->GetBinContent(refEtaBin, kHQ2nRe);
-    dQ2nIm = fCumuRef->GetBinContent(refEtaBin, kHQ2nIm);
-    
-    // For each etaBin bin the necessary values for differential flow
-    // is calculated. .
-    mp = fCumuDiff->GetBinContent(etaBin, kHmultA);
-    pnRe = fCumuDiff->GetBinContent(etaBin, kHQnReA);
-    pnIm = fCumuDiff->GetBinContent(etaBin, kHQnImA);
-    p2nRe = fCumuDiff->GetBinContent(etaBin, kHQ2nRe);
-    p2nIm = fCumuDiff->GetBinContent(etaBin, kHQ2nIm);
-    
-    if (multA <= 3) continue; 
-    if (mp == 0) continue; 
-    
-    // The reference flow is calculated 
-    // 2-particle
-    if (!(fFlags & kEtaGap)) {
-      w2 = multA * (multA - 1.);
-      two = dQnReA*dQnReA + dQnImA*dQnImA - multA;
-    } else {
-      w2 = multA * multB;
-      two = dQnReA*dQnReB + dQnImA*dQnImB;
+  UShort_t input = AliForwardUtil::CheckForAOD();
+  // Then we loop over the input and calculate sum cos(k*n*phi)
+  // and fill it in the reference and differential histograms
+  Int_t nTr = trList->GetEntries();
+  if (nTr == 0) return kFALSE;
+  AliVTrack* tr = 0;
+  AliAODTrack* aodTr = 0;
+  // Cuts for AOD tracks (have already been applied to ESD tracks)
+  const Double_t pTMin = 0.5, pTMax = 20., etaMin = -0.8, etaMax = 0.8, minNCl = 50;
+  for (Int_t i = 0; i < nTr; i++) { // track loop
+    tr = (AliVTrack*)trList->At(i);
+    if (!tr) continue;
+    if (input == 1) { // If AOD input
+      // A dynamic cast would be more safe here, but this is faster...
+      aodTr = (AliAODTrack*)tr;
+      if (aodTr->GetID() > -1) continue;
+      if (!aodTr->TestFilterBit(128) || !aodTr->Pt() > pTMax || aodTr->Pt() < pTMin || 
+       aodTr->Eta() > etaMax || aodTr->Eta() < etaMin || aodTr->GetTPCNcls() < minNCl) continue;
     }
-    
-    fCumuHist->Fill(eta, cent, kW2Two, two);
-    fCumuHist->Fill(eta, cent, kW2, w2);
-
-    fCumuHist->Fill(eta, cent, kQnReA, dQnReA);
-    fCumuHist->Fill(eta, cent, kQnImA, dQnImA);
-    fCumuHist->Fill(eta, cent, kMA, multA);
-    
-    fCumuHist->Fill(eta, cent, kQnReB, dQnReB);
-    fCumuHist->Fill(eta, cent, kQnImB, dQnImB);
-    fCumuHist->Fill(eta, cent, kMB, multB);
-
-    // Differential flow calculations for each eta bin is done:
-    // 2-particle differential flow
-    if (!(fFlags & kEtaGap)) {
-      mq = mp;
-      qnRe = pnRe;
-      qnIm = pnIm;
-      q2nRe = p2nRe;
-      q2nIm = p2nIm;
+    // Track accepted
+    Double_t eta = tr->Eta();
+    Double_t phi = tr->Phi();
+    if ((mode & kFillRef)) {
+      fCumuRef->Fill(eta, 0.);// mult goes in underflowbin - no visual, but not needed?
+      fdNdedpRefAcc->Fill(eta, phi);
     }
+    if ((mode & kFillDiff)) {
+      fCumuDiff->Fill(eta, 0);
+      fdNdedpDiffAcc->Fill(eta, phi);
+    }
+    for (Int_t n = 1; n <= 2*fMaxMoment; n++) {
+      Double_t cosBin = fCumuDiff->GetYaxis()->GetBinCenter(GetBinNumberCos(n));
+      Double_t sinBin = fCumuDiff->GetYaxis()->GetBinCenter(GetBinNumberSin(n));
+      Double_t cosnPhi = TMath::Cos(n*phi);
+      Double_t sinnPhi = TMath::Sin(n*phi);
+      // fill ref
+      if ((mode & kFillRef)) {
+       fCumuRef->Fill(eta, cosBin, cosnPhi);
+       fCumuRef->Fill(eta, sinBin, sinnPhi);
+      }
+      // fill diff
+      if ((mode & kFillDiff)) {
+       fCumuDiff->Fill(eta, cosBin, cosnPhi);
+       fCumuDiff->Fill(eta, sinBin, sinnPhi);
+      }
+    } // End of NUA loop
+  } // End of track loop
+  return kTRUE;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::CumulantsAccumulate(Double_t cent) 
+{
+  // 
+  //  Calculate the Q cumulant up to order fMaxMoment
+  //
+  //  Parameters:
+  //   cent: centrality of event
+  //
+  if (!fCumuRef) AliFatal("You have not called AddOutput() - Terminating!");
 
-    w2p = mp * multB - mq;
-    twoPrime = pnRe*dQnReB + pnIm*dQnImB - mq;
-    
-    fCumuHist->Fill(eta, cent, kw2two, twoPrime);
-    fCumuHist->Fill(eta, cent, kw2, w2p);
-
-    fCumuHist->Fill(eta, cent, kpnRe, pnRe);
-    fCumuHist->Fill(eta, cent, kpnIm, pnIm);
-    fCumuHist->Fill(eta, cent, kmp, mp);
-
-    if ((fFlags & kEtaGap) || skipFourP) continue;
-    // The reference flow is calculated 
-    // 4-particle
-    w4 = multA * (multA - 1.) * (multA - 2.) * (multA - 3.);
-  
-    four = 2.*multA*(multA-3.) + TMath::Power((TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.)),2.)
-             -4.*(multA-2.)*(TMath::Power(dQnReA,2.) + TMath::Power(dQnImA,2.))
-             -2.*(TMath::Power(dQnReA,2.)*dQ2nRe+2.*dQnReA*dQnImA*dQ2nIm-TMath::Power(dQnImA,2.)*dQ2nRe)
-             +(TMath::Power(dQ2nRe,2.)+TMath::Power(dQ2nIm,2.));
+  // Fill out NUA hists
+  for (Int_t etaBin = 1; etaBin <= fCumuRef->GetNbinsX(); etaBin++) {
+    Double_t eta = fCumuRef->GetXaxis()->GetBinCenter(etaBin);
+    if (fCumuRef->GetBinContent(etaBin, 0) == 0) continue;
+    for (Int_t qBin = 0; qBin <= fCumuRef->GetNbinsY(); qBin++) {
+      fCumuNUARef->Fill(eta, cent, Double_t(qBin), fCumuRef->GetBinContent(etaBin, qBin));
+    }
+  }
+  for (Int_t etaBin = 1; etaBin <= fCumuDiff->GetNbinsX(); etaBin++) {
+    Double_t eta = fCumuDiff->GetXaxis()->GetBinCenter(etaBin);
+    if (fCumuDiff->GetBinContent(etaBin, 0) == 0) continue;
+    for (Int_t qBin = 0; qBin <= fCumuDiff->GetNbinsY(); qBin++) {
+      fCumuNUADiff->Fill(eta, cent, Double_t(qBin), fCumuDiff->GetBinContent(etaBin, qBin));
+    }
+  }
 
-    fCumuHist->Fill(eta, cent, kW4Four, four);
-    fCumuHist->Fill(eta, cent, kW4, w4);
+  // We create the objects needed for the analysis
+  TH3D* cumuRef = 0; 
+  TH3D* cumuDiff = 0; 
+  // For each n we loop over the hists
+  for (Int_t n = 2; n <= fMaxMoment; n++) {
+    cumuRef  = (TH3D*)fCumuHists.Get('r',n);
+    cumuDiff = (TH3D*)fCumuHists.Get('d',n);
+    Int_t prevRefEtaBin = 0;
+
+    // Per mom. quantities
+    Double_t dQnReA = 0, dQnImA = 0, multA = 0; 
+    Double_t dQnReB = 0, dQnImB = 0, multB = 0;
+    Double_t dQ2nReA = 0, dQ2nImA = 0;
+    Double_t two = 0, w2 = 0, four = 0, w4 = 0;
+    Double_t cosPhi1Phi2 = 0, cosPhi1Phi2Phi3m = 0;
+    Double_t sinPhi1Phi2 = 0, sinPhi1Phi2Phi3m = 0;
+    for (Int_t etaBin = 1; etaBin <= fCumuDiff->GetNbinsX(); etaBin++) {
+      Double_t eta = fCumuDiff->GetXaxis()->GetBinCenter(etaBin);
+      Int_t refEtaBinA = fCumuRef->GetXaxis()->FindBin(eta);
+      Int_t refEtaBinB = fCumuRef->GetXaxis()->FindBin(-eta);
+      if (refEtaBinA != prevRefEtaBin) {
+       prevRefEtaBin = refEtaBinA;
+       // Reference flow
+       multA  = fCumuRef->GetBinContent(refEtaBinA, 0);
+       dQnReA = fCumuRef->GetBinContent(refEtaBinA, GetBinNumberCos(n));
+       dQnImA = fCumuRef->GetBinContent(refEtaBinA, GetBinNumberSin(n));
+       dQ2nReA = fCumuRef->GetBinContent(refEtaBinA, GetBinNumberCos(n*2));
+       dQ2nImA = fCumuRef->GetBinContent(refEtaBinA, GetBinNumberSin(n*2));
+       
+       multB  = fCumuRef->GetBinContent(refEtaBinB, 0);
+       dQnReB = fCumuRef->GetBinContent(refEtaBinB, GetBinNumberCos(n));
+       dQnImB = fCumuRef->GetBinContent(refEtaBinB, GetBinNumberSin(n));
+
+       if (multA <= 3 || multB <= 3) return; 
+       // The reference flow is calculated 
+       // 2-particle
+       if ((fFlags & kStdQC)) {
+         w2 = multA * (multA - 1.);
+         two = dQnReA*dQnReA + dQnImA*dQnImA - multA;
+       } else {
+         w2 = multA * multB;
+         two = dQnReA*dQnReB + dQnImA*dQnImB;
+       }
+       cumuRef->Fill(eta, cent, kW2Two, two);
+       cumuRef->Fill(eta, cent, kW2, w2);
+
+       // The reference flow is calculated 
+       // 4-particle
+       if ((fFlags & kStdQC)) {
+         w4 = multA * (multA - 1.) * (multA - 2.) * (multA - 3.);
+       
+         four = 2.*multA*(multA-3.) + TMath::Power((TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.)),2.)
+                  -4.*(multA-2.)*(TMath::Power(dQnReA,2.) + TMath::Power(dQnImA,2.))
+                  -2.*(TMath::Power(dQnReA,2.)*dQ2nReA+2.*dQnReA*dQnImA*dQ2nImA-TMath::Power(dQnImA,2.)*dQ2nReA)
+                  +(TMath::Power(dQ2nReA,2.)+TMath::Power(dQ2nImA,2.));
+
+         cumuRef->Fill(eta, cent, kW4Four, four);
+         cumuRef->Fill(eta, cent, kW4, w4);
+
+         // NUA
+         cosPhi1Phi2 = dQnReA*dQnReA - dQnImA*dQnImA - dQ2nReA;
+         sinPhi1Phi2 = 2.*dQnReA*dQnImA - dQ2nImA;
+
+         cosPhi1Phi2Phi3m = dQnReA*(TMath::Power(dQnReA,2)+TMath::Power(dQnImA,2))
+                             -dQnReA*dQ2nReA-dQnImA*dQ2nImA-2.*(multA-1)*dQnReA;
+
+         sinPhi1Phi2Phi3m = -dQnImA*(TMath::Power(dQnReA,2)+TMath::Power(dQnImA,2))
+                             +dQnReA*dQ2nImA-dQnImA*dQ2nReA+2.*(multA-1)*dQnImA; 
+
+         cumuRef->Fill(eta, cent, kCosphi1phi2, cosPhi1Phi2);
+         cumuRef->Fill(eta, cent, kSinphi1phi2, sinPhi1Phi2);
+         cumuRef->Fill(eta, cent, kCosphi1phi2phi3m, cosPhi1Phi2Phi3m);
+         cumuRef->Fill(eta, cent, kSinphi1phi2phi3m, sinPhi1Phi2Phi3m);
+         cumuRef->Fill(eta, cent, k3pWeight, multA*(multA-1.)*(multA-2.));
+       } // End of QC{4}
+      } // End of reference flow
+      // For each etaBin bin the necessary values for differential flow is calculated
+      Double_t mp = fCumuDiff->GetBinContent(etaBin, 0);
+      Double_t pnRe = fCumuDiff->GetBinContent(etaBin, GetBinNumberCos(n));
+      Double_t pnIm = fCumuDiff->GetBinContent(etaBin, GetBinNumberSin(n));
+      Double_t p2nRe = fCumuDiff->GetBinContent(etaBin, GetBinNumberCos(n*2));
+      Double_t p2nIm = fCumuDiff->GetBinContent(etaBin, GetBinNumberSin(n*2));
+      if (mp == 0) continue;
+      Double_t mq = 0;
+      Double_t qnRe = 0;
+      Double_t qnIm = 0;
+      Double_t q2nRe = 0;
+      Double_t q2nIm = 0;
+
+      // Differential flow calculations for each eta bin is done:
+      // 2-particle differential flow
+      if ((fFlags & kStdQC) && !(fFlags & kTPC)) {
+       mq = mp;
+       qnRe = pnRe;
+       qnIm = pnIm;
+       q2nRe = p2nRe;
+       q2nIm = p2nIm;
+      }
 
-    cosPhi1Phi2 = dQnReA*dQnReA - dQnImA*dQnImA - dQ2nRe;
-    sinPhi1Phi2 = 2.*dQnReA*dQnImA - dQ2nIm;
+      Double_t w2p = mp * multB - mq;
+      Double_t twoPrime = pnRe*dQnReB + pnIm*dQnImB - mq;
       
-    cosPhi1Phi2Phi3m = dQnReA*(TMath::Power(dQnReA,2)+TMath::Power(dQnImA,2))-dQnReA*dQ2nRe-dQnImA*dQ2nIm-2.*(multA-1)*dQnReA;
-
-    sinPhi1Phi2Phi3m = -dQnImA*(TMath::Power(dQnReA,2)+TMath::Power(dQnImA,2))+dQnReA*dQ2nIm-dQnImA*dQ2nRe+2.*(multA-1)*dQnImA; 
+      cumuDiff->Fill(eta, cent, kW2Two, twoPrime);
+      cumuDiff->Fill(eta, cent, kW2, w2p);
 
-    fCumuHist->Fill(eta, cent, kCosphi1phi2, cosPhi1Phi2);
-    fCumuHist->Fill(eta, cent, kSinphi1phi2, sinPhi1Phi2);
-    fCumuHist->Fill(eta, cent, kCosphi1phi2phi3m, cosPhi1Phi2Phi3m);
-    fCumuHist->Fill(eta, cent, kSinphi1phi2phi3m, sinPhi1Phi2Phi3m);
-    fCumuHist->Fill(eta, cent, kMm1m2, multA*(multA-1.)*(multA-2.));
-
-    // Differential flow calculations for each eta bin bin is done:
-    // 4-particle differential flow
-    w4p = (mp * multA - 3.*mq)*(multA - 1.)*(multA - 2.);
-    fourPrime = (TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.))*(pnRe*dQnReA+pnIm*dQnImA)
-                      - q2nRe*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))
-                      - 2.*q2nIm*dQnReA*dQnImA
-                      - pnRe*(dQnReA*dQ2nRe+dQnImA*dQ2nIm)
-                      + pnIm*(dQnImA*dQ2nRe-dQnReA*dQ2nIm)
-                      - 2.*multA*(pnRe*dQnReA+pnIm*dQnImA)
-                      - 2.*(TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.))*mq                      
-                      + 6.*(qnRe*dQnReA+qnIm*dQnImA)                                            
-                      + 1.*(q2nRe*dQ2nRe+q2nIm*dQ2nIm)                      
-                      + 2.*(pnRe*dQnReA+pnIm*dQnImA)                       
-                      + 2.*mq*multA                      
-                      - 6.*mq; 
-
-    fCumuHist->Fill(eta, cent, kw4four, fourPrime);
-    fCumuHist->Fill(eta, cent, kw4, w4p);
-
-    cosPsi1Phi2 = pnRe*dQnReA - pnIm*dQnImA - q2nRe;
-    sinPsi1Phi2 = pnRe*dQnImA + pnIm*dQnReA - q2nIm;
-
-    cosPsi1Phi2Phi3p = pnRe*(TMath::Power(dQnImA,2.)+TMath::Power(dQnReA,2.)-multA)
-                          - 1.*(q2nRe*dQnReA+q2nIm*dQnImA)  
-                          - mq*dQnReA+2.*qnRe;
-    sinPsi1Phi2Phi3p = pnIm*(TMath::Power(dQnImA,2.)+TMath::Power(dQnReA,2.)-multA)
-                          - 1.*(q2nIm*dQnReA-q2nRe*dQnImA)  
-                          - mq*dQnImA+2.*qnIm; 
-
-    cosPsi1Phi2Phi3m = pnRe*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))+2.*pnIm*dQnReA*dQnImA
-                          - 1.*(pnRe*dQ2nRe+pnIm*dQ2nIm)  
-                          - 2.*mq*dQnReA+2.*qnRe;
-    sinPsi1Phi2Phi3m = pnIm*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))-2.*pnRe*dQnReA*dQnImA
-                          - 1.*(pnIm*dQ2nRe-pnRe*dQ2nIm)
-                          + 2.*mq*dQnImA-2.*qnIm;
+      if ((fFlags & kEtaGap)) continue;
+      // Differential flow calculations for each eta bin bin is done:
+      // 4-particle differential flow
+      Double_t w4p = (mp * multA - 3.*mq)*(multA - 1.)*(multA - 2.);
+   
+      Double_t fourPrime = (TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.))*(pnRe*dQnReA+pnIm*dQnImA)
+                         - q2nRe*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))
+                         - 2.*q2nIm*dQnReA*dQnImA
+                         - pnRe*(dQnReA*dQ2nReA+dQnImA*dQ2nImA)
+                         + pnIm*(dQnImA*dQ2nReA-dQnReA*dQ2nImA)
+                         - 2.*multA*(pnRe*dQnReA+pnIm*dQnImA)
+                         - 2.*(TMath::Power(dQnReA,2.)+TMath::Power(dQnImA,2.))*mq 
+                         + 6.*(qnRe*dQnReA+qnIm*dQnImA)
+                         + 1.*(q2nRe*dQ2nReA+q2nIm*dQ2nImA)
+                         + 2.*(pnRe*dQnReA+pnIm*dQnImA) 
+                         + 2.*mq*multA 
+                         - 6.*mq; 
+
+      cumuDiff->Fill(eta, cent, kW4Four, fourPrime);
+      cumuDiff->Fill(eta, cent, kW4, w4p);
+
+      // NUA
+      Double_t cosPsi1Phi2 = pnRe*dQnReA - pnIm*dQnImA - q2nRe;
+      Double_t sinPsi1Phi2 = pnRe*dQnImA + pnIm*dQnReA - q2nIm;
+
+      Double_t cosPsi1Phi2Phi3p = pnRe*(TMath::Power(dQnImA,2.)+TMath::Power(dQnReA,2.)-multA)
+                           - 1.*(q2nRe*dQnReA+q2nIm*dQnImA)  
+                           - mq*dQnReA+2.*qnRe;
+   
+      Double_t sinPsi1Phi2Phi3p = pnIm*(TMath::Power(dQnImA,2.)+TMath::Power(dQnReA,2.)-multA)
+                           - 1.*(q2nIm*dQnReA-q2nRe*dQnImA)  
+                           - mq*dQnImA+2.*qnIm; 
+
+      Double_t cosPsi1Phi2Phi3m = pnRe*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))+2.*pnIm*dQnReA*dQnImA
+                           - 1.*(pnRe*dQ2nReA+pnIm*dQ2nImA)  
+                           - 2.*mq*dQnReA+2.*qnRe;
+   
+      Double_t sinPsi1Phi2Phi3m = pnIm*(TMath::Power(dQnReA,2.)-TMath::Power(dQnImA,2.))-2.*pnRe*dQnReA*dQnImA
+                           - 1.*(pnIm*dQ2nReA-pnRe*dQ2nImA)
+                           + 2.*mq*dQnImA-2.*qnIm;
+
+      cumuDiff->Fill(eta, cent, kCosphi1phi2, cosPsi1Phi2);
+      cumuDiff->Fill(eta, cent, kSinphi1phi2, sinPsi1Phi2);
+      cumuDiff->Fill(eta, cent, kCosphi1phi2phi3m, cosPsi1Phi2Phi3m);
+      cumuDiff->Fill(eta, cent, kSinphi1phi2phi3m, sinPsi1Phi2Phi3m);
+      cumuDiff->Fill(eta, cent, k3pWeight, (mp*multA-2.*mq)*(multA-1.));
+      cumuDiff->Fill(eta, cent, kCosphi1phi2phi3p, cosPsi1Phi2Phi3p);
+      cumuDiff->Fill(eta, cent, kSinphi1phi2phi3p, sinPsi1Phi2Phi3p); 
+    } // End of eta loop
+    // Event count
+    cumuRef->Fill(-7., cent, -0.5, 1.);
+  } // End of moment loop
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::GetLimits(Int_t bin, Int_t& aLow, Int_t& aHigh,
+                                                Int_t& bLow, Int_t& bHigh) const
+{
+  //
+  //  Get the limits for the 3 correlator method
+  //
+  //  Parameters: 
+  //   bin  : reference bin #
+  //   aLow : Lowest bin to be included in v_A calculations
+  //   aHigh: Highest bin to be included in v_A calculations
+  //   bLow : Lowest bin to be included in v_B calculations
+  //   bHigh: Highest bin to be included in v_B calculations
+  //
+  if ((fFlags & kFMD)) {
+    switch(bin) {
+      case 0:
+       aLow = 14; aHigh = 15;
+       bLow = 20; bHigh = 22;
+       break;
+      case 1:
+       aLow = 16; aHigh = 16;
+       bLow = 21; bHigh = 22;
+       break;
+      case 2:
+       aLow =  6; aHigh =  7;
+       bLow = 21; bHigh = 22;
+       break;
+      case 3:
+       aLow =  6; aHigh =  7;
+       bLow = 12; bHigh = 12; 
+       break;
+      case 4:
+       aLow =  6; aHigh =  8;
+       bLow = 13; bHigh = 14;
+       break;
+      default:
+       AliFatal(Form("No limits for this eta region! (%d)", bin));
+    }
+  } 
+  else if ((fFlags & kVZERO)) {
+    switch(bin) {
+      case 0:
+        aLow =  6; aHigh = 13;
+        bLow = 17; bHigh = 18;
+       break;
+      case 1:
+        aLow =  6; aHigh =  9;
+        bLow = 17; bHigh = 18;
+       break;
+      case 2:
+        aLow =  2; aHigh =  3;
+        bLow = 17; bHigh = 18;
+       break;
+      case 3:
+        aLow =  2; aHigh =  3;
+        bLow =  6; bHigh =  9;
+       break;
+      case 4:
+        aLow =  2; aHigh =  3;
+        bLow =  6; bHigh = 13;
+       break;
+      default:
+       AliFatal(Form("No limits for this eta region! (%d)", bin));
+    }
+  }
+  // Try to catch cases where fEtaLimits and these values do not correspond to each other
+  if (aHigh > fCumuNUARef->GetNbinsX() || bHigh > fCumuNUARef->GetNbinsX()) 
+    AliFatal(Form("Limits outside vtx range! (%d) - aHigh = %d, bHigh = %d, Nbins = %d", 
+      bin, aHigh, bHigh, fCumuNUARef->GetNbinsX()));
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::CumulantsAccumulate3Cor(Double_t cent) 
+{
+  // 
+  //  Calculate the Q cumulant up to order fMaxMoment
+  //
+  //  Parameters:
+  //   cent: centrality of event
+  //
+  if (!fCumuRef) AliFatal("You have not called AddOutput() - Terminating!");
 
-    fCumuHist->Fill(eta, cent, kCospsi1phi2, cosPsi1Phi2);
-    fCumuHist->Fill(eta, cent, kSinpsi1phi2, sinPsi1Phi2);
-    fCumuHist->Fill(eta, cent, kCospsi1phi2phi3m, cosPsi1Phi2Phi3m);
-    fCumuHist->Fill(eta, cent, kSinpsi1phi2phi3m, sinPsi1Phi2Phi3m);
-    fCumuHist->Fill(eta, cent, kmpmq, (mp*multA-2.*mq)*(multA-1.));
-    fCumuHist->Fill(eta, cent, kCospsi1phi2phi3p, cosPsi1Phi2Phi3p);
-    fCumuHist->Fill(eta, cent, kSinpsi1phi2phi3p, sinPsi1Phi2Phi3p); 
+  // Fill out NUA hists
+  for (Int_t etaBin = 1; etaBin <= fCumuRef->GetNbinsX(); etaBin++) {
+    Double_t eta = fCumuRef->GetXaxis()->GetBinCenter(etaBin);
+    if (fCumuRef->GetBinContent(etaBin, 0) == 0) continue;
+    for (Int_t qBin = 0; qBin <= fCumuRef->GetNbinsY(); qBin++) {
+      fCumuNUARef->Fill(eta, cent, Double_t(qBin), fCumuRef->GetBinContent(etaBin, qBin));
+    }
   }
-  // Event count
-  fCumuHist->Fill(-7., cent, -0.5, 1.);
+  for (Int_t etaBin = 1; etaBin <= fCumuDiff->GetNbinsX(); etaBin++) {
+    Double_t eta = fCumuDiff->GetXaxis()->GetBinCenter(etaBin);
+    if (fCumuDiff->GetBinContent(etaBin, 0) == 0) continue;
+    for (Int_t qBin = 0; qBin <= fCumuDiff->GetNbinsY(); qBin++) {
+      fCumuNUADiff->Fill(eta, cent, Double_t(qBin), fCumuDiff->GetBinContent(etaBin, qBin));
+    }
+  }
+
+  // We create the objects needed for the analysis
+  TH3D* cumuRef = 0; 
+  TH3D* cumuDiff = 0; 
+  // For each n we loop over the hists
+  for (Int_t n = 2; n <= fMaxMoment; n++) {
+    cumuRef  = (TH3D*)fCumuHists.Get('r',n);
+    cumuDiff = (TH3D*)fCumuHists.Get('d',n);
+
+    // Per mom. quantities
+    Int_t prevLim = 0;
+    Int_t aLow = 0, aHigh = 0, bLow = 0, bHigh = 0;
+    Double_t dQnReA = 0, dQnImA = 0, multA = 0; 
+    Double_t dQnReB = 0, dQnImB = 0, multB = 0;
+    Double_t two = 0, w2 = 0;
+    for (Int_t etaBin = 1; etaBin <= fCumuDiff->GetNbinsX(); etaBin++) {
+      Double_t eta = fCumuDiff->GetXaxis()->GetBinCenter(etaBin);
+      if (fEtaLims[prevLim] < eta) {
+        GetLimits(prevLim, aLow, aHigh, bLow, bHigh);
+       prevLim++;
+       multA = 0; dQnReA = 0; dQnImA = 0;
+       multB = 0; dQnReB = 0; dQnImB = 0;
+       // Reference flow
+        for (Int_t a = aLow; a <= aHigh; a++) {
+         multA  += fCumuRef->GetBinContent(a, 0);
+         dQnReA += fCumuRef->GetBinContent(a, GetBinNumberCos(n));
+         dQnImA += fCumuRef->GetBinContent(a, GetBinNumberSin(n));
+       }
+       for (Int_t b = bLow; b <= bHigh; b++) {
+         multB  += fCumuRef->GetBinContent(b, 0);
+         dQnReB += fCumuRef->GetBinContent(b, GetBinNumberCos(n));
+         dQnImB += fCumuRef->GetBinContent(b, GetBinNumberSin(n));
+       }
+       // The reference flow is calculated 
+       // 2-particle
+       w2 = multA * multB;
+       two = dQnReA*dQnReB + dQnImA*dQnImB;
+      } // End of reference flow
+      cumuRef->Fill(eta, cent, kW2Two, two);
+      cumuRef->Fill(eta, cent, kW2, w2);
+
+      // For each etaBin bin the necessary values for differential flow is calculated
+      Double_t mp = fCumuDiff->GetBinContent(etaBin, 0);
+      Double_t pnRe = fCumuDiff->GetBinContent(etaBin, GetBinNumberCos(n));
+      Double_t pnIm = fCumuDiff->GetBinContent(etaBin, GetBinNumberSin(n));
+      if (mp == 0) continue;
+
+      // Differential flow calculations for each eta bin is done:
+      // 2-particle differential flow
+      Double_t w2pA = mp * multA;
+      Double_t twoPrimeA = pnRe*dQnReA + pnIm*dQnImA;
+      cumuDiff->Fill(eta, cent, kW2Two, twoPrimeA);
+      cumuDiff->Fill(eta, cent, kW2, w2pA);
+
+      Double_t w2pB = mp * multB;
+      Double_t twoPrimeB = pnRe*dQnReB + pnIm*dQnImB;
+      cumuDiff->Fill(eta, cent, kW4Four, twoPrimeB);
+      cumuDiff->Fill(eta, cent, kW4, w2pB);
+     } // End of eta loop
+    // Event count
+    cumuRef->Fill(-7., cent, -0.5, 1.);
+  } // End of moment loop
+  return;
 
 }
 //_____________________________________________________________________
@@ -1104,365 +1668,1246 @@ void AliForwardFlowTaskQC::VertexBin::CumulantsTerminate(TList* inlist, TList* o
   //   inlist: input sumlist
   //   outlist: output result list 
   //
-
+  
   // Re-find cumulants hist if Terminate is called separately
-  if (!fCumuHist) {
-    TList* list = (TList*)inlist->FindObject(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-    fCumuHist = (TH3D*)list->FindObject(Form("%sv%d_vertex_%d_%d%s_cumu", fType.Data(), fMoment, 
-                                        fVzMin, fVzMax, ((fFlags & kEtaGap) ? "_etaGap" : "")));
+  if (!fCumuHists.IsConnected()) {
+    TList* list = (TList*)inlist->FindObject(Form("%svertex_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
+    fCumuHists.ConnectList(Form("%sCumu_%d_%d%s", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)), list);
+
+    if (!fCumuNUARef) 
+      fCumuNUARef = (TH3D*)list->FindObject(Form("%s_vertex_%d_%d%s_cumuNUARef", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
+    if (!fCumuNUADiff) 
+      fCumuNUADiff = (TH3D*)list->FindObject(Form("%s_vertex_%d_%d%s_cumuNUADiff", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
   }
-
-  // Create outputs
+  // Clone to avoid normalization problems when redoing terminate locally
+  fCumuNUARef = (TH3D*)fCumuNUARef->Clone(Form("%s_vertex_%d_%d%s_cumuNUARefNorm", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
+  fCumuNUADiff = (TH3D*)fCumuNUADiff->Clone(Form("%s_vertex_%d_%d%s_cumuNUADiffNorm", fType.Data(), fVzMin, fVzMax, GetQCType(fFlags)));
+
+  // Diagnostics histograms
+  TH2I* quality = (TH2I*)outlist->FindObject(Form("hQCQuality%s%s", fType.Data(), GetQCType(fFlags)));
+  if (!quality) { 
+    quality = MakeQualityHist(Form("hQCQuality%s%s", fType.Data(), GetQCType(fFlags)));
+    outlist->Add(quality);
+  }
+  TH1D* cent = (TH1D*)outlist->FindObject(Form("%s%s_cent", fType.Data(), GetQCType(fFlags)));
+  if (!cent) {
+    cent = new TH1D(Form("%s%s_cent", fType.Data(), GetQCType(fFlags)), 
+                    Form("%s%s_cent", fType.Data(), GetQCType(fFlags)), 
+                fCumuNUARef->GetNbinsY(), fCumuNUARef->GetYaxis()->GetXmin(), fCumuNUARef->GetYaxis()->GetXmax());
+    cent->GetXaxis()->Set(fCumuNUARef->GetNbinsY(), fCumuNUARef->GetYaxis()->GetXbins()->GetArray());
+    outlist->Add(cent);
+  }
+  TH2D* dNdetaRef = (TH2D*)outlist->FindObject(Form("%s%s_dNdetaRef", fType.Data(), GetQCType(fFlags)));
+  if (!dNdetaRef) {
+    dNdetaRef = new TH2D(Form("%s%s_dNdetaRef", fType.Data(), GetQCType(fFlags)), 
+                               Form("%s%s_dNdetaRef", fType.Data(), GetQCType(fFlags)), 
+                fCumuNUARef->GetNbinsX(), fCumuNUARef->GetXaxis()->GetXmin(), fCumuNUARef->GetXaxis()->GetXmax(),
+                fCumuNUARef->GetNbinsY(), fCumuNUARef->GetYaxis()->GetXmin(), fCumuNUARef->GetYaxis()->GetXmax());
+    dNdetaRef->GetYaxis()->Set(fCumuNUARef->GetNbinsY(), fCumuNUARef->GetYaxis()->GetXbins()->GetArray());
+    dNdetaRef->Sumw2();
+    outlist->Add(dNdetaRef);
+  }
+  TH2D* dNdetaDiff = (TH2D*)outlist->FindObject(Form("%s%s_dNdetaDiff", fType.Data(), GetQCType(fFlags)));
+  if (!dNdetaDiff) {
+    dNdetaDiff = new TH2D(Form("%s%s_dNdetaDiff", fType.Data(), GetQCType(fFlags)), 
+                                Form("%s%s_dNdetaDiff", fType.Data(), GetQCType(fFlags)), 
+                fCumuNUADiff->GetNbinsX(), fCumuNUADiff->GetXaxis()->GetXmin(), fCumuNUADiff->GetXaxis()->GetXmax(),
+                fCumuNUADiff->GetNbinsY(), fCumuNUADiff->GetYaxis()->GetXmin(), fCumuNUADiff->GetYaxis()->GetXmax());
+    dNdetaDiff->GetYaxis()->Set(fCumuNUADiff->GetNbinsY(), fCumuNUADiff->GetYaxis()->GetXbins()->GetArray());
+    dNdetaDiff->Sumw2();
+    outlist->Add(dNdetaDiff);
+  }
+  
+  // Setting up outputs
+  // Create output lists and diagnostics
   TList* vtxList = (TList*)outlist->FindObject("vtxList");
   if (!vtxList) {
     vtxList = new TList();
     vtxList->SetName("vtxList");
     outlist->Add(vtxList);
   }
+  vtxList->Add(fCumuNUARef);
+  vtxList->Add(fCumuNUADiff);
+  // Setup output profiles
+  CumuHistos cumu2(fMaxMoment, ((fFlags & kNUAcorr) ? 2 : 0));
+  CumuHistos cumu4(fMaxMoment, ((fFlags & kNUAcorr) ? 1 : 0));
+
+  cumu2.ConnectList(Form("%sQC2_Cumu%s_vtx_%d_%d", fType.Data(), GetQCType(fFlags), fVzMin, fVzMax), vtxList);
+  if ((fFlags & kStdQC)) 
+    cumu4.ConnectList(Form("%sQC4_Cumu%s_vtx_%d_%d", fType.Data(), GetQCType(fFlags), fVzMin, fVzMax), vtxList);
+
+  for (Int_t n = 2; n <= fMaxMoment; n++) {
+    // 2-particle 
+    cumu2.Add(MakeOutputHist(2, n, "Ref", CumuHistos::kNoNUA));
+    if ((fFlags & k3Cor)){
+      cumu2.Add(MakeOutputHist(2, n, "DiffA", CumuHistos::kNoNUA));
+      cumu2.Add(MakeOutputHist(2, n, "DiffB", CumuHistos::kNoNUA));
+    } else {
+      cumu2.Add(MakeOutputHist(2, n, "Diff", CumuHistos::kNoNUA));
+    }
+    // 4-particle      
+    if ((fFlags & kStdQC)) {
+      cumu4.Add(MakeOutputHist(4, n, "Ref", CumuHistos::kNoNUA));
+      cumu4.Add(MakeOutputHist(4, n, "Diff", CumuHistos::kNoNUA));
+    }
+  } // End of v_n result loop
+  // NUA corrected
+  if ((fFlags & kNUAcorr)) {
+    for (Int_t n = 2; n <= fMaxMoment; n++) {
+      // 2-particle 
+      cumu2.Add(MakeOutputHist(2, n, "Ref", CumuHistos::kNUAOld));
+      if ((fFlags & k3Cor)) {
+        cumu2.Add(MakeOutputHist(2, n, "DiffA", CumuHistos::kNUAOld));
+        cumu2.Add(MakeOutputHist(2, n, "DiffB", CumuHistos::kNUAOld));
+      } else {
+       cumu2.Add(MakeOutputHist(2, n, "Diff", CumuHistos::kNUAOld));
+      }
+      // 4-particle      
+      if ((fFlags & kStdQC)) {
+       cumu4.Add(MakeOutputHist(4, n, "Ref", CumuHistos::kNUAOld));
+       cumu4.Add(MakeOutputHist(4, n, "Diff", CumuHistos::kNUAOld));
+      }   
+    }
+    for (Int_t n = 2; n <= fMaxMoment; n++) {
+      // 2-particle 
+      cumu2.Add(MakeOutputHist(2, n, "Ref", CumuHistos::kNUA));
+      if ((fFlags & k3Cor)) {
+       cumu2.Add(MakeOutputHist(2, n, "DiffA", CumuHistos::kNUA));
+       cumu2.Add(MakeOutputHist(2, n, "DiffB", CumuHistos::kNUA));
+      } else {
+       cumu2.Add(MakeOutputHist(2, n, "Diff", CumuHistos::kNUA));
+      }
+    }
+  }
+
+  // Calculating the cumulants
+  if ((fFlags & k3Cor)) {
+    Calculate3CorFlow(cumu2, quality, cent, dNdetaRef, dNdetaDiff);
+  } else {
+    CalculateReferenceFlow(cumu2, cumu4, quality, cent, dNdetaRef);
+    CalculateDifferentialFlow(cumu2, cumu4, quality, dNdetaDiff);
+  }
+  if ((fFlags & kNUAcorr)) {
+    SolveCoupledFlowEquations(cumu2, 'r');
+    if ((fFlags & k3Cor)) {
+      SolveCoupledFlowEquations(cumu2, 'a');
+      SolveCoupledFlowEquations(cumu2, 'b');
+    } else {
+      SolveCoupledFlowEquations(cumu2, 'd');
+    }
+  }
+  // Add to output for immediate viewing - individual vtx bins are used for final results
+  AddVertexBins(cumu2, outlist, ((fFlags & kNUAcorr) ? 2 : 0));
+  if ((fFlags & kStdQC)) AddVertexBins(cumu4, outlist, ((fFlags & kNUAcorr) ? 1 : 0));
+
+  // Setup NUA diagnoastics histograms
   TList* nualist = (TList*)outlist->FindObject("NUATerms");
   if (!nualist) {
     nualist = new TList();
     nualist->SetName("NUATerms");
     outlist->Add(nualist);
   }
-
-  TH1I* quality = (TH1I*)outlist->FindObject(Form("hQCQuality%s%s", fType.Data(), ((fFlags & kEtaGap) ? "_etaGap" : "")));
-
-  // Differential flow
-  TProfile2D* cumu2Sum = (TProfile2D*)outlist->FindObject(Form("%sQC2_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : ""))); 
-  TProfile2D* cumu4Sum = (TProfile2D*)outlist->FindObject(Form("%sQC4_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : ""))); 
-  if (!cumu2Sum) {
-    cumu2Sum = new TProfile2D(Form("%sQC2_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           Form("%sQC2_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-             fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-             fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cumu2Sum->GetYaxis());
-    outlist->Add(cumu2Sum);
+  // Reference
+  TH2D* nuaRef = (TH2D*)nualist->FindObject(Form("%sReferenceNUA%s", fType.Data(), GetQCType(fFlags)));
+  TH2D* temp = 0;
+  if (!nuaRef) {
+    nuaRef = (TH2D*)fCumuNUARef->Project3D("yz");
+    nuaRef->Scale(1./fCumuNUARef->GetNbinsX());
+    nuaRef->SetName(Form("%sReferenceNUA%s", fType.Data(), GetQCType(fFlags)));
+    nuaRef->SetTitle(Form("%sReferenceNUA%s", fType.Data(), GetQCType(fFlags)));
+    nualist->Add(nuaRef);
+  } else {
+    temp = (TH2D*)fCumuNUARef->Project3D("yz");
+    temp->Scale(1./fCumuNUARef->GetNbinsX());
+    nuaRef->Add(temp);
+    delete temp;
   }
-  if (!cumu4Sum && !(fFlags & kEtaGap)) {
-    cumu4Sum = new TProfile2D(Form("%sQC4_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           Form("%sQC4_v%d_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-             fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-             fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cumu4Sum->GetYaxis());
-    outlist->Add(cumu4Sum);
+  // Filling in underflow to make scaling possible in Terminate()
+  nuaRef->Fill(0., -1., 1.);
+  // Differential
+  TH2D* nuaDiff = (TH2D*)nualist->FindObject(Form("%sDifferentialNUA%s", fType.Data(), GetQCType(fFlags)));
+  if (!nuaDiff) {
+    nuaDiff = (TH2D*)fCumuNUADiff->Project3D("yz");
+    nuaDiff->SetName(Form("%sDifferentialNUA%s", fType.Data(), GetQCType(fFlags)));
+    nuaDiff->SetTitle(Form("%sDifferentialNUA%s", fType.Data(), GetQCType(fFlags)));
+    nualist->Add(nuaDiff);
+  } else {
+    temp = (TH2D*)fCumuNUADiff->Project3D("yz");
+    nuaDiff->Add(temp);
+    delete temp;
   }
-  TProfile2D* cumu2 = new TProfile2D(Form("%sQC2_v%d_unCorr%s_vtx%3.1f", fType.Data(), fMoment, 
-                         ((fFlags & kEtaGap) ? "_etaGap" : ""), (fVzMin+fVzMax)/2.),
-                        Form("%sQC2_v%d_unCorr%s_vtx%3.1f", fType.Data(), fMoment,
-                        ((fFlags & kEtaGap) ? "_etaGap" : ""), (fVzMin+fVzMax)/2.),
-           fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-           fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-  SetupCentAxis(cumu2->GetYaxis());
-  vtxList->Add(cumu2);
-  TProfile2D* cumu4 = 0;
-  if (!(fFlags & kEtaGap)) { 
-    cumu4 = new TProfile2D(Form("%sQC4_v%d_unCorr%s_vtx%3.1f", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : ""), (fVzMin+fVzMax)/2.),
-                           Form("%sQC4_v%d_unCorr%s_vtx%3.1f", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : ""), (fVzMin+fVzMax)/2.),
-             fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-             fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cumu4->GetYaxis());
-    vtxList->Add(cumu4);
-  }
-
-  // Reference flow
-  TProfile2D* cumu2Ref = (TProfile2D*)outlist->FindObject(Form("%sQC2_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : ""))); 
-  TProfile2D* cumu4Ref = (TProfile2D*)outlist->FindObject(Form("%sQC4_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!cumu2Ref) {
-    cumu2Ref = new TProfile2D(Form("%sQC2_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           Form("%sQC2_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-             fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-             fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cumu2Ref->GetYaxis());
-    outlist->Add(cumu2Ref);
-  }
-  if (!cumu4Ref && !(fFlags & kEtaGap)) {
-    cumu4Ref = new TProfile2D(Form("%sQC4_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           Form("%sQC4_v%d_ref_unCorr%s", fType.Data(), fMoment, ((fFlags & kEtaGap) ? "_etaGap" : "")),
-             fCumuHist->GetNbinsX(), fCumuHist->GetXaxis()->GetXmin(), fCumuHist->GetXaxis()->GetXmax(), 
-             fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cumu4Ref->GetYaxis());
-    outlist->Add(cumu4Ref);
-  }
-
-  // NUA terms
-  TProfile2D* cosPhi = (TProfile2D*)nualist->FindObject(Form("%sCosPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!cosPhi) {
-    cosPhi = new TProfile2D(Form("%sCosPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                                 Form("%sCosPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           48, -6, 6, 
-                           fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cosPhi->GetYaxis());
-    nualist->Add(cosPhi);
-  }
-
-  TProfile2D* cosPsi = (TProfile2D*)nualist->FindObject(Form("%sCosPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!cosPsi) {
-    cosPsi = new TProfile2D(Form("%sCosPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                                 Form("%sCosPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           48, -6, 6,
-                           fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(cosPsi->GetYaxis());
-    nualist->Add(cosPsi);
-  }
-
-  TProfile2D* sinPhi = (TProfile2D*)nualist->FindObject(Form("%sSinPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!sinPhi) { 
-    sinPhi = new TProfile2D(Form("%sSinPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                                 Form("%sSinPhi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           48, -6, 6,
-                           fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(sinPhi->GetYaxis());
-    nualist->Add(sinPhi);
-  }
-
-  TProfile2D* sinPsi = (TProfile2D*)nualist->FindObject(Form("%sSinPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")));
-  if (!sinPsi) {
-    sinPsi = new TProfile2D(Form("%sSinPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                                 Form("%sSinPsi_v%d_unCorr%s", fType.Data(), fMoment, 
-                           ((fFlags & kEtaGap) ? "_etaGap" : "")),
-                           48, -6, 6,
-                           fCumuHist->GetNbinsY(), fCumuHist->GetYaxis()->GetXmin(), fCumuHist->GetYaxis()->GetXmax());
-    SetupCentAxis(sinPsi->GetYaxis());
-    nualist->Add(sinPsi);
+  // Filling in underflow to make scaling possible in Terminate()
+  nuaDiff->Fill(0., -1., 1.);
+
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::CalculateReferenceFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, TH2I* quality, 
+                                                             TH1D* chist, TH2D* dNdetaRef) const  
+{
+  // 
+  //  Calculates the reference flow
+  //
+  //  Parameters:
+  //   cumu2h: CumuHistos object with QC{2} cumulants
+  //   cumu4h: CumuHistos object with QC{4} cumulants
+  //   quality: Histogram for success rate of cumulants
+  //   chist: Centrality histogram
+  //   dNdetaRef: dN/deta histogram for estimating multiplicity used for ref calculations
+  //
+
+  // Normalizing common NUA hists
+  for (Int_t cBin = 1; cBin <= fCumuNUARef->GetNbinsY(); cBin++) {
+    Double_t cent = fCumuNUARef->GetYaxis()->GetBinCenter(cBin);
+    for (Int_t eBin = 1; eBin <= fCumuNUARef->GetNbinsX(); eBin++) {
+      Double_t eta = fCumuNUARef->GetXaxis()->GetBinCenter(eBin);
+      Double_t mult = fCumuNUARef->GetBinContent(eBin, cBin, 0);
+      if (mult == 0) continue;
+      for (Int_t qBin = 1; qBin <= fCumuNUARef->GetNbinsZ(); qBin++) {
+       fCumuNUARef->SetBinContent(eBin, cBin, qBin, fCumuNUARef->GetBinContent(eBin, cBin, qBin)/mult);
+       fCumuNUARef->SetBinError(eBin, cBin, qBin, fCumuNUARef->GetBinError(eBin, cBin, qBin)/mult);
+      }
+      // Fill dN/deta diagnostics
+      dNdetaRef->Fill(eta, cent, mult);
+    }
   }
-  
+
   // For flow calculations
-  Double_t two = 0, qc2 = 0, vnTwo = 0, four = 0, qc4 = 0, vnFour = 0; 
-  Double_t twoPrime = 0, qc2Prime = 0, vnTwoDiff = 0, fourPrime = 0, qc4Prime = 0, vnFourDiff = 0;
-  Double_t w2 = 0, w4 = 0, w2p = 0, w4p = 0;
-  Double_t w2Two = 0, w2pTwoPrime = 0, w4Four = 0, w4pFourPrime = 0;
-  Double_t cosP1nPhiA = 0, sinP1nPhiA = 0, multA = 0;
-  Double_t cosP1nPhiB = 0, sinP1nPhiB = 0, multB = 0;
-  Double_t cosP1nPhi1P1nPhi2 = 0, sinP1nPhi1P1nPhi2 = 0;
-  Double_t cosP1nPhi1M1nPhi2M1nPhi3 = 0, sinP1nPhi1M1nPhi2M1nPhi3 = 0, multm1m2 = 0;
-  Double_t cosP1nPsi = 0, sinP1nPsi = 0, mp = 0, cosP1nPsi1P1nPhi2 = 0, sinP1nPsi1P1nPhi2 = 0;
-  Double_t cosP1nPsi1M1nPhi2M1nPhi3 = 0, sinP1nPsi1M1nPhi2M1nPhi3 = 0, mpqMult = 0;
-  Double_t cosP1nPsi1P1nPhi2M1nPhi3 = 0, sinP1nPsi1P1nPhi2M1nPhi3 = 0;
-
-  // Loop over cumulant histogram for final calculations   
-  // Centrality loop
-  for (Int_t cBin = 1; cBin <= fCumuHist->GetNbinsY(); cBin++) {
-    // for weighted avg.
-    Double_t cent = fCumuHist->GetYaxis()->GetBinCenter(cBin);
-    if (fDebug > 0) AliInfo(Form("%s - v_%d: centrality %3.1f:..", fType.Data(), fMoment, cent));
-    // Eta loop
-    for (Int_t etaBin = 1; etaBin <= fCumuHist->GetNbinsX(); etaBin++) {
-      Double_t eta = fCumuHist->GetXaxis()->GetBinCenter(etaBin);
-      // 2-particle reference flow
-      w2Two = fCumuHist->GetBinContent(etaBin, cBin, kW2Two);
-      w2 = fCumuHist->GetBinContent(etaBin, cBin, kW2);
-      multA = fCumuHist->GetBinContent(etaBin, cBin, kMA);
-      multB = fCumuHist->GetBinContent(etaBin, cBin, kMB);
-      if (w2 == 0 || multA == 0 || multB == 0) continue;
-      cosP1nPhiA = fCumuHist->GetBinContent(etaBin, cBin, kQnReA);
-      sinP1nPhiA = fCumuHist->GetBinContent(etaBin, cBin, kQnImA);
-      cosP1nPhiB = fCumuHist->GetBinContent(etaBin, cBin, kQnReB);
-      sinP1nPhiB = fCumuHist->GetBinContent(etaBin, cBin, kQnImB);
-        
-      cosP1nPhiA /= multA;
-      sinP1nPhiA /= multA;
-      cosP1nPhiB /= multB;
-      sinP1nPhiB /= multB;
-      two = w2Two / w2;
-      // With no eta gap the last two terms are <<cos(phi)>>^2 and <<sin(phi)>>^2,
-      // with eta gap the different coverage is taken into account. 
-      // The next line covers both cases.
-      qc2 = two - cosP1nPhiA*cosP1nPhiB - sinP1nPhiA*sinP1nPhiB;
-      if (qc2 <= 0) { 
-       if (fDebug > 0) AliInfo(Form("%s: QC_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f - skipping", fType.Data(), fMoment, qc2, eta, cent));
-       quality->Fill((fMoment-2)*8+2);
-       continue;
-      }
-       vnTwo = TMath::Sqrt(qc2);
-      if (!TMath::IsNaN(vnTwo*multA)) { 
-       quality->Fill((fMoment-2)*8+1);
-       cumu2Ref->Fill(eta, cent, vnTwo);
-      }
+  TH3D* cumuRef = 0; 
+  TH2D* cumu2 = 0;
+  TH2D* cumu2NUAold = 0;
+  TH2D* cumu2NUA = 0;
+  TH2D* cumu4 = 0;
+  TH2D* cumu4NUA = 0;
+  Int_t qualityFactor = ((fFlags & kStdQC) ? 8 : 4); // used for correctly filling in quality hists
+  // Loop over cumulant histogram for final calculations 
+  for (Int_t n = 2; n <= fMaxMoment; n++) { // Moment loop begins
+    cumu2 = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNoNUA);
+    if ((fFlags & kNUAcorr)) {
+      cumu2NUAold = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNUAOld);
+      cumu2NUA = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNUA);
+    }
+    if ((fFlags & kStdQC)) {
+      cumu4 = (TH2D*)cumu4h.Get('r', n, CumuHistos::kNoNUA);
+      if ((fFlags & kNUAcorr)) cumu4NUA = (TH2D*)cumu4h.Get('r', n, CumuHistos::kNUAOld);
+    }
+    cumuRef  = (TH3D*)fCumuHists.Get('r', n);
+    // Begin loops
+    for (Int_t cBin = 1; cBin <= cumuRef->GetNbinsY(); cBin++) { // Centrality loop begins
+      Double_t cent = cumuRef->GetYaxis()->GetBinCenter(cBin);
+      if (n == 2) chist->Fill(cent, cumuRef->GetBinContent(0, cBin, 0));
+      if (fDebug > 0) AliInfo(Form("%s - v_%d: centrality %3.1f:..", fType.Data(), n, cent));
+      for (Int_t etaBin = 1; etaBin <= cumuRef->GetNbinsX(); etaBin++) { // Eta loop begins
+       Double_t eta = cumuRef->GetXaxis()->GetBinCenter(etaBin);
+       Int_t refEtaBinA = fCumuNUARef->GetXaxis()->FindBin(eta);
+       Int_t refEtaBinB = fCumuNUARef->GetXaxis()->FindBin(-eta);
+       // 2-particle reference flow
+       Double_t w2Two = cumuRef->GetBinContent(refEtaBinA, cBin, kW2Two);
+       Double_t w2 = cumuRef->GetBinContent(refEtaBinA, cBin, kW2);
+       if (w2 == 0) continue;
+       Double_t cosP1nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberSin(n));
+       Double_t cosP1nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberSin(n));
+       Double_t cos2nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberCos(2*n));
+       Double_t sin2nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberSin(2*n));
+       Double_t cos2nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberCos(2*n));
+       Double_t sin2nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberSin(2*n));  
+       Double_t two = w2Two / w2; 
+       Double_t qc2 = two;
+        if (qc2 >= 0) cumu2->Fill(eta, cent, TMath::Sqrt(qc2));
+
+       if ((fFlags & kNUAcorr)) {
+         // Old NUA
+         // With no eta gap the last two terms are <<cos(phi)>>^2 and <<sin(phi)>>^2,
+         // with eta gap the different coverage is taken into account. 
+         // The next line covers both cases.
+         qc2 -= cosP1nPhiA*cosP1nPhiB + sinP1nPhiA*sinP1nPhiB;
+         // Extra NUA term from 2n cosines and sines
+         Double_t den = 1-(cos2nPhiA*cos2nPhiB + sin2nPhiA*sin2nPhiB);
+         if (den != 0) qc2 /= den;
+         else qc2 = 0;
+       }
+       if (qc2 <= 0) { 
+         if (fDebug > 0) 
+           AliInfo(Form("%s: QC_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f - skipping", 
+           fType.Data(), n, qc2, eta, cent));
+         quality->Fill((n-2)*qualityFactor+2, Int_t(cent));
+         continue;
+       }
+       Double_t vnTwo = TMath::Sqrt(qc2);
+       if (!TMath::IsNaN(vnTwo)) { 
+         quality->Fill((n-2)*qualityFactor+1, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu2NUAold->Fill(eta, cent, vnTwo);
+       }
 
-      // 2-particle differential flow
-      w2pTwoPrime = fCumuHist->GetBinContent(etaBin, cBin, kw2two);
-      w2p = fCumuHist->GetBinContent(etaBin, cBin, kw2);
-      mp = fCumuHist->GetBinContent(etaBin, cBin, kmp);
-      if (w2p == 0 || mp == 0) continue;
-      cosP1nPsi = fCumuHist->GetBinContent(etaBin, cBin, kpnRe);
-      sinP1nPsi = fCumuHist->GetBinContent(etaBin, cBin, kpnIm);
-
-      cosP1nPsi /= mp;
-      sinP1nPsi /= mp;
-      twoPrime = w2pTwoPrime / w2p;
-      qc2Prime = twoPrime - sinP1nPsi*sinP1nPhiB - cosP1nPsi*cosP1nPhiB;
-
-      cosPhi->Fill(eta, cent, cosP1nPhiB); 
-      cosPsi->Fill(eta, cent, cosP1nPsi); 
-      sinPhi->Fill(eta, cent, sinP1nPhiB); 
-      sinPsi->Fill(eta, cent, sinP1nPsi); 
-      vnTwoDiff = qc2Prime / TMath::Sqrt(qc2);
-      if (!TMath::IsNaN(vnTwoDiff*mp)) {
-       cumu2->Fill(eta, cent, vnTwoDiff);
-       quality->Fill((fMoment-2)*8+3);
-      }
-      else 
-       quality->Fill((fMoment-2)*8+4);
+       if (!(fFlags & kStdQC)) continue;
+       // 4-particle reference flow
+       Double_t w4Four = cumuRef->GetBinContent(refEtaBinA, cBin, kW4Four);
+       Double_t w4 = cumuRef->GetBinContent(refEtaBinA, cBin, kW4);
+       Double_t multm1m2 = cumuRef->GetBinContent(refEtaBinA, cBin, k3pWeight);
+       if (w4 == 0 || multm1m2 == 0) continue;
+       Double_t cosP1nPhi1P1nPhi2 = cumuRef->GetBinContent(refEtaBinA, cBin, kCosphi1phi2);
+       Double_t sinP1nPhi1P1nPhi2 = cumuRef->GetBinContent(refEtaBinA, cBin, kSinphi1phi2);
+       Double_t cosP1nPhi1M1nPhi2M1nPhi3 = cumuRef->GetBinContent(refEtaBinA, cBin, kCosphi1phi2phi3m);
+       Double_t sinP1nPhi1M1nPhi2M1nPhi3 = cumuRef->GetBinContent(refEtaBinA, cBin, kSinphi1phi2phi3m);
+
+       cosP1nPhi1P1nPhi2 /= w2;
+       sinP1nPhi1P1nPhi2 /= w2;
+       cosP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
+       sinP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
+       Double_t four = w4Four / w4;
+       Double_t qc4 = four-2.*TMath::Power(two,2.);
+        if (qc4 < 0) cumu4->Fill(eta, cent, TMath::Power(-qc4, 0.25));
+       
+       if ((fFlags & kNUAcorr)) {
+          qc4 += - 4.*cosP1nPhiA*cosP1nPhi1M1nPhi2M1nPhi3
+                 + 4.*sinP1nPhiA*sinP1nPhi1M1nPhi2M1nPhi3-TMath::Power(cosP1nPhi1P1nPhi2,2.)-TMath::Power(sinP1nPhi1P1nPhi2,2.)
+                 + 4.*cosP1nPhi1P1nPhi2*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.))
+                 + 8.*sinP1nPhi1P1nPhi2*sinP1nPhiA*cosP1nPhiA
+                 + 8.*two*(TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.))
+                 - 6.*TMath::Power((TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.)),2.);
+       }
+       if (qc4 >= 0) {
+         if (fDebug > 0) 
+           AliInfo(Form("%s: QC_%d{4} = %1.3f for eta = %1.2f and centrality %3.1f - skipping", 
+           fType.Data(), n, qc2, eta, cent));
+         quality->Fill((n-2)*qualityFactor+6, Int_t(cent));
+         continue;
+       }
+       Double_t vnFour = TMath::Power(-qc4, 0.25);
+       if (!TMath::IsNaN(vnFour*multm1m2)) {
+         quality->Fill((n-2)*qualityFactor+5, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu4NUA->Fill(eta, cent, vnFour);
+       }
+      } // End of eta
+    } // End of cent
+  } // End of moment
 
-      if (fDebug > 1) AliInfo(Form("%s: v_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f", fType.Data(), fMoment, vnTwoDiff, eta, cent));
-      if ((fFlags & kEtaGap)) continue;
-      
-      // 4-particle reference flow
-      w4Four = fCumuHist->GetBinContent(etaBin, cBin, kW4Four);
-      w4 = fCumuHist->GetBinContent(etaBin, cBin, kW4);
-      multm1m2 = fCumuHist->GetBinContent(etaBin, cBin, kMm1m2);
-      if (w4 == 0 || multm1m2 == 0) continue;
-      cosP1nPhi1P1nPhi2 = fCumuHist->GetBinContent(etaBin, cBin, kCosphi1phi2);
-      sinP1nPhi1P1nPhi2 = fCumuHist->GetBinContent(etaBin, cBin, kSinphi1phi2);
-      cosP1nPhi1M1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kCosphi1phi2phi3m);
-      sinP1nPhi1M1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kSinphi1phi2phi3m);
-
-      cosP1nPhi1P1nPhi2 /= w2;
-      sinP1nPhi1P1nPhi2 /= w2;
-      cosP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
-      sinP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
-      four = w4Four / w4;
-      qc4 = four-2.*TMath::Power(two,2.)
-         - 4.*cosP1nPhiA*cosP1nPhi1M1nPhi2M1nPhi3
-         + 4.*sinP1nPhiA*sinP1nPhi1M1nPhi2M1nPhi3-TMath::Power(cosP1nPhi1P1nPhi2,2.)-TMath::Power(sinP1nPhi1P1nPhi2,2.)
-         + 4.*cosP1nPhi1P1nPhi2*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.))
-         + 8.*sinP1nPhi1P1nPhi2*sinP1nPhiA*cosP1nPhiA
-         + 8.*two*(TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.))
-         - 6.*TMath::Power((TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.)),2.);
-      
-      if (qc4 >= 0) {
-       if (fDebug > 0) AliInfo(Form("%s: QC_%d{4} = %1.3f for eta = %1.2f and centrality %3.1f - skipping", fType.Data(), fMoment, qc2, eta, cent));
-       quality->Fill((fMoment-2)*8+6);
-       continue;
-      }
-      vnFour = TMath::Power(-qc4, 0.25);
-      if (!TMath::IsNaN(vnFour*multm1m2)) {
-       quality->Fill((fMoment-2)*8+5);
-        cumu4Ref->Fill(eta, cent, vnFour);
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::CalculateDifferentialFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, 
+                                                                TH2I* quality, TH2D* dNdetaDiff) const  
+{
+  // 
+  //  Calculates the differential flow
+  //
+  //  Parameters:
+  //   cumu2h: CumuHistos object with QC{2} cumulants
+  //   cumu4h: CumuHistos object with QC{4} cumulants
+  //   quality: Histogram for success rate of cumulants
+  //   dNdetaDiff: dN/deta histogram for estimating multiplicity used for diff calculations
+  //
+
+  for (Int_t cBin = 1; cBin <= fCumuNUADiff->GetNbinsY(); cBin++) {
+    Double_t cent = fCumuNUADiff->GetYaxis()->GetBinCenter(cBin);
+    for (Int_t eBin = 1; eBin <= fCumuNUADiff->GetNbinsX(); eBin++) {
+      Double_t eta = fCumuNUADiff->GetXaxis()->GetBinCenter(eBin);
+      Double_t mult = fCumuNUADiff->GetBinContent(eBin, cBin, 0);
+      if (mult == 0) continue;
+      for (Int_t qBin = 1; qBin <= fCumuNUADiff->GetNbinsZ(); qBin++) {
+       fCumuNUADiff->SetBinContent(eBin, cBin, qBin, fCumuNUADiff->GetBinContent(eBin, cBin, qBin)/mult);
+       fCumuNUADiff->SetBinError(eBin, cBin, qBin, fCumuNUADiff->GetBinError(eBin, cBin, qBin)/mult);
       }
+      dNdetaDiff->Fill(eta, cent, mult);
+    }
+  }
 
-      // 4-particle differential flow
-      w4pFourPrime = fCumuHist->GetBinContent(etaBin, cBin, kw4four);
-      w4p = fCumuHist->GetBinContent(etaBin, cBin, kw4);
-      mpqMult = fCumuHist->GetBinContent(etaBin, cBin, kmpmq);
-      if (w4p == 0 || mpqMult == 0) continue;
-      cosP1nPsi1P1nPhi2 = fCumuHist->GetBinContent(etaBin, cBin, kCospsi1phi2);
-      sinP1nPsi1P1nPhi2 = fCumuHist->GetBinContent(etaBin, cBin, kSinpsi1phi2);
-      cosP1nPsi1M1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kCospsi1phi2phi3m);
-      sinP1nPsi1M1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kSinpsi1phi2phi3m);
-      cosP1nPsi1P1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kCospsi1phi2phi3p);
-      sinP1nPsi1P1nPhi2M1nPhi3 = fCumuHist->GetBinContent(etaBin, cBin, kSinpsi1phi2phi3p); 
-      
-      cosP1nPsi1P1nPhi2 /= w2p;
-      sinP1nPsi1P1nPhi2 /= w2p;
-      cosP1nPsi1M1nPhi2M1nPhi3 /= mpqMult;
-      sinP1nPsi1M1nPhi2M1nPhi3 /= mpqMult;
-      cosP1nPsi1P1nPhi2M1nPhi3 /= mpqMult;
-      sinP1nPsi1P1nPhi2M1nPhi3 /= mpqMult;
-
-      fourPrime = w4pFourPrime / w4p;
-
-      qc4Prime = fourPrime-2.*twoPrime*two
-                - cosP1nPsi*cosP1nPhi1M1nPhi2M1nPhi3
-                + sinP1nPsi*sinP1nPhi1M1nPhi2M1nPhi3
-                - cosP1nPhiA*cosP1nPsi1M1nPhi2M1nPhi3
-                + sinP1nPhiA*sinP1nPsi1M1nPhi2M1nPhi3
-                - 2.*cosP1nPhiA*cosP1nPsi1P1nPhi2M1nPhi3
-                - 2.*sinP1nPhiA*sinP1nPsi1P1nPhi2M1nPhi3
-                - cosP1nPsi1P1nPhi2*cosP1nPhi1P1nPhi2
-                - sinP1nPsi1P1nPhi2*sinP1nPhi1P1nPhi2
-                + 2.*cosP1nPhi1P1nPhi2*(cosP1nPsi*cosP1nPhiA-sinP1nPsi*sinP1nPhiA)
-                + 2.*sinP1nPhi1P1nPhi2*(cosP1nPsi*sinP1nPhiA+sinP1nPsi*cosP1nPhiA)
-                + 4.*two*(cosP1nPsi*cosP1nPhiA+sinP1nPsi*sinP1nPhiA)
-                + 2.*cosP1nPsi1P1nPhi2*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.))
-                + 4.*sinP1nPsi1P1nPhi2*cosP1nPhiA*sinP1nPhiA
-                + 4.*twoPrime*(TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.))
-                - 6.*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.)) 
-                * (cosP1nPsi*cosP1nPhiA-sinP1nPsi*sinP1nPhiA)
-                - 12.*cosP1nPhiA*sinP1nPhiA
-                * (sinP1nPsi*cosP1nPhiA+cosP1nPsi*sinP1nPhiA);
-
-      vnFourDiff = - qc4Prime / TMath::Power(-qc4, 0.75);
-      if (!TMath::IsNaN(vnFourDiff*mpqMult) && vnFourDiff > 0) {
-       cumu4->Fill(eta, cent, vnFourDiff);
-       quality->Fill((fMoment-2)*8+7);
+  // For flow calculations
+  TH3D* cumuRef = 0; 
+  TH3D* cumuDiff = 0; 
+  TH2D* cumu2 = 0;
+  TH2D* cumu2NUAold = 0;
+  TH2D* cumu2NUA = 0;
+  TH2D* cumu4 = 0;
+  TH2D* cumu4NUA = 0;
+  Int_t qualityFactor = ((fFlags & kStdQC) ? 8 : 4); // used for correctly filling in quality hists
+  // Loop over cumulant histogram for final calculations 
+  for (Int_t n = 2; n <= fMaxMoment; n++) { // Moment loop begins
+    cumu2 = (TH2D*)cumu2h.Get('d', n, CumuHistos::kNoNUA);
+    if ((fFlags & kNUAcorr)) {
+      cumu2NUAold = (TH2D*)cumu2h.Get('d', n, CumuHistos::kNUAOld);
+      cumu2NUA = (TH2D*)cumu2h.Get('d', n, CumuHistos::kNUA);
+    }
+    if (!(fFlags & kEtaGap)) {
+      cumu4 = (TH2D*)cumu4h.Get('d',n);
+      if ((fFlags & kNUAcorr)) cumu4NUA = (TH2D*)cumu4h.Get('d', n, CumuHistos::kNUAOld);
+    }
+    cumuRef  = (TH3D*)fCumuHists.Get('r',n);
+    cumuDiff = (TH3D*)fCumuHists.Get('d',n);
+    for (Int_t cBin = 1; cBin <= cumuDiff->GetNbinsY(); cBin++) { // Centrality loop begins
+      Double_t cent = cumuDiff->GetYaxis()->GetBinCenter(cBin);
+      if (fDebug > 0) AliInfo(Form("%s - v_%d: centrality %3.1f:..", fType.Data(), n, cent));
+      for (Int_t etaBin = 1; etaBin <= cumuDiff->GetNbinsX(); etaBin++) { // Eta loop begins
+       Double_t eta = cumuDiff->GetXaxis()->GetBinCenter(etaBin);
+       Int_t refEtaBinA = fCumuNUARef->GetXaxis()->FindBin(eta);
+       Int_t refEtaBinB = fCumuNUARef->GetXaxis()->FindBin(-eta);
+
+        // Reference objects
+       Double_t w2 = cumuRef->GetBinContent(refEtaBinA, cBin, kW2);
+       if (w2 == 0) continue;
+       Double_t two = cumuRef->GetBinContent(refEtaBinA, cBin, kW2Two);
+        two /= w2;
+       Double_t cosP1nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPhiA = fCumuNUARef->GetBinContent(refEtaBinA, cBin, GetBinNumberSin(n));
+       Double_t cosP1nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberSin(n));       
+       Double_t cos2nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberCos(2*n));
+       Double_t sin2nPhiB = fCumuNUARef->GetBinContent(refEtaBinB, cBin, GetBinNumberSin(2*n));  
+       
+       // 2-particle differential flow
+       Double_t w2pTwoPrime = cumuDiff->GetBinContent(etaBin, cBin, kW2Two);
+       Double_t w2p = cumuDiff->GetBinContent(etaBin, cBin, kW2);
+       if (w2p == 0) continue;
+       Double_t cosP1nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberSin(n));
+       Double_t cos2nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberCos(2*n));
+       Double_t sin2nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberSin(2*n));
+       Double_t twoPrime = w2pTwoPrime / w2p;
+
+       Double_t qc2Prime = twoPrime;
+       cumu2->Fill(eta, cent, qc2Prime);
+       if ((fFlags & kNUAcorr)) {
+         // Old nua
+         qc2Prime -= cosP1nPsi*cosP1nPhiB + sinP1nPsi*sinP1nPhiB;
+         // Extra NUA term from 2n cosines and sines
+         qc2Prime /= (1.-(cos2nPsi*cos2nPhiB + sin2nPsi*sin2nPhiB));
+       }
+       if (!TMath::IsNaN(qc2Prime)) {
+         quality->Fill((n-2)*qualityFactor+3, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu2NUAold->Fill(eta, cent, qc2Prime);
+       }
+       else 
+         quality->Fill((n-2)*qualityFactor+4, Int_t(cent));
+       if (fDebug > 1) 
+         AliInfo(Form("%s: QC'_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f", 
+         fType.Data(), n, qc2Prime, eta, cent));
+
+        if (!(fFlags & kStdQC)) continue;
+        // Reference objects
+       Double_t cosP1nPhi1P1nPhi2 = cumuRef->GetBinContent(refEtaBinA, cBin, kCosphi1phi2);
+       Double_t sinP1nPhi1P1nPhi2 = cumuRef->GetBinContent(refEtaBinA, cBin, kSinphi1phi2);
+       Double_t cosP1nPhi1M1nPhi2M1nPhi3 = cumuRef->GetBinContent(refEtaBinA, cBin, kCosphi1phi2phi3m);
+       Double_t sinP1nPhi1M1nPhi2M1nPhi3 = cumuRef->GetBinContent(refEtaBinA, cBin, kSinphi1phi2phi3m);
+       Double_t multm1m2 = cumuRef->GetBinContent(refEtaBinA, cBin, k3pWeight);
+       cosP1nPhi1P1nPhi2 /= w2;
+       sinP1nPhi1P1nPhi2 /= w2;
+       cosP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
+       sinP1nPhi1M1nPhi2M1nPhi3 /= multm1m2;
+
+       // 4-particle differential flow
+       Double_t w4pFourPrime = cumuDiff->GetBinContent(etaBin, cBin, kW4Four);
+       Double_t w4p = cumuDiff->GetBinContent(etaBin, cBin, kW4);
+       Double_t mpqMult = cumuDiff->GetBinContent(etaBin, cBin, k3pWeight);
+       if (w4p == 0 || mpqMult == 0) continue;
+       Double_t cosP1nPsi1P1nPhi2 = cumuDiff->GetBinContent(etaBin, cBin, kCosphi1phi2);
+       Double_t sinP1nPsi1P1nPhi2 = cumuDiff->GetBinContent(etaBin, cBin, kSinphi1phi2);
+       Double_t cosP1nPsi1M1nPhi2M1nPhi3 = cumuDiff->GetBinContent(etaBin, cBin, kCosphi1phi2phi3m);
+       Double_t sinP1nPsi1M1nPhi2M1nPhi3 = cumuDiff->GetBinContent(etaBin, cBin, kSinphi1phi2phi3m);
+       Double_t cosP1nPsi1P1nPhi2M1nPhi3 = cumuDiff->GetBinContent(etaBin, cBin, kCosphi1phi2phi3p);
+       Double_t sinP1nPsi1P1nPhi2M1nPhi3 = cumuDiff->GetBinContent(etaBin, cBin, kSinphi1phi2phi3p); 
+       
+       cosP1nPsi1P1nPhi2 /= w2p;
+       sinP1nPsi1P1nPhi2 /= w2p;
+       cosP1nPsi1M1nPhi2M1nPhi3 /= mpqMult;
+       sinP1nPsi1M1nPhi2M1nPhi3 /= mpqMult;
+       cosP1nPsi1P1nPhi2M1nPhi3 /= mpqMult;
+       sinP1nPsi1P1nPhi2M1nPhi3 /= mpqMult;
+       
+       Double_t fourPrime = w4pFourPrime / w4p;
+       Double_t qc4Prime = fourPrime-2.*twoPrime*two; 
+       cumu4->Fill(eta, cent, qc4Prime);
+
+       if ((fFlags & kNUAcorr)) {
+         qc4Prime += - cosP1nPsi*cosP1nPhi1M1nPhi2M1nPhi3
+                     + sinP1nPsi*sinP1nPhi1M1nPhi2M1nPhi3
+                     - cosP1nPhiA*cosP1nPsi1M1nPhi2M1nPhi3
+                     + sinP1nPhiA*sinP1nPsi1M1nPhi2M1nPhi3
+                     - 2.*cosP1nPhiA*cosP1nPsi1P1nPhi2M1nPhi3
+                     - 2.*sinP1nPhiA*sinP1nPsi1P1nPhi2M1nPhi3
+                     - cosP1nPsi1P1nPhi2*cosP1nPhi1P1nPhi2
+                     - sinP1nPsi1P1nPhi2*sinP1nPhi1P1nPhi2
+                     + 2.*cosP1nPhi1P1nPhi2*(cosP1nPsi*cosP1nPhiA-sinP1nPsi*sinP1nPhiA)
+                     + 2.*sinP1nPhi1P1nPhi2*(cosP1nPsi*sinP1nPhiA+sinP1nPsi*cosP1nPhiA)
+                     + 4.*two*(cosP1nPsi*cosP1nPhiA+sinP1nPsi*sinP1nPhiA) 
+                     + 2.*cosP1nPsi1P1nPhi2*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.))
+                     + 4.*sinP1nPsi1P1nPhi2*cosP1nPhiA*sinP1nPhiA
+                     + 4.*twoPrime*(TMath::Power(cosP1nPhiA,2.)+TMath::Power(sinP1nPhiA,2.))
+                     - 6.*(TMath::Power(cosP1nPhiA,2.)-TMath::Power(sinP1nPhiA,2.)) 
+                     * (cosP1nPsi*cosP1nPhiA-sinP1nPsi*sinP1nPhiA)
+                     - 12.*cosP1nPhiA*sinP1nPhiA
+                     * (sinP1nPsi*cosP1nPhiA+cosP1nPsi*sinP1nPhiA);
+       }
+//     Double_t vnFourDiff = - qc4Prime / TMath::Power(-qc4, 0.75);
+       if (!TMath::IsNaN(qc4Prime*mpqMult)) {
+         quality->Fill((n-2)*qualityFactor+7, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu4NUA->Fill(eta, cent, qc4Prime);
+       }
+       else 
+         quality->Fill((n-2)*qualityFactor+8, Int_t(cent));
+       if (fDebug > 1) 
+         AliInfo(Form("%s: v_%d{4} = %1.3f for eta = %1.2f and centrality %3.1f", 
+         fType.Data(), n, qc4Prime, eta, cent));
+      } // End of eta loop
+    } // End of centrality loop
+  } // End of moment
+
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::Calculate3CorFlow(CumuHistos& cumu2h, TH2I* quality, TH1D* chist,
+                                                        TH2D* dNdetaRef, TH2D* dNdetaDiff) const  
+{
+  // 
+  //  Calculates the 3 sub flow
+  //
+  //  Parameters:
+  //   cumu2h: CumuHistos object with QC{2} cumulants
+  //   quality: Histogram for success rate of cumulants
+  //   chist: Centrality histogram
+  //   dNdetaDiff: dN/deta histogram for estimating multiplicity used for diff calculations
+  //
+
+  // For flow calculations
+  TH3D* cumuRef = 0; 
+  TH3D* cumuDiff = 0; 
+  TH2D* cumu2r = 0;
+  TH2D* cumu2rNUAold = 0;
+  TH2D* cumu2rNUA = 0;
+  TH2D* cumu2a = 0;
+  TH2D* cumu2aNUAold = 0;
+  TH2D* cumu2aNUA = 0;
+  TH2D* cumu2b = 0;
+  TH2D* cumu2bNUAold = 0;
+  TH2D* cumu2bNUA = 0;
+  // Loop over cumulant histogram for final calculations 
+  for (Int_t n = 2; n <= fMaxMoment; n++) { // Moment loop begins
+    cumu2r = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNoNUA);
+    cumu2a = (TH2D*)cumu2h.Get('a', n, CumuHistos::kNoNUA);
+    cumu2b = (TH2D*)cumu2h.Get('b', n, CumuHistos::kNoNUA);
+    if ((fFlags & kNUAcorr)) {
+      cumu2rNUAold = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNUAOld);
+      cumu2rNUA = (TH2D*)cumu2h.Get('r', n, CumuHistos::kNUA);
+      cumu2aNUAold = (TH2D*)cumu2h.Get('a', n, CumuHistos::kNUAOld);
+      cumu2aNUA = (TH2D*)cumu2h.Get('a', n, CumuHistos::kNUA);
+      cumu2bNUAold = (TH2D*)cumu2h.Get('b', n, CumuHistos::kNUAOld);
+      cumu2bNUA = (TH2D*)cumu2h.Get('b', n, CumuHistos::kNUA);
+    }
+    cumuRef  = (TH3D*)fCumuHists.Get('r',n);
+    cumuDiff = (TH3D*)fCumuHists.Get('d',n);
+    for (Int_t cBin = 1; cBin <= cumuRef->GetNbinsY(); cBin++) { // Centrality loop begins
+      Double_t cent = cumuRef->GetYaxis()->GetBinCenter(cBin);
+      if (n == 2) chist->Fill(cent, cumuRef->GetBinContent(0, cBin, 0));
+      if (fDebug > 0) AliInfo(Form("%s - v_%d: centrality %3.1f:..", fType.Data(), n, cent));
+      // Here it starts!
+      Int_t prevLim = 0;
+      Int_t aLow = 0, aHigh = 0, bLow = 0, bHigh = 0;
+      Double_t cosP1nPhiA = 0;
+      Double_t sinP1nPhiA = 0;
+      Double_t cos2nPhiA = 0;
+      Double_t sin2nPhiA = 0;
+      Double_t cosP1nPhiB = 0;
+      Double_t sinP1nPhiB = 0;
+      Double_t cos2nPhiB = 0;
+      Double_t sin2nPhiB = 0;
+      Double_t multA = 0;
+      Double_t multB = 0;
+
+      for (Int_t etaBin = 1; etaBin <= cumuDiff->GetNbinsX(); etaBin++) { // Eta loop begins
+       Double_t eta = cumuDiff->GetXaxis()->GetBinCenter(etaBin);
+       // 2-particle reference flow
+       Double_t w2Two = cumuRef->GetBinContent(etaBin, cBin, kW2Two);
+       Double_t w2 = cumuRef->GetBinContent(etaBin, cBin, kW2);
+       if (w2 == 0) continue;
+
+       // Update NUA for new range!
+       if (fEtaLims[prevLim] < eta) {
+         GetLimits(prevLim, aLow, aHigh, bLow, bHigh);
+         prevLim++;
+         cosP1nPhiA = 0; sinP1nPhiA = 0; cos2nPhiA = 0; sin2nPhiA = 0; multA = 0;
+         cosP1nPhiB = 0; sinP1nPhiB = 0; cos2nPhiB = 0; sin2nPhiB = 0; multB = 0;
+         for (Int_t a = aLow; a <= aHigh; a++) {
+           cosP1nPhiA += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberCos(n));
+           sinP1nPhiA += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberSin(n));
+           cos2nPhiA += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberCos(2*n));
+           sin2nPhiA += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberSin(2*n));
+           multA += fCumuNUARef->GetBinContent(a, cBin, 0);
+         }
+         for (Int_t b = bLow; b <= bHigh; b++) {
+           cosP1nPhiB += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberCos(n));
+           sinP1nPhiB += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberSin(n));
+           cos2nPhiB += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberCos(2*n));
+           sin2nPhiB += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberSin(2*n));
+           multB += fCumuNUARef->GetBinContent(b, cBin, 0);
+         }
+         if (multA == 0 || multB == 0) AliFatal("Empty NUA values for 3Cor!");
+         cosP1nPhiA /= multA;
+         sinP1nPhiA /= multA;
+         cos2nPhiA /= multA;
+         sin2nPhiA /= multA;
+         cosP1nPhiB /= multB;
+         sinP1nPhiB /= multB;
+         cos2nPhiB /= multB;
+         sin2nPhiB /= multB;
+
+         dNdetaRef->Fill(eta, cent, multA+multB);
+       }
+       Double_t two = w2Two / w2;
+  
+       Double_t qc2 = two;
+        if (qc2 >= 0) cumu2r->Fill(eta, cent, TMath::Sqrt(qc2));
+
+       if ((fFlags & kNUAcorr)) {
+         // Old nua
+         qc2 -= cosP1nPhiA*cosP1nPhiB + sinP1nPhiA*sinP1nPhiB;
+         // Extra NUA term from 2n cosines and sines
+         qc2 /= (1-(cos2nPhiA*cos2nPhiB + sin2nPhiA*sin2nPhiB));
+       }
+       if (qc2 <= 0) { 
+         if (fDebug > 0) 
+           AliInfo(Form("%s: QC_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f - skipping", 
+           fType.Data(), n, qc2, eta, cent));
+         quality->Fill((n-2)*4+2, Int_t(cent));
+         continue;
+       }
+       Double_t vnTwo = TMath::Sqrt(qc2);
+       if (!TMath::IsNaN(vnTwo)) { 
+         quality->Fill((n-2)*4+1, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu2rNUAold->Fill(eta, cent, vnTwo);
+       }
+
+       // 2-particle differential flow
+       Double_t w2pTwoPrimeA = cumuDiff->GetBinContent(etaBin, cBin, kW2Two);
+       Double_t w2pA = cumuDiff->GetBinContent(etaBin, cBin, kW2);
+       Double_t w2pTwoPrimeB = cumuDiff->GetBinContent(etaBin, cBin, kW4Four);
+       Double_t w2pB = cumuDiff->GetBinContent(etaBin, cBin, kW4);
+       if (w2pA == 0 || w2pB == 0) continue;
+       Double_t cosP1nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberCos(n));
+       Double_t sinP1nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberSin(n));
+       Double_t cos2nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberCos(2*n));
+       Double_t sin2nPsi = fCumuNUADiff->GetBinContent(etaBin, cBin, GetBinNumberSin(2*n));
+        Double_t mult = fCumuNUADiff->GetBinContent(etaBin, cBin, 0);
+        if (mult == 0) continue;
+        cosP1nPsi /= mult;
+        sinP1nPsi /= mult;
+        cos2nPsi /= mult;
+        sin2nPsi /= mult;
+       Double_t twoPrimeA = w2pTwoPrimeA / w2pA;
+       Double_t twoPrimeB = w2pTwoPrimeB / w2pB;
+       dNdetaDiff->Fill(eta, cent, mult);
+
+       Double_t qc2PrimeA = twoPrimeA;
+       Double_t qc2PrimeB = twoPrimeB;
+       if (qc2PrimeA*qc2PrimeB >= 0) {
+         cumu2a->Fill(eta, cent, qc2PrimeA);
+         cumu2b->Fill(eta, cent, qc2PrimeB);
+       }
+       if ((fFlags & kNUAcorr)) {
+         // Old nua
+         qc2PrimeA -= cosP1nPsi*cosP1nPhiA + sinP1nPsi*sinP1nPhiA;
+         qc2PrimeB -= cosP1nPsi*cosP1nPhiB + sinP1nPsi*sinP1nPhiB; // Is this OK?
+         // Extra NUA term from 2n cosines and sines
+         qc2PrimeA /= (1.-(cos2nPsi*cos2nPhiA + sin2nPsi*sin2nPhiA));
+         qc2PrimeB /= (1.-(cos2nPsi*cos2nPhiB + sin2nPsi*sin2nPhiB));
+       }
+       if (!TMath::IsNaN(qc2PrimeA) && !TMath::IsNaN(qc2PrimeB) && qc2 != 0) {
+       if (qc2PrimeA*qc2PrimeB >= 0) {
+         quality->Fill((n-2)*4+3, Int_t(cent));
+         if ((fFlags & kNUAcorr)) cumu2aNUAold->Fill(eta, cent, qc2PrimeA);
+         if ((fFlags & kNUAcorr)) cumu2bNUAold->Fill(eta, cent, qc2PrimeB);
+       }
       }
       else 
-       quality->Fill((fMoment-2)*8+8);
+       quality->Fill((n-2)*4+4, Int_t(cent));
+       if (fDebug > 1) 
+         AliInfo(Form("%s: QC'a_%d{2} = %1.3f, QC'b_%d{2} = %1.3f for eta = %1.2f and centrality %3.1f", 
+         fType.Data(), n, qc2PrimeA, n, qc2PrimeB, eta, cent));
+      } // End of eta loop
+    } // End of centrality loop
+  } // End of moment
 
-      if (fDebug > 1) AliInfo(Form("%s: v_%d{4} = %1.3f for eta = %1.2f and centrality %3.1f", fType.Data(), fMoment, vnFourDiff, eta, cent));
+  return;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::SolveCoupledFlowEquations(CumuHistos& cumu, const Char_t type) const  
+{
+  // 
+  //  Function to solve the coupled flow equations
+  //  We solve it by using matrix calculations:
+  //  A*v_n = V => v_n = A^-1*V
+  //  First we set up a TMatrixD container to make ROOT
+  //  do the inversions in an efficient way, we multiply the current <<2>> estimates.
+  //  Then we fill new TH2D's if the corrected <<2>>'s (cumuNUA object).
+  //
+  //  Parameters:
+  //   cumu: CumuHistos object - uncorrected
+  //   type: Reference ('r') or differential ('d') or ('a' or 'b') for 3 correlator
+  //
+
+  // We start by declaring Matrix and vector objects, as their constructors are quite heavy
+  TMatrixD mNUA(fMaxMoment-1, fMaxMoment-1);
+  TVectorD vQC2(fMaxMoment-1);
+
+  for (Int_t cBin = 1; cBin <= cumu.Get(type, 2, CumuHistos::kNUAOld)->GetNbinsY(); cBin++) { // cent loop
+    Double_t cent = cumu.Get(type, 2, CumuHistos::kNUAOld)->GetYaxis()->GetBinCenter(cBin);
+    for (Int_t eBin = 1; eBin <= cumu.Get(type, 2, CumuHistos::kNUAOld)->GetNbinsX(); eBin++) { // eta loop
+      Double_t eta = cumu.Get(type, 2, CumuHistos::kNUAOld)->GetXaxis()->GetBinCenter(eBin);
+      mNUA.Zero(); // reset matrix
+      vQC2.Zero(); // reset vector
+      for (Int_t n = 0; n < fMaxMoment-1; n++) { // moment loop
+       vQC2(n) = static_cast<TH2D*>(cumu.Get(type, n+2, CumuHistos::kNUAOld))->GetBinContent(eBin, cBin);
+       if (type == 'r' || type == 'R') vQC2(n) *= vQC2(n); // going back to <<2>>
+       for (Int_t m = 0; m < fMaxMoment-1; m++) { // cross moment
+         mNUA(n,m) = CalculateNUAMatrixElement(n, m, type, eBin, cBin);
+       } // End of cross moment loop
+      } // End of moment loop
+      // Invert matrix
+      Double_t det = 0;
+      mNUA.Invert(&det);
+      // If determinant is non-zero we go with corrected results
+      if (det != 0 ) vQC2 = mNUA*vQC2;
+      else AliWarning(Form("Determinant == 0 - cent: %d-%d, eta: %f, type: '%c', data: %s, vtx: %d-%d%s", 
+                     Int_t(cumu.Get(type, 2, CumuHistos::kNUAOld)->GetYaxis()->GetBinLowEdge(cBin)), 
+                     Int_t(cumu.Get(type, 2, CumuHistos::kNUAOld)->GetYaxis()->GetBinUpEdge(cBin)),
+                     cumu.Get(type, 2, CumuHistos::kNUAOld)->GetXaxis()->GetBinCenter(eBin), 
+                     type, fType.Data(), fVzMin, fVzMax, 
+                     ((fFlags & kEtaGap) ? ", eta-gap" : "")));
+      // Go back to v_n for ref. keep <<2'>> for diff. flow).
+      for (Int_t n = 0; n < fMaxMoment-1; n++) {
+       Double_t vnTwo = 0;
+        if (type == 'r' || type == 'R') 
+          vnTwo = (vQC2(n) > 0. ? TMath::Sqrt(vQC2(n)) : 0.);
+        else {
+          // is really more <<2'>> in this case
+         vnTwo = vQC2(n);
+       }
+        // Fill in corrected v_n
+       if (vnTwo != 0) static_cast<TH2D*>(cumu.Get(type, n+2, CumuHistos::kNUA))->Fill(eta, cent, vnTwo);
+      } // End of moment loop
     } // End of eta loop
   } // End of centrality loop
-  cumu2Sum->Add(cumu2);
-  if (!(fFlags & kEtaGap)) cumu4Sum->Add(cumu4);
-
   return;
 }
 //_____________________________________________________________________
-void AliForwardFlowTaskQC::VertexBin::SetupCentAxis(TAxis* axis)  
+Double_t AliForwardFlowTaskQC::VertexBin::CalculateNUAMatrixElement(Int_t n, Int_t m, Char_t type, Int_t binA, Int_t cBin) const  
 {
-  // 
-  // Setup centrality axis for histogram
+  //  
+  //  Calculates the (n,m)-th element in the NUA matrix: 1 if n == m, otherwise:
+  //               <<cos[(n-m)phi1]>>*<<cos[(n-m)phi2]>> + <<sin[(n-m)phi1]>>*<<sin[(n-m)phi2]>>
+  //    NUA(n,m) = -----------------------------------------------------------------------------
+  //                   1 + <<cos[2nphi1]>>*<<cos[2nphi2]>> + <<sin[2nphi1]>>*<<sin[2nphi2]>>
   //
-  // Parameters:
-  //  axis: centrality axis
+  //               <<cos[(n+m)phi1]>>*<<cos[(n+m)phi2]>> + <<sin[(n+m)phi1]>>*<<sin[(n+m)phi2]>>
+  //             + -----------------------------------------------------------------------------
+  //                   1 + <<cos[2nphi1]>>*<<cos[2nphi2]>> + <<sin[2nphi1]>>*<<sin[2nphi2]>>
   //
-  if (!axis) {
-    AliError("Null pointer passed for axis");
-    return;
+  //  Parameters:
+  //   n: row
+  //   m: coumn
+  //   type: Reference ('r') or differential ('d') or ('a' or 'b')
+  //   binA: eta bin of phi1
+  //   cBin: centrality bin
+  //
+  //  Return: NUA(n,m)
+  //
+  if (n == m) return 1.;
+  n += 2;
+  m += 2;
+
+  Double_t cosnMmPhi1 = 0, cosnMmPhi2 = 0, sinnMmPhi1 = 0, sinnMmPhi2 = 0;
+  Double_t cosnPmPhi1 = 0, cosnPmPhi2 = 0, sinnPmPhi1 = 0, sinnPmPhi2 = 0;
+  Double_t cos2nPhi1 = 0, cos2nPhi2 = 0, sin2nPhi1 = 0, sin2nPhi2 = 0;
+
+  // reference flow
+  if (type == 'r' || type == 'R') {
+    if ((fFlags & k3Cor)) {
+      Double_t eta = fCumuNUARef->GetXaxis()->GetBinCenter(binA);
+      Int_t i = 0;
+      while (fEtaLims[i] < eta) i++;
+      Int_t aLow = 0, aHigh = 0, bLow = 0, bHigh = 0;
+      GetLimits(i-1, aLow, aHigh, bLow, bHigh);
+      Double_t multA = 0, multB = 0;
+      for (Int_t a = aLow; a <= aHigh; a++) {
+       cosnMmPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberCos(n-m));
+       sinnMmPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberSin(n-m));
+       cosnPmPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberCos(n+m));
+       sinnPmPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberSin(n+m));
+       cos2nPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberCos(2*n));
+       sin2nPhi1 += fCumuNUARef->GetBinContent(a, cBin, GetBinNumberSin(2*n));
+       multA += fCumuNUARef->GetBinContent(a, cBin, 0);
+      }
+       for (Int_t b = bLow; b <= bHigh; b++) {
+       cosnMmPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberCos(n-m));
+       sinnMmPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberSin(n-m));
+       cosnPmPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberCos(n+m));
+       sinnPmPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberSin(n+m));
+       cos2nPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberCos(2*n));
+       sin2nPhi2 += fCumuNUARef->GetBinContent(b, cBin, GetBinNumberSin(2*n));
+       multB += fCumuNUARef->GetBinContent(b, cBin, 0);
+      }
+      if (multA == 0 || multB == 0) {
+        if (fDebug > 0) AliWarning("multA or multB == 0 in matrix elements, aborting NUA");
+        return 0.;
+      }
+      cosnMmPhi1 /= multA;
+      sinnMmPhi1 /= multA;
+      cosnPmPhi1 /= multA;
+      sinnPmPhi1 /= multA;
+      cos2nPhi1 /= multA; 
+      sin2nPhi1 /= multA;
+      cosnMmPhi2 /= multB;
+      sinnMmPhi2 /= multB;
+      cosnPmPhi2 /= multB;
+      sinnPmPhi2 /= multB;
+      cos2nPhi2 /= multB; 
+      sin2nPhi2 /= multB;
+    } else {
+      Int_t binB = fCumuNUARef->GetXaxis()->FindBin(-fCumuNUARef->GetXaxis()->GetBinCenter(binA));
+      cosnMmPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberCos(n-m));
+      sinnMmPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberSin(n-m));
+      cosnPmPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberCos(n+m));
+      sinnPmPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberSin(n+m));
+      cos2nPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberCos(2*n));
+      sin2nPhi1 = fCumuNUARef->GetBinContent(binA, cBin, GetBinNumberSin(2*n));
+      cosnMmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(n-m));
+      sinnMmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(n-m));
+      cosnPmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(n+m));
+      sinnPmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(n+m));
+      cos2nPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(2*n));
+      sin2nPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(2*n));
+    }
+  } // differential flow
+  else if (type == 'd' || type == 'D') {
+    Int_t binB = fCumuNUARef->GetXaxis()->FindBin(-fCumuNUADiff->GetXaxis()->GetBinCenter(binA));
+    cosnMmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(n-m));
+    sinnMmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(n-m));
+    cosnPmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(n+m));
+    sinnPmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(n+m));
+    cos2nPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(2*n));
+    sin2nPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(2*n));
+    cosnMmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(n-m));
+    sinnMmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(n-m));
+    cosnPmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(n+m));
+    sinnPmPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(n+m));
+    cos2nPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberCos(2*n));
+    sin2nPhi2 = fCumuNUARef->GetBinContent(binB, cBin, GetBinNumberSin(2*n));
+  } // 3 correlator part a or b
+  else if (type == 'a' || type == 'A' || type == 'b' || type == 'B') {
+    Double_t mult1 = 0, mult2 = 0;
+    // POIs
+    cosnMmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(n-m));
+    sinnMmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(n-m));
+    cosnPmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(n+m));
+    sinnPmPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(n+m));
+    cos2nPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberCos(2*n));
+    sin2nPhi1 = fCumuNUADiff->GetBinContent(binA, cBin, GetBinNumberSin(2*n));
+    mult1 = fCumuNUADiff->GetBinContent(binA, cBin, 0);
+    // RPs
+    Double_t eta = fCumuNUADiff->GetXaxis()->GetBinCenter(binA);
+    Int_t i = 0;
+    while (fEtaLims[i] < eta) i++;
+    Int_t aLow = 0, aHigh = 0, bLow = 0, bHigh = 0;
+    GetLimits(i-1, aLow, aHigh, bLow, bHigh);
+    Int_t lLow = ((type == 'a' || type == 'A') ? aLow : bLow);
+    Int_t lHigh = ((type == 'a' || type == 'A') ? aHigh : bHigh);
+    for (Int_t l = lLow; l <= lHigh; l++) {
+      cosnMmPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberCos(n-m));
+      sinnMmPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberSin(n-m));
+      cosnPmPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberCos(n+m));
+      sinnPmPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberSin(n+m));
+      cos2nPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberCos(2*n));
+      sin2nPhi2 += fCumuNUARef->GetBinContent(l, cBin, GetBinNumberSin(2*n));
+      mult2 += fCumuNUARef->GetBinContent(l, cBin, 0);
+    }
+    if (mult1 == 0 || mult2 == 0) { 
+      if (fDebug > 0) AliWarning("mult1 or mult2 == 0 in matrix elements, aborting NUA");
+      return 0.;
+    }
+    cosnMmPhi1 /= mult1;
+    sinnMmPhi1 /= mult1;
+    cosnPmPhi1 /= mult1;
+    sinnPmPhi1 /= mult1;
+    cos2nPhi1 /= mult1; 
+    sin2nPhi1 /= mult1;
+    cosnMmPhi2 /= mult2;
+    sinnMmPhi2 /= mult2;
+    cosnPmPhi2 /= mult2;
+    sinnPmPhi2 /= mult2;
+    cos2nPhi2 /= mult2; 
+    sin2nPhi2 /= mult2;
   }
 
-  if ((fFlags & kSatVtx)) {
-    Double_t cent[3] = {0, 40, 100};
-    axis->Set(2, cent);
-  } else {
-    Double_t cent[13] = {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100 };
-//    Double_t cent[13] = {0, 2.5, 15, 25, 50, 60, 70, 80, 90, 100, 110, 115, 120 };
-    axis->Set(12, cent);
+  // Actual calculation
+  Double_t e = cosnMmPhi1*cosnMmPhi2 + sinnMmPhi1*sinnMmPhi2 + cosnPmPhi1*cosnPmPhi2 + sinnPmPhi1*sinnPmPhi2;
+  Double_t den = 1 + cos2nPhi1*cos2nPhi2 + sin2nPhi1*sin2nPhi2;
+  if (den != 0) e /= den;
+  else return 0.;
+
+  return e;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::AddVertexBins(CumuHistos& cumu, TList* list, UInt_t nNUA) const  
+{
+  //
+  //  Add up vertex bins with flow results
+  //
+  //  Parameters:
+  //   cumu: CumuHistos object with vtxbin results
+  //   list: Outout list with added results
+  //   nNUA: # of NUA histograms to loop over
+  //
+  TH2D* vtxHist = 0;
+  TProfile2D* avgProf = 0;
+  TString name;
+  Int_t nT = ((fFlags & k3Cor) ? 3 : 2);
+  Char_t ct = '\0';
+  for (UInt_t nua = 0; nua <= nNUA; nua++) { // NUA loop
+    for (Int_t n = 2; n <= fMaxMoment; n++) { // moment loop
+      for (Int_t t = 0; t < nT; t++) { // type loop (r/d/a/b)
+        // Find type
+        switch (t) {
+          case 0: ct = 'r'; break;
+          case 1: ct = ((fFlags & k3Cor) ? 'a' : 'd'); break;
+          case 2: ct = 'b'; break;
+          default: ct = '\0'; break;
+       }
+       vtxHist = static_cast<TH2D*>(cumu.Get(ct,n,nua));
+       if (!vtxHist) {
+         AliWarning("VertexBin::AddVertexBins: vtxHist not found!");
+         continue;
+       }
+       name = vtxHist->GetName();
+       // Strip name of vtx info
+       Ssiz_t l = name.Last('x')-3;
+       name.Resize(l);
+       avgProf = (TProfile2D*)list->FindObject(name.Data());
+       // if no output profile yet, make one
+       if (!avgProf) {
+         avgProf = new TProfile2D(name.Data(), name.Data(), 
+             vtxHist->GetNbinsX(), vtxHist->GetXaxis()->GetXmin(), vtxHist->GetXaxis()->GetXmax(),
+             vtxHist->GetNbinsY(), vtxHist->GetYaxis()->GetXmin(), vtxHist->GetYaxis()->GetXmax());
+         if (vtxHist->GetXaxis()->IsVariableBinSize()) 
+           avgProf->GetXaxis()->Set(vtxHist->GetNbinsX(), vtxHist->GetXaxis()->GetXbins()->GetArray());
+         if (vtxHist->GetYaxis()->IsVariableBinSize()) 
+           avgProf->GetYaxis()->Set(vtxHist->GetNbinsY(), vtxHist->GetYaxis()->GetXbins()->GetArray());
+         list->Add(avgProf);
+       }
+       // Fill in, cannot be done with Add function.
+       for (Int_t e = 1; e <= vtxHist->GetNbinsX(); e++) { // eta loop
+         Double_t eta = vtxHist->GetXaxis()->GetBinCenter(e);
+         for (Int_t c = 1; c <= vtxHist->GetNbinsY(); c++) { // cent loop
+           Double_t cent = vtxHist->GetYaxis()->GetBinCenter(c);
+           Double_t cont = vtxHist->GetBinContent(e, c);
+           if (cont == 0) continue;
+           avgProf->Fill(eta, cent, cont);
+         } // End of cent loop
+       } //  End of eta loop
+      } // End of type loop
+    } // End of moment loop
+  } // End of nua loop
+}
+//_____________________________________________________________________
+Int_t AliForwardFlowTaskQC::VertexBin::GetBinNumberCos(Int_t n) const  
+{
+  //
+  //  Get the bin number of <<cos(nphi)>>
+  //
+  //  Parameters:
+  //   n: moment
+  //
+  //  Return: bin number
+  //
+  Int_t bin = 0;
+  n = TMath::Abs(n);
+  
+  if (n == 0) bin = fMaxMoment*4-1;
+  else        bin = n*2-1;
+  
+  return bin;
+}
+//_____________________________________________________________________
+Int_t AliForwardFlowTaskQC::VertexBin::GetBinNumberSin(Int_t n) const  
+{
+  //
+  //  Get the bin number of <<sin(nphi)>>
+  //
+  //  Parameters:
+  //   n: moment
+  //
+  //  Return: bin number
+  //
+  Int_t bin = 0;
+  n = TMath::Abs(n);
+  
+  if (n == 0) bin = fMaxMoment*4;
+  else        bin = n*2;
+
+  return bin;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::VertexBin::SetupNUALabels(TAxis* a) const
+{
+  // 
+  //  Setup NUA labels on axis
+  //
+  //  Parameters:
+  //   a: Axis to set up
+  //
+  if (a->GetNbins() != GetBinNumberSin()) AliFatal("SetupNUALabels: Wrong number of bins on axis");
+
+  Int_t i = 1, j= 1;
+  while (i <= a->GetNbins()) {
+    a->SetBinLabel(i++, Form("<<cos(%d#varphi)>>", j));
+    a->SetBinLabel(i++, Form("<<sin(%d#varphi)>>", j++));
   }
 
   return;
 }
 //_____________________________________________________________________
+TH2I* AliForwardFlowTaskQC::VertexBin::MakeQualityHist(const Char_t* name) const 
+{
+  //
+  //  Add a histogram for checking the analysis quality
+  //
+  //  Parameters:
+  //   const char*: name of data type
+  //
+  //  Return: histogram for tracking successful calculations
+  //
+  Int_t nBins = ((fFlags & kStdQC) ? 8 : 4);
+  TH2I* quality = new TH2I(name, name, (fMaxMoment-1)*nBins, 1, (fMaxMoment-1)*nBins+1, fCumuNUARef->GetNbinsY(), 
+                           fCumuNUARef->GetYaxis()->GetXmin(), fCumuNUARef->GetYaxis()->GetXmax());
+  quality->GetYaxis()->Set(fCumuNUARef->GetNbinsY(), fCumuNUARef->GetYaxis()->GetXbins()->GetArray());
+  for (Int_t i = 2, j = 1; i <= fMaxMoment; i++) {
+    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{2} > 0", i));
+    quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{2} <= 0", i));
+    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{2} > 0", i));
+    quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{2} <= 0", i));
+    if ((fFlags & kStdQC)) {
+      quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{4} < 0", i));
+      quality->GetXaxis()->SetBinLabel(j++, Form("QC_{%d}{4} >= 0", i));
+      quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{4} < 0", i));
+      quality->GetXaxis()->SetBinLabel(j++, Form("QC'_{%d}{4} >= 0", i));
+    }
+  }
+
+  return quality;
+}
+//_____________________________________________________________________
+TH2D* AliForwardFlowTaskQC::VertexBin::MakeOutputHist(Int_t qc, Int_t n, const Char_t* ctype, UInt_t nua) const
+{
+  //
+  //  Setup a TH2D for the output
+  //
+  //  Parameters:
+  //   qc   # of particle correlations
+  //   n    flow moment
+  //   ref  Type: r/d/a/b
+  //   nua  For nua corrected hists?
+  //
+  //  Return: 2D hist for results
+  //
+  Bool_t ref = ((ctype[0] == 'R') || (ctype[0] == 'r'));
+  TAxis* xAxis = (ref ? fCumuNUARef->GetXaxis() : fCumuNUADiff->GetXaxis());
+  TAxis* yAxis = (ref ? fCumuNUARef->GetYaxis() : fCumuNUADiff->GetYaxis());
+  TString ntype = "";
+  switch (nua) {
+    case CumuHistos::kNoNUA: ntype = "Un"; break;
+    case CumuHistos::kNUAOld: ntype = "NUAOld"; break;
+    case CumuHistos::kNUA: ntype = "NUA"; break;
+    default: break;
+  }
+  TH2D* h = new TH2D(Form("%sQC%d_v%d_%s_%sCorr%s_vtx_%d_%d", 
+                       fType.Data(), qc, n, ctype, ntype.Data(),
+                       GetQCType(fFlags), fVzMin, fVzMax),
+                     Form("%sQC%d_v%d_%s_%sCorr%s_vtx_%d_%d", 
+                       fType.Data(), qc, n, ctype, ntype.Data(),
+                       GetQCType(fFlags), fVzMin, fVzMax),
+                     xAxis->GetNbins(), xAxis->GetXmin(), xAxis->GetXmax(),
+                     yAxis->GetNbins(), yAxis->GetXmin(), yAxis->GetXmax());
+  if (xAxis->IsVariableBinSize()) h->GetXaxis()->Set(xAxis->GetNbins(), xAxis->GetXbins()->GetArray());
+  h->GetYaxis()->Set(yAxis->GetNbins(), yAxis->GetXbins()->GetArray());
+
+  return h;
+}
+//_____________________________________________________________________
 void AliForwardFlowTaskQC::PrintFlowSetup() const 
 {
   //
-  // Print the setup of the flow task
+  //  Print the setup of the flow task
   //
-  Printf("AliForwardFlowTaskQC::Print");
-  Printf("Number of bins in vertex axis   :\t%d", fVtxAxis->GetNbins());
-  Printf("Range of vertex axis            :\t[%3.1f,%3.1f]", 
+  Printf("=======================================================");
+  Printf("%s::Print", this->IsA()->GetName());
+  Printf("Forward detector:                 :\t%s", ((fFlowFlags & kFMD) ? "FMD" : "VZERO"));
+  Printf("Number of bins in vertex axis     :\t%d", fVtxAxis->GetNbins());
+  Printf("Range of vertex axis              :\t[%3.1f,%3.1f]", 
                          fVtxAxis->GetXmin(), fVtxAxis->GetXmax());
-  printf("Doing flow analysis for         :\t");
-  for (Int_t n  = 0; n < fV.GetSize(); n++) printf("v%d ", fV.At(n));
+  Printf("Number of bins in centrality axis :\t%d", fCentAxis->GetNbins());
+  printf("Centrality binning                :\t");
+  for (Int_t cBin = 1; cBin <= fCentAxis->GetNbins(); cBin++) {
+    printf("%02d-%02d%% ", Int_t(fCentAxis->GetBinLowEdge(cBin)), Int_t(fCentAxis->GetBinUpEdge(cBin)));
+    if (cBin == fCentAxis->GetNbins()) printf("\n");
+    else if (cBin % 4 == 0) printf("\n\t\t\t\t\t");
+  }
+  printf("Doing flow analysis for           :\t");
+  for (Int_t n  = 2; n <= fMaxMoment; n++) printf("v%d ", n);
   printf("\n");
-  Printf("Satellite vertex flag           :\t%s", ((fFlowFlags & kSatVtx) ? "true" : "false"));
-  Printf("Symmetrize ref. flow wrt eta = 0:\t%s", ((fFlowFlags & kSymEta) ? "true" : "false"));
-  Printf("Use an eta-gap for ref. flow    :\t%s", ((fFlowFlags & kEtaGap) ? "true" : "false"));
-  Printf("FMD sigma cut:                  :\t%f", fFMDCut);
-  Printf("SPD sigma cut:                  :\t%f", fSPDCut);
+  TString type = "Standard QC{2} and QC{4} calculations.";
+  if ((fFlowFlags & kTPC)) type.ReplaceAll(".", " with TPC tracks for reference.");
+  if ((fFlowFlags & kEtaGap)) type = "QC{2} with a rapidity gap.";
+  if ((fFlowFlags & k3Cor))   type = "QC{2} with 3 correlators.";
+  Printf("QC calculation type               :\t%s", type.Data());
+  Printf("Symmetrize ref. flow wrt. eta = 0 :\t%s", ((fFlowFlags & kSymEta) ? "true" : "false"));
+  Printf("Apply NUA correction terms        :\t%s", ((fFlowFlags & kNUAcorr) ? "true" : "false"));
+  Printf("Satellite vertex flag             :\t%s", ((fFlowFlags & kSatVtx) ? "true" : "false"));
+  Printf("FMD sigma cut:                    :\t%f", fFMDCut);
+  Printf("SPD sigma cut:                    :\t%f", fSPDCut);
   if ((fFlowFlags & kEtaGap)) 
-    Printf("Eta gap:                        :\t%f", fEtaGap);
+    Printf("Eta gap:                          :\t%f", fEtaGap);
+  Printf("=======================================================");
+}
+//_____________________________________________________________________
+const Char_t* AliForwardFlowTaskQC::GetQCType(UShort_t flags, Bool_t prependUS) 
+{
+  // 
+  //  Get the type of the QC calculations
+  //  Used for naming of objects in the VertexBin class, 
+  //  important to avoid memory problems when running multiple
+  //  initializations of the class with different setups
+  // 
+  //  Parameters:
+  //   flags: Flow flags for type determination
+  //   prependUS: Prepend an underscore (_) to the name
+  // 
+  //  Return: QC calculation type
+  //
+  TString type = "";
+  if      ((flags & kStdQC))  type = "StdQC";
+  else if ((flags & kEtaGap)) type = "EtaGap";
+  else if ((flags & k3Cor))   type = "3Cor";
+  else type = "UNKNOWN";
+  if (prependUS) type.Prepend("_");
+  if ((flags & kTPC)) type.Append("TPCTr");
+  return type.Data();
+}
+//_____________________________________________________________________
+TH1* AliForwardFlowTaskQC::CumuHistos::Get(const Char_t t, Int_t n, UInt_t nua) const
+{
+  //
+  //  Get histogram/profile for type t and moment n
+  //
+  //  Parameters:
+  //   t: type = 'r'/'d'
+  //   n: moment
+  //   nua: NUA type
+  //
+  n = GetPos(n, nua);
+  if (n < 0) AliFatal(Form("CumuHistos out of range: (%c,%d)", t, n));
+
+  TH1* h = 0;
+  Int_t pos = -1;
+  if      (t == 'r' || t == 'R') pos = n;    
+  else if (t == 'd' || t == 'D') pos = n;    
+  else if (t == 'a' || t == 'A') pos = 2*n;  
+  else if (t == 'b' || t == 'B') pos = 2*n+1;
+  else AliFatal(Form("CumuHistos wrong type: %c", t));
+
+  if (t == 'r' || t == 'R') {
+    if (pos < fRefHists->GetEntries()) {
+      h = (TH1*)fRefHists->At(pos);
+    }
+  } else if (pos < fDiffHists->GetEntries()) {
+    h = (TH1*)fDiffHists->At(pos);
+  }
+  if (!h) AliFatal(Form("No hist found in list %c at pos %d", t, pos));
+
+  return h;
+}
+//_____________________________________________________________________
+void AliForwardFlowTaskQC::CumuHistos::ConnectList(TString name, TList* l)
+{
+  //
+  //  Connect an output list with this object
+  //
+  //  Parameters:
+  //   name: base name
+  //   l: list to keep outputs in
+  //
+  TString ref = name;
+  ref.ReplaceAll("Cumu","CumuRef");
+  fRefHists = (TList*)l->FindObject(ref.Data());
+  if (!fRefHists) {
+    fRefHists = new TList();
+    fRefHists->SetName(ref.Data());
+    l->Add(fRefHists);
+  } else {
+    // Check that the list correspond to fMaxMoments
+    if (fRefHists->GetEntries() != (fMaxMoment-1.)*(fNUA+1)) 
+      AliError("CumuHistos::ConnectList Wrong number of hists in ref list,"
+               "you are doing something wrong!");
+  }
+  TString diff = name;
+  diff.ReplaceAll("Cumu","CumuDiff");
+  fDiffHists = (TList*)l->FindObject(diff.Data());
+  if (!fDiffHists) {
+    fDiffHists = new TList();
+    fDiffHists->SetName(diff.Data());
+    l->Add(fDiffHists);
+  } else {
+    // Check that the list correspond to fMaxMoment
+    if ((fDiffHists->GetEntries() != (fMaxMoment-1.)*(fNUA+1)) &&  
+        (fDiffHists->GetEntries() != 2*(fMaxMoment-1.)*(fNUA+1)))  
+      AliError(Form("CumuHistos::ConnectList Wrong number of hists in diff list,"
+               "you are doing something wrong! (%s)",name.Data()));
+  }
 
 }
 //_____________________________________________________________________
+void AliForwardFlowTaskQC::CumuHistos::Add(TH1* h) const
+{
+  //
+  //  Add a histogram to this objects lists
+  //
+  //  Parameters:
+  //   h: histogram/profile to add
+  //
+  TString name = h->GetName();
+  if (name.Contains("Ref")) {
+    if (fRefHists) fRefHists->Add(h);
+    // Check that the list correspond to fMaxMoments
+    if (fRefHists->GetEntries() > (fNUA+1)*(fMaxMoment-1.)) 
+      AliError("CumuHistos::Add wrong number of hists in ref list, "
+               "you are doing something wrong!");
+  }
+  else if (name.Contains("Diff")) {
+    if (fDiffHists) fDiffHists->Add(h);
+    // Check that the list correspond to fMaxMoment
+    if (fDiffHists->GetEntries() > 2*(fNUA+1)*(fMaxMoment-1.)) 
+      AliError("CumuHistos::Add wrong number of hists in diff list, "
+        "you are doing something wrong!");
+  }
+  return;
+}
+//_____________________________________________________________________
+Int_t AliForwardFlowTaskQC::CumuHistos::GetPos(Int_t n, UInt_t nua) const
+{
+  //
+  //  Get position in list of moment n objects
+  //  To take care of different numbering schemes
+  //
+  //  Parameters:
+  //   n: moment
+  //   nua: # of nua corrections applied
+  //
+  //  Return: position #
+  //
+  if (n > fMaxMoment) return -1;
+  else return (n-2)+nua*(fMaxMoment-1);
+}
+//_____________________________________________________________________
 //
 //
 // EOF
index 7a39fa2f0fbaa71b23f866a3cb28bce2c2fa0db1..897cb39c4277ebf0c9b1281ca0cdacd685b8c79d 100644 (file)
@@ -9,18 +9,20 @@
  * 
  * @brief
  * 
- * 
  * @ingroup pwglf_forward_flow
  */
 #include "AliAnalysisTaskSE.h"
 #include "TString.h"
-#include "TArrayI.h"
+#include <TH2D.h>
 class AliAODForwardMult;
+class TH1I;
 class TH1D;
+class TH2I;
 class TH2F;
 class TH2D;
 class TH3D;
 class TAxis;
+class AliESDtrackCuts;
 /**
  * @defgroup pwglf_forward_tasks_flow Flow tasks 
  *
@@ -35,7 +37,7 @@ class TAxis;
  *   - AliAODEvent
  *
  * Outputs:
- *   - AnalysisResults.root
+ *   - forward_flow.root
  *
  * @ingroup pwglf_forward_tasks_flow
  * @ingroup pwglf_forward_flow
@@ -90,19 +92,23 @@ public:
    */
   TList* GetOutputList() { return fOutputList; }
   /**
-   * Set which flow moments to calculate.
-   * 
-   * @param  n Do @f$ v_{n}@f$
+   * Set max flow moment to calculate.
    * 
-   * @return void 
+   * @param  n Do v_2 to v_n
    */
-  void AddFlowMoment(Short_t n); 
+  void SetMaxFlowMoment(Short_t n) { fMaxMoment = n; } 
   /**
-   * Set non-default vertex binning and range
+   * Set vertex binning and range
    *
    * @param axis Use this vtx axis
    */
   void SetVertexAxis(TAxis* axis) { fVtxAxis = axis; }
+  /**
+   * Set centrality/multiplicity binning and range
+   *
+   * @param axis Use this binning
+   */
+  void SetCentralityAxis(TAxis* axis) { fCentAxis = axis; }
   /**
    * Set detector sigma cuts
    *
@@ -112,33 +118,173 @@ public:
   void SetDetectorCuts(Double_t fmdCut, Double_t spdCut) { fFMDCut = fmdCut; fSPDCut = spdCut; }
   /**
    * Set flow flags, @f$\eta@f$-gap, sym. around @f$\eta=0@f$ or
-   * sat. vtx. interactions
+   * sat. vtx. interactions, also sets which forward detector to use
    *
    * @param flags EFlowFlags 
    */
-  void SetFlowFlags(UShort_t flags) { fFlowFlags = flags; }
+  void SetFlowFlags(UShort_t flags);
   /**
-   * Enum for flow flags
-   */
-  enum EFlowFlags {
-    kEtaGap  = 0x1,
-    kSymEta  = 0x2,
-    kSatVtx  = 0x4
-  };
+    * Get QC type
+    *
+    * @param flags EFlowFlags
+    * @param prepensUS prepend an underscore
+    *
+    * @return type
+    */
+  static const Char_t* GetQCType(UShort_t flags, Bool_t prependUS = kTRUE);
   /**
    *  Set @f$|\eta|@f$ value to make cut for @f$\eta@f$ gap at
    *
    * @param eg gap value
    */
   void SetEtaGapValue(Double_t eg) { fEtaGap = eg; }
+  /**
+   * Enum for flow flags
+   */
+  enum EFlowFlags {
+    kStdQC   = 0x001, // Standard QC{2} and QC{4} calculations
+    kEtaGap  = 0x002, // QC{2} w/ an eta-gap
+    k3Cor    = 0x004, // 3 correlator method for QC{2} w/ an eta-gap
+    kSymEta  = 0x008, // Symmetrize ref flow in std. QC{2} and QC{4} around eta = 0
+    kSatVtx  = 0x010, // Do satellite vertex input (currently not implemented)
+    kNUAcorr = 0x020, // Apply full NUA correction
+    kFMD     = 0x040, // Use FMD for forward flow
+    kVZERO   = 0x080, // Use VZERO for forward flow
+    kTPC     = 0x100  // Use TPC tracks for reference flow
+  };
+  /**
+   * struct to handle cumulant calculations and control histograms
+   */
+  struct CumuHistos : public TObject
+  {
+  public:
+    /*
+     * Constructor
+     */
+    CumuHistos() : fMaxMoment(), fRefHists(), fDiffHists(), fNUA() {}
+    /**
+     * Constructor
+     * 
+     * @param n max flow moment contained
+     * @param nua Make room for NUA corrected histograms
+     */
+    CumuHistos(Int_t n, UInt_t nua) : fMaxMoment(n), fRefHists(), fDiffHists(), fNUA(nua) {}
+    /**
+     * Copy constructor 
+     * 
+     * @param o Object to copy from
+     * 
+     * @return CumuHistos
+     */
+    CumuHistos(const CumuHistos& o)
+      : TObject(o),
+        fMaxMoment(o.fMaxMoment), // Max moment to compute
+        fRefHists(o.fRefHists),   // List with ref hists
+        fDiffHists(o.fDiffHists), // List with diff hists
+        fNUA(o.fNUA)
+    {}
+    /**
+     * Assignment operator 
+     * 
+     * @param o Object to assing from
+     * 
+     * @return reference to this 
+     */
+    CumuHistos& operator=(const CumuHistos& o) 
+    { 
+      if (&o == this) return *this;
+      TObject::operator=(o);
+      fMaxMoment = o.fMaxMoment;
+      fRefHists  = o.fRefHists;
+      fDiffHists = o.fDiffHists;
+      fNUA       = o.fNUA;
+      return *this;
+    }
+    /**
+     * Destructor 
+     */
+    ~CumuHistos(){}
+    /**
+     * To access histograms
+     * main function of this class
+     *
+     * @param t (r)eference or (d)iff
+     * @param n    flow moment 
+     * @param nua  nua type
+     * 
+     * @return requested histogram
+     */
+    TH1* Get(const Char_t t, Int_t n, UInt_t nua = 0) const;
+    /**
+     * Connect internal lists to output
+     *
+     * @param name Name of VertexBin
+     * @param l    Output list
+     */
+    void ConnectList(TString name, TList* l);
+    /**
+     * Make histograms to one of the lists
+     *
+     * @param h Hist to add
+     */
+     void Add(TH1* h) const;
+    /** 
+     * Check to see of lists are connected, 
+     * needed for grid/proof
+     *
+     * @return is connected?
+     */
+    Bool_t IsConnected() { return (fRefHists && fDiffHists); }
+    /**
+     * enum for NUA histograms
+     */
+    enum {
+      kNoNUA = 0, // No NUA applied
+      kNUAOld,    // NUA correction from same moment applied
+      kNUA        // Full cross-moment NUA correction applied
+    };
+  protected:
+    /**
+     * Get position of histogram in list
+     *
+     * @param n moment to get position of
+     * @param nua nua type
+     * 
+     * @return position
+     */
+    Int_t GetPos(Int_t n, UInt_t nua) const;
+
+    Int_t  fMaxMoment;  // Max flow moment contained
+    TList* fRefHists;   // List of reference hists
+    TList* fDiffHists;  // List of diff hists
+    UInt_t fNUA;        // NUA tracker
+
+    ClassDef(CumuHistos, 1);
+  }; // End of struct
+
 protected:
   /**
-   * Enum for reference flow (eta-gap) mode
+   * Enum for filling flow histos
    */
-  enum EFillFlow {
-    kFillRef  = 0x1,
-    kFillDiff = 0x2,
-    kFillBoth = 0x3
+  enum {
+    kFillRef  = 0x1, // Fill only ref flow
+    kFillDiff = 0x2, // Fill only diff flow
+    kFillBoth = 0x3, // Fill both
+    kReset    = 0x4, // Reset hists (used with one of the above)
+  };
+  /**
+   * Enum for event diagnostics
+   */
+  enum {
+    kNoEvent = 1, // No event found
+    kNoForward,   // No forward object found
+    kNoCentral,   // No central object found
+    kNoTrigger,   // No (wrong) trigger
+    kNoCent,      // No centrality
+    kInvCent,     // Centrality outside range
+    kNoVtx,       // No vertex
+    kInvVtx,      // Vertex outside range
+    kOK           // Event OK!
   };
   // ----------------- Being nested class ---------------------
   /**
@@ -157,15 +303,15 @@ protected:
      * @param vLow Min vertex z-coordinate
      * @param vHigh Max vertex z-coordinate
      * @param moment Flow moment
-     * @param type Data type (FMD/SPD/FMDTR/SPDTR/MC)
+     * @param type Data type (FMD/VZERO/SPD/FMDTR/SPDTR/MC)
      * @param flags Flags
      * @param cut Cut value 
      * @param etaGap @f$\eta@f$ gap 
      */
     VertexBin(Int_t vLow, Int_t vHigh, 
               UShort_t moment, TString type,
-              UShort_t flags = kSymEta
-              Double_t cut = -1, Double_t etaGap = 2.);
+              UShort_t flags, 
+              Double_t cut = -1, Double_t etaGap = -1.);
     /**
      * Copy constructor 
      * 
@@ -190,12 +336,14 @@ protected:
      * Add vertex bin output to list
      * 
      * @param list Histograms are added to this list
+     * @param centAxis Axis to handle centrality binning
      * 
      * @return void 
      */
-    virtual void AddOutput(TList* list);
+    void AddOutput(TList* list, TAxis* centAxis);
     /**
      * Fill reference and differential flow histograms for analysis
+     * using histograms as input
      *
      * @param dNdetadphi 2D data histogram
      * @param cent Centrality
@@ -203,89 +351,183 @@ protected:
      *
      * @return false if bad event (det. hotspot)
      */
-    Bool_t FillHists(const TH2D& dNdetadphi, Double_t cent, EFillFlow mode = kFillBoth);
+    Bool_t FillHists(TH2D& dNdetadphi, Double_t cent, UShort_t mode);
+    /** 
+     * Fill reference and differential flow histograms for analysis 
+     * using tracks as input
+     *
+     * @param trList Array with tracks
+     * @param cent Centrality
+     * @param mode fill ref/diff or both
+     *
+     * @return false if bad event (det. hotspot)
+     */
+    Bool_t FillTracks(TObjArray* trList, UShort_t mode);
     /**
      * Do cumulants calculations for current event with 
      * centrality cent
      * 
      * @param cent Event centrality
-     * @param skipFourP Skip ?
+     */
+    void CumulantsAccumulate(Double_t cent);
+    /**
+     * Do 3 correlator cumulants calculations for current event with 
+     * centrality cent
+     * 
+     * @param cent Event centrality
+     */
+    void CumulantsAccumulate3Cor(Double_t cent);
+    /**
+     * Get limits to do reference flow calculations for 3 correlator method
      *
-     * @return void 
+     * @param bin Differential bin
+     * @param aLow Lowest bin to be used for v_A
+     * @param aHigh Highest bin to be used for v_A
+     * @param bLow Lowest bin to be used for v_B
+     * @param bHigh Highest bin to be used for v_B
      */
-    void CumulantsAccumulate(Double_t cent, Bool_t skipFourP = kFALSE);
+    void GetLimits(Int_t bin, Int_t& aLow, Int_t& aHigh, Int_t& bLow, Int_t& bHigh) const;
     /**
      * Finish cumulants calculations. Takes input and
      * output lists in case Terminate is called separately
      * 
      * @param inlist List with input histograms
      * @param outlist List with output histograms
-     * 
-     * @return void 
      */
     void CumulantsTerminate(TList* inlist, TList* outlist);
-
-  protected:
-    /*
-     * Enumeration for ref/diff histograms
-     */
-    enum { kHmultA = 1, kHmultB, kHQnReA, kHQnImA, kHQnReB, kHQnImB, kHQ2nRe, kHQ2nIm };
     /*
      * Enumeration for cumulant histograms
      */
-    enum { kW2Two = 1, 
-          kW2, 
-          kW4Four, 
-          kW4, 
-          kQnReA, 
-          kQnImA, 
-          kMA,
-          kQnReB, 
-          kQnImB, 
-          kMB,
-          kCosphi1phi2, 
-          kSinphi1phi2, 
-          kCosphi1phi2phi3m, 
-          kSinphi1phi2phi3m, 
-          kMm1m2, 
-          kw2two, 
-          kw2, 
-          kw4four, 
-          kw4, 
-          kpnRe, 
-          kpnIm, 
-          kmp, 
-          kCospsi1phi2, 
-          kSinpsi1phi2, 
-          kCospsi1phi2phi3m, 
-          kSinpsi1phi2phi3m,
-          kmpmq, 
-          kCospsi1phi2phi3p, 
-          kSinpsi1phi2phi3p };
+    enum { kW2Two = 1, // <w2*two>
+          kW2, // <w2>
+          kW4Four, // <w4*four>
+          kW4, // <w4>
+          kCosphi1phi2, // <cos(phi1+phi2)> 
+          kSinphi1phi2, // <sin(phi1+phi2)>
+          kCosphi1phi2phi3m, // <cos(phi1-phi2-phi3)>
+          kSinphi1phi2phi3m, // <sin(phi1-phi2-phi3)>
+          k3pWeight, // M(M-1)(M-1) or (mp*M-2mq)(M-1)
+          kCosphi1phi2phi3p, // <cos(phi1+phi2-phi3)>
+          kSinphi1phi2phi3p // <sin(phi1+phi2-phi3)>
+         };
+  protected:
+    /** 
+     * Calculate reference flow
+     *
+     * @param cumu2 QC2 histos
+     * @param cumu4 QC4 histos
+     * @param quality QC Quality diag. histo
+     * @param chist Centrality histogram
+     * @param dNdetaRef dN/deta histogram
+     */
+    void CalculateReferenceFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, TH2I* quality, TH1D* chist, TH2D* dNdetaRef) const;
+    /** 
+     * Calculate differential flow
+     *
+     * @param cumu2 QC2 histos
+     * @param cumu4 QC4 histos
+     * @param quality QC Quality diag. histo
+     * @param dNdetaDiff dN/deta histogram
+     */
+    void CalculateDifferentialFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, TH2I* quality, TH2D* dNdetaDiff) const;
+    /** 
+     * Calculate 3 correlator ref and fiff flow
+     *
+     * @param cumu2 QC2 histos
+     * @param quality QC Quality diag. histo
+     * @param chist Centrality histogram
+     * @param dNdetaRef dN/deta histogram
+     * @param dNdetaDiff dN/deta histogram
+     */
+    void Calculate3CorFlow(CumuHistos& cumu2h, TH2I* quality, TH1D* chist, TH2D* dNDetaRef, TH2D* dNdetaDiff) const;
+    /**
+     * Solve coupled eqs. to get v_n
+     * 
+     * @param cumu CumuHistos object with non-corrected flow results
+     * @param type reference of differential flow ('r'/'d'/'a'/'b')
+     */
+    void SolveCoupledFlowEquations(CumuHistos& cumu, Char_t type) const;
+    /**
+     * Calculate NUA matrix elements to fill into the matrix
+     * 
+     * @param n row
+     * @param m column
+     * @param type reference of differential flow ('r'/'d'/'a'/'b')
+     * @param binA Eta bin of phi1
+     * @param cBin Centrality bin
+     *
+     * @return maxtrix element
+     */
+    Double_t CalculateNUAMatrixElement(Int_t n, Int_t m, Char_t type, Int_t binA, Int_t cBin) const;
+    /**
+     * Adds up the vertex bins to master profiles
+     *
+     * @param cumu QC histos
+     * @param list output list
+     * @param nNUA number of nua calculations
+     */
+    void AddVertexBins(CumuHistos& cumu, TList* list, UInt_t nNUA) const;
     /**
-     * Set centrality axis
+     * Get the bin number of <<cos(nphi)>>
      *
-     * @param axis Centrality axis
+     * @param n moment
      *
-     * @return void
+     * @return bin number
      */
-    void SetupCentAxis(TAxis* axis);
+    Int_t GetBinNumberCos(Int_t n = 0) const;
+    /**
+     * Get the bin number of <<sin(nphi)>>
+     *
+     * @param n moment
+     *
+     * @return bin number
+     */
+    Int_t GetBinNumberSin(Int_t n = 0) const;
+    /**
+     * Setup NUA axis with labels
+     *
+     * @param axis NUA axis
+     */
+    void SetupNUALabels(TAxis* a) const;
+    /**
+     * Make diagnostics hitogram
+     *
+     * @param name Name
+     *
+     * @return hist
+     */
+    TH2I* MakeQualityHist(const Char_t* name) const;
+    /**
+     * Make output histogram
+     *
+     * @param qc   # of particle correlations
+     * @param n    flow moment
+     * @param ctype  Type of flow
+     * @param nua  For nua corrected hists
+     *
+     * @return hist
+     */
+    TH2D* MakeOutputHist(Int_t qc, Int_t n, const Char_t* ctype, UInt_t nua) const;
 
-    const UShort_t fMoment;        // flow moment 
-    const Int_t    fVzMin;         // z-vertex min must be in whole [cm]
-    const Int_t    fVzMax;         // z-vertex max must be in whoe [cm]
-    TString        fType;          // data type
-    const UShort_t fFlags;         // Flow flags, e.g., eta-gap sat. vtx
-    const Double_t fSigmaCut;      // Detector specific cut for outlier events
-    const Double_t fEtaGap;        // Eta gap value
-    TH2D*          fCumuRef;       // histogram for reference flow
-    TH2D*          fCumuDiff;      // histogram for differential flow
-    TH3D*          fCumuHist;      // histogram for cumulants calculations
-    TH2F*          fdNdedpAcc;     // Diagnostics histogram to make acc. maps
-    TH2F*          fOutliers;      // Sigma <M> histogram 
-    UShort_t       fDebug;         // Debug flag
+    UShort_t   fMaxMoment;     // Max flow moment 
+    Int_t      fVzMin;         // z-vertex min must be in whole [cm]
+    Int_t      fVzMax;         // z-vertex max must be in whole [cm]
+    TString    fType;          // Data type
+    UShort_t   fFlags;         // Flow flags, e.g., eta-gap or sat. vtx
+    Double_t   fSigmaCut;      // Detector specific cut for outlier events
+    Double_t   fEtaGap;        // Eta gap value
+    Double_t   fEtaLims[6];    // Limits for binning in 3Cor method
+    TH2D*      fCumuRef;       // Histogram for reference flow
+    TH2D*      fCumuDiff;      // Histogram for differential flow
+    CumuHistos fCumuHists;     // Array of histograms for cumulants calculations
+    TH3D*      fCumuNUARef;    // histogram for NUA terms
+    TH3D*      fCumuNUADiff;   // histogram for NUA terms
+    TH2F*      fdNdedpRefAcc;  // Diagnostics histogram for acc. maps
+    TH2F*      fdNdedpDiffAcc; // Diagnostics histogram for acc. maps
+    TH2F*      fOutliers;      // Sigma <M> histogram 
+    UShort_t   fDebug;         // Debug flag
 
-    ClassDef(VertexBin, 3); // object for cumulants ananlysis in FMD
+    ClassDef(VertexBin, 4); // object for eta dependent cumulants ananlysis
   };
   // ---------- End of nested class -------------
   /** 
@@ -324,10 +566,9 @@ protected:
    * @param list List of vertex bins
    * @param h dN/detadphi histogram
    * @param vtx Current vertex bin
-   *
-   * @return true on success
+   * @param flags Extra flags
    */
-  Bool_t FillVtxBinList(const TList& list, const TH2D& h, Int_t vtx) const;
+  void FillVtxBinList(const TList& list, TH2D& h1, Int_t vtx, UShort_t flags = 0x0) const;
   /**
    * Loops of vertex bins in list and runs analysis on those for current vertex
    *
@@ -335,11 +576,34 @@ protected:
    * @param href dN/detadphi histogram for ref flow
    * @param hdiff dN/detadphi histogram for diff flow
    * @param vtx Current vertex bin
+   * @param flags Extra flags
+   */
+  void FillVtxBinListEtaGap(const TList& list, TH2D& href, TH2D& hdiff, Int_t vtx, UShort_t flags = 0x0) const;
+  /**
+   * Loops of vertex bins in list and runs analysis on those for current vertex
    *
-   * @return true on success
+   * @param list List of vertex bins
+   * @param hcent dN/detadphi histogram for central barrel
+   * @param hfwd dN/detadphi histogram for fwd detectors
+   * @param vtx Current vertex bin
+   * @param flags Extra flags
    */
-  Bool_t FillVtxBinListEtaGap(const TList& list, const TH2D& href, const TH2D& hdiff, Int_t vtx) const;
-
+  void FillVtxBinList3Cor(const TList& list, TH2D& hcent, TH2D& hfwd, Int_t vtx, UShort_t flags = 0x0);
+  /** 
+   * Combine forward and central detector histograms to one histogram, to be used for 3 correlator method
+   *
+   * @param hcent Central data
+   * @param hfwd Forward data
+   *
+   * @return combined hist
+   */
+  TH2D& CombineHists(TH2D& hcent, TH2D& hfwd);
+  /**
+   * Get TPC tracks from ESD or AOD input event
+   *
+   * @return array of tracks
+   */
+  TObjArray* GetTracks() const;
   /**
    * Loops over VertexBin list and calls terminate on each
    *
@@ -347,80 +611,86 @@ protected:
    */
   void EndVtxBinList(const TList& list) const;
   /**
-   * Projects a list of TProfile2D's with flow
+   * Projects a list of TH2D's with flow
    * results to TH1's in centrality bins
    *
    * @param list List of flow results
-   *
-   * @return void
    */
-  void MakeCentralityHists(TList* list);
+  void MakeCentralityHists(TList* list) const;
   /**
    * Check AODevent object for trigger, vertex and centrality
+   * uses aod header if object is null
    * returns true if event is OK
    *
-   * @param aodfm AliAODForwardMultObject
+   * @param aodfm AliAODForwardMult object
    * 
    * @return Bool_t 
    */
   Bool_t CheckEvent(const AliAODForwardMult* aodfm);
   /**
    * Check trigger from AODForwardMult object
+   * uses aod header if object is null
    * returns true if offline trigger is present
    *
-   * @param aodfm AliAODForwardMultObject
+   * @param aodfm AliAODForwardMult object
    * 
    * @return Bool_t 
    */
   virtual Bool_t CheckTrigger(const AliAODForwardMult* aodfm) const;
   /**
    * Check for centrality in AliAODForwardMult object, 
+   * uses aod header if object is null
    * if present return true - also sets fCent value
    *
-   * @param aodfm AliAODForwardMultObject
+   * @param aodfm AliAODForwardMult object
    * 
    * @return Bool_t 
    */
   virtual Bool_t GetCentrality(const AliAODForwardMult* aodfm);
   /**
    * Check for vertex in AliAODForwardMult
+   * uses aod header if object is null
    * returns true if in range of fVtxAXis, also sets fVtx value
    *
-   * @param aodfm AliAODForwardMultObject
+   * @param aodfm AliAODForwardMult object
    * 
    * @return Bool_t 
    */
   virtual Bool_t GetVertex(const AliAODForwardMult* aodfm);
   /**
-   * Make diagnostics hitogram
+   * Fill VZERO d^2N/detadphi hist
    *
-   * @return void
+   * @param aodvzero: AliAODVZERO object
    */
-  void MakeQualityHist(const Char_t* name) const;
+  void FillVZEROHist(AliAODVZERO* aodVZero);
   /**
    * Print the setup of the task
-   *
-   * @return void
    */
-  virtual void PrintFlowSetup() const;
+  void PrintFlowSetup() const;
 
-  TAxis*         fVtxAxis;          //  Axis to control vertex binning
-  Double_t       fFMDCut;           //  FMD sigma cut for outlier events
-  Double_t       fSPDCut;           //  SPD sigma cut for outlier events
-  UShort_t       fFlowFlags;        //  Flow flags, e.g., eta-gap, sat. vtx.
-  Double_t       fEtaGap;           //  Eta gap value
-  TList          fBinsFMD;          //  list with FMD VertexBin objects 
-  TList          fBinsSPD;          //  list with SPD VertexBin objects
-  TList*         fSumList;          //  sum list
-  TList*         fOutputList;       //  Output list
-  AliAODEvent*   fAOD;              //  AOD event
-  TArrayI        fV;                //  Calculate v_{n} flag
-  Float_t       fVtx;              //  Z vertex bin
-  Double_t       fCent;             //  Centrality
-  TH1D*          fHistCent;         //  Diagnostics hist for centrality
-  TH1D*          fHistVertexSel;    //  Diagnostics hist for selected vertices
+  TAxis*           fVtxAxis;       //  Axis to control vertex binning
+  TAxis*           fCentAxis;      //  Axis to control centrality/multiplicity binning
+  Double_t         fFMDCut;        //  FMD sigma cut for outlier events
+  Double_t         fSPDCut;        //  SPD sigma cut for outlier events
+  UShort_t         fFlowFlags;     //  Flow flags, e.g., eta-gap, sat. vtx.
+  Double_t         fEtaGap;        //  Eta gap value
+  TList            fBinsForward;   //  List with forward VertexBin objects 
+  TList            fBinsCentral;   //  List with central VertexBin objects
+  TList*           fSumList;       //  Sum list
+  TList*           fOutputList;    //  Output list
+  AliAODEvent*     fAOD;           //  AOD event
+  AliESDtrackCuts* fESDTrackCuts;  //  ESD track cuts
+  Int_t            fMaxMoment;     //  Calculate v_{n} flag
+  Float_t          fVtx;           //  Z vertex bin
+  Double_t         fCent;          //  Centrality
+  TH2D             fHistdNdedpV0;  //  VZERO d^2N/detadphi histogram
+  TH2D             fHistdNdedp3Cor;//  VZERO d^2N/detadphi histogram
+  TH2D*            fHistFMDSPDCorr;//  Diagnostics hist for multiplicity correlations between FMD and SPD
+  TH1D*            fHistCent;      //  Diagnostics hist for centrality
+  TH1D*            fHistVertexSel; //  Diagnostics hist for selected vertices
+  TH1I*            fHistEventSel;  //  Diagnostics hist for event selection
 
-  ClassDef(AliForwardFlowTaskQC, 3); // Analysis task for FMD analysis
+  ClassDef(AliForwardFlowTaskQC, 4); // Analysis task for flow analysis
 };
 
 #endif
index dfd884e3cd09ac65bc19d1edd7ee60ae16e09c84..f628d8aa601342c0e29069d9dcbb050c5d5f7a03 100644 (file)
@@ -7,26 +7,17 @@
 // Outputs:
 //  - AnalysisResults.root
 //
-/**
- * @file   AliForwardMCFlowTaskQC.cxx
- * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
- * @date   Thu Feb  7 01:09:19 2013
- * 
- * @brief  
- * 
- * 
- * @ingroup pwglf_forward_flow
- */
 #include "AliForwardMCFlowTaskQC.h"
 #include "AliAODMCParticle.h"
 #include "AliAODMCHeader.h"
 #include "TGraph.h"
 #include "TF1.h"
-#include "TProfile2D.h"
 #include "AliAODEvent.h"
 #include "AliAODForwardMult.h"
 #include "AliAODCentralMult.h"
 #include "AliGenEventHeader.h"
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
 
 ClassImp(AliForwardMCFlowTaskQC)
 #if 0
@@ -35,18 +26,19 @@ ClassImp(AliForwardMCFlowTaskQC)
 //_____________________________________________________________________
 AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC() 
   : AliForwardFlowTaskQC(), 
-    fBinsFMDTR(),          // List of FMDTR analysis objects
-    fBinsSPDTR(),          // List of SPDTR analysis objects
-    fBinsMC(),             // List of MC truth analysis objects
-    fdNdedpMC(),           // MC truth d^2N/detadphi histogram
+    fBinsForwardTR(),      // List of FMDTR analysis objects
+    fBinsCentralTR(),      // List of SPDTR analysis objects
+    fBinsMC(),             // List of MC particle analysis objects
+    fHistdNdedpMC(),       // MC particle d^2N/detadphi histogram
+    fHistFMDMCCorr(),      // FMD MC correlation
+    fHistSPDMCCorr(),      // SPD MC correlation
     fWeights(),            // Flow weights
     fImpactParToCent(),    // Impact parameter to centrality graph
     fUseImpactPar(0),      // Use impact par for centrality
-    fFMDMinEta(-6),        // FMD min eta coverage for this vtx
-    fFMDMaxEta(6),         // FMD max eta coverage for this vtx
-    fAddFlow(0),           // Add flow to MC truth
-    fAddType(0),           // Add type of flow to MC truth
-    fAddOrder(0)           // Add order of flow to MC truth        
+    fUseMCVertex(0),       // Get vertex from MC header?
+    fAddFlow(0),           // Add flow to MC particles
+    fAddType(0),           // Add type of flow to MC particles
+    fAddOrder(0)           // Add order of flow to MC particles        
 {} 
   //
   // Default Constructor
@@ -54,18 +46,19 @@ AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC()
 //_____________________________________________________________________
 AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC(const char* name) 
   : AliForwardFlowTaskQC(name),
-    fBinsFMDTR(),          // List of FMDTR analysis objects
-    fBinsSPDTR(),          // List of SPDTR analysis objects
-    fBinsMC(),             // List of MC truth analysis objects
-    fdNdedpMC(),           // MC truth d^2N/detadphi histogram
+    fBinsForwardTR(),      // List of FMDTR analysis objects
+    fBinsCentralTR(),      // List of SPDTR analysis objects
+    fBinsMC(),             // List of MC particles analysis objects
+    fHistdNdedpMC(),       // MC particles d^2N/detadphi histogram
+    fHistFMDMCCorr(),      // FMD MC correlation
+    fHistSPDMCCorr(),      // SPD MC correlation
     fWeights(),            // Flow weights
     fImpactParToCent(),    // Impact parameter to centrality graph
     fUseImpactPar(0),      // Use impact par for centrality
-    fFMDMinEta(-6),        // FMD min eta coverage for this vtx
-    fFMDMaxEta(6),         // FMD max eta coverage for this vtx
-    fAddFlow(0),           // Add flow to MC truth
-    fAddType(0),           // Add type of flow to MC truth
-    fAddOrder(0)           // Add order of flow to MC truth        
+    fUseMCVertex(0),       // Get vertex from MC header?
+    fAddFlow(0),           // Add flow to MC particles
+    fAddType(0),           // Add type of flow to MC particles
+    fAddOrder(0)           // Add order of flow to MC particles        
 { 
   // 
   // Constructor
@@ -88,18 +81,19 @@ AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC(const char* name)
 //_____________________________________________________________________
 AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC(const AliForwardMCFlowTaskQC& o) 
   : AliForwardFlowTaskQC(o), 
-    fBinsFMDTR(),                          // List of FMDTR analysis objects
-    fBinsSPDTR(),                          // List of SPDTR analysis objects
-    fBinsMC(),                             // List of MC truth analysis objects
-    fdNdedpMC(o.fdNdedpMC),                // MC truth d^2N/detadphi histogram
+    fBinsForwardTR(),                      // List of FMDTR analysis objects
+    fBinsCentralTR(),                      // List of SPDTR analysis objects
+    fBinsMC(),                             // List of MC particles analysis objects
+    fHistdNdedpMC(o.fHistdNdedpMC),        // MC particles d^2N/detadphi histogram
+    fHistFMDMCCorr(o.fHistFMDMCCorr),      // FMD MC correlation
+    fHistSPDMCCorr(o.fHistSPDMCCorr),      // SPD MC correlation
     fWeights(o.fWeights),                  // Flow weights
     fImpactParToCent(o.fImpactParToCent),  // Impact parameter to centrality
     fUseImpactPar(o.fUseImpactPar),        // Use impact par for centrality
-    fFMDMinEta(o.fFMDMinEta),              // FMD min eta coverage for this vtx
-    fFMDMaxEta(o.fFMDMaxEta),              // FMD max eta coverage for this vtx
-    fAddFlow(o.fAddFlow),                  // Add flow to MC truth
-    fAddType(o.fAddType),                  // Add type of flow to MC truth
-    fAddOrder(o.fAddOrder)                 // Add order of flow to MC truth
+    fUseMCVertex(o.fUseMCVertex),          // Get vertex from MC header?
+    fAddFlow(o.fAddFlow),                  // Add flow to MC particles
+    fAddType(o.fAddType),                  // Add type of flow to MC particles
+    fAddOrder(o.fAddOrder)                 // Add order of flow to MC particles
 {
   //
   // Copy Constructor
@@ -115,12 +109,13 @@ AliForwardMCFlowTaskQC::operator=(const AliForwardMCFlowTaskQC& o)
   //    o Object to copy from 
   //
   if (&o == this) return *this;
-  fdNdedpMC        = o.fdNdedpMC;
+  fHistdNdedpMC    = o.fHistdNdedpMC;
+  fHistFMDMCCorr   = o.fHistFMDMCCorr;
+  fHistSPDMCCorr   = o.fHistSPDMCCorr;
   fWeights         = o.fWeights;
   fImpactParToCent = o.fImpactParToCent;
   fUseImpactPar    = o.fUseImpactPar;
-  fFMDMinEta       = o.fFMDMinEta;
-  fFMDMaxEta       = o.fFMDMaxEta;
+  fUseMCVertex     = o.fUseMCVertex;
   fAddFlow         = o.fAddFlow;
   fAddType         = o.fAddType;
   fAddOrder        = o.fAddOrder;
@@ -134,15 +129,21 @@ void AliForwardMCFlowTaskQC::InitVertexBins()
   //
   AliForwardFlowTaskQC::InitVertexBins();
 
-  Int_t moment = 0;
-  for(UShort_t n = 0; n < fV.GetSize(); n++) {
-    moment = fV.At(n);
-    for (Int_t v = 1; v <= fVtxAxis->GetNbins(); v++) {
-      Int_t vL = Int_t(fVtxAxis->GetBinLowEdge(v));
-      Int_t vH = Int_t(fVtxAxis->GetBinUpEdge(v));
-      fBinsFMDTR.Add(new VertexBin(vL, vH, moment, "FMDTR", fFlowFlags, fFMDCut, fEtaGap));
-      fBinsSPDTR.Add(new VertexBin(vL, vH, moment, "SPDTR", fFlowFlags, fSPDCut, fEtaGap));
-      fBinsMC.Add(new VertexBin(vL, vH, moment, "MC", fFlowFlags, -1, fEtaGap));
+  Bool_t isNUA = (fFlowFlags & kNUAcorr);
+  for (Int_t v = 1; v <= fVtxAxis->GetNbins(); v++) {
+    Int_t vL = Int_t(fVtxAxis->GetBinLowEdge(v));
+    Int_t vH = Int_t(fVtxAxis->GetBinUpEdge(v));
+    // FMD
+    if ((fFlowFlags & kFMD)) {
+      fBinsForwardTR.Add(new VertexBin(vL, vH, fMaxMoment, "FMDTR", fFlowFlags, fFMDCut, fEtaGap));
+      if (!(fFlowFlags & k3Cor)) fBinsCentralTR.Add(new VertexBin(vL, vH, fMaxMoment, "SPDTR", fFlowFlags, fSPDCut, fEtaGap));
+      if (isNUA) fFlowFlags ^= kNUAcorr;
+      fBinsMC.Add(new VertexBin(vL, vH, fMaxMoment, "MC-FMD", fFlowFlags, -1, fEtaGap));
+      if (isNUA) fFlowFlags ^= kNUAcorr;
+    }
+    // VZERO
+    else if ((fFlowFlags & kVZERO)) {
+      fBinsMC.Add(new VertexBin(vL, vH, fMaxMoment, "MC-VZERO", fFlowFlags, -1, fEtaGap));
     }
   }
 }
@@ -154,23 +155,34 @@ void AliForwardMCFlowTaskQC::InitHists()
   //
   AliForwardFlowTaskQC::InitHists();
 
-  fdNdedpMC = TH2D(Form("fdNdedpMC%s", ((fFlowFlags & kEtaGap) ? "_etaGap" : "")),
-                  Form("fdNdedpMC%s", ((fFlowFlags & kEtaGap) ? "_etaGap" : "")),
-                  48, -6., 6., 200, 0., 2.*TMath::Pi());
-  fdNdedpMC.Sumw2();
+  TString subDetName = ((fFlowFlags & kFMD) ? "FMD" : ((fFlowFlags & kVZERO) ? "VZERO" : "none"));
+  fHistdNdedpMC = TH2D(Form("fdNdedpMC%s%s", subDetName.Data(), GetQCType(fFlowFlags)),
+                  Form("fdNdedpMC%s%s", subDetName.Data(), GetQCType(fFlowFlags)),
+                  240, -6., 6., 200, 0., TMath::TwoPi());
+  
+  fHistFMDMCCorr = new TH2D("hFMDMCCorr", "hFMDMCCorr", 200, 0., 15000., 200, 0, 20000);
+  fHistSPDMCCorr = new TH2D("hSPDMCCorr", "hSPDMCCorr", 200, 0., 7500., 200, 0, 20000);
+  TList* dList = (TList*)fSumList->FindObject("Diagnostics");
+  if (!dList) {
+    dList = new TList();
+    dList->SetName("Diagnostics");
+    fSumList->Add(dList);
+  }
+  dList->Add(fHistFMDMCCorr);
+  dList->Add(fHistSPDMCCorr);
 
-  TIter nextFMDTR(&fBinsFMDTR);
+  TIter nextForwardTR(&fBinsForwardTR);
   VertexBin* bin = 0;
-  while ((bin = static_cast<VertexBin*>(nextFMDTR()))) {
-    bin->AddOutput(fSumList);
+  while ((bin = static_cast<VertexBin*>(nextForwardTR()))) {
+    bin->AddOutput(fSumList, fCentAxis);
   }
-  TIter nextSPDTR(&fBinsSPDTR);
-  while ((bin = static_cast<VertexBin*>(nextSPDTR()))) {
-    bin->AddOutput(fSumList);
+  TIter nextCentralTR(&fBinsCentralTR);
+  while ((bin = static_cast<VertexBin*>(nextCentralTR()))) {
+    bin->AddOutput(fSumList, fCentAxis);
   }
   TIter nextMC(&fBinsMC);
   while ((bin = static_cast<VertexBin*>(nextMC()))) {
-    bin->AddOutput(fSumList);
+    bin->AddOutput(fSumList, fCentAxis);
   }
 
   TList* wList = new TList();
@@ -189,36 +201,51 @@ Bool_t AliForwardMCFlowTaskQC::Analyze()
   if (!AliForwardFlowTaskQC::Analyze()) return kFALSE;
 
   // Run analysis on trackrefs from FMD and SPD
-  const AliAODForwardMult* aodfmult = 
-    static_cast<AliAODForwardMult*>(fAOD->FindListObject("ForwardMC"));
-  const AliAODCentralMult* aodcmult = 
-    static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClustersMC"));
+  AliAODForwardMult* aodfmult = static_cast<AliAODForwardMult*>(fAOD->FindListObject("ForwardMC"));
+  AliAODCentralMult* aodcmult = static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClustersMC"));
   Int_t vtx = fVtxAxis->FindBin(fVtx)-1;
   
   // if objects are present, get histograms
   if (aodfmult) {
-    const TH2D& fmdTRdNdetadphi = aodfmult->GetHistogram();
-    if ((fFlowFlags & kEtaGap)) {
-      FillVtxBinListEtaGap(fBinsFMDTR, fmdTRdNdetadphi, fmdTRdNdetadphi, vtx);
-    } else {
-      FillVtxBinList(fBinsFMDTR, fmdTRdNdetadphi, vtx);
+    TH2D& fmdTRdNdetadphi = aodfmult->GetHistogram();
+    if ((fFlowFlags & kStdQC)) {
+      FillVtxBinList(fBinsForwardTR, fmdTRdNdetadphi, vtx);
+    } else if ((fFlowFlags & kEtaGap)) {
+      FillVtxBinListEtaGap(fBinsForwardTR, fmdTRdNdetadphi, fmdTRdNdetadphi, vtx/*, kDoVtxCut*/);
     }
-    
     if (aodcmult) {
-      const TH2D& spdTRdNdetadphi = aodcmult->GetHistogram();
-      if ((fFlowFlags & kEtaGap)) {
-       FillVtxBinListEtaGap(fBinsSPDTR, fmdTRdNdetadphi, spdTRdNdetadphi, vtx);
-      } else {
-       FillVtxBinList(fBinsSPDTR, spdTRdNdetadphi, vtx);
+      TH2D& spdTRdNdetadphi = aodcmult->GetHistogram();
+      if ((fFlowFlags & kStdQC)) {
+       FillVtxBinList(fBinsCentralTR, spdTRdNdetadphi, vtx);
+      } else if ((fFlowFlags & kEtaGap)) {
+       FillVtxBinListEtaGap(fBinsCentralTR, fmdTRdNdetadphi, spdTRdNdetadphi, vtx/*, kDoVtxCut*/);
+      } else if ((fFlowFlags & k3Cor)) {
+       FillVtxBinList3Cor(fBinsForwardTR, spdTRdNdetadphi, fmdTRdNdetadphi, vtx);
       }
     }
   }
   // Run analysis on MC branch
-  if (!LoopAODMC()) return kFALSE;
-  if ((fFlowFlags & kEtaGap)) {
-    FillVtxBinListEtaGap(fBinsMC, fdNdedpMC, fdNdedpMC, vtx);
-  } else {
-    FillVtxBinList(fBinsMC, fdNdedpMC, vtx);
+  if (!FillMCHist()) return kFALSE;
+  if ((fFlowFlags & kStdQC)) {
+    FillVtxBinList(fBinsMC, fHistdNdedpMC, vtx);
+  } else if ((fFlowFlags & kEtaGap)) {
+    FillVtxBinListEtaGap(fBinsMC, fHistdNdedpMC, fHistdNdedpMC, vtx);
+  } else if ((fFlowFlags & k3Cor)) {
+    FillVtxBinList3Cor(fBinsMC, fHistdNdedpMC, fHistdNdedpMC, vtx);
+  }
+
+  // Mult correlation diagnostics
+  if (aodfmult && aodcmult) {
+    AliAODForwardMult* fmult = static_cast<AliAODForwardMult*>(fAOD->FindListObject("Forward"));
+    AliAODCentralMult* cmult = static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClusters"));
+    const TH2D& fhist = fmult->GetHistogram();
+    const TH2D& chist = cmult->GetHistogram();
+
+    Double_t totForward = fhist.Integral(1, fhist.GetNbinsX(), 1, fhist.GetNbinsY());
+    Double_t totSPD = chist.Integral(1, chist.GetNbinsX(), 1, chist.GetNbinsY());
+    Double_t totMC = fHistdNdedpMC.Integral(1, fHistdNdedpMC.GetNbinsX(), 1, fHistdNdedpMC.GetNbinsY());
+    fHistFMDMCCorr->Fill(totForward, totMC);
+    fHistSPDMCCorr->Fill(totSPD, totMC);
   }
 
   return kTRUE;
@@ -231,8 +258,8 @@ void AliForwardMCFlowTaskQC::Finalize()
   //
   AliForwardFlowTaskQC::Finalize();
 
-  EndVtxBinList(fBinsFMDTR);
-  EndVtxBinList(fBinsSPDTR);
+  EndVtxBinList(fBinsForwardTR);
+  EndVtxBinList(fBinsCentralTR);
   EndVtxBinList(fBinsMC);
 
   return;
@@ -248,7 +275,10 @@ Bool_t AliForwardMCFlowTaskQC::CheckTrigger(const AliAODForwardMult* aodfm) cons
   //
   // Returns true if B trigger is present - for some reason this is the one we use in MC
   //
-  return aodfm->IsTriggerBits(AliAODForwardMult::kB);
+  if (aodfm) return aodfm->IsTriggerBits(AliAODForwardMult::kB);
+  else return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))
+                 ->IsEventSelected() & AliVEvent::kMB);
+
 }
 // _____________________________________________________________________
 Bool_t AliForwardMCFlowTaskQC::GetCentrality(const AliAODForwardMult* aodfm)
@@ -262,44 +292,60 @@ Bool_t AliForwardMCFlowTaskQC::GetCentrality(const AliAODForwardMult* aodfm)
   //
   // Returns true when centrality is set.
   //
+//  fCent = 2.5;
+//  return kTRUE;
   if (fUseImpactPar) {
     fCent = GetCentFromB();
-    if (fCent != -1) return kTRUE;
-  }
-  return AliForwardFlowTaskQC::GetCentrality(aodfm);
+    if (fCentAxis->GetXmin() > fCent || fCent >= fCentAxis->GetXmax()) {
+      fHistEventSel->Fill(kInvCent);
+      return kFALSE;
+    }
+    if (fCent != 0) return kTRUE;
+    else {
+      fHistEventSel->Fill(kNoCent);
+      return kFALSE;
+    }
+  } else 
+    return AliForwardFlowTaskQC::GetCentrality(aodfm);
 }
 //_____________________________________________________________________
-void AliForwardMCFlowTaskQC::GetFMDLimits()
+Bool_t AliForwardMCFlowTaskQC::GetVertex(const AliAODForwardMult* aodfm)
 {
-
-  const AliAODForwardMult* aodfmult = 
-    static_cast<AliAODForwardMult*>(fAOD->FindListObject("Forward"));
-  const TH2D& h = aodfmult->GetHistogram();
-
-  for (Int_t e = 1; ; e++) {
-    if (h.GetBinContent(e, 0) != 0) { 
-      fFMDMinEta = h.GetXaxis()->GetBinLowEdge(e);
-      break;
-    }
-  }
-  for (Int_t e = h.GetNbinsX(); ; e--) {
-    if (h.GetBinContent(e, 0) != 0) { 
-      fFMDMaxEta = h.GetXaxis()->GetBinLowEdge(e);
-      break;
+  //
+  // Function to look for vertex determination in the event using the MC header.
+  //
+  // Parameters: 
+  //  AliAODForwardMult: Not used
+  //
+  // Returns true if vertex is determined
+  //
+  if (fUseMCVertex) {
+    AliAODMCHeader* header = 
+      static_cast<AliAODMCHeader*>(fAOD->FindListObject(AliAODMCHeader::StdBranchName()));
+    if (header) {
+      fVtx = header->GetVtxZ();
+      if (fVtx < fVtxAxis->GetXmin() || fVtx > fVtxAxis->GetXmax()) {
+        fHistEventSel->Fill(kInvVtx);
+       return kFALSE;
+      }
+      return kTRUE;
+    } else {
+      fHistEventSel->Fill(kNoVtx);
+      return kFALSE;
     }
-  }
-
-  return;
+  } else 
+    return AliForwardFlowTaskQC::GetVertex(aodfm);
 }
 //_____________________________________________________________________
-Bool_t AliForwardMCFlowTaskQC::LoopAODMC()  
+Bool_t AliForwardMCFlowTaskQC::FillMCHist()  
 {
   // 
   // Loop over AliAODParticle branch and fill d^2N/detadphi-histograms.
   // Add flow if set to do so in AddTask function
   //
-  fdNdedpMC.Reset();
-  GetFMDLimits();
+  fHistdNdedpMC.Reset();
+  Int_t minEta = -3.75;
+  Int_t maxEta = 5.;
 
   //retreive MC particles from event
   TClonesArray* mcArray = 
@@ -311,19 +357,21 @@ Bool_t AliForwardMCFlowTaskQC::LoopAODMC()
   }
 
   AliAODMCHeader* header = 
-    dynamic_cast<AliAODMCHeader*>(fAOD->FindListObject(
+    static_cast<AliAODMCHeader*>(fAOD->FindListObject(
                                   AliAODMCHeader::StdBranchName()));
   if (!header) 
     AliWarning("No header file found.");
-  
-  // Double_t rp = header->GetReactionPlaneAngle();
 
   Int_t ntracks = mcArray->GetEntriesFast();
-  // TODO: Make this bit smarter...
-  if (header->GetNCocktailHeaders() > 1) {
-    ntracks = header->GetCocktailHeader(0)->NProduced();
+//  Double_t rp = -1, b = -1;
+  if (header) {
+//    rp = header->GetReactionPlaneAngle();
+//    b = header->GetImpactParameter();
+    if (header->GetNCocktailHeaders() > 1) {
+      ntracks = header->GetCocktailHeader(0)->NProduced();
+    }
   }
-
+  
   UShort_t flowFlags = 0;
   if (fAddFlow.Length() > 1) {
     if (fAddFlow.Contains("pt"))   flowFlags |= AliForwardFlowWeights::kPt;
@@ -331,12 +379,9 @@ Bool_t AliForwardMCFlowTaskQC::LoopAODMC()
     if (fAddFlow.Contains("eta"))  flowFlags |= AliForwardFlowWeights::kEta;
     if (fAddFlow.Contains("cent")) flowFlags |= AliForwardFlowWeights::kCent;
   }
-  // Double_t b = header->GetImpactParameter();
 
-  // Track loop: chek how many particles will be accepted
-  Double_t weight = 0;
-  for (Int_t it = 0; it < ntracks; it++) {
-    weight = 1;
+  for (Int_t it = 0; it < ntracks; it++) { // Track loop
+    Double_t weight = 1;
     AliAODMCParticle* particle = (AliAODMCParticle*)mcArray->At(it);
     if (!particle) {
       AliError(Form("Could not receive track %d", it));
@@ -347,23 +392,26 @@ Bool_t AliForwardMCFlowTaskQC::LoopAODMC()
     //Double_t pT = particle->Pt();
     Double_t eta = particle->Eta();
     Double_t phi = particle->Phi();
-    if (eta >= fFMDMinEta && eta <= fFMDMaxEta) {
+    if (eta >= minEta && eta < maxEta) {
       // Add flow if it is in the argument
-      /* FLOW WEIGHTS DISABLED IN THE VERSION - COMING BACK SOON
-      if (flowFlags != 0) { 
+      // FLOW WEIGHTS DISABLED IN THE VERSION - COMING BACK SOON
+//      if (flowFlags != 0) { 
 //     weight = fWeights.CalcWeight(eta, pT, phi, particle->PdgCode(), 
 //                                  rp, fCent, fAddType, fAddOrder, 
 //                                  flowFlags) + 1;
-        weight = fWeights.CalcWeight(eta, pT, phi, particle->PdgCode(),
-                                    rp, b); 
+//        weight = fWeights.CalcWeight(eta, pT, phi, particle->PdgCode(),
+//                                    rp, b); 
 //      Printf("%f", weight);
-      }*/
-        fdNdedpMC.Fill(eta, phi, weight);
+//      }
+      fHistdNdedpMC.Fill(eta, phi, weight);
     }
   }
-  Int_t sBin = fdNdedpMC.GetXaxis()->FindBin(fFMDMinEta);
-  Int_t eBin = fdNdedpMC.GetXaxis()->FindBin(fFMDMaxEta);
-  for ( ; sBin < eBin; sBin++) fdNdedpMC.SetBinContent(sBin, 0, 1.);
+  // Set underflow bins for acceptance checks
+  Int_t sBin = fHistdNdedpMC.GetXaxis()->FindBin(minEta);
+  Int_t eBin = fHistdNdedpMC.GetXaxis()->FindBin(maxEta);
+  for ( ; sBin <= eBin; sBin++) {
+    fHistdNdedpMC.SetBinContent(sBin, 0, 1);
+  } // End of eta bin loop
 
   return kTRUE;
 }
@@ -379,37 +427,11 @@ Double_t AliForwardMCFlowTaskQC::GetCentFromB() const
                                                      StdBranchName()));
   if (!header) return cent;
   Double_t b = header->GetImpactParameter();
-
   cent = fImpactParToCent->Eval(b);
 
   return cent;
 }
 //_____________________________________________________________________
-void AliForwardMCFlowTaskQC::PrintFlowSetup() const  
-{
-  //
-  // Print the setup of the flow task
-  //
-  Printf("AliForwardMCFlowTaskQC::Print");
-  Printf("Number of bins in vertex axis:\t%d", fVtxAxis->GetNbins());
-  Printf("Range of vertex axis         :\t[%3.1f,%3.1f]", 
-                         fVtxAxis->GetXmin(), fVtxAxis->GetXmax());
-  printf("Doing flow analysis for      :\t");
-  for (Int_t n  = 0; n < fV.GetSize(); n++) printf("v%d ", fV.At(n));
-  printf("\n");
-  Printf("Satellite vertex flag           :\t%s", ((fFlowFlags & kSatVtx) ? 
-                                                  "true" : "false"));
-  Printf("Symmetrize ref. flow wrt eta = 0:\t%s", ((fFlowFlags & kSymEta) ? 
-                                                  "true" : "false"));
-  Printf("Use an eta-gap for ref. flow    :\t%s", ((fFlowFlags & kEtaGap) ? 
-                                                  "true" : "false"));
-  Printf("FMD sigma cut:               :\t%f", fFMDCut);
-  Printf("SPD sigma cut:               :\t%f", fSPDCut);
-  if ((fFlowFlags & kEtaGap)) 
-    Printf("Eta gap:                     :\t%f", fEtaGap);
-}
-//_____________________________________________________________________
 //
 //
 // EOF
-
index 4621395c59a8206cacb14d149e06fffe038a1ffc..7e12151bd4f249d977cbd2d5f160ea848cba6f59 100644 (file)
@@ -9,12 +9,10 @@
  * 
  * @brief  
  * 
- * 
  * @ingroup pwglf_forward_flow
  */
 #include "AliForwardFlowTaskQC.h"
 #include "AliForwardFlowWeights.h"
-#include <TH2D.h>
 class TGraph;
 
 /**
@@ -24,7 +22,7 @@ class TGraph;
  *   - AliAODEvent
  *
  * Outputs:
- *   - AnalysisResults.root
+ *   - forward_flow.root
  *
  * @ingroup pwglf_forward_tasks_flow
  * @ingroup pwglf_forward_flow
@@ -48,32 +46,19 @@ public:
    */
   virtual ~AliForwardMCFlowTaskQC() {}
   /**
-   * Check trigger from AODForwardMult object
-   * returns true if B trigger is present
-   *
-   * @param aodfm AliAODForwardMultObject
-   * 
-   * @return Bool_t 
-   */
-  virtual Bool_t CheckTrigger(const AliAODForwardMult* aodfm) const;
-  /**
-   * Check for centrality in AliAODForwardMult object, 
-   * if present return true - also sets fCent value
-   * can be used to get centrality from impact parameter
+   * Set use parametrization from impact parameter for centrality
    *
-   * @param aodfm AliAODForwardMultObject
-   * 
-   * @return Bool_t 
+   * @param use Use impact par
    */
-  virtual Bool_t GetCentrality(const AliAODForwardMult* aodfm);
+  void SetUseImpactParameter(Bool_t use = kTRUE) { fUseImpactPar = use; }
   /**
-   * Set use parametrization from impact parameter for centrality
+   * Set to get vertex from MC header
    *
-   * @param use Use impact par
+   * @param use Get from MC header
    */
-  void SetUseImpactParameter(Bool_t use) { fUseImpactPar = use; }
+  void SetUseMCHeaderVertex(Bool_t use = kTRUE) { fUseMCVertex = use; }
   /**
-   * Set string to add flow to MC truth particles
+   * Set string to add flow to MC particles particles
    *
    * @param type String
    */
@@ -125,43 +110,62 @@ protected:
    */
   void Finalize();
   /**
-   * Find FMD coverage for this vtx, to make MC histogram match
+   * Check trigger from AODForwardMult object
+   * returns true if B trigger is present
+   *
+   * @param aodfm AliAODForwardMultObject
+   * 
+   * @return Bool_t 
+   */
+  virtual Bool_t CheckTrigger(const AliAODForwardMult* aodfm) const;
+  /**
+   * Check for centrality in AliAODForwardMult object, 
+   * if present return true - also sets fCent value
+   * can be used to get centrality from impact parameter
+   *
+   * @param aodfm AliAODForwardMultObject
+   * 
+   * @return Bool_t 
    */
-  void GetFMDLimits();
+  virtual Bool_t GetCentrality(const AliAODForwardMult* aodfm);
+  /**
+   * Check for vertex in MCHeader
+   * returns true if in range of fVtxAXis, also sets fVtx value
+   *
+   * @param aodfm Not used
+   * 
+   * @return Bool_t 
+   */
+  virtual Bool_t GetVertex(const AliAODForwardMult* aodfm);
   /**
    * Loop over AliAODMCParticle branch object and fill d^2N/detadphi histograms
    * add flow if arguments are set
    * 
    * @return true on success
    */
-  Bool_t LoopAODMC();
+  Bool_t FillMCHist();
   /**
    * Get centrality form MC impact parameter
    *
    * @return Centrality
    */
   Double_t GetCentFromB() const;
-  /**
-   * Print the setup of the task
-   *
-   * @return void
-   */
-  virtual void PrintFlowSetup() const;
   
-  TList         fBinsFMDTR;         //  List with FMDTR VertexBin objects
-  TList         fBinsSPDTR;         //  List with SPDTR VertexBin objects
-  TList         fBinsMC;            //  List with MC VertexBin objects
-  TH2D          fdNdedpMC;          //  d^2N/detadphi MC truth histogram
-  AliForwardFlowWeights fWeights;   //  Flow after burner 
-  TGraph*       fImpactParToCent;   //  Parametrization of b to centrality
-  Bool_t        fUseImpactPar;      //  Flag to use impact parameter for cent
-  Double_t      fFMDMinEta;         //  FMD min. eta coverage for this vtx
-  Double_t      fFMDMaxEta;         //  FMD max. eta coverage for this vtx
-  TString       fAddFlow;           //  Add flow string
-  Int_t         fAddType;           //  Add flow type #
-  Int_t         fAddOrder;          //  Add flow order
+  TList                 fBinsForwardTR;   //  List with FMDTR VertexBin objects
+  TList                 fBinsCentralTR;   //  List with SPDTR VertexBin objects
+  TList                 fBinsMC;          //  List with MC VertexBin objects
+  TH2D                  fHistdNdedpMC;    //  d^2N/detadphi MC particles histogram
+  TH2D*                 fHistFMDMCCorr;   //  Diagnostics for mult. corr. between FMD and MC
+  TH2D*                 fHistSPDMCCorr;   //  Diagnostics for mult. corr. between SPD and MC
+  AliForwardFlowWeights fWeights;         //  Flow after burner 
+  TGraph*               fImpactParToCent; //  Parametrization of b to centrality
+  Bool_t                fUseImpactPar;    //  Flag to use impact parameter for cent
+  Bool_t                fUseMCVertex;     //  Get vertex from MC header
+  TString               fAddFlow;         //  Add flow string
+  Int_t                 fAddType;         //  Add flow type #
+  Int_t                 fAddOrder;        //  Add flow order
 
-  ClassDef(AliForwardMCFlowTaskQC, 3); // FMD MC analysis task 
+  ClassDef(AliForwardMCFlowTaskQC, 4); // FMD MC analysis task 
 };
  
 #endif
index 37bb0e56aec8f95fd908b37f2926f215b17aefb8..c602323b97932ab1758fe260d6281e3a01ad3e78 100644 (file)
@@ -134,7 +134,7 @@ AliForwardMultDists::BinSpec::Axis() const
     fAxis.Set(fN[0], fLow, fN[0]*fD[0]+fLow);
   }
   else { 
-    Int_t n = fN.GetSum();
+    Int_t n = Int_t(fN.GetSum());
     Int_t l = fN.GetSize();
     Int_t i = 0;
     TArrayD b(n+1);
@@ -185,7 +185,7 @@ AliForwardMultDists::AliForwardMultDists(const char* name)
     fUsePhiAcc(true),
     fIsSelected(false)
 {
-  /** 
+  /* 
    * User constructor 
    * 
    * @param name Name of the task 
@@ -197,7 +197,7 @@ AliForwardMultDists::AliForwardMultDists(const char* name)
 Bool_t
 AliForwardMultDists::Book()
 {
-  /** 
+  /* 
    * Create output objects - called at start of job in slave 
    * 
    */
@@ -207,10 +207,9 @@ AliForwardMultDists::Book()
 Bool_t
 AliForwardMultDists::PreData()
 {
-  /** 
+  /* 
    * Set-up internal structures on first seen event 
    * 
-   * @param hist Basic histogram template from AOD object 
    */
   AliAODEvent*       aod     = AliForwardUtil::GetAODEvent(this);
   AliAODForwardMult* forward = GetForward(*aod);
@@ -295,10 +294,10 @@ AliForwardMultDists::PreData()
 Bool_t
 AliForwardMultDists::Event(AliAODEvent& aod)
 {
-  /** 
+  /* 
    * Analyse a single event 
    * 
-   * @param option Not used
+   * @param aod Input event
    */
   AliAODForwardMult* forward = GetForward(aod, false, true);
   if (!forward) return false;
@@ -395,12 +394,9 @@ AliForwardMultDists::CheckEvent(const AliAODForwardMult& fwd)
 Bool_t
 AliForwardMultDists::Finalize()
 {
-  /*
+  /*
    * Called at the end of the final processing of the job on the
    * full data set (merged data)
-   * 
-   * 
-   * @param option Not used
    */
   fResults->Add(fSums->FindObject("triggers")->Clone());
   fResults->Add(fSums->FindObject("status")->Clone());
@@ -429,7 +425,7 @@ AliForwardMultDists::Finalize()
     
     Int_t mkrBits = GetIndexMarker(idx);
     while (*ph) { 
-      Int_t factor = TMath::Power(10, idx);
+      Int_t factor = Int_t(TMath::Power(10, idx));
       TH1* h = static_cast<TH1*>((*ph)->Clone());
       h->SetDirectory(0);
       h->Scale(factor);
@@ -458,7 +454,7 @@ AliForwardMultDists::Finalize()
 void
 AliForwardMultDists::ProjectX(const TH2& input, TH1& cache, Bool_t usePhiAcc)
 {
-  /*
+  /*
    * Project a 2D histogram into a 1D histogram taking care to use
    * either the @f$\phi@f$ acceptance stored in the overflow bins, or
    * the @f$\eta@f$ coverage stored in the underflow bins.
@@ -497,7 +493,7 @@ AliForwardMultDists::ProjectX(const TH2& input, TH1& cache, Bool_t usePhiAcc)
 void
 AliForwardMultDists::ProjectX(const TH2* input, TH1* cache)
 {
-  /*
+  /*
    * Project on @f$\eta@f$ axis.  If any of the pointers passed is
    * zero, do nothing.
    * 
@@ -536,7 +532,7 @@ void
 AliForwardMultDists::AddBin(Double_t etaLow, Double_t etaMax, 
                            const TAxis& mAxis) 
 {
-  /*
+  /*
    * Add an @f$\eta@f$ bin
    * 
    * @param etaLow Low cut on @f$\eta@f$
@@ -556,7 +552,7 @@ void
 AliForwardMultDists::AddBin(Double_t etaLow, Double_t etaMax, 
                            UShort_t nMax, UShort_t nDiv)
 {
-  /** 
+  /* 
    * Add an @f$\eta@f$ bin
    * 
    * @param etaLow Low cut on @f$\eta@f$
@@ -586,7 +582,7 @@ AliForwardMultDists::AddBin(Double_t etaLow, Double_t etaMax,
 void
 AliForwardMultDists::Print(Option_t* option) const 
 {
-  /** 
+  /* 
    * Print this task 
    * 
    * @param option Not used
@@ -622,7 +618,7 @@ AliForwardMultDists::EtaBin::EtaBin()
     fTruthAccepted(0),
     fCoverage(0)
 {
-  /** 
+  /* 
    * I/O constructor
    */
 }
@@ -644,7 +640,7 @@ AliForwardMultDists::EtaBin::EtaBin(Double_t minEta, Double_t maxEta,
     fTruthAccepted(0),
     fCoverage(0)
 {
-  /*
+  /*
    * User constructor 
    * 
    * @param minEta Least @f$\eta@f$ to consider 
@@ -677,8 +673,8 @@ AliForwardMultDists::EtaBin::EtaBin(Double_t minEta, Double_t maxEta,
   }
   else {
     // Rounded down maximum and minimum
-    Int_t max = mAxis.GetXmax(); 
-    Int_t min = mAxis.GetXmin();
+    Int_t max = Int_t(mAxis.GetXmax()); 
+    Int_t min = Int_t(mAxis.GetXmin());
     fTAxis.Set((max-min)+1, min-.5, max+.5);
   }
 }
@@ -833,7 +829,7 @@ void
 AliForwardMultDists::EtaBin::SetupForData(TList* list, const TH2& hist, 
                                          Bool_t useMC)
 {
-  /*
+  /*
    * Set-up internal structures on first event. 
    * 
    * @param list  List to add information to
@@ -937,7 +933,7 @@ AliForwardMultDists::EtaBin::Process(const TH1& sumForward,
                                     Bool_t     accepted, 
                                     const TH1* mc)
 {
-  /*
+  /*
    * Process a single event 
    * 
    * @param sumForward  Projection of forward data
@@ -1042,7 +1038,7 @@ AliForwardMultDists::EtaBin::Process(const TH1& sumForward,
 void
 AliForwardMultDists::EtaBin::Terminate(TList* in, TList* out)
 {
-  /*
+  /*
    * Called at the end of the final processing of the job on the
    * full data set (merged data)
    * 
index 824342b6a0eaef4043a486698abdaefe38779a4b..d1f562e78c89a2f4a3fb53ed5e7cd30f13f432fb 100644 (file)
@@ -18,7 +18,7 @@ class TH2;
 class AliAODForwardMult;
 
 /**
- * Class to make raw @f$P(N_{ch})@f$ distributions 
+ * Class to make raw @f$ P(N_{ch})@f$ distributions 
  * 
  * @ingroup pwglf_forward_multdist
  */
@@ -26,18 +26,26 @@ class AliForwardMultDists : public AliBaseAODTask
 {
 public:
   enum { 
+    /** Mark for invalid pseudo-rapidity */
     kInvalidEta = 999
   };
+  /** 
+   * Histogram enumeration 
+   */
   enum { 
+    /** Measured */
     kAnalysis = 1, 
+    /** MC-truth */
     kMC       = 2, 
+    /** MC-truth Triggered */
     kTrigger  = 3, 
+    /** MC-truth w/vertex */
     kVertex   = 4, 
+    /** MC-truth triggered and w/vertex */
     kTriggerVertex = 5
   };
   /**
    * Structure to define @f$\eta@f$ bins with an @f$ N_{ch}@f$ axis 
-   * 
    */
   struct BinSpec 
   {
@@ -73,12 +81,12 @@ public:
      * @return Reference to the axis 
      */
     const TAxis& Axis() const;
-    Double_t fEtaMin;
-    Double_t fEtaMax;
-    Double_t fLow;
-    TArrayI  fN;
-    TArrayD  fD;
-    mutable TAxis    fAxis;
+    Double_t fEtaMin; // Least pseudo-rapidity
+    Double_t fEtaMax; // Largest pseudo-rapidity
+    Double_t fLow;    // Low cut 
+    TArrayI  fN;      // Number of bins
+    TArrayD  fD;      // Bin widths 
+    mutable TAxis    fAxis; // Our axis 
   };
 
   /** 
@@ -95,6 +103,10 @@ public:
    * Destructor
    */
   virtual ~AliForwardMultDists() {}
+  /** 
+   * @{ 
+   * @name Interface memer functions 
+   */
   /** 
    * Create output objects - called at start of job in slave 
    * 
@@ -128,14 +140,19 @@ public:
    * @return true on success
    */
   Bool_t Finalize();
+  /* @} */
+  /**
+   * @{
+   * @name Bin definitions 
+   */
   /** 
-   * Add an @f$\eta@f$ bin
+   * Add an @f$ \eta@f$ bin
    * 
    * @param spec Bin specification 
    */
   void AddBin(const BinSpec& spec);
   /** 
-   * Add an @f$\eta@f$ bin
+   * Add an @f$ \eta@f$ bin.
    * 
    * @param etaLow Low cut on @f$\eta@f$  
    * @param etaMax High cut on @f$\eta@f$ 
@@ -152,6 +169,7 @@ public:
    *
    */
   void AddBin(Double_t etaLow, Double_t etaMax, UShort_t nMax, UShort_t nDiv); 
+  /* @} */
   /** 
    * Whether to use the stored phi acceptance 
    * 
index eecb888acf6fd0dda220c4a5453d56fe2e2b9e56..15209fb55ecb3687c27629e7585a7cff1cb9c00e 100644 (file)
@@ -157,6 +157,18 @@ AliForwardMultiplicityTask::Event(AliESDEvent& esd)
     if (fDoTiming) fHTiming->Fill(kTimingEventPlaneFinder,individual.CpuTime());
   }
   
+  // Check how many rings have been marked for skipping 
+  Int_t nSkip = 0;
+  for (UShort_t d=1; d<=3; d++) { 
+    for (UShort_t q=0; q<=(d/2); q++) { 
+      TH2D* h = fHistos.Get(d,q == 0 ? 'I' : 'O');
+      if (h && h->TestBit(AliForwardUtil::kSkipRing)) nSkip++;
+    }
+  }
+  if (nSkip > 0) 
+    // Skip the rest if we have too many outliers 
+    return false;
+  
   // Do the secondary and other corrections. 
   if (fDoTiming) individual.Start(true);
   if (!fCorrections.Correct(fHistos, ivz)) { 
@@ -175,7 +187,7 @@ AliForwardMultiplicityTask::Event(AliESDEvent& esd)
   }
   if (fDoTiming) fHTiming->Fill(kTimingHistCollector, individual.CpuTime());
 
-  if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel))
+  if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel) && nSkip < 1) 
     fHData->Add(&(fAODFMD.GetHistogram()));
 
   if (fDoTiming) fHTiming->Fill(kTimingTotal, total.CpuTime());
index 6da5701206fd84c5940080cc22e92662db6003b8..4d8b87e7fe2f6f184564b84296cdfffe99e42fbc 100644 (file)
@@ -31,21 +31,57 @@ ULong_t AliForwardUtil::AliROOTRevision()
 {
 #ifdef ALIROOT_SVN_REVISION
   return ALIROOT_SVN_REVISION;
-#else 
-  return 0;
+#elif defined(ALIROOT_REVISION)
+  static ULong_t ret = 0;
+  if (ret != 0) return ret;
+
+  // Select first 32bits of the 40byte long check-sum
+  TString rev(ALIROOT_REVISION, 8);
+  for (ULong_t i = 0; i < 8; i++) {
+    ULong_t p = 0;
+    switch (rev[i]) { 
+    case '0': p = 0; break;
+    case '1': p = 1; break;
+    case '2': p = 2; break;
+    case '3': p = 3; break;
+    case '4': p = 4; break;
+    case '5': p = 5; break;
+    case '6': p = 6; break;
+    case '7': p = 7; break;
+    case '8': p = 8; break;
+    case '9': p = 9; break;
+    case 'a': case 'A': p = 10; break;
+    case 'b': case 'B': p = 11; break;
+    case 'c': case 'C': p = 12; break;
+    case 'd': case 'D': p = 13; break;
+    case 'e': case 'E': p = 14; break;
+    case 'f': case 'F': p = 15; break;
+    }
+    ret |= (p << (32-4*(i+1)));
+  }
+  return ret;
 #endif
 }
 //____________________________________________________________________
 ULong_t AliForwardUtil::AliROOTBranch()
 {
   // Do something here when we switch to git - sigh!
-#ifdef ALIROOT_SVN_BRANCH
+#if !defined(ALIROOT_SVN_BRANCH) && !defined(ALIROOT_BRANCH) 
+  return 0;
+#endif
   static ULong_t ret = 0;
   if (ret != 0) return ret;
-  
-  TString str(ALIROOT_SVN_BRANCH);
+  TString str;
+  TString top;
+#ifdef ALIROOT_SVN_BRANCH
+  str = ALIROOT_SVN_BRANCH;
+  top = "trunk";
+#elif defined(ALIROOT_BRANCH)
+  str = ALIROOT_BRANCH;
+  top = "master";
+#endif
   if (str[0] == 'v') str.Remove(0,1);
-  if (str.EqualTo("trunk")) return ret = 0xFFFFFFFF;
+  if (str.EqualTo(top)) return ret = 0xFFFFFFFF;
 
   TObjArray*   tokens = str.Tokenize("-");
   TObjString*  pMajor = static_cast<TObjString*>(tokens->At(0));
@@ -63,9 +99,6 @@ ULong_t AliForwardUtil::AliROOTBranch()
     (pAn ? 0xAA : 0));
   
   return ret;
-#else 
-  return 0;
-#endif
 }
 
 //====================================================================
@@ -546,6 +579,14 @@ Double_t AliForwardUtil::GetPhiFromStrip(Char_t ring, UShort_t strip,
 //====================================================================
 TAxis*
 AliForwardUtil::MakeFullIpZAxis(Int_t nCenter)
+{
+  TArrayD bins;
+  MakeFullIpZAxis(nCenter, bins);
+  TAxis* a = new TAxis(bins.GetSize()-1,bins.GetArray());
+  return a;
+}
+void
+AliForwardUtil::MakeFullIpZAxis(Int_t nCenter, TArrayD& bins)
 {
   // Custom vertex axis that will include satellite vertices 
   // Satellite vertices are at k*37.5 where k=-10,-9,...,9,10 
@@ -563,7 +604,7 @@ AliForwardUtil::MakeFullIpZAxis(Int_t nCenter)
   const Int_t    nBins   = 2*nSat + nCenter;
   const Int_t    mBin    = nBins / 2;
   Double_t       dCenter = 2*mCenter / nCenter;
-  TArrayD        bins(nBins+1);        
+  bins.Set(nBins+1);
   bins[mBin] = 0;
   for (Int_t i = 1; i <= nCenter/2; i++) { 
     // Assign from the middle out 
@@ -579,9 +620,18 @@ AliForwardUtil::MakeFullIpZAxis(Int_t nCenter)
     bins[mBin-o] = -v;
     bins[mBin+o] = +v;
   }
-  TAxis* a = new TAxis(nBins,bins.GetArray());
-  return a;
 }
+void 
+AliForwardUtil::MakeLogScale(Int_t    nBins, 
+                            Int_t    minOrder, 
+                            Int_t    maxOrder, 
+                            TArrayD& bins)
+{
+  Double_t dO = Double_t(maxOrder-minOrder) / nBins; 
+  bins.Set(nBins+1);
+  for (Int_t i = 0; i <= nBins; i++) bins[i] = TMath::Power(10, i * dO);
+}
+
 void 
 AliForwardUtil::PrintTask(const TObject& o)
 {
@@ -1559,11 +1609,11 @@ AliForwardUtil::Histos::Clear(Option_t* option)
   // Parameters:
   //    option Not used 
   //
-  if (fFMD1i) fFMD1i->Reset(option);
-  if (fFMD2i) fFMD2i->Reset(option);
-  if (fFMD2o) fFMD2o->Reset(option);
-  if (fFMD3i) fFMD3i->Reset(option);
-  if (fFMD3o) fFMD3o->Reset(option);
+  if (fFMD1i) { fFMD1i->Reset(option); fFMD1i->ResetBit(kSkipRing); }
+  if (fFMD2i) { fFMD2i->Reset(option); fFMD2i->ResetBit(kSkipRing); }
+  if (fFMD2o) { fFMD2o->Reset(option); fFMD2o->ResetBit(kSkipRing); }
+  if (fFMD3i) { fFMD3i->Reset(option); fFMD3i->ResetBit(kSkipRing); }
+  if (fFMD3o) { fFMD3o->Reset(option); fFMD3o->ResetBit(kSkipRing); }
 }
 
 //____________________________________________________________________
index d1ec6401c61870e9678a9fd46bbf7062aa163a33..297a3e90d12d8463bb24add934840b5c1abc554c 100644 (file)
@@ -22,6 +22,7 @@ class TH1I;
 class TH1;
 class TF1;
 class TAxis;
+class TArrayD;
 class AliESDEvent;
 class AliAODEvent;
 class AliAnalysisTaskSE;
@@ -34,6 +35,9 @@ class AliAnalysisTaskSE;
 class AliForwardUtil : public TObject
 {
 public:
+  enum { 
+    kSkipRing = (1 << 19) // Bit for skipping a histogram
+  };
   /** 
    * Get the standard color for a ring  
    *
@@ -281,6 +285,8 @@ public:
    * @name Axis functions 
    */
   static TAxis* MakeFullIpZAxis(Int_t nCenter=20);
+  static void MakeFullIpZAxis(Int_t nCenter, TArrayD& bins);
+  static void MakeLogScale(Int_t nBins, Int_t minOrder, Int_t maxOrder, TArrayD& bins);
   static void PrintTask(const TObject& o);
   static void PrintName(const char* name);
   static void PrintField(const char* name, const char* value, ...);
@@ -735,7 +741,7 @@ public:
      * Constructor
      * 
      */
-    RingHistos() : fDet(0), fRing('\0'), fName("") {}
+    RingHistos() : fDet(0), fRing('\0'), fName(""), fkNSector(0), fkNStrip(0) {}
     /** 
      * 
      * 
@@ -743,7 +749,9 @@ public:
      * @param r Ring 
      */
     RingHistos(UShort_t d, Char_t r) 
-      : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r)) 
+      : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r)),
+       fkNSector(r == 'i' || r == 'I' ? 20 : 40), 
+       fkNStrip(r == 'i' || r == 'I' ? 512 : 256)
     {}
     /** 
      * Copy constructor
@@ -751,7 +759,8 @@ public:
      * @param o Object to copy from 
      */
     RingHistos(const RingHistos& o) 
-      : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName)
+      : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName),
+       fkNSector(o.fkNSector), fkNStrip(o.fkNStrip)
     {}
     /** 
      * 
@@ -771,6 +780,8 @@ public:
       fDet  = o.fDet;
       fRing = o.fRing;
       fName = o.fName;
+      fkNSector = o.fkNSector;
+      fkNStrip  = o.fkNStrip;
       return *this;
     }
     /** 
@@ -814,9 +825,19 @@ public:
      * @return Name of this ring 
      */
     const char* GetName() const { return fName.Data(); } 
+    /** 
+     * Get number of sectors 
+     */
+    const UShort_t& NSector() const { return fkNSector; }
+    /** 
+     * Get number of strips 
+     */
+    const UShort_t& NStrip() const { return fkNStrip; }
     UShort_t fDet;   // Detector
     Char_t   fRing;  // Ring
     TString  fName;  // Name
+    UShort_t fkNSector; // Number of sectors 
+    UShort_t fkNStrip;  // Number of strips 
 
     ClassDef(RingHistos,1) 
   };
index aaca8ebe8767c801f22c2328bbba25ddd00441c9..fb1ab0b5540d922437f9206bfb705f694fce3f73 100644 (file)
@@ -343,9 +343,9 @@ AliOADBForward::Table::Query(ULong_t        runNo,
   ULong_t  oldDist = 0xFFFFFFFF;
   Int_t    entry  = -1;
   for (Int_t row = 0; row < nRows; row++) {
-    Int_t    ent  = fTree->GetV1()[row];
-    ULong_t  run  = fTree->GetV2()[row];
-    ULong_t  tim  = fTree->GetV3()[row];
+    Int_t    ent  = Int_t(fTree->GetV1()[row]);
+    ULong_t  run  = ULong_t(fTree->GetV2()[row]);
+    ULong_t  tim  = ULong_t(fTree->GetV3()[row]);
     ULong_t  dist = (run > runNo ? run - runNo : runNo - run);
        
     if (fVerbose) {
@@ -819,6 +819,30 @@ AliOADBForward::Insert(const TString& table,
 
   return t->Insert(o, runNo, sys, sNN, field, mc, sat, aliRev, author);
 }          
+//____________________________________________________________________
+Bool_t
+AliOADBForward::CopyEntry(const TString& table, 
+                         ULong_t        oldRunNo, 
+                         UShort_t       oldSys, 
+                         UShort_t       oldSNN, 
+                         Short_t        oldField, 
+                         ULong_t        newRunNo, 
+                         UShort_t       newSys, 
+                         UShort_t       newSNN, 
+                         Short_t        newField, 
+                         Bool_t         mc, 
+                         Bool_t         sat)
+{
+  Table* t = FindTable(table);
+  if (!t) return false;
+
+  Entry* e = t->Get(oldRunNo, t->fMode, oldSys, oldSNN, oldField, mc, sat);
+  if (!e) return false;
+
+  return t->Insert(e->fData, newRunNo, newSys, newSNN, newField, mc, sat, 
+               e->fAliROOTRevision, e->fAuthor);
+}
+
 //____________________________________________________________________
 void
 AliOADBForward::Print(const Option_t* option) const
index 30cef04e643c4db70941e01f7ac51ef8df7c578b..0ef7279173bd32018ac37ae97b1e77d35b75f262 100644 (file)
@@ -555,6 +555,34 @@ public:
                Bool_t         sat=false,
                ULong_t        aliRev=0,
                const TString& author="");
+  /** 
+   * Copy one entry to another entry 
+   * 
+   * @param table      Table name 
+   * @param oldRunNo   Old run number 
+   * @param oldSys     Old collision system
+   * @param oldSNN     Old center of mass energy 
+   * @param oldField   Old L3 magnetic field strength
+   * @param newRunNo   New run number               
+   * @param newSys     New collision system         
+   * @param newSNN     New center of mass energy     
+   * @param newField   New L3 magnetic field strength
+   * @param mc         True for MC only queries
+   * @param sat        True for including satellite queries
+   * 
+   * @return true on success 
+   */
+  Bool_t CopyEntry(const TString& table, 
+                  ULong_t        oldRunNo, 
+                  UShort_t       oldSys,
+                  UShort_t       oldSNN, 
+                  Short_t        oldField, 
+                  ULong_t        newRunNo,
+                  UShort_t       newSys,
+                  UShort_t       newSNN, 
+                  Short_t        newField, 
+                  Bool_t         mc, 
+                  Bool_t         sat);
   /* @} */
   /** 
    * Print the content of all tables
index a240507ef159382fd68df703ef6ca1da59df5b3b..4f4d0f22349e4d4a674a2ae32cd8426629bc6721 100644 (file)
@@ -406,6 +406,13 @@ AliPoissonCalculator::Result(Bool_t correct)
       fBasic->SetBinError(ix,iy,poissonE);
     }
   }
+  return fBasic;
+}
+  
+//____________________________________________________________________
+void
+AliPoissonCalculator::FillDiagnostics()
+{
   for (Int_t ix = 1; ix <= fEmpty->GetNbinsX(); ix++) { 
     for (Int_t iy = 1; iy <= fEmpty->GetNbinsY(); iy++) { 
       Double_t empty    = fEmpty->GetBinContent(ix, iy);
@@ -419,9 +426,7 @@ AliPoissonCalculator::Result(Bool_t correct)
       fCorr->Fill(mean, corr);
     }
   }
-  return fBasic;
 }
-  
 //____________________________________________________________________
 void
 AliPoissonCalculator::Print(const Option_t*) const
index 1d953946b6009232ad6a986f3d52f567114f39d8..c526d82b360e1a17c4413f8abb6e08e54cff64bd 100644 (file)
@@ -134,6 +134,11 @@ public:
    * @return The result histogram (fBase overwritten)
    */
   TH2D* Result(Bool_t correct=true);
+  /** 
+   * After calculating the results, fill the diagnostics histograms 
+   * 
+   */
+  void FillDiagnostics();
   /** 
    * @return Always true 
    */
@@ -279,7 +284,7 @@ protected:
   TH1D*    fMean;         // Mean calculated by poisson method 
   TH1D*    fOcc;          // Histogram of occupancies 
   TH2D*    fCorr;         // Correction as a function of mean 
-  ClassDef(AliPoissonCalculator,2) // Calculate N_ch using Poisson
+  ClassDef(AliPoissonCalculator,3) // Calculate N_ch using Poisson
 };
 
 #endif
index 5700c0853f9290204e978ef426aa264a0d1b611a..8dba561586fec6a3652e81e4027d427f6226b8b5 100644 (file)
@@ -147,6 +147,11 @@ ForwardAODConfig(AliForwardMultiplicityBase* task)
   task->GetDensityCalculator().SetRecalculatePhi(true);
   // Least acceptable quality of ELoss fits
   task->GetDensityCalculator().SetMinQuality(8);
+  // Set the maximum ratio of outlier bins to the total number of bins
+  // task->GetDensityCalculator().SetMaxOutliers(.10);
+  task->GetDensityCalculator().SetMaxOutliers(1.0);//Disable filter
+  // Set the maximum relative diviation between N_ch from Eloss and Poisson
+  task->GetDensityCalculator().SetOutlierCut(0.5);
   // Set whether or not to use the phi acceptance
   //   AliFMDDensityCalculator::kPhiNoCorrect
   //   AliFMDDensityCalculator::kPhiCorrectNch
index 4109afef22620a9cdbe6d0ef20c5b1a3c309887b..049259dbff9251e5532e7764430dd875697a28b4 100644 (file)
@@ -1,32 +1,21 @@
 /**
  * @file   MakeFlow.C
  * @author Alexander Hansen 
- * @date   Wed Mar 23 12:11:33 2011
  * 
  * @brief  
  * 
- * @ingroup pwg2_forward_scripts_makers
+ * @ingroup pwglf_forward_scripts_makers
  * 
  */
 //====================================================================
 /**
  * Script to analyse AOD input for flow
  * 
- * Takes either a single (AOD) .root file as input or a .txt
- * The .txt file is expected to contain the path to the files 
- * from the current directory or the absolute path.
- * 
- * @par Inputs: 
- *  
- * 
- * @par Outputs: 
- * - 
- *
  * @param name     Name of train 
  * @param options  Options @see RunTrain 
  * @param mode     Which execution environment 
- * @param datadir  Data directory 
- * @param urlOpts  URL options 
+ * @param datadir  Data directory/proof path 
+ * @param urlOpts  URL options
  *
  * @ingroup pwglf_forward_flow
  */
@@ -42,7 +31,7 @@ void MakeFlow(TString name    = "flow",
   
   gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/trains/RunTrain.C");
 
-  if (!datadir.EndsWith("/")) datadir.Append("/");
+  if (!datadir.EndsWith("/") && !mode.Contains("proof")) datadir.Append("/");
   
   TUrl url(datadir.Data());
   url.SetProtocol(mode.Data());
index 162eeae4a1cf896905f6c3bddd1e3d2aeaf8c35e..06cbccb45ce3f347d0c337eab7ebd6891cb45dd5 100644 (file)
@@ -691,8 +691,10 @@ protected:
       TDirectory* savDir = gDirectory;
       if (!gSystem->AccessPathName(fELossExtra.Data())) {
        hists = TFile::Open(fELossExtra, "READ");
-       // Info("", "Opened forward_eloss.root -> %p", hists);
+       Info("", "Opened forward_eloss.root -> %p", hists);
       }
+      else 
+       Warning("", "Couldn't open %s", fELossExtra.Data());
       if (hists) {
        TList* fr = static_cast<TList*>(hists->Get("ForwardELossResults"));
        // Info("", "Got forward results -> %p", fr);
@@ -771,9 +773,10 @@ protected:
          // Info("", "Got detector list -> %p", dl);
          if (dl) { 
            // Info("", "Detector list: %s", dl->GetName());
-           dists = static_cast<TList*>(dl->FindObject("EDists"));
+           dists = static_cast<TList*>(dl->FindObject("elossDists"));
            // Info("", "Got distributions -> %p", dists);
-           resis = static_cast<TList*>(dl->FindObject("residuals"));
+           resis = static_cast<TList*>(dl->FindObject("elossResiduals"));
+           // Info("", "Got residuals -> %p", resis);
          }
        }
        
@@ -856,6 +859,8 @@ protected:
        }
        if (dist) { 
          // Info("", "Histogram: %s", dist->GetName());
+         dist->SetFillStyle(3001);
+         dist->SetMarkerStyle(0);
          DrawInPad(drawPad, subPad, dist, "HIST E", (subPad * kGridx) + kLogy);
          same = true;    
        }
index ba8a5daa5596dff78b20eccdd843383ad7928bfc..9c39c2c2117c990ff23ffdeb5a13e134ad3cfa90 100644 (file)
 #error This file is not for compilation 
 /** 
- * @page train_setup_doc Using the TrainSetup facility 
- *
- * @tableofcontents
- *
- * @section train_setup_overview Overview 
- *
- * The TrainSetup framework allows users to easily set up an analysis
- * train which can be executed in all environments supported by ALICE. 
- * 
- * The train definition takes the form of a class deriving from the
- * base class TrainSetup.  
- *
- * Specific hooks in the base class allows users to customize the
- * various aspects of a train.  The base class also facilities to
- * easily define parameters of the train which can be set by parsing
- * simple command line options or strings.  Furthermore, the basic
- * setup ensures that the analysis becomes a self-contained,
- * self-documenting unit by storing all relevant files together with
- * the various kinds of output generated during the analysis job.
- *
- * The execution environment (local, Proof, Grid) is specified as a
- * simple URL like string, with room for environment specific options.
- * This scheme allows a user to run the same analysis in various
- * environments by simply changing the execution environment URL with
- * another URL.  Various helpers for each type of environment ensures
- * that all needed steps are taken to help ensure successful execution
- * of the analysis regardless of the underlying execution environment.
- *
- * Trains defined using this framework can either be executed in an
- * interactive AliROOT session or using a stand-alone program.
- *
- * @section train_setup_usage Usage
- *
- * Users should define a class that derives from TrainSetup.  The class
- * should implement the member function TrainSetup::CreateTasks to add
- * needed tasks to the train
- * 
- * @code 
- * // MyTrain.C 
- * class MyTrain : public TrainSetup
- * {
- * public:
- *   MyTrain(const char* name="MyTrain")
- *     : TrainSetup(name), 
- *   {
- *      // fOptions.Set("type", "AOD"); // AOD input
- *      // fOptions.Set("type", "ESD"); // ESD input
- *      fOptions.Add("parameter", "VALUE", "Help on parameter", "value");
- *   }
- * protected:
- *   void CreateTasks(AliAnalysisManager* mgr)
- *   {
- *     AliAnalysisManager::SetCommonFileName("my_analysis.root");
- *     fHelper->LoadLibrary("MyAnalysis", true);
- *     Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
- *     Double_t param = fOptions.AsDouble("parameter");
- *     gROOT->Macro(Form("AddTaskMyAnalysis.C(%f)",param));
- *   }
- *   const char* ClassName() const { return "MyTrain"; }
- * };
- * @endcode 
- *
- * @section train_setup_params Parameters of the setup 
- *
- * Parameters of the user defined class deriving from TrainSetup is
- * best handled by adding options to the internal member @c fOptions
- * in the constructor e.g.,
- *
- * @code 
- *   fOptions.Add("<name>", "<dummy>", "<description>", "<default>");
- *   fOptions.Add("<name>", "<dummy>", "<description>", defaultInt_t);
- *   fOptions.Add("<name>", "<dummy>", "<description>", defaultLong64_t);
- *   fOptions.Add("<name>", "<dummy>", "<description>", defaultDouble_t);
- *   fOptions.Add("<name>", "<description>");
- *   fOptions.Add("<name>", "<description>", defaultBool);
- * @endcode
- * 
- * The first 4 forms defined a parameter that has a value, while the
- * last 2 forms defines a flag (or toggle).  The values or flags can be
- * retrieved later by doing
- * 
- * @code 
- *    Double_t value = fOptions.AsDouble("<name>",<value if not set>);
- *    Int_t    value = fOptions.AsInt("<name>",<value if not set>);
- *    Long64_t value = fOptions.AsLong("<name>",<value if not set>);
- *    Bool_t   value = fOptions.AsBool("<name>",<value if not set>)
- *    TString  value = fOptions.Get("<name>");
- *    Bool_t   value = fOptions.Has("<name>");
- * @endcode
- *
- * Parameters defined this way are directly accessible as options to
- * pass to either runTrain or RunTrain.C
- *
- * @section train_setup_exec Execution of the train 
- *
- * A user defined TrainSetup class can then be run like 
- * 
- * @code 
- * Root> .x RunTrain.C("<class>", "<name>", "<uri>", "<options>")
- * @endcode 
- * 
- * or using the program @b runTrain
- * 
- * @code
- * > runTrain --class=<class> --name=<name> --url=<uri> [<options>] 
- * @endcode
- *
- * Here, 
- *
- * - &lt;class&gt; is the name of the user defined class deriving from
- *   TrainSetup.
- * 
- * - &lt;name&gt; is an arbitary name to give to the train. Note, an
- *   @e escaped @e name will be generated from this, which replaces
- *   all spaces and the like with '_' and (optionally) with the date
- *   and time appended. 
- *
- * - &lt;uri&gt; is the job execution URI which specified both the
- *   execution environment and the input data, as well as some options.  
- *   See more below. 
- *
- * - &lt;options&gt; is a list of options.  For RunTrain this is a
- *   comma separated list of options in the form
- *   &lt;option&gt;=&lt;value&gt; for value options and &lt;option&gt;
- *   for flags (booleans).  For @c runTrain, the options are of the
- *   traditional Unix long type: @c --&lt;option&gt;=&lt;value&gt; and
- *   @c --&lt;option&gt;.  The exact list of options for a given train
- *   can be listed by passing the option @b help.
- *
- * See also ::RunTrain and ::main
- *
- * In both cases, a new sub-directory called @e escaped @e name of the
- * train is created, and various files are copied there - depending on
- * the mode of execution.
- *
- * For local analysis, no aditional files are copied there, but the
- * output will be put there. 
- *
- * For PROOF analysis, the needed PAR files are copied there and
- * expanded.  The output of the job may end up in this directory if so
- * instructed.
- *
- * For Grid analysis, various JDL and steering scripts are copied to
- * this directory.  Scripts to run merge/terminate stages and to
- * download the results are also generated for the users convinence.
- * The special generated script <tt>Watch.C</tt> will monitor the
- * progess of the jobs and automatically execute the needed merging
- * and terminate stages.  Various files needed by the train are copied
- * to the Grid working directory as a form of documentation.
- *
- * In all cases, a file named @c ReRun.C (and for @b runTrain:
- * rerun.sh) is generated in this sub-directory.  It contains the
- * setting used for the train and can easily be used to run jobs again
- * as well as serve as a form of documentation.
- *
- * @section train_setup_url_spec Execution URI 
- *
- * This URI has the form 
- * @code 
- *  <protocol>://[[<user>@]<host>]/<input>[?<options>][#<treename>]
- * @endcode 
- * and specifies several things.
- * 
- * <dl>
- *   <dt><tt>&lt;protocol&gt;</tt></dt>
- *   <dd>One of 
- *     <dl>
- *       <dt><tt>local</tt></dt>
- *       <dd>Local analysis on local data executed sequentially on the
- *         local machine</dd>
- *       <dt><tt>lite</tt></dt>
- *       <dd>Proof-Lite analysis on local data executed in parallel on
- *         the local machine</dd>
- *       <dt><tt>proof</tt></dt> 
- *       <dd>Proof analysis on cluster data executed in parallel on a
- *         PROOF cluster</dd>
- *       <dt><tt>alien</tt></dt>
- *       <dd>Grid analysis on grid data executed on the Grid</dd>
- *     </dl>
- *   </dd>
- *   <dt><tt>[[&lt;user&gt;@]&lt;host&gt;]</tt></dt>
- *   <dd>Sets the master host for Proof analysis</dd>
- *   <dt><tt>&lt;input&gt;</tt></dt>
- *   <dd>Input data specification.  The exact form depends on the
- *     protocol used e.g., for local analysis it can be a single,
- *     while for other environments it could be a data set name, and
- *     so on.</dd>
- *   <dt><tt>&lt;options&gt;</tt></dt>
- *   <dd>Protocol specific options</dd>
- *   <dt><tt>&lt;treename&gt;</tt></dt>
- *   <dd>If specified, gives what data to analyse</dd>
- *  </dl>
- *       
- * @section train_setup_proof_spec PROOF specifics
- *
- * Local and Grid jobs are in a sense very similar.  That is, the
- * individual Grid jobs are very much like Local jobs, in that they
- * always produce output files (albiet not after Terminate, though
- * parameter container files are (re)made). 
- *
- * PROOF jobs are very different.  In a PROOF analysis, each slave
- * only produces in memory output which is then sent via net
- * connections (sockets) to the master.  One therefore needs to be
- * very of output object ownership and the like.  
- *
- * Another major difference is that output files are generated within
- * the PROOF cluster, and are generally not accessible from the
- * outside.  For plain PROOF clusters in a local area network or
- * so-called <i>Lite</i> session, it is generally not a problem since
- * the files are accessible on the LAN or local machine for Lite
- * sessions.  However, for large scale analysis farms (AAFs), the
- * workers and masters are generally on a in-accessible sub-net, and
- * there's no direct access to the produced files.  Now, for normal
- * output files, like histogram files, etc. there are provisions for
- * this, which means the final merged output is sent back to the
- * client.  Special output, such as AODs, are however not merged nor
- * sent back to the user by default.  There are two ways to deal with this: 
- * 
- * <ol>
- *  <li> Register the output tree as a data set on the cluster.  This
- *    is useful if you need to process the results again on the
- *    cluster.</li>
- *  <li> Send the output to a (possibly custom) XRootd server.  This
- *    is useful if you need to process the output outside of the
- *    cluster</li>
- * </ol>
- *
- * The first mode is specified by passing the option
- * <tt>dsname=</tt><i>&lt;name&gt;</i> in the cluster URI.  The created
- * dataset will normally be made in
- * <tt>/default/</tt><i>&lt;user&gt;</i><tt>/</tt><i>&lt;name&gt;</i>. If the
- * <tt>=</tt><i>&lt;name&gt;</i> part is left out, the <i>escaped name</i> of
- * the job will be used.  
- *
- * The second mode is triggered by passing the option
- * <tt>storage=<i>URI</i></tt> to the train setup.  The <i>URI</i>
- * should be of the form
- *
- * @code
- *   rootd://<host>[:<port>]/<path>
- * @endcode
- * 
- * where <i>&lt;host&gt;</i> is the name of a machine accessible by
- * the cluster, <i>&lt;port&gt;</i> is an optional port number (e.g.,
- * if different from 1093), and <i>&lt;path&gt;</i> is an absolute
- * path on <i>&lt;host&gt;</i>.
- * 
- * The XRootd process should be started (optionally by the user) on
- * <i>&lt;host&gt;</i> as
- *
- * @code
- *    xrootd -p <port> <path>
- * @endcode
- *
- * When running jobs on AAFs, one can use the Grid handler to set-up
- * aspects of the job.  To enable the Grid handler, pass the option
- * <tt>plugin</tt> in the execution URI
- *
- * @section train_setup_input Specifying the input
- * @subsection train_setup_local Local and Lite data input
- * 
- * For both ESD and AOD input for local jobs, one must specify the
- * root of the sub-tree that holds the data.  That is, if - for
- * example - the data resides in a directory structure like
- *
- * <pre>
- *   /some/directory/&lt;run&gt;/&lt;seq&gt;/AliESDs.root 
- * </pre>
- *
- * then one should specify the input location like 
- *
- * @code 
- *   local:///some/directory[?pattern=AliESDs.root][#esdTree]
- *   lite:///some/directory[?pattern=AliESDs.root][#esdTree]
- * @endcode
- *
- * <tt>/some/directory</tt> is then search recursively for input files
- * that match the pattern given by the analysis type (ESD:
- * <tt>AliESDs.root</tt>, AOD: <tt>AliAOD.root</tt>).  The found files
- * are then chained together.  If MC input is specified, then the
- * companion files <tt>galice.root</tt>, <tt>Kinematics.root</tt>, and
- * <tt>TrackRefs.root</tt> must be found in the same directories as
- * the <tt>AliESDs.root</tt> files
- *
- * @subsection train_setup_proof PROOF input. 
- * 
- * The input data for a PROOF based analysis is specified as data set
- * names,
- * 
- * @code 
- *   proof://[<user>@]<host>/<data-set-name>[?options][#<treename>]
- * @endcode 
- *
- * @subsection train_setup_grid_esd Grid ESD input. 
- *
- * Suppose the ESD files are stored on the Grid as 
- *
- * <pre>
- *   /alice/data/&lt;year&gt;/&lt;period&gt;/&lt;run&gt;/ESDs/pass&lt;no&gt;/&lt;year&gt;&lt;run&gt;&lt;chunk&gt;.&lt;part&gt;/AliESDs.root 
- * </pre> 
- *
- * where &lt;run&gt; is zero-padded by typically 3 '0's.  One should
- * specify the input location like
- *
- * @code 
- *   alien:///alice/data/<year>/<period>?pattern=ESDs/pass<no>/&ast;/&run=<run>[#<treename>]
- * @endcode
- *
- * If a particular kind of pass is needed, say
- * <tt>pass&lt;no&gt;_MUON</tt>, one should do modify the
- * <tt>pattern</tt> option accordingly
- *
- * <pre>
- *   /alice/data/&lt;year&gt;/&lt;period&gt;/&lt;run&gt;/ESDs/pass&lt;no&gt;/&nbsp;*&nbsp;/AliESDs.root 
- * </pre>
- *
- * for each added run. 
- *
- * For simulation output, the files are generally stored like 
- * 
- * <pre>
- *   /alice/sim/&lt;year&gt;/&lt;prod&gt;/&lt;run&gt;/&lt;seq&gt;/AliESDs.root 
- * </pre> 
- *
- * where &lt;run&gt; is generally @e not zero-padded. One should
- * specify the input location like
- *
- * @code 
- *   alien:///alice/data/<year>/<period>?pattern=&ast;/&mc&run=<run>[#<treename>]
- * @endcode
- *
- *
- * @subsection train_setup_grid_aod Grid AOD input 
- * 
- * Suppose your AOD files are placed in directories like 
- * 
- * <pre>
- *   /some/directory/&lt;run&gt;/&lt;seq&gt;/AliAOD.root
- * </pre>
- *
- * where &lt;run&gt; is zero-padded by typically 3 '0's.  One should
- * then specify the input as 
- *
- * @code 
- *   alien:///some/directory?pattern=&ast;/&run=<run>[#<treename>
- * @endcode
- * 
- * The AliEn analysis plug-in is then instructed to look for data files under 
- * 
- * <pre>
- *   /some/directory/&lt;run&gt;/&nbsp;*&nbsp;/AliAOD.root 
- * </pre>
- *
- * for each added run.  
- *
- * Suppose the AODs are in 
- *
- * <pre>
- *  /alice/data/&lt;year&gt;/&lt;period&gt;/&lt;run&gt;/ESDs/pass&lt;no&gt;/AOD&vers&gt;/&lt;seq&gt;/AliAOD.root 
- * </pre>
- * 
- *  @code 
- *   alien:///alice/data/<year>/<period>?pattern=ESDs/pass<no>/AOD<vers>/&ast;/&run=<run>[#<treename>]
- * @endcode
- *
- * @section train_setup_other Other features  
- *
- * @subsection train_setup_aux Auxillary libraries, sources, and files
- *
- * Auxillary libraries should be loaded using 
- *
- * - Helper::LoadLibrary(const char*)
- *
- * where the argument is the name of the library
- *
- * If the train needs additional files, say a script for setting up
- * the tasks, or some data file, it can be passed on the the
- * PROOF/Grid workers using the member functions 
- *
- * - Helper::LoadAux(const char*)
- * - Helper::LoadSource(const char*,bool)
- * 
- * @subsection train_setup_overload Overloading the behaviour 
- *
- * The base class TrainSetup tries to implement a sensible setup for a
- * given type of analysis, but some times a particular train needs a
- * bit of tweaking.  One can therefore overload the following functions 
- * 
- * - TrainSetup::CreateInputHandler(UShort_t)
- * - TrainSetup::CreateMCHandler(UShort_t,bool)
- * - TrainSetup::CreateOutputHandler(UShort_t)
- * - TrainSetup::CreatePhysicsSelection(Bool_t,AliAnalysisManager*)
- * - TrainSetup::CreateCentralitySelection(Bool_t,AliAnalysisManager*)
- *
- * @section train_setup_scripts Tasks defined in scripts 
- *
- * A task can even be defined in a script, like for example a task like 
- * 
- * @include MyAnalysis.C 
- *
- * Our train set-up can then use the member function
- * ParUtilities::MakeScriptPAR to make a PAR file of the script and use
- * that to make a library loaded on the workers and then generate an
- * object of our task defined in the script.
- *
- * @include MyTrain.C
- *
- * This can allow for fast development and testing of analysis tasks
- * without having to wait for official tasks and builds of all of
- * AliROOT
- *
- * @section train_setup_impl Implementation details
- *
- * @subsection train_setup_imp_helper Helpers 
- *
- * The specifics of the each possible execution environment and input
- * is handled by sub-classes of the base class Helper. Each of these
- * helpers define
- *
- * - URI options. 
- * - Steps to be done before the tasks are added to the train 
- * - How to load libraries, additional scripts and files 
- * - Steps to be done after the setup of tasks 
- * - How to execute the analysis 
- * 
- * Currently defined helpers are 
- *
- * - LocalHelper for local jobs 
- * - ProofHelper for jobs running on a PROOF farm 
- * - LiteHelper for jobs running in a PROOF-Lite session 
- * - AAFHelper Special kind of ProofHelper for jobs running on AAFs 
- * - AAFPluginHelper As AAFHelper, but uses the AliEn plugin 
- * - GridHelper for Grid jobs 
- */
+    @page train_setup_doc Using the TrainSetup facility 
+    @tableofcontents
+    @section train_setup_overview Overview 
+    
+    The TrainSetup framework allows users to easily set up an analysis
+    train which can be executed in all environments supported by ALICE. 
+    
+    The train definition takes the form of a class deriving from the
+    base class TrainSetup.
+    
+    Specific hooks in the base class allows users to customize the
+    various aspects of a train.  The base class also facilities to
+    easily define parameters of the train which can be set by parsing
+    simple command line options or strings.  Furthermore, the basic
+    setup ensures that the analysis becomes a self-contained,
+    self-documenting unit by storing all relevant files together with
+    the various kinds of output generated during the analysis job.
+    
+    The execution environment (local, Proof, Grid) is specified as a
+    simple URL like string, with room for environment specific
+    options.  This scheme allows a user to run the same analysis in
+    various environments by simply changing the execution environment
+    URL with another URL.  Various helpers for each type of
+    environment ensures that all needed steps are taken to help ensure
+    successful execution of the analysis regardless of the underlying
+    execution environment.
+    
+    Trains defined using this framework can either be executed in an
+    interactive AliROOT session or using a stand-alone program.
+    
+    @section train_setup_usage Usage
+    
+    Users should define a class that derives from TrainSetup.  The
+    class should implement the member function TrainSetup::CreateTasks
+    to add needed tasks to the train.  The derived class must also
+    override the member function TrainSetup::ClassName to return the
+    name of the derived class as a C-string.
+    
+    @code 
+    // MyTrain.C 
+    class MyTrain : public TrainSetup
+    {
+    public:
+      MyTrain(const char  name="MyTrain")
+       : TrainSetup(name), 
+      {
+         // fOptions.Set("type", "AOD"); // AOD input
+         // fOptions.Set("type", "ESD"); // ESD input
+         fOptions.Add("parameter", "VALUE", "Help on parameter", "value");
+      }
+    protected:
+      void CreateTasks(AliAnalysisManager  mgr)
+      {
+        AliAnalysisManager::SetCommonFileName("my_analysis.root");
+        fHelper->LoadLibrary("MyAnalysis", true);
+        Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
+        Double_t param = fOptions.AsDouble("parameter");
+        gROOT->Macro(Form("AddTaskMyAnalysis.C(%f)",param));
+      }
+      const char* ClassName() const { return "MyTrain"; }
+    };
+    @endcode 
+    (Please note, that TrainSetup does not inherit from TObject so one
+    should _not_ put in a call to the *ClassDef* macro)
+
+    @section train_setup_params Parameters of the setup 
+    
+    Parameters of the user defined class deriving from TrainSetup is
+    best handled by adding options to the internal member @c fOptions
+    in the constructor e.g.,
+    @code
+    fOptions.Add("<name>", "<dummy>", "<description>", "<default>");
+    fOptions.Add("<name>", "<dummy>", "<description>", defaultInt_t);
+    fOptions.Add("<name>", "<dummy>", "<description>", defaultLong64_t);
+    fOptions.Add("<name>", "<dummy>", "<description>", defaultDouble_t);
+    fOptions.Add("<name>", "<description>");
+    fOptions.Add("<name>", "<description>", defaultBool);
+    @endcode
+    
+    The first 4 forms defined a parameter that has a value, while the
+    last 2 forms defines a flag (or toggle).  The values or flags can be
+    retrieved later by doing
+    @code 
+    Double_t value = fOptions.AsDouble("<name>",<value if not set>);
+    Int_t    value = fOptions.AsInt("<name>",<value if not set>);
+    Long64_t value = fOptions.AsLong("<name>",<value if not set>);
+    Bool_t   value = fOptions.AsBool("<name>",<value if not set>)
+    TString  value = fOptions.Get("<name>");
+    Bool_t   value = fOptions.Has("<name>");
+    @endcode
+    
+    Parameters defined this way are directly accessible as options to
+    pass to either runTrain or RunTrain.C
+    
+    @section train_setup_exec Execution of the train 
+    
+    A user defined TrainSetup class can then be run like
+    @code
+    Root> .x RunTrain.C("<class>", "<name>", "<uri>", "<options>")
+    @endcode
+
+    or using the program @b runTrain
+    @verbatim
+    > runTrain --class=<class> --name=<name> --url=<uri> [<options>] 
+    @endverbatim
+
+    Here, 
+    <dl>
+      <dt>`<class>`</dt>
+      <dd> is the name of the user defined class deriving from
+        TrainSetup.</dd>
+      <dt>`<name>`</dt> 
+      <dd> is an arbitary name to give to the train. Note, an @e
+        escaped @e name will be generated from this, which replaces
+        all spaces and the like with '_' and (optionally) with the
+        date and time appended.</dd>
+      <dt>`<uri>`</dt>
+      <dd> is the job execution URI which specified both the
+        execution environment and the input data, as well as some options.  
+       See more below. </dd>
+      <dt>`<options>`</dt>
+      <dd> is a list of options.  For RunTrain this is a
+        comma separated list of options in the form
+       &lt;option&gt;=&lt;value&gt; for value options and &lt;option&gt;
+       for flags (booleans).  For @c runTrain, the options are of the
+       traditional Unix long type: `--<option>=<value>` and
+       @c `--<option>`.  The exact list of options for a given train
+       can be listed by passing the option @b help.
+       </dd>
+    </dl>
+    See also ::RunTrain and ::main
+    
+    In both cases, a new sub-directory called @e escaped @e name of
+    the train is created, and various files are copied there -
+    depending on the mode of execution.
+    
+    For local analysis, no aditional files are copied there, but the
+    output will be put there.
+    
+    For PROOF analysis, the needed PAR files are copied there and
+    expanded.  The output of the job may end up in this directory if
+    so instructed.
+    
+    For Grid analysis, various JDL and steering scripts are copied to
+    this directory.  Scripts to run merge/terminate stages and to
+    download the results are also generated for the users convinence.
+    The special generated script <tt>Watch.C</tt> will monitor the
+    progess of the jobs and automatically execute the needed merging
+    and terminate stages.  Various files needed by the train are
+    copied to the Grid working directory as a form of documentation.
+    
+    In all cases, a file named @c ReRun.C (and for @b runTrain:
+    rerun.sh) is generated in this sub-directory.  It contains the
+    setting used for the train and can easily be used to run jobs
+    again as well as serve as a form of documentation.
+    
+    @section train_setup_url_spec Execution URI 
+    
+    This URI has the form 
+    @verbatim 
+    <protocol>://[[<user>@]<host>]/<input>[?<options>][#<treename>]
+    @endverbatim
+    and specifies several things.
+    
+    <dl>
+      <dt>`<protocol>`</dt>
+      <dd>One of 
+        <dl>
+          <dt><tt>local</tt></dt>
+          <dd>Local analysis on local data executed sequentially on the
+            local machine</dd>
+          <dt><tt>lite</tt></dt>
+          <dd>Proof-Lite analysis on local data executed in parallel on
+            the local machine</dd>
+          <dt><tt>proof</tt></dt> 
+          <dd>Proof analysis on cluster data executed in parallel on a
+            PROOF cluster</dd>
+          <dt><tt>alien</tt></dt>
+          <dd>Grid analysis on grid data executed on the Grid</dd>
+        </dl>
+      </dd>
+      <dt>`[[<user>@]<host>]`</dt>
+      <dd>Sets the master host for Proof analysis</dd>
+      <dt>`<input>`</dt>
+      <dd>Input data specification.  The exact form depends on the
+        protocol used e.g., for local analysis it can be a single,
+        while for other environments it could be a data set name, and
+        so on.</dd>
+      <dt>`<options>`</dt>
+      <dd>Protocol specific options</dd>
+      <dt>`<treename>`</dt>
+      <dd>If specified, gives what data to analyse</dd>
+     </dl>
+          
+    @section train_setup_proof_spec PROOF specifics
+    
+    Local and Grid jobs are in a sense very similar.  That is, the
+    individual Grid jobs are very much like Local jobs, in that they
+    always produce output files (albiet not after Terminate, though
+    parameter container files are (re)made). 
+    
+    PROOF jobs are very different.  In a PROOF analysis, each slave
+    only produces in memory output which is then sent via net
+    connections (sockets) to the master.  One therefore needs to be
+    very of output object ownership and the like.  
+    
+    Another major difference is that output files are generated within
+    the PROOF cluster, and are generally not accessible from the
+    outside.  For plain PROOF clusters in a local area network or
+    so-called <i>Lite</i> session, it is generally not a problem since
+    the files are accessible on the LAN or local machine for Lite
+    sessions.  However, for large scale analysis farms (AAFs), the
+    workers and masters are generally on a in-accessible sub-net, and
+    there's no direct access to the produced files.  Now, for normal
+    output files, like histogram files, etc. there are provisions for
+    this, which means the final merged output is sent back to the
+    client.  Special output, such as AODs, are however not merged nor
+    sent back to the user by default.  There are two ways to deal with this: 
+    
+    <ol>
+     <li> Register the output tree as a data set on the cluster.  This
+       is useful if you need to process the results again on the
+       cluster.</li>
+     <li> Send the output to a (possibly custom) XRootd server.  This
+       is useful if you need to process the output outside of the
+       cluster</li>
+    </ol>
+    
+    The first mode is specified by passing the option
+    <tt>dsname=</tt><i>&lt;name&gt;</i> in the cluster URI.  The created
+    dataset will normally be made in
+    <tt>/default/</tt><i>&lt;user&gt;</i><tt>/</tt><i>&lt;name&gt;</i>. If the
+    <tt>=</tt><i>&lt;name&gt;</i> part is left out, the <i>escaped name</i> of
+    the job will be used.  
+    
+    The second mode is triggered by passing the option
+    <tt>storage=<i>URI</i></tt> to the train setup.  The <i>URI</i>
+    should be of the form
+    
+    @verbatim
+    rootd://<host>[:<port>]/<path>
+    @endverbatim
+    
+    where <i>&lt;host&gt;</i> is the name of a machine accessible by
+    the cluster, <i>&lt;port&gt;</i> is an optional port number (e.g.,
+    if different from 1093), and <i>&lt;path&gt;</i> is an absolute
+    path on <i>&lt;host&gt;</i>.
+    
+    The XRootd process should be started (optionally by the user) on
+    <i>&lt;host&gt;</i> as
+    
+    @verbatim
+    xrootd -p <port> <path>
+    @endverbatim
+    
+    When running jobs on AAFs, one can use the Grid handler to set-up
+    aspects of the job.  To enable the Grid handler, pass the option
+    <tt>plugin</tt> in the execution URI
+    
+    @section train_setup_input Specifying the input
+    @subsection train_setup_local Local and Lite data input
+    
+    For both ESD and AOD input for local jobs, one must specify the
+    root of the sub-tree that holds the data.  That is, if - for
+    example - the data resides in a directory structure like
+    
+    @verbatim
+    /some/directory/<run>/<seq>/AliESDs.root 
+    @endverbatim
+    
+    then one should specify the input location like 
+    
+    @verbatim 
+    local:///some/directory[?pattern=AliESDs.root][#esdTree]
+    lite:///some/directory[?pattern=AliESDs.root][#esdTree]
+    @endverbatim
+    
+    <tt>/some/directory</tt> is then search recursively for input files
+    that match the pattern given by the analysis type (ESD:
+    <tt>AliESDs.root</tt>, AOD: <tt>AliAOD.root</tt>).  The found files
+    are then chained together.  If MC input is specified, then the
+    companion files <tt>galice.root</tt>, <tt>Kinematics.root</tt>, and
+    <tt>TrackRefs.root</tt> must be found in the same directories as
+    the <tt>AliESDs.root</tt> files
+    
+    @subsection train_setup_proof PROOF input. 
+    
+    The input data for a PROOF based analysis is specified as data set
+    names,
+    
+    @verbatim
+    proof://[<user>@]<host>/<data-set-name>[?options][#<treename>]
+    @endverbatim
+    
+    @subsection train_setup_grid_esd Grid ESD input. 
+    
+    Suppose the ESD files are stored on the Grid as 
+    
+    @verbatim
+    /alice/data/<year>/<period>/<run>/ESDs/pass<no>/<year><run><chunk>.<part>/AliESDs.root 
+    @endverbatim
+    
+    where &lt;run&gt; is zero-padded by typically 3 '0's.  One should
+    specify the input location like
+    
+    @verbatim
+    alien:///alice/data/<year>/<period>?pattern=ESDs/pass<no>/*&run=<run>[#<treename>]
+    @endverbatim
+    
+    If a particular kind of pass is needed, say
+    <tt>pass&lt;no&gt;_MUON</tt>, one should do modify the
+    <tt>pattern</tt> option accordingly
+    
+    @verbatim
+    /alice/data/<year>/<period>/<run>/ESDs/pass<no>_MUON/* /AliESDs.root 
+    @endverbatim
+    
+    For simulation output, the files are generally stored like 
+    @verbatim
+    /alice/sim/<year>/<prod>/<run>/<seq>/AliESDs.root 
+    @endverbatim
+    
+    where &lt;run&gt; is generally @e not zero-padded. One should
+    specify the input location like
+    
+    @verbatim
+    alien:///alice/data/<year>/<period>?pattern=*&mc&run=<run>[#<treename>]
+    @endverbatim
+    
+    
+    @subsection train_setup_grid_aod Grid AOD input 
+    
+    Suppose your AOD files are placed in directories like 
+    
+    @verbatim
+    /some/directory/<run>/<seq>/AliAOD.root
+    @endverbatim
+    
+    where &lt;run&gt; is zero-padded by typically 3 '0's.  One should
+    then specify the input as 
+    
+    @verbatim
+    alien:///some/directory?pattern=*&run=<run>[#<treename>
+    @endverbatim
+    
+    The AliEn analysis plug-in is then instructed to look for data files under 
+    
+    @verbatim
+    /some/directory/<run>/* /AliAOD.root 
+    @endverbatim
+    
+    for each added run.  
+    
+    Suppose the AODs are in 
+    
+    @verbatim
+    /alice/data/<year>/<period>/<run>/ESDs/pass<no>/AOD<vers>/<seq>/AliAOD.root 
+    @endverbatim
+    
+    Then the url should be 
+    @verbatim
+    alien:///alice/data/<year>/<period>?pattern=ESDs/pass<no>/AOD<vers>/*&run=<run>[#<treename>]
+    @endverbatim
+    
+    @section train_setup_other Other features  
+    
+    @subsection train_setup_aux Auxillary libraries, sources, and files
+    
+    Auxillary libraries should be loaded using 
+
+    @code
+    Helper::LoadLibrary(const char*)
+    @endcode 
+
+    where the argument is the name of the library
+    
+    If the train needs additional files, say a script for setting up
+    the tasks, or some data file, it can be passed on the the
+    PROOF/Grid workers using the member functions 
+
+    @code 
+    Helper::LoadAux(const char*)
+    Helper::LoadSource(const TString&,bool)
+    @endcode 
+    
+    @subsection train_setup_overload Overloading the behaviour 
+    
+    The base class TrainSetup tries to implement a sensible setup for a
+    given type of analysis, but some times a particular train needs a
+    bit of tweaking.  One can therefore overload the following functions 
+    
+    - TrainSetup::CreateInputHandler(UShort_t)
+    - TrainSetup::CreateMCHandler(UShort_t,bool)
+    - TrainSetup::CreateOutputHandler(UShort_t)
+    - TrainSetup::CreatePhysicsSelection(Bool_t,AliAnalysisManager*)
+    - TrainSetup::CreateCentralitySelection(Bool_t,AliAnalysisManager*)
+    
+    @section train_setup_scripts Tasks defined in scripts 
+    
+    A task can even be defined in a script, like for example a task like 
+    
+    @include MyAnalysis.C 
+    
+    Our train set-up can then use the member function
+    ParUtilities::MakeScriptPAR to make a PAR file of the script and use
+    that to make a library loaded on the workers and then generate an
+    object of our task defined in the script.
+    
+    @include MyTrain.C
+    
+    This can allow for fast development and testing of analysis tasks
+    without having to wait for official tasks and builds of all of
+    AliROOT
+    
+    @section train_setup_impl Implementation details
+    
+    @subsection train_setup_imp_helper Helpers 
+    
+    The specifics of the each possible execution environment and input
+    is handled by sub-classes of the base class Helper. Each of these
+    helpers define
+    
+    - URI options. 
+    - Steps to be done before the tasks are added to the train 
+    - How to load libraries, additional scripts and files 
+    - Steps to be done after the setup of tasks 
+    - How to execute the analysis 
+    
+    Currently defined helpers are 
+    
+    - LocalHelper for local jobs 
+    - ProofHelper for jobs running on a PROOF farm 
+    - LiteHelper for jobs running in a PROOF-Lite session 
+    - AAFHelper Special kind of ProofHelper for jobs running on AAFs 
+    - AAFPluginHelper As AAFHelper, but uses the AliEn plugin 
+    - GridHelper for Grid jobs 
+*/
 //
 // EOF
 //
index bb9adc5ea81076d7a06959044cb2f7c19afc367b..687e922df327a93a18cc12135caad492df5bc5c1 100644 (file)
@@ -1,4 +1,12 @@
 #include "SummaryDrawer.C"
+#ifndef __CINT__
+# include <TGraph.h>
+# include <TGraphErrors.h>
+# include <TF1.h>
+# include <TArrow.h>
+#else
+class TGraph;
+#endif
 
 /**
  * Class to draw a summary of the AOD production
@@ -70,8 +78,10 @@ public:
 
     // --- Possibly make a chapter here ------------------------------
     TCollection* centralSums = GetCollection(file, "CentralSums", false);
-    if (!centralSums) 
+    if (!centralSums) {
+      Info("Run", "Trying old name \"Central\"");
       centralSums = GetCollection(file, "Central", false);
+    }
     if (what & kCentral && centralSums) 
       MakeChapter("Forward");
     
@@ -93,6 +103,8 @@ public:
     if (what & kCentral) { 
       // --- Get top-level collection --------------------------------
       fSums = GetCollection(file, "CentralSums");
+      if (!fSums) 
+       fSums = GetCollection(file, "Central");
       if (fSums) {
        MakeChapter("Central");
        DrawCentral();
@@ -160,6 +172,41 @@ protected:
     fParName->SetTextSize(save);
     fParVal->SetTextSize(save);
   }
+  TGraph* CreateCutGraph(Int_t method, Int_t iy, TH2* cuts, TH1* eloss,
+                        Int_t color)
+  {
+    TGraph*  ret = new TGraph(4);
+    Double_t y0  = TMath::Max(eloss->GetMinimum(),1.);
+    Double_t y1  = eloss->GetMaximum();
+    Double_t min = 1000;
+    Double_t max = 0;
+    if (method == 0) { // Fixed value
+      max = cuts->GetBinContent(1, iy);
+      min = eloss->GetXaxis()->GetXmin();
+    }
+    else {
+      for (Int_t ix=1; ix <= cuts->GetNbinsX(); ix++) {
+       Double_t c = cuts->GetBinContent(ix, iy);
+       if (c <= 0.0001) continue;
+       min = TMath::Min(c, min);
+       max = TMath::Max(c, max);
+      }
+    }
+    // Printf("Cuts between %f,%f @%f, %f", min, max, y0,y1);
+    ret->SetPoint(0, min, y0); 
+    ret->SetPoint(1, min, y1); 
+    ret->SetPoint(2, max, y1);
+    ret->SetPoint(3, max, y0);
+    ret->SetFillColor(color);
+    ret->SetFillStyle(3002);
+    ret->SetLineColor(kBlack);
+    ret->SetLineStyle(2);
+    ret->SetName(Form("g%s", cuts->GetName()));
+    ret->SetTitle(cuts->GetTitle());
+    
+    return ret;
+  }
+    
   //____________________________________________________________________
   void DrawSharingFilter()
   {
@@ -169,7 +216,7 @@ protected:
     TCollection* rc = GetCollection(fResults, "fmdSharingFilter");
     if (!rc) rc = c;
 
-    fBody->Divide(1, 3);
+    fBody->Divide(1, 3, 0, 0);
     fBody->cd(1);
   
     Double_t y = .8;
@@ -207,27 +254,43 @@ protected:
                                          
     TH2* hLow  = GetH2(c, "lowCuts");
     TH2* hHigh = GetH2(c, "highCuts");
-    if (hLow  && nFiles) hLow->Scale(1. / nFiles->GetVal());
-    if (hHigh && nFiles) hHigh->Scale(1. / nFiles->GetVal());
+    // if (hLow  && nFiles) hLow->Scale(1. / nFiles->GetVal());
+    // if (hHigh && nFiles) hHigh->Scale(1. / nFiles->GetVal());
     DrawInPad(fBody, 2, hLow,  "colz");
     DrawInPad(fBody, 3, hHigh, "colz");
   
     PrintCanvas("Sharing filter");
 
+    Double_t savX = fParVal->GetX();
+    Double_t savY = fParVal->GetY();
+    fParVal->SetX(0.6);
+    fParVal->SetY(0.6);
     const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
     const char** ptr   = subs;
+    UShort_t     iq    = 1;
     while (*ptr) { 
       TCollection* sc = GetCollection(c, *ptr);
-      if (!sc) { ptr++; continue; }
+      if (!sc) { ptr++; iq++; continue; }
     
-      fBody->Divide(2,3);
-      DrawInPad(fBody, 1, GetH1(sc, "esdEloss"),       "",     kLogy,
+      if (fLandscape) fBody->Divide(3, 2);
+      else            fBody->Divide(2,3);
+
+      TH1*    esdELoss = GetH1(sc, "esdEloss");
+      esdELoss->GetXaxis()->SetRangeUser(-.1, 2);
+      TGraph* lowCut   = CreateCutGraph(lm, iq,  hLow,  esdELoss, kYellow+1);
+      TGraph* highCut  = CreateCutGraph(hm, iq,  hHigh, esdELoss, kCyan+1);
+
+      DrawInPad(fBody, 1, esdELoss, "", kLogy,
                "#Delta/#Delta_{mip} reconstructed and merged");
-      DrawInPad(fBody, 1, GetH1(sc, "anaEloss"),       "same", kLogy|kLegend);
+      DrawInPad(fBody, 1, GetH1(sc, "anaEloss"), "same");
+      DrawInPad(fBody, 1, lowCut,  "lf same"); 
+      DrawInPad(fBody, 1, highCut, "lf same", kLogy|kLegend); 
+
       DrawInPad(fBody, 2, GetH1(sc, "singleEloss"),    "",     kLogy,
                "#Delta/#Delta_{mip} for single, double, and tripple hits");
       DrawInPad(fBody, 2, GetH1(sc, "doubleEloss"),    "same", kLogy);
       DrawInPad(fBody, 2, GetH1(sc, "tripleEloss"),    "same", kLogy|kLegend);  
+
       DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz", kLogz);
       // DrawInPad(fBody, 4, GetH1(sc, "distanceBefore"), "",     0x2);
       // DrawInPad(fBody, 4, GetH1(sc, "distanceAfter"),  "same", 0x12);
@@ -245,7 +308,10 @@ protected:
 
       PrintCanvas(Form("Sharing filter - %s", *ptr));
       ptr++;
+      iq++;
     }
+    fParVal->SetX(savX);
+    fParVal->SetY(savY);
 
     // --- MC --------------------------------------------------------
     TCollection* cc = GetCollection(c, "esd_mc_comparion", false); // Spelling!
@@ -264,6 +330,102 @@ protected:
     DrawTrackDensity(c);
   }
 
+  void ShowSliceFit(Bool_t inY, TH2* h, Double_t nVar, 
+                   TVirtualPad* p, Int_t sub, UShort_t flags=0,
+                   Double_t cut=-1)
+  {
+    if (!h) return;
+
+    TObjArray* fits = new TObjArray;
+    fits->SetOwner();
+    if (inY) h->FitSlicesY(0, 1, -1, 10, "QN", fits);
+    else     h->FitSlicesX(0, 1, -1, 10, "QN", fits);
+    if (!fits) { 
+      Warning("ShowSliceFit", "No fits returned");
+      return;
+    }
+    TH1* mean = static_cast<TH1*>(fits->At(1));
+    TH1* var  = static_cast<TH1*>(fits->At(2));
+    if (!mean || !var) {
+      Warning("ShowSliceFit", "Didn't get histograms");
+      fits->Delete();
+      return;
+    }
+    TF1* fmean = new TF1("mean", "pol1");
+    TF1* fvar  = new TF1("var",  "pol1");
+    mean->Fit(fmean, "Q0+");
+    var->Fit(fvar, "Q0+");
+    if (!fmean || !fvar) {
+      Warning("ShowSliceFit", "No functions returned");
+      fits->Delete();
+      return;
+    }
+
+    TGraphErrors* g = new TGraphErrors(h->GetNbinsX());
+    g->SetName(Form("g%s", h->GetName()));
+    TString xTit = h->GetXaxis()->GetTitle();
+    TString yTit = h->GetYaxis()->GetTitle();
+    g->SetTitle(Form("Correlation of %s and %s",
+                    inY  ? xTit.Data() : yTit.Data(), 
+                    !inY ? xTit.Data() : yTit.Data()));
+    g->SetFillColor(kBlue-10);
+    g->SetFillStyle(3001);
+    TGraph* up  = (cut > 0 ? new TGraph(h->GetNbinsX()) : 0);
+    TGraph* low = (cut > 0 ? new TGraph(h->GetNbinsX()) : 0);
+    if (up)  { 
+      up ->SetLineColor(kBlack); 
+      up ->SetLineWidth(2); 
+      up ->SetLineStyle(2); 
+    }
+    if (low) { 
+      low->SetLineColor(kBlack); 
+      low->SetLineWidth(2); 
+      low->SetLineStyle(2); 
+    }
+    for (Int_t i = 1; i <= h->GetNbinsX(); i++) { 
+      Double_t x  = h->GetXaxis()->GetBinCenter(i);
+      Double_t y  = fmean->Eval(x);
+      Double_t e  = fvar->Eval(x);
+      Double_t ee = nVar * e;
+      if (flags & 0x8000) ee *= e > 0 ? TMath::Log10(e) : 1;
+      g->SetPoint(i-1, x, y);
+      g->SetPointError(i-1, 0, ee);
+
+      if (up)  up ->SetPoint(i-1,x,x+cut*x);
+      if (low) low->SetPoint(i-1,x,x-cut*x);
+    }
+    DrawInPad(p, sub, g, "3", flags);
+    if (up)  DrawInPad(p, sub, up, "l", flags);
+    if (low) DrawInPad(p, sub, low, "l", flags);
+    fmean->SetRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
+    fmean->SetLineWidth(2);
+    DrawInPad(p, sub, fmean, "same", flags);
+
+    TVirtualPad* pp = p->GetPad(sub);
+    Double_t y = 1-pp->GetTopMargin()-.01;
+    TLatex* l = new TLatex(.15, y, 
+                          Form("#LT%s#GT(%s) = "
+                               "%f + %f %s", 
+                               yTit.Data(), xTit.Data(), 
+                               fmean->GetParameter(0), 
+                               fmean->GetParameter(1), xTit.Data()));
+    l->SetNDC();
+    l->SetTextAlign(13);
+    l->SetTextSize(0.04);
+    l->SetTextFont(42);
+    l->Draw();
+    l->DrawLatex(0.15, y-0.07, 
+                Form("#sigma_{%s}(%s) = "
+                     "%f + %f %s", 
+                     yTit.Data(), xTit.Data(),
+                     fvar->GetParameter(0), 
+                     fvar->GetParameter(1),  xTit.Data()));
+    l->DrawLatex(0.15, y-0.14, Form("#delta = %3.1f %s #sigma",
+                                   nVar, 
+                                   flags & 0x8000 ? "log_{10}(#sigma)" : ""));
+    fits->Delete();
+  }
+
   //____________________________________________________________________
   void DrawDensityCalculator()
   {
@@ -277,6 +439,7 @@ protected:
     Double_t y = .8;
     Int_t maxParticles=0, phiAcceptance=0, etaLumping=0, phiLumping=0;
     Bool_t method=false, recalcEta=false, recalcPhi=false;
+    Double_t maxOutliers=0, outlierCut=0;
     Double_t size = fLandscape ? 0.06 : 0.04;
   
     GetParameter(c, "maxParticle", maxParticles);
@@ -285,24 +448,27 @@ protected:
       DrawParameter(y, "#phi acceptance method", 
                    (phiAcceptance == 1 ? "N_{ch}" : 
                     phiAcceptance == 2 ? "#DeltaE" : "none"),       size);
-    
     if (GetParameter(c, "etaLumping", etaLumping) &&
        GetParameter(c, "phiLumping", phiLumping))
       DrawParameter(y, "Region size (sector#timesstrip)", 
                    Form("%2d #times %2d", phiLumping, etaLumping),  size);
-    
     if (GetParameter(c, "method", method))
       DrawParameter(y, "Method", (method ? "Poisson" : "#DeltaE"),   size); 
-
     if (GetParameter(c, "recalcEta", recalcEta))
       DrawParameter(y, "Recalculate #eta",(recalcEta ? "yes" : "no"),size); 
-
     if (GetParameter(c, "recalcPhi", recalcPhi))
       DrawParameter(y, "Recalculate #phi",(recalcPhi ? "yes" : "no"),size); 
+    if (GetParameter(c, "maxOutliers", maxOutliers))
+      DrawParameter(y, "Max relative N_{outlier}",
+                   Form("%5.3f",maxOutliers),size);
+    if (GetParameter(c, "outlierCut", outlierCut))
+      DrawParameter(y, "Max relative diviation",Form("%5.3f",outlierCut),size);
+
+
     TParameter<int>* nFiles = 
       static_cast<TParameter<int>*>(GetObject(c, "nFiles"));
     if (nFiles)
-      DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()));
+      DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()), size);
 
     TCollection* lc = GetCollection(c, "lCuts");
     Int_t lm;
@@ -311,7 +477,7 @@ protected:
                                          lm == 1 ? "fraction of MPV" : 
                                          lm == 2 ? "fit range" : 
                                          lm == 3 ? "Landau width" : 
-                                         "unknown"));
+                                         "unknown"), size);
 
 
     TVirtualPad* p = fBody; // fBody->cd(2);
@@ -342,25 +508,62 @@ protected:
       TCollection* sc = GetCollection(c, *ptr);
       if (!sc) { ptr++; continue; }
     
-      fBody->Divide(2,3);
+      if (fLandscape) fBody->Divide(3,2);
+      else            fBody->Divide(2,3);
     
-      DrawInPad(fBody, 1, GetH2(sc, "elossVsPoisson"),   "colz",   kLogz);
-      DrawInPad(fBody, 2, GetH1(sc, "diffElossPoisson"), "HIST E", kLogy);
-      DrawInPad(fBody, 3, GetH1(sc, "occupancy"),        "",       kLogy);
-      DrawInPad(fBody, 4, GetH1(sc, "eloss"),            "",       kLogy,
+      TH2* corr      = GetH2(sc, "elossVsPoisson");
+      TH2* corrOut   = GetH2(sc, "elossVsPoissonOutlier");
+      TH1* diff      = GetH1(sc, "diffElossPoisson");
+      TH1* diffOut   = GetH1(sc, "diffElossPoissonOutlier");
+      TH1* eloss     = GetH1(sc, "eloss");
+      TH1* elossUsed = GetH1(sc, "elossUsed");
+      TH1* occ       = GetH1(sc, "occupancy");
+      if (eloss)     eloss    ->SetLineWidth(1);
+      if (elossUsed) elossUsed->SetLineWidth(1);
+      
+      DrawInPad(fBody, 1, corr,    "colz",        kLogz);
+      DrawInPad(fBody, 1, corrOut, "same",        kLogz);
+      DrawInPad(fBody, 2, diff,    "HIST E",      kLogy);
+      DrawInPad(fBody, 2, diffOut, "HIST E SAME", kLogy|kLegend);
+      DrawInPad(fBody, 3, occ,      "",           kLogy);
+      DrawInPad(fBody, 4, eloss,    "",           kLogy, 
                "#Delta/#Delta_{mip} before and after cuts");
-      DrawInPad(fBody, 4, GetH1(sc, "elossUsed"),        "same",kLogy|kLegend);
+      DrawInPad(fBody, 4, elossUsed, "same",      kLogy|kLegend);
       TH1* phiB = GetH1(sc, "phiBefore");
       TH1* phiA = GetH1(sc, "phiAfter");
-      if (phiB && phiA) { 
+      TH1* outliers = GetH1(sc, "outliers");
+      if (outliers) 
+       DrawInPad(fBody, 5, outliers, "hist", kLogy);
+      else if (phiB && phiA) { 
        phiA->Add(phiB, -1);
        phiA->Divide(phiB);
        phiA->SetTitle("#Delta#phi from Ip (x,y) correction");
        phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}");
+       DrawInPad(fBody, 5, phiA);
+      }
+      else {
+       fBody->cd(5);
+       TLatex* ltx = new TLatex(0.5, 0.5, "No outliers or #phi corrections");
+       ltx->SetTextAlign(22);
+       ltx->SetTextSize(0.07);
+       ltx->SetNDC();
+       ltx->Draw();
       }
-      DrawInPad(fBody, 5, phiA);
       DrawInPad(fBody, 6, GetH2(sc, "phiAcc"), "colz",   kLogz);
     
+      ShowSliceFit(true, corr, 10, fBody, 1, kLogz, outlierCut);
+
+      if (diff && diffOut) { 
+       fBody->cd(2);
+       Double_t in  = diff->GetEntries();
+       Double_t out = diffOut->GetEntries();
+       TLatex*  ltx = new TLatex(0.11, 0.89, 
+                                 Form("Fraction: %7.3f%%", 100*out/(in+out)));
+       ltx->SetNDC();
+       ltx->SetTextAlign(13);
+       ltx->SetTextSize(0.06);
+       ltx->Draw();
+      }
       PrintCanvas(Form("Density calculator - %s", *ptr));
       ptr++;    
     }
@@ -426,16 +629,18 @@ protected:
     TCollection* c = GetCollection(fSums, "fmdHistCollector");
     if (!c) return;
 
-    fBody->Divide(1, 3);
-    fBody->cd(1);
+    fBody->Divide(2, 1);
+    TVirtualPad* p = fBody->cd(1);
+    p->Divide(1,2);
+    p->cd(1);
 
     Double_t y = .8;
     Int_t nCutBins=0, fiducial=0, merge=0, skipRings=0;
     Double_t fiducialCut=0.;
     Bool_t  bgAndHits=false;
-
+    Double_t size = fLandscape ? 0.06 : 0.04;
     if (GetParameter(c, "nCutBins", nCutBins))
-      DrawParameter(y, "# of bins to cut",      Form("%d", nCutBins));
+      DrawParameter(y, "# of bins to cut", Form("%d", nCutBins),size);
 
     if (GetParameter(c, "skipRings", skipRings)) {
       TString skipped;
@@ -444,37 +649,41 @@ protected:
       if (skipRings & 0x0a) skipped.Append("FMD2o ");
       if (skipRings & 0x11) skipped.Append("FMD3i ");
       if (skipRings & 0x12) skipped.Append("FMD3o ");
-      DrawParameter(y, "Skipped rings", skipped);
+      if (skipped.IsNull()) skipped = "none";
+      DrawParameter(y, "Skipped rings", skipped, size);
     }
-
     if (GetParameter(c, "bgAndHits", bgAndHits))
-      DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no");
-
+      DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no",size);
     if (GetParameter(c, "merge", merge))
       DrawParameter(y, "Merge method", 
                    (merge == 0 ? "straight mean" :
                     merge == 1 ? "straight mean, no zeroes" : 
                     merge == 2 ? "weighted mean" : 
                     merge == 3 ? "least error" : 
-                    merge == 4 ? "sum" : "unknown"));
-
+                    merge == 4 ? "sum" : "unknown"),size);
     if (GetParameter(c, "fiducial", fiducial))
       DrawParameter(y, "Fiducial method.", 
-                   fiducial == 0 ? "cut" : "distance");
-
+                   fiducial == 0 ? "cut" : "distance", size);
     if (GetParameter(c, "fiducialCut", fiducialCut))
-      DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut));
-
+      DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut), size);
+
+    // p->cd(2);
+    // Printf("Drawing skipped");
+    TH1* skipped = GetH1(c, "skipped");
+    if (skipped) { 
+      skipped->SetFillColor(kRed+1);
+      skipped->SetFillStyle(3001);
+    }
+    DrawInPad(p, 2, skipped, "hist");
                 
-    DrawInPad(fBody, 2, GetH2(c, "sumRings"), "colz"); 
-    DrawInPad(fBody, 3, GetH2(c, "coverage"), "colz");
-
-    fBody->cd(1)->Modified();
-    fBody->cd(2)->Modified();
-    fBody->cd(3)->Modified();
-    fBody->cd(1)->Update();
-    fBody->cd(2)->Update();
-    fBody->cd(3)->Update();
+    p = fBody->cd(2);
+    p->Divide(1,2,0,0);
+
+    // Printf("Drawing sumRings");
+    DrawInPad(p, 1, GetH2(c, "sumRings"), "colz"); 
+    // Printf("Drawing coverage");
+    DrawInPad(p, 2, GetH2(c, "coverage"), "colz");
+    // Printf("Done drawing for now");
     PrintCanvas("Histogram collector");
                
     
@@ -486,6 +695,7 @@ protected:
       if (name.Index(regexp) == kNPOS) continue;
       
       TList* vl = static_cast<TList*>(o);
+      if (!vl) continue;
 
       DivideForRings(false, false);
       
@@ -521,23 +731,40 @@ protected:
     TCollection* c = fSums; 
     if (!c) return;
 
-    fBody->Divide(1, 3);
+    fBody->Divide(2, 2);
     fBody->cd(1);
+    Double_t y = .7;  
+    Bool_t secondary=false, acceptance=false;  
+    if (GetParameter(c, "secondary", secondary))
+      DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no");
+    if (GetParameter(c, "acceptance", acceptance))
+      DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no");
 
                 
-    DrawInPad(fBody, 1, GetH2(c, "coverage"), "col", 0,
+    DrawInPad(fBody, 2, GetH2(c, "coverage"), "col", 0,
              "#eta coverage per v_{z}");
-    DrawInPad(fBody, 2, GetH2(c, "nClusterVsnTracklet"), "colz", kLogx|kLogy,
+    TH2* cvst = GetH2(c, "nClusterVsnTracklet");
+    if (cvst) {
+      // cvst->Scale(1, "width");
+      cvst->GetXaxis()->SetTitle("N_{free cluster}");
+      cvst->GetYaxis()->SetTitle("N_{tracklet}");
+      cvst->GetXaxis()->SetRangeUser(1,10000);
+      cvst->GetYaxis()->SetRangeUser(1,10000);
+    }
+    DrawInPad(fBody, 3, cvst, "colz", kLogx|kLogy|kLogz,
              "Correlation of # of tracklets and clusters"); 
-    DrawInPad(fBody, 3, GetH2(c, "clusterPerTracklet"), "colz", 0x0,
+    DrawInPad(fBody, 4, GetH2(c, "clusterPerTracklet"), "colz", 0x0,
              "# clusters per tracklet vs #eta"); 
+    ShowSliceFit(true, cvst, 3, fBody, 3, 0x8000|kLogz);
 
     fBody->cd(1)->Modified();
     fBody->cd(2)->Modified();
     fBody->cd(3)->Modified();
+    fBody->cd(4)->Modified();
     fBody->cd(1)->Update();
     fBody->cd(2)->Update();
     fBody->cd(3)->Update();
+    fBody->cd(4)->Update();
     PrintCanvas("Central - overview");
                
     
@@ -612,24 +839,37 @@ protected:
                TObject*     cur,
                TLegend*     leg,
                const char*  title,
-               TVirtualPad* can)
+               TVirtualPad* can,
+               Int_t        sub,
+               Int_t        nCol)
   {
     if (all->GetHists()->GetEntries() <= 0 || !cur) return;
 
     // Info("", "Drawing step # %d", step);
-    Bool_t left = (step % 2) == 1; 
-    TVirtualPad* p = can->cd(step);
+    Bool_t       left = sub % nCol == 1; 
+    Bool_t       right= sub % nCol == 0;
+    Bool_t       top  = (sub-1) / nCol == 0;
+    TVirtualPad* p    = can->cd(sub);
     gStyle->SetOptTitle(0);
     p->SetTitle(Form("Step # %d", step));
     p->SetFillColor(kWhite);
-    p->SetRightMargin(left ? 0 : 0.02);
-    p->SetTopMargin(0); // 0.02);
+    p->SetRightMargin(right ? 0.02 : 0);
+    p->SetTopMargin(top ? 0.02 : 0); // 0.02);
+    // Info("", "Drawing step %d in sub-pad %d (%s)", 
+    //      step, sub, (left?"left":"right"));
 
     p->cd();
     all->Draw("nostack");
     all->GetHistogram()->SetXTitle("#eta");
     all->GetHistogram()->SetYTitle("signal");
 
+    TLegendEntry* e = 
+      static_cast<TLegendEntry*>(leg->GetListOfPrimitives()->At(step-1));
+    e->SetMarkerColor(kBlack);
+    e->SetLineColor(kBlack);
+    e->SetTextColor(kBlack);
+
+
     // p->cd();
     gROOT->SetSelectedPad(p);
     cur->DrawClone("same nostack");
@@ -647,10 +887,34 @@ protected:
     ltx->SetTextAlign(13);
     ltx->Draw();
 
+    if (step > 1) { 
+      Double_t x1 = 0.5*(p->GetUxmax()+p->GetUxmin());
+      Double_t x2 = x1;
+      Double_t y1 = p->GetUymax();
+      Double_t y2 = 0.92*y1;
+      Double_t sz = 0.05;
+      if (fLandscape) { 
+       x1 = 0.99*p->GetUxmin();
+       x2 = 0.80*x1;
+       y1 = .5*(p->GetUymax()+p->GetUymin());
+       y2 = y1;
+       sz = 0.034;
+      }
+      // Info("", "Arrow at (x1,y1)=%f,%f (x2,y2)=%f,%f", x1, y1, x2, y2);
+      TArrow* a = new TArrow(x1, y1, x2, y2, sz, "|>");
+      // (fLandscape ? "<|" : "|>"));
+      a->SetFillColor(kGray+1);
+      a->SetLineColor(kGray+1);
+      a->Draw();
+    }
     p->Modified();
     p->Update();
     p->cd();
 
+    e->SetMarkerColor(kGray);
+    e->SetLineColor(kGray);
+    e->SetTextColor(kGray);
+
     gStyle->SetOptTitle(1);
   }
 
@@ -689,6 +953,8 @@ protected:
   {
     // MakeChapter(can, "Steps");
 
+    THStack* esds    = GetStack(GetCollection(fResults, "fmdSharingFilter"), 
+                               "sumsESD", "summedESD");
     THStack* deltas  = GetStack(GetCollection(fResults, "fmdSharingFilter"), 
                                "sums", "summed");
     THStack* nchs    = GetStack(GetCollection(fResults, 
@@ -702,14 +968,16 @@ protected:
     TH1*     dndeta  = GetH1(fResults, "dNdeta");
     if (dndeta) dndeta->SetMarkerColor(kBlack);
 
-    FixStack(deltas, "#sum_{} #Delta/#Delta_{mip}",  "",     20);
-    FixStack(nchs,   "#sum_{} N_{ch,incl}",         "",     21);
-    FixStack(prims,  "#sum_{} N_{ch,primary}",       "",     22);
-    FixStack(rings,  "dN/d#eta per ring",            "",     23);
+    FixStack(esds,   "#sum_{s} #Delta/#Delta_{mip}", "",     20);
+    FixStack(deltas, "#sum_{c} #Delta/#Delta_{mip}", "",     21);
+    FixStack(nchs,   "#sum_{b} N_{ch,incl}",        "",     22);
+    FixStack(prims,  "#sum_{b} N_{ch,primary}",      "",     23);
+    FixStack(rings,  "dN/d#eta per ring",            "",     33);
     FixStack(mcRings,"dN/d#eta per ring (MC)",       "(MC)", 34);
 
     THStack* all = new THStack;
     AddToAll(all, mcRings);
+    AddToAll(all, esds);
     AddToAll(all, deltas);
     AddToAll(all, nchs);
     AddToAll(all, prims);
@@ -737,6 +1005,11 @@ protected:
       AddLegendEntry(l, h, mcRings->GetTitle());
     }
 
+    if (esds) {
+      h = static_cast<TH1*>(esds->GetHists()->At(0));
+      AddLegendEntry(l, h, esds->GetTitle());
+    }
+
     if (deltas) {
       h = static_cast<TH1*>(deltas->GetHists()->At(0));
       AddLegendEntry(l, h, deltas->GetTitle());    
@@ -763,36 +1036,51 @@ protected:
     }
     
     TObject* objs[] = { mcRings, 
+                       esds, 
                        deltas, 
                        nchs, 
                        prims, 
                        rings, 
                        dndeta };
-    const char* titles[] = { "MC", 
-                            "After merging", 
-                            "After particle counting", 
-                            "After corrections", 
-                            "After normalization", 
-                            "After combining" };
+    const char* titles[] = { /* 1 */ "MC",  
+                            /* 2 */ "ESD input",
+                            /* 3 */ "After merging", 
+                            /* 4 */ "After particle counting", 
+                            /* 5 */ "After corrections", 
+                            /* 6 */ "After normalization", 
+                            /* 7 */ "After combining" };
+    Int_t nY = mcRings ? 4 : 3;
+    Int_t nX = 2;
+    if (fLandscape) {
+      Int_t tmp = nX;
+      nX        = nY;
+      nY        = tmp;
+    }
+    fBody->Divide(nX, nY, 0, 0);
     
-    fBody->Divide(2, 3, 0, 0); // mcRings ? 4 : 3, 0, 0);
     Int_t step = 0;
-    for (Int_t i = 0; i < 6; i++) { 
+    for (Int_t i = 0; i < 7; i++) { 
       TObject* obj = objs[i];
       if (!obj) continue;
-      e = static_cast<TLegendEntry*>(l->GetListOfPrimitives()->At(step));
-      e->SetMarkerColor(kBlack);
-      e->SetLineColor(kBlack);
-      e->SetTextColor(kBlack);
+
       step++;
-      
-      DrawStep(step, all, obj, l, titles[i], fBody);
-      e->SetMarkerColor(kGray);
-      e->SetLineColor(kGray);
-      e->SetTextColor(kGray);
+      Int_t padNo = step;
+      if (!fLandscape) {
+       switch (step) { 
+       case 1: padNo = 1; break; 
+       case 2: padNo = 3; break; 
+       case 3: padNo = 5; break; 
+       case 4: padNo = (mcRings ? 7 : 2); break; 
+       case 5: padNo = (mcRings ? 2 : 4); break; 
+       case 6: padNo = (mcRings ? 4 : 6); break; 
+       case 7: padNo = (mcRings ? 6 : 8); break; 
+    }
+      }
+      //Printf("Drawing step %d in sub-pad %d (%s)",step,padNo,obj->GetTitle());
+      DrawStep(step, all, obj, l, titles[i], fBody, padNo, nX);
     }
 
-    if (!mcRings && deltas) { 
+    if (!esds && !mcRings && deltas) { 
       fBody->cd(6);
       TLegend* ll = new TLegend(0.01, 0.11, 0.99, 0.99);
       // ll->SetNDC();
@@ -810,6 +1098,7 @@ protected:
       }
       ll->Draw();
     }
+    // Printf("Done drawing steps");
     PrintCanvas("Steps");
   }
 
@@ -819,7 +1108,7 @@ protected:
   {
     // MakeChapter(can, "Results");
 
-    fBody->Divide(2,2);
+    fBody->Divide(2,1);
 
     TCollection* c = GetCollection(fResults, "ringResults");
     if (!c) return;
@@ -858,18 +1147,27 @@ protected:
       }
       pring++;
     }
-    DrawInPad(fBody, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : kLegend,
+    Double_t savX = fParVal->GetX();
+    Double_t savY = fParVal->GetY();
+    fParVal->SetX(.3);
+    fParVal->SetY(.2);
+    TVirtualPad* p = fBody->cd(1);
+    p->Divide(1,2,0,0);
+    DrawInPad(p, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : kLegend,
              "Individual ring results");
-    DrawInPad(fBody, 1, mcRings, "nostack same", kLegend);
-    DrawInPad(fBody, 2, dndeta_phi, 
-             "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}");
-    DrawInPad(fBody, 2, dndeta_eta, "Same", kLegend);
-    DrawInPad(fBody, 3, allEta, "nostack hist", kLegend,
+    DrawInPad(p, 1, mcRings, "nostack same", kLegend|kSilent);
+    DrawInPad(p, 2, allEta, "nostack hist", kLegend,
              "#phi acceptance and #eta coverage per ring");
-    DrawInPad(fBody, 3, allPhi, "nostack hist same", 0x0);
-    DrawInPad(fBody, 4, GetH1(fResults, "norm"), "", 0x0, 
+    DrawInPad(p, 2, allPhi, "nostack hist same", 0x0);
+
+    p = fBody->cd(2);
+    p->Divide(1,2,0,0);
+    DrawInPad(p, 1, dndeta_phi, "", 0x0, 
+             "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}");
+    DrawInPad(p, 1, dndeta_eta, "Same", kLegend);
+    DrawInPad(p, 2, GetH1(fResults, "norm"), "", 0x0, 
              "Total #phi acceptance and #eta coverage");
-    DrawInPad(fBody, 4, GetH1(fResults, "phi"), "same", kLegend);
+    DrawInPad(p, 2, GetH1(fResults, "phi"), "same", kLegend);
     // DrawInPad(fBody, 4, GetH1(fSums,    "d2Ndetadphi"), "colz");
 
     // fBody->cd(1);
@@ -884,6 +1182,8 @@ protected:
     // fBody->cd(3);
     // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)");
     
+    fParVal->SetX(savX);
+    fParVal->SetY(savY);
     PrintCanvas("Results");
   }
 
@@ -903,8 +1203,11 @@ protected:
     stack->Add(dndeta);
     
     DrawInPad(fBody, 1, stack, "nostack");
-    stack->GetHistogram()->SetXTitle("#it{#eta}");
-    stack->GetHistogram()->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
+    TH1* h = stack->GetHistogram();
+    if (h) {
+      h->SetXTitle("#it{#eta}");
+      h->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
+    }
     fBody->cd(1);
     TLegend* l = new TLegend(.3, .05, .7, .4);
     l->SetFillColor(0);
index 12005fa238267263a220c15caafaf485bb697095..4bee55fdcbc38eebd3767d8a5acdb95a2300d91b 100644 (file)
@@ -30,6 +30,7 @@
 #  include <TGaxis.h>
 #  include <TPad.h>
 #  include <TRegexp.h>
+#  include <TGraph.h>
 # else 
 #  ifdef __ACLIC__
 class THStack;
@@ -76,7 +77,8 @@ public:
       fPause(false),
       fLandscape(false), 
       fRingMap(0), 
-      fPDF(true)
+      fPDF(true),
+      fLastTitle("")
   {
     fRingMap = new TVirtualPad*[6];
     fRingMap[0] = 0;
@@ -629,9 +631,13 @@ protected:
   {
     // Info("CloseCanvas", "Closing canvas");
     // ClearCanvas();
-    if (fPDF && fCanvas)
+    if (fPDF && fCanvas) {
+      // Printf("Closing canvas with last title %s", fLastTitle.Data());
       fCanvas->Print(Form("%s]", fCanvas->GetTitle()),
-                    Form("pdf %s", fLandscape ? "Landscape" : ""));
+                    Form("pdf %s Title:%s", 
+                         fLandscape ? "Landscape" : "",
+                         fLastTitle.Data()));
+    }
     if (fCanvas)
       fCanvas->Close();
     fCanvas = 0;
@@ -662,7 +668,7 @@ protected:
       gSystem->RedirectOutput("/dev/null");
       fCanvas->Print(fCanvas->GetTitle(), tit);
       gSystem->RedirectOutput(0);
-
+      fLastTitle = title;
       Pause();
 
       ClearCanvas();
@@ -723,6 +729,8 @@ protected:
       DrawObjClone(static_cast<TH1*>(o), options, title);
     else if (o->IsA()->InheritsFrom(THStack::Class())) 
       DrawObjClone(static_cast<THStack*>(o), options, title);
+    else if (o->IsA()->InheritsFrom(TGraph::Class()))
+      o->DrawClone(options);
     else 
       o->Draw(options);
   }
@@ -739,6 +747,10 @@ protected:
     o->Draw(options);
     if (title && title[0] != '\0') o->GetHistogram()->SetTitle(title);
     TAxis*   xAxis = o->GetXaxis();
+    if (!xAxis) {
+      Warning("DrawObjClone", "No X-axis for drawn stack %s", o->GetName());
+      return;
+    }
     TH1*     h     = 0;
     Int_t    nBins = xAxis->GetNbins();
     Double_t xMin  = xAxis->GetXmin();
@@ -816,7 +828,12 @@ protected:
     DrawObjClone(h, o, title);
     
     if (flags& kLegend) { 
-      TLegend* l = p->BuildLegend(0.33, .67, .66, .99-p->GetTopMargin());
+      Double_t x1 = fParVal->GetX();
+      Double_t y1 = fParVal->GetY();
+      Double_t x2 = TMath::Min(x1+.5, .99);
+      Double_t y2 = TMath::Min(y1+.5, .99-p->GetTopMargin());
+      //Printf("Legend at (%f,%f)x(%f,%f)", x1, y1, x2, y2);
+      TLegend* l = p->BuildLegend(x1, y1, x2, y2);
       l->SetFillColor(0);
       l->SetFillStyle(0);
       l->SetBorderSize(0);
@@ -1185,7 +1202,8 @@ protected:
     fParName->SetTextSize(save);
     fParVal->SetTextSize(save);
 
-    fBody->Divide(2,4);
+    if (fLandscape) fBody->Divide(4,2);
+    else            fBody->Divide(2,4);
     
     TH1*    nEventsTr    = GetH1(c, "nEventsTr");
     TH1*    nEventsTrVtx = GetH1(c, "nEventsTrVtx");
@@ -1220,7 +1238,7 @@ protected:
     if (cent && centQual) { 
       cent->Scale(1, "width");
       centQual->Scale(1, "width");
-      DrawInPad(fBody, 7, cent);
+      DrawInPad(fBody, 7, cent, "", kLogy);
       DrawInPad(fBody, 8, centQual, "colz", kLogz);
     }
     
@@ -1315,6 +1333,7 @@ protected:
   Bool_t   fLandscape; // Landscape or Portrait orientation
   TVirtualPad** fRingMap;
   Bool_t   fPDF;
+  TString  fLastTitle;
 };
 #if 0
 template <> 
diff --git a/PWGLF/FORWARD/analysis2/trains/ELossTimeTask.C b/PWGLF/FORWARD/analysis2/trains/ELossTimeTask.C
new file mode 100644 (file)
index 0000000..0c0f0d6
--- /dev/null
@@ -0,0 +1,378 @@
+#ifndef __CINT__
+# include <AliFMDEventInspector.h>
+# include <AliForwardCorrectionManager.h>
+# include <TH2.h>
+# include <AliESDFMD.h>
+# include <AliAODForwardMult.h>
+# include <AliESDEvent.h>
+# include <TFile.h>
+# include <TSystem.h>
+#else
+class AliFMDEventInspector;
+class TH2;
+class AliESDFMD;
+#endif
+#include <AliBaseESDTask.h>
+#include <AliForwardUtil.h>
+#define NO_TASK
+#define NO_SORTER
+#include "EventTimeTask.C"
+
+/**
+ * @defgroup pwglf_forward_eventtime Investigation of time-between-events 
+ * @ingroup pwglf_forward_trains_specific
+ */
+/**
+ * Task to analyse the energy loss in the FMD rings as function of the
+ * time to previous event.
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */
+struct ELossTimeTask : public AliBaseESDTask
+{
+  /** 
+   * Constructor - for I/O only
+   */
+  ELossTimeTask() 
+    : AliBaseESDTask(),
+      fEventInspector(),
+      fFMD1i(),
+      fFMD2i(),
+      fFMD2o(), 
+      fFMD3i(),
+      fFMD3o(),
+      fMap(0),
+      fDt(0)
+  {}
+  /** 
+   * Constructor 
+   * 
+   * @param name Name of task 
+   */     
+  ELossTimeTask(const char* name) 
+    : AliBaseESDTask(name, "ELossTimeTask", 
+                    &(AliForwardCorrectionManager::Instance())),
+      fEventInspector("fmdEventInspector"),
+      fFMD1i(1, 'i'),
+      fFMD2i(2, 'i'),
+      fFMD2o(2, 'o'), 
+      fFMD3i(3, 'i'),
+      fFMD3o(3, 'o'),
+      fMap(0),
+      fDt(0)
+  {
+  }
+  /** 
+   * Book output objects. Derived class should define this to book
+   * output objects on the processing output list @c fList before the
+   * actual event processing.  This is called on the master and on
+   * each slave.
+   * 
+   * If this member function returns false, the execution is stopped
+   * with a fatal signal.
+   *
+   * @return true on success. 
+   */
+  virtual Bool_t Book() 
+  {
+    fNeededCorrections = 0;
+    fExtraCorrections  = 0;
+
+    fDt = new TH1D("dt", "Time-to-last event (PS-triggered)", 60, 0, 15);
+    fDt->SetXTitle("log_{10}(#Deltat)");
+    fDt->SetFillColor(kYellow+2);
+    fDt->SetLineColor(kYellow+2);
+    fDt->SetFillStyle(3001);
+    fDt->SetDirectory(0);
+    fList->Add(fDt);
+
+    fFMD1i.Book(fList, fDt);
+    fFMD2i.Book(fList, fDt);
+    fFMD2o.Book(fList, fDt);
+    fFMD3i.Book(fList, fDt);
+    fFMD3o.Book(fList, fDt);
+
+    // Possibly re-read map
+    ReadMap("map.root");
+
+    return true;
+  }
+  /** 
+   * Process a single event
+   * 
+   * @param esd Input event 
+   * 
+   * @return true on success 
+   */
+  virtual Bool_t Event(AliESDEvent& esd)
+  {
+    Bool_t   lowFlux   = kFALSE;
+    UInt_t   triggers  = 0;
+    UShort_t ivz       = 0;
+    TVector3 ip;
+    Double_t cent      = 0;
+    UShort_t nClusters = 0;
+    UInt_t   found     = fEventInspector.Process(&esd, triggers, lowFlux, 
+                                                ivz, ip, cent, nClusters);
+    if (found & AliFMDEventInspector::kNoEvent)    return false;
+    if (found & AliFMDEventInspector::kNoTriggers) return false;
+    if (found & AliFMDEventInspector::kNoSPD)      return false;
+    if (found & AliFMDEventInspector::kNoFMD)      return false;
+    if (found & AliFMDEventInspector::kNoVertex)   return false;
+    if (found & AliFMDEventInspector::kBadVertex)  return false;
+
+    // do not process pile-up, A, C, and E events 
+    if (triggers & AliAODForwardMult::kPileUp)     return false;
+    if (triggers & AliAODForwardMult::kA)          return false;
+    if (triggers & AliAODForwardMult::kC)          return false;
+    if (triggers & AliAODForwardMult::kE)          return false;
+  
+    // We want only the events found by off-line 
+    if (!(triggers & AliAODForwardMult::kOffline)) return false;
+    
+    // Perhaps we should also insist on MB only 
+    // if (fOnlyMB && (!(triggers & AliAODForwardMult::kInel))) return false;
+         
+    // Get FMD data 
+    AliESDFMD* esdFMD = esd.GetFMDData();
+    ULong64_t  period = esd.GetPeriodNumber();
+    ULong64_t  orbit  = esd.GetOrbitNumber();
+    ULong64_t  bc     = esd.GetBunchCrossNumber();
+    ULong64_t  full   = EventTimeData::EncodeFull(period, orbit, bc);
+    ULong64_t  dt     = fMap->Get(full);
+    Double_t   logDt  = TMath::Log10(25. * dt);
+    if (dt == EventTimeMap::kInvalidTime) {
+      logDt = 0;
+      Printf("!!! Failed to find dT for 0x%016llu", full);
+    }
+    // else 
+    //   Printf("=== 0x%016llu -> 0x%016llu", full, dt);
+    fDt->Fill(logDt);
+    
+    for (UShort_t d = 1; d <= 3; d++) { 
+      UShort_t nQ = d == 1 ? 1 : 2;
+      for (UShort_t q = 0; q < nQ; q++) { 
+       RingHistos* r = 0;
+       switch (d) { 
+       case 1: r = &fFMD1i; break;
+       case 2: r = (q == 0 ? &fFMD2i : &fFMD2o); break;
+       case 3: r = (q == 0 ? &fFMD3i : &fFMD3o); break;
+       }
+       r->Event(*esdFMD, logDt);
+      }
+    }
+    return true;
+  }
+  /** 
+   * Do the final analysis on the merged output. 
+   * 
+   * @return true on success
+   */
+  virtual Bool_t Finalize() 
+  { 
+    fDt = static_cast<TH1*>(fList->FindObject("dt"));
+
+    fFMD1i.Finalize(fList, fResults, fDt);
+    fFMD2i.Finalize(fList, fResults, fDt);
+    fFMD2o.Finalize(fList, fResults, fDt);
+    fFMD3i.Finalize(fList, fResults, fDt);
+    fFMD3o.Finalize(fList, fResults, fDt);
+    return true; 
+  }
+  /** 
+   * Get a reference to the event inspector. User must override this
+   * to return proper object
+   * 
+   * @return Reference to the event inspector 
+   */
+  virtual AliFMDEventInspector& GetEventInspector() { return fEventInspector; }
+  /** 
+   * Get a reference to the event inspector. User must override this
+   * to return proper object
+   * 
+   * @return Reference to the event inspector 
+   */
+  virtual const AliFMDEventInspector& GetEventInspector() const 
+  {
+    return fEventInspector;
+  }
+  /** 
+   * Read the map from timestamp to time-to-previous event 
+   * 
+   * @param filename File to read the map from 
+   * 
+   * @return true on success, false otherwise 
+   */
+  Bool_t ReadMap(const char* filename)
+  {
+    if (gSystem->AccessPathName(filename, kReadPermission)) {
+      // TSystem::AccessPathName returns false if file can be accessed!
+      Error("ReadMap", "File \"%s\" cannot be open for reading", filename);
+      return false;
+    }
+    Printf("Opening \"%s\" ...", filename);
+    TFile* file = TFile::Open(filename, "READ");
+    if (!file) { 
+      Error("ReadMap", "Failed to open file \"%s\"", filename);
+      return false;
+    }
+    Printf("Opened \"%s\" ...", filename);
+    TObject* o = file->Get("eventTimeMap");
+    if (!o) { 
+      Error("ReadMap", "Failed to get \"eventTimeMap\" from %s", filename);
+      return false;
+    }
+    Printf("Got object \"eventTimeMap\" from \"%s\" ...", filename);
+    if (!o->IsA()->InheritsFrom(EventTimeMap::Class())) { 
+      Error("ReadMap", "Object \"%s\" is not an EventTimeMap, but a %s", 
+           o->GetName(), o->ClassName());
+      return false;
+    }
+    Printf("Set the \"eventTimeMap\" to use");
+    if (fMap) { 
+      delete fMap;
+      fMap = 0;
+    }
+    fMap = static_cast<EventTimeMap*>(o);
+    file->Close();
+    return true;
+  }
+  /** 
+   * Create and connect the task 
+   * 
+   * @param mapfile File name of file containing timestamp map
+   * 
+   * @return true on connect
+   */
+  static Bool_t Create(const char* mapfile) 
+  {
+    ELossTimeTask* task = new ELossTimeTask("elossTime");
+    if (!task->ReadMap(mapfile)) return false;
+    task->Connect();
+    return true;
+  }
+protected:
+  /** 
+   * Dummy copy constructor 
+   * 
+   * @param o Object to copy from 
+   */
+  ELossTimeTask(const ELossTimeTask& o) : AliBaseESDTask(o) {}
+  /** Our event inspector */
+  AliFMDEventInspector fEventInspector;
+  /** 
+   * Structure to hold per-ring histograms 
+   */
+  struct RingHistos : public AliForwardUtil::RingHistos
+  {
+    /** 
+     * Constructor - for I/O only
+     */
+    RingHistos() 
+      : AliForwardUtil::RingHistos(),
+       fDtVsELoss(0)
+    {}
+    /** 
+     * Constructor 
+     * 
+     * @param d detector number 
+     * @param r ring identifier 
+     */
+    RingHistos(UShort_t d, Char_t r) 
+      : AliForwardUtil::RingHistos(d,r),
+       fDtVsELoss(0)
+    {}
+    /** 
+     * Book histograms 
+     * 
+     * @param dir Parent list to add our list to
+     * @param dt  Histogram of time differences 
+     * 
+     * @return true on success 
+     */
+    Bool_t Book(TList* dir, TH1* dt)
+    {
+      TList* l = DefineOutputList(dir);
+      // Double_t dtBins[] = { 0, 1, 2e3, 5e5, 1.1e6, 5e6, 1e12, 1e20 };
+      fDtVsELoss = new TH2D("dtVsELoss", 
+                           Form("#Deltat vs #Delta/#Delta_{mip} - %s", 
+                                GetName()), 450, 0, 15, 
+                           dt->GetXaxis()->GetNbins(), 
+                           dt->GetXaxis()->GetXmin(), 
+                           dt->GetXaxis()->GetXmax());
+      fDtVsELoss->SetXTitle("#Delta/#Delta_{mip}");
+      fDtVsELoss->SetYTitle("log_{10}(#Deltat) [ns]");
+      fDtVsELoss->SetMarkerColor(Color());
+      fDtVsELoss->SetDirectory(0);
+      l->Add(fDtVsELoss);
+
+      return true;
+    }
+    /** 
+     * Process a single event
+     * 
+     * @param fmd   FMD ESD data
+     * @param logDt Logarithm (base 10) of Time-to-previous event
+     */
+    void Event(AliESDFMD& fmd, Double_t logDt)
+    {
+      const UShort_t nSec = NSector();
+      const UShort_t nStr = NStrip();
+      for (UShort_t s = 0; s < nSec; s++) { 
+       for (UShort_t t = 0; t < nStr; t++) { 
+         Float_t mult = fmd.Multiplicity(fDet,fRing,s,t);
+         if(mult == AliESDFMD::kInvalidMult || mult <= 0) 
+           continue;
+         fDtVsELoss->Fill(mult, logDt);
+       }
+      }
+    }
+    void Finalize(const TList* input, TList* output, TH1* dt)
+    {
+      TList* in  = GetOutputList(input);
+      TList* out = DefineOutputList(output);
+
+      fDtVsELoss = static_cast<TH2*>(in->FindObject("dtVsELoss"));
+
+      TH2* dtVsELoss = static_cast<TH2*>(fDtVsELoss->Clone());
+      dtVsELoss->SetDirectory(0);
+      dtVsELoss->SetZTitle("1/N_{events}");
+      dtVsELoss->Reset();
+      for (UShort_t j = 1; j <= dt->GetNbinsX(); j++) { 
+       Double_t norm = dt->GetBinContent(j);
+       if (norm <= 0) {
+         // Warning("Finalize", "Bin %d empty in dT", j);
+         continue;
+       }
+       for (UShort_t i = 1; i <= fDtVsELoss->GetNbinsX(); i++) { 
+         Double_t c = fDtVsELoss->GetBinContent(i, j);
+         Double_t e = fDtVsELoss->GetBinError(i, j);
+         dtVsELoss->SetBinContent(i,j,c/norm);
+         dtVsELoss->SetBinError(i,j,e/norm);
+       }
+      }
+      out->Add(dtVsELoss);
+    }
+    /** Our histogram */
+    TH2* fDtVsELoss;
+    ClassDef(RingHistos,1)
+  };
+  /** Container of FMD1i histograms */
+  RingHistos    fFMD1i;
+  /** Container of FMD2i histograms */
+  RingHistos    fFMD2i;
+  /** Container of FMD2o histograms */
+  RingHistos    fFMD2o;
+  /** Container of FMD3i histograms */
+  RingHistos    fFMD3i;
+  /** Container of FMD3o histograms */
+  RingHistos    fFMD3o;
+  /** Map from timestamp to time-to-previous event*/
+  EventTimeMap* fMap;
+  /** Distribution of log10(dt) */
+  TH1* fDt;
+  ClassDef(ELossTimeTask,2)
+};
+//
+// EOF
+//
diff --git a/PWGLF/FORWARD/analysis2/trains/ELossTimeTrain.C b/PWGLF/FORWARD/analysis2/trains/ELossTimeTrain.C
new file mode 100644 (file)
index 0000000..7a46de6
--- /dev/null
@@ -0,0 +1,312 @@
+// ELossTimeTrain.C
+#ifndef NO_TRAIN
+#ifndef __CINT__
+#include <AliAnalysisManager.h>
+#include <fstream>
+#else
+class AliAnalysisManager;
+#endif
+#include "TrainSetup.C"
+#include "ParUtilities.C"
+
+/** 
+ * Train to record time of each event 
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */        
+class ELossTimeTrain : public TrainSetup
+{
+public:
+  /** 
+   * Constructor 
+   * 
+   * @param name The name 
+   */
+  ELossTimeTrain(const char* name="eventTime") : TrainSetup(name)
+  { 
+    fOptions.Add("map", "FILE", "File containg map", "map.root");
+    fOptions.Set("type", "ESD");
+  }
+  /** 
+   * Create our tasks 
+   */
+  void CreateTasks(AliAnalysisManager*)
+  {
+    if (!fHelper->LoadLibrary("PWGLFforward2")) 
+      Fatal("CreateTasks", "Failed to load PWGLFforward2");
+    
+    if (!ParUtilities::MakeScriptPAR(fHelper->Mode() == Helper::kLocal,
+                                    "EventTimeTask.C",
+                                    // Gui because of CDB - sigh!
+                                    // XMLParser because of CDB 
+                                    "Gui,XMLParser,"
+                                    "STEERBase,CDB,ESD,AOD,ANALYSIS,OADB,"
+                                    "ANALYSISalice",
+                                    fHelper)) 
+      Fatal("","Failed to make support PAR");
+    if (!fHelper->LoadLibrary("EventTimeTask")) 
+      Fatal("CreateTasks", "Failed to load EventTimeTask");
+
+    if (!ParUtilities::MakeScriptPAR(fHelper->Mode() == Helper::kLocal,
+                                    "ELossTimeTask.C",
+                                    "Gui,STEERBase,CDB,ESD,AOD,ANALYSIS,OADB,"
+                                    "ANALYSISalice,PWGLFforward2,"
+                                    "EventTimeTask",
+                                    fHelper)) 
+      Fatal("","Failed to make PAR");
+    if (!fHelper->LoadLibrary("ELossTimeTask")) 
+      Fatal("CreateTasks", "Failed to load ELossTimeTask");
+
+    TString mapfile = fOptions.Get("map");
+    gROOT->ProcessLine(Form("ELossTimeTask::Create(\"%s\")", mapfile.Data()));
+
+    fHelper->LoadAux(mapfile.Data(), true);
+  }
+  /** 
+   * Do not create a physics selection
+   */
+  // void CreatePhysicsSelection(Bool_t, AliAnalysisManager*) {}
+  /** 
+   * Do not create a centrality selection
+   */
+  void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {}
+  /** 
+   * Do not create an output handler
+   */
+  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
+  /** 
+   * The train class name 
+   * 
+   * @return Train class name
+   */
+  const char* ClassName() const { return "ELossTimeTrain"; }
+  /** 
+   * Overloaded to create new dNdeta.C and dndeta.sh in the output 
+   * directory
+   * 
+   * @param asShellScript 
+   */
+  void SaveSetup(Bool_t asShellScript)
+  {
+    TrainSetup::SaveSetup(asShellScript);
+    
+    SaveDraw();
+  }
+  void SaveDraw()
+  {
+    std::ofstream o("Draw.C");
+    o << "// Written by " << ClassName() << "\n"
+      << "void Draw(const char* fileName=\"AnalysisResults.root\")\n"
+      << "{\n"
+      << "  gSystem->AddIncludePath(\"-DNO_TRAIN -DSUMMARY\");\n"
+      << "  const char* fwd = \"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
+      << "  gSystem->AddIncludePath(Form(\"-I%s/scripts\", fwd));\n"
+      << "  gROOT->SetMacroPath(Form(\"%s/trains:%s\", fwd,\n"
+      << "                           gROOT->GetMacroPath()));\n"
+      << "  gROOT->LoadMacro(\"ELossTimeTrain.C+\");\n"
+      << "  ELossTimeSummary s;\n"
+      << "  s.Run(fileName);\n"
+      << "}\n"
+      << std::endl;
+    o.close();
+  }
+  void PostShellCode(std::ostream& f)
+  {
+    f << "  echo \"=== Draw results ...\"\n"
+      << "  aliroot -l -b -q ${prefix}Draw.C\\(\\\"AnalysisResults.root\\\"\\)\n"
+      << std::endl;
+  }
+};
+#endif
+#ifdef SUMMARY
+# include <SummaryDrawer.C>
+# include <TColor.h>
+
+/**
+ * Draw summary of the above train
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */
+struct ELossTimeSummary : public SummaryDrawer 
+{
+  enum EFlags { 
+    kEventInspector    = 0x001, 
+  };
+  /** 
+   * Run the class 
+   * 
+   * @param fname Filename 
+   * @param flags Flags
+   */
+  void Run(const char* fname, UShort_t flags=0x01)
+  {
+    // --- Open the file -----------------------------------------------
+    TString filename(fname);
+    TFile* file = TFile::Open(filename.Data(), "READ");
+    if (!file) { 
+      Error("Run", "Failed to open \"%s\"", filename.Data());
+      return;
+    }
+    fPause         = flags & kPause;
+    
+    // --- Make our canvas ---------------------------------------------
+    TString pdfName(filename);
+    pdfName.ReplaceAll(".root", ".pdf");
+    CreateCanvas(pdfName, flags & kLandscape);
+
+    // --- Make title page -------------------------------------------
+    TCollection* c = GetCollection(file, "elossTimeSums");
+    DrawTitlePage(c);
+
+    if (flags & kEventInspector)    DrawEventInspector(c);
+    
+    TH1* dt = GetH1(c, "dt");
+    DrawInPad(fBody, 0, dt, "", kLogy);
+    PrintCanvas("#Deltat");
+
+    const char* rings[] = { "FMD1i", "FMD2i", "FMD2o", "FMD3o", "FMD3i", 0 };
+    const char** pring   = rings;
+
+    while (*pring) {
+      DrawRing(c, *pring, dt);
+      pring++;
+    }
+
+    CloseCanvas();
+  }
+  /** 
+   * Draw the title page 
+   * 
+   * @param c Parent collection
+   */
+  void DrawTitlePage(TCollection* c)
+  {
+    fBody->cd();
+
+    Double_t y = .7;
+    TLatex* ltx = new TLatex(.5, y, "#Deltat vs #Delta/#Delta_{mip}");
+    ltx->SetTextSize(0.07);
+    ltx->SetTextFont(62);
+    ltx->SetTextAlign(22);
+    ltx->SetNDC();
+    ltx->Draw();
+
+    Double_t save = fParName->GetTextSize();
+    fParName->SetTextSize(0.03);
+    fParVal->SetTextSize(0.03);
+    y = .6;
+    
+    TCollection* fc = GetCollection(c, "fmdEventInspector");
+    UShort_t sys;
+    UShort_t sNN;
+    ULong_t  runNo;
+    GetParameter(fc, "sys",     sys);
+    GetParameter(fc, "sNN",     sNN);
+    GetParameter(fc, "runNo",   runNo);
+    
+    DrawParameter(y, "Run #", Form("%lu", runNo));
+    TString tS; SysString(sys, tS);      DrawParameter(y, "System", tS);
+    TString tE; SNNString(sNN, tE);      DrawParameter(y, "#sqrt{s_{NN}}", tE);
+
+    PrintCanvas("Title page");
+    fParName->SetTextSize(save);
+    fParVal->SetTextSize(save);
+  }
+  /** 
+   * Draw a single ring
+   * 
+   * @param c     Parent collection
+   * @param ring  Ring name 
+   * @param dt    Histogram of delta time 
+   */
+  void DrawRing(TCollection* c, const char* ring, TH1* dt)
+  {
+    TCollection* lring = GetCollection(c, ring);
+    if (!lring) return;
+    
+    TH2* h2 = GetH2(lring, "dtVsELoss");
+    if (!h2) return;
+
+    THStack* stack = new THStack(ring, ring);
+    // stack->SetTitle(ring);
+
+    THStack* ratios = new THStack(Form("Ratios for %s",ring), ring);
+    // stack->SetTitle(ring);
+
+    Printf(ring);
+    Int_t j = 2;
+    TH1* first = 0;
+    Double_t lfirst = 0;
+    Double_t rmax = 0;
+    Double_t max = 3;
+    for (Int_t i = 1; i <= h2->GetNbinsY(); i++) { 
+      TH1*     h     = h2->ProjectionX(Form("%s_%03d", ring, i), i,i);
+      Double_t logDt = h2->GetYaxis()->GetBinCenter(i);
+
+      Int_t    nFill = h->GetEntries();
+      if (nFill <= 1000) continue;
+      Double_t norm = dt->GetBinContent(i);
+      if (norm <= 1e-6) {
+       Warning("", "Normalization=%f<1e-6 but got "
+               "%d>1000 entries for log10(dt)=%5.3f", norm, nFill, logDt);
+       continue;
+      }
+      if (!first && logDt > TMath::Log10(25.)) {
+       lfirst = logDt;
+       first = h;
+      }
+      // Info("", "Normalization is %f", norm);
+      h->Sumw2();
+      h->Scale(1. / norm);
+      h->SetTitle(Form("log_{10}(#Deltat)=%5.3f", logDt));
+
+      Float_t r, g, b;
+      TColor::HSV2RGB((j-1)*45, 1, .8, r, g, b);
+      Int_t col = TColor::GetColor(r, g, b);
+      j++;
+      h->SetLineColor(col);
+      h->SetLineStyle(j % 3+1);
+      h->SetLineWidth(2);
+      // h->SetFillColor(col);
+      // h->SetFillStyle(3002);
+      stack->Add(h);
+
+      if (h == first) continue;
+      TH1* rh = static_cast<TH1*>(h->Clone(Form("ratio%s", h->GetName())));
+      // rh->SetTitle(Form("log_{10}(#Deltat)=%5.3f", logDt));
+      rh->Divide(first);
+      for (Int_t k = 1; k <= rh->GetNbinsX(); k++) {
+       if (rh->GetXaxis()->GetBinCenter(k) > max) break;
+       rmax = TMath::Max(rmax, rh->GetBinContent(k));
+      }
+
+      ratios->Add(rh);
+    }
+    Double_t savX = fParVal->GetX();
+    Double_t savY = fParVal->GetY();
+    fParVal->SetX(0.12);
+    fParVal->SetY(0.12);
+    fBody->Divide(1,2,0,0);
+    DrawInPad(fBody,1,stack,"nostack hist", kLogy|kLegend);
+    stack->GetXaxis()->SetRangeUser(-.1,max);
+    stack->GetYaxis()->SetTitle("1/N_{ev} dN/d(#Delta/#Delta_{mip})");
+
+    fParVal->SetX(0.6);
+    fParVal->SetY(0.4);
+    DrawInPad(fBody,2,ratios,"nostack hist", kLegend);
+    ratios->GetXaxis()->SetRangeUser(-.1, max);
+    ratios->GetXaxis()->SetTitle("#Delta/#Delta_{mip}");
+    ratios->GetYaxis()
+      ->SetTitle(Form("X/(1/N_{ev}dN/d(#Delta/#Delta_{mip}))|_{%5.3f}",lfirst));
+    Printf("Max: %f (%f)", ratios->GetMaximum(), rmax);
+    ratios->SetMaximum(rmax*1.2);
+
+
+    fParVal->SetX(savX);
+    fParVal->SetY(savY);
+    PrintCanvas(ring);
+  }
+};
+
+#endif 
+// EOF
diff --git a/PWGLF/FORWARD/analysis2/trains/EventTimeTask.C b/PWGLF/FORWARD/analysis2/trains/EventTimeTask.C
new file mode 100644 (file)
index 0000000..4217ea2
--- /dev/null
@@ -0,0 +1,820 @@
+// EventTimeTask.C
+#ifndef __CINT__
+# include <TTree.h>
+# include <TError.h>
+# include <TChain.h>
+#else
+class TTree;
+// Force load of libGui
+class TGWindow;
+#endif
+class AliESDEvent;
+
+/**
+ * Data structure to be filled by task - one for each event
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */
+struct EventTimeData 
+{
+  /**
+   * Widths of field in the full timestamp 
+   */
+  enum { 
+    kBCWidth      = 12, 
+    kOrbitWidth   = 24, 
+    kPeriodWidth  = 28
+  };
+  /** Full time stamp */
+  ULong64_t fFull;
+  /** LDC creation time - standard time_t */
+  UInt_t    fTime;
+  /** Mask of detectors present in the event - FMD is 0x1000 */
+  UInt_t    fDetectors;
+  /** Type of event - 7 is physics */
+  UShort_t  fType;
+  /** GUID */
+  UChar_t   fGUID[42];
+  /** 
+   * Create a branch in a tree 
+   * 
+   * @param tree Tree to create the branch in 
+   */
+  void CreateBranch(TTree* tree)
+  {
+    tree->Branch("event", &(this->fFull), 
+                "full/l:time/i:detector:type/s:guid/C");
+  }
+  /** 
+   * Set the address of a branch for reading back objects from the tree
+   * 
+   * @param tree Tree to read back from 
+   */
+  void ReadBranch(TTree* tree) 
+  {
+    tree->SetBranchAddress("event", &(this->fFull));
+  }
+  /** 
+   * Utility function to encode the full time stamp from components. 
+   * 
+   * @param period Period counter (overflow of orbit counter)
+   * @param orbit  Orbit counter (period of 88us)
+   * @param bc     Bunch crossing number (period of 25ns)
+   * 
+   * @return Encoded full time stamp 
+   */
+  static ULong64_t EncodeFull(ULong64_t period, 
+                             ULong64_t orbit, 
+                             ULong64_t bc) 
+  {
+    const ULong64_t bcMask     = (1 << kBCWidth) - 1;
+    const ULong64_t orbitMask  = (1 << kOrbitWidth) - 1;
+    const ULong64_t periodMask = (1 << kPeriodWidth) - 1;
+    ULong64_t ret = ((bc     & bcMask)                  | 
+                    (orbit  & orbitMask)  <<  kBCWidth | 
+                    (period & periodMask) << (kBCWidth+kOrbitWidth));
+    return ret;
+  }
+  /** 
+   * Fill information from ESD into this data structure. 
+   * 
+   * @param esd  Event 
+   * @param dets List of active detectors in this event. 
+   * @param guid Current file GUID
+   */
+  void Fill(AliESDEvent* esd, UInt_t dets, const TString& guid);
+};
+
+#ifndef NO_TASK
+# ifndef __CINT__
+#  include <AliESDEvent.h>
+# endif
+inline void EventTimeData::Fill(AliESDEvent* esd, UInt_t dets, 
+                               const TString& guid)
+{
+  ULong64_t period = esd->GetPeriodNumber();
+  ULong64_t orbit  = esd->GetOrbitNumber();
+  ULong64_t bc     = esd->GetBunchCrossNumber();
+  fType            = esd->GetEventType();
+  fTime            = esd->GetTimeStamp();//LDC time
+  fDetectors       = dets; // esd->GetDAQDetectorPattern();
+  fFull            = EncodeFull(period, orbit, bc);
+  Int_t i = 0;
+  for (i = 0; i < guid.Length() && i < 42; i++) fGUID[i] = guid[i];
+  for (; i < 42; i++) fGUID[i] = '\0';
+  fGUID[41] = '\0';
+}
+# else
+inline void EventTimeData::Fill(AliESDEvent*, UInt_t, const TString&) 
+{
+  Warning("Fill", "Calling empty method - shouldn't happen");
+}
+#endif
+
+#ifndef NO_TASK
+# ifndef __CINT__
+#  include <AliAnalysisManager.h>
+#  include <AliVEventHandler.h>
+#  include <AliESDEvent.h>
+#  include <TTree.h>
+#  include <TH2.h>
+#  include <TList.h>
+#  include <AliCDBManager.h>
+#  include <AliCDBEntry.h>
+#  include <AliTriggerConfiguration.h>
+#  include <AliTriggerClass.h>
+#  include <AliTriggerCluster.h>
+#  include <AliDAQ.h>
+#  include <TObjArray.h>
+#  include <TDirectory.h>
+#  include <TUrl.h>
+# else
+class AliAnalysisManager;
+class TTree;
+class AliTimeStamp;
+class TList;
+class TH2;
+# endif
+# include <AliAnalysisTaskSE.h>
+# include <vector>
+/**
+ * A task to record the unique timestamp of each event. 
+ *
+ * @par Input: ESD 
+ * @par Output:  A tree with a single branch 
+ * @ingroup pwglf_forward_eventtime
+ */
+class EventTimeTask : public AliAnalysisTaskSE
+{
+public:
+  enum { 
+    kListSlot = 1,
+    kTreeSlot = 2
+  };
+  /** 
+   * Default CTOR - for I/O only.
+   */
+  EventTimeTask() 
+    : AliAnalysisTaskSE(), 
+      fTree(0),
+      fHistograms(0),
+      fDetVsType(0)
+  {
+  }
+  /** 
+   * User constructor 
+   * 
+   * @param name Name of task 
+   */
+  EventTimeTask(const char* name) 
+    : AliAnalysisTaskSE(name), 
+      fTree(0),
+      fHistograms(0),
+      fDetVsType(0),
+      fGUID("")
+  {
+    DefineOutput(kListSlot, TList::Class());
+    DefineOutput(kTreeSlot, TTree::Class());
+    fBranchNames = "ESD:AliESDRun.,AliESDHeader.";
+  }
+  /** 
+   * Create user output objects.
+   *
+   * Called on each slave at start of job
+   */
+  void UserCreateOutputObjects()
+  {
+    Printf("Creating tree and histogram");
+    fGUID = "";
+    fHistograms = new TList();
+    fHistograms->SetOwner();
+    fHistograms->SetName("L");
+    
+    fDetVsType = new TH2D("detVsType", "Detector vs type", 
+                    16, -.5, 15.5, 31, -.5, 30.5);
+    fDetVsType->SetXTitle("Type");
+    fDetVsType->SetYTitle("Detector");
+    fDetVsType->SetDirectory(0);
+    fHistograms->Add(fDetVsType);
+    Printf("Histogram (%d,%f,%f)x(%d,%f,%f)",
+          fDetVsType->GetXaxis()->GetNbins(), 
+          fDetVsType->GetXaxis()->GetXmin(), 
+          fDetVsType->GetXaxis()->GetXmax(),
+          fDetVsType->GetYaxis()->GetNbins(), 
+          fDetVsType->GetYaxis()->GetXmin(), 
+          fDetVsType->GetYaxis()->GetXmax());
+
+    // TDirectory* savdir = gDirectory;
+    // Printf("Opening file at slot %d", kTreeSlot);
+    // OpenFile(kTreeSlot);
+    Printf("Make tree and disassociate from file");
+    fTree = new TTree("T", "T");
+    fTree->SetDirectory(0);
+    Printf("Create branch");
+    fData.CreateBranch(fTree);
+    // savdir->cd();
+    
+
+    PostData(kListSlot, fHistograms);
+    PostData(kTreeSlot, fTree);
+  }
+  /** 
+   * Analyse a single event 
+   * 
+   */
+  void UserExec(Option_t*)
+  {
+    static Bool_t first = true;
+    LoadBranches();
+
+    AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
+    if (!esd) return;
+    if (!esd->GetHeader()) return;     
+
+    if (first) {
+      LoadTriggerConfig(esd->GetRunNumber());
+      first = false;
+    }
+    ULong64_t mask = esd->GetTriggerMask();
+    UInt_t    dets = 0;
+    for (UShort_t i = 0; i < fDets.size(); i++) {
+      if ((1 << i) & mask) dets |= fDets[i];
+    }
+    // Printf("Event mask 0x%016llx -> 0x%08x", mask, dets);
+    fData.Fill(esd, dets, fGUID);
+    fTree->Fill();
+
+    UInt_t type      = esd->GetEventType();
+    UInt_t detectors = dets;
+    for (UInt_t i = 0; i < 31; i++) { 
+      if ((1 << i) & detectors) fDetVsType->Fill(type, i);
+    }
+
+    PostData(kListSlot, fHistograms);
+    PostData(kTreeSlot, fTree);
+  }
+  Bool_t UserNotify()
+  {
+    fGUID = "";
+    AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
+    AliVEventHandler*   inp = mgr->GetInputEventHandler();
+    if (!inp) { 
+      Warning("UserNotify", "No input handler");
+      return true;
+    }
+    TTree* tree = inp->GetTree();
+    if (!tree) { 
+      Warning("UserNotify", "No input tree");
+      return true;
+    }
+    TFile* file = tree->GetCurrentFile();
+    if (!file) { 
+      Warning("UserNotify", "No current file for tree");
+      return true;
+    }
+    const TUrl* url = file->GetEndpointUrl();
+    if (!url) { 
+      Warning("UserNotify", "No end point for file");
+      return false;
+    }
+    fGUID = gSystem->BaseName(url->GetFile());
+    Printf("Got GUID=%s from %s", fGUID.Data(), url->GetUrl());
+    
+    return true;
+  }
+  void LoadTriggerConfig(Int_t runNo)
+  {
+    Printf("Loading trigger configuration for run %d",  runNo);
+    // --- Connect to CDB --------------------------------------------
+    AliCDBManager* cdb = AliCDBManager::Instance();
+    cdb->SetDefaultStorageFromRun(runNo);
+    cdb->SetRun(runNo);
+    
+    // --- Get entry -------------------------------------------------
+    AliCDBEntry* entry = cdb->Get("GRP/CTP/Config");
+    if (!entry || !entry->GetObject()) { 
+      Warning("LoadTriggerConfig", "Couldn't get trigger configuration");
+      return;
+    }
+    AliTriggerConfiguration* config = 
+      static_cast<AliTriggerConfiguration*>(entry->GetObject());
+
+    // --- Get the classes, and resize cache -------------------------
+    const TObjArray& clss = config->GetClasses();
+    fDets.resize(clss.GetEntries());
+
+    // --- Loop over configurations ----------------------------------
+    TIter next(&clss);
+    AliTriggerClass* cls = 0;
+    while ((cls = static_cast<AliTriggerClass*>(next()))) {
+      Int_t              mask    = cls->GetMask();
+      AliTriggerCluster* cluster = cls->GetCluster();
+      if (!cluster) { 
+       Warning("LoadTriggerConfig", 
+               "Failed to get trigger cluster for %s", cls->GetName());
+       continue;
+      }
+      TString names = cluster->GetDetectorsInCluster();
+      if (names.IsNull()) { 
+       Warning("LoadTriggerConfig", "No detectors for cluster %s",
+               cls->GetName());
+       continue;
+      }
+      UInt_t dets = AliDAQ::DetectorPattern(names);
+      UInt_t id   = UInt_t(TMath::Log2(mask));
+      fDets[id]   = dets;
+      Printf("Trigger mask 0x%08x (%3d): 0x%08x (%s)", 
+            mask, id, dets, names.Data());
+    }
+    // cdb->Destroy();
+  }
+  /** 
+   * Register with manager and connect output containers
+   * 
+   * @param mgr Manager 
+   */
+  void Connect(AliAnalysisManager* mgr)
+  {
+    mgr->AddTask(this);
+    mgr->ConnectInput(this, 0, mgr->GetCommonInputContainer());
+    AliAnalysisDataContainer* contTree = 
+      mgr->CreateContainer("T", TTree::Class(), 
+                          AliAnalysisManager::kOutputContainer,
+                          "time.root");
+    AliAnalysisDataContainer* contList = 
+      mgr->CreateContainer("L", TList::Class(), 
+                          AliAnalysisManager::kOutputContainer,
+                          "hist.root");
+    mgr->ConnectOutput(this, kTreeSlot, contTree);
+    mgr->ConnectOutput(this, kListSlot, contList);
+  }
+  /** 
+   * Create an instance of this task, and register it and it's
+   * outputs.
+   */
+  static void Create()
+  {
+    EventTimeTask* task = new EventTimeTask("eventTime");
+    task->Connect(AliAnalysisManager::GetAnalysisManager());
+  }
+  TTree*              fTree;       // Our tree
+  EventTimeData       fData;       // Our data 
+  TList*              fHistograms; // List
+  TH2D*               fDetVsType;  // Histogram
+  std::vector<UInt_t> fDets;       // Per-trigger-bit detector mask 
+  TString             fGUID;
+  
+  ClassDef(EventTimeTask,3);
+};
+#endif // NO_TASK 
+
+#ifndef NO_MAP
+#include <utility>
+#include <map>
+
+typedef std::pair<ULong64_t,ULong64_t> EventTimeMapPair;
+
+/**
+ * A map of event time-stamp to distance to previous event
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */
+struct EventTimeMap : public TObject
+{
+  /** Map type */
+  typedef std::map<ULong64_t,ULong64_t> Map;
+  /** Key type */
+  typedef Map::key_type Key;
+  /** Mapped value type */
+  typedef Map::mapped_type Value;
+  /** Element type */
+  typedef Map::value_type Pair;
+  /** Iterator type */
+  typedef Map::iterator   Iterator;
+  /** Constant iterator type */
+  typedef Map::const_iterator ConstIterator;
+  /** 
+   * Constructor
+   */
+  EventTimeMap() : TObject(), fMap() {}
+  /** 
+   * Destructor 
+   */
+  virtual ~EventTimeMap() {}
+  /** 
+   * Get name of this object - always the same 
+   * 
+   * @return The string "eventTimeMap"
+   */
+  const char* GetName() const { return "eventTimeMap"; }
+  /** 
+   * Element access.  If the key @a k doesn't already exist, it is
+   * created
+   * 
+   * @param k Key 
+   * 
+   * @return A pair of key and value 
+   */
+  Value& operator[](const Key& k)
+  {
+    return fMap[k];
+  } 
+  /** 
+   * Find the element whos key is @a k 
+   * 
+   * @param k Key to look for
+   * 
+   * @return Iterator pointing to element, or end of container if not found 
+   */
+  Iterator Find(const Key& k)
+  {
+    return fMap.find(k);
+  }
+  /** 
+   * Find the element whos key is @a k 
+   * 
+   * @param k Key to look for
+   * 
+   * @return Iterator pointing to element, or end of container if not found 
+   */
+  ConstIterator Find(const Key& k) const
+  {
+    return fMap.find(k);
+  }
+  /** 
+   * Get forward iterator pointing beginning of the container
+   *
+   * @return Iterator to start of container
+   */
+  Iterator Begin()
+  {
+    return fMap.begin();
+  }
+  /** 
+   * Get forward iterator pointing beginning of the container
+   *
+   * @return Iterator to start of container
+   */
+  ConstIterator Begin() const
+  {
+    return fMap.begin();
+  }
+  /** 
+   * Get forward iterator pointing just beyond the end of the container
+   *
+   * @return Iterator just beyond container
+   */
+  Iterator End()
+  {
+    return fMap.end();
+  }
+  /** 
+   * Get forward iterator pointing just beyond the end of the container
+   *
+   * @return Iterator just beyond container
+   */
+  ConstIterator End() const
+  {
+    return fMap.end();
+  }
+  enum { 
+    kInvalidTime = 0xFFFFFFFFFFFFFFFF
+  };
+  /**
+   * Get the time difference to previous event from a event with a
+   * given time stamp.
+   *
+   * @param timestamp Time stamp of the event 
+   *
+   * @return time difference or kInvalidTime if not found 
+   */
+  Value Get(const Key& timestamp) const 
+  {
+    ConstIterator i = Find(timestamp);
+    if (i == End()) return kInvalidTime;
+    return i->second;
+  }
+  /** 
+   * Set the time to previous event for a given event time stamp
+   * 
+   * @param timestamp Event time stamp 
+   * @param diff      Time to previous event 
+   */
+  void Set(const Key& timestamp, const Value& diff)
+  {
+    this->operator[](timestamp) = diff;
+  }
+  ULong64_t Size() const { return fMap.size(); }
+  /** Our embeded map */
+  Map fMap;
+  ClassDef(EventTimeMap,1)
+};
+#endif // NO_MAP
+
+#ifndef NO_SORTER
+# ifndef __CINT__
+#  include <TFile.h>
+#  include <TArrayL64.h>
+#  include <TMath.h>
+#  include <TParameter.h>
+#  include <TCanvas.h>
+#  include <TH1.h>
+# else 
+class TFile;
+class TTree;
+class TCanvas;
+# endif
+
+/** 
+ * A class to sort the tree and generate our timestamp->dT map.
+ *
+ * @ingroup pwglf_forward_eventtime
+ */
+struct EventTimeSorter 
+{
+  TTree*        fTree; 
+  EventTimeData fData;
+  ULong64_t     fMin;
+  ULong64_t     fMax;
+
+  /** 
+   * Constructor 
+   */
+  EventTimeSorter() : fTree(0), fData(), fMin(0xFFFFFFFFFFFFFFFF), fMax(0) {}
+  /** 
+   * Progress meter 
+   * 
+   * @param cur    Current entry
+   * @param total  Total number of entries
+   */
+  void Progress(Long64_t cur, Long64_t total) const
+  {
+    static UShort_t old = 0;
+    if (cur == 0) old = 0;
+    UShort_t now = UShort_t(100 * (cur + 1 == total ? 1 : 
+                                  Double_t(cur)/total));
+    if (now > old) 
+      std::cout << "\rLooping over " << total << " entries: ... "
+               << now << '%' << std::flush;
+    if (now >= 100) std::cout << std::endl;
+    old = now;
+  }
+  /** 
+   * Connect a tree 
+   * 
+   * @param inputName 
+   * @param treeName 
+   * 
+   * @return 
+   */
+  Bool_t OpenInput(const char* inputName, const char* treeName)
+  {
+    CloseInput();
+
+    // --- Get input -------------------------------------------------
+    TChain* chain = new TChain(treeName);
+    chain->Add(inputName);
+    if (chain->GetListOfFiles()->GetEntries() < 1) { 
+      Error("Run", "Failed to add \"%s\" to chain", inputName);
+      return false;
+    }
+    fTree = chain;
+
+    // --- Set branch address ---------------------------------------
+    fData.ReadBranch(fTree);
+
+    return true;
+  }
+  /** 
+   * Disconnect tree
+   */          
+  void CloseInput()
+  {
+    if (!fTree) return;
+    TFile* file = fTree->GetCurrentFile();
+    if (file) file->Close();
+    fTree = 0;
+  }
+  /** 
+   * Run the sorter 
+   * 
+   * @param inputName   Input file name 
+   * @param outputName  Output file name 
+   * @param treeName    Tree name 
+   * 
+   * @return true on success
+   */
+  Bool_t Run(const char* inputName, const char* outputName, 
+            const char* treeName="T") 
+  {
+    if (!OpenInput(inputName, treeName)) return false;
+
+    // --- Loop over the data ----------------------------------------
+    Long64_t   nEnt    = fTree->GetEntries();
+    Long64_t   n       = 0;
+    ULong64_t* values  = new ULong64_t[nEnt];
+    UInt_t*    dets    = new UInt_t[nEnt];
+    UShort_t*  types   = new UShort_t[nEnt];
+    UInt_t*    times   = new UInt_t[nEnt];
+    for (Long64_t iEnt = 0; iEnt < nEnt; iEnt++) { 
+      Progress(iEnt, nEnt);
+
+      fTree->GetEntry(iEnt);
+
+      if (!(fData.fDetectors & 0x1000)) 
+       // No FMD read-out 
+       continue;
+      if (fData.fType != 7) { 
+       // Ignore all but physics events 
+       Warning("Run", "Non-PHYSICS event (%d) with FMD in it", fData.fType);
+       // continue;
+      }
+
+      // Store values 
+      Int_t j = n;
+      values[j] = fData.fFull;
+      dets[j]   = fData.fDetectors;
+      types[j]  = fData.fType;
+      times[j]  = fData.fTime;
+      n++;
+    }
+    
+    // --- Now sort all values ---------------------------------------
+    TArrayL64 index(n);
+    TMath::Sort(n, values, index.fArray, false);
+    
+    // Maps the unique time to the distance to previous event 
+    EventTimeMap  eventTimeMap;
+    ULong64_t     key   = values[index[0]];
+    ULong64_t     prev  = 0;
+    ULong64_t     dt    = key-prev;
+    ULong64_t     min   = 0xFFFFFFFFFFFFFFFF;
+    ULong64_t     max   = 0;
+    eventTimeMap[key]   = dt; 
+    for (Long64_t i = 1; i < n; i++) { 
+      Long64_t j        = index[i];
+      Long64_t k        = index[i-1];
+      key               = values[j];
+      prev              = values[k];
+      dt                = key - prev;
+      if (dt <= 0) {
+       Printf("0x%016llx==0x%016llx -> dt=%10llu [%10lld %10lld] "
+              "(det: 0x%08x 0x%08x  type: 0x%04x 0x%04x  time: %08d %08d)",
+              key, prev, dt, j, k, dets[j], dets[k], 
+              types[j], types[k], times[j], times[k]);
+       // continue;
+      }
+      eventTimeMap[key] = dt;
+      min               = TMath::Min(dt, min);
+      max               = TMath::Max(dt, max);
+    }
+    std::cout << "Range is [" << min << "," << max << ']' << std::endl;
+
+    TFile* output = TFile::Open(outputName, "RECREATE");
+    if (!output) { 
+      Error("Run", "Failed to create output file \"%s\"", outputName);
+      return false;
+    }
+    fMin = min;
+    fMax = max;
+    eventTimeMap.Write();
+    output->Write();
+    output->Close();
+    
+    delete [] values; 
+
+    CloseInput();
+
+    return true;
+  }
+  Bool_t Test(const char* inputName, const char* outputName, 
+             const char* treeName="T") 
+  {
+    if (!OpenInput(inputName, treeName)) return false;
+
+    // --- Get our map -----------------------------------------------
+    TFile* output = TFile::Open(outputName, "UPDATE");
+    if (!output) { 
+      Error("Test", "Failed to open \"%s\"", outputName);
+      return false;
+    }
+
+    EventTimeMap* eventTimeMap = 
+      static_cast<EventTimeMap*>(output->Get("eventTimeMap"));
+    if (!eventTimeMap) { 
+      Error("Test", "Failed to get \"%s\" from \"%s\"",
+           "eventTimeMap", outputName);
+      return false;
+    }
+
+    // --- Histograms --------------------------------------------------
+    ULong64_t mmin = TMath::Min(25*fMin, 900000ULL);
+    ULong64_t mmax = TMath::Min(25*fMax, 110000000ULL);
+    TH1*      diff = new TH1D("diff", "Time-to-last-event (10#mus bins w/FMD)", 
+                             (mmax-mmin)/10000, mmin, mmax);
+    diff->SetStats(0);
+    diff->SetXTitle("#Deltat [ns]");
+    diff->SetFillColor(kRed+1);
+    diff->SetFillStyle(3001);
+    diff->SetDirectory(0);
+    
+
+    TH1* ldiff = new TH1D("ldiff", "log(#Deltat) - Events w/FMD",
+                         300, 0, 15);
+    ldiff->SetStats(0);
+    ldiff->SetXTitle("log_{10}(#Deltat) [ns]");
+    ldiff->SetFillColor(kGreen+1);
+    ldiff->SetFillStyle(3001);
+    ldiff->SetDirectory(0);
+                        
+    // --- Loop over the data ----------------------------------------
+    Long64_t   nEnt    = fTree->GetEntries();
+    Long64_t   nZero   = 0;
+    Long64_t   nMiss   = 0;
+    Long64_t   nGood   = 0;
+    Long64_t   nNoFMD  = 0;
+    for (Long64_t iEnt = 0; iEnt < /*10*/ nEnt; iEnt++) { 
+      Progress(iEnt, nEnt);
+      fTree->GetEntry(iEnt);
+      
+      if (!(fData.fDetectors & 0x1000)) {
+       // No FMD read-out 
+       nNoFMD++;
+       continue;
+      }
+      if (fData.fType != 7) { 
+       // Ignore all but physics events 
+       Warning("Run", "Non-PHYSICS event (%d) with FMD in it", fData.fType);
+       // continue;
+      }
+      
+      // Look-up the timestamp 
+      ULong64_t value = fData.fFull;
+      ULong64_t dT    = eventTimeMap->Get(value);
+      if (dT == EventTimeMap::kInvalidTime) {
+       Warning("Test", "Value %llu not found", value);
+       ldiff->Fill(1);
+       nMiss++;
+       continue;
+      }
+      if (dT <= 0) { 
+#if 0
+       Warning("Test", "Impossible dt=%llu found for %llu (0x%0x %2d)", 
+               dT, value, fData.fDetectors, fData.fType);
+#endif
+       ldiff->Fill(1);
+       nZero++;
+       continue;
+      }
+      nGood++;
+      Double_t  dt    = 25.*dT;
+      diff->Fill(dt);
+      Double_t  logDt = TMath::Log10(dt);
+      ldiff->Fill(logDt);
+    }
+    CloseInput();
+    Printf("missing: %llu, bad: %llu, good: %llu, no FMD: %llu, all: %llu", 
+          nMiss,nZero,nGood,nNoFMD,nEnt);
+
+    // --- Draw results ----------------------------------------------
+    TCanvas* c = new TCanvas("c", "C");
+    c->SetTopMargin(0.01);
+    c->SetRightMargin(0.01);
+    c->Divide(2,1); // ,0,0);
+    TVirtualPad* p = c->cd(2);
+    // p->SetRightMargin(0.10);
+    p->SetLogy();
+    ldiff->DrawCopy();
+    
+    p = c->cd(1);
+    p->SetLogy();
+    p->SetLogx();
+    diff->DrawCopy();
+
+    c->Print("dt.png");
+    c->Print("dt.C");
+
+    // --- Write histogram to file -----------------------------------
+    output->cd();
+    diff->Write();
+    output->Write();
+    output->Close();
+    
+    return true;
+  }
+};
+#endif // NO_SORTER 
+#ifdef __MAKECINT__
+# ifndef NO_MAP
+#  pragma link C++ class std::pair<ULong64_t,ULong64_t>+;
+#  pragma link C++ class std::map<ULong64_t,ULong64_t>+;
+# endif
+# ifndef NO_TASK
+#  pragma link C++ class std::vector<UInt_t>+;
+# endif
+#endif
+
+// EOF
+        
+        
diff --git a/PWGLF/FORWARD/analysis2/trains/EventTimeTrain.C b/PWGLF/FORWARD/analysis2/trains/EventTimeTrain.C
new file mode 100644 (file)
index 0000000..6bd8c75
--- /dev/null
@@ -0,0 +1,104 @@
+// EventTimeTrain.C
+#ifndef __CINT__
+#include <AliAnalysisManager.h>
+#include <fstream>
+#else
+class AliAnalysisManager;
+#endif
+#include "TrainSetup.C"
+#include "ParUtilities.C"
+
+/** 
+ * Train to record time of each event 
+ * 
+ * @ingroup pwglf_forward_eventtime
+ */        
+class EventTimeTrain : public TrainSetup
+{
+public:
+  /** 
+   * Constructor 
+   * 
+   * @param name The name 
+   */
+  EventTimeTrain(const char* name="eventTime") : TrainSetup(name)
+  { 
+    fOptions.Set("type", "ESD");
+  }
+  /** 
+   * Create our tasks 
+   * 
+   */
+  void CreateTasks(AliAnalysisManager*)
+  {
+    if (!ParUtilities::MakeScriptPAR(fHelper->Mode() == Helper::kLocal,
+                                    "EventTimeTask.C",
+                                    // Gui because of CDB 
+                                    // XMLParser because of CDB
+                                    // CDB because look-up of trigger config
+                                    "Gui,XMLParser,"
+                                    "STEERBase,CDB,ESD,AOD,ANALYSIS,OADB,"
+                                    "ANALYSISalice",
+                                    fHelper)) 
+      Fatal("","Failed to make PAR");
+    fHelper->LoadLibrary("EventTimeTask");
+    gROOT->ProcessLine("EventTimeTask::Create()");
+  }
+  /** 
+   * Do not create a physics selection
+   */
+  void CreatePhysicsSelection(Bool_t, AliAnalysisManager*) {}
+  /** 
+   * Do not create a centrality selection
+   */
+  void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {}
+  /** 
+   * Do not create an output handler
+   */
+  AliVEventHandler* CreateOutputHandler(UShort_t) { return 0; }
+  /** 
+   * The train class name 
+   * 
+   * @return Train class name
+   */
+  const char* ClassName() const { return "EventTimeTrain"; }
+  /** 
+   * Overloaded to create new dNdeta.C and dndeta.sh in the output 
+   * directory
+   * 
+   * @param asShellScript 
+   */
+  void SaveSetup(Bool_t asShellScript)
+  {
+    TrainSetup::SaveSetup(asShellScript);
+    
+    SaveSort();
+  }
+  void SaveSort()
+  {
+    std::ofstream o("Sort.C");
+    o << "// Written by " << ClassName() << "\n"
+      << "void Sort(const char* prefix=\"\",\n"
+      << "          const char* fileName=\"time.root\",\n"
+      << "          const char* outName=\"map.root\",\n"
+      << "          const char* treeName=\"T\")\n"
+      << "{\n"
+      << "  gSystem->AddIncludePath(\"-DNO_TASK -I$ALICE_ROOT/include\");\n"
+      << "  TString mac(\"EventTimeTask/EventTimeTask.C+g\");\n"
+      << "  if (prefix && prefix[0] != '\\0') mac.Prepend(prefix);\n"
+      << "  gROOT->LoadMacro(mac);\n"
+      << "  EventTimeSorter s;\n"
+      << "  if (!s.Run(fileName,outName,treeName)) return;\n"
+      << "  s.Test(fileName,outName,treeName);\n"
+      << "}\n"
+      << std::endl;
+    o.close();
+  }
+  void PostShellCode(std::ostream& f)
+  {
+    f << "  echo \"=== Sort results ...\"\n"
+      << "  aliroot -l -b -q ${prefix}Sort.C\\(\\\"${prefix}\\\"\\)\n"
+      << std::endl;
+  }
+};
+// EOF
index 3f97b380e4fa69faff8fa1d0befa275617097027..56ee98b7c3c170ead137a5bbca6c507895eeff66 100644 (file)
@@ -264,7 +264,7 @@ protected:
       << "//   0x200     Pause\n"
       << "//\n"
       << "void Summarize(const char* filename=\"forward.root\",\n"
-      << "               UShort_t what=0x0FF)\n"
+      << "               UShort_t what=0x1FF)\n"
       << "{\n"
       << "  const char* fwd=\"$ALICE_ROOT/PWGLF/FORWARD/analysis2\";\n"
       << "  gROOT->LoadMacro(Form(\"%s/DrawAODSummary.C\",fwd));\n"
index 34baf5924c18478fbd00f93e2fcc1a0acbaa471c..6ac1ee2f2a703d5ae3e4fbfff4c70ce2ba8b6a7a 100644 (file)
@@ -1,7 +1,6 @@
 /**
  * @file   MakeFlowTrain.C
- * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
- * @date   Fri Jun  1 13:51:48 2012
+ * @author Alexander Hansen                                      
  * 
  * @brief  
  * 
@@ -12,7 +11,7 @@
 
 //====================================================================
 /**
- * Analysis train to make @f$ flow@f$
+ * Analysis train to make flow@
  * 
  *
  * @ingroup pwglf_forward_flow
@@ -22,27 +21,34 @@ class MakeFlowTrain : public TrainSetup
 {
 public:
   /** 
-   * Constructor.  Date and time must be specified when running this
-   * in Termiante mode on Grid
+   * Constructor.  
    * 
    * @param name     Name of train (free form)
    */
   MakeFlowTrain(const char* name)
   : TrainSetup(name)
   {
+    // General options
     fOptions.Add("mc", "Do MC analysis");
-    fOptions.Add("mom", "Flow moments to analyse", "234", "234");
-    fOptions.Add("eta-gap", "Whether to use an eta-gap", "[no,yes,both]", "both");
-    fOptions.Add("eg-value", "Set value in |eta| of the eta gap", "2.0");
+    fOptions.Add("max-mom", "2|3|4|5", "Max flow moment to analyse", "5");
     fOptions.Add("use-cent", "Whether to use the impact parameter for centrality");
-    fOptions.Add("afterburner", "What to afterburn", "[eta,phi,b,pid]", "");
-    fOptions.Add("ab-type", "Type of afterburner", "1|2|3|4", "");
-    fOptions.Add("ab-order", "Order of afterburner", "2|3|4|5|6", "");
-    fOptions.Add("sat-vtx", "Whether to use satellite interactions");
-    fOptions.Add("outlier-fmd", "Outlier cut for FMD", "NSIGMA", "4.0");
-    fOptions.Add("outlier-spd", "Outlier cut for SPD", "NSIGMA", "0.0");
+    fOptions.Add("mc-vtx", "Whether to get the vertex from the MC header");
+    fOptions.Add("afterburner", "[eta,phi,b,pid]", "What to afterburn", "");
+    fOptions.Add("ab-type", "1|2|3|4", "Type of afterburner", "");
+    fOptions.Add("ab-order", "2|3|4|5|6", "Order of afterburner", "");
+    fOptions.Add("fwd-dets", "[fmd,vzero]", "Forward detectors", "");
     fOptions.Set("type", "AOD");
     fOptions.Show(std::cout);
+    // QC specific options
+    fOptions.Add("QC", "Add QC tasks (requires AODs with FMD and SPD objects)");
+    fOptions.Add("qc-type", "[std,eta-gap,3cor,all]", "Which types of QC's to do", "both");
+    fOptions.Add("eg-value", "EGVALUE", "Set value in |eta| of the eta gap", "2.0");
+    fOptions.Add("tpc-tracks", "Whether to use TPC tracks for reference flow");
+    fOptions.Add("sat-vtx", "Whether to use satellite interactions");
+    fOptions.Add("outlier-fmd", "NSIGMA", "Outlier cut for FMD", "4.0");
+    fOptions.Add("outlier-spd", "NSIGMA", "Outlier cut for SPD", "4.0");
+    // EP specific options
+    fOptions.Add("EP", "Add EP tasks (requires VZERO AOD objects)");
   }
 protected:
   //__________________________________________________________________
@@ -54,7 +60,7 @@ protected:
   void CreateTasks(AliAnalysisManager* mgr)
   {
     // --- Output file name ------------------------------------------
-    AliAnalysisManager::SetCommonFileName("AnalysisResults.root");
+    AliAnalysisManager::SetCommonFileName("forward_flow.root");
 
     // --- Load libraries/pars ---------------------------------------
     fHelper->LoadLibrary("PWGLFforward2");
@@ -62,50 +68,99 @@ protected:
     // --- Set load path ---------------------------------------------
     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
                             gROOT->GetMacroPath()));
+    gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/ANALYSIS/macros",
+                             gROOT->GetMacroPath()));
+
+    // --- Add the tasks ---------------------------------------------
+    Bool_t doQC = fOptions.AsBool("QC");
+    Bool_t doEP = fOptions.AsBool("EP");
+    if (doQC) AddQCTasks();
+    if (doEP) AddEPTasks();
+    if (!doQC && !doEP) Fatal("CreateTasks", "No flow tasks were added");
 
+  }
+  //__________________________________________________________________
+  /**
+   * Add the QC task(s)
+   */
+  void AddQCTasks()
+  {
     // --- Get the parameters ----------------------------------------
-    TString  type    = fOptions.Get("mom");
-    TString  etaGap  = fOptions.Get("eta-gap");
-    Double_t egValue = fOptions.AsDouble("eg-value");
-    Bool_t   useCent = fOptions.AsBool("use-cent");
-    TString  addFlow = fOptions.Get("afterburner");
-    Int_t    abType  = fOptions.AsInt("ab-type");
-    Int_t    abOrder = fOptions.AsInt("ab-order");
-    Bool_t   satVtx  = fOptions.AsBool("sat-vtx");
-    Double_t fmdCut  = fOptions.AsDouble("outlier-fmd");
-    Double_t spdCut  = fOptions.AsDouble("outlier-spd");
-    Bool_t   mc      = fOptions.AsBool("mc"); 
+    Int_t    moment   = fOptions.AsInt("max-mom");
+    TString  fwdDets  = fOptions.Get("fwd-dets");
+    TString  types    = fOptions.Get("qc-type");
+    Double_t egValue  = fOptions.AsDouble("eg-value");
+    Bool_t   tpcTr    = fOptions.AsBool("tpc-tracks");
+    Bool_t   useCent  = fOptions.AsBool("use-cent");
+    Bool_t   useMCVtx = fOptions.AsBool("mc-vtx");
+    TString  addFlow  = fOptions.Get("afterburner");
+    Int_t    abType   = fOptions.AsInt("ab-type");
+    Int_t    abOrder  = fOptions.AsInt("ab-order");
+    Bool_t   satVtx   = fOptions.AsBool("sat-vtx");
+    Double_t fmdCut   = fOptions.AsDouble("outlier-fmd");
+    Double_t spdCut   = fOptions.AsDouble("outlier-spd");
+    Bool_t   mc       = fOptions.AsBool("mc"); 
 
-    // --- Add the task ----------------------------------------------
-    if (etaGap.Contains("no") || etaGap.Contains("false") ||
-        etaGap.Contains("both"))
-          gROOT->Macro(Form("AddTaskForwardFlow.C(\"%s\",%d,%d,%f,%f,%f,%d,%d,\"%s\",%d,%d)",
-                     type.Data(),
-                     kFALSE,
-                     mc, 
-                     fmdCut, 
-                     spdCut,
-                     egValue,
-                     useCent,
-                     satVtx, 
-                     addFlow.Data(), 
-                     abType, 
-                     abOrder));
+    types.ToLower();
+    fwdDets.ToUpper();
+    Bool_t doFMD = fwdDets.Contains("FMD");
+    Bool_t doVZERO = fwdDets.Contains("VZERO");
+
+    TString args(TString::Format("AddTaskForwardFlowQC.C(%d,\"%%s\",%%d,%%d,%d,%f,%f,%f,%%d,%d,%d,%d,\"%s\",%d,%d)",
+                       moment,
+                       mc, 
+                       fmdCut, 
+                       spdCut,
+                       egValue,
+                       useCent,
+                       useMCVtx,
+                       satVtx, 
+                       addFlow.Data(), 
+                       abType, 
+                       abOrder));
     
-    if (etaGap.Contains("yes") || etaGap.Contains("true") ||
-        etaGap.Contains("both"))
-          gROOT->Macro(Form("AddTaskForwardFlow.C(\"%s\",%d,%d,%f,%f,%f,%d,%d,\"%s\",%d,%d)",
-                     type.Data(),
-                     kTRUE,
-                     mc, 
-                     fmdCut, 
-                     spdCut, 
-                     egValue,
-                     useCent,
-                     satVtx, 
-                     addFlow.Data(), 
-                     abType, 
-                     abOrder));
+    // --- Add the task ----------------------------------------------
+    if (doFMD) {
+      if (types.Contains("std") || types.Contains("all")) {
+       gROOT->Macro(Form(args.Data(), "FMD", false, false, false));
+       if (tpcTr)
+         gROOT->Macro(Form(args.Data(), "FMD", false, false, true));
+      }
+      if (types.Contains("eta-gap") || types.Contains("all"))
+       gROOT->Macro(Form(args.Data(), "FMD", true, false, false));
+      if (types.Contains("3cor") || types.Contains("all"))
+       gROOT->Macro(Form(args.Data(), "FMD", false, true, false));
+    }
+    if (doVZERO) {
+      if (types.Contains("std") || types.Contains("all")) {
+       gROOT->Macro(Form(args.Data(), "VZERO", false, false, false));
+       if (tpcTr)
+         gROOT->Macro(Form(args.Data(), "VZERO", false, false, true));
+      }
+      if (types.Contains("eta-gap") || types.Contains("all"))
+       gROOT->Macro(Form(args.Data(), "VZERO", true, false, false));
+      if (types.Contains("3cor") || types.Contains("all"))
+       gROOT->Macro(Form(args.Data(), "VZERO", false, true, false));
+    }
+  }
+  //__________________________________________________________________
+  /**
+   * Add the EP task(s)
+   */
+  void AddEPTasks()
+  {
+    // --- Get the parameters ----------------------------------------
+    Int_t    moment   = fOptions.AsInt("max-mom");
+    TString  etaGap   = fOptions.Get("eta-gap");
+    TString  addFlow  = fOptions.Get("afterburner");
+    Int_t    abType   = fOptions.AsInt("ab-type");
+    Int_t    abOrder  = fOptions.AsInt("ab-order");
+    Bool_t   mc       = fOptions.AsBool("mc"); 
+    TString  fwdDets  = fOptions.Get("fwd-dets");
+
+    // --- Add the task ----------------------------------------------
+    gROOT->Macro("AddTaskEventplane.C");
+    gROOT->Macro(Form("AddTaskForwardFlowEP.C(%d, %d, \"%s\")", mc, moment, fwdDets.Data()));
   }
   //__________________________________________________________________
   /** 
index f8d702b427e4c58e00e98ce014db40493a83330e..60532c56948c88b6525122f2ed94200318490521 100644 (file)
@@ -33,7 +33,7 @@ public:
     fOptions.Add("trig",       "TYPE", "Trigger type", "V0AND");
     fOptions.Add("vzMin",      "CENTIMETER", "Min Ip Z", -4);
     fOptions.Add("vzMax",      "CENTIMETER", "Max Ip Z", +4);
-    fOptions.Add("phi-acc",    "Use stored phi acceptance", true);
+    fOptions.Add("phi-acc",    "Use stored phi acceptance", false);
     fOptions.Add("asymmetric", "Make asymmetric (+/-) bins", false);
   }
 protected:
index 4b8a4a083c115c4f277f292b1289379e82b19f41..90cae92f9de133616c377248c766696b5628fec2 100644 (file)
@@ -591,7 +591,7 @@ FILE_VERSION_FILTER    =
 # You can optionally specify a file name after the option, if omitted
 # DoxygenLayout.xml will be used as the name of the layout file.
 
-LAYOUT_FILE            =
+LAYOUT_FILE            = ../analysis2/../doc/layout.xml
 
 # The CITE_BIB_FILES tag can be used to specify one or more bib files
 # containing the references data. This must be a list of .bib files. The
diff --git a/PWGLF/FORWARD/doc/layout.xml b/PWGLF/FORWARD/doc/layout.xml
new file mode 100644 (file)
index 0000000..71907e6
--- /dev/null
@@ -0,0 +1,194 @@
+<doxygenlayout version="1.0">
+  <!-- Generated by doxygen 1.8.5 -->
+  <!-- Navigation index tabs for HTML output -->
+  <navindex>
+    <tab type="mainpage" visible="yes" title=""/>
+    <tab type="pages" visible="yes" title="" intro=""/>
+    <tab type="modules" visible="yes" title="" intro=""/>
+    <tab type="namespaces" visible="yes" title="">
+      <tab type="namespacelist" visible="yes" title="" intro=""/>
+      <tab type="namespacemembers" visible="yes" title="" intro=""/>
+    </tab>
+    <tab type="classes" visible="yes" title="">
+      <tab type="classlist" visible="yes" title="" intro=""/>
+      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> 
+      <tab type="hierarchy" visible="yes" title="" intro=""/>
+      <tab type="classmembers" visible="no" title="" intro=""/>
+    </tab>
+    <tab type="files" visible="yes" title="">
+      <tab type="filelist" visible="yes" title="" intro=""/>
+      <tab type="globals" visible="yes" title="" intro=""/>
+    </tab>
+    <tab type="examples" visible="yes" title="" intro=""/>  
+  </navindex>
+
+  <!-- Layout definition for a class page -->
+  <class>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <detaileddescription title=""/>
+    <inheritancegraph visible="$CLASS_GRAPH"/>
+    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+    <memberdecl>
+      <nestedclasses visible="yes" title=""/>
+      <publictypes title=""/>
+      <services title=""/>
+      <interfaces title=""/>
+      <publicslots title=""/>
+      <signals title=""/>
+      <publicmethods title=""/>
+      <publicstaticmethods title=""/>
+      <publicattributes title=""/>
+      <publicstaticattributes title=""/>
+      <protectedtypes title=""/>
+      <protectedslots title=""/>
+      <protectedmethods title=""/>
+      <protectedstaticmethods title=""/>
+      <protectedattributes title=""/>
+      <protectedstaticattributes title=""/>
+      <packagetypes title=""/>
+      <packagemethods title=""/>
+      <packagestaticmethods title=""/>
+      <packageattributes title=""/>
+      <packagestaticattributes title=""/>
+      <properties title=""/>
+      <events title=""/>
+      <privatetypes title=""/>
+      <privateslots title=""/>
+      <privatemethods title=""/>
+      <privatestaticmethods title=""/>
+      <privateattributes title=""/>
+      <privatestaticattributes title=""/>
+      <friends title=""/>
+      <related title="" subtitle=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <inlineclasses title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <services title=""/>
+      <interfaces title=""/>
+      <constructors title=""/>
+      <functions title=""/>
+      <related title=""/>
+      <variables title=""/>
+      <properties title=""/>
+      <events title=""/>
+    </memberdef>
+    <allmemberslink visible="yes"/>
+    <usedfiles visible="$SHOW_USED_FILES"/>
+    <authorsection visible="yes"/>
+  </class>
+
+  <!-- Layout definition for a namespace page -->
+  <namespace>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <memberdecl>
+      <nestednamespaces visible="yes" title=""/>
+      <constantgroups visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <inlineclasses title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </namespace>
+
+  <!-- Layout definition for a file page -->
+  <file>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <includegraph visible="$INCLUDE_GRAPH"/>
+    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+    <sourcelink visible="yes"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <constantgroups visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <inlineclasses title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection/>
+  </file>
+
+  <!-- Layout definition for a group page -->
+  <group>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <groupgraph visible="$GROUP_GRAPHS"/>
+    <memberdecl>
+      <nestedgroups visible="yes" title=""/>
+      <dirs visible="yes" title=""/>
+      <files visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <memberdef>
+      <pagedocs/>
+      <inlineclasses title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </group>
+
+  <!-- Layout definition for a directory page -->
+  <directory>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <directorygraph visible="yes"/>
+    <memberdecl>
+      <dirs visible="yes"/>
+      <files visible="yes"/>
+    </memberdecl>
+  </directory>
+</doxygenlayout>
index b021156a78c4e9924acf8b7cf2213f61abdb810f..440e9a61b18a88144e469678c6b3f3d5a2316a66 100644 (file)
@@ -356,6 +356,7 @@ struct ChainBuilder
 
 
     collection->SetDefaultTreeName(chain->GetName());
+    Long64_t nEntries = 0;
     while ((element = static_cast<TChainElement*>(next()))) {
       Info("", "Element: '%s' - '%s' %lld", 
           element->GetName(), element->GetTitle(), 
@@ -368,9 +369,16 @@ struct ChainBuilder
       // info->AddUrl(Form("file://%s", element->GetTitle()));
       collection->Add(info);
       
+      Long64_t n = element->GetEntries();
+      if (n >= 0) nEntries += n;
+      
     }
     collection->Update();
+    TFileInfoMeta* cMeta = new TFileInfoMeta(chain->GetName(), 
+                                            "TTree", nEntries);
+    collection->AddMetaData(cMeta);
     collection->Write();
+    Printf("A total of %lld entries", nEntries);
     // collection->Print("MFL");
     out->Close();
   }
@@ -507,7 +515,8 @@ struct ChainBuilder
   {
     Info("", "Removing bad file %s", path.Data());
     gSystem->RedirectOutput("/dev/null", "w");
-    gSystem->Unlink(path);
+    // gSystem->Unlink(path);
+    gSystem->Rename(path, Form("%s.bad", path.Data()));
     gSystem->RedirectOutput(0);    
   }
   //------------------------------------------------------------------
index 2037043895091614ffab90805b0248e6649656b6..37a438d46cf5921deb81b34a778565f190b68f40 100644 (file)
 void
 CreateFileCollection(const TString& dir="/data/alice/data/ppb/LHC12g/pass1/188359/",
                     const TString& tN="esdTree", 
-                    const TString& pa="AliESD", 
+                    const TString& pa="AliESD*", 
                     Bool_t mc=false, 
                     Bool_t recursive=false)
 )
 {
-  gROOT->LoadMacro("ChainBuilder.C+");
+  gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/trains/ChainBuilder.C+");
   
-  UShort_t type = ChainBuilder::CheckSource(dir);
+  UShort_t flags = 0;
+  if (recursive) flags |= ChainBuilder::kRecursive;
+  if (mc)        flags |= ChainBuilder::kMC;
+  UShort_t type = ChainBuilder::CheckSource(dir, flags);
   Info("", "type=%d", type);
-  TChain* chain = ChainBuilder::Create(dir, tN, pa, mc, recursive);
+  TChain* chain = ChainBuilder::Create(type, dir, tN, pa, flags);
   if (!chain) { 
     Error("CreateFileCollection", "Failed to make chain");
     return;
diff --git a/PWGLF/FORWARD/trains/CreateIndex.C b/PWGLF/FORWARD/trains/CreateIndex.C
new file mode 100644 (file)
index 0000000..3112977
--- /dev/null
@@ -0,0 +1,42 @@
+void
+CreateIndex(const TString& dir, const TString& tree="esdTree")
+{
+  gROOT->SetMacroPath(Form("$ALICE_ROOT/PWGLF/FORWARD/trains:%s", 
+                          gROOT->GetMacroPath()));
+  gROOT->LoadMacro("ChainBuilder.C+");
+  
+  Bool_t mc = false;
+  if (tree.BeginsWith("mc")) { 
+    mc = true;
+    tree.Remove(0,2);
+  }
+  
+  TString pat("*.root");
+  if      (tree.EqualTo("esdTree", TString::kIgnoreCase)) pat="AliESDs*";
+  else if (tree.EqualTo("aodTree", TString::kIgnoreCase)) pat="AliAOD*";
+  else    Warning("", "Unknown tree: %s, pattern set to *.root", tree.Data());
+  if (mc) pat.Prepend("root_archive.zip@");
+
+
+  TString opts;
+  opts.Append(Form("pattern=%s", pat.Data()));
+  opts.Append("&check");
+  opts.Append("&clean");
+  opts.Append("&recursive");
+  if (mc) opts.Append("&mc");
+
+  TUrl url;
+  url.SetProtocol("local");
+  url.SetPort(0);
+  url.SetFile(dir);
+  url.SetAnchor(tree);
+  url.SetOptions(opts);
+  
+  Printf("Running ChainBuilder::CreateCollection(\"%s/index.root\",\"%s\")",
+        dir.Data(), url.GetUrl());
+  ChainBuilder::CreateCollection(Form("%s/index.root", dir.Data()), url);
+}
+
+                                
+  
+  
index 2dcd006481e2923e075653c8f6478ede09689ae2..65bb6131c8b5e8c17dd452933072eab3e77b5f68 100644 (file)
@@ -179,12 +179,14 @@ struct LiteHelper : public ProofHelper
                        TProofDebug::kGlobal|*/
                        TProofDebug::kPackage);
     if (nEvents < 0) nEvents = fChain->GetEntries();
-    Info("Run", "Output objects registered with PROOF:");
-    gProof->GetOutputList()->ls();
-    Long64_t ret = mgr->StartAnalysis("proof", fChain, nEvents);
+    Long64_t off = fOptions.AsLong("offset", 0);
+    if (nEvents > 0 && nEvents < off) {
+      Warning("Run", "Number of events %lld < offset (%lld), stopping", 
+             nEvents, off);
+      return 0;
+    }
+    Long64_t ret = mgr->StartAnalysis("proof", fChain, nEvents, off);
     
-    Info("Run", "Output objects registered with PROOF:");
-    gProof->GetOutputList()->ls();
     if (fVerbose > 2) 
       TProof::Mgr(fUrl.GetUrl())->GetSessionLogs()->Save("*","lite.log");
     return ret;
index be07e97806ea53b9ed7962b4acd26e5b39c887f1..66feb5daa878c1f3b2dc4adc4fc7af5f808bdf12 100644 (file)
@@ -60,16 +60,16 @@ public:
       AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
       AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
       if (inputHandler) {
-       Info("", "Got input handler");
-       TList *uiList = inputHandler->GetUserInfo();
-       if (uiList) {
-         Info("", "Got user list:");
-         uiList->ls();
-       
-         fProd = new AliProdInfo(uiList);
-         Info("", "Lising production information");
-         fProd->List();
-       }
+        Info("", "Got input handler");
+        TList *uiList = inputHandler->GetUserInfo();
+        if (uiList) {
+          Info("", "Got user list:");
+          uiList->ls();
+        
+          fProd = new AliProdInfo(uiList);
+          Info("", "Lising production information");
+          fProd->List();
+        }
       }
     }
 
index d67447d4c628b34ca37553b0811236fadcb0d8b2..3db04e546d6dc5ffbda275ccbb3bed32e9d3b66f 100644 (file)
@@ -355,6 +355,7 @@ struct ParUtilities
        << "  export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:"
        << "${ALICE_ROOT}/lib/tgt_${ALICE_TARGET}\n"
        << "fi\n"
+       << "# printenv | sort -u\n"
        << "echo BUILD.sh@`hostname`: Building " << base << "\n"
        << "root.exe -l -out -q PROOF-INF/BUILD.C 2>&1 | tee " 
        << base << ".log\n"
@@ -402,6 +403,7 @@ struct ParUtilities
       }
     }
     out << "  // gDebug = 5;\n"
+       << "  // gSystem->ListLibraries();\n"
        << "  int ret = gROOT->LoadMacro(\"" 
        << base << "." << ext << "++g\");\n"
        << "  if (ret != 0) Fatal(\"BUILD\",\"Failed to build\");\n"
@@ -446,20 +448,36 @@ struct ParUtilities
        << "  if (val.IsNull())\n"
        << "    Warning(\"Add\",\"%s_INCLUDE not defined\", env);\n"
        << "  else {\n"
-       << "    gSystem->AddIncludePath(Form(\"-I../%s\",val.Data()));\n"
+       << "    // gSystem->AddIncludePath(Form(\"-I../%s\",val.Data()));\n"
+       << "    // Prepend to include path\n"
+       << "    TString incPath(gSystem->GetIncludePath());\n"
+       << "    incPath.Prepend(Form(\"-I../%s \",val.Data()));\n"
+       << "    gSystem->SetIncludePath(incPath);\n"
+       << "    // Printf(\"Include path: %s\",incPath.Data());\n"
        << "  }\n"
        << "}\n\n"
        << "void LoadDep(const char* name) {\n"
-       << "  gSystem->AddDynamicPath(Form(\"../%s\",name));\n"
+       << "  // Printf(\"Loading dependency \\\"%s\\\" ...\",name);\n"
+       << "  // gSystem->AddDynamicPath(Form(\"../%s\",name));\n"
+       << "  // Prepend to dynamic path\n"
+       << "  TString dynPath(gSystem->GetDynamicPath());\n"
+       << "  dynPath.Prepend(Form(\"../%s:\",name));\n"
+       << "  gSystem->SetDynamicPath(dynPath);\n"
+       << "  // Printf(\"Dynamic path: %s\",dynPath.Data());\n"
        << "  char* full = gSystem->DynamicPathName(name,true);\n"
        << "  if (!full) \n"
        << "   full = gSystem->DynamicPathName(Form(\"lib%s\",name),true);\n"
        << "  if (!full) \n"
        << "   full = gSystem->DynamicPathName(Form(\"lib%s.so\",name),true);\n"
+       << "  if (!full) \n"
+       << "   full = gSystem->DynamicPathName(Form(\"%s_C.so\",name),true);\n"
+       << "  if (!full) \n"
+       << "   full = gSystem->DynamicPathName(Form(\"%s_h.so\",name),true);\n"
        << "  if (!full) {\n"
        << "    Warning(\"LoadDep\",\"Module %s not found\", name);\n"
        << "    return;\n"
        << "  }\n"
+       << "  Printf(\"Loading \\\"%s\\\" for \\\"%s\\\"\",full,name);\n"
        << "  gSystem->Load(full);\n"
        << "}\n"
        << std::endl;
@@ -490,6 +508,7 @@ struct ParUtilities
     }
     out << "void SETUP() {\n"
        << "  gROOT->LoadMacro(\"PROOF-INF/UTIL.C\");\n"
+       << "  Printf(\"Loading \\\"" << base << "\\\" ...\");\n"
        << "  LoadROOTLibs();\n"
        << "  // Info(\"SETUP\",\"Loading libraries\");\n";
     if (deps) {
index a528b2e99242b3bda57c8374975bf70b7b782623..0e876a0a5046d7ebc0edf41395b0055b66bf3c8f 100644 (file)
@@ -110,6 +110,8 @@ struct ProofHelper : public Helper
     fOptions.Add("clear",    "PKGS", "Clear packages ','-separated", "");
     fOptions.Add("reset",    "soft|hard", "Reset cluster", "hard");
     fOptions.Add("feedback", "Enable feedback mechanism");
+    fOptions.Add("env",      "SCRIPT", "Script to set-up environment","-none-");
+    fOptions.Add("offset",   "EVENTS", "Skip this number of events", 0);
     if (!fUrl.GetUser() || fUrl.GetUser()[0] == '\0') 
       fUrl.SetUser(gSystem->GetUserInfo()->fUser);
     fAuxFiles.SetOwner();
@@ -306,24 +308,48 @@ struct ProofHelper : public Helper
     b.close();
     gSystem->Exec(Form("chmod a+x %s/PROOF-INF/BUILD.sh",parName.Data()));
 
+    TString envScript = fOptions.Get("env");
+    if (envScript.EqualTo("-none-", TString::kIgnoreCase)) 
+      envScript = "";
+    if (!envScript.IsNull()) { 
+      // If an environment script was specified, copy that to the par
+      if (gSystem->AccessPathName(envScript.Data()) == 0) { 
+       // Copy script 
+       if (gSystem->Exec(Form("cp %s %s/PROOF-INF/", envScript.Data(), 
+                              parName.Data())) != 0) {
+         Error("ProofHelper", "Failed to copy %s", envScript.Data());
+         return false;
+       }
+      }
+      else {
+       Warning("CreateALIROOTPar", "Couldn't read %s", envScript.Data());
+       envScript = "";
+      }
+    }
     std::ofstream s(Form("%s/PROOF-INF/SETUP.C", parName.Data()));
     if (!s) { 
       Error("ProofHelper::CreateAliROOTPar", 
            "Failed to make SETUP.C ROOT script");
       return false;
     }
-    s << "void SETUP(TList* opts) {\n"
-      << "  gSystem->Setenv(\"ALICE\",\"" 
+    s << "void SETUP(TList* opts) {\n";
+    if (envScript.IsNull()) {
+      s << "  gSystem->Setenv(\"ALICE\",\"" 
       << gSystem->Getenv("ALICE") << "\");\n"
       << "  gSystem->Setenv(\"ALICE_ROOT\",\"" 
       << gSystem->Getenv("ALICE_ROOT") << "\");\n"
       << "  gSystem->Setenv(\"ALICE_TARGET\",\"" 
-      << gSystem->Getenv("ALICE_TARGET") << "\");\n"
-      << "  gSystem->AddDynamicPath("
-      << "\"$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)\");\n";
+       << gSystem->Getenv("ALICE_TARGET") << "\");\n";
     if (gSystem->Getenv("OADB_PATH")) 
       s << "  gSystem->Setenv(\"OADB_PATH\",\"" 
        << gSystem->Getenv("OADB_PATH") << "\");\n";
+    }
+    else { 
+      s << "  gROOT->Macro(\"PROOF-INF/" << gSystem->BaseName(envScript.Data())
+       << "\");\n";
+    }
+    s          << "  gSystem->AddDynamicPath("
+       << "\"$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)\");\n";
     s << "  \n"
       << "  // Info(\"SETUP\",\"Loading ROOT libraries\");\n"
       << "  gSystem->Load(\"libTree\");\n"
@@ -362,7 +388,7 @@ struct ProofHelper : public Helper
       << "  \n";
     s << "  par = opts->FindObject(\"ALIROOT_EXTRA_LIBS\");\n"
       << "  if (par) {\n"
-      << "    Info(\"SETUP\",\"Libaries to load: %s\n\",par->GetTitle());\n"
+      << "    Info(\"SETUP\",\"Libaries to load: %s\\n\",par->GetTitle());\n"
       << "    TString tit(par->GetTitle());\n"
       << "    TObjArray* tokens = tit.Tokenize(\":\");\n"
       << "    TObject*   lib    = 0;\n"
@@ -371,7 +397,7 @@ struct ProofHelper : public Helper
       << "      TString libName(lib->GetName());\n"
       << "      if (!libName.BeginsWith(\"lib\")) libName.Prepend(\"lib\");\n"
       << "      // Info(\"SETUP\",\"Loading %s ...\",libName.Data());\n"
-      << "      gSystem->Load(Form(\"lib%s\",lib->GetName()));\n"
+      << "      gSystem->Load(libName.Data());\n"
       << "    }\n"
       << "  }\n"
       << "}\n"
@@ -607,9 +633,15 @@ struct ProofHelper : public Helper
     TString dsName(fUrl.GetFile());
     // if (fUrl.GetAnchor() && fUrl.GetAnchor()[0] != '\0') 
     //   dsName.Append(Form("#%s", fUrl.GetAnchor()));
-    Info("Run", "Output objects registered with PROOF:");
-    gProof->GetOutputList()->ls();
-    Long64_t ret = mgr->StartAnalysis(fUrl.GetProtocol(), dsName, nEvents);
+    // Info("Run", "Output objects registered with PROOF:");
+    // gProof->GetOutputList()->ls();
+    Long64_t off = fOptions.AsLong("offset", 0);
+    if (nEvents > 0 && nEvents < off) {
+      Warning("Run", "Number of events %lld < offset (%lld), stopping", 
+             nEvents, off);
+      return 0;
+    }
+    Long64_t ret = mgr->StartAnalysis(fUrl.GetProtocol(), dsName, nEvents, off);
     
     if (fVerbose > 10) 
       TProof::Mgr(fUrl.GetUrl())->GetSessionLogs()->Save("*","proof.log");
index c69b7ad8a24c84fef9af1c86ed036a1407c755f9..997cefb1863d2a2395fc293a4bbc210b3c3387f5 100644 (file)
@@ -1,8 +1,8 @@
 /**
- * @defgroup pwglf_forward_trains Trains
+ * @defgroup pwglf_forward_trains Trains.
  * 
- * Train specifications 
- *
+ * Train specifications. 
+ * See also @ref train_setup_doc
  */
 /**
  * @file   TrainSetup.C
index 4436789fe2292690cae69956c08d0259e44900c6..a1f38bfbc00a531ce2290a794ac95dd32af2acdf 100644 (file)
@@ -114,6 +114,7 @@ void ProgramUsage(const char* progname, std::ostream& o)
   PrintFakeOption(o, "class=CLASS",       "Train class");
   PrintFakeOption(o, "name=NAME",         "Name of train");
   PrintFakeOption(o, "include=DIRECTORY", "Append dir to macro/header path");
+  PrintFakeOption(o, "define=DEFINE",     "Set a preprocessor macro");
   PrintFakeOption(o, "batch",             "Batch mode");
   PrintFakeOption(o, "spawn",             "Spawn interactive ROOT shell");
 }
@@ -142,6 +143,7 @@ main(int argc, char** argv)
 {
   TList optList;
   TList paths;
+  TList defines;
   TString name;
   TString cls;
   TString where;
@@ -163,7 +165,7 @@ main(int argc, char** argv)
       if      (arg.BeginsWith("--class"))   cls  = val;
       else if (arg.BeginsWith("--name"))    name = val;
       else if (arg.BeginsWith("--include")) paths.Add(new TObjString(val)); 
-      // AppendPath(val);
+      else if (arg.BeginsWith("--define"))  defines.Add(new TObjString(val));
       else if (arg.BeginsWith("--batch"))   batch  = true;
       else if (arg.BeginsWith("--help"))    help   = true;
       else if (arg.BeginsWith("--where"))   where  = val;
@@ -186,6 +188,10 @@ main(int argc, char** argv)
   TIter nextP(&paths);
   TObject* path = 0;
   while ((path = nextP())) AppendPath(path->GetName());
+  TIter nextD(&defines);
+  TObject* def = 0;
+  while ((def = nextD())) 
+    gSystem->AddIncludePath(Form("-D%s", def->GetName()));
 
   // --- Initial check or URI/WHERE ----------------------------------
   if (!where.IsNull()) {
index ba0a8b5bee027bad5bab81af418f891c1312175f..68e637e581376528a149136a2e0313e2c9eeafcf 100644 (file)
 #endif
 #pragma link C++ class AliForwardFlowTaskQC+;
 #if ROOT_VERSION_CODE < 0x56300 // ROOT_VERSION(5,99,0)
+#pragma link C++ class AliForwardFlowTaskQC::CumuHistos+;
+#endif
+#if ROOT_VERSION_CODE < 0x56300 // ROOT_VERSION(5,99,0)
 #pragma link C++ class AliForwardFlowTaskQC::VertexBin+;
 #endif
 #pragma link C++ class AliForwardMCCorrectionsTask+;
index a2d9d827a67ab6e8d609207777dbcc21ca84a3dc..1c10170023317cb8748fba6f0bb49cbb33c96e33 100644 (file)
@@ -25,7 +25,9 @@ AliRsnCutSetDaughterParticle::AliRsnCutSetDaughterParticle() :
    fCutQuality(0x0),
    fAODTrkCutFilterBit(0),
    fCheckOnlyFilterBit(kTRUE),
-   fUseCustomQualityCuts(kFALSE)  
+   fUseCustomQualityCuts(kFALSE),
+   fIsUse2011stdQualityCuts(kFALSE),  
+   fIsUse2011stdQualityCutsHighPt(kFALSE)  
 {
    //
    // Default constructor
@@ -43,7 +45,9 @@ AliRsnCutSetDaughterParticle::AliRsnCutSetDaughterParticle(const char *name, Ali
    fCutQuality(new AliRsnCutTrackQuality("CutQuality")),
    fAODTrkCutFilterBit(AODfilterBit),
    fCheckOnlyFilterBit(kTRUE),
-   fUseCustomQualityCuts(kFALSE)
+   fUseCustomQualityCuts(kFALSE),
+   fIsUse2011stdQualityCuts(kFALSE),  
+   fIsUse2011stdQualityCutsHighPt(kFALSE)  
 {
    //
    // Constructor
@@ -74,7 +78,9 @@ AliRsnCutSetDaughterParticle::AliRsnCutSetDaughterParticle(const char *name, Ali
   fCutQuality(rsnTrackQualityCut),
   fAODTrkCutFilterBit(0),
   fCheckOnlyFilterBit(kFALSE),
-  fUseCustomQualityCuts(kTRUE)
+  fUseCustomQualityCuts(kFALSE),
+  fIsUse2011stdQualityCuts(kFALSE),  
+  fIsUse2011stdQualityCutsHighPt(kFALSE)  
 {
   //
   // Constructor: uses externally-defined track-quality cut object
@@ -119,7 +125,9 @@ AliRsnCutSetDaughterParticle::AliRsnCutSetDaughterParticle(const AliRsnCutSetDau
   fCutQuality(copy.fCutQuality),
   fAODTrkCutFilterBit(copy.fAODTrkCutFilterBit),
   fCheckOnlyFilterBit(copy.fCheckOnlyFilterBit),
-  fUseCustomQualityCuts(copy.fUseCustomQualityCuts)
+  fUseCustomQualityCuts(copy.fUseCustomQualityCuts),
+  fIsUse2011stdQualityCuts(copy.fIsUse2011stdQualityCuts),  
+  fIsUse2011stdQualityCutsHighPt(copy.fIsUse2011stdQualityCutsHighPt)  
 {
   //
   // copy constructor
@@ -143,6 +151,8 @@ AliRsnCutSetDaughterParticle &AliRsnCutSetDaughterParticle::operator=(const AliR
    fAODTrkCutFilterBit=copy.fAODTrkCutFilterBit;
    fCheckOnlyFilterBit=copy.fCheckOnlyFilterBit;
    fUseCustomQualityCuts=copy.fUseCustomQualityCuts;
+   fIsUse2011stdQualityCuts=copy.fIsUse2011stdQualityCuts;
+   fIsUse2011stdQualityCutsHighPt=copy.fIsUse2011stdQualityCutsHighPt; 
    fCutQuality=copy.fCutQuality;
    return (*this);
 }
@@ -186,7 +196,11 @@ void AliRsnCutSetDaughterParticle::Init()
          break;
 
       case AliRsnCutSetDaughterParticle::kQualityStd2011:
-         //fCutQuality->SetAODTestFilterBit(10);     //1024
+         AddCut(fCutQuality);
+         SetCutScheme(fCutQuality->GetName());
+         break;
+
+    case AliRsnCutSetDaughterParticle::kQualityStd2011HighPt:
          AddCut(fCutQuality);
          SetCutScheme(fCutQuality->GetName());
          break;
@@ -408,7 +422,7 @@ void AliRsnCutSetDaughterParticle::Init()
      break;
         
            
-   case AliRsnCutSetDaughterParticle::kTPCpidTOFvetoKStarPPB2011:
+   case AliRsnCutSetDaughterParticle::kTPCTOFtightPidKStarPPB2011:
      if (fNsigmaTPC <= 0.0) {
        AliWarning(Form("Invalid number of sigmas required for %s. Setting nSigma = 5.0",iCutTPCNSigma->GetName()));
        SetNsigmaForFastTPCpid(5.0);
@@ -441,10 +455,159 @@ void AliRsnCutSetDaughterParticle::Init()
      SetCutScheme( Form("%s&%s&%s",fCutQuality->GetName(), iCutTPCNSigma->GetName(),iCutTOFMatch->GetName()) );
      break;
 
-   default :
+    case AliRsnCutSetDaughterParticle::kTPCpidTOFveto4s:
+      if (fNsigmaTPC <= 0.0) {
+       AliWarning(Form("Invalid number of sigmas required for %s. Setting nSigma = 5.0",iCutTPCNSigma->GetName()));
+       SetNsigmaForFastTPCpid(5.0);
+      }
+      iCutTPCNSigma->SinglePIDRange(fNsigmaTPC);
+      AddCut(fCutQuality);
+      iCutTOFNSigma->SinglePIDRange(4.0);
+
+      AddCut(iCutTPCNSigma);
+      AddCut(iCutTOFMatch);
+      AddCut(iCutTOFNSigma);
+      
+      // scheme:
+      // quality & [ (TPCsigma & !TOFmatch) | (TPCsigma & TOFsigma) ]
+      SetCutScheme( Form("%s&((%s&(!%s))|(%s&%s))",fCutQuality->GetName(), iCutTPCNSigma->GetName(), iCutTOFMatch->GetName(),iCutTOFNSigma->GetName(), iCutTPCNSigma->GetName()) ) ;
+       break;
+
+    case AliRsnCutSetDaughterParticle::kTPCpidTOFveto3s:
+      if (fNsigmaTPC <= 0.0) {
+       AliWarning(Form("Invalid number of sigmas required for %s. Setting nSigma = 5.0",iCutTPCNSigma->GetName()));
+       SetNsigmaForFastTPCpid(5.0);
+      }
+      iCutTPCNSigma->SinglePIDRange(fNsigmaTPC);
+      AddCut(fCutQuality);
+      iCutTOFNSigma->SinglePIDRange(3.0);
+
+      AddCut(iCutTPCNSigma);
+      AddCut(iCutTOFMatch);
+      AddCut(iCutTOFNSigma);
+      
+      // scheme:
+      // quality & [ (TPCsigma & !TOFmatch) | (TPCsigma & TOFsigma) ]
+      SetCutScheme( Form("%s&((%s&(!%s))|(%s&%s))",fCutQuality->GetName(), iCutTPCNSigma->GetName(), iCutTOFMatch->GetName(),iCutTOFNSigma->GetName(), iCutTPCNSigma->GetName()) ) ;
+       break;     
+
+    case AliRsnCutSetDaughterParticle::kCombinedPidBestPtDep:
+      /* Set TPC  PID (if no TOF)*/
+      // all   below  500 MeV: 3sigma
+      // all above 500 MeV: 2sigma
+      iCutTPCNSigma->AddPIDRange(3.0, 0.0, 0.5);
+      iCutTPCNSigma->AddPIDRange(2.0, 0.5, 1E20);
+      
+      AddCut(fCutQuality);
+      AddCut(iCutTOFMatch);
+      AddCut(iCutTPCNSigma);
+      
+      /* set TPC+TOF PID*/
+      // pions if TOF match: TPC 5 sigma & TOF 3 sigma
+      // kaons if TOF match: 
+      //            below 1.5GeV/c: TPC 5 sigma & TOF 3 sigma
+      //            above 1.5GeV/c: TPC 3 sigma & TOF 3 sigma
+
+      if (fPID==AliPID::kPion){
+       iCutTPCTOFNSigma->SinglePIDRange(5.0);
+      }
+      
+      if (fPID==AliPID::kKaon){
+       iCutTPCTOFNSigma->AddPIDRange(5.0, 0.0, 1.5);
+       iCutTPCTOFNSigma->AddPIDRange(3.0, 1.5, 1E20);
+      }
+      iCutTOFNSigma->AddPIDRange(3.0, 0.0, 1E20);
+      AddCut(iCutTPCTOFNSigma);
+      AddCut(iCutTOFNSigma);
+        
+     // scheme:
+     // quality & [ (TOF & TPCTOF) || (!TOFmatch & TPConly) ]
+     SetCutScheme( Form("%s&((%s&%s)|((!%s)&%s))",fCutQuality->GetName(), iCutTPCTOFNSigma->GetName(), iCutTOFNSigma->GetName(), iCutTOFMatch->GetName(), iCutTPCNSigma->GetName()) ) ;
+     break;
+      
+    case AliRsnCutSetDaughterParticle::kTPCPidPtDep:
+      /* Set TPC  PID (if no TOF)*/
+      // all   below  500 MeV: 3sigma
+      // all above 500 MeV: 2sigma
+      iCutTPCNSigma->AddPIDRange(3.0, 0.0, 0.5);
+      iCutTPCNSigma->AddPIDRange(2.0, 0.5, 1E20);
+      
+      AddCut(fCutQuality);
+      AddCut(iCutTPCNSigma);
+      // scheme:
+     // quality & TPConly
+     SetCutScheme( Form("%s&%s",fCutQuality->GetName(), iCutTPCNSigma->GetName()) ) ;
      break;
-   }
 
+    case AliRsnCutSetDaughterParticle::kTOFPidPtDep:
+      /* Set TOF  PID */
+      // all   below  1500 MeV: 3sigma
+      // all above 1500 MeV: 2sigma
+      //TPC 5 sigma always to remove mismatch
+      iCutTPCTOFNSigma->SinglePIDRange(5.0);
+      iCutTOFNSigma->AddPIDRange(3.0, 0.0, 1.5);
+      iCutTOFNSigma->AddPIDRange(2.0, 1.5, 1E20);
+      
+      AddCut(fCutQuality);
+      AddCut(iCutTPCTOFNSigma);
+      AddCut(iCutTOFNSigma);
+      // scheme:
+      // quality & TPConly
+      SetCutScheme( Form("%s&%s&%s", fCutQuality->GetName(), iCutTPCTOFNSigma->GetName(), iCutTOFNSigma->GetName()) ) ;
+      break;
+
+    case AliRsnCutSetDaughterParticle::kTPCRejPtDepTOFNsigma:
+      /* Set TOF  PID */
+      // TPC mismatch rejection:
+      //             below  1.500 GeV: 5sigma
+      //             above  1.500 GeV: 3sigma
+      // TOF nsigma PID in full pT
+      iCutTPCTOFNSigma->AddPIDRange(5.0, 0.0, 1.5);
+      iCutTPCTOFNSigma->AddPIDRange(3.0, 1.5, 1E20);
+      
+      if (fNsigmaTOF <= 0.0) {
+       AliWarning(Form("Invalid number of sigmas required for %s. Setting default nSigma = 10",iCutTOFNSigma->GetName()));
+       SetNsigmaForFastTOFpid(10.0);
+      }
+      iCutTOFNSigma->SinglePIDRange(fNsigmaTOF);
+      
+      AddCut(fCutQuality);
+      AddCut(iCutTPCTOFNSigma);
+      AddCut(iCutTOFNSigma);
+      // scheme:
+      // quality & TPConly
+      SetCutScheme( Form("%s&%s&%s", fCutQuality->GetName(), iCutTPCTOFNSigma->GetName(), iCutTOFNSigma->GetName()) ) ;
+      break;
+      
+    case AliRsnCutSetDaughterParticle::kTPCNsigmaTOFVetoPtDep:
+      /* Set TPC  PID */
+      // TOF veto:
+      //             below  1.500 GeV: 5sigma
+      //             above  1.500 GeV: 3sigma
+      // TPC nsigma PID in full pT
+      if (fNsigmaTPC <= 0.0) {
+       AliWarning(Form("Invalid number of sigmas required for %s. Setting default nSigma = 10",iCutTPCNSigma->GetName()));
+       SetNsigmaForFastTPCpid(10.0);
+      }
+      iCutTPCNSigma->SinglePIDRange(fNsigmaTPC);
+      
+      iCutTOFNSigma->AddPIDRange(3.0, 0.0, 1.5);
+      iCutTOFNSigma->AddPIDRange(4.0, 1.5, 1E20);
+      
+      AddCut(fCutQuality);
+      AddCut(iCutTPCNSigma);
+      AddCut(iCutTOFMatch);
+      AddCut(iCutTOFNSigma);
+      
+      // scheme:
+      // quality & [ (TPCsigma & !TOFmatch) | (TPCsigma & TOFsigma) ]
+      SetCutScheme( Form("%s&((%s&(!%s))|(%s&%s))",fCutQuality->GetName(), iCutTPCNSigma->GetName(), iCutTOFMatch->GetName(),iCutTOFNSigma->GetName(), iCutTPCNSigma->GetName()) ) ;
+      break;
+      
+    default :
+      break;
+    }
+  
 }
 
 
@@ -462,30 +625,45 @@ void AliRsnCutSetDaughterParticle::InitStdQualityCuts()
   // initialize quality std (if not externally defined) and PID cuts
   // init cut sets by setting variable params
   // 
-  Bool_t isUse2011stdQualityCuts = ((fAppliedCutSetID==AliRsnCutSetDaughterParticle::kQualityStd2011) ||
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTOFMatchPPB2011) || //pA analysis
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidKstarPPB2011) ||
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTOFpidKstarPPB2011) ||
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCTOFpidKstarPPB2011) ||
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidTOFvetoKStarPPB2011) ||
-                                   (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidMatchPPB2011));
-  if (isUse2011stdQualityCuts) {
-    fCutQuality->SetDefaults2011();//uses filter bit 10 as default
-    fCutQuality->SetAODTestFilterBit(fAODTrkCutFilterBit); //changes default filter bit 10 to the chosen filter bit
+  // Bool_t isUse2011stdQualityCutsHighPt = ((fAppliedCutSetID==AliRsnCutSetDaughterParticle::kQualityStd2011HighPt) ||
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTOFMatchPPB2011) || //pA analysis
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidKstarPPB2011) ||
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTOFpidKstarPPB2011) ||
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCTOFpidKstarPPB2011) ||
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidTOFvetoKStarPPB2011) ||
+  //                                     (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kTPCpidMatchPPB2011));
+  
+  // Bool_t isUse2011stdQualityCuts = (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kQualityStd2011);
+
+  if (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kQualityStd2011) {
+    fIsUse2011stdQualityCuts = kTRUE;
+    fIsUse2011stdQualityCutsHighPt = kFALSE;
+  }
+  if (fAppliedCutSetID==AliRsnCutSetDaughterParticle::kQualityStd2011HighPt) {
+    fIsUse2011stdQualityCuts = kFALSE;
+    fIsUse2011stdQualityCutsHighPt = kTRUE;
+  }
+
+  if (fIsUse2011stdQualityCuts) {
+    fCutQuality->SetDefaults2011();//uses filter bit 5 as default
   } else {
-    fCutQuality->SetDefaults2010();
-    fCutQuality->SetDCARPtFormula("0.0182+0.0350/pt^1.01");
-    fCutQuality->SetDCAZmax(2.0);
-    fCutQuality->SetSPDminNClusters(1);
-    fCutQuality->SetITSminNClusters(0);
-    fCutQuality->SetITSmaxChi2(36);
-    fCutQuality->SetTPCminNClusters(70);
-    fCutQuality->SetTPCmaxChi2(4.0);
-    fCutQuality->SetRejectKinkDaughters();
-    fCutQuality->SetAODTestFilterBit(fAODTrkCutFilterBit);
-    //fCutQuality->SetITSmaxChi2(36);
-    //fCutQuality->SetMaxChi2TPCConstrainedGlobal(36);
+    if (fIsUse2011stdQualityCutsHighPt) {
+      fCutQuality->SetDefaultsHighPt2011();//uses filter bit 5 as default
+    } else {
+      fCutQuality->SetDefaults2010();
+      fCutQuality->SetDCARPtFormula("0.0182+0.0350/pt^1.01");
+      fCutQuality->SetDCAZmax(2.0);
+      fCutQuality->SetSPDminNClusters(1);
+      fCutQuality->SetITSminNClusters(0);
+      fCutQuality->SetITSmaxChi2(36);
+      fCutQuality->SetTPCminNClusters(70);
+      fCutQuality->SetTPCmaxChi2(4.0);
+      fCutQuality->SetRejectKinkDaughters();
+      //fCutQuality->SetITSmaxChi2(36);
+      //fCutQuality->SetMaxChi2TPCConstrainedGlobal(36);
+    }
   }
+  fCutQuality->SetAODTestFilterBit(fAODTrkCutFilterBit); //changes default filter bit to the chosen filter bit
   
   //apply pt and eta cuts
   fCutQuality->SetPtRange(fPtRange[0], fPtRange[1]);
index e457f7015dfdb7f4287c888496b06f0e391789e7..148f2eda3f6e28750cd071ff8acf7c70dc353e65 100644 (file)
@@ -25,7 +25,8 @@ public:
   enum ERsnDaughterCutSet {
     kNoCuts,
     kQualityStd2010,//quality only
-    kQualityStd2011,    
+    kQualityStd2011,
+    kQualityStd2011HighPt,    
     kTOFMatch,  
     kFastTPCpidNsigma, //PbPb analysis
     kFastTOFpidNsigma,
@@ -43,8 +44,15 @@ public:
     kTPCpidKstarPPB2011,
     kTOFpidKstarPPB2011,
     kTPCTOFpidKstarPPB2011,
-    kTPCpidTOFvetoKStarPPB2011, //TPC pid with TOF veto
+    kTPCTOFtightPidKStarPPB2011, //TPC 2.0 (3.0) sigma pid & TOF at 3.0 (5.0) sigma 
     kTPCpidMatchPPB2011, //Match with nsigma = fNsigmaTPC
+    kTPCpidTOFveto4s, //TPC n sigma + 4.0 sigma TOF veto
+    kTPCpidTOFveto3s, //TPC n sigma + 3.0 sigma TOF veto
+    kCombinedPidBestPtDep, 
+    kTPCPidPtDep,
+    kTOFPidPtDep,
+    kTPCRejPtDepTOFNsigma,
+    kTPCNsigmaTOFVetoPtDep,
     kNDaughterCuts
   };
 
@@ -86,7 +94,8 @@ public:
    void           EnableCustomCuts(Bool_t useCustom=kFALSE) {fUseCustomQualityCuts=useCustom; return;}
    void           SetPtRange(Double_t a, Double_t b)        {fPtRange[0] = TMath::Min(a, b); fPtRange[1] = TMath::Max(a, b); return;}
    void           SetEtaRange(Double_t a, Double_t b)       {fEtaRange[0] = TMath::Min(a, b); fEtaRange[1] = TMath::Max(a, b); return;}
-
+   void           SetUse2011StdQualityCuts(Bool_t use2011=kFALSE) {fIsUse2011stdQualityCuts=use2011; return;}
+   void           SetUse2011StdQualityCutsHighPt(Bool_t use2011HighPt=kFALSE) {fIsUse2011stdQualityCutsHighPt=use2011HighPt; return;}
    //getters
    const char   *GetAppliedDaughterCutSetName() { return GetName();}
    Int_t         GetAppliedDaughterCutSetId() { return fAppliedCutSetID;}
@@ -105,8 +114,10 @@ public:
    Bool_t                fUseCustomQualityCuts; //flag to enable the usage of custom quality cuts
    Float_t               fPtRange[2]; //single track pt range (min, max)
    Float_t               fEtaRange[2]; //single track eta range (min, max)
-
-   ClassDef(AliRsnCutSetDaughterParticle, 4) // cut definitions for K*
+   Bool_t                fIsUse2011stdQualityCuts;//flag to enalble std quality cuts 2011 
+   Bool_t                fIsUse2011stdQualityCutsHighPt;//flag to enalble std quality cuts 2011 
+   ClassDef(AliRsnCutSetDaughterParticle, 5) // cut definitions for K*
 
 };
 
index c324d43c89d6a90bc7760dae5a179d3b557546d2..2b71792d2b5529ee1b662f13dcf6328d0318d36e 100644 (file)
@@ -58,7 +58,6 @@ AliRsnCutTrackQuality::AliRsnCutTrackQuality(const char *name) :
 // Default constructor.
 // Initializes all cuts in such a way that all of them are disabled.
 //
-
    SetPtRange(0.0, 1E20);
    SetEtaRange(-1E20, 1E20);
 }
@@ -261,13 +260,18 @@ Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
    cuts.SetRequireSigmaToVertex(kFALSE);
 
    // TPC related cuts for TPC+ITS tracks
-   cuts.SetMinNClustersTPC(fTPCminNClusters);
+   if (fIsUseCrossedRowsCut) {
+     cuts.SetMinNCrossedRowsTPC(fTPCminNCrossedRows);
+     cuts.SetMinRatioCrossedRowsOverFindableClustersTPC(fTPCminCrossedRowsOverFindableCls);
+   } else {
+     cuts.SetMinNClustersTPC(fTPCminNClusters);
+   }
    cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
    cuts.SetAcceptKinkDaughters(!fRejectKinkDaughters);
    cuts.SetMaxChi2TPCConstrainedGlobal(fCutMaxChi2TPCConstrainedVsGlobal);
-   cuts.SetMinNCrossedRowsTPC(fTPCminNCrossedRows);
-   cuts.SetMinRatioCrossedRowsOverFindableClustersTPC(fTPCminCrossedRowsOverFindableCls);
-   cuts.SetMinLengthActiveVolumeTPC(fCutMinLengthActiveVolumeTPC);
+
+   if (fIsUseLengthActiveVolumeTPCCut)
+     cuts.SetMinLengthActiveVolumeTPC(fCutMinLengthActiveVolumeTPC);
 
    // ITS related cuts for TPC+ITS tracks
    if (fSPDminNClusters > 0)
@@ -319,10 +323,11 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
 
 
    //step #1: check number of clusters 
-   if (track->GetTPCNcls() < fTPCminNClusters) {
+   if ((!fIsUseCrossedRowsCut) && (track->GetTPCNcls() < fTPCminNClusters)) {
       AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
       return kFALSE;
    }
    if (track->GetITSNcls() < fITSminNClusters) {
       AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
       return kFALSE;
@@ -339,23 +344,26 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
    }
 
    //step #2a: check number of crossed rows in TPC
-   Float_t nCrossedRowsTPC = track->GetTPCNCrossedRows();
-   if (nCrossedRowsTPC < fTPCminNCrossedRows) {
-     AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows. Rejected");
-     return kFALSE;
-   }
-   if (track->GetTPCNclsF()>0) {
-     Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC / track->GetTPCNclsF();
-     if (ratioCrossedRowsOverFindableClustersTPC < fTPCminCrossedRowsOverFindableCls){
-       AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows/findable clusters. Rejected");
+   if (fIsUseCrossedRowsCut) {
+     Float_t nCrossedRowsTPC = track->GetTPCNCrossedRows();
+     if (nCrossedRowsTPC < fTPCminNCrossedRows) {
+       AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows. Rejected");
+       return kFALSE;
+     }
+     if (track->GetTPCNclsF()>0) {
+       Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC / track->GetTPCNclsF();
+       if (ratioCrossedRowsOverFindableClustersTPC < fTPCminCrossedRowsOverFindableCls){
+        AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows/findable clusters. Rejected");
+        return kFALSE;
+       }
+     } else {
+       AliDebug(AliLog::kDebug + 2, "Negative value for TPC crossed rows/findable clusters. Rejected");
        return kFALSE;
      }
-   } else {
-     AliDebug(AliLog::kDebug + 2, "Negative value for TPC crossed rows/findable clusters. Rejected");
-     return kFALSE;
    }
    //step #2b: check on track length in active volume of TPC implemented only for ESD tracks
-     
+   //if (fIsUseLengthActiveVolumeTPCCut) { // not yet implemented in AODs}
    //step #3: reject kink daughters
    AliAODVertex *vertex = track->GetProdVertex();
    if (vertex && fRejectKinkDaughters) {
@@ -480,26 +488,40 @@ void AliRsnCutTrackQuality::SetDefaults2010()
 }
 
 //__________________________________________________________________________________________________
-void AliRsnCutTrackQuality::SetDefaults2011()
+void AliRsnCutTrackQuality::SetDefaultsHighPt2011(Bool_t useTPCCrossedRows)
 {
 //
 // Default settings for cuts used in 2011 (for high-pT)
 //
-   fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE,1);
+   fIsUseCrossedRowsCut=useTPCCrossedRows;
+   fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, useTPCCrossedRows);
    fESDtrackCuts->SetMinNCrossedRowsTPC(120); //default is min 70 crossed rows -> use 120 to go to higher pt
-   fESDtrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
-   fESDtrackCuts->SetMaxChi2PerClusterITS(36);
    fESDtrackCuts->SetMaxFractionSharedTPCClusters(0.4);//default is not set --> use to go to higher pt
-   fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
-   AddStatusFlag(AliESDtrack::kTPCin   , kTRUE);
-   AddStatusFlag(AliESDtrack::kTPCrefit, kTRUE);
-   AddStatusFlag(AliESDtrack::kITSrefit, kTRUE);
+   //fESDtrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);//already in 2011 std
+   //fESDtrackCuts->SetMaxChi2PerClusterITS(36);//already in 2011 std
+   //fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(36);//already in 2011 std
+   // AddStatusFlag(AliESDtrack::kTPCin   , kTRUE); //already in 2011 std
+   // AddStatusFlag(AliESDtrack::kTPCrefit, kTRUE);//already in 2011 std
+   // AddStatusFlag(AliESDtrack::kITSrefit, kTRUE);//already in 2011 std
    SetPtRange(0.15, 1E+20);
    SetEtaRange(-0.8, 0.8);
    SetAODTestFilterBit(10);
+   return;
 }
 
+//__________________________________________________________________________________________________
+void AliRsnCutTrackQuality::SetDefaults2011(Bool_t useTPCCrossedRows)
+{
+//
+// Default std cuts 2011 with crossed rows (=70)
+//
+  fIsUseCrossedRowsCut=useTPCCrossedRows;
+  fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE,useTPCCrossedRows);
+  SetPtRange(0.15, 1E+20);
+  SetEtaRange(-0.8, 0.8);
+  SetAODTestFilterBit(5);
+  return;
+}
 //__________________________________________________________________________________________________
 const char *AliRsnCutTrackQuality::Binary(UInt_t number)
 {
index 96739bb973845e2502db91567e07f9eda0bf7dec..cb27bd1901d05899e889da5a2bd387615e092ec4 100644 (file)
@@ -48,16 +48,17 @@ public:
    void      SetTPCminNClusters(Int_t value)           {fTPCminNClusters = value;}
    void      SetTPCmaxChi2(Double_t value)             {fTPCmaxChi2 = value;}
    void      SetMaxChi2TPCConstrainedGlobal(Float_t max) {fCutMaxChi2TPCConstrainedVsGlobal = max; }
-   void      SetMinNCrossedRowsTPC(Double_t min)       {fTPCminNCrossedRows=min;}
-   void      SetMinNCrossedRowsOverFindableClsTPC(Double_t min) {fTPCminCrossedRowsOverFindableCls=min;}
-   void      SetMinLengthActiveVolumeTPC(Double_t min) {fCutMinLengthActiveVolumeTPC=min;}
+   void      SetMinNCrossedRowsTPC(Double_t min, Bool_t useTPCCrossedRows) {fTPCminNCrossedRows=min; fIsUseCrossedRowsCut=useTPCCrossedRows;}
+   void      SetMinNCrossedRowsOverFindableClsTPC(Double_t min, Bool_t useTPCCrossedRows) {fTPCminCrossedRowsOverFindableCls=min; fIsUseCrossedRowsCut=useTPCCrossedRows;}
+   void      SetMinLengthActiveVolumeTPC(Double_t min, Bool_t on = kFALSE) {fCutMinLengthActiveVolumeTPC=min; fIsUseLengthActiveVolumeTPCCut=on;}
    void      SetRejectKinkDaughters(Bool_t yn = kTRUE) {fRejectKinkDaughters = yn;}
 
    void      SetAODTestFilterBit(Int_t value)          {fAODTestFilterBit = value;}
    void      SetCheckOnlyFilterBit(Bool_t on=kTRUE)    {fCheckOnlyFilterBit=on;}
-
    void      SetDefaults2010();
-   void      SetDefaults2011();
+   void      SetDefaults2011(Bool_t useTPCCrossedRows = kTRUE);
+   void      SetDefaultsHighPt2011(Bool_t useTPCCrossedRows = kTRUE);
    void      SetESDtrackCuts(AliESDtrackCuts *esdTrackCuts) {fESDtrackCuts = esdTrackCuts;}
    AliESDtrackCuts  *GetESDtrackCuts() {return fESDtrackCuts;}
    Double_t   GetPtRange(Bool_t max) {return fPt[max];}
@@ -94,8 +95,10 @@ protected:
    Double_t   fTPCmaxChi2;             // maximum chi2 / number of clusters in TPC
    Float_t    fCutMaxChi2TPCConstrainedVsGlobal;  // max chi2 TPC track constrained with vtx vs. global track
    
+   Bool_t     fIsUseCrossedRowsCut;     //enable cut on minimum number of TPC crossed rows
    Float_t    fTPCminNCrossedRows;     // minimum number of TPC crossed rows
    Float_t    fTPCminCrossedRowsOverFindableCls;     // minimum number of crossed rows/findable clusters
+   Bool_t     fIsUseLengthActiveVolumeTPCCut;     //enable cut on minimum track lenght in TPC active volume
    Float_t    fCutMinLengthActiveVolumeTPC; // mininum length (in cm) over which the track is sampled in the active volume of the TPC (outside boundaries)
 
    Int_t      fAODTestFilterBit;       // test filter bit for AOD tracks
index 2f4a8935a425995224d5bc6777c7cb96a26aa161..322cdf2401f640b6991c7b7cd5b7c45e2dd1f157 100644 (file)
-#ifndef __CINT__
-#include <AliRsnCutTrackQuality.h>
-#endif
-Int_t AddRsnDaughterCutsPhiNsigma(AliPID::EParticleType type1,AliPID::EParticleType type2,TString opt,AliRsnInputHandler *rsnIH=0,AliAnalysisTaskSE *task=0)
-{
-
-  if (!rsnIH) return 0;
-  
-  Bool_t valid = kTRUE;
-  //   Int_t collisionType = AliRsnTrainManager::GetGlobalInt("IsCollisionType",valid);
-  Int_t useCommonQualityCut = AliRsnTrainManager::GetGlobalInt("RsnCommonQualityCut",valid);
-  TString rsnQualityCut = AliRsnTrainManager::GetGlobalStr("RsnQualityCut",valid);
-  Int_t isMC = AliRsnTrainManager::GetGlobalInt("IsMC",valid);
-  Int_t isRsnMini = AliRsnTrainManager::GetGlobalInt("IsRsnMini",valid);
-  Int_t isMixing = AliRsnTrainManager::GetGlobalInt("IsMixing",valid);
-
-  // experts only (don't touch)
-  Int_t isRsnDev = AliAnalysisManager::GetGlobalInt("rsnUseRSNParDev",valid);
-
-  // === USER HAS TO SET CORRECT NUMBER OF CUTS SETS =====
-  Int_t numberOfCuts = 1;
-
-  //---------------------------------------------
-  //  Define single cuts
-  //---------------------------------------------
-
-  Printf("AliRsnCutPIDNSigma Option : %s",opt.Data());
-
-  Double_t nSigmaTPC=3.0;
-  Double_t nSigmaTOF=3.0;
-  Double_t etaMin=-0.8;
-  Double_t etaMax=0.8;
-  Double_t trackPtMin=0.;
-  Double_t trackPtMax=1.e10;
-  Int_t NclTPC=70;
-  Char_t DCAxyFormula[100]="0.0182+0.035/pt^1.01";
-
-  Bool_t useTPC_K=kFALSE;
-  Bool_t useTOF_K=kFALSE;
-  Bool_t useTrackPtCut=kFALSE;
-
-  if (opt.Contains("qualityonly")) {
-    useTPC_K=kFALSE;
-    useTOF_K=kFALSE;
-  } else if (!opt.Contains("nsig")) {
-    useTPC_K=kTRUE;
-    useTOF_K=kTRUE;
-  }
-
-  if (opt.Contains("KTPCnsig"))  useTPC_K=kTRUE;
-  if (opt.Contains("KTOFnsig"))  useTOF_K=kTRUE;
-
-  if (opt.Contains("KTPCnsig05")) nSigmaTPC = 0.5;
-  if (opt.Contains("KTPCnsig08")) nSigmaTPC = 0.8;
-  if (opt.Contains("KTPCnsig10")) nSigmaTPC = 1.0;
-  if (opt.Contains("KTPCnsig15")) nSigmaTPC = 1.5;
-  if (opt.Contains("KTPCnsig20")) nSigmaTPC = 2.0;
-  if (opt.Contains("KTPCnsig25")) nSigmaTPC = 2.5;
-  if (opt.Contains("KTPCnsig30")) nSigmaTPC = 3.0;
-  if (opt.Contains("KTPCnsig40")) nSigmaTPC = 4.0;
-  if (opt.Contains("KTPCnsig50")) nSigmaTPC = 5.0;
-  if (opt.Contains("KTPCnsig1000")) nSigmaTPC = 100.0;
-
-  if (opt.Contains("KTOFnsig10")) nSigmaTOF = 1.0;
-  if (opt.Contains("KTOFnsig15")) nSigmaTOF = 1.5;
-  if (opt.Contains("KTOFnsig20")) nSigmaTOF = 2.0;
-  if (opt.Contains("KTOFnsig25")) nSigmaTOF = 2.5;
-  if (opt.Contains("KTOFnsig30")) nSigmaTOF = 3.0;
-  if (opt.Contains("KTOFnsig1000")) nSigmaTOF = 100.0;
-
-  if (opt.Contains("trackPt")) {
-    useTrackPtCut = kTRUE;
-    if (opt.Contains("trackPtMin015")) trackPtMin = 0.15;
-    if (opt.Contains("trackPtMin02")) trackPtMin = 0.2;
-    if (opt.Contains("trackPtMin05")) trackPtMin = 0.5;
-    if (opt.Contains("trackPtMin06")) trackPtMin = 0.6;
-
-    if (opt.Contains("trackPtMax18")) trackPtMax = 1.8;
-    if (opt.Contains("trackPtMax20")) trackPtMax = 2.0;
-    if (opt.Contains("trackPtMax25")) trackPtMax = 2.5;
-  }
-
-  Bool_t usePDG=kFALSE;
-  if (opt.Contains("pdg")) {
-    Printf("Using PDG");
-    usePDG = kTRUE;
-  }
-
-  Bool_t useEta = kFALSE;
-  if (opt.Contains("eta")) {
-    for(int j=1;j<=9;j++) if(opt.Contains(Form("eta0%i",j))){etaMin=-0.1*j; etaMax=0.1*j;}
-
-    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMinMinus0%i",j))) etaMin=-0.1*j;
-    if(opt.Contains("etaMin00")) etaMin=0.;
-    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMinPlus0%i",j))) etaMin=0.1*j;
-
-    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMaxMinus0%i",j))) etaMax=-0.1*j;
-    if(opt.Contains("etaMax00")) etaMax=0.;
-    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMaxPlus0%i",j))) etaMax=0.1*j;
-
-    Printf("Using ETA range (%.2f,%.2f)",etaMin,etaMax);
-    useEta = kTRUE;
-  }
-
-  Bool_t useNclTPC = kFALSE;
-  if (opt.Contains("NclTPC")) {
-    if (opt.Contains("NclTPC70")) NclTPC=70;
-    if (opt.Contains("NclTPC75")) NclTPC=75;
-    if (opt.Contains("NclTPC80")) NclTPC=80;
-    if (opt.Contains("NclTPC85")) NclTPC=85;
-    if (opt.Contains("NclTPC90")) NclTPC=90;
-    useNclTPC = kTRUE;
-  }
-
-  Bool_t useDCAxy = kFALSE;
-  if (opt.Contains("DCAxy")) {
-    if (opt.Contains("DCAxyFormula7s")) sprintf(DCAxyFormula,"0.0182+0.035/pt^1.01");
-    if (opt.Contains("DCAxyFormula6s")) sprintf(DCAxyFormula,"0.0156+0.03/pt^1.01");
-    if (opt.Contains("DCAxyFormula5s")) sprintf(DCAxyFormula,"0.013+0.025/pt^1.01");
-    useDCAxy = kTRUE;
-  }
-
-  //---------------------------------------------
-  //  Combine cuts
-  //---------------------------------------------
-
-  TString cutname = "K_Phi";
-  if (!opt.IsNull()) cutname += Form("_%s",opt.Data());
-  AliRsnCutSet *cuts = new AliRsnCutSet(cutname.Data(), AliRsnTarget::kDaughter);
-
-  TString scheme="";
-  AliRsnCutTrackQuality *qualityCut = new AliRsnCutTrackQuality("cutQualityK");
-  if (!rsnQualityCut.IsNull()) {
-    AliESDtrackCuts *esdTK = RsnQualityCut(rsnQualityCut.Data());
-    if(useDCAxy) esdTK->SetMaxDCAToVertexXYPtDep(DCAxyFormula);
-    qualityCut->SetESDtrackCuts(esdTK);
-  } else {
-    if (useCommonQualityCut>=0) {
-      qualityCut->SetAODTestFilterBit(useCommonQualityCut);
-      if(useDCAxy) {qualityCut->SetCheckOnlyFilterBit(kFALSE); qualityCut->SetDCARPtFormula(DCAxyFormula);}
-    } else {
-      qualityCut->SetDefaults2010();
-      if(useDCAxy) qualityCut->SetDCARPtFormula(DCAxyFormula);
-    }
-  }
-
-  cuts->AddCut(qualityCut);
-  if (!scheme.IsNull()) scheme += "&";
-  scheme += qualityCut->GetName();
-
-
-  if (useTPC_K) {
-    AliRsnCutPIDNSigma *cutKTPC = new AliRsnCutPIDNSigma("cutPIDNSigmaTPCK",AliPID::kKaon,AliRsnCutPIDNSigma::kTPC);
-    cutKTPC->SinglePIDRange(nSigmaTPC);
-    cuts->AddCut(cutKTPC);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutKTPC->GetName();
-  }
-
-  if (useTOF_K) {
-    AliRsnCutPIDNSigma *cutKTOF = new AliRsnCutPIDNSigma("cutPIDNSigmaTOFK",AliPID::kKaon,AliRsnCutPIDNSigma::kTOF);
-    cutKTOF->SinglePIDRange(nSigmaTOF);
-    cuts->AddCut(cutKTOF);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutKTOF->GetName();
-  }
-
-  if (useEta) {
-    Printf("Adding ETA ...");
-    AliRsnValueDaughter *valEta = new AliRsnValueDaughter(Form("val%sETA%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kEta);
-    AliRsnCutValue *cutEta = new AliRsnCutValue(Form("cut%sETA%s",AliPID::ParticleName(type1),opt.Data()),etaMin,etaMax);
-    cutEta->SetTargetType(AliRsnTarget::kDaughter);
-    cutEta->SetValueObj(valEta);
-    cuts->AddCut(cutEta);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutEta->GetName();
-  }
-
-  if (useTrackPtCut) {
-    Printf("Adding Pt min=%.3f max=%.3f ...",trackPtMin,trackPtMax);
-    AliRsnValueDaughter *valTrackPt = new AliRsnValueDaughter(Form("val%sTrackPt%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kPt);
-
-    AliRsnCutValue *cutTrackPt = new AliRsnCutValue(Form("cut%sTrackPt%s",AliPID::ParticleName(type1),opt.Data()),trackPtMin,trackPtMax);
-    cutTrackPt->SetTargetType(AliRsnTarget::kDaughter);
-    cutTrackPt->SetValueObj(valTrackPt);
-    cuts->AddCut(cutTrackPt);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutTrackPt->GetName();
-  }
-
-  if (useNclTPC) {
-    Printf("Adding NclTPC >= %i",NclTPC);
-    AliRsnValueDaughter *valNclTPC = new AliRsnValueDaughter(Form("val%sNclTPC%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kNTPCclusters);
-    AliRsnCutValue *cutNclTPC = new AliRsnCutValue(Form("cut%sNclTPC%s",AliPID::ParticleName(type1),opt.Data()),NclTPC-0.1,1000.);
-    cutNclTPC->SetTargetType(AliRsnTarget::kDaughter);
-    cutNclTPC->SetValueObj(valNclTPC);
-    cuts->AddCut(cutNclTPC);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutNclTPC->GetName();
-  }
-
-  if (usePDG) {
-    Printf("Adding PDG ...");
-    AliRsnCutPID *cutPDG = new AliRsnCutPID(Form("cut%sPDG%s",AliPID::ParticleName(type1),opt.Data()),type1,0.0,kTRUE);
-    cuts->AddCut(cutPDG);
-    if (!scheme.IsNull()) scheme += "&";
-    scheme += cutPDG->GetName();
-  }
-
-  Printf ("CUT Scheme is '%s'",scheme.Data());
-  cuts->SetCutScheme(scheme.Data());
-
-  if (opt.Contains("mon")) {
-    AddMonitorOutput(cuts->GetMonitorOutput(),opt);
-  }
-  if (isRsnMini) {
-    AliRsnMiniAnalysisTask *taskRsnMini = (AliRsnMiniAnalysisTask *)task;
-    if (taskRsnMini) {
-      taskRsnMini->AddTrackCuts(cuts);
-    }
-  } else {
-    AliRsnDaughterSelector *sel = rsnIH->GetSelector();
-    //       sel->SetLabelCheck(kFALSE);
-    sel->Add(cuts, kTRUE);
-    if (isRsnDev>=0 && opt.Contains("pairPID")) {
-      AliRsnActPostDaughterSelection *pairPID = new AliRsnActPostDaughterSelection();
-      pairPID->SetID(0);
-
-      const char *fn="rsnRange.txt";
-      if (!gSystem->AccessPathName(fn)) {
-       TString minStr = gSystem->GetFromPipe(TString::Format("head -n 1 %s").Data());
-       TString maxStr = gSystem->GetFromPipe(TString::Format("tail -n 1 %s").Data());
-       pairPID->SetMass(minStr.Atof(),maxStr.Atof());
-      } else {
-       //       pairPID->SetMass(1.01,1.03);
-       pairPID->SetMass(1.015,1.025);
-       pairPID->SetMass(1.019,1.021);
-       pairPID->SetMass(1.0195,1.0205);
-       pairPID->SetMass(1.1000,1.1005);
-       //       pairPID->SetMass(1.1005,1.1010);
-      }
-      sel->AddAction(pairPID);
-    }
-
-  }
-  return numberOfCuts;
-
-}
+#ifndef __CINT__\r
+#include <AliRsnCutTrackQuality.h>\r
+#endif\r
+Int_t AddRsnDaughterCutsPhiNsigma(AliPID::EParticleType type1,AliPID::EParticleType type2,TString opt,AliRsnInputHandler *rsnIH=0,AliAnalysisTaskSE *task=0)\r
+{\r
+\r
+  if (!rsnIH) return 0;\r
+  \r
+  Bool_t valid = kTRUE;\r
+  //   Int_t collisionType = AliRsnTrainManager::GetGlobalInt("IsCollisionType",valid);\r
+  Int_t useCommonQualityCut = AliRsnTrainManager::GetGlobalInt("RsnCommonQualityCut",valid);\r
+  TString rsnQualityCut = AliRsnTrainManager::GetGlobalStr("RsnQualityCut",valid);\r
+  Int_t isMC = AliRsnTrainManager::GetGlobalInt("IsMC",valid);\r
+  Int_t isRsnMini = AliRsnTrainManager::GetGlobalInt("IsRsnMini",valid);\r
+  Int_t isMixing = AliRsnTrainManager::GetGlobalInt("IsMixing",valid);\r
+\r
+  // experts only (don't touch)\r
+  Int_t isRsnDev = AliAnalysisManager::GetGlobalInt("rsnUseRSNParDev",valid);\r
+\r
+  // === USER HAS TO SET CORRECT NUMBER OF CUTS SETS =====\r
+  Int_t numberOfCuts = 1;\r
+\r
+  //---------------------------------------------\r
+  //  Define single cuts\r
+  //---------------------------------------------\r
+\r
+  Printf("AliRsnCutPIDNSigma Option : %s",opt.Data());\r
+\r
+  Double_t nSigmaTPC=3.0;\r
+  Double_t nSigmaTOF=3.0;\r
+  Double_t etaMin=-0.8;\r
+  Double_t etaMax=0.8;\r
+  Double_t trackPtMin=0.;\r
+  Double_t trackPtMax=1.e10;\r
+  Int_t NclTPC=70;\r
+  Char_t DCAxyFormula[100]="0.0182+0.035/pt^1.01";\r
+\r
+  Bool_t useTPC_K=kFALSE;\r
+  Bool_t useTOF_K=kFALSE;\r
+  Bool_t rejectUnmatchedTOF_K=kTRUE;\r
+  Bool_t useTrackPtCut=kFALSE;\r
+\r
+  if (opt.Contains("qualityonly")) {\r
+    useTPC_K=kFALSE;\r
+    useTOF_K=kFALSE;\r
+  }\r
+\r
+  if (opt.Contains("KTPCnsig"))  useTPC_K=kTRUE;\r
+  if (opt.Contains("KTOFnsig"))  useTOF_K=kTRUE;\r
+  if (opt.Contanns("KTOFacceptUnmatched")) rejectUnmatchedTOF_K=kFALSE;\r
+\r
+  if (opt.Contains("KTPCnsig05")) nSigmaTPC = 0.5;\r
+  if (opt.Contains("KTPCnsig08")) nSigmaTPC = 0.8;\r
+  if (opt.Contains("KTPCnsig10")) nSigmaTPC = 1.0;\r
+  if (opt.Contains("KTPCnsig15")) nSigmaTPC = 1.5;\r
+  if (opt.Contains("KTPCnsig20")) nSigmaTPC = 2.0;\r
+  if (opt.Contains("KTPCnsig25")) nSigmaTPC = 2.5;\r
+  if (opt.Contains("KTPCnsig30")) nSigmaTPC = 3.0;\r
+  if (opt.Contains("KTPCnsig40")) nSigmaTPC = 4.0;\r
+  if (opt.Contains("KTPCnsig50")) nSigmaTPC = 5.0;\r
+  if (opt.Contains("KTPCnsig1000")) nSigmaTPC = 100.0;\r
+\r
+  if (opt.Contains("KTOFnsig10")) nSigmaTOF = 1.0;\r
+  if (opt.Contains("KTOFnsig15")) nSigmaTOF = 1.5;\r
+  if (opt.Contains("KTOFnsig20")) nSigmaTOF = 2.0;\r
+  if (opt.Contains("KTOFnsig25")) nSigmaTOF = 2.5;\r
+  if (opt.Contains("KTOFnsig30")) nSigmaTOF = 3.0;\r
+  if (opt.Contains("KTOFnsig40")) nSigmaTOF = 4.0;\r
+  if (opt.Contains("KTOFnsig50")) nSigmaTOF = 5.0;\r
+  if (opt.Contains("KTOFnsig1000")) nSigmaTOF = 100.0;\r
+\r
+  if (opt.Contains("trackPt")) {\r
+    useTrackPtCut = kTRUE;\r
+    if (opt.Contains("trackPtMin015")) trackPtMin = 0.15;\r
+    if (opt.Contains("trackPtMin02")) trackPtMin = 0.2;\r
+    if (opt.Contains("trackPtMin05")) trackPtMin = 0.5;\r
+    if (opt.Contains("trackPtMin06")) trackPtMin = 0.6;\r
+\r
+    if (opt.Contains("trackPtMax18")) trackPtMax = 1.8;\r
+    if (opt.Contains("trackPtMax20")) trackPtMax = 2.0;\r
+    if (opt.Contains("trackPtMax25")) trackPtMax = 2.5;\r
+  }\r
+\r
+  Bool_t usePDG=kFALSE;\r
+  if (opt.Contains("pdg")) {\r
+    Printf("Using PDG");\r
+    usePDG = kTRUE;\r
+  }\r
+\r
+  Bool_t useEta = kFALSE;\r
+  if (opt.Contains("eta")) {\r
+    for(int j=1;j<=9;j++) if(opt.Contains(Form("eta0%i",j))){etaMin=-0.1*j; etaMax=0.1*j;}\r
+\r
+    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMinMinus0%i",j))) etaMin=-0.1*j;\r
+    if(opt.Contains("etaMin00")) etaMin=0.;\r
+    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMinPlus0%i",j))) etaMin=0.1*j;\r
+\r
+    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMaxMinus0%i",j))) etaMax=-0.1*j;\r
+    if(opt.Contains("etaMax00")) etaMax=0.;\r
+    for(int j=1;j<=9;j++) if(opt.Contains(Form("etaMaxPlus0%i",j))) etaMax=0.1*j;\r
+\r
+    Printf("Using ETA range (%.2f,%.2f)",etaMin,etaMax);\r
+    useEta = kTRUE;\r
+  }\r
+\r
+  Bool_t useNclTPC = kFALSE;\r
+  if (opt.Contains("NclTPC")) {\r
+    if (opt.Contains("NclTPC70")) NclTPC=70;\r
+    if (opt.Contains("NclTPC75")) NclTPC=75;\r
+    if (opt.Contains("NclTPC80")) NclTPC=80;\r
+    if (opt.Contains("NclTPC85")) NclTPC=85;\r
+    if (opt.Contains("NclTPC90")) NclTPC=90;\r
+    useNclTPC = kTRUE;\r
+  }\r
+\r
+  Bool_t useDCAxy = kFALSE;\r
+  if (opt.Contains("DCAxy")) {\r
+    if (opt.Contains("DCAxyFormula7s")) sprintf(DCAxyFormula,"0.0182+0.035/pt^1.01");\r
+    if (opt.Contains("DCAxyFormula6s")) sprintf(DCAxyFormula,"0.0156+0.03/pt^1.01");\r
+    if (opt.Contains("DCAxyFormula5s")) sprintf(DCAxyFormula,"0.013+0.025/pt^1.01");\r
+    useDCAxy = kTRUE;\r
+  }\r
+\r
+  //---------------------------------------------\r
+  //  Combine cuts\r
+  //---------------------------------------------\r
+\r
+  TString cutname = "K_Phi";\r
+  if (!opt.IsNull()) cutname += Form("_%s",opt.Data());\r
+  AliRsnCutSet *cuts = new AliRsnCutSet(cutname.Data(), AliRsnTarget::kDaughter);\r
+\r
+  TString scheme="";\r
+  AliRsnCutTrackQuality *qualityCut = new AliRsnCutTrackQuality("cutQualityK");\r
+  if (!rsnQualityCut.IsNull()) {\r
+    AliESDtrackCuts *esdTK = RsnQualityCut(rsnQualityCut.Data());\r
+    if(useDCAxy) esdTK->SetMaxDCAToVertexXYPtDep(DCAxyFormula);\r
+    qualityCut->SetESDtrackCuts(esdTK);\r
+  } else {\r
+    if (useCommonQualityCut>=0) {\r
+      qualityCut->SetAODTestFilterBit(useCommonQualityCut);\r
+      if(useDCAxy) {qualityCut->SetCheckOnlyFilterBit(kFALSE); qualityCut->SetDCARPtFormula(DCAxyFormula);}\r
+    } else {\r
+      qualityCut->SetDefaults2010();\r
+      if(useDCAxy) qualityCut->SetDCARPtFormula(DCAxyFormula);\r
+    }\r
+  }\r
+\r
+  cuts->AddCut(qualityCut);\r
+  if (!scheme.IsNull()) scheme += "&";\r
+  scheme += qualityCut->GetName();\r
+\r
+\r
+  if (useTPC_K) {\r
+    AliRsnCutPIDNSigma *cutKTPC = new AliRsnCutPIDNSigma("cutPIDNSigmaTPCK",AliPID::kKaon,AliRsnCutPIDNSigma::kTPC);\r
+    cutKTPC->SinglePIDRange(nSigmaTPC);\r
+    cuts->AddCut(cutKTPC);\r
+    if (!scheme.IsNull()) scheme += "&";\r
+    scheme += cutKTPC->GetName();\r
+  }\r
+\r
+  if (useTOF_K) {\r
+    AliRsnCutPIDNSigma *cutKTOF = new AliRsnCutPIDNSigma("cutPIDNSigmaTOFK",AliPID::kKaon,AliRsnCutPIDNSigma::kTOF);\r
+    cutKTOF->SinglePIDRange(nSigmaTOF);\r
+    if(rejectUnmatchedTOF_K){\r
+      cuts->AddCut(cutKTOF);\r
+      if (!scheme.IsNull()) scheme += "&";\r
+      scheme += cutKTOF->GetName();\r
+    }else{\r
+      AliRsnCutTOFMatch *cutTOFMatch = new AliRsnCutTOFMatch("cutTOFMatch");\r
+      cuts->AddCut(cutTOFMatch);\r
+      if (!scheme.IsNull()) scheme += "&";\r
+      scheme += Form("(%s|(!%s))",cutKTOF->GetName(),cutTOFMatch->GetName());\r
+    }\r
+  }\r
+\r
+  if (useEta) {\r
+    Printf("Adding ETA ...");\r
+    AliRsnValueDaughter *valEta = new AliRsnValueDaughter(Form("val%sETA%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kEta);\r
+    AliRsnCutValue *cutEta = new AliRsnCutValue(Form("cut%sETA%s",AliPID::ParticleName(type1),opt.Data()),etaMin,etaMax);\r
+    cutEta->SetTargetType(AliRsnTarget::kDaughter);\r
+    cutEta->SetValueObj(valEta);\r
+    cuts->AddCut(cutEta);\r
+    if (!scheme.IsNull()) scheme += "&";\r
+    scheme += cutEta->GetName();\r
+  }\r
+\r
+  if (useTrackPtCut) {\r
+    Printf("Adding Pt min=%.3f max=%.3f ...",trackPtMin,trackPtMax);\r
+    AliRsnValueDaughter *valTrackPt = new AliRsnValueDaughter(Form("val%sTrackPt%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kPt);\r
+\r
+    AliRsnCutValue *cutTrackPt = new AliRsnCutValue(Form("cut%sTrackPt%s",AliPID::ParticleName(type1),opt.Data()),trackPtMin,trackPtMax);\r
+    cutTrackPt->SetTargetType(AliRsnTarget::kDaughter);\r
+    cutTrackPt->SetValueObj(valTrackPt);\r
+    cuts->AddCut(cutTrackPt);\r
+    if (!scheme.IsNull()) scheme += "&";\r
+    scheme += cutTrackPt->GetName();\r
+  }\r
+\r
+  if (useNclTPC) {\r
+    Printf("Adding NclTPC >= %i",NclTPC);\r
+    AliRsnValueDaughter *valNclTPC = new AliRsnValueDaughter(Form("val%sNclTPC%s",AliPID::ParticleName(type1),opt.Data()),AliRsnValueDaughter::kNTPCclusters);\r
+    AliRsnCutValue *cutNclTPC = new AliRsnCutValue(Form("cut%sNclTPC%s",AliPID::ParticleName(type1),opt.Data()),NclTPC-0.1,1000.);\r
+    cutNclTPC->SetTargetType(AliRsnTarget::kDaughter);\r
+    cutNclTPC->SetValueObj(valNclTPC);\r
+    cuts->AddCut(cutNclTPC);\r
+    if (!scheme.IsNull()) scheme += "&";\r
+    scheme += cutNclTPC->GetName();\r
+  }\r
+\r
+  if (usePDG) {\r
+    Printf("Adding PDG ...");\r
+    AliRsnCutPID *cutPDG = new AliRsnCutPID(Form("cut%sPDG%s",AliPID::ParticleName(type1),opt.Data()),type1,0.0,kTRUE);\r
+    cuts->AddCut(cutPDG);\r
+    if (!scheme.IsNull()) scheme += "&";\r
+    scheme += cutPDG->GetName();\r
+  }\r
+\r
+  Printf ("CUT Scheme is '%s'",scheme.Data());\r
+  cuts->SetCutScheme(scheme.Data());\r
+\r
+  if (opt.Contains("mon")) {\r
+    AddMonitorOutput(cuts->GetMonitorOutput(),opt);\r
+  }\r
+  if (isRsnMini) {\r
+    AliRsnMiniAnalysisTask *taskRsnMini = (AliRsnMiniAnalysisTask *)task;\r
+    if (taskRsnMini) {\r
+      taskRsnMini->AddTrackCuts(cuts);\r
+    }\r
+  } else {\r
+    AliRsnDaughterSelector *sel = rsnIH->GetSelector();\r
+    //       sel->SetLabelCheck(kFALSE);\r
+    sel->Add(cuts, kTRUE);\r
+    if (isRsnDev>=0 && opt.Contains("pairPID")) {\r
+      AliRsnActPostDaughterSelection *pairPID = new AliRsnActPostDaughterSelection();\r
+      pairPID->SetID(0);\r
+\r
+      const char *fn="rsnRange.txt";\r
+      if (!gSystem->AccessPathName(fn)) {\r
+       TString minStr = gSystem->GetFromPipe(TString::Format("head -n 1 %s").Data());\r
+       TString maxStr = gSystem->GetFromPipe(TString::Format("tail -n 1 %s").Data());\r
+       pairPID->SetMass(minStr.Atof(),maxStr.Atof());\r
+      } else {\r
+       //       pairPID->SetMass(1.01,1.03);\r
+       pairPID->SetMass(1.015,1.025);\r
+       pairPID->SetMass(1.019,1.021);\r
+       pairPID->SetMass(1.0195,1.0205);\r
+       pairPID->SetMass(1.1000,1.1005);\r
+       //       pairPID->SetMass(1.1005,1.1010);\r
+      }\r
+      sel->AddAction(pairPID);\r
+    }\r
+\r
+  }\r
+  return numberOfCuts;\r
+\r
+}\r
index 2bc60b8ef1516e9d8e10477d6196c5352a0c9c73..3ac0e6b73d2fc92f233a05685d8dfb8a5ffae5eb 100644 (file)
@@ -49,9 +49,12 @@ Bool_t ConfigTOFanalysisKStar
   } else {
     //use defult quality cuts (std 2010 or 2011)
     cutSetQ  = new AliRsnCutSetDaughterParticle(Form("cutQ_bit%i",aodFilterBit), AliRsnCutSetDaughterParticle::kQualityStd2011, AliPID::kPion, -1.0, aodFilterBit);
+    cutSetQ->SetUse2011StdQualityCuts(kTRUE);
     cutSetPi = new AliRsnCutSetDaughterParticle(Form("cutPi%i_%2.1fsigma",cutPiCandidate, nsigmaPi), cutPiCandidate, AliPID::kPion, nsigmaPi, aodFilterBit);
+    cutSetPi->SetUse2011StdQualityCuts(kTRUE);
     cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutK%i_%2.1fsigma",cutPiCandidate, nsigmaKa), cutKaCandidate, AliPID::kKaon, nsigmaKa, aodFilterBit);
-  }
+    cutSetK->SetUse2011StdQualityCuts(kTRUE);
+   }
   
   Int_t iCutQ = task->AddTrackCuts(cutSetQ);
   Int_t iCutPi = task->AddTrackCuts(cutSetPi);
index 2dada75043e9da9f5a044b2c9e4541dc70bbce76..4c0dfcc35e96afd5a90427d0c93e3e5442835f02 100644 (file)
@@ -16,7 +16,7 @@
 // AlidNdPtAnalysisPbPbAOD class. 
 // 
 // Author: P. Luettig, 15.05.2013
-// last modified: 08.10.2013
+// last modified: 17.10.2013
 //------------------------------------------------------------------------------
 
 
@@ -27,155 +27,72 @@ using namespace std;
 
 ClassImp(AlidNdPtAnalysisPbPbAOD)
 
-// dummy constructor
-AlidNdPtAnalysisPbPbAOD::AlidNdPtAnalysisPbPbAOD() : AliAnalysisTaskSE(),
-fOutputList(0),
-// Histograms
-hPt(0),
-hMCPt(0),
-hnZvPtEtaCent(0),
-hnMCRecPrimZvPtEtaCent(0),
-hnMCGenZvPtEtaCent(0),
-hnMCRecSecZvPtEtaCent(0),
-hEventStatistics(0),
-hEventStatisticsCentrality(0),
-hMCEventStatisticsCentrality(0),
-hAllEventStatisticsCentrality(0),
-hEventStatisticsCentralityTrigger(0),
-hnZvMultCent(0),
-hTriggerStatistics(0),
-hMCTrackPdgCode(0),
-hMCTrackStatusCode(0),
-hCharge(0),
-hMCCharge(0),
-hMCPdgPt(0),
-hMCHijingPrim(0),
-hDCAPtAll(0),
-hDCAPtAccepted(0),
-hMCDCAPtSecondary(0),
-hMCDCAPtPrimary(0),
-//global
-bIsMonteCarlo(0),
-// event cut variables
-dCutMaxZVertex(10.),  
-// track kinematic cut variables
-dCutPtMin(0.15),
-dCutPtMax(1000.),
-dCutEtaMin(-0.8),
-dCutEtaMax(0.8),    
-// track quality cut variables
-bCutRequireTPCRefit(kTRUE),
-dCutMinNumberOfCrossedRows(120.),
-dCutMinRatioCrossedRowsOverFindableClustersTPC(0.8),
-dCutMaxChi2PerClusterTPC(4.),
-dCutMaxFractionSharedTPCClusters(0.4),
-dCutMaxDCAToVertexZ(3.0),
-dCutMaxDCAToVertexXY(3.0),
-bCutRequireITSRefit(kTRUE),
-dCutMaxChi2PerClusterITS(36.),
-dCutDCAToVertex2D(kFALSE),
-dCutRequireSigmaToVertex(kFALSE),
-dCutMaxDCAToVertexXYPtDepPar0(0.0182),
-dCutMaxDCAToVertexXYPtDepPar1(0.0350),
-dCutMaxDCAToVertexXYPtDepPar2(1.01),
-bCutAcceptKinkDaughters(kFALSE),
-dCutMaxChi2TPCConstrainedGlobal(36.),
-// binning for THnSparse
-fMultNbins(0),
-fPtNbins(0),
-fPtCorrNbins(0),
-fPtCheckNbins(0),
-fEtaNbins(0),
-fEtaCheckNbins(0),
-fZvNbins(0),
-fCentralityNbins(0),
-fPhiNbins(0),
-fBinsMult(0),
-fBinsPt(0),
-fBinsPtCorr(0),
-fBinsPtCheck(0),
-fBinsEta(0),
-fBinsEtaCheck(0),
-fBinsZv(0),
-fBinsCentrality(0),
-fBinsPhi(0)
-{
-  for(Int_t i = 0; i < cqMax; i++)
-  {
-    hCrossCheckAll[i] = 0;
-    hCrossCheckAcc[i] = 0;
-  }
-  
-  fMultNbins = 0;
-  fPtNbins = 0;
-  fPtCorrNbins = 0;
-  fPtCheckNbins = 0;
-  fEtaNbins = 0;
-  fZvNbins = 0;
-  fCentralityNbins = 0;
-  fBinsMult = 0;
-  fBinsPt = 0;
-  fBinsPtCorr = 0;
-  fBinsEta = 0;
-  fBinsEtaCheck = 0;
-  fBinsZv = 0;
-  fBinsCentrality = 0;
-  fBinsPhi = 0;
-  
-}
+
 
 AlidNdPtAnalysisPbPbAOD::AlidNdPtAnalysisPbPbAOD(const char *name) : AliAnalysisTaskSE(name),
 fOutputList(0),
 // Histograms
-hPt(0),
-hMCPt(0),
-hnZvPtEtaCent(0),
-hnMCRecPrimZvPtEtaCent(0),
-hnMCGenZvPtEtaCent(0),
-hnMCRecSecZvPtEtaCent(0),
-hEventStatistics(0),
-hEventStatisticsCentrality(0),
-hMCEventStatisticsCentrality(0),
-hAllEventStatisticsCentrality(0),
-hEventStatisticsCentralityTrigger(0),
-hnZvMultCent(0),
-hTriggerStatistics(0),
-hMCTrackPdgCode(0),
-hMCTrackStatusCode(0),
-hCharge(0),
-hMCCharge(0),
-hMCPdgPt(0),
-hMCHijingPrim(0),
-hDCAPtAll(0),
-hDCAPtAccepted(0),
-hMCDCAPtSecondary(0),
-hMCDCAPtPrimary(0),
+fPt(0),
+fMCPt(0),
+fZvPtEtaCent(0),
+fMCRecPrimZvPtEtaCent(0),
+fMCGenZvPtEtaCent(0),
+fMCRecSecZvPtEtaCent(0),
+fEventStatistics(0),
+fEventStatisticsCentrality(0),
+fMCEventStatisticsCentrality(0),
+fAllEventStatisticsCentrality(0),
+fEventStatisticsCentralityTrigger(0),
+fZvMultCent(0),
+fTriggerStatistics(0),
+fMCTrackPdgCode(0),
+fMCTrackStatusCode(0),
+fCharge(0),
+fMCCharge(0),
+fMCPdgPt(0),
+fMCHijingPrim(0),
+fDCAPtAll(0),
+fDCAPtAccepted(0),
+fMCDCAPtSecondary(0),
+fMCDCAPtPrimary(0),
+fCutPercClusters(0),
+fCutPercCrossed(0),
+fCrossCheckRowsLength(0),
+fCrossCheckClusterLength(0),
+fCrossCheckRowsLengthAcc(0),
+fCrossCheckClusterLengthAcc(0),
 //global
-bIsMonteCarlo(0),
+fIsMonteCarlo(0),
 // event cut variables
-dCutMaxZVertex(10.),  
+fCutMaxZVertex(10.),  
 // track kinematic cut variables
-dCutPtMin(0.15),
-dCutPtMax(200.),
-dCutEtaMin(-0.8),
-dCutEtaMax(0.8),    
+fCutPtMin(0.15),
+fCutPtMax(200.),
+fCutEtaMin(-0.8),
+fCutEtaMax(0.8),    
 // track quality cut variables
-bCutRequireTPCRefit(kTRUE),
-dCutMinNumberOfCrossedRows(120.),
-dCutMinRatioCrossedRowsOverFindableClustersTPC(0.8),
-dCutMaxChi2PerClusterTPC(4.),
-dCutMaxFractionSharedTPCClusters(0.4),
-dCutMaxDCAToVertexZ(3.0),
-dCutMaxDCAToVertexXY(3.0),
-bCutRequireITSRefit(kTRUE),
-dCutMaxChi2PerClusterITS(36.),
-dCutDCAToVertex2D(kFALSE),
-dCutRequireSigmaToVertex(kFALSE),
-dCutMaxDCAToVertexXYPtDepPar0(0.0182),
-dCutMaxDCAToVertexXYPtDepPar1(0.0350),
-dCutMaxDCAToVertexXYPtDepPar2(1.01),
-bCutAcceptKinkDaughters(kFALSE),
-dCutMaxChi2TPCConstrainedGlobal(36.),
+fUseRelativeCuts(kFALSE),
+fCutRequireTPCRefit(kTRUE),
+fCutMinNumberOfClusters(60),
+fCutPercMinNumberOfClusters(0.2),
+fCutMinNumberOfCrossedRows(120.),
+fCutPercMinNumberOfCrossedRows(0.2),
+fCutMinRatioCrossedRowsOverFindableClustersTPC(0.8),
+fCutMaxChi2PerClusterTPC(4.),
+fCutMaxFractionSharedTPCClusters(0.4),
+fCutMaxDCAToVertexZ(3.0),
+fCutMaxDCAToVertexXY(3.0),
+fCutRequireITSRefit(kTRUE),
+fCutMaxChi2PerClusterITS(36.),
+fCutDCAToVertex2D(kFALSE),
+fCutRequireSigmaToVertex(kFALSE),
+fCutMaxDCAToVertexXYPtDepPar0(0.0182),
+fCutMaxDCAToVertexXYPtDepPar1(0.0350),
+fCutMaxDCAToVertexXYPtDepPar2(1.01),
+fCutAcceptKinkDaughters(kFALSE),
+fCutMaxChi2TPCConstrainedGlobal(36.),
+fCutLengthInTPCPtDependent(kFALSE),
+fPrefactorLengthInTPCPtDependent(1),
 // binning for THnSparse
 fMultNbins(0),
 fPtNbins(0),
@@ -199,8 +116,8 @@ fBinsPhi(0)
   
   for(Int_t i = 0; i < cqMax; i++)
   {
-    hCrossCheckAll[i] = 0;
-    hCrossCheckAcc[i] = 0;
+    fCrossCheckAll[i] = 0;
+    fCrossCheckAcc[i] = 0;
   }
   
   fMultNbins = 0;
@@ -228,36 +145,36 @@ fBinsPhi(0)
 AlidNdPtAnalysisPbPbAOD::~AlidNdPtAnalysisPbPbAOD()
 {
   
-  if(hnZvPtEtaCent) delete hnZvPtEtaCent; hnZvPtEtaCent = 0;
-  if(hPt) delete hPt; hPt = 0;
-  if(hnMCRecPrimZvPtEtaCent) delete hnMCRecPrimZvPtEtaCent; hnMCRecPrimZvPtEtaCent = 0;
-  if(hnMCGenZvPtEtaCent) delete hnMCGenZvPtEtaCent; hnMCGenZvPtEtaCent = 0;
-  if(hnMCRecSecZvPtEtaCent) delete hnMCRecSecZvPtEtaCent; hnMCRecSecZvPtEtaCent = 0;
-  if(hMCPt) delete hMCPt; hMCPt = 0;
-  if(hEventStatistics) delete hEventStatistics; hEventStatistics = 0;
-  if(hEventStatisticsCentrality) delete hEventStatisticsCentrality; hEventStatisticsCentrality = 0;
-  if(hMCEventStatisticsCentrality) delete hMCEventStatisticsCentrality; hMCEventStatisticsCentrality = 0;
-  if(hAllEventStatisticsCentrality) delete hAllEventStatisticsCentrality; hAllEventStatisticsCentrality = 0;
-  if(hEventStatisticsCentralityTrigger) delete hEventStatisticsCentralityTrigger; hEventStatisticsCentralityTrigger = 0;
-  if(hnZvMultCent) delete hnZvMultCent; hnZvMultCent = 0;
-  if(hTriggerStatistics) delete hTriggerStatistics; hTriggerStatistics = 0;
-  if(hMCTrackPdgCode) delete hMCTrackPdgCode; hMCTrackPdgCode = 0;
-  if(hMCTrackStatusCode) delete hMCTrackStatusCode; hMCTrackStatusCode = 0;
-  if(hCharge) delete hCharge; hCharge = 0;
-  if(hMCCharge) delete hMCCharge; hMCCharge = 0;
-  if(hMCPdgPt) delete hMCPdgPt; hMCPdgPt = 0;
-  if(hMCHijingPrim) delete hMCHijingPrim; hMCHijingPrim = 0;
-  if(hDCAPtAll) delete hDCAPtAll; hDCAPtAll = 0;
-  if(hDCAPtAccepted) delete hDCAPtAccepted; hDCAPtAccepted = 0;
-  if(hMCDCAPtSecondary) delete hMCDCAPtSecondary; hMCDCAPtSecondary = 0;
-  if(hMCDCAPtPrimary) delete hMCDCAPtPrimary; hMCDCAPtPrimary = 0;
-  if(hMCDCAPtSecondary) delete hMCDCAPtSecondary; hMCDCAPtSecondary = 0;
-  if(hMCDCAPtPrimary) delete hMCDCAPtPrimary; hMCDCAPtPrimary = 0;
+  if(fZvPtEtaCent) delete fZvPtEtaCent; fZvPtEtaCent = 0;
+  if(fPt) delete fPt; fPt = 0;
+  if(fMCRecPrimZvPtEtaCent) delete fMCRecPrimZvPtEtaCent; fMCRecPrimZvPtEtaCent = 0;
+  if(fMCGenZvPtEtaCent) delete fMCGenZvPtEtaCent; fMCGenZvPtEtaCent = 0;
+  if(fMCRecSecZvPtEtaCent) delete fMCRecSecZvPtEtaCent; fMCRecSecZvPtEtaCent = 0;
+  if(fMCPt) delete fMCPt; fMCPt = 0;
+  if(fEventStatistics) delete fEventStatistics; fEventStatistics = 0;
+  if(fEventStatisticsCentrality) delete fEventStatisticsCentrality; fEventStatisticsCentrality = 0;
+  if(fMCEventStatisticsCentrality) delete fMCEventStatisticsCentrality; fMCEventStatisticsCentrality = 0;
+  if(fAllEventStatisticsCentrality) delete fAllEventStatisticsCentrality; fAllEventStatisticsCentrality = 0;
+  if(fEventStatisticsCentralityTrigger) delete fEventStatisticsCentralityTrigger; fEventStatisticsCentralityTrigger = 0;
+  if(fZvMultCent) delete fZvMultCent; fZvMultCent = 0;
+  if(fTriggerStatistics) delete fTriggerStatistics; fTriggerStatistics = 0;
+  if(fMCTrackPdgCode) delete fMCTrackPdgCode; fMCTrackPdgCode = 0;
+  if(fMCTrackStatusCode) delete fMCTrackStatusCode; fMCTrackStatusCode = 0;
+  if(fCharge) delete fCharge; fCharge = 0;
+  if(fMCCharge) delete fMCCharge; fMCCharge = 0;
+  if(fMCPdgPt) delete fMCPdgPt; fMCPdgPt = 0;
+  if(fMCHijingPrim) delete fMCHijingPrim; fMCHijingPrim = 0;
+  if(fDCAPtAll) delete fDCAPtAll; fDCAPtAll = 0;
+  if(fDCAPtAccepted) delete fDCAPtAccepted; fDCAPtAccepted = 0;
+  if(fMCDCAPtSecondary) delete fMCDCAPtSecondary; fMCDCAPtSecondary = 0;
+  if(fMCDCAPtPrimary) delete fMCDCAPtPrimary; fMCDCAPtPrimary = 0;
+  if(fMCDCAPtSecondary) delete fMCDCAPtSecondary; fMCDCAPtSecondary = 0;
+  if(fMCDCAPtPrimary) delete fMCDCAPtPrimary; fMCDCAPtPrimary = 0;
   
   for(Int_t i = 0; i < cqMax; i++)
   {
-    if(hCrossCheckAll[i]) delete hCrossCheckAll[i]; hCrossCheckAll[i] = 0;
-    if(hCrossCheckAcc[i]) delete hCrossCheckAcc[i]; hCrossCheckAcc[i] = 0;
+    if(fCrossCheckAll[i]) delete fCrossCheckAll[i]; fCrossCheckAll[i] = 0;
+    if(fCrossCheckAcc[i]) delete fCrossCheckAcc[i]; fCrossCheckAcc[i] = 0;
   }
   
 }
@@ -298,110 +215,110 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   Int_t binsZvMultCent[3]={fZvNbins-1,fMultNbins-1,fCentralityNbins-1};
   
   // define Histograms
-  hnZvPtEtaCent = new THnSparseF("hnZvPtEtaCent","Zv:Pt:Eta:Centrality",4,binsZvPtEtaCent);
-  hnZvPtEtaCent->SetBinEdges(0,fBinsZv);
-  hnZvPtEtaCent->SetBinEdges(1,fBinsPt);
-  hnZvPtEtaCent->SetBinEdges(2,fBinsEta);
-  hnZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  hnZvPtEtaCent->GetAxis(0)->SetTitle("Zv (cm)");
-  hnZvPtEtaCent->GetAxis(1)->SetTitle("Pt (GeV/c)");
-  hnZvPtEtaCent->GetAxis(2)->SetTitle("Eta");
-  hnZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
-  hnZvPtEtaCent->Sumw2();
-  
-  hnMCRecPrimZvPtEtaCent = new THnSparseF("hnMCRecPrimZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
-  hnMCRecPrimZvPtEtaCent->SetBinEdges(0,fBinsZv);
-  hnMCRecPrimZvPtEtaCent->SetBinEdges(1,fBinsPt);
-  hnMCRecPrimZvPtEtaCent->SetBinEdges(2,fBinsEta);
-  hnMCRecPrimZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  hnMCRecPrimZvPtEtaCent->GetAxis(0)->SetTitle("MC Zv (cm)");
-  hnMCRecPrimZvPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
-  hnMCRecPrimZvPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
-  hnMCRecPrimZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
-  hnMCRecPrimZvPtEtaCent->Sumw2();
-  
-  hnMCGenZvPtEtaCent = new THnSparseF("hnMCGenZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
-  hnMCGenZvPtEtaCent->SetBinEdges(0,fBinsZv);
-  hnMCGenZvPtEtaCent->SetBinEdges(1,fBinsPt);
-  hnMCGenZvPtEtaCent->SetBinEdges(2,fBinsEta);
-  hnMCGenZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  hnMCGenZvPtEtaCent->GetAxis(0)->SetTitle("MC Zv (cm)");
-  hnMCGenZvPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
-  hnMCGenZvPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
-  hnMCGenZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
-  hnMCGenZvPtEtaCent->Sumw2();
-  
-  hnMCRecSecZvPtEtaCent = new THnSparseF("hnMCRecSecZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
-  hnMCRecSecZvPtEtaCent->SetBinEdges(0,fBinsZv);
-  hnMCRecSecZvPtEtaCent->SetBinEdges(1,fBinsPt);
-  hnMCRecSecZvPtEtaCent->SetBinEdges(2,fBinsEta);
-  hnMCRecSecZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  hnMCRecSecZvPtEtaCent->GetAxis(0)->SetTitle("MC Sec Zv (cm)");
-  hnMCRecSecZvPtEtaCent->GetAxis(1)->SetTitle("MC Sec Pt (GeV/c)");
-  hnMCRecSecZvPtEtaCent->GetAxis(2)->SetTitle("MC Sec Eta");
-  hnMCRecSecZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
-  hnMCRecSecZvPtEtaCent->Sumw2();
-  
-  hPt = new TH1F("hPt","hPt",2000,0,200);
-  hPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
-  hPt->GetYaxis()->SetTitle("dN/dp_{T}");
-  hPt->Sumw2();
-  
-  hMCPt = new TH1F("hMCPt","hMCPt",2000,0,200);
-  hMCPt->GetXaxis()->SetTitle("MC p_{T} (GeV/c)");
-  hMCPt->GetYaxis()->SetTitle("dN/dp_{T}");
-  hMCPt->Sumw2();
-  
-  hEventStatistics = new TH1F("hEventStatistics","hEventStatistics",10,0,10);
-  hEventStatistics->GetYaxis()->SetTitle("number of events");
-  hEventStatistics->SetBit(TH1::kCanRebin);
-  
-  hEventStatisticsCentrality = new TH1F("hEventStatisticsCentrality","hEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
-  hEventStatisticsCentrality->GetYaxis()->SetTitle("number of events");
-  
-  hMCEventStatisticsCentrality = new TH1F("hMCEventStatisticsCentrality","hMCEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
-  hMCEventStatisticsCentrality->GetYaxis()->SetTitle("number of MC events");
-  
-  hAllEventStatisticsCentrality = new TH1F("hAllEventStatisticsCentrality","hAllEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
-  hAllEventStatisticsCentrality->GetYaxis()->SetTitle("number of events");
-  
-  hEventStatisticsCentralityTrigger = new TH2F("hEventStatisticsCentralityTrigger","hEventStatisticsCentralityTrigger;centrality;trigger",100,0,100,3,0,3);
-  hEventStatisticsCentralityTrigger->Sumw2();
-  
-  hnZvMultCent = new THnSparseF("hnZvMultCent","Zv:mult:Centrality",3,binsZvMultCent);
-  hnZvMultCent->SetBinEdges(0,fBinsZv);
-  hnZvMultCent->SetBinEdges(1,fBinsMult);
-  hnZvMultCent->SetBinEdges(2,fBinsCentrality);
-  hnZvMultCent->GetAxis(0)->SetTitle("Zv (cm)");
-  hnZvMultCent->GetAxis(1)->SetTitle("N_{acc}");
-  hnZvMultCent->GetAxis(2)->SetTitle("Centrality");
-  hnZvMultCent->Sumw2();
-  
-  hTriggerStatistics = new TH1F("hTriggerStatistics","hTriggerStatistics",10,0,10);
-  hTriggerStatistics->GetYaxis()->SetTitle("number of events");
-  
-  hMCTrackPdgCode = new TH1F("hMCTrackPdgCode","hMCTrackPdgCode",100,0,10);
-  hMCTrackPdgCode->GetYaxis()->SetTitle("number of tracks");
-  hMCTrackPdgCode->SetBit(TH1::kCanRebin);
-  
-  hMCTrackStatusCode = new TH1F("hMCTrackStatusCode","hMCTrackStatusCode",100,0,10);
-  hMCTrackStatusCode->GetYaxis()->SetTitle("number of tracks");
-  hMCTrackStatusCode->SetBit(TH1::kCanRebin);
-  
-  hCharge = new TH1F("hCharge","hCharge",30, -5, 5);
-  hCharge->GetXaxis()->SetTitle("Charge");
-  hCharge->GetYaxis()->SetTitle("number of tracks");
-  
-  hMCCharge = new TH1F("hMCCharge","hMCCharge",30, -5, 5);
-  hMCCharge->GetXaxis()->SetTitle("MC Charge");
-  hMCCharge->GetYaxis()->SetTitle("number of tracks");
-  
-  hMCPdgPt = new TH2F("hMCPdgPt","hMCPdgPt",fPtNbins-1, fBinsPt, 100,0,100);
-  hMCPdgPt->GetYaxis()->SetTitle("particle");
-  hMCPdgPt->GetXaxis()->SetTitle("Pt (GeV/c)");
-  
-  hMCHijingPrim = new TH1F("hMCHijingPrim","hMCHijingPrim",2,0,2);
-  hMCPdgPt->GetYaxis()->SetTitle("number of particles");
+  fZvPtEtaCent = new THnSparseF("fZvPtEtaCent","Zv:Pt:Eta:Centrality",4,binsZvPtEtaCent);
+  fZvPtEtaCent->SetBinEdges(0,fBinsZv);
+  fZvPtEtaCent->SetBinEdges(1,fBinsPt);
+  fZvPtEtaCent->SetBinEdges(2,fBinsEta);
+  fZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
+  fZvPtEtaCent->GetAxis(0)->SetTitle("Zv (cm)");
+  fZvPtEtaCent->GetAxis(1)->SetTitle("Pt (GeV/c)");
+  fZvPtEtaCent->GetAxis(2)->SetTitle("Eta");
+  fZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
+  fZvPtEtaCent->Sumw2();
+  
+  fMCRecPrimZvPtEtaCent = new THnSparseF("fMCRecPrimZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
+  fMCRecPrimZvPtEtaCent->SetBinEdges(0,fBinsZv);
+  fMCRecPrimZvPtEtaCent->SetBinEdges(1,fBinsPt);
+  fMCRecPrimZvPtEtaCent->SetBinEdges(2,fBinsEta);
+  fMCRecPrimZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
+  fMCRecPrimZvPtEtaCent->GetAxis(0)->SetTitle("MC Zv (cm)");
+  fMCRecPrimZvPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
+  fMCRecPrimZvPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
+  fMCRecPrimZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
+  fMCRecPrimZvPtEtaCent->Sumw2();
+  
+  fMCGenZvPtEtaCent = new THnSparseF("fMCGenZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
+  fMCGenZvPtEtaCent->SetBinEdges(0,fBinsZv);
+  fMCGenZvPtEtaCent->SetBinEdges(1,fBinsPt);
+  fMCGenZvPtEtaCent->SetBinEdges(2,fBinsEta);
+  fMCGenZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
+  fMCGenZvPtEtaCent->GetAxis(0)->SetTitle("MC Zv (cm)");
+  fMCGenZvPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
+  fMCGenZvPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
+  fMCGenZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
+  fMCGenZvPtEtaCent->Sumw2();
+  
+  fMCRecSecZvPtEtaCent = new THnSparseF("fMCRecSecZvPtEtaCent","mcZv:mcPt:mcEta:Centrality",4,binsZvPtEtaCent);
+  fMCRecSecZvPtEtaCent->SetBinEdges(0,fBinsZv);
+  fMCRecSecZvPtEtaCent->SetBinEdges(1,fBinsPt);
+  fMCRecSecZvPtEtaCent->SetBinEdges(2,fBinsEta);
+  fMCRecSecZvPtEtaCent->SetBinEdges(3,fBinsCentrality);
+  fMCRecSecZvPtEtaCent->GetAxis(0)->SetTitle("MC Sec Zv (cm)");
+  fMCRecSecZvPtEtaCent->GetAxis(1)->SetTitle("MC Sec Pt (GeV/c)");
+  fMCRecSecZvPtEtaCent->GetAxis(2)->SetTitle("MC Sec Eta");
+  fMCRecSecZvPtEtaCent->GetAxis(3)->SetTitle("Centrality");
+  fMCRecSecZvPtEtaCent->Sumw2();
+  
+  fPt = new TH1F("fPt","fPt",2000,0,200);
+  fPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
+  fPt->GetYaxis()->SetTitle("dN/dp_{T}");
+  fPt->Sumw2();
+  
+  fMCPt = new TH1F("fMCPt","fMCPt",2000,0,200);
+  fMCPt->GetXaxis()->SetTitle("MC p_{T} (GeV/c)");
+  fMCPt->GetYaxis()->SetTitle("dN/dp_{T}");
+  fMCPt->Sumw2();
+  
+  fEventStatistics = new TH1F("fEventStatistics","fEventStatistics",10,0,10);
+  fEventStatistics->GetYaxis()->SetTitle("number of events");
+  fEventStatistics->SetBit(TH1::kCanRebin);
+  
+  fEventStatisticsCentrality = new TH1F("fEventStatisticsCentrality","fEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
+  fEventStatisticsCentrality->GetYaxis()->SetTitle("number of events");
+  
+  fMCEventStatisticsCentrality = new TH1F("fMCEventStatisticsCentrality","fMCEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
+  fMCEventStatisticsCentrality->GetYaxis()->SetTitle("number of MC events");
+  
+  fAllEventStatisticsCentrality = new TH1F("fAllEventStatisticsCentrality","fAllEventStatisticsCentrality",fCentralityNbins-1, fBinsCentrality);
+  fAllEventStatisticsCentrality->GetYaxis()->SetTitle("number of events");
+  
+  fEventStatisticsCentralityTrigger = new TH2F("fEventStatisticsCentralityTrigger","fEventStatisticsCentralityTrigger;centrality;trigger",100,0,100,3,0,3);
+  fEventStatisticsCentralityTrigger->Sumw2();
+  
+  fZvMultCent = new THnSparseF("fZvMultCent","Zv:mult:Centrality",3,binsZvMultCent);
+  fZvMultCent->SetBinEdges(0,fBinsZv);
+  fZvMultCent->SetBinEdges(1,fBinsMult);
+  fZvMultCent->SetBinEdges(2,fBinsCentrality);
+  fZvMultCent->GetAxis(0)->SetTitle("Zv (cm)");
+  fZvMultCent->GetAxis(1)->SetTitle("N_{acc}");
+  fZvMultCent->GetAxis(2)->SetTitle("Centrality");
+  fZvMultCent->Sumw2();
+  
+  fTriggerStatistics = new TH1F("fTriggerStatistics","fTriggerStatistics",10,0,10);
+  fTriggerStatistics->GetYaxis()->SetTitle("number of events");
+  
+  fMCTrackPdgCode = new TH1F("fMCTrackPdgCode","fMCTrackPdgCode",100,0,10);
+  fMCTrackPdgCode->GetYaxis()->SetTitle("number of tracks");
+  fMCTrackPdgCode->SetBit(TH1::kCanRebin);
+  
+  fMCTrackStatusCode = new TH1F("fMCTrackStatusCode","fMCTrackStatusCode",100,0,10);
+  fMCTrackStatusCode->GetYaxis()->SetTitle("number of tracks");
+  fMCTrackStatusCode->SetBit(TH1::kCanRebin);
+  
+  fCharge = new TH1F("fCharge","fCharge",30, -5, 5);
+  fCharge->GetXaxis()->SetTitle("Charge");
+  fCharge->GetYaxis()->SetTitle("number of tracks");
+  
+  fMCCharge = new TH1F("fMCCharge","fMCCharge",30, -5, 5);
+  fMCCharge->GetXaxis()->SetTitle("MC Charge");
+  fMCCharge->GetYaxis()->SetTitle("number of tracks");
+  
+  fMCPdgPt = new TH2F("fMCPdgPt","fMCPdgPt",fPtNbins-1, fBinsPt, 100,0,100);
+  fMCPdgPt->GetYaxis()->SetTitle("particle");
+  fMCPdgPt->GetXaxis()->SetTitle("Pt (GeV/c)");
+  
+  fMCHijingPrim = new TH1F("fMCHijingPrim","fMCHijingPrim",2,0,2);
+  fMCHijingPrim->GetYaxis()->SetTitle("number of particles");
   
   
   
@@ -409,58 +326,58 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   Double_t minDCAxyDCAzPtEtaPhi[6] = { -5, -5, 0, -1.5, 0., 0, };
   Double_t maxDCAxyDCAzPtEtaPhi[6] = { 5., 5., 100, 1.5, 2.*TMath::Pi(), 100};
   
-  hDCAPtAll = new THnSparseF("hDCAPtAll","hDCAPtAll",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
-  hDCAPtAccepted = new THnSparseF("hDCAPtAccepted","hDCAPtAccepted",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
-  hMCDCAPtSecondary = new THnSparseF("hMCDCAPtSecondary","hMCDCAPtSecondary",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
-  hMCDCAPtPrimary = new THnSparseF("hMCDCAPtPrimary","hMCDCAPtPrimary",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
-  
-  hDCAPtAll->SetBinEdges(2, fBinsPtCheck);
-  hDCAPtAccepted->SetBinEdges(2, fBinsPtCheck);
-  hMCDCAPtSecondary->SetBinEdges(2, fBinsPtCheck);
-  hMCDCAPtPrimary->SetBinEdges(2, fBinsPtCheck);
-  
-  hDCAPtAll->SetBinEdges(3, fBinsEtaCheck);
-  hDCAPtAccepted->SetBinEdges(3, fBinsEtaCheck);
-  hMCDCAPtSecondary->SetBinEdges(3, fBinsEtaCheck);
-  hMCDCAPtPrimary->SetBinEdges(3, fBinsEtaCheck);
-  
-  hDCAPtAll->SetBinEdges(5, fBinsCentrality);
-  hDCAPtAccepted->SetBinEdges(5, fBinsCentrality);
-  hMCDCAPtSecondary->SetBinEdges(5, fBinsCentrality);
-  hMCDCAPtPrimary->SetBinEdges(5, fBinsCentrality);
-  
-  hDCAPtAll->Sumw2();
-  hDCAPtAccepted->Sumw2();
-  hMCDCAPtSecondary->Sumw2();
-  hMCDCAPtPrimary->Sumw2();
-  
-  hDCAPtAll->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
-  hDCAPtAll->GetAxis(1)->SetTitle("DCA_{z} (cm)");
-  hDCAPtAll->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
-  hDCAPtAll->GetAxis(3)->SetTitle("#eta");
-  hDCAPtAll->GetAxis(4)->SetTitle("#phi");
-  hDCAPtAll->GetAxis(5)->SetTitle("Centrality");
-  
-  hDCAPtAccepted->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
-  hDCAPtAccepted->GetAxis(1)->SetTitle("DCA_{z} (cm)");
-  hDCAPtAccepted->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
-  hDCAPtAccepted->GetAxis(3)->SetTitle("#eta");
-  hDCAPtAccepted->GetAxis(4)->SetTitle("#phi");
-  hDCAPtAccepted->GetAxis(5)->SetTitle("Centrality");
-  
-  hMCDCAPtSecondary->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
-  hMCDCAPtSecondary->GetAxis(1)->SetTitle("DCA_{z} (cm)");
-  hMCDCAPtSecondary->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
-  hMCDCAPtSecondary->GetAxis(3)->SetTitle("#eta");
-  hMCDCAPtSecondary->GetAxis(4)->SetTitle("#phi");
-  hMCDCAPtSecondary->GetAxis(5)->SetTitle("Centrality");
-  
-  hMCDCAPtPrimary->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
-  hMCDCAPtPrimary->GetAxis(1)->SetTitle("DCA_{z} (cm)");
-  hMCDCAPtPrimary->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
-  hMCDCAPtPrimary->GetAxis(3)->SetTitle("#eta");
-  hMCDCAPtPrimary->GetAxis(4)->SetTitle("#phi");
-  hMCDCAPtPrimary->GetAxis(5)->SetTitle("Centrality");
+  fDCAPtAll = new THnSparseF("fDCAPtAll","fDCAPtAll",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
+  fDCAPtAccepted = new THnSparseF("fDCAPtAccepted","fDCAPtAccepted",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
+  fMCDCAPtSecondary = new THnSparseF("fMCDCAPtSecondary","fMCDCAPtSecondary",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
+  fMCDCAPtPrimary = new THnSparseF("fMCDCAPtPrimary","fMCDCAPtPrimary",6, binsDCAxyDCAzPtEtaPhi, minDCAxyDCAzPtEtaPhi, maxDCAxyDCAzPtEtaPhi);
+  
+  fDCAPtAll->SetBinEdges(2, fBinsPtCheck);
+  fDCAPtAccepted->SetBinEdges(2, fBinsPtCheck);
+  fMCDCAPtSecondary->SetBinEdges(2, fBinsPtCheck);
+  fMCDCAPtPrimary->SetBinEdges(2, fBinsPtCheck);
+  
+  fDCAPtAll->SetBinEdges(3, fBinsEtaCheck);
+  fDCAPtAccepted->SetBinEdges(3, fBinsEtaCheck);
+  fMCDCAPtSecondary->SetBinEdges(3, fBinsEtaCheck);
+  fMCDCAPtPrimary->SetBinEdges(3, fBinsEtaCheck);
+  
+  fDCAPtAll->SetBinEdges(5, fBinsCentrality);
+  fDCAPtAccepted->SetBinEdges(5, fBinsCentrality);
+  fMCDCAPtSecondary->SetBinEdges(5, fBinsCentrality);
+  fMCDCAPtPrimary->SetBinEdges(5, fBinsCentrality);
+  
+  fDCAPtAll->Sumw2();
+  fDCAPtAccepted->Sumw2();
+  fMCDCAPtSecondary->Sumw2();
+  fMCDCAPtPrimary->Sumw2();
+  
+  fDCAPtAll->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
+  fDCAPtAll->GetAxis(1)->SetTitle("DCA_{z} (cm)");
+  fDCAPtAll->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
+  fDCAPtAll->GetAxis(3)->SetTitle("#eta");
+  fDCAPtAll->GetAxis(4)->SetTitle("#phi");
+  fDCAPtAll->GetAxis(5)->SetTitle("Centrality");
+  
+  fDCAPtAccepted->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
+  fDCAPtAccepted->GetAxis(1)->SetTitle("DCA_{z} (cm)");
+  fDCAPtAccepted->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
+  fDCAPtAccepted->GetAxis(3)->SetTitle("#eta");
+  fDCAPtAccepted->GetAxis(4)->SetTitle("#phi");
+  fDCAPtAccepted->GetAxis(5)->SetTitle("Centrality");
+  
+  fMCDCAPtSecondary->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
+  fMCDCAPtSecondary->GetAxis(1)->SetTitle("DCA_{z} (cm)");
+  fMCDCAPtSecondary->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
+  fMCDCAPtSecondary->GetAxis(3)->SetTitle("#eta");
+  fMCDCAPtSecondary->GetAxis(4)->SetTitle("#phi");
+  fMCDCAPtSecondary->GetAxis(5)->SetTitle("Centrality");
+  
+  fMCDCAPtPrimary->GetAxis(0)->SetTitle("DCA_{xy} (cm)");
+  fMCDCAPtPrimary->GetAxis(1)->SetTitle("DCA_{z} (cm)");
+  fMCDCAPtPrimary->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
+  fMCDCAPtPrimary->GetAxis(3)->SetTitle("#eta");
+  fMCDCAPtPrimary->GetAxis(4)->SetTitle("#phi");
+  fMCDCAPtPrimary->GetAxis(5)->SetTitle("Centrality");
   
   
   char cFullTempTitle[255];
@@ -474,6 +391,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   //   Double_t dBinsRowsClusters[iNbinRowsClusters] = {0, 7.95, 15.9, 23.85, 31.8, 39.75, 47.7, 55.65, 63.6, 71.55, 79.5, 87.45, 95.4, 103.35, 111.3, 119.25, 127.2, 135.15, 143.1, 151.05, 159.};
   
   const Int_t iNbinChi = 51;
+  const Int_t iNbinLength = 165;
   //   Double_t dBinsChi[iNbinChi] = {0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4, 4.2, 4.4, 4.6, 4.8, 5, 5.2, 5.4, 5.6, 5.8, 6, 6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4, 8.6, 8.8, 9, 9.2, 9.4, 9.6, 9.8,10.};
   
   Int_t iNbin = 0;
@@ -486,80 +404,114 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
     // iCheckQuant: 0 = CrossedRows, 1 = Nclusters, 2 = Chi^2/clusterTPC
     if(iCheckQuant == cqCrossedRows) 
     {
-      sprintf(cTempTitleAxis0All, "NcrossedRows before Cut"); 
-      sprintf(cTempTitleAxis0Acc, "NcrossedRows after Cut"); 
-      sprintf(cTempNameAxis0, "CrossedRows");
+      snprintf(cTempTitleAxis0All,256, "NcrossedRows before Cut"); 
+      snprintf(cTempTitleAxis0Acc,256, "NcrossedRows after Cut"); 
+      snprintf(cTempNameAxis0,256, "CrossedRows");
       iNbin = iNbinRowsClusters;
       dBinMin = 0;
       dBinMax = 159.;
     }
     else if(iCheckQuant == cqNcluster) 
     {
-      sprintf(cTempTitleAxis0All, "Nclusters before Cut"); 
-      sprintf(cTempTitleAxis0Acc, "Nclusters after Cut"); 
-      sprintf(cTempNameAxis0, "Clusters");
+      snprintf(cTempTitleAxis0All,256, "Nclusters before Cut"); 
+      snprintf(cTempTitleAxis0Acc,256, "Nclusters after Cut"); 
+      snprintf(cTempNameAxis0,256, "Clusters");
       iNbin = iNbinRowsClusters;
       dBinMin = 0;
       dBinMax = 159.;
     }
     else if(iCheckQuant == cqChi) 
     {
-      sprintf(cTempTitleAxis0All, "#Chi^{2}/cluster before Cut"); 
-      sprintf(cTempTitleAxis0Acc, "#Chi^{2}/cluster after Cut"); 
-      sprintf(cTempNameAxis0, "Chi");
+      snprintf(cTempTitleAxis0All,256, "#Chi^{2}/cluster before Cut"); 
+      snprintf(cTempTitleAxis0Acc,256, "#Chi^{2}/cluster after Cut"); 
+      snprintf(cTempNameAxis0,256, "Chi");
       iNbin = iNbinChi;
       dBinMin = 0;
       dBinMax = 10.;
     }
+    else if(iCheckQuant == cqLength) 
+    {
+      snprintf(cTempTitleAxis0All,256, "Length in TPC before Cut (cm)"); 
+      snprintf(cTempTitleAxis0Acc,256, "Length in TPC after Cut (cm)"); 
+      snprintf(cTempNameAxis0,256, "Length");
+      iNbin = iNbinLength;
+      dBinMin = 0;
+      dBinMax = 165.;
+    }
     
     Int_t binsCheckPtEtaPhi[5] = { iNbin, fPtCheckNbins-1, fEtaCheckNbins-1, 18, fCentralityNbins-1};
+//     Int_t binsCheckPtEtaPhi[5] = { iNbin, fPtNbins-1, fEtaCheckNbins-1, 18, fCentralityNbins-1};
     Double_t minCheckPtEtaPhi[5] = { dBinMin,  0, -1.5, 0., 0, };
     Double_t maxCheckPtEtaPhi[5] = { dBinMax, 100, 1.5, 2.*TMath::Pi(), 100};
     
-    sprintf(cFullTempName, "h%sPtEtaPhiAll",cTempNameAxis0);
-    sprintf(cFullTempTitle,"%s;%s;p_{T} (GeV/c);#eta;#phi;Centrality", cFullTempName, cTempTitleAxis0All);
-    hCrossCheckAll[iCheckQuant] = new THnF(cFullTempName, cFullTempTitle, 5, binsCheckPtEtaPhi, minCheckPtEtaPhi, maxCheckPtEtaPhi);
-    hCrossCheckAll[iCheckQuant]->SetBinEdges(1, fBinsPtCheck);
-    hCrossCheckAll[iCheckQuant]->SetBinEdges(2, fBinsEtaCheck);
-    hCrossCheckAll[iCheckQuant]->Sumw2();
+    snprintf(cFullTempName, 256, "f%sPtEtaPhiAll",cTempNameAxis0);
+    snprintf(cFullTempTitle, 256,"%s;%s;p_{T} (GeV/c);#eta;#phi;Centrality", cFullTempName, cTempTitleAxis0All);
+    fCrossCheckAll[iCheckQuant] = new THnF(cFullTempName, cFullTempTitle, 5, binsCheckPtEtaPhi, minCheckPtEtaPhi, maxCheckPtEtaPhi);
+    fCrossCheckAll[iCheckQuant]->SetBinEdges(1, fBinsPtCheck);
+    fCrossCheckAll[iCheckQuant]->SetBinEdges(2, fBinsEtaCheck);
+    fCrossCheckAll[iCheckQuant]->Sumw2();
     
-    sprintf(cFullTempName, "h%sPtEtaPhiAcc",cTempNameAxis0);
-    sprintf(cFullTempTitle,"%s;%s;p_{T} (GeV/c);#eta;#phi;Centrality", cFullTempName, cTempTitleAxis0Acc);
-    hCrossCheckAcc[iCheckQuant] = new THnF(cFullTempName, cFullTempTitle, 5, binsCheckPtEtaPhi, minCheckPtEtaPhi, maxCheckPtEtaPhi);
-    hCrossCheckAcc[iCheckQuant]->SetBinEdges(1, fBinsPtCheck);
-    hCrossCheckAcc[iCheckQuant]->SetBinEdges(2, fBinsEtaCheck);
-    hCrossCheckAcc[iCheckQuant]->Sumw2();
+    snprintf(cFullTempName, 256, "f%sPtEtaPhiAcc",cTempNameAxis0);
+    snprintf(cFullTempTitle, 256,"%s;%s;p_{T} (GeV/c);#eta;#phi;Centrality", cFullTempName, cTempTitleAxis0Acc);
+    fCrossCheckAcc[iCheckQuant] = new THnF(cFullTempName, cFullTempTitle, 5, binsCheckPtEtaPhi, minCheckPtEtaPhi, maxCheckPtEtaPhi);
+    fCrossCheckAcc[iCheckQuant]->SetBinEdges(1, fBinsPtCheck);
+    fCrossCheckAcc[iCheckQuant]->SetBinEdges(2, fBinsEtaCheck);
+    fCrossCheckAcc[iCheckQuant]->Sumw2();
   } // end iCheckQuant
   
+  fCutPercClusters = new TH1F("fCutPercClusters","fCutPercClusters;NclustersTPC;counts",160,0,160);
+  fCutPercClusters->Sumw2();
+  fCutPercCrossed = new TH1F("fCutPercCrossed","fCutPercCrossed;NcrossedRowsTPC;counts",160,0,160);
+  fCutPercCrossed->Sumw2();
+  
+  fCrossCheckRowsLength = new TH2F("fCrossCheckRowsLength","fCrossCheckRowsLength;Length in TPC;NcrossedRows",170,0,170,170,0,170);
+  fCrossCheckRowsLength->Sumw2();
+  
+  fCrossCheckClusterLength = new TH2F("fCrossCheckClusterLength","fCrossCheckClusterLength;Length in TPC;NClusters",170,0,170,170,0,170);
+  fCrossCheckClusterLength->Sumw2();
+  
+  fCrossCheckRowsLengthAcc = new TH2F("fCrossCheckRowsLengthAcc","fCrossCheckRowsLengthAcc;Length in TPC;NcrossedRows",170,0,170,170,0,170);
+  fCrossCheckRowsLengthAcc->Sumw2();
+  
+  fCrossCheckClusterLengthAcc = new TH2F("fCrossCheckClusterLengthAcc","fCrossCheckClusterLengthAcc;Length in TPC;NClusters",170,0,170,170,0,170);
+  fCrossCheckClusterLengthAcc->Sumw2();
+  
+  
   // Add Histos, Profiles etc to List
-  fOutputList->Add(hnZvPtEtaCent);
-  fOutputList->Add(hPt);
-  fOutputList->Add(hnMCRecPrimZvPtEtaCent);
-  fOutputList->Add(hnMCGenZvPtEtaCent);
-  fOutputList->Add(hnMCRecSecZvPtEtaCent);
-  fOutputList->Add(hMCPt);
-  fOutputList->Add(hEventStatistics);
-  fOutputList->Add(hEventStatisticsCentrality);
-  fOutputList->Add(hMCEventStatisticsCentrality);
-  fOutputList->Add(hAllEventStatisticsCentrality);
-  fOutputList->Add(hEventStatisticsCentralityTrigger);
-  fOutputList->Add(hnZvMultCent);
-  fOutputList->Add(hTriggerStatistics);
-  fOutputList->Add(hMCTrackPdgCode);
-  fOutputList->Add(hMCTrackStatusCode);
-  fOutputList->Add(hCharge);
-  fOutputList->Add(hMCCharge);
-  fOutputList->Add(hMCPdgPt);
-  fOutputList->Add(hMCHijingPrim);
-  fOutputList->Add(hDCAPtAll);
-  fOutputList->Add(hDCAPtAccepted);
-  fOutputList->Add(hMCDCAPtSecondary);
-  fOutputList->Add(hMCDCAPtPrimary);
+  fOutputList->Add(fZvPtEtaCent);
+  fOutputList->Add(fPt);
+  fOutputList->Add(fMCRecPrimZvPtEtaCent);
+  fOutputList->Add(fMCGenZvPtEtaCent);
+  fOutputList->Add(fMCRecSecZvPtEtaCent);
+  fOutputList->Add(fMCPt);
+  fOutputList->Add(fEventStatistics);
+  fOutputList->Add(fEventStatisticsCentrality);
+  fOutputList->Add(fMCEventStatisticsCentrality);
+  fOutputList->Add(fAllEventStatisticsCentrality);
+  fOutputList->Add(fEventStatisticsCentralityTrigger);
+  fOutputList->Add(fZvMultCent);
+  fOutputList->Add(fTriggerStatistics);
+  fOutputList->Add(fMCTrackPdgCode);
+  fOutputList->Add(fMCTrackStatusCode);
+  fOutputList->Add(fCharge);
+  fOutputList->Add(fMCCharge);
+  fOutputList->Add(fMCPdgPt);
+  fOutputList->Add(fMCHijingPrim);
+  fOutputList->Add(fDCAPtAll);
+  fOutputList->Add(fDCAPtAccepted);
+  fOutputList->Add(fMCDCAPtSecondary);
+  fOutputList->Add(fMCDCAPtPrimary);
   for(Int_t i = 0; i < cqMax; i++)
   {   
-    fOutputList->Add(hCrossCheckAll[i]);
-    fOutputList->Add(hCrossCheckAcc[i]);
+    fOutputList->Add(fCrossCheckAll[i]);
+    fOutputList->Add(fCrossCheckAcc[i]);
   }
+  fOutputList->Add(fCutPercClusters);
+  fOutputList->Add(fCutPercCrossed);
+  fOutputList->Add(fCrossCheckRowsLength);
+  fOutputList->Add(fCrossCheckClusterLength);
+  fOutputList->Add(fCrossCheckRowsLengthAcc);
+  fOutputList->Add(fCrossCheckClusterLengthAcc);
   
   PostData(1, fOutputList);
 }
@@ -569,7 +521,7 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   
   // Main Loop
   // called for each event
-  hEventStatistics->Fill("all events",1);
+  fEventStatistics->Fill("all events",1);
   
   // set ZERO pointers:
   AliInputEventHandler *inputHandler = NULL;
@@ -601,7 +553,7 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   Double_t dEventZv = -100;
   Int_t iAcceptedMultiplicity = 0;
   
-  bIsMonteCarlo = kFALSE;
+  fIsMonteCarlo = kFALSE;
   
   AliAODEvent *eventAOD = 0x0;
   eventAOD = dynamic_cast<AliAODEvent*>( InputEvent() );
@@ -616,11 +568,11 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   bIsEventSelectedSemi = ( inputHandler->IsEventSelected() & AliVEvent::kSemiCentral);
   bIsEventSelectedCentral = ( inputHandler->IsEventSelected() & AliVEvent::kCentral);
   
-  if(bIsEventSelectedMB || bIsEventSelectedSemi || bIsEventSelectedCentral) hTriggerStatistics->Fill("all triggered events",1);
-  if(bIsEventSelectedMB) { hTriggerStatistics->Fill("MB trigger",1); nTriggerFired++; }
-  if(bIsEventSelectedSemi) { hTriggerStatistics->Fill("SemiCentral trigger",1); nTriggerFired++; }
-  if(bIsEventSelectedCentral) { hTriggerStatistics->Fill("Central trigger",1); nTriggerFired++; }
-  if(nTriggerFired == 0) { hTriggerStatistics->Fill("No trigger",1); }
+  if(bIsEventSelectedMB || bIsEventSelectedSemi || bIsEventSelectedCentral) fTriggerStatistics->Fill("all triggered events",1);
+  if(bIsEventSelectedMB) { fTriggerStatistics->Fill("MB trigger",1); nTriggerFired++; }
+  if(bIsEventSelectedSemi) { fTriggerStatistics->Fill("SemiCentral trigger",1); nTriggerFired++; }
+  if(bIsEventSelectedCentral) { fTriggerStatistics->Fill("Central trigger",1); nTriggerFired++; }
+  if(nTriggerFired == 0) { fTriggerStatistics->Fill("No trigger",1); }
   
   bIsEventSelected = ( inputHandler->IsEventSelected() & GetCollisionCandidates() );
   
@@ -629,7 +581,7 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   
   //   if( !bIsEventSelected || nTriggerFired>1 ) return;
   
-  //   hEventStatistics->Fill("events with only coll. cand.", 1);
+  //   fEventStatistics->Fill("events with only coll. cand.", 1);
   
   
   
@@ -640,7 +592,7 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   
   if( stack )
   {
-    bIsMonteCarlo = kTRUE;
+    fIsMonteCarlo = kTRUE;
     
     mcHdr = (AliAODMCHeader*)list->FindObject(AliAODMCHeader::StdBranchName());
     
@@ -653,26 +605,26 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
     
     dMCEventZv = mcHdr->GetVtxZ();
     dMCTrackZvPtEtaCent[0] = dMCEventZv;
-    hEventStatistics->Fill("MC all events",1);
+    fEventStatistics->Fill("MC all events",1);
   }
   
   AliCentrality* aCentrality = eventAOD->GetCentrality();
   Double_t dCentrality = aCentrality->GetCentralityPercentile("V0M");
   
   if( dCentrality < 0 ) return;
-  hEventStatistics->Fill("after centrality selection",1);
+  fEventStatistics->Fill("after centrality selection",1);
   
   
   
   // start with MC truth analysis
-  if(bIsMonteCarlo)
+  if(fIsMonteCarlo)
   {
     
-    if( dMCEventZv > dCutMaxZVertex )  { return; }
+    if( dMCEventZv > GetCutMaxZVertex() )  { return; }
     
     dMCTrackZvPtEtaCent[0] = dMCEventZv;
     
-    hEventStatistics->Fill("MC afterZv cut",1);
+    fEventStatistics->Fill("MC afterZv cut",1);
     
     for(Int_t iMCtrack = 0; iMCtrack < stack->GetEntriesFast(); iMCtrack++)
     {
@@ -685,11 +637,11 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
       
       if(mcPart->IsPhysicalPrimary() ) 
       {
-       hMCHijingPrim->Fill("IsPhysicalPrimary",1);
+       fMCHijingPrim->Fill("IsPhysicalPrimary",1);
       }
       else
       {
-       hMCHijingPrim->Fill("NOT a primary",1);
+       fMCHijingPrim->Fill("NOT a primary",1);
        continue;
       }
       
@@ -702,25 +654,26 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
       
       bEventHasATrack = kTRUE;
       
-      hnMCGenZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
+      fMCGenZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
       
-      if( (dMCTrackZvPtEtaCent[1] > dCutPtMin) &&
-       (dMCTrackZvPtEtaCent[1] < dCutPtMax) &&
-       (dMCTrackZvPtEtaCent[2] > dCutEtaMin) &&
-       (dMCTrackZvPtEtaCent[2] < dCutEtaMax) )
+      if( (dMCTrackZvPtEtaCent[1] > GetCutPtMin() ) &&
+       (dMCTrackZvPtEtaCent[1] < GetCutPtMax() ) &&
+       (dMCTrackZvPtEtaCent[2] > GetCutEtaMin() ) &&
+       (dMCTrackZvPtEtaCent[2] < GetCutEtaMax() ) )
       {
-       hMCPt->Fill(mcPart->Pt());
-       hMCCharge->Fill(mcPart->Charge()/3.);
+       fMCPt->Fill(mcPart->Pt());
+       fMCCharge->Fill(mcPart->Charge()/3.);
        bEventHasATrackInRange = kTRUE;
       }
       
     }
   } // isMonteCarlo
-  if(bEventHasATrack) { hEventStatistics->Fill("MC events with tracks",1); }
+  
+  if(bEventHasATrack) { fEventStatistics->Fill("MC events with tracks",1); }
   if(bEventHasATrackInRange) 
   { 
-    hEventStatistics->Fill("MC events with tracks in range",1); 
-    hMCEventStatisticsCentrality->Fill(dCentrality);
+    fEventStatistics->Fill("MC events with tracks in range",1); 
+    fMCEventStatisticsCentrality->Fill(dCentrality);
   }
   bEventHasATrack = kFALSE;
   bEventHasATrackInRange = kFALSE;
@@ -730,14 +683,19 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   // Loop over recontructed tracks
   
   dEventZv = eventAOD->GetPrimaryVertex()->GetZ();
-  if( TMath::Abs(dEventZv) > dCutMaxZVertex ) return;
+  if( TMath::Abs(dEventZv) > GetCutMaxZVertex() ) return;
   
-  hAllEventStatisticsCentrality->Fill(dCentrality/*, nTriggerFired*/);
+  fAllEventStatisticsCentrality->Fill(dCentrality/*, nTriggerFired*/);
   
-  hEventStatistics->Fill("after Zv cut",1);
+  fEventStatistics->Fill("after Zv cut",1);
   
   dTrackZvPtEtaCent[0] = dEventZv;
   
+  if(AreRelativeCutsEnabled())
+  {
+    if(!SetRelativeCuts(eventAOD)) return;
+  }
+  
   for(Int_t itrack = 0; itrack < eventAOD->GetNumberOfTracks(); itrack++)
   {
     track = eventAOD->GetTrack(itrack);
@@ -754,21 +712,21 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
     
     Double_t dDCAxyDCAzPt[5] = { dDCA[0], dDCA[1], track->Pt(), track->Eta(), track->Phi() };
     
-    hDCAPtAll->Fill(dDCAxyDCAzPt);
+    fDCAPtAll->Fill(dDCAxyDCAzPt);
     
-    if( !(IsTrackAccepted(track, dCentrality)) ) continue;
+    if( !(IsTrackAccepted(track, dCentrality, eventAOD->GetMagneticField())) ) continue;
     
     dTrackZvPtEtaCent[1] = track->Pt();
     dTrackZvPtEtaCent[2] = track->Eta();
     dTrackZvPtEtaCent[3] = dCentrality;
     
-    if( bIsMonteCarlo )
+    if( fIsMonteCarlo )
     {
       mcPart = (AliAODMCParticle*)stack->At(TMath::Abs(track->GetLabel()));
       if( !mcPart ) { continue; }
       
       // check for charge
-      if( !(IsMCTrackAccepted(mcPart)) ) {  continue; } 
+      // if( !(IsMCTrackAccepted(mcPart)) ) {  continue; } 
       
       bIsHijingParticle = IsHijingParticle(mcPart, genHijingHeader);
       //       bIsPythiaParticle = IsPythiaParticle(mcPart, genPythiaHeader);
@@ -783,8 +741,9 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
       
       if(bIsPrimary && bIsHijingParticle)
       {
-       hnMCRecPrimZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
-       hMCDCAPtPrimary->Fill(dDCAxyDCAzPt);
+       fMCRecPrimZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
+       if( (TMath::Abs(mcPart->Eta()) < 0.8) && (dCentrality<5.) ) { fMCPdgPt->Fill(mcPart->Pt(), Form("%s",GetParticleName(mcPart->GetPdgCode())), 1); }
+       fMCDCAPtPrimary->Fill(dDCAxyDCAzPt);
       }
       
       if(!bIsPrimary /*&& !bIsHijingParticle*/)
@@ -797,12 +756,12 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
          
          if(bMotherIsHijingParticle) // only store secondaries, which come from a not embedded signal!
          {
-           hMCTrackStatusCode->Fill(Form("%d",mcPart->GetStatus()), 1);
-           if(TMath::Abs(mcPart->Eta()) < 0.8) { hMCPdgPt->Fill(mcPart->Pt(), Form("%s",GetParticleName(mcPart->GetPdgCode())), 1); }
+           fMCTrackStatusCode->Fill(Form("%d",mcPart->GetStatus()), 1);
+           
            
-           hnMCRecSecZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
-           hMCDCAPtSecondary->Fill(dDCAxyDCAzPt);
-           hMCTrackPdgCode->Fill(Form("%s_H%i_H%i",GetParticleName(moth->GetPdgCode()),bMotherIsHijingParticle, bIsHijingParticle), 1);
+           fMCRecSecZvPtEtaCent->Fill(dMCTrackZvPtEtaCent);
+           fMCDCAPtSecondary->Fill(dDCAxyDCAzPt);
+           fMCTrackPdgCode->Fill(Form("%s_H%i_H%i",GetParticleName(moth->GetPdgCode()),bMotherIsHijingParticle, bIsHijingParticle), 1);
            //    delete moth;
          }
        }       
@@ -813,7 +772,7 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
     
     // only keep prim and sec from not embedded signal
     Bool_t bKeepMCTrack = kFALSE;
-    if(bIsMonteCarlo) 
+    if(fIsMonteCarlo) 
     {
       if( (bIsHijingParticle && bIsPrimary) ^ (bMotherIsHijingParticle && !bIsPrimary) )
       {
@@ -827,66 +786,167 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
     
     bEventHasATrack = kTRUE;
     
-    hnZvPtEtaCent->Fill(dTrackZvPtEtaCent);
-    hDCAPtAccepted->Fill(dDCAxyDCAzPt);
+    fZvPtEtaCent->Fill(dTrackZvPtEtaCent);
+    fDCAPtAccepted->Fill(dDCAxyDCAzPt);
     
-    if( (dTrackZvPtEtaCent[1] > dCutPtMin) &&
-      (dTrackZvPtEtaCent[1] < dCutPtMax) &&
-      (dTrackZvPtEtaCent[2] > dCutEtaMin) &&
-      (dTrackZvPtEtaCent[2] < dCutEtaMax) )
+    if( (dTrackZvPtEtaCent[1] > GetCutPtMin()) &&
+      (dTrackZvPtEtaCent[1] < GetCutPtMax()) &&
+      (dTrackZvPtEtaCent[2] > GetCutEtaMin()) &&
+      (dTrackZvPtEtaCent[2] < GetCutEtaMax()) )
     {
       iAcceptedMultiplicity++;
       bEventHasATrackInRange = kTRUE;
-      hPt->Fill(track->Pt());
-      hCharge->Fill(track->Charge());
+      fPt->Fill(track->Pt());
+      fCharge->Fill(track->Charge());
     }
   } // end track loop
   
-  if(bEventHasATrack) { hEventStatistics->Fill("events with tracks",1); bEventHasATrack = kFALSE; }
+  if(bEventHasATrack) { fEventStatistics->Fill("events with tracks",1); bEventHasATrack = kFALSE; }
   
   if(bEventHasATrackInRange) 
   { 
-    hEventStatistics->Fill("events with tracks in range",1); 
-    hEventStatisticsCentrality->Fill(dCentrality); 
+    fEventStatistics->Fill("events with tracks in range",1); 
+    fEventStatisticsCentrality->Fill(dCentrality); 
     bEventHasATrackInRange = kFALSE; 
     
-    if(bIsEventSelectedMB) hEventStatisticsCentralityTrigger->Fill(dCentrality, 0);
-    if(bIsEventSelectedSemi) hEventStatisticsCentralityTrigger->Fill(dCentrality, 1);
-    if(bIsEventSelectedCentral) hEventStatisticsCentralityTrigger->Fill(dCentrality, 2);
+    if(bIsEventSelectedMB) fEventStatisticsCentralityTrigger->Fill(dCentrality, 0);
+    if(bIsEventSelectedSemi) fEventStatisticsCentralityTrigger->Fill(dCentrality, 1);
+    if(bIsEventSelectedCentral) fEventStatisticsCentralityTrigger->Fill(dCentrality, 2);
   }
   
   Double_t dEventZvMultCent[3] = {dEventZv, iAcceptedMultiplicity, dCentrality};
-  hnZvMultCent->Fill(dEventZvMultCent);
+  fZvMultCent->Fill(dEventZvMultCent);
   
   PostData(1, fOutputList);
   
 }
 
-Bool_t AlidNdPtAnalysisPbPbAOD::IsTrackAccepted(AliAODTrack *tr, Double_t dCentrality)
+Bool_t AlidNdPtAnalysisPbPbAOD::SetRelativeCuts(AliAODEvent *event)
+{
+  if(!event) return kFALSE; 
+  
+  AliAODTrack *tr = 0x0;
+  TH1F *hCluster = new TH1F("hCluster","hCluster",160,0,160);
+  TH1F *hCrossed = new TH1F("hCrossed","hCrossed",160,0,160);
+  
+  for(Int_t itrack = 0; itrack < event->GetNumberOfTracks(); itrack++)
+  {
+    tr = event->GetTrack(itrack);
+    if(!tr) continue;
+    
+    // do some selection already
+    //if(!(tr->TestFilterBit(AliAODTrack::kTrkGlobal)) ) { continue; } 
+    
+    Double_t dNClustersTPC = tr->GetTPCNcls();
+    Double_t dCrossedRowsTPC = tr->GetTPCClusterInfo(2,1);
+    
+    hCluster->Fill(dNClustersTPC);
+    hCrossed->Fill(dCrossedRowsTPC);
+  }
+  
+  // loop trough histogram to check, where percentage is reach
+  Double_t dTotIntCluster = hCluster->Integral();
+  Double_t dTotIntCrossed = hCrossed->Integral();
+  Float_t dIntCluster = 0;
+  Float_t dIntCrossed = 0;
+  
+  if(dTotIntCluster)
+  {
+    for(Int_t i = 0; i < hCluster->GetNbinsX(); i++)
+    {
+      if(hCluster->GetBinCenter(i) < 0) continue;
+      dIntCluster += hCluster->GetBinContent(i);
+      if(dIntCluster/dTotIntCluster > (1-GetCutPercMinNClustersTPC())) 
+      {
+       SetCutMinNClustersTPC(hCluster->GetBinCenter(i));
+       fCutPercClusters->Fill(hCluster->GetBinCenter(i));
+       break;
+      }
+    }
+  }
+  
+  if(dTotIntCrossed)
+  {
+    for(Int_t i = 0; i < hCrossed->GetNbinsX(); i++)
+    {
+      if(hCrossed->GetBinCenter(i) < 0) continue;
+      dIntCrossed += hCrossed->GetBinContent(i);
+      if(dIntCrossed/dTotIntCrossed > (1-GetCutPercMinNCrossedRowsTPC())) 
+      {
+       SetCutMinNClustersTPC(hCrossed->GetBinCenter(i));
+       fCutPercCrossed->Fill(hCrossed->GetBinCenter(i));
+       break;
+      }
+    }
+  }
+  
+  delete hCrossed;
+  delete hCluster;
+  return kTRUE;
+  
+}
+
+Bool_t AlidNdPtAnalysisPbPbAOD::IsTrackAccepted(AliAODTrack *tr, Double_t dCentrality, Double_t bMagZ)
 {
   if(!tr) return kFALSE;
   
   if(tr->Charge()==0) { return kFALSE; }
   
+  //
+  // as done in AliAnalysisTaskFragmentationFunction
+  //
+  
+  Short_t sign = tr->Charge();
+  Double_t xyz[50];
+  Double_t pxpypz[50];
+  Double_t cv[100];
+  
+  for(Int_t i = 0; i < 100; i++) cv[i] = 0;
+  for(Int_t i = 0; i < 50; i++) xyz[i] = 0;
+  for(Int_t i = 0; i < 50; i++) pxpypz[i] = 0;
+
+  tr->GetXYZ(xyz);
+  tr->GetPxPyPz(pxpypz);
+  
+  // similar error occured as this one:
+  // See https://savannah.cern.ch/bugs/?102721
+  // which is one of the two 11h re-filtering follow-ups:
+  // Andrea Dainese now first does the beam pipe
+  // check and then copies from the vtrack (was the other
+  // way around) to avoid the crash in the etp::Set()
+
+//   if(xyz[0]*xyz[0]+xyz[1]*xyz[1] > 3.*3.) { return kFALSE; }
+  
+  AliExternalTrackParam * par = new AliExternalTrackParam(xyz, pxpypz, cv, sign);
+  if(!par) { return kFALSE; }
+  AliESDtrack dummy;
+//   Double_t dLength = dummy.GetLengthInActiveZone(par,3,236, -5 ,0,0);
+//   Double_t dLengthInTPC = GetLengthInTPC(tr, 1.8, 220, bMagZ);
+
+  Double_t dLengthInTPC = dummy.GetLengthInActiveZone(par,3,236, bMagZ ,0,0);
   Double_t dNClustersTPC = tr->GetTPCNcls();
   Double_t dCrossedRowsTPC = tr->GetTPCClusterInfo(2,1);
+  Double_t dFindableClustersTPC = tr->GetTPCNclsF();
   Double_t dChi2PerClusterTPC = (dNClustersTPC>0)?tr->Chi2perNDF()*(dNClustersTPC-5)/dNClustersTPC:-1.; // see AliDielectronVarManager.h
   
   //   hAllCrossedRowsTPC->Fill(dCrossedRowsTPC);
   
-  Double_t *dCheck = new Double_t[cqMax];
-  Double_t *dKine = new Double_t[kqMax];
-  dKine[0] = tr->Pt();
-  dKine[1] = tr->Eta();
-  dKine[2] = tr->Phi();
-  
-  dCheck[0] = dCrossedRowsTPC;
-  dCheck[1] = dNClustersTPC;
-  dCheck[2] = dChi2PerClusterTPC;
+  Double_t dCheck[cqMax] = {dCrossedRowsTPC, dNClustersTPC, dChi2PerClusterTPC, dLengthInTPC};// = new Double_t[cqMax];
+  Double_t dKine[kqMax] = {tr->Pt(), tr->Eta(), tr->Phi()};// = new Double_t[kqMax];
+  //   dKine[0] = tr->Pt();
+  //   dKine[1] = tr->Eta();
+  //   dKine[2] = tr->Phi();
+  //   
+  //   dCheck[0] = dCrossedRowsTPC;
+  //   dCheck[1] = dNClustersTPC;
+  //   dCheck[2] = dChi2PerClusterTPC;
   
   
   FillDebugHisto(dCheck, dKine, dCentrality, kFALSE);
   
+  // first cut on length
+  
+  if( DoCutLengthInTPCPtDependent() && ( dLengthInTPC < GetPrefactorLengthInTPCPtDependent()*(130-5*TMath::Abs(1./tr->Pt())) )  ) { return kFALSE; }
   
   // filter bit 5
   if(!(tr->TestFilterBit(AliAODTrack::kTrkGlobal)) ) { return kFALSE; } 
@@ -896,70 +956,77 @@ Bool_t AlidNdPtAnalysisPbPbAOD::IsTrackAccepted(AliAODTrack *tr, Double_t dCentr
   
   //   hFilterCrossedRowsTPC->Fill(dCrossedRowsTPC);
   
-  if(dCrossedRowsTPC < GetCutMinNCrossedRowsTPC()) { return kFALSE; }
   
-  // do a relativ cut in Nclusters, both time at 80% of mean
-//   if(bIsMonteCarlo) 
-//   { 
-//     if(dNClustersTPC < 88) { return kFALSE; }
-//   }
-//   else
-//   {
-//     if(dNClustersTPC < 76) { return kFALSE; }
-//   }
+   if(dFindableClustersTPC == 0) {return kFALSE; }
+   if(dCrossedRowsTPC < GetCutMinNCrossedRowsTPC()) { return kFALSE; }
+   if( (dCrossedRowsTPC/dFindableClustersTPC) < GetCutMinRatioCrossedRowsOverFindableClustersTPC() ) { return kFALSE; }
+   if(dNClustersTPC < GetCutMinNClustersTPC()) { return kFALSE; }
   
+  if (!(tr->GetStatus() & AliVTrack::kITSrefit)) { return kFALSE; } // no ITS refit
   
-  FillDebugHisto(dCheck, dKine, dCentrality, kTRUE);
-  
-  
-  //   hAccNclsTPC->Fill(dNClustersTPC);
-  //   hAccCrossedRowsTPC->Fill(dCrossedRowsTPC);
-  //   Double_t dFindableClustersTPC = tr->GetTPCNclsF();
-  //   Double_t dChi2PerClusterTPC = (dNClustersTPC>0)?tr->Chi2perNDF()*(dNClustersTPC-5)/dNClustersTPC:-1.; // see AliDielectronVarManager.h
-  //   
-  //   Bool_t bIsFromKink = kFALSE;
-  //   if(tr->GetProdVertex()->GetType() == AliAODVertex::kKink) bIsFromKink = kTRUE;
-  //   
-  //   // from AliAnalysisTaskPIDqa.cxx
-  //   ULong_t uStatus = tr->GetStatus();
-  //   Bool_t bHasRefitTPC = kFALSE;
-  //   Bool_t bHasRefitITS = kFALSE;
-  //   
-  //   if ((uStatus & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) bHasRefitTPC = kTRUE;
-  //   if ((uStatus & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) bHasRefitITS = kTRUE;
-  //   
-  //   // from AliDielectronVarManager.h
-  //   Bool_t bHasHitInSPD = kFALSE;
-  //   for (Int_t iC=0; iC<2; iC++) 
-  //   {
-    //     if (((tr->GetITSClusterMap()) & (1<<(iC))) > 0) {  bHasHitInSPD = kTRUE;  }
+  // do a relativ cut in Nclusters, both time at 80% of mean
+  //   if(fIsMonteCarlo) 
+  //   { 
+    //     if(dNClustersTPC < 88) { return kFALSE; }
     //   }
-    //   
-    //   Double_t dNClustersITS = tr->GetITSNcls();
-    
-    // cuts to be done:
-    // TPC  
-    //   esdTrackCuts->SetMinNCrossedRowsTPC(70);
-    //   esdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
-    //   
-    //   esdTrackCuts->SetMaxChi2PerClusterTPC(4);
-    //   esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
-    //   esdTrackCuts->SetRequireTPCRefit(kTRUE);
-    // ITS
-    //   esdTrackCuts->SetRequireITSRefit(kTRUE);
-    //   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,  AliESDtrackCuts::kAny);
-    //   
-    //   esdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
-    //   esdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
-    //   
-    //   esdTrackCuts->SetMaxDCAToVertexZ(2);
-    //   esdTrackCuts->SetDCAToVertex2D(kFALSE);
-    //   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
-    //   
-    //   esdTrackCuts->SetMaxChi2PerClusterITS(36);
-    
-    
-    return kTRUE;
+    //   else
+    //   {
+      //     if(dNClustersTPC < 76) { return kFALSE; }
+      //   }
+      
+      
+      FillDebugHisto(dCheck, dKine, dCentrality, kTRUE);
+      
+      
+      //   hAccNclsTPC->Fill(dNClustersTPC);
+      //   hAccCrossedRowsTPC->Fill(dCrossedRowsTPC);
+      //   Double_t dFindableClustersTPC = tr->GetTPCNclsF();
+      //   Double_t dChi2PerClusterTPC = (dNClustersTPC>0)?tr->Chi2perNDF()*(dNClustersTPC-5)/dNClustersTPC:-1.; // see AliDielectronVarManager.h
+      //   
+      //   Bool_t bIsFromKink = kFALSE;
+      //   if(tr->GetProdVertex()->GetType() == AliAODVertex::kKink) bIsFromKink = kTRUE;
+      //   
+      //   // from AliAnalysisTaskPIDqa.cxx
+      //   ULong_t uStatus = tr->GetStatus();
+      //   Bool_t bHasRefitTPC = kFALSE;
+      //   Bool_t bHasRefitITS = kFALSE;
+      //   
+      //   if ((uStatus & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) bHasRefitTPC = kTRUE;
+      //   if ((uStatus & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) bHasRefitITS = kTRUE;
+      //   
+      //   // from AliDielectronVarManager.h
+      //   Bool_t bHasHitInSPD = kFALSE;
+      //   for (Int_t iC=0; iC<2; iC++) 
+      //   {
+       //     if (((tr->GetITSClusterMap()) & (1<<(iC))) > 0) {  bHasHitInSPD = kTRUE;  }
+       //   }
+       //   
+       //   Double_t dNClustersITS = tr->GetITSNcls();
+       
+       // cuts to be done:
+       // TPC  
+       //   esdTrackCuts->SetMinNCrossedRowsTPC(70);
+       //   esdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
+       //   
+       //   esdTrackCuts->SetMaxChi2PerClusterTPC(4);
+       //   esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+       //   esdTrackCuts->SetRequireTPCRefit(kTRUE);
+       // ITS
+       //   esdTrackCuts->SetRequireITSRefit(kTRUE);
+       //   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,       AliESDtrackCuts::kAny);
+       //   
+       //   esdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
+       //   esdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
+       //   
+       //   esdTrackCuts->SetMaxDCAToVertexZ(2);
+       //   esdTrackCuts->SetDCAToVertex2D(kFALSE);
+       //   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+       //   
+       //   esdTrackCuts->SetMaxChi2PerClusterITS(36);
+       
+       //     delete [] dKine;
+       //     delete [] dCheck;
+       return kTRUE;
 }
 
 Bool_t AlidNdPtAnalysisPbPbAOD::FillDebugHisto(Double_t *dCrossCheckVar, Double_t *dKineVar, Double_t dCentrality, Bool_t bIsAccepted)
@@ -969,16 +1036,22 @@ Bool_t AlidNdPtAnalysisPbPbAOD::FillDebugHisto(Double_t *dCrossCheckVar, Double_
     for(Int_t iCrossCheck = 0; iCrossCheck < cqMax; iCrossCheck++)
     {
       Double_t dFillIt[5] = {dCrossCheckVar[iCrossCheck], dKineVar[0], dKineVar[1], dKineVar[2], dCentrality};
-      hCrossCheckAcc[iCrossCheck]->Fill(dFillIt);
+      fCrossCheckAcc[iCrossCheck]->Fill(dFillIt);
     }
+    
+    fCrossCheckRowsLengthAcc->Fill(dCrossCheckVar[cqLength], dCrossCheckVar[cqCrossedRows]);
+    fCrossCheckClusterLengthAcc->Fill(dCrossCheckVar[cqLength], dCrossCheckVar[cqNcluster]);
   }
   else
   {
     for(Int_t iCrossCheck = 0; iCrossCheck < cqMax; iCrossCheck++)
     {
       Double_t dFillIt[5] = {dCrossCheckVar[iCrossCheck], dKineVar[0], dKineVar[1], dKineVar[2], dCentrality};
-      hCrossCheckAll[iCrossCheck]->Fill(dFillIt);
+      fCrossCheckAll[iCrossCheck]->Fill(dFillIt);
     }
+    
+    fCrossCheckRowsLength->Fill(dCrossCheckVar[cqLength], dCrossCheckVar[cqCrossedRows]);
+    fCrossCheckClusterLength->Fill(dCrossCheckVar[cqLength], dCrossCheckVar[cqNcluster]);
   }
   
   return kTRUE;
@@ -1088,6 +1161,7 @@ AliGenPythiaEventHeader* AlidNdPtAnalysisPbPbAOD::GetPythiaEventHeader(AliAODMCH
 Bool_t AlidNdPtAnalysisPbPbAOD::IsHijingParticle(const AliAODMCParticle *part, AliGenHijingEventHeader* hijingGenHeader){
   
   // Check whether a particle is from Hijing or some injected 
+  // returns kFALSE if particle is injected
   
   if(part->Label() > (hijingGenHeader->NProduced()-1)) return kFALSE;
   return kTRUE;
index bbb1bd85fb35f584cccd88a86d666ff7f761e11d..4ffc50c9c04b232f337b5771209515601e5ec1d0 100644 (file)
@@ -46,19 +46,19 @@ class THnSparse;
 #include "AliGenHijingEventHeader.h"
 #include "AliGenPythiaEventHeader.h"
 #include "AliExternalTrackParam.h"
+#include "AliESDtrack.h"
 
 #include "TSystem.h"
 #include "TROOT.h"
 
 class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
   public :
-    enum CheckQuantity { cqCrossedRows = 0, cqNcluster = 1, cqChi = 2 };
+    enum CheckQuantity { cqCrossedRows = 0, cqNcluster = 1, cqChi = 2, cqLength = 3 };
     enum KinematicQuantity { kqPt = 0, kqEta = 1, kqPhi = 2 };
-    enum MaxCheckQuantity { cqMax = 3 };
+    enum MaxCheckQuantity { cqMax = 4 };
     enum MaxKinematicQuantity { kqMax = 3 };
     
-    AlidNdPtAnalysisPbPbAOD(); 
-    AlidNdPtAnalysisPbPbAOD(const char *name);
+    AlidNdPtAnalysisPbPbAOD(const char *name = "dNdPtPbPbAOD");
     ~AlidNdPtAnalysisPbPbAOD();
     
     virtual void UserCreateOutputObjects();
@@ -77,51 +77,81 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     void SetBinsPhi(Int_t nbins, Double_t* edges)              { Printf("[I] Setting Phi Bins"); fPhiNbins = nbins; fBinsPhi = GetArrayClone(nbins,edges); }
     
     // set event cut variables
-    void SetCutMaxZVertex( Double_t d)                                 { dCutMaxZVertex = d; }
+    void SetCutMaxZVertex( Double_t d)                                 { fCutMaxZVertex = d; }
+    Double_t GetCutMaxZVertex()                                                { return fCutMaxZVertex; }
     
     // set track kinematic cut parameters
-    void SetCutPtRange(Double_t ptmin, Double_t ptmax)                 { dCutPtMin = ptmin; dCutPtMax = ptmax; }
-    void SetCutEtaRange(Double_t etamin, Double_t etamax)              { dCutEtaMin = etamin; dCutEtaMax = etamax; }
-    
-    // set track quality cut parameters
-    void SetCutRequireTPCRefit(Bool_t *b)                              { bCutRequireTPCRefit = b; } 
-    void SetCutMinNCrossedRowsTPC(Double_t d)                          { dCutMinNumberOfCrossedRows = d; }    
-    void SetCutMinRatioCrossedRowsOverFindableClustersTPC(Double_t d)  { dCutMinRatioCrossedRowsOverFindableClustersTPC = d; }
-    void SetCutMaxChi2PerClusterTPC(Double_t d)                        { dCutMaxChi2PerClusterTPC = d; }
-    void SetCutMaxFractionSharedTPCClusters(Double_t d)                { dCutMaxFractionSharedTPCClusters = d; }
-    void SetCutMaxDCAToVertexZ(Double_t d)                             { dCutMaxDCAToVertexZ = d; }
-    void SetCutMaxDCAToVertexXY(Double_t d)                            { dCutMaxDCAToVertexXY = d; }
-    void SetCutRequireITSRefit(Bool_t *b)                              { bCutRequireITSRefit = b; } 
-    void SetCutMaxChi2PerClusterITS(Double_t d)                        { dCutMaxChi2PerClusterITS = d; }
-    void SetCutDCAToVertex2D(Bool_t *b)                                { dCutDCAToVertex2D = b; } 
-    void SetCutRequireSigmaToVertex(Bool_t *b)                                 { dCutRequireSigmaToVertex = b; } 
+    void SetCutPtRange(Double_t ptmin, Double_t ptmax)                 { fCutPtMin = ptmin; fCutPtMax = ptmax; }
+    Double_t GetCutPtMin()                                             { return fCutPtMin; }
+    Double_t GetCutPtMax()                                             { return fCutPtMax; }
+    
+    void SetCutEtaRange(Double_t etamin, Double_t etamax)              { fCutEtaMin = etamin; fCutEtaMax = etamax; }
+    Double_t GetCutEtaMin()                                            { return fCutEtaMin; }
+    Double_t GetCutEtaMax()                                            { return fCutEtaMax; }
+    
+    void EnableRelativeCuts()                                          { Printf("[I] Relative Cuts enabled"); fUseRelativeCuts = kTRUE; }
+    Bool_t AreRelativeCutsEnabled()                                    { return fUseRelativeCuts; }
+    
+    // setter and getter track quality cut parameters
+    void SetCutRequireTPCRefit(Bool_t *b)                              { fCutRequireTPCRefit = b; } 
+    Bool_t IsTPCRefitRequired()                                        { return fCutRequireTPCRefit; } 
+    
+    void SetCutMinNClustersTPC(Double_t d)                             { fCutMinNumberOfClusters = d; }
+    Double_t GetCutMinNClustersTPC()                                   { return fCutMinNumberOfClusters; }
+    
+    void SetCutPercMinNClustersTPC(Double_t d)                         { Printf("[I] Take only %.2f%% tracks with most clusters", d*100.); fCutPercMinNumberOfClusters = d; }
+    Double_t GetCutPercMinNClustersTPC()                               { return fCutPercMinNumberOfClusters; }
+    
+    void SetCutMinNCrossedRowsTPC(Double_t d)                          { fCutMinNumberOfCrossedRows = d; }    
+    Double_t GetCutMinNCrossedRowsTPC()                                        { return fCutMinNumberOfCrossedRows; }
+    
+    void SetCutPercMinNCrossedRowsTPC(Double_t d)                      { Printf("[I] Take only %.2f%% tracks with most crossedRows", d*100.); fCutPercMinNumberOfCrossedRows = d; }    
+    Double_t GetCutPercMinNCrossedRowsTPC()                            { return fCutPercMinNumberOfCrossedRows; }
+    
+    void SetCutMinRatioCrossedRowsOverFindableClustersTPC(Double_t d)  { fCutMinRatioCrossedRowsOverFindableClustersTPC = d; }
+    Double_t GetCutMinRatioCrossedRowsOverFindableClustersTPC()                { return fCutMinRatioCrossedRowsOverFindableClustersTPC; }
+    
+    void SetCutLengthInTPCPtDependent()                                        { fCutLengthInTPCPtDependent = kTRUE; }
+    Bool_t DoCutLengthInTPCPtDependent()                               { return fCutLengthInTPCPtDependent; }
+    
+    void SetPrefactorLengthInTPCPtDependent(Double_t d)                        { fPrefactorLengthInTPCPtDependent = d; }
+    Double_t GetPrefactorLengthInTPCPtDependent()                      { return fPrefactorLengthInTPCPtDependent; }
+     
+    void SetCutMaxChi2PerClusterTPC(Double_t d)                        { fCutMaxChi2PerClusterTPC = d; }
+    void SetCutMaxFractionSharedTPCClusters(Double_t d)                { fCutMaxFractionSharedTPCClusters = d; }
+    void SetCutMaxDCAToVertexZ(Double_t d)                             { fCutMaxDCAToVertexZ = d; }
+    void SetCutMaxDCAToVertexXY(Double_t d)                            { fCutMaxDCAToVertexXY = d; }
+    void SetCutRequireITSRefit(Bool_t *b)                              { fCutRequireITSRefit = b; } 
+    void SetCutMaxChi2PerClusterITS(Double_t d)                        { fCutMaxChi2PerClusterITS = d; }
+    void SetCutDCAToVertex2D(Bool_t *b)                                { fCutDCAToVertex2D = b; } 
+    void SetCutRequireSigmaToVertex(Bool_t *b)                                 { fCutRequireSigmaToVertex = b; } 
     void SetCutMaxDCAToVertexXYPtDep(Double_t d0, Double_t d1, Double_t d2)
     {
-      dCutMaxDCAToVertexXYPtDepPar0 = d0;
-      dCutMaxDCAToVertexXYPtDepPar1 = d1;
-      dCutMaxDCAToVertexXYPtDepPar2 = d2;
+      fCutMaxDCAToVertexXYPtDepPar0 = d0;
+      fCutMaxDCAToVertexXYPtDepPar1 = d1;
+      fCutMaxDCAToVertexXYPtDepPar2 = d2;
     }
-    void SetCutAcceptKinkDaughters(Bool_t *b)                          { bCutAcceptKinkDaughters = b; } 
-    void SetCutMaxChi2TPCConstrainedGlobal(Double_t d)                         { dCutMaxChi2TPCConstrainedGlobal = d; }
-    
-    // getter for qualtiy track cuts
-    Double_t GetCutMinNCrossedRowsTPC()                                        { return dCutMinNumberOfCrossedRows; }
-    
+    void SetCutAcceptKinkDaughters(Bool_t *b)                          { fCutAcceptKinkDaughters = b; } 
+    void SetCutMaxChi2TPCConstrainedGlobal(Double_t d)                         { fCutMaxChi2TPCConstrainedGlobal = d; }
+       
     // fill function for cross check histos
     Bool_t FillDebugHisto(Double_t *dCrossCheckVar, Double_t *dKineVar, Double_t dCentrality, Bool_t bIsAccepted);
     
     // getter for DCA
     Bool_t GetDCA(const AliAODTrack *track, AliAODEvent *evt, Double_t d0z0[2]);
     
-    THnSparseF *GetHistZvPtEtaCent() const { return hnZvPtEtaCent; }
-    TH1F *GetHistEventStatistics() const { return hEventStatistics; }
+    THnSparseF *GetHistZvPtEtaCent() const { return fZvPtEtaCent; }
+    TH1F *GetHistEventStatistics() const { return fEventStatistics; }
     
     const char * GetParticleName(Int_t pdg);
     
     AliGenHijingEventHeader* GetHijingEventHeader(AliAODMCHeader *header);
     AliGenPythiaEventHeader* GetPythiaEventHeader(AliAODMCHeader *header);
     
-    Bool_t IsTrackAccepted(AliAODTrack *tr, Double_t dCentrality);
+    
+    Bool_t SetRelativeCuts(AliAODEvent *event);
+    
+    Bool_t IsTrackAccepted(AliAODTrack *tr, Double_t dCentrality, Double_t bMagZ);
     Bool_t IsMCTrackAccepted(AliAODMCParticle *part);
     
     Bool_t IsHijingParticle(const AliAODMCParticle *part, AliGenHijingEventHeader* hijingGenHeader);
@@ -135,62 +165,74 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     TList      *fOutputList;
     
     // Histograms
-    TH1F       *hPt; // simple pT histogramm
-    TH1F       *hMCPt; // simple pT truth histogramm
-    THnSparseF         *hnZvPtEtaCent; //-> Zv:Pt:Eta:Cent
-    THnSparseF         *hnMCRecPrimZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
-    THnSparseF         *hnMCGenZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
-    THnSparseF         *hnMCRecSecZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent, only secondaries
-    TH1F       *hEventStatistics; // contains statistics of number of events after each cut
-    TH1F       *hEventStatisticsCentrality; // contains number of events vs centrality, events need to have a track in kinematic range
-    TH1F       *hMCEventStatisticsCentrality; // contains MC number of events vs centrality, events need to have a track in kinematic range
-    TH1F       *hAllEventStatisticsCentrality; // contains number of events vs centrality, events need to be triggered
-    TH2F       *hEventStatisticsCentralityTrigger; // contains number of events vs centrality in 1% bins vs trigger
-    THnSparseF *hnZvMultCent; // Zv:Mult:Cent
-    TH1F       *hTriggerStatistics; // contains number of events per trigger
-    TH1F       *hMCTrackPdgCode; // contains statistics of pdg codes of tracks
-    TH1F       *hMCTrackStatusCode; // contains statistics of status codes of tracks
-    TH1F       *hCharge; // charge distribution in data
-    TH1F       *hMCCharge; // charge distribution in MC
-    TH2F       *hMCPdgPt; // PDGvs PT for MC Particles
-    TH1F       *hMCHijingPrim; // number of particles, which are Hijing particles and primaries
-    THnSparseF *hDCAPtAll; //control histo: DCAz:DCAxy:pT:eta:phi for all reconstructed tracks
-    THnSparseF *hDCAPtAccepted; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco tracks
-    THnSparseF *hMCDCAPtSecondary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are secondaries (using MC info)
-    THnSparseF *hMCDCAPtPrimary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are primaries (using MC info)
-    THnF       *hCrossCheckAll[3]; //control histo: {CrossedRows,Ncluster,Chi} vs pT,eta,phi,Centrality for all tracks
-    THnF       *hCrossCheckAcc[3]; //control histo: {CrossedRows,Ncluster,Chi} vs pT,eta,phi,Centrality after cuts
+    TH1F       *fPt; // simple pT histogramm
+    TH1F       *fMCPt; // simple pT truth histogramm
+    THnSparseF         *fZvPtEtaCent; //-> Zv:Pt:Eta:Cent
+    THnSparseF         *fMCRecPrimZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
+    THnSparseF         *fMCGenZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
+    THnSparseF         *fMCRecSecZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent, only secondaries
+    TH1F       *fEventStatistics; // contains statistics of number of events after each cut
+    TH1F       *fEventStatisticsCentrality; // contains number of events vs centrality, events need to have a track in kinematic range
+    TH1F       *fMCEventStatisticsCentrality; // contains MC number of events vs centrality, events need to have a track in kinematic range
+    TH1F       *fAllEventStatisticsCentrality; // contains number of events vs centrality, events need to be triggered
+    TH2F       *fEventStatisticsCentralityTrigger; // contains number of events vs centrality in 1% bins vs trigger
+    THnSparseF *fZvMultCent; // Zv:Mult:Cent
+    TH1F       *fTriggerStatistics; // contains number of events per trigger
+    TH1F       *fMCTrackPdgCode; // contains statistics of pdg codes of tracks
+    TH1F       *fMCTrackStatusCode; // contains statistics of status codes of tracks
+    TH1F       *fCharge; // charge distribution in data
+    TH1F       *fMCCharge; // charge distribution in MC
+    TH2F       *fMCPdgPt; // PDGvs PT for MC Particles
+    TH1F       *fMCHijingPrim; // number of particles, which are Hijing particles and primaries
+    THnSparseF *fDCAPtAll; //control histo: DCAz:DCAxy:pT:eta:phi for all reconstructed tracks
+    THnSparseF *fDCAPtAccepted; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco tracks
+    THnSparseF *fMCDCAPtSecondary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are secondaries (using MC info)
+    THnSparseF *fMCDCAPtPrimary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are primaries (using MC info)
+    THnF       *fCrossCheckAll[4]; //control histo: {CrossedRows,Ncluster,Chi} vs pT,eta,phi,Centrality for all tracks
+    THnF       *fCrossCheckAcc[4]; //control histo: {CrossedRows,Ncluster,Chi} vs pT,eta,phi,Centrality after cuts
+    TH1F       *fCutPercClusters; // control histo: number of clusters, where the relative cut has been set e-by-e
+    TH1F       *fCutPercCrossed; // control histo: number of crossed rows, where the relative cut has been set e-by-e
+    TH2F       *fCrossCheckRowsLength; // control histo: number of crossed rows vs length in TPC
+    TH2F       *fCrossCheckClusterLength; // control histo: number of clusters vs length in TPC
+    TH2F       *fCrossCheckRowsLengthAcc; // control histo: number of crossed rows vs length in TPC for all accepted tracks
+    TH2F       *fCrossCheckClusterLengthAcc; // control histo: number of clusters vs length in TPC for all accepted tracks
     
     
     // global variables
-    Bool_t bIsMonteCarlo;
+    Bool_t fIsMonteCarlo;
     
     // event cut variables
-    Double_t dCutMaxZVertex;
+    Double_t fCutMaxZVertex;
     
     // track kinematic cut variables
-    Double_t dCutPtMin;
-    Double_t dCutPtMax;
-    Double_t dCutEtaMin;
-    Double_t dCutEtaMax;
+    Double_t fCutPtMin;
+    Double_t fCutPtMax;
+    Double_t fCutEtaMin;
+    Double_t fCutEtaMax;
     
     // track quality cut variables
-    Bool_t     bCutRequireTPCRefit;
-    Double_t   dCutMinNumberOfCrossedRows;
-    Double_t   dCutMinRatioCrossedRowsOverFindableClustersTPC;
-    Double_t   dCutMaxChi2PerClusterTPC;
-    Double_t   dCutMaxFractionSharedTPCClusters;
-    Double_t   dCutMaxDCAToVertexZ;
-    Double_t   dCutMaxDCAToVertexXY;
-    Bool_t     bCutRequireITSRefit;
-    Double_t   dCutMaxChi2PerClusterITS;
-    Bool_t     dCutDCAToVertex2D;
-    Bool_t     dCutRequireSigmaToVertex;
-    Double_t   dCutMaxDCAToVertexXYPtDepPar0;
-    Double_t   dCutMaxDCAToVertexXYPtDepPar1;
-    Double_t   dCutMaxDCAToVertexXYPtDepPar2;
-    Bool_t     bCutAcceptKinkDaughters;
-    Double_t   dCutMaxChi2TPCConstrainedGlobal;
+    Bool_t     fUseRelativeCuts;
+    Bool_t     fCutRequireTPCRefit;
+    Double_t   fCutMinNumberOfClusters;
+    Double_t   fCutPercMinNumberOfClusters;
+    Double_t   fCutMinNumberOfCrossedRows;
+    Double_t   fCutPercMinNumberOfCrossedRows;
+    Double_t   fCutMinRatioCrossedRowsOverFindableClustersTPC;
+    Double_t   fCutMaxChi2PerClusterTPC;
+    Double_t   fCutMaxFractionSharedTPCClusters;
+    Double_t   fCutMaxDCAToVertexZ;
+    Double_t   fCutMaxDCAToVertexXY;
+    Bool_t     fCutRequireITSRefit;
+    Double_t   fCutMaxChi2PerClusterITS;
+    Bool_t     fCutDCAToVertex2D;
+    Bool_t     fCutRequireSigmaToVertex;
+    Double_t   fCutMaxDCAToVertexXYPtDepPar0;
+    Double_t   fCutMaxDCAToVertexXYPtDepPar1;
+    Double_t   fCutMaxDCAToVertexXYPtDepPar2;
+    Bool_t     fCutAcceptKinkDaughters;
+    Double_t   fCutMaxChi2TPCConstrainedGlobal;
+    Bool_t     fCutLengthInTPCPtDependent;
+    Double_t   fPrefactorLengthInTPCPtDependent;
     
     //binning for THNsparse
     Int_t fMultNbins;
@@ -215,7 +257,7 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     AlidNdPtAnalysisPbPbAOD(const AlidNdPtAnalysisPbPbAOD&); // not implemented
     AlidNdPtAnalysisPbPbAOD& operator=(const AlidNdPtAnalysisPbPbAOD&); // not implemented  
     
-    ClassDef(AlidNdPtAnalysisPbPbAOD,3); // has to be at least 1, otherwise not streamable...
+    ClassDef(AlidNdPtAnalysisPbPbAOD,4); // has to be at least 1, otherwise not streamable...
 };
 
 #endif
index 46f236e3284403614a2fea80b6ffb7969ddfab55..24922abc348459f079a2756e9cae34445a8cca51 100644 (file)
@@ -55,7 +55,7 @@ public :
   TFolder* GetAnalysisFolder() const {return fAnalysisFolder;}
 
   // Fill control histograms
-  void SetHistogramsOn(const Bool_t histOn=kTRUE) {fHistogramsOn = histOn;}
+  void SetHistogramsOn(Bool_t histOn=kTRUE) {fHistogramsOn = histOn;}
   Bool_t IsHistogramsOn() const {return fHistogramsOn;}
 
   // Define 0-multiplicity bin for LHC
index 4b03bdd380db82aedfb03503804c9f996cf37d22..9e10febbc2122a902a93a0549d875b1994411dd4 100644 (file)
@@ -1,7 +1,8 @@
 AlidNdPtAnalysisPbPbAOD *AddTask_dNdPt_PbPbAOD( UInt_t uTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral , 
-                                               Double_t dNCrossedRowsTPC = 120, 
+                                               Double_t dNCrossedRowsTPC = 100, 
                                                char *contName = "dNdPtPbPbAOD")
 {
+  Printf("===============BAUM================");
   // Creates, configures and attaches to the train a cascades check task.
   // Get the pointer to the existing analysis manager via the static access method.
   //==============================================================================
@@ -28,7 +29,16 @@ AlidNdPtAnalysisPbPbAOD *AddTask_dNdPt_PbPbAOD( UInt_t uTriggerMask = AliVEvent:
   task->SelectCollisionCandidates(uTriggerMask);
   
   task->SetCutMinNCrossedRowsTPC(dNCrossedRowsTPC);
-  
+  task->SetCutMinNClustersTPC(0);
+  //task->SetCutLengthInTPCPtDependent();
+  //task->SetPrefactorLengthInTPCPtDependent(0.85);
+//   task->EnableRelativeCuts();
+//   task->SetCutPercMinNClustersTPC(1.0);
+//   task->SetCutPercMinNCrossedRowsTPC(1.0);
+  
+  Double_t binsPtCheck[] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 3.0, 4.0, 5.0, 10.0, 13.0, 15.0, 20.0, 25.0, 30.0, 40.0, 50.0, 70.0, 100.0, 150.0, 200.0}; 
+  Int_t nBinPtCheck = sizeof(binsPtCheck)/sizeof(Double_t);
+  task->SetBinsPtCheck(nBinPtCheck, binsPtCheck);
   ::Info("AddTask_dNdPt_PbPbAOD",Form("CrossedRowCut set to %.0f", task->GetCutMinNCrossedRowsTPC()));
   
   mgr->AddTask(task);
index 84a459e21762c9d831590011337922b0a0094248..f81b79dd035b1c348ca0241823b7856c33a929b1 100644 (file)
@@ -13,7 +13,7 @@ AliAnalysisTaskSE *AddTaskNuclei(Bool_t kAOD=kTRUE, Double_t CentralityMin=0.0,
     return 0;
   }
   else if(1){ // check ESD
-
+    //.......
   }
 
   //========= Add tender to the ANALYSIS manager and set default storage =====
index df2391c537a1b2e8f2a58d6dfbd038ab7967cb4f..8a23e06d8445a9ca501627cd74d8b80981fd5689 100644 (file)
@@ -22,7 +22,7 @@
 #include "AliAnalysisManager.h"
 #include "TFile.h"
 
-ClassImp(AliAnalysisNucleiMass)
+ClassImp(AliAnalysisNucleiMass)//...
 
 //_____________________________________________________________________________
 AliAnalysisNucleiMass::AliAnalysisNucleiMass():
index 6a67e6029984af227797f2c84ca022e3d739fc54..b06c4dd77bd201ca86ddadf9931f9fda49a4d2fa 100644 (file)
@@ -124,9 +124,9 @@ class AliAnalysisNucleiMass : public AliAnalysisTaskSE {
   TProfile *prPmeanVsBetaGamma[nBconf][18];       //!<p>/p vs beta*gamma (profile)
 
   //------------------------------Methods----------------------------------------
-  void GetMassFromPvertex(Double_t beta, Double_t p, Double_t &M2);
-  void GetZTpc(Double_t dedx, Double_t pTPC, Double_t M2, Double_t &Z2);
-  void GetMassFromExpTimes(Double_t beta, Double_t *IntTimes, Double_t *Mass2, Int_t iCorr, Double_t pVtx, Int_t FlagPid, Double_t charge);
+  void GetMassFromPvertex(Double_t beta, Double_t p, Double_t &M2);       //...*
+  void GetZTpc(Double_t dedx, Double_t pTPC, Double_t M2, Double_t &Z2);  //...*
+  void GetMassFromExpTimes(Double_t beta, Double_t *IntTimes, Double_t *Mass2, Int_t iCorr, Double_t pVtx, Int_t FlagPid, Double_t charge); //...*
  
   ClassDef(AliAnalysisNucleiMass, 1);
 };
index 46cad5f474bbd75ca3bc242912eb4bc472f0e875..c5ef326f5cd0cbad6c9e12fc8f41e0fa474cb48a 100644 (file)
@@ -37,7 +37,7 @@ AliAnalysisTaskSpectraAllChAOD* AddTaskSpectraAllChAOD(
       return NULL;\r
     }\r
   \r
-  AliSpectraAODTrackCuts  * trcuts = new AliSpectraAODTrackCuts("Track Cuts");  \r
+  AliSpectraAODTrackCuts  * trcuts = new AliSpectraAODTrackCuts(Form("TrackCuts%s",opt.Data()));  \r
   trcuts->SetDCA(DCA);\r
   trcuts->SetTrackBits(trkbit);\r
   trcuts->SetPt(pt);\r
@@ -46,7 +46,7 @@ AliAnalysisTaskSpectraAllChAOD* AddTaskSpectraAllChAOD(
   trcuts->SetMinTPCcls(minNclsTPC);\r
   trcuts->PrintCuts();\r
   \r
-  AliSpectraAODEventCuts * evcuts = new AliSpectraAODEventCuts("Event Cuts");\r
+  AliSpectraAODEventCuts * evcuts = new AliSpectraAODEventCuts(Form("EventCuts%s",opt.Data()));\r
   evcuts->SetQVectorCut(QvecCutMin,QvecCutMax);\r
   evcuts->SetCentralityCutMax(CentCutMax);  \r
   evcuts->SetCentralityCutMin(CentCutMin);\r
@@ -54,6 +54,7 @@ AliAnalysisTaskSpectraAllChAOD* AddTaskSpectraAllChAOD(
   evcuts->PrintCuts();\r
   \r
   AliHelperPID *pid=new AliHelperPID();\r
+  pid->SetName(Form("HelperPID%s",opt.Data()));\r
   pid->SetNSigmaCut(nsigmacut);\r
   pid->SetPIDType(PIDtype);\r
   if(PIDtype==3){\r
@@ -84,10 +85,10 @@ AliAnalysisTaskSpectraAllChAOD* AddTaskSpectraAllChAOD(
   \r
   cout<<"outputFileName:  "<<outputFileName<<endl;\r
   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();      \r
-  AliAnalysisDataContainer *coutputpt1 = mgr->CreateContainer("chist",                      TList::Class(),     AliAnalysisManager::kOutputContainer,outputFileName);\r
-  AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer("cvcut", AliSpectraAODEventCuts::Class(),     AliAnalysisManager::kOutputContainer,outputFileName);\r
-  AliAnalysisDataContainer *coutputpt3 = mgr->CreateContainer("ctcut", AliSpectraAODTrackCuts::Class(),     AliAnalysisManager::kOutputContainer, outputFileName);\r
-  AliAnalysisDataContainer *coutputpt4 = mgr->CreateContainer("cpid",               AliHelperPID::Class(),     AliAnalysisManager::kOutputContainer, outputFileName);\r
+  AliAnalysisDataContainer *coutputpt1 = mgr->CreateContainer(Form("chist%s",opt.Data()),                      TList::Class(),     AliAnalysisManager::kOutputContainer,outputFileName);\r
+  AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer(Form("cvcut%s",opt.Data()), AliSpectraAODEventCuts::Class(),     AliAnalysisManager::kOutputContainer,outputFileName);\r
+  AliAnalysisDataContainer *coutputpt3 = mgr->CreateContainer(Form("ctcut%s",opt.Data()), AliSpectraAODTrackCuts::Class(),     AliAnalysisManager::kOutputContainer, outputFileName);\r
+  AliAnalysisDataContainer *coutputpt4 = mgr->CreateContainer(Form("cpid%s",opt.Data()),               AliHelperPID::Class(),     AliAnalysisManager::kOutputContainer, outputFileName);\r
   mgr->AddTask(task);\r
   \r
   mgr->ConnectInput(task, 0, cinput);\r
index c30d79f932b6510b143d4a17eb187c97171186e5..25810a0001be17b1c973309530e58cc044759fc0 100644 (file)
@@ -36,6 +36,7 @@
 #include "AliSpectraAODTrackCuts.h"\r
 #include "AliSpectraAODEventCuts.h"\r
 #include "AliHelperPID.h"\r
+#include "AliPIDCombined.h"\r
 #include "AliCentrality.h"\r
 #include "TProof.h"\r
 #include "AliVEvent.h"\r
@@ -167,6 +168,9 @@ void AliAnalysisTaskSpectraAllChAOD::UserExec(Option_t *)
     }\r
   \r
   if(!fEventCuts->IsSelected(fAOD,fTrackCuts))return;//event selection\r
+\r
+  //Default TPC priors\r
+  if(fHelperPID->GetPIDType()==kBayes)fHelperPID->GetPIDCombined()->SetDefaultTPCPriors();//FIXME maybe this can go in the UserCreateOutputObject?\r
   \r
   Double_t Qvec=0.;//in case of MC we save space in the memory\r
   if(!fIsMC)Qvec=fEventCuts->GetqV0A();//FIXME we'll have to combine A and C\r
index 6e1f3f3a9209dddbd0a81aa24683204821215f81..9c76df46d9c1cedc23f771934175e43dc96efa7d 100644 (file)
@@ -64,6 +64,10 @@ AliSpectraAODEventCuts::AliSpectraAODEventCuts(const char *name) :
   fMultiplicityCutMax(99999.),
   fqV0C(-999.),
   fqV0A(-999.),
+  fqV0Cx(-999.),
+  fqV0Ax(-999.),
+  fqV0Cy(-999.),
+  fqV0Ay(-999.),
   fPsiV0C(-999.),
   fPsiV0A(-999.),
   fCent(-999.),
@@ -343,6 +347,10 @@ Double_t AliSpectraAODEventCuts::CalculateQVectorLHC10h(){
   
   fqV0A = TMath::Sqrt((QxaCor2*QxaCor2 + QyaCor2*QyaCor2)/sumMa);
   fqV0C = TMath::Sqrt((QxcCor2*QxcCor2 + QycCor2*QycCor2)/sumMc);
+  fqV0Ax = QxaCor2*TMath::Sqrt(1./sumMa);
+  fqV0Cx = QxcCor2*TMath::Sqrt(1./sumMc);
+  fqV0Ay = QyaCor2*TMath::Sqrt(1./sumMa);
+  fqV0Cy = QycCor2*TMath::Sqrt(1./sumMc);
   
   ((TH2F*)fOutput->FindObject("fQVecACor"))->Fill((Float_t)fAOD->GetCentrality()->GetCentralityPercentile("V0M"), fqV0A);
   ((TH2F*)fOutput->FindObject("fQVecCCor"))->Fill((Float_t)fAOD->GetCentrality()->GetCentralityPercentile("V0M"), fqV0C);
index 1e059309566dd703f4050fadc8bed43d6415c7f4..8938ae9d146fc3d01c5fdfd9e1ee40742d21b2d5 100644 (file)
@@ -47,6 +47,10 @@ class AliSpectraAODEventCuts : public TNamed
     fMultiplicityCutMax(99999.),
     fqV0C(-999.),
     fqV0A(-999.),
+    fqV0Cx(-999.),
+    fqV0Ax(-999.),
+    fqV0Cy(-999.),
+    fqV0Ay(-999.),
     fPsiV0C(-999.),
     fPsiV0A(-999.),
     fCent(-999.),
@@ -99,6 +103,12 @@ class AliSpectraAODEventCuts : public TNamed
   Float_t  GetMultiplicityCutMax()  const {  return fMultiplicityCutMax; }
   Double_t  GetqV0C()  const {  return fqV0C; }
   Double_t  GetqV0A()  const {  return fqV0A; }
+  Double_t  GetqV0Cx()  const {  return fqV0Cx; }
+  Double_t  GetqV0Ax()  const {  return fqV0Ax; }
+  Double_t  GetqV0Cy()  const {  return fqV0Cy; }
+  Double_t  GetqV0Ay()  const {  return fqV0Ay; }
+  Double_t  GetPsiV0C()  const {  return fPsiV0C; }
+  Double_t  GetPsiV0A()  const {  return fPsiV0A; }
   Double_t  GetCent()  const {  return fCent; }
   TList *GetOutputList()       {return fOutput;};
   TList *GetCalibList()       {return fCalib;};
@@ -149,8 +159,12 @@ class AliSpectraAODEventCuts : public TNamed
   Float_t         fMultiplicityCutMax;     // maximum multiplicity position
   Double_t       fqV0C;            //q vector in the VZERO-C
   Double_t       fqV0A;            //q vector in the VZERO-A
-  Double_t       fPsiV0C;            //q vector in the VZERO-C
-  Double_t       fPsiV0A;            //q vector in the VZERO-A
+  Double_t       fqV0Cx;            //q vector in the VZERO-C, x-comp
+  Double_t       fqV0Ax;            //q vector in the VZERO-A, x-comp
+  Double_t       fqV0Cy;            //q vector in the VZERO-C, y-comp
+  Double_t       fqV0Ay;            //q vector in the VZERO-A, y-comp
+  Double_t       fPsiV0C;            //EP from VZERO-C
+  Double_t       fPsiV0A;            //EP from VZERO-A
   Double_t       fCent;            //centrality according to fCentralityMethod
   TList            *fOutput;        // output list 
   TList            *fCalib;        // output list 
@@ -172,7 +186,7 @@ class AliSpectraAODEventCuts : public TNamed
   AliSpectraAODEventCuts(const AliSpectraAODEventCuts&);
   AliSpectraAODEventCuts& operator=(const AliSpectraAODEventCuts&);
   
-  ClassDef(AliSpectraAODEventCuts, 4);
+  ClassDef(AliSpectraAODEventCuts, 5);
   
 };
 #endif
index aef009147952555fe6306ce27f4e657002cd0b26..91cbce02a62c9b87c8506a5cf10944be7eed5c6e 100644 (file)
@@ -64,9 +64,9 @@ AliSpectraAODTrackCuts::AliSpectraAODTrackCuts(const char *name) : TNamed(name,
   fHistoCuts = new TH1I("fTrkCuts", "Track Cuts", kNTrkCuts, -0.5, kNTrkCuts - 0.5);
   for(Int_t ibin=1;ibin<=kNTrkCuts;ibin++)fHistoCuts->GetXaxis()->SetBinLabel(ibin,kBinLabel[ibin-1]);
   //standard histo
-  const Double_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,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,2.5,2.6,2.7,2.8,2.9,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0};
-  Int_t nbinsTempl=52;
-  
+  const Double_t templBins[] = {0.20,0.30,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.4,2.8,3.2,3.6,4.0,5.0,6.0,7.0,8.0,9.0,10.,12.,15.};
+  const Int_t nbinsTempl=26;
+
   fHistoNSelectedPos=new TH1F("fHistoNSelectedPos","fHistoNSelectedPos",nbinsTempl,templBins);
   fHistoNSelectedPos->GetXaxis()->SetTitle("P_{T} (GeV / c)");
   fHistoNSelectedNeg=new TH1F("fHistoNSelectedNeg","fHistoNSelectedNeg",nbinsTempl,templBins);
index 361495634175a32326d1b940176770c46f37b910..658333d383d2b742577d663076cdd897fcc809fa 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  * 
  **************************************************************************/
 
+//git test
+
 #include <TCanvas.h>
 #include <TTree.h>
 #include <TFile.h>
index b9c3ccea0ec527c637e6c21a68e3fa5dd955f258..f16174fd1fc2e780bc14bec88683565969f0c75f 100644 (file)
@@ -78,8 +78,8 @@ AliAnalysisTaskITSAlignQA::AliAnalysisTaskITSAlignQA() : AliAnalysisTaskSE("SDD
   fNPtBins(8),
   fMinMult(0),
   fMaxMult(1e9),
-  fCutDCAXY(1.e10),
-  fCutDCAZ(1.e10),
+  fCutDCAXY(100.),
+  fCutDCAZ(100.),
   fFitter(0),
   fITSSumTP(),
   fTPTree(),
index 764260400ae8cbaad28fcf5b3acb7a19d9daf8a5..aa1f6971aff2f73183b243e62cbecca02711de1b 100644 (file)
@@ -1,14 +1,18 @@
 /*  created by fbellini@cern.ch on 29/04/2013 */
 /*  last modified by fbellini   on 29/04/2013 */
 
-UInt_t kTriggerInt = AliVEvent::kAnyINT;
 // UInt_t kTriggerMuonAll = AliVEvent::kMUL7 | AliVEvent::kMUSH7 | AliVEvent::kMUU7 | AliVEvent::kMUS7;
 // UInt_t kTriggerMuonBarell = AliVEvent::kMUU7;
 // UInt_t kTriggerEMC   = AliVEvent::kEMC7;
 // UInt_t kTriggerHM   = AliVEvent::kHighMult;
+UInt_t kTriggerInt = AliVEvent::kAnyINT;
 UInt_t kTriggerMask = kTriggerInt;
 
-AliAnalysisTaskSE * AddTaskTOFqaID(UInt_t triggerMask = kTriggerMask, Bool_t flagEnableAdvancedCheck=kFALSE, Bool_t isMC = kFALSE, Short_t absPdgCode = 0) 
+AliAnalysisTaskSE * AddTaskTOFqaID(UInt_t triggerMask = kTriggerMask, 
+                                  Bool_t flagEnableAdvancedCheck=kFALSE, 
+                                  Bool_t useStdCuts2011 = kTRUE, 
+                                  Bool_t isMC = kFALSE, 
+                                  Short_t absPdgCode = 0) 
 {
   // Task for checking TOF QA
  
@@ -50,33 +54,38 @@ AliAnalysisTaskSE * AddTaskTOFqaID(UInt_t triggerMask = kTriggerMask, Bool_t fla
   esdTrackCutsLoose2010->SetAcceptKinkDaughters(kFALSE); 
   esdTrackCutsLoose2010->SetMaxNsigmaToVertex(4.0);
   */
+
   /* standard cuts ITS-TPC 2010 */
   AliESDtrackCuts* esdTrackCutsStd2010 = new AliESDtrackCuts("AliESDtrackCuts", "Standard2010");
+  esdTrackCutsStd2010->GetStandardITSTPCTrackCuts2010(kTRUE,0);
   // TPC  
-  esdTrackCutsStd2010->SetMinNClustersTPC(70); 
-  esdTrackCutsStd2010->SetMaxChi2PerClusterTPC(4);
-  esdTrackCutsStd2010->SetAcceptKinkDaughters(kFALSE); 
-  esdTrackCutsStd2010->SetRequireTPCRefit(kTRUE);
-  // ITS
-  esdTrackCutsStd2010->SetRequireITSRefit(kTRUE);
-  esdTrackCutsStd2010->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
-                                               AliESDtrackCuts::kAny);
-  esdTrackCutsStd2010->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");//selects primaries
-  esdTrackCutsStd2010->SetMaxDCAToVertexZ(2);
-  esdTrackCutsStd2010->SetDCAToVertex2D(kFALSE);
-  esdTrackCutsStd2010->SetRequireSigmaToVertex(kFALSE);
+  // esdTrackCutsStd2010->SetMinNClustersTPC(70); 
+  // esdTrackCutsStd2010->SetMaxChi2PerClusterTPC(4);
+  // esdTrackCutsStd2010->SetAcceptKinkDaughters(kFALSE); 
+  // esdTrackCutsStd2010->SetRequireTPCRefit(kTRUE);
+  // // ITS
+  // esdTrackCutsStd2010->SetRequireITSRefit(kTRUE);
+  // esdTrackCutsStd2010->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+  //                                           AliESDtrackCuts::kAny);
+  // esdTrackCutsStd2010->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");//selects primaries
+  // esdTrackCutsStd2010->SetMaxDCAToVertexZ(2);
+  // esdTrackCutsStd2010->SetDCAToVertex2D(kFALSE);
+  // esdTrackCutsStd2010->SetRequireSigmaToVertex(kFALSE);
 
-  /*
-    AliESDtrackCuts* esdTrackCutsStd2011 = new AliESDtrackCuts("AliESDtrackCuts", "Standard2011");
-    esdTrackCutsStd2011->GetStandardITSTPCTrackCuts2011(kTRUE,0);
-  */
+  /* standard cuts ITS-TPC 2011 */
+  AliESDtrackCuts* esdTrackCutsStd2011 = new AliESDtrackCuts("AliESDtrackCuts", "Standard2011");
+  esdTrackCutsStd2011->GetStandardITSTPCTrackCuts2011(kTRUE,0);
   
   AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
-  trackFilter->AddCuts(esdTrackCutsStd2010);
+  if (useStdCuts2011) 
+    trackFilter->AddCuts(esdTrackCutsStd2011);
+  else
+    trackFilter->AddCuts(esdTrackCutsStd2010);
   task->SetTrackFilter(trackFilter);
-   
+  
   TString partName(task->GetSpeciesName(absPdgCode));
-
+  
   // Create containers for input/output
   AliAnalysisDataContainer *cInputTOFqa = mgr->CreateContainer("cInputTOFqa",TChain::Class(),AliAnalysisManager::kInputContainer);
   AliAnalysisDataContainer *cGeneralTOFqa = mgr->CreateContainer(Form("base_%s",partName.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:TOF_Performance",mgr->GetCommonFileName(), partName.Data()));
index 96555ed09916ceb704b7b9e0edd8b40aca137000..0f09cb4b2b3103a3f950a3ab55ba16f881687dad 100644 (file)
@@ -529,7 +529,7 @@ void AliAnalysisTaskTOFqaID::Terminate(Option_t *)
 }
 
 //---------------------------------------------------------------
-Int_t AliAnalysisTaskTOFqaID::GetStripIndex(const Int_t * const in)
+Int_t AliAnalysisTaskTOFqaID::GetStripIndex(const Int_t * in)
 {
   /* return tof strip index between 0 and 91 */
   
index 45b5918df31deef26bda69c2b20f0d1b06c67de5..766519ca801e75d8cd3345021d400bb49a7af7e2 100644 (file)
@@ -24,7 +24,7 @@ class AliAnalysisTaskTOFqaID : public AliAnalysisTaskSE {
   virtual void   UserExec(Option_t *option);
   virtual void   Terminate(Option_t *);
     
-  Int_t   GetStripIndex(const Int_t * const in);
+  Int_t   GetStripIndex(const Int_t * in);
   void    SetTrackFilter(AliAnalysisFilter *filter) {fTrackFilter = filter;};
   void    EnableAdvancedCheck(Bool_t enable){fEnableAdvancedCheck=enable;};
   void    SetExpTimeHistoRange(Float_t min, Float_t max){fExpTimeRangeMin=min; fExpTimeRangeMax=max;return;};
index 9a488562a7f8c2c1bd6cc5c8d109381b64495076..65d57bce4797a20e7f2ee3e2ce38190a1c829e43 100644 (file)
-/**************************************************************************\r
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
-*                                                                        *\r
-* Author: The ALICE Off-line Project.                                    *\r
-* Contributors are mentioned in the code where appropriate.              *\r
-*                                                                        *\r
-* Permission to use, copy, modify and distribute this software and its   *\r
-* documentation strictly for non-commercial purposes is hereby granted   *\r
-* without fee, provided that the above copyright notice appears in all   *\r
-* copies and that both the copyright notice and this permission notice   *\r
-* appear in the supporting documentation. The authors make no claims     *\r
-* about the suitability of this software for any purpose. It is          *\r
-* provided "as is" without express or implied warranty.                  *\r
-**************************************************************************/\r
-\r
-/////////////////////////////////////////////////////\r
-//\r
-// Check basic detector results at ESD level\r
-//   - Geometrical efficiency  \r
-//   - Tracking efficiency  \r
-//   - PID efficiency  \r
-//   - Refit efficiency  \r
-//\r
-// Author\r
-//   Alex Bercuci <A.Bercuci@gsi.de>\r
-//   Ionut Arsene <i.c.arsene@gsi.de>\r
-//\r
-//////////////////////////////////////////////////////\r
-\r
-#include <TClonesArray.h>\r
-#include <TCanvas.h>\r
-#include <TObjArray.h>\r
-#include <TPad.h>\r
-#include <TLegend.h>\r
-#include <TLatex.h>\r
-#include <TLine.h>\r
-#include <TF1.h>\r
-#include <TH1D.h>\r
-#include <TH2D.h>\r
-#include <TH3D.h>\r
-#include <TH2I.h>\r
-#include <TH2F.h>\r
-#include <TH3S.h>\r
-#include <TH3F.h>\r
-#include <TProfile2D.h>\r
-#include <TProfile.h>\r
-#include <TGraphErrors.h>\r
-#include <TGraphAsymmErrors.h>\r
-#include <TFile.h>\r
-#include <TTree.h>\r
-#include <TROOT.h>\r
-#include <TChain.h>\r
-#include <TParticle.h>\r
-#include <TTimeStamp.h>\r
-#include <TRandom.h>\r
-#include <TString.h>\r
-\r
-#include "AliLog.h"\r
-#include "AliAnalysisManager.h"\r
-#include "AliAnalysisCuts.h"\r
-#include "AliPhysicsSelection.h"\r
-#include "AliESDEvent.h"\r
-#include "AliESDkink.h"\r
-#include "AliMCEvent.h"\r
-#include "AliESDInputHandler.h"\r
-#include "AliMCEventHandler.h"\r
-#include "AliESDpid.h"\r
-\r
-#include "AliESDtrack.h"\r
-#include "AliMCParticle.h"\r
-#include "AliPID.h"\r
-#include "AliStack.h"\r
-#include "AliTrackReference.h"\r
-//#include "AliESDCentrality.h"\r
-#include "AliMultiplicity.h"\r
-#include "AliCFContainer.h"\r
-\r
-#include "AliTRDcheckESD.h"\r
-#include <iostream>\r
-using std::cout;\r
-using std::endl;\r
-\r
-ClassImp(AliTRDcheckESD)\r
-\r
-const Float_t AliTRDcheckESD::fgkxTPC = 290.;\r
-const Float_t AliTRDcheckESD::fgkxTOF = 365.;\r
-const UChar_t AliTRDcheckESD::fgkNgraph[AliTRDcheckESD::kNrefs] ={\r
-8, 4, 2, 20};\r
-FILE* AliTRDcheckESD::fgFile = NULL;\r
-\r
-const Float_t AliTRDcheckESD::fgkEvVertexZ = 15.;\r
-const Int_t   AliTRDcheckESD::fgkEvVertexN = 1;\r
-const Float_t AliTRDcheckESD::fgkTrkDCAxy  = 40.;\r
-const Float_t AliTRDcheckESD::fgkTrkDCAz   = 15.;\r
-const Int_t   AliTRDcheckESD::fgkNclTPC    = 100;\r
-const Float_t AliTRDcheckESD::fgkPt        = 0.2;\r
-const Float_t AliTRDcheckESD::fgkEta       = 0.9;\r
-const Float_t AliTRDcheckESD::fgkQs        = 0.002;\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::AliTRDcheckESD():\r
-  AliAnalysisTaskSE()\r
-  ,fStatus(0)\r
-  ,fNRefFigures(0)\r
-  ,fESD(NULL)\r
-  ,fMC(NULL)\r
-  ,fESDpid(new AliESDpid)\r
-  ,fHistos(NULL)\r
-  ,fResults(NULL)\r
-  ,fExpertCF(NULL)\r
-  ,fMatchingPhiEtaCF(NULL)\r
-  ,fMatchingPtCF(NULL)\r
-  ,fBunchCrossingsCF(NULL)\r
-  ,fCentralityCF(NULL)\r
-  ,fQtotCF(NULL)\r
-  ,fPulseHeightCF(NULL)\r
-  ,fReferenceTrackFilter(NULL)\r
-  ,fPhysSelTriggersEnabled(kFALSE)\r
-  ,fUserEnabledTriggers("")\r
-  ,fNAssignedTriggers(0)\r
-{\r
-  //\r
-  // Default constructor\r
-  //\r
-  for(Int_t i=0; i<kNTrdCfVariables; ++i) {\r
-    fExpertCFVars[i] = -1;\r
-    fMatchingPhiEtaCFVars[i] = -1;\r
-    fMatchingPtCFVars[i] = -1;\r
-    fBunchCrossingsCFVars[i] = -1;\r
-    fCentralityCFVars[i] = -1;\r
-    fQtotCFVars[i] = -1;\r
-    fPulseHeightCFVars[i] = -1;\r
-    fExpertCFVarsEnabled[i] = kFALSE;\r
-    fExpertCFVarNBins[i] = 0;\r
-    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;\r
-    fExpertCFVarBins[i] = "";\r
-  }\r
-  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;\r
-  SetNameTitle("TRDcheckESD", "Check TRD @ ESD level");\r
-  SetMC(kTRUE);\r
-}\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::AliTRDcheckESD(char* name):\r
-  AliAnalysisTaskSE(name)\r
-  ,fStatus(0)\r
-  ,fNRefFigures(0)\r
-  ,fESD(NULL)\r
-  ,fMC(NULL)\r
-  ,fESDpid(new AliESDpid)\r
-  ,fHistos(NULL)\r
-  ,fResults(NULL)\r
-  ,fExpertCF(NULL)\r
-  ,fMatchingPhiEtaCF(NULL)\r
-  ,fMatchingPtCF(NULL)\r
-  ,fBunchCrossingsCF(NULL)\r
-  ,fCentralityCF(NULL)\r
-  ,fQtotCF(NULL)\r
-  ,fPulseHeightCF(NULL)\r
-  ,fReferenceTrackFilter(NULL)\r
-  ,fPhysSelTriggersEnabled(kFALSE)\r
-  ,fUserEnabledTriggers("")\r
-  ,fNAssignedTriggers(0)\r
-{\r
-  //\r
-  // Default constructor\r
-  //\r
-  for(Int_t i=0; i<kNTrdCfVariables; ++i) {\r
-    fExpertCFVars[i] = -1;\r
-    fMatchingPhiEtaCFVars[i] = -1;\r
-    fMatchingPtCFVars[i] = -1;\r
-    fBunchCrossingsCFVars[i] = -1;\r
-    fCentralityCFVars[i] = -1;\r
-    fQtotCFVars[i] = -1;\r
-    fPulseHeightCFVars[i] = -1;\r
-    fExpertCFVarsEnabled[i] = kFALSE;\r
-    fExpertCFVarNBins[i] = 0;\r
-    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;\r
-    fExpertCFVarBins[i] = "";\r
-  }\r
-  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;\r
-  SetMC(kTRUE);\r
-  SetTitle("Check TRD @ ESD level");\r
-  DefineOutput(1, TObjArray::Class());\r
-}\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::~AliTRDcheckESD()\r
-{\r
-  // Destructor\r
-  if(fHistos && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){\r
-    if(fHistos->IsOwner()) fHistos->Delete();\r
-    delete fHistos;\r
-    fHistos = NULL;\r
-  }\r
-  \r
-  if(fResults){\r
-    fResults->Delete();\r
-    delete fResults;\r
-  }\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, \r
-                                   Int_t nbins, Double_t lowLim, Double_t highLim) {\r
-  //\r
-  // Configure variables for the expert CF container\r
-  //\r
-  fExpertCFVarsEnabled[var] = kTRUE;\r
-  fExpertCFVarNBins[var] = nbins;\r
-  fExpertCFVarRanges[var][0] = lowLim;\r
-  fExpertCFVarRanges[var][1] = highLim;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, \r
-                                   const Char_t* bins) {\r
-  //\r
-  // Configure variables for the expert CF container\r
-  //\r
-  fExpertCFVarsEnabled[var] = kTRUE;\r
-  fExpertCFVarBins[var] = bins;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::UserCreateOutputObjects()\r
-{      \r
-  //\r
-  // Create Output Containers (TObjectArray containing 1D histograms)\r
-  //\r
-  Histos();\r
-  PostData(1, fHistos);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::MakeSummaryFromCF(Double_t* trendValues, const Char_t* triggerName, Bool_t useIsolatedBC, Bool_t cutTOFbc){\r
-  //\r
-  // Draw summary plots for the ESDcheck task using the CF container\r
-  //\r
-\r
-  cout << "Make summary from CF" << endl;\r
-  TCanvas *cOut=0x0;\r
-  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");\r
-  cOut = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  PlotTrackingSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("trackingSummary.gif");\r
-  \r
-  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");\r
-  cOut = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  //GetRefFigure(6);\r
-  PlotPidSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("pidSummary.gif");\r
-\r
-  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");\r
-  cOut = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  //GetRefFigure(7);\r
-  PlotCentSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("centSummary.gif");\r
-\r
-  for(Int_t i=0;i<50;++i) cout << "trend #" << i << " :: " << trendValues[i] << endl;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::MakeSummary(Double_t* trendValues){\r
-  //\r
-  // Draw summary plots for the ESDcheck task\r
-  //\r
-  // Old method to draw summary pictures from histograms. Use the MakeSummaryFromCF() when CF container is present\r
-  \r
-  cout << "Make summary" << endl;\r
-  TCanvas *cTracking=0x0;\r
-  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");\r
-  cTracking = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);\r
-  cTracking->cd();\r
-  //GetRefFigure(5);\r
-  if(PlotTrackingSummary(0, trendValues))\r
-    cTracking->SaveAs("trackingSummary.gif");\r
-  \r
-  TCanvas* cPid = 0x0;\r
-  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");\r
-  cPid = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);\r
-  cPid->cd();\r
-  //GetRefFigure(6);\r
-  if(PlotPidSummary(0, trendValues))\r
-    cPid->SaveAs("pidSummary.gif");\r
-\r
-  TCanvas* cCent=0x0;\r
-  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");\r
-  cCent = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);\r
-  cCent->cd();\r
-  //GetRefFigure(7);\r
-  if(PlotCentSummary(trendValues))\r
-    cCent->SaveAs("centSummary.gif");\r
-}\r
-\r
-//____________________________________________________________________\r
-Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)\r
-{\r
-  //\r
-  // Produce reference Plots during PostProcessing\r
-  //\r
-  if(ifig>=fNRefFigures){\r
-    AliWarning(Form("Ref plot %d not available. Valid only up to %d", ifig, fNRefFigures));\r
-    return kFALSE;\r
-  }\r
-  if(!gPad){\r
-    AliWarning("Please provide a canvas to draw results.");\r
-    return kFALSE;\r
-  } else {\r
-    gPad->SetLogx(0);gPad->SetLogy(0);\r
-    gPad->SetMargin(0.125, 0.015, 0.1, 0.015);\r
-  }\r
-\r
-  const Char_t *title[20];\r
-  TH1 *hF(NULL);\r
-  if((hF=(TH1S*)gROOT->FindObject("hFcheckESD"))) delete hF;\r
-  TLegend *leg(NULL);\r
-  TList *l(NULL); TVirtualPad *pad(NULL);\r
-  TGraphErrors *g(NULL);TGraphAsymmErrors *ga(NULL);\r
-  TObjArray *arr(NULL);\r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  TLine line;\r
-  TTimeStamp now;\r
-  switch(ifig){\r
-  case kNCl: // number of clusters/track\r
-    if(!(arr = (TObjArray*)fResults->At(kNCl))) return kFALSE;\r
-\r
-    leg = new TLegend(.83, .7, .99, .96);\r
-    leg->SetHeader("Species");\r
-    leg->SetBorderSize(0); leg->SetFillStyle(0);\r
-    for(Int_t ig(0); ig<fgkNgraph[kNCl-1]; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;\r
-      if(!g->GetN()) continue;\r
-      g->Draw(ig?"pc":"apc"); leg->AddEntry(g, g->GetTitle(), "pl");\r
-      if(ig) continue;\r
-      hF=g->GetHistogram();\r
-      hF->SetXTitle("no of clusters");\r
-      hF->SetYTitle("entries"); \r
-      hF->GetYaxis()->CenterTitle(1);\r
-      hF->GetYaxis()->SetTitleOffset(1.2);\r
-      hF->SetMinimum(5);\r
-    }\r
-    leg->Draw(); gPad->SetLogy();\r
-    break;\r
-  case kTRDstat: // Efficiency\r
-    if(!(arr = (TObjArray*)fResults->At(kTRDstat))) return kFALSE;\r
-    leg = new TLegend(.62, .77, .98, .98);\r
-    leg->SetHeader("TRD Efficiency");\r
-    leg->SetBorderSize(0); leg->SetFillStyle(0);\r
-    title[0] = "Geometrical (TRDin/TPCout)";\r
-    title[1] = "Tracking (TRDout/TRDin)";\r
-    title[2] = "PID (TRDpid/TRDin)";\r
-    title[3] = "Refit (TRDrefit/TRDin)";\r
-    hF = new TH1S("hFcheckESD", ";p [GeV/c];Efficiency", 10, 0.1, 10.);\r
-    hF->SetMaximum(1.4);\r
-    hF->GetXaxis()->SetMoreLogLabels();\r
-    hF->GetYaxis()->CenterTitle(1);\r
-    hF->Draw("p");\r
-    for(Int_t ig(0); ig<fgkNgraph[kTRDstat-1]; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;\r
-      g->Draw("pl"); leg->AddEntry(g, title[ig], "pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    leg->Draw(); gPad->SetLogx();\r
-    break;\r
-  case kTRDmom: // Energy loss\r
-    if(!(arr = (TObjArray*)fResults->At(kTRDmom))) return kFALSE;\r
-    leg = new TLegend(.65, .7, .95, .99);\r
-    leg->SetHeader("Energy Loss");\r
-    leg->SetBorderSize(1); leg->SetFillColor(0);\r
-    title[0] = "Max & 90% quantile";\r
-    title[1] = "Mean & 60% quantile";\r
-    hF = new TH1S("hFcheckESD", ";layer;#Delta E", 6, -0.5, 5.5);\r
-    hF->SetMaximum(1.3);hF->SetMinimum(-.3);\r
-    hF->Draw("p");\r
-    for(Int_t ig(0); ig<fgkNgraph[kTRDmom-1]; ig++){\r
-      if(!(ga = (TGraphAsymmErrors*)arr->At(ig))) return kFALSE;\r
-      ga->Draw("pl"); leg->AddEntry(ga, title[ig], "pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    leg->Draw();gPad->SetLogx(kFALSE);\r
-    break;\r
-  case kPtRes: // Pt resolution @ vertex\r
-    if(!(arr = (TObjArray*)fResults->At(kPtRes))) return kFALSE;\r
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); \r
-    pad = ((TVirtualPad*)l->At(0)); pad->cd(); pad->SetLogx();\r
-    pad->SetMargin(0.1, 0.022, 0.1, 0.023);\r
-    hF = new TH1S("hFcheckESD", "ITS+TPC+TRD;p_{t} [GeV/c];#Delta p_{t} / p_{t} [%]", 10, 0.2, 10.);\r
-    hF->SetMaximum(10.);hF->SetMinimum(-3.);\r
-    hF->GetXaxis()->SetMoreLogLabels();\r
-    hF->GetXaxis()->SetTitleOffset(1.2);\r
-    hF->GetYaxis()->CenterTitle();\r
-    hF->Draw("p");\r
-    //for(Int_t ig(0); ig<fgkNgraph[kPtRes-1]/2; ig++){\r
-    for(Int_t ig(2); ig<6; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) continue;\r
-      if(!g->GetN()) continue;\r
-      g->Draw("pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    pad = ((TVirtualPad*)l->At(1)); pad->cd(); pad->SetLogx();\r
-    pad->SetMargin(0.1, 0.22, 0.1, 0.023);\r
-    hF = (TH1*)hF->Clone("hFcheckESD1");\r
-    hF->SetTitle("ITS+TPC");\r
-    hF->SetMaximum(10.);hF->SetMinimum(-3.);\r
-    hF->Draw("p");\r
-    leg = new TLegend(.78, .1, .99, .98);\r
-    leg->SetHeader("P_{t} @ DCA");\r
-    leg->SetBorderSize(1); leg->SetFillColor(0);\r
-    leg->SetTextAlign(22);\r
-    leg->SetTextFont(12);\r
-    leg->SetTextSize(0.03813559);\r
-    {\r
-      Int_t nPlots(0);\r
-      //for(Int_t ig(fgkNgraph[kPtRes-1]/2); ig<fgkNgraph[kPtRes-1]; ig++){\r
-      for(Int_t ig(12); ig<16; ig++){\r
-        if(!(g = (TGraphErrors*)arr->At(ig))) continue;\r
-        if(!g->GetN()) continue;\r
-        nPlots++;\r
-        g->Draw("pl"); leg->AddEntry(g, g->GetTitle(), "pl");\r
-        //PutTrendValue(name[id], g->GetMean(2));\r
-        //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-      }\r
-      if(nPlots) leg->Draw();\r
-    }\r
-    break;\r
-  case 5: // plot a 3x3 canvas with tracking related histograms\r
-    PlotTrackingSummary(0);\r
-    break;\r
-    \r
-  case 6: // plot a 3x3 canvas with PID related histograms\r
-    PlotPidSummary(0);\r
-    break;\r
-\r
-  case 7: // plot a 3x3 canvas with centrality dependence histograms\r
-    PlotCentSummary();\r
-    break;\r
-\r
-  }\r
-  return kTRUE;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::UserExec(Option_t *){\r
-  //\r
-  // Run the Analysis\r
-  //\r
-  fESD = dynamic_cast<AliESDEvent*>(InputEvent());\r
-  fMC = MCEvent();\r
-\r
-  if(!fESD){\r
-    AliError("ESD event missing.");\r
-    return;\r
-  }\r
-  \r
-  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());\r
-  if(!inputHandler) return;\r
-  \r
-  if(!fPhysSelTriggersEnabled) {\r
-    InitializeCFContainers();\r
-    fPhysSelTriggersEnabled = kTRUE;\r
-  }\r
-    \r
-  UInt_t isSelected = AliVEvent::kAny;\r
-  if(inputHandler){\r
-    if(inputHandler->GetEventSelection()) {\r
-      isSelected = inputHandler->IsEventSelected();\r
-    }\r
-  }\r
-  if(!isSelected) return;\r
-\r
-  TString triggerClasses = fESD->GetFiredTriggerClasses();\r
-  //  cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++triggers fired:  " << triggerClasses.Data() << endl;\r
-  TObjArray* triggers = triggerClasses.Tokenize(" ");\r
-  TObjArray* userTriggers = fUserEnabledTriggers.Tokenize(";");\r
-  if(triggers->GetEntries()<1) {delete triggers; delete userTriggers; return;}\r
-  Bool_t hasGoodTriggers = kFALSE;\r
-  Int_t triggerIndices[kNMaxAssignedTriggers] = {0};\r
-  Int_t nTrigFired=0;\r
-  for(Int_t i=0; i<triggers->GetEntries(); ++i) {\r
-    //    cout << "check trigger " << triggers->At(i)->GetName() << endl;\r
-    TString trigStr=triggers->At(i)->GetName();\r
-    if(!trigStr.Contains("NOTRD") && !trigStr.Contains("MUON")) hasGoodTriggers = kTRUE;    // check wheter TRD was read out in this event\r
-    if(i>=kNMaxAssignedTriggers) continue;\r
-    //    triggerIndices[i] = GetTriggerIndex(triggers->At(i)->GetName(), kFALSE);\r
-    for(Int_t j=0;j<userTriggers->GetEntries();++j) {\r
-      TString userTrigStr=userTriggers->At(j)->GetName();\r
-      if(trigStr.Contains(userTrigStr.Data())) {\r
-       triggerIndices[nTrigFired] = GetTriggerIndex(userTrigStr.Data(), kFALSE);\r
-       if(triggerIndices[nTrigFired]==-1) triggerIndices[nTrigFired]=1;  // 0-assigned to all other triggers\r
-       ++nTrigFired;\r
-      }\r
-    }\r
-    triggerIndices[nTrigFired] = GetTriggerIndex(trigStr.Data(), kFALSE);\r
-    if(triggerIndices[nTrigFired]==-1) triggerIndices[nTrigFired]=1;  // 0-assigned to all other triggers\r
-    ++nTrigFired;\r
-  } \r
-  //  Int_t nTRDtracks = fESD->GetNumberOfTrdTracks();\r
-  //  Int_t nGlobalTracks = fESD->GetNumberOfTracks();\r
-  //cout << "TRD/All tracks: " << nTRDtracks << "/" << nGlobalTracks << endl;\r
-  //\r
-  //\r
-  for(Int_t i=0; i<nTrigFired; ++i) \r
-    ((TH1F*)fHistos->At(kTriggerDefs))->Fill(triggerIndices[i]);\r
-\r
-  if(!hasGoodTriggers) {\r
-    PostData(1, fHistos);\r
-    delete triggers;\r
-    delete userTriggers;\r
-    return;\r
-  }\r
-  \r
-  // Get MC information if available\r
-  AliStack * fStack = NULL;\r
-  if(HasMC()){\r
-    if(!fMC){ \r
-      AliWarning("MC event missing");\r
-      SetMC(kFALSE);\r
-    } else {\r
-      if(!(fStack = fMC->Stack())){\r
-        AliWarning("MC stack missing");\r
-        SetMC(kFALSE);\r
-      }\r
-    }\r
-  }\r
-  TH1 *h(NULL);\r
-  \r
-  Double_t values[kNTrdCfVariables];      // array where the CF container variables are stored\r
-  values[kEventVtxZ] = fESD->GetPrimaryVertex()->GetZv();\r
-  values[kEventBC] = fESD->GetBunchCrossNumber();\r
-  \r
-  const AliMultiplicity* mult=fESD->GetMultiplicity();\r
-  Double_t itsNTracklets = mult->GetNumberOfTracklets();\r
-  if(itsNTracklets<1) return;\r
-  Int_t multLimits[6] = {0, 700, 1400, 2100, 2800, 3500};\r
-  Int_t centralityClass = 0;\r
-  for(Int_t iCent=0; iCent<5; ++iCent) {\r
-    if(itsNTracklets>=multLimits[iCent] && itsNTracklets<multLimits[iCent+1])\r
-      centralityClass=iCent+1;\r
-  }\r
-  values[kEventMult] = itsNTracklets;\r
-  if(centralityClass == 0) return;\r
-  \r
-  Double_t* valuesMatchingPhiEtaCF = new Double_t[fMatchingPhiEtaCF->GetNVar()];\r
-  Double_t* valuesMatchingPtCF = new Double_t[fMatchingPtCF->GetNVar()];\r
-  Double_t* valuesBCCF = new Double_t[fBunchCrossingsCF->GetNVar()];\r
-  Double_t* valuesCentCF = new Double_t[fCentralityCF->GetNVar()];\r
-  Double_t* valuesQtotCF = new Double_t[fQtotCF->GetNVar()];\r
-  Double_t* valuesPHCF = new Double_t[fPulseHeightCF->GetNVar()];\r
-  Double_t* valuesExpertCF = (fExpertCF ? new Double_t[fExpertCF->GetNVar()] : 0x0);\r
-  \r
-  AliESDtrack *esdTrack(NULL);\r
-  for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){\r
-    esdTrack = fESD->GetTrack(itrk);\r
-    \r
-    Float_t dcaxy,dcaz;\r
-    esdTrack->GetImpactParameters(dcaxy,dcaz);\r
-    \r
-    if(!fReferenceTrackFilter->IsSelected(esdTrack)) continue;\r
-\r
-    ULong_t status = esdTrack->GetStatus(); \r
-            \r
-    // pid quality\r
-    Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin);\r
-\r
-    // find position and momentum of the track at entrance in TRD\r
-    Double_t rTRD[6] = {298.0, 311.0, 324.0, 337.0, 350.0, 363.0};\r
-    Double_t localCoord[6][3] = {{0.0}};\r
-    Bool_t localCoordGood[6];\r
-    for(Int_t il=0;il<6;++il) localCoordGood[il] = esdTrack->GetXYZAt(rTRD[il], fESD->GetMagneticField(), localCoord[il]);\r
-    Double_t localMom[6][3] = {{0.0}};\r
-    Bool_t localMomGood[6];\r
-    for(Int_t il=0; il<6; ++il) localMomGood[il] = esdTrack->GetPxPyPzAt(rTRD[il], fESD->GetMagneticField(), localMom[il]);\r
-    //Double_t localPhi = (localMomGood ? TMath::ATan2(localMom[1], localMom[0]) : 0.0);\r
-    Double_t localSagitaPhi[6] = {-999.};\r
-    for(Int_t il=0; il<6; ++il) localSagitaPhi[il] = (localCoordGood[il] ? TMath::ATan2(localCoord[il][1], localCoord[il][0]) : -999.);\r
-\r
-    values[kTrackTOFBC]      = esdTrack->GetTOFBunchCrossing(fESD->GetMagneticField());\r
-    Float_t dcaXY=0.0; Float_t dcaZ=0.0;\r
-    esdTrack->GetImpactParameters(dcaXY, dcaZ);\r
-    values[kTrackDCAxy]  = dcaXY;\r
-    values[kTrackDCAz]   = dcaZ;\r
-    values[kTrackCharge] = esdTrack->Charge();\r
-    values[kTrackPhi]    = localSagitaPhi[0];\r
-    values[kTrackEta]    = esdTrack->Eta();\r
-    values[kTrackPt]     = esdTrack->Pt();\r
-    values[kTrackP]      = esdTrack->P();\r
-    values[kTrackTrdTracklets] = esdTrack->GetTRDntracklets();\r
-    values[kTrackTrdClusters] = esdTrack->GetTRDncls();\r
-    for(Int_t i=0; i<6; ++i) values[kTrackQtot+i] = 0.0;\r
-        \r
-    if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0) {\r
-      for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-      fBunchCrossingsCF->Fill(valuesBCCF, 0);\r
-    }\r
-         \r
-    if(localCoordGood[0] && localMomGood[0]) {\r
-      for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {\r
-       values[kEventTrigger] = triggerIndices[itrig];\r
-       if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-         for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-         fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 0);\r
-       }\r
-       if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-         for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-         fMatchingPtCF->Fill(valuesMatchingPtCF, 0);\r
-       }\r
-       if(fExpertCF) {\r
-         if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0))\r
-           if(fExpertCF->GetStep("TPC")>=0 && fExpertCF->GetStep("TPC")<3) {\r
-             for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-             fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TPC"));\r
-           }\r
-       }\r
-      }\r
-    }\r
-            \r
-    // TRD reference tracks\r
-    if(values[kTrackTrdTracklets]>=1) {\r
-      // (slicePH,sliceNo) distribution and Qtot from slices\r
-      for(Int_t iPlane=0; iPlane<6; iPlane++) {\r
-        values[kTrackQtot+iPlane] = fgkQs*esdTrack->GetTRDslice(iPlane, 0);\r
-       values[kTrackPhi] = localSagitaPhi[iPlane];\r
-       for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {\r
-         values[kEventTrigger] = triggerIndices[itrig];\r
-         if((fCentralityCF->GetVar("trigger")<0 && itrig==0) || (fCentralityCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fCentralityCF->GetNVar(); ++iv) valuesCentCF[iv] = values[fCentralityCFVars[iv]];\r
-           valuesCentCF[fCentralityCF->GetNVar()-2] = values[kTrackQtot+iPlane];\r
-           fCentralityCF->Fill(valuesCentCF, 0);\r
-         }\r
-         if(values[kTrackTrdTracklets]>=4)\r
-           if((fQtotCF->GetVar("trigger")<0 && itrig==0) || (fQtotCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fQtotCF->GetNVar(); ++iv) valuesQtotCF[iv] = values[fQtotCFVars[iv]];\r
-             valuesQtotCF[fQtotCF->GetNVar()-3] = values[kTrackQtot+iPlane];\r
-             valuesQtotCF[fQtotCF->GetNVar()-1] = iPlane;\r
-             fQtotCF->Fill(valuesQtotCF, 0);\r
-           }\r
-       }\r
-        for(Int_t iSlice=0; iSlice<8; iSlice++) {\r
-         if(esdTrack->GetTRDslice(iPlane, iSlice)>20.) {\r
-           values[kTrackPHslice+iSlice] =  fgkQs*esdTrack->GetTRDslice(iPlane, iSlice);\r
-           h = (TH2F*)fHistos->At(kPHSlice); h->Fill(iSlice, values[kTrackPHslice+iSlice]);\r
-           h = (TH2F*)fHistos->At(kPHSlice+centralityClass); h->Fill(iSlice, values[kTrackPHslice+iSlice]);\r
-           for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-             values[kEventTrigger] = triggerIndices[itrig];\r
-             if((fPulseHeightCF->GetVar("trigger")<0 && itrig==0) || (fPulseHeightCF->GetVar("trigger")>=0)) {\r
-               for(Int_t iv=0; iv<fPulseHeightCF->GetNVar(); ++iv) valuesPHCF[iv] = values[fPulseHeightCFVars[iv]];\r
-               valuesPHCF[fPulseHeightCF->GetNVar()-3] = values[kTrackPHslice+iSlice];\r
-               valuesPHCF[fPulseHeightCF->GetNVar()-1] = iSlice;\r
-               //                for(Int_t iv=0;iv<fPulseHeightCF->GetNVar(); ++iv) cout << "var #" << iv << " :: " << valuesPHCF[iv] << endl;\r
-               fPulseHeightCF->Fill(valuesPHCF, 0);\r
-             }\r
-           }\r
-         }\r
-       }\r
-      }\r
-      values[kTrackPhi] = localSagitaPhi[0];\r
-            \r
-      if(localCoordGood[0] && localMomGood[0]) {\r
-       for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {\r
-         values[kEventTrigger] = triggerIndices[itrig];\r
-         if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-           fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 1);\r
-         }\r
-         if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-           fMatchingPtCF->Fill(valuesMatchingPtCF, 1);\r
-         }\r
-         if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)\r
-           if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-             fBunchCrossingsCF->Fill(valuesBCCF, 1);\r
-           }\r
-         if(fExpertCF) {\r
-           if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {\r
-             if(fExpertCF->GetStep("TRD")>=0 && fExpertCF->GetStep("TRD")<3) {\r
-               for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-               fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TRD"));\r
-             }\r
-           }\r
-         } \r
-       }\r
-        if(Bool_t(status & AliESDtrack::kTOFpid)) {\r
-         for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {\r
-           values[kEventTrigger] = triggerIndices[itrig];\r
-           if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-             fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 2);\r
-           }\r
-           if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-             fMatchingPtCF->Fill(valuesMatchingPtCF, 2);\r
-           }\r
-           if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)\r
-             if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {\r
-               for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-               fBunchCrossingsCF->Fill(valuesBCCF, 2);\r
-             }\r
-           if(fExpertCF) {\r
-             if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {\r
-               if(fExpertCF->GetStep("TOF")>=0 && fExpertCF->GetStep("TOF")<3) {\r
-                 for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-                 fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TOF"));\r
-               }\r
-             }\r
-           }\r
-         }\r
-       }\r
-      }\r
-    }  // end if nTRDtrkl>=1\r
-    \r
-    // look at external track param\r
-    const AliExternalTrackParam *op = esdTrack->GetOuterParam();\r
-    const AliExternalTrackParam *ip = esdTrack->GetInnerParam();\r
-\r
-    Double_t pt(0.), pt0(0.), ptTRD(0.); \r
-    // read MC info if available\r
-    Bool_t kFOUND(kFALSE), kPhysPrim(kFALSE);\r
-    AliMCParticle *mcParticle(NULL);\r
-    if(HasMC()){\r
-      AliTrackReference *ref(NULL); \r
-      Int_t fLabel(esdTrack->GetLabel());\r
-      Int_t fIdx(TMath::Abs(fLabel));\r
-      if(!fStack || fIdx > fStack->GetNtrack()) continue; \r
-      \r
-      // read MC particle \r
-      if(!(mcParticle = (AliMCParticle*) fMC->GetTrack(fIdx))) {\r
-        AliWarning(Form("MC particle missing. Label[ %d].", fLabel));\r
-        continue;\r
-      }\r
-  \r
-      pt   = esdTrack->Pt();\r
-      pt0  = mcParticle->Pt();\r
-      //Double_t eta0 = mcParticle->Eta();\r
-      //Double_t phi0 = mcParticle->Phi();\r
-      kPhysPrim = fMC->IsPhysicalPrimary(fIdx);\r
-\r
-      // read track references\r
-      Int_t nRefs = mcParticle->GetNumberOfTrackReferences();\r
-      if(!nRefs){\r
-        AliWarning(Form("No TR found for track @ Label[%d].", fLabel));\r
-        continue;\r
-      }\r
-      Int_t iref = 0;\r
-      while(iref<nRefs){\r
-        ref = mcParticle->GetTrackReference(iref);\r
-        if(ref->LocalX() > fgkxTPC) break;\r
-        ref=NULL; iref++;\r
-      }\r
-      if(ref){ \r
-        if(ref->LocalX() > fgkxTOF){ // track skipping TRD fiducial volume\r
-          ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));\r
-        }\r
-      } else { // track stopped in TPC \r
-        ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));\r
-      }\r
-      ptTRD = ref->Pt();kFOUND=kTRUE;\r
-    } else { // use reconstructed values\r
-      if(op){\r
-        Double_t x(op->GetX());\r
-        if(x<fgkxTOF && x>fgkxTPC){\r
-          ptTRD=op->Pt();\r
-          kFOUND=kTRUE;\r
-        }\r
-      }\r
-\r
-      if(!kFOUND && ip){\r
-        ptTRD=ip->Pt();\r
-        kFOUND=kTRUE;\r
-      }\r
-    }     // end if(HasMC())\r
-\r
-    if(kFOUND){\r
-      h = (TH2I*)fHistos->At(kTRDstat);\r
-      if(status & AliESDtrack::kTPCout) h->Fill(ptTRD, kTPCout);\r
-      if(status & AliESDtrack::kTRDin) h->Fill(ptTRD, kTRDin);\r
-      if(kBarrel && (status & AliESDtrack::kTRDout)) h->Fill(ptTRD, kTRDout);\r
-      if(kBarrel && (status & AliESDtrack::kTRDpid)) h->Fill(ptTRD, kTRDpid);\r
-      if(kBarrel && (status & AliESDtrack::kTRDrefit)) h->Fill(ptTRD, kTRDref);\r
-    }\r
-    Int_t idx(HasMC() ? Pdg2Idx(TMath::Abs(mcParticle->PdgCode())): 0)\r
-         ,sgn(esdTrack->Charge()<0?0:1);\r
-    if(kBarrel && kPhysPrim) {\r
-      TH3 *h3 = (TH3S*)fHistos->At(kPtRes);\r
-      Int_t offset = (status & AliESDtrack::kTRDrefit) ? 0 : 10; \r
-      h3->Fill(pt0, 1.e2*(pt/pt0-1.), \r
-        offset + 2*idx + sgn);\r
-    }\r
-    ((TH1*)fHistos->At(kNCl))->Fill(esdTrack->GetTRDncls(), 2*idx + sgn);\r
-    if(ip){\r
-      h = (TH2I*)fHistos->At(kTRDmom);\r
-      Float_t pTRD(0.);\r
-      for(Int_t ily=6; ily--;){\r
-        if((pTRD=esdTrack->GetTRDmomentum(ily))<0.) continue;\r
-        h->Fill(ip->GetP()-pTRD, ily);\r
-      }\r
-    }\r
-  }  // end loop over tracks\r
-  \r
-  \r
-  \r
-  delete triggers;\r
-  delete userTriggers;\r
-  delete [] valuesMatchingPhiEtaCF;\r
-  delete [] valuesMatchingPtCF;\r
-  delete [] valuesBCCF;\r
-  delete [] valuesCentCF;\r
-  delete [] valuesQtotCF;\r
-  delete [] valuesPHCF;\r
-  if(valuesExpertCF) delete [] valuesExpertCF;\r
-  \r
-  PostData(1, fHistos);\r
-}\r
-\r
-//____________________________________________________________________\r
-TObjArray* AliTRDcheckESD::Histos()\r
-{\r
-// Retrieve histograms array if already build or build it\r
-\r
-  if(fHistos) return fHistos;\r
-\r
-  fHistos = new TObjArray(kNhistos+1);\r
-  fHistos->SetOwner(kTRUE);\r
-\r
-  TH1 *h = NULL;\r
-\r
-  // clusters per track\r
-  const Int_t kNpt(30);\r
-  Float_t pt(0.2);\r
-  Float_t binsPt[kNpt+1];\r
-  for(Int_t i=0;i<kNpt+1; i++,pt+=(TMath::Exp(i*i*.001)-1.)) binsPt[i]=pt;\r
-  if(!(h = (TH2I*)gROOT->FindObject("hNCl"))){\r
-    h = new TH2I("hNCl", "Clusters per TRD track;N_{cl}^{TRD};SPECIES;entries", 60, 0., 180., 10, -0.5, 9.5);\r
-    TAxis *ay(h->GetYaxis());\r
-    ay->SetLabelOffset(0.015);\r
-    for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-      ay->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      ay->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-    }\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNCl); fNRefFigures++;\r
-\r
-  // status bits histogram\r
-  const Int_t kNbits(5);\r
-  Float_t bits(.5);\r
-  Float_t binsBits[kNbits+1];\r
-  for(Int_t i=0; i<kNbits+1; i++,bits+=1.) binsBits[i]=bits;\r
-  if(!(h = (TH2I*)gROOT->FindObject("hTRDstat"))){\r
-    h = new TH2I("hTRDstat", "TRD status bits;p_{t} @ TRD [GeV/c];status;entries", kNpt, binsPt, kNbits, binsBits);\r
-    TAxis *ay(h->GetYaxis());\r
-    ay->SetBinLabel(1, "kTPCout");\r
-    ay->SetBinLabel(2, "kTRDin");\r
-    ay->SetBinLabel(3, "kTRDout");\r
-    ay->SetBinLabel(4, "kTRDpid");\r
-    ay->SetBinLabel(5, "kTRDrefit");\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTRDstat);\r
-\r
-  // energy loss\r
-  if(!(h = (TH2I*)gROOT->FindObject("hTRDmom"))){\r
-    h = new TH2I("hTRDmom", "TRD energy loss;p_{inner} - p_{ly} [GeV/c];ly;entries", 100, -1., 2., 6, -0.5, 5.5);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTRDmom);\r
-  //if(!HasMC()) return fHistos;\r
-\r
-  // pt resolution\r
-  const Int_t kNdpt(100), kNspec(4*AliPID::kSPECIES);\r
-  Float_t dpt(-3.), spec(-0.5);\r
-  Float_t binsDPt[kNdpt+1], binsSpec[kNspec+1];\r
-  for(Int_t i=0; i<kNdpt+1; i++,dpt+=6.e-2) binsDPt[i]=dpt;\r
-  for(Int_t i=0; i<kNspec+1; i++,spec+=1.) binsSpec[i]=spec;\r
-  if(!(h = (TH3S*)gROOT->FindObject("hPtRes"))){\r
-    h = new TH3S("hPtRes", "P_{t} resolution @ DCA;p_{t}^{MC} [GeV/c];#Delta p_{t}/p_{t}^{MC} [%];SPECIES", kNpt, binsPt, kNdpt, binsDPt, kNspec, binsSpec);\r
-    TAxis *az(h->GetZaxis());\r
-    az->SetLabelOffset(0.015);\r
-    for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-      az->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(10+2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(10+2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-    }\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPtRes);\r
-\r
-  // TPC event vertex distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hTPCVertex"))){\r
-    h = new TH1F("hTPCVertex", "Event vertex Z coord. from TPC tracks", 100, -25., 25.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTPCVertex);\r
-  \r
-  // Event vertex\r
-  if(!(h = (TH1F*)gROOT->FindObject("hEventVertex"))){\r
-    h = new TH1F("hEventVertex", "Event vertex Z coord.", 100, -25., 25.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEventVertex);\r
-  \r
-  // Number of all tracks\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAll"))){\r
-    h = new TH1I("hNTracksAll", "Number of tracks per event, event vertex cuts", 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksAll);\r
-  \r
-  // Number of tracks in acceptance and DCA cut\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAcc"))){\r
-    h = new TH1I("hNTracksAcc", Form("Number of tracks per event, |#eta|<%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                                    fgkEta, fgkTrkDCAxy, fgkTrkDCAz), 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksAcc);\r
-  \r
-  // Number of tracks in TPC (Ncls>10)\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksTPC"))){\r
-    h = new TH1I("hNTracksTPC", Form("Number of tracks per event, |#eta|<%.1f, pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                    fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksTPC);\r
-  \r
-  // Distribution of DCA-xy\r
-  if(!(h = (TH1F*)gROOT->FindObject("hDCAxy"))){\r
-    h = new TH1F("hDCAxy", "Distribution of transverse DCA", 100, -100., 100.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kDCAxy);\r
-  \r
-  // Distribution of DCA-z\r
-  if(!(h = (TH1F*)gROOT->FindObject("hDCAz"))){\r
-    h = new TH1F("hDCAz", "Distribution of longitudinal DCA", 100, -100., 100.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kDCAz);\r
-  \r
-  Double_t binPtLimits[33] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,\r
-                            1.0, 1.1, 1.2, 1.3, 1.4, \r
-                            1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0,\r
-                            3.4, 3.8, 4.2, 4.6, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};\r
-  // Pt distributions\r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt1"))){\r
-    h = new TH1F("hPt1", Form("dN/dpt, |#eta|<%.1f and pt>%.1f", fgkEta, fgkPt), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt1);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt2"))){\r
-    h = new TH1F("hPt2", Form("dN/dpt, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                             fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt2);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt3pos"))){\r
-    h = new TH1F("hPt3pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt3pos);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt3neg"))){\r
-    h = new TH1F("hPt3neg", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt3neg);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt4pos"))){\r
-    h = new TH1F("hPt4pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt4pos);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt4neg"))){\r
-    h = new TH1F("hPt4pos", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt4neg);\r
-  \r
-  // theta distribution of TRD tracks\r
-  if(!(h = (TH1F*)gROOT->FindObject("hTheta"))){\r
-    h = new TH1F("hTheta", Form("dN/d#theta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 220,.5,2.7);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTheta);\r
-  \r
-  // phi distribution of TRD tracks\r
-  if(!(h = (TH1F*)gROOT->FindObject("hPhi"))){\r
-    h = new TH1F("hPhi", Form("dN/d#varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 157,0,6.28);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPhi);\r
-  \r
-  // TPC cluster distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hNTPCCl"))){\r
-    h = new TH1I("hNTPCCl", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTPCCl);\r
-  \r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTPCCl2"))){\r
-    h = new TH1F("hNTPCCl2", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, pt>1.0 GeV/c",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTPCCl2);\r
-  \r
-  // dE/dx vs P for TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hTPCDedx"))){\r
-    h = new TH2F("hTPCDedx", Form("TPC dE/dx vs P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 150, 0, 150.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTPCDedx);\r
-  \r
-  // eta,phi distribution of TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hEtaPhi"))){\r
-    h = new TH2F("hEtaPhi", Form("TPC (#eta,#varphi), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 50, -1, 1, 157, 0, 6.28);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEtaPhi);\r
-  \r
-  // Nclusters vs eta distribution for TPC tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hEtaNclsTPC"))){\r
-    h = new TH2F("hEtaNclsTPC", Form("TPC Nclusters vs. #eta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 50, -1, 1, 160, 0, 160.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEtaNclsTPC);\r
-  \r
-  // Nclusters vs phi distribution for TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hPhiNclsTPC"))){\r
-    h = new TH2F("hPhiNclsTPC", Form("TPC Nclusters vs. #varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 157, 0, 6.28, 160, 0, 160.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPhiNclsTPC);\r
-\r
-  // SPD multiplicity distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hSPDMult"))){\r
-    h = new TH1F("hSPDMult", "SPD multiplicity", 10000, -0.5, 9999.5);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kSPDMult);\r
-\r
-  // Ntracklets/track vs P for TRD reference tracks\r
-  Double_t binsP[19] = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0,\r
-                       2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hNTrackletsTRD_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hNTrackletsTRD_cent%d",iCent+1), Form("TRD Ntracklets/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                                              iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 7, -0.5, 6.5);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kNTrackletsTRD+iCent);\r
-  }\r
-  \r
-  // Nclusters/track vs P for TRD reference tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hNClsTrackTRD_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hNClsTrackTRD_cent%d",iCent+1), Form("TRD Nclusters/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                                             iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 300, 0., 300.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kNClsTrackTRD+iCent);\r
-  }  \r
-\r
-  // <PH> vs slice number for TRD reference tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSlice_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSlice_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                   iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 200, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSlice+iCent);\r
-  }\r
-\r
-  // <PH> vs slice number for TRD reference tracklets, from TPC pions\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCpions_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSliceTPCpions_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC pions",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSliceTPCpions+iCent);\r
-  }\r
-\r
-  // TPC dE/dx vs P for TRD reference tracks, pions\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxPions_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hTPCdedxPions_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC pions, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                        iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCdedxPions+iCent);\r
-  }\r
-\r
-  // <PH> vs slice number for TRD reference tracklets, from TPC electrons\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCelectrons_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSliceTPCelectrons_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d,|#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC electrons",\r
-                                               iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSliceTPCelectrons+iCent);\r
-  }\r
-\r
-  // TPC dE/dx vs P for TRD reference tracks, electrons\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxElectrons_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hTPCdedxElectrons_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC electrons, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                            iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCdedxElectrons+iCent);\r
-  }\r
-\r
-  // Qtot vs P for TRD reference tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hQtotP_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hQtotP_cent%d",iCent+1), Form("Qtot(from slices) vs P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 400, 0., 20);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kQtotP+iCent);\r
-  }\r
-  \r
-  // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-  if(!(h = (TH3F*)gROOT->FindObject("hPropagXYvsP"))){\r
-    h = new TH3F("hPropagXYvsP", Form("(x,y) vs P after AliESDtrack::PropagateTo(r=300.), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-500,500, 100,-500,500, 10, 0.,10.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPropagXYvsP);\r
-  \r
-  // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-  if(!(h = (TH3F*)gROOT->FindObject("hPropagRZvsP"))){\r
-    h = new TH3F("hPropagRZvsP", Form("(r,z) vs P after AliESDtrack::PropagateTo(r=300.), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-350., 350., 100,0.,500., 10, 0.,10.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPropagRZvsP);\r
-  \r
-  Double_t etaBinLimits[101];  \r
-  for(Int_t i=0; i<101; i++) etaBinLimits[i] = -1.0 + i*2.0/100.;\r
-  Double_t phiBinLimits[151];\r
-  for(Int_t i=0; i<151; i++) phiBinLimits[i] = -1.1*TMath::Pi() + i*2.2*TMath::Pi()/150.;\r
-  // (eta,detector phi,P) distribution of reference TPC positive tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksPos_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTPCRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCRefTracksPos+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TPC negative tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksNeg_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTPCRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCRefTracksNeg+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 4 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos4_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos4+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 5 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos5_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos5+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 6 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos6_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos6+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 4 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg4_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg4+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 5 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg5_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg5+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 6 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg6_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg6+iCent);\r
-  }\r
-\r
-\r
-  // (eta,detector phi) profile of average number of TRD tracklets/track\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1)))){\r
-      h = new TProfile2D(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta,detector #varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDEtaPhiAvNtrkl+iCent);\r
-  }\r
-\r
-  // (eta,delta phi) profile of average number of TRD tracklets/track\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1)))){\r
-      h = new TProfile2D(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta, #Delta#varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                       iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 50, -0.4*TMath::Pi(), 0.4*TMath::Pi());\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDEtaDeltaPhiAvNtrkl+iCent);\r
-  }  \r
-\r
-  // (eta, detector phi) profile of average tracklet Qtot from slices\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    for(Int_t iLayer=0;iLayer<6;iLayer++) {\r
-      if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1)))) {\r
-       h = new TProfile2D(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1),\r
-                          Form("<Q_{tot}> vs (#eta, detector #varphi) for TRD reference tracks (layer %d), centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                               iLayer, iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());\r
-      } else h->Reset();\r
-      fHistos->AddAt(h, kTRDEtaPhiAvQtot+iCent*6+iLayer);\r
-    }\r
-  }\r
-  \r
-  // Trigger definitions\r
-  if(!(h=(TH1F*)gROOT->FindObject("hTriggerDefs"))) {\r
-    h = new TH1F("hTriggerDefs", "Trigger definitions", kNMaxAssignedTriggers, 0.5, 0.5+Float_t(kNMaxAssignedTriggers));\r
-  }\r
-  else h->Reset();\r
-  fHistos->AddAt(h, kTriggerDefs);\r
-\r
-  // dummy histo\r
-  if(!(h=(TH1F*)gROOT->FindObject("hDummy"))) {\r
-    h = new TH1F("hDummy", "Dummy hist", 10, 0., 1.);\r
-  }\r
-  else h->Reset();\r
-  fHistos->AddAt(h, 0);\r
-  \r
-  fMatchingPhiEtaCF = CreateCFContainer("MatchingPhiEta", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fMatchingPhiEtaCF, kMatchingPhiEtaCF);\r
-  fMatchingPtCF = CreateCFContainer("MatchingPt", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fMatchingPtCF, kMatchingPtCF);\r
-  fBunchCrossingsCF = CreateCFContainer("BunchCrossingsCF", "CF container with bunch crossings dependent data");\r
-  fHistos->AddAt(fBunchCrossingsCF, kBunchCrossingsCF);\r
-  fCentralityCF = CreateCFContainer("CentralityCF", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fCentralityCF, kCentralityCF);\r
-  fQtotCF = CreateCFContainer("QtotCF", "CF container with TRD tracklet charge data");\r
-  fHistos->AddAt(fQtotCF, kQtotCF);\r
-  fPulseHeightCF = CreateCFContainer("PulseHeightCF", "CF container with TRD tracklet PH data");\r
-  fHistos->AddAt(fPulseHeightCF, kPulseHeightCF);\r
-  fExpertCF = CreateCFContainer("ExpertCF", "CF container with customized information");\r
-  if(fExpertCF) fHistos->AddAt(fExpertCF, kExpertCF);\r
-  \r
-  return fHistos;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-void AliTRDcheckESD::InitializeCFContainers() {\r
-  //\r
-  //  Initialize the CF container\r
-  //\r
-  AliAnalysisManager* man=AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());\r
-  if(!inputHandler) return;\r
-\r
-  GetTriggerIndex("All triggers", kTRUE);\r
-\r
-  AliPhysicsSelection* physSel = (AliPhysicsSelection*)inputHandler->GetEventSelection();\r
-  const TList* trigList = (physSel ? physSel->GetCollisionTriggerClasses() : 0x0);\r
-  const TList* bgTrigList = (physSel ? physSel->GetBGTriggerClasses() : 0x0);\r
-  \r
-  // Add collision triggers from PhysicsSelection\r
-  if(trigList) {\r
-    for(Int_t it=0; it<trigList->GetEntries(); ++it) {\r
-      TString trigName = trigList->At(it)->GetName();\r
-      TObjArray* arr = trigName.Tokenize(" ");\r
-      trigName = arr->At(0)->GetName();\r
-      trigName.Remove(0,1);\r
-      TObjArray* arr2 = trigName.Tokenize(",");\r
-      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {\r
-        // Assign an index into the trigger histogram and the CF container for this trigger\r
-        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);\r
-      }\r
-      delete arr;\r
-    }\r
-  }\r
-  // Add background triggers from PhysicsSelection\r
-  if(bgTrigList) {\r
-    for(Int_t it=0; it<bgTrigList->GetEntries(); ++it) {\r
-      TString trigName = bgTrigList->At(it)->GetName();\r
-      TObjArray* arr = trigName.Tokenize(" ");\r
-      trigName = arr->At(0)->GetName();\r
-      trigName.Remove(0,1);\r
-      TObjArray* arr2 = trigName.Tokenize(",");\r
-      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {\r
-        // Assign an index into the trigger histogram and the CF container for this trigger\r
-        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);\r
-      }\r
-      delete arr;\r
-    }\r
-  }\r
-    \r
-  // Add user enabled triggers\r
-  TObjArray* arr = fUserEnabledTriggers.Tokenize(";");\r
-  for(Int_t it=0; it<arr->GetEntries(); ++it) {\r
-    GetTriggerIndex(arr->At(it)->GetName(), kTRUE);\r
-  }\r
-  delete arr;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-AliCFContainer* AliTRDcheckESD::CreateCFContainer(const Char_t* name, const Char_t* title) {\r
-  //\r
-  //  make a CF container\r
-  //\r
-  // create a CF container and add it to the list of histograms\r
-  Int_t nbinsCf[kNTrdCfVariables];\r
-  for(Int_t i=0;i<kNTrdCfVariables;++i) nbinsCf[i]=0;\r
-  nbinsCf[kEventVtxZ]         =    5;\r
-  nbinsCf[kEventMult]         =    5;\r
-  nbinsCf[kEventTrigger]      =    kNMaxAssignedTriggers;\r
-  nbinsCf[kEventBC]           = 3500;\r
-  nbinsCf[kTrackTOFBC]        =    2;\r
-  nbinsCf[kTrackDCAxy]        =    9;\r
-  nbinsCf[kTrackDCAz]         =    5;\r
-  nbinsCf[kTrackCharge]       =    2;\r
-  nbinsCf[kTrackPhi]          =  180;\r
-  nbinsCf[kTrackEta]          =   90;\r
-  nbinsCf[kTrackPt]           =   18;\r
-  nbinsCf[kTrackP]            =   17;\r
-  nbinsCf[kTrackTrdTracklets] =    7;\r
-  nbinsCf[kTrackTrdClusters]  =  200;\r
-  for(Int_t i=0;i<6;++i) nbinsCf[kTrackQtot+i] = 100;\r
-  for(Int_t i=0;i<8;++i) nbinsCf[kTrackPHslice+i] = 400;\r
-  //Double_t evVtxLims[2]      = {-10.,+10.};\r
-  Double_t evMultLims[6]     = {0.0, 700., 1400., 2100., 2800., 3500.};\r
-  Double_t evTriggerLims[2]  = {0.5, 0.5+Float_t(kNMaxAssignedTriggers)};\r
-  Double_t evBCLims[2]       = {-0.5, +3499.5};\r
-  //Double_t trkTOFBClims[3]   = {-0.5, 0.5, 5.5};\r
-  //Double_t trkDCAxyLims[10]  = {-10.0,  -6.0, -3.0,  -2.0,  -1.0,   \r
-  //                               +1.0, +2.0,  +3.0,  +6.0, +10.0};    \r
-  //Double_t trkDCAzLims[2]    = {-15.0, +15.0};    \r
-  Double_t trkChargeLims[2]  = {-1.5, +1.5};\r
-  Double_t trkPhiLims[2]     = {-1.001*TMath::Pi(), +1.001*TMath::Pi()};\r
-  Double_t trkEtaLims[2]     = {-0.9, +0.9};\r
-  Double_t trkPtLims[19]     = {0.0, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, \r
-                                3.5, 4.0, 4.5,  5.0, 6.0,  7.0, 8.0,  9.0, 10.0};\r
-  Double_t trkPLims[18]      = {0.0, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0, 2.5, \r
-                                3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};\r
-  Double_t trkTrdNLims[2]    = {-0.5, 6.5};\r
-  Double_t trkTrdNclsLims[2] = {-0.5, 199.5};\r
-  Double_t trkQtotLims[2]    = {0.0, 20.};\r
-  /*Double_t trkQtotLims[20]   = {0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0,\r
-                                5.5, 6.0, 6.5, 7.0, 8.0, 9.0,10.0,12.0,15.0,20.0};*/\r
-  const Char_t* varNames[kNTrdCfVariables] = {"vtxZ", "multiplicity", "trigger", "BC", "TOFBC", "DCAxy", "DCAz",\r
-    "charge", "phi", "eta", "pt", "P", "tracklets", "clusters", \r
-    "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7",\r
-    "Qtot0", "Qtot1", "Qtot2", "Qtot3", "Qtot4", "Qtot5"};\r
-  \r
-  AliCFContainer* cf;\r
-  TString nameStr=name;\r
-  if(nameStr.Contains("MatchingPhiEta")) {\r
-    fMatchingPhiEtaCFVars[0] = kTrackCharge;       fMatchingPhiEtaCFVars[1] = kTrackPhi; fMatchingPhiEtaCFVars[2] = kTrackEta;\r
-    fMatchingPhiEtaCFVars[3] = kTrackTrdTracklets; fMatchingPhiEtaCFVars[4] = kEventTrigger;\r
-    const Int_t nVars = 5;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPhiEtaCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, trkChargeLims[0], trkChargeLims[1]);\r
-    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(2, trkEtaLims[0], trkEtaLims[1]);\r
-    cf->SetBinLimits(3, trkTrdNLims[0], trkTrdNLims[1]);\r
-    cf->SetBinLimits(4, evTriggerLims[0], evTriggerLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPhiEtaCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("MatchingPt")) {\r
-    fMatchingPtCFVars[0] = kEventMult; fMatchingPtCFVars[1] = kTrackCharge;        fMatchingPtCFVars[2] = kTrackPhi; \r
-    fMatchingPtCFVars[3] = kTrackPt;   fMatchingPtCFVars[4] = kTrackTrdTracklets;  fMatchingPtCFVars[5] = kEventTrigger;\r
-    const Int_t nVars = 6;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPtCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, evMultLims);\r
-    cf->SetBinLimits(1, trkChargeLims[0], trkChargeLims[1]);\r
-    cf->SetBinLimits(2, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(3, trkPtLims);\r
-    cf->SetBinLimits(4, trkTrdNLims[0], trkTrdNLims[1]);\r
-    cf->SetBinLimits(5, evTriggerLims[0], evTriggerLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPtCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("BunchCrossings")) {\r
-    fBunchCrossingsCFVars[0] = kEventBC; fBunchCrossingsCFVars[1] = kTrackPhi;\r
-    const Int_t nVars = 2;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fBunchCrossingsCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, evBCLims[0], evBCLims[1]);\r
-    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fBunchCrossingsCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Centrality")) {\r
-    fCentralityCFVars[0] = kEventMult; fCentralityCFVars[1] = kTrackP; fCentralityCFVars[2] = kTrackTrdClusters; \r
-    fCentralityCFVars[3] = kTrackQtot; fCentralityCFVars[4] = kEventTrigger;\r
-    const Int_t nVars = 5;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fCentralityCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    cf->SetBinLimits(0, evMultLims);\r
-    cf->SetBinLimits(1, trkPLims);\r
-    cf->SetBinLimits(2, trkTrdNclsLims[0], trkTrdNclsLims[1]);\r
-    cf->SetBinLimits(3, trkQtotLims[0], trkQtotLims[1]);\r
-    cf->SetBinLimits(4, evTriggerLims[0], evTriggerLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fCentralityCFVars[i]]);\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Qtot")) {\r
-    fQtotCFVars[0] = kTrackPhi; fQtotCFVars[1] = kTrackEta; fQtotCFVars[2] = kTrackQtot; \r
-    fQtotCFVars[3] = kEventTrigger;\r
-    const Int_t nVars = 5;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fQtotCFVars[i]];\r
-    nBins[2] = 50;\r
-    nBins[nVars-1] = 6;\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    cf->SetBinLimits(0, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(1, trkEtaLims[0], trkEtaLims[1]);\r
-    cf->SetBinLimits(2, trkQtotLims[0], trkQtotLims[1]);\r
-    cf->SetBinLimits(3, evTriggerLims[0], evTriggerLims[1]);\r
-    cf->SetBinLimits(4, -0.5, 5.5);\r
-    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fQtotCFVars[i]]);\r
-    cf->SetVarTitle(nVars-1, "layer");\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("PulseHeight")) {\r
-    fPulseHeightCFVars[0] = kTrackP; fPulseHeightCFVars[1] = kTrackPHslice; fPulseHeightCFVars[2] = kEventTrigger;\r
-    const Int_t nVars = 4;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fPulseHeightCFVars[i]];\r
-    nBins[nVars-1] = 8;\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    //cf->SetBinLimits(0, evTriggerLims[0], evTriggerLims[1]);\r
-    cf->SetBinLimits(0, trkPLims);\r
-    cf->SetBinLimits(1, trkQtotLims[0], trkQtotLims[1]);\r
-    cf->SetBinLimits(2, evTriggerLims[0], evTriggerLims[1]);\r
-    cf->SetBinLimits(3, -0.5, 7.5);\r
-    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fPulseHeightCFVars[i]]);\r
-    cf->SetVarTitle(nVars-1, "slice");\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Expert")) {\r
-    Int_t nVars = 0;\r
-    Int_t nBins[kNTrdCfVariables];\r
-    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {\r
-      if(!fExpertCFVarsEnabled[ivar]) continue;\r
-      if(fExpertCFVarBins[ivar][0]=='\0') {\r
-       nBins[nVars] = fExpertCFVarNBins[ivar];\r
-       nVars++;\r
-      }\r
-      else {\r
-       TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");\r
-       nBins[nVars] = arr->GetEntries()-1;\r
-       if(nBins[nVars]>0) nVars++;\r
-       delete arr;\r
-      }\r
-    }\r
-    if(nVars<1) return 0x0;\r
-    Int_t nSteps = 0; for(Int_t i=0; i<3; ++i) if(fExpertCFEnabledSteps[i]) nSteps++;\r
-    if(nSteps<1) return 0x0;\r
-    cf = new AliCFContainer(name, title, nSteps, nVars, nBins);\r
-    Int_t iUsedVar = 0;\r
-    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {\r
-      if(!fExpertCFVarsEnabled[ivar]) continue;\r
-      if(fExpertCFVarBins[ivar][0]=='\0')\r
-       cf->SetBinLimits(iUsedVar, fExpertCFVarRanges[ivar][0], fExpertCFVarRanges[ivar][1]);\r
-      else {\r
-       TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");\r
-       if(arr->GetEntries()-1>0) {\r
-         Double_t* binLims = new Double_t[arr->GetEntries()];\r
-         for(Int_t ib=0;ib<arr->GetEntries();++ib) {\r
-           TString binStr = arr->At(ib)->GetName();\r
-           binLims[ib] = binStr.Atof();\r
-         }\r
-         cf->SetBinLimits(iUsedVar++, binLims);\r
-       }\r
-       delete arr;\r
-      }\r
-      cf->SetVarTitle(iUsedVar, varNames[ivar]);\r
-    }\r
-    const Char_t* stepNames[3] = {"TPC","TRD","TOF"};\r
-    Int_t iUsedStep = 0;\r
-    for(Int_t istep=0; istep<3; ++istep) {\r
-      if(fExpertCFEnabledSteps[istep]) cf->SetStepTitle(iUsedStep++, stepNames[istep]);\r
-    }\r
-    return cf;\r
-  }  \r
-  return 0x0;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-Bool_t AliTRDcheckESD::Load(const Char_t *file, const Char_t *dir, const Char_t *name)\r
-{\r
-// Load data from performance file\r
-\r
-  if(!TFile::Open(file)){\r
-    AliWarning(Form("Couldn't open file %s.", file));\r
-    return kFALSE;\r
-  }\r
-  if(dir){\r
-    if(!gFile->cd(dir)){\r
-      AliWarning(Form("Couldn't cd to %s in %s.", dir, file));\r
-      return kFALSE;\r
-    }\r
-  }\r
-  TObjArray *o(NULL);\r
-  const Char_t *tn=(name ? name : GetName());\r
-  if(!(o = (TObjArray*)gDirectory->Get(tn))){\r
-    AliWarning(Form("Missing histogram container %s.", tn));\r
-    return kFALSE;\r
-  }\r
-  fHistos = (TObjArray*)o->Clone(GetName());\r
-  fMatchingPhiEtaCF = (AliCFContainer*)fHistos->At(kMatchingPhiEtaCF);\r
-  fMatchingPtCF = (AliCFContainer*)fHistos->At(kMatchingPtCF);\r
-  fBunchCrossingsCF = (AliCFContainer*)fHistos->At(kBunchCrossingsCF);\r
-  fCentralityCF = (AliCFContainer*)fHistos->At(kCentralityCF);\r
-  fQtotCF = (AliCFContainer*)fHistos->At(kQtotCF);\r
-  fPulseHeightCF = (AliCFContainer*)fHistos->At(kPulseHeightCF);\r
-  fExpertCF = (AliCFContainer*)fHistos->At(kExpertCF);\r
-  \r
-  /*\r
-  TObjArray *cfs(NULL);\r
-  if(!(cfs = (TObjArray*)gDirectory->Get(Form("%s_CF", tn)))){\r
-    AliWarning(Form("Missing CFs container %s_CF.", tn));\r
-    fCfList = NULL;\r
-    //return kFALSE;\r
-  } \r
-  else\r
-    fCfList = (TObjArray*)cfs->Clone(Form("%s_CF_clone", GetName()));\r
-  */\r
-  \r
-  gFile->Close();\r
-  return kTRUE;\r
-}\r
-\r
-//_______________________________________________________\r
-Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val)\r
-{\r
-// Dump trending value to default file\r
-\r
-  if(!fgFile){\r
-    fgFile = fopen("TRD.Performance.txt", "at");\r
-  }\r
-  fprintf(fgFile, "%s_%s %f\n", GetName(), name, val);\r
-  return kTRUE;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::Terminate(Option_t *)\r
-{\r
-  // Steer post-processing \r
-  if(!fHistos){\r
-    fHistos = dynamic_cast<TObjArray *>(GetOutputData(1));\r
-    if(!fHistos){\r
-      AliError("Histogram container not found in output");\r
-      return;\r
-    }\r
-  }\r
-\r
-  //  fNRefFigures = 15;\r
-  //  return;\r
-\r
-  const Char_t *name[kNrefs] = {\r
-    "Ncl", "Eff", "Eloss", "PtResDCA"\r
-  };\r
-\r
-  TObjArray *arr(NULL); TGraph *g(NULL);\r
-  if(!fResults){\r
-    fResults = new TObjArray(kNrefs);\r
-    fResults->SetOwner();\r
-    fResults->SetName("results");\r
-    for(Int_t iref(0); iref<kNrefs; iref++){\r
-      fResults->AddAt(arr = new TObjArray(fgkNgraph[iref]), iref);\r
-      arr->SetName(name[iref]);  arr->SetOwner();\r
-      switch(iref+1){\r
-      case kNCl:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-          g->SetName(Form("s%d", ig));\r
-          switch(ig){\r
-          case 0: g->SetTitle("ALL"); break;\r
-          case 1: g->SetTitle("NEG"); break;\r
-          case 2: g->SetTitle("POS"); break;\r
-          default: g->SetTitle(AliPID::ParticleLatexName(ig-3)); break;\r
-          };\r
-        }\r
-        break;\r
-      case kTRDmom:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphAsymmErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-        }\r
-        break;\r
-      case kPtRes:\r
-       for(Int_t idx(0); idx<AliPID::kSPECIES; idx++){\r
-          Int_t ig(2*idx);\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(kRed-idx); \r
-          g->SetMarkerColor(kRed-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("s%d", ig), Form("res %s", AliPID::ParticleLatexName(idx)));\r
-          arr->AddAt(g = new TGraphErrors(), ig+1);\r
-          g->SetLineColor(kBlue-idx); \r
-          g->SetMarkerColor(kBlue-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("m%d", ig+1), Form("sys %s", AliPID::ParticleLatexName(idx)));\r
-\r
-          ig+=10;\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(kRed-idx); \r
-          g->SetMarkerColor(kRed-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("s%d", ig), Form("sigma %s", AliPID::ParticleLatexName(idx)));\r
-          arr->AddAt(g = new TGraphErrors(), ig+1);\r
-          g->SetLineColor(kBlue-idx); \r
-          g->SetMarkerColor(kBlue-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("m%d", ig+1), Form("mean %s", AliPID::ParticleLatexName(idx)));\r
-        }\r
-        break;\r
-      default:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  TH1 *h1[2] = {NULL, NULL};\r
-  TH2I *h2(NULL);\r
-  TAxis *ax(NULL);\r
-\r
-  // No of clusters\r
-  if(!(h2 = (TH2I*)fHistos->At(kNCl))) return;\r
-  ax = h2->GetXaxis();\r
-  arr = (TObjArray*)fResults->At(kNCl);\r
-  \r
-  // All tracks\r
-  h1[0] = h2->ProjectionX("Ncl_px");\r
-  TGraphErrors *ge=(TGraphErrors*)arr->At(0);\r
-  if (ge) {\r
-    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-      ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));\r
-    }\r
-  }\r
-  \r
-  // All charged tracks\r
-  TH1 *hNclCh[2] = {(TH1D*)h1[0]->Clone("NEG"), (TH1D*)h1[0]->Clone("POS")};\r
-  hNclCh[0]->Reset();hNclCh[1]->Reset();\r
-  for(Int_t is(1); is<=AliPID::kSPECIES; is++){\r
-    hNclCh[0]->Add(h2->ProjectionX("Ncl_px", 2*is-1, 2*is-1)); // neg\r
-    hNclCh[1]->Add(h2->ProjectionX("Ncl_px", 2*is, 2*is));     // pos\r
-  }\r
-  if(Int_t(hNclCh[0]->GetEntries())){\r
-    ge=(TGraphErrors*)arr->At(1);\r
-    if (ge) {\r
-      for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-       ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[0]->GetBinContent(ib));\r
-      }\r
-    }\r
-  }\r
-  \r
-  if(Int_t(hNclCh[1]->GetEntries())){\r
-    ge=(TGraphErrors*)arr->At(2);\r
-    if (ge) {\r
-      for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-       ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[1]->GetBinContent(ib));\r
-      }\r
-    }\r
-  }\r
-  // Species wise\r
-  for(Int_t is(1); is<=AliPID::kSPECIES; is++){\r
-    h1[0] = h2->ProjectionX("Ncl_px", 2*is-1, 2*is);\r
-    if(!Int_t(h1[0]->GetEntries())) continue;\r
-    ge=(TGraphErrors*)arr->At(2+is);\r
-    if (ge) {\r
-      for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-       ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));\r
-      }\r
-    }\r
-  }\r
-  \r
-  fNRefFigures = 1;\r
-\r
-  // EFFICIENCY\r
-  // geometrical efficiency\r
-  if(!(h2 = (TH2I*)fHistos->At(kTRDstat))) return;\r
-  arr = (TObjArray*)fResults->At(kTRDstat-1);\r
-  h1[0] = h2->ProjectionX("checkESDx0", kTPCout, kTPCout);\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDin, kTRDin);\r
-  Process(h1, (TGraphErrors*)arr->At(0));\r
-  delete h1[0];delete h1[1];\r
-  // tracking efficiency\r
-  h1[0] = h2->ProjectionX("checkESDx0", kTRDin, kTRDin);\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDout, kTRDout);\r
-  Process(h1, (TGraphErrors*)arr->At(1));\r
-  delete h1[1];\r
-  // PID efficiency\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDpid, kTRDpid);\r
-  Process(h1, (TGraphErrors*)arr->At(2));\r
-  delete h1[1];\r
-  // Refit efficiency\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDref, kTRDref);\r
-  Process(h1, (TGraphErrors*)arr->At(3));\r
-  delete h1[1];\r
-  fNRefFigures++;\r
-\r
-  // ENERGY LOSS\r
-  if(!(h2 = dynamic_cast<TH2I*>(fHistos->At(kTRDmom)))) return;\r
-  arr = (TObjArray*)fResults->At(kTRDmom-1);\r
-  TGraphAsymmErrors *g06 = (TGraphAsymmErrors*)arr->At(0), *g09 = (TGraphAsymmErrors*)arr->At(1);\r
-  ax=h2->GetXaxis();\r
-  const Int_t nq(4);\r
-  const Double_t xq[nq] = {0.05, 0.2, 0.8, 0.95};\r
-  Double_t yq[nq];\r
-  for(Int_t ily=6; ily--;){\r
-    h1[0] = h2->ProjectionX("checkESDp0", ily+1, ily+1);\r
-    h1[0]->GetQuantiles(nq,yq,xq);\r
-    g06->SetPoint(ily, Float_t(ily), ax->GetBinCenter(h1[0]->GetMaximumBin()));\r
-    g06->SetPointError(ily, 0., 0., TMath::Abs(yq[0]), yq[3]);\r
-    g09->SetPoint(ily, Float_t(ily), h1[0]->GetMean());\r
-    g09->SetPointError(ily, 0., 0., TMath::Abs(yq[1]), yq[2]);\r
-\r
-    //printf(" max[%f] mean[%f] q[%f %f %f %f]\n", ax->GetBinCenter(h1[0]->GetMaximumBin()), h1[0]->GetMean(), yq[0], yq[1], yq[2], yq[3]);\r
-    delete h1[0];\r
-  }\r
-  fNRefFigures++;\r
-//  if(!HasMC()) return;\r
-\r
-  // Pt RESOLUTION @ DCA\r
-  TH3S* h3(NULL); TGraphErrors *gg[2] = {NULL,NULL};\r
-  if(!(h3 = dynamic_cast<TH3S*>(fHistos->At(kPtRes)))) return;\r
-  arr = (TObjArray*)fResults->At(kPtRes-1);\r
-  TAxis *az(h3->GetZaxis());\r
-  for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-    Int_t idx(2*i);\r
-    az->SetRange(idx+1, idx+2); \r
-    gg[1] = (TGraphErrors*)arr->At(idx);\r
-    gg[0] = (TGraphErrors*)arr->At(idx+1);\r
-    Process2D((TH2*)h3->Project3D("yx"), gg);\r
-\r
-    idx+=10;\r
-    az->SetRange(idx+1, idx+2); \r
-    gg[1] = (TGraphErrors*)arr->At(idx);\r
-    gg[0] = (TGraphErrors*)arr->At(idx+1);\r
-    Process2D((TH2*)h3->Project3D("yx"), gg);\r
-  }\r
-  fNRefFigures++;\r
-  \r
-  fNRefFigures++;\r
-  // 3x3 tracking summary canvases for every centrality class\r
-  fNRefFigures++;\r
-  // 3x3 PID summary canvases for every centrality class\r
-  fNRefFigures++;\r
-  // 3x3 for centrality dependent pictures\r
-  fNRefFigures++;\r
-  \r
-  //DoTrending();  \r
-}\r
-\r
-//____________________________________________________________________\r
-Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg) const\r
-{\r
-  //\r
-  // Helper function converting PDG code into AliPID index\r
-  //\r
-  switch(pdg){\r
-  case kElectron: \r
-  case kPositron: return AliPID::kElectron;  \r
-  case kMuonPlus:\r
-  case kMuonMinus: return AliPID::kMuon;  \r
-  case kPiPlus: \r
-  case kPiMinus: return AliPID::kPion;  \r
-  case kKPlus: \r
-  case kKMinus: return AliPID::kKaon;\r
-  case kProton: \r
-  case kProtonBar: return AliPID::kProton;\r
-  } \r
-  return -1;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::Process(TH1 **h1, TGraphErrors *g)\r
-{\r
-// Generic function to process one reference plot\r
-\r
-  Int_t n1 = 0, n2 = 0, ip=0;\r
-  Double_t eff = 0.;\r
-\r
-  TAxis *ax = h1[0]->GetXaxis();\r
-  for(Int_t ib=1; ib<=ax->GetNbins(); ib++){\r
-    if(!(n1 = (Int_t)h1[0]->GetBinContent(ib))) continue;\r
-    n2 = (Int_t)h1[1]->GetBinContent(ib);\r
-    eff = n2/Float_t(n1);\r
-\r
-    ip=g->GetN();\r
-    g->SetPoint(ip, ax->GetBinCenter(ib), eff);\r
-    g->SetPointError(ip, 0., n2 ? eff*TMath::Sqrt(1./n1+1./n2) : 0.);\r
-  }\r
-}  \r
-//________________________________________________________\r
-void AliTRDcheckESD::Process2D(TH2 * const h2, TGraphErrors **g)\r
-{\r
-  //\r
-  // Do the processing\r
-  //\r
-\r
-  Int_t n = 0;\r
-  if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);\r
-  if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);\r
-  TF1 f("fg", "gaus", -3.,3.);\r
-  for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){\r
-    Double_t x = h2->GetXaxis()->GetBinCenter(ibin);\r
-    TH1D *h = h2->ProjectionY("py", ibin, ibin);\r
-    if(h->GetEntries()<100) continue;\r
-    //AdjustF1(h, f);\r
-\r
-    h->Fit(&f, "QN");\r
-    Int_t ip = g[0]->GetN();\r
-    g[0]->SetPoint(ip, x, f.GetParameter(1));\r
-    g[0]->SetPointError(ip, 0., f.GetParError(1));\r
-    g[1]->SetPoint(ip, x, f.GetParameter(2));\r
-    g[1]->SetPointError(ip, 0., f.GetParError(2));\r
-  }\r
-  return;\r
-}\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::PrintStatus(ULong_t status)\r
-{\r
-// Dump track status to stdout\r
-\r
-  printf("ITS[i(%d) o(%d) r(%d)] TPC[i(%d) o(%d) r(%d) p(%d)] TRD[i(%d) o(%d) r(%d) p(%d) s(%d)] HMPID[o(%d) p(%d)]\n"\r
-    ,Bool_t(status & AliESDtrack::kITSin)\r
-    ,Bool_t(status & AliESDtrack::kITSout)\r
-    ,Bool_t(status & AliESDtrack::kITSrefit)\r
-    ,Bool_t(status & AliESDtrack::kTPCin)\r
-    ,Bool_t(status & AliESDtrack::kTPCout)\r
-    ,Bool_t(status & AliESDtrack::kTPCrefit)\r
-    ,Bool_t(status & AliESDtrack::kTPCpid)\r
-    ,Bool_t(status & AliESDtrack::kTRDin)\r
-    ,Bool_t(status & AliESDtrack::kTRDout)\r
-    ,Bool_t(status & AliESDtrack::kTRDrefit)\r
-    ,Bool_t(status & AliESDtrack::kTRDpid)\r
-    ,Bool_t(status & AliESDtrack::kTRDStop)\r
-    ,Bool_t(status & AliESDtrack::kHMPIDout)\r
-    ,Bool_t(status & AliESDtrack::kHMPIDpid)\r
-  );\r
-}\r
-\r
-//____________________________________________________________________\r
-TH1D* AliTRDcheckESD::Proj2D(TH2* hist, TH1* mpvErr, TH1* widthErr, TH1* chi2) {\r
-  //\r
-  // project the PH vs Slice 2D-histo into a 1D histo with Landau MPV and widths\r
-  //\r
-  \r
-  TH1D* hProjection = (TH1D*)hist->ProjectionX(Form("hProjection_%f", gRandom->Rndm()));\r
-  hProjection->Reset();\r
-  \r
-  TF1* fitLandau = new TF1("landauFunc","landau",0.,2000.);\r
-  TH1D *hD;\r
-  for(Int_t iBin=1;iBin<=hist->GetXaxis()->GetNbins();iBin++) {\r
-    if(gROOT->FindObject("projection"))\r
-      delete gROOT->FindObject("projection");\r
-    hD = (TH1D*)hist->ProjectionY("projection",iBin,iBin);\r
-    //hD->Rebin(4);\r
-    if(hD->Integral()>10) {\r
-      fitLandau->SetParameter(1, hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParLimits(1, 0.2*hD->GetBinCenter(hD->GetMaximumBin()), 3.0*hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParameter(0, 1000.);\r
-      fitLandau->SetParLimits(0, 1., 10000000.);\r
-      fitLandau->SetParameter(2, 0.5*hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParLimits(2, 0.01*hD->GetBinCenter(hD->GetMaximumBin()), 1.0*hD->GetRMS());\r
-      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());\r
-      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());\r
-      hProjection->SetBinContent(iBin, fitLandau->GetParameter(1));\r
-      hProjection->SetBinError(iBin, fitLandau->GetParameter(2));\r
-      if(mpvErr) {\r
-       mpvErr->SetBinContent(iBin, fitLandau->GetParameter(1));\r
-       mpvErr->SetBinError(iBin, fitLandau->GetParError(1));\r
-      }\r
-      if(widthErr) {\r
-       widthErr->SetBinContent(iBin, fitLandau->GetParameter(2));\r
-       widthErr->SetBinError(iBin, fitLandau->GetParError(2));\r
-      }\r
-      if(chi2) {\r
-       chi2->SetBinContent(iBin, (fitLandau->GetNDF()>0 ? fitLandau->GetChisquare()/Double_t(fitLandau->GetNDF()) : 0.0));\r
-      }\r
-    }\r
-    else{\r
-      hProjection->SetBinContent(iBin, 0);\r
-      hProjection->SetBinError(iBin, 0);\r
-    }\r
-  }\r
-  return hProjection;\r
-}\r
-\r
-//____________________________________________________________________\r
-TH2F* AliTRDcheckESD::Proj3D(TH3* hist, TH2* accMap, Int_t zbinLow, Int_t zbinHigh, Float_t &entries) {\r
-  //\r
-  //  Project a 3D histogram to a 2D histogram in the Z axis interval [zbinLow,zbinHigh] \r
-  //  Return the 2D histogram and also the number of entries into this projection (entries)\r
-\r
-  Int_t nBinsX = hist->GetXaxis()->GetNbins();   // X and Y axis bins are assumed to be all equal\r
-  Float_t minX = hist->GetXaxis()->GetXmin();\r
-  Float_t maxX = hist->GetXaxis()->GetXmax();\r
-  Int_t nBinsY = hist->GetYaxis()->GetNbins();\r
-  Float_t minY = hist->GetYaxis()->GetXmin();\r
-  Float_t maxY = hist->GetYaxis()->GetXmax();\r
-  Int_t nBinsZ = hist->GetZaxis()->GetNbins();  // Z axis bins (pt) might have different widths\r
-\r
-  TH2F* projHisto = (TH2F*)gROOT->FindObject("projHisto");\r
-  if(projHisto) \r
-    projHisto->Reset();\r
-  else\r
-    projHisto = new TH2F("projHisto", "projection", nBinsX, minX, maxX, nBinsY, minY, maxY);\r
-\r
-  for(Int_t iZ=1; iZ<=nBinsZ; iZ++) {\r
-    if(iZ<zbinLow) continue;\r
-    if(iZ>zbinHigh) continue;\r
-    for(Int_t iX=1; iX<=nBinsX; iX++) {\r
-      for(Int_t iY=1; iY<=nBinsY; iY++) {\r
-        if(accMap) {\r
-          if(accMap->GetBinContent(iX,iY)>0.1)\r
-            projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));\r
-        }\r
-        else    // no acc. cut \r
-          projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));\r
-        // count only the entries which are inside the acceptance map\r
-        if(accMap) {\r
-          if(accMap->GetBinContent(iX,iY)>0.1)\r
-            entries+=hist->GetBinContent(iX,iY,iZ);\r
-        }\r
-        else    // no acc. cut\r
-          entries+=hist->GetBinContent(iX,iY,iZ);\r
-      }\r
-    }\r
-  }\r
-  return projHisto;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]) {\r
-  //\r
-  // Check the active super-modules\r
-  //\r
-  Double_t entries[18] = {0.0};\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  for(Int_t phiBin=1; phiBin<=phiProj->GetXaxis()->GetNbins(); ++phiBin) {\r
-    Double_t phi = phiProj->GetBinCenter(phiBin);\r
-    Int_t sm = -1;\r
-    for(Int_t ism=0; ism<18; ++ism) \r
-      if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1]) sm = ism;\r
-    if(sm==-1) continue;\r
-    entries[sm] += phiProj->GetBinContent(phiBin);\r
-  }\r
-  Double_t avEntries = Double_t(phiProj->Integral())/18.0;\r
-  for(Int_t ism=0; ism<18; ++ism) \r
-    if(entries[ism]>0.5*avEntries) activeSM[ism] = kTRUE;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-TH1F* AliTRDcheckESD::EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, \r
-                                         Int_t stepNom, Int_t stepDenom, const Char_t* varStr/*="pt"*/, const Char_t* type/*="TPCTRD"*/) {\r
-  //\r
-  // Use the CF container to extract the efficiency vs pt\r
-  //\r
-  Int_t varTrackPhi = cf->GetVar("phi");\r
-  Int_t var = cf->GetVar(varStr);\r
-    \r
-  TH1D* phiProj = (TH1D*)cf->Project(1, varTrackPhi);\r
-  Bool_t activeSM[18] = {kFALSE};\r
-  CheckActiveSM(phiProj, activeSM); delete phiProj;\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  \r
-  TString effTypeStr = type;\r
-  if(effTypeStr.Contains("TRDTOF")) {\r
-    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)\r
-      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));\r
-  }\r
-  TH2D* hDenomPhiVar = (TH2D*)cf->Project(stepDenom, var, varTrackPhi);\r
-  if(effTypeStr.Contains("TPCTRD")) {\r
-    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)\r
-      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));\r
-  }\r
-  TH2D* hNomPhiVar = (TH2D*)cf->Project(stepNom, var, varTrackPhi);\r
-  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);\r
-  \r
-  TH1F* hEff = new TH1F(Form("hEff%s_%d_%d_%f", varStr, stepNom, stepDenom, gRandom->Rndm()), "", \r
-                       hNomPhiVar->GetXaxis()->GetNbins(), hNomPhiVar->GetXaxis()->GetXbins()->GetArray());\r
-  for(Int_t ivar=1; ivar<=hEff->GetXaxis()->GetNbins(); ++ivar) {\r
-    Double_t nom = 0.0; Double_t denom = 0.0;\r
-    Double_t eff = 0.0; Double_t err = 0.0;\r
-    for(Int_t iphi=1; iphi<=hNomPhiVar->GetYaxis()->GetNbins(); ++iphi) {\r
-      Double_t phi = hNomPhiVar->GetYaxis()->GetBinCenter(iphi);\r
-      Bool_t isActive = kFALSE;\r
-      for(Int_t ism=0; ism<18; ++ism) \r
-        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) \r
-         isActive = kTRUE;\r
-      if(!isActive) continue;\r
-      nom += hNomPhiVar->GetBinContent(ivar, iphi);\r
-      denom += hDenomPhiVar->GetBinContent(ivar, iphi);\r
-    }\r
-    eff = (denom>0.001 ? nom/denom : 0.0);\r
-    err = (denom>0.001 && (denom-nom)>0.001 && nom>0.001 ? (TMath::Sqrt(nom*(denom-nom)/denom/denom/denom)) : 0.0);\r
-    hEff->SetBinContent(ivar, eff);\r
-    hEff->SetBinError(ivar, err);\r
-  }   // end loop over pt bins\r
-  delete hNomPhiVar; delete hDenomPhiVar;\r
-  return hEff;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-TH1F* AliTRDcheckESD::EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance) {\r
-  //\r
-  // Calculate the TRD-TPC matching efficiency as function of pt\r
-  //\r
-  \r
-  if(!tpc3D || !trd3D) return NULL;\r
-  Int_t nBinsZ = trd3D->GetZaxis()->GetNbins();\r
-  // project everything on the eta-phi map to obtain an acceptance map\r
-  Float_t nada = 0.;\r
-  TH2F *trdAcc = (useAcceptance ? (TH2F*)Proj3D(trd3D, 0x0, 1, nBinsZ, nada)->Clone(Form("trdAcc%f", gRandom->Rndm())) : 0x0);\r
-  TH1D *phiProj = (trdAcc ? trdAcc->ProjectionY(Form("phiProj%f", gRandom->Rndm())) : 0x0);\r
-  \r
-  // prepare the acceptance map\r
-  Bool_t activeSM[18] = {kFALSE};\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  if(phiProj) {\r
-    CheckActiveSM(phiProj, activeSM);   // get the active SMs\r
-    trdAcc->Reset();\r
-    // Put 1 entry in every bin which belongs to an active SM\r
-    for(Int_t iY=1; iY<=trdAcc->GetYaxis()->GetNbins(); ++iY) {\r
-      Double_t phi = trdAcc->GetYaxis()->GetBinCenter(iY);\r
-      Bool_t isActive = kFALSE;\r
-      for(Int_t ism=0; ism<18; ++ism) {\r
-        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) {\r
-         isActive = kTRUE;\r
-        }\r
-      }\r
-      if(!isActive) continue;\r
-      for(Int_t iX=1; iX<=trdAcc->GetXaxis()->GetNbins(); ++iX) \r
-        if(trdAcc->GetXaxis()->GetBinCenter(iX)>=-0.85 && trdAcc->GetXaxis()->GetBinCenter(iX)<=0.85) trdAcc->SetBinContent(iX, iY, 1.0);\r
-    }  // end for over Y(phi) bins\r
-  }  // end if phiProj\r
-    \r
-  // get the bin limits from the Z axis of 3D histos\r
-  Float_t *ptBinLimits = new Float_t[nBinsZ+1];\r
-  for(Int_t i=1; i<=nBinsZ; i++) {\r
-    ptBinLimits[i-1] = trd3D->GetZaxis()->GetBinLowEdge(i);\r
-  }\r
-  ptBinLimits[nBinsZ] = trd3D->GetZaxis()->GetBinUpEdge(nBinsZ);\r
-  \r
-  TH1F *efficiency = new TH1F(Form("eff%d", Int_t(1000000.0*gRandom->Rndm())), "TRD-TPC matching efficiency", nBinsZ, ptBinLimits);\r
-  \r
-  // loop over Z bins\r
-  Bool_t effGood = kFALSE;\r
-  for(Int_t i=1; i<=nBinsZ; i++) {\r
-    Float_t tpcEntries = 0.0; Float_t trdEntries = 0.0;\r
-    Proj3D(tpc3D, trdAcc, i, i, tpcEntries);\r
-    Proj3D(trd3D, trdAcc, i, i, trdEntries);\r
-    Float_t ratio = 0;\r
-    if(tpcEntries>0) ratio = trdEntries/tpcEntries;\r
-    Float_t error = 0;\r
-    if(tpcEntries>0 && trdEntries>0 && (tpcEntries-trdEntries)>=0.0) \r
-      error = TMath::Sqrt(trdEntries*(tpcEntries-trdEntries)/tpcEntries/tpcEntries/tpcEntries);\r
-    if(ratio>0.001) {\r
-      efficiency->SetBinContent(i,ratio);\r
-      efficiency->SetBinError(i,error);\r
-      effGood = kTRUE;\r
-    }\r
-  }     // end loop over Z bins\r
-  if(!effGood) return 0x0;\r
-  \r
-  return efficiency;\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::PlotCentSummaryFromCF(Double_t* /*trendValues*/, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  // Make the centrality summary figure from the CF container \r
-  // \r
-  if(!fMatchingPtCF) return;\r
-  AliCFContainer* cf = 0x0;    \r
-  \r
-  TLatex* lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001); gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  TVirtualPad* pad=0x0;\r
-  \r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.3);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  \r
-  Int_t padsForEffs[5] = {0,3,6,1,4};\r
-  for(Int_t iCent=1; iCent<6; ++iCent) {\r
-    pad = ((TVirtualPad*)l->At(padsForEffs[iCent-1])); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEffPt->Draw();\r
-    TLine line;\r
-    line.SetLineStyle(2);\r
-    line.SetLineWidth(2);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-    \r
-    cf = fMatchingPtCF;\r
-    cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-       \r
-    cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  \r
-    TH1F* hEffPosAll = EfficiencyFromPhiPt(cf,  0,  6, 1, 0);\r
-    TH1F* hEffPosTrk4 = EfficiencyFromPhiPt(cf, 4,  4, 1, 0);  \r
-    TH1F* hEffPosTrk5 = EfficiencyFromPhiPt(cf, 5,  5, 1, 0);\r
-    TH1F* hEffPosTrk6 = EfficiencyFromPhiPt(cf, 6,  6, 1, 0);\r
-     \r
-    cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  \r
-    TH1F* hEffNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);  \r
-    TH1F* hEffNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);  \r
-    TH1F* hEffNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);  \r
-    TH1F* hEffNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-    cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);  \r
-    cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  \r
-    \r
-    SetStyle(hEffPosAll,  1, kRed, 1, 24, kRed, 1);\r
-    SetStyle(hEffPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-    SetStyle(hEffPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-    SetStyle(hEffPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-    SetStyle(hEffNegAll,  1, kBlue, 1, 24, kBlue, 1);\r
-    SetStyle(hEffNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-    SetStyle(hEffNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-    SetStyle(hEffNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-    hEffPosAll->Draw("same");\r
-    hEffNegAll->Draw("same");\r
-    hEffPosTrk4->Draw("same");\r
-    hEffNegTrk4->Draw("same");\r
-    hEffPosTrk5->Draw("same");\r
-    hEffNegTrk5->Draw("same");\r
-    hEffPosTrk6->Draw("same");\r
-    hEffNegTrk6->Draw("same");    \r
-        \r
-    TLegend* leg=new TLegend(0.18, 0.7, 0.77, 0.89);\r
-    if(iCent==1) {\r
-      leg->SetFillColor(0);\r
-      leg->SetNColumns(2);\r
-      leg->SetMargin(0.1);\r
-      leg->SetBorderSize(0);\r
-      leg->AddEntry(hEffPosAll,  "pos. (#geq 1 tracklet)", "p");\r
-      leg->AddEntry(hEffNegAll,  "neg. (#geq 1 tracklet)", "p");\r
-      leg->AddEntry(hEffPosTrk4, "pos. (4 tracklets)", "p");\r
-      leg->AddEntry(hEffNegTrk4, "neg. (4 tracklets)", "p");\r
-      leg->AddEntry(hEffPosTrk5, "pos. (5 tracklets)", "p");\r
-      leg->AddEntry(hEffNegTrk5, "neg. (5 tracklets)", "p");\r
-      leg->AddEntry(hEffPosTrk6, "pos. (6 tracklets)", "p");     \r
-      leg->AddEntry(hEffNegTrk6, "neg. (6 tracklets)", "p");\r
-      leg->Draw();\r
-    }\r
-    lat->DrawLatex(0.2, 1.32, Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent)));\r
-  }   // end for loop over multiplicity classes\r
-  \r
-  // Reset the modified user ranges of the CF container\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0., 3500.);\r
-     \r
-  // Cluster distributions in all multiplicity classes\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");\r
-  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);\r
-  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNcls->SetStats(kFALSE);\r
-  rangeNcls->Draw();\r
-    \r
-  TH1D* hNcls[6]={0x0};\r
-  TLegend* legCls=new TLegend(0.7, 0.75, 0.97, 0.97);\r
-  legCls->SetBorderSize(0);\r
-  legCls->SetFillColor(0);\r
-  legCls->SetMargin(0.15);\r
-  cf = fCentralityCF;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    if(iCent>0)\r
-      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-    hNcls[iCent] = (TH1D*)cf->Project(0, cf->GetVar("clusters"));\r
-    if(!hNcls[iCent]) continue;\r
-    \r
-    hNcls[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-    Double_t maximum = hNcls[iCent]->GetMaximum();\r
-    if(maximum>1.0)\r
-      hNcls[iCent]->Scale(1.0/maximum);\r
-    hNcls[iCent]->SetStats(kFALSE);\r
-    hNcls[iCent]->SetTitle("");\r
-    hNcls[iCent]->SetLineWidth(2);\r
-    \r
-    if(hNcls[iCent]->Integral()>0.01) {\r
-      hNcls[iCent]->Draw("same");\r
-      legCls->AddEntry(hNcls[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), \r
-                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");\r
-    }\r
-  }\r
-  legCls->Draw();\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 6.0, kTRUE);\r
-  \r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");\r
-  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);\r
-  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtot->SetStats(kFALSE);\r
-  rangeQtot->Draw();\r
-  \r
-  TH1D* hQtot[6]={0x0};\r
-  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.97);\r
-  leg2->SetFillColor(0);\r
-  leg2->SetBorderSize(0);\r
-  \r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    if(iCent>0)\r
-      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-    \r
-    hQtot[iCent] = (TH1D*)cf->Project(0, cf->GetVar("Qtot0"));\r
-    if(!hQtot[iCent]) continue;\r
-    hQtot[iCent]->SetBinContent(1, 0);\r
-    \r
-    Double_t maximum = hQtot[iCent]->GetMaximum();\r
-    if(maximum>1.0)\r
-      hQtot[iCent]->Scale(1.0/maximum);\r
-    hQtot[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-    hQtot[iCent]->SetStats(kFALSE);\r
-    hQtot[iCent]->SetTitle("");\r
-    hQtot[iCent]->SetLineWidth(2);\r
-    if(hQtot[iCent]->Integral()>0.01) {\r
-      hQtot[iCent]->Draw(iCent==0 ? "" : "same");\r
-      leg2->AddEntry(hQtot[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), \r
-                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");\r
-    }\r
-  }\r
-  leg2->Draw();\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 5.0, kTRUE);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::PlotTrackingSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  //  Plot tracking summary\r
-  //\r
-  if(!fMatchingPhiEtaCF || !fMatchingPtCF || !fCentralityCF || !fBunchCrossingsCF) return;\r
-  AliCFContainer* cf = 0x0;  \r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-  \r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  // eta-phi distr. for positive TPC tracks\r
-  TVirtualPad* pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
\r
-  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);\r
-  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  // find all the isolated bunch crossings with entries\r
-  TH2D* hTPCrefPos = 0x0; TH2D* hTRDrefPos = 0x0; TH2D* hTOFrefPos = 0x0;\r
-  TH2D* hTPCrefNeg = 0x0; TH2D* hTRDrefNeg = 0x0; TH2D* hTOFrefNeg = 0x0;\r
-  cf = fMatchingPhiEtaCF;\r
-  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);\r
-  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);      // positive charges\r
-  hTPCrefPos = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTRDrefPos = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTOFrefPos = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);      // negative charges\r
-  hTPCrefNeg = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTRDrefNeg = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTOFrefNeg = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);      // reset charge cut\r
-    \r
-  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);  \r
-  \r
-  //----------------------------------------------\r
-  // eta-phi efficiency for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTRDeffPos = (hTRDrefPos ? (TH2D*)hTRDrefPos->Clone("hTRDeffPos") : 0x0);\r
-  if(hTRDeffPos) {\r
-    hTRDeffPos->Reset();\r
-    hTRDeffPos->SetStats(kFALSE);\r
-    hTRDeffPos->Divide(hTRDrefPos, hTPCrefPos);\r
-    hTRDeffPos->SetMaximum(1.0);\r
-    hTRDeffPos->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for positive tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi efficiency for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(3)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTRDeffNeg = (hTRDrefNeg ? (TH2D*)hTRDrefNeg->Clone("hTRDeffNeg") : 0x0);\r
-  if(hTRDeffNeg) {\r
-    hTRDeffNeg->Reset();\r
-    hTRDeffNeg->SetStats(kFALSE);\r
-    hTRDeffNeg->Divide(hTRDrefNeg, hTPCrefNeg);\r
-    hTRDeffNeg->SetMaximum(1.0);\r
-    hTRDeffNeg->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for negative tracks");\r
-    DrawTRDGrid();  \r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi TRD-TOF matching efficiency for positive tracks\r
-  pad = ((TVirtualPad*)l->At(1)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTOFeffPos = (hTOFrefPos ? (TH2D*)hTOFrefPos->Clone("hTOFeffPos") : 0x0);\r
-  if(hTOFeffPos) {\r
-    hTOFeffPos->Reset();\r
-    hTOFeffPos->SetStats(kFALSE);\r
-    hTOFeffPos->Divide(hTOFrefPos, hTRDrefPos);\r
-    hTOFeffPos->SetMaximum(1.0);\r
-    hTOFeffPos->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for positive tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi TRD-TOF matching efficiency for negative tracks\r
-  pad = ((TVirtualPad*)l->At(4)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTOFeffNeg = (hTOFrefNeg ? (TH2D*)hTOFrefNeg->Clone("hTOFeffNeg") : 0x0);\r
-  if(hTOFeffNeg) {\r
-    hTOFeffNeg->Reset();\r
-    hTOFeffNeg->SetStats(kFALSE);\r
-    hTOFeffNeg->Divide(hTOFrefNeg, hTRDrefNeg);\r
-    hTOFeffNeg->SetMaximum(1.0);\r
-    hTOFeffNeg->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for negative tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  if(hTRDrefPos) delete hTRDrefPos; if(hTPCrefPos) delete hTPCrefPos; if(hTOFrefPos) delete hTOFrefPos;\r
-  if(hTRDrefNeg) delete hTRDrefNeg; if(hTPCrefNeg) delete hTPCrefNeg; if(hTOFrefNeg) delete hTOFrefNeg;\r
-  \r
-  // switch to the Pt cf container\r
-  cf = fMatchingPtCF;\r
-  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  \r
-  TH1F* hTRDEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);\r
-  TH1F* hTOFEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");\r
-  \r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  \r
-  TH1F* hTRDEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);\r
-  TH1F* hTOFEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  \r
-  \r
-  TF1* funcConst = new TF1("constFunc", "[0]", 1.0, 3.0);\r
-  if(trendValues) {\r
-    if(hTRDEffPtPosAll && hTRDEffPtPosAll->Integral()>0.1) {\r
-      hTRDEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[0] = funcConst->GetParameter(0);\r
-      trendValues[1] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTRDEffPtNegAll && hTRDEffPtNegAll->Integral()>0.1) {\r
-      hTRDEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[2] = funcConst->GetParameter(0);\r
-      trendValues[3] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTOFEffPtPosAll && hTOFEffPtPosAll->Integral()>0.1) {\r
-      hTOFEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[4] = funcConst->GetParameter(0);\r
-      trendValues[5] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTOFEffPtNegAll && hTOFEffPtNegAll->Integral()>0.1) {\r
-      hTOFEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[6] = funcConst->GetParameter(0);\r
-      trendValues[7] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  \r
-  //---------------------------------------------------------\r
-  // TPC-TRD matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(6)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEffPt->Draw();\r
-  lat->DrawLatex(0.2, 1.42, "TPC-TRD matching efficiency");\r
-  //++++++++++++++++++\r
-  TLine line;\r
-  line.SetLineStyle(2);\r
-  line.SetLineWidth(2);\r
-  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.7, 0.89);\r
-  leg->SetNColumns(2);\r
-  leg->SetMargin(0.15);\r
-  leg->SetBorderSize(0);\r
-  leg->SetFillColor(0);\r
-\r
-  SetStyle(hTRDEffPtPosAll, 1, kRed, 1, 24, kRed, 1);\r
-  SetStyle(hTRDEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-  if(hTRDEffPtPosAll) {hTRDEffPtPosAll->Draw("same"); leg->AddEntry(hTRDEffPtPosAll, "pos. (#geq 1 tracklet)", "p");}\r
-  if(hTRDEffPtNegAll) {hTRDEffPtNegAll->Draw("same"); leg->AddEntry(hTRDEffPtNegAll, "neg. (#geq 1 tracklet)", "p");}\r
-  hTRDEffPtPosTrk4->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk4, "pos. (4 tracklets)", "p");\r
-  hTRDEffPtNegTrk4->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk4, "neg. (4 tracklets)", "p");\r
-  hTRDEffPtPosTrk5->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk5, "pos. (5 tracklets)", "p");\r
-  hTRDEffPtNegTrk5->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk5, "neg. (5 tracklets)", "p");\r
-  hTRDEffPtPosTrk6->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk6, "pos. (6 tracklets)", "p");\r
-  hTRDEffPtNegTrk6->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk6, "neg. (6 tracklets)", "p");\r
-  \r
-  leg->Draw();\r
-  \r
-  //---------------------------------------------------------\r
-  // TRD-TOF matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(7)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  rangeEffPt->Draw();\r
-  lat->DrawLatex(0.2, 1.42, "TRD-TOF matching efficiency");\r
-  SetStyle(hTOFEffPtPosAll, 1, kRed, 1, 24, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-  SetStyle(hTOFEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-  if(hTOFEffPtPosAll) hTOFEffPtPosAll->Draw("same"); \r
-  hTOFEffPtPosTrk4->Draw("same"); \r
-  hTOFEffPtPosTrk5->Draw("same"); \r
-  hTOFEffPtPosTrk6->Draw("same"); \r
-  if(hTOFEffPtNegAll) hTOFEffPtNegAll->Draw("same"); \r
-  hTOFEffPtNegTrk4->Draw("same"); \r
-  hTOFEffPtNegTrk5->Draw("same"); \r
-  hTOFEffPtNegTrk6->Draw("same");  \r
-    \r
-  //-----------------------------------------------------\r
-  // <ntracklets> vs (phi,eta)\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");\r
-  \r
-  cf = fMatchingPhiEtaCF;\r
-  TH3D* hNtracklets = (TH3D*)cf->Project(1, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("tracklets"));\r
-  \r
-  TProfile2D* hNtrackletsProf = hNtracklets->Project3DProfile();\r
-  delete hNtracklets;\r
-  if(hNtrackletsProf) {\r
-    hNtrackletsProf->SetStats(kFALSE);\r
-    hNtrackletsProf->SetMinimum(0.);\r
-    hNtrackletsProf->SetMaximum(6.);\r
-    hNtrackletsProf->Draw("samecolz");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  // calculate the trend value for tracklets/track\r
-  cf = fMatchingPtCF;\r
-  TH2D* hNtrackletsVsP = (TH2D*)cf->Project(1, cf->GetVar("pt"), cf->GetVar("tracklets"));\r
-  if(trendValues &&  hNtrackletsVsP && hNtrackletsVsP->GetEntries()>0.1) {\r
-    TProfile* hNtrackletsVsPprof = hNtrackletsVsP->ProfileX("hNtrackletsVsPprof");\r
-    hNtrackletsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-    trendValues[8] = funcConst->GetParameter(0);\r
-    trendValues[9] = funcConst->GetParError(0);\r
-    delete hNtrackletsVsP;\r
-  }\r
-      \r
-  //--------------------------------------------------------------\r
-  // Nclusters per TRD track vs momentum\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  \r
-  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");\r
-  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);\r
-  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNclsP->SetStats(kFALSE);\r
-  rangeNclsP->Draw();\r
-  lat->DrawLatex(1.0, 205., "TRD Clusters / track");\r
-  \r
-  cf = fCentralityCF;\r
-  TH2D* hNclsVsP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("clusters"));\r
-  if(hNclsVsP) {\r
-    hNclsVsP->SetStats(kFALSE);\r
-    hNclsVsP->Draw("samecolz");\r
-  }    \r
-  \r
-  if(trendValues && hNclsVsP && hNclsVsP->GetEntries()>10) {\r
-    TProfile* hNclsVsPprof = hNclsVsP->ProfileX("hNclsVsPprof");\r
-    hNclsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-    trendValues[10] = funcConst->GetParameter(0);\r
-    trendValues[11] = funcConst->GetParError(0);\r
-  }\r
-    \r
-  //--------------------------------------------------------------\r
-  // TRD-TPC and TOF-TRD matching efficiency vs bunch crossing\r
-  pad = ((TVirtualPad*)l->At(8)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-\r
-  cf = fBunchCrossingsCF;\r
-  TH1F* hTRDEffBC = EfficiencyFromPhiPt(cf, 0, 6, 1, 0, "BC", "TPCTRD");\r
-  TH1F* hTOFEffBC = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "BC", "TRDTOF");\r
-  \r
-  if(gROOT->FindObject("rangeBC")) delete gROOT->FindObject("rangeBC");\r
-  TH2F* rangeBC = new TH2F("rangeBC", "", 10, -0.5, 3499.5, 10, 0.0, 1.4);\r
-  rangeBC->SetStats(kFALSE);\r
-  SetStyle(rangeBC->GetXaxis(), "Bunch crossing", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeBC->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeBC->Draw();\r
-  \r
-  TLegend* legBC=new TLegend(0.8, 0.7, 0.95, 0.89);\r
-  legBC->SetBorderSize(0);\r
-  legBC->SetMargin(0.15);\r
-  legBC->SetFillColor(0);\r
-  if(hTRDEffBC) {\r
-    hTRDEffBC->SetStats(kFALSE);\r
-    SetStyle(hTRDEffBC, 1, kRed, 2, 24, kRed, 1); legBC->AddEntry(hTRDEffBC, "TPC-TRD", "p");\r
-    SetStyle(hTOFEffBC, 1, kBlue, 2, 24, kBlue, 1); legBC->AddEntry(hTOFEffBC, "TRD-TOF", "p");\r
-    hTRDEffBC->Draw("same");\r
-    hTOFEffBC->Draw("same");\r
-    legBC->Draw();\r
-    lat->DrawLatex(200., 1.42, "Matching efficiency at 1<p_{T}<3 GeV/c");\r
-  }\r
-    \r
-  // reset the user range on the event multiplicity\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-  \r
-  delete funcConst;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::PlotPidSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  // Centrality summary\r
-  //\r
-  if(!fQtotCF || !fPulseHeightCF || !fCentralityCF) return;\r
-  \r
-  AliCFContainer* cf = 0x0;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);\r
-  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);  \r
-  \r
-  // eta-phi distr. for <Qtot> in layer 0\r
-  TVirtualPad* pad;\r
-  TProfile2D* hProf2D;\r
-  cf = fQtotCF;\r
-  for(Int_t iLayer=0; iLayer<6; ++iLayer) {\r
-    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+1))); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEtaPhi->Draw();\r
-    \r
-    cf->SetRangeUser(cf->GetVar("layer"), Double_t(iLayer), Double_t(iLayer));\r
-    TH3D* hQtotEtaPhi = (TH3D*)cf->Project(0, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("Qtot0"));\r
-    hProf2D = (hQtotEtaPhi ? hQtotEtaPhi->Project3DProfile() : 0x0);\r
-    if(hQtotEtaPhi) delete hQtotEtaPhi;\r
-    \r
-    if(hProf2D) {\r
-      hProf2D->SetName(Form("Qtot_layer%d",iLayer));\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(4.);\r
-      hProf2D->Draw("samecolz");\r
-    }\r
-    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));\r
-    DrawTRDGrid();\r
-  }\r
-  cf->SetRangeUser(cf->GetVar("layer"), 0.0, 5.0);\r
-    \r
-  // PH versus slice number\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");\r
-  TH2F* rangePHslice=new TH2F("rangePHslice", "", 8, -0.5, 7.5, 10, 0.0, 6.);\r
-  rangePHslice->SetStats(kFALSE);\r
-  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);\r
-  rangePHslice->Draw();\r
-  \r
-  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);\r
-  \r
-  cf = fPulseHeightCF;\r
-  TH2D* hPH = (TH2D*)cf->Project(0, cf->GetVar("slice"), cf->GetVar("PH0"));\r
-  TH1D* hSliceErr = new TH1D(Form("hSliceErr%f", gRandom->Rndm()), "", hPH->GetXaxis()->GetNbins(), hPH->GetXaxis()->GetXbins()->GetArray());\r
-  TH1D* hLandauFit = Proj2D(hPH, hSliceErr);\r
-  hPH->SetStats(kFALSE);\r
-  hPH->Draw("samecolz");\r
-  if(trendValues) {\r
-    hSliceErr->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);\r
-    trendValues[12] = funcPol1->GetParameter(0);  // PH plateau\r
-    trendValues[13] = funcPol1->GetParError(0);   // PH plateau\r
-    trendValues[14] = funcPol1->GetParameter(1);  // PH slope\r
-    trendValues[15] = funcPol1->GetParError(1);   // PH slope\r
-  }\r
-  hLandauFit->SetLineWidth(2);\r
-  hLandauFit->SetLineStyle(2);\r
-  hLandauFit->Draw("same");\r
-  \r
-  delete funcPol1; delete hSliceErr;\r
-  \r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  \r
-  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");\r
-  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);\r
-  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtotP->SetStats(kFALSE);\r
-  rangeQtotP->Draw();\r
-  \r
-  cf = fCentralityCF;\r
-  TH2D* hQtotP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("Qtot0"));\r
-  TH1D* mpvErr=new TH1D("mpvErr", "Landau MPV error vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());  \r
-  TH1D* widthErr=new TH1D("widthErr", "Landau width error vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());\r
-  TH1D* landauChi2=new TH1D("landauChi2", "Landau fit #chi^{2} vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());  \r
-  \r
-  if(hQtotP)\r
-    for(Int_t i=1; i<=hQtotP->GetXaxis()->GetNbins(); ++i) \r
-      hQtotP->SetBinContent(i, 1, 0.0);  \r
-  TH1D* hQtotProj = (hQtotP ? Proj2D(hQtotP, mpvErr, widthErr, landauChi2) : 0x0);\r
-  //landauChi2->Scale(0.001);\r
-  if(hQtotProj) SetStyle(hQtotProj, 2, kBlue, 2, 1, kBlue, 1);\r
-  if(trendValues && hQtotProj && hQtotProj->GetEntries()>2) {\r
-    trendValues[16] = hQtotProj->GetBinContent(hQtotProj->FindBin(1.0));   // Landau MPV at 1GeV/c\r
-    trendValues[17] = hQtotProj->GetBinError(hQtotProj->FindBin(1.0));     // Landau width at 1 GeV/c\r
-  }\r
-  if(hQtotP) {\r
-    hQtotP->SetStats(kFALSE);\r
-    hQtotP->Draw("samecolz");\r
-    hQtotProj->Draw("same");\r
-  }\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-  \r
-  \r
-  // Qtot vs P (fit results)\r
-  pad = ((TVirtualPad*)l->At(8)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  \r
-  if(gROOT->FindObject("rangeQtotPfit")) delete gROOT->FindObject("rangeQtotPfit");\r
-  TH2F* rangeQtotPfit = new TH2F("rangeQtotPfit", "", 100, 0.0, 11.99, 100, 0.0, 5.99);\r
-  SetStyle(rangeQtotPfit->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtotPfit->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtotPfit->SetStats(kFALSE);\r
-  rangeQtotPfit->Draw();\r
-  \r
-  if(mpvErr) SetStyle(mpvErr, 1, kBlue, 2, 1, kBlue, 1);\r
-  if(widthErr) SetStyle(widthErr, 2, kRed, 2, 1, kRed, 1);\r
-  if(mpvErr) {\r
-    mpvErr->SetStats(kFALSE);\r
-    mpvErr->Draw("same");\r
-  }\r
-  if(widthErr) {\r
-    widthErr->SetStats(kFALSE);\r
-    widthErr->Draw("same");\r
-  }\r
-  TLegend* leg=new TLegend(0.2,0.6,0.5,0.9);\r
-  leg->SetFillColor(0);\r
-  leg->SetBorderSize(0);\r
-  leg->AddEntry("mpvErr","Landau MPV","l");\r
-  leg->AddEntry("widthErr","Landau width","l");\r
-  leg->Draw();\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotCentSummary(Double_t* /*trendValues*/) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex* lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  TPad* pad=0x0;  \r
-\r
-  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  \r
-  TH3F *h3(NULL), *h3p(NULL), *h3n(NULL);\r
-  Int_t padsForEffs[5] = {0,3,6,1,4};\r
-  for(Int_t iCent=1; iCent<6; ++iCent) {\r
-    // TPC-TRD matching efficiencies\r
-    pad = ((TPad*)l->At(padsForEffs[iCent-1])); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    \r
-    if(!(h3p = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+iCent)))) continue;\r
-    if(!(h3n = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+iCent)))) continue;\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+iCent)))) continue;\r
-    TH1F* hFeffP = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+iCent)))) continue;\r
-    TH1F* hFeffN = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+iCent)))) continue;\r
-    TH1F* hFeffP4 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+iCent)))) continue;\r
-    TH1F* hFeffN4 = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+iCent)))) continue;\r
-    TH1F* hFeffP5 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+iCent)))) continue;\r
-    TH1F* hFeffN5 = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+iCent)))) continue;\r
-    TH1F* hFeffP6 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+iCent)))) continue;\r
-    TH1F* hFeffN6 = EfficiencyTRD(h3n, h3, kTRUE);\r
-  \r
-    rangeEffPt->Draw();\r
-    \r
-    TLine line;\r
-    line.SetLineStyle(2);\r
-    line.SetLineWidth(2);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-    line.SetLineStyle(1);\r
-    line.SetLineWidth(1);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 1.0, rangeEffPt->GetXaxis()->GetXmax(), 1.0);\r
-    if(hFeffP) SetStyle(hFeffP, 1, kRed, 1, 24, kRed, 1);\r
-    if(hFeffP4) SetStyle(hFeffP4, 1, kRed, 1, 25, kRed, 1);\r
-    if(hFeffP5) SetStyle(hFeffP5, 1, kRed, 1, 26, kRed, 1);\r
-    if(hFeffP6) SetStyle(hFeffP6, 1, kRed, 1, 27, kRed, 1);\r
-    if(hFeffN) SetStyle(hFeffN, 1, kBlue, 1, 24, kBlue, 1);\r
-    if(hFeffN4) SetStyle(hFeffN4, 1, kBlue, 1, 25, kBlue, 1);\r
-    if(hFeffN5) SetStyle(hFeffN5, 1, kBlue, 1, 26, kBlue, 1);\r
-    if(hFeffN6) SetStyle(hFeffN6, 1, kBlue, 1, 27, kBlue, 1);\r
-    \r
-    TLegend* leg=new TLegend(0.16, 0.7, 0.61, 0.89);\r
-    leg->SetFillColor(0);\r
-    leg->SetNColumns(2);\r
-    leg->SetTextSize(0.039);\r
-    leg->SetMargin(0.1);\r
-    if(hFeffP && hFeffP->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP->Draw("same");\r
-      leg->AddEntry(hFeffP, "pos. (#geq 1 trcklt)", "p");\r
-    }\r
-    if(hFeffN && hFeffN->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN->Draw("same");\r
-      leg->AddEntry(hFeffN, "neg. (#geq 1 trcklt)", "p");\r
-    }\r
-    if(hFeffP4 && hFeffP4->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP4->Draw("same");\r
-      leg->AddEntry(hFeffP4, "pos. (4 trcklts)", "p");\r
-    }\r
-    if(hFeffN4 && hFeffN4->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN4->Draw("same");\r
-      leg->AddEntry(hFeffN4, "neg. (4 trcklts)", "p");\r
-    }\r
-    if(hFeffP5 && hFeffP5->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP5->Draw("same");\r
-      leg->AddEntry(hFeffP5, "pos. (5 trcklts)", "p");\r
-    }\r
-    if(hFeffN5 && hFeffN5->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN5->Draw("same");\r
-      leg->AddEntry(hFeffN5, "neg. (5 trcklts)", "p");\r
-    }\r
-    if(hFeffP6 && hFeffP6->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP6->Draw("same");\r
-      leg->AddEntry(hFeffP6, "pos. (6 trcklts)", "p");\r
-    }\r
-    if(hFeffN6 && hFeffN6->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN6->Draw("same");\r
-      leg->AddEntry(hFeffN6, "neg. (6 trklts)", "p");\r
-    }\r
-    \r
-    if(isGoodForSaving) {\r
-      if(iCent==1) leg->Draw();\r
-      lat->DrawLatex(5.6, 1.3, Form("Centrality class %d", iCent));\r
-      lat->DrawLatex(0.5, 1.42, "TPC-TRD matching efficiency");\r
-    }\r
-  }   // end loop over multiplicity intervals\r
-\r
-  // Number of clusters per TRD track\r
-  pad = ((TPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");\r
-  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);\r
-  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNcls->SetStats(kFALSE);\r
-  rangeNcls->Draw();\r
-  \r
-  TH2F* h2F[6]; TH1D* proj[6];\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.5, 0.95);\r
-  leg->SetFillColor(0);\r
-  Bool_t isGood=kFALSE;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+iCent));\r
-    proj[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projCent%d",iCent)) : 0x0);\r
-    if(proj[iCent]) {\r
-      proj[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-      Double_t maximum = proj[iCent]->GetMaximum();\r
-      if(maximum>1.0)\r
-        proj[iCent]->Scale(1.0/maximum);\r
-      proj[iCent]->SetStats(kFALSE);\r
-      proj[iCent]->Draw("same");\r
-      leg->AddEntry(proj[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");\r
-      isGood = kTRUE;\r
-    }\r
-  }\r
-  if(isGood) leg->Draw();\r
-  isGoodForSaving = isGoodForSaving || isGood;\r
-  \r
-  // Qtot vs P\r
-  pad = ((TPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");\r
-  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);\r
-  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtot->SetStats(kFALSE);\r
-  rangeQtot->Draw();\r
-  \r
-  TH1D* projQ[6];\r
-  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.95);\r
-  leg2->SetFillColor(0);\r
-  isGood = kFALSE;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {  \r
-    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kQtotP+iCent));\r
-    projQ[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projQCent%d",iCent)) : 0x0);\r
-    if(projQ[iCent]) {\r
-      projQ[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-      Double_t maximum = projQ[iCent]->GetMaximum();\r
-      if(maximum>1.0)\r
-        projQ[iCent]->Scale(1.0/maximum);\r
-      projQ[iCent]->SetStats(kFALSE);\r
-      projQ[iCent]->Draw("same");\r
-      leg2->AddEntry(projQ[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");\r
-      isGood = kTRUE;\r
-    }\r
-  }\r
-  if(isGood) leg2->Draw();\r
-  isGoodForSaving = isGoodForSaving || isGood;\r
-  return isGoodForSaving;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotTrackingSummary(Int_t centralityClass, Double_t* trendValues) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  // eta-phi distr. for positive TPC tracks\r
-  TVirtualPad* pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TPC positive ref. tracks");\r
-  \r
-  TH3F* h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass));\r
-  TH2F* h2FtpcP = 0x0;\r
-  Float_t nada=0.0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtpcP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtpcP->SetStats(kFALSE);\r
-    h2FtpcP->Draw("samecolz"); isGoodForSaving = kTRUE;\r
-    isGoodForSaving = kTRUE;\r
-  }\r
-  //-----------------\r
-  // eta-phi distr. for negative TPC tracks\r
-  pad = ((TVirtualPad*)l->At(1)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TPC negative ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass));\r
-  TH2F* h2FtpcN = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtpcN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtpcN->SetStats(kFALSE);\r
-    h2FtpcN->Draw("samecolz"); \r
-    isGoodForSaving = kTRUE;\r
-  }\r
-  //----------------------------------------------\r
-  // eta-phi distr. for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(3)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD positive ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass));\r
-  TH2F* h2FtrdP = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtrdP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtrdP->SetStats(kFALSE);\r
-    h2FtrdP->SetMaximum((h2FtpcP ? h2FtpcP->GetMaximum() : h2FtrdP->GetMaximum()));\r
-    h2FtrdP->Draw("samecolz"); \r
-    isGoodForSaving=kTRUE;\r
-  }\r
-  //--------------------------------------------\r
-  // eta-phi distr. for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(4)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD negative ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass));\r
-  TH2F* h2FtrdN = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtrdN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtrdN->SetStats(kFALSE);\r
-    h2FtrdN->SetMaximum(h2FtpcN ? h2FtpcN->GetMaximum() : h2FtrdN->GetMaximum());\r
-    h2FtrdN->Draw("samecolz"); \r
-    isGoodForSaving=kTRUE;\r
-  }\r
-  //----------------------------------------------\r
-  // eta-phi efficiency for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(6)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "Efficiency positive tracks");\r
-  \r
-  TH2F* h2Feff = (h2FtrdP ? (TH2F*)h2FtrdP->Clone("h2FeffPos") : 0x0);\r
-  if(h2Feff) {\r
-    h2Feff->Reset();\r
-    h2Feff->SetStats(kFALSE);\r
-    h2Feff->Divide(h2FtrdP, h2FtpcP);\r
-    h2Feff->SetMaximum(1.0);\r
-    if(h2Feff->GetEntries()>1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-  }\r
-  //-------------------------------------------------\r
-  // eta-phi efficiency for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(7)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "Efficiency negative tracks");\r
-  \r
-  h2Feff = (h2FtrdN ? (TH2F*)h2FtrdN->Clone("h2FeffNeg") : 0x0);\r
-  if(h2Feff) {\r
-    h2Feff->Reset();\r
-    h2Feff->SetStats(kFALSE);\r
-    h2Feff->Divide(h2FtrdN, h2FtpcN);\r
-    h2Feff->SetMaximum(1.0);\r
-    if(h2Feff->GetEntries()>0.1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-  }\r
-  //-----------------------------------------------------\r
-  // <ntracklets> vs (phi,eta)\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");\r
-  \r
-  TProfile2D* hProf2D;\r
-  if((hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvNtrkl+centralityClass)))) {\r
-    if(hProf2D->GetEntries()>10) {\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(6.);\r
-      if(hProf2D->GetEntries()>1) { hProf2D->Draw("samecolz"); isGoodForSaving = kTRUE; }\r
-    }\r
-  }\r
-  //---------------------------------------------------------\r
-  // TPC-TRD matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  TH1F* hFeffP = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass)), kTRUE);\r
-  TH1F* hFeffN = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass)), kTRUE);\r
-  TH1F* hFeffP4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+centralityClass)), kTRUE);\r
-  TH1F* hFeffN4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+centralityClass)), kTRUE);\r
-  TH1F* hFeffP5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+centralityClass)), kTRUE);\r
-  TH1F* hFeffN5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+centralityClass)), kTRUE);\r
-  TH1F* hFeffP6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+centralityClass)), kTRUE);\r
-  TH1F* hFeffN6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+centralityClass)), kTRUE);\r
-  \r
-  TF1* funcConst = new TF1("funcConst", "[0]", 1.0, 3.0);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");\r
-  TH2F* rangeEffPt2=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt2->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt2->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt2->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEffPt2->Draw();\r
-  lat->DrawLatex(0.5, 1.42, "TRD-TPC matching efficiency");\r
-  //++++++++++++++++++\r
-  TLine line;\r
-  line.SetLineStyle(2);\r
-  line.SetLineWidth(2);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.7, rangeEffPt2->GetXaxis()->GetXmax(), 0.7);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.9, rangeEffPt2->GetXaxis()->GetXmax(), 0.9);\r
-  line.SetLineStyle(1);\r
-  line.SetLineWidth(1);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 1.0, rangeEffPt2->GetXaxis()->GetXmax(), 1.0);\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.6, 0.89);\r
-  leg->SetNColumns(2);\r
-  leg->SetFillColor(0);\r
-  if(hFeffP){\r
-    hFeffP->SetMarkerStyle(24);\r
-    hFeffP->SetMarkerColor(2);\r
-    hFeffP->SetLineColor(2);\r
-    if(trendValues && hFeffP->GetEntries()>1) {\r
-      hFeffP->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-      trendValues[0] = funcConst->GetParameter(0);\r
-      trendValues[1] = funcConst->GetParError(0);\r
-    }\r
-    if(hFeffP->Integral()>0.001) {\r
-      hFeffP->Draw("same"); \r
-      leg->AddEntry(hFeffP, "positives (#geq 1 tracklet)", "p");\r
-    }\r
-  }\r
-  if(hFeffN){\r
-    hFeffN->SetMarkerStyle(24);\r
-    hFeffN->SetMarkerColor(4);\r
-    hFeffN->SetLineColor(4);\r
-    if(trendValues && hFeffN->GetEntries()>1) {\r
-      hFeffN->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-      trendValues[2] = funcConst->GetParameter(0);\r
-      trendValues[3] = funcConst->GetParError(0);\r
-    }\r
-    if(hFeffN->Integral()>0.001) {\r
-      hFeffN->Draw("same"); \r
-      leg->AddEntry(hFeffN, "negatives (#geq 1 tracklet)", "p");\r
-    }\r
-  }\r
-  if(hFeffP4){\r
-    hFeffP4->SetMarkerStyle(25);\r
-    hFeffP4->SetMarkerColor(2);\r
-    hFeffP4->SetLineColor(2);\r
-    if(hFeffP4->Integral()>0.001) {\r
-      hFeffP4->Draw("same"); \r
-      leg->AddEntry(hFeffP4, "positives (4 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN4){\r
-    hFeffN4->SetMarkerStyle(25);\r
-    hFeffN4->SetMarkerColor(4);\r
-    hFeffN4->SetLineColor(4);\r
-    if(hFeffN4->Integral()>0.001) {\r
-      hFeffN4->Draw("same"); \r
-      leg->AddEntry(hFeffN4, "negatives (4 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffP5){\r
-    hFeffP5->SetMarkerStyle(26);\r
-    hFeffP5->SetMarkerColor(2);\r
-    hFeffP5->SetLineColor(2);\r
-    if(hFeffP5->Integral()>0.001) {\r
-      hFeffP5->Draw("same"); \r
-      leg->AddEntry(hFeffP5, "positives (5 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN5){\r
-    hFeffN5->SetMarkerStyle(26);\r
-    hFeffN5->SetMarkerColor(4);\r
-    hFeffN5->SetLineColor(4);\r
-    if(hFeffN5->Integral()>0.001) {\r
-      hFeffN5->Draw("same"); \r
-      leg->AddEntry(hFeffN5, "negatives (5 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffP6){\r
-    hFeffP6->SetMarkerStyle(27);\r
-    hFeffP6->SetMarkerColor(2);\r
-    hFeffP6->SetLineColor(2);\r
-    if(hFeffP6->Integral()>0.001) {\r
-      hFeffP6->Draw("same"); \r
-      leg->AddEntry(hFeffP6, "positives (6 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN6){\r
-    hFeffN6->SetMarkerStyle(27);\r
-    hFeffN6->SetMarkerColor(4);\r
-    hFeffN6->SetLineColor(4);\r
-    if(hFeffN6->Integral()>0.001) {\r
-      hFeffN6->Draw("same"); \r
-      leg->AddEntry(hFeffN6, "negatives (6 tracklets)", "p");\r
-    }\r
-  }\r
-  leg->Draw();\r
-  \r
-  //--------------------------------------------------------------\r
-  // Nclusters per TRD track\r
-  pad = ((TVirtualPad*)l->At(8)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");\r
-  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);\r
-  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNclsP->SetStats(kFALSE);\r
-  rangeNclsP->Draw();\r
-  lat->DrawLatex(1.0, 205., "TRD Clusters / track");\r
-  \r
-  TH2F* hNclsVsP=0x0;\r
-  if((hNclsVsP = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+centralityClass)))) {\r
-    hNclsVsP->SetStats(kFALSE);\r
-    if(hNclsVsP->GetEntries()>10) {\r
-      hNclsVsP->Draw("samecolz"); isGoodForSaving=kTRUE;\r
-      if(trendValues) {\r
-        TProfile* h2FProf = hNclsVsP->ProfileX("nclsVsPprof");\r
-        h2FProf->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-        trendValues[4] = funcConst->GetParameter(0);\r
-        trendValues[5] = funcConst->GetParError(0);\r
-      }\r
-    }\r
-  }\r
-  \r
-  delete funcConst;\r
-  return isGoodForSaving;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotPidSummary(Int_t centralityClass, Double_t* trendValues) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  // eta-phi distr. for <Qtot> in layer 0\r
-  TVirtualPad* pad;\r
-  TProfile2D* hProf2D;\r
-  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);\r
-  \r
-  for(Int_t iLayer=0; iLayer<6; ++iLayer) {\r
-    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+1))); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEtaPhi->Draw();\r
-    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));\r
-    \r
-    if(!(hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+6*centralityClass+iLayer)))) continue;\r
-    if(hProf2D && hProf2D->GetEntries()>10) {\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(4.);\r
-      if(hProf2D->GetEntries()>10) { hProf2D->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-    }\r
-  }\r
-    \r
-  // PH versus slice number\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");\r
-  TH2F* rangePHslice = new TH2F("rangePHslice", "", 10, -0.5, 7.5, 10, 0.0, 2000.0);\r
-  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);\r
-  rangePHslice->SetStats(kFALSE);\r
-  rangePHslice->Draw();\r
-  \r
-  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);\r
-  \r
-  TH2F* h2F;\r
-  TH1D* hF;\r
-  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kPHSlice+centralityClass)))) {\r
-    if(h2F && h2F->GetEntries()>10) {\r
-      hF = Proj2D(h2F);\r
-      h2F->SetStats(kFALSE);\r
-      h2F->Draw("samecolz");\r
-      isGoodForSaving=kTRUE;\r
-      if(trendValues) {\r
-        hF->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);\r
-        trendValues[6] = funcPol1->GetParameter(0);\r
-        trendValues[7] = funcPol1->GetParError(0);\r
-        trendValues[8] = funcPol1->GetParameter(1);\r
-        trendValues[9] = funcPol1->GetParError(1);\r
-      }\r
-      hF->SetLineWidth(2);\r
-      hF->Draw("same");\r
-    }\r
-  }\r
-  delete funcPol1;\r
-\r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");\r
-  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);\r
-  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtotP->SetStats(kFALSE);\r
-  rangeQtotP->Draw();\r
-  \r
-  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kQtotP+centralityClass)))) {\r
-    if(h2F && h2F->GetEntries()>10) {\r
-      h2F->SetStats(kFALSE);\r
-      h2F->Draw("samecolz");\r
-      isGoodForSaving=kTRUE;\r
-      hF = Proj2D(h2F);\r
-      hF->SetLineWidth(2);\r
-      hF->Draw("same");\r
-      if(trendValues) {\r
-        trendValues[10] = hF->GetBinContent(hF->FindBin(1.0));\r
-        trendValues[11] = hF->GetBinError(hF->FindBin(1.0));\r
-      }\r
-    }\r
-  }\r
-  return isGoodForSaving;\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::DrawTRDGrid() {\r
-  //\r
-  //   Draw a grid of lines showing the TRD supermodule and stack structure in (eta,phi) coordinates.\r
-  //   The canvas on which to draw must already exist.\r
-  //\r
-  TLine line;\r
-  line.SetLineColor(2);\r
-  line.SetLineWidth(1);\r
-  line.SetLineStyle(2);\r
-  for(Int_t i=0; i<=9; ++i) {\r
-    line.DrawLine(-1.0, 2.0*TMath::Pi()/18.0*i, +1.0, 2.0*TMath::Pi()/18.0*i);\r
-    line.DrawLine(-1.0, -2.0*TMath::Pi()/18.0*i, +1.0, -2.0*TMath::Pi()/18.0*i);\r
-  }\r
-  line.DrawLine(-0.85, -3.2, -0.85, +3.2);\r
-  line.DrawLine(-0.54, -3.2, -0.54, +3.2);\r
-  line.DrawLine(-0.16, -3.2, -0.16, +3.2);\r
-  line.DrawLine(+0.16, -3.2, +0.16, +3.2);\r
-  line.DrawLine(+0.54, -3.2, +0.54, +3.2);\r
-  line.DrawLine(+0.85, -3.2, +0.85, +3.2);\r
-}\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::SetStyle(TH1* hist, \r
-                             Int_t lineStyle, Int_t lineColor, Int_t lineWidth, \r
-                             Int_t markerStyle, Int_t markerColor, Int_t markerSize) {\r
-  //\r
-  // Set style settings for histograms\r
-  //\r
-  if(!hist) return;\r
-  hist->SetLineStyle(lineStyle);\r
-  hist->SetLineColor(lineColor);\r
-  hist->SetLineWidth(lineWidth);\r
-  hist->SetMarkerStyle(markerStyle);\r
-  hist->SetMarkerColor(markerColor);\r
-  hist->SetMarkerSize(markerSize);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, \r
-                              Float_t labelSize) {\r
-  //\r
-  // Set style settings for axes\r
-  //\r
-  if(!axis) return;\r
-  axis->SetTitle(title);\r
-  axis->SetTitleSize(titleSize);\r
-  axis->SetTitleOffset(titleOffset); \r
-  axis->CenterTitle(centerTitle);\r
-  axis->SetLabelSize(labelSize);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]) {\r
-  //\r
-  // Find the isolated bunch crossings\r
-  //\r
-  Int_t isolationSize = 5;      // number of free bunches in both directions\r
-  for(Int_t bcBin=1; bcBin<=bcHist->GetXaxis()->GetNbins(); ++bcBin) {\r
-    Int_t bc = TMath::Nint(bcHist->GetBinCenter(bcBin));\r
-    if(bc<-0.001 || bc>3499.01) {\r
-      isIsolated[bc] = kFALSE;\r
-      continue;\r
-    }\r
-    Double_t entries = bcHist->GetBinContent(bcBin);\r
-    if(entries<0.001) {\r
-      isIsolated[bc] = kFALSE;\r
-      continue;     // no entries\r
-    }\r
-        \r
-    // check isolation\r
-    isIsolated[bc] = kTRUE;\r
-    for(Int_t ibc = TMath::Max(1,bcBin-isolationSize); ibc<=TMath::Min(3499, bcBin+isolationSize); ++ibc) {\r
-      if(ibc==bcBin) continue;\r
-      if(bcHist->GetBinContent(ibc)>0.01) {\r
-        isIsolated[bc] = kFALSE;\r
-        break;\r
-      }\r
-    }\r
-  }   // end loop over BC bins\r
-  \r
-  cout << "Isolated bunches: " << endl;\r
-  for(Int_t ibc=0; ibc<3500; ++ibc) \r
-    if(isIsolated[ibc]) cout << "BC #" << ibc << endl; \r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetTriggerIndex(const Char_t* name, Bool_t createNew/*=kTRUE*/) {\r
-  //\r
-  //  Return the index of trigger "name" in the trigger histogram.\r
-  //  If the index for this trigger does not exist yet, then assign one if createNew is set to TRUE \r
-  //\r
-  //cout << "GetTriggerIndex for " << name << endl;\r
-  TH1F* triggerHist = (TH1F*)fHistos->At(kTriggerDefs);\r
-  TString nameStr=name;\r
-  for(Int_t i=1; i<=triggerHist->GetXaxis()->GetNbins(); ++i) {\r
-    if(!nameStr.CompareTo(triggerHist->GetXaxis()->GetBinLabel(i))) {\r
-      //cout << "       index found: " << i << endl;\r
-      return i;\r
-    }\r
-  }\r
-  if(createNew) {\r
-    triggerHist->GetXaxis()->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fMatchingPhiEtaCF->GetVar("trigger")>=0) {\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fMatchingPtCF->GetVar("trigger")>=0) {\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fBunchCrossingsCF->GetVar("trigger")>=0) {\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fCentralityCF->GetVar("trigger")>=0) \r
-      fCentralityCF->GetAxis(fCentralityCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fQtotCF->GetVar("trigger")>=0) \r
-      fQtotCF->GetAxis(fQtotCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fPulseHeightCF->GetVar("trigger")>=0)\r
-      fPulseHeightCF->GetAxis(fPulseHeightCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fExpertCF) {\r
-      if(fExpertCF->GetVar("trigger")>=0)\r
-        for(Int_t istep=0; istep<fExpertCF->GetNStep(); ++istep) \r
-         fExpertCF->GetAxis(fExpertCF->GetVar("trigger"), istep)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    \r
-    ++fNAssignedTriggers;\r
-    return fNAssignedTriggers+1;\r
-  }\r
-  else {\r
-    return -1;\r
-  }\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::PrintTriggers() const {\r
-  //\r
-  //  Print the available triggers for this run\r
-  //\r
-  if(!fHistos) {\r
-    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;\r
-    return;\r
-  }\r
-  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);\r
-  cout << "Triggers found in this run" << endl;\r
-  cout << "==========================" << endl;\r
-  cout << "Name   Index   Entries    " << endl;\r
-  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {\r
-    if(hTriggers->GetXaxis()->GetBinLabel(it)[0]!='\0') {\r
-      cout << hTriggers->GetXaxis()->GetBinLabel(it) << "  " << hTriggers->GetXaxis()->GetBinCenter(it) << "  " << hTriggers->GetBinContent(it) << endl;\r
-    }\r
-  }\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetTriggerCounter(const Char_t* triggerName) const {\r
-  //\r
-  // Get the number of events for a given trigger name\r
-  //\r
-  if(!fHistos) {\r
-    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;\r
-    return -1;\r
-  }\r
-  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);\r
-  Int_t counter = -1;\r
-  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {\r
-    TString trgString = hTriggers->GetXaxis()->GetBinLabel(it);\r
-    if(!trgString.CompareTo(triggerName)) \r
-      counter = (Int_t)hTriggers->GetBinContent(it);\r
-  }\r
-  if(counter<0) {cout << "AliTRDcheckESD::GetTriggerCounter()  Trigger not found !!";}\r
-  return counter;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetNAssignedTriggers() {\r
-  //\r
-  // Return the number of assigned triggers\r
-  //\r
-  return fNAssignedTriggers;\r
-}\r
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// Check basic detector results at ESD level                            //
+//   - Geometrical efficiency                                           //
+//   - Tracking efficiency                                              //
+//   - PID efficiency                                                   //
+//   - Refit efficiency                                                 //
+//                                                                      //
+// Author                                                               //
+//   Alex Bercuci <A.Bercuci@gsi.de>                                    //
+//   Ionut Arsene <i.c.arsene@gsi.de>                                   //
+//                                                                      //
+//     The analysis task fills AliCFContainer objects defined in the    //
+//   configuration macro using the AddCFContainer() method.             //
+//   The CF containers can be filled with any of the variables defined  //
+//   in ETrdCfVariables and at any of the steps defined in ETrdCfSteps. //
+//     To define a new variable one needs to:                           //
+//   1. Add an entry in the ETrdCfVariables enumeration                 //
+//   2. Add the corresponding variable name (and in the correct order)  //
+//      in fgkVarNames                                                  //
+//   3. Define how the variable is filled in one of the Fill functions: //
+//      FillEventInfo(), FillTrackInfo(), FillTrackletInfo(),           //
+//      FillTrackletSliceInfo().                                        //
+//     To define a new step one needs to:                               //
+//   1. Add an entry in the ETrdCfSteps                                 //
+//   2. Add the corresponding name in fgkStepNames                      //
+//   3. Define the track level cuts for this step in IsTrackSelected()  //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+
+#include <TClonesArray.h>
+#include <TCanvas.h>
+#include <TObjArray.h>
+#include <TPad.h>
+#include <TLegend.h>
+#include <TLatex.h>
+#include <TLine.h>
+#include <TF1.h>
+#include <TH1D.h>
+#include <TH2D.h>
+#include <TH3D.h>
+#include <TH2I.h>
+#include <TH2F.h>
+#include <TH3S.h>
+#include <TH3F.h>
+#include <TProfile2D.h>
+#include <TProfile.h>
+#include <TGraphErrors.h>
+#include <TGraphAsymmErrors.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TROOT.h>
+#include <TChain.h>
+#include <TParticle.h>
+#include <TTimeStamp.h>
+#include <TRandom.h>
+#include <TString.h>
+
+#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisCuts.h"
+#include "AliPhysicsSelection.h"
+#include "AliESDEvent.h"
+#include "AliESDkink.h"
+#include "AliMCEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliESDpid.h"
+#include "AliExternalTrackParam.h"
+
+#include "AliESDtrack.h"
+#include "AliMCParticle.h"
+#include "AliPID.h"
+#include "AliStack.h"
+#include "AliTrackReference.h"
+#include "AliMultiplicity.h"
+#include "AliCFContainer.h"
+
+#include "AliTRDcheckESD.h"
+#include <iostream>
+using std::cout;
+using std::endl;
+
+ClassImp(AliTRDcheckESD)
+
+const Float_t AliTRDcheckESD::fgkxTPC = 290.;
+const Float_t AliTRDcheckESD::fgkxTOF = 365.;
+const Char_t* AliTRDcheckESD::fgkVarNames[AliTRDcheckESD::kNTrdCfVariables] = {
+    "vtxZ", "multiplicity", "trigger", "BC", "TOFBC", "DCAxy", "DCAz", "charge", "OuterParam rad.", "phiVtx", "phi", 
+    "etaVtx", "eta", "pt", "ptTRD", "P", "PTRD", "TRDchi2", "tracklets", "clusters", "TrdQuality", 
+    "TrdBudget", "Qtot0", "ClustersPerRows", "Clusters/tracklet", "TrdP", "TrdPloss", "layer", "slice", "PH0"
+}; 
+const Char_t* AliTRDcheckESD::fgkStepNames[AliTRDcheckESD::kNSteps] = {"TPC", "TRD", "TOF", "TOFin", "TOFout"};  
+
+FILE* AliTRDcheckESD::fgFile = NULL;
+
+//____________________________________________________________________
+AliTRDcheckESD::AliTRDcheckESD():
+  AliAnalysisTaskSE()
+  ,fStatus(0)
+  ,fNRefFigures(0)
+  ,fESD(NULL)
+  ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
+  ,fHistos(NULL)
+  ,fReferenceTrackFilter(NULL)
+  ,fPhysSelTriggersEnabled(kFALSE)
+  ,fUserEnabledTriggers("")
+  ,fNAssignedTriggers(0)
+{
+  //
+  // Default constructor
+  //
+  SetNameTitle("TRDcheckESD", "Check TRD @ ESD level");
+  SetMC(kTRUE);
+}
+
+//____________________________________________________________________
+AliTRDcheckESD::AliTRDcheckESD(char* name):
+  AliAnalysisTaskSE(name)
+  ,fStatus(0)
+  ,fNRefFigures(0)
+  ,fESD(NULL)
+  ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
+  ,fHistos(NULL)
+  ,fReferenceTrackFilter(NULL)
+  ,fPhysSelTriggersEnabled(kFALSE)
+  ,fUserEnabledTriggers("")
+  ,fNAssignedTriggers(0)
+{
+  //
+  // Default constructor
+  //
+  SetMC(kTRUE);
+  SetTitle("Check TRD @ ESD level");
+  DefineOutput(1, TObjArray::Class());
+}
+
+//____________________________________________________________________
+AliTRDcheckESD::~AliTRDcheckESD()
+{
+  // Destructor
+  if(fHistos && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){
+    if(fHistos->IsOwner()) fHistos->Delete();
+    delete fHistos;
+    fHistos = NULL;
+  }
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FillEventInfo(Double_t* values) {
+  //
+  // Fill event information
+  //
+  values[kEventVtxZ] = fESD->GetPrimaryVertex()->GetZv();
+  values[kEventBC] = fESD->GetBunchCrossNumber();
+  
+  const AliMultiplicity* mult=fESD->GetMultiplicity();
+  Double_t itsNTracklets = mult->GetNumberOfTracklets();
+  values[kEventMult] = itsNTracklets;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FillTrackInfo(Double_t* values, AliESDtrack* esdTrack) {
+  //
+  // Fill track information
+  //
+  Float_t dcaxy,dcaz;
+  esdTrack->GetImpactParameters(dcaxy,dcaz);
+  values[kTrackDCAxy]  = dcaxy;
+  values[kTrackDCAz]   = dcaz;  
+  values[kTrackCharge] = esdTrack->Charge();
+  values[kTrackPt]     = esdTrack->Pt();
+  values[kTrackPhi]    = esdTrack->Phi();
+  values[kTrackEta]    = esdTrack->Eta();
+  values[kTrackP]      = esdTrack->P();
+  values[kTrackTrdTracklets] = esdTrack->GetTRDntracklets();
+  values[kTrackTrdClusters]  = esdTrack->GetTRDncls();
+  values[kTrackTrdChi2]      = esdTrack->GetTRDchi2()/(esdTrack->GetTRDntracklets()>0 ? esdTrack->GetTRDntracklets() : 1.0);
+  values[kTrackTrdQuality]   = esdTrack->GetTRDQuality();
+  values[kTrackTRDBudget]    = esdTrack->GetTRDBudget();
+  values[kTrackTOFBC]        = esdTrack->GetTOFBunchCrossing(fESD->GetMagneticField());
+  const AliExternalTrackParam *out=esdTrack->GetOuterParam();
+  Double_t p[3];
+  if(out->GetXYZ(p)) 
+    values[kTrackOuterParamRadius] = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
+  else 
+    values[kTrackOuterParamRadius] = 0.0;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FillTrackletInfo(Double_t* values, AliESDtrack* esdTrack, Int_t iPlane,
+                                      Double_t* localSagitaPhi, Double_t localMom[][3], Bool_t* localMomGood) {
+  //
+  // Fill TRD tracklet info
+  //
+  values[kTrackletClustersVsRows] = esdTrack->GetTRDtrkltClCross(iPlane);
+  values[kTrackletClusters]       = esdTrack->GetTRDtrkltOccupancy(iPlane);
+  values[kTrackletQtot]           = esdTrack->GetTRDslice(iPlane, 0);
+  values[kTrackletP]              = esdTrack->GetTRDmomentum(iPlane);
+  values[kTrackPlossTRDlayer]     = esdTrack->P() - values[kTrackletP];
+  values[kTrackletLayer]          = iPlane;
+  values[kTrackPhiTRD]            = localSagitaPhi[iPlane];
+  values[kTrackPtTRD]         = (localMomGood[iPlane] ? TMath::Sqrt(localMom[iPlane][0]*localMom[iPlane][0]+
+                                                                   localMom[iPlane][1]*localMom[iPlane][1]) : values[kTrackPt]);
+  values[kTrackPTRD]          = (localMomGood[iPlane] ? TMath::Sqrt(values[kTrackPtTRD]*values[kTrackPtTRD]+
+                                                                    localMom[iPlane][2]*localMom[iPlane][2]) : values[kTrackP]);       
+  values[kTrackEtaTRD] = values[kTrackPTRD]-(localMomGood[iPlane] ? localMom[iPlane][2] : esdTrack->Pz());
+  values[kTrackEtaTRD] = (TMath::Abs(values[kTrackPTRD])>1.0e-8 ? (values[kTrackPTRD]+(localMomGood[iPlane] ? localMom[iPlane][2] : esdTrack->Pz()))/values[kTrackEtaTRD] : 0.0);
+  values[kTrackEtaTRD] = (values[kTrackEtaTRD]>1.0e-8 ? 0.5*TMath::Log(values[kTrackEtaTRD]) : -999.);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FillTrackletSliceInfo(Double_t* values, AliESDtrack* esdTrack, Int_t iSlice) {
+  //
+  // Fill TRD tracklet info
+  //
+  values[kTrackletPHslice] = esdTrack->GetTRDslice(Int_t(values[kTrackletLayer]), iSlice);
+  values[kTrackletSlice] = iSlice;
+}
+
+//____________________________________________________________________
+Bool_t AliTRDcheckESD::IsTrackSelected(AliESDtrack* track, Double_t* /*values*/, Int_t step) {
+  //
+  // Select tracks at each step
+  //
+  Bool_t referenceFilter = fReferenceTrackFilter->IsSelected(track);
+  if(step==kTPCreference) {    // reference track filter
+    return referenceFilter;
+  }
+  if(step==kTRD) {    // TRD reference track filter
+    return (referenceFilter && track->GetTRDntracklets()>0);
+  }
+  if(step==kTOF) {    // TOFpid request
+    return (referenceFilter && track->GetTRDntracklets()>0 && (track->GetStatus() & AliESDtrack::kTOFpid)); 
+  }
+  if(step==kTOFin) {    // TOFin request
+    return (referenceFilter && (track->GetStatus() & AliESDtrack::kTOFin)); 
+  }
+  if(step==kTOFout) {    // TOFout request
+    return (referenceFilter && (track->GetStatus() & AliESDtrack::kTOFout)); 
+  }
+  return kFALSE;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::UserCreateOutputObjects()
+{      
+  //
+  // Create Output Containers (TObjectArray containing 1D histograms)
+  //
+  Histos();
+  PostData(1, fHistos);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::MakeSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/){
+  //
+  // Draw summary plots for the ESDcheck task using the CF container
+  //
+
+  cout << "Make summary from CF" << endl;
+  TCanvas *cOut=0x0;
+  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");
+  cOut = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  //PlotTrackingSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  PlotTrackingSummaryFromCF(trendValues);
+  cOut->SaveAs("trackingSummary.gif");
+  
+  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");
+  cOut = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  //PlotPidSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  PlotPidSummaryFromCF(trendValues);
+  cOut->SaveAs("pidSummary.gif");
+
+  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");
+  cOut = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  //PlotCentSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  PlotCentSummaryFromCF(trendValues);
+  cOut->SaveAs("centSummary.gif");
+  
+  PlotOtherSummaryFromCF(trendValues);
+  
+  if(trendValues)
+    for(Int_t i=0;i<50;++i) cout << "trend #" << i << " :: " << trendValues[i] << endl;
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::UserExec(Option_t *){
+  //
+  // Run the Analysis
+  //
+  fESD = dynamic_cast<AliESDEvent*>(InputEvent());
+  fMC = MCEvent();
+
+  if(!fESD){
+    AliError("ESD event missing.");
+    return;
+  }
+  
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if(!inputHandler) return;
+  
+  if(!fPhysSelTriggersEnabled) {
+    InitializeCFContainers();
+    fPhysSelTriggersEnabled = kTRUE;
+  }
+    
+  UInt_t isSelected = AliVEvent::kAny;
+  if(inputHandler){
+    if(inputHandler->GetEventSelection()) {
+      isSelected = inputHandler->IsEventSelected();
+    }
+  }
+  if(!isSelected) return;
+
+  TString triggerClasses = fESD->GetFiredTriggerClasses();
+  //cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++triggers fired:  " << triggerClasses.Data() << endl;
+  TObjArray* triggers = triggerClasses.Tokenize(" ");
+  TObjArray* userTriggers = fUserEnabledTriggers.Tokenize(";");
+  if(triggers->GetEntries()<1) {delete triggers; delete userTriggers; return;}
+  Bool_t hasGoodTriggers = kFALSE;
+  Int_t triggerIndices[kNMaxAssignedTriggers] = {0};
+  Int_t nTrigFired=0;
+  Bool_t trigAlreadyChecked = kFALSE;
+  Bool_t trigSelected = kFALSE;
+  Int_t trigIdx = 0;
+  for(Int_t i=0; i<triggers->GetEntries(); ++i) {
+    TString trigStr=triggers->At(i)->GetName();
+    if(!trigStr.Contains("NOTRD") && !trigStr.Contains("MUON")) hasGoodTriggers = kTRUE;    // check wheter TRD was read out in this event
+    if(trigStr.Contains("NOTRD")) continue;
+    if(trigStr.Contains("MUON")) continue;
+    if(i>=kNMaxAssignedTriggers) continue;
+    
+    hasGoodTriggers = kTRUE;
+    // enable the "All triggers" bit
+    trigIdx = 1;
+    trigAlreadyChecked = kFALSE;
+    for(Int_t k=0;k<nTrigFired;++k) 
+      if(triggerIndices[k]==trigIdx) {
+       trigAlreadyChecked = kTRUE;
+       break;
+    }
+    if(!trigAlreadyChecked) triggerIndices[nTrigFired++] = trigIdx;  
+    
+    trigSelected = kFALSE;
+    // check whether this trigger matches any of the user defined trigger families
+    for(Int_t j=0;j<userTriggers->GetEntries();++j) {
+      TString userTrigStr=userTriggers->At(j)->GetName();
+      if(trigStr.Contains(userTrigStr.Data())) {
+       trigSelected = kTRUE;
+       trigIdx = GetTriggerIndex(userTrigStr.Data(), kFALSE);
+       trigAlreadyChecked = kFALSE;
+       for(Int_t k=0;k<nTrigFired;++k) 
+         if(triggerIndices[k]==trigIdx) {
+           trigAlreadyChecked = kTRUE;
+           break;
+         }
+       if(!trigAlreadyChecked) {    // add trigger to the list of enabled triggers only if it was not added already
+         triggerIndices[nTrigFired++] = trigIdx;  
+       }
+      }
+    }
+    
+    trigIdx = GetTriggerIndex(trigStr.Data(), kFALSE);
+    if(trigIdx>0) trigSelected = kTRUE;
+    if(trigIdx==-1) trigIdx=1;  
+    trigAlreadyChecked = kFALSE;
+    for(Int_t k=0;k<nTrigFired;++k) 
+      if(triggerIndices[k]==trigIdx) {
+        trigAlreadyChecked = kTRUE;
+       break;
+      }
+    if(!trigAlreadyChecked) {
+      triggerIndices[nTrigFired++]=1;  // 0-assigned to all other triggers
+    }
+  }  // end loop over triggers  
+  
+  if(!trigSelected && hasGoodTriggers) {
+    triggerIndices[nTrigFired++]=2;
+  }
+  
+  TH1F* hTrig = (TH1F*)fHistos->FindObject("hTriggerDefs");
+  for(Int_t i=0; i<nTrigFired; ++i)
+    hTrig->Fill(triggerIndices[i]);
+
+  if(!hasGoodTriggers) {
+    PostData(1, fHistos);
+    delete triggers;
+    delete userTriggers;
+    return;
+  }
+  
+  Int_t* trigFiredIdx=new Int_t[nTrigFired];
+  for(Int_t i=0;i<nTrigFired;++i) trigFiredIdx[i] = triggerIndices[i];
+  
+  // Get MC information if available
+  //AliStack * fStack = NULL;
+  if(HasMC()){
+    if(!fMC){ 
+      AliWarning("MC event missing");
+      SetMC(kFALSE);
+    } else {
+      if(!fMC->Stack()){
+        AliWarning("MC stack missing");
+        SetMC(kFALSE);
+      }
+    }
+  }
+  
+  Double_t values[kNTrdCfVariables];      // array where the CF container variables are stored
+  for(Int_t i=0;i<kNTrdCfVariables; ++i) values[i] = -999.;
+  FillEventInfo(values);  
+  
+  Int_t multLimits[6] = {0, 700, 1400, 2100, 2800, 3500};
+  Int_t centralityClass = 0;
+  for(Int_t iCent=0; iCent<5; ++iCent) {
+    if(values[kEventMult]>=multLimits[iCent] && values[kEventMult]<multLimits[iCent+1])
+      centralityClass=iCent+1;
+  }
+  if(centralityClass == 0) return;
+  
+  // radius of TRD entrance plane in each layer
+  Double_t rTRD[6] = {298.0, 311.0, 324.0, 337.0, 350.0, 363.0};
+  
+  AliESDtrack *esdTrack(NULL);
+  for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){
+    esdTrack = fESD->GetTrack(itrk);
+    
+    Bool_t stepSelections[kNSteps]; 
+    for(Int_t is=0;is<kNSteps;++is) {
+      stepSelections[is] = IsTrackSelected(esdTrack, values, is);
+    }
+    if(!stepSelections[0]) continue;
+    
+    FillTrackInfo(values, esdTrack);
+    
+    // find position and momentum of the track at entrance in TRD
+    const AliExternalTrackParam *outerParam = esdTrack->GetOuterParam();
+    Double_t localCoord[6][3] = {{0.0}};
+    Bool_t localCoordGood[6];
+    for(Int_t il=0;il<6;++il) 
+      localCoordGood[il] = (outerParam ? outerParam : esdTrack)->GetXYZAt(rTRD[il], fESD->GetMagneticField(), localCoord[il]);  
+    Double_t localMom[6][3] = {{0.0}};
+    Bool_t localMomGood[6];
+    for(Int_t il=0; il<6; ++il) 
+      localMomGood[il] = (outerParam ? outerParam : esdTrack)->GetPxPyPzAt(rTRD[il], fESD->GetMagneticField(), localMom[il]);
+    Double_t localSagitaPhi[6] = {-999.};
+    for(Int_t il=0; il<6; ++il) 
+      localSagitaPhi[il] = (localCoordGood[il] ? TMath::ATan2(localCoord[il][1], localCoord[il][0]) : -999.);
+    if(!localMomGood[0]) continue;
+    
+    FillTrackletInfo(values, esdTrack, 0, localSagitaPhi, localMom, localMomGood);
+        
+    for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {
+      values[kEventTrigger] = Double_t(trigFiredIdx[itrig]);
+      
+      // check if cf needs tracklet or slice info
+      FillGlobalTrackContainers(values, stepSelections, itrig);
+      
+      for(Int_t iPlane=0; iPlane<6; iPlane++) {
+        FillTrackletInfo(values, esdTrack, iPlane, localSagitaPhi, localMom, localMomGood);
+       if(values[kTrackletQtot]>20.0) FillTrdTrackletContainers(values, stepSelections, itrig);
+       
+       for(Int_t iSlice=0; iSlice<8; iSlice++) {
+         FillTrackletSliceInfo(values, esdTrack, iSlice);
+         if(values[kTrackletPHslice]>20.0) FillTrdSliceContainers(values, stepSelections, itrig);
+       }  // end loop over slices
+      }  // end loop over TRD layers
+    }  // end loop over triggers
+  }  // end loop over tracks
+  
+  delete triggers;
+  delete userTriggers;
+  delete [] trigFiredIdx;  
+  
+  PostData(1, fHistos);
+}
+
+//____________________________________________________________________
+TObjArray* AliTRDcheckESD::Histos()
+{
+  // Retrieve histograms array if already build or build it
+  if(!fHistos) {
+    fHistos = new TObjArray();
+    fHistos->SetOwner(kTRUE);
+  }
+  
+  TH1* h = 0x0;
+  // Trigger definitions
+  if(!(h=(TH1F*)gROOT->FindObject("hTriggerDefs"))) {
+    h = new TH1F("hTriggerDefs", "Trigger definitions", kNMaxAssignedTriggers, 0.5, 0.5+Float_t(kNMaxAssignedTriggers));
+  }
+  else h->Reset();
+  fHistos->Add(h);
+    
+  return fHistos;
+}
+
+
+//__________________________________________________________________________________________________________
+void AliTRDcheckESD::InitializeCFContainers() {
+  //
+  //  Initialize the CF container
+  //
+  AliAnalysisManager* man=AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if(!inputHandler) return;
+
+  GetTriggerIndex("All triggers", kTRUE);
+  GetTriggerIndex("Not specified triggers", kTRUE);
+
+  AliPhysicsSelection* physSel = (AliPhysicsSelection*)inputHandler->GetEventSelection();
+  const TList* trigList = (physSel ? physSel->GetCollisionTriggerClasses() : 0x0);
+  const TList* bgTrigList = (physSel ? physSel->GetBGTriggerClasses() : 0x0);
+  
+  // Add collision triggers from PhysicsSelection
+  if(trigList) {
+    for(Int_t it=0; it<trigList->GetEntries(); ++it) {
+      TString trigName = trigList->At(it)->GetName();
+      TObjArray* arr = trigName.Tokenize(" ");
+      trigName = arr->At(0)->GetName();
+      trigName.Remove(0,1);
+      TObjArray* arr2 = trigName.Tokenize(",");
+      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {
+        // Assign an index into the trigger histogram and the CF container for this trigger
+        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);
+      }
+      delete arr;
+    }
+  }
+  // Add background triggers from PhysicsSelection
+  if(bgTrigList) {
+    for(Int_t it=0; it<bgTrigList->GetEntries(); ++it) {
+      TString trigName = bgTrigList->At(it)->GetName();
+      TObjArray* arr = trigName.Tokenize(" ");
+      trigName = arr->At(0)->GetName();
+      trigName.Remove(0,1);
+      TObjArray* arr2 = trigName.Tokenize(",");
+      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {
+        // Assign an index into the trigger histogram and the CF container for this trigger
+        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);
+      }
+      delete arr;
+    }
+  }
+    
+  // Add user enabled triggers
+  TObjArray* arr = fUserEnabledTriggers.Tokenize(";");
+  for(Int_t it=0; it<arr->GetEntries(); ++it) {
+    GetTriggerIndex(arr->At(it)->GetName(), kTRUE);
+  }
+  delete arr;
+}
+
+
+//__________________________________________________________________________________________________________
+void AliTRDcheckESD::AddCFContainer(const Char_t* name, const Char_t* title,
+                                   Int_t nSteps, Int_t* steps, 
+                                   Int_t nVars, UInt_t* vars, TArrayD* binLimits) {
+  //
+  // Add a CF container
+  //
+  if(!fHistos) {
+    fHistos = new TObjArray();
+    fHistos->SetOwner(kTRUE);
+  }
+  // get number of bins for each variable
+  Int_t* nBins = new Int_t[nVars];
+  for(Int_t iv=0;iv<nVars;++iv)
+    nBins[iv] = binLimits[iv].GetSize()-1;  
+  // create the CF container
+  AliCFContainer* cf = new AliCFContainer(name, title, nSteps, nVars, nBins);
+  // set CF container variable binning and name
+  for(Int_t iv=0;iv<nVars;++iv) {
+    cf->SetBinLimits(iv, binLimits[iv].GetArray());
+    cf->SetVarTitle(iv, fgkVarNames[vars[iv]]);
+  }
+  // set the step names 
+  for(Int_t is=0; is<nSteps; ++is) {
+    cf->SetStepTitle(is, fgkStepNames[steps[is]]);
+    for(Int_t iv=0;iv<nVars;++iv) cf->GetAxis(iv, is)->SetUniqueID(vars[iv]);
+  }
+  fHistos->Add(cf);
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::FillTrdSliceContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig) {
+  //
+  // fill TRD slice info
+  //
+  if(!fHistos) return;
+  for(Int_t i=0;i<fHistos->GetEntries();++i) {
+    TString objType = fHistos->At(i)->IsA()->GetName();
+    if(!objType.Contains("AliCFContainer")) continue;
+    AliCFContainer* cf = (AliCFContainer*)fHistos->At(i);
+    if(cf->GetVar(fgkVarNames[kTrackletSlice])<0 && cf->GetVar(fgkVarNames[kTrackletPHslice])<0) continue;
+    if((cf->GetVar(fgkVarNames[kEventTrigger])<0 && itrig==0) || (cf->GetVar(fgkVarNames[kEventTrigger])>=0))
+      FillCFContainer(cf, values, stepSelections);
+  }
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::FillTrdTrackletContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig) {
+  //
+  // fill global track info
+  //
+  if(!fHistos) return;
+  for(Int_t i=0;i<fHistos->GetEntries();++i) {
+    TString objType = fHistos->At(i)->IsA()->GetName();
+    if(!objType.Contains("AliCFContainer")) continue;
+    AliCFContainer* cf = (AliCFContainer*)fHistos->At(i);
+    if(cf->GetVar(fgkVarNames[kTrackletSlice])>=0 || cf->GetVar(fgkVarNames[kTrackletPHslice])>=0) continue;
+    if(cf->GetVar(fgkVarNames[kTrackletLayer])<0 && cf->GetVar(fgkVarNames[kTrackletQtot])<0) continue;
+    if((cf->GetVar(fgkVarNames[kEventTrigger])<0 && itrig==0) || (cf->GetVar(fgkVarNames[kEventTrigger])>=0))
+      FillCFContainer(cf, values, stepSelections);
+  }
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::FillGlobalTrackContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig) {
+  //
+  // fill global track info
+  //
+  if(!fHistos) return;
+  for(Int_t i=0;i<fHistos->GetEntries();++i) {
+    TString objType = fHistos->At(i)->IsA()->GetName();
+    if(!objType.Contains("AliCFContainer")) continue;
+    AliCFContainer* cf = (AliCFContainer*)fHistos->At(i);
+    if(cf->GetVar(fgkVarNames[kTrackletLayer])>=0 || 
+       cf->GetVar(fgkVarNames[kTrackletSlice])>=0 || 
+       cf->GetVar(fgkVarNames[kTrackletQtot])>=0 || 
+       cf->GetVar(fgkVarNames[kTrackletPHslice])>=0) continue;
+    if((cf->GetVar(fgkVarNames[kEventTrigger])<0 && itrig==0) || 
+       (cf->GetVar(fgkVarNames[kEventTrigger])>=0))
+      FillCFContainer(cf, values, stepSelections);
+  }
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::FillCFContainer(AliCFContainer* cf, Double_t* values, Bool_t* stepSelections) {
+  //
+  // Fill CF container
+  //
+  Double_t* cfValues=new Double_t[cf->GetNVar()];
+  for(Int_t iv=0;iv<cf->GetNVar();++iv)
+    cfValues[iv] = values[cf->GetAxis(iv,0)->GetUniqueID()];
+    
+  for(Int_t istep=0; istep<cf->GetNStep(); ++istep) {
+    TString stepTitle = cf->GetStepTitle(istep);
+    Int_t stepNo = -1;
+    for(Int_t is=0;is<kNSteps;++is) 
+      if(!stepTitle.CompareTo(fgkStepNames[is])) {
+       stepNo = is;
+       break;
+      }
+    if(stepSelections[stepNo]) cf->Fill(cfValues, istep);
+  }  // end loop over steps
+
+  delete [] cfValues;
+}
+
+//____________________________________________________________________
+Bool_t AliTRDcheckESD::Load(const Char_t *file, const Char_t *dir, const Char_t *name)
+{
+  //
+  // Load data from performance file
+  //
+  if(!TFile::Open(file)){
+    AliWarning(Form("Couldn't open file %s.", file));
+    return kFALSE;
+  }
+  if(dir){
+    if(!gFile->cd(dir)){
+      AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
+      return kFALSE;
+    }
+  }
+  TObjArray *o(NULL);
+  const Char_t *tn=(name ? name : GetName());
+  if(!(o = (TObjArray*)gDirectory->Get(tn))){
+    AliWarning(Form("Missing histogram container %s.", tn));
+    return kFALSE;
+  }
+  fHistos = (TObjArray*)o->Clone(GetName());
+    
+  TH1F* trigHist = (TH1F*)fHistos->FindObject("hTriggerDefs");
+  for(Int_t i=1;i<=trigHist->GetXaxis()->GetNbins();++i) {
+    if(trigHist->GetXaxis()->GetBinLabel(i)[0]!='\0') ++fNAssignedTriggers;
+  }
+  gFile->Close();
+  return kTRUE;
+}
+
+//_______________________________________________________
+Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val)
+{
+// Dump trending value to default file
+
+  if(!fgFile){
+    fgFile = fopen("TRD.Performance.txt", "at");
+  }
+  fprintf(fgFile, "%s_%s %f\n", GetName(), name, val);
+  return kTRUE;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::Terminate(Option_t *)
+{
+  // Steer post-processing 
+  if(!fHistos){
+    fHistos = dynamic_cast<TObjArray *>(GetOutputData(1));
+    if(!fHistos){
+      AliError("Histogram container not found in output");
+      return;
+    }
+  }
+}
+
+//____________________________________________________________________
+Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg) const
+{
+  //
+  // Helper function converting PDG code into AliPID index
+  //
+  switch(pdg){
+  case kElectron: 
+  case kPositron: return AliPID::kElectron;  
+  case kMuonPlus:
+  case kMuonMinus: return AliPID::kMuon;  
+  case kPiPlus: 
+  case kPiMinus: return AliPID::kPion;  
+  case kKPlus: 
+  case kKMinus: return AliPID::kKaon;
+  case kProton: 
+  case kProtonBar: return AliPID::kProton;
+  } 
+  return -1;
+}
+
+  
+//________________________________________________________
+void AliTRDcheckESD::Process2D(TH2 * const h2, TGraphErrors **g)
+{
+  //
+  // Do the processing
+  //
+
+  Int_t n = 0;
+  if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);
+  if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);
+  TF1 f("fg", "gaus", -3.,3.);
+  for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
+    Double_t x = h2->GetXaxis()->GetBinCenter(ibin);
+    TH1D *h = h2->ProjectionY("py", ibin, ibin);
+    if(h->GetEntries()<100) continue;
+    //AdjustF1(h, f);
+
+    h->Fit(&f, "QN");
+    Int_t ip = g[0]->GetN();
+    g[0]->SetPoint(ip, x, f.GetParameter(1));
+    g[0]->SetPointError(ip, 0., f.GetParError(1));
+    g[1]->SetPoint(ip, x, f.GetParameter(2));
+    g[1]->SetPointError(ip, 0., f.GetParError(2));
+  }
+  return;
+}
+//____________________________________________________________________
+void AliTRDcheckESD::PrintStatus(ULong_t status)
+{
+// Dump track status to stdout
+
+  printf("ITS[i(%d) o(%d) r(%d)] TPC[i(%d) o(%d) r(%d) p(%d)] TRD[i(%d) o(%d) r(%d) p(%d) s(%d)] HMPID[o(%d) p(%d)]\n"
+    ,Bool_t(status & AliESDtrack::kITSin)
+    ,Bool_t(status & AliESDtrack::kITSout)
+    ,Bool_t(status & AliESDtrack::kITSrefit)
+    ,Bool_t(status & AliESDtrack::kTPCin)
+    ,Bool_t(status & AliESDtrack::kTPCout)
+    ,Bool_t(status & AliESDtrack::kTPCrefit)
+    ,Bool_t(status & AliESDtrack::kTPCpid)
+    ,Bool_t(status & AliESDtrack::kTRDin)
+    ,Bool_t(status & AliESDtrack::kTRDout)
+    ,Bool_t(status & AliESDtrack::kTRDrefit)
+    ,Bool_t(status & AliESDtrack::kTRDpid)
+    ,Bool_t(status & AliESDtrack::kTRDStop)
+    ,Bool_t(status & AliESDtrack::kHMPIDout)
+    ,Bool_t(status & AliESDtrack::kHMPIDpid)
+  );
+}
+
+//____________________________________________________________________
+TH1D* AliTRDcheckESD::Proj2D(TH2* hist, TH1* mpvErr, TH1* widthErr, TH1* chi2) {
+  //
+  // project the PH vs Slice 2D-histo into a 1D histo with Landau MPV and widths
+  //
+  
+  TH1D* hProjection = (TH1D*)hist->ProjectionX(Form("hProjection_%f", gRandom->Rndm()));
+  hProjection->Reset();
+  
+  TF1* fitLandau = new TF1("landauFunc","landau",20.,3000.);
+  TH1D *hD;
+  for(Int_t iBin=1;iBin<=hist->GetXaxis()->GetNbins();iBin++) {
+    if(gROOT->FindObject("projection"))
+      delete gROOT->FindObject("projection");
+    hD = (TH1D*)hist->ProjectionY("projection",iBin,iBin);
+    //hD->Rebin(4);
+    if(hD->Integral()>10) {
+      fitLandau->SetParameter(1, hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParLimits(1, 0.2*hD->GetBinCenter(hD->GetMaximumBin()), 3.0*hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParameter(0, 1000.);
+      fitLandau->SetParLimits(0, 1., 10000000.);
+      fitLandau->SetParameter(2, 0.5*hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParLimits(2, 0.01*hD->GetBinCenter(hD->GetMaximumBin()), 1.0*hD->GetRMS());
+      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());
+      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());
+      hProjection->SetBinContent(iBin, fitLandau->GetParameter(1));
+      hProjection->SetBinError(iBin, fitLandau->GetParameter(2));
+      if(mpvErr) {
+       mpvErr->SetBinContent(iBin, fitLandau->GetParameter(1));
+       mpvErr->SetBinError(iBin, fitLandau->GetParError(1));
+      }
+      if(widthErr) {
+       widthErr->SetBinContent(iBin, fitLandau->GetParameter(2));
+       widthErr->SetBinError(iBin, fitLandau->GetParError(2));
+      }
+      if(chi2) {
+       chi2->SetBinContent(iBin, (fitLandau->GetNDF()>0 ? fitLandau->GetChisquare()/Double_t(fitLandau->GetNDF()) : 0.0));
+      }
+    }
+    else{
+      hProjection->SetBinContent(iBin, 0);
+      hProjection->SetBinError(iBin, 0);
+    }
+  }
+  return hProjection;
+}
+
+//____________________________________________________________________
+TH2F* AliTRDcheckESD::Proj3D(TH3* hist, TH2* accMap, Int_t zbinLow, Int_t zbinHigh, Float_t &entries) {
+  //
+  //  Project a 3D histogram to a 2D histogram in the Z axis interval [zbinLow,zbinHigh] 
+  //  Return the 2D histogram and also the number of entries into this projection (entries)
+
+  Int_t nBinsX = hist->GetXaxis()->GetNbins();   // X and Y axis bins are assumed to be all equal
+  Float_t minX = hist->GetXaxis()->GetXmin();
+  Float_t maxX = hist->GetXaxis()->GetXmax();
+  Int_t nBinsY = hist->GetYaxis()->GetNbins();
+  Float_t minY = hist->GetYaxis()->GetXmin();
+  Float_t maxY = hist->GetYaxis()->GetXmax();
+  Int_t nBinsZ = hist->GetZaxis()->GetNbins();  // Z axis bins (pt) might have different widths
+
+  TH2F* projHisto = (TH2F*)gROOT->FindObject("projHisto");
+  if(projHisto) 
+    projHisto->Reset();
+  else
+    projHisto = new TH2F("projHisto", "projection", nBinsX, minX, maxX, nBinsY, minY, maxY);
+
+  for(Int_t iZ=1; iZ<=nBinsZ; iZ++) {
+    if(iZ<zbinLow) continue;
+    if(iZ>zbinHigh) continue;
+    for(Int_t iX=1; iX<=nBinsX; iX++) {
+      for(Int_t iY=1; iY<=nBinsY; iY++) {
+        if(accMap) {
+          if(accMap->GetBinContent(iX,iY)>0.1)
+            projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));
+        }
+        else    // no acc. cut 
+          projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));
+        // count only the entries which are inside the acceptance map
+        if(accMap) {
+          if(accMap->GetBinContent(iX,iY)>0.1)
+            entries+=hist->GetBinContent(iX,iY,iZ);
+        }
+        else    // no acc. cut
+          entries+=hist->GetBinContent(iX,iY,iZ);
+      }
+    }
+  }
+  return projHisto;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]) {
+  //
+  // Check the active super-modules
+  //
+  Double_t entries[18] = {0.0};
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  for(Int_t phiBin=1; phiBin<=phiProj->GetXaxis()->GetNbins(); ++phiBin) {
+    Double_t phi = phiProj->GetBinCenter(phiBin);
+    Int_t sm = -1;
+    for(Int_t ism=0; ism<18; ++ism) 
+      if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1]) sm = ism;
+    if(sm==-1) continue;
+    entries[sm] += phiProj->GetBinContent(phiBin);
+  }
+  Double_t avEntries = Double_t(phiProj->Integral())/18.0;
+  for(Int_t ism=0; ism<18; ++ism) 
+    if(entries[ism]>0.5*avEntries) activeSM[ism] = kTRUE;
+}
+
+
+//__________________________________________________________________________________________________
+TH1F* AliTRDcheckESD::EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, 
+                                         Int_t stepNom, Int_t stepDenom, Int_t var) {
+  //
+  // Use the CF container to extract the efficiency vs pt (other variable beside pt also posible)
+  //
+  Int_t varTrackPhi = cf->GetVar(fgkVarNames[kTrackPhiTRD]);
+  Int_t otherVar = cf->GetVar(fgkVarNames[var]);
+  
+  TH1D* phiProj = (TH1D*)cf->Project(kTRD, varTrackPhi);
+  Bool_t activeSM[18] = {kFALSE};
+  CheckActiveSM(phiProj, activeSM); delete phiProj;
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  
+  if((stepNom==kTRD || stepDenom==kTRD) &&
+     (minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7))
+    cf->SetRangeUser(cf->GetVar(fgkVarNames[kTrackTrdTracklets]), Double_t(minNtrkl), Double_t(maxNtrkl));
+  
+  TH2D* hNomPhiVar = (TH2D*)cf->Project(stepNom, otherVar, varTrackPhi);
+  TH2D* hDenomPhiVar = (TH2D*)cf->Project(stepDenom, otherVar, varTrackPhi);
+  if((stepNom==kTRD || stepDenom==kTRD) &&
+     (minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7))
+    cf->SetRangeUser(cf->GetVar(fgkVarNames[kTrackTrdTracklets]), 0.0,6.0);
+  
+  TH1F* hEff = new TH1F(Form("hEff%s_%d_%d_%f", fgkVarNames[var], stepNom, stepDenom, gRandom->Rndm()), "", 
+                       hNomPhiVar->GetXaxis()->GetNbins(), hNomPhiVar->GetXaxis()->GetXbins()->GetArray());
+  for(Int_t ib=1;ib<=hNomPhiVar->GetXaxis()->GetNbins();++ib)
+    hEff->GetXaxis()->SetBinLabel(ib, hNomPhiVar->GetXaxis()->GetBinLabel(ib));
+  
+  for(Int_t ivar=1; ivar<=hEff->GetXaxis()->GetNbins(); ++ivar) {
+    Double_t nom = 0.0; Double_t denom = 0.0;
+    Double_t eff = 0.0; Double_t err = 0.0;
+    for(Int_t iphi=1; iphi<=hNomPhiVar->GetYaxis()->GetNbins(); ++iphi) {
+      Double_t phi = hNomPhiVar->GetYaxis()->GetBinCenter(iphi);
+      Bool_t isActive = kFALSE;
+      for(Int_t ism=0; ism<18; ++ism) 
+        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) 
+         isActive = kTRUE;
+      if(!isActive) continue;
+      nom += hNomPhiVar->GetBinContent(ivar, iphi);
+      denom += hDenomPhiVar->GetBinContent(ivar, iphi);
+    }
+    eff = (denom>0.001 ? nom/denom : 0.0);
+    err = (denom>0.001 && (denom-nom)>0.001 && nom>0.001 ? (TMath::Sqrt(nom*(denom-nom)/denom/denom/denom)) : 0.0);
+    hEff->SetBinContent(ivar, eff);
+    hEff->SetBinError(ivar, err);
+  }   // end loop over pt bins
+  delete hNomPhiVar; delete hDenomPhiVar;
+  return hEff;
+}
+
+
+//____________________________________________________________________
+TH1F* AliTRDcheckESD::EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance) {
+  //
+  // Calculate the TRD-TPC matching efficiency as function of pt
+  //
+  
+  if(!tpc3D || !trd3D) return NULL;
+  Int_t nBinsZ = trd3D->GetZaxis()->GetNbins();
+  // project everything on the eta-phi map to obtain an acceptance map
+  Float_t nada = 0.;
+  TH2F *trdAcc = (useAcceptance ? (TH2F*)Proj3D(trd3D, 0x0, 1, nBinsZ, nada)->Clone(Form("trdAcc%f", gRandom->Rndm())) : 0x0);
+  TH1D *phiProj = (trdAcc ? trdAcc->ProjectionY(Form("phiProj%f", gRandom->Rndm())) : 0x0);
+  
+  // prepare the acceptance map
+  Bool_t activeSM[18] = {kFALSE};
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  if(phiProj) {
+    CheckActiveSM(phiProj, activeSM);   // get the active SMs
+    trdAcc->Reset();
+    // Put 1 entry in every bin which belongs to an active SM
+    for(Int_t iY=1; iY<=trdAcc->GetYaxis()->GetNbins(); ++iY) {
+      Double_t phi = trdAcc->GetYaxis()->GetBinCenter(iY);
+      Bool_t isActive = kFALSE;
+      for(Int_t ism=0; ism<18; ++ism) {
+        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) {
+         isActive = kTRUE;
+        }
+      }
+      if(!isActive) continue;
+      for(Int_t iX=1; iX<=trdAcc->GetXaxis()->GetNbins(); ++iX) 
+        if(trdAcc->GetXaxis()->GetBinCenter(iX)>=-0.85 && trdAcc->GetXaxis()->GetBinCenter(iX)<=0.85) trdAcc->SetBinContent(iX, iY, 1.0);
+    }  // end for over Y(phi) bins
+  }  // end if phiProj
+    
+  // get the bin limits from the Z axis of 3D histos
+  Float_t *ptBinLimits = new Float_t[nBinsZ+1];
+  for(Int_t i=1; i<=nBinsZ; i++) {
+    ptBinLimits[i-1] = trd3D->GetZaxis()->GetBinLowEdge(i);
+  }
+  ptBinLimits[nBinsZ] = trd3D->GetZaxis()->GetBinUpEdge(nBinsZ);
+  
+  TH1F *efficiency = new TH1F(Form("eff%d", Int_t(1000000.0*gRandom->Rndm())), "TRD-TPC matching efficiency", nBinsZ, ptBinLimits);
+  
+  // loop over Z bins
+  Bool_t effGood = kFALSE;
+  for(Int_t i=1; i<=nBinsZ; i++) {
+    Float_t tpcEntries = 0.0; Float_t trdEntries = 0.0;
+    Proj3D(tpc3D, trdAcc, i, i, tpcEntries);
+    Proj3D(trd3D, trdAcc, i, i, trdEntries);
+    Float_t ratio = 0;
+    if(tpcEntries>0) ratio = trdEntries/tpcEntries;
+    Float_t error = 0;
+    if(tpcEntries>0 && trdEntries>0 && (tpcEntries-trdEntries)>=0.0) 
+      error = TMath::Sqrt(trdEntries*(tpcEntries-trdEntries)/tpcEntries/tpcEntries/tpcEntries);
+    if(ratio>0.001) {
+      efficiency->SetBinContent(i,ratio);
+      efficiency->SetBinError(i,error);
+      effGood = kTRUE;
+    }
+  }     // end loop over Z bins
+  if(!effGood) return 0x0;
+  
+  return efficiency;
+}
+
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::PlotCentSummaryFromCF(Double_t* /*trendValues*/, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  // Make the centrality summary figure from the CF container 
+  // 
+  if(!fHistos) return;
+  AliCFContainer* matchPt=(AliCFContainer*)fHistos->FindObject("MatchingPt");
+  if(!matchPt) return;
+  AliCFContainer* centCF=(AliCFContainer*)fHistos->FindObject("CentralityCF");
+  if(!centCF) return;
+  
+  TLatex* lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001); gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  TVirtualPad* pad=0x0;
+  
+  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");
+  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.3);
+  rangeEffPt->SetStats(kFALSE);
+  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  
+  Int_t padsForEffs[5] = {0,3,6,1,4};
+  for(Int_t iCent=1; iCent<6; ++iCent) {
+    pad = ((TVirtualPad*)l->At(padsForEffs[iCent-1])); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    rangeEffPt->Draw();
+    TLine line;
+    line.SetLineStyle(2);
+    line.SetLineWidth(2);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);
+    
+    matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kEventMult]), Double_t(iCent), Double_t(iCent), kTRUE);
+       
+    matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), +1.0, +1.0);  
+    TH1F* hEffPosAll = EfficiencyFromPhiPt(matchPt,  0,  6, 1, 0);
+    TH1F* hEffPosTrk4 = EfficiencyFromPhiPt(matchPt, 4,  4, 1, 0);  
+    TH1F* hEffPosTrk5 = EfficiencyFromPhiPt(matchPt, 5,  5, 1, 0);
+    TH1F* hEffPosTrk6 = EfficiencyFromPhiPt(matchPt, 6,  6, 1, 0);
+     
+    matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);  
+    TH1F* hEffNegAll = EfficiencyFromPhiPt(matchPt, 0, 6, 1, 0);  
+    TH1F* hEffNegTrk4 = EfficiencyFromPhiPt(matchPt, 4, 4, 1, 0);  
+    TH1F* hEffNegTrk5 = EfficiencyFromPhiPt(matchPt, 5, 5, 1, 0);  
+    TH1F* hEffNegTrk6 = EfficiencyFromPhiPt(matchPt, 6, 6, 1, 0);
+    matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackTrdTracklets]), 0.0, 6.0);  
+    matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), -1.0, +1.0);  
+    
+    SetStyle(hEffPosAll,  1, kRed, 1, 24, kRed, 1);
+    SetStyle(hEffPosTrk4, 1, kRed, 1, 25, kRed, 1);
+    SetStyle(hEffPosTrk5, 1, kRed, 1, 26, kRed, 1);
+    SetStyle(hEffPosTrk6, 1, kRed, 1, 27, kRed, 1);
+    SetStyle(hEffNegAll,  1, kBlue, 1, 24, kBlue, 1);
+    SetStyle(hEffNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+    SetStyle(hEffNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+    SetStyle(hEffNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+    hEffPosAll->Draw("same");
+    hEffNegAll->Draw("same");
+    hEffPosTrk4->Draw("same");
+    hEffNegTrk4->Draw("same");
+    hEffPosTrk5->Draw("same");
+    hEffNegTrk5->Draw("same");
+    hEffPosTrk6->Draw("same");
+    hEffNegTrk6->Draw("same");    
+        
+    TLegend* leg=new TLegend(0.18, 0.7, 0.77, 0.89);
+    if(iCent==1) {
+      leg->SetFillColor(0);
+      leg->SetNColumns(2);
+      leg->SetMargin(0.1);
+      leg->SetBorderSize(0);
+      leg->AddEntry(hEffPosAll,  "pos. (#geq 1 tracklet)", "p");
+      leg->AddEntry(hEffNegAll,  "neg. (#geq 1 tracklet)", "p");
+      leg->AddEntry(hEffPosTrk4, "pos. (4 tracklets)", "p");
+      leg->AddEntry(hEffNegTrk4, "neg. (4 tracklets)", "p");
+      leg->AddEntry(hEffPosTrk5, "pos. (5 tracklets)", "p");
+      leg->AddEntry(hEffNegTrk5, "neg. (5 tracklets)", "p");
+      leg->AddEntry(hEffPosTrk6, "pos. (6 tracklets)", "p");     
+      leg->AddEntry(hEffNegTrk6, "neg. (6 tracklets)", "p");
+      leg->Draw();
+    }
+    lat->DrawLatex(0.2, 1.32, Form("%.0f < SPD tracklets < %.0f", matchPt->GetAxis(matchPt->GetVar(fgkVarNames[kEventMult]),0)->GetBinLowEdge(iCent), matchPt->GetAxis(matchPt->GetVar(fgkVarNames[kEventMult]),0)->GetBinUpEdge(iCent)));
+  }   // end for loop over multiplicity classes
+  
+  // Reset the modified user ranges of the CF container
+  matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kEventMult]), 0., 3500.);
+     
+  // Cluster distributions in all multiplicity classes
+  pad = ((TVirtualPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");
+  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);
+  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeNcls->SetStats(kFALSE);
+  rangeNcls->Draw();
+    
+  TH1D* hNcls[6]={0x0};
+  TLegend* legCls=new TLegend(0.7, 0.75, 0.97, 0.97);
+  legCls->SetBorderSize(0);
+  legCls->SetFillColor(0);
+  legCls->SetMargin(0.15);
+  
+  for(Int_t iCent=0; iCent<6; ++iCent) {
+    if(iCent>0)
+      centCF->SetRangeUser(centCF->GetVar(fgkVarNames[kEventMult]), Double_t(iCent), Double_t(iCent), kTRUE);
+    hNcls[iCent] = (TH1D*)centCF->Project(0, centCF->GetVar(fgkVarNames[kTrackTrdClusters]));
+    if(!hNcls[iCent]) continue;
+    
+    hNcls[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+    Double_t maximum = hNcls[iCent]->GetMaximum();
+    if(maximum>1.0)
+      hNcls[iCent]->Scale(1.0/maximum);
+    hNcls[iCent]->SetStats(kFALSE);
+    hNcls[iCent]->SetTitle("");
+    hNcls[iCent]->SetLineWidth(2);
+    
+    if(hNcls[iCent]->Integral()>0.01) {
+      hNcls[iCent]->Draw("same");
+      legCls->AddEntry(hNcls[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", centCF->GetAxis(centCF->GetVar(fgkVarNames[kEventMult]),0)->GetBinLowEdge(iCent), 
+                                                                          centCF->GetAxis(centCF->GetVar(fgkVarNames[kEventMult]),0)->GetBinUpEdge(iCent))), "l");
+    }
+  }
+  legCls->Draw();
+  centCF->SetRangeUser(centCF->GetVar(fgkVarNames[kEventMult]), 0.0, 6.0, kTRUE);
+  
+  // Qtot vs P
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");
+  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);
+  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtot->SetStats(kFALSE);
+  rangeQtot->Draw();
+  
+  TH1D* hQtot[6]={0x0};
+  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.97);
+  leg2->SetFillColor(0);
+  leg2->SetBorderSize(0);
+  
+  for(Int_t iCent=0; iCent<6; ++iCent) {
+    if(iCent>0)
+      centCF->SetRangeUser(centCF->GetVar(fgkVarNames[kEventMult]), Double_t(iCent), Double_t(iCent), kTRUE);
+    
+    hQtot[iCent] = (TH1D*)centCF->Project(0, centCF->GetVar(fgkVarNames[kTrackletQtot]));
+    if(!hQtot[iCent]) continue;
+    hQtot[iCent]->SetBinContent(1, 0);
+    
+    Double_t maximum = hQtot[iCent]->GetMaximum();
+    if(maximum>1.0)
+      hQtot[iCent]->Scale(1.0/maximum);
+    hQtot[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+    hQtot[iCent]->SetStats(kFALSE);
+    hQtot[iCent]->SetTitle("");
+    hQtot[iCent]->SetLineWidth(2);
+    if(hQtot[iCent]->Integral()>0.01) {
+      hQtot[iCent]->Draw(iCent==0 ? "" : "same");
+      leg2->AddEntry(hQtot[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", centCF->GetAxis(centCF->GetVar(fgkVarNames[kEventMult]),0)->GetBinLowEdge(iCent), 
+                                                                          centCF->GetAxis(centCF->GetVar(fgkVarNames[kEventMult]),0)->GetBinUpEdge(iCent))), "l");
+    }
+  }
+  leg2->Draw();
+  centCF->SetRangeUser(centCF->GetVar(fgkVarNames[kEventMult]), 0.0, 5.0, kTRUE);
+}
+
+
+
+//_________________________________________________________________
+void AliTRDcheckESD::PlotTrackingSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  //  Plot tracking summary
+  //
+  if(!fHistos) return;
+  AliCFContainer* matchPhiEta=(AliCFContainer*)fHistos->FindObject("MatchingPhiEta");
+  if(!matchPhiEta) return;
+  AliCFContainer* matchPt=(AliCFContainer*)fHistos->FindObject("MatchingPt");
+  if(!matchPt) return;
+  AliCFContainer* clustersCF=(AliCFContainer*)fHistos->FindObject("CentralityCF");
+  if(!clustersCF) return;
+  AliCFContainer* bcCF=(AliCFContainer*)fHistos->FindObject("BunchCrossingsCF");
+  if(!bcCF) return;
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+  lat->SetTextFont(42);
+  
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  
+  // eta-phi distr. for positive TPC tracks
+  TVirtualPad* pad = ((TVirtualPad*)l->At(0)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  TH2D* hTPCrefPos = 0x0; TH2D* hTRDrefPos = 0x0; TH2D* hTOFrefPos = 0x0;
+  TH2D* hTPCrefNeg = 0x0; TH2D* hTRDrefNeg = 0x0; TH2D* hTOFrefNeg = 0x0;
+  matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackTrdTracklets]), 0.0, 6.0);
+  matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackCharge]), +1.0, +1.0);      // positive charges
+  hTPCrefPos = (TH2D*)matchPhiEta->Project(0, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  hTRDrefPos = (TH2D*)matchPhiEta->Project(1, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  hTOFrefPos = (TH2D*)matchPhiEta->Project(2, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);      // negative charges
+  hTPCrefNeg = (TH2D*)matchPhiEta->Project(0, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  hTRDrefNeg = (TH2D*)matchPhiEta->Project(1, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  hTOFrefNeg = (TH2D*)matchPhiEta->Project(2, matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]));
+  matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackCharge]), -1.0, +1.0);      // reset charge cut
+    
+  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.15, 3.15);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);  
+  
+  //----------------------------------------------
+  // eta-phi efficiency for positive TRD tracks
+  pad = ((TVirtualPad*)l->At(0)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTRDeffPos = (hTRDrefPos ? (TH2D*)hTRDrefPos->Clone("hTRDeffPos") : 0x0);
+  if(hTRDeffPos) {
+    hTRDeffPos->Reset();
+    hTRDeffPos->SetStats(kFALSE);
+    hTRDeffPos->Divide(hTRDrefPos, hTPCrefPos);
+    hTRDeffPos->SetMaximum(1.0);
+    hTRDeffPos->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.3, "TPC-TRD matching for positive tracks");
+    DrawTRDGrid();
+  }
+  
+  //----------------------------------------------
+  // eta-phi efficiency for negative TRD tracks
+  pad = ((TVirtualPad*)l->At(3)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTRDeffNeg = (hTRDrefNeg ? (TH2D*)hTRDrefNeg->Clone("hTRDeffNeg") : 0x0);
+  if(hTRDeffNeg) {
+    hTRDeffNeg->Reset();
+    hTRDeffNeg->SetStats(kFALSE);
+    hTRDeffNeg->Divide(hTRDrefNeg, hTPCrefNeg);
+    hTRDeffNeg->SetMaximum(1.0);
+    hTRDeffNeg->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.3, "TPC-TRD matching for negative tracks");
+    DrawTRDGrid();  
+  }
+  
+  //----------------------------------------------
+  // eta-phi TRD-TOF matching efficiency for positive tracks
+  pad = ((TVirtualPad*)l->At(1)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTOFeffPos = (hTOFrefPos ? (TH2D*)hTOFrefPos->Clone("hTOFeffPos") : 0x0);
+  if(hTOFeffPos) {
+    hTOFeffPos->Reset();
+    hTOFeffPos->SetStats(kFALSE);
+    hTOFeffPos->Divide(hTOFrefPos, hTRDrefPos);
+    hTOFeffPos->SetMaximum(1.0);
+    hTOFeffPos->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.3, "TRD-TOF matching for positive tracks");
+    DrawTRDGrid();
+  }
+  
+  //----------------------------------------------
+  // eta-phi TRD-TOF matching efficiency for negative tracks
+  pad = ((TVirtualPad*)l->At(4)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTOFeffNeg = (hTOFrefNeg ? (TH2D*)hTOFrefNeg->Clone("hTOFeffNeg") : 0x0);
+  if(hTOFeffNeg) {
+    hTOFeffNeg->Reset();
+    hTOFeffNeg->SetStats(kFALSE);
+    hTOFeffNeg->Divide(hTOFrefNeg, hTRDrefNeg);
+    hTOFeffNeg->SetMaximum(1.0);
+    hTOFeffNeg->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.3, "TRD-TOF matching for negative tracks");
+    DrawTRDGrid();
+  }
+  
+  if(hTRDrefPos) delete hTRDrefPos; if(hTPCrefPos) delete hTPCrefPos; if(hTOFrefPos) delete hTOFrefPos;
+  if(hTRDrefNeg) delete hTRDrefNeg; if(hTPCrefNeg) delete hTPCrefNeg; if(hTOFrefNeg) delete hTOFrefNeg;
+  
+  // switch to the Pt cf container
+  matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), +1.0, +1.0);  
+  TH1F* hTRDEffPtPosAll = EfficiencyFromPhiPt(matchPt, 0, 6, 1, 0);
+  TH1F* hTOFEffPtPosAll = EfficiencyFromPhiPt(matchPt, 0, 6, 2, 1);
+  TH1F* hTRDEffPtPosTrk4 = EfficiencyFromPhiPt(matchPt, 4, 4, 1, 0);
+  TH1F* hTOFEffPtPosTrk4 = EfficiencyFromPhiPt(matchPt, 4, 4, 2, 1);
+  TH1F* hTRDEffPtPosTrk5 = EfficiencyFromPhiPt(matchPt, 5, 5, 1, 0);
+  TH1F* hTOFEffPtPosTrk5 = EfficiencyFromPhiPt(matchPt, 5, 5, 2, 1);
+  TH1F* hTRDEffPtPosTrk6 = EfficiencyFromPhiPt(matchPt, 6, 6, 1, 0);
+  TH1F* hTOFEffPtPosTrk6 = EfficiencyFromPhiPt(matchPt, 6, 6, 2, 1);
+  
+  matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);  
+  TH1F* hTRDEffPtNegAll = EfficiencyFromPhiPt(matchPt, 0, 6, 1, 0);
+  TH1F* hTOFEffPtNegAll = EfficiencyFromPhiPt(matchPt, 0, 6, 2, 1);
+  TH1F* hTRDEffPtNegTrk4 = EfficiencyFromPhiPt(matchPt, 4, 4, 1, 0);
+  TH1F* hTOFEffPtNegTrk4 = EfficiencyFromPhiPt(matchPt, 4, 4, 2, 1);
+  TH1F* hTRDEffPtNegTrk5 = EfficiencyFromPhiPt(matchPt, 5, 5, 1, 0);
+  TH1F* hTOFEffPtNegTrk5 = EfficiencyFromPhiPt(matchPt, 5, 5, 2, 1);
+  TH1F* hTRDEffPtNegTrk6 = EfficiencyFromPhiPt(matchPt, 6, 6, 1, 0);
+  TH1F* hTOFEffPtNegTrk6 = EfficiencyFromPhiPt(matchPt, 6, 6, 2, 1);
+  matchPt->SetRangeUser(matchPt->GetVar(fgkVarNames[kTrackCharge]), -1.0, +1.0);  
+  
+  TF1* funcConst = new TF1("constFunc", "[0]", 1.0, 3.0);
+  if(trendValues) {
+    if(hTRDEffPtPosAll && hTRDEffPtPosAll->Integral()>0.1) {
+      hTRDEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[0] = funcConst->GetParameter(0);
+      trendValues[1] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTRDEffPtNegAll && hTRDEffPtNegAll->Integral()>0.1) {
+      hTRDEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[2] = funcConst->GetParameter(0);
+      trendValues[3] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTOFEffPtPosAll && hTOFEffPtPosAll->Integral()>0.1) {
+      hTOFEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[4] = funcConst->GetParameter(0);
+      trendValues[5] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTOFEffPtNegAll && hTOFEffPtNegAll->Integral()>0.1) {
+      hTOFEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[6] = funcConst->GetParameter(0);
+      trendValues[7] = funcConst->GetParError(0);
+    }
+  }
+  
+  //---------------------------------------------------------
+  // TPC-TRD matching efficiency vs pt
+  pad = ((TVirtualPad*)l->At(6)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");
+  TH2F* rangeEffPt=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);
+  rangeEffPt->SetStats(kFALSE);
+  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  rangeEffPt->Draw();
+  lat->DrawLatex(0.2, 1.44, "TPC-TRD matching efficiency");
+  //++++++++++++++++++
+  TLine line;
+  line.SetLineStyle(2);
+  line.SetLineWidth(2);
+  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);
+  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);
+  TLegend* leg=new TLegend(0.2, 0.7, 0.7, 0.89);
+  leg->SetNColumns(2);
+  leg->SetMargin(0.15);
+  leg->SetBorderSize(0);
+  leg->SetFillColor(0);
+
+  SetStyle(hTRDEffPtPosAll, 1, kRed, 1, 24, kRed, 1);
+  SetStyle(hTRDEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+  if(hTRDEffPtPosAll) {hTRDEffPtPosAll->Draw("same"); leg->AddEntry(hTRDEffPtPosAll, "pos. (#geq 1 tracklet)", "p");}
+  if(hTRDEffPtNegAll) {hTRDEffPtNegAll->Draw("same"); leg->AddEntry(hTRDEffPtNegAll, "neg. (#geq 1 tracklet)", "p");}
+  hTRDEffPtPosTrk4->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk4, "pos. (4 tracklets)", "p");
+  hTRDEffPtNegTrk4->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk4, "neg. (4 tracklets)", "p");
+  hTRDEffPtPosTrk5->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk5, "pos. (5 tracklets)", "p");
+  hTRDEffPtNegTrk5->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk5, "neg. (5 tracklets)", "p");
+  hTRDEffPtPosTrk6->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk6, "pos. (6 tracklets)", "p");
+  hTRDEffPtNegTrk6->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk6, "neg. (6 tracklets)", "p");
+  
+  leg->Draw();
+  
+  //---------------------------------------------------------
+  // TRD-TOF matching efficiency vs pt
+  pad = ((TVirtualPad*)l->At(7)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  rangeEffPt->Draw();
+  lat->DrawLatex(0.2, 1.44, "TRD-TOF matching efficiency");
+  SetStyle(hTOFEffPtPosAll, 1, kRed, 1, 24, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);
+  SetStyle(hTOFEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+  if(hTOFEffPtPosAll) hTOFEffPtPosAll->Draw("same"); 
+  hTOFEffPtPosTrk4->Draw("same"); 
+  hTOFEffPtPosTrk5->Draw("same"); 
+  hTOFEffPtPosTrk6->Draw("same"); 
+  if(hTOFEffPtNegAll) hTOFEffPtNegAll->Draw("same"); 
+  hTOFEffPtNegTrk4->Draw("same"); 
+  hTOFEffPtNegTrk5->Draw("same"); 
+  hTOFEffPtNegTrk6->Draw("same");  
+    
+  //-----------------------------------------------------
+  // <ntracklets> vs (phi,eta)
+  pad = ((TVirtualPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.3, "TRD <N_{tracklets}>");
+  
+  TH3D* hNtracklets = (TH3D*)matchPhiEta->Project(kTRD, matchPhiEta->GetVar(fgkVarNames[kTrackPhiTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackEtaTRD]), matchPhiEta->GetVar(fgkVarNames[kTrackTrdTracklets]));
+  
+  TProfile2D* hNtrackletsProf = hNtracklets->Project3DProfile();
+  delete hNtracklets;
+  if(hNtrackletsProf) {
+    hNtrackletsProf->SetStats(kFALSE);
+    hNtrackletsProf->SetMinimum(0.);
+    hNtrackletsProf->SetMaximum(6.);
+    hNtrackletsProf->Draw("samecolz");
+    DrawTRDGrid();
+  }
+  
+  // calculate the trend value for tracklets/track
+  TH2D* hNtrackletsVsP = (TH2D*)matchPt->Project(kTRD, matchPt->GetVar(fgkVarNames[kTrackPt]), matchPt->GetVar(fgkVarNames[kTrackTrdTracklets]));
+  if(trendValues &&  hNtrackletsVsP && hNtrackletsVsP->GetEntries()>0.1) {
+    TProfile* hNtrackletsVsPprof = hNtrackletsVsP->ProfileX("hNtrackletsVsPprof");
+    hNtrackletsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+    trendValues[8] = funcConst->GetParameter(0);
+    trendValues[9] = funcConst->GetParError(0);
+    delete hNtrackletsVsP;
+  }
+    
+  //--------------------------------------------------------------
+  // Nclusters per TRD track vs momentum
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  
+  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");
+  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);
+  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);
+  rangeNclsP->SetStats(kFALSE);
+  rangeNclsP->Draw();
+  lat->DrawLatex(1.0, 205., "TRD Clusters / track");
+  
+  TH2D* hNclsVsP = (TH2D*)clustersCF->Project(0, clustersCF->GetVar(fgkVarNames[kTrackP]), clustersCF->GetVar(fgkVarNames[kTrackTrdClusters]));
+  if(hNclsVsP) {
+    hNclsVsP->SetStats(kFALSE);
+    hNclsVsP->Draw("samecolz");
+  }
+  
+  if(trendValues && hNclsVsP && hNclsVsP->GetEntries()>10) {
+    TProfile* hNclsVsPprof = hNclsVsP->ProfileX("hNclsVsPprof");
+    hNclsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+    trendValues[10] = funcConst->GetParameter(0);
+    trendValues[11] = funcConst->GetParError(0);
+  }
+  
+  //--------------------------------------------------------------
+  // TRD-TPC and TOF-TRD matching efficiency vs bunch crossing
+  pad = ((TVirtualPad*)l->At(8)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+
+  TH1F* hTRDEffBC = EfficiencyFromPhiPt(bcCF, -1, -1, 1, 0, kEventBC);
+  TH1F* hTOFEffBC = EfficiencyFromPhiPt(bcCF, -1, -1, 2, 1, kEventBC);
+   
+  if(gROOT->FindObject("rangeBC")) delete gROOT->FindObject("rangeBC");
+  TH2F* rangeBC = new TH2F("rangeBC", "", 10, -0.5, 3499.5, 10, 0.0, 1.4);
+  rangeBC->SetStats(kFALSE);
+  SetStyle(rangeBC->GetXaxis(), "Bunch crossing", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeBC->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  rangeBC->Draw();
+  
+  TLegend* legBC=new TLegend(0.8, 0.7, 0.95, 0.89);
+  legBC->SetBorderSize(0);
+  legBC->SetMargin(0.15);
+  legBC->SetFillColor(0);
+  if(hTRDEffBC) {
+    hTRDEffBC->SetStats(kFALSE);
+    SetStyle(hTRDEffBC, 1, kRed, 2, 24, kRed, 1); legBC->AddEntry(hTRDEffBC, "TPC-TRD", "p");
+    SetStyle(hTOFEffBC, 1, kBlue, 2, 24, kBlue, 1); legBC->AddEntry(hTOFEffBC, "TRD-TOF", "p");
+    hTRDEffBC->Draw("same");
+    hTOFEffBC->Draw("same");
+    legBC->Draw();
+    lat->DrawLatex(200., 1.44, "Matching efficiency at 1<p_{T}<3 GeV/c");
+  }
+  
+  delete funcConst;
+}
+
+
+
+//_________________________________________________________________
+void AliTRDcheckESD::PlotPidSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  // PID summary
+  //
+  if(!fHistos) return;
+  AliCFContainer* qtotCF = (AliCFContainer*)fHistos->FindObject("QtotCF");
+  if(!qtotCF) return;
+  AliCFContainer* phCF = (AliCFContainer*)fHistos->FindObject("PulseHeightCF");
+  if(!phCF) return;
+  AliCFContainer* centCF = (AliCFContainer*)fHistos->FindObject("CentralityCF");
+  if(!centCF) return;   
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  lat->SetTextFont(42);
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+    
+  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.15, 3.15);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);  
+  
+  // eta-phi distr. for <Qtot> in layer 0
+  TVirtualPad* pad;
+  TProfile2D* hProf2D;
+  TH1D* hqtot = (TH1D*)qtotCF->Project(0, qtotCF->GetVar(fgkVarNames[kTrackletQtot]));
+  for(Int_t iLayer=0; iLayer<6; ++iLayer) {
+    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+1))); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    rangeEtaPhi->Draw();
+    qtotCF->SetRangeUser(qtotCF->GetVar(fgkVarNames[kTrackletLayer]), Double_t(iLayer), Double_t(iLayer));
+    TH3D* hQtotEtaPhi = (TH3D*)qtotCF->Project(0, qtotCF->GetVar(fgkVarNames[kTrackPhiTRD]), qtotCF->GetVar(fgkVarNames[kTrackEtaTRD]), qtotCF->GetVar(fgkVarNames[kTrackletQtot]));  
+    hProf2D = (hQtotEtaPhi ? hQtotEtaPhi->Project3DProfile() : 0x0);
+    if(hQtotEtaPhi) delete hQtotEtaPhi;
+    
+    if(hProf2D) {
+      hProf2D->SetName(Form("Qtot_layer%d",iLayer));
+      hProf2D->SetStats(kFALSE);
+      hProf2D->SetMinimum(0.);
+      hProf2D->SetMaximum((hqtot->GetMean()<10 ? 4.0 : 2000.));
+      hProf2D->Draw("samecolz");
+    }
+    lat->DrawLatex(-0.9, 3.3, Form("TRD <Q_{tot}> Layer %d", iLayer));
+    DrawTRDGrid();
+  }
+  qtotCF->SetRangeUser(qtotCF->GetVar(fgkVarNames[kTrackletLayer]), 0.0, 5.0);
+  // PH versus slice number
+  pad = ((TVirtualPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");
+  TH2F* rangePHslice=new TH2F("rangePHslice", "", 8, -0.5, 7.5, 10, 0.0, (hqtot->GetMean()<10.0 ? 6.0 : 3000.));
+  rangePHslice->SetStats(kFALSE);
+  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);
+  rangePHslice->Draw();
+  
+  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);
+  
+  TH2D* hPH = (TH2D*)phCF->Project(0, phCF->GetVar(fgkVarNames[kTrackletSlice]), phCF->GetVar(fgkVarNames[kTrackletPHslice]));
+  TH1D* hSliceErr = new TH1D(Form("hSliceErr%f", gRandom->Rndm()), "", hPH->GetXaxis()->GetNbins(), hPH->GetXaxis()->GetXbins()->GetArray());
+  TH1D* hLandauFit = Proj2D(hPH, hSliceErr);
+  hPH->SetStats(kFALSE);
+  hPH->Draw("samecolz");
+  const Double_t kQx = 0.002;
+  if(trendValues) {
+    hSliceErr->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);
+    trendValues[12] = kQx*funcPol1->GetParameter(0);  // PH plateau
+    trendValues[13] = kQx*funcPol1->GetParError(0);   // PH plateau
+    trendValues[14] = kQx*funcPol1->GetParameter(1);  // PH slope
+    trendValues[15] = kQx*funcPol1->GetParError(1);   // PH slope
+  }
+  hLandauFit->SetLineWidth(2);
+  hLandauFit->SetLineStyle(2);
+  hLandauFit->Draw("same");
+  
+  delete funcPol1; delete hSliceErr;
+  // Qtot vs P
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  
+  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");
+  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, (hqtot->GetMean()<10.0 ? 11.99 : 5999.));
+  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtotP->SetStats(kFALSE);
+  rangeQtotP->Draw();
+  
+  Int_t pVar = centCF->GetVar(fgkVarNames[kTrackP]);
+  if(pVar<0) pVar = centCF->GetVar(fgkVarNames[kTrackletP]);
+  TH2D* hQtotP = (TH2D*)centCF->Project(0, pVar, centCF->GetVar(fgkVarNames[kTrackletQtot]));
+  TH1D* mpvErr=new TH1D("mpvErr", "Landau MPV error vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());  
+  TH1D* widthErr=new TH1D("widthErr", "Landau width error vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());
+  TH1D* landauChi2=new TH1D("landauChi2", "Landau fit #chi^{2} vs. P", hQtotP->GetXaxis()->GetNbins(), hQtotP->GetXaxis()->GetXbins()->GetArray());  
+  if(hQtotP)
+    for(Int_t i=1; i<=hQtotP->GetXaxis()->GetNbins(); ++i) 
+      hQtotP->SetBinContent(i, 1, 0.0);  
+  TH1D* hQtotProj = (hQtotP ? Proj2D(hQtotP, mpvErr, widthErr, landauChi2) : 0x0);
+  //landauChi2->Scale(0.001);
+  if(hQtotProj) SetStyle(hQtotProj, 2, kBlue, 2, 1, kBlue, 1);
+  if(trendValues && hQtotProj && hQtotProj->GetEntries()>2) {
+    trendValues[16] = kQx*hQtotProj->GetBinContent(hQtotProj->FindBin(1.0));   // Landau MPV at 1GeV/c
+    trendValues[17] = kQx*hQtotProj->GetBinError(hQtotProj->FindBin(1.0));     // Landau width at 1 GeV/c
+  }
+  if(hQtotP) {
+    hQtotP->SetStats(kFALSE);
+    hQtotP->Draw("samecolz");
+    hQtotProj->Draw("same");
+  }
+  
+  // Qtot vs P (fit results)
+  pad = ((TVirtualPad*)l->At(8)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  
+  if(gROOT->FindObject("rangeQtotPfit")) delete gROOT->FindObject("rangeQtotPfit");
+  TH2F* rangeQtotPfit = new TH2F("rangeQtotPfit", "", 100, 0.0, 11.99, 100, 0.0, (hqtot->GetMean()<10.0 ? 6.0 : 3999.));
+  SetStyle(rangeQtotPfit->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtotPfit->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtotPfit->SetStats(kFALSE);
+  rangeQtotPfit->Draw();
+  
+  if(mpvErr) SetStyle(mpvErr, 1, kBlue, 2, 1, kBlue, 1);
+  if(widthErr) SetStyle(widthErr, 2, kRed, 2, 1, kRed, 1);
+  if(mpvErr) {
+    mpvErr->SetStats(kFALSE);
+    mpvErr->Draw("same");
+  }
+  if(widthErr) {
+    widthErr->SetStats(kFALSE);
+    widthErr->Draw("same");
+  }
+  TLegend* leg=new TLegend(0.2,0.6,0.5,0.9);
+  leg->SetFillColor(0);
+  leg->SetBorderSize(0);
+  leg->AddEntry("mpvErr","Landau MPV","l");
+  leg->AddEntry("widthErr","Landau width","l");
+  leg->Draw();
+}
+
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::PlotOtherSummaryFromCF(Double_t* /*trendValues*/) {
+  //
+  //
+  //
+  if(!fHistos) return;
+  AliCFContainer* matchPhiEta = (AliCFContainer*)fHistos->FindObject("MatchingPhiEta");
+  AliCFContainer* trdQuality = (AliCFContainer*)fHistos->FindObject("trdQuality");
+  AliCFContainer* trdChi2 = (AliCFContainer*)fHistos->FindObject("trdChi2");
+  AliCFContainer* trdBudget = (AliCFContainer*)fHistos->FindObject("trdBudget");
+  AliCFContainer* ploss = (AliCFContainer*)fHistos->FindObject("Ploss");
+  AliCFContainer* clusters = (AliCFContainer*)fHistos->FindObject("clustersPerTracklet");  
+  AliCFContainer* clsRows = (AliCFContainer*)fHistos->FindObject("clustersVsRows");
+  AliCFContainer* tpcTofMatch = (AliCFContainer*)fHistos->FindObject("MatchingPhiEta_TPCTOF");
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+  lat->SetNDC();
+  lat->SetTextFont(42);
+  TCanvas* c1 = new TCanvas("ESDsummary", "ESD summary 1", 1600, 1200);
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  TVirtualPad* pad=0x0;
+  
+  // matching as a function of trigger class
+  if(matchPhiEta) {
+    matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);
+    TH1F* hTRDEffTriggerNeg = EfficiencyFromPhiPt(matchPhiEta, -1, -1, 1, 0, kEventTrigger);
+    matchPhiEta->SetRangeUser(matchPhiEta->GetVar(fgkVarNames[kTrackCharge]), +1.0, +1.0);
+    TH1F* hTRDEffTriggerPos = EfficiencyFromPhiPt(matchPhiEta, -1, -1, 1, 0, kEventTrigger);
+      
+    pad = ((TVirtualPad*)l->At(0)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.01);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    hTRDEffTriggerNeg->SetStats(kFALSE);
+    SetStyle(hTRDEffTriggerNeg->GetYaxis(), "efficiency", 0.06, 1.0, kTRUE, 0.06);
+    hTRDEffTriggerNeg->GetXaxis()->SetRange(1,fNAssignedTriggers);
+    hTRDEffTriggerPos->GetXaxis()->SetRange(1,fNAssignedTriggers);
+    SetStyle(hTRDEffTriggerNeg, 1, 2, 2, 20, 2, 1);
+    SetStyle(hTRDEffTriggerPos, 1, 4, 2, 20, 4, 1);
+    hTRDEffTriggerNeg->Draw();
+    hTRDEffTriggerPos->Draw("same");
+    TLegend* legEff=new TLegend(0.5,0.5,0.7,0.7);
+    legEff->SetFillColor(0);
+    legEff->SetBorderSize(0);
+    legEff->AddEntry(hTRDEffTriggerNeg, "negatives", "l");
+    legEff->AddEntry(hTRDEffTriggerPos, "positives", "l");
+    legEff->Draw();
+    lat->DrawLatex(0.2, 0.95, "TPC-TRD matching efficiency");
+  }
+  
+  if(trdQuality) {
+  // Track TRD quality vs (eta,phi) and vs TRD n-clusters
+    TH3D* trdQuality3D = (TH3D*)trdQuality->Project(0, trdQuality->GetVar(fgkVarNames[kTrackEtaTRD]), 
+                                                      trdQuality->GetVar(fgkVarNames[kTrackPhiTRD]),
+                                                      trdQuality->GetVar(fgkVarNames[kTrackTrdQuality]));
+    trdQuality3D->GetZaxis()->SetRangeUser(0.1,100.0);
+    trdQuality3D->SetName("trdQuality3D");
+    TProfile2D* prof2DQuality = trdQuality3D->Project3DProfile("yx");
+    prof2DQuality->SetName("prof2DQuality");
+    trdQuality->SetRangeUser(trdQuality->GetVar(fgkVarNames[kTrackCharge]), -1.5,-0.5);
+    TH2D* trdQualityPneg = (TH2D*)trdQuality->Project(0, trdQuality->GetVar(fgkVarNames[kTrackP]), 
+                                                        trdQuality->GetVar(fgkVarNames[kTrackTrdQuality]));
+    trdQualityPneg->SetName("trdQualityPneg");
+    trdQuality->SetRangeUser(trdQuality->GetVar(fgkVarNames[kTrackCharge]), +0.5,1.5);
+    TH2D* trdQualityPpos = (TH2D*)trdQuality->Project(0, trdQuality->GetVar(fgkVarNames[kTrackP]), 
+                                                        trdQuality->GetVar(fgkVarNames[kTrackTrdQuality]));
+    trdQualityPpos->SetName("trdQualityPpos");
+    trdQualityPneg->GetYaxis()->SetRangeUser(0.1,100.0);
+    TProfile* trdQualityPnegprof = trdQualityPneg->ProfileX();
+    trdQualityPnegprof->SetName("trdQualityPnegprof");
+    trdQualityPpos->GetYaxis()->SetRangeUser(0.1,100.0);
+    TProfile* trdQualityPposprof = trdQualityPpos->ProfileX();
+    trdQualityPposprof->SetName("trdQualityPposprof");
+    pad = ((TVirtualPad*)l->At(3)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    prof2DQuality->SetStats(kFALSE);
+    prof2DQuality->SetTitle("");
+    SetStyle(prof2DQuality->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(prof2DQuality->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+    prof2DQuality->SetMaximum(1.6); prof2DQuality->SetMinimum(0.4);
+    prof2DQuality->Draw("colz");
+    lat->DrawLatex(0.2, 0.95, "TRD quality");
+    pad = ((TVirtualPad*)l->At(6)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.01);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    trdQualityPnegprof->SetStats(kFALSE);
+    trdQualityPnegprof->SetTitle("");
+    SetStyle(trdQualityPnegprof->GetXaxis(), "P (GeV/c)", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(trdQualityPnegprof->GetYaxis(), "<TRD quality>", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(trdQualityPnegprof, 1, 2, 2, 20, 2, 1);
+    SetStyle(trdQualityPposprof, 1, 4, 2, 20, 4, 1);
+    trdQualityPnegprof->GetYaxis()->SetRangeUser(0.5, 1.39);
+    trdQualityPnegprof->Draw();
+    trdQualityPposprof->Draw("same");
+    lat->DrawLatex(0.2, 0.95, "TRD quality");
+  }
+  
+  if(trdChi2) {
+    // Track TRD chi2 vs (eta,phi)
+    TH3D* trdChi23D = (TH3D*)trdChi2->Project(0, trdChi2->GetVar(fgkVarNames[kTrackEtaTRD]), 
+                                              trdChi2->GetVar(fgkVarNames[kTrackPhiTRD]),
+                                              trdChi2->GetVar(fgkVarNames[kTrackTrdChi2]));
+    trdChi23D->SetName("trdChi23D");
+    TProfile2D* prof2DChi2 = trdChi23D->Project3DProfile("yx");
+    prof2DChi2->SetName("prof2DChi2");
+    pad = ((TVirtualPad*)l->At(1)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    prof2DChi2->SetStats(kFALSE);
+    prof2DChi2->SetTitle("");
+    SetStyle(prof2DChi2->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(prof2DChi2->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+    prof2DChi2->SetMaximum(2.9);
+    prof2DChi2->Draw("colz");
+    lat->DrawLatex(0.2, 0.95, "TRD #chi^{2}");
+  
+    // Track TRD chi2 vs pt and charge
+    trdChi2->SetRangeUser(trdChi2->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);
+    TH2D* trdChi2VsPtNeg = (TH2D*)trdChi2->Project(0, trdChi2->GetVar(fgkVarNames[kTrackPt]),
+                                                    trdChi2->GetVar(fgkVarNames[kTrackTrdChi2]));
+    trdChi2VsPtNeg->SetName("trdChi2VsPtNeg");
+    TProfile* trdChi2VsPtNegProf = trdChi2VsPtNeg->ProfileX();
+    trdChi2VsPtNegProf->SetName("trdChi2VsPtNegProf");
+    trdChi2->SetRangeUser(trdChi2->GetVar(fgkVarNames[kTrackCharge]), 1.0, 1.0);
+    TH2D* trdChi2VsPtPos = (TH2D*)trdChi2->Project(0, trdChi2->GetVar(fgkVarNames[kTrackPt]),
+                                                    trdChi2->GetVar(fgkVarNames[kTrackTrdChi2]));
+    trdChi2VsPtPos->SetName("trdChi2VsPtPos");
+    TProfile* trdChi2VsPtPosProf = trdChi2VsPtPos->ProfileX();
+    trdChi2VsPtPosProf->SetName("trdChi2VsPtPosProf");
+    pad = ((TVirtualPad*)l->At(4)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.01);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    trdChi2VsPtNegProf->SetStats(kFALSE);
+    trdChi2VsPtNegProf->SetTitle("");
+    SetStyle(trdChi2VsPtNegProf->GetXaxis(), "p_{T} (GeV/c)", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(trdChi2VsPtNegProf->GetYaxis(), "<TRD #chi^{2}>", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(trdChi2VsPtNegProf, 1, 2, 2, 20, 2, 1);
+    SetStyle(trdChi2VsPtPosProf, 1, 4, 2, 20, 4, 1);
+    trdChi2VsPtNegProf->Draw();
+    trdChi2VsPtPosProf->Draw("same");
+    lat->DrawLatex(0.2, 0.95, "TRD #chi^{2}");
+  }
+  
+  if(trdBudget) {
+    // Track TRD budget vs (eta,phi)
+    TH3D* trdBudget3D = (TH3D*)trdBudget->Project(0, trdBudget->GetVar(fgkVarNames[kTrackEtaTRD]), 
+                                                  trdBudget->GetVar(fgkVarNames[kTrackPhiTRD]),
+                                                  trdBudget->GetVar(fgkVarNames[kTrackTRDBudget]));
+    trdBudget3D->SetName("trdBudget3D");
+    TProfile2D* prof2DBudget = trdBudget3D->Project3DProfile("yx");
+    prof2DBudget->SetName("prof2DBudget");
+    pad = ((TVirtualPad*)l->At(7)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    prof2DBudget->SetStats(kFALSE);
+    prof2DBudget->SetTitle("");
+    SetStyle(prof2DBudget->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(prof2DBudget->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+    prof2DBudget->Draw("colz");
+    lat->DrawLatex(0.2, 0.95, "TRD budget");
+  }
+  
+  if(ploss) {
+    // momentum loss
+    ploss->SetRangeUser(ploss->GetVar(fgkVarNames[kTrackCharge]), -1.0, -1.0);
+    TH2D* plossLayerNeg = (TH2D*)ploss->Project(0, ploss->GetVar(fgkVarNames[kTrackletLayer]), 
+                                                  ploss->GetVar(fgkVarNames[kTrackPlossTRDlayer]));
+    plossLayerNeg->SetName("plossLayerNeg");
+    TProfile* plossLayerNegProf = plossLayerNeg->ProfileX();
+    plossLayerNegProf->SetName("plossLayerNegProf");
+    ploss->SetRangeUser(ploss->GetVar(fgkVarNames[kTrackCharge]), +1.0, +1.0);
+    TH2D* plossLayerPos = (TH2D*)ploss->Project(0, ploss->GetVar(fgkVarNames[kTrackletLayer]), 
+                                                  ploss->GetVar(fgkVarNames[kTrackPlossTRDlayer]));
+    plossLayerPos->SetName("plossLayerPos");
+    TProfile* plossLayerPosProf = plossLayerPos->ProfileX();
+    plossLayerPosProf->SetName("plossLayerPosProf");
+    ploss->SetRangeUser(ploss->GetVar(fgkVarNames[kTrackCharge]), -1.5, +1.5);
+    
+    ploss->SetRangeUser(ploss->GetVar(fgkVarNames[kTrackletLayer]), 0.0, 0.0);
+    TH3D* ploss3Dl0 = (TH3D*)ploss->Project(0, ploss->GetVar(fgkVarNames[kTrackEtaTRD]), 
+                                            ploss->GetVar(fgkVarNames[kTrackPhiTRD]), 
+                                            ploss->GetVar(fgkVarNames[kTrackPlossTRDlayer]));
+    ploss3Dl0->SetName("ploss3Dl0");
+    TProfile2D* plossEtaPhiL0Prof = ploss3Dl0->Project3DProfile("yx");
+    plossEtaPhiL0Prof->SetName("plossEtaPhiL0Prof");
+    ploss->SetRangeUser(ploss->GetVar(fgkVarNames[kTrackletLayer]), 5.0, 5.0);
+    TH3D* ploss3Dl5 = (TH3D*)ploss->Project(0, ploss->GetVar(fgkVarNames[kTrackEtaTRD]), 
+                                            ploss->GetVar(fgkVarNames[kTrackPhiTRD]), 
+                                            ploss->GetVar(fgkVarNames[kTrackPlossTRDlayer]));
+    ploss3Dl5->SetName("ploss3Dl5");
+    TProfile2D* plossEtaPhiL5Prof = ploss3Dl5->Project3DProfile("yx");
+    plossEtaPhiL5Prof->SetName("plossEtaPhiL5Prof");
+    pad = ((TVirtualPad*)l->At(2)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    plossEtaPhiL0Prof->SetStats(kFALSE);
+    plossEtaPhiL0Prof->SetTitle("");
+    SetStyle(plossEtaPhiL0Prof->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(plossEtaPhiL0Prof->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+    plossEtaPhiL0Prof->SetMaximum(0.08);
+    plossEtaPhiL0Prof->SetMinimum(-0.02);
+    plossEtaPhiL0Prof->Draw("colz");
+    lat->DrawLatex(0.2, 0.95, "P_{loss} at layer 0");
+    pad = ((TVirtualPad*)l->At(5)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    plossEtaPhiL5Prof->SetStats(kFALSE);
+    plossEtaPhiL5Prof->SetTitle("");
+    SetStyle(plossEtaPhiL5Prof->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(plossEtaPhiL5Prof->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+    plossEtaPhiL5Prof->SetMaximum(0.08);
+    plossEtaPhiL5Prof->SetMinimum(-0.02);
+    plossEtaPhiL5Prof->Draw("colz");
+    lat->DrawLatex(0.2, 0.95, "P_{loss} at layer 5");
+    pad = ((TVirtualPad*)l->At(8)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.01);
+    pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+    plossLayerNegProf->SetStats(kFALSE);
+    plossLayerNegProf->SetTitle("");
+    SetStyle(plossLayerNegProf->GetYaxis(), "#Delta P (GeV/c)", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(plossLayerNegProf->GetXaxis(), "TRD layer", 0.06, 1.0, kTRUE, 0.06);
+    SetStyle(plossLayerNegProf, 1, 2, 2, 20, 2, 1);
+    SetStyle(plossLayerPosProf, 1, 4, 2, 20, 4, 1);
+    plossLayerNegProf->GetYaxis()->SetRangeUser(TMath::Min(plossLayerNegProf->GetMinimum(),plossLayerPosProf->GetMinimum()-0.01),
+                                                TMath::Max(plossLayerNegProf->GetMaximum(),plossLayerPosProf->GetMaximum())+0.01);
+    plossLayerNegProf->Draw();  
+    plossLayerPosProf->Draw("same");
+    lat->DrawLatex(0.2, 0.95, "P_{loss} vs layer");
+  }
+  
+  // clusters/tracklet and clusters/crossed rows
+  TH3D* clustersEtaPhi[6]={0x0};
+  TH3D* clsRowsEtaPhi[6]={0x0};
+  for(Int_t il=0;il<6;++il) {
+    if(clusters) {
+      clusters->SetRangeUser(clusters->GetVar(fgkVarNames[kTrackletLayer]), Double_t(il), Double_t(il));
+      clustersEtaPhi[il]=(TH3D*)clusters->Project(0, clusters->GetVar(fgkVarNames[kTrackEtaTRD]),
+                                                   clusters->GetVar(fgkVarNames[kTrackPhiTRD]),
+                                                   clusters->GetVar(fgkVarNames[kTrackletClusters]));
+      clustersEtaPhi[il]->SetName(Form("clustersEtaPhi%d",il));
+    }
+    if(clsRows) {
+      clsRows->SetRangeUser(clsRows->GetVar(fgkVarNames[kTrackletLayer]), Double_t(il), Double_t(il));
+      clsRowsEtaPhi[il]=(TH3D*)clsRows->Project(0, clsRows->GetVar(fgkVarNames[kTrackEtaTRD]),
+                                                 clsRows->GetVar(fgkVarNames[kTrackPhiTRD]),
+                                                 clsRows->GetVar(fgkVarNames[kTrackletClustersVsRows]));
+      clsRowsEtaPhi[il]->SetName(Form("clsRowsEtaPhi%d",il));
+    }
+  }
+    
+  lat->SetTextSize(0.05);
+  Int_t layerPads[6] = {0, 2, 4, 1, 3, 5};
+  
+  TCanvas* c2=0x0;
+  if(clusters) {
+    c2 = new TCanvas("ESDsummary2", "ESD summary 2", 1600, 1200);
+    gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+    gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+    gPad->Divide(3,2,0.,0.);
+    l=gPad->GetListOfPrimitives();
+    for(Int_t il=0;il<6;++il) {
+      TProfile2D* clustersEtaPhiProf = clustersEtaPhi[il]->Project3DProfile("yx");
+      pad = ((TVirtualPad*)l->At(layerPads[il])); pad->cd();
+      pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+      pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+      clustersEtaPhiProf->SetStats(kFALSE);
+      clustersEtaPhiProf->SetTitle("");
+      SetStyle(clustersEtaPhiProf->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+      SetStyle(clustersEtaPhiProf->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+      clustersEtaPhiProf->Draw("colz");
+      lat->DrawLatex(0.2, 0.95, Form("Clusters / tracklet, layer %d", il));
+    }
+  }
+  
+  TCanvas* c3=0x0;
+  if(clsRows) {
+    c3 = new TCanvas("ESDsummary3", "ESD summary 3", 1600, 1200);
+    gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+    gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+    gPad->Divide(3,2,0.,0.);
+    l=gPad->GetListOfPrimitives();
+    for(Int_t il=0;il<6;++il) {
+      TProfile2D* clsRowsEtaPhiProf = clsRowsEtaPhi[il]->Project3DProfile("yx");
+      pad = ((TVirtualPad*)l->At(layerPads[il])); pad->cd();
+      pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+      pad->SetTopMargin(0.06); pad->SetBottomMargin(0.15);
+      clsRowsEtaPhiProf->SetStats(kFALSE);
+      clsRowsEtaPhiProf->SetTitle("");
+      SetStyle(clsRowsEtaPhiProf->GetXaxis(), "#eta", 0.06, 1.0, kTRUE, 0.06);
+      SetStyle(clsRowsEtaPhiProf->GetYaxis(), "#varphi (rad.)", 0.06, 1.0, kTRUE, 0.06);
+      clsRowsEtaPhiProf->Draw("colz");
+      lat->DrawLatex(0.2, 0.95, Form("Clusters / crossed rows, layer %d", il));
+    }
+  }
+  
+  TCanvas* c4=0x0;
+  if(tpcTofMatch) {
+    TH2D* tpcRef = (TH2D*)tpcTofMatch->Project(0, tpcTofMatch->GetVar(fgkVarNames[kTrackEtaTRD]),
+                                                  tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    TH2D* tpcPhiPt = (TH2D*)tpcTofMatch->Project(0, tpcTofMatch->GetVar(fgkVarNames[kTrackPt]),
+                                                    tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    TH2D* tofin  = (TH2D*)tpcTofMatch->Project(1, tpcTofMatch->GetVar(fgkVarNames[kTrackEtaTRD]),
+                                                  tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    TH2D* tofinPhiPt = (TH2D*)tpcTofMatch->Project(1, tpcTofMatch->GetVar(fgkVarNames[kTrackPt]),
+                                                      tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    TH2D* tofout = (TH2D*)tpcTofMatch->Project(2, tpcTofMatch->GetVar(fgkVarNames[kTrackEtaTRD]),
+                                                  tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    TH2D* tofoutPhiPt = (TH2D*)tpcTofMatch->Project(2, tpcTofMatch->GetVar(fgkVarNames[kTrackPt]),
+                                                       tpcTofMatch->GetVar(fgkVarNames[kTrackPhiTRD]));
+    tofin->Divide(tpcRef);
+    tofout->Divide(tpcRef);
+    tofinPhiPt->Divide(tpcPhiPt);
+    tofoutPhiPt->Divide(tpcPhiPt);
+    
+    c4=new TCanvas("ESDsummary4", "TPC - TOF matching", 1600., 1200.);
+    c4->SetLeftMargin(0.01); c4->SetRightMargin(0.01);
+    c4->SetTopMargin(0.01); c4->SetBottomMargin(0.01);
+    c4->Divide(2,2,0.,0.);
+    pad=c4->cd(1);
+    pad->SetLeftMargin(0.12); pad->SetRightMargin(0.12);
+    pad->SetTopMargin(0.07); pad->SetBottomMargin(0.12);
+    tofin->SetTitle(""); tofin->SetStats(kFALSE);
+    tofin->Draw("colz");
+    lat->DrawLatex(0.1, 0.94, "TPC - TOFin matching");
+    pad=c4->cd(2);
+    pad->SetLeftMargin(0.12); pad->SetRightMargin(0.12);
+    pad->SetTopMargin(0.07); pad->SetBottomMargin(0.12);
+    tofout->SetTitle(""); tofout->SetStats(kFALSE);
+    tofout->Draw("colz");
+    lat->DrawLatex(0.1, 0.94, "TPC - TOFout matching");
+    pad=c4->cd(3);
+    pad->SetLeftMargin(0.12); pad->SetRightMargin(0.12);
+    pad->SetTopMargin(0.07); pad->SetBottomMargin(0.12);
+    tofinPhiPt->SetTitle(""); tofinPhiPt->SetStats(kFALSE);
+    tofinPhiPt->Draw("colz");
+    lat->DrawLatex(0.1, 0.94, "TPC - TOFin matching");
+    pad=c4->cd(4);
+    pad->SetLeftMargin(0.12); pad->SetRightMargin(0.12);
+    pad->SetTopMargin(0.07); pad->SetBottomMargin(0.12);
+    tofoutPhiPt->SetTitle(""); tofoutPhiPt->SetStats(kFALSE);
+    tofoutPhiPt->Draw("colz");
+    lat->DrawLatex(0.1, 0.94, "TPC - TOFout matching");
+  }
+
+  if(matchPhiEta || trdQuality || trdChi2 || trdBudget || ploss) c1->SaveAs("esdSummary1.gif");
+  if(clusters) c2->SaveAs("esdSummary2.gif");
+  if(clsRows) c3->SaveAs("esdSummary3.gif");
+  if(tpcTofMatch) c4->SaveAs("esdSummary4.gif");
+}
+
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::DrawTRDGrid() {
+  //
+  //   Draw a grid of lines showing the TRD supermodule and stack structure in (eta,phi) coordinates.
+  //   The canvas on which to draw must already exist.
+  //
+  TLine line;
+  line.SetLineColor(2);
+  line.SetLineWidth(1);
+  line.SetLineStyle(2);
+  for(Int_t i=-9; i<=9; ++i) {
+    line.DrawLine(-1.0, 2.0*TMath::Pi()/18.0*i, +1.0, 2.0*TMath::Pi()/18.0*i);
+  }
+  line.DrawLine(-0.85, -3.15, -0.85, 3.15);
+  line.DrawLine(-0.54, -3.15, -0.54, 3.15);
+  line.DrawLine(-0.16, -3.15, -0.16, 3.15);
+  line.DrawLine(+0.16, -3.15, +0.16, 3.15);
+  line.DrawLine(+0.54, -3.15, +0.54, 3.15);
+  line.DrawLine(+0.85, -3.15, +0.85, 3.15);
+}
+
+//_________________________________________________________________
+void AliTRDcheckESD::SetStyle(TH1* hist, 
+                             Int_t lineStyle, Int_t lineColor, Int_t lineWidth, 
+                             Int_t markerStyle, Int_t markerColor, Int_t markerSize) {
+  //
+  // Set style settings for histograms
+  //
+  if(!hist) return;
+  hist->SetLineStyle(lineStyle);
+  hist->SetLineColor(lineColor);
+  hist->SetLineWidth(lineWidth);
+  hist->SetMarkerStyle(markerStyle);
+  hist->SetMarkerColor(markerColor);
+  hist->SetMarkerSize(markerSize);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, 
+                              Float_t labelSize) {
+  //
+  // Set style settings for axes
+  //
+  if(!axis) return;
+  axis->SetTitle(title);
+  axis->SetTitleSize(titleSize);
+  axis->SetTitleOffset(titleOffset); 
+  axis->CenterTitle(centerTitle);
+  axis->SetLabelSize(labelSize);
+  axis->SetTitleFont(42);
+  axis->SetLabelFont(42);
+  axis->SetNdivisions(507);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]) {
+  //
+  // Find the isolated bunch crossings
+  //
+  Int_t isolationSize = 5;      // number of free bunches in both directions
+  for(Int_t bcBin=1; bcBin<=bcHist->GetXaxis()->GetNbins(); ++bcBin) {
+    Int_t bc = TMath::Nint(bcHist->GetBinCenter(bcBin));
+    if(bc<-0.001 || bc>3499.01) {
+      isIsolated[bc] = kFALSE;
+      continue;
+    }
+    Double_t entries = bcHist->GetBinContent(bcBin);
+    if(entries<0.001) {
+      isIsolated[bc] = kFALSE;
+      continue;     // no entries
+    }
+        
+    // check isolation
+    isIsolated[bc] = kTRUE;
+    for(Int_t ibc = TMath::Max(1,bcBin-isolationSize); ibc<=TMath::Min(3499, bcBin+isolationSize); ++ibc) {
+      if(ibc==bcBin) continue;
+      if(bcHist->GetBinContent(ibc)>0.01) {
+        isIsolated[bc] = kFALSE;
+        break;
+      }
+    }
+  }   // end loop over BC bins
+  
+  cout << "Isolated bunches: " << endl;
+  for(Int_t ibc=0; ibc<3500; ++ibc) 
+    if(isIsolated[ibc]) cout << "BC #" << ibc << endl; 
+}
+
+
+//__________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetTriggerIndex(const Char_t* name, Bool_t createNew/*=kTRUE*/) {
+  //
+  //  Return the index of trigger "name" in the trigger histogram.
+  //  If the index for this trigger does not exist yet, then assign one if createNew is set to TRUE 
+  //
+  //cout << "GetTriggerIndex for " << name << endl;
+  TH1F* triggerHist = (TH1F*)fHistos->FindObject("hTriggerDefs");
+  TString nameStr=name;
+  for(Int_t i=1; i<=triggerHist->GetXaxis()->GetNbins(); ++i) {
+    if(!nameStr.CompareTo(triggerHist->GetXaxis()->GetBinLabel(i))) {
+      //cout << "       index found: " << i << endl;
+      return i;
+    }
+  }
+  if(createNew) {
+    triggerHist->GetXaxis()->SetBinLabel(fNAssignedTriggers+1, name);
+    for(Int_t i=1;i<fHistos->GetEntries();++i) {
+      TString objType = fHistos->At(i)->IsA()->GetName();
+      if(!objType.Contains("AliCFContainer")) continue;
+      AliCFContainer* cf=(AliCFContainer*)fHistos->At(i);
+      Int_t trigVar = cf->GetVar(fgkVarNames[kEventTrigger]);
+      if(trigVar>=0)
+       for(Int_t istep=0;istep<cf->GetNStep();++istep) 
+         cf->GetAxis(trigVar, istep)->SetBinLabel(fNAssignedTriggers+1, name);
+    }  // end loop over histograms and CFs
+        
+    ++fNAssignedTriggers;
+    return fNAssignedTriggers+1;
+  }
+  else {
+    return -1;
+  }
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::PrintTriggers() const {
+  //
+  //  Print the available triggers for this run
+  //
+  if(!fHistos) {
+    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;
+    return;
+  }
+  TH1F* hTriggers = (TH1F*)fHistos->FindObject("hTriggerDefs");
+  cout << "Triggers found in this run" << endl;
+  cout << "==========================" << endl;
+  cout << "Name   Index   Entries    " << endl;
+  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {
+    if(hTriggers->GetXaxis()->GetBinLabel(it)[0]!='\0') {
+      cout << hTriggers->GetXaxis()->GetBinLabel(it) << "  " << hTriggers->GetXaxis()->GetBinCenter(it) << "  " << hTriggers->GetBinContent(it) << endl;
+    }
+  }
+}
+
+
+//__________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetTriggerCounter(const Char_t* triggerName) const {
+  //
+  // Get the number of events for a given trigger name
+  //
+  if(!fHistos) {
+    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;
+    return -1;
+  }
+  TH1F* hTriggers = (TH1F*)fHistos->FindObject("hTriggerDefs");
+  Int_t counter = -1;
+  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {
+    TString trgString = hTriggers->GetXaxis()->GetBinLabel(it);
+    if(!trgString.CompareTo(triggerName)) 
+      counter = (Int_t)hTriggers->GetBinContent(it);
+  }
+  if(counter<0) {cout << "AliTRDcheckESD::GetTriggerCounter()  Trigger not found !!";}
+  return counter;
+}
+
+
+//__________________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetNAssignedTriggers() {
+  //
+  // Return the number of assigned triggers
+  //
+  return fNAssignedTriggers;
+}
index 7e1188e7c06fa2301f516353cfb529bddccde382..a84c021929e1825638d8d511b0cb00d1d153b7e1 100644 (file)
-#ifndef ALITRDCHECKESD_H\r
-#define ALITRDCHECKESD_H\r
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * See cxx source for full Copyright notice                               */\r
-\r
-/* $Id: AliTRDcheckESD.h 27496 2008-07-22 08:35:45Z cblume $ */\r
-\r
-/////////////////////////////////////////////////////\r
-//\r
-// Check basic detector results at ESD level\r
-//\r
-// Author\r
-//   Alex Bercuci <A.Bercuci@gsi.de>\r
-//\r
-//////////////////////////////////////////////////////\r
-\r
-#ifndef ALIANALYSISTASK_H\r
-#include "AliAnalysisTaskSE.h"\r
-#endif\r
-\r
-class AliESDEvent;\r
-class AliMCEvent;\r
-class AliESDpid;\r
-class AliCFContainer;\r
-class AliAnalysisCuts;\r
-class TH1;\r
-class TH2;\r
-class TH1F;\r
-class TH1D;\r
-class TH2F;\r
-class TH3F;\r
-class TH3;\r
-class TObjArray;\r
-class TGraph;\r
-class TGraphErrors;\r
-class TAxis;\r
-\r
-class AliTRDcheckESD : public AliAnalysisTaskSE {\r
-public:\r
-  enum ETRDcheckESDstatus {\r
-     kMC        = BIT(0)  // use MC info\r
-    ,kCollision = BIT(1)  // \r
-  };\r
-  enum ETRDcheckESDhistos {\r
-    kNCl = 1                // number of clusters per track\r
-   ,kTRDstat                // TRD tracks status\r
-   ,kTRDmom                 // TRD track momentum\r
-   ,kPtRes                  // Pt resolution @ vertex for TRD\r
-   ,kTPCVertex              // event vertex from TPC\r
-   ,kEventVertex            // event vertex\r
-   ,kNTracksAll             // ntracks - all\r
-   ,kNTracksAcc             // ntracks - inside acc. and DCA cut\r
-   ,kNTracksTPC             // additional cut on number of TPC clusters\r
-   ,kDCAxy                  // transverse DCA \r
-   ,kDCAz                   // z - DCA\r
-   ,kPt1                    // Pt distribution, eta and ptmin cuts\r
-   ,kPt2                    // Pt distribution, cuts from kPt1 and DCA cuts\r
-   ,kPt3pos                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for positives (>100)\r
-   ,kPt3neg                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for negatives (>100)\r
-   ,kPt4pos                 // Pt distribution, cuts from kPt3pos and at least one TRD tracklet\r
-   ,kPt4neg                 // Pt distribution, cuts from kPt3neg and at least one TRD tracklet\r
-   ,kTheta                  // distribution of theta for tracks passing the cuts from kPt4pos and kPt4neg\r
-   ,kPhi                    // distribution of phi for tracks passing the cuts from kPt4pos and kPt4neg\r
-   ,kNTPCCl                 // number of TPC clusters, cuts from kPt2\r
-   ,kNTPCCl2                // number of TPC clusters, cuts from kPt2 + pt>1 GeV/c\r
-   ,kTPCDedx                // TPC dE/dx, cuts from kPt3pos or kPt3neg\r
-   ,kEtaPhi                 // (eta,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kEtaNclsTPC             // (TPC_Ncls,eta) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kPhiNclsTPC             // (TPC_Ncls,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kSPDMult                // SPD multiplicity\r
-   ,kNTrackletsTRD          // (TRD tracklets per track, P) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kNClsTrackTRD=kNTrackletsTRD+6    // (TRD clusters per track, P) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPHSlice=kNClsTrackTRD+6         // (slicePH,sliceNo) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPHSliceTPCpions=kPHSlice+6      // (slicePH,sliceNo) distribution for TPC pions, after cuts from kPt4pos or kPt4neg \r
-   ,kTPCdedxPions=kPHSliceTPCpions+6     // (TPC dedx,P) for selected TPC pions\r
-   ,kPHSliceTPCelectrons=kTPCdedxPions+6    // (slicePH,sliceNo) distribution for TPC electrons, after cuts from kPt4pos or kPt4neg\r
-   ,kTPCdedxElectrons=kPHSliceTPCelectrons+6   // (TPC dedx,P) for selected TPC electrons\r
-   ,kQtotP=kTPCdedxElectrons+6              // (total Q from slices, momentum) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPropagXYvsP=kQtotP+6       // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-   ,kPropagRZvsP            // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-   ,kTPCRefTracksPos        // (eta,detector phi,Pt) distribution of reference TPC positive tracks (fulfill cuts from kPt3pos)\r
-   ,kTPCRefTracksNeg=kTPCRefTracksPos+6    // (eta,detector phi,Pt) distribution of reference TPC negative tracks (fulfill cuts from kPt3neg)\r
-   ,kTRDRefTracksPos=kTPCRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks (fulfill cuts from kPt4pos)\r
-   ,kTRDRefTracksNeg=kTRDRefTracksPos+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks (fulfill cuts from kPt4neg)\r
-   ,kTRDRefTracksPos4=kTRDRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks with 4 tracklets (fulfill cuts from kPt4pos)\r
-   ,kTRDRefTracksNeg4=kTRDRefTracksPos4+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks with 4 tracklets (fulfill cuts from kPt4neg)\r
-   ,kTRDRefTracksPos5=kTRDRefTracksNeg4+6\r
-   ,kTRDRefTracksNeg5=kTRDRefTracksPos5+6\r
-   ,kTRDRefTracksPos6=kTRDRefTracksNeg5+6\r
-   ,kTRDRefTracksNeg6=kTRDRefTracksPos6+6\r
-   ,kTRDEtaPhiAvNtrkl=kTRDRefTracksNeg6+6       // (eta, detector phi) profile of average number of tracklets\r
-   ,kTRDEtaDeltaPhiAvNtrkl=kTRDEtaPhiAvNtrkl+6  // (eta, delta-phi) profile of average number of tracklets\r
-                                         // delta-phi is the angle made by the track with the normal to the chamber entrance plane\r
-   ,kTRDEtaPhiAvQtot=kTRDEtaDeltaPhiAvNtrkl+6      // (eta, detector phi) profile of total tracklet charge from slices                     \r
-   ,kTriggerDefs=kTRDEtaPhiAvQtot+36\r
-   ,kMatchingPhiEtaCF\r
-   ,kMatchingPtCF\r
-   ,kBunchCrossingsCF\r
-   ,kCentralityCF\r
-   ,kQtotCF\r
-   ,kPulseHeightCF\r
-   ,kExpertCF\r
-   ,kNhistos      // number of histograms\r
-   ,kNrefs   = 4  // number of reference plots\r
-  };\r
-  enum ETrdCfVariables {\r
-    kEventVtxZ=0,\r
-    kEventMult,\r
-    kEventTrigger,\r
-    kEventBC,\r
-    kTrackTOFBC,\r
-    kTrackDCAxy,\r
-    kTrackDCAz,\r
-    kTrackCharge,\r
-    kTrackPhi,\r
-    kTrackEta,\r
-    kTrackPt,\r
-    kTrackP,\r
-    kTrackTrdTracklets,\r
-    kTrackTrdClusters,\r
-    kTrackPHslice,\r
-    kTrackQtot=kTrackPHslice+8,\r
-    kNTrdCfVariables=kTrackQtot+6,\r
-    kNMaxAssignedTriggers = 100\r
-  };\r
-  enum ETRDcheckESDbits {\r
-    kTPCout = 1 // track left TPC\r
-   ,kTRDin      // track reach TRD fiducial volume\r
-   ,kTRDout     // track reconstructed in TRD\r
-   ,kTRDpid     // PID calculated in TRD\r
-   ,kTRDref     // track refitted in TRD\r
-  };\r
-  \r
-  AliTRDcheckESD();\r
-  AliTRDcheckESD(char* name);\r
-  virtual ~AliTRDcheckESD();\r
-  \r
-  void          UserCreateOutputObjects();\r
-  Bool_t        GetRefFigure(Int_t ifig);\r
-  Int_t         GetNRefFigures() const  { return fNRefFigures; } \r
-  void          UserExec(Option_t *);\r
-\r
-  void          SetRefTrackFilter(AliAnalysisCuts* const filter) {fReferenceTrackFilter = filter;}\r
-  \r
-  Bool_t        HasMC() const { return TESTBIT(fStatus, kMC);}\r
-  Bool_t        IsCollision() const {return TESTBIT(fStatus, kCollision);}\r
-  void          SetCollision(Bool_t set=kTRUE) {set ? SETBIT(fStatus, kCollision) : CLRBIT(fStatus, kCollision);}\r
-  TObjArray*    Histos();\r
-  AliCFContainer* GetMatchingPhiEtaCF() const {return fMatchingPhiEtaCF;}\r
-  AliCFContainer* GetMatchingPtCF() const {return fMatchingPtCF;}\r
-  AliCFContainer* GetBunchCrossingsCF() const {return fBunchCrossingsCF;}\r
-  AliCFContainer* GetCentralityCF() const {return fCentralityCF;}\r
-  AliCFContainer* GetQtotCF() const {return fQtotCF;}\r
-  AliCFContainer* GetPulseHeightCF() const {return fPulseHeightCF;}\r
-  AliCFContainer* GetExpertCF() const {return fExpertCF;}\r
-  Int_t         GetTriggerCounter(const Char_t* triggerName) const;\r
-  void          PrintTriggers() const;\r
-  Bool_t        Load(const Char_t *fn="AnalysisResults.root", const Char_t *dir="TRD_Performance", const Char_t *name=NULL);\r
-  void          SetMC(Bool_t mc = kTRUE) { mc ? SETBIT(fStatus, kMC) : CLRBIT(fStatus, kMC);}\r
-  Bool_t        PutTrendValue(const Char_t *name, Double_t val);\r
-  void          Terminate(Option_t *);\r
-  void          MakeSummary(Double_t* trendValues=0x0);\r
-  void          MakeSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="", Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);\r
-  //virtual Long64_t Merge(TCollection* list);\r
-  Int_t         GetNAssignedTriggers();\r
-  void          AddUserTrigger(const Char_t* name) {fUserEnabledTriggers += name; fUserEnabledTriggers += ";";}\r
-  \r
-  // configure the expert CF container\r
-  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, Int_t nbins, Double_t lowLim, Double_t highLim);\r
-  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, const Char_t* bins);\r
-  void          EnableExpertCFStep(Int_t step) {if(step>=0 && step<3) fExpertCFEnabledSteps[step] = kTRUE;}\r
-  \r
-private:\r
-  static const Float_t fgkxTPC; // end radial position of TPC\r
-  static const Float_t fgkxTOF; // start radial position of TOF\r
-  static const UChar_t fgkNgraph[kNrefs]; // number of graphs/ref plot\r
-\r
-  Bool_t PlotTrackingSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);     // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  Bool_t PlotPidSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);          // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  Bool_t PlotCentSummary(Double_t* trendValues=0x0);                                  // centrality dependent plots\r
-\r
-  void PlotTrackingSummaryFromCF(Double_t* trendValues=0x0,\r
-                                const Char_t* triggerName="",\r
-                                 Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);   // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  void PlotPidSummaryFromCF(Double_t* trendValues=0x0,\r
-                           const Char_t* triggerName="",\r
-                            Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);        // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  void PlotCentSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="",\r
-                             Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);       // centrality dependent plots\r
-  \r
-  AliTRDcheckESD(const AliTRDcheckESD&);\r
-  AliTRDcheckESD& operator=(const AliTRDcheckESD&);\r
-  Int_t         Pdg2Idx(Int_t pdg) const;\r
-  void          Process(TH1 **h, TGraphErrors *g);\r
-  void          Process2D(TH2 * const h, TGraphErrors **g);\r
-  void          PrintStatus(ULong_t s);\r
-  TH2F*         Proj3D(TH3* hist, TH2* accMap, Int_t binLow, Int_t binHigh, Float_t &entries);\r
-  TH1D*         Proj2D(TH2* hist, TH1* mpvErr=0x0, TH1* widthErr=0x0, TH1* chi2=0x0);\r
-  TH1F*         EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance=kTRUE);\r
-  TH1F*         EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, Int_t stepNom, Int_t stepDenom, const Char_t* varStr="pt", const Char_t* type="TPCTRD");\r
-  void          DrawTRDGrid();\r
-  void          SetStyle(TH1* hist, Int_t lineStyle, Int_t lineColor, Int_t lineWidth, \r
-                         Int_t markerStyle, Int_t markerColor, Int_t markerSize);\r
-  void          SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, \r
-                         Float_t labelSize);\r
-  void          CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]);\r
-  void          FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]);\r
-  void          InitializeCFContainers();\r
-  AliCFContainer* CreateCFContainer(const Char_t* name, const Char_t *title);\r
-  Int_t         GetTriggerIndex(const Char_t* name, Bool_t createNew=kTRUE);\r
-  \r
-  Int_t            fStatus;            // bit mask for controlling the task\r
-  Int_t            fNRefFigures;       // number of current ref plots\r
-  AliESDEvent      *fESD;              //! ESD event\r
-  AliMCEvent       *fMC;               //! MC event\r
-  AliESDpid        *fESDpid;           //  ESD pid object \r
-  TObjArray        *fHistos;           //! QA histos\r
-  TObjArray        *fResults;          // QA graphs\r
-  static FILE      *fgFile;            //! trend file streamer\r
-  \r
-  AliCFContainer*  fExpertCF;          // CF container configured for expert checks\r
-  Int_t            fExpertCFVars[kNTrdCfVariables];\r
-  Bool_t           fExpertCFVarsEnabled[kNTrdCfVariables];\r
-  Int_t            fExpertCFVarNBins[kNTrdCfVariables];\r
-  Double_t         fExpertCFVarRanges[kNTrdCfVariables][2];\r
-  TString          fExpertCFVarBins[kNTrdCfVariables];\r
-  Bool_t           fExpertCFEnabledSteps[3];      // enabled steps 0-TPC; 1-TRD; 2-TOF\r
-  \r
-  AliCFContainer*  fMatchingPhiEtaCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fMatchingPhiEtaCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fMatchingPtCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fMatchingPtCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fBunchCrossingsCF;  //\r
-  Int_t            fBunchCrossingsCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fCentralityCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fCentralityCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fQtotCF;         //\r
-  Int_t            fQtotCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fPulseHeightCF;     //\r
-  Int_t            fPulseHeightCFVars[kNTrdCfVariables];\r
-  \r
-  AliAnalysisCuts* fReferenceTrackFilter;     // reference track filter\r
-  Bool_t           fPhysSelTriggersEnabled;   // flag wheter physics selection triggers were enabled\r
-  TString          fUserEnabledTriggers;      // list of user enabled triggers\r
-  Int_t            fNAssignedTriggers;        // number of assigned triggers\r
-    \r
-  // Vertex selection\r
-  static const Float_t fgkEvVertexZ;// cm\r
-  static const Int_t   fgkEvVertexN;// cm\r
-  // Track selection\r
-  static const Float_t fgkTrkDCAxy; // cm\r
-  static const Float_t fgkTrkDCAz;  // cm\r
-  static const Int_t   fgkNclTPC;   // N clusters TPC\r
-  static const Float_t fgkPt;       // min. pt\r
-  static const Float_t fgkEta;      // eta range\r
-  \r
-  static const Float_t fgkQs;      // scale for the total charge\r
-\r
-  ClassDef(AliTRDcheckESD, 9)          // user oriented TRD analysis based on ESD-MC data\r
-};\r
-#endif\r
+#ifndef ALITRDCHECKESD_H
+#define ALITRDCHECKESD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTRDcheckESD.h 27496 2008-07-22 08:35:45Z cblume $ */
+
+/////////////////////////////////////////////////////
+//
+// Check basic detector results at ESD level
+//
+// Author
+//   Alex Bercuci <A.Bercuci@gsi.de>
+//   Ionut Arsene <iarsene@cern.ch>
+//
+//////////////////////////////////////////////////////
+
+#ifndef ALIANALYSISTASK_H
+#include "AliAnalysisTaskSE.h"
+#endif
+
+class AliESDEvent;
+class AliMCEvent;
+class AliESDpid;
+class AliCFContainer;
+class AliAnalysisCuts;
+class TH1;
+class TH2;
+class TH1F;
+class TH1D;
+class TH2F;
+class TH3F;
+class TH3;
+class TObjArray;
+class TGraph;
+class TGraphErrors;
+class TAxis;
+
+class AliTRDcheckESD : public AliAnalysisTaskSE {
+public:
+  enum ETRDcheckESDstatus {
+     kMC        = BIT(0)  // use MC info
+    ,kCollision = BIT(1)  // 
+  };
+    
+  enum ETrdCfVariables {
+    kEventVtxZ=0,                // event vtx. Z        ---
+    kEventMult,                  // event multiplicity  ---
+    kEventTrigger,               // trigger class
+    kEventBC,                    // event BC        --- 
+    kTrackTOFBC,                 // track TOF BC    ---
+    kTrackDCAxy,                 // dca xy          ---
+    kTrackDCAz,                  // dca z           ---
+    kTrackCharge,                // charge          ---
+    kTrackOuterParamRadius,      // outer param radius
+    kTrackPhi,                   // phi at the vertex  ---
+    kTrackPhiTRD,                // phi at the entrance of TRD  ---
+    kTrackEta,                   // eta at the vertex  ---
+    kTrackEtaTRD,                // eta at the entrance of TRD  ---
+    kTrackPt,                    // pt at the vertex     ---
+    kTrackPtTRD,                 // pt at the entrance of TRD ---
+    kTrackP,                     // p at the vertex      ---
+    kTrackPTRD,                  // p at the entrance of TRD  ---
+    kTrackTrdChi2,               // TRD track chi2 ---
+    kTrackTrdTracklets,          // number of TRD tracklets  ---
+    kTrackTrdClusters,           // number of TRD clusters   ---
+    kTrackTrdQuality,            // TRD quality for TOF
+    kTrackTRDBudget,             // TRD material budget
+    kTrackletQtot,               // tracklet qtot in each layer
+    kTrackletClustersVsRows,     // clusters / crossed rows
+    kTrackletClusters,           // number of clusters per tracklet
+    kTrackletP,                  // tracklet p in each layer
+    kTrackPlossTRDlayer,         // p loss at each layer
+    kTrackletLayer,              // layer of the current tracklet
+    kTrackletSlice,              // tracklet slice number
+    kTrackletPHslice,            // charge per tracklet slice
+    kNTrdCfVariables,
+    kNMaxAssignedTriggers = 200
+  };
+  
+  enum ETrdCfSteps {
+    kTPCreference=0,
+    kTRD,
+    kTOF,
+    kTOFin,
+    kTOFout,
+    kNSteps
+  };
+     
+  AliTRDcheckESD();
+  AliTRDcheckESD(char* name);
+  virtual ~AliTRDcheckESD();
+  
+  void          UserCreateOutputObjects();
+  void          UserExec(Option_t *);
+
+  void          SetRefTrackFilter(AliAnalysisCuts* const filter) {fReferenceTrackFilter = filter;}
+  
+  Bool_t        HasMC() const { return TESTBIT(fStatus, kMC);}
+  Bool_t        IsCollision() const {return TESTBIT(fStatus, kCollision);}
+  void          SetCollision(Bool_t set=kTRUE) {set ? SETBIT(fStatus, kCollision) : CLRBIT(fStatus, kCollision);}
+  TObjArray*    Histos();
+  Int_t         GetTriggerCounter(const Char_t* triggerName) const;
+  void          PrintTriggers() const;
+  Bool_t        Load(const Char_t *fn="AnalysisResults.root", const Char_t *dir="TRD_Performance", const Char_t *name=NULL);
+  void          SetMC(Bool_t mc = kTRUE) { mc ? SETBIT(fStatus, kMC) : CLRBIT(fStatus, kMC);}
+  Bool_t        PutTrendValue(const Char_t *name, Double_t val);
+  void          Terminate(Option_t *);
+  void          MakeSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="", Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);
+  Int_t         GetNAssignedTriggers();
+  void          AddUserTrigger(const Char_t* name) {fUserEnabledTriggers += name; fUserEnabledTriggers += ";";}
+  
+  void          AddCFContainer(const Char_t* name, const Char_t* title, Int_t nSteps, Int_t* steps, 
+                              Int_t nVars, UInt_t* vars, TArrayD* binLimits);
+  
+private:
+  static const Float_t fgkxTPC; // end radial position of TPC
+  static const Float_t fgkxTOF; // start radial position of TOF
+  static const Char_t* fgkVarNames[kNTrdCfVariables];
+  static const Char_t* fgkStepNames[kNSteps];
+  
+  void PlotTrackingSummaryFromCF(Double_t* trendValues=0x0,
+                                const Char_t* triggerName="",
+                                 Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);   // 1 <= centralityClass <= 5; 0-all centrality classes together
+  void PlotPidSummaryFromCF(Double_t* trendValues=0x0,
+                           const Char_t* triggerName="",
+                            Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);        // 1 <= centralityClass <= 5; 0-all centrality classes together
+  void PlotCentSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="",
+                             Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);       // centrality dependent plots
+  void PlotOtherSummaryFromCF(Double_t* trendValues);
+  
+  AliTRDcheckESD(const AliTRDcheckESD&);
+  AliTRDcheckESD& operator=(const AliTRDcheckESD&);
+  Int_t         Pdg2Idx(Int_t pdg) const;
+  void          Process(TH1 **h, TGraphErrors *g);
+  void          Process2D(TH2 * const h, TGraphErrors **g);
+  void          PrintStatus(ULong_t s);
+  TH2F*         Proj3D(TH3* hist, TH2* accMap, Int_t binLow, Int_t binHigh, Float_t &entries);
+  TH1D*         Proj2D(TH2* hist, TH1* mpvErr=0x0, TH1* widthErr=0x0, TH1* chi2=0x0);
+  TH1F*         EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance=kTRUE);
+  TH1F*         EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, Int_t stepNom, Int_t stepDenom, Int_t var=kTrackPt);
+  void          DrawTRDGrid();
+  void          SetStyle(TH1* hist, Int_t lineStyle, Int_t lineColor, Int_t lineWidth, 
+                         Int_t markerStyle, Int_t markerColor, Int_t markerSize);
+  void          SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, 
+                         Float_t labelSize);
+  void          CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]);
+  void          FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]);
+  void          InitializeCFContainers();
+  Int_t         GetTriggerIndex(const Char_t* name, Bool_t createNew=kTRUE);
+  void          FillEventInfo(Double_t* values);
+  void          FillTrackInfo(Double_t* values, AliESDtrack* esdTrack);
+  void          FillTrackletInfo(Double_t* values, AliESDtrack* esdTrack, Int_t iPlane,
+                                 Double_t* localSagitaPhi, Double_t localMom[][3], Bool_t* localMomGood);
+  void          FillTrackletSliceInfo(Double_t* values, AliESDtrack* esdTrack, Int_t iSlice);
+  //void          FillCFContainer(AliCFContainer* cf, Double_t* values, Int_t step);
+  void          FillCFContainer(AliCFContainer* cf, Double_t* values, Bool_t* stepSelections);
+  Bool_t        IsTrackSelected(AliESDtrack* track, Double_t* values, Int_t step);
+  void          FillGlobalTrackContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig);
+  void          FillTrdTrackletContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig);
+  void          FillTrdSliceContainers(Double_t* values, Bool_t* stepSelections, Int_t itrig);
+  
+  Int_t            fStatus;            // bit mask for controlling the task
+  Int_t            fNRefFigures;       // number of current ref plots
+  AliESDEvent      *fESD;              //! ESD event
+  AliMCEvent       *fMC;               //! MC event
+  AliESDpid        *fESDpid;           //  ESD pid object 
+  static FILE      *fgFile;            //! trend file streamer
+  TObjArray*        fHistos;           //! QA histograms
+    
+  AliAnalysisCuts* fReferenceTrackFilter;     // reference track filter
+  Bool_t           fPhysSelTriggersEnabled;   // flag wheter physics selection triggers were enabled
+  TString          fUserEnabledTriggers;      // list of user enabled triggers
+  Int_t            fNAssignedTriggers;        // number of assigned triggers
+    
+  ClassDef(AliTRDcheckESD, 10)          // user oriented TRD analysis based on ESD-MC data
+};
+#endif
index f1db42cea1ad9f437b656b01b01d80db6cc10579..3e1fb40379ca1e3b1a45075dbc449a04309cd926 100644 (file)
-\r
-#if ! defined (__CINT__) || defined (__MAKECINT__)\r
-#include "AliLog.h"\r
-#include "AliAnalysisManager.h"\r
-#include "AliAnalysisDataContainer.h"\r
-#include "AliAnalysisCuts.h"\r
-#include "AliESDtrackCuts.h"\r
-#include "PWGPP/TRD/AliTRDcheckESD.h"\r
-#endif\r
-\r
-AliESDtrackCuts* SetupESDcuts();\r
-\r
-void AddTRDcheckESD(AliAnalysisManager *mgr)\r
-{\r
-  //AliLog::SetClassDebugLevel("AliTRDcheckESD", 5);\r
-  //  AliInfo("aaaaaa6666666666");\r
-  AliTRDcheckESD *checkESD = new AliTRDcheckESD((char*)"TRDcheckESD");\r
-  checkESD->SetRefTrackFilter(SetupESDcuts());\r
-  mgr->AddTask(checkESD);\r
-  Bool_t mc = mgr->GetMCtruthEventHandler();\r
-  checkESD->SetMC(mc);\r
-  checkESD->SetCollision(/*kFALSE*/);\r
-  checkESD->SetDebugLevel(0);\r
-  checkESD->AddUserTrigger("WU");\r
-  checkESD->AddUserTrigger("QU");\r
-  checkESD->AddUserTrigger("SE");\r
-  checkESD->AddUserTrigger("JT");\r
-  \r
-  mgr->ConnectInput(checkESD,  0, mgr->GetCommonInputContainer());  \r
-  mgr->ConnectOutput(checkESD, 1, mgr->CreateContainer(checkESD->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("%s:TRD_Performance",mgr->GetCommonFileName())));\r
-}\r
-\r
-AliESDtrackCuts* SetupESDcuts() {\r
-  // Setup ESD cuts for the TPC reference tracks\r
-  AliESDtrackCuts* esdCuts = new AliESDtrackCuts;\r
-  esdCuts->SetPtRange(0.5, 100.0);\r
-  esdCuts->SetEtaRange(-0.9, +0.9);\r
-  esdCuts->SetRequireTPCRefit(kTRUE);\r
-  esdCuts->SetAcceptKinkDaughters(kFALSE);\r
-  esdCuts->SetMaxDCAToVertexXY(1.);\r
-  esdCuts->SetMaxDCAToVertexZ(3.);\r
-  esdCuts->SetMinNClustersTPC(70);\r
-  esdCuts->SetRequireITSRefit(kTRUE);\r
-  esdCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);\r
-  return esdCuts;\r
-}\r
-\r
+
+#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "AliAnalysisCuts.h"
+#include "AliESDtrackCuts.h"
+#include "PWGPP/TRD/AliTRDcheckESD.h"
+#endif
+
+AliESDtrackCuts* SetupESDcuts();
+void AddCFContainers(AliTRDcheckESD* checkESD);
+
+void AddTRDcheckESD(AliAnalysisManager *mgr)
+{
+  //AliLog::SetClassDebugLevel("AliTRDcheckESD", 5);
+  //  AliInfo("aaaaaa6666666666");
+  AliTRDcheckESD *checkESD = new AliTRDcheckESD((char*)"TRDcheckESD");
+  checkESD->SetRefTrackFilter(SetupESDcuts());
+  mgr->AddTask(checkESD);
+  Bool_t mc = mgr->GetMCtruthEventHandler();
+  checkESD->SetMC(mc);
+  checkESD->SetCollision(/*kFALSE*/);
+  checkESD->SetDebugLevel(0);
+  checkESD->AddUserTrigger("WU");
+  checkESD->AddUserTrigger("QU");
+  checkESD->AddUserTrigger("SE");
+  checkESD->AddUserTrigger("JT");
+  
+  AddCFContainers(checkESD);
+  
+  mgr->ConnectInput(checkESD,  0, mgr->GetCommonInputContainer());  
+  mgr->ConnectOutput(checkESD, 1, mgr->CreateContainer(checkESD->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("%s:TRD_Performance",mgr->GetCommonFileName())));
+}
+
+AliESDtrackCuts* SetupESDcuts() {
+  // Setup ESD cuts for the TPC reference tracks
+  AliESDtrackCuts* esdCuts = new AliESDtrackCuts;
+  esdCuts->SetPtRange(0.5, 100.0);
+  esdCuts->SetEtaRange(-0.9, +0.9);
+  esdCuts->SetRequireTPCRefit(kTRUE);
+  esdCuts->SetAcceptKinkDaughters(kFALSE);
+  esdCuts->SetMaxDCAToVertexXY(1.);
+  esdCuts->SetMaxDCAToVertexZ(3.);
+  esdCuts->SetMinNClustersTPC(70);
+  esdCuts->SetRequireITSRefit(kTRUE);
+  esdCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
+  return esdCuts;
+}
+
+
+void AddCFContainers(AliTRDcheckESD* checkESD) {
+  //
+  // configure output CF containers
+  //
+  Double_t bcLimits[3501]; for(Int_t i=0; i<=3500; ++i) bcLimits[i] = -0.5+Double_t(i);
+  Double_t phiLimits[181]; for(Int_t i=0; i<=180; ++i) phiLimits[i] = 0.0+i*2.0*TMath::Pi()/180.0;
+  Double_t phiParamLimits[181]; for(Int_t i=0; i<=180; ++i) phiParamLimits[i] = -1.0*TMath::Pi()+i*2.0*TMath::Pi()/180.0;
+  Double_t ptLimits[19] = {0.0, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 
+                           3.5, 4.0, 4.5,  5.0, 6.0,  7.0, 8.0,  9.0, 10.0};
+  Double_t chargeLimits[3] = {-1.5,0.0,1.5};
+  Double_t etaLimits[91]; for(Int_t i=0;i<=90;++i) etaLimits[i] = -0.9+i*1.8/90.;
+  Double_t trdTrkltsLimits[8] = {-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5};
+  Double_t trigLimits[AliTRDcheckESD::kNMaxAssignedTriggers+1]; for(Int_t i=0;i<=AliTRDcheckESD::kNMaxAssignedTriggers;++i) trigLimits[i] = 0.5+Double_t(i);
+  Double_t evMultLimits[6] = {0.0, 700., 1400., 2100., 2800., 3500.};
+  Double_t pLimits[18] = {0.0, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0, 2.5, 
+                          3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};
+  Double_t qtotLimits[101]; for(Int_t i=0;i<=100;++i) qtotLimits[i] = 0.0+i*10000./100.;
+  Double_t layerLimits[7] = {-0.5,0.5,1.5,2.5,3.5,4.5,5.5};
+  Double_t sliceLimits[9] = {-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5};
+  Double_t pLossLimits[101]; for(Int_t i=0;i<=100;++i) pLossLimits[i] = -0.5+i*1.0/100.;
+  Double_t trdClustersLimits[201]; for(Int_t i=0;i<=200;++i) trdClustersLimits[i] = -0.5+i*200.0/200.;
+  Double_t trdQualityLimits[101]; for(Int_t i=0;i<=100;++i) trdQualityLimits[i] = 0.0+i*2.0/100.;
+  Double_t trdBudgetLimits[101]; for(Int_t i=0;i<=100;++i) trdBudgetLimits[i] = -100.0+i*200.0/100.;
+  Double_t trdChi2Limits[101]; for(Int_t i=0;i<=100;++i) trdChi2Limits[i] = 0.0+i*10.0/100.;
+  Double_t trackletClustersLimits[31]; for(Int_t i=0;i<=30;++i) trackletClustersLimits[i] = 0.0+i*1.0;
+  Double_t trackletClsRowsLimits[31]; for(Int_t i=0;i<=30;++i) trackletClsRowsLimits[i] = 0.0+Double_t(i)*1.0/30.0;
+  Double_t outerParamRadLimits[51]; for(Int_t i=0;i<=50;++i) outerParamRadLimits[i] = 0.0+Double_t(i)*500.0/50.0;
+  
+  // BC container
+  cout << "Container 1 :: BunchCrossingsCF" << endl;
+  Int_t bcSteps[3] = {AliTRDcheckESD::kTPCreference, AliTRDcheckESD::kTRD, AliTRDcheckESD::kTOF};
+  UInt_t bcVars[3] = {AliTRDcheckESD::kEventBC, AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackPt};
+  TArrayD bcBinning[3] = {TArrayD(3501, bcLimits), TArrayD(181,phiParamLimits), TArrayD(19,ptLimits)};
+  checkESD->AddCFContainer("BunchCrossingsCF", "Matching vs bunch crossings", 3, bcSteps, 3, bcVars, bcBinning);
+  
+  // (phi,eta) matching container
+  cout << "Container 2 :: MatchingPhiEta" << endl;
+  Int_t matchPhiEtaSteps[3] = {AliTRDcheckESD::kTPCreference, AliTRDcheckESD::kTRD, AliTRDcheckESD::kTOF};
+  UInt_t matchPhiEtaVars[5] = {AliTRDcheckESD::kTrackCharge,       AliTRDcheckESD::kTrackPhiTRD,    AliTRDcheckESD::kTrackEtaTRD,
+                               AliTRDcheckESD::kTrackTrdTracklets, AliTRDcheckESD::kEventTrigger};
+  TArrayD matchPhiEtaBinning[5] = {TArrayD(3,chargeLimits),    TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                   TArrayD(8,trdTrkltsLimits), TArrayD(AliTRDcheckESD::kNMaxAssignedTriggers+1, trigLimits)};
+  checkESD->AddCFContainer("MatchingPhiEta", "(phi,eta) matching CF", 3, matchPhiEtaSteps, 5, matchPhiEtaVars, matchPhiEtaBinning);
+  
+  // pt matching container
+  cout << "Container 3 :: MatchingPt" << endl;
+  Int_t matchPtSteps[3] = {AliTRDcheckESD::kTPCreference, AliTRDcheckESD::kTRD, AliTRDcheckESD::kTOF};
+  UInt_t matchPtVars[6] = {AliTRDcheckESD::kEventMult, AliTRDcheckESD::kTrackCharge,       AliTRDcheckESD::kTrackPhiTRD,
+                           AliTRDcheckESD::kTrackPt,   AliTRDcheckESD::kTrackTrdTracklets, AliTRDcheckESD::kEventTrigger};
+  TArrayD matchPtBinning[6] = {TArrayD(6,evMultLimits), TArrayD(3, chargeLimits),    TArrayD(181, phiParamLimits),
+                               TArrayD(19, ptLimits),   TArrayD(8, trdTrkltsLimits), TArrayD(AliTRDcheckESD::kNMaxAssignedTriggers+1, trigLimits)};
+  checkESD->AddCFContainer("MatchingPt", "(pt,phi,multiplicity) matching", 3, matchPtSteps, 6, matchPtVars, matchPtBinning);
+  
+  // qtot, vs event multiplicity and p
+  cout << "Container 4 :: CentralityCF" << endl;
+  Int_t qtotCentSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t qtotCentVars[4] = {AliTRDcheckESD::kEventMult, AliTRDcheckESD::kTrackP,
+                            AliTRDcheckESD::kTrackletQtot, AliTRDcheckESD::kTrackTrdClusters};
+  TArrayD qtotCentBinning[4] = {TArrayD(6,evMultLimits),
+                                TArrayD(18, pLimits), TArrayD(101, qtotLimits), TArrayD(201, trdClustersLimits)};
+  checkESD->AddCFContainer("CentralityCF", "qtot vs event multiplicity and p", 1, qtotCentSteps, 4, qtotCentVars, qtotCentBinning);
+  
+  // qtot vs (phi,eta) and layer
+  cout << "Container 5 :: QtotCF" << endl;
+  Int_t qtotSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t qtotVars[4] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD, 
+                        AliTRDcheckESD::kTrackletQtot, AliTRDcheckESD::kTrackletLayer};
+  TArrayD qtotBinning[4] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                            TArrayD(101, qtotLimits), TArrayD(7, layerLimits)};
+  checkESD->AddCFContainer("QtotCF", "qtot vs (phi,eta) and layer", 1, qtotSteps, 4, qtotVars, qtotBinning);
+  
+  // pulse height vs p and slice
+  cout << "Container 6 :: PulseHeightCF" << endl;
+  Int_t phSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t phVars[4] = {AliTRDcheckESD::kEventTrigger, AliTRDcheckESD::kTrackletP, 
+                      AliTRDcheckESD::kTrackletPHslice, AliTRDcheckESD::kTrackletSlice};
+  TArrayD phBinning[4] = {TArrayD(AliTRDcheckESD::kNMaxAssignedTriggers+1, trigLimits), TArrayD(18,pLimits),
+                          TArrayD(101, qtotLimits), TArrayD(9,sliceLimits)};
+  checkESD->AddCFContainer("PulseHeightCF", "PH vs p and slice", 1, phSteps, 4, phVars, phBinning);  
+    
+  // TRD quality
+  cout << "Container 7 :: TRD quality" << endl;
+  Int_t trdQualitySteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t trdQualityVars[5] = {AliTRDcheckESD::kTrackP, AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD,
+                              AliTRDcheckESD::kTrackTrdQuality, AliTRDcheckESD::kTrackCharge};
+  TArrayD trdQualityBinning[5] = {TArrayD(18, pLimits), TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                  TArrayD(101, trdQualityLimits), TArrayD(3, chargeLimits)};
+  checkESD->AddCFContainer("trdQuality", "TRD quality vs (p,phi,eta,charge)", 1, trdQualitySteps, 
+                          5, trdQualityVars, trdQualityBinning);
+  
+  // TRD chi2
+  cout << "Container 8 :: TRD chi2" << endl;
+  Int_t trdChi2Steps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t trdChi2Vars[5] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD,
+                           AliTRDcheckESD::kTrackTrdChi2,
+                           AliTRDcheckESD::kTrackPt, AliTRDcheckESD::kTrackCharge};
+  TArrayD trdChi2Binning[5] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                               TArrayD(101, trdChi2Limits),
+                               TArrayD(19, ptLimits), TArrayD(3, chargeLimits)};
+  checkESD->AddCFContainer("trdChi2", "TRD chi2 vs (phi,eta,pt,charge)", 1, trdChi2Steps, 
+                          5, trdChi2Vars, trdChi2Binning);
+  
+  // TRD material budget
+  cout << "Container 9 :: TRD material budget" << endl;
+  Int_t trdBudgetSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t trdBudgetVars[3] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD,
+                             AliTRDcheckESD::kTrackTRDBudget};
+  TArrayD trdBudgetBinning[3] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                 TArrayD(101, trdBudgetLimits)};
+  checkESD->AddCFContainer("trdBudget", "TRD budget vs (phi,eta)", 1, trdBudgetSteps, 
+                          3, trdBudgetVars, trdBudgetBinning);
+  
+  // ploss vs (phi,eta) and layer
+  cout << "Container 10 :: Momentum loss" << endl;
+  Int_t plossSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t plossVars[5] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD, 
+                         AliTRDcheckESD::kTrackPlossTRDlayer, AliTRDcheckESD::kTrackletLayer,
+                         AliTRDcheckESD::kTrackCharge};
+  TArrayD plossBinning[5] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                             TArrayD(101, pLossLimits), TArrayD(7, layerLimits),
+                             TArrayD(3, chargeLimits)};
+  checkESD->AddCFContainer("Ploss", "p loss vs (phi,eta,layer,charge)", 1, plossSteps, 5, plossVars, plossBinning);
+
+  // clusters per tracklet  
+  cout << "Container 11 :: Clusters per tracklet" << endl;
+  Int_t clustersSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t clustersVars[5] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD, 
+                            AliTRDcheckESD::kTrackletLayer, AliTRDcheckESD::kTrackletClusters,
+                            AliTRDcheckESD::kTrackCharge};
+  TArrayD clustersBinning[5] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                TArrayD(7, layerLimits), TArrayD(31, trackletClustersLimits),
+                                TArrayD(3,chargeLimits)};
+  checkESD->AddCFContainer("clustersPerTracklet", "tracklet clusters vs (phi,eta,layer,charge)", 1, clustersSteps, 5, clustersVars, clustersBinning);
+
+  // clusters/crossed rows  
+  cout << "Container 12 :: Clusters/crossed rows" << endl;
+  Int_t clsRowsSteps[1] = {AliTRDcheckESD::kTRD};
+  UInt_t clsRowsVars[5] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD, 
+                            AliTRDcheckESD::kTrackletLayer, AliTRDcheckESD::kTrackletClustersVsRows,
+                            AliTRDcheckESD::kTrackCharge};
+  TArrayD clsRowsBinning[5] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                TArrayD(7, layerLimits), TArrayD(31, trackletClsRowsLimits),
+                                TArrayD(3,chargeLimits)};
+  checkESD->AddCFContainer("clustersVsRows", "tracklet/rows vs (phi,eta,layer,charge)", 1, clsRowsSteps, 5, clsRowsVars, clsRowsBinning);
+/*  
+  // outer param radius  
+  cout << "Container 13 :: Outer param" << endl;
+  Int_t outerParamSteps[1] = {AliTRDcheckESD::kTPCreference};
+  UInt_t outerParamVars[5] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD, 
+                              AliTRDcheckESD::kTrackOuterParamRadius, AliTRDcheckESD::kTrackTrdTracklets,
+                              AliTRDcheckESD::kTrackPt};
+  TArrayD outerParamBinning[5] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                  TArrayD(51, outerParamRadLimits), TArrayD(8,trdTrkltsLimits),
+                                  TArrayD(19, ptLimits)};
+  checkESD->AddCFContainer("outerParam", "outer param radius vs (phi,eta,pt,n-tracklets)", 1, outerParamSteps, 5, outerParamVars, outerParamBinning);
+*/
+  
+  // TPC-TOF (phi,eta) matching container
+  cout << "Container 14 :: MatchingPhiEta_TPCTOF" << endl;
+  Int_t matchPhiEtaTPCTOFSteps[3] = {AliTRDcheckESD::kTPCreference, AliTRDcheckESD::kTOFin, AliTRDcheckESD::kTOFout};
+  UInt_t matchPhiEtaTPCTOFVars[4] = {AliTRDcheckESD::kTrackPhiTRD, AliTRDcheckESD::kTrackEtaTRD,
+                                     AliTRDcheckESD::kTrackPt, AliTRDcheckESD::kTrackCharge};
+  TArrayD matchPhiEtaTPCTOFBinning[4] = {TArrayD(181, phiParamLimits), TArrayD(91, etaLimits),
+                                         TArrayD(19, ptLimits), TArrayD(3,chargeLimits)};
+  checkESD->AddCFContainer("MatchingPhiEta_TPCTOF", "TPC_TOF (phi,eta) matching", 3, matchPhiEtaTPCTOFSteps, 4, matchPhiEtaTPCTOFVars, matchPhiEtaTPCTOFBinning);
+}
+
index 17dfb23165c057a74944304b6a41602f888e3052..fac5820b378bd455234df747bce6a392574be40e 100644 (file)
@@ -4,7 +4,7 @@
 
 ClassImp(AliPIDperfContainer);
 
-AliPIDperfContainer::AliPIDperfContainer(const char *name,const Int_t nvar,const Int_t* binVar) :
+AliPIDperfContainer::AliPIDperfContainer(const char *name, Int_t nvar,const Int_t* binVar) :
   TNamed(name,name),
   fNbinVar(new TArrayI(nvar)),
   fXmin(new TArrayF(nvar)),
index fb1821e815042d41f716daf29c098b4c881b958e..302efdf79d6d0c3311c1378698124c2ac6275aba 100644 (file)
@@ -21,7 +21,7 @@
 class AliPIDperfContainer : public TNamed
 {
  public:
-  AliPIDperfContainer(const char *name,const Int_t nvar,const Int_t* binVar);
+  AliPIDperfContainer(const char *name, Int_t nvar,const Int_t* binVar);
   AliPIDperfContainer();
   ~AliPIDperfContainer();
   AliPIDperfContainer(const AliPIDperfContainer &old);
index 0dd7fdbf57c1e5553fddf57ac7aade64d6eedb86..87722cb8549657f08392f3614329ca1ba4039aaa 100644 (file)
@@ -179,7 +179,7 @@ const Double_t AliCDMesonBase::fgkMaxVerticesDistance = 5.; // upper border
 
 
 //------------------------------------------------------------------------------
-Int_t AliCDMesonBase::GetGapBin(TString tag, const Int_t gapcg,
+Int_t AliCDMesonBase::GetGapBin(TString tag, Int_t gapcg,
                                 Bool_t checkCentralActivity /* = kTRUE */)
 {
        //
@@ -231,8 +231,8 @@ Int_t AliCDMesonBase::GetGapBin(TString tag, const Int_t gapcg,
 
 
 //------------------------------------------------------------------------------
-void AliCDMesonBase::CheckRange(Double_t &var, const Double_t min,
-                                const Double_t max)
+void AliCDMesonBase::CheckRange(Double_t &var, Double_t min,
+                                Double_t max)
 {
        //
        // check whether the value is with in the range specified with min and max
@@ -339,19 +339,19 @@ THnSparseD * AliCDMesonBase::GetThnMother(TString name /* = "CDMeson_Mother" */)
 
 
 //------------------------------------------------------------------------------
-void AliCDMesonBase::FillThnMother(THnSparseD *thn, const Double_t vNch,
-                                   const Double_t vCombCh,
-                                   const Double_t vCombPID, const Double_t vV0,
-                                   const Double_t vFMD, const Double_t vSPD,
-                                   const Double_t vTPC, const Double_t vMass,
-                                   const Double_t vPt,  const Double_t vOA,
-                                   const Double_t vCTS,
-                                   const Double_t vDaughterPt,
-                                   const Double_t vTrackResiduals,
-                                   const Double_t vVertexZ,
-                                   const Double_t vProcessType,
-                                   const Double_t vVertexCoincidence,
-                                   const Double_t vTrkltResiduals)
+void AliCDMesonBase::FillThnMother(THnSparseD *thn, Double_t vNch,
+                                   Double_t vCombCh,
+                                   Double_t vCombPID, Double_t vV0,
+                                   Double_t vFMD, Double_t vSPD,
+                                   Double_t vTPC, Double_t vMass,
+                                   Double_t vPt,  Double_t vOA,
+                                   Double_t vCTS,
+                                   Double_t vDaughterPt,
+                                   Double_t vTrackResiduals,
+                                   Double_t vVertexZ,
+                                   Double_t vProcessType,
+                                   Double_t vVertexCoincidence,
+                                   Double_t vTrkltResiduals)
 {
        //
        // fill ThnMother
@@ -378,7 +378,7 @@ void AliCDMesonBase::FillThnMother(THnSparseD *thn, const Double_t vNch,
 
 
 //------------------------------------------------------------------------------
-Int_t AliCDMesonBase::GetAxisMother(const TString name)
+Int_t AliCDMesonBase::GetAxisMother(TString name)
 {
        //
        // return axis number corresponding to the name
@@ -434,22 +434,22 @@ THnSparseD* AliCDMesonBase::GetThnEmptyEvents()
 
 
 //------------------------------------------------------------------------------
-void AliCDMesonBase::FillThnEmptyEvents(THnSparseD * thn, const Int_t eventType,
-                                        const Int_t multFMDA,
-                                        const Int_t multFMDC,
-                                        const Int_t multSPDIA,
-                                        const Int_t multSPDIC,
-                                        const Int_t multSPDOA,
-                                        const Int_t multSPDOC,
-                                        const Int_t multSPDtrkltA,
-                                        const Int_t multSPDtrkltC,
-                                        const Int_t fmdSum1I,
-                                        const Int_t fmdSum2I,
-                                        const Int_t fmdSum2O,
-                                        const Int_t fmdSum3I,
-                                        const Int_t fmdSum3O/*,
-                                        const Int_t multTPC,
-                                        const Int_t multTPCdiffVertex */)
+void AliCDMesonBase::FillThnEmptyEvents(THnSparseD * thn, Int_t eventType,
+                                        Int_t multFMDA,
+                                        Int_t multFMDC,
+                                        Int_t multSPDIA,
+                                        Int_t multSPDIC,
+                                        Int_t multSPDOA,
+                                        Int_t multSPDOC,
+                                        Int_t multSPDtrkltA,
+                                        Int_t multSPDtrkltC,
+                                        Int_t fmdSum1I,
+                                        Int_t fmdSum2I,
+                                        Int_t fmdSum2O,
+                                        Int_t fmdSum3I,
+                                        Int_t fmdSum3O/*,
+                                        Int_t multTPC,
+                                        Int_t multTPCdiffVertex */)
 {
        //
        // Fill ThnEmptyEvents
@@ -472,7 +472,7 @@ void AliCDMesonBase::FillThnEmptyEvents(THnSparseD * thn, const Int_t eventType,
 
 
 //------------------------------------------------------------------------------
-Int_t AliCDMesonBase::GetAxisEmptyEvents(const TString name)
+Int_t AliCDMesonBase::GetAxisEmptyEvents(TString name)
 {
        //
        // return axis number corresponding to the name
@@ -528,18 +528,18 @@ THnSparseD* AliCDMesonBase::GetThnMultiplicity()
 
 
 //------------------------------------------------------------------------------
-void AliCDMesonBase::FillThnMultiplicity(THnSparseD *thn, const Double_t vNch,
-                                         const Double_t vNsoft,
-                                         const Double_t vNcombined,
-                                         const Double_t vV0,
-                                         const Double_t vFMD,
-                                         const Double_t vSPD,
-                                         const Double_t vTPC,
-                                         const Double_t vNresidualTracks,
-                                         const Double_t vNresidualTracklets,
-                                         const Double_t vVertexZ,
-                                         const Double_t vVerticesDistance,
-                                         const Double_t vProcessType)
+void AliCDMesonBase::FillThnMultiplicity(THnSparseD *thn, Double_t vNch,
+                                         Double_t vNsoft,
+                                         Double_t vNcombined,
+                                         Double_t vV0,
+                                         Double_t vFMD,
+                                         Double_t vSPD,
+                                         Double_t vTPC,
+                                         Double_t vNresidualTracks,
+                                         Double_t vNresidualTracklets,
+                                         Double_t vVertexZ,
+                                         Double_t vVerticesDistance,
+                                         Double_t vProcessType)
 {
        // fill ThnMultiplicity
        // input list copied from GetTitle
@@ -561,7 +561,7 @@ void AliCDMesonBase::FillThnMultiplicity(THnSparseD *thn, const Double_t vNch,
 
 
 //------------------------------------------------------------------------------
-Int_t AliCDMesonBase::GetAxisMultiplicity(const TString name)
+Int_t AliCDMesonBase::GetAxisMultiplicity(TString name)
 {
        //
        // return axis number corresponding to the name
@@ -712,7 +712,7 @@ TObjArray* AliCDMesonBase::GetHistVZEROStudies(TList* l)
 
 //------------------------------------------------------------------------------
 void AliCDMesonBase::GetGapTriggers(THnSparseI* gaprun, Int_t gapCondition,
-                                    const Int_t run, Double_t& triggers,
+                                    Int_t run, Double_t& triggers,
                                     Double_t& total)
 {
        // determine the number of certain triggers with a gap in the detectors
@@ -735,7 +735,7 @@ void AliCDMesonBase::GetGapTriggers(THnSparseI* gaprun, Int_t gapCondition,
 
 //------------------------------------------------------------------------------
 void AliCDMesonBase::GetNoGapTriggers(THnSparseI* gaprun, Int_t gapCondition,
-                                      const Int_t run, Double_t& triggers,
+                                      Int_t run, Double_t& triggers,
                                       Double_t& total)
 {
        // determine the number of certain triggers with a NO gap in the detectors
index a98f7fd91a7f3a50c7fc2bcf8d7d826d04562810..47f9a69266b58b67ae379edc29c11b0ded6da822 100644 (file)
@@ -165,63 +165,63 @@ public:
                kBitConfigurationVersion = (1<<28) // always set, last bit
        };
 
-       static Int_t GetGapBin(const TString tag, const Int_t gapcg,
+       static Int_t GetGapBin(TString tag, Int_t gapcg,
                               Bool_t checkCentralActivity = kTRUE);
 
        static THnSparseD* GetThnMother(TString name = "CDMeson_Mother");
-       static void FillThnMother(THnSparseD *thn, const Double_t vNch,
-                                 const Double_t vCombCh, const Double_t vCombPID,
-                                 const Double_t vV0, const Double_t vFMD,
-                                 const Double_t vSPD, const Double_t vTPC,
-                                 const Double_t vMass, const Double_t vPt,
-                                 const Double_t vOA, const Double_t vCTS,
-                                 const Double_t vDaughterPt,
-                                 const Double_t vTrackResiduals,
-                                 const Double_t vVertexZ,
-                                 const Double_t vProcessType,
-                                 const Double_t vVertexCoincidence,
-                                 const Double_t vTrkltResiduals);
-       static Int_t GetAxisMother(const TString name);
+       static void FillThnMother(THnSparseD *thn, Double_t vNch,
+                                 Double_t vCombCh, Double_t vCombPID,
+                                 Double_t vV0, Double_t vFMD,
+                                 Double_t vSPD, Double_t vTPC,
+                                 Double_t vMass, Double_t vPt,
+                                 Double_t vOA, Double_t vCTS,
+                                 Double_t vDaughterPt,
+                                 Double_t vTrackResiduals,
+                                 Double_t vVertexZ,
+                                 Double_t vProcessType,
+                                 Double_t vVertexCoincidence,
+                                 Double_t vTrkltResiduals);
+       static Int_t GetAxisMother(TString name);
 
        static THnSparseD* GetThnEmptyEvents();
-       static void FillThnEmptyEvents(THnSparseD *thn, const Int_t eventType,
-                                      const Int_t multFMDA, const Int_t multFMDC,
-                                      const Int_t multSPDIA, const Int_t multSPDIC,
-                                      const Int_t multSPDOA, const Int_t multSPDOC,
-                                      const Int_t multSPDtrklA,
-                                      const Int_t multSPDtrklC, const Int_t fmdSum1I,
-                                      const Int_t fmdSum2I, const Int_t fmdSum20,
-                                      const Int_t fmdSum3I, const Int_t fmdSum3O/*,
-                                      const Int_t multTPC,
-                                      const Int_t multTPCdiffVertex */);
-       static Int_t GetAxisEmptyEvents(const TString name);
+       static void FillThnEmptyEvents(THnSparseD *thn, Int_t eventType,
+                                      Int_t multFMDA, Int_t multFMDC,
+                                      Int_t multSPDIA, Int_t multSPDIC,
+                                      Int_t multSPDOA, Int_t multSPDOC,
+                                      Int_t multSPDtrklA,
+                                      Int_t multSPDtrklC, Int_t fmdSum1I,
+                                      Int_t fmdSum2I, Int_t fmdSum20,
+                                      Int_t fmdSum3I, Int_t fmdSum3O/*,
+                                      Int_t multTPC,
+                                      Int_t multTPCdiffVertex */);
+       static Int_t GetAxisEmptyEvents(TString name);
 
        static THnSparseD* GetThnMultiplicity();
-       static void FillThnMultiplicity(THnSparseD *thn, const Double_t vNch,
-                                       const Double_t vNsoft,
-                                       const Double_t vNcombined,
-                                       const Double_t vV0, const Double_t vFMD,
-                                       const Double_t vSPD, const Double_t vTPC,
-                                       const Double_t vNresidualTracks,
-                                       const Double_t vNresidualTracklets,
-                                       const Double_t vVertexZ,
-                                       const Double_t vVerticesDistance,
-                                       const Double_t vProcessType);
-       static Int_t GetAxisMultiplicity(const TString name);
+       static void FillThnMultiplicity(THnSparseD *thn, Double_t vNch,
+                                       Double_t vNsoft,
+                                       Double_t vNcombined,
+                                       Double_t vV0, Double_t vFMD,
+                                       Double_t vSPD, Double_t vTPC,
+                                       Double_t vNresidualTracks,
+                                       Double_t vNresidualTracklets,
+                                       Double_t vVertexZ,
+                                       Double_t vVerticesDistance,
+                                       Double_t vProcessType);
+       static Int_t GetAxisMultiplicity(TString name);
 
        static TH1F* GetHistStatsFlow();
        static TH2F* GetHistPIDStudies(TString name);
        static TObjArray* GetHistVZEROStudies(TList* l);
 
        static void GetGapTriggers(THnSparseI* gaprun, Int_t gapCondition,
-                                  const Int_t run, Double_t& triggers,
+                                  Int_t run, Double_t& triggers,
                                   Double_t& total);
 
        static void GetNoGapTriggers(THnSparseI* gaprun, Int_t gapCondition,
-                                    const Int_t run, Double_t& triggers,
+                                    Int_t run, Double_t& triggers,
                                     Double_t& total);
 private:
-       static void CheckRange(Double_t &var, const Double_t min, const Double_t max);
+       static void CheckRange(Double_t &var, Double_t min, Double_t max);
        static Int_t GetAxis(TString thntit, TString name);
        static TString GetTitleMother();
        static TString GetTitleEmptyEvents();
index 28e990ab1c4c0c697c2f204f82e931f281550cfd..998a969579fe52837b90be1d8fddf8d5fb624991 100644 (file)
@@ -47,6 +47,7 @@
 #include "AliESDMuonTrack.h"
 #include "AliAODMCParticle.h"
 #include "AliMCParticle.h"
+#include "AliCentrality.h"
 
 // my headers
 #include "AliAnalysisTaskUpcPsi2s.h"
@@ -62,11 +63,15 @@ using std::endl;
 //_____________________________________________________________________________
 AliAnalysisTaskUpcPsi2s::AliAnalysisTaskUpcPsi2s() 
   : AliAnalysisTaskSE(),fType(0),fRunTree(kTRUE),fRunHist(kTRUE),fJPsiTree(0),fPsi2sTree(0),
-    fRunNum(0),fPerNum(0),fOrbNum(0),fL0inputs(0),fL1inputs(0),fVtxContrib(0),fBCrossNum(0),fNtracklets(0),
+    fRunNum(0),fPerNum(0),fOrbNum(0),fL0inputs(0),fL1inputs(0),
+    fTOFtrig1(0), fTOFtrig2(0),
+    fVtxContrib(0),fVtxPosX(0),fVtxPosY(0),fVtxPosZ(0),fVtxErrX(0),fVtxErrY(0),fVtxErrZ(0),fVtxChi2(0),fVtxNDF(0),
+    fBCrossNum(0),fNtracklets(0),
     fZDCAenergy(0),fZDCCenergy(0),fV0Adecision(0),fV0Cdecision(0),
     fDataFilnam(0),fRecoPass(0),fEvtNum(0),
     fJPsiAODTracks(0),fJPsiESDTracks(0),fPsi2sAODTracks(0),fPsi2sESDTracks(0),
     fListTrig(0),fHistUpcTriggersPerRun(0),fHistZedTriggersPerRun(0),fHistCvlnTriggersPerRun(0),
+    fHistMBTriggersPerRun(0),fHistCentralTriggersPerRun(0),fHistSemiCentralTriggersPerRun(0),
     fListHist(0),fHistNeventsJPsi(0),fHistTPCsignalJPsi(0),fHistDiLeptonPtJPsi(0),fHistDiElectronMass(0),fHistDiMuonMass(0),
     fHistNeventsPsi2s(0),fHistPsi2sMassVsPt(0),fHistPsi2sMassCoherent(0)
 
@@ -80,11 +85,15 @@ AliAnalysisTaskUpcPsi2s::AliAnalysisTaskUpcPsi2s()
 //_____________________________________________________________________________
 AliAnalysisTaskUpcPsi2s::AliAnalysisTaskUpcPsi2s(const char *name) 
   : AliAnalysisTaskSE(name),fType(0),fRunTree(kTRUE),fRunHist(kTRUE),fJPsiTree(0),fPsi2sTree(0),
-    fRunNum(0),fPerNum(0),fOrbNum(0),fL0inputs(0),fL1inputs(0),fVtxContrib(0),fBCrossNum(0),fNtracklets(0),
+    fRunNum(0),fPerNum(0),fOrbNum(0),fL0inputs(0),fL1inputs(0),
+    fTOFtrig1(0), fTOFtrig2(0),
+    fVtxContrib(0),fVtxPosX(0),fVtxPosY(0),fVtxPosZ(0),fVtxErrX(0),fVtxErrY(0),fVtxErrZ(0),fVtxChi2(0),fVtxNDF(0),
+    fBCrossNum(0),fNtracklets(0),
     fZDCAenergy(0),fZDCCenergy(0),fV0Adecision(0),fV0Cdecision(0),
     fDataFilnam(0),fRecoPass(0),fEvtNum(0),
     fJPsiAODTracks(0),fJPsiESDTracks(0),fPsi2sAODTracks(0),fPsi2sESDTracks(0),
     fListTrig(0),fHistUpcTriggersPerRun(0),fHistZedTriggersPerRun(0),fHistCvlnTriggersPerRun(0),
+    fHistMBTriggersPerRun(0),fHistCentralTriggersPerRun(0),fHistSemiCentralTriggersPerRun(0),
     fListHist(0),fHistNeventsJPsi(0),fHistTPCsignalJPsi(0),fHistDiLeptonPtJPsi(0),fHistDiElectronMass(0),fHistDiMuonMass(0),
     fHistNeventsPsi2s(0),fHistPsi2sMassVsPt(0),fHistPsi2sMassCoherent(0)
 
@@ -160,6 +169,19 @@ void AliAnalysisTaskUpcPsi2s::UserCreateOutputObjects()
   fJPsiTree ->Branch("fL1inputs", &fL1inputs, "fL1inputs/i");
   fJPsiTree ->Branch("fNtracklets", &fNtracklets, "fNtracklets/s");
   fJPsiTree ->Branch("fVtxContrib", &fVtxContrib, "fVtxContrib/I");
+  
+  fJPsiTree ->Branch("fTOFtrig1", &fTOFtrig1, "fTOFtrig1/O");
+  fJPsiTree ->Branch("fTOFtrig2", &fTOFtrig2, "fTOFtrig2/O");
+  
+  fJPsiTree ->Branch("fVtxPosX", &fVtxPosX, "fVtxPosX/D");
+  fJPsiTree ->Branch("fVtxPosY", &fVtxPosY, "fVtxPosY/D");
+  fJPsiTree ->Branch("fVtxPosZ", &fVtxPosZ, "fVtxPosZ/D");
+  fJPsiTree ->Branch("fVtxErrX", &fVtxErrX, "fVtxErrX/D");
+  fJPsiTree ->Branch("fVtxErrY", &fVtxErrY, "fVtxErrY/D");
+  fJPsiTree ->Branch("fVtxErrZ", &fVtxErrZ, "fVtxErrZ/D");
+  fJPsiTree ->Branch("fVtxChi2", &fVtxChi2, "fVtxChi2/D");
+  fJPsiTree ->Branch("fVtxNDF", &fVtxNDF, "fVtxNDF/D");
+  
   fJPsiTree ->Branch("fZDCAenergy", &fZDCAenergy, "fZDCAenergy/D");
   fJPsiTree ->Branch("fZDCCenergy", &fZDCCenergy, "fZDCCenergy/D");
   fJPsiTree ->Branch("fV0Adecision", &fV0Adecision, "fV0Adecision/I");
@@ -186,6 +208,19 @@ void AliAnalysisTaskUpcPsi2s::UserCreateOutputObjects()
   fPsi2sTree ->Branch("fL1inputs", &fL1inputs, "fL1inputs/i");
   fPsi2sTree ->Branch("fNtracklets", &fNtracklets, "fNtracklets/s");
   fPsi2sTree ->Branch("fVtxContrib", &fVtxContrib, "fVtxContrib/I");
+  
+  fPsi2sTree ->Branch("fTOFtrig1", &fTOFtrig1, "fTOFtrig1/O");
+  fPsi2sTree ->Branch("fTOFtrig2", &fTOFtrig2, "fTOFtrig2/O");
+  
+  fPsi2sTree ->Branch("fVtxPosX", &fVtxPosX, "fVtxPosX/D");
+  fPsi2sTree ->Branch("fVtxPosY", &fVtxPosY, "fVtxPosY/D");
+  fPsi2sTree ->Branch("fVtxPosZ", &fVtxPosZ, "fVtxPosZ/D");
+  fPsi2sTree ->Branch("fVtxErrX", &fVtxErrX, "fVtxErrX/D");
+  fPsi2sTree ->Branch("fVtxErrY", &fVtxErrY, "fVtxErrY/D");
+  fPsi2sTree ->Branch("fVtxErrZ", &fVtxErrZ, "fVtxErrZ/D");
+  fPsi2sTree ->Branch("fVtxChi2", &fVtxChi2, "fVtxChi2/D");
+  fPsi2sTree ->Branch("fVtxNDF", &fVtxNDF, "fVtxNDF/D");
+  
   fPsi2sTree ->Branch("fZDCAenergy", &fZDCAenergy, "fZDCAenergy/D");
   fPsi2sTree ->Branch("fZDCCenergy", &fZDCCenergy, "fZDCCenergy/D");
   fPsi2sTree ->Branch("fV0Adecision", &fV0Adecision, "fV0Adecision/I");
@@ -212,6 +247,15 @@ void AliAnalysisTaskUpcPsi2s::UserCreateOutputObjects()
   fHistCvlnTriggersPerRun = new TH1D("fHistCvlnTriggersPerRun", "fHistCvlnTriggersPerRun", 3000, 167000.5, 170000.5);
   fListTrig->Add(fHistCvlnTriggersPerRun);
   
+  fHistMBTriggersPerRun = new TH1D("fHistMBTriggersPerRun", "fHistMBTriggersPerRun", 3000, 167000.5, 170000.5);
+  fListTrig->Add(fHistMBTriggersPerRun);
+  
+  fHistCentralTriggersPerRun = new TH1D("fHistCentralTriggersPerRun", "fHistCentralTriggersPerRun", 3000, 167000.5, 170000.5);
+  fListTrig->Add(fHistCentralTriggersPerRun);
+  
+  fHistSemiCentralTriggersPerRun = new TH1D("fHistSemiCentralTriggersPerRun", "fHistSemiCentralTriggersPerRun", 3000, 167000.5, 170000.5);
+  fListTrig->Add(fHistSemiCentralTriggersPerRun);
+  
   fListHist = new TList();
   fListHist ->SetOwner();
   
@@ -291,12 +335,24 @@ void AliAnalysisTaskUpcPsi2s::RunAODtrig()
   
   if(trigger.Contains("CCUP4-B")) fHistUpcTriggersPerRun->Fill(fRunNum); //Upc triggers
   
-  if(trigger.Contains("CVLN-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN-B triggers
-  
-  //if(aod->GetHeader()->IsTriggerInputFired("1ZED")) fHistZedTriggersPerRun->Fill(fRunNum); //1ZED trigger inputs
+  if(trigger.Contains("CVLN_B2-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN triggers - synchronously downscaled
+  if(trigger.Contains("CVLN_R1-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN triggers - randomly downscaled
   
   fL1inputs = aod->GetHeader()->GetL1TriggerInputs();
   if(fL1inputs & (1 << 18)) fHistZedTriggersPerRun->Fill(fRunNum); //1ZED trigger inputs
+  
+  //MB, Central and SemiCentral triggers
+  AliCentrality *centrality = aod->GetCentrality();
+  UInt_t selectionMask = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+  
+  Double_t percentile = centrality->GetCentralityPercentileUnchecked("V0M");
+  //Double_t percentile = centrality->GetCentralityPercentile("V0M");
+  
+  if(((selectionMask & AliVEvent::kMB) == AliVEvent::kMB) && percentile<80 && percentile>0) fHistMBTriggersPerRun->Fill(fRunNum);
+  
+  if(((selectionMask & AliVEvent::kCentral) == AliVEvent::kCentral) && percentile<6 && percentile>0) fHistCentralTriggersPerRun->Fill(fRunNum);
+
+  if(((selectionMask & AliVEvent::kSemiCentral) == AliVEvent::kSemiCentral) && percentile<50 && percentile>15) fHistSemiCentralTriggersPerRun->Fill(fRunNum);
 
 PostData(3, fListTrig);
 
@@ -350,13 +406,13 @@ void AliAnalysisTaskUpcPsi2s::RunAODhist()
   fZDCAenergy = fZDCdata->GetZNATowerEnergy()[0];
   fZDCCenergy = fZDCdata->GetZNCTowerEnergy()[0];
 
-  if( fZDCAenergy > 12000 || fZDCCenergy > 12000) return;
+  if( fZDCAenergy > 8200 || fZDCCenergy > 8200) return;
   
   fHistNeventsJPsi->Fill(4);
   fHistNeventsPsi2s->Fill(4);
 
-   Int_t nGoodTracks=0;
   //Two tracks loop
+  Int_t nGoodTracks = 0;
   Int_t TrackIndex[5] = {-1,-1,-1,-1,-1};
   
   TLorentzVector vLepton[4], vPion[4], vCandidate, vDilepton;
@@ -365,71 +421,7 @@ void AliAnalysisTaskUpcPsi2s::RunAODhist()
   Double_t jRecTPCsignal[5];
   Int_t mass[3]={-1,-1,-1};
   
-  //Two track loop
-  for(Int_t itr=0; itr<aod ->GetNumberOfTracks(); itr++) {
-    AliAODTrack *trk = aod->GetTrack(itr);
-    if( !trk ) continue;
-
-      if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
-      if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
-      if(trk->GetTPCNcls() < 70)continue;
-      if(trk->Chi2perNDF() > 4)continue;
-      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
-      Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
-      if(!trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
-      if(TMath::Abs(dca[1]) > 2) continue;
-      if(TMath::Abs(dca[0]) > 0.2) continue;
-     
-      TrackIndex[nGoodTracks] = itr;
-      nGoodTracks++;
-                                 
-      if(nGoodTracks > 2) break;  
-  }//Track loop
-
-  if(nGoodTracks == 2){
-         fHistNeventsJPsi->Fill(5);
-         for(Int_t i=0; i<2; i++){
-               AliAODTrack *trk = aod->GetTrack(TrackIndex[i]);                
-               if(trk->Pt() > 1) nHighPt++;     
-               jRecTPCsignal[nLepton] = trk->GetTPCsignal();     
-               qLepton[nLepton] = trk->Charge();
-               if(jRecTPCsignal[nLepton] > 40 && jRecTPCsignal[nLepton] < 70){
-                               vLepton[nLepton].SetPtEtaPhiM(trk->Pt(), trk->Eta(), trk->Phi(), muonMass);
-                               mass[nLepton] = 0;
-                               }
-               if(jRecTPCsignal[nLepton] > 70 && jRecTPCsignal[nLepton] < 100){
-                               vLepton[nLepton].SetPtEtaPhiM(trk->Pt(), trk->Eta(), trk->Phi(), electronMass);
-                               mass[nLepton] = 1;
-                               }
-                       nLepton++;              
-               }               
-       if(nLepton == 2){
-               if(qLepton[0]*qLepton[1] > 0) fHistNeventsJPsi->Fill(6);
-               if(qLepton[0]*qLepton[1] < 0){
-                       fHistNeventsJPsi->Fill(7);
-                       if(nHighPt > 0){
-                               fHistNeventsJPsi->Fill(8);
-                               fHistTPCsignalJPsi->Fill(jRecTPCsignal[0],jRecTPCsignal[1]);
-                               if(nHighPt == 2) fHistNeventsJPsi->Fill(9);
-                               if(mass[0] == mass[1] && mass[0] != -1) {
-                                       fHistNeventsJPsi->Fill(10);
-                                       vCandidate = vLepton[0]+vLepton[1];
-                                       if( vCandidate.M() > 2.8 && vCandidate.M() < 3.2) fHistDiLeptonPtJPsi->Fill(vLepton[0].Pt(),vLepton[1].Pt());
-                                       if(mass[0] == 0) {
-                                               fHistDiMuonMass->Fill(vCandidate.M());
-                                               fHistNeventsJPsi->Fill(11);
-                                               }
-                                       if(mass[0] == 1) {
-                                               fHistDiElectronMass->Fill(vCandidate.M());
-                                               fHistNeventsJPsi->Fill(12);
-                                               }
-                                       }
-                               }
-                       }
-               }
-  }
-  
-  nGoodTracks = 0;
+   
   //Four track loop
   for(Int_t itr=0; itr<aod ->GetNumberOfTracks(); itr++) {
     AliAODTrack *trk = aod->GetTrack(itr);
@@ -440,7 +432,10 @@ void AliAnalysisTaskUpcPsi2s::RunAODhist()
       if(trk->GetTPCNcls() < 50)continue;
       if(trk->Chi2perNDF() > 4)continue;
       Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
-      if(!trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+      if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      delete trk_clone;
+
       if(TMath::Abs(dca[1]) > 2) continue;
      
       TrackIndex[nGoodTracks] = itr;
@@ -498,6 +493,77 @@ void AliAnalysisTaskUpcPsi2s::RunAODhist()
                }
   }
   
+  nGoodTracks = 0;
+  //Two track loop
+  for(Int_t itr=0; itr<aod ->GetNumberOfTracks(); itr++) {
+    AliAODTrack *trk = aod->GetTrack(itr);
+    if( !trk ) continue;
+
+      if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
+      if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
+      if(trk->GetTPCNcls() < 70)continue;
+      if(trk->Chi2perNDF() > 4)continue;
+      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
+      Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
+      AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+      if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      delete trk_clone;
+      if(TMath::Abs(dca[1]) > 2) continue;
+      if(TMath::Abs(dca[0]) > 0.2) continue;
+     
+      TrackIndex[nGoodTracks] = itr;
+      nGoodTracks++;
+                                 
+      if(nGoodTracks > 2) break;  
+  }//Track loop
+  
+   nLepton=0; nPion=0; nHighPt=0;
+  mass[0]= -1; mass[1]= -1, mass[2]= -1;
+
+  if(nGoodTracks == 2){
+         fHistNeventsJPsi->Fill(5);
+         for(Int_t i=0; i<2; i++){
+               AliAODTrack *trk = aod->GetTrack(TrackIndex[i]);                
+               if(trk->Pt() > 1) nHighPt++;     
+               jRecTPCsignal[nLepton] = trk->GetTPCsignal();     
+               qLepton[nLepton] = trk->Charge();
+               if(jRecTPCsignal[nLepton] > 40 && jRecTPCsignal[nLepton] < 70){
+                               vLepton[nLepton].SetPtEtaPhiM(trk->Pt(), trk->Eta(), trk->Phi(), muonMass);
+                               mass[nLepton] = 0;
+                               }
+               if(jRecTPCsignal[nLepton] > 70 && jRecTPCsignal[nLepton] < 100){
+                               vLepton[nLepton].SetPtEtaPhiM(trk->Pt(), trk->Eta(), trk->Phi(), electronMass);
+                               mass[nLepton] = 1;
+                               }
+                       nLepton++;              
+               }               
+       if(nLepton == 2){
+               if(qLepton[0]*qLepton[1] > 0) fHistNeventsJPsi->Fill(6);
+               if(qLepton[0]*qLepton[1] < 0){
+                       fHistNeventsJPsi->Fill(7);
+                       if(nHighPt > 0){
+                               fHistNeventsJPsi->Fill(8);
+                               fHistTPCsignalJPsi->Fill(jRecTPCsignal[0],jRecTPCsignal[1]);
+                               if(nHighPt == 2) fHistNeventsJPsi->Fill(9);
+                               if(mass[0] == mass[1] && mass[0] != -1) {
+                                       fHistNeventsJPsi->Fill(10);
+                                       vCandidate = vLepton[0]+vLepton[1];
+                                       if( vCandidate.M() > 2.8 && vCandidate.M() < 3.2) fHistDiLeptonPtJPsi->Fill(vLepton[0].Pt(),vLepton[1].Pt());
+                                       if(mass[0] == 0) {
+                                               fHistDiMuonMass->Fill(vCandidate.M());
+                                               fHistNeventsJPsi->Fill(11);
+                                               }
+                                       if(mass[0] == 1) {
+                                               fHistDiElectronMass->Fill(vCandidate.M());
+                                               fHistNeventsJPsi->Fill(12);
+                                               }
+                                       }
+                               }
+                       }
+               }
+  }
+  
   PostData(4, fListHist);
 
 }
@@ -524,6 +590,9 @@ void AliAnalysisTaskUpcPsi2s::RunAODtree()
   //trigger inputs
   fL0inputs = aod->GetHeader()->GetL0TriggerInputs();
   fL1inputs = aod->GetHeader()->GetL1TriggerInputs();
+  
+  //TOF trigger info (0OMU)
+  
 
   //Event identification
   fPerNum = aod ->GetPeriodNumber();
@@ -533,6 +602,16 @@ void AliAnalysisTaskUpcPsi2s::RunAODtree()
   //primary vertex
   AliAODVertex *fAODVertex = aod->GetPrimaryVertex();
   fVtxContrib = fAODVertex->GetNContributors();
+  fVtxPosX = fAODVertex->GetX();
+  fVtxPosY = fAODVertex->GetY();
+  fVtxPosZ = fAODVertex->GetZ();
+  Double_t CovMatx[6];
+  fAODVertex->GetCovarianceMatrix(CovMatx); 
+  fVtxErrX = CovMatx[0];
+  fVtxErrY = CovMatx[1];
+  fVtxErrZ = CovMatx[2];
+  fVtxChi2 = fAODVertex->GetChi2();
+  fVtxNDF = fAODVertex->GetNDF();
 
   //Tracklets
   fNtracklets = aod->GetTracklets()->GetNumberOfTracklets();
@@ -548,79 +627,90 @@ void AliAnalysisTaskUpcPsi2s::RunAODtree()
   
   Int_t nGoodTracks=0;
   Int_t TrackIndex[5] = {-1,-1,-1,-1,-1};
-
-  //Two track loop
+  
+   //Four track loop
   for(Int_t itr=0; itr<aod ->GetNumberOfTracks(); itr++) {
     AliAODTrack *trk = aod->GetTrack(itr);
     if( !trk ) continue;
 
       if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
       if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
-      if(trk->GetTPCNcls() < 70)continue;
+      if(trk->GetTPCNcls() < 50)continue;
       if(trk->Chi2perNDF() > 4)continue;
-      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
       Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
+      AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+      if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      delete trk_clone;
       if(!trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
       if(TMath::Abs(dca[1]) > 2) continue;
-      if(TMath::Abs(dca[0]) > 0.2) continue;
-     
+
       TrackIndex[nGoodTracks] = itr;
       nGoodTracks++;
                                  
-      if(nGoodTracks > 2) break;  
+      if(nGoodTracks > 4) break;  
   }//Track loop
-
-  if(nGoodTracks == 2){
-         for(Int_t i=0; i<2; i++){
+  
+  
+  if(nGoodTracks == 4){
+         for(Int_t i=0; i<4; i++){
                AliAODTrack *trk = aod->GetTrack(TrackIndex[i]);
                
                Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
-               trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov);
-                               
-               trk->SetDCA(dca[0],dca[1]); //to get DCAxy trk->DCA(); to get DCAz trk->ZAtDCA();
-               new((*fJPsiAODTracks)[i]) AliAODTrack(*trk); 
+               AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+               if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+               delete trk_clone;
                
+               new((*fPsi2sAODTracks)[i]) AliAODTrack(*trk);
+               ((AliAODTrack*)((*fPsi2sAODTracks)[i]))->SetDCA(dca[0],dca[1]);//to get DCAxy trk->DCA(); to get DCAz trk->ZAtDCA();
+                               
                }
-  fJPsiTree ->Fill();
-  PostData(1, fJPsiTree);
+  fPsi2sTree ->Fill();
   }
-
+ //
   nGoodTracks = 0;
-  //Four track loop
+  //Two track loop
   for(Int_t itr=0; itr<aod ->GetNumberOfTracks(); itr++) {
     AliAODTrack *trk = aod->GetTrack(itr);
     if( !trk ) continue;
 
       if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
       if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
-      if(trk->GetTPCNcls() < 50)continue;
+      if(trk->GetTPCNcls() < 70)continue;
       if(trk->Chi2perNDF() > 4)continue;
+      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
       Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
-      if(!trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+      if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+      delete trk_clone;
       if(TMath::Abs(dca[1]) > 2) continue;
+      if(TMath::Abs(dca[0]) > 0.2) continue;
      
       TrackIndex[nGoodTracks] = itr;
       nGoodTracks++;
                                  
-      if(nGoodTracks > 4) break;  
+      if(nGoodTracks > 2) break;  
   }//Track loop
-  
-  
-  if(nGoodTracks == 4){
-         for(Int_t i=0; i<4; i++){
+
+  if(nGoodTracks == 2){
+         for(Int_t i=0; i<2; i++){
                AliAODTrack *trk = aod->GetTrack(TrackIndex[i]);
                
                Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};
-               trk->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov);
-               
-               trk->SetDCA(dca[0],dca[1]); //to get DCAxy trk->DCA(); to get DCAz trk->ZAtDCA();
-               new((*fPsi2sAODTracks)[i]) AliAODTrack(*trk); 
+               AliAODTrack* trk_clone=(AliAODTrack*)trk->Clone("trk_clone");
+               if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+               delete trk_clone;
+                               
+               new((*fJPsiAODTracks)[i]) AliAODTrack(*trk); 
+               ((AliAODTrack*)((*fJPsiAODTracks)[i]))->SetDCA(dca[0],dca[1]);//to get DCAxy trk->DCA(); to get DCAz trk->ZAtDCA();
                
                }
-  fPsi2sTree ->Fill();
-  PostData(2, fPsi2sTree);
+  fJPsiTree ->Fill();
   }
 
+  
+  PostData(1, fJPsiTree);
+  PostData(2, fPsi2sTree);
+
 }//RunAOD
 
 //_____________________________________________________________________________
@@ -637,10 +727,25 @@ void AliAnalysisTaskUpcPsi2s::RunESDtrig()
   
   if(trigger.Contains("CCUP4-B")) fHistUpcTriggersPerRun->Fill(fRunNum); //Upc triggers
   
-  if(trigger.Contains("CVLN-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN-B triggers
+  if(trigger.Contains("CVLN_B2-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN triggers - synchronously downscaled
+  if(trigger.Contains("CVLN_R1-B")) fHistCvlnTriggersPerRun->Fill(fRunNum); //CVLN triggers - randomly downscaled
   
   if(esd->GetHeader()->IsTriggerInputFired("1ZED")) fHistZedTriggersPerRun->Fill(fRunNum); //1ZED trigger inputs
   
+   //MB, Central and SemiCentral triggers
+  AliCentrality *centrality = esd->GetCentrality();
+  UInt_t selectionMask = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+  
+  //Double_t percentile = centrality->GetCentralityPercentile("V0M");
+  Double_t percentile = centrality->GetCentralityPercentileUnchecked("V0M");
+  
+  if(((selectionMask & AliVEvent::kMB) == AliVEvent::kMB) && percentile<80 && percentile>0) fHistMBTriggersPerRun->Fill(fRunNum);
+  
+  if(((selectionMask & AliVEvent::kCentral) == AliVEvent::kCentral) && percentile<6 && percentile>0) fHistCentralTriggersPerRun->Fill(fRunNum);
+
+  if(((selectionMask & AliVEvent::kSemiCentral) == AliVEvent::kSemiCentral) && percentile<50 && percentile>15) fHistSemiCentralTriggersPerRun->Fill(fRunNum);
+
+  
 PostData(3, fListTrig);
 
 }
@@ -692,7 +797,7 @@ void AliAnalysisTaskUpcPsi2s::RunESDhist()
   
   fZDCAenergy = fZDCdata->GetZN2TowerEnergy()[0];
   fZDCCenergy = fZDCdata->GetZN1TowerEnergy()[0];
-  if( fZDCAenergy > 12000 || fZDCCenergy > 12000) return;
+  if( fZDCAenergy > 8200 || fZDCCenergy > 8200) return;
   
   fHistNeventsJPsi->Fill(4);
   fHistNeventsPsi2s->Fill(4);
@@ -707,24 +812,27 @@ void AliAnalysisTaskUpcPsi2s::RunESDhist()
   Double_t jRecTPCsignal[5];
   Int_t mass[3]={-1,-1,-1};
 
 //Track loop
//Two Track loop
   for(Int_t itr=0; itr<esd ->GetNumberOfTracks(); itr++) {
     AliESDtrack *trk = esd->GetTrack(itr);
     if( !trk ) continue;
 
       if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
       if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
-      if(trk->GetTPCNcls() < 50)continue;
+      if(trk->GetTPCNcls() < 70)continue;
       if(trk->GetTPCchi2()/trk->GetTPCNcls() > 4)continue;
+      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
       Float_t dca[2] = {0.0,0.0}; AliExternalTrackParam cParam;
       if(!trk->RelateToVertex(fESDVertex, esd->GetMagneticField(),300.,&cParam)) continue;
       trk->GetImpactParameters(dca[0],dca[1]);
       if(TMath::Abs(dca[1]) > 2) continue;
+      if(TMath::Abs(dca[1]) > 0.2) continue;
       
       TrackIndex[nGoodTracks] = itr;
       nGoodTracks++;
-      if(nGoodTracks > 4) break;   
+      if(nGoodTracks > 2) break;   
   }//Track loop
+
   
   if(nGoodTracks == 2){
          fHistNeventsJPsi->Fill(5);
@@ -768,9 +876,28 @@ void AliAnalysisTaskUpcPsi2s::RunESDhist()
                        }
                }
   }
-  nLepton=0; nPion=0; nHighPt=0;
+  nGoodTracks = 0; nLepton=0; nPion=0; nHighPt=0;
   mass[0]= -1; mass[1]= -1, mass[2]= -1;
   
+    //Four Track loop
+  for(Int_t itr=0; itr<esd ->GetNumberOfTracks(); itr++) {
+    AliESDtrack *trk = esd->GetTrack(itr);
+    if( !trk ) continue;
+
+      if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
+      if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
+      if(trk->GetTPCNcls() < 50)continue;
+      if(trk->GetTPCchi2()/trk->GetTPCNcls() > 4)continue;
+      Float_t dca[2] = {0.0,0.0}; AliExternalTrackParam cParam;
+      if(!trk->RelateToVertex(fESDVertex, esd->GetMagneticField(),300.,&cParam)) continue;
+      trk->GetImpactParameters(dca[0],dca[1]);
+      if(TMath::Abs(dca[1]) > 2) continue;
+      
+      TrackIndex[nGoodTracks] = itr;
+      nGoodTracks++;
+      if(nGoodTracks > 4) break;   
+  }//Track loop
+  
   if(nGoodTracks == 4){
          fHistNeventsPsi2s->Fill(5);
          for(Int_t i=0; i<4; i++){
@@ -844,6 +971,10 @@ void AliAnalysisTaskUpcPsi2s::RunESDtree()
   //trigger inputs
   fL0inputs = esd->GetHeader()->GetL0TriggerInputs();
   fL1inputs = esd->GetHeader()->GetL1TriggerInputs();
+  
+  //TOF trigger info (0OMU)
+  fTOFtrig1 = esd->GetHeader()->IsTriggerInputFired("0OMU");
+  fTOFtrig2 = esd->GetHeader()->GetActiveTriggerInputs().Contains("0OMU") ? ((esd->GetHeader()) ? esd->GetHeader()->IsTriggerInputFired("0OMU") : kFALSE) : TESTBIT(esd->GetHeader()->GetL0TriggerInputs(), (kFALSE) ? 21 : 9);
 
   //Event identification
   fPerNum = esd->GetPeriodNumber();
@@ -853,6 +984,16 @@ void AliAnalysisTaskUpcPsi2s::RunESDtree()
   //primary vertex
   AliESDVertex *fESDVertex = (AliESDVertex*) esd->GetPrimaryVertex();
   fVtxContrib = fESDVertex->GetNContributors();
+  fVtxPosX = fESDVertex->GetX();
+  fVtxPosY = fESDVertex->GetY();
+  fVtxPosZ = fESDVertex->GetZ();
+  Double_t CovMatx[6];
+  fESDVertex->GetCovarianceMatrix(CovMatx); 
+  fVtxErrX = CovMatx[0];
+  fVtxErrY = CovMatx[1];
+  fVtxErrZ = CovMatx[2];
+  fVtxChi2 = fESDVertex->GetChi2();
+  fVtxNDF = fESDVertex->GetNDF();
 
   //Tracklets
   fNtracklets = esd->GetMultiplicity()->GetNumberOfTracklets();
@@ -869,23 +1010,25 @@ void AliAnalysisTaskUpcPsi2s::RunESDtree()
   Int_t nGoodTracks=0;
   Int_t TrackIndex[5] = {-1,-1,-1,-1,-1};
   
-  //Track loop
+  //Two Track loop
   for(Int_t itr=0; itr<esd ->GetNumberOfTracks(); itr++) {
     AliESDtrack *trk = esd->GetTrack(itr);
     if( !trk ) continue;
 
       if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
       if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
-      if(trk->GetTPCNcls() < 50)continue;
+      if(trk->GetTPCNcls() < 70)continue;
       if(trk->GetTPCchi2()/trk->GetTPCNcls() > 4)continue;
+      if((!trk->HasPointOnITSLayer(0))&&(!trk->HasPointOnITSLayer(1))) continue;
       Float_t dca[2] = {0.0,0.0}; AliExternalTrackParam cParam;
       if(!trk->RelateToVertex(fESDVertex, esd->GetMagneticField(),300.,&cParam)) continue;
       trk->GetImpactParameters(dca[0],dca[1]);
       if(TMath::Abs(dca[1]) > 2) continue;
+      if(TMath::Abs(dca[1]) > 0.2) continue;
       
       TrackIndex[nGoodTracks] = itr;
       nGoodTracks++;
-      if(nGoodTracks > 4) break;   
+      if(nGoodTracks > 2) break;   
   }//Track loop
 
   if(nGoodTracks == 2){
@@ -899,9 +1042,28 @@ void AliAnalysisTaskUpcPsi2s::RunESDtree()
                
                }
   fJPsiTree ->Fill();
-  PostData(1, fJPsiTree);
   }
   
+  nGoodTracks = 0;
+  //Four track loop
+  for(Int_t itr=0; itr<esd ->GetNumberOfTracks(); itr++) {
+    AliESDtrack *trk = esd->GetTrack(itr);
+    if( !trk ) continue;
+
+      if(!(trk->GetStatus() & AliESDtrack::kTPCrefit) ) continue;
+      if(!(trk->GetStatus() & AliESDtrack::kITSrefit) ) continue;
+      if(trk->GetTPCNcls() < 50)continue;
+      if(trk->GetTPCchi2()/trk->GetTPCNcls() > 4)continue;
+      Float_t dca[2] = {0.0,0.0}; AliExternalTrackParam cParam;
+      if(!trk->RelateToVertex(fESDVertex, esd->GetMagneticField(),300.,&cParam)) continue;
+      trk->GetImpactParameters(dca[0],dca[1]);
+      if(TMath::Abs(dca[1]) > 2) continue;
+      
+      TrackIndex[nGoodTracks] = itr;
+      nGoodTracks++;
+      if(nGoodTracks > 4) break;   
+  }//Track loop
+  
   if(nGoodTracks == 4){
          for(Int_t i=0; i<4; i++){
                AliESDtrack *trk = esd->GetTrack(TrackIndex[i]);
@@ -913,8 +1075,10 @@ void AliAnalysisTaskUpcPsi2s::RunESDtree()
                
                }
   fPsi2sTree ->Fill();
-  PostData(2, fPsi2sTree);
   }
+  
+  PostData(1, fJPsiTree);
+  PostData(2, fPsi2sTree);
 
 }//RunESD
 
index e542b6d0e9a09da22560973a6f359d4cc4b9741a..ae87cf49b14f08867cf1633e56c82499942bc882 100644 (file)
@@ -47,7 +47,11 @@ class AliAnalysisTaskUpcPsi2s : public AliAnalysisTaskSE {
   //trigger
   Bool_t fTrigger[ntrg];
   UInt_t fL0inputs, fL1inputs;
+  Bool_t fTOFtrig1, fTOFtrig2;
   Int_t fVtxContrib;
+  Double_t fVtxPosX,fVtxPosY,fVtxPosZ;
+  Double_t fVtxErrX,fVtxErrY,fVtxErrZ;
+  Double_t fVtxChi2,fVtxNDF;
   UShort_t fBCrossNum, fNtracklets;
   //vzero, zdc
   Double_t fZDCAenergy, fZDCCenergy;
@@ -66,6 +70,9 @@ class AliAnalysisTaskUpcPsi2s : public AliAnalysisTaskSE {
   TH1D *fHistUpcTriggersPerRun;
   TH1D *fHistZedTriggersPerRun;
   TH1D *fHistCvlnTriggersPerRun;
+  TH1D *fHistMBTriggersPerRun;
+  TH1D *fHistCentralTriggersPerRun;
+  TH1D *fHistSemiCentralTriggersPerRun;
   
   TList *fListHist;
   TH1D *fHistNeventsJPsi; 
index 1b30028ca5eb83f134892b46eb999d04cfffd6fd..0f5bca4f1d5b6fd9d93b65f65a51f4fad29d4f2e 100644 (file)
@@ -506,8 +506,11 @@ Bool_t AliExternalTrackParam::CorrectForMeanMaterial
   // "anglecorr" - switch for the angular correction
   // "Bethe" - function calculating the energy loss (GeV/(g/cm^2)) 
   //------------------------------------------------------------------
-  
   Double_t bg=GetP()/mass;
+  if (bg<kAlmost0) {
+    AliDebug(2,Form("Non-positive beta*gamma = %e, mass = %e",bg,mass));
+    return kFALSE;
+  }
   Double_t dEdx=Bethe(bg);
 
   return CorrectForMeanMaterialdEdx(xOverX0,xTimesRho,mass,dEdx,anglecorr);
index d4c0bb0725b49cba77fe8952c5c28985856fd6e0..81274ba2346f6639c813f6c0c45e871b9dd44f66 100644 (file)
@@ -553,16 +553,14 @@ void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass, Int_t run)
   }
   
   // Set up TPC multiplicity for PbPb
-  //TODO Will NOT give the desired number for AODs -> Needs new variable/function in future.
-  // Fatal, if AOD event and correction enabled
-  //printf("DETECTED class: %s (%d)\n\n\n\n", event->IsA()->GetName(), fUseTPCMultiplicityCorrection);//TODO
-  if (fUseTPCMultiplicityCorrection && strcmp(event->IsA()->GetName(), "AliESDEvent") != 0) {
-    AliFatal("TPC multiplicity correction is enabled, but will NOT work for AOD events, only for ESD => Disabled multiplicity correction!");
-    fUseTPCMultiplicityCorrection = kFALSE;
+  if (fUseTPCMultiplicityCorrection) {
+    Int_t numESDtracks = event->GetNumberOfESDTracks();
+    if (numESDtracks < 0) {
+      AliError("Cannot obtain event multiplicity (number of ESD tracks < 0). If you are using AODs, this might be a too old production. Please disable the multiplicity correction to get a reliable PID result!");
+      numESDtracks = 0;
+    }
+    fTPCResponse.SetCurrentEventMultiplicity(numESDtracks);
   }
-  
-  if (fUseTPCMultiplicityCorrection)
-    fTPCResponse.SetCurrentEventMultiplicity(event->GetNumberOfTracks());
   else
     fTPCResponse.SetCurrentEventMultiplicity(0);
   
@@ -1301,13 +1299,29 @@ void AliPIDResponse::SetTPCParametrisation()
 
 
   //
-  // Setup multiplicity correction
+  // Setup multiplicity correction (only used for non-pp collisions)
   //
-  if (fUseTPCMultiplicityCorrection && !(fBeamType.CompareTo("PP") == 0)) {
+  
+  const Bool_t isPP = (fBeamType.CompareTo("PP") == 0);
+  
+  // 2013 pPb data taking at low luminosity
+  const Bool_t isPPb2013LowLuminosity = period.Contains("LHC13B") || period.Contains("LHC13C") || period.Contains("LHC13D");
+  // PbPb 2010, period 10h.pass2
+  //TODO Needs further development const Bool_t is10hpass2 = period.Contains("LHC10H") && recopass == 2;
+  
+  // If correction is available, but disabled (highly NOT recommended!), print warning
+  if (!fUseTPCMultiplicityCorrection && !isPP) {
+    //TODO: Needs further development if (is10hpass2 || isPPb2013LowLuminosity) {
+    if (isPPb2013LowLuminosity) {
+      AliWarning("Mulitplicity correction disabled, but correction parameters for this period exist. It is highly recommended to use enable the correction. Otherwise the splines might be off!");
+    }
+  }
+  
+  if (fUseTPCMultiplicityCorrection && !isPP) {
     AliInfo("Multiplicity correction enabled!");
     
     //TODO After testing, load parameters from outside       
-    /*TODO now correction for MC
+    /*TODO no correction for MC
     if (period.Contains("LHC11A10"))  {//LHC11A10A
       AliInfo("Using multiplicity correction parameters for 11a10!");
       fTPCResponse.SetParameterMultiplicityCorrection(0, 6.90133e-06);
@@ -1325,8 +1339,8 @@ void AliPIDResponse::SetTPCParametrisation()
       fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, -6.36337e-01);
       fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.13479e-02);
     }
-    else*/ if (period.Contains("LHC13B") || period.Contains("LHC13C") || period.Contains("LHC13D"))  {// 2013 pPb data taking at low luminosity
-      AliInfo("Using multiplicity correction parameters for 13b.pass2!");
+    else*/ if (isPPb2013LowLuminosity)  {// 2013 pPb data taking at low luminosity
+      AliInfo("Using multiplicity correction parameters for 13b.pass2 (at least also valid for 13{c,d} and pass 3)!");
       
       fTPCResponse.SetParameterMultiplicityCorrection(0, -5.906e-06);
       fTPCResponse.SetParameterMultiplicityCorrection(1, -5.064e-04);
@@ -1360,7 +1374,8 @@ void AliPIDResponse::SetTPCParametrisation()
       fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.47931e-02);
       */
     }
-    else if (period.Contains("LHC10H") && recopass == 2) {    
+    /*TODO: Needs further development
+    else if (is10hpass2) {    
       AliInfo("Using multiplicity correction parameters for 10h.pass2!");
       fTPCResponse.SetParameterMultiplicityCorrection(0, 3.21636e-07);
       fTPCResponse.SetParameterMultiplicityCorrection(1, -6.65876e-04);
@@ -1377,6 +1392,7 @@ void AliPIDResponse::SetTPCParametrisation()
       fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, -3.20788e-01);
       fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.07345e-02);
     }
+    */
     else {
       AliError(Form("Multiplicity correction is enabled, but no multiplicity correction parameters have been found for period %s.pass%d -> Mulitplicity correction DISABLED!", period.Data(), recopass));
       fUseTPCMultiplicityCorrection = kFALSE;
@@ -1398,21 +1414,18 @@ void AliPIDResponse::SetTPCParametrisation()
     fTPCResponse.ResetMultiplicityCorrectionFunctions();
   }
   
-  /*
-  //TODO NOW start
-  for (Int_t i = 0; i <= 4 + 1; i++) {
-    printf("parMultCorr: %d, %e\n", i, fTPCResponse.GetMultiplicityCorrectionFunction()->GetParameter(i));
-  }
-  for (Int_t j = 0; j <= 2 + 1; j++) {
-    printf("parMultCorrTanTheta: %d, %e\n", j, fTPCResponse.GetMultiplicityCorrectionFunctionTanTheta()->GetParameter(j));
-  }
-  for (Int_t j = 0; j <= 3 + 1; j++) {
-    printf("parMultSigmaCorr: %d, %e\n", j, fTPCResponse.GetMultiplicitySigmaCorrectionFunction()->GetParameter(j));
+  if (fUseTPCMultiplicityCorrection) {
+    for (Int_t i = 0; i <= 4 + 1; i++) {
+      AliInfo(Form("parMultCorr: %d, %e", i, fTPCResponse.GetMultiplicityCorrectionFunction()->GetParameter(i)));
+    }
+    for (Int_t j = 0; j <= 2 + 1; j++) {
+      AliInfo(Form("parMultCorrTanTheta: %d, %e", j, fTPCResponse.GetMultiplicityCorrectionFunctionTanTheta()->GetParameter(j)));
+    }
+    for (Int_t j = 0; j <= 3 + 1; j++) {
+      AliInfo(Form("parMultSigmaCorr: %d, %e", j, fTPCResponse.GetMultiplicitySigmaCorrectionFunction()->GetParameter(j)));
+    }
   }
   
-  //TODO NOW end
-  */
-  
   //
   // Setup old resolution parametrisation
   //
index cbdea74c9ef597a715910d10c6807e0367eb9256..33270a98e0e4e1cd7fadd4d0db16302c28b63cf4 100644 (file)
@@ -91,7 +91,7 @@ public:
   virtual Float_t NumberOfSigmasTPC  (const AliVParticle *track, AliPID::EParticleType type, AliTPCPIDResponse::ETPCdEdxSource dedxSource) const;
   virtual Float_t NumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const;
   virtual Float_t NumberOfSigmasTOF  (const AliVParticle *track, AliPID::EParticleType type) const;
-  virtual Float_t NumberOfSigmasTOF  (const AliVParticle *track, AliPID::EParticleType type, const Float_t /*timeZeroTOF*/) const { return NumberOfSigmasTOF(track,type); }
+  virtual Float_t NumberOfSigmasTOF  (const AliVParticle *track, AliPID::EParticleType type, Float_t /*timeZeroTOF*/) const { return NumberOfSigmasTOF(track,type); }
   virtual Float_t NumberOfSigmasHMPID(const AliVParticle *track, AliPID::EParticleType type) const;
   virtual Float_t NumberOfSigmasEMCAL(const AliVParticle *track, AliPID::EParticleType type) const;
 
index ff8be78c2125f69bdcc353e38c3d53652c30fb75..547c4a9c346d1c9fa7496b8bbe34e3641e4920a8 100644 (file)
@@ -313,7 +313,7 @@ void AliTPCPIDResponse::SetSigma(Float_t res0, Float_t resN2) {
 }
 
 //_________________________________________________________________________
-Double_t AliTPCPIDResponse::GetExpectedSignal(const Float_t mom,
+Double_t AliTPCPIDResponse::GetExpectedSignal(Float_t mom,
                                              AliPID::EParticleType n) const {
   //
   // Deprecated function (for backward compatibility). Please use 
@@ -347,8 +347,8 @@ Double_t AliTPCPIDResponse::GetExpectedSignal(const Float_t mom,
 }
 
 //_________________________________________________________________________
-Double_t AliTPCPIDResponse::GetExpectedSigma(const Float_t mom, 
-                                             const Int_t nPoints,
+Double_t AliTPCPIDResponse::GetExpectedSigma(Float_t mom, 
+                                             Int_t nPoints,
                                              AliPID::EParticleType n) const {
   //
   // Deprecated function (for backward compatibility). Please use 
@@ -1064,7 +1064,7 @@ Double_t AliTPCPIDResponse::GetTrackTanTheta(const AliVTrack *track) const
 
 
 //_________________________________________________________________________
-Double_t AliTPCPIDResponse::GetMultiplicityCorrectionFast(const AliVTrack *track, const Double_t dEdxExpected, const Int_t multiplicity) const
+Double_t AliTPCPIDResponse::GetMultiplicityCorrectionFast(const AliVTrack *track, Double_t dEdxExpected, Int_t multiplicity) const
 {
   // NOTE: For expert use only -> Non-experts are advised to use the function without the "Fast" suffix or stick to AliPIDResponse directly.
   //
@@ -1220,7 +1220,7 @@ Double_t AliTPCPIDResponse::GetEtaAndMultiplicityCorrectedTrackdEdx(const AliVTr
 
 
 //_________________________________________________________________________
-Double_t AliTPCPIDResponse::GetMultiplicitySigmaCorrectionFast(const Double_t dEdxExpected, const Int_t multiplicity) const
+Double_t AliTPCPIDResponse::GetMultiplicitySigmaCorrectionFast(Double_t dEdxExpected, Int_t multiplicity) const
 {
   // NOTE: For expert use only -> Non-experts are advised to use the function without the "Fast" suffix or stick to AliPIDResponse directly.
   //
index ee3f9b95e9eede4529a25521ba7f73e0ff9398c7..e981afba31ac64f74519a12fc446567c3070bfe2 100644 (file)
@@ -132,9 +132,9 @@ public:
   // Fast functions for expert use only
   Double_t GetEtaCorrectionFast(const AliVTrack *track, Double_t dEdxSplines) const;
   
-  Double_t GetMultiplicityCorrectionFast(const AliVTrack *track, const Double_t dEdxExpected, const Int_t multiplicity) const;
+  Double_t GetMultiplicityCorrectionFast(const AliVTrack *track, Double_t dEdxExpected, Int_t multiplicity) const;
   
-  Double_t GetMultiplicitySigmaCorrectionFast(const Double_t dEdxExpected, const Int_t multiplicity) const;
+  Double_t GetMultiplicitySigmaCorrectionFast(Double_t dEdxExpected, Int_t multiplicity) const;
   
   Double_t GetSigmaPar1Fast(const AliVTrack *track, AliPID::EParticleType species,
                             Double_t dEdx, const TSpline3* responseFunction) const;
@@ -190,13 +190,13 @@ public:
   void ResetSplines();
 
   //OLD
-  Double_t GetExpectedSignal(const Float_t mom,
+  Double_t GetExpectedSignal(Float_t mom,
                      AliPID::EParticleType n=AliPID::kKaon) const;
-  Double_t GetExpectedSigma(const Float_t mom, const Int_t nPoints,
+  Double_t GetExpectedSigma(Float_t mom, Int_t nPoints,
                             AliPID::EParticleType n=AliPID::kKaon) const;
-  Float_t  GetNumberOfSigmas(const Float_t mom, 
-                             const Float_t dEdx, 
-                                              const Int_t nPoints,
+  Float_t  GetNumberOfSigmas(Float_t mom, 
+                             Float_t dEdx, 
+                            Int_t nPoints,
                              AliPID::EParticleType n=AliPID::kKaon) const {
     //
     // Deprecated function (for backward compatibility). Please use 
index 97d57984180995ce7b76af77930f66bfc0ac765c..1b2e64a78146fe9dd02775124d7282a176429adb 100644 (file)
@@ -202,7 +202,7 @@ Double_t AliTRDPIDResponse::GetProbabilitySingleLayer(Int_t species, Double_t pl
   case kLQ2D: // 2D LQ
       {
          if(species==0||species==2){ // references only for electrons and pions
-             Double_t error;
+             Double_t error = 0.;
              Double_t point[kNslicesLQ2D];
              for(Int_t idim=0;idim<kNslicesLQ2D;idim++){point[idim]=dEdx[idim];}
 
index 79ead135afa66752b1e4dd8169db26f37875ed78..f54fcbb346a1b538f7548f6287532bab132a6b2e 100644 (file)
@@ -89,10 +89,11 @@ public:
   virtual void SetEMCALcluster(Int_t)       {;}
   virtual Bool_t IsEMCAL()            const {return kFALSE;}
 
-  virtual Double_t GetTrackPhiOnEMCal() const {return -999;}
-  virtual Double_t GetTrackEtaOnEMCal() const {return -999;}
-  virtual Double_t GetTrackPtOnEMCal() const {return -999;}
-  virtual Double_t GetTrackPOnEMCal() const {return -999;}
+  virtual Double_t GetTrackPhiOnEMCal()  const {return -999;}
+  virtual Double_t GetTrackEtaOnEMCal()  const {return -999;}
+  virtual Double_t GetTrackPtOnEMCal()   const {return -999;}
+  virtual Double_t GetTrackPOnEMCal()    const {return -999;}
+  virtual Bool_t IsExtrapolatedToEMCAL() const {return GetTrackPtOnEMCal()!=-999;} 
   virtual void SetTrackPhiEtaPtOnEMCal(Double_t,Double_t,Double_t=-999) {;}
 
   virtual Int_t GetPHOScluster()      const {return -1;}
index 999fd3222ca7b61851af430624d4afa755eee47f..1f47c83015e1a60fe471022c833880bd80e14719 100644 (file)
@@ -436,4 +436,6 @@ void AliTRDReconstructor::ResetContainers() const
     AliDebug(1, Form("Removing %3d online tracks @ %p", fgTracks->GetEntriesFast(), (void*)fgTracks));
     fgTracks->Clear();
   }
+  for (Int_t iSector = 0; iSector < 18; iSector++)
+    fgTriggerFlags.SetFlags(iSector, 0);
 }
index 1d941f46c451cb499fabf038deee9e04eacc8605..107cc857da0dd6985643e0ad63181f853f954ba8 100644 (file)
@@ -55,7 +55,7 @@ AliTRDgtuSim::AliTRDgtuSim(AliRunLoader *rl)
   : TObject(),
   fRunLoader(rl),
   fFeeParam(AliTRDfeeParam::Instance()),
-  fTMU(0x0),
+  fTMU(new AliTRDgtuTMU()),
   fTrackletArray(0x0)
 {
 
@@ -68,6 +68,7 @@ AliTRDgtuSim::~AliTRDgtuSim()
   if (fTrackletArray)
     fTrackletArray->Clear();
   delete fTrackletArray;
+  delete fTMU;
 }
 
 Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t noev)
@@ -90,7 +91,8 @@ Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t
   Int_t iEvent = -1;
   Int_t evcnt = -1;
 
-  fTMU = 0x0;
+  fTMU->Reset();
+  Bool_t pendingTracklets = kFALSE;;
 
   TClonesArray trklArray("AliTRDtrackletWord", 100);
   TClonesArray trklArrayGTU("AliTRDtrackletGTU", 100);
@@ -119,7 +121,7 @@ Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t
     if ((iEvent != iEventPrev) ||
        (iStack != iStackPrev) ||
        (iSec != iSecPrev)) {
-      if(fTMU) {
+      if(pendingTracklets) {
        TList *listOfTracks = new TList();
        fTMU->SetStack(iStackPrev);
        fTMU->SetSector(iSecPrev);
@@ -128,12 +130,10 @@ Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t
        WriteTracksToDataFile(listOfTracks, iEventPrev);
        if (listOfTracks->GetEntries() > 0)
          AliDebug(2,Form("   %4.1f GeV/c", ((AliTRDtrackGTU*) listOfTracks->At(0))->GetPt() ));
-       delete fTMU;
-       fTMU = new AliTRDgtuTMU();
+       fTMU->Reset();
        delete listOfTracks;
-       listOfTracks = 0x0;
       } else {
-       fTMU = new AliTRDgtuTMU();
+       pendingTracklets = kTRUE;
       }
       iStackPrev = iStack;
       iSecPrev = iSec;
@@ -158,15 +158,14 @@ Bool_t AliTRDgtuSim::RunGTUFromTrackletFile(TString filename, Int_t event, Int_t
     delete tokens;
   }
 
-  if (fTMU && evcnt < noev) {
+  if (pendingTracklets && evcnt < noev) {
     TList *listOfTracks = new TList();
     fTMU->SetStack(iStackPrev);
     fTMU->SetSector(iSecPrev);
     fTMU->RunTMU(listOfTracks);
     WriteTracksToDataFile(listOfTracks, iEventPrev);
-    delete fTMU;
     delete listOfTracks;
-    fTMU = 0x0;
+    fTMU->Reset();
   }
 
   AliInfo(Form("Analyzed %i events", evcnt));
@@ -202,31 +201,28 @@ Bool_t AliTRDgtuSim::RunGTU(AliLoader *loader, AliESDEvent *esd, Int_t label, In
     Int_t iStack = -1;
     Int_t iLink = -1;
 
-    if (fTMU) {
-       delete fTMU;
-       fTMU = 0x0;
-    }
-
+    fTMU->Reset();
+    Bool_t pendingTracklets = kFALSE;
     TList *listOfTracks = new TList();
 
     TIter next(fTrackletArray);
-
     while (AliTRDtrackletGTU *trkl = (AliTRDtrackletGTU*) next()) {
        iSec = trkl->GetDetector() / 30;
        iStack = (trkl->GetDetector() % 30) / 6;
        iLink = trkl->GetHCId() % 12;
 
        if (iStack != iStackPrev || iSec != iSecPrev) {
-           if(fTMU) {
+           if(pendingTracklets) {
                fTMU->SetStack(iStackPrev);
                fTMU->SetSector(iSecPrev);
                fTMU->RunTMU(listOfTracks, 0x0, outLabel);
-               WriteTracksToLoader(listOfTracks);
+               if (loader)
+                 WriteTracksToLoader(listOfTracks);
                WriteTracksToESD(listOfTracks, esd);
+               listOfTracks->Clear();
                fTMU->Reset();
-               listOfTracks->Delete();
            } else {
-               fTMU = new AliTRDgtuTMU();
+             pendingTracklets = kTRUE;
            }
            iStackPrev = iStack;
            iSecPrev = iSec;
@@ -239,15 +235,15 @@ Bool_t AliTRDgtuSim::RunGTU(AliLoader *loader, AliESDEvent *esd, Int_t label, In
        }
     }
 
-    if (fTMU) {
+    if (pendingTracklets) {
        fTMU->SetStack(iStackPrev);
        fTMU->SetSector(iSecPrev);
        fTMU->RunTMU(listOfTracks, 0x0, outLabel);
-       WriteTracksToLoader(listOfTracks);
+       if (loader)
+         WriteTracksToLoader(listOfTracks);
        WriteTracksToESD(listOfTracks, esd);
-       delete fTMU;
-       fTMU = 0x0;
-       listOfTracks->Delete();
+       listOfTracks->Clear();
+       fTMU->Reset();
     }
 
     delete listOfTracks;
index 7755e9a28975c466d782d4d89632632dbdc2a0bd..abb69af89dc314ed6f5c04012fe9382eae14631d 100644 (file)
@@ -46,6 +46,7 @@ AliTRDgtuTMU::AliTRDgtuTMU(Int_t stack, Int_t sector) :
   fTracklets(0x0),
   fTrackletsPostInput(0x0),
   fZChannelTracklets(0x0),
+  fTrackArray(new TClonesArray("AliTRDtrackGTU", 50)),
   fTracks(0x0),
   fGtuParam(0x0),
   fStack(-1),
@@ -88,6 +89,8 @@ AliTRDgtuTMU::~AliTRDgtuTMU()
     delete [] fTracks[zch];
   }
   delete [] fTracks;
+  delete fTrackArray;
+
   for (Int_t layer = 0; layer < fGtuParam->GetNLayers(); layer++) {
     delete [] fZChannelTracklets[layer];
     delete fTrackletsPostInput[layer];
@@ -137,6 +140,8 @@ Bool_t AliTRDgtuTMU::Reset()
     }
   }
 
+  fTrackArray->Delete();
+
   // delete all added tracklets
   for (Int_t iLink = 0; iLink < fGtuParam->GetNLinks(); iLink++) {
     fTracklets[iLink]->Clear();
@@ -527,7 +532,7 @@ Bool_t AliTRDgtuTMU::RunTrackFinder(Int_t zch, TList* /* ListOfTracks */)
 
        if (nHits >= 4) {
         // ----- track registration -----
-        AliTRDtrackGTU *track = new AliTRDtrackGTU();
+        AliTRDtrackGTU *track = new ((*fTrackArray)[fTrackArray->GetEntriesFast()]) AliTRDtrackGTU();
         track->SetSector(fSector);
         track->SetStack(fStack);
         for (Int_t layer = 0; layer < fGtuParam->GetNLayers(); layer++ ) {
@@ -551,8 +556,6 @@ Bool_t AliTRDgtuTMU::RunTrackFinder(Int_t zch, TList* /* ListOfTracks */)
             track->SetRefLayerIdx(refLayerIdx);
             fTracks[zch][refLayerIdx].Add(track);
         }
-        else
-          delete track;
        }
 
        if ( (nUnc != 0) && (nUnc + nHits >= 4) ) // could this position of the reference layer give some track //??? special check in case of hit?
@@ -901,7 +904,25 @@ Bool_t AliTRDgtuTMU::RunTrackMerging(TList* ListOfTracks)
 
     TIter next(tracksZUniqueStage0);
     while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) next()) {
-       tracksZSplitted[(trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) % 2]->Add(trk);
+      if ((trk->GetZChannel() < 0) ||
+         (trk->GetZChannel() > 2) ||
+         (trk->GetZSubChannel() < 0) ||
+         (trk->GetZSubChannel() > 6)) {
+       AliError(Form("track with invalid z-channel information at %p: zch = %i, subchannel = %i",
+                     trk, trk->GetZChannel(), trk->GetZSubChannel()));
+       trk->Dump();
+      }
+      Int_t idx = (trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) % 2;
+      if ((idx < 0) || (idx > 1)) {
+       AliError(Form("invalid index %i null", idx));
+       trk->Dump();
+       continue;
+      }
+      if (!tracksZSplitted[idx]) {
+       AliError(Form("array pointer %i null", idx));
+       continue;
+      }
+      tracksZSplitted[idx]->Add(trk);
     }
 
     for (Int_t i = 0; i < 2; i++) {
@@ -1154,10 +1175,7 @@ Bool_t AliTRDgtuTMU::Uniquifier(const TList *inlist, TList *outlist)
     AliTRDtrackGTU *trkStage1 = 0x0;
 
     do {
-      if (trkStage0 != trkStage1)
-       delete trkStage0;
-
-       trkStage0 = (AliTRDtrackGTU*) next();
+        trkStage0 = (AliTRDtrackGTU*) next();
 
        Bool_t tracksEqual = kFALSE;
        if (trkStage0 != 0 && trkStage1 != 0) {
@@ -1170,10 +1188,8 @@ Bool_t AliTRDgtuTMU::Uniquifier(const TList *inlist, TList *outlist)
        }
 
        if (tracksEqual) {
-         if (trkStage0->GetNTracklets() >= trkStage1->GetNTracklets()) {
-           delete trkStage1;
+         if (trkStage0->GetNTracklets() >= trkStage1->GetNTracklets())
            trkStage1 = trkStage0;
-         }
        }
        else {
            if (trkStage1 != 0x0)
index ac87bb8e180513b15bbe3964a348c93b5b0f0748..9875eb67ec53eca5a7de49cfd204640f3511a4c5 100644 (file)
 //--------------------------------------------------------------------
 
 #include "TObject.h"
-#include "TList.h"
 
 #include "AliTRDtrackletGTU.h"
 #include "AliTRDgtuParam.h"
 
 class TTree;
+class TList;
+class TClonesArray;
 class TBranch;
 class AliTRDtrackGTU;
 class AliESDEvent;
@@ -51,6 +52,7 @@ protected:
   TObjArray **fTrackletsPostInput; // holding all tracklets of a layer
                                   // after sorting/calculation in input units
   TList **fZChannelTracklets; // holding all tracklets for layer and z-channel
+  TClonesArray *fTrackArray; // array of tracks
   TList **fTracks; // lists of tracks
   AliTRDgtuParam *fGtuParam; // pointer to the instance of the GtuParam class
 
index 3384c5364a7962fb418abae70cd1bebbf9e1860a..985b0c5a470070452af9f5e0d3e63c2c74ca4b88 100644 (file)
@@ -200,10 +200,20 @@ Int_t AliTRDtrackGTU::GetZSubChannel()
 // returns the z-subchannel
 
   if (fZSubChannel < 0) {
-    for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
-    {
-      if (IsTrackletInLayer(layer))
-       fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
+    for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++) {
+      if (IsTrackletInLayer(layer)) {
+       AliTRDtrackletGTU *trkl = (AliTRDtrackletGTU*) (*fTracklets)[layer];
+       if (trkl) {
+         if ((fZSubChannel > -1) &&
+             (fZSubChannel != trkl->GetSubChannel(GetZChannel())))
+           AliError(Form("found inconsistent z-subchannels: track = %i/%i, trkl = %i",
+                         GetZChannel(), fZSubChannel, trkl->GetSubChannel(GetZChannel())));
+         fZSubChannel = trkl->GetSubChannel(GetZChannel());
+       }
+       else {
+         AliError("no tracklet where one should be according to layer mask");
+       }
+      }
     }
   }
   return fZSubChannel;
index f6672fc57a46ad055b8c9942b93fddf4ae200dd1..4b3a2e2ebf704908a339a9dc01cec52d5e6e6ecf 100644 (file)
@@ -850,6 +850,11 @@ AliTRDtrapConfig::AliTRDtrapValue::AliTRDtrapValue() :
   fValid[0] = kTRUE;
 }
 
+AliTRDtrapConfig::AliTRDtrapValue::~AliTRDtrapValue()
+{
+  delete [] fData;
+  delete [] fValid;
+}
 
 Bool_t AliTRDtrapConfig::AliTRDtrapValue::Allocate(Alloc_t alloc)
 {
index ed418a8c5a0167eece693e32f9bfcfb497a7099f..777710a49608c6e74beeab3d47a87ce0168c3e44 100644 (file)
@@ -526,7 +526,7 @@ class AliTRDtrapConfig : public TNamed
   class AliTRDtrapValue : public TObject {
   public:
     AliTRDtrapValue();
-    virtual ~AliTRDtrapValue() {}
+    virtual ~AliTRDtrapValue();
 
     virtual Bool_t Allocate(Alloc_t mode);
 
index 937d716daa05cd6832ab43769a086cb1da6d4d0b..8ced6a1ffd6993abbb791e7638558bc9421b9378 100644 (file)
@@ -183,28 +183,39 @@ foreach(detector ${ONLINEDETECTORS} )
          endif(DANAME)
        add_dependencies(${BASIC_TARGET} ${DATARGETNAME})  
        add_dependencies(${BASIC_RPM} ${DATARGETNAME}-rpm) 
-        set(DATARGETDIR "${DAINSTALL}/${DAMODULE}/tgt_$ENV{ALICE_TARGET}")
-         file(MAKE_DIRECTORY ${DATARGETDIR})
-         set(DAOBJ "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.o")
-         set(DASRC "${DAMODULE}/${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx")
-         set(DALIB "${DAMODULE}${SUBDAMODULE}${DANAME}DA")
-         set(DAEXE "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe")
-         set(DADEP "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.d") 
+       set(DATARGETDIR "${DAINSTALL}/${DAMODULE}/tgt_$ENV{ALICE_TARGET}")
+       file(MAKE_DIRECTORY ${DATARGETDIR})
+       set(DAOBJ "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.o")
+       set(DASRC "${DAMODULE}/${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx")
+       set(DALIB "${DAMODULE}${SUBDAMODULE}${DANAME}DA")
+       set(DAEXE "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe")
+       set(DADEP "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.d") 
 
        # DAVERSION
-      execute_process(COMMAND svn info ${CMAKE_SOURCE_DIR}/${DASRC} OUTPUT_VARIABLE _daversion OUTPUT_STRIP_TRAILING_WHITESPACE)
-         string(REGEX REPLACE ".*Last Changed Rev: ([^\n]+)\n.*" "\\1" DAVERSION ${_daversion})
+       # execute_process(COMMAND svn info ${CMAKE_SOURCE_DIR}/${DASRC} OUTPUT_VARIABLE _daversion OUTPUT_STRIP_TRAILING_WHITESPACE)
+       # string(REGEX REPLACE ".*Last Changed Rev: ([^\n]+)\n.*" "\\1" DAVERSION ${_daversion}e)
+       execute_process(COMMAND git log -1 --format=%h 
+         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${DASRC} 
+         OUTPUT_VARIABLE DAVERSION)
 
        #DAREVISION
-         execute_process(COMMAND svn info ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE _darevision OUTPUT_STRIP_TRAILING_WHITESPACE)
-          string(REGEX REPLACE ".*Revision: ([^\n]+)\n.*" "\\1" DAREVISION ${_darevision})
+       # execute_process(COMMAND svn info ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE _darevision OUTPUT_STRIP_TRAILING_WHITESPACE)
+        # string(REGEX REPLACE ".*Revision: ([^\n]+)\n.*" "\\1" DAREVISION ${_darevision})
+       execute_process(COMMAND git log -1 --format=%h 
+         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${DASRC} 
+         OUTPUT_VARIABLE DAVERSION)
+
        # DAROOTRELEASE 
          execute_process(COMMAND root-config --version OUTPUT_VARIABLE _darootrelease OUTPUT_STRIP_TRAILING_WHITESPACE)
          string(REGEX REPLACE "/" "." DAROOTRELEASE ${_darootrelease})
        
        # DAALIROOTRELEASE
-         string(REGEX REPLACE ".*URL: .*/(.+)/${DASRC}.*$" "\\1" DAALIROOTRELEASE ${_daversion})
-          string (REPLACE "-" "." DAALIROOTRELEASE "${DAALIROOTRELEASE}")
+       # string(REGEX REPLACE ".*URL: .*/(.+)/${DASRC}.*$" "\\1" DAALIROOTRELEASE ${_daversion})
+        # string (REPLACE "-" "." DAALIROOTRELEASE "${DAALIROOTRELEASE}")
+       execute_process(COMMAND git branch
+         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${DASRC} 
+         OUTPUT_VARIABLE DAVERSION)
+        string (REPLACE "* " "" DAALIROOTRELEASE "${DAALIROOTRELEASE}")
        
          set(DAARCNAME "${DATARGETNAME}")
          #string(REPLACE "-" "" DAARCNAME "${DAARCNAME}")
@@ -290,7 +301,7 @@ COMMAND @echo '\# Makefile for Detector Algorithm' >> ${DAMAKEFILE}
 COMMAND @echo '\#' >> ${DAMAKEFILE}
 COMMAND @echo '\# It is necessary to setup build environment before' >> ${DAMAKEFILE}
 COMMAND @echo '\# using make:' >> ${DAMAKEFILE}
-COMMAND @echo '\# - define path to daqDAlib (env. DAQDALIB_PATH)' >> ${DAMAKEFILE}
+COMMAND @echo '\# - define path to daqDAlib \(env. DAQDALIB_PATH\)' >> ${DAMAKEFILE}
 COMMAND @echo '\#' >> ${DAMAKEFILE}
 COMMAND @echo '\#*****************************************************' >> ${DAMAKEFILE}
 COMMAND @echo "" >> ${DAMAKEFILE}
@@ -300,7 +311,7 @@ COMMAND @echo "" >> ${DAMAKEFILE}
 COMMAND @echo "CXXFLAGS=${CXXFLAGS}" >> ${DAMAKEFILE}
 COMMAND @echo "LDFLAGS=${LDFLAGS}" >> ${DAMAKEFILE}
 COMMAND @echo "" >> ${DAMAKEFILE}
-COMMAND @echo 'ifeq ($$(DAQDALIB_PATH),)' >> ${DAMAKEFILE}
+COMMAND @echo 'ifeq \($$\(DAQDALIB_PATH\),\)' >> ${DAMAKEFILE}
 COMMAND @echo "DAQDADIR=${ALICE}/daqDAlib" >> ${DAMAKEFILE}
 COMMAND @echo "else" >> ${DAMAKEFILE}
 COMMAND @echo 'DAQDADIR=$$(DAQDALIB_PATH)' >> ${DAMAKEFILE}
@@ -430,7 +441,7 @@ COMMAND @echo "%pre" >> ${DASPECFILE}
 COMMAND @echo "" >> ${DASPECFILE}
 COMMAND @echo '\# list of files to be installed' >> ${DASPECFILE}
 COMMAND @echo "%files" >> ${DASPECFILE}
-COMMAND @echo '%defattr (-,root,root)' >> ${DASPECFILE}
+COMMAND @echo '%defattr \(-,root,root\)' >> ${DASPECFILE}
 COMMAND @echo "%{destdir}" >> ${DASPECFILE}
 COMMAND @echo "" >> ${DASPECFILE}
 COMMAND @echo '\# post-install script' >> ${DASPECFILE}