]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Merge remote-tracking branch 'origin/master' into TPCdev
authormkrzewic <mikolaj.krzewicki@cern.ch>
Mon, 3 Feb 2014 17:16:48 +0000 (18:16 +0100)
committermkrzewic <mikolaj.krzewicki@cern.ch>
Mon, 3 Feb 2014 17:16:48 +0000 (18:16 +0100)
Conflicts:
TPC/Sim/AliTPCv2.cxx

178 files changed:
ANALYSIS/AliAnalysisAlien.cxx
ANALYSIS/AliAnalysisGrid.h
ANALYSIS/ESDfilter/AliAnalysisTaskESDfilter.cxx
HLT/CMakeLists.txt
HLT/CMakehlt.conf
HLT/TPCLib/AliHLTTPCTransform.cxx
HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPU.pkg [new file with mode: 0644]
HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPUOpenCL.pkg [new file with mode: 0644]
ITS/UPGRADE/AliITSUSuze02.cxx [new file with mode: 0644]
ITS/UPGRADE/AliITSUSuze02.h [new file with mode: 0644]
ITS/UPGRADE/AliITSUv1.cxx [new file with mode: 0644]
ITS/UPGRADE/AliITSUv1.h [new file with mode: 0644]
ITS/UPGRADE/AliITSUv1Layer.cxx [new file with mode: 0644]
ITS/UPGRADE/AliITSUv1Layer.h [new file with mode: 0644]
ITS/UPGRADE/CMakelibITSUpgradeSim.pkg
ITS/UPGRADE/ITSUpgradeSimLinkDef.h
ITS/UPGRADE/macros/ScanDigitsSuze02_v15.C [new file with mode: 0644]
ITS/UPGRADE/testITSUv1/Config.C [new file with mode: 0644]
ITS/UPGRADE/testITSUv1/CreateITSUv0.C [new file with mode: 0644]
ITS/UPGRADE/testITSUv1/CreateITSUv1.C [new file with mode: 0644]
ITS/UPGRADE/testITSUv1/sim.C [new file with mode: 0644]
JETAN/AliAnalysisTaskFastEmbedding.cxx
JETAN/AliAnalysisTaskJetCluster.cxx
PWG/CMakelibPWGflowBase.pkg
PWG/CaloTrackCorrBase/AliAnaCaloTrackCorrMaker.cxx
PWG/CaloTrackCorrBase/AliCaloTrackMCReader.cxx
PWG/CaloTrackCorrBase/AliCaloTrackReader.h
PWG/EMCAL/AliEmcalPicoTrackMaker.cxx
PWG/EMCAL/AliEmcalSetupTask.cxx
PWG/EMCAL/macros/AddTaskEMCALTenderUsingDatasetDef.C
PWG/FLOW/Base/AliFlowAnalysis.cxx [new file with mode: 0644]
PWG/FLOW/Base/AliFlowAnalysis.h [new file with mode: 0644]
PWG/FLOW/Base/AliFlowAnalysisWithScalarProduct.cxx
PWG/FLOW/Base/AliFlowAnalysisWithScalarProduct.h
PWG/FLOW/Base/AliFlowEventSimple.cxx
PWG/FLOW/Base/AliFlowEventSimple.h
PWG/FLOW/Base/AliFlowEventSimpleCuts.cxx [new file with mode: 0644]
PWG/FLOW/Base/AliFlowEventSimpleCuts.h [new file with mode: 0644]
PWG/FLOW/Base/AliFlowEventStar.cxx
PWG/FLOW/Base/AliFlowTrackSimple.cxx
PWG/FLOW/Base/AliFlowTrackSimple.h
PWG/FLOW/Base/AliFlowTrackSimpleCuts.cxx
PWG/FLOW/Base/AliFlowTrackSimpleCuts.h
PWG/FLOW/Base/AliFlowVector.cxx
PWG/FLOW/Base/AliFlowVector.cxx.orig [new file with mode: 0644]
PWG/FLOW/Base/AliFlowVector.h
PWG/FLOW/Base/AliFlowVector.h.orig [new file with mode: 0644]
PWG/FLOW/Tasks/AliAnalysisTaskFlowEvent.cxx
PWG/FLOW/Tasks/AliAnalysisTaskFlowEvent.h
PWG/FLOW/Tasks/AliAnalysisTaskScalarProduct.cxx
PWG/FLOW/Tasks/AliFlowCandidateTrack.cxx
PWG/FLOW/Tasks/AliFlowCandidateTrack.h
PWG/FLOW/Tasks/AliFlowEvent.cxx
PWG/FLOW/Tasks/AliFlowEvent.h
PWG/FLOW/Tasks/AliFlowEventCuts.cxx
PWG/FLOW/Tasks/AliFlowEventCuts.h
PWG/FLOW/Tasks/AliFlowTrack.h
PWG/FLOW/Tasks/AliFlowTrackCuts.cxx
PWG/FLOW/Tasks/AliFlowTrackCuts.h
PWG/PWGflowBaseLinkDef.h
PWG/muon/AliAnalysisTaskESDMuonFilter.cxx
PWG/muon/AliAnalysisTaskLinkToMC.cxx
PWG/muon/AliAnalysisTaskSingleMu.cxx
PWG/muon/AliAnalysisTaskSingleMu.h
PWGCF/CMakelibPWGCFCorrelationsDPhi.pkg
PWGCF/Correlations/DPhi/AliAnalysisTaskDiHadron.cxx [changed mode: 0755->0644]
PWGCF/Correlations/DPhi/AliAnalysisTaskDiHadron.h [changed mode: 0755->0644]
PWGCF/Correlations/DPhi/PhiEffMC/AliAnalysisTaskPhiEffMc.cxx
PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx
PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.h
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskToyModel.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskToyModel.h
PWGCF/EBYE/BalanceFunctions/AliBalancePsi.cxx
PWGCF/EBYE/Fluctuations/AliEbyEHigherMomentsTask.cxx
PWGCF/FEMTOSCOPY/macros/Plot_PDCumulants.C
PWGCF/FEMTOSCOPY/macros/Plot_PDCumulants_TPR.C
PWGCF/FEMTOSCOPY/macros/Plot_muons.C [new file with mode: 0755]
PWGCF/FEMTOSCOPY/macros/Plot_plots.C
PWGCF/FEMTOSCOPY/macros/Plot_plotsTPR.C
PWGCF/FEMTOSCOPYAOD/AliAnalysisTaskPWG2ESDfilter.cxx
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQa.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaMunu.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaVZERO.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQb.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbMunu.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbVZERO.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQa.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQaVZERO.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQb.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQbVZERO.C [new file with mode: 0644]
PWGCF/FLOW/macros/Kinks/runFlowTaskCentralityKinkTrain.C [new file with mode: 0644]
PWGCF/FLOW/macros/merge.C [new file with mode: 0644]
PWGCF/FLOW/macros/redoFinish.C
PWGCF/PWGCFCorrelationsDPhiLinkDef.h
PWGDQ/dielectron/AliAnalysisTaskDielectronFilter.cxx
PWGDQ/dielectron/AliDielectronHF.cxx
PWGDQ/dielectron/AliDielectronHFhelper.cxx
PWGDQ/dielectron/macrosJPSI/AddTaskJPSIFilter.C
PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Cent.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Peri.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent1.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent2.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C [new file with mode: 0644]
PWGGA/CMakelibPWGGAGammaConv.pkg
PWGGA/CaloTasks/AliAnalysisTaskCaloFilter.cxx
PWGGA/CaloTrackCorrelations/AliAnaPhoton.cxx
PWGGA/EMCALTasks/AliAnalysisTaskEMCALPi0PbPb.cxx
PWGGA/GammaConv/AliAnalysisTaskConversionQA.cxx
PWGGA/GammaConv/AliAnalysisTaskConversionQA.h
PWGGA/GammaConv/macros/AddTask_GammaConvDalitzV1_pPb.C
PWGGA/GammaConv/macros/AddTask_GammaConvV1_pPb.C
PWGGA/PHOSTasks/ClusterSelection/AliPHOSClusterSelection.cxx
PWGGA/PHOSTasks/ClusterSelection/AliPHOSClusterSelection.h
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0Flow.cxx
PWGHF/hfe/AliAnalysisTaskEMCalHFEpA.cxx
PWGHF/hfe/AliAnalysisTaskEMCalHFEpA.h
PWGHF/hfe/AliAnalysisTaskFlowITSTPCTOFQCSP.h
PWGHF/hfe/AliAnalysisTaskFlowTPCEMCalQCSP.cxx
PWGHF/hfe/AliAnalysisTaskFlowTPCEMCalQCSP.h
PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C
PWGJE/EMCALJetTasks/AliFJWrapper.h
PWGJE/EMCALJetTasks/AliJetEmbeddingFromGenTask.cxx
PWGJE/EMCALJetTasks/AliJetModelBaseTask.cxx
PWGJE/EMCALJetTasks/FJ_includes.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetMass.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetMass.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetMassBkg.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetMassBkg.h
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTagger.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskHJetDphi.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskHJetDphi.h
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetMass.C
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C
PWGJE/EMCALJetTasks/macros/runEMCalJetAnalysis.C
PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.cxx
PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C
PWGJE/FlavourJetTasks/macros/AddTasksFlavourJet.C
PWGJE/FlavourJetTasks/macros/AnalysisTrainCorrJetsLocal.C
PWGJE/UserTasks/AliAnalysisTaskPID.cxx
PWGJE/UserTasks/AliAnalysisTaskPID.h
PWGLF/RESONANCES/macros/mini/AddTaskLambdaStarPbPb.C
PWGLF/RESONANCES/macros/mini/ConfigLambdaStarPbPb.C
PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysisPbPbAOD.cxx
PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysisPbPbAOD.h
PWGLF/SPECTRA/Nuclei/deuteronpA/AliAnalysisDeuteronpA.cxx
PWGLF/SPECTRA/Nuclei/masses/AddTaskNuclei.C
PWGLF/SPECTRA/Nuclei/masses/AliAnalysisNucleiMass.cxx
PWGLF/SPECTRA/Nuclei/masses/AliAnalysisNucleiMass.h
PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraAllChAOD.cxx
PWGLF/STRANGENESS/Correlations/AliAnalysisTaskLambdaOverK0sJets.cxx
PWGLF/STRANGENESS/Correlations/AliAnalysisTaskLambdaOverK0sJets.h
PWGLF/STRANGENESS/Correlations/macros/AddTaskLambdaOverK0sJets.C
PWGLF/STRANGENESS/Correlations/macros/runGridLambdaOverK0sJets.C
PWGPP/EvTrkSelection/AliAnalysisTrackingUncertainties.cxx
PWGPP/pid/doeffAllSpecies.C
PWGPP/pid/doeffKa.C
PWGPP/pid/doeffPi.C
PWGPP/pid/doeffPr.C
README_CMake
STEER/AOD/AliAODTrack.cxx
STEER/AOD/AliAODTrack.h
STEER/AODLinkDef.h
STEER/ESD/AliESDEvent.cxx
STEER/ESD/AliESDEvent.h
STEER/ESD/AliESDpid.cxx
STEER/ESD/AliESDpid.h
STEER/ESD/AliESDtrack.cxx
STEER/ESD/AliESDtrack.h
STEER/ESDLinkDef.h
STEER/STEERBase/AliPIDCombined.cxx
STEER/STEERBase/AliPIDCombined.h
STEER/STEERBase/AliPIDResponse.cxx
STEER/STEERBase/AliPIDResponse.h
STEER/STEERBase/AliVTrack.h
TOF/AliTOFtracker.cxx
TPC/Sim/AliTPCv2.cxx

index 0038b097329d5e141958114cc2909861a451afd4..d44a874c139b579a343f27fde6ec7b6f77d92418 100644 (file)
@@ -4617,7 +4617,10 @@ void AliAnalysisAlien::WriteMergingMacro()
       out << "// Set temporary compilation directory to current one" << endl;
       out << "   gSystem->SetBuildDir(gSystem->pwd(), kTRUE);" << endl << endl;   
       out << "   TString outputDir = dir;" << endl;  
-      out << "   TString outputFiles = \"" << GetListOfFiles("out") << "\";" << endl;
+      if (IsMergeAOD())
+         out << "   TString outputFiles = \"" << GetListOfFiles("outaod") << "\";" << endl;
+      else   
+         out << "   TString outputFiles = \"" << GetListOfFiles("out") << "\";" << endl;
       out << "   TString mergeExcludes = \"" << fMergeExcludes << " " << fRegisterExcludes << "\";" << endl;
       out << "   TObjArray *list = outputFiles.Tokenize(\",\");" << endl;
       out << "   TIter *iter = new TIter(list);" << endl;
index 62105a273fa27fc6d28dd862cb9e92ac439d4c8a..0be90856a6f970d91c30dd9ec59f6b5cea1783b7 100644 (file)
@@ -43,7 +43,8 @@ enum EPluginBits {
    kProofConnectGrid = BIT(5),
    kOneStageMerging = BIT(6),
    kUseMCchain = BIT(7),
-   kLocalTest  = BIT(8)
+   kLocalTest  = BIT(8),
+   kMergeAOD   = BIT(9)
 };
 
    AliAnalysisGrid() : TNamed(), fSpecialBits(0) {}
@@ -127,6 +128,8 @@ enum EPluginBits {
    void                SetUseMCchain(Bool_t flag=kTRUE) {SetSpecialBit(kUseMCchain,flag);}
    Bool_t              IsLocalTest() const {return TestSpecialBit(kLocalTest);}
    void                SetLocalTest(Bool_t flag=kTRUE) {SetSpecialBit(kLocalTest,flag);}
+   Bool_t              IsMergeAOD() const {return TestSpecialBit(kMergeAOD);}
+   virtual void        SetMergeAOD(Bool_t flag=kTRUE) {SetSpecialBit(kMergeAOD,flag);}
 
 // PROOF mode
    virtual void        SetProofCluster(const char *cluster)              = 0;
index 3a5dbce4b9cfa38d465a120b88a39d606bc1e4f5..994e6b79d434272e31c06a6d391d992b41ae4eeb 100644 (file)
@@ -471,7 +471,7 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
   Double_t covVtx[6] = { 0. };
   Double_t momBach[3]={0.};
   Double_t covTr[21]={0.};
-  Double_t pid[10]={0.};
+  //  Double_t pid[10]={0.};
   AliAODPid* detpid(0x0);
   AliAODVertex* vV0FromCascade(0x0);
   AliAODv0* aodV0(0x0);
@@ -579,7 +579,7 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
       esdCascadeBach->GetPxPyPz(momBach);
       esdCascadeBach->GetXYZ(pos);
       esdCascadeBach->GetCovarianceXYZPxPyPz(covTr);
-      esdCascadeBach->GetESDpid(pid);
+      //      esdCascadeBach->GetESDpid(pid);
       esdCascadeBach->GetTOFLabel(tofLabel);
 
       fUsedTrack[idxBachFromCascade] = kTRUE;
@@ -595,12 +595,13 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
                                                                 covTr, 
                                                                 (Short_t)esdCascadeBach->GetSign(),
                                                                 esdCascadeBach->GetITSClusterMap(), 
-                                                                pid,
+                                                                // pid,
                                                                 vCascade,
                                                                 kTRUE,  // usedForVtxFit = kFALSE ? FIXME
                                                                 vtx->UsesTrack(esdCascadeBach->GetID()),
                                                                 AliAODTrack::kSecondary,
                                                                 selectInfo);
+      aodTrack->SetPIDForTracking(esdCascadeBach->GetPIDForTracking());
       aodTrack->SetTPCFitMap(esdCascadeBach->GetTPCFitMap());
       aodTrack->SetTPCClusterMap(esdCascadeBach->GetTPCClusterMap());
       aodTrack->SetTPCSharedMap (esdCascadeBach->GetTPCSharedMap());
@@ -657,7 +658,7 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
       esdCascadePos->GetPxPyPz(momPos);
       esdCascadePos->GetXYZ(pos);
       esdCascadePos->GetCovarianceXYZPxPyPz(covTr);
-      esdCascadePos->GetESDpid(pid);
+      //      esdCascadePos->GetESDpid(pid);
       esdCascadePos->GetTOFLabel(tofLabel);      
       
       if (!fUsedTrack[idxPosFromV0Dghter]) {
@@ -675,12 +676,13 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
                                                                   covTr, 
                                                                   (Short_t)esdCascadePos->GetSign(),
                                                                   esdCascadePos->GetITSClusterMap(), 
-                                                                  pid,
+                                                                  //pid,
                                                                   vV0FromCascade,
                                                                   kTRUE,  // usedForVtxFit = kFALSE ? FIXME
                                                                   vtx->UsesTrack(esdCascadePos->GetID()),
                                                                   AliAODTrack::kSecondary,
                                                                   selectInfo);
+       aodTrack->SetPIDForTracking(esdCascadePos->GetPIDForTracking());
         aodTrack->SetTPCFitMap(esdCascadePos->GetTPCFitMap());
         aodTrack->SetTPCClusterMap(esdCascadePos->GetTPCClusterMap());
         aodTrack->SetTPCSharedMap (esdCascadePos->GetTPCSharedMap());
@@ -707,7 +709,7 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
       esdCascadeNeg->GetPxPyPz(momNeg);
       esdCascadeNeg->GetXYZ(pos);
       esdCascadeNeg->GetCovarianceXYZPxPyPz(covTr);
-      esdCascadeNeg->GetESDpid(pid);
+      //   esdCascadeNeg->GetESDpid(pid);
       esdCascadeNeg->GetTOFLabel(tofLabel);
       
       if (!fUsedTrack[idxNegFromV0Dghter]) {
@@ -726,12 +728,13 @@ void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd)
                                                                   covTr, 
                                                                   (Short_t)esdCascadeNeg->GetSign(),
                                                                   esdCascadeNeg->GetITSClusterMap(), 
-                                                                  pid,
+                                                                  // pid,
                                                                   vV0FromCascade,
                                                                   kTRUE,  // usedForVtxFit = kFALSE ? FIXME
                                                                   vtx->UsesTrack(esdCascadeNeg->GetID()),
                                                                   AliAODTrack::kSecondary,
                                                                   selectInfo);
+       aodTrack->SetPIDForTracking(esdCascadeNeg->GetPIDForTracking());
         aodTrack->SetTPCFitMap(esdCascadeNeg->GetTPCFitMap());
         aodTrack->SetTPCClusterMap(esdCascadeNeg->GetTPCClusterMap());
         aodTrack->SetTPCSharedMap (esdCascadeNeg->GetTPCSharedMap());
@@ -858,7 +861,7 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
   Double_t covVtx[6] = { 0. };
   Double_t momPos[3]={0.};
   Double_t covTr[21]={0.};
-  Double_t pid[10]={0.};
+  //  Double_t pid[10]={0.};
   AliAODTrack* aodTrack(0x0);
   AliAODPid* detpid(0x0);
   Double_t momNeg[3]={0.};
@@ -923,7 +926,7 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
     esdV0Pos->GetPxPyPz(momPos);
     esdV0Pos->GetXYZ(pos);
     esdV0Pos->GetCovarianceXYZPxPyPz(covTr);
-    esdV0Pos->GetESDpid(pid);
+    //    esdV0Pos->GetESDpid(pid);
     esdV0Pos->GetTOFLabel(tofLabel);
     
     const AliESDVertex *vtx = esd.GetPrimaryVertex();
@@ -942,12 +945,13 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
                                                                    covTr, 
                                                                    (Short_t)esdV0Pos->GetSign(),
                                                                    esdV0Pos->GetITSClusterMap(), 
-                                                                   pid,
+                                                                   // pid,
                                                                    vV0,
                                                                    kTRUE,  // check if this is right
                                                                    vtx->UsesTrack(esdV0Pos->GetID()),
                                                                    AliAODTrack::kSecondary,
                                                                    selectInfo);
+           aodTrack->SetPIDForTracking(esdV0Pos->GetPIDForTracking());
            aodTrack->SetTPCFitMap(esdV0Pos->GetTPCFitMap());
            aodTrack->SetTPCClusterMap(esdV0Pos->GetTPCClusterMap());
            aodTrack->SetTPCSharedMap (esdV0Pos->GetTPCSharedMap());
@@ -971,7 +975,7 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
     esdV0Neg->GetPxPyPz(momNeg);
     esdV0Neg->GetXYZ(pos);
     esdV0Neg->GetCovarianceXYZPxPyPz(covTr);
-    esdV0Neg->GetESDpid(pid);
+    //    esdV0Neg->GetESDpid(pid);
     esdV0Neg->GetTOFLabel(tofLabel);
     
     if (!fUsedTrack[negFromV0]) {
@@ -988,12 +992,13 @@ void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)
                                                              covTr, 
                                                              (Short_t)esdV0Neg->GetSign(),
                                                              esdV0Neg->GetITSClusterMap(), 
-                                                             pid,
+                                                             // pid,
                                                              vV0,
                                                              kTRUE,  // check if this is right
                                                              vtx->UsesTrack(esdV0Neg->GetID()),
                                                              AliAODTrack::kSecondary,
                                                              selectInfo);
+      aodTrack->SetPIDForTracking(esdV0Neg->GetPIDForTracking());
       aodTrack->SetTPCFitMap(esdV0Neg->GetTPCFitMap());
       aodTrack->SetTPCClusterMap(esdV0Neg->GetTPCClusterMap());
       aodTrack->SetTPCSharedMap (esdV0Neg->GetTPCSharedMap());
@@ -1086,7 +1091,7 @@ void AliAnalysisTaskESDfilter::ConvertTPCOnlyTracks(const AliESDEvent& esd)
 
   Double_t pos[3] = { 0. };      
   Double_t covTr[21]={0.};
-  Double_t pid[10]={0.};  
+  //  Double_t pid[10]={0.};  
   Double_t p[3] = { 0. };
   Double_t pDCA[3] = { 0. }; // momentum at DCA
   Double_t rDCA[3] = { 0. }; // position at DCA
@@ -1165,7 +1170,7 @@ void AliAnalysisTaskESDfilter::ConvertTPCOnlyTracks(const AliESDEvent& esd)
 
     track->GetXYZ(pos);
     track->GetCovarianceXYZPxPyPz(covTr);
-    esdTrack->GetESDpid(pid);// original PID
+    //    esdTrack->GetESDpid(pid);// original PID
     esdTrack->GetTOFLabel(tofLabel);
     if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());
     fUsedTrackCopy[nTrack] |= selectInfo;
@@ -1178,12 +1183,13 @@ void AliAnalysisTaskESDfilter::ConvertTPCOnlyTracks(const AliESDEvent& esd)
                                                            covTr, 
                                                            (Short_t)track->GetSign(),
                                                            track->GetITSClusterMap(), 
-                                                           pid,
+                                                           // pid,
                                                            fPrimaryVertex,
                                                            kTRUE, // check if this is right
                                                            vtx->UsesTrack(track->GetID()),
                                                            AliAODTrack::kPrimary, 
                                                            selectInfo);
+    aodTrack->SetPIDForTracking(track->GetPIDForTracking());
     aodTrack->SetIsHybridTPCConstrainedGlobal(isHybridITSTPC);    
     aodTrack->SetTPCFitMap(track->GetTPCFitMap());
     aodTrack->SetTPCClusterMap(track->GetTPCClusterMap());
@@ -1238,7 +1244,7 @@ void AliAnalysisTaskESDfilter::ConvertGlobalConstrainedTracks(const AliESDEvent&
  
   Double_t pos[3] = { 0. };      
   Double_t covTr[21]={0.};
-  Double_t pid[10]={0.};  
+  //  Double_t pid[10]={0.};  
   Double_t p[3] = { 0. };
 
   Double_t pDCA[3] = { 0. }; // momentum at DCA
@@ -1298,7 +1304,7 @@ void AliAnalysisTaskESDfilter::ConvertGlobalConstrainedTracks(const AliESDEvent&
 
     esdTrack->GetConstrainedXYZ(pos);
     exParamGC->GetCovarianceXYZPxPyPz(covTr);
-    esdTrack->GetESDpid(pid);
+    //    esdTrack->GetESDpid(pid);
     esdTrack->GetTOFLabel(tofLabel); 
     if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());
     fUsedTrackCopy[nTrack] |= selectInfo;
@@ -1311,12 +1317,13 @@ void AliAnalysisTaskESDfilter::ConvertGlobalConstrainedTracks(const AliESDEvent&
                                                             covTr, 
                                                             (Short_t)esdTrack->GetSign(),
                                                             esdTrack->GetITSClusterMap(), 
-                                                            pid,
+                                                            // pid,
                                                             fPrimaryVertex,
                                                             kTRUE, // check if this is right
                                                             vtx->UsesTrack(esdTrack->GetID()),
                                                             AliAODTrack::kPrimary, 
                                                             selectInfo);
+    aodTrack->SetPIDForTracking(esdTrack->GetPIDForTracking());
     aodTrack->SetIsHybridGlobalConstrainedGlobal(isHybridGC);    
     aodTrack->SetIsGlobalConstrained(kTRUE);    
     aodTrack->SetTPCFitMap(esdTrack->GetTPCFitMap());
@@ -1355,7 +1362,7 @@ void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)
   Double_t p[3] = { 0. };
   Double_t pos[3] = { 0. };
   Double_t covTr[21] = { 0. };
-  Double_t pid[10] = { 0. };
+  //  Double_t pid[10] = { 0. };
   Int_t    tofLabel[3] = {0};
   AliAODTrack* aodTrack(0x0);
   AliAODPid* detpid(0x0);
@@ -1376,7 +1383,7 @@ void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)
     esdTrack->GetPxPyPz(p);
     esdTrack->GetXYZ(pos);
     esdTrack->GetCovarianceXYZPxPyPz(covTr);
-    esdTrack->GetESDpid(pid);
+    //    esdTrack->GetESDpid(pid);
     esdTrack->GetTOFLabel(tofLabel);
     if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());
     fUsedTrack[nTrack] = kTRUE;
@@ -1389,13 +1396,14 @@ void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)
                                                             covTr, 
                                                             (Short_t)esdTrack->GetSign(),
                                                             esdTrack->GetITSClusterMap(), 
-                                                            pid,
+                                                            // pid,
                                                             fPrimaryVertex,
                                                             kTRUE, // check if this is right
                                                             vtx->UsesTrack(esdTrack->GetID()),
                                                             AliAODTrack::kPrimary, 
                                                             selectInfo);
     fPrimaryVertex->AddDaughter(aodTrack);
+    aodTrack->SetPIDForTracking(esdTrack->GetPIDForTracking());
     aodTrack->SetTPCFitMap(esdTrack->GetTPCFitMap());
     aodTrack->SetTPCClusterMap(esdTrack->GetTPCClusterMap());
     aodTrack->SetTPCSharedMap (esdTrack->GetTPCSharedMap());
@@ -1633,7 +1641,7 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
   // The loop is on the tracks in order to find the mother and daugther of each kink
   
   Double_t covTr[21]={0.};
-  Double_t pid[10]={0.};
+  //  Double_t pid[10]={0.};
   AliAODPid* detpid(0x0);
   Int_t tofLabel[3] = {0};
   
@@ -1691,7 +1699,7 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
             esdTrackM->GetPxPyPz(p);
             esdTrackM->GetXYZ(pos);
             esdTrackM->GetCovarianceXYZPxPyPz(covTr);
-            esdTrackM->GetESDpid(pid);
+           //            esdTrackM->GetESDpid(pid);
            esdTrackM->GetTOFLabel(tofLabel);
             if(fMChandler)fMChandler->SelectParticle(esdTrackM->GetLabel());
             mother = new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdTrackM->GetID(),
@@ -1703,12 +1711,13 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
                                                                  covTr, 
                                                                  (Short_t)esdTrackM->GetSign(),
                                                                  esdTrackM->GetITSClusterMap(), 
-                                                                 pid,
+                                                                 // pid,
                                                                  fPrimaryVertex,
                                                                  kTRUE, // check if this is right
                                                                  vtx->UsesTrack(esdTrack->GetID()),
                                                                  AliAODTrack::kPrimary,
                                                                  selectInfo);
+           mother->SetPIDForTracking(esdTrackM->GetPIDForTracking());
             mother->SetTPCFitMap(esdTrackM->GetTPCFitMap());
             mother->SetTPCClusterMap(esdTrackM->GetTPCClusterMap());
             mother->SetTPCSharedMap (esdTrackM->GetTPCSharedMap());
@@ -1750,7 +1759,7 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
             esdTrackD->GetPxPyPz(p);
             esdTrackD->GetXYZ(pos);
             esdTrackD->GetCovarianceXYZPxPyPz(covTr);
-            esdTrackD->GetESDpid(pid);
+           //            esdTrackD->GetESDpid(pid);
            esdTrackD->GetTOFLabel(tofLabel);
             selectInfo = 0;
             if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdTrackD);
@@ -1764,12 +1773,13 @@ void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)
                                                                    covTr, 
                                                                    (Short_t)esdTrackD->GetSign(),
                                                                    esdTrackD->GetITSClusterMap(), 
-                                                                   pid,
+                                                                   // pid,
                                                                    vkink,
                                                                    kTRUE, // check if this is right
                                                                    vtx->UsesTrack(esdTrack->GetID()),
                                                                    AliAODTrack::kSecondary,
                                                                    selectInfo);
+           daughter->SetPIDForTracking(esdTrackD->GetPIDForTracking());
             daughter->SetTPCFitMap(esdTrackD->GetTPCFitMap());
             daughter->SetTPCClusterMap(esdTrackD->GetTPCClusterMap());
             daughter->SetTPCSharedMap (esdTrackD->GetTPCSharedMap());
@@ -2076,12 +2086,12 @@ void AliAnalysisTaskESDfilter::ConvertTRD(const AliESDEvent& esd)
          Double_t mom[3]={0.};
          Double_t pos[3]={0.};
          Double_t covTr[21]={0.};
-         Double_t pid[10]={0.};
+         //      Double_t pid[10]={0.};
 
          esdTrkMatch->GetPxPyPz(mom);
          esdTrkMatch->GetXYZ(pos);
          esdTrkMatch->GetCovarianceXYZPxPyPz(covTr);
-         esdTrkMatch->GetESDpid(pid);
+         // esdTrkMatch->GetESDpid(pid);
          const AliESDVertex* vtx = esd.GetPrimaryVertex();
 
          fUsedTrack[idx] = kTRUE;
@@ -2096,12 +2106,13 @@ void AliAnalysisTaskESDfilter::ConvertTRD(const AliESDEvent& esd)
                                                                     covTr,
                                                                     (Short_t)esdTrkMatch->GetSign(),
                                                                     esdTrkMatch->GetITSClusterMap(),
-                                                                    pid,
+                                                                    // pid,
                                                                     fPrimaryVertex,
                                                                     kTRUE,
                                                                     vtx->UsesTrack(esdTrkMatch->GetID()),
                                                                     AliAODTrack::kUndef,
                                                                     selectInfo);
+         aodTrkMatch->SetPIDForTracking(esdTrkMatch->GetPIDForTracking());
          aodTrkMatch->SetTPCFitMap(esdTrkMatch->GetTPCFitMap());
          aodTrkMatch->SetTPCClusterMap(esdTrkMatch->GetTPCClusterMap());
          aodTrkMatch->SetTPCSharedMap (esdTrkMatch->GetTPCSharedMap());
index 8559dc606b94622a29b0f548a873be472a5a0390..abd4eeeb6fa1ca4bc5609debc5ec63774bc70391 100644 (file)
@@ -5,8 +5,19 @@
 
 cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
 
+option(HLT_CUDA   "Build HLT GPU tracker using CUDA"   OFF)
+option(HLT_OPENCL "Build HLT GPU tracker using OpenCL" OFF)
+
 include("CMakehltdoc.conf")
 
 file(GLOB PACKAGES CMake*.pkg)
 
+if(HLT_CUDA)
+  list(APPEND PACKAGES TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPU.pkg)
+endif(HLT_CUDA)
+
+if(HLT_OPENCL)
+  list(APPEND PACKAGES TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPUOpenCL.pkg)
+endif()
+
 ALICE_BuildModule()
index ea1a81be9725812886e66660520d9c2db1b2c1d1..9c1040a464cdcd31dda2e38180da72c5b6f828c0 100644 (file)
@@ -4,7 +4,7 @@
 #                                                                                #
 #--------------------------------------------------------------------------------#
 
-set ( HLTDEFS  "-Duse_aliroot -Duse_root -DROWHOUGHPARAMS -Duse_reconstruction -Duse_newio -DROOTVERSION=\\\"unchecked\\\" -DALIROOTVERSION=\\\"unchecked\\\" -D__ROOT__ -DUSE_ALILOG -DLINUX" )
+set ( HLTDEFS  "-Duse_aliroot -Duse_root -DROWHOUGHPARAMS" )
 
 string ( REGEX REPLACE "(-ansi|-pedantic-errors|-Woverloaded-virtual)" "" HLTCXXFLAGS ${CFLAGS})
 string ( REGEX REPLACE "(-ansi|-pedantic-errors|-Woverloaded-virtual)" "" HLTCXXFLAGS ${CXXFLAGS})
index 0d43c6aee4601e110b77215b37d23878f253346e..6103a5665ebfb3c9736a6e32d2141567e7dc1ca7 100644 (file)
@@ -1537,49 +1537,5 @@ void AliHLTTPCTransform::Global2HLT(Float_t *xyz,Int_t slice,Int_t slicerow)
 
 void AliHLTTPCTransform::PrintCompileOptions()
 {
-  //print compile options
-#if defined(__GNUC__)
-  cout << "Compiler (g++) version used: " << __GNUC__ << endl;
-#endif
-
-#ifdef no_root
-  cout << "STANDALONE version: -Dno_root was given." << endl;
-#else
-  const Char_t *roottest="$ROOTSYS/bin/root -n -b -q  | grep Version | cut -b 17-25 | cut -d\" \" -f1";
-#ifdef use_aliroot
-#ifdef use_cvs
-  const Char_t *aliroottest="if test -n \"`cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | grep none`\"; then echo HEAD; else cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | cut -b 18- | cut -d\" \" -f1; fi";
-#else
-  const Char_t *aliroottest="Unknown";
-#endif
-  cout << "ALIROOT version: -Duse_aliroot and -Duse_root was given." << endl;
-  cout << "Root Version: " << ROOTVERSION << " found " << flush;
-  gSystem->Exec(roottest);
-
-  cout << "AliRoot Version: " << ALIROOTVERSION << " found " << flush;
-  gSystem->Exec(aliroottest);
-#else
-  cout << "ROOT version: -Duse_root was given." << endl;
-  cout << "Root Version: " << ROOTVERSION << " found " << flush;
-  gSystem->Exec(roottest);
-#endif
-#endif
-
-#ifdef do_mc
-  cout << "Using Monte Carlo Info: -Ddo_mc was given." << endl;
-#else
-  cout << "NOT using Monte Carlo Info: -Ddo_mc was not given." << endl;
-#endif
-
-#ifdef INCLUDE_TPC_HOUGH
-  cout << "Including support for TPC Hough transformations." << endl;
-#ifdef ROWHOUGHPARAMS
-  cout << "Using extended AliHLTTPCTrackSegmentData: -DROWHOUGHPARAMS was given." << endl;
-#else
-  cout << "NOT using extended AliHLTTPCTrackSegmentData: -DROWHOUGHPARAMS was not given." << endl;
-#endif
-#else
-  cout << "NOT including any support for TPC Hough transformations." << endl;
-#endif // INCLUDE_TPC_HOUGH
-
+//deprecated; to be removed
 }
diff --git a/HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPU.pkg b/HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPU.pkg
new file mode 100644 (file)
index 0000000..598c705
--- /dev/null
@@ -0,0 +1,109 @@
+# -*- mode: CMake -*- 
+# $Id$
+#--------------------------------------------------------------------------------#
+# Package File for AliHLTTPCCAGPU                                                #
+# 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)           #
+#--------------------------------------------------------------------------------#
+
+find_package ( CUDA )
+if ( NOT CUDA_FOUND )
+  #fail if CUDA wasn't found
+  message ( FATAL_ERROR "NVIDIA CUDA package not found. Please install or set HLT_CUDA=OFF" )
+endif ( NOT CUDA_FOUND )
+
+#set nvcc flags
+set ( CUDA_NVCC_FLAGS --use_fast_math --maxrregcount 64 -O4 -Xptxas -O4 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 )
+#for convenience
+set ( CAGPUDIR TPCLib/tracking-ca/cagpu )
+#add include path
+include_directories( ${CAGPUDIR} )
+#nvcc fails with std=c++11, remove it temporarily
+string ( FIND ${CMAKE_CXX_FLAGS} "-std=c++11" STDCXX11FOUND )
+if ( STDCXX11FOUND GREATER -1 )
+  string ( REPLACE "-std=c++11" "-std=c++98" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
+endif ( )
+#compile CUDA object file
+cuda_compile ( CAGPU_O ${CAGPUDIR}/AliHLTTPCCAGPUTrackerNVCC.cu )
+#set it back
+if ( STDCXX11FOUND GREATER -1 )
+  string ( REPLACE "-std=c++98" "-std=c++11" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
+endif ( )
+#end of CUDA specific stuff; from here on build usual library
+
+set ( CLASS_HDRS
+  AliHLTTPCCAGPUTrackerBase.h
+  AliHLTTPCCAGPUTrackerNVCC.h
+)
+
+set ( MODULE_SRCS 
+  AliHLTTPCCAGPUTrackerBase.cxx
+)
+
+set ( MODULE_HDRS
+  ${CLASS_HDRS}
+  AliHLTTPCCAGPUTrackerCommon.h
+)
+
+set ( MODULE_DHDR )
+
+set ( EINCLUDE HLT/${CAGPUDIR} HLT/TPCLib/tracking-ca HLT/BASE )
+
+#CUDA run-time and driver
+set ( ELIBS ${CUDA_LIBRARIES} -lcuda )
+
+include ("CMakehlt.conf")
+
+if (MODULE_SRCS)
+ALICE_Format (SRCS "${CAGPUDIR}/" "" "${MODULE_SRCS}")
+endif(MODULE_SRCS)
+if (CLASS_HDRS)
+ALICE_Format (CINTHDRS "${CAGPUDIR}/" "" "${CLASS_HDRS}")
+endif(CLASS_HDRS)
+if (MODULE_HDRS)
+ALICE_Format (HDRS "${CAGPUDIR}/" "" "${MODULE_HDRS}")
+endif(MODULE_HDRS)
+if (MODULE_DHDR)
+ALICE_Format (DHDR "${CAGPUDIR}/" "" "${MODULE_DHDR}")
+endif(MODULE_DHDR)
+
+#add CUDA object file(s) as library (link) dependency
+list(APPEND SRCS ${CAGPU_O})
+
+# bit of a hack, but otherwise dictionary compilation fails:
+# defines cudaError_t to make it known
+# defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
+# not sure why __ROOT__ is used here, could just as well be something else
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPU.cxx PROPERTIES COMPILE_DEFINITIONS "cudaError_t=int;__ROOT__")
+
+if(NOT DHDR)
+  set(CINTAUTOLINK 1)
+endif(NOT DHDR)
+
+set ( EDEFINE  ${HLTDEFS} )
+set ( PACKCXXFLAGS  "${HLTCXXFLAGS} -Wshadow -Wall -O3")
+set ( PACKCFLAGS  ${HLTCLFAGS})
+set ( PACKDCXXFLAGS  ${HLTDCXXFLAGS})
+set ( PACKSOFLAGS ${HLTSOFLAGS})
+#set ( CINTFLAGS )
diff --git a/HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPUOpenCL.pkg b/HLT/TPCLib/tracking-ca/cagpu/CMakelibAliHLTTPCCAGPUOpenCL.pkg
new file mode 100644 (file)
index 0000000..394bfac
--- /dev/null
@@ -0,0 +1,132 @@
+# -*- mode: CMake -*- 
+# $Id$
+#--------------------------------------------------------------------------------#
+# Package File for AliHLTTPCCAGPUOpenCL                                          #
+# 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)           #
+#--------------------------------------------------------------------------------#
+
+
+# AMD APP SDK required for OpenCL tracker; it's using specific
+# extensions (currently) not provided by other vendors.
+# either set cmake variable via "-D$AMDAPPSDKROOT=/path/to/amdappsdkroot"
+# or via environment variable $AMDAPPSDKROOT
+if ( NOT AMDAPPSDKROOT )
+  set ( AMDAPPSDKROOT $ENV{AMDAPPSDKROOT} )
+endif()
+
+if ( NOT AMDAPPSDKROOT )
+  #fail if not set
+  message ( FATAL_ERROR "AMDAPPSDKROOT not set. Please install AMD APP SDK and set $AMDAPPSDKROOT or disable HLT_OPENCL." )
+endif()
+
+if ( NOT "$ENV{GPU_FORCE_64BIT_PTR}" STREQUAL "1"  )
+  message ( FATAL_ERROR "Please set env variable $GPU_FORCE_64BIT_PTR=1, required by HLT OpenCL tracker.")
+endif()
+
+#convenience variables
+set ( CAGPUDIR TPCLib/tracking-ca/cagpu )
+
+# build the OpenCL compile wrapper:
+# -- checks the correct vendor implementation (AMD)
+# -- builds binary code (blob) for the found platform(s)
+add_executable ( opencl_compiler ${CAGPUDIR}/makefiles/makefile_opencl_compiler.cpp )
+target_link_libraries ( opencl_compiler -L${AMDAPPSDKROOT}/lib/x86_64 OpenCL )
+
+#convenience variables
+set (CL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${CAGPUDIR}/AliHLTTPCCAGPUTrackerOpenCL.cl )
+set (CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/AliHLTTPCCAGPUTrackerOpenCLCode.bin )
+set (CL_INC 
+  -I${CMAKE_CURRENT_SOURCE_DIR}/BASE 
+  -I${CMAKE_CURRENT_SOURCE_DIR}/TPCLib/tracking-ca 
+  -I${CMAKE_CURRENT_SOURCE_DIR}/${CAGPUDIR}
+)
+
+# executes OpenCL compiler wrapper to build binary object
+add_custom_command(
+  OUTPUT ${CL_BIN}
+  COMMAND opencl_compiler -output-file ${CL_BIN} ${CL_SRC} -- ${CL_INC} -x clc++
+  MAIN_DEPENDENCY ${CL_SRC}
+)
+
+# make cmake compile the assembler file
+set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES LANGUAGE CXX)
+# add proper dependency on included binary code
+set_source_files_properties(${CAGPUDIR}/makefiles/include.S PROPERTIES OBJECT_DEPENDS ${CL_BIN})
+
+
+#usual aliroot library stuff...
+set ( CLASS_HDRS
+  AliHLTTPCCAGPUTrackerBase.h
+  AliHLTTPCCAGPUTrackerOpenCL.h
+)
+
+set ( MODULE_SRCS 
+  AliHLTTPCCAGPUTrackerBase.cxx
+  AliHLTTPCCAGPUTrackerOpenCL.cxx
+  makefiles/include.S
+)
+
+set ( MODULE_HDRS
+  ${CLASS_HDRS}
+  AliHLTTPCCAGPUTrackerCommon.h
+  AliHLTTPCCAGPUTrackerOpenCLInternals.h
+)
+
+set ( MODULE_DHDR )
+
+set ( EINCLUDE ${AMDAPPSDKROOT}/include HLT/${CAGPUDIR} HLT/${CAGPUDIR}/makefiles HLT/TPCLib/tracking-ca HLT/BASE )
+
+set ( ELIBS -L$(AMDAPPSDKROOT)/lib/x86_64 -lOpenCL )
+
+include ("CMakehlt.conf")
+
+if (MODULE_SRCS)
+ALICE_Format (SRCS "${CAGPUDIR}/" "" "${MODULE_SRCS}")
+endif(MODULE_SRCS)
+if (CLASS_HDRS)
+ALICE_Format (CINTHDRS "${CAGPUDIR}/" "" "${CLASS_HDRS}")
+endif(CLASS_HDRS)
+if (MODULE_HDRS)
+ALICE_Format (HDRS "${CAGPUDIR}/" "" "${MODULE_HDRS}")
+endif(MODULE_HDRS)
+if (MODULE_DHDR)
+ALICE_Format (DHDR "${CAGPUDIR}/" "" "${MODULE_DHDR}")
+endif(MODULE_DHDR)
+
+# bit of a hack, but otherwise dictionary compilation fails:
+# defines __ROOT__; triggers "ifdef" in source code to circumvent broken cint behaviour with "volatile" keyword
+# not sure why __ROOT__ is used here, could just as well be something else
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/G__AliHLTTPCCAGPUOpenCL.cxx PROPERTIES COMPILE_DEFINITIONS "__ROOT__")
+
+if(NOT DHDR)
+  set(CINTAUTOLINK 1)
+endif(NOT DHDR)
+
+set ( EDEFINE  ${HLTDEFS} )
+set ( PACKCXXFLAGS  "${HLTCXXFLAGS} -Wshadow -Wall -O3")
+set ( PACKCFLAGS  ${HLTCLFAGS})
+set ( PACKDCXXFLAGS  ${HLTDCXXFLAGS})
+set ( PACKSOFLAGS ${HLTSOFLAGS})
+#set ( CINTFLAGS )
diff --git a/ITS/UPGRADE/AliITSUSuze02.cxx b/ITS/UPGRADE/AliITSUSuze02.cxx
new file mode 100644 (file)
index 0000000..c5d18bf
--- /dev/null
@@ -0,0 +1,262 @@
+#include "TMath.h"
+#include "AliITSUSuze02.h"
+
+//*******************************************************************
+//
+//  Simulation of the SUZE02 readout
+//  Origin: Serhiy.Senuykov@cern.ch
+//  
+//*******************************************************************
+
+ClassImp(AliITSUSuze02)
+
+AliITSUSuze02::AliITSUSuze02(Int_t Nrows, Int_t Ncols) {
+  if(Ncols%(kNumberOfFSBB*kNumberOfHalfFSBB)==0){  
+    fNRowsModule=Nrows;
+    fNColsModule=Ncols;
+    fModule=new TMatrixF(fNRowsModule,fNColsModule); 
+    
+    fNWindowsPer32colsMax=0;
+    fNWindowsPerHalfFSBBMax=0;
+    fNWindowsPerFSBBMax=0;
+    
+    fTestColumnSize=2;
+    fTestRowSize=2;
+  }
+  else{
+    printf("Number of columns should be multiple of %d. SUZE matrix wasn't created\n",kNumberOfFSBB*kNumberOfHalfFSBB);
+  }
+}  
+  
+AliITSUSuze02::~AliITSUSuze02() {
+  if(fModule) delete fModule;
+}
+
+void AliITSUSuze02::SetEncodingWindowSize(Int_t Wrows, Int_t Wcols){
+  fTestColumnSize=Wrows;
+  fTestRowSize=Wcols;
+}
+
+void AliITSUSuze02::SetQuotas(Int_t q32, Int_t qHalfFSBB, Int_t qFSBB){
+  fNWindowsPer32colsMax=q32;
+  fNWindowsPerHalfFSBBMax=qHalfFSBB;
+  fNWindowsPerFSBBMax=qFSBB;
+}
+
+void AliITSUSuze02::AddDigit(Int_t row, Int_t col){
+  (*fModule)(row,col)++;
+}
+
+//void AliITSUSuze02::Process(Bool_t Verbose){  
+void AliITSUSuze02::Process(TH1F* OverflowCodes, TH1F* NDigitsPerEncodingWindowDist, Bool_t Verbose) {
+
+  //cout<<"Processing"<<endl;
+  //fModule->Print(); 
+  
+  Int_t NRowsFSBB=fNRowsModule;
+  Int_t NColsFSBB=fNColsModule/kNumberOfFSBB;
+  TMatrixF FSBB(NRowsFSBB,NColsFSBB);
+  
+  Int_t NRowsSuperLine=fTestColumnSize;
+  Int_t NColsSuperLine=NColsFSBB;   
+  TMatrixF SuperLineUp(NRowsSuperLine,NColsSuperLine);
+  TMatrixF SuperLineDown(NRowsSuperLine,NColsSuperLine);
+  
+  Int_t NRowsSuperLineX2=NRowsSuperLine*2; 
+  Int_t NColsSuperLineX2=NColsSuperLine; //SuperLineX2 and SuperLine size in columns is equal to FSBB.
+  TMatrixF SuperLineX2(NRowsSuperLineX2,NColsSuperLineX2); 
+  
+  TMatrixF TestRow(1,fTestRowSize);
+  TMatrixF TestColumn(fTestColumnSize,1);      
+  Int_t TestRowSum=0;
+  TMatrixF EncodingWindow(fTestColumnSize,fTestRowSize);
+  
+  Int_t EncodingWindowStartRow=0;
+  Int_t EncodingWindowStopRow=0;
+  Int_t EncodingWindowStartCol=0;
+  Int_t EncodingWindowStopCol=0;
+  
+  Int_t nMasks=fTestRowSize-1;
+  Int_t MaskSize=NRowsSuperLineX2-1;
+  TMatrixF Masks(MaskSize,nMasks);
+
+   //parameters for internal data size calculation
+  Int_t DataSizePerWindowInRow=8+fTestColumnSize*fTestRowSize+TMath::Ceil(TMath::Log2(fTestColumnSize));
+  Int_t DataSizePerSuperLineX2Header=30;   
+  
+  Int_t DataSizePerSuperLineX2=0;
+  
+  Bool_t Overflow32=kFALSE;
+  Bool_t OverflowHalfFSBB=kFALSE;
+  Bool_t OverflowFSBB=kFALSE;
+  
+  Int_t nWindowsPer32cols=fNWindowsPer32colsMax;
+  Int_t nWindowsPerHalfFSBB=fNWindowsPerHalfFSBBMax;
+  Int_t nWindowsPerFSBB=fNWindowsPerFSBBMax; 
+  
+  fNWindowsPer32colsMin=fNWindowsPer32colsMax;
+  fNWindowsPerHalfFSBBMin=fNWindowsPerHalfFSBBMax;
+  fNWindowsPerFSBBMin=fNWindowsPerFSBBMax;  
+  
+  fNEncodedWindows=0;
+  fNDigitsEncoded=0;
+  fNLostWindows=0;
+  fNDigitsLost=0;
+  fDataSizePerModule=0;    
+  
+  for(Int_t FSBBindex=0; FSBBindex<kNumberOfFSBB; FSBBindex++){
+    FSBB=fModule->GetSub(0,NRowsFSBB-1,FSBBindex*NColsFSBB,(FSBBindex+1)*NColsFSBB-1);
+    SuperLineDown=FSBB.GetSub(0,NRowsSuperLine-1,0,NColsSuperLine-1);
+    for(Int_t SuperLineX2StartRow=0; SuperLineX2StartRow<NRowsFSBB; SuperLineX2StartRow+=NRowsSuperLine){
+      if(nWindowsPerFSBB<fNWindowsPerFSBBMin) {fNWindowsPerFSBBMin=nWindowsPerFSBB;} //saving the lowest number of remaining windows
+      nWindowsPerFSBB=fNWindowsPerFSBBMax; //Reset number of available encoding windows for the new double SuperLine
+      OverflowFSBB=kFALSE;
+      SuperLineUp=SuperLineDown;
+      if(SuperLineX2StartRow+NRowsSuperLineX2<=NRowsFSBB){
+        SuperLineDown=FSBB.GetSub(SuperLineX2StartRow+NRowsSuperLine,SuperLineX2StartRow+NRowsSuperLineX2-1,0,NColsSuperLine-1);
+      }
+      else if(SuperLineX2StartRow+NRowsSuperLine<NRowsFSBB){
+        SuperLineDown.Zero();
+        SuperLineDown.SetSub(0,0,FSBB.GetSub(SuperLineX2StartRow+NRowsSuperLine,NRowsFSBB-1,0,NColsSuperLine-1));
+      } 
+      else{
+        SuperLineDown.Zero();
+      }
+      if(SuperLineUp.Sum()>0){
+        DataSizePerSuperLineX2=0; 
+        SuperLineX2.SetSub(0,0,SuperLineUp);
+        SuperLineX2.SetSub(NRowsSuperLine,0,SuperLineDown);
+        for(Int_t HalfFSBBindex=0; HalfFSBBindex<kNumberOfHalfFSBB; HalfFSBBindex++){
+          if(nWindowsPerHalfFSBB<fNWindowsPerHalfFSBBMin) {fNWindowsPerHalfFSBBMin=nWindowsPerHalfFSBB;}  
+          nWindowsPerHalfFSBB=fNWindowsPerHalfFSBBMax; //reset counter per HalfFSBB
+          OverflowHalfFSBB=kFALSE;
+          for(Int_t i=0; i<MaskSize; i++){ //reset masks to 1111111
+            for(Int_t j=0; j<nMasks; j++){
+              Masks(i,j)=1;
+            }
+          }
+          
+          for(Int_t TestRowStartCol=HalfFSBBindex*NColsSuperLineX2/kNumberOfHalfFSBB; TestRowStartCol<(HalfFSBBindex+1)*NColsSuperLineX2/kNumberOfHalfFSBB; TestRowStartCol++){
+            if(TestRowStartCol%32==0){
+                   if(nWindowsPer32cols<fNWindowsPer32colsMin) fNWindowsPer32colsMin=nWindowsPer32cols;
+              nWindowsPer32cols=fNWindowsPer32colsMax; //reset nWindowsPer32cols counter every 32 columns
+              Overflow32=kFALSE;
+            }
+            //apply masks
+            for(Int_t RowIndex=0; RowIndex<MaskSize; RowIndex++){
+              for(Int_t MaskIndex=0; MaskIndex<nMasks; MaskIndex++){
+                if(Masks(RowIndex,MaskIndex)==0){
+                  // cout<<"Mask has zero bit at pos:"<<RowIndex<<":"<<MaskIndex<<endl;
+                  // cout<<"will clean the pixels at row:"<<RowIndex<<" from pos.:"<<TestRowStartCol<<" till "<< TestRowStartCol+(nMasks-MaskIndex)<<endl;
+                  for(Int_t ColIndex=TestRowStartCol; ColIndex<TestRowStartCol+(nMasks-MaskIndex); ColIndex++){
+                    if(ColIndex<(HalfFSBBindex+1)*NColsSuperLineX2/kNumberOfHalfFSBB){
+                      SuperLineX2(RowIndex,ColIndex)=0;
+                      // cout<<"Mask has zero bit. Cleaning at pos:"<<RowIndex<<":"<<ColIndex<<endl;
+                      if(RowIndex>=fTestColumnSize){
+                        SuperLineDown(RowIndex-fTestColumnSize,ColIndex)=0;
+                      }
+                    }
+                  }
+                  break;
+                }
+              }
+            }
+            //shift masks
+            for(Int_t RowIndex=0; RowIndex<MaskSize; RowIndex++){
+              for(Int_t MaskIndex=nMasks-1; MaskIndex>0; MaskIndex--){
+                Masks(RowIndex,MaskIndex)=Masks(RowIndex,MaskIndex-1);
+              }
+              Masks(RowIndex,0)=1;
+            }  
+            
+            for(Int_t TestRowStartRow=0; TestRowStartRow<fTestColumnSize; TestRowStartRow++){
+              TestRowSum=0;
+              for(Int_t TestRowIndex=0; TestRowIndex<fTestRowSize; TestRowIndex++){
+                if(TestRowStartCol+TestRowIndex<(HalfFSBBindex+1)*NColsSuperLineX2/kNumberOfHalfFSBB){
+                  TestRowSum+=SuperLineX2(TestRowStartRow,TestRowStartCol+TestRowIndex);
+                }
+                if(TestRowSum>0){
+                  //cout<<"TestR at col n."<<TestRowStartCol<<" and row n."<<TestRowStartRow<<" has a hit"<<endl;
+                  break;
+                }
+              }
+              if(TestRowSum>0){
+                TestColumn=SuperLineX2.GetSub(TestRowStartRow,TestRowStartRow+fTestColumnSize-1,TestRowStartCol,TestRowStartCol);   
+                if(TestColumn.Sum()>0){
+                  EncodingWindowStartRow=TestRowStartRow;
+                  EncodingWindowStopRow=EncodingWindowStartRow+fTestColumnSize-1;
+                  EncodingWindowStartCol=TestRowStartCol; 
+                  
+                  if(TestRowStartCol+fTestRowSize>(HalfFSBBindex+1)*NColsSuperLineX2/kNumberOfHalfFSBB){
+                    EncodingWindowStopCol=((HalfFSBBindex+1)*NColsSuperLineX2/kNumberOfHalfFSBB)-1;
+                  }
+                  else{
+                    EncodingWindowStopCol=EncodingWindowStartCol+fTestRowSize-1;
+                  }
+
+                  EncodingWindow.Zero();
+                  EncodingWindow.SetSub(0,0,SuperLineX2.GetSub(EncodingWindowStartRow,EncodingWindowStopRow,EncodingWindowStartCol,EncodingWindowStopCol));
+                  
+                  if(nWindowsPer32cols && nWindowsPerHalfFSBB && nWindowsPerFSBB){
+                    //cout<<"Will encode window starting at "<<TestRowStartRow<<":"<<TestRowStartCol<<endl;
+                    fNDigitsEncoded+=EncodingWindow.Sum();
+                    fNEncodedWindows++;
+                    OverflowCodes->Fill(0);
+                               NDigitsPerEncodingWindowDist->Fill(EncodingWindow.Sum());
+                    nWindowsPerFSBB--;
+                    nWindowsPerHalfFSBB--;
+                    nWindowsPer32cols--;
+                    DataSizePerSuperLineX2+=DataSizePerWindowInRow;
+                    //cout<<"Windows left:"<<nWindowsPerFSBB<<":"<<nWindowsPerHalfFSBB<<":"<<nWindowsPer32cols<<endl;
+                  }
+                  else{
+                    fNDigitsLost+=EncodingWindow.Sum();
+                    fNLostWindows++;
+                    //cout<<"------ No encoding at col.:"<<TestRowStartCol<<" at SuperLineX2 that starts at row:"<<SuperLineX2StartRow<<endl;
+                    if(!nWindowsPer32cols) Overflow32=kTRUE;
+                    if(!nWindowsPerHalfFSBB) OverflowHalfFSBB=kTRUE;
+                    if(!nWindowsPerFSBB) OverflowFSBB=kTRUE;
+                    OverflowCodes->Fill(Overflow32+2*OverflowHalfFSBB+4*OverflowFSBB);
+                  } 
+                  for(Int_t k=TestRowStartRow;k<TestRowStartRow+fTestColumnSize; k++){
+                    Masks(k,0)=0;
+                    //cout<<"Setting Mask to 0 at "<<k<<endl;
+                    //Setting to 0 the first column of the encoding window. This part if probably present in the real SUZE.
+                    SuperLineX2(k,TestRowStartCol)=0;
+                    if(k>=fTestColumnSize){
+                      SuperLineDown(k-fTestColumnSize,TestRowStartCol)=0;
+                    }
+                  }
+                }  
+                break;
+              }
+            }
+          }
+        }
+        fDataSizePerModule+=(DataSizePerSuperLineX2+DataSizePerSuperLineX2Header);
+      }
+    }
+  }
+  if(Verbose){
+    cout<<fNDigitsEncoded<<" digits encoded in "<<fNEncodedWindows<<" windows"<<endl;
+    cout<<fNDigitsLost<<" digits lost in "<<fNLostWindows<<" windows"<<endl;
+  }
+}
+
+void AliITSUSuze02::GetResults(){
+  
+}
+/*
+void AliITSUSuze02::InitHistos(){
+  fOverflowCodes = new TH1F("OverflowCodes","Overflow codes",8,0,8);
+  if(fNRowsModule*fNColsModule){
+    fNDigitsPerEncodingWindowDist = new TH1F("nDigitsPerEncodingWindowPerModule","nDigitsPerEncodingWindowPerModule",fTestColumnSize*fTestRowSize,1,fTestColumnSize*fTestRowSize+1);
+  }
+  else{
+    printf("Run AliITSUSuze02::SetEncodingWindowSize first\n");
+  }
+}
+*/
+void AliITSUSuze02::ResetModule(){
+  fModule->Zero();
+}
diff --git a/ITS/UPGRADE/AliITSUSuze02.h b/ITS/UPGRADE/AliITSUSuze02.h
new file mode 100644 (file)
index 0000000..8f9fa51
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef ALIITSUSUZE02_H
+#define ALIITSUSUZE02_H
+
+#include <Riostream.h>
+#include <TMatrixF.h>
+#include <TH1F.h>
+
+//*******************************************************************
+//
+//  Simulation of the SUZE02 readout
+//  Origin: Serhiy.Senuykov@cern.ch
+//  (see macros/ScanDigitsSuze02*.C for an example of use)
+//
+//*******************************************************************
+
+class AliITSUSuze02{
+  public:
+  AliITSUSuze02(Int_t Nrows, Int_t Ncols);
+  virtual ~AliITSUSuze02();
+  
+  void SetEncodingWindowSize(Int_t Wrows, Int_t Wcols);
+  void SetQuotas(Int_t q32, Int_t qHalfFSBB, Int_t qFSBB);
+  //void InitHistos(); 
+  void AddDigit(Int_t row, Int_t col);
+  void Process(TH1F* OverflowCodes, TH1F* NDigitsPerEncodingWindowDist, Bool_t Verbose=kFALSE); 
+  //void Process(Bool_t Verbose=kFALSE); 
+       
+  void GetResults();  
+  Int_t GetNDigitsEncoded() {return fNDigitsEncoded;}
+  Int_t GetNEncodedWindows() {return fNEncodedWindows;} 
+  Int_t GetNDigitsLost() {return fNDigitsLost;}
+  Int_t GetNLostWindows() {return fNLostWindows;}    
+  
+  Int_t GetDataSize() {return fDataSizePerModule;}  
+  
+  Int_t GetNWindowsPer32colsMin() {return fNWindowsPer32colsMin;}
+  Int_t GetNWindowsPerHalfFSBBMin() {return fNWindowsPerHalfFSBBMin;}
+  Int_t GetNWindowsPerFSBBMin() {return fNWindowsPerFSBBMin;}
+  
+  void ResetModule();
+  
+  private:         
+  static const Int_t kNumberOfFSBB=3; 
+  static const Int_t kNumberOfHalfFSBB=2;
+  
+  //matrix to be processed by Suze02   
+  Int_t fNRowsModule;
+  Int_t fNColsModule;
+  TMatrixF* fModule; 
+               
+  //Suze02 parameters
+  Int_t fTestColumnSize;   //Number of rows of the encoding window
+  Int_t fTestRowSize;   //Number of columns of the encoding window
+  
+  //Suze02 quotas
+  Int_t fNWindowsPer32colsMax;
+  Int_t fNWindowsPerHalfFSBBMax;
+  Int_t fNWindowsPerFSBBMax;
+  
+  //results    
+  Int_t fNDigitsEncoded; 
+  Int_t fNEncodedWindows;
+  
+  Int_t fNDigitsLost;
+  Int_t fNLostWindows;
+  
+  //TH1F* fOverflowCodes;
+  //TH1F* fNDigitsPerEncodingWindowDist;
+  
+  Int_t fDataSizePerModule;
+  
+  Int_t fNWindowsPer32colsMin;
+  Int_t fNWindowsPerHalfFSBBMin;
+  Int_t fNWindowsPerFSBBMin;
+
+  ClassDef(AliITSUSuze02,1)
+};
+
+#endif
diff --git a/ITS/UPGRADE/AliITSUv1.cxx b/ITS/UPGRADE/AliITSUv1.cxx
new file mode 100644 (file)
index 0000000..95bc298
--- /dev/null
@@ -0,0 +1,770 @@
+/**************************************************************************
+ * 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: AliITSUv1.cxx */
+
+
+//========================================================================
+//
+//        Geometry for the Upgrade of the Inner Tracking System
+//
+// Mario Sitta (sitta@to.infn.it)
+// Chinorat Kobdaj (kobdaj@g.sut.ac.th)
+//
+//========================================================================
+
+
+
+// $Log: AliITSUv1.cxx,v $
+
+#include <TClonesArray.h>
+#include <TGeoGlobalMagField.h>
+#include <TGeoManager.h>
+#include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
+#include <TGeoVolume.h>
+#include <TGeoTube.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 "AliITSUv1Layer.h"
+#include "AliITSUv1.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliGeomManager.h"
+using namespace TMath;
+
+
+ClassImp(AliITSUv1)
+
+//______________________________________________________________________
+AliITSUv1::AliITSUv1()
+:  fNWrapVol(0)
+  ,fWrapRMin(0)
+  ,fWrapRMax(0)
+  ,fWrapZSpan(0)
+  ,fLayTurbo(0)
+  ,fLayPhi0(0)
+  ,fLayRadii(0)
+  ,fLayZLength(0)
+  ,fLaddPerLay(0)
+  ,fModPerLadd(0)
+  ,fLadThick(0)
+  ,fLadWidth(0)
+  ,fLadTilt(0)
+  ,fDetThick(0)
+  ,fDetTypeID(0)
+  ,fBuildLevel(0)
+  ,fUpGeom(0)
+  ,fStaveModelIB(kIBModel0)
+  ,fStaveModelOB(kOBModel0)
+{
+  //    Standard default constructor
+  // Inputs:
+  //   none.
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+}
+
+//______________________________________________________________________
+AliITSUv1::AliITSUv1(const char *title,const Int_t nlay)
+  :AliITSU(title,nlay)
+  ,fNWrapVol(0)
+  ,fWrapRMin(0)
+  ,fWrapRMax(0)
+  ,fWrapZSpan(0)
+  ,fLayTurbo(0)
+  ,fLayPhi0(0)
+  ,fLayRadii(0)
+  ,fLayZLength(0)
+  ,fLaddPerLay(0)
+  ,fModPerLadd(0)
+  ,fLadThick(0)
+  ,fLadWidth(0)
+  ,fLadTilt(0)
+  ,fDetThick(0)
+  ,fDetTypeID(0)
+  ,fBuildLevel(0)
+  ,fUpGeom(0)
+  ,fStaveModelIB(kIBModel0)
+  ,fStaveModelOB(kOBModel0)
+{
+  //    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 AliITSUv1Layer
+  //
+  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];
+  fBuildLevel = new Int_t[fNLayers];
+
+
+  fUpGeom = new AliITSUv1Layer*[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;
+      fBuildLevel[j] = 0;
+      fUpGeom[j] = 0;     
+    }
+  }
+}
+
+//______________________________________________________________________
+AliITSUv1::~AliITSUv1() {
+  //    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 [] fBuildLevel;
+  delete [] fUpGeom;
+  delete [] fWrapRMin;
+  delete [] fWrapRMax;
+  delete [] fWrapZSpan;
+}
+
+//______________________________________________________________________
+void AliITSUv1::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 AliITSUv1::SetNWrapVolumes(Int_t n)
+{
+  // book arrays for wrapper volumes
+  if (fNWrapVol) AliFatal(Form("%d wrapper volumes already defined",fNWrapVol));
+  if (n<1) return;
+  fNWrapVol = n;
+  fWrapRMin = new Double_t[fNWrapVol];
+  fWrapRMax = new Double_t[fNWrapVol];
+  fWrapZSpan= new Double_t[fNWrapVol];
+  for (int i=fNWrapVol;i--;) fWrapRMin[i]=fWrapRMax[i]=fWrapZSpan[i]=-1;
+  //
+}
+
+//______________________________________________________________________
+void AliITSUv1::DefineWrapVolume(Int_t id, Double_t rmin,Double_t rmax, Double_t zspan)
+{
+  // set parameters of id-th wrapper volume
+  if (id>=fNWrapVol||id<0) AliFatal(Form("id=%d of wrapper volume is not in 0-%d range",id,fNWrapVol-1));
+  fWrapRMin[id] = rmin;
+  fWrapRMax[id] = rmax;
+  fWrapZSpan[id] = zspan;
+}
+
+//______________________________________________________________________
+void AliITSUv1::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());
+  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"; //?
+  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++)
+
+  // Create the wrapper volumes
+  TGeoVolume **wrapVols = 0;
+  if (fNWrapVol) {
+    wrapVols = new TGeoVolume*[fNWrapVol];
+    for (int id=0;id<fNWrapVol;id++) {
+      wrapVols[id] = CreateWrapperVolume(id);
+      vITSV->AddNode(wrapVols[id], 1, 0);
+    }
+  }
+  //
+  // Now create the actual geometry
+  for (Int_t j=0; j<fNLayers; j++) {
+    TGeoVolume* dest = vITSV;
+    //
+    if (fLayTurbo[j]) {
+      fUpGeom[j] = new AliITSUv1Layer(j,kTRUE,kFALSE);
+      fUpGeom[j]->SetLadderWidth(fLadWidth[j]);
+      fUpGeom[j]->SetLadderTilt(fLadTilt[j]);
+    }
+    else fUpGeom[j] = new AliITSUv1Layer(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]);
+    fUpGeom[j]->SetBuildLevel(fBuildLevel[j]);
+    if (j < 3)
+      fUpGeom[j]->SetStaveModel(fStaveModelIB);
+    else
+      fUpGeom[j]->SetStaveModel(fStaveModelOB);
+    AliDebug(1,Form("fBuildLevel: %d\n",fBuildLevel[j]));
+    //
+    if (fLadThick[j] != 0) fUpGeom[j]->SetLadderThick(fLadThick[j]);
+    if (fDetThick[j] != 0) fUpGeom[j]->SetSensorThick(fDetThick[j]);
+    //
+    for (int iw=0;iw<fNWrapVol;iw++) {
+      if (fLayRadii[j]>fWrapRMin[iw] && fLayRadii[j]<fWrapRMax[iw]) {
+       AliInfo(Form("Will embed layer %d in wrapper volume %d",j,iw));
+       if (fLayZLength[j]>=fWrapZSpan[iw]) AliFatal(Form("ZSpan %.3f of wrapper volume %d is less than ZSpan %.3f of layer %d",
+                                                         fWrapZSpan[iw],iw,fLayZLength[j],j));
+       dest = wrapVols[iw];
+       break;
+      }
+    }
+    fUpGeom[j]->CreateLayer(dest);
+  }
+  delete wrapVols; // delete pointer only, not the volumes
+  //
+}
+
+//______________________________________________________________________
+void AliITSUv1::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;
+
+  // Water
+  Float_t aWater[2]={1.00794,15.9994};
+  Float_t zWater[2]={1.,8.};
+  Float_t wWater[2]={0.111894,0.888106};
+  Float_t dWater   = 1.0;
+
+
+  // Kapton
+  Float_t aKapton[4]={1.00794,12.0107, 14.010,15.9994};
+  Float_t zKapton[4]={1.,6.,7.,8.};
+  Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
+  Float_t dKapton   = 1.42;
+  AliMixture(1,"AIR$",aAir,zAir,dAir,4,wAir);
+  AliMedium(1, "AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+  AliMixture(2,"WATER$",aWater,zWater,dWater,2,wWater);
+  AliMedium(2, "WATER$",2,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+  AliMaterial(3,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+  AliMedium(3,  "SI$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+  AliMaterial(4,"BERILLIUM$",9.01, 4., 1.848, 35.3, 36.7);// From AliPIPEv3
+  AliMedium(4,  "BERILLIUM$",4,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+  AliMaterial(5,"COPPER$",0.63546E+02,0.29000E+02,0.89600E+01,0.14300E+01,0.99900E+03);
+  AliMedium(5,  "COPPER$",5,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    
+  // needed for STAVE , Carbon, kapton, Epoxy, flexcable
+
+  //AliMaterial(6,"CARBON$",12.0107,6,2.210,999,999);
+  AliMaterial(6,"CARBON$",12.0107,6,2.210/1.3,999,999);
+  AliMedium(6,  "CARBON$",6,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+  AliMixture(7,"KAPTON(POLYCH2)$", aKapton, zKapton, dKapton, 4, wKapton);
+  AliMedium(7, "KAPTON(POLYCH2)$",7,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+  // values below modified as compared to source AliITSv11 !
+
+  //AliMaterial(7,"GLUE$",0.12011E+02,0.60000E+01,0.1930E+01/2.015,999,999); // original
+  AliMaterial(15,"GLUE$",12.011,6,1.93/2.015,999,999);  // conform with ATLAS, Corrado, Stefan
+  AliMedium(15,  "GLUE$",15,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+  // All types of carbon
+  // Unidirectional prepreg
+ AliMaterial(8,"K13D2U2k$",12.0107,6,1.643,999,999);
+ AliMedium(8,  "K13D2U2k$",8,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+ //Impregnated thread
+ AliMaterial(9,"M60J3K$",12.0107,6,2.21,999,999);
+ AliMedium(9,  "M60J3K$",9,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+ //Impregnated thread
+ AliMaterial(10,"M55J6K$",12.0107,6,1.63,999,999);
+ AliMedium(10,  "M55J6K$",10,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+ // Fabric(0/90)
+ AliMaterial(11,"T300$",12.0107,6,1.725,999,999);
+ AliMedium(11,  "T300$",11,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+ //AMEC Thermasol
+ AliMaterial(12,"FGS003$",12.0107,6,1.6,999,999);
+ AliMedium(12,  "FGS003$",12,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+ // Carbon fleece
+ AliMaterial(13,"CarbonFleece$",12.0107,6,0.4,999,999);
+ AliMedium(13,  "CarbonFleece$",13,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+  // Flex cable
+  Float_t aFCm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
+  Float_t zFCm[5]={6.,1.,7.,8.,13.};
+  Float_t wFCm[5]={0.520088819984,0.01983871336,0.0551367996,0.157399667056, 0.247536};
+  //Float_t dFCm = 1.6087;  // original
+  //Float_t dFCm = 2.55;   // conform with STAR
+   Float_t dFCm = 2.595;   // conform with Corrado
+
+  AliMixture(14,"FLEXCABLE$",aFCm,zFCm,dFCm,5,wFCm);
+  AliMedium(14, "FLEXCABLE$",14,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+  AliMaterial(16,"ALUMINUM$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
+  AliMedium(16,"ALUMINUM$",16,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+}
+
+//______________________________________________________________________
+void AliITSUv1::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,
+                           const Int_t buildLevel)
+{
+  //     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)
+  //          buildLevel (if 0, all geometry is build, used for material budget studies)
+  // 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;
+  fBuildLevel[nlay] = buildLevel;
+    
+}
+
+//______________________________________________________________________
+void AliITSUv1::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, Int_t buildLevel)
+{
+  //     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)
+  //          dettypeID  ??
+  //          buildLevel (if 0, all geometry is build, used for material budget studies)
+  // 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;
+  fBuildLevel[nlay] = buildLevel;
+
+}
+
+//______________________________________________________________________
+void AliITSUv1::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,
+                                  UInt_t &dettype) 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
+  //          dettype detector type
+  // 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];
+  dettype= fDetTypeID[nlay];
+}
+
+//______________________________________________________________________
+TGeoVolume* AliITSUv1::CreateWrapperVolume(Int_t id)
+{
+  //     Creates an air-filled wrapper cylindrical volume 
+  // Inputs:
+  //          volume id
+  // Outputs:
+  //          the wrapper volume
+
+  if (fWrapRMin[id]<0 || fWrapRMax[id]<0 || fWrapZSpan[id]<0) AliFatal(Form("Wrapper volume %d was requested but not defined",id));
+  // Now create the actual shape and volume
+  //
+  TGeoTube *tube = new TGeoTube(fWrapRMin[id], fWrapRMax[id], fWrapZSpan[id]/2.);
+
+  TGeoMedium *medAir = gGeoManager->GetMedium("ITS_AIR$");
+
+  char volnam[30];
+  snprintf(volnam, 29, "%s%d", AliITSUGeomTGeo::GetITSWrapVolPattern(),id);
+
+  TGeoVolume *wrapper = new TGeoVolume(volnam, tube, medAir);
+
+  return wrapper;
+}
+
+//______________________________________________________________________
+void AliITSUv1::Init()
+{
+  //     Initialise the ITS after it has been created.
+  UpdateInternalGeometry();
+  AliITSU::Init();
+  //  
+}
+
+//______________________________________________________________________
+Bool_t AliITSUv1::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 AliITSUv1::SetDefaults()
+{
+  // sets the default segmentation, response, digit and raw cluster classes
+}
+
+//______________________________________________________________________
+void AliITSUv1::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 AliITSUv1::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 AliITSUv1::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/AliITSUv1.h b/ITS/UPGRADE/AliITSUv1.h
new file mode 100644 (file)
index 0000000..40336b2
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef ALIITSUV1_H
+#define ALIITSUV1_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: AliITSUv1.h 
+
+#include "AliITSU.h"
+
+class  AliITSUv1Layer;
+//class  AliITSv11GeomBeamPipe;
+class  TGeoVolume;
+class  TGeoVolumeAssembly;
+
+class AliITSUv1 : public AliITSU {
+
+ public:
+
+
+  typedef enum {
+    kIBModelDummy=0,
+    kIBModel0=1,
+    kIBModel1=2, 
+    kIBModel21=3,
+    kIBModel22=4,
+    kIBModel3=5,
+    kOBModelDummy=6,
+    kOBModel0=7,
+    kOBModel1=8 
+  } AliITSUModel_t;
+  
+
+  AliITSUv1();
+  AliITSUv1(const char *title, const Int_t nlay);
+  virtual       ~AliITSUv1() ;
+  virtual void   SetNWrapVolumes(Int_t n);
+  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, Int_t buildFlag=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, Int_t buildFlag=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,
+                                   UInt_t &dettype) const;
+  virtual void   DefineWrapVolume(Int_t id, Double_t rmin,Double_t rmax, Double_t zspan);
+  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);
+  virtual void   SetStaveModelIB(AliITSUModel_t model) {fStaveModelIB=model;}
+  virtual void   SetStaveModelOB(AliITSUModel_t model) {fStaveModelOB=model;}
+  virtual AliITSUModel_t GetStaveModelIB() const {return fStaveModelIB;}
+  virtual AliITSUModel_t GetStaveModelOB() const {return fStaveModelOB;}
+  //
+ private:
+  AliITSUv1(const AliITSUv1 &source); // copy constructor
+  AliITSUv1& operator=(const AliITSUv1 &source); // assignment operator
+
+  TGeoVolume* CreateWrapperVolume(const Int_t nLay);
+
+  //
+  Int_t     fNWrapVol;       // number of wrapper volumes
+  Double_t* fWrapRMin;       // min radius of wrapper volume
+  Double_t* fWrapRMax;       // max radius of wrapper volume
+  Double_t* fWrapZSpan;      // Z span of wrapper volume
+  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
+  Int_t    *fBuildLevel;     // Vector of Material Budget Studies
+  //  
+  AliITSUv1Layer **fUpGeom; //! Geometry
+  AliITSUModel_t fStaveModelIB; // The stave model for the Inner Barrel
+  AliITSUModel_t fStaveModelOB; // The stave model for the Outer Barrel
+  
+  // Parameters for the Upgrade geometry
+  
+  ClassDef(AliITSUv1,0)                          
+};
+#endif
diff --git a/ITS/UPGRADE/AliITSUv1Layer.cxx b/ITS/UPGRADE/AliITSUv1Layer.cxx
new file mode 100644 (file)
index 0000000..05153c8
--- /dev/null
@@ -0,0 +1,2646 @@
+/**************************************************************************
+ * 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>
+//  Chinorat Kobdaj (kobdaj@g.sut.ac.th)
+//*************************************************************************
+
+
+/* $Id: AliITSUv1Layer.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 "AliITSUv1Layer.h"
+#include "AliITSUGeomTGeo.h"
+#include <TGeoBBox.h>
+#include <TGeoShape.h>
+#include <TGeoTrd1.h>
+using namespace TMath;
+
+const Double_t AliITSUv1Layer::fgkDefaultSensorThick = 300*fgkmicron;
+const Double_t AliITSUv1Layer::fgkDefaultLadderThick =   1*fgkcm;
+
+const Double_t AliITSUv1Layer::fgkOBHalfStaveWidth   =   3.01 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBModuleGap        =   0.01 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBFlexCable1Thick  =   0.005*fgkcm;
+const Double_t AliITSUv1Layer::fgkOBFlexCable2Thick  =   0.01 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBBusCable1Thick   =   0.02 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBBusCable2Thick   =   0.02 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBColdPlateThick   =   0.012*fgkcm;
+const Double_t AliITSUv1Layer::fgkOBCarbonPlateThick =   0.012*fgkcm;
+const Double_t AliITSUv1Layer::fgkOBGlueThick        =   0.03 *fgkcm;
+const Double_t AliITSUv1Layer::fgkOBModuleZLength    =  21.06 *fgkcm;
+
+
+ClassImp(AliITSUv1Layer)
+
+#define SQ(A) (A)*(A)
+
+//________________________________________________________________________
+AliITSUv1Layer::AliITSUv1Layer(): 
+  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),
+  fBuildLevel(0),
+  fStaveModel(AliITSUv1::kIBModelDummy)
+{
+  //
+  // Standard constructor
+  //
+}
+
+//________________________________________________________________________
+AliITSUv1Layer::AliITSUv1Layer(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),
+  fBuildLevel(0),
+  fStaveModel(AliITSUv1::kIBModelDummy)
+{
+  //
+  // Constructor setting debugging level
+  //
+}
+
+//________________________________________________________________________
+AliITSUv1Layer::AliITSUv1Layer(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),
+  fBuildLevel(0),
+  fStaveModel(AliITSUv1::kIBModelDummy)
+{
+  //
+  // Constructor setting layer number and debugging level
+  //
+}
+
+//________________________________________________________________________
+AliITSUv1Layer::AliITSUv1Layer(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),
+  fBuildLevel(0),
+  fStaveModel(AliITSUv1::kIBModelDummy)
+{
+  //
+  // Constructor setting layer number and debugging level
+  // for a "turbo" layer (i.e. where ladders overlap in phi)
+  //
+}
+
+//________________________________________________________________________
+AliITSUv1Layer::AliITSUv1Layer(const AliITSUv1Layer &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(s.fDetTypeID),
+  fIsTurbo(s.fIsTurbo),
+  fBuildLevel(s.fBuildLevel),
+  fStaveModel(s.fStaveModel)
+{
+  //
+  // Copy constructor
+  //
+}
+
+//________________________________________________________________________
+AliITSUv1Layer& AliITSUv1Layer::operator=(const AliITSUv1Layer &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;
+  fBuildLevel  = s.fBuildLevel;
+  fStaveModel  = s.fStaveModel;
+
+  return *this;
+}
+
+//________________________________________________________________________
+AliITSUv1Layer::~AliITSUv1Layer() {
+  //
+  // Destructor
+  //
+}
+
+//________________________________________________________________________
+void AliITSUv1Layer::CreateLayer(TGeoVolume *moth){
+//
+// Creates the actual Layer and places inside its mother volume
+//
+// Input:
+//         moth : the TGeoVolume owing the volume structure
+//
+// Output:
+//
+// Return:
+//
+// Created:      17 Jun 2011  Mario Sitta
+// Updated:      08 Jul 2011  Mario Sitta
+// Updated:      20 May 2013  Mario Sitta  Layer is Assembly instead of Tube
+//
+  // Local variables
+  char volname[30];
+  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);
+    return;
+  }
+
+
+  // First create the ladder container
+  alpha = (360./(2*fNLadders))*DegToRad();
+
+  //  fLadderWidth = fLayRadius*Tan(alpha);
+
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
+  TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
+  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 AliITSUv1Layer::CreateLayerTurbo(TGeoVolume *moth){
+//
+// 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
+//
+// Output:
+//
+// Return:
+//
+// Created:      08 Jul 2011  Mario Sitta
+// Updated:      08 Mar 2012  Mario Sitta  Correct way to compute container R
+// Updated:      20 May 2013  Mario Sitta  Layer is Assemgbly instead of Tube
+//
+
+
+  // Local variables
+  char volname[30];
+  Double_t xpos, ypos, zpos;
+  Double_t alpha;
+
+
+  // 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));
+
+
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
+  TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
+  layVol->SetUniqueID(fDetTypeID);
+  layVol->SetVisibility(kTRUE);
+  layVol->SetLineColor(1);
+  TGeoVolume *laddVol = CreateLadder();
+
+
+  // Now build up the layer
+  alpha = 360./fNLadders;
+  Double_t r = fLayRadius /* +module thick ?! */;
+  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* AliITSUv1Layer::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
+// Updated:      18 Dec 2013  Mario Sitta  Handle IB and OB
+//
+
+  char volname[30];
+  Double_t xLenO = 5.79/2;
+  Double_t xlenI, ylen, zlen;
+  Double_t xpos, ypos, zpos, zmod;
+  Double_t alpha;
+
+
+  // First create all needed shapes
+  alpha = (360./(2*fNLadders))*DegToRad();
+
+  // The ladder
+  xlenI = fLayRadius*Tan(alpha);
+  if (fIsTurbo) xlenI = 0.5*fLadderWidth;
+  ylen = 0.5*fLadderThick;
+  zlen = 0.5*fZLength;
+
+  Double_t yplus = 0.46;
+  TGeoXtru *ladder = new TGeoXtru(2); //z sections
+  Double_t xv[5] = {xlenI,xlenI,0,-xlenI,-xlenI};
+  Double_t yv[5] = {ylen+0.09,-0.15,-yplus-fSensorThick,-0.15,ylen+0.09};    
+  ladder->DefinePolygon(5,xv,yv);
+  ladder->DefineSection(0,-zlen,0,0,1.);
+  ladder->DefineSection(1,+zlen,0,0,1.);
+
+  // We have all shapes: now create the real volumes
+
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+//  TGeoVolume *laddVol = new TGeoVolume(volname, ladder, medAir);
+  TGeoVolume *laddVol = new TGeoVolumeAssembly(volname);
+
+  //  laddVol->SetVisibility(kFALSE);
+  laddVol->SetVisibility(kTRUE);
+  laddVol->SetLineColor(2);
+  TGeoVolume *modVol = 0;
+  TGeoVolume *mechLaddVol = 0;
+
+  // Now build up the ladder
+  if (fLayerNumber<3) {
+    modVol = CreateModuleInnerB(xlenI,ylen,zlen);
+    zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
+    for (Int_t j=0; j<fNModules; j++) {
+      xpos = 0.;
+      ypos = 0.021;  // Remove small overlap - M.S: 21may13
+      zpos = -ladder->GetDZ() + j*2*zmod + zmod;
+      laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
+    }
+  // put mechanical stave structure, only inner barrel up to now
+    mechLaddVol = CreateStaveStructInnerB(xlenI,zlen); 
+    if (mechLaddVol)
+      laddVol->AddNode(mechLaddVol, fNModules, new TGeoCombiTrans(0, -0.15-ylen, 0, new TGeoRotation("",0, 0, 180)));
+  }
+
+  else{
+    if (fStaveModel == AliITSUv1::kOBModel0) { // Create simplified stave struct as in v0
+      modVol = CreateModuleInnerB(xlenI,ylen,zlen);
+  printf("?????? %f %f %f\n",xlenI,ylen,zlen);
+      zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
+      for (Int_t j=0; j<fNModules; j++) {
+       xpos = 0.;
+       ypos = 0.021;  // Remove small overlap - M.S: 21may13
+       zpos = -ladder->GetDZ() + j*2*zmod + zmod;
+       laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
+      }
+    } else { // (if fStaveModel) Create new stave struct as in TDR
+      modVol = CreateStaveOuterB(xLenO);
+      laddVol->AddNode(modVol, 1, new TGeoTranslation(0, 2.5, 0));
+
+      mechLaddVol = CreateSpaceFrameOuterB(xLenO); 
+      if (mechLaddVol)
+       laddVol->AddNode(mechLaddVol, 1,
+                        new TGeoCombiTrans(0, 0, 0,
+                                           new TGeoRotation("", 180, 0, 0)));
+    } // if (fStaveModel)
+  }
+  
+
+  // Done, return the ladder
+  return laddVol;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveStructInnerB(const Double_t xlad,
+                                                   const Double_t zlad,
+                                                   const TGeoManager *mgr){
+//
+// Create the mechanical stave structure
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+//
+
+  TGeoVolume *mechLaddVol = 0;
+
+  switch (fStaveModel) {
+    case AliITSUv1::kIBModelDummy:
+      mechLaddVol = CreateStaveModelInnerBDummy(xlad,zlad,mgr);
+      break;
+    case AliITSUv1::kIBModel0:
+      mechLaddVol = CreateStaveModelInnerB0(xlad,zlad,mgr);
+      break;
+    case AliITSUv1::kIBModel1:
+      mechLaddVol = CreateStaveModelInnerB1(xlad,zlad,mgr);
+      break;
+    case AliITSUv1::kIBModel21:
+      mechLaddVol = CreateStaveModelInnerB21(xlad,zlad,mgr);
+      break;
+    case AliITSUv1::kIBModel22:
+      mechLaddVol = CreateStaveModelInnerB22(xlad,zlad,mgr);
+      break;
+    case AliITSUv1::kIBModel3:
+      mechLaddVol = CreateStaveModelInnerB3(xlad,zlad,mgr);
+      break;
+    default:
+      AliFatal(Form("Unknown stave model %d",fStaveModel));
+      break;
+  }
+
+  return mechLaddVol; 
+}
+
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerBDummy(const Double_t ,
+                                                       const Double_t ,
+                                                       const TGeoManager *) const {
+//
+// Create dummy stave
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+//
+
+  // Done, return the stave structur
+  return 0;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB0(const Double_t xlad,
+                                                   const Double_t zlad,
+                                                   const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for Model 0 of TDR
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+//
+  
+  // Materials defined in AliITSUv1
+  TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
+  TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
+
+  TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
+  TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
+
+  // Local parameters
+  Double_t kConeOutRadius = 0.15/2;
+  Double_t kConeInRadius = 0.1430/2;
+  Double_t kStaveLength = zlad*2;
+  Double_t kStaveWidth = xlad*2-kConeOutRadius*2;
+  Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
+  Double_t kStaveHeight = 0.3;
+  Double_t kHeight = kStaveHeight/2;
+  Double_t kAlpha = 90-67;//90-33.69;
+  Double_t kTheta = kAlpha*TMath::DegToRad();
+  Double_t kS1 = kWidth/TMath::Sin(kTheta);
+  Double_t kL1 = kWidth/TMath::Tan(kTheta);
+  Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
+  Double_t kThe2 = TMath::ATan(kHeight/kS1);
+  Double_t kBeta = kThe2*TMath::RadToDeg();
+  // Int_t  loop = kStaveLength/(kL1);
+  // Double_t s3 = kWidth/(2*TMath::Sin(kTheta));
+  // Double_t s4 = 3*kWidth/(2*TMath::Sin(kTheta));
+
+  AliDebug(1, Form("BuildLevel %d\n",fBuildLevel));
+
+  char volname[30];
+  snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+
+  Double_t z=0, y=-0.011+0.0150, x=0;
+
+   TGeoVolume *mechLaddVol = 0;
+
+  if (fBuildLevel < 5) {
+
+    // world (trapezoid)
+    TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
+    Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
+    Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
+    mechStruct->DefinePolygon(5,xv,yv);
+    mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
+    mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
+
+    mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
+    mechLaddVol->SetLineColor(12);
+    mechLaddVol->SetFillColor(12); 
+    mechLaddVol->SetVisibility(kTRUE);
+      
+    // detailed structure ++++++++++++++
+    //Pipe Kapton grey-35
+    TGeoTube *coolTube = new TGeoTube(kConeInRadius,kConeOutRadius,kStaveLength/2);
+    TGeoVolume *volCoolTube= new TGeoVolume("pipe", coolTube, medKapton);
+    volCoolTube->SetFillColor(35);
+    volCoolTube->SetLineColor(35);
+    mechLaddVol->AddNode(volCoolTube,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
+    mechLaddVol->AddNode(volCoolTube,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
+  }
+
+  if (fBuildLevel < 4) {
+    TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength/2);
+    TGeoVolume *volCoolTubeW= new TGeoVolume("pipeWater", coolTubeW, medWater);
+    volCoolTubeW->SetFillColor(4);
+    volCoolTubeW->SetLineColor(4);
+    mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
+    mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
+  }
+
+  //frequency of filament
+  //n = 4 means very dense(4 filaments per interval)
+  //n = 2 means dense(2 filaments per interval)
+  Int_t n =4;
+  Int_t loop = (Int_t)(kStaveLength/(4*kL1/n) + 2/n)-1;
+  if (fBuildLevel < 3) {
+    //Top CFRP Filament black-12 Carbon structure TGeoBBox (length,thickness,width)
+    TGeoBBox *t2=new TGeoBBox(kS2,0.007/2,0.15/2);//(kS2,0.002,0.02);
+    TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
+    volT2->SetLineColor(12);
+    volT2->SetFillColor(12); 
+
+    for(int i=1;i<loop;i++){  //i<60;i++){
+      mechLaddVol->AddNode(volT2,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
+                                                    new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
+                                                    new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
+                                                    new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),  
+                                                    new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
+    }
+
+
+    //Bottom CFRP Filament black-12 Carbon structure  TGeoBBox (thickness,width,length)
+    TGeoBBox *t1=new TGeoBBox(0.007/2,0.15/2,kS1);//(0.002,0.02,kS1);
+    TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
+    volT1->SetLineColor(12);
+    volT1->SetFillColor(12); 
+
+    for(int i=1;i<loop;i++){
+      mechLaddVol->AddNode(volT1,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(i*2*kL1),  
+                                                    new TGeoRotation("volT1",-90,kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2,  //z-14.25+(i*2*kL1), 
+                                                    new TGeoRotation("volT1",90,kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
+                                                    new TGeoRotation("volT1",-90,-kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
+                                                    new TGeoRotation("volT1",-90,+kAlpha,0)));
+    }
+  }
+   
+  if (fBuildLevel < 2) {
+    // Glue CFRP-Silicon layers TGeoBBox(thickness,width,kS1);
+    TGeoBBox *tG=new TGeoBBox(0.0075/2,0.18/2,kS1);
+    TGeoVolume *volTG=new TGeoVolume("Glue1", tG, medGlue);
+    volTG->SetLineColor(5);
+    volTG->SetFillColor(5); 
+
+    for(int i=1;i<loop;i++){ //i<60;i++){
+      mechLaddVol->AddNode(volTG,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
+                                                    new TGeoRotation("volTG",-90,kAlpha,0)));
+      mechLaddVol->AddNode(volTG,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
+                                                    new TGeoRotation("volTG",90,kAlpha,0)));
+      mechLaddVol->AddNode(volTG,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*i*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
+                                                    new TGeoRotation("volTG",-90,-kAlpha,0)));
+      mechLaddVol->AddNode(volTG,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
+                                                    new TGeoRotation("volTG",-90,+kAlpha,0)));
+    }
+
+    TGeoBBox *glue = new TGeoBBox(xlad, 0.005/2, zlad);
+    TGeoVolume *volGlue=new TGeoVolume("Glue2", glue, medGlue);
+    volGlue->SetLineColor(5);
+    volGlue->SetFillColor(5); 
+    //mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
+    mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
+  }
+
+  if (fBuildLevel < 1) {
+    //Flex cable brown-28 TGeoBBox(width,thickness,length); 
+    TGeoBBox *kapCable = new TGeoBBox(xlad, 0.01/2, zlad);
+    TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
+    volCable->SetLineColor(28);
+    volCable->SetFillColor(28); 
+    mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
+ }
+
+  // Done, return the stave structur
+  return mechLaddVol;
+}
+
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB1(const Double_t xlad,
+                                                   const Double_t zlad,
+                                                   const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for Model 1 of TDR
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+//
+  
+  // Materials defined in AliITSUv1
+  TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
+  TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
+
+  TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
+  TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
+
+  // Local parameters
+  Double_t kConeOutRadius = 0.15/2;
+  //    Double_t kConeInRadius = 0.1430/2;
+  Double_t kStaveLength = zlad*2;
+  //    Double_t kStaveWidth = xlad*2-kConeOutRadius*2;
+  Double_t kStaveWidth = xlad*2;
+  Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
+  Double_t kStaveHeight = 0.3;
+  Double_t kHeight = kStaveHeight/2;
+  Double_t kAlpha = 90-33.;//90-30;
+  Double_t kTheta = kAlpha*TMath::DegToRad();
+  Double_t kS1 = kWidth/TMath::Sin(kTheta);
+  Double_t kL1 = kWidth/TMath::Tan(kTheta);
+  Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
+  Double_t kThe2 = TMath::ATan(kHeight/kS1);
+  Double_t kBeta = kThe2*TMath::RadToDeg();
+  Int_t  loop = (Int_t)((kStaveLength/(2*kL1))/2);
+  
+
+  TGeoVolume *mechLaddVol = 0;
+
+  char volname[30];
+  snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+    
+
+  // detailed structure ++++++++++++++
+  Double_t z=0, y=-0.011+0.0150, x=0;
+
+  // Polimide micro channels numbers
+  Double_t yMC = y-kHeight+0.01;
+  Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
+  Double_t xladMC = (nb*0.1-0.08)/2;
+
+
+  if (fBuildLevel < 5) {
+    // world (trapezoid)
+    TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
+    Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
+    Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
+    mechStruct->DefinePolygon(5,xv,yv);
+    mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
+    mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
+
+    mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
+    mechLaddVol->SetLineColor(12);
+    mechLaddVol->SetFillColor(12); 
+    mechLaddVol->SetVisibility(kTRUE);
+      
+    // Polimide micro channels numbers
+    TGeoBBox *tM0=new TGeoBBox(xladMC, 0.005/2, zlad);
+    TGeoVolume *volTM0=new TGeoVolume("MicroChanCover", tM0, medKapton);
+    volTM0->SetLineColor(35);
+    volTM0->SetFillColor(35); 
+    mechLaddVol->AddNode(volTM0, 0, new TGeoCombiTrans(x,-0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
+    mechLaddVol->AddNode(volTM0, 1, new TGeoCombiTrans(x,+0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
+      
+    TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zlad);
+    TGeoVolume *volTM0b=new TGeoVolume("MicroChanWalls", tM0b, medKapton);
+    volTM0b->SetLineColor(35);
+    volTM0b->SetFillColor(35); 
+    for (Int_t ib=0;ib<nb;ib++) {
+      mechLaddVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
+    }
+      
+  }
+    
+  if (fBuildLevel < 4) {
+    // Water in Polimide micro channels
+    TGeoBBox *water=new TGeoBBox(0.08/2, 0.02/2, zlad+0.1);
+    TGeoVolume *volWater=new TGeoVolume("Water", water, medWater);
+    volWater->SetLineColor(4);
+    volWater->SetFillColor(4); 
+    for (Int_t ib=0;ib<(nb-1);ib++) {
+      mechLaddVol->AddNode(volWater, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.06,yMC, z, new TGeoRotation("",0, 0, 0)));
+    }
+  }
+    
+  if (fBuildLevel < 3) {
+    //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
+    Double_t filWidth = 0.04;
+    Double_t filHeight= 0.02;
+    TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,kS1);
+    TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
+    volT1->SetLineColor(12);
+    volT1->SetFillColor(12); 
+    for(int i=0;i<loop;i++){//i<30;i++){
+      mechLaddVol->AddNode(volT1,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
+                                                    new TGeoRotation("volT1",90,kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,-kAlpha,0)));
+      mechLaddVol->AddNode(volT1,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,+kAlpha,0)));
+    }
+
+      // Top filament CFRP black-12 Carbon structure TGeoBBox (length,thickness,width)
+    TGeoBBox *t2=new TGeoBBox(kS2,filHeight/2,filWidth/2);
+    TGeoVolume *volT2=new TGeoVolume("CFRPTop", t2, medM60J3K);
+    volT2->SetLineColor(12);
+    volT2->SetFillColor(12); 
+    for(int i=0;i<loop;i++){ //i<30;i++){
+      mechLaddVol->AddNode(volT2,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
+                                                    new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
+                                                    new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2,
+                                                    new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
+    }
+  }
+
+  if (fBuildLevel < 2) {
+    // Glue between filament and polimide micro channel
+    TGeoBBox *t3=new TGeoBBox(0.01/2,0.04,kS1);
+    TGeoVolume *volT3=new TGeoVolume("FilamentGlue", t3, medGlue);
+    volT3->SetLineColor(5);
+    volT3->SetFillColor(5); 
+    for(int i=0;i<loop;i++){//i<30;i++){
+      mechLaddVol->AddNode(volT3,4*i+0,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,kAlpha,0)));
+      mechLaddVol->AddNode(volT3,4*i+1,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
+                                                    new TGeoRotation("volT1",90,kAlpha,0)));
+      mechLaddVol->AddNode(volT3,4*i+2,
+                                 new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,-kAlpha,0)));
+      mechLaddVol->AddNode(volT3,4*i+3,
+                                 new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
+                                                    new TGeoRotation("volT1",-90,+kAlpha,0)));
+    }
+      
+    // Glue microchannel and sensor
+    TGeoBBox *glueM = new TGeoBBox(xlad, 0.01/2, zlad);
+    TGeoVolume *volGlueM=new TGeoVolume("MicroChanGlue", glueM, medGlue);
+    volGlueM->SetLineColor(5);
+    volGlueM->SetFillColor(5); 
+    mechLaddVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
+
+    // Glue sensor and kapton
+    TGeoBBox *glue = new TGeoBBox(xlad, 0.005/2, zlad);
+    TGeoVolume *volGlue=new TGeoVolume("SensorGlue", glue, medGlue);
+    volGlue->SetLineColor(5);
+    volGlue->SetFillColor(5); 
+    mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
+  }
+
+  if (fBuildLevel < 1) {
+    TGeoBBox *kapCable = new TGeoBBox(xlad, 0.01/2, zlad);
+    TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
+    volCable->SetLineColor(28);
+    volCable->SetFillColor(28); 
+    mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
+  }
+    
+  // Done, return the stave structur
+  return mechLaddVol;
+
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB21(const Double_t xlad,
+                                                    const Double_t zlad,
+                                                    const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for Model 2.1 of TDR
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+//
+  
+  // Materials defined in AliITSUv1
+  TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
+  TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
+
+  TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
+  TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
+  TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
+  TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
+  TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
+
+  // Local parameters
+  Double_t kConeOutRadius =0.151384/2;
+  Double_t kConeInRadius = 0.145034/2;
+  Double_t kStaveLength = zlad;
+  Double_t kStaveWidth = xlad*2;
+  Double_t kWidth = (kStaveWidth+0.005)/4;
+  Double_t kStaveHeigth = 0.33;//0.33;
+  Double_t kHeight = (kStaveHeigth+0.025)/2;
+  Double_t kAlpha = 57; //56.31;
+  Double_t kTheta = kAlpha*TMath::DegToRad();
+  Double_t kS1 = (kStaveWidth/4)/TMath::Sin(kTheta);
+  Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
+  Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
+  Double_t kThe2 = TMath::ATan(kHeight/kS1);
+  Double_t kBeta = kThe2*TMath::RadToDeg();
+  // Double_t lay1 = 0.003157;
+  Double_t kLay1 = 0.003;//Amec carbon
+  // Double_t lay2 = 0.0043215;//C Fleece carbon
+  Double_t kLay2 = 0.002;//C Fleece carbon
+  Double_t kLay3 = 0.007;//K13D2U carbon
+  Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
+
+
+  char volname[30];
+  snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+
+  Double_t z=0, y=-(kConeOutRadius+0.03)+0.0385, x=0;
+
+  TGeoVolume *mechLaddVol = 0;
+
+  if (fBuildLevel < 5) {
+    // world (trapezoid)
+    TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
+    Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
+    Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeigth,0,-kConeOutRadius*2-0.07};    
+    mechStruct->DefinePolygon(5,xv,yv);
+    mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
+    mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
+
+    mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
+    mechLaddVol->SetLineColor(12);
+    mechLaddVol->SetFillColor(12); 
+    mechLaddVol->SetVisibility(kTRUE);  
+      
+    //Pipe Kapton grey-35 
+    TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius,kConeInRadius,kConeOutRadius);
+    TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
+    volCone1->SetFillColor(35);
+    volCone1->SetLineColor(35);
+    mechLaddVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
+    mechLaddVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
+  }
+
+  if (fBuildLevel < 4) {
+    
+    TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength);
+    TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
+    volCoolTubeW->SetFillColor(4);
+    volCoolTubeW->SetLineColor(4);
+    mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
+    mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
+  }
+
+  if (fBuildLevel < 3) {
+    //top fillament
+    // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
+    TGeoBBox *t2=new TGeoBBox(kS2,0.02/2,0.04/2); //TGeoBBox *t2=new TGeoBBox(kS2,0.01,0.02);
+    TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
+    volT2->SetLineColor(12);
+    volT2->SetFillColor(12); 
+    for(int i=0;i<loop;i++){// i<28;i++){
+      mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,i*4+2,new TGeoCombiTrans(x-kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
+      mechLaddVol->AddNode(volT2,i*4+3,new TGeoCombiTrans(x+kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
+      mechLaddVol->AddNode(volT2,i*4+4,new TGeoCombiTrans(x-kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
+//    mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight-(0.12/2)+0.072,z+kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
+
+ }
+    //wall side structure out
+    TGeoBBox *box4 = new TGeoBBox(0.03/2,0.12/2,kStaveLength-0.50);
+    TGeoVolume *plate4 = new TGeoVolume("WallOut",box4,medM60J3K);
+    plate4->SetFillColor(35);
+    plate4->SetLineColor(35);
+    mechLaddVol->AddNode(plate4,1,new TGeoCombiTrans(x+(2*kStaveWidth/4)-(0.03/2),y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate4",0,0,0)));
+    mechLaddVol->AddNode(plate4,2,new TGeoCombiTrans(x-(2*kStaveWidth/4)+(0.03/2),y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate4",0,0,0)));
+    //wall side in
+    TGeoBBox *box5 = new TGeoBBox(0.015/2,0.12/2,kStaveLength-0.50);
+    TGeoVolume *plate5 = new TGeoVolume("WallIn",box5,medM60J3K);
+    plate5->SetFillColor(12);
+    plate5->SetLineColor(12);
+    mechLaddVol->AddNode(plate5,1,new TGeoCombiTrans(x+(2*kStaveWidth/4)-0.03-0.015/2,y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate5",0,0,0)));
+    mechLaddVol->AddNode(plate5,2,new TGeoCombiTrans(x-(2*kStaveWidth/4)+0.03+0.015/2,y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate5",0,0,0)));
+
+     //Amec Thermasol red-2 cover tube FGS300
+    TGeoConeSeg *cons1 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius,kConeOutRadius+kLay1,kConeOutRadius,kConeOutRadius+kLay1,0,180);
+    TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
+    cone11->SetFillColor(2);
+    cone11->SetLineColor(2);
+    mechLaddVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
+    mechLaddVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
+
+    TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,kLay1/2,kStaveLength-0.50);
+    TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
+    plate2->SetFillColor(2);
+    plate2->SetLineColor(2);
+    mechLaddVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate2",0,0,0)));
+
+    TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay1/2,kStaveLength-0.50);
+    TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
+    plate21->SetFillColor(2);
+    plate21->SetLineColor(2);
+    mechLaddVol->AddNode(plate21,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(0.75-0.25-kConeOutRadius)/2-(kLay1/2),y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate21",0,0,0)));
+    mechLaddVol->AddNode(plate21,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-(0.75-0.25-kConeOutRadius)/2+(kLay1/2),y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate21",0,0,0)));
+
+    TGeoBBox *box22 = new TGeoBBox((kLay1/2),kConeOutRadius/2,kStaveLength-0.50);
+    TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
+    plate22->SetFillColor(2);
+    plate22->SetLineColor(2);
+    mechLaddVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+    mechLaddVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+    mechLaddVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+    mechLaddVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+
+    //C Fleece
+    TGeoConeSeg *cons2 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,0,180); 
+    TGeoVolume *cone12 = new TGeoVolume("CFleecePipeCover",cons2,medCarbonFleece);
+    cone12->SetFillColor(28);
+    cone12->SetLineColor(28);
+    mechLaddVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
+    mechLaddVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
+
+    TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+kLay1)))/2,kLay2/2,kStaveLength-0.50);
+    TGeoVolume *plate3 = new TGeoVolume("CFleeceMiddle",box3,medCarbonFleece);
+    plate3->SetFillColor(28);
+    plate3->SetLineColor(28);
+    mechLaddVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate3",0,0,0)));
+
+    TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay2/2,kStaveLength-0.50);
+    TGeoVolume *plate31 = new TGeoVolume("CFleeceLeftRight",box31,medCarbonFleece);
+    plate31->SetFillColor(28);
+    plate31->SetLineColor(28);
+    mechLaddVol->AddNode(plate31,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+kLay1+(0.75-0.25-kConeOutRadius-kLay1)/2,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate31",0,0,0)));
+    mechLaddVol->AddNode(plate31,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-kLay1-(0.75-0.25-kConeOutRadius-kLay1)/2,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate31",0,0,0)));
+
+    TGeoBBox *box32 = new TGeoBBox((kLay2/2),(kConeOutRadius-kLay1)/2,kStaveLength-0.50);
+    TGeoVolume *plate32 = new TGeoVolume("CFleeceVertical",box32,medCarbonFleece);
+    plate32->SetFillColor(28);
+    plate32->SetLineColor(28);
+    mechLaddVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+    mechLaddVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+    mechLaddVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+    mechLaddVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+
+
+    //K13D2U carbon plate
+    TGeoBBox *box1 = new TGeoBBox(2*kWidth,kLay3/2,kStaveLength-0.50);
+    TGeoVolume *plate1 = new TGeoVolume("CarbonPlate",box1,medK13D2U2k);
+    plate1->SetFillColor(5);
+    plate1->SetLineColor(5);
+    mechLaddVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(kLay3/2)),z,new TGeoRotation("plate1",0,0,0)));
+
+    //C Fleece bottom plate 
+    TGeoBBox *box6 = new TGeoBBox(2*kWidth,kLay2/2,kStaveLength-0.50);
+    TGeoVolume *plate6 = new TGeoVolume("CFleeceBottom",box6,medCarbonFleece);
+    plate6->SetFillColor(2);
+    plate6->SetLineColor(2);
+    mechLaddVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)),z,new TGeoRotation("plate1",0,0,0)));
+      
+      
+  }
+
+  if (fBuildLevel < 2) {
+    //Glue layers and kapton
+    TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, 0.005/2, zlad);
+    TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
+    volGlue->SetLineColor(5);
+    volGlue->SetFillColor(5); 
+    mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
+    mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+0.01+fSensorThick+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
+  }
+
+  if (fBuildLevel < 1) {
+    TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, 0.01/2, zlad);
+    TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
+    volCable->SetLineColor(28);
+    volCable->SetFillColor(28); 
+    mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+kLay3+(kLay2/2)+0.01+fSensorThick+0.01+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
+  }
+    
+
+  // Done, return the stave structure
+  return mechLaddVol;
+  
+}
+// new model22
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB22(const Double_t xlad,
+                                                    const Double_t zlad,
+                                                    const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for Model 2.2 of TDR
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      22 Mar 2013  Chinorat Kobdaj
+// Updated:      26 Apr 2013  Mario Sitta
+// Updated:      30 Apr 2013  Wanchaloem Poonsawat 
+//
+  
+  // Materials defined in AliITSUv1
+  TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
+  TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
+
+  TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
+  TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
+  TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
+  TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
+  TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
+
+  // Local parameters
+  Double_t kConeOutRadius =0.107/2;//0.107/2;
+  Double_t kConeInRadius = 0.1015/2;//0.10105/2
+  Double_t kStaveLength = zlad;
+  Double_t kStaveWidth = xlad*2;
+  Double_t kWidth = (kStaveWidth)/4;
+  Double_t kStaveHeight = 0.283;//0.33;
+  Double_t kHeight = (kStaveHeight)/2;
+  Double_t kAlpha = 57;//56.31;
+  Double_t kTheta = kAlpha*TMath::DegToRad();
+  Double_t kS1 = ((kStaveWidth)/4)/TMath::Sin(kTheta);
+  Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
+  Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(kThe2);
+  Double_t kThe2 = TMath::ATan(kHeight/(0.375-0.036));
+  Double_t kBeta = kThe2*TMath::RadToDeg();
+  Double_t klay1 = 0.003;//Amec carbon
+  Double_t klay2 = 0.002;//C Fleece carbon
+  Double_t klay3 = 0.007;//CFplate K13D2U carbon
+  Double_t klay4 = 0.007;//GluekStaveLength/2
+  Double_t klay5 = 0.01;//Flex cable
+  Double_t kTopVertexMaxWidth = 0.072;
+  Double_t kTopVertexHeight = 0.04;
+  Double_t kSideVertexMWidth = 0.052;
+  Double_t kSideVertexHeight = 0.11; 
+
+  Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
+
+  char volname[30];
+  snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+
+  Double_t z=0, y=-(2*kConeOutRadius)+klay1+klay2+fSensorThick/2-0.0004, x=0;
+
+  TGeoVolume *mechLaddVol = 0;
+
+  if (fBuildLevel < 5) {
+    // world (trapezoid)
+    TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
+    Double_t xv[6] = {kStaveWidth/2,kStaveWidth/2,0.012,-0.012,-kStaveWidth/2,-kStaveWidth/2}; 
+    /* Double_t yv[6] = {-2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5),
+                        0-0.02,kStaveHeight+0.01,kStaveHeight+0.01,0-0.02,
+                       -2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5)};  // (kConeOutRadius*2)-0.0635 */
+    Double_t yv[6] = {-(kConeOutRadius*2)-0.06395,0-0.02,kStaveHeight+0.01,kStaveHeight+0.01,0-0.02,-(kConeOutRadius*2)-0.06395};  // (kConeOutRadius*2)-0.064
+    mechStruct->DefinePolygon(6,xv,yv);
+    mechStruct->DefineSection(0,-kStaveLength,0,0,1.);
+    mechStruct->DefineSection(1,kStaveLength,0,0,1.);
+
+    mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
+    mechLaddVol->SetLineColor(12);
+    mechLaddVol->SetFillColor(12); 
+    mechLaddVol->SetVisibility(kTRUE);  
+      
+    //Polyimide Pipe Kapton grey-35 
+    TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius-0.0001,kConeInRadius,kConeOutRadius-0.0001);
+    TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
+    volCone1->SetFillColor(35);
+    volCone1->SetLineColor(35);
+    mechLaddVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
+    mechLaddVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
+    }
+
+  if (fBuildLevel < 4) {
+    TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius-0.0001,kStaveLength);
+    TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
+    volCoolTubeW->SetFillColor(4);
+    volCoolTubeW->SetLineColor(4);
+    mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
+    mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
+  }
+
+  if (fBuildLevel < 3) {
+    //top fillament
+    // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
+    TGeoBBox *t2=new TGeoBBox(kS2-0.028,0.02/2,0.02/2); //0.04/2//TGeoBBox *t2=new TGeoBBox(kS2,0.01,0.02);//kS2-0.03 old Config.C
+    TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
+    volT2->SetLineColor(12);
+    volT2->SetFillColor(12); 
+    for(int i=0;i<loop;i++){// i<28;i++){
+      // 1) Front Left Top Filament
+       mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight+0.01,z-kStaveLength+0.1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
+      // 2) Front Right Top Filament
+      mechLaddVol->AddNode(volT2,i*4+2,new TGeoCombiTrans(x-kWidth-0.0036,y+kHeight+0.01,z-kStaveLength+0.1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
+      // 3) Back Left  Top Filament
+      mechLaddVol->AddNode(volT2,i*4+3,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight+0.01,z-kStaveLength+0.1+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
+      // 4) Back Right Top Filament
+      mechLaddVol->AddNode(volT2,i*4+4,new TGeoCombiTrans(x-kWidth-0.0036,y+kHeight+0.01,z-kStaveLength+0.1+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
+   }
+     //Vertex  structure 
+
+      //top ver trd1
+      TGeoTrd1 *trd1 = new TGeoTrd1(0,kTopVertexMaxWidth/2,kStaveLength,kTopVertexHeight/2);
+      TGeoVolume *ibdv = new TGeoVolume("TopVertex",trd1,medM60J3K);
+      ibdv->SetFillColor(12);
+      ibdv->SetLineColor(12);
+      mechLaddVol->AddNode(ibdv,1,new TGeoCombiTrans(x,y+kStaveHeight+0.03,z,new TGeoRotation("ibdv",0.,-90,0)));//y+kStaveHeight+0.056
+
+      //left trd2
+      TGeoTrd1 *trd2 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
+      TGeoVolume *ibdv2 = new TGeoVolume("LeftVertex",trd2,medM60J3K);
+      ibdv2->SetFillColor(12);
+      ibdv2->SetLineColor(12);
+      mechLaddVol->AddNode(ibdv2,1,new TGeoCombiTrans(x+kStaveWidth/2-0.06,y-0.0355,z,new TGeoRotation("ibdv2",-103.3,90,0))); //x-kStaveWidth/2-0.09 old Config.C y-0.0355,
+
+      //right trd3
+      TGeoTrd1 *trd3 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
+      TGeoVolume *ibdv3 = new TGeoVolume("RightVertex",trd3,medM60J3K);
+      ibdv3->SetFillColor(12);
+      ibdv3->SetLineColor(12);
+      mechLaddVol->AddNode(ibdv3,1,new TGeoCombiTrans(x-kStaveWidth/2+0.06,y-0.0355,z,new TGeoRotation("ibdv3",103.3,90,0))); //x-kStaveWidth/2+0.09 old Config.C
+      
+     //Carbon Fleece
+      TGeoConeSeg *cons2 = new TGeoConeSeg(zlad,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,0,180); 
+      TGeoVolume *cone12 = new TGeoVolume("CarbonFleecePipeCover",cons2,medCarbonFleece);
+      cone12->SetFillColor(28);
+      cone12->SetLineColor(28);
+      mechLaddVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone12",0,0,0)));
+      mechLaddVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone12",0,0,0)));
+
+      TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+klay1)))/2,klay2/2,zlad);//kStaveLength-0.50);
+      TGeoVolume *plate3 = new TGeoVolume("CarbonFleeceMiddle",box3,medCarbonFleece);
+      plate3->SetFillColor(28);
+      plate3->SetLineColor(28);
+      mechLaddVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate3",0,0,0)));
+
+      TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,klay2/2,zlad);
+      TGeoVolume *plate31 = new TGeoVolume("CarbonFleeceLeftRight",box31,medCarbonFleece);
+      plate31->SetFillColor(28);
+      plate31->SetLineColor(28);
+      mechLaddVol->AddNode(plate31,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+klay1+(0.75-0.25-kConeOutRadius-klay1)/2,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate31",0,0,0)));
+      mechLaddVol->AddNode(plate31,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-klay1-(0.75-0.25-kConeOutRadius-klay1)/2,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate31",0,0,0)));
+
+      TGeoBBox *box32 = new TGeoBBox((klay2/2),(kConeOutRadius-klay1)/2,zlad);
+      TGeoVolume *plate32 = new TGeoVolume("CarbonFleeceVertical",box32,medCarbonFleece);
+      plate32->SetFillColor(28);
+      plate32->SetLineColor(28);
+      mechLaddVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+      mechLaddVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+      mechLaddVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+      mechLaddVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
+
+     //Amec Thermasol red-2 cover tube FGS300 or Carbon Paper
+      TGeoConeSeg *cons1 = new TGeoConeSeg(zlad,kConeOutRadius,kConeOutRadius+klay1-0.0001,kConeOutRadius,kConeOutRadius+klay1-0.0001,0,180);//kConeOutRadius+klay1-0.0001
+      TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
+      cone11->SetFillColor(2);
+      cone11->SetLineColor(2);
+      mechLaddVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone11",0,0,0)));
+      mechLaddVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone11",0,0,0)));
+
+      TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,(klay1/2),zlad);//kStaveLength-0.50);
+      TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
+      plate2->SetFillColor(2);
+      plate2->SetLineColor(2);
+      mechLaddVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate2",0,0,0)));
+
+      TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,(klay1/2),zlad);
+      TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
+      plate21->SetFillColor(2);
+      plate21->SetLineColor(2);
+      mechLaddVol->AddNode(plate21,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(0.75-0.25-kConeOutRadius)/2-(klay1/2)+0.0025,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate21",0,0,0)));
+      mechLaddVol->AddNode(plate21,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-(0.75-0.25-kConeOutRadius)/2+(klay1/2)-0.0025,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate21",0,0,0)));
+
+      TGeoBBox *box22 = new TGeoBBox((klay1/2),kConeOutRadius/2,zlad);
+      TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
+      plate22->SetFillColor(2);
+      plate22->SetLineColor(2);
+      mechLaddVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+      mechLaddVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+      mechLaddVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+      mechLaddVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
+
+     //K13D2U CF plate
+      TGeoBBox *box1 = new TGeoBBox(2*kWidth,(klay3)/2,zlad);
+      TGeoVolume *plate1 = new TGeoVolume("CFPlate",box1,medK13D2U2k);
+      plate1->SetFillColor(5);
+      plate1->SetLineColor(5);
+      mechLaddVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(klay3/2)),z,new TGeoRotation("plate1",0,0,0)));
+
+     //C Fleece bottom plate 
+      TGeoBBox *box6 = new TGeoBBox(2*kWidth,(klay2)/2,zlad);
+      TGeoVolume *plate6 = new TGeoVolume("CarbonFleeceBottom",box6,medCarbonFleece);
+      plate6->SetFillColor(2);
+      plate6->SetLineColor(2);
+      mechLaddVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+(klay2/2)),z,new TGeoRotation("plate6",0,0,0)));
+
+    }
+   if (fBuildLevel < 2) {
+      //Glue klayers and kapton
+     TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, (klay4)/2, zlad);
+      TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
+      volGlue->SetLineColor(5);
+      volGlue->SetFillColor(5); 
+      // mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4/2)), z, new TGeoRotation("",0, 0, 0)));
+      mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4)/2)+0.00005, z, new TGeoRotation("",0, 0, 0)));
+    }
+
+     if (fBuildLevel < 1) {
+     //Flex Cable or Bus
+      TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, klay5/2, zlad);//klay5/2
+      TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
+      volCable->SetLineColor(28);
+      volCable->SetFillColor(28); 
+      //      mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.0002, z, new TGeoRotation("",0, 0, 0)));
+      mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.01185, z, new TGeoRotation("",0, 0, 0)));
+      }
+    // Done, return the stave structe
+    return mechLaddVol;
+}
+
+// model3
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB3(const Double_t xlad,
+                                                   const Double_t zlad,
+                                                   const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for Model 3 of TDR
+//
+// Input:
+//         xlad : X length
+//         zlad : Z length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      28 May 2013  Chinorat Kobdaj
+// Updated:                   Mario Sitta
+// Updated:                   Wanchaloem Poonsawat 
+//
+  
+  // Materials defined in AliITSUv1
+  TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
+  TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
+
+  TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
+  TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
+  //TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
+  //TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
+  //TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
+
+  // Local parameters
+    Double_t kConeOutRadius = 0.15/2;
+    Double_t kStaveLength = zlad*2;
+    Double_t kStaveWidth = xlad*2;
+    Double_t w = kStaveWidth/4;//1/2 of W
+    Double_t staveHeight = 0.3;
+    Double_t h = staveHeight/2;
+    Double_t alpha = 90-33.;//90-30;
+    Double_t the1 = alpha*TMath::DegToRad();
+    Double_t s1 = w/TMath::Sin(the1);
+    Double_t l = w/TMath::Tan(the1);
+    Double_t s2 = TMath::Sqrt(h*h + s1*s1);//TMath::Sin(the2);
+    Double_t the2 = TMath::ATan(h/s1);
+    Double_t beta = the2*TMath::RadToDeg();
+    Double_t klay4 = 0.007; //Glue
+    Double_t klay5 = 0.01; //Flexcable
+    Int_t  loop = (Int_t)((kStaveLength/(2*l))/2);
+    Double_t hh = 0.01;
+       Double_t ang1 = 0*TMath::DegToRad();
+       Double_t ang2 = 0*TMath::DegToRad();
+       Double_t ang3 = 0*TMath::DegToRad();
+       Int_t modules = 4;
+       Double_t headWidth=0.25;
+       Double_t smcLength=kStaveLength/modules-2*headWidth;//6.25;
+       Double_t smcWidth=kStaveWidth;
+       Double_t smcSide1Thick=0.03;
+       Double_t vaporThick=0.032;
+       Double_t liquidThick=0.028;
+       Double_t smcSide2Thick=0.01;
+       Double_t smcSide3Thick=0.0055;
+       Double_t smcSide4Thick=0.0095;
+       Double_t smcSide5Thick=0.0075;
+       Double_t smcSpace=0.01;
+
+
+    char volname[30];
+    snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
+    
+    // detailed structure ++++++++++++++
+    Double_t z=0, y=0-0.007, x=0;
+
+    // Polimide micro channels numbers
+    Double_t yMC = y-h+0.01;
+    Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
+    Double_t xladMC = (nb*0.1-0.08)/2;
+
+
+    TGeoVolume *mechLaddVol = 0;
+    if (fBuildLevel < 5) {
+      // world (trapezoid)
+      TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
+      Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
+      Double_t yv[5] = {-kConeOutRadius*2-0.07,0,staveHeight,0,-kConeOutRadius*2-0.07};    
+      mechStruct->DefinePolygon(5,xv,yv);
+      mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
+      mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
+      mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
+      mechLaddVol->SetLineColor(12);
+      mechLaddVol->SetFillColor(12); 
+      mechLaddVol->SetVisibility(kTRUE);
+
+       // Silicon micro channels numbers
+      
+      TGeoBBox *tM0a=new TGeoBBox(smcWidth/2, 0.003/2, headWidth/2);
+      TGeoVolume *volTM0a=new TGeoVolume("microChanTop1", tM0a, medKapton);
+      volTM0a->SetLineColor(35);
+      volTM0a->SetFillColor(35); 
+
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0a, 0, new TGeoCombiTrans(x,yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));
+      mechLaddVol->AddNode(volTM0a, 1, new TGeoCombiTrans(x,yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));
+      }
+      TGeoBBox *tM0c=new TGeoBBox(0.3/2, 0.003/2,smcLength/2);
+      TGeoVolume *volTM0c=new TGeoVolume("microChanTop2", tM0c, medKapton);
+      volTM0c->SetLineColor(35);
+      volTM0c->SetFillColor(35); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0c, 0, new TGeoCombiTrans(x+(smcWidth/2)-(0.3/2),yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));
+      mechLaddVol->AddNode(volTM0c, 1, new TGeoCombiTrans(x-(smcWidth/2)+(0.3/2),yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0c1=new TGeoBBox(0.2225/2, 0.003/2,smcLength/2);
+      TGeoVolume *volTM0c1=new TGeoVolume("microChanBot1", tM0c1, medKapton);
+      volTM0c1->SetLineColor(6);
+      volTM0c1->SetFillColor(6); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0c1, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-(0.2225/2),yMC+0.03-hh-(0.003), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      mechLaddVol->AddNode(volTM0c1, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick)+(0.2225/2),yMC+0.03-hh-(0.003), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0c2=new TGeoBBox(0.072/2, 0.003/2,smcLength/2);
+      TGeoVolume *volTM0c2=new TGeoVolume("microChanBot2", tM0c2, medKapton);
+      volTM0c2->SetLineColor(35);
+      volTM0c2->SetFillColor(35); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0c2, 0, new TGeoCombiTrans(x+smcWidth/2-(0.072/2),yMC+0.03-(0.035+0.0015)-(0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0c2r=new TGeoBBox(0.068/2, 0.003/2,smcLength/2);
+      TGeoVolume *volTM0c2r=new TGeoVolume("microChanBot3", tM0c2r, medKapton);
+      volTM0c2r->SetLineColor(35);
+      volTM0c2r->SetFillColor(35); 
+      for(Int_t  mo=1; mo<=modules; mo++) {      
+      mechLaddVol->AddNode(volTM0c2r, 0, new TGeoCombiTrans(x-smcWidth/2+(0.068/2),yMC+0.03-(0.035+0.0015)-(0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0d=new TGeoBBox(smcSide1Thick/2, 0.035/2,smcLength/2);
+      TGeoVolume *volTM0d=new TGeoVolume("microChanSide1", tM0d, medKapton);
+      volTM0d->SetLineColor(12);
+      volTM0d->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0d, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      mechLaddVol->AddNode(volTM0d, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+
+      TGeoBBox *tM0d1=new TGeoBBox(smcSide2Thick/2, 0.035/2,smcLength/2);
+      TGeoVolume *volTM0d1=new TGeoVolume("microChanSide2", tM0d1, medKapton);
+      volTM0d1->SetLineColor(12);
+      volTM0d1->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0d1, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick/2),yMC+0.03-(0.003+0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      mechLaddVol->AddNode(volTM0d1, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick/2),yMC+0.03-(0.003+0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0d2=new TGeoBBox(smcSide3Thick/2, (hh+0.003)/2, smcLength/2);
+      TGeoVolume *volTM0d2=new TGeoVolume("microChanSide3", tM0d2, medKapton);
+      volTM0d2->SetLineColor(12);
+      volTM0d2->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0d2, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick/2),yMC+0.03-(0.003+hh+0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0d2r=new TGeoBBox(smcSide4Thick/2, (hh+0.003)/2, smcLength/2);
+      TGeoVolume *volTM0d2r=new TGeoVolume("microChanSide4", tM0d2r, medKapton);
+      volTM0d2r->SetLineColor(12);
+      volTM0d2r->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0d2r, 0, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick/2),yMC+0.03-(0.003+hh+0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0e=new TGeoBBox(smcSide5Thick/2, hh/2,smcLength/2);
+      TGeoVolume *volTM0e=new TGeoVolume("microChanSide5", tM0e, medKapton);    
+      volTM0e->SetLineColor(12);
+      volTM0e->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      for (Int_t ie=0;ie<11;ie++) {
+       mechLaddVol->AddNode(volTM0e, 0, new TGeoCombiTrans(x-(ie*(smcSpace+smcSide5Thick))+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-smcSpace-(smcSide5Thick/2),yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+       mechLaddVol->AddNode(volTM0e, 1, new TGeoCombiTrans(x+(ie*(smcSpace+smcSide5Thick))-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick)+smcSpace+(smcSide5Thick/2),yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+         }
+      }
+      
+      TGeoBBox *tM0f=new TGeoBBox(0.02/2, hh/2, smcLength/2);
+      TGeoVolume *volTM0f=new TGeoVolume("microChanTop3", tM0f, medKapton);
+      //Double_t smcChannels=12;
+      Double_t smcCloseWallvapor=smcWidth/2-smcSide1Thick-vaporThick-smcSide2Thick-smcSide3Thick-12*smcSpace-11*smcSide5Thick;
+      Double_t smcCloseWallliquid=smcWidth/2-smcSide1Thick-liquidThick-smcSide2Thick-smcSide4Thick-12*smcSpace-11*smcSide5Thick;
+      volTM0f->SetLineColor(12);
+      volTM0f->SetFillColor(12); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+       mechLaddVol->AddNode(volTM0f, 0, new TGeoCombiTrans(x+smcCloseWallvapor-(0.02)/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+       mechLaddVol->AddNode(volTM0f, 1, new TGeoCombiTrans(x-smcCloseWallliquid+(0.02)/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      //Head(back) microchannel
+
+      TGeoBBox *tM0hb=new TGeoBBox(smcWidth/2, 0.025/2, headWidth/2);
+      TGeoVolume *volTM0hb=new TGeoVolume("microChanHeadBackBottom1", tM0hb, medKapton);
+      volTM0hb->SetLineColor(4);
+      volTM0hb->SetFillColor(4); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0hb, 0, new TGeoCombiTrans(x,yMC+0.03-0.0145-(0.025/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      mechLaddVol->AddNode(volTM0hb, 1, new TGeoCombiTrans(x,yMC+0.03-0.0145-(0.025)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0h1=new TGeoBBox(smcWidth/2, 0.013/2, 0.05/2);
+      TGeoVolume *volTM0h1=new TGeoVolume("microChanHeadBackBottom2", tM0h1, medKapton);
+      volTM0h1->SetLineColor(5);
+      volTM0h1->SetFillColor(5); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0h1, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-headWidth+(0.05/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0h2=new TGeoBBox(smcWidth/2, 0.003/2, 0.18/2);
+      TGeoVolume *volTM0h2=new TGeoVolume("microChanHeadBackBottom7", tM0h2, medKapton);
+      volTM0h2->SetLineColor(6);
+      volTM0h2->SetFillColor(6);
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0h2, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-0.01-(0.003/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-0.02-(0.18/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0h3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
+      TGeoVolume *volTM0h3=new TGeoVolume("microChanHeadBackBottom3", tM0h3, medKapton);
+      volTM0h3->SetLineColor(5);
+      volTM0h3->SetFillColor(5); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0h3, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(0.02/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0b1=new TGeoBBox(smcWidth/2, 0.013/2, 0.03/2);
+      TGeoVolume *volTM0b1=new TGeoVolume("microChanHeadBackBottom4", tM0b1, medKapton);
+      volTM0b1->SetLineColor(5);
+      volTM0b1->SetFillColor(5); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0b1, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+headWidth-(0.03/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0b2=new TGeoBBox(smcWidth/2, 0.003/2, 0.2/2);
+      TGeoVolume *volTM0b2=new TGeoVolume("microChanHeadBackBottom5", tM0b2, medKapton);
+      volTM0b2->SetLineColor(6);
+      volTM0b2->SetFillColor(6); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0b2, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-0.01-(0.003/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+0.02+(0.2/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0b3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
+      TGeoVolume *volTM0b3=new TGeoVolume("microChanHeadBackBottom6", tM0b3, medKapton);
+      volTM0b3->SetLineColor(5);
+      volTM0b3->SetFillColor(5); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0b3, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(0.02/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+     
+      TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zlad);
+      TGeoVolume *volTM0b=new TGeoVolume("microChanWalls", tM0b, medKapton);
+      volTM0b->SetLineColor(35);
+      volTM0b->SetFillColor(35); 
+      for (Int_t ib=0;ib<nb;ib++) {
+       //mechLaddVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
+      }
+      
+      } 
+    
+    if (fBuildLevel < 4) {
+
+      //**********cooling  inlet outlet
+
+      TGeoBBox *tM0dv=new TGeoBBox(vaporThick/2, 0.035/2,smcLength/2);
+      TGeoVolume *volTM0dv=new TGeoVolume("microChanVapor", tM0dv, medWater);
+      volTM0dv->SetLineColor(2);
+      volTM0dv->SetFillColor(2);
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0dv, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      TGeoBBox *tM0dl=new TGeoBBox(liquidThick/2, 0.035/2,smcLength/2);
+      TGeoVolume *volTM0dl=new TGeoVolume("microChanLiquid", tM0dl, medWater);
+      volTM0dl->SetLineColor(3);
+      volTM0dl->SetFillColor(3); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      mechLaddVol->AddNode(volTM0dl, 0, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      // small cooling fluid now using water wait for freeon value  
+      TGeoBBox *tM0dlq=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
+      TGeoVolume *volTM0dlq=new TGeoVolume("smallLiquid", tM0dlq, medWater);
+      volTM0dlq->SetLineColor(3);
+      volTM0dlq->SetFillColor(3); 
+      TGeoBBox *tM0dvp=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
+      TGeoVolume *volTM0dvp=new TGeoVolume("microChanVapor", tM0dvp, medWater);
+      volTM0dvp->SetLineColor(2);
+      volTM0dvp->SetFillColor(2); 
+      for(Int_t  mo=1; mo<=modules; mo++) {
+      for (Int_t is=0;is<12;is++) {
+       mechLaddVol->AddNode(volTM0dlq, 0, new TGeoCombiTrans(x+(is*(smcSpace+smcSide5Thick))-smcWidth/2+(smcSide1Thick)+(vaporThick)+(smcSide2Thick)+(smcSide3Thick)+smcSpace/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+       mechLaddVol->AddNode(volTM0dvp, 1, new TGeoCombiTrans(x-(is*(smcSpace+smcSide5Thick))+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-smcSpace/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
+      }
+      }
+
+      //*************
+
+    }
+    
+    if (fBuildLevel < 3) {
+
+      //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
+      Double_t filWidth = 0.04;
+      Double_t filHeight= 0.02;
+      TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,s1);
+      TGeoVolume *volT1=new TGeoVolume("bottomFilament", t1, medM60J3K);
+      volT1->SetLineColor(12);
+      volT1->SetFillColor(12); 
+      for(int i=0;i<loop;i++){//i<30;i++){
+               mechLaddVol->AddNode(volT1,4*i+0,
+                                   new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
+                                                      new TGeoRotation("volT1",-90,alpha,0)));
+       mechLaddVol->AddNode(volT1,4*i+1,
+                                   new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
+                                                      new TGeoRotation("volT1",90,alpha,0)));
+       mechLaddVol->AddNode(volT1,4*i+2,
+                                   new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
+                                                      new TGeoRotation("volT1",-90,-alpha,0)));
+       mechLaddVol->AddNode(volT1,4*i+3,
+                                   new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
+                                                      new TGeoRotation("volT1",-90,+alpha,0)));
+       }
+     // Top filament CERP black-12 Carbon structure TGeoBBox (length,thickness,width)
+
+      TGeoBBox *t2=new TGeoBBox(s2,filHeight/2,filWidth/2);
+      TGeoVolume *volT2=new TGeoVolume("topFilament", t2, medM60J3K);
+      volT2->SetLineColor(12);
+      volT2->SetFillColor(12); 
+      for(int i=0;i<loop;i++){ //i<30;i++){
+               mechLaddVol->AddNode(volT2,4*i+0,
+                                   new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
+                                                      new TGeoRotation("volT2",90,90-alpha,90-beta)));
+       mechLaddVol->AddNode(volT2,4*i+1,
+                                   new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
+                                                      new TGeoRotation("volT2",90,-90+alpha,-90+beta)));
+       mechLaddVol->AddNode(volT2,4*i+2,
+                                   new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2,
+                                                      new TGeoRotation("volT2",90,-90+alpha,90-beta)));
+       mechLaddVol->AddNode(volT2,4*i+3,
+                                   new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
+                                                      new TGeoRotation("volT2",90,90-alpha,-90+beta)));
+       }
+    }
+
+    if (fBuildLevel < 2) {
+
+      // Glue Filament and Silicon MicroChannel
+      TGeoBBox *tM0=new TGeoBBox(xladMC/5, klay4/2, zlad);
+      TGeoVolume *volTM0=new TGeoVolume("glueFM", tM0,medGlue );
+      volTM0->SetLineColor(5);
+      volTM0->SetFillColor(5); 
+      mechLaddVol->AddNode(volTM0, 0, new TGeoCombiTrans(x-xlad/2-0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
+      mechLaddVol->AddNode(volTM0, 1, new TGeoCombiTrans(x+xlad/2+0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
+
+            
+      // Glue microchannel and sensor
+      TGeoBBox *glueM = new TGeoBBox(xladMC/5, klay4/2, zlad);
+      TGeoVolume *volGlueM=new TGeoVolume("glueMS", glueM, medGlue);
+      volGlueM->SetLineColor(5);
+      volGlueM->SetFillColor(5); 
+      mechLaddVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x-xlad/2-0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
+      mechLaddVol->AddNode(volGlueM, 1, new TGeoCombiTrans(x+xlad/2+0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
+     
+       // Glue sensor and kapton
+      TGeoBBox *glue = new TGeoBBox(xlad, klay4/2, zlad);
+      TGeoVolume *volGlue=new TGeoVolume("glueSensorBus", glue, medGlue);
+      volGlue->SetLineColor(5);
+      volGlue->SetFillColor(5); 
+       mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4/2, z, new TGeoRotation("",0, 0, 0)));
+    }      
+
+    if (fBuildLevel < 1) {
+      TGeoBBox *kapCable = new TGeoBBox(xlad, klay5/2, zlad);
+      TGeoVolume *volCable=new TGeoVolume("Flexcable", kapCable, medFlexCable);
+      volCable->SetLineColor(28);
+      volCable->SetFillColor(28); 
+      mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4-klay5/2, z, new TGeoRotation("",0, 0, 0)));
+    }
+
+  // Done, return the stave structur
+    return mechLaddVol;
+ }
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveOuterB(const Double_t xlad,
+                                             const TGeoManager *mgr){
+//
+// Create the module stave for the Outer Barrel
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      20 Dec 2013  Mario Sitta
+//
+
+  TGeoVolume *mechLaddVol = 0;
+
+  switch (fStaveModel) {
+    case AliITSUv1::kOBModelDummy:
+      mechLaddVol = CreateStaveModelOuterBDummy(xlad,mgr);
+      break;
+    case AliITSUv1::kOBModel0:
+      mechLaddVol = CreateStaveModelOuterB0(xlad,mgr);
+      break;
+    case AliITSUv1::kOBModel1:
+      mechLaddVol = CreateStaveModelOuterB1(xlad,mgr);
+      break;
+    default:
+      AliFatal(Form("Unknown stave model %d",fStaveModel));
+      break;
+  }
+
+  return mechLaddVol; 
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterBDummy(const Double_t ,
+                                                       const TGeoManager *) const {
+//
+// Create dummy stave
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      20 Dec 2013  Mario Sitta
+//
+
+
+  // Done, return the stave structure
+  return 0;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterB0(const Double_t ,
+                                                   const TGeoManager *) const {
+//
+// Creation of the mechanical stave structure for the Outer Barrel as in v0
+// is done directly in CreateLadder, so this method does nothing
+// (doing it there is simpler, since all needed dimensions are known)
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      20 Dec 2013  Mario Sitta
+//
+
+  // Done, return the stave structure
+  return 0;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterB1(const Double_t xlad,
+                                                   const TGeoManager *mgr){
+//
+// Create the mechanical stave structure for the Outer Barrel as in TDR
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      20 Nov 2013  Anastasia Barbano
+// Updated:      16 Jan 2014  Mario Sitta
+//
+
+  // Materials defined in AliITSUv0
+  TGeoMedium *medAluminum     = mgr->GetMedium("ITS_ALUMINUM$");
+  TGeoMedium *medCarbon       = mgr->GetMedium("ITS_CARBON$");
+  TGeoMedium *medKapton       = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
+  TGeoMedium *medGlue         = mgr->GetMedium("ITS_GLUE$");
+  TGeoMedium *medWater        = mgr->GetMedium("ITS_WATER$");
+  TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
+  TGeoMedium *medFGS003       = mgr->GetMedium("ITS_FGS003$"); //amec thermasol
+  TGeoMedium *medAir          = mgr->GetMedium("ITS_AIR$");
+
+
+  // Local parameters
+  Double_t modGap             = fgkOBModuleGap;
+  Double_t yFlex1             = fgkOBFlexCable1Thick;
+  Double_t yFlex2             = fgkOBFlexCable2Thick;
+  Double_t yBus1              = fgkOBBusCable1Thick;
+  Double_t yBus2              = fgkOBBusCable2Thick;
+  Double_t xModPlate          = fgkOBHalfStaveWidth;
+  Double_t yModPlate          = fgkOBCarbonPlateThick;
+  Double_t xCPlate            = fgkOBHalfStaveWidth;
+  Double_t yCPlate            = fgkOBColdPlateThick;
+  Double_t yGlue              = fgkOBGlueThick;
+  Double_t flexOverlap        = 5;
+  Double_t deltaY             = 0.176;
+  Double_t xOverlap           = 0.23;       //overlapping of the halfStaves to cover the dead zone of sensors
+  Double_t zMod               = fgkOBModuleZLength;
+  Double_t xHalfSt            = fgkOBHalfStaveWidth/2;
+  Double_t xPos               = xOverlap/2 - xHalfSt;
+  Double_t xlen               = xlad;
+  Double_t rMin               = 0.267/2;
+  Double_t rMax               = rMin + 0.0065;
+  Double_t kLay1              = 0.004;      //carbon fleece
+  Double_t kLay2              = 0.003;      //carbon paper
+  Double_t yPos               = kLay1+kLay2;
+  Double_t ylen,zact;
+  Double_t zpos, zpos5cm;
+  Double_t ymod;
+  Double_t zbus;
+  Double_t zlen;
+
+
+  if (fIsTurbo) xlen = 0.5*fLadderWidth;
+  //ylen    = 0.5*fLadderThick;
+  ymod    = 0.005/2;//0.5*fSensorThick;
+  ylen    = 0.5*(2*kLay1+2*kLay2+2*rMax+yCPlate+yGlue+ yModPlate + ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2 + deltaY);
+  zact    = fNModules*zMod; //active area 
+  zbus    = zact + (fNModules-1)*modGap; 
+  zlen    = zbus/2;
+
+
+  // First create all needed shapes
+
+  TGeoTube *coolTube   = new TGeoTube("CoolingTube",rMin,rMax,zbus/2);
+  TGeoTube *coolTubeW  = new TGeoTube("CoolingTubeWater",0,rMin,zbus/2);
+  TGeoBBox *coldPlate  = new TGeoBBox("ColdPlate",xCPlate/2,yCPlate/2,zbus/2);
+  TGeoBBox *glue       = new TGeoBBox("Glue",xCPlate/2,yGlue/2,zbus/2);
+  TGeoBBox *modPlate   = new TGeoBBox("CarbonPlate",xModPlate/2,yModPlate/2,zbus/2);
+  TGeoBBox *flex1      = new TGeoBBox("Flex1MV",xHalfSt,yFlex1/2,zMod/2);
+  TGeoBBox *flex2      = new TGeoBBox("Flex2MV",xHalfSt,yFlex2/2,zMod/2);
+  TGeoBBox *flex1_5cm  = new TGeoBBox("Flex1MV_5cm",xHalfSt,yFlex1/2,flexOverlap/2);
+  TGeoBBox *flex2_5cm  = new TGeoBBox("Flex2MV_5cm",xHalfSt,yFlex2/2,flexOverlap/2);
+  TGeoBBox *bus1       = new TGeoBBox("Bus1HV",xHalfSt,yBus1/2,zbus/2);
+  TGeoBBox *bus2       = new TGeoBBox("Bus2HV",xHalfSt,yBus2/2,zbus/2); 
+  TGeoTubeSeg *cone1   = new TGeoTubeSeg(rMax +kLay2,rMax+kLay1+kLay2,zlen,180.,360.);  //Carbon Fleece 
+  TGeoTubeSeg *cone2   = new TGeoTubeSeg(rMax ,rMax+kLay2,zlen,180.,360.);  //Graphite paper 
+  TGeoBBox *box11      = new TGeoBBox((0.95-kLay2-rMax)/2,kLay1/2,zlen);
+  TGeoBBox *box12      = new TGeoBBox((1.11-2*kLay2-2*rMax)/2,kLay1/2,zlen);
+  TGeoBBox *box13      = new TGeoBBox(kLay1/2,(rMax-(kLay1+kLay2))/2,zlen);
+  TGeoBBox *box21      = new TGeoBBox((0.95-rMax)/2,kLay2/2,zlen);
+  TGeoBBox *box22      = new TGeoBBox((1.11-2*rMax)/2,kLay2/2,zlen);
+  TGeoBBox *box23      = new TGeoBBox(kLay2/2,(rMax-kLay2)/2,zlen);
+  TGeoBBox *mechStruct = new TGeoBBox("mechanicalStructure",xlen, ylen, 0.5*fZLength); 
+
+
+  TGeoVolume *modVol       = CreateModuleOuterB(xHalfSt, ymod, zMod);
+  TGeoVolume *coolTubeVol  = new TGeoVolume("CoolingTubeVol",coolTube,medKapton);
+  TGeoVolume *coolTubeWVol = new TGeoVolume("CoolingTubeWaterVol",coolTubeW,medWater);
+  TGeoVolume *coldPlateVol = new TGeoVolume("ColdPlateVol",coldPlate,medCarbon);
+  TGeoVolume *glueVol      = new TGeoVolume("GlueVol",glue,medGlue);
+  TGeoVolume *modPlateVol  = new TGeoVolume("CarbonPlateVol",modPlate,medCarbon);
+  TGeoVolume *flex1Vol     = new TGeoVolume("Flex1Vol",flex1,medAluminum);
+  TGeoVolume *flex2Vol     = new TGeoVolume("Flex2Vol",flex2,medKapton);
+  TGeoVolume *flex1_5cmVol = new TGeoVolume("Flex1Vol5cm",flex1_5cm,medAluminum);
+  TGeoVolume *flex2_5cmVol = new TGeoVolume("Flex2Vol5cm",flex2_5cm,medKapton);
+  TGeoVolume *bus1Vol      = new TGeoVolume("Bus1Vol",bus1,medAluminum);
+  TGeoVolume *bus2Vol      = new TGeoVolume("Bus2Vol",bus2,medKapton);
+  TGeoVolume *cone1Vol     = new TGeoVolume("CarbonFleecePipeCover",cone1,medCarbonFleece);
+  TGeoVolume *cone2Vol     = new TGeoVolume("GraphitePaperPipeCover",cone2,medFGS003);
+  TGeoVolume *plate11Vol   = new TGeoVolume("CarbonFleeceLR1",box11,medCarbonFleece);
+  TGeoVolume *plate12Vol   = new TGeoVolume("CarbonFleeceMiddle1",box12,medCarbonFleece); 
+  TGeoVolume *plate13Vol   = new TGeoVolume("CarbonFleeceVertical1",box13,medCarbonFleece); 
+  TGeoVolume *plate21Vol   = new TGeoVolume("CarbonFleeceLR2",box21,medFGS003);
+  TGeoVolume *plate22Vol   = new TGeoVolume("CarbonFleeceMiddle2",box22,medFGS003);
+  TGeoVolume *plate23Vol   = new TGeoVolume("CarbonFleeceVertical2",box23,medFGS003);
+  TGeoVolume *mechLaddVol  = new TGeoVolume("mechLadderVolume",mechStruct,medAir);
+
+  mechLaddVol->SetLineColor(12);
+  mechLaddVol->SetFillColor(12); 
+  mechLaddVol->SetVisibility(kTRUE);
+
+  modVol->SetVisibility(kTRUE);
+  flex1_5cmVol->SetLineColor(kRed);
+  flex2_5cmVol->SetLineColor(kGreen);
+  modPlateVol->SetLineColor(kMagenta-8);
+  coolTubeVol->SetLineColor(kGray);
+  coolTubeWVol->SetLineColor(kBlue);
+  coldPlateVol->SetLineColor(kYellow-3);
+  glueVol->SetLineColor(kBlack);
+  flex1Vol->SetLineColor(kRed);
+  flex2Vol->SetLineColor(kGreen);
+  bus1Vol->SetLineColor(kCyan);
+  bus2Vol->SetLineColor(kBlue);
+  cone1Vol->SetFillColor(kViolet);
+  plate11Vol->SetFillColor(kViolet);
+  plate12Vol->SetLineColor(kViolet);
+  plate13Vol->SetLineColor(kViolet);
+  cone2Vol->SetLineColor(kGreen);
+  plate22Vol->SetFillColor(kGreen);
+  plate21Vol->SetLineColor(kGreen);
+  plate23Vol->SetLineColor(kGreen);
+
+
+  //Carbon Fleece
+
+  mechLaddVol->AddNode(plate11Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
+  mechLaddVol->AddNode(plate11Vol,2,new TGeoTranslation(xPos +(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
+  mechLaddVol->AddNode(plate11Vol,3,new TGeoTranslation(-xPos -(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2 +deltaY,0));
+  mechLaddVol->AddNode(plate11Vol,4,new TGeoTranslation(-xPos +(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2 +deltaY,0));
+  mechLaddVol->AddNode(plate12Vol,1,new TGeoTranslation(xPos ,-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
+  mechLaddVol->AddNode(plate12Vol,2,new TGeoTranslation(-xPos ,-ylen + yPos +2*rMax-kLay2-kLay1/2 + deltaY,0));
+  mechLaddVol->AddNode(plate13Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
+  mechLaddVol->AddNode(plate13Vol,2,new TGeoTranslation(xPos -1.11/2+rMax+kLay2+box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
+  mechLaddVol->AddNode(plate13Vol,3,new TGeoTranslation(xPos +(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
+  mechLaddVol->AddNode(plate13Vol,4,new TGeoTranslation(xPos +1.11/2-rMax-kLay2-box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
+  mechLaddVol->AddNode(plate13Vol,5,new TGeoTranslation(-xPos -(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
+  mechLaddVol->AddNode(plate13Vol,6,new TGeoTranslation(-xPos -1.11/2+rMax+kLay2+box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
+  mechLaddVol->AddNode(plate13Vol,7,new TGeoTranslation(-xPos +(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
+  mechLaddVol->AddNode(plate13Vol,8,new TGeoTranslation(-xPos +1.11/2-rMax-kLay2-box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
+
+  mechLaddVol->AddNode(cone1Vol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(cone1Vol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(cone1Vol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
+  mechLaddVol->AddNode(cone1Vol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
+
+
+  //Carbon Paper
+
+  mechLaddVol->AddNode(plate21Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box21->GetDX()),-ylen + yPos +2*rMax-kLay2/2,0));
+  mechLaddVol->AddNode(plate21Vol,2,new TGeoTranslation(xPos +(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2,0));
+  mechLaddVol->AddNode(plate21Vol,3,new TGeoTranslation(-xPos -(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2 +deltaY,0));
+  mechLaddVol->AddNode(plate21Vol,4,new TGeoTranslation(-xPos +(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2 +deltaY,0));
+  mechLaddVol->AddNode(plate22Vol,1,new TGeoTranslation(xPos ,-ylen + yPos +2*rMax-kLay2/2,0));
+  mechLaddVol->AddNode(plate22Vol,2,new TGeoTranslation(-xPos ,-ylen + yPos +2*rMax-kLay2/2 + deltaY,0));
+  mechLaddVol->AddNode(plate23Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
+  mechLaddVol->AddNode(plate23Vol,2,new TGeoTranslation(xPos -1.11/2+rMax+box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
+  mechLaddVol->AddNode(plate23Vol,3,new TGeoTranslation(xPos +(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
+  mechLaddVol->AddNode(plate23Vol,4,new TGeoTranslation(xPos +1.11/2-rMax-box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
+  mechLaddVol->AddNode(plate23Vol,5,new TGeoTranslation(-xPos -(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
+  mechLaddVol->AddNode(plate23Vol,6,new TGeoTranslation(-xPos -1.11/2+rMax+box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
+  mechLaddVol->AddNode(plate23Vol,7,new TGeoTranslation(-xPos +(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
+  mechLaddVol->AddNode(plate23Vol,8,new TGeoTranslation(-xPos +1.11/2-rMax-box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
+
+  mechLaddVol->AddNode(cone2Vol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(cone2Vol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(cone2Vol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
+  mechLaddVol->AddNode(cone2Vol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
+
+  //Cooling Tubes + water
+
+  mechLaddVol->AddNode(coolTubeVol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(coolTubeWVol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(coolTubeVol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(coolTubeWVol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
+  mechLaddVol->AddNode(coolTubeVol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
+  mechLaddVol->AddNode(coolTubeWVol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
+  mechLaddVol->AddNode(coolTubeVol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
+  mechLaddVol->AddNode(coolTubeWVol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
+
+  //Cold Plate
+
+  mechLaddVol->AddNode(coldPlateVol,1,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate/2,0));
+  mechLaddVol->AddNode(coldPlateVol,2,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate/2 + deltaY,0));
+
+  //Glue
+
+  mechLaddVol->AddNode(glueVol,1,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue/2,0));
+  mechLaddVol->AddNode(glueVol,2,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue/2 + deltaY,0));
+
+  //Module Carbon Plate
+
+  mechLaddVol->AddNode(modPlateVol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate/2,0));
+  mechLaddVol->AddNode(modPlateVol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate/2 + deltaY,0));
+
+  //Bus
+
+  mechLaddVol->AddNode(bus1Vol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1/2,0));
+  mechLaddVol->AddNode(bus1Vol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1/2 + deltaY,0));
+  mechLaddVol->AddNode(bus2Vol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2/2,0));
+  mechLaddVol->AddNode(bus2Vol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2/2 + deltaY,0));
+  
+  //FPC + modules
+
+  for (Int_t j=0; j<fNModules; j++) {
+
+    zpos = -(zact + (fNModules-1)*modGap)/2 + j*(zMod + modGap) + zMod/2;
+    zpos5cm = -(zact + (fNModules-1)*modGap)/2 + (j+1)*(zMod + modGap) + flexOverlap/2 ;
+
+    mechLaddVol->AddNode(modVol, j, new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + ymod, zpos));
+    mechLaddVol->AddNode(modVol, fNModules+j, new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + ymod +deltaY, zpos));
+    mechLaddVol->AddNode(flex1Vol,j,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2,zpos));
+    mechLaddVol->AddNode(flex1Vol,fNModules+j,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2 + deltaY,zpos));
+    mechLaddVol->AddNode(flex2Vol,j,new TGeoTranslation(xPos, -ylen + yPos + yModPlate + 2*rMax + yCPlate + yGlue + 2*ymod + yFlex1 + yFlex2/2,zpos));
+    mechLaddVol->AddNode(flex2Vol,fNModules+j,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2/2 + deltaY,zpos));
+
+    if((j+1)!=fNModules){
+      mechLaddVol->AddNode(flex1_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2 + yFlex1/2,zpos5cm));
+      mechLaddVol->AddNode(flex1_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2 + yFlex1/2 +deltaY,zpos5cm));
+      mechLaddVol->AddNode(flex2_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 3*yFlex2/2,zpos5cm));
+      mechLaddVol->AddNode(flex2_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 3*yFlex2/2 +deltaY,zpos5cm));
+    }
+    else {
+      mechLaddVol->AddNode(flex1_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2,zpos5cm-modGap));
+      mechLaddVol->AddNode(flex1_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2 +deltaY,zpos5cm-modGap));
+      mechLaddVol->AddNode(flex2_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate +2*ymod + yFlex1 + yFlex2/2,zpos5cm-modGap));
+      mechLaddVol->AddNode(flex2_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2/2 +deltaY,zpos5cm-modGap));
+
+      }
+  }
+  
+
+  // Done, return the stave structur
+  return mechLaddVol;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterB(const Double_t xlad,
+                                                  const TGeoManager *mgr){
+//
+// Create the space frame for the Outer Barrel
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+//
+
+  TGeoVolume *mechLaddVol = 0;
+
+  switch (fStaveModel) {
+    case AliITSUv1::kOBModelDummy:
+      mechLaddVol = CreateSpaceFrameOuterBDummy(xlad,mgr);
+      break;
+    case AliITSUv1::kOBModel1:
+      mechLaddVol = CreateSpaceFrameOuterB0(xlad,mgr);
+      break;
+    default:
+      AliFatal(Form("Unknown stave model %d",fStaveModel));
+      break;
+  }
+
+  return mechLaddVol; 
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterBDummy(const Double_t ,
+                                                       const TGeoManager *) const {
+//
+// Create dummy stave
+//
+// Input:
+//         xlad : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+
+
+  // Done, return the stave structur
+  return 0;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterB0(const Double_t xlen,
+                                                   const TGeoManager *mgr){
+//
+// Create the space frame for the Outer Barrel (Model 0)
+//
+// Input:
+//         xlen : X length
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//         a TGeoVolume with the Space Frame of a stave
+//
+// Created:      20 Dec 2013  Anastasia Barbano
+// Updated:      15 Jan 2014  Mario Sitta
+//
+
+
+  // Materials defined in AliITSUv0
+  TGeoMedium *medCarbon       = mgr->GetMedium("ITS_CARBON$");
+  TGeoMedium *medAir          = mgr->GetMedium("ITS_AIR$");
+
+
+  // Local parameters
+  Double_t ladderWidth        = 4.2;
+  Double_t ladderHeight       = 4.2;
+//  Double_t ladderSegBoxDW     = 7.5;
+//  Double_t ladderSegBoxDH     = 7.1;
+  Double_t ladderBeamRadius   = 0.06;
+  Double_t ladderLa           = 0.3;
+  Double_t ladderHa           = 0.0721979;
+  Double_t ladderLb           = 0.37;
+  Double_t ladderHb           = 0.0890428;
+  Double_t ladderl            = 0.025;
+  Double_t beamSidePhi        = 65;
+  Double_t bottomBeamAngle    = 56.5;
+//  Double_t dy                 = ladderSegBoxDH/2;
+  Double_t triangleHeight     = ladderHeight - ladderBeamRadius;
+  Double_t halfTheta          = TMath::ATan( 0.5*ladderWidth/triangleHeight );
+  Double_t alpha              = TMath::Pi()*3./4. - halfTheta/2.;
+  Double_t beta               = (TMath::Pi() - 2.*halfTheta)/4.;
+//  Double_t dYTranslation      = (ladderHeight/2. -0.5*ladderWidth*TMath::Tan(beta)-ladderBeamRadius);
+  Double_t distCenterSideDown =  0.5*ladderWidth/TMath::Cos(beta);
+  Double_t zact;
+  Double_t zbus;
+  Double_t zlen;
+  Double_t seglen;    
+
+
+  zact    = fNModules*fgkOBModuleZLength; //active area 
+  zbus    = zact + (fNModules-1)*fgkOBModuleGap; 
+  zlen    = zbus/2;
+  seglen  = zlen/10;
+
+  // First create all needed shapes and volumes
+
+  TGeoBBox *spaceFrame = new TGeoBBox("CarbonFrame",xlen, 2.2, zlen);
+  TGeoBBox *segment    = new TGeoBBox(ladderWidth/2,ladderHeight/2,seglen/2);
+
+  TGeoVolume *spaceFrameVol = new TGeoVolume("CarbonFrameVolume",
+                                            spaceFrame, medAir);
+  spaceFrameVol->SetVisibility(kTRUE);
+
+  TGeoVolume *segmentVol    = new TGeoVolume("segmentVol",segment,medAir);
+
+  //SpaceFrame
+
+  //--- the top V of the Carbon Fiber Ladder (segment)
+  TGeoArb8 *cfLaddTop1 = CreateLadderSide("CFladdTopCornerVol1shape", seglen/2., halfTheta, -1, ladderLa, ladderHa, ladderl);
+  TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1", cfLaddTop1,medCarbon);
+  TGeoArb8 *cfLaddTop2 = CreateLadderSide( "CFladdTopCornerVol2shape", seglen/2., halfTheta, 1, ladderLa, ladderHa, ladderl);
+  TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerVol2",cfLaddTop2,medCarbon );
+
+  //TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2-dy, 0);
+  TGeoTranslation *trTop1 = new TGeoTranslation(0, ladderHeight/2, 0);
+  
+  //--- the 2 side V
+  TGeoArb8 *cfLaddSide1 = CreateLadderSide( "CFladdSideCornerVol1shape", seglen/2., beta, -1,ladderLb, ladderHb, ladderl);
+  TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerVol1", cfLaddSide1,medCarbon);
+  TGeoArb8 *cfLaddSide2 = CreateLadderSide( "CFladdSideCornerVol2shape", seglen/2., beta, 1, ladderLb, ladderHb, ladderl);
+  TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerVol2", cfLaddSide2,medCarbon );
+
+  
+  TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,alpha*TMath::RadToDeg());
+  //AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation-dy, 0);
+  AddTranslationToCombiTrans(ctSideR, 0, ladderHeight/2-2.85/*2.765250/*triangleHeight*/, 0);
+  TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,-alpha*TMath::RadToDeg());
+  //AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation-dy, 0);
+  AddTranslationToCombiTrans(ctSideL, 0, ladderHeight/2-2.85/*triangleHeight*/, 0);
+
+  segmentVol->AddNode(cfLaddTopVol1,1,trTop1);
+  segmentVol->AddNode(cfLaddTopVol2,1,trTop1);
+  segmentVol->AddNode(cfLaddSideVol1,1,ctSideR);
+  segmentVol->AddNode(cfLaddSideVol1,2,ctSideL);
+  segmentVol->AddNode(cfLaddSideVol2,1,ctSideR);
+  segmentVol->AddNode(cfLaddSideVol2,2,ctSideL);
+
+
+  //--- The beams
+  // Beams on the sides
+  Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*TMath::Sin(2*beta)/(TanD(beamSidePhi)*TanD(beamSidePhi))) ));
+  Double_t beamLength = TMath::Sqrt( ladderHeight*ladderHeight/( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))+ ladderWidth*ladderWidth/4.)-ladderLa/2-ladderLb/2;
+  TGeoTubeSeg *sideBeamS = new TGeoTubeSeg(0, ladderBeamRadius,beamLength/2.,0, 180);
+  TGeoVolume *sideBeam = new TGeoVolume("ITSsddCFSideBeamVol", sideBeamS,medCarbon);
+
+  //Euler rotation : about Z, then new X, then new Z
+  TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),-beamPhiPrime*TMath::RadToDeg(),-90);
+  TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(), beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(), beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),-beamPhiPrime*TMath::RadToDeg(),-90);
+
+  TGeoCombiTrans *beamTransf[8];
+  beamTransf[0] = new TGeoCombiTrans( 0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot1);
+
+  beamTransf[1] = new TGeoCombiTrans( 0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot1);
+  AddTranslationToCombiTrans(beamTransf[1], 0, 0, seglen/2);
+
+  beamTransf[2] = new TGeoCombiTrans(0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-seglen/8, beamRot2);
+
+  beamTransf[3] = new TGeoCombiTrans(0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-seglen/8, beamRot2);
+  AddTranslationToCombiTrans(beamTransf[3], 0, 0, seglen/2);
+
+  beamTransf[4] = new TGeoCombiTrans(-0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot3);
+
+  beamTransf[5] = new TGeoCombiTrans(-0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot3);
+  AddTranslationToCombiTrans(beamTransf[5], 0, 0, seglen/2);
+
+  beamTransf[6] = new TGeoCombiTrans(-0.5*triangleHeight* TMath::Tan(halfTheta),ladderBeamRadius/2., -seglen/8,beamRot4);
+  beamTransf[7] = new TGeoCombiTrans(-0.5*triangleHeight* TMath::Tan(halfTheta),ladderBeamRadius/2.,3*seglen/8,beamRot4);
+
+  //--- Beams of the bottom
+  TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, ladderBeamRadius,ladderWidth/2.-ladderLb/3, 0, 180);
+  TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol", bottomBeam1, medCarbon);
+  TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, ladderBeamRadius,ladderWidth/2.-ladderLb/3, 0, 90);
+  TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",bottomBeam2, medCarbon);
+  TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, ladderBeamRadius,0.5*ladderWidth/SinD(bottomBeamAngle) - ladderLb/3, 0, 180);
+  TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol", bottomBeam3, medCarbon);
+  TGeoRotation *bottomBeamRot1 = new TGeoRotation("", 90, 90,  90);
+  TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
+
+  TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans("",0,-(ladderHeight/2-ladderBeamRadius),0, bottomBeamRot1);
+  TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),-seglen/2, bottomBeamRot1);
+  TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius), seglen/2, bottomBeamRot2);
+  // be careful for beams #3: when "reading" from -z to +z and 
+  // from the bottom of the ladder, it should draw a Lambda, and not a V
+  TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, bottomBeamAngle, -90);
+  TGeoRotation *bottomBeamRot5 = new TGeoRotation("" ,-90,-bottomBeamAngle, -90);
+  TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),-seglen/4,bottomBeamRot4);
+  TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),seglen/4, bottomBeamRot5);
+
+  cfLaddTopVol1->SetLineColor(35);
+  cfLaddTopVol2->SetLineColor(35);
+  cfLaddSideVol1->SetLineColor(35);
+  cfLaddSideVol2->SetLineColor(35);
+  sideBeam->SetLineColor(35);
+  bottomBeam1Vol->SetLineColor(35);
+  bottomBeam2Vol->SetLineColor(35);
+  bottomBeam3Vol->SetLineColor(35);
+
+
+  segmentVol->AddNode(sideBeam,1, beamTransf[0]);
+  segmentVol->AddNode(sideBeam,2, beamTransf[1]);
+  segmentVol->AddNode(sideBeam,3, beamTransf[2]);
+  segmentVol->AddNode(sideBeam,4, beamTransf[3]);
+  segmentVol->AddNode(sideBeam,5, beamTransf[4]);
+  segmentVol->AddNode(sideBeam,6, beamTransf[5]);
+  segmentVol->AddNode(sideBeam,7, beamTransf[6]);
+  segmentVol->AddNode(sideBeam,8, beamTransf[7]);
+  segmentVol->AddNode(bottomBeam1Vol,1,bottomBeamTransf1);
+  segmentVol->AddNode(bottomBeam2Vol,1,bottomBeamTransf2);
+  segmentVol->AddNode(bottomBeam2Vol,1,bottomBeamTransf3);
+  segmentVol->AddNode(bottomBeam3Vol,1,bottomBeamTransf4);
+  segmentVol->AddNode(bottomBeam3Vol,1,bottomBeamTransf5);
+
+  for(Int_t i=0;i<10;i++){
+    spaceFrameVol->AddNode(segmentVol,i,new TGeoTranslation(0,0,seglen*(0.5+i)));
+    spaceFrameVol->AddNode(segmentVol,11+i,new TGeoTranslation(0,0,-seglen*(0.5+i)));
+  }
+
+
+  // Done, return the stave structur
+  return spaceFrameVol;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateModuleInnerB(const Double_t xlad,
+                                              const Double_t ylad,   
+                                              const Double_t zlad,
+                                              const TGeoManager *mgr){
+//
+// Creates the actual Module
+//
+// Input:
+//         xlad,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(kTRUE);
+  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;
+}
+
+//________________________________________________________________________
+TGeoVolume* AliITSUv1Layer::CreateModuleOuterB(const Double_t xlad,
+                                              const Double_t ylad,   
+                                              const Double_t zmod,
+                                              const TGeoManager *mgr){
+//
+// Creates the actual Module
+//
+// Input:
+//         xlad,ylad,zlad : the half stave dimensions
+//         mgr  : the GeoManager (used only to get the proper material)
+//
+// Output:
+//
+// Return:
+//
+// Created:      18 Dec 2013  M. Sitta, A. Barbano
+//
+
+
+  char volname[30];
+
+  Double_t xGap  = 0.01; 
+  Double_t zGap  = 0.01;
+
+  Double_t xlen, ylen, zlen;
+  Double_t xpos, ypos, zpos;
+  
+  // First create all needed shapes
+
+  // The module
+  TGeoBBox *module = new TGeoBBox(xlad,  ylad, zmod/2);
+
+  // The sensor
+  xlen = 0.5*(module->GetDX()-xGap/2);
+  //xlen = 0.5*1.5;
+  ylen = ylad;
+  zlen = (2*module->GetDZ()-6*zGap)/14;
+  TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
+
+
+  // We have all shapes: now create the real volumes
+  TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern(), fLayerNumber);
+  TGeoVolume *modVol = new TGeoVolume(volname, module, medSi);
+  modVol->SetVisibility(kTRUE);
+
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
+  TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
+  
+
+
+  // Now build up the module
+  xpos = -module->GetDX() + sensor->GetDX();
+  //xpos = -xGap/2 -sensor->GetDX();
+  ypos = -module->GetDY() + sensor->GetDY();
+  for(Int_t k=0;k<7;k++)   //put 7x2 chip into one module
+    {
+      zpos = -module->GetDZ() + sensor->GetDZ() + k*(2*sensor->GetDZ() + zGap);
+      modVol->AddNode(sensVol, k+1, new TGeoTranslation(xpos, ypos, zpos));
+      modVol->AddNode(sensVol, k+2, new TGeoTranslation(-xpos, ypos, zpos));
+    }
+  
+  //sensVol->SetVisibility(kTRUE);
+  sensVol->SetLineColor(kYellow);
+  //sensVol->SetLineWidth(1);
+  //sensVol->SetTransparency(30);
+  sensVol->SetFillColor(sensVol->GetLineColor());
+  sensVol->SetFillStyle(4000); // 0% transparent
+  // Done, return the module
+  return modVol;
+}
+
+//________________________________________________________________________
+Double_t AliITSUv1Layer::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 AliITSUv1Layer::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 AliITSUv1Layer::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");
+
+}
+
+//________________________________________________________________________
+TGeoArb8 *AliITSUv1Layer::CreateLadderSide(const char *name,
+                         Double_t dz, Double_t angle, Double_t xSign,
+                         Double_t L, Double_t H, Double_t l) {
+//
+// Creates the V-shaped sides of the OB space frame
+// (from a similar method with same name and function
+// in AliITSv11GeometrySDD class by L.Gaudichet)
+//
+
+    // Create one half of the V shape corner of CF ladder
+  
+    TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
+    cfLaddSide->SetName(name);
+
+    // Points must be in clockwise order
+    cfLaddSide->SetVertex(0, 0,  0);
+    cfLaddSide->SetVertex(2, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
+                         -L*TMath::Cos(angle)-l*TMath::Sin(angle));
+    cfLaddSide->SetVertex(4, 0,  0);
+    cfLaddSide->SetVertex(6, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
+                         -L*TMath::Cos(angle)-l*TMath::Sin(angle));
+    if (xSign < 0) {
+     cfLaddSide->SetVertex(1, 0, -H);
+     cfLaddSide->SetVertex(3, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
+     cfLaddSide->SetVertex(5, 0, -H);
+     cfLaddSide->SetVertex(7, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
+    } else {
+     cfLaddSide->SetVertex(1, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
+     cfLaddSide->SetVertex(3, 0, -H);
+     cfLaddSide->SetVertex(5, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
+     cfLaddSide->SetVertex(7, 0, -H);
+    }
+    return cfLaddSide;
+}
+
+//________________________________________________________________________
+TGeoCombiTrans *AliITSUv1Layer::CreateCombiTrans(const char *name,
+                                        Double_t dy, Double_t dz,
+                                        Double_t dphi, Bool_t planeSym) {
+//
+// Help method to create a TGeoCombiTrans matrix
+// (from a similar method with same name and function
+// in AliITSv11GeometrySDD class by L.Gaudichet)
+//
+
+    //
+    // return the TGeoCombiTrans which make a translation in y and z
+    // and a rotation in phi in the global coord system
+    // If planeSym = true, the rotation places the object symetrically
+    // (with respect to the transverse plane) to its position in the
+    // case planeSym = false
+    //
+
+    TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
+    TGeoRotation r1("",0.,0.,dphi);
+    TGeoRotation r2("",90, 180, -90-dphi);
+
+    TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
+    combiTrans1->SetTranslation(t1);
+    if (planeSym) combiTrans1->SetRotation(r1);
+    else  combiTrans1->SetRotation(r2);
+    return combiTrans1;
+}
+
+//________________________________________________________________________
+void AliITSUv1Layer::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
+                                                       Double_t dx,
+                                                       Double_t dy,
+                                                       Double_t dz) const{
+//
+// Help method to add a translation to a TGeoCombiTrans matrix
+// (from a similar method with same name and function
+// in AliITSv11GeometrySDD class by L.Gaudichet)
+//
+
+  // Add a dx,dy,dz translation to the initial TGeoCombiTrans
+  const Double_t *vect = ct->GetTranslation();
+  Double_t newVect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
+  ct->SetTranslation(newVect);
+}
diff --git a/ITS/UPGRADE/AliITSUv1Layer.h b/ITS/UPGRADE/AliITSUv1Layer.h
new file mode 100644 (file)
index 0000000..520cbd0
--- /dev/null
@@ -0,0 +1,139 @@
+#ifndef ALIITSUV1LAYER_H
+#define ALIITSUV1LAYER_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: AliITSUv1Layer.h
+ */
+
+#include "AliITSv11Geometry.h"
+#include "AliITSUv1.h"
+#include <TGeoManager.h>
+#include <TGeoCompositeShape.h>
+#include <TGeoXtru.h>
+
+class TGeoVolume;
+
+class AliITSUv1Layer : public AliITSv11Geometry {
+  public:
+    AliITSUv1Layer();
+    AliITSUv1Layer(Int_t debug);
+    AliITSUv1Layer(Int_t lay, Int_t debug);
+    AliITSUv1Layer(Int_t lay, Bool_t turbo, Int_t debug);
+    AliITSUv1Layer(const AliITSUv1Layer &source);
+    AliITSUv1Layer& operator=(const AliITSUv1Layer &source);
+    virtual ~AliITSUv1Layer();
+    //
+    Bool_t    IsTurbo() const {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;}
+    AliITSUv1::AliITSUModel_t GetStaveModel() const {return fStaveModel;}
+    //
+    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;}
+    void      SetBuildLevel(Int_t buildLevel){fBuildLevel=buildLevel;}
+    void      SetStaveModel(AliITSUv1::AliITSUModel_t model) {fStaveModel=model;}
+    virtual void CreateLayer(TGeoVolume *moth);
+
+  private:
+    void CreateLayerTurbo(TGeoVolume *moth);
+
+    Double_t RadiusOfTurboContainer();
+
+    TGeoVolume* CreateLadder(const TGeoManager *mgr=gGeoManager);
+    //TGeoVolume* CreateModule(Double_t x, Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateModuleInnerB(Double_t x,Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateModuleOuterB(Double_t x,Double_t y, Double_t z, const TGeoManager *mgr=gGeoManager);
+
+
+    TGeoVolume* CreateStaveStructInnerB(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelInnerBDummy(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager) const;
+    TGeoVolume* CreateStaveModelInnerB0(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelInnerB1(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelInnerB21(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelInnerB22(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelInnerB3(Double_t x,Double_t z, const TGeoManager *mgr=gGeoManager);
+
+    TGeoVolume* CreateStaveOuterB(Double_t x, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateStaveModelOuterBDummy(Double_t x, const TGeoManager *mgr=gGeoManager) const;
+    TGeoVolume* CreateStaveModelOuterB0(Double_t x, const TGeoManager *mgr=gGeoManager) const;
+    TGeoVolume* CreateStaveModelOuterB1(Double_t x, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateSpaceFrameOuterB(Double_t x, const TGeoManager *mgr=gGeoManager);
+    TGeoVolume* CreateSpaceFrameOuterBDummy(Double_t x, const TGeoManager *mgr=gGeoManager) const;
+    TGeoVolume* CreateSpaceFrameOuterB0(Double_t x, const TGeoManager *mgr=gGeoManager);
+
+    TGeoArb8* CreateLadderSide(const char *name,
+                              Double_t dz, Double_t angle, Double_t xSign,
+                              Double_t L, Double_t H, Double_t l);
+    TGeoCombiTrans* CreateCombiTrans( const char *name,
+                                     Double_t dy, Double_t dz, Double_t dphi,
+                                     Bool_t planeSym=kFALSE);
+    void AddTranslationToCombiTrans( TGeoCombiTrans* ct,
+                                    Double_t dx=0, Double_t dy=0,
+                                    Double_t dz=0) const;
+
+
+    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
+    Int_t     fBuildLevel;  // Used for material studies
+
+    AliITSUv1::AliITSUModel_t fStaveModel; // The stave model
+
+    // Parameters for the Upgrade geometry
+
+    static const Double_t fgkDefaultSensorThick; // Default sensor thickness
+    static const Double_t fgkDefaultLadderThick; // Default ladder thickness
+
+    static const Double_t fgkOBHalfStaveWidth;   // OB Half Stave Width
+    static const Double_t fgkOBModuleGap;        // Gap between OB modules
+    static const Double_t fgkOBFlexCable1Thick;  // Thickness of
+    static const Double_t fgkOBFlexCable2Thick;  // OB flex cables
+    static const Double_t fgkOBBusCable1Thick;   // Thickness of
+    static const Double_t fgkOBBusCable2Thick;   // OB bus cables
+    static const Double_t fgkOBCarbonPlateThick; // OB Carbon Plate Thickness
+    static const Double_t fgkOBColdPlateThick;   // OB Cold Plate Thickness
+    static const Double_t fgkOBGlueThick;        // OB Glue total Thickness
+    static const Double_t fgkOBModuleZLength;    // OB Module Length along Z
+
+  ClassDef(AliITSUv1Layer,0) // ITS Upgrade v1 geometry
+};
+
+#endif
index 55846edf6f1aa3c1dc051eb8fab75a6560eba636..d3eda96e394f977adf71fa68df6866c4fea12a9e 100644 (file)
 set ( SRCS     
 #v0/AliITSupgrade.cxx 
 #v0/AliITSupgradeDigitizer.cxx 
-#AliITSUv11.cxx 
-#AliITSUv11Layer.cxx 
 #
 AliITSU.cxx 
 AliITSUv0.cxx 
 AliITSUv0Layer.cxx 
+AliITSUv1.cxx 
+AliITSUv1Layer.cxx 
 AliITSUModule.cxx
 AliITSUSimuParam.cxx
 AliITSUSimulation.cxx
@@ -41,6 +41,7 @@ AliITSUSimulationPix.cxx
 AliITSUDigitPix.cxx
 AliITSUDigitizer.cxx
 AliITSUHit.cxx
+AliITSUSuze02.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index c49c7a8cef048d8c38cd302caaca09bef34df650..8014d82f0e67c4c50d0f6de33f320bbd892755c7 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+;       // obsolete
-//#pragma link C++ class  AliITSUv11Layer+;  // obsolete
+#pragma link C++ class  AliITSUv1+;
+#pragma link C++ class  AliITSUv1Layer+;
 #pragma link C++ class  AliITSUModule+;
 #pragma link C++ class  AliITSUSimuParam+;
 #pragma link C++ class  AliITSUSimulation+;
@@ -29,6 +29,7 @@
 #pragma link C++ class  AliITSUDigitPix+;
 #pragma link C++ class  AliITSUDigitizer+;
 #pragma link C++ class  AliITSUHit+;
+#pragma link C++ class  AliITSUSuze02+;
 
 
 #endif
diff --git a/ITS/UPGRADE/macros/ScanDigitsSuze02_v15.C b/ITS/UPGRADE/macros/ScanDigitsSuze02_v15.C
new file mode 100644 (file)
index 0000000..82159db
--- /dev/null
@@ -0,0 +1,467 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+  #include <Riostream.h>
+  #include <TH2I.h>
+  #include <TH1D.h>
+  #include <TH2D.h>
+  #include <TH1I.h>
+  #include <TCanvas.h>
+  #include <TMatrixD.h>
+  #include <TSystem.h>
+  #include <TROOT.h>
+  #include <TClonesArray.h>
+  #include <TTree.h>
+  #include <TFile.h>  
+  #include <TDirectoryFile.h>
+
+  #include <AliRun.h>
+  #include <AliStack.h>
+  #include <AliLoader.h>
+  #include <AliGeomManager.h>
+  #include <AliITSUGeomTGeo.h>
+  #include <AliITSUDigitPix.h>
+  #include <AliITSUSegmentationPix.h>
+  #include "AliITSUSuze02.h"
+
+#endif
+
+//v4 - SuZe limits version can be chosen. Requires MakeSuze_v2.h
+//v5 - saving average number of digits per encoding window for each module/event
+//v6 - saving the lowest remaining number of windows for each of three limits for eache module/event. Requires MakeSuze_v3.h
+//v7 - saving distribution of number of digits per encoding window per layer and in total. Requires at least MakeSuze_v4.h
+//v8 - changed the number of rows for the small and big sensor to 320 and 640 rescpectively. Used for the "final" production.
+//v9 - compatibility changes to MakeSuze_v7 that returns the data size as well.       
+//v10 - modules with signal hits are processed by SUZE
+//v11 - version to use with MakeSuze_v8 where data size calculation has been corrected and SuzeLimitsVersion=99 has been added
+//v12 - switch added to process modules with only signal hits        
+//v13 - AliITSUSuze02.h is used instead of MakeSuze_v8.h
+//v14 - QED digits are added from the separate file  
+//v15 - switch added to add QED digits
+
+Int_t GetSuzeLimits(Int_t DataSizePerWindowInRow, Int_t Version, Int_t& Limit32, Int_t& LimitHalfFSBB, Int_t& LimitFSBB){
+  
+  switch (Version){
+    case 1:
+      Limit32=6;
+      LimitHalfFSBB=12;
+      LimitFSBB=19;
+      return 1;
+    case 2:
+      Limit32=6;
+      LimitHalfFSBB=9;
+      LimitFSBB=18;
+      return 1;
+    case 3:
+      Limit32=5;
+      LimitHalfFSBB=6;
+      LimitFSBB=7;
+      return 1;
+    case 4:
+      Limit32=4;
+      LimitHalfFSBB=5;
+      LimitFSBB=6;
+      return 1;
+    case 99:
+      Limit32=(Int_t)180/DataSizePerWindowInRow;
+      LimitHalfFSBB=(Int_t)360/DataSizePerWindowInRow;
+      LimitFSBB=(Int_t)570/DataSizePerWindowInRow;
+      return 1;
+    default:
+      return 0;
+  }
+}
+
+void ScanDigitsSuze02_v15(Int_t Cycle=0, Int_t CollectMode=0, Bool_t ProcessOnlyModulesWithSignal=0, Bool_t AddQED=0, Int_t nEvents=-1, Int_t NRowsEncodingWindow=4,  Int_t NColsEncodingWindow=5, Int_t SuzeLimitsVersion=99, Bool_t SaveResults=kTRUE){ 
+//CollectMode - defines which digits are added to SUZE matrix (-1 - Noise, +1 - Signal, 0 - Noise+Signal)
+//ProcessOnlyModulesWithSignal - defines if only modules with signal hits are processed, if 0 all the modules are processed
+  Int_t DataSizePerWindowInRow = 8 + NRowsEncodingWindow*NColsEncodingWindow+TMath::Ceil(TMath::Log2(NRowsEncodingWindow));
+
+  gROOT->SetStyle("Plain");
+  if(nEvents==-1) cout<<"Analysing all events in the run";
+  else cout<<"Analysing first "<<nEvents<<" events of the run";
+  cout<<" (cycle #"<<Cycle<<")";
+  if(CollectMode==-1) cout<<" taking only noise pixels";
+  else if(CollectMode==1) cout<<" taking only signal pixels";
+  cout<<endl;    
+  if(ProcessOnlyModulesWithSignal) cout<<"Only modules with signal hits will be processed";
+  else cout<<"All modules will be processed";
+  cout<<endl;
+  //Int_t debugOn=0; //DEBUG
+  Int_t nWindowsPerFSBBMax=19;
+  Int_t nWindowsPerHalfFSBBMax=12;
+  Int_t nWindowsPer32colsMax=6;
+
+  if(!GetSuzeLimits(DataSizePerWindowInRow,SuzeLimitsVersion,nWindowsPer32colsMax,nWindowsPerHalfFSBBMax,nWindowsPerFSBBMax)){
+   cout<<"Wrong suze limits version!"<<endl;
+   return;
+  }
+  else{
+    cout<<"Suze will use the follwing limits:"<<endl;
+    cout<<nWindowsPer32colsMax<<" windows per 32 columns,"<<endl;
+    cout<<nWindowsPerHalfFSBBMax<< " windows per half FSBB,"<<endl;
+    cout<<nWindowsPerFSBBMax<<" windows per FSBB"<<endl;
+  }
+
+  Int_t nWindowsPerFSBBMin=nWindowsPerFSBBMax;
+  Int_t nWindowsPerHalfFSBBMin=nWindowsPerHalfFSBBMax;
+  Int_t nWindowsPer32colsMin=nWindowsPer32colsMax;
+
+  Char_t logfile_name[100];
+  sprintf(logfile_name,"ScanDigits_v15_log_Cycle_%d_nEvents_%d_EncWindow_%dx%d_SuzeLimitsVersion_%d_Mode_%d-%d_QED_%d.log",Cycle,nEvents,NRowsEncodingWindow,NColsEncodingWindow,SuzeLimitsVersion,CollectMode,ProcessOnlyModulesWithSignal,AddQED);
+  FILE *logfile = fopen (logfile_name,"w");
+
+  gAlice=NULL;
+  AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
+  
+  runLoader->LoadgAlice();
+
+  gAlice = runLoader->GetAliRun();
+
+  runLoader->LoadHeader();
+  runLoader->LoadKinematics();
+  runLoader->LoadSDigits();
+  runLoader->LoadDigits();
+
+  AliGeomManager::LoadGeometry("geometry.root");
+  AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE,kTRUE);
+  //
+  Int_t nLayers = gm->GetNLayers();
+  Int_t nModules = gm->GetNModules();
+
+  AliLoader *dl = runLoader->GetDetectorLoader("ITS");
+
+  //DIGITS INIT
+  TTree * digTree = 0x0; 
+  TClonesArray *digArr = new TClonesArray("AliITSUDigitPix"); 
+  
+  TTree * digTreeQED = 0x0;
+  TClonesArray *digArrQED = new TClonesArray("AliITSUDigitPix");
+  TDirectoryFile* EventDirectoryQED = 0x0;
+  TFile* DigitsFileQED = 0x0;
+  
+  if(AddQED) {
+      
+    DigitsFileQED = new TFile("QED/ITS.Digits.root");
+    
+  }
+  if(nEvents==-1) nEvents=runLoader->GetNumberOfEvents();
+  printf("N Events : %i \n",nEvents);
+
+  //Module sizes
+  Int_t Module_Ncols=1362;
+  Int_t Module_Nrows_small=320;
+  Int_t Module_Nrows_big=640;
+  Int_t ColAddress=0;
+  Int_t RowAddress=0;
+
+  Int_t DataSize=0;
+  //Int_t ModuleSum=0;
+
+  TH1F* OverflowCodesPerModule = new TH1F("OverflowCodesPerModule","OverflowCodesPerModule",8,0,8);
+  TH1F* OverflowCodes = new TH1F("OverflowCodes","Overflow codes",8,0,8);
+  TH1F* OverflowCodesPerLayer[nLayers];
+
+  TH1F* nDigitsPerEncodingWindowPerModule = new TH1F("nDigitsPerEncodingWindowPerModule","nDigitsPerEncodingWindowPerModule",NRowsEncodingWindow*NColsEncodingWindow,1,NRowsEncodingWindow*NColsEncodingWindow+1);
+  TH1F* nDigitsPerEncodingWindow = new TH1F("nDigitsPerEncodingWindow","nDigitsPerEncodingWindow",NRowsEncodingWindow*NColsEncodingWindow,1,NRowsEncodingWindow*NColsEncodingWindow+1);
+  TH1F* nDigitsPerEncodingWindowPerLayer[nLayers];
+
+  Int_t nDigitsLostPerModule=0;
+  Int_t nDigitsEncodedPerModule=0;
+  Int_t nDigitsLostPerEvent=0;
+  Int_t nDigitsPerEvent=0;
+  Double_t FractionDigitsLostPerEvent=0;
+
+  Int_t nDigitsLostPerEventPerLayer[nLayers];
+  Int_t nDigitsPerEventPerLayer[nLayers];
+  Double_t FractionDigitsLostPerEventPerLayer[nLayers];
+  Int_t MaxNWindowsPerLadderPerLayerPerEvent[nLayers];
+
+  TH1I* NtracksPerEvent_hist = new TH1I("NtracksPerEvent","Ntracks per event",nEvents,0,nEvents);
+  TH1I* NdigitsPerEvent_hist = new TH1I("NdigitsPerEvent","Ndigits per event",nEvents,0,nEvents);
+  TH1I* NdigitsPerEventPerLayer_hist[nLayers];
+
+  TH1I* nDigitsLostPerEvent_hist = new TH1I("nDigitsLostPerEvent","Digits lost per event",nEvents,0,nEvents);
+
+  TH1D* FractionDigitsLostPerEvent_hist = new TH1D("FractionDigitsLostPerEvent","Fraction of Digits lost per event",nEvents,0,nEvents);
+  TH1D* FractionDigitsLostPerEventPerLayer_hist[nLayers];
+
+  TH1I* MaxNWindowsPerLadderPerLayerPerEvent_hist[nLayers];
+
+  Int_t nWindows=0;
+
+  //complete maps
+  TH2I* nDigitsPerModulePerEvent = new TH2I("nDigitsPerModulePerEvent","nDigits per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2I* nDigitsEncodedPerModulePerEvent = new TH2I("nDigitsEncodedPerModulePerEvent","nDigits encoded per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2I* nDigitsLostPerModulePerEvent = new TH2I("nDigitsLostPerModulePerEvent","nDigits lost per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2F* FractionDigitsLostPerModulePerEvent = new TH2F("FractionDigitsLostPerModulePerEvent","Fraction of digits lost per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2I* nEncodingWindowsPerModulePerEvent = new TH2I("nEncodingWindowsPerModulePerEvent","Encoding windows per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2F* nDigitsPerEncodingWindowPerModulePerEvent = new TH2F("nDigitsPerEncodingWindowPerModulePerEvent","Average digits per encoding window per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+
+  TH2I* nWindowsPerFSBBMinPerModulePerEvent = new TH2I("nWindowsPerFSBBMinPerModulePerEvent","nWindowsPerFSBBMin per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2I* nWindowsPerHalfFSBBMinPerModulePerEvent = new TH2I("nWindowsPerHalfFSBBMinPerModulePerEvent","nWindowsPerHalfFSBBMin per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+  TH2I* nWindowsPer32colsMinPerModulePerEvent = new TH2I("nWindowsPer32colsMinPerModulePerEvent","nWindowsPer32colsMin per Module per Event",nModules,0,nModules,nEvents,0,nEvents);
+
+  TH2F* DataSizePerModulePerEvent = new TH2F("DataSizePerModulePerEvent","DataSizePerModulePerEvent",nModules,0,nModules,nEvents,0,nEvents);
+
+  Int_t current_ladder=-1;
+  Int_t current_layer=-1;
+  Double_t NWindowsPerLadder=0;
+
+  for(Int_t i=0; i<nLayers; i++){
+    nDigitsLostPerEventPerLayer[i]=0;
+    nDigitsPerEventPerLayer[i]=0;
+    FractionDigitsLostPerEventPerLayer[i]=0;
+
+    NdigitsPerEventPerLayer_hist[i] = new TH1I(Form("NdigitsPerEventPerLayer_%d",i),Form("Ndigits at layer %d",i),nEvents,0,nEvents);
+    FractionDigitsLostPerEventPerLayer_hist[i] = new TH1D(Form("FractionDigitsLostPerEventPerLayer_%d",i),Form("Fraction of digits lost per event at layer %d",i),nEvents,0,nEvents);
+
+    MaxNWindowsPerLadderPerLayerPerEvent[i]=0;
+    MaxNWindowsPerLadderPerLayerPerEvent_hist[i] = new TH1I(Form("MaxNWindowsPerLadderPerLayerPerEvent_%d",i),Form("Max number of windows per ladder per event at layer %d",i),nEvents,0,nEvents);
+
+    OverflowCodesPerLayer[i] = new TH1F(Form("OverflowCodesPerLayer_%d",i),Form("Overflow codes at layer %d",i),8,0,8);
+    nDigitsPerEncodingWindowPerLayer[i] = new TH1F(Form("nDigitsPerEncodingWindowPerLayer_%d",i),Form("nDigitsPerEncodingWindowPerLayer_%d",i),NRowsEncodingWindow*NColsEncodingWindow,1,NRowsEncodingWindow*NColsEncodingWindow+1);
+  }
+
+  Int_t NtracksKine=0;
+  for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
+  //for (Int_t iEvent = 7; iEvent < nEvents; iEvent++) {    //!!!DEBUG
+    printf("\n Event %i \n",iEvent);
+    runLoader->GetEvent(iEvent);
+    AliStack *stack = runLoader->Stack();
+    NtracksKine=stack->TreeK()->GetEntries();
+    digTree=dl->TreeD(); 
+    
+    //manually load digits tree for QED
+    if(AddQED){
+      EventDirectoryQED=(TDirectoryFile*)DigitsFileQED->Get(Form("Event%d",iEvent));          
+      digTreeQED=(TTree*)EventDirectoryQED->Get("TreeD"); 
+      digTreeQED->SetBranchAddress("ITSDigitsPix",&digArrQED);
+    }
+    //
+    digTree->SetBranchAddress("ITSDigitsPix",&digArr);
+    nDigitsLostPerEvent=0;
+    nDigitsPerEvent=0;
+    for(Int_t i=0; i<nLayers; i++){
+      nDigitsPerEventPerLayer[i]=0;
+      nDigitsLostPerEventPerLayer[i]=0;
+      MaxNWindowsPerLadderPerLayerPerEvent[i]=0;
+    }
+    current_ladder=-1;
+    current_layer=-1;
+    NWindowsPerLadder=0;
+    
+    Int_t ndigQED=0;
+    
+    for (Int_t imod=0;imod<nModules;imod++) {
+      AliITSUSuze02* Module;
+      nDigitsLostPerModule=0;
+      nDigitsEncodedPerModule=0;
+      digTree->GetEntry(imod); 
+      
+      if(AddQED){
+        digTreeQED->GetEntry(imod);
+        ndigQED = digArrQED->GetEntries();
+      }
+      //Int_t detType = gm->GetModuleDetTypeID(imod);
+      //AliITSUSegmentationPix* segm = (AliITSUSegmentationPix*)gm->GetSegmentationByID(detType);
+      Int_t lay,lad,det;
+      Int_t ndig  = digArr->GetEntries();
+      
+      Int_t ndig_in_cycle=0; 
+      Int_t ndig_signal_in_cycle=0;
+      if (ndig<1) continue;
+      gm->GetModuleId(imod, lay,lad,det);
+//       printf("\nModule %3d: (det %2d in ladder %2d of Layer %d) | NDigits: %4d\n",imod,det,lad,lay,ndig);
+      //    
+      //if(iEvent==7 && lay==2) cout<<"Module #"<<imod<<endl;     //!!!DEBUG   
+      //if(iEvent==7 && lay==2 && imod==363) debugOn=1; //continue;  //!!!DEBUG
+      //else debugOn=0; 
+      if(lay>=0 && lay <=2){
+        Module = new AliITSUSuze02(Module_Nrows_small,Module_Ncols);
+      }
+      else{
+        Module = new AliITSUSuze02(Module_Nrows_big,Module_Ncols);
+      }
+      
+      Module->SetEncodingWindowSize(NRowsEncodingWindow,NColsEncodingWindow);
+      Module->SetQuotas(nWindowsPer32colsMax,nWindowsPerHalfFSBBMax,nWindowsPerFSBBMax);
+      
+      OverflowCodesPerModule->Reset();
+      nDigitsPerEncodingWindowPerModule->Reset();
+
+      nWindows=0;
+      for(Int_t idig=0;idig<ndig;idig++) {
+        AliITSUDigitPix *pDig = (AliITSUDigitPix*)digArr->At(idig);
+        if(pDig->GetROCycle()!=Cycle) continue; //selection of the hits from a given RO cycle
+        if((CollectMode==-1 && pDig->GetHit(0)!=-1) || (CollectMode==1 && pDig->GetHit(0)==-1)) continue; // selection between noise and signal or both
+        ndig_in_cycle++; 
+        if(pDig->GetHit(0)!=-1) ndig_signal_in_cycle++;  //counts signal hits in a given RO cycle
+        ColAddress=pDig->GetCoord1();
+        RowAddress=pDig->GetCoord2();
+        Module->AddDigit(RowAddress,ColAddress);
+      }//diglist  
+      
+      if(AddQED){
+        for(Int_t idig=0;idig<ndigQED;idig++) {
+          AliITSUDigitPix *pDig = (AliITSUDigitPix*)digArrQED->At(idig);
+          if(pDig->GetROCycle()!=Cycle) continue; //selection of the hits from a given RO cycle
+          ndig_in_cycle++; 
+          ColAddress=pDig->GetCoord1();
+          RowAddress=pDig->GetCoord2();
+          Module->AddDigit(RowAddress,ColAddress);
+        }//diglist
+      }
+      
+      if(ndig_in_cycle<1){  
+        delete Module; 
+        continue; //rejects when no hits in a given cycle
+      }
+      nDigitsPerEvent+=ndig_in_cycle;
+      nDigitsPerEventPerLayer[lay]+=ndig_in_cycle;
+      if(ProcessOnlyModulesWithSignal){       //if ProcessOnlyModulesWithSignal==1
+        if(ndig_signal_in_cycle<1){   
+          delete Module;
+          continue;  //rejects when only noise is the present
+        }
+      }
+      
+      Module->Process(OverflowCodesPerModule,nDigitsPerEncodingWindowPerModule);
+      DataSize=Module->GetDataSize();
+      nDigitsEncodedPerModule=Module->GetNDigitsEncoded();
+      nDigitsLostPerModule=Module->GetNDigitsLost();
+      nWindows=Module->GetNEncodedWindows();                           
+      nWindowsPer32colsMin=Module->GetNWindowsPer32colsMin();
+      nWindowsPerHalfFSBBMin=Module->GetNWindowsPerHalfFSBBMin();
+      nWindowsPerFSBBMin=Module->GetNWindowsPerFSBBMin();
+      
+     //DataSize=MakeSuze(Module_matrix,OverflowCodesPerModule,nDigitsEncodedPerModule,nDigitsLostPerModule,nWindows,nWindowsPer32colsMax,nWindowsPerHalfFSBBMax,nWindowsPerFSBBMax,nWindowsPer32colsMin,nWindowsPerHalfFSBBMin,nWindowsPerFSBBMin,nDigitsPerEncodingWindowPerModule);
+//       cout<<"SUZE encoded "<<SuzeReturn<<" digits in "<<nWindows<<" windows"<<endl;
+      OverflowCodes->Add(OverflowCodesPerModule);
+      OverflowCodesPerLayer[lay]->Add(OverflowCodesPerModule);
+
+      nDigitsPerEncodingWindow->Add(nDigitsPerEncodingWindowPerModule);
+      nDigitsPerEncodingWindowPerLayer[lay]->Add(nDigitsPerEncodingWindowPerModule);
+
+//       if(nDigitsLostPerModule){
+//         cout<<"------- Some digits were lost. Check overflow errors"<<endl;
+//         cout<<"Module has "<<ModuleSum<<" digits"<<endl;
+//         cout<<"SUZE reported "<<SuzeReturn<<" encoded and "<<nDigitsLost<<" lost digits"<<endl;
+//         cout<<"Module n."<<imod<<" has lost "<<nDigitsLostPerModule<<" digits due to the overflow"<<endl;
+
+//       }
+      if(nDigitsLostPerModule){
+             printf("Event #%d mod. #%d (layer %d) has %d digits lost\n",iEvent,imod,lay,nDigitsLostPerModule);
+             fprintf(logfile,"Event #%d mod. #%d (layer %d) has %d (%f) digits lost\n",iEvent,imod,lay,nDigitsLostPerModule, (Float_t)nDigitsLostPerModule/ndig_in_cycle);
+      }
+      nDigitsLostPerEvent+=nDigitsLostPerModule;
+      nDigitsLostPerEventPerLayer[lay]+=nDigitsLostPerModule;
+//       cout<<"Lay:"<<lay<<" Lad:"<<lad<<" current_ladder:"<<current_ladder<<" current layer:"<<current_layer<<" Digits:"<<SuzeReturn<<endl;
+      if(lay!=current_layer){
+        cout<<"Layer #"<<lay<<endl;
+      }
+      if(lad!=current_ladder || lay!=current_layer){
+        current_ladder=lad;
+             current_layer=lay;
+             NWindowsPerLadder=0;
+      }
+      NWindowsPerLadder+=nWindows;
+      if(NWindowsPerLadder>MaxNWindowsPerLadderPerLayerPerEvent[current_layer]){
+             MaxNWindowsPerLadderPerLayerPerEvent[current_layer]=NWindowsPerLadder;
+//     cout<<"---- MaxNWindowsPerLadderPerLayerPerEvent:"<<MaxNWindowsPerLadderPerLayerPerEvent[current_layer]<<" at layer:"<<current_layer<<endl;
+      }
+      nDigitsPerModulePerEvent->SetBinContent(imod+1,iEvent+1,ndig_in_cycle);
+      nDigitsEncodedPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nDigitsEncodedPerModule);
+      nDigitsLostPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nDigitsLostPerModule);
+      FractionDigitsLostPerModulePerEvent->SetBinContent(imod+1,iEvent+1,(Double_t)nDigitsLostPerModule/ndig_in_cycle);
+      nEncodingWindowsPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nWindows);
+      nDigitsPerEncodingWindowPerModulePerEvent->SetBinContent(imod+1,iEvent+1,(Double_t)nDigitsEncodedPerModule/nWindows); 
+
+      nWindowsPerFSBBMinPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nWindowsPerFSBBMax-nWindowsPerFSBBMin);
+      nWindowsPerHalfFSBBMinPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nWindowsPerHalfFSBBMax-nWindowsPerHalfFSBBMin);
+      nWindowsPer32colsMinPerModulePerEvent->SetBinContent(imod+1,iEvent+1,nWindowsPer32colsMax-nWindowsPer32colsMin);
+
+      DataSizePerModulePerEvent->SetBinContent(imod+1,iEvent+1,DataSize);   
+      
+      delete Module;
+//      break;
+    }//mod
+    NtracksPerEvent_hist->SetBinContent(iEvent+1,NtracksKine);
+    NdigitsPerEvent_hist->SetBinContent(iEvent+1,nDigitsPerEvent);
+    for(Int_t i=0; i<nLayers; i++){
+      NdigitsPerEventPerLayer_hist[i]->SetBinContent(iEvent+1,nDigitsPerEventPerLayer[i]);
+    }
+
+    nDigitsLostPerEvent_hist->SetBinContent(iEvent+1,nDigitsLostPerEvent);
+
+    if(nDigitsPerEvent){
+      FractionDigitsLostPerEvent=(Double_t)nDigitsLostPerEvent/nDigitsPerEvent;
+      if(FractionDigitsLostPerEvent) cout<<"Fraction lost = "<<FractionDigitsLostPerEvent<<endl;
+      FractionDigitsLostPerEvent_hist->SetBinContent(iEvent+1,FractionDigitsLostPerEvent);
+      for(Int_t i=0; i<nLayers; i++){
+        if(nDigitsPerEventPerLayer[i]){
+          FractionDigitsLostPerEventPerLayer[i]=(Double_t)nDigitsLostPerEventPerLayer[i]/nDigitsPerEventPerLayer[i];
+          if(FractionDigitsLostPerEventPerLayer[i]) cout<<"Fraction lost at layer:"<<i<<" is "<<FractionDigitsLostPerEventPerLayer[i]<<endl;
+          FractionDigitsLostPerEventPerLayer_hist[i]->SetBinContent(iEvent+1,FractionDigitsLostPerEventPerLayer[i]);
+        }
+      }
+    }
+    for(Int_t i=0; i<nLayers; i++){
+      MaxNWindowsPerLadderPerLayerPerEvent_hist[i]->SetBinContent(iEvent+1,MaxNWindowsPerLadderPerLayerPerEvent[i]);
+    }
+//     break;
+  }//event loop
+//   TCanvas* c1=new TCanvas();
+//   c1->SetLogy();
+//   OverflowCodes->DrawNormalized();
+//   new TCanvas();
+//   nMultipleEncodingsPerEvent_hist->Draw();
+//   new TCanvas();
+//   nDigitsLostPerEvent_hist->Draw();
+
+  TFile* ResultsFile;
+  Char_t ResultsFileName[100];
+  if(SaveResults){
+    sprintf(ResultsFileName,"ScanDigits_v15_results_cycle_%d_EncWindow_%dx%d_SuzeLimitsVersion_%d_mode_%d-%d_QED_%d.root",Cycle,NRowsEncodingWindow,NColsEncodingWindow,SuzeLimitsVersion,CollectMode,ProcessOnlyModulesWithSignal,AddQED);
+    ResultsFile = new TFile(ResultsFileName,"RECREATE");
+
+    OverflowCodes->Write();
+    nDigitsPerEncodingWindow->Write();
+
+    NtracksPerEvent_hist->Write();
+    NdigitsPerEvent_hist->Write();
+
+    nDigitsLostPerEvent_hist->Write();
+
+    FractionDigitsLostPerEvent_hist->Write();
+
+    for(Int_t i=0; i<nLayers; i++){
+      NdigitsPerEventPerLayer_hist[i]->Write();
+      FractionDigitsLostPerEventPerLayer_hist[i]->Write();
+
+      MaxNWindowsPerLadderPerLayerPerEvent_hist[i]->Write();
+
+      OverflowCodesPerLayer[i]->Write();
+      nDigitsPerEncodingWindowPerLayer[i]->Write();
+    }
+
+    nDigitsPerModulePerEvent->Write();
+    nDigitsEncodedPerModulePerEvent->Write();
+    nDigitsLostPerModulePerEvent->Write();
+    FractionDigitsLostPerModulePerEvent->Write();
+    nEncodingWindowsPerModulePerEvent->Write();
+    nDigitsPerEncodingWindowPerModulePerEvent->Write();
+
+    nWindowsPerFSBBMinPerModulePerEvent->Write();
+    nWindowsPerHalfFSBBMinPerModulePerEvent->Write();
+    nWindowsPer32colsMinPerModulePerEvent->Write();
+
+    DataSizePerModulePerEvent->Write();
+
+    ResultsFile->Close();
+  }
+  fclose (logfile);
+//   cout<<"Multiple Encodings:"<<nMultipleEncodings<<endl;
+//   cout<<"Lost digits:"<<nDigitsLostTotal<<endl;
+
+}
diff --git a/ITS/UPGRADE/testITSUv1/Config.C b/ITS/UPGRADE/testITSUv1/Config.C
new file mode 100644 (file)
index 0000000..12b0dff
--- /dev/null
@@ -0,0 +1,456 @@
+/// One can use the configuration macro in compiled mode by
+// root [0] gSystem->Load("libgeant321");
+// root [0] gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include\
+//                   -I$ALICE_ROOT -I$ALICE/geant3/TGeant3");
+// root [0] .x grun.C(1,"Config.C++"
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <Riostream.h>
+#include <TPDGCode.h>
+#include <TRandom.h>
+#include <TSystem.h>
+#include <TVirtualMC.h>
+#include <TGeant3TGeo.h>
+#include "STEER/AliRunLoader.h"
+#include "STEER/AliRun.h"
+#include "STEER/AliConfig.h"
+#include "PYTHIA6/AliDecayerPythia.h"
+#include "EVGEN/AliGenCocktail.h"
+#include "EVGEN/AliGenHIJINGpara.h"
+#include "EVGEN/AliGenFixed.h"
+#include "EVGEN/AliGenBox.h"
+#include "STEER/AliMagWrapCheb.h"
+#include "STRUCT/AliBODY.h"
+#include "STRUCT/AliMAG.h"
+#include "STRUCT/AliABSOv3.h"
+#include "STRUCT/AliDIPOv3.h"
+#include "STRUCT/AliHALLv3.h"
+#include "STRUCT/AliFRAMEv2.h"
+#include "STRUCT/AliSHILv3.h"
+#include "STRUCT/AliPIPEv3.h"
+#include "STRUCT/AliPIPEupgrade.h"
+#include "ITS/AliITSv11.h"
+#include "ITS/UPGRADE/AliITSUv1.h"
+#include "TPC/AliTPCv2.h"
+#include "TOF/AliTOFv6T0.h"
+#include "HMPID/AliHMPIDv3.h"
+#include "ZDC/AliZDCv3.h"
+#include "TRD/AliTRDv1.h"
+#include "TRD/AliTRDgeometry.h"
+#include "FMD/AliFMDv1.h"
+#include "MUON/AliMUONv1.h"
+#include "PHOS/AliPHOSv1.h"
+#include "PMD/AliPMDv1.h"
+#include "T0/AliT0v1.h"
+#include "EMCAL/AliEMCALv2.h"
+#include "ACORDE/AliACORDEv1.h"
+#include "VZERO/AliVZEROv7.h"
+#include <TVirtualMagField.h>
+#endif
+
+Int_t generatorFlag = 0;
+
+/* $Id: Config.C 47147 2011-02-07 11:46:44Z amastros $ */
+enum PprTrigConf_t
+{
+  kDefaultPPTrig, kDefaultPbPbTrig
+};
+
+const char * pprTrigConfName[] = {
+  "p-p","Pb-Pb"
+};
+
+
+Float_t EtaToTheta(Float_t arg);
+
+static PprTrigConf_t strig = kDefaultPPTrig;// default PP trigger configuration
+
+void Config()
+{
+  // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
+  // Theta range given through pseudorapidity limits 22/6/2001
+
+  // Set Random Number seed
+  gRandom->SetSeed(1); // Set 0 to use the currecnt time
+
+
+  // libraries required by geant321
+#if defined(__CINT__)
+  gSystem->Load("liblhapdf");
+  gSystem->Load("libEGPythia6");
+  gSystem->Load("libpythia6");
+  gSystem->Load("libAliPythia6");
+  gSystem->Load("libgeant321");
+  gSystem->Load("libhijing");  
+  gSystem->Load("libTHijing");
+#endif
+  gSystem->Load("libITSUpgradeBase.so");
+  gSystem->Load("libITSUpgradeSim.so");
+
+
+  new     TGeant3TGeo("C++ Interface to Geant3");
+
+  AliRunLoader* rl=0x0;
+
+
+  rl = AliRunLoader::Open("galice.root",
+                         AliConfig::GetDefaultEventFolderName(),
+                         "recreate");
+  if (rl == 0x0)
+    {
+      gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
+      return;
+    }
+  rl->SetCompressionLevel(2);
+  rl->SetNumberOfEventsPerFile(2000);
+  gAlice->SetRunLoader(rl);
+
+  // Set the trigger configuration
+  // gAlice->SetTriggerDescriptor(pprTrigConfName[strig]);
+  //cout<<"Trigger configuration is set to  "<<pprTrigConfName[strig]<<endl;
+  AliSimulation::Instance()->SetTriggerConfig(pprTrigConfName[strig]);
+  cout<<"Trigger configuration is set to  pprTrigConfName[strig] "<<endl;
+
+  //
+  // Set External decayer
+  TVirtualMCDecayer *decayer = new AliDecayerPythia();
+
+  decayer->SetForceDecay(kAll);
+  decayer->Init();
+  gMC->SetExternalDecayer(decayer);
+  //=======================================================================
+  // ************* STEERING parameters FOR ALICE SIMULATION **************
+  // --- Specify event type to be tracked through the ALICE setup
+  // --- All positions are in cm, angles in degrees, and P and E in GeV
+
+
+  gMC->SetProcess("DCAY",1);
+  gMC->SetProcess("PAIR",1);
+  gMC->SetProcess("COMP",1);
+  gMC->SetProcess("PHOT",1);
+  gMC->SetProcess("PFIS",0);
+  gMC->SetProcess("DRAY",0);
+  gMC->SetProcess("ANNI",1);
+  gMC->SetProcess("BREM",1);
+  gMC->SetProcess("MUNU",1);
+  gMC->SetProcess("CKOV",1);
+  gMC->SetProcess("HADR",0);
+  gMC->SetProcess("LOSS",2);
+  gMC->SetProcess("MULS",1);
+  gMC->SetProcess("RAYL",1);
+
+  Float_t cut = 1.e-3;        // 1MeV cut by default
+  Float_t tofmax = 1.e10;
+
+  gMC->SetCut("CUTGAM", cut);
+  gMC->SetCut("CUTELE", cut);
+  gMC->SetCut("CUTNEU", cut);
+  gMC->SetCut("CUTHAD", cut);
+  gMC->SetCut("CUTMUO", cut);
+  gMC->SetCut("BCUTE",  cut); 
+  gMC->SetCut("BCUTM",  cut); 
+  gMC->SetCut("DCUTE",  cut); 
+  gMC->SetCut("DCUTM",  cut); 
+  gMC->SetCut("PPCUTM", cut);
+  gMC->SetCut("TOFMAX", tofmax); 
+
+  // Special generation for Valgrind tests
+  // Each detector is fired by few particles selected 
+  // to cover specific cases
+
+
+  // The cocktail itself
+  if (generatorFlag==0) {
+    // Fast generator with parametrized pi,kaon,proton distributions
+    
+    int  nParticles = 100;//14022;
+    AliGenHIJINGpara *gener = new AliGenHIJINGpara(nParticles);
+    gener->SetMomentumRange(0.1, 10.);
+    gener->SetPhiRange(0., 360.);
+    Float_t thmin = EtaToTheta(2.5);   // theta min. <---> eta max
+    Float_t thmax = EtaToTheta(-2.5);  // theta max. <---> eta min
+    gener->SetThetaRange(thmin,thmax);
+    gener->SetOrigin(0, 0, 0);  //vertex position
+    gener->SetSigma(50e-4, 50e-4, 5.0);   //Sigma in (X,Y,Z) (cm) on IP position
+    gener->SetVertexSmear(kPerEvent);
+    gener->Init();
+    
+  }
+  else if (generatorFlag==1) {
+    int  nParticlesHP = 12000;
+    int  nPiPFlat=200;
+    int  nPiMFlat=200;
+
+    AliGenCocktail *cocktail = new AliGenCocktail();
+    cocktail->SetProjectile("A", 208, 82);
+    cocktail->SetTarget    ("A", 208, 82);
+    Float_t thmin = EtaToTheta( 2.5);   // theta min. <---> eta max
+    Float_t thmax = EtaToTheta(-2.5);  // theta max. <---> eta min 
+    cocktail->SetThetaRange(thmin,thmax);
+    cocktail->SetEnergyCMS(5500);
+    cocktail->SetOrigin(0, 0, 0);  //vertex position
+    cocktail->SetSigma(50e-4, 50e-4, 5.0);   //Sigma in (X,Y,Z) (cm) on IP position
+    cocktail->SetVertexSmear(kPerEvent);
+    cocktail->Init();  
+
+    // HijingParam + flat pion spectrum
+    
+    AliGenHIJINGpara *generH = new AliGenHIJINGpara(nParticlesHP);
+    generH->SetMomentumRange(0.1, 10.);
+    generH->SetPhiRange(0., 360.);
+    generH->SetThetaRange(thmin,thmax);
+    generH->SetOrigin(0, 0, 0);  //vertex position
+    generH->SetSigma(0, 0, 0);   //Sigma in (X,Y,Z) (cm) on IP position
+    //    generH->Init();
+    //
+    cocktail->AddGenerator(generH,"hijingParam",1);
+    //
+    AliGenBox *gpipflat = new AliGenBox(nPiPFlat);
+    gpipflat->SetMomentumRange(0,10.);
+    gpipflat->SetPhiRange(0., 360.);
+    gpipflat->SetThetaRange(thmin,thmax);
+    gpipflat->SetPart(kPiPlus);
+    cocktail->AddGenerator(gpipflat,"genPiPlus",1);
+    //
+    //
+    AliGenBox *gpimflat = new AliGenBox(nPiMFlat);
+    gpimflat->SetMomentumRange(0,10.);
+    gpimflat->SetPhiRange(0., 360.);
+    gpimflat->SetThetaRange(thmin,thmax);
+    gpimflat->SetPart(kPiMinus);
+    cocktail->AddGenerator(gpimflat,"genPimus",1);
+    //
+    cocktail->Init();
+  }
+  else if (generatorFlag==2) {
+    
+    // Pure HiJing generator adapted to ~2000dNdy at highest energy
+    
+    AliGenHijing *generHijing = new AliGenHijing(-1);
+    generHijing->SetEnergyCMS(5500.); // GeV
+    generHijing->SetImpactParameterRange(0,2);
+    generHijing->SetReferenceFrame("CMS");
+    generHijing->SetProjectile("A", 208, 82);
+    generHijing->SetTarget    ("A", 208, 82);
+    generHijing->KeepFullEvent();
+    generHijing->SetJetQuenching(1);
+    generHijing->SetShadowing(1);
+    generHijing->SetSpectators(0);
+    generHijing->SetSelectAll(0);
+    generHijing->SetPtHardMin(4.5);
+    
+    AliGenerator*  gener = generHijing;
+    gener->SetSigma(50e-4, 50e-4, 5.0);   //Sigma in (X,Y,Z) (cm) on IP position
+    gener->SetVertexSmear(kPerEvent);
+    gener->Init();
+      
+  }
+  // 
+  
+
+  // 
+  // Activate this line if you want the vertex smearing to happen
+  // track by track
+  //
+  //VertexSmear_t perTrack;
+  //gener->SetVertexSmear(perTrack); 
+  // Field (L3 0.5 T)
+  //AliMagF* field = new AliMagF("map","map",2, -1.,1., 15, AliMagF::k5kGUniform);
+  //TGeoGlobalMagField::Instance()->SetField(field);
+  TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG));
+
+  Int_t   iABSO  =  0;
+  Int_t   iDIPO  =  0;
+  Int_t   iFMD   =  0;
+  Int_t   iFRAME =  0;
+  Int_t   iHALL  =  0;
+  Int_t   iITS   =  1;
+  Int_t   iMAG   =  0;
+  Int_t   iMUON  =  0;
+  Int_t   iPHOS  =  0;
+  Int_t   iPIPE  =  0;
+  Int_t   iPMD   =  0;
+  Int_t   iHMPID =  0;
+  Int_t   iSHIL  =  0;
+  Int_t   iT0    =  0;
+  Int_t   iTOF   =  0;
+  Int_t   iTPC   =  0;
+  Int_t   iTRD   =  0;
+  Int_t   iZDC   =  0;
+  Int_t   iEMCAL =  0;
+  Int_t   iACORDE=  0;
+  Int_t   iVZERO =  0;
+  rl->CdGAFile();
+  //=================== Alice BODY parameters =============================
+  AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
+
+  if (iMAG)
+    {
+      //=================== MAG parameters ============================
+      // --- Start with Magnet since detector layouts may be depending ---
+      // --- on the selected Magnet dimensions ---
+      AliMAG *MAG = new AliMAG("MAG", "Magnet");
+    }
+
+
+  if (iABSO)
+    {
+      //=================== ABSO parameters ============================
+      AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
+    }
+
+  if (iDIPO)
+    {
+      //=================== DIPO parameters ============================
+
+      AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
+    }
+
+  if (iHALL)
+    {
+      //=================== HALL parameters ============================
+
+      AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
+    }
+
+
+  if (iFRAME)
+    {
+      //=================== FRAME parameters ============================
+
+      AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
+      FRAME->SetHoles(1);
+    }
+
+  if (iSHIL)
+    {
+      //=================== SHIL parameters ============================
+
+      AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
+    }
+
+
+  if (iPIPE)
+    {
+      //=================== PIPE parameters ============================
+
+      AliPIPE *PIPE = new AliPIPEupgrade("PIPE", "Beam Pipe",0,1.8,0.08,40.0);
+      //AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
+    }
+  if (iITS)
+    {
+      //=================== ITS parameters ============================
+//      gROOT->ProcessLine(".x CreateITSU.C");
+      gROOT->ProcessLine(".x CreateITSUv1.C");
+//      gROOT->ProcessLine(".x CreateITSUv0.C");
+//      gROOT->ProcessLine(".x CreateITSU_MS.C");
+      //    CreateITSU();
+
+    }
+  if (iTPC)
+    {
+      //============================ TPC parameters ===================
+      AliTPC *TPC = new AliTPCv2("TPC", "Default");
+    }
+
+
+  if (iTOF) {
+    //=================== TOF parameters ============================
+    AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
+  }
+
+
+  if (iHMPID)
+    {
+      //=================== HMPID parameters ===========================
+      AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
+
+    }
+
+
+  if (iZDC)
+    {
+      //=================== ZDC parameters ============================
+
+      AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
+    }
+
+  if (iTRD)
+    {
+      //=================== TRD parameters ============================
+
+      AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
+      AliTRDgeometry *geoTRD = TRD->GetGeometry();
+      // Partial geometry: modules at 2,3,4,6,11,12,14,15
+      // starting at 6h in positive direction
+      geoTRD->SetSMstatus(0,0);
+      geoTRD->SetSMstatus(1,0);
+      geoTRD->SetSMstatus(5,0);
+      geoTRD->SetSMstatus(7,0);
+      geoTRD->SetSMstatus(8,0);
+      geoTRD->SetSMstatus(9,0);
+      geoTRD->SetSMstatus(10,0);
+      geoTRD->SetSMstatus(13,0);
+      geoTRD->SetSMstatus(16,0);
+      geoTRD->SetSMstatus(17,0);
+    }
+
+  if (iFMD)
+    {
+      //=================== FMD parameters ============================
+      AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
+    }
+
+  if (iMUON)
+    {
+      //=================== MUON parameters ===========================
+      // New MUONv1 version (geometry defined via builders)
+      AliMUON *MUON = new AliMUONv1("MUON","default");
+    }
+  //=================== PHOS parameters ===========================
+
+  if (iPHOS)
+    {
+      AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
+    }
+
+
+  if (iPMD)
+    {
+      //=================== PMD parameters ============================
+      AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
+    }
+
+  if (iT0)
+    {
+      //=================== T0 parameters ============================
+      AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
+    }
+
+  if (iEMCAL)
+    {
+      //=================== EMCAL parameters ============================
+      AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETEV1");
+    }
+
+  if (iACORDE)
+    {
+      //=================== ACORDE parameters ============================
+      AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
+    }
+
+  if (iVZERO)
+    {
+      //=================== VZERO parameters ============================
+      AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
+    }
+
+
+}
+
+Float_t EtaToTheta(Float_t arg){
+  return (180./TMath::Pi())*2.*atan(exp(-arg));
+}
+
diff --git a/ITS/UPGRADE/testITSUv1/CreateITSUv0.C b/ITS/UPGRADE/testITSUv1/CreateITSUv0.C
new file mode 100644 (file)
index 0000000..eb4689f
--- /dev/null
@@ -0,0 +1,158 @@
+#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 CreateITSUv0()
+{
+  //
+  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;
+  const int kBuildLevel = 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.  , 49},  // for others: -, rMid, -, NMod/Stave, phi0, nStave
+    {-1,   24.7, -1,    28., 0.  , 61},
+    {-1,   35.32,-1,    49., 0.  , 88},
+    {-1,   40.52,-1,    49., 0.  , 100}
+  };
+
+  // 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());
+  //
+  AliITSUSegmentationPix* seg1 = new AliITSUSegmentationPix(1,        // segID (0:9)
+                                                           kNChips,  // chips per module
+                                                           kNChips*kNCol,    // ncols (total for module)
+                                                           2*kNRow,    // nrows for oute layers
+                                                           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
+                                                           kReadOutEdge, // top   !!! readout from both sides
+                                                           kReadOutEdge  // bottom
+                                                           );    // see AliITSUSegmentationPix.h for extra options
+  seg1->Store(AliITSUGeomTGeo::GetITSsegmentationFileName());
+  //
+  seg0->Print();
+  seg1->Print();
+  //
+  const double kMinOvl = 0.005; // 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);
+  AliITSUv1 *ITS  = new AliITSUv1("ITS Upgrade",7);
+  ITS->SetStaveModelIB(AliITSUv1::kIBModel22);
+  ITS->SetStaveModelOB(AliITSUv1::kOBModel0);
+  //
+  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   = seg1;
+      turbo = kTilt;
+      thick = kLrThick08;
+    }
+    nStaveLr = TMath::Nint(tdr5dat[idLr][kNStave]);
+    if (nStaveLr<0) 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;
+}
diff --git a/ITS/UPGRADE/testITSUv1/CreateITSUv1.C b/ITS/UPGRADE/testITSUv1/CreateITSUv1.C
new file mode 100644 (file)
index 0000000..06950e5
--- /dev/null
@@ -0,0 +1,168 @@
+#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 CreateITSUv1()
+{
+  //
+  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;
+  const int kBuildLevel = 3;
+  enum {kRmn,kRmd,kRmx,kNModPerStave,kPhi0,kNStave,kNPar};
+  // Radii are from last TDR (ALICE-TDR-017.pdf Tab. 1.1, rMid is mean value)
+  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.6 ,   -1,  4.,  0.  , 24},  // for others: -, rMid, -, NMod/Stave, phi0, nStave // 24 was 49
+    {-1,  24.55, -1,    4.,  0.  , 30},  // 30 was 61
+    {-1,  34.39, -1,    7.,  0.  , 42},  // 42 was 88
+    {-1,  39.34, -1,    7.,  0.  , 48}   // 48 was 100
+  };
+  const int nChipsPerModule = 7; // For OB we have to specify how many chips
+
+  // 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());
+  //
+  AliITSUSegmentationPix* seg1 = new AliITSUSegmentationPix(1,        // segID (0:9)
+                                                           kNChips,  // chips per module
+                                                           kNChips*kNCol,    // ncols (total for module)
+                                                           2*kNRow,    // nrows for oute layers
+                                                           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
+                                                           kReadOutEdge, // top   !!! readout from both sides
+                                                           kReadOutEdge  // bottom
+                                                           );    // see AliITSUSegmentationPix.h for extra options
+  seg1->Store(AliITSUGeomTGeo::GetITSsegmentationFileName());
+  //
+  seg0->Print();
+  seg1->Print();
+  //
+  const double kMinOvl = 0.005; // 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);
+  AliITSUv1 *ITS  = new AliITSUv1("ITS Upgrade",7);
+  ITS->SetStaveModelIB(AliITSUv1::kIBModel22);
+  ITS->SetStaveModelOB(AliITSUv1::kOBModel1);
+  //
+  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, 96.0, 158.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   = seg1;
+      turbo = kTilt;
+      thick = kLrThick08;
+    }
+    nStaveLr = TMath::Nint(tdr5dat[idLr][kNStave]);
+    if (nStaveLr<0) nStaveLr = getNStaves(seg,kTilt,rLr,kMinOvl); // calculate automatically
+    nModPerStaveLr =  TMath::Nint(tdr5dat[idLr][kNModPerStave]);
+    int nChipsPerStaveLr = nModPerStaveLr;
+    if (idLr>=kNLrInner) {
+      nChipsPerStaveLr *= nChipsPerModule;
+      ITS->DefineLayer(idLr, phi0, rLr, nChipsPerStaveLr*seg->Dz(), nStaveLr, nModPerStaveLr, 
+                      thick, seg->Dy(), seg->GetDetTypeID(),kBuildLevel);
+      printf("Add Lr%d: R=%6.2f DZ:%6.2f Staves:%3d NMod/Stave:%3d\n",idLr,rLr,nChipsPerStaveLr*seg->Dz(),nStaveLr,nModPerStaveLr);
+    } else {
+      ITS->DefineLayerTurbo(idLr, phi0, rLr, nChipsPerStaveLr*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,nChipsPerStaveLr*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;
+}
diff --git a/ITS/UPGRADE/testITSUv1/sim.C b/ITS/UPGRADE/testITSUv1/sim.C
new file mode 100644 (file)
index 0000000..cce4ed5
--- /dev/null
@@ -0,0 +1,24 @@
+void sim(Int_t nev=3) {
+
+  gSystem->Exec(" rm itsSegmentations.root ");
+  AliSimulation simulator;
+  //  simulator.SetMakeSDigits("");
+
+  //  simulator.SetMakeDigits("");
+
+  simulator.SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  simulator.SetSpecificStorage("GRP/GRP/Data",
+                              Form("local://%s",gSystem->pwd()));
+  simulator.SetSpecificStorage("ITS/Align/Data",
+                              Form("local://%s",gSystem->pwd()));
+  simulator.SetSpecificStorage("ITS/Calib/SimuParam",
+                              Form("local://%s",gSystem->pwd()));
+  simulator.SetRunHLT("");
+  simulator.SetRunQA(":");
+
+  TStopwatch timer;
+  timer.Start();
+  simulator.Run(nev);
+  timer.Stop();
+  timer.Print();
+}
index 4e20f0b46fc9fe10db74b3598e987db44a560c67..4527ec0838b2c008255e51ec9e96708741369c6a 100644 (file)
@@ -944,7 +944,7 @@ void AliAnalysisTaskFastEmbedding::UserExec(Option_t *)
          NULL,   // covMatrix,
          -99,    // charge
          0,      // itsClusMap
-         NULL,   // pid 
+        //         NULL,   // pid 
          NULL,   // prodVertex
          kFALSE, // used for vertex fit
          kFALSE, // used for prim vtx fit
index 6e5f04b399a20b24d2b3173c27cc12a27b3421f0..aac7806b4d12a19293a5c33beaf0b5de53f80f75 100644 (file)
@@ -1929,6 +1929,12 @@ Int_t  AliAnalysisTaskJetCluster::GetListOfTracks(TList *list,Int_t type){
        else if(fFilterType == 2)bGood = trackAOD->IsHybridGlobalConstrainedGlobal();
        if((fFilterMask>0)&&((!trackAOD->TestFilterBit(fFilterMask)||(!bGood))))continue;
         if(fRequireITSRefit){if((trackAOD->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+         if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(trackAOD->GetTPCnclsS()) /Double_t(trackAOD->GetTPCncls());
+           if (frac > 0.4) continue;
+        }
+
+
        if(TMath::Abs(trackAOD->Eta())>fTrackEtaWindow) continue;
        if(trackAOD->Pt()<fTrackPtCut) continue;
        if(fDebug) printf("pt extra track %.2f \n", trackAOD->Pt());
index 334914ae8273de37e94eea37edfca9085a1e9530..b803fc93ac4d0bc606bd4ee2ffc4a2a29132e019 100644 (file)
@@ -35,6 +35,7 @@ set ( SRCS
       FLOW/Base/AliFlowEventStar.cxx 
       FLOW/Base/AliStarEventReader.cxx 
       FLOW/Base/AliFlowTrackSimpleCuts.cxx 
+      FLOW/Base/AliFlowEventSimpleCuts.cxx
       FLOW/Base/AliFlowVector.cxx 
       FLOW/Base/AliFlowCommonConstants.cxx 
       FLOW/Base/AliFlowLYZConstants.cxx 
@@ -44,6 +45,7 @@ set ( SRCS
       FLOW/Base/AliFlowLYZHist1.cxx 
       FLOW/Base/AliFlowLYZHist2.cxx 
       FLOW/Base/AliFlowLYZEventPlane.cxx 
+      FLOW/Base/AliFlowAnalysis.cxx 
       FLOW/Base/AliFlowAnalysisWithScalarProduct.cxx 
       FLOW/Base/AliFlowAnalysisWithMCEventPlane.cxx 
       FLOW/Base/AliFlowAnalysisWithLYZEventPlane.cxx 
index ce9378331bb6ce3e7b6175f2cee3a3c6e91bc5b9..38de96ff0036076d97ab412fc5f8507b35c8f4fe 100755 (executable)
@@ -339,6 +339,7 @@ void AliAnaCaloTrackCorrMaker::FillTriggerControlHistograms()
   Bool_t triggerMatch= fReader->IsTriggerMatched();
   Bool_t triggerBCOK = kTRUE;
   Int_t  triggerId   = fReader->GetTriggerClusterId() ;
+  
   Bool_t reMatchOpenTime = fReader->IsTriggerMatchedOpenCuts(0);
   Bool_t reMatchNeigbour = fReader->IsTriggerMatchedOpenCuts(1);
   Bool_t reMatchBoth     = fReader->IsTriggerMatchedOpenCuts(2);
@@ -924,7 +925,21 @@ void AliAnaCaloTrackCorrMaker::ProcessEvent(Int_t iEntry, const char * currentFi
   //Tell the reader to fill the data in the 3 detector lists
   Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
   
-  FillTriggerControlHistograms();
+  //Access pointers, and trigger mask check needed in mixing case
+  AliAnalysisManager   *manager      = AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
+  
+  UInt_t isMBTrigger = kFALSE;
+  UInt_t isTrigger   = kFALSE;
+  if(inputHandler)
+  {
+    isMBTrigger = inputHandler->IsEventSelected() & fReader->GetMixEventTriggerMask();
+    isTrigger   = inputHandler->IsEventSelected() & fReader->GetEventTriggerMask();
+  }
+  
+  //Fill trigger control histograms, make sure it is only for triggered events and
+  // not the MB events used for mixing
+  if(fReader->IsEventTriggerAtSEOn() || isTrigger) FillTriggerControlHistograms();
   
   if(!ok)
   {
@@ -939,18 +954,6 @@ void AliAnaCaloTrackCorrMaker::ProcessEvent(Int_t iEntry, const char * currentFi
   //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
   //gObjectTable->Print();
   
-  //Access pointers, and trigger mask check needed in mixing case
-  AliAnalysisManager   *manager      = AliAnalysisManager::GetAnalysisManager();
-  AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
-  
-  UInt_t isMBTrigger = kFALSE;
-  UInt_t isTrigger   = kFALSE;
-  if(inputHandler)
-  {
-    isMBTrigger = inputHandler->IsEventSelected() & fReader->GetMixEventTriggerMask();
-    isTrigger   = inputHandler->IsEventSelected() & fReader->GetEventTriggerMask();
-  }
-  
   // Init mag field for tracks in case of ESDs, not really necessary
   if (!TGeoGlobalMagField::Instance()->GetField() && ((AliESDEvent*) fReader->GetInputEvent()))
     ((AliESDEvent*)fReader->GetInputEvent())->InitMagneticField();
index 817b9a5706117e9de8855a7e8a86c5706a6570b0..d6586e562adaada6358f60893277f224faa5b77e 100755 (executable)
@@ -287,7 +287,7 @@ Bool_t AliCaloTrackMCReader::FillInputEvent(Int_t iEntry,
           p[0] = particle->Px(); p[1] = particle->Py(); p[2] = particle->Pz();
           //Create object and write it to file
           AliAODTrack *aodTrack = new AliAODTrack(0, iParticle, p, kTRUE, x, kFALSE,NULL, 0, 0, 
-                                                  NULL,
+                                                  // NULL,
                                                   0x0,//primary,
                                                   kFALSE, // No fit performed
                                                   kFALSE, // No fit performed
index f2aac7ef5d2cc5457986e661acdcd714e5cc5900..42b1f748355f2a9424b6c63852df1272e299ccd2 100755 (executable)
@@ -298,15 +298,19 @@ public:
   void             SetTriggerPatchTimeWindow(Int_t min, Int_t max) { fTriggerPatchTimeWindow[0] = min ;
                                                                      fTriggerPatchTimeWindow[1] = max ; }
   
+  Bool_t           AreBadTriggerEventsRemoved()      const { return fRemoveBadTriggerEvents     ; }
   void             SwitchOffBadTriggerEventsRemoval()      { fRemoveBadTriggerEvents   = kFALSE ; }
   void             SwitchOnBadTriggerEventsRemoval()       { fRemoveBadTriggerEvents   = kTRUE  ; }
 
+  Bool_t           AreUnMatchedTriggerEventsRemoved()const { return fRemoveUnMatchedTriggers    ; }
   void             SwitchOffUnMatchedTriggerEventsRemoval(){ fRemoveUnMatchedTriggers  = kFALSE ; }
   void             SwitchOnUnMatchedTriggerEventsRemoval() { fRemoveUnMatchedTriggers  = kTRUE  ; }
   
+  Bool_t           IsTriggerPatchMatchedToCluster()  const { return fTriggerPatchClusterMatch   ; }
   void             SwitchOffTriggerPatchMatching()         { fTriggerPatchClusterMatch = kFALSE ; }
   void             SwitchOnTriggerPatchMatching()          { fTriggerPatchClusterMatch = kTRUE  ; }
-
+  
+  Bool_t           IsTriggerClusterTimeRecal()       const { return fTriggerClusterTimeRecal    ; }
   void             SwitchOnTriggerClusterTimeRecal ()      { fTriggerClusterTimeRecal  = kTRUE  ; }
   void             SwitchOffTriggerClusterTimeRecal()      { fTriggerClusterTimeRecal  = kFALSE ; }
   
index 6d7ec65007ccd7ea840bfd109f29e135cc5f9230..b62ce8c851620f824221baa8c4d1d92f3ebe6ec9 100644 (file)
@@ -135,15 +135,15 @@ void AliEmcalPicoTrackMaker::UserExec(Option_t *)
       isEmc = kTRUE;
 
     AliPicoTrack *picotrack = new ((*fTracksOut)[nacc]) AliPicoTrack(track->Pt(), 
-                                                                        track->Eta(), 
-                                                                        track->Phi(), 
-                                                                        track->Charge(), 
-                                                                        track->GetLabel(),
-                                                                        AliPicoTrack::GetTrackType(track),
-                                                                        track->GetTrackEtaOnEMCal(), 
-                                                                        track->GetTrackPhiOnEMCal(), 
-                                                                        track->GetTrackPtOnEMCal(), 
-                                                                        isEmc);
+                                                                    track->Eta(), 
+                                                                    track->Phi(), 
+                                                                    track->Charge(), 
+                                                                    track->GetLabel(),
+                                                                    AliPicoTrack::GetTrackType(track),
+                                                                    track->GetTrackEtaOnEMCal(), 
+                                                                    track->GetTrackPhiOnEMCal(), 
+                                                                    track->GetTrackPtOnEMCal(), 
+                                                                    isEmc);
     picotrack->SetTrack(track);
     ++nacc;
   }
index 8055bb156676498237fb1232e29b16eb3227ed0a..b98ea434cd369954ec59a97a503f5df40b588a00 100644 (file)
@@ -135,13 +135,10 @@ void AliEmcalSetupTask::Setup(Int_t runno)
 {
   // Setup everything
 
-  if (runno<=0)
-    return;
-
   // Setup AliEMCALGeometry corresponding to year
   TString geoname("EMCAL_COMPLETE12SMV1");
   Int_t year = 2013;
-  if (runno<=139517) {
+  if (runno>0 && runno<=139517) {
     year = 2010;
     geoname = "EMCAL_FIRSTYEARV1";
   } else if ((runno>139517) && (runno<=170593)) {
@@ -156,6 +153,9 @@ void AliEmcalSetupTask::Setup(Int_t runno)
     return;
   }
 
+  if (runno<=0)
+    return;
+
   // Setup CDB manager
   AliCDBManager *man = 0;
   man = AliCDBManager::Instance();
index bdd0ad8214bb9289a9c7f5d597137f8504c2cfdd..10e85811d5a976e8d68560da4c66e45f63ef639f 100644 (file)
@@ -23,16 +23,37 @@ AliAnalysisTaskSE *AddTaskEMCALTenderUsingDatasetDef(
   UInt_t clusterizer    = AliEMCALRecParam::kClusterizerv2;
   Bool_t trackMatch     = kTRUE;   //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       = 900e-9;  //maximum time difference between the digits inside EMC cluster (s)
+  Float_t timeMin       = -50e6;   //minimum time of physical signal in a cell/digit (s)
+  Float_t timeMax       =  50e6;   //maximum time of physical signal in a cell/digit (s)
+  Float_t timeCut       =   1e6;   //maximum time difference between the digits inside EMC cluster (s)
+
+  Bool_t isMC = kFALSE;
 
   TString period(perstr);
   period.ToLower();
-  if (period == "lhc12a15e")
+
+  if (period == "lhc11h") {
+    trackMatch = kFALSE;
+    timeMin = 100e-9;
+    timeMax = 900e-9;
+    timeCut = 900e-9;
+  }
+  else if (period == "lhc12a15e" || period == "lhc12a15e_fix") {
     nonLinFunct = AliEMCALRecoUtils::kPi0MCv3;
-  else if (period == "lhc12a15a")
+    isMC = kTRUE;
+  }
+  else if (period == "lhc12a15a") {
     nonLinFunct = AliEMCALRecoUtils::kPi0MCv2;
+    isMC = kTRUE;
+  }
+  else if(period == "lhc12a" || period == "lhc12b" || period == "lhc12c" || period == "lhc12d" || period == "lhc12e" || period == "lhc12f" || period == "lhc12g" || period == "lhc12h" || period == "lhc12i") {
+    reclusterize = kTRUE;
+    seedthresh = 0.3;
+    cellthresh = 0.05;
+    timeMin = 485e-9; //no timing calib available
+    timeMax = 685e-9;
+    timeCut =  1e6;
+  }
   else if(period == "lhc13b" || period == "lhc13c" || period == "lhc13d" || period == "lhc13e" || period == "lhc13f" || period == "lhc13g" || 
          period == "lhc13b4" || period == "lhc13b4_fix" || period == "lhc13b4_plus") {
     reclusterize = kTRUE;
@@ -44,12 +65,17 @@ AliAnalysisTaskSE *AddTaskEMCALTenderUsingDatasetDef(
       timeCut =  1e6;
     }
     else if(period == "lhc13b4" || period == "lhc13b4_fix" || period == "lhc13b4_plus") {
-      timeMin = -1;
-      timeMax =  1e6;
-      timeCut =  1e6;
+      nonLinFunct = AliEMCALRecoUtils::kPi0MCv3;
+      isMC = kTRUE;
     }
   }
 
+  if(isMC) { //no timing cuts when running on MC
+    timeMin = -1;
+    timeMax =  1e6;
+    timeCut =  1e6;
+  }
+
   AliAnalysisTaskSE *task = AddTaskEMCALTender(
     distBC, recalibClus, recalcClusPos, nonLinearCorr,
     remExotic, fidRegion, calibEnergy, calibTime, remBC, nonLinFunct, 
diff --git a/PWG/FLOW/Base/AliFlowAnalysis.cxx b/PWG/FLOW/Base/AliFlowAnalysis.cxx
new file mode 100644 (file)
index 0000000..d286375
--- /dev/null
@@ -0,0 +1,54 @@
+/*************************************************************************
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  * 
+**************************************************************************/
+
+#define ALIFLOWANALYSISBASE_CXX
+#include "AliFlowAnalysis.h"
+#include "AliFlowEventSimpleCuts.h"
+#include "AliFlowEventSimple.h"
+
+//////////////////////////////////////////////////////////////////////////////
+// AliFlowAnalysis:
+// Description: Base class for flow analysis methods
+// author: M. Krzewicki mikolaj.krzewicki@cern.ch
+//////////////////////////////////////////////////////////////////////////////
+
+ClassImp(AliFlowAnalysis)
+
+//-----------------------------------------------------------------------
+AliFlowAnalysis::AliFlowAnalysis(const char* name):
+TNamed(name,name),
+fEventCuts(NULL),
+fPOItype(1)
+{
+  //ctor
+}
+
+//-----------------------------------------------------------------------
+AliFlowAnalysis::~AliFlowAnalysis() 
+{
+  //destructor
+  delete fEventCuts;
+}
+
+//-----------------------------------------------------------------------
+void AliFlowAnalysis::ProcessEvent(AliFlowEventSimple* event)
+{
+  //process the event
+  //only call the analysis if we pass the event cuts (if any)
+  Bool_t pass=kTRUE;
+  if (fEventCuts) pass=fEventCuts->IsSelected(event,(TObject*)NULL);
+  if (pass) Make(event);
+}
diff --git a/PWG/FLOW/Base/AliFlowAnalysis.h b/PWG/FLOW/Base/AliFlowAnalysis.h
new file mode 100644 (file)
index 0000000..1f2cef8
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#ifndef ALIFLOWANALYSISBASE_H
+#define ALIFLOWANALYSISBASE_H
+
+class AliFlowEventSimple;
+class AliFlowEventSimpleCuts;
+class TList;
+class TDirectoryFile;
+#include "TNamed.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// Description: base class for flow analysis classes
+// origin:      Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+/////////////////////////////////////////////////////////////////////////////
+class AliFlowAnalysis : public TNamed {
+ public:
+   AliFlowAnalysis(const char* name="AliFlowAnalysis");            //default constructor
+   virtual  ~AliFlowAnalysis();  //destructor
+   virtual void Init() {}                                       //Define output objects
+   virtual void ProcessEvent(AliFlowEventSimple* /*anEvent*/);  //Main routine executed by the framework
+   virtual void Make(AliFlowEventSimple* /*anEvent*/) {}        //Main routine to be implemened by user
+   virtual void Finish() {}                                           //Fill results
+   virtual void GetOutputHistograms(TList* /* outputListHistos */) {} //Copy output objects from TList
+   virtual void WriteHistograms(TDirectoryFile* /* outputFileName */) const {} //writes histograms locally (for OnTheFly)
+   
+   virtual TList*    GetHistList()      const {return NULL;}
+   virtual void      SetHistList(TList*) {}
+   void SetPOItype(Int_t i) {fPOItype=i;}
+   Int_t GetPOItype() const {return fPOItype;}
+
+   void SetEventCuts(AliFlowEventSimpleCuts* cuts) {fEventCuts=cuts;}
+   AliFlowEventSimpleCuts* GetEventCuts() const {return fEventCuts;}
+
+ protected:
+   AliFlowEventSimpleCuts* fEventCuts;  //some analysis level event cuts
+   Int_t fPOItype;                       //which POI type are we processing in this analysis?
+ private:
+   AliFlowAnalysis(const AliFlowAnalysis& anAnalysis);            //copy constructor
+   AliFlowAnalysis& operator=(const AliFlowAnalysis& anAnalysis); //assignment operator
+
+   ClassDef(AliFlowAnalysis,1)  // class version
+};
+#endif
index 50bda6b67813bca326af404e230aa996731b8a4d..3a8c6449156c904919ee34f3ce43220d4d8fa42d 100644 (file)
@@ -68,6 +68,7 @@ fHistQbNormMb(NULL),
 fResolution(NULL),
 fHistQaQb(NULL),
 fHistQaQbCos(NULL),
+fHistNumberOfSubtractedDaughters(NULL),
 fCommonHists(NULL),
 fCommonHistsuQ(NULL),
 fCommonHistsRes(NULL)
@@ -175,7 +176,8 @@ void AliFlowAnalysisWithScalarProduct::Init() {
   dMin[1]   = AliFlowCommonConstants::GetMaster()->GetEtaMin();
   dMax[0]   = AliFlowCommonConstants::GetMaster()->GetPtMax();
   dMax[1]   = AliFlowCommonConstants::GetMaster()->GetEtaMax();
-  for(Int_t iPOI=0; iPOI!=2; ++iPOI) for(Int_t iSpace=0; iSpace!=2; ++iSpace) {
+  for(Int_t iPOI=0; iPOI!=2; ++iPOI) 
+    for(Int_t iSpace=0; iSpace!=2; ++iSpace) {
     // uQ
     fHistProUQ[iPOI][iSpace] = new TProfile( Form( "FlowPro_UQ_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
                                        Form( "FlowPro_UQ%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
@@ -285,6 +287,9 @@ void AliFlowAnalysisWithScalarProduct::Init() {
     fHistQaQbCos->SetYTitle("dN/d#phi");
     fHistQaQbCos->SetXTitle("#phi");
     tQARelated->Add(fHistQaQbCos);
+    
+    fHistNumberOfSubtractedDaughters = new TH1I("NumberOfSubtractedDaughtersInQ",";daughters;counts;Number of daughters subtracted from Q",5,0.,5.);
+    tQARelated->Add(fHistNumberOfSubtractedDaughters);
   }
 
   fHistList->Add(uQRelated);
@@ -396,7 +401,7 @@ void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
     }
 
     //remove track if in subevent
-    for(Int_t inSubEvent=0; inSubEvent!=2; ++inSubEvent) {
+    for(Int_t inSubEvent=0; inSubEvent<2; ++inSubEvent) {
       if( !pTrack->InSubevent( inSubEvent ) )
         continue;
       if(inSubEvent==0)
@@ -406,17 +411,27 @@ void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
         if( fTotalQvector<2 )
           continue;
       Double_t dW=1;
-      Double_t dPhiCenter = dPhi;
+      //Double_t dPhiCenter = dPhi;
       //if phi weights are used
       if(fUsePhiWeights && fPhiWeightsSub[inSubEvent]) {
         Int_t iNBinsPhiSub = fPhiWeightsSub[inSubEvent]->GetNbinsX();
         Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNBinsPhiSub/TMath::TwoPi()));
         dW = fPhiWeightsSub[inSubEvent]->GetBinContent(phiBin);
-        dPhiCenter = fPhiWeightsSub[inSubEvent]->GetBinCenter(phiBin);
+        //dPhiCenter = fPhiWeightsSub[inSubEvent]->GetBinCenter(phiBin);
+      }
+      //Double_t dQmX = vQm.X() - dW*(pTrack->Weight())* TMath::Cos(fHarmonic*dPhiCenter);
+      //Double_t dQmY = vQm.Y() - dW*(pTrack->Weight())* TMath::Sin(fHarmonic*dPhiCenter);
+      //vQm.Set(dQmX,dQmY);
+      
+      //subtrack the track from the Q vector, but only if it was used to construct this
+      //Q vector: i.e. check wether it has the same tags and is in the same subevent
+      //this is especially important for the daughters (as for the mother it is already checked)
+      Int_t numberOfsubtractedDaughters=vQm.SubtractTrackWithDaughters(pTrack,dW);
+      
+      if(!fMinimalBook) {
+        fHistNumberOfSubtractedDaughters->Fill(numberOfsubtractedDaughters);
       }
-      Double_t dQmX = vQm.X() - dW*(pTrack->Weight())* TMath::Cos(fHarmonic*dPhiCenter);
-      Double_t dQmY = vQm.Y() - dW*(pTrack->Weight())* TMath::Sin(fHarmonic*dPhiCenter);
-      vQm.Set(dQmX,dQmY);
+
       dMq = dMq-dW*pTrack->Weight();
     }
     dNq = fNormalizationType ? dMq : vQm.Mod();
@@ -442,7 +457,7 @@ void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
     for(Int_t iPOI=0; iPOI!=2; ++iPOI) {
       if( (iPOI==0)&&(!pTrack->InRPSelection()) )
         continue;
-      if( (iPOI==1)&&(!pTrack->InPOISelection()) )
+      if( (iPOI==1)&&(!pTrack->InPOISelection(fPOItype)) )
         continue;
       fHistProUQ[iPOI][0]->Fill(dPt ,dUQ/dNq,dWq); //Fill (uQ/Nq') with weight (Nq')
       fHistProUQ[iPOI][1]->Fill(dEta,dUQ/dNq,dWq); //Fill (uQ/Nq') with weight (Nq')
index 35c4dcf2b3148e05c06d2de6e0ab5e94c829e99b..d075202e6c485612f3326bec78f420723c2441ae 100644 (file)
@@ -12,11 +12,13 @@ class AliFlowEventSimple;
 class AliFlowCommonHist;
 class AliFlowCommonHistResults;
 
+#include  "TList.h"
+#include "AliFlowAnalysis.h"
+
 class TH1D;
 class TH1F;
 class TH2D;
 class TProfile;
-#include  "TList.h"
 class TDirectoryFile;
 
 /////////////////////////////////////////////////////////////////////////////
@@ -27,7 +29,7 @@ class TDirectoryFile;
 // mods:    Carlos Perez (cperez@nikhef.nl)
 /////////////////////////////////////////////////////////////////////////////
  
-class AliFlowAnalysisWithScalarProduct {
+class AliFlowAnalysisWithScalarProduct : public AliFlowAnalysis {
  public:
  
    AliFlowAnalysisWithScalarProduct();            //default constructor
@@ -96,6 +98,7 @@ class AliFlowAnalysisWithScalarProduct {
    TH1D* fResolution; // Resolution
    TH1D* fHistQaQb; // QaQb
    TH1D* fHistQaQbCos; // QaQbCos
+   TH1I* fHistNumberOfSubtractedDaughters; //how many daughters were subtracted during Q calculation?
 
    AliFlowCommonHist*        fCommonHists;    // control histograms
    AliFlowCommonHist*        fCommonHistsuQ;  // control histograms
@@ -107,7 +110,7 @@ class AliFlowAnalysisWithScalarProduct {
    TH1D*      fHistSumOfWeightsu[2][2][3]; // holds sums of 0: Nq', 1: Nq'^2, 2: Nq'*Na*Nb
    TProfile*  fHistProNUAu[2][2][2];          // NUA related qq for RP|POI PT|ETA
 
-   ClassDef(AliFlowAnalysisWithScalarProduct,0)  // class version
+   ClassDef(AliFlowAnalysisWithScalarProduct,1)  // class version
 };
  
 
index a67a8272d730aae99f1e265dd4e9ffff75d4b668..a921fb6f1b9306a5d7536e5d76e84be488e0e99e 100644 (file)
@@ -52,8 +52,6 @@ AliFlowEventSimple::AliFlowEventSimple():
   fTrackCollection(NULL),
   fReferenceMultiplicity(0),
   fNumberOfTracks(0),
-  fNumberOfRPs(0),
-  fNumberOfPOIs(0),
   fUseGlauberMCSymmetryPlanes(kFALSE),
   fUseExternalSymmetryPlanes(kFALSE),
   fPsi1(0.),
@@ -73,7 +71,11 @@ AliFlowEventSimple::AliFlowEventSimple():
   fNumberOfPOIsWrap(NULL),
   fMCReactionPlaneAngleWrap(NULL),
   fShuffledIndexes(NULL),
-  fShuffleTracks(kFALSE)
+  fShuffleTracks(kFALSE),
+  fMothersCollection(NULL),
+  fCentrality(-1.),
+  fNumberOfPOItypes(2),
+  fNumberOfPOIs(NULL)
 {
   cout << "AliFlowEventSimple: Default constructor to be used only by root for io" << endl;
 }
@@ -89,8 +91,6 @@ AliFlowEventSimple::AliFlowEventSimple( Int_t n,
   fTrackCollection(new TObjArray(n)),
   fReferenceMultiplicity(0),
   fNumberOfTracks(0),
-  fNumberOfRPs(0),
-  fNumberOfPOIs(0),
   fUseGlauberMCSymmetryPlanes(kFALSE),
   fUseExternalSymmetryPlanes(kFALSE),
   fPsi1(0.),
@@ -110,7 +110,11 @@ AliFlowEventSimple::AliFlowEventSimple( Int_t n,
   fNumberOfPOIsWrap(NULL),
   fMCReactionPlaneAngleWrap(NULL),
   fShuffledIndexes(NULL),
-  fShuffleTracks(kFALSE)
+  fShuffleTracks(kFALSE),
+  fMothersCollection(new TObjArray()),
+  fCentrality(-1.),
+  fNumberOfPOItypes(2),
+  fNumberOfPOIs(new Int_t[fNumberOfPOItypes])
 {
   //ctor
   // if second argument is set to AliFlowEventSimple::kGenerate
@@ -127,8 +131,6 @@ AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
   fTrackCollection((TObjArray*)(anEvent.fTrackCollection)->Clone()),
   fReferenceMultiplicity(anEvent.fReferenceMultiplicity),
   fNumberOfTracks(anEvent.fNumberOfTracks),
-  fNumberOfRPs(anEvent.fNumberOfRPs),
-  fNumberOfPOIs(anEvent.fNumberOfPOIs),
   fUseGlauberMCSymmetryPlanes(anEvent.fUseGlauberMCSymmetryPlanes),
   fUseExternalSymmetryPlanes(anEvent.fUseExternalSymmetryPlanes),
   fPsi1(anEvent.fPsi1),
@@ -148,9 +150,42 @@ AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
   fNumberOfPOIsWrap(anEvent.fNumberOfPOIsWrap),
   fMCReactionPlaneAngleWrap(anEvent.fMCReactionPlaneAngleWrap),
   fShuffledIndexes(NULL),
-  fShuffleTracks(anEvent.fShuffleTracks)
+  fShuffleTracks(anEvent.fShuffleTracks),
+  fMothersCollection(new TObjArray()),
+  fCentrality(anEvent.fCentrality),
+  fNumberOfPOItypes(anEvent.fNumberOfPOItypes),
+  fNumberOfPOIs(new Int_t[fNumberOfPOItypes])
 {
   //copy constructor
+  memcpy(fNumberOfPOIs,anEvent.fNumberOfPOIs,fNumberOfPOItypes*sizeof(Int_t));
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEventSimple::SetNumberOfPOIs( Int_t numberOfPOIs, Int_t poiType)
+{
+  //set the number of poi classes, resize the array if larger is needed
+  //never shrink the array
+  //never decrease the stored number
+  if (poiType>=fNumberOfPOItypes)
+  {
+    Int_t n = poiType+1;
+    Int_t* tmp = new Int_t[n];
+    for (Int_t j=0; j<n; j++) { tmp[j]=0; }       
+    memcpy(tmp,fNumberOfPOIs,fNumberOfPOItypes*sizeof(Int_t));
+    delete [] fNumberOfPOIs;
+    fNumberOfPOIs = tmp;
+    fNumberOfPOItypes = n;
+  }
+  
+  fNumberOfPOIs[poiType] = numberOfPOIs;
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEventSimple::IncrementNumberOfPOIs(Int_t poiType)
+{
+
+  if (poiType>=fNumberOfPOItypes) SetNumberOfPOIs(0,poiType);
+  fNumberOfPOIs[poiType]++;
 }
 
 //-----------------------------------------------------------------------
@@ -163,8 +198,10 @@ AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEv
   fTrackCollection = (TObjArray*)(anEvent.fTrackCollection)->Clone(); //deep copy
   fReferenceMultiplicity = anEvent.fReferenceMultiplicity;
   fNumberOfTracks = anEvent.fNumberOfTracks;
-  fNumberOfRPs = anEvent.fNumberOfRPs;
-  fNumberOfPOIs = anEvent.fNumberOfPOIs;
+  fNumberOfPOItypes = anEvent.fNumberOfPOItypes;
+  delete [] fNumberOfPOIs;
+  fNumberOfPOIs=new Int_t[fNumberOfPOItypes];
+  memcpy(fNumberOfPOIs,anEvent.fNumberOfPOIs,fNumberOfPOItypes*sizeof(Int_t));
   fUseGlauberMCSymmetryPlanes = anEvent.fUseGlauberMCSymmetryPlanes;
   fUseExternalSymmetryPlanes = anEvent.fUseExternalSymmetryPlanes;
   fPsi1 = anEvent.fPsi1;
@@ -199,6 +236,8 @@ AliFlowEventSimple::~AliFlowEventSimple()
   delete fNumberOfPOIsWrap;
   delete fMCReactionPlaneAngleWrap;
   delete fShuffledIndexes;
+  delete fMothersCollection;
+  delete [] fNumberOfPOIs;
 }
 
 //-----------------------------------------------------------------------
@@ -312,12 +351,13 @@ void AliFlowEventSimple::ShuffleTracks()
   //shuffle track indexes
   if (!fShuffledIndexes) 
   {
-    //initialize the table with shuffeled indexes
+    //initialize the table with shuffled indexes
     fShuffledIndexes = new Int_t[fNumberOfTracks];
     for (Int_t j=0; j<fNumberOfTracks; j++) { fShuffledIndexes[j]=j; }
   }
   //shuffle
   std::random_shuffle(&fShuffledIndexes[0], &fShuffledIndexes[fNumberOfTracks]);
+  Printf("Tracks shuffled! tracks: %i",fNumberOfTracks);
 }
 
 //-----------------------------------------------------------------------
@@ -327,11 +367,27 @@ void AliFlowEventSimple::AddTrack( AliFlowTrackSimple* track )
   if (fNumberOfTracks < fTrackCollection->GetEntriesFast())
   {
     TObject* o = fTrackCollection->At(fNumberOfTracks);
-    if (o) delete o;
+    delete o;
   }
   fTrackCollection->AddAtAndExpand(track,fNumberOfTracks);
+  if (track->GetNDaughters()>0)
+  {
+    //if there track has daughters cache in the collection of mothers
+    fMothersCollection->Add(track);
+  }
+  TrackAdded();
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEventSimple::TrackAdded()
+{
+  //book keeping after a new track has been added
   fNumberOfTracks++;
-  delete [] fShuffledIndexes; fShuffledIndexes=NULL;
+  if (fShuffledIndexes)
+  {
+    delete [] fShuffledIndexes;
+    fShuffledIndexes=NULL;  
+  }
 }
 
 //-----------------------------------------------------------------------
@@ -346,7 +402,11 @@ AliFlowTrackSimple* AliFlowEventSimple::MakeNewTrack()
 }
 
 //-----------------------------------------------------------------------
-AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
+AliFlowVector AliFlowEventSimple::GetQ( Int_t n, 
+                                        TList *weightsList, 
+                                        Bool_t usePhiWeights, 
+                                        Bool_t usePtWeights, 
+                                        Bool_t useEtaWeights )
 {
   // calculate Q-vector in harmonic n without weights (default harmonic n=2)
   Double_t dQX = 0.;
@@ -450,13 +510,21 @@ AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePh
 
   vQ.Set(dQX,dQY);
   vQ.SetMult(sumOfWeights);
+  vQ.SetHarmonic(iOrder);
+  vQ.SetPOItype(AliFlowTrackSimple::kRP);
+  vQ.SetSubeventNumber(-1);
 
   return vQ;
 
 }
 
 //-----------------------------------------------------------------------
-void AliFlowEventSimple::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
+void AliFlowEventSimple::Get2Qsub( AliFlowVector* Qarray, 
+                                   Int_t n, 
+                                   TList *weightsList, 
+                                   Bool_t usePhiWeights, 
+                                   Bool_t usePtWeights, 
+                                   Bool_t useEtaWeights )
 {
 
   // calculate Q-vector in harmonic n without weights (default harmonic n=2)
@@ -528,66 +596,66 @@ void AliFlowEventSimple::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weights
     for(Int_t i=0; i<fNumberOfTracks; i++)
     {
       pTrack = (AliFlowTrackSimple*)fTrackCollection->At(i);
-      if(pTrack)
-      {
-        if(pTrack->InRPSelection())
-        {
-          if (pTrack->InSubevent(s))
-          {
-            dPhi    = pTrack->Phi();
-            dPt     = pTrack->Pt();
-            dEta    = pTrack->Eta();
-           dWeight = pTrack->Weight();
-
-            // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
-           //subevent 0
-           if(s == 0)  { 
-             if(phiWeightsSub0 && iNbinsPhiSub0)  {
-               Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub0/TMath::TwoPi()));
-               //use the phi value at the center of the bin
-               dPhi  = phiWeightsSub0->GetBinCenter(phiBin);
-               dWphi = phiWeightsSub0->GetBinContent(phiBin);
-             }
-           } 
-           //subevent 1
-           else if (s == 1) { 
-             if(phiWeightsSub1 && iNbinsPhiSub1) {
-               Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub1/TMath::TwoPi()));
-               //use the phi value at the center of the bin
-               dPhi  = phiWeightsSub1->GetBinCenter(phiBin);
-               dWphi = phiWeightsSub1->GetBinContent(phiBin);
-             } 
-           }
-           
-            // determine v'(pt) weight:
-            if(ptWeights && dBinWidthPt)
-            {
-              dWpt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
-            }
-
-            // determine v'(eta) weight:
-            if(etaWeights && dBinWidthEta)
-            {
-              dWeta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
-            }
-
-            // building up the weighted Q-vector:
-            dQX += dWeight*dWphi*dWpt*dWeta*TMath::Cos(iOrder*dPhi);
-            dQY += dWeight*dWphi*dWpt*dWeta*TMath::Sin(iOrder*dPhi);
-
-            // weighted multiplicity:
-            sumOfWeights+=dWeight*dWphi*dWpt*dWeta;
-
-          } // end of subevent
-        } // end of if (pTrack->InRPSelection())
-      } // end of if (pTrack)
-      else
+      if(!pTrack)
       {
         cerr << "no particle!!!"<<endl;
+        continue;
       }
+      if(pTrack->InRPSelection() && (pTrack->InSubevent(s)))
+      {
+        dPhi    = pTrack->Phi();
+        dPt     = pTrack->Pt();
+        dEta    = pTrack->Eta();
+        dWeight = pTrack->Weight();
+
+        // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
+        //subevent 0
+        if(s == 0)  { 
+          if(phiWeightsSub0 && iNbinsPhiSub0)  {
+            Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub0/TMath::TwoPi()));
+            //use the phi value at the center of the bin
+            dPhi  = phiWeightsSub0->GetBinCenter(phiBin);
+            dWphi = phiWeightsSub0->GetBinContent(phiBin);
+          }
+        } 
+        //subevent 1
+        else if (s == 1) { 
+          if(phiWeightsSub1 && iNbinsPhiSub1) {
+            Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNbinsPhiSub1/TMath::TwoPi()));
+            //use the phi value at the center of the bin
+            dPhi  = phiWeightsSub1->GetBinCenter(phiBin);
+            dWphi = phiWeightsSub1->GetBinContent(phiBin);
+          } 
+        }
+
+        // determine v'(pt) weight:
+        if(ptWeights && dBinWidthPt)
+        {
+          dWpt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-dPtMin)/dBinWidthPt)));
+        }
+
+        // determine v'(eta) weight:
+        if(etaWeights && dBinWidthEta)
+        {
+          dWeta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-dEtaMin)/dBinWidthEta)));
+        }
+
+        // building up the weighted Q-vector:
+        dQX += dWeight*dWphi*dWpt*dWeta*TMath::Cos(iOrder*dPhi);
+        dQY += dWeight*dWphi*dWpt*dWeta*TMath::Sin(iOrder*dPhi);
+
+        // weighted multiplicity:
+        sumOfWeights+=dWeight*dWphi*dWpt*dWeta;
+
+      } // end of if (pTrack->InRPSelection())
     } // loop over particles
+    
     Qarray[s].Set(dQX,dQY);
     Qarray[s].SetMult(sumOfWeights);
+    Qarray[s].SetHarmonic(iOrder);
+    Qarray[s].SetPOItype(AliFlowTrackSimple::kRP);
+    Qarray[s].SetSubeventNumber(s);
+
     //reset
     sumOfWeights = 0.;
     dQX = 0.;
@@ -603,8 +671,8 @@ void AliFlowEventSimple::Print(Option_t *option) const
   //   -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
   //             ===============================================
   //   printf( "TH1.Print Name  = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
-  printf( "Class.Print Name = %s, #tracks= %d, Number of RPs= %d, Number of POIs= %d, MC EventPlaneAngle= %f\n",
-          GetName(),fNumberOfTracks, fNumberOfRPs, fNumberOfPOIs, fMCReactionPlaneAngle );
+  printf( "Class.Print Name = %s, #tracks= %d, Number of RPs= %d, Number of POIs = %d, MC EventPlaneAngle= %f\n",
+          GetName(),fNumberOfTracks, fNumberOfPOIs[0], fNumberOfPOIs[1], fMCReactionPlaneAngle );
 
   TString optionstr(option);
   if (!optionstr.Contains("all")) return;
@@ -630,12 +698,12 @@ void AliFlowEventSimple::Browse(TBrowser *b)
   }
   if (!fNumberOfRPsWrap)
   {
-    fNumberOfRPsWrap = new TParameter<int>("fNumberOfRPs", fNumberOfRPs);
+    fNumberOfRPsWrap = new TParameter<int>("fNumberOfRPs", GetNumberOfRPs());
     b->Add(fNumberOfRPsWrap);
   }
   if (!fNumberOfPOIsWrap)
   {
-    fNumberOfPOIsWrap = new TParameter<int>("fNumberOfPOIs", fNumberOfPOIs);
+    fNumberOfPOIsWrap = new TParameter<int>("fNumberOfPOIs", GetNumberOfPOIs());
     b->Add(fNumberOfPOIsWrap);
   }
   if (!fMCReactionPlaneAngleWrap)
@@ -653,8 +721,6 @@ AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
   fTrackCollection(NULL),
   fReferenceMultiplicity(0),
   fNumberOfTracks(0),
-  fNumberOfRPs(0),
-  fNumberOfPOIs(0),
   fUseGlauberMCSymmetryPlanes(kFALSE),
   fUseExternalSymmetryPlanes(kFALSE),
   fPsi1(0.),
@@ -674,7 +740,11 @@ AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
   fNumberOfPOIsWrap(NULL),
   fMCReactionPlaneAngleWrap(NULL),
   fShuffledIndexes(NULL),
-  fShuffleTracks(kFALSE)
+  fShuffleTracks(kFALSE),
+  fMothersCollection(new TObjArray()),
+  fCentrality(-1.),
+  fNumberOfPOItypes(2),
+  fNumberOfPOIs(new Int_t[fNumberOfPOItypes])
 {
   //constructor, fills the event from a TTree of kinematic.root files
   //applies RP and POI cuts, tags the tracks
@@ -692,8 +762,9 @@ AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
     if (!pParticle) continue; //no particle
     if (!pParticle->IsPrimary()) continue;
 
-    Bool_t rpOK = rpCuts->PassesCuts(pParticle);
+    Bool_t rpOK = (rpCuts->PassesCuts(pParticle)>0);
     Bool_t poiOK = poiCuts->PassesCuts(pParticle);
+    Int_t poiType = poiCuts->GetPOItype();
     
     if (rpOK || poiOK)
     {
@@ -702,16 +773,16 @@ AliFlowEventSimple::AliFlowEventSimple( TTree* inputTree,
       //marking the particles used for int. flow:
       if(rpOK)
       {
-        pTrack->SetForRPSelection(kTRUE);
-        fNumberOfRPs++;
-        cout<<"fNumberOfRPs = "<<fNumberOfRPs<<endl;
+        pTrack->TagRP(kTRUE);
+        IncrementNumberOfPOIs(0);
+        cout<<"numberOfRPs = "<<fNumberOfPOIs[0]<<endl;
       }
       //marking the particles used for diff. flow:
       if(poiOK)
       {
-        pTrack->SetForPOISelection(kTRUE);
-        fNumberOfPOIs++;
-        cout<<"fNumberOfPOIs = "<<fNumberOfPOIs<<endl;
+        pTrack->Tag(poiType);
+        IncrementNumberOfPOIs(poiType);
+        printf("fNumberOfPOIs[%i] = %i",poiType,fNumberOfPOIs[poiType]);
       }
       //adding a particles which were used either for int. or diff. flow to the list
       AddTrack(pTrack);
@@ -920,18 +991,18 @@ void AliFlowEventSimple::TagRP( const AliFlowTrackSimpleCuts* cuts )
     Bool_t rpTrack=track->InRPSelection();
     if (pass) 
     {
-      if (!rpTrack) fNumberOfRPs++; //only increase if not already tagged
+      if (!rpTrack) fNumberOfPOIs[0]++; //only increase if not already tagged
     }
     else
     {
-      if (rpTrack) fNumberOfRPs--; //only decrease if detagging
+      if (rpTrack) fNumberOfPOIs[0]--; //only decrease if detagging
     }
     track->SetForRPSelection(pass);
   }
 }
 
 //_____________________________________________________________________________
-void AliFlowEventSimple::TagPOI( const AliFlowTrackSimpleCuts* cuts )
+void AliFlowEventSimple::TagPOI( const AliFlowTrackSimpleCuts* cuts, Int_t poiType )
 {
   //tag tracks as particles of interest (POIs)
   for (Int_t i=0; i<fNumberOfTracks; i++)
@@ -942,13 +1013,13 @@ void AliFlowEventSimple::TagPOI( const AliFlowTrackSimpleCuts* cuts )
     Bool_t poiTrack=track->InPOISelection();
     if (pass) 
     {
-      if (!poiTrack) fNumberOfPOIs++; //only increase if not already tagged
+      if (!poiTrack) fNumberOfPOIs[poiType]++; //only increase if not already tagged
     }
     else
     {
-      if (poiTrack) fNumberOfPOIs--; //only decrease if detagging
+      if (poiTrack) fNumberOfPOIs[poiType]--; //only decrease if detagging
     }
-    track->SetForPOISelection(pass);
+    track->Tag(poiType,pass);
   }
 }
 
@@ -967,9 +1038,12 @@ void AliFlowEventSimple::DefineDeadZone( Double_t etaMin,
     Double_t phi = track->Phi();
     if (eta>etaMin && eta<etaMax && phi>phiMin && phi<phiMax)
     {
-      if (track->InRPSelection()) {fNumberOfRPs--;}
-      if (track->InPOISelection()) {fNumberOfPOIs--;}
-      track->ResetFlowTags();
+      if (track->InRPSelection()) {fNumberOfPOIs[0]--;}
+      for (Int_t j=1; j<fNumberOfPOItypes; j++)
+      {
+        if (track->CheckTag(j)) {fNumberOfPOIs[j]--;}
+      }
+      track->ResetPOItype();
     }
   }
 }
@@ -1009,13 +1083,16 @@ TF1* AliFlowEventSimple::SimplePtSpectrum()
 //_____________________________________________________________________________
 void AliFlowEventSimple::ClearFast()
 {
-  //clear the counter without deleting allocated objects so they can be reused
+  //clear the counters without deleting allocated objects so they can be reused
   fReferenceMultiplicity = 0;
   fNumberOfTracks = 0;
-  fNumberOfRPs = 0;
-  fNumberOfPOIs = 0;
+  for (Int_t i=0; i<fNumberOfPOItypes; i++)
+  {
+    fNumberOfPOIs[i] = 0;
+  }
   fMCReactionPlaneAngle = 0.0;
   fMCReactionPlaneAngleIsSet = kFALSE;
   fAfterBurnerPrecision = 0.001;
   fUserModified = kFALSE;
+  delete [] fShuffledIndexes; fShuffledIndexes=NULL;
 }
index f1990349df9c6834f8e1528a89e944b359f4e289..d16695956d6604aa8f08c8d9c7f1750e036a6026 100644 (file)
@@ -50,14 +50,15 @@ class AliFlowEventSimple: public TObject {
   Int_t    NumberOfTracks() const                   { return fNumberOfTracks; }
   Int_t    GetReferenceMultiplicity() const         { return fReferenceMultiplicity; }
   void     SetReferenceMultiplicity( Int_t m )      { fReferenceMultiplicity = m; }
-  Int_t    GetEventNSelTracksRP() const             { return fNumberOfRPs; } 
-  void     SetEventNSelTracksRP(Int_t nr)           { fNumberOfRPs = nr; }  
-  Int_t    GetEventNSelTracksPOI() const            { return fNumberOfPOIs; } 
-  void     SetEventNSelTracksPOI(Int_t np)          { fNumberOfPOIs = np; }  
-  Int_t    GetNumberOfRPs() const                   { return fNumberOfRPs; }
-  void     SetNumberOfRPs( Int_t nr )               { fNumberOfRPs=nr; }
-  Int_t    GetNumberOfPOIs() const                  { return fNumberOfPOIs; }
-  void     SetNumberOfPOIs( Int_t np )              { fNumberOfPOIs=np; }
+  Int_t    GetEventNSelTracksRP() const             { return GetNumberOfPOIs(0); } 
+  void     SetEventNSelTracksRP(Int_t nr)           { SetNumberOfPOIs(nr,0); }  
+  Int_t    GetEventNSelTracksPOI() const            { return GetNumberOfPOIs(1); } 
+  void     SetEventNSelTracksPOI(Int_t np)          { SetNumberOfPOIs(np,1); }  
+  Int_t    GetNumberOfRPs() const                   { return GetNumberOfPOIs(0); }
+  void     SetNumberOfRPs( Int_t nr )               { SetNumberOfPOIs(nr,0); }
+  Int_t    GetNumberOfPOIs(Int_t i=1) const         { return (i<fNumberOfPOItypes)?fNumberOfPOIs[i]:0; }
+  void     SetNumberOfPOIs( Int_t nubmerOfPOIs, Int_t poiType=1 );
+  void     IncrementNumberOfPOIs(Int_t poiType=1);
 
   void     SetUseGlauberMCSymmetryPlanes()          { fUseGlauberMCSymmetryPlanes = kTRUE; }
   void     SetUseExternalSymmetryPlanes(TF1 *gPsi1Psi3 = 0x0,
@@ -88,7 +89,7 @@ class AliFlowEventSimple: public TObject {
   void TagSubeventsInEta(Double_t etaMinA, Double_t etaMaxA, Double_t etaMinB, Double_t etaMaxB );
   void TagSubeventsByCharge();
   void TagRP(const AliFlowTrackSimpleCuts* cuts );
-  void TagPOI(const AliFlowTrackSimpleCuts* cuts );
+  void TagPOI(const AliFlowTrackSimpleCuts* cuts, Int_t poiType=0);
   void CloneTracks(Int_t n);
   void AddV1( Double_t v1 );
   void AddV2( Double_t v2 );
@@ -101,18 +102,22 @@ class AliFlowEventSimple: public TObject {
   void AddV2( TF1* ptDepV2 );
   void DefineDeadZone( Double_t etaMin, Double_t etaMax, Double_t phiMin, Double_t phiMax );
   Int_t CleanUpDeadTracks();
-  void ClearFast();
+  virtual void ClearFast();
  
   static TF1* SimplePtSpectrum();
   static TF1* SimplePtDepV2();
 
   AliFlowTrackSimple* GetTrack(Int_t i);
   void AddTrack( AliFlowTrackSimple* track ); 
+  void TrackAdded();
   AliFlowTrackSimple* MakeNewTrack();
  
   virtual AliFlowVector GetQ(Int_t n=2, TList *weightsList=NULL, Bool_t usePhiWeights=kFALSE, Bool_t usePtWeights=kFALSE, Bool_t useEtaWeights=kFALSE);
   virtual void Get2Qsub(AliFlowVector* Qarray, Int_t n=2, TList *weightsList=NULL, Bool_t usePhiWeights=kFALSE, Bool_t usePtWeights=kFALSE, Bool_t useEtaWeights=kFALSE);  
 
+  void SetCentrality(Double_t c) {fCentrality=c;}
+  Double_t GetCentrality() const {return fCentrality;}
+
  protected:
   virtual void Generate( Int_t nParticles,
                          TF1* ptDist=NULL,
@@ -125,8 +130,6 @@ class AliFlowEventSimple: public TObject {
   TObjArray*              fTrackCollection;           //-> collection of tracks
   Int_t                   fReferenceMultiplicity;     // reference multiplicity
   Int_t                   fNumberOfTracks;            // number of tracks
-  Int_t                   fNumberOfRPs;               // number of tracks that have passed the RP selection
-  Int_t                   fNumberOfPOIs;              // number of tracks that have passed the POI selection
   Bool_t                  fUseGlauberMCSymmetryPlanes;// Use symmetry planes (Glauber MC)
   Bool_t                  fUseExternalSymmetryPlanes; // Use symmetry planes (external)
   Double_t                fPsi1;                      // Psi_1
@@ -147,6 +150,12 @@ class AliFlowEventSimple: public TObject {
   TParameter<Double_t>*   fMCReactionPlaneAngleWrap;  //! the angle of the reaction plane from the MC truth in TBrowser
   Int_t*                  fShuffledIndexes;           //! placeholder for randomized indexes
   Bool_t                  fShuffleTracks;             // do we shuffle tracks on get?
+  TObjArray*              fMothersCollection;         //!cache the particles with daughters
+  Double_t                fCentrality;                //centrality
+ private:
+  Int_t                   fNumberOfPOItypes;    // how many different flow particle types do we have? (RP,POI,POI_2,...)
+  Int_t*                  fNumberOfPOIs;          //[fNumberOfPOItypes] number of tracks that have passed the POI selection
 
   ClassDef(AliFlowEventSimple,1)
 };
diff --git a/PWG/FLOW/Base/AliFlowEventSimpleCuts.cxx b/PWG/FLOW/Base/AliFlowEventSimpleCuts.cxx
new file mode 100644 (file)
index 0000000..e02916e
--- /dev/null
@@ -0,0 +1,86 @@
+/**************************************************************************
+ * 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$ */ 
+
+// AliFlowEventSimpleCuts:
+// An event cut class for the flow framework
+//
+// origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
+
+#include "AliFlowEventSimpleCuts.h"
+#include "AliFlowEventSimple.h"
+
+ClassImp(AliFlowEventSimpleCuts)
+
+//-----------------------------------------------------------------------
+AliFlowEventSimpleCuts::AliFlowEventSimpleCuts():
+  TNamed(),
+  fCutCentralityPercentile(kFALSE),
+  fCentralityPercentileMax(100.),
+  fCentralityPercentileMin(0.)
+{
+  //constructor 
+}
+
+//-----------------------------------------------------------------------
+AliFlowEventSimpleCuts::AliFlowEventSimpleCuts(const char* name, const char* title):
+  TNamed(name, title),
+  fCutCentralityPercentile(kFALSE),
+  fCentralityPercentileMax(100.),
+  fCentralityPercentileMin(0.)
+{
+  //constructor 
+}
+
+////-----------------------------------------------------------------------
+AliFlowEventSimpleCuts::AliFlowEventSimpleCuts(const AliFlowEventSimpleCuts& that):
+  TNamed(that),
+  fCutCentralityPercentile(that.fCutCentralityPercentile),
+  fCentralityPercentileMax(that.fCentralityPercentileMax),
+  fCentralityPercentileMin(that.fCentralityPercentileMin)
+{
+  //copy ctor
+}
+
+////-----------------------------------------------------------------------
+AliFlowEventSimpleCuts::~AliFlowEventSimpleCuts()
+{
+  //dtor
+}
+
+////-----------------------------------------------------------------------
+AliFlowEventSimpleCuts& AliFlowEventSimpleCuts::operator=(const AliFlowEventSimpleCuts& that)
+{
+  //assignment
+  if (this==&that) return *this;
+
+  fCutCentralityPercentile=that.fCutCentralityPercentile;
+  fCentralityPercentileMax=that.fCentralityPercentileMax;
+  fCentralityPercentileMin=that.fCentralityPercentileMin;
+  return *this;
+}
+
+//----------------------------------------------------------------------- 
+Bool_t AliFlowEventSimpleCuts::IsSelected(TObject* obj, TObject* /*mcobj*/)
+{
+  //check cuts
+  AliFlowEventSimple* event = dynamic_cast<AliFlowEventSimple*>(obj);
+  if (!event) return kFALSE;  //when passed wrong type of object
+  Double_t centrality = event->GetCentrality();
+  if (centrality>=fCentralityPercentileMin && centrality<fCentralityPercentileMax)
+    return kTRUE;
+  return kFALSE;
+}
diff --git a/PWG/FLOW/Base/AliFlowEventSimpleCuts.h b/PWG/FLOW/Base/AliFlowEventSimpleCuts.h
new file mode 100644 (file)
index 0000000..b7aed28
--- /dev/null
@@ -0,0 +1,38 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. */
+/* See cxx source for full Copyright notice */
+/* $Id$ */
+
+// AliFlowEventSimpleCuts:
+// An event cut base class
+// origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
+
+#ifndef ALIFLOWEVENTSIMPLECUTS_H
+#define ALIFLOWEVENTSIMPLECUTS_H
+
+#include "TNamed.h"
+
+class AliFlowEventSimpleCuts : public TNamed {
+
+ public:
+  AliFlowEventSimpleCuts();
+  AliFlowEventSimpleCuts(const char* name, const char* title = "AliFlowEventSimpleCuts");
+  AliFlowEventSimpleCuts(const AliFlowEventSimpleCuts& someCuts);
+  AliFlowEventSimpleCuts& operator=(const AliFlowEventSimpleCuts& someCuts);
+  virtual  ~AliFlowEventSimpleCuts();
+  
+  virtual Bool_t IsSelected(TObject* obj, TObject* mcobj);
+  virtual void SetCentralityPercentileRange(Float_t min, Float_t max){ fCentralityPercentileMin=min;
+                                                               fCentralityPercentileMax=max;
+                                                               fCutCentralityPercentile=kTRUE; }
+
+ protected:
+  Bool_t fCutCentralityPercentile; //cut on centrality perc. from AliESDCentrality
+  Float_t fCentralityPercentileMax; // max centr. perc
+  Float_t fCentralityPercentileMin; // min centr. perc
+
+  ClassDef(AliFlowEventSimpleCuts,1)
+};
+
+#endif
+
+
index da8ed0155f961e4b16d6ce0178518562b035520b..07a14626733b7fca1204921d1a00a6f8f5d8cbec 100644 (file)
@@ -76,7 +76,7 @@ AliFlowEventStar::AliFlowEventStar( const AliStarEvent* starevent,
     {
       Bool_t pass = rpCuts->PassesCuts(startrack);
       flowtrack->TagRP(pass); //tag RPs
-      if (pass) fNumberOfRPs++;
+      if (pass) IncrementNumberOfPOIs(0);
     }
     if (poiCuts)
     {
index 90c8954865b52383cb2544de4ef7ef58f3090574..1cb219ac94b947d94ab975b876282a9579cc8819 100644 (file)
@@ -40,7 +40,7 @@ AliFlowTrackSimple::AliFlowTrackSimple():
   fTrackWeight(1.),
   fCharge(0),
   fMass(-1),
-  fFlowBits(0),
+  fPOItype(0),
   fSubEventBits(0),
   fID(-1)
 {
@@ -56,7 +56,7 @@ AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt,
   fTrackWeight(weight),
   fCharge(charge),
   fMass(mass),
-  fFlowBits(0),
+  fPOItype(0),
   fSubEventBits(0),
   fID(-1)
 {
@@ -72,7 +72,7 @@ AliFlowTrackSimple::AliFlowTrackSimple( TParticle* p ):
   fTrackWeight(1.),
   fCharge(0),
   fMass(-1),
-  fFlowBits(0),
+  fPOItype(0),
   fSubEventBits(0),
   fID(-1)
 {
@@ -104,7 +104,7 @@ AliFlowTrackSimple::AliFlowTrackSimple(const AliFlowTrackSimple& aTrack):
   fTrackWeight(aTrack.fTrackWeight),
   fCharge(aTrack.fCharge),
   fMass(aTrack.fMass),
-  fFlowBits(aTrack.fFlowBits),
+  fPOItype(aTrack.fPOItype),
   fSubEventBits(aTrack.fSubEventBits),
   fID(aTrack.fID)
 {
@@ -129,7 +129,7 @@ AliFlowTrackSimple& AliFlowTrackSimple::operator=(const AliFlowTrackSimple& aTra
   fTrackWeight = aTrack.fTrackWeight;
   fCharge = aTrack.fCharge;
   fMass = aTrack.fMass;
-  fFlowBits = aTrack.fFlowBits;
+  fPOItype = aTrack.fPOItype;
   fSubEventBits = aTrack.fSubEventBits;
   fID = aTrack.fID;
 
@@ -377,7 +377,7 @@ void AliFlowTrackSimple::Clear(Option_t*)
   fTrackWeight=1.0;
   fCharge=0;
   fMass=-1;
-  fFlowBits.ResetAllBits();
+  fPOItype.ResetAllBits();
   fSubEventBits.ResetAllBits();
   fID=-1;
 }
index 155a5a30c015a61f3085cc69225df1aa7dee9ff5..f1b39219a36dade2941bf470338675133cb07f33 100644 (file)
@@ -17,7 +17,7 @@ class TParticle;
 class AliFlowTrackSimple: public TObject {
 
 public:
-  enum tagType { kInvalid=-1,
+  enum poiTypes { kInvalid=-1,
                  kRP=0,
                  kPOI=1,
                  kPOI1=2,
@@ -46,9 +46,18 @@ public:
   Int_t PID() const {return 0;}
   
   Bool_t InRPSelection() const; 
-  Bool_t InPOISelection() const; 
+  Bool_t InPOISelection(Int_t poiType=1) const; 
+  Bool_t IsPOItype(Int_t poiType) const;
+  void SetPOItype(Int_t poiType, Bool_t b=kTRUE);
   Bool_t InSubevent(Int_t i) const;
-  Bool_t IsDead() const {return (fFlowBits.CountBits()==0);}
+  void TagRP(Bool_t b=kTRUE) {SetForRPSelection(b);} 
+  void TagPOI(Bool_t b=kTRUE) {SetForPOISelection(b);} 
+  void Tag(Int_t n, Bool_t b=kTRUE) {fPOItype.SetBitNumber(n,b);}
+  Bool_t CheckTag(Int_t n) {return fPOItype.TestBitNumber(n);}
+  void SetForSubevent(Int_t i); 
+  void ResetPOItype() {fPOItype.ResetAllBits();}
+  void ResetSubEventTags() {fSubEventBits.ResetAllBits();}
+  Bool_t IsDead() const {return (fPOItype.CountBits()==0);}
       
   void SetEta(Double_t eta);
   void SetPt(Double_t pt); 
@@ -58,14 +67,7 @@ public:
   void SetMass(Double_t mass);
   void SetForRPSelection(Bool_t b=kTRUE); 
   void SetForPOISelection(Bool_t b=kTRUE); 
-  void TagRP(Bool_t b=kTRUE) {SetForRPSelection(b);} 
-  void TagPOI(Bool_t b=kTRUE) {SetForPOISelection(b);} 
-  void Tag(Int_t n, Bool_t b=kTRUE) {fFlowBits.SetBitNumber(n,b);}
-  void CheckTag(Int_t n) {fFlowBits.TestBitNumber(n);}
-  void SetForSubevent(Int_t i); 
-  void ResetFlowTags() {fFlowBits.ResetAllBits();}
-  void ResetSubEventTags() {fSubEventBits.ResetAllBits();}
-  void Clear(Option_t* o="");
+  virtual void Clear(Option_t* o="");
   
   void ResolutionPt(Double_t resolution);
 
@@ -117,20 +119,27 @@ public:
                 Double_t precision,
                 Int_t maxNumberOfIterations=100 );
 
-  const TBits* GetFlowBits() const {return &fFlowBits;}
+  const TBits* GetPOItype() const {return &fPOItype;}
+  const TBits* GetFlowBits() const {return GetPOItype();}
 
   void  SetID(Int_t i) {fID=i;}
   Int_t GetID() const {return fID;}
 
+  virtual Int_t GetNDaughters() const {return 0;}
+  virtual void  AddDaughter(Int_t /*value*/) {}
+  virtual Int_t GetIDDaughter(Int_t /*value*/) const {return 0;}
+  virtual void SetDaughter(Int_t /*value*/, AliFlowTrackSimple* /*track*/) {}
+  virtual AliFlowTrackSimple *GetDaughter(Int_t /*value*/) const {return NULL;}
+
  private:
   AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge, Double_t mass=-1);
   Double_t fEta;         // eta
   Double_t fPt;          // pt
   Double_t fPhi;         // phi
   Double_t fTrackWeight; // weight
-  Int_t fCharge;         //charge
+  Int_t    fCharge;      //charge
   Double_t fMass;        // mass
-  TBits    fFlowBits;    // bits to set if track is selected
+  TBits    fPOItype;    // bits to set if track is selected
   TBits    fSubEventBits;// bits to set if track is selected for a subevent
   Int_t    fID;          // Unique track ID, point back to the ESD track
 
@@ -153,9 +162,11 @@ inline Double_t AliFlowTrackSimple::Mass() const {
   return this->fMass; }
 //TBits
 inline Bool_t AliFlowTrackSimple::InRPSelection() const { 
-  return this->fFlowBits.TestBitNumber(kRP); }
-inline Bool_t AliFlowTrackSimple::InPOISelection() const { 
-  return this->fFlowBits.TestBitNumber(kPOI); }
+  return fPOItype.TestBitNumber(kRP); }
+inline Bool_t AliFlowTrackSimple::InPOISelection(Int_t poiType) const { 
+  return fPOItype.TestBitNumber(poiType); }
+inline Bool_t AliFlowTrackSimple::IsPOItype(Int_t poiType) const {
+  return fPOItype.TestBitNumber(poiType); }
 inline Bool_t AliFlowTrackSimple::InSubevent(Int_t i) const { 
   return this->fSubEventBits.TestBitNumber(i); }
 
@@ -172,13 +183,17 @@ inline void AliFlowTrackSimple::SetCharge(Int_t val) {
   fCharge = val; }
 inline void AliFlowTrackSimple::SetMass(Double_t val) {
   fMass = val; }
-//TBits
+
+  //TBits
 inline void AliFlowTrackSimple::SetForRPSelection(Bool_t val) {
-  fFlowBits.SetBitNumber(kRP,val); }
+  fPOItype.SetBitNumber(kRP,val); }
 inline void AliFlowTrackSimple::SetForPOISelection(Bool_t val) {
-  fFlowBits.SetBitNumber(kPOI,val); }
+  fPOItype.SetBitNumber(kPOI,val); }
 inline void AliFlowTrackSimple::SetForSubevent(Int_t i) {
   fSubEventBits.SetBitNumber(i,kTRUE); }
 
+inline void AliFlowTrackSimple::SetPOItype(Int_t poiType, Bool_t b) {
+  fPOItype.SetBitNumber(poiType,b); }
+
 #endif
 
index 15b728d4a2d0980aa88f279268759ea432691459..6d3ff12d50e1ea59e98dbf6debe0b83a883b119b 100644 (file)
@@ -50,7 +50,8 @@ AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const char* name):
   fCharge(0),
   fCutMass(kFALSE),
   fMassMax(FLT_MAX),
-  fMassMin(-FLT_MAX)
+  fMassMin(-FLT_MAX),
+  fPOItype(1)
 {
   //constructor 
 }
index 805bfd9a3f09e2855df00dbd2c9adca5377b844a..9a82cc08be140e715764e25004db4a31b36e9ade 100644 (file)
@@ -52,6 +52,9 @@ class AliFlowTrackSimpleCuts : public TNamed {
   Bool_t PassesCuts(const AliFlowTrackSimple *track) const;
   Bool_t PassesCuts(TParticle* p) const;
 
+  Int_t GetPOItype() const {return fPOItype;}
+  void SetPOItype(Int_t t) {fPOItype=t;}
+
   virtual Bool_t IsSelected(TObject* obj, Int_t id=-1);
 
  protected:
@@ -71,6 +74,7 @@ class AliFlowTrackSimpleCuts : public TNamed {
   Bool_t   fCutMass; // cut on mass?
   Double_t fMassMax; //max mass
   Double_t fMassMin; //min mass
+  Int_t    fPOItype; //which poi type do we produce? (RP=0, POI=1,2,3,4,5...)
 
   ClassDef(AliFlowTrackSimpleCuts,2)
 };
index 1084999c92aacdcb243eec9db4a9e759f443a7e9..8242451d220ad7620d3701abd6d1e319707f38c3 100644 (file)
 **************************************************************************/
 
 #include "AliFlowVector.h"
+#include "AliFlowTrackSimple.h"
+#include "TMath.h"
 
 //********************************************************************
 // AliFlowVector:                                                    *
 // Class to hold the flow vector and multiplicity for flow analysis. *
 // Author: A. Bilandzic (anteb@nikhef.nl)                            *
+// extended: M.Krzewicki (mikolaj.krzewicki@cern.ch)                 *
 //********************************************************************
 
 ClassImp(AliFlowVector)
@@ -26,7 +29,11 @@ ClassImp(AliFlowVector)
 //________________________________________________________________________
 
 AliFlowVector::AliFlowVector():
- TVector2(0.0,0.0),fMult(0.0)
+  TVector2(0.0,0.0),
+  fMult(0.0),
+  fHarmonic(2),
+  fPOItype(0),
+  fSubeventNumber(-1)
 {
   // default constructor
 }
@@ -35,34 +42,46 @@ AliFlowVector::AliFlowVector():
 
 AliFlowVector::AliFlowVector(const AliFlowVector& aVector):
   TVector2(aVector),
-  fMult(aVector.fMult)
+  fMult(aVector.fMult),
+  fHarmonic(aVector.fHarmonic),
+  fPOItype(aVector.fPOItype),
+  fSubeventNumber(aVector.fSubeventNumber)
 {
   // copy constructor
 }
 
 //________________________________________________________________________
 
-AliFlowVector::AliFlowVector(Double_t *y, Double_t m):
+AliFlowVector::AliFlowVector(Double_t *y, Double_t m, Int_t h, Int_t t, Int_t s):
   TVector2(y),
-  fMult(m)
+  fMult(m),
+  fHarmonic(h),
+  fPOItype(t),
+  fSubeventNumber(s)
 {
   // Analogue of TVector2 constructor. Sets (x,y) and multiplicity 1.
 }
 
  //________________________________________________________________________
 
-AliFlowVector::AliFlowVector(const TVector2 &v, Double_t m):
+AliFlowVector::AliFlowVector(const TVector2 &v, Double_t m, Int_t h, Int_t t, Int_t s):
   TVector2(v),
-  fMult(m)
+  fMult(m),
+  fHarmonic(h),
+  fPOItype(t),
+  fSubeventNumber(s)
 {
   // custom constructor, Sets vector and multiplicity
 }
 
  //________________________________________________________________________
 
-AliFlowVector::AliFlowVector(Double_t x, Double_t y, Double_t m):
+AliFlowVector::AliFlowVector(Double_t x, Double_t y, Double_t m, Int_t h, Int_t t, Int_t s):
   TVector2(x,y),
-  fMult(m)
+  fMult(m),
+  fHarmonic(h),
+  fPOItype(t),
+  fSubeventNumber(s)
 {
   // custom constructor analogue of TVector2 constructor
 }
@@ -74,7 +93,7 @@ AliFlowVector::~AliFlowVector()
   // default destructor 
 }
 
-void AliFlowVector::SetMagPhi(double size, double angle, double mult)
+void AliFlowVector::SetMagPhi(Double_t size, Double_t angle, Double_t mult)
 {
    // Analogue to SetMagPhi for a TVector2 but here including a sum of weights
    TVector2::SetMagPhi(size,angle);
@@ -113,7 +132,7 @@ AliFlowVector& AliFlowVector::operator-=(const AliFlowVector& aVector)
   return *this;
 }
 
-AliFlowVector& AliFlowVector::operator*=(double w)
+AliFlowVector& AliFlowVector::operator*=(Double_t w)
 {
    // multiply by a weight operator
    fX*=w;
@@ -121,3 +140,56 @@ AliFlowVector& AliFlowVector::operator*=(double w)
    fMult*=w;
    return *this;
 }
+
+//________________________________________________________________________
+void AliFlowVector::Clear(Option_t* /*option*/)
+{
+  //clear
+  fX=0.;
+  fY=0.;
+  fMult=0;
+  fHarmonic=2;
+  fPOItype=AliFlowTrackSimple::kRP;
+  fSubeventNumber=-1;
+}
+
+//________________________________________________________________________
+Int_t AliFlowVector::SubtractTrackWithDaughters( const AliFlowTrackSimple* track, 
+                                                Double_t extraWeight 
+                                              )
+{
+  //subtract a track and all its daughters, only if tagged with flowTag and in specified
+  //subevent (-1 for no subevent selection)
+  //to only subtract if it was actually used in the construction of the vector)
+  //TODO: maybe make recursive if it ever becomes needed
+  //for complicated decay topologies
+  Bool_t inSubEvent=kTRUE;
+  if (fSubeventNumber>=0) 
+  {
+    inSubEvent = track->InSubevent(fSubeventNumber);
+  }
+  if (track->IsPOItype(fPOItype) && inSubEvent )
+  {
+    fX -= extraWeight * track->Weight() * TMath::Cos(fHarmonic*track->Phi());
+    fY -= extraWeight * track->Weight() * TMath::Sin(fHarmonic*track->Phi());
+  }
+  
+  Int_t numberOfsubtractedDaughters=0;
+  for (Int_t i=0; i<track->GetNDaughters(); i++)
+  {
+    AliFlowTrackSimple* daughter = track->GetDaughter(i);
+    if (!daughter) continue;
+    inSubEvent=kTRUE;
+    if (fSubeventNumber>=0) 
+    {
+      inSubEvent = daughter->InSubevent(fSubeventNumber);
+    }
+    if (daughter->IsPOItype(fPOItype) && inSubEvent )
+    {
+      fX -= extraWeight * daughter->Weight() * TMath::Cos(fHarmonic*daughter->Phi());
+      fY -= extraWeight * daughter->Weight() * TMath::Sin(fHarmonic*daughter->Phi());
+      numberOfsubtractedDaughters++;
+    }
+  }
+  return numberOfsubtractedDaughters;
+}
diff --git a/PWG/FLOW/Base/AliFlowVector.cxx.orig b/PWG/FLOW/Base/AliFlowVector.cxx.orig
new file mode 100644 (file)
index 0000000..1084999
--- /dev/null
@@ -0,0 +1,123 @@
+/*************************************************************************
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  * 
+**************************************************************************/
+
+#include "AliFlowVector.h"
+
+//********************************************************************
+// AliFlowVector:                                                    *
+// Class to hold the flow vector and multiplicity for flow analysis. *
+// Author: A. Bilandzic (anteb@nikhef.nl)                            *
+//********************************************************************
+
+ClassImp(AliFlowVector)
+
+//________________________________________________________________________
+
+AliFlowVector::AliFlowVector():
+ TVector2(0.0,0.0),fMult(0.0)
+{
+  // default constructor
+}
+
+//________________________________________________________________________
+
+AliFlowVector::AliFlowVector(const AliFlowVector& aVector):
+  TVector2(aVector),
+  fMult(aVector.fMult)
+{
+  // copy constructor
+}
+
+//________________________________________________________________________
+
+AliFlowVector::AliFlowVector(Double_t *y, Double_t m):
+  TVector2(y),
+  fMult(m)
+{
+  // Analogue of TVector2 constructor. Sets (x,y) and multiplicity 1.
+}
+
+ //________________________________________________________________________
+
+AliFlowVector::AliFlowVector(const TVector2 &v, Double_t m):
+  TVector2(v),
+  fMult(m)
+{
+  // custom constructor, Sets vector and multiplicity
+}
+
+ //________________________________________________________________________
+
+AliFlowVector::AliFlowVector(Double_t x, Double_t y, Double_t m):
+  TVector2(x,y),
+  fMult(m)
+{
+  // custom constructor analogue of TVector2 constructor
+}
+
+//________________________________________________________________________ 
+
+AliFlowVector::~AliFlowVector()
+{
+  // default destructor 
+}
+
+void AliFlowVector::SetMagPhi(double size, double angle, double mult)
+{
+   // Analogue to SetMagPhi for a TVector2 but here including a sum of weights
+   TVector2::SetMagPhi(size,angle);
+   SetMult(mult);
+}
+
+//________________________________________________________________________
+
+AliFlowVector& AliFlowVector::operator=(const AliFlowVector& aVector)
+{
+  // assignement operator
+  if (this==&aVector) return *this;
+  fX = aVector.X();
+  fY = aVector.Y();
+  fMult = aVector.GetMult();
+  return *this;
+}
+
+//________________________________________________________________________
+
+AliFlowVector& AliFlowVector::operator+=(const AliFlowVector& aVector)
+{
+  // addition operator
+  fX += aVector.X(); 
+  fY += aVector.Y(); 
+  fMult += aVector.GetMult(); 
+  return *this;
+}
+
+AliFlowVector& AliFlowVector::operator-=(const AliFlowVector& aVector)
+{
+  // subtraction operator
+  fX -= aVector.X(); 
+  fY -= aVector.Y(); 
+  fMult -= aVector.GetMult();
+  return *this;
+}
+
+AliFlowVector& AliFlowVector::operator*=(double w)
+{
+   // multiply by a weight operator
+   fX*=w;
+   fY*=w;
+   fMult*=w;
+   return *this;
+}
index 1af3d9395b7ae08d30453243487719b1e8013bbc..c6f35208ba641d9ea90c75ce4809d0ed0c435001 100644 (file)
@@ -6,20 +6,22 @@
 #define ALIFLOWVECTOR_H
 
 #include "TVector2.h"
+#include "AliFlowTrackSimple.h"
 
 //********************************************************************
 // AliFlowVector:                                                    *
 // Class to hold the flow vector and multiplicity for flow analysis. *
 // Author: A. Bilandzic (anteb@nikhef.nl)                            *
 //********************************************************************
+class AliFlowTrackSimple;
 
 class AliFlowVector: public TVector2 {
  public:
   AliFlowVector();
   AliFlowVector(const AliFlowVector& aVector);
-  AliFlowVector(const TVector2 &p, Double_t m);                      // constructor: Add a weight to the TVector
-  AliFlowVector(Double_t *y, Double_t m=1);                          // constructor: Analogue to TVector2(y) with multiplicity
-  AliFlowVector(Double_t x, Double_t y, Double_t m=1);   // constructor: Sets the components individually
+  AliFlowVector(const TVector2 &p, Double_t m, Int_t h=2, Int_t poiType=0, Int_t s=1);                      // constructor: Add a weight to the TVector
+  AliFlowVector(Double_t *y, Double_t m=1, Int_t h=2, Int_t poiType=0, Int_t s=-1);                          // constructor: Analogue to TVector2(y) with multiplicity
+  AliFlowVector(Double_t x, Double_t y, Double_t m=1, Int_t h=2, Int_t poiType=0, Int_t s=-1);               // constructor: Sets the components individually
   virtual ~AliFlowVector();
 
   void SetMagPhi(Double_t size, Double_t angle, Double_t mult=1);          // Set vector and weighted multiplicity
@@ -27,22 +29,36 @@ class AliFlowVector: public TVector2 {
   AliFlowVector& operator=(const AliFlowVector& aVector);                        // Assign to self
   AliFlowVector& operator+=(const AliFlowVector& aVector);                       // Add to self
   AliFlowVector& operator-=(const AliFlowVector& aVector);                       // Subtract from self
-  AliFlowVector& operator*=(double w);                                     // Multiply by a weight
-  AliFlowVector& operator/=(double w){ (*this)*=(1.0/w); return *this;};      // Divide by a weight
+  AliFlowVector& operator*=(Double_t w);                                     // Multiply by a weight
+  AliFlowVector& operator/=(Double_t w){ (*this)*=(1.0/w); return *this;};      // Divide by a weight
   const AliFlowVector operator+(const AliFlowVector&a) const { AliFlowVector v(*this); return v+=a; };   // Add and return by value
   const AliFlowVector operator-(const AliFlowVector&a) const { AliFlowVector v(*this); return v-=a; };   // Subtract and return by value
-  const AliFlowVector operator*(double w) const { AliFlowVector v(*this); return v*=w; };          // Scale and return by value
-  const AliFlowVector operator/(double w) const { AliFlowVector v(*this); return v/=w; };          // Scale and return by value
+  const AliFlowVector operator*(Double_t w) const { AliFlowVector v(*this); return v*=w; };          // Scale and return by value
+  const AliFlowVector operator/(Double_t w) const { AliFlowVector v(*this); return v/=w; };          // Scale and return by value
+
+  Int_t SubtractTrackWithDaughters( const AliFlowTrackSimple* track,
+                                   Double_t extraWeight=1.
+                                 );  //subtract a track with all its daughters
 
   Bool_t  IsFolder() const {return kTRUE;};
 
   void SetMult(Double_t mult) {fMult = mult;};           // Set sum of weights
   Double_t GetMult() const {return fMult;};                    // Get sum of weights
+  void SetHarmonic(Int_t h) {fHarmonic = h;}             //set the harmonic
+  Int_t GetHarmonic() const {return fHarmonic;}          //get the harmonic
+  void SetPOItype(Int_t t) {fPOItype=t;}
+  Int_t GetPOItype() const {return fPOItype;}
+  void SetSubeventNumber(Int_t n) {fSubeventNumber=n;}
+  Int_t GetSubeventNumber() const {return fSubeventNumber;}
+  void Clear(Option_t* option="");
         
  private:
   Double_t fMult;                 // multiplicity = sum of weights = w_1 + w_2 + ... + w_n
+  Int_t fHarmonic;                // harmonic for which the vector is constructed
+  Int_t fPOItype;             //which tracks are used to construct? RP=0, POIn=n,...
+  Int_t fSubeventNumber;          //for which subevent is this vector constructed? (-1 for no subevent in particular)
    
-  ClassDef(AliFlowVector, 1
+  ClassDef(AliFlowVector, 2
 };
 
 
diff --git a/PWG/FLOW/Base/AliFlowVector.h.orig b/PWG/FLOW/Base/AliFlowVector.h.orig
new file mode 100644 (file)
index 0000000..1af3d93
--- /dev/null
@@ -0,0 +1,75 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice */
+/* $Id$ */
+
+#ifndef ALIFLOWVECTOR_H
+#define ALIFLOWVECTOR_H
+
+#include "TVector2.h"
+
+//********************************************************************
+// AliFlowVector:                                                    *
+// Class to hold the flow vector and multiplicity for flow analysis. *
+// Author: A. Bilandzic (anteb@nikhef.nl)                            *
+//********************************************************************
+
+class AliFlowVector: public TVector2 {
+ public:
+  AliFlowVector();
+  AliFlowVector(const AliFlowVector& aVector);
+  AliFlowVector(const TVector2 &p, Double_t m);                      // constructor: Add a weight to the TVector
+  AliFlowVector(Double_t *y, Double_t m=1);                          // constructor: Analogue to TVector2(y) with multiplicity
+  AliFlowVector(Double_t x, Double_t y, Double_t m=1);   // constructor: Sets the components individually
+  virtual ~AliFlowVector();
+
+  void SetMagPhi(Double_t size, Double_t angle, Double_t mult=1);          // Set vector and weighted multiplicity
+
+  AliFlowVector& operator=(const AliFlowVector& aVector);                        // Assign to self
+  AliFlowVector& operator+=(const AliFlowVector& aVector);                       // Add to self
+  AliFlowVector& operator-=(const AliFlowVector& aVector);                       // Subtract from self
+  AliFlowVector& operator*=(double w);                                     // Multiply by a weight
+  AliFlowVector& operator/=(double w){ (*this)*=(1.0/w); return *this;};      // Divide by a weight
+  const AliFlowVector operator+(const AliFlowVector&a) const { AliFlowVector v(*this); return v+=a; };   // Add and return by value
+  const AliFlowVector operator-(const AliFlowVector&a) const { AliFlowVector v(*this); return v-=a; };   // Subtract and return by value
+  const AliFlowVector operator*(double w) const { AliFlowVector v(*this); return v*=w; };          // Scale and return by value
+  const AliFlowVector operator/(double w) const { AliFlowVector v(*this); return v/=w; };          // Scale and return by value
+
+  Bool_t  IsFolder() const {return kTRUE;};
+
+  void SetMult(Double_t mult) {fMult = mult;};           // Set sum of weights
+  Double_t GetMult() const {return fMult;};                    // Get sum of weights
+        
+ private:
+  Double_t fMult;                 // multiplicity = sum of weights = w_1 + w_2 + ... + w_n
+   
+  ClassDef(AliFlowVector, 1) 
+};
+
+
+/* Old, less efficient code
+inline  AliFlowVector operator+(const AliFlowVector& aVector,const AliFlowVector& bVector) {
+  AliFlowVector cVector;
+  Double_t x = aVector.X() + bVector.X(); 
+  Double_t y = aVector.Y() + bVector.Y(); 
+  Double_t mult = aVector.GetMult() + bVector.GetMult();
+  cVector.Set(x,y);
+  cVector.SetMult(mult);
+  
+  return cVector;
+}
+
+inline  AliFlowVector operator-(const AliFlowVector& aVector,const AliFlowVector& bVector) 
+{
+   // Difference between two vectors
+  AliFlowVector cVector;
+  Double_t x = aVector.X() - bVector.X(); 
+  Double_t y = aVector.Y() - bVector.Y(); 
+  Double_t mult = aVector.GetMult() - bVector.GetMult();
+  cVector.Set(x,y);
+  cVector.SetMult(mult);
+  
+  return cVector;
+}
+*/
+
+#endif
index e678dcc97c2a2c74c40650b108f5b8b02204e399..c9461d10ce304dfea31fa704f985f9cf42f2991e 100644 (file)
@@ -336,6 +336,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
 
     //    if (myESD)
     fFlowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent(),mcEvent));
+    fFlowEvent->SetCentrality(fCutsEvent->GetCentrality(InputEvent(),mcEvent));
     if (mcEvent && mcEvent->GenEventHeader()) fFlowEvent->SetMCReactionPlaneAngle(mcEvent);
   }
 
@@ -563,6 +564,9 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
   //do we want to serve shullfed tracks to everybody?
   fFlowEvent->SetShuffleTracks(fShuffleTracks);
 
+  // associate the mother particles to their daughters in the flow event (if any)
+  fFlowEvent->FindDaughters();
+
   //fListHistos->Print();
   //fOutputFile->WriteObject(fFlowEvent,"myFlowEventSimple");
   PostData(1,fFlowEvent);
index b2d9285531fba691d2bfb5e6dcdb155b84527ca8..9ed59b2c720c8204c7cb1cfa54bc438c51cdcf6d 100644 (file)
@@ -60,9 +60,9 @@ class AliAnalysisTaskFlowEvent : public AliAnalysisTaskSE {
 
   void          SetCutsEvent(AliFlowEventCuts* cutsEvent) {fCutsEvent=cutsEvent;}
   AliFlowEventCuts* GetCutsEvent() const {return fCutsEvent;}
-  void          SetCutsRP(AliFlowTrackCuts* cutsRP) {fCutContainer->Add(cutsRP); fCutsRP=cutsRP; cutsRP->SetFlowTagType(AliFlowTrackSimple::kRP);}
+  void          SetCutsRP(AliFlowTrackCuts* cutsRP) {fCutContainer->AddAt(cutsRP,0); fCutsRP=cutsRP; cutsRP->SetPOItype(0); }
   AliFlowTrackCuts* GetCutsRP() const {return fCutsRP;} //to be reimplemented
-  void          SetCutsPOI(AliFlowTrackCuts* cutsPOI) {fCutContainer->Add(cutsPOI); fCutsPOI=cutsPOI; cutsPOI->SetFlowTagType(AliFlowTrackSimple::kPOI);}
+  void          SetCutsPOI(AliFlowTrackCuts* cutsPOI) {fCutContainer->AddAt(cutsPOI,1); fCutsPOI=cutsPOI; cutsPOI->SetPOItype(1); }
   AliFlowTrackCuts* GetCutsPOI() const {return fCutsPOI;} //to be reimplemented
 
   void          SetCFManager1(AliCFManager* cfmgr) {this->fCFManager1 = cfmgr; } 
index 896e6b347e0a63be40532ad3a5d192cef60a7002..8a37bc07c2f90bb3041851b50883c14c6718c130 100644 (file)
@@ -167,7 +167,7 @@ void AliAnalysisTaskScalarProduct::UserExec(Option_t *)
 
   fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
   if (fEvent){
-    fSP->Make(fEvent);
+    fSP->ProcessEvent(fEvent);
   }
   else {
     cout << "Warning no input data for Scalar Product task!!!" << endl;
index 4f797cc05ccae50597df9a31a8399fd6306ef573..06e86f3971c3a356248255c03e136d87f9403d2d 100644 (file)
@@ -35,7 +35,7 @@ AliFlowCandidateTrack::AliFlowCandidateTrack():
 }
 
 void AliFlowCandidateTrack::ClearMe(void) {
-  AliFlowTrackSimple::Clear();
+  AliFlowTrack::Clear();
   fNDaughters = 0;
   for(int i=0; i!=5; ++i) {
     fDaughter[i] = -1;
index 517261634d36f633d9b0c92ef91bd0dce63ffa6f..6e2b4a3e839286396114c4ee89cf3e364968c1b4 100644 (file)
@@ -21,17 +21,19 @@ class AliFlowCandidateTrack : public AliFlowTrack {
     ~AliFlowCandidateTrack();
 
     void ClearMe(void);
+    virtual void Clear(Option_t* /*o=""*/) {ClearMe();}
+
     Int_t GetNDaughters(void)        const { return fNDaughters; }
     void  AddDaughter(Int_t value)  { if(fNDaughters<3) fDaughter[fNDaughters++]=value; }
     Int_t GetIDDaughter(Int_t value) const { return fDaughter[value]; }
 
-    void SetDaughter(Int_t value, AliFlowTrack *track) { fTrack[value]=track; }
-    AliFlowTrack *GetDaughter(Int_t value) const { return fTrack[value]; }
+    void SetDaughter(Int_t value, AliFlowTrackSimple *track) { fTrack[value]=track; }
+    AliFlowTrackSimple *GetDaughter(Int_t value) const { return fTrack[value]; }
 
   protected:
     Int_t fNDaughters;        // number of daughters (5 max)
     Int_t fDaughter[5];       // fID of daughter, points back to ESD track
-    AliFlowTrack *fTrack[5];  //! pointer to daughter in FlowEvent
+    AliFlowTrackSimple *fTrack[5];  //! pointer to daughter in FlowEvent
 
     ClassDef(AliFlowCandidateTrack, 2);
 };
index 3e5e8cc688498ee5daf0e9c59a7f913b1d4032c3..14e0013ed527934f85f55780a50f827e617ec348 100644 (file)
@@ -53,7 +53,7 @@ ClassImp(AliFlowEvent)
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent():
-  AliFlowEventSimple(), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -66,14 +66,13 @@ AliFlowEvent::AliFlowEvent():
             }
         }
     }
-
   //ctor
   cout << "AliFlowEvent: Default constructor to be used only by root for io" << endl;
 }
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent(Int_t n):
-  AliFlowEventSimple(n), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(n), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -90,7 +89,7 @@ AliFlowEvent::AliFlowEvent(Int_t n):
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
-  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // copy constructor 
     for(Int_t i(0); i < 9; i++) {
@@ -108,13 +107,12 @@ AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
 //-----------------------------------------------------------------------
 AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)
 {
-
   //assignment operator
   if (&event==this) return *this;       // check self-assignment
 
   fApplyRecentering = event.fApplyRecentering; 
   fCachedRun = event.fCachedRun; 
-  fCurrentCentrality = event.fCurrentCentrality;
+  fVZEROcentralityBin = event.fVZEROcentralityBin;
   for(Int_t i(0); i < 9; i++) {
       for(Int_t j(0); j < 2; j++) {
           for(Int_t k(0); k < 2; k++) {
@@ -199,7 +197,7 @@ void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)
 AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -212,7 +210,6 @@ AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
             }
         }
     }
-
   //Fills the event from the MC kinematic information
 
   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
@@ -240,12 +237,12 @@ AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
     if (rpOK && rpCFManager)
     {
       pTrack->SetForRPSelection(kTRUE);
-      fNumberOfRPs++;
+      IncrementNumberOfPOIs(0);
     }
     if (poiOK && poiCFManager)
     {
       pTrack->SetForPOISelection(kTRUE);
-      fNumberOfPOIs++;
+      IncrementNumberOfPOIs(1);
     }
 
     AddTrack(pTrack) ;
@@ -257,7 +254,7 @@ AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20),  fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20),  fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -300,13 +297,13 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
     if(rpOK && rpCFManager)
     {
       pTrack->SetForRPSelection(kTRUE);
-      fNumberOfRPs++;
+      IncrementNumberOfPOIs(0);
     }
     //marking the particles used for diff. flow:
     if(poiOK && poiCFManager)
     {
       pTrack->SetForPOISelection(kTRUE);
-      fNumberOfPOIs++;
+      IncrementNumberOfPOIs(1);
     }
 
     AddTrack(pTrack);
@@ -317,7 +314,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -330,7 +327,6 @@ AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
             }
         }
     }
-
   //Fills the event from the AOD
   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
 
@@ -358,12 +354,12 @@ AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
     if (rpOK /* && rpCFManager */ ) // to be fixed - with CF managers uncommented only empty events (NULL in header files)
     {
       pTrack->SetForRPSelection(kTRUE);
-      fNumberOfRPs++;
+      IncrementNumberOfPOIs(0);
     }
     if (poiOK /* && poiCFManager*/ )
     {
       pTrack->SetForPOISelection(kTRUE);
-      fNumberOfPOIs++;
+      IncrementNumberOfPOIs(1);
     }
     AddTrack(pTrack);
   }
@@ -401,7 +397,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                             KineSource anOption,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -414,7 +410,6 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
             }
         }
     }
-
   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
   if (anOption==kNoKine)
   {
@@ -482,12 +477,12 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 
     if (rpOK && rpCFManager)
     {
-      fNumberOfRPs++;
+      IncrementNumberOfPOIs(0);
       pTrack->SetForRPSelection();
     }
     if (poiOK && poiCFManager) 
     { 
-      fNumberOfPOIs++;
+      IncrementNumberOfPOIs(1);
       pTrack->SetForPOISelection();
     }
 
@@ -500,7 +495,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const AliMultiplicity* anInputTracklets,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -514,7 +509,6 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
         }
     }
 
-
   //Select the particles of interest from the ESD
   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
 
@@ -538,7 +532,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
        {
-          fNumberOfPOIs++;
+          IncrementNumberOfPOIs(1);
          pTrack->SetForPOISelection(kTRUE);
          pTrack->SetSource(AliFlowTrack::kFromESD);
        }
@@ -563,7 +557,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
     pTrack->SetEta(etaTr);
     pTrack->SetPhi(phiTr);
     //marking the particles used for the reference particle (RP) selection:
-    fNumberOfRPs++;
+    IncrementNumberOfPOIs(0);
     pTrack->SetForRPSelection(kTRUE);
     pTrack->SetSource(AliFlowTrack::kFromTracklet);
 
@@ -577,7 +571,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
                            const AliCFManager* poiCFManager,
                             Bool_t hybrid):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -591,7 +585,6 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
         }
     }
 
-
   //Select the particles of interest from the ESD
   Int_t iNumberOfInputTracks = esd->GetNumberOfTracks() ;
 
@@ -653,13 +646,13 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
       if(poiOK && poiCFManager)
       {
         pTrack->SetForPOISelection(kTRUE);
-        fNumberOfPOIs++;
+        IncrementNumberOfPOIs(1);
       }
 
       if(useTPC)
       {
         pTrack->SetForRPSelection(kTRUE);
-        fNumberOfRPs++;
+        IncrementNumberOfPOIs(0);
       }
 
       AddTrack(pTrack);
@@ -672,7 +665,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const TH2F* anInputFMDhist,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -686,7 +679,6 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
         }
     }
 
-
   //Select the particles of interest from the ESD
   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
 
@@ -710,7 +702,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
        {
-          fNumberOfPOIs++; 
+    IncrementNumberOfPOIs(1);
          pTrack->SetForPOISelection(kTRUE);
          pTrack->SetSource(AliFlowTrack::kFromESD);
        }
@@ -738,7 +730,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
        pTrack->SetWeight(weightFMD);
        //marking the particles used for the reference particle (RP) selection:
        pTrack->TagRP();
-       fNumberOfRPs++;
+       IncrementNumberOfPOIs(0);
        pTrack->SetSource(AliFlowTrack::kFromFMD);
 
        //Add the track to the flowevent
@@ -750,6 +742,34 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 
 }
 
+//-----------------------------------------------------------------------
+void AliFlowEvent::FindDaughters(Bool_t keepDaughtersInRPselection)
+{
+  //each flow track holds it's esd track index as well as its daughters esd index.
+  //fill the array of daughters for every track with the pointers to flow tracks
+  //to associate the mothers with daughters directly
+  for (Int_t iTrack=0; iTrack<fMothersCollection->GetEntriesFast(); iTrack++)
+  {
+    AliFlowTrack* mother = static_cast<AliFlowTrack*>(fMothersCollection->At(iTrack));
+    if (!mother) continue;
+    if (mother->GetNDaughters()<1) continue;
+    for (Int_t iDaughterCandidate=0; iDaughterCandidate<fNumberOfTracks; iDaughterCandidate++)
+    {
+      AliFlowTrack* daughterCandidate = static_cast<AliFlowTrack*>(fTrackCollection->At(iDaughterCandidate));
+      Int_t esdIndexDaughterCandidate = daughterCandidate->GetID();
+      for (Int_t iDaughter=0; iDaughter<mother->GetNDaughters(); iDaughter++)
+      {
+        Int_t esdIndexDaughter = mother->GetIDDaughter(iDaughter);
+        if (esdIndexDaughter==esdIndexDaughterCandidate)
+        {
+          mother->SetDaughter(iDaughter,daughterCandidate);
+          daughterCandidate->SetForRPSelection(keepDaughtersInRPselection);
+        }
+      }
+    }
+  }
+}
+
 //-----------------------------------------------------------------------
 void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
                          AliFlowTrackCuts* poiCuts )
@@ -769,52 +789,36 @@ void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
   AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
   AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
   AliFlowTrack* pTrack=NULL;
-  
-  // if the source for rp's or poi's is the VZERO detector, get the calibration 
-  // and set the calibration parameters
-  if (sourceRP == AliFlowTrackCuts::kV0 || sourceRP == AliFlowTrackCuts::kVZERO) {
-      SetVZEROCalibrationForTrackCuts(rpCuts);
-//      for now, recentering is only applied if the user specifically asks for it
-//      by setting the flag to kTRUE in the ali flow track cuts
-      if(!rpCuts->GetApplyRecentering()) {
-          // if the user does not want to recenter, switch the flag
-          fApplyRecentering = -1;
-      }
-      // note: this flag is used in the overloaded implementation of Get2Qsub()
-      // and tells the function to use as Qsub vectors the recentered Q-vectors
-      // from the VZERO oadb file or from the event header
-  }
-  if (sourcePOI ==AliFlowTrackCuts::kV0 || sourcePOI == AliFlowTrackCuts::kVZERO) {
-      // probably no-one will choose vzero tracks as poi's ...
-      SetVZEROCalibrationForTrackCuts(poiCuts); 
-  }
+
   if (sourceRP==sourcePOI)
   {
     //loop over tracks
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
+    Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObjects; i++)
     {
       //get input object (particle)
       TObject* particle = rpCuts->GetInputObject(i);
 
       Bool_t rp = rpCuts->IsSelected(particle,i);
       Bool_t poi = poiCuts->IsSelected(particle,i);
-      
+
       if (!(rp||poi)) continue;
 
-      //make new AliFLowTrack
+      //make new AliFlowTrack
       if (rp)
       {
-        pTrack = ReuseTrack(fNumberOfTracks);
-        if (!rpCuts->FillFlowTrack(pTrack)) continue;
-        pTrack->TagRP(); fNumberOfRPs++;
-        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}
+        pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
+        if (!pTrack) continue;
+        pTrack->Tag(0); IncrementNumberOfPOIs(0);
+        if (poi) {pTrack->Tag(1); IncrementNumberOfPOIs(1);}
+        if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
       }
       else if (poi)
       {
-        pTrack = ReuseTrack(fNumberOfTracks);
-        if (!poiCuts->FillFlowTrack(pTrack)) continue;
-        pTrack->TagPOI(); fNumberOfPOIs++;
+        pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
+        if (!pTrack) continue;
+        pTrack->Tag(1); IncrementNumberOfPOIs(1);
+        if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
       }
       fNumberOfTracks++;
     }//end of while (i < numberOfTracks)
@@ -823,50 +827,45 @@ void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
   {
     //here we have two different sources of particles, so we fill
     //them independently
-    //RP
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
-      {
-      TObject* particle = rpCuts->GetInputObject(i);
-      Bool_t rp = rpCuts->IsSelected(particle,i);
-      if (!rp) continue;
-      pTrack = ReuseTrack(fNumberOfTracks);
-      if (!rpCuts->FillFlowTrack(pTrack)) continue;
-      pTrack->TagRP();
-      fNumberOfRPs++;
-      fNumberOfTracks++;
-    }
     //POI
-    numberOfInputObject = poiCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
+    for (Int_t i=0; i<poiCuts->GetNumberOfInputObjects(); i++)
     {
       TObject* particle = poiCuts->GetInputObject(i);
       Bool_t poi = poiCuts->IsSelected(particle,i);
       if (!poi) continue;
-      pTrack = ReuseTrack(fNumberOfTracks);
-      if (!poiCuts->FillFlowTrack(pTrack)) continue;
-      pTrack->TagPOI();
-      fNumberOfPOIs++;
+      pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
+      if (!pTrack) continue;
+      pTrack->Tag(1);
+      IncrementNumberOfPOIs(1);
       fNumberOfTracks++;
+      if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
+    }
+    //RP
+    Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObjects; i++)
+      {
+      TObject* particle = rpCuts->GetInputObject(i);
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      if (!rp) continue;
+      pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
+      if (!pTrack) continue;
+      pTrack->Tag(0);
+      IncrementNumberOfPOIs(0);
+      fNumberOfTracks++;
+      if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
     }
   }
 }
 
 //-----------------------------------------------------------------------
-void AliFlowEvent::InsertTrack(AliFlowTrack *thisTrack) {
+void AliFlowEvent::InsertTrack(AliFlowTrack *track) {
   // adds a flow track at the end of the container
   AliFlowTrack *pTrack = ReuseTrack( fNumberOfTracks++ );
-  pTrack->SetPt( thisTrack->Pt() );
-  pTrack->SetPhi( thisTrack->Phi() );
-  pTrack->SetEta( thisTrack->Eta() );
-  pTrack->SetWeight( thisTrack->Weight() );
-  pTrack->SetCharge( thisTrack->Charge() );
-  pTrack->SetMass( thisTrack->Mass() );
-  pTrack->SetForRPSelection( thisTrack->InRPSelection() );
-  pTrack->SetForPOISelection( thisTrack->InPOISelection() );
-  if(thisTrack->InSubevent(0)) pTrack->SetForSubevent(0);
-  if(thisTrack->InSubevent(1)) pTrack->SetForSubevent(1);
-  pTrack->SetID( thisTrack->GetID() );
+  *pTrack = *track;
+  if (track->GetNDaughters()>0)
+  {
+    fMothersCollection->Add(pTrack);
+  }
   return;
 }
 
@@ -890,7 +889,7 @@ AliFlowTrack* AliFlowEvent::ReuseTrack(Int_t i)
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
                             AliFlowTrackCuts* poiCuts ):
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -903,83 +902,9 @@ AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
             }
         }
     }
-
   //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
   //the input data needs to be attached to the cuts
-  //we have two cases, if we're cutting the same collection of tracks
-  //(same param type) then we can have tracks that are both rp and poi
-  //in the other case we want to have two exclusive sets of rps and pois
-  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
-  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
-  //TAKEN TWICE
-
-  if (!rpCuts || !poiCuts) return;
-  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
-  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
-
-  if (sourceRP==sourcePOI)
-  {
-    //loop over tracks
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
-    {
-      //get input object (particle)
-      TObject* particle = rpCuts->GetInputObject(i);
-
-      Bool_t rp = rpCuts->IsSelected(particle,i);
-      Bool_t poi = poiCuts->IsSelected(particle,i);
-      
-      if (!(rp||poi)) continue;
-
-      //make new AliFLowTrack
-      AliFlowTrack* pTrack = NULL;
-      if (rp)
-      {
-        pTrack = rpCuts->MakeFlowTrack();
-        if (!pTrack) continue;
-        pTrack->TagRP(); fNumberOfRPs++;
-        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}
-      }
-      else
-      if (poi)
-      {
-        pTrack = poiCuts->MakeFlowTrack();
-        if (!pTrack) continue;
-        pTrack->TagPOI(); fNumberOfPOIs++;
-      }
-      AddTrack(pTrack);
-    }//end of while (i < numberOfTracks)
-  }
-  else if (sourceRP!=sourcePOI)
-  {
-    //here we have two different sources of particles, so we fill
-    //them independently
-    AliFlowTrack* pTrack = NULL;
-    //RP
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
-    {
-      TObject* particle = rpCuts->GetInputObject(i);
-      Bool_t rp = rpCuts->IsSelected(particle,i);
-      if (!rp) continue;
-      pTrack = rpCuts->MakeFlowTrack();
-      if (!pTrack) continue;
-      pTrack->TagRP(); fNumberOfRPs++;
-      AddTrack(pTrack);
-    }
-    //POI
-    numberOfInputObject = poiCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObject; i++)
-    {
-      TObject* particle = poiCuts->GetInputObject(i);
-      Bool_t poi = poiCuts->IsSelected(particle,i);
-      if (!poi) continue;
-      pTrack = poiCuts->MakeFlowTrack();
-      if (!pTrack) continue;
-      pTrack->TagPOI(); fNumberOfPOIs++;
-      AddTrack(pTrack);
-    }
-  }
+  Fill(rpCuts,poiCuts);
 }
 
 //-------------------------------------------------------------------//
@@ -988,7 +913,7 @@ AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const AliESDPmdTrack *pmdtracks,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -1001,7 +926,6 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
             }
         }
     }
-
   Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos);
   Float_t GetPmdPhi(Float_t xPos, Float_t yPos);
   //Select the particles of interest from the ESD
@@ -1026,7 +950,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
        {
-          fNumberOfPOIs++;
+          IncrementNumberOfPOIs(1);
          pTrack->SetForPOISelection(kTRUE);
          pTrack->SetSource(AliFlowTrack::kFromESD);
        }
@@ -1060,7 +984,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       pTrack->SetEta(etacls);
       pTrack->SetPhi(phicls);
       //marking the particles used for the reference particle (RP) selection:
-      fNumberOfRPs++;
+      IncrementNumberOfPOIs(0);
       pTrack->SetForRPSelection(kTRUE);
       pTrack->SetSource(AliFlowTrack::kFromPMD);
       //Add the track to the flowevent
@@ -1103,7 +1027,6 @@ Float_t GetPmdPhi(Float_t xPos, Float_t yPos)
 }
 //---------------------------------------------------------------//
 
-
 void AliFlowEvent::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
 {
   // get q vectors for the subevents. if no recentering is necessary, get the guy from the flow event simple
@@ -1133,25 +1056,25 @@ void AliFlowEvent::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList,
     Double_t Qycrms(1);        
     
     if( n == 2) {       // second order symmetry
-        Qxamean = fMeanQ[fCurrentCentrality][1][0];
-        Qxarms  = fWidthQ[fCurrentCentrality][1][0];
-        Qyamean = fMeanQ[fCurrentCentrality][1][1];
-        Qyarms  = fWidthQ[fCurrentCentrality][1][1];
-
-        Qxcmean = fMeanQ[fCurrentCentrality][0][0];
-        Qxcrms  = fWidthQ[fCurrentCentrality][0][0];
-        Qycmean = fMeanQ[fCurrentCentrality][0][1];
-        Qycrms  = fWidthQ[fCurrentCentrality][0][1];   
+        Qxamean = fMeanQ[fVZEROcentralityBin][1][0];
+        Qxarms  = fWidthQ[fVZEROcentralityBin][1][0];
+        Qyamean = fMeanQ[fVZEROcentralityBin][1][1];
+        Qyarms  = fWidthQ[fVZEROcentralityBin][1][1];
+
+        Qxcmean = fMeanQ[fVZEROcentralityBin][0][0];
+        Qxcrms  = fWidthQ[fVZEROcentralityBin][0][0];
+        Qycmean = fMeanQ[fVZEROcentralityBin][0][1];
+        Qycrms  = fWidthQ[fVZEROcentralityBin][0][1];  
     } else if (n == 3) {        // third order symmetry
-        Qxamean = fMeanQv3[fCurrentCentrality][1][0];
-        Qxarms  = fWidthQv3[fCurrentCentrality][1][0];
-        Qyamean = fMeanQv3[fCurrentCentrality][1][1];
-        Qyarms  = fWidthQv3[fCurrentCentrality][1][1];
+        Qxamean = fMeanQv3[fVZEROcentralityBin][1][0];
+        Qxarms  = fWidthQv3[fVZEROcentralityBin][1][0];
+        Qyamean = fMeanQv3[fVZEROcentralityBin][1][1];
+        Qyarms  = fWidthQv3[fVZEROcentralityBin][1][1];
   
-        Qxcmean = fMeanQv3[fCurrentCentrality][0][0];
-        Qxcrms  = fWidthQv3[fCurrentCentrality][0][0];
-        Qycmean = fMeanQv3[fCurrentCentrality][0][1];
-        Qycrms  = fWidthQv3[fCurrentCentrality][0][1]; 
+        Qxcmean = fMeanQv3[fVZEROcentralityBin][0][0];
+        Qxcrms  = fWidthQv3[fVZEROcentralityBin][0][0];
+        Qycmean = fMeanQv3[fVZEROcentralityBin][0][1];
+        Qycrms  = fWidthQv3[fVZEROcentralityBin][0][1];        
     }
     // do the correction    
     Double_t QxaCor = (Qxa - Qxamean)/Qxarms;
@@ -1197,15 +1120,15 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {
     if(!cuts->GetEvent()) return; // coverity. we need to know the event to get the runnumber and centrlaity
     // get the vzero centrality percentile (cc dependent calibration)
     Float_t v0Centr(cuts->GetEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
-    if(v0Centr < 5) fCurrentCentrality = 0;
-    else if(v0Centr < 10) fCurrentCentrality = 1;
-    else if(v0Centr < 20) fCurrentCentrality = 2;
-    else if(v0Centr < 30) fCurrentCentrality = 3;
-    else if(v0Centr < 40) fCurrentCentrality = 4;
-    else if(v0Centr < 50) fCurrentCentrality = 5;
-    else if(v0Centr < 60) fCurrentCentrality = 6;
-    else if(v0Centr < 70) fCurrentCentrality = 7;
-    else fCurrentCentrality = 8;
+    if(v0Centr < 5) fVZEROcentralityBin = 0;
+    else if(v0Centr < 10) fVZEROcentralityBin = 1;
+    else if(v0Centr < 20) fVZEROcentralityBin = 2;
+    else if(v0Centr < 30) fVZEROcentralityBin = 3;
+    else if(v0Centr < 40) fVZEROcentralityBin = 4;
+    else if(v0Centr < 50) fVZEROcentralityBin = 5;
+    else if(v0Centr < 60) fVZEROcentralityBin = 6;
+    else if(v0Centr < 70) fVZEROcentralityBin = 7;
+    else fVZEROcentralityBin = 8;
 
     // if this event is from the same run as the previous event
     // we can use the cached calibration values, no need to re-open the 
@@ -1241,26 +1164,26 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {
         for(Int_t r(0); r < 176; r++) {
             if(run == runs11h[r]) {
                 printf(" > run has been identified as 11h < \n");
-                if(cuts->GetV0gainEqualizationPerRing()) {
+                if(cuts->GetVZEROgainEqualizationPerRing()) {
                     // enable or disable rings through the weights, weight 1. is enabled, 0. is disabled
                     // start with the vzero c rings (segments 0 through 31)
-                    (cuts->GetUseVZERORing(0)) ? cuts->SetV0Cpol(0, 1.) : cuts->SetV0Cpol(0, 0.);
-                    (cuts->GetUseVZERORing(1)) ? cuts->SetV0Cpol(1, 1.) : cuts->SetV0Cpol(1, 0.);
-                    (cuts->GetUseVZERORing(2)) ? cuts->SetV0Cpol(2, 1.) : cuts->SetV0Cpol(2, 0.);
-                    (cuts->GetUseVZERORing(3)) ? cuts->SetV0Cpol(3, 1.) : cuts->SetV0Cpol(3, 0.);
+                    (cuts->GetUseVZERORing(0)) ? cuts->SetVZEROCpol(0, 1.) : cuts->SetVZEROCpol(0, 0.);
+                    (cuts->GetUseVZERORing(1)) ? cuts->SetVZEROCpol(1, 1.) : cuts->SetVZEROCpol(1, 0.);
+                    (cuts->GetUseVZERORing(2)) ? cuts->SetVZEROCpol(2, 1.) : cuts->SetVZEROCpol(2, 0.);
+                    (cuts->GetUseVZERORing(3)) ? cuts->SetVZEROCpol(3, 1.) : cuts->SetVZEROCpol(3, 0.);
                     // same for vzero a
-                    (cuts->GetUseVZERORing(4)) ? cuts->SetV0Apol(0, 1.) : cuts->SetV0Apol(0, 0.);
-                    (cuts->GetUseVZERORing(5)) ? cuts->SetV0Apol(1, 1.) : cuts->SetV0Apol(1, 0.);
-                    (cuts->GetUseVZERORing(6)) ? cuts->SetV0Apol(2, 1.) : cuts->SetV0Apol(2, 0.);
-                    (cuts->GetUseVZERORing(7)) ? cuts->SetV0Apol(3, 1.) : cuts->SetV0Apol(3, 0.);
+                    (cuts->GetUseVZERORing(4)) ? cuts->SetVZEROApol(0, 1.) : cuts->SetVZEROApol(0, 0.);
+                    (cuts->GetUseVZERORing(5)) ? cuts->SetVZEROApol(1, 1.) : cuts->SetVZEROApol(1, 0.);
+                    (cuts->GetUseVZERORing(6)) ? cuts->SetVZEROApol(2, 1.) : cuts->SetVZEROApol(2, 0.);
+                    (cuts->GetUseVZERORing(7)) ? cuts->SetVZEROApol(3, 1.) : cuts->SetVZEROApol(3, 0.);
                 } else {
                     // else enable all rings
-                    for(Int_t i(0); i < 4; i++) cuts->SetV0Cpol(i, 1.);
-                    for(Int_t i(0); i < 4; i++) cuts->SetV0Apol(i, 1.);
+                    for(Int_t i(0); i < 4; i++) cuts->SetVZEROCpol(i, 1.);
+                    for(Int_t i(0); i < 4; i++) cuts->SetVZEROApol(i, 1.);
                 }
                 // pass a NULL pointer to the track cuts object
                 // the NULL pointer will identify 11h runs
-                cuts->SetV0gainEqualisation(NULL);
+                cuts->SetVZEROgainEqualisation(NULL);
                 // this will identify the recentering style that is required. flight might be changed if recenetering is disabled
                 fApplyRecentering = 2011;
                 SetVZEROCalibrationForTrackCuts2011(cuts); 
@@ -1268,45 +1191,45 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {
             }
         }
         // the run has not been identified as lhc11h data, so we assume a template calibration
-       printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);
+       printf("OADB object hMultVZEROBefCorr is not available for run %i (used run 137366)\n",run);
        run = 137366;
     }
     printf(" > run has been identified as 10h < \n");
     // step 1) get the proper multiplicity weights from the vzero signal
-    TProfile* fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();
+    TProfile* fMultVZERO = ((TH2F *) cont->GetObject(run))->ProfileX();
 
     TF1 *fpol0 = new TF1("fpol0","pol0"); 
-    if(cuts->GetV0gainEqualizationPerRing()) {
+    if(cuts->GetVZEROgainEqualizationPerRing()) {
         // do the calibration per ring
         // start with the vzero c rings (segments 0 through 31)
-        fMultV0->Fit(fpol0, "", "", 0, 8);
-        (cuts->GetUseVZERORing(0)) ? cuts->SetV0Cpol(0, fpol0->GetParameter(0)) : cuts->SetV0Cpol(0, 0.);
-        fMultV0->Fit(fpol0, "", "", 8, 16);
-        (cuts->GetUseVZERORing(1)) ? cuts->SetV0Cpol(1, fpol0->GetParameter(0)) : cuts->SetV0Cpol(1, 0.);
-        fMultV0->Fit(fpol0, "", "", 16, 24);
-        (cuts->GetUseVZERORing(2)) ? cuts->SetV0Cpol(2, fpol0->GetParameter(0)) : cuts->SetV0Cpol(2, 0.);
-        fMultV0->Fit(fpol0, "", "", 24, 32);
-        (cuts->GetUseVZERORing(3)) ? cuts->SetV0Cpol(3, fpol0->GetParameter(0)) : cuts->SetV0Cpol(3, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 0, 8);
+        (cuts->GetUseVZERORing(0)) ? cuts->SetVZEROCpol(0, fpol0->GetParameter(0)) : cuts->SetVZEROCpol(0, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 8, 16);
+        (cuts->GetUseVZERORing(1)) ? cuts->SetVZEROCpol(1, fpol0->GetParameter(0)) : cuts->SetVZEROCpol(1, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 16, 24);
+        (cuts->GetUseVZERORing(2)) ? cuts->SetVZEROCpol(2, fpol0->GetParameter(0)) : cuts->SetVZEROCpol(2, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 24, 32);
+        (cuts->GetUseVZERORing(3)) ? cuts->SetVZEROCpol(3, fpol0->GetParameter(0)) : cuts->SetVZEROCpol(3, 0.);
         // same thing for vero A
-        fMultV0->Fit(fpol0, "", "", 32, 40);
-        (cuts->GetUseVZERORing(4)) ? cuts->SetV0Apol(0, fpol0->GetParameter(0)) : cuts->SetV0Apol(0, 0.);
-        fMultV0->Fit(fpol0, "", "", 40, 48);
-        (cuts->GetUseVZERORing(5)) ? cuts->SetV0Apol(1, fpol0->GetParameter(0)) : cuts->SetV0Apol(1, 0.);
-        fMultV0->Fit(fpol0, "", "", 48, 56);
-        (cuts->GetUseVZERORing(6)) ? cuts->SetV0Apol(2, fpol0->GetParameter(0)) : cuts->SetV0Apol(2, 0.);
-        fMultV0->Fit(fpol0, "", "", 56, 64);
-        (cuts->GetUseVZERORing(7)) ? cuts->SetV0Apol(3, fpol0->GetParameter(0)) : cuts->SetV0Apol(3, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 32, 40);
+        (cuts->GetUseVZERORing(4)) ? cuts->SetVZEROApol(0, fpol0->GetParameter(0)) : cuts->SetVZEROApol(0, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 40, 48);
+        (cuts->GetUseVZERORing(5)) ? cuts->SetVZEROApol(1, fpol0->GetParameter(0)) : cuts->SetVZEROApol(1, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 48, 56);
+        (cuts->GetUseVZERORing(6)) ? cuts->SetVZEROApol(2, fpol0->GetParameter(0)) : cuts->SetVZEROApol(2, 0.);
+        fMultVZERO->Fit(fpol0, "", "", 56, 64);
+        (cuts->GetUseVZERORing(7)) ? cuts->SetVZEROApol(3, fpol0->GetParameter(0)) : cuts->SetVZEROApol(3, 0.);
     } else {
         // do the calibration in one go. the calibration will still be 
         // stored per ring, but each ring has the same weight now
-       fMultV0->Fit(fpol0,"","",0,31);
-       for(Int_t i(0); i < 4; i++) cuts->SetV0Cpol(i, fpol0->GetParameter(0));
-       fMultV0->Fit(fpol0,"","",32,64);
-       for(Int_t i(0); i < 4; i++) cuts->SetV0Apol(i, fpol0->GetParameter(0));
+       fMultVZERO->Fit(fpol0,"","",0,31);
+       for(Int_t i(0); i < 4; i++) cuts->SetVZEROCpol(i, fpol0->GetParameter(0));
+       fMultVZERO->Fit(fpol0,"","",32,64);
+       for(Int_t i(0); i < 4; i++) cuts->SetVZEROApol(i, fpol0->GetParameter(0));
     }
     // the parameters to weigh the vzero track cuts have been extracted now, 
     // so we can pass them to the current track cuts obect
-    cuts->SetV0gainEqualisation(fMultV0);       // passed as a TH1
+    cuts->SetVZEROgainEqualisation(fMultVZERO);       // passed as a TH1
 
     // step 2) reweight the q-vectors that will be  called by flow methods which use
     // subevents
@@ -1406,3 +1329,11 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts2011(AliFlowTrackCuts* cuts)
     fMeanQv3[0][0][1] = qyEPc3;
 } 
 //_____________________________________________________________________________
+
+void AliFlowEvent::ClearFast()
+{
+  //clear the event without releasing any memory
+  AliFlowEventSimple::ClearFast();
+  fApplyRecentering=0;
+  fCachedRun=0;
+}
index c5cf51dbb85835467f88640028fe9ec350e2b03d..31083425d47c82cee199489e5ddf3a232bf445ed 100644 (file)
@@ -74,6 +74,8 @@ public:
   void Fill( AliFlowTrackCuts* rpCuts,
              AliFlowTrackCuts* poiCuts );
 
+  void FindDaughters(Bool_t keepDaughtersInRPselection=kFALSE);
+
   void SetMCReactionPlaneAngle(const AliMCEvent* mcEvent);
   using AliFlowEventSimple::SetMCReactionPlaneAngle;
 
@@ -85,13 +87,15 @@ public:
   void SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts);
   void SetVZEROCalibrationForTrackCuts2011(AliFlowTrackCuts* cuts);
 
+  virtual void ClearFast();
+
 protected:
   AliFlowTrack* ReuseTrack( Int_t i);
 
 private:
   Int_t         fApplyRecentering;      // apply recentering of q-vectors? 2010 is 10h style, 2011 is 11h style
   Int_t         fCachedRun;             //! cached calibration info for vzero
-  Int_t         fCurrentCentrality;     //! centrality bin for the current event 
+  Int_t         fVZEROcentralityBin;     //! centrality bin for the current event 
   Float_t       fMeanQ[9][2][2];        //! recentering
   Float_t       fWidthQ[9][2][2];       //! recentering
   Float_t       fMeanQv3[9][2][2];      //! recentering
index 362cbafe673f2cf16104297965c27cc048f611f4..8f0780ee6571fca2def8433b03f624f1d42e383d 100644 (file)
@@ -48,7 +48,7 @@ ClassImp(AliFlowEventCuts)
 
 //-----------------------------------------------------------------------
 AliFlowEventCuts::AliFlowEventCuts():
-  TNamed(),
+  AliFlowEventSimpleCuts(),
   fQA(NULL),
   fCutNumberOfTracks(kFALSE),
   fNumberOfTracksMax(INT_MAX),
@@ -81,11 +81,8 @@ AliFlowEventCuts::AliFlowEventCuts():
   fCutSPDvertexerAnomaly(kFALSE),
   fCutSPDTRKVtxZ(kFALSE),
   fCutTPCmultiplicityOutliers(kFALSE),
-  fCutCentralityPercentile(kFALSE),
   fUseCentralityUnchecked(kFALSE),
   fCentralityPercentileMethod(kTPConly),
-  fCentralityPercentileMax(100.),
-  fCentralityPercentileMin(0.),
   fCutZDCtiming(kFALSE),
   fTrigAna(),
   fCutImpactParameter(kFALSE),
@@ -99,7 +96,7 @@ AliFlowEventCuts::AliFlowEventCuts():
 
 //-----------------------------------------------------------------------
 AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
-  TNamed(name, title),
+  AliFlowEventSimpleCuts(name, title),
   fQA(NULL),
   fCutNumberOfTracks(kFALSE),
   fNumberOfTracksMax(INT_MAX),
@@ -132,11 +129,8 @@ AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
   fCutSPDvertexerAnomaly(kFALSE),
   fCutSPDTRKVtxZ(kFALSE),
   fCutTPCmultiplicityOutliers(kFALSE),
-  fCutCentralityPercentile(kFALSE),
   fUseCentralityUnchecked(kFALSE),
   fCentralityPercentileMethod(kTPConly),
-  fCentralityPercentileMax(100.),
-  fCentralityPercentileMin(0.),
   fCutZDCtiming(kFALSE),
   fTrigAna(),
   fCutImpactParameter(kFALSE),
@@ -150,7 +144,7 @@ AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
 
 ////-----------------------------------------------------------------------
 AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
-  TNamed(that),
+  AliFlowEventSimpleCuts(that),
   fQA(NULL),
   fCutNumberOfTracks(that.fCutNumberOfTracks),
   fNumberOfTracksMax(that.fNumberOfTracksMax),
@@ -183,11 +177,8 @@ AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
   fCutSPDvertexerAnomaly(that.fCutSPDvertexerAnomaly),
   fCutSPDTRKVtxZ(that.fCutSPDTRKVtxZ),
   fCutTPCmultiplicityOutliers(that.fCutTPCmultiplicityOutliers),
-  fCutCentralityPercentile(that.fCutCentralityPercentile),
   fUseCentralityUnchecked(that.fUseCentralityUnchecked),
   fCentralityPercentileMethod(that.fCentralityPercentileMethod),
-  fCentralityPercentileMax(that.fCentralityPercentileMax),
-  fCentralityPercentileMin(that.fCentralityPercentileMin),
   fCutZDCtiming(that.fCutZDCtiming),
   fTrigAna(),
   fCutImpactParameter(that.fCutImpactParameter),
@@ -270,11 +261,8 @@ AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& that)
   fCutSPDvertexerAnomaly=that.fCutSPDvertexerAnomaly;
   fCutSPDTRKVtxZ=that.fCutSPDTRKVtxZ;
   fCutTPCmultiplicityOutliers=that.fCutTPCmultiplicityOutliers;
-  fCutCentralityPercentile=that.fCutCentralityPercentile;
   fUseCentralityUnchecked=that.fUseCentralityUnchecked;
   fCentralityPercentileMethod=that.fCentralityPercentileMethod;
-  fCentralityPercentileMax=that.fCentralityPercentileMax;
-  fCentralityPercentileMin=that.fCentralityPercentileMin;
   fCutZDCtiming=that.fCutZDCtiming;
   fhistTPCvsGlobalMult=that.fhistTPCvsGlobalMult;
   fData2011=that.fData2011;
@@ -473,6 +461,31 @@ Bool_t AliFlowEventCuts::PassesCuts(AliVEvent *event, AliMCEvent *mcevent)
   return pass;
 }
 
+//----------------------------------------------------------------------- 
+Float_t AliFlowEventCuts::GetCentrality(AliVEvent* event, AliMCEvent* /*mcEvent*/)
+{
+  //get the centrality percentile of the event
+  AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*>(event);
+  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(event);
+
+  Float_t centrality=-1.;
+
+  AliCentrality* centr = NULL;
+  if (esdEvent)
+    centr = esdEvent->GetCentrality();
+  if (aodEvent) 
+    centr = aodEvent->GetHeader()->GetCentralityP();
+  
+  if (!centr) return -1.;
+
+  if (fUseCentralityUnchecked) 
+    centrality=centr->GetCentralityPercentileUnchecked(CentrMethName(fCentralityPercentileMethod));
+  else 
+    centrality=centr->GetCentralityPercentile(CentrMethName(fCentralityPercentileMethod));
+
+  return centrality;
+}
+
 //----------------------------------------------------------------------- 
 const char* AliFlowEventCuts::CentrMethName(refMultMethod method) const
 {
@@ -486,7 +499,7 @@ const char* AliFlowEventCuts::CentrMethName(refMultMethod method) const
       return "CL1";
     case kTPConly:
       return "TRK";
-    case kV0:
+    case kVZERO:
       return "V0M";
     default:
       return "";
@@ -525,7 +538,7 @@ Int_t AliFlowEventCuts::RefMult(AliVEvent* event, AliMCEvent *mcEvent)
     fRefMultCuts->SetParamType(AliFlowTrackCuts::kSPDtracklet);
     fRefMultCuts->SetEtaRange(-0.8,0.8);
   }
-  else if (fRefMultMethod==kV0)
+  else if (fRefMultMethod==kVZERO)
   {
     if (!esdevent) return 0;
     vzero=esdevent->GetVZEROData();
index b83113177f08bbd8c53cad4fbb7eff79bb05513a..72e2ed14255cd8abac1271e2b1893d24b5fa8a9a 100644 (file)
@@ -20,11 +20,12 @@ class TBrowser;
 #include "TH1.h"
 #include "AliTriggerAnalysis.h"
 #include "AliFlowTrackCuts.h"
+#include "AliFlowEventSimpleCuts.h"
 
-class AliFlowEventCuts : public TNamed {
+class AliFlowEventCuts : public AliFlowEventSimpleCuts {
 
  public:
-  enum refMultMethod { kTPConly, kSPDtracklets, kV0, kSPD1clusters };
+  enum refMultMethod { kTPConly, kSPDtracklets, kVZERO, kV0=kVZERO, kSPD1clusters };
 
   AliFlowEventCuts();
   AliFlowEventCuts(const char* name, const char* title = "AliFlowEventCuts");
@@ -82,12 +83,12 @@ class AliFlowEventCuts : public TNamed {
   //Int_t GetRefMult() {return fRefMult;}
   Int_t GetReferenceMultiplicity(AliVEvent* event, AliMCEvent *mcEvent) {return RefMult(event,mcEvent);}
   const char* CentrMethName(refMultMethod method) const;
-  void SetCentralityPercentileRange(Float_t min, Float_t max){ fCentralityPercentileMin=min;
-                                                               fCentralityPercentileMax=max;
-                                                               fCutCentralityPercentile=kTRUE; }
   void SetCentralityPercentileMethod( refMultMethod m) {fCentralityPercentileMethod=m;}
   void SetUseCentralityUnchecked(Bool_t b=kTRUE) {fUseCentralityUnchecked=b;}
+
+  Float_t GetCentrality(AliVEvent* event, AliMCEvent* mcEvent);
   void SetUsedDataset(Bool_t b=kTRUE) {fData2011=b;}
+
   void Browse(TBrowser* b);
   Long64_t Merge(TCollection* list);  
   TH2F *GetCorrelationTPCvsGlobalMultiplicity() {return fhistTPCvsGlobalMult;}  
@@ -126,11 +127,8 @@ class AliFlowEventCuts : public TNamed {
   Bool_t fCutSPDvertexerAnomaly; //cut on the spd vertexer anomaly
   Bool_t fCutSPDTRKVtxZ; //require compatibility between SPDvertexz TRKvertexz
   Bool_t fCutTPCmultiplicityOutliers; //cut TPC multiplicity outliers
-  Bool_t fCutCentralityPercentile; //cut on centrality perc. from AliESDCentrality
   Bool_t fUseCentralityUnchecked; //use the unchecked method
   refMultMethod fCentralityPercentileMethod; //where to get the percentile from
-  Float_t fCentralityPercentileMax; // max centr. perc
-  Float_t fCentralityPercentileMin; // min centr. perc
   Bool_t fCutZDCtiming;   //cut on ZDC timing
   AliTriggerAnalysis fTrigAna; //trigger analysis object
   Bool_t fCutImpactParameter; //cut on impact parameter (MC header)
index 4b18961da837aa19d1ac2e73c361b25f37db1c3c..a72b5b948f9378e873fa72a71a15b2ed3eeac842 100644 (file)
@@ -22,7 +22,8 @@ public:
                      kFromFMD=4,
                      kFromPMD=5,
                      kFromV0=6,
-                     kFromMUON=7 }; // XZhang 20120604
+                     kFromMUON=7,// XZhang 20120604
+                     kFromKink }; 
   AliFlowTrack();
   AliFlowTrack(const AliVParticle* p);
   AliFlowTrack& operator=(const AliFlowTrack& aTrack);
@@ -38,6 +39,8 @@ public:
   Bool_t IsSource( trackSource s ) const
                  { return fTrackSourceBits.TestBitNumber(s); }
 
+  virtual void Clear(Option_t* o="") {AliFlowTrackSimple::Clear(o); fTrackSourceBits.Clear();}
+
 private:
   TBits fTrackSourceBits; //where do i come from?
   
index 39babfa693616220d39ac17f3bf974d843c8e4b6..45fd03ea8da2572cd4ce45a90f5fbf30b6d60f55 100644 (file)
@@ -49,6 +49,8 @@
 #include "AliVParticle.h"
 #include "AliVVZERO.h"
 #include "AliMCParticle.h"
+#include "AliESDkink.h"
+#include "AliESDv0.h"
 #include "AliESDtrack.h"
 #include "AliESDMuonTrack.h"   // XZhang 20120604
 #include "AliMultiplicity.h"
 #include "AliESDPmdTrack.h"
 #include "AliESDUtils.h" //TODO
 #include "AliFlowBayesianPID.h"
+#include "AliFlowCandidateTrack.h"
+#include "AliKFParticle.h"
+#include "AliESDVZERO.h"
+#include "AliFlowCommonConstants.h"
 
 ClassImp(AliFlowTrackCuts)
 
@@ -113,9 +119,22 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fPmdAdc(0.),
   fCutPmdNcell(kFALSE),
   fPmdNcell(0.),  
+  fMinKinkAngle(TMath::DegToRad()*2.),
+  fMinKinkRadius(130.),
+  fMaxKinkRadius(200.),
+  fMinKinkQt(.05),
+  fMaxKinkQt(.5),
+  fMinKinkInvMassKmu(0.),
+  fMaxKinkInvMassKmu(0.6),
+  fForceTPCstandalone(kFALSE),
+  fRequireKinkDaughters(kFALSE),
   fParamType(kGlobal),
   fParamMix(kPure),
+  fKink(NULL),
+  fV0(NULL),
   fTrack(NULL),
+  fTrackMass(0.),
+  fTrackPt(0.),
   fTrackPhi(0.),
   fTrackEta(0.),
   fTrackWeight(1.),
@@ -124,7 +143,6 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fMCparticle(NULL),
   fEvent(NULL),
   fTPCtrack(),
-  fFlowTagType(AliFlowTrackSimple::kInvalid),
   fESDpid(),
   fBayesianResponse(NULL),
   fPIDsource(kTOFpid),
@@ -137,9 +155,9 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fCutRejectElectronsWithTPCpid(kFALSE),
   fProbBayes(0.0),
   fCurrCentr(0.0),
-  fV0gainEqualization(NULL),
+  fVZEROgainEqualization(NULL),
   fApplyRecentering(kFALSE),
-  fV0gainEqualizationPerRing(kFALSE)
+  fVZEROgainEqualizationPerRing(kFALSE)
 {
   //io constructor 
   SetPriors(); //init arrays
@@ -151,8 +169,8 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fBayesianResponse = new AliFlowBayesianPID();
   fBayesianResponse->SetNewTrackParam();
   for(Int_t i(0); i < 4; i++) {
-      fV0Apol[i] = 0;
-      fV0Cpol[i] = 0;
+      fVZEROApol[i] = 0;
+      fVZEROCpol[i] = 0;
   }
   for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = kTRUE;
 
@@ -206,9 +224,22 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fPmdAdc(0.),
   fCutPmdNcell(kFALSE),
   fPmdNcell(0.),  
+  fMinKinkAngle(TMath::DegToRad()*2.),
+  fMinKinkRadius(130.),
+  fMaxKinkRadius(200.),
+  fMinKinkQt(0.05),
+  fMaxKinkQt(0.5),
+  fMinKinkInvMassKmu(0.0),
+  fMaxKinkInvMassKmu(0.6),
+  fForceTPCstandalone(kFALSE),
+  fRequireKinkDaughters(kFALSE),
   fParamType(kGlobal),
   fParamMix(kPure),
+  fKink(NULL),
+  fV0(NULL),
   fTrack(NULL),
+  fTrackMass(0.),
+  fTrackPt(0.),
   fTrackPhi(0.),
   fTrackEta(0.),
   fTrackWeight(1.),
@@ -217,7 +248,6 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fMCparticle(NULL),
   fEvent(NULL),
   fTPCtrack(),
-  fFlowTagType(AliFlowTrackSimple::kInvalid),
   fESDpid(),
   fBayesianResponse(NULL),
   fPIDsource(kTOFpid),
@@ -230,9 +260,9 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fCutRejectElectronsWithTPCpid(kFALSE),
   fProbBayes(0.0),
   fCurrCentr(0.0),
-  fV0gainEqualization(NULL),
+  fVZEROgainEqualization(NULL),
   fApplyRecentering(kFALSE),
-  fV0gainEqualizationPerRing(kFALSE)
+  fVZEROgainEqualizationPerRing(kFALSE)
 {
   //constructor 
   SetTitle("AliFlowTrackCuts");
@@ -247,8 +277,8 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fBayesianResponse = new AliFlowBayesianPID();
   fBayesianResponse->SetNewTrackParam();
   for(Int_t i(0); i < 4; i++) {
-      fV0Apol[i] = 0;
-      fV0Cpol[i] = 0;
+      fVZEROApol[i] = 0;
+      fVZEROCpol[i] = 0;
   }
   for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = kTRUE;
 }
@@ -301,9 +331,22 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fPmdAdc(that.fPmdAdc),
   fCutPmdNcell(that.fCutPmdNcell),
   fPmdNcell(that.fPmdNcell),  
+  fMinKinkAngle(that.fMinKinkAngle),
+  fMinKinkRadius(that.fMinKinkRadius),
+  fMaxKinkRadius(that.fMaxKinkRadius),
+  fMinKinkQt(that.fMinKinkQt),
+  fMaxKinkQt(that.fMaxKinkQt),
+  fMinKinkInvMassKmu(that.fMinKinkInvMassKmu),
+  fMaxKinkInvMassKmu(that.fMaxKinkInvMassKmu),
+  fForceTPCstandalone(that.fForceTPCstandalone),
+  fRequireKinkDaughters(that.fRequireKinkDaughters),
   fParamType(that.fParamType),
   fParamMix(that.fParamMix),
+  fKink(NULL),
+  fV0(NULL),
   fTrack(NULL),
+  fTrackMass(0.),
+  fTrackPt(0.),
   fTrackPhi(0.),
   fTrackEta(0.),
   fTrackWeight(1.),
@@ -312,7 +355,6 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fMCparticle(NULL),
   fEvent(NULL),
   fTPCtrack(),
-  fFlowTagType(that.fFlowTagType),
   fESDpid(that.fESDpid),
   fBayesianResponse(NULL),
   fPIDsource(that.fPIDsource),
@@ -325,9 +367,9 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fCutRejectElectronsWithTPCpid(that.fCutRejectElectronsWithTPCpid),
   fProbBayes(0.0),
   fCurrCentr(0.0),
-  fV0gainEqualization(NULL),
+  fVZEROgainEqualization(NULL),
   fApplyRecentering(that.fApplyRecentering),
-  fV0gainEqualizationPerRing(that.fV0gainEqualizationPerRing)
+  fVZEROgainEqualizationPerRing(that.fVZEROgainEqualizationPerRing)
 {
   //copy constructor
   printf(" \n\n claling copy ctor \n\n" );
@@ -342,13 +384,13 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fBayesianResponse = new AliFlowBayesianPID();
   fBayesianResponse->SetNewTrackParam();
 
-  // V0 gain calibration
-  // no reason to init fV0gainEqualizationPerRing, will be initialized on node if necessary
+  // VZERO gain calibration
+  // no reason to init fVZEROgainEqualizationPerRing, will be initialized on node if necessary
   // pointer is set to NULL in initialization list of this constructor
-//  if (that.fV0gainEqualization) fV0gainEqualization = new TH1(*(that.fV0gainEqualization));
+//  if (that.fVZEROgainEqualization) fVZEROgainEqualization = new TH1(*(that.fVZEROgainEqualization));
   for(Int_t i(0); i < 4; i++) { // no use to copy these guys since they're only initialized on worked node
-      fV0Apol[i] = 0.;
-      fV0Cpol[i] = 0.;
+      fVZEROApol[i] = 0.;
+      fVZEROCpol[i] = 0.;
   }
   for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = that.fUseVZERORing[i];
 
@@ -370,7 +412,7 @@ AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
   if ( that.fMuonTrackCuts &&  fMuonTrackCuts) *fMuonTrackCuts = *(that.fMuonTrackCuts);                   // XZhang 20120604
   if ( that.fMuonTrackCuts && !fMuonTrackCuts)  fMuonTrackCuts = new AliMuonTrackCuts(*(that.fMuonTrackCuts));  // XZhang 20120604
   if (!that.fMuonTrackCuts) delete fMuonTrackCuts; fMuonTrackCuts = NULL;                                  // XZhang 20120604
-  if (!that.fV0gainEqualization) delete fV0gainEqualization; fV0gainEqualization = NULL;
+  if (!that.fVZEROgainEqualization) delete fVZEROgainEqualization; fVZEROgainEqualization = NULL;
   //these guys we don't need to copy, just reinit
   if (that.fQA) {fQA->Delete(); delete fQA; fQA=NULL; DefineHistograms();} 
   fCutMC=that.fCutMC;
@@ -415,12 +457,24 @@ AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
   fPmdAdc=that.fPmdAdc;
   fCutPmdNcell=that.fCutPmdNcell;
   fPmdNcell=that.fPmdNcell;
-  fFlowTagType=that.fFlowTagType;
+  fMinKinkAngle=that.fMinKinkAngle;
+  fMinKinkRadius=that.fMinKinkRadius;
+  fMaxKinkRadius=that.fMaxKinkRadius;
+  fMinKinkQt=that.fMinKinkQt;
+  fMaxKinkQt=that.fMaxKinkQt;
+  fMinKinkInvMassKmu=that.fMinKinkInvMassKmu;
+  fMaxKinkInvMassKmu=that.fMaxKinkInvMassKmu;
+  fForceTPCstandalone=that.fForceTPCstandalone;
+  fRequireKinkDaughters=that.fRequireKinkDaughters;
   
   fParamType=that.fParamType;
   fParamMix=that.fParamMix;
 
+  fKink=NULL;
+  fV0=NULL;
   fTrack=NULL;
+  fTrackMass=0.;
+  fTrackPt=0.;
   fTrackEta=0.;
   fTrackPhi=0.;
   fTrackWeight=1.;
@@ -446,16 +500,16 @@ AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
   fCurrCentr = that.fCurrCentr;
   
   fApplyRecentering = that.fApplyRecentering;
-  fV0gainEqualizationPerRing = that.fV0gainEqualizationPerRing;
+  fVZEROgainEqualizationPerRing = that.fVZEROgainEqualizationPerRing;
 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)           
-  if (that.fV0gainEqualization) fV0gainEqualization = new TH1(*(that.fV0gainEqualization));
+  if (that.fVZEROgainEqualization) fVZEROgainEqualization = new TH1(*(that.fVZEROgainEqualization));
 #else
   //PH Lets try Clone, however the result might be wrong
-  if (that.fV0gainEqualization) fV0gainEqualization = (TH1*)that.fV0gainEqualization->Clone();
+  if (that.fVZEROgainEqualization) fVZEROgainEqualization = (TH1*)that.fVZEROgainEqualization->Clone();
 #endif
   for(Int_t i(0); i < 4; i++) { // no use to copy these guys since they're only initialized on worked node
-      fV0Apol[i] = that.fV0Apol[i];
-      fV0Cpol[i] = that.fV0Cpol[i];
+      fVZEROApol[i] = that.fVZEROApol[i];
+      fVZEROCpol[i] = that.fVZEROCpol[i];
   }
   for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = that.fUseVZERORing[i];
 
@@ -471,7 +525,7 @@ AliFlowTrackCuts::~AliFlowTrackCuts()
   delete fTOFpidCuts;
   if (fMuonTrackCuts) delete fMuonTrackCuts;  // XZhang 20120604
   if (fQA) { fQA->SetOwner(); fQA->Delete(); delete fQA; }
-  if (fV0gainEqualization) delete fV0gainEqualization;
+  if (fVZEROgainEqualization) delete fVZEROgainEqualization;
 }
 
 //-----------------------------------------------------------------------
@@ -547,7 +601,12 @@ Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)
   AliESDPmdTrack* pmdtrack = dynamic_cast<AliESDPmdTrack*>(obj);
   if (pmdtrack) return PassesPMDcuts(pmdtrack);
   AliVEvent* vvzero = dynamic_cast<AliVEvent*>(obj); // should be removed; left for protection only
-  if (vvzero) return PassesV0cuts(id);
+  if (vvzero) return PassesVZEROcuts(id);
+  AliESDkink* kink = dynamic_cast<AliESDkink*>(obj);
+  if (kink) return PassesCuts(kink);
+  //AliESDv0* v0 = dynamic_cast<AliESDv0*>(obj);
+  //if (v0) return PassesCuts(v0);
+  
   return kFALSE;  //default when passed wrong type of object
 }
 
@@ -578,7 +637,7 @@ Bool_t AliFlowTrackCuts::PassesCuts(const AliFlowTrackSimple* track)
   //check cuts on a flowtracksimple
 
   //clean up from last iteration
-  fTrack = NULL;
+  ClearTrack();
   return AliFlowTrackSimpleCuts::PassesCuts(track);
 }
 
@@ -590,9 +649,7 @@ Bool_t AliFlowTrackCuts::PassesCuts(const AliMultiplicity* tracklet, Int_t id)
   if (id<0) return kFALSE;
 
   //clean up from last iteration, and init label
-  fTrack = NULL;
-  fMCparticle=NULL;
-  fTrackLabel=-999;
+  ClearTrack();
 
   fTrackPhi = tracklet->GetPhi(id);
   fTrackEta = tracklet->GetEta(id);
@@ -623,9 +680,7 @@ Bool_t AliFlowTrackCuts::PassesCuts(const AliAODTracklets* tracklet, Int_t id)
   if (id<0) return kFALSE;
 
   //clean up from last iteration, and init label
-  fTrack = NULL;
-  fMCparticle=NULL;
-  fTrackLabel=-999;
+  ClearTrack();
 
   fTrackPhi = tracklet->GetPhi(id);
 //fTrackEta = tracklet->GetEta(id);
@@ -707,6 +762,130 @@ Bool_t AliFlowTrackCuts::PassesMCcuts()
   return PassesMCcuts(fMCevent,fTrackLabel);
 }
 
+//-----------------------------------------------------------------------
+Bool_t AliFlowTrackCuts::PassesCuts(const AliESDv0* v0)
+{
+  //check if the v0 passes cuts
+
+  //clean up from last iteration
+  ClearTrack();
+  
+  fV0 = const_cast<AliESDv0*>(v0);
+
+  Bool_t pass = kTRUE;
+
+  //first, extract/prepare the v0
+  if (!v0->GetOnFlyStatus()) return kFALSE; //skip offline V0 finder
+  const AliExternalTrackParam *negHelix=v0->GetParamN();
+  const AliExternalTrackParam *posHelix=v0->GetParamP();
+  AliVParticle *v0tracks[2];
+  v0tracks[0] = fEvent->GetTrack(v0->GetNindex());
+  v0tracks[1] = fEvent->GetTrack(v0->GetPindex());
+  if( v0tracks[1]->Charge() < 0)
+  {
+    v0tracks[1] = fEvent->GetTrack(v0->GetNindex());
+    v0tracks[0] = fEvent->GetTrack(v0->GetPindex());
+    negHelix=v0->GetParamP();
+    posHelix=v0->GetParamN();
+  }
+
+  int KalmanPidPairs[4][2] =
+  {
+    {-11,11}, // e-,e+ (gamma)
+    {-211,2212}, // pi- p (lambda)
+    {-2212,211}, // anti-p pi+ (anti-lambda)
+    {-211,211} // pi-  pi+ (Kshort)
+    //   {-321,321} // K- K+ (phi)
+  };
+    
+  Int_t id = 3;
+  //refit using a mass hypothesis
+  AliKFParticle v0trackKFneg(*(negHelix),KalmanPidPairs[id][0]);
+  AliKFParticle v0trackKFpos(*(posHelix),KalmanPidPairs[id][1]);
+  AliKFParticle v0particleRefit;
+  v0particleRefit += v0trackKFneg;
+  v0particleRefit += v0trackKFpos;
+  Double_t invMassErr= -999;
+  v0particleRefit.GetMass(fTrackMass,invMassErr);
+  //Double_t openAngle = v0trackKFneg.GetAngle(v0trackKFpos);
+  fTrackEta = v0particleRefit.GetEta();
+  fTrackPt = v0particleRefit.GetPt();
+  fTrackPhi = TMath::Pi()+v0particleRefit.GetPhi();
+  ////find out which mass bin and put the number in fPOItype
+  //Int_t massBins = AliFlowCommonConstants::GetMaster()->GetNbinsMass();
+  //Double_t massMin = AliFlowCommonConstants::GetMaster()->GetMassMin();
+  //Double_t massMax = AliFlowCommonConstants::GetMaster()->GetMassMax();
+  //fPOItype = 1 + int(massBins*(fTrackMass-massMin)/(massMax-massMin));
+  
+  /////////////////////////////////////////////////////////////////////////////
+  //apply cuts
+  if ( v0tracks[0]->Charge() == v0tracks[1]->Charge() ) pass=kFALSE;
+  if ( v0tracks[0]->Pt()<0.15 || v0tracks[1]->Pt()<0.15 ) pass=kFALSE;
+
+  return pass;
+}
+
+//-----------------------------------------------------------------------
+Bool_t AliFlowTrackCuts::PassesCuts(const AliESDkink* kink)
+{
+  //check if the kink passes cuts
+  
+  //clean up from last iteration
+  ClearTrack();
+  fKink=const_cast<AliESDkink*>(kink);
+
+  Bool_t pass = kTRUE;
+
+  Float_t kinkAngle = kink->GetAngle(2);
+  if (kinkAngle<fMinKinkAngle) pass = kFALSE;
+  Double_t kinkRadius = kink->GetR();
+  if (kinkRadius<fMinKinkRadius || kinkRadius>fMaxKinkRadius) pass = kFALSE;
+
+  //Qt
+  const TVector3 motherMfromKink(kink->GetMotherP());
+  const TVector3 daughterMfromKink(kink->GetDaughterP());
+  Float_t qt=kink->GetQt();
+  if ( qt < fMinKinkQt || qt > fMaxKinkQt) pass = kFALSE;
+
+  //invariant mass
+  Float_t energyDaughterMu = TMath::Sqrt( daughterMfromKink.Mag()*daughterMfromKink.Mag()+
+                                          0.105658*0.105658 );
+  Float_t p1XM = motherMfromKink.Px();
+  Float_t p1YM = motherMfromKink.Py();
+  Float_t p1ZM = motherMfromKink.Pz();
+  Float_t p2XM = daughterMfromKink.Px();
+  Float_t p2YM = daughterMfromKink.Py();
+  Float_t p2ZM = daughterMfromKink.Pz();
+  Float_t p3Daughter = TMath::Sqrt( ((p1XM-p2XM)*(p1XM-p2XM))+((p1YM-p2YM)*(p1YM-p2YM))+
+                                    ((p1ZM-p2ZM)*(p1ZM-p2ZM)) );
+  Double_t invariantMassKmu = TMath::Sqrt( (energyDaughterMu+p3Daughter)*(energyDaughterMu+p3Daughter)-
+                                           motherMfromKink.Mag()*motherMfromKink.Mag() );
+  if (invariantMassKmu > fMaxKinkInvMassKmu) pass=kFALSE;
+  if (invariantMassKmu < fMinKinkInvMassKmu) pass=kFALSE;
+  fTrackMass=invariantMassKmu;
+
+  if (fQA)
+  {
+    QAbefore(13)->Fill(qt);
+    if (pass) QAafter(13)->Fill(qt);
+    QAbefore(14)->Fill(invariantMassKmu);
+    if (pass) QAafter(14)->Fill(invariantMassKmu);
+    const Double_t* kinkPosition = kink->GetPosition();
+    QAbefore(15)->Fill(kinkPosition[0],kinkPosition[1]);
+    if (pass) QAafter(15)->Fill(kinkPosition[0],kinkPosition[1]);
+    QAbefore(16)->Fill(motherMfromKink.Mag(),kinkAngle*TMath::RadToDeg());
+    if (pass) QAafter(16)->Fill(motherMfromKink.Mag(),kinkAngle*TMath::RadToDeg());
+  }
+
+  //mother track cuts
+  Int_t indexKinkMother = kink->GetIndex(0);
+  AliESDtrack* motherTrack = dynamic_cast<AliESDtrack*>(fEvent->GetTrack(indexKinkMother));
+  if (!motherTrack) return kFALSE;
+  if (!PassesCuts(motherTrack)) pass = kFALSE;
+  
+  return pass;
+}
+
 //-----------------------------------------------------------------------
 Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
 {
@@ -716,7 +895,8 @@ Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
   //  start by preparing the track parameters to cut on //////////
   ////////////////////////////////////////////////////////////////
   //clean up from last iteration
-  fTrack=NULL; 
+  ClearTrack();
+  Bool_t pass=kTRUE;
 
   //get the label and the mc particle
   fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
@@ -746,7 +926,6 @@ Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
   //because it may be different from global, not needed for aodTrack because we dont do anything funky there
   if (esdTrack) esdTrack = static_cast<AliESDtrack*>(fTrack);
   
-  Bool_t pass=kTRUE;
   //check the common cuts for the current particle fTrack (MC,AOD,ESD)
   Double_t pt = fTrack->Pt();
   Double_t p = fTrack->P();
@@ -1116,6 +1295,8 @@ Bool_t AliFlowTrackCuts::PassesESDcuts(AliESDtrack* track)
     QAbefore(6)->Fill(pt,dcaz);
     if (pass) QAafter(5)->Fill(pt,dcaxy);
     if (pass) QAafter(6)->Fill(pt,dcaz);
+    QAbefore(17)->Fill(Float_t(track->GetKinkIndex(0)));
+    if (pass) QAafter(17)->Fill(Float_t(track->GetKinkIndex(0)));
   }
 
   return pass;
@@ -1157,7 +1338,23 @@ void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
       else fMCparticle=NULL;
       break;
     default:
-      fTrack = track;
+      if (fForceTPCstandalone)
+      {
+        if (!track->FillTPCOnlyTrack(fTPCtrack))
+        {
+          fTrack=NULL;
+          fMCparticle=NULL;
+          fTrackLabel=-998;
+          return;
+        }
+        fTrack = &fTPCtrack;
+        //recalculate the label and mc particle, they may differ as TPClabel != global label
+        fTrackLabel = (fFakesAreOK)?TMath::Abs(fTrack->GetLabel()):fTrack->GetLabel();
+        if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
+        else fMCparticle=NULL;
+      }
+      else 
+        fTrack = track;
       break;
   }
 }
@@ -1200,14 +1397,14 @@ AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts()
 //-----------------------------------------------------------------------
 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2010()
 {
-  //get standard V0 cuts
+  //get standard VZERO cuts
   AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts 2010");
-  cuts->SetParamType(kV0);
+  cuts->SetParamType(kVZERO);
   cuts->SetEtaRange( -10, +10 );
   cuts->SetPhiMin( 0 );
   cuts->SetPhiMax( TMath::TwoPi() );
   // options for the reweighting
-  cuts->SetV0gainEqualizationPerRing(kFALSE);
+  cuts->SetVZEROgainEqualizationPerRing(kFALSE);
   cuts->SetApplyRecentering(kTRUE);
   // to exclude a ring , do e.g.
   // cuts->SetUseVZERORing(7, kFALSE);
@@ -1216,7 +1413,7 @@ AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2010()
 //-----------------------------------------------------------------------
 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2011()
 {
-  //get standard V0 cuts for 2011 data
+  //get standard VZERO cuts for 2011 data
   //in this case, the vzero segments will be weighted by
   //VZEROEqMultiplicity, 
   //if recentering is enableded, the sub-q vectors
@@ -1233,7 +1430,7 @@ AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2011()
   //  AddTaskVZEROEPSelection();
   //
   AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts 2011");
-  cuts->SetParamType(kV0);
+  cuts->SetParamType(kVZERO);
   cuts->SetEtaRange( -10, +10 );
   cuts->SetPhiMin( 0 );
   cuts->SetPhiMax( TMath::TwoPi() );
@@ -1326,55 +1523,101 @@ AliFlowTrackCuts* AliFlowTrackCuts::GetStandardMuonTrackCuts(Bool_t isMC, Int_t
 }
 
 //-----------------------------------------------------------------------
-Bool_t AliFlowTrackCuts::FillFlowTrackGeneric(AliFlowTrack* flowtrack) const
-{
-  //fill a flow track from tracklet,vzero,pmd,...
-  TParticle *tmpTParticle=NULL;
-  AliMCParticle* tmpAliMCParticle=NULL;
-  switch (fParamMix)
-  {
-    case kPure:
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
-    case kTrackWithMCkine:
-      if (!fMCparticle) return kFALSE;
-      flowtrack->SetPhi( fMCparticle->Phi() );
-      flowtrack->SetEta( fMCparticle->Eta() );
-      flowtrack->SetPt( fMCparticle->Pt() );
-      break;
-    case kTrackWithMCpt:
-      if (!fMCparticle) return kFALSE;
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      flowtrack->SetPt(fMCparticle->Pt());
-      break;
-    case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return kFALSE;
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      tmpTParticle = fMCparticle->Particle();
-      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
-      flowtrack->SetPt(tmpAliMCParticle->Pt());
-      break;
-    default:
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
-  }
-  flowtrack->SetSource(AliFlowTrack::kFromTracklet);
-  return kTRUE;
-}
+//AliFlowTrack* AliFlowTrackCuts::FillFlowTrackV0(TObjArray* trackCollection, Int_t trackIndex) const
+//{
+//  //fill flow track from a reconstructed V0 (topological)
+//  AliFlowTrack* flowtrack = static_cast<AliFlowTrack*>(trackCollection->At(trackIndex));
+//  if (flowtrack)
+//  {
+//    flowtrack->Clear();
+//  }
+//  else 
+//  {
+//    flowtrack = new AliFlowCandidateTrack();
+//    trackCollection->AddAtAndExpand(flowtrack,trackIndex);
+//  }
+//
+//  TParticle *tmpTParticle=NULL;
+//  AliMCParticle* tmpAliMCParticle=NULL;
+//  AliExternalTrackParam* externalParams=NULL;
+//  AliESDtrack* esdtrack=NULL;
+//  switch(fParamMix)
+//  {
+//    case kPure:
+//      flowtrack->Set(fTrack);
+//      break;
+//    case kTrackWithMCkine:
+//      flowtrack->Set(fMCparticle);
+//      break;
+//    case kTrackWithMCPID:
+//      flowtrack->Set(fTrack);
+//      //flowtrack->setPID(...) from mc, when implemented
+//      break;
+//    case kTrackWithMCpt:
+//      if (!fMCparticle) return NULL;
+//      flowtrack->Set(fTrack);
+//      flowtrack->SetPt(fMCparticle->Pt());
+//      break;
+//    case kTrackWithPtFromFirstMother:
+//      if (!fMCparticle) return NULL;
+//      flowtrack->Set(fTrack);
+//      tmpTParticle = fMCparticle->Particle();
+//      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
+//      flowtrack->SetPt(tmpAliMCParticle->Pt());
+//      break;
+//    case kTrackWithTPCInnerParams:
+//      esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
+//      if (!esdtrack) return NULL;
+//      externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
+//      if (!externalParams) return NULL;
+//      flowtrack->Set(externalParams);
+//      break;
+//    default:
+//      flowtrack->Set(fTrack);
+//      break;
+//  }
+//  if (fParamType==kMC) 
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromMC);
+//    flowtrack->SetID(fTrackLabel);
+//  }
+//  else if (dynamic_cast<AliAODTrack*>(fTrack))
+//  {
+//    if (fParamType==kMUON)                            // XZhang 20120604
+//      flowtrack->SetSource(AliFlowTrack::kFromMUON);  // XZhang 20120604
+//    else                                              // XZhang 20120604
+//      flowtrack->SetSource(AliFlowTrack::kFromAOD);   // XZhang 20120604
+//    flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
+//  }
+//  else if (dynamic_cast<AliMCParticle*>(fTrack)) 
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromMC);
+//    flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
+//  }
+//
+//  if (fV0)
+//  {
+//    //add daughter indices
+//  }
+//
+//  return flowtrack;
+//}
 
 //-----------------------------------------------------------------------
-Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
+AliFlowTrack* AliFlowTrackCuts::FillFlowTrackKink(TObjArray* trackCollection, Int_t trackIndex) const
 {
   //fill flow track from AliVParticle (ESD,AOD,MC)
-  if (!fTrack) return kFALSE;
+  AliFlowTrack* flowtrack = static_cast<AliFlowTrack*>(trackCollection->At(trackIndex));
+  if (flowtrack)
+  {
+    flowtrack->Clear();
+  }
+  else 
+  {
+    flowtrack = new AliFlowCandidateTrack();
+    trackCollection->AddAtAndExpand(flowtrack,trackIndex);
+  }
+
   TParticle *tmpTParticle=NULL;
   AliMCParticle* tmpAliMCParticle=NULL;
   AliExternalTrackParam* externalParams=NULL;
@@ -1392,12 +1635,12 @@ Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
       //flowtrack->setPID(...) from mc, when implemented
       break;
     case kTrackWithMCpt:
-      if (!fMCparticle) return kFALSE;
+      if (!fMCparticle) return NULL;
       flowtrack->Set(fTrack);
       flowtrack->SetPt(fMCparticle->Pt());
       break;
     case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return kFALSE;
+      if (!fMCparticle) return NULL;
       flowtrack->Set(fTrack);
       tmpTParticle = fMCparticle->Particle();
       tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
@@ -1405,9 +1648,9 @@ Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
       break;
     case kTrackWithTPCInnerParams:
       esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
-      if (!esdtrack) return kFALSE;
+      if (!esdtrack) return NULL;
       externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
-      if (!externalParams) return kFALSE;
+      if (!externalParams) return NULL;
       flowtrack->Set(externalParams);
       break;
     default:
@@ -1442,84 +1685,128 @@ Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
     flowtrack->SetSource(AliFlowTrack::kFromMC);
     flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
   }
-  return kTRUE;
+
+  if (fKink)
+  {
+    Int_t indexMother = fKink->GetIndex(0);
+    Int_t indexDaughter = fKink->GetIndex(1);
+    flowtrack->SetID(indexMother);
+    flowtrack->AddDaughter(indexDaughter);
+    flowtrack->SetMass(1.);
+    flowtrack->SetSource(AliFlowTrack::kFromKink);
+  }
+
+  flowtrack->SetMass(fTrackMass);
+
+  return flowtrack;
 }
 
 //-----------------------------------------------------------------------
-Bool_t AliFlowTrackCuts::FillFlowTrack(AliFlowTrack* track) const
+AliFlowTrack* AliFlowTrackCuts::FillFlowTrackGeneric(TObjArray* trackCollection, Int_t trackIndex) const
 {
-  //fill a flow track constructed from whatever we applied cuts on
-  //return true on success
-  switch (fParamType)
+  //fill a flow track from tracklet,vzero,pmd,...
+  AliFlowTrack* flowtrack = static_cast<AliFlowTrack*>(trackCollection->At(trackIndex));
+  if (flowtrack)
   {
-    case kSPDtracklet:
-      return FillFlowTrackGeneric(track);
-    case kPMD:
-      return FillFlowTrackGeneric(track);
-    case kV0:
-      return FillFlowTrackGeneric(track);
-    default:
-      return FillFlowTrackVParticle(track);
+    flowtrack->Clear();
+  }
+  else 
+  {
+    flowtrack = new AliFlowTrack();
+    trackCollection->AddAtAndExpand(flowtrack,trackIndex);
+  }
+  
+  if (FillFlowTrackGeneric(flowtrack)) return flowtrack;
+  else 
+  {
+    trackCollection->RemoveAt(trackIndex);
+    delete flowtrack;
+    return NULL;
   }
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackSPDtracklet() const
+Bool_t AliFlowTrackCuts::FillFlowTrackGeneric(AliFlowTrack* flowtrack) const
 {
-  //make a flow track from tracklet
-  AliFlowTrack* flowtrack=NULL;
+  //fill a flow track from tracklet,vzero,pmd,...
   TParticle *tmpTParticle=NULL;
   AliMCParticle* tmpAliMCParticle=NULL;
   switch (fParamMix)
   {
     case kPure:
-      flowtrack = new AliFlowTrack();
       flowtrack->SetPhi(fTrackPhi);
       flowtrack->SetEta(fTrackEta);
       flowtrack->SetWeight(fTrackWeight);
+      flowtrack->SetPt(fTrackPt);
+      flowtrack->SetMass(fTrackMass);
       break;
     case kTrackWithMCkine:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
+      if (!fMCparticle) return kFALSE;
       flowtrack->SetPhi( fMCparticle->Phi() );
       flowtrack->SetEta( fMCparticle->Eta() );
       flowtrack->SetPt( fMCparticle->Pt() );
+      flowtrack->SetMass(fTrackMass);
       break;
     case kTrackWithMCpt:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
+      if (!fMCparticle) return kFALSE;
       flowtrack->SetPhi(fTrackPhi);
       flowtrack->SetEta(fTrackEta);
       flowtrack->SetWeight(fTrackWeight);
       flowtrack->SetPt(fMCparticle->Pt());
+      flowtrack->SetMass(fTrackMass);
       break;
     case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
+      if (!fMCparticle) return kFALSE;
       flowtrack->SetPhi(fTrackPhi);
       flowtrack->SetEta(fTrackEta);
       flowtrack->SetWeight(fTrackWeight);
       tmpTParticle = fMCparticle->Particle();
       tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
       flowtrack->SetPt(tmpAliMCParticle->Pt());
+      flowtrack->SetMass(fTrackMass);
       break;
     default:
-      flowtrack = new AliFlowTrack();
       flowtrack->SetPhi(fTrackPhi);
       flowtrack->SetEta(fTrackEta);
       flowtrack->SetWeight(fTrackWeight);
+      flowtrack->SetPt(fTrackPt);
+      flowtrack->SetMass(fTrackMass);
       break;
   }
   flowtrack->SetSource(AliFlowTrack::kFromTracklet);
-  return flowtrack;
+  return kTRUE;
+}
+
+//-----------------------------------------------------------------------
+AliFlowTrack* AliFlowTrackCuts::FillFlowTrackVParticle(TObjArray* trackCollection, Int_t trackIndex) const
+{
+  //fill flow track from AliVParticle (ESD,AOD,MC)
+  
+  AliFlowTrack* flowtrack = static_cast<AliFlowTrack*>(trackCollection->At(trackIndex));
+  if (flowtrack)
+  {
+    flowtrack->Clear();
+  }
+  else 
+  {
+    flowtrack = new AliFlowTrack();
+    trackCollection->AddAtAndExpand(flowtrack,trackIndex);
+  }
+
+  if (FillFlowTrackVParticle(flowtrack)) return flowtrack;
+  else
+  {
+    trackCollection->RemoveAt(trackIndex);
+    delete flowtrack;
+    return NULL;
+  }
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
+Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
 {
-  //make flow track from AliVParticle (ESD,AOD,MC)
-  if (!fTrack) return NULL;
-  AliFlowTrack* flowtrack=NULL;
+  //fill flow track from AliVParticle (ESD,AOD,MC)
+  if (!fTrack) return kFALSE;
   TParticle *tmpTParticle=NULL;
   AliMCParticle* tmpAliMCParticle=NULL;
   AliExternalTrackParam* externalParams=NULL;
@@ -1527,36 +1814,36 @@ AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
   switch(fParamMix)
   {
     case kPure:
-      flowtrack = new AliFlowTrack(fTrack);
+      flowtrack->Set(fTrack);
       break;
     case kTrackWithMCkine:
-      flowtrack = new AliFlowTrack(fMCparticle);
+      flowtrack->Set(fMCparticle);
       break;
     case kTrackWithMCPID:
-      flowtrack = new AliFlowTrack(fTrack);
+      flowtrack->Set(fTrack);
       //flowtrack->setPID(...) from mc, when implemented
       break;
     case kTrackWithMCpt:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack(fTrack);
+      if (!fMCparticle) return kFALSE;
+      flowtrack->Set(fTrack);
       flowtrack->SetPt(fMCparticle->Pt());
       break;
     case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack(fTrack);
+      if (!fMCparticle) return kFALSE;
+      flowtrack->Set(fTrack);
       tmpTParticle = fMCparticle->Particle();
       tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
       flowtrack->SetPt(tmpAliMCParticle->Pt());
       break;
     case kTrackWithTPCInnerParams:
       esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
-      if (!esdtrack) return NULL;
+      if (!esdtrack) return kFALSE;
       externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
-      if (!externalParams) return NULL;
-      flowtrack = new AliFlowTrack(externalParams);
+      if (!externalParams) return kFALSE;
+      flowtrack->Set(externalParams);
       break;
     default:
-      flowtrack = new AliFlowTrack(fTrack);
+      flowtrack->Set(fTrack);
       break;
   }
   if (fParamType==kMC) 
@@ -1569,9 +1856,17 @@ AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
     flowtrack->SetSource(AliFlowTrack::kFromESD);
     flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
   }
-  else if (dynamic_cast<AliAODTrack*>(fTrack)) 
+  else if (dynamic_cast<AliESDMuonTrack*>(fTrack))                                  // XZhang 20120604
+  {                                                                                 // XZhang 20120604
+    flowtrack->SetSource(AliFlowTrack::kFromMUON);                                  // XZhang 20120604
+    flowtrack->SetID((Int_t)static_cast<AliESDMuonTrack*>(fTrack)->GetUniqueID());  // XZhang 20120604
+  }                                                                                 // XZhang 20120604
+  else if (dynamic_cast<AliAODTrack*>(fTrack))
   {
-    flowtrack->SetSource(AliFlowTrack::kFromAOD);
+    if (fParamType==kMUON)                            // XZhang 20120604
+      flowtrack->SetSource(AliFlowTrack::kFromMUON);  // XZhang 20120604
+    else                                              // XZhang 20120604
+      flowtrack->SetSource(AliFlowTrack::kFromAOD);   // XZhang 20120604
     flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
   }
   else if (dynamic_cast<AliMCParticle*>(fTrack)) 
@@ -1579,137 +1874,297 @@ AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
     flowtrack->SetSource(AliFlowTrack::kFromMC);
     flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
   }
-  return flowtrack;
-}
-
-//-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackPMDtrack() const
-{
-  //make a flow track from PMD track
-  AliFlowTrack* flowtrack=NULL;
-  TParticle *tmpTParticle=NULL;
-  AliMCParticle* tmpAliMCParticle=NULL;
-  switch (fParamMix)
-  {
-    case kPure:
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
-    case kTrackWithMCkine:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi( fMCparticle->Phi() );
-      flowtrack->SetEta( fMCparticle->Eta() );
-      flowtrack->SetWeight(fTrackWeight);
-      flowtrack->SetPt( fMCparticle->Pt() );
-      break;
-    case kTrackWithMCpt:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      flowtrack->SetPt(fMCparticle->Pt());
-      break;
-    case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      tmpTParticle = fMCparticle->Particle();
-      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
-      flowtrack->SetPt(tmpAliMCParticle->Pt());
-      break;
-    default:
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
-  }
-
-  flowtrack->SetSource(AliFlowTrack::kFromPMD);
-  return flowtrack;
+  flowtrack->SetMass(fTrackMass);
+  return kTRUE;
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackV0() const
+AliFlowTrack* AliFlowTrackCuts::FillFlowTrack(TObjArray* trackCollection, Int_t trackIndex) const
 {
-  //make a flow track from V0
-  AliFlowTrack* flowtrack=NULL;
-  TParticle *tmpTParticle=NULL;
-  AliMCParticle* tmpAliMCParticle=NULL;
-  switch (fParamMix)
+  //fill a flow track constructed from whatever we applied cuts on
+  //return true on success
+  switch (fParamType)
   {
-    case kPure:
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
-    case kTrackWithMCkine:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi( fMCparticle->Phi() );
-      flowtrack->SetEta( fMCparticle->Eta() );
-      flowtrack->SetWeight(fTrackWeight);
-      flowtrack->SetPt( fMCparticle->Pt() );
-      break;
-    case kTrackWithMCpt:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      flowtrack->SetPt(fMCparticle->Pt());
-      break;
-    case kTrackWithPtFromFirstMother:
-      if (!fMCparticle) return NULL;
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      tmpTParticle = fMCparticle->Particle();
-      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
-      flowtrack->SetPt(tmpAliMCParticle->Pt());
-      break;
+    case kSPDtracklet:
+      return FillFlowTrackGeneric(trackCollection, trackIndex);
+    case kPMD:
+      return FillFlowTrackGeneric(trackCollection, trackIndex);
+    case kVZERO:
+      return FillFlowTrackGeneric(trackCollection, trackIndex);
+    case kKink:
+      return FillFlowTrackKink(trackCollection, trackIndex);
+    //case kV0:
+    //  return FillFlowTrackV0(trackCollection, trackIndex);
     default:
-      flowtrack = new AliFlowTrack();
-      flowtrack->SetPhi(fTrackPhi);
-      flowtrack->SetEta(fTrackEta);
-      flowtrack->SetWeight(fTrackWeight);
-      break;
+      return FillFlowTrackVParticle(trackCollection, trackIndex);
   }
-
-  flowtrack->SetSource(AliFlowTrack::kFromV0);
-  return flowtrack;
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
+Bool_t AliFlowTrackCuts::FillFlowTrack(AliFlowTrack* track) const
 {
-  //get a flow track constructed from whatever we applied cuts on
-  //caller is resposible for deletion
-  //if construction fails return NULL
-  //TODO: for tracklets, PMD and V0 we probably need just one method,
-  //something like MakeFlowTrackGeneric(), wait with this until
-  //requirements quirks are known.
+  //fill a flow track constructed from whatever we applied cuts on
+  //return true on success
   switch (fParamType)
   {
     case kSPDtracklet:
-      return MakeFlowTrackSPDtracklet();
+      return FillFlowTrackGeneric(track);
     case kPMD:
-      return MakeFlowTrackPMDtrack();
-    case kV0:
-      return MakeFlowTrackV0();
+      return FillFlowTrackGeneric(track);
+    case kVZERO:
+      return FillFlowTrackGeneric(track);
     default:
-      return MakeFlowTrackVParticle();
+      return FillFlowTrackVParticle(track);
   }
 }
 
+////-----------------------------------------------------------------------
+//AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackSPDtracklet() const
+//{
+//  //make a flow track from tracklet
+//  AliFlowTrack* flowtrack=NULL;
+//  TParticle *tmpTParticle=NULL;
+//  AliMCParticle* tmpAliMCParticle=NULL;
+//  switch (fParamMix)
+//  {
+//    case kPure:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//    case kTrackWithMCkine:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi( fMCparticle->Phi() );
+//      flowtrack->SetEta( fMCparticle->Eta() );
+//      flowtrack->SetPt( fMCparticle->Pt() );
+//      break;
+//    case kTrackWithMCpt:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      flowtrack->SetPt(fMCparticle->Pt());
+//      break;
+//    case kTrackWithPtFromFirstMother:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      tmpTParticle = fMCparticle->Particle();
+//      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
+//      flowtrack->SetPt(tmpAliMCParticle->Pt());
+//      break;
+//    default:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//  }
+//  flowtrack->SetSource(AliFlowTrack::kFromTracklet);
+//  return flowtrack;
+//}
+//
+////-----------------------------------------------------------------------
+//AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
+//{
+//  //make flow track from AliVParticle (ESD,AOD,MC)
+//  if (!fTrack) return NULL;
+//  AliFlowTrack* flowtrack=NULL;
+//  TParticle *tmpTParticle=NULL;
+//  AliMCParticle* tmpAliMCParticle=NULL;
+//  AliExternalTrackParam* externalParams=NULL;
+//  AliESDtrack* esdtrack=NULL;
+//  switch(fParamMix)
+//  {
+//    case kPure:
+//      flowtrack = new AliFlowTrack(fTrack);
+//      break;
+//    case kTrackWithMCkine:
+//      flowtrack = new AliFlowTrack(fMCparticle);
+//      break;
+//    case kTrackWithMCPID:
+//      flowtrack = new AliFlowTrack(fTrack);
+//      //flowtrack->setPID(...) from mc, when implemented
+//      break;
+//    case kTrackWithMCpt:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack(fTrack);
+//      flowtrack->SetPt(fMCparticle->Pt());
+//      break;
+//    case kTrackWithPtFromFirstMother:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack(fTrack);
+//      tmpTParticle = fMCparticle->Particle();
+//      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
+//      flowtrack->SetPt(tmpAliMCParticle->Pt());
+//      break;
+//    case kTrackWithTPCInnerParams:
+//      esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
+//      if (!esdtrack) return NULL;
+//      externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
+//      if (!externalParams) return NULL;
+//      flowtrack = new AliFlowTrack(externalParams);
+//      break;
+//    default:
+//      flowtrack = new AliFlowTrack(fTrack);
+//      break;
+//  }
+//  if (fParamType==kMC) 
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromMC);
+//    flowtrack->SetID(fTrackLabel);
+//  }
+//  else if (dynamic_cast<AliESDtrack*>(fTrack))
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromESD);
+//    flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
+//  }
+//  else if (dynamic_cast<AliAODTrack*>(fTrack)) 
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromAOD);
+//    flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
+//  }
+//  else if (dynamic_cast<AliMCParticle*>(fTrack)) 
+//  {
+//    flowtrack->SetSource(AliFlowTrack::kFromMC);
+//    flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
+//  }
+//  return flowtrack;
+//}
+//
+////-----------------------------------------------------------------------
+//AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackPMDtrack() const
+//{
+//  //make a flow track from PMD track
+//  AliFlowTrack* flowtrack=NULL;
+//  TParticle *tmpTParticle=NULL;
+//  AliMCParticle* tmpAliMCParticle=NULL;
+//  switch (fParamMix)
+//  {
+//    case kPure:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//    case kTrackWithMCkine:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi( fMCparticle->Phi() );
+//      flowtrack->SetEta( fMCparticle->Eta() );
+//      flowtrack->SetWeight(fTrackWeight);
+//      flowtrack->SetPt( fMCparticle->Pt() );
+//      break;
+//    case kTrackWithMCpt:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      flowtrack->SetPt(fMCparticle->Pt());
+//      break;
+//    case kTrackWithPtFromFirstMother:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      tmpTParticle = fMCparticle->Particle();
+//      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
+//      flowtrack->SetPt(tmpAliMCParticle->Pt());
+//      break;
+//    default:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//  }
+//
+//  flowtrack->SetSource(AliFlowTrack::kFromPMD);
+//  return flowtrack;
+//}
+//
+////-----------------------------------------------------------------------
+//AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVZERO() const
+//{
+//  //make a flow track from VZERO
+//  AliFlowTrack* flowtrack=NULL;
+//  TParticle *tmpTParticle=NULL;
+//  AliMCParticle* tmpAliMCParticle=NULL;
+//  switch (fParamMix)
+//  {
+//    case kPure:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//    case kTrackWithMCkine:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi( fMCparticle->Phi() );
+//      flowtrack->SetEta( fMCparticle->Eta() );
+//      flowtrack->SetWeight(fTrackWeight);
+//      flowtrack->SetPt( fMCparticle->Pt() );
+//      break;
+//    case kTrackWithMCpt:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      flowtrack->SetPt(fMCparticle->Pt());
+//      break;
+//    case kTrackWithPtFromFirstMother:
+//      if (!fMCparticle) return NULL;
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      tmpTParticle = fMCparticle->Particle();
+//      tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
+//      flowtrack->SetPt(tmpAliMCParticle->Pt());
+//      break;
+//    default:
+//      flowtrack = new AliFlowTrack();
+//      flowtrack->SetPhi(fTrackPhi);
+//      flowtrack->SetEta(fTrackEta);
+//      flowtrack->SetWeight(fTrackWeight);
+//      break;
+//  }
+//
+//  flowtrack->SetSource(AliFlowTrack::kFromVZERO);
+//  return flowtrack;
+//}
+//
+////-----------------------------------------------------------------------
+//AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
+//{
+//  //get a flow track constructed from whatever we applied cuts on
+//  //caller is resposible for deletion
+//  //if construction fails return NULL
+//  //TODO: for tracklets, PMD and VZERO we probably need just one method,
+//  //something like MakeFlowTrackGeneric(), wait with this until
+//  //requirements quirks are known.
+//  switch (fParamType)
+//  {
+//    case kSPDtracklet:
+//      return MakeFlowTrackSPDtracklet();
+//    case kPMD:
+//      return MakeFlowTrackPMDtrack();
+//    case kVZERO:
+//      return MakeFlowTrackVZERO();
+//    default:
+//      return MakeFlowTrackVParticle();
+//  }
+//}
+
 //-----------------------------------------------------------------------
 Bool_t AliFlowTrackCuts::IsPhysicalPrimary() const
 {
@@ -1914,6 +2369,21 @@ void AliFlowTrackCuts::DefineHistograms()
   before->Add(new TH2F("TOFkProton",";p_{t}[GeV/c];TOF signal - IT",   kNbinsP,binsP,1000,-2e4, 2e4));//12
   after->Add( new TH2F("TOFkProton",";p_{t}[GeV/c];TOF signal - IT",   kNbinsP,binsP,1000,-2e4, 2e4));//12
 
+  //kink stuff
+  before->Add(new TH1F("KinkQt",";q_{t}[GeV/c];counts", 200, 0., 0.3));//13
+  after->Add(new TH1F("KinkQt",";q_{t}[GeV/c];counts", 200, 0., 0.3));//13
+
+  before->Add(new TH1F("KinkMinv",";m_{inv}(#mu#nu)[GeV/c^{2}];counts;Kink M_{inv}", 200, 0., 0.7));//14
+  after->Add(new TH1F("KinkMinv",";m_{inv}(#mu#nu)[GeV/c^{2}];counts;Kink M_{inv}", 200, 0., 0.7));//14
+
+  before->Add(new TH2F("KinkVertex",";x[cm];y[cm];Kink vertex position",250,-250.,250., 250,-250.,250.));//15
+  after->Add(new TH2F("KinkVertex",";x[cm];y[cm];Kink vertex position",250,-250.,250., 250,-250.,250.));//15
+
+  before->Add(new TH2F("KinkAngleMp",";p_{mother}[GeV/c];Kink decay angle [deg];", 100,0.,6., 100,0.,80.));//16
+  after->Add(new TH2F("KinkAngleMp",";p_{mother}[GeV/c];Kink decay angle [deg];", 100,0.,6., 100,0.,80.));//16
+
+  before->Add(new TH1F("KinkIndex",";Kink index;counts", 2, 0., 2.));//17
+  after->Add(new TH1F("KinkIndex",";Kink index;counts", 2, 0., 2.));//17
   TH1::AddDirectory(adddirstatus);
 }
 
@@ -1941,13 +2411,21 @@ Int_t AliFlowTrackCuts::GetNumberOfInputObjects() const
       esd = dynamic_cast<AliESDEvent*>(fEvent);
       if (!esd) return 0;
       return esd->GetNumberOfPmdTracks();
-    case kV0:
-      return fgkNumberOfV0tracks;
+    case kVZERO:
+      return fgkNumberOfVZEROtracks;
     case kMUON:                                      // XZhang 20120604
       if (!fEvent) return 0;                         // XZhang 20120604
       esd = dynamic_cast<AliESDEvent*>(fEvent);      // XZhang 20120604
       if (esd) return esd->GetNumberOfMuonTracks();  // XZhang 20120604
       return fEvent->GetNumberOfTracks();  // if AOD // XZhang 20120604
+    case kKink:
+      esd = dynamic_cast<AliESDEvent*>(fEvent);
+      if (!esd) return 0;
+      return esd->GetNumberOfKinks();
+    case kV0:
+      esd = dynamic_cast<AliESDEvent*>(fEvent);
+      if (!esd) return 0;
+      return esd->GetNumberOfV0s();
     default:
       if (!fEvent) return 0;
       return fEvent->GetNumberOfTracks();
@@ -1979,21 +2457,28 @@ TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
       esd = dynamic_cast<AliESDEvent*>(fEvent);
       if (!esd) return NULL;
       return esd->GetPmdTrack(i);
-    case kV0:
-      //esd = dynamic_cast<AliESDEvent*>(fEvent);
-      //if (!esd) //contributed by G.Ortona
-      //{
-      //  AliAODEvent* aod = dynamic_cast<AliAODEvent*>(fEvent);
-      //  if(!aod)return NULL;
-      //  return aod->GetVZEROData();
-      //}
-      //return esd->GetVZEROData();
-      return fEvent; // left only for compatibility
+    case kVZERO:
+      esd = dynamic_cast<AliESDEvent*>(fEvent);
+      if (!esd) //contributed by G.Ortona
+      {
+        aod = dynamic_cast<AliAODEvent*>(fEvent);
+        if(!aod)return NULL;
+        return aod->GetVZEROData();
+      }
+      return esd->GetVZEROData();
     case kMUON:                                  // XZhang 20120604
       if (!fEvent) return NULL;                  // XZhang 20120604
       esd = dynamic_cast<AliESDEvent*>(fEvent);  // XZhang 20120604
       if (esd) return esd->GetMuonTrack(i);      // XZhang 20120604
       return fEvent->GetTrack(i);  // if AOD     // XZhang 20120604
+    case kKink:
+      esd = dynamic_cast<AliESDEvent*>(fEvent);
+      if (!esd) return NULL;
+      return esd->GetKink(i);
+    case kV0:
+      esd = dynamic_cast<AliESDEvent*>(fEvent);
+      if (!esd) return NULL;
+      return esd->GetV0(i);
     default:
       if (!fEvent) return NULL;
       return fEvent->GetTrack(i);
@@ -2004,13 +2489,26 @@ TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
 void AliFlowTrackCuts::Clear(Option_t*)
 {
   //clean up
-  fTrack=NULL;
   fMCevent=NULL;
+  fEvent=NULL;
+  ClearTrack();
+}
+
+//-----------------------------------------------------------------------
+void AliFlowTrackCuts::ClearTrack(Option_t*)
+{
+  //clean up last track
+  fKink=NULL;
+  fV0=NULL;
+  fTrack=NULL;
   fMCparticle=NULL;
   fTrackLabel=-997;
   fTrackWeight=1.0;
   fTrackEta=0.0;
   fTrackPhi=0.0;
+  fTrackPt=0.0;
+  fPOItype=1;
+  fTrackMass=0.;
 }
 //-----------------------------------------------------------------------
 Bool_t AliFlowTrackCuts::PassesAODpidCut(const AliAODTrack* track )
@@ -4093,10 +4591,14 @@ const char* AliFlowTrackCuts::GetParamTypeName(trackParameterType type)
       return "SPDtracklets";
     case kPMD:
       return "PMD";
-    case kV0:
-      return "V0";
+    case kVZERO:
+      return "VZERO";
     case kMUON:       // XZhang 20120604
       return "MUON";  // XZhang 20120604
+    case kKink:
+      return "Kink";
+    case kV0:
+      return "V0";
     default:
       return "unknown";
   }
@@ -4134,50 +4636,48 @@ Bool_t AliFlowTrackCuts::PassesPMDcuts(const AliESDPmdTrack* track )
 }
   
 //-----------------------------------------------------------------------
-Bool_t AliFlowTrackCuts::PassesV0cuts(Int_t id)
+Bool_t AliFlowTrackCuts::PassesVZEROcuts(Int_t id)
 {
-  //check V0 cuts
+  //check VZERO cuts
   if (id<0) return kFALSE;
 
   //clean up from last iter
-  fTrack = NULL;
-  fMCparticle=NULL;
-  fTrackLabel=-995;
+  ClearTrack();
 
   fTrackPhi = TMath::PiOver4()*(0.5+id%8);
 
   // 10102013 weighting vzero tiles - rbertens@cern.ch
-  if(!fV0gainEqualization) {
+  if(!fVZEROgainEqualization) {
       // if for some reason the equalization is not initialized (e.g. 2011 data)
-      // the fV0xpol[] weights are used to enable or disable vzero rings
+      // the fVZEROxpol[] weights are used to enable or disable vzero rings
     if(id<32) {   // v0c side
       fTrackEta = -3.45+0.5*(id/8);
-      if(id < 8) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Cpol[0];
-      else if (id < 16 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Cpol[1];
-      else if (id < 24 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Cpol[2];
-      else if (id < 32 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Cpol[3];
+      if(id < 8) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROCpol[0];
+      else if (id < 16 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROCpol[1];
+      else if (id < 24 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROCpol[2];
+      else if (id < 32 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROCpol[3];
     } else {       // v0a side
       fTrackEta = +4.8-0.6*((id/8)-4);
-      if( id < 40) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Apol[0];
-      else if ( id < 48 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Apol[1];
-      else if ( id < 56 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Apol[2];
-      else if ( id < 64 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fV0Apol[3];
+      if( id < 40) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROApol[0];
+      else if ( id < 48 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROApol[1];
+      else if ( id < 56 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROApol[2];
+      else if ( id < 64 ) fTrackWeight = fEvent->GetVZEROEqMultiplicity(id)*fVZEROApol[3];
     }
   } else { // the equalization is initialized
      // note that disabled rings have already been excluded on calibration level in 
-     // AliFlowEvent (so for a disabled ring, fV0xpol is zero
+     // AliFlowEvent (so for a disabled ring, fVZEROxpol is zero
     if(id<32) {    // v0c side
       fTrackEta = -3.45+0.5*(id/8);
-      if(id < 8) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Cpol[0]/fV0gainEqualization->GetBinContent(1+id);
-      else if (id < 16 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Cpol[1]/fV0gainEqualization->GetBinContent(1+id);
-      else if (id < 24 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Cpol[2]/fV0gainEqualization->GetBinContent(1+id);
-      else if (id < 32 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Cpol[3]/fV0gainEqualization->GetBinContent(1+id);
+      if(id < 8) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROCpol[0]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if (id < 16 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROCpol[1]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if (id < 24 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROCpol[2]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if (id < 32 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROCpol[3]/fVZEROgainEqualization->GetBinContent(1+id);
     } else {       // v0a side
       fTrackEta = +4.8-0.6*((id/8)-4);
-      if( id < 40) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Apol[0]/fV0gainEqualization->GetBinContent(1+id);
-      else if ( id < 48 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Apol[1]/fV0gainEqualization->GetBinContent(1+id);
-      else if ( id < 56 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Apol[2]/fV0gainEqualization->GetBinContent(1+id);
-      else if ( id < 64 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fV0Apol[3]/fV0gainEqualization->GetBinContent(1+id);
+      if( id < 40) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROApol[0]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if ( id < 48 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROApol[1]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if ( id < 56 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROApol[2]/fVZEROgainEqualization->GetBinContent(1+id);
+      else if ( id < 64 ) fTrackWeight = fEvent->GetVZEROData()->GetMultiplicity(id)*fVZEROApol[3]/fVZEROgainEqualization->GetBinContent(1+id);
     }
     // printf ( " tile %i and weight %.2f \n", id, fTrackWeight);
   }
@@ -4185,10 +4685,10 @@ Bool_t AliFlowTrackCuts::PassesV0cuts(Int_t id)
   if (fLinearizeVZEROresponse && id < 64)
   {
     //this is only needed in pass1 of LHC10h
-    Float_t multV0[fgkNumberOfV0tracks];
+    Float_t multVZERO[fgkNumberOfVZEROtracks];
     Float_t dummy=0.0;
-    AliESDUtils::GetCorrV0((AliESDEvent*)fEvent,dummy,multV0);
-    fTrackWeight = multV0[id];
+    AliESDUtils::GetCorrV0((AliESDEvent*)fEvent,dummy,multVZERO);
+    fTrackWeight = multVZERO[id];
   }
 
   Bool_t pass=kTRUE;
@@ -4202,7 +4702,7 @@ Bool_t AliFlowTrackCuts::PassesV0cuts(Int_t id)
 Bool_t AliFlowTrackCuts::PassesMuonCuts(AliVParticle* vparticle)
 {
 // XZhang 20120604
-  fTrack=NULL;
+  ClearTrack();
   fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
   if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
   else fMCparticle=NULL;
index 17e0b6a872f75c83330629dfed66b4c5b8915873..bfedc49d4d6ac819ddd7b65395170c734d23c29c 100644 (file)
@@ -34,6 +34,9 @@ class AliAODTrack;
 class AliESDtrack;
 class AliESDPmdTrack;
 class AliFlowBayesianPID;
+class AliESDkink;
+class AliESDv0;
+class AliESDVZERO;
 
 class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
 
@@ -60,16 +63,18 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
                             kTPCstandalone, 
                             kSPDtracklet,
                             kPMD,
-                            kV0,
-                            kVZERO=kV0,
-                            kMUON  // XZhang 20120604
+                            kV0,    //neutral reconstructed v0 particle
+                            kVZERO, //forward VZERO detector
+                            kMUON,  // XZhang 20120604
+                            kKink
                           };
   enum trackParameterMix  { kPure, 
                             kTrackWithMCkine, 
                             kTrackWithMCPID, 
                             kTrackWithMCpt, 
                             kTrackWithPtFromFirstMother,
-                            kTrackWithTPCInnerParams
+                            kTrackWithTPCInnerParams,
+                            kTrackWithTPCstandalone
                           };
   enum PIDsource {
                    kTPCpid,      // default TPC pid (via GetTPCpid)
@@ -116,7 +121,6 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   void SetPmdAdc(Float_t pmdAdc){fCutPmdAdc=kTRUE; fPmdAdc = pmdAdc; }
   void SetPmdNcell(Float_t pmdNcell) {fCutPmdNcell=kTRUE; fPmdNcell = pmdNcell; }                                               
   void SetPriors(Float_t centr = 0); // set my favourite priors for Bayesian PID (requested if Bayesian PID is used)
-  void SetFlowTagType(AliFlowTrackSimple::tagType t) {fFlowTagType=t;}
 
   AliMuonTrackCuts *GetMuonTrackCuts() { InitMuonCuts(); return fMuonTrackCuts; }                           // XZhang 20121014
   void SetStandardMuonTrackCuts()      { InitMuonCuts(); fMuonTrackCuts->SetDefaultFilterMask(); return; }  // XZhang 20120604
@@ -124,6 +128,25 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   void SetMuonPassNumber(Int_t passN)  { InitMuonCuts(); fMuonTrackCuts->SetPassNumber(passN);   return; }  // XZhang 20121013
   void SetRunsMuon(const AliInputEventHandler* eventHandler) { if (fMuonTrackCuts) fMuonTrackCuts->SetRun(eventHandler); }  // XZhang 20120604
 
+  void SetForceTPCstandalone(Bool_t b) {fForceTPCstandalone=b;}
+
+  //Kinks
+  void SetMinKinkAngle(Double_t a) {fMinKinkAngle=a;}
+  void SetMinKinkRadius(Double_t r) {fMinKinkRadius=r;}
+  void SetMaxKinkRAdius(Double_t r) {fMaxKinkRadius=r;}
+  void SetMinKinkQt(Double_t m) {fMinKinkQt=m;}
+  void SetMaxKinkQt(Double_t m) {fMaxKinkQt=m;}
+  void SetMaxKinkInvMassKmu(Double_t m) {fMaxKinkInvMassKmu=m;}
+  void SetMinKinkInvMassKmu(Double_t m) {fMinKinkInvMassKmu=m;}
+
+  Double_t GetMinKinkAngle() const {return fMinKinkAngle;}
+  Double_t GetMinKinkRadius() const {return fMinKinkRadius;}
+  Double_t GetMaxKinkRadius() const {return fMaxKinkRadius;}
+  Double_t GetMinKinkQt() const {return fMinKinkQt;}
+  Double_t GetMaxKinkQt() const {return fMaxKinkQt;}
+  Double_t GetMaxKinkInvMassKmu() const {return fMaxKinkInvMassKmu;}
+  Double_t GetMinKinkInvMassKmu() const {return fMinKinkInvMassKmu;}
+
   Int_t GetMinNClustersTPC() const {if (!fAliESDtrackCuts) return 0; return fAliESDtrackCuts->GetMinNClusterTPC();}
   Int_t GetMinNClustersITS() const {if (!fAliESDtrackCuts) return 0; return fAliESDtrackCuts->GetMinNClustersITS();}
   AliESDtrackCuts::ITSClusterRequirement GetClusterRequirementITS( AliESDtrackCuts::Detector det ) const
@@ -157,6 +180,8 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   Float_t GetBayesianProb() const {return fProbBayes;};
   AliFlowBayesianPID* GetBayesianResponse() const {return  fBayesianResponse;}
 
+  Bool_t GetForceTPCstandalone() const {return fForceTPCstandalone;}
+
   void SetQA(Bool_t b=kTRUE) {if (b) DefineHistograms();}
   TList* GetQA() const {return fQA;}
   TH1* QAbefore(Int_t i) {return static_cast<TH1*>(static_cast<TList*>(fQA->At(0))->At(i));}
@@ -185,8 +210,10 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   virtual Bool_t IsSelectedMCtruth(TObject* obj, Int_t id=-666);
   AliVParticle* GetTrack() const {return fTrack;}
   AliMCParticle* GetMCparticle() const {return fMCparticle;}
-  AliFlowTrack* MakeFlowTrack() const;
+  //AliFlowTrack* MakeFlowTrack() const;
   Bool_t FillFlowTrack(AliFlowTrack* track) const;
+  //FillFlowTrackV0(TObjArray* trackCollection, Int_t trackIndex) const
+  AliFlowTrack* FillFlowTrack(TObjArray* trackCollection, Int_t trackIndex) const;
   Bool_t IsPhysicalPrimary() const; 
   static Bool_t IsPhysicalPrimary(AliMCEvent* p, Int_t label, Bool_t requiretransported=kTRUE); 
   
@@ -197,6 +224,7 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   Int_t GetNumberOfInputObjects() const;
   TObject* GetInputObject(Int_t i);
   void Clear(Option_t* option="");
+  void ClearTrack(Option_t* option="");
 
   Double_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos);
   Double_t GetPmdPhi(Float_t xPos, Float_t yPos);  
@@ -222,10 +250,12 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   Bool_t PassesESDcuts(AliESDtrack* track);
   Bool_t PassesAODcuts(const AliAODTrack* track, Bool_t passFid=kTRUE);
   Bool_t PassesPMDcuts(const AliESDPmdTrack* track);
-  Bool_t PassesV0cuts(Int_t id);
+  Bool_t PassesVZEROcuts(Int_t id);
   Bool_t PassesCuts(const AliFlowTrackSimple* track);
   Bool_t PassesCuts(const AliMultiplicity* track, Int_t id);
   Bool_t PassesCuts(const AliAODTracklets* track, Int_t id);  // XZhang 20120615
+  Bool_t PassesCuts(const AliESDkink* kink);
+  Bool_t PassesCuts(const AliESDv0* v0);
   Bool_t PassesMCcuts();
   Bool_t PassesMCcuts(AliMCEvent* mcevent, Int_t label);
   Bool_t PassesTPCdedxCut(const AliESDtrack* track);
@@ -245,30 +275,34 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   Long64_t Merge(TCollection* list);
   
   //gain equalization and recentering
-  void SetV0gainEqualisation(TH1* g) {fV0gainEqualization=g;}
-  void SetV0Apol(Int_t ring, Float_t f) {fV0Apol[ring]=f;}
-  void SetV0Cpol(Int_t ring, Float_t f) {fV0Cpol[ring]=f;}
+  void SetVZEROgainEqualisation(TH1* g) {fVZEROgainEqualization=g;}
+  void SetVZEROApol(Int_t ring, Float_t f) {fVZEROApol[ring]=f;}
+  void SetVZEROCpol(Int_t ring, Float_t f) {fVZEROCpol[ring]=f;}
   // set the flag for recentering (which is done in AliFlowEvent)
   void SetApplyRecentering(Bool_t r)    { fApplyRecentering = r; }
   Bool_t GetApplyRecentering() const    { return fApplyRecentering;}
-  void SetV0gainEqualizationPerRing(Bool_t s)   {fV0gainEqualizationPerRing = s;}
-  Bool_t GetV0gainEqualizationPerRing() const {return fV0gainEqualizationPerRing;}
+  void SetVZEROgainEqualizationPerRing(Bool_t s)   {fVZEROgainEqualizationPerRing = s;}
+  Bool_t GetVZEROgainEqualizationPerRing() const {return fVZEROgainEqualizationPerRing;}
   // exclude vzero rings: 0 through 7 can be excluded by calling this setter multiple times
   // 0 corresponds to segment ID 0 through 7, etc
   // disabled vzero rings get weight 0
   void SetUseVZERORing(Int_t i, Bool_t u) {
       fUseVZERORing[i] = u;
-      fV0gainEqualizationPerRing = kTRUE;       // must be true for this option
+      fVZEROgainEqualizationPerRing = kTRUE;       // must be true for this option
   }
   Bool_t GetUseVZERORing(Int_t i) const {return fUseVZERORing[i];}
 
  protected:
-  AliFlowTrack* MakeFlowTrackSPDtracklet() const;
-  AliFlowTrack* MakeFlowTrackPMDtrack() const;
-  AliFlowTrack* MakeFlowTrackV0() const;
-  AliFlowTrack* MakeFlowTrackVParticle() const;
+  //AliFlowTrack* MakeFlowTrackSPDtracklet() const;
+  //AliFlowTrack* MakeFlowTrackPMDtrack() const;
+  //AliFlowTrack* MakeFlowTrackVZERO() const;
+  //AliFlowTrack* MakeFlowTrackVParticle() const;
   Bool_t FillFlowTrackVParticle(AliFlowTrack* t) const;
   Bool_t FillFlowTrackGeneric(AliFlowTrack* t) const;
+  AliFlowTrack* FillFlowTrackKink(TObjArray* trackCollection, Int_t trackIndex) const;
+  AliFlowTrack* FillFlowTrackVZERO(TObjArray* trackCollection, Int_t trackIndex) const;
+  AliFlowTrack* FillFlowTrackGeneric(TObjArray* trackCollection, Int_t trackIndex) const;
+  AliFlowTrack* FillFlowTrackVParticle(TObjArray* trackCollection, Int_t trackIndex) const;
   void HandleESDtrack(AliESDtrack* track);
   void HandleVParticle(AliVParticle* track);
   void DefineHistograms();
@@ -328,10 +362,25 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   Float_t fPmdAdc;      //value of cluster ADC
   Bool_t  fCutPmdNcell; //cut on cluster ncell
   Float_t fPmdNcell;    //value of cluster ncell
+
+  Double_t fMinKinkAngle; //max kink angle
+  Double_t fMinKinkRadius; //min kink radius
+  Double_t fMaxKinkRadius; //max kink radius
+  Double_t fMinKinkQt; //min kink qt
+  Double_t fMaxKinkQt; //max kink qt
+  Double_t fMinKinkInvMassKmu; //max kink inv mass
+  Double_t fMaxKinkInvMassKmu; //max kink inv mass
+  Bool_t fForceTPCstandalone; //use TPC parameters when applying cuts on the kink mother
+  Bool_t fRequireKinkDaughters; //well, the name says it all
    
   trackParameterType fParamType;     //parameter type tu cut on
   trackParameterMix fParamMix;       //parameter mixing
+  
+  AliESDkink* fKink;                 //!placeholder for the current kink
+  AliESDv0* fV0;                     //!placeholder for the current V0
   AliVParticle* fTrack;              //!the track to apply cuts on
+  Double_t fTrackMass;               //!mass of the particle
+  Double_t fTrackPt;                 //!track pt
   Double_t fTrackPhi;                //!track phi
   Double_t fTrackEta;                //!track eta
   Double_t fTrackWeight;             //!track weight
@@ -340,7 +389,6 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   AliMCParticle* fMCparticle;        //!mc particle
   AliVEvent* fEvent;                 //!placeholder for current event
   AliESDtrack fTPCtrack;             //!placeholder for TPC only track to avoid new/delete on every track
-  AliFlowTrackSimple::tagType fFlowTagType; //what kind of tag, RP, POI, POIx, ...
 
   //PID
   AliESDpid fESDpid; //pid obj
@@ -362,13 +410,13 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   // end part added by F. Noferini
   
   //gain equalization and recentering for vzero
-  TH1* fV0gainEqualization;     //! equalization histo
+  TH1* fVZEROgainEqualization;     //! equalization histo
   Bool_t fApplyRecentering;     // apply recentering of q-sub vectors in AliFlowEvent ?
-  Bool_t fV0gainEqualizationPerRing;    // per ring vzero gain calibration
-  Float_t fV0Apol[4];           //! calibration info per ring
-  Float_t fV0Cpol[4];           //! calibration info per ring
+  Bool_t fVZEROgainEqualizationPerRing;    // per ring vzero gain calibration
+  Float_t fVZEROApol[4];           //! calibration info per ring
+  Float_t fVZEROCpol[4];           //! calibration info per ring
   Bool_t fUseVZERORing[8];      // kTRUE means the ring is included
-  static const Int_t fgkNumberOfV0tracks=64; //number of V0 channels
+  static const Int_t fgkNumberOfVZEROtracks=64; //number of VZERO channels
 
   ClassDef(AliFlowTrackCuts,13)
 };
index 0b2d8492c1c60e0889fd9acf0bde5b0d21b7cb53..c8c2034dc6c5b34e8c2af6aa5dab628c9a96b539 100644 (file)
@@ -19,6 +19,7 @@
 #pragma link C++ class AliFlowEventStar+;
 
 #pragma link C++ class AliFlowTrackSimpleCuts+;
+#pragma link C++ class AliFlowEventSimpleCuts+;
 
 #pragma link C++ class AliFlowEventSimpleMakerOnTheFly+;
 
@@ -30,6 +31,7 @@
 
 #pragma link C++ class AliFlowLYZEventPlane+;
 
+#pragma link C++ class AliFlowAnalysis+;
 #pragma link C++ class AliFlowAnalysisWithMCEventPlane+;
 #pragma link C++ class AliFlowAnalysisWithScalarProduct+;
 #pragma link C++ class AliFlowAnalysisWithMSP+;
index c3c5d6ed0f1978594b63b2a4b85f47db02412877..df4a1005af0b3b9f756cf7025ef5db00ba76f3b7 100644 (file)
@@ -231,11 +231,11 @@ void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD()
   // Define arrays for muons
   Double_t pos[3];
   Double_t p[3];
-  Double_t pid[10];
+  //  Double_t pid[10];
   
   // has to be changed once the muon pid is provided by the ESD
-  for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
-  pid[AliAODTrack::kMuon]=1.;
+  //  for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
+  //  pid[AliAODTrack::kMuon]=1.;
   
   AliAODHeader* header = AODEvent()->GetHeader();
   AliAODTrack *aodTrack = 0x0;
@@ -305,13 +305,14 @@ void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD()
                                                   0x0, // covariance matrix
                                                   esdMuTrack->Charge(), // charge
                                                   itsClusMap, // ITSClusterMap
-                                                  pid, // pid
+                                                  //pid, // pid
                                                   primary, // primary vertex
                                                   kFALSE, // used for vertex fit?
                                                   kFALSE, // used for primary vertex fit?
                                                   AliAODTrack::kPrimary,// track type
                                                   selectInfo); 
     
+    aodTrack->SetPIDForTracking(AliPID::kMuon);
     aodTrack->SetXYAtDCA(esdMuTrack->GetNonBendingCoorAtDCA(), esdMuTrack->GetBendingCoorAtDCA());
     aodTrack->SetPxPyPzAtDCA(esdMuTrack->PxAtDCA(), esdMuTrack->PyAtDCA(), esdMuTrack->PzAtDCA());
     aodTrack->SetRAtAbsorberEnd(esdMuTrack->GetRAtAbsorberEnd());
index 787daffb09ca42400b42ccb292abb4b62a18f1cd..dead2524ca5b2ecbd650a092b6b3942e4dc99225 100644 (file)
@@ -583,11 +583,11 @@ void AliAnalysisTaskLinkToMC::CreateAODTracks(TMap& links)
        // Define arrays for muons
        Double_t pos[3];
        Double_t p[3];
-       Double_t pid[10];
+       //      Double_t pid[10];
        
        // has to be changed once the muon pid is provided by the ESD
-       for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
-       pid[AliAODTrack::kMuon]=1.;
+       // for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
+       // pid[AliAODTrack::kMuon]=1.;
        
        AliAODHeader* header = AODEvent()->GetHeader();
        AliAODTrack *aodTrack = 0x0;
@@ -647,7 +647,7 @@ void AliAnalysisTaskLinkToMC::CreateAODTracks(TMap& links)
                                0x0, // covariance matrix
                                esdMuTrack->Charge(), // charge
                                0, // ITSClusterMap
-                               pid, // pid
+                               // pid, // pid
                                primary, // primary vertex
                                kFALSE, // used for vertex fit?
                                kFALSE, // used for primary vertex fit?
@@ -655,6 +655,7 @@ void AliAnalysisTaskLinkToMC::CreateAODTracks(TMap& links)
                                selectInfo
                        );
                
+               aodTrack->SetPIDForTracking(AliPID::kMuon);
                aodTrack->SetXYAtDCA(esdMuTrack->GetNonBendingCoorAtDCA(), esdMuTrack->GetBendingCoorAtDCA());
                aodTrack->SetPxPyPzAtDCA(esdMuTrack->PxAtDCA(), esdMuTrack->PyAtDCA(), esdMuTrack->PzAtDCA());
                aodTrack->ConvertAliPIDtoAODPID();
index 72cab6db9b49b2adaae058e78f01d4f43f50e51a..3767ff35788db4771f210606366a2ae59137e44c 100644 (file)
@@ -204,6 +204,8 @@ void AliAnalysisTaskSingleMu::MyUserCreateOutputObjects()
   AddObjectToCollection(histoDimu, kNobjectTypes+2);
   
   fMuonTrackCuts->Print("mask");
+  
+  AliInfo(Form("Apply cut on dimuon (60<M_mumu<120 GeV/c^2) to reject Z contribution: %i", fCutOnDimu));
 }
 
 //________________________________________________________________________
@@ -265,11 +267,11 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
           TLorentzVector dimuPair = AliAnalysisMuonUtility::GetTrackPair(track,auxTrack);
           Double_t ptMin = TMath::Min(track->Pt(),auxTrack->Pt());
           Double_t invMass = dimuPair.M();
+          if ( invMass > 60. && invMass < 120. ) {
+            rejectTrack[itrack] = 1;
+            rejectTrack[jtrack] = 1;
+          }
           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;
@@ -358,8 +360,33 @@ void AliAnalysisTaskSingleMu::Terminate(Option_t *) {
   furtherOpt.ToUpper();
   Bool_t plotChargeAsymmetry = furtherOpt.Contains("ASYM");
   
-  AliCFContainer* cfContainer = static_cast<AliCFContainer*> ( GetSum(physSel,trigClassName,centralityRange,"SingleMuContainer") );
-  if ( ! cfContainer ) return;
+  AliCFContainer* inContainer = static_cast<AliCFContainer*> ( GetSum(physSel,trigClassName,centralityRange,"SingleMuContainer") );
+  if ( ! inContainer ) return;
+  
+  AliCFContainer* cfContainer = inContainer;
+  
+  if ( ! furtherOpt.Contains("GENINTRIGCLASS") && trigClassName != "ANY" ) {
+    // The output container contains both the reconstructed and (in MC)
+    // the generated muons in a specific trigger class.
+    // Since the trigger pt level of the track is matched to the trigger class,
+    // analyzing the MUHigh trigger (for example) is equivalent of analyzing
+    // Hpt tracks.
+    // However, in this way, the generated muons distribution depend
+    // on a condition on the reconstructed track.
+    // If we calculate the Acc.xEff. as the ratio of reconstructed and
+    // generated muons IN A TRIGGER CLASS, we are biasing the final result.
+    // The correct value of Acc.xEff. is hence obtained as the distribution
+    // of reconstructed tracks in a muon trigger class, divided by the
+    // total number of generated class (which is in the "class" ANY).
+    // The following code sets the generated muons as the one in the class ANY.
+    // The feature is the default. If you want the generated muons in the same
+    // trigger class as the generated tracks, use option "GENINTRIGCLASS"
+    AliCFContainer* fullMCcontainer = static_cast<AliCFContainer*> ( GetSum(physSel,"ANY",centralityRange,"SingleMuContainer") );
+    if ( fullMCcontainer ) {
+      cfContainer = static_cast<AliCFContainer*>(cfContainer->Clone("SingleMuContainerCombo"));
+      cfContainer->SetGrid(kStepGeneratedMC,fullMCcontainer->GetGrid(kStepGeneratedMC));
+    }
+  }
   
   AliCFEffGrid* effSparse = new AliCFEffGrid(Form("eff%s", cfContainer->GetName()),Form("Efficiency %s", cfContainer->GetTitle()),*cfContainer);
   effSparse->CalculateEfficiency(kStepReconstructed, kStepGeneratedMC);
index bcf743c36011e8c7b6b82d0e0786964da286ede5..558fda7c5f4780ba4dc915ae688c3ebbdebad661 100644 (file)
@@ -28,6 +28,7 @@ class AliAnalysisTaskSingleMu : public AliVAnalysisMuon {
   void MyUserCreateOutputObjects();
   void ProcessEvent(TString physSel, const TObjArray& selectTrigClasses, TString centrality);
   
+  /// Apply cut on dimuon invariant mass (to reject Z contribution)
   void SetCutDimu ( Bool_t cutOnDimu = kTRUE ) { fCutOnDimu = cutOnDimu; }
   
   enum {
index a60e9392ab83426de0ce495138c7da3f46c738c8..bdc3d6cd0c46e60d0a07263424f072ae8bc349bb 100644 (file)
@@ -55,6 +55,7 @@ set ( SRCS
     Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.cxx
     Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx
     Correlations/DPhi/PidPid/AliAnalysisTaskPidPidCorrelations.cxx
+    Correlations/DPhi/PhiEffMC/AliAnalysisTaskPhiEffMc.cxx
     )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index e41cc2769c419bc6cba8cf2526a0c94f2184be27..b3d96f93048e76c39921a64ebf96db5114275344 100644 (file)
@@ -41,8 +41,8 @@
 #include "AliPID.h"
 #include "AliVEvent.h"
 #include "AliPIDResponse.h"
-#include "AliSpectraAODTrackCuts.h"
-#include "AliSpectraAODEventCuts.h"
+#include "PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODTrackCuts.h"
+#include "PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODEventCuts.h"
 #include "AliStack.h"
 #include <TMCProcess.h>
 #include "AliAnalyseLeadingTrackUE.h"
index c71d774649901b28d33680c544fa0f465791c189..87383ced1a3a782bed1beb32b6771841026a28f7 100644 (file)
@@ -75,16 +75,19 @@ AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be ini
   fOutput(0),
   fCentralityMethod("V0A"),
   fSampleType("pPb"),
-fnTracksVertex(1),  // QA tracks pointing to principal vertex (= 3 default)
+  fnTracksVertex(1),  // QA tracks pointing to principal vertex (= 3 default)
   trkVtx(0),
   zvtx(0),
   fFilterBit(768),
+  fSharedClusterCut(-1),
+  fVertextype(1),
   fzvtxcut(10.0),
   ffilltrigassoUNID(kFALSE),
   ffilltrigUNIDassoID(kFALSE),
   ffilltrigIDassoUNID(kTRUE),
   ffilltrigIDassoID(kFALSE),
   ffilltrigIDassoIDMCTRUTH(kFALSE),
+  fMaxNofMixingTracks(50000),
   fPtOrderMCTruth(kFALSE),
   fTriggerSpeciesSelection(kFALSE),
   fAssociatedSpeciesSelection(kFALSE),
@@ -92,6 +95,7 @@ fnTracksVertex(1),  // QA tracks pointing to principal vertex (= 3 default)
   fAssociatedSpecies(SpPion),
   fCustomBinning(""),
   fBinningString(""),
+  fSelectHighestPtTrig(kFALSE),
   fcontainPIDtrig(kTRUE),
   fcontainPIDasso(kFALSE),
 //frejectPileUp(kFALSE),
@@ -225,12 +229,15 @@ AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data membe
   trkVtx(0),
   zvtx(0),
   fFilterBit(768),
+  fSharedClusterCut(-1),
+  fVertextype(1),
   fzvtxcut(10.0),
   ffilltrigassoUNID(kFALSE),
   ffilltrigUNIDassoID(kFALSE),
   ffilltrigIDassoUNID(kTRUE),
   ffilltrigIDassoID(kFALSE),
   ffilltrigIDassoIDMCTRUTH(kFALSE),
+  fMaxNofMixingTracks(50000),
   fPtOrderMCTruth(kFALSE),
   fTriggerSpeciesSelection(kFALSE),
   fAssociatedSpeciesSelection(kFALSE),
@@ -238,6 +245,7 @@ AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data membe
   fAssociatedSpecies(SpPion),
   fCustomBinning(""),
   fBinningString(""),
+  fSelectHighestPtTrig(kFALSE),
   fcontainPIDtrig(kTRUE),
   fcontainPIDasso(kFALSE),
    // frejectPileUp(kFALSE),
@@ -991,7 +999,7 @@ skipParticlesAbove = eventHeader->NProduced();
   }
 
  //vertex selection(is it fine for PP?)
-  if ( fSampleType=="pPb"){
+  if ( fVertextype==1){
   trkVtx = aod->GetPrimaryVertex();
   if (!trkVtx || trkVtx->GetNContributors()<=0) return;
   TString vtxTtl = trkVtx->GetTitle();
@@ -1006,7 +1014,7 @@ skipParticlesAbove = eventHeader->NProduced();
   if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
    if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
   }
-  else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case
+  else if(fVertextype==2) {//for pp and pb-pb case
        Int_t nVertex = aod->GetNumberOfVertices();
        if( nVertex > 0 ) { 
     trkVtx = aod->GetPrimaryVertex();
@@ -1174,7 +1182,7 @@ if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTHngenprimPidTruth
   }
    
  Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0
-if(partMC->Pt()>=fminPtAsso || partMC->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool
+if((partMC->Pt()>=fminPtAsso && partMC->Pt()<=fmaxPtAsso) || (partMC->Pt()>=fminPtTrig && partMC->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
   {
 LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth);
 //copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel()));
@@ -1184,6 +1192,7 @@ LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),pa
   }//MC truth track loop ends
 
 //*********************still in event loop
+ Float_t weghtval=1.0;
 
  if (fSampleType=="pp") cent_v0_truth=nooftrackstruth;
  else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case
@@ -1194,7 +1203,7 @@ if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH)
   {
  //Fill Correlations for MC truth particles(same event)
 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation
Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
 Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,weghtval,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
 
 //start mixing
 AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200);
@@ -1202,11 +1211,12 @@ if (pool2 && pool2->IsReady())
   {//start mixing only when pool->IsReady
 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)
   {//proceed only when no. of trigger particles >0 in current event
+    Float_t nmix=(Float_t)pool2->GetCurrentNEvents();  
 for (Int_t jMix=0; jMix<pool2->GetCurrentNEvents(); jMix++) 
   { //pool event loop start
  TObjArray* bgTracks6 = pool2->GetEvent(jMix);
   if(!bgTracks6) continue;
-  Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case
+  Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,nmix,bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case
   
    }// pool event loop ends mixing case
  }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case
@@ -1318,7 +1328,7 @@ isduplicate2=kTRUE;
  //NOTE:: this will be used for fillinfg THnSparse of efficiency & also to get the the track by track eff. factor on the fly(only in case of pp)
 
  //Clone & Reduce track list(TObjArray) for unidentified particles
-if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool
+if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
   {
  if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
    effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);
@@ -1416,7 +1426,7 @@ if(TMath::Abs(pdgCode)==321 ||  TMath::Abs(pdgCode)==2212)   fTHnrecomatchedallP
   if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212) fTHnrecomatchedallPid[2]->Fill(allrecomatchedpid);//for protons
    }
 
-if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig)//to reduce memory consumption in pool
+if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
   {
 if (fapplyTrigefficiency || fapplyAssoefficiency)
     effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles 
@@ -1446,14 +1456,14 @@ if(trackscount>0.0)
  //same event delte-eta, delta-phi plot
 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
   {//same event calculation starts
-    if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
-    if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID)  Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
+    if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weghtval,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
+    if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID)  Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weghtval,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
   }
 
 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
   {//same event calculation starts
-    if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID)  Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
-    if(ffilltrigIDassoID)   Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
+    if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID)  Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weghtval,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
+    if(ffilltrigIDassoID)   Fillcorrelation(tracksID,0,cent_v0,zvtx,weghtval,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
   }
 
 //still in  main event loop
@@ -1462,14 +1472,15 @@ if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
 if (pool && pool->IsReady())
   {//start mixing only when pool->IsReady
+    Float_t nmix1=(Float_t)pool->GetCurrentNEvents();  
  for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++) 
   { //pool event loop start
  TObjArray* bgTracks = pool->GetEvent(jMix);
   if(!bgTracks) continue;
   if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
-  Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
+    Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
  if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
-  Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE 
+   Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE 
    }// pool event loop ends mixing case
 
 } //if pool->IsReady() condition ends mixing case
@@ -1483,14 +1494,15 @@ if(pool)
 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
 if (pool1 && pool1->IsReady())
   {//start mixing only when pool->IsReady
+  Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();  
 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++) 
   { //pool event loop start
  TObjArray* bgTracks2 = pool1->GetEvent(jMix);
   if(!bgTracks2) continue;
 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
-  Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE  
+  Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE  
 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
-  Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
+  Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
 
    }// pool event loop ends mixing case
 } //if pool1->IsReady() condition ends mixing case
@@ -1561,7 +1573,7 @@ void AliTwoParticlePIDCorr::doAODevent()
  if (!fPID) return;//this should be available with each event even if we don't do PID selection
   
   //vertex selection(is it fine for PP?)
-  if ( fSampleType=="pPb"){
+ if ( fVertextype==1){//for pPb basically if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return; 
   trkVtx = aod->GetPrimaryVertex();
   if (!trkVtx || trkVtx->GetNContributors()<=0) return;
   TString vtxTtl = trkVtx->GetTitle();
@@ -1576,7 +1588,7 @@ void AliTwoParticlePIDCorr::doAODevent()
   if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
    if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
   }
-  else if(fSampleType=="PbPb" || fSampleType=="pp") {//for pp and pb-pb case
+  else if(fVertextype==2) {//for pp and pb-pb case , taken from Jan's code
        Int_t nVertex = aod->GetNumberOfVertices();
        if( nVertex > 0 ) { 
      trkVtx = aod->GetPrimaryVertex();
@@ -1661,7 +1673,7 @@ if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0)  return;//for pp
 
 
  //to reduce memory consumption in pool
-  if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig
+  if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig)
   {
  //Clone & Reduce track list(TObjArray) for unidentified particles
  if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
@@ -1723,7 +1735,7 @@ if (particletype==SpProton)
   }
     }
  
-if(track->Pt()>=fminPtAsso || track->Pt()<=fmaxPtTrig
+ if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig)
   {
 if (fapplyTrigefficiency || fapplyAssoefficiency)
   effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles; Bool_t mesoneffrequired=kFALSE
@@ -1739,6 +1751,9 @@ if(trackscount<1.0){
   return;
  }
 
+ Float_t weightval=1.0;
+
+
 // cout<<fminPtAsso<<"***"<<fmaxPtAsso<<"*********************"<<fminPtTrig<<"***"<<fmaxPtTrig<<"*****************"<<kTrackVariablesPair<<endl;
 if(fSampleType=="pp")  cent_v0=trackscount;//multiplicity
   
@@ -1754,14 +1769,14 @@ if(fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_
 
 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
   {//same event calculation starts
-    if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
-    if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID)  Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
+    if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weightval,bSign,kTRUE,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
+    if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID)  Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weightval,bSign,kFALSE,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
   }
 
 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
   {//same event calculation starts
-    if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID)  Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
-    if(ffilltrigIDassoID)   Fillcorrelation(tracksID,0,cent_v0,zvtx,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
+    if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID)  Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weightval,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
+    if(ffilltrigIDassoID)   Fillcorrelation(tracksID,0,cent_v0,zvtx,weightval,bSign,kFALSE,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
   }
 
 //still in  main event loop
@@ -1772,14 +1787,15 @@ if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
 if (pool && pool->IsReady())
   {//start mixing only when pool->IsReady
+  Float_t nmix1=(Float_t)pool->GetCurrentNEvents();  
  for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++) 
   { //pool event loop start
  TObjArray* bgTracks = pool->GetEvent(jMix);
   if(!bgTracks) continue;
   if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
-  Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
+    Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,bSign,kTRUE,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
  if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
-  Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE 
+   Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE 
    }// pool event loop ends mixing case
 
 } //if pool->IsReady() condition ends mixing case
@@ -1794,14 +1810,15 @@ if(pool)
 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
 if (pool1 && pool1->IsReady())
   {//start mixing only when pool->IsReady
+  Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();  
 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++) 
   { //pool event loop start
  TObjArray* bgTracks2 = pool1->GetEvent(jMix);
   if(!bgTracks2) continue;
 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
-  Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE  
+  Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,bSign,kFALSE,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE  
 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
-  Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
+  Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,bSign,kFALSE,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
 
    }// pool event loop ends mixing case
 } //if pool1->IsReady() condition ends mixing case
@@ -1846,7 +1863,7 @@ TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks)
 }
 
 //--------------------------------------------------------------------------------
-void AliTwoParticlePIDCorr::Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup)
+void AliTwoParticlePIDCorr::Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup)
 {
 
   //before calling this function check that either trackstrig & tracksasso are available 
@@ -1914,8 +1931,56 @@ if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5)
       }
     }
 
-    //two particle correlation filling
+      //Select the highest Pt trigger particle in an event (within a given Pt trigger range)
 
+    Float_t TriggerPtMin=fminPtTrig;
+    Float_t TriggerPtMax=fmaxPtTrig;
+    Int_t HighestPtTriggerIndx=-99999;
+
+    if(fSelectHighestPtTrig)//**************add this data member to the constructor
+      {
+for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
+    {  //trigger loop starts(highest Pt trigger selection)
+      LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
+      if(!trig) continue;
+      Float_t trigpt=trig->Pt();
+    //to avoid overflow qnd underflow
+      if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
+      Int_t particlepidtrig=trig->getparticle();
+      if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
+
+      Float_t trigeta=trig->Eta();
+
+      // some optimization
+ if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
+       continue;
+
+if (fOnlyOneEtaSide != 0)
+      {
+       if (fOnlyOneEtaSide * trigeta < 0)
+         continue;
+      }
+  if (fTriggerSelectCharge != 0)
+       if (trig->Charge() * fTriggerSelectCharge < 0)
+         continue;
+       
+      if (fRejectResonanceDaughters > 0)
+       if (trig->TestBit(kResonanceDaughterFlag)) continue;
+
+ if(trigpt>TriggerPtMin && trigpt<=TriggerPtMax)
+          {
+           //TriggerPt=trigpt;//*********think about it
+         
+           HighestPtTriggerIndx=(Int_t)trig->GetUniqueID();
+          TriggerPtMin=trigpt;
+          }
+
+    }//trigger loop ends(highest Pt trigger selection)
+
+      }//******************SelectHighestPtTrig condition ends
+
+
+ //two particle correlation filling
 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
     {  //trigger loop starts
       LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
@@ -1944,6 +2009,10 @@ if (fOnlyOneEtaSide != 0)
       if (fRejectResonanceDaughters > 0)
        if (trig->TestBit(kResonanceDaughterFlag)) continue;
 
+      if(fSelectHighestPtTrig && HighestPtTriggerIndx!=-99999) {
+       if(trig->GetUniqueID()!=(UInt_t)HighestPtTriggerIndx) continue;
+      }
+
       Float_t trigphi=trig->Phi();
       Float_t trackefftrig=1.0;
       if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval();
@@ -2158,6 +2227,7 @@ if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEf
          }
        }
 
+       Float_t weightperevent=weight;
         Float_t trackeffasso=1.0;
         if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval();
        //cout<<"*******************trackeffasso="<<trackeffasso<<endl;
@@ -2165,8 +2235,8 @@ if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEf
        Float_t delphi=PhiRange(trigphi-asso->Phi()); 
 
  //here get the two particle efficiency correction factor
-       Float_t effweight=trackefftrig*trackeffasso;
-       //cout<<"*******************effweight="<<effweight<<endl;
+       Float_t effweight=trackefftrig*trackeffasso*weightperevent;
+       // if(mixcase==kFALSE)  cout<<"*******************effweight="<<effweight<<endl;
        Double_t* vars;
         vars= new Double_t[kTrackVariablesPair];
        vars[0]=cent;
@@ -2335,6 +2405,12 @@ Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vert
            return 0;
        }
 
+       if (fSharedClusterCut >= 0)
+       {
+         Double_t frac = Double_t(((AliAODTrack*)track)->GetTPCnclsS()) / Double_t(((AliAODTrack*)track)->GetTPCncls());
+         if (frac > fSharedClusterCut)
+           return 0;
+       }
      fHistQA[8]->Fill(pt);
      fHistQA[9]->Fill(track->Eta());
      fHistQA[10]->Fill(track->Phi());
@@ -2649,25 +2725,24 @@ Float_t  AliTwoParticlePIDCorr::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t c
 //_________________________________________________________________________
 void AliTwoParticlePIDCorr ::DefineEventPool()
 {
-const Int_t MaxNofEvents=1000;
-const Int_t MaxNofTracks=50000;
+Int_t MaxNofEvents=1000;
 const Int_t NofVrtxBins=10+(1+10)*2;
 Double_t ZvrtxBins[NofVrtxBins+1]={ -10,   -8,  -6,  -4,  -2,   0,   2,   4,   6,   8,  10, 
                                       90,  92,  94,  96,  98, 100, 102, 104, 106, 108, 110, 
                                      190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210 
                                      };
  if (fSampleType=="pp"){
-const Int_t  NofCentBins=5;
-Double_t CentralityBins[NofCentBins+1]={0.,10., 20., 40.,80.,200.1};
-fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
+const Int_t  NofCentBins=4;
+ Double_t CentralityBins[NofCentBins+1]={0.,20., 40.,60.,200.1};//Is This binning is fine for pp, or we don't require them....
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
  }
 if (fSampleType=="pPb" || fSampleType=="PbPb")
   {
 const Int_t  NofCentBins=15;
 Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
-fPoolMgr = new AliEventPoolManager(MaxNofEvents,MaxNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
   }
-fPoolMgr->SetTargetValues(MaxNofTracks, 0.1, 5);
+fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
 
 //if(!fPoolMgr) return kFALSE;
 //return kTRUE;
index d4138a71a72f1c6c6e1db6b2030e4b1afcdbfb42..e20ad27db23255589ae634ee6608ecc832ddc57c 100644 (file)
@@ -91,9 +91,13 @@ class AliTwoParticlePIDCorr : public AliAnalysisTaskSE {
     virtual void    doAODevent();
     virtual void    doMCAODevent();
     virtual void     Terminate(Option_t *);
+  void          SetSharedClusterCut(Double_t value) { fSharedClusterCut = value; }
+
+    void SetVertextype(Int_t Vertextype){fVertextype=Vertextype;}
+    void SetZvtxcut(Double_t zvtxcut) {fzvtxcut=zvtxcut;}
     void SetCustomBinning(TString receivedCustomBinning) { fCustomBinning = receivedCustomBinning; }
     void SetAsymmetricBin(THnSparse *h,Int_t axisno,Double_t *arraybin,Int_t arraybinsize,TString axisTitle); 
-
+    void SetMaxNofMixingTracks(Int_t MaxNofMixingTracks) {fMaxNofMixingTracks=MaxNofMixingTracks;}
   void SetCentralityEstimator(TString CentralityMethod) { fCentralityMethod = CentralityMethod;}
   void SetSampleType(TString SampleType) {fSampleType=SampleType;}
   void SetAnalysisType(TString AnalysisType){fAnalysisType=AnalysisType;}
@@ -103,6 +107,7 @@ class AliTwoParticlePIDCorr : public AliAnalysisTaskSE {
   void SetfilltrigIDassoUNID(Bool_t filltrigIDassoUNID){ffilltrigIDassoUNID=filltrigIDassoUNID;}
   void SetfilltrigIDassoID(Bool_t filltrigIDassoID){ ffilltrigIDassoID=filltrigIDassoID;}
   void SetfilltrigIDassoIDMCTRUTH(Bool_t filltrigIDassoIDMCTRUTH){ffilltrigIDassoIDMCTRUTH=filltrigIDassoIDMCTRUTH;}
+  void SetSelectHighestPtTrig(Bool_t SelectHighestPtTrig){fSelectHighestPtTrig=SelectHighestPtTrig;}
   void SetTriggerSpeciesSelection(Bool_t TriggerSpeciesSelection,Int_t TriggerSpecies,Bool_t containPIDtrig){
     fTriggerSpeciesSelection=TriggerSpeciesSelection;//if it is KTRUE then Set containPIDtrig=kFALSE
     fTriggerSpecies=TriggerSpecies;
@@ -196,12 +201,15 @@ fPtTOFPIDmax=PtTOFPIDmax;
     AliAODVertex* trkVtx;//!
     Float_t zvtx;
     Int_t    fFilterBit;         // track selection cuts
+    Double_t       fSharedClusterCut;  // cut on shared clusters (only for AOD)
+    Int_t fVertextype;
     Double_t fzvtxcut;
     Bool_t ffilltrigassoUNID;
     Bool_t ffilltrigUNIDassoID;
     Bool_t ffilltrigIDassoUNID;
     Bool_t ffilltrigIDassoID;
     Bool_t ffilltrigIDassoIDMCTRUTH;
+    Int_t fMaxNofMixingTracks;
     Bool_t fPtOrderMCTruth;
     Bool_t fTriggerSpeciesSelection;
     Bool_t fAssociatedSpeciesSelection;
@@ -209,6 +217,7 @@ fPtTOFPIDmax=PtTOFPIDmax;
     Int_t fAssociatedSpecies;
     TString fCustomBinning;//for setting customized binning
     TString fBinningString;//final binning string
+    Bool_t fSelectHighestPtTrig;
     Bool_t fcontainPIDtrig;
     Bool_t fcontainPIDasso;
     // Bool_t frejectPileUp;
@@ -296,7 +305,7 @@ fPtTOFPIDmax=PtTOFPIDmax;
   Double_t* GetBinning(const char* configuration, const char* tag, Int_t& nBins);
 
 
-  void Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup);//mixcase=kTRUE in case of mixing; 
+  void Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup);//mixcase=kTRUE in case of mixing; 
  Float_t GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid);
 
 //Mixing functions
index 8985f573d1e63bf9ca22bd8a7c2c2d49979056c9..d970f16fc46bdcd8ce0d701b27cc1a1eaf4ea40b 100755 (executable)
@@ -61,6 +61,17 @@ AliAnalysisTaskToyModel::AliAnalysisTaskToyModel()
   fNumberOfDeadSectors(0),
   fEfficiencyDropNearEtaEdges(kFALSE),
   fEfficiencyMatrix(0),
+  fSimulateDetectorEffectsCorrection(kFALSE),
+  fCentralityArrayBinsForCorrections(101),
+  fPtMinForCorrections(0.3),
+  fPtMaxForCorrections(1.5),
+  fPtBinForCorrections(36), 
+  fEtaMinForCorrections(-0.8),
+  fEtaMaxForCorrections(0.8),
+  fEtaBinForCorrections(16),
+  fPhiMinForCorrections(0.),
+  fPhiMaxForCorrections(360.),
+  fPhiBinForCorrections(100),
   fUseAllCharges(kFALSE), fParticleMass(0.0),
   fPtSpectraAllCharges(0), fTemperatureAllCharges(100.),
   fReactionPlane(0.0),
@@ -83,8 +94,17 @@ AliAnalysisTaskToyModel::AliAnalysisTaskToyModel()
   fEllipticFlowProtons(0.0), fTriangularFlowProtons(0.0),
   fQuandrangularFlowProtons(0.0), fPentangularFlowProtons(0.0),
   fUseDynamicalCorrelations(kFALSE), fDynamicalCorrelationsPercentage(0.1),
-  fUseJets(kFALSE), fPtAssoc(0) {
+  fUseJets(kFALSE), fPtAssoc(0),
+  fUseLCC(kFALSE) {
   // Constructor
+
+  //======================================================correction
+  for (Int_t i=0; i<101; i++){
+    fHistCorrectionPlus[i] = NULL; 
+    fHistCorrectionMinus[i] = NULL; 
+    fCentralityArrayForCorrections[i] = -1.;
+  }
+  //=====================================================correction
 }
 
 //________________________________________________________________________
@@ -274,6 +294,69 @@ void AliAnalysisTaskToyModel::SetupEfficiencyMatrix() {
   }
 }
 
+//________________________________________________________________________
+void AliAnalysisTaskToyModel::SimulateDetectorEffectsCorrection(TString filename, 
+                                                               Int_t nCentralityBins, 
+                                                               Double_t *centralityArrayForCorrections) {
+  //Setup the efficiency matrix from the correction of data
+  fSimulateDetectorEffectsCorrection = kTRUE;
+
+  //Open files that will be used for correction
+  fCentralityArrayBinsForCorrections = nCentralityBins;
+  for (Int_t i=0; i<nCentralityBins; i++)
+    fCentralityArrayForCorrections[i] = centralityArrayForCorrections[i];
+
+  // No file specified -> run without corrections
+  if(!filename.Contains(".root")) {
+    AliInfo(Form("No correction file specified (= %s) --> run without corrections",filename.Data()));
+    return;
+  }
+
+  //Open the input file
+  TFile *f = TFile::Open(filename);
+  if(!f->IsOpen()) {
+    AliInfo(Form("File %s not found --> run without corrections",filename.Data()));
+    return;
+  }
+    
+  //TString listEffName = "";
+  for (Int_t iCent = 0; iCent < fCentralityArrayBinsForCorrections-1; iCent++) {    
+    //Printf("iCent %d:",iCent);    
+    TString histoName = "fHistCorrectionPlus";
+    histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1]));
+    fHistCorrectionPlus[iCent]= dynamic_cast<TH3F *>(f->Get(histoName.Data()));
+    if(!fHistCorrectionPlus[iCent]) {
+      AliError(Form("fHist %s not found!!!",histoName.Data()));
+      return;
+    }
+    
+    histoName = "fHistCorrectionMinus";
+    histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1]));
+    fHistCorrectionMinus[iCent] = dynamic_cast<TH3F *>(f->Get(histoName.Data())); 
+    if(!fHistCorrectionMinus[iCent]) {
+      AliError(Form("fHist %s not found!!!",histoName.Data()));
+      return; 
+    }
+  }//loop over centralities: ONLY the PbPb case is covered
+
+  if(fHistCorrectionPlus[0]){
+    fEtaMinForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmin();
+    fEtaMaxForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmax();
+    fEtaBinForCorrections = fHistCorrectionPlus[0]->GetNbinsX();
+    
+    fPtMinForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmin();
+    fPtMaxForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmax();
+    fPtBinForCorrections = fHistCorrectionPlus[0]->GetNbinsY();
+    
+    fPhiMinForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmin();
+    fPhiMaxForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmax();
+    fPhiBinForCorrections = fHistCorrectionPlus[0]->GetNbinsZ();
+  }
+
+
+
+}
+
 //________________________________________________________________________
 void AliAnalysisTaskToyModel::CreateOutputObjects() {
   // Create histograms
@@ -633,6 +716,9 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
        vPt = fPtSpectraAllCharges->GetRandom();
        vPhi = fAzimuthalAngleAllCharges->GetRandom();
       }
+
+      if(fUseDebug) 
+       Printf("Generated: Charge = %d, eta = %.2f, phi = %.2f, pt = %.2f",vCharge,vEta,vPhi,vPt);
       
       vP[0] = vPt*TMath::Cos(vPhi);
       vP[1] = vPt*TMath::Sin(vPhi);
@@ -662,6 +748,15 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
          continue;
       }
 
+      //Detector effects as for correction of data
+      if(fSimulateDetectorEffectsCorrection) {
+       Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+       Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+       Double_t randomNumber = gRandom->Rndm(); 
+       if(randomNumber > efficiency)
+         continue;
+      }
+
       //Fill QA histograms (acceptance);
       if(vCharge > 0) {
        gNumberOfAcceptedPositiveParticles += 1;
@@ -703,6 +798,93 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
       tracksMain->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, 1.0));  
       if(fRunMixing) 
        tracksMixing->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, 1.0));  
+    
+
+      // Local Charge Conservation usage (Still not perfect since only for accepted particles so far and then realistic efficiencies!!!)
+      // only for charged so far
+      if(fUseLCC && fUseAllCharges) {
+               
+       // Decide the charge
+       Int_t vCharge_LCC = -vCharge;
+       
+       // Get Kinematics
+       Double_t vPt_LCC  = gRandom->Gaus(vPt,0.1);
+       Double_t vEta_LCC = gRandom->Gaus(vEta,0.5);
+       Double_t vPhi_LCC = gRandom->Gaus(vPhi,0.5);
+
+       if(fUseDebug) 
+         Printf("Generated LCC: Charge = %d, eta = %.2f, phi = %.2f, pt = %.2f",vCharge_LCC,vEta_LCC,vPhi_LCC,vPt_LCC);
+
+       //Acceptance
+       if((vEta_LCC < fEtaMin) || (vEta_LCC > fEtaMax)) continue;
+             
+       vP[0] = vPt_LCC*TMath::Cos(vPhi_LCC);
+       vP[1] = vPt_LCC*TMath::Sin(vPhi_LCC);
+       vP[2] = vPt_LCC*TMath::SinH(vEta_LCC);
+       vE = TMath::Sqrt(TMath::Power(fParticleMass,2) +
+                        TMath::Power(vP[0],2) +
+                        TMath::Power(vP[1],2) +
+                        TMath::Power(vP[2],2));
+       
+       vY = 0.5*TMath::Log((vE + vP[2])/(vE - vP[2]));
+       
+       //pt coverage
+       if((vPt_LCC < fPtMin) || (vPt_LCC > fPtMax)) continue;
+       
+       //acceptance filter
+       if(fUseAcceptanceParameterization) {
+         Double_t gRandomNumberForAcceptance = gRandom->Rndm();
+         if(gRandomNumberForAcceptance > fAcceptanceParameterization->Eval(vPt_LCC)) 
+           continue;
+       }
+
+       //Detector effects
+       if(fSimulateDetectorEffects) {
+         Double_t randomNumber = gRandom->Rndm();
+         if(randomNumber > fEfficiencyMatrix->GetBinContent(fEfficiencyMatrix->FindBin(vEta_LCC,vPt_LCC,vPhi_LCC)))
+           continue;
+       }
+
+       //Detector effects as for correction of data
+       if(fSimulateDetectorEffectsCorrection) {
+         Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+         Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+         Double_t randomNumber = gRandom->Rndm(); 
+         if(randomNumber > efficiency)
+           continue;
+       }
+       
+       //Fill QA histograms (acceptance);
+       if(vCharge_LCC > 0) {
+         gNumberOfAcceptedPositiveParticles += 1;
+         if(vPhi_LCC > 3.*TMath::Pi()/2.)
+           fHistEtaPhiPos->Fill(vEta_LCC,vPhi_LCC-2.*TMath::Pi());
+         else
+           fHistEtaPhiPos->Fill(vEta_LCC,vPhi_LCC);
+       }
+       else {
+         gNumberOfAcceptedNegativeParticles += 1;
+         if(vPhi_LCC > 3.*TMath::Pi()/2.)
+           fHistEtaPhiNeg->Fill(vEta_LCC,vPhi_LCC-2.*TMath::Pi());
+         else
+           fHistEtaPhiNeg->Fill(vEta_LCC,vPhi_LCC);
+       }
+       
+       fHistEta->Fill(vEta_LCC);
+       fHistRapidity->Fill(vY);
+       fHistPhi->Fill(vPhi_LCC);
+       fHistPt->Fill(vPt_LCC);
+
+       iParticleCount += 1;
+       gNumberOfAcceptedParticles += 1;
+       
+       // add the track to the TObjArray
+       tracksMain->Add(new AliBFBasicParticle(vEta_LCC, vPhi_LCC, vPt_LCC, vCharge_LCC, 1.0));  
+       if(fRunMixing) 
+         tracksMixing->Add(new AliBFBasicParticle(vEta_LCC, vPhi_LCC, vPt_LCC, vCharge_LCC, 1.0));  
+       
+      }//Local charge conservation usage
+
     }//generated positive particle loop
 
     //Jets
@@ -748,6 +930,15 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
          continue;
       }
 
+      //Detector effects as for correction of data
+      if(fSimulateDetectorEffectsCorrection) {
+       Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+       Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+       Double_t randomNumber = gRandom->Rndm(); 
+       if(randomNumber > efficiency)
+         continue;
+      }
+
       gNumberOfAcceptedParticles += 1;
 
       // add the track to the TObjArray
@@ -792,6 +983,15 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
              continue;
          }
 
+         //Detector effects as for correction of data
+         if(fSimulateDetectorEffectsCorrection) {
+           Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+           Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+           Double_t randomNumber = gRandom->Rndm(); 
+           if(randomNumber > efficiency)
+             continue;
+         }
+
          gNumberOfAcceptedParticles += 1;
 
          // add the track to the TObjArray
@@ -827,7 +1027,7 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
        if(gRandomNumberForAcceptance > fAcceptanceParameterization->Eval(gPtTrig2)) 
          continue;
       }
-
+    
       //Detector effects
       if(fSimulateDetectorEffects) {
        Double_t randomNumber = gRandom->Rndm();
@@ -835,6 +1035,15 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
          continue;
       }
 
+      //Detector effects as for correction of data
+      if(fSimulateDetectorEffectsCorrection) {
+       Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+       Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+       Double_t randomNumber = gRandom->Rndm(); 
+       if(randomNumber > efficiency)
+         continue;
+      }
+
       gNumberOfAcceptedParticles += 1;
 
       // add the track to the TObjArray
@@ -879,6 +1088,15 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
              continue;
          }
 
+         //Detector effects as for correction of data
+         if(fSimulateDetectorEffectsCorrection) {
+           Double_t gCentrality = 1.; //simulate most central events here (gCentrality = 1.)
+           Double_t efficiency = 1./GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);   
+           Double_t randomNumber = gRandom->Rndm(); 
+           if(randomNumber > efficiency)
+             continue;
+         }
+
          gNumberOfAcceptedParticles += 1;
 
          // add the track to the TObjArray
@@ -888,15 +1106,8 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
        }//pt,assoc < pt,trig
       }//associated
     }//Jet usage
-
-
-
-
-
-
-
-
     
+
     //Dynamical correlations
     Int_t nGeneratedPositiveDynamicalCorrelations = 0;
     Int_t nGeneratedNegativeDynamicalCorrelations = 0;
@@ -1121,6 +1332,75 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
   }//event loop
 }      
 
+//________________________________________________________________________
+Double_t AliAnalysisTaskToyModel::GetTrackbyTrackCorrectionMatrix( Double_t vEta, 
+                                                                  Double_t vPhi, 
+                                                                  Double_t vPt, 
+                                                                  Short_t vCharge, 
+                                                                  Double_t gCentrality) {
+  // -- Get efficiency correction of particle dependent on (eta, phi, pt, charge, centrality) 
+
+  Double_t correction = 1.;
+  Int_t binEta = 0, binPt = 0, binPhi = 0;
+
+  //Printf("EtaMAx: %lf - EtaMin: %lf - EtaBin: %lf", fEtaMaxForCorrections,fEtaMinForCorrections,fEtaBinForCorrections);
+  if(fEtaBinForCorrections != 0) {
+    Double_t widthEta = (fEtaMaxForCorrections - fEtaMinForCorrections)/fEtaBinForCorrections;
+    if(fEtaMaxForCorrections != fEtaMinForCorrections) 
+      binEta = (Int_t)((vEta-fEtaMinForCorrections)/widthEta)+1;
+  }
+
+  if(fPtBinForCorrections != 0) {
+    Double_t widthPt = (fPtMaxForCorrections - fPtMinForCorrections)/fPtBinForCorrections;
+    if(fPtMaxForCorrections != fPtMinForCorrections) 
+      binPt = (Int_t)((vPt-fPtMinForCorrections)/widthPt) + 1;
+  }
+  if(fPhiBinForCorrections != 0) {
+    Double_t widthPhi = (fPhiMaxForCorrections - fPhiMinForCorrections)/fPhiBinForCorrections;
+    if(fPhiMaxForCorrections != fPhiMinForCorrections) 
+      binPhi = (Int_t)((vPhi-fPhiMinForCorrections)/widthPhi)+ 1;
+  }
+
+  Int_t gCentralityInt = -1;
+  for (Int_t i=0; i<fCentralityArrayBinsForCorrections-1; i++){
+    if((fCentralityArrayForCorrections[i] <= gCentrality)&&(gCentrality <= fCentralityArrayForCorrections[i+1])){
+      gCentralityInt = i;
+      break;
+    }
+  }  
+
+  // centrality not in array --> no correction
+  if(gCentralityInt < 0){
+    correction = 1.;
+  }
+  else{
+    
+    //Printf("//=============CENTRALITY=============// %d:",gCentralityInt);
+    
+    if(fHistCorrectionPlus[gCentralityInt]){
+      if (vCharge > 0) {
+       correction = fHistCorrectionPlus[gCentralityInt]->GetBinContent(fHistCorrectionPlus[gCentralityInt]->GetBin(binEta, binPt, binPhi));
+       //Printf("CORRECTIONplus: %.2f | Centrality %d",correction,gCentralityInt);  
+      }
+      if (vCharge < 0) {
+       correction = fHistCorrectionMinus[gCentralityInt]->GetBinContent(fHistCorrectionMinus[gCentralityInt]->GetBin(binEta, binPt, binPhi));
+       //Printf("CORRECTIONminus: %.2f | Centrality %d",correction,gCentralityInt);
+      }
+    }
+    else {
+      correction = 1.;
+    }
+  }//centrality in array
+  
+  if (correction == 0.) { 
+    AliError(Form("Should not happen : bin content = 0. >> eta: %.2f | phi : %.2f | pt : %.2f | cent %d",vEta, vPhi, vPt, gCentralityInt)); 
+    correction = 1.; 
+  } 
+  
+  return correction;
+}
+
 //________________________________________________________________________
 void  AliAnalysisTaskToyModel::FinishOutput() {
   //Printf("END BF");
index 8e808a57b38122df9a7fe25c47ed388e692b7d93..35d16fd477e466efb6b2fbc5c07a6283f7bf4fad 100755 (executable)
@@ -69,6 +69,9 @@ class AliAnalysisTaskToyModel : public TObject {
     fNumberOfDeadSectors = numberOfDeadSectors;}
   void EnableEfficiencyDropNearEtaEdges() {
     fEfficiencyDropNearEtaEdges = kTRUE;}
+  void SimulateDetectorEffectsCorrection(TString filename, 
+                                        Int_t nCentralityBins, 
+                                        Double_t *centralityArrayForCorrections);
 
   //All charges
   void SetSpectraTemperatureForAllCharges(Double_t temperature) {
@@ -146,10 +149,20 @@ class AliAnalysisTaskToyModel : public TObject {
 
   //Jet-like structures
   void SetUseJets() {fUseJets = kTRUE;}
+
+  // Local charge conservation (LCC)
+  void SetUseLCC() {fUseLCC = kTRUE;}
+
   //============Toy model: List of setters============//
 
  private:
-  void SetupEfficiencyMatrix();
+  void SetupEfficiencyMatrix();//setup the efficiency matrix
+
+  Double_t GetTrackbyTrackCorrectionMatrix(Double_t vEta, 
+                                             Double_t vPhi, 
+                                             Double_t vPt, 
+                                             Short_t vCharge, 
+                                             Double_t gCentrality);//efficiency factor for the track
 
   Bool_t fUseDebug; //Debug flag
 
@@ -205,6 +218,21 @@ class AliAnalysisTaskToyModel : public TObject {
   Int_t fNumberOfDeadSectors;//number of dead sectors
   Bool_t fEfficiencyDropNearEtaEdges;//efficiency drop in eta edges
   TH3F *fEfficiencyMatrix; //efficiency matrix in eta-pt-phi
+  
+  Bool_t fSimulateDetectorEffectsCorrection;//simulate detector effects as used for correction of data
+  TH3F *fHistCorrectionPlus[101]; //correction matrix Plus
+  TH3F *fHistCorrectionMinus[101]; //correction matrix minus
+  Double_t fCentralityArrayForCorrections[101];//centrality array for correction
+  Int_t fCentralityArrayBinsForCorrections;//number of centralitry bins
+  Double_t fPtMinForCorrections;//only used for AODs
+  Double_t fPtMaxForCorrections;//only used for AODs
+  Double_t fPtBinForCorrections; //=================================correction
+  Double_t fEtaMinForCorrections;//only used for AODs
+  Double_t fEtaMaxForCorrections;//only used for AODs
+  Double_t fEtaBinForCorrections; //=================================correction
+  Double_t fPhiMinForCorrections;//only used for AODs
+  Double_t fPhiMaxForCorrections;//only used for AODs
+  Double_t fPhiBinForCorrections; //=================================correction
 
   //Kinematics
   Bool_t   fUseAllCharges; //use all charges
@@ -258,6 +286,8 @@ class AliAnalysisTaskToyModel : public TObject {
   Bool_t fUseJets;//Usage of jet-like structures
   TF1 *fPtAssoc;//pt of associated
 
+  Bool_t fUseLCC;//Usage of Local Charge Conservation
+
   AliAnalysisTaskToyModel(const AliAnalysisTaskToyModel&); // not implemented
   AliAnalysisTaskToyModel& operator=(const AliAnalysisTaskToyModel&); // not implemented
   
index 9e1a3b56061051c4d74569b7acbfba672f194959..d233c488b8f8411400925ebe553b49802fea8f73 100644 (file)
@@ -1963,7 +1963,7 @@ TH2D *AliBalancePsi::GetCorrelationFunction(TString type,
        fMixed = bMixed->GetCorrelationFunctionChargeIndependent(binPsiLowEdge,binPsiUpEdge,binVertexLowEdge,binVertexUpEdge,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax);
       }
 
-      if(fMixed && normToTrig){
+      if(fMixed && normToTrig && fMixed->Integral()>0){
        
        // normalization of Event mixing to 1 at (0,0) --> Jan Fietes method
        // do it only on away-side (due to two-track cuts)
index ab57c08c3b5e08b022983052b9975b7b0faed3f5..ccf6e8611564ff7658f765f8ac090cb5c4c63afc 100644 (file)
@@ -442,7 +442,7 @@ void AliEbyEHigherMomentsTask::doMCAODEvent(){
   fTHnCentNplusNminusChTruth->Fill(fContainerChTruth);//MC -Truth ch. particles
   
   //cout << fCentrality << " " << positiveSumMCRec << " " << negativeSumMCRec <<endl;
-  cout <<fCentrality<<"   " << positiveSumMCTruth << " " << negativeSumMCTruth << endl;
+  //cout <<fCentrality<<"   " << positiveSumMCTruth << " " << negativeSumMCTruth << endl;
   //cout <<"   " << posPidSumMCRec << " " << negPidSumMCRec << endl;
   //cout <<"   " << posPidSumMCTruth << " " << negPidSumMCTruth << endl;
   //cout <<"---------------------------------" << endl;
@@ -456,10 +456,10 @@ void AliEbyEHigherMomentsTask::doMCAODEvent(){
     ptContainer[i] = PtCh[i-1];
     ptContainerMC[i] = ptChMC[i-1];
     //cout <<" "<< PtCh[i-1]<<endl;
-    cout<< " MC=" << ptChMC[i-1];
+    //  cout<< " MC=" << ptChMC[i-1];
   }
 
-  cout << endl;
+  //cout << endl;
 
   fPtBinNplusNminusCh->Fill(ptContainer);
   fPtBinNplusNminusChTruth->Fill(ptContainerMC);
index a0747892fb4e002dc3957bcf10bd4ed7e9ced1c8..fd86b274d347a4aef38c08fca0928bc5c49a1179 100644 (file)
@@ -25,6 +25,7 @@
 #include "TCanvas.h"
 #include "TLatex.h"
 #include "TPaveStats.h"
+#include "TASImage.h"
 
 #define BohrR 1963.6885 // Bohr Radius for pions
 #define FmToGeV 0.19733 // conversion to fm
 
 using namespace std;
 
-int FileSetting=0;// 0(standard), 1(r3 Lambda), 2(TTC), 3(PID), 4(Pos B), 5(Neg B), 6(GaussR8to5), 7(GaussR11to6), 8(4 kt bins old TTC cuts), 9 (FB5and7overlap)
+int FileSetting=0;// 0(standard), 1(r3 Lambda), 2(TTC), 3(PID), 4(Pos B), 5(Neg B), 6(GaussR8to5), 7(GaussR11to6), 8(4 kt bins old TTC cuts), 9 (FB5and7overlap), 10 (muon Variation: -0.5<NsigmaPion<2.0)
 bool MCcase_def=kFALSE;// MC data?
 int CHARGE_def=-1;// -1 or +1: + or - pions for same-charge case, --+ or ++- for mixed-charge case
-bool SameCharge_def=kTRUE;// 3-pion same-charge?
+bool SameCharge_def=1;// 3-pion same-charge?
 int EDbin_def=0;// 0 or 1: Kt3 bin
 //
+bool MuonCorrection=1;// correct for Muons?
 bool IncludeG_def=kFALSE;// Include coherence?
 bool IncludeEW_def=kTRUE;// Include EdgeWorth coefficients?
 bool IncludeEWfromTherm_def=kFALSE;// Include EdgeWorth coefficients from Therminator?
@@ -106,12 +108,10 @@ TH1D *CoulCorr2SS;
 TH1D *CoulCorr2OS;
 TF1 *StrongSC;// same-charge pion strong FSI
 
-//static double Lednicky_qinv[74];
-//static double Lednicky_CoulStrong[74];
 
 void ReadCoulCorrections(int, int, int);
 void ReadCoulCorrections_Omega0();
-//void ReadLednickyFile(int);
+void ReadMuonCorrections(int);
 void ReadMomResFile(int, double);
 double CoulCorr2(int, double);
 double CoulCorrOmega0(bool, double, double, double);
@@ -126,6 +126,7 @@ double C2osFitFunction(Double_t *x, Double_t *par);
 double cubicInterpolate(double[4], double);
 double bicubicInterpolate(double[4][4], double, double);
 double tricubicInterpolate(double[4][4][4], double, double, double);
+void DrawALICELogo(Bool_t, Float_t, Float_t, Float_t, Float_t);
 //
 void fcnC2_Global(int&, double*, double&, double[], int);
 void fcnOSL(int&, double*, double&, double[], int);
@@ -194,6 +195,12 @@ double r3_3d_arr_e[20][20][20];
 double AvgQinvSS[30];
 double AvgQinvOS[30];
 //
+TH1D *C2muonCorrection_SC;
+TH1D *C2muonCorrection_MC;
+TH1D *WeightmuonCorrection;
+TH1D *C3muonCorrection;
+
+
 
 
 void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bool IncludeEWfromTherm=IncludeEWfromTherm_def, bool SameCharge=SameCharge_def, bool IncludeG=IncludeG_def, bool IncludeEW=IncludeEW_def, bool GRS=GRS_def, int EDbin=EDbin_def, int CHARGE=CHARGE_def, int Mbin=Mbin_def, int Ktbin=Ktbin_def){
@@ -288,7 +295,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   
   // Core-Halo modeling of single-particle and triple-particle core fraction 
   //float AvgN[10]={472.56, 390.824, 319.597, 265.933, 218.308, 178.865, 141.2, 115.88, 87.5556, 69.3235};// 10h (avg total pion mult)/2. 2.0sigma
-  float AvgN[10]={571.2, 472.7, 400.2, 325.2, 268.721, 220.3, 178.9, 143.4, 113.412, 88.0};// 11h (avg total pion mult)/2.  2.0sigma
+  //float AvgN[10]={571.2, 472.7, 400.2, 325.2, 268.721, 220.3, 178.9, 143.4, 113.412, 88.0};// 11h (avg total pion mult)/2.  2.0sigma
  
   //
   // avg Qinv within the 5 MeV bins (0-5, 5-10,...) for true bin mean values.  From unsmeared HIJING 0-5% with input signal
@@ -330,7 +337,8 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
       if(Mbin<=1){
        //myfile = new TFile("Results/PDC_HIJING_12a17ad_fix_genSignal_Rinv11.root","READ");
        //myfile = new TFile("Results/PDC_HIJING_12a17ad_fix_genSignal_Rinv11_Smeared.root","READ");
-       myfile = new TFile("Results/PDC_HIJING_12a17ad_fix_KtgenSignal_Rinv11.root","READ");
+       //myfile = new TFile("Results/PDC_HIJING_12a17ad_fix_KtgenSignal_Rinv11.root","READ");
+       myfile = new TFile("Results/PDC_pureHIJING_12a17a_fix_KtgenSignal_Rinv11.root","READ");
        //myfile = new TFile("Results/PDC_HIJING_10h8.root","READ");
       }else{
        myfile = new TFile("Results/PDC_HIJING_12a17b_myRun_L0p68R11_C2plots.root","READ");
@@ -351,7 +359,8 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
       if(FileSetting==6) myfile = new TFile("Results/PDC_11h_GaussR8to5.root","READ");// Gaussian
       if(FileSetting==7) myfile = new TFile("Results/PDC_11h_GaussR11to6.root","READ");// Gaussian
       if(FileSetting==8) myfile = new TFile("Results/PDC_11h_4ktbins.root","READ");// 4 kt bins (0.035TTC)
-      if(FileSetting==9) myfile = new TFile("Results/PDC_11h_FB5and7overlap.root","READ");// FB5and7overlap
+      if(FileSetting==9) myfile = new TFile("Results/PDC_11h_FB5and7overlap_l0p8.root","READ");// FB5and7overlap
+      if(FileSetting==10) myfile = new TFile("Results/PDC_11h_muonVar.root","READ");
     }
   }else{// pp
     cout<<"pp not currently supported"<<endl;
@@ -362,9 +371,10 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   //ReadLednickyFile(RValue);
   ReadMomResFile(RValueMomRes, TwoFracMomRes);
   ReadCoulCorrections_Omega0();
+  ReadMuonCorrections(Mbin);
   //
   /////////////////////////////////////////////////////////
-
+  
 
   double NormQcutLow;
   double NormQcutHigh;
@@ -910,14 +920,14 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
     for(int i=0; i<BINRANGE_C2global; i++){
       
       C2ssFitting[i] = (temp_mm->GetBinContent(i+1) + temp_pp->GetBinContent(i+1))/2.;
-      if(!GeneratedSignal && !MCcase) C2ssFitting[i] *= MomRes_C2_pp[i];
+      if(!GeneratedSignal && !MCcase) C2ssFitting[i] *= (MomRes_C2_pp[i]-1)*MRCShift+1;
       C2ssFitting_e[i] = pow(MomRes_C2_pp[i]*sqrt(pow(temp_mm->GetBinError(i+1),2) + pow(temp_pp->GetBinError(i+1),2))/sqrt(2.),2);
       C2ssRaw->SetBinContent(i+1, (temp_mm->GetBinContent(i+1) + temp_pp->GetBinContent(i+1))/2.);
       C2ssRaw->SetBinError(i+1, pow(sqrt(pow(temp_mm->GetBinError(i+1),2) + pow(temp_pp->GetBinError(i+1),2))/sqrt(2.),2));
       C2ssFitting_e[i] += pow((MomRes_C2_pp[i]-1)*0.1 * (temp_mm->GetBinContent(i+1) + temp_pp->GetBinContent(i+1))/2.,2);
       C2ssFitting_e[i] = sqrt(C2ssFitting_e[i]);
       C2osFitting[i] = temp_mp->GetBinContent(i+1);
-      if(!GeneratedSignal && !MCcase) C2osFitting[i] *= MomRes_C2_mp[i];
+      if(!GeneratedSignal && !MCcase) C2osFitting[i] *= (MomRes_C2_mp[i]-1)*MRCShift+1;
       C2osFitting_e[i] = pow(MomRes_C2_mp[i]*temp_mp->GetBinError(i+1),2);
       C2osRaw->SetBinContent(i+1, temp_mp->GetBinContent(i+1));
       C2osRaw->SetBinError(i+1, temp_mp->GetBinError(i+1));
@@ -1084,7 +1094,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
     
   }// iteration loop
   
-
   TH1D *C2_ss=(TH1D*)Two_ex_clone_mm->Clone();
   TH1D *C2_os=(TH1D*)Two_ex_clone_mp->Clone();
   TH1D *C2_ss_Momsys=(TH1D*)Two_ex_clone_mm->Clone();
@@ -1093,7 +1103,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   TH1D *C2_os_Ksys=(TH1D*)Two_ex_clone_mp->Clone();
   TH1D *K2_ss = (TH1D*)Two_ex_clone_mm->Clone();
   TH1D *K2_os = (TH1D*)Two_ex_clone_mp->Clone();
-  
+
   for(int i=0; i<BINRANGE_C2global; i++){ 
     C2_ss->SetBinContent(i+1, C2ssFitting[i]);
     C2_os->SetBinContent(i+1, C2osFitting[i]);
@@ -1113,7 +1123,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
     K2_ss->SetBinContent(i+1, K2SS[i]); K2_ss->SetBinError(i+1, 0);
     K2_os->SetBinContent(i+1, K2OS[i]); K2_os->SetBinError(i+1, 0);
   }
-  
+
   C2_ss_Momsys->SetMarkerSize(0);
   C2_ss_Momsys->SetFillStyle(1000);
   C2_ss_Momsys->SetFillColor(kRed-10);
@@ -1148,9 +1158,9 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   C2_os->SetMarkerSize(1.5);
   C2_os->SetMarkerStyle(25);
   C2_os->SetMarkerColor(4);
-  
-  TF1 *fitC2ss = new TF1("fitC2ss",C2ssFitFunction, 0.005,0.2, npar);
-  TF1 *fitC2os = new TF1("fitC2os",C2osFitFunction, 0.005,0.2, npar);
+  TF1 *fitC2ss = new TF1("fitC2ss",C2ssFitFunction, 0.001,0.2, npar);
+  TF1 *fitC2os = new TF1("fitC2os",C2osFitFunction, 0.001,0.2, npar);
   for(int i=0; i<npar; i++) {
     fitC2ss->FixParameter(i,OutputPar[i]);
     fitC2ss->SetParError(i,OutputPar_e[i]);
@@ -1163,6 +1173,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   TH1D *fitC2os_h=new TH1D("fitC2os_h","",C2_os->GetNbinsX(),0,C2_os->GetXaxis()->GetBinUpEdge(C2_os->GetNbinsX()));
   fitC2ss_h->SetLineWidth(2); fitC2os_h->SetLineWidth(2);
   fitC2ss_h->SetLineColor(2); fitC2os_h->SetLineColor(4);
+
   for(int bin=1; bin<=fitC2ss_h->GetNbinsX(); bin++){
     double qinv=(bin-0.5)*0.005;
     fitC2ss_h->SetBinContent(bin, fitC2ss->Eval(qinv));
@@ -1511,7 +1522,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   TH1D *Coul_Omega0 = new TH1D("Coul_Omega0","",Q3BINS,0,0.2);
   TH1D *c3_hist = new TH1D("c3_hist","",Q3BINS,0,0.2);
   TH1D *c3_hist_STAR = new TH1D("c3_hist_STAR","",Q3BINS,0,0.2);
-  TProfile *MomRes_2d = new TProfile("MomRes_2d","",Q3BINS,0,0.2, 0,20.,"");
+  //TProfile *MomRes_2d = new TProfile("MomRes_2d","",Q3BINS,0,0.2, 0,20.,"");
   TProfile *MomRes_3d_term1 = new TProfile("MomRes_3d_term1","",Q3BINS,0,0.2, 0,20.,"");
   TProfile *MomRes_3d_term2 = new TProfile("MomRes_3d_term2","",Q3BINS,0,0.2, 0,20.,"");
   TProfile *MomRes_3d_term5 = new TProfile("MomRes_3d_term5","",Q3BINS,0,0.2, 0,20.,"");
@@ -1550,8 +1561,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
     else {CB1=0; CB2=1; CB3=1; CP12=-1, CP13=-1, CP23=+1;}
   }
   
-
-
+  cout<<"here"<<endl;
   // SC = species combination.  Always 0 meaning pi-pi-pi.
   int SCBin=0;
   //
@@ -1608,7 +1618,8 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
        }
        if(MCcase && !GeneratedSignal) { K2_12=1.; K2_13=1.; K2_23=1.; K3=1.;}
        if(K3==0) continue;
-       
+       if(GeneratedSignal) K3 = K2_12*K2_13*K2_23;// no interpolation for Generated signal
+
        double TERM1=Three_3d[CB1][CB2][CB3][SCBin][0]->GetBinContent(i,j,k);// N3 (3-pion yield per q12,q13,q23 cell). 3-pions from same-event
        double TERM2=Three_3d[CB1][CB2][CB3][SCBin][1]->GetBinContent(i,j,k);// N2*N1. 1 and 2 from same-event
        double TERM3=Three_3d[CB1][CB2][CB3][SCBin][2]->GetBinContent(i,j,k);// N2*N1. 1 and 3 from same-event
@@ -1617,6 +1628,31 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
        if(TERM1==0 && TERM2==0 && TERM3==0 && TERM4==0 && TERM5==0) continue;
        if(TERM1==0 || TERM2==0 || TERM3==0 || TERM4==0 || TERM5==0) continue;
        
+       double muonCorr_C3=1.0, muonCorr_C2_12=1.0, muonCorr_C2_13=1.0, muonCorr_C2_23=1.0;
+       double muonCorr_W12=1.0, muonCorr_W13=1.0, muonCorr_W23=1.0;
+       if(MuonCorrection){
+         if(SameCharge){
+           muonCorr_C3 = C3muonCorrection->GetBinContent(Q3bin);
+           muonCorr_C2_12 = C2muonCorrection_SC->GetBinContent(Q12bin);
+           muonCorr_C2_13 = C2muonCorrection_SC->GetBinContent(Q13bin);
+           muonCorr_C2_23 = C2muonCorrection_SC->GetBinContent(Q23bin);
+           muonCorr_W12 = WeightmuonCorrection->GetBinContent(Q12bin);
+           muonCorr_W13 = WeightmuonCorrection->GetBinContent(Q13bin);
+           muonCorr_W23 = WeightmuonCorrection->GetBinContent(Q23bin);
+         }else{
+           muonCorr_C3 = C3muonCorrection->GetBinContent(Q3bin);
+           if(CHARGE==-1){// pi-pi-pi+
+             muonCorr_C2_12 = C2muonCorrection_SC->GetBinContent(Q12bin);
+             muonCorr_C2_13 = C2muonCorrection_MC->GetBinContent(Q13bin);
+             muonCorr_C2_23 = C2muonCorrection_MC->GetBinContent(Q23bin);
+           }else{// pi-pi+pi+
+             muonCorr_C2_12 = C2muonCorrection_MC->GetBinContent(Q12bin);
+             muonCorr_C2_13 = C2muonCorrection_MC->GetBinContent(Q13bin);
+             muonCorr_C2_23 = C2muonCorrection_SC->GetBinContent(Q23bin);
+           }
+         }
+       }       
+
        if(Q3>0.08 && Q3<0.09){// just for testing
          if(Q12>0.08 || Q13>0.08 || Q23>0.08) OutTriplets++;
          else InTriplets++;
@@ -1631,13 +1667,6 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
            TERM3 *= (MomRes3d[0][2]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
            TERM4 *= (MomRes3d[0][3]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
            TERM5 *= (MomRes3d[0][4]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
-           // Triple produce of 1-d momentum resolution corrections (less accurate).
-           /*TERM1 *= MomRes_term1_pp[i-1]*MomRes_term1_pp[j-1]*MomRes_term1_pp[k-1];
-           TERM2 *= MomRes_term1_pp[i-1]*MomRes_term2_pp[j-1]*MomRes_term2_pp[k-1];
-           TERM3 *= MomRes_term2_pp[i-1]*MomRes_term1_pp[j-1]*MomRes_term2_pp[k-1];
-           TERM4 *= MomRes_term2_pp[i-1]*MomRes_term2_pp[j-1]*MomRes_term1_pp[k-1];
-           TERM5 *= MomRes_term2_pp[i-1]*MomRes_term2_pp[j-1]*MomRes_term2_pp[k-1];*/
-           //MomRes_2d->Fill(Q3, MomRes_term1_pp[i-1]*MomRes_term1_pp[j-1]*MomRes_term1_pp[k-1]);
            MomRes_3d_term1->Fill(Q3, MomRes3d[0][0]->GetBinContent(Q12bin, Q13bin, Q23bin),TERM1);
            MomRes_3d_term2->Fill(Q3, MomRes3d[0][1]->GetBinContent(Q12bin, Q13bin, Q23bin),TERM2);
            MomRes_3d_term5->Fill(Q3, MomRes3d[0][4]->GetBinContent(Q12bin, Q13bin, Q23bin),TERM5);
@@ -1648,25 +1677,13 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
              TERM3 *= (MomRes3d[1][2]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
              TERM4 *= (MomRes3d[1][3]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
              TERM5 *= (MomRes3d[1][4]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;
-             //TERM1 *= MomRes_term1_pp[i-1]*MomRes_term1_mp[j-1]*MomRes_term1_mp[k-1];
-             //TERM2 *= MomRes_term1_pp[i-1]*MomRes_term2_mp[j-1]*MomRes_term2_mp[k-1];
-             //TERM3 *= MomRes_term2_pp[i-1]*MomRes_term1_mp[j-1]*MomRes_term2_mp[k-1];
-             //TERM4 *= MomRes_term2_pp[i-1]*MomRes_term2_mp[j-1]*MomRes_term1_mp[k-1];
-             //TERM5 *= MomRes_term2_pp[i-1]*MomRes_term2_mp[j-1]*MomRes_term2_mp[k-1];
-             
            }else {// pi-pi+pi+
              TERM1 *= (MomRes3d[1][0]->GetBinContent(Q23bin, Q13bin, Q12bin)-1)*MRCShift+1;
              TERM2 *= (MomRes3d[1][3]->GetBinContent(Q23bin, Q13bin, Q12bin)-1)*MRCShift+1;
              TERM3 *= (MomRes3d[1][2]->GetBinContent(Q23bin, Q13bin, Q12bin)-1)*MRCShift+1;
              TERM4 *= (MomRes3d[1][1]->GetBinContent(Q23bin, Q13bin, Q12bin)-1)*MRCShift+1;
              TERM5 *= (MomRes3d[1][4]->GetBinContent(Q23bin, Q13bin, Q12bin)-1)*MRCShift+1;
-             //TERM1 *= MomRes_term1_mp[i-1]*MomRes_term1_mp[j-1]*MomRes_term1_pp[k-1];
-             //TERM2 *= MomRes_term1_mp[i-1]*MomRes_term2_mp[j-1]*MomRes_term2_pp[k-1];
-             //TERM3 *= MomRes_term2_mp[i-1]*MomRes_term1_mp[j-1]*MomRes_term2_pp[k-1];
-             //TERM4 *= MomRes_term2_mp[i-1]*MomRes_term2_mp[j-1]*MomRes_term1_pp[k-1];
-             //TERM5 *= MomRes_term2_mp[i-1]*MomRes_term2_mp[j-1]*MomRes_term2_pp[k-1];
            }
-           //MomRes_2d->Fill(Q3, MomRes_term1_pp[i-1]*MomRes_term1_mp[j-1]*MomRes_term1_mp[k-1]);// always treats 12 as ss pair
            MomRes_3d_term1->Fill(Q3, MomRes3d[1][0]->GetBinContent(Q12bin, Q13bin, Q23bin), TERM1);
            MomRes_3d_term2->Fill(Q3, MomRes3d[1][1]->GetBinContent(Q12bin, Q13bin, Q23bin),TERM2);
            MomRes_3d_term5->Fill(Q3, MomRes3d[1][4]->GetBinContent(Q12bin, Q13bin, Q23bin),TERM5);
@@ -1677,9 +1694,9 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
        for(int LamType=0; LamType<2; LamType++){
          
          if(LamType==1) TwoFrac=TwoFracr3;// r3
-         else TwoFrac = OutputPar[1];// c3
+         else TwoFrac = 0.7;//OutputPar[1];// c3 (newly fixed to 0.7)
          
-         if(LamType==0 && FileSetting==9) TwoFrac=0.8;// for FB5and7overlap choose a fixed higher lambda
+         if(FileSetting==9) TwoFrac=0.8;// for FB5and7overlap choose a fixed higher lambda
 
          OneFrac=pow(TwoFrac,0.5); // 0.495 to bring baseline up
          ThreeFrac=pow(TwoFrac,1.5);
@@ -1695,16 +1712,18 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
          N3_QS[LamType] -= (1-OneFrac)*(TERM2 + TERM3 + TERM4 - 3*(1-TwoFrac)*TERM5);
          N3_QS[LamType] /= ThreeFrac;
          N3_QS[LamType] /= K3;
+         N3_QS[LamType] *= muonCorr_C3;
          
          if(LamType==0) num_QS->Fill(Q3, N3_QS[LamType]);
          
          // Isolate 3-pion cumulant
          value_num[LamType] = N3_QS[LamType];
-         value_num[LamType] -= (TERM2 - (1-TwoFrac)*TERM5)/K2_12/TwoFrac;
-         value_num[LamType] -= (TERM3 - (1-TwoFrac)*TERM5)/K2_13/TwoFrac;
-         value_num[LamType] -= (TERM4 - (1-TwoFrac)*TERM5)/K2_23/TwoFrac;
+         value_num[LamType] -= (TERM2 - (1-TwoFrac)*TERM5)/K2_12/TwoFrac * muonCorr_C2_12;
+         value_num[LamType] -= (TERM3 - (1-TwoFrac)*TERM5)/K2_13/TwoFrac * muonCorr_C2_13;
+         value_num[LamType] -= (TERM4 - (1-TwoFrac)*TERM5)/K2_23/TwoFrac * muonCorr_C2_23;
          value_num[LamType] += 2*TERM5;
          
+         //value_num[LamType] += 0.004*TERM5;
                  
          // r3 denominator
          if(LamType==1 && SameCharge) {
@@ -1747,11 +1766,14 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
              double den_ratioKShift = sqrt(fabs(denMRC1))/sqrt(fabs(denKshiftBack));
              value_den[LamType] *= den_ratioKShift;
              //
+             value_den[LamType] *= sqrt(muonCorr_W12*muonCorr_W13*muonCorr_W23);// muon correction
+             //
              //value_den[LamType] -= TPNRejects->GetBinContent(i,j,k);// Testing for 0-5% only to estimate the effect when C2^QS < 1.0
              value_den[LamType] *= (MomRes3d[0][4]->GetBinContent(Q12bin, Q13bin, Q23bin)-1)*MRCShift+1;// momentum resolution correction to combinatorics
-           }
+           }// !MCcase
          }
-         
+        
+
          // errors
          N3_QS_e[LamType] = fabs(TERM1);
          N3_QS_e[LamType] += pow(( pow(1-OneFrac,3) +3*OneFrac*pow(1-OneFrac,2) )*sqrt(fabs(TERM5)),2);
@@ -1973,7 +1995,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   c3_hist->SetLineColor(2);
   c3_hist->SetMaximum(3);
   c3_hist->SetMinimum(.9);
-  if(!MCcase) c3_hist->Draw("same");
+  if(!MCcase && !GeneratedSignal) c3_hist->Draw("same");
   //legend2->AddEntry(c3_hist,"#font[12]{c}_{3} (cumulant correlation)","p");
   
   if(SameCharge){
@@ -2009,7 +2031,7 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   //MomRes_3d_term5->Draw("same");
   //legend2->AddEntry(MomRes_3d,"3D","p");
   
-  legend2->Draw("same");
+  //legend2->Draw("same");
   
   //cout<<c3_hist->Integral(8,10)/3.<<endl;
   
@@ -2284,10 +2306,14 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
   TF1 *QuarticFit = new TF1("QuarticFit","[0]*(1-[1]*pow(x,4))",0,.1);
   QuarticFit->SetParameter(0,2); QuarticFit->SetParameter(1,0);
   QuarticFit->SetLineColor(4);
-  QuarticFit->SetParName(0,"I(Q^{4})"); QuarticFit->SetParName(1,"a(Q^{4})"); 
+  QuarticFit->SetParName(0,"I^{Quartic}"); QuarticFit->SetParName(1,"a^{Quartic}"); 
   TF1 *QuadraticFit = new TF1("QuadraticFit","[0]*(1-[1]*pow(x,2))",0,.1);
   QuadraticFit->SetParameter(0,2); QuadraticFit->SetParameter(1,0);
-  QuadraticFit->SetParName(0,"I(Q^{2})"); QuadraticFit->SetParName(1,"a(Q^{2})"); 
+  QuadraticFit->SetParName(0,"I^{Quadratic}"); QuadraticFit->SetParName(1,"a^{Quadratic}"); 
+  TLegend *legend3 = new TLegend(.2,.85,.5,.95,NULL,"brNDC");
+  legend3->SetBorderSize(1);
+  legend3->SetTextSize(.04);// small .03; large .06
+  legend3->SetFillColor(0);
 
 
   if(SameCharge){
@@ -2295,29 +2321,164 @@ void Plot_PDCumulants(bool SaveToFile=SaveToFile_def, bool MCcase=MCcase_def, bo
     r3_num_Q3->SetMinimum(0); r3_num_Q3->SetMaximum(2.5);// 0 to 2.5
     r3_num_Q3->GetXaxis()->SetRangeUser(0.0,0.1);
     r3_num_Q3->Draw();
+
+
+    // HIJING standalone
+    // Kt3 1
+    /*double Gen_r3_m_M0[10]={0, 1.97963, 2.10248, 2.04465, 1.96697, 2.02295, 1.92281, 2.10031, 2.22338, 2.49729};
+    double Gen_r3_m_M0_e[10]={0, 0.132726, 0.0668652, 0.0451347, 0.042838, 0.0546967, 0.0754362, 0.133624, 0.286307, 0.628381};
+    double Gen_r3_p_M0[10]={0, 1.91771, 1.9653, 2.00742, 2.02393, 1.90624, 1.93554, 1.66, 1.79584, 0.301761};
+    double Gen_r3_p_M0_e[10]={0, 0.133654, 0.0667213, 0.0451512, 0.0428925, 0.0547591, 0.0754764, 0.13365, 0.28638, 0.628441};*/
+    // Kt3 2
+    /*double Gen_r3_m_M0[10]={0, 1.12993, 2.09715, 1.91886, 2.08493, 2.10931, 2.00286, 1.99898, 1.78549, 1.91861};
+    double Gen_r3_m_M0_e[10]={0, 0.237903, 0.115454, 0.0725178, 0.0630867, 0.0730326, 0.0886163, 0.12885, 0.213654, 0.379273};
+    double Gen_r3_p_M0[10]={0, 2.05766, 1.97408, 2.05182, 2.02431, 2.11783, 1.93294, 1.97525, 2.21833, 2.31318};
+    double Gen_r3_p_M0_e[10]={0, 0.24238, 0.11515, 0.0725077, 0.0629938, 0.0729842, 0.0886386, 0.12884, 0.213737, 0.379196};*/
+    
+    
+    // HIJING + ALICE
+    // Kt3 1
+    /*double Gen_r3_m_M0[10]={0, 2.03468, 2.05783, 1.97757, 2.03809, 1.95703, 2.02915, 1.80055, 1.97664, 1.49573};
+    double Gen_r3_m_M0_e[10]={0, 0.284164, 0.0923288, 0.0543837, 0.045952, 0.0565222, 0.0748221, 0.128994, 0.271954, 0.599077};
+    double Gen_r3_p_M0[10]={0, 1.74611, 1.92369, 2.11024, 2.02823, 2.06235, 2.00127, 1.91551, 1.90576, 2.521};
+    double Gen_r3_p_M0_e[10]={0, 0.279962, 0.0928866, 0.0548168, 0.0462253, 0.0569129, 0.0752683, 0.129803, 0.2736, 0.602535};
+    double Gen_r3_m_M1[10]={0, 1.71341, 1.8735, 1.9352, 1.96466, 1.93852, 1.69509, 1.51402, 1.6014, -0.802941};
+    double Gen_r3_m_M1_e[10]={0, 0.334562, 0.108368, 0.0640739, 0.0540579, 0.0663174, 0.0876532, 0.149302, 0.307982, 0.640548};
+    double Gen_r3_p_M1[10]={0, 1.50861, 2.09508, 2.05338, 1.96178, 1.97999, 2.07162, 1.8607, 1.91805, 1.10468};
+    double Gen_r3_p_M1_e[10]={0, 0.3399, 0.109449, 0.0646241, 0.0544419, 0.0667711, 0.0882695, 0.150195, 0.309844, 0.643923};*/
+    // Kt3 2
+    /*double Gen_r3_m_M0[10]={0, 1.04272, 2.05961, 1.93025, 2.08203, 2.07565, 2.29192, 1.93009, 2.68715, 1.71175};
+    double Gen_r3_m_M0_e[10]={0, 3.09343, 0.30016, 0.117634, 0.0757208, 0.0794904, 0.090823, 0.128235, 0.21308, 0.40023};
+    double Gen_r3_p_M0[10]={0, 1.83276, 1.88969, 2.03778, 2.0907, 2.11919, 2.04992, 2.02593, 1.95209, 1.68264};
+    double Gen_r3_p_M0_e[10]={0, 3.59, 0.298056, 0.118354, 0.0762849, 0.079909, 0.0912179, 0.128866, 0.213999, 0.402173};
+    double Gen_r3_m_M1[10]={0, 5.40628, 1.52822, 1.93258, 2.13338, 2.05811, 2.02963, 2.1204, 2.04906, 1.9021};
+    double Gen_r3_m_M1_e[10]={0, 4.3025, 0.350163, 0.13871, 0.0897272, 0.0938973, 0.107045, 0.151557, 0.25029, 0.446325};
+    double Gen_r3_p_M1[10]={0, 3.15883, 1.86772, 2.24914, 2.12118, 2.09175, 2.01447, 2.36802, 2.57239, 2.68729};
+    double Gen_r3_p_M1_e[10]={0, 4.6622, 0.348237, 0.140294, 0.0903003, 0.09446, 0.107692, 0.152575, 0.251939, 0.448919};*/
     
+    //double r3Sys_M1[10]={0, 0.097, 0.056, 0.063, 0.097, 0.17, 0.32, 0.66, 1.4, 3.4};
+    // muon variation
+    /*double r3_muonVar_M1[10]={0, 1.73244, 1.80921, 1.77852, 1.7192, 1.62059, 1.50122, 1.37656, 1.01344, 0.755781};
+    double r3_muonVar_M1_e[10]={0, 0.160786, 0.051075, 0.031982, 0.0293467, 0.0390241, 0.0514494, 0.0760959, 0.112944, 0.154592};
+    TH1D *r3_muonVar=(TH1D*)r3_num_Q3->Clone();
+    for(int i=0; i<10; i++){ 
+      r3_muonVar->SetBinContent(i+1,r3_muonVar_M1[i]); 
+      r3_muonVar->SetBinError(i+1,sqrt(pow(r3_muonVar_M1_e[i],2)+pow(r3Sys_M1[i],2)));
+    }
+    r3_muonVar->SetMarkerStyle(21);
+    r3_muonVar->SetMarkerColor(2); r3_muonVar->SetLineColor(2);
+    r3_muonVar->SetFillStyle(1000); r3_muonVar->SetFillColor(kRed-10);
+    r3_muonVar->Draw("E2 same");
+    r3_num_Q3->Draw("same");
+    legend3->AddEntry(r3_num_Q3,"-2.0<N#sigma_{Pion}<2.0 (default)","p");
+    legend3->AddEntry(r3_muonVar,"-0.5<N#sigma_{Pion}<2.0","p");
+    legend3->Draw("same");*/
+    
+    // muon correction 
+    /*double r3_muonCorr_M1[10]={0, 1.8462, 1.84371, 1.79934, 1.77217, 1.76725, 1.79545, 1.7986, 2.11717, 2.86177};
+    double r3_muonCorr_M1_e[10]={0, 0.0838277, 0.0266269, 0.0168108, 0.0156166, 0.0211333, 0.0286836, 0.0450595, 0.075618, 0.141419};
+    TH1D *r3_muonCorr=(TH1D*)r3_num_Q3->Clone();
+    for(int i=0; i<10; i++){ 
+      r3_muonCorr->SetBinContent(i+1,r3_muonCorr_M1[i]); 
+      r3_muonCorr->SetBinError(i+1,sqrt(pow(r3_muonCorr_M1_e[i],2) + pow(r3Sys_M1[i],2)));
+    }
+    r3_muonCorr->SetMarkerStyle(21);
+    r3_muonCorr->SetMarkerColor(2); r3_muonCorr->SetLineColor(2);
+    r3_muonCorr->SetFillStyle(1000); r3_muonCorr->SetFillColor(kRed-10);
+    r3_muonCorr->Draw("E2 same");
+    r3_num_Q3->Draw("same");
+    legend3->AddEntry(r3_num_Q3,"No Muon Correction","p");
+    legend3->AddEntry(r3_muonCorr,"Correction Applied","p");
+    legend3->Draw("same");*/
+    
+    // muon correction for muon variation data
+    /*double r3_muonCorr_M1[10]={0, 1.71115, 1.8128, 1.79761, 1.76112, 1.70699, 1.63908, 1.63417, 1.49861, 1.75565};
+    double r3_muonCorr_M1_e[10]={0, 0.155228, 0.0491558, 0.0308125, 0.0283357, 0.0378035, 0.0501422, 0.0756057, 0.119169, 0.202093};
+    TH1D *r3_muonCorr=(TH1D*)r3_num_Q3->Clone();
+    for(int i=0; i<10; i++){ 
+      r3_muonCorr->SetBinContent(i+1,r3_muonCorr_M1[i]); 
+      r3_muonCorr->SetBinError(i+1,sqrt(pow(r3_muonCorr_M1_e[i],2) + pow(r3Sys_M1[i],2)));
+    }
+    r3_muonCorr->SetMarkerStyle(21);
+    r3_muonCorr->SetMarkerColor(2); r3_muonCorr->SetLineColor(2);
+    r3_muonCorr->SetFillStyle(1000); r3_muonCorr->SetFillColor(kRed-10);
+    r3_muonCorr->Draw("E2 same");
+    r3_num_Q3->Draw("same");
+    legend3->AddEntry(r3_num_Q3,"Muon Corrected.  Default PID","p");
+    legend3->AddEntry(r3_muonCorr,"Muon Corrected.  Varied PID","p");
+    legend3->Draw("same");*/
+
+    /*for(int i=1; i<=10; i++){
+      cout<<r3_num_Q3->GetBinContent(i)<<", ";
+    }
+    cout<<endl;
+    for(int i=1; i<=10; i++){
+      cout<<r3_num_Q3->GetBinError(i)<<", ";
+      }*/
+
     /*
-    r3_num_Q3->Fit(QuarticFit,"IME","",0,0.1);
+    TH1D *Merged_SanityCheck=(TH1D*)r3_num_Q3->Clone();
+    for(int i=1; i<=10; i++){
+      double value = (Gen_r3_m_M0[i-1]+Gen_r3_p_M0[i-1])/2.;
+      double value_e = sqrt(pow(Gen_r3_m_M0_e[i-1],2)+pow(Gen_r3_p_M0_e[i-1],2))/2.;
+      //double value = (Gen_r3_m_M0[i-1]+Gen_r3_p_M0[i-1]+Gen_r3_m_M1[i-1]+Gen_r3_p_M1[i-1])/4.;
+      //double value_e = sqrt(pow(Gen_r3_m_M0_e[i-1],2)+pow(Gen_r3_p_M0_e[i-1],2)+pow(Gen_r3_m_M1_e[i-1],2)+pow(Gen_r3_p_M1_e[i-1],2))/4.;
+      Merged_SanityCheck->SetBinContent(i,value);
+      Merged_SanityCheck->SetBinError(i,value_e);
+    }
+    gPad->SetTopMargin(0.02); gPad->SetLeftMargin(0.1);
+    gPad->SetGridx(0); gPad->SetGridy(0);
+    Merged_SanityCheck->GetXaxis()->SetTitleOffset(1.2);
+    Merged_SanityCheck->GetYaxis()->SetTitleOffset(1.3);
+    Merged_SanityCheck->SetMinimum(0.3); Merged_SanityCheck->SetMaximum(2.68);
+    Merged_SanityCheck->Draw();
+    
+    
+    //r3_num_Q3->Fit(QuarticFit,"IME","",0,0.1);
+    Merged_SanityCheck->Fit(QuarticFit,"IME","",0,0.1);
     gPad->Update();
-    TPaveStats *Quartic_stats=(TPaveStats*)r3_num_Q3->FindObject("stats");
-    Quartic_stats->SetX1NDC(0.2);
-    Quartic_stats->SetX2NDC(0.5);
-    Quartic_stats->SetY1NDC(.8);
-    Quartic_stats->SetY2NDC(.9);
+    //TPaveStats *Quartic_stats=(TPaveStats*)r3_num_Q3->FindObject("stats");
+    TPaveStats *Quartic_stats=(TPaveStats*)Merged_SanityCheck->FindObject("stats");
+    Quartic_stats->SetX1NDC(0.15);
+    Quartic_stats->SetX2NDC(0.52);
+    Quartic_stats->SetY1NDC(.2);
+    Quartic_stats->SetY2NDC(.3);
     
-    TH1D *r3_clone=(TH1D*)r3_num_Q3->Clone();
+    //TH1D *r3_clone=(TH1D*)r3_num_Q3->Clone();
+    TH1D *r3_clone=(TH1D*)Merged_SanityCheck->Clone();
     r3_clone->Fit(QuadraticFit,"IME","",0,0.1);
     gPad->Update();
     TPaveStats *Quadratic_stats=(TPaveStats*)r3_clone->FindObject("stats");
-    Quadratic_stats->SetX1NDC(0.55);
-    Quadratic_stats->SetX2NDC(0.85);
-    Quadratic_stats->SetY1NDC(.8);
-    Quadratic_stats->SetY2NDC(.9);
+    Quadratic_stats->SetX1NDC(0.54);
+    Quadratic_stats->SetX2NDC(0.91);
+    Quadratic_stats->SetY1NDC(.2);
+    Quadratic_stats->SetY2NDC(.3);
     
     QuarticFit->Draw("same");
     QuadraticFit->Draw("same");
     Quartic_stats->Draw("same");
     Quadratic_stats->Draw("same");
+    
+    TF1 *ChaoticLimit = new TF1("ChaoticLimit","2.0",0,1);
+    ChaoticLimit->SetLineStyle(3);
+    ChaoticLimit->Draw("same");
+    
+    TLatex *Specif_SanityCheck=new TLatex(0.2,0.35,"HIJING With Simulated QS+FSI Weights");
+    Specif_SanityCheck->SetNDC();
+    Specif_SanityCheck->SetTextFont(42);
+    Specif_SanityCheck->SetTextSize(0.04);
+    Specif_SanityCheck->Draw();
+    //TLatex *Specif_Kt3=new TLatex(0.2,0.45,"0.16<K_{t,3}<0.3 GeV/c");
+    TLatex *Specif_Kt3=new TLatex(0.2,0.45,"0.3<K_{t,3}<1.0 GeV/c");
+    Specif_Kt3->SetNDC();
+    Specif_Kt3->SetTextFont(42);
+    Specif_Kt3->SetTextSize(0.04);
+    Specif_Kt3->Draw();
+    
+    legend3->AddEntry(QuarticFit,"Quartic fit","l");
+    legend3->AddEntry(QuadraticFit,"Quadratic fit","l");
+    legend3->Draw("same");
+    //DrawALICELogo(kFALSE, .72, .4, .87, .55);
     */
     /*
     ////////// 
@@ -2792,12 +2953,14 @@ void fcnC2_Global(int& npar, double* deriv, double& f, double par[], int flag){
     //else CSS -= Dp1/(1+Dp1) * Dp2/(1+Dp2);
 
     CSS *= par[1]*K2SS[i];
+    if(MuonCorrection) CSS /= C2muonCorrection_SC->GetBinContent(i+1);
     CSS += 1-par[1];
     CSS *= par[0];
     //
     COS = 1;
     if(ChargeConstraint && GofP) COS += 1/5.* Dp1/(1+Dp1) * Dp2/(1+Dp2);
     COS *= par[1]*K2OS[i];
+    if(MuonCorrection) COS /= C2muonCorrection_MC->GetBinContent(i+1);
     COS += 1-par[1];
     COS *= par[9];// different Norm
     //
@@ -2858,6 +3021,7 @@ double C2ssFitFunction(Double_t *x, Double_t *par)
   else CSS -= pow(Gaus_coh*Dp,2)/((1+Dp1)*(1+Dp2));
   //else CSS -= Dp1/(1+Dp1) * Dp2/(1+Dp2);
   CSS *= par[1]*K2SS[qbin];
+  if(MuonCorrection) CSS /= C2muonCorrection_SC->GetBinContent(qbin+1);
   CSS += 1-par[1];
   CSS *= par[0];
 
@@ -2887,6 +3051,7 @@ double C2osFitFunction(Double_t *x, Double_t *par)
   double COS = 1;
   if(ChargeConstraint && GofP) COS += 1/5.* Dp1/(1+Dp1) * Dp2/(1+Dp2);
   COS *= par[1]*K2OS[qbin];
+  if(MuonCorrection) COS /= C2muonCorrection_MC->GetBinContent(qbin+1);
   COS += 1-par[1];
   COS *= par[9];
   return COS;
@@ -3544,3 +3709,44 @@ double tricubicInterpolate (double p[4][4][4], double x, double y, double z) {
 float fact(float n){
   return (n < 1.00001) ? 1 : fact(n - 1) * n;
 }
+void DrawALICELogo(Bool_t prel, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
+{
+  // revision on July 24th or 25th 2012
+  // correct for aspect ratio of figure plus aspect ratio of pad (coordinates are NDC!)
+  x2 = x1 + (y2 - y1) * (466. / 523) * gPad->GetWh() * gPad->GetHNDC() / (gPad->GetWNDC() * gPad->GetWw());
+  // Printf("%f %f %f %f", x1, x2, y1, y2);
+  
+  TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo", x1, y1, x2, y2);
+  myPadLogo->SetLeftMargin(0);
+  myPadLogo->SetTopMargin(0);
+  myPadLogo->SetRightMargin(0);
+  myPadLogo->SetBottomMargin(0);
+  myPadLogo->Draw();
+  myPadLogo->cd();
+  TASImage *myAliceLogo = new TASImage((prel) ? "~/Pictures/2011-Nov-24-ALICE_PRELIMARY_logo_BLACK_small_usage_design.eps" : "~/Pictures/2011-Nov-24-ALICE_PERFORMANCE_logo_BLACK_small_usage_design.eps");
+  myAliceLogo->Draw();
+}
+//________________________________________________________________________________________
+void ReadMuonCorrections(int mbin){
+  TString *name = new TString("MuonCorrection_");
+  if(mbin<=1) *name += 0;
+  else if(mbin<=3) *name += 1;
+  else if(mbin<=5) *name += 2;
+  else if(mbin<=7) *name += 3;
+  else if(mbin<=9) *name += 3;
+  else *name += 4;
+  name->Append(".root");
+  TFile *muonfile=new TFile(name->Data(),"READ");
+  C2muonCorrection_SC = (TH1D*)muonfile->Get("C2muonCorrection_SC");
+  C2muonCorrection_MC = (TH1D*)muonfile->Get("C2muonCorrection_MC");
+  WeightmuonCorrection = (TH1D*)muonfile->Get("WeightmuonCorrection");
+  if(SameCharge_def) C3muonCorrection = (TH1D*)muonfile->Get("C3muonCorrection_SC");
+  else C3muonCorrection = (TH1D*)muonfile->Get("C3muonCorrection_MC");
+  //
+  C2muonCorrection_SC->SetDirectory(0);
+  C2muonCorrection_MC->SetDirectory(0);
+  WeightmuonCorrection->SetDirectory(0);
+  C3muonCorrection->SetDirectory(0);
+  //
+  muonfile->Close();
+}
index 7b1b8e9e5b294063da52f916a524a8ba268775b7..cdd7b42c0761a60a18dec1a1196a8a96e5ecd445 100755 (executable)
@@ -31,8 +31,8 @@
 #define FmToGeV 0.19733 // conversion to fm
 #define PI 3.1415926
 #define masspiC 0.1395702 // pi+ mass (GeV/c^2)
-#define kappa3 0.16
-#define kappa4 0.40
+#define kappa3 0.16 // 0.16 (default), 0.05 or 0.3 as variations
+#define kappa4 0.4 // 0.4 (default), 
 
 using namespace std;
 
@@ -42,12 +42,14 @@ int CHARGE_def=-1;// -1 or +1: + or - pions for same-charge case, --+ or ++- for
 bool SameCharge_def=kTRUE;// 3-pion same-charge?
 bool AddCC=kTRUE;
 //
+bool MuonCorrection=1;// apply Muon correction?
 bool IncludeEW=kTRUE;// Include EdgeWorth coefficients?
 bool FixEWavg=kTRUE;
-int Mbin_def=2;// 0-19 (0=1050-2000 pions, 19=0-5 pions)
+int Mbin_def=12;// 0-19 (0=1050-2000 pions, 19=0-5 pions)
 int EDbin_def=0;// 0-2: Kt3 bin
-int Ktbin_def=2;// 1-6, 10=full range
+int Ktbin_def=10;// 1-6, 10=full range
 double MRCShift=1.0;// 1.0=full Momentum Resolution Correction. 1.1 for 10% systematic increase
+bool FitRangeShift=kFALSE;// 30% reduction in Fit Range
 //
 //
 bool SaveToFile_def=kFALSE;// Save outputs to file?
@@ -90,6 +92,7 @@ TH1D *CoulCorr2OS_2;// for interpolation in transition from Therminator to Gauss
 
 void ReadCoulCorrections(int);
 void ReadMomResFile(int);
+void ReadMuonCorrections(int,int);
 double CoulCorr2(int, double);
 double CoulCorrGRS(bool, double, double, double);
 double Dfitfunction_c3(Double_t *x, Double_t *par);
@@ -155,7 +158,9 @@ int MRC2index;// index for C2 MRC
 
 double AvgP[6][20];// kt bin, qinv bin
 
-
+TH1D *C2muonCorrection_SC;
+TH1D *C2muonCorrection_MC;
+TH1D *C3muonCorrection;
 
 TF1 *StrongSC;// same-charge pion strong FSI
 TF1 *MixedChargeSysFit;// mixed-charge 3-pion cumulant residue obtained from Plot_plotsTPR.C
@@ -174,7 +179,10 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   SameCharge_def=SameCharge;// 3-pion same-charge
   Mbin_def=Mbin;
   //
+
+  double MainFitParams[8]={0};
+  //
+  double RefMainFitParams[8]={8.82821,  8.53081,  0.372113,  0.712252,  10.3545,  10.4871,  0.693955,  1.62568};
 
   /*
   // Old way
@@ -222,7 +230,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
 
   Ktlowbin=(Ktbin)*2+3;// kt bins are 0.5 GeV/c wide (0-0.5, 0.5-1.0 ...)
   Kthighbin=(Ktbin)*2+4;
-  //if(Ktbin==2) {cout<<"Kthighbin incremented"<<endl; Kthighbin++;}// to make <KT3> comparible to <kT> 
+  if(Ktbin==2) {cout<<"Kthighbin increased"<<endl; Kthighbin = 20;}// to make <KT3> comparible to <kT> 
   
   // Pythia pol2 fits
   PythiaFit=new TF1("PythiaFit","pol1",0,1.4);
@@ -264,10 +272,9 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
     }
     BinWidthQ2 = 0.01;
   }
-  //Q3Limit = 0.2;
+  if(FitRangeShift) Q3Limit -= 0.3*Q3Limit;
   Q2Limit = Q3Limit/sqrt(2.);
-  //Q2Limit -= 0.02;// Systematic variations
-  //Q3Limit -= 0.2*Q3Limit;// Systematic variations
+  
 
   // extend BinCenters for high q
   for(int index=40; index<400; index++){
@@ -316,6 +323,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
       //_file0 = new TFile("Results/PDC_10h_noPID.root","READ");
       //_file0 = new TFile("Results/PDC_10h_1percentCentral.root","READ");
       _file0 = new TFile("Results/PDC_10h_11h_2Kt3bins.root","READ");// standard
+      //_file0 = new TFile("Results/PDC_10h_dEta0p025dPhi0p055.root","READ");
       //_file0 = new TFile("Results/PDC_11h_3Kt3bins_FB5and7overlap.root","READ");
       //_file0 = new TFile("Results/PDC_10h_11h_V0binning.root","READ");
     }
@@ -326,9 +334,17 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
       //_file0 = new TFile("Results/PDC_13bc_3Ktbins.root","READ");
       //_file0 = new TFile("Results/PDC_13bc_kAnyINT_kINT7.root","READ");
       //_file0 = new TFile("Results/PDC_13bc_2Kt3bins.root","READ");
-      _file0 = new TFile("Results/PDC_13bc_kINT7_kHighMult.root","READ");// standard
+      //_file0 = new TFile("Results/PDC_13bc_kINT7.root","READ");// paper v1
+      //_file0 = new TFile("Results/PDC_13c_posEta.root","READ");// eta sub-range
+      //_file0 = new TFile("Results/PDC_13c_negEta.root","READ");// eta sub-range
+      //_file0 = new TFile("Results/PDC_13c_0p4to0p8eta.root","READ");// eta sub-range
+      //_file0 = new TFile("Results/PDC_13c_neg0p4toneg0p8eta.root","READ");// eta sub-range
+      //_file0 = new TFile("Results/PDC_13bc_dEta0p025dPhi0p055_kINT7_kHighMult.root","READ");
       //_file0 = new TFile("Results/PDC_13bc_FB5and7overlap_V0binning.root","READ");
       //_file0 = new TFile("Results/PDC_13bc_kAnyINT_V0binning.root","READ");
+      //_file0 = new TFile("Results/PDC_13bcd_kHighMult.root","READ");
+      //_file0 = new TFile("Results/PDC_13bcd_kINT7.root","READ");
+      _file0 = new TFile("Results/PDC_13bcd_kINT7_plus_kHighMult.root","READ");// standard
     }else{
       _file0 = new TFile("Results/PDC_13b2_efix_p1234_R2_2Ktbins.root","READ");
     }
@@ -340,8 +356,9 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
       //_file0 = new TFile("Results/PDC_10e_kAnyINT.root","READ");
       //_file0 = new TFile("Results/PDC_10cde_kAnyINT.root","READ");
       //_file0 = new TFile("Results/PDC_10cde_kAnyINT_Plus_kHighMult.root","READ");
-      //_file0 = new TFile("Results/K0sRange_10cde.root","READ");
+      //_file0 = new TFile("Results/K0sRange_10cde.root","READ");// for K0s peak removal
       //_file0 = new TFile("Results/PDC_10cde_2Kt3bins.root","READ");
+      //_file0 = new TFile("Results/PDC_10e_kHighMult.root","READ");
       //_file0 = new TFile("Results/PDC_10cde_kMB.root","READ");
       _file0 = new TFile("Results/PDC_10cde_kMB_plus_kHighMult_2Kt3bins.root","READ");// standard
       //_file0 = new TFile("Results/PDC_10cde_FB5and7overlap.root","READ");
@@ -352,6 +369,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   
   ReadCoulCorrections(FSIindex);
   ReadMomResFile(Mbin);
+  ReadMuonCorrections(CollisionType,Mbin);
   //
   /////////////////////////////////////////////////////////
 
@@ -385,8 +403,11 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
       MyList=(TList*)_file0->Get("MyList");
     }
   }else {
-    if(!MCcase) MyList=(TList*)tdir->Get("ThreePionRadiiOutput_1");
-    else MyList=(TList*)_file0->Get("MyList");
+    if(!MCcase) {
+      //MyList=(TList*)_file0->Get("MyList");
+      if(CollisionType==2 && Mbin<15) MyList=(TList*)tdir->Get("ThreePionRadiiOutput_2");
+      else MyList=(TList*)tdir->Get("ThreePionRadiiOutput_1");
+    }else MyList=(TList*)_file0->Get("MyList");
   }
   _file0->Close();
   
@@ -932,7 +953,8 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
        fitC2ss_EW->SetParError(i,OutputPar_e[i]);
       }
     }
-
+    if(ft==0) {MainFitParams[0]=OutputPar[3]; MainFitParams[2]=OutputPar[1];}
+    else {MainFitParams[4]=OutputPar[3]; MainFitParams[6]=OutputPar[1];}
   }// ft
   
 
@@ -1042,8 +1064,6 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   }
   
   
-
-  
  
   cout<<"============================================"<<endl;
   cout<<"Start 3-pion section"<<endl;
@@ -1199,8 +1219,27 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
        if(TERM1==0 && TERM2==0 && TERM3==0 && TERM4==0 && TERM5==0) continue;
        if(TERM1==0 || TERM2==0 || TERM3==0 || TERM4==0 || TERM5==0) continue;
        
+       double muonCorr_C3=1.0, muonCorr_C2_12=1.0, muonCorr_C2_13=1.0, muonCorr_C2_23=1.0;
+       if(MuonCorrection){
+         if(SameCharge){
+           muonCorr_C3 = C3muonCorrection->GetBinContent(C3muonCorrection->GetXaxis()->FindBin(Q3));
+           muonCorr_C2_12 = C2muonCorrection_SC->GetBinContent(C2muonCorrection_SC->GetXaxis()->FindBin(Q12));
+           muonCorr_C2_13 = C2muonCorrection_SC->GetBinContent(C2muonCorrection_SC->GetXaxis()->FindBin(Q13));
+           muonCorr_C2_23 = C2muonCorrection_SC->GetBinContent(C2muonCorrection_SC->GetXaxis()->FindBin(Q23));
+         }else{
+           muonCorr_C3 = C3muonCorrection->GetBinContent(C3muonCorrection->GetXaxis()->FindBin(Q3));
+           if(CHARGE==-1){// pi-pi-pi+
+             muonCorr_C2_12 = C2muonCorrection_SC->GetBinContent(C2muonCorrection_SC->GetXaxis()->FindBin(Q12));
+             muonCorr_C2_13 = C2muonCorrection_MC->GetBinContent(C2muonCorrection_MC->GetXaxis()->FindBin(Q13));
+             muonCorr_C2_23 = C2muonCorrection_MC->GetBinContent(C2muonCorrection_MC->GetXaxis()->FindBin(Q23));
+           }else{// pi-pi+pi+
+             muonCorr_C2_12 = C2muonCorrection_MC->GetBinContent(C2muonCorrection_MC->GetXaxis()->FindBin(Q12));
+             muonCorr_C2_13 = C2muonCorrection_MC->GetBinContent(C2muonCorrection_MC->GetXaxis()->FindBin(Q13));
+             muonCorr_C2_23 = C2muonCorrection_SC->GetBinContent(C2muonCorrection_SC->GetXaxis()->FindBin(Q23));
+           }
+         }
+       }
 
-       
        // apply momentum resolution correction
        if(!MCcase && !GeneratedSignal){
          int MRC_Q3bin = int(Q3/0.01) + 1;
@@ -1234,14 +1273,15 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
        N3_QS -= (1-OneFrac)*(TERM2 + TERM3 + TERM4 - 3*(1-TwoFrac)*TERM5);
        N3_QS /= ThreeFrac;
        N3_QS /= K3;
-       
+       N3_QS *=  muonCorr_C3;
+
        num_QS->Fill(Q3, N3_QS);
        
        // Isolate 3-pion cumulant
        value_num = N3_QS;
-       value_num -= (TERM2 - (1-TwoFrac)*TERM5)/K2_12/TwoFrac;
-       value_num -= (TERM3 - (1-TwoFrac)*TERM5)/K2_13/TwoFrac;
-       value_num -= (TERM4 - (1-TwoFrac)*TERM5)/K2_23/TwoFrac;
+       value_num -= (TERM2 - (1-TwoFrac)*TERM5)/K2_12/TwoFrac * muonCorr_C2_12;
+       value_num -= (TERM3 - (1-TwoFrac)*TERM5)/K2_13/TwoFrac * muonCorr_C2_13;
+       value_num -= (TERM4 - (1-TwoFrac)*TERM5)/K2_23/TwoFrac * muonCorr_C2_23;
        value_num += 2*TERM5;
        
        
@@ -1446,8 +1486,8 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   legend2->AddEntry(c3_hist,"#font[12]{#bf{c}}_{3} (cumulant correlation)","p");
   c3_hist->Draw();
   
-  //for(int i=1; i<=15; i++) cout<<c3_hist->GetBinContent(i)<<", ";
-  //cout<<endl;
+  for(int i=1; i<=15; i++) cout<<c3_hist->GetBinContent(i)<<", ";
+  cout<<endl;
   //for(int i=1; i<=15; i++) cout<<c3_hist->GetBinError(i)<<", ";
   //cout<<endl;
 
@@ -1466,8 +1506,8 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   arglist_c3 = 5000;
   MyMinuit_c3.mnexcm("MIGRAD", &arglist_c3 ,1,ierflg_c3);
   
-  TF1 *c3Fit1D_Gauss=new TF1("c3Fit1D_Gauss","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.))",0,1);;
-  TF1 *c3Fit1D_EW=new TF1("c3Fit1D_EW","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.) * pow(1 + ([3]/(6.*pow(2,1.5))*(8.*pow([2]*x/sqrt(3.)/0.19733,3) - 12.*pow([2]*x/sqrt(3.)/0.19733,1))) + ([4]/(24.*pow(2,2))*(16.*pow([2]*x/sqrt(3.)/0.19733,4) -48.*pow([2]*x/sqrt(3.)/0.19733,2) + 12)),3))",0,1);;
+  TF1 *c3Fit1D_Gauss=new TF1("c3Fit1D_Gauss","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.))",0,1);
+  TF1 *c3Fit1D_EW=new TF1("c3Fit1D_EW","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.) * pow(1 + ([3]/(6.*pow(2,1.5))*(8.*pow([2]*x/sqrt(3.)/0.19733,3) - 12.*pow([2]*x/sqrt(3.)/0.19733,1))) + ([4]/(24.*pow(2,2))*(16.*pow([2]*x/sqrt(3.)/0.19733,4) -48.*pow([2]*x/sqrt(3.)/0.19733,2) + 12)),3))",0,1);
 
   double OutputPar_c3[npar_c3]={0};
   double OutputPar_c3_e[npar_c3]={0};
@@ -1485,7 +1525,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
       minVal_c3[0] = 0.95; minVal_c3[1] = 0.2; minVal_c3[2] = 0.5; minVal_c3[3] = -1; minVal_c3[4] = -1;
       maxVal_c3[0] = 1.1; maxVal_c3[1] = 2.5; maxVal_c3[2] = 15.; maxVal_c3[3] = +1; maxVal_c3[4] = +1;
       parName_c3[0] = "N"; parName_c3[1] = "#lambda_{3}"; parName_c3[2] = "R_{inv}"; parName_c3[3] = "#kappa_{3}"; parName_c3[4] = "#kappa_{4}";
-      
+      c3Fit1D_Gauss->SetParName(0,"N"); c3Fit1D_Gauss->SetParName(1,"#lambda_{3}"); c3Fit1D_Gauss->SetParName(2,"R_{inv}");
       
       for (int i=0; i<npar_c3; i++){
        MyMinuit_c3.DefineParameter(i, parName_c3[i].c_str(), par_c3[i], stepSize_c3[i], minVal_c3[i], maxVal_c3[i]);
@@ -1526,21 +1566,35 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
        c3Fit1D_Gauss->SetParameter(0,OutputPar_c3[0]); c3Fit1D_Gauss->SetParError(0,OutputPar_c3_e[0]);
        c3Fit1D_Gauss->SetParameter(1,OutputPar_c3[1]); c3Fit1D_Gauss->SetParError(1,OutputPar_c3_e[1]);
        c3Fit1D_Gauss->SetParameter(2,OutputPar_c3[2]); c3Fit1D_Gauss->SetParError(2,OutputPar_c3_e[2]);
-       c3Fit1D_Gauss->Draw("same");
+       c3Fit1D_Gauss->SetLineStyle(2);
+       //c3Fit1D_Gauss->Draw("same");
       }else{
        c3Fit1D_EW->SetParameter(0,OutputPar_c3[0]); c3Fit1D_EW->SetParError(0,OutputPar_c3_e[0]);
        c3Fit1D_EW->SetParameter(1,OutputPar_c3[1]); c3Fit1D_EW->SetParError(1,OutputPar_c3_e[1]);
        c3Fit1D_EW->SetParameter(2,OutputPar_c3[2]); c3Fit1D_EW->SetParError(2,OutputPar_c3_e[2]);
        c3Fit1D_EW->SetParameter(3,OutputPar_c3[3]); c3Fit1D_EW->SetParError(3,OutputPar_c3_e[3]);
        c3Fit1D_EW->SetParameter(4,OutputPar_c3[4]); c3Fit1D_EW->SetParError(4,OutputPar_c3_e[4]);
-       c3Fit1D_EW->SetLineStyle(2);
+       c3Fit1D_EW->SetLineStyle(1);
        c3Fit1D_EW->Draw("same");
       }
-      
+      if(ft==0) {MainFitParams[1]=OutputPar_c3[2]; MainFitParams[3]=OutputPar_c3[1];}
+      else {MainFitParams[5]=OutputPar_c3[2]; MainFitParams[7]=OutputPar_c3[1];}
     }// fit type
   }// SC and !MC
-
-    /*
+  // uncomment to display fit box
+  //c3_hist->GetListOfFunctions()->Add(c3Fit1D_Gauss);
+  
+  // Fit Range Systematics
+  //for(int i=0; i<8; i++){cout<<MainFitParams[i]<<",  ";}
+  //cout<<endl;
+  //for(int i=0; i<4; i++){cout<<int(100*(MainFitParams[i]-RefMainFitParams[i])/MainFitParams[i])<<"$\\%$ & ";}// Gaussian
+  //cout<<endl;
+  //for(int i=4; i<8; i++){cout<<int(100*(MainFitParams[i]-RefMainFitParams[i])/MainFitParams[i])<<"$\\%$ & ";}// Edgeworth
+  //cout<<endl;
+  
+  /*
     TF3 *fitcopy_c3 = new TF3("fitcopy_c3",Dfitfunction_c3, 0,0.4, 0,0.4, 0,0.4, npar_c3);
     for(int i=0; i<npar_c3; i++) {fitcopy_c3->FixParameter(i,OutputPar_c3[i]);}
     for(int i=0; i<BINLIMIT_3; i++){
@@ -1573,17 +1627,20 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
     dentimesFit_c3->SetLineWidth(2);
     //dentimesFit_c3->DrawCopy("C same");// for visualization of fit but with less well defined bin centers
     */
-
-  /*TLatex *fitBox1=new TLatex(0.5,0.7,"#lambda_{3}=0.92 #pm 0.07");
+  /*TString *lamName=new TString("#lambda_{3}=");
+  TString *RName=new TString("#R_{inv,3}=");
+  *lamName += int(100*c3Fit1D_Gauss->GetParameter(1))/100.; lamName->Append(" #pm "); *lamName += int(100*c3Fit1D_Gauss->GetParError(1))/100.;
+  *RName += round(100*c3Fit1D_Gauss->GetParameter(2))/100; RName->Append(" #pm "); *RName += int(100*c3Fit1D_Gauss->GetParError(2))/100.; RName->Append(" fm");
+  TLatex *fitBox1=new TLatex(0.5,0.9,lamName->Data());
   fitBox1->SetNDC(kTRUE);
   fitBox1->Draw();
-  TLatex *fitBox2=new TLatex(0.5,0.6,"R_{inv,3}=3.8 #pm 0.1 fm");
+  TLatex *fitBox2=new TLatex(0.5,0.8,RName->Data());
   fitBox2->SetNDC(kTRUE);
-  fitBox2->Draw();
-  TLatex *fitBox3=new TLatex(0.5,0.5,"<N_{rec,pions}>=103");
-  fitBox3->SetNDC(kTRUE);
-  fitBox3->Draw();
-  */
+  fitBox2->Draw();*/
+  //TLatex *fitBox3=new TLatex(0.5,0.5,"<N_{rec,pions}>=103");
+  //fitBox3->SetNDC(kTRUE);
+  //fitBox3->Draw();
+  
     //TPaveStats *c3Stats=(TPaveStats*)c3Fit1D_Gauss->FindObject("stats");
     //c3Stats->SetX1NDC(0.15);
     //c3Stats->SetX2NDC(0.52);
@@ -1592,7 +1649,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
     //c3Stats->Draw("same");
     
 
-    // The below fit has less well defined bin centers
+    // The below 1D fit method has less well defined bin centers
     //TF1 *c3Fit1D=new TF1("c3Fit1D","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.))",0,1);
     //TF1 *c3Fit1D=new TF1("c3Fit1D","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.) * (1 + (-0.12/(6.*pow(2,1.5))*(8.*pow([2]*x/0.19733,3) - 12.*pow([2]*x/0.19733,1))) + (0.43/(24.*pow(2,2))*(16.*pow([2]*x/0.19733,4) -48.*pow([2]*x/0.19733,2) + 12))))",0,1);
     //TF1 *c3Fit1D=new TF1("c3Fit1D","[0]*(1+[1]*exp(-pow([2]*x/0.19733,2)/2.) * (1 + ([3]/(6.*pow(2,1.5))*(8.*pow([2]*x/0.19733,3) - 12.*pow([2]*x/0.19733,1))) + ([4]/(24.*pow(2,2))*(16.*pow([2]*x/0.19733,4) -48.*pow([2]*x/0.19733,2) + 12))))",0,1);
@@ -1652,7 +1709,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   Cterm1->Draw("same");
   legend2->Draw("same");
   
-  /*if(SameCharge==kTRUE){
+  /*if(SameCharge==kTRUE && MCcase==kFALSE){
     TString *savename=new TString("C3c3_SC_");
     if(CollisionType==0) savename->Append("PbPb_K");
     if(CollisionType==1) savename->Append("pPb_K");
@@ -1746,7 +1803,30 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   K0sProjection->GetXaxis()->SetTitleOffset(1.2); K0sProjection->GetYaxis()->SetTitleOffset(1.3);
   
   K0sProjection->Draw();
+  // Sys errors
+  TH1D *Sys_K0sProjection=(TH1D*)K0sProjection->Clone();
+  TH1D *Sys_K0sProjection_term1=(TH1D*)K0sProjection_term1->Clone();
+  Sys_K0sProjection->SetMarkerSize(0); Sys_K0sProjection_term1->SetMarkerSize(0);
+  Sys_K0sProjection->SetFillColor(kBlue-10); Sys_K0sProjection_term1->SetFillColor(kBlue-10);
+  Sys_K0sProjection->SetFillStyle(1000); Sys_K0sProjection_term1->SetFillStyle(1000);
+  for(int i=0; i<Sys_K0sProjection->GetNbinsX(); i++) { 
+    Sys_K0sProjection->SetBinError(i+1, 0.01 * Sys_K0sProjection->GetBinContent(i+1));
+    Sys_K0sProjection_term1->SetBinError(i+1, 0.01 * Sys_K0sProjection_term1->GetBinContent(i+1));
+  }
+  for(int i=0; i<Sys_K0sProjection->GetNbinsX(); i++) cout<<K0sProjection->GetBinContent(i+1)<<", ";
+  cout<<endl;
+  for(int i=0; i<Sys_K0sProjection->GetNbinsX(); i++) cout<<K0sProjection->GetBinError(i+1)<<", ";
+  cout<<endl;
+  for(int i=0; i<Sys_K0sProjection->GetNbinsX(); i++) cout<<K0sProjection_term1->GetBinContent(i+1)<<", ";
+  cout<<endl;
+  for(int i=0; i<Sys_K0sProjection->GetNbinsX(); i++) cout<<K0sProjection_term1->GetBinError(i+1)<<", ";
+  cout<<endl;
+
+  Sys_K0sProjection->Draw("E2 same");
+  Sys_K0sProjection_term1->Draw("E2 same");
+  K0sProjection->Draw("same");
   K0sProjection_term1->Draw("same");
+
   legend4->AddEntry(K0sProjection,"#font[12]{C_{3}^{#pm#pm#mp}} projection","p");
   legend4->AddEntry(K0sProjection_term1,"#font[12]{#bf{c}_{3}^{#pm#pm#mp}} projection","p");
   legend4->Draw("same");
@@ -1756,7 +1836,7 @@ void Plot_PDCumulants_TPR(bool SaveToFile=SaveToFile_def, int CollisionType=Coll
   Specif_qRange->SetTextFont(42);
   Specif_qRange->SetTextSize(0.04);
   Specif_qRange->Draw("same");
-  TLatex *Specif_System = new TLatex(0.3,0.7,"N_{ch} = 8.8 #pm 0.4, pp #sqrt{#font[12]{s}}=7 TeV");
+  TLatex *Specif_System = new TLatex(0.3,0.7,"N_{ch} = 9.0 #pm 0.5, pp #sqrt{#font[12]{s}}=7 TeV");
   Specif_System->SetNDC();
   Specif_System->SetTextFont(42);
   Specif_System->SetTextSize(0.04);
@@ -2549,6 +2629,30 @@ double tricubicInterpolate (double p[4][4][4], double x, double y, double z) {
        return cubicInterpolate(arr, x);
 }
 //____________________________________________________________________________________________________
+void ReadMuonCorrections(int ct, int mbin){
+  TString *name = new TString("MuonCorrection_");
+  if(ct==0){// PbPb
+    if(mbin<=1) *name += 0;
+    else if(mbin<=3) *name += 1;
+    else if(mbin<=5) *name += 2;
+    else if(mbin<=7) *name += 3;
+    else if(mbin<10) *name += 4;
+    else *name += 5;
+  }else *name += 6;
+  name->Append(".root");
+  TFile *muonfile=new TFile(name->Data(),"READ");
+  C2muonCorrection_SC = (TH1D*)muonfile->Get("C2muonCorrection_SC");
+  C2muonCorrection_MC = (TH1D*)muonfile->Get("C2muonCorrection_MC");
+  if(SameCharge_def) C3muonCorrection = (TH1D*)muonfile->Get("C3muonCorrection_SC");
+  else C3muonCorrection = (TH1D*)muonfile->Get("C3muonCorrection_MC");
+  //
+  C2muonCorrection_SC->SetDirectory(0);
+  C2muonCorrection_MC->SetDirectory(0);
+  C3muonCorrection->SetDirectory(0);
+  //
+  muonfile->Close();
+}
+//____________________________________________________________________________________________________
 void DrawALICELogo(Bool_t prel, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
 {
   // revision on July 24th or 25th 2012
diff --git a/PWGCF/FEMTOSCOPY/macros/Plot_muons.C b/PWGCF/FEMTOSCOPY/macros/Plot_muons.C
new file mode 100755 (executable)
index 0000000..12322be
--- /dev/null
@@ -0,0 +1,276 @@
+#include <math.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <Riostream.h>
+#include <assert.h>
+
+#include "TVector2.h"
+#include "TFile.h"
+#include "TString.h"
+#include "TF1.h"
+#include "TF3.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+#include "TProfile.h"
+#include "TProfile2D.h"
+#include "TMath.h"
+#include "TText.h"
+#include "TRandom3.h"
+#include "TArray.h"
+#include "TLegend.h"
+#include "TStyle.h"
+#include "TMinuit.h"
+#include "TCanvas.h"
+#include "TLatex.h"
+#include "TPaveStats.h"
+#include "TASImage.h"
+
+#define BohrR 1963.6885 // Bohr Radius for pions
+#define FmToGeV 0.19733 // conversion to fm
+#define PI 3.1415926
+#define masspiC 0.1395702 // pi+ mass (GeV/c^2)
+#define kappa3 0.16
+#define kappa4 0.40
+
+using namespace std;
+
+
+void Plot_muons(){
+  
+  gStyle->SetOptStat(0);
+  gStyle->SetOptDate(0);
+  gStyle->SetOptFit(0111);
+  
+  int ChComb=1;// 0=Same-charge, 1=Mixed-charge
+  int kTbin_L=5, kTbin_H=6;
+  int binKT3=1;//1-2
+
+  //TFile *_file0= new TFile("Results/PDC_12a17a_muons_R6.root","READ");
+  //TFile *_file0= new TFile("Results/PDC_13b2_efix_p1_muons_R2.root","READ");
+  TFile *_file0= new TFile("Results/PDC_12a17e_muons_R4.root","READ");
+  
+  TList *MyList=(TList*)_file0->Get("MyList");
+  _file0->Close();
+
+  TH1D *PionCandidates=(TH1D*)MyList->FindObject("fPionCandidates");
+  PionCandidates->GetXaxis()->SetTitle("PDG code");
+  //PionCandidates->Draw();
+  //
+  TH1D *MuonParentsPrimary=(TH1D*)MyList->FindObject("fMuonParents");
+  MuonParentsPrimary->GetXaxis()->SetTitle("PDG code");
+  MuonParentsPrimary->SetFillColor(1);
+  //MuonParentsPrimary->Draw();
+  //
+  TH1D *MuonParentsSecondary=(TH1D*)MyList->FindObject("fSecondaryMuonParents");
+  MuonParentsSecondary->GetXaxis()->SetTitle("PDG code");
+  MuonParentsSecondary->SetFillColor(1);
+  //MuonParentsSecondary->Draw();
+  //
+  // M0 R10-R6, M6 for R4, M17 for R2
+  TH3D *PurityNum_3D = (TH3D*)MyList->FindObject("Explicit2_Charge1_1_Charge2_1_SC_0_M_6_ED_0_Term_1_PIDpurityNum");
+  TH2D *PurityDen_2D = (TH2D*)MyList->FindObject("Explicit2_Charge1_1_Charge2_1_SC_0_M_6_ED_0_Term_1_PIDpurityDen");
+  TH1D *PurityNum=PurityNum_3D->ProjectionX("PurityNum",kTbin_L,kTbin_H,1,20);
+  double PurityNorm=PurityDen_2D->Integral(kTbin_L,kTbin_H,1,20);
+  PurityNum->Scale(1/PurityNorm);
+  char *namesAxis[15]={"e-e","e-mu","e-pi","e-k","e-p","mu-mu","mu-pi","mu-k","mu-p","pi-pi","pi-k","pi-p","k-k","k-p","p-p"};
+  for(int i=1; i<=15; i++) PurityNum->GetXaxis()->SetBinLabel(i, namesAxis[i-1]);
+  PurityNum->GetXaxis()->SetRange(1,15);
+  PurityNum->GetYaxis()->SetTitle("Probability");
+  PurityNum->Draw();
+  //
+  //
+  TCanvas *can = new TCanvas("can", "can",800,0,800,800);// 11,53,700,500
+  can->SetHighLightColor(2);
+  gStyle->SetOptFit(0111);
+  can->SetFillColor(10);//10
+  can->SetBorderMode(0);
+  can->SetBorderSize(2);
+  can->SetFrameFillColor(0);
+  can->SetFrameBorderMode(0);
+  can->SetFrameBorderMode(0);
+  can->cd();
+  TPad *pad = new TPad("pad","pad",0.,0.,1.,1.);
+  gPad->SetTickx();
+  gPad->SetTicky();
+  pad->SetGridx();
+  pad->SetGridy();
+  pad->SetTopMargin(0.02);//0.05
+  pad->SetRightMargin(0.02);//3e-2
+  pad->SetBottomMargin(0.1);//0.12
+  pad->SetLeftMargin(0.1);
+  pad->Draw();
+  pad->cd();
+  TLegend *legend = new TLegend(.5,.65, .9,.95,NULL,"brNDC");//.45 or .4 for x1
+  legend->SetBorderSize(0);
+  legend->SetFillColor(0);
+  legend->SetTextFont(42);
+  legend->SetTextSize(0.03);
+  //
+  TH3D *MuonSmearedNum2_3=(TH3D*)MyList->FindObject("fMuonContamSmearedNum2");
+  TH3D *MuonSmearedDen2_3=(TH3D*)MyList->FindObject("fMuonContamSmearedDen2");
+  TH3D *PionNum2_3=(TH3D*)MyList->FindObject("fMuonContamIdealNum2");
+  TH3D *PionDen2_3=(TH3D*)MyList->FindObject("fMuonContamIdealDen2");
+  TH3D *PionPionK2_3=(TH3D*)MyList->FindObject("fPionPionK2");
+  //
+  TH3D *MuonSmearedNum3_3=(TH3D*)MyList->FindObject("fMuonContamSmearedNum3");
+  TH3D *MuonSmearedDen3_3=(TH3D*)MyList->FindObject("fMuonContamSmearedDen3");
+  TH3D *PionNum3_3=(TH3D*)MyList->FindObject("fMuonContamIdealNum3");
+  TH3D *PionDen3_3=(TH3D*)MyList->FindObject("fMuonContamIdealDen3");
+  TH3D *PionPionK3_3=(TH3D*)MyList->FindObject("fPionPionK3");
+  TH3D *MuonPionK3_3=(TH3D*)MyList->FindObject("fMuonPionK3");
+  
+  
+  TH1D *MuonSmearedNum2[2];// SC/MC  
+  TH1D *MuonSmearedDen2[2];
+  TH1D *PionNum2[2];
+  TH1D *PionDen2[2];
+  TH1D *PionPionK2[2];
+  //
+  TH1D *MuonSmearedNum3[2];// SC/MC  
+  TH1D *MuonSmearedDen3[2];
+  TH1D *PionNum3[2];
+  TH1D *PionDen3[2];
+  TH1D *PionPionK3[2];
+  //
+  TH1D *C2muonSmeared[2];
+  TH1D *C2pion[2];
+  TH1D *C3muonSmeared[2];
+  TH1D *C3pion[2];
+  //
+  for(int chtype=0; chtype<2; chtype++){
+    TString *names[10];
+    for(int i=0; i<10; i++) {names[i]=new TString("name_"); *names[i] += i; *names[i] += chtype;}
+
+    MuonSmearedNum2[chtype]=(TH1D*)MuonSmearedNum2_3->ProjectionZ(names[0]->Data(),chtype+1,chtype+1,kTbin_L,kTbin_H);
+    MuonSmearedDen2[chtype]=(TH1D*)MuonSmearedDen2_3->ProjectionZ(names[1]->Data(),chtype+1,chtype+1,kTbin_L,kTbin_H);
+    PionNum2[chtype]=(TH1D*)PionNum2_3->ProjectionZ(names[2]->Data(),chtype+1,chtype+1,kTbin_L,kTbin_H);
+    PionDen2[chtype]=(TH1D*)PionDen2_3->ProjectionZ(names[3]->Data(),chtype+1,chtype+1,kTbin_L,kTbin_H);
+    PionPionK2[chtype]=(TH1D*)PionPionK2_3->ProjectionZ(names[4]->Data(),chtype+1,chtype+1,kTbin_L,kTbin_H);
+    PionPionK2[chtype]->Divide(PionDen2[chtype]);
+    ////////////////
+    MuonSmearedNum3[chtype]=(TH1D*)MuonSmearedNum3_3->ProjectionZ(names[5]->Data(),chtype+1,chtype+1,binKT3,binKT3);
+    MuonSmearedDen3[chtype]=(TH1D*)MuonSmearedDen3_3->ProjectionZ(names[6]->Data(),chtype+1,chtype+1,binKT3,binKT3);
+    PionNum3[chtype]=(TH1D*)PionNum3_3->ProjectionZ(names[7]->Data(),chtype+1,chtype+1,binKT3,binKT3);
+    PionDen3[chtype]=(TH1D*)PionDen3_3->ProjectionZ(names[8]->Data(),chtype+1,chtype+1,binKT3,binKT3);
+    PionPionK3[chtype]=(TH1D*)PionPionK3_3->ProjectionZ(names[9]->Data(),chtype+1,chtype+1,binKT3,binKT3);
+    PionPionK3[chtype]->Divide(PionDen3[chtype]);
+    //
+    C2muonSmeared[chtype]=(TH1D*)MuonSmearedNum2[chtype]->Clone();
+    C2pion[chtype]=(TH1D*)PionNum2[chtype]->Clone();
+    C2muonSmeared[chtype]->Divide(MuonSmearedDen2[chtype]);
+    C2pion[chtype]->Divide(PionDen2[chtype]);
+    //
+    C3muonSmeared[chtype]=(TH1D*)MuonSmearedNum3[chtype]->Clone();
+    C3pion[chtype]=(TH1D*)PionNum3[chtype]->Clone();
+    C3muonSmeared[chtype]->Divide(MuonSmearedDen3[chtype]);
+    C3pion[chtype]->Divide(PionDen3[chtype]);
+    //
+    //
+    C2pion[chtype]->SetLineColor(4);
+    C2muonSmeared[chtype]->SetLineColor(2);
+    C2pion[chtype]->GetXaxis()->SetRangeUser(0,0.15);
+    C2pion[chtype]->SetMinimum(0.98); C2pion[chtype]->SetMaximum(1.35);
+    C2pion[chtype]->GetYaxis()->SetTitleOffset(1.5);
+    C2pion[chtype]->GetXaxis()->SetTitle("q_{inv} (GeV/c)");
+    C2pion[chtype]->GetYaxis()->SetTitle("C_{2}K_{2}");
+    //
+    C3pion[chtype]->SetLineColor(4);
+    C3muonSmeared[chtype]->SetLineColor(2);
+    C3pion[chtype]->GetXaxis()->SetRangeUser(0,0.15);
+    C3pion[chtype]->SetMinimum(0.90); C3pion[chtype]->SetMaximum(2.0);
+    C3pion[chtype]->GetYaxis()->SetTitleOffset(1.5);
+    C3pion[chtype]->GetXaxis()->SetTitle("Q_{3} (GeV/c)");
+    C3pion[chtype]->GetYaxis()->SetTitle("C_{3}K_{3}");
+  }
+  //
+  //
+  
+  C2pion[ChComb]->Draw();
+  C2muonSmeared[ChComb]->Draw("same");
+  legend->AddEntry(C2pion[ChComb],"Input Pion-Pion, C_{2}^{#pi-#pi,QS}K_{2}^{#pi-#pi,QS}","l");
+  legend->AddEntry(C2muonSmeared[ChComb],"Pion-Muon residual, C_{2}^{#mu-#pi,QS}K_{2}^{#mu-#pi,QS}","l");
+  legend->Draw("same");
+  //PionPionK2->Draw("same");
+  //
+  //
+  
+  //
+  //C3pion[ChComb]->Draw();
+  //C3muonSmeared[ChComb]->Draw("same");
+  //PionPionK3[0]->Draw("same");
+  //legend->AddEntry(C3pion[ChComb],"Input Pion-Pion-Pion, C_{3}^{#pi-#pi-#pi,QS}K_{3}^{#pi-#pi-#pi,QS}","l");
+  //legend->AddEntry(C3muonSmeared[ChComb],"Muon-Pion-Pion residual, C_{3}^{#mu-#pi-#pi,QS}K_{3}^{#mu-#pi-#pi,QS}","l");
+  //legend->Draw("same");
+    
+  
+  // corrections
+  TFile *fout=new TFile("MuonCorrection_temp.root","RECREATE");
+  TH1D *C2muonCorrection[2]; 
+  C2muonCorrection[0] = new TH1D("C2muonCorrection_SC","",100,0,0.5);
+  C2muonCorrection[1] = new TH1D("C2muonCorrection_MC","",100,0,0.5);
+  TH1D *WeightmuonCorrection = new TH1D("WeightmuonCorrection","",100,0,0.5);
+  TH1D *C3muonCorrection[2]; 
+  C3muonCorrection[0] = new TH1D("C3muonCorrection_SC","",50,0,0.5);
+  C3muonCorrection[1] = new TH1D("C3muonCorrection_MC","",50,0,0.5);
+  //
+  C2muonCorrection[0]->GetXaxis()->SetTitle("q_{inv} (GeV/c)"); C2muonCorrection[0]->GetYaxis()->SetTitle("x_{2}"); 
+  C2muonCorrection[1]->GetXaxis()->SetTitle("q_{inv} (GeV/c)"); C2muonCorrection[1]->GetYaxis()->SetTitle("x_{2}"); 
+  C3muonCorrection[0]->GetXaxis()->SetTitle("Q_{3} (GeV/c)"); C3muonCorrection[0]->GetYaxis()->SetTitle("x_{3}"); 
+  C3muonCorrection[1]->GetXaxis()->SetTitle("Q_{3} (GeV/c)"); C3muonCorrection[1]->GetYaxis()->SetTitle("x_{3}"); 
+  WeightmuonCorrection->GetXaxis()->SetTitle("q_{inv} (GeV/c)"); WeightmuonCorrection->GetYaxis()->SetTitle("x_{2}^{w}"); 
+  
+  // 0.944 and 0.959
+  float GoodPairFraction=1-0.93*(1-PurityNum->GetBinContent(10));
+  cout<<"Pion Pair Purity = "<<PurityNum->GetBinContent(10)<<endl;
+  cout<<"Effective Pion Pair Purity = "<<GoodPairFraction<<endl;
+  float pionPurity=pow(GoodPairFraction,0.5);
+  float muonPurity=1-pionPurity;
+  for(int chtype=0; chtype<2; chtype++){
+    for(int bin=1; bin<=100; bin++){
+      
+      bool emptybin2=kFALSE, emptybin3=kFALSE;
+      if(PionPionK2[chtype]->GetBinContent(bin)==0) {PionPionK2[chtype]->SetBinContent(bin, 1.00001);}
+      if(PionPionK3[chtype]->GetBinContent(bin)==0) {PionPionK3[chtype]->SetBinContent(bin, 1.00001);}
+      if(bin > C2pion[chtype]->GetNbinsX()) emptybin2=kTRUE;
+      if(bin > C3pion[chtype]->GetNbinsX()) emptybin3=kTRUE;
+      double value = C2pion[chtype]->GetBinContent(bin)/PionPionK2[chtype]->GetBinContent(bin);
+      double den = (GoodPairFraction*C2pion[chtype]->GetBinContent(bin) + (1-GoodPairFraction)*C2muonSmeared[chtype]->GetBinContent(bin))/PionPionK2[chtype]->GetBinContent(bin);
+      if(den > 0 && !emptybin2) C2muonCorrection[chtype]->SetBinContent(bin,value/den);
+      else C2muonCorrection[chtype]->SetBinContent(bin, 1);
+      //
+      if(chtype==0){
+       value = C2pion[chtype]->GetBinContent(bin)/PionPionK2[chtype]->GetBinContent(bin) - 1.0;
+       den = ((GoodPairFraction*C2pion[chtype]->GetBinContent(bin) + (1-GoodPairFraction)*C2muonSmeared[chtype]->GetBinContent(bin))/PionPionK2[chtype]->GetBinContent(bin)) - 1.0;
+       if(den > 0 && !emptybin2) WeightmuonCorrection->SetBinContent(bin,value/den);
+      }
+      //
+      value = C3pion[chtype]->GetBinContent(bin)/PionPionK3[chtype]->GetBinContent(bin);
+      den = (pow(pionPurity,3)*C3pion[chtype]->GetBinContent(bin) + (3*pow(pionPurity,2)*muonPurity)*C3muonSmeared[chtype]->GetBinContent(bin))/PionPionK3[chtype]->GetBinContent(bin);
+      if(den > 0 && !emptybin3) C3muonCorrection[chtype]->SetBinContent(bin,value/den);
+      else C3muonCorrection[chtype]->SetBinContent(bin, 1);
+    }
+    //C2muonCorrection[chtype]->SetBinContent(1, C2muonCorrection[chtype]->GetBinContent(2));
+    //C3muonCorrection[chtype]->SetBinContent(1, C3muonCorrection[chtype]->GetBinContent(2));
+    C2muonCorrection[chtype]->Write();
+    C3muonCorrection[chtype]->Write();
+    if(chtype==0) {
+      //WeightmuonCorrection->SetBinContent(1, WeightmuonCorrection->GetBinContent(2));
+      WeightmuonCorrection->Write();
+    }
+  }
+  
+  //
+  //C3muonCorrection[0]->SetMinimum(0.99); 
+  //C3muonCorrection[0]->SetMaximum(1.05); 
+  //C3muonCorrection[0]->GetYaxis()->SetTitleOffset(1.3);
+  //C3muonCorrection[0]->Draw();
+  //WeightmuonCorrection->GetYaxis()->SetTitleOffset(1.3);
+  //WeightmuonCorrection->Draw();
+  fout->Close();
+  
+  
+}
index 965e2c0a94b2cebb4a181666c72246311f93b850..3455605d09231dfb55e39e9e83183bbaa4cfa4fa 100644 (file)
@@ -31,14 +31,13 @@ using namespace std;
 bool TherminatorC2=kFALSE;
 const int BOI_1=0;// centrality bin (0-9)
 const int BOI_2=9;// centrality of second bin for C2 fit parameter plot only
-const int ParN=1;// Which C2 fit parameter to plot? 1=lambda, 2=G, 3=Rch, 4=Rcoh,
 const int ChProdBOI=0;// 0=SameCharge, 1=MixedCharge
 const int KT3Bin=0;// Kt3 bin. 0=low Kt3 bin.  1=high Kt3 bin
 //
 const int CoulChoice=0;// 0 for GRS (default), 1 for Omega0
 
 double MIN[10]={0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97, 0.97};// C2 y-axis min
-double MAX[10]={1.39, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.52};// C2 y-axis max
+double MAX[10]={1.39, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.38, 1.53};// C2 y-axis max
 //
 const int KTBINS = 6;
 int KTINDEX;
@@ -46,14 +45,14 @@ bool ChargeConstraint=kFALSE;
 bool LinkRadii=kFALSE;
 //
 int TextFont=42;// 63, or 42
-float SizeLabel=0.08;// 20(63 font), 0.08(42 font)
-float SizeLegend=0.08;// 
-float SizeTitle=0.08;// 
+float SizeLabel=0.1;// 20(63 font), 0.08(42 font)
+float SizeLegend=0.1;// .08
+float SizeTitle=0.12;// 
 float SizeSpecif=0.075;// 
 float SF1=2/3.*0.95;
 float SF2=1/2.*0.95;
 
-double RightMargin=0.002;// 0.002
+double RightMargin=0.004;// 0.002
 //
 double Chi2_C2global;
 double NFitPoints_C2global;
@@ -234,12 +233,12 @@ void Plot_plots(){
                c3[ChComb][Coul][KT3][cb]->SetBinError(bin, valuec3_e);
                if(Coul==0) {c3[ChComb][Coul][KT3][cb]->SetMarkerStyle(20); c3[ChComb][Coul][KT3][cb]->SetMarkerColor(4); c3[ChComb][Coul][KT3][cb]->SetLineColor(4);}
                else {c3[ChComb][Coul][KT3][cb]->SetMarkerStyle(22); c3[ChComb][Coul][KT3][cb]->SetMarkerColor(2); c3[ChComb][Coul][KT3][cb]->SetLineColor(2);}
-               c3[ChComb][Coul][KT3][cb]->GetYaxis()->SetTitleOffset(1.4);
+               c3[ChComb][Coul][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
                if(ChComb==1){
                  c3[ChComb][Coul][KT3][cb]->SetMinimum(0.96);// 0.99
                  c3[ChComb][Coul][KT3][cb]->SetMaximum(1.02);// 1.02
                  c3[ChComb][Coul][KT3][cb]->GetXaxis()->SetRangeUser(0,0.13);
-                 c3[ChComb][Coul][KT3][cb]->GetYaxis()->SetTitleOffset(1.1);
+                 c3[ChComb][Coul][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
                  c3[ChComb][Coul][KT3][cb]->GetYaxis()->SetTitleSize(.05);
                }
                
@@ -442,7 +441,7 @@ void Plot_plots(){
   canK3->SetHighLightColor(2);
   //canK3->Range(-0.7838115,-1.033258,0.7838115,1.033258);
   gStyle->SetOptFit(0111);
-  canK3->SetFillColor(10);//10
+  canK3->SetFillColor(0);//10
   canK3->SetBorderMode(0);
   canK3->SetBorderSize(2);
   canK3->SetFrameFillColor(0);
@@ -460,8 +459,8 @@ void Plot_plots(){
   padK3->Divide(1,2,0,0);
   padK3->Draw();
   padK3->cd(1);
-  gPad->SetLeftMargin(0.12);
-  gPad->SetRightMargin(0.02);
+  gPad->SetLeftMargin(0.14);
+  gPad->SetRightMargin(0.03);
   //double Dim1=gPad->GetAbsHNDC();
   //cout<<gPad->GetAbsHNDC()<<endl;
   //cout<<gPad->GetAspectRatio()<<endl;
@@ -487,9 +486,10 @@ void Plot_plots(){
   K3[0][1][KT3Bin][BOI_1]->GetXaxis()->SetNdivisions(808); K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetNdivisions(909);
   TGaxis::SetMaxDigits(3); 
   K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitleFont(TextFont);
-  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitleSize(SizeLabel*SF1);
-  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitle("K_{3}");
-  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitleOffset(1.1);
+  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitleSize(SizeTitle*SF1);
+  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitle("#font[12]{K_{3}}");
+  K3[0][1][KT3Bin][BOI_1]->GetYaxis()->SetTitleOffset(0.8);
+
   //
   K3[0][1][KT3Bin][BOI_1]->Draw();
   K3[0][0][KT3Bin][BOI_1]->Draw("same");
@@ -501,20 +501,21 @@ void Plot_plots(){
   legendK3->AddEntry(K3[1][1][KT3Bin][BOI_1],"mixed-charge, #Omega_{0}","p");
   legendK3->AddEntry(K3[1][0][KT3Bin][BOI_1],"mixed-charge, GRS","p");
   legendK3->Draw("same");
-  TLatex *K3Label = new TLatex(-0.009,1.25,"K_{3}");// -0.011,0.92 (ss), 1.26 (os)
-  K3Label->SetTextFont(TextFont);
-  K3Label->SetTextSize(SizeTitle*SF1);
-  K3Label->SetTextAngle(90);
+  //TLatex *K3Label = new TLatex(0.02,1.25,"K_{3}");// -0.011,0.92 (ss), 1.26 (os)
+  //K3Label->SetTextFont(TextFont);
+  //K3Label->SetTextSize(SizeTitle*SF1);
+  //K3Label->SetTextAngle(90);
   //K3Label->Draw();
   //
   padK3->cd(2);
-  gPad->SetLeftMargin(0.12);
-  gPad->SetRightMargin(0.02);
-  gPad->SetBottomMargin(0.12);
+  double SF_correction=0.97;
+  gPad->SetLeftMargin(0.14);
+  gPad->SetRightMargin(0.03);
+  gPad->SetBottomMargin(0.16);
   //double Dim2=gPad->GetAbsHNDC();
   TLegend *legendK3comp = new TLegend(.45,.8,.95,.95,NULL,"brNDC");
   legendK3comp->SetBorderSize(0);
-  legendK3comp->SetTextSize(SizeLabel*SF1);// small .03; large .06
+  legendK3comp->SetTextSize(SizeLabel*SF1*SF_correction);// small .03; large .06
   legendK3comp->SetFillColor(0);
 
   TH1D *K3sc_compOmega0 = (TH1D*)K3[0][1][KT3Bin][BOI_1]->Clone();
@@ -541,11 +542,11 @@ void Plot_plots(){
   K3sc_compOmega0->SetMaximum(0.12);// 0.021
   K3sc_compOmega0->SetBinContent(1,-100); K3mc_compOmega0->SetBinContent(1,-100);
   K3sc_compOmega0->GetYaxis()->SetNdivisions(404);
-  K3sc_compOmega0->GetYaxis()->SetTitleFont(TextFont); K3sc_compOmega0->GetYaxis()->SetTitleSize(SizeTitle*SF1);
+  K3sc_compOmega0->GetYaxis()->SetTitleFont(TextFont); K3sc_compOmega0->GetYaxis()->SetTitleSize(SizeTitle*SF1*SF_correction);
   //K3sc_compOmega0->GetXaxis()->SetTitleFont(TextFont); K3sc_compOmega0->GetXaxis()->SetTitleSize(SizeTitle*2/3.*.96);
   //K3sc_compOmega0->GetXaxis()->SetTitle("Q_{3} (GeV/c)");
-  K3sc_compOmega0->GetYaxis()->SetTitle("#Delta K_{3}/(K_{3}(#Omega_{0})-1)");
-  K3sc_compOmega0->GetXaxis()->SetTitleOffset(1.2); K3sc_compOmega0->GetYaxis()->SetTitleOffset(1.1);
+  K3sc_compOmega0->GetYaxis()->SetTitle("#Delta#font[12]{K_{3} / (K_{3}}(#Omega_{0})-1)");
+  K3sc_compOmega0->GetXaxis()->SetTitleOffset(1.2); K3sc_compOmega0->GetYaxis()->SetTitleOffset(0.8);
   K3sc_compOmega0->Draw();
   K3mc_compOmega0->Draw("same");
   TF1 *Zero=new TF1("Zero","0",0,1);
@@ -554,13 +555,13 @@ void Plot_plots(){
   legendK3comp->AddEntry(K3sc_compOmega0,"same-charge","p");
   legendK3comp->AddEntry(K3mc_compOmega0,"mixed-charge","p");
   legendK3comp->Draw("same");
-  TLatex *RatioLabel = new TLatex(-.011,0.02,"#Delta K_{3}/(K_{3}(#Omega_{0})-1)");// -0.011,0.04
-  RatioLabel->SetTextFont(TextFont);
-  RatioLabel->SetTextSize(SizeTitle*SF1);
-  RatioLabel->SetTextAngle(90);
+  //TLatex *RatioLabel = new TLatex(-.011,0.02,"#Delta K_{3}/(K_{3}(#Omega_{0})-1)");// -0.011,0.04
+  //RatioLabel->SetTextFont(TextFont);
+  //RatioLabel->SetTextSize(SizeTitle*SF1);
+  //RatioLabel->SetTextAngle(90);
   //RatioLabel->Draw();
 
-  TLatex *Q3Label = new TLatex(.081,-0.147,"Q_{3} (GeV/c)");//.065,-0.147
+  TLatex *Q3Label = new TLatex(.071,-0.155,"#font[12]{Q}_{3} (GeV/#font[12]{c})");//.065,-0.147
   Q3Label->SetTextFont(TextFont);
   Q3Label->SetTextSize(SizeTitle*SF1);// 0.08
   Q3Label->Draw();
@@ -688,7 +689,7 @@ void Plot_plots(){
   canC2->SetHighLightColor(2);
   //canC2->Range(-0.7838115,-1.033258,0.7838115,1.033258);
   gStyle->SetOptFit(0111);
-  canC2->SetFillColor(10);//10
+  canC2->SetFillColor(0);//10
   canC2->SetBorderMode(0);
   canC2->SetBorderSize(2);
   canC2->SetFrameFillColor(0);
@@ -696,7 +697,7 @@ void Plot_plots(){
   canC2->SetFrameBorderMode(0);
   
   
-  TPad *pad1 = new TPad("pad1","pad1",0.05,0.05,1.,1.);//0.05,0.05,1.,1.
+  TPad *pad1 = new TPad("pad1","pad1",0.06,0.06,1.,1.);//0.05,0.05,1.,1.
   gPad->SetGridx(0);
   gPad->SetGridy(0);
   gPad->SetTickx();
@@ -704,19 +705,19 @@ void Plot_plots(){
   pad1->SetTopMargin(0.02);//0.05
   pad1->SetLeftMargin(0.12);//
   pad1->SetRightMargin(0.01);//3e-2
-  pad1->SetBottomMargin(0.07);//0.12
+  pad1->SetBottomMargin(0.08);//0.12
   pad1->Divide(2,3,0,0);
   pad1->Draw();
  
 
-  TLegend *legend1 = new TLegend(.37,.75,.99,.95,NULL,"brNDC");//.45 or .4 for x1
+  TLegend *legend1 = new TLegend(.2,.75,.99,.95,NULL,"brNDC");//.45 or .4 for x1
   legend1->SetBorderSize(0);
   //legend1->SetTextSize(.08);// small .03; large .036 
   legend1->SetTextFont(TextFont);
   legend1->SetTextSize(SizeLegend);
   legend1->SetFillColor(0);
   //
-  TLegend *legend2 = new TLegend(.5,.74, .99,.98,NULL,"brNDC");//.45 or .4 for x1
+  TLegend *legend2 = new TLegend(.35,.74, .99,.98,NULL,"brNDC");//.45 or .4 for x1
   legend2->SetBorderSize(0);
   //legend2->SetTextSize(.08);// small .03; large .036 
   legend2->SetTextFont(TextFont);
@@ -729,6 +730,10 @@ void Plot_plots(){
   for(int kt=0; kt<KTBINS; kt++) {
     pad1->cd(kt+1);
     gPad->SetRightMargin(RightMargin);
+    if(kt%2==0) gPad->SetRightMargin(0.001);
+    if(kt==4) SF_correction=0.92;
+    else if(kt==5) SF_correction=1.015;
+    else SF_correction=1.0;
     //if(kt==0) Dim1=gPad->GetAbsWNDC()*gPad->GetAbsHNDC();
     //Dim2=gPad->GetAbsWNDC()*gPad->GetAbsHNDC();
     C2_ss[kt][BOI_1]->SetMinimum(MIN[BOI_1]);
@@ -739,11 +744,11 @@ void Plot_plots(){
     C2_ss[kt][BOI_1]->GetXaxis()->SetTitle(""); C2_ss[kt][BOI_1]->GetYaxis()->SetTitle("");
     C2_ss[kt][BOI_1]->GetXaxis()->SetTitleFont(TextFont); C2_ss[kt][BOI_1]->GetYaxis()->SetTitleFont(TextFont);
     C2_ss[kt][BOI_1]->GetXaxis()->SetLabelFont(TextFont); C2_ss[kt][BOI_1]->GetYaxis()->SetLabelFont(TextFont);
-    C2_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(SizeLabel); C2_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel);
-    if(kt%2==0) C2_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel);
+    C2_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(SizeLabel*SF_correction); C2_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel*SF_correction);
+    if(kt%2==0) C2_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel*SF_correction);
     else {C2_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(.0);}
     if(kt<KTBINS-2) C2_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(.0);
-    C2_ss[kt][BOI_1]->GetXaxis()->SetNdivisions(606); C2_ss[kt][BOI_1]->GetYaxis()->SetNdivisions(606);
+    C2_ss[kt][BOI_1]->GetXaxis()->SetNdivisions(603); C2_ss[kt][BOI_1]->GetYaxis()->SetNdivisions(606);
     
     //
     C2Therm_ss[kt][BOI_1]->SetMinimum(MIN[BOI_1]);
@@ -753,10 +758,10 @@ void Plot_plots(){
     C2Therm_ss[kt][BOI_1]->GetYaxis()->SetTitleOffset(0.85);
     C2Therm_ss[kt][BOI_1]->GetXaxis()->SetTitle(""); C2Therm_ss[kt][BOI_1]->GetYaxis()->SetTitle("");
     C2Therm_ss[kt][BOI_1]->GetXaxis()->SetLabelFont(TextFont); C2Therm_ss[kt][BOI_1]->GetYaxis()->SetLabelFont(TextFont); 
-    if(kt%2==0) C2Therm_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel);
+    if(kt%2==0) C2Therm_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel*SF_correction);
     else {C2Therm_ss[kt][BOI_1]->GetYaxis()->SetLabelSize(.0);}
     if(kt<KTBINS-2) C2Therm_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(.0);
-    else {C2Therm_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(SizeLabel);}
+    else {C2Therm_ss[kt][BOI_1]->GetXaxis()->SetLabelSize(SizeLabel*SF_correction);}
     C2Therm_ss[kt][BOI_1]->GetXaxis()->SetNdivisions(606); C2Therm_ss[kt][BOI_1]->GetYaxis()->SetNdivisions(606);
 
     if(BOI_1==9 && kt==5) {// Point with large statistical error
@@ -793,7 +798,7 @@ void Plot_plots(){
     //
     if(kt==0){
       TLatex *Specif;
-      if(!TherminatorC2) Specif = new TLatex(0.007,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.91,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");// ALICE specifications
+      if(!TherminatorC2) Specif = new TLatex(0.007,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.91,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");// ALICE specifications
       else Specif = new TLatex(0.0015,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.91,"Therminator");// Therminator
       Specif->SetTextFont(TextFont);
       Specif->SetTextSize(SizeSpecif*.9);
@@ -805,7 +810,7 @@ void Plot_plots(){
       }
       TLatex *Specif2 = new TLatex(0.027,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.8,CentName->Data());
       Specif2->SetTextFont(TextFont);
-      Specif2->SetTextSize(SizeLegend);
+      Specif2->SetTextSize(SizeSpecif);
       Specif->Draw("same");
       Specif2->Draw("same");
     }
@@ -831,14 +836,14 @@ void Plot_plots(){
       legend2->Draw("same");
     }
     TLatex *KtLabel;
-    if(kt==0) KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.2<k_{T}<0.3");// 0.003,.988
-    else if(kt==1) KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.3<k_{T}<0.4");
-    else if(kt==2) KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.4<k_{T}<0.5");
-    else if(kt==3) KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.5<k_{T}<0.6");
-    else if(kt==4) KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.6<k_{T}<0.7");
-    else KtLabel = new TLatex(0.035,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.6,"0.7<k_{T}<0.8");
+    if(kt==0) KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.2<#font[12]{k}_{T}<0.3 GeV/#font[12]{c}");// 0.003,.988
+    else if(kt==1) KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.3<#font[12]{k}_{T}<0.4 GeV/#font[12]{c}");
+    else if(kt==2) KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.4<#font[12]{k}_{T}<0.5 GeV/#font[12]{c}");
+    else if(kt==3) KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.5<#font[12]{k}_{T}<0.6 GeV/#font[12]{c}");
+    else if(kt==4) KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.6<#font[12]{k}_{T}<0.7 GeV/#font[12]{c}");
+    else KtLabel = new TLatex(0.028,MIN[BOI_1]+(MAX[BOI_1]-MIN[BOI_1])*0.68,"0.7<#font[12]{k}_{T}<0.8 GeV/#font[12]{c}");
     KtLabel->SetTextFont(TextFont);// 23
-    KtLabel->SetTextSize(SizeSpecif);// 24
+    KtLabel->SetTextSize(SizeSpecif*SF_correction);// 24
     KtLabel->Draw("same");
   }
  
@@ -848,17 +853,17 @@ void Plot_plots(){
   pad1_2->SetFillStyle(0);
   pad1_2->Draw();
   pad1_2->cd();
-  TLatex *C2Label = new TLatex(.04,.97,"C_{2}");// 0.04,.91
+  TLatex *C2Label = new TLatex(.04,.94,"#font[12]{C}_{2}");// 0.04,.91
   C2Label->SetTextFont(TextFont);
   C2Label->SetTextSize(SizeTitle*SF2);
   C2Label->SetTextAngle(90);
   C2Label->Draw();
-  TLatex *Q2Label = new TLatex(.84,.015,"q (GeV/c)");// .7,.02
+  TLatex *Q2Label = new TLatex(.75,.015,"#font[12]{q} (GeV/#font[12]{c})");// .7,.02
   Q2Label->SetTextFont(TextFont);
   Q2Label->SetTextSize(SizeTitle*SF2);
   Q2Label->Draw();
-  TBox *CoverUp = new TBox(0.554,0.05,0.57,.07);
-  CoverUp->SetFillColor(10);
+  TBox *CoverUp = new TBox(0.554,0.05,0.58,.083);
+  CoverUp->SetFillColor(0);
   CoverUp->Draw();
   
 
@@ -870,7 +875,7 @@ void Plot_plots(){
   TCanvas *can2 = new TCanvas("can2", "can2",680,0,600,900);// 680,0,600,900 with G
   can2->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can2->SetFillColor(10);//10
+  can2->SetFillColor(0);//10
   can2->SetBorderMode(0);
   can2->SetBorderSize(2);
   can2->SetFrameFillColor(0);
@@ -890,21 +895,21 @@ void Plot_plots(){
   pad2->Divide(1,2,0,0);// 1,3,0,0 with G
   pad2->Draw();
   pad2->cd();
-  TLegend *legend3 = new TLegend(.56,.64, .96,.98,NULL,"brNDC");// .56,.6, .96,.98
+  TLegend *legend3 = new TLegend(.44,.66, .96,.98,NULL,"brNDC");// .56,.6, .96,.98
   legend3->SetBorderSize(0);
   legend3->SetTextFont(TextFont);
   legend3->SetTextSize(SizeLegend*SF1);
   legend3->SetFillColor(0);
     
-  double LowerLimits[4]={0.46, 0.32, 4.8, 0.08};// 0.63, 0.32, 5.2, 0.08
-  double UpperLimits[4]={0.84, 0.63, 13.2, 1.28};// 0.92, 0.63, 13.4, 1.28
+  double LowerLimits[4]={0.46, 0.32, 4.8, 0.08};// 0.46, 0.32, 4.8, 0.08
+  double UpperLimits[4]={0.87, 0.63, 13.2, 1.28};// 0.84, 0.63, 13.2, 1.28
   for(int par=1; par<=3; par++){
     //pad2->cd(par);
     if(par!=1 && par!=3) continue;
     if(par==1) pad2->cd(1);
     else pad2->cd(2);
-    gPad->SetRightMargin(0.03); gPad->SetLeftMargin(0.12);
-    if(par==3) gPad->SetBottomMargin(0.13);// 0.22 with G
+    gPad->SetRightMargin(0.03); gPad->SetLeftMargin(0.14);
+    if(par==3) gPad->SetBottomMargin(0.16);// 0.22 with G
     // settings applied to ParHisto_coh[par-1][BOI_1] to include G.  
     ParHisto_ch[par-1][BOI_1]->SetMinimum(LowerLimits[par-1]);
     ParHisto_ch[par-1][BOI_1]->SetMaximum(UpperLimits[par-1]);
@@ -919,17 +924,19 @@ void Plot_plots(){
       ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetTitleSize(0);
       ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetLabelSize(0);
     }
-    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitleSize(SizeTitle*SF1);
-    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel*SF1);
-    ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetTitle("k_{T} (GeV/c)");
+    if(par==1) SF_correction=1.0;
+    else SF_correction=0.97;
+    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitleSize(SizeTitle*SF1*SF_correction);
+    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetLabelSize(SizeLabel*SF1*SF_correction);
+    ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetTitle("#font[12]{k}_{T} (GeV/#font[12]{c})");
     ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetRangeUser(0.2,0.79);
     if(par==1) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("#lambda");
-    if(par==2) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("G");
-    if(par==3) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("R_{ch} (fm)");
-    if(par==4) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("R_{coh} (fm)");
-    ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetTitleOffset(1.2);// 2.0
-    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitleOffset(1.1);// 1.4
-    
+    if(par==2) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("#font[12]{G}");
+    if(par==3) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("#font[12]{R_{ch}} (fm)");
+    if(par==4) ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitle("#font[12]{R_{coh}} (fm)");
+    ParHisto_ch[par-1][BOI_1]->GetXaxis()->SetTitleOffset(0.9);// 2.0
+    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetTitleOffset(0.8);// 1.4
+    ParHisto_ch[par-1][BOI_1]->GetYaxis()->SetNdivisions(505);
    
     // ParN=2 (lambda), 3(G), 4(Rch), 5(Rcoh)
     ParHisto_ch[par-1][BOI_1]->Draw();
@@ -978,12 +985,12 @@ void Plot_plots(){
       //legend3->AddEntry(ParHisto_chEWfromTherm[par-1][BOI_1],"E_{w}, 0-5%","p"); legend3->AddEntry(ParHisto_chEWfromTherm[par-1][BOI_2],"E_{w}, 45-50%","p");
       //legend3->AddEntry(ParHisto_coh[par-1][BOI_1],"G#neq0, 0-5%","p"); legend3->AddEntry(ParHisto_coh[par-1][BOI_2],"G#neq0, 45-50%","p");
       legend3->AddEntry(ParHisto_ch[par-1][BOI_1],"Gauss, 0-5%","p"); legend3->AddEntry(ParHisto_ch[par-1][BOI_2],"Gauss, 45-50%","p");
-      legend3->AddEntry(ParHisto_chEW[par-1][BOI_1],"E_{w}, 0-5%","p"); legend3->AddEntry(ParHisto_chEW[par-1][BOI_2],"E_{w}, 45-50%","p");
+      legend3->AddEntry(ParHisto_chEW[par-1][BOI_1],"Edgeworth, 0-5%","p"); legend3->AddEntry(ParHisto_chEW[par-1][BOI_2],"Edgeworth, 45-50%","p");
     }
     
     if(par==3) legend3->Draw("same");// par==2 with G
     if(par==1){
-      TLatex *Specif_2 = new TLatex(0.35,LowerLimits[par-1]+(UpperLimits[par-1]-LowerLimits[par-1])*.91,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");
+      TLatex *Specif_2 = new TLatex(0.35,LowerLimits[par-1]+(UpperLimits[par-1]-LowerLimits[par-1])*.94,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");
       Specif_2->SetTextFont(TextFont);
       Specif_2->SetTextSize(SizeSpecif*SF1);
       Specif_2->Draw();
@@ -993,11 +1000,11 @@ void Plot_plots(){
   ////////////////////////////////////////////////////
   ////////////////////////////////////////////////////
   // C2(+-) Therminator comparisons
-
+  
   TCanvas *can3 = new TCanvas("can3", "can3",1800,0,600,600);// 11,53,700,500
   can3->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can3->SetFillColor(10);//10
+  can3->SetFillColor(0);//10
   can3->SetBorderMode(0);
   can3->SetBorderSize(2);
   can3->SetFrameFillColor(0);
@@ -1015,11 +1022,11 @@ void Plot_plots(){
   //pad3->Divide(1,2,0,0);
   pad3->Draw();
   pad3->cd();
-  TLegend *legend4 = new TLegend(.21,.72, .85,.92,NULL,"brNDC");//.45 or .4 for x1
+  TLegend *legend4 = new TLegend(.24,.78, .85,.97,NULL,"brNDC");//.45 or .4 for x1
   legend4->SetBorderSize(0);
   legend4->SetFillColor(0);
   
-  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.12); gPad->SetBottomMargin(0.1); gPad->SetTopMargin(0.01);
+  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.16); gPad->SetBottomMargin(0.11); gPad->SetTopMargin(0.01);
 
   TH1D *C2_os_ktcompare[2][KTBINS];
   TH1D *C2Therm_os_ktcompare[2][KTBINS];
@@ -1053,15 +1060,15 @@ void Plot_plots(){
        valueC2Therm_e += pow(FSIbase->GetBinError(qbin) * C2Therm_os_ktcompare[type][kt]->GetBinContent(qbin)/pow(FSIbase->GetBinContent(qbin),2),2);
        valueC2Therm_e = sqrt(valueC2Therm_e);
        // cumulant comparison
-       /*double value = (C2_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/(C2_os[0][BOI_1]->GetBinContent(qbin)-1.);
-       double value_e = pow(C2_os_ktcompare[type][kt]->GetBinError(qbin)/(C2_os[0][BOI_1]->GetBinContent(qbin)-1.),2);
-       value_e += pow(C2_os[0][BOI_1]->GetBinError(qbin) * (C2_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/pow((C2_os[0][BOI_1]->GetBinContent(qbin)-1.),2),2);
-       value_e = sqrt(value_e);
-       double valueC2Therm = (C2Therm_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/(FSIbase->GetBinContent(qbin)-1.);
-       double valueC2Therm_e = pow(C2Therm_os_ktcompare[type][kt]->GetBinError(qbin)/(FSIbase->GetBinContent(qbin)-1.),2);
-       valueC2Therm_e += pow(FSIbase->GetBinError(qbin) * (C2Therm_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/pow((FSIbase->GetBinContent(qbin)-1.),2),2);
-       valueC2Therm_e = sqrt(valueC2Therm_e);
-       */
+       //double value = (C2_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/(C2_os[0][BOI_1]->GetBinContent(qbin)-1.);
+       //double value_e = pow(C2_os_ktcompare[type][kt]->GetBinError(qbin)/(C2_os[0][BOI_1]->GetBinContent(qbin)-1.),2);
+       //value_e += pow(C2_os[0][BOI_1]->GetBinError(qbin) * (C2_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/pow((C2_os[0][BOI_1]->GetBinContent(qbin)-1.),2),2);
+       //value_e = sqrt(value_e);
+       //double valueC2Therm = (C2Therm_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/(FSIbase->GetBinContent(qbin)-1.);
+       //double valueC2Therm_e = pow(C2Therm_os_ktcompare[type][kt]->GetBinError(qbin)/(FSIbase->GetBinContent(qbin)-1.),2);
+       //valueC2Therm_e += pow(FSIbase->GetBinError(qbin) * (C2Therm_os_ktcompare[type][kt]->GetBinContent(qbin)-1.)/pow((FSIbase->GetBinContent(qbin)-1.),2),2);
+       //valueC2Therm_e = sqrt(valueC2Therm_e);
+       
        
        //
        C2_os_ktcompare[type][kt]->SetBinContent(qbin, value);
@@ -1092,7 +1099,8 @@ void Plot_plots(){
        C2_os_ktcompare[type][kt]->GetXaxis()->SetTitleFont(TextFont); C2_os_ktcompare[type][kt]->GetYaxis()->SetTitleFont(TextFont);
        C2_os_ktcompare[type][kt]->GetXaxis()->SetTitleSize(SizeTitle*SF2); 
        C2_os_ktcompare[type][kt]->GetYaxis()->SetTitleSize(SizeTitle*SF2);
-       C2_os_ktcompare[type][kt]->GetXaxis()->SetTitle("q (GeV/c)");
+       C2_os_ktcompare[type][kt]->GetXaxis()->SetTitle("#font[12]{q} (GeV/#font[12]{c})");
+       C2_os_ktcompare[type][kt]->GetXaxis()->SetTitleOffset(0.8);
        C2_os_ktcompare[type][kt]->GetXaxis()->SetLabelFont(TextFont); C2_os_ktcompare[type][kt]->GetYaxis()->SetLabelFont(TextFont);
        C2_os_ktcompare[type][kt]->GetXaxis()->SetLabelSize(SizeLabel*SF2); 
        C2_os_ktcompare[type][kt]->GetYaxis()->SetLabelSize(SizeLabel*SF2); 
@@ -1104,9 +1112,9 @@ void Plot_plots(){
       //else {
       //C2_os_ktcompare[type][kt]->DrawCopy("same");
       //}
-      TString *ktname = new TString("k_{T,");
+      TString *ktname = new TString("#font[12]{k}_{T,");
       *ktname += kt+1;
-      ktname->Append("}/k_{T,1}");
+      ktname->Append("}/#font[12]{k}_{T,1}");
       TString *nameReal=new TString(ktname->Data());
       nameReal->Append(", ALICE");
       TString *nameTherm=new TString(ktname->Data());
@@ -1117,7 +1125,7 @@ void Plot_plots(){
        legend4->AddEntry(C2Therm_os_ktcompare[type][kt],nameTherm->Data(),"p");
       }else {
        TString *nameTherm2=new TString(nameTherm->Data());
-       nameTherm2->Append(", r*<80 fm");
+       //nameTherm2->Append(", r*<80 fm");
        nameTherm2->Append(" (undiluted)");
        legend4->AddEntry(C2Therm_os_ktcompare[type][kt],nameTherm2->Data(),"p");
       }
@@ -1125,11 +1133,11 @@ void Plot_plots(){
     }
     
     if(type==1) {
-      TLatex *Specif_3 = new TLatex(0.45,0.65,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");
+      TLatex *Specif_3 = new TLatex(0.4,0.15,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");
       Specif_3->SetNDC();
       Specif_3->SetTextFont(TextFont);
       Specif_3->SetTextSize(SizeSpecif*SF2);
-      TLatex *Specif2_3 = new TLatex(0.35,0.65,"0-5%");
+      TLatex *Specif2_3 = new TLatex(0.55,0.22,"0-5%");
       Specif2_3->SetNDC();
       Specif2_3->SetTextFont(TextFont);
       Specif2_3->SetTextSize(SizeLegend*SF2);
@@ -1150,12 +1158,12 @@ void Plot_plots(){
   pad3_2->SetFillStyle(0);
   pad3_2->Draw();
   pad3_2->cd();
-  TLatex *DthLabel = new TLatex(.035,.7,"C_{2}^{+-}(k_{T,6}) / C_{2}^{+-}(k_{T,1})");// .04,.96, "D^{+-}_{Th}"
+  TLatex *DthLabel = new TLatex(.044,.58,"#font[12]{C}_{2}^{+-}(#font[12]{k}_{T,6}) / #font[12]{C}_{2}^{+-}(#font[12]{k}_{T,1})");// .04,.96, "D^{+-}_{Th}"
   DthLabel->SetTextFont(TextFont);
   DthLabel->SetTextSize(SizeTitle*SF2);
   DthLabel->SetTextAngle(90);
   DthLabel->Draw();
-  Q2Label->Draw();
+  
 
   ////////////////////////////////////////////////////
   ////////////////////////////////////////////////////
@@ -1165,7 +1173,7 @@ void Plot_plots(){
   TCanvas *can4 = new TCanvas("can4", "can4",10,300,600,900);// 11,53,700,500
   can4->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can4->SetFillColor(10);//10
+  can4->SetFillColor(0);//10
   can4->SetBorderMode(0);
   can4->SetBorderSize(2);
   can4->SetFrameFillColor(0);
@@ -1173,7 +1181,7 @@ void Plot_plots(){
   can4->SetFrameBorderMode(0);
   
   
-  TPad *pad4 = new TPad("pad4","pad4",0.05,0.05,1.,1.);
+  TPad *pad4 = new TPad("pad4","pad4",0.06,0.06,1.,1.);
   gPad->SetGridx(0);
   gPad->SetGridy(0);
   gPad->SetTickx();
@@ -1181,7 +1189,7 @@ void Plot_plots(){
   pad4->SetTopMargin(0.02);//0.05
   pad4->SetLeftMargin(0.12);
   pad4->SetRightMargin(0.01);//3e-2
-  pad4->SetBottomMargin(0.07);//0.12
+  pad4->SetBottomMargin(0.08);//0.12
   pad4->Divide(2,3,0,0);
   pad4->Draw();
 
@@ -1223,6 +1231,10 @@ void Plot_plots(){
   for(int cb=0; cb<6; cb++) {
     pad4->cd(cb+1);
     gPad->SetRightMargin(RightMargin);
+    if(cb%2==0) gPad->SetRightMargin(0.001);
+    if(cb==4) SF_correction=0.92;
+    else if(cb==5) SF_correction=1.015;
+    else SF_correction=1.0;
     //if(cb==0) Dim1=gPad->GetAbsWNDC()*gPad->GetAbsHNDC()*gPad->PixeltoX(10)*gPad->PixeltoY(10);
     //Dim2=gPad->GetAbsWNDC()*gPad->GetAbsHNDC()*gPad->PixeltoX(10)*gPad->PixeltoY(10);
     
@@ -1237,8 +1249,8 @@ void Plot_plots(){
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetTitle(""); C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetTitle("");
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelFont(TextFont);
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelFont(TextFont);
-    C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(SizeLabel);
-    if(cb%2==0) C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(SizeLabel);
+    C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(SizeLabel*SF_correction);
+    if(cb%2==0) C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(SizeLabel*SF_correction);
     else {C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(.0);}
     if(cb<4) C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(.0);
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetRangeUser(0,0.11);
@@ -1251,6 +1263,7 @@ void Plot_plots(){
       c3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->SetBinContent(2,-100);
     }
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetXaxis()->SetNdivisions(404);
+    C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->GetYaxis()->SetNdivisions(505);
     //TGaxis::SetMaxDigits(3);
     C3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->DrawCopy();
     c3merged[ChProdBOI][CoulChoice][KT3Bin][cb]->DrawCopy("same");
@@ -1282,25 +1295,25 @@ void Plot_plots(){
 
     if(cb==0){
       if(ChProdBOI==0){
-       legend5->AddEntry(C3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#it{C}_{3}^{#pm#pm#pm}","p");
-       legend5->AddEntry(c3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#bf{c}_{3}^{#pm#pm#pm}","p");
+       legend5->AddEntry(C3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#font[12]{C}_{3}^{#pm#pm#pm}","p");
+       legend5->AddEntry(c3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
       }else{
-       legend5->AddEntry(C3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#it{C}_{3}^{#pm#pm#mp}","p");
-       legend5->AddEntry(c3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#bf{c}_{3}^{#pm#pm#mp}","p");
+       legend5->AddEntry(C3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#font[12]{C}_{3}^{#pm#pm#mp}","p");
+       legend5->AddEntry(c3merged[ChProdBOI][CoulChoice][KT3Bin][cb],"#font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
       }
       legend5->Draw("same");
     }
-    TLatex *Specif_3 = new TLatex(0.007,0.9+(C3MAX-0.9)*0.91,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");// ALICE specifications
+    TLatex *Specif_3 = new TLatex(0.007,0.9+(C3MAX-0.9)*0.91,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");// ALICE specifications
     Specif_3->SetTextFont(TextFont);
-    Specif_3->SetTextSize(SizeSpecif);
+    Specif_3->SetTextSize(SizeSpecif*SF_correction);
     if(cb==3) Specif_3->Draw("same");
 
     TString *KTString = new TString("");
-    if(KT3Bin==0) KTString->Append("0.16<K_{t,3}<0.3 GeV/c");
-    else KTString->Append("0.3<K_{t,3}<1.0 GeV/c");
+    if(KT3Bin==0) KTString->Append("0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}");
+    else KTString->Append("0.3<#font[12]{K}_{T,3}<1.0 GeV/#font[12]{c}");
     TLatex *Kt3Name_1 = new TLatex(0.016,0.9+(C3MAX-0.9)*0.91,KTString->Data());
     Kt3Name_1->SetTextFont(TextFont);
-    Kt3Name_1->SetTextSize(SizeSpecif);
+    Kt3Name_1->SetTextSize(SizeLabel*SF_correction);
     if(cb==1) Kt3Name_1->Draw("same");
 
     TLatex *CentLabel_1;
@@ -1312,7 +1325,7 @@ void Plot_plots(){
     else CentLabel_1 = new TLatex(0.07,C3MAX-0.75,"40-50%");
     
     CentLabel_1->SetTextFont(TextFont);
-    CentLabel_1->SetTextSize(SizeLabel);//.1
+    CentLabel_1->SetTextSize(SizeLabel*SF_correction);//.1
     CentLabel_1->Draw("same");
 
     if(ChProdBOI==1){
@@ -1332,12 +1345,12 @@ void Plot_plots(){
   pad4_2->SetFillStyle(0);
   pad4_2->Draw();
   pad4_2->cd();
-  TLatex *C3Label = new TLatex(.04,.91,"C_{3} or #bf{c}_{3}");// 0.05,0.9
+  TLatex *C3Label = new TLatex(.04,.86,"#font[12]{C}_{3} or #font[12]{#bf{c}}_{3}");// 0.05,0.9
   C3Label->SetTextFont(TextFont);
   C3Label->SetTextSize(SizeTitle*SF2);
   C3Label->SetTextAngle(90);
   C3Label->Draw();
-  TLatex *Q3Label = new TLatex(.82,.015,"Q_{3} (GeV/c)");// 0.05,0.9
+  TLatex *Q3Label = new TLatex(.72,.02,"#font[12]{Q}_{3} (GeV/#font[12]{c})");// 0.05,0.9
   Q3Label->SetTextFont(TextFont);
   Q3Label->SetTextSize(SizeTitle*SF2);
   Q3Label->Draw();
@@ -1391,7 +1404,7 @@ void Plot_plots(){
   TCanvas *can5 = new TCanvas("can5", "can5",680,300,600,900);// 11,53,700,500
   can5->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can5->SetFillColor(10);//10
+  can5->SetFillColor(0);//10
   can5->SetBorderMode(0);
   can5->SetBorderSize(2);
   can5->SetFrameFillColor(0);
@@ -1399,7 +1412,7 @@ void Plot_plots(){
   can5->SetFrameBorderMode(0);
   
   
-  TPad *pad5 = new TPad("pad5","pad5",0.05,0.05,1.,1.);
+  TPad *pad5 = new TPad("pad5","pad5",0.06,0.06,1.,1.);
   gPad->SetGridx(0);
   gPad->SetGridy(0);
   gPad->SetTickx();
@@ -1407,11 +1420,11 @@ void Plot_plots(){
   pad5->SetTopMargin(0.02);//0.05
   pad5->SetLeftMargin(0.12);//.14 for wide title, .10 for narrow title, 0.08 for DeltaQ
   pad5->SetRightMargin(0.01);//3e-2
-  pad5->SetBottomMargin(0.07);//0.12
+  pad5->SetBottomMargin(0.08);//0.12
   pad5->Divide(2,3,0,0);
   pad5->Draw();
   
-  TLegend *legend6 = new TLegend(.18,.16, .53,.46,NULL,"brNDC");// .25,.16, .6,.46
+  TLegend *legend6 = new TLegend(.18,.72, .53,.98,NULL,"brNDC");// .25,.16, .6,.46
   legend6->SetBorderSize(0);
   legend6->SetTextFont(TextFont);
   legend6->SetTextSize(SizeLegend);
@@ -1420,12 +1433,17 @@ void Plot_plots(){
   
   double LambdaSysPar0[6]={0.0143, 0.014, 0.01294, 0.00204, 0.001227, 0.00999};
   double LambdaSysPar1[6]={-0.857, -0.741, -0.6655, -0.3516, -0.2327, -0.3325};
-  double r3MIN = 0.3;// 0.3
-  double r3MAX = 2.68;// was 2.68
+  double r3MIN = 1.45;// 0.3
+  double r3MAX = 2.45;// 2.68
+  r3merged[CoulChoice][1][5]->SetBinContent(3,100);  r3merged[CoulChoice][1][5]->SetBinError(3,1000);// remove high stat error point
   for(int cb=0; cb<6; cb++) {
     pad5->cd(cb+1);
     gPad->SetRightMargin(RightMargin);
-    
+    if(cb%2==0) gPad->SetRightMargin(0.001);
+    if(cb==4) SF_correction=0.92;
+    else if(cb==5) SF_correction=1.015;
+    else SF_correction=1.0;
     r3merged[CoulChoice][KT3Bin][cb]->SetMarkerSize(1.5);
     r3merged[CoulChoice][KT3Bin][cb]->SetMarkerStyle(20);
     r3merged[CoulChoice][KT3Bin][cb]->SetMarkerColor(2); r3merged[CoulChoice][KT3Bin][cb]->SetLineColor(2); 
@@ -1433,15 +1451,16 @@ void Plot_plots(){
     r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetTitle(""); 
     r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelFont(TextFont);
     r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelFont(TextFont);
-    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(SizeLabel);
-    if(cb%2==0) r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(SizeLabel);
+    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(SizeLabel*SF_correction);
+    if(cb%2==0) r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(SizeLabel*SF_correction);
     else {r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetLabelSize(.0);}
     if(cb<4) r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetLabelSize(.0);
-    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetRangeUser(0,0.11);
+    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetRangeUser(0,0.071);// was 0,0.11
     r3merged[CoulChoice][KT3Bin][cb]->SetMinimum(r3MIN);
     r3merged[CoulChoice][KT3Bin][cb]->SetMaximum(r3MAX);
     if(cb>2 || KT3Bin==1) r3merged[CoulChoice][KT3Bin][cb]->SetBinContent(2,-100);// 10-20 MeV bin is insignificant
-    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetNdivisions(404);
+    r3merged[CoulChoice][KT3Bin][cb]->GetXaxis()->SetNdivisions(502);// was 404
+    r3merged[CoulChoice][KT3Bin][cb]->GetYaxis()->SetNdivisions(505);// was absent
     r3merged[CoulChoice][KT3Bin][cb]->DrawCopy();
     //ChaoticLimit->Draw("same");
 
@@ -1494,8 +1513,9 @@ void Plot_plots(){
       double Q3 = (bin-0.5)*0.01;
       double SysMeth=0;
       if(C3merged[1][CoulChoice][KT3Bin][cb]->GetBinContent(bin)>0) {
-       SysMeth = pow(2 * (fabs(ResidueFit->Eval(Q3)-1.0) + 0.002)/(c3merged[0][CoulChoice][KT3Bin][cb]->GetBinContent(bin)-1.0),2);// mixed-charge baseline (new).  Includes 0.002 as allowed variation through lambda powers
-       }
+       //SysMeth = pow(2 * (fabs(ResidueFit->Eval(Q3)-1.0) + 0.002)/(c3merged[0][CoulChoice][KT3Bin][cb]->GetBinContent(bin)-1.0),2);// mixed-charge baseline (new).  Includes 0.002 as allowed variation through lambda powers
+       SysMeth = pow((fabs(ResidueFit->Eval(Q3)-1.0)+0.002)/(c3merged[0][CoulChoice][KT3Bin][cb]->GetBinContent(bin)-1.0) * r3merged[CoulChoice][KT3Bin][cb]->GetBinContent(bin),2);// factional error determined from MC residue fit divided by SC cumulant.  Error = Fraction * r3
+      }
       SysMeth += pow(r3LambdaSysFit->Eval(Q3,2)*r3merged[CoulChoice][KT3Bin][cb]->GetBinContent(bin),2);// Lambda 0.7 vs 0.6
       double SysDet = pow(0.01*r3merged[CoulChoice][KT3Bin][cb]->GetBinContent(bin),2);// MRC
       SysDet += pow(0.01*r3merged[CoulChoice][KT3Bin][cb]->GetBinContent(bin),2);// PID
@@ -1511,8 +1531,8 @@ void Plot_plots(){
     r3DetSys->Draw("E2 same");
     r3CoulSys->Draw("P");
     //
-    float MinQ3Fit=0.01;
-    float MaxQ3Fit=0.1;
+    float MinQ3Fit=0.01;//0.01
+    float MaxQ3Fit=0.08;//0.1
     if(r3merged[CoulChoice][KT3Bin][cb]->GetBinContent(2)<-10) MinQ3Fit=0.02;
 
     r3merged[CoulChoice][KT3Bin][cb]->Fit(QuarticFit[0][cb],"IMENQ","",MinQ3Fit,MaxQ3Fit);// Stat only
@@ -1525,7 +1545,11 @@ void Plot_plots(){
     r3Coul1->Fit(QuadraticFit[2][cb],"IMENQ","",MinQ3Fit,MaxQ3Fit);// GRS
     r3Coul2->Fit(QuadraticFit[3][cb],"IMENQ","",MinQ3Fit,MaxQ3Fit);// Omega0
     //
-    
+    //if(cb==1){
+    //for(int i=0; i<10; i++){
+    // cout<<r3MethDetSys->GetBinError(i+1)<<endl;
+    //}
+    //}
     //
     QuarticFit[2][cb]->Draw("same");
     QuadraticFit[2][cb]->Draw("same");
@@ -1534,31 +1558,31 @@ void Plot_plots(){
     //cout<<"Quartic Chi^2/NDF = "<<QuarticFit[cb]->GetChisquare()/QuarticFit[cb]->GetNDF()<<endl;
     //cout<<"Quadratic Chi^2/NDF = "<<QuadraticFit[cb]->GetChisquare()/QuadraticFit[cb]->GetNDF()<<endl;
     
-    TLatex *Specif_4 = new TLatex(0.007,r3MIN+(r3MAX-r3MIN)*0.91,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");// 0.005,2.1
+    TLatex *Specif_4 = new TLatex(0.007,r3MIN+(r3MAX-r3MIN)*0.91,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");// 0.005,2.1
     Specif_4->SetTextFont(TextFont);
-    Specif_4->SetTextSize(SizeSpecif);
+    Specif_4->SetTextSize(SizeSpecif*SF_correction);
     if(cb==3) Specif_4->Draw("same");
    
     
     TString *KTString = new TString("");
-    if(KT3Bin==0) KTString->Append("0.16<K_{t,3}<0.3 GeV/c");
-    else KTString->Append("0.3<K_{t,3}<1.0 GeV/c");
-    TLatex *Kt3Name_2 = new TLatex(0.01,r3MIN+(r3MAX-r3MIN)*0.91,KTString->Data());//
+    if(KT3Bin==0) KTString->Append("0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}");
+    else KTString->Append("0.3<#font[12]{K}_{T,3}<1.0 GeV/#font[12]{c}");
+    TLatex *Kt3Name_2 = new TLatex(0.002,r3MIN+(r3MAX-r3MIN)*0.91,KTString->Data());//
     Kt3Name_2->SetTextFont(TextFont);
-    Kt3Name_2->SetTextSize(SizeSpecif);
+    Kt3Name_2->SetTextSize(SizeLabel*SF_correction);
     if(cb==1) Kt3Name_2->Draw("same");
-
+    
     TLatex *CentLabel_2;
     //TString *CentLabel2;
-    if(cb==0) {CentLabel_2 = new TLatex(0.04,0.4,"0-5%"); }//CentLabel2 = new TString("0-5\\%");}
-    else if(cb==1) {CentLabel_2 = new TLatex(0.04,0.4,"5-10%");}// CentLabel2 = new TString("5-10\\%");}
-    else if(cb==2) {CentLabel_2 = new TLatex(0.04,0.4,"10-20%");}// CentLabel2 = new TString("10-20\\%");}
-    else if(cb==3) {CentLabel_2 = new TLatex(0.04,0.4,"20-30%");}// CentLabel2 = new TString("20-30\\%");}
-    else if(cb==4) {CentLabel_2 = new TLatex(0.04,0.4,"30-40%");}// CentLabel2 = new TString("30-40\\%");}
-    else {CentLabel_2 = new TLatex(0.04,0.4,"40-50%");}// CentLabel2 = new TString("40-50\\%");}
+    if(cb==0) {CentLabel_2 = new TLatex(0.03,1.52,"0-5%"); }//CentLabel2 = new TString("0-5\\%");}// was 0.04,0.4
+    else if(cb==1) {CentLabel_2 = new TLatex(0.03,1.52,"5-10%");}// CentLabel2 = new TString("5-10\\%");}
+    else if(cb==2) {CentLabel_2 = new TLatex(0.03,1.52,"10-20%");}// CentLabel2 = new TString("10-20\\%");}
+    else if(cb==3) {CentLabel_2 = new TLatex(0.03,1.52,"20-30%");}// CentLabel2 = new TString("20-30\\%");}
+    else if(cb==4) {CentLabel_2 = new TLatex(0.03,1.52,"30-40%");}// CentLabel2 = new TString("30-40\\%");}
+    else {CentLabel_2 = new TLatex(0.03,1.52,"40-50%");}// CentLabel2 = new TString("40-50\\%");}
     
     CentLabel_2->SetTextFont(TextFont);
-    CentLabel_2->SetTextSize(SizeLabel);
+    CentLabel_2->SetTextSize(SizeLabel*SF_correction);
     CentLabel_2->Draw("same");
     
     if(cb==0){
@@ -1574,9 +1598,9 @@ void Plot_plots(){
   pad5_2->SetFillStyle(0);
   pad5_2->Draw();
   pad5_2->cd();
-  TLatex *r3Label = new TLatex(.035,.97,"r_{3}");// 0.035,0.88
+  TLatex *r3Label = new TLatex(.035,.96,"#font[12]{r}_{3}");// 0.035,0.88
   r3Label->SetTextFont(TextFont);
-  r3Label->SetTextSize(SizeLabel*SF2);
+  r3Label->SetTextSize(SizeTitle*SF2);
   r3Label->SetTextAngle(90);
   r3Label->Draw();
   CoverUp->Draw();
@@ -1591,6 +1615,7 @@ void Plot_plots(){
   double a_quartic_Avg=0, a_quadratic_Avg=0;
   double a_quartic_AvgErr1=0, a_quadratic_AvgErr1=0;
   double a_quartic_AvgErr2=0, a_quadratic_AvgErr2=0;
+  
   cout<<"Quartic"<<endl;
   for(int cb=0; cb<6; cb++) {
     TString *CentLabel2;
@@ -1602,8 +1627,8 @@ void Plot_plots(){
     else {CentLabel2 = new TString("40-50\\%");}
 
     double SF=1000.;
-    double I_Sys1=fabs(QuarticFit[1][cb]->GetParameter(0)-QuarticFit[0][cb]->GetParameter(0));
-    double I_Sys2=fabs(QuarticFit[2][cb]->GetParameter(0)-QuarticFit[3][cb]->GetParameter(0));
+    double I_Sys1=fabs(QuarticFit[1][cb]->GetParameter(0)-QuarticFit[0][cb]->GetParameter(0));// Meth+Det Sys
+    double I_Sys2=fabs(QuarticFit[2][cb]->GetParameter(0)-QuarticFit[3][cb]->GetParameter(0));// Coulomb Sys
     double I_SysTotal = sqrt(pow(I_Sys1,2)+pow(I_Sys2,2));
     double a_Sys1=fabs(QuarticFit[1][cb]->GetParameter(1)-QuarticFit[0][cb]->GetParameter(1));
     double a_Sys2=fabs(QuarticFit[2][cb]->GetParameter(1)-QuarticFit[3][cb]->GetParameter(1));
@@ -1611,7 +1636,7 @@ void Plot_plots(){
     double a_SysTotal = sqrt(pow(a_Sys1,2)+pow(a_Sys2,2));
     I_quartic_Avg += QuarticFit[1][cb]->GetParameter(0);// [1] has both Stat+Sys errors
     I_quartic_AvgErr1 += pow(QuarticFit[0][cb]->GetParError(0),2);// [0] has only Stat errors
-    I_quartic_AvgErr2 += sqrt(pow(I_Sys1,2) + pow(I_Sys2,2));
+    I_quartic_AvgErr2 += I_SysTotal;
     a_quartic_Avg += QuarticFit[1][cb]->GetParameter(1)/SF;
     a_quartic_AvgErr1 += pow(QuarticFit[0][cb]->GetParError(1)/SF,2);
     a_quartic_AvgErr2 += sqrt(pow(a_Sys1,2) + pow(a_Sys2,2));
@@ -1623,6 +1648,37 @@ void Plot_plots(){
   a_quartic_Avg /= 6.; a_quartic_AvgErr1 = sqrt(a_quartic_AvgErr1)/6.; a_quartic_AvgErr2 = a_quartic_AvgErr2/6.;
   cout<<"$"<<setprecision(2)<<fixed<<"0-50\\%"<<"$ & $"<<I_quartic_Avg<<" \\pm "<<I_quartic_AvgErr1<<" \\pm "<<I_quartic_AvgErr2<<"$ & $"<<setprecision(1)<<fixed<<a_quartic_Avg<<" \\pm "<<a_quartic_AvgErr1<<" \\pm "<<a_quartic_AvgErr2<<"$ \\\\ \\hline"<<endl;
   
+  /*TCanvas *can5_5 = new TCanvas("can5_5", "can5_5",680,300,600,600);// 11,53,700,500
+  can5_5->SetHighLightColor(2);
+  gStyle->SetOptFit(0111);
+  can5_5->SetFillColor(0);//10
+  can5_5->SetBorderMode(0);
+  can5_5->SetBorderSize(2);
+  can5_5->SetFrameFillColor(0);
+  can5_5->SetFrameBorderMode(0);
+  can5_5->SetFrameBorderMode(0);
+  can5_5->Draw();
+  double Iold_K1[6]={1.84,1.84,1.82,1.84,1.79,1.73};
+  double Iold_K2[6]={1.94,1.92,2.02,1.98,2.01,2.03};
+  double aold_K1[6]={13.8,10.6,6.9,6.7,3.7,4.9};
+  double aold_K2[6]={8.7,4.6,4.4,1.8,-0.2,-1.8};
+
+  TH1D *ratioMuonCorr=new TH1D("ratioMuonCorr","",6,0.5,6.5);
+  ratioMuonCorr->GetXaxis()->SetBinLabel(1,"0-5%");
+  ratioMuonCorr->GetXaxis()->SetBinLabel(2,"5-10%");
+  ratioMuonCorr->GetXaxis()->SetBinLabel(3,"10-20%");
+  ratioMuonCorr->GetXaxis()->SetBinLabel(4,"20-30%");
+  ratioMuonCorr->GetXaxis()->SetBinLabel(5,"30-40%");
+  ratioMuonCorr->GetXaxis()->SetBinLabel(6,"40-50%");
+  ratioMuonCorr->GetYaxis()->SetTitle("New/Old"); ratioMuonCorr->GetYaxis()->SetTitleOffset(1.8);
+  ratioMuonCorr->SetTitle("Quartic coefficient");
+  for(int i=0; i<6; i++){
+    ratioMuonCorr->SetBinContent(i+1, QuarticFit[1][i]->GetParameter(1)/SF/aold_K1[i]);
+    ratioMuonCorr->SetBinError(i+1, 1000./QuarticFit[1][i]->GetParameter(1));// 0.015/1.8 for I_K1, 0.03/1.8 for I_K2, 
+  }
+  ratioMuonCorr->Draw();
+  */
+  
   ////////////////////////////
   cout<<"Quadratic"<<endl;
   for(int cb=0; cb<6; cb++) {
@@ -1634,8 +1690,9 @@ void Plot_plots(){
     else if(cb==4) {CentLabel2 = new TString("30-40\\%");}
     else {CentLabel2 = new TString("40-50\\%");}
     double SF=10.;
-    double I_Sys1=fabs(QuadraticFit[1][cb]->GetParameter(0)-QuadraticFit[0][cb]->GetParameter(0));
-    double I_Sys2 = fabs(QuadraticFit[2][cb]->GetParameter(0)-QuadraticFit[3][cb]->GetParameter(0));
+    cout.precision(4);
+    double I_Sys1 = fabs(QuadraticFit[1][cb]->GetParameter(0)-QuadraticFit[0][cb]->GetParameter(0));// Meth+Det Sys
+    double I_Sys2 = fabs(QuadraticFit[2][cb]->GetParameter(0)-QuadraticFit[3][cb]->GetParameter(0));// Coulomb Sys
     double I_SysTotal = sqrt(pow(I_Sys1,2)+pow(I_Sys2,2));
     double a_Sys1=fabs(QuadraticFit[1][cb]->GetParameter(1)-QuadraticFit[0][cb]->GetParameter(1));
     double a_Sys2 = fabs(QuadraticFit[2][cb]->GetParameter(1)-QuadraticFit[3][cb]->GetParameter(1));
@@ -1643,7 +1700,7 @@ void Plot_plots(){
     double a_SysTotal = sqrt(pow(a_Sys1,2)+pow(a_Sys2,2));
     I_quadratic_Avg += QuadraticFit[1][cb]->GetParameter(0);
     I_quadratic_AvgErr1 += pow(QuadraticFit[0][cb]->GetParError(0),2);
-    I_quadratic_AvgErr2 += sqrt(pow(I_Sys1,2) + pow(I_Sys2,2));
+    I_quadratic_AvgErr2 += I_SysTotal;
     a_quadratic_Avg += QuadraticFit[1][cb]->GetParameter(1)/SF;
     a_quadratic_AvgErr1 += pow(QuadraticFit[0][cb]->GetParError(1)/SF,2);
     a_quadratic_AvgErr2 += sqrt(pow(a_Sys1,2) + pow(a_Sys2,2));
@@ -1653,19 +1710,19 @@ void Plot_plots(){
   I_quadratic_Avg /= 6.; I_quadratic_AvgErr1 = sqrt(I_quadratic_AvgErr1)/6.; I_quadratic_AvgErr2 = I_quadratic_AvgErr2/6.;
   a_quadratic_Avg /= 6.; a_quadratic_AvgErr1 = sqrt(a_quadratic_AvgErr1)/6.; a_quadratic_AvgErr2 = a_quadratic_AvgErr2/6.;
   cout<<"$"<<setprecision(2)<<fixed<<"0-50\\%"<<"$ & $"<<I_quadratic_Avg<<" \\pm "<<I_quadratic_AvgErr1<<" \\pm "<<I_quadratic_AvgErr2<<"$ & $"<<setprecision(1)<<fixed<<a_quadratic_Avg<<" \\pm "<<a_quadratic_AvgErr1<<" \\pm "<<a_quadratic_AvgErr2<<"$ \\\\ \\hline"<<endl;
-
+  
  
 
 
-
+  
   ////////////////////////////////////////////////////////////////////////////////
-  // To visualize Separate Systematic uncertainties
+  // Coulomb Variation
   
   int CBOI_SS=1;// 1=5-10%
   TCanvas *can6 = new TCanvas("can6", "can6",1800,300,600,900);// 680,300,600,600
   can6->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can6->SetFillColor(10);//10
+  can6->SetFillColor(0);//10
   can6->SetBorderMode(0);
   can6->SetBorderSize(2);
   can6->SetFrameFillColor(0);
@@ -1683,7 +1740,7 @@ void Plot_plots(){
   pad6->Divide(1,2,0,0);
   pad6->Draw();
   pad6->cd(1);
-  TLegend *legend7 = new TLegend(.75,.7, .95,.85,NULL,"brNDC");//c3
+  TLegend *legend7 = new TLegend(.8,.05, .98,.2,NULL,"brNDC");//c3
   legend7->SetBorderSize(0);
   legend7->SetTextFont(TextFont);
   legend7->SetTextSize(SizeLegend*SF1);
@@ -1695,17 +1752,17 @@ void Plot_plots(){
   c3merged[1][1][KT3Bin][CBOI_SS]->SetMarkerStyle(21); c3merged[1][1][KT3Bin][CBOI_SS]->SetMarkerColor(4); c3merged[1][1][KT3Bin][CBOI_SS]->SetLineColor(4);// Omega0, Kt3_1
   c3merged[1][0][KT3Bin][CBOI_SS]->SetMinimum(0.995); c3merged[1][0][KT3Bin][CBOI_SS]->SetMaximum(1.065); 
   //
-  gPad->SetRightMargin(RightMargin); gPad->SetLeftMargin(0.12);
+  gPad->SetRightMargin(RightMargin); gPad->SetLeftMargin(0.13);
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelFont(TextFont); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelFont(TextFont); 
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelSize(0); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelSize(SizeLabel*SF1);
   //
-  r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(1.2);
+  r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(0.8);
   r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleFont(TextFont);
   r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleSize(SizeTitle*SF1);
-  r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("r_{3}");
-  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetRangeUser(0,0.11);
+  r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("#font[12]{r}_{3}");
+  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetRangeUser(0,0.08);
   //
-  r3merged[0][KT3Bin][CBOI_SS]->SetMinimum(0.3); r3merged[0][KT3Bin][CBOI_SS]->SetMaximum(2.28);
+  r3merged[0][KT3Bin][CBOI_SS]->SetMinimum(0.9); r3merged[0][KT3Bin][CBOI_SS]->SetMaximum(2.4);
   r3merged[0][KT3Bin][CBOI_SS]->SetMarkerSize(1.5);
   r3merged[1][KT3Bin][CBOI_SS]->SetMarkerSize(1.7);
   r3merged[0][KT3Bin][CBOI_SS]->DrawCopy();
@@ -1714,44 +1771,48 @@ void Plot_plots(){
   legend7->AddEntry(r3merged[0][KT3Bin][CBOI_SS],"GRS","p");
   legend7->AddEntry(r3merged[1][KT3Bin][CBOI_SS],"#Omega_{0}","p");
   legend7->Draw("same");
-  TLatex *Specif_5 = new TLatex(0.3,0.2,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");
+  TLatex *Specif_5 = new TLatex(0.36,0.94,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");
   Specif_5->SetNDC();
   Specif_5->SetTextFont(TextFont);
   Specif_5->SetTextSize(SizeSpecif*SF1);
-  TLatex *Specif2_5 = new TLatex(0.17,0.2,"5-10%");
+  TLatex *Specif2_5 = new TLatex(0.5,0.1,"5-10%");
   Specif2_5->SetNDC();
   Specif2_5->SetTextFont(TextFont);
-  Specif2_5->SetTextSize(SizeLegend*SF1);
+  Specif2_5->SetTextSize(SizeLabel*SF1);
   Specif_5->Draw();
   Specif2_5->Draw();
   TString *KTString = new TString("");
-  if(KT3Bin==0) KTString->Append("0.16<K_{t,3}<0.3 GeV/c");
-  else KTString->Append("0.3<K_{t,3}<1.0 GeV/c");
-  TLatex *Kt3Name_3 = new TLatex(0.17,0.3,KTString->Data());
+  if(KT3Bin==0) KTString->Append("0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}");
+  else KTString->Append("0.3<#font[12]{K}_{T,3}<1.0 GeV/#font[12]{c}");
+  TLatex *Kt3Name_3 = new TLatex(0.36,0.22,KTString->Data());
   Kt3Name_3->SetNDC();
   Kt3Name_3->SetTextFont(TextFont);
-  Kt3Name_3->SetTextSize(SizeSpecif*SF1);
+  Kt3Name_3->SetTextSize(SizeLabel*SF1);
   Kt3Name_3->Draw("same");
   
   //
   //
   pad6->cd(2);
-  gPad->SetRightMargin(RightMargin); gPad->SetLeftMargin(0.12); gPad->SetBottomMargin(0.13);
+  SF_correction=0.97;
+  gPad->SetRightMargin(RightMargin); gPad->SetLeftMargin(0.13); gPad->SetBottomMargin(0.16);
   c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelFont(TextFont); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelFont(TextFont);
-  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelSize(SizeLabel*SF1); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelSize(SizeLabel*SF1);
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelSize(SizeLabel*SF1*SF_correction); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelSize(SizeLabel*SF1*SF_correction);
   c3merged[1][0][KT3Bin][CBOI_SS]->SetMarkerStyle(21);
   c3merged[1][1][KT3Bin][CBOI_SS]->SetMarkerStyle(25);
   c3merged[1][0][KT3Bin][CBOI_SS]->SetMarkerSize(1.5);
   c3merged[1][1][KT3Bin][CBOI_SS]->SetMarkerSize(1.7);
   //
-  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleOffset(1.2); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(1.2);
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleOffset(0.9); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(0.8);
   c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleFont(TextFont); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleFont(TextFont);
   c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleSize(SizeTitle*SF1); c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleSize(SizeTitle*SF1);
-  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitle("Q_{3} (GeV/c)"); 
-  c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("#bf{c}_{3}^{#pm#pm#mp}");
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitle("#font[12]{Q}_{3} (GeV/#font[12]{c})"); 
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("#font[12]{#bf{c}}_{3}^{#pm#pm#mp}");
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetYaxis()->SetNdivisions(504);
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetNdivisions(503);
   //
-  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetRangeUser(0,0.11);
-  TLegend *legend8 = new TLegend(.75,.7, .95,.85,NULL,"brNDC");//c3
+  c3merged[1][0][KT3Bin][CBOI_SS]->GetXaxis()->SetRangeUser(0,0.08);
+  c3merged[1][0][KT3Bin][CBOI_SS]->SetMaximum(1.08);
+  TLegend *legend8 = new TLegend(.8,.8, .98,.95,NULL,"brNDC");//c3
   legend8->SetBorderSize(0);
   legend8->SetTextFont(TextFont);
   legend8->SetTextSize(SizeLegend*SF1);
@@ -1766,12 +1827,12 @@ void Plot_plots(){
   
   //can6->SaveAs("SaveFigs/Fig_r3c3_CoulVar.eps");
   ///////////////////////////////////////////////////
-
+  // Lambda variation
   
   TCanvas *can7 = new TCanvas("can7", "can7",1800,300,600,600);// 680,300,600,600
   can7->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can7->SetFillColor(10);//10
+  can7->SetFillColor(0);//10
   can7->SetBorderMode(0);
   can7->SetBorderSize(2);
   can7->SetFrameFillColor(0);
@@ -1793,15 +1854,15 @@ void Plot_plots(){
   legend9->SetTextSize(SizeLegend*SF2);
   legend9->SetFillColor(0);
   
-  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.12); gPad->SetBottomMargin(0.1); gPad->SetTopMargin(0.01);
-  r3merged[0][KT3Bin][CBOI_SS]->SetMinimum(0.3); r3merged[0][KT3Bin][CBOI_SS]->SetMaximum(2.28);
+  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.13); gPad->SetBottomMargin(0.13); gPad->SetTopMargin(0.01);
+  r3merged[0][KT3Bin][CBOI_SS]->SetMinimum(r3MIN); r3merged[0][KT3Bin][CBOI_SS]->SetMaximum(r3MAX);
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelFont(TextFont); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelFont(TextFont);
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetLabelSize(SizeLabel*SF2); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetLabelSize(SizeLabel*SF2);
   //
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleFont(TextFont); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleFont(TextFont); 
   r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleSize(SizeTitle*SF2); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleSize(SizeTitle*SF2);
-  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitle("Q_{3} (GeV/c)"); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("r_{3}");
-  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleOffset(1.2); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(1.4); 
+  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitle("#font[12]{Q}_{3} (GeV/#font[12]{c})"); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitle("#font[12]{r}_{3}");
+  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetTitleOffset(0.9); r3merged[0][KT3Bin][CBOI_SS]->GetYaxis()->SetTitleOffset(1.05); 
   TH1D *r3LambdaVaried = (TH1D*)r3merged[0][KT3Bin][CBOI_SS]->Clone();
   r3LambdaVaried->SetMarkerStyle(25);
   TF1 *r3LambdaSysFit = new TF1("r3LambdaSysFit","pol1",0,0.1);
@@ -1811,7 +1872,8 @@ void Plot_plots(){
     double Q3 = (bin-0.5)*0.01;
     r3LambdaVaried->SetBinContent(bin, (1-r3LambdaSysFit->Eval(Q3)) * r3LambdaVaried->GetBinContent(bin));
   }
-  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetNdivisions(606);
+  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetNdivisions(503);
+  r3merged[0][KT3Bin][CBOI_SS]->GetXaxis()->SetRangeUser(0,0.08);
 
   r3merged[0][KT3Bin][CBOI_SS]->DrawCopy();
   r3LambdaVaried->DrawCopy("same");
@@ -1820,23 +1882,23 @@ void Plot_plots(){
   legend9->AddEntry(r3LambdaVaried,"#lambda=0.6","p");
   legend9->Draw("same");
   
-  TLatex *Specif_6 = new TLatex(0.3,0.2,"ALICE Pb-Pb #\sqrt{s_{NN}}=2.76 TeV");
+  TLatex *Specif_6 = new TLatex(0.36,0.94,"ALICE Pb-Pb #\sqrt{#font[12]{s}_{NN}}=2.76 TeV");
   Specif_6->SetNDC();
   Specif_6->SetTextFont(TextFont);
   Specif_6->SetTextSize(SizeSpecif*SF2);
-  TLatex *Specif2_6 = new TLatex(0.17,0.2,"5-10%");
+  TLatex *Specif2_6 = new TLatex(0.5,0.2,"5-10%");
   Specif2_6->SetNDC();
   Specif2_6->SetTextFont(TextFont);
   Specif2_6->SetTextSize(SizeLegend*SF2);
   Specif_6->Draw();
   Specif2_6->Draw();
   TString *KTString = new TString("");
-  if(KT3Bin==0) KTString->Append("0.16<K_{t,3}<0.3 GeV/c");
-  else KTString->Append("0.3<K_{t,3}<1.0 GeV/c");
-  TLatex *Kt3Name_4 = new TLatex(0.17,0.3,KTString->Data());
+  if(KT3Bin==0) KTString->Append("0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}");
+  else KTString->Append("0.3<#font[12]{K}_{T,3}<1.0 GeV/#font[12]{c}");
+  TLatex *Kt3Name_4 = new TLatex(0.36,0.28,KTString->Data());
   Kt3Name_4->SetNDC();
   Kt3Name_4->SetTextFont(TextFont);
-  Kt3Name_4->SetTextSize(SizeSpecif*SF2);
+  Kt3Name_4->SetTextSize(SizeLabel*SF2);
   Kt3Name_4->Draw("same");
 
   //can7->SaveAs("SaveFigs/Fig_r3_LamVar.eps");
@@ -1847,7 +1909,7 @@ void Plot_plots(){
   //*OutName += BOI_1;
   //OutName->Append(".png");
   //can6->SaveAs(OutName->Data());
+  
 
   
  
@@ -1920,7 +1982,7 @@ void Plot_plots(){
   tex4->SetTextColor();
   //tex4->Draw("same");
 
-  TLatex *tex5 = new TLatex(0.0005,.5,"Pb-Pb #sqrt{s_{NN}}=2.76 TeV: 0-10% Centrality");
+  TLatex *tex5 = new TLatex(0.0005,.5,"Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV: 0-10% Centrality");
   tex5->SetTextSize(.04);
   tex5->SetTextColor();
   //tex5->Draw("same");
index 47a51b0a82a4b537b6be1760e6f6e7b0a8ac69d3..7fb97899e7e42acf2456594c2c9bb2ee5c0b678a 100755 (executable)
 using namespace std;
 
 bool SaveFiles=kFALSE;
-const int ChProdBOI=0;// 0=SameCharge, 1=MixedCharge
-const int KT3Bin=1;// Kt3 bin. 0-1
+const int KT3Bin=0;// Kt3 bin. 0-1
 int FitType=1;// 0 (Gaussian), 1 (Edgeworth)
+bool p_pPb_Comp=0;
 bool AddedCC=kTRUE;// Charge Conjugate already added?
 //
 int MbinMaxPbPb=15;// 15
 int MbinMinpPb=11;// 13
-int MbinMinpp=14;// 14 
+int MbinMinpp=13;// 14 
 int MbinMinPbPb=0;// 0
 int MbinMaxpPb=18;// 18
 //
@@ -49,10 +49,10 @@ int MbinMaxpPb=18;// 18
 //
 const int MaxKT3Bins=2;
 int TextFont=42;// 63, or 42
-float SizeLabel=0.03;// 20(63 font), 0.08(42 font)
-float SizeLegend=0.03;// 
-float SizeTitle=0.03;// 
-float SizeSpecif=0.03;// 
+float SizeLabel=0.06;// 20(63 font), 0.08(42 font)
+float SizeLegend=0.05;// 
+float SizeTitle=0.06;// 
+float SizeSpecif=0.05;// 
 
 
 
@@ -73,7 +73,7 @@ void Plot_plotsTPR(){
 
   gStyle->SetOptStat(0);
   gStyle->SetOptDate(0);
-  gStyle->SetOptFit(0111);
+  //gStyle->SetOptFit(0111);
 
   ////////////////////////////////////
   // Get Nrec to Nch mapping
@@ -87,25 +87,37 @@ void Plot_plotsTPR(){
   TH2D *NrecMap;
   TList *MyList;
   //
-  NrecMapFile = new TFile("Results/NrecMapping_12a17a.root","READ");
+  NrecMapFile = new TFile("Results/NrecMapping_12a17a.root","READ");// standard (with P < 1.0 cut)
+  //NrecMapFile = new TFile("Results/Old_NrecMappingFiles/NrecMapping_12a17a.root","READ");// paper v1 file (without P < 1.0 cut)
   //NrecMapFile = new TFile("Results/NrecMapping_12a11a.root","READ");// MC variation
   //NrecMapFile = new TFile("Results/NrecMapping_12a17a_FB5and7overlap.root","READ");
   MyList=(TList*)NrecMapFile->Get("MyList");
   NrecMap = (TH2D*)MyList->FindObject("fNchTrueDist");
   for(int bin=1; bin<=2; bin++){// 1 to 2 (FB7),  1 to 1 (AMPT),  1 to 4 (FB5and7overlap)
     NrecMap->GetXaxis()->SetRangeUser(bin,bin);
-    if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    if(NrecMap->GetMean(2)>0) {
+      meanNchPbPb[bin-1] = NrecMap->GetMean(2);
+      //cout<<NrecMap->GetMean(2)<<"  "<<fabs(NrecMap->GetRMS(2))/NrecMap->GetMean(2)<<endl;
+    }
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = pow(NrecMap->GetMean(2),1/3.);
   }
   NrecMapFile->Close();
   //
-  NrecMapFile = new TFile("Results/NrecMapping_12a17e.root","READ");
+  NrecMapFile = new TFile("Results/NrecMapping_12a17e.root","READ");// standard (with P < 1.0 cut)
+  //NrecMapFile = new TFile("Results/Old_NrecMappingFiles/NrecMapping_12a17e.root","READ");// paper v1 file (without P < 1.0 cut)
   //NrecMapFile = new TFile("Results/NrecMapping_12a11b.root","READ");// MC variation
   //NrecMapFile = new TFile("Results/NrecMapping_12a17e_FB5and7overlap.root","READ");
   MyList=(TList*)NrecMapFile->Get("MyList");
   NrecMap = (TH2D*)MyList->FindObject("fNchTrueDist");
   for(int bin=3; bin<=10; bin++){// 3 to 10 (FB7),  2 to 3 (AMPT), 5 to 12 (FB5and7overlap)
     NrecMap->GetXaxis()->SetRangeUser(bin,bin);
-    if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    if(NrecMap->GetMean(2)>0) {
+      meanNchPbPb[bin-1] = NrecMap->GetMean(2);
+      //cout<<NrecMap->GetMean(2)<<"  "<<fabs(NrecMap->GetRMS(2))/NrecMap->GetMean(2)<<endl;
+    }
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = pow(NrecMap->GetMean(2),1/3.);
   }
   NrecMapFile->Close();
   //
@@ -120,36 +132,55 @@ void Plot_plotsTPR(){
   NrecMapFile->Close();*/
   //////////////////////////////////////////
   //
-  NrecMapFile = new TFile("Results/NrecMapping_12a17c.root","READ");
+  NrecMapFile = new TFile("Results/NrecMapping_12a17c.root","READ");// standard (with P < 1.0 cut)
+  //NrecMapFile = new TFile("Results/Old_NrecMappingFiles/NrecMapping_12a17c.root","READ");// paper v1 file (without P < 1.0 cut)
   //NrecMapFile = new TFile("Results/NrecMapping_12a11g.root","READ");// MC variation
   //NrecMapFile = new TFile("Results/NrecMapping_12a17c_FB5and7overlap.root","READ");
   MyList=(TList*)NrecMapFile->Get("MyList");
   NrecMap = (TH2D*)MyList->FindObject("fNchTrueDist");
   for(int bin=11; bin<=19; bin++){// 11 to 19 (FB7),  1 to 1 (AMPT), 13 to 19 (FB5and7overlap)
     NrecMap->GetXaxis()->SetRangeUser(bin,bin);
-    if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = log10(NrecMap->GetMean(2));
+    if(NrecMap->GetMean(2)>0) {
+      meanNchPbPb[bin-1] = NrecMap->GetMean(2);
+      //cout<<NrecMap->GetMean(2)<<"  "<<fabs(NrecMap->GetRMS(2))/NrecMap->GetMean(2)<<endl;
+    }    
+    //if(NrecMap->GetMean(2)>0) meanNchPbPb[bin-1] = pow(NrecMap->GetMean(2),1/3.);
   }
   NrecMapFile->Close();
+  //cout<<endl;
   //
-  NrecMapFile = new TFile("Results/PDC_13b2_efix_p1_R2.root","READ");
+  NrecMapFile = new TFile("Results/NrecMapping_13b2_efix_p1.root","READ");// standard (with P < 1.0 cut)
+  //NrecMapFile = new TFile("Results/PDC_13b2_efix_p1_R2.root","READ");// paper v1 file (without P < 1.0 cut)
   //NrecMapFile = new TFile("Results/NrecMapping_13b3.root","READ");// MC variation
   //NrecMapFile = new TFile("Results/NrecMapping_13b2_efix_p1_FB5and7overlap.root","READ");
   MyList=(TList*)NrecMapFile->Get("MyList");
   NrecMap = (TH2D*)MyList->FindObject("fNchTrueDist");
   for(int bin=10; bin<=20; bin++){
     NrecMap->GetXaxis()->SetRangeUser(bin,bin);
-    if(NrecMap->GetMean(2)>0) meanNchpPb[bin-1] = log10(NrecMap->GetMean(2));
+    //if(NrecMap->GetMean(2)>0) meanNchpPb[bin-1] = log10(NrecMap->GetMean(2));
+    if(NrecMap->GetMean(2)>0) {
+      meanNchpPb[bin-1] = NrecMap->GetMean(2);
+      //cout<<NrecMap->GetMean(2)<<"  "<<fabs(NrecMap->GetRMS(2))/NrecMap->GetMean(2)<<endl;
+    }
+    //if(NrecMap->GetMean(2)>0) meanNchpPb[bin-1] = pow(NrecMap->GetMean(2),1/3.);
   }
   NrecMapFile->Close();
   //
-  NrecMapFile = new TFile("Results/PDC_10f6a_R2.root","READ");
+  NrecMapFile = new TFile("Results/NrecMapping_10f6a.root","READ");// standard (with P < 1.0 cut)
+  //NrecMapFile = new TFile("Results/PDC_10f6a_R2.root","READ");// paper v1 file (without P < 1.0 cut)
   //NrecMapFile = new TFile("Results/NrecMapping_10f6.root","READ");// MC variation
   //NrecMapFile = new TFile("Results/NrecMapping_10f6a_FB5and7overlap.root","READ");
   MyList=(TList*)NrecMapFile->Get("MyList");
   NrecMap = (TH2D*)MyList->FindObject("fNchTrueDist");
   for(int bin=10; bin<=20; bin++){
     NrecMap->GetXaxis()->SetRangeUser(bin,bin);
-    if(NrecMap->GetMean(2)>0) meanNchpp[bin-1] = log10(NrecMap->GetMean(2));
+    //if(NrecMap->GetMean(2)>0) meanNchpp[bin-1] = log10(NrecMap->GetMean(2));
+    if(NrecMap->GetMean(2)>0) {
+      meanNchpp[bin-1] = NrecMap->GetMean(2);
+      //cout<<NrecMap->GetMean(2)<<"  "<<fabs(NrecMap->GetRMS(2))/NrecMap->GetMean(2)<<endl;
+    }
+    //if(NrecMap->GetMean(2)>0) meanNchpp[bin-1] = pow(NrecMap->GetMean(2),1/3.);
   }
   NrecMapFile->Close();
   
@@ -157,7 +188,7 @@ void Plot_plotsTPR(){
   //cout<<"+++++++++++++++"<<endl;
   //for(int i=0; i<20; i++) cout<<pow(10,meanNchpPb[i])<<endl;
   //cout<<"+++++++++++++++"<<endl;
-  //for(int i=0; i<20; i++) cout<<pow(10,meanNchpp[i])<<endl;
+  //for(int i=0; i<20; i++) cout<<meanNchpp[i]<<endl;
 
   TFile *ExRangeFile=new TFile("Results/ExtendedQ3rangeM0.root","READ");
   TList *ExList=(TList*)ExRangeFile->Get("MyList");
@@ -200,7 +231,7 @@ void Plot_plotsTPR(){
   TH1D *C3_Sys[3][2][2][3][20];// CollType, Real/MonteCarlo, SC/MC, EDbin, cb
   TH1D *c3_Sys[3][2][2][3][20];// CollType, Real/MonteCarlo, SC/MC, EDbin, cb
   TF1 *c3_fit[3][2][3][20];// CollType, Gauss/EW, EDbin, cb
-  TMinuit *Min[3][2][3][20];// CollType, +/-, EDbin, cb
+  //TMinuit *Min[3][2][3][20];// CollType, +/-, EDbin, cb
   TH1D *Parameters_c3[3][2][3][5];// CollType, Gaussian/EW, EDbin, Parameter#
   //char *labels[20]={"1050-2000","850-1050","700-850","600-700","500-600","400-500","320-400","260-320","200-260","150-200","100-150","70-100","50-70","40-50","30-40","20-30","15-20","10-15","5-10","0-5"};
   for(int ct=0; ct<3; ct++){
@@ -217,17 +248,18 @@ void Plot_plotsTPR(){
          *name_c3 += ft;
          *name_c3 += kt3;
          *name_c3 += par;
-         //Parameters_c3[ct][par] = new TH1D(name->Data(),"",20,0.5,20.5);
-         //for(int cb=0; cb<20; cb++) Parameters_c3[ct][par]->GetXaxis()->SetBinLabel(cb+1,labels[cb]);
-         Parameters_C2[ct][ft][kt3][par] = new TH1D(name_C2->Data(),"",2900,0.6,3.4);// 2900,0.6,3.4
-         Parameters_c3[ct][ft][kt3][par] = new TH1D(name_c3->Data(),"",2900,0.6,3.4);
-         
+         //Parameters_C2[ct][ft][kt3][par] = new TH1D(name_C2->Data(),"",2900,0.6,3.4);// log10(Nch)
+         //Parameters_c3[ct][ft][kt3][par] = new TH1D(name_c3->Data(),"",2900,0.6,3.4);// log10(Nch)
+         Parameters_C2[ct][ft][kt3][par] = new TH1D(name_C2->Data(),"",30000,1,3001);// Nch
+         Parameters_c3[ct][ft][kt3][par] = new TH1D(name_c3->Data(),"",30000,1,3001);// Nch
+         //Parameters_C2[ct][ft][kt3][par] = new TH1D(name_C2->Data(),"",3000,1,14.4);// Nch^(1/3)
+         //Parameters_c3[ct][ft][kt3][par] = new TH1D(name_c3->Data(),"",3000,1,14.4);// Nch^(1/3)
        }
       }
     }
   }
   
-  TH1D *RadiiC2pp_Published = new TH1D("RadiiC2pp_Published","",2900,0.6,3.4);
+  TH1D *RadiiC2pp_Published = new TH1D("RadiiC2pp_Published","",3000,1.0,3001);
   //
   double N_1 = 0, N_1_e=0;
   double lambda_1 = 0, lambda_1_e=0;
@@ -270,7 +302,7 @@ void Plot_plotsTPR(){
              TFile *file=new TFile(name3->Data(),"READ");
              //
              if(ChComb==0 && dt==0){
-               Min[ct][ch][KT3][cb]=(TMinuit*)file->Get("MyMinuit_c3");
+               //Min[ct][ch][KT3][cb]=(TMinuit*)file->Get("MyMinuit_c3");
                //Min[ct][ch][KT3][cb]->SetDirectory(0);
              }
                
@@ -286,13 +318,13 @@ void Plot_plotsTPR(){
                
                C3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetRangeUser(0,0.5);
                C3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetLabelFont(TextFont); C3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetLabelFont(TextFont); 
-               C3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetTitleOffset(1.2);
-               C3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
+               //C3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetTitleOffset(1.2);
+               //C3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
                C3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleFont(TextFont);
                c3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetRangeUser(0,0.5);
                c3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetLabelFont(TextFont); c3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetLabelFont(TextFont); 
-               c3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetTitleOffset(1.2);
-               c3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
+               //c3[ct][dt][ChComb][KT3][cb]->GetXaxis()->SetTitleOffset(1.2);
+               //c3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleOffset(1.2);
                c3[ct][dt][ChComb][KT3][cb]->GetYaxis()->SetTitleFont(TextFont);
                if(ct==0) {
                  C3[ct][dt][ChComb][KT3][cb]->SetMarkerColor(1); C3[ct][dt][ChComb][KT3][cb]->SetLineColor(1);
@@ -391,6 +423,8 @@ void Plot_plotsTPR(){
              }
             
              if(AddedCC && dt==0){
+               if(ct==0 || ct==1) c3[ct][dt][ChComb][KT3][cb]->SetMarkerSize(1.12*C3[ct][dt][ChComb][KT3][cb]->GetMarkerSize());
+               else c3[ct][dt][ChComb][KT3][cb]->SetMarkerSize(1.2*C3[ct][dt][ChComb][KT3][cb]->GetMarkerSize());
                //Min[ct][0][KT3][cb]->GetParameter(0,N_1,N_1_e);
                //Min[ct][0][KT3][cb]->GetParameter(1,lambda_1,lambda_1_e);
                //Min[ct][0][KT3][cb]->GetParameter(2,radius_1,radius_1_e);
@@ -463,11 +497,11 @@ void Plot_plotsTPR(){
                  for(int i=1; i<=c3[ct][0][ChComb][KT3][cb]->GetNbinsX(); i++) {
                    float Q3=(i-0.5)*0.01;
                    // SameCharge
-                   C3_Sys[ct][0][0][KT3][cb]->SetBinError(i, 0.02 * C3_Sys[ct][0][0][KT3][cb]->GetBinContent(i));
-                   c3_Sys[ct][0][0][KT3][cb]->SetBinError(i, MixedChargeSysFit->Eval(Q3)-1.0);
+                   C3_Sys[ct][0][0][KT3][cb]->SetBinError(i, 0.01 * C3_Sys[ct][0][0][KT3][cb]->GetBinContent(i));
+                   c3_Sys[ct][0][0][KT3][cb]->SetBinError(i, sqrt(pow(MixedChargeSysFit->Eval(Q3)-1.0,2) + pow(0.1*(c3_Sys[ct][0][0][KT3][cb]->GetBinContent(i)-1.0),2)));// residue + lambda undilution variation (0.7 to 0.65)
                    // MixedCharge
-                   C3_Sys[ct][0][1][KT3][cb]->SetBinError(i, 0.02 * C3_Sys[ct][0][1][KT3][cb]->GetBinContent(i));
-                   c3_Sys[ct][0][1][KT3][cb]->SetBinError(i, 0.02 * c3_Sys[ct][0][1][KT3][cb]->GetBinContent(i));
+                   C3_Sys[ct][0][1][KT3][cb]->SetBinError(i, 0.01 * C3_Sys[ct][0][1][KT3][cb]->GetBinContent(i));// correlation function uncertainty
+                   c3_Sys[ct][0][1][KT3][cb]->SetBinError(i, sqrt(pow(0.01 * c3_Sys[ct][0][1][KT3][cb]->GetBinContent(i),2) + pow(0.1*(c3_Sys[ct][0][1][KT3][cb]->GetBinContent(i)-1.0),2)));// correlation function uncertainty + lambda undilution variation (0.7 to 0.65)
                  }
                }
                C3_Sys[ct][0][ChComb][KT3][cb]->SetDirectory(0); c3_Sys[ct][0][ChComb][KT3][cb]->SetDirectory(0);
@@ -519,14 +553,14 @@ void Plot_plotsTPR(){
              if(par==1) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("#lambda or #lambda_{3}");
              //if(par==2) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("R_{inv,3} (fm)");
              if(par==2) {
-               if(FitType==0) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("R_{inv,2} or R_{inv,3} (fm)");
-               else Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("R^{Ew}_{inv,2} or R^{Ew}_{inv,3} (fm)");
+               if(FitType==0) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("#font[12]{R}_{inv,2} or #font[12]{R}_{inv,3} (fm)");
+               else Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("#font[12]{R^{E_{w}}}_{inv,2} or #font[12]{R^{E_{w}}}_{inv,3} (fm)");
              }         
              if(par==3) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("#kappa_{3}");
              if(par==4) Parameters_c3[ct][ft][KT3][par]->GetYaxis()->SetTitle("#kappa_{4}");
-             Parameters_c3[ct][ft][KT3][par]->GetXaxis()->SetTitle("log_{10}(N_{ch})");
-           
-             
+             //Parameters_c3[ct][ft][KT3][par]->GetXaxis()->SetTitle("log_{10}(N_{ch})");
+             Parameters_c3[ct][ft][KT3][par]->GetXaxis()->SetTitle("N_{ch}");
+             //Parameters_c3[ct][ft][KT3][par]->GetXaxis()->SetTitle("N_{ch}^{1/3}");
            }// par
          }// KT3
        }// ft
@@ -551,7 +585,7 @@ void Plot_plotsTPR(){
   TCanvas *can2 = new TCanvas("can2", "can2",10,0,600,600);// 11,53,700,500
   can2->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can2->SetFillColor(10);//10
+  can2->SetFillColor(0);//10
   can2->SetBorderMode(0);
   can2->SetBorderSize(2);
   can2->SetFrameFillColor(0);
@@ -591,11 +625,11 @@ void Plot_plotsTPR(){
   c3[2][0][0][0][Mb_pp]->SetMinimum(0.9);
   c3[2][0][0][0][Mb_pp]->Draw();
   //legend3->AddEntry(c3[2][0][0][Mb_pp],"N_{ch} = 9#pm0.2, pp #sqrt{s}=7 TeV","p");
-  //legend3->AddEntry(c3[1][0][0][Mb_pPb],"N_{ch} = 59#pm2, p-Pb #sqrt{s_{NN}}=5.02 TeV","p");
-  //legend3->AddEntry(c3[0][0][0][Mb_PbPb],"N_{ch} = 1922#pm135, Pb-Pb #sqrt{s_{NN}}=2.76 TeV","p");
+  //legend3->AddEntry(c3[1][0][0][Mb_pPb],"N_{ch} = 59#pm2, p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV","p");
+  //legend3->AddEntry(c3[0][0][0][Mb_PbPb],"N_{ch} = 1922#pm135, Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV","p");
   legend3->AddEntry(c3[2][0][0][0][Mb_pp],"Low N_{ch}, pp #sqrt{#font[12]{s}}=7 TeV","p");
-  legend3->AddEntry(c3[1][0][0][0][Mb_pPb],"Mid N_{ch}, p-Pb #sqrt{#font[12]{s_{NN}}}=5.02 TeV","p");
-  legend3->AddEntry(c3[0][0][0][0][Mb_PbPb],"High N_{ch}, Pb-Pb #sqrt{#font[12]{s_{NN}}}=2.76 TeV","p");
+  legend3->AddEntry(c3[1][0][0][0][Mb_pPb],"Mid N_{ch}, p-Pb #sqrt{#font[12]{#font[12]{s}_{NN}}}=5.02 TeV","p");
+  legend3->AddEntry(c3[0][0][0][0][Mb_PbPb],"High N_{ch}, Pb-Pb #sqrt{#font[12]{#font[12]{s}_{NN}}}=2.76 TeV","p");
   //
   //TH1D *FillerHist = new TH1D("FillerHist","",50,0,0.5);
   for(int i=1; i<=50; i++) {
@@ -640,24 +674,122 @@ void Plot_plotsTPR(){
 
   if(SaveFiles) can2->SaveAs("ThreePionCorrelation_Evolution.eps");
   */
+
+
+  
+  ////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////
+  // K0s removal plot
+  TCanvas *can1 = new TCanvas("can1", "can1",10,700,600,600);// 11,53,700,500
+  can1->SetHighLightColor(2);
+  gStyle->SetOptFit(0111);
+  can1->SetFillColor(0);//10
+  can1->SetBorderMode(0);
+  can1->SetBorderSize(2);
+  can1->SetFrameFillColor(0);
+  can1->SetFrameBorderMode(0);
+  can1->SetFrameBorderMode(0);
+  can1->cd();
+  TPad *pad1 = new TPad("pad1","pad1",0.,0.,1.,1.);
+  gPad->SetTickx();
+  gPad->SetTicky();
+  pad1->SetTopMargin(0.0);//0.05
+  pad1->SetRightMargin(0.0);//3e-2
+  pad1->SetBottomMargin(0.0);//0.12
+  pad1->SetLeftMargin(0.0);
+  pad1->Draw();
+  pad1->cd();
+  TLegend *legend1 = new TLegend(.2,.65, .55,.85,NULL,"brNDC");//.45 or .4 for x1
+  legend1->SetBorderSize(0);
+  legend1->SetFillColor(0);
+  legend1->SetTextFont(TextFont);
+  legend1->SetTextSize(SizeLegend);
+
+  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.14);
+  gPad->SetBottomMargin(0.14); gPad->SetTopMargin(0.02);
+  gPad->SetTickx(); gPad->SetTicky();
+  // pp, M18
+  double points_K0s_C3[50]={1.44542, 1.33366, 1.25518, 1.21051, 1.20484, 1.18742, 1.18246, 1.17024, 1.16383, 1.1555, 1.15536, 1.15272, 1.14571, 1.14822, 1.14708, 1.14066, 1.14133, 1.13866, 1.13755, 1.13308, 1.1386, 1.13821, 1.13429, 1.13707, 1.13294, 1.13545, 1.13929, 1.13374, 1.13546, 1.13205, 1.12846, 1.1281, 1.12947, 1.13162, 1.13822, 1.13626, 1.13912, 1.14379, 1.15594, 1.19387, 1.29685, 1.21203, 1.14452, 1.14288, 1.14161, 1.1408, 1.13796, 1.13661, 1.13565, 1.13312};
+  double points_K0s_C3_e[50]={0.0270571, 0.00940436, 0.0058043, 0.00430829, 0.00355541, 0.00306969, 0.00275566, 0.00253068, 0.00236966, 0.00224498, 0.00215682, 0.00208189, 0.00201555, 0.00196896, 0.00192381, 0.0018782, 0.00184374, 0.0018119, 0.00178103, 0.00175109, 0.00173313, 0.00171119, 0.00168873, 0.00167507, 0.00165525, 0.00164399, 0.00163488, 0.00161686, 0.00160668, 0.00159163, 0.00157479, 0.00155996, 0.00154251, 0.00152405, 0.00150469, 0.00147687, 0.00144939, 0.00142223, 0.0013988, 0.00139214, 0.00142684, 0.0013476, 0.00128368, 0.00126468, 0.0012497, 0.00123827, 0.001228, 0.00122253, 0.00121921, 0.00121782};
+  double points_K0s_c3[50]={0.965148, 1.05077, 0.983133, 0.972848, 0.993922, 0.994064, 1.00618, 0.993434, 1.00322, 0.999747, 0.982221, 1.00029, 0.992184, 0.993566, 1.00007, 0.995263, 0.998559, 0.987037, 0.987919, 0.991035, 0.991488, 0.99592, 0.99677, 0.990709, 0.990352, 0.994706, 0.99606, 0.998525, 0.994121, 0.986511, 0.991009, 0.990309, 1.00161, 0.997478, 1.00117, 0.989375, 0.996592, 0.990832, 0.998989, 0.995124, 0.996301, 1.00189, 0.995304, 0.992511, 0.994084, 0.994777, 1.00074, 0.996959, 0.998713, 0.996205};
+  double points_K0s_c3_e[50]={0.0630244, 0.0223583, 0.0140589, 0.0105446, 0.00871274, 0.00755392, 0.00678715, 0.00625387, 0.00586333, 0.00556614, 0.00535136, 0.00516553, 0.00501148, 0.00489185, 0.00478054, 0.00467542, 0.00458851, 0.00451377, 0.00443821, 0.00436787, 0.00431762, 0.00426282, 0.0042107, 0.00417461, 0.00412901, 0.00409783, 0.00407137, 0.0040317, 0.00400527, 0.00397212, 0.00393349, 0.00389671, 0.00385012, 0.00380258, 0.00374821, 0.0036816, 0.0036096, 0.00353852, 0.00346903, 0.00342075, 0.00342477, 0.00329675, 0.0031932, 0.00314748, 0.00311129, 0.00308337, 0.00305968, 0.00304743, 0.00303989, 0.00303859};
+  TH1D *K0s_C3=new TH1D("K0s_C3","",50,0,0.5);
+  TH1D *K0s_c3=new TH1D("K0s_c3","",50,0,0.5);
+  for(int i=0; i<50; i++){
+    K0s_C3->SetBinContent(i+1, points_K0s_C3[i]);
+    K0s_C3->SetBinError(i+1, points_K0s_C3_e[i]);
+    K0s_c3->SetBinContent(i+1, points_K0s_c3[i]);
+    K0s_c3->SetBinError(i+1, points_K0s_c3_e[i]);
+  }
+  K0s_c3->SetMarkerStyle(20);
+  K0s_c3->SetMarkerColor(4);
+  K0s_C3->SetMarkerStyle(24);
+  K0s_C3->SetMarkerColor(4);
+  K0s_c3->SetMarkerSize(K0s_C3->GetMarkerSize() * 1.12);
+  K0s_C3->SetMinimum(0.92);
+  K0s_C3->GetXaxis()->SetTitle("#font[12]{q_{31}^{#pm#mp}} (GeV/#font[12]{c})");
+  K0s_C3->GetYaxis()->SetTitle("#font[12]{C_{3}} or #font[12]{#bf{c}_{3}}"); 
+  K0s_C3->GetXaxis()->SetTitleOffset(1.05); K0s_C3->GetYaxis()->SetTitleOffset(1.12);
+  K0s_C3->GetXaxis()->SetTitleSize(SizeTitle); K0s_C3->GetYaxis()->SetTitleSize(SizeTitle);
+  K0s_C3->GetXaxis()->SetLabelSize(SizeTitle); K0s_C3->GetYaxis()->SetLabelSize(SizeTitle);
+  K0s_C3->GetXaxis()->SetNdivisions(404);
+  K0s_C3->GetYaxis()->SetNdivisions(404);
+  //K0s_C3->GetXaxis()->SetRangeUser(-0.001,0.5);
+
+  K0s_C3->Draw();
+  // Sys errors
+  TH1D *Sys_K0s_C3=(TH1D*)K0s_C3->Clone();
+  TH1D *Sys_K0s_c3=(TH1D*)K0s_c3->Clone();
+  Sys_K0s_C3->SetMarkerSize(0); Sys_K0s_c3->SetMarkerSize(0);
+  Sys_K0s_C3->SetFillColor(kBlue-10); Sys_K0s_c3->SetFillColor(kBlue-10);
+  Sys_K0s_C3->SetFillStyle(1000); Sys_K0s_c3->SetFillStyle(1000);
+  for(int i=0; i<Sys_K0s_C3->GetNbinsX(); i++) { 
+    Sys_K0s_C3->SetBinError(i+1, 0.01 * Sys_K0s_C3->GetBinContent(i+1));
+    Sys_K0s_c3->SetBinError(i+1, sqrt(pow(0.01 * Sys_K0s_c3->GetBinContent(i+1),2) + pow(0.1*(Sys_K0s_c3->GetBinContent(i+1)-1),2)));
+  }
+  Sys_K0s_C3->Draw("E2 same");
+  Sys_K0s_c3->Draw("E2 same");
+  K0s_C3->Draw("same");
+  K0s_c3->Draw("same");
+
+  legend1->AddEntry(K0s_C3,"#font[12]{C_{3}^{#pm#pm#mp}} projection","p");
+  legend1->AddEntry(K0s_c3,"#font[12]{#bf{c}_{3}^{#pm#pm#mp}} projection","p");
+  legend1->Draw("same");
+  
+  TLatex *Specif_qRange = new TLatex(0.25,0.6,"0.2 < #font[12]{q_{12}^{#pm#pm},q_{23}^{#pm#mp}} < 0.5 GeV/#font[12]{c}");
+  Specif_qRange->SetNDC();
+  Specif_qRange->SetTextFont(42);
+  Specif_qRange->SetTextSize(SizeSpecif);
+  Specif_qRange->Draw("same");
+  TLatex *Specif_System = new TLatex(0.25,0.9,"pp #sqrt{#font[12]{s}}=7 TeV, #LTN_{ch}#GT = 8.0 #pm 0.4");
+  Specif_System->SetNDC();
+  Specif_System->SetTextFont(42);
+  Specif_System->SetTextSize(SizeSpecif);
+  Specif_System->Draw("same");
+  
+
+
+
+
   ////////////////////////////////////////////////////
   ////////////////////////////////////////////////////
   // Radii and lambda plot
+  float SF_2panel=1.2;
   float RadiiC2ppPubPoints[2][8]={{0.88,1.09,1.23,1.28,1.34,1.37,1.42,1.48},{0.86,1.06,1.16,1.23,1.23,1.28,1.32,1.38}};
   float RadiiC2ppPubPoints_e[2][8]={{0.058,0.064,0.071,0.071,0.078,0.078,0.086,0.098},{0.12,0.12,0.13,0.13,0.13,0.13,0.13,0.13}};
   float MeanPubNch[8]={6.98,14.95,19.68,24.68,29.38,33.95,38.46,42.66};
-  float SF=1.3;
+  
   TCanvas *can3 = new TCanvas("can3", "can3",1000,0,600,900);// 11,53,700,500
   can3->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can3->SetFillColor(10);//10
+  can3->SetFillColor(0);//10
   can3->SetBorderMode(0);
   can3->SetBorderSize(2);
   can3->SetFrameFillColor(0);
   can3->SetFrameBorderMode(0);
   can3->SetFrameBorderMode(0);
   can3->cd();
-  float PadLeftMargin=0.06, PadBottomMargin=0.;
+  float PadLeftMargin=0.0, PadBottomMargin=0.;
   TPad *pad3 = new TPad("pad3","pad3",PadLeftMargin,PadBottomMargin,1.,1.);
   gPad->SetTickx();
   gPad->SetTicky();
@@ -668,34 +800,33 @@ void Plot_plotsTPR(){
   pad3->Divide(1,2,0,0);
   pad3->Draw();
   pad3->cd();
-  TLegend *legend4 = new TLegend(.1,.65, .5,.95,NULL,"brNDC");//.45 or .4 for x1
+  TLegend *legend4 = new TLegend(.15,.65, .55,.95,NULL,"brNDC");//.45 or .4 for x1
   legend4->SetBorderSize(0);
   legend4->SetFillColor(0);
   legend4->SetTextFont(TextFont);
   legend4->SetTextSize(SizeLegend);
   //
   pad3->cd(1);
-  gPad->SetLeftMargin(0.05);
+  gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.01);
-  gPad->SetTopMargin(0.02);
-  gPad->SetBottomMargin(0.1);
-  //gPad->SetRightMargin(RightMargin); gPad->SetLeftMargin(0.12);
-  //gPad->SetBottomMargin(0.1);
+  gPad->SetTopMargin(0.01);
+  gPad->SetBottomMargin(0.16);
   gPad->SetTickx(); gPad->SetTicky();
+  gPad->SetLogx();
   //gPad->SetGridx(); gPad->SetGridy();
   TH1D *RadiiPbPb=(TH1D*)Parameters_c3[0][FitType][KT3Bin][2]->Clone();
   TH1D *RadiipPb=(TH1D*)Parameters_c3[1][FitType][KT3Bin][2]->Clone();
   TH1D *Radiipp=(TH1D*)Parameters_c3[2][FitType][KT3Bin][2]->Clone();
   RadiiPbPb->GetXaxis()->SetLabelFont(TextFont); RadiiPbPb->GetYaxis()->SetLabelFont(TextFont); 
-  RadiiPbPb->GetXaxis()->SetLabelSize(SizeLabel*SF); RadiiPbPb->GetYaxis()->SetLabelSize(SizeLabel*SF);
+  RadiiPbPb->GetXaxis()->SetLabelSize(SizeLabel*SF_2panel); RadiiPbPb->GetYaxis()->SetLabelSize(SizeLabel*SF_2panel);
   RadiiPbPb->GetXaxis()->SetNdivisions(808);
-  RadiiPbPb->GetXaxis()->SetTitleOffset(1.1);//1.3
+  RadiiPbPb->GetXaxis()->SetTitleOffset(0.95);//1.3
   RadiiPbPb->GetYaxis()->SetTitleOffset(100);//1.1
-  RadiiPbPb->GetXaxis()->SetTitleFont(TextFont); RadiiPbPb->GetXaxis()->SetTitleSize(SizeTitle*SF);
-  RadiiPbPb->GetYaxis()->SetTitleFont(TextFont); RadiiPbPb->GetYaxis()->SetTitleSize(SizeTitle*SF);
-  RadiiPbPb->SetMinimum(0); RadiiPbPb->SetMaximum(11.5);
-  
-
+  RadiiPbPb->GetXaxis()->SetTitleFont(TextFont); RadiiPbPb->GetXaxis()->SetTitleSize(SizeTitle*SF_2panel);
+  RadiiPbPb->GetYaxis()->SetTitleFont(TextFont); RadiiPbPb->GetYaxis()->SetTitleSize(SizeTitle*SF_2panel);
+  RadiiPbPb->SetMinimum(0); RadiiPbPb->SetMaximum(11.9);
+  //gStyle->SetErrorX(0);
+  RadiiPbPb->GetXaxis()->SetRangeUser(3,3000);
   RadiiPbPb->Draw();
   //
   double xAxis_e[20]={0};
@@ -707,40 +838,50 @@ void Plot_plotsTPR(){
   double yAxispp_e[20]={0};
   
   
-  TF1 *QrangeSys_c3=new TF1("QrangeSys_c3","0.1 - .07*(x/3.3)",0,4);
+  //TF1 *QrangeSys_c3=new TF1("QrangeSys_c3","0.1 - .07*(x/3.3)",0,4);// old method
+  // Old method for Rsys was Sys = sqrt(pow(QrangeSys_c3->Eval(meanNchPbPb[cb])*RadiiPbPb->GetBinContent(binPbPb),2) + pow(0.05,2)); 
+  // same for pp and pPb but with proper Nch
+  double SysPercent_PbPb[2][4]={{12,10,11,16},{5,7,5,10}};// Gauss/EW, parameter#(Rinv2, Rinv3, lambda, lambda_3)
+  double SysPercent_pPb[2][4]={{15,10,6,10},{6,2,1,4}};// Gauss/EW, parameter#(Rinv2, Rinv3, lambda, lambda_3)
+  double SysPercent_pp[2][4]={{11,9,2,5},{12,5,2,5}};// Gauss/EW, parameter#(Rinv2, Rinv3, lambda, lambda_3)
   for(int cb=0; cb<20; cb++){
     int binPbPb = RadiiPbPb->GetXaxis()->FindBin(meanNchPbPb[cb]);
     int binpPb = RadiipPb->GetXaxis()->FindBin(meanNchpPb[cb]);
     int binpp = Radiipp->GetXaxis()->FindBin(meanNchpp[cb]);
-    double RsysPbPb = sqrt(pow(QrangeSys_c3->Eval(meanNchPbPb[cb])*RadiiPbPb->GetBinContent(binPbPb),2) + pow(0.05,2));
-    double RsyspPb = sqrt(pow(QrangeSys_c3->Eval(meanNchpPb[cb])*RadiipPb->GetBinContent(binpPb),2) + pow(0.05,2));
-    double Rsyspp = sqrt(pow(QrangeSys_c3->Eval(meanNchpp[cb])*Radiipp->GetBinContent(binpp),2) + pow(0.05,2));
+    double RsysPbPb = 0.01*sqrt(pow(SysPercent_PbPb[FitType][1],2) + pow(1,2)) *  RadiiPbPb->GetBinContent(binPbPb);// fit Variation + MRC 
+    double RsyspPb = 0.01*sqrt(pow(SysPercent_pPb[FitType][1],2) + pow(1,2)) *  RadiipPb->GetBinContent(binpPb);// fit Variation + MRC 
+    double Rsyspp = 0.01*sqrt(pow(SysPercent_pp[FitType][1],2) + pow(1,2)) *  Radiipp->GetBinContent(binpp);// fit Variation + MRC 
     if(RadiiPbPb->GetBinContent(binPbPb)==0) {yAxisPbPb[cb]=100; yAxisPbPb_e[cb]=100;}
     else {yAxisPbPb[cb]=RadiiPbPb->GetBinContent(binPbPb); yAxisPbPb_e[cb]=RsysPbPb;}
     if(RadiipPb->GetBinContent(binpPb)==0) {yAxispPb[cb]=100; yAxispPb_e[cb]=100;}
     else {yAxispPb[cb]=RadiipPb->GetBinContent(binpPb); yAxispPb_e[cb]=RsyspPb;}
     if(Radiipp->GetBinContent(binpp)==0) {yAxispp[cb]=100; yAxispp_e[cb]=100;}
     else {yAxispp[cb]=Radiipp->GetBinContent(binpp); yAxispp_e[cb]=Rsyspp;}
-    // Nch systematics
-    // old method: log10((0.93 + 0.05*(cb/19))*pow(10,<Nch>)), 7% discrepancy max for central PbPb, 2% for pp and pPb.
-    // Now 5% for all bins
-    if(cb<13) xAxis_e[cb]=fabs(meanNchPbPb[cb] - log10((0.95)*pow(10,meanNchPbPb[cb])));
-    else xAxis_e[cb]=fabs(meanNchpPb[cb] - log10((0.95)*pow(10,meanNchpPb[cb])));
+    //cout<<RadiipPb->GetBinContent(binpPb)<<"  "<<Radiipp->GetBinContent(binpp)<<endl;
+    // X-axis systematics 5% for all bins
+    //if(cb<13) xAxis_e[cb]=fabs(meanNchPbPb[cb] - log10((0.95)*pow(10,meanNchPbPb[cb])));
+    //else xAxis_e[cb]=fabs(meanNchpPb[cb] - log10((0.95)*pow(10,meanNchpPb[cb])));
+    if(cb<13) xAxis_e[cb]=fabs(meanNchPbPb[cb] - (0.95)*meanNchPbPb[cb]);
+    else xAxis_e[cb]=fabs(meanNchpPb[cb] - (0.95)*meanNchpPb[cb]);
   }
   TGraphErrors *grRadiiSys_PbPb=new TGraphErrors(20,meanNchPbPb,yAxisPbPb,xAxis_e,yAxisPbPb_e);
   TGraphErrors *grRadiiSys_pPb=new TGraphErrors(20,meanNchpPb,yAxispPb,xAxis_e,yAxispPb_e);
   TGraphErrors *grRadiiSys_pp=new TGraphErrors(20,meanNchpp,yAxispp,xAxis_e,yAxispp_e);
   grRadiiSys_pp->SetMarkerSize(0); grRadiiSys_pp->SetFillStyle(1000); grRadiiSys_pp->SetFillColor(kBlue-10);
   grRadiiSys_pPb->SetMarkerSize(0); grRadiiSys_pPb->SetFillStyle(1000); grRadiiSys_pPb->SetFillColor(kRed-10);
   grRadiiSys_PbPb->SetMarkerSize(0); grRadiiSys_PbPb->SetFillStyle(1000); grRadiiSys_PbPb->SetFillColor(kGray);
-  
+  grRadiiSys_pp->SetMarkerColor(kBlue-10); grRadiiSys_pp->SetMarkerColor(kRed-10); grRadiiSys_pp->SetMarkerColor(kGray);
   // C2 
   TH1D *RadiiC2PbPb=(TH1D*)Parameters_C2[0][FitType][KT3Bin][2]->Clone();
   TH1D *RadiiC2pPb=(TH1D*)Parameters_C2[1][FitType][KT3Bin][2]->Clone();
   TH1D *RadiiC2pp=(TH1D*)Parameters_C2[2][FitType][KT3Bin][2]->Clone();
-  
+  RadiiC2pp_Published->SetMarkerStyle(30);
+  if(FitType==0) RadiiC2pp->SetMarkerStyle(30);
+
   for(int mbin=0; mbin<8; mbin++){
-    int bin = RadiiC2pp_Published->GetXaxis()->FindBin(log10(MeanPubNch[mbin])); 
+    //int bin = RadiiC2pp_Published->GetXaxis()->FindBin(log10(MeanPubNch[mbin]));
+    int bin = RadiiC2pp_Published->GetXaxis()->FindBin(MeanPubNch[mbin]);
     RadiiC2pp_Published->SetBinContent(bin, RadiiC2ppPubPoints[KT3Bin][mbin]); 
     RadiiC2pp_Published->SetBinError(bin, RadiiC2ppPubPoints_e[KT3Bin][mbin]);
   }  
@@ -749,42 +890,47 @@ void Plot_plotsTPR(){
     int binPbPb = RadiiC2PbPb->GetXaxis()->FindBin(meanNchPbPb[cb]);
     int binpPb = RadiiC2pPb->GetXaxis()->FindBin(meanNchpPb[cb]);
     int binpp = RadiiC2pp->GetXaxis()->FindBin(meanNchpp[cb]);
-    double RsysPbPb = sqrt(pow(0.08*RadiiC2PbPb->GetBinContent(binPbPb),2) + pow(0.02*RadiiC2PbPb->GetBinContent(binPbPb),2));// 8% fit range, 2% MRC
-    double RsyspPb = sqrt(pow(0.08*RadiiC2pPb->GetBinContent(binpPb),2) + pow(0.02*RadiiC2pPb->GetBinContent(binpPb),2));
-    double Rsyspp = sqrt(pow(0.08*RadiiC2pp->GetBinContent(binpp),2) + pow(0.02*RadiiC2pp->GetBinContent(binpp),2));
-    if(RadiiC2PbPb->GetBinContent(binPbPb)==0) {yAxisPbPb[cb]=100; yAxisPbPb_e[cb]=100;}
+    double RsysPbPb = 0.01*sqrt(pow(SysPercent_PbPb[FitType][0],2) + pow(1,2)) *  RadiiC2PbPb->GetBinContent(binPbPb);// fit Variation + MRC
+    double RsyspPb = 0.01*sqrt(pow(SysPercent_pPb[FitType][0],2) + pow(1,2)) *  RadiiC2pPb->GetBinContent(binpPb);// fit Variation + MRC
+    double Rsyspp = 0.01*sqrt(pow(SysPercent_pp[FitType][0],2) + pow(1,2)) *  RadiiC2pp->GetBinContent(binpp);// fit Variation + MRC
+    if(RadiiC2PbPb->GetBinContent(binPbPb)==0) {yAxisPbPb[cb]=100; yAxisPbPb_e[cb]=1000;}
     else {yAxisPbPb[cb]=RadiiC2PbPb->GetBinContent(binPbPb); yAxisPbPb_e[cb]=RsysPbPb;}
-    if(RadiiC2pPb->GetBinContent(binpPb)==0) {yAxispPb[cb]=100; yAxispPb_e[cb]=100;}
+    if(RadiiC2pPb->GetBinContent(binpPb)==0) {yAxispPb[cb]=100; yAxispPb_e[cb]=1000;}
     else {yAxispPb[cb]=RadiiC2pPb->GetBinContent(binpPb); yAxispPb_e[cb]=RsyspPb;}
-    if(RadiiC2pp->GetBinContent(binpp)==0) {yAxispp[cb]=100; yAxispp_e[cb]=100;}
+    if(RadiiC2pp->GetBinContent(binpp)==0) {yAxispp[cb]=100; yAxispp_e[cb]=1000;}
     else {yAxispp[cb]=RadiiC2pp->GetBinContent(binpp); yAxispp_e[cb]=Rsyspp;}
   }
   TGraphErrors *grRadiiC2Sys_PbPb=new TGraphErrors(20,meanNchPbPb,yAxisPbPb,xAxis_e,yAxisPbPb_e);
   TGraphErrors *grRadiiC2Sys_pPb=new TGraphErrors(20,meanNchpPb,yAxispPb,xAxis_e,yAxispPb_e);
   TGraphErrors *grRadiiC2Sys_pp=new TGraphErrors(20,meanNchpp,yAxispp,xAxis_e,yAxispp_e);
-  grRadiiC2Sys_pp->SetMarkerSize(0); grRadiiC2Sys_pp->SetFillStyle(3001); grRadiiC2Sys_pp->SetFillColor(kBlue-10);
-  grRadiiC2Sys_pPb->SetMarkerSize(0); grRadiiC2Sys_pPb->SetFillStyle(3001); grRadiiC2Sys_pPb->SetFillColor(kRed-10);
-  grRadiiC2Sys_PbPb->SetMarkerSize(0); grRadiiC2Sys_PbPb->SetFillStyle(3001); grRadiiC2Sys_PbPb->SetFillColor(kGray);
+  grRadiiC2Sys_pp->SetMarkerSize(0); //grRadiiC2Sys_pp->SetFillStyle(3001); grRadiiC2Sys_pp->SetFillColor(kBlue-10);
+  grRadiiC2Sys_pPb->SetMarkerSize(0); //grRadiiC2Sys_pPb->SetFillStyle(3001); grRadiiC2Sys_pPb->SetFillColor(kRed-10);
+  grRadiiC2Sys_PbPb->SetMarkerSize(0); //grRadiiC2Sys_PbPb->SetFillStyle(3001); grRadiiC2Sys_PbPb->SetFillColor(kGray);
+  //grRadiiC2Sys_PbPb->SetMarkerSize(3.3*RadiiC2PbPb->GetMarkerSize());
+  //grRadiiC2Sys_PbPb->SetLineWidth(3.3*RadiiC2PbPb->GetLineWidth());
   //
   if(FitType==1){
-    grRadiiC2Sys_pp->Draw("E2 p");
-    grRadiiC2Sys_pPb->Draw("E2 p");
-  }  
-  grRadiiC2Sys_PbPb->Draw("E2 p");
+    //grRadiiC2Sys_pp->Draw("|| p");
+    //grRadiiC2Sys_pPb->Draw("|| p");
+  }
   grRadiiSys_pp->Draw("E2 p");
   grRadiiSys_pPb->Draw("E2 p");
   grRadiiSys_PbPb->Draw("E2 p");
   RadiiPbPb->Draw("same");
   RadiipPb->Draw("same");
   Radiipp->Draw("same");
+  grRadiiC2Sys_PbPb->Draw("|| p");
   if(FitType==0) RadiiC2pp_Published->Draw("same");
   //
-  TF1 *PbPbFit=new TF1("PbPbFit","pol1",2.1,3.6); PbPbFit->SetLineColor(1);
-  //RadiiPbPb->Fit(PbPbFit,"IMENQ","",2.1,3.6);
+  //for(int i=0; i<20; i++){
+  //cout<<yAxispPb[i]<<"  "<<yAxispPb_e[i]<<endl;
+  //}
+  TF1 *PbPbFit=new TF1("PbPbFit","pol1",1,14); PbPbFit->SetLineColor(1);
+  //grRadiiSys_PbPb->Fit(PbPbFit,"","",1,13);
   //PbPbFit->Draw("same");
   //cout<<"PbPb: "<<PbPbFit->GetParameter(0)<<", "<<PbPbFit->GetParameter(1)<<endl;
-  TF1 *pPbFit=new TF1("pPbFit","pol1",0.8,1.8); pPbFit->SetLineColor(2);
-  //RadiipPb->Fit(pPbFit,"IMENQ","",0.8,1.8);
+  TF1 *pPbFit=new TF1("pPbFit","pol1",1,14); pPbFit->SetLineColor(2);
+  //grRadiiSys_pPb->Fit(pPbFit,"","",2,4.5);
   //pPbFit->Draw("same");
   //cout<<"pPb: "<<pPbFit->GetParameter(0)<<", "<<pPbFit->GetParameter(1)<<endl;
   TF1 *ppFit=new TF1("ppFit","pol1",0,1.5); ppFit->SetLineColor(4);
@@ -800,6 +946,8 @@ void Plot_plotsTPR(){
   ppFit->FixParameter(0,parspp[KT3Bin][0]); ppFit->FixParameter(1,parspp[KT3Bin][1]);
   //PbPbFit->Draw("same"); pPbFit->Draw("same"); ppFit->Draw("same");
   //
+  //RadiiC2PbPb->SetMarkerSize(1.3*RadiiC2PbPb->GetMarkerSize());
+  
   RadiiC2PbPb->Draw("same");
   if(FitType==1) {
     RadiiC2pPb->Draw("same");
@@ -807,77 +955,115 @@ void Plot_plotsTPR(){
   }
 
   legend4->AddEntry(Radiipp,"pp #sqrt{s}=7 TeV","p");
-  legend4->AddEntry(RadiipPb,"p-Pb #sqrt{s_{NN}}=5.02 TeV","p");
-  legend4->AddEntry(RadiiPbPb,"Pb-Pb #sqrt{s_{NN}}=2.76 TeV","p");
-
-  TLatex *Specif_Marker_1 = new TLatex(0.55,0.23,"Hollow=R_{inv,2}  Solid=R_{inv,3}");
-  Specif_Marker_1->SetNDC();
-  Specif_Marker_1->SetTextFont(TextFont);
-  Specif_Marker_1->SetTextSize(SizeSpecif*SF);
-  Specif_Marker_1->Draw("same");
-  TLatex *Specif_kappas = new TLatex(0.55,0.16,"#kappa_{3}=0.16, #kappa_{4}=0.4");
-  Specif_kappas->SetNDC();
-  Specif_kappas->SetTextFont(TextFont);
-  Specif_kappas->SetTextSize(SizeSpecif*SF);
-  if(FitType==1) Specif_kappas->Draw("same");
-  TLatex *Specif_Gauss = new TLatex(0.55,0.16,"Gaussian Radii");
-  Specif_Gauss->SetNDC();
-  Specif_Gauss->SetTextFont(TextFont);
-  Specif_Gauss->SetTextSize(SizeSpecif*SF);
-  if(FitType==0) Specif_Gauss->Draw("same");
+  legend4->AddEntry(RadiipPb,"p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV","p");
+  legend4->AddEntry(RadiiPbPb,"Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV","p");
+
+  
 
   TLatex *Specif_Kt3;
   TLatex *Specif_kt;
-  if(KT3Bin==0) {Specif_Kt3 = new TLatex(0.1, 0.6,"0.16<K_{T,3}<0.3, <k_{T}>=0.24 GeV/c"); Specif_kt = new TLatex(0.1, 0.5,"0.2<k_{T}<0.3, <k_{T}>=0.25 GeV/c");}
-  if(KT3Bin==1) {Specif_Kt3 = new TLatex(0.1, 0.6,"0.3<K_{T,3}<1.0, <k_{T}>=0.39 GeV/c"); Specif_kt = new TLatex(0.1, 0.5,"0.3<k_{T}<0.4, <k_{T}>=0.35 GeV/c");}
-  //if(KT3Bin==0) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.16<K_{T,3}<0.25 GeV/c"); Specif_kt = new TLatex(0.57, 0.76,"0.2<k_{T}<0.3 GeV/c");}
-  //if(KT3Bin==1) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.25<K_{T,3}<0.35 GeV/c"); Specif_kt = new TLatex(0.57, 0.76,"0.3<k_{T}<0.4 GeV/c");}
-  //if(KT3Bin==2) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.35<K_{T,3}<1.0 GeV/c"); Specif_kt = new TLatex(0.57, 0.76,"0.4<k_{T}<0.5 GeV/c");}
+  if(KT3Bin==0) {
+    Specif_Kt3 = new TLatex(0.17, 0.57,"0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}"); 
+    Specif_kt = new TLatex(0.17, 0.47,"0.2<#font[12]{k}_{T}<0.3 GeV/#font[12]{c}");
+    // KT3:  #LT#font[12]{k}_{T}#GT=0.24 GeV/#font[12]{c}
+    // kT:  #LT#font[12]{k}_{T}#GT=0.25 GeV/#font[12]{c}
+  }
+  if(KT3Bin==1) {
+    Specif_Kt3 = new TLatex(0.17, 0.57,"0.3<#font[12]{K}_{T,3}<1.0 GeV/#font[12]{c}"); 
+    Specif_kt = new TLatex(0.17, 0.47,"0.3<#font[12]{k}_{T}<1.0 GeV/#font[12]{c}");
+    // KT3:  #LT#font[12]{k}_{T}#GT=0.39 GeV/#font[12]{c}
+    // kT:  #LT#font[12]{k}_{T}#GT=0.43 GeV/#font[12]{c}
+  }
+  //if(KT3Bin==0) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.16<K_{T,3}<0.25 GeV/#font[12]{c}"); Specif_kt = new TLatex(0.57, 0.76,"0.2<k_{T}<0.3 GeV/#font[12]{c}");}
+  //if(KT3Bin==1) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.25<K_{T,3}<0.35 GeV/#font[12]{c}"); Specif_kt = new TLatex(0.57, 0.76,"0.3<k_{T}<0.4 GeV/#font[12]{c}");}
+  //if(KT3Bin==2) {Specif_Kt3 = new TLatex(0.57, 0.83,"0.35<K_{T,3}<1.0 GeV/#font[12]{c}"); Specif_kt = new TLatex(0.57, 0.76,"0.4<k_{T}<0.5 GeV/#font[12]{c}");}
   Specif_Kt3->SetTextFont(TextFont); Specif_kt->SetTextFont(TextFont);
-  Specif_Kt3->SetTextSize(SizeSpecif*SF); Specif_kt->SetTextSize(SizeSpecif*SF);
+  Specif_Kt3->SetTextSize(SizeSpecif*SF_2panel); Specif_kt->SetTextSize(SizeSpecif*SF_2panel);
   Specif_Kt3->SetNDC(); Specif_kt->SetNDC();
   Specif_Kt3->Draw("same");
   Specif_kt->Draw("same");
   
   legend4->SetTextFont(TextFont);
-  legend4->SetTextSize(SizeLegend*SF);
+  legend4->SetTextSize(SizeLegend*SF_2panel);
   legend4->Draw("same");
   
+  TH1D *MarkerPbPb_3=(TH1D*)RadiiPbPb->Clone();
+  TH1D *MarkerpPb_3=(TH1D*)RadiipPb->Clone();
+  TH1D *Markerpp_3=(TH1D*)Radiipp->Clone();
+  TH1D *MarkerPbPb_2=(TH1D*)RadiiC2PbPb->Clone();
+  TH1D *MarkerpPb_2=(TH1D*)RadiiC2pPb->Clone();
+  TH1D *Markerpp_2=(TH1D*)RadiiC2pp->Clone();
+  for(int i=1; i<=MarkerPbPb_3->GetNbinsX(); i++){
+    MarkerPbPb_3->SetBinContent(i,1000); MarkerpPb_3->SetBinContent(i,1000); Markerpp_3->SetBinContent(i,1000);
+    MarkerPbPb_2->SetBinContent(i,1000); MarkerpPb_2->SetBinContent(i,1000); Markerpp_2->SetBinContent(i,1000);
+    MarkerPbPb_3->SetBinError(i,0.001); MarkerpPb_3->SetBinError(i,0.001); Markerpp_3->SetBinError(i,0.001);
+    MarkerPbPb_2->SetBinError(i,0.001); MarkerpPb_2->SetBinError(i,0.001); Markerpp_2->SetBinError(i,0.001);
+  }
+  MarkerPbPb_3->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(450), 1);
+  MarkerpPb_3->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(600), 1);
+  Markerpp_3->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(800), 1);
+  MarkerPbPb_2->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(450), 3.1);
+  MarkerpPb_2->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(600), 3.1);
+  Markerpp_2->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(800), 3.1);
+  if(FitType==0) MarkerpPb_2->SetBinContent(MarkerPbPb_3->GetXaxis()->FindBin(600), 100);
+  MarkerPbPb_3->Draw("same"); MarkerpPb_3->Draw("same"); Markerpp_3->Draw("same");
+  MarkerPbPb_2->Draw("same"); MarkerpPb_2->Draw("same"); Markerpp_2->Draw("same");
+
+  TLatex *TwoPionText = new TLatex(0.74,0.41,"Two-Pions");
+  TLatex *ThreePionText = new TLatex(0.74,0.265,"Three-Pions");
+  TwoPionText->SetNDC(); ThreePionText->SetNDC(); 
+  TwoPionText->SetTextFont(TextFont); ThreePionText->SetTextFont(TextFont);
+  TwoPionText->SetTextSize(SizeSpecif*SF_2panel); ThreePionText->SetTextSize(SizeSpecif*SF_2panel);
+  TwoPionText->Draw("same");
+  ThreePionText->Draw("same");
+
+  TLatex *Specif_kappas = new TLatex(0.4,0.2,"#kappa_{3}=0.16, #kappa_{4}=0.4");// 0.16 and 0.4
+  Specif_kappas->SetNDC();
+  Specif_kappas->SetTextFont(TextFont);
+  Specif_kappas->SetTextSize(SizeSpecif*SF_2panel);
+  if(FitType==1) Specif_kappas->Draw("same");
+
   ///////////////////////////////////////////////////////////////////
   pad3->cd(2);
-  gPad->SetLeftMargin(0.05);
+  gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.01);
-  gPad->SetTopMargin(0.02);
-  gPad->SetBottomMargin(0.1);
+  gPad->SetTopMargin(0.01);
+  gPad->SetBottomMargin(0.16);
   gPad->SetTickx(); gPad->SetTicky();
+  gPad->SetLogx();
   //gPad->SetGridx(); gPad->SetGridy();
   TH1D *LambdaPbPb=(TH1D*)Parameters_c3[0][FitType][KT3Bin][1]->Clone();
   TH1D *LambdapPb=(TH1D*)Parameters_c3[1][FitType][KT3Bin][1]->Clone();
   TH1D *Lambdapp=(TH1D*)Parameters_c3[2][FitType][KT3Bin][1]->Clone();
   
   LambdaPbPb->GetXaxis()->SetLabelFont(TextFont); LambdaPbPb->GetYaxis()->SetLabelFont(TextFont); 
-  LambdaPbPb->GetXaxis()->SetLabelSize(SizeLabel*SF); LambdaPbPb->GetYaxis()->SetLabelSize(SizeLabel*SF);
+  LambdaPbPb->GetXaxis()->SetLabelSize(SizeLabel*SF_2panel); LambdaPbPb->GetYaxis()->SetLabelSize(SizeLabel*SF_2panel);
   LambdaPbPb->GetXaxis()->SetNdivisions(808);
   LambdaPbPb->GetYaxis()->SetNdivisions(606);
-  LambdaPbPb->GetXaxis()->SetTitleFont(TextFont); LambdaPbPb->GetXaxis()->SetTitleSize(SizeTitle*SF);
-  LambdaPbPb->GetYaxis()->SetTitleFont(TextFont); LambdaPbPb->GetYaxis()->SetTitleSize(SizeTitle*SF);
+  LambdaPbPb->GetXaxis()->SetTitleFont(TextFont); LambdaPbPb->GetXaxis()->SetTitleSize(SizeTitle*SF_2panel);
+  LambdaPbPb->GetYaxis()->SetTitleFont(TextFont); LambdaPbPb->GetYaxis()->SetTitleSize(SizeTitle*SF_2panel);
   LambdaPbPb->SetMaximum(2.3);
-  LambdaPbPb->GetXaxis()->SetTitleOffset(1.1);
+  LambdaPbPb->GetXaxis()->SetTitleOffset(0.95);
   LambdaPbPb->GetYaxis()->SetTitleOffset(100);//1.1
   
+  LambdaPbPb->GetXaxis()->SetRangeUser(3,3000);
   LambdaPbPb->Draw();
   
+  // old method was PbPb Sys = sqrt(pow(0.05,2)+pow(0.1,2));// MRC + Qrange
+  // for pp and pPb: sqrt(pow(0.03,2)+pow(0.05,2));
   for(int cb=0; cb<20; cb++){
     int binPbPb = LambdaPbPb->GetXaxis()->FindBin(meanNchPbPb[cb]);
     int binpPb = LambdapPb->GetXaxis()->FindBin(meanNchpPb[cb]);
     int binpp = Lambdapp->GetXaxis()->FindBin(meanNchpp[cb]);
-    double LambdasysPbPb = sqrt(pow(0.05,2)+pow(0.1,2));// MRC + Qrange
-    double LambdasyspPb = sqrt(pow(0.03,2)+pow(0.05,2));// MRC + Qrange
-    double Lambdasyspp = sqrt(pow(0.03,2)+pow(0.05,2));// MRC + Qrange
+    double LambdasysPbPb = 0.01*sqrt(pow(SysPercent_PbPb[FitType][3],2) + pow(1,2) + pow(5,2) + pow(10,2)) *  LambdaPbPb->GetBinContent(binPbPb);// fit Variation + MRC + TTC
+    double LambdasyspPb = 0.01*sqrt(pow(SysPercent_pPb[FitType][3],2) + pow(1,2) + pow(10,2)) *  LambdapPb->GetBinContent(binpPb);// fit Variation + MRC
+    double Lambdasyspp = 0.01*sqrt(pow(SysPercent_pp[FitType][3],2) + pow(1,2) + pow(10,2)) *  Lambdapp->GetBinContent(binpp);// fit Variation + MRC
     if(LambdaPbPb->GetBinContent(binPbPb)==0) {yAxisPbPb[cb]=100; yAxisPbPb_e[cb]=100;}
     else {yAxisPbPb[cb]=LambdaPbPb->GetBinContent(binPbPb); yAxisPbPb_e[cb]=LambdasysPbPb;}
+    //
     if(LambdapPb->GetBinContent(binpPb)==0) {yAxispPb[cb]=100; yAxispPb_e[cb]=100;}
     else {yAxispPb[cb]=LambdapPb->GetBinContent(binpPb); yAxispPb_e[cb]=LambdasyspPb;}
+    //
     if(Lambdapp->GetBinContent(binpp)==0) {yAxispp[cb]=100; yAxispp_e[cb]=100;}
     else {yAxispp[cb]=Lambdapp->GetBinContent(binpp); yAxispp_e[cb]=Lambdasyspp;}
   }
@@ -887,6 +1073,7 @@ void Plot_plotsTPR(){
   grLambdaSys_pp->SetMarkerSize(0); grLambdaSys_pp->SetFillStyle(1000); grLambdaSys_pp->SetFillColor(kBlue-10);
   grLambdaSys_pPb->SetMarkerSize(0); grLambdaSys_pPb->SetFillStyle(1000); grLambdaSys_pPb->SetFillColor(kRed-10);
   grLambdaSys_PbPb->SetMarkerSize(0); grLambdaSys_PbPb->SetFillStyle(1000); grLambdaSys_PbPb->SetFillColor(kGray);
+  grLambdaSys_pp->SetMarkerColor(kBlue-10); grLambdaSys_pPb->SetMarkerColor(kRed-10); grLambdaSys_PbPb->SetMarkerColor(kGray);
   // C2 sys
   TH1D *LambdaC2PbPb=(TH1D*)Parameters_C2[0][FitType][KT3Bin][1]->Clone();
   TH1D *LambdaC2pPb=(TH1D*)Parameters_C2[1][FitType][KT3Bin][1]->Clone();
@@ -895,9 +1082,9 @@ void Plot_plotsTPR(){
     int binPbPb = LambdaC2PbPb->GetXaxis()->FindBin(meanNchPbPb[cb]);
     int binpPb = LambdaC2pPb->GetXaxis()->FindBin(meanNchpPb[cb]);
     int binpp = LambdaC2pp->GetXaxis()->FindBin(meanNchpp[cb]);
-    double LambdasysPbPb = sqrt(pow(0.03,2)+pow(0.04,2));// MRC + Qrange
-    double LambdasyspPb = sqrt(pow(0.02,2)+pow(0.01,2));// MRC + Qrange
-    double Lambdasyspp = sqrt(pow(0.02,2)+pow(0.01,2));// MRC + Qrange
+    double LambdasysPbPb = 0.01*sqrt(pow(SysPercent_PbPb[FitType][2],2) + pow(1,2) + pow(5,2)) *  LambdaC2PbPb->GetBinContent(binPbPb);// fit Variation + MRC + TTC
+    double LambdasyspPb = 0.01*sqrt(pow(SysPercent_pPb[FitType][2],2) + pow(1,2)) *  LambdaC2pPb->GetBinContent(binpPb);// fit Variation + MRC
+    double Lambdasyspp = 0.01*sqrt(pow(SysPercent_pp[FitType][2],2) + pow(1,2)) *  LambdaC2pp->GetBinContent(binpp);// fit Variation + MRC
     if(LambdaC2PbPb->GetBinContent(binPbPb)==0) {yAxisPbPb[cb]=100; yAxisPbPb_e[cb]=100;}
     else {yAxisPbPb[cb]=LambdaC2PbPb->GetBinContent(binPbPb); yAxisPbPb_e[cb]=LambdasysPbPb;}
     if(LambdaC2pPb->GetBinContent(binpPb)==0) {yAxispPb[cb]=100; yAxispPb_e[cb]=100;}
@@ -908,20 +1095,20 @@ void Plot_plotsTPR(){
   TGraphErrors *grLambdaC2Sys_PbPb=new TGraphErrors(20,meanNchPbPb,yAxisPbPb,xAxis_e,yAxisPbPb_e);
   TGraphErrors *grLambdaC2Sys_pPb=new TGraphErrors(20,meanNchpPb,yAxispPb,xAxis_e,yAxispPb_e);
   TGraphErrors *grLambdaC2Sys_pp=new TGraphErrors(20,meanNchpp,yAxispp,xAxis_e,yAxispp_e);
-  grLambdaC2Sys_pp->SetMarkerSize(0); grLambdaC2Sys_pp->SetFillStyle(3001); grLambdaC2Sys_pp->SetFillColor(kBlue-10);
-  grLambdaC2Sys_pPb->SetMarkerSize(0); grLambdaC2Sys_pPb->SetFillStyle(3001); grLambdaC2Sys_pPb->SetFillColor(kRed-10);
-  grLambdaC2Sys_PbPb->SetMarkerSize(0); grLambdaC2Sys_PbPb->SetFillStyle(3001); grLambdaC2Sys_PbPb->SetFillColor(kGray);
+  grLambdaC2Sys_pp->SetMarkerSize(0); grLambdaC2Sys_pp->SetFillStyle(3001); grLambdaC2Sys_pp->SetFillColor(0);
+  grLambdaC2Sys_pPb->SetMarkerSize(0); grLambdaC2Sys_pPb->SetFillStyle(3001); grLambdaC2Sys_pPb->SetFillColor(0);
+  grLambdaC2Sys_PbPb->SetMarkerSize(0); grLambdaC2Sys_PbPb->SetFillStyle(3001); grLambdaC2Sys_PbPb->SetFillColor(0);
   //
+  
   if(FitType==1){
-    grLambdaC2Sys_pp->Draw("E2 p");
-    grLambdaC2Sys_pPb->Draw("E2 p");
+    //grLambdaC2Sys_pp->Draw("|| p");
+    //grLambdaC2Sys_pPb->Draw("|| p");
   }
-  grLambdaC2Sys_PbPb->Draw("E2 p");
+  grLambdaC2Sys_PbPb->Draw("|| p");
 
   grLambdaSys_pp->Draw("E2 p");
   grLambdaSys_pPb->Draw("E2 p");
   grLambdaSys_PbPb->Draw("E2 p");
-  
   //
   LambdaPbPb->Draw("same");
   LambdapPb->Draw("same");
@@ -932,27 +1119,36 @@ void Plot_plotsTPR(){
     LambdaC2pPb->Draw("same");
     LambdaC2pp->Draw("same");
   }
-  TLatex *Specif_Marker_2 = new TLatex(0.55,0.9,"Hollow=#lambda  Solid=#lambda_{3}");
+  
+  
+  /*TLatex *Specif_Marker_2;
+  if(FitType==0) Specif_Marker_2 = new TLatex(0.55,0.9,"Hollow=#lambda^{#font[12]{G}}  Solid=#lambda^{#font[12]{G}}_{3}");
+  else Specif_Marker_2 = new TLatex(0.3,0.9,"Hollow=#lambda^{#font[12]{E_{w}}}, #font[12]{R^{E_{w}}}_{inv}   Solid=#lambda^{#font[12]{E_{w}}}_{3}, #font[12]{R^{E_{w}}}_{inv,3}");
   Specif_Marker_2->SetNDC();
   Specif_Marker_2->SetTextFont(TextFont);
-  Specif_Marker_2->SetTextSize(SizeSpecif*SF);
-  Specif_Marker_2->Draw("same");
+  Specif_Marker_2->SetTextSize(SizeSpecif*SF_2panel);
+  Specif_Marker_2->Draw("same");*/
   
   can3->cd();
+  TPad *pad3_2 = new TPad("pad3_2","pad3_2",0.0,0.0,1.,1.);
+  pad3_2->SetFillStyle(0);
+  pad3_2->Draw();
+  pad3_2->cd();
   TLatex *RinvTitle;
-  if(FitType==0) RinvTitle=new TLatex(0.04,0.8,"#font[12]{R}_{inv,2} or #font[12]{R}_{inv,3} (fm)");
-  else RinvTitle=new TLatex(0.04,0.8,"#font[12]{R}^{#font[12]{Ew}}_{inv,2} or #font[12]{R}^{#font[12]{Ew}}_{inv,3} (fm)");
+  if(FitType==0) RinvTitle=new TLatex(0.062,0.72,"#font[12]{R}^{#font[12]{G}}_{inv} or #font[12]{R}^{#font[12]{G}}_{inv,3} (fm)");
+  else RinvTitle=new TLatex(0.062,0.72,"#font[12]{R}^{#font[12]{E_{w}}}_{inv} or #font[12]{R}^{#font[12]{E_{w}}}_{inv,3} (fm)");
   RinvTitle->SetNDC();
   RinvTitle->SetTextFont(TextFont);
-  RinvTitle->SetTextSize(SizeTitle*SF);
+  RinvTitle->SetTextSize(SizeTitle);
   RinvTitle->SetTextAngle(90);
   RinvTitle->Draw("same");
   TLatex *LambdaTitle;
-  if(FitType==0) LambdaTitle=new TLatex(0.04,0.4,"#lambda or #lambda_{3}");
-  else LambdaTitle=new TLatex(0.04,0.37,"#lambda^{#font[12]{Ew}} or #lambda^{#font[12]{Ew}}_{3}");
+  if(FitType==0) LambdaTitle=new TLatex(0.064,0.35,"#lambda^{#font[12]{G}} or #lambda^{#font[12]{G}}_{3}");
+  else LambdaTitle=new TLatex(0.064,0.33,"#lambda^{#font[12]{E_{w}}} or #lambda^{#font[12]{E_{w}}}_{3}");
   LambdaTitle->SetNDC();
   LambdaTitle->SetTextFont(TextFont);
-  LambdaTitle->SetTextSize(SizeTitle*SF);
+  LambdaTitle->SetTextSize(SizeTitle);
   LambdaTitle->SetTextAngle(90);
   LambdaTitle->Draw("same");
   
@@ -967,11 +1163,10 @@ void Plot_plotsTPR(){
   ////////////////////////////////////////////////////
   ////////////////////////////////////////////////////
   // Correlation functions and Monte Carlo
-  SF=2;
   /*
   TCanvas *can4 = new TCanvas("can4", "can4",10,0,900,600);// 11,53,700,500
   gStyle->SetOptFit(0111);
-  can4->SetFillColor(10);//10
+  can4->SetFillColor(0);//10
   can4->SetBorderMode(0);
   //can4->SetBorderSize(2);
   can4->SetFrameFillColor(0);
@@ -996,7 +1191,7 @@ void Plot_plotsTPR(){
   can4->Draw();
 
   TLegend *legend5[6];
-  legend5[0] = new TLegend(.4,.6, .97,.97,NULL,"brNDC");//.45 or .4 for x1
+  legend5[0] = new TLegend(.3,.52, .97,.99,NULL,"brNDC");//.45 or .4 for x1
   legend5[0]->SetBorderSize(0);
   legend5[0]->SetFillColor(0);
   legend5[0]->SetTextFont(TextFont);
@@ -1005,6 +1200,8 @@ void Plot_plotsTPR(){
   legend5[3]=(TLegend*)legend5[0]->Clone();
   legend5[4]=(TLegend*)legend5[0]->Clone();
   legend5[5]=(TLegend*)legend5[0]->Clone();
+  TLegend *legendFitTypes = (TLegend*)legend5[0]->Clone();
+  
   //
   //TGaxis *Xaxes[3];
   //TGaxis *Yaxes[2];
@@ -1024,7 +1221,7 @@ void Plot_plotsTPR(){
   }
   //
   for(int padNum=1; padNum<=6; padNum++){
-    
+    //gPad->SetTickx(); gPad->SetTicky();
     /*pad4->cd(padNum);
     
     if(padNum==1 || padNum==4) {gPad->SetLeftMargin(0.0);}
@@ -1039,7 +1236,10 @@ void Plot_plotsTPR(){
     can4->cd(padNum);
     if(padNum==3 || padNum==6) gPad->SetRightMargin(0.005);
     float SF_6pannel=2;
-    
+    double SF_correction=1.0;
+    if(padNum==3) SF_correction=1.1;
+    if(padNum==4) SF_correction=0.8;
+    if(padNum==5 || padNum==6) SF_correction=0.92;
     
     //
     int System_proof=0;
@@ -1052,7 +1252,8 @@ void Plot_plotsTPR(){
     if(padNum==5) {System_proof=1; ChComb_proof=1; Mb_proof=14;}
     if(padNum==6) {System_proof=0; ChComb_proof=1; Mb_proof=3;}
     
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->SetMinimum(0.9); C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->SetMaximum(3.1);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->SetMinimum(0.9); 
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->SetMaximum(3.3);
     //
     //c3[2][0][0][KT3Bin][Mb_pp]->GetXaxis()->SetLabelSize(SizeLabel*SF2); c3[2][0][0][KT3Bin][Mb_pp]->GetYaxis()->SetLabelSize(SizeLabel*SF2);
     //c3[2][0][0][KT3Bin][Mb_pp]->GetXaxis()->SetNdivisions(808);
@@ -1060,16 +1261,21 @@ void Plot_plotsTPR(){
     C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitle("#font[12]{C}_{3} or #font[12]{#bf{c}}_{3} ");
     if(padNum<=5){
       C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleOffset(10); 
-    }else C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleOffset(1.1);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleOffset(1.1);
-    
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetLabelSize(SizeLabel*SF);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetLabelSize(SizeLabel*SF);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleSize(SizeTitle*SF);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleSize(SizeTitle*SF);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetNdivisions(606);
-    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetNdivisions(606);
-    
+    }else C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleOffset(0.88);
+    if(padNum==1) C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleOffset(0.55);
+    else C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleOffset(10.);
+    if(padNum>=5) C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetLabelOffset(-.0);
+
+    //C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetLabelSize(SizeLabel);
+    //C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetLabelSize(SizeLabel);
+    //C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleSize(SizeTitle);
+    //C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleSize(SizeTitle);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetNdivisions(504);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetNdivisions(504);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetTitleSize(SizeTitle*SF_6pannel*SF_correction);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetTitleSize(SizeTitle*SF_6pannel*SF_correction);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetXaxis()->SetLabelSize(SizeTitle*SF_6pannel*SF_correction);
+    C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof]->GetYaxis()->SetLabelSize(SizeTitle*SF_6pannel*SF_correction);
     double Q3Limit;
     //if(System_proof==0) Q3Limit = 0.1 + 0.1*Mb_proof/16.;
     //else Q3Limit = 0.3 + 0.2*fabs(Mb_proof-10)/9.;
@@ -1111,43 +1317,44 @@ void Plot_plotsTPR(){
     if(padNum<=3){
       legend5[padNum-1]->AddEntry(C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof],"#font[12]{C}_{3}^{#pm#pm#pm}","p");
       legend5[padNum-1]->AddEntry(c3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof],"#font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
-      if(System_proof==0) legend5[padNum-1]->AddEntry(HIJING_c3_SC,"HIJING #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
-      if(System_proof==1) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"DPMJET #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
-      if(System_proof==2) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"Pythia #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
+      //if(System_proof==0) legend5[padNum-1]->AddEntry(HIJING_c3_SC,"HIJING #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
+      //if(System_proof==1) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"DPMJET #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
+      //if(System_proof==2) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"PYTHIA #font[12]{#bf{c}}_{3}^{#pm#pm#pm}","p");
     }else{
       legend5[padNum-1]->AddEntry(C3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof],"#font[12]{C}_{3}^{#pm#pm#mp}","p");
       legend5[padNum-1]->AddEntry(c3[System_proof][0][ChComb_proof][KT3Bin][Mb_proof],"#font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
       if(System_proof==0) legend5[padNum-1]->AddEntry(HIJING_c3_MC,"HIJING #font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
       if(System_proof==1) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"DPMJET #font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
-      if(System_proof==2) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"Pythia #font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
+      if(System_proof==2) legend5[padNum-1]->AddEntry(c3[System_proof][1][ChComb_proof][KT3Bin][Mb_proof],"PYTHIA #font[12]{#bf{c}}_{3}^{#pm#pm#mp}","p");
     }
    
     if(ChComb_proof==0) {
       c3_fit[System_proof][0][KT3Bin][Mb_proof]->Draw("c same");
       c3_fit[System_proof][1][KT3Bin][Mb_proof]->Draw("c same");
-      legend5[padNum-1]->AddEntry(c3_fit[System_proof][0][KT3Bin][Mb_proof],"Gaussian Fit","l");
-      legend5[padNum-1]->AddEntry(c3_fit[System_proof][1][KT3Bin][Mb_proof],"Edgeworth Fit","l");
+      if(padNum==3){
+       legendFitTypes->AddEntry(c3_fit[System_proof][0][KT3Bin][Mb_proof],"Gaussian","l");
+       legendFitTypes->AddEntry(c3_fit[System_proof][1][KT3Bin][Mb_proof],"Edgeworth","l");
+      }
     }
-    double SF_correction=1.0;
-    if(padNum==4 || padNum==5) SF_correction=0.95;
-    if(padNum==6) SF_correction=0.92;
-
-
+    
     TLatex *CTLabel;
-    if(System_proof==0) CTLabel = new TLatex(0.45,0.52,"Pb-Pb #sqrt{s_{NN}}=2.76 TeV");// 0.003,.988
-    if(System_proof==1) CTLabel = new TLatex(0.45,0.52,"p-Pb #sqrt{s_{NN}}=5.02 TeV");// 0.003,.988
-    if(System_proof==2) CTLabel = new TLatex(0.65,0.52,"pp #sqrt{s}=7 TeV");// 0.003,.988
+    if(System_proof==0) CTLabel = new TLatex(0.12,0.9,"Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV");// 0.003,.988
+    if(System_proof==1) CTLabel = new TLatex(0.15,0.9,"p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV");// 0.003,.988
+    if(System_proof==2) CTLabel = new TLatex(0.4,0.9,"pp #sqrt{s}=7 TeV");// 0.003,.988
     CTLabel->SetNDC();
     CTLabel->SetTextFont(TextFont);
     CTLabel->SetTextSize(SizeSpecif*SF_6pannel*SF_correction);
-    CTLabel->Draw("same");
+    if(padNum>=4) CTLabel->Draw("same");
     
-    TString *nameCh=new TString("N_{ch} = ");
+    TString *nameCh=new TString("#LTN_{ch}#GT = ");
     float Nch=1;
-    if(System_proof==0) Nch = pow(10,meanNchPbPb[Mb_proof]);
-    else if(System_proof==1) Nch = pow(10,meanNchpPb[Mb_proof]);
-    else Nch = pow(10,meanNchpp[Mb_proof]);
-    *nameCh += int(Nch);
+    //if(System_proof==0) Nch = pow(10,meanNchPbPb[Mb_proof]);
+    //else if(System_proof==1) Nch = pow(10,meanNchpPb[Mb_proof]);
+    //else Nch = pow(10,meanNchpp[Mb_proof]);
+    if(System_proof==0) Nch = meanNchPbPb[Mb_proof];
+    else if(System_proof==1) Nch = meanNchpPb[Mb_proof];
+    else Nch = meanNchpp[Mb_proof];
+    *nameCh += int(Nch + 0.5);
     nameCh->Append(" #pm ");
     float SysPercent = 0.05;
     int SigFig=0;
@@ -1156,17 +1363,28 @@ void Plot_plotsTPR(){
     
     *nameCh += SigFig;
     TLatex *MLabel;
-    if(System_proof!=2) MLabel = new TLatex(0.45,0.4,nameCh->Data());
-    else MLabel = new TLatex(0.65,0.4,nameCh->Data());
+    if(padNum==1) MLabel = new TLatex(0.52,0.6,nameCh->Data());
+    if(padNum==2) MLabel = new TLatex(0.4,0.6,nameCh->Data());
+    if(padNum==3) MLabel = new TLatex(0.4,0.6,nameCh->Data());
+   
     MLabel->SetNDC();
     MLabel->SetTextFont(TextFont);
     MLabel->SetTextSize(SizeSpecif*SF_6pannel*SF_correction);
-    MLabel->Draw("same");
+    if(padNum<=3) MLabel->Draw("same");
     
     
-    legend5[padNum-1]->SetTextSize(SizeLegend*SF_6pannel);
-    if(padNum==1 || padNum==4) legend5[padNum-1]->SetX1(0.55);
-    else legend5[padNum-1]->SetX1(0.45);
+    legend5[padNum-1]->SetTextSize(SizeLegend*SF_6pannel*SF_correction);
+    if(padNum==1) {legend5[padNum-1]->SetX1(0.45); legend5[padNum-1]->SetY1(0.69);}
+    if(padNum==2) {legend5[padNum-1]->SetX1(0.32); legend5[padNum-1]->SetY1(0.69);}
+    if(padNum==3) {
+      legend5[padNum-1]->SetX1(0.32); legend5[padNum-1]->SetY1(0.69);
+      legendFitTypes->SetX1(0.44); 
+      legendFitTypes->SetY1(0.22); legendFitTypes->SetY2(0.56);
+      legendFitTypes->Draw("same");
+    }
+    if(padNum==4) {legend5[padNum-1]->SetX1(0.45); legend5[padNum-1]->SetY1(0.45); legend5[padNum-1]->SetY2(0.85);}
+    if(padNum==5) {legend5[padNum-1]->SetX1(0.32); legend5[padNum-1]->SetY1(0.45); legend5[padNum-1]->SetY2(0.85);}
+    if(padNum==6) {legend5[padNum-1]->SetX1(0.32); legend5[padNum-1]->SetY1(0.45); legend5[padNum-1]->SetY2(0.85);}
     legend5[padNum-1]->Draw("same");
   }
   
@@ -1178,75 +1396,13 @@ void Plot_plotsTPR(){
   pad4_2->SetFillStyle(0);
   pad4_2->Draw();
   pad4_2->cd();
-  TBox *CoverUp1 = new TBox(0.35,0.05,0.38,.075);
-  CoverUp1->SetFillColor(10);
+  TBox *CoverUp1 = new TBox(0.35,0.05,0.42,.115);
+  CoverUp1->SetFillColor(0);
   CoverUp1->Draw();
-  TBox *CoverUp2 = new TBox(0.66,0.05,0.69,.075);
-  CoverUp2->SetFillColor(10);
+  TBox *CoverUp2 = new TBox(0.66,0.05,0.73,.115);
+  CoverUp2->SetFillColor(0);
   CoverUp2->Draw();
-  /*
-  TLatex *Q3Title=new TLatex(0.9,0.02,"#font[12]{Q}_{3} (GeV/#font[12]{c})");
-  Q3Title->SetNDC();
-  Q3Title->SetTextFont(TextFont);
-  Q3Title->SetTextSize(SizeTitle);
-  Q3Title->Draw("same");
   
-  TLatex *C3c3Title=new TLatex(0.02,0.9,"#font[12]{C}_{3} or #font[12]{#bf{c}}_{3}");
-  C3c3Title->SetNDC();
-  C3c3Title->SetTextFont(TextFont);
-  C3c3Title->SetTextSize(SizeTitle);
-  C3c3Title->SetTextAngle(90);
-  C3c3Title->Draw("same");
-
-
-  
-  Xaxes[0]=new TGaxis(PadLeftMargin,PadBottomMargin+CanTRMarg, PadLeftMargin+.333*(1-PadLeftMargin),PadBottomMargin+CanTRMarg, AxesLimitsX[0][0],AxesLimitsX[0][1],606,"");
-  Xaxes[0]->SetLabelFont(TextFont);
-  Xaxes[0]->SetLabelSize(SizeLabel);
-  Xaxes[0]->Draw();
-  //
-  Xaxes[1]=new TGaxis(PadLeftMargin+.3333*(1-PadLeftMargin),PadBottomMargin+CanTRMarg, PadLeftMargin+.666*(1-PadLeftMargin),PadBottomMargin+CanTRMarg, AxesLimitsX[1][0],AxesLimitsX[1][1],606,"+L");
-  Xaxes[1]->SetLabelFont(TextFont);
-  Xaxes[1]->SetLabelSize(SizeLabel);
-  Xaxes[1]->Draw();
-  //
-  Xaxes[2]=new TGaxis(PadLeftMargin+.667*(1-PadLeftMargin),PadBottomMargin+CanTRMarg, PadLeftMargin+(1-PadLeftMargin),PadBottomMargin+CanTRMarg, AxesLimitsX[2][0],AxesLimitsX[2][1],606,"+L");
-  Xaxes[2]->SetLabelFont(TextFont);
-  Xaxes[2]->SetLabelSize(SizeLabel);
-  Xaxes[2]->Draw();
-  //
-  Yaxes[0]=new TGaxis(PadLeftMargin,PadBottomMargin+CanTRMarg, PadLeftMargin,PadBottomMargin+CanTRMarg+0.5*(1-PadBottomMargin), AxesLimitsY[0][0],AxesLimitsY[0][1],606,"+L");
-  Yaxes[0]->SetLabelFont(TextFont);
-  Yaxes[0]->SetLabelSize(SizeLabel);
-  Yaxes[0]->SetOption("-");
-  Yaxes[0]->Draw();
-  //
-  Yaxes[1]=new TGaxis(PadLeftMargin,PadBottomMargin+0.5*(1-PadBottomMargin), PadLeftMargin,PadBottomMargin+(1-PadBottomMargin), AxesLimitsY[1][0],AxesLimitsY[1][1],606,"+L");
-  Yaxes[1]->SetLabelFont(TextFont);
-  Yaxes[1]->SetLabelSize(SizeLabel);
-  Yaxes[1]->SetOption("-");
-  Yaxes[1]->Draw();
-  */
-  
-
-  //TString *nameCh=new TString("N_{rec}: ");
-  //nameCh->Append(labels[Mb_proof]);
-  //TLatex *MLabel;
-  //if(System_proof==0) MLabel = new TLatex((0.1 + 0.1*Mb_proof/16.) * 0.5,2.0,nameCh->Data());
-  //else MLabel = new TLatex( (0.3 + 0.2*fabs(Mb_proof-10)/9.)* 0.5,2.0,nameCh->Data());
-  //MLabel->SetTextFont(TextFont);
-  //MLabel->SetTextSize(SizeTitle*SF2);
-  //MLabel->Draw("same");
-  //TLatex *CTLabel;
-  //if(System_proof==0) CTLabel = new TLatex((0.1 + 0.1*Mb_proof/16.) * 0.5,2.2,"Pb-Pb #sqrt{s_{NN}}=2.76 TeV");// 0.003,.988
-  //if(System_proof==1) CTLabel = new TLatex((0.3 + 0.2*fabs(Mb_proof-10)/9.)* 0.5,2.2,"p-Pb #sqrt{s_{NN}}=5.02 TeV");// 0.003,.988
-  //if(System_proof==2) CTLabel = new TLatex((0.3 + 0.2*fabs(Mb_proof-10)/9.)* 0.5,2.2,"pp #sqrt{s}=7 TeV");// 0.003,.988
-  //CTLabel->SetTextFont(TextFont);
-  //CTLabel->SetTextSize(SizeTitle*SF2);
-  //CTLabel->Draw("same");
-  
-
-
   
 
  
@@ -1254,11 +1410,10 @@ void Plot_plotsTPR(){
   ////////////////////////////////////////////////////
   ////////////////////////////////////////////////////
   // 2 system correlation function comparison
-  SF=1.1;
   TCanvas *can5 = new TCanvas("can5", "can5",1700,700,600,600);// 11,53,700,500
   can5->SetHighLightColor(2);
-  gStyle->SetOptFit(0111);
-  can5->SetFillColor(10);//10
+  gStyle->SetOptFit(0);// 0111 to show fit stat box
+  can5->SetFillColor(0);//10
   can5->SetBorderMode(0);
   can5->SetBorderSize(2);
   can5->SetFrameFillColor(0);
@@ -1274,58 +1429,87 @@ void Plot_plotsTPR(){
   pad5->SetLeftMargin(0.0);//0.12
   pad5->Draw();
   pad5->cd();
-  TLegend *legend6 = new TLegend(.3,.75, .8,.95,NULL,"brNDC");//.45 or .4 for x1
+  TLegend *legend6 = new TLegend(.4,.6, .9,.95,NULL,"brNDC");//.45 or .4 for x1
   legend6->SetBorderSize(0);
   legend6->SetFillColor(0);
   legend6->SetTextFont(TextFont);
-  legend6->SetTextSize(SizeLegend*SF);
+  legend6->SetTextSize(SizeLegend);
+  TLegend *legend7 = new TLegend(.65,.35, .97,.52,NULL,"brNDC");//.45 or .4 for x1
+  legend7->SetBorderSize(0);
+  legend7->SetFillColor(0);
+  legend7->SetTextFont(TextFont);
+  legend7->SetTextSize(SizeLegend);
   //
-  gPad->SetRightMargin(0.03); gPad->SetLeftMargin(0.09);
-  gPad->SetBottomMargin(0.09); gPad->SetTopMargin(0.02);
+  gPad->SetRightMargin(0.01); gPad->SetLeftMargin(0.10);
+  gPad->SetBottomMargin(0.14); gPad->SetTopMargin(0.02);
   gPad->SetTickx(); gPad->SetTicky();
   //
   int KT3Bin_CorrComp=0;
-  int Mbin_SysCompPbPb=12;// 12
-  int Mbin_SysComppPb=16;// 12, 16,
-  int Mbin_SysComppp=15;//   ,  15,
-  TH1D *c3_PbPb=(TH1D*)c3[0][0][0][KT3Bin_CorrComp][Mbin_SysCompPbPb]->Clone();
-  TH1D *c3_pPb=(TH1D*)c3[1][0][0][KT3Bin_CorrComp][Mbin_SysComppPb]->Clone();
-  TH1D *c3_pp=(TH1D*)c3[2][0][0][KT3Bin_CorrComp][Mbin_SysComppp]->Clone();
+  int Mbin_SysComp_PbPb=12;// 12
+  int Mbin_SysComp_pPb;// 12, 16,
+  int Mbin_SysComp_pp=15;//   ,  15,
+  if(p_pPb_Comp) Mbin_SysComp_pPb=16; 
+  else Mbin_SysComp_pPb=12;
+
+  TH1D *c3_PbPb=(TH1D*)c3[0][0][0][KT3Bin_CorrComp][Mbin_SysComp_PbPb]->Clone();
+  TH1D *c3_pPb=(TH1D*)c3[1][0][0][KT3Bin_CorrComp][Mbin_SysComp_pPb]->Clone();
+  TH1D *c3_pp=(TH1D*)c3[2][0][0][KT3Bin_CorrComp][Mbin_SysComp_pp]->Clone();
 
   c3_pPb->GetYaxis()->SetTitle("#bf{c}_{3}^{#pm#pm#pm}");
-  c3_pPb->GetXaxis()->SetRangeUser(0,0.5);// pp and pPb
-  //c3_pPb->GetXaxis()->SetRangeUser(0,0.27);// PbPb and pPb
-  c3_pPb->GetXaxis()->SetLabelSize(SizeLabel*SF); c3_pp->GetYaxis()->SetLabelSize(SizeLabel*SF);
-  c3_pPb->GetXaxis()->SetTitleSize(SizeLabel*SF); c3_pp->GetYaxis()->SetTitleSize(SizeLabel*SF);
+  c3_pPb->GetXaxis()->SetRangeUser(0,0.27);
+  
+  c3_pPb->GetXaxis()->SetLabelSize(SizeLabel); c3_pPb->GetYaxis()->SetLabelSize(SizeLabel);
+  c3_pPb->GetXaxis()->SetTitleSize(SizeTitle); c3_pPb->GetYaxis()->SetTitleSize(SizeTitle);
+  
   c3_pPb->GetYaxis()->SetTitle("#font[12]{#bf{c}}_{3}^{#pm#pm#pm}");
-  c3_pPb->GetXaxis()->SetTitleOffset(1.2); c3_pp->GetYaxis()->SetTitleOffset(1.3);
-  c3_pPb->SetMinimum(0.9); c3_pPb->SetMaximum(3.1);
-  c3_pPb->GetXaxis()->SetNdivisions(606);
+  c3_pPb->GetXaxis()->SetTitleOffset(1.0); 
+  c3_pPb->GetYaxis()->SetTitleOffset(0.7); 
+  c3_pPb->SetMinimum(0.9); c3_pPb->SetMaximum(3.3);
+  c3_pPb->GetXaxis()->SetNdivisions(503);
+  c3_pPb->GetYaxis()->SetNdivisions(503);
+
   c3_pPb->Draw();
   //
-  c3_Sys[2][0][0][KT3Bin_CorrComp][Mbin_SysComppp]->Draw("E2 same");
-  c3_Sys[1][0][0][KT3Bin_CorrComp][Mbin_SysComppPb]->Draw("E2 same");
-  //c3_Sys[0][0][0][KT3Bin][Mbin_SysCompPbPb]->Draw("E2 same");
-  c3_pp->Draw("same");
+  if(p_pPb_Comp) c3_Sys[2][0][0][KT3Bin_CorrComp][Mbin_SysComp_pp]->Draw("E2 same");
+  c3_Sys[1][0][0][KT3Bin_CorrComp][Mbin_SysComp_pPb]->Draw("E2 same");
+  if(!p_pPb_Comp) c3_Sys[0][0][0][KT3Bin][Mbin_SysComp_PbPb]->Draw("E2 same");
+  if(p_pPb_Comp) c3_pp->Draw("same");
   c3_pPb->Draw("same");
-  //c3_PbPb->Draw("same");
+  if(!p_pPb_Comp) c3_PbPb->Draw("same");
   // SysPercent = 0.07 - 0.05*(Mb_proof/19.);
   
-  legend6->AddEntry(c3_pPb,"p-Pb #sqrt{s_{NN}}=5.02 TeV, N_{ch} = 24#pm1.2","p");// MpPb=16
-  legend6->AddEntry(c3_pp,"pp #sqrt{s}=7 TeV, N_{ch} = 27#pm1.4","p");// Mpp=15
-  //legend6->AddEntry(c3_pPb,"p-Pb #sqrt{s_{NN}}=5.02 TeV, N_{ch} = 59#pm3.0","p");// MpPb=12
-  //legend6->AddEntry(c3_PbPb,"Pb-Pb #sqrt{s}=7 TeV, N_{ch} = 69#pm3.5","p");// MPbPb=12
-
-  //c3_fit[0][0][KT3Bin][Mbin_SysCompPbPb]->Draw("c same");
-  c3_fit[1][0][KT3Bin][Mbin_SysComppPb]->Draw("c same");
-  c3_fit[2][0][KT3Bin][Mbin_SysComppp]->Draw("c same");
+  if(p_pPb_Comp) {
+    legend6->AddEntry(c3_pPb,"#splitline{p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV}{#LTN_{ch}#GT = 23 #pm 1.2}","p");// MpPb=16
+    legend6->AddEntry(c3_pp,"#splitline{pp #sqrt{s}=7 TeV}{#LTN_{ch}#GT = 26 #pm 1.3}","p");// Mpp=15
+  }else{  
+    legend6->AddEntry(c3_pPb,"#splitline{p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV}{#LTN_{ch}#GT = 71 #pm 4}","p");// MpPb=12
+    legend6->AddEntry(c3_PbPb,"#splitline{Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV}{#LTN_{ch}#GT = 87 #pm 4}","p");// MPbPb=12
+  }
+  
+  //
+  
+  if(!p_pPb_Comp) c3_fit[0][0][KT3Bin][Mbin_SysComp_PbPb]->Draw("c same");
+  c3_fit[1][0][KT3Bin][Mbin_SysComp_pPb]->Draw("c same");
+  if(p_pPb_Comp) c3_fit[2][0][KT3Bin][Mbin_SysComp_pp]->Draw("c same");
+  //
+  TF1 *GaussFit_forLegend=(TF1*)c3_fit[1][0][KT3Bin][Mbin_SysComp_pPb]->Clone();
+  TF1 *EwFit_forLegend=(TF1*)c3_fit[1][1][KT3Bin][Mbin_SysComp_pPb]->Clone();
+  GaussFit_forLegend->SetLineColor(1);
+  EwFit_forLegend->SetLineColor(1);
+  legend7->AddEntry(GaussFit_forLegend,"Gaussian","l");
+  legend7->AddEntry(EwFit_forLegend,"Edgeworth","l");
+  //
+  
+  if(!p_pPb_Comp) c3_fit[0][1][KT3Bin][Mbin_SysComp_PbPb]->Draw("c same");
+  c3_fit[1][1][KT3Bin][Mbin_SysComp_pPb]->Draw("c same");
+  if(p_pPb_Comp) c3_fit[2][1][KT3Bin][Mbin_SysComp_pp]->Draw("c same");
   legend6->Draw("same");
-
+  legend7->Draw("same");
   
-  TLatex *Specif_Kt3_4 = new TLatex(0.425,0.67,"0.16<K_{T,3}<0.3 GeV/c");
+  TLatex *Specif_Kt3_4 = new TLatex(0.52,0.55,"0.16<#font[12]{K}_{T,3}<0.3 GeV/#font[12]{c}");
   Specif_Kt3_4->SetNDC();
   Specif_Kt3_4->SetTextFont(TextFont);
-  Specif_Kt3_4->SetTextSize(SizeTitle*SF);
+  Specif_Kt3_4->SetTextSize(SizeSpecif);
   Specif_Kt3_4->Draw("same");
   
 
@@ -1334,7 +1518,7 @@ void Plot_plotsTPR(){
     TString *name = new TString("c3SystemComp");
     if(FitType==1) name->Append("EW");
     name->Append("_MpPb");
-    *name += Mbin_SysComppPb;
+    *name += Mbin_SysComp_pPb;
     name->Append(".eps");
     //
     can5->SaveAs(name->Data());
@@ -1348,7 +1532,7 @@ void Plot_plotsTPR(){
   TCanvas *can6 = new TCanvas("can6", "can6",500,700,600,600);// 11,53,700,500
   can6->SetHighLightColor(2);
   gStyle->SetOptFit(0111);
-  can6->SetFillColor(10);//10
+  can6->SetFillColor(0);//10
   can6->SetBorderMode(0);
   can6->SetBorderSize(2);
   can6->SetFrameFillColor(0);
@@ -1387,16 +1571,16 @@ void Plot_plotsTPR(){
   Fit_h_C2[1][Mbin_C2]->Draw("C same");
   
   //legend7->AddEntry(C2[2][Mbin_C2],"N_{ch} = 8.8 pp #sqrt{s}=7 TeV","p");
-  //legend7->AddEntry(C2[1][Mbin_C2],"N_{ch} = 10.2 p-Pb #sqrt{s_{NN}}=5.02 TeV","p");
+  //legend7->AddEntry(C2[1][Mbin_C2],"N_{ch} = 10.2 p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV","p");
   legend7->AddEntry(C2[2][Mbin_C2],"N_{ch} = 4.6 pp #sqrt{s}=7 TeV","p");
-  legend7->AddEntry(C2[1][Mbin_C2],"N_{ch} = 5.4 p-Pb #sqrt{s_{NN}}=5.02 TeV","p");
+  legend7->AddEntry(C2[1][Mbin_C2],"N_{ch} = 5.4 p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV","p");
   //
   legend7->Draw("same");
-  TLatex *Specif_Kt = new TLatex(0.22,1.35,"0.16<K_{t}<1.0 GeV/c");
+  TLatex *Specif_Kt = new TLatex(0.22,1.35,"0.16<K_{t}<1.0 GeV/#font[12]{c}");
   Specif_Kt->SetTextFont(TextFont);
   Specif_Kt->SetTextSize(SizeSpecif*SF2);
   Specif_Kt->Draw("same");
-  TLatex *Specif_Kinematics_5 = new TLatex(0.172,1.3,"|#eta|<0.8, 0.16<p_{T}<1.0 GeV/c");
+  TLatex *Specif_Kinematics_5 = new TLatex(0.172,1.3,"|#eta|<0.8, 0.16<p_{T}<1.0 GeV/#font[12]{c}");
   Specif_Kinematics_5->SetTextFont(TextFont);
   Specif_Kinematics_5->SetTextSize(SizeSpecif*SF2);
   Specif_Kinematics_5->Draw("same");
@@ -1427,8 +1611,8 @@ void Plot_plotsTPR(){
   Parameters_c3[1][4]->Draw("same");
   Parameters_c3[2][4]->Draw("same");
   legend6->AddEntry(Parameters_c3[2][2],"pp #sqrt{s}=7 TeV","p");
-  legend6->AddEntry(Parameters_c3[1][2],"p-Pb #sqrt{s_{NN}}=5.02 TeV","p");
-  legend6->AddEntry(Parameters_c3[0][2],"Pb-Pb #sqrt{s_{NN}}=2.76 TeV","p");
+  legend6->AddEntry(Parameters_c3[1][2],"p-Pb #sqrt{#font[12]{s}_{NN}}=5.02 TeV","p");
+  legend6->AddEntry(Parameters_c3[0][2],"Pb-Pb #sqrt{#font[12]{s}_{NN}}=2.76 TeV","p");
   legend6->Draw("same");
   double sumk3=0, Enk3=0, sumk4=0, Enk4=0;
   for(int ct=0; ct<3; ct++){ 
@@ -1495,8 +1679,8 @@ TCanvas *make_canvas(const Char_t *name, const Char_t *title, Int_t n_x, Int_t n
     canvas=new TCanvas(name,title,10,0,ww,wh);
     canvas->SetTopMargin(0.01);
     canvas->SetRightMargin(0.01);
-    canvas->SetLeftMargin(0.13); 
-    canvas->SetBottomMargin(0.13); 
+    canvas->SetLeftMargin(0.14); 
+    canvas->SetBottomMargin(0.18); 
     
     canvas->Divide(n_x,n_y,0,0);
   }
index 49a24e32b9c37b16a4d54f0b382781b1273fde5d..a8d5bc01df8e42686252c216b81515aa0cf621f5 100644 (file)
@@ -164,7 +164,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
     Double_t p[3];
     Double_t covVtx[6];
     Double_t covTr[21];
-    Double_t pid[10];
+    //    Double_t pid[10];
 
     for (Int_t i = 0; i < 6; i++)  covVtx[i] = 0.;
     for (Int_t i = 0; i < 21; i++) covTr [i] = 0.;
@@ -380,7 +380,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
            esdTrack->GetPxPyPz(p);
            esdTrack->GetXYZ(pos);
            esdTrack->GetCovarianceXYZPxPyPz(covTr);
-           esdTrack->GetESDpid(pid);
+           //      esdTrack->GetESDpid(pid);
            
            vV0FromCascade->AddDaughter(aodTrack =
                                        new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
@@ -392,7 +392,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                           covTr, 
                                                                           (Short_t)esdTrack->GetSign(),
                                                                           esdTrack->GetITSClusterMap(), 
-                                                                          pid,
+                                                                          // pid,
                                                                           vV0FromCascade,
                                                                           kTRUE,  // check if this is right
                                                                           kFALSE, // check if this is right
@@ -415,7 +415,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
            esdTrack->GetPxPyPz(p);
            esdTrack->GetXYZ(pos);
            esdTrack->GetCovarianceXYZPxPyPz(covTr);
-           esdTrack->GetESDpid(pid);
+           //      esdTrack->GetESDpid(pid);
            
            vV0FromCascade->AddDaughter(aodTrack =
                                        new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
@@ -427,7 +427,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                           covTr, 
                                                                           (Short_t)esdTrack->GetSign(),
                                                                           esdTrack->GetITSClusterMap(), 
-                                                                          pid,
+                                                                          //pid,
                                                                           vV0FromCascade,
                                                                           kTRUE,  // check if this is right
                                                                           kFALSE, // check if this is right
@@ -452,7 +452,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
            esdTrack->GetPxPyPz(p);
            esdTrack->GetXYZ(pos);
            esdTrack->GetCovarianceXYZPxPyPz(covTr);
-           esdTrack->GetESDpid(pid);
+           //      esdTrack->GetESDpid(pid);
            
            vcascade->AddDaughter(aodTrack =
                                  new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
@@ -464,7 +464,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                     covTr, 
                                                                     (Short_t)esdTrack->GetSign(),
                                                                     esdTrack->GetITSClusterMap(), 
-                                                                    pid,
+                                                                    //pid,
                                                                     vcascade,
                                                                     kTRUE,  // check if this is right
                                                                     kFALSE, // check if this is right
@@ -520,7 +520,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
            esdTrack->GetPxPyPz(p);
            esdTrack->GetXYZ(pos);
            esdTrack->GetCovarianceXYZPxPyPz(covTr);
-           esdTrack->GetESDpid(pid);
+           //esdTrack->GetESDpid(pid);
            
            vV0->AddDaughter(aodTrack =
                             new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
@@ -532,7 +532,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                covTr, 
                                                                (Short_t)esdTrack->GetSign(),
                                                                esdTrack->GetITSClusterMap(), 
-                                                               pid,
+                                                               //pid,
                                                                vV0,
                                                                kTRUE,  // check if this is right
                                                                kFALSE, // check if this is right
@@ -555,7 +555,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
            esdTrack->GetPxPyPz(p);
            esdTrack->GetXYZ(pos);
            esdTrack->GetCovarianceXYZPxPyPz(covTr);
-           esdTrack->GetESDpid(pid);
+           //esdTrack->GetESDpid(pid);
            
            vV0->AddDaughter(aodTrack =
                             new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
@@ -567,7 +567,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                covTr, 
                                                                (Short_t)esdTrack->GetSign(),
                                                                esdTrack->GetITSClusterMap(), 
-                                                               pid,
+                                                               //pid,
                                                                vV0,
                                                                kTRUE,  // check if this is right
                                                                kFALSE, // check if this is right
@@ -641,7 +641,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                        esdTrackC->GetPxPyPz(p);
                        esdTrackC->GetXYZ(pos);
                        esdTrackC->GetCovarianceXYZPxPyPz(covTr);
-                       esdTrackC->GetESDpid(pid);
+                       //esdTrackC->GetESDpid(pid);
                        
                        mother = 
                            new(tracks[jTracks++]) AliAODTrack(esdTrackC->GetID(),
@@ -653,7 +653,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                               covTr, 
                                                               (Short_t)esdTrackC->GetSign(),
                                                               esdTrackC->GetITSClusterMap(), 
-                                                              pid,
+                                                              //pid,
                                                               primary,
                                                               kTRUE, // check if this is right
                                                               kTRUE, // check if this is right
@@ -687,7 +687,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                        esdTrackC->GetPxPyPz(p);
                        esdTrackC->GetXYZ(pos);
                        esdTrackC->GetCovarianceXYZPxPyPz(covTr);
-                       esdTrackC->GetESDpid(pid);
+                       //esdTrackC->GetESDpid(pid);
                        
                        daughter = 
                            new(tracks[jTracks++]) AliAODTrack(esdTrackC->GetID(),
@@ -699,7 +699,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                               covTr, 
                                                               (Short_t)esdTrackC->GetSign(),
                                                               esdTrackC->GetITSClusterMap(), 
-                                                              pid,
+                                                              //pid,
                                                               vkink,
                                                               kTRUE, // check if this is right
                                                               kTRUE, // check if this is right
@@ -745,7 +745,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
        esdTrack->GetPxPyPz(p);
        esdTrack->GetXYZ(pos);
        esdTrack->GetCovarianceXYZPxPyPz(covTr);
-       esdTrack->GetESDpid(pid);
+       //esdTrack->GetESDpid(pid);
        
        Float_t impactXY, impactZ;
        
@@ -778,7 +778,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                                    covTr, 
                                                                    (Short_t)esdTrack->GetSign(),
                                                                    esdTrack->GetITSClusterMap(), 
-                                                                   pid,
+                                                                   //pid,
                                                                    primary,
                                                                    kTRUE, // check if this is right
                                                                    kTRUE, // check if this is right
@@ -808,7 +808,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                                   covTr, 
                                                   (Short_t)esdTrack->GetSign(),
                                                   esdTrack->GetITSClusterMap(), 
-                                                  pid,
+                                                  //pid,
                                                   NULL,
                                                   kFALSE, // check if this is right
                                                   kFALSE, // check if this is right
@@ -840,8 +840,8 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
        pos[2] = primary->GetZ();
        
        // has to be changed once the muon pid is provided by the ESD
-       for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
-       pid[AliAODTrack::kMuon]=1.;
+       //for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
+       //pid[AliAODTrack::kMuon]=1.;
        
        primary->AddDaughter(
            new(tracks[jTracks++]) AliAODTrack(0, // no ID provided
@@ -853,7 +853,7 @@ void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
                                               NULL, // no covariance matrix provided
                                               (Short_t)-99, // no charge provided
                                               0, // no ITSClusterMap
-                                              pid,
+                                              //pid,
                                               primary,
                                               kTRUE,  // check if this is right
                                               kTRUE,  // not used for vertex fit
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQa.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQa.C
new file mode 100644 (file)
index 0000000..2e2b38b
--- /dev/null
@@ -0,0 +1,660 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityKinkQa( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qa"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=0.4;
+  Double_t poiMaxEta=0.9;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaMunu.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaMunu.C
new file mode 100644 (file)
index 0000000..e26e02e
--- /dev/null
@@ -0,0 +1,661 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityKinkQaMunu( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qa"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=0.4;
+  Double_t poiMaxEta=0.9;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+  cutsPOI->SetMinKinkInvMassKmu(0.46);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaVZERO.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQaVZERO.C
new file mode 100644 (file)
index 0000000..e01b5f9
--- /dev/null
@@ -0,0 +1,649 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityKinkQaVZERO( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -5.;
+  Double_t maxA = -2.;
+  Double_t minB = 2.;
+  Double_t maxB = 5.;
+  TString totalQvectorSP="QaQb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=0.9;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kVZERO;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kVZERO);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kVZERO);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQb.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQb.C
new file mode 100644 (file)
index 0000000..632816a
--- /dev/null
@@ -0,0 +1,660 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+AliAnalysisManager AddTaskFlowCentralityKinkQb( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=-0.4;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbMunu.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbMunu.C
new file mode 100644 (file)
index 0000000..0798213
--- /dev/null
@@ -0,0 +1,661 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityKinkQbMunu( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=-0.4;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+  cutsPOI->SetMinKinkInvMassKmu(0.46);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbVZERO.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKinkQbVZERO.C
new file mode 100644 (file)
index 0000000..6a6be01
--- /dev/null
@@ -0,0 +1,649 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+AliAnalysisManager AddTaskFlowCentralityKinkQbVZERO( Float_t centrMin=0.,
+                                  Float_t centrMax=100.,
+                                  TString fileNameBase="output",
+                                  AliPID::EParticleType particleType=AliPID::kUnknown,
+                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                  Int_t charge=0,
+                                  Int_t harmonic=2,
+                                  Bool_t doQA=kFALSE,
+                                  TString uniqueStr=""
+                                )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=-0.4;
+
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  //Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+  Bool_t METHODS[] = {SP};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kVZERO;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kVZERO);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kVZERO);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(30);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  //cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(3.);
+  cutsPOI->SetMaxDCAToVertexZ(3.);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kTRUE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
+  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
+  if (particleType!=AliPID::kUnknown)
+  {
+    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+    outputSlotName+=" ";
+    outputSlotName+=AliPID::ParticleName(particleType);
+  }
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQa.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQa.C
new file mode 100644 (file)
index 0000000..745cc5c
--- /dev/null
@@ -0,0 +1,652 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityPIDQa( Float_t centrMin=0.,
+                                 Float_t centrMax=100.,
+                                 TString fileNameBase="output",
+                                 AliPID::EParticleType particleType=AliPID::kPion,
+                                 AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                 Int_t charge=0,
+                                 Int_t harmonic=2,
+                                 Bool_t doQA=kFALSE,
+                                 TString uniqueStr="" )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qa"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=0.4;
+  Double_t poiMaxEta=0.9;
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(70);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(0.3);
+  cutsPOI->SetMaxDCAToVertexZ(0.3);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kFALSE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+  outputSlotName+=" ";
+  outputSlotName+=AliPID::ParticleName(particleType);
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQaVZERO.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQaVZERO.C
new file mode 100644 (file)
index 0000000..c7d863c
--- /dev/null
@@ -0,0 +1,641 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityPIDQaVZERO( Float_t centrMin=0.,
+                                 Float_t centrMax=100.,
+                                 TString fileNameBase="output",
+                                 AliPID::EParticleType particleType=AliPID::kPion,
+                                 AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                 Int_t charge=0,
+                                 Int_t harmonic=2,
+                                 Bool_t doQA=kFALSE,
+                                 TString uniqueStr="" )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -10.;
+  Double_t maxA = -0.;
+  Double_t minB = 0.;
+  Double_t maxB = 10.;
+  TString totalQvectorSP="Qa"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=0.9;
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kVZERO;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(70);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(0.3);
+  cutsPOI->SetMaxDCAToVertexZ(0.3);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kFALSE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+  outputSlotName+=" ";
+  outputSlotName+=AliPID::ParticleName(particleType);
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQb.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQb.C
new file mode 100644 (file)
index 0000000..544897a
--- /dev/null
@@ -0,0 +1,652 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityPIDQb( Float_t centrMin=0.,
+                                 Float_t centrMax=100.,
+                                 TString fileNameBase="output",
+                                 AliPID::EParticleType particleType=AliPID::kPion,
+                                 AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                 Int_t charge=0,
+                                 Int_t harmonic=2,
+                                 Bool_t doQA=kFALSE,
+                                 TString uniqueStr="" )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -0.9;
+  Double_t maxA = -0.4;
+  Double_t minB = 0.4;
+  Double_t maxB = 0.9;
+  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=-0.4;
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
+  cutsRP->SetParamType(rptype);
+  cutsRP->SetParamMix(rpmix);
+  cutsRP->SetPtRange(0.2,5.);
+  cutsRP->SetEtaRange(-0.8,0.8);
+  cutsRP->SetMinNClustersTPC(70);
+  cutsRP->SetMinChi2PerClusterTPC(0.1);
+  cutsRP->SetMaxChi2PerClusterTPC(4.0);
+  cutsRP->SetMaxDCAToVertexXY(3.0);
+  cutsRP->SetMaxDCAToVertexZ(3.0);
+  cutsRP->SetAcceptKinkDaughters(kFALSE);
+  cutsRP->SetMinimalTPCdedx(10.);
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(70);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(0.3);
+  cutsPOI->SetMaxDCAToVertexZ(0.3);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kFALSE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+  outputSlotName+=" ";
+  outputSlotName+=AliPID::ParticleName(particleType);
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQbVZERO.C b/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPIDQbVZERO.C
new file mode 100644 (file)
index 0000000..9db7217
--- /dev/null
@@ -0,0 +1,641 @@
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// AddTask* macro for flow analysis
+// Creates a Flow Event task and adds it to the analysis manager.
+// Sets the cuts using the correction framework (CORRFW) classes.
+// Also creates Flow Analysis tasks and connects them to the output of the flow event task.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+void AddTaskFlowCentralityPIDQbVZERO( Float_t centrMin=0.,
+                                 Float_t centrMax=100.,
+                                 TString fileNameBase="output",
+                                 AliPID::EParticleType particleType=AliPID::kPion,
+                                 AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
+                                 Int_t charge=0,
+                                 Int_t harmonic=2,
+                                 Bool_t doQA=kFALSE,
+                                 TString uniqueStr="" )
+{
+  // Define the range for eta subevents (for SP method)
+  Double_t minA = -10.;
+  Double_t maxA = -0.;
+  Double_t minB = 0.;
+  Double_t maxB = 10.;
+  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
+  Double_t poiMinEta=-0.9;
+  Double_t poiMaxEta=0.9;
+
+  // AFTERBURNER
+  Bool_t useAfterBurner=kFALSE;
+  Double_t v1=0.0;
+  Double_t v2=0.0;
+  Double_t v3=0.0;
+  Double_t v4=0.0;
+  Int_t numberOfTrackClones=0; //non-flow
+
+  // Define a range of the detector to exclude
+  Bool_t ExcludeRegion = kFALSE;
+  Double_t excludeEtaMin = -0.;
+  Double_t excludeEtaMax = 0.;
+  Double_t excludePhiMin = 0.;
+  Double_t excludePhiMax = 0.;
+
+  // use physics selection class
+  Bool_t  UsePhysicsSelection = kTRUE;
+
+  // QA
+  Bool_t runQAtask=kFALSE;
+  Bool_t FillQAntuple=kFALSE;
+  Bool_t DoQAcorrelations=kFALSE;
+
+  // RUN SETTINGS
+  // Flow analysis method can be:(set to kTRUE or kFALSE)
+  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
+  Bool_t QC       = kTRUE;  // cumulants using Q vectors
+  
+  //these are OBSOLETE, use at own peril
+  Bool_t GFC      = kFALSE;  // cumulants based on generating function
+  Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
+  Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)
+  Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)
+  Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)
+  Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
+  Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
+  Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
+  Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  
+  Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
+
+  Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
+
+  // Boolean to use/not use weights for the Q vector
+  Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
+
+  // SETTING THE CUTS
+
+  //---------Data selection----------
+  //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet
+  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kVZERO;
+  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
+
+  //---------Parameter mixing--------
+  //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt
+  AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;
+  AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
+
+
+  const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
+  const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
+
+  //===========================================================================
+  // EVENTS CUTS:
+  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
+  cutsEvent->SetNContributorsRange(2);
+  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
+  cutsEvent->SetQA(doQA);
+  
+  // RP TRACK CUTS:
+  AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();
+  cutsRP->SetQA(doQA);
+
+  // POI TRACK CUTS:
+  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
+  cutsPOI->SetParamType(poitype);
+  cutsPOI->SetParamMix(poimix);
+  cutsPOI->SetPtRange(0.0,10.);
+  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
+  //cutsPOI->SetRequireCharge(kTRUE);
+  //cutsPOI->SetPID(PdgRP);
+  cutsPOI->SetMinNClustersTPC(70);
+  cutsPOI->SetMinChi2PerClusterTPC(0.1);
+  cutsPOI->SetMaxChi2PerClusterTPC(4.0);
+  cutsPOI->SetRequireITSRefit(kTRUE);
+  cutsPOI->SetRequireTPCRefit(kTRUE);
+  cutsPOI->SetMinNClustersITS(2);
+  //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);
+  cutsPOI->SetMaxDCAToVertexXY(0.3);
+  cutsPOI->SetMaxDCAToVertexZ(0.3);
+  //cutsPOI->SetDCAToVertex2D(kTRUE);
+  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
+  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
+  cutsPOI->SetAcceptKinkDaughters(kFALSE);
+  cutsPOI->SetPID(particleType, sourcePID);
+  if (charge!=0) cutsPOI->SetCharge(charge);
+  //cutsPOI->SetAllowTOFmismatch(kFALSE);
+  cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);
+  //iexample: francesco's tunig TPC Bethe Bloch for data:
+  //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);
+  //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);
+  cutsPOI->SetMinimalTPCdedx(10.);
+  cutsPOI->SetQA(doQA);
+
+  TString outputSlotName("");
+  outputSlotName+=uniqueStr;
+  outputSlotName+=" ";
+  outputSlotName+=totalQvectorSP;
+  outputSlotName+=" ";
+  outputSlotName+=Form("V%i ",harmonic);
+  outputSlotName+=cutsRP->GetName();
+  outputSlotName+=" ";
+  outputSlotName+=cutsPOI->GetName();
+  outputSlotName+=Form(" %.0f-",centrMin);
+  outputSlotName+=Form("%.0f ",centrMax);
+  outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
+  outputSlotName+=" ";
+  outputSlotName+=AliPID::ParticleName(particleType);
+  if (charge<0) outputSlotName+="-";
+  if (charge>0) outputSlotName+="+";
+
+  TString fileName(fileNameBase);
+  fileName.Append(".root");
+
+  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
+  if (useWeights) cout<<"Weights are used"<<endl;
+  else cout<<"Weights are not used"<<endl;
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
+    return NULL;
+  }
+  
+  // Check the analysis type using the event handlers connected to the analysis
+  // manager. The availability of MC handler can also be checked here.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // Open external input files
+  //===========================================================================
+  //weights: 
+  TFile *weightsFile = NULL;
+  TList *weightsList = NULL;
+
+  if(useWeights) {
+    //open the file with the weights:
+    weightsFile = TFile::Open("weights.root","READ");
+    if(weightsFile) {
+      //access the list which holds the histos with weigths:
+      weightsList = (TList*)weightsFile->Get("weights");
+    }
+    else {
+      cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;
+      break;
+    } 
+  }
+  
+  //LYZ2
+  if (LYZ2SUM || LYZ2PROD) {
+    //read the outputfile of the first run
+    TString outputFileName = "AnalysisResults1.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
+    
+    if (LYZ2SUM){  
+      // read the output directory from LYZ1SUM 
+      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
+      inputFileNameLYZ2SUM += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
+      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
+      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
+       if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2SUM input file/list read..."<<endl;
+    }
+
+    if (LYZ2PROD){  
+      // read the output directory from LYZ1PROD 
+      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
+      inputFileNameLYZ2PROD += rptypestr;
+      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
+      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
+      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
+       cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
+       break;
+      }
+      else {
+       TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
+       if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
+      }
+      cout<<"LYZ2PROD input file/list read..."<<endl;
+    }
+  }
+
+  if (LYZEP) {
+    //read the outputfile of the second run
+    TString outputFileName = "AnalysisResults2.root";
+    TString pwd(gSystem->pwd());
+    pwd+="/";
+    pwd+=outputFileName.Data();
+    TFile *outputFile = NULL;
+    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
+      cout<<"WARNING: You do not have an output file:"<<endl;
+      cout<<"         "<<pwd.Data()<<endl;
+      exit(0);
+    } else {
+      outputFile = TFile::Open(pwd.Data(),"READ");
+    }
+    
+    // read the output file from LYZ2SUM
+    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
+    inputFileNameLYZEP += rptypestr;
+    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
+    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
+    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
+      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
+      break;
+    }
+    else {
+      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
+      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
+    }
+    cout<<"LYZEP input file/list read..."<<endl;
+  }
+  
+  
+  // Create the FMD task and add it to the manager
+  //===========================================================================
+  if (rptypestr == "FMD") {
+    AliFMDAnalysisTaskSE *taskfmd = NULL;
+    if (rptypestr == "FMD") {
+      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
+      mgr->AddTask(taskfmd);
+      
+      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
+      pars->Init();
+      pars->SetProcessPrimary(kTRUE); //for MC only
+      pars->SetProcessHits(kFALSE);
+      
+      //pars->SetRealData(kTRUE); //for real data
+      //pars->SetProcessPrimary(kFALSE); //for real data
+    }
+  }
+  
+  // Create the flow event task, add it to the manager.
+  //===========================================================================
+  AliAnalysisTaskFlowEvent *taskFE = NULL;
+
+  if(useAfterBurner)
+    { 
+      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
+      taskFE->SetFlow(v1,v2,v3,v4); 
+      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
+      taskFE->SetAfterburnerOn();
+    }
+  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
+  if (ExcludeRegion) {
+    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
+  }
+  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
+  if (UsePhysicsSelection) {
+    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
+    cout<<"Using Physics Selection"<<endl;
+  }
+  mgr->AddTask(taskFE);
+  
+  // Pass cuts for RPs and POIs to the task:
+  taskFE->SetCutsEvent(cutsEvent);
+  taskFE->SetCutsRP(cutsRP);
+  taskFE->SetCutsPOI(cutsPOI);
+  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
+  { 
+    //TODO: since this is set in a static object all analyses in an analysis train
+    //will be affected.
+    taskFE->SetHistWeightvsPhiMin(0.);
+    taskFE->SetHistWeightvsPhiMax(200.);
+  }
+
+  // Create the analysis tasks, add them to the manager.
+  //===========================================================================
+  if (SP){
+    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
+    taskSP->SetRelDiffMsub(1.0);
+    taskSP->SetApplyCorrectionForNUA(kTRUE);
+    taskSP->SetTotalQvector(totalQvectorSP.Data());
+    mgr->AddTask(taskSP);
+  }
+  if (LYZ1SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
+    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ1SUM);
+  }
+  if (LYZ1PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
+    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
+    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ1PROD);
+  }
+  if (LYZ2SUM){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
+    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
+    mgr->AddTask(taskLYZ2SUM);
+  }
+  if (LYZ2PROD){
+    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
+    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
+    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
+    mgr->AddTask(taskLYZ2PROD);
+  }
+  if (LYZEP){
+    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskLYZEP);
+  }
+  if (GFC){
+    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
+    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskGFC->SetUsePtWeights(WEIGHTS[1]);
+    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
+    mgr->AddTask(taskGFC);
+  }
+  if (QC){
+    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
+    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
+    taskQC->SetUsePtWeights(WEIGHTS[1]);
+    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
+    taskQC->SetCalculateCumulantsVsM(kFALSE);
+    taskQC->SetnBinsMult(10000);
+    taskQC->SetMinMult(0.);
+    taskQC->SetMaxMult(10000.);
+    taskQC->SetHarmonic(harmonic);
+    taskQC->SetApplyCorrectionForNUA(kFALSE);
+    taskQC->SetFillMultipleControlHistograms(kFALSE);     
+    mgr->AddTask(taskQC);
+  }
+  if (FQD){
+    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
+    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
+    taskFQD->SetqMin(0.);
+    taskFQD->SetqMax(1000.);
+    taskFQD->SetqNbins(10000);
+    mgr->AddTask(taskFQD);
+  }
+  if (MCEP){
+    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
+    mgr->AddTask(taskMCEP);
+  }
+  if (MH){
+    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
+    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskMH->SetNoOfMultipicityBins(10000);
+    taskMH->SetMultipicityBinWidth(1.);
+    taskMH->SetMinMultiplicity(1.);
+    taskMH->SetCorrectForDetectorEffects(kTRUE);
+    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
+    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskMH);
+  }  
+  if (NL){
+    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
+    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
+    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
+    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
+    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
+    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
+    mgr->AddTask(taskNL);
+  }
+
+  // Create the output container for the data produced by the task
+  // Connect to the input and output containers
+  //===========================================================================
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (rptypestr == "FMD") {
+    AliAnalysisDataContainer *coutputFMD = 
+      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
+    //input and output taskFMD     
+    mgr->ConnectInput(taskfmd, 0, cinput1);
+    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
+    //input into taskFE
+    mgr->ConnectInput(taskFE,1,coutputFMD);
+  }
+  
+  AliAnalysisDataContainer *coutputFE = 
+  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
+  mgr->ConnectInput(taskFE,0,cinput1); 
+  mgr->ConnectOutput(taskFE,1,coutputFE);
+  if (taskFE->GetQAOn())
+  {
+    TString outputQA = fileName;
+    outputQA += ":QA";
+    AliAnalysisDataContainer* coutputFEQA = 
+    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
+    mgr->ConnectOutput(taskFE,2,coutputFEQA);
+  }
+
+  // Create the output containers for the data produced by the analysis tasks
+  // Connect to the input and output containers
+  //===========================================================================
+  if (useWeights) {    
+    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer); 
+  }
+
+  if(SP) {
+    TString outputSP = fileName;
+    outputSP += ":outputSPanalysis";
+    outputSP+= rptypestr;
+    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
+    mgr->ConnectInput(taskSP,0,coutputFE); 
+    mgr->ConnectOutput(taskSP,1,coutputSP); 
+    if (WEIGHTS[0]) {
+      mgr->ConnectInput(taskSP,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(LYZ1SUM) {
+    TString outputLYZ1SUM = fileName;
+    outputLYZ1SUM += ":outputLYZ1SUManalysis";
+    outputLYZ1SUM+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
+    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
+    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
+  }
+  if(LYZ1PROD) {
+    TString outputLYZ1PROD = fileName;
+    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
+    outputLYZ1PROD+= rptypestr;
+    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
+    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
+    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
+  }
+  if(LYZ2SUM) {
+    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
+                                                                  TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2SUM = fileName;
+    outputLYZ2SUM += ":outputLYZ2SUManalysis";
+    outputLYZ2SUM+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
+                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
+    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
+    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
+    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
+  }
+  if(LYZ2PROD) {
+    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
+                                                                   TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZ2PROD = fileName;
+    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
+    outputLYZ2PROD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
+                                                                    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
+    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
+    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
+    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
+    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
+  }
+  if(LYZEP) {
+    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
+                                                                TList::Class(),AliAnalysisManager::kInputContainer);
+    TString outputLYZEP = fileName;
+    outputLYZEP += ":outputLYZEPanalysis";
+    outputLYZEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
+                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
+    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
+    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
+    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
+    cinputLYZEP->SetData(fInputListLYZEP);
+  }
+  if(GFC) {
+    TString outputGFC = fileName;
+    outputGFC += ":outputGFCanalysis";
+    outputGFC+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
+    mgr->ConnectInput(taskGFC,0,coutputFE); 
+    mgr->ConnectOutput(taskGFC,1,coutputGFC);
+    if (useWeights) {
+      mgr->ConnectInput(taskGFC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(QC) {
+    TString outputQC = fileName;
+    outputQC += ":outputQCanalysis";
+    outputQC+= rptypestr;
+
+    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
+    mgr->ConnectInput(taskQC,0,coutputFE); 
+    mgr->ConnectOutput(taskQC,1,coutputQC);
+    if (useWeights) {
+      mgr->ConnectInput(taskQC,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    }
+  }
+  if(FQD) {
+    TString outputFQD = fileName;
+    outputFQD += ":outputFQDanalysis";
+    outputFQD+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
+                                                               TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
+    mgr->ConnectInput(taskFQD,0,coutputFE); 
+    mgr->ConnectOutput(taskFQD,1,coutputFQD);
+    if(useWeights) {
+      mgr->ConnectInput(taskFQD,1,cinputWeights);
+      cinputWeights->SetData(weightsList);
+    } 
+  }
+  if(MCEP) {
+    TString outputMCEP = fileName;
+    outputMCEP += ":outputMCEPanalysis";
+    outputMCEP+= rptypestr;
+    
+    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
+                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
+    mgr->ConnectInput(taskMCEP,0,coutputFE);
+    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
+  }
+  if(MH) {
+    TString outputMH = fileName;
+    outputMH += ":outputMHanalysis";
+    outputMH += rptypestr;
+        
+    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
+    mgr->ConnectInput(taskMH,0,coutputFE); 
+    mgr->ConnectOutput(taskMH,1,coutputMH); 
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskMH,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+  if(NL) {
+    TString outputNL = fileName;
+    outputNL += ":outputNLanalysis";
+    outputNL += rptypestr;
+
+    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
+                                                              TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
+    mgr->ConnectInput(taskNL,0,coutputFE);
+    mgr->ConnectOutput(taskNL,1,coutputNL);
+    //if (useWeights) {
+    //  mgr->ConnectInput(taskNL,1,cinputWeights);
+    //  cinputWeights->SetData(weightsList);
+    //} 
+  }
+
+  ///////////////////////////////////////////////////////////////////////////////////////////
+  if (runQAtask)
+  {
+    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
+    taskQAflow->SetEventCuts(cutsEvent);
+    taskQAflow->SetTrackCuts(cutsRP);
+    taskQAflow->SetFillNTuple(FillQAntuple);
+    taskQAflow->SetDoCorrelations(DoQAcorrelations);
+    mgr->AddTask(taskQAflow);
+    
+    Printf("outputSlotName %s",outputSlotName.Data());
+    TString taskQAoutputFileName(fileNameBase);
+    taskQAoutputFileName.Append("_QA.root");
+    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
+                                              TObjArray::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
+                                              TNtuple::Class(),
+                                              AliAnalysisManager::kOutputContainer,
+                                              taskQAoutputFileName);
+    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
+    mgr->ConnectInput(taskQAflow,1,coutputFE);
+    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
+    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
+  }
+}
+
+
+
+
+
diff --git a/PWGCF/FLOW/macros/Kinks/runFlowTaskCentralityKinkTrain.C b/PWGCF/FLOW/macros/Kinks/runFlowTaskCentralityKinkTrain.C
new file mode 100644 (file)
index 0000000..8c1c462
--- /dev/null
@@ -0,0 +1,378 @@
+enum anaModes {mLocal,mPROOF,mGrid};
+Int_t binfirst = 0;  //where do we start numbering bins
+Int_t binlast = 8;  //where do we stop numbering bins
+const Int_t numberOfCentralityBins = 9;
+Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
+//Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
+
+TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
+
+void runFlowTaskCentralityKinkTrain( Int_t mode = mLocal,
+                                     Bool_t useFlowParFiles = kFALSE,
+                                     Bool_t DATA = kTRUE,
+                                     const Char_t* dataDir="fileList",
+                                     Int_t nEvents = 1e4,
+                                     Int_t offset=0 )
+{
+  // Time:
+  TStopwatch timer;
+  timer.Start();
+
+  // Load needed libraries:
+  LoadLibraries(mode,useFlowParFiles);
+
+  // Create analysis manager:
+  AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
+
+  // Chains:
+  if(mode == mLocal)
+  {
+    gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
+    TChain* chain = CreateESDChain(dataDir, nEvents, offset);
+    //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
+  }
+
+  // Connect plug-in to the analysis manager:
+  if(mode == mGrid)
+  {
+    gROOT->LoadMacro("CreateAlienHandler.C");
+    AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
+    if(!alienHandler) return;
+    mgr->SetGridHandler(alienHandler);
+  }
+
+  // Event handlers:
+  AliVEventHandler* esdH = new AliESDInputHandler;
+  mgr->SetInputEventHandler(esdH);
+  if (!DATA)
+  {
+    AliMCEventHandler *mc = new AliMCEventHandler();
+    mgr->SetMCtruthEventHandler(mc);
+  }
+
+  // Task to check the offline trigger:
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+  AddTaskPhysicsSelection(!DATA);
+
+  //Add the centrality determination task
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
+  AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
+  if (!DATA) centSelTask->SetMCInput();
+
+  //add the PID response task
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
+  AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(!DATA);
+
+  //Add the TOF tender
+  //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskTenderTOF.C");
+  //AddTaskTenderTOF();
+
+  // Setup kink analysis per centrality bin:
+  gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKink.C");
+  for (Int_t i=binfirst; i<binlast+1; i++)
+  {
+    Float_t lowCentralityBinEdge = centralityArray[i];
+    Float_t highCentralityBinEdge = centralityArray[i+1];
+    AddTaskFlowCentralityKink( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kUnknown,
+                              AliFlowTrackCuts::kTOFbeta,
+                              -1,2,kTRUE );
+    AddTaskFlowCentralityKink( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kUnknown,
+                              AliFlowTrackCuts::kTOFbeta,
+                              1,2,kTRUE );
+    AddTaskFlowCentralityKink( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kUnknown,
+                              AliFlowTrackCuts::kTOFbeta,
+                              -1,3 );
+    AddTaskFlowCentralityKink( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kUnknown,
+                              AliFlowTrackCuts::kTOFbeta,
+                              1,3 );
+  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+
+  // Setup kaon analysis per centrality bin:
+  gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
+  for (Int_t i=binfirst; i<binlast+1; i++)
+  {
+    Float_t lowCentralityBinEdge = centralityArray[i];
+    Float_t highCentralityBinEdge = centralityArray[i+1];
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kKaon,
+                              AliFlowTrackCuts::kTOFbeta,
+                              -1,2,kTRUE );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kKaon,
+                              AliFlowTrackCuts::kTOFbeta,
+                              1,2,kTRUE );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kKaon,
+                              AliFlowTrackCuts::kTOFbeta,
+                              -1,3 );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kKaon,
+                              AliFlowTrackCuts::kTOFbeta,
+                              1,3 );
+  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+
+  // Setup He3 analysis per centrality bin:
+  gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
+  for (Int_t i=binfirst; i<binlast+1; i++)
+  {
+    Float_t lowCentralityBinEdge = centralityArray[i];
+    Float_t highCentralityBinEdge = centralityArray[i+1];
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kHe3,
+                              AliFlowTrackCuts::kTPCNuclei,
+                              -1,2,kTRUE );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kHe3,
+                              AliFlowTrackCuts::kTPCNuclei,
+                              1,2,kTRUE );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kHe3,
+                              AliFlowTrackCuts::kTPCNuclei,
+                              -1,3 );
+    AddTaskFlowCentralityPID( lowCentralityBinEdge,
+                              highCentralityBinEdge,
+                              commonOutputFileName,
+                              AliPID::kHe3,
+                              AliFlowTrackCuts::kTPCNuclei,
+                              1,3 );
+  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+
+  // Enable debug printouts:
+  mgr->SetDebugLevel(2);
+  // Run the analysis:
+  if(!mgr->InitAnalysis()) return;
+  mgr->PrintStatus();
+  if(mode == mLocal)
+  {
+    mgr->StartAnalysis("local",chain);
+  }
+  else if(mode == mPROOF)
+  {
+    mgr->StartAnalysis("proof",dataDir,nEvents,offset);
+  }
+  else if(mode == mGrid)
+  {
+    mgr->StartAnalysis("grid");
+  }
+
+  // Print real and CPU time used for analysis:
+  timer.Stop();
+  timer.Print();
+
+} // end of void runFlowTaskCentralityPIDTrain(...)
+
+//===============================================================================================
+/*
+void CrossCheckUserSettings(Bool_t bData)
+{
+ // Check in this method if the user settings make sense.
+ if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
+ if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
+ if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
+ if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
+} // end of void CrossCheckUserSettings()
+*/
+//===============================================================================================
+
+void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
+{
+  //--------------------------------------
+  // Load the needed libraries most of them already loaded by aliroot
+  //--------------------------------------
+
+  gSystem->Load("libCore");
+  gSystem->Load("libTree");
+  gSystem->Load("libGeom");
+  gSystem->Load("libVMC");
+  gSystem->Load("libXMLIO");
+  gSystem->Load("libPhysics");
+  gSystem->Load("libXMLParser");
+  gSystem->Load("libProof");
+  gSystem->Load("libMinuit");
+
+  if (mode==mLocal || mode==mGrid)
+  {
+    gSystem->Load("libSTEERBase");
+    gSystem->Load("libCDB");
+    gSystem->Load("libRAWDatabase");
+    gSystem->Load("libRAWDatarec");
+    gSystem->Load("libESD");
+    gSystem->Load("libAOD");
+    gSystem->Load("libSTEER");
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libTPCbase");
+    gSystem->Load("libTOFbase");
+    gSystem->Load("libTOFrec");
+    gSystem->Load("libTRDbase");
+    gSystem->Load("libVZERObase");
+    gSystem->Load("libVZEROrec");
+    gSystem->Load("libT0base");
+    gSystem->Load("libT0rec");
+    gSystem->Load("libTENDER");
+    gSystem->Load("libTENDERSupplies");
+
+    if (useFlowParFiles)
+    {
+      AliAnalysisAlien::SetupPar("PWGflowBase");
+      AliAnalysisAlien::SetupPar("PWGflowTasks");
+    }
+    else
+    {
+      gSystem->Load("libPWGflowBase");
+      gSystem->Load("libPWGflowTasks");
+    }
+  }
+  else if (mode==mPROOF)
+  {
+    TList* list = new TList();
+    list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
+    if (useFlowParFiles)
+      list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
+    else
+      list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWGflowBase:PWGflowTasks"));
+
+    //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
+
+    // Connect to proof
+    printf("*** Connect to PROOF ***\n");
+    gEnv->SetValue("XSec.GSI.DelegProxy","2");
+    //TProof* proof = TProof::Open("alice-caf.cern.ch");
+    TProof* proof = TProof::Open("skaf.saske.sk");
+
+    // list the data available
+    //gProof->ShowDataSets("/*/*");
+    //gProof->ShowDataSets("/alice/sim/"); //for MC Data
+    //gProof->ShowDataSets("/alice/data/"); //for REAL Data
+
+    proof->ClearPackages();
+    proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
+
+    if (useFlowParFiles)
+    {
+      gProof->UploadPackage("PWGflowBase.par");
+      gProof->UploadPackage("PWGflowTasks.par");
+    }
+
+    // Show enables Packages
+    gProof->ShowEnabledPackages();
+  }
+} // end of void LoadLibraries(const anaModes mode)
+
+//===============================================================================================
+
+TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+{
+  // creates chain of files in a given directory or file containing a list.
+  // In case of directory the structure is expected as:
+  // <aDataDir>/<dir0>/AliAOD.root
+  // <aDataDir>/<dir1>/AliAOD.root
+  // ...
+
+  if (!aDataDir)
+    return 0;
+
+  Long_t id, size, flags, modtime;
+  if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+  {
+    printf("%s not found.\n", aDataDir);
+    return 0;
+  }
+
+  TChain* chain = new TChain("aodTree");
+  TChain* chaingAlice = 0;
+
+  if (flags & 2)
+  {
+    TString execDir(gSystem->pwd());
+    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+    TList* dirList            = baseDir->GetListOfFiles();
+    Int_t nDirs               = dirList->GetEntries();
+    gSystem->cd(execDir);
+
+    Int_t count = 0;
+
+    for (Int_t iDir=0; iDir<nDirs; ++iDir)
+    {
+      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+        continue;
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      TString presentDirName(aDataDir);
+      presentDirName += "/";
+      presentDirName += presentDir->GetName();
+      chain->Add(presentDirName + "/AliAOD.root/aodTree");
+      // cerr<<presentDirName<<endl;
+    }
+
+  }
+  else
+  {
+    // Open the input stream
+    ifstream in;
+    in.open(aDataDir);
+
+    Int_t count = 0;
+
+    // Read the input list of files and add them to the chain
+    TString aodfile;
+    while(in.good())
+    {
+      in >> aodfile;
+      if (!aodfile.Contains("root")) continue; // protection
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      // add aod file
+      chain->Add(aodfile);
+    }
+
+    in.close();
+  }
+
+  return chain;
+
+} // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
+
diff --git a/PWGCF/FLOW/macros/merge.C b/PWGCF/FLOW/macros/merge.C
new file mode 100644 (file)
index 0000000..c05a77d
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+  merge output calib objects on Alien
+  using AliFileMerger functionality
+
+  Directory with runCalibTrain output: outputDir
+  pattern: AliESDfriends_v1.root
+  Output file name: CalibObjects.root
+
+  Example:
+  .L $ALICE_ROOT/ANALYSIS/CalibMacros/MergeCalibration/merge.C
+  merge("alien:///alice/cern.ch/user/j/jotwinow/CalibTrain/output","AliESDfriends_v1.root");
+*/
+void mergeInChunksTXT(const char* mlist, const char* dest, int maxFiles=700);
+
+
+void merge(const char* outputDir, const char* pattern, Bool_t copyLocal=kFALSE, const char* outputFileName="mergedAnalysisResults.root")
+{
+  //
+  // load libraries
+  //
+  printf("Merging with chunks copying turned %s\n",copyLocal ? "ON":"OFF");
+  gROOT->Macro("$ALICE_ROOT/PWGCF/FLOW/macros/LoadLibraries.C");
+  
+  //if pattern is empty and outputDir is a local file assume it contains the list of files to merge
+  //otherwise fall back to old behaviour: search alien and process those files
+  TString listFileName("file.list");
+  TString patternStr(pattern);
+  Long_t id, size, flags, modtime;
+  Bool_t outputDirFailure = gSystem->GetPathInfo(outputDir, &id, &size, &flags, &modtime);
+  printf("st: %i, flags: %i, patt: %s\n",outputDirFailure,flags,patternStr.Data());
+  if (!outputDirFailure && (flags==0)) 
+  { 
+    printf("### processing local fileList: %s\n",outputDir);
+    listFileName=outputDir;
+  }
+  else
+  {
+    cpTimeOut(outputDir, pattern, 10, copyLocal);
+    listFileName="calib.list";
+  }
+
+  //
+  // local
+  mergeInChunksTXT(listFileName.Data(),outputFileName);
+  //  AliFileMerger merger;
+  //  merger.AddReject("esdFriend"); // do not merge
+  //  merger.SetMaxFilesOpen(700);
+  //  merger.IterTXT("calib.list","CalibObjects.root",kFALSE);
+
+  // alien
+  //merger.IterAlien(outputDir, "CalibObjects.root", pattern);
+
+  return;
+}
+
+void cpTimeOut(const char * searchdir, const char* pattern, Int_t timeOut=10, Bool_t copyLocal)
+{
+
+  gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut));
+  gEnv->SetValue("XNet.RequestTimeout", timeOut);
+  gEnv->SetValue("XNet.ConnectTimeout", timeOut);
+  gEnv->SetValue("XNet.TransactionTimeout", timeOut);
+  TFile::SetOpenTimeout(timeOut);
+
+  TGrid::Connect("alien");
+
+  TString filelist;
+  TString command;
+  command = Form("find %s/ %s", searchdir, pattern);
+  cerr<<"command: "<<command<<endl;
+  TGridResult *res = gGrid->Command(command);
+  if (!res) return;
+  res->Print();
+  TIter nextmap(res);
+  TMap *map = 0;
+
+  ofstream outputFile;
+  outputFile.open(Form("calib.list"));
+  Int_t counter=0;
+
+  while((map=(TMap*)nextmap())) 
+  {
+    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
+    if (!objs || !objs->GetString().Length())
+    {
+      delete res;
+      break;
+    }
+
+    TString src=Form("%s",objs->GetString().Data());
+    TString dst=src;
+    Bool_t result = kTRUE;
+    if (copyLocal) {
+      dst.ReplaceAll("alien:///","");
+      dst.ReplaceAll("/","_");
+      TTimeStamp s1;
+      result = TFile::Cp(src.Data(),dst.Data(),kTRUE);
+      TTimeStamp s2;
+      AliSysInfo::AddStamp(dst.Data(),counter, result);
+    }
+    if (result) {
+      counter++;
+      outputFile << dst.Data()<< endl;
+    }
+  }
+  if (copyLocal) cout<<counter<<" files copied!"<<endl;
+  else           cout<<counter<<" files registerd!"<<endl;
+  outputFile.close();
+  gSystem->Exec("mv syswatch.log syswatch_copy.log");
+  return;
+}
+
+void mergeInChunksTXT(const char* mlist, const char* dest, int maxFiles)
+{
+  TH1::AddDirectory(0);
+  AliFileMerger merger;
+  merger.SetNoTrees(kFALSE);
+  //  merger.SetMaxFilesOpen(999);
+  merger.AddReject("esdFriend"); // do not merge
+  merger.AddReject("syswatchRec"); // do not merge
+  merger.AddReject("syswatchCalib"); // do not merge
+  //
+  if (maxFiles<2) maxFiles = 2;
+  TString filesToMerge = mlist, fileDest = dest;
+  if (filesToMerge.IsNull()) {printf("List to merge is not provided\n"); return;}
+  if (fileDest.IsNull())     {printf("Merging destination is not provided\n"); return;}
+  const char* tmpMerge[3]={"__merge_part0.root","__merge_part1.root","__part_of_calib.list"};
+  //
+  gSystem->ExpandPathName(filesToMerge);
+  ofstream outfile;
+  ifstream infile(filesToMerge.Data());
+  if (!infile) {printf("No %s file\n",filesToMerge.Data()); return;}
+  //
+  int currTmp = 0, nfiles = 0, nparts = 0; // counter for number of merging operations
+  string line;
+  TString lineS;
+  while ( !infile.eof() ) {
+    getline(infile, line); 
+    lineS = line;
+    if (lineS.IsNull() || lineS.BeginsWith("#")) continue;
+    int st = nfiles%maxFiles;
+    if (st==0) { // new chunk should be started
+      if (nfiles) { // merge prev. chunk
+       outfile.close();
+       merger.IterTXT(tmpMerge[2], tmpMerge[currTmp] ,kFALSE);
+       printf("Merging to %s | %d files at step %d\n",tmpMerge[currTmp], nfiles,nparts);
+      }
+      outfile.open(tmpMerge[2], ios::out); // start list for new chunk  
+      if (nparts++) {
+       printf("Adding previous result %s | %d files %d at part\n",tmpMerge[currTmp], nfiles,nparts);
+       outfile << tmpMerge[currTmp] << endl; // result of previous merge goes 1st
+      }
+      currTmp = (currTmp==0) ? 1:0;         // swap tmp files
+    }
+    outfile << line << endl;
+    nfiles++;
+  }
+  // merge the rest
+  merger.IterTXT(tmpMerge[2], dest ,kFALSE);
+  outfile.close();
+  infile.close();
+  for (int i=0;i<3;i++) gSystem->Exec(Form("if [ -e %s ]; then \nrm %s\nfi",tmpMerge[i],tmpMerge[i]));
+  printf("Merged %d files in %d steps\n",nfiles, nparts);
+  //
+}
+
index 216dd8987953759ae2176d526d90341184599ff5..d268dde816ca808a4805e7c2e7c32244d25056e7 100644 (file)
@@ -41,6 +41,7 @@ void redoFinish()
     if(!(mergedFileName == outputFileName))
     {
       TSystemFile *fileTemp = new TSystemFile(mergedFileFullPathName.Data(),".");
+      gSystem->Unlink("mergedAnalysisResultsTemp.root");
       fileTemp->Copy("mergedAnalysisResultsTemp.root");
       delete fileTemp;
     }
index b89ba7fba04be03514511bfb53dcbf66b7172236..58040548a7a3dc3ee535e8e20fb721824f70f221 100644 (file)
@@ -39,4 +39,6 @@
 #pragma link C++ class AliTwoParticlePIDCorr+;
 #pragma link C++ class LRCParticlePID+;
 #pragma link C++ class AliAnalysisTaskPidPidCorrelations+;
+#pragma link C++ class AliPidPidCorrelationReducedTrack+;
+#pragma link C++ class AliAnalysisTaskPhiEffMc+;
 #endif
index 370e400d4e6a9e94c5fbf4df24a8f847a1b3070c..3177aa886067f24080d54ab7c2f40fed0674bff4 100644 (file)
@@ -156,6 +156,7 @@ if(fCreateNanoAOD && isAOD){
    extDielectron->GetAOD()->GetStdContent();
    }else if(fCreateNanoAOD && !isAOD){AliWarning("Filtered-Nano AODs creation works only on AODs ");  } 
   
+  PostData(1, const_cast<THashList*>(fDielectron->GetHistogramList()));
   PostData(2,fEventStat);
 }
 
@@ -197,7 +198,7 @@ void AliAnalysisTaskDielectronFilter::UserExec(Option_t *)
   //before physics selection
   fEventStat->Fill(kAllEvents);
   if (isSelected==0||isRejected) {
-    PostData(3,fEventStat);
+    PostData(2,fEventStat);
     return;
   }
   //after physics selection
index 1bfb813d9e500e612573d413caf215716bce7162..545fe1d4a116811c3419bcfdfc5087f21b41e934 100644 (file)
@@ -557,7 +557,7 @@ void AliDielectronHF::Init()
   Int_t istep=0;
   if(fPairType != kMConly) {
     for(istep=0; istep<AliDielectron::kEv1PMRot+1; istep++) {
-      //    for(Int_t i=steps; i<steps+AliDielectron::kEv1PMRot+1; i++) {
+
       if(IsPairTypeSelected(istep)) {
        // add a deep copy of the array
        fArrPairType[istep]=(TObjArray*)histArr->Clone(AliDielectron::PairClassName(istep));
@@ -568,12 +568,6 @@ void AliDielectronHF::Init()
        ((TObjArray*)fArrPairType[istep])->SetOwner();
        ((TObjArray*)fArrPairType[istep])->SetName(AliDielectron::PairClassName(istep));
       }
-      // fArrPairType[istep]=(TObjArray*)histArr->Clone(AliDielectron::PairClassName(istep));
-      // ((TObjArray*)fArrPairType[istep])->SetOwner();
-      // if(!IsPairTypeSelected(istep)) {
-      //       ((TObjArray*)fArrPairType[istep])->Delete();
-      //       ((TObjArray*)fArrPairType[istep])->Expand(0);
-      // }
     } //end: loop over pair types
   }
 
@@ -615,8 +609,8 @@ Bool_t AliDielectronHF::IsPairTypeSelected(Int_t itype)
 {
   //
   // check whether a pair type was selected
-  //
-  
+  // TODO: cross check or replace by mixinghandlers processsing
+
   Bool_t selected = kFALSE;
 
   // fill all
@@ -635,6 +629,8 @@ Bool_t AliDielectronHF::IsPairTypeSelected(Int_t itype)
     if(fPairType==kMeAll || fPairType==kSeMeAll)   selected = kTRUE;
     break;
   case AliDielectron::kEv1PEv2M:
+    if(fPairType==kMeAll || fPairType==kSeMeAll) selected = kTRUE;
+    break;
   case AliDielectron::kEv1MEv2P:
     if(fPairType==kMeAll || fPairType==kSeMeAll || fPairType==kMeOnlyOS || fPairType==kSeMeOnlyOS)   selected = kTRUE;
     break;
index acd46a900b94d3e8e41f732e327b613b46287dc7..4c1d40e04efa8b203b4266194c9764cbf2f699b4 100644 (file)
@@ -118,7 +118,7 @@ void AliDielectronHFhelper::SetHFArray(const char* filename, const char* contain
        if( objname.Contains(Form("%s_HF",container)) && obj->IsA()==TObjArray::Class()) {
          fMainArr = new TObjArray( *(dynamic_cast<TObjArray*>(obj)) );
          fMainArr->SetOwner();
-         //fMainArr->Print();
+         //      fMainArr->Print();
          return;
        }
       }
@@ -240,6 +240,7 @@ TObjArray* AliDielectronHFhelper::CollectProfiles(TString option,
   if(varx < AliDielectronVarManager::kNMaxValues) dim++;
   if(vary < AliDielectronVarManager::kNMaxValues) dim++;
   if(varz < AliDielectronVarManager::kNMaxValues) dim++;
+  if(vart < AliDielectronVarManager::kNMaxValues) dim++;
   Bool_t bPairClass=0;
   if( varx < AliDielectronVarManager::kPairMax ||
       vary < AliDielectronVarManager::kPairMax ||
index 3443036272250c0028650ec09d5eec94e9df22b1..147195071be97e4fab5d5f581f57f356b3a7d4ed 100644 (file)
@@ -18,6 +18,14 @@ AliAnalysisTask *AddTaskJPSIFilter(Bool_t storeLS = kFALSE, Bool_t hasMC_aod = k
   //Do we run on AOD?
   Bool_t isAOD=mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
 
+  //Allow merging of the filtered aods on grid trains
+  if(mgr->GetGridHandler()) {
+    printf(" SET MERGE FILTERED AODs \n");
+    mgr->GetGridHandler()->SetMergeAOD(kTRUE);
+  }
+
+
+
   //gROOT->LoadMacro("$ALICE_ROOT/PWGDQ/dielectron/macros/ConfigBJpsi_ff_PbPbFilter.C");
   //  gROOT->LoadMacro("$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigBJpsi_ff_PbPbFilter.C");
   gROOT->LoadMacro("$ALICE_ROOT/PWGDQ/dielectron/macrosJPSI/ConfigJpsi_nano_PbPb.C");
@@ -90,6 +98,7 @@ AliAnalysisTask *AddTaskJPSIFilter(Bool_t storeLS = kFALSE, Bool_t hasMC_aod = k
   
   
   mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
   mgr->ConnectOutput(task, 1, cOutputHist1);
   mgr->ConnectOutput(task, 2, cOutputHist2);
   
diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Cent.C b/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Cent.C
new file mode 100644 (file)
index 0000000..34ed048
--- /dev/null
@@ -0,0 +1,155 @@
+AliAnalysisTask *AddTask_Remi_LMEEPbPb2011AOD_Cent(Char_t* outputFileName="LMEEoutput.root", Bool_t runAll=kFALSE,Bool_t setMC=kFALSE,Bool_t getFromAlien=kFALSE, Bool_t PIDbaseline=kFALSE, Bool_t rejOnly=kTRUE) {
+
+  Bool_t bESDANA=kFALSE; //Autodetect via InputHandler
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+       Error("AddTask_Remi_LMEEPbPb2011", "No analysis manager found.");
+       return 0;
+  }
+
+
+//  create task and add it to the manager
+//     gSystem->AddIncludePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE");
+
+
+  TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
+  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
+  //  if (trainRoot.IsNull()) configBasePath= "/home/tanizaki/nfs/LMee_Deflection/";
+  if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
+
+
+  if (getFromAlien &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C .")) &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C ."))
+     ) {
+        configBasePath=Form("%s/",gSystem->pwd());
+  }
+
+  TString configFile("ConfigRemiLMEEPbPb2011AOD.C");
+  TString configLMEECutLib("LMEECutLibRemi.C");
+
+  TString configFilePath(configBasePath+configFile);
+  TString configLMEECutLibPath(configBasePath+configLMEECutLib);
+
+  //AOD Usage currently tested with separate task, to be merged
+  if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
+  }
+  else if (mgr->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011AOD","switching on ESD specific code");
+       bESDANA=kTRUE;
+  }
+
+
+  //Do we have an MC handler?
+  Bool_t hasMC=setMC;
+  if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0)
+       hasMC=kTRUE;
+
+
+
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
+       gROOT->LoadMacro(configLMEECutLibPath.Data());
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
+       gROOT->LoadMacro(configFilePath.Data());
+
+
+  LMEECutLibRemi* cutlib = new LMEECutLibRemi();
+  AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData");
+  if (!hasMC) task->UsePhysicsSelection();
+  task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SelectCollisionCandidates(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SetRejectPileup();
+  task->SelectCollisionCandidates(AliVEvent::kAny);  
+  task->SetEventFilter(cutlib->GetEventCuts(LMEECutLibRemi::kPbPb2011TPCandTOF)); //
+
+  //load dielectron configuration file
+
+  //add dielectron analysis with different cuts to the task
+
+
+if (rejOnly) {
+
+      AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+      task->AddDielectron(lowmass1);
+      printf("add: %s\n",lowmass1->GetName());
+
+  
+  //  AliDielectron *lowmass2=ConfigRemiLMEEPbPb2011AOD(2,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass2);
+  //  printf("add: %s\n",lowmass2->GetName());
+
+  
+  //  AliDielectron *lowmass3=ConfigRemiLMEEPbPb2011AOD(3,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass3);
+  //  printf("add: %s\n",lowmass3->GetName());
+
+  
+  //  AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass4);
+  //  printf("add: %s\n",lowmass4->GetName());
+
+  
+  //  AliDielectron *lowmass5=ConfigRemiLMEEPbPb2011AOD(5,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass5);
+  //  printf("add: %s\n",lowmass5->GetName());
+
+  
+
+}
+else {
+  AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+  task->AddDielectron(lowmass4);
+  printf("add: %s\n",lowmass4->GetName());
+
+
+  AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+  task->AddDielectron(lowmass1);
+  printf("add: %s\n",lowmass1->GetName());
+
+
+if (PIDbaseline) {
+       AliDielectron *lowmass7=ConfigRemiLMEEPbPb2011AOD(7,hasMC,bESDANA);
+       task->AddDielectron(lowmass7);
+       printf("add: %s\n",lowmass7->GetName());
+
+}
+}
+
+  mgr->AddTask(task);
+
+  //create output container
+  AliAnalysisDataContainer *coutput1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_tree",
+               TTree::Class(),
+               AliAnalysisManager::kExchangeContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_out",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist2 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_CF",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist3 =
+       mgr->CreateContainer("Remi_EventStatPbPb2011",
+               TH1D::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+
+  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, coutput1 );
+  mgr->ConnectOutput(task, 1, cOutputHist1);
+  mgr->ConnectOutput(task, 2, cOutputHist2);
+  mgr->ConnectOutput(task, 3, cOutputHist3);
+
+  return task;
+}
diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Peri.C b/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_Peri.C
new file mode 100644 (file)
index 0000000..ac5d4a3
--- /dev/null
@@ -0,0 +1,155 @@
+AliAnalysisTask *AddTask_Remi_LMEEPbPb2011AOD_Peri(Char_t* outputFileName="LMEEoutput.root", Bool_t runAll=kFALSE,Bool_t setMC=kFALSE,Bool_t getFromAlien=kFALSE, Bool_t PIDbaseline=kFALSE, Bool_t rejOnly=kTRUE) {
+
+  Bool_t bESDANA=kFALSE; //Autodetect via InputHandler
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+       Error("AddTask_Remi_LMEEPbPb2011", "No analysis manager found.");
+       return 0;
+  }
+
+
+//  create task and add it to the manager
+//     gSystem->AddIncludePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE");
+
+
+  TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
+  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
+  //  if (trainRoot.IsNull()) configBasePath= "/home/tanizaki/nfs/LMee_Deflection/";
+  if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
+
+
+  if (getFromAlien &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C .")) &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C ."))
+      ) {
+    configBasePath=Form("%s/",gSystem->pwd());
+  }
+
+
+  TString configFile("ConfigRemiLMEEPbPb2011AOD.C");
+  TString configLMEECutLib("LMEECutLibRemi.C");
+
+  TString configFilePath(configBasePath+configFile);
+  TString configLMEECutLibPath(configBasePath+configLMEECutLib);
+
+  //AOD Usage currently tested with separate task, to be merged
+  if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
+  }
+  else if (mgr->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011AOD","switching on ESD specific code");
+       bESDANA=kTRUE;
+  }
+
+
+  //Do we have an MC handler?
+  Bool_t hasMC=setMC;
+  if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0)
+       hasMC=kTRUE;
+
+
+
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
+       gROOT->LoadMacro(configLMEECutLibPath.Data());
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
+       gROOT->LoadMacro(configFilePath.Data());
+
+
+  LMEECutLibRemi* cutlib = new LMEECutLibRemi();
+  AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData");
+  if (!hasMC) task->UsePhysicsSelection();
+  task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SelectCollisionCandidates(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SetRejectPileup();
+  task->SelectCollisionCandidates(AliVEvent::kAny);  
+  task->SetEventFilter(cutlib->GetEventCuts(LMEECutLibRemi::kPbPb2011TPCandTOF)); //
+
+  //load dielectron configuration file
+
+  //add dielectron analysis with different cuts to the task
+
+
+if (rejOnly) {
+
+  //    AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+  //    task->AddDielectron(lowmass1);
+  //    printf("add: %s\n",lowmass1->GetName());
+
+  
+  //  AliDielectron *lowmass2=ConfigRemiLMEEPbPb2011AOD(2,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass2);
+  //  printf("add: %s\n",lowmass2->GetName());
+
+  
+  //  AliDielectron *lowmass3=ConfigRemiLMEEPbPb2011AOD(3,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass3);
+  //  printf("add: %s\n",lowmass3->GetName());
+
+  
+    AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+    task->AddDielectron(lowmass4);
+    printf("add: %s\n",lowmass4->GetName());
+
+  
+  //  AliDielectron *lowmass5=ConfigRemiLMEEPbPb2011AOD(5,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass5);
+  //  printf("add: %s\n",lowmass5->GetName());
+
+
+}
+else {
+  AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+  task->AddDielectron(lowmass4);
+  printf("add: %s\n",lowmass4->GetName());
+
+
+  AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+  task->AddDielectron(lowmass1);
+  printf("add: %s\n",lowmass1->GetName());
+
+
+if (PIDbaseline) {
+       AliDielectron *lowmass7=ConfigRemiLMEEPbPb2011AOD(7,hasMC,bESDANA);
+       task->AddDielectron(lowmass7);
+       printf("add: %s\n",lowmass7->GetName());
+
+}
+}
+
+  mgr->AddTask(task);
+
+  //create output container
+  AliAnalysisDataContainer *coutput1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_tree",
+               TTree::Class(),
+               AliAnalysisManager::kExchangeContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_out",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist2 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_CF",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist3 =
+       mgr->CreateContainer("Remi_EventStatPbPb2011",
+               TH1D::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+
+  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, coutput1 );
+  mgr->ConnectOutput(task, 1, cOutputHist1);
+  mgr->ConnectOutput(task, 2, cOutputHist2);
+  mgr->ConnectOutput(task, 3, cOutputHist3);
+
+  return task;
+}
diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent1.C b/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent1.C
new file mode 100644 (file)
index 0000000..acbcc4b
--- /dev/null
@@ -0,0 +1,112 @@
+AliAnalysisTask *AddTask_Remi_LMEEPbPb2011AODSemiCent1(Char_t* outputFileName="LMEEoutput.root", Bool_t runAll=kFALSE,Bool_t setMC=kFALSE,Bool_t getFromAlien=kFALSE, Bool_t PIDbaseline=kFALSE, Bool_t rejOnly=kTRUE) {
+
+  Bool_t bESDANA=kFALSE; //Autodetect via InputHandler
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+       Error("AddTask_Remi_LMEEPbPb2011", "No analysis manager found.");
+       return 0;
+  }
+
+
+//  create task and add it to the manager
+//     gSystem->AddIncludePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE");
+
+
+  TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
+  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
+  //  if (trainRoot.IsNull()) configBasePath= "/home/tanizaki/nfs/LMee_Deflection/";
+  if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
+
+
+  if (getFromAlien &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C .")) &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C ."))
+      ) {
+    configBasePath=Form("%s/",gSystem->pwd());
+  }
+
+
+  TString configFile("ConfigRemiLMEEPbPb2011AOD.C");
+  TString configLMEECutLib("LMEECutLibRemi.C");
+
+  TString configFilePath(configBasePath+configFile);
+  TString configLMEECutLibPath(configBasePath+configLMEECutLib);
+
+  //AOD Usage currently tested with separate task, to be merged
+  if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
+  }
+  else if (mgr->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011AOD","switching on ESD specific code");
+       bESDANA=kTRUE;
+  }
+
+
+  //Do we have an MC handler?
+  Bool_t hasMC=setMC;
+  if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0)
+       hasMC=kTRUE;
+
+
+
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
+       gROOT->LoadMacro(configLMEECutLibPath.Data());
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
+       gROOT->LoadMacro(configFilePath.Data());
+
+
+  LMEECutLibRemi* cutlib = new LMEECutLibRemi();
+  AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData");
+  if (!hasMC) task->UsePhysicsSelection();
+  task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SelectCollisionCandidates(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SetRejectPileup();
+  task->SelectCollisionCandidates(AliVEvent::kAny);  
+  task->SetEventFilter(cutlib->GetEventCuts(LMEECutLibRemi::kPbPb2011TPCandTOF)); //
+
+  //load dielectron configuration file
+
+  //add dielectron analysis with different cuts to the task
+
+  AliDielectron *lowmass2=ConfigRemiLMEEPbPb2011AOD(2,hasMC,bESDANA);
+  task->AddDielectron(lowmass2);
+  printf("add: %s\n",lowmass2->GetName());
+
+
+  mgr->AddTask(task);
+
+  //create output container
+  AliAnalysisDataContainer *coutput1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_tree",
+               TTree::Class(),
+               AliAnalysisManager::kExchangeContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_out",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist2 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_CF",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist3 =
+       mgr->CreateContainer("Remi_EventStatPbPb2011",
+               TH1D::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+
+  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, coutput1 );
+  mgr->ConnectOutput(task, 1, cOutputHist1);
+  mgr->ConnectOutput(task, 2, cOutputHist2);
+  mgr->ConnectOutput(task, 3, cOutputHist3);
+
+  return task;
+}
diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent2.C b/PWGDQ/dielectron/macrosLMEE/AddTask_Remi_LMEEPbPb2011AOD_SemiCent2.C
new file mode 100644 (file)
index 0000000..1dde6f8
--- /dev/null
@@ -0,0 +1,155 @@
+AliAnalysisTask *AddTask_Remi_LMEEPbPb2011AOD_SemiCent2(Char_t* outputFileName="LMEEoutput.root", Bool_t runAll=kFALSE,Bool_t setMC=kFALSE,Bool_t getFromAlien=kFALSE, Bool_t PIDbaseline=kFALSE, Bool_t rejOnly=kTRUE) {
+
+  Bool_t bESDANA=kFALSE; //Autodetect via InputHandler
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+       Error("AddTask_Remi_LMEEPbPb2011", "No analysis manager found.");
+       return 0;
+  }
+
+
+//  create task and add it to the manager
+//     gSystem->AddIncludePath("$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE");
+
+
+  TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
+  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
+  //  if (trainRoot.IsNull()) configBasePath= "/home/tanizaki/nfs/LMee_Deflection/";
+  if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
+
+
+  if (getFromAlien &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C .")) &&
+      (!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/c/cbaumann/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C ."))
+      ) {
+    configBasePath=Form("%s/",gSystem->pwd());
+  }
+
+
+  TString configFile("ConfigRemiLMEEPbPb2011AOD.C");
+  TString configLMEECutLib("LMEECutLibRemi.C");
+
+  TString configFilePath(configBasePath+configFile);
+  TString configLMEECutLibPath(configBasePath+configLMEECutLib);
+
+  //AOD Usage currently tested with separate task, to be merged
+  if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
+  }
+  else if (mgr->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){
+       ::Info("AddTaskLMEEPbPb2011AOD","switching on ESD specific code");
+       bESDANA=kTRUE;
+  }
+
+
+  //Do we have an MC handler?
+  Bool_t hasMC=setMC;
+  if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0)
+       hasMC=kTRUE;
+
+
+
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
+       gROOT->LoadMacro(configLMEECutLibPath.Data());
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
+       gROOT->LoadMacro(configFilePath.Data());
+
+
+  LMEECutLibRemi* cutlib = new LMEECutLibRemi();
+  AliAnalysisTaskMultiDielectron *task=new AliAnalysisTaskMultiDielectron("MultiDiEData");
+  if (!hasMC) task->UsePhysicsSelection();
+  task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SelectCollisionCandidates(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+//  task->SetRejectPileup();
+  task->SelectCollisionCandidates(AliVEvent::kAny);  
+  task->SetEventFilter(cutlib->GetEventCuts(LMEECutLibRemi::kPbPb2011TPCandTOF)); //
+
+  //load dielectron configuration file
+
+  //add dielectron analysis with different cuts to the task
+
+
+if (rejOnly) {
+
+  //    AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+  //    task->AddDielectron(lowmass1);
+  //    printf("add: %s\n",lowmass1->GetName());
+
+  
+  //    AliDielectron *lowmass2=ConfigRemiLMEEPbPb2011AOD(2,hasMC,bESDANA);
+  //    task->AddDielectron(lowmass2);
+  //    printf("add: %s\n",lowmass2->GetName());
+
+  
+      AliDielectron *lowmass3=ConfigRemiLMEEPbPb2011AOD(3,hasMC,bESDANA);
+      task->AddDielectron(lowmass3);
+      printf("add: %s\n",lowmass3->GetName());
+
+  
+  //  AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass4);
+  //  printf("add: %s\n",lowmass4->GetName());
+
+  
+  //  AliDielectron *lowmass5=ConfigRemiLMEEPbPb2011AOD(5,hasMC,bESDANA);
+  //  task->AddDielectron(lowmass5);
+  //  printf("add: %s\n",lowmass5->GetName());
+
+
+}
+else {
+  AliDielectron *lowmass4=ConfigRemiLMEEPbPb2011AOD(4,hasMC,bESDANA);
+  task->AddDielectron(lowmass4);
+  printf("add: %s\n",lowmass4->GetName());
+
+
+  AliDielectron *lowmass1=ConfigRemiLMEEPbPb2011AOD(1,hasMC,bESDANA);
+  task->AddDielectron(lowmass1);
+  printf("add: %s\n",lowmass1->GetName());
+
+
+if (PIDbaseline) {
+       AliDielectron *lowmass7=ConfigRemiLMEEPbPb2011AOD(7,hasMC,bESDANA);
+       task->AddDielectron(lowmass7);
+       printf("add: %s\n",lowmass7->GetName());
+
+}
+}
+
+  mgr->AddTask(task);
+
+  //create output container
+  AliAnalysisDataContainer *coutput1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_tree",
+               TTree::Class(),
+               AliAnalysisManager::kExchangeContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist1 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_out",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist2 =
+       mgr->CreateContainer("Remi_LMEEPbPb2011_CF",
+               TList::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+  AliAnalysisDataContainer *cOutputHist3 =
+       mgr->CreateContainer("Remi_EventStatPbPb2011",
+               TH1D::Class(),
+               AliAnalysisManager::kOutputContainer,
+               outputFileName);
+
+
+  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, coutput1 );
+  mgr->ConnectOutput(task, 1, cOutputHist1);
+  mgr->ConnectOutput(task, 2, cOutputHist2);
+  mgr->ConnectOutput(task, 3, cOutputHist3);
+
+  return task;
+}
diff --git a/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C b/PWGDQ/dielectron/macrosLMEE/ConfigRemiLMEEPbPb2011AOD.C
new file mode 100644 (file)
index 0000000..212c632
--- /dev/null
@@ -0,0 +1,504 @@
+//#include "PWGDQ/dielectron/macrosLMEE/LMEECutLib.C"
+
+void InitHistograms(AliDielectron *die, Int_t cutDefinition);
+void InitCF(AliDielectron* die, Int_t cutDefinition);
+void EnableMC();
+
+TString names=("noPairing;TPCTOFCentnoRej;TPCTOFSemiCent1noRej;TPCTOFSemiCent2noRej;TPCTOFPerinoRej;TPCTOFAllCentnoRej;TPCTOFCentRej;TPCTOFSemiCent1Rej;TPCTOFSemiCent2Rej;TPCTOFPeriRej;TPCTOFAllCentRej;");
+TObjArray *arrNames=names.Tokenize(";");
+const Int_t nDie=arrNames->GetEntries();
+
+Bool_t MCenabled=kFALSE;
+
+
+AliDielectron* ConfigRemiLMEEPbPb2011AOD(Int_t cutDefinition, Bool_t hasMC=kFALSE, Bool_t ESDanalysis=kFALSE)
+{
+
+  Int_t selectedPID=-1;
+  Int_t selectedCentrality=-1;
+  Int_t selectedPairCut=-1;
+  Bool_t rejectionStep=kFALSE;
+  Bool_t PairCut=kFALSE;
+  LMEECutLibRemi*  LMCL = new LMEECutLibRemi();
+
+  //
+  // Setup the instance of AliDielectron
+  //
+
+  MCenabled=hasMC;
+
+  // create the actual framework object
+
+  TString name=Form("%02d",cutDefinition);
+  if ((cutDefinition)<arrNames->GetEntriesFast()){
+       name=arrNames->At((cutDefinition))->GetName();
+  }
+
+  //thisCut only relevant for MC:
+  AliDielectron *die =
+       new AliDielectron(Form
+               ("%s",name.Data()),
+               Form("Track cuts: %s",name.Data()));
+  //      die->SetZDCRecenteringFilename("/home/tanizaki/nfs/ZDCrpH1Recentering/ZDCRecenteringProfile.root");
+  //  die->SetZDCRecenteringFilename("alien:///alice/cern.ch/user/r/rtanizak/ZDCrpH1/ZDCRecentProf/ZDCRecenteringProfile.root")
+
+  //Setup AnalysisSelection:
+  if (cutDefinition==0) {
+       //not yet implemented
+  }
+  else if (cutDefinition==1) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011Central;
+    rejectionStep = kFALSE;
+    PairCut = kFALSE;
+
+  }
+  else if (cutDefinition==2) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011SemiCentral1;
+    rejectionStep = kFALSE;
+    PairCut = kFALSE;
+
+  }
+  else if (cutDefinition==3) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011SemiCentral2;
+    rejectionStep = kFALSE;
+    PairCut = kFALSE;
+
+  }
+  else if (cutDefinition==4) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011Peripheral;
+    rejectionStep = kFALSE;
+    PairCut = kFALSE;
+
+  }
+  else if (cutDefinition==5) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011AllCentral;
+    rejectionStep = kFALSE;
+    PairCut = kFALSE;
+
+  }
+
+  else if (cutDefinition==6) {
+       selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+       selectedCentrality = LMEECutLibRemi::kPbPb2011Central;
+       rejectionStep = kFALSE;
+        PairCut = kTRUE;
+
+  }
+  else if (cutDefinition==7) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011SemiCentral1;
+    rejectionStep = kFALSE;
+    PairCut = kTRUE;
+
+  }
+  else if (cutDefinition==8) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011SemiCentral2;
+    rejectionStep = kFALSE;
+    PairCut = kTRUE;
+
+  }
+  else if (cutDefinition==9) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011Peripheral;
+    rejectionStep = kFALSE;
+    PairCut = kTRUE;
+
+  }
+  else if (cutDefinition==10) {
+    selectedPID = LMEECutLibRemi::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLibRemi::kPbPb2011AllCentral;
+    rejectionStep = kFALSE;
+    PairCut = kTRUE;
+
+  }
+
+  else {
+       cout << " =============================== " << endl;
+       cout << " ==== INVALID CONFIGURATION ==== " << endl;
+       cout << " =============================== " << endl;
+  }
+
+
+  //Now configure task
+
+  //Apply correct Pre-Filter Scheme, if necessary
+  die->SetPreFilterAllSigns();
+
+  //switch off KF PArticle:
+  die->SetUseKF(kFALSE);
+
+  if (selectedPID == LMEECutLibRemi::kPbPb2011NoPID) {
+         die->SetNoPairing();
+   }
+
+  if (rejectionStep) {
+    if (ESDanalysis) {
+      die->GetTrackFilter().AddCuts( LMCL->GetESDTrackCutsAna(selectedPID) );
+      die->GetPairPreFilterLegs().AddCuts( LMCL->GetESDTrackCutsAna(selectedPID) );
+    }
+
+    //die->GetTrackFilter().AddCuts(LMCL->GetPIDCutsPre(selectedPID) );
+    die->GetTrackFilter().AddCuts(LMCL->GetPIDCutsAna(selectedPID) );
+    die->GetPairPreFilterLegs().AddCuts(LMCL->GetPIDCutsAna(selectedPID) );
+    die->GetPairPreFilter().AddCuts(LMCL->GetPairCuts(selectedPID) );
+
+    //    if(PairCut){
+    //      die->GetPairFilter().AddCuts( LMCL->GetPairCutsInvMass(selectedPairCut));
+    //    }
+  }
+  else { //No Prefilter, no Pairfilter
+    
+    if (ESDanalysis) {
+      die->GetTrackFilter().AddCuts( LMCL->GetESDTrackCutsAna(selectedPID) );
+    }
+    
+    die->GetTrackFilter().AddCuts( LMCL->GetTrackCutsAna(selectedPID) );
+    die->GetTrackFilter().AddCuts( LMCL->GetPIDCutsAna(selectedPID) );
+    die->GetEventFilter().AddCuts(LMCL->GetCentralityCuts(selectedCentrality));
+    
+    //    if(PairCut){
+    //      die->GetPairFilter().AddCuts( LMCL->GetPairCutsInvMass(selectedPairCut));
+    //    }
+    die->GetPairFilter().AddCuts(LMCL->GetPairCuts2(selectedPID,kFALSE));
+    
+  }
+  //Introduce NULL-check for pp?
+  die->GetEventFilter().AddCuts(LMCL->GetCentralityCuts(selectedCentrality));
+
+
+
+
+  AliDielectronTrackRotator *rot= 0x0;
+  /*AliDielectronTrackRotator *rot= LMCL->GetTrackRotator(selectedPID);
+  die->SetTrackRotator(rot);
+   */
+  AliDielectronMixingHandler *mix=LMCL->GetMixingHandler(selectedPID);
+  die->SetMixingHandler(mix);
+
+  // histogram setup
+  // only if an AliDielectronHistos object is attached to the
+  // dielectron framework histograms will be filled
+  //
+  InitHistograms(die,cutDefinition);
+
+  // the last definition uses no cuts and only the QA histograms should be filled!
+//  InitCF(die,cutDefinition);
+
+  return die;
+}
+
+//______________________________________________________________________________________
+
+void InitHistograms(AliDielectron *die, Int_t cutDefinition)
+{
+  //
+  // Initialise the histograms
+  //
+
+  //Setup histogram Manager
+  AliDielectronHistos *histos=
+       new AliDielectronHistos(die->GetName(),
+               die->GetTitle());
+  //Initialise histogram classes
+  histos->SetReservedWords("Track;Pair;Pre;RejTrack;RejPair");
+
+  //Event class
+//  if (cutDefinition==nDie-1) 
+               histos->AddClass("Event");
+
+  //Track classes
+  //to fill also track info from 2nd event loop until 2
+  for (Int_t i=0; i<2; ++i){
+       histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i)));
+  }
+
+  //Pair classes
+  // to fill also mixed event histograms loop until 10
+  for (Int_t i=0; i<3; ++i){
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
+  }
+
+  //ME and track rot
+  if (die->GetMixingHandler()) {
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3)));
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7)));
+  }
+  if (die->GetTrackRotator()) {
+       histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(10)));
+  }
+
+  //PreFilter Classes
+  //to fill also track info from 2nd event loop until 2
+  for (Int_t i=0; i<2; ++i){
+       histos->AddClass(Form("Pre_%s",AliDielectron::TrackClassName(i)));
+  }
+
+
+  //Create Classes for Rejected Tracks/Pairs:
+  for (Int_t i=0; i<2; ++i){
+       histos->AddClass(Form("RejTrack_%s",AliDielectron::TrackClassName(i)));
+  }
+  for (Int_t i=0; i<3; ++i){
+       histos->AddClass(Form("RejPair_%s",AliDielectron::PairClassName(i)));
+  }
+
+  /*
+  //track rotation
+
+  histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(AliDielectron::kEv1PMRot)));
+  histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(AliDielectron::kEv1PMRot)));
+  */
+       //add histograms to event class
+       histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",
+               1,0.,1.,AliDielectronVarManager::kNevents);
+       histos->UserHistogram("Event","Centrality","Centrality;Centrality [%]","0,10,20,40,80,100,101",
+               AliDielectronVarManager::kCentrality);
+       /*        histos->UserHistogram("Event","v0ACrpH2","VZERO-AC;v0ACrpH2",
+                             100,-2.0,2.0,
+                             AliDielectronVarManager::kv0ACrpH2);
+        histos->UserHistogram("Event","v0ArpH2","VZERO-A;v0ArpH2",
+                             100,-2.0,2.0,
+                             AliDielectronVarManager::kv0ArpH2);
+        histos->UserHistogram("Event","v0CrpH2","VZERO-C;v0CrpH2",
+                             100,-2.0,2.0,
+                             AliDielectronVarManager::kv0CrpH2);
+        histos->UserHistogram("Event","v0ArpH2_vs_v0CrpH2","VZERO-A vs VZERO-C;v0ArpH2;v0CrpH2",
+                              100,-2.0,2.0,100, -2.0, 2.0,
+                              AliDielectronVarManager::kv0ArpH2,AliDielectronVarManager::kv0CrpH2);
+       //      histos->UserHistgram("Event","resov0ACrpH2","VZERO-A;v0ArpH2",
+       //                           100, -2.0,2.0, AliDielectronVarManager::kresov0ACrpH2);
+       */
+
+       histos->UserHistogram("Event","ZDCArpH1","ZDC-ZN-A;ZDCrpH1",
+                              100,-3.5,3.5,
+                              AliDielectronVarManager::kZDCArpH1);
+       /*        histos->UserHistogram("Event","ZDCrpResH1","ZDC;ZDCrpResH1",
+                              100,-3.5,3.5,
+                              AliDielectronVarManager::kZDCrpResH1);
+       histos->UserHistogram("Event","v0ZDCrpRes","ZDC;v0ZDCrpRes",
+                              100,-3.5,3.5,
+                              AliDielectronVarManager::kv0ZDCrpRes);
+       */
+        histos->UserProfile("Event","ZDCrpResH1Prof","ZDC;ZDCrpResH1",
+                           AliDielectronVarManager::kZDCrpResH1, 
+                           10, 0, 100,
+                              AliDielectronVarManager::kCentrality);
+    
+        histos->UserProfile("Event","v0ZDCrpResProf","ZDC;v0ZDCrpRes",
+                            AliDielectronVarManager::kv0ZDCrpRes,
+                            10, 0, 100,
+                           AliDielectronVarManager::kCentrality);
+       
+       
+       histos->UserHistogram("Event","RefMult","RefMultiplicity;Multiplixity",
+                             100,-3.5,3.5,
+                             AliDielectronVarManager::kRefMult);
+       histos->UserHistogram("Event","kXvPrim","VertexX;vertex_x",
+                             100,0.03,0.1,
+                             AliDielectronVarManager::kXvPrim);
+       histos->UserHistogram("Event","kYvPrim","VartexY;vertex_y",
+                             100,0.2,0.3,
+                             AliDielectronVarManager::kYvPrim);
+       
+
+
+        histos->UserHistogram("Pair","InvMassAllPairplaneMagInPro","Inner Product of Mag and ee plane vs Inv.Mass;Inv. Mass [GeV];Phi [rad]",
+                             1000, 0.0,1.0,100,-2.0,2.0,AliDielectronVarManager::kM,AliDielectronVarManager::kPairPlaneMagInPro);
+       histos->UserHistogram("Pair","InvMassLowPairplaneMagInPro","ee plane Mag component vs Inv.Mass;Inv. Mass [GeV];Phi [rad]",
+                             300, 0.0,0.03,100,-2.0,2.0,AliDielectronVarManager::kM,AliDielectronVarManager::kPairPlaneMagInPro);
+       histos->UserHistogram("Pair","InvMassMiddlePairplaneMagInPro","ee plane Mag component vs Inv.Mass;Inv. Mass [GeV];Phi [rad]",
+                              180,0.12, 0.3,100,-2.0,2.0,AliDielectronVarManager::kM,AliDielectronVarManager::kPairPlaneMagInPro);
+       histos->UserHistogram("Pair","InvMassHighPairplaneMagInPro","ee plane Mag component vs Inv.Mass;Inv. Mass [GeV];Phi [rad]",
+                              200, 0.3, 0.5,100,-2.0,2.0,AliDielectronVarManager::kM,AliDielectronVarManager::kPairPlaneMagInPro);
+
+
+        histos->UserHistogram("Pair","PtAllPairplaneMagInPro","ee plane Mag component vs Pt;Pt [GeV];Phi [rad]",
+                              500,0.0,10.0,100,-2.0,2.0,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro);
+        histos->UserHistogram("Pair","PtLowPairplaneMagInPro","ee plane Mag component vs Pt;Pt [GeV];Phi [rad]",
+                             100,0.0,1.0,100,-2.0,2.0,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro);
+        histos->UserHistogram("Pair","PtMiddlePairplaneMagInPro","ee plane Mag component vs Pt;Pt [GeV];Phi [rad]",
+                             100,1.0,2.0,100,-2.0,2.0,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro);
+        histos->UserHistogram("Pair","PtHighPairplaneMagInPro","ee plane Mag component vs Pt;Pt [GeV];Phi [rad]",
+                             200,2.0,10.0,100,-2.0,2.0,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro);
+
+
+       /*      histos->UserHistogram("Pair","AllInvMassPtPairplaneMagInPro","ee plane Mag component",
+                             1000,0.0 ,0.5,500,0.0,10.0,100,-2.0,2.0,
+                             AliDielectronVarManager::kM,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro,
+                             kFALSE,kFALSE,kFALSE,999);
+       */
+
+       
+       //              histos->UserHistogram("Pair","AllInvMassPtPairplaneMagInPro","ee plane Mag component vs Pt;Inv.Mass[GeV];Pt [GeV];Phi [rad]",
+       //                                    1000,0.0,0.5,500,0.0,10.0,100,-2.0,2.0,
+       //                                    AliDielectronVarManager::kM,AliDielectronVarManager::kPt,AliDielectronVarManager::kPairPlaneMagInPro);
+       
+
+  //add histograms to Track classes
+       /*  histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPt);
+  histos->UserHistogram("Track","Px","Px;Px [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPx);
+  histos->UserHistogram("Track","Py","Py;Py [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPy);
+  histos->UserHistogram("Track","Pz","Pz;Pz [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPz);
+  histos->UserHistogram("Track","P","P;P [GeV];#tracks",200,0,20.,AliDielectronVarManager::kP);
+       */
+  /*
+  histos->UserHistogram("Track","NclsSFracTPC","NclsSFracTPC; NclsSFracTPC;#tracks",200,0,10.,AliDielectronVarManager::kNclsSFracTPC);
+  histos->UserHistogram("Track","TPCclsDiff","TPCclsDiff; TPCclsDiff;#tracks",200,0,10.,AliDielectronVarManager::kTPCclsDiff);
+
+  histos->UserHistogram("Track","ITS_dEdx_P","ITS_dEdx;P [GeV];ITS signal (arb units);#tracks",
+         400,0.0,20.,1000,0.,1000.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal,kTRUE);
+
+  histos->UserHistogram("Track","dEdx_P","dEdx;P [GeV];TPC signal (arb units);#tracks",
+         400,0.0,20.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
+
+  histos->UserHistogram("Track","TPCnSigmaEle_P","TPC number of sigmas Electrons;P [GeV];TPC number of sigmas Electrons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+  histos->UserHistogram("Track","TPCnSigmaKao_P","TPC number of sigmas Kaons;P [GeV];TPC number of sigmas Kaons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaKao,kTRUE);
+  histos->UserHistogram("Track","TPCnSigmaPio_P","TPC number of sigmas Pions;P [GeV];TPC number of sigmas Pions;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
+
+  histos->UserHistogram("Track","TRDpidPobEle_P","TRD PID probability Electrons;P [GeV];TRD prob Electrons;#tracks",
+         400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobEle,kTRUE);
+  histos->UserHistogram("Track","TRDpidPobPio_P","TRD PID probability Pions;P [GeV];TRD prob Pions;#tracks",
+         400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobPio,kTRUE);
+
+  histos->UserHistogram("Track","TOFnSigmaKao_P","TOF number of sigmas Kaons;P [GeV];TOF number of sigmas Kaons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaKao,kTRUE);
+  histos->UserHistogram("Track","TOFnSigmaPro_P","TOF number of sigmas Protons;P [GeV];TOF number of sigmas Protons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaPro,kTRUE);
+
+  histos->UserHistogram("Track","TOFbeta","TOF beta;P [GeV];TOF beta;#tracks",
+         400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFbeta,kTRUE);
+
+
+  histos->UserHistogram("Track","Eta","Eta; Eta;#tracks",
+         200,-2,2,AliDielectronVarManager::kEta);
+  histos->UserHistogram("Track","Phi","Phi; Phi;#tracks",
+         200,0.,3.15,AliDielectronVarManager::kPhi);
+
+  histos->UserHistogram("Track","Eta_Phi","Eta Phi Map; Eta; Phi;#tracks",
+         200,-2,2,200,0,3.15,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
+
+  histos->UserHistogram("Track","dXY_dZ","dXY dZ Map; dXY; dZ;#tracks",
+         200,-2,2,200,-2,2.,AliDielectronVarManager::kImpactParXY,AliDielectronVarManager::kImpactParZ);
+
+
+  histos->UserHistogram("Track","dXY","dXY;dXY [cm];#tracks",200,-2.,2.,AliDielectronVarManager::kImpactParXY);
+  histos->UserHistogram("Track","dZ","dZ;dZ [cm];#tracks",200,-2.,2.,AliDielectronVarManager::kImpactParZ);
+
+         histos->UserHistogram("Track","TPCcrossedRowsOverFindable","Number of Crossed Rows TPC over Findable;TPC crossed rows over findable;#tracks",100,0.,1.,AliDielectronVarManager::kNFclsTPCfCross);
+         histos->UserHistogram("Track","TPCcrossedRows","Number of Crossed Rows TPC;TPC crossed rows;#tracks",159,0.,159.,AliDielectronVarManager::kNFclsTPCr);
+         histos->UserHistogram("Track","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",159,0.,159.,AliDielectronVarManager::kNclsTPC);
+         histos->UserHistogram("Track","ITSnCls","Number of Clusters ITS;ITS number clusteres;#tracks",159,0.,159.,AliDielectronVarManager::kNclsITS);
+
+         histos->UserHistogram("Track","TPCchi2","TPC Chi2 value;TPC chi2;#tracks",100,0.,10.,AliDielectronVarManager::kTPCchi2Cl);
+         histos->UserHistogram("Track","ITSchi2","ITS Chi2 value;ITS chi2;#tracks",100,0.,10.,AliDielectronVarManager::kITSchi2Cl);
+
+         histos->UserHistogram("Track","TPCnCls_kNFclsTPCr","nTPC vs nTPCr;nTPC vs nTPCr;#tracks",159,0.,159.,159,0.,159.,AliDielectronVarManager::kNclsTPC,AliDielectronVarManager::kNFclsTPCr);
+
+         histos->UserHistogram("Track","kNFclsTPCr_pT","nTPCr vs pt;nTPCr vs pt;#tracks",159,0.,159.,200,0.,20.,AliDielectronVarManager::kNFclsTPCr,AliDielectronVarManager::kPt);
+
+  */
+         //add histograms to Pair classes
+         histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs",
+                 500,0.0,5.00,AliDielectronVarManager::kM);
+         histos->UserHistogram("Pair","Rapidity","Rapidity;Rapidity;#pairs",
+                 100,-2.,2.,AliDielectronVarManager::kY);
+         histos->UserHistogram("Pair","OpeningAngle","Opening angle;angle",
+                 100,0.,3.15,AliDielectronVarManager::kOpeningAngle);
+         //2D Histo Plot
+         histos->UserHistogram("Pair","InvMassPairPt","Inv.Mass vs PairPt;Inv. Mass [GeV], pT [GeV];#pairs",
+                 500,0.0,5.0,500,0.,50.,AliDielectronVarManager::kM,AliDielectronVarManager::kPt);
+
+         histos->UserHistogram("Pair","InvMassOpeningAngle","Opening Angle vs Inv.Mass;Inv. Mass [GeV];#pairs",
+                 500,0.0,5.0,200,0.,6.3,AliDielectronVarManager::kM,AliDielectronVarManager::kOpeningAngle);
+         /*
+         //add histograms to Track classes
+         histos->UserHistogram("Pre","Pt","Pt;Pt [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPt);
+
+         histos->UserHistogram("Pre","ITS_dEdx_P","ITS_dEdx;P [GeV];ITS signal (arb units);#tracks",
+                 400,0.0,20.,1000,0.,1000.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal,kTRUE);
+
+         histos->UserHistogram("Pre","dEdx_P","dEdx;P [GeV];TPC signal (arb units);#tracks",
+                 400,0.0,20.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
+
+
+         histos->UserHistogram("Pre","TPCnSigmaEle_P","TPC number of sigmas Electrons;P [GeV];TPC number of sigmas Electrons;#tracks",
+                 400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+         histos->UserHistogram("Pre","TPCnSigmaKao_P","TPC number of sigmas Kaons;P [GeV];TPC number of sigmas Kaons;#tracks",
+                 400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaKao,kTRUE);
+         histos->UserHistogram("Pre","TPCnSigmaPio_P","TPC number of sigmas Pions;P [GeV];TPC number of sigmas Pions;#tracks",
+                 400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
+
+         histos->UserHistogram("Pre","TRDpidPobEle_P","TRD PID probability Electrons;P [GeV];TRD prob Electrons;#tracks",
+                 400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobEle,kTRUE);
+         histos->UserHistogram("Pre","TRDpidPobPio_P","TRD PID probability Pions;P [GeV];TRD prob Pions;#tracks",
+                 400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobPio,kTRUE);
+
+         histos->UserHistogram("Pre","TOFnSigmaKao_P","TOF number of sigmas Kaons;P [GeV];TOF number of sigmas Kaons;#tracks",
+                 400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaKao,kTRUE);
+         histos->UserHistogram("Pre","TOFnSigmaPro_P","TOF number of sigmas Protons;P [GeV];TOF number of sigmas Protons;#tracks",
+                 400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaPro,kTRUE);
+
+         histos->UserHistogram("Pre","Eta_Phi","Eta Phi Map; Eta; Phi;#tracks",
+                 200,-2,2,200,0,3.15,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
+
+         histos->UserHistogram("Pre","dXY","dXY;dXY [cm];#tracks",200,-2.,2.,AliDielectronVarManager::kImpactParXY);
+
+  histos->UserHistogram("Pre","ZVertex ","ZVertex ;ZVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kZv);
+  histos->UserHistogram("Pre","XVertex ","XVertex ;XVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kXv);
+  histos->UserHistogram("Pre","YVertex ","YVertex ;YVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kYv);
+
+  histos->UserHistogram("Pre","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",159,0.,159.,AliDielectronVarManager::kNclsTPC);
+         */
+  //add histograms to Pair classes For Rejected Pairs:
+  die->SetHistogramManager(histos);
+}
+
+
+void InitCF(AliDielectron* die, Int_t cutDefinition)
+{
+  //
+  // Setupd the CF Manager if needed
+  //
+  AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
+
+  //pair variables
+  cf->AddVariable(AliDielectronVarManager::kP,200,0,20);
+  cf->AddVariable(AliDielectronVarManager::kM,201,-0.01,4.01); //20Mev Steps
+  cf->AddVariable(AliDielectronVarManager::kPairType,10,0,10);
+
+  cf->AddVariable(AliDielectronVarManager::kCentrality,"0.,10.0,30.0,40.0,60.,80.,100.");
+
+  //leg variables
+  cf->AddVariable(AliDielectronVarManager::kP,200,0.,20.,kTRUE);
+    cf->AddVariable(AliDielectronVarManager::kITSsignal,1000,0.0.,1000.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kTPCsignal,500,0.0.,500.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kHaveSameMother,21,-10,10,kTRUE);
+
+  //only in this case write MC truth info
+  if (MCenabled) {
+       cf->SetStepForMCtruth();
+       cf->SetStepsForMCtruthOnly();
+       cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE);
+       cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE);
+  }
+
+  cf->SetStepsForSignal();
+  die->SetCFManagerPair(cf);
+}
+
+//--------------------------------------
+void EnableMC() {
+  MCenabled=kTRUE;
+}
+
diff --git a/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C b/PWGDQ/dielectron/macrosLMEE/LMEECutLibRemi.C
new file mode 100644 (file)
index 0000000..97ce54a
--- /dev/null
@@ -0,0 +1,553 @@
+class LMEECutLibRemi {
+
+  public:
+       static  enum LMMECutSet {
+               kPbPb2011NoPID,
+               kPbPb2011TPCandTOF,
+               kPbPb2011TPCandTOFHPT,
+               kPbPb2011TPC, //TOF required, more relaxed cut on TPC
+               kPbPb2011TPCandTOFwide, //TOF required, more relaxed cut on TPC
+               kPbPb2011TPCorTOF,
+               kpp2010TPCandTOF,
+               kpp2010TPCorTOF,
+               kCUTSETMAX
+       };
+
+       static  enum LMMECentSel {
+               kPbPb2011Central,
+               kPbPb2011SemiCentral1,
+                kPbPb2011SemiCentral2,
+               kPbPb2011Peripheral,
+                kPbPb2011AllCentral,
+                kCENTSELMAX
+       };
+
+        static  enum LMEEPairCutSet{
+               kPbPb2011MassLow,
+               kPbPb2011MassMiddle,
+               kPbPb2011MassHigh,
+               kPbPb2011MassAll,
+               
+               kPAIRCUTSETMAX
+       };
+
+
+
+       //char* LMEECutNames[kCUTSETMAX] = { "PbPb2011TPCandTOF","PbPb2011TPCorTOF"};
+
+
+       LMEECutLib() {}
+
+       AliDielectronEventCuts*     GetEventCuts(Int_t cutSet);
+       AliAnalysisCuts*            GetCentralityCuts(Int_t centSel);
+       AliDielectronTrackRotator*  GetTrackRotator(Int_t cutSet);
+       AliDielectronMixingHandler* GetMixingHandler(Int_t cutSet);
+
+       AliAnalysisCuts* GetPIDCutsAna(Int_t cutSet);  
+       AliAnalysisCuts* GetPIDCutsPre(Int_t cutSet);  
+
+       AliAnalysisCuts* GetPairCuts2(Int_t cutSet,Bool_t tooglePC=kFALSE);
+       AliAnalysisCuts* GetPairCuts(Int_t cutSet);  
+        AliAnalysisCuts* GetPairCutsInvMass(Int_t cutSet);
+
+       AliAnalysisCuts* GetTrackCutsAna(Int_t cutSet);  
+       AliAnalysisCuts* GetTrackCutsPre(Int_t cutSet);  
+
+
+
+
+       AliDielectronEventCuts* GetEventCuts(Int_t cutSet) {
+         AliDielectronEventCuts* eventCuts = 0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                 eventCuts=new AliDielectronEventCuts("eventCuts","Vertex Track && |vtxZ|<10 && ncontrib>0");
+                 eventCuts->SetVertexType(AliDielectronEventCuts::kVtxSPD); // AOD
+                 //eventCuts->SetVertexType(AliDielectronEventCuts::kVtxTPC); // AOD
+                 //           eventCuts->SetCentralityRange(0.0,80.0);
+                 eventCuts->SetRequireVertex();
+                 eventCuts->SetMinVtxContributors(1);
+                 eventCuts->SetVertexZ(-10.,10.);
+                 break;
+               default: cout << "No Event Cut defined" << endl;
+         }
+         return eventCuts;
+       }
+
+       AliAnalysisCuts* GetCentralityCuts(Int_t centSel) {
+         AliDielectronVarCuts* centCuts = 0x0;
+         switch (centSel) {
+               case kPbPb2011Central:
+                 centCuts = new AliDielectronVarCuts("centCuts","CentralityPbPb2011Central");
+                 centCuts->AddCut(AliDielectronVarManager::kCentrality,0.,10.);
+                 break;
+               case kPbPb2011SemiCentral1:
+                 centCuts = new AliDielectronVarCuts("centCuts","CentralityPbPb2011SemiCentral1");
+                 //Restrict to 50%, Trigger selction
+                 centCuts->AddCut(AliDielectronVarManager::kCentrality,10.,30.);
+                 break;
+                case kPbPb2011SemiCentral2:
+                 centCuts = new AliDielectronVarCuts("centCuts","CentralityPbPb2011SemiCentral2");
+                 //Restrict to 50%, Trigger selction
+                 centCuts->AddCut(AliDielectronVarManager::kCentrality,30.,50.);//
+                 break;
+
+               case kPbPb2011Peripheral:
+                 centCuts = new AliDielectronVarCuts("centCuts","CentralityPbPb2011Peripheral");
+                 centCuts->AddCut(AliDielectronVarManager::kCentrality,50.,90.);
+                 break;
+                 
+               case kPbPb2011AllCentral:
+                 centCuts = new AliDielectronVarCuts("centCuts","CentralityPbPb2011AllCentral");
+                 centCuts->AddCut(AliDielectronVarManager::kCentrality,0.,100.);
+                 break;
+
+                       default: cout << "No Centrality selected" << endl;
+
+
+         }
+         return centCuts;
+       }
+
+
+       AliDielectronTrackRotator* GetTrackRotator(Int_t cutSet) {
+         AliDielectronTrackRotator* trackRotator = 0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                 trackRotator = new AliDielectronTrackRotator();
+                 trackRotator->SetIterations(20);
+                 trackRotator->SetConeAnglePhi(TMath::Pi()/180*165);
+                 trackRotator->SetStartAnglePhi(TMath::Pi());
+                 break;
+               default: cout << "No Rotator defined" << endl;
+         }
+         return trackRotator;
+       }
+
+
+       AliDielectronMixingHandler* GetMixingHandler(Int_t cutSet) {
+         AliDielectronMixingHandler* mixingHandler = 0x0;
+         switch (cutSet) {
+               case kPbPb2011TPCorTOF  :
+/*
+                 mixingHandler = new AliDielectronMixingHandler;
+                 mixingHandler->AddVariable(AliDielectronVarManager::kZvPrim,"-10,-5,0,5,10");
+                 mixingHandler->AddVariable(AliDielectronVarManager::kCentrality,"0,5,10,20,40,80");
+                 mixingHandler->SetDepth(25);
+                 mixingHandler->SetMixType(AliDielectronMixingHandler::kAll);
+                 break;
+*/
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+                 mixingHandler = new AliDielectronMixingHandler;
+                 mixingHandler->AddVariable(AliDielectronVarManager::kZvPrim,"-10,-5,0,5,10");
+                 mixingHandler->AddVariable(AliDielectronVarManager::kCentrality,"0,5,10,20,40,80");
+                  mixingHandler->AddVariable(AliDielectronVarManager::kv0ACrpH2,"-6*(TMath::Pi()/6),-5*(TMath::Pi()/6),-4*(TMath::Pi()/6),-3*(TMath::Pi()/6),-2*(TMath::Pi()/6),-1*(TMath::Pi()/6),0,1*(TMath::Pi()/6),2*(TMath::Pi()/6),3*(TMath::Pi()/6),4*(TMath::Pi()/6),5*(TMath::Pi()/6),6*(TMath::Pi()/6)");
+                 //mixingHandler->SetDepth(50);
+                 mixingHandler->SetDepth(15);
+                 mixingHandler->SetMixType(AliDielectronMixingHandler::kAll);
+                 break;
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                 mixingHandler = new AliDielectronMixingHandler;
+                 mixingHandler->AddVariable(AliDielectronVarManager::kZvPrim,"-10,-5,0,5,10");
+                 mixingHandler->AddVariable(AliDielectronVarManager::kNacc,"0,10000");
+                 //might want to add multiplicity?
+                 mixingHandler->SetDepth(50);
+                 mixingHandler->SetMixType(AliDielectronMixingHandler::kAll);
+                 break;
+               default: cout << "No Rotator defined" << endl;
+         }
+         return mixingHandler;
+       }
+
+
+       AliAnalysisCuts* GetPIDCutsAna(Int_t cutSet) {
+         AliAnalysisCuts* anaCuts=0x0;
+
+         // + [2] added for Dec2010 Cut! 
+         TF1 *lowerCut = new TF1("lowerCut", "[0] * TMath::Exp([1]*x) + [2]", 0, 20);
+         /* until Nov2010
+                lowerCut->SetParameter(0, -2.7);
+                lowerCut->SetParameter(1, -0.4357);
+          */
+         /* 18.01.2011 ALiHFEpid.cxx */
+         lowerCut->SetParameter(0,-3.7);
+         lowerCut->SetParameter(1,-0.8);
+         lowerCut->SetParameter(2,-0.35);
+
+         if (MCenabled) { //overwrite parameters
+               lowerCut->SetParameter(0,-2.5);
+               lowerCut->SetParameter(2,-2.2);
+         }
+
+         //---------------------------------------------
+         AliDielectronPID *pidTPCTOFeOnly = new AliDielectronPID("TPC-TOF","TPC-TOF");
+         pidTPCTOFeOnly->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3,3.,0.0,100.,kFALSE);
+         pidTPCTOFeOnly->AddCut(AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.0 , 100., kFALSE );
+
+
+          AliDielectronPID *pidTPCandTOF = new AliDielectronPID("TPC-TOF-HFE","TPC-TOF-HFE");
+          pidTPCandTOF->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3.,3.,0.0,100.,kFALSE);
+          pidTPCandTOF->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-3.,3.,0.,100.,kTRUE);
+          pidTPCandTOF->AddCut(AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.0 , 100., kFALSE );
+
+         AliDielectronPID *pidTPChardTOF = new AliDielectronPID("TPC-TOF-HFE","TPC-TOF-HFE");
+         pidTPChardTOF->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,lowerCut,3.,0.0,100.,kFALSE);
+         pidTPChardTOF->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-3,3.,0.,100.,kTRUE);
+         pidTPChardTOF->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-3.,3.,0.,100.,kTRUE);
+         pidTPChardTOF->AddCut(AliDielectronPID::kTPC,AliPID::kKaon,-3.,3.,0.,100.,kTRUE);
+         pidTPChardTOF->AddCut(AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.0 , 100., kFALSE );
+         //___________________________________________
+         AliDielectronPID *pidTT = new AliDielectronPID("TPC-TOF","TPC-TOF");
+         pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-1.5,3.,0.2,0.4,kFALSE);
+         pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3,3.,0.4,100.,kFALSE);
+         pidTT->AddCut(AliDielectronPID::kTOF ,AliPID::kElectron , -3. , 3. , 0.2 , 100., kFALSE );
+
+         pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-3,3.,0.,100.,kTRUE);
+         pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-3.,3.,0.,100.,kTRUE);
+         pidTT->AddCut(AliDielectronPID::kTPC,AliPID::kKaon,-3.,3.,0.,100.,kTRUE);
+         //___________________________________________
+         AliDielectronVarCuts *pidTPCsignal = new AliDielectronVarCuts("pidTPCsignal","cut on the TPC signal");
+         if (MCenabled) {
+         pidTPCsignal->AddCut(AliDielectronVarManager::kTPCsignal,65.,85.); 
+         }     
+         else {
+         pidTPCsignal->AddCut(AliDielectronVarManager::kTPCsignal,75.,90.); 
+         }
+         //___________________________________________
+
+         AliDielectronVarCuts *pidTPCsignalWide = new AliDielectronVarCuts("pidTPCsignalWide","cut on the TPC signal");
+         pidTPCsignalWide->AddCut(AliDielectronVarManager::kTPCsignal,75.,90.);
+
+
+         AliDielectronVarCuts *pTPCHPT = new AliDielectronVarCuts("P>.4hpt","P>.4hpt");
+         pTPCHPT->AddCut(AliDielectronVarManager::kPt,.4,3.0);
+
+         AliDielectronVarCuts *pTPC = new AliDielectronVarCuts("P>.4","P>.4");
+         pTPC->AddCut(AliDielectronVarManager::kPt,.4,2.0);
+         
+         AliDielectronVarCuts *pMin = new AliDielectronVarCuts("P>.2","P>.2");
+         pMin->AddCut(AliDielectronVarManager::kPt,.2,2.5);
+
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+                 AliDielectronCutGroup* cgSecondTrackFilterNoPID = new AliDielectronCutGroup("cgNoPID","cgNoPID",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterNoPID->AddCut(pTPC);
+                 anaCuts= cgSecondTrackFilterNoPID;
+                 break;
+               case kPbPb2011TPCandTOFHPT:
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC1 = new AliDielectronCutGroup("cgPIDTPC1","cgPIDTPC1",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pTPCHPT);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pidTPCTOFeOnly);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pidTPCsignal);
+                 anaCuts = cgSecondTrackFilterPIDTPC1;
+               case kPbPb2011TPCandTOF :
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC1 = new AliDielectronCutGroup("cgPIDTPC1","cgPIDTPC1",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pTPC);
+                 //cgSecondTrackFilterPIDTPC1->AddCut(pidTPChardTOF);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pidTPCTOFeOnly);
+                 cgSecondTrackFilterPIDTPC1->AddCut(pidTPCsignal);
+                 anaCuts = cgSecondTrackFilterPIDTPC1;
+                 break;
+               case kPbPb2011TPC :
+                  AliDielectronCutGroup* cgSecondTrackFilterPIDTPC1 = new AliDielectronCutGroup("cgPIDTPC1","cgPIDTPC1",AliDielectronCutGroup::kCompAND);
+                  cgSecondTrackFilterPIDTPC1->AddCut(pTPC);
+                  cgSecondTrackFilterPIDTPC1->AddCut(pidTPCsignalWide);
+                  anaCuts = cgSecondTrackFilterPIDTPC1;
+                  break;
+
+               case kPbPb2011TPCandTOFwide :
+                  AliDielectronCutGroup* cgSecondTrackFilterPIDTPC1 = new AliDielectronCutGroup("cgPIDTPC1","cgPIDTPC1",AliDielectronCutGroup::kCompAND);
+                  cgSecondTrackFilterPIDTPC1->AddCut(pTPC);
+                  cgSecondTrackFilterPIDTPC1->AddCut(pidTPCandTOF);
+                  cgSecondTrackFilterPIDTPC1->AddCut(pidTPCsignalWide);
+                  anaCuts = cgSecondTrackFilterPIDTPC1;
+                  break;
+
+               case kPbPb2011TPCorTOF  :
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC2 = new AliDielectronCutGroup("cgPIDTPC2","cgPIDTPC2",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterPIDTPC2->AddCut(pMin);
+                 cgSecondTrackFilterPIDTPC2->AddCut(pidTT);
+                 cgSecondTrackFilterPIDTPC2->AddCut(pidTPCsignal);
+                 anaCuts = cgSecondTrackFilterPIDTPC2;
+                 break;
+               case kpp2010TPCandTOF :
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC = new AliDielectronCutGroup("cgPIDTPC","cgPIDTPC",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterPIDTPC->AddCut(pTPC);
+                 //cgSecondTrackFilterPIDTPC->AddCut(pidTPChardTOF);
+                 cgSecondTrackFilterPIDTPC->AddCut(pidTPCTOFeOnly);
+                 anaCuts = cgSecondTrackFilterPIDTPC;
+                 break;
+               case kpp2010TPCorTOF  :
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC = new AliDielectronCutGroup("cgPIDTPC","cgPIDTPC",AliDielectronCutGroup::kCompAND);
+                 cgSecondTrackFilterPIDTPC->AddCut(pMin);
+                 cgSecondTrackFilterPIDTPC->AddCut(pidTT);
+                 anaCuts = cgSecondTrackFilterPIDTPC;
+                 break;
+               default: cout << "No Analysis PID Cut defined " << endl;
+         }
+         return anaCuts;
+       }
+
+       AliAnalysisCuts* GetPIDCutsPre(Int_t cutSet) {
+         AliAnalysisCuts* anaCuts=0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                 AliDielectronCutGroup* cgSecondTrackFilterPIDTPC = new AliDielectronCutGroup("cgPIDTPC","cgPIDTPC",AliDielectronCutGroup::kCompAND);
+                 AliDielectronCutGroup* cgITSTPC = new AliDielectronCutGroup("cgITSTPC","cgITSTPC",AliDielectronCutGroup::kCompAND);
+                 AliDielectronPID *pidITSTPC = new AliDielectronPID("TPCpre","TPCpre");
+                 pidITSTPC->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3.,3.);
+                 cgITSTPC->AddCut(pidITSTPC);
+
+
+                 AliDielectronCutGroup* cgITSSA = new AliDielectronCutGroup("cgITSSA","cgITSSA",AliDielectronCutGroup::kCompAND);
+                 AliDielectronPID *pidITSSA = new  AliDielectronPID("pidITSSA","pidITSSA");
+                 pidITSSA->AddCut(AliDielectronPID::kITS,AliPID::kElectron,-3.,3.);
+                 cgITSSA->AddCut(pidITSSA);
+                 //      cgITSSA->AddCut(GetTrackCutsPre(cutSet));
+
+                 AliDielectronCutGroup* cgInitialTrackFilter = new AliDielectronCutGroup("cgInitialTrackFilter","cgInitialTrackFilter",AliDielectronCutGroup::kCompOR);
+                 cgInitialTrackFilter->AddCut(cgITSTPC);
+                 cgInitialTrackFilter->AddCut(cgITSSA);
+                 anaCuts = cgInitialTrackFilter;
+                 break;
+               default: cout << "No Pre-PID Cut defined " << endl;
+         }
+         return anaCuts;
+       }
+
+
+
+        AliAnalysisCuts* GetPairCuts2(Int_t cutSet, Bool_t togglePC /*=kFALSE*/)  {
+          AliAnalysisCuts* pairCuts=0x0;
+          switch (cutSet) {
+                case kPbPb2011TPCorTOF  :
+                case kpp2010TPCandTOF :
+                  AliDielectronVarCuts* pairCutsV= new AliDielectronVarCuts("InvMass","InvMass > 150 MeV");
+                  pairCutsV->AddCut(AliDielectronVarManager::kM,0.15,100.,kTRUE);
+                  pairCuts = pairCutsV;
+                  break;
+               case kPbPb2011NoPID:
+                case kPbPb2011TPCandTOF :
+                case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFHPT:
+                case kPbPb2011TPCandTOFwide :
+                case kpp2010TPCorTOF  :
+                  if (!togglePC) {
+
+                  AliDielectronCutGroup* pairCutsCG2 =new AliDielectronCutGroup("pairCutsCG2","pairCutsCG2",AliDielectronCutGroup::kCompOR);
+                  AliDielectronCutGroup* pairCutsCG =new AliDielectronCutGroup("pairCutsCG","pairCutsCG",AliDielectronCutGroup::kCompAND);
+                  pairCutsPhiv =new AliDielectronVarCuts("Phiv Cuts","Phiv<2.0rad");
+                  pairCutsPhiv->AddCut(AliDielectronVarManager::kPhivPair, 0.0, 2.0); 
+                  pairCutsInvM =new AliDielectronVarCuts("InvM Cuts","InvM<0.3");
+                  pairCutsInvM->AddCut(AliDielectronVarManager::kM, 0.0, 0.3); 
+                  pairCutsInvMgood =new AliDielectronVarCuts("InvM Cuts good","InvM>0.3");
+                  pairCutsInvMgood->AddCut(AliDielectronVarManager::kM, 0.3, 99999.); 
+                  pairCutsCG->AddCut(pairCutsPhiv);
+                  pairCutsCG->AddCut(pairCutsInvM);
+                  pairCutsCG2->AddCut(pairCutsInvMgood);
+                  pairCutsCG2->AddCut(pairCutsCG);
+                  pairCuts = pairCutsCG2;
+                  }
+                  else {
+                        AliDielectronVarCuts* pairCutsV =new AliDielectronVarCuts("OpeningAngle","Opening angle > .035rad");
+                        pairCutsV->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.035,kTRUE);
+                        pairCuts = pairCutsV;
+                  }
+                  break;
+                default: cout << "No Pair Cuts defined " << endl;
+          }
+          return pairCuts;
+        }
+
+
+       AliAnalysisCuts* GetPairCuts(Int_t cutSet)  {  
+         AliAnalysisCuts* pairCuts=0x0;
+         switch (cutSet) {
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+                       AliDielectronVarCuts* pairCutsM=0x0;
+                 pairCutsM = new AliDielectronVarCuts("InvMass","InvMass > 150 MeV");
+                 pairCutsM->AddCut(AliDielectronVarManager::kM,0.15,100.,kTRUE);
+                 pairCuts = pairCutsM;
+                 break;
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCandTOFHPT:
+               case kpp2010TPCorTOF  :
+
+                 AliDielectronCutGroup* pairCutsCG =new AliDielectronCutGroup("pairCutsCG","pairCutsCG",AliDielectronCutGroup::kCompAND);
+                 AliDielectronVarCuts* pairCutsPhiv =new AliDielectronVarCuts("Phiv Cuts","Phiv<2.0rad");
+                 pairCutsPhiv->AddCut(AliDielectronVarManager::kPhivPair, 2.0, 3.2); 
+                 AliDielectronVarCuts* pairCutsInvM =new AliDielectronVarCuts("InvM Cuts","InvM<0.3");
+                 pairCutsInvM->AddCut(AliDielectronVarManager::kM, 0.0, 0.3); 
+                 pairCutsCG->AddCut(pairCutsPhiv);
+                 pairCutsCG->AddCut(pairCutsInvM);
+
+                 pairCuts = pairCutsCG;
+
+
+               //pairCuts =new AliDielectronVarCuts("OpeningAngle","Opening angle > .035rad");
+               //pairCuts->AddCut(AliDielectronVarManager::kOpeningAngle, 0. , 0.035);
+               break;
+               default: cout << "No Pair Cuts defined " << endl;
+         } 
+         return pairCuts;
+       }
+
+       AliAnalysisCuts* GetESDTrackCutsAna(Int_t cutSet) {
+         AliESDtrackCuts* esdTrackCutsH = 0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                       // standard cuts with very loose DCA: Bit4 (Int: 16), AOD095&115
+                 
+                        esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE); 
+                        esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
+                        esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
+                        esdTrackCutsH->SetDCAToVertex2D(kTRUE);
+               /* 
+
+                 esdTrackCutsH = new AliESDtrackCuts();
+                 esdTrackCutsH->SetAcceptKinkDaughters(kFALSE);
+                 //Not done so far via dielectron cuts:
+                 */
+                 /*
+                 esdTrackCuts->SetDCAToVertex2D(kFALSE);
+                 esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+                 esdTrackCuts->SetMaxChi2PerClusterITS(36);
+                  */
+
+                 break;
+               default: cout << "No Analysis Track Cut defined " << endl;
+         }
+         return esdTrackCutsH;
+       } 
+
+  AliAnalysisCuts* GetPairCutsInvMass(Int_t cutSet) {
+    AliDielectronVarCuts* pairCuts=0x0;
+    switch (cutSet) {
+    case kPbPb2011MassLow :
+      pairCuts = new AliDielectronVarCuts("InvMass","0 MeV  < InvMass < 30 MeV");
+      pairCuts->AddCut(AliDielectronVarManager::kM, 0.,0.03);
+      break;
+    case kPbPb2011MassMiddle :
+      pairCuts = new AliDielectronVarCuts("InvMass","120 MeV  < InvMass < 300 MeV");
+      pairCuts->AddCut(AliDielectronVarManager::kM, 0.12,0.30);
+      break;
+    case kPbPb2011MassHigh :
+      pairCuts = new AliDielectronVarCuts("InvMass","300 MeV  < InvMass < 500 MeV");
+      pairCuts->AddCut(AliDielectronVarManager::kM, 0.30,0.50);
+      break;
+    case kPbPb2011MassAll :
+      pairCuts = new AliDielectronVarCuts("InvMass","0 GeV  < InvMass < 10 GeV");
+      pairCuts->AddCut(AliDielectronVarManager::kM, 0.0,10.0);
+      break;
+
+    default: cout << "No Pair Cuts defined " << endl;
+    }
+    return pairCuts;
+  }
+
+
+       AliAnalysisCuts* GetTrackCutsAna(Int_t cutSet) {
+         AliDielectronCutGroup* trackCuts=0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPC :
+               case kPbPb2011TPCandTOFwide :
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+                       trackCuts = new AliDielectronCutGroup("cgPIDTPC1","cgPIDTPC1",AliDielectronCutGroup::kCompAND);
+
+                       AliDielectronVarCuts* trackCutsAOD =new AliDielectronVarCuts("trackCutsAOD","trackCutsAOD");
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kPt,0.05,6.);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kEta,-0.84,0.84);
+                       //DCA Cut
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kImpactParXY, -1.0,   1.0);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kImpactParZ,  -3.0,   3.0);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kNclsITS,     3.0, 100.0);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kTPCchi2Cl,    0.0,   3.5);
+                       AliDielectronTrackCuts *trackCutsDiel = new AliDielectronTrackCuts("trackCutsDiel","trackCutsDiel");
+                       trackCutsDiel->SetAODFilterBit(16); //does nothing for ESDs
+                       trackCutsDiel->SetRequireITSRefit(kTRUE);
+                       trackCutsDiel->SetRequireTPCRefit(kTRUE);
+
+                       trackCutsDiel->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
+//                     trackCutsAOD->AddCut(AliDielectronVarManager::kNclsTPC,     80., 140.0);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kNFclsTPCr,     110.0, 160.0);
+                       trackCutsAOD->AddCut(AliDielectronVarManager::kNFclsTPCfCross,     0.8, 1.0);//tighter than before,
+                                                                                                                                                                                //due to AOD production
+                       trackCuts->AddCut(trackCutsDiel);
+                       trackCuts->AddCut(trackCutsAOD);
+                 break;
+               default: cout << "No Analysis Track Cut defined " << endl;
+         }
+         return trackCuts;
+       } 
+
+       AliAnalysisCuts* GetTrackCutsPre(Int_t cutSet) {
+         AliESDtrackCuts* trackCuts=0x0;
+         switch (cutSet) {
+               case kPbPb2011NoPID:
+               case kPbPb2011TPCandTOF :
+               case kPbPb2011TPCandTOFHPT:
+               case kPbPb2011TPCorTOF  :
+               case kpp2010TPCandTOF :
+               case kpp2010TPCorTOF  :
+/*
+                       trackCuts = new AliESDtrackCuts();
+                       trackCuts->SetDCAToVertex2D(kTRUE);
+                       trackCuts->SetMaxDCAToVertexZ(3.0);
+                       trackCuts->SetMaxDCAToVertexXY(1.0);
+                 trackCuts->SetEtaRange( -0.84 , 0.84 );
+                 trackCuts->SetPtRange(  0.05 , 0.5);
+                 trackCuts->SetAcceptKinkDaughters(kFALSE);
+                 trackCuts->SetRequireITSRefit(kTRUE);
+                 trackCuts->SetRequireITSStandAlone(kTRUE);
+                 trackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
+                 trackCuts->SetMinNClustersITS(3); //PhotonGroup-Dalitz: 2?!
+*/
+                 cout << "No Pre-Track Cut defined for AODs at the moment " << endl;
+                 break;
+               default: cout << "No Pre-Track Cut defined " << endl;
+         }
+         return trackCuts;
+       }
+
+};
index 07b12c5b23a028012cd238f211ec03829fd97433..8a7234514ea1bbc0f5f7de2740544eb550cdd856 100644 (file)
@@ -27,7 +27,7 @@
 #--------------------------------------------------------------------------------#
 
 set ( SRCS  
-        GammaConv/AliConversionPhotonBase.cxx
+       GammaConv/AliConversionPhotonBase.cxx
        GammaConv/AliAODConversionParticle.cxx
        GammaConv/AliAODConversionMother.cxx
        GammaConv/AliAODConversionPhoton.cxx
@@ -35,27 +35,27 @@ set ( SRCS
        GammaConv/AliKFConversionMother.cxx
        GammaConv/AliConversionCuts.cxx
        GammaConv/AliConversionSelection.cxx
-        GammaConv/AliConversionMesonCuts.cxx
-        GammaConv/AliDalitzElectronCuts.cxx
-        GammaConv/AliDalitzElectronSelector.cxx
+       GammaConv/AliConversionMesonCuts.cxx
+       GammaConv/AliDalitzElectronCuts.cxx
+       GammaConv/AliDalitzElectronSelector.cxx
        GammaConv/AliV0ReaderV1.cxx
        GammaConv/AliConversionAODBGHandlerRP.cxx
        GammaConv/AliConversionTrackCuts.cxx
-        GammaConv/AliGammaConversionAODBGHandler.cxx
-        GammaConv/AliAnalysisTaskConversionQA.cxx
-        GammaConv/AliAnalysisTaskMaterial.cxx
-        GammaConv/AliAnalysisTaskResolution.cxx
+       GammaConv/AliGammaConversionAODBGHandler.cxx
+       GammaConv/AliAnalysisTaskConversionQA.cxx
+       GammaConv/AliAnalysisTaskMaterial.cxx
+       GammaConv/AliAnalysisTaskResolution.cxx
        GammaConv/AliAnalysisTaskPi0v2.cxx
-        GammaConv/AliAnalysisTaskGammaConvV1.cxx
-        GammaConv/AliAnalysisTaskGammaConvDalitzV1.cxx
-        GammaConv/AliAnaConvIsolation.cxx
+       GammaConv/AliAnalysisTaskGammaConvV1.cxx
+       GammaConv/AliAnalysisTaskGammaConvDalitzV1.cxx
+       GammaConv/AliAnaConvIsolation.cxx
        GammaConv/AliAnaConvCorrBase.cxx
        GammaConv/AliAnaConvCorrPion.cxx
        GammaConv/AliAnaConvCorrPhoton.cxx
        GammaConv/AliAnalysisTaskdPhi.cxx
        GammaConv/AliAnalysisTaskCaloConv.cxx
        GammaConv/AliAnalysisTaskGCPartToPWG4Part.cxx
-       )
+)
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
index 7850b824430af90dc8ad1299769fb684a87fe10b..d8e6d3c79c9495921a27ec5176fbd0cec7d481d1 100644 (file)
@@ -712,7 +712,7 @@ void AliAnalysisTaskCaloFilter::FillAODTracks()
   
   Double_t pos[3]   = { 0. };      
   Double_t covTr[21]= { 0. };
-  Double_t pid[10]  = { 0. };  
+  //Double_t pid[10]  = { 0. };  
   Double_t p[3]     = { 0. };
     
   // Copy from AODs
@@ -739,7 +739,7 @@ void AliAnalysisTaskCaloFilter::FillAODTracks()
       track->GetPxPyPz(p);
       Bool_t isDCA  = track->GetPosition(pos);
       track->GetCovMatrix(covTr);
-      track->GetPID(pid);
+      //track->GetPID(pid);
       
       AliAODVertex* primVertex = (AliAODVertex*) AODEvent()->GetVertices()->At(0); // primary vertex, copied previously!!!
 
@@ -753,7 +753,7 @@ void AliAnalysisTaskCaloFilter::FillAODTracks()
                                                             covTr, 
                                                             track->Charge(),
                                                             track->GetITSClusterMap(), 
-                                                            pid,
+                                                            // pid,
                                                             primVertex,
                                                             track->GetUsedForVtxFit(),
                                                             track->GetUsedForPrimVtxFit(),
@@ -762,6 +762,7 @@ void AliAnalysisTaskCaloFilter::FillAODTracks()
                                                             track->Chi2perNDF());
       
       
+      aodTrack->SetPIDForTracking(track->GetPIDForTracking());
       aodTrack->SetIsHybridGlobalConstrainedGlobal(track->IsHybridGlobalConstrainedGlobal());   
       aodTrack->SetIsHybridTPCConstrainedGlobal   (track->IsHybridTPCConstrainedGlobal());    
       aodTrack->SetIsGlobalConstrained            (track->IsGlobalConstrained());  
index 029abea9d64f393b341a831911b1df35a7fcbeac..b6f819fbecce89d6af05894e8726ab4796dd513e 100755 (executable)
@@ -741,6 +741,9 @@ void  AliAnaPhoton::FillEMCALTriggerClusterBCHistograms(Int_t idcalo,       Floa
   Int_t  id     = GetReader()->GetTriggerClusterId();
   Bool_t badMax = GetReader()->IsBadMaxCellTriggerEvent();
   
+  Int_t histoBC = bc+5;
+  if(GetReader()->AreBadTriggerEventsRemoved()) histoBC=0; // histograms created only for one BC since the others where rejected
+
   if(id==-2)
   {
     //printf("AliAnaPhoton::ClusterSelected() - No trigger found bc=%d\n",bc);
@@ -753,13 +756,13 @@ void  AliAnaPhoton::FillEMCALTriggerClusterBCHistograms(Int_t idcalo,       Floa
     {
       if(GetReader()->IsTriggerMatched())
       {
-        if(ecluster > 2) fhEtaPhiTriggerEMCALBC[bc+5]->Fill(etacluster, phicluster);
-        fhTimeTriggerEMCALBC[bc+5]->Fill(ecluster, tofcluster);
-        if(GetReader()->IsPileUpFromSPD()) fhTimeTriggerEMCALBCPileUpSPD[bc+5]->Fill(ecluster, tofcluster);
+        if(ecluster > 2) fhEtaPhiTriggerEMCALBC[histoBC]->Fill(etacluster, phicluster);
+        fhTimeTriggerEMCALBC[histoBC]->Fill(ecluster, tofcluster);
+        if(GetReader()->IsPileUpFromSPD()) fhTimeTriggerEMCALBCPileUpSPD[histoBC]->Fill(ecluster, tofcluster);
         
         if(idcalo ==  GetReader()->GetTriggerClusterId())
         {
-          fhEtaPhiTriggerEMCALBCCluster[bc+5]->Fill(etacluster, phicluster);
+          fhEtaPhiTriggerEMCALBCCluster[histoBC]->Fill(etacluster, phicluster);
           fhTimeTriggerEMCALBCCluster        ->Fill(ecluster, tofcluster);
           
           if(bc==0)
@@ -776,8 +779,8 @@ void  AliAnaPhoton::FillEMCALTriggerClusterBCHistograms(Int_t idcalo,       Floa
       }
       else
       {
-        if(ecluster > 2) fhEtaPhiTriggerEMCALBCUM[bc+5]->Fill(etacluster, phicluster);
-        fhTimeTriggerEMCALBCUM[bc+5]->Fill(ecluster, tofcluster);
+        if(ecluster > 2) fhEtaPhiTriggerEMCALBCUM[histoBC]->Fill(etacluster, phicluster);
+        fhTimeTriggerEMCALBCUM[histoBC]->Fill(ecluster, tofcluster);
         
         if(bc==0)
         {
@@ -788,7 +791,7 @@ void  AliAnaPhoton::FillEMCALTriggerClusterBCHistograms(Int_t idcalo,       Floa
         
         if(idcalo ==  GetReader()->GetTriggerClusterId())
         {
-          fhEtaPhiTriggerEMCALBCUMCluster[bc+5]->Fill(etacluster, phicluster);
+          fhEtaPhiTriggerEMCALBCUMCluster[histoBC]->Fill(etacluster, phicluster);
           fhTimeTriggerEMCALBCUMCluster->Fill(ecluster, tofcluster);
           if(bc==0)
           {
@@ -1771,6 +1774,14 @@ TList *  AliAnaPhoton::GetCreateOutputObjects()
   
   Int_t bin[] = {0,2,4,6,10,15,20,100}; // energy bins for SS studies
   
+  Int_t nTrigBC  = 1;
+  Int_t iBCShift = 0;
+  if(!GetReader()->AreBadTriggerEventsRemoved())
+  {
+    nTrigBC = 11;
+    iBCShift = 5;
+  }
+  
   TString cut[] = {"Open","Reader","E","Time","NCells","NLM","Fidutial","Matching","Bad","PID"};
   for (Int_t i = 0; i < 10 ;  i++)
   {
@@ -1849,59 +1860,59 @@ TList *  AliAnaPhoton::GetCreateOutputObjects()
     fhEtaPhiEMCALBCN->SetXTitle("#eta");
     outputContainer->Add(fhEtaPhiEMCALBCN) ;
     
-    for(Int_t i = 0; i < 11; i++)
+    for(Int_t i = 0; i < nTrigBC; i++)
     {
       fhEtaPhiTriggerEMCALBC[i] = new TH2F
-      (Form("hEtaPhiTriggerEMCALBC%d",i-5),
-       Form("cluster E > 2 GeV, #eta vs #phi, Trigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiTriggerEMCALBC%d",i-iBCShift),
+       Form("cluster E > 2 GeV, #eta vs #phi, Trigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiTriggerEMCALBC[i]->SetYTitle("#phi (rad)");
       fhEtaPhiTriggerEMCALBC[i]->SetXTitle("#eta");
       outputContainer->Add(fhEtaPhiTriggerEMCALBC[i]) ;
       
       fhTimeTriggerEMCALBC[i] = new TH2F
-      (Form("hTimeTriggerEMCALBC%d",i-5),
-       Form("cluster time vs E of clusters, Trigger EMCAL-BC=%d",i-5),
+      (Form("hTimeTriggerEMCALBC%d",i-iBCShift),
+       Form("cluster time vs E of clusters, Trigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimeTriggerEMCALBC[i]->SetXTitle("E (GeV)");
       fhTimeTriggerEMCALBC[i]->SetYTitle("time (ns)");
       outputContainer->Add(fhTimeTriggerEMCALBC[i]);
       
       fhTimeTriggerEMCALBCPileUpSPD[i] = new TH2F
-      (Form("hTimeTriggerEMCALBC%dPileUpSPD",i-5),
-       Form("cluster time vs E of clusters, Trigger EMCAL-BC=%d",i-5),
+      (Form("hTimeTriggerEMCALBC%dPileUpSPD",i-iBCShift),
+       Form("cluster time vs E of clusters, Trigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimeTriggerEMCALBCPileUpSPD[i]->SetXTitle("E (GeV)");
       fhTimeTriggerEMCALBCPileUpSPD[i]->SetYTitle("time (ns)");
       outputContainer->Add(fhTimeTriggerEMCALBCPileUpSPD[i]);
       
       fhEtaPhiTriggerEMCALBCUM[i] = new TH2F
-      (Form("hEtaPhiTriggerEMCALBC%d_UnMatch",i-5),
-       Form("cluster E > 2 GeV, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiTriggerEMCALBC%d_UnMatch",i-iBCShift),
+       Form("cluster E > 2 GeV, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiTriggerEMCALBCUM[i]->SetYTitle("#phi (rad)");
       fhEtaPhiTriggerEMCALBCUM[i]->SetXTitle("#eta");
       outputContainer->Add(fhEtaPhiTriggerEMCALBCUM[i]) ;
       
       fhTimeTriggerEMCALBCUM[i] = new TH2F
-      (Form("hTimeTriggerEMCALBC%d_UnMatch",i-5),
-       Form("cluster time vs E of clusters, unmatched trigger EMCAL-BC=%d",i-5),
+      (Form("hTimeTriggerEMCALBC%d_UnMatch",i-iBCShift),
+       Form("cluster time vs E of clusters, unmatched trigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimeTriggerEMCALBCUM[i]->SetXTitle("E (GeV)");
       fhTimeTriggerEMCALBCUM[i]->SetYTitle("time (ns)");
       outputContainer->Add(fhTimeTriggerEMCALBCUM[i]);
       
       fhEtaPhiTriggerEMCALBCCluster[i] = new TH2F
-      (Form("hEtaPhiTriggerEMCALBC%d_OnlyTrigger",i-5),
-       Form("trigger cluster, #eta vs #phi, Trigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiTriggerEMCALBC%d_OnlyTrigger",i-iBCShift),
+       Form("trigger cluster, #eta vs #phi, Trigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiTriggerEMCALBCCluster[i]->SetYTitle("#phi (rad)");
       fhEtaPhiTriggerEMCALBCCluster[i]->SetXTitle("#eta");
       outputContainer->Add(fhEtaPhiTriggerEMCALBCCluster[i]) ;
             
       fhEtaPhiTriggerEMCALBCUMCluster[i] = new TH2F
-      (Form("hEtaPhiTriggerEMCALBC%d_OnlyTrigger_UnMatch",i-5),
-       Form("trigger cluster, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiTriggerEMCALBC%d_OnlyTrigger_UnMatch",i-iBCShift),
+       Form("trigger cluster, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiTriggerEMCALBCUMCluster[i]->SetYTitle("#phi (rad)");
       fhEtaPhiTriggerEMCALBCUMCluster[i]->SetXTitle("#eta");
@@ -1970,247 +1981,249 @@ TList *  AliAnaPhoton::GetCreateOutputObjects()
     fhEtaPhiTriggerEMCALBCUMClusterBelowTh2->SetXTitle("#eta");
     outputContainer->Add(fhEtaPhiTriggerEMCALBCUMClusterBelowTh2) ;
     
-    fhEtaPhiTriggerEMCALBCExotic = new TH2F
-    ("hEtaPhiTriggerExotic",
-     "cluster E > 2 GeV, #eta vs #phi, Trigger Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCExotic->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCExotic->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCExotic) ;
-    
-    fhTimeTriggerEMCALBCExotic = new TH2F
-    ("hTimeTriggerExotic",
-     "cluster time vs E of clusters, Trigger Exotic ",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCExotic);
-    
-    fhEtaPhiTriggerEMCALBCUMExotic = new TH2F
-    ("hEtaPhiTriggerExotic_UnMatch",
-     "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMExotic->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMExotic->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMExotic) ;
-    
-    fhTimeTriggerEMCALBCUMExotic = new TH2F
-    ("hTimeTriggerExotic_UnMatch",
-     "cluster time vs E of clusters, unmatched trigger Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMExotic);
-    
-    fhEtaPhiTriggerEMCALBCExoticCluster = new TH2F
-    ("hEtaPhiTriggerExotic_OnlyTrigger",
-     "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCExoticCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCExoticCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCExoticCluster) ;
-    
-    fhTimeTriggerEMCALBCExoticCluster = new TH2F
-    ("hTimeTriggerExotic_OnlyTrigger",
-     "trigger cluster time vs E of clusters, Trigger Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCExoticCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCExoticCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCExoticCluster);
-    
-    fhEtaPhiTriggerEMCALBCUMExoticCluster = new TH2F
-    ("hEtaPhiTriggerExotic_OnlyTrigger_UnMatch",
-     "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMExoticCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMExoticCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMExoticCluster) ;
-    
-    fhTimeTriggerEMCALBCUMExoticCluster = new TH2F
-    ("hTimeTriggerExotic_OnlyTrigger_UnMatch",
-     "trigger cluster time vs E of clusters, unmatched trigger Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMExoticCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMExoticCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMExoticCluster);
-    
-    fhEtaPhiTriggerEMCALBCBad = new TH2F
-    ("hEtaPhiTriggerBad",
-     "cluster E > 2 GeV, #eta vs #phi, Trigger Bad",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCBad->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCBad->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCBad) ;
-    
-    fhTimeTriggerEMCALBCBad = new TH2F
-    ("hTimeTriggerBad",
-     "cluster time vs E of clusters, Trigger Bad ",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBad->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBad->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBad);
-    
-    fhEtaPhiTriggerEMCALBCUMBad = new TH2F
-    ("hEtaPhiTriggerBad_UnMatch",
-     "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMBad->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMBad->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBad) ;
-    
-    fhTimeTriggerEMCALBCUMBad = new TH2F
-    ("hTimeTriggerBad_UnMatch",
-     "cluster time vs E of clusters, unmatched trigger Bad",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBad->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBad->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBad);
-    
-    fhEtaPhiTriggerEMCALBCBadCluster = new TH2F
-    ("hEtaPhiTriggerBad_OnlyTrigger",
-     "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Bad",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCBadCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCBadCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCBadCluster) ;
-    
-    fhTimeTriggerEMCALBCBadCluster = new TH2F
-    ("hTimeTriggerBad_OnlyTrigger",
-     "trigger cluster time vs E of clusters, Trigger Bad",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBadCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBadCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBadCluster);
-    
-    fhEtaPhiTriggerEMCALBCUMBadCluster = new TH2F
-    ("hEtaPhiTriggerBad_OnlyTrigger_UnMatch",
-     "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMBadCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMBadCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadCluster) ;
-    
-    fhTimeTriggerEMCALBCUMBadCluster = new TH2F
-    ("hTimeTriggerBad_OnlyTrigger_UnMatch",
-     "trigger cluster time vs E of clusters, unmatched trigger Bad",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBadCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBadCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBadCluster);
-    
-    fhEtaPhiTriggerEMCALBCBadExotic = new TH2F
-    ("hEtaPhiTriggerBadExotic",
-     "cluster E > 2 GeV, #eta vs #phi, Trigger Bad&Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCBadExotic->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCBadExotic->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCBadExotic) ;
-    
-    fhTimeTriggerEMCALBCBadExotic = new TH2F
-    ("hTimeTriggerBadExotic",
-     "cluster time vs E of clusters, Trigger Bad&Exotic ",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBadExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBadExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBadExotic);
-    
-    fhEtaPhiTriggerEMCALBCUMBadExotic = new TH2F
-    ("hEtaPhiTriggerBadExotic_UnMatch",
-     "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad&Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMBadExotic->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMBadExotic->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadExotic) ;
-    
-    fhTimeTriggerEMCALBCUMBadExotic = new TH2F
-    ("hTimeTriggerBadExotic_UnMatch",
-     "cluster time vs E of clusters, unmatched trigger Bad&Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBadExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBadExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBadExotic);
-    
-    fhEtaPhiTriggerEMCALBCBadExoticCluster = new TH2F
-    ("hEtaPhiTriggerBadExotic_OnlyTrigger",
-     "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Bad&Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCBadExoticCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCBadExoticCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCBadExoticCluster) ;
-    
-    fhTimeTriggerEMCALBCBadExoticCluster = new TH2F
-    ("hTimeTriggerBadExotic_OnlyTrigger",
-     "trigger cluster time vs E of clusters, Trigger Bad&Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBadExoticCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBadExoticCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBadExoticCluster);
-    
-    fhEtaPhiTriggerEMCALBCUMBadExoticCluster = new TH2F
-    ("hEtaPhiTriggerBadExotic_OnlyTrigger_UnMatch",
-     "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad&Exotic",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiTriggerEMCALBCUMBadExoticCluster->SetYTitle("#phi (rad)");
-    fhEtaPhiTriggerEMCALBCUMBadExoticCluster->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadExoticCluster) ;
-    
-    fhTimeTriggerEMCALBCUMBadExoticCluster = new TH2F
-    ("hTimeTriggerBadExotic_OnlyTrigger_UnMatch",
-     "trigger cluster time vs E of clusters, unmatched trigger Bad&Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBadExoticCluster->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBadExoticCluster->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBadExoticCluster);
-    
-    fhTimeTriggerEMCALBCBadMaxCell = new TH2F
-    ("hTimeTriggerBadMaxCell",
-     "cluster time vs E of clusters, Trigger BadMaxCell",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBadMaxCell->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBadMaxCell->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBadMaxCell);
-    
-    fhTimeTriggerEMCALBCUMBadMaxCell = new TH2F
-    ("hTimeTriggerBadMaxCell_UnMatch",
-     "cluster time vs E of clusters, unmatched trigger BadMaxCell",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBadMaxCell->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBadMaxCell->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBadMaxCell);
-    
-    
-    fhTimeTriggerEMCALBCBadMaxCellExotic = new TH2F
-    ("hTimeTriggerBadMaxCellExotic",
-     "cluster time vs E of clusters, Trigger BadMaxCell&Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCBadMaxCellExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCBadMaxCellExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCBadMaxCellExotic);
-    
-    fhTimeTriggerEMCALBCUMBadMaxCellExotic = new TH2F
-    ("hTimeTriggerBadMaxCellExotic_UnMatch",
-     "cluster time vs E of clusters, unmatched trigger BadMaxCell&Exotic",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeTriggerEMCALBCUMBadMaxCellExotic->SetXTitle("E (GeV)");
-    fhTimeTriggerEMCALBCUMBadMaxCellExotic->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeTriggerEMCALBCUMBadMaxCellExotic);
-    
-    fhTimeNoTrigger = new TH2F
-    ("hTimeNoTrigger",
-     "events with no foundable trigger, time vs e of clusters",
-     nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
-    fhTimeNoTrigger->SetXTitle("E (GeV)");
-    fhTimeNoTrigger->SetYTitle("time (ns)");
-    outputContainer->Add(fhTimeNoTrigger);
-    
-    fhEtaPhiNoTrigger = new TH2F
-    ("hEtaPhiNoTrigger",
-     "events with no foundable trigger, eta vs phi of clusters",
-     netabins,etamin,etamax,nphibins,phimin,phimax);
-    fhEtaPhiNoTrigger->SetYTitle("#phi (rad)");
-    fhEtaPhiNoTrigger->SetXTitle("#eta");
-    outputContainer->Add(fhEtaPhiNoTrigger) ;
-    
+    if(!GetReader()->AreBadTriggerEventsRemoved())
+    {
+      fhEtaPhiTriggerEMCALBCExotic = new TH2F
+      ("hEtaPhiTriggerExotic",
+       "cluster E > 2 GeV, #eta vs #phi, Trigger Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCExotic->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCExotic->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCExotic) ;
+      
+      fhTimeTriggerEMCALBCExotic = new TH2F
+      ("hTimeTriggerExotic",
+       "cluster time vs E of clusters, Trigger Exotic ",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCExotic);
+      
+      fhEtaPhiTriggerEMCALBCUMExotic = new TH2F
+      ("hEtaPhiTriggerExotic_UnMatch",
+       "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMExotic->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMExotic->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMExotic) ;
+      
+      fhTimeTriggerEMCALBCUMExotic = new TH2F
+      ("hTimeTriggerExotic_UnMatch",
+       "cluster time vs E of clusters, unmatched trigger Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMExotic);
+      
+      fhEtaPhiTriggerEMCALBCExoticCluster = new TH2F
+      ("hEtaPhiTriggerExotic_OnlyTrigger",
+       "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCExoticCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCExoticCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCExoticCluster) ;
+      
+      fhTimeTriggerEMCALBCExoticCluster = new TH2F
+      ("hTimeTriggerExotic_OnlyTrigger",
+       "trigger cluster time vs E of clusters, Trigger Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCExoticCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCExoticCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCExoticCluster);
+      
+      fhEtaPhiTriggerEMCALBCUMExoticCluster = new TH2F
+      ("hEtaPhiTriggerExotic_OnlyTrigger_UnMatch",
+       "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMExoticCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMExoticCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMExoticCluster) ;
+      
+      fhTimeTriggerEMCALBCUMExoticCluster = new TH2F
+      ("hTimeTriggerExotic_OnlyTrigger_UnMatch",
+       "trigger cluster time vs E of clusters, unmatched trigger Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMExoticCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMExoticCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMExoticCluster);
+      
+      fhEtaPhiTriggerEMCALBCBad = new TH2F
+      ("hEtaPhiTriggerBad",
+       "cluster E > 2 GeV, #eta vs #phi, Trigger Bad",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCBad->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCBad->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCBad) ;
+      
+      fhTimeTriggerEMCALBCBad = new TH2F
+      ("hTimeTriggerBad",
+       "cluster time vs E of clusters, Trigger Bad ",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBad->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBad->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBad);
+      
+      fhEtaPhiTriggerEMCALBCUMBad = new TH2F
+      ("hEtaPhiTriggerBad_UnMatch",
+       "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMBad->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMBad->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBad) ;
+      
+      fhTimeTriggerEMCALBCUMBad = new TH2F
+      ("hTimeTriggerBad_UnMatch",
+       "cluster time vs E of clusters, unmatched trigger Bad",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBad->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBad->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBad);
+      
+      fhEtaPhiTriggerEMCALBCBadCluster = new TH2F
+      ("hEtaPhiTriggerBad_OnlyTrigger",
+       "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Bad",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCBadCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCBadCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCBadCluster) ;
+      
+      fhTimeTriggerEMCALBCBadCluster = new TH2F
+      ("hTimeTriggerBad_OnlyTrigger",
+       "trigger cluster time vs E of clusters, Trigger Bad",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBadCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBadCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBadCluster);
+      
+      fhEtaPhiTriggerEMCALBCUMBadCluster = new TH2F
+      ("hEtaPhiTriggerBad_OnlyTrigger_UnMatch",
+       "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMBadCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMBadCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadCluster) ;
+      
+      fhTimeTriggerEMCALBCUMBadCluster = new TH2F
+      ("hTimeTriggerBad_OnlyTrigger_UnMatch",
+       "trigger cluster time vs E of clusters, unmatched trigger Bad",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBadCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBadCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBadCluster);
+      
+      fhEtaPhiTriggerEMCALBCBadExotic = new TH2F
+      ("hEtaPhiTriggerBadExotic",
+       "cluster E > 2 GeV, #eta vs #phi, Trigger Bad&Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCBadExotic->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCBadExotic->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCBadExotic) ;
+      
+      fhTimeTriggerEMCALBCBadExotic = new TH2F
+      ("hTimeTriggerBadExotic",
+       "cluster time vs E of clusters, Trigger Bad&Exotic ",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBadExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBadExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBadExotic);
+      
+      fhEtaPhiTriggerEMCALBCUMBadExotic = new TH2F
+      ("hEtaPhiTriggerBadExotic_UnMatch",
+       "cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad&Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMBadExotic->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMBadExotic->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadExotic) ;
+      
+      fhTimeTriggerEMCALBCUMBadExotic = new TH2F
+      ("hTimeTriggerBadExotic_UnMatch",
+       "cluster time vs E of clusters, unmatched trigger Bad&Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBadExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBadExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBadExotic);
+      
+      fhEtaPhiTriggerEMCALBCBadExoticCluster = new TH2F
+      ("hEtaPhiTriggerBadExotic_OnlyTrigger",
+       "trigger cluster E > 2 GeV, #eta vs #phi, Trigger Bad&Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCBadExoticCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCBadExoticCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCBadExoticCluster) ;
+      
+      fhTimeTriggerEMCALBCBadExoticCluster = new TH2F
+      ("hTimeTriggerBadExotic_OnlyTrigger",
+       "trigger cluster time vs E of clusters, Trigger Bad&Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBadExoticCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBadExoticCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBadExoticCluster);
+      
+      fhEtaPhiTriggerEMCALBCUMBadExoticCluster = new TH2F
+      ("hEtaPhiTriggerBadExotic_OnlyTrigger_UnMatch",
+       "trigger cluster E > 2 GeV, #eta vs #phi, unmatched trigger Bad&Exotic",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiTriggerEMCALBCUMBadExoticCluster->SetYTitle("#phi (rad)");
+      fhEtaPhiTriggerEMCALBCUMBadExoticCluster->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiTriggerEMCALBCUMBadExoticCluster) ;
+      
+      fhTimeTriggerEMCALBCUMBadExoticCluster = new TH2F
+      ("hTimeTriggerBadExotic_OnlyTrigger_UnMatch",
+       "trigger cluster time vs E of clusters, unmatched trigger Bad&Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBadExoticCluster->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBadExoticCluster->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBadExoticCluster);
+      
+      fhTimeTriggerEMCALBCBadMaxCell = new TH2F
+      ("hTimeTriggerBadMaxCell",
+       "cluster time vs E of clusters, Trigger BadMaxCell",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBadMaxCell->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBadMaxCell->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBadMaxCell);
+      
+      fhTimeTriggerEMCALBCUMBadMaxCell = new TH2F
+      ("hTimeTriggerBadMaxCell_UnMatch",
+       "cluster time vs E of clusters, unmatched trigger BadMaxCell",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBadMaxCell->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBadMaxCell->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBadMaxCell);
+      
+      
+      fhTimeTriggerEMCALBCBadMaxCellExotic = new TH2F
+      ("hTimeTriggerBadMaxCellExotic",
+       "cluster time vs E of clusters, Trigger BadMaxCell&Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCBadMaxCellExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCBadMaxCellExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCBadMaxCellExotic);
+      
+      fhTimeTriggerEMCALBCUMBadMaxCellExotic = new TH2F
+      ("hTimeTriggerBadMaxCellExotic_UnMatch",
+       "cluster time vs E of clusters, unmatched trigger BadMaxCell&Exotic",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeTriggerEMCALBCUMBadMaxCellExotic->SetXTitle("E (GeV)");
+      fhTimeTriggerEMCALBCUMBadMaxCellExotic->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeTriggerEMCALBCUMBadMaxCellExotic);
+      
+      fhTimeNoTrigger = new TH2F
+      ("hTimeNoTrigger",
+       "events with no foundable trigger, time vs e of clusters",
+       nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
+      fhTimeNoTrigger->SetXTitle("E (GeV)");
+      fhTimeNoTrigger->SetYTitle("time (ns)");
+      outputContainer->Add(fhTimeNoTrigger);
+      
+      fhEtaPhiNoTrigger = new TH2F
+      ("hEtaPhiNoTrigger",
+       "events with no foundable trigger, eta vs phi of clusters",
+       netabins,etamin,etamax,nphibins,phimin,phimax);
+      fhEtaPhiNoTrigger->SetYTitle("#phi (rad)");
+      fhEtaPhiNoTrigger->SetXTitle("#eta");
+      outputContainer->Add(fhEtaPhiNoTrigger) ;
+    }
     
     fhEtaPhiTriggerEMCALBCUMReMatchOpenTimeCluster = new TH2F("hEtaPhiTriggerEMCALBC0_OnlyTrigger_UnMatch_ReMatch_OpenTime",
                                                        "cluster E > 2 GeV, #eta vs #phi, Trigger EMCAL-BC=0, un match, rematch open time",
@@ -2325,43 +2338,43 @@ TList *  AliAnaPhoton::GetCreateOutputObjects()
     fhEtaPhiPhotonEMCALBCN->SetXTitle("#eta");
     outputContainer->Add(fhEtaPhiPhotonEMCALBCN) ;
     
-    for(Int_t i = 0; i < 11; i++)
+    for(Int_t i = 0; i < nTrigBC; i++)
     {
       fhEtaPhiPhotonTriggerEMCALBC[i] = new TH2F
-      (Form("hEtaPhiPhotonTriggerEMCALBC%d",i-5),
-       Form("photon E > 2 GeV, #eta vs #phi, PhotonTrigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiPhotonTriggerEMCALBC%d",i-iBCShift),
+       Form("photon E > 2 GeV, #eta vs #phi, PhotonTrigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiPhotonTriggerEMCALBC[i]->SetYTitle("#phi (rad)");
       fhEtaPhiPhotonTriggerEMCALBC[i]->SetXTitle("#eta");
       outputContainer->Add(fhEtaPhiPhotonTriggerEMCALBC[i]) ;
       
       fhTimePhotonTriggerEMCALBC[i] = new TH2F
-      (Form("hTimePhotonTriggerEMCALBC%d",i-5),
-       Form("photon time vs E of clusters, PhotonTrigger EMCAL-BC=%d",i-5),
+      (Form("hTimePhotonTriggerEMCALBC%d",i-iBCShift),
+       Form("photon time vs E of clusters, PhotonTrigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimePhotonTriggerEMCALBC[i]->SetXTitle("E (GeV)");
       fhTimePhotonTriggerEMCALBC[i]->SetYTitle("time (ns)");
       outputContainer->Add(fhTimePhotonTriggerEMCALBC[i]);
       
       fhTimePhotonTriggerEMCALBCPileUpSPD[i] = new TH2F
-      (Form("hTimePhotonTriggerEMCALBC%dPileUpSPD",i-5),
-       Form("photon time vs E, PhotonTrigger EMCAL-BC=%d",i-5),
+      (Form("hTimePhotonTriggerEMCALBC%dPileUpSPD",i-iBCShift),
+       Form("photon time vs E, PhotonTrigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimePhotonTriggerEMCALBCPileUpSPD[i]->SetXTitle("E (GeV)");
       fhTimePhotonTriggerEMCALBCPileUpSPD[i]->SetYTitle("time (ns)");
       outputContainer->Add(fhTimePhotonTriggerEMCALBCPileUpSPD[i]);
       
       fhEtaPhiPhotonTriggerEMCALBCUM[i] = new TH2F
-      (Form("hEtaPhiPhotonTriggerEMCALBC%d_UnMatch",i-5),
-       Form("photon E > 2 GeV, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-5),
+      (Form("hEtaPhiPhotonTriggerEMCALBC%d_UnMatch",i-iBCShift),
+       Form("photon E > 2 GeV, #eta vs #phi, unmatched trigger EMCAL-BC=%d",i-iBCShift),
        netabins,etamin,etamax,nphibins,phimin,phimax);
       fhEtaPhiPhotonTriggerEMCALBCUM[i]->SetYTitle("#phi (rad)");
       fhEtaPhiPhotonTriggerEMCALBCUM[i]->SetXTitle("#eta");
       outputContainer->Add(fhEtaPhiPhotonTriggerEMCALBCUM[i]) ;
       
       fhTimePhotonTriggerEMCALBCUM[i] = new TH2F
-      (Form("hTimePhotonTriggerEMCALBC%d_UnMatch",i-5),
-       Form("photon time vs E, unmatched trigger EMCAL-BC=%d",i-5),
+      (Form("hTimePhotonTriggerEMCALBC%d_UnMatch",i-iBCShift),
+       Form("photon time vs E, unmatched trigger EMCAL-BC=%d",i-iBCShift),
        nptbins,ptmin,ptmax, ntimebins,timemin,timemax);
       fhTimePhotonTriggerEMCALBCUM[i]->SetXTitle("E (GeV)");
       fhTimePhotonTriggerEMCALBCUM[i]->SetYTitle("time (ns)");
@@ -3571,7 +3584,7 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
   Bool_t bad    = GetReader()->IsBadCellTriggerEvent();
   
   if( fFillEMCALBCHistograms && fCalorimeter=="EMCAL" &&
-     ( bad || exotic )  && idTrig >= 0)
+     ( bad || exotic )  && idTrig >= 0 && !GetReader()->AreBadTriggerEventsRemoved())
   {
     //    printf("Index %d, Id %d,  bad %d, exo %d\n",
     //           GetReader()->GetTriggerClusterIndex(),
@@ -3795,18 +3808,20 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
       }
       
       Int_t bc = GetReader()->GetTriggerClusterBC();
+      Int_t histoBC = bc-5;
+      if(GetReader()->AreBadTriggerEventsRemoved()) histoBC=0; // histograms created only for one BC since the others where rejected
       if(TMath::Abs(bc) < 6 && !GetReader()->IsBadCellTriggerEvent() && !GetReader()->IsExoticEvent())
       {
         if(GetReader()->IsTriggerMatched())
         {
-          if(calo->E() > 2) fhEtaPhiPhotonTriggerEMCALBC[bc+5]->Fill(aodph.Eta(), phicluster);
-          fhTimePhotonTriggerEMCALBC[bc+5]->Fill(calo->E(), calotof);
-          if(GetReader()->IsPileUpFromSPD()) fhTimePhotonTriggerEMCALBCPileUpSPD[bc+5]->Fill(calo->E(), calotof);
+          if(calo->E() > 2) fhEtaPhiPhotonTriggerEMCALBC[histoBC]->Fill(aodph.Eta(), phicluster);
+          fhTimePhotonTriggerEMCALBC[histoBC]->Fill(calo->E(), calotof);
+          if(GetReader()->IsPileUpFromSPD()) fhTimePhotonTriggerEMCALBCPileUpSPD[histoBC]->Fill(calo->E(), calotof);
         }
         else
         {
-          if(calo->E() > 2) fhEtaPhiPhotonTriggerEMCALBCUM[bc+5]->Fill(aodph.Eta(), phicluster);
-          fhTimePhotonTriggerEMCALBCUM[bc+5]->Fill(calo->E(), calotof);
+          if(calo->E() > 2) fhEtaPhiPhotonTriggerEMCALBCUM[histoBC]->Fill(aodph.Eta(), phicluster);
+          fhTimePhotonTriggerEMCALBCUM[histoBC]->Fill(calo->E(), calotof);
           
           if(bc==0)
           {
index ef81bb7cc77e73a1ca53aa33852448485bc5286f..7d5b93abb744ff93c2072d2a3af7e18b891bd072 100644 (file)
@@ -1214,8 +1214,8 @@ void AliAnalysisTaskEMCALPi0PbPb::CalcPrimTracks()
       copyt.GetXYZ(pos);
       Double_t covTr[21] = { 0. };
       copyt.GetCovarianceXYZPxPyPz(covTr);
-      Double_t pid[10]   = { 0. };  
-      copyt.GetESDpid(pid);
+      //      Double_t pid[10]   = { 0. };  
+      //      copyt.GetESDpid(pid);
       AliAODTrack *aTrack = new AliAODTrack(copyt.GetID(),
                                             copyt.GetLabel(),
                                             p,
@@ -1225,10 +1225,11 @@ void AliAnalysisTaskEMCALPi0PbPb::CalcPrimTracks()
                                             covTr, 
                                             (Short_t)copyt.GetSign(),
                                             copyt.GetITSClusterMap(), 
-                                            pid,
+                                            //pid,
                                             0,/*fPrimaryVertex,*/
                                             kTRUE, // check if this is right
                                             vtx->UsesTrack(copyt.GetID()));
+      aTrack->SetPIDForTracking(copyt.GetPIDForTracking());
       aTrack->SetTPCClusterMap(copyt.GetTPCClusterMap());
       aTrack->SetTPCSharedMap (copyt.GetTPCSharedMap());
       Float_t ndf = copyt.GetTPCNcls() + 1 - 5 ;
index c912b3adebbbedcc6d63e3d62348afff2f1bd67c..a94745ecf1ae3cc9e865547351a66d04d297f52c 100644 (file)
@@ -77,6 +77,7 @@ AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA() : AliAnalysisTaskSE()
    hElectronITSdEdxP(NULL),
    hElectronTOFP(NULL),
    hElectronNSigmadEdxP(NULL),
+   hElectronNSigmadEdxEta(NULL),
    hElectronNSigmaPiondEdxP(NULL),
    hElectronNSigmaITSP(NULL),
    hElectronNSigmaTOFP(NULL),
@@ -84,6 +85,7 @@ AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA() : AliAnalysisTaskSE()
    hPositronITSdEdxP(NULL),
    hPositronTOFP(NULL),
    hPositronNSigmadEdxP(NULL),
+   hPositronNSigmadEdxEta(NULL),
    hPositronNSigmaPiondEdxP(NULL),
    hPositronNSigmaITSP(NULL),
    hPositronNSigmaTOFP(NULL),
@@ -162,6 +164,7 @@ AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA(const char *name) : Ali
    hElectronITSdEdxP(NULL),
    hElectronTOFP(NULL),
    hElectronNSigmadEdxP(NULL),
+   hElectronNSigmadEdxEta(NULL),
    hElectronNSigmaPiondEdxP(NULL),
    hElectronNSigmaITSP(NULL),
    hElectronNSigmaTOFP(NULL),
@@ -169,6 +172,7 @@ AliAnalysisTaskConversionQA::AliAnalysisTaskConversionQA(const char *name) : Ali
    hPositronITSdEdxP(NULL),
    hPositronTOFP(NULL),
    hPositronNSigmadEdxP(NULL),
+   hPositronNSigmadEdxEta(NULL),
    hPositronNSigmaPiondEdxP(NULL),
    hPositronNSigmaITSP(NULL),
    hPositronNSigmaTOFP(NULL),
@@ -294,9 +298,13 @@ void AliAnalysisTaskConversionQA::UserCreateOutputObjects()
       hElectronNSigmadEdxP =  new TH2F("Electron_NSigmadEdx_P","Electron_NSigmadEdx_P",100, 0.05, 20, 200, -10, 10);  
       SetLogBinningXTH2(hElectronNSigmadEdxP);
       fESDList->Add(hElectronNSigmadEdxP);
+         hElectronNSigmadEdxEta =  new TH2F("Electron_NSigmadEdx_Eta","Electron_NSigmadEdx_Eta",140, -1.4, 1.4, 200, -10, 10);  
+         fESDList->Add(hElectronNSigmadEdxEta);
       hPositronNSigmadEdxP =  new TH2F("Positron_NSigmadEdx_P","Positron_NSigmadEdx_P",100, 0.05, 20, 200, -10, 10);
       SetLogBinningXTH2(hPositronNSigmadEdxP);
       fESDList->Add(hPositronNSigmadEdxP);
+         hPositronNSigmadEdxEta =  new TH2F("Positron_NSigmadEdx_Eta","Positron_NSigmadEdx_Eta",140, -1.4, 1.4, 200, -10, 10);  
+         fESDList->Add(hPositronNSigmadEdxEta);
       hElectronNSigmaPiondEdxP =  new TH2F("Electron_NSigmaPiondEdx_P","Electron_NSigmaPiondEdx_P",100, 0.05, 20, 200, -10, 10);  
       SetLogBinningXTH2(hElectronNSigmaPiondEdxP);
       fESDList->Add(hElectronNSigmaPiondEdxP);
@@ -613,7 +621,7 @@ void AliAnalysisTaskConversionQA::ProcessQATree(AliAODConversionPhoton *gamma){
    // TOF 
    if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
-      Double_t timesPos[5];
+      Double_t timesPos[9];
       posTrack->GetIntegratedTimes(timesPos);
       Double_t TOFsignalPos =  posTrack->GetTOFsignal();
       Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
@@ -625,7 +633,7 @@ void AliAnalysisTaskConversionQA::ProcessQATree(AliAODConversionPhoton *gamma){
    }
    if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
-      Double_t timesNeg[5];
+      Double_t timesNeg[9];
       negTrack->GetIntegratedTimes(timesNeg);
       Double_t TOFsignalNeg =  negTrack->GetTOFsignal();
       Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
@@ -680,15 +688,17 @@ void AliAnalysisTaskConversionQA::ProcessQA(AliAODConversionPhoton *gamma){
    //TPC dEdx
    hElectrondEdxP->Fill(negTrack->P() ,negTrack->GetTPCsignal());
    hElectronNSigmadEdxP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kElectron));
+   hElectronNSigmadEdxEta->Fill(negTrack->Eta() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kElectron));
    hElectronNSigmaPiondEdxP->Fill(negTrack->P() ,pidResonse->NumberOfSigmasTPC(negTrack, AliPID::kPion));
    hPositrondEdxP->Fill(posTrack->P() ,posTrack->GetTPCsignal());
    hPositronNSigmadEdxP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kElectron));
+   hPositronNSigmadEdxEta->Fill(posTrack->Eta() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kElectron));
    hPositronNSigmaPiondEdxP->Fill(posTrack->P() ,pidResonse->NumberOfSigmasTPC(posTrack, AliPID::kPion));
    
    //TOF signal
    if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
-      Double_t timesNeg[5];
+      Double_t timesNeg[9];
       negTrack->GetIntegratedTimes(timesNeg);
       Double_t TOFsignalNeg = negTrack->GetTOFsignal();
       Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
@@ -697,7 +707,7 @@ void AliAnalysisTaskConversionQA::ProcessQA(AliAODConversionPhoton *gamma){
    }
    if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
-      Double_t timesPos[5];
+      Double_t timesPos[9];
       posTrack->GetIntegratedTimes(timesPos);
       Double_t TOFsignalPos = posTrack->GetTOFsignal();
       Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
index 254b97143475c6bfceb4f0b0ab85a3655f548d71..59c3c078b72b6c74d4eb77a338383e4481a5e9a4 100644 (file)
@@ -95,6 +95,7 @@ class AliAnalysisTaskConversionQA : public AliAnalysisTaskSE{
    TH2F* hElectronITSdEdxP;
    TH2F* hElectronTOFP;
    TH2F* hElectronNSigmadEdxP;
+   TH2F* hElectronNSigmadEdxEta;
    TH2F* hElectronNSigmaPiondEdxP;
    TH2F* hElectronNSigmaITSP;
    TH2F* hElectronNSigmaTOFP;
@@ -102,6 +103,7 @@ class AliAnalysisTaskConversionQA : public AliAnalysisTaskSE{
    TH2F* hPositronITSdEdxP;
    TH2F* hPositronTOFP;
    TH2F* hPositronNSigmadEdxP;
+   TH2F* hPositronNSigmadEdxEta;
    TH2F* hPositronNSigmaPiondEdxP;
    TH2F* hPositronNSigmaITSP;
    TH2F* hPositronNSigmaTOFP;
index 26a209f50bdb88f4dc52a073267543fdc7a86ac3..13c8a67ea2ae5f0b7ffd90010811bb36e57d46ff 100644 (file)
@@ -247,7 +247,130 @@ else if( trainConfig == 4 ) {
         ConvCutarray[3] = "8460012082093603007200000000"; ElecCutarray[3] = "9047540025810262171"; MesonCutarray[3] = "01039035009000"; //standard cut Pi0 PbPb 40-60
         ConvCutarray[4] = "8680012082093603007200000000"; ElecCutarray[4] = "9047540025810262171"; MesonCutarray[4] = "01039035009000"; //standard cut Pi0 PbPb 60-80        
         ConvCutarray[5] = "8600012082093603007200000000"; ElecCutarray[5] = "9047540025810262171"; MesonCutarray[5] = "01039035009000"; //standard cut Pi0 PbPb 60-100
-} 
+       
+}  else if( trainConfig == 8 ) {  //No eta shift |Y| < 0.8
+       
+       
+       ConvCutarray[0] = "8000011002093653007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.3 GeV Low and 3.5 High momentum
+       ConvCutarray[1] = "8000011002093601007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.5 GeV Low and 5.0 High momentum
+       ConvCutarray[2] = "8000011002093603007900000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 15
+       ConvCutarray[3] = "8000011002093603007800000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 20
+       ConvCutarray[4] = "8000011002093603007100000000"; ElecCutarray[4] = "9047540025310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 50
+       ConvCutarray[5] = "8000011002093603002200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.7
+       
+       
+}  else if( trainConfig == 9 ) {       //No eta shift |Y| < 0.8
+
+       ConvCutarray[0] = "8000011002093603003200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.5
+       ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540015310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + SPD first layer
+       ConvCutarray[2] = "8000011002093603007200000000"; ElecCutarray[2] = "9047540025330262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + PsiPair cut 0.52
+       ConvCutarray[3] = "8000011002093603007200000000"; ElecCutarray[3] = "9047540025310162171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Background method V0 multiplicity
+       ConvCutarray[4] = "8000011042093603007200000000"; ElecCutarray[4] = "9047540025510262171"; MesonCutarray[4] = "01032035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Y < 0.70  and prim and sec e |eta| < 0.75 //NOTE revisar
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310263171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single prim Pt cut > 0.150
+       
+       
+} else if ( trainConfig == 10 ) {      //No eta shift |Y| < 0.8
+
+       ConvCutarray[0] = "8000011002493603007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.075
+       ConvCutarray[1] = "8000011002193603007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.100
+       ConvCutarray[2] = "8000011002083603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Findable Cls sec  > 0.35
+       ConvCutarray[3] = "8000011002093603007200000000"; ElecCutarray[3] = "9047540026310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Findable Cls prim > 0.60
+       ConvCutarray[4] = "8000011002093603007200000000"; ElecCutarray[4] = "9047540028310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Min TPC cls = 0
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9057540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx primary electron -3,5
+       
+       
+} else if ( trainConfig == 11 ) {        //No eta shift |Y| < 0.8
+       
+       ConvCutarray[0] = "8000011002093603007200000000"; ElecCutarray[0] = "9043540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 2.0sigmas Low and 0 High momentum
+       ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047740025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.3 GeV Low and 3.5 High momentum
+       ConvCutarray[2] = "8000011002093603007200000000"; ElecCutarray[2] = "9047520025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.5 GeV Low and 5.0 High momentum
+       ConvCutarray[3] = "8000011002093603007200000000"; ElecCutarray[3] = "9047540025310262271"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + DCAxy < 1 cm
+       ConvCutarray[4] = "8000011002093603007200000000"; ElecCutarray[4] = "9047540025310261171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + Single prim Pt cut > 0.100
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031005009000"; //standard cut Pi0 pPb 00-100 Standard cut + Alpha cut < 0.7
+       
+       
+} else if ( trainConfig == 12 ) {         //No eta shift |Y| < 0.8
+
+       ConvCutarray[0] = "8000011002093603001200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + qT < 0.1
+       ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540025310262141"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + InvMass(e+,e-) < 0.050
+       ConvCutarray[2] = "8000011002093603007200000000"; ElecCutarray[2] = "9037540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx primary  electron -5,5
+       ConvCutarray[3] = "8000011002091603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx secondary electron -5,5
+       ConvCutarray[4] = "8000011002092603007200000000"; ElecCutarray[4] = "9047540025310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx secondary electron -3,5
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9042540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  primary  2.0sigmas Low and -1 High momentum 
+           
+       
+} else if ( trainConfig == 13 ) {
+  
+       ConvCutarray[0] = "8000011002093803007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  secon    2.0sigmas Low and  1 High momentum
+       ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540025310272171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 100 events backgroubd
+       ConvCutarray[2] = "8000011002093603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + Standard
+       ConvCutarray[3] = "8000011002093603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035000000"; //standard cut Pi0 PbPb 00-100 + No extra smearing
+       ConvCutarray[4] = "8000011002093603007200000000"; ElecCutarray[4] = "9047540025300262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + No psi pair 
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310252171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 50 events background
+   
+
+} else if( trainConfig == 14 ) {  //No eta shift |Y| < 0.8 addedSignal
+       
+       
+       ConvCutarray[0] = "8000012002093653007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.3 GeV Low and 3.5 High momentum
+       ConvCutarray[1] = "8000012002093601007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.5 GeV Low and 5.0 High momentum
+       ConvCutarray[2] = "8000012002093603007900000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 15
+       ConvCutarray[3] = "8000012002093603007800000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 20
+       ConvCutarray[4] = "8000012002093603007100000000"; ElecCutarray[4] = "9047540025310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Chi2 < 50
+       ConvCutarray[5] = "8000012002093603002200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.7
+       
+       
+}  else if( trainConfig == 15 ) {      //No eta shift |Y| < 0.8 addedSignal
+
+       ConvCutarray[0] = "8000012002093603003200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.5
+       ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540015310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + SPD first layer
+       ConvCutarray[2] = "8000012002093603007200000000"; ElecCutarray[2] = "9047540025330262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + PsiPair cut 0.52
+       ConvCutarray[3] = "8000012002093603007200000000"; ElecCutarray[3] = "9047540025310162171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Background method V0 multiplicity
+       ConvCutarray[4] = "8000012042093603007200000000"; ElecCutarray[4] = "9047540025510262171"; MesonCutarray[4] = "01032035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Y < 0.70  and prim and sec e |eta| < 0.75 //NOTE revisar
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310263171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single prim Pt cut > 0.150
+       
+       
+} else if ( trainConfig == 16 ) {      //No eta shift |Y| < 0.8 addedSignal
+
+       ConvCutarray[0] = "8000012002493603007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.075
+       ConvCutarray[1] = "8000012002193603007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.100
+       ConvCutarray[2] = "8000012002083603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Findable Cls sec  > 0.35
+       ConvCutarray[3] = "8000012002093603007200000000"; ElecCutarray[3] = "9047540026310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Findable Cls prim > 0.60
+       ConvCutarray[4] = "8000012002093603007200000000"; ElecCutarray[4] = "9047540028310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Min TPC cls = 0
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9057540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx primary electron -3,5
+       
+       
+} else if ( trainConfig == 17 ) {        //No eta shift |Y| < 0.8 addedSignal
+       
+       ConvCutarray[0] = "8000012002093603007200000000"; ElecCutarray[0] = "9043540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 2.0sigmas Low and 0 High momentum
+       ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047740025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.3 GeV Low and 3.5 High momentum
+       ConvCutarray[2] = "8000012002093603007200000000"; ElecCutarray[2] = "9047520025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.5 GeV Low and 5.0 High momentum
+       ConvCutarray[3] = "8000012002093603007200000000"; ElecCutarray[3] = "9047540025310262271"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + DCAxy < 1 cm
+       ConvCutarray[4] = "8000012002093603007200000000"; ElecCutarray[4] = "9047540025310261171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + Single prim Pt cut > 0.100
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031005009000"; //standard cut Pi0 pPb 00-100 Standard cut + Alpha cut < 0.7
+       
+       
+} else if ( trainConfig == 18 ) {         //No eta shift |Y| < 0.8 addedSignal
+
+       ConvCutarray[0] = "8000012002093603001200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + qT < 0.1
+       ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540025310262141"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + InvMass(e+,e-) < 0.050
+       ConvCutarray[2] = "8000012002093603007200000000"; ElecCutarray[2] = "9037540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx primary  electron -5,5
+       ConvCutarray[3] = "8000012002091603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx secondary electron -5,5
+       ConvCutarray[4] = "8000012002092603007200000000"; ElecCutarray[4] = "9047540025310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx secondary electron -3,5
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9042540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  primary  2.0sigmas Low and -1 High momentum 
+           
+       
+} else if ( trainConfig == 19 ) {         //No eta shift |Y| < 0.8 addedSignal
+  
+        ConvCutarray[0] = "8000012002093803007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  secon    2.0sigmas Low and  1 High momentum
+       ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540025310272171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 100 events backgroubd
+       ConvCutarray[2] = "8000012002093603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + Standard
+       ConvCutarray[3] = "8000012002093603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035000000"; //standard cut Pi0 PbPb 00-100 + No extra smearing
+       ConvCutarray[4] = "8000012002093603007200000000"; ElecCutarray[4] = "9047540025300262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + No psi pair 
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310252171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 50 events background
+ } 
+
  
    
    
@@ -283,7 +406,7 @@ else if( trainConfig == 4 ) {
       }
    else {
 
-   if ( trainConfig == 1 || trainConfig == 3 || trainConfig == 4 ){
+   if ( trainConfig == 1 || trainConfig == 3 || trainConfig == 4  ){
 
          if (i == 0 && doWeighting){
 
@@ -330,7 +453,7 @@ else if( trainConfig == 4 ) {
          }
    }
       
-   else if (trainConfig == 5 ||  trainConfig == 6  || trainConfig == 7 ){
+  else if ( trainConfig == 5 ||  trainConfig == 6  || trainConfig == 7 ){
 
          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");
@@ -352,7 +475,25 @@ else if( trainConfig == 4 ) {
          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");
          }
-     }
+   
+  }
+  else if ( trainConfig == 8 ||  trainConfig == 9  || trainConfig == 10 || trainConfig == 11 ||  trainConfig == 12  || trainConfig == 13 ){
+    
+         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");
+            }
+         }
+  }
+  else if ( trainConfig == 14 ||  trainConfig == 15  || trainConfig == 16 || trainConfig == 17 ||  trainConfig == 18  || trainConfig == 19 ){
+    
+         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");
+         }
+  }
+   
         
 
 
index 42ef90c0d1d1d48578f169ff282b5e1b865346ab..dc51a29b7909e2435a4f79374a8e2295db01a5a0 100644 (file)
@@ -761,7 +761,206 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
                cutarray[ 1] = "8600012002092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //no MCP smearing      
                cutarray[ 2] = "8600012002093172003290000000"; mesonCutArray[ 2] = "01621035000000";  //old standard eta=0.9 y=0.8 
                cutarray[ 3] = "8600012002092170008260400000"; mesonCutArray[ 3] = "01621035008000";  //new standard eta=0.9 y=0.8 // fPSigSmearingCte=0.014;   
-       
+       } else if (trainConfig == 133) {
+               cutarray[ 0] = "8000011002092770023220000000"; mesonCutArray[ 0] = "01621035000000";                       
+               cutarray[ 1] = "8000011002092551023220000000"; mesonCutArray[ 1] = "01621035000000";                       
+               cutarray[ 2] = "8000011002092170003220000000"; mesonCutArray[ 2] = "01621035000000"; //just tighten Psi pair
+               cutarray[ 3] = "8000011002092170003260000000"; mesonCutArray[ 3] = "01621035000000"; //tighten Psi pair and chi2 in 2D
+       } else if (trainConfig == 134) {
+               cutarray[ 0] = "8000012002092770023220000000"; mesonCutArray[ 0] = "01621035000000";                       
+               cutarray[ 1] = "8000012002092551023220000000"; mesonCutArray[ 1] = "01621035000000";                          
+               cutarray[ 2] = "8000012002092170003220000000"; mesonCutArray[ 2] = "01621035000000"; //just tighten Psi pair
+               cutarray[ 3] = "8000012002092170003260000000"; mesonCutArray[ 3] = "01621035000000"; //tighten Psi pair and chi2 in 2D
+       } else if (trainConfig == 135) {          
+               cutarray[ 0] = "8000011002092170008220000000"; mesonCutArray[ 0] = "01621035000000"; //tighten psi pair and qt in 2D
+               cutarray[ 1] = "8000011002092170008260000000"; mesonCutArray[ 1] = "01621035000000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+               cutarray[ 2] = "8000011002092170008220400000"; mesonCutArray[ 2] = "01621035000000"; //clean cuts
+               cutarray[ 3] = "8000011002092170008260400000"; mesonCutArray[ 3] = "01621035000000"; //clean cuts
+       } else if (trainConfig == 136) {
+               cutarray[ 0] = "8000012002092170008220000000"; mesonCutArray[ 0] = "01621035000000"; //tighten psi pair and qt in 2D
+               cutarray[ 1] = "8000012002092170008260000000"; mesonCutArray[ 1] = "01621035000000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+               cutarray[ 2] = "8000012002092170008220400000"; mesonCutArray[ 2] = "01621035000000"; //clean cuts
+               cutarray[ 3] = "8000012002092170008260400000"; mesonCutArray[ 3] = "01621035000000"; //clean cuts
+       } else if (trainConfig == 137) {
+               cutarray[ 0] = "8000011001092170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8  // minR 2.8
+               cutarray[ 1] = "8000011009092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8  //minR 7.5
+               cutarray[ 2] = "8000011002792170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0. GeV/c
+               cutarray[ 3] = "8000011002012170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0.1 GeV/c
+       } else if (trainConfig == 138) {
+               cutarray[ 0] = "8000012001092170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8  // minR 2.8
+               cutarray[ 1] = "8000012009092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8  //minR 7.5
+               cutarray[ 2] = "8000012002792170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0. GeV/c
+               cutarray[ 3] = "8000012002012170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0.1 GeV/c
+       } else if (trainConfig == 139) {
+               cutarray[ 0] = "8000011002082170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.35
+               cutarray[ 1] = "8000011002062170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.7      
+               cutarray[ 2] = "8000011002093170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -4,5
+               cutarray[ 3] = "8000011002096170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -2.5,4
+       } else if (trainConfig == 140) {
+               cutarray[ 0] = "8000012002082170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.35
+               cutarray[ 1] = "8000012002062170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.7
+               cutarray[ 2] = "8000012002093170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -4,5
+               cutarray[ 3] = "8000012002096170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -2.5,4
+       } else if (trainConfig == 141) {
+               cutarray[ 0] = "8000011002092270008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 1,-10
+               cutarray[ 1] = "8000011002092570008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 2,-10
+               cutarray[ 2] = "8000011002092160008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi minMom 0.25
+               cutarray[ 3] = "8000011002092150008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi min Mom 0.3
+       } else if (trainConfig == 142) {
+               cutarray[ 0] = "8000012002092270008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 1,-10
+               cutarray[ 1] = "8000012002092570008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 2,-10
+               cutarray[ 2] = "8000012002092160008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi minMom 0.25
+               cutarray[ 3] = "8000012002092150008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi min Mom 0.3             
+       } else if (trainConfig == 143) {
+               cutarray[ 0] = "8000011002092172008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi maxMom 4GeV
+               cutarray[ 1] = "8000011002092162008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi minMom 0.25GeV maxMom 4GeV
+               cutarray[ 2] = "8000011002092260008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV
+               cutarray[ 3] = "8000011002092262008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV maxMom 4GeV
+       } else if (trainConfig == 144) {
+               cutarray[ 0] = "8000012002092172008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi maxMom 4GeV
+               cutarray[ 1] = "8000012002092162008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi minMom 0.25GeV maxMom 4GeV
+               cutarray[ 2] = "8000012002092260008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV
+               cutarray[ 3] = "8000012002092262008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV maxMom 4GeV
+       } else if (trainConfig == 145) {
+               cutarray[ 0] = "8000011002092170003260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.05 1D
+               cutarray[ 1] = "8000011002092170009260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.03 2D
+               cutarray[ 2] = "8000011002092170002260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.07 1D
+               cutarray[ 3] = "8000011002092170008220400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 and psi Pair 1D 
+       } else if (trainConfig == 146) {
+               cutarray[ 0] = "8000012002092170003260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.05 1D
+               cutarray[ 1] = "8000012002092170009260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.03 2D
+               cutarray[ 2] = "8000012002092170002260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.07 1D
+               cutarray[ 3] = "8000012002092170008220400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 and psi Pair 1D 
+       } else if (trainConfig == 147) {        
+               cutarray[ 0] = "8000011002092170008160400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 50  2D
+               cutarray[ 1] = "8000011002092170008860400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 20  2D
+               cutarray[ 2] = "8000011002092170008250400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.1
+               cutarray[ 3] = "8000011002092170008270400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.035     
+       } else if (trainConfig == 148) {
+               cutarray[ 0] = "8000012002092170008160400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 50  2D
+               cutarray[ 1] = "8000012002092170008860400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 20  2D
+               cutarray[ 2] = "8000012002092170008250400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.1
+               cutarray[ 3] = "8000012002092170008270400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.035
+       } else if (trainConfig == 149) {
+               cutarray[ 0] = "8000011002092170008260300000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // cos pointing angle 0.75
+               cutarray[ 1] = "8000011002092170008260600000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //cos pointing angle 0.9
+               cutarray[ 2] = "8000011002092170008260400000"; mesonCutArray[ 2] = "01621065000000";  //new standard eta=0.9 y=0.8 // alpha meson cut 0.8 
+               cutarray[ 3] = "8000011002092170008260400000"; mesonCutArray[ 3] = "01621034000000";  //new standard eta=0.9 y=0.8 //chi2 meson 500
+       } else if (trainConfig == 150) {
+               cutarray[ 0] = "8000012002092170008260300000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // cos pointing angle 0.75
+               cutarray[ 1] = "8000012002092170008260600000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //cos pointing angle 0.9
+               cutarray[ 2] = "8000012002092170008260400000"; mesonCutArray[ 2] = "01621065000000";  //new standard eta=0.9 y=0.8 // alpha meson cut 0.8 
+               cutarray[ 3] = "8000012002092170008260400000"; mesonCutArray[ 3] = "01621034000000";  //new standard eta=0.9 y=0.8 //chi2 meson 500             
+       } else if (trainConfig == 151) {
+               cutarray[ 0] = "8000011002092170008260400000"; mesonCutArray[ 0] = "02621035000000";  //new standard eta=0.9 y=0.8 // BG track multiplicity
+               cutarray[ 1] = "8000011002092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //no MCP smearing
+               cutarray[ 2] = "8000011002093172003290000000"; mesonCutArray[ 2] = "01621035000000";  //old standard eta=0.9 y=0.8 
+               cutarray[ 3] = "8000011002092170008260400000"; mesonCutArray[ 3] = "01621035008000";  //new standard eta=0.9 y=0.8 // fPSigSmearingCte=0.014;
+       } else if (trainConfig == 152) {
+               cutarray[ 0] = "8000012002092170008260400000"; mesonCutArray[ 0] = "02621035000000";  //new standard eta=0.9 y=0.8 // BG track multiplicity
+               cutarray[ 1] = "8000012002092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //no MCP smearing      
+               cutarray[ 2] = "8000012002093172003290000000"; mesonCutArray[ 2] = "01621035000000";  //old standard eta=0.9 y=0.8 
+               cutarray[ 3] = "8000012002092170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 // fPSigSmearingCte=0.014;
+       } else if (trainConfig == 153) {
+               cutarray[ 0] = "8020011002092770023220000000"; mesonCutArray[ 0] = "01621035000000";                       
+               cutarray[ 1] = "8020011002092551023220000000"; mesonCutArray[ 1] = "01621035000000";                       
+               cutarray[ 2] = "8020011002092170003220000000"; mesonCutArray[ 2] = "01621035000000"; //just tighten Psi pair
+               cutarray[ 3] = "8020011002092170003260000000"; mesonCutArray[ 3] = "01621035000000"; //tighten Psi pair and chi2 in 2D  
+       } else if (trainConfig == 154) {
+               cutarray[ 0] = "8020012002092770023220000000"; mesonCutArray[ 0] = "01621035000000";                       
+               cutarray[ 1] = "8020012002092551023220000000"; mesonCutArray[ 1] = "01621035000000";                          
+               cutarray[ 2] = "8020012002092170003220000000"; mesonCutArray[ 2] = "01621035000000"; //just tighten Psi pair
+               cutarray[ 3] = "8020012002092170003260000000"; mesonCutArray[ 3] = "01621035000000"; //tighten Psi pair and chi2 in 2D
+       } else if (trainConfig == 155) {          
+               cutarray[ 0] = "8020011002092170008220000000"; mesonCutArray[ 0] = "01621035000000"; //tighten psi pair and qt in 2D
+               cutarray[ 1] = "8020011002092170008260000000"; mesonCutArray[ 1] = "01621035000000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+               cutarray[ 2] = "8020011002092170008220400000"; mesonCutArray[ 2] = "01621035000000"; //clean cuts
+               cutarray[ 3] = "8020011002092170008260400000"; mesonCutArray[ 3] = "01621035000000"; //clean cuts
+       } else if (trainConfig == 156) {
+               cutarray[ 0] = "8020012002092170008220000000"; mesonCutArray[ 0] = "01621035000000"; //tighten psi pair and qt in 2D
+               cutarray[ 1] = "8020012002092170008260000000"; mesonCutArray[ 1] = "01621035000000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
+               cutarray[ 2] = "8020012002092170008220400000"; mesonCutArray[ 2] = "01621035000000"; //clean cuts
+               cutarray[ 3] = "8020012002092170008260400000"; mesonCutArray[ 3] = "01621035000000"; //clean cuts
+       } else if (trainConfig == 157) {
+               cutarray[ 0] = "8020011001092170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8  // minR 2.8
+               cutarray[ 1] = "8020011009092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8  //minR 7.5
+               cutarray[ 2] = "8020011002792170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0. GeV/c
+               cutarray[ 3] = "8020011002012170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0.1 GeV/c
+       } else if (trainConfig == 158) {
+               cutarray[ 0] = "8020012001092170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8  // minR 2.8
+               cutarray[ 1] = "8020012009092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8  //minR 7.5
+               cutarray[ 2] = "8020012002792170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0. GeV/c
+               cutarray[ 3] = "8020012002012170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8  //single pT 0.1 GeV/c
+       } else if (trainConfig == 159) {
+               cutarray[ 0] = "8020011002082170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.35
+               cutarray[ 1] = "8020011002062170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.7      
+               cutarray[ 2] = "8020011002093170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -4,5
+               cutarray[ 3] = "8020011002096170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -2.5,4
+       } else if (trainConfig == 160) {
+               cutarray[ 0] = "8020012002082170008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.35
+               cutarray[ 1] = "8020012002062170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //TPC Cluster 0.7
+               cutarray[ 2] = "8020012002093170008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -4,5
+               cutarray[ 3] = "8020012002096170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //edEdx -2.5,4
+       } else if (trainConfig == 161) {
+               cutarray[ 0] = "8020011002092270008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 1,-10
+               cutarray[ 1] = "8020011002092570008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 2,-10
+               cutarray[ 2] = "8020011002092160008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi minMom 0.25
+               cutarray[ 3] = "8020011002092150008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi min Mom 0.3
+       } else if (trainConfig == 162) {
+               cutarray[ 0] = "8020012002092270008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 1,-10
+               cutarray[ 1] = "8020012002092570008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi dEdx 2,-10
+               cutarray[ 2] = "8020012002092160008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi minMom 0.25
+               cutarray[ 3] = "8020012002092150008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi min Mom 0.3             
+       } else if (trainConfig == 163) {
+               cutarray[ 0] = "8020011002092172008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi maxMom 4GeV
+               cutarray[ 1] = "8020011002092162008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi minMom 0.25GeV maxMom 4GeV
+               cutarray[ 2] = "8020011002092260008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV
+               cutarray[ 3] = "8020011002092262008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV maxMom 4GeV
+       } else if (trainConfig == 164) {
+               cutarray[ 0] = "8020012002092172008260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi maxMom 4GeV
+               cutarray[ 1] = "8020012002092162008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 // pi minMom 0.25GeV maxMom 4GeV
+               cutarray[ 2] = "8020012002092260008260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV
+               cutarray[ 3] = "8020012002092262008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //pi dEdx 1,-10  minMom 0.25GeV maxMom 4GeV
+       } else if (trainConfig == 165) {
+               cutarray[ 0] = "8020011002092170003260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.05 1D
+               cutarray[ 1] = "8020011002092170009260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.03 2D
+               cutarray[ 2] = "8020011002092170002260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.07 1D
+               cutarray[ 3] = "8020011002092170008220400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 and psi Pair 1D 
+       } else if (trainConfig == 166) {
+               cutarray[ 0] = "8020012002092170003260400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.05 1D
+               cutarray[ 1] = "8020012002092170009260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.03 2D
+               cutarray[ 2] = "8020012002092170002260400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //qT 0.07 1D
+               cutarray[ 3] = "8020012002092170008220400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 and psi Pair 1D 
+       } else if (trainConfig == 167) {        
+               cutarray[ 0] = "8020011002092170008160400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 50  2D
+               cutarray[ 1] = "8020011002092170008860400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 20  2D
+               cutarray[ 2] = "8020011002092170008250400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.1
+               cutarray[ 3] = "8020011002092170008270400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.035     
+       } else if (trainConfig == 168) {
+               cutarray[ 0] = "8020012002092170008160400000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 50  2D
+               cutarray[ 1] = "8020012002092170008860400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //chi2 20  2D
+               cutarray[ 2] = "8020012002092170008250400000"; mesonCutArray[ 2] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.1
+               cutarray[ 3] = "8020012002092170008270400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 //psi pair 0.035
+       } else if (trainConfig == 169) {
+               cutarray[ 0] = "8020011002092170008260300000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // cos pointing angle 0.75
+               cutarray[ 1] = "8020011002092170008260600000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //cos pointing angle 0.9
+               cutarray[ 2] = "8020011002092170008260400000"; mesonCutArray[ 2] = "01621065000000";  //new standard eta=0.9 y=0.8 // alpha meson cut 0.8 
+               cutarray[ 3] = "8020011002092170008260400000"; mesonCutArray[ 3] = "01621034000000";  //new standard eta=0.9 y=0.8 //chi2 meson 500
+       } else if (trainConfig == 170) {
+               cutarray[ 0] = "8020012002092170008260300000"; mesonCutArray[ 0] = "01621035000000";  //new standard eta=0.9 y=0.8 // cos pointing angle 0.75
+               cutarray[ 1] = "8020012002092170008260600000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //cos pointing angle 0.9
+               cutarray[ 2] = "8020012002092170008260400000"; mesonCutArray[ 2] = "01621065000000";  //new standard eta=0.9 y=0.8 // alpha meson cut 0.8 
+               cutarray[ 3] = "8020012002092170008260400000"; mesonCutArray[ 3] = "01621034000000";  //new standard eta=0.9 y=0.8 //chi2 meson 500             
+       } else if (trainConfig == 171) {
+               cutarray[ 0] = "8020011002092170008260400000"; mesonCutArray[ 0] = "02621035000000";  //new standard eta=0.9 y=0.8 // BG track multiplicity
+               cutarray[ 1] = "8020011002092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //no MCP smearing
+               cutarray[ 2] = "8020011002093172003290000000"; mesonCutArray[ 2] = "01621035000000";  //old standard eta=0.9 y=0.8 
+               cutarray[ 3] = "8020011002092170008260400000"; mesonCutArray[ 3] = "01621035008000";  //new standard eta=0.9 y=0.8 // fPSigSmearingCte=0.014;
+       } else if (trainConfig == 172) {
+               cutarray[ 0] = "8020012002092170008260400000"; mesonCutArray[ 0] = "02621035000000";  //new standard eta=0.9 y=0.8 // BG track multiplicity
+               cutarray[ 1] = "8020012002092170008260400000"; mesonCutArray[ 1] = "01621035000000";  //new standard eta=0.9 y=0.8 //no MCP smearing      
+               cutarray[ 2] = "8020012002093172003290000000"; mesonCutArray[ 2] = "01621035000000";  //old standard eta=0.9 y=0.8 
+               cutarray[ 3] = "8020012002092170008260400000"; mesonCutArray[ 3] = "01621035000000";  //new standard eta=0.9 y=0.8 // fPSigSmearingCte=0.014;           
        } else {
                Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
                return;
@@ -799,7 +998,7 @@ 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 == 3 || trainConfig == 5 || trainConfig == 7 || trainConfig == 9 || trainConfig == 11 || trainConfig == 13 || trainConfig == 15|| trainConfig == 17|| trainConfig == 19 || trainConfig == 21 ){
+               if ( trainConfig == 1 || trainConfig == 3 || trainConfig == 5 || trainConfig == 7 || trainConfig == 9 || trainConfig == 11 || trainConfig == 13 || trainConfig == 15|| trainConfig == 17|| trainConfig == 19 || trainConfig == 21 || trainConfig == 133 || trainConfig == 135 || trainConfig == 137 || trainConfig == 139 || trainConfig == 141 || trainConfig == 143 || trainConfig == 145 || trainConfig == 147 || trainConfig == 149 || trainConfig == 151){
                        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");
@@ -808,13 +1007,13 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
                                }
                        }
                }   
-               if ( trainConfig == 2 || trainConfig == 4 || trainConfig == 6 || trainConfig == 8 || trainConfig == 10 || trainConfig == 12 || trainConfig == 14 || trainConfig == 16|| trainConfig == 18|| trainConfig == 20|| trainConfig == 22){
+               if ( trainConfig == 2 || trainConfig == 4 || trainConfig == 6 || trainConfig == 8 || trainConfig == 10 || trainConfig == 12 || trainConfig == 14 || trainConfig == 16|| trainConfig == 18|| trainConfig == 20|| trainConfig == 22 || trainConfig == 134 || trainConfig == 136 || trainConfig == 138 || trainConfig == 140 || trainConfig == 142 || trainConfig == 144 || trainConfig == 146 || trainConfig == 148 || trainConfig == 150 || trainConfig == 152){
                        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");
                        }
                        
                }   
-               if ( trainConfig == 23 || trainConfig == 25 || trainConfig == 27 || trainConfig == 29 || trainConfig == 31 || trainConfig == 33 || trainConfig == 35 || trainConfig == 37|| trainConfig == 39|| trainConfig == 41 || trainConfig == 43 ){
+               if ( trainConfig == 23 || trainConfig == 25 || trainConfig == 27 || trainConfig == 29 || trainConfig == 31 || trainConfig == 33 || trainConfig == 35 || trainConfig == 37|| trainConfig == 39|| trainConfig == 41 || trainConfig == 43 || trainConfig == 153 || trainConfig == 155 || trainConfig == 157 || trainConfig == 159 || trainConfig == 161 || trainConfig == 163 || trainConfig == 165 || trainConfig == 167 || trainConfig == 169 || trainConfig == 171){
                        if (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");
@@ -823,7 +1022,7 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
                                }
                        }
                }   
-               if ( trainConfig == 24 || trainConfig == 26 || trainConfig == 28 || trainConfig == 30 || trainConfig == 32 || trainConfig == 34 || trainConfig == 36 || trainConfig == 38|| trainConfig == 40|| trainConfig == 42|| trainConfig == 44){
+               if ( trainConfig == 24 || trainConfig == 26 || trainConfig == 28 || trainConfig == 30 || trainConfig == 32 || trainConfig == 34 || trainConfig == 36 || trainConfig == 38|| trainConfig == 40|| trainConfig == 42|| trainConfig == 44 || trainConfig == 154 || trainConfig == 156 || trainConfig == 158 || trainConfig == 160 || trainConfig == 162 || trainConfig == 164 || trainConfig == 166 || trainConfig == 168 || trainConfig == 170 || trainConfig == 172){
                        if (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");
                        }
index 6c9443b45f7a15bc0351744cf22ea3b3807fcb2a..50447b52320cedfdfeb8c599722a2fb27b0f4a43 100644 (file)
 #include "AliInputEventHandler.h"
 #include "AliMultiInputEventHandler.h"
 #include "AliVEvent.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliESDCaloCluster.h"
+#include "AliVParticle.h"
+#include "AliVTrack.h"
+#include "AliAODCluster.h"
+#include "AliVCaloCells.h"
+#include "AliOADBContainer.h"
+#include "AliPHOSGeometry.h"
+#include "AliAnalysisManager.h"
+
+
 
 #include "AliPHOSClusterSelection.h"
 
@@ -26,7 +38,7 @@ AliPHOSClusterSelection::AliPHOSClusterSelection()
   : fMinChargedParticleTrackDistance(-1.), 
     fNotUnfolded(false),
     fMaxDispR2(-1.),
-    fMaxDispCoreR2(-1.),
+    fCoreRadius(-1.),
     fMaxTOF(-1.)
 {
   // Defaults to the most lenient selection allowable
@@ -48,9 +60,96 @@ Bool_t AliPHOSClusterSelection::IsSelected(AliVCluster* cluster) const
 
 Bool_t IsSelectedCPV(AliVCluster* cluster) const
 {
-  if( 0 > SetMinChargedParticleTrackDistance )
+  if( 0 > fMinChargedParticleTrackDistance )//No selection on CPV
     return true; 
-  //TODO: implement positive case
+
+  else{
+    Bool_t cpvBit = true; //Changed to false if there is a matching track in the requested radius.
+
+    Double_t dx=cluster->GetTrackDx();//Position for Track matching
+    Double_t dz=cluster->GetTrackDz();
+
+
+    AliESDEvent* EventESD = dynamic_cast<AliESDEvent*> (AliPHOSClusterSelection::GetCurrentEvent());//dynamic cast to test for ESD or AOD
+    AliAODEvent* EventAOD = dynamic_cast<AliAODEvent*> (AliPHOSClusterSelection::GetCurrentEvent());
+    Double_t mf = 0.; //
+    if(EventAOD) mf = EventAOD->GetMagneticField(); //Positive for ++ and negative for -- 
+    else if(EventESD) mf = EventESD->GetMagneticField(); //Positive for ++ and negative for --
+
+
+    if(EventESD){//if ESD
+      AliESDCaloCluster * ESDcluster = static_cast<AliESDCaloCluster*> (cluster);//Know its ESD so static cast is fine?
+      TArrayI * itracks = ESDcluster-> GetTracksMatched() ;
+      if(itracks->GetSize()>0){
+       Int_t iTr = itracks->At(0);
+       if(iTr>=0 && iTr<fEvent->GetNumberOfTracks()){
+         AliVParticle* track = fEvent->GetTrack(iTr);
+         Double_t pt = track->Pt() ;
+         Short_t charge = track->Charge() ;
+         Double_t r=AliPHOSClusterSelection::TestCPV(dx, dz, pt, charge, mf) ;
+         cpvBit=(r>fMinChargedParticleTrackDistance) ;
+       }
+      }
+    }
+
+
+    if(EventAOD){//if AOD
+      AliAODCluster * AODcluster = static_cast<AliAODCluster*> (cluster);
+      int nTracksMatched = AODcluster->GetNTracksMatched();
+      if(nTracksMatched > 0) {
+       AliVTrack* track = dynamic_cast<AliVTrack*> (cluster->GetTrackMatched(0));
+       if ( track ) {
+         Double_t pt = track->Pt();
+         Short_t charge = track->Charge();
+         Double_t r = AliPHOSClusterSelection::TestCPV(dx, dz, pt, charge, mf) ;
+         cpvBit=(r>fMinChargedParticleTrackDistance) ;
+       }
+      }
+    }
+    return cpvBit;
+  }
+}
+
+
+Bool_t IsSelectedUnfolded(AliVCluster* cluster) const
+{
+  if(!fNotUnfolded)
+    return true;
+  else{
+    Bool_t NotUnfolded = cluster->GetNExMax()<2;//True if it was not unfolded
+    return !NotUnfolded;
+  }
+}
+
+Bool_t IsSelectedDisp(AliVCluster* cluster) const
+{
+  if(0 > fMaxDispR2)
+    return true;
+  else{
+    Double_t m02 = 0.,m20 = 0.;
+    if(fCoreRadius<0){//No core calculation
+      m02 = cluster->GetM02();
+      m20 = cluster->GetM20();
+      return AliPHOSClusterSelection::TestLambda(cluster->E(),m20,m02) ;
+    }
+    else{//TODO: Core calculation for general R 
+      AliVCaloCells* cells = static_cast<AliVCaloCells*> (AliPHOSClusterSelection::GetCurrentEvent()->GetPHOSCells());//Need the cells
+      AliPHOSClusterSelection::EvalCoreLambdas(cluster, cells, m02, m20);
+      return AliPHOSClusterSelection::TestLambda(cluster->E(),m20,m02);
+    }
+  }
+
+}
+
+Bool_t IsSelectedTOF(AliVCluster* cluster) const
+{
+  if(0 > fMaxTOF)
+    return true;
+  else{ 
+    // Time of Flight (TOF)
+    Double_t tof = cluster->GetTOF();//Time of Flight for the cluster
+    return  TMath::Abs(tof) < fMaxTOF;//True if the cut is passed
+  }
 }
 
 AliPHOSClusterSelection* AliPHOSClusterSelection::SetMinChargedParticleTrackDistance(Float_t distance)
@@ -61,6 +160,42 @@ AliPHOSClusterSelection* AliPHOSClusterSelection::SetMinChargedParticleTrackDist
   // being "not applied" or "disabled".
   
   fMinChargedParticleTrackDistance = distance;
+  return this;
+}
+
+AliPHOSClusterSelection* AliPHOSClusterSelection::SetNotUnfolded(Bool_t notUnfolded)
+{
+  //if notUnfolded true, it rejects Unfolded Clusters
+  fNotUnfolded = notUnfolded;
+  return this;
+}
+
+AliPHOSClusterSelection* AliPHOSClusterSelection::SetMaxDispR2(Float_t maxR2)
+{
+  // 'maxR2' sets the maximum allowed dispersion.
+  // If 'maxR2' is negative, then all clusters are selected, the selection
+  // being "not applied" or "disabled".
+  
+  fMaxDispR2 = maxR2;
+  return this;
+}
+
+AliPHOSClusterSelection* AliPHOSClusterSelection::SetCoreRadius(Float_t radius)
+{
+  // 'radius' sets the core radius used for the dispersion cut evaluation.
+  // If 'radius' is negative, the whole cluster is used.
+  
+  fCoreRadius = radius;
+  return this;
+}
+
+AliPHOSClusterSelection* AliPHOSClusterSelection::SetMaxTOF(Float_t maxTOF)
+{
+  // 'maxTOF' sets the maximum allowed time of flight for the cluster.
+  // If 'maxTOF' is negative, all clusters are selected and the selection is "disabled".
+  
+  fCoreRadius = radius;
+  return this;
 }
 
 TString AliPHOSClusterSelection::ToString() const
@@ -70,25 +205,214 @@ TString AliPHOSClusterSelection::ToString() const
   // is limited by the precision given in the formatting of the string.
   // Take care that the precision is sufficient for your needs.
 
-  return TString::Format("%f_%i_%f_%f_%f",
+  return TString::Format("%.1f_%i_%.1f_%.1f_%.1f",
                         fMinChargedParticleTrackDistance,
                         fNotUnfolded,
                         fMaxDispR2,
-                        fMaxDispCoreR2,
+                        fCoreRadius,
                         fMaxTOF
                         );
 }
 
 
-Float_t AliPHOSClusterSelection::SetMinChargedParticleTrackDistance(const TString& string)
+Float_t AliPHOSClusterSelection::GetMinChargedParticleTrackDistance(const TString& string)
+{
+  //TObjArray * objarray = string.Tokenize("_");
+  TObjString * objstring = string.Tokenize("_")->At(0);
+  Float_t flt= objstring->GetString()->Atof();
+  delete objstring;
+  return flt;
+}
+
+Bool_t AliPHOSClusterSelection::GetUnfolded(const TString& string)
+{
+  TObjString * objstring = string.Tokenize("_")->At(1);
+  Bool_t bl = objstring->GetString()->Atoi(); 
+  delete objstring;
+  return bl;
+}
+
+Float_t AliPHOSClusterSelection::GetMaxDispR2(const TString& string)
+{
+  TObjString * objstring = string.Tokenize("_")->At(2);
+  Float_t flt = objstring->Atof(); 
+  delete objstring;
+  return flt;
+}
+
+Float_t AliPHOSClusterSelection::GetCoreRadius(const TString& string)
+{
+  TObjArray * objstring = string.Tokenize("_")->At(3);
+  Float_t flt = objstring->Atof(); 
+  delete objstring;
+  return flt;
+}
+
+Float_t AliPHOSClusterSelection::GetMaxTOF(const TString& string)
 {
-  TObjArray * objarray = string.Tokenize("_");
-  Float_t flt = objarray->At(0)->Atof();
-  delete objarray;
+  TObjArray * objstring = string.Tokenize("_")->At(4);
+  Float_t flt = objstring->Atof(); 
+  delete objstring;
   return flt;
 }
 
 
+Double_t AliPHOSClusterSelection::TestCPV(Double_t dx, Double_t dz, Double_t pt, Int_t charge, Double_t mf){
+  //Parameterization of LHC10h period
+  //_true if neutral_
+  //Copied from Pi0Flow task
+
+  Double_t meanX=0;
+  Double_t meanZ=0.;
+  Double_t sx=TMath::Min(5.4,2.59719e+02*TMath::Exp(-pt/1.02053e-01)+
+                        6.58365e-01*5.91917e-01*5.91917e-01/((pt-9.61306e-01)*(pt-9.61306e-01)+5.91917e-01*5.91917e-01)+1.59219);
+  Double_t sz=TMath::Min(2.75,4.90341e+02*1.91456e-02*1.91456e-02/(pt*pt+1.91456e-02*1.91456e-02)+1.60) ;
+  if(mf<0.){ //field --
+    meanZ = -0.468318 ;
+    if(charge>0)
+      meanX=TMath::Min(7.3, 3.89994*1.20679*1.20679/(pt*pt+1.20679*1.20679)+0.249029+2.49088e+07*TMath::Exp(-pt*3.33650e+01)) ;
+    else
+      meanX=-TMath::Min(7.7,3.86040*0.912499*0.912499/(pt*pt+0.912499*0.912499)+1.23114+4.48277e+05*TMath::Exp(-pt*2.57070e+01)) ;
+  }
+  else{ //Field ++
+    meanZ= -0.468318;
+    if(charge>0)
+      meanX=-TMath::Min(8.0,3.86040*1.31357*1.31357/(pt*pt+1.31357*1.31357)+0.880579+7.56199e+06*TMath::Exp(-pt*3.08451e+01)) ;
+    else
+      meanX= TMath::Min(6.85, 3.89994*1.16240*1.16240/(pt*pt+1.16240*1.16240)-0.120787+2.20275e+05*TMath::Exp(-pt*2.40913e+01)) ;
+  }
+
+  Double_t rz=(dz-meanZ)/sz ;
+  Double_t rx=(dx-meanX)/sx ;
+  return TMath::Sqrt(rx*rx+rz*rz) ;
+}
+
+//____________________________________________________________________________
+void  AliPHOSClusterSelection::EvalCoreLambdas(AliVCluster * clu, AliVCaloCells * cells,Double_t &m02, Double_t &m20){ 
+  //calculate dispecrsion of the cluster in the circle with radius distanceCut around the maximum
+  //Copied from pi0flowtask
+
+  const Double_t rCut=fCoreRadius;//TODO: This now works only for R=4.5 as the dispersion cut is not tuned for other values  
+  const Double32_t * elist = clu->GetCellsAmplitudeFraction() ;  
+// Calculates the center of gravity in the local PHOS-module coordinates
+  Float_t wtot = 0;
+  const Int_t mulDigit=clu->GetNCells() ;
+  Double_t xc[mulDigit] ;
+  Double_t zc[mulDigit] ;
+  Double_t wi[mulDigit] ;
+  Double_t x = 0 ;
+  Double_t z = 0 ;
+  const Double_t logWeight=4.5 ;
+  for(Int_t iDigit=0; iDigit<mulDigit; iDigit++) {
+    Int_t relid[4] ;
+    Float_t xi=0. ;
+    Float_t zi=0. ;
+    Int_t absId = clu->GetCellAbsId(iDigit) ;
+
+    AliOADBContainer geomContainer("phosGeo");//Initialize Geometry
+    geomContainer.InitFromFile("$ALICE_ROOT/OADB/PHOS/PHOSGeometry.root","PHOSRotationMatrixes");
+    TObjArray *matrixes = (TObjArray*)geomContainer.GetObject(fRunNumber,"PHOSRotationMatrixes");
+    AliPHOSGeometry * fPHOSGeo =  AliPHOSGeometry::GetInstance("IHEP") ;
+    for(Int_t mod=0; mod<5; mod++) {
+      if(!matrixes->At(mod)) {
+       if( fDebug )
+         AliInfo(Form("No PHOS Matrix for mod:%d, geo=%p\n", mod, fPHOSGeo));
+       continue;
+      }
+
+
+    fPHOSGeo->AbsToRelNumbering(absId, relid) ;
+    fPHOSGeo->RelPosInModule(relid, xi, zi);
+    xc[iDigit]=xi ;
+    zc[iDigit]=zi ;
+    Double_t ei = elist[iDigit]*cells->GetCellAmplitude(absId) ;
+    wi[iDigit]=0. ;
+    if (clu->E()>0 && ei>0) {
+      wi[iDigit] = TMath::Max( 0., logWeight + TMath::Log( ei / clu->E() ) ) ;
+      Double_t w=wi[iDigit];
+      x    += xc[iDigit] * w ;
+      z    += zc[iDigit] * w ;
+      wtot += w ;
+    }
+  }
+  if (wtot>0) {
+    x /= wtot ;
+    z /= wtot ;
+  }
+     
+  wtot = 0. ;
+  Double_t dxx  = 0.;
+  Double_t dzz  = 0.;
+  Double_t dxz  = 0.;
+  Double_t xCut = 0. ;
+  Double_t zCut = 0. ;
+  for(Int_t iDigit=0; iDigit<mulDigit; iDigit++) {
+    Double_t w=wi[iDigit];
+    if (w>0.) {
+        Double_t xi= xc[iDigit] ;
+        Double_t zi= zc[iDigit] ;
+       if((xi-x)*(xi-x)+(zi-z)*(zi-z) < rCut*rCut){
+          xCut += w * xi ;
+          zCut += w * zi ; 
+          dxx  += w * xi * xi ;
+          dzz  += w * zi * zi ;
+          dxz  += w * xi * zi ; 
+          wtot += w ;
+       }
+    }
+    
+  }
+  if (wtot>0) {
+    xCut/= wtot ;
+    zCut/= wtot ;
+    dxx /= wtot ;
+    dzz /= wtot ;
+    dxz /= wtot ;
+    dxx -= xCut * xCut ;
+    dzz -= zCut * zCut ;
+    dxz -= xCut * zCut ;
+
+    m02 =  0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz )  ;
+    m20 =  0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz )  ;
+  }
+  else {
+    m20=m02=0.;
+  }
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisTaskPi0Flow::TestLambda(Double_t pt,Double_t l1,Double_t l2){
+  //Evaluates if lambdas correspond to photon cluster
+  //Tuned using pp data 
+  //copied from Pi0FlowTask
+  Double_t l2Mean, l1Mean, l2Sigma, l1Sigma, c, R2;
+  if(fCoreRadius<0){
+    l2Mean  = 1.53126+9.50835e+06/(1.+1.08728e+07*pt+1.73420e+06*pt*pt) ;
+    l1Mean  = 1.12365+0.123770*TMath::Exp(-pt*0.246551)+5.30000e-03*pt ;
+    l2Sigma = 6.48260e-02+7.60261e+10/(1.+1.53012e+11*pt+5.01265e+05*pt*pt)+9.00000e-03*pt;
+    l1Sigma = 4.44719e-04+6.99839e-01/(1.+1.22497e+00*pt+6.78604e-07*pt*pt)+9.00000e-03*pt;
+    c=-0.35-0.550*TMath::Exp(-0.390730*pt) ;
+    R2=0.5*(l1-l1Mean)*(l1-l1Mean)/l1Sigma/l1Sigma +
+      0.5*(l2-l2Mean)*(l2-l2Mean)/l2Sigma/l2Sigma +
+      0.5*c*(l1-l1Mean)*(l2-l2Mean)/l1Sigma/l2Sigma ;
+  }
+  else{
+    //For core radius R=4.5
+    l1Mean  = 1.150200 + 0.097886/(1.+1.486645*pt+0.000038*pt*pt) ;
+    l2Mean = 1.574706 + 0.997966*exp(-0.895075*pt)-0.010666*pt ;
+    l1Sigma = 0.100255 + 0.337177*exp(-0.517684*pt)+0.001170*pt ;
+    l2Sigma = 0.232580 + 0.573401*exp(-0.735903*pt)-0.002325*pt ;
+    c = -0.110983 -0.017353/(1.-1.836995*pt+0.934517*pt*pt) ;
+    R2=0.5*(l1-l1Mean)*(l1-l1Mean)/l1Sigma/l1Sigma + 
+      0.5*(l2-l2Mean)*(l2-l2Mean)/l2Sigma/l2Sigma +
+      0.5*c*(l1-l1Mean)*(l2-l2Mean)/l1Sigma/l2Sigma ;
+  }
+  return (R2<fMaxDispR2*MaxDispR2);//TODO: Check if this should be 2. order
+}
+
+
 AliVEvent* AliPHOSClusterSelection::GetCurrentEvent() const
 {
   // Hackish way of getting the current event.
index 1d109a7933e67c0e24d39efc200c339ec67deb07..93d89c7e5c375f5410f8641e7d55d788658c02f3 100644 (file)
@@ -28,35 +28,43 @@ class AliPHOSClusterSelection : TObject {
   virtual Bool_t IsSelectedCPV(AliVCluster* cluster) const;
   virtual Bool_t IsSelectedUnfolded(AliVCluster* cluster) const;
   virtual Bool_t IsSelectedDisp(AliVCluster* cluster) const;
-  virtual Bool_t IsSelectedDispCore(AliVCluster* cluster) const;
   virtual Bool_t IsSelectedTOF(AliVCluster* cluster) const;
 
   // Configuration Functions
   AliPHOSClusterSelection* SetMinChargedParticleTrackDistance(Float_t distance);
   AliPHOSClusterSelection* SetNotUnfolded(Bool_t notUnfolded);
   AliPHOSClusterSelection* SetMaxDispR2(Float_t maxR2);
-  AliPHOSClusterSelection* SetMaxDispCoreR2(Float_t maxR2);
+  AliPHOSClusterSelection* SetCoreRadius(Float_t radius);
   AliPHOSClusterSelection* SetMaxTOF(Float_t maxTOF);
   
   AliPHOSClusterSelection* SetMinSelection();
 
   virtual TString ToString() const;
-  static Float_t SetMinChargedParticleTrackDistance(const TString string);
-  
+  static Float_t  GetMinChargedParticleTrackDistance(const TString string);
+  static Bool_t   GetUnfolded(const TString string);
+  static Float_t  GetMaxDispR2(const TString string);
+  static Float_t  GetCoreRadius(const TString string);
+  static Float_t  GetMaxTOF(const TString string);
+
+
  protected:
   AliPHOSClusterSelection(const AliPHOSClusterSelection&); // not implemented
   AliPHOSClusterSelection& operator=(const AliPHOSClusterSelection&); // not implemented
   
+  Double_t TestCPV(Double_t dx, Double_t dz, Double_t pt, Int_t charge, Double_t mf);//Copied from Pi0Flow task
+  void  AliPHOSClusterSelection::EvalCoreLambdas(AliVCluster * clu, AliVCaloCells * cells,Double_t &m02, Double_t &m20);//Copied from Pi0Flow task
+  Bool_t AliAnalysisTaskPi0Flow::TestLambda(Double_t pt,Double_t l1,Double_t l2);//Copied from Pi0FlowTask
   // Selection Parameters
   Float_t fMinChargedParticleTrackDistance; // CPV, Charged Particle Veto
   Bool_t fNotUnfolded; // if true, rejects Unfolded Clusters
   Float_t fMaxDispR2; // dispersion cut
-  Float_t fMaxDispCoreR2; // dispersion cut of core cells
+  Float_t fCoreRadius; // Core radius
   Float_t fMaxTOF; // TOF cut
 
   AliVEvent* GetCurrentEvent() const;
-  
+
   ClassDef(AliPHOSClusterSelection, 1);
 };
 
 #endif
+
index 4690c866b5503205174abea985e4422d0edd4d46..1f9f4dd392aece7dacb8407424d1a2b221d05ba5 100644 (file)
@@ -60,6 +60,7 @@
 // Authors : Dmitri Peressounko
 // Date    : 28.05.2011
 // Modified: 03.08.2012 Henrik Qvigstad
+/* $Id: AliAnalysisTaskPi0Flow.cxx 64584 2013-10-17 15:37:28Z kharlov $ */
 
 ClassImp(AliAnalysisTaskPi0Flow);
 
@@ -79,9 +80,7 @@ Double_t rnlin(Double_t *x, Double_t * /*par*/)
   //a = par[0], b = par[1].
   //1+a*exp(-e/b)
 
-// return 0.0241+1.0504*x[0]+0.000249*x[0]*x[0] ;
- return 1.015*(0.0241+1.0504*x[0]+0.000249*x[0]*x[0]) ;
-
+  return 0.0241+1.0504*x[0]+0.000249*x[0]*x[0] ;
 }
 
 //________________________________________________________________________
index b227dda21eb32f271e74560a389c301c804c3326..132ed6cf9efa193bca7b5aa3bfb50078c283eab3 100644 (file)
@@ -18,7 +18,7 @@
        //      Task for Heavy-flavour electron analysis in pPb collisions    //
        //      (+ Electron-Hadron Jetlike Azimuthal Correlation)             //
        //                                                                                                                                        //
-       //              version: November 21, 2013.                                                               //
+       //              version: January 28, 2014.                                                                    //
        //                                                                    //
        //          Authors                                                                               //
        //              Elienos Pereira de Oliveira Filho (epereira@cern.ch)          //
@@ -176,7 +176,11 @@ AliAnalysisTaskEMCalHFEpA::AliAnalysisTaskEMCalHFEpA(const char *name)
 ,fTPCnsigma_phi(0)
 ,fECluster(0)
 ,fEtaPhi(0)
+,fEtaPhi_num(0)
+,fEtaPhi_den(0)
 ,fVtxZ(0)
+,fEtad(0)
+
 ,fNTracks(0)
 ,fNClusters(0)
 ,fTPCNcls_EoverP(0)
@@ -249,6 +253,10 @@ AliAnalysisTaskEMCalHFEpA::AliAnalysisTaskEMCalHFEpA(const char *name)
 ,fAngleCutFlag(kFALSE)
 ,fChi2CutFlag(kFALSE)
 ,fDCAcutFlag(kFALSE)
+
+,fAssHadronPtMin(0.5)
+,fAssHadronPtMax(2.0)
+
 ,fPtBackgroundBeforeReco(0)
 ,fPtBackgroundBeforeReco2(0)
 ,fPtBackgroundBeforeReco_weight(0)
@@ -409,7 +417,11 @@ AliAnalysisTaskEMCalHFEpA::AliAnalysisTaskEMCalHFEpA()
 ,fTPCnsigma_phi(0)
 ,fECluster(0)
 ,fEtaPhi(0)
+,fEtaPhi_num(0)
+,fEtaPhi_den(0)
 ,fVtxZ(0)
+,fEtad(0)
+
 ,fNTracks(0)
 ,fNClusters(0)
 ,fTPCNcls_EoverP(0)
@@ -481,6 +493,10 @@ AliAnalysisTaskEMCalHFEpA::AliAnalysisTaskEMCalHFEpA()
 ,fAngleCutFlag(kFALSE)
 ,fChi2CutFlag(kFALSE)
 ,fDCAcutFlag(kFALSE)
+
+,fAssHadronPtMin(0.5)
+,fAssHadronPtMax(2.0)
+
 ,fPtBackgroundBeforeReco(0)
 ,fPtBackgroundBeforeReco2(0)
 ,fPtBackgroundBeforeReco_weight(0)
@@ -619,7 +635,7 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
        
                //Store the number of events
                //Define the histo
-       fNevent = new TH1F("fNevent","Number of Events",5,-0.5,4.5);
+       fNevent = new TH1F("fNevent","Number of Events",10,-0.5,10);
                //And then, add to the output list
        fOutputList->Add(fNevent);
        
@@ -651,7 +667,8 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
        fPtTrigger_Inc = new TH1F("fPtTrigger_Inc","pT dist for Hadron Contamination; p_{t} (GeV/c); Count",300,0,30);
        fTPCnsigma_pt_2D = new TH2F("fTPCnsigma_pt_2D",";pt (GeV/c);TPC Electron N#sigma",1000,0.3,30,1000,-15,10);
        fShowerShapeCut = new TH2F("fShowerShapeCut","Shower Shape;M02;M20",500,0,1.8,500,0,1.8);
-       
+       fEtaPhi_num=new TH2F("fEtaPhi_num","#eta x #phi track;#phi;#eta",200,0.,5,50,-1.,1.);
+       fEtaPhi_den=new TH2F("fEtaPhi_den","#eta x #phi track;#phi;#eta",200,0.,5,50,-1.,1.);
        
        
        fCharge_n = new TH1F("fCharge_n","Inclusive Electrons (Negative Charge); p_{t} (GeV/c); Count",200,0,30);
@@ -679,6 +696,9 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
        fOutputList->Add(fTOF02);
        fOutputList->Add(fTOF03);
        
+       fOutputList->Add(fEtaPhi_num);
+       fOutputList->Add(fEtaPhi_den);
+       
        fOutputList->Add(fPtElec_Inc);
        fOutputList->Add(fPtElec_ULS);
        fOutputList->Add(fPtElec_LS);
@@ -735,6 +755,7 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
        fECluster= new TH1F *[3];
        fEtaPhi= new TH2F *[3];
        fVtxZ= new  TH1F *[3];
+       fEtad= new  TH1F *[3];
        fNTracks= new  TH1F *[3];
        fNClusters= new TH1F *[3];
        fTPCNcls_EoverP= new TH2F *[3]; 
@@ -750,7 +771,8 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
                fECluster[i]= new TH1F(Form("fECluster%d",i), ";ECluster",2000, 0,100);
                fEtaPhi[i]= new TH2F(Form("fEtaPhi%d",i),"#eta x #phi Clusters;#phi;#eta",200,0.,5,50,-1.,1.);
                fVtxZ[i]= new  TH1F(Form("fVtxZ%d",i),"VtxZ",1000, -50,50);
-               fNTracks[i]= new  TH1F(Form("fNTracks%d",i),"NTracks",1000, 0,1000);
+               fEtad[i]= new  TH1F(Form("fEtad%d",i),"Eta distribution",200, -1.2,1.2);
+               fNTracks[i]= new  TH1F(Form("fNTracks%d",i),"NTracks",1000, 0,5000);
                fNClusters[i]= new TH1F(Form("fNClusters%d",i),"fNClusters0",200, 0,100);
                fTPCNcls_EoverP[i]= new TH2F(Form("fTPCNcls_EoverP%d",i),"TPCNcls_EoverP",1000,0,200,200,0,2);  
                        
@@ -764,6 +786,7 @@ void AliAnalysisTaskEMCalHFEpA::UserCreateOutputObjects()
                fOutputList->Add(fECluster[i]);
                fOutputList->Add(fEtaPhi[i]);
                fOutputList->Add(fVtxZ[i]);
+               fOutputList->Add(fEtad[i]);
                fOutputList->Add(fNTracks[i]);
                fOutputList->Add(fNClusters[i]);
                fOutputList->Add(fTPCNcls_EoverP[i]);
@@ -1220,7 +1243,7 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                
                
                
-                       /// ESD
+               /// ESD
                const AliESDVertex* trkVtx = fESD->GetPrimaryVertex();
                if(!trkVtx || trkVtx->GetNContributors()<=0) return;
                TString vtxTtl = trkVtx->GetTitle();
@@ -1242,6 +1265,9 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
        
                //Only events with at least 2 tracks are accepted
        Int_t fNOtrks =  fVevent->GetNumberOfTracks();
+       
+               //if(fIsAOD) Int_t fNOtrks =  fAOD->GetNumberOfTracks();
+               //if(!fIsAOD) Int_t fNOtrks =  fESD->GetNumberOfTracks();
        if(fNOtrks<2) return;
        
                //______________________________________________________________________
@@ -1333,9 +1359,14 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                        fPtMCparticleAll->Fill(fMCparticle->Pt());
                                                        
                                                        Bool_t MotherFound = FindMother(iMC);
+                                                       //Bool_t MotherFound = FindMother(track->GetLabel());
                                                        if(MotherFound)
                                                        {
-                                                               if(fIsHFE1) fPtMCparticleAllHfe1->Fill(fMCparticle->Pt()); //denominator for total efficiency
+                                                               if(fIsHFE1){
+                                                                       fPtMCparticleAllHfe1->Fill(fMCparticle->Pt());
+                                                                       fEtaPhi_den->Fill(fMCparticle->Phi(),fMCparticle->Eta());
+                                                               
+                                                               } //denominator for total efficiency and tracking
                                                                if(fIsHFE2) fPtMCparticleAllHfe2->Fill(fMCparticle->Pt());
                                                        }
                                                }
@@ -1385,39 +1416,49 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                if(TMath::Abs(mpdg) == 221 || TMath::Abs(mpdg) == 22 || TMath::Abs(mpdg) == 111){
                                                                Double_t proR=particle->R();
                                                                if(proR<7){
-                                                               fPtMCparticleAlle_nonPrimary->Fill(fMCtrack->Pt()); //denominator for total efficiency for all electrons, and not primary
+                                                                       fPtMCparticleAlle_nonPrimary->Fill(fMCtrack->Pt()); //denominator for total efficiency for all electrons, and not primary
                                                                }
                                                }
                                        }
                                        
-                                       if (TMath::Abs(pdg) == 11 && fMCstack->IsPhysicalPrimary(iMC))  fPtMCparticleAlle_Primary->Fill(fMCtrack->Pt());
-
+                                       if(TMath::Abs(pdg) == 11 && fMCstack->IsPhysicalPrimary(iMC)){
+                                               
+                                               fPtMCparticleAlle_Primary->Fill(fMCtrack->Pt());
+                                       }
                                        
                                        if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 )
                                        {
                                                fPtMCparticleAll_nonPrimary->Fill(fMCtrack->Pt());//denominator for total efficiency for all particle, non Primary track
                                                
-                                               if(!fMCstack->IsPhysicalPrimary(iMC)) continue;
-                                               fPtMCparticleAll->Fill(fMCtrack->Pt());
-                                               
-                                               Bool_t MotherFound = FindMother(iMC);
-                                               if(MotherFound)
+                                               if(fMCstack->IsPhysicalPrimary(iMC))
                                                {
-                                                       if(fIsHFE1) fPtMCparticleAllHfe1->Fill(fMCtrack->Pt());//denominator for total efficiency
-                                                       if(fIsHFE2) fPtMCparticleAllHfe2->Fill(fMCtrack->Pt());
-                                               }
+                                                       fPtMCparticleAll->Fill(fMCtrack->Pt());
+                                               
+                                                       Bool_t MotherFound = FindMother(iMC);
+                                                       //Bool_t MotherFound = FindMother(track->GetLabel());
+                                                       if(MotherFound)
+                                                       {
+                                                               if(fIsHFE1){
+                                                                       fPtMCparticleAllHfe1->Fill(fMCtrack->Pt());//denominator for total efficiency and tracking
+                                                                       fEtaPhi_den->Fill(fMCtrack->Phi(),fMCtrack->Eta());
+                                                               }
+                                                               if(fIsHFE2) fPtMCparticleAllHfe2->Fill(fMCtrack->Pt());
+                                                       }
+                                               }//Is Physical primary
                                        }       
-                               }//particle kind
+                               }//eta cut
                }//loop tracks
                }//ESD
        }//Is MC
        
-               //______________________________________________________________________
-               //EMCal Trigger Selection (Threshould selection)
+       //______________________________________________________________________
+       //EMCal Trigger Selection (Threshold selection)
        TString firedTrigger;
-       TString TriggerEG1("EG1");
-       TString TriggerEG2("EG2");
-       
+       TString TriggerEG1("CEMC7EG1"); //takes trigger with name with EG1, ex: CEMC7EG1-B-NOPF-CENTNOTRD  
+       TString TriggerEG2("CEMC7EG2");
+       //Jan 17, 2014
+       TString TriggerEJE("EJE");
+               
        if(fAOD) firedTrigger = fAOD->GetFiredTriggerClasses();
        else if(fESD) firedTrigger = fESD->GetFiredTriggerClasses();
        
@@ -1425,36 +1466,64 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
        if(firedTrigger.Contains(TriggerEG1)) fNevent->Fill(1);
        if(firedTrigger.Contains(TriggerEG2)) fNevent->Fill(2);
        
-               //EG1
+       // Jan 06, 2014: I changed the counters: Only fill with 3 or 4 if we want the trigger threshold selected.
+       //EG1
        if(firedTrigger.Contains(TriggerEG1))
        { 
-               fNevent->Fill(3);
+               if(fEMCEG1) fNevent->Fill(3);
        }
        else 
        {
                if(fEMCEG1) return;
        }
        
-               //EG2
+       //EG2
        if(firedTrigger.Contains(TriggerEG2))
        { 
-               fNevent->Fill(4);
+               if(fEMCEG2) fNevent->Fill(4);
        }
        else
        { 
                if(fEMCEG2) return;
        }
        
-               //______________________________________________________________________
+       //______________________________________________________________________
+       //Testing if there is an overlap EGA and EJE
+       //none
+       if(!(firedTrigger.Contains(TriggerEG1) && firedTrigger.Contains(TriggerEG2) ) && !firedTrigger.Contains(TriggerEJE))
+       { 
+               fNevent->Fill(6);
+       }
+       //only GA
+       if((firedTrigger.Contains(TriggerEG1) || firedTrigger.Contains(TriggerEG2)) && !firedTrigger.Contains(TriggerEJE))
+       { 
+               fNevent->Fill(7);
+       }
+       //only JE
+       if(!(firedTrigger.Contains(TriggerEG1) && firedTrigger.Contains(TriggerEG2)) && firedTrigger.Contains(TriggerEJE))
+       { 
+               fNevent->Fill(8);
+       }
+       //both
+       if((firedTrigger.Contains(TriggerEG1) || firedTrigger.Contains(TriggerEG2)) && firedTrigger.Contains(TriggerEJE))
+       { 
+               fNevent->Fill(9);
+       }
+       
+       
+       
+       
+       
+       //__________________________________________________________________
        
        Int_t ClsNo = -999;
        if(!fIsAOD) ClsNo = fESD->GetNumberOfCaloClusters(); 
        else ClsNo = fAOD->GetNumberOfCaloClusters(); 
        
-               //______________________________________________________________________
+       //______________________________________________________________________
        
-               ///______________________________________________________________________
-               ///Track loop
+       ///_____________________________________________________________________
+       ///Track loop
        for(Int_t iTracks = 0; iTracks < fVevent->GetNumberOfTracks(); iTracks++) 
        {
                AliVParticle* Vtrack = fVevent->GetTrack(iTracks);
@@ -1477,8 +1546,13 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                Double_t fPt = -999;
                Double_t fP = -999;
                
-                       ///_____________________________________________________________________________
-                       ///Fill QA plots without track selection
+               //December 9th 2013
+               //Etacut test on the begging
+               fEtad[0]->Fill(track->Eta());
+                       //if(track->Eta()<fEtaCutMin || track->Eta()>fEtaCutMax) continue;
+               fEtad[1]->Fill(track->Eta());
+               ///_____________________________________________________________________________
+               ///Fill QA plots without track selection
                fPt = track->Pt();
                fP = TMath::Sqrt((track->Pt())*(track->Pt()) + (track->Pz())*(track->Pz()));
                
@@ -1614,56 +1688,59 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                        else fPtMCWithoutLabel->Fill(fPt);
                }
                
-               if(fIsMC && fIsAOD && track->GetLabel()>=0)
+               if(fIsMC  && track->GetLabel()>=0)
                {
-                       fMCparticle = (AliAODMCParticle*) fMCarray->At(track->GetLabel());
+                       if(fIsAOD){
+                               fMCparticle = (AliAODMCParticle*) fMCarray->At(track->GetLabel());
                        
-                       if(fMCparticle->IsPhysicalPrimary()) fPtIsPhysicaPrimary->Fill(fPt);
                        
-                       Int_t pdg = fMCparticle->GetPdgCode();
-                       if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax && fMCparticle->Charge()!=0)
-                       {
+                               if(fMCparticle->IsPhysicalPrimary()) fPtIsPhysicaPrimary->Fill(fPt);
+                       
+                               Int_t pdg = fMCparticle->GetPdgCode();
+                               if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax && fMCparticle->Charge()!=0)
+                               {
                                
                                                                
-                               if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 ) 
-                               {       
-                                       fPtMCparticleReco_nonPrimary->Fill(fMCparticle->Pt()); //not Primary track
+                                       if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 ) 
+                                       {       
+                                               fPtMCparticleReco_nonPrimary->Fill(fMCparticle->Pt()); //not Primary track
                                        
-                                       if(fMCparticle->IsPhysicalPrimary()) 
-                                       {
-                                               fPtMCparticleReco->Fill(fMCparticle->Pt());
-                                               
-                                               Bool_t MotherFound = FindMother(track->GetLabel());
-                                               if(MotherFound)
+                                               if(fMCparticle->IsPhysicalPrimary()) 
                                                {
-                                                       if(fIsHFE1) fPtMCparticleRecoHfe1->Fill(fMCparticle->Pt());
-                                                       if(fIsHFE2) fPtMCparticleRecoHfe2->Fill(fMCparticle->Pt());
+                                                       fPtMCparticleReco->Fill(fMCparticle->Pt());
+                                               
+                                                       Bool_t MotherFound = FindMother(track->GetLabel());
+                                                       if(MotherFound)
+                                                       {
+                                                               if(fIsHFE1) fPtMCparticleRecoHfe1->Fill(fMCparticle->Pt());//numerator tracking
+                                                               if(fIsHFE2) fPtMCparticleRecoHfe2->Fill(fMCparticle->Pt());
+                                                       }
                                                }
                                        }
                                }
-                       }
-               }
-               else if(fIsMC && track->GetLabel()>=0)
-               {       
-                       if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax)
-                       {
+                       }//close AOD
+                        //ESD
+                       else 
+                       {       
+                       
+                                                       
+                               if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax)
+                               {
                                
-                               fMCtrack = fMCstack->Particle(track->GetLabel());
-                               Int_t pdg = fMCtrack->GetPdgCode();
+                                       fMCtrack = fMCstack->Particle(track->GetLabel());
+                                       Int_t pdg = fMCtrack->GetPdgCode();
                                
-                               if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 )
-                               {
-                                       fPtMCparticleReco_nonPrimary->Fill(fMCtrack->Pt());//not Primary track
-                               }
+                                       if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 )
+                                       {
+                                               fPtMCparticleReco_nonPrimary->Fill(fMCtrack->Pt());//not Primary track
+                                       }
                                
                                
-                               if(fMCstack->IsPhysicalPrimary(track->GetLabel()))
-                               {
+                                       if(fMCstack->IsPhysicalPrimary(track->GetLabel()))
+                                       {
                                                fPtIsPhysicaPrimary->Fill(fPt);
                                
                                
-                                               
-                               
                                                if( TMath::Abs(pdg) == 211 || TMath::Abs(pdg) == 2212 || TMath::Abs(pdg) == 321 || TMath::Abs(pdg) == 11 || TMath::Abs(pdg) == 13 )
                                                {
                                                        fPtMCparticleReco->Fill(fMCtrack->Pt());
@@ -1671,13 +1748,14 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                        Bool_t MotherFound = FindMother(track->GetLabel());
                                                        if(MotherFound)
                                                        {
-                                                               if(fIsHFE1) fPtMCparticleRecoHfe1->Fill(fMCtrack->Pt());
+                                                               if(fIsHFE1) fPtMCparticleRecoHfe1->Fill(fMCtrack->Pt());//numerator tracking
                                                                if(fIsHFE2) fPtMCparticleRecoHfe2->Fill(fMCtrack->Pt());
                                                        }
                                                }
+                                       }
                                }
-                       }
-               }
+                       }//close ESD
+               }//close IsMC
                
                fTPC_p[1]->Fill(fPt,fTPCsignal);
                fTPCnsigma_p[1]->Fill(fP,fTPCnSigma);
@@ -1712,7 +1790,7 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                        fTPCNcls_EoverP[1]->Fill(TPCNcls, EoverP);
                                        
                                        
-                                               //for EMCal trigger performance
+                                       //for EMCal trigger performance
                                        if(EoverP > 0.9){
                                                ftpc_p_EoverPcut->Fill(track->P(), fTPCsignal);
                                                fnsigma_p_EoverPcut->Fill(track->P(), fTPCnSigma);
@@ -1788,18 +1866,19 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                        }
                }
                
-                       //______________________________________________________________
-                       // Vertex
+               //______________________________________________________________
+               // Vertex
                
                fVtxZ[1]->Fill(fZvtx);
                fNTracks[1]->Fill(fNOtrks);
                fNClusters[1]->Fill(ClsNo);
                fTPCNcls_pid[1]->Fill(TPCNcls, TPCNcls_pid);
-                       //______________________________________________________________
                
-                       ///______________________________________________________________________
-                       ///Histograms for PID Studies
-                       //Double_t fPtBin[6] = {2,4,6,8,10,15};
+               //______________________________________________________________
+               
+               ///______________________________________________________________________
+               ///Histograms for PID Studies
+               //Double_t fPtBin[6] = {2,4,6,8,10,15};
                
                for(Int_t i = 0; i < 6; i++)
                {
@@ -1867,9 +1946,12 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                        
                                        if(fMCtrack->GetFirstMother()>0){
                                            fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
-                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
-                                                       if(fIsHFE1) fPtMC_TPC_All->Fill(fMCtrack->Pt());        
-                                       }
+                                               Bool_t MotherFound = FindMother(track->GetLabel());
+                                               if(MotherFound){
+                                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
+                                                               if(fIsHFE1) fPtMC_TPC_All->Fill(fMCtrack->Pt());        
+                                                       }
+                                               }
                                        }
                                }
                        }
@@ -1880,9 +1962,9 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                        if(fPt>2 && fPt<4) fTOF02->Fill(fTOFnSigma,fTPCnSigma);
                        if(fPt>4 && fPt<6) fTOF03->Fill(fTOFnSigma,fTPCnSigma);
                
-                       ///________________________________________________________________________
-                       ///PID
-                       ///Here the PID cuts defined in the file "ConfigEMCalHFEpA.C" is applied
+               ///________________________________________________________________________
+               ///PID
+               ///Here the PID cuts defined in the file "ConfigEMCalHFEpA.C" is applied
            Int_t pidpassed = 1;
            AliHFEpidObject hfetrack;
            hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
@@ -1895,10 +1977,10 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                        ///________________________________________________________________________             
                
                
-                       ////////////////////////////////////////////////////////////////////
-                       ///TPC efficiency calculations 
+               ////////////////////////////////////////////////////////////////////
+               ///TPC efficiency calculations 
                
-                       /// changing start here
+                       
                if(fIsMC && fIsAOD && track->GetLabel()>=0)
                {
                        fMCparticle = (AliAODMCParticle*) fMCarray->At(track->GetLabel());
@@ -1932,9 +2014,12 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                        
                                        if(fMCtrack->GetFirstMother()>0){
                                            fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
-                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
-                                                       if(fIsHFE1) fPtMC_TPC_Selected->Fill(fMCtrack->Pt());   
-                                       }
+                                               Bool_t MotherFound = FindMother(track->GetLabel());
+                                               if(MotherFound){
+                                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
+                                                               if(fIsHFE1) fPtMC_TPC_Selected->Fill(fMCtrack->Pt());   
+                                                       }
+                                               }
                                        }
                                }
                        }
@@ -1947,7 +2032,11 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                
                        //Background for TPC only
                if(fFillBackground){
-                       Background(track, iTracks, Vtrack, kTRUE); //IsTPConly=kTRUE
+                       
+                       //efficiency without SS cut for TPC only
+                       if(track->Eta()>=fEtaCutMin && track->Eta()<=fEtaCutMax){
+                               Background(track, iTracks, Vtrack, kTRUE); //IsTPConly=kTRUE
+                       } //Eta cut to be consistent with other efficiency
                }
                
                
@@ -1962,52 +2051,79 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                        if(fClus->IsEMCAL())
                        {
                                
-                                       //________________________________________________________________________              
+               //________________________________________________________________________              
                                
                                
-                                       //Cluster timing distribution
-                               if(fUseEMCal && !fIsAOD ){
-                                       AliESDCaloCells &cells=*(fESD->GetEMCALCells());
-                                               //      Int_t nTotalCells = cells.GetNumberOfCells() ;  
-                                               //Int_t type        = cells.GetType();
-                                               //for (Int_t icell=  0; icell <  nTotalCells; icell++) {
-                                               //fTime->Fill(cells.GetTime(icell));
-                                               //}
+                               //Cluster timing distribution -- for ESD 
+                               if(fUseEMCal && !fIsAOD){
+                                               
+                                       AliESDCaloCells &cells_esd=*(fESD->GetEMCALCells());
+                                       TRefArray* caloClusters_esd = new TRefArray();
+                                   fESD->GetEMCALClusters(caloClusters_esd);
+                                       Int_t nclus_esd = caloClusters_esd->GetEntries();
+                                       
+                               
+                                       for (Int_t icl = 0; icl < nclus_esd; icl++) {
+                                                                                               
+                                               AliESDCaloCluster* clus_esd = (AliESDCaloCluster*)caloClusters_esd->At(icl);
+                                               
+                                               if(clus_esd->IsEMCAL()){
+                                                       Float_t ncells_esd      = fClus->GetNCells();
+                                                       UShort_t * index_esd = clus_esd->GetCellsAbsId() ;
+                                                       UShort_t * index2_esd = fClus->GetCellsAbsId() ;
+                                                       
+                                                       
+                                                       for(Int_t i = 0; i < ncells_esd ; i++){
+                                                               
+                                                               Int_t absId_esd =   index_esd[i];
+                                                               fTime->Fill(fPt,cells_esd.GetCellTime(absId_esd));
+                                                               
+                                                               Int_t absId2_esd =   index2_esd[i];
+                                                               fTime2->Fill(fPt,cells_esd.GetCellTime(absId2_esd));
+                                                       }
+                                                       
+                                               }
+                                       }
+                                       
+                               }
+                               /* not working!
+                               //Cluster timing distribution -- for AOD 
+                               if(fUseEMCal && fIsAOD){
                                        
-                                       TRefArray* caloClusters = new TRefArray();
-                                       fESD->GetEMCALClusters(caloClusters);
+                                       AliAODCaloCells &cells_aod=*(fAOD->GetEMCALCells());
                                        
-                                       Int_t nclus = caloClusters->GetEntries();
+                                       TRefArray* caloClusters_aod = new TRefArray();
+                                       fAOD->GetEMCALClusters(caloClusters_aod);
                                        
-                                               //fClusESD = fESD->GetCaloCluster(track->GetEMCALcluster());
+                                       Int_t nclus_aod = caloClusters_aod->GetEntries();
                                        
-                                       for (Int_t icl = 0; icl < nclus; icl++) {
+                                       for (Int_t icl = 0; icl < nclus_aod; icl++) {
+                                                                                               
+                                               AliAODCaloCluster* clus_aod = (AliAODCaloCluster*)caloClusters_aod->At(icl);
                                                
-                                               AliESDCaloCluster* clus = (AliESDCaloCluster*)caloClusters->At(icl);
                                                
-                                               if(fClus->IsEMCAL()){
-                                                       Float_t ncells  = fClus->GetNCells();
-                                                       UShort_t * index = clus->GetCellsAbsId() ;
-                                                       UShort_t * index2 = fClus->GetCellsAbsId() ;
+                                               if(clus_aod->IsEMCAL()){
+                                                       Float_t ncells_aod      = fClus->GetNCells();
+                                                       UShort_t * index_aod = clus_aod->GetCellsAbsId() ;
+                                                       UShort_t * index2_aod = fClus->GetCellsAbsId() ;
                                                        
                                                        
-                                                       for(Int_t i = 0; i < ncells ; i++){
+                                                       for(Int_t i = 0; i < ncells_aod ; i++){
                                                                
-                                                               Int_t absId =   index[i];
-                                                               fTime->Fill(fPt,cells.GetCellTime(absId));
+                                                               Int_t absId_aod =   index_aod[i];
+                                                               fTime->Fill(fPt,cells_aod.GetCellTime(absId_aod));
                                                                
-                                                               Int_t absId2 =   index2[i];
-                                                               fTime2->Fill(fPt,cells.GetCellTime(absId2));
+                                                               Int_t absId2_aod =   index2_aod[i];
+                                                               fTime2->Fill(fPt,cells_aod.GetCellTime(absId2_aod));
                                                        }
                                                        
                                                }
                                        }
                                        
-                                       
-                                       
-                                       
                                }
-                               
+                                */
+                                       
+                                                                       
                                if(fUseEMCal){
                                        double emctof = fClus->GetTOF();
                                        ftimingEle->Fill(fPt,emctof);
@@ -2017,10 +2133,11 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                
                                
                                
-                                       /////////////// Residuals
+                               // Residuals
                                Double_t Dx = fClus->GetTrackDx();
                                Double_t Dz = fClus->GetTrackDz();
                                Double_t R=TMath::Sqrt(Dx*Dx+Dz*Dz);
+                               
                                for(Int_t i = 0; i < 6; i++)
                                {
                                        if(fPt>=fPtBin[i] && fPt<fPtBin[i+1])
@@ -2039,9 +2156,10 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                        Float_t M02     = fClus->GetM02();
                                        Float_t M20     = fClus->GetM20();
                                        Float_t ncells  = fClus->GetNCells();
-                                               //----------------------------------------------------------------------------------------
-                                               // EtaCut electrons histogram
-                                               //Shower Shape Cut
+                                       //----------------------------------------------------------------------------------------
+                                       
+                                       // EtaCut electrons histogram
+                                       //Shower Shape Cut
                                        if(track->Eta()>=fEtaCutMin && track->Eta()<=fEtaCutMax ){
                                                
                                                if(fUseShowerShapeCut){
@@ -2067,11 +2185,11 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                
                                        }
                                        
-                                               //----------------------------------------------------------------------------------------
+                                       //----------------------------------------------------------------------------------------
                                        
                                        
                                        
-                                               /////////////// for Eta Phi distribution
+                                       // for Eta Phi distribution
                                        fClus->GetPosition(pos3);
                                        TVector3 vpos(pos3[0],pos3[1],pos3[2]);
                                        Double_t cphi = vpos.Phi();
@@ -2108,31 +2226,31 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                        fNcells_pt->Fill(fPt, ncells);
                                        
                                        
-                                               ////////////////////////////////////////////////////////////////////
-                                               ///EMCal - Efficiency calculations 
+                                       ////////////////////////////////////////////////////////////////////
+                                       ///EMCal - Efficiency calculations 
                                        
-                                               /// changing start here
+                                               
                                        if(fIsMC && fIsAOD && track->GetLabel()>=0)
                                        {
                                                fMCparticle = (AliAODMCParticle*) fMCarray->At(track->GetLabel());
                                                Int_t pdg = fMCparticle->GetPdgCode();
                                                
-                                                       //
+                                               //
                                                if(fMCparticle->IsPhysicalPrimary()){
                                                        
-                                                       
-                                                       if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax ){
+                                                       //Phi cut && fMCparticle->Phi()>=(TMath::Pi()*80/180) && fMCparticle->Phi()<=TMath::Pi()
+                                                       if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax  ){
                                                                
                                                                Bool_t MotherFound = FindMother(track->GetLabel());
                                                                if(MotherFound){
                                                                        fMCparticleMother = (AliAODMCParticle*) fMCarray->At(fMCparticle->GetMother());
                                                                        if( TMath::Abs(pdg) == 11 && fMCparticleMother->GetPdgCode()!=22 ){
-                                                                               fPtMC_EMCal_All->Fill(fMCparticle->Pt());       
+                                                                               if(fIsHFE1)fPtMC_EMCal_All->Fill(fMCparticle->Pt());    
                                                                        }
                                                                }
                                                        }
                                                }
-                                       }///until here
+                                       }
                                        
                                        else if(fIsMC && track->GetLabel()>=0)//ESD
                                        {
@@ -2143,13 +2261,17 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                        fMCtrack = fMCstack->Particle(track->GetLabel());
                                                        
                                                        Int_t pdg = fMCtrack->GetPdgCode();
-                                                       if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax && fMCtrack->Phi()>=(TMath::Pi()*80/180) && fMCtrack->Phi()<=TMath::Pi())
+                                                       //Phi cut && fMCtrack->Phi()>=(TMath::Pi()*80/180) && fMCtrack->Phi()<=TMath::Pi()
+                                                       if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax )
                                                        {
-                                                               if(fMCtrack->GetFirstMother()>0){
-                                                                       fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
-                                                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
-                                                                               
-                                                                               fPtMC_EMCal_All->Fill(fMCtrack->Pt());  
+                                                               Bool_t MotherFound = FindMother(track->GetLabel());
+                                                                       //MotherFound included
+                                                               if(MotherFound){
+                                                                       if(fMCtrack->GetFirstMother()>0){
+                                                                               fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
+                                                                               if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
+                                                                                       if(fIsHFE1)fPtMC_EMCal_All->Fill(fMCtrack->Pt());       
+                                                                               }
                                                                        }
                                                                }
                                                        }
@@ -2163,21 +2285,33 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                
                                            fECluster[2]->Fill(Energy);
                                                fTPCNcls_pid[3]->Fill(TPCNcls, TPCNcls_pid);
-                                               //_______________________________________________________
-                                               //Correlation Analysis
+                                               
                                                if(fUseEMCal)
                                                {
                                                        fPtElec_Inc->Fill(fPt);
                                                        //Eta cut for background
                                                        if(fFillBackground){
-                                                               if(track->Eta()>=fEtaCutMin && track->Eta()<=fEtaCutMax){
-                                                                       Background(track, iTracks, Vtrack, kFALSE);
+                                                               fEtad[2]->Fill(track->Eta());
+                                                               
+                                                               //background for triggered data: trigger electron must have same cuts on shower shape  06/Jan/2014
+                                                               if(fUseShowerShapeCut){
+                                                                       if(M02 >= fM02CutMin && M02<=fM02CutMax && M20>=fM20CutMin && M20<=fM20CutMax){
+                                                                               if(track->Eta()>=fEtaCutMin && track->Eta()<=fEtaCutMax){
+                                                                                       Background(track, iTracks, Vtrack, kFALSE);
+                                                                               }
+                                                                       }
+                                                               }
+                                                               else{
+                                                                       if(track->Eta()>=fEtaCutMin && track->Eta()<=fEtaCutMax){
+                                                                               Background(track, iTracks, Vtrack, kFALSE);
+                                                                       }
                                                                }
+                                                               
                                                        }
                                                        
                                                        double emctof2 = fClus->GetTOF();
                                                        ftimingEle2->Fill(fPt,emctof2);
-                                                       
+                                                       //Correlation Analysis
                                                        if(fCorrelationFlag) 
                                                        {
                                                                ElectronHadronCorrelation(track, iTracks, Vtrack);
@@ -2207,7 +2341,7 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                        double proR = sqrt(pow(proX,2)+pow(proY,2));
                                                        
                                                        
-                                                       if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax ){
+                                                       if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax && fMCparticle->Phi()>=(TMath::Pi()*80/180) && fMCparticle->Phi()<=TMath::Pi()  ){
                                                                        
                                                                if( TMath::Abs(pdg) == 11 && fMCparticle->GetMother()>0 ){
                                                                        Int_t mpdg = fMCparticleMother->GetPdgCode();
@@ -2225,26 +2359,35 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                                
                                                                if(fMCparticle->Eta()>=fEtaCutMin && fMCparticle->Eta()<=fEtaCutMax ){
                                                                                
-                                                                       if(!fUseShowerShapeCut){
-                                                                               if(fIsHFE1) fPtMCelectronAfterAll->Fill(fMCparticle->Pt()); //numerator for the total efficiency AOD
-                                                                       }
-                                                                       //November 11 for efficiency of triggered data
-                                                                       if(fUseShowerShapeCut){
-                                                                               if(M02 >= fM02CutMin && M02<=fM02CutMax && M20>=fM20CutMin && M20<=fM20CutMax){
-                                                                                       if(fIsHFE1) fPtMCelectronAfterAll->Fill(fMCparticle->Pt()); //numerator for the total efficiency AOD
-                                                                               }
-                                                                       }
-                                                                       
                                                                        Bool_t MotherFound = FindMother(track->GetLabel());
                                                                        if(MotherFound){
-                                                                               fMCparticleMother = (AliAODMCParticle*) fMCarray->At(fMCparticle->GetMother());
-                                                                               if( TMath::Abs(pdg) == 11 && fMCparticleMother->GetPdgCode()!=22 ){
-                                                                                       fPtMC_EMCal_Selected->Fill(fMCparticle->Pt());  
+                                                                               
+                                                                               if(!fUseShowerShapeCut){
+                                                                                       if(fIsHFE1){ 
+                                                                                               fPtMCelectronAfterAll->Fill(fMCparticle->Pt());
+                                                                                               fEtaPhi_num->Fill(fMCparticle->Phi(),fMCparticle->Eta());
+                                                                                       }//numerator for the total efficiency AOD
                                                                                }
-                                                                       }
-                                                               }
+                                                                                       //November 11 for efficiency of triggered data
+                                                                               if(fUseShowerShapeCut){
+                                                                                       if(M02 >= fM02CutMin && M02<=fM02CutMax && M20>=fM20CutMin && M20<=fM20CutMax){
+                                                                                               if(fIsHFE1){ 
+                                                                                                       fPtMCelectronAfterAll->Fill(fMCparticle->Pt());
+                                                                                                       fEtaPhi_num->Fill(fMCparticle->Phi(),fMCparticle->Eta());
+                                                                                               }//numerator for the total efficiency AOD
+                                                                                       }
+                                                                               }
+                                                                       
+                                                                       
+                                                                       
+                                                                                       fMCparticleMother = (AliAODMCParticle*) fMCarray->At(fMCparticle->GetMother());
+                                                                                       if( TMath::Abs(pdg) == 11 && fMCparticleMother->GetPdgCode()!=22 ){
+                                                                                               if(fIsHFE1)fPtMC_EMCal_Selected->Fill(fMCparticle->Pt());       
+                                                                                       }
+                                                                       }//if MotherFound
+                                                               }//eta cut
                                                        }
-                                               }///until here
+                                               }///close AOD
                                                
                                                else if(fIsMC && track->GetLabel()>=0)//ESD
                                                {
@@ -2281,12 +2424,18 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                                                
                                                                                
                                                                                if(!fUseShowerShapeCut){
-                                                                                       if(fIsHFE1) fPtMCelectronAfterAll->Fill(fMCtrack->Pt()); //numerator for the total efficiency ESD
+                                                                                       if(fIsHFE1){
+                                                                                               fPtMCelectronAfterAll->Fill(fMCtrack->Pt()); //numerator for the total efficiency ESD
+                                                                                               fEtaPhi_num->Fill(fMCtrack->Phi(),fMCtrack->Eta());
+                                                                                       }
                                                                                }
                                                                                //November 11 for efficiency of triggered data
                                                                                if(fUseShowerShapeCut){
                                                                                        if(M02 >= fM02CutMin && M02<=fM02CutMax && M20>=fM20CutMin && M20<=fM20CutMax){
-                                                                                               if(fIsHFE1) fPtMCelectronAfterAll->Fill(fMCtrack->Pt()); //numerator for the total efficiency ESD
+                                                                                               if(fIsHFE1){
+                                                                                                       fPtMCelectronAfterAll->Fill(fMCtrack->Pt()); //numerator for the total efficiency ESD
+                                                                                                       fEtaPhi_num->Fill(fMCtrack->Phi(),fMCtrack->Eta());
+                                                                                               }
                                                                                        }
                                                                                }
                                                                                
@@ -2297,20 +2446,25 @@ void AliAnalysisTaskEMCalHFEpA::UserExec(Option_t *)
                                                                
                                                                
                                                                
-                                                               
-                                                               if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax && fMCtrack->Phi()>=(TMath::Pi()*80/180) && fMCtrack->Phi()<=TMath::Pi())
+                                                               // Phi cut && fMCtrack->Phi()>=(TMath::Pi()*80/180) && fMCtrack->Phi()<=TMath::Pi()
+                                                               if(fMCtrack->Eta()>=fEtaCutMin && fMCtrack->Eta()<=fEtaCutMax)
                                                                {
-                                                                       if(fMCtrack->GetFirstMother()>0){
-                                                                               fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
-                                                                               if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
+                                                                       //included MotherFound
+                                                                       
+                                                                       if(MotherFound)
+                                                                       {
+                                                                               if(fMCtrack->GetFirstMother()>0){
+                                                                                       fMCtrackMother = fMCstack->Particle(fMCtrack->GetFirstMother());
+                                                                                       if( TMath::Abs(pdg) == 11 && fMCtrackMother->GetPdgCode()!=22 ){
                                                                                        
-                                                                                       fPtMC_EMCal_Selected->Fill(fMCtrack->Pt());     
+                                                                                               if(fIsHFE1)fPtMC_EMCal_Selected->Fill(fMCtrack->Pt());  
+                                                                                       }
                                                                                }
                                                                        }
                                                                }
                                                        }
-                                               }
-                                                       ///////////////////////////////////////////////////////////////////
+                                               }//close ESD
+                                               ///////////////////////////////////////////////////////////////////
                                                
                                                
                                        }
@@ -2924,7 +3078,7 @@ void AliAnalysisTaskEMCalHFEpA::ElectronHadronCorrelation(AliVTrack *track, Int_
                                        fEtaH = MixedTrack->Eta();
                                        fPtH = MixedTrack->Pt();
                                        
-                                       if(fPtH<0.5 || fPtH>2.0) continue;
+                                       if(fPtH<fAssHadronPtMin || fPtH>fAssHadronPtMax) continue;
                                        
                                        fDphi = fPhiE - fPhiH;
                                        
@@ -2972,6 +3126,8 @@ void AliAnalysisTaskEMCalHFEpA::ElectronHadronCorrelation(AliVTrack *track, Int_
                
                AliVTrack *track2 = dynamic_cast<AliVTrack*>(Vtrack2);
                
+               if(track2->Eta()<fEtaCutMin || track2->Eta()>fEtaCutMax ) continue;
+               
                if(fIsAOD) 
                {
                        AliAODTrack *atrack2 = dynamic_cast<AliAODTrack*>(Vtrack2);
@@ -2990,7 +3146,7 @@ void AliAnalysisTaskEMCalHFEpA::ElectronHadronCorrelation(AliVTrack *track, Int_
                fEtaH = track2->Eta();
                fPtH = track2->Pt();
                
-               if(fPtH<0.5 || fPtH>2.0) continue;
+               if(fPtH<fAssHadronPtMin || fPtH>fAssHadronPtMax) continue;
                
                fDphi = fPhiE - fPhiH;
                
@@ -3051,6 +3207,8 @@ TObjArray* AliAnalysisTaskEMCalHFEpA::SelectedHadrons()
                
                AliVTrack *track2 = dynamic_cast<AliVTrack*>(Vtrack2);
                
+               if(track2->Eta()<fEtaCutMin || track2->Eta()>fEtaCutMax ) continue;
+               
                if(fIsAOD) 
                {
                        AliAODTrack *atrack2 = dynamic_cast<AliAODTrack*>(Vtrack2);
@@ -3118,6 +3276,7 @@ void AliAnalysisTaskEMCalHFEpA::DiHadronCorrelation(AliVTrack *track, Int_t trac
                }
                
                AliVTrack *track2 = dynamic_cast<AliVTrack*>(Vtrack2);
+               if(track2->Eta()<fEtaCutMin || track2->Eta()>fEtaCutMax ) continue;
                
                if(fIsAOD) 
                {
@@ -3137,7 +3296,7 @@ void AliAnalysisTaskEMCalHFEpA::DiHadronCorrelation(AliVTrack *track, Int_t trac
                fEtaH = track2->Eta();
                fPtH = track2->Pt();
                
-               if(fPtH<0.5 || fPtH>2.0) continue;
+               if(fPtH<fAssHadronPtMin || fPtH>fAssHadronPtMax) continue;
                
                fDphi = fPhiE - fPhiH;
                
index f92f46a7a0889c3cc01d17cc2e68c0d96f9884ce..e59ab7944c143cb0dbdeaa6621e485f980fcf613 100644 (file)
@@ -9,7 +9,7 @@
        //      Task for Heavy-flavour electron analysis in pPb collisions    //
        //      (+ Electron-Hadron Jetlike Azimuthal Correlation)             //
        //                                                                                                                                        //
-       //              version: September 12th, 2013.                                                                                                            //
+       //              version: January 13, 2014.                                                                    //
        //                                                                    //
        //          Authors                                                                               //
        //              Elienos Pereira de Oliveira Filho (epereira@cern.ch)          //
@@ -58,6 +58,7 @@ public:
        virtual void   Terminate(Option_t *);
        
                //Setters
+       void SetAssHadronPtRange(Double_t AssHadronPtMin, Double_t AssHadronPtMax) {fAssHadronPtMin = AssHadronPtMin; fAssHadronPtMax = AssHadronPtMax; };
        void SetHFECuts(AliHFEcuts * const cuts) {fCuts = cuts;};
        void SetRejectKinkMother(Bool_t rejectKinkMother = kFALSE) {fRejectKinkMother = rejectKinkMother;};
        void SetCorrelationAnalysis(Bool_t CorrelationFlag=kTRUE) {fCorrelationFlag = CorrelationFlag;};
@@ -209,7 +210,10 @@ private:
        
        TH1F                            **fECluster;
        TH2F                            **fEtaPhi;
+       TH2F                            *fEtaPhi_num;
+       TH2F                            *fEtaPhi_den;
        TH1F                            **fVtxZ;
+       TH1F                            **fEtad;
        TH1F                            **fNTracks;
        TH1F                            **fNClusters;
        TH2F                            **fTPCNcls_EoverP;
@@ -289,6 +293,10 @@ private:
        Bool_t                          fChi2CutFlag;
        Bool_t                          fDCAcutFlag;
        
+       //Correlation Function
+       Double_t                        fAssHadronPtMin;
+       Double_t                        fAssHadronPtMax;
+       
                //Non-HFE reconstruction efficiency
        TH1F                            *fPtBackgroundBeforeReco;
        TH1F                            *fPtBackgroundBeforeReco2;
index aeafacde7438029f6d255bab3786bcb6a8583ab5..bb793b79f540ce13a5ed3b8fb6c5319e202c858b 100755 (executable)
@@ -80,55 +80,55 @@ private:
     Bool_t ProcessCutStep(Int_t cutStep, AliVParticle *track);
     
     Bool_t               fDebug; //! enable debug mode
-    AliAODEvent          *fAOD;                     //AOD object
-    TList                *fOutputList;          //output list
-    AliHFEcuts           *fCuts;                 //Cut Collection
-    Bool_t               fIdentifiedAsOutInz;    //Out Of Range in z
-    Bool_t               fPassTheEventCut;       //Pass The Event Cut
-    AliCFManager         *fCFM;                  //!Correction Framework Manager
-    AliHFEpid            *fPID;                  //PID
-    AliHFEpidQAmanager   *fPIDqa;             //! PID QA manager
+    AliAODEvent          *fAOD; //AOD object
+    TList                *fOutputList;//output list
+    AliHFEcuts           *fCuts; //Cut Collection
+    Bool_t               fIdentifiedAsOutInz;//Out Of Range in z
+    Bool_t               fPassTheEventCut;//Pass The Event Cut
+    AliCFManager         *fCFM;//!Correction Framework Manager
+    AliHFEpid            *fPID;//PID
+    AliHFEpidQAmanager   *fPIDqa; //! PID QA manager
     AliFlowTrackCuts     *fCutsRP; // track cuts for reference particles
     AliFlowTrackCuts     *fNullCuts; // dummy cuts for flow event tracks
-    AliFlowEvent         *fFlowEvent; //! flow events Inclusive e
+    AliFlowEvent         *fFlowEvent; // flow events Inclusive e
     const char           *fkCentralityMethod; // method used to determine centrality (V0 by default)
     Double_t             fCentrality; // event centrality for QA
     Double_t             fCentralityMin; // lower bound of cenrality bin
     Double_t             fCentralityMax; // upper bound of centrality bin
-    Double_t             fInvmassCut;           //invariant mass cut value
-    Double_t             fpTCutmin;    //pt cut value min
-    Double_t             fpTCutmax;    //pt cut value max
-    Int_t                fTrigger;          //invariant mass cut value
+    Double_t             fInvmassCut;//invariant mass cut value
+    Double_t             fpTCutmin;//pt cut value min
+    Double_t             fpTCutmax; //pt cut value max
+    Int_t                fTrigger; //invariant mass cut value
     TH1F                 *fPhi; //! QA plot of azimuthal distribution of tracks used for event plane estimation
     TH1F                 *fEta; //! QA plot of eta distribution of tracks used for event plane estimation
     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)
-    TH1F                 *fNoEvents;            //no of events
-    TH1F                 *fInclusiveElecPt; // Inclusive elec pt
-    TH2F                 *fTPCnsigma;               //TPC n sigma vs p
-    TH2F                 *fTPCnsigmaAft;                //TPC n sigma vs p after HFE pid
-    TH2F                 *fITSnsigmaAft;                //ITS n sigma vs p after HFE pid
-    TH2F                 *fTPCnsigmaVSptAft;   //lodviow
-    TH2F                 *fTOFns;           //track TOFnSigma
-    TH2F                 *fTOFnsAft;                //track TOFnSigma after PID
-    TH2F                 *fTOFBetaAft;
+    TH1F                 *fNoEvents; //!no of events
+    TH1F                 *fInclusiveElecPt; //!Inclusive elec pt
+    TH2F                 *fTPCnsigma;//!TPC n sigma vs p
+    TH2F                 *fTPCnsigmaAft;//!TPC n sigma vs p after HFE pid
+    TH2F                 *fITSnsigmaAft;//!ITS n sigma vs p after HFE pid
+    TH2F                 *fTPCnsigmaVSptAft;//!lodviow
+    TH2F                 *fTOFns;//!track TOFnSigma
+    TH2F                 *fTOFnsAft;//!track TOFnSigma after PID
+    TH2F                 *fTOFBetaAft;//!track TOFnSigma after PID2
     TH1F                 *fCentralityPass; // ! QA histogram of events that pass centrality cut
     TH1F                 *fCentralityNoPass; //! QA histogram of events that do not pass centrality cut
-    TH1F                 *fInvmassLS1; //LS Invmass for all rec par
-    TH1F                 *fInvmassULS1;//ULS Invmass for all rec par
-    TH1F                 *fPhotoElecPt;             //photonic elec pt
-    TH1F                 *fSemiInclElecPt;  //Semi inclusive ele pt
-    TH1F                 *fULSElecPt; //ULS elec Pt
-    TH1F                 *fLSElecPt;// LS elec pt
+    TH1F                 *fInvmassLS1; //!LS Invmass for all rec par
+    TH1F                 *fInvmassULS1;//!ULS Invmass for all rec par
+    TH1F                 *fPhotoElecPt;//!photonic elec pt
+    TH1F                 *fSemiInclElecPt;//!Semi inclusive ele pt
+    TH1F                 *fULSElecPt; //ULS elec Pt
+    TH1F                 *fLSElecPt;//! LS elec pt
     TH2F                 *fMultCorAfterCuts; //! QA profile global and tpc multiplicity after outlier cut
     TH2F                 *fMultvsCentr; //! QA profile of centralty vs multiplicity
     TProfile             *fSubEventDPhiv2;
-    TH1D                 *EPVzA;//ep v0a
-    TH1D                 *EPVzC;//ep v0c
-    TH1D                 *EPTPC;//ep tpc
+    TH1D                 *EPVzA;//!ep v0a
+    TH1D                 *EPVzC;//!ep v0c
+    TH1D                 *EPTPC;//!ep tpc
     THnSparseF           *fV2Phi;//! v2 analysis of EP-V0
-    TH1D                 *fvertex;//vertex
+    TH1D                 *fvertex;//!vertex
     TH2F                 *fMultCorBeforeCuts; //! QA profile global and tpc multiplicity after outlier cut
     THnSparseF           *fQAPid;             //! v2 analysis of EP-V0
     Double_t             fminITSnsigmaLowpT;  //ID cuts its
@@ -147,18 +147,18 @@ private:
     Int_t                fVz; //vertex range
     Double_t             fOpeningAngleCut; //openingAngle cut value
     Bool_t               fOP_angle; //to shitch on and off the op_angle cut
-    TH1F                 *fOpeningAngleLS;  //opening angle for LS pairs
-    TH1F                 *fOpeningAngleULS; //opening angle for ULS pairs
+    TH1F                 *fOpeningAngleLS;  //!opening angle for LS pairs
+    TH1F                 *fOpeningAngleULS; //!opening angle for ULS pairs
     AliSelectNonHFE      *fNonHFE;//new elienos stuff
     Bool_t               fDCA;//selection PHelectron
-    TH2F                 *fITSnsigma;               //TPC n sigma vs p
-    TH2F                 *fTPCnsigmaAftITSTOF;               //TPC n sigma vs p
+    TH2F                 *fITSnsigma;//!TPC n sigma vs p
+    TH2F                 *fTPCnsigmaAftITSTOF; //!TPC n sigma vs p
     TH2F                 *fTPCnsigmaAftTOF; //TPC n sigma vs p
-    TH2F                 *fITSnsigmaAftTOF;//jbd
-    TH2F                 *fITSvsTOF;               //TPC n sigma vs p
-    TH2F                 *fTPCvsITS;               //TPC n sigma vs p
-    TH2F                 *fTPCvsITSafterTOF; //TPC n sigma vs p
-    TH2F                 *fTPCvsTOF;//jbd
+    TH2F                 *fITSnsigmaAftTOF;//!jbd
+    TH2F                 *fITSvsTOF;//!TPC n sigma vs p
+    TH2F                 *fTPCvsITS;//!TPC n sigma vs p
+    TH2F                 *fTPCvsITSafterTOF;//!TPC n sigma vs p
+    TH2F                 *fTPCvsTOF;//!jbd
     Bool_t               fMultCut;//for mult correlationcut
     TH2F                 *fMultCorAfterCentrBeforeCuts; //! QA profile global and tpc multiplicity after outlier cut
     TH2F                 *fMultCorAfterVZTRKComp;//!after cent comp
@@ -166,13 +166,13 @@ private:
     TH1F                 *fCentralityAfterVZTRK;//!cent chneck2
     TH1F                 *fCentralityAfterCorrCut;//!cent chneck2
     TH2F                 *fMultCorAfterCorrCut;//!after cent comp
-    TH1D                 *EPVz;//v0cep
-    TH1D                 *EPTPCp;//tpcep
-    TH1D                 *EPTPCn;//!tpcep
+    TH1D                 *EPVz;//!v0cep
+    TH1D                 *EPTPCp;//!tpcep
+    TH1D                 *EPTPCn;//!tpcen
     TProfile             *fSubEventDPhiv2new;
     THnSparseF           *fV2Phivzerotot;//! v2 analysis of EP-V0
-    TH1F                 *fHistCentrDistr;// isto for Centr Flat
-    TH1F                 *fCentralityNoPassForFlattening; //! QA histogram of events that do not pass centrality cut for flattening
+    TH1F                 *fHistCentrDistr;//-> isto for Centr Flat
+    TH1F                 *fCentralityNoPassForFlattening; //!QA histogram of events that do not pass centrality cut for flattening
   
     
     AliAnalysisTaskFlowITSTPCTOFQCSP(const AliAnalysisTaskFlowITSTPCTOFQCSP&); // not implemented
index b23975bb35e7c5e97f083826b52d9afda67cee4e..c271e8c4549c0c64c3fbcac06625ef2988d6e70a 100644 (file)
@@ -626,7 +626,7 @@ void AliAnalysisTaskFlowTPCEMCalQCSP::UserExec(Option_t*)
                 AliFlowTrack *sTrackCont = new AliFlowTrack();
                 sTrackCont->Set(track);
                 sTrackCont->SetID(track->GetID());
-                sTrackCont->SetForRPSelection(kFALSE);
+                sTrackCont->SetForRPSelection(kTRUE);
                 sTrackCont->SetForPOISelection(kTRUE);
                 sTrackCont->SetMass(2637);
                 for(int iRPs=0; iRPs!=fFlowEventCont->NumberOfTracks(); ++iRPs)
@@ -640,10 +640,12 @@ void AliAnalysisTaskFlowTPCEMCalQCSP::UserExec(Option_t*)
                         if(fDebug) printf(" was in RP set");
                         //       cout << sTrack->GetID() <<"   ==  " << iRP->GetID() << " was in RP set" <<endl;
                         iRPCont->SetForRPSelection(kFALSE);
-                        fFlowEventCont->SetNumberOfRPs(fFlowEventCont->GetNumberOfRPs() - 1);
+                      //  fFlowEventCont->SetNumberOfRPs(fFlowEventCont->GetNumberOfRPs() - 1);
                     }
                 } //end of for loop on RPs
                 fFlowEventCont->InsertTrack(((AliFlowTrack*) sTrackCont));
+                fFlowEventCont->SetNumberOfPOIs(fFlowEventCont->GetNumberOfPOIs()+1);
+
             }
         }
         //==========================================================================================================
@@ -673,7 +675,7 @@ void AliAnalysisTaskFlowTPCEMCalQCSP::UserExec(Option_t*)
         AliFlowTrack *sTrack = new AliFlowTrack();
         sTrack->Set(track);
         sTrack->SetID(track->GetID());
-        sTrack->SetForRPSelection(kFALSE);
+        sTrack->SetForRPSelection(kTRUE);
         sTrack->SetForPOISelection(kTRUE);
         sTrack->SetMass(263732);
         for(int iRPs=0; iRPs!=fFlowEvent->NumberOfTracks(); ++iRPs)
@@ -687,11 +689,11 @@ void AliAnalysisTaskFlowTPCEMCalQCSP::UserExec(Option_t*)
                 if(fDebug) printf(" was in RP set");
                 //       cout << sTrack->GetID() <<"   ==  " << iRP->GetID() << " was in RP set" <<endl;
                 iRP->SetForRPSelection(kFALSE);
-                fFlowEvent->SetNumberOfRPs(fFlowEvent->GetNumberOfRPs() - 1);
+               // fFlowEvent->SetNumberOfRPs(fFlowEvent->GetNumberOfRPs() - 1);
             }
         } //end of for loop on RPs
         fFlowEvent->InsertTrack(((AliFlowTrack*) sTrack));
-        
+        fFlowEvent->SetNumberOfPOIs(fFlowEvent->GetNumberOfPOIs()+1);
         
         
         if(fDCA){
index 5408bd92a73a8633f2431432488ebcc7e0d4290d..80da9bd483c255dc50c785d088e86ba805bc01fe 100644 (file)
@@ -98,7 +98,7 @@ private:
     AliHFEpidQAmanager   *fPIDqa;               //! PID QA manager
     AliFlowTrackCuts     *fCutsRP; // track cuts for reference particles
     AliFlowTrackCuts     *fNullCuts; // dummy cuts for flow event tracks
-    AliFlowEvent         *fFlowEvent; //! flow events Inclusive e
+    AliFlowEvent         *fFlowEvent; // flow events Inclusive e
     const char           *fkCentralityMethod; // method used to determine centrality (V0 by default)
     Double_t             fCentrality; // event centrality for QA
     Double_t             fCentralityMin; // lower bound of cenrality bin
@@ -111,20 +111,20 @@ 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)
-    TH1F                 *fNoEvents;            //no of events
-    TH2F                 *fTrkEovPBef;          //track E/p before HFE pid
+    TH1F                 *fNoEvents;            //!no of events
+    TH2F                 *fTrkEovPBef;          //!track E/p before HFE pid
     //   TH2F                           *fdEdxBef;         //track dEdx vs p before HFE pid
-    TH1F                 *fInclusiveElecPt; // Inclusive elec pt
-    TH2F                 *fTPCnsigma;               //TPC n sigma vs p
-    TH2F                 *fTPCnsigmaAft;                //TPC n sigma vs p after HFE pid
+    TH1F                 *fInclusiveElecPt; //! Inclusive elec pt
+    TH2F                 *fTPCnsigma;               //!TPC n sigma vs p
+    TH2F                 *fTPCnsigmaAft;                //!TPC n sigma vs p after HFE pid
     TH1F                 *fCentralityPass; // ! QA histogram of events that pass centrality cut
     TH1F                 *fCentralityNoPass; //! QA histogram of events that do not pass centrality cut
-    TH1F                 *fInvmassLS1; //LS Invmass for all rec par
-    TH1F                 *fInvmassULS1;//ULS Invmass for all rec par
-    TH1F                 *fPhotoElecPt;             //photonic elec pt
-    TH1F                 *fSemiInclElecPt;  //Semi inclusive ele pt
-    TH1F                 *fULSElecPt; //ULS elec Pt
-    TH1F                 *fLSElecPt;// LS elec pt
+    TH1F                 *fInvmassLS1; //!LS Invmass for all rec par
+    TH1F                 *fInvmassULS1;//!ULS Invmass for all rec par
+    TH1F                 *fPhotoElecPt;             //!photonic elec pt
+    TH1F                 *fSemiInclElecPt;  //!Semi inclusive ele pt
+    TH1F                 *fULSElecPt; //!ULS elec Pt
+    TH1F                 *fLSElecPt;//! LS elec pt
     Double_t             fminTPC;  //ID cuts tpc
     Double_t             fmaxTPC;  //ID cuts tpc
     Double_t             fminEovP;  //ID cuts eovp
@@ -136,21 +136,21 @@ private:
     Double_t             fDispersion;//ID cuts SS
     TH2F                 *fMultCorAfterCuts; //! QA profile global and tpc multiplicity after outlier cut
     TH2F                 *fMultvsCentr; //! QA profile of centralty vs multiplicity
-    TProfile             *fSubEventDPhiv2;
-    TH1D                 *EPVzA;//v0aep
-    TH1D                 *EPVzC;//v0cep
-    TH1D                 *EPTPC;//tpcep
+    TProfile             *fSubEventDPhiv2;//!lll
+    TH1D                 *EPVzA;//!v0aep
+    TH1D                 *EPVzC;//!v0cep
+    TH1D                 *EPTPC;//!tpcep
     THnSparseF           *fV2Phi;//! v2 analysis of EP-V0
     THnSparseD           *fSparseElectronHadron;//! Trk matching sparse for v1 clusterizer
-    TH1D                 *fvertex;//huge ThNsparse
+    TH1D                 *fvertex;//!huge ThNsparse
     TH2F                 *fMultCorBeforeCuts; //! QA profile global and tpc multiplicity after outlier cut
     Bool_t               fSideBandsFlow;//flow from side bands for contamination
     Bool_t               fPhiminusPsi;//flow from phi minus psi method
-    AliFlowEvent         *fFlowEventCont; //! flow events for elect Contamination
+    AliFlowEvent         *fFlowEventCont; // flow events for elect Contamination
     Bool_t               fpurity; //for purity evaluation
     THnSparseD           *fSparseElectronpurity;//! Trk matching sparse for v1 clusterizer
-    TH1F                 *fOpeningAngleLS;  //opening angle for LS pairs
-    TH1F                 *fOpeningAngleULS; //opening angle for ULS pairs
+    TH1F                 *fOpeningAngleLS;  //!opening angle for LS pairs
+    TH1F                 *fOpeningAngleULS; //!opening angle for ULS pairs
     AliSelectNonHFE      *fNonHFE;//new elienos stuff
     Bool_t               fDCA;//selection PHelectron
     Double_t             fOpeningAngleCut; //openingAngle cut value
@@ -164,15 +164,15 @@ private:
     TH1F                 *fCentralityAfterVZTRK;//!cent chneck2
     TH1F                 *fCentralityAfterCorrCut;//!cent chneck2
     TH2F                 *fMultCorAfterCorrCut;//!after cent comp
-    TH1D                 *EPVz;//v0cep
-    TH1D                 *EPTPCp;//tpcep
+    TH1D                 *EPVz;//!v0cep
+    TH1D                 *EPTPCp;//!tpcep
     TH1D                 *EPTPCn;//!tpcep
     TProfile             *fSubEventDPhiv2new;
     THnSparseF           *fV2Phivzerotot;//! v2 analysis of EP-V0
-    TH1F                 *fHistCentrDistr;// isto for Centr Flat
+    TH1F                 *fHistCentrDistr;//-> isto for Centr Flat
     TH1F                 *fCentralityNoPassForFlattening; //! QA histogram of events that do not pass centrality cut for flattening
-    TH1F                 *fInvmassLS1highpt; //LS Invmass for all rec par high pt
-    TH1F                 *fInvmassULS1highpt;//ULS Invmass for all rec par high pt
+    TH1F                 *fInvmassLS1highpt; //!LS Invmass for all rec par high pt
+    TH1F                 *fInvmassULS1highpt;//!ULS Invmass for all rec par high pt
     
     
     
index 37f704f525d405d383c5032e5bb11344c848e3e9..27d192cd7a92f2590d8fcc66ee1774042ac20ed5 100644 (file)
@@ -28,9 +28,10 @@ AliAnalysisTaskHFECal* ConfigHFECal(Bool_t useMC,Bool_t MassConst,Bool_t MassWid
   hfecuts->SetPtRange(2, 50);
   hfecuts->SetMaxImpactParam(3.,3.);
   
   AliAnalysisTaskHFECal *task = new AliAnalysisTaskHFECal("HFEanalysisEMCal");
   printf("task ------------------------ %p\n ", task);
-  task->SetHFECuts(hfecuts);
+  //task->SetHFECuts(hfecuts);
   task->SetMassConstraint(MassConst);
   task->SetMassWidthCut(MassWidthCut);
   task->SetMassNonlinear(MassNonlinear);
index e93fc88eb1fda447aff8342ee08c47ba96daa87c..586093b34253c576d2460a761f2e881a31fc8ea7 100644 (file)
@@ -131,7 +131,7 @@ AliFJWrapper::AliFJWrapper(const char *name, const char *title)
   , fScheme            (fj::BIpt_scheme)
   , fAreaType          (fj::active_area)
   , fNGhostRepeats     (1)
-  , fGhostArea         (0.01)
+  , fGhostArea         (0.005)
   , fMaxRap            (1.)
   , fR                 (0.4)
   , fGridScatter       (1.0)
@@ -390,6 +390,15 @@ Int_t AliFJWrapper::Run()
                                       0,    //search of stable cones - zero = until no more
                                       1.0); // this should be seed effectively for proto jets
       fJetDef = new fastjet::JetDefinition(fPlugin);
+    } else if (fPluginAlgor == 1) {
+      // CDF cone
+      // NOTE: hardcoded split parameter
+      Double_t overlap_threshold = 0.75; // NOTE: this actually splits a lot: thr/min(pt1,pt2)
+      fPlugin = new fj::CDFMidPointPlugin(fR, 
+                                      overlap_threshold,
+                                      1.0,    //search of stable cones - zero = until no more
+                                      1.0); // this should be seed effectively for proto jets
+      fJetDef = new fastjet::JetDefinition(fPlugin);
     } else {
       AliError("[e] Unrecognized plugin number!");
     }
index 10dab5ae7ae6c7a8bfefd694031cfc115c3d8b0c..5b38bd3de63bacecd1f896fcda35ddfc1b1d85c0 100644 (file)
@@ -72,13 +72,13 @@ Bool_t AliJetEmbeddingFromGenTask::ExecOnce()
   fGen->SetStack(stack);
   fGen->Init();
 
-  if (InputEvent()->FindListObject(fTracksName) == 0) {
+  if (!(InputEvent()->FindListObject(fTracksName))) {
     fOutTracks = new TClonesArray("AliPicoTrack", 1000);
     fOutTracks->SetName(fTracksName);
     InputEvent()->AddObject(fOutTracks);
     fNTracks = 0;
   }
-
+  
   return kTRUE;
 }
 
@@ -87,6 +87,9 @@ void AliJetEmbeddingFromGenTask::Run()
 {
   // Embed particles.
 
+  if(fOutTracks)
+   fOutTracks->Delete();
+
   if (fCopyArray) 
     CopyTracks();
 
index e16dfde950c8a2a161d2b9e58f33d74614a58d2f..0fc94aba8adb6593a3c68c26238714561c8dd31d 100644 (file)
@@ -181,14 +181,12 @@ void AliJetModelBaseTask::UserExec(Option_t *)
   if (vert)
     vert->GetXYZ(fVertex);
 
-  if (fCopyArray) {
-    if (fOutTracks)
-      fOutTracks->Delete();
-    if (fOutClusters)
-      fOutClusters->Delete();
-    if (fOutMCParticles)
-      fOutMCParticles->Delete();
-  }
+  if (fOutTracks)
+    fOutTracks->Delete();
+  if (fOutClusters)
+    fOutClusters->Delete();
+  if (fOutMCParticles)
+    fOutMCParticles->Delete();
 
   if (fDensitySpectrum) {
     fNTracks = TMath::Nint(fDensitySpectrum->GetRandom());
index d94ad9e3d2796280e822d6d88d1391996c276187..573c8bf0999c403e5e4afd6fe28b5c4cd9eb60ec 100644 (file)
@@ -14,6 +14,7 @@
 #include <fastjet/ClusterSequenceArea.hh>
 #include <fastjet/AreaDefinition.hh>
 #include <fastjet/SISConePlugin.hh>
+#include <fastjet/CDFMidPointPlugin.hh>
 #ifdef FASTJET_VERSION
 #include <fastjet/tools/JetMedianBackgroundEstimator.hh>
 #endif
index 6d47285fd29b2ebbde8e9d7b0eac97258084a61f..f7d02fdb062f94aefc726b9b5ae4f3a9ddafa66a 100644 (file)
@@ -46,7 +46,8 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass() :
   fpPtVsMassJet1All(0),
   fpPtVsMassJet1Tagged(0),
   fh2MassVsAreaJet1All(0),
-  fh2MassVsAreaJet1Tagged(0)
+  fh2MassVsAreaJet1Tagged(0),
+  fh2EtMassOverEtRSq(0)
 {
   // Default constructor.
 
@@ -58,6 +59,7 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass() :
   fpPtVsMassJet1Tagged         = new TProfile*[fNcentBins];
   fh2MassVsAreaJet1All         = new TH2F*[fNcentBins];
   fh2MassVsAreaJet1Tagged      = new TH2F*[fNcentBins];
+  fh2EtMassOverEtRSq           = new TH2F*[fNcentBins];
 
   for (Int_t i = 0; i < fNcentBins; i++) {
     fh2PtJet1VsLeadPtAllSel[i]     = 0;
@@ -68,6 +70,7 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass() :
     fpPtVsMassJet1Tagged[i]        = 0;
     fh2MassVsAreaJet1All[i]        = 0;
     fh2MassVsAreaJet1Tagged[i]     = 0;
+    fh2EtMassOverEtRSq[i]          = 0;
   }
 
   SetMakeGeneralHistograms(kTRUE);
@@ -85,7 +88,8 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass(const char *name) :
   fpPtVsMassJet1All(0),
   fpPtVsMassJet1Tagged(0),
   fh2MassVsAreaJet1All(0),
-  fh2MassVsAreaJet1Tagged(0)
+  fh2MassVsAreaJet1Tagged(0),
+  fh2EtMassOverEtRSq(0)
 {
   // Standard constructor.
 
@@ -97,6 +101,7 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass(const char *name) :
   fpPtVsMassJet1Tagged         = new TProfile*[fNcentBins];
   fh2MassVsAreaJet1All         = new TH2F*[fNcentBins];
   fh2MassVsAreaJet1Tagged      = new TH2F*[fNcentBins];
+  fh2EtMassOverEtRSq           = new TH2F*[fNcentBins];
 
   for (Int_t i = 0; i < fNcentBins; i++) {
     fh2PtJet1VsLeadPtAllSel[i]     = 0;
@@ -107,6 +112,7 @@ AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass(const char *name) :
     fpPtVsMassJet1Tagged[i]        = 0;
     fh2MassVsAreaJet1All[i]        = 0;
     fh2MassVsAreaJet1Tagged[i]     = 0;
+    fh2EtMassOverEtRSq[i]          = 0;
   }
 
   SetMakeGeneralHistograms(kTRUE);
@@ -179,6 +185,10 @@ void AliAnalysisTaskEmcalJetMass::UserCreateOutputObjects()
     fh2MassVsAreaJet1Tagged[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsArea,minArea,maxArea);
     fOutput->Add(fh2MassVsAreaJet1Tagged[i]);
 
+    histName = TString::Format("fh2EtMassOverEtRSq_%d",i);
+    histTitle = TString::Format("%s;#it{E}_{T};(#it{M}/(#it{E}_{T}#it{R}))^{2}",histName.Data());
+    fh2EtMassOverEtRSq[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,100,0.,1.);
+    fOutput->Add(fh2EtMassOverEtRSq[i]);
   }
 
   // =========== Switch on Sumw2 for all histos ===========
@@ -210,31 +220,42 @@ Bool_t AliAnalysisTaskEmcalJetMass::FillHistograms()
 {
   // Fill histograms.
 
-  for(int i = 0; i < GetNJets(fContainerBase);++i) {
-    AliEmcalJet *jet1 = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(i, fContainerBase));
-    if(!jet1) continue;
-
-    Double_t ptJet1 =  jet1->Pt() - GetRhoVal(fContainerBase)*jet1->Area();
-    fh2PtJet1VsLeadPtAllSel[fCentBin]->Fill(ptJet1,jet1->MaxTrackPt());
-    fh2PtVsMassJet1All[fCentBin]->Fill(ptJet1,jet1->M());
-    fpPtVsMassJet1All[fCentBin]->Fill(ptJet1,jet1->M());
-    fh2MassVsAreaJet1All[fCentBin]->Fill(jet1->M(),jet1->Area());    
-
-    if(jet1->GetTagStatus()<1)
-      continue;
-
-    AliEmcalJet *jet2 = jet1->GetTaggedJet();
-    if(!jet2) continue;
-    
-    fh2PtJet1VsLeadPtTagged[fCentBin]->Fill(ptJet1,jet1->MaxTrackPt());
-    fh2PtVsMassJet1Tagged[fCentBin]->Fill(ptJet1,jet1->M());
-    fpPtVsMassJet1Tagged[fCentBin]->Fill(ptJet1,jet1->M());
-    fh2MassVsAreaJet1Tagged[fCentBin]->Fill(jet1->M(),jet1->Area());    
-  
+  AliEmcalJet* jet1 = 0;
+  AliEmcalJet* jet2 = 0;
+
+  AliJetContainer *jetCont = GetJetContainer(fContainerBase);
+  if(jetCont) {
+    jetCont->ResetCurrentID();
+    while((jet1 = jetCont->GetNextAcceptJet())) {
+      Double_t ptJet1 = jet1->Pt() - GetRhoVal(fContainerBase)*jet1->Area();//jetCont->GetJetPtCorr(jetCont->GetCurrentID());//
+      fh2PtJet1VsLeadPtAllSel[fCentBin]->Fill(ptJet1,jet1->MaxTrackPt());
+      fh2PtVsMassJet1All[fCentBin]->Fill(ptJet1,jet1->M());
+      fpPtVsMassJet1All[fCentBin]->Fill(ptJet1,jet1->M());
+      fh2MassVsAreaJet1All[fCentBin]->Fill(jet1->M(),jet1->Area());
+      
+      if(jet1->GetTagStatus()<1)
+       continue;
+      
+      jet2 = jet1->GetTaggedJet();
+      if(!jet2) continue;
+      
+      fh2PtJet1VsLeadPtTagged[fCentBin]->Fill(ptJet1,jet1->MaxTrackPt());
+      fh2PtVsMassJet1Tagged[fCentBin]->Fill(ptJet1,jet1->M());
+      fpPtVsMassJet1Tagged[fCentBin]->Fill(ptJet1,jet1->M());
+      fh2MassVsAreaJet1Tagged[fCentBin]->Fill(jet1->M(),jet1->Area());
+      
+      //      Double_t massOverEtR = jet1->M()/(ptJet1*jetCont->GetJetRadius());
+      //      fh2EtMassOverEtRSq[fCentBin]->Fill(ptJet1,massOverEtR*massOverEtR);
+      Double_t Et2 = jet1->M()*jet1->M() + jet1->Pt()*jet1->Pt();
+      Double_t Et = 0.;    Double_t massOverEtR = 0.;
+      if(Et2>0.) Et = TMath::Sqrt(Et2);
+      if((Et*jetCont->GetJetRadius())>0.) 
+       massOverEtR = jet1->M()/(Et*jetCont->GetJetRadius());
+      fh2EtMassOverEtRSq[fCentBin]->Fill(Et,massOverEtR*massOverEtR);
+    }
   }
 
   return kTRUE;
-
 }
 
 
index 7d40f8522c7ad25fdad2512a0e9474f3302b49da..2ce8bc4a27f3aa4ac3a05460f63f3d58a3e76af0 100644 (file)
@@ -42,11 +42,12 @@ class AliAnalysisTaskEmcalJetMass : public AliAnalysisTaskEmcalJet {
   TProfile        **fpPtVsMassJet1Tagged;         //!pT vs avg mass of tagged jets
   TH2F            **fh2MassVsAreaJet1All;         //!mass vs area of all jets
   TH2F            **fh2MassVsAreaJet1Tagged;      //!mass vs area of tagged jets
+  TH2F            **fh2EtMassOverEtRSq;           //!Et vs (M/Et*R)^2
 
   AliAnalysisTaskEmcalJetMass(const AliAnalysisTaskEmcalJetMass&);            // not implemented
   AliAnalysisTaskEmcalJetMass &operator=(const AliAnalysisTaskEmcalJetMass&); // not implemented
 
-  ClassDef(AliAnalysisTaskEmcalJetMass, 1)
+  ClassDef(AliAnalysisTaskEmcalJetMass, 2)
 };
 #endif
 
index a29db4cb8eaccda4802cf76e0b2e7bb40d2b90c3..7759d571a18d2c404973f34d2d98fe188e1f3ac6 100644 (file)
@@ -51,13 +51,17 @@ AliAnalysisTaskEmcalJetMassBkg::AliAnalysisTaskEmcalJetMassBkg() :
   fTracksCont(0),
   fCaloClustersCont(0),
   fh2PtVsMassRC(0),
-  fpPtVsMassRC(0),
   fh2PtVsMassRCExLJDPhi(0),
-  fpPtVsMassRCExLJ(0),
   fh2PtVsMassPerpConeLJ(0),
-  fpPtVsMassPerpConeLJ(0),
   fh2PtVsMassPerpConeTJ(0),
+  fpPtVsMassRC(0),
+  fpPtVsMassRCExLJ(0),
+  fpPtVsMassPerpConeLJ(0),
   fpPtVsMassPerpConeTJ(0),
+  fh2EtaVsMassRC(0),
+  fh2EtaVsMassRCExLJ(0),
+  fh2EtaVsMassPerpConeLJ(0),
+  fh2EtaVsMassPerpConeTJ(0),
   fh2CentVsMassRC(0),
   fh2CentVsMassRCExLJ(0),
   fh2CentVsMassPerpConeLJ(0),
@@ -82,23 +86,35 @@ AliAnalysisTaskEmcalJetMassBkg::AliAnalysisTaskEmcalJetMassBkg() :
   // Default constructor.
 
   fh2PtVsMassRC            = new TH2F*[fNcentBins];
-  fpPtVsMassRC             = new TProfile*[fNcentBins];
   fh2PtVsMassRCExLJDPhi    = new TH3F*[fNcentBins];
-  fpPtVsMassRCExLJ         = new TProfile*[fNcentBins];
   fh2PtVsMassPerpConeLJ    = new TH2F*[fNcentBins];
-  fpPtVsMassPerpConeLJ     = new TProfile*[fNcentBins];
   fh2PtVsMassPerpConeTJ    = new TH2F*[fNcentBins];
+
+  fpPtVsMassRC             = new TProfile*[fNcentBins];
+  fpPtVsMassRCExLJ         = new TProfile*[fNcentBins];
+  fpPtVsMassPerpConeLJ     = new TProfile*[fNcentBins];
   fpPtVsMassPerpConeTJ     = new TProfile*[fNcentBins];
 
+  fh2EtaVsMassRC            = new TH2F*[fNcentBins];
+  fh2EtaVsMassRCExLJ        = new TH2F*[fNcentBins];
+  fh2EtaVsMassPerpConeLJ    = new TH2F*[fNcentBins];
+  fh2EtaVsMassPerpConeTJ    = new TH2F*[fNcentBins];
+
   for (Int_t i = 0; i < fNcentBins; i++) {
     fh2PtVsMassRC[i]             = 0;
-    fpPtVsMassRC[i]              = 0;
     fh2PtVsMassRCExLJDPhi[i]     = 0;
-    fpPtVsMassRCExLJ[i]          = 0;
     fh2PtVsMassPerpConeLJ[i]     = 0;
-    fpPtVsMassPerpConeLJ[i]      = 0;
     fh2PtVsMassPerpConeTJ[i]     = 0;
+
+    fpPtVsMassRC[i]              = 0;
+    fpPtVsMassRCExLJ[i]          = 0;
+    fpPtVsMassPerpConeLJ[i]      = 0;
     fpPtVsMassPerpConeTJ[i]      = 0;
+
+    fh2EtaVsMassRC[i]             = 0;
+    fh2EtaVsMassRCExLJ[i]         = 0;
+    fh2EtaVsMassPerpConeLJ[i]     = 0;
+    fh2EtaVsMassPerpConeTJ[i]     = 0;
   }
 
   SetMakeGeneralHistograms(kTRUE);
@@ -120,13 +136,17 @@ AliAnalysisTaskEmcalJetMassBkg::AliAnalysisTaskEmcalJetMassBkg(const char *name)
   fTracksCont(0),
   fCaloClustersCont(0),
   fh2PtVsMassRC(0),
-  fpPtVsMassRC(0),
   fh2PtVsMassRCExLJDPhi(0),
-  fpPtVsMassRCExLJ(0),
   fh2PtVsMassPerpConeLJ(0),
-  fpPtVsMassPerpConeLJ(0),
   fh2PtVsMassPerpConeTJ(0),
+  fpPtVsMassRC(0),
+  fpPtVsMassRCExLJ(0),
+  fpPtVsMassPerpConeLJ(0),
   fpPtVsMassPerpConeTJ(0),
+  fh2EtaVsMassRC(0),
+  fh2EtaVsMassRCExLJ(0),
+  fh2EtaVsMassPerpConeLJ(0),
+  fh2EtaVsMassPerpConeTJ(0),
   fh2CentVsMassRC(0),
   fh2CentVsMassRCExLJ(0),
   fh2CentVsMassPerpConeLJ(0),
@@ -151,23 +171,35 @@ AliAnalysisTaskEmcalJetMassBkg::AliAnalysisTaskEmcalJetMassBkg(const char *name)
   // Standard constructor.
 
   fh2PtVsMassRC            = new TH2F*[fNcentBins];
-  fpPtVsMassRC             = new TProfile*[fNcentBins];
   fh2PtVsMassRCExLJDPhi    = new TH3F*[fNcentBins];
-  fpPtVsMassRCExLJ         = new TProfile*[fNcentBins];
   fh2PtVsMassPerpConeLJ    = new TH2F*[fNcentBins];
-  fpPtVsMassPerpConeLJ     = new TProfile*[fNcentBins];
   fh2PtVsMassPerpConeTJ    = new TH2F*[fNcentBins];
+
+  fpPtVsMassRC             = new TProfile*[fNcentBins];
+  fpPtVsMassRCExLJ         = new TProfile*[fNcentBins];
+  fpPtVsMassPerpConeLJ     = new TProfile*[fNcentBins];
   fpPtVsMassPerpConeTJ     = new TProfile*[fNcentBins];
 
+  fh2EtaVsMassRC            = new TH2F*[fNcentBins];
+  fh2EtaVsMassRCExLJ        = new TH2F*[fNcentBins];
+  fh2EtaVsMassPerpConeLJ    = new TH2F*[fNcentBins];
+  fh2EtaVsMassPerpConeTJ    = new TH2F*[fNcentBins];
+
   for (Int_t i = 0; i < fNcentBins; i++) {
-    fh2PtVsMassRC[i]              = 0;
-    fpPtVsMassRC[i]               = 0;
-    fh2PtVsMassRCExLJDPhi[i]      = 0;
-    fpPtVsMassRCExLJ[i]           = 0;
-    fh2PtVsMassPerpConeLJ[i]       = 0;
-    fpPtVsMassPerpConeLJ[i]        = 0;
-    fh2PtVsMassPerpConeTJ[i]       = 0;
-    fpPtVsMassPerpConeTJ[i]        = 0;
+    fh2PtVsMassRC[i]             = 0;
+    fh2PtVsMassRCExLJDPhi[i]     = 0;
+    fh2PtVsMassPerpConeLJ[i]     = 0;
+    fh2PtVsMassPerpConeTJ[i]     = 0;
+
+    fpPtVsMassRC[i]              = 0;
+    fpPtVsMassRCExLJ[i]          = 0;
+    fpPtVsMassPerpConeLJ[i]      = 0;
+    fpPtVsMassPerpConeTJ[i]      = 0;
+
+    fh2EtaVsMassRC[i]             = 0;
+    fh2EtaVsMassRCExLJ[i]         = 0;
+    fh2EtaVsMassPerpConeLJ[i]     = 0;
+    fh2EtaVsMassPerpConeTJ[i]     = 0;
   }
 
   SetMakeGeneralHistograms(kTRUE);
@@ -197,6 +229,10 @@ void AliAnalysisTaskEmcalJetMassBkg::UserCreateOutputObjects()
   const Double_t minPt = -50.;
   const Double_t maxPt = 200.;
 
+  const Int_t nBinsEta  = 100;
+  const Double_t minEta = -1.;
+  const Double_t maxEta =  1.;
+
   const Int_t nBinsCent  = 100;
   const Double_t minCent = 0.;
   const Double_t maxCent = 100.;
@@ -273,36 +309,56 @@ void AliAnalysisTaskEmcalJetMassBkg::UserCreateOutputObjects()
     fh2PtVsMassRC[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt);
     fOutput->Add(fh2PtVsMassRC[i]);
 
-    histName = TString::Format("fpPtVsMassRC_%d",i);
-    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
-    fpPtVsMassRC[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
-    fOutput->Add(fpPtVsMassRC[i]);
-
     histName = TString::Format("fh2PtVsMassRCExLJDPhi_%d",i);
     histTitle = TString::Format("%s;#it{p}_{T,RC};#it{M}_{RC}",histName.Data());
     fh2PtVsMassRCExLJDPhi[i] = new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt,72,-0.5*TMath::Pi(),1.5*TMath::Pi());
     fOutput->Add(fh2PtVsMassRCExLJDPhi[i]);
 
-    histName = TString::Format("fpPtVsMassRCExLJ_%d",i);
-    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
-    fpPtVsMassRCExLJ[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
-    fOutput->Add(fpPtVsMassRCExLJ[i]);
-
     histName = TString::Format("fh2PtVsMassPerpConeLJ_%d",i);
     histTitle = TString::Format("%s;#it{p}_{T,PerpConeLJ};#it{M}_{PerpConeLJ}",histName.Data());
     fh2PtVsMassPerpConeLJ[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt);
     fOutput->Add(fh2PtVsMassPerpConeLJ[i]);
 
-    histName = TString::Format("fpPtVsMassPerpConeLJ_%d",i);
-    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
-    fpPtVsMassPerpConeLJ[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
-    fOutput->Add(fpPtVsMassPerpConeLJ[i]);
-
     histName = TString::Format("fh2PtVsMassPerpConeTJ_%d",i);
     histTitle = TString::Format("%s;#it{p}_{T,PerpConeTJ};#it{M}_{PerpConeTJ}",histName.Data());
     fh2PtVsMassPerpConeTJ[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt);
     fOutput->Add(fh2PtVsMassPerpConeTJ[i]);
 
+    histName = TString::Format("fh2EtaVsMassRC_%d",i);
+    histTitle = TString::Format("%s;#eta_{RC};#it{M}_{RC}",histName.Data());
+    fh2EtaVsMassRC[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsEta,minEta,maxEta,nBinsPt,minPt,maxPt);
+    fOutput->Add(fh2EtaVsMassRC[i]);
+
+    histName = TString::Format("fh2EtaVsMassRCExLJ_%d",i);
+    histTitle = TString::Format("%s;#eta_{RC};#it{M}_{RC}",histName.Data());
+    fh2EtaVsMassRCExLJ[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsEta,minEta,maxEta,nBinsPt,minPt,maxPt);
+    fOutput->Add(fh2EtaVsMassRCExLJ[i]);
+
+    histName = TString::Format("fh2EtaVsMassPerpConeLJ_%d",i);
+    histTitle = TString::Format("%s;#eta_{PerpConeLJ};#it{M}_{PerpConeLJ}",histName.Data());
+    fh2EtaVsMassPerpConeLJ[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsEta,minEta,maxEta,nBinsPt,minPt,maxPt);
+    fOutput->Add(fh2EtaVsMassPerpConeLJ[i]);
+
+    histName = TString::Format("fh2EtaVsMassPerpConeTJ_%d",i);
+    histTitle = TString::Format("%s;#eta_{PerpConeTJ};#it{M}_{PerpConeTJ}",histName.Data());
+    fh2EtaVsMassPerpConeTJ[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsEta,minEta,maxEta,nBinsPt,minPt,maxPt);
+    fOutput->Add(fh2EtaVsMassPerpConeTJ[i]);
+
+    histName = TString::Format("fpPtVsMassRC_%d",i);
+    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
+    fpPtVsMassRC[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
+    fOutput->Add(fpPtVsMassRC[i]);
+
+    histName = TString::Format("fpPtVsMassRCExLJ_%d",i);
+    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
+    fpPtVsMassRCExLJ[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
+    fOutput->Add(fpPtVsMassRCExLJ[i]);
+
+    histName = TString::Format("fpPtVsMassPerpConeLJ_%d",i);
+    histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
+    fpPtVsMassPerpConeLJ[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
+    fOutput->Add(fpPtVsMassPerpConeLJ[i]);
+
     histName = TString::Format("fpPtVsMassPerpConeTJ_%d",i);
     histTitle = TString::Format("%s;#it{p}_{T,RC};Avg #it{M}_{RC}",histName.Data());
     fpPtVsMassPerpConeTJ[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
@@ -375,6 +431,7 @@ Bool_t AliAnalysisTaskEmcalJetMassBkg::FillHistograms()
     if (RCpt > 0) {
       fh2PtVsMassRC[fCentBin]->Fill(RCpt - rho*rcArea,RCmass);
       fpPtVsMassRC[fCentBin]->Fill(RCpt - rho*rcArea,RCmass);
+      fh2EtaVsMassRC[fCentBin]->Fill(RCeta,RCmass);
       fh2CentVsMassRC->Fill(fCent,RCmass);
       fh2MultVsMassRC->Fill(trackMult,RCmass);
 
@@ -397,6 +454,7 @@ Bool_t AliAnalysisTaskEmcalJetMassBkg::FillHistograms()
        if (dphi < -0.5*TMath::Pi()) dphi += TMath::Pi() * 2;
        fh2PtVsMassRCExLJDPhi[fCentBin]->Fill(RCpt - rho*rcArea,RCmass,dphi);
        fpPtVsMassRCExLJ[fCentBin]->Fill(RCpt - rho*rcArea,RCmass);
+       fh2EtaVsMassRCExLJ[fCentBin]->Fill(RCeta,RCmass);
        fh2CentVsMassRCExLJ->Fill(fCent,RCmass);
        fh2MultVsMassRCExLJ->Fill(trackMult,RCmass);
 
@@ -451,6 +509,7 @@ Bool_t AliAnalysisTaskEmcalJetMassBkg::FillHistograms()
       if(PCpt>0.) {
        fh2PtVsMassPerpConeLJ[fCentBin]->Fill(PCpt-rho*rcArea,PCmass);
        fpPtVsMassPerpConeLJ[fCentBin]->Fill(PCpt-rho*rcArea,PCmass);
+       fh2EtaVsMassPerpConeLJ[fCentBin]->Fill(PCeta,PCmass);
        fh2CentVsMassPerpConeLJ->Fill(fCent,PCmass);
        fh2MultVsMassPerpConeLJ->Fill(trackMult,PCmass);
       }
@@ -472,6 +531,7 @@ Bool_t AliAnalysisTaskEmcalJetMassBkg::FillHistograms()
       if(PCpt>0.) {
        fh2PtVsMassPerpConeTJ[fCentBin]->Fill(PCpt-rho*rcArea,PCmass);
        fpPtVsMassPerpConeTJ[fCentBin]->Fill(PCpt-rho*rcArea,PCmass);
+       fh2EtaVsMassPerpConeTJ[fCentBin]->Fill(PCeta,PCmass);
        fh2CentVsMassPerpConeTJ->Fill(fCent,PCmass);
        fh2MultVsMassPerpConeTJ->Fill(trackMult,PCmass);
       }
index 2a3b07ca0ee4031f67a9a481016210d72c1c23d9..a3d90938587df5d2485310632c466e510685a946 100644 (file)
@@ -60,14 +60,20 @@ class AliAnalysisTaskEmcalJetMassBkg : public AliAnalysisTaskEmcalJet {
 
  private:
   TH2F            **fh2PtVsMassRC;                //!pT vs mass of RC
+  TH3F            **fh2PtVsMassRCExLJDPhi;        //!pT vs mass of RC excluding area around leading jet
+  TH2F            **fh2PtVsMassPerpConeLJ;        //!pT vs mass of cone perpendicular to leading jet
+  TH2F            **fh2PtVsMassPerpConeTJ;        //!pT vs mass of cone perpendicular to all tagged jets
+
   TProfile        **fpPtVsMassRC;                 //!pT vs Avg mass of RC
-  TH3F            **fh2PtVsMassRCExLJDPhi;        //!pT vs mass of RC
   TProfile        **fpPtVsMassRCExLJ;             //!pT vs Avg mass of RC excluding area around leading jet
-  TH2F            **fh2PtVsMassPerpConeLJ;        //!pT vs mass of cone perpendicular to leading jet
   TProfile        **fpPtVsMassPerpConeLJ;         //!pT vs Avg mass of cone perpendicular to leading jet
-  TH2F            **fh2PtVsMassPerpConeTJ;        //!pT vs mass of cone perpendicular to all tagged jets
   TProfile        **fpPtVsMassPerpConeTJ;         //!pT vs Avg mass of cone perpendicular to all tagged jets
 
+  TH2F            **fh2EtaVsMassRC;               //!eta vs mass of RC
+  TH2F            **fh2EtaVsMassRCExLJ;           //!eta vs mass of RC excluding area around leading jet
+  TH2F            **fh2EtaVsMassPerpConeLJ;       //!eta vs mass of cone perpendicular to leading jet
+  TH2F            **fh2EtaVsMassPerpConeTJ;       //!eta vs mass of cone perpendicular to all tagged jets
+
   TH2F             *fh2CentVsMassRC;              //!cent vs mass of RC
   TH2F             *fh2CentVsMassRCExLJ;          //!cent vs mass of RC excluding area around leading jet
   TH2F             *fh2CentVsMassPerpConeLJ;      //!cent vs mass of RC perpendicular to leading jet
@@ -99,7 +105,7 @@ class AliAnalysisTaskEmcalJetMassBkg : public AliAnalysisTaskEmcalJet {
   AliAnalysisTaskEmcalJetMassBkg(const AliAnalysisTaskEmcalJetMassBkg&);            // not implemented
   AliAnalysisTaskEmcalJetMassBkg &operator=(const AliAnalysisTaskEmcalJetMassBkg&); // not implemented
 
-  ClassDef(AliAnalysisTaskEmcalJetMassBkg, 2)
+  ClassDef(AliAnalysisTaskEmcalJetMassBkg, 3)
 };
 #endif
 
index 9ba28bc34b8c9d3d610a2eb66df2046c1290fe77..3abc28575db37a72247c5c272095ed750070c8d7 100644 (file)
@@ -344,8 +344,10 @@ void AliAnalysisTaskEmcalJetTagger::MatchJetsGeo(Int_t c1, Int_t c2,
        dist = dR;
       }
     }//j jet loop
-    if(faMatchIndex2[i]>=0) iFlag[i*nJets2+faMatchIndex2[i]]+=1;//j closest to i
-    if(iDebug>10) Printf("Full Distance (%d)--(%d) %3.3f flag[%d] = %d",i,faMatchIndex2[i],dist,i*nJets2+faMatchIndex2[i],iFlag[i*nJets2+faMatchIndex2[i]]);
+    if(faMatchIndex2[i]>=0) {
+      iFlag[i*nJets2+faMatchIndex2[i]]+=1;//j closest to i
+      if(iDebug>10) Printf("Full Distance (%d)--(%d) %3.3f flag[%d] = %d",i,faMatchIndex2[i],dist,i*nJets2+faMatchIndex2[i],iFlag[i*nJets2+faMatchIndex2[i]]);
+    }
   
   }//i jet loop
 
@@ -382,8 +384,10 @@ void AliAnalysisTaskEmcalJetTagger::MatchJetsGeo(Int_t c1, Int_t c2,
         dist = dR;
       }   
     }
-    if(faMatchIndex1[j]>=0) iFlag[faMatchIndex1[j]*nJets2+j]+=2;//i closest to j
-    if(iDebug>10) Printf("Other way Distance (%d)--(%d) %3.3f flag[%d] = %d",faMatchIndex1[j],j,dist,faMatchIndex1[j]*nJets2+j,iFlag[faMatchIndex1[j]*nJets2+j]);
+    if(faMatchIndex1[j]>=0) {
+      iFlag[faMatchIndex1[j]*nJets2+j]+=2;//i closest to j
+      if(iDebug>10) Printf("Other way Distance (%d)--(%d) %3.3f flag[%d] = %d",faMatchIndex1[j],j,dist,faMatchIndex1[j]*nJets2+j,iFlag[faMatchIndex1[j]*nJets2+j]);
+    }
 
   }
     
@@ -392,7 +396,7 @@ void AliAnalysisTaskEmcalJetTagger::MatchJetsGeo(Int_t c1, Int_t c2,
     AliEmcalJet *jet1 = static_cast<AliEmcalJet*>(GetJetFromArray(i, c1));
     for(int j = 0;j<nJets2;j++){
       AliEmcalJet *jet2 = static_cast<AliEmcalJet*>(GetJetFromArray(j, c2));
-      if(iDebug>10) AliInfo(Form("%s: Flag[%d][%d] %d ",GetName(),i,j,iFlag[i*nJets2+j]));
+      AliDebug(11,Form("%s: Flag[%d][%d] %d ",GetName(),i,j,iFlag[i*nJets2+j]));
       
       // we have a uniqe correlation
       if(iFlag[i*nJets2+j]==3){
index 3b1f6f47dfbf42042b1964d5bf9077f15768087b..02d180a32adb54b9d83f49284c8d040e2009ae3a 100644 (file)
@@ -254,10 +254,6 @@ void AliAnalysisTaskHJetDphi::UserCreateOutputObjects()
   const Double_t lowBinKt[dimKt] = {lowTrkPtBin,   0,  -40.5, 0,  0};
   const Double_t hiBinKt[dimKt]  = {upTrkPtBin,  200,  40.5,  10, 11};
 
-  OpenFile(1);
-  fOutputList = new TList();
-  fOutputList->SetOwner(1);
-
    // Called once
    OpenFile(1);
    if(!fOutputList) fOutputList = new TList;
@@ -362,11 +358,15 @@ void AliAnalysisTaskHJetDphi::UserCreateOutputObjects()
          fhNumberOfTT[i] = new TH1F(Form("%s_fhNumberOfTT",triggerName[i]), Form("%s: number of TT",triggerName[i]),6,0,6);
          fOutputList->Add(fhNumberOfTT[i]);
 
-         fHJetPhiCorrUp[i] = new THnSparseF(Form("%s_fHJetPhiCorrUp",triggerName[i]),Form("%s: single inclusive TT p_{T} vs recoil jet p_{T} vs #Delta#varphi vs area vs centrality vs #Delta#eta vs pt hard bin (R=%1.1f);TT p_{T} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;area;centrality;#Delta#eta;ptHardBin",triggerName[i],fRadius),dimCor,nBinsCor,lowBinCor,hiBinCor);
-         fOutputList->Add(fHJetPhiCorrUp[i]);
 
-         fHJetPhiCorrDown[i] = new THnSparseF(Form("%s_fHJetPhiCorrDown",triggerName[i]),Form("%s: single inclusive TT p_{T} vs recoil jet p_{T} vs #Delta#varphi vs area vs centrality vs #Delta#eta vs pt hard bin (R=%1.1f);TT p_{T} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;area;centrality;#Delta#eta;ptHardBin",triggerName[i],fRadius),dimCor,nBinsCor,lowBinCor,hiBinCor);
-         fOutputList->Add(fHJetPhiCorrDown[i]);
+         if(fRunBkgFlow)
+           {
+             fHJetPhiCorrUp[i] = new THnSparseF(Form("%s_fHJetPhiCorrUp",triggerName[i]),Form("%s: single inclusive TT p_{T} vs recoil jet p_{T} vs #Delta#varphi vs area vs centrality vs #Delta#eta vs pt hard bin (R=%1.1f);TT p_{T} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;area;centrality;#Delta#eta;ptHardBin",triggerName[i],fRadius),dimCor,nBinsCor,lowBinCor,hiBinCor);
+             fOutputList->Add(fHJetPhiCorrUp[i]);
+             
+             fHJetPhiCorrDown[i] = new THnSparseF(Form("%s_fHJetPhiCorrDown",triggerName[i]),Form("%s: single inclusive TT p_{T} vs recoil jet p_{T} vs #Delta#varphi vs area vs centrality vs #Delta#eta vs pt hard bin (R=%1.1f);TT p_{T} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;area;centrality;#Delta#eta;ptHardBin",triggerName[i],fRadius),dimCor,nBinsCor,lowBinCor,hiBinCor);
+             fOutputList->Add(fHJetPhiCorrDown[i]);
+           }
        }
 
       if(fRunLeadTrkQA)
@@ -516,9 +516,12 @@ void AliAnalysisTaskHJetDphi::UserExec(Option_t *)
   fESD=dynamic_cast<AliESDEvent*>(InputEvent());
   if (!fESD) 
     {
-      AliInfo("ESD not available");
       fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
     }
+  else
+    {
+      if(fAnaType==1) fEvent = AODEvent();
+    }
   if(fAnaType==1)
     {
       fAODOut = dynamic_cast<AliAODEvent*>(AODEvent());
@@ -536,6 +539,19 @@ void AliAnalysisTaskHJetDphi::UserExec(Option_t *)
 
   fhEventStat->Fill(0.5);
 
+  if(fVerbosity>1)
+    {
+      TList *list = fEvent->GetList();
+      for(Int_t i=0; i<list->GetEntries(); i++)
+       {
+         TObject *obj = (TObject*)list->At(i);
+         cout<<i<<": "<<obj->GetName()<<" : "<<obj->ClassName()<<endl;
+       }
+    }
+  // Retrieve arraies from memory
+  if(!fIsInit) fIsInit = RetrieveArraies();
+  if(!fIsInit) return;
+
   if(fIsEmbedding)
     {
       if(fAnaType==0)
@@ -598,10 +614,6 @@ void AliAnalysisTaskHJetDphi::UserExec(Option_t *)
     fCentrality = 0;
   fhCentrality[fTriggerType]->Fill(fCentrality);
 
-  // Retrieve arraies from memory
-  if(!fIsInit) fIsInit = RetrieveArraies();
-  if(!fIsInit) return;
-
   // Get Rho value
   if(fCollisionSystem=="PbPb")
     {
@@ -715,7 +727,7 @@ Int_t AliAnalysisTaskHJetDphi::FindSingleIncTrigger(const TClonesArray *trackArr
       arr.Reset();
     }
 
-  if(trigIndex>0)
+  if(trigIndex>-1)
     {
       AliVParticle *tt = (AliVParticle*) fTrackArray->At(trigIndex);
       trigPt = tt->Pt();
@@ -732,8 +744,9 @@ Int_t AliAnalysisTaskHJetDphi::FindSingleIncTrigger(const TClonesArray *trackArr
            }
        }
     }
+
   if(trigIndex==-1) { trigPt = -1; trigPhi = -999; trigEta = -999;}
-  if(arrayType==0) fTriggerTrkIndex = trigIndex; 
+  if(arrayType<2) fTriggerTrkIndex = trigIndex; 
   return nTT;
 }
 
@@ -744,12 +757,12 @@ void AliAnalysisTaskHJetDphi::RunSingleInclHJetCorr(Double_t trigPt, Double_t tr
 
   if(hTT)
     {
-      Double_t fillTT[] = {trigPt, fCentrality, fPtHardBin};
+      Double_t fillTT[] = {trigPt, fCentrality, (Double_t)fPtHardBin};
       hTT->Fill(fillTT);
     }
 
   Int_t nJets = jetArray->GetEntries();
-  Double_t jetPt, jetEta, jetPhi, jetArea;
+  Double_t jetPt = 0, jetEta = 0, jetPhi = 0, jetArea = 0;
   for(Int_t ij=0; ij<nJets; ij++)
     {
       if(fAnaType==0)
@@ -760,7 +773,7 @@ void AliAnalysisTaskHJetDphi::RunSingleInclHJetCorr(Double_t trigPt, Double_t tr
          jetPhi  = jet->Phi();
          jetArea = jet->Area();
        }
-      if(fAnaType==1)
+      else if(fAnaType==1)
        {
          AliAODJet* jet = dynamic_cast<AliAODJet*>(jetArray->At(ij));
          jetPt   = jet->Pt();
@@ -768,13 +781,15 @@ void AliAnalysisTaskHJetDphi::RunSingleInclHJetCorr(Double_t trigPt, Double_t tr
          jetPhi  = jet->Phi();
          jetArea = jet->EffectiveAreaCharged();
        }
+      else
+       return;
       if(!IsGoodJet(jetEta)) continue; // eta cut
       Double_t dPhi = CalculateDPhi(trigPhi,jetPhi);
 
       Double_t jetPtCorr = jetPt-rho*jetArea;
       if(jetPtCorr>fJetPtMin)
        {
-         Double_t fill[] = {trigPt,jetPtCorr,dPhi,jetArea,fCentrality,trigEta-jetEta, fPtHardBin};
+         Double_t fill[] = {trigPt,jetPtCorr,dPhi,jetArea,fCentrality,trigEta-jetEta, (Double_t)fPtHardBin};
          hn->Fill(fill);
        }
     }
@@ -823,12 +838,12 @@ void AliAnalysisTaskHJetDphi::RunTrackQA()
              TParticle *tpart = (TParticle*)part->Particle();
              if(TMath::Abs(tpart->GetPdgCode())==211)
                {
-                 Double_t fillPhiRes[] = {esdtrack->Pt(),part->Phi()-esdtrack->Phi(),type,fCentrality};
+                 Double_t fillPhiRes[] = {esdtrack->Pt(),part->Phi()-esdtrack->Phi(),(Double_t)type,fCentrality};
                  fhTrkPhiRes[fTriggerType]->Fill(fillPhiRes);
                }
              resolution = (part->Pt()-esdtrack->Pt())/part->Pt();
            }
-         Double_t fillPtRes[] = {esdtrack->Pt(),esdtrack->Pt()*TMath::Sqrt(esdtrack->GetSigma1Pt2()),resolution,type,fCentrality};
+         Double_t fillPtRes[] = {esdtrack->Pt(),esdtrack->Pt()*TMath::Sqrt(esdtrack->GetSigma1Pt2()),resolution,(Double_t)type,fCentrality};
          fhTrkPtRes[fTriggerType]->Fill(fillPtRes);
        }
     }
@@ -860,12 +875,12 @@ void AliAnalysisTaskHJetDphi::RunTrackQA()
            {
              AliMCParticle *part = (AliMCParticle*)fMC->GetTrack(label);
              resolution = (part->Pt()-aodtrack->Pt())/part->Pt();
-             Double_t fillPhiRes[] = {aodtrack->Pt(),part->Phi()-aodtrack->Phi(),type,fCentrality};
+             Double_t fillPhiRes[] = {aodtrack->Pt(),part->Phi()-aodtrack->Phi(),(Double_t)type,fCentrality};
              fhTrkPhiRes[fTriggerType]->Fill(fillPhiRes);
            }
          if(sigma1Pt2>0)
            {
-             Double_t fillPtRes[5] = {aodtrack->Pt(),aodtrack->Pt()*TMath::Sqrt(sigma1Pt2),resolution,type,fCentrality};
+             Double_t fillPtRes[5] = {aodtrack->Pt(),aodtrack->Pt()*TMath::Sqrt(sigma1Pt2),resolution,(Double_t)type,fCentrality};
              fhTrkPtRes[fTriggerType]->Fill(fillPtRes);
            }
        }
@@ -876,8 +891,8 @@ void AliAnalysisTaskHJetDphi::RunTrackQA()
 void AliAnalysisTaskHJetDphi::RunJetQA(const TClonesArray *jetArray, const Double_t rho, THnSparse *hJetPt, THnSparse *hJetArea, THnSparse *hJetQA)
 {
   Int_t nJets = jetArray->GetEntries();
-  Double_t jetPt, jetEta, jetPhi, jetArea, jetPtCorr;
-  Int_t nCons;
+  Double_t jetPt = 0, jetEta = 0, jetPhi = 0, jetArea = 0, jetPtCorr = 0;
+  Int_t nCons = 0;
   for(Int_t ij=0; ij<nJets; ij++)
     {
       if(fAnaType==0)
@@ -889,7 +904,7 @@ void AliAnalysisTaskHJetDphi::RunJetQA(const TClonesArray *jetArray, const Doubl
          jetArea = jet->Area();
          nCons   = jet->GetNumberOfConstituents();
        }
-      if(fAnaType==1)
+      else if(fAnaType==1)
        {
          AliAODJet* jet = dynamic_cast<AliAODJet*>(jetArray->At(ij));
          jetPt   = jet->Pt();
@@ -898,18 +913,20 @@ void AliAnalysisTaskHJetDphi::RunJetQA(const TClonesArray *jetArray, const Doubl
          jetArea = jet->EffectiveAreaCharged();
          nCons   = jet->GetRefTracks()->GetEntriesFast();
        }
+      else
+       return;
       if(!IsGoodJet(jetEta)) continue; // eta cut
 
       jetPtCorr = jetPt-rho*jetArea;
-      Double_t fillPt[] = {jetPtCorr, jetPt, fCentrality, fPtHardBin};
+      Double_t fillPt[] = {jetPtCorr, jetPt, fCentrality, (Double_t)fPtHardBin};
       hJetPt->Fill(fillPt);
 
-      Double_t fillA[] = {jetPtCorr, jetArea, fCentrality, fPtHardBin};
+      Double_t fillA[] = {jetPtCorr, jetArea, fCentrality, (Double_t)fPtHardBin};
       hJetArea->Fill(fillA);
 
       if(jetPtCorr>fJetPtMin)
        {
-         Double_t fillQA[] = {jetPtCorr, jetPhi*TMath::RadToDeg(), jetEta, jetArea, nCons, fCentrality, fPtHardBin};
+         Double_t fillQA[] = {jetPtCorr, jetPhi*TMath::RadToDeg(), jetEta, jetArea, (Double_t)nCons, fCentrality, (Double_t)fPtHardBin};
          hJetQA->Fill(fillQA);
        }
     }
@@ -961,22 +978,21 @@ void AliAnalysisTaskHJetDphi::StudyKtEffects()
 
   fKtValue = 0; // dummy
 
+
   AliPicoTrack *tt = (AliPicoTrack*) fTrackArray->At(fTriggerTrkIndex);
   Double_t triggerPhi = tt->GetTrackPhiOnEMCal();
 
   Int_t nJets = fDLJetArray->GetEntries();
-  Double_t jetPhi, jetPt, jetArea;
   for(Int_t ij=0; ij<nJets; ij++)
     {
       AliEmcalJet* jet = dynamic_cast<AliEmcalJet*>(fDLJetArray->At(ij));
       if(!IsGoodJet(jet->Eta())) continue; // eta cut
-      jetPhi = jet->Phi();
-      jetPt  = jet->Pt();
-      jetArea = jet->Area();
-      Double_t dPhi = CalculateDPhi(triggerPhi,jet->Phi());
+      Double_t jetPhi = jet->Phi();
+      Double_t jetPt  = jet->Pt();
+      Double_t dPhi = CalculateDPhi(triggerPhi,jetPhi);
       if(dPhi<pi+0.6 && dPhi>pi-0.6)
        {
-         Double_t fill[] = {tt->Pt(), jet->Pt(), jet->Pt()*TMath::Tan(tt->GetTrackPtOnEMCal()), fCentrality, fPtHardBin};
+         Double_t fill[] = {tt->Pt(), jetPt, jetPt*TMath::Tan(tt->GetTrackPtOnEMCal()), fCentrality, (Double_t)fPtHardBin};
          fhKtEffects[fTriggerType]->Fill(fill);
        }
     }
@@ -1158,7 +1174,7 @@ Bool_t AliAnalysisTaskHJetDphi::RetrieveArraies()
       // Get DL jet collection
       if (!fDLJetArrName.IsNull())
        {
-         AliInfo(Form("Retrieve jets %s!", fDLJetArrName.Data()));
+         AliInfo(Form("Retrieve DL jets %s!", fDLJetArrName.Data()));
          if(fAODOut        && !fDLJetArray) fDLJetArray = dynamic_cast<TClonesArray*>(fAODOut->FindListObject(fDLJetArrName));
          if(fAODExtension  && !fDLJetArray) fDLJetArray = dynamic_cast<TClonesArray*>(fAODExtension->GetAOD()->FindListObject(fDLJetArrName));
          if(fAODIn         && !fDLJetArray) fDLJetArray = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fDLJetArrName));
@@ -1314,6 +1330,7 @@ void AliAnalysisTaskHJetDphi::PrintConfig()
   printf("Is this MC data: %s\n",decision[fIsMC]);
   printf("Run on particle level: %s\n",decision[fAnalyzeMCTruth]);
   printf("Event type selection: %d\n",fOfflineTrgMask);
+  printf("Is embedding? %s\n",decision[fIsEmbedding]);
   printf("Track filter mask: %d\n",fFilterMask);
   printf("Require track to have ITS refit? %s\n",decision[fRequireITSRefit]);
   printf("Track pt range: %2.2f < pt < %2.2f\n",fMinTrkPt, fMaxTrkPt);
index cce27f1940a7e9889017b35f9617575a69e21eca..65a9d6c9b226271dbfcaeb05a0532af89b4152ce 100644 (file)
@@ -101,7 +101,7 @@ protected:
   Int_t                             GetPtHardBin(Double_t ptHard);
 
  private:
-  Int_t                             fVerbosity;                  //! Control output
+  Int_t                             fVerbosity;                  //  Control output
   Bool_t                            fIsEmbedding;                //  Flag of embedding trains
   Int_t                             fAnaType;                    //  0-EMCal jet framework; 1-charged jet framework
   TString                           fPeriod;                     //  Run period
index be910eff1889de4694e0d961ca2c4066ae138287..9d0ca78204a00e382995c5b7d17030ac41a3c1f4 100644 (file)
@@ -156,7 +156,6 @@ AliEmcalJetTask* AddTaskEmcalJet(
   const char *tag            = "Jet"
 )
 {  
-  
   UInt_t jetType = 0;
 
   if (algo == 0) 
@@ -180,5 +179,10 @@ AliEmcalJetTask* AddTaskEmcalJet(
   else
     jetType |= AliEmcalJetTask::kRX1Jet;
 
+  if (ghostArea<=0) {
+    ::Error("AddTaskEmcalJet","Ghost area set to 0, check your settings (try 0.005)");
+    return NULL;
+  }
+
   return AddTaskEmcalJet(jetType, nTracks, nClusters, minTrPt, minClPt, ghostArea, radius, recombScheme, tag);
 }
index 14d2fa61bd8051f56f0bbabc24f2435293107b3c..5dfc7c1628cd52e2e8427f13a646ee76f89b9c9c 100644 (file)
@@ -137,7 +137,7 @@ AliAnalysisTaskEmcalJetMass* AddTaskEmcalJetMass(const char * njetsBase,
     jetContBase->ConnectParticleContainer(trackCont);
     jetContBase->ConnectClusterContainer(clusterCont);
     jetContBase->SetZLeadingCut(0.98,0.98);
-    task->SetPercAreaCut(0.6, 0);
+    jetContBase->SetPercAreaCut(0.6);
   }
 
   task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
index 8f5969656e401da84da246158e0bb510097e3095..fc5df3ca84e809ed56f737cafb6c37e56f7d3594 100644 (file)
@@ -52,11 +52,11 @@ AliAnalysisTaskEmcalJetSample* AddTaskEmcalJetSample(
 
   AliAnalysisTaskEmcalJetSample* jetTask = new AliAnalysisTaskEmcalJetSample(name);
 
-  AliParticleContainer *trackCont  = task->AddParticleContainer(ntracks);
-  AliClusterContainer *clusterCont = task->AddClusterContainer(nclusters);
+  AliParticleContainer *trackCont  = jetTask->AddParticleContainer(ntracks);
+  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);
 
   TString strType(type);
-  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,R);
+  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
   if(jetCont) {
     jetCont->SetRhoName(nrho);
     jetCont->ConnectParticleContainer(trackCont);
index abd4f6c1e27ff9eaf7043dc2a497ae905d7262e4..f0267d0ef8b357c476893195b12ee6e4290f0d60 100644 (file)
@@ -282,6 +282,7 @@ void LoadLibs()
   gSystem->Load("libTENDERSupplies");
   gSystem->Load("libPWGTools");
   gSystem->Load("libPWGEMCAL");
+  gSystem->Load("libESDfilter");
   gSystem->Load("libPWGGAEMCALTasks");
   gSystem->Load("libPWGCFCorrelationsBase");
   gSystem->Load("libPWGCFCorrelationsDPhi");
@@ -291,6 +292,7 @@ void LoadLibs()
   gSystem->Load("libfastjet");
     //For FastJet 3.x use siscon*,fastjetplugins for 2.x use SISConePlugin
   gSystem->Load("libSISConePlugin");
+  gSystem->Load("libCDFConesPlugin");
   //  gSystem->Load("libsiscone");
   //  gSystem->Load("libsiscone_spherical");
   //  gSystem->Load("libfastjetplugins");
index e554c627e23e3c68bb7d479d11b6f4af286c8d1e..f28bcf4cfbb38a90635d7a1ba8dcb2badf640e3d 100644 (file)
@@ -307,7 +307,8 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
    TH1F* hNDPerEvNoJet=(TH1F*)fmyOutput->FindObject("hNDPerEvNoJet");
    TH1F* hptDPerEvNoJet=(TH1F*)fmyOutput->FindObject("hptDPerEvNoJet");
    TH1F* hNJetPerEvNoD=(TH1F*)fmyOutput->FindObject("hNJetPerEvNoD");
-   TH1F* hPtJetPerEvNoD=(TH1F*)fmyOutput->FindObject("hPtJetPerEvNoD");  
+   TH1F* hPtJetPerEvNoD=(TH1F*)fmyOutput->FindObject("hPtJetPerEvNoD");
+   THnSparseF* hnspDstandalone=(THnSparseF*)fmyOutput->FindObject("hsDstandalone");
        
    hstat->Fill(0);
    
@@ -340,7 +341,47 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
       return;
       
    }
-    
+   
+   //loop on candidates standalone (checking the candidates are there and their phi-eta distributions)
+   
+   for(Int_t ic = 0; ic < candidates; ic++) {
+      
+      // D* candidates
+      AliVParticle* charm=0x0;
+      charm=(AliVParticle*)candidatesArr->At(ic);
+      if(!charm) continue;
+      hstat->Fill(2);
+      
+      Double_t candsparse[4]={charm->Eta(), charm->Phi(), charm->Pt(), 0};
+      
+      if(fCandidateType==kDstartoKpipi) {
+        AliAODRecoCascadeHF* dstar = (AliAODRecoCascadeHF*)charm;
+        Double_t deltamass= dstar->DeltaInvMass();
+        candsparse[3]=deltamass;
+        hnspDstandalone->Fill(candsparse);
+      }
+      if(fCandidateType==kD0toKpi){
+        AliAODRecoDecayHF* dzero=(AliAODRecoDecayHF*)charm;
+        Int_t isselected=fCuts->IsSelected(dzero,AliRDHFCuts::kAll,aodEvent);
+        
+        Double_t masses[2];
+        Int_t pdgdaughtersD0[2]={211,321};//pi,K 
+        Int_t pdgdaughtersD0bar[2]={321,211};//K,pi 
+        
+        masses[0]=dzero->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
+        masses[1]=dzero->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
+        if(isselected==1 || isselected==3) {
+           candsparse[3]=masses[0];
+           hnspDstandalone->Fill(candsparse);
+        }
+        if(isselected>=2){
+           candsparse[3]=masses[1];
+           hnspDstandalone->Fill(candsparse);
+           
+        }
+      }
+   }
+
    // we start with jets
    Double_t ejet   = 0;
    Double_t phiJet = 0;
@@ -420,7 +461,7 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
         AliVParticle* charm=0x0;
         charm=(AliVParticle*)candidatesArr->At(ic);
         if(!charm) continue;
-        hstat->Fill(2);
+        
         
         FlagFlavour(charm, jet);
         if (jet->TestFlavourTag(AliEmcalJet::kDStar)) hstat->Fill(4);
@@ -559,11 +600,13 @@ Bool_t  AliAnalysisTaskFlavourJetCorrelations::DefineHistoForAnalysis(){
    const Int_t nbinsptD=100;
    const Int_t nbinsz=100;
    const Int_t nbinsphi=200;
+   const Int_t nbinseta=100;
    
    const Float_t ptjetlims[2]={0.,200.};
    const Float_t ptDlims[2]={0.,50.};
    const Float_t zlims[2]={0.,1.2};
    const Float_t philims[2]={0.,6.3};
+   const Float_t etalims[2]={-1.5,1.5};
    
    if(fCandidateType==kDstartoKpipi) 
    {
@@ -585,21 +628,30 @@ Bool_t  AliAnalysisTaskFlavourJetCorrelations::DefineHistoForAnalysis(){
       
    }
    // D related histograms
-      TH1F *hNDPerEvNoJet=new TH1F("hNDPerEvNoJet","Number of candidates per event with no jets; N candidate/ev with no jet", 20, 0., 20.);
-      hNDPerEvNoJet->Sumw2();
-      fmyOutput->Add(hNDPerEvNoJet);
-
-      TH1F *hptDPerEvNoJet=new TH1F("hptDPerEvNoJet","pt distribution of candidates per events with no jets; p_{t}^{D} (GeV/c)",nbinsptD, ptDlims[0],ptDlims[1]);
-      hptDPerEvNoJet->Sumw2();
-      fmyOutput->Add(hptDPerEvNoJet);
-
+   TH1F *hNDPerEvNoJet=new TH1F("hNDPerEvNoJet","Number of candidates per event with no jets; N candidate/ev with no jet", 20, 0., 20.);
+   hNDPerEvNoJet->Sumw2();
+   fmyOutput->Add(hNDPerEvNoJet);
+   
+   TH1F *hptDPerEvNoJet=new TH1F("hptDPerEvNoJet","pt distribution of candidates per events with no jets; p_{t}^{D} (GeV/c)",nbinsptD, ptDlims[0],ptDlims[1]);
+   hptDPerEvNoJet->Sumw2();
+   fmyOutput->Add(hptDPerEvNoJet);
+   
+   const Int_t    nAxisD=4;
+   const Int_t    nbinsSparseD[nAxisD]={nbinsphi,nbinseta,nbinsptD,nbinsmass};
+   const Double_t minSparseD[nAxisD]  ={philims[0],etalims[0],ptDlims[0],fMinMass};
+   const Double_t maxSparseD[nAxisD]  ={philims[1],etalims[1],ptDlims[1],fMaxMass};
+   THnSparseF *hsDstandalone=new THnSparseF("hsDstandalone","#phi, #eta, p_{T}^{D}, and mass", nAxisD, nbinsSparseD, minSparseD, maxSparseD);
+   hsDstandalone->Sumw2();
+   
+   fmyOutput->Add(hsDstandalone);
+   
    // jet related fistograms
    
    TH1F* hEjetTrks      = new TH1F("hEjetTrks",  "Jet tracks energy distribution;Energy (GeV)",500,0,200);
    hEjetTrks->Sumw2();
    TH1F* hPhiJetTrks    = new TH1F("hPhiJetTrks","Jet tracks #phi distribution; #phi (rad)",  nbinsphi,philims[0],philims[1]);
    hPhiJetTrks->Sumw2();
-   TH1F* hEtaJetTrks    = new TH1F("hEtaJetTrks","Jet tracks #eta distribution; #eta",  100,-1.5,1.5);
+   TH1F* hEtaJetTrks    = new TH1F("hEtaJetTrks","Jet tracks #eta distribution; #eta",  nbinseta,etalims[0],etalims[1]);
    hEtaJetTrks->Sumw2();
    TH1F* hPtJetTrks     = new TH1F("hPtJetTrks",  "Jet tracks Pt distribution; p_{T} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1]);
    hPtJetTrks->Sumw2();
@@ -608,7 +660,7 @@ Bool_t  AliAnalysisTaskFlavourJetCorrelations::DefineHistoForAnalysis(){
    hEjet->Sumw2();
    TH1F* hPhiJet    = new TH1F("hPhiJet","Jet #phi distribution; #phi (rad)",  nbinsphi,philims[0],philims[1]);
    hPhiJet->Sumw2();
-   TH1F* hEtaJet    = new TH1F("hEtaJet","Jet #eta distribution; #eta",  100,-1.5,1.5);
+   TH1F* hEtaJet    = new TH1F("hEtaJet","Jet #eta distribution; #eta", nbinseta,etalims[0],etalims[1]);
    hEtaJet->Sumw2();
    TH1F* hPtJet      = new TH1F("hPtJet",  "Jet Pt distribution; p_{T} (GeV/c)",nbinsptjet,ptjetlims[0],ptjetlims[1]);
    hPtJet->Sumw2();
@@ -679,7 +731,7 @@ Bool_t  AliAnalysisTaskFlavourJetCorrelations::DefineHistoForAnalysis(){
    const Int_t nbinsSparse[nAxis]={nbinsz,nbinsphi,nbinsptjet,nbinsptD,nbinsmass,2};
    const Double_t minSparse[nAxis]={zlims[0],philims2[0],ptjetlims[0],ptDlims[0],fMinMass,-0.5};
    const Double_t maxSparse[nAxis]={zlims[1],philims2[1],ptjetlims[1],ptDlims[1],fMaxMass, 1.5};
-   THnSparseF *hsDphiz=new THnSparseF("hsDphiz","Z and #Delta#phi vs p_{T}^{jet}, p_{T}^{D}, and mass", nAxis, nbinsSparse, minSparse, maxSparse);
+   THnSparseF *hsDphiz=new THnSparseF("hsDphiz","Z and #Delta#phi vs p_{T}^{jet}, p_{T}^{D}, mass and IsSB", nAxis, nbinsSparse, minSparse, maxSparse);
    hsDphiz->Sumw2();
    
    fmyOutput->Add(hsDphiz);
@@ -725,7 +777,6 @@ void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsRecoJetCorr(AliVPartic
 
 void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsD0JetCorr(AliAODRecoDecayHF* candidate, Double_t dPhi, Double_t z, Double_t ptD, Double_t ptj,Double_t deltaR, AliAODEvent* aodEvent){
 
-  //dPhi and z not used at the moment,but will be (re)added
 
    Double_t masses[2]={0.,0.};
    Int_t pdgdaughtersD0[2]={211,321};//pi,K 
@@ -736,7 +787,7 @@ void AliAnalysisTaskFlavourJetCorrelations::FillHistogramsD0JetCorr(AliAODRecoDe
    
    TH3F* hPtJetWithD=(TH3F*)fmyOutput->FindObject("hPtJetWithD");
    THnSparseF* hsDphiz=(THnSparseF*)fmyOutput->FindObject("hsDphiz");
-   Double_t point[5]={z,dPhi,ptj,ptD,masses[0]};
+   Double_t point[6]={z,dPhi,ptj,ptD,masses[0],0};
    
    Int_t isselected=fCuts->IsSelected(candidate,AliRDHFCuts::kAll,aodEvent);
    if(isselected==1 || isselected==3) {
@@ -812,6 +863,8 @@ void AliAnalysisTaskFlavourJetCorrelations::FillMassHistograms(Double_t mass,Dou
    }
 }
 
+//________________________________________________________________________________
+
 void AliAnalysisTaskFlavourJetCorrelations::FlagFlavour(AliVParticle *charm, AliEmcalJet *jet){
    Double_t deltaR=DeltaR(charm, jet);
    AliEmcalJet::EFlavourTag tag=AliEmcalJet::kDStar;
index 5d4bb82e1eb57a0c42a2c534b28495f990444a63..fe235a3a8dc1a10802307eb6f63655a8bed164b6 100644 (file)
@@ -59,7 +59,9 @@ AliAnalysisTaskFlavourJetCorrelations *AddTaskFlavourJetCorrelations(
   task->SetUseReco(reco);
   task->SetTriggerOnLeadingJet(triggerOnLeadingJet);
   task->SetJetAcceptanceType(cutType);
-
+  task->SetJetPtCut(jptcut);
+  task->SetPercAreaCut(percjetareacut);
+  
   mgr->AddTask(task);
 
   if(theMCon) {
index 1b7251fcb9856885982d979d482f2e31165943d6..b004a95af15c10c536a3698a019d06daadc5fbc5 100644 (file)
@@ -82,10 +82,10 @@ void AddTasksFlavourJet(const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
    // Jet preparation
    //gROOT->LoadMacro("/data/Work/jets/testEMCalJetFramework/code/v4/AddTaskJetPreparation.C");
    gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskJetPreparation.C");
-   AddTaskJetPreparation(type,sRunPeriod,"PicoTracks",bIsMC ? "MCParticlesSelected" : "",/*next 7 emcal default settings*/"","",2.,0.,0.03,0.015,0.15,uTriggerMask, kFALSE /*track cluster*/,kFALSE /*do histos*/,kTRUE /*make pico tracks*/,kFALSE /*make emcal trigger*/,kFALSE /*is emcal train*/);
+   AddTaskJetPreparation(sRunPeriod,"PicoTracks",bIsMC ? "MCParticlesSelected" : "",/*next 7 emcal default settings*/"","",2.,0.,0.03,0.015,0.15,uTriggerMask, kFALSE /*track cluster*/,kFALSE /*do histos*/,kTRUE /*make pico tracks*/,kFALSE /*make emcal trigger*/,kFALSE /*is emcal train*/);
    
    gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalPicoTrackMaker.C");
-   AliEmcalPicoTrackMaker *taskPicoTrack = AddTaskEmcalPicoTrackMaker(sUsedTrks.Data(),sInputTrk.Data(),sRunPeriod.Data());
+   AliEmcalPicoTrackMaker *taskPicoTrack = AddTaskEmcalPicoTrackMaker(sUsedTrks.Data(),sInputTrk.Data());
    taskPicoTrack->SelectCollisionCandidates(uTriggerMask);
    
    gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
index 2090575e40a32e1be006ef43473f143b79885743..20907a9a45b74f8ebde44607a17b37f07e7aaa1a 100644 (file)
@@ -212,47 +212,47 @@ void LoadLibs()
   gSystem->Load("libEVGEN");
   gSystem->Load("libANALYSISalice");
   gSystem->Load("libCORRFW");
-  gSystem->Load("libTOFbase");
+  //gSystem->Load("libTOFbase");
   //gSystem->Load("libTOFrec");
-  gSystem->Load("libRAWDatabase.so");
-  gSystem->Load("libRAWDatarec.so");
-  gSystem->Load("libTPCbase.so");
-  gSystem->Load("libTPCrec.so");
-  gSystem->Load("libITSbase.so");
-  gSystem->Load("libITSrec.so");
-  gSystem->Load("libTRDbase.so");
-  gSystem->Load("libTENDER.so");
-  gSystem->Load("libSTAT.so");
-  gSystem->Load("libTRDrec.so");
-  gSystem->Load("libHMPIDbase.so");
+  //gSystem->Load("libRAWDatabase.so");
+  //gSystem->Load("libRAWDatarec.so");
+  //gSystem->Load("libTPCbase.so");
+  //gSystem->Load("libTPCrec.so");
+  //gSystem->Load("libITSbase.so");
+  //gSystem->Load("libITSrec.so");
+  //gSystem->Load("libTRDbase.so");
+  //gSystem->Load("libTENDER.so");
+  //gSystem->Load("libSTAT.so");
+  //gSystem->Load("libTRDrec.so");
+  //gSystem->Load("libHMPIDbase.so");
   gSystem->Load("libPWGTools.so");
-  gSystem->Load("libPWGPP.so");
+  //gSystem->Load("libPWGPP.so");
   gSystem->Load("libPWGHFbase");
-  gSystem->Load("libPWGDQdielectron");
-  gSystem->Load("libPWGHFhfe");
+  //gSystem->Load("libPWGDQdielectron");
+  //gSystem->Load("libPWGHFhfe");
   gSystem->Load("libPWGflowBase.so");
   gSystem->Load("libPWGflowTasks.so");
   gSystem->Load("libPWGHFvertexingHF");
   gSystem->Load("libEMCALUtils");
-  gSystem->Load("libPHOSUtils");
-  gSystem->Load("libPWGCaloTrackCorrBase");
+  //gSystem->Load("libPHOSUtils");
+  //gSystem->Load("libPWGCaloTrackCorrBase");
   gSystem->Load("libEMCALraw");
   gSystem->Load("libEMCALbase");
-  gSystem->Load("libEMCALrec");
-  gSystem->Load("libTRDbase");
-  gSystem->Load("libVZERObase");
-  gSystem->Load("libVZEROrec");
+  //gSystem->Load("libEMCALrec");
+  //gSystem->Load("libTRDbase");
+  //gSystem->Load("libVZERObase");
+  //gSystem->Load("libVZEROrec");
   gSystem->Load("libTENDER");
-  gSystem->Load("libTENDERSupplies");
+  //gSystem->Load("libTENDERSupplies");
   gSystem->Load("libPWGEMCAL");
   gSystem->Load("libPWGGAEMCALTasks");
-  gSystem->Load("libPWGTools");
-  gSystem->Load("libPWGCFCorrelationsBase");
-  gSystem->Load("libPWGCFCorrelationsDPhi");
+  //gSystem->Load("libPWGCFCorrelationsBase");
+  //gSystem->Load("libPWGCFCorrelationsDPhi");
 
   //load CGAL, Fastjet and SISCone
   //gSystem->Load("libCGAL");
   gSystem->Load("libfastjet");
+  gSystem->Load("libCDFConesPlugin");
   gSystem->Load("libSISConePlugin");
 
   gSystem->Load("libJETAN");
@@ -286,7 +286,7 @@ AliAnalysisGrid* CreateAlienHandler(const char* uniqueName, const char* gridDir,
   }else tmpName +="_20130412_122423";
   */
   TString tmpAdditionalLibs("");
-  tmpAdditionalLibs = Form("libTree.so libVMC.so libGeom.so libGui.so libXMLParser.so libMinuit.so libMinuit2.so libProof.so libPhysics.so libSTEERBase.so libESD.so libAOD.so libOADB.so libANALYSIS.so libCDB.so libRAWDatabase.so libSTEER.so libANALYSISalice.so libCORRFW.so libTOFbase.so libRAWDatabase.so libRAWDatarec.so libTPCbase.so libTPCrec.so libITSbase.so libITSrec.so libTRDbase.so libTENDER.so libSTAT.so libTRDrec.so libHMPIDbase.so libPWGTools.so libPWGPP.so libPWGHFbase.so libPWGDQdielectron.so libPWGHFhfe.so libPWGflowBase.so libPWGflowTasks.so libPWGHFvertexingHF.so libEMCALUtils.so libPHOSUtils.so libPWGCaloTrackCorrBase.so libEMCALraw.so libEMCALbase.so libEMCALrec.so libTRDbase.so libVZERObase.so libVZEROrec.so libTENDER.so libTENDERSupplies.so libPWGEMCAL.so libPWGGAEMCALTasks.so libPWGTools.so libPWGCFCorrelationsBase.so libPWGCFCorrelationsDPhi.so  libCGAL.so libJETAN.so libfastjet.so libSISConePlugin.so libFASTJETAN.so libPWGJE.so libPWGmuon.so libPWGJEEMCALJetTasks.so libPWGJEFlavourJetTasks.so %s %s",additionalCode.Data(),additionalHeaders.Data());
+  tmpAdditionalLibs = Form("libTree.so libVMC.so libGeom.so libGui.so libXMLParser.so libMinuit.so libMinuit2.so libProof.so libPhysics.so libSTEERBase.so libESD.so libESDfilter.so libAOD.so libOADB.so libANALYSIS.so libCDB.so libRAWDatabase.so libSTEER.so libANALYSISalice.so libCORRFW.so libPWGTools.so libPWGHFbase.so libPWGflowBase.so libPWGflowTasks.so libPWGHFvertexingHF.so libEMCALUtils.so libEMCALraw.so libEMCALbase.so libTENDER.so libPWGEMCAL.so libPWGGAEMCALTasks.so libPWGTools.so libCGAL.so libJETAN.so libfastjet.so libSISConePlugin.so libCDFConesPlugin.so libFASTJETAN.so libPWGJE.so libPWGmuon.so libPWGJEEMCALJetTasks.so libPWGJEFlavourJetTasks.so %s %s",additionalCode.Data(),additionalHeaders.Data());
 
 
   TString macroName("");
@@ -302,8 +302,8 @@ AliAnalysisGrid* CreateAlienHandler(const char* uniqueName, const char* gridDir,
 
   // Here you can set the (Ali)ROOT version you want to use
   plugin->SetAPIVersion("V1.1x");
-  plugin->SetROOTVersion("v5-34-08");
-  plugin->SetAliROOTVersion("v5-05-11-AN");
+  plugin->SetROOTVersion("v5-34-08-4");
+  plugin->SetAliROOTVersion("v5-05-63-AN");
 
   plugin->SetGridDataDir(gridDir); // e.g. "/alice/sim/LHC10a6"
   plugin->SetDataPattern(pattern); //dir structure in run directory
index 660b573aa2e5a6cbf1b4d7afb62c549b4f62312c..b8499e8931f82221f1b8f7a44e10101bad9f92a0 100644 (file)
@@ -71,7 +71,9 @@ AliAnalysisTaskPID::AliAnalysisTaskPID()
   , fEtaAbsCutLow(0.0)
   , fEtaAbsCutUp(0.9)
   , fDoAnySystematicStudiesOnTheExpectedSignal(kFALSE)
-  , fSystematicScalingSplines(1.0)
+  , fSystematicScalingSplinesThreshold(50.)
+  , fSystematicScalingSplinesBelowThreshold(1.0)
+  , fSystematicScalingSplinesAboveThreshold(1.0)
   , fSystematicScalingEtaCorrectionMomentumThr(0.35)
   , fSystematicScalingEtaCorrectionLowMomenta(1.0)
   , fSystematicScalingEtaCorrectionHighMomenta(1.0)
@@ -196,7 +198,9 @@ AliAnalysisTaskPID::AliAnalysisTaskPID(const char *name)
   , fEtaAbsCutLow(0.0)
   , fEtaAbsCutUp(0.9)
   , fDoAnySystematicStudiesOnTheExpectedSignal(kFALSE)
-  , fSystematicScalingSplines(1.0)
+  , fSystematicScalingSplinesThreshold(50.)
+  , fSystematicScalingSplinesBelowThreshold(1.0)
+  , fSystematicScalingSplinesAboveThreshold(1.0)
   , fSystematicScalingEtaCorrectionMomentumThr(0.35)
   , fSystematicScalingEtaCorrectionLowMomenta(1.0)
   , fSystematicScalingEtaCorrectionHighMomenta(1.0)
@@ -1089,7 +1093,9 @@ void AliAnalysisTaskPID::CheckDoAnyStematicStudiesOnTheExpectedSignal()
   
   fDoAnySystematicStudiesOnTheExpectedSignal = kFALSE;
   
-  if (TMath::Abs(fSystematicScalingSplines - 1.0) > fgkEpsilon) {
+  
+  if ((TMath::Abs(fSystematicScalingSplinesBelowThreshold - 1.0) > fgkEpsilon) ||
+      (TMath::Abs(fSystematicScalingSplinesAboveThreshold - 1.0) > fgkEpsilon)) {
     fDoAnySystematicStudiesOnTheExpectedSignal = kTRUE;
     return;
   }
@@ -2072,7 +2078,9 @@ void AliAnalysisTaskPID::PrintSystematicsSettings() const
   // Print current settings for systematic studies.
   
   printf("\n\nSettings for systematics for task %s:\n", GetName());
-  printf("Splines:\t%f\n", GetSystematicScalingSplines());
+  printf("SplinesThr:\t%f\n", GetSystematicScalingSplinesThreshold());
+  printf("SplinesBelowThr:\t%f\n", GetSystematicScalingSplinesBelowThreshold());
+  printf("SplinesAboveThr:\t%f\n", GetSystematicScalingSplinesAboveThreshold());
   printf("EtaCorrMomThr:\t%f\n", GetSystematicScalingEtaCorrectionMomentumThr());
   printf("EtaCorrLowP:\t%f\n", GetSystematicScalingEtaCorrectionLowMomenta());
   printf("EtaCorrHighP:\t%f\n", GetSystematicScalingEtaCorrectionHighMomenta());
@@ -2169,12 +2177,47 @@ Bool_t AliAnalysisTaskPID::ProcessTrack(const AliVTrack* track, Int_t particlePD
     dEdxPr = fPIDResponse->GetTPCResponse().GetExpectedSignal(track, AliPID::kProton, AliTPCPIDResponse::kdEdxDefault, kFALSE, kFALSE);
     
     // Scale splines, if desired
-    if (TMath::Abs(fSystematicScalingSplines - 1.0) > fgkEpsilon) {
-      dEdxEl *= fSystematicScalingSplines;
-      dEdxKa *= fSystematicScalingSplines;
-      dEdxPi *= fSystematicScalingSplines;
-      dEdxMu *= fTakeIntoAccountMuons ? fSystematicScalingSplines : 1.;
-      dEdxPr *= fSystematicScalingSplines;
+    if ((TMath::Abs(fSystematicScalingSplinesBelowThreshold - 1.0) > fgkEpsilon) ||
+        (TMath::Abs(fSystematicScalingSplinesAboveThreshold - 1.0) > fgkEpsilon)) {
+       
+      // Tune turn-on of correction for pions (not so relevant for the other species, since at very large momenta)
+      const Double_t pTPC = track->GetTPCmomentum();
+      Double_t bg = 0;
+      Double_t scaleFactor = 1.;
+      Double_t usedSystematicScalingSplines = 1.;
+        
+      bg = pTPC / AliPID::ParticleMass(AliPID::kElectron);
+      scaleFactor = 0.5 * (1. + TMath::Erf((bg - fSystematicScalingSplinesThreshold) / 4.));
+      usedSystematicScalingSplines = fSystematicScalingSplinesBelowThreshold * (1 - scaleFactor)
+                                            + fSystematicScalingSplinesAboveThreshold * scaleFactor;
+      dEdxEl *= usedSystematicScalingSplines;
+      
+      bg = pTPC / AliPID::ParticleMass(AliPID::kKaon);
+      scaleFactor = 0.5 * (1. + TMath::Erf((bg - fSystematicScalingSplinesThreshold) / 4.));
+      usedSystematicScalingSplines = fSystematicScalingSplinesBelowThreshold * (1 - scaleFactor)
+                                            + fSystematicScalingSplinesAboveThreshold * scaleFactor;
+      dEdxKa *= usedSystematicScalingSplines;
+      
+      bg = pTPC / AliPID::ParticleMass(AliPID::kPion);
+      scaleFactor = 0.5 * (1. + TMath::Erf((bg - fSystematicScalingSplinesThreshold) / 4.));
+      usedSystematicScalingSplines = fSystematicScalingSplinesBelowThreshold * (1 - scaleFactor)
+                                            + fSystematicScalingSplinesAboveThreshold * scaleFactor;
+      dEdxPi *= usedSystematicScalingSplines;
+      
+      if (fTakeIntoAccountMuons) {
+        bg = pTPC / AliPID::ParticleMass(AliPID::kMuon);
+        scaleFactor = 0.5 * (1. + TMath::Erf((bg - fSystematicScalingSplinesThreshold) / 4.));
+        usedSystematicScalingSplines = fSystematicScalingSplinesBelowThreshold * (1 - scaleFactor)
+                                              + fSystematicScalingSplinesAboveThreshold * scaleFactor;
+        dEdxMu *= usedSystematicScalingSplines;
+      }
+      
+      
+      bg = pTPC / AliPID::ParticleMass(AliPID::kProton);
+      scaleFactor = 0.5 * (1. + TMath::Erf((bg - fSystematicScalingSplinesThreshold) / 4.));
+      usedSystematicScalingSplines = fSystematicScalingSplinesBelowThreshold * (1 - scaleFactor)
+                                            + fSystematicScalingSplinesAboveThreshold * scaleFactor;
+      dEdxPr *= usedSystematicScalingSplines;
     }
     
     // Get the eta correction factors for the (modified) expected dEdx
index 00e125573d2919b30351a2e0d68a8cc13c471114..0dbb3c7ea5996b76be8f6bdda5ee3ef83cea966d 100644 (file)
@@ -181,9 +181,16 @@ class AliAnalysisTaskPID : public AliAnalysisTaskPIDV0base {
   
   Bool_t IsInAcceptedEtaRange(Double_t etaAbs) const { return (etaAbs >= fEtaAbsCutLow && etaAbs <= fEtaAbsCutUp); };
   
-  Double_t GetSystematicScalingSplines() const { return fSystematicScalingSplines; };
-  void SetSystematicScalingSplines(Double_t scaleFactor) 
-    { fSystematicScalingSplines = scaleFactor; CheckDoAnyStematicStudiesOnTheExpectedSignal(); };
+  Double_t GetSystematicScalingSplinesThreshold() const { return fSystematicScalingSplinesThreshold; };
+  void SetSystematicScalingSplinesThreshold(Double_t threshold) { fSystematicScalingSplinesThreshold = threshold; };
+  
+  Double_t GetSystematicScalingSplinesBelowThreshold() const { return fSystematicScalingSplinesBelowThreshold; };
+  void SetSystematicScalingSplinesBelowThreshold(Double_t scaleFactor) 
+    { fSystematicScalingSplinesBelowThreshold = scaleFactor; CheckDoAnyStematicStudiesOnTheExpectedSignal(); };
+    
+  Double_t GetSystematicScalingSplinesAboveThreshold() const { return fSystematicScalingSplinesAboveThreshold; };
+  void SetSystematicScalingSplinesAboveThreshold(Double_t scaleFactor) 
+    { fSystematicScalingSplinesAboveThreshold = scaleFactor; CheckDoAnyStematicStudiesOnTheExpectedSignal(); };
   
   Double_t GetSystematicScalingEtaCorrectionMomentumThr() const { return fSystematicScalingEtaCorrectionMomentumThr; };
   void SetSystematicScalingEtaCorrectionMomentumThr(Double_t threshold) { fSystematicScalingEtaCorrectionMomentumThr = threshold; };
@@ -280,7 +287,9 @@ class AliAnalysisTaskPID : public AliAnalysisTaskPIDV0base {
   
   // For systematic studies
   Bool_t   fDoAnySystematicStudiesOnTheExpectedSignal; // Internal flag indicating whether any systematic studies are going to be performed
-  Double_t fSystematicScalingSplines;        // Systematic scale factor for the splines (1. = no systematics) 
+  Double_t fSystematicScalingSplinesThreshold;         // beta-gamma threshold for the systematic spline scale factor
+  Double_t fSystematicScalingSplinesBelowThreshold;        // Systematic scale factor for the splines (1. = no systematics) below threshold
+  Double_t fSystematicScalingSplinesAboveThreshold;        // Systematic scale factor for the splines (1. = no systematics) above threshold
   Double_t fSystematicScalingEtaCorrectionMomentumThr;  // Momentum threshold for the systematic scale factor for the eta correction (separates low-p from high-p
   Double_t fSystematicScalingEtaCorrectionLowMomenta;   // Systematic scale factor for the eta correction (1. = no systematics) at low momenta
   Double_t fSystematicScalingEtaCorrectionHighMomenta;  // Systematic scale factor for the eta correction (1. = no systematics) at high momenta
@@ -369,7 +378,7 @@ class AliAnalysisTaskPID : public AliAnalysisTaskPIDV0base {
   AliAnalysisTaskPID(const AliAnalysisTaskPID&); // not implemented
   AliAnalysisTaskPID& operator=(const AliAnalysisTaskPID&); // not implemented
   
-  ClassDef(AliAnalysisTaskPID, 15);
+  ClassDef(AliAnalysisTaskPID, 16);
 };
 
 
index 2e5100d08163624cf11fee30e2fecb30a53774a4..0d3a5568224597754ffab0fb2bb47b74c8237685 100644 (file)
@@ -26,8 +26,8 @@ AliRsnMiniAnalysisTask * AddTaskLambdaStarPbPb
 
    AliRsnCutSetDaughterParticle::ERsnDaughterCutSet cutKaCandidate = AliRsnCutSetDaughterParticle::kTPCTOFpidKstarPP2010,
 
-   Float_t     nsigmaPr = 3.0,
-   Float_t     nsigmaKa = 3.0,
+   Float_t     nsigmaPr = 2.0,
+   Float_t     nsigmaKa = 2.0,
    Bool_t      enableMonitor = kTRUE,
    Bool_t      IsMcTrueOnly = kFALSE,
    Int_t       nmix = 5,
index bf7ae1d1013f78ad371d8a2c8924e14166a2b3c0..4a6cd2241d63f7a51801c02ad5b53f9619b68fe7 100644 (file)
@@ -38,7 +38,7 @@ Bool_t ConfigLambdaStarPbPb
 
   cutSetQ  = new AliRsnCutSetDaughterParticle("cutQuality", AliRsnCutSetDaughterParticle::kQualityStd2011, AliPID::kKaon, -1.0, aodFilterBit);
   cutSetPr = new AliRsnCutSetDaughterParticle(Form("cutProtonTPCPbPb2011_%2.1fsigma",nsigmaPr), cutPrCandidate, AliPID::kProton, nsigmaPr, aodFilterBit);
-  cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutKaonTPPbPb2011_%2.1f2sigma",nsigmaKa), cutKaCandidate, AliPID::kKaon, nsigmaKa, aodFilterBit);
+  cutSetK  = new AliRsnCutSetDaughterParticle(Form("cutKaonTPCPbPb2011_%2.1f2sigma",nsigmaKa), cutKaCandidate, AliPID::kKaon, nsigmaKa, aodFilterBit);
 
   Int_t iCutQ = task->AddTrackCuts(cutSetQ);
   Int_t iCutPr = task->AddTrackCuts(cutSetPr);
index 64325ef91a68566d25df914f1663e8afb7c9c6e6..01541eebdcccf7bde82ae6f4fae7d9fff68f0066 100644 (file)
 
 #include "AlidNdPtAnalysisPbPbAOD.h"
 
+#include "AliAnalysisTaskSE.h"
 
 using namespace std;
 
 ClassImp(AlidNdPtAnalysisPbPbAOD)
 
-
-
 AlidNdPtAnalysisPbPbAOD::AlidNdPtAnalysisPbPbAOD(const char *name) : AliAnalysisTaskSE(name),
 fOutputList(0),
 // Histograms
@@ -66,6 +65,7 @@ fCrossCheckRowsLength(0),
 fCrossCheckClusterLength(0),
 fCrossCheckRowsLengthAcc(0),
 fCrossCheckClusterLengthAcc(0),
+fCutSettings(0),
 //global
 fIsMonteCarlo(0),
 // event cut variables
@@ -149,14 +149,21 @@ fBinsPhi(0)
 
 // destructor
 AlidNdPtAnalysisPbPbAOD::~AlidNdPtAnalysisPbPbAOD()
-{
-  
+{  
   if(fZvPtEtaCent) delete fZvPtEtaCent; fZvPtEtaCent = 0;
+  if(fPhiPtEtaCent) delete fPhiPtEtaCent; fPhiPtEtaCent = 0;
+  if(fPtResptCent) delete fPtResptCent; fPtResptCent = 0;
   if(fPt) delete fPt; fPt = 0;
+  if(fMCPt) delete fMCPt; fMCPt = 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(fMCRecPrimPhiPtEtaCent) delete fMCRecPrimPhiPtEtaCent; fMCRecPrimPhiPtEtaCent = 0;
+  if(fMCGenPhiPtEtaCent) delete fMCGenPhiPtEtaCent; fMCGenPhiPtEtaCent = 0;
+  if(fMCRecSecPhiPtEtaCent) delete fMCRecSecPhiPtEtaCent; fMCRecSecPhiPtEtaCent = 0;
+  
   if(fEventStatistics) delete fEventStatistics; fEventStatistics = 0;
   if(fEventStatisticsCentrality) delete fEventStatisticsCentrality; fEventStatisticsCentrality = 0;
   if(fMCEventStatisticsCentrality) delete fMCEventStatisticsCentrality; fMCEventStatisticsCentrality = 0;
@@ -174,8 +181,6 @@ AlidNdPtAnalysisPbPbAOD::~AlidNdPtAnalysisPbPbAOD()
   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++)
   {
@@ -183,6 +188,20 @@ AlidNdPtAnalysisPbPbAOD::~AlidNdPtAnalysisPbPbAOD()
     if(fCrossCheckAcc[i]) delete fCrossCheckAcc[i]; fCrossCheckAcc[i] = 0;
   }
   
+  if(fCutPercClusters) delete fCutPercClusters; fCutPercClusters = 0;
+  if(fCutPercCrossed) delete fCutPercCrossed; fCutPercCrossed = 0;
+  if(fCrossCheckRowsLength) delete fCrossCheckRowsLength; fCrossCheckRowsLength = 0;
+  if(fCrossCheckClusterLength) delete fCrossCheckClusterLength; fCrossCheckClusterLength = 0;
+  if(fCrossCheckRowsLengthAcc) delete fCrossCheckRowsLengthAcc; fCrossCheckRowsLengthAcc = 0;
+  if(fCrossCheckClusterLengthAcc) delete fCrossCheckClusterLengthAcc; fCrossCheckClusterLengthAcc = 0;
+  if(fCutSettings) delete fCutSettings; fCutSettings = 0;
+  
+  if(fOutputList)
+  {
+    fOutputList->Clear();
+    delete fOutputList;
+  }
+  fOutputList = 0;
 }
 
 void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
@@ -242,7 +261,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fPhiPtEtaCent->SetBinEdges(1,fBinsPt);
   fPhiPtEtaCent->SetBinEdges(2,fBinsEta);
   fPhiPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  fPhiPtEtaCent->GetAxis(0)->SetTitle("Phi (cm)");
+  fPhiPtEtaCent->GetAxis(0)->SetTitle("Phi");
   fPhiPtEtaCent->GetAxis(1)->SetTitle("Pt (GeV/c)");
   fPhiPtEtaCent->GetAxis(2)->SetTitle("Eta");
   fPhiPtEtaCent->GetAxis(3)->SetTitle("Centrality");
@@ -294,7 +313,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fMCRecPrimPhiPtEtaCent->SetBinEdges(1,fBinsPt);
   fMCRecPrimPhiPtEtaCent->SetBinEdges(2,fBinsEta);
   fMCRecPrimPhiPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  fMCRecPrimPhiPtEtaCent->GetAxis(0)->SetTitle("MC Phi (cm)");
+  fMCRecPrimPhiPtEtaCent->GetAxis(0)->SetTitle("MC Phi");
   fMCRecPrimPhiPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
   fMCRecPrimPhiPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
   fMCRecPrimPhiPtEtaCent->GetAxis(3)->SetTitle("Centrality");
@@ -305,7 +324,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fMCGenPhiPtEtaCent->SetBinEdges(1,fBinsPt);
   fMCGenPhiPtEtaCent->SetBinEdges(2,fBinsEta);
   fMCGenPhiPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  fMCGenPhiPtEtaCent->GetAxis(0)->SetTitle("MC Phi (cm)");
+  fMCGenPhiPtEtaCent->GetAxis(0)->SetTitle("MC Phi");
   fMCGenPhiPtEtaCent->GetAxis(1)->SetTitle("MC Pt (GeV/c)");
   fMCGenPhiPtEtaCent->GetAxis(2)->SetTitle("MC Eta");
   fMCGenPhiPtEtaCent->GetAxis(3)->SetTitle("Centrality");
@@ -316,7 +335,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fMCRecSecPhiPtEtaCent->SetBinEdges(1,fBinsPt);
   fMCRecSecPhiPtEtaCent->SetBinEdges(2,fBinsEta);
   fMCRecSecPhiPtEtaCent->SetBinEdges(3,fBinsCentrality);
-  fMCRecSecPhiPtEtaCent->GetAxis(0)->SetTitle("MC Sec Phi (cm)");
+  fMCRecSecPhiPtEtaCent->GetAxis(0)->SetTitle("MC Sec Phi");
   fMCRecSecPhiPtEtaCent->GetAxis(1)->SetTitle("MC Sec Pt (GeV/c)");
   fMCRecSecPhiPtEtaCent->GetAxis(2)->SetTitle("MC Sec Eta");
   fMCRecSecPhiPtEtaCent->GetAxis(3)->SetTitle("Centrality");
@@ -385,7 +404,7 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   
   
   
-  Int_t binsDCAxyDCAzPtEtaPhi[6] = { 200,200, fPtCheckNbins-1, fEtaCheckNbins-1, 18, fCentralityNbins-1};
+  Int_t binsDCAxyDCAzPtEtaPhi[6] = { 10,10, fPtCheckNbins-1, fEtaCheckNbins-1, 18, fCentralityNbins-1};
   Double_t minDCAxyDCAzPtEtaPhi[6] = { -5, -5, 0, -1.5, 0., 0, };
   Double_t maxDCAxyDCAzPtEtaPhi[6] = { 5., 5., 100, 1.5, 2.*TMath::Pi(), 100};
   
@@ -539,6 +558,9 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fCrossCheckClusterLengthAcc = new TH2F("fCrossCheckClusterLengthAcc","fCrossCheckClusterLengthAcc;Length in TPC;NClusters",170,0,170,170,0,170);
   fCrossCheckClusterLengthAcc->Sumw2();
   
+  fCutSettings = new TH1F("fCutSettings","fCutSettings",100,0,10);
+  fCutSettings->GetYaxis()->SetTitle("cut value");
+  fCutSettings->SetBit(TH1::kCanRebin);
   
   // Add Histos, Profiles etc to List
   fOutputList->Add(fZvPtEtaCent);
@@ -580,6 +602,9 @@ void AlidNdPtAnalysisPbPbAOD::UserCreateOutputObjects()
   fOutputList->Add(fCrossCheckClusterLength);
   fOutputList->Add(fCrossCheckRowsLengthAcc);
   fOutputList->Add(fCrossCheckClusterLengthAcc);
+  fOutputList->Add(fCutSettings);
+  
+  StoreCutSettingsToHistogram();
   
   PostData(1, fOutputList);
 }
@@ -915,6 +940,8 @@ void AlidNdPtAnalysisPbPbAOD::UserExec(Option_t *option)
   
   PostData(1, fOutputList);
   
+  // delete pointers:
+  
 }
 
 Bool_t AlidNdPtAnalysisPbPbAOD::SetRelativeCuts(AliAODEvent *event)
@@ -1014,19 +1041,19 @@ Bool_t AlidNdPtAnalysisPbPbAOD::IsTrackAccepted(AliAODTrack *tr, Double_t dCentr
   
   //   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; }
+  AliExternalTrackParam par(xyz, pxpypz, cv, sign);
+//   AliExternalTrackParam *par = new AliExternalTrackParam(xyz, pxpypz, cv, sign); // high mem consumption!!!!
   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 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
   Double_t dOneOverPt = tr->OneOverPt();
-  Double_t dSigmaOneOverPt = TMath::Sqrt(par->GetSigma1Pt2());
+  Double_t dSigmaOneOverPt = TMath::Sqrt(par.GetSigma1Pt2());
   
   //   hAllCrossedRowsTPC->Fill(dCrossedRowsTPC);
   
@@ -1080,7 +1107,9 @@ Bool_t AlidNdPtAnalysisPbPbAOD::IsTrackAccepted(AliAODTrack *tr, Double_t dCentr
        
        // fill debug histogram for all accepted tracks
        FillDebugHisto(dCheck, dKine, dCentrality, kTRUE);
-
+       
+       // delete pointers
+        
        return kTRUE;
 }
 
@@ -1113,6 +1142,50 @@ Bool_t AlidNdPtAnalysisPbPbAOD::FillDebugHisto(Double_t *dCrossCheckVar, Double_
   
 }
 
+void AlidNdPtAnalysisPbPbAOD::StoreCutSettingsToHistogram()
+{
+    //
+    // this function stores all cut settings to a histograms
+    //
+    
+    fCutSettings->Fill("IsMonteCarlo",fIsMonteCarlo);
+    
+    fCutSettings->Fill("fCutMaxZVertex", fCutMaxZVertex);
+    
+    // kinematic cuts
+    fCutSettings->Fill("fCutPtMin", fCutPtMin);
+    fCutSettings->Fill("fCutPtMax", fCutPtMax);
+    fCutSettings->Fill("fCutEtaMin", fCutEtaMin);
+    fCutSettings->Fill("fCutEtaMax", fCutEtaMax);
+    
+    // track quality cut variables
+    fCutSettings->Fill("fFilterBit", fFilterBit);
+    if(fUseRelativeCuts) fCutSettings->Fill("fUseRelativeCuts", 1);
+    if(fCutRequireTPCRefit) fCutSettings->Fill("fCutRequireTPCRefit", 1);
+    if(fCutRequireITSRefit) fCutSettings->Fill("fCutRequireITSRefit", 1);
+    
+    fCutSettings->Fill("fCutMinNumberOfClusters", fCutMinNumberOfClusters);
+    fCutSettings->Fill("fCutPercMinNumberOfClusters", fCutPercMinNumberOfClusters);
+    fCutSettings->Fill("fCutMinNumberOfCrossedRows", fCutMinNumberOfCrossedRows);
+    fCutSettings->Fill("fCutPercMinNumberOfCrossedRows", fCutPercMinNumberOfCrossedRows);
+    
+    fCutSettings->Fill("fCutMinRatioCrossedRowsOverFindableClustersTPC", fCutMinRatioCrossedRowsOverFindableClustersTPC);
+    fCutSettings->Fill("fCutMaxFractionSharedTPCClusters", fCutMaxFractionSharedTPCClusters);
+    fCutSettings->Fill("fCutMaxDCAToVertexXY", fCutMaxDCAToVertexXY);
+    fCutSettings->Fill("fCutMaxChi2PerClusterITS", fCutMaxChi2PerClusterITS);
+    
+    if(fCutDCAToVertex2D) fCutSettings->Fill("fCutDCAToVertex2D", 1);
+    if(fCutRequireSigmaToVertex) fCutSettings->Fill("fCutRequireSigmaToVertex",1);
+    fCutSettings->Fill("fCutMaxDCAToVertexXYPtDepPar0", fCutMaxDCAToVertexXYPtDepPar0);
+    fCutSettings->Fill("fCutMaxDCAToVertexXYPtDepPar1", fCutMaxDCAToVertexXYPtDepPar1);
+    fCutSettings->Fill("fCutMaxDCAToVertexXYPtDepPar2", fCutMaxDCAToVertexXYPtDepPar2);
+    
+    if(fCutAcceptKinkDaughters) fCutSettings->Fill("fCutAcceptKinkDaughters", 1);
+    fCutSettings->Fill("fCutMaxChi2TPCConstrainedGlobal", fCutMaxChi2TPCConstrainedGlobal);
+    if(fCutLengthInTPCPtDependent) fCutSettings->Fill("fCutLengthInTPCPtDependent", 1);
+    fCutSettings->Fill("fPrefactorLengthInTPCPtDependent", fPrefactorLengthInTPCPtDependent);
+}
+
 Bool_t AlidNdPtAnalysisPbPbAOD::GetDCA(const AliAODTrack *track, AliAODEvent *evt, Double_t d0z0[2])
 {
   // function adapted from AliDielectronVarManager.h
index 01b935462cfdefd872e222d2908ffd5dfaa3959c..ea985ee3381d25f75036c3cf2d98aa80d72c017f 100644 (file)
 // last modified: 08.10.2013
 //------------------------------------------------------------------------------
 
-class iostream;
-
-class TObject;
-class TFile;
-class TCint;
-class THnSparse;
 
-#include "AliAnalysisTaskSE.h"
 
+class iostream;
 
+#include "AliAnalysisTaskSE.h"
+#include "TObject.h"
 #include "TList.h"
 #include "TFile.h"
 #include "TH1.h"
@@ -142,11 +138,14 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     // fill function for cross check histos
     Bool_t FillDebugHisto(Double_t *dCrossCheckVar, Double_t *dKineVar, Double_t dCentrality, Bool_t bIsAccepted);
     
+    // fill function for cut settings
+    void StoreCutSettingsToHistogram();
+    
     // getter for DCA
     Bool_t GetDCA(const AliAODTrack *track, AliAODEvent *evt, Double_t d0z0[2]);
     
-    THnSparseF *GetHistZvPtEtaCent() const { return fZvPtEtaCent; }
-    TH1F *GetHistEventStatistics() const { return fEventStatistics; }
+    THnSparseF * GetHistZvPtEtaCent() const { return fZvPtEtaCent; }
+    TH1F * GetHistEventStatistics() const { return fEventStatistics; }
     
     const char * GetParticleName(Int_t pdg);
     
@@ -182,7 +181,7 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     THnSparseF         *fMCGenPhiPtEtaCent; //-> MC Phi:Pt:Eta:Cent
     THnSparseF         *fMCRecSecPhiPtEtaCent; //-> MC Phi: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        *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
@@ -206,6 +205,7 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     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
+    TH1F        *fCutSettings; // control histo: cut settings
     
     
     // global variables
@@ -235,7 +235,7 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     Double_t   fCutMaxDCAToVertexZ;
     Double_t   fCutMaxDCAToVertexXY;
     Double_t   fCutMaxChi2PerClusterITS;
-    Bool_t     fCutDCAToVertex2D;
+    Bool_t     fCutDCAToVertex2D;
     Bool_t     fCutRequireSigmaToVertex;
     Double_t   fCutMaxDCAToVertexXYPtDepPar0;
     Double_t   fCutMaxDCAToVertexXYPtDepPar1;
@@ -246,15 +246,15 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     Double_t   fPrefactorLengthInTPCPtDependent;
     
     //binning for THNsparse
-    Int_t fMultNbins;
-    Int_t fPtNbins;
-    Int_t fPtCorrNbins;
-    Int_t fPtCheckNbins;
-    Int_t fEtaNbins;
-    Int_t fEtaCheckNbins;
-    Int_t fZvNbins;
-    Int_t fCentralityNbins;
-    Int_t fPhiNbins;
+    Int_t   fMultNbins;
+    Int_t   fPtNbins;
+    Int_t   fPtCorrNbins;
+    Int_t   fPtCheckNbins;
+    Int_t   fEtaNbins;
+    Int_t   fEtaCheckNbins;
+    Int_t   fZvNbins;
+    Int_t   fCentralityNbins;
+    Int_t   fPhiNbins;
     Double_t* fBinsMult; //[fMultNbins]
     Double_t* fBinsPt; //[fPtNbins]
     Double_t* fBinsPtCorr; //[fPtCorrNbins]
@@ -268,7 +268,7 @@ class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
     AlidNdPtAnalysisPbPbAOD(const AlidNdPtAnalysisPbPbAOD&); // not implemented
     AlidNdPtAnalysisPbPbAOD& operator=(const AlidNdPtAnalysisPbPbAOD&); // not implemented  
     
-    ClassDef(AlidNdPtAnalysisPbPbAOD,4); // has to be at least 1, otherwise not streamable...
+    ClassDef(AlidNdPtAnalysisPbPbAOD,5); // has to be at least 1, otherwise not streamable...
 };
 
 #endif
index e67e76cea3dbd843e3b205109b510794259de96d..e0260569d4633aa18b03fd6d990e677ef032d8c3 100644 (file)
@@ -176,6 +176,19 @@ void AliAnalysisDeuteronpA::UserCreateOutputObjects()
   const Int_t kPtBins = 28;
   const Int_t kMultBins = 11;
   const Int_t kDcaBins = 38;
+
+
+  //different binning for YCMS in pA to cover detector acceptance
+  Double_t kYlowBorder = -0.6;
+  Double_t kYhighBorder = 0.6;
+  Double_t kYBins = 12;
+
+  if (fRapCMSpA){
+    kYlowBorder = -0.1;
+    kYhighBorder = 1.1;
+    kYBins = 12;
+  }
+
   //
   // sort pT-bins ..
   //
@@ -203,10 +216,10 @@ void AliAnalysisDeuteronpA::UserCreateOutputObjects()
   // (8..) dca_xy
   // (9.) CODE -- only MC 0-generated, 1-true rec. primaries, 2-misident prim, 3-second weak, 4-second material, 5-misident sec
   //
-  //                              0,           1,           2,  3,      4,    5,    6,    7,       8
-  Int_t    binsHistReal[9] = {   3,   kMultBins,     kPtBins,  2,      12,   50,    2,  100, kDcaBins};
-  Double_t xminHistReal[9] = {-0.5,        -0.5,           0, -2,    -0.6,   -5,- 0.5, -2.5,       -3};
-  Double_t xmaxHistReal[9] = { 2.5,        10.5,           3,  2,     0.6,    5,  1.5,  2.5,        3};
+  //                              0,           1,           2,  3,      4,              5,    6,    7,       8
+  Int_t    binsHistReal[9] = {   3,   kMultBins,     kPtBins,  2,      kYBins      ,   50,    2,  100, kDcaBins};
+  Double_t xminHistReal[9] = {-0.5,        -0.5,           0, -2,      kYlowBorder ,   -5,- 0.5, -2.5,       -3};
+  Double_t xmaxHistReal[9] = { 2.5,        10.5,           3,  2,      kYhighBorder,    5,  1.5,  2.5,        3};
   fHistRealTracks = new THnSparseF("fHistRealTracks","real tracks",9,binsHistReal,xminHistReal,xmaxHistReal);
   //
   fHistRealTracks->GetAxis(2)->Set(kPtBins, binsPt);
@@ -220,10 +233,10 @@ void AliAnalysisDeuteronpA::UserCreateOutputObjects()
   //
   fHistTofQA = new TH2F("fHistTofQA","TOF-QA",200,-4.,4.,400,0,1.1);
   fListHist->Add(fHistTofQA);
-  //                            0,            1,           2,  3,      4,   5,    6,    7,        8,    9
-  Int_t    binsHistMC[10] = {   3,    kMultBins,     kPtBins,  2,     12,  50,    2,  100, kDcaBins,    6};
-  Double_t xminHistMC[10] = {-0.5,         -0.5,           0, -2,   -0.6,  -5,- 0.5, -2.5,       -3, -0.5};
-  Double_t xmaxHistMC[10] = { 2.5,         10.5,           3,  2,    0.6,   5,  1.5,  2.5,        3,  5.5};
+  //                            0,            1,           2,  3,      4,            5,    6,    7,        8,    9
+  Int_t    binsHistMC[10] = {   3,    kMultBins,     kPtBins,  2,    kYBins      ,  50,    2,  100, kDcaBins,    6};
+  Double_t xminHistMC[10] = {-0.5,         -0.5,           0, -2,    kYlowBorder ,  -5,- 0.5, -2.5,       -3, -0.5};
+  Double_t xmaxHistMC[10] = { 2.5,         10.5,           3,  2,    kYhighBorder,   5,  1.5,  2.5,        3,  5.5};
   //
   // different binning for CODE axis, if we want to save motherPDG
   //
@@ -421,7 +434,7 @@ void AliAnalysisDeuteronpA::UserExec(Option_t *)
       //
       Double_t xv = trackMC->Vx();
       Double_t yv = trackMC->Vy();
-      Double_t zv = trackMC->Vz();
+      //Double_t zv = trackMC->Vz();
       Double_t dxy = 0;
       dxy = TMath::Sqrt(xv*xv + yv*yv); // so stupid to avoid warnings
       //Double_t dz = 0;
index ba654fca7d9a9af80509ada62ff5fb380b180d5e..718e2ef9228c8a0f21ef940f0678a18d694deaf8 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 8f692c3781551c085df74a434690305fc821c378..acbbc9f039d7890bf1c3479669f75417f97a9ef4 100644 (file)
@@ -28,9 +28,9 @@ ClassImp(AliAnalysisNucleiMass)
 //_____________________________________________________________________________
 AliAnalysisNucleiMass::AliAnalysisNucleiMass():
   AliAnalysisTaskSE(),
-//Centrality(NULL),                         
+  Centrality(),                         
   FilterBit(16),                                
-//  EtaLimit(NULL),                           
+  EtaLimit(),                           
   DCAxyCut(0.1),                               
   DCAzCut(1000.),                                
   NsigmaTpcCut(2.0),                           
@@ -46,6 +46,12 @@ AliAnalysisNucleiMass::AliAnalysisNucleiMass():
   fEvent(NULL),
   fPIDResponse(NULL)
 {
+  Centrality[0]=0.0;
+  Centrality[1]=100.0;
+
+  EtaLimit[0]=-99.0;
+  EtaLimit[1]=99.0;
+
   fList[0]=new TList();
   fList[0]->SetName("results");
   
@@ -55,9 +61,9 @@ AliAnalysisNucleiMass::AliAnalysisNucleiMass():
 //______________________________________________________________________________
 AliAnalysisNucleiMass::AliAnalysisNucleiMass(const char *name):
   AliAnalysisTaskSE(name),
-  //Centrality(NULL),                         
+  Centrality(),                         
   FilterBit(16),                                
-  //EtaLimit(NULL),                           
+  EtaLimit(),                           
   DCAxyCut(0.1),                               
   DCAzCut(1000.),                                
   NsigmaTpcCut(2.0),                           
@@ -73,6 +79,13 @@ AliAnalysisNucleiMass::AliAnalysisNucleiMass(const char *name):
   fEvent(NULL),
   fPIDResponse(NULL)
 {
+
+  Centrality[0]=0.0;
+  Centrality[1]=100.0;
+
+  EtaLimit[0]=-99.0;
+  EtaLimit[1]=99.0;
+
   fList[0]=new TList();
   DefineOutput(1, TList::Class());
   fList[0]->SetName("results");
@@ -141,14 +154,14 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
     hZvertex[iB][0] = new TH1F("hZvertex_Selected","Vertex distribution of selected events;z vertex (cm)",240,-30,30);
     hZvertex[iB][1] = new TH1F("hZvertex_Analyzed","Vertex distribution of analyzed events;z vertex (cm)",240,-30,30);
     
-    hEta[iB] = new TH1F("hEta_Analyzed","|#eta| distribution after the track cuts;|#eta|",100,0.0,1.0);
+    hEta[iB] = new TH1F("hEta_Analyzed","|#eta| distribution after the track cuts;|#eta|",200,-1.0,1.0);
     
     hPhi[iB] = new TH1F("hPhi_Analyzed","#phi distribution after the track cuts;#phi (rad.)",90,0,6.3);//Each TRD supermodule is divided for 5 (DeltaPhi(TRD)=0.35 theoretical)
     
     Int_t hbins[2];
-    if(kSignalCheck!=0) {hbins[0]=100; hbins[1]=90;}
+    if(kSignalCheck!=0) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=100; hbins[1]=90;} to reduce RAM consuming (toram)
     else {hbins[0]=1; hbins[1]=1;}
-    fEtaPhi[iB] = new TH2F("fEtaPhi_Analyzed","|#eta| vs. #phi after the track cuts;|#eta|;#phi (rad.)",hbins[0],0.0,1.0,hbins[1],0,6.3);
+    fEtaPhi[iB] = new TH2F("fEtaPhi_Analyzed","#eta vs. #phi after the track cuts;|#eta|;#phi (rad.)",hbins[0],-1.0,1.0,hbins[1],0,6.3);
 
     hNTpcCluster[iB] = new TH1F("hNTpcCluster","Number of the TPC clusters after the track cuts;n_{cl}^{TPC}",300,0,300);
 
@@ -156,7 +169,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
 
     if(kSignalCheck==1) {hbins[0]=500; hbins[1]=2000;}
     else if(kSignalCheck==0) {hbins[0]=1; hbins[1]=1;}
-    else if(kSignalCheck==2) {hbins[0]=100; hbins[1]=500;}
+    else if(kSignalCheck==2) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=100; hbins[1]=500;} toram
     fdEdxVSp[iB][0] = new TH2F("fdEdxVSp_pos","dE/dx vs p (positive charge); p/|z| (GeV/c); dE/dx_{TPC} (a.u.)",hbins[0],0,5,hbins[1],0,1000);
     fdEdxVSp[iB][1] = new TH2F("fdEdxVSp_neg","dE/dx vs p (negative charge); p/|z| (GeV/c); dE/dx_{TPC} (a.u.)",hbins[0],0,5,hbins[1],0,1000);
 
@@ -165,12 +178,12 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
     for(Int_t i=0;i<nPart;i++) {
       snprintf(name_hDeDxExp[i],200,"hDeDxExp_%s",namePart[i]);
       snprintf(title_hDeDxExp[i],200,"Expected dE/dx of %s in the TPC;p/|z| (GeV/c);dE/dx_{TPC} (a.u.)",namePart[i]);
-      hDeDxExp[iB][i] = new TProfile(name_hDeDxExp[i],title_hDeDxExp[i],500,0,5,0,1000,"");
+      hDeDxExp[iB][i] = new TProfile(name_hDeDxExp[i],title_hDeDxExp[i],1,0,5,0,1,"");//,500,0,5,0,1000,""); toram
     }
 
     Char_t name_fNsigmaTpc[nPart][200];
     Char_t title_fNsigmaTpc[nPart][200];
-    if(kSignalCheck==1) {hbins[0]=100; hbins[1]=100;}
+    if(kSignalCheck==1) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=100; hbins[1]=100;} toram
     else {hbins[0]=1; hbins[1]=1;}
     for(Int_t i=0;i<nPart;i++) {
       snprintf(name_fNsigmaTpc[i],200,"NsigmaTpc_%s",namePart[i]);
@@ -178,7 +191,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
       fNsigmaTpc[iB][i] = new TH2F(name_fNsigmaTpc[i],title_fNsigmaTpc[i],hbins[0],0,5,hbins[1],-5,5);
     }
     
-    if(kSignalCheck>1) {hbins[0]=100; hbins[1]=100;}
+    if(kSignalCheck>0) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=100; hbins[1]=100;} toram
     else if(kSignalCheck==0) {hbins[0]=1; hbins[1]=1;}
     Char_t name_fNsigmaTpc_kTOF[nSpec][200];
     Char_t title_fNsigmaTpc_kTOF[nSpec][200];
@@ -190,7 +203,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
 
     if(kSignalCheck==1) {hbins[0]=1000; hbins[1]=1300;}
     else if(kSignalCheck==0) {hbins[0]=1; hbins[1]=1;}
-    else if(kSignalCheck==2) {hbins[0]=100; hbins[1]=260;}
+    else if(kSignalCheck==2) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=100; hbins[1]=260;}
     fBetaTofVSp[iB][0] = new TH2F("fBetaTofVSp_pos","#beta_{TOF} vs p/|z| (positive charge);p(GeV/c);#beta_{TOF}",hbins[0],0,5,hbins[1],0.4,1.05);
     fBetaTofVSp[iB][1] = new TH2F("fBetaTofVSp_neg","#beta_{TOF} vs p/|z| (negative charge);p(GeV/c);#beta_{TOF}",hbins[0],0,5,hbins[1],0.4,1.05);
     
@@ -199,7 +212,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
     for(Int_t i=0;i<nPart;i++) {
       snprintf(name_hBetaExp[i],200,"hBetaTofVsP_Exp_%s",namePart[i]);
       snprintf(title_hBetaExp[i],200,"Expected #beta_{TOF} vs p/|z| of %s;p/|z| (GeV/c); #beta_{TOF}",namePart[i]);
-      hBetaExp[iB][i] = new TProfile(name_hBetaExp[i],title_hBetaExp[i],400,0,5,0.4,1.05,"");
+      hBetaExp[iB][i] = new TProfile(name_hBetaExp[i],title_hBetaExp[i],1,0,5,0.4,1.05,"");//,400,0,5,0.4,1.05,""); toram
     }
     
     Char_t name_fNsigmaTof[nPart][200];
@@ -229,7 +242,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
 
     if(kSignalCheck==1) {hbins[0]=8000; hbins[1]=100;}
     else if(kSignalCheck==0) {hbins[0]=1; hbins[1]=1;}
-    else if(kSignalCheck==2) {hbins[0]=1000; hbins[1]=100;}
+    else if(kSignalCheck==2) {hbins[0]=1; hbins[1]=1;}// {hbins[0]=1000; hbins[1]=100;} toram
     fM2vsP_NoTpcCut[iB][1][0] = new TH2F("fM2vsP_NoTpcCut_DCAxyCut_pos","m^{2}/z^{2}_{TOF} vs p/|z| (positive charge) with DCAxy cut;m^{2}/z^{2}_{TOF} (GeV^{2}/c^{4});p/|z| (GeV/c)",hbins[0],0,10,hbins[1],0,5);
     fM2vsP_NoTpcCut[iB][1][1] = new TH2F("fM2vsP_NoTpcCut_DCAxyCut_neg","m^{2}/z^{2}_{TOF} vs p/|z| (negative charge) with DCAxy cut;m^{2}/z^{2}_{TOF} (GeV^{2}/c^{4});p/|z| (GeV/c)",hbins[0],0,10,hbins[1],0,5);
 
@@ -249,7 +262,7 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
       
       if(kSignalCheck==1) {hbins[0]=8000; hbins[1]=100;}
       else if(kSignalCheck==0) {hbins[0]=1; hbins[1]=1;}
-      else if(kSignalCheck==2) {hbins[0]=1000; hbins[1]=100;}
+      else if(kSignalCheck==2) {hbins[0]=1; hbins[1]=1;}//{hbins[0]=1000; hbins[1]=100;} toram
       fM2vsP[iB][1][i] = new TH2F(name_fM2vsP[1][i],title_fM2vsP[1][i],hbins[0],0,10,hbins[1],0,5);
     }
     
@@ -368,82 +381,16 @@ void AliAnalysisNucleiMass::UserCreateOutputObjects()
     snprintf(nameTemp[8],200,"#bar{d}");
     snprintf(nameTemp[9],200,"#bar{He3}");
     
-    Double_t pars_fPmeanVsBGcorr[10][3];
-    //particle
-    for(Int_t i=0;i<5;i++) {
-      if(i==0) {//pi
-       pars_fPmeanVsBGcorr[i][0]=4.89956e-02;
-       pars_fPmeanVsBGcorr[i][1]=-6.46308e-01;
-       pars_fPmeanVsBGcorr[i][2]=1.00462e+00;
-      }
-      else if(i==1) {//K
-       pars_fPmeanVsBGcorr[i][0]=3.06216e-02;
-       pars_fPmeanVsBGcorr[i][1]=-2.10247e+00;
-       pars_fPmeanVsBGcorr[i][2]=9.97142e-01;
-      }
-      else if(i==2) {//p
-       pars_fPmeanVsBGcorr[i][0]=1.58652e-02;
-       pars_fPmeanVsBGcorr[i][1]=-2.64898e+00;
-       pars_fPmeanVsBGcorr[i][2]=9.97176e-01;
-      }
-      else if(i==3) {//d
-       pars_fPmeanVsBGcorr[i][0]=0.011233;
-       pars_fPmeanVsBGcorr[i][1]=-2.389911;
-       pars_fPmeanVsBGcorr[i][2]=0.997176;
-      }
-      else if(i==4) {//He3
-       pars_fPmeanVsBGcorr[i][0]=0.030884;
-       pars_fPmeanVsBGcorr[i][1]=-2.124273;
-       pars_fPmeanVsBGcorr[i][2]=0.997176;
-      }
-    }
-    //antiparticle
-    if(iMtof==8) {
-      for(Int_t i=5;i<10;i++) {
-       if(i==0+5) {//pi-
-         pars_fPmeanVsBGcorr[i][0]=6.86083e-02;
-         pars_fPmeanVsBGcorr[i][1]=-8.37051e-01;
-         pars_fPmeanVsBGcorr[i][2]=1.00589e+00;
-       }
-       else if(i==1+5) {//K-
-         pars_fPmeanVsBGcorr[i][0]=3.26139e-02;
-         pars_fPmeanVsBGcorr[i][1]=-2.08158e+00;
-         pars_fPmeanVsBGcorr[i][2]=9.99782e-01;
-       }
-       else if(i==2+5) {//pbar
-         pars_fPmeanVsBGcorr[i][0]=1.58118e-02;
-         pars_fPmeanVsBGcorr[i][1]=-2.66903e+00;
-         pars_fPmeanVsBGcorr[i][2]=9.99201e-01;
-       }
-       else if(i==3+5) {//dbar
-         pars_fPmeanVsBGcorr[i][0]=0.011195;
-         pars_fPmeanVsBGcorr[i][1]=-2.407999;
-         pars_fPmeanVsBGcorr[i][2]=0.999201;
-       }
-       else if(i==4+5) {//He3bar
-         pars_fPmeanVsBGcorr[i][0]=0.030780;
-         pars_fPmeanVsBGcorr[i][1]=-2.140350;
-         pars_fPmeanVsBGcorr[i][2]=0.999201;
-       }
-      }
-    }
-    else {//else if(iMtof!=8)
-      for(Int_t i=5;i<10;i++) {
-       pars_fPmeanVsBGcorr[i][0]=pars_fPmeanVsBGcorr[i-5][0];
-       pars_fPmeanVsBGcorr[i][1]=pars_fPmeanVsBGcorr[i-5][1];
-       pars_fPmeanVsBGcorr[i][2]=pars_fPmeanVsBGcorr[i-5][2];
-      }
-    }
-    
     Char_t name_fPmeanVsBGcorr[10][200];
-    
     for(Int_t i=0;i<10;i++) {
       snprintf(name_fPmeanVsBGcorr[i],200,"fPmeanVsBGcorr_%s",nameTemp[i]);
-      fPmeanVsBGcorr[i]=new TF1(name_fPmeanVsBGcorr[i],"[2]-[0]*TMath::Power(x,[1]);p_{vtx}/m;<p>/p",0.0001,100);
-      fPmeanVsBGcorr[i]->SetParameters(pars_fPmeanVsBGcorr[i]);
-      fPmeanVsBGcorr[i]->SetNpx(fPmeanVsBGcorr[i]->GetNpx()*10);
+      fPmeanVsBGcorr[0][i]=new TF1(name_fPmeanVsBGcorr[i],"[2]-[0]*TMath::Power(x,[1]);p_{vtx}/m;<p>/p",0.0001,100);
+      fPmeanVsBGcorr[1][i]=new TF1(name_fPmeanVsBGcorr[i],"[2]-[0]*TMath::Power(x,[1]);p_{vtx}/m;<p>/p",0.0001,100);
+      //fPmeanVsBGcorr[i]->SetParameters(pars_fPmeanVsBGcorr[i]);
+      //fPmeanVsBGcorr[i]->SetNpx(fPmeanVsBGcorr[i]->GetNpx()*10);
     }
-
+    SetPmeanCorrections();
+       
     Char_t name_prPmeanVsBGcorr[10][200];
     Char_t title_prPmeanVsBGcorr[10][200];
    
@@ -590,7 +537,7 @@ void AliAnalysisNucleiMass::UserExec(Option_t *)
       }
       
      //For the geometrical cuts
-      Double_t etaAbs = TMath::Abs(track->Eta());
+      Double_t eta = track->Eta();
       
       Bool_t trkFlag = 0;
       trkFlag = ((AliAODTrack *) track)->TestFilterBit(FilterBit);
@@ -604,7 +551,7 @@ void AliAnalysisNucleiMass::UserExec(Option_t *)
       if(nTpcCluster>NminTpcCluster) isMinTpcCluster=kTRUE;
 
       //-------------------------------------start TRACK CUTS----------------------------------
-      if ((track->Pt() < 0.2) || (etaAbs<EtaLimit[0]) || (etaAbs>EtaLimit[1]) || !trkFlag || !isMinTpcCluster)
+      if ((track->Pt() < 0.2) || (eta<EtaLimit[0]) || (eta>EtaLimit[1]) || !trkFlag || !isMinTpcCluster)
        continue;
       
       //Vertex determination
@@ -636,9 +583,9 @@ void AliAnalysisNucleiMass::UserExec(Option_t *)
       //-------------------------------------Track info--------------------------------------
       Double_t phi= track->Phi();
       
-      hEta[iBconf]->Fill(etaAbs);
+      hEta[iBconf]->Fill(eta);
       hPhi[iBconf]->Fill(phi);
-      fEtaPhi[iBconf]->Fill(etaAbs,phi);
+      fEtaPhi[iBconf]->Fill(eta,phi);
       hNTpcCluster[iBconf]->Fill(nTpcCluster);
       hNTrdSlices[iBconf]->Fill(nTrdSlices);
        
@@ -670,7 +617,7 @@ void AliAnalysisNucleiMass::UserExec(Option_t *)
       //Correction of the momentum to the vertex for (anti)nuclei
       Double_t pC[9];
       for(Int_t iS=0;iS<9;iS++)        pC[iS]=p;
-      this->MomVertexCorrection(p,pC,etaAbs,FlagPid);
+      this->MomVertexCorrection(p,pC,eta,FlagPid);
 
       //More TPC info:
       for(Int_t iS=0;iS<9;iS++){
@@ -740,7 +687,7 @@ void AliAnalysisNucleiMass::UserExec(Option_t *)
        this->GetZTpc(dedx,pTPC,M2,Z2);
        
        Double_t Mass2[9];
-       //-----------------------------M2 as a function of the momentum to the primary vertex if iMtof==1---------------------------------
+       //-----------------------------M2 as a function of momentum to the primary vertex if iMtof==1---------------------------------
        if(iMtof==1) this->GetMassFromPvertexCorrected(beta,pC,Mass2);
 
        if(iMtof>1) this->GetPmeanVsBetaGamma(exptimes,pC,FlagPid,FlagPidTof,charge,DCAxy);
@@ -1018,12 +965,12 @@ void AliAnalysisNucleiMass::GetMassFromMeanMom(Double_t beta, Double_t *IntTimes
   for(Int_t iS=0;iS<9;iS++) {
     if(iS==2 || iS==3 || iS==4 || iS==5 || iS==7) {
       if(charge>0) {
-       if(iS!=7) p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iS-2]->Eval(pVtx[iS]/massOverZ[iS]);
-       else p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iS-3]->Eval(pVtx[iS]/massOverZ[iS]);
+       if(iS!=7) p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iBconf][iS-2]->Eval(pVtx[iS]/massOverZ[iS]);
+       else p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iBconf][iS-3]->Eval(pVtx[iS]/massOverZ[iS]);
       }
       else if(charge<0) {
-       if(iS!=7) p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iS+3]->Eval(pVtx[iS]/massOverZ[iS]);
-       else p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iS+2]->Eval(pVtx[iS]/massOverZ[iS]);
+       if(iS!=7) p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iBconf][iS+3]->Eval(pVtx[iS]/massOverZ[iS]);
+       else p2Exp[iS]=pVtx[iS]*fPmeanVsBGcorr[iBconf][iS+2]->Eval(pVtx[iS]/massOverZ[iS]);
       }
       p2Exp[iS]*=p2Exp[iS];
     }
@@ -1066,4 +1013,275 @@ void AliAnalysisNucleiMass::GetMassFromMeanMom(Double_t beta, Double_t *IntTimes
   return;
   
 }
+//________________________________________________________________________________________
+void AliAnalysisNucleiMass::SetPmeanCorrections(){
+  
+  //iMtof==8 -> different particle and antiparticle parameterization 
+  
+  Double_t pars_fPmeanVsBGcorr[nBconf][10][3];
+  //particle
+
+  Double_t etaMin=0.0;
+  Double_t etaMax=0.8;
+
+  if(EtaLimit[0]<0.0 || EtaLimit[1]<0.0) {
+    etaMin=TMath::Abs(EtaLimit[1]);
+    etaMax=TMath::Abs(EtaLimit[0]);
+  }
+  else {
+    etaMin=TMath::Abs(EtaLimit[0]);
+    etaMax=TMath::Abs(EtaLimit[1]);
+  }
+
+  if(etaMin>-0.00001 && etaMax<0.10001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fAAA\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=4.16853e-02; pars_fPmeanVsBGcorr[0][i][1]=-7.67091e-01; pars_fPmeanVsBGcorr[0][i][2]=9.98035e-01;//B--
+       pars_fPmeanVsBGcorr[1][i][0]=5.51380e-02; pars_fPmeanVsBGcorr[1][i][1]=-7.58112e-01; pars_fPmeanVsBGcorr[1][i][2]=1.00360e+00;//B++
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=2.73697e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.43042e+00; pars_fPmeanVsBGcorr[0][i][2]=9.93148e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.19397e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.08037e+00; pars_fPmeanVsBGcorr[1][i][2]=9.98016e-01;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.35721e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.80958e+00; pars_fPmeanVsBGcorr[0][i][2]=9.93925e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.63564e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.55914e+00; pars_fPmeanVsBGcorr[1][i][2]=9.98106e-01;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.009609; pars_fPmeanVsBGcorr[0][i][1]=-2.534810; pars_fPmeanVsBGcorr[0][i][2]=0.993507;
+       pars_fPmeanVsBGcorr[1][i][0]=0.011580; pars_fPmeanVsBGcorr[1][i][1]=-2.308857; pars_fPmeanVsBGcorr[1][i][2]=0.998126;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.026420; pars_fPmeanVsBGcorr[0][i][1]=-2.253066; pars_fPmeanVsBGcorr[0][i][2]=0.993507;
+       pars_fPmeanVsBGcorr[1][i][0]=0.031840; pars_fPmeanVsBGcorr[1][i][1]=-2.052228; pars_fPmeanVsBGcorr[1][i][2]=0.998126;
+      }
+    }
+  }
+  else if(etaMin>0.09999 && etaMax<0.20001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fBBB\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=4.98872e-02; pars_fPmeanVsBGcorr[0][i][1]=-3.56884e-01; pars_fPmeanVsBGcorr[0][i][2]=1.01356e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=6.11287e-02; pars_fPmeanVsBGcorr[1][i][1]=-3.65072e-01; pars_fPmeanVsBGcorr[1][i][2]=1.02074e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=2.85027e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.04376e+00; pars_fPmeanVsBGcorr[0][i][2]=9.94804e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.30937e-02; pars_fPmeanVsBGcorr[1][i][1]=-1.72959e+00; pars_fPmeanVsBGcorr[1][i][2]=9.99966e-01;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.38640e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.71621e+00; pars_fPmeanVsBGcorr[0][i][2]=9.94151e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.74869e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.38269e+00; pars_fPmeanVsBGcorr[1][i][2]=9.98776e-01;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.009816; pars_fPmeanVsBGcorr[0][i][1]=-2.450567; pars_fPmeanVsBGcorr[0][i][2]=0.994465;
+       pars_fPmeanVsBGcorr[1][i][0]=0.012381; pars_fPmeanVsBGcorr[1][i][1]=-2.149671; pars_fPmeanVsBGcorr[1][i][2]=0.999302;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.026988; pars_fPmeanVsBGcorr[0][i][1]=-2.178186; pars_fPmeanVsBGcorr[0][i][2]=0.994465;
+       pars_fPmeanVsBGcorr[1][i][0]=0.034041; pars_fPmeanVsBGcorr[1][i][1]=-1.910736; pars_fPmeanVsBGcorr[1][i][2]=0.999302;
+      }
+    }
+  }
+  else if(etaMin>0.19999 && etaMax<0.30001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fCCC\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=4.71844e-02; pars_fPmeanVsBGcorr[0][i][1]=-6.24048e-01; pars_fPmeanVsBGcorr[0][i][2]=1.00525e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=5.45281e-02; pars_fPmeanVsBGcorr[1][i][1]=-5.87331e-01; pars_fPmeanVsBGcorr[1][i][2]=1.01029e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=2.92060e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.15537e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97130e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.24550e-02; pars_fPmeanVsBGcorr[1][i][1]=-1.97289e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00059e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.33594e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.86707e+00; pars_fPmeanVsBGcorr[0][i][2]=9.96053e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.57187e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.62957e+00; pars_fPmeanVsBGcorr[1][i][2]=9.99431e-01;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.009458; pars_fPmeanVsBGcorr[0][i][1]=-2.586677; pars_fPmeanVsBGcorr[0][i][2]=0.996592;
+       pars_fPmeanVsBGcorr[1][i][0]=0.011129; pars_fPmeanVsBGcorr[1][i][1]=-2.372404; pars_fPmeanVsBGcorr[1][i][2]=1.000024;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.026006; pars_fPmeanVsBGcorr[0][i][1]=-2.299168; pars_fPmeanVsBGcorr[0][i][2]=0.996592;
+       pars_fPmeanVsBGcorr[1][i][0]=0.030599; pars_fPmeanVsBGcorr[1][i][1]=-2.108711; pars_fPmeanVsBGcorr[1][i][2]=1.000024;
+      }
+    }
+  }
+  else if(etaMin>0.29999 && etaMax<0.40001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fDDD\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=5.25262e-02; pars_fPmeanVsBGcorr[0][i][1]=-3.04325e-01; pars_fPmeanVsBGcorr[0][i][2]=1.02056e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=5.70585e-02; pars_fPmeanVsBGcorr[1][i][1]=-5.95375e-01; pars_fPmeanVsBGcorr[1][i][2]=1.01130e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=2.96035e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.17931e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97539e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.35067e-02; pars_fPmeanVsBGcorr[1][i][1]=-1.99656e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00128e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.44529e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.77844e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97130e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.68180e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.56489e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00070e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.010233; pars_fPmeanVsBGcorr[0][i][1]=-2.506714; pars_fPmeanVsBGcorr[0][i][2]=0.997341;
+       pars_fPmeanVsBGcorr[1][i][0]=0.011907; pars_fPmeanVsBGcorr[1][i][1]=-2.314052; pars_fPmeanVsBGcorr[1][i][2]=1.001048;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.028135; pars_fPmeanVsBGcorr[0][i][1]=-2.228093; pars_fPmeanVsBGcorr[0][i][2]=0.997341;
+       pars_fPmeanVsBGcorr[1][i][0]=0.032739; pars_fPmeanVsBGcorr[1][i][1]=-2.056845; pars_fPmeanVsBGcorr[1][i][2]=1.001048;
+      }
+    }
+  }
+  else if(etaMin>0.39999 && etaMax<0.50001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fEEE\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=5.72833e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.51868e-01; pars_fPmeanVsBGcorr[0][i][2]=1.02665e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=6.59446e-02; pars_fPmeanVsBGcorr[1][i][1]=-9.09587e-01; pars_fPmeanVsBGcorr[1][i][2]=1.00472e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=3.00754e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.18175e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97758e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.36764e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.08206e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00094e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.54832e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.70549e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97921e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.75353e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.52898e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00121e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.010962; pars_fPmeanVsBGcorr[0][i][1]=-2.440895; pars_fPmeanVsBGcorr[0][i][2]=0.997846;
+       pars_fPmeanVsBGcorr[1][i][0]=0.012415; pars_fPmeanVsBGcorr[1][i][1]=-2.281648; pars_fPmeanVsBGcorr[1][i][2]=1.001189;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.030140; pars_fPmeanVsBGcorr[0][i][1]=-2.169590; pars_fPmeanVsBGcorr[0][i][2]=0.997846;
+       pars_fPmeanVsBGcorr[1][i][0]=0.034135; pars_fPmeanVsBGcorr[1][i][1]=-2.028043; pars_fPmeanVsBGcorr[1][i][2]=1.001189;
+      }
+    }
+  }
+  else if(etaMin>0.49999 && etaMax<0.60001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fFFF\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=5.29436e-02; pars_fPmeanVsBGcorr[0][i][1]=-5.04070e-01; pars_fPmeanVsBGcorr[0][i][2]=1.00951e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=1.04356e-01; pars_fPmeanVsBGcorr[1][i][1]=-1.19297e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00197e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=3.36237e-02; pars_fPmeanVsBGcorr[0][i][1]=-1.89739e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97921e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.76386e-02; pars_fPmeanVsBGcorr[1][i][1]=-1.89484e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00097e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.93889e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.38744e+00; pars_fPmeanVsBGcorr[0][i][2]=9.98551e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=2.12666e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.29606e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00174e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.013727; pars_fPmeanVsBGcorr[0][i][1]=-2.153951; pars_fPmeanVsBGcorr[0][i][2]=0.998275;
+       pars_fPmeanVsBGcorr[1][i][0]=0.015057; pars_fPmeanVsBGcorr[1][i][1]=-2.071511; pars_fPmeanVsBGcorr[1][i][2]=1.001396;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.037743; pars_fPmeanVsBGcorr[0][i][1]=-1.914539; pars_fPmeanVsBGcorr[0][i][2]=0.998275;
+       pars_fPmeanVsBGcorr[1][i][0]=0.041398; pars_fPmeanVsBGcorr[1][i][1]=-1.841262; pars_fPmeanVsBGcorr[1][i][2]=1.001396;
+      }
+    }
+  }
+  else if(etaMin>0.59999 && etaMax<0.70001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fGGG\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=7.18462e-02; pars_fPmeanVsBGcorr[0][i][1]=-1.15676e+00; pars_fPmeanVsBGcorr[0][i][2]=9.99111e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=8.52428e-02; pars_fPmeanVsBGcorr[1][i][1]=-9.11048e-01; pars_fPmeanVsBGcorr[1][i][2]=1.00777e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=3.32328e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.30015e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97683e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.88555e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.18109e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00130e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.71488e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.73349e+00; pars_fPmeanVsBGcorr[0][i][2]=9.98517e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.89105e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.65564e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00159e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.012141; pars_fPmeanVsBGcorr[0][i][1]=-2.466162; pars_fPmeanVsBGcorr[0][i][2]=0.998125;
+       pars_fPmeanVsBGcorr[1][i][0]=0.013389; pars_fPmeanVsBGcorr[1][i][1]=-2.395927; pars_fPmeanVsBGcorr[1][i][2]=1.001633;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.033383; pars_fPmeanVsBGcorr[0][i][1]=-2.192048; pars_fPmeanVsBGcorr[0][i][2]=0.998125;
+       pars_fPmeanVsBGcorr[1][i][0]=0.036812; pars_fPmeanVsBGcorr[1][i][1]=-2.129620; pars_fPmeanVsBGcorr[1][i][2]=1.001633;
+      }
+    }
+  }
+  else if(etaMin>0.69999 && etaMax<0.80001) {
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fHHH\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=9.56419e-02; pars_fPmeanVsBGcorr[0][i][1]=-1.31941e+00; pars_fPmeanVsBGcorr[0][i][2]=9.98375e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=8.30340e-02; pars_fPmeanVsBGcorr[1][i][1]=-4.46775e-01; pars_fPmeanVsBGcorr[1][i][2]=1.02721e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=3.55532e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.25782e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97746e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=4.26998e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.10431e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00185e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.87103e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.65814e+00; pars_fPmeanVsBGcorr[0][i][2]=9.98847e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=2.07010e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.60124e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00210e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.013247; pars_fPmeanVsBGcorr[0][i][1]=-2.398177; pars_fPmeanVsBGcorr[0][i][2]=0.998269;
+       pars_fPmeanVsBGcorr[1][i][0]=0.014656; pars_fPmeanVsBGcorr[1][i][1]=-2.346847; pars_fPmeanVsBGcorr[1][i][2]=1.002033;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.036422; pars_fPmeanVsBGcorr[0][i][1]=-2.131620; pars_fPmeanVsBGcorr[0][i][2]=0.998269;
+       pars_fPmeanVsBGcorr[1][i][0]=0.040298; pars_fPmeanVsBGcorr[1][i][1]=-2.085995; pars_fPmeanVsBGcorr[1][i][2]=1.002033;
+      }
+    }
+  }
+  else {//for all eta
+    //printf("EtaLimit[0]== %f and EtaLimit[1]== %fIII\n",EtaLimit[0],EtaLimit[1]);
+    for(Int_t i=0;i<5;i++) {
+      if(i==0) {//pi
+       pars_fPmeanVsBGcorr[0][i][0]=4.89956e-02; pars_fPmeanVsBGcorr[0][i][1]=-6.46308e-01; pars_fPmeanVsBGcorr[0][i][2]=1.00462e+00;
+       pars_fPmeanVsBGcorr[1][i][0]=6.36672e-02; pars_fPmeanVsBGcorr[1][i][1]=-6.10966e-01; pars_fPmeanVsBGcorr[1][i][2]=1.01188e+00;
+      }
+      else if(i==1) {//K
+       pars_fPmeanVsBGcorr[0][i][0]=3.06216e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.10247e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97142e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=3.48865e-02; pars_fPmeanVsBGcorr[1][i][1]=-1.89213e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00123e+00;
+      }
+      else if(i==2) {//p
+       pars_fPmeanVsBGcorr[0][i][0]=1.58652e-02; pars_fPmeanVsBGcorr[0][i][1]=-2.64898e+00; pars_fPmeanVsBGcorr[0][i][2]=9.97176e-01;
+       pars_fPmeanVsBGcorr[1][i][0]=1.83264e-02; pars_fPmeanVsBGcorr[1][i][1]=-2.45858e+00; pars_fPmeanVsBGcorr[1][i][2]=1.00079e+00;
+      }
+      else if(i==3) {//d
+       pars_fPmeanVsBGcorr[0][i][0]=0.011233; pars_fPmeanVsBGcorr[0][i][1]=-2.389911; pars_fPmeanVsBGcorr[0][i][2]=0.997176;//0.997210
+       pars_fPmeanVsBGcorr[1][i][0]=0.012975; pars_fPmeanVsBGcorr[1][i][1]=-2.218137; pars_fPmeanVsBGcorr[1][i][2]=1.001091;
+      }
+      else if(i==4) {//He3
+       pars_fPmeanVsBGcorr[0][i][0]=0.030884; pars_fPmeanVsBGcorr[0][i][1]=-2.124273; pars_fPmeanVsBGcorr[0][i][2]=0.997176;//0.997210
+       pars_fPmeanVsBGcorr[1][i][0]=0.035675; pars_fPmeanVsBGcorr[1][i][1]=-1.971591; pars_fPmeanVsBGcorr[1][i][2]=1.001091;
+      }
+    }
+  }
+
+  /*
+  for(Int_t iB=0;iB<nBconf;iB++) {
+    for(Int_t i=0;i<5;i++) {
+      pars_fPmeanVsBGcorr[iB][i][0]=0.02; pars_fPmeanVsBGcorr[iB][i][1]=-2.0; pars_fPmeanVsBGcorr[iB][i][2]=1.0;
+    }
+    }*/
+
+  for(Int_t iB=0;iB<nBconf;iB++) {
+    for(Int_t i=5;i<10;i++) {
+      pars_fPmeanVsBGcorr[iB][i][0]=pars_fPmeanVsBGcorr[iB][i-5][0];
+      pars_fPmeanVsBGcorr[iB][i][1]=pars_fPmeanVsBGcorr[iB][i-5][1];
+      pars_fPmeanVsBGcorr[iB][i][2]=pars_fPmeanVsBGcorr[iB][i-5][2];
+    }
+  }
+
+  for(Int_t iB=0;iB<nBconf;iB++) {
+    for(Int_t i=0;i<10;i++) {
+      fPmeanVsBGcorr[iB][i]->SetParameters(pars_fPmeanVsBGcorr[iB][i]);
+      fPmeanVsBGcorr[iB][i]->SetNpx(fPmeanVsBGcorr[iB][i]->GetNpx()*10);
+    }
+  }
+    
+  return;
+  
+}
 
index 9df7042431d210c233bbc6417635799f8a2e3189..7b84156849678e33d10323dd1af323cf1bc48533 100644 (file)
@@ -51,7 +51,7 @@ class AliAnalysisNucleiMass : public AliAnalysisTaskSE {
   void SetisSignalCheck(Int_t IsSignalCheck=2) {kSignalCheck=IsSignalCheck;}
   void SetMtofMethod(Int_t iMtofMethod=1) {iMtof=iMtofMethod;}
   void SetPvtxNucleiCorrection(Int_t kMomVtxCorr=1) {kPvtxCorr=kMomVtxCorr;}
-
+  
  private:
   AliAnalysisNucleiMass(const AliAnalysisNucleiMass &old); 
   AliAnalysisNucleiMass& operator=(const AliAnalysisNucleiMass &source);
@@ -72,9 +72,9 @@ class AliAnalysisNucleiMass : public AliAnalysisTaskSE {
   Int_t iTrdCut;                                   // iTrdCut==0-> No TRD cut; iTrdCut==1-> Yes TRD cut: yes TRD; iTrdCut==2->Yes TRD cut: no TRD; 
   Int_t kSignalCheck;                              // kSignalCheck==1->Fill all plots ; kSignalCheck==0->Fill only TH1 ; kSignalCheck==2-> Fill TH1 and some TH2 usefull in analysis
   Int_t iMtof;                                     // iMtof==1->m~pVtx ; iMtof==2->m~pExp ; iMtof==4->m~<p> (same correction for particle and antiparticle) ; iMtof==8->m~<p> (different correction for particle and antiparticle) 
-  //Use only iMtof<=2; In the next commit also iMtof>2 will work well... 
+  //To use only iMtof<=4; In the next commit also iMtof>4 will work well... 
   Int_t kPvtxCorr;                                 // kPvtxCorr==1->Momentum at the primary vertex for (anti)nuclei is rescaled ; kPvtxCorr==0->no correction
-
+  
   //other:
   Int_t iBconf;                                   //! If Magnetic Field configuration is down or up
   Bool_t kTOF;                                    //! kTOFout and kTIME required
@@ -128,7 +128,7 @@ class AliAnalysisNucleiMass : public AliAnalysisTaskSE {
   TF2 *fPvtxTrueVsReco[2];                        //! TF1 pVtx_True vs pVtx_Reco calculated with MC for d, He3
   TProfile *prPvtxTrueVsReco[nBconf][2];          //! TProfile pVtx_True vs pVtx_Reco calculated with MC for d, He3 (as Check)
 
-  TF1 *fPmeanVsBGcorr[10];                        //! <p>/p as a function of beta*gamma for pi,K,p,d,He3
+  TF1 *fPmeanVsBGcorr[nBconf][10];                        //! <p>/p as a function of beta*gamma for pi,K,p,d,He3
   TProfile *prPmeanVsBGcorr[nBconf][10];          //! <p>/p vs beta*gamma for pi,K,p,d,He3 as calculated from the parameterization (as Check)
  
   //------------------------------Methods----------------------------------------
@@ -144,8 +144,9 @@ class AliAnalysisNucleiMass : public AliAnalysisTaskSE {
 
   void GetMassFromMeanMom(Double_t beta, Double_t *IntTimes, Double_t *pVtx, Double_t charge, Double_t *Mass2, Int_t FlagPid, Int_t FlagPidTof, Double_t DCAxy);
   
-  ClassDef(AliAnalysisNucleiMass, 1);
+  void SetPmeanCorrections();
+
+  ClassDef(AliAnalysisNucleiMass, 2);
 };
 
 #endif
index c1db06773e52a62b0cce120641804b17c3c1d761..a81768230c17b9164dabedce6cb221f12ce5e37f 100644 (file)
@@ -135,16 +135,18 @@ void AliAnalysisTaskSpectraAllChAOD::UserCreateOutputObjects()
   fOutput->Add(NSparseHistSt);
   
   //dimensions of THnSparse for the normalization
-  const Int_t nvarev=2;
-  //                                             cent             Q vec   
-  Int_t    binsHistRealEv[nvarev] = {    fnCentBins,      fnQvecBins};
-  Double_t xminHistRealEv[nvarev] = {           0.,               0.};
-  Double_t xmaxHistRealEv[nvarev] = {       100.,              10.};
+  const Int_t nvarev=3;
+  //                                             cent             Q vec          Nch
+  Int_t    binsHistRealEv[nvarev] = {    fnCentBins,      fnQvecBins,           360.};
+  Double_t xminHistRealEv[nvarev] = {           0.,               0.,             0.};
+  Double_t xmaxHistRealEv[nvarev] = {       100.,               8.,            1800.};
   THnSparseF* NSparseHistEv = new THnSparseF("NSparseHistEv","NSparseHistEv",nvarev,binsHistRealEv,xminHistRealEv,xmaxHistRealEv);
   NSparseHistEv->GetAxis(0)->SetTitle(Form("%s cent",fEventCuts->GetCentralityMethod().Data()));
   NSparseHistEv->GetAxis(0)->SetName(Form("%s_cent",fEventCuts->GetCentralityMethod().Data()));
   NSparseHistEv->GetAxis(1)->SetTitle("Q vec");
   NSparseHistEv->GetAxis(1)->SetName("Q_vec");
+  NSparseHistEv->GetAxis(2)->SetTitle("N charged");
+  NSparseHistEv->GetAxis(2)->SetName("N_ch");
   fOutput->Add(NSparseHistEv);
   
   PostData(1, fOutput  );
@@ -215,6 +217,9 @@ void AliAnalysisTaskSpectraAllChAOD::UserExec(Option_t *)
     }
   
   //main loop on tracks
+  
+  Int_t Nch = 0.;
+  
   for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++) {
     AliAODTrack* track = fAOD->GetTrack(iTracks);
     if(fCharge != 0 && track->Charge() != fCharge) continue;//if fCharge != 0 only select fCharge 
@@ -263,15 +268,17 @@ void AliAnalysisTaskSpectraAllChAOD::UserExec(Option_t *)
     //fill all charged (3)
     varTrk[3]=3.;
     varTrk[4]=3.;
+    Nch++;
     ((THnSparseF*)fOutput->FindObject("NSparseHistTrk"))->Fill(varTrk);//track loop
     
     //Printf("a track");
     
   } // end loop on tracks
   
-  Double_t varEv[2];
+  Double_t varEv[3];
   varEv[0]=Cent;
   varEv[1]=Qvec;
+  varEv[2]=Nch;
   ((THnSparseF*)fOutput->FindObject("NSparseHistEv"))->Fill(varEv);//event loop
   
   PostData(1, fOutput  );
index 658333d383d2b742577d663076cdd897fcc809fa..d561e1891f0296e950cdf25381be57a2216797d1 100644 (file)
@@ -80,46 +80,96 @@ AliAnalysisTaskLambdaOverK0sJets::AliAnalysisTaskLambdaOverK0sJets(const char *n
 
   fAOD(0),  fCollision("PbPb2010"), fIsMC(kFALSE), fUsePID(kFALSE), fCentMin(0.), fCentMax(90.), fDoQA(kFALSE), fDoMixEvt(kFALSE), fTrigPtMin(8.), fTrigPtMax(20.), fTrigEtaMax(0.8), fCheckIDTrig(kFALSE), fSeparateInjPart(kTRUE), fEndOfHijingEvent(-1),  fPIDResponse(0),
 
-  fMinPtDaughter(0.160), fMaxEtaDaughter(0.8), fMaxDCADaughter(1.0), fYMax(0.5), fDCAToPrimVtx(0.1), fMinCPA(0.998), fNSigma(3.0), fMinCtau(0.), fMaxCtau(3.), fIdTrigger(-1), fIsV0LP(0), fPtV0LP(0.), fIsSndCheck(0),
+  fMinPtDaughter(0.160), fMaxEtaDaughter(0.8), fMaxDCADaughter(1.0), fYMax(0.5), fDCAToPrimVtx(0.1), fMinCPA(0.998), fNSigma(3.0),fDaugNClsTPC(70.), fMinCtau(0.), fMaxCtau(3.), fIdTrigger(-1), fIsV0LP(0), fPtV0LP(0.), fIsSndCheck(0),
 
-  fOutput(0), fOutputQA(0), fOutputME(0), fMEList(0x0), fTriggerParticles(0x0), fTriggerPartMC(0x0), fAssocParticles(0x0), fAssocPartMC(0x0), fEvents(0), fCentrality(0),  fCentrality2(0), fPrimaryVertexX(0), fPrimaryVertexY(0), fPrimaryVertexZ(0), fCentMult(0), fdEdx(0), fdEdxPid(0), 
+  fOutput(0), fOutputQA(0), fOutputME(0), fMEList(0x0), fTriggerParticles(0x0), fTriggerPartMC(0x0), fAssocParticles(0x0), fAssocPartMC(0x0), fEvents(0), fCentrality(0),  fCentrality2(0), fCentralityTrig(0), fPrimaryVertexX(0), fPrimaryVertexY(0), fPrimaryVertexZ(0),
 
-  fTriggerMCPtCent(0), fTriggerMCResPt(0), fTriggerMCResEta(0), fTriggerMCResPhi(0), fTriggerPtCent(0), fNTrigPerEvt(0), fTriggerWiSPDHit(0), fTriggerEtaPhi(0), fCheckTriggerFromV0Daug(0), fTriggerComingFromDaug(0), fTriggerIsV0(0), fCheckIDTrigPtK0s(0), fCheckIDTrigPhiK0s(0), fCheckIDTrigEtaK0s(0), fCheckIDTrigPtLambda(0), fCheckIDTrigPhiLambda(0), fCheckIDTrigEtaLambda(0), fCheckIDTrigPtAntiLambda(0), fCheckIDTrigPhiAntiLambda(0),fCheckIDTrigEtaAntiLambda(0), fInjectedParticles(0),
+ fTriggerEventPlane(0),  fTriggerMCPtCent(0), fTriggerMCResPt(0), fTriggerMCResEta(0), fTriggerMCResPhi(0), fTriggerPtCent(0), fNTrigPerEvt(0), fTriggerWiSPDHit(0), fTriggerEtaPhi(0), fCheckTriggerFromV0Daug(0), fTriggerComingFromDaug(0), fTriggerIsV0(0), fCheckIDTrigPtK0s(0), fCheckIDTrigPhiK0s(0), fCheckIDTrigEtaK0s(0), fCheckIDTrigPtLambda(0), fCheckIDTrigPhiLambda(0), fCheckIDTrigEtaLambda(0), fCheckIDTrigPtAntiLambda(0), fCheckIDTrigPhiAntiLambda(0),fCheckIDTrigEtaAntiLambda(0), 
 
-  fK0sMCPt(0), fK0sMCPtRap(0),fK0sMCPtRap2(0), fK0sMCPtRapEmbeded(0), fK0sAssocPt(0), fK0sAssocPtArm(0), fK0sAssocPtMassArm(0), fK0sAssocPtArmEmbeded(0), fK0sAssocPtRap(0), fK0sAssocPtRapEmbeded(0), fK0sMCResEta(0), fK0sMCResPhi(0), fLambdaMCPt(0), fLambdaMCPtRap(0), fLambdaMCPtRap2(0), fLambdaMCPtRapEmbeded(0), fLambdaMCFromXi(0), fLambdaAssocPt(0), fLambdaAssocPtRap(0), fLambdaAssocPtMass(0), fLambdaAssocPtRapEmbeded(0), fLambdaAssocFromXi(0), fLambdaMCResEta(0), fLambdaMCResPhi(0), fAntiLambdaMCPt(0), fAntiLambdaMCPtRap(0), fAntiLambdaMCPtRap2(0), fAntiLambdaMCPtRapEmbeded(0), fAntiLambdaMCFromXi(0), fAntiLambdaAssocPt(0), fAntiLambdaAssocPtRap(0), fAntiLambdaAssocPtMass(0), fAntiLambdaAssocPtRapEmbeded(0), fAntiLambdaAssocFromXi(0), fAntiLambdaMCResEta(0), fAntiLambdaMCResPhi(0),
+fInjectedParticles(0),
+
+fK0sMCPt(0), fK0sMCPtRap(0), fK0sMCPtRap2(0), fK0sMCPtRapVtx(0), fK0sMCPtRapEmbeded(0), fK0sMCPtRapVtxEmbeded(0), fK0sAssocPt(0), fK0sAssocPtArm(0),  fK0sAssocPtRap(0), fK0sAssocPtRapEmbeded(0), fK0sMCResEta(0), fK0sMCResPhi(0), fLambdaMCPt(0), fLambdaMCPtRap(0), fLambdaMCPtRap2(0),  fLambdaMCPtRapVtx(0), fLambdaMCPtRapEmbeded(0),  fLambdaMCPtRapVtxEmbeded(0), fLambdaMCFromXi(0), fLambdaAssocPt(0), fLambdaAssocPtRap(0), fLambdaAssocFromXi(0), fLambdaMCResEta(0), fLambdaMCResPhi(0), fAntiLambdaMCPt(0), fAntiLambdaMCPtRap(0), fAntiLambdaMCPtRap2(0), fAntiLambdaMCPtRapVtx(0), fAntiLambdaMCPtRapEmbeded(0), fAntiLambdaMCPtRapVtxEmbeded(0), fAntiLambdaMCFromXi(0), fAntiLambdaAssocPt(0), fAntiLambdaAssocPtRap(0), fAntiLambdaAssocFromXi(0), fAntiLambdaMCResEta(0), fAntiLambdaMCResPhi(0),
 
   fHistArmenterosPodolanski(0), fHistArmPodBckg(0),
   
-  fK0sMass(0), fK0sPtvsEta(0), fK0sPtvsRap(0), fK0sEtaPhi(0), fK0sMassPtPhi(0), fK0sSiPtL(0), fK0sDaughtersPt(0), fK0sDCADaugToPrimVtx(0), fK0sSpatialRes(0), fK0sBckgDecLength(0), fK0sBckgDCADaugToPrimVtx(0), fK0sdEdxPosDaug(0), fK0sdEdxNegDaug(0), fK0sBckgEtaPhi(0), fK0sBckgPhiRadio(0), fK0sBckgDCANegDaugToPrimVtx(0), fK0sBckgDCAPosDaugToPrimVtx(0), fV0MassCascade(0),
+  fK0sMass(0), fK0sMassEmbeded(0), fK0sPtvsEta(0), fK0sPtvsRap(0), fK0sMassPtPhi(0), fK0sDaughtersPt(0), fK0sDCADaugToPrimVtx(0), fK0sSpatialRes(0), fK0sBckgDecLength(0), fK0sBckgDCADaugToPrimVtx(0), fK0sBckgEtaPhi(0), fK0sBckgPhiRadio(0), fK0sBckgDCANegDaugToPrimVtx(0), fK0sBckgDCAPosDaugToPrimVtx(0), fV0MassCascade(0),
   
-  fLambdaMass(0), fLambdaPtvsEta(0), fLambdaPtvsRap(0), fLambdaEtaPhi(0), fLambdaMassPtPhi(0), fLambdaSiPtL(0), fLambdaDaughtersPt(0), fLambdaDCADaugToPrimVtx(0), fLambdaSpatialRes(0), fLambdaBckgDecLength(0), fLambdaBckgDCADaugToPrimVtx(0), fLambdadEdxPosDaug(0), fLambdadEdxNegDaug(0), fLambdaBckgEtaPhi(0), fLambdaBckgPhiRadio(0), fLambdaBckgDCANegDaugToPrimVtx(0), fLambdaBckgDCAPosDaugToPrimVtx(0), 
+  fLambdaMass(0), fLambdaMassEmbeded(0), fLambdaMass2(0), fLambdaMass2Embeded(0), fLambdaPtvsEta(0), fLambdaPtvsRap(0), fLambdaMassPtPhi(0), fLambdaDaughtersPt(0), fLambdaDCADaugToPrimVtx(0), fLambdaSpatialRes(0), fLambdaBckgDecLength(0), fLambdaBckgDCADaugToPrimVtx(0), fLambdaBckgEtaPhi(0), fLambdaBckgPhiRadio(0), fLambdaBckgDCANegDaugToPrimVtx(0), fLambdaBckgDCAPosDaugToPrimVtx(0), 
 
-  fAntiLambdaMass(0), fAntiLambdaPtvsEta(0), fAntiLambdaPtvsRap(0), fAntiLambdaEtaPhi(0), fAntiLambdaMassPtPhi(0), fAntiLambdaSiPtL(0), fAntiLambdaDaughtersPt(0), fAntiLambdaDCADaugToPrimVtx(0), fAntiLambdaSpatialRes(0), fAntiLambdaBckgDecLength(0), fAntiLambdaBckgDCADaugToPrimVtx(0), fAntiLambdadEdxPosDaug(0), fAntiLambdadEdxNegDaug(0), fAntiLambdaBckgEtaPhi(0), fAntiLambdaBckgPhiRadio(0), fAntiLambdaBckgDCANegDaugToPrimVtx(0), fAntiLambdaBckgDCAPosDaugToPrimVtx(0), 
+  fAntiLambdaMass(0), fAntiLambdaMassEmbeded(0), fAntiLambdaMass2(0), fAntiLambdaMass2Embeded(0), fAntiLambdaPtvsEta(0), fAntiLambdaPtvsRap(0), fAntiLambdaMassPtPhi(0), fAntiLambdaDaughtersPt(0), fAntiLambdaDCADaugToPrimVtx(0), fAntiLambdaSpatialRes(0), fAntiLambdaBckgDecLength(0), fAntiLambdaBckgDCADaugToPrimVtx(0), fAntiLambdaBckgEtaPhi(0), fAntiLambdaBckgPhiRadio(0), fAntiLambdaBckgDCANegDaugToPrimVtx(0), fAntiLambdaBckgDCAPosDaugToPrimVtx(0), 
 
-  fK0sPIDPosDaug(0), fK0sPIDNegDaug(0), fK0sBckgPIDPosDaug(0), fK0sBckgPIDNegDaug(0), fK0sPhiEtaPosDaug(0), fK0sPhiEtaNegDaug(0), fK0sBckgPhiEtaPosDaug(0), fK0sBckgPhiEtaNegDaug(0), fK0sDCAPosDaug(0), fK0sDCANegDaug(0), fK0sBckgDCAPosDaug(0), fK0sBckgDCANegDaug(0), fK0sDifPtPosDaug(0), fK0sDifPtNegDaug(0), fK0sBckgDifPtPosDaug(0), fK0sBckgDifPtNegDaug(0), fK0sDecayPos(0), fK0sBckgDecayPos(0), fK0sDecayVertex(0), fK0sBckgDecayVertex(0), fK0sDecayVertexZoom(0), fK0sBckgDecayVertexZoom(0), fK0sCPA(0), fK0sBckgCPA(0), fK0sDCAV0Daug(0), fK0sBckgDCAV0Daug(0), fK0sNClustersTPC(0), fK0sBckgNClustersTPC(0), fK0sNClustersITSPos(0), fK0sNClustersITSNeg(0), fK0sBckgNClustersITSPos(0),  fK0sBckgNClustersITSNeg(0),   
+  fK0sPtPosDaug(0), fK0sPtNegDaug(0), fK0sBckgPtPosDaug(0), fK0sBckgPtNegDaug(0), fK0sPhiEtaPosDaug(0), fK0sPhiEtaNegDaug(0), fK0sBckgPhiEtaPosDaug(0), fK0sBckgPhiEtaNegDaug(0), fK0sDCAPosDaug(0), fK0sDCANegDaug(0), fK0sBckgDCAPosDaug(0), fK0sBckgDCANegDaug(0), fK0sDecayPos(0), fK0sBckgDecayPos(0), fK0sDecayVertex(0), fK0sBckgDecayVertex(0), fK0sCPA(0), fK0sBckgCPA(0), fK0sDCAV0Daug(0), fK0sBckgDCAV0Daug(0), fK0sNClustersTPC(0), fK0sBckgNClustersTPC(0), fK0sNClustersITSPos(0), fK0sNClustersITSNeg(0), fK0sBckgNClustersITSPos(0), fK0sBckgNClustersITSNeg(0),   
 
-  fLambdaPIDPosDaug(0), fLambdaPIDNegDaug(0), fLambdaBckgPIDPosDaug(0), fLambdaBckgPIDNegDaug(0), fLambdaPhiEtaPosDaug(0),fLambdaPhiEtaNegDaug(0), fLambdaBckgPhiEtaPosDaug(0),fLambdaBckgPhiEtaNegDaug(0), fLambdaDCAPosDaug(0),fLambdaDCANegDaug(0), fLambdaBckgDCAPosDaug(0), fLambdaBckgDCANegDaug(0), fLambdaDifPtPosDaug(0), fLambdaDifPtNegDaug(0), fLambdaBckgDifPtPosDaug(0), fLambdaBckgDifPtNegDaug(0), fLambdaDecayPos(0), fLambdaBckgDecayPos(0), fLambdaDecayVertex(0), fLambdaBckgDecayVertex(0), fLambdaDecayVertexZoom(0), fLambdaBckgDecayVertexZoom(0), fLambdaCPA(0), fLambdaBckgCPA(0), fLambdaDCAV0Daug(0), fLambdaBckgDCAV0Daug(0), fLambdaNClustersTPC(0), fLambdaBckgNClustersTPC(0), fLambdaNClustersITSPos(0), fLambdaNClustersITSNeg(0), fLambdaBckgNClustersITSPos(0),  fLambdaBckgNClustersITSNeg(0),
+  fLambdaPtPosDaug(0), fLambdaPtNegDaug(0), fLambdaBckgPtPosDaug(0), fLambdaBckgPtNegDaug(0), fLambdaPhiEtaPosDaug(0),fLambdaPhiEtaNegDaug(0), fLambdaBckgPhiEtaPosDaug(0),fLambdaBckgPhiEtaNegDaug(0), fLambdaDCAPosDaug(0),fLambdaDCANegDaug(0), fLambdaBckgDCAPosDaug(0), fLambdaBckgDCANegDaug(0), fLambdaDecayPos(0), fLambdaBckgDecayPos(0), fLambdaDecayVertex(0), fLambdaBckgDecayVertex(0), fLambdaCPA(0), fLambdaBckgCPA(0), fLambdaDCAV0Daug(0), fLambdaBckgDCAV0Daug(0), fLambdaNClustersTPC(0), fLambdaBckgNClustersTPC(0), fLambdaNClustersITSPos(0), fLambdaNClustersITSNeg(0), fLambdaBckgNClustersITSPos(0),  fLambdaBckgNClustersITSNeg(0),
 
-  fAntiLambdaPIDPosDaug(0), fAntiLambdaPIDNegDaug(0), fAntiLambdaBckgPIDPosDaug(0), fAntiLambdaBckgPIDNegDaug(0), fAntiLambdaPhiEtaPosDaug(0),fAntiLambdaPhiEtaNegDaug(0), fAntiLambdaBckgPhiEtaPosDaug(0),fAntiLambdaBckgPhiEtaNegDaug(0), fAntiLambdaDCAPosDaug(0),fAntiLambdaDCANegDaug(0), fAntiLambdaBckgDCAPosDaug(0), fAntiLambdaBckgDCANegDaug(0), fAntiLambdaDifPtPosDaug(0), fAntiLambdaDifPtNegDaug(0), fAntiLambdaBckgDifPtPosDaug(0), fAntiLambdaBckgDifPtNegDaug(0), fAntiLambdaDecayPos(0), fAntiLambdaBckgDecayPos(0), fAntiLambdaDecayVertex(0), fAntiLambdaBckgDecayVertex(0), fAntiLambdaDecayVertexZoom(0), fAntiLambdaBckgDecayVertexZoom(0), fAntiLambdaCPA(0), fAntiLambdaBckgCPA(0), fAntiLambdaDCAV0Daug(0), fAntiLambdaBckgDCAV0Daug(0), fAntiLambdaNClustersTPC(0), fAntiLambdaBckgNClustersTPC(0), fAntiLambdaNClustersITSPos(0), fAntiLambdaNClustersITSNeg(0), fAntiLambdaBckgNClustersITSPos(0),  fAntiLambdaBckgNClustersITSNeg(0)
+  fAntiLambdaPtPosDaug(0), fAntiLambdaPtNegDaug(0), fAntiLambdaBckgPtPosDaug(0), fAntiLambdaBckgPtNegDaug(0), fAntiLambdaPhiEtaPosDaug(0),fAntiLambdaPhiEtaNegDaug(0), fAntiLambdaBckgPhiEtaPosDaug(0),fAntiLambdaBckgPhiEtaNegDaug(0), fAntiLambdaDCAPosDaug(0),fAntiLambdaDCANegDaug(0), fAntiLambdaBckgDCAPosDaug(0), fAntiLambdaBckgDCANegDaug(0), fAntiLambdaDecayPos(0), fAntiLambdaBckgDecayPos(0), fAntiLambdaDecayVertex(0), fAntiLambdaBckgDecayVertex(0), fAntiLambdaCPA(0), fAntiLambdaBckgCPA(0), fAntiLambdaDCAV0Daug(0), fAntiLambdaBckgDCAV0Daug(0), fAntiLambdaNClustersTPC(0), fAntiLambdaBckgNClustersTPC(0), fAntiLambdaNClustersITSPos(0), fAntiLambdaNClustersITSNeg(0), fAntiLambdaBckgNClustersITSPos(0),  fAntiLambdaBckgNClustersITSNeg(0)
   
 {
   // Dummy Constructor
 
-
+  // Particles properties in MC
   for (Int_t i=0; i<kNCent; i++){ 
+    
     // K0s
     fK0sMCPtPhiEta[i] = 0;
     fK0sAssocPtPhiEta[i] = 0;
+    // -- Natural particles
+    fK0sAssocPtMassArm[i] = 0;
+    fK0sAssocMassPtVtx[i] = 0;
+    fK0sAssocMassPtDCADaug[i] = 0;
+    fK0sAssocMassPtCPA[i] = 0;
+    fK0sAssocMassPtDCAPV[i] = 0;
+    fK0sAssocMassPtDaugNClsTPC[i] = 0;
+    // -- Embeded particles
+    fK0sAssocPtMassArmEmbeded[i] = 0;
+    fK0sAssocMassPtVtxEmbeded[i] = 0;
+    fK0sAssocMassPtDCADaug[i] = 0;
+    fK0sAssocMassPtCPAEmbeded[i] = 0;
+    fK0sAssocMassPtDCAPVEmbeded[i] = 0;
+    fK0sAssocMassPtDaugNClsTPCEmbeded[i] = 0;
 
     // Lambda
     fLambdaMCPtPhiEta[i] = 0;
     fLambdaAssocPtPhiEta[i] = 0;
-    
+    // -- Natural particles
+    fLambdaAssocMassPtRap[i] = 0;
+    fLambdaAssocMassPtRap2[i] = 0;
+    fLambdaAssocMassPtVtx[i] = 0;
+    fLambdaAssocMassPtDCADaug[i] = 0;
+    fLambdaAssocMassPtCPA[i] = 0;
+    fLambdaAssocMassPtDCAPV[i] = 0;
+    fLambdaAssocMassPtDaugNClsTPC[i] = 0;
+    // -- Embeded particles
+    fLambdaAssocMassPtRapEmbeded[i] = 0;
+    fLambdaAssocMassPtRapEmbeded2[i] = 0;
+    fLambdaAssocMassPtVtxEmbeded[i] = 0;
+    fLambdaAssocMassPtDCADaug[i] = 0;
+    fLambdaAssocMassPtCPAEmbeded[i] = 0;
+    fLambdaAssocMassPtDCAPVEmbeded[i] = 0;
+    fLambdaAssocMassPtDaugNClsTPCEmbeded[i] = 0;
+
     // AntiLambda
     fAntiLambdaMCPtPhiEta[i] = 0;
     fAntiLambdaAssocPtPhiEta[i] = 0;
+    // -- Natural particles
+    fAntiLambdaAssocMassPtRap[i] = 0;
+    fAntiLambdaAssocMassPtRap2[i] = 0;
+    fAntiLambdaAssocMassPtVtx[i] = 0;
+    fAntiLambdaAssocMassPtDCADaug[i] = 0;
+    fAntiLambdaAssocMassPtCPA[i] = 0;
+    fAntiLambdaAssocMassPtDCAPV[i] = 0;
+    fAntiLambdaAssocMassPtDaugNClsTPC[i] = 0;
+    // -- Embeded particles
+    fAntiLambdaAssocMassPtRapEmbeded[i] = 0;
+    fAntiLambdaAssocMassPtRapEmbeded2[i] = 0;
+    fAntiLambdaAssocMassPtVtxEmbeded[i] = 0;
+    fAntiLambdaAssocMassPtDCADaug[i] = 0;
+    fAntiLambdaAssocMassPtCPAEmbeded[i] = 0;
+    fAntiLambdaAssocMassPtDCAPVEmbeded[i] = 0;
+    fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[i] = 0;
   }
 
+  // Correlations in MC
   for (Int_t i=0; i<kNCent*kN1; i++){     
     // K0s
     fK0sdPhidEtaMC[i] = 0;
@@ -129,21 +179,17 @@ AliAnalysisTaskLambdaOverK0sJets::AliAnalysisTaskLambdaOverK0sJets(const char *n
     fAntiLambdadPhidEtaMC[i] = 0;
   }
 
-  
+  // Correlations
   for (Int_t i=0; i<(kNCent*kN1*kNVtxZ); i++){     
     // K0s
     fK0sdPhidEtaPtL[i] = 0;
-    //fK0sdPhidEtaPtLBckg[i] = 0;
     // Lambda
     fLambdadPhidEtaPtL[i] = 0;
-    //fLambdadPhidEtaPtLBckg[i] = 0;
     // AntiLambda
-    fAntiLambdadPhidEtaPtL[i] = 0;
-    //fAntiLambdadPhidEtaPtLBckg[i] = 0;  
+    fAntiLambdadPhidEtaPtL[i] = 0;  
   }
 
-
-  // Gamma Conversion
+  // Gamma Conversion correlation
   for (Int_t i=0; i<kNCent; i++)
     fGammaConversiondPhidEta[i] = 0;
 
@@ -254,6 +300,12 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fCentrality2 = new TH1F("fCentrality2","Centrality in events with |VtxZ|<10 cm;Centrality (%);Events",100,0.,100.);
   fOutput->Add(fCentrality2);
 
+  fCentralityTrig = new TH2F("fCentralityTrig","Centrality in events per trigger selection;Centrality (%);Triger Selection",100,0.,100.,3,0.5,3.5);
+  fCentralityTrig->GetYaxis()->SetBinLabel(1,"kCentral");
+  fCentralityTrig->GetYaxis()->SetBinLabel(1,"kSemiCentral");
+  fCentralityTrig->GetYaxis()->SetBinLabel(1,"kMB");
+  fOutput->Add(fCentralityTrig);
+
   // Primary Vertex:
   fPrimaryVertexX = new TH1F("fPrimaryVertexX", "Primary Vertex Position X;Primary Vertex Position X (cm);Events",100,-0.5,0.5);
   fOutput->Add(fPrimaryVertexX);
@@ -263,9 +315,13 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   
   fPrimaryVertexZ = new TH1F("fPrimaryVertexZ", "Primary Vertex Position Z;Primary Vertex Position Z (cm);Events",200,-20,20);
   fOutput->Add(fPrimaryVertexZ);
-
+  
 
   // ====== Trigger Particle characteristics ====== //
+  
+  // Difference between Event plane and the Trigger particles:
+  fTriggerEventPlane = new TH1F("fTriggerEventPlane", ";#phi_{EP}-#phi_{Trig};Events",50,0.,TMath::Pi());
+  fOutput->Add(fTriggerEventPlane);
 
   // MC: Pt Trigger particle vs centrality:
   if(fIsMC){
@@ -286,7 +342,7 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fTriggerPtCent = new TH3F("fTriggerPtCent","Trigger particle;p_{T} (GeV/c);centrality (%);Vertex Z (cm)",nbinPtLP,pMin,ptMaxLP,100,0.,100.,nbinsVtx,-10.,10.);
   fOutput->Add(fTriggerPtCent);
 
-  fNTrigPerEvt = new TH2F("fNTrigPerEvt","Number of Trigger Particles Per Event;Counts;Centrality",21,-0.5,20.5,100,0.,100);
+  fNTrigPerEvt = new TH2F("fNTrigPerEvt","Number of Trigger Particles Per Event;Counts;Centrality",51,-0.5,50.5,100,0.,100);
   fOutput->Add(fNTrigPerEvt);
 
   fTriggerWiSPDHit = new TH1F("fTriggerWiSPDHit","Number of Trigger Particles wi SPD Hits",3,0.,3.);
@@ -322,18 +378,18 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fCheckIDTrigPtK0s->GetYaxis()->SetBinLabel(6,"Neg Daug Z");
   fOutput->Add(fCheckIDTrigPtK0s);
 
-  fCheckIDTrigPhiK0s = new TH3F("fCheckIDTrigPhiK0s","K^{0}_{S};#delta#phi;;p_{V0}",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigPhiK0s = new TH3F("fCheckIDTrigPhiK0s","K^{0}_{S};#delta#phi;;p_{V0}",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigPhiK0s->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigPhiK0s->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigPhiK0s);
 
-  fCheckIDTrigEtaK0s = new TH3F("fCheckIDTrigEtaK0s","K^{0}_{S};#delta#eta;;p_{V0}",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigEtaK0s = new TH3F("fCheckIDTrigEtaK0s","K^{0}_{S};#delta#eta;;p_{V0}",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigEtaK0s->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigEtaK0s->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigEtaK0s);
 
   //   Lambda
-  fCheckIDTrigPtLambda = new TH3F("fCheckIDTrigPtLambda","#Lambda",40,-0.2,0.2,7,-0.5,6.5,100,1.,11.);
+  fCheckIDTrigPtLambda = new TH3F("fCheckIDTrigPtLambda","#Lambda",40,-0.1,0.1,7,-0.5,6.5,100,1.,11.);
   fCheckIDTrigPtLambda->GetYaxis()->SetBinLabel(1,"Pos Daug X");
   fCheckIDTrigPtLambda->GetYaxis()->SetBinLabel(2,"Pos Daug Y");
   fCheckIDTrigPtLambda->GetYaxis()->SetBinLabel(3,"Pos Daug Z");
@@ -342,12 +398,12 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fCheckIDTrigPtLambda->GetYaxis()->SetBinLabel(6,"Neg Daug Z");
   fOutput->Add(fCheckIDTrigPtLambda);
 
-  fCheckIDTrigPhiLambda  = new TH3F("fCheckIDTrigPhiLambda","#Lambda",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigPhiLambda  = new TH3F("fCheckIDTrigPhiLambda","#Lambda",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigPhiLambda->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigPhiLambda->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigPhiLambda);
 
-  fCheckIDTrigEtaLambda  = new TH3F("fCheckIDTrigEtaLambda","#Lambda",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigEtaLambda  = new TH3F("fCheckIDTrigEtaLambda","#Lambda",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigEtaLambda->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigEtaLambda->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigEtaLambda);
@@ -362,12 +418,12 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fCheckIDTrigPtAntiLambda->GetYaxis()->SetBinLabel(6,"Neg Daug Z");
   fOutput->Add(fCheckIDTrigPtAntiLambda);
 
-  fCheckIDTrigPhiAntiLambda  = new TH3F("fCheckIDTrigPhiAntiLambda","#bar{#Lambda}",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigPhiAntiLambda  = new TH3F("fCheckIDTrigPhiAntiLambda","#bar{#Lambda}",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigPhiAntiLambda->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigPhiAntiLambda->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigPhiAntiLambda);
 
-  fCheckIDTrigEtaAntiLambda  = new TH3F("fCheckIDTrigEtaAntiLambda","#bar{#Lambda}",20,-0.2,0.2,3,-0.5,2.5,100,1.,11.);
+  fCheckIDTrigEtaAntiLambda  = new TH3F("fCheckIDTrigEtaAntiLambda","#bar{#Lambda}",40,-0.1,0.1,3,-0.5,2.5,100,1.,11.);
   fCheckIDTrigEtaAntiLambda->GetYaxis()->SetBinLabel(1,"Pos Daug");
   fCheckIDTrigEtaAntiLambda->GetYaxis()->SetBinLabel(2,"Neg Daug");
   fOutput->Add(fCheckIDTrigEtaAntiLambda);
@@ -384,19 +440,24 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fK0sMCPt       = new TH1F("fK0sMCPt", "K^{0}_{S} MC;p_{T} (GeV/c);Counts",nbins,pMin,pMax);
     fOutput->Add(fK0sMCPt);
 
-    fK0sMCPtRap    = new TH3F("fK0sMCPtRap", "K^{0}_{S} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fK0sMCPtRap    = new TH3F("fK0sMCPtRap", "K^{0}_{S} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fK0sMCPtRap);
 
-    fK0sMCPtRap2   = new TH3F("fK0sMCPtRap2", "K^{0}_{S} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fK0sMCPtRap2   = new TH3F("fK0sMCPtRap2", "K^{0}_{S} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fK0sMCPtRap2);
 
-    fK0sMCPtRapEmbeded   = new TH3F("fK0sMCPtRapEmbeded", "K^{0}_{S} Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fK0sMCPtRapVtx = new TH3F("fK0sMCPtRapVtx", "K^{0}_{S} MC  |VtxZ|<3 cm;p_{T} (GeV/c);VtxZ;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fK0sMCPtRapVtx);
+
+    fK0sMCPtRapEmbeded   = new TH3F("fK0sMCPtRapEmbeded", "K^{0}_{S} Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.,1.,100,0.,100.);
     fOutput->Add(fK0sMCPtRapEmbeded);
 
+    fK0sMCPtRapVtxEmbeded = new TH3F("fK0sMCPtRapVtxEmbeded", "K^{0}_{S} Embeded MC |VtxZ|<3 cm;p_{T} (GeV/c);VtxZ;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fK0sMCPtRapVtxEmbeded);
   
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fK0sMCPtPhiEta_Cent_%d",jj);
-      fK0sMCPtPhiEta[jj]    = new TH3F(hNameHist, "K^{0}_{S} MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fK0sMCPtPhiEta[jj]    = new TH3F(hNameHist, "K^{0}_{S} MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.,1.,nbins,pMin,pMax);
       fOutput->Add(fK0sMCPtPhiEta[jj]);
     }
   
@@ -406,27 +467,77 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fOutput->Add(fK0sAssocPt);
 
     fK0sAssocPtArm = 
-      new TH3F("fK0sAssocPtArm","K^{0}_{S} Assoc: p_{T} vs y vs centrality;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+      new TH3F("fK0sAssocPtArm","K^{0}_{S} Assoc: p_{T} vs y vs centrality;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fK0sAssocPtArm);
 
-    fK0sAssocPtArmEmbeded = 
-      new TH3F("fK0sAssocPtArmEmbeded","K^{0}_{S} Assoc - Embeded MC: p_{T} vs y vs centrality;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
-    fOutput->Add(fK0sAssocPtArmEmbeded);
-
-    fK0sAssocPtRap    = new TH3F("fK0sAssocPtRap","K^{0}_{S} Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fK0sAssocPtRap    = new TH3F("fK0sAssocPtRap","K^{0}_{S} Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fK0sAssocPtRap);
 
-    fK0sAssocPtMassArm    = new TH3F("fK0sAssocPtMassArm","K^{0}_{S} Assoc;Mass (GeV/c^{2})p_{T} (GeV/c);centrality",nbins,0.398,0.598,nbins,pMin,pMax,100,0.,100.);
-    fOutput->Add(fK0sAssocPtMassArm);
-
-    fK0sAssocPtRapEmbeded    = new TH3F("fK0sAssocPtRapEmbeded","K^{0}_{S} Assoc  - Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fK0sAssocPtRapEmbeded    = new TH3F("fK0sAssocPtRapEmbeded","K^{0}_{S} Assoc  - Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fK0sAssocPtRapEmbeded);
   
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fK0sAssocPtPhiEta_Cent_%d",jj);
-      fK0sAssocPtPhiEta[jj]    = new TH3F(hNameHist,"K^{0}_{S} Assoc;#phi;#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fK0sAssocPtPhiEta[jj]    = new TH3F(hNameHist,"K^{0}_{S} Assoc;#phi;#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.0,1.0,nbins,pMin,pMax);
       fOutput->Add(fK0sAssocPtPhiEta[jj]);
     }
+
+    // Histogramas para estudios sistematicos de la eficiencia
+    for(Int_t i=0; i<kNCent; i++){
+     
+      /// ------- Natural particles
+      snprintf(hNameHist,100, "fK0sAssocPtMassArm_Cent_%d",i);
+      fK0sAssocPtMassArm[i]    = new TH3F(hNameHist,"K^{0}_{S} Assoc;Mass (GeV/c^{2});p_{T} (GeV/c);rap",nbins,0.398,0.598,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fK0sAssocPtMassArm[i]);
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtVtx_Cent_%d",i);
+      fK0sAssocMassPtVtx[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; VtxZ",nbins,0.398,0.598,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fK0sAssocMassPtVtx[i]);      
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDCADaug_Cent_%d",i);
+      fK0sAssocMassPtDCADaug[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; DCADaug",nbins,0.398,0.598,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fK0sAssocMassPtDCADaug[i]); 
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtCPA_Cent_%d",i);
+      fK0sAssocMassPtCPA[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; CPA",nbins,0.398,0.598,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fK0sAssocMassPtCPA[i]);  
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDCAPV_Cent_%d",i);
+      fK0sAssocMassPtDCAPV[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; DCA to Prim. Vtx",nbins,0.398,0.598,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fK0sAssocMassPtDCAPV[i]);  
+
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDaugNClsTPC_Cent_%d",i);
+      fK0sAssocMassPtDaugNClsTPC[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; # TPC Cls",nbins,0.398,0.598,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fK0sAssocMassPtDaugNClsTPC[i]); 
+
+      /// ----- Embeded particles 
+      snprintf(hNameHist,100, "fK0sAssocPtMassArmEmbeded_Cent_%d",i);
+      fK0sAssocPtMassArmEmbeded[i]    = new TH3F(hNameHist,"K^{0}_{S} Assoc Embeded;Mass (GeV/c^{2});p_{T} (GeV/c);rap",nbins,0.398,0.598,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fK0sAssocPtMassArmEmbeded[i]);
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtVtxEmbeded_Cent_%d",i);
+      fK0sAssocMassPtVtxEmbeded[i]  = new TH3F(hNameHist, "K^{0}_{S} Embeded; mass; pt; VtxZ",nbins,0.398,0.598,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fK0sAssocMassPtVtxEmbeded[i]);      
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDCADaugEmbeded_Cent_%d",i);
+      fK0sAssocMassPtDCADaugEmbeded[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; DCADaug",nbins,0.398,0.598,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fK0sAssocMassPtDCADaugEmbeded[i]); 
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtCPAEmbeded_Cent_%d",i);
+      fK0sAssocMassPtCPAEmbeded[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; CPA",nbins,0.398,0.598,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fK0sAssocMassPtCPAEmbeded[i]);  
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDCAPVEmbeded_Cent_%d",i);
+      fK0sAssocMassPtDCAPVEmbeded[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; DCA to Prim. Vtx",nbins,0.398,0.598,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fK0sAssocMassPtDCAPVEmbeded[i]);  
+
+
+      snprintf(hNameHist,100, "fK0sAssocMassPtDaugNClsTPCEmbeded_Cent_%d",i);
+      fK0sAssocMassPtDaugNClsTPCEmbeded[i]  = new TH3F(hNameHist, "K^{0}_{S}; mass; pt; # TPC Cls",nbins,0.398,0.598,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fK0sAssocMassPtDaugNClsTPCEmbeded[i]); 
+
+    }
     
     fK0sMCResEta     = new TH3F("fK0sMCResEta","K^{0}_{S} Assoc: #eta resolution; #eta_{MC}-#eta_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fK0sMCResEta);
@@ -438,21 +549,27 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fLambdaMCPt = new TH1F("fLambdaMCPt","#Lambda MC;p_{T} (GeV/c);Counts",nbins,pMin,pMax);
     fOutput->Add(fLambdaMCPt);
 
-    fLambdaMCPtRap = new TH3F("fLambdaMCPtRap","#Lambda MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fLambdaMCPtRap = new TH3F("fLambdaMCPtRap","#Lambda MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fLambdaMCPtRap);
 
-    fLambdaMCPtRap2 = new TH3F("fLambdaMCPtRap2","#Lambda MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fLambdaMCPtRap2 = new TH3F("fLambdaMCPtRap2","#Lambda MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fLambdaMCPtRap2);
 
-    fLambdaMCPtRapEmbeded = new TH3F("fLambdaMCPtRapEmbeded","#Lambda Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fLambdaMCPtRapVtx = new TH3F("fLambdaMCPtRapVtx","#Lambda MC  |VtxZ|<3 cm;p_{T} (GeV/c);zv;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fLambdaMCPtRapVtx);
+
+    fLambdaMCPtRapEmbeded = new TH3F("fLambdaMCPtRapEmbeded","#Lambda Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fLambdaMCPtRapEmbeded);
   
+    fLambdaMCPtRapVtxEmbeded = new TH3F("fLambdaMCPtRapVtxEmbeded","#Lambda Embeded MC |VtxZ|<3 cm;p_{T} (GeV/c);zv;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fLambdaMCPtRapVtxEmbeded);
+
     fLambdaMCFromXi  = new TH2F("fLambdaMCFromXi", "#Lambda from Xi MC;p_{T} (GeV/c);centrality",nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fLambdaMCFromXi);
 
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fLambdaMCPtPhiEta_Cent_%d",jj);
-      fLambdaMCPtPhiEta[jj] = new TH3F(hNameHist,"#Lambda MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fLambdaMCPtPhiEta[jj] = new TH3F(hNameHist,"#Lambda MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.0,1.0,nbins,pMin,pMax);
       fOutput->Add(fLambdaMCPtPhiEta[jj]);
     }
 
@@ -461,88 +578,206 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
       new TH1F("fLambdaAssocPt","#Lambda Assoc: L_{T} vs p_{T};p_{T} (GeV/c);Counts",nbins,pMin,pMax);
     fOutput->Add(fLambdaAssocPt);
 
-    fLambdaAssocPtRap = new TH3F("fLambdaAssocPtRap", "#Lambda Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fLambdaAssocPtRap = new TH3F("fLambdaAssocPtRap", "#Lambda Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fLambdaAssocPtRap);
-    fLambdaAssocPtMass    = new TH3F("fLambdaAssocPtMass","#Lambda Assoc;Mass (GeV/c^{2})p_{T} (GeV/c);centrality",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
-    fOutput->Add(fLambdaAssocPtMass);
-
-    fLambdaAssocPtRapEmbeded = new TH3F("fLambdaAssocPtRapEmbeded", "#Lambda Assoc - Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
-    fOutput->Add(fLambdaAssocPtRapEmbeded);
     
     fLambdaAssocFromXi  = new TH2F("fLambdaAssocFromXi", "#Lambda from Xi Assoc;p_{T} (GeV/c);centrality",nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fLambdaAssocFromXi);
 
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fLambdaAssocPtPhiEta_Cent_%d",jj);
-      fLambdaAssocPtPhiEta[jj] = new TH3F(hNameHist, "#Lambda Assoc;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fLambdaAssocPtPhiEta[jj] = new TH3F(hNameHist, "#Lambda Assoc;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.0,1.0,nbins,pMin,pMax);
       fOutput->Add(fLambdaAssocPtPhiEta[jj]);
     }
+    
+    // Histogramas para estudios sistematicos de la eficiencia
+    for(Int_t i=0; i<kNCent; i++){
+      // --------- Natural particles
+      snprintf(hNameHist,100, "fLambdaAssocMassPtRap_Cent_%d",i);
+      fLambdaAssocMassPtRap[i]  = new TH3F(hNameHist, "#Lambda: mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fLambdaAssocMassPtRap[i]);      
+    
+      snprintf(hNameHist,100, "fLambdaAssocMassPtRap2_Cent_%d",i);
+      fLambdaAssocMassPtRap2[i]  = new TH3F(hNameHist, "#Lambda: mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fLambdaAssocMassPtRap2[i]);     
+  
+      snprintf(hNameHist,100, "fLambdaAssocMassPtVtx_Cent_%d",i);
+      fLambdaAssocMassPtVtx[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; VtxZ",nbins,1.065,1.165,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fLambdaAssocMassPtVtx[i]);      
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDCADaug_Cent_%d",i);
+      fLambdaAssocMassPtDCADaug[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; DCADaug",nbins,1.065,1.165,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fLambdaAssocMassPtDCADaug[i]); 
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtCPA_Cent_%d",i);
+      fLambdaAssocMassPtCPA[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; CPA",nbins,1.065,1.165,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fLambdaAssocMassPtCPA[i]);  
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDCAPV_Cent_%d",i);
+      fLambdaAssocMassPtDCAPV[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; DCA to Prim. Vtx",nbins,1.065,1.165,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fLambdaAssocMassPtDCAPV[i]);  
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDaugNClsTPC_Cent_%d",i);
+      fLambdaAssocMassPtDaugNClsTPC[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; # TPC Cls",nbins,1.065,1.165,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fLambdaAssocMassPtDaugNClsTPC[i]); 
+
+      // ------------ Embeded particles
+      snprintf(hNameHist,100, "fLambdaAssocMassPtRapEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtRapEmbeded[i]  = new TH3F(hNameHist, "#Lambda Embeded; mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fLambdaAssocMassPtRapEmbeded[i]);  
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtRapEmbeded2_Cent_%d",i);
+      fLambdaAssocMassPtRapEmbeded2[i]  = new TH3F(hNameHist, "#Lambda Embeded; mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fLambdaAssocMassPtRapEmbeded2[i]);    
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtVtxEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtVtxEmbeded[i]  = new TH3F(hNameHist, "#Lambda Embeded; mass; pt; VtxZ",nbins,1.065,1.165,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fLambdaAssocMassPtVtxEmbeded[i]);      
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDCADaugEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtDCADaugEmbeded[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; DCADaug",nbins,1.065,1.165,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fLambdaAssocMassPtDCADaugEmbeded[i]); 
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtCPAEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtCPAEmbeded[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; CPA",nbins,1.065,1.165,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fLambdaAssocMassPtCPAEmbeded[i]);  
 
-    fLambdaMCResEta     = new TH3F("fLambdaMCResEta","#Lambda Assoc: #eta resolution;#eta_{MC}-#eta_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDCAPVEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtDCAPVEmbeded[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; DCA to Prim. Vtx",nbins,1.065,1.165,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fLambdaAssocMassPtDCAPVEmbeded[i]);  
+
+
+      snprintf(hNameHist,100, "fLambdaAssocMassPtDaugNClsTPCEmbeded_Cent_%d",i);
+      fLambdaAssocMassPtDaugNClsTPCEmbeded[i]  = new TH3F(hNameHist, "#Lambda; mass; pt; # TPC Cls",nbins,1.065,1.165,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fLambdaAssocMassPtDaugNClsTPCEmbeded[i]);
+    } 
+
+    fLambdaMCResEta     = new TH3F("fLambdaMCResEta","#Lambda Assoc: #eta resolution; #eta_{MC}-#eta_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fLambdaMCResEta);
 
-    fLambdaMCResPhi     = new TH3F("fLambdaMCResPhi","#Lambda Assoc: #phi resolution;#phi_{MC}-#phi_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
+    fLambdaMCResPhi     = new TH3F("fLambdaMCResPhi","#Lambda Assoc: #phi resolution; #phi_{MC}-#phi_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fLambdaMCResPhi);
-  
+
     // AntiLambda MC-true: 
     fAntiLambdaMCPt = new TH1F("fAntiLambdaMCPt","#bar{#Lambda} MC;p_{T} (GeV/c);Counts",nbins,pMin,pMax);
     fOutput->Add(fAntiLambdaMCPt);
-
-    fAntiLambdaMCPtRap = new TH3F("fAntiLambdaMCPtRap","#bar{#Lambda} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+  
+    fAntiLambdaMCPtRap = new TH3F("fAntiLambdaMCPtRap","#bar{#Lambda} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fAntiLambdaMCPtRap);
-
-    fAntiLambdaMCPtRap2 = new TH3F("fAntiLambdaMCPtRap2","#bar{#Lambda} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+  
+    fAntiLambdaMCPtRap2 = new TH3F("fAntiLambdaMCPtRap2","#bar{#Lambda} MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fAntiLambdaMCPtRap2);
 
-    fAntiLambdaMCPtRapEmbeded = new TH3F("fAntiLambdaMCPtRapEmbeded","#bar{#Lambda} Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+    fAntiLambdaMCPtRapVtx = new TH3F("fAntiLambdaMCPtRapVtx","#bar{#Lambda} MC |VtxZ|<3;p_{T} (GeV/c);zv;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fAntiLambdaMCPtRapVtx);  
+
+    fAntiLambdaMCPtRapEmbeded = new TH3F("fAntiLambdaMCPtRapEmbeded","#bar{#Lambda} Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fAntiLambdaMCPtRapEmbeded);
-  
+    
+    fAntiLambdaMCPtRapVtxEmbeded = new TH3F("fAntiLambdaMCPtRapVtxEmbeded","#bar{#Lambda} Embeded MC |VtxZ|<3;p_{T} (GeV/c);zv;centrality",nbins,pMin,pMax,20,-10.,10.,100,0.,100.);
+    fOutput->Add(fAntiLambdaMCPtRapVtxEmbeded); 
+
     fAntiLambdaMCFromXi  = new TH2F("fAntiLambdaMCFromXi", "#bar{#Lambda} from Xi MC;p_{T} (GeV/c);centrality",nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fAntiLambdaMCFromXi);
 
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fAntiLambdaMCPtPhiEta_Cent_%d",jj);
-      fAntiLambdaMCPtPhiEta[jj] = new TH3F(hNameHist,"#bar{#Lambda} MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fAntiLambdaMCPtPhiEta[jj] = new TH3F(hNameHist,"#bar{#Lambda} MC;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.0,1.0,nbins,pMin,pMax);
       fOutput->Add(fAntiLambdaMCPtPhiEta[jj]);
     }
-
+  
     // AntiLambda MC-Association:
     fAntiLambdaAssocPt = 
       new TH1F("fAntiLambdaAssocPt","#bar{#Lambda} Assoc: L_{T} vs p_{T};p_{T} (GeV/c)",nbins,pMin,pMax);
     fOutput->Add(fAntiLambdaAssocPt);
-
-    fAntiLambdaAssocPtRap = new TH3F("fAntiLambdaAssocPtRap", "#bar{#Lambda} Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
+  
+    fAntiLambdaAssocPtRap = new TH3F("fAntiLambdaAssocPtRap", "#bar{#Lambda} Assoc;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,20,-1.0,1.0,100,0.,100.);
     fOutput->Add(fAntiLambdaAssocPtRap);
   
-    fAntiLambdaAssocPtMass    = new TH3F("fAntiLambdaAssocPtMass","#bar{#Lambda} Assoc;Mass (GeV/c^{2})p_{T} (GeV/c);centrality",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
-    fOutput->Add(fAntiLambdaAssocPtMass);
-
-    fAntiLambdaAssocPtRapEmbeded = new TH3F("fAntiLambdaAssocPtRapEmbeded", "#bar{#Lambda} Assoc - Embeded MC;p_{T} (GeV/c);y;centrality",nbins,pMin,pMax,30,-1.5,1.5,100,0.,100.);
-    fOutput->Add(fAntiLambdaAssocPtRapEmbeded); 
-
     fAntiLambdaAssocFromXi  = new TH2F("fAntiLambdaAssocFromXi", "#bar{#Lambda} from Xi MC;p_{T} (GeV/c);centrality",nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fAntiLambdaAssocFromXi);
 
-
     for(Int_t jj=0;jj<kNCent;jj++){
       snprintf(hNameHist,100, "fAntiLambdaAssocPtPhiEta_Cent_%d",jj);
-      fAntiLambdaAssocPtPhiEta[jj] = new TH3F(hNameHist, "#bar{#Lambda} Assoc;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),30,-1.5,1.5,nbins,pMin,pMax);
+      fAntiLambdaAssocPtPhiEta[jj] = new TH3F(hNameHist, "#Lambda Assoc;#phi (rad);#eta;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),20,-1.0,1.0,nbins,pMin,pMax);
       fOutput->Add(fAntiLambdaAssocPtPhiEta[jj]);
     }
 
-    fAntiLambdaMCResEta     = new TH3F("fAntiLambdaMCResEta","#bar{#Lambda} Assoc: #eta resolution;#eta_{MC}-#eta_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
+    // Histogramas para estudios sistematicos de la eficiencia
+    for(Int_t i=0; i<kNCent; i++){
+      // --------- Natural particles
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtRap_Cent_%d",i);
+      fAntiLambdaAssocMassPtRap[i]  = new TH3F(hNameHist, "#bar{#Lambda}: mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fAntiLambdaAssocMassPtRap[i]);      
+  
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtRap2_Cent_%d",i);
+      fAntiLambdaAssocMassPtRap2[i]  = new TH3F(hNameHist, "#bar{#Lambda}: mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fAntiLambdaAssocMassPtRap2[i]); 
+    
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtVtx_Cent_%d",i);
+      fAntiLambdaAssocMassPtVtx[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; VtxZ",nbins,1.065,1.165,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fAntiLambdaAssocMassPtVtx[i]);      
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDCADaug_Cent_%d",i);
+      fAntiLambdaAssocMassPtDCADaug[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; DCADaug",nbins,1.065,1.165,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fAntiLambdaAssocMassPtDCADaug[i]); 
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtCPA_Cent_%d",i);
+      fAntiLambdaAssocMassPtCPA[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; CPA",nbins,1.065,1.165,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fAntiLambdaAssocMassPtCPA[i]);  
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDCAPV_Cent_%d",i);
+      fAntiLambdaAssocMassPtDCAPV[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; DCA to Prim. Vtx",nbins,1.065,1.165,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fAntiLambdaAssocMassPtDCAPV[i]);  
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDaugNClsTPC_Cent_%d",i);
+      fAntiLambdaAssocMassPtDaugNClsTPC[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; # TPC Cls",nbins,1.065,1.165,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fAntiLambdaAssocMassPtDaugNClsTPC[i]); 
+
+      // ------------ Embeded particles
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtRapEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtRapEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda} Embeded; mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fAntiLambdaAssocMassPtRapEmbeded[i]);    
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtRapEmbeded2_Cent_%d",i);
+      fAntiLambdaAssocMassPtRapEmbeded2[i]  = new TH3F(hNameHist, "#bar{#Lambda} Embeded; mass, pt, rap",nbins,1.065,1.165,nbins,pMin,pMax,20,-1.0,1.0);
+      fOutput->Add(fAntiLambdaAssocMassPtRapEmbeded2[i]);    
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtVtxEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtVtxEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda} Embeded; mass; pt; VtxZ",nbins,1.065,1.165,nbins,pMin,pMax,20,-10.,10.);
+      fOutput->Add(fAntiLambdaAssocMassPtVtxEmbeded[i]);      
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDCADaugEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtDCADaugEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; DCADaug",nbins,1.065,1.165,nbins,pMin,pMax,60,0,1.2);
+      fOutput->Add(fAntiLambdaAssocMassPtDCADaugEmbeded[i]); 
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtCPAEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtCPAEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; CPA",nbins,1.065,1.165,nbins,pMin,pMax,25,0.9975,1.);
+      fOutput->Add(fAntiLambdaAssocMassPtCPAEmbeded[i]);  
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDCAPVEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtDCAPVEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; DCA to Prim. Vtx",nbins,1.065,1.165,nbins,pMin,pMax,6,0.5,6.5);
+      fOutput->Add(fAntiLambdaAssocMassPtDCAPVEmbeded[i]);  
+
+
+      snprintf(hNameHist,100, "fAntiLambdaAssocMassPtDaugNClsTPCEmbeded_Cent_%d",i);
+      fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[i]  = new TH3F(hNameHist, "#bar{#Lambda}; mass; pt; # TPC Cls",nbins,1.065,1.165,nbins,pMin,pMax,4,0.5,4.5);
+      fOutput->Add(fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[i]);
+    } 
+
+    fAntiLambdaMCResEta     = new TH3F("fAntiLambdaMCResEta","#bar{#Lambda} Assoc: #eta resolution; #eta_{MC}-#eta_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fAntiLambdaMCResEta);
 
-    fAntiLambdaMCResPhi     = new TH3F("fAntiLambdaMCResPhi","#bar{#Lambda} Assoc: #phi resolution;#phi_{MC}-#phi_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
+    fAntiLambdaMCResPhi     = new TH3F("fAntiLambdaMCResPhi","#bar{#Lambda} Assoc: #phi resolution; #phi_{MC}-#phi_{Rec};p_{T} (GeV/c); centrality",40,-0.1,0.1,nbins,pMin,pMax,100,0.,100.);
     fOutput->Add(fAntiLambdaMCResPhi);
 
-  }  
+  } //End MC
 
-  // ====== Reconstruction information in AOD ====== //
+  // ======================================================== //
+  // ========== Reconstruction information in AOD =========== //
   fHistArmenterosPodolanski  =
     new TH3F("fHistArmenterosPodolanski","Armenteros-Podolanski phase space;#alpha;p_{t} arm",
-            100,-1.0,1.0,50,0,0.5,7,-0.5,6.5);
+             100,-1.0,1.0,50,0,0.5,7,-0.5,6.5);
   fHistArmenterosPodolanski->GetZaxis()->SetBinLabel(1,"K^{0}_{S} Inv. Mass Peak");
   fHistArmenterosPodolanski->GetZaxis()->SetBinLabel(2,"K^{0}_{S} Bckg");
   fHistArmenterosPodolanski->GetZaxis()->SetBinLabel(3,"#Lambda Inv. Mass Peak");
@@ -550,25 +785,32 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fHistArmenterosPodolanski->GetZaxis()->SetBinLabel(5,"#bar{#Lambda} Inv. Mass Peak");
   fHistArmenterosPodolanski->GetZaxis()->SetBinLabel(6,"#bar{#Lambda} Bckg");
   fOutput->Add(fHistArmenterosPodolanski);
-
   fHistArmPodBckg =
     new TH3F("fHistArmPodBckg","Background: Armenteros-Podolanski phase space;#alpha;p_{t} arm",
-            100,-1.0,1.0,50,0,0.5,4,-0.5,3.5);
+             100,-1.0,1.0,50,0,0.5,4,-0.5,3.5);
   fHistArmPodBckg->GetZaxis()->SetBinLabel(1,"K^{0}_{S}: Trig events");
   fHistArmPodBckg->GetZaxis()->SetBinLabel(2,"#Lambda: Trig events");
   fHistArmPodBckg->GetZaxis()->SetBinLabel(3,"#bar{#Lambda}: Trig events");
   fOutput->Add(fHistArmPodBckg);
-  
   // ****** K0s ******
-  fK0sMass = 
+  fK0sMass =
     new TH3F("fK0sMass", "K^{0}_{s}: mass vs p_{T}",nbins,0.398,0.598,nbins,pMin,pMax,100,0.,100.);
-  fK0sMass->GetXaxis()->SetTitle("Mass (GeV/c^2)"); 
-  fK0sMass->GetYaxis()->SetTitle("p_{T} (GeV/c)"); 
-  fK0sMass->GetZaxis()->SetTitle("centrality"); 
+  fK0sMass->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fK0sMass->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fK0sMass->GetZaxis()->SetTitle("centrality");
   fOutput->Add(fK0sMass);
+  fK0sMassEmbeded =
+    new TH3F("fK0sMassEmbeded", "K^{0}_{s} Embeded: mass vs p_{T}",nbins,0.398,0.598,nbins,pMin,pMax,100,0.,100.);
+  fK0sMassEmbeded->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fK0sMassEmbeded->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fK0sMassEmbeded->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fK0sMassEmbeded);
 
   fK0sPtvsEta =
-    new TH3F("fK0sPtvsEta","K^{0}_{s}: p_{T} vs #eta",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fK0sPtvsEta","K^{0}_{s}: p_{T} vs #eta",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fK0sPtvsEta->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fK0sPtvsEta->GetYaxis()->SetTitle("#eta");
   fK0sPtvsEta->GetZaxis()->SetBinLabel(1,"All events");
@@ -576,27 +818,22 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fK0sPtvsEta->GetZaxis()->SetBinLabel(3,"All ev wi Inv Mass cut");
   fK0sPtvsEta->GetZaxis()->SetBinLabel(4,"Trig ev wi Inv Mass cut");
   fOutput->Add(fK0sPtvsEta);
-
   fK0sPtvsRap =
-    new TH3F("fK0sPtvsRap","K^{0}_{s}: p_{T} vs y",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fK0sPtvsRap","K^{0}_{s}: p_{T} vs y",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fK0sPtvsRap->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fK0sPtvsRap->GetYaxis()->SetTitle("y");
   fK0sPtvsRap->GetZaxis()->SetBinLabel(1,"All events");
   fK0sPtvsRap->GetZaxis()->SetBinLabel(2,"Triggered events");
   fK0sPtvsRap->GetZaxis()->SetBinLabel(3,"All ev wi Inv Mass cut");
   fK0sPtvsRap->GetZaxis()->SetBinLabel(4,"Trig ev wi Inv Mass cut");
-  fOutput->Add(fK0sPtvsRap);
-
-  fK0sEtaPhi = 
-    new TH2F("fK0sEtaPhi","K^{0}_{s}: #phi vs #eta;#phi (rad);#eta",nbinsPhi,0.,2.*TMath::Pi(),100,-1.,1.);
-  fOutput->Add(fK0sEtaPhi);
-
-  fK0sMassPtPhi  = 
+  fOutput->Add(fK0sPtvsRap); 
+  fK0sMassPtPhi  =
     new TH3F("fK0sMassPtPhi","K^{0}_{s}: mass vs pt vs #phi;Mass (GeV/c^2);p_{T} (GeV/c);#phi (rad)",
-            nbins,0.398,0.598,nbins,pMin,pMax,nbinsPhi,0.,2.*TMath::Pi());
+             nbins,0.398,0.598,nbins,pMin,pMax,nbinsPhi,0.,2.*TMath::Pi());
   fOutput->Add(fK0sMassPtPhi);
-
-
+  
   // Correlations:
   fK0sDCADaugToPrimVtx  
     = new TH3F("fK0sDCADaugToPrimVtx","K^{0}_{S} Bckg: dca daughter vs. p_{T,l};DCA Pos daug (cm);DCA Neg daug (cm);p_{T,l} (GeV/c)",
@@ -636,19 +873,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
        fK0sdPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]->GetZaxis()->SetTitle("Inv. Mass"); 
        fOutput->Add(fK0sdPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]);
       }
-  
-      /*
-      snprintf(hNameHist,100, "fK0sdPhidEtaPtL_Bckg_%.2f_%.2f_Cent_%.0f_%.0f",kPtBinV0[k],kPtBinV0[k+1],kBinCent[jj],kBinCent[jj+1]); 
-      fK0sdPhidEtaPtLBckg[jj*kN1+k] = new TH3F(hNameHist,"K^{0}_{S}: #Delta#phi vs #Delta#eta vs p_{T,l}",
-                                              nbinsdPhi,-TMath::PiOver2(),3*TMath::PiOver2(),
-                                              nbinsdEta,-1.5,1.5,
-                                              nbinsVtx,-10.,10.);
-      fK0sdPhidEtaPtLBckg[jj*kN1+k]->GetXaxis()->SetTitle("#Delta#phi (rad)"); 
-      fK0sdPhidEtaPtLBckg[jj*kN1+k]->GetYaxis()->SetTitle("#Delta#eta"); 
-      fK0sdPhidEtaPtLBckg[jj*kN1+k]->GetZaxis()->SetTitle("Vertex Z (cm)");
-      fOutput->Add(fK0sdPhidEtaPtLBckg[jj*kN1+k]);
-      */
-
     }
   }
 
@@ -723,8 +947,29 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fLambdaMass->GetZaxis()->SetTitle("centrality"); 
   fOutput->Add(fLambdaMass);
   
+  fLambdaMassEmbeded =
+    new TH3F("fLambdaMassEmbeded","Mass vs p_{T} for \\Lambda Embeded",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fLambdaMassEmbeded->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fLambdaMassEmbeded->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fLambdaMassEmbeded->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fLambdaMassEmbeded);
+
+  fLambdaMass2 =
+    new TH3F("fLambdaMass2","Mass vs p_{T} for \\Lambda",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fLambdaMass2->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fLambdaMass2->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fLambdaMass2->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fLambdaMass2);
+
+  fLambdaMass2Embeded =
+    new TH3F("fLambdaMass2Embeded","Mass vs p_{T} for \\Lambda Embeded",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fLambdaMass2Embeded->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fLambdaMass2Embeded->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fLambdaMass2Embeded->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fLambdaMass2Embeded);
+
   fLambdaPtvsEta =
-    new TH3F("fLambdaPtvsEta","\\Lambda: p_{T} vs #eta",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fLambdaPtvsEta","\\Lambda: p_{T} vs #eta",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fLambdaPtvsEta->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fLambdaPtvsEta->GetYaxis()->SetTitle("#eta");
   fK0sPtvsEta->GetXaxis()->SetTitle("p_{T} (GeV/c)");
@@ -736,7 +981,7 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fOutput->Add(fLambdaPtvsEta);
 
   fLambdaPtvsRap =
-    new TH3F("fLambdaPtvsRap","\\Lambda: p_{T} vs y",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fLambdaPtvsRap","\\Lambda: p_{T} vs y",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fLambdaPtvsRap->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fLambdaPtvsRap->GetYaxis()->SetTitle("y");
   fLambdaPtvsRap->GetYaxis()->SetTitle("#eta");
@@ -746,14 +991,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fLambdaPtvsRap->GetZaxis()->SetBinLabel(4,"Trig ev wi Inv Mass cut");
   fOutput->Add(fLambdaPtvsRap);
 
-  fLambdaEtaPhi =
-    new TH2F("fLambdaEtaPhi","#phi vs #eta for #Lambda",
-            nbinsPhi,0.,2.*TMath::Pi(),100,-1.,1.);
-  fLambdaEtaPhi->GetXaxis()->SetTitle("#phi (rad)"); 
-  fLambdaEtaPhi->GetYaxis()->SetTitle("#eta"); 
-  fOutput->Add(fLambdaEtaPhi);
-
-
   fLambdaMassPtPhi  = 
     new TH3F("fLambdaMassPtPhi","#Lambda: mass vs pt vs #phi",
             nbins,1.065,1.165,nbins,pMin,pMax,nbinsPhi,0.,2.*TMath::Pi());
@@ -805,18 +1042,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
        fLambdadPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]->GetZaxis()->SetTitle("Inv. Mass");
        fOutput->Add(fLambdadPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]);
       }
-      /*
-       snprintf(hNameHist,100, "fLambdadPhidEtaPtL_Bckg_%.2f_%.2f_Cent_%.0f_%.0f",kPtBinV0[k],kPtBinV0[k+1],kBinCent[jj],kBinCent[jj+1]); 
-       fLambdadPhidEtaPtLBckg[jj*kN1+k] = new TH3F(hNameHist,"#Lambda: #Delta#phi  vs #Delta#eta vs p_{T,l}",
-       nbinsdPhi,-TMath::PiOver2(),3*TMath::PiOver2(),
-       nbinsdEta,-1.5,1.5,
-       nbinsVtx,-10.,10.);
-       fLambdadPhidEtaPtLBckg[jj*kN1+k]->GetXaxis()->SetTitle("#Delta#phi (rad)"); 
-       fLambdadPhidEtaPtLBckg[jj*kN1+k]->GetYaxis()->SetTitle("#Delta#eta"); 
-       fLambdadPhidEtaPtLBckg[jj*kN1+k]->GetZaxis()->SetTitle("Vertex Z (cm)");
-       fOutput->Add(fLambdadPhidEtaPtLBckg[jj*kN1+k]);
-      */
-
     }
   }
 
@@ -889,8 +1114,29 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fAntiLambdaMass->GetZaxis()->SetTitle("centrality"); 
   fOutput->Add(fAntiLambdaMass);
   
+  fAntiLambdaMassEmbeded =
+    new TH3F("fAntiLambdaMassEmbeded","Mass vs p_{T} for #bar{#Lambda} Embeded",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fAntiLambdaMassEmbeded->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fAntiLambdaMassEmbeded->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fAntiLambdaMassEmbeded->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fAntiLambdaMassEmbeded);
+
+  fAntiLambdaMass2 =
+    new TH3F("fAntiLambdaMass2","Mass vs p_{T} for #bar{#Lambda}",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fAntiLambdaMass2->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fAntiLambdaMass2->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fAntiLambdaMass2->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fAntiLambdaMass2);  
+
+  fAntiLambdaMass2Embeded =
+    new TH3F("fAntiLambdaMass2Embeded","Mass vs p_{T} for #bar{#Lambda} Embeded",nbins,1.065,1.165,nbins,pMin,pMax,100,0.,100.);
+  fAntiLambdaMass2Embeded->GetXaxis()->SetTitle("Mass (GeV/c^2)");
+  fAntiLambdaMass2Embeded->GetYaxis()->SetTitle("p_{T} (GeV/c)");
+  fAntiLambdaMass2Embeded->GetZaxis()->SetTitle("centrality");
+  fOutput->Add(fAntiLambdaMass2Embeded);  
+
   fAntiLambdaPtvsEta =
-    new TH3F("fAntiLambdaPtvsEta","#bar{#Lambda}: p_{T} vs #eta",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fAntiLambdaPtvsEta","#bar{#Lambda}: p_{T} vs #eta",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fAntiLambdaPtvsEta->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fAntiLambdaPtvsEta->GetYaxis()->SetTitle("#eta");
   fK0sPtvsEta->GetXaxis()->SetTitle("p_{T} (GeV/c)");
@@ -902,7 +1148,7 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fOutput->Add(fAntiLambdaPtvsEta);
 
   fAntiLambdaPtvsRap =
-    new TH3F("fAntiLambdaPtvsRap","#bar{#Lambda}: p_{T} vs y",nbins,pMin,pMax,30,-1.5,1.5,4,-0.5,3.5);
+    new TH3F("fAntiLambdaPtvsRap","#bar{#Lambda}: p_{T} vs y",nbins,pMin,pMax,20,-1.0,1.0,4,-0.5,3.5);
   fAntiLambdaPtvsRap->GetXaxis()->SetTitle("p_{T} (GeV/c)");
   fAntiLambdaPtvsRap->GetYaxis()->SetTitle("y");
   fAntiLambdaPtvsRap->GetYaxis()->SetTitle("#eta");
@@ -912,14 +1158,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
   fAntiLambdaPtvsRap->GetZaxis()->SetBinLabel(4,"Trig ev wi Inv Mass cut");
   fOutput->Add(fAntiLambdaPtvsRap);
 
-  fAntiLambdaEtaPhi =
-    new TH2F("fAntiLambdaEtaPhi","#phi vs #eta for #bar{#Lambda}",
-            nbinsPhi,0.,2.*TMath::Pi(),100,-1.,1.);
-  fAntiLambdaEtaPhi->GetXaxis()->SetTitle("#phi (rad)"); 
-  fAntiLambdaEtaPhi->GetYaxis()->SetTitle("#eta"); 
-  fOutput->Add(fAntiLambdaEtaPhi);
-
-
   fAntiLambdaMassPtPhi  = 
     new TH3F("fAntiLambdaMassPtPhi","#bar{#Lambda}: mass vs pt vs #phi",
             nbins,1.065,1.165,nbins,pMin,pMax,nbinsPhi,0.,2.*TMath::Pi());
@@ -971,20 +1209,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
        fAntiLambdadPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]->GetZaxis()->SetTitle("Inv. Mass");
        fOutput->Add(fAntiLambdadPhidEtaPtL[jj*kN1*kNVtxZ  + k*kNVtxZ + ll]);
       }
-
-
-      /*
-      snprintf(hNameHist,100, "fAntiLambdadPhidEtaPtL_Bckg_%.2f_%.2f_Cent_%.0f_%.0f",kPtBinV0[k],kPtBinV0[k+1],kBinCent[jj],kBinCent[jj+1]); 
-      fAntiLambdadPhidEtaPtLBckg[jj*kN1+k] = new TH3F(hNameHist,"#bar{#Lambda}: #Delta#phi  vs #Delta#eta vs p_{T,l}",
-                                                     nbinsdPhi,-TMath::PiOver2(),3*TMath::PiOver2(),
-                                                     nbinsdEta,-1.5,1.5,
-                                                     nbinsVtx,-10.,10.);
-      fAntiLambdadPhidEtaPtLBckg[jj*kN1+k]->GetXaxis()->SetTitle("#Delta#phi (rad)"); 
-      fAntiLambdadPhidEtaPtLBckg[jj*kN1+k]->GetYaxis()->SetTitle("#Delta#eta"); 
-      fAntiLambdadPhidEtaPtLBckg[jj*kN1+k]->GetZaxis()->SetTitle("Vertex Z (cm)");
-      fOutput->Add(fAntiLambdadPhidEtaPtLBckg[jj*kN1+k]);
-      */
-
     }
   }
 
@@ -1104,25 +1328,27 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
 
   if(fDoQA){
 
+    // ----------------------------
     // Quality Assurance K0s:
-    // Track PID :
-    //    --- signal ---
-    fK0sPIDPosDaug  = 
-      new TH3F("fK0sPIDPosDaug","K^{0}_{S}: dE/dx Pos. Daug.;TPC Momentum (GeV/c);a.u.;p_{T} V0",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sPIDPosDaug);
 
-    fK0sPIDNegDaug  = 
-      new TH3F("fK0sPIDNegDaug","K^{0}_{S}: dE/dx Neg. Daug.;TPC Momentum (GeV/c);a.u.;p_{T} V0",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sPIDNegDaug);
+    // Transverse momentum:
+    //     --- signal ---
+    fK0sPtPosDaug =
+      new TH2F("fK0sPtPosDaug","K^{0}_{S}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fK0sPtPosDaug);
+
+    fK0sPtNegDaug =
+      new TH2F("fK0sPtNegDaug","K^{0}_{S}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fK0sPtNegDaug);
 
-    //    --- background ---
-    fK0sBckgPIDPosDaug  = 
-      new TH3F("fK0sBckgPIDPosDaug","K^{0}_{S} Bckg: dE/dx Pos. Daug.;TPC Momentum (GeV/c);a.u.;p_{T} V0",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sBckgPIDPosDaug);
+    //     --- background ---
+    fK0sBckgPtPosDaug =
+      new TH2F("fK0sBckgPtPosDaug","K^{0}_{S}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fK0sBckgPtPosDaug);
 
-    fK0sBckgPIDNegDaug  = 
-      new TH3F("fK0sBckgPIDNegDaug","K^{0}_{S} Bckg: dE/dx Neg. Daug.;TPC Momentum (GeV/c);a.u.;p_{T} V0",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sBckgPIDNegDaug);
+    fK0sBckgPtNegDaug =
+      new TH2F("fK0sBckgPtNegDaug","K^{0}_{S}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fK0sBckgPtNegDaug);
 
     // Phi Eta
     //     --- signal ---
@@ -1162,26 +1388,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
       new TH2F("fK0sBckgDCANegDaug","K^{0}_{S} Bckg: dca Neg;dca;p_{T} V0",90,0.,3.3,nbins,pMin,pMax);
     fOutputQA->Add(fK0sBckgDCANegDaug);
 
-    // Difference in momentum:
-    //     --- signal ---
-    fK0sDifPtPosDaug =  
-      new TH2F("fK0sDifPtPosDaug","K^{0}_{S}: dif. p_{T};#Delta p_{T};p_{T} V0",90,0.,3.3,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sDifPtPosDaug);
-
-    fK0sDifPtNegDaug =  
-      new TH2F("fK0sDifPtNegDaug","K^{0}_{S}: dif. p_{T};#Delta p_{T};p_{T} V0",90,0.,3.3,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sDifPtNegDaug);
-
-    //     --- background ---
-    fK0sBckgDifPtPosDaug =  
-      new TH2F("fK0sBckgDifPtPosDaug","K^{0}_{S} Bckg: dif. p_{T};#Delta p_{T};p_{T} V0",90,0.,3.3,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sBckgDifPtPosDaug);
-
-    fK0sBckgDifPtNegDaug =  
-      new TH2F("fK0sBckgDifPtNegDaug","K^{0}_{S} Bckg: dif. p_{T};#Delta p_{T};p_{T} V0",90,0.,3.3,nbins,pMin,pMax);
-    fOutputQA->Add(fK0sBckgDifPtNegDaug);
-
-
     // Decay vertex reconstruction:
     //     --- signal ---
     fK0sDecayPos  =  
@@ -1197,12 +1403,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fK0sDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fK0sDecayVertex);
 
-    fK0sDecayVertexZoom  =  
-      new TH2F("fK0sDecayVertexZoom","K^{0}_{S}: decay length",20,0.,1.,nbins,pMin,pMax);
-    fK0sDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fK0sDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fK0sDecayVertexZoom);
-
     //     --- background ---
     fK0sBckgDecayPos  =  
       new TH3F("fK0sBckgDecayPos","K^{0}_{S}: Position of Dec. Vtx",200,-100.,100.,200,-100.,100.,nbins,pMin,pMax);
@@ -1217,12 +1417,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fK0sBckgDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fK0sBckgDecayVertex);
 
-    fK0sBckgDecayVertexZoom  =  
-      new TH2F("fK0sBckgDecayVertexZoom","K^{0}_{S} Bckg: decay length",20,0.,1.,nbins,pMin,pMax);
-    fK0sBckgDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fK0sBckgDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fK0sBckgDecayVertexZoom);
-
     // Cosine of the Pointing Angle:
     //     --- signal ---
     fK0sCPA  =  
@@ -1254,11 +1448,11 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     // Number of TPC clusters:
     //     --- signal ---
     fK0sNClustersTPC =  // Positive momentum to positive daugther - Negative momentum to negative daugther 
-      new TH3F("fK0sNClustersTPC","K^{0}_{S};#phi;Num. TPC Clusters; p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fK0sNClustersTPC","K^{0}_{S};#phi;Num. TPC Clusters; p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fK0sNClustersTPC);
     //     --- background ---
     fK0sBckgNClustersTPC =  // Positive momentum to positive daugther - Negative momentum to negative daugther 
-      new TH3F("fK0sBckgNClustersTPC","K^{0}_{S} Bckg;#phi;Num. TPC Clusters; p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fK0sBckgNClustersTPC","K^{0}_{S} Bckg;#phi;Num. TPC Clusters; p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fK0sBckgNClustersTPC);
  
     // Number of ITS clusters:
@@ -1279,38 +1473,27 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
       new TH3F("fK0sBckgNClustersITSNeg","K^{0}_{S} Bckg: Neg. Daug;#phi;Num. ITS Clusters;;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),7,-0.5,6.5,nbins,pMin,pMax); 
     fOutputQA->Add(fK0sBckgNClustersITSNeg);
   
-
+    // ----------------------------
     // Quality Assurance Lambda:
-    // Track PID :
-    //    --- signal ---
-    fLambdaPIDPosDaug  = 
-      new TH3F("fLambdaPIDPosDaug","#Lambda: dE/dx Pos. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fLambdaPIDPosDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fLambdaPIDPosDaug->GetYaxis()->SetTitle("a.u."); 
-    fLambdaPIDPosDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaPIDPosDaug);
-
-    fLambdaPIDNegDaug  = 
-      new TH3F("fLambdaPIDNegDaug","#Lambda: dE/dx Neg. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fLambdaPIDNegDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fLambdaPIDNegDaug->GetYaxis()->SetTitle("a.u."); 
-    fLambdaPIDNegDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaPIDNegDaug);
-
-    //    --- background ---
-    fLambdaBckgPIDPosDaug  = 
-      new TH3F("fLambdaBckgPIDPosDaug","#Lambda: dE/dx Pos. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fLambdaBckgPIDPosDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fLambdaBckgPIDPosDaug->GetYaxis()->SetTitle("a.u."); 
-    fLambdaBckgPIDPosDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaBckgPIDPosDaug);
-
-    fLambdaBckgPIDNegDaug  = 
-      new TH3F("fLambdaBckgPIDNegDaug","#Lambda: dE/dx Neg. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fLambdaBckgPIDNegDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fLambdaBckgPIDNegDaug->GetYaxis()->SetTitle("a.u."); 
-    fLambdaBckgPIDNegDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaBckgPIDNegDaug);
+
+    // Transverse momentum:
+    //     --- signal ---
+    fLambdaPtPosDaug =
+      new TH2F("fLambdaPtPosDaug","#Lambda: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fLambdaPtPosDaug);
+
+    fLambdaPtNegDaug =
+      new TH2F("fLambdaPtNegDaug","#Lambda: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fLambdaPtNegDaug);
+
+    //     --- background ---
+    fLambdaBckgPtPosDaug =
+      new TH2F("fLambdaBckgPtPosDaug","#Lambda: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fLambdaBckgPtPosDaug);
+
+    fLambdaBckgPtNegDaug =
+      new TH2F("fLambdaBckgPtNegDaug","#Lambda: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fLambdaBckgPtNegDaug);
 
     // Phi Eta
     //     --- signal ---
@@ -1370,33 +1553,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fLambdaBckgDCANegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fLambdaBckgDCANegDaug);
 
-    // Difference in momentum
-    //     --- signal ---
-    fLambdaDifPtPosDaug =  
-      new TH2F("fLambdaDifPtPosDaug","#Lambda: dif. p_{T} Pos",90,0.,3.3,nbins,pMin,pMax);
-    fLambdaDifPtPosDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fLambdaDifPtPosDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaDifPtPosDaug);
-
-    fLambdaDifPtNegDaug =  
-      new TH2F("fLambdaDifPtNegDaug","#Lambda: dif. p_{T} Neg",90,0.,3.3,nbins,pMin,pMax);
-    fLambdaDifPtNegDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fLambdaDifPtNegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaDifPtNegDaug);
-
-    //     --- background ---
-    fLambdaBckgDifPtPosDaug =  
-      new TH2F("fLambdaBckgDifPtPosDaug","#Lambda Bckg: dif. p_{T} Pos.",90,0.,3.3,nbins,pMin,pMax);
-    fLambdaBckgDifPtPosDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fLambdaBckgDifPtPosDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaBckgDifPtPosDaug);
-
-    fLambdaBckgDifPtNegDaug =  
-      new TH2F("fLambdaBckgDifPtNegDaug","#Lambda Bckg: dif. p_{t} Neg",90,0.,3.3,nbins,pMin,pMax);
-    fLambdaBckgDifPtNegDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fLambdaBckgDifPtNegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaBckgDifPtNegDaug);
-
 
     // Decay vertex reconstruction
     //     --- signal ---
@@ -1413,12 +1569,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fLambdaDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fLambdaDecayVertex);
 
-    fLambdaDecayVertexZoom  =  
-      new TH2F("fLambdaDecayVertexZoom","#Lambda: decay length",20,0.,1.,nbins,pMin,pMax);
-    fLambdaDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fLambdaDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaDecayVertexZoom);
-
     //     --- background ---
     fLambdaBckgDecayPos  =  
       new TH3F("fLambdaBckgDecayPos","#Lambda Bckg: Position of Dec. Vtx",200,-100.,100.,200,-100.,100.,nbins,pMin,pMax);
@@ -1433,12 +1583,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fLambdaBckgDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fLambdaBckgDecayVertex);
 
-    fLambdaBckgDecayVertexZoom  =  
-      new TH2F("fLambdaBckgDecayVertexZoom","#Lambda Bckg: decay length",20,0.,1.,nbins,pMin,pMax);
-    fLambdaBckgDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fLambdaBckgDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fLambdaBckgDecayVertexZoom);
-
     // Cosine of the Pointing Angle
     //     --- signal ---
     fLambdaCPA  =  
@@ -1470,11 +1614,11 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     // Number of TPC clusters:
     //     --- signal ---
     fLambdaNClustersTPC = 
-      new TH3F("fLambdaNClustersTPC","#Lambda;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fLambdaNClustersTPC","#Lambda;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fLambdaNClustersTPC);
     //     --- background ---
     fLambdaBckgNClustersTPC = 
-      new TH3F("fLambdaBckgNClustersTPC","#Lambda Bckg;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fLambdaBckgNClustersTPC","#Lambda Bckg;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fLambdaBckgNClustersTPC);
  
     // Number of ITS clusters:
@@ -1496,38 +1640,26 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fOutputQA->Add(fLambdaBckgNClustersITSNeg);
 
 
-
+    // ----------------------------
     // Quality Assurance AntiLambda:
-    // Track PID :
-    //    --- signal ---
-    fAntiLambdaPIDPosDaug  = 
-      new TH3F("fAntiLambdaPIDPosDaug","#bar{#Lambda}: dE/dx Pos. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fAntiLambdaPIDPosDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fAntiLambdaPIDPosDaug->GetYaxis()->SetTitle("a.u."); 
-    fAntiLambdaPIDPosDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaPIDPosDaug);
-
-    fAntiLambdaPIDNegDaug  = 
-      new TH3F("fAntiLambdaPIDNegDaug","#bar{#Lambda}: dE/dx Neg. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fAntiLambdaPIDNegDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fAntiLambdaPIDNegDaug->GetYaxis()->SetTitle("a.u."); 
-    fAntiLambdaPIDNegDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaPIDNegDaug);
-
-    //    --- background ---
-    fAntiLambdaBckgPIDPosDaug  = 
-      new TH3F("fAntiLambdaBckgPIDPosDaug","#bar{#Lambda}: dE/dx Pos. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fAntiLambdaBckgPIDPosDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fAntiLambdaBckgPIDPosDaug->GetYaxis()->SetTitle("a.u."); 
-    fAntiLambdaBckgPIDPosDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaBckgPIDPosDaug);
-
-    fAntiLambdaBckgPIDNegDaug  = 
-      new TH3F("fAntiLambdaBckgPIDNegDaug","#bar{#Lambda}: dE/dx Neg. Daug.",50,0.2,3,50,0.,6.,nbins,pMin,pMax);
-    fAntiLambdaBckgPIDNegDaug->GetXaxis()->SetTitle("TPC Momentum (GeV/c)"); 
-    fAntiLambdaBckgPIDNegDaug->GetYaxis()->SetTitle("a.u."); 
-    fAntiLambdaBckgPIDNegDaug->GetZaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaBckgPIDNegDaug);
+    // Transverse momentum:
+    //     --- signal ---
+    fAntiLambdaPtPosDaug =
+      new TH2F("fAntiLambdaPtPosDaug","#bar{#Lambda}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fAntiLambdaPtPosDaug);
+
+    fAntiLambdaPtNegDaug =
+      new TH2F("fAntiLambdaPtNegDaug","#bar{#Lambda}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fAntiLambdaPtNegDaug);
+
+    //     --- background ---
+    fAntiLambdaBckgPtPosDaug =
+      new TH2F("fAntiLambdaBckgPtPosDaug","#bar{#Lambda}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fAntiLambdaBckgPtPosDaug);
+
+    fAntiLambdaBckgPtNegDaug =
+      new TH2F("fAntiLambdaBckgPtNegDaug","#bar{#Lambda}: p_{T};p_{T};p_{T} V0",nbins,pMin,pMax,nbins,pMin,pMax);
+    fOutputQA->Add(fAntiLambdaBckgPtNegDaug);
 
     // Phi Eta
     //     --- signal ---
@@ -1587,34 +1719,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fAntiLambdaBckgDCANegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fAntiLambdaBckgDCANegDaug);
 
-    // Difference in momentum
-    //     --- signal ---
-    fAntiLambdaDifPtPosDaug =  
-      new TH2F("fAntiLambdaDifPtPosDaug","#bar{#Lambda}: dif. p_{T} Pos",90,0.,3.3,nbins,pMin,pMax);
-    fAntiLambdaDifPtPosDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fAntiLambdaDifPtPosDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaDifPtPosDaug);
-
-    fAntiLambdaDifPtNegDaug =  
-      new TH2F("fAntiLambdaDifPtNegDaug","#bar{#Lambda}: dif. p_{T} Neg",90,0.,3.3,nbins,pMin,pMax);
-    fAntiLambdaDifPtNegDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fAntiLambdaDifPtNegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaDifPtNegDaug);
-
-    //     --- background ---
-    fAntiLambdaBckgDifPtPosDaug =  
-      new TH2F("fAntiLambdaBckgDifPtPosDaug","#bar{#Lambda} Bckg: dif. p_{T} Pos.",90,0.,3.3,nbins,pMin,pMax);
-    fAntiLambdaBckgDifPtPosDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fAntiLambdaBckgDifPtPosDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaBckgDifPtPosDaug);
-
-    fAntiLambdaBckgDifPtNegDaug =  
-      new TH2F("fAntiLambdaBckgDifPtNegDaug","#bar{#Lambda} Bckg: dif. p_{t} Neg",90,0.,3.3,nbins,pMin,pMax);
-    fAntiLambdaBckgDifPtNegDaug->GetXaxis()->SetTitle("#Delta p_{T}"); 
-    fAntiLambdaBckgDifPtNegDaug->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaBckgDifPtNegDaug);
-
-
     // Decay vertex reconstruction
     //     --- signal ---
     fAntiLambdaDecayPos  =  
@@ -1630,12 +1734,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fAntiLambdaDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fAntiLambdaDecayVertex);
 
-    fAntiLambdaDecayVertexZoom  =  
-      new TH2F("fAntiLambdaDecayVertexZoom","#bar{#Lambda}: decay length",20,0.,1.,nbins,pMin,pMax);
-    fAntiLambdaDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fAntiLambdaDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaDecayVertexZoom);
-
     //     --- background ---
     fAntiLambdaBckgDecayPos  =  
       new TH3F("fAntiLambdaBckgDecayPos","#bar{#Lambda} Bckg: Position of Dec. Vtx",200,-100.,100.,200,-100.,100.,nbins,pMin,pMax);
@@ -1650,12 +1748,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     fAntiLambdaBckgDecayVertex->GetYaxis()->SetTitle("p_{T} V0"); 
     fOutputQA->Add(fAntiLambdaBckgDecayVertex);
 
-    fAntiLambdaBckgDecayVertexZoom  =  
-      new TH2F("fAntiLambdaBckgDecayVertexZoom","#bar{#Lambda} Bckg: decay length",20,0.,1.,nbins,pMin,pMax);
-    fAntiLambdaBckgDecayVertexZoom->GetXaxis()->SetTitle("l_{T}"); 
-    fAntiLambdaBckgDecayVertexZoom->GetYaxis()->SetTitle("p_{T} V0"); 
-    fOutputQA->Add(fAntiLambdaBckgDecayVertexZoom);
-
     // Cosine of the Pointing Angle
     //     --- signal ---
     fAntiLambdaCPA  =  
@@ -1687,11 +1779,11 @@ void AliAnalysisTaskLambdaOverK0sJets::UserCreateOutputObjects()
     // Number of TPC clusters:
     //     --- signal ---
     fAntiLambdaNClustersTPC = 
-      new TH3F("fAntiLambdaNClustersTPC","#bar{#Lambda};#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fAntiLambdaNClustersTPC","#bar{#Lambda};#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fAntiLambdaNClustersTPC);
     //     --- background ---
     fAntiLambdaBckgNClustersTPC = 
-      new TH3F("fAntiLambdaBckgNClustersTPC","#bar{#Lambda} Bckg;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),111,69.5,180.5,nbins,-pMax,pMax); 
+      new TH3F("fAntiLambdaBckgNClustersTPC","#bar{#Lambda} Bckg;#phi;Num. TPC Clusters;p_{T} (GeV/c)",nbinsPhi,0.,2.*TMath::Pi(),131,49.5,180.5,nbins,-pMax,pMax); 
     fOutputQA->Add(fAntiLambdaBckgNClustersTPC);
  
     // Number of ITS clusters:
@@ -1800,12 +1892,12 @@ Bool_t AliAnalysisTaskLambdaOverK0sJets::AcceptTrack(AliAODTrack *t)
 
 //___________________________________________________________________________________________
 
-static Bool_t AcceptTrackV0(const AliAODTrack *t) 
+Bool_t AliAnalysisTaskLambdaOverK0sJets::AcceptTrackV0(const AliAODTrack *t) 
 { 
   // Track criteria for daughter particles of V0 candidate 
   if (!t->IsOn(AliAODTrack::kTPCrefit)) return kFALSE;
   Float_t nCrossedRowsTPC = t->GetTPCClusterInfo(2,1); 
-  if (nCrossedRowsTPC < 70) return kFALSE;
+  if (nCrossedRowsTPC<fDaugNClsTPC) return kFALSE;
 
   return kTRUE;   
 }
@@ -2071,20 +2163,17 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     const AliAODTrack *ntrack=(AliAODTrack *)v0->GetDaughter(1);
     const AliAODTrack *ptrack=(AliAODTrack *)v0->GetDaughter(0);
 
-    Float_t etaNeg = ntrack->Eta();
-    Float_t etaPos = ptrack->Eta();
-    Float_t lPtNeg = ntrack->Pt();
-    Float_t lPtPos = ptrack->Pt();
-
     // Decay vertex
     Double_t xyz[3]; v0->GetSecondaryVtx(xyz);
     Float_t dx=xyz[0]-xv, dy=xyz[1]-yv;//, dz=xyz[2]-zv;
-    // Decay length: 2D & 3D 
-    Float_t lt=TMath::Sqrt(dx*dx + dy*dy); 
-    //Float_t dl=TMath::Sqrt(dx*dx + dy*dy + dz*dz);  
+   
     // Momentum: 2D & 3D
     Float_t pt=TMath::Sqrt(v0->Pt2V0());
     //Float_t p=v0->P();
+
+    // Decay length: 2D & 3D 
+    Float_t lt=TMath::Sqrt(dx*dx + dy*dy); 
+    //Float_t dl=TMath::Sqrt(dx*dx + dy*dy + dz*dz);  
     
     Float_t dlK = 0.4977*lt/pt;
     Float_t dlL = 1.1157*lt/pt; 
@@ -2099,10 +2188,76 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     Bool_t ctL=kTRUE;  if (dlL > fMaxCtau*7.89 || dlL < fMinCtau*7.89) ctL=kFALSE; 
     Bool_t ctAL=kTRUE; if (dlL > fMaxCtau*7.89 || dlL < fMinCtau*7.89) ctAL=kFALSE;    
 
+    //  ---- Daughter tracks properties:
+    // Pt
+    Float_t lPtNeg = ntrack->Pt();
+    Float_t lPtPos = ptrack->Pt();  
+    // Momentum
+    Double_t pNegDaug[3];  ntrack->GetPxPyPz(pNegDaug);                  
+    Double_t pPosDaug[3];  ptrack->GetPxPyPz(pPosDaug);
+    // Phi
+    Float_t phiNeg = ntrack->Phi();
+    Float_t phiPos = ptrack->Phi();
+    // Eta
+    Float_t etaNeg = ntrack->Eta();
+    Float_t etaPos = ptrack->Eta();
+    //  Number of TPC Clusters 
+    Float_t nClsTPCPos = ptrack->GetTPCClusterInfo(2,1);
+    Float_t nClsTPCNeg = ntrack->GetTPCClusterInfo(2,1); 
+    // Number of clusters of ITS
+    Double_t posITSNcls = ptrack->GetITSNcls();   
+    Double_t negITSNcls = ntrack->GetITSNcls();
+
+    //  ---- V0 candidate properties:
     // Armenteros variables:
     Float_t lAlphaV0      =  v0->AlphaV0();
     Float_t lPtArmV0      =  v0->PtArmV0();
+    // dca to primary vertex
+    Float_t dcaNeg = v0->DcaNegToPrimVertex();
+    Float_t dcaPos = v0->DcaPosToPrimVertex();
+    // dca between daughters
+    Float_t dca   = v0->DcaV0Daughters();
+    // cpa
+    Float_t cpa   = v0->CosPointingAngle(fAOD->GetPrimaryVertex());
+    // eta
+    Float_t lEta  = v0->PseudoRapV0();
+    // phi
+    Float_t lPhi  = v0->Phi();
+    //lPhi  = ( (lPhi < 0) ? lPhi + 2*TMath::Pi() : lPhi );    
+
+    // **********************************
+    // Disentangle the V0 candidate
+    Float_t massK0s = 0., mK0s = 0., sK0s = 0.;
+    Float_t massLambda = 0., mLambda = 0., sL = 0.;
+    Float_t massAntiLambda = 0., sAL = 0.;
+
+    Bool_t isCandidate2K0s = kFALSE;
+    massK0s = v0->MassK0Short();
+    mK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass();
+    if( fCollision.Contains("PbPb2010") )
+      sK0s = kCteK0s2010[curCentBin] + kLinearK0s2010[curCentBin]*pt;
+    else if( fCollision.Contains("PbPb2011") ) 
+      sK0s = kCteK0s2011[curCentBin] + kLinearK0s2011[curCentBin]*pt;
+    if ( TMath::Abs(mK0s-massK0s) < 3*sK0s )  isCandidate2K0s = kTRUE;     
     
+    Bool_t isCandidate2Lambda = kFALSE;
+    massLambda = v0->MassLambda();
+    mLambda = TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass();
+    if( fCollision.Contains("PbPb2010") )
+      sL = kCteLambda2010[curCentBin] + kLinearLambda2010[curCentBin]*pt;
+    else if( fCollision.Contains("PbPb2011") ) 
+      sL = kCteLambda2011[curCentBin] + kLinearLambda2011[curCentBin]*pt;
+    if (TMath::Abs(mLambda-massLambda) < 3*sL)  isCandidate2Lambda = kTRUE;  
+    
+    Bool_t isCandidate2LambdaBar = kFALSE;
+    massAntiLambda = v0->MassAntiLambda();
+    if( fCollision.Contains("PbPb2010") )
+      sAL = kCteAntiLambda2010[curCentBin] + kLinearAntiLambda2010[curCentBin]*pt;
+    else if( fCollision.Contains("PbPb2011") ) 
+      sAL = kCteAntiLambda2011[curCentBin] + kLinearAntiLambda2011[curCentBin]*pt;
+    if (TMath::Abs(mLambda-massAntiLambda) < 3*sAL)  isCandidate2LambdaBar = kTRUE; 
+
+    // **********************************
     // MC Association:
     Bool_t lComeFromSigma     = kTRUE; 
     Bool_t lCheckMcK0Short    = kTRUE;
@@ -2110,8 +2265,8 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     Bool_t lCheckMcAntiLambda = kTRUE;
     Bool_t lComeFromXi        = kTRUE; 
        
-    Int_t lMCAssocNegDaug = 0;
-    Int_t lMCAssocPosDaug = 0;  
+    Int_t lMCAssocNegDaug = -100;
+    Int_t lMCAssocPosDaug = -100;  
     
     // ********* MC - Association *********
     // In case of injected-MC, the correlations might be done with only natural particles 
@@ -2121,6 +2276,8 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
       if(fIsMC){        
        if(!stackMC) goto noas;
 
+       isNaturalPart = kFALSE;
+
        lComeFromSigma     = kFALSE; 
        lCheckMcK0Short    = kFALSE;
        lCheckMcLambda     = kFALSE;
@@ -2150,11 +2307,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
             TMath::Abs(pPart->Eta()) > fMaxEtaDaughter )
          goto noas;
        
+       /*
        // Daughter momentum cut
        if ( ( nPart->Pt() < fMinPtDaughter ) || 
-            ( pPart->Pt() < fMinPtDaughter )  ) 
-         goto noas;
-       
+       ( pPart->Pt() < fMinPtDaughter )  ) 
+       goto noas;
+       */
+
        // ----------------------------------------
        
        Int_t lPDGCodeNegDaughter = nPart->GetPdgCode();
@@ -2219,11 +2378,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
          if (lMCAODMotherOfMother) {lPdgcodeMotherOfMother = lMCAODMotherOfMother->GetPdgCode();}
        }
        
+       /*
        // Daughter momentum cut: ! FIX it in case of AOD ! //MC or REc
        if ( (nPart->Pt()  < fMinPtDaughter ) ||
-            (pPart->Pt()  < fMinPtDaughter ) )
-         goto noas;
-       
+       (pPart->Pt()  < fMinPtDaughter ) )
+       goto noas;
+       */
+
        if( (lPDGCodeV0 != kK0Short) &&
            (lPDGCodeV0 != kLambda0) &&
            (lPDGCodeV0 != kLambda0Bar) ) 
@@ -2300,75 +2461,364 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
        Float_t resEta = p0->Eta() - v0->Eta(); 
        Float_t resPhi = p0->Phi() - v0->Phi(); 
 
-       if (l < 0.01) { // Primary V0
+       if ( (l < 0.01)  &&  (ptAs<10.) ) { // Primary V0
          
          // K0s:
-         if(ctK){ 
+         if(ctK && lCheckMcK0Short){ 
+           
+           // Natural particles
+           if(isNaturalPart){
+
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
 
-           if(lCheckMcK0Short && isNaturalPart){
-             fK0sAssocPt->Fill(ptAs);
-             fK0sAssocPtRap->Fill(ptAs,rapAs,centrality);
+               fK0sAssocPt->Fill(ptAs);
+               fK0sAssocPtRap->Fill(ptAs,rapAs,centrality);
+               fK0sAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
              
-             fK0sAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
+               // Armenteros Pod.  and rapidity cut
+               if( (lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ) && TMath::Abs(rapAs)<fYMax ){ 
+                               
+                 // Distributions for the efficiency (systematics chechks)
+                 fK0sAssocPtMassArm[curCentBin]->Fill(v0->MassK0Short(),ptAs,rapAs);
+                 fK0sAssocMassPtVtx[curCentBin]->Fill(v0->MassK0Short(),ptAs,zv);
+                 fK0sAssocMassPtDCADaug[curCentBin]->Fill(v0->MassK0Short(),ptAs,dca);
+                 fK0sAssocMassPtCPA[curCentBin]->Fill(v0->MassK0Short(),ptAs,cpa);
+               }
              
-             if(lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ){
-               fK0sAssocPtArm->Fill(ptAs,rapAs,centrality);
-               if(TMath::Abs(rapAs)<fYMax)  fK0sAssocPtMassArm->Fill(v0->MassK0Short(),ptAs,centrality);
-             }
-
-             fK0sMCResEta->Fill(resEta,pt,centrality);
-             fK0sMCResPhi->Fill(resPhi,pt,centrality);
-
-           }
+               fK0sMCResEta->Fill(resEta,pt,centrality);
+               fK0sMCResPhi->Fill(resPhi,pt,centrality);
+             
+             } // End selection in the dca to prim. vtx and the number of clusters
+
+             // Distributions for the efficiency (Systematic checks)
+             if( (lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ) && TMath::Abs(rapAs)<fYMax ){ 
+
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fK0sAssocMassPtDCAPV[curCentBin]->Fill(v0->MassK0Short(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fK0sAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassK0Short(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fK0sAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassK0Short(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fK0sAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassK0Short(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fK0sAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassK0Short(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           } // End natural particle selection
            // Embeded particles
            if(!isNaturalPart){ 
-             fK0sAssocPtRapEmbeded->Fill(ptAs,rapAs,centrality);
-             if(lPtArmV0 > TMath::Abs(0.2*lAlphaV0) )
-               fK0sAssocPtArmEmbeded->Fill(ptAs,rapAs,centrality);     
-           }
-           
-         }
-         // End K0s selection
+
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+
+               fK0sAssocPtRapEmbeded->Fill(ptAs,rapAs,centrality);
+
+               if( (lPtArmV0 > TMath::Abs(0.2*lAlphaV0)) && TMath::Abs(rapAs)<fYMax ){
+                 
+                 // Distributions for the efficiency (systematics chechks)
+                 fK0sAssocPtMassArmEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,rapAs);    
+                 fK0sAssocMassPtVtxEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,zv);
+                 fK0sAssocMassPtDCADaugEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,dca);
+                 fK0sAssocMassPtCPAEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,cpa);
+               }
+
+             } // End selection in the dca to prim. vtx and the number of clusters
+
+             // Distributions for the efficiency (Systematic checks)
+             if( (lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ) && TMath::Abs(rapAs)<fYMax ){ 
+
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fK0sAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fK0sAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fK0sAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fK0sAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fK0sAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassK0Short(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           } // End embeded particle selection
+
+         }  // End K0s selection
+
          // Lambda:
-         else if(ctL) {  
+         if(ctL && lCheckMcLambda) {  
+           
+           // Natural particles
+           if(isNaturalPart){
 
-           if(lCheckMcLambda && isNaturalPart){
-             fLambdaAssocPt->Fill(ptAs);
-             fLambdaAssocPtRap->Fill(ptAs,rapAs,centrality);
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
 
-             fLambdaAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
+               fLambdaAssocPt->Fill(ptAs);
+               fLambdaAssocPtRap->Fill(ptAs,rapAs,centrality);
+               fLambdaAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
 
-             if(TMath::Abs(rapAs)<fYMax)  fLambdaAssocPtMass->Fill(v0->MassLambda(),ptAs,centrality);
+               // Rapidity cut
+               if(TMath::Abs(rapAs)<fYMax)  {
 
-             fLambdaMCResEta->Fill(resEta,pt,centrality);
-             fLambdaMCResPhi->Fill(resPhi,pt,centrality);
-           }
+                 // Distributions for the efficiency (systematics chechks)
+                 fLambdaAssocMassPtRap[curCentBin]->Fill(v0->MassLambda(),ptAs,rapAs);
+                 fLambdaAssocMassPtVtx[curCentBin]->Fill(v0->MassLambda(),ptAs,zv);
+                 fLambdaAssocMassPtDCADaug[curCentBin]->Fill(v0->MassLambda(),ptAs,dca);
+                 fLambdaAssocMassPtCPA[curCentBin]->Fill(v0->MassLambda(),ptAs,cpa);
+
+                 if( !isCandidate2K0s && !isCandidate2LambdaBar)
+                   fLambdaAssocMassPtRap2[curCentBin]->Fill(v0->MassLambda(),ptAs,rapAs);
+
+               }
+
+               fLambdaMCResEta->Fill(resEta,pt,centrality);
+               fLambdaMCResPhi->Fill(resPhi,pt,centrality);
+
+             } // End selection in the dca to prim. vtx and the number of clusters
+             
+             // Distributions for the efficiency (Systematic checks)
+             if( TMath::Abs(rapAs)<fYMax ){ 
+               
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassLambda(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassLambda(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassLambda(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassLambda(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassLambda(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           } // End natural particle selection
            // Embeded particles
-           if(ctL && !isNaturalPart)
-             fLambdaAssocPtRapEmbeded->Fill(ptAs,rapAs,centrality);
+           if(!isNaturalPart){
 
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+             
+               if( TMath::Abs(rapAs)<fYMax ){
+                 // Distributions for the efficiency (systematics chechks)
+                 fLambdaAssocMassPtRapEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,rapAs);
+                 fLambdaAssocMassPtVtxEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,zv);
+                 fLambdaAssocMassPtDCADaugEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,dca);
+                 fLambdaAssocMassPtCPAEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,cpa);
+
+                 if( !isCandidate2K0s && !isCandidate2LambdaBar)
+                   fLambdaAssocMassPtRapEmbeded2[curCentBin]->Fill(v0->MassLambda(),ptAs,rapAs);
+               }
+
+             } // End selection in the dca to prim. vtx and the number of clusters
+
+             // Distributions for the efficiency (Systematic checks)
+             if( TMath::Abs(rapAs)<fYMax ){ 
+
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassLambda(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           }  // End embeded particle selection
+           
          } // End Lambda selection
+
          // AntiLambda:
-         else if (ctAL){
+         if (ctAL && lCheckMcAntiLambda){
+           
+           if(isNaturalPart){
 
-           if(lCheckMcAntiLambda && isNaturalPart){
-             fAntiLambdaAssocPt->Fill(ptAs);
-             fAntiLambdaAssocPtRap->Fill(ptAs,rapAs,centrality);
-             
-             fAntiLambdaAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
-             
-             if(TMath::Abs(rapAs)<fYMax)  fAntiLambdaAssocPtMass->Fill(v0->MassAntiLambda(),ptAs,centrality);
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
 
-             fAntiLambdaMCResEta->Fill(resEta,pt,centrality);
-             fAntiLambdaMCResPhi->Fill(resPhi,pt,centrality);
-           }
+               fAntiLambdaAssocPt->Fill(ptAs);
+               fAntiLambdaAssocPtRap->Fill(ptAs,rapAs,centrality);
+               fAntiLambdaAssocPtPhiEta[curCentBin]->Fill(p0->Phi(),etaAs,ptAs);
+  
+               // Rapidity cut
+               if(TMath::Abs(rapAs)<fYMax)  {
+
+                 // Distributions for the efficiency (systematics chechks)
+                 fAntiLambdaAssocMassPtRap[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,rapAs);
+                 fAntiLambdaAssocMassPtVtx[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,zv);
+                 fAntiLambdaAssocMassPtDCADaug[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,dca);
+                 fAntiLambdaAssocMassPtCPA[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,cpa);
+
+                 if( !isCandidate2K0s && !isCandidate2Lambda )
+                   fAntiLambdaAssocMassPtRap2[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,rapAs);
+               }
+
+               fAntiLambdaMCResEta->Fill(resEta,pt,centrality);
+               fAntiLambdaMCResPhi->Fill(resPhi,pt,centrality);
+
+             } // End selection in the dca to prim. vtx and the number of clusters
+
+             // Distributions for the efficiency (Systematic checks)
+             if( TMath::Abs(rapAs)<fYMax ){ 
+               
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fAntiLambdaAssocMassPtDCAPV[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fAntiLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fAntiLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fAntiLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fAntiLambdaAssocMassPtDaugNClsTPC[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           }  // End natural particle selection
            // Embeded particles
-           if(ctAL && !isNaturalPart)
-             fAntiLambdaAssocPtRapEmbeded->Fill(ptAs,rapAs,centrality);
+           if(!isNaturalPart){
+
+             if( (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+
+               if( TMath::Abs(rapAs)<fYMax ){
+                 // Distributions for the efficiency (systematics chechks)
+                 fAntiLambdaAssocMassPtRapEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,rapAs);
+                 fAntiLambdaAssocMassPtVtxEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,zv);
+                 fAntiLambdaAssocMassPtDCADaugEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,dca);
+                 fAntiLambdaAssocMassPtCPAEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,cpa);
+
+                 if( !isCandidate2K0s && !isCandidate2Lambda )
+                   fAntiLambdaAssocMassPtRapEmbeded2[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,rapAs);
+               }
+
+             } // End selection in the dca to prim. vtx and the number of clusters
+
+
+             // Distributions for the efficiency (Systematic checks)
+             if( TMath::Abs(rapAs)<fYMax ){ 
+
+               //  Cut in the DCA ToPrim Vtx
+               if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 if( (dcaPos>0.1) && (dcaNeg>0.1) ) // default value
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,1);
+                 if( (dcaPos>0.095) && (dcaNeg>0.095) )
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,2);
+                 if( (dcaPos>0.115) && (dcaNeg>0.115) ) 
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,3);
+                 if( (dcaPos>0.12) && (dcaNeg>0.12) )
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,4);
+                 if( (dcaPos>0.2) && (dcaNeg>0.2) )
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,5);
+                 if( (dcaPos>0.5) && (dcaNeg>0.5) )
+                   fAntiLambdaAssocMassPtDCAPVEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,6);
+               }                 
+
+               // cut in the number of tpc ckusters
+               if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+                 if( (nClsTPCPos>70) && (nClsTPCNeg>70) )  // default value
+                   fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,1);
+                 if( (nClsTPCPos>50) && (nClsTPCNeg>50) )
+                   fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,2);
+                 if( (nClsTPCPos>60) && (nClsTPCNeg>60) )
+                   fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,3);
+                 if( (nClsTPCPos>80) && (nClsTPCNeg>80) )
+                   fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[curCentBin]->Fill(v0->MassAntiLambda(),ptAs,4);
+               }
+
+             } // End selection for systematics
+
+           }  // End embeded particle selection
            
          } // End AntiLambda:
          // Xi decay:
-         if( lComeFromXi ){
+         if( lComeFromXi && isNaturalPart ){
            if(lPDGCodeV0==3122) { fLambdaAssocFromXi->Fill(ptAs,centrality); }
            else if(lPDGCodeV0==-3122) { fAntiLambdaAssocFromXi->Fill(ptAs,centrality); }
          }
@@ -2381,94 +2831,48 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
          lMCAssocNegDaug = 6;
        if(lMCAssocPosDaug==0)
          lMCAssocPosDaug = 6;
-       
-       
+               
       } // End MC-Association 
       
-      // ************************************
-      
     }// End Correlation Step
-    
+   
+    // ************************************
   noas:
 
-    Float_t pPos = -100.;
-    Float_t pNeg = -100.;
-    Float_t dedxPos = -1000.;
-    Float_t dedxNeg = -1000.;
+    /*
+      Float_t pPos = -100.;
+      Float_t pNeg = -100.;
     
-    //Float_t nsigPosPion   = 0.;
-    Float_t nsigPosProton = 0.;
-    //Float_t nsigNegPion   = 0.;
-    Float_t nsigNegProton = 0.;
-
-    /*  
-       if(fUsePID && !fIsMC) {     
-       const AliAODPid *pidNeg = ntrack->GetDetPid();
-       const AliAODPid *pidPos = ptrack->GetDetPid();
+      Float_t dedxPos = -1000.;
+      Float_t dedxNeg = -1000.;
+      Float_t nsigPosPion   = 0.;
+      Float_t nsigNegPion   = 0.;
+      Float_t nsigPosProton = 0.;
+      Float_t nsigNegProton = 0.;
+
+      if(fUsePID && !fIsMC) {     
+      const AliAODPid *pidNeg = ntrack->GetDetPid();
+      const AliAODPid *pidPos = ptrack->GetDetPid();
       
-       if (pidNeg && pidPos) {
-       pPos = pidPos->GetTPCmomentum();
-       pNeg = pidNeg->GetTPCmomentum();
-       dedxPos = pidPos->GetTPCsignal()/47.; 
-       dedxNeg = pidNeg->GetTPCsignal()/47.; 
+      if (pidNeg && pidPos) {
+      pPos = pidPos->GetTPCmomentum();
+      pNeg = pidNeg->GetTPCmomentum();
+      dedxPos = pidPos->GetTPCsignal()/47.; 
+      dedxNeg = pidNeg->GetTPCsignal()/47.; 
   
 
-       if(pPos<1.){
-       nsigPosPion   = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ptrack,AliPID::kPion));
-       nsigPosProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ptrack,AliPID::kProton));
-       }
-       if(pNeg<1.){
-       nsigNegPion   = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ntrack,AliPID::kPion));
-       nsigNegProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ntrack,AliPID::kProton));
-       }
-
-       }
-
-       }
-    */
-
-    Double_t pNegDaug[3];  ntrack->GetPxPyPz(pNegDaug);                  
-    Double_t pPosDaug[3];  ptrack->GetPxPyPz(pPosDaug);
-
-    Float_t dcaNeg = v0->DcaNegToPrimVertex();
-    Float_t dcaPos = v0->DcaPosToPrimVertex();
-
-    Float_t phiNeg = ntrack->Phi();
-    Float_t phiPos = ptrack->Phi();
-    Float_t difPtNeg = pt - lPtNeg;
-    Float_t difPtPos = pt - lPtPos;
-
-    Float_t dca   = v0->DcaV0Daughters();
-    Float_t cpa   = v0->CosPointingAngle(fAOD->GetPrimaryVertex());
-    Float_t lEta  = v0->PseudoRapV0();
-    Float_t lPhi  = v0->Phi();
-    //lPhi  = ( (lPhi < 0) ? lPhi + 2*TMath::Pi() : lPhi );    
-
-    // Number of clusters of daughters in the TPC and ITS
-    Double_t posITSNcls = ptrack->GetITSNcls();   
-    Double_t negITSNcls = ntrack->GetITSNcls();
-
-    Double_t posTPCNcls = ptrack->GetTPCNclsF();
-    Double_t negTPCNcls = ntrack->GetTPCNclsF();
-   
-
-    //cout << "  negITSNcls " << negITSNcls << " posITSNcls " << posITSNcls << endl;
-    //cout << "  negTPCNcls " << negTPCNcls << " posTPCNcls " << posTPCNcls << endl;
+      if(pPos<1.){
+      nsigPosPion   = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ptrack,AliPID::kPion));
+      nsigPosProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ptrack,AliPID::kProton));
+      }
+      if(pNeg<1.){
+      nsigNegPion   = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ntrack,AliPID::kPion));
+      nsigNegProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(ntrack,AliPID::kProton));
+      }
 
-    /*
-    // Good regions
-    lPhi  = v0->Phi();
-    if(lPhi>0. && lPhi<1.8) continue;
-    if(lPhi>2.2 && lPhi<3.8) continue;
-    if(lPhi>4.2 && lPhi<5.8) continue;
-    */
+      }
 
-    /*
-    // Bad regions
-    lPhi  = v0->Phi();
-    if(lPhi>1.8 && lPhi<2.2) continue;
-    if(lPhi>3.8 && lPhi<4.2) continue;
-    if(lPhi>5.8 && lPhi<6.2) continue;
+      }
     */
 
     // Comparing the pt of the trigger particle wrt the v0-candidate's daughter:
@@ -2480,42 +2884,9 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
       isSameTrkNegDaug = SameTrack(trkTrig,ntrack);
     }
 
-    // **********************************
-    // Disentangle the V0 candidate
-    Float_t massK0s = 0., mK0s = 0., sK0s = 0.;
-    Float_t massLambda = 0., mLambda = 0., sL = 0.;
-    Float_t massAntiLambda = 0., sAL = 0.;
-
-    Bool_t isCandidate2K0s = kFALSE;
-    massK0s = v0->MassK0Short();
-    mK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass();
-    if( fCollision.Contains("PbPb2010") )
-      sK0s = kCteK0s2010[curCentBin] + kLinearK0s2010[curCentBin]*pt;
-    else if( fCollision.Contains("PbPb2011") ) 
-      sK0s = kCteK0s2011[curCentBin] + kLinearK0s2011[curCentBin]*pt;
-    if ( TMath::Abs(mK0s-massK0s) < 3*sK0s )  isCandidate2K0s = kTRUE;     
-    
-    Bool_t isCandidate2Lambda = kFALSE;
-    massLambda = v0->MassLambda();
-    mLambda = TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass();
-    if( fCollision.Contains("PbPb2010") )
-      sL = kCteLambda2010[curCentBin] + kLinearLambda2010[curCentBin]*pt;
-    else if( fCollision.Contains("PbPb2011") ) 
-      sL = kCteLambda2011[curCentBin] + kLinearLambda2011[curCentBin]*pt;
-    if (TMath::Abs(mLambda-massLambda) < 3*sL)  isCandidate2Lambda = kTRUE;  
-    
-    Bool_t isCandidate2LambdaBar = kFALSE;
-    massAntiLambda = v0->MassAntiLambda();
-    if( fCollision.Contains("PbPb2010") )
-      sAL = kCteAntiLambda2010[curCentBin] + kLinearAntiLambda2010[curCentBin]*pt;
-    else if( fCollision.Contains("PbPb2011") ) 
-      sAL = kCteAntiLambda2011[curCentBin] + kLinearAntiLambda2011[curCentBin]*pt;
-    if (TMath::Abs(mLambda-massAntiLambda) < 3*sAL)  isCandidate2LambdaBar = kTRUE; 
-
     // *******************
     //   Gamma conversion
     // *******************
-
     if(step==kReconstruction)
       if( (TMath::Sqrt(lPtArmV0*lPtArmV0 + lAlphaV0*lAlphaV0) < 0.2)  && isNaturalPart ){
        fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 2) );
@@ -2524,39 +2895,39 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     // *******************
     //   K0s selection
     // *******************
-    if (ctK && (TMath::Abs(v0->RapK0Short())<fYMax) &&
-        ( lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ) && ( massK0s > 0.3979 && massK0s < 0.5981 ) ) {
+    if (ctK && (TMath::Abs(v0->RapK0Short())<fYMax) && ( lPtArmV0 > TMath::Abs(0.2*lAlphaV0) ) && ( massK0s > 0.3979 && massK0s < 0.5981 ) ) {
       
       switch(step) {
       case kTriggerCheck: 
 
-       if (isCandidate2K0s){
+       if (isCandidate2K0s && (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+
          if(pt>ptTrig){
            fIsV0LP = 1; 
            fPtV0LP = pt;
          }       
          
-         if( isSameTrkPosDaug==1 || isSameTrkNegDaug==1 ){
+         if( isSameTrkPosDaug==1 || isSameTrkNegDaug==1){
            Printf("  The LP has the same momentum in X and Y as one of the K0s daughters *** iV0 %d",iV0); 
-
+           
            if(fCheckIDTrig){  // Compare properties of daughters nad 
-              Float_t difNegP[3];
+             Float_t difNegP[3];
              difNegP[0] = (pTrig[0]-pNegDaug[0])/pTrig[0];  difNegP[1] = (pTrig[1]-pNegDaug[1])/pTrig[1]; difNegP[2] = (pTrig[2]-pNegDaug[2])/pTrig[2];
-              Float_t difPosP[3]; 
+             Float_t difPosP[3]; 
              difPosP[0] = (pTrig[0]-pPosDaug[0])/pTrig[0];  difPosP[1] = (pTrig[1]-pPosDaug[1])/pTrig[1]; difPosP[2] = (pTrig[2]-pPosDaug[2])/pTrig[2];
              Float_t posDeltaPhi =  phiTrig - phiPos, negDeltaPhi =  phiTrig - phiNeg;
              Float_t posDeltaEta =  etaTrig - etaPos, negDeltaEta =  etaTrig - etaNeg;
-           
+             
              /*
-             Printf("  The LP has the same momentum in X and Y as one of the K0s daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
-                    iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
-                    TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
-                    TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
-                    TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
-                    TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
-                    );
+               Printf("  The LP has the same momentum in X and Y as one of the K0s daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
+               iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
+               TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
+               TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
+               TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
+               TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
+               );
              */
-
+             
              // Positive daughter
              if( isSameTrkPosDaug==1 ){
                for(Int_t i=0;i<3;i++)
@@ -2573,105 +2944,108 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
              }
              
            } // End check ID
-
-
+           
+           
            fTriggerParticles->RemoveAt(iArray);
            fTriggerParticles->AddAt( new AliMiniParticle(centrality, zv, idTrig, ptTrig, phiTrig, etaTrig, 0, 0, 0), iArray);
            
          } // Close isTrigFromV0daug
-
+         
        }// End K0s Mass cut
-
+       
        break; // End K0s selection for TriggerCheck
       case kReconstruction:
        
-       fK0sMass->Fill(massK0s,pt,centrality);
-
-       fK0sPtvsEta->Fill(pt,lEta,0);
-       fK0sPtvsRap->Fill(pt,v0->RapK0Short(),0);
-       fK0sMassPtPhi->Fill(massK0s,pt,lPhi);
-
-       if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
-         fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 3) );
+       if( (dcaPos > 0.1) && (dcaNeg > 0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) && (pt<10.) ){
+         
+         if(isNaturalPart) fK0sMass->Fill(massK0s,pt,centrality);
+         else fK0sMassEmbeded->Fill(massK0s,pt,centrality);
+         
+         fK0sPtvsEta->Fill(pt,lEta,0);
+         fK0sPtvsRap->Fill(pt,v0->RapK0Short(),0);
+         fK0sMassPtPhi->Fill(massK0s,pt,lPhi);
 
-       // Only for triggered events and in case of MC K0s is not an embeded particle
-       if( isTriggered && isNaturalPart ){
+         if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 3) );
          
-         fK0sPtvsEta->Fill(pt,lEta,1);
-         fK0sPtvsRap->Fill(pt,v0->RapK0Short(),1);
+         // Only for triggered events and in case of MC K0s is not an embeded particle
+         if( isTriggered && isNaturalPart ){
+           fK0sPtvsEta->Fill(pt,lEta,1);
+           fK0sPtvsRap->Fill(pt,v0->RapK0Short(),1);     
+         }
          
        }
 
-       // Invariant Mass cut
-       if (TMath::Abs(mK0s-massK0s) < 3*sK0s) {
+       if( fDoQA && lCheckMcK0Short && isNaturalPart && (pt<10.) ){ // Quality Assurance
 
-         fK0sEtaPhi->Fill(lPhi,lEta);
-         fK0sPtvsEta->Fill(pt,lEta,2);
-         fK0sPtvsRap->Fill(pt,v0->RapK0Short(),2);
+         // Invariant Mass cut
+         if (TMath::Abs(mK0s-massK0s) < 3*sK0s) {
 
-         if(fDoQA && lCheckMcK0Short){ // Quality Assurance
-           fK0sPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fK0sPIDNegDaug->Fill(pNeg,dedxNeg,pt);
-           
-           fK0sPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fK0sPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
-           
-           fK0sDCAPosDaug->Fill(dcaPos,pt);
-           fK0sDCANegDaug->Fill(dcaNeg,pt);
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+             fK0sDCAPosDaug->Fill(dcaPos,pt);
+             fK0sDCANegDaug->Fill(dcaNeg,pt);
+           }
+
+           if( (dcaPos > 0.1) && (dcaNeg > 0.1) ){
+
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+               fK0sPtPosDaug->Fill(pt,lPtPos);
+               fK0sPtNegDaug->Fill(pt,lPtNeg);
+
+               fK0sPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+               fK0sPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
            
-           fK0sDifPtPosDaug->Fill(difPtPos,pt);
-           fK0sDifPtNegDaug->Fill(difPtNeg,pt);
+               fK0sDecayPos->Fill(dx,dy,pt);
+               fK0sDecayVertex->Fill(lt,pt);
            
-           fK0sDecayPos->Fill(dx,dy,pt);
-           fK0sDecayVertex->Fill(lt,pt);
+               fK0sCPA->Fill(cpa,pt); 
+               fK0sDCAV0Daug->Fill(dca,pt); 
+
+               fK0sNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+               fK0sNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+             }
+
+             fK0sNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fK0sNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
+           }
+
+         } // End selection in mass
+
+         if( TMath::Abs(mK0s-massK0s + 6.5*sK0s) < 1.5*sK0s ||
+             TMath::Abs(mK0s-massK0s - 6.5*sK0s) < 1.5*sK0s  ) {
+
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+             fK0sBckgDCAPosDaug->Fill(dcaPos,pt);
+             fK0sBckgDCANegDaug->Fill(dcaNeg,pt);
+           }
            
-           if(lt<1.0)
-             fK0sDecayVertexZoom->Fill(lt,pt); //**
-           fK0sCPA->Fill(cpa,pt); //**
-           fK0sDCAV0Daug->Fill(dca,pt); //**
-
-           fK0sNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fK0sNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fK0sNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fK0sNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
-             
-         }// End QA 
-         
-       } // End selection in mass
-       if( TMath::Abs(mK0s-massK0s + 6.5*sK0s) < 1.5*sK0s ||
-           TMath::Abs(mK0s-massK0s - 6.5*sK0s) < 1.5*sK0s  ) {
+           if( (dcaPos > 0.1) && (dcaNeg > 0.1) ){
 
-         fK0sEtaPhi->Fill(lPhi,lEta,-1);
-         
-         if(fDoQA && lCheckMcK0Short){ // Quality Assurance
-           fK0sBckgPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fK0sBckgPIDNegDaug->Fill(pNeg,dedxNeg,pt);
-            
-           fK0sBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fK0sBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+               fK0sBckgPtPosDaug->Fill(pt,lPtPos);
+               fK0sBckgPtNegDaug->Fill(pt,lPtNeg);
              
-           fK0sBckgDCAPosDaug->Fill(dcaPos,pt);
-           fK0sBckgDCANegDaug->Fill(dcaNeg,pt);
+               fK0sBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+               fK0sBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
              
-           fK0sBckgDifPtPosDaug->Fill(difPtPos,pt);
-           fK0sBckgDifPtNegDaug->Fill(difPtNeg,pt);
+               fK0sBckgDecayPos->Fill(dx,dy,pt);
+               fK0sBckgDecayVertex->Fill(lt,pt);
              
-           fK0sBckgDecayPos->Fill(dx,dy,pt);
-           fK0sBckgDecayVertex->Fill(lt,pt);
+               fK0sBckgCPA->Fill(cpa,pt); 
+               fK0sBckgDCAV0Daug->Fill(dca,pt); 
              
-           if(lt<1.0)
-             fK0sBckgDecayVertexZoom->Fill(lt,pt); //**
-           fK0sBckgCPA->Fill(cpa,pt); //**
-           fK0sBckgDCAV0Daug->Fill(dca,pt); //**
-             
-           fK0sBckgNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fK0sBckgNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fK0sBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fK0sBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+               fK0sBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+               fK0sBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+             }
 
-         } // End QA
+             fK0sBckgNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fK0sBckgNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
 
-       }// End selection in outside the mass cut
+           }
+
+         }// End selection in outside the mass cut
+
+       } // End QA
        
        break; // End K0s selection for Corrleation
       default:
@@ -2685,14 +3059,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     // *******************
     // Lambda selection
     // *******************
-    if ( ctL && (TMath::Abs(v0->RapLambda())<fYMax)  &&
-        (nsigPosProton < fNSigma) && !isCandidate2K0s && !isCandidate2LambdaBar
-        && (massLambda > 1.0649 && massLambda < 1.1651 ) ){
+    if ( ctL && (TMath::Abs(v0->RapLambda())<fYMax) && (massLambda > 1.0649 && massLambda < 1.1651 ) ){
 
       switch(step) {
       case kTriggerCheck: 
        
-       if (isCandidate2Lambda){
+       if (isCandidate2Lambda && (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70 )){
+
          if(pt>ptTrig) {
            fIsV0LP = 1;
            fPtV0LP = pt;
@@ -2710,13 +3083,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
              Float_t posDeltaEta =  etaTrig - etaPos, negDeltaEta =  etaTrig - etaNeg;
     
              /*
-             Printf("  The LP has the same momentum in X and Y as one of the Lambda daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
-                    iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
-                    TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
-                    TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
-                    TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
-                    TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
-                    );
+               Printf("  The LP has the same momentum in X and Y as one of the Lambda daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
+               iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
+               TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
+               TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
+               TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
+               TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
+               );
              */
 
              // Positive daughter
@@ -2745,93 +3118,102 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
        break; // End Lambda selection for TriggerCheck
       case kReconstruction:
        
-       fLambdaMass->Fill(massLambda,pt,centrality);
-       fLambdaPtvsEta->Fill(pt,lEta,0);
-       fLambdaPtvsRap->Fill(pt,v0->RapLambda(),0);
-       
-       fLambdaMassPtPhi->Fill(massLambda,pt,lPhi);
+       if( (dcaPos > 0.1) && (dcaNeg > 0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70 ) && (pt<10.) ){
+
+         if(isNaturalPart) fLambdaMass->Fill(massLambda,pt,centrality);
+         else  fLambdaMassEmbeded->Fill(massLambda,pt,centrality);
+
+         if( !isCandidate2K0s && !isCandidate2LambdaBar){
+           if(isNaturalPart) fLambdaMass2->Fill(massLambda,pt,centrality);
+           else fLambdaMass2Embeded->Fill(massLambda,pt,centrality);
+         }
 
-       if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
-         fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 4) );
+         fLambdaPtvsEta->Fill(pt,lEta,0);
+         fLambdaPtvsRap->Fill(pt,v0->RapLambda(),0);   
+         fLambdaMassPtPhi->Fill(massLambda,pt,lPhi);
 
-       // Only for triggered events and in case of MC Lambda is not a embeded particle
-       if( isTriggered && isNaturalPart ){
+         if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 4) );
          
-         fLambdaPtvsEta->Fill(pt,lEta,1);
-         fLambdaPtvsRap->Fill(pt,v0->RapLambda(),1);
+         // Only for triggered events and in case of MC Lambda is not a embeded particle
+         if( isTriggered && isNaturalPart){
+           fLambdaPtvsEta->Fill(pt,lEta,1);
+           fLambdaPtvsRap->Fill(pt,v0->RapLambda(),1);
+         } 
          
-       } 
+       }
+       
        // Invariant Mass cut
-       if (TMath::Abs(mLambda-massLambda) < 3*sL) {
-
-         fLambdaEtaPhi->Fill(lPhi,lEta);
-         fLambdaPtvsEta->Fill(pt,lEta,2);
-         fLambdaPtvsRap->Fill(pt,v0->RapLambda(),2);
-         
-         if(fDoQA && lCheckMcLambda){ // Quality Assurance
-           fLambdaPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fLambdaPIDNegDaug->Fill(pNeg,dedxNeg,pt);
+       if(fDoQA && lCheckMcLambda && isNaturalPart && (pt<10.)){ // Quality Assurance
           
-           fLambdaPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fLambdaPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+         // Invariant Mass cut
+         if (TMath::Abs(mLambda-massLambda) < 3*sL) {
 
-           fLambdaDCAPosDaug->Fill(dcaPos,pt);
-           fLambdaDCANegDaug->Fill(dcaNeg,pt);
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+             fLambdaDCAPosDaug->Fill(dcaPos,pt);
+             fLambdaDCANegDaug->Fill(dcaNeg,pt);
+           }
 
-           fLambdaDifPtPosDaug->Fill(difPtPos,pt);
-           fLambdaDifPtNegDaug->Fill(difPtNeg,pt);
+           if( (dcaPos > 0.1) && (dcaNeg > 0.1) ){
 
-           fLambdaDecayPos->Fill(dx,dy,pt);
-           fLambdaDecayVertex->Fill(lt,pt);
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+               fLambdaPtPosDaug->Fill(pt,lPtPos);
+               fLambdaPtNegDaug->Fill(pt,lPtNeg);
 
-           if(lt<1.0)
-             fLambdaDecayVertexZoom->Fill(lt,pt); //**
-           fLambdaCPA->Fill(cpa,pt); //**
-           fLambdaDCAV0Daug->Fill(dca,pt); //**
+               fLambdaPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+               fLambdaPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
 
-           fLambdaNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fLambdaNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fLambdaNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fLambdaNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+               fLambdaDecayPos->Fill(dx,dy,pt);
+               fLambdaDecayVertex->Fill(lt,pt);
 
-         } //End QA
-                 
-       } // End selection in mass
-       
-       if( (TMath::Abs(mLambda-massLambda + 6.5*sL) < 1.5*sL) ||
-           (TMath::Abs(mLambda-massLambda - 6.5*sL) < 1.5*sL) ){
+               fLambdaCPA->Fill(cpa,pt); 
+               fLambdaDCAV0Daug->Fill(dca,pt); 
 
-         fLambdaEtaPhi->Fill(lPhi,lEta,-1);
-         
-         if(fDoQA && lCheckMcLambda){ // Quality Assurance
-           fLambdaBckgPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fLambdaBckgPIDNegDaug->Fill(pNeg,dedxNeg,pt);
-          
-           fLambdaBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fLambdaBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+               fLambdaNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+               fLambdaNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+             }
+
+             fLambdaNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fLambdaNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
+
+           }
 
-           fLambdaBckgDCAPosDaug->Fill(dcaPos,pt);
-           fLambdaBckgDCANegDaug->Fill(dcaNeg,pt);
+         } // End selection in mass
+       
+         if( (TMath::Abs(mLambda-massLambda + 6.5*sL) < 1.5*sL) ||
+             (TMath::Abs(mLambda-massLambda - 6.5*sL) < 1.5*sL) ){
 
-           fLambdaBckgDifPtPosDaug->Fill(difPtPos,pt);
-           fLambdaBckgDifPtNegDaug->Fill(difPtNeg,pt);
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+             fLambdaBckgDCAPosDaug->Fill(dcaPos,pt);
+             fLambdaBckgDCANegDaug->Fill(dcaNeg,pt);
+           }       
 
-           fLambdaBckgDecayPos->Fill(dx,dy,pt);
-           fLambdaBckgDecayVertex->Fill(lt,pt);
+           if( (dcaPos > 0.1) && (dcaNeg > 0.1) ){
 
-           if(lt<1.0)
-             fLambdaBckgDecayVertexZoom->Fill(lt,pt); //**
-           fLambdaBckgCPA->Fill(cpa,pt); //**
-           fLambdaBckgDCAV0Daug->Fill(dca,pt); //**
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+               fLambdaBckgPtPosDaug->Fill(pt,lPtPos);
+               fLambdaBckgPtNegDaug->Fill(pt,lPtNeg);
 
-           fLambdaBckgNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fLambdaBckgNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fLambdaBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fLambdaBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+               fLambdaBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+               fLambdaBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+             
+               fLambdaBckgDecayPos->Fill(dx,dy,pt);
+               fLambdaBckgDecayVertex->Fill(lt,pt);
+             
+               fLambdaBckgCPA->Fill(cpa,pt); 
+               fLambdaBckgDCAV0Daug->Fill(dca,pt); 
 
-         } // End QA
+               fLambdaBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+               fLambdaBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+             }
+             
+             fLambdaBckgNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fLambdaBckgNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
+           }
 
-       }// End selection in outside the mass cut
+         }// End selection in outside the mass cut  
+         
+       } // End QA
 
        break; // End Lambda selection for Correlation
       default:
@@ -2845,14 +3227,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
     // *******************
     // AntiLambda selection
     // *******************
-    if ( ctAL && (TMath::Abs(v0->RapLambda())<fYMax)  &&
-        (nsigNegProton < fNSigma)  && !isCandidate2K0s && !isCandidate2Lambda 
-        && (massAntiLambda > 1.0649 && massAntiLambda < 1.1651 ) ) {
+    if ( ctAL && (TMath::Abs(v0->RapLambda())<fYMax)  && (massAntiLambda > 1.0649 && massAntiLambda < 1.1651 ) ) {
       
       switch(step) {
       case kTriggerCheck: 
        
-       if (isCandidate2LambdaBar){
+       if (isCandidate2LambdaBar && (dcaPos>0.1) && (dcaNeg>0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+
          if(pt>ptTrig) {
            fIsV0LP = 1;
            fPtV0LP = pt;
@@ -2870,13 +3251,13 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
              Float_t posDeltaEta =  etaTrig - etaPos, negDeltaEta =  etaTrig - etaNeg;
 
              /*
-             Printf("  The LP has the same momentum in X and Y as one of the AntiLambda daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
-                    iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
-                    TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
-                    TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
-                    TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
-                    TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
-                    );
+               Printf("  The LP has the same momentum in X and Y as one of the AntiLambda daughters *** iV0 %d \n\t\t %d %d %d \n\t\t %lf %lf %lf \n\t\t %lf %lf %lf \n\t\t %lf %lf \n\t\t %lf %lf ",
+               iV0, TMath::Abs( trkTrig->GetID() ), ntrack->GetID() ,  ptrack->GetID() ,
+               TMath::Abs( difNegP[1] ), TMath::Abs( difNegP[2] ), TMath::Abs( difNegP[0] ),
+               TMath::Abs( difPosP[1] ), TMath::Abs( difPosP[2] ), TMath::Abs( difPosP[0] ),
+               TMath::Abs( negDeltaPhi ), TMath::Abs( negDeltaEta ),
+               TMath::Abs( posDeltaPhi ), TMath::Abs( posDeltaEta )
+               );
              */
 
              // Positive daughter
@@ -2905,93 +3286,102 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
        break; // End AntiLambda selection for CheckTrigger
       case kReconstruction: 
        
-       fAntiLambdaMass->Fill(massAntiLambda,pt,centrality);
-       fAntiLambdaPtvsEta->Fill(pt,lEta,0);
-       fAntiLambdaPtvsRap->Fill(pt,v0->RapLambda(),0);
+       if( (dcaPos > 0.1) && (dcaNeg > 0.1) && (nClsTPCPos>70) && (nClsTPCNeg>70 ) && (pt<10.) ) {
 
-       fAntiLambdaMassPtPhi->Fill(massAntiLambda,pt,lPhi);
-         
-       if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
-         fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 5) );
+         if(isNaturalPart)  fAntiLambdaMass->Fill(massAntiLambda,pt,centrality);
+         else fAntiLambdaMassEmbeded->Fill(massAntiLambda,pt,centrality);
 
-       // Only for triggered events and in case of MC AntiLambda is not a embeded particle
-       if( isTriggered && isNaturalPart ){
-         
-         fAntiLambdaPtvsEta->Fill(pt,lEta,1);
-         fAntiLambdaPtvsRap->Fill(pt,v0->RapLambda(),1);
-         
-       } 
-       // Invariant Mass cut
-       if (TMath::Abs(mLambda-massAntiLambda) < 3*sAL) {
-         fAntiLambdaEtaPhi->Fill(lPhi,lEta);
-         fAntiLambdaPtvsEta->Fill(pt,lEta,2);
-         fAntiLambdaPtvsRap->Fill(pt,v0->RapLambda(),2);
-
-         if(fDoQA && lCheckMcAntiLambda){ // Quality Assurance
-           fAntiLambdaPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fAntiLambdaPIDNegDaug->Fill(pNeg,dedxNeg,pt);
-          
-           fAntiLambdaPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fAntiLambdaPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+         if( !isCandidate2K0s && !isCandidate2Lambda) {
+           if(isNaturalPart) fAntiLambdaMass2->Fill(massAntiLambda,pt,centrality);
+           else fAntiLambdaMass2Embeded->Fill(massAntiLambda,pt,centrality);
+         }
 
-           fAntiLambdaDCAPosDaug->Fill(dcaPos,pt);
-           fAntiLambdaDCANegDaug->Fill(dcaNeg,pt);
+         fAntiLambdaPtvsEta->Fill(pt,lEta,0);
+         fAntiLambdaPtvsRap->Fill(pt,v0->RapLambda(),0);         
+         fAntiLambdaMassPtPhi->Fill(massAntiLambda,pt,lPhi);
+       
+         if( (pt>kPtBinV0[0]) && (pt<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocParticles->Add( new AliMiniParticle(centrality, zv, iV0, pt, lPhi, lEta, lMCAssocNegDaug, lMCAssocPosDaug, 5) );
 
-           fAntiLambdaDifPtPosDaug->Fill(difPtPos,pt);
-           fAntiLambdaDifPtNegDaug->Fill(difPtNeg,pt);
+         // Only for triggered events and in case of MC AntiLambda is not a embeded particle
+         if( isTriggered && isNaturalPart){
+           fAntiLambdaPtvsEta->Fill(pt,lEta,1);
+           fAntiLambdaPtvsRap->Fill(pt,v0->RapLambda(),1);
+         }
 
-           fAntiLambdaDecayPos->Fill(dx,dy,pt);
-           fAntiLambdaDecayVertex->Fill(lt,pt);
+       }
+       if( fDoQA && lCheckMcAntiLambda && isNaturalPart && (pt<10.) ){ // Quality Assurance
 
-           if(lt<1.0)
-             fAntiLambdaDecayVertexZoom->Fill(lt,pt); //**
-           fAntiLambdaCPA->Fill(cpa,pt); //**
-           fAntiLambdaDCAV0Daug->Fill(dca,pt); //**
+         // Invariant Mass cut
+         if (TMath::Abs(mLambda-massAntiLambda) < 3*sAL) {
 
-           fAntiLambdaNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fAntiLambdaNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fAntiLambdaNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fAntiLambdaNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
-             
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+             fAntiLambdaDCAPosDaug->Fill(dcaPos,pt);
+             fAntiLambdaDCANegDaug->Fill(dcaNeg,pt);
+           }
 
-         } //End QA
+           if( (dcaPos>0.1) && (dcaNeg>0.1) ){
+             
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70) ){
+                 fAntiLambdaPtPosDaug->Fill(pt,lPtPos);
+                 fAntiLambdaPtNegDaug->Fill(pt,lPtNeg);
+                 
+                 fAntiLambdaPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+                 fAntiLambdaPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+                 
+                 fAntiLambdaDecayPos->Fill(dx,dy,pt);
+                 fAntiLambdaDecayVertex->Fill(lt,pt);
+                 
+                 fAntiLambdaCPA->Fill(cpa,pt); 
+                 fAntiLambdaDCAV0Daug->Fill(dca,pt); 
+                 
+                 fAntiLambdaNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+                 fAntiLambdaNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+               }
+             
+             fAntiLambdaNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fAntiLambdaNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
+           }
 
-       } // End selection in mass
+         } // End selection in mass
        
-       if( (TMath::Abs(mLambda-massAntiLambda + 6.5*sAL) < 1.5*sAL) ||
-           (TMath::Abs(mLambda-massAntiLambda - 6.5*sAL) < 1.5*sAL) ){
+         if( (TMath::Abs(mLambda-massAntiLambda + 6.5*sAL) < 1.5*sAL) ||
+             (TMath::Abs(mLambda-massAntiLambda - 6.5*sAL) < 1.5*sAL) ){
 
-         fAntiLambdaEtaPhi->Fill(lPhi,lEta,-1);
-         
-         if(fDoQA && lCheckMcAntiLambda){ // Quality Assurance
-           fAntiLambdaBckgPIDPosDaug->Fill(pPos,dedxPos,pt);
-           fAntiLambdaBckgPIDNegDaug->Fill(pNeg,dedxNeg,pt);
-          
-           fAntiLambdaBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
-           fAntiLambdaBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+           if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){
+             fAntiLambdaBckgDCAPosDaug->Fill(dcaPos,pt);
+             fAntiLambdaBckgDCANegDaug->Fill(dcaNeg,pt);
+           }
 
-           fAntiLambdaBckgDCAPosDaug->Fill(dcaPos,pt);
-           fAntiLambdaBckgDCANegDaug->Fill(dcaNeg,pt);
+           if( (dcaPos>0.1) && (dcaNeg>0.1) ){
 
-           fAntiLambdaBckgDifPtPosDaug->Fill(difPtPos,pt);
-           fAntiLambdaBckgDifPtNegDaug->Fill(difPtNeg,pt);
+             if( (nClsTPCPos>70) && (nClsTPCNeg>70 ) ){              
+               fAntiLambdaBckgPtPosDaug->Fill(pt,lPtPos);
+               fAntiLambdaBckgPtNegDaug->Fill(pt,lPtNeg);
+             
+               fAntiLambdaBckgPhiEtaPosDaug->Fill(phiPos,etaPos,pt);
+               fAntiLambdaBckgPhiEtaNegDaug->Fill(phiNeg,etaNeg,pt);
+             
+               fAntiLambdaBckgDecayPos->Fill(dx,dy,pt);
+               fAntiLambdaBckgDecayVertex->Fill(lt,pt);
+             
+               fAntiLambdaBckgCPA->Fill(cpa,pt); 
+               fAntiLambdaBckgDCAV0Daug->Fill(dca,pt); 
 
-           fAntiLambdaBckgDecayPos->Fill(dx,dy,pt);
-           fAntiLambdaBckgDecayVertex->Fill(lt,pt);
+               fAntiLambdaBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
+               fAntiLambdaBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
+             }
+             
+             fAntiLambdaBckgNClustersTPC->Fill(phiPos,nClsTPCPos,pt);
+             fAntiLambdaBckgNClustersTPC->Fill(phiNeg,nClsTPCNeg,-pt);
 
-           if(lt<1.0)
-             fAntiLambdaBckgDecayVertexZoom->Fill(lt,pt); //**
-           fAntiLambdaBckgCPA->Fill(cpa,pt); //**
-           fAntiLambdaBckgDCAV0Daug->Fill(dca,pt); //**
+           }
 
-           fAntiLambdaBckgNClustersTPC->Fill(phiPos,posTPCNcls,pt);
-           fAntiLambdaBckgNClustersTPC->Fill(phiNeg,negTPCNcls,-pt);
-           fAntiLambdaBckgNClustersITSPos->Fill(phiPos,posITSNcls,pt);
-           fAntiLambdaBckgNClustersITSNeg->Fill(phiNeg,negITSNcls,pt);
-             
-         } // End QA
-               
-       }// End selection in outside the mass cut
+         }// End selection in outside the mass cut
+         
+       } // End QA
+       
        break;
       default:
        Printf( " Selection of 'step' is not set properly");
@@ -2999,7 +3389,7 @@ void AliAnalysisTaskLambdaOverK0sJets::V0Loop(V0LoopStep_t step, Bool_t isTrigge
       }// End switch
       
     } // End AntiLambda selection
-      
+    
   } // End V0 loop
   
 }
@@ -3095,12 +3485,15 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
   UInt_t maskIsSelected = hdr->IsEventSelected();
   Bool_t isSelected = kFALSE;
 
+  Bool_t isSelectedCentral     = kFALSE;
+  Bool_t isSelectedSemiCentral = kFALSE;
+  Bool_t isSelectedMB          = kFALSE;
   if( fCollision.Contains("PbPb2010") )
     isSelected = (maskIsSelected & AliVEvent::kMB);
   else if( fCollision.Contains("PbPb2011") ){
-    Bool_t isSelectedCentral   =  maskIsSelected  &  AliVEvent::kCentral;
-    Bool_t isSelectedSemiCentral   =  maskIsSelected  &  AliVEvent::kSemiCentral;
-    Bool_t isSelectedMB   =  maskIsSelected   &  AliVEvent::kMB;
+    isSelectedCentral   =  maskIsSelected  &  AliVEvent::kCentral;
+    isSelectedSemiCentral   =  maskIsSelected  &  AliVEvent::kSemiCentral;
+    isSelectedMB   =  maskIsSelected   &  AliVEvent::kMB;
     if( isSelectedCentral || isSelectedSemiCentral || isSelectedMB )   isSelected = kTRUE;
   }
 
@@ -3121,18 +3514,31 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
   fEvents->Fill(4);
 
   Float_t xv=vtx->GetX(), yv=vtx->GetY(), zv=vtx->GetZ();
-  
-  fPrimaryVertexX->Fill(xv);
-  fPrimaryVertexY->Fill(yv);
-  fPrimaryVertexZ->Fill(zv);
 
   if (TMath::Abs(zv) > 10.) return;   
   fEvents->Fill(5);
+  fPrimaryVertexX->Fill(xv);
+  fPrimaryVertexY->Fill(yv);
+  fPrimaryVertexZ->Fill(zv);
   fCentrality2->Fill(centrality);
 
+  if(isSelectedCentral) fCentralityTrig->Fill(centrality,1);
+  if(isSelectedSemiCentral) fCentralityTrig->Fill(centrality,2);
+  if(isSelectedMB) fCentralityTrig->Fill(centrality,3);
+
+
   // Protect the code: only interested in events with centrality < 40%
   if(centrality>=40.) return;
 
+  //  Event plane 
+  AliEventplane *EventPlane = InputEvent()->GetEventplane();
+  Double_t eventPlane = EventPlane->GetEventplane("V0",InputEvent(),2);
+  eventPlane = ( (eventPlane < 0) ? eventPlane + TMath::Pi() : eventPlane );
+  eventPlane = ( ( eventPlane > TMath::Pi() ) ? eventPlane - TMath::Pi() : eventPlane );
   // Getting PID Response
   fPIDResponse = hdr->GetPIDResponse();
 
@@ -3149,30 +3555,36 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
   if(fIsV0LP) { fEvents->Fill(8); fTriggerIsV0->Fill(fPtV0LP);}
 
   Int_t NtrigPerEvnt = 0;
+  Float_t phi2 = -100.;
   for (Int_t i=0; i<(fTriggerParticles->GetEntriesFast()); i++){
     AliMiniParticle* trig = (AliMiniParticle*) fTriggerParticles->At(i);
 
     if(trig->WhichCandidate()==0){
-      fEvents->Fill(10);
       fTriggerComingFromDaug->Fill(trig->Pt());
       fCheckTriggerFromV0Daug->Fill(1);
       if(fIsV0LP)  fCheckTriggerFromV0Daug->Fill(2);
     }
     else if( trig->WhichCandidate()==1){
-      fEvents->Fill(12); 
       fTriggerEtaPhi->Fill(trig->Phi(),trig->Eta());
       fTriggerPtCent->Fill(trig->Pt(),centrality,zv);
       fCheckTriggerFromV0Daug->Fill(0);
+
+      phi2 = ( (trig->Phi() > TMath::Pi()) ? trig->Phi() - TMath::Pi() : trig->Phi() )  ;
+      fTriggerEventPlane->Fill(phi2);
+
       NtrigPerEvnt++;
+
     }
 
   }
 
+  if(NtrigPerEvnt>0) fEvents->Fill(11); 
+  else fEvents->Fill(12);
+
   fNTrigPerEvt->Fill(NtrigPerEvnt,centrality);
   
   // ******************************************
   // Start loop over MC particles
-  
   fTriggerPartMC = new TObjArray();
   fTriggerPartMC->SetOwner(kTRUE);
   fAssocPartMC = new TObjArray();
@@ -3204,9 +3616,6 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
       
       AliAODMCParticle *p0 = (AliAODMCParticle*)stack->At(iTrkMC);
       if(!p0) continue;
-      if(p0->Charge()==0) continue;
-      if(TMath::Abs(p0->Eta())>fTrigEtaMax) continue;
-      if( ( p0->Pt() < fTrigPtMin )  || ( p0->Pt() > fTrigPtMax ) ) continue;
 
       // ----------------------------------------
       
@@ -3229,10 +3638,14 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
        isNaturalPart = 0; 
      
       // ----------------------------------------
-       
+      
+      if(p0->Charge()==0) continue;
       if(isNaturalPart == 0) continue;
       if( !p0->IsPhysicalPrimary() ) continue;
-      
+
+      if(TMath::Abs(p0->Eta())>fTrigEtaMax) continue;
+      if( ( p0->Pt() < fTrigPtMin )  || ( p0->Pt() > fTrigPtMax ) ) continue;
+
       fTriggerPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, p0->Pt(), p0->Phi(), p0->Eta(), 0, 0, 1) ); 
     
     } // End loop over charged particles
@@ -3295,11 +3708,13 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
        continue;       
 
       // Daughter momentum cut: ! FIX it in case of AOD !
+      /*
       if ( ( pDaughter0->Pt() < fMinPtDaughter ) || 
           ( pDaughter1->Pt() < fMinPtDaughter )  ) 
-       continue;
+          continue;
+      */
       
-      if ((p0->Pt())<pMin) continue;  
+      if ((p0->Pt())<pMin || (p0->Pt())>10. ) continue;  
       if (TMath::Abs(lRapCurrentPart) > fYMax)  continue;
     
       Float_t dx = mcXv-p0->Xv(),  dy = mcYv-p0->Yv(),  dz = mcZv-p0->Zv();
@@ -3317,17 +3732,19 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
 
        fK0sMCPt->Fill(lPtCurrentPart);
        fK0sMCPtRap->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-       if(lt>5){
-
-         if(isNaturalPart){
-           fK0sMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-           fK0sMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
-           
-           if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
-             fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 3) );
-         }
-         else{ fK0sMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); }
 
+       if(isNaturalPart){
+         fK0sMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
+         fK0sMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
+         
+         if(TMath::Abs(lRapCurrentPart)<0.7)  fK0sMCPtRapVtx->Fill(lPtCurrentPart,zv,centrality);
+         
+         if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 3) );
+       }
+       else{ 
+         fK0sMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); 
+         if(TMath::Abs(lRapCurrentPart)<0.7)  fK0sMCPtRapVtxEmbeded->Fill(lPtCurrentPart,zv,centrality);
        }
 
       } // End K0s selection
@@ -3336,42 +3753,48 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
        
        fLambdaMCPt->Fill(lPtCurrentPart);
        fLambdaMCPtRap->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-       if(lt>5){
-         if(isNaturalPart){
-           fLambdaMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-           fLambdaMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
+      
+       if(isNaturalPart){
+         fLambdaMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
+         fLambdaMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
            
-           if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
-             fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 4) );
-         }
-         else{ fLambdaMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); }
+         if(TMath::Abs(lRapCurrentPart)<0.7) fLambdaMCPtRapVtx->Fill(lPtCurrentPart,zv,centrality);
 
-         if ( TMath::Abs(lPdgCurrentMother) == 3312) 
-           fLambdaMCFromXi->Fill(lPtCurrentPart,centrality);
+         if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 4) );
+       }
+       else{ 
+         fLambdaMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); 
+         if(TMath::Abs(lRapCurrentPart)<0.7) fLambdaMCPtRapVtxEmbeded->Fill(lPtCurrentPart,zv,centrality);
        }
 
+       if ( isNaturalPart && TMath::Abs(lPdgCurrentMother) == 3312 ) 
+         fLambdaMCFromXi->Fill(lPtCurrentPart,centrality);
+       
       } // End Lambda
       // AntiLambda
       if (lPdgcodeCurrentPart == kLambda0Bar) {
 
        fAntiLambdaMCPt->Fill(lPtCurrentPart);
        fAntiLambdaMCPtRap->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-       if(lt>5){
 
-         if(isNaturalPart){
-           fAntiLambdaMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);
-           
-           fAntiLambdaMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
+       if(isNaturalPart){
+         fAntiLambdaMCPtRap2->Fill(lPtCurrentPart,lRapCurrentPart,centrality);     
+         fAntiLambdaMCPtPhiEta[curCentBin]->Fill(lPhiCurrentPart,lEtaCurrentPart,lPtCurrentPart);
+
+         if(TMath::Abs(lRapCurrentPart)<0.7) fAntiLambdaMCPtRapVtx->Fill(lPtCurrentPart,zv,centrality);
            
-           if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
-             fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 5) );
-         }
-         else{ fAntiLambdaMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); }
-         
-         if ( TMath::Abs(lPdgCurrentMother) == 3312) 
-           fAntiLambdaMCFromXi->Fill(lPtCurrentPart,centrality);
+         if( (lPtCurrentPart>kPtBinV0[0]) && (lPtCurrentPart<kPtBinV0[kN1]) && isNaturalPart )
+           fAssocPartMC->Add( new AliMiniParticle(centrality, zv, iTrkMC, lPtCurrentPart, lPhiCurrentPart, lEtaCurrentPart, 0, 0, 5) );
        }
-
+       else{ 
+         fAntiLambdaMCPtRapEmbeded->Fill(lPtCurrentPart,lRapCurrentPart,centrality); 
+         if(TMath::Abs(lRapCurrentPart)<0.7) fAntiLambdaMCPtRapVtxEmbeded->Fill(lPtCurrentPart,zv,centrality);
+       }
+         
+       if ( isNaturalPart && TMath::Abs(lPdgCurrentMother) == 3312 ) 
+         fAntiLambdaMCFromXi->Fill(lPtCurrentPart,centrality);
+       
       } // End AntiLambda
      
     } // End loop over MC
@@ -3420,7 +3843,7 @@ void AliAnalysisTaskLambdaOverK0sJets::UserExec(Option_t *)
     } // End loop over trigger particles
 
   } // End MC condition
-
   // *************************************************
   // V0 loop - AOD
   fAssocParticles = new TObjArray(); 
index 99872b51e76e8bbdbec332dea216aa85734065dd..839e5e234d7af731807f71c95764bb9deac7e218 100644 (file)
@@ -3,13 +3,13 @@
  * See cxx source for full Copyright notice */ 
 
 /*
-          AliAnalysisTaskLambdaOverK0sJets class
+                AliAnalysisTaskLambdaOverK0sJets class
 
-          This program obtains the production of K0s and Lambdas and calculates 
-         the correlation (in the variables phi and eta) with respect to the
-         triggers particles (high-pt charged particles).
-         It works with MC information and AOD tree.
-         Origin: X. Sanchez Castro August2012, xsanchez@cern.ch
+                This program obtains the production of K0s and Lambdas and calculates 
+                the correlation (in the variables phi and eta) with respect to the
+                triggers particles (high-pt charged particles).
+                It works with MC information and AOD tree.
+                Origin: X. Sanchez Castro August2012, xsanchez@cern.ch
 */
 
 
@@ -30,6 +30,8 @@ class TH3F;
 class TList;
 class TString;
 
+class TObjArray;
+
 const int    kN1 = 8; 
 const float  kPtBinV0[kN1+1] = {2.0,2.25,2.5,2.75,3.0,3.5,4.0,5.0,7.0};
 
@@ -40,7 +42,7 @@ const int    kNCent  = 4;
 const double kBinCent[kNCent+1] = {0.0,5.0,10.0,20.0,40.0};
 
 //  ------------------------------------
-//  Inv. Mass width as function os the centrality
+//  Inv. Mass width as function of the centrality
 //  Linear polimomial dependence: sigma(pt) = a0 * a1*pt
 
 const double kCteK0s2010[kNCent] = {0.00367, 0.00363, 0.00358, 0.00348};
@@ -88,11 +90,12 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   void SetMinPtDaughter(Float_t minPtDaughter=0.160) {fMinPtDaughter=minPtDaughter;} 
   void SetMaxEtaDaughter(Float_t maxEta=0.8) {fMaxEtaDaughter=maxEta;} 
   void SetMaxDCADaughter(Float_t maxDCA=1.0) {fMaxDCADaughter=maxDCA;} 
+  void SetDCAToPrimVtx(Float_t dcaToPrimVtx=0.1) {fDCAToPrimVtx=dcaToPrimVtx;}
+  void SetNSigmaPID(Float_t nSigma=3) {fNSigma=nSigma;} 
+  void SetNClsTPC(Float_t nClsTPC=70.) {fDaugNClsTPC=nClsTPC;}
   //   2.  V0 candidate
   void SetMaxY(Float_t yMax=0.5) {fYMax=yMax;} 
-  void SetDCAToPrimVtx(Float_t dcaToPrimVtx=0.1) {fDCAToPrimVtx=dcaToPrimVtx;}
   void SetMinCPA(Float_t minCPA=0.998) {fMinCPA=minCPA;} 
-  void SetNSigmaPID(Float_t nSigma=3) {fNSigma=nSigma;} 
   void SetCtau(Float_t minCtau = 0., Float_t maxCtau = 3.) {fMinCtau=minCtau;fMaxCtau=maxCtau;} 
 
   // Getters
@@ -102,6 +105,7 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   // Main functions
   virtual void     UserCreateOutputObjects();
   virtual Bool_t   AcceptTrack(AliAODTrack *t); 
+  virtual Bool_t   AcceptTrackV0(const AliAODTrack *t);
   virtual Bool_t   AcceptV0(AliAODVertex *vtx, const AliAODv0 *v0);
   virtual void     RecCascade(AliAODTrack *trk1,const AliAODTrack *trk2,const AliAODTrack *trkBch,TString histo);
   virtual void     V0Loop(V0LoopStep_t step, Bool_t isTriggered, Int_t iArray, Int_t idTrig);
@@ -139,6 +143,7 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   Float_t fDCAToPrimVtx;                 //  Mimimum distance of closest approach of daughters to the vertex            
   Float_t fMinCPA;                       //  Minimum Cosine of the Pointing Angle to the vertex for V0  
   Float_t fNSigma;                       //  Number of sigmas for PID wi dE/dx
+  Float_t fDaugNClsTPC;                  //  Number of TPC clusters for daughters
   Float_t fMinCtau;                      //  Minimum ctau
   Float_t fMaxCtau;                      //  Maximum ctau
 
@@ -146,7 +151,6 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   Int_t   fIsV0LP;                       //  Flag: V0 has the highest pt in the event
   Float_t fPtV0LP;                       //  Pt of the leading V0
   Int_t   fIsSndCheck;                   //  Flag: trigger particle is the second leaidng particle
-  
 
   TList*  fOutput;                       //! List of histograms for main analysis
   TList*  fOutputQA;                     //! List of histograms for Quality Assurance
@@ -161,12 +165,12 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH1F*   fEvents;                       //! Counter for the number of events in each step
   TH1F*   fCentrality;                   //! Event centrality per centil
   TH1F*   fCentrality2;                  //! Event centrality per centil with |VtxZ|<10cm
+  TH2F*   fCentralityTrig;               //! Event centrality per trigger
   TH1F*   fPrimaryVertexX;               //! Primary vertex position in X
   TH1F*   fPrimaryVertexY;               //! Primary vertex position in Y
   TH1F*   fPrimaryVertexZ;               //! Primary vertex position in Z
-  TH2F*   fCentMult;                     //! Event centrality vs Track multiplicity
-  TH2F*   fdEdx;                         //! dEdx
-  TH2F*   fdEdxPid;                      //! dEdx with PID
+
+  TH1F*   fTriggerEventPlane;            //! Distance between the trigger particle direction and the event plane angle
 
   TH2F*   fTriggerMCPtCent;              //! Trigger particle MC: pt vs centrality
   TH3F*   fTriggerMCResPt;               //! Trigger particle MC: pt resolution
@@ -185,70 +189,129 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH3F*   fCheckIDTrigPtLambda;          //! Trigger particle: pt comparison between trigger track and Lambda daughter track
   TH3F*   fCheckIDTrigPhiLambda;         //! Trigger particle: phi comparison between trigger track and Lambda daughter track
   TH3F*   fCheckIDTrigEtaLambda;         //! Trigger particle: eta comparison between trigger track and Lambda daughter track
-  TH3F*   fCheckIDTrigPtAntiLambda;      //! Trigger particle: pt comparison between trigger track and Lambda daughter track
-  TH3F*   fCheckIDTrigPhiAntiLambda;     //! Trigger particle: phi comparison between trigger track and Lambda daughter track
-  TH3F*   fCheckIDTrigEtaAntiLambda;     //! Trigger particle: eta comparison between trigger track and Lambda daughter track
+  TH3F*   fCheckIDTrigPtAntiLambda;      //! Trigger particle: pt comparison between trigger track and AntiLambda daughter track
+  TH3F*   fCheckIDTrigPhiAntiLambda;     //! Trigger particle: phi comparison between trigger track and AntiLambda daughter track
+  TH3F*   fCheckIDTrigEtaAntiLambda;     //! Trigger particle: eta comparison between trigger track and AntiLambda daughter track
  
-
+  // ==============  Monte Carlo  ================= //
   TH1F*   fInjectedParticles;            //! Number of injected particles
 
+  //           K0s            //
   TH1F*   fK0sMCPt;                      //! K0s MC: pt
   TH3F*   fK0sMCPtRap;                   //! K0s MC: pt vs rapidity
-  TH3F*   fK0sMCPtRap2;                  //! K0s MC: pt vs rapidity
+  TH3F*   fK0sMCPtRap2;                  //! K0s MC: pt vs rapidity (is Natural)
+  TH3F*   fK0sMCPtRapVtx;                //! K0s MC: pt vs Z vtx position  vs centrality
   TH3F*   fK0sMCPtRapEmbeded;            //! K0s MC: pt vs rapidity  (embeded particles)
+  TH3F*   fK0sMCPtRapVtxEmbeded;         //! K0s MC: pt vs Z vtx position rapidity  vs centrality (embeded particles)
   TH3F*   fK0sMCPtPhiEta[kNCent];        //! K0s MC: pt vs pseudo-rapidity
-  TH1F*   fK0sAssocPt;                   //! K0s Assoc: pt
-  TH3F*   fK0sAssocPtArm;                //! K0s Assoc: pt vs rapidity vs centrality
-  TH3F*   fK0sAssocPtMassArm;            //! K0s Assoc: mass vs pt vs centrality
-  TH3F*   fK0sAssocPtArmEmbeded;         //! K0s Assoc: pt vs rapidity vs centrality  (embeded particles)
-  TH3F*   fK0sAssocPtRap;                //! K0s Assoc: pt vs rapidity
-  TH3F*   fK0sAssocPtRapEmbeded;         //! K0s Assoc: pt vs rapidity (embeded particles)
-  TH3F*   fK0sAssocPtPhiEta[kNCent];     //! K0s Assoc: pt vs pseudo-rapidity
+
+  TH1F*   fK0sAssocPt;                         //! K0s Assoc: pt
+  TH3F*   fK0sAssocPtArm;                      //! K0s Assoc: pt vs rapidity vs centrality (arm. pod. cut)
+  TH3F*   fK0sAssocPtRap;                      //! K0s Assoc: pt vs rapidity vs centrality
+  TH3F*   fK0sAssocPtPhiEta[kNCent];           //! K0s Assoc: pt vs pseudo-rapidity
+
+  TH3F*   fK0sAssocPtMassArm[kNCent];          //! K0s Assoc: mass vs pt vs centrality
+  TH3F*   fK0sAssocMassPtVtx[kNCent];          //! K0s Assoc: mass vs pt vs Z vertex position
+  TH3F*   fK0sAssocMassPtDCADaug[kNCent];      //! K0s Assoc: mass vs pt vs dca between daughters
+  TH3F*   fK0sAssocMassPtCPA[kNCent];          //! K0s Assoc: mass vs pt vs cpa
+  TH3F*   fK0sAssocMassPtDCAPV[kNCent];        //! K0s Assoc: mass vs pt vs dca to prim. vtx
+  TH3F*   fK0sAssocMassPtDaugNClsTPC[kNCent];  //! K0s Assoc: mass vs pt vs num. of tpc clusters
+
+  TH3F*   fK0sAssocPtRapEmbeded;                      //! K0s Assoc: pt vs rapidity vs centrality  (embeded particles)
+  TH3F*   fK0sAssocPtMassArmEmbeded[kNCent];          //! K0s Assoc: mass vs pt vs rapidity  (embeded particles)
+  TH3F*   fK0sAssocMassPtVtxEmbeded[kNCent];          //! K0s Assoc: mass vs pt vs Z vertex position  (embeded particles)
+  TH3F*   fK0sAssocMassPtDCADaugEmbeded[kNCent];      //! K0s Assoc: mass vs pt vs dca between daughters  (embeded particles)
+  TH3F*   fK0sAssocMassPtCPAEmbeded[kNCent];          //! K0s Assoc: mass vs pt vs cpa  (embeded particles)
+  TH3F*   fK0sAssocMassPtDCAPVEmbeded[kNCent];        //! K0s Assoc: mass vs pt vs dca to prim. vtx  (embeded particles)
+  TH3F*   fK0sAssocMassPtDaugNClsTPCEmbeded[kNCent];  //! K0s Assoc: mass vs pt vs num. o ftpc clusters (embeded particles)
+
   TH3F*   fK0sMCResEta;                  //! K0s Assoc: eta resolution
   TH3F*   fK0sMCResPhi;                  //! K0s Assoc: phi resolution
 
+
+  //           Lambda            //
   TH1F*   fLambdaMCPt;                   //! Lambda MC: pt
   TH3F*   fLambdaMCPtRap;                //! Lambda MC: pt vs rapidity
-  TH3F*   fLambdaMCPtRap2;               //! Lambda MC: pt vs rapidity
+  TH3F*   fLambdaMCPtRap2;               //! Lambda MC: pt vs rapidity  (is Natural)
+  TH3F*   fLambdaMCPtRapVtx;             //! Lambda MC: pt vs Z vtx position rapidity vs centrality
   TH3F*   fLambdaMCPtRapEmbeded;         //! Lambda MC: pt vs rapidity (embeded particles)
+  TH3F*   fLambdaMCPtRapVtxEmbeded;      //! Lambda MC: pt vs Z vtx position vs centrality  (embeded particles)
   TH2F*   fLambdaMCFromXi;               //! Lambda MC: coming from Xi
   TH3F*   fLambdaMCPtPhiEta[kNCent];     //! Lambda MC: pt vs pseudo-rapidity
+
   TH1F*   fLambdaAssocPt;                //! Lambda Assoc: pt
   TH3F*   fLambdaAssocPtRap;             //! Lambda Assoc: pt vs rapidity
-  TH3F*   fLambdaAssocPtMass;            //! Lambda Assoc: mass vs pt vs rapidity
-  TH3F*   fLambdaAssocPtRapEmbeded;      //! Lambda Assoc: pt vs rapidity (embeded particles)
   TH2F*   fLambdaAssocFromXi;            //! Lambda Assoc: coming from Xi
   TH3F*   fLambdaAssocPtPhiEta[kNCent];  //! Lambda Assoc: pt vs pseudo-rapidity
+
+  TH3F*   fLambdaAssocMassPtRap[kNCent];          //! Lambda Assoc: pt vs rapidity vs mass
+  TH3F*   fLambdaAssocMassPtRap2[kNCent];         //! Lambda Assoc: pt vs rapidity vs mass (wo Cross contamination)
+  TH3F*   fLambdaAssocMassPtVtx[kNCent];          //! Lambda Assoc: mass vs pt vs Z vertex position
+  TH3F*   fLambdaAssocMassPtDCADaug[kNCent];      //! Lambda Assoc: mass vs pt vs dca btween daughters
+  TH3F*   fLambdaAssocMassPtCPA[kNCent];          //! Lambda Assoc: mass vs pt vs cpa
+  TH3F*   fLambdaAssocMassPtDCAPV[kNCent];        //! Lambda Assoc: mass vs pt vs dca to prim vtx
+  TH3F*   fLambdaAssocMassPtDaugNClsTPC[kNCent];  //! Lambda Assoc: mass vs pt vs num.of tpc clusters
+
+  TH3F*   fLambdaAssocMassPtRapEmbeded[kNCent];          //! Lambda Assoc: pt vs rapidity vs mass (embeded)
+  TH3F*   fLambdaAssocMassPtRapEmbeded2[kNCent];         //! Lambda Assoc: pt vs rapidity vs mass  (wo Cross contamination) (embeded)
+  TH3F*   fLambdaAssocMassPtVtxEmbeded[kNCent];          //! Lambda Assoc: mass vs pt vs Z vertex position  (embeded particles)
+  TH3F*   fLambdaAssocMassPtDCADaugEmbeded[kNCent];      //! Lambda Assoc: mass vs pt vs dca between daughters  (embeded particles)
+  TH3F*   fLambdaAssocMassPtCPAEmbeded[kNCent];          //! Lambda Assoc: mass vs pt vs cpa  (embeded particles)
+  TH3F*   fLambdaAssocMassPtDCAPVEmbeded[kNCent];        //! Lambda Assoc: mass vs pt vs dca to prim vtx  (embeded particles)
+  TH3F*   fLambdaAssocMassPtDaugNClsTPCEmbeded[kNCent];  //! Lambda Assoc: mass vs pt vs num. of tpc clusters  (embeded particles)
+
   TH3F*   fLambdaMCResEta;               //! Lambda Assoc: eta resolution
   TH3F*   fLambdaMCResPhi;               //! Lambda Assoc: phi resolution
 
-  TH1F*   fAntiLambdaMCPt;               //! AntiLambda MC: pt
-  TH3F*   fAntiLambdaMCPtRap;            //! AntiLambda MC: pt vs rapidity
-  TH3F*   fAntiLambdaMCPtRap2;           //! AntiLambda MC: pt vs rapidity
-  TH3F*   fAntiLambdaMCPtRapEmbeded;     //! AntiLambda MC: pt vs rapidity (embeded particles)
-  TH2F*   fAntiLambdaMCFromXi;           //! AntiLambda MC: coming from Xi
-  TH3F*   fAntiLambdaMCPtPhiEta[kNCent]; //! AntiLambda MC: pt vs pseudo-rapidity
-  TH1F*   fAntiLambdaAssocPt;            //! AntiLambda Assoc: pt
-  TH3F*   fAntiLambdaAssocPtRap;         //! AntiLambda Assoc: pt vs rapidity
-  TH3F*   fAntiLambdaAssocPtMass;        //! AntiLambda Assoc: mass vs pt vs rapidity
-  TH3F*   fAntiLambdaAssocPtRapEmbeded;  //! AntiLambda Assoc: pt vs rapidity (embeded particles)
-  TH2F*   fAntiLambdaAssocFromXi;        //! AntiLambda Assoc: coming from Xi
-  TH3F*   fAntiLambdaAssocPtPhiEta[kNCent]; //! AntiLambda Assoc: pt vs pseudo-rapidity
-  TH3F*   fAntiLambdaMCResEta;           //! AntiLambda Assoc: eta resolution
-  TH3F*   fAntiLambdaMCResPhi;           //! AntiLambda Assoc: phi resolution
+
+  //           AntiLambda            //
+  TH1F*   fAntiLambdaMCPt;                  //! AntiLambda MC: pt
+  TH3F*   fAntiLambdaMCPtRap;               //! AntiLambda MC: pt vs rapidity
+  TH3F*   fAntiLambdaMCPtRap2;              //! AntiLambda MC: pt vs rapidity  (is Natural)
+  TH3F*   fAntiLambdaMCPtRapVtx;            //! AntiLambda MC: pt vs rapidity vs Z vtx position
+  TH3F*   fAntiLambdaMCPtRapEmbeded;        //! AntiLambda MC: pt vs rapidity (embeded particles)
+  TH3F*   fAntiLambdaMCPtRapVtxEmbeded;     //! AntiLambda MC: pt vs rapidity  vs Z vtx position 
+  TH2F*   fAntiLambdaMCFromXi;              //! AntiLambda MC: coming from Xi
+  TH3F*   fAntiLambdaMCPtPhiEta[kNCent];    //! AntiLambda MC: pt vs pseudo-rapidity
+
+  TH1F*   fAntiLambdaAssocPt;                 //! AntiLambda Assoc: pt
+  TH3F*   fAntiLambdaAssocPtRap;              //! AntiLambda Assoc: pt vs rapidity vscentrality
+  TH2F*   fAntiLambdaAssocFromXi;             //! AntiLambda Assoc: coming from Xi
+  TH3F*   fAntiLambdaAssocPtPhiEta[kNCent];   //! AntiLambda Assoc: pt vs pseudo-rapidity
+
+  TH3F*   fAntiLambdaAssocMassPtRap[kNCent];          //! AntiLambda Assoc: mass vs pt vs rapidity
+  TH3F*   fAntiLambdaAssocMassPtRap2[kNCent];         //! AntiLambda Assoc: mass vs pt vs rapidity  (wo Cross contamination)
+  TH3F*   fAntiLambdaAssocMassPtVtx[kNCent];          //! AntiLambda Assoc: mass vs pt vs Z vtx position
+  TH3F*   fAntiLambdaAssocMassPtDCADaug[kNCent];      //! AntiLambda Assoc: mass vs pt vs Dca between daughters
+  TH3F*   fAntiLambdaAssocMassPtCPA[kNCent];          //! AntiLambda Assoc: mass vs pt vs cpa
+  TH3F*   fAntiLambdaAssocMassPtDCAPV[kNCent];        //! AntiLambda Assoc: mass vs pt vs dca to prim. vtx
+  TH3F*   fAntiLambdaAssocMassPtDaugNClsTPC[kNCent];  //! AntiLambda Assoc: mass vs pt vs num. of tpc clusters
+
+  TH3F*   fAntiLambdaAssocMassPtRapEmbeded[kNCent];          //! AntiLambda Assoc: mass vs pt vs rapidity  (embeded)
+  TH3F*   fAntiLambdaAssocMassPtRapEmbeded2[kNCent];         //! AntiLambda Assoc: mass vs pt vs rapidity  (wo Cross contamination) (embeded)
+  TH3F*   fAntiLambdaAssocMassPtVtxEmbeded[kNCent];          //! AntiLambda Assoc: mass vs pt vs Z vtx. position  (embeded particles)
+  TH3F*   fAntiLambdaAssocMassPtDCADaugEmbeded[kNCent];      //! AntiLambda Assoc: mass vs pt vs dca between daughters  (embeded particles)
+  TH3F*   fAntiLambdaAssocMassPtCPAEmbeded[kNCent];          //! AntiLambda Assoc: mass vs pt vs cpa  (embeded particles)
+  TH3F*   fAntiLambdaAssocMassPtDCAPVEmbeded[kNCent];        //! AntiLambda Assoc: mass vs pt vs dca to prim. vtx  (embeded particles)
+  TH3F*   fAntiLambdaAssocMassPtDaugNClsTPCEmbeded[kNCent];  //! AntiLambda Assoc: mass vs pt vs num. of tpc clusters  (embeded particles)
+
+  TH3F*   fAntiLambdaMCResEta;             //! AntiLambda Assoc: eta resolution
+  TH3F*   fAntiLambdaMCResPhi;             //! AntiLambda Assoc: phi resolution
+
 
   /// ====== Histohgrmas for Correlations ====== ///
 
   TH3F*   fHistArmenterosPodolanski;     //! Armenteros-Podolanski plot inside 3 sigma of the signal
   TH3F*   fHistArmPodBckg;               //! Armenteros-Podolanski plot outside 3 sigma of the signal      
 
+
+  //           K0s            //
   TH3F*   fK0sMass;                      //! Mass for K0s
+  TH3F*   fK0sMassEmbeded;               //! Mass for K0s embeded
   TH3F*   fK0sPtvsEta;                   //! K0s: pt vs eta
   TH3F*   fK0sPtvsRap;                   //! K0s: pt vs rap
-  TH2F*   fK0sEtaPhi;                    //! K0s: eta vs phi
   TH3F*   fK0sMassPtPhi;                 //! K0s: mass vs phi
 
-  TH3F*   fK0sSiPtL;                     //! K0s: mass, vs leading particle
   TH2F*   fK0sDaughtersPt;               //! K0s: pt of daughters
   TH3F*   fK0sDCADaugToPrimVtx;          //! K0s: DCA to primary vertex of daughters vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fK0sSpatialRes;                //! K0s: Spatial resolution  
@@ -259,21 +322,22 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
  
   TH2F*   fK0sBckgDecLength;             //! K0s background: Decay lenght vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fK0sBckgDCADaugToPrimVtx;      //! K0s background: DCA to primary vrtex of daughters vs leading particle's pt inside a radio wrt the near-side peak
-  TH2F*   fK0sdEdxPosDaug;               //! K0s background: dE/dx of the positive daughter particle inside a radio wrt the near-side peak
-  TH2F*   fK0sdEdxNegDaug;               //! K0s background: dE/dx of the negative daughter particle inside a radio wrt the near-side peak
   TH2F*   fK0sBckgEtaPhi;                //! K0s background: Phi vs Eta inside a radio wrt the near-side peak
   TH2F*   fK0sBckgPhiRadio;              //! K0s background: Phi vs radio inside a radio wrt the near-side peak
   TH2F*   fK0sBckgDCANegDaugToPrimVtx;   //! K0s background: DCA of Negative daughter to the primary vertex inside the radio 0.4 wrt the near-side peak
   TH2F*   fK0sBckgDCAPosDaugToPrimVtx;   //! K0s background: DCA of Positive daughter to the primary vertex inside the radio 0.4 wrt the near-side peak
   TH2F*   fV0MassCascade;                //! V0s candiates: Possible mismatching of tracks due to cascades decays
 
+
+  //           Lambda            //
   TH3F*   fLambdaMass;                   //! Mass for Lambda
+  TH3F*   fLambdaMassEmbeded;            //! Mass for Lambda embeded
+  TH3F*   fLambdaMass2;                  //! Mass for Lambda (rejecting crosscontamination)
+  TH3F*   fLambdaMass2Embeded;           //! Mass for Lambda embded (rejecting crosscontamination)
   TH3F*   fLambdaPtvsEta;                //! Lambda: pt vs eta
   TH3F*   fLambdaPtvsRap;                //! Lambda: pt vs rap
-  TH2F*   fLambdaEtaPhi;                 //! Lambda: eta vs phi
   TH3F*   fLambdaMassPtPhi;              //! Lambda: mass vs phi 
 
-  TH3F*   fLambdaSiPtL;                  //! Lambda: mass, vs leading particle
   TH2F*   fLambdaDaughtersPt;            //! Lambda: pt of daughters
   TH3F*   fLambdaDCADaugToPrimVtx;       //! Lambda: DCA to primary vrtex of daughters vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fLambdaSpatialRes;             //! Lambda: Spatial resolution  
@@ -285,20 +349,22 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
 
   TH2F*   fLambdaBckgDecLength;            //! Lambda background: Decay lenght vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fLambdaBckgDCADaugToPrimVtx;     //! Lambda background: DCA to primary vrtex of daughters vs leading particle's pt inside a radio wrt the near-side peak
-  TH2F*   fLambdadEdxPosDaug;              //! Lambda background: dE/dx of the positive daughter particle inside a radio wrt the near-side peak
-  TH2F*   fLambdadEdxNegDaug;              //! Lambda background: dE/dx of the negative daughter particle inside a radio wrt the near-side peak
   TH2F*   fLambdaBckgEtaPhi;               //! Lambda background: Phi vs Eta inside a radio wrt the near-side peak
   TH2F*   fLambdaBckgPhiRadio ;            //! Lambda background: Phi vs radio inside a radio wrt the near-side peak
   TH2F*   fLambdaBckgDCANegDaugToPrimVtx;  //! Lambda background: DCA of Negative daughter to the primary vertex inside the radio 0.4 wrt the near-side peak
   TH2F*   fLambdaBckgDCAPosDaugToPrimVtx;  //! Lambda background: DCA of Positive daughter to the primary vertex inside the radio 0.4 wrt the near-side peak
 
+
+  //           AntiLambda            //
   TH3F*   fAntiLambdaMass;                     //! Mass for AntiLambda
+  TH3F*   fAntiLambdaMassEmbeded;              //! Mass for AntiLambda embeded
+  TH3F*   fAntiLambdaMass2;                    //! Mass for AntiLambda (rejecting crosscontamination)
+  TH3F*   fAntiLambdaMass2Embeded;             //! Mass for AntiLambda embded (rejecting crosscontamination)
+
   TH3F*   fAntiLambdaPtvsEta;                  //! AntiLambda: pt vs eta
   TH3F*   fAntiLambdaPtvsRap;                  //! AntiLambda: pt vs rap
-  TH2F*   fAntiLambdaEtaPhi;                   //! AntiLambda: eta vs phi
   TH3F*   fAntiLambdaMassPtPhi;                //! Lambda: mass vs phi 
 
-  TH3F*   fAntiLambdaSiPtL;                    //! AntiLambda: mass, vs leading particle
   TH2F*   fAntiLambdaDaughtersPt;              //! AntiLambda: pt of daughters
   TH3F*   fAntiLambdaDCADaugToPrimVtx;         //! AntiLambda: DCA to primary vrtex of daughters vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fAntiLambdaSpatialRes;               //! AntiLambda: Spatial resolution  
@@ -309,8 +375,6 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
 
   TH2F*   fAntiLambdaBckgDecLength;            //! AntiLambda background: Decay lenght vs leading particle's pt inside a radio wrt the near-side peak
   TH3F*   fAntiLambdaBckgDCADaugToPrimVtx;     //! AntiLambda background: DCA to primary vrtex of daughters vs leading particle's pt inside a radio wrt the near-side peak
-  TH2F*   fAntiLambdadEdxPosDaug;              //! AntiLambda background: dE/dx of the positive daughter particle inside a radio wrt the near-side peak
-  TH2F*   fAntiLambdadEdxNegDaug;              //! AntiLambda background: dE/dx of the negative daughter particle inside a radio wrt the near-side peak
   TH2F*   fAntiLambdaBckgEtaPhi;               //! AntiLambda background: Phi vs Eta inside a radio wrt the near-side peak
   TH2F*   fAntiLambdaBckgPhiRadio ;            //! AntiLambda background: Phi vs radio inside a radio wrt the near-side peak
   TH2F*   fAntiLambdaBckgDCANegDaugToPrimVtx;  //! AntiLambda background: DCA of Negative daughter to the primary vertex inside the radio 0.4 wrt the near-side peak
@@ -322,11 +386,10 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   ///  ==== Quality Assurance plots === ///
 
   //           K0s            //
-
-  TH3F*   fK0sPIDPosDaug;                    //! K0s: Pos. track PID
-  TH3F*   fK0sPIDNegDaug;                    //! K0s: Neg. track PID
-  TH3F*   fK0sBckgPIDPosDaug;                //! K0s Bckg: Pos. track PID
-  TH3F*   fK0sBckgPIDNegDaug;                //! K0s Bckg: Neg. track PID
+  TH2F*   fK0sPtPosDaug;                     //! K0s: Pos. pt
+  TH2F*   fK0sPtNegDaug;                     //! K0s: Neg. pt
+  TH2F*   fK0sBckgPtPosDaug;                 //! K0s Bckg: Pos. pt
+  TH2F*   fK0sBckgPtNegDaug;                 //! K0s Bckg: Neg. pt
 
   TH3F*   fK0sPhiEtaPosDaug;                 //! K0s: Pos. track phi vs eta 
   TH3F*   fK0sPhiEtaNegDaug;                 //! K0s: Neg. track phi vs eta
@@ -338,17 +401,10 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH2F*   fK0sBckgDCAPosDaug;                //! K0s Bckg: Pos. track DCA to primary vertex
   TH2F*   fK0sBckgDCANegDaug;                //! K0s Bckg: Neg. track DCA to primary vertex
 
-  TH2F*   fK0sDifPtPosDaug;                  //! K0s: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fK0sDifPtNegDaug;                  //! K0s: Neg. track diference berween pt of the daughter and the V0
-  TH2F*   fK0sBckgDifPtPosDaug;              //! K0s Bckg: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fK0sBckgDifPtNegDaug;              //! K0s Bckg: Neg. track diference berween pt of the daughter and the V0
-
   TH3F*   fK0sDecayPos;                      //! K0s: 2D decay position  
   TH3F*   fK0sBckgDecayPos;                  //! K0s Bckg: 2D decay position   
   TH2F*   fK0sDecayVertex;                   //! K0s: decay lenght
   TH2F*   fK0sBckgDecayVertex;               //! K0s Bckg: decay lenght 
-  TH2F*   fK0sDecayVertexZoom;               //! K0s: decay lenght Zoom
-  TH2F*   fK0sBckgDecayVertexZoom;           //! K0s Bckg: decay lenght Zoom
 
   TH2F*   fK0sCPA;                           //! K0s: cosine of the pointing angle
   TH2F*   fK0sBckgCPA;                       //! K0s Bckg: cosine of the pointing angle
@@ -362,12 +418,12 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH3F*   fK0sBckgNClustersITSPos;           //! K0s Bckg: Pos. Daug. Numbers of ITS clusters of the daughter tracks 
   TH3F*   fK0sBckgNClustersITSNeg;           //! K0s Bckg: Neg. Daug. Numbers of ITS clusters of the daughter tracks 
 
-  //          Lambda          //
 
-  TH3F*   fLambdaPIDPosDaug;                    //! Lambda: Pos. track PID
-  TH3F*   fLambdaPIDNegDaug;                    //! Lambda: Neg. track PID
-  TH3F*   fLambdaBckgPIDPosDaug;                //! Lambda Bckg: Pos. track PID
-  TH3F*   fLambdaBckgPIDNegDaug;                //! Lambda Bckg: Neg. track PID
+  //          Lambda          //
+  TH2F*   fLambdaPtPosDaug;                     //! Lambda: Pos. pt
+  TH2F*   fLambdaPtNegDaug;                     //! Lambda: Neg. pt
+  TH2F*   fLambdaBckgPtPosDaug;                 //! Lambda Bckg: Pos. pt
+  TH2F*   fLambdaBckgPtNegDaug;                 //! Lambda Bckg: Neg. pt
 
   TH3F*   fLambdaPhiEtaPosDaug;                 //! Lambda: Pos. track phi vs eta 
   TH3F*   fLambdaPhiEtaNegDaug;                 //! Lambda: Neg. track phi vs eta
@@ -379,17 +435,10 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH2F*   fLambdaBckgDCAPosDaug;                //! Lambda Bckg: Pos. track DCA to primary vertex
   TH2F*   fLambdaBckgDCANegDaug;                //! Lambda Bckg: Neg. track DCA to primary vertex
 
-  TH2F*   fLambdaDifPtPosDaug;                  //! Lambda: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fLambdaDifPtNegDaug;                  //! Lambda: Neg. track diference berween pt of the daughter and the V0
-  TH2F*   fLambdaBckgDifPtPosDaug;              //! Lambda Bckg: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fLambdaBckgDifPtNegDaug;              //! Lambda Bckg: Neg. track diference berween pt of the daughter and the V0
-
   TH3F*   fLambdaDecayPos;                      //! Lambda: 2D decay position  
   TH3F*   fLambdaBckgDecayPos;                  //! Lambda Bckg: 2D decay position   
   TH2F*   fLambdaDecayVertex;                   //! Lambda: decay lenght
   TH2F*   fLambdaBckgDecayVertex;               //! Lambda Bckg: decay lenght 
-  TH2F*   fLambdaDecayVertexZoom;               //! Lambda: decay lenght Zoom
-  TH2F*   fLambdaBckgDecayVertexZoom;           //! Lambda Bckg: decay lenght Zoom
 
   TH2F*   fLambdaCPA;                           //! Lambda: cosine of the pointing angle
   TH2F*   fLambdaBckgCPA;                       //! Lambda Bckg: cosine of the pointing angle
@@ -403,12 +452,12 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH3F*   fLambdaBckgNClustersITSPos;           //! Lambda Bckg: Pos. Daug. Numbers of ITS clusters of the daughter tracks 
   TH3F*   fLambdaBckgNClustersITSNeg;           //! Lambda Bckg: Neg. Daug. Numbers of ITS clusters of the daughter tracks 
 
-  //        AntiLambda        //
 
-  TH3F*   fAntiLambdaPIDPosDaug;                    //! AntiLambda: Pos. track PID
-  TH3F*   fAntiLambdaPIDNegDaug;                    //! AntiLambda: Neg. track PID
-  TH3F*   fAntiLambdaBckgPIDPosDaug;                //! AntiLambda Bckg: Pos. track PID
-  TH3F*   fAntiLambdaBckgPIDNegDaug;                //! AntiLambda Bckg: Neg. track PID
+  //        AntiLambda        //
+  TH2F*   fAntiLambdaPtPosDaug;                     //! AntiLambda: Pos. pt
+  TH2F*   fAntiLambdaPtNegDaug;                     //! AntiLambda: Neg. pt
+  TH2F*   fAntiLambdaBckgPtPosDaug;                 //! AntiLambda Bckg: Pos. pt
+  TH2F*   fAntiLambdaBckgPtNegDaug;                 //! AntiLambda Bckg: Neg. pt
 
   TH3F*   fAntiLambdaPhiEtaPosDaug;                 //! AntiLambda: Pos. track phi vs eta 
   TH3F*   fAntiLambdaPhiEtaNegDaug;                 //! AntiLambda: Neg. track phi vs eta
@@ -420,17 +469,10 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
   TH2F*   fAntiLambdaBckgDCAPosDaug;                //! AntiLambda Bckg: Pos. track DCA to primary vertex
   TH2F*   fAntiLambdaBckgDCANegDaug;                //! AntiLambda Bckg: Neg. track DCA to primary vertex
 
-  TH2F*   fAntiLambdaDifPtPosDaug;                  //! AntiLambda: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fAntiLambdaDifPtNegDaug;                  //! AntiLambda: Neg. track diference berween pt of the daughter and the V0
-  TH2F*   fAntiLambdaBckgDifPtPosDaug;              //! AntiLambda Bckg: Pos. track diference berween pt of the daughter and the V0
-  TH2F*   fAntiLambdaBckgDifPtNegDaug;              //! AntiLambda Bckg: Neg. track diference berween pt of the daughter and the V0
-
   TH3F*   fAntiLambdaDecayPos;                      //! AntiLambda: 2D decay position  
   TH3F*   fAntiLambdaBckgDecayPos;                  //! AntiLambda Bckg: 2D decay position   
   TH2F*   fAntiLambdaDecayVertex;                   //! AntiLambda: decay lenght
-  TH2F*   fAntiLambdaBckgDecayVertex;               //! AntiLambda Bckg: decay lenght 
-  TH2F*   fAntiLambdaDecayVertexZoom;               //! AntiLambda: decay lenght Zoom
-  TH2F*   fAntiLambdaBckgDecayVertexZoom;           //! AntiLambda Bckg: decay lenght Zoom
+  TH2F*   fAntiLambdaBckgDecayVertex;               //! AntiLambda Bckg: decay lenght
 
   TH2F*   fAntiLambdaCPA;                           //! AntiLambda: cosine of the pointing angle
   TH2F*   fAntiLambdaBckgCPA;                       //! AntiLambda Bckg: cosine of the pointing angle
@@ -461,13 +503,13 @@ class AliAnalysisTaskLambdaOverK0sJets : public AliAnalysisTaskSE {
 */
 class AliMiniParticle : public AliVParticle
 {
 public:
+ public:
  AliMiniParticle(Float_t centrality, Float_t vtxZ, Int_t id,Double_t pt, Double_t phi, 
                 Double_t eta, Int_t negDaugMC, Int_t posDaugMC, Short_t candidate)
    :fCentrality(centrality), fVtxZ(vtxZ),  fId(id), fPt(pt),
     fPhi(phi), fEta(eta), fNegDaugMC(negDaugMC), fPosDaugMC(posDaugMC), fCandidate(candidate)
-    {
-    }
+  {
+  }
   
   virtual ~AliMiniParticle() {}
   
index adc3e01ccc1c7e4684a9a058504677bc7c70ccc5..49158e25e323c437e55d54f85871b91c9eff3b94 100644 (file)
@@ -2,11 +2,9 @@ AliAnalysisTaskLambdaOverK0sJets *AddTaskLambdaOverK0sJets( TString  name      =
                                                            TString  data      = "PbPb2010", 
                                                            Float_t  minCen    = 0.,
                                                            Float_t  maxCen    = 40.,
-                                                           Float_t  dcaDaug   = 1.,
                                                            Bool_t   sepInjec  = kTRUE,
                                                            Bool_t   isMC      = kFALSE,
-                                                           Bool_t   usePID    = kTRUE,
-                                                           Bool_t   doQA      = kFALSE){
+                                                           Bool_t   doQA      = kTRUE){
 
 
 
@@ -16,6 +14,10 @@ AliAnalysisTaskLambdaOverK0sJets *AddTaskLambdaOverK0sJets( TString  name      =
   Float_t  etaMaxTrig  = 0.7;
   Float_t  checkIDTrig = kTRUE;
   Float_t  rapMaxV0    = 0.7;
+  Bool_t   usePID      = kFALSE;
+  Float_t  nSigmaPID   = 3.0;
+  Float_t  dcaDaug     = 0.095;  // looser cut
+  Float_t  nclsDaug    = 50;     // looser cut
 
 
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
@@ -24,7 +26,7 @@ AliAnalysisTaskLambdaOverK0sJets *AddTaskLambdaOverK0sJets( TString  name      =
     return NULL;
   }   
   
-  Float_t  nSigmaPID = 3.0;
+  
   
   // Create and configure the task
   AliAnalysisTaskLambdaOverK0sJets *task = new AliAnalysisTaskLambdaOverK0sJets(name.Data());
@@ -36,6 +38,7 @@ AliAnalysisTaskLambdaOverK0sJets *AddTaskLambdaOverK0sJets( TString  name      =
   task->SetMaxY(rapMaxV0);
   task->SetMaxDCADaughter(dcaDaug); // Add to perform systematics
   task->SetNSigmaPID(nSigmaPID);
+  task->SetNClsTPC(nclsDaug);
   task->SetSeparateInjectedPart(sepInjec);
   task->SetMC(isMC);
   task->SetPID(usePID);
index 92f48b9de4c4eaf3c2a02c078efdc802db85e15c..f81be88beac9e7d18374b2d4c648b55fe6e5c1e5 100644 (file)
@@ -1,4 +1,4 @@
-
 // "ESDs/pass2/AOD086/*/AliAOD.root"
 // "/alice/data/2010/LHC10h"
 
@@ -7,16 +7,15 @@ class AliAnalysisAlien;
 void runGridLambdaOverK0sJets(TString  runMode    = "full", 
                              TString  alirootVer = "v5-05-38-AN",
                              TString  rootVer    = "v5-34-11",
-                             TString  dataPath   = "ESDs/pass2/AOD115/*/AliAOD.root",
-                             TString  dataDir    = "/alice/data/2011/LHC11h_2",                      
+                             TString  dataPath   = "AOD124/*/AliAOD.root"/*"ESDs/pass2/AOD115/* /AliAOD.root"*/,
+                             TString  dataDir    = "/alice/sim/2012/LHC12a17d_fix"/*"/alice/data/2011/LHC11h_2"*/,                   
                              TString  workDir    = "test",
                              TString  name       = "LambdaOverK0sRatio", 
                              TString  data       = "PbPb2011",
                              Float_t  minCen     = 0.,
                              Float_t  maxCen     = 40.,
-                             Float_t  dcaDaug    = 0.5,
-                             Bool_t   sepInjec   = kTRUE,
-                             Bool_t   isMC       = kFALSE,
+                             Bool_t   sepInjec   = kFALSE,
+                             Bool_t   isMC       = kTRUE,
                              Bool_t   usePID     = kFALSE,
                              Bool_t   doQA       = kTRUE,
                              Int_t    run        = 169838/*137530*//*138624*/){
@@ -54,7 +53,7 @@ void runGridLambdaOverK0sJets(TString  runMode    = "full",
   gROOT->LoadMacro("AliAnalysisTaskLambdaOverK0sJets.cxx++g"); 
   //gSystem->Load("libPWGLFSTRANGENESS");
   gROOT->LoadMacro("AddTaskLambdaOverK0sJets.C");
-  AliAnalysisTaskLambdaOverK0sJets *task = AddTaskLambdaOverK0sJets(name,data,minCen,maxCen,dcaDaug,sepInjec,isMC,usePID,doQA);
+  AliAnalysisTaskLambdaOverK0sJets *task = AddTaskLambdaOverK0sJets(name,data,minCen,maxCen,sepInjec,isMC,doQA);
    // _____________________________________________________ //
  
    if (!mgr->InitAnalysis()) return;
@@ -142,13 +141,13 @@ AliAnalysisAlien* CreateAlienHandler(TString runMode,TString alirootVer,
   plugin->SetAnalysisMacro("AnalysisProduction.C");
   //plugin->SetAnalysisMacro("mytask.C");
   // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
-  plugin->SetSplitMaxInputFileNumber(50);
+  plugin->SetSplitMaxInputFileNumber(5);
   // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
   plugin->SetMaxInitFailed(12);
   // Optionally resubmit threshold.
   plugin->SetMasterResubmitThreshold(90);
   // Optionally set time to live (default 30000 sec)
-  plugin->SetTTL(30000);
+  plugin->SetTTL(450000);
   // Optionally set input format (default xml-single)
   plugin->SetInputFormat("xml-single");
   // Optionally modify the name of the generated JDL (default analysis.jdl)
index d37ad33f60c7c868798242def577e10ab73f349e..fb220568fa75d95b65ef466857156448588f03f2 100644 (file)
@@ -166,6 +166,8 @@ void AliAnalysisTrackingUncertainties::UserCreateOutputObjects()
   fListHist->Add(hBestMatchBg);
   fListHist->Add(hAllMatchBg);
   fListHist->Add(hAllMatchGloBg);
+  //add default track cuts in the output list
+  fListHist->Add(fESDtrackCuts);
   //
   // post data
   //
@@ -387,7 +389,7 @@ void AliAnalysisTrackingUncertainties::ProcessTrackCutVariation() {
     //
     // relevant variables
     //
-    Double_t pid        = Double_t(GetPid(track));
+    //Double_t pid        = Double_t(GetPid(track));
     //
     Int_t nclsTPC       = track->GetTPCncls();
     Float_t pT          = track->Pt();
@@ -422,7 +424,6 @@ void AliAnalysisTrackingUncertainties::ProcessTrackCutVariation() {
     }else {
       chi2ITS = 999.;
     }
-
     //
     track->GetImpactParameters(dca, cov);
     //
@@ -531,35 +532,43 @@ void AliAnalysisTrackingUncertainties::ProcessTrackCutVariation() {
     // remove all ITS requirements
     //
     // Leonardo and Emilia: 
-    //  -> beautify this (save the previous cut)
-    //  -> check if really all cuts related to the matching are removed
-    //  -> histogram with default cuts
-    //  -> if MC is available: fill it only for true primaries
+    //  -> if MC is available: fill it only for true primaries, 
+    //        --to be done for every cut?
     //  -> Postprocessing: plot histogram with 1 divided by histogram with 0 as a function of pT/eta/phi
-    // 
-    //
+    //  -> Do we want to remove the DCA cut?
+    Bool_t refit=fESDtrackCuts->GetRequireITSRefit();
+    Float_t chi2tpc= fESDtrackCuts->GetMaxChi2TPCConstrainedGlobal();
+    Float_t chi2its= fESDtrackCuts->GetMaxChi2PerClusterITS();
+    //TString str = fESDtrackCuts->GetMaxDCAToVertexXYPtDep();
+    
     fESDtrackCuts->SetRequireITSRefit(kFALSE);
-    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
     fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(99999.);
     fESDtrackCuts->SetMaxChi2PerClusterITS(999999.);
-    //
-    TString str = fESDtrackCuts->GetMaxDCAToVertexXYPtDep();
-    fESDtrackCuts->SetMaxDCAToVertexXYPtDep();
+       //TString str = fESDtrackCuts->GetMaxDCAToVertexXYPtDep();
+    //fESDtrackCuts->SetMaxDCAToVertexXYPtDep();
+    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
+    
+    if (fESDtrackCuts->AcceptTrack(track)) {
+      for(Int_t iPid = 0; iPid < 6; iPid++) {
+       Double_t vecHistTpcItsMatch[kNumberOfAxes] = {isMatched, pT, eta, phi, iPid};
+       if (IsConsistentWithPid(iPid, track)) histTpcItsMatch->Fill(vecHistTpcItsMatch); // fill with 1 here
+      }
+    }
+    //apply back the cuts
+    fESDtrackCuts->SetRequireITSRefit(refit);
+    fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(chi2tpc);
+    fESDtrackCuts->SetMaxChi2PerClusterITS(chi2its);
+    //fESDtrackCuts->SetMaxDCAToVertexXYPtDep(str.Data());
+    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
+    //set is matched
+    isMatched=kTRUE;
     if (fESDtrackCuts->AcceptTrack(track)) {
-      UInt_t status = track->GetStatus();
-      isMatched  = status&AliESDtrack::kITSrefit; // this will be obsolete
       for(Int_t iPid = 0; iPid < 6; iPid++) {
        Double_t vecHistTpcItsMatch[kNumberOfAxes] = {isMatched, pT, eta, phi, iPid};
        if (IsConsistentWithPid(iPid, track)) histTpcItsMatch->Fill(vecHistTpcItsMatch); // fill with 0 here
       }
     }
-    fESDtrackCuts->SetRequireITSRefit(kTRUE);
-    fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
-    fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
-    fESDtrackCuts->SetMaxDCAToVertexXYPtDep(str.Data());
-    fESDtrackCuts->SetMaxChi2PerClusterITS(36);
-    // fill with 1 here
-
+    
   } // end of track loop
 
 
index 1eaf489e7e75b66c7945bcf4fde226664cb48a9f..539db73858aaa6e62ab27efc385cff509376e972 100644 (file)
@@ -42,9 +42,20 @@ performAllPi(){
   isMC = kFALSE;
   selectTrue = kTRUE;
   keepTrue = kFALSE;
-  
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kFALSE;
   if(! LoadLib()) return;
-  
+
+  kPid2Sigma = kTRUE;
+  doeffPi(1,0.,etamin,etamax);
+  doeffPi(0,0.,etamin,etamax);
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kTRUE;
+  doeffPi(1,0.,etamin,etamax);
+  doeffPi(0,0.,etamin,etamax);
+  kPid3Sigma = kFALSE;
+
   // matching and PID eff.
   doeffPi(1,0.1,etamin,etamax);
   doeffPi(0,0.1,etamin,etamax);
@@ -139,8 +150,19 @@ performAllPr(){
   isMC = kFALSE;
   selectTrue = kTRUE;
   keepTrue = kFALSE;
-  
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kFALSE;
   if(! LoadLib()) return;
+
+  kPid2Sigma = kTRUE;
+  doeffPr(1,0.,etamin,etamax);
+  doeffPr(0,0.,etamin,etamax);
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kTRUE;
+  doeffPr(1,0.,etamin,etamax);
+  doeffPr(0,0.,etamin,etamax);
+  kPid3Sigma = kFALSE;
   
   // matching and PID eff.
   doeffPr(1,0.1,etamin,etamax);
@@ -236,15 +258,26 @@ performAllKa(){
   isMC = kFALSE;
   selectTrue = kTRUE;
   keepTrue = kFALSE;
-
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kFALSE;
   if(! LoadLib()) return;
 
+  kPid2Sigma = kTRUE;
+  doeffKa(1,0.,etamin,etamax);
+  doeffKa(0,0.,etamin,etamax);
+  kPid2Sigma = kFALSE;
+  kPid3Sigma = kTRUE;
+  doeffKa(1,0.,etamin,etamax);
+  doeffKa(0,0.,etamin,etamax);
+  kPid3Sigma = kFALSE;
+
   // matching and PID eff.
   doeffKa(1,0.1,etamin,etamax);
   doeffKa(0,0.1,etamin,etamax);
   doeffKa(1,0.2,etamin,etamax);
   doeffKa(1,0.4,etamin,etamax);
- doeffKa(1,0.6,etamin,etamax);
 doeffKa(1,0.6,etamin,etamax);
   doeffKa(1,0.8,etamin,etamax);
   doeffKa(0,0.2,etamin,etamax);
   doeffKa(0,0.4,etamin,etamax);
index 919015e53b8b9e2878b8a2fcddf38a33d03c5593..fd6a22abe6b55f7a4527fa82af8bf0f91365466e 100644 (file)
@@ -58,6 +58,8 @@ Bool_t kTOFmatch = kFALSE; // for combined PID requires TOF matching
 Bool_t kOverAll = kFALSE;
 Bool_t kOverAllTOFmatch = kFALSE;
 Bool_t kOverAll2Sigma = kFALSE;
+Bool_t kPid2Sigma = kFALSE;
+Bool_t kPid3Sigma = kFALSE;
 
 TH2F *hmatched;
 TH2F *htracked;
@@ -173,7 +175,7 @@ void doeffKa(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
     maxptbin = xmax[3];
   }
 
-  if(prob > 0.1999){
+  if(prob > 0.1999|| kPid3Sigma ||kPid2Sigma){
     kGoodMatch = kFALSE;
     kSigma2vs3 = kFALSE;
 //    if(! kOverAll) require5sigma = kTRUE;
@@ -336,6 +338,11 @@ void doeffKa(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
   if(kOverAll2Sigma)
     sprintf(flag2,"OverAll2sigma"); 
 
+  if(kPid3Sigma)
+    sprintf(flag2,"pid3sigma");
+  if(kPid2Sigma)
+    sprintf(flag2,"pid2sigma");
+
   if(pos){
     if(prob >=0.2) sprintf(name,"kaonPos%sP%iEff%i_%i%s%s.root",etarange,Int_t(prob*100),(cmin-1)*10,cmax*10,flag,flag2);
     else{
@@ -359,7 +366,7 @@ void doeffKa(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
 
 TH2F *GetHistoKap(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09 || kPid3Sigma||kPid2Sigma)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,ptM-0.001,xmax[3],xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
   if(kOverAll){
@@ -409,6 +416,8 @@ TH2F *GetHistoKap(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
   }
 
   if(require5sigma) x2[9] = 4.9;
+  if(kPid3Sigma && pMinkp>0.09) x2[9] = 2.9;
+  if(kPid2Sigma && pMinkp>0.09) x2[9] = 1.9;
 
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
 
@@ -422,7 +431,7 @@ TH2F *GetHistoKap(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
 
 TH2F *GetHistoKan(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09 || kPid3Sigma||kPid2Sigma)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,xmax[2],ptM-0.001,xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
  if(kOverAll){
@@ -470,6 +479,8 @@ TH2F *GetHistoKan(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t e
   }
 
   if(require5sigma) x2[10] = 4.9;
+  if(kPid3Sigma && pMinkn>0.09) x2[10] = 2.9;
+  if(kPid2Sigma && pMinkn>0.09) x2[10] = 1.9;
 
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid2;
 
index c99d4e8cfa65c52cbcf4fa56c89a8c7ddcaf5546..c6a060d89c3a51552219b98d841810532dc26d4c 100644 (file)
@@ -50,7 +50,7 @@ Bool_t kGoodMatch = kFALSE; // to check good matching
 
 Bool_t kSigma2vs3 = kFALSE; // to check good matching
 
-Bool_t require5sigma = kFALSE; // don't touch this flag
+Bool_t require5sigma = kTRUE; // don't touch this flag
 
 Bool_t bayesVsigma = kFALSE; // only to do checks
 
@@ -60,6 +60,9 @@ Bool_t kOverAll = kFALSE;
 Bool_t kOverAllTOFmatch = kFALSE;
 Bool_t kOverAll2Sigma = kFALSE;
 
+Bool_t kPid2Sigma = kFALSE;
+Bool_t kPid3Sigma = kFALSE;
+
 TH2F *hmatched;
 TH2F *htracked;
 
@@ -162,7 +165,7 @@ void doeffPi(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
     maxptbin = xmax[3];
   }
 
-  if(prob > 0.1999){
+  if(prob > 0.1999|| kPid3Sigma ||kPid2Sigma){
     kGoodMatch = kFALSE;
     kSigma2vs3 = kFALSE;
 //    if(! kOverAll) require5sigma = kTRUE;
@@ -323,6 +326,12 @@ void doeffPi(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
   if(kOverAll2Sigma)
     sprintf(flag2,"OverAll2sigma");
 
+  if(kPid3Sigma)
+    sprintf(flag2,"pid3sigma");
+  if(kPid2Sigma)
+    sprintf(flag2,"pid2sigma");
+
+
   if(pos){
     if(prob >=0.2) sprintf(name,"pionPos%sP%iEff%i_%i%s%s.root",etarange,Int_t(prob*100),(cmin-1)*10,cmax*10,flag,flag2);
     else{
@@ -346,7 +355,7 @@ void doeffPi(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
 
 TH2F *GetHistoPip(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09 || kPid3Sigma||kPid2Sigma)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,ptM-0.001,xmax[3],xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
   if(kOverAll){
@@ -396,6 +405,8 @@ TH2F *GetHistoPip(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
   }
 
   if(require5sigma) x2[9] = 4.9;
+  if(kPid3Sigma && pMinkp>0.09) x2[9] = 2.9;
+  if(kPid2Sigma && pMinkp>0.09) x2[9] = 1.9;
 
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
 
@@ -409,7 +420,7 @@ TH2F *GetHistoPip(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
 
 TH2F *GetHistoPin(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09 || kPid3Sigma|| kPid2Sigma)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,xmax[2],ptM-0.001,xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
   if(kOverAll){
@@ -458,6 +469,9 @@ TH2F *GetHistoPin(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t e
 
   if(require5sigma) x2[10] = 4.9;
 
+  if(kPid3Sigma && pMinkn>0.09) x2[10] = 2.9;
+  if(kPid2Sigma && pMinkn>0.09) x2[10] = 1.9;
+
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid2;
 
   TH2F *h = tmp->GetQA(0, x, x2);
index 9674730bc972d5eb6e3b7a923f9da9f303f04585..65a7277310887b8636204dcda71ce63be49a43f2 100644 (file)
@@ -59,6 +59,8 @@ Bool_t kTOFmatch = kFALSE; // for combined PID requires TOF matching
 Bool_t kOverAll = kFALSE;
 Bool_t kOverAllTOFmatch = kFALSE;
 Bool_t kOverAll2Sigma = kFALSE;
+Bool_t kPid2Sigma = kFALSE;
+Bool_t kPid3Sigma = kFALSE;
 
 TH2F *hmatched;
 TH2F *htracked;
@@ -162,7 +164,7 @@ void doeffPr(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
     maxptbin = xmax[3];
   }
 
-  if(prob > 0.1999){
+  if(prob > 0.1999|| kPid3Sigma ||kPid2Sigma){
     kGoodMatch = kFALSE;
     kSigma2vs3 = kFALSE;
 //    if(! kOverAll) require5sigma = kTRUE;
@@ -323,6 +325,11 @@ void doeffPr(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
   if(kOverAll2Sigma)
     sprintf(flag2,"OverAll2sigma");
 
+  if(kPid3Sigma)
+    sprintf(flag2,"pid3sigma");
+  if(kPid2Sigma)
+    sprintf(flag2,"pid2sigma");
+
   if(pos){
     if(prob >=0.2) sprintf(name,"protonPos%sP%iEff%i_%i%s%s.root",etarange,Int_t(prob*100),(cmin-1)*10,cmax*10,flag,flag2);
     else{
@@ -346,7 +353,7 @@ void doeffPr(Int_t pos,Float_t prob,Float_t etaminkp,Float_t etamaxkp){
 
 TH2F *GetHistoPrp(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,pt+0.001,xmin[3]+0.001,pMinkp+0.001,pMinkn+0.001,(pMinkp>0.09 || kPid3Sigma||kPid2Sigma)+0.001,kTOFmatch+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,ptM-0.001,xmax[3],xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
   if(kOverAll){
@@ -396,6 +403,8 @@ TH2F *GetHistoPrp(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
   }
 
   if(require5sigma) x2[9] = 4.9;
+  if(kPid3Sigma && pMinkp>0.09) x2[9] = 2.9;
+  if(kPid2Sigma && pMinkp>0.09) x2[9] = 1.9;
 
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid1;
 
@@ -409,7 +418,7 @@ TH2F *GetHistoPrp(Float_t pt,Float_t ptM,Float_t pMinkp,Float_t pMinkn,Float_t e
 
 TH2F *GetHistoPrn(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t etaminkp,Float_t etamaxkp){
 
-  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
+  Float_t x[] = {xmin[0]+0.001,etaminkp+0.001,xmin[2]+0.001,pt+0.001,pMinkp+0.001,pMinkn+0.001,kTOFmatch+0.001,(pMinkn>0.09 || kPid3Sigma||kPid2Sigma)+0.001,selectTrue,xmin[9],xmin[10],xmin[11],xmin[12],xmin[13]};
   Float_t x2[] = {xmax[0],etamaxkp-0.001,xmax[2],ptM-0.001,xmax[4],xmax[5],xmax[6],xmax[7],keepTrue,xmax[9],xmax[10],xmax[11],xmax[12],xmax[13]};
 
   if(kOverAll){
@@ -457,6 +466,8 @@ TH2F *GetHistoPrn(Float_t pt,Float_t ptM,Float_t pMinkn,Float_t pMinkp,Float_t e
   }
 
   if(require5sigma) x2[10] = 4.9;
+  if(kPid3Sigma && pMinkn>0.09) x2[10] = 2.9;
+  if(kPid2Sigma && pMinkn>0.09) x2[10] = 1.9;
 
   AliPIDperfContainer *tmp = (AliPIDperfContainer *) fContPid2;
 
index 4947305f4001e729fe69a10f7453a5bdbba2e517..f9930b6d0b22312613f44fd4e9377f496d4ec0d1 100644 (file)
@@ -111,4 +111,4 @@ eg. make STEERbase STEERbase-static
   make test-<Package>
   make test-<Module>-par-all
 
-!IMPORTANT! - Make sure your source folder is clean. If you used the old make system to build aliroot run make clean in the source directory before you run cmake
\ No newline at end of file
+!IMPORTANT! - Make sure your source folder is clean. If you used the old make system to build aliroot run make clean in the source directory before you run cmake
index a45e590efceab137064bf9fa3bcae81cf08eb2d2..958bed217f2a8f778ae1f59f63fea503fa272b26 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliDetectorPID.h"
 #include "AliAODEvent.h"
 #include "AliAODHMPIDrings.h"
+#include "AliTOFHeader.h"
 
 #include "AliAODTrack.h"
 
@@ -39,6 +40,7 @@ AliAODTrack::AliAODTrack() :
   fRAtAbsorberEnd(0.),
   fChi2perNDF(-999.),
   fChi2MatchTrigger(0.),
+  fPID(0),
   fFlags(0),
   fLabel(-999),
   fTOFLabel(),
@@ -55,6 +57,7 @@ AliAODTrack::AliAODTrack() :
   fID(-999),
   fCharge(-99),
   fType(kUndef),
+  fPIDForTracking(AliPID::kPion),
   fCaloIndex(kEMCALNoMatch),
   fCovMatrix(NULL),
   fDetPid(NULL),
@@ -73,7 +76,6 @@ AliAODTrack::AliAODTrack() :
   SetPosition((Float_t*)NULL);
   SetXYAtDCA(-999., -999.);
   SetPxPyPzAtDCA(-999., -999., -999.);
-  SetPID((Float_t*)NULL);
   for (Int_t i = 0; i < 3; i++) {fTOFLabel[i] = -1;}
 }
 
@@ -87,7 +89,6 @@ AliAODTrack::AliAODTrack(Short_t id,
                         Double_t covMatrix[21],
                         Short_t charge,
                         UChar_t itsClusMap,
-                        Double_t pid[10],
                         AliAODVertex *prodVertex,
                         Bool_t usedForVtxFit,
                         Bool_t usedForPrimVtxFit,
@@ -98,6 +99,7 @@ AliAODTrack::AliAODTrack(Short_t id,
   fRAtAbsorberEnd(0.),
   fChi2perNDF(chi2perNDF),
   fChi2MatchTrigger(0.),
+  fPID(0),
   fFlags(0),
   fLabel(label),
   fTOFLabel(),
@@ -114,6 +116,7 @@ AliAODTrack::AliAODTrack(Short_t id,
   fID(id),
   fCharge(charge),
   fType(ttype),
+  fPIDForTracking(AliPID::kPion),
   fCaloIndex(kEMCALNoMatch),
   fCovMatrix(NULL),
   fDetPid(NULL),
@@ -135,7 +138,6 @@ AliAODTrack::AliAODTrack(Short_t id,
   SetUsedForVtxFit(usedForVtxFit);
   SetUsedForPrimVtxFit(usedForPrimVtxFit);
   if(covMatrix) SetCovMatrix(covMatrix);
-  SetPID(pid);
   SetITSClusterMap(itsClusMap);
   for (Int_t i=0;i<3;i++) {fTOFLabel[i]=-1;}
 }
@@ -150,17 +152,17 @@ AliAODTrack::AliAODTrack(Short_t id,
                         Float_t covMatrix[21],
                         Short_t charge,
                         UChar_t itsClusMap,
-                        Float_t pid[10],
                         AliAODVertex *prodVertex,
                         Bool_t usedForVtxFit,
                         Bool_t usedForPrimVtxFit,
                         AODTrk_t ttype,
                         UInt_t selectInfo,
-                        Float_t chi2perNDF) :
+                        Float_t chi2perNDF ) :
   AliVTrack(),
   fRAtAbsorberEnd(0.),
   fChi2perNDF(chi2perNDF),
   fChi2MatchTrigger(0.),
+  fPID(0),
   fFlags(0),
   fLabel(label),
   fTOFLabel(),
@@ -177,6 +179,7 @@ AliAODTrack::AliAODTrack(Short_t id,
   fID(id),
   fCharge(charge),
   fType(ttype),
+  fPIDForTracking(AliPID::kPion),
   fCaloIndex(kEMCALNoMatch),
   fCovMatrix(NULL),
   fDetPid(NULL),
@@ -198,7 +201,6 @@ AliAODTrack::AliAODTrack(Short_t id,
   SetUsedForVtxFit(usedForVtxFit);
   SetUsedForPrimVtxFit(usedForPrimVtxFit);
   if(covMatrix) SetCovMatrix(covMatrix);
-  SetPID(pid);
   SetITSClusterMap(itsClusMap);
   for (Int_t i=0;i<3;i++) {fTOFLabel[i]=-1;}
 }
@@ -210,6 +212,7 @@ AliAODTrack::~AliAODTrack()
   delete fCovMatrix;
   delete fDetPid;
   delete fDetectorPID;
+  delete[] fPID;
 }
 
 
@@ -219,6 +222,7 @@ AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
   fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
   fChi2perNDF(trk.fChi2perNDF),
   fChi2MatchTrigger(trk.fChi2MatchTrigger),
+  fPID(0),
   fFlags(trk.fFlags),
   fLabel(trk.fLabel),
   fTOFLabel(),
@@ -235,6 +239,7 @@ AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
   fID(trk.fID),
   fCharge(trk.fCharge),
   fType(trk.fType),
+  fPIDForTracking(trk.fPIDForTracking),
   fCaloIndex(trk.fCaloIndex),
   fCovMatrix(NULL),
   fDetPid(NULL),
@@ -277,7 +282,7 @@ AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
     fRAtAbsorberEnd    = trk.fRAtAbsorberEnd;
     fChi2perNDF        = trk.fChi2perNDF;
     fChi2MatchTrigger  = trk.fChi2MatchTrigger;
-    trk.GetPID(fPID);
+    SetPID( trk.fPID );
     fFlags             = trk.fFlags;
     fLabel             = trk.fLabel;    
     fTrackLength       = trk.fTrackLength;
@@ -293,6 +298,7 @@ AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
     fID                = trk.fID;
     fCharge            = trk.fCharge;
     fType              = trk.fType;
+    fPIDForTracking    = trk.fPIDForTracking;
     fCaloIndex         = trk.fCaloIndex;
     fTrackPhiOnEMCal   = trk.fTrackPhiOnEMCal;
     fTrackEtaOnEMCal   = trk.fTrackEtaOnEMCal;
@@ -444,21 +450,22 @@ AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
   
   Int_t nPID = 10;
   AODTrkPID_t loc = kUnknown;
-  Double_t max = 0.;
   Bool_t allTheSame = kTRUE;
-  
-  for (Int_t iPID = 0; iPID < nPID; iPID++) {
-    if (fPID[iPID] >= max) {
-      if (fPID[iPID] > max) {
-       allTheSame = kFALSE;
-       max = fPID[iPID];
-       loc = (AODTrkPID_t)iPID;
-      } else {
-       allTheSame = kTRUE;
+  if (fPID) {
+    Double_t max = 0.;
+    for (Int_t iPID = 0; iPID < nPID; iPID++) {
+      if (fPID[iPID] >= max) {
+       if (fPID[iPID] > max) {
+         allTheSame = kFALSE;
+         max = fPID[iPID];
+         loc = (AODTrkPID_t)iPID;
+       } else {
+         allTheSame = kTRUE;
+       }
       }
     }
   }
-  return allTheSame ? kUnknown : loc;
+  return allTheSame ? AODTrkPID_t(GetPIDForTracking()) : loc;
 }
 
 //______________________________________________________________________________
@@ -467,13 +474,13 @@ void AliAODTrack::ConvertAliPIDtoAODPID()
   // Converts AliPID array.
   // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
   // Everything else has to be set to zero.
-
-  fPID[kDeuteron] = 0.;
-  fPID[kTriton]   = 0.;
-  fPID[kHelium3]  = 0.;
-  fPID[kAlpha]    = 0.;
-  fPID[kUnknown]  = 0.;
-  
+  if (fPID) {
+    fPID[kDeuteron] = 0.;
+    fPID[kTriton]   = 0.;
+    fPID[kHelium3]  = 0.;
+    fPID[kAlpha]    = 0.;
+    fPID[kUnknown]  = 0.;
+  }
   return;
 }
 
@@ -1109,3 +1116,14 @@ void  AliAODTrack::GetITSdEdxSamples(Double_t s[4]) const
   if (!fDetPid) for (int i=4;i--;) s[i]=0;
   else          for (int i=4;i--;) s[i] = fDetPid->GetITSdEdxSample(i);
 }
+
+//_____________________________________________
+Double_t AliAODTrack::GetMassForTracking() const
+{
+  double m = AliPID::ParticleMass(fPIDForTracking);
+  return (fPIDForTracking==AliPID::kHe3 || fPIDForTracking==AliPID::kAlpha) ? -m : m;
+}
+//_______________________________________________________
+const AliTOFHeader* AliAODTrack::GetTOFHeader() const {
+  return fAODEvent->GetTOFHeader();
+}
index 2adb7bd0b9a2aca35d42d114685d276bba58a043..df3524a596a5ae72e43f8518a216be599b421ecd 100644 (file)
@@ -23,6 +23,7 @@ class AliVVertex;
 class AliDetectorPID;
 class AliTPCdEdxInfo;
 class AliAODEvent;
+class AliTOFHeader;
 
 class AliAODTrack : public AliVTrack {
 
@@ -80,7 +81,6 @@ class AliAODTrack : public AliVTrack {
              Double_t covMatrix[21],
              Short_t q,
              UChar_t itsClusMap,
-             Double_t pid[10],
              AliAODVertex *prodVertex,
              Bool_t usedForVtxFit,
              Bool_t usedForPrimVtxFit,
@@ -88,6 +88,7 @@ class AliAODTrack : public AliVTrack {
              UInt_t selectInfo=0,
              Float_t chi2perNDF = -999.);
 
+
   AliAODTrack(Short_t id,
              Int_t label,
              Float_t p[3],
@@ -97,7 +98,6 @@ class AliAODTrack : public AliVTrack {
              Float_t covMatrix[21],
              Short_t q,
              UChar_t itsClusMap,
-             Float_t pid[10],
              AliAODVertex *prodVertex,
              Bool_t usedForVtxFit,
              Bool_t usedForPrimVtxFit,
@@ -163,13 +163,21 @@ class AliAODTrack : public AliVTrack {
   void ConvertAliPIDtoAODPID();
   void SetDetPID(AliAODPid *aodpid) {fDetPid = aodpid;}
 
+  void     SetPIDForTracking(Int_t pid) {fPIDForTracking = pid;}
+  Int_t    GetPIDForTracking()  const   {return fPIDForTracking;}
+  Double_t GetMassForTracking() const;
+
   template <typename T> void GetPID(T *pid) const {
-    for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
+    for(Int_t i=0; i<10; ++i) pid[i] = fPID ? fPID[i]:0;}
  
   template <typename T> void SetPID(const T *pid) {
-    if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
-    else {  for(Int_t i=0; i<10; i++) fPID[i]=0.; fPID[AliAODTrack::kUnknown]=1.;}}
-
+    if (pid) {
+      if (!fPID) fPID = new Double32_t[10];
+      for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
+    }
+    else {delete[] fPID; fPID = 0;}
+  }
+  
   Bool_t IsOn(Int_t mask) const {return (fFlags&mask)>0;}
   ULong_t GetStatus() const { return GetFlags(); }
   ULong_t GetFlags() const { return fFlags; }
@@ -326,6 +334,7 @@ class AliAODTrack : public AliVTrack {
 
   const AliAODEvent* GetAODEvent() const {return fAODEvent;}
   void SetAODEvent(const AliAODEvent* ptr){fAODEvent = ptr;}
+  const AliTOFHeader* GetTOFHeader() const;
 
   AliAODPid    *GetDetPid() const { return fDetPid; }
   AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
@@ -421,7 +430,7 @@ class AliAODTrack : public AliVTrack {
   
   Double32_t    fChi2perNDF;        // chi2/NDF of momentum fit
   Double32_t    fChi2MatchTrigger;  // chi2 of trigger/track matching
-  Double32_t    fPID[10];           // [0.,1.,8] pointer to PID object
+  Double32_t*   fPID;               //! [0.,1.,8] pointer to PID object
 
   ULong_t       fFlags;             // reconstruction status flags 
   Int_t         fLabel;             // track label, points back to MC track
@@ -445,6 +454,8 @@ class AliAODTrack : public AliVTrack {
   Char_t        fCharge;            // particle charge
   Char_t        fType;              // Track Type
 
+  Char_t        fPIDForTracking;    // pid using for tracking of ESD track
+
   Int_t         fCaloIndex;         // index of associated EMCAL/PHOS cluster (AliAODCaloCluster)
 
   
@@ -462,7 +473,7 @@ class AliAODTrack : public AliVTrack {
 
   const AliAODEvent* fAODEvent;     //! 
 
-  ClassDef(AliAODTrack, 22);
+  ClassDef(AliAODTrack, 23);
 };
 
 inline Bool_t  AliAODTrack::IsPrimaryCandidate() const
index c1241bf593e8ae9e97f85c595a1044693328ca7e..b5e85dabf6e515a415ed60ff238c0ff73a4b7cbb 100644 (file)
@@ -17,7 +17,6 @@
 
 #pragma link C++ class AliAODEvent+;
 #pragma link C++ class AliAODHeader+;
-#pragma link C++ class AliAODTrack+;
 
 #pragma read                                              \
     sourceClass="AliAODPid"                               \
     code="{newObj->SetTPCsignalN((UChar_t)onfile.fTPCsignalN); newObj->SetTPCmomentum(onfile.fTPCmomentum); for (Int_t i=0;i<6;++i) newObj->SetTRDmomentum(i,onfile.fTRDmomentum[i]);}" 
 
 #pragma link C++ class AliAODPid+;
+
+
+#pragma read sourceClass="AliAODTrack" targetClass="AliAODTrack" source="Double32_t fPID[10]"  version="[-23]" \
+ target="fPID" targetType="Double32_t*" \
+   code="{fPID = new Double32_t[10];for(Int_t isp=10;isp--;) fPID[isp]=onfile.fPID[isp];}"
+
+#pragma link C++ class AliAODTrack+;
+
 #pragma link C++ class AliAODVertex+;
 #pragma link C++ class AliAODCluster+;
 #pragma link C++ class AliAODCaloCluster+;
index 4df8b227af03a9cba4db5b3e6e46a490c5efafa7..5f72ac612ac4e9237ee44cfc5c54650d38166d39 100644 (file)
@@ -166,7 +166,7 @@ AliESDEvent::AliESDEvent():
   fDAQDetectorPattern(0xFFFF),
   fDAQAttributes(0xFFFF),
   fNTOFclusters(0),
-  fTOFcluster(new TObjArray(1))
+  fTOFcluster(0)
 {
 }
 //______________________________________________________________________________
@@ -1439,6 +1439,7 @@ void AliESDEvent::GetStdContent()
   fESDAD = (AliESDAD*)fESDObjects->FindObject(fgkESDListName[kESDAD]);
   fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]);
   fCosmicTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCosmicTracks]);
+  fTOFcluster = new TObjArray(1);
 }
 
 void AliESDEvent::SetStdNames(){
index b630c4ce14cee1ef132caeb83a1f5d805fb5028d..b16fd19f857ef6a5178932c944a8c7d9b853054c 100644 (file)
@@ -74,7 +74,6 @@ class AliESDCosmicTrack;
 class TList;
 class TString;
 
-
 class AliESDEvent : public AliVEvent {
 public:
 
index e8bebbf14c808e0802ea77f3a445e8ce047957df..e6cb319327b15b6be9047a3f7cec6d8370ecec40 100644 (file)
@@ -469,7 +469,7 @@ Float_t AliESDpid::GetNumberOfSigmasTOFold(const AliVParticle *track, AliPID::EP
 }
 
 //_________________________________________________________________________
-void AliESDpid::SetMassForTracking(AliESDtrack *esdtr) const
+void AliESDpid::SetPIDForTracking(AliESDtrack *esdtr) const
 {
   // assign mass for tracking
   //
@@ -484,7 +484,7 @@ void AliESDpid::SetMassForTracking(AliESDtrack *esdtr) const
   EDetPidStatus pidStatus=ComputePIDProbability(kTPC, esdtr, AliPID::kSPECIESC, prob);
   // check if a valid signal was found, otherwise return pion mass
   if (pidStatus!=kDetPidOk) {
-    esdtr->SetMassForTracking(AliPID::kPion);
+    esdtr->SetPIDForTracking(AliPID::kPion);
     return;
   }
 
@@ -501,7 +501,7 @@ void AliESDpid::SetMassForTracking(AliESDtrack *esdtr) const
   //
   if (pid<AliPID::kPion || pid>AliPID::kSPECIESC-1) pid = AliPID::kPion;
   //
-  esdtr->SetMassForTracking( AliPID::ParticleCharge(pid)==1 ? AliPID::ParticleMass(pid) : -AliPID::ParticleMass(pid));
+  esdtr->SetPIDForTracking( pid );
   //
 }
 
@@ -513,7 +513,7 @@ void AliESDpid::MakePIDForTracking(AliESDEvent *event) const
   Int_t nTrk=event->GetNumberOfTracks();
   for (Int_t iTrk=nTrk; iTrk--;) {  
     AliESDtrack *track = event->GetTrack(iTrk);
-    SetMassForTracking(track);
+    SetPIDForTracking(track);
   }
 
 }
index 6e1d5279e76919e53ff1efd85abbaa5e78196b0b..2c79267f64688211c6b2c6ee1c4abbe9621cfad6 100644 (file)
@@ -42,7 +42,7 @@ AliESDpid& operator=(const AliESDpid& a){if (this==&a) return *this; AliPIDRespo
   void MakeTRDPID(AliESDtrack *track) const;
   void CombinePID(AliESDtrack *track) const;
 
-  void SetMassForTracking(AliESDtrack *track) const;
+  void SetPIDForTracking(AliESDtrack *track) const;
 
 //   Float_t NumberOfSigmasTOF(const AliVParticle *track, AliPID::EParticleType type) const {return AliPIDResponse::NumberOfSigmasTOF(track,type);}
 //   Float_t GetNumberOfSigmasTOF(const AliVParticle *track, AliPID::EParticleType type, const Float_t timeZeroTOF) const;
index da01af84eb4db8f5e9303c7e3dd3d3ab1a5fcd98..c590d247756da20cadea45c1ddb44d4d48ffbf17 100644 (file)
@@ -185,7 +185,12 @@ AliESDtrack::AliESDtrack() :
   fHMPIDqn(0),
   fHMPIDcluIdx(-1),
   fCaloIndex(kEMCALNoMatch),
-  fMassForTracking(0.13957),
+  fR(0),
+  fITSr(0),
+  fTPCr(0),
+  fTRDr(0),
+  fTOFr(0),
+  fHMPIDr(0),
   fHMPIDtrkTheta(0),
   fHMPIDtrkPhi(0),
   fHMPIDsignal(0),
@@ -242,6 +247,7 @@ AliESDtrack::AliESDtrack() :
   fTRDnSlices(0),
   fTRDslices(0x0),
   fVertexID(-2),// -2 means an orphan track 
+  fPIDForTracking(AliPID::kPion),
   fESDEvent(0),
   fCacheNCrossedRows(-10),
   fCacheChi2TPCConstrainedVsGlobal(-10),
@@ -260,7 +266,6 @@ AliESDtrack::AliESDtrack() :
 
   Int_t i;
   for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
-  for (i=0; i<AliPID::kSPECIES; i++) fR[i]=fITSr[i]=fTPCr[i]=fTRDr[i]=fTOFr[i]=fHMPIDr[i]=0.;
   
   for (i=0; i<3; i++)   { fKinkIndexes[i]=0;}
   for (i=0; i<3; i++)   { fV0Indexes[i]=0;}
@@ -299,7 +304,12 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
   fHMPIDqn(track.fHMPIDqn),
   fHMPIDcluIdx(track.fHMPIDcluIdx),
   fCaloIndex(track.fCaloIndex),
-  fMassForTracking(track.fMassForTracking),
+  fR(0),
+  fITSr(0),
+  fTPCr(0),
+  fTRDr(0),
+  fTOFr(0),
+  fHMPIDr(0),
   fHMPIDtrkTheta(track.fHMPIDtrkTheta),
   fHMPIDtrkPhi(track.fHMPIDtrkPhi),
   fHMPIDsignal(track.fHMPIDsignal),
@@ -356,6 +366,7 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
   fTRDnSlices(track.fTRDnSlices),
   fTRDslices(0x0),
   fVertexID(track.fVertexID),
+  fPIDForTracking(AliPID::kPion),
   fESDEvent(track.fESDEvent),
   fCacheNCrossedRows(track.fCacheNCrossedRows),
   fCacheChi2TPCConstrainedVsGlobal(track.fCacheChi2TPCConstrainedVsGlobal),
@@ -377,11 +388,20 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
     for (Int_t i=0;i<AliPID::kSPECIESC;i++) fTrackTime[i]=track.fTrackTime[i];
   }
 
-  for (Int_t i=0;i<AliPID::kSPECIES;i++)  fR[i]=track.fR[i];
-  //
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i]; 
+  if (track.fR) {
+    fR = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;)  fR[i]=track.fR[i];
+  }
+  if (track.fITSr) {
+    fITSr = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;)  fITSr[i]=track.fITSr[i]; 
+  }
   //
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i]; 
+  if (track.fTPCr) {
+    fTPCr = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;) fTPCr[i]=track.fTPCr[i]; 
+  }
+
   for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
   for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
   for (Int_t i=0; i<3;i++)   { fKinkIndexes[i]=track.fKinkIndexes[i];}
@@ -398,8 +418,16 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
 
   if (track.fDetectorPID) fDetectorPID = new AliDetectorPID(*track.fDetectorPID);
 
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i]; 
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
+  if (track.fTRDr) {
+    fTRDr  = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fTRDr[i]=track.fTRDr[i]; 
+  }
+
+  if (track.fTOFr) {
+    fTOFr = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fTOFr[i]=track.fTOFr[i];
+  }
+
   if(track.fTOFLabel){
     if(!fTOFLabel) fTOFLabel = new Int_t[3];
     for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
@@ -407,7 +435,11 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
 
   for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
   for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
+  
+  if (track.fHMPIDr) {
+    fHMPIDr = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fHMPIDr[i]=track.fHMPIDr[i];
+  }
 
   if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
   if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
@@ -449,7 +481,12 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   fHMPIDqn(0),
   fHMPIDcluIdx(-1),
   fCaloIndex(kEMCALNoMatch),
-  fMassForTracking(0.13957),
+  fR(0),
+  fITSr(0),
+  fTPCr(0),
+  fTRDr(0),
+  fTOFr(0),
+  fHMPIDr(0),
   fHMPIDtrkTheta(0),
   fHMPIDtrkPhi(0),
   fHMPIDsignal(0),
@@ -506,6 +543,7 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   fTRDnSlices(0),
   fTRDslices(0x0),
   fVertexID(-2),  // -2 means an orphan track
+  fPIDForTracking(track->GetPIDForTracking()),
   fESDEvent(0),
   fCacheNCrossedRows(-10),
   fCacheChi2TPCConstrainedVsGlobal(-10),
@@ -532,7 +570,6 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   // Reset all the arrays
   Int_t i;
   for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
-  for (i=0; i<AliPID::kSPECIES; i++) fR[i]=fITSr[i]=fTPCr[i]=fTRDr[i]=fTOFr[i]=fHMPIDr[i]=0.;
   
   for (i=0; i<3; i++)   { fKinkIndexes[i]=0;}
   for (i=0; i<3; i++)   { fV0Indexes[i]=-1;}
@@ -569,7 +606,10 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   //
   // Set the combined PID
   const Double_t *pid = track->PID();
-  if(pid) for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
+  if(pid) {
+    fR = new Double32_t[AliPID::kSPECIES];
+    for (i=AliPID::kSPECIES; i--;) fR[i]=pid[i];
+  }
   //
   // calo matched cluster id
   SetEMCALcluster(track->GetEMCALcluster());
@@ -636,7 +676,12 @@ AliESDtrack::AliESDtrack(TParticle * part) :
   fHMPIDqn(0),
   fHMPIDcluIdx(-1),
   fCaloIndex(kEMCALNoMatch),
-  fMassForTracking(0.13957),
+  fR(0),
+  fITSr(0),
+  fTPCr(0),
+  fTRDr(0),
+  fTOFr(0),
+  fHMPIDr(0),
   fHMPIDtrkTheta(0),
   fHMPIDtrkPhi(0),
   fHMPIDsignal(0),
@@ -693,6 +738,7 @@ AliESDtrack::AliESDtrack(TParticle * part) :
   fTRDnSlices(0),
   fTRDslices(0x0),
   fVertexID(-2),  // -2 means an orphan track
+  fPIDForTracking(AliPID::kPion),
   fESDEvent(0),
   fCacheNCrossedRows(-10),
   fCacheChi2TPCConstrainedVsGlobal(-10),
@@ -711,7 +757,6 @@ AliESDtrack::AliESDtrack(TParticle * part) :
   // Reset all the arrays
   Int_t i;
   for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
-  for (i=0; i<AliPID::kSPECIES; i++) fR[i]=fITSr[i]=fTPCr[i]=fTRDr[i]=fTOFr[i]=fHMPIDr[i]=0.;
   
   for (i=0; i<3; i++)   { fKinkIndexes[i]=0;}
   for (i=0; i<3; i++)   { fV0Indexes[i]=-1;}
@@ -771,18 +816,10 @@ AliESDtrack::AliESDtrack(TParticle * part) :
   // Set the PID
   Int_t indexPID = 99;
   if (pdgCode<0) pdgCode = -pdgCode;
-  for (i=0;i<AliPID::kSPECIES;i++) if (pdgCode==AliPID::ParticleCode(i)) {indexPID = i; break;}
+  for (i=0;i<AliPID::kSPECIESC;i++) if (pdgCode==AliPID::ParticleCode(i)) {indexPID = i; break;}
 
-  // If the particle is not valid charged the PID probabilities are set to 0
-  if (indexPID < AliPID::kSPECIES) {
-    fR[indexPID]=1.;
-    fITSr[indexPID]=1.;
-    fTPCr[indexPID]=1.;
-    fTRDr[indexPID]=1.;
-    fTOFr[indexPID]=1.;
-    fHMPIDr[indexPID]=1.;
+  if (indexPID < AliPID::kSPECIES) fPIDForTracking = indexPID;
 
-  }
   // AliESD track label
   SetLabel(part->GetUniqueID());
 
@@ -816,12 +853,21 @@ AliESDtrack::~AliESDtrack(){
 
   delete fDetectorPID;
 
+  delete[] fR;
+  delete[] fITSr;
+  delete[] fTPCr;
+  delete[] fTRDr;
+  delete[] fTOFr;
+  delete[] fHMPIDr;
+  //
   if(fTrackTime) delete[] fTrackTime; 
   if(fTOFLabel) delete[] fTOFLabel;
 }
 
-AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
-  
+//_______________________________________________________________________
+AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source)
+{
+  // == operator
 
   if(&source == this) return *this;
   AliExternalTrackParam::operator=(source);
@@ -930,16 +976,43 @@ AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
     fV0Indexes[i]   = source.fV0Indexes[i]; 
   }
 
-  for(int i = 0; i< AliPID::kSPECIES;++i){
-    fR[i]     = source.fR[i];
-    fITSr[i]  = source.fITSr[i];
-    fTPCr[i]  = source.fTPCr[i];
-    fTRDr[i]  = source.fTRDr[i];
-    fTOFr[i]  = source.fTOFr[i];
-    fHMPIDr[i] = source.fHMPIDr[i];
+  if (source.fR) {
+    if (!fR) fR = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;)  fR[i]=source.fR[i];
+  }
+  else {delete[] fR; fR = 0;}
+
+  if (source.fITSr) {
+    if (!fITSr) fITSr = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;)  fITSr[i]=source.fITSr[i]; 
   }
+  else {delete[] fITSr; fITSr = 0;}
+  //
+  if (source.fTPCr) {
+    if (!fTPCr) fTPCr = new Double32_t[AliPID::kSPECIES]; 
+    for (Int_t i=AliPID::kSPECIES;i--;) fTPCr[i]=source.fTPCr[i]; 
+  }
+  else {delete[] fTPCr; fTPCr = 0;}
+
+  if (source.fTRDr) {
+    if (!fTRDr) fTRDr  = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fTRDr[i]=source.fTRDr[i]; 
+  }
+  else {delete[] fTRDr; fTRDr = 0;}
+
+  if (source.fTOFr) {
+    if (!fTOFr) fTOFr = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fTOFr[i]=source.fTOFr[i];
+  }
+  else {delete[] fTOFr; fTOFr = 0;}
+
+  if (source.fHMPIDr) {
+    if (!fHMPIDr) fHMPIDr = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES;i--;) fHMPIDr[i]=source.fHMPIDr[i];
+  }
+  else {delete[] fHMPIDr; fHMPIDr = 0;}
   
-  fMassForTracking = source.fMassForTracking;
+  fPIDForTracking = source.fPIDForTracking;
 
   fHMPIDtrkTheta = source.fHMPIDtrkTheta;
   fHMPIDtrkPhi   = source.fHMPIDtrkPhi;
@@ -1037,6 +1110,7 @@ AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
   fTRDncls0  = source.fTRDncls0;      
   fTRDntracklets  = source.fTRDntracklets; 
   fVertexID = source.fVertexID;
+  fPIDForTracking = source.fPIDForTracking;
 
   fCacheNCrossedRows = source.fCacheNCrossedRows;
   fCacheChi2TPCConstrainedVsGlobal = source.fCacheChi2TPCConstrainedVsGlobal;
@@ -1158,11 +1232,16 @@ Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
   track.fTPCnclsFIter1   = fTPCnclsFIter1;     
 
   // PID 
-  for(int i=0;i<AliPID::kSPECIES;++i){
-    track.fTPCr[i] = fTPCr[i];
-    // combined PID is TPC only!
-    track.fR[i] = fTPCr[i];
+  if (fTPCr) {
+    if (!track.fTPCr) track.fTPCr = new Double32_t[AliPID::kSPECIES];
+    for(int i=AliPID::kSPECIES;i--;) track.fTPCr[i] = fTPCr[i];
+  }
+  //
+  if (fR) {
+    if (!track.fR) track.fR = new Double32_t[AliPID::kSPECIES];
+    for(int i=AliPID::kSPECIES;i--;) track.fR[i] = fR[i];
   }
+    
   track.fTPCFitMap = fTPCFitMap;
   track.fTPCClusterMap = fTPCClusterMap;
   track.fTPCSharedMap = fTPCSharedMap;
@@ -1214,7 +1293,7 @@ void AliESDtrack::MakeMiniESDtrack(){
   fITSSharedMap=0;
   fITSsignal = 0;     
   for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0; 
+  if (fITSr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0; 
   fITSLabel = 0;       
 
   // Reset TPC related track information
@@ -1231,7 +1310,7 @@ void AliESDtrack::MakeMiniESDtrack(){
   fTPCsignalTuned= 0;
   fTPCsignalS= 0;      
   fTPCsignalN= 0;      
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0; 
+  if (fTPCr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i] = 0; 
   fTPCLabel=0;       
   for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
   for (Int_t i=0; i<3;i++)   fKinkIndexes[i] = 0;
@@ -1248,7 +1327,7 @@ void AliESDtrack::MakeMiniESDtrack(){
   for (Int_t i=0;i<kTRDnPlanes;i++) {
     fTRDTimBin[i]  = 0;
   }
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0; 
+  if (fTRDr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0; 
   fTRDLabel = 0;       
   fTRDQuality  = 0;
   fTRDntracklets = 0;
@@ -1269,7 +1348,7 @@ void AliESDtrack::MakeMiniESDtrack(){
   fTOFsignalDx = 999;
   fTOFdeltaBC = 999;
   fTOFl0l1 = 999;
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
+  if (fTOFr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
   for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
 
   // Reset HMPID related track information
@@ -1277,8 +1356,7 @@ void AliESDtrack::MakeMiniESDtrack(){
   fHMPIDqn = 0;     
   fHMPIDcluIdx = -1;     
   fHMPIDsignal = 0;     
-  for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
-  fMassForTracking = 0.13957;
+  if (fHMPIDr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
   fHMPIDtrkTheta = 0;     
   fHMPIDtrkPhi = 0;      
   fHMPIDtrkX = 0;     
@@ -1291,25 +1369,29 @@ void AliESDtrack::MakeMiniESDtrack(){
   fGlobalChi2 = 0;
 
   fVertexID = -2; // an orphan track
-
+  fPIDForTracking = AliPID::kPion;
+  //
   delete fFriendTrack; fFriendTrack = 0;
 } 
 
 //_______________________________________________________________________
 Int_t AliESDtrack::GetPID(Bool_t tpcOnly) const 
 {
-  // Returns the particle most probable id
+  // Returns the particle most probable id. For backward compatibility first the prob. arrays
+  // will be checked, but normally the GetPIDForTracking will be returned
   Int_t i;
   const Double32_t *prob = 0;
   if (tpcOnly) { // check if TPCpid is valid
+    if (!fTPCr) return GetPIDForTracking();
     prob = fTPCr;
     for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
     if (i == AliPID::kSPECIES-1) prob = 0; // not valid, try with combined pid
   }
   if (!prob) { // either requested TPCpid is not valid or comb.pid is requested 
+    if (!fR) return GetPIDForTracking();
     prob = fR;
     for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
-    if (i == AliPID::kSPECIES-1) return AliPID::kPion;  // If all the probabilities are equal, return the pion mass
+    if (i == AliPID::kSPECIES-1) return GetPIDForTracking();  // If all the probabilities are equal, return the pion mass
   }
   //
   Float_t max=0.;
@@ -1317,19 +1399,21 @@ Int_t AliESDtrack::GetPID(Bool_t tpcOnly) const
   for (i=0; i<AliPID::kSPECIES; i++) if (prob[i]>max) {k=i; max=prob[i];}
   //
   if (k==0) { // dE/dx "crossing points" in the TPC
+    /*
     Double_t p=GetP();
     if ((p>0.38)&&(p<0.48))
       if (prob[0]<prob[3]*10.) return AliPID::kKaon;
     if ((p>0.75)&&(p<0.85))
       if (prob[0]<prob[4]*10.) return AliPID::kProton;
+    */
     return AliPID::kElectron;
   }
   if (k==1) return AliPID::kMuon; 
   if (k==2||k==-1) return AliPID::kPion;
   if (k==3) return AliPID::kKaon;
   if (k==4) return AliPID::kProton;
-  AliWarning("Undefined PID !");
-  return AliPID::kPion;
+  //  AliWarning("Undefined PID !");
+  return GetPIDForTracking();
 }
 
 //_______________________________________________________________________
@@ -1807,6 +1891,7 @@ void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
 //_______________________________________________________________________
 void AliESDtrack::SetITSpid(const Double_t *p) {
   // Sets values for the probability of each particle type (in ITS)
+  if (!fITSr) fITSr = new Double32_t[AliPID::kSPECIESC];
   SetPIDValues(fITSr,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kITSpid);
 }
@@ -1814,7 +1899,7 @@ void AliESDtrack::SetITSpid(const Double_t *p) {
 //_______________________________________________________________________
 void AliESDtrack::GetITSpid(Double_t *p) const {
   // Gets the probability of each particle type (in ITS)
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fITSr ? fITSr[i] : 0;
 }
 
 //_______________________________________________________________________
@@ -2061,6 +2146,7 @@ Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
 //_______________________________________________________________________
 void AliESDtrack::SetTPCpid(const Double_t *p) {  
   // Sets values for the probability of each particle type (in TPC)
+  if (!fTPCr) fTPCr = new Double32_t[AliPID::kSPECIES];
   SetPIDValues(fTPCr,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kTPCpid);
 }
@@ -2068,7 +2154,7 @@ void AliESDtrack::SetTPCpid(const Double_t *p) {
 //_______________________________________________________________________
 void AliESDtrack::GetTPCpid(Double_t *p) const {
   // Gets the probability of each particle type (in TPC)
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTPCr ? fTPCr[i] : 0;
 }
 
 //_______________________________________________________________________
@@ -2118,6 +2204,7 @@ UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
 //_______________________________________________________________________
 void AliESDtrack::SetTRDpid(const Double_t *p) {  
   // Sets values for the probability of each particle type (in TRD)
+  if (!fTRDr) fTRDr = new Double32_t[AliPID::kSPECIES];
   SetPIDValues(fTRDr,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kTRDpid);
 }
@@ -2125,20 +2212,24 @@ void AliESDtrack::SetTRDpid(const Double_t *p) {
 //_______________________________________________________________________
 void AliESDtrack::GetTRDpid(Double_t *p) const {
   // Gets the probability of each particle type (in TRD)
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTRDr ? fTRDr[i]:0;
 }
 
 //_______________________________________________________________________
 void    AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
 {
   // Sets the probability of particle type iSpecies to p (in TRD)
+  if (!fTRDr) {
+    fTRDr = new Double32_t[AliPID::kSPECIES];
+    for (Int_t i=AliPID::kSPECIES; i--;) fTRDr[i] = 0;
+  }
   fTRDr[iSpecies] = p;
 }
 
 Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
 {
   // Returns the probability of particle type iSpecies (in TRD)
-  return fTRDr[iSpecies];
+  return fTRDr ? fTRDr[iSpecies] : 0;
 }
 
 //____________________________________________________
@@ -2256,6 +2347,7 @@ void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
 //_______________________________________________________________________
 void AliESDtrack::SetTOFpid(const Double_t *p) {  
   // Sets the probability of each particle type (in TOF)
+  if (!fTOFr) fTOFr = new Double32_t[AliPID::kSPECIES];
   SetPIDValues(fTOFr,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kTOFpid);
 }
@@ -2270,7 +2362,7 @@ void AliESDtrack::SetTOFLabel(const Int_t *p) {
 //_______________________________________________________________________
 void AliESDtrack::GetTOFpid(Double_t *p) const {
   // Gets probabilities of each particle type (in TOF)
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTOFr ? fTOFr[i]:0;
 }
 
 //_______________________________________________________________________
@@ -2305,6 +2397,7 @@ void AliESDtrack::SetTOFInfo(Float_t*info) {
 //_______________________________________________________________________
 void AliESDtrack::SetHMPIDpid(const Double_t *p) {  
   // Sets the probability of each particle type (in HMPID)
+  if (!fHMPIDr) fHMPIDr = new Double32_t[AliPID::kSPECIES];
   SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kHMPIDpid);
 }
@@ -2318,7 +2411,7 @@ void  AliESDtrack::SetTPCdEdxInfo(AliTPCdEdxInfo * dEdxInfo){
 //_______________________________________________________________________
 void AliESDtrack::GetHMPIDpid(Double_t *p) const {
   // Gets probabilities of each particle type (in HMPID)
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fHMPIDr ? fHMPIDr[i]:0;
 }
 
 
@@ -2326,6 +2419,7 @@ void AliESDtrack::GetHMPIDpid(Double_t *p) const {
 //_______________________________________________________________________
 void AliESDtrack::SetESDpid(const Double_t *p) {  
   // Sets the probability of each particle type for the ESD track
+  if (!fR) fR = new Double32_t[AliPID::kSPECIES];
   SetPIDValues(fR,p,AliPID::kSPECIES);
   SetStatus(AliESDtrack::kESDpid);
 }
@@ -2333,7 +2427,7 @@ void AliESDtrack::SetESDpid(const Double_t *p) {
 //_______________________________________________________________________
 void AliESDtrack::GetESDpid(Double_t *p) const {
   // Gets probability of each particle type for the ESD track
-  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fR ? fR[i]:0;
 }
 
 //_______________________________________________________________________
@@ -2860,6 +2954,12 @@ Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam  *paramT
   return length;
 }
 
+Double_t AliESDtrack::GetMassForTracking() const
+{
+  double m = AliPID::ParticleMass(fPIDForTracking);
+  return (fPIDForTracking==AliPID::kHe3 || fPIDForTracking==AliPID::kAlpha) ? -m : m;
+}
+
 void    AliESDtrack::SetTOFclusterArray(Int_t ncluster,Int_t *TOFcluster){
   AliInfo("Method has to be implemented!");
 //   fNtofClusters=ncluster;
@@ -3092,3 +3192,7 @@ void AliESDtrack::SortTOFcluster(){
     }
   }
 }
+
+const AliTOFHeader* AliESDtrack::GetTOFHeader() const {
+  return fESDEvent->GetTOFHeader();
+}
index 3446802f458ac2370f0a474c1fb0de9d4656279b..87ee990a1ef218ecc52369ff5ebfb7ff22757052 100644 (file)
 
 class TParticle;
 class AliESDVertex;
-class AliESDEvent;
 class AliKalmanTrack;
 class AliTrackPointArray;
 class TPolyMarker3D;
 class AliDetectorPID;
 class TTreeSRedirector;
+class AliESDEvent;
 
 class AliESDtrack : public AliExternalTrackParam {
 public:
@@ -91,8 +91,9 @@ public:
   Int_t    GetPID(Bool_t tpcOnly=kFALSE)  const;
   Int_t    GetTOFBunchCrossing(Double_t b=0, Bool_t pidTPConly=kTRUE) const;
   Double_t GetMass(Bool_t tpcOnly=kFALSE) const {return AliPID::ParticleMass(GetPID(tpcOnly));}
-  Double_t GetMassForTracking() const {return fMassForTracking;}
-  void     SetMassForTracking(Double_t m) {fMassForTracking = m;}
+  Double_t GetMassForTracking() const;
+  void     SetPIDForTracking(Int_t pid) {fPIDForTracking = pid;}
+  Int_t    GetPIDForTracking() const    {return fPIDForTracking;}
   Double_t M() const;
   Double_t E() const;
   Double_t Y() const;
@@ -418,6 +419,7 @@ public:
   }
   virtual void Print(Option_t * opt) const ;
   const AliESDEvent* GetESDEvent() const {return fESDEvent;}
+  const AliTOFHeader* GetTOFHeader() const;
   void         SetESDEvent(const AliESDEvent* evt) {fESDEvent = evt;}
 
   // Trasient PID object, is owned by the track
@@ -472,13 +474,12 @@ protected:
   Int_t     fKinkIndexes[3]; // array of indexes of posible kink candidates 
   Int_t     fV0Indexes[3];   // array of indexes of posible kink candidates 
 
-  Double32_t   fR[AliPID::kSPECIES]; //! [0.,0.,8] combined "detector response probability"
-  Double32_t   fITSr[AliPID::kSPECIES]; //! [0.,0.,8] "detector response probabilities" (for the PID)
-  Double32_t   fTPCr[AliPID::kSPECIES]; //! [0.,0.,8] "detector response probabilities" (for the PID)
-  Double32_t   fTRDr[AliPID::kSPECIES]; //! [0.,0.,8] "detector response probabilities" (for the PID)  
-  Double32_t   fTOFr[AliPID::kSPECIES]; //! [0.,0.,8] "detector response probabilities" (for the PID)
-  Double32_t   fHMPIDr[AliPID::kSPECIES];//! [0.,0.,8] "detector response probabilities" (for the PID)
-  Double32_t   fMassForTracking;         // mass used for tracking
+  Double32_t   *fR; //! [0.,0.,8] combined "detector response probability"
+  Double32_t   *fITSr; //! [0.,0.,8] "detector response probabilities" (for the PID)
+  Double32_t   *fTPCr; //! [0.,0.,8] "detector response probabilities" (for the PID)
+  Double32_t   *fTRDr; //! [0.,0.,8] "detector response probabilities" (for the PID)  
+  Double32_t   *fTOFr; //! [0.,0.,8] "detector response probabilities" (for the PID)
+  Double32_t   *fHMPIDr; //! [0.,0.,8] "detector response probabilities" (for the PID)
 
   Double32_t fHMPIDtrkTheta;//[-2*pi,2*pi,16] theta of the track extrapolated to the HMPID, LORS
   // how much of this is needed?
@@ -560,6 +561,8 @@ protected:
 
   Char_t  fTRDTimBin[kTRDnPlanes];   // Time bin of Max cluster from all six planes
   Char_t  fVertexID; // ID of the primary vertex this track belongs to
+  Char_t  fPIDForTracking;           // mass used for tracking
+
   mutable const AliESDEvent*   fESDEvent; //!Pointer back to event to which the track belongs
   
   mutable Float_t fCacheNCrossedRows; //! Cache for the number of crossed rows
@@ -582,7 +585,7 @@ protected:
   static bool fgkOnlineMode; //! indicate the online mode to skip some of the functionality
 
   AliESDtrack & operator=(const AliESDtrack & );
-  ClassDef(AliESDtrack,70)  //ESDtrack 
+  ClassDef(AliESDtrack,71)  //ESDtrack 
 };
 
 
index 1f502d84463f052a2063c0ddb1c8284033506bde..a9d31377ce5b667e709a033bbddf728879506be9 100644 (file)
 #pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Short_t fTOFdeltaBC"  version="[-68]" target="fTOFdeltaBC" targetType="Short_t" code="{fTOFdeltaBC=onfile.fTOFdeltaBC;}"
 #pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Short_t fTOFl0l1"  version="[-68]" target="fTOFl0l1" targetType="Short_t" code="{fTOFl0l1=onfile.fTOFl0l1;}"
 
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fR[5]"  version="[-71]" \
+ target="fR" targetType="Double32_t*" include="AliPID.h" \
+   code="{fR = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fR[isp]=onfile.fR[isp];}"
+
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fTPCr[5]"  version="[-71]" \
+   target="fTPCr" targetType="Double32_t*" include="AliPID.h" \
+   code="{fTPCr = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fTPCr[isp]=onfile.fTPCr[isp];}"
+
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fITSr[5]"  version="[-71]" \
+   target="fITSr" targetType="Double32_t*" include="AliPID.h" \
+   code="{fITSr = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fITSr[isp]=onfile.fITSr[isp];}"
+
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fTRDr[5]"  version="[-71]" \
+   target="fTRDr" targetType="Double32_t*" include="AliPID.h" \
+   code="{fTRDr = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fTRDr[isp]=onfile.fTRDr[isp];}"
+
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fTOFr[5]"  version="[-71]" \
+   target="fTOFr" targetType="Double32_t*" include="AliPID.h" \
+   code="{fTOFr = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fTOFr[isp]=onfile.fTOFr[isp];}"
+
+#pragma read sourceClass="AliESDtrack" targetClass="AliESDtrack" source="Double32_t fHMPIDr[5]"  version="[-71]" \
+   target="fHMPIDr" targetType="Double32_t*" include="AliPID.h" \
+   code="{fHMPIDr = new Double32_t[AliPID::kSPECIES];for(Int_t isp=5;isp--;) fHMPIDr[isp]=onfile.fHMPIDr[isp];}"
 
 #pragma link C++ class  AliESDtrack+;
 #pragma read sourceClass="AliESDfriendTrack" targetClass="AliESDfriendTrack" source="Int_t fITSindex" version="[-3]" \
index 761fb8d9788257b866841b633222980d4a37a001..9fa2be88448c5f5753058ebd98013a1080f74aed 100644 (file)
@@ -39,6 +39,7 @@
 
 // initialize static members
 TH2F* AliPIDCombined::fDefaultPriorsTPC[]={0x0};
+Float_t AliPIDCombined::fTOFmismProb = 0;
 
 ClassImp(AliPIDCombined);
 
@@ -109,9 +110,12 @@ UInt_t AliPIDCombined::ComputeProbabilities(const AliVTrack *track, const AliPID
 
   // (1) Get raw probabilities of selected detectors and combine
   UInt_t usedMask=0;             // detectors actually used for track
+  fTOFmismProb = 0; // reset TOF mismatch weights
+
   AliPIDResponse::EDetPidStatus status=AliPIDResponse::kDetNoSignal;
   Double_t p[fSelectedSpecies];  // combined probabilities of selected detectors
-  for (Int_t i=0;i<fSelectedSpecies;i++) p[i]=1.; // no decision
+  Double_t pMismTOF[fSelectedSpecies];  // combined TOF mismatch probabilities using selected detectors
+  for (Int_t i=0;i<fSelectedSpecies;i++){ p[i]=1.;pMismTOF[i]=1.;} // no decision
   for (Int_t ibit = 0; ibit < 7 ; ibit++) {
     AliPIDResponse::EDetCode detBit = (AliPIDResponse::EDetCode)(1<<ibit);
     if (fDetectorMask & detBit) {          // getting probabilities for requested detectors only
@@ -120,7 +124,8 @@ UInt_t AliPIDCombined::ComputeProbabilities(const AliVTrack *track, const AliPID
       if (status == AliPIDResponse::kDetPidOk) {
        if (fRejectMismatchMask & detBit) {         // mismatch check (currently just for TOF)
          if (detBit == AliPIDResponse::kDetTOF) {
-           Float_t probMis = response->GetTOFMismatchProbability(track);
+           fTOFmismProb = response->GetTOFMismatchProbability(); // mismatch weights computed with TOF probs (no arguments)
+           Float_t probMis = response->GetTOFMismatchProbability(track); // mismatch compatibility TPC-TOF cut
            SetCombinedStatus(status,&usedMask,detBit,detProb,probMis);
          } else {
            SetCombinedStatus(status,&usedMask,detBit);
@@ -128,7 +133,11 @@ UInt_t AliPIDCombined::ComputeProbabilities(const AliVTrack *track, const AliPID
        } else {
          SetCombinedStatus(status,&usedMask,detBit);
        }
-       for (Int_t i=0;i<fSelectedSpecies;i++) p[i] *= detProb[i];
+       for (Int_t i=0;i<fSelectedSpecies;i++){
+         p[i] *= detProb[i];
+         if(detBit == AliPIDResponse::kDetTOF) pMismTOF[i] *= fTOFmismProb;
+         else pMismTOF[i] *= detProb[i];
+       }
       }
     }
   }
@@ -251,6 +260,11 @@ UInt_t AliPIDCombined::ComputeProbabilities(const AliVTrack *track, const AliPID
 
   // (3) Compute Bayes probabilities
   ComputeBayesProbabilities(bayesProbabilities,p,priors);
+
+  // compute TOF probability contribution from mismatch
+  fTOFmismProb = 0; 
+  for (Int_t i=0;i<fSelectedSpecies;i++) fTOFmismProb += pMismTOF[i];
+
   return usedMask;
 }
 
@@ -350,7 +364,7 @@ void AliPIDCombined::GetPriors(const AliVTrack *track,Double_t* p,const AliPIDRe
        return;
 }
 //-------------------------------------------------------------------------------------------------    
-void AliPIDCombined::ComputeBayesProbabilities(Double_t* probabilities, const Double_t* probDensity, const Double_t* prior) const {
+void AliPIDCombined::ComputeBayesProbabilities(Double_t* probabilities, const Double_t* probDensity, const Double_t* prior, Double_t* probDensityMism) const {
 
 
   //
@@ -368,6 +382,7 @@ void AliPIDCombined::ComputeBayesProbabilities(Double_t* probabilities, const Do
   }
   for (Int_t i = 0; i < fSelectedSpecies; i++) {
     probabilities[i] = probDensity[i] * prior[i] / sum;
+    if(probDensityMism) probDensityMism[i] *= prior[i] / sum;
   }
 
 
index d1f9043cd3ec2e6726fd57a065e77c9696dbac14..62e8de8f640bd79e88bb20326887c78ac143852e 100644 (file)
@@ -47,9 +47,11 @@ public:
   void SetSelectedSpecies(Int_t selectedSpecies) {fSelectedSpecies = selectedSpecies;}
   Int_t GetSelectedSpecies() const {return fSelectedSpecies;}
 
+  static Float_t GetTOFmismatchProb() {return fTOFmismProb;}
+
 protected:
   void GetPriors(const AliVTrack *track,Double_t* priors,Float_t centrality=-1) const;
-  void ComputeBayesProbabilities(Double_t* bayesProbabilities,const Double_t* probDensity, const Double_t* priors) const;
+  void ComputeBayesProbabilities(Double_t* bayesProbabilities,const Double_t* probDensity, const Double_t* priors, Double_t* probDensityMism=NULL) const;
   void SetCombinedStatus(const AliPIDResponse::EDetPidStatus status,UInt_t *mask, const AliPIDResponse::EDetCode bit) const;
   void SetCombinedStatus(const AliPIDResponse::EDetPidStatus status,UInt_t *mask, const AliPIDResponse::EDetCode bit, Double_t* p,const Float_t probMis) const;
 
@@ -64,6 +66,7 @@ private:
   TH1F *fPriorsDistributions[AliPID::kSPECIESC]; // priors
   Bool_t fUseDefaultTPCPriors; // switch to use Defaul TPC Priors
   static TH2F *fDefaultPriorsTPC[AliPID::kSPECIES]; // Default priors for TPC tracks
+  static Float_t fTOFmismProb; //TOF mismatch probability
 
   ClassDef(AliPIDCombined, 3);   // Combined PID using priors
 };
index 0cdf7372a5b8ccdff3f466f219f02e2834b30691..38b3e17f7dbed3aa4ee02899de632411b1f136a5 100644 (file)
@@ -52,6 +52,8 @@
 
 ClassImp(AliPIDResponse);
 
+Float_t AliPIDResponse::fgTOFmismatchProb = 0.0;
+
 AliPIDResponse::AliPIDResponse(Bool_t isMC/*=kFALSE*/) :
 TNamed("PIDResponse","PIDResponse"),
 fITSResponse(isMC),
@@ -92,7 +94,8 @@ fTOFPIDParams(NULL),
 fHMPIDPIDParams(NULL),
 fEMCALPIDParams(NULL),
 fCurrentEvent(NULL),
-fCurrCentrality(0.0)
+fCurrCentrality(0.0),
+fBeamTypeNum(kPP)
 {
   //
   // default ctor
@@ -155,7 +158,8 @@ fTOFPIDParams(NULL),
 fHMPIDPIDParams(NULL),
 fEMCALPIDParams(NULL),
 fCurrentEvent(NULL),
-fCurrCentrality(0.0)
+fCurrCentrality(0.0),
+fBeamTypeNum(kPP)
 {
   //
   // copy ctor
@@ -186,6 +190,7 @@ AliPIDResponse& AliPIDResponse::operator=(const AliPIDResponse &other)
     fIsMC=other.fIsMC;
     fCachePID=other.fCachePID;
     fBeamType="PP";
+    fBeamTypeNum=kPP;
     fLHCperiod="";
     fMCperiodTPC="";
     fMCperiodUser=other.fMCperiodUser;
@@ -654,6 +659,7 @@ void AliPIDResponse::SetRecoInfo()
   fBeamType="";
     
   fBeamType="PP";
+  fBeamTypeNum=kPP;
 
   Bool_t hasProdInfo=(fCurrentFile.BeginsWith("LHC"));
   
@@ -675,6 +681,7 @@ void AliPIDResponse::SetRecoInfo()
     // exception for 13d2 and later
     if (fCurrentAliRootRev >= 62714) fMCperiodTPC="LHC13D2";
     fBeamType="PBPB";
+    fBeamTypeNum=kPBPB;
   }
   else if (fRun>=139847&&fRun<=146974) { fLHCperiod="LHC11A"; fMCperiodTPC="LHC10F6A"; }
   //TODO: periods 11B (146975-150721), 11C (150722-155837) are not yet treated assume 11d for the moment
@@ -688,25 +695,27 @@ void AliPIDResponse::SetRecoInfo()
     fLHCperiod="LHC11H";
     fMCperiodTPC="LHC11A10";
     fBeamType="PBPB";
+    fBeamTypeNum=kPBPB;
     if (reg12a17.MatchB(fCurrentFile)) fMCperiodTPC="LHC12A17";
   }
-  if (fRun>=170719 && fRun<=177311) { fLHCperiod="LHC12A"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
+  if (fRun>=170719 && fRun<=177311) { fLHCperiod="LHC12A"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
   // for the moment use LHC12b parameters up to LHC12d
-  if (fRun>=177312 /*&& fRun<=179356*/) { fLHCperiod="LHC12B"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-//   if (fRun>=179357 && fRun<=183173) { fLHCperiod="LHC12C"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-//   if (fRun>=183174 && fRun<=186345) { fLHCperiod="LHC12D"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-//   if (fRun>=186346 && fRun<=186635) { fLHCperiod="LHC12E"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-
-//   if (fRun>=186636 && fRun<=188166) { fLHCperiod="LHC12F"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-//   if (fRun >= 188167 && fRun <= 188355 ) { fLHCperiod="LHC12G"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
-//   if (fRun >= 188356 && fRun <= 188503 ) { fLHCperiod="LHC12G"; fBeamType="PPB"; /*fMCperiodTPC="";*/ }
+  if (fRun>=177312 /*&& fRun<=179356*/) { fLHCperiod="LHC12B"; fBeamType="PP";fBeamTypeNum=kPP; /*fMCperiodTPC="";*/ }
+//   if (fRun>=179357 && fRun<=183173) { fLHCperiod="LHC12C"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
+//   if (fRun>=183174 && fRun<=186345) { fLHCperiod="LHC12D"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
+//   if (fRun>=186346 && fRun<=186635) { fLHCperiod="LHC12E"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
+
+//   if (fRun>=186636 && fRun<=188166) { fLHCperiod="LHC12F"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
+//   if (fRun >= 188167 && fRun <= 188355 ) { fLHCperiod="LHC12G"; fBeamType="PP"; fBeamTypeNum=kPP;/*fMCperiodTPC="";*/ }
+//   if (fRun >= 188356 && fRun <= 188503 ) { fLHCperiod="LHC12G"; fBeamType="PPB"; fBeamTypeNum=kPPB;/*fMCperiodTPC="";*/ }
 // for the moment use 12g parametrisation for all full gain runs (LHC12e+)
-  if (fRun >= 186346 && fRun < 194480) { fLHCperiod="LHC12G"; fBeamType="PPB"; fMCperiodTPC="LHC12G"; }
+  if (fRun >= 186346 && fRun < 194480) { fLHCperiod="LHC12G"; fBeamType="PPB";fBeamTypeNum=kPPB; fMCperiodTPC="LHC12G"; }
 
   // New parametrisation for 2013 pPb runs
   if (fRun >= 194480) { 
     fLHCperiod="LHC13B"; 
     fBeamType="PPB";
+    fBeamTypeNum=kPPB;
     fMCperiodTPC="LHC12G";
   
     if (fCurrentAliRootRev >= 61605)
@@ -721,7 +730,7 @@ void AliPIDResponse::SetRecoInfo()
   }
 
   //exception new pp MC productions from 2011 (11a periods have 10f6a splines!)
-  if (fBeamType=="PP" && reg.MatchB(fCurrentFile) && !fCurrentFile.Contains("LHC11a")) { fMCperiodTPC="LHC11B2"; fBeamType="PP"; }
+  if (fBeamType=="PP" && reg.MatchB(fCurrentFile) && !fCurrentFile.Contains("LHC11a")) { fMCperiodTPC="LHC11B2"; fBeamType="PP";fBeamTypeNum=kPP; }
   // exception for 11f1
   if (fCurrentFile.Contains("LHC11f1")) fMCperiodTPC="LHC11F1";
   // exception for 12f1a, 12f1b and 12i3
@@ -2277,7 +2286,32 @@ AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeTOFProbability  (const A
   // Compute PID probabilities for TOF
   //
 
-  Double_t mismprob = 1E-8;
+  fgTOFmismatchProb = 1E-8;
+
+  // centrality --> fCurrCentrality
+  // Beam type --> fBeamTypeNum
+  // N TOF cluster --> TOF header --> to get the TOF header we need to add a virtual method in AliVTrack extended to ESD and AOD tracks
+  // isMC --> fIsMC
+
+  Int_t nTOFcluster = 0;
+  if(track->GetTOFHeader() && track->GetTOFHeader()->GetTriggerMask()){ // N TOF clusters available
+    nTOFcluster = track->GetTOFHeader()->GetNumberOfTOFclusters();
+    if(fIsMC) nTOFcluster *= 1.5; // +50% in MC
+  }
+  else{
+    switch(fBeamTypeNum){
+    case kPP: // pp 7 TeV
+      nTOFcluster = 50;
+      break;
+    case kPPB: // pPb 5.05 ATeV
+      nTOFcluster = 50 + (100-fCurrCentrality)*50;
+      break;
+    case kPBPB: // PbPb 2.76 ATeV
+      nTOFcluster = 50 + (100-fCurrCentrality)*150;
+      break;
+    }
+  }
+
   //fTOFResponse.GetMismatchProbability(track->GetTOFsignal(),track->Eta()) * 0.01; // for future implementation of mismatch (i.e. 1% mismatch that should be extended for PbPb, pPb)
 
   // set flat distribution (no decision)
@@ -2300,7 +2334,7 @@ AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeTOFProbability  (const A
     else
       p[j] = TMath::Exp(-(nsigmas - fTOFtail*0.5)*fTOFtail)/sig;
     
-    p[j] += mismprob;
+    p[j] += fgTOFmismatchProb;
   }
   
   return kDetPidOk;
@@ -2462,6 +2496,8 @@ Float_t AliPIDResponse::GetTOFMismatchProbability(const AliVTrack *track) const
   // compute mismatch probability cross-checking at 5 sigmas with TPC
   // currently just implemented as a 5 sigma compatibility cut
 
+  if(!track) return fgTOFmismatchProb;
+
   // check pid status
   const EDetPidStatus tofStatus=GetTOFPIDStatus(track);
   if (tofStatus!=kDetPidOk) return 0.;
index 33270a98e0e4e1cd7fadd4d0db16302c28b63cf4..ff2438675b877b2651f7d10d6546311e4d269836 100644 (file)
@@ -60,6 +60,12 @@ public:
     kDetPHOS = 0x40
   };
 
+  enum EBeamType {
+    kPP = 0,
+    kPPB,
+    kPBPB
+  };
   enum EStartTimeType_t {kFILL_T0,kTOF_T0, kT0_T0, kBest_T0};
 
   enum ITSPIDmethod { kITSTruncMean, kITSLikelihood };
@@ -119,8 +125,8 @@ public:
   EDetPidStatus CheckPIDStatus(EDetector detCode, const AliVTrack *track)  const;
 
   AliTOFPIDParams *GetTOFPIDParams() const {return fTOFPIDParams;}
-  Float_t GetTOFMismatchProbability(const AliVTrack *track) const;
-  
+  Float_t GetTOFMismatchProbability(const AliVTrack *track = NULL) const; // if empty argument return the value stored during TOF probability computation
+
   void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
   
   void SetOADBPath(const char* path) {fOADBPath=path;}
@@ -198,6 +204,8 @@ protected:
 
 
 private:
+  static Float_t fgTOFmismatchProb;    // TOF mismatch probability (Bayesian)
+
   Bool_t fIsMC;                        //  If we run on MC data
   Bool_t fCachePID;
 
@@ -236,7 +244,8 @@ private:
   AliVEvent *fCurrentEvent;            //! event currently being processed
 
   Float_t fCurrCentrality;             //! current centrality
-  
+
+  EBeamType fBeamTypeNum;              //! beam type enum 
   
   void ExecNewRun();
   
@@ -317,7 +326,7 @@ private:
   EDetPidStatus GetPHOSPIDStatus(const AliVTrack *track) const;
   EDetPidStatus GetEMCALPIDStatus(const AliVTrack *track) const;
 
-  ClassDef(AliPIDResponse, 12);  //PID response handling
+  ClassDef(AliPIDResponse, 13);  //PID response handling
 };
 
 #endif
index f54fcbb346a1b538f7548f6287532bab132a6b2e..072095c19911ee1661b42679523dc19a23c8acca 100644 (file)
@@ -17,6 +17,7 @@ class AliVVertex;
 class AliExternalTrackParam;
 class AliTPCdEdxInfo;
 class AliDetectorPID;
+class AliTOFHeader;
  
 class AliVTrack: public AliVParticle {
 
@@ -99,6 +100,8 @@ public:
   virtual Int_t GetPHOScluster()      const {return -1;}
   virtual void SetPHOScluster(Int_t)        {;}
   virtual Bool_t IsPHOS()             const {return kFALSE;}
+  virtual void   SetPIDForTracking(Int_t ) {}
+  virtual Int_t  GetPIDForTracking() const {return -999;}
   
   //pid info
   virtual void     SetStatus(ULong_t /*flags*/) {;}
@@ -142,6 +145,7 @@ public:
   virtual Bool_t   GetPxPyPz(Double_t */*p*/) const { return kFALSE; }
   virtual void     SetID(Short_t /*id*/) {;}
   virtual Int_t    GetTOFBunchCrossing(Double_t = 0, Bool_t = kFALSE) const { return kTOFBCNA;}
+  virtual const AliTOFHeader *GetTOFHeader() const {return NULL;};
 
   ClassDef(AliVTrack,1)  // base class for tracks
 };
index 07491060406095375b38bb8ffd37b41a23373cdb..4b853c9272ae030c2fcda1545199b99aaed176af 100644 (file)
@@ -99,6 +99,10 @@ AliTOFtracker::AliTOFtracker():
   // Getting the geometry
   fGeom = new AliTOFGeometry();
 
+  for(Int_t i=0; i< 20000;i++){
+    fClusterESD[i] = NULL;
+  }
+
   InitCheckHists();
 
 }
index a81688eac14322d59b7964348e0f76fb7a6fc661..18337b67319adbb4519e0044aa5b02b73c74b23d 100644 (file)
@@ -56,7 +56,6 @@
 
 using std::ifstream;
 using std::ios_base;
-
 extern "C"{
   Gas gaspar_;
 };
@@ -83,7 +82,6 @@ AliTPCv2::AliTPCv2(const char *name, const char *title) :
   gaspar_.eexpo=fTPCParam->GetExp();
 
 
-
 }
  
 //_____________________________________________________________________________
@@ -2146,8 +2144,9 @@ void AliTPCv2::StepManager()
   //const Float_t kprim = 14.35; // number of primary collisions per 1 cm
   //const Float_t kpoti = 20.77e-9; // first ionization potential for Ne/CO2
   //const Float_t kwIon = 35.97e-9; // energy for the ion-electron pair creation 
+  const Float_t kScalewIonG4 = 0.85; // scale factor to tune kwIon for Geant4 
+  const Float_t kFanoFactorG4 = 0.7; // parameter for smearing the number of ionizations (nel) using Geant4
   const Int_t   kMaxDistRef =15;     // maximal difference between 2 stored references 
-
   Float_t prim = fTPCParam->GetNprim();
   Float_t poti = fTPCParam->GetFpot();
   Float_t wIon = fTPCParam->GetWmean();
@@ -2277,6 +2276,8 @@ void AliTPCv2::StepManager()
       nel = (Int_t)(((gMC->Edep())-poti)/wIon) + 1;
     }
     else {
+      
+      /*
       static Double_t deForNextStep = 0.;
       // Geant4 (the meaning of Edep as in Geant3) - wrong
       //nel = (Int_t)(((gMC->Edep())-poti)/wIon) + 1;
@@ -2285,6 +2286,11 @@ void AliTPCv2::StepManager()
       Double_t eAvailable = gMC->Edep() + deForNextStep;
       nel = (Int_t)(eAvailable/wIon);
       deForNextStep = eAvailable - nel*wIon;
+      */
+
+      //new Geant4-approach
+      Double_t meanIon = gMC->Edep()/(wIon*kScalewIonG4);
+      nel = (Int_t) ( kFanoFactorG4*AliMathBase::Gamma(meanIon/kFanoFactorG4)); // smear nel using gamma distr w mean = meanIon and variance = meanIon/kFanoFactorG4
     }
     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
     //