Update for PbPb (Chiara)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 27 Feb 2011 22:22:47 +0000 (22:22 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 27 Feb 2011 22:22:47 +0000 (22:22 +0000)
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.h
PWG3/vertexingHF/macros/AddTaskD0Mass.C

index d58f4f3..4e9966d 100644 (file)
@@ -72,7 +72,8 @@ fLsNormalization(1.),
 fFillOnlyD0D0bar(0),
 fDaughterTracks(),
 fIsSelectedCandidate(0),
-fFillVarHists(kTRUE)
+fFillVarHists(kTRUE),
+fSys(0)
 {
   // Default constructor
 }
@@ -94,21 +95,19 @@ fLsNormalization(1.),
 fFillOnlyD0D0bar(0),
 fDaughterTracks(),
 fIsSelectedCandidate(0),
-fFillVarHists(kTRUE)
+fFillVarHists(kTRUE),
+fSys(0)
 {
   // Default constructor
 
   fNPtBins=cuts->GetNPtBins();
-  // fTotPosPairs=new Int_t[fNPtBins];
-  // fTotNegPairs=new Int_t[fNPtBins];
-  // for(Int_t i=0;i<fNPtBins;i++) {fTotPosPairs[i]=0; fTotNegPairs[i]=0;}
     
   fCuts=cuts;
 
   // Output slot #1 writes into a TList container (mass with cuts)
   DefineOutput(1,TList::Class());  //My private output
   // Output slot #2 writes into a TList container (distributions)
-  DefineOutput(2,TList::Class());  //My private output
+  if(fFillVarHists) DefineOutput(2,TList::Class());  //My private output
   // Output slot #3 writes into a TH1F container (number of events)
   DefineOutput(3,TH1F::Class());  //My private output
   // Output slot #4 writes into a TList container (cuts)
@@ -120,7 +119,7 @@ fFillVarHists(kTRUE)
 //________________________________________________________________________
 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
 {
-   if (fOutputMass) {
+  if (fOutputMass) {
     delete fOutputMass;
     fOutputMass = 0;
   }
@@ -198,273 +197,217 @@ void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
     nameMassNocutsB+=i;
 
     //histograms of cut variable distributions
+    if(fFillVarHists){
+      //  pT
+      namedistr="hptpiS_";
+      namedistr+=i;
+      TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
 
-    //  pT
-    namedistr="hptpiS_";
-    namedistr+=i;
-    TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
-
-    namedistr="hptKS_";
-    namedistr+=i;
-    TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
+      namedistr="hptKS_";
+      namedistr+=i;
+      TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
 
-    namedistr="hptB_";
-    namedistr+=i;
-    TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
+      namedistr="hptB_";
+      namedistr+=i;
+      TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
 
-    //  pT no mass cut
-    // namedistr="hptpiSnoMcut_";
-    // namedistr+=i;
-    // TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
 
-    // namedistr="hptKSnoMcut_";
-    // namedistr+=i;
-    // TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
+      //  dca
+      namedistr="hdcaS_";
+      namedistr+=i;
+      TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
+      namedistr="hdcaB_";
+      namedistr+=i;
+      TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
 
-    // namedistr="hptB1prongnoMcut_";
-    // namedistr+=i;
-    // TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
+      //  costhetastar
+      namedistr="hcosthetastarS_";
+      namedistr+=i;
+      TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
+      namedistr="hcosthetastarB_";
+      namedistr+=i;
+      TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
 
-    // namedistr="hptB2prongsnoMcut_";
-    // namedistr+=i;
-    // TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
-    
-    // fDistr->Add(hptpiSnoMcut);
-    // fDistr->Add(hptKSnoMcut);
-    // fDistr->Add(hptB1pnoMcut);
-    // fDistr->Add(hptB2pnoMcut);
-
-
-    //  dca
-    namedistr="hdcaS_";
-    namedistr+=i;
-    TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
-    namedistr="hdcaB_";
-    namedistr+=i;
-    TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
-
-    //  costhetastar
-    namedistr="hcosthetastarS_";
-    namedistr+=i;
-    TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
-    namedistr="hcosthetastarB_";
-    namedistr+=i;
-    TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
-
-    // impact parameter
-    namedistr="hd0piS_";
-    namedistr+=i;
-    TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
-
-    namedistr="hd0KS_";
-    namedistr+=i;
-    TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
-
-    namedistr="hd0B_";
-    namedistr+=i;
-    TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
-
-    namedistr="hd0p0B_";
-    namedistr+=i;
-    TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
-
-    namedistr="hd0p1B_";
-    namedistr+=i;
-    TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
-
-    namedistr="hd0moresB_";
-    namedistr+=i;
-    TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
-
-    namedistr="hd0d0moresB_";
-    namedistr+=i;
-    TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
-
-    namedistr="hd0d0S_";
-    namedistr+=i;
-    TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
-    namedistr="hd0d0B_";
-    namedistr+=i;
-    TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
-
-    //decay lenght
-    namedistr="hdeclS_";
-    namedistr+=i;
-    TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length distribution;Decay Length [cm]",200,0,0.15);
-
-    namedistr="hdeclB_";
-    namedistr+=i;
-    TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length distribution;Decay Length [cm]",200,0,0.15);
-
-    namedistr="hnormdeclS_";
-    namedistr+=i;
-    TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;Decay Length/Err ",200,0,6.);
-
-    namedistr="hnormdeclB_";
-    namedistr+=i;
-    TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;Decay Length/Err ",200,0,6.);
-
-   //  costhetapoint
-    namedistr="hcosthetapointS_";
-    namedistr+=i;
-    TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
-    namedistr="hcosthetapointB_";
-    namedistr+=i;
-    TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
-
-    namedistr="hcosthetapointmoresB_";
-    namedistr+=i;
-    TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
-
-   //  costhetapoint vs d0 or d0d0
-    namedistr="hcosthpointd0S_";
-    namedistr+=i;
-    TH2F *hcosthpointd0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
-
-    namedistr="hcosthpointd0B_";
-    namedistr+=i;
-    TH2F *hcosthpointd0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
-
-    namedistr="hcosthpointd0d0S_";
-    namedistr+=i;
-    TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
-    namedistr="hcosthpointd0d0B_";
-    namedistr+=i;
-    TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
-
-    fDistr->Add(hptpiS);
-    fDistr->Add(hptKS);
-    fDistr->Add(hptB);
-
-    fDistr->Add(hdcaS);
-    fDistr->Add(hdcaB);
-
-    fDistr->Add(hd0piS);
-    fDistr->Add(hd0KS);
-    fDistr->Add(hd0B);
-    fDistr->Add(hd0p0B);
-    fDistr->Add(hd0p1B);
-    fDistr->Add(hd0moresB);
-
-    fDistr->Add(hd0d0S);
-    fDistr->Add(hd0d0B);
-    fDistr->Add(hd0d0moresB);
-
-    fDistr->Add(hcosthetastarS);
-    fDistr->Add(hcosthetastarB);
-
-    fDistr->Add(hcosthetapointS);
-    fDistr->Add(hcosthetapointB);
-    fDistr->Add(hcosthetapointmoresB);
-
-    fDistr->Add(hdeclengthS);
-    fDistr->Add(hdeclengthB);
-
-    fDistr->Add(hnormdeclengthS);
-    fDistr->Add(hnormdeclengthB);
-
-    fDistr->Add(hcosthpointd0S);
-    fDistr->Add(hcosthpointd0B);
-
-    fDistr->Add(hcosthpointd0d0S);
-    fDistr->Add(hcosthpointd0d0B);
-
-    //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
-
-    if(fCuts->GetIsPrimaryWithoutDaughters()){
-      namedistr="hd0vmoresB_";
+      // impact parameter
+      namedistr="hd0piS_";
       namedistr+=i;
-      TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
+      TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
 
-      namedistr="hd0d0vmoresB_";
+      namedistr="hd0KS_";
       namedistr+=i;
-      TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
+      TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
 
+      namedistr="hd0B_";
+      namedistr+=i;
+      TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
+      namedistr="hd0d0S_";
+      namedistr+=i;
+      TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
+      namedistr="hd0d0B_";
+      namedistr+=i;
+      TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
 
-      namedistr="hd0vpiS_";
+      //decay lenght
+      namedistr="hdeclS_";
       namedistr+=i;
-      TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
+      TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm]",200,0,0.025);
 
-      namedistr="hd0vKS_";
+      namedistr="hdeclB_";
       namedistr+=i;
-      TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
-      namedistr="hd0vB_";
+      TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm^{2}]",200,0,0.025);
+
+      namedistr="hnormdeclS_";
       namedistr+=i;
-      TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+      TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length^{2} distribution;(Decay Length/Err)^{2} ",200,0,6.);
 
-      namedistr="hd0vp0B_";
+      namedistr="hnormdeclB_";
       namedistr+=i;
-      TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+      TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;(Decay Length/Err)^{2} ",200,0,6.);
 
-      namedistr="hd0vp1B_";
+      //  costhetapoint
+      namedistr="hcosthetapointS_";
+      namedistr+=i;
+      TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
+      namedistr="hcosthetapointB_";
       namedistr+=i;
-      TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+      TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
 
+      namedistr="hdeclxyS_";
+      namedistr+=i;
+      TH1F* hdeclxyS=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
+      namedistr="hnormdeclxyS_";
+      namedistr+=i;
+      TH1F* hnormdeclxyS=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6); //check range 0.15
 
-      namedistr="hd0d0vS_";
+      namedistr="hdeclxyB_";
       namedistr+=i;
-      TH1F *hd0d0vS = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
-      namedistr="hd0d0vB_";
+      TH1F* hdeclxyB=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);//chech range 0.15
+      namedistr="hnormdeclxyB_";
       namedistr+=i;
-      TH1F *hd0d0vB = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
+      TH1F* hnormdeclxyB=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6); //check range 0.15
+
+      fDistr->Add(hptpiS);
+      fDistr->Add(hptKS);
+      fDistr->Add(hptB);
+
+      fDistr->Add(hdcaS);
+      fDistr->Add(hdcaB);
+
+      fDistr->Add(hd0piS);
+      fDistr->Add(hd0KS);
+      fDistr->Add(hd0B);
+
+      fDistr->Add(hd0d0S);
+      fDistr->Add(hd0d0B);
+
+      fDistr->Add(hcosthetastarS);
+      fDistr->Add(hcosthetastarB);
+
+      fDistr->Add(hcosthetapointS);
+      fDistr->Add(hcosthetapointB);
+
+
+      fDistr->Add(hdeclengthS);
+      fDistr->Add(hdeclengthB);
+
+      fDistr->Add(hnormdeclengthS);
+      fDistr->Add(hnormdeclengthB);
+
+      fDistr->Add(hdeclxyS);
+      fDistr->Add(hdeclxyB);
+
+      fDistr->Add(hnormdeclxyS);
+      fDistr->Add(hnormdeclxyB);
+
+      //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
+
+      if(fCuts->GetIsPrimaryWithoutDaughters()){
+       namedistr="hd0vmoresB_";
+       namedistr+=i;
+       TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
+
+       namedistr="hd0d0vmoresB_";
+       namedistr+=i;
+       TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
+
+
+       namedistr="hd0vpiS_";
+       namedistr+=i;
+       TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
+
+       namedistr="hd0vKS_";
+       namedistr+=i;
+       TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
+       namedistr="hd0vB_";
+       namedistr+=i;
+       TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+
+       namedistr="hd0vp0B_";
+       namedistr+=i;
+       TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+
+       namedistr="hd0vp1B_";
+       namedistr+=i;
+       TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
+
+
+       namedistr="hd0d0vS_";
+       namedistr+=i;
+       TH1F *hd0d0vS = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
+       namedistr="hd0d0vB_";
+       namedistr+=i;
+       TH1F *hd0d0vB = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
 
  
-      namedistr="hdeclvS_";
-      namedistr+=i;
-      TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
+       namedistr="hdeclvS_";
+       namedistr+=i;
+       TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
 
-      namedistr="hdeclvB_";
-      namedistr+=i;
-      TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
+       namedistr="hdeclvB_";
+       namedistr+=i;
+       TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
 
-      namedistr="hnormdeclvS_";
-      namedistr+=i;
-      TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
+       namedistr="hnormdeclvS_";
+       namedistr+=i;
+       TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
 
-      namedistr="hnormdeclvB_";
-      namedistr+=i;
-      TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
+       namedistr="hnormdeclvB_";
+       namedistr+=i;
+       TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
 
  
 
-      fDistr->Add(hd0vpiS);
-      fDistr->Add(hd0vKS);
-      fDistr->Add(hd0vB);
-      fDistr->Add(hd0vp0B);
-      fDistr->Add(hd0vp1B);
-      fDistr->Add(hd0vmoresB);
+       fDistr->Add(hd0vpiS);
+       fDistr->Add(hd0vKS);
+       fDistr->Add(hd0vB);
+       fDistr->Add(hd0vp0B);
+       fDistr->Add(hd0vp1B);
+       fDistr->Add(hd0vmoresB);
 
-      fDistr->Add(hd0d0vS);
-      fDistr->Add(hd0d0vB);
-      fDistr->Add(hd0d0vmoresB);
+       fDistr->Add(hd0d0vS);
+       fDistr->Add(hd0d0vB);
+       fDistr->Add(hd0d0vmoresB);
 
-      fDistr->Add(hdeclengthvS);
-      fDistr->Add(hdeclengthvB);
+       fDistr->Add(hdeclengthvS);
+       fDistr->Add(hdeclengthvB);
 
-      fDistr->Add(hnormdeclengthvS);
-      fDistr->Add(hnormdeclengthvB);
-    }
+       fDistr->Add(hnormdeclengthvS);
+       fDistr->Add(hnormdeclengthvB);
+      }
 
-    //histograms of invariant mass distributions
+      TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
+      TH1F *tmpMB=(TH1F*)tmpMS->Clone();
+      tmpMB->SetName(nameMassNocutsB.Data());
+      tmpMS->Sumw2();
+      tmpMB->Sumw2();
 
-    TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
-    TH1F *tmpMl=(TH1F*)tmpMt->Clone();
-    tmpMt->Sumw2();
-    tmpMl->Sumw2();
+      fDistr->Add(tmpMS);
+      fDistr->Add(tmpMB);
+
+    }
+    //histograms of invariant mass distributions
 
-    //to compare with AliAnalysisTaskCharmFraction
-    // TH1F* tmpS27t = new TH1F(nameSgn27.Data(),"D^{0} invariant mass in M(D^{0}) +/- 27 MeV - MC; M [GeV]; Entries",200,1.5648,2.1648);
-    // TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
-    // tmpS27t->Sumw2();
-    // tmpS27l->Sumw2();
-    //distribution w/o cuts
-    //   TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
-    TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
-    TH1F *tmpMB=(TH1F*)tmpMS->Clone();
-    tmpMB->SetName(nameMassNocutsB.Data());
-    tmpMS->Sumw2();
-    tmpMB->Sumw2();
 
     //MC signal and background
     TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
@@ -482,20 +425,114 @@ void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
     TH1F *tmpRl=(TH1F*)tmpRt->Clone();
     tmpRt->Sumw2();
     tmpRl->Sumw2();
-  //  printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
+    //  printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
 
-    fOutputMass->Add(tmpMt);
     fOutputMass->Add(tmpSt);
-    //    fOutputMass->Add(tmpS27t);
     fOutputMass->Add(tmpBt);
     fOutputMass->Add(tmpRt);
 
-    fDistr->Add(tmpMS);
-    fDistr->Add(tmpMB);
+    //mass
+    TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
+    TH1F *tmpMl=(TH1F*)tmpMt->Clone();
+    tmpMt->Sumw2();
+    tmpMl->Sumw2();
+    //distribution w/o cuts large range
+    // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
+
+    fOutputMass->Add(tmpMt);
+
+    if(fSys==0){ //histograms filled only in pp to save time in PbPb
+      if(fFillVarHists){
+       //pT no mass cut
+
+       namedistr="hptpiSnoMcut_";
+       namedistr+=i;
+       TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
+
+       namedistr="hptKSnoMcut_";
+       namedistr+=i;
+       TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
+
+       namedistr="hptB1prongnoMcut_";
+       namedistr+=i;
+       TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
+
+       namedistr="hptB2prongsnoMcut_";
+       namedistr+=i;
+       TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
+    
+       fDistr->Add(hptpiSnoMcut);
+       fDistr->Add(hptKSnoMcut);
+       fDistr->Add(hptB1pnoMcut);
+       fDistr->Add(hptB2pnoMcut);
+
+       //impact parameter of negative/positive track
+       namedistr="hd0p0B_";
+       namedistr+=i;
+       TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
+
+       namedistr="hd0p1B_";
+       namedistr+=i;
+       TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
+
+       //impact parameter corrected for strangeness
+       namedistr="hd0moresB_";
+       namedistr+=i;
+       TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
 
+       namedistr="hd0d0moresB_";
+       namedistr+=i;
+       TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
+
+    
+       namedistr="hcosthetapointmoresB_";
+       namedistr+=i;
+       TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
+
+       //  costhetapoint vs d0 or d0d0
+       namedistr="hcosthpointd0S_";
+       namedistr+=i;
+       TH2F *hcosthpointd0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
+
+       namedistr="hcosthpointd0B_";
+       namedistr+=i;
+       TH2F *hcosthpointd0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
+
+       namedistr="hcosthpointd0d0S_";
+       namedistr+=i;
+       TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
+       namedistr="hcosthpointd0d0B_";
+       namedistr+=i;
+       TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
+
+       fDistr->Add(hd0p0B);
+       fDistr->Add(hd0p1B);
+
+       fDistr->Add(hd0moresB);
+       fDistr->Add(hd0d0moresB);
+       fDistr->Add(hcosthetapointmoresB);
+
+       fDistr->Add(hcosthpointd0S);
+       fDistr->Add(hcosthpointd0B);
+
+       fDistr->Add(hcosthpointd0d0S);
+       fDistr->Add(hcosthpointd0d0B);
+      }
 
+      //to compare with AliAnalysisTaskCharmFraction
+      TH1F* tmpS27t = new TH1F(nameSgn27.Data(),"D^{0} invariant mass in M(D^{0}) +/- 27 MeV - MC; M [GeV]; Entries",200,1.5648,2.1648);
+      TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
+      tmpS27t->Sumw2();
+      tmpS27l->Sumw2();
+      fOutputMass->Add(tmpS27t);
+      fOutputMass->Add(tmpS27l);
+    } //end pp histo
   }
 
+
+  //for Like sign analysis
+
   if(fArray==1){
     namedistr="hpospair";
     TH1F* hpospair=new TH1F(namedistr.Data(),"Number of positive pairs",2*fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
@@ -515,13 +552,17 @@ void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
   fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
   fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
   fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
-  fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
-  fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
-  fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
-  fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
-  fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
-  fNentries->GetXaxis()->SetBinLabel(12,"K");
-  fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
+  if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
+  if(fFillVarHists){
+    fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
+    fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
+    fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
+    fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
+  }
+  if(fReadMC && fSys==0){
+    fNentries->GetXaxis()->SetBinLabel(12,"K");
+    fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
+  }
   fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
   fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
   fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
@@ -530,7 +571,7 @@ void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
 
   // Post the data
   PostData(1,fOutputMass);
-  PostData(2,fDistr);
+  if(fFillVarHists) PostData(2,fDistr);
   PostData(3,fNentries);
   PostData(5,fCounter);  
   return;
@@ -655,11 +696,8 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
   Int_t nSelectedloose=0,nSelectedtight=0;  
   for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
-    //Int_t nPosPairs=0, nNegPairs=0;
-    //cout<<"inside the loop"<<endl;
     AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
 
-
     Bool_t unsetvtx=kFALSE;
     if(!d->GetOwnPrimaryVtx()) {
       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
@@ -670,12 +708,14 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
     if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
       nSelectedloose++;
       nSelectedtight++;      
-      fNentries->Fill(6);       
+      if(fSys==0){
+       if(fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);       
+      }
       Int_t ptbin=fCuts->PtBin(d->Pt());
       if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
       fIsSelectedCandidate=fCuts->IsSelected(d,AliRDHFCuts::kCandidate,aod); //selected
       if(fFillVarHists) {
-       if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
+       //if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
          fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(0),0);
          fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(1),1);
          //check daughters
@@ -685,9 +725,10 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
            fDaughterTracks.Clear();
            continue;
          }
-       }
+         //}
        FillVarHists(aod,d,mcArray,fCuts,fDistr);
       }
+
       FillMassHists(d,mcArray,fCuts,fOutputMass);
     }
   
@@ -698,7 +739,7 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);  
   // Post the data
   PostData(1,fOutputMass);
-  PostData(2,fDistr);
+  if(fFillVarHists) PostData(2,fDistr);
   PostData(3,fNentries);
   PostData(5,fCounter);
   return;
@@ -715,14 +756,15 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
   Int_t lab=-9999;
   if(fReadMC) lab=part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
   //Double_t pt = d->Pt(); //mother pt
-  Int_t isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
+  Int_t isSelectedPID=3;
+  if(!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
   if (isSelectedPID==0)fNentries->Fill(7);
   if (isSelectedPID==1)fNentries->Fill(8);
   if (isSelectedPID==2)fNentries->Fill(9);
   if (isSelectedPID==3)fNentries->Fill(10);
     //fNentries->Fill(8+isSelectedPID);
 
-  if(fCutOnDistr && !fIsSelectedCandidate) return;
+  if(fCutOnDistr && !fIsSelectedCandidate) return; 
   //printf("\nif no cuts or cuts passed\n");
 
 
@@ -773,8 +815,8 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
     d0[0]=dz1[0];
     d0[1]=dz2[0];
 
-    decl[0]=part->DecayLength();
-    decl[1]=part->NormalizedDecayLength();
+    decl[0]=part->DecayLength2();
+    decl[1]=part->NormalizedDecayLength2();
     part->UnsetOwnPrimaryVtx();
   
   }
@@ -782,10 +824,10 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
   Double_t cosThetaStarD0 = 99;
   Double_t cosThetaStarD0bar = 99;
   Double_t cosPointingAngle = 99;
-  Double_t normalizedDecayLength = -1;
-  Double_t decayLength = -1;
+  Double_t normalizedDecayLength2 = -1, normalizedDecayLengthxy=-1;
+  Double_t decayLength2 = -1, decayLengthxy=-1;
   Double_t ptProng[2]={-99,-99};
-
+  Double_t d0Prong[2]={-99,-99};
   
 
     //disable the PID
@@ -813,27 +855,28 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        }
       }
     
-
-      //no mass cut ditributions: ptbis
+      if(fSys==0){
+       //no mass cut ditributions: ptbis
        
-      // fillthispi="hptpiSnoMcut_";
-      // fillthispi+=ptbin;
-
-      // fillthisK="hptKSnoMcut_";
-      // fillthisK+=ptbin;
-
-      // if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
-      //     || (isSelectedPID==1 || isSelectedPID==3)){
-      //       ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[0]);
-      //       ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[1]);
-      // }
-
-      // if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
-      //     || (isSelectedPID==2 || isSelectedPID==3)){
-      //       ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[0]);
-      //       ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[1]);
-      // }
-      
+       fillthispi="hptpiSnoMcut_";
+       fillthispi+=ptbin;
+
+       fillthisK="hptKSnoMcut_";
+       fillthisK+=ptbin;
+
+       if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
+           || (isSelectedPID==1 || isSelectedPID==3)){
+         ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(0));
+         ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(1));
+       }
+
+       if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
+           || (isSelectedPID==2 || isSelectedPID==3)){
+         ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(0));
+         ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(1));
+       }
+      }
+
       //no mass cut ditributions: mass
       fillthis="hMassS_";
       fillthis+=ptbin;
@@ -853,10 +896,14 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        cosThetaStarD0 = part->CosThetaStarD0();
        cosThetaStarD0bar = part->CosThetaStarD0bar();
        cosPointingAngle = part->CosPointingAngle();
-       normalizedDecayLength = part->NormalizedDecayLength();
-       decayLength = part->DecayLength();
+       normalizedDecayLength2 = part->NormalizedDecayLength2();
+       decayLength2 = part->DecayLength2();
+       decayLengthxy = part->DecayLengthXY();
+       normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
+
        ptProng[0]=part->PtProng(0); ptProng[1]=part->PtProng(1);
-       
+       d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
+
        if(fArray==1) cout<<"LS signal: ERROR"<<endl;
        for (Int_t iprong=0; iprong<2; iprong++){
          AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
@@ -879,7 +926,7 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
            ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[iprong]);
            fillthispi="hd0piS_";
            fillthispi+=ptbin;
-           ((TH1F*)listout->FindObject(fillthispi))->Fill(part->Getd0Prong(iprong));
+           ((TH1F*)listout->FindObject(fillthispi))->Fill(d0Prong[iprong]);
            if(recalcvtx) {
 
              fillthispi="hd0vpiS_";
@@ -897,7 +944,7 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
            ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[iprong]);
            fillthisK="hd0KS_";
            fillthisK+=ptbin;
-           ((TH1F*)listout->FindObject(fillthisK))->Fill(part->Getd0Prong(iprong));
+           ((TH1F*)listout->FindObject(fillthisK))->Fill(d0Prong[iprong]);
            if (recalcvtx){
              fillthisK="hd0vKS_";
              fillthisK+=ptbin;
@@ -905,10 +952,11 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
            }
          }
 
-         fillthis="hcosthpointd0S_";
-         fillthis+=ptbin;        
-         ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Getd0Prong(iprong));
-
+         if(fSys==0){
+           fillthis="hcosthpointd0S_";
+           fillthis+=ptbin;      
+           ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[iprong]);
+         }
        } //end loop on prongs
 
        fillthis="hdcaS_";
@@ -919,10 +967,7 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        fillthis+=ptbin;          
        ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
 
-       fillthis="hcosthpointd0d0S_";
-       fillthis+=ptbin;          
-       ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
-         
+
        fillthis="hcosthetastarS_";
        fillthis+=ptbin;
        if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
@@ -934,19 +979,21 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        fillthis+=ptbin;
        ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
 
-       if(recalcvtx){
-         fillthis="hd0d0vS_";
-         fillthis+=ptbin;
-         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
-       }
-
        fillthis="hdeclS_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
 
        fillthis="hnormdeclS_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
+
+       fillthis="hdeclxyS_";
+       fillthis+=ptbin;
+       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
+
+       fillthis="hnormdeclxyS_";
+       fillthis+=ptbin;
+       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
 
        if(recalcvtx) {
          fillthis="hdeclvS_";
@@ -956,7 +1003,18 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
          fillthis="hnormdeclvS_";
          fillthis+=ptbin;
          ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
+
+         fillthis="hd0d0vS_";
+         fillthis+=ptbin;
+         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
+       }
+
+       if(fSys==0){
+         fillthis="hcosthpointd0d0S_";
+         fillthis+=ptbin;        
+         ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
        }
+
       } //end mass cut
     
     } else{ //Background or LS
@@ -966,29 +1024,32 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
       //no mass cut distributions: mass, ptbis
       fillthis="hMassB_";
       fillthis+=ptbin;
-      
+
       if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3))) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
       if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1)) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
-
-      // fillthis="hptB1prongnoMcut_";
-      // fillthis+=ptbin;
+      if(fSys==0){
+       fillthis="hptB1prongnoMcut_";
+       fillthis+=ptbin;
       
-      // ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(0));
       
-      // fillthis="hptB2prongsnoMcut_";
-      // fillthis+=ptbin;
-      // ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
-      // ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
-
+       fillthis="hptB2prongsnoMcut_";
+       fillthis+=ptbin;
+       ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(0));
+       ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(1));
+      }
       //apply cut on invariant mass on the pair
       if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
 
        cosThetaStarD0 = part->CosThetaStarD0();
        cosThetaStarD0bar = part->CosThetaStarD0bar();
        cosPointingAngle = part->CosPointingAngle();
-       normalizedDecayLength = part->NormalizedDecayLength();
-       decayLength = part->DecayLength();
+       normalizedDecayLength2 = part->NormalizedDecayLength2();
+       decayLength2 = part->DecayLength2();
+       decayLengthxy = part->DecayLengthXY();
+       normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
        ptProng[0]=part->PtProng(0); ptProng[1]=part->PtProng(1);
+       d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
 
 
        AliAODTrack *prongg=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
@@ -1014,16 +1075,10 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
        ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
 
-       fillthis="hd0p0B_";
-       fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(0));
-       fillthis="hd0p1B_";
-       fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(1));
        fillthis="hd0B_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(0));
-       ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(1));
+       ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
 
        if(fReadMC){
          Int_t pdgMother[2]={0,0};
@@ -1043,65 +1098,86 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
              }
            }
 
-           fillthis="hd0moresB_";
-           fillthis+=ptbin;
+           if(fSys==0){
+
+             fillthis="hd0moresB_";
+             fillthis+=ptbin;
          
-           if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
-             if(ptProng[iprong]<=1)factor[iprong]=1./.7;
-             else factor[iprong]=1./.6;
-             fNentries->Fill(11);
-           }
+             if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
+               if(ptProng[iprong]<=1)factor[iprong]=1./.7;
+               else factor[iprong]=1./.6;
+               fNentries->Fill(11);
+             }
            
-           if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
-             factor[iprong]=1./0.25;
-             fNentries->Fill(12);
-           }
-           fillthis="hd0moresB_";
-           fillthis+=ptbin;
+             if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
+               factor[iprong]=1./0.25;
+               fNentries->Fill(12);
+             }
+             fillthis="hd0moresB_";
+             fillthis+=ptbin;
 
-           ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(iprong),factor[iprong]);
+             ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[iprong],factor[iprong]);
 
-           if(recalcvtx){
-             fillthis="hd0vmoresB_";
-             fillthis+=ptbin;
-             ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
+             if(recalcvtx){
+               fillthis="hd0vmoresB_";
+               fillthis+=ptbin;
+               ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
+             }
            }
+         } //loop on prongs
 
-         }
-
+         if(fSys==0){
          fillthis="hd0d0moresB_";
          fillthis+=ptbin;
          ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
 
+         fillthis="hcosthetapointmoresB_";
+         fillthis+=ptbin;
+         ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
+
          if(recalcvtx){
            fillthis="hd0d0vmoresB_";
            fillthis+=ptbin;
            ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
          }
-         fillthis="hcosthetapointmoresB_";
-         fillthis+=ptbin;
-         ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
-       }
+         }
+       } //readMC
 
-       if(recalcvtx){
-         fillthis="hd0vp0B_";
+       if(fSys==0){        
+         fillthis="hd0p0B_";
          fillthis+=ptbin;
-         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
-         fillthis="hd0vp1B_";
+         ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
+         fillthis="hd0p1B_";
          fillthis+=ptbin;
-         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
-         
-         fillthis="hd0vB_";
+         ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
+       
+         fillthis="hcosthpointd0d0B_";
          fillthis+=ptbin;
-         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
-         ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
-       }  
+         ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
+       
+         fillthis="hcosthpointd0B_";
+         fillthis+=ptbin;        
+         ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[0]);
+         ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[1]);
+         
 
-       fillthis="hcosthpointd0B_";
-       fillthis+=ptbin;          
-       ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Getd0Prong(0));
-       ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Getd0Prong(1));
+         if(recalcvtx){
+
+           fillthis="hd0vp0B_";
+           fillthis+=ptbin;
+           ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
+           fillthis="hd0vp1B_";
+           fillthis+=ptbin;
+           ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
+         
+           fillthis="hd0vB_";
+           fillthis+=ptbin;
+           ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
+           ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
 
+         }
+
+       }  
 
        fillthis="hdcaB_";
        fillthis+=ptbin;
@@ -1114,7 +1190,7 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
 
        fillthis="hd0d0B_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
+       ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]*d0Prong[1]);
 
        if(recalcvtx){
          fillthis="hd0d0vB_";
@@ -1126,17 +1202,21 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
        fillthis+=ptbin;
        ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
 
-       fillthis="hcosthpointd0d0B_";
-       fillthis+=ptbin;
-       ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
-
        fillthis="hdeclB_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
 
        fillthis="hnormdeclB_";
        fillthis+=ptbin;
-       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength);
+       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
+
+       fillthis="hdeclxyB_";
+       fillthis+=ptbin;
+       ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
+
+       fillthis="hnormdeclxyB_";
+       fillthis+=ptbin;
+       ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
 
        if(recalcvtx) {
 
@@ -1148,6 +1228,7 @@ void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Pr
          fillthis+=ptbin;
          ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
 
+
        }
       }//mass cut      
     }//else (background)
@@ -1162,7 +1243,7 @@ void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClon
   //
 
 
-  //  Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
+  Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
 
   //cout<<"is selected = "<<fIsSelectedCandidate<<endl;
 
@@ -1181,6 +1262,20 @@ void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClon
   //printf("SELECTED\n");
   Int_t ptbin=cuts->PtBin(part->Pt());
 
+  AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
+  if(!prong) {
+    AliDebug(2,"No daughter found");
+    return;
+  }
+  else{
+    // if(prong->Charge()==1) {
+    //   ((TH1F*)fDistr->FindObject("hpospair"))->Fill(fCuts->GetNPtBins()+ptbin);
+    //   //fTotPosPairs[ptbin]++;
+    // } else {
+    //   ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(fCuts->GetNPtBins()+ptbin);
+    //   //fTotNegPairs[ptbin]++;
+    // }
+  }
  
   // for(Int_t it=0;it<2;it++){
  
@@ -1222,11 +1317,13 @@ void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClon
        fillthis="histSgn_";
        fillthis+=ptbin;
        ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
-       // if(TMath::Abs(invmassD0 - mPDG) < 0.027){
-       //   fillthis="histSgn27_";
-       //   fillthis+=ptbin;
-       //   ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
-       // }
+       if(fSys==0){
+       if(TMath::Abs(invmassD0 - mPDG) < 0.027){
+         fillthis="histSgn27_";
+         fillthis+=ptbin;
+         ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
+       }
+       }
       } else{ //it was a D0bar
        fillthis="histRfl_";
        fillthis+=ptbin;
@@ -1339,12 +1436,14 @@ void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
     printf("ERROR: fOutputMass not available\n");
     return;
   }
-  fDistr = dynamic_cast<TList*> (GetOutputData(2));
-  if (!fDistr) {
-    printf("ERROR: fDistr not available\n");
-    return;
+  if(fFillVarHists){
+    fDistr = dynamic_cast<TList*> (GetOutputData(2));
+    if (!fDistr) {
+      printf("ERROR: fDistr not available\n");
+      return;
+    }
   }
+
   fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
   
   if(!fNentries){
@@ -1364,7 +1463,7 @@ void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
   Int_t nptbins=fCuts->GetNPtBins();
   for(Int_t ipt=0;ipt<nptbins;ipt++){ 
 
-    if(fArray==1){ 
+    if(fArray==1 && fFillVarHists){ 
       fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fDistr->FindObject("hpospair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)*((TH1F*)fDistr->FindObject("hnegpair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)); //after cuts
 
 
index f38a65e..7badaa0 100644 (file)
@@ -50,10 +50,12 @@ class AliAnalysisTaskSED0Mass : public AliAnalysisTaskSE
   void SetUsePid4Distr(Bool_t usepid=kTRUE){fUsePid4Distr=usepid;}
   void SetFillOnlyD0D0bar(Int_t flagfill){fFillOnlyD0D0bar=flagfill;}
   void SetFillVarHists(Bool_t flag) {fFillVarHists=flag;}
+  void SetSystem(Int_t sys){fSys=sys; if(fSys==1) SetFillVarHists(kFALSE);}
 
   Bool_t GetCutOnDistr() const {return fCutOnDistr;}
   Bool_t GetUsePid4Distr() const {return fUsePid4Distr;}
   Int_t  GetFillOnlyD0D0bar() const {return fFillOnlyD0D0bar;}
+  Int_t  GetSystem() const {return fSys;}
 
  private:
 
@@ -78,8 +80,9 @@ class AliAnalysisTaskSED0Mass : public AliAnalysisTaskSE
   TObjArray fDaughterTracks;      // keeps the daughter tracks
   Int_t     fIsSelectedCandidate; // selection outcome
   Bool_t    fFillVarHists;        // flag to enable filling variable histos
+  Int_t     fSys;                 // fSys=0 -> p-p; fSys=1 ->PbPb (in this case fFillVarHists=kFALSE by default: set it to kTRUE *after* if needed)
 
-  ClassDef(AliAnalysisTaskSED0Mass,13); // AliAnalysisTaskSE for D0->Kpi
+  ClassDef(AliAnalysisTaskSED0Mass,14); // AliAnalysisTaskSE for D0->Kpi
 };
 
 #endif
index 810e1b9..5ed89d2 100644 (file)
@@ -131,14 +131,15 @@ AliAnalysisTaskSED0Mass *AddTaskD0Mass(Int_t flag=0/*0 = D0,1 = LS*/,Bool_t read
   if (flag==0)taskname.Prepend("D0");
   else taskname.Prepend("LS");
   AliAnalysisTaskSED0Mass *massD0Task = new AliAnalysisTaskSED0Mass(taskname.Data(),RDHFD0toKpi);
-  massD0Task->SetDebugLevel(2);
+  massD0Task->SetDebugLevel(0);
   massD0Task->SetArray(flag);
   massD0Task->SetReadMC(readMC);
   massD0Task->SetCutOnDistr(cutOnDistr);
   massD0Task->SetUsePid4Distr(kFALSE);
   massD0Task->SetFillOnlyD0D0bar(flagD0D0bar);
-  massD0Task->SetFillVarHists(kTRUE); // set to FALSE to go faster in PbPb
-
+  massD0Task->SetSystem(1); //0=pp, 1=PbPb
+  //massD0Task->SetFillVarHists(kTRUE); // default is FALSE if System=PbPb
   mgr->AddTask(massD0Task);
   
   //