major dielectron update (included also the data and plotting macros for paper)
authorandronic <andronic@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 May 2011 18:40:48 +0000 (18:40 +0000)
committerandronic <andronic@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 May 2011 18:40:48 +0000 (18:40 +0000)
91 files changed:
PWG3/CMakelibPWG3dielectron.pkg
PWG3/PWG3dielectronLinkDef.h
PWG3/dielectron/AliAnalysisTaskDielectronEfficiency.cxx
PWG3/dielectron/AliAnalysisTaskDielectronEfficiency.h
PWG3/dielectron/AliAnalysisTaskDielectronFilter.cxx
PWG3/dielectron/AliAnalysisTaskDielectronFilter.h
PWG3/dielectron/AliAnalysisTaskDielectronME.cxx
PWG3/dielectron/AliAnalysisTaskDielectronME.h
PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.cxx [new file with mode: 0644]
PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.h [new file with mode: 0644]
PWG3/dielectron/AliAnalysisTaskDielectronSE.cxx
PWG3/dielectron/AliAnalysisTaskDielectronSE.h
PWG3/dielectron/AliAnalysisTaskMultiDielectron.cxx
PWG3/dielectron/AliAnalysisTaskMultiDielectron.h
PWG3/dielectron/AliDielectron.cxx
PWG3/dielectron/AliDielectron.h
PWG3/dielectron/AliDielectronBtoJPSItoEle.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronBtoJPSItoEle.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronCF.cxx
PWG3/dielectron/AliDielectronCF.h
PWG3/dielectron/AliDielectronCFdraw.cxx
PWG3/dielectron/AliDielectronCFdraw.h
PWG3/dielectron/AliDielectronCutGroup.cxx
PWG3/dielectron/AliDielectronCutGroup.h
PWG3/dielectron/AliDielectronDebugTree.cxx
PWG3/dielectron/AliDielectronDebugTree.h
PWG3/dielectron/AliDielectronEventCuts.cxx
PWG3/dielectron/AliDielectronEventCuts.h
PWG3/dielectron/AliDielectronHelper.cxx
PWG3/dielectron/AliDielectronHelper.h
PWG3/dielectron/AliDielectronHistos.cxx
PWG3/dielectron/AliDielectronHistos.h
PWG3/dielectron/AliDielectronMC.cxx
PWG3/dielectron/AliDielectronMC.h
PWG3/dielectron/AliDielectronPID.cxx
PWG3/dielectron/AliDielectronPID.h
PWG3/dielectron/AliDielectronPair.cxx
PWG3/dielectron/AliDielectronPair.h
PWG3/dielectron/AliDielectronPairLegCuts.cxx
PWG3/dielectron/AliDielectronPairLegCuts.h
PWG3/dielectron/AliDielectronSignalBase.cxx
PWG3/dielectron/AliDielectronSignalBase.h
PWG3/dielectron/AliDielectronSignalExt.cxx
PWG3/dielectron/AliDielectronSignalExt.h
PWG3/dielectron/AliDielectronSignalFunc.cxx
PWG3/dielectron/AliDielectronSignalFunc.h
PWG3/dielectron/AliDielectronSignalMC.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronSignalMC.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronSpectrum.cxx
PWG3/dielectron/AliDielectronSpectrum.h
PWG3/dielectron/AliDielectronTRDpidCut.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronTRDpidCut.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronTrackCuts.cxx
PWG3/dielectron/AliDielectronTrackCuts.h
PWG3/dielectron/AliDielectronVarContainer.cxx [new file with mode: 0644]
PWG3/dielectron/AliDielectronVarContainer.h [new file with mode: 0644]
PWG3/dielectron/AliDielectronVarCuts.cxx
PWG3/dielectron/AliDielectronVarCuts.h
PWG3/dielectron/AliDielectronVarManager.cxx
PWG3/dielectron/AliDielectronVarManager.h
PWG3/dielectron/macros/AddTaskJPSI.C
PWG3/dielectron/macros/AddTaskReadAODBranch.C [new file with mode: 0644]
PWG3/dielectron/macros/ConfigJpsi2eeData.C
PWG3/dielectron/macros/ExtractEfficiencies.C
PWG3/dielectron/macros/FitCDFLocal.C [new file with mode: 0644]
PWG3/dielectron/macros/MakeDataReport.C
PWG3/dielectron/macros/PlotDataResults.C
PWG3/dielectron/macros/paper7TeV/PlotJpsiCrsec7TeV.C [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bc/eff_trk_bc.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bc/sig_cAnyArith.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/polarizErrors.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/sigPt_cAnyArith.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/sigPt_cAnyRot.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/sig_cAnyArith.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/sig_cAny_Y03.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/bcd/sig_cAny_Y03_09.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/d/eff_trk_d.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/d/sig_cAnyArith.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt-cms_y1.2.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt-cms_y1.6-2.4.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt_atlas_y0.75.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt_lhcb_y2.5-4.0.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt_spd0_Arith.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt_spd0_Rot.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdpt_y2.5_4.0.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdy_lhcb.txt [new file with mode: 0644]
PWG3/dielectron/macros/paper7TeV/dsigdy_y2.5_4.0.txt [new file with mode: 0644]

index 3485963..4678f3a 100644 (file)
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS  dielectron/AliDielectron.cxx dielectron/AliDielectronPair.cxx dielectron/AliDielectronHistos.cxx dielectron/AliDielectronCF.cxx dielectron/AliDielectronCFdraw.cxx dielectron/AliDielectronMC.cxx dielectron/AliDielectronVarManager.cxx dielectron/AliAnalysisTaskDielectronSE.cxx dielectron/AliAnalysisTaskDielectronME.cxx dielectron/AliAnalysisTaskDielectronFilter.cxx dielectron/AliAnalysisTaskDielectronEfficiency.cxx dielectron/AliAnalysisTaskMultiDielectron.cxx dielectron/AliDielectronVarCuts.cxx dielectron/AliDielectronTrackCuts.cxx dielectron/AliDielectronPairLegCuts.cxx dielectron/AliDielectronSignalBase.cxx dielectron/AliDielectronSignalFunc.cxx dielectron/AliDielectronSignalExt.cxx dielectron/AliDielectronSpectrum.cxx dielectron/AliDielectronDebugTree.cxx dielectron/AliDielectronTrackRotator.cxx dielectron/AliDielectronPID.cxx dielectron/AliDielectronCutGroup.cxx dielectron/AliDielectronEventCuts.cxx dielectron/AliDielectronHelper.cxx)
+set ( SRCS  
+      dielectron/AliDielectron.cxx 
+      dielectron/AliDielectronPair.cxx 
+      dielectron/AliDielectronHistos.cxx 
+      dielectron/AliDielectronCF.cxx 
+      dielectron/AliDielectronCFdraw.cxx 
+      dielectron/AliDielectronMC.cxx 
+      dielectron/AliDielectronVarManager.cxx 
+      dielectron/AliAnalysisTaskDielectronSE.cxx 
+      dielectron/AliAnalysisTaskDielectronME.cxx 
+      dielectron/AliAnalysisTaskDielectronFilter.cxx 
+      dielectron/AliAnalysisTaskDielectronEfficiency.cxx 
+      dielectron/AliAnalysisTaskMultiDielectron.cxx 
+      dielectron/AliDielectronVarCuts.cxx 
+      dielectron/AliDielectronTrackCuts.cxx 
+      dielectron/AliDielectronPairLegCuts.cxx 
+      dielectron/AliDielectronSignalBase.cxx 
+      dielectron/AliDielectronSignalFunc.cxx 
+      dielectron/AliDielectronSignalExt.cxx 
+      dielectron/AliDielectronSpectrum.cxx 
+      dielectron/AliDielectronDebugTree.cxx 
+      dielectron/AliDielectronTrackRotator.cxx 
+      dielectron/AliDielectronPID.cxx 
+      dielectron/AliDielectronCutGroup.cxx 
+      dielectron/AliDielectronEventCuts.cxx 
+      dielectron/AliDielectronHelper.cxx
+      dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.cxx
+      dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.cxx
+      dielectron/AliDielectronBtoJPSItoEle.cxx
+      dielectron/AliAnalysisTaskDielectronReadAODBranch.cxx
+      dielectron/AliDielectronTRDpidCut.cxx
+      dielectron/AliDielectronSignalMC.cxx
+)
 
 string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
 
@@ -35,6 +67,6 @@ set ( EINCLUDE  PWG3/dielectron STEER CORRFW)
 
 if( ALICE_TARGET STREQUAL "win32gcc")
        
-               set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lESD -lSTEER -lANALYSISalice -lANALYSIS -lCORRFW)
+  set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lESD -lSTEER -lANALYSISalice -lANALYSIS -lCORRFW)
 
 endif( ALICE_TARGET STREQUAL "win32gcc")
index 0e51dc7..d745438 100644 (file)
@@ -18,6 +18,7 @@
 #pragma link C++ class AliAnalysisTaskDielectronFilter+;
 #pragma link C++ class AliAnalysisTaskDielectronEfficiency+;
 #pragma link C++ class AliAnalysisTaskMultiDielectron+;
+#pragma link C++ class AliAnalysisTaskDielectronReadAODBranch+;
 #pragma link C++ class AliDielectronVarCuts+;
 #pragma link C++ class AliDielectronTrackCuts+;
 #pragma link C++ class AliDielectronPairLegCuts+;
 #pragma link C++ class AliDielectronCutGroup+;
 #pragma link C++ class AliDielectronEventCuts+;
 #pragma link C++ class AliDielectronHelper+;
+#pragma link C++ class AliDielectronBtoJPSItoEleCDFfitFCN+;
+#pragma link C++ class AliDielectronBtoJPSItoEleCDFfitHandler+;
+#pragma link C++ class AliDielectronBtoJPSItoEle+;
+#pragma link C++ class AliDielectronTRDpidCut+;
+#pragma link C++ class AliDielectronSignalMC+;
+
 #endif
index af148b8..191dd60 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 //#####################################################
 //#                                                   #
 //#  Simple efficiency study for dielectrons          #
index 84cbd9f..0574d3b 100644 (file)
@@ -1,8 +1,5 @@
 #ifndef ALIANALYSISTASKDIELECTRONEFFICIENCY_H
 #define ALIANALYSISTASKDIELECTRONEFFICIENCY_H
-
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#  Analysis Task for Event Mixing for dielectron    #
index 748e499..8338bfd 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                        Basic Analysis Task                            //
index e2c50a2..4249ef1 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#        Dielectron even filter task                #
index a24396e..3d95e0f 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                        Basic Analysis Task                            //
index 01277a9..54c42ae 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#        Basic Analysis task for Dielectron         #
diff --git a/PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.cxx b/PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.cxx
new file mode 100644 (file)
index 0000000..f88f52a
--- /dev/null
@@ -0,0 +1,454 @@
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////
+//  Class to retrieve the branch of the dielectron candidates stored in   //
+//  filtered AODs file (AliAOD.Dielectron.root). It is possible to        //
+//  apply tighter cuts to candidates stored in the branch and do the      //
+//  matching with MC truth.                                               //
+////////////////////////////////////////////////////////////////////////////
+
+#include "TChain.h"
+#include "TNtuple.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TDatabasePDG.h"
+#include "TF1.h"
+#include "AliAnalysisManager.h"
+#include "AliAODHandler.h"
+#include "AliAODEvent.h"
+#include "AliAODVertex.h"
+#include "AliAODTrack.h"
+#include "AliAODMCParticle.h"
+#include "AliAnalysisTaskDielectronReadAODBranch.h"
+#include "AliDielectronPair.h"
+
+ClassImp(AliAnalysisTaskDielectronReadAODBranch)
+       //________________________________________________________________________
+       AliAnalysisTaskDielectronReadAODBranch::AliAnalysisTaskDielectronReadAODBranch():
+               AliAnalysisTaskSE(),
+               fOutput(0),
+                fNtupleJPSI(0),
+                fNentries(0),
+               fInvMass(0),
+               fInvMassNoCuts(0),
+                fpsproperSignal(0),
+               fpsproperSidebands(0),            
+               fpsproperAll(0),                  
+               fpsproperUnder(0),
+                fpsproperUpper(0),
+                fLxyVsPtleg1(0),
+               fLxyVsPtleg2(0),
+               fLxyVsPt(0),
+               fMeeVsPt(0),
+               fMeeVsLxy(0),
+               fprimvtxZ(0),  
+               fsecvtxZ(0),  
+               fprimvtxX(0),  
+               fsecvtxX(0),  
+               fprimvtxY(0),  
+               fsecvtxY(0),  
+               fPt(0),
+               fPtLeg1(0),
+               fPtLeg2(0),
+               fdEdxP(0),
+               fHasMC(0),
+               fobj(0),
+               fobjMC(0),
+                fPtCut(1.),
+                fSpdFirstRequired(kFALSE),
+                fClsTPC(90),
+                fPairType(1),
+                fPtJpsi(1.3),
+                fInvMassSignalLimits(0),
+                fInvMassSideBandsLimits(0)
+{
+       // Default constructor
+}
+
+//________________________________________________________________________
+AliAnalysisTaskDielectronReadAODBranch::AliAnalysisTaskDielectronReadAODBranch(const char *name):
+       AliAnalysisTaskSE(name),
+       fOutput(0),
+        fNtupleJPSI(0),
+        fNentries(0),
+       fInvMass(0),
+        fInvMassNoCuts(0),
+        fpsproperSignal(0),
+       fpsproperSidebands(0),            
+       fpsproperAll(0),                  
+       fpsproperUnder(0),
+        fpsproperUpper(0),
+        fLxyVsPtleg1(0),
+       fLxyVsPtleg2(0),
+       fLxyVsPt(0),
+       fMeeVsPt(0),
+       fMeeVsLxy(0),
+       fprimvtxZ(0), 
+       fsecvtxZ(0),  
+       fprimvtxX(0), 
+       fsecvtxX(0),  
+       fprimvtxY(0), 
+       fsecvtxY(0),  
+       fPt(0),
+       fPtLeg1(0),
+       fPtLeg2(0),
+       fdEdxP(0),
+        fHasMC(0),
+       fobj(0),
+       fobjMC(0),
+        fPtCut(1.),
+        fSpdFirstRequired(kFALSE),
+        fClsTPC(90),
+        fPairType(1),
+        fPtJpsi(1.3),
+        fInvMassSignalLimits(0),
+        fInvMassSideBandsLimits(0) 
+{
+       // Default constructor
+       DefineInput(0,TChain::Class());
+       DefineOutput(1,TList::Class());  //My private output
+
+        fInvMassSignalLimits = new Double_t[2]; 
+        fInvMassSignalLimits[0] = 0.;  fInvMassSignalLimits[1] = 0.; 
+        fInvMassSideBandsLimits = new Double_t[2]; 
+        fInvMassSideBandsLimits[0] = 0.;  fInvMassSideBandsLimits[1] = 0.;
+}
+
+//________________________________________________________________________
+AliAnalysisTaskDielectronReadAODBranch::~AliAnalysisTaskDielectronReadAODBranch()
+{
+       if(fOutput)   delete fOutput;
+       if(fobj)      delete fobj;
+       if(fobjMC)    delete fobjMC;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskDielectronReadAODBranch::Init()
+{
+       // Initialization
+       if(fDebug > 1) printf("AnalysisTaskReadAOD::Init() \n");
+       return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskDielectronReadAODBranch::UserCreateOutputObjects()
+{
+       //
+        // Create the output container
+       //
+       if(fDebug > 1) printf("AnalysisTaskReadAOD::UserCreateOutputObjects() \n");
+       fOutput = new TList();
+       fOutput->SetOwner();
+       //// Histogram booking
+        
+        // invariant mass
+        fInvMass = new TH1F("fInvMass","fInvMass",300,2.0,2.0+300*.04); // step 40MeV
+        fInvMassNoCuts = new TH1F("fInvMass_no_cuts","fInvMass_no_cuts",125,0,125*0.04); //step 40MeV
+        fNentries = new TH1F("numberOfevent","numbOfEvent",1,-0.5,0.5);
+       
+        //pseudoproper 
+       fpsproperSignal = new TH1F("psproper_decay_length",Form("psproper_decay_length_distrib(AODcuts+#clustTPC>%d, pT(leg)>%fGeV, pT(J/#psi)>%fGeV/c, %f < M < %f);X [#mu m];Entries/40#mu m",fClsTPC,fPtCut,fPtJpsi,fInvMassSignalLimits[0],fInvMassSignalLimits[1]),150,-3000.,3000.);
+       fpsproperSidebands = new TH1F("psproper_decay_length_sidebands",Form("psproper_decay_length_distrib_sidebands(AODcuts+#clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c,M> %f && M < %f );  X [#mu m]; Entries/40#mu m",fClsTPC,fPtCut,fPtJpsi,fInvMassSideBandsLimits[1],fInvMassSideBandsLimits[0]),150,-3000.,3000.);
+       fpsproperAll = new TH1F("psproper_decay_length_all",Form("psproper_decay_length_distrib_all(AODcuts+#clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c);X [#mu m];Entries/15#mu m",fClsTPC,fPtCut,fPtJpsi),400,-3000.,3000.);
+       fpsproperUnder = new TH1F("psproper_decay_length_under",Form("psproper_decay_length_distrib_under(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c);X [#mu m];Entries/15#mu m",fClsTPC,fPtCut,fPtJpsi),400,-3000.,3000.); 
+        fpsproperUpper = new TH1F("psproper_decay_length_upper",Form("psproper_decay_length_distrib_upper(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c);X [#mu m];Entries/15#mu m",fClsTPC,fPtCut,fPtJpsi),400,-3000.,3000.);  
+        //
+       fLxyVsPtleg1 = new TH2F("Lxy_vs_Pt_leg1",Form("Lxy_vs_Pt_leg1_distrib(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c,%f<M<%f);p_{T}[GeV/c]; X",fClsTPC,fPtCut,fPtJpsi,fInvMassSignalLimits[0],fInvMassSignalLimits[1]), 700, 0., 7.,400, -3000.,3000.);
+       fLxyVsPtleg2 = new TH2F("Lxy_vs_Pt_leg2",Form("Lxy_vs_Pt_leg2_distrib(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c,%f<M<%f);p_{T}[GeV/c]; X",fClsTPC,fPtCut,fPtJpsi,fInvMassSignalLimits[0],fInvMassSignalLimits[1]), 700, 0., 7.,400, -3000.,3000.);
+       fLxyVsPt = new TH2F("Lxy_vs_Pt_jpsi",Form("Lxy_vs_Pt_jpsi_distrib(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c,%f<M<%f); p_{T}[GeV/c]; X",fClsTPC,fPtCut,fPtJpsi,fInvMassSignalLimits[0],fInvMassSignalLimits[1]), 700, 0., 7.,400, -3000.,3000.);
+       fMeeVsPt = new TH2F("Mee_vs_Pt_jpsi",Form("Mee_vs_Pt_jpsi_distrib(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV,pT(J/#psi)>%f GeV/c,%f<M<%f); p_{T}[GeV/c]; M_{ee}",fClsTPC,fPtCut,fPtJpsi,fInvMassSignalLimits[0],fInvMassSignalLimits[1]), 700, 0., 7.,200, 1.99,4.1);
+       fMeeVsLxy = new TH2F("Mee_vs_Lxy_jpsi",Form("Mee_vs_Lxy_jpsi_distrib(AODcuts+#clustTPC>%d,pT(e+e-)>%f GeV),pT(J/#psi)>%f GeV/c; X; M_{ee}",fClsTPC,fPtCut,fPtJpsi), 400, -3000, 3000.,200, 1.99,4.1);
+
+       // QA plots
+       fprimvtxZ = new TH1F("prim_vtx_Z",Form("prim_vtx_Z_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV, pT(J/#psi)>%f);  Z[cm]; Entries/20 mm",fClsTPC,fPtCut,fPtJpsi),1000,-10.,10.);
+       fsecvtxZ = new TH1F("sec_vtx_Z",Form("sec_vtx_Z_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV, pT(J/#psi)>%f);  Z[cm]; Entries/20 mm",fClsTPC,fPtCut,fPtJpsi),1000,-10.,10.);
+       fprimvtxX = new TH1F("prim_vtx_X",Form("prim_vtx_X_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f);  X[cm]; Entries/mm",fClsTPC,fPtCut,fPtJpsi),1000,-0.5,0.5);
+       fsecvtxX = new TH1F("sec_vtx_X",Form("sec_vtx_X_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f);  X[cm]; Entries/20 mm",fClsTPC,fPtCut,fPtJpsi),100,-1.,1.);
+       fprimvtxY = new TH1F("prim_vtx_Y",Form("prim_vtx_Y_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f);  Y[cm]; Entries/mm",fClsTPC,fPtCut,fPtJpsi),1000,-0.5,0.5);
+       fsecvtxY = new TH1F("sec_vtx_Y",Form("sec_vtx_Y_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV,pT(J/#psi)>%f);  Y[cm]; Entries/20 mm",fClsTPC,fPtCut,fPtJpsi),100,-1.,1.);
+       //
+       fPt = new TH1F("Pt(J/psi)",Form("Pt_Jpsi_distrib(AODcuts + #clustTPC>%d, pT(e+e-)>%f GeV, pT(J/#psi)>%f); p_{T}(J/#psi)[GeV/c]; Entries/25 MeV",fClsTPC,fPtCut,fPtJpsi),400,0.,10.);
+       fPtLeg1 = new TH1F("Pt_leg1",Form("Pt_leg1_distrib(AODcuts + #clustTPC>%d, pT(e+e-) > %f GeV, pT(J/#psi)>%f);  p_{T}[GeV/c]; Entries/25 MeV",fClsTPC,fPtCut,fPtJpsi),400,0.,10.);
+       fPtLeg2 = new TH1F("Pt_leg2",Form("Pt_leg2_distrib(AODcuts + #clustTPC>%d, pT(e+e-) > %f GeV, pT(J/#psi)>%f);  p_{T}[GeV/c]; Entries/25 MeV",fClsTPC,fPtCut,fPtJpsi),400,0.,10.);
+       //dE/dx plots
+       fdEdxP = new TH2F("dE/dx_vs_Ptpc",Form("dE/dx_vs_Ptpc(AODcuts + #clustTPC>%d, pT(e+e-) > %f GeV, pT(J/#psi)>%f)",fClsTPC,fPtCut,fPtJpsi),400,0.2,20.,200,0.,200.);
+        
+        //J/psi n-tuple (X and M values)
+        fNtupleJPSI = new TNtuple("fNtupleJPSI","J/#psi pseudo-proper decay time & invariant mass","Xdecaytime:Mass");
+       // add histograms to list
+       fOutput->Add(fNentries);
+       fOutput->Add(fInvMass);
+        fOutput->Add(fInvMassNoCuts); 
+       fOutput->Add(fpsproperSignal);
+       fOutput->Add(fpsproperSidebands);
+       fOutput->Add(fpsproperAll);
+       fOutput->Add(fpsproperUnder);
+        fOutput->Add(fpsproperUpper);
+        fOutput->Add(fLxyVsPtleg1);
+       fOutput->Add(fLxyVsPtleg2);
+       fOutput->Add(fLxyVsPt);
+       fOutput->Add(fMeeVsPt);
+       fOutput->Add(fMeeVsLxy);
+       fOutput->Add(fprimvtxZ);
+       fOutput->Add(fsecvtxZ);
+       fOutput->Add(fprimvtxX);
+       fOutput->Add(fsecvtxX);
+       fOutput->Add(fprimvtxY);
+       fOutput->Add(fsecvtxY);
+       fOutput->Add(fPt);
+       fOutput->Add(fPtLeg1);
+       fOutput->Add(fPtLeg2);
+        fOutput->Add(fNtupleJPSI);
+        fOutput->Add(fdEdxP);
+       return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskDielectronReadAODBranch::UserExec(Option_t */*option*/)
+{
+       // Execute analysis for current event:
+       AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
+       Double_t vtxPrim[3] = {0.,0.,0.};
+
+       AliAODVertex* primvtx = aod->GetPrimaryVertex();
+       vtxPrim[0] = primvtx->GetX();
+       vtxPrim[1] = primvtx->GetY();
+       vtxPrim[2] = primvtx->GetZ();
+
+       AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
+
+       TTree *aodTree = aodHandler->GetTree();
+       if(!fobj) aodTree->SetBranchAddress("dielectrons",&fobj);
+
+       if(fHasMC){ aodTree->SetBranchAddress("mcparticles",&fobjMC);
+       if(!fobjMC) printf("AliAnalysisTaskDielectronReadAODBranch::UserExec: MC particles branch not found!\n"); }
+
+       fNentries->Fill(0);
+       aodTree->GetEvent(Entry());
+       Int_t dgLabels[2] = {0,0};
+       Int_t pdgDgJPSItoEE[2] = {11,11};
+
+       // loop over candidates
+       if(fobj) {
+               TObjArray *objArr = (TObjArray*)fobj->UncheckedAt(fPairType);
+               for(int j=0;j<objArr->GetEntriesFast();j++)
+               {
+                       AliDielectronPair *pairObj = (AliDielectronPair*)objArr->UncheckedAt(j);
+                       fInvMassNoCuts->Fill(pairObj->M()); 
+                        Double_t vtxSec[3] = {0.,0.,0.};
+                       fprimvtxX->Fill(vtxPrim[0]);
+                       fprimvtxY->Fill(vtxPrim[1]);
+                       fprimvtxZ->Fill(vtxPrim[2]);
+                       pairObj->XvYvZv(vtxSec);
+                       fsecvtxX->Fill(vtxSec[0]);
+                       fsecvtxY->Fill(vtxSec[1]);
+                       fsecvtxZ->Fill(vtxSec[2]);
+
+                       Double_t lxy = ((vtxSec[0]-vtxPrim[0])*(pairObj->Px()) + (vtxSec[1]-vtxPrim[1])*(pairObj->Py()))/pairObj->Pt();
+                       Double_t psProperDecayLength = lxy*(TDatabasePDG::Instance()->GetParticle(443)->Mass())/pairObj->Pt();
+
+                       AliAODTrack *trk = (AliAODTrack*)pairObj->GetFirstDaughter();
+                       AliAODTrack *trk1 = (AliAODTrack*)pairObj->GetSecondDaughter();
+                       if(!trk || !trk1) {printf("ERROR: daughter tracks not available\n"); continue;}
+                       dgLabels[0] = trk->GetLabel(); 
+                       dgLabels[1] = trk1->GetLabel(); 
+
+                       //check in case of MC analysis if candidate is a true J/psi->ee
+                       if(fHasMC && !MatchToMC(443,fobjMC,dgLabels,2,2,pdgDgJPSItoEE)) continue;
+                           AliAODPid *pid  = trk->GetDetPid();
+                                AliAODPid *pid1 = trk1->GetDetPid();
+                                if(!pid || !pid1){
+                                        if(fDebug>1) printf("No AliAODPid found\n");
+                                        continue;
+                                }
+                                 // ptLeg cut
+                                if((trk->Pt()<fPtCut) || (trk1->Pt()<fPtCut)) continue;
+                           
+                                // pt jpsi cut
+                                if((pairObj->Pt())<fPtJpsi) continue; 
+                              //spd first required
+                              if(fSpdFirstRequired)
+                              {
+                               if((!trk->HasPointOnITSLayer(0)) || (!trk1->HasPointOnITSLayer(0))) continue;
+                              }
+                           //
+                          if((trk->GetTPCNcls()) <= fClsTPC || (trk1->GetTPCNcls()) <= fClsTPC) continue;
+                               if(trk->Charge()==-1){
+                                       fPtLeg1->Fill(trk->Pt());
+                               } else {fPtLeg2->Fill(trk->Pt());}
+                               if(trk1->Charge()==-1){
+                                       fPtLeg1->Fill(trk1->Pt());
+                               } else {fPtLeg2->Fill(trk1->Pt());}
+                               //Fill dE/dx related plots (before PID cuts)
+                               fdEdxP->Fill(pid->GetTPCmomentum(),pid->GetTPCsignal());
+                               fdEdxP->Fill(pid1->GetTPCmomentum(),pid1->GetTPCsignal());
+                                       fInvMass->Fill(pairObj->M());
+                                       fPt->Fill(pairObj->Pt());
+                                       fMeeVsLxy->Fill(10000*psProperDecayLength,pairObj->M());
+                                       fMeeVsPt->Fill(pairObj->Pt(),pairObj->M());
+                                       fpsproperAll->Fill(10000*psProperDecayLength);
+                                           
+                                           //psproper in the signal region 
+                                          if((pairObj->M())<fInvMassSignalLimits[1] && (pairObj->M())>fInvMassSignalLimits[0]){
+                                               fpsproperSignal->Fill(10000*psProperDecayLength);
+                                               fLxyVsPt->Fill(pairObj->Pt(),10000*psProperDecayLength);  //jpsi 
+                                               fLxyVsPtleg1->Fill(trk->Pt(),10000*psProperDecayLength);  //leg1 (warning: mixture of pos and neg tracks)
+                                               fLxyVsPtleg2->Fill(trk1->Pt(),10000*psProperDecayLength); //leg2 (warning: mixture of pos and neg tracks)
+                                               fNtupleJPSI->Fill(10000*psProperDecayLength,pairObj->M()); // fill the N-tuple (imput of the minimization algorithm)
+                                                 } 
+
+                                        // psproper in the sidebands 
+                                       if((pairObj->M())> fInvMassSideBandsLimits[1] || (pairObj->M())< fInvMassSideBandsLimits[0])
+                                        fpsproperSidebands->Fill(10000*psProperDecayLength);
+                                          
+                                        // psproper in the lower sideband
+                                       if(pairObj->M()< fInvMassSideBandsLimits[0]) fpsproperUnder->Fill(10000*psProperDecayLength);
+                                          
+                                        // psproper in the upper sideband
+                                        if(pairObj->M()> fInvMassSideBandsLimits[1]) fpsproperUpper->Fill(10000*psProperDecayLength);
+                        } // end loop over candidates
+               }// end loop over pair types
+        // Post the data
+       PostData(1,fOutput);
+       return;
+} 
+
+//________________________________________________________________________
+void AliAnalysisTaskDielectronReadAODBranch::Terminate(Option_t */*option*/)
+{
+       if(fDebug > 1) printf("AliAnalysisTaskDielectronReadAODBranch::Terminate() \n");
+       return;
+}
+
+//___________________________________________________________________
+Bool_t AliAnalysisTaskDielectronReadAODBranch::MatchToMC(Int_t pdgabs,const TObjArray *mcArray,
+               const Int_t *dgLabels,Int_t ndg,
+               Int_t ndgCk, const Int_t *pdgDg) const
+{
+       //
+       // jpsi candidates association to MC truth
+        // Check if this candidate is matched to a MC signal
+       // If no, return kFALSE
+       // If yes, return kTRUE
+       // 
+       Int_t labMom[2]={0,0};
+       Int_t i,j,lab,labMother,pdgMother,pdgPart,labJPSIMother,pdgJPSIMother;
+       AliAODMCParticle *part=0;
+       AliAODMCParticle *mother=0;
+       AliAODMCParticle *jPSImother=0;
+       Double_t pxSumDgs=0.,pySumDgs=0.,pzSumDgs=0.;
+       Bool_t pdgUsed[2]={kFALSE,kFALSE};
+
+       // loop on daughter labels
+       for(i=0; i<ndg; i++) {
+               labMom[i]=-1;
+               lab = dgLabels[i];
+               if(lab<0) {
+                       printf("daughter with negative label %d\n",lab);
+                       return kFALSE;
+               }
+               part = (AliAODMCParticle*)mcArray->At(lab);
+               if(!part) {
+                       printf("no MC particle\n");
+                       return kFALSE;
+               }
+
+               // check the PDG of the daughter, if requested
+               if(ndgCk>0) {
+                       pdgPart=TMath::Abs(part->GetPdgCode());
+                       printf("pdg code of daughter %d == %d\n",i,pdgPart);
+                       for(j=0; j<ndg; j++) {
+                               if(!pdgUsed[j] && pdgPart==pdgDg[j]) {
+                                       pdgUsed[j]=kTRUE;
+                                       break;
+                               }
+                       }
+               }
+
+               // for the J/psi, check that the daughters are electrons
+               if(pdgabs==443) {
+                       if(TMath::Abs(part->GetPdgCode())!=11) return kFALSE;
+               }
+
+               mother = part;
+               while(mother->GetMother()>=0) {
+                       labMother=mother->GetMother();
+                       mother = (AliAODMCParticle*)mcArray->At(labMother);//get particle mother
+                       if(!mother) {
+                               printf("no MC mother particle\n");
+                               break;
+                       }
+                       pdgMother = TMath::Abs(mother->GetPdgCode());//get particle mother pdg code
+                       printf("pdg code of mother track == %d\n",pdgMother);
+                       if(pdgMother==pdgabs) {
+                               labJPSIMother=mother->GetMother();
+                               jPSImother = (AliAODMCParticle*)mcArray->At(labJPSIMother);//get J/psi mother
+                               if(jPSImother) {
+                                       pdgJPSIMother = TMath::Abs(jPSImother->GetPdgCode()); //get J/psi mother pdg code
+                                       if( pdgJPSIMother==511   || pdgJPSIMother==521   ||
+                                                       pdgJPSIMother==10511 || pdgJPSIMother==10521 ||
+                                                       pdgJPSIMother==513   || pdgJPSIMother==523   ||
+                                                       pdgJPSIMother==10513 || pdgJPSIMother==10523 ||
+                                                       pdgJPSIMother==20513 || pdgJPSIMother==20523 ||
+                                                       pdgJPSIMother==515   || pdgJPSIMother==525   ||
+                                                       pdgJPSIMother==531   || pdgJPSIMother==10531 ||
+                                                       pdgJPSIMother==533   || pdgJPSIMother==10533 ||
+                                                       pdgJPSIMother==20533 || pdgJPSIMother==535   ||
+                                                       pdgJPSIMother==541   || pdgJPSIMother==10541 ||
+                                                       pdgJPSIMother==543   || pdgJPSIMother==10543 ||
+                                                       pdgJPSIMother==20543 || pdgJPSIMother==545) return kFALSE;} //check if J/psi comes from B hadron
+
+                                       labMom[i]=labMother;
+                                       // keep sum of daughters' momenta, to check for mom conservation
+                                       pxSumDgs += part->Px();
+                                       pySumDgs += part->Py();
+                                       pzSumDgs += part->Pz();
+                                       break;
+                       } else if(pdgMother>pdgabs || pdgMother<10) {
+                               break;
+                       }
+               }
+               if(labMom[i]==-1) {printf("mother PDG not ok for this daughter\n"); return kFALSE;} // mother PDG not ok for this daughter
+       } // end loop on daughters
+
+       // check if the candidate is signal
+       labMother=labMom[0];
+       // all labels have to be the same and !=-1
+       for(i=0; i<ndg; i++) {
+               if(labMom[i]==-1)        return kFALSE;
+               if(labMom[i]!=labMother) return kFALSE;
+       }
+
+       // check that all daughter PDGs are matched
+       if(ndgCk>0) {
+               for(i=0; i<ndg; i++) {
+                       if(pdgUsed[i]==kFALSE) return kFALSE;
+               }
+       }
+
+       mother = (AliAODMCParticle*)mcArray->At(labMother);
+       Double_t pxMother = mother->Px();
+       Double_t pyMother = mother->Py();
+       Double_t pzMother = mother->Pz();
+       // within 0.1%
+       if((TMath::Abs(pxMother-pxSumDgs)/(TMath::Abs(pxMother)+1.e-13)) > 0.00001 &&
+                       (TMath::Abs(pyMother-pySumDgs)/(TMath::Abs(pyMother)+1.e-13)) > 0.00001 &&
+                       (TMath::Abs(pzMother-pzSumDgs)/(TMath::Abs(pzMother)+1.e-13)) > 0.00001) return kFALSE;
+
+       return kTRUE;
+}
diff --git a/PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.h b/PWG3/dielectron/AliAnalysisTaskDielectronReadAODBranch.h
new file mode 100644 (file)
index 0000000..6e712c9
--- /dev/null
@@ -0,0 +1,106 @@
+#ifndef ALIANALYSISTASKDIELECTRONREADAODBRANCH_H
+#define ALIANALYSISTASKDIELECTRONREADAODBRANCH_H
+
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////////////////////////////////
+//  Class to retrieve the branch of the dielectron candidates stored in   //
+//  filtered AOD files (AliAOD.Dielectron.root). It is possible to        //
+//  apply tighter cuts to candidates stored in the branch and do the      //
+//  matching with MC truth                                                //
+//                                                                        //
+//  Contacts : G. Bruno / Giuseppe.Bruno@ba.infn.it,                      //
+//             F. Fionda / Fiorella.Fionda@ba.infn.it,                    //
+//             C. Di Giglio / Carmelo.Digiglio@ba.infn.it                 // 
+////////////////////////////////////////////////////////////////////////////
+
+#include "AliAnalysisTaskSE.h"
+
+class TNtuple;
+class TH1F;
+class TH2F;
+
+class AliAnalysisTaskDielectronReadAODBranch : public AliAnalysisTaskSE
+{
+       public:
+               AliAnalysisTaskDielectronReadAODBranch();
+               AliAnalysisTaskDielectronReadAODBranch(const char *name);
+               virtual ~AliAnalysisTaskDielectronReadAODBranch();
+
+               // Implementation of interface methods
+               virtual void UserCreateOutputObjects();
+               virtual void Init();
+               virtual void LocalInit() {Init();}
+               virtual void UserExec(Option_t *option);
+               virtual void Terminate(Option_t *option);
+               Bool_t MatchToMC(Int_t pdgabs,const TObjArray *mcArray,const Int_t *dgLabels,Int_t ndg,Int_t ndgCk,const Int_t *pdgDg) const;
+              
+                //setters
+                void SetPtLeg(Double_t cutPt){ fPtCut = cutPt;} 
+                void SetSpdFirstRequired(Bool_t spdfirst){fSpdFirstRequired = spdfirst;}
+                void SetNclsTPC(Int_t nCls){fClsTPC = nCls;}
+                void SetPairType(Int_t type){fPairType = type;}
+                void SetPtJpsi(Double_t ptjpsi) {fPtJpsi = ptjpsi;}
+                void SetInvMassSignalRegion(Double_t lowLimit, Double_t upLimit){fInvMassSignalLimits[0]=lowLimit; fInvMassSignalLimits[1]=upLimit;}
+                void SetInvMassSidebandRegion(Double_t lowLimit, Double_t upLimit){fInvMassSideBandsLimits[0]=lowLimit; fInvMassSideBandsLimits[1]=upLimit;}
+                void SetHasMC(Bool_t mcFlag) {fHasMC = mcFlag;}
+
+
+     enum {
+    kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008,
+      kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080,
+      kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800,
+      kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000,
+      kHMPIDout=0x10000,kHMPIDpid=0x20000
+  };
+
+       private:
+               AliAnalysisTaskDielectronReadAODBranch(const AliAnalysisTaskDielectronReadAODBranch &c);
+               AliAnalysisTaskDielectronReadAODBranch& operator= (const AliAnalysisTaskDielectronReadAODBranch &c);
+
+               TList      *fOutput;                 // output list with histo
+               TNtuple    *fNtupleJPSI;             // ntupla to store invariant mass and psproper of candidates
+                TH1F       *fNentries;               // number of filtered events
+               TH1F       *fInvMass;                // invariant mass of candidates in branch after tighter cuts application
+               TH1F       *fInvMassNoCuts;          // invariant mass of candidates in branch without cuts
+                TH1F       *fpsproperSignal;         // psproper distribution in the mass signal region           
+               TH1F       *fpsproperSidebands;      // psproper distribution in the mass sidebands region           
+               TH1F       *fpsproperAll;            // whole psproper distribution          
+                TH1F       *fpsproperUnder;          // psproper distribution in the lower mass sidebands region 
+                TH1F       *fpsproperUpper;          // psproper distribution in the upper mass sidebands region
+               TH2F       *fLxyVsPtleg1;            // psproper vs pt for leg1
+               TH2F       *fLxyVsPtleg2;            // psproper vs pt for leg2          
+               TH2F       *fLxyVsPt;                // psproper vs pt jpsi 
+               TH2F       *fMeeVsPt;                // invariant mass vs pt jpsi
+               TH2F       *fMeeVsLxy;               // invariant mass vs psproper
+
+               // QA plots
+               TH1F       *fprimvtxZ;               // z coord of primary vertex        
+               TH1F       *fsecvtxZ;                // z coord of secondary vertex        
+               TH1F       *fprimvtxX;               // x coord of primary vertex          
+               TH1F       *fsecvtxX;                // x coord of secondary vertex           
+               TH1F       *fprimvtxY;               // y coord of primary vertex          
+               TH1F       *fsecvtxY;                // y coord of secondary vertex          
+               TH1F       *fPt;                     // pT(J/psi) distribution               
+               TH1F       *fPtLeg1;                 // pT(leg1)  distribution. Warning: mixture of pos and neg tracks               
+               TH1F       *fPtLeg2;                 // pT(leg2)  distribution. Warning: mixture of pos and neg tracks               
+               TH2F       *fdEdxP;                  // dEdx vs P for legs
+               Bool_t     fHasMC;                   // flag for read MC branch
+                TObjArray  *fobj;                    // TObjArray with stored reconstructed candidates
+               TObjArray  *fobjMC;                  // TObjArray with MC tracks
+                // cuts on candidates
+                Double_t  fPtCut;                    // ptLeg 
+                Bool_t    fSpdFirstRequired;         // spd any/first 
+                Int_t     fClsTPC;                   // #clsTPC
+                Int_t     fPairType;                 // pair Type
+                Double_t  fPtJpsi;                   // pt jpsi
+                Double_t  *fInvMassSignalLimits;     // invariant mass signal region to extract psproper distribution
+                Double_t  *fInvMassSideBandsLimits;  // invariant mass sideband region to extract psproper distribution 
+
+               ClassDef(AliAnalysisTaskDielectronReadAODBranch,2); // AliAnalysisTaskSE for the MC association of heavy-flavour decay candidates
+};
+
+
+#endif
index 5723467..83b7bfa 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                        Basic Analysis Task                            //
index 8482d85..6718328 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#        Basic Analysis task for Dielectron         #
index 30335b9..6415794 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                        Basic Analysis Task                            //
@@ -115,6 +113,12 @@ void AliAnalysisTaskMultiDielectron::UserCreateOutputObjects()
     fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins);
     fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel.");
     fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel.");
+
+    //default names
+    fEventStat->GetXaxis()->SetBinLabel(3,"Bin3 not used");
+    fEventStat->GetXaxis()->SetBinLabel(4,"Bin4 not used");
+    fEventStat->GetXaxis()->SetBinLabel(5,"Bin5 not used");
+    
     if (fTriggerOnV0AND&&isESD) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers");
     if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter");
     if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection");
@@ -144,11 +148,13 @@ void AliAnalysisTaskMultiDielectron::UserExec(Option_t *)
   if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return;
 
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
-  AliESDInputHandler *esdHandler=0x0;
   Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class();
   Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
-  if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
-    AliDielectronVarManager::SetESDpid(esdHandler->GetESDpid());
+  
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  
+  if ( inputHandler->GetPIDResponse() ){
+    AliDielectronVarManager::SetPIDResponse( inputHandler->GetPIDResponse() );
   } else {
     //load esd pid bethe bloch parameters depending on the existance of the MC handler
     // yes: MC parameters
@@ -177,7 +183,6 @@ void AliAnalysisTaskMultiDielectron::UserExec(Option_t *)
     }
   } 
   // Was event selected ?
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
   UInt_t isSelected = AliVEvent::kAny;
   if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) {
     isSelected = inputHandler->IsEventSelected();
index 1383b94..1d8b510 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#        Basic Analysis task for Dielectron         #
index 47e6253..0c0a746 100644 (file)
@@ -59,6 +59,7 @@ The names are available via the function PairClassName(Int_t i)
 #include "AliDielectronVarManager.h"
 #include "AliDielectronTrackRotator.h"
 #include "AliDielectronDebugTree.h"
+#include "AliDielectronSignalMC.h"
 
 #include "AliDielectron.h"
 
@@ -96,6 +97,7 @@ AliDielectron::AliDielectron() :
   fPdgMother(443),
   fPdgLeg1(11),
   fPdgLeg2(11),
+  fSignalsMC(0x0),
   fNoPairing(kFALSE),
   fHistos(0x0),
   fPairCandidates(new TObjArray(10)),
@@ -103,6 +105,7 @@ AliDielectron::AliDielectron() :
   fTrackRotator(0x0),
   fDebugTree(0x0),
   fPreFilterUnlikeOnly(kFALSE),
+  fPreFilterAllSigns(kFALSE),
   fHasMC(kFALSE)
 {
   //
@@ -122,6 +125,7 @@ AliDielectron::AliDielectron(const char* name, const char* title) :
   fPdgMother(443),
   fPdgLeg1(11),
   fPdgLeg2(11),
+  fSignalsMC(0x0),
   fNoPairing(kFALSE),
   fHistos(0x0),
   fPairCandidates(new TObjArray(10)),
@@ -129,6 +133,7 @@ AliDielectron::AliDielectron(const char* name, const char* title) :
   fTrackRotator(0x0),
   fDebugTree(0x0),
   fPreFilterUnlikeOnly(kFALSE),
+  fPreFilterAllSigns(kFALSE),
   fHasMC(kFALSE)
 {
   //
@@ -146,6 +151,7 @@ AliDielectron::~AliDielectron()
   if (fHistos) delete fHistos;
   if (fPairCandidates) delete fPairCandidates;
   if (fDebugTree) delete fDebugTree;
+  if (fSignalsMC) delete fSignalsMC;
 }
 
 //________________________________________________________________
@@ -157,7 +163,10 @@ void AliDielectron::Init()
 
   if(GetHasMC()) AliDielectronMC::Instance()->SetHasMC(GetHasMC());
   
-  if (fCfManagerPair) fCfManagerPair->InitialiseContainer(fPairFilter);
+  if (fCfManagerPair) {
+    fCfManagerPair->SetSignalsMC(fSignalsMC);
+    fCfManagerPair->InitialiseContainer(fPairFilter);
+  }
   if (fTrackRotator)  {
     fTrackRotator->SetTrackArrays(&fTracks[0],&fTracks[1]);
     fTrackRotator->SetPdgLegs(fPdgLeg1,fPdgLeg2);
@@ -208,14 +217,22 @@ void AliDielectron::Process(AliVEvent *ev1, AliVEvent *ev2)
   //fill track arrays for the first event
   if (ev1){
     FillTrackArrays(ev1);
-    if ((fPreFilterUnlikeOnly) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) PairPreFilter(0, 1, fTracks[0], fTracks[1]);
+    if (((fPreFilterAllSigns)||(fPreFilterUnlikeOnly)) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) PairPreFilter(0, 1, fTracks[0], fTracks[1]);
+    if ((fPreFilterAllSigns) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) {
+                       PairPreFilter(0, 0, fTracks[0], fTracks[0]);
+                       PairPreFilter(1, 1, fTracks[1], fTracks[1]);
+               }               
   }
 
 
   //fill track arrays for the second event
   if (ev2) {
     FillTrackArrays(ev2,1);
-    if ((fPreFilterUnlikeOnly) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) PairPreFilter(2, 3, fTracks[2], fTracks[3]);
+    if (((fPreFilterAllSigns)||(fPreFilterUnlikeOnly)) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) PairPreFilter(2, 3, fTracks[2], fTracks[3]);
+    if ((fPreFilterAllSigns) && ( fPairPreFilter.GetCuts()->GetEntries()>0 )) {
+                       PairPreFilter(2, 2, fTracks[2], fTracks[2]);
+                       PairPreFilter(3, 3, fTracks[3], fTracks[3]);
+               }               
   }
 
   if (!fNoPairing){
@@ -247,16 +264,102 @@ void AliDielectron::ProcessMC()
   // Process the MC data
   //
 
+  AliDielectronMC *dieMC=AliDielectronMC::Instance();
+
+  if (fHistos) FillHistogramsMC(dieMC->GetMCEvent());
+
+  if(!fSignalsMC) return;
   //loop over all MC data and Fill the CF container if it exist
   if (!fCfManagerPair) return;
   fCfManagerPair->SetPdgMother(fPdgMother);
-  AliDielectronMC *dieMC=AliDielectronMC::Instance();
-  for (Int_t ipart=0; ipart<dieMC->GetNMCTracks();++ipart){
-    //TODO: MC truth cut properly!!!
-    AliVParticle *mcPart=dieMC->GetMCTrackFromMCEvent(ipart);
-    if (!dieMC->IsMCMotherToEE(mcPart, fPdgMother)) continue;
-    fCfManagerPair->FillMC(mcPart);
+  if(!fCfManagerPair->GetStepForMCtruth()) return;
+
+  // signals to be studied
+  Int_t nSignals = fSignalsMC->GetEntries();
+
+  // initialize 2D arrays of labels for particles from each MC signal
+  Int_t** labels1;      // labels for particles satisfying branch 1
+  Int_t** labels2;      // labels for particles satisfying branch 2
+  Int_t** labels12;     // labels for particles satisfying both branches
+  labels1 = new Int_t*[nSignals];
+  labels2 = new Int_t*[nSignals];
+  labels12 = new Int_t*[nSignals];
+  Int_t* indexes1=new Int_t[nSignals];
+  Int_t* indexes2=new Int_t[nSignals];
+  Int_t* indexes12=new Int_t[nSignals];
+  for(Int_t isig=0;isig<nSignals;++isig) {
+    *(labels1+isig) = new Int_t[dieMC->GetNMCTracks()];
+    *(labels2+isig) = new Int_t[dieMC->GetNMCTracks()];
+    *(labels12+isig) = new Int_t[dieMC->GetNMCTracks()];
+    for(Int_t ip=0; ip<dieMC->GetNMCTracks();++ip) {
+      labels1[isig][ip] = -1;
+      labels2[isig][ip] = -1;
+      labels12[isig][ip] = -1;
+    }
+    indexes1[isig]=0;
+    indexes2[isig]=0;
+    indexes12[isig]=0;
   }
+
+  Bool_t truth1=kFALSE;
+  Bool_t truth2=kFALSE;
+  // loop over the MC tracks
+  for(Int_t ipart=0; ipart<dieMC->GetNMCTracks(); ++ipart) {
+    for(Int_t isig=0; isig<nSignals; ++isig) {       // loop over signals
+      // Proceed only if this signal is required in the pure MC step
+      // NOTE: Some signals can be satisfied by many particles and this leads to high
+      //       computation times (e.g. secondary electrons from the GEANT transport). Be aware of this!!
+      if(!((AliDielectronSignalMC*)fSignalsMC->At(isig))->GetFillPureMCStep()) continue;
+
+      truth1 = dieMC->IsMCTruth(ipart, (AliDielectronSignalMC*)fSignalsMC->At(isig), 1);
+      truth2 = dieMC->IsMCTruth(ipart, (AliDielectronSignalMC*)fSignalsMC->At(isig), 2);
+
+      // particles satisfying both branches are treated separately to avoid double counting during pairing
+      if(truth1 && truth2) {
+       labels12[isig][indexes12[isig]] = ipart;
+       ++indexes12[isig];
+      }
+      else {
+       if(truth1) {
+         labels1[isig][indexes1[isig]] = ipart;
+         ++indexes1[isig];
+       }
+       if(truth2) {
+         labels2[isig][indexes2[isig]] = ipart;
+         ++indexes2[isig];
+       }
+      }
+    }
+  }  // end loop over MC particles
+
+  // Do the pairing and fill the CF container with pure MC info
+  for(Int_t isig=0; isig<nSignals; ++isig) {
+    // mix the particles which satisfy only one of the signal branches
+    for(Int_t i1=0;i1<indexes1[isig];++i1) {
+      for(Int_t i2=0;i2<indexes2[isig];++i2) {
+       fCfManagerPair->FillMC(labels1[isig][i1], labels2[isig][i2], isig);
+      }
+    }
+    // mix the particles which satisfy both branches
+    for(Int_t i1=0;i1<indexes12[isig];++i1) {
+      for(Int_t i2=0; i2<i1; ++i2) {
+       fCfManagerPair->FillMC(labels12[isig][i1], labels12[isig][i2], isig);
+      }
+    }
+  }    // end loop over signals
+
+  // release the memory
+  for(Int_t isig=0;isig<nSignals;++isig) {
+    delete [] *(labels1+isig);
+    delete [] *(labels2+isig);
+    delete [] *(labels12+isig);
+  }
+  delete [] labels1;
+  delete [] labels2;
+  delete [] labels12;
+  delete [] indexes1;
+  delete [] indexes2;
+  delete [] indexes12;
 }
 
 //________________________________________________________________
@@ -281,6 +384,23 @@ void AliDielectron::FillHistogramsTracks(TObjArray **tracks)
     }
   }
 }
+
+
+//________________________________________________________________
+void AliDielectron::FillHistogramsMC(const AliMCEvent *ev)
+{
+  //
+  // Fill Histogram information for MCEvents
+  //
+
+  Double_t values[AliDielectronVarManager::kNMaxValues];
+  // Fill event information
+  AliDielectronVarManager::Fill(ev, values);
+  if (fHistos->GetHistogramList()->FindObject("MCEvent"))
+    fHistos->FillClass("MCEvent", AliDielectronVarManager::kNMaxValues, values);
+}
+
+
 //________________________________________________________________
 void AliDielectron::FillHistograms(const AliVEvent *ev)
 {
@@ -450,6 +570,8 @@ void AliDielectron::PairPreFilter(Int_t arr1, Int_t arr2, TObjArray &arrTracks1,
                           track2, fPdgLeg2);
       candidate.SetType(pairIndex);
       candidate.SetLabel(AliDielectronMC::Instance()->GetLabelMotherWithPdg(&candidate,fPdgMother));
+      //relate to the production vertex
+//       if (AliDielectronVarManager::GetKFVertex()) candidate.SetProductionVertex(*AliDielectronVarManager::GetKFVertex());
       
       //pair cuts
       UInt_t cutMask=fPairPreFilter.IsSelected(&candidate);
@@ -458,7 +580,7 @@ void AliDielectron::PairPreFilter(Int_t arr1, Int_t arr2, TObjArray &arrTracks1,
       if (cutMask!=selectedMask) continue;
       if (fCfManagerPair) fCfManagerPair->Fill(selectedMaskPair+1 ,&candidate);
       accepted=kTRUE;
-      FillHistogramsPair(&candidate,kTRUE);
+      if (fHistos) FillHistogramsPair(&candidate,kTRUE);
       //remove the tracks from the Track arrays
       arrTracks2.AddAt(0x0,itrack2);
       //in case of like sign remove the track from both arrays!
@@ -503,7 +625,7 @@ void AliDielectron::PairPreFilter(Int_t arr1, Int_t arr2, TObjArray &arrTracks1,
     }
   }
   //For unlike-sign monitor track-cuts:
-  if (arr1!=arr2) {
+  if (arr1!=arr2&&fHistos) {
     TObjArray *unlikesignArray[2] = {&arrTracks1,&arrTracks2};
     FillHistogramsTracks(unlikesignArray);
   }
@@ -520,7 +642,7 @@ void AliDielectron::FillPairArrays(Int_t arr1, Int_t arr2)
   TObjArray arrTracks2=fTracks[arr2];
 
   //process pre filter if set
-  if ((!fPreFilterUnlikeOnly) && ( fPairPreFilter.GetCuts()->GetEntries()>0 ))  PairPreFilter(arr1, arr2, arrTracks1, arrTracks2);
+  if ((!fPreFilterAllSigns) && (!fPreFilterUnlikeOnly) && ( fPairPreFilter.GetCuts()->GetEntries()>0 ))  PairPreFilter(arr1, arr2, arrTracks1, arrTracks2);
   
   Int_t pairIndex=GetPairIndex(arr1,arr2);
 
@@ -610,3 +732,15 @@ void AliDielectron::SaveDebugTree()
   if (fDebugTree) fDebugTree->DeleteStreamer();
 }
 
+
+//__________________________________________________________________
+void AliDielectron::AddSignalMC(AliDielectronSignalMC* signal) {
+  //
+  //  Add an MC signal to the signals list
+  //
+  if(!fSignalsMC) {
+    fSignalsMC = new TObjArray();
+    fSignalsMC->SetOwner();
+  }
+  fSignalsMC->Add(signal);
+}
index a33d3dc..9229ff0 100644 (file)
 #include "AliDielectronHistos.h"
 
 class AliVEvent;
+class AliMCEvent;
 class THashList;
 class AliDielectronCF;
 class AliDielectronDebugTree;
 class AliDielectronTrackRotator;
 class AliDielectronPair;
+class AliDielectronSignalMC;
 
 //________________________________________________________________
 class AliDielectron : public TNamed {
@@ -84,13 +86,16 @@ public:
   AliDielectronCF* GetCFManagerPair() const { return fCfManagerPair; }
 
   void SetPreFilterUnlikeOnly(Bool_t setValue=kTRUE){fPreFilterUnlikeOnly=setValue;};
+  void SetPreFilterAllSigns(Bool_t setValue=kTRUE){fPreFilterAllSigns=setValue;};
 
   void SetTrackRotator(AliDielectronTrackRotator * const rot) { fTrackRotator=rot; }
   AliDielectronTrackRotator* GetTrackRotator() const { return fTrackRotator; }
 
   void SetHasMC(Bool_t hasMC) { fHasMC = hasMC; }
   Bool_t GetHasMC() const     { return fHasMC;  }
-  
+
+  void AddSignalMC(AliDielectronSignalMC* signal);  
+
   void SetDebugTree(AliDielectronDebugTree * const tree) { fDebugTree=tree; }
   
   static const char* TrackClassName(Int_t i) { return (i>=0&&i<4)?fgkTrackClassNames[i]:""; }
@@ -111,6 +116,8 @@ private:
   Int_t fPdgLeg1;       // pdg code leg1
   Int_t fPdgLeg2;       // pdg code leg2
 
+  TObjArray* fSignalsMC;      // array of AliDielectronSignalMC
+
   Bool_t fNoPairing;    // if to skip pairing, can be used for track QA only
     
   AliDielectronHistos *fHistos;   // Histogram manager
@@ -131,6 +138,7 @@ private:
   AliDielectronDebugTree *fDebugTree;  // Debug tree output
 
   Bool_t fPreFilterUnlikeOnly;  //Apply PreFilter either in +- or to ++/--/+- individually
+  Bool_t fPreFilterAllSigns;  //Apply PreFilter find in  ++/--/+- and remove from all
   Bool_t fHasMC;                //If we run with MC, at the moment only needed in AOD
   
   void FillTrackArrays(AliVEvent * const ev, Int_t eventNr=0);
@@ -151,6 +159,7 @@ private:
   void ProcessMC();
   
   void  FillHistograms(const AliVEvent *ev);
+  void  FillHistogramsMC(const AliMCEvent *ev);
   void  FillHistogramsPair(AliDielectronPair *pair,Bool_t fromPreFilter=kFALSE);
   void  FillHistogramsTracks(TObjArray **tracks);
 
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEle.cxx b/PWG3/dielectron/AliDielectronBtoJPSItoEle.cxx
new file mode 100644 (file)
index 0000000..be4446c
--- /dev/null
@@ -0,0 +1,123 @@
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//-------------------------------------------------------------------------
+//                      Class AliDielectronBtoJPSItoEle
+//                  Unbinned log-likelihood fit analysis class
+//
+//                             Origin: C.Di Giglio
+//        Contact: Carmelo.Digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it
+//-------------------------------------------------------------------------
+class TH1F ;
+#include "TNtuple.h"
+#include "TMath.h"
+
+#include "AliDielectronBtoJPSItoEleCDFfitFCN.h"
+#include "AliDielectronBtoJPSItoEleCDFfitHandler.h"
+#include "AliDielectronBtoJPSItoEle.h"
+#include "AliLog.h"
+
+ClassImp(AliDielectronBtoJPSItoEle)
+
+//_______________________________________________________________________________ 
+AliDielectronBtoJPSItoEle::AliDielectronBtoJPSItoEle() :
+fFCNfunction(0),
+fPtBin(0),
+fMCtemplate(0)
+{
+  //
+  // default constructor
+  //
+}
+//___________________________________________________________________________________
+AliDielectronBtoJPSItoEle::AliDielectronBtoJPSItoEle(const AliDielectronBtoJPSItoEle& source) :
+TNamed(source),
+fFCNfunction(source.fFCNfunction),
+fPtBin(source.fPtBin),
+fMCtemplate(source.fMCtemplate)
+{
+  //
+  // copy constructor
+  //
+}
+//_________________________________________________________________________________________________
+
+AliDielectronBtoJPSItoEle &AliDielectronBtoJPSItoEle::operator=(const AliDielectronBtoJPSItoEle& source)
+{
+  //
+  // assignment operator
+  //
+  if(&source == this) return *this;
+  fFCNfunction = source.fFCNfunction;
+  fPtBin = source.fPtBin;
+  fMCtemplate = source.fMCtemplate;
+
+  return *this;
+}
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEle::~AliDielectronBtoJPSItoEle()
+{
+  //
+  // destructor
+  //
+  delete fFCNfunction;
+  delete fMCtemplate;
+}
+//_________________________________________________________________________________________________
+Int_t AliDielectronBtoJPSItoEle::DoMinimization()
+{
+  //
+  // performs the minimization
+  //
+  Int_t iret=fFCNfunction->DoMinimization();
+
+  return iret;
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEle::ReadCandidates(TNtuple* nt, Double_t* &pseudoproper,Double_t* &invmass, Int_t& ncand)
+{
+  //
+  // Read N-tuple with X and M values
+  //
+  Float_t mJPSI = 0; Float_t x = 0;
+  Int_t nentries = 0;
+  ncand=0;
+  nt->SetBranchAddress("Mass",&mJPSI);
+  nt->SetBranchAddress("Xdecaytime",&x);
+  nentries = (Int_t)nt->GetEntries();
+  pseudoproper = new Double_t[nentries];
+  invmass      = new Double_t[nentries];
+  for(Int_t i = 0; i < nentries; i++) {
+      nt->GetEntry(i);
+      ncand++;
+      pseudoproper[i]=(Double_t)(10000*x);
+      invmass[i]=(Double_t)mJPSI;
+    }
+
+ return; 
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEle::SetCsiMC()
+{
+  //
+  // Sets X distribution used as MC template for JPSI from B
+  //
+  fFCNfunction->LikelihoodPointer()->SetCsiMC(fMCtemplate);
+
+  return;
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEle::SetFitHandler(Double_t* x /*pseudoproper*/, Double_t* m /*inv mass*/, Int_t ncand /*candidates*/) 
+{
+  //
+  // Create the fit handler object to play with different params of the fitting function
+  //
+
+  fFCNfunction = new AliDielectronBtoJPSItoEleCDFfitHandler(x,m,ncand);
+  if(!fFCNfunction) {
+
+     AliInfo("fFCNfunction not istanziated  ---> nothing done");
+     return;
+
+     } 
+}
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEle.h b/PWG3/dielectron/AliDielectronBtoJPSItoEle.h
new file mode 100644 (file)
index 0000000..cdd0fed
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef ALIDIELECTRONBTOJPSITOELE_H\r
+#define ALIDIELECTRONBTOJPSITOELE_H\r
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice                               */\r
+\r
+//-------------------------------------------------------------------------\r
+//                         Class AliDielectronBtoJPSItoEle\r
+//                  Unbinned log-likelihood fit analysis class\r
+//\r
+//                             Origin: C.Di Giglio\r
+//       Contact: Carmelo.Digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it\r
+//-------------------------------------------------------------------------\r
+\r
+#include "TH1F.h"\r
+\r
+class TNtuple ;\r
+class AliDielectronBtoJPSItoEleCDFfitHandler ; \r
+class AliDielectronBtoJPSItoEleCDFfitFCN ; \r
+\r
+class AliDielectronBtoJPSItoEle : public TNamed {\r
+       public:\r
+               //\r
+               AliDielectronBtoJPSItoEle();\r
+               AliDielectronBtoJPSItoEle(const AliDielectronBtoJPSItoEle& source);\r
+               AliDielectronBtoJPSItoEle& operator=(const AliDielectronBtoJPSItoEle& source);\r
+               virtual ~AliDielectronBtoJPSItoEle();\r
+\r
+               Int_t DoMinimization();\r
+               void ReadCandidates(TNtuple* nt, Double_t* &x, Double_t* &m, Int_t& n); // primary JPSI + secondary JPSI + bkg couples\r
+\r
+               void SetPtBin(Int_t BinNum) { fPtBin = BinNum ; }\r
+               void SetCsiMC();\r
+               void SetFitHandler(Double_t* x /*pseudoproper*/, Double_t* m /*inv mass*/, Int_t ncand /*candidates*/); \r
+               void CloneMCtemplate(const TH1F* MCtemplate) {fMCtemplate = (TH1F*)MCtemplate->Clone("fMCtemplate");}\r
+               Double_t* GetResolutionConstants(Double_t* resolutionConst);\r
+               AliDielectronBtoJPSItoEleCDFfitHandler* GetCDFFitHandler() const { return fFCNfunction ; }\r
+               Int_t GetPtBin() const { return fPtBin ; }\r
+\r
+       private:\r
+               //\r
+               AliDielectronBtoJPSItoEleCDFfitHandler* fFCNfunction; //! pointer to the interface class\r
+               Int_t fPtBin;                               // number of pt bin in which the analysis is performes\r
+               TH1F* fMCtemplate;                            //! template of the MC distribution for the x distribution of the secondary J/psi\r
+\r
+               ClassDef(AliDielectronBtoJPSItoEle,1); // AliDielectronBtoJPSItoEle class\r
+};\r
+\r
+#endif\r
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.cxx b/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.cxx
new file mode 100644 (file)
index 0000000..380099b
--- /dev/null
@@ -0,0 +1,521 @@
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+#include <TFormula.h>
+#include <TF1.h>
+#include <TCanvas.h>
+#include <TMath.h>
+
+#include <AliLog.h>
+
+#include "AliDielectronBtoJPSItoEleCDFfitFCN.h"
+
+//_________________________________________________________________________
+//                        Class AliDielectronBtoJPSItoEleCDFfitFCN
+//                   Definition of main function used in 
+//                     unbinned log-likelihood fit for
+//                 the channel B -> JPsi + X -> e+e- + X
+//      
+//                           Origin: C.Di Giglio
+//       Contact: Carmelo.Digiglio@ba.infn.it , Giuseppe.Bruno@ba.infn.it
+//_________________________________________________________________________
+
+ClassImp(AliDielectronBtoJPSItoEleCDFfitFCN)
+
+       //_________________________________________________________________________________________________
+       AliDielectronBtoJPSItoEleCDFfitFCN::AliDielectronBtoJPSItoEleCDFfitFCN() :
+               fFPlus(0.),
+               fFMinus(0.),
+               fFSym(0.),
+               fintmMassSig(1.),
+               fintmMassBkg(1.),
+               fhCsiMC(0x0),
+               fMassWndHigh(0.),
+               fMassWndLow(0.),
+               fCrystalBallParam(kFALSE)
+{
+       //
+       // constructor
+       //
+       SetCrystalBallFunction(kFALSE);
+       SetMassWndHigh(0.2);
+       SetMassWndLow(0.5);
+       for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = 0.;
+       fParameters[9] = 1.;fParameters[11] = 1.;fParameters[12] = 1.;
+       for(Int_t index=0; index<4; index++) fResolutionConstants[index] = 0.;
+       AliInfo("Instance of AliDielectronBtoJPSItoEleCDFfitFCN-class created");
+}
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitFCN::AliDielectronBtoJPSItoEleCDFfitFCN(const AliDielectronBtoJPSItoEleCDFfitFCN& source) :
+       TNamed(source),
+       fFPlus(source.fFPlus),
+       fFMinus(source.fFMinus),
+       fFSym(source.fFSym),
+       fintmMassSig(source.fintmMassSig),
+       fintmMassBkg(source.fintmMassBkg),
+       fhCsiMC(source.fhCsiMC),
+       fMassWndHigh(source.fMassWndHigh),
+       fMassWndLow(source.fMassWndLow),
+       fCrystalBallParam(source.fCrystalBallParam)
+{
+       //
+       // Copy constructor
+       //
+       for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = source.fParameters[iPar];
+       for(Int_t index=0; index<4; index++) fResolutionConstants[index] = source.fResolutionConstants[index];
+}
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitFCN& AliDielectronBtoJPSItoEleCDFfitFCN::operator=(const AliDielectronBtoJPSItoEleCDFfitFCN& source) 
+{
+       //
+       // Assignment operator
+       //
+       if(&source == this) return *this;
+       fFPlus = source.fFPlus;
+       fFMinus = source.fFMinus;
+       fFSym = source.fFSym;
+       fintmMassSig = source.fintmMassSig;
+       fintmMassBkg = source.fintmMassBkg;
+       fhCsiMC = source.fhCsiMC;
+       fCrystalBallParam = source.fCrystalBallParam;
+
+       for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = source.fParameters[iPar];
+       for(Int_t index=0; index<4; index++) fResolutionConstants[index] = source.fResolutionConstants[index];
+
+       return *this;
+}  
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitFCN::~AliDielectronBtoJPSItoEleCDFfitFCN()
+{
+       //
+       // Default destructor
+       //
+
+       delete fhCsiMC;
+       for(Int_t iPar = 0; iPar < 20; iPar++) fParameters[iPar] = 0.;
+       for(Int_t index=0; index<4; index++) fResolutionConstants[index] = 0.;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateLikelihood(const Double_t* pseudoproperdecaytime,
+               const Double_t* invariantmass, const Int_t ncand) const
+{
+       //
+       // This function evaluates the Likelihood fnction
+       // It returns the -Log(of the likelihood function)
+       //
+       Double_t f = 0.;
+       Double_t ret = 0.;
+
+       for(Int_t i=0; i < ncand; i++) {
+               f = EvaluateCDFfuncNorm(pseudoproperdecaytime[i],invariantmass[i]);
+               if(f <= 0.) continue;  
+               ret += -1*TMath::Log(f);  
+       }
+       return ret;
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitFCN::SetAllParameters(const Double_t* parameters)
+{ 
+       //
+       // Sets array of FCN parameters
+       //
+       for(Int_t index = 0; index < 20; index++) fParameters[index] = parameters[index];
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitFCN::ComputeMassIntegral() 
+{ 
+       //
+       // this function compute the integral of the likelihood function 
+       // (theoretical function) in order to normalize it to unity
+       //
+       Double_t npm = 20000.;
+       Double_t stepm;
+       Double_t mx=0.;
+       stepm = (fMassWndHigh-fMassWndLow)/npm; 
+       // compute integrals for  invariant mass terms        
+
+       Double_t iMassSig;
+       Double_t intmMassSig = 0.0;
+       Double_t summMassSig = 0.0;
+       for(iMassSig = 1.0;  iMassSig<= npm/2.; iMassSig++)  {
+               mx = fMassWndLow + (iMassSig - .5)*stepm;
+               summMassSig += EvaluateCDFInvMassSigDistr(mx);
+               mx = fMassWndHigh - (iMassSig - .5)*stepm;
+               summMassSig += EvaluateCDFInvMassSigDistr(mx);
+       }
+       intmMassSig = summMassSig*stepm;
+       SetIntegralMassSig(intmMassSig);
+       //
+       Double_t iMassBkg;
+       Double_t intmMassBkg = 0.0;
+       Double_t summMassBkg = 0.0;
+       for(iMassBkg = 1.0; iMassBkg <= npm/2.; iMassBkg++)  {
+               mx = fMassWndLow + (iMassBkg - .5)*stepm;
+               summMassBkg += EvaluateCDFInvMassBkgDistr(mx);
+               mx = fMassWndHigh - (iMassBkg - .5)*stepm;
+               summMassBkg += EvaluateCDFInvMassBkgDistr(mx);
+       }
+       intmMassBkg = summMassBkg*stepm;
+       SetIntegralMassBkg(intmMassBkg);
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitFCN::PrintStatus()
+{
+       //
+       //  Print the parameters of the fits 
+       //
+       printf("\n");
+       // background param
+       printf("actual value of fWeightRes------------------------------------->> | %f \n", GetResWeight());
+       printf("actual value of fPos ------------------------------------------>> | %f \n", GetFPlus());
+       printf("actual value of fNeg ------------------------------------------>> | %f \n", GetFMinus());
+       printf("actual value of fSym ------------------------------------------>> | %f \n", GetFSym()); 
+       printf("actual value of fOneOvLamPlus --------------------------------->> | %f \n", GetLamPlus());
+       printf("actual value of fOneOvLamMinus -------------------------------->> | %f \n", GetLamMinus());
+       printf("actual value of fOneOvLamSym ---------------------------------->> | %f \n", GetLamSym());
+       printf("actual value of fFractionJpsiFromBeauty ----------------------->> | %f \n", GetFractionJpsiFromBeauty());
+       printf("actual value of fFsig ----------------------------------------->> | %f \n", GetFsig());
+
+       if(fCrystalBallParam){
+               printf("actual value of fCrystalBallMmean ----------------------------->> | %f \n", GetCrystalBallMmean());
+               printf("actual value of fCrystalBallNexp ------------------------------>> | %f \n", GetCrystalBallNexp());
+               printf("actual value of fCrystalBallSigma ----------------------------->> | %f \n", GetCrystalBallSigma());
+               printf("actual value of fCrystalBallAlpha ----------------------------->> | %f \n", GetCrystalBallAlpha());
+               printf("actual value of fCrystalBallNorm  ----------------------------->> | %f \n", GetCrystalBallNorm());
+       }else{
+               printf("actual value of fMpv ------------------------------------------>> | %f \n", GetCrystalBallMmean());
+               printf("actual value of fConstRovL ------------------------------------>> | %f \n", GetCrystalBallNexp());
+               printf("actual value of fSigmaL --------------------------------------->> | %f \n", GetCrystalBallSigma());
+               printf("actual value of fSigmaR --------------------------------------->> | %f \n", GetCrystalBallAlpha());
+       }
+
+       // back Mass func
+       printf("actual value of normBkg ----------------------------------------->> | %f \n", GetBkgInvMassNorm());
+       printf("actual value of meanBkg ----------------------------------------->> | %f \n", GetBkgInvMassMean());
+       printf("actual value of slopeBkg ---------------------------------------->> | %f \n", GetBkgInvMassSlope());
+       printf("actual value of constBkg ---------------------------------------->> | %f \n", GetBkgInvMassConst());
+       // resolution func
+       printf("actual value of norm1Gauss -------------------------------------->> | %f \n",GetNormGaus1ResFunc());
+       printf("actual value of norm2Gauss -------------------------------------->> | %f \n",GetNormGaus2ResFunc());
+
+       printf("\n");
+       // integrals constants
+       printf("Actual value of normalization integral for MassSig ---------------->> | %f \n", GetIntegralMassSig());
+       printf("Actual value of normalization integral for MassBkg ---------------->> | %f \n", GetIntegralMassBkg());
+
+       printf("\n");
+}
+//_________________________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitFCN::SetResolutionConstants(Double_t* resolutionConst)
+{
+       //
+       // Resolution function is parametrized as the sum of two gaussian
+       //
+       fResolutionConstants[0]  = resolutionConst[0]; // mean 1
+       fResolutionConstants[1]  = resolutionConst[1]; // sigma 1
+       fResolutionConstants[2]  = resolutionConst[2]; // mean 2
+       fResolutionConstants[3]  = resolutionConst[3]; // sigma 2
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfunc(Double_t x, Double_t m) const 
+{
+       return fParameters[8]*EvaluateCDFfuncSignalPart(x,m) + (1. - fParameters[8])*EvaluateCDFfuncBkgPart(x,m);
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncNorm(Double_t x, Double_t m) const
+{
+       return EvaluateCDFfunc(x,m);
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncSignalPart(Double_t x, Double_t m) const 
+{
+       return EvaluateCDFDecayTimeSigDistr(x)*(EvaluateCDFInvMassSigDistr(m)/fintmMassSig); 
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeSigDistr(Double_t x) const
+{
+       //
+       // Implementation of the Background part of the Likelyhood function
+       // 
+
+       Double_t retvalue = 0.;
+       Double_t funBnorm = FunB(x);
+       Double_t funPnorm = ResolutionFunc(x);
+       retvalue = fParameters[7]*funBnorm + (1. - fParameters[7])*funPnorm;
+       return retvalue;
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFInvMassSigDistr(Double_t m) const
+{ 
+       //
+       // Parametrization of signal part invariant mass distribution
+       // It can be either Crystal Ball function or sum of two Landau
+       //
+
+       Double_t fitval = 0.;
+
+       if(fCrystalBallParam){
+               Double_t t = (m-fParameters[9])/fParameters[11]; ;
+               if (fParameters[12] < 0) t = -t;
+
+               Double_t absAlpha = TMath::Abs((Double_t)fParameters[12]);
+
+               if (t >= -absAlpha) {
+                       return fParameters[13]*TMath::Exp(-0.5*t*t);
+               }
+               else {
+                       Double_t a =  TMath::Power(fParameters[10]/absAlpha,fParameters[10])* TMath::Exp(-0.5*absAlpha*absAlpha);
+                       Double_t b= fParameters[10]/absAlpha - absAlpha;
+                       fitval = (fParameters[13]*a/TMath::Power(b - t, fParameters[10]));
+                       return fitval;
+               }
+       }else{
+               Double_t t=-1*m;
+               Double_t tmpv=-1*fParameters[9];
+               fitval=TMath::Sqrt(TMath::Landau(t,tmpv,fParameters[11]));
+               fitval += fParameters[10]*(TMath::Landau(m,fParameters[9],fParameters[12]));
+               return fitval;
+       }
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunB(Double_t x) const  
+{
+       //  
+       // Parameterisation of the fit function for the x part of the Background
+       //
+       Double_t np = 1000.0;
+       Double_t sc = 10.;
+       Double_t sigma3 = 1000.; // valore usato nella macro
+       Double_t xprime;
+       Double_t sum = 0.0;
+       Double_t xlow,xupp;
+       Double_t step;
+       Double_t i;
+       xlow = x - sc * sigma3 ;
+       xupp = x + sc * sigma3 ;
+       step = (xupp-xlow) / np;
+       Double_t csiMCxprime = 0.;
+       Double_t resolutionxdiff = 0.;
+       Double_t xdiff = 0.;
+
+       for(i=1.0; i<=np; i++){
+               xprime = xlow + (i-.5) * step;
+               csiMCxprime = CsiMC(xprime);
+               xdiff = xprime - x;
+               resolutionxdiff = ResolutionFunc(xdiff); // normalized value
+               sum += csiMCxprime * resolutionxdiff;
+       }
+
+       return step * sum ;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunP(Double_t x) const 
+{
+       //
+       //  Parameterisation of the Prompt part for the x distribution
+       //
+       return ResolutionFunc(x);
+}
+
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::CsiMC(Double_t x) const 
+{
+       //
+       //  Distribution (template) of the x distribution for the x variable 
+       //  for the J/psi coming from Beauty hadrons
+       //
+       Double_t returnvalue = 0.;
+
+       if((fhCsiMC->FindBin(x) > 0) && (fhCsiMC->FindBin(x) < fhCsiMC->GetNbinsX()+1))  
+               returnvalue = fhCsiMC->Interpolate(x);
+
+       return returnvalue;
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFfuncBkgPart(Double_t x,Double_t m) const 
+{
+       //
+       // Return the part of the likelihood function for the background hypothesis
+       //
+       return EvaluateCDFDecayTimeBkgDistr(x)*(EvaluateCDFInvMassBkgDistr(m)/fintmMassBkg);
+}  
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeBkgDistr(Double_t x) const 
+{
+       //
+       // it returns the value of the probability to have a given x for the background 
+       //
+
+       Double_t ret = fParameters[0]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*ResolutionFunc(x) + fParameters[1]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgPos(x) +  fParameters[2]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgNeg(x) + fParameters[3]/(fParameters[0]+fParameters[1]+fParameters[2]+fParameters[3])*FunBkgSym(x);
+       return ret;
+}
+
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFInvMassBkgDistr(Double_t m) const 
+{
+       //
+       // it returns the value of the probability to have a given mass for the background
+       //
+       Double_t value = 0.;
+       value = fParameters[14]*TMath::Exp(-1*(m-fParameters[15])/fParameters[16]) + fParameters[17];  
+       return value;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgPos(Double_t x) const 
+{
+       //
+       // exponential with positive slopes for the background part (x)
+       //
+
+       Double_t np = 1000.0;
+       Double_t sc = 10.;      
+       Double_t sigma3 = 1000.; // valore usato nella macro 
+       Double_t xprime;
+       Double_t sum = 0.0;
+       Double_t xlow,xupp;
+       Double_t step;
+       Double_t i;
+       xlow = x - sc * sigma3 ;
+       xupp = x + sc * sigma3 ;
+       step = (xupp-xlow) / np;
+
+       for(i=1.0; i<=np/2; i++) {
+               xprime = xlow + (i-.5) * step;
+               if (xprime > 0) {sum += fParameters[4] * TMath::Exp(-1*xprime*fParameters[4])*(ResolutionFunc(xprime-x));}
+               xprime = xupp - (i-.5) * step;
+               if (xprime > 0) {sum += fParameters[4] * TMath::Exp(-1*xprime*fParameters[4])*(ResolutionFunc(xprime-x));}
+       }
+
+       return step * sum ;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgNeg(Double_t x) const 
+{
+       //
+       // exponential with negative slopes for the background part (x)
+       //
+       Double_t np = 1000.0;
+       Double_t sc = 10.;      
+       Double_t sigma3 = 1000.; 
+       Double_t xprime;
+       Double_t sum = 0.0;
+       Double_t xlow,xupp;
+       Double_t step;
+       Double_t i;
+       xlow = x - sc * sigma3 ;
+       xupp = x + sc * sigma3 ;
+       step = (xupp-xlow) / np;
+
+       for(i=1.0; i<=np/2; i++) {
+
+               xprime = xlow + (i-.5) * step;
+               if (xprime < 0) {sum += fParameters[5] * TMath::Exp(xprime*fParameters[5]) * (ResolutionFunc(xprime-x));}
+
+               xprime = xupp - (i-.5) * step;
+               if (xprime < 0) {sum += fParameters[5] * TMath::Exp(xprime*fParameters[5]) * (ResolutionFunc(xprime-x));}
+       }
+
+       return step * sum ;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::FunBkgSym(Double_t x) const 
+{
+       //
+       // exponential with both positive and negative slopes for the background part (x)
+       //
+       Double_t np = 1000.0;
+       Double_t sc = 10.;      
+       Double_t sigma3 = 1000.; 
+       Double_t xprime;
+       Double_t sum1 = 0.0;
+       Double_t sum2 = 0.0;
+       Double_t xlow,xupp;
+       Double_t step;
+       Double_t i;
+       xlow = x - sc * sigma3 ;
+       xupp = x + sc * sigma3 ;
+       step = (xupp-xlow) / np;
+
+       for(i=1.0; i<=np/2; i++) {
+
+               xprime = xlow + (i-.5) * step;
+               if (xprime > 0) {sum1 += 0.5 * fParameters[6]*TMath::Exp(-1*xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
+               if (xprime < 0) {sum2 += 0.5 * fParameters[6]*TMath::Exp(xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
+
+               xprime = xupp - (i-.5) * step;
+               if (xprime > 0) {sum1 += 0.5 * fParameters[6]*TMath::Exp(-1*xprime*fParameters[6]) * (ResolutionFunc(xprime-x));} 
+               if (xprime < 0) {sum2 += 0.5 * fParameters[6]*TMath::Exp(xprime*fParameters[6]) * (ResolutionFunc(xprime-x));}
+       }
+
+       return step*(sum1 + sum2) ;
+}
+//_________________________________________________________________________________________________
+Double_t AliDielectronBtoJPSItoEleCDFfitFCN::ResolutionFunc(Double_t x) const 
+{
+       //
+       // parametrization with 2 gaus
+       //
+       Double_t ret = 0.;
+       Double_t mean1 = fResolutionConstants[0]; 
+       Double_t mean2 = fResolutionConstants[2];
+       Double_t norm1 = fParameters[18];
+       Double_t sigma1 = fResolutionConstants[1];
+       Double_t sigma2 = fResolutionConstants[3]; 
+       Double_t norm2 = fParameters[19];
+
+       ret = (norm1/(norm1+norm2))*((1/(sigma1*TMath::Sqrt(2*TMath::Pi())))*TMath::Exp(-0.5*((x-mean1)/sigma1)*((x-mean1)/sigma1)))+(norm2/(norm1+norm2))*((1/(sigma2*TMath::Sqrt(2*TMath::Pi())))*TMath::Exp(-0.5*((x-mean2)/sigma2)*((x-mean2)/sigma2))); 
+
+       return ret;
+}
+
+//_________________________________________________________________________________________________
+TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetCsiMC(Double_t xmin, Double_t xmax) 
+{
+       // return the pointer to the templateMC function 
+       TF1* templateMC = new TF1("MCtemplate",this,&AliDielectronBtoJPSItoEleCDFfitFCN::CsiMCfunc,xmin,xmax,0);
+       templateMC->SetNpx(5000);
+        return (TF1*)templateMC->Clone();
+}
+
+//__________________________________________________________________________________________________
+TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetResolutionFunc(Double_t xmin, Double_t xmax){
+       // return the pointer to the resolution function
+       TF1* resFunc = new TF1("resolutionFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::ResolutionFuncf,xmin,xmax,0);
+       resFunc->SetNpx(5000);
+        return (TF1*)resFunc->Clone();
+}
+
+//___________________________________________________________________________________________________
+TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetEvaluateCDFDecayTimeBkgDistr(Double_t xmin, Double_t xmax){
+       // return the pointer to the background x distribution function
+       TF1 *backFunc = new TF1("backFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeBkgDistrFunc,xmin,xmax,0);
+       backFunc->SetNpx(5000);
+        return (TF1*)backFunc->Clone();
+}
+
+//__________________________________________________________________________________________________
+TF1* AliDielectronBtoJPSItoEleCDFfitFCN::GetEvaluateCDFDecayTimeSigDistr(Double_t xmin, Double_t xmax){
+       // return the pointer to the signal x distribution function
+       TF1 *signFunc = new TF1("signalFunc",this,&AliDielectronBtoJPSItoEleCDFfitFCN::EvaluateCDFDecayTimeSigDistrFunc,xmin,xmax,0);
+        signFunc->SetNpx(5000);
+       return (TF1*)signFunc->Clone();
+}
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h b/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitFCN.h
new file mode 100644 (file)
index 0000000..6e985ca
--- /dev/null
@@ -0,0 +1,181 @@
+#ifndef ALIDIELECTRONBTOJPSITOELECDFFITFCN_H\r
+#define ALIDIELECTRONBTOJPSITOELECDFFITFCN_H\r
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice                               */\r
+\r
+//_________________________________________________________________________\r
+//                      Class AliDielectronBtoJPSItoEleCDFfitFCN\r
+//                    Definition of main function used in \r
+//                     unbinned log-likelihood fit for\r
+//                 the channel B -> JPsi + X -> e+e- + X\r
+//      \r
+//                          Origin: C.Di Giglio\r
+//     Contact: Carmelo.Digiglio@ba.infn.it , Giuseppe.Bruno@ba.infn.it\r
+//_________________________________________________________________________\r
+\r
+#include <TNamed.h>\r
+#include <TDatabasePDG.h>\r
+#include <TH1F.h>\r
+\r
+class TRandom3;\r
+class TF1;\r
+\r
+enum IntegralType {kBkg, \r
+       kBkgNorm, \r
+       kSig, \r
+       kSigNorm};\r
+\r
+enum PtBins       {kallpt, \r
+       kptbin1,kptbin2,kptbin3,\r
+       kptbin4,kptbin5,kptbin6,\r
+       kptbin7,kptbin8,kptbin9};\r
+//_________________________________________________________________________________________________\r
+class AliDielectronBtoJPSItoEleCDFfitFCN : public TNamed {\r
+       public:\r
+               //\r
+               AliDielectronBtoJPSItoEleCDFfitFCN();\r
+               AliDielectronBtoJPSItoEleCDFfitFCN(const AliDielectronBtoJPSItoEleCDFfitFCN& source); \r
+               AliDielectronBtoJPSItoEleCDFfitFCN& operator=(const AliDielectronBtoJPSItoEleCDFfitFCN& source);  \r
+               virtual ~AliDielectronBtoJPSItoEleCDFfitFCN();\r
+\r
+               Double_t EvaluateLikelihood(const Double_t* pseudoproperdecaytime,\r
+                               const Double_t* invariantmass, const Int_t ncand) const;\r
+\r
+               Double_t GetResWeight()                    const { return fParameters[0]; }\r
+               Double_t GetFPlus()                        const { return fParameters[1]; }\r
+               Double_t GetFMinus()                       const { return fParameters[2]; }\r
+               Double_t GetFSym()                         const { return fParameters[3]; } \r
+               Double_t GetLamPlus()                      const { return fParameters[4]; }\r
+               Double_t GetLamMinus()                     const { return fParameters[5]; }\r
+               Double_t GetLamSym()                       const { return fParameters[6]; }\r
+               Double_t GetFractionJpsiFromBeauty()       const { return fParameters[7]; }\r
+               Double_t GetFsig()                         const { return fParameters[8]; }\r
+               Double_t GetCrystalBallMmean()             const { return fParameters[9]; }\r
+               Double_t GetCrystalBallNexp()              const { return fParameters[10]; }\r
+               Double_t GetCrystalBallSigma()             const { return fParameters[11]; }\r
+               Double_t GetCrystalBallAlpha()             const { return fParameters[12]; }\r
+               Double_t GetCrystalBallNorm()              const { return fParameters[13]; }\r
+               Double_t GetBkgInvMassNorm()               const { return fParameters[14]; }\r
+               Double_t GetBkgInvMassMean()               const { return fParameters[15]; }\r
+               Double_t GetBkgInvMassSlope()              const { return fParameters[16]; }  \r
+               Double_t GetBkgInvMassConst()              const { return fParameters[17]; } \r
+               Double_t GetNormGaus1ResFunc()             const { return fParameters[18]; }\r
+               Double_t GetNormGaus2ResFunc()             const { return fParameters[19]; }\r
+               Double_t GetIntegralMassSig()              const { return fintmMassSig; }\r
+               Double_t GetIntegralMassBkg()              const { return fintmMassBkg; }\r
+               const Double_t* GetResolutionConstants()   const { return fResolutionConstants; }\r
+               Bool_t GetCrystalBallParam()               const { return fCrystalBallParam; }\r
+               TH1F * GetCsiMcHisto()                     const { return fhCsiMC; }\r
+\r
+               // return pointer to likelihood functions  \r
+               TF1* GetCsiMC(Double_t xmin, Double_t xmax);\r
+               TF1* GetResolutionFunc(Double_t xmin, Double_t xmax);\r
+               TF1* GetEvaluateCDFDecayTimeBkgDistr(Double_t xmin, Double_t xmax);\r
+               TF1* GetEvaluateCDFDecayTimeSigDistr(Double_t xmin, Double_t xmax);\r
+\r
+               void SetResWeight (Double_t resWgt) {fParameters[0] = resWgt;}\r
+               void SetFPlus(Double_t plus) {fParameters[1] = plus;}\r
+               void SetFMinus(Double_t minus) {fParameters[2]  = minus;}\r
+               void SetFSym(Double_t sym) {fParameters[3] = sym;}\r
+               void SetLamPlus(Double_t lamplus) {fParameters[4] = lamplus;}\r
+               void SetLamMinus(Double_t lamminus) {fParameters[5] = lamminus;}\r
+               void SetLamSym(Double_t lamsym) {fParameters[6] = lamsym;}\r
+               void SetFractionJpsiFromBeauty(Double_t B) {fParameters[7] = B;}\r
+               void SetFsig(Double_t Fsig) {fParameters[8] = Fsig;}\r
+               void SetCrystalBallMmean(Double_t CrystalBallMmean) {fParameters[9] = CrystalBallMmean;}\r
+               void SetCrystalBallNexp(Double_t CrystalBallNexp) {fParameters[10] = CrystalBallNexp;}\r
+               void SetCrystalBallSigma(Double_t CrystalBallSigma) {fParameters[11] = CrystalBallSigma;}\r
+               void SetCrystalBallAlpha(Double_t CrystalBallAlpha) {fParameters[12] = CrystalBallAlpha;}\r
+               void SetCrystalBallNorm(Double_t CrystalBallNorm) {fParameters[13] = CrystalBallNorm;}\r
+               void SetBkgInvMassNorm(Double_t BkgInvMassNorm) {fParameters[14] = BkgInvMassNorm;}\r
+               void SetBkgInvMassMean(Double_t BkgInvMassMean) {fParameters[15] = BkgInvMassMean;}\r
+               void SetBkgInvMassSlope(Double_t BkgInvMassSlope) {fParameters[16] = BkgInvMassSlope;}\r
+               void SetBkgInvMassConst(Double_t BkgInvMassConst) {fParameters[17] = BkgInvMassConst;}\r
+               void SetNormGaus1ResFunc(Double_t norm1) {fParameters[18] = norm1;}\r
+               void SetNormGaus2ResFunc(Double_t norm2) {fParameters[19] = norm2;}\r
+               void SetAllParameters(const Double_t* parameters);\r
+               void SetIntegralMassSig(Double_t integral) { fintmMassSig = integral; }\r
+               void SetIntegralMassBkg(Double_t integral) { fintmMassBkg = integral; }\r
+               void SetCsiMC(const TH1F* MCtemplate) {fhCsiMC = (TH1F*)MCtemplate->Clone("fhCsiMC");}\r
+\r
+               void SetResolutionConstants(Double_t* resolutionConst);\r
+               void SetMassWndHigh(Double_t limit) { fMassWndHigh = TDatabasePDG::Instance()->GetParticle(443)->Mass() + limit ;}\r
+               void SetMassWndLow(Double_t limit) { fMassWndLow = TDatabasePDG::Instance()->GetParticle(443)->Mass() - limit ;}\r
+               void SetCrystalBallFunction(Bool_t okCB) {fCrystalBallParam = okCB;}\r
+\r
+               void ComputeMassIntegral(); \r
+\r
+               void ReadMCtemplates(Int_t BinNum);\r
+\r
+               void PrintStatus();\r
+\r
+       private:  \r
+               //\r
+               Double_t fParameters[20];        /*  par[0]  = weightRes;                \r
+                                                    par[1]  = fPos;\r
+                                                    par[2]  = fNeg;\r
+                                                    par[3]  = fSym\r
+                                                    par[4]  = fOneOvLamPlus;\r
+                                                    par[5]  = fOneOvLamMinus;\r
+                                                    par[6]  = fOneOvLamSym;\r
+                                                    par[7]  = fFractionJpsiFromBeauty;\r
+                                                    par[8]  = fFsig;\r
+                                                    par[9]  = fCrystalBallMmean;\r
+                                                    par[10] = fCrystalBallNexp;\r
+                                                    par[11] = fCrystalBallSigma;\r
+                                                    par[12] = fCrystalBallAlpha;\r
+                                                    par[13] = fCrystalBallNorm;\r
+                                                    par[14] = fBkgNorm;\r
+                                                    par[15] = fBkgMean; \r
+                                                    par[16] = fBkgSlope;\r
+                                                    par[17] = fBkgConst;\r
+                                                    par[18] = norm1Gaus;\r
+                                                    par[19] = norm2Gaus;*/\r
+\r
+\r
+               Double_t fFPlus;                     // parameters of the log-likelihood function\r
+               Double_t fFMinus;                    // Slopes of the x distributions of the background \r
+               Double_t fFSym;                      // functions \r
+\r
+               Double_t fintmMassSig;               // integral of invariant mass distribution for the signal\r
+               Double_t fintmMassBkg;               // integral of invariant mass distribution for the bkg\r
+\r
+               TH1F *fhCsiMC;                       // X distribution used as MC template for JPSI from B\r
+               Double_t fResolutionConstants[4];    // constants for the parametrized resolution function R(X)\r
+               Double_t fMassWndHigh;               // JPSI Mass window higher limit\r
+               Double_t fMassWndLow;                // JPSI Mass window lower limit\r
+               Bool_t fCrystalBallParam;            // Boolean to switch to Crystall Ball parameterisation\r
+\r
+               ////\r
+\r
+               Double_t EvaluateCDFfunc(Double_t x, Double_t m) const ;\r
+               Double_t EvaluateCDFfuncNorm(Double_t x, Double_t m) const ;\r
+\r
+               ////\r
+\r
+               Double_t EvaluateCDFfuncSignalPart(Double_t x, Double_t m) const ;      // Signal part \r
+               Double_t EvaluateCDFDecayTimeSigDistr(Double_t x) const ;\r
+               Double_t EvaluateCDFDecayTimeSigDistrFunc(const Double_t* x, const Double_t *par) const { par = 0x0;  return EvaluateCDFDecayTimeSigDistr(x[0]);}\r
+               Double_t EvaluateCDFInvMassSigDistr(Double_t m) const ;\r
+               Double_t EvaluateCDFfuncBkgPart(Double_t x,Double_t m) const ;          // Background part\r
+               Double_t EvaluateCDFDecayTimeBkgDistr(Double_t x) const ;\r
+               Double_t EvaluateCDFDecayTimeBkgDistrFunc(const Double_t* x, const Double_t *par) const { par = 0x0;  return EvaluateCDFDecayTimeBkgDistr(x[0]);}\r
+               Double_t EvaluateCDFInvMassBkgDistr(Double_t m) const ;\r
+\r
+               ////\r
+\r
+               Double_t FunB(Double_t x) const;\r
+               Double_t FunP(Double_t x) const ;\r
+               Double_t CsiMC(Double_t x) const;\r
+               Double_t CsiMCfunc(const Double_t* x, const Double_t *par) const {  par = 0x0; return CsiMC(x[0]);}\r
+               Double_t FunBkgPos(Double_t x) const ;\r
+               Double_t FunBkgNeg(Double_t x) const ;\r
+               Double_t FunBkgSym(Double_t x) const ;\r
+               Double_t ResolutionFunc(Double_t x) const ;\r
+               Double_t ResolutionFuncf(const Double_t* x, const Double_t *par) const { par = 0x0;  return ResolutionFunc(x[0]);}\r
+\r
+               ClassDef (AliDielectronBtoJPSItoEleCDFfitFCN,1);         // Unbinned log-likelihood fit \r
+\r
+};\r
+\r
+#endif\r
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.cxx b/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.cxx
new file mode 100644 (file)
index 0000000..d340108
--- /dev/null
@@ -0,0 +1,243 @@
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+#include <TVirtualFitter.h>
+#include <TStopwatch.h>
+#include "AliLog.h"
+#include "AliDielectronBtoJPSItoEleCDFfitHandler.h"
+#include "AliDielectronBtoJPSItoEleCDFfitFCN.h"
+
+//-------------------------------------------------------------------------
+//                      Class AliDielectronBtoJPSItoEleCDFfitHandler
+//            Class to perform unbinned log-likelihood fit
+//      
+//                        Origin: C. Di Giglio
+//     Contact: carmelo.digiglio@ba.infn.it , giuseppe.bruno@ba.infn.it
+//-------------------------------------------------------------------------
+
+void CDFFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag);
+
+ClassImp(AliDielectronBtoJPSItoEleCDFfitHandler)
+
+       //______________________________________________________________________________
+void CDFFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+       // This function is called by minuit
+       // The corresponding member method is called
+       // using SetObjectFit/GetObjectFit methods of TMinuit
+       AliDielectronBtoJPSItoEleCDFfitHandler* dummy = (AliDielectronBtoJPSItoEleCDFfitHandler *)TVirtualFitter::GetFitter()->GetObjectFit();
+       dummy->CdfFCN(npar, gin, f, par, iflag);
+}
+
+
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler():
+       fIsParamFixed(20),
+       fPrintStatus(kFALSE),
+       fUp(0),
+       fX(0x0),
+       fM(0x0),
+       fLikely(0x0),
+       fNcand(0)
+{
+       //
+       // default constructor
+       //
+}
+//_________________________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler(Double_t* decaytime, 
+               Double_t* invariantmass, Int_t ncand) :
+       fIsParamFixed(20),
+       fPrintStatus(kFALSE),
+       fUp(0),
+       fX(decaytime),
+       fM(invariantmass),
+       fLikely(0x0),
+       fNcand(ncand)
+{
+       //
+       // constructor
+       //
+       AliInfo("\n+++\n+++ Minimization object AliDielectronBtoJPSItoEleCDFfitHandler created\n+++\n");
+       fLikely = new AliDielectronBtoJPSItoEleCDFfitFCN();
+       AliInfo("\n+++\n+++ CDF fit function object AliDielectronBtoJPSItoEleCDFfitFCN created\n+++\n");
+       AliInfo("Parameter 0  ----> fWeightRes");
+       AliInfo("Parameter 1  ----> fPos");
+       AliInfo("Parameter 2  ----> fNeg");
+       AliInfo("Parameter 3  ----> fSym");
+       AliInfo("Parameter 4  ----> fOneOvLamPlus");
+       AliInfo("Parameter 5  ----> fOneOvLamMinus");
+       AliInfo("Parameter 6  ----> fOneOvLamSym");
+       AliInfo("Parameter 7  ----> fB");
+       AliInfo("Parameter 8  ----> fFsig");
+       AliInfo("Parameter 9  ----> fMmean");
+       AliInfo("Parameter 10 ----> fNexp");
+       AliInfo("Parameter 11 ----> fSigma");
+       AliInfo("Parameter 12 ----> fAlpha");
+       AliInfo("Parameter 13 ----> fNorm");
+       AliInfo("Parameter 14 ----> fBkgNorm");
+       AliInfo("Parameter 15 ----> fBkgMean");
+       AliInfo("Parameter 16 ----> fBkgSlope");
+       AliInfo("Parameter 17 ----> fBkgConst");
+       AliInfo("Parameter 18 ----> fNormGaus1");
+       AliInfo("Parameter 19 ----> fNormGaus2");
+
+       AliInfo(Form("\n+++\n+++ Number of candidates ---> %d\n+++\n ", ncand));
+}
+//___________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitHandler& AliDielectronBtoJPSItoEleCDFfitHandler::operator=(const AliDielectronBtoJPSItoEleCDFfitHandler& c)
+{
+       //
+       // Assignment operator
+       //
+       if (this!=&c) {
+               fIsParamFixed = c.fIsParamFixed;
+               fPrintStatus  = c.fPrintStatus;
+               fUp           = c.fUp;
+               fX            = c.fX;
+               fM            = c.fM;
+               fLikely       = c.fLikely;
+               fNcand        = c.fNcand;
+       }
+       return *this;
+}
+
+//_______________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitHandler::AliDielectronBtoJPSItoEleCDFfitHandler(const AliDielectronBtoJPSItoEleCDFfitHandler& c) :
+       TNamed(c),
+       fIsParamFixed(c.fIsParamFixed),
+       fPrintStatus(c.fPrintStatus),
+       fUp(c.fUp),
+       fX(c.fX),
+       fM(c.fM),
+       fLikely(c.fLikely),
+       fNcand(c.fNcand)
+{
+       //
+       // Copy Constructor
+       //
+}
+//_______________________________________________________________________________________
+AliDielectronBtoJPSItoEleCDFfitHandler::~AliDielectronBtoJPSItoEleCDFfitHandler()
+{
+       //
+       //destructor
+       //
+       delete fLikely;
+}
+//_______________________________________________________________________________________
+Int_t AliDielectronBtoJPSItoEleCDFfitHandler::DoMinimization()
+{
+       //
+       // performs the minimization
+       //
+       static TVirtualFitter *fitter = TVirtualFitter::Fitter(this,20);
+       fitter->SetFCN(CDFFunction);
+
+       fitter->SetParameter(0,"fWeightRes",fParamStartValues[0], 1.e-08, 0., 1.e+06);
+       fitter->SetParameter(1,"fPos",fParamStartValues[1], 1.e-08, 0.,1.e+06);
+       fitter->SetParameter(2,"fNeg",fParamStartValues[2], 1.e-08, 0.,1.e+06);
+       fitter->SetParameter(3,"fSym",fParamStartValues[3], 1.e-08, 0.,1.e+06);
+       fitter->SetParameter(4,"fOneOvLamPlus",fParamStartValues[4], 1.e-10, 0.0000001, 5.e+01);
+       fitter->SetParameter(5,"fOneOvLamMinus",fParamStartValues[5], 1.e-10, 0.00000001, 5.e+01);
+       fitter->SetParameter(6,"fOneOvLamSym",fParamStartValues[6], 1.e-10, 0.00000001, 5.e+01);
+       fitter->SetParameter(7,"fB",fParamStartValues[7], 1.e-10, 0., 1.);
+       fitter->SetParameter(8,"fFsig",fParamStartValues[8], 1.e-10, 0., 1.);
+       fitter->SetParameter(9,"fMmean",fParamStartValues[9], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(10,"fNexp",fParamStartValues[10], 1.e-08, 0., 1.e+02);
+       fitter->SetParameter(11,"fSigma",fParamStartValues[11], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(12,"fAlpha",fParamStartValues[12], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(13,"fNorm",fParamStartValues[13], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(14,"fBkgNorm",fParamStartValues[14], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(15,"fBkgMean",fParamStartValues[15], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(16,"fBkgSlope",fParamStartValues[16], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(17,"fBkgSlope",fParamStartValues[17], 1.e-08, 0., 1.e+04);
+       fitter->SetParameter(18,"fNormGaus1",fParamStartValues[18], 1.e-08, 0., 1.e+05);
+       fitter->SetParameter(19,"fNormGaus2",fParamStartValues[19], 1.e-08, 0., 1.e+05); 
+
+       for(UInt_t indexparam = 0; indexparam < 20; indexparam++){
+               if(IsParamFixed(indexparam))fitter->FixParameter((Int_t)indexparam);
+       }
+
+       Double_t arglist[2]={10000,1.0}; 
+       Int_t iret=fitter->ExecuteCommand("MIGRAD", arglist ,2);
+       fitter->PrintResults(4,0);
+
+       AliInfo("Minimization procedure finished\n");
+
+       return iret;
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::CdfFCN(Int_t & /* npar */, 
+               Double_t * /* gin */,Double_t &f,Double_t *par,Int_t /* iflag */)
+{
+       // 
+       // Definition of the FCN to be used by minuit
+       //
+       fLikely->SetAllParameters(par);
+       fLikely->ComputeMassIntegral();
+       if(fPrintStatus)fLikely->PrintStatus();
+
+       TStopwatch t;
+       t.Start();
+
+       f = fLikely->EvaluateLikelihood(fX,fM,fNcand);
+
+       t.Stop();
+       AliDebug(2,Form("Real time spent to calculate function == %f \n", t.RealTime()));
+       AliDebug(2,Form("CPU time spent to calculate function == %f \n", t.CpuTime()));
+       AliDebug(2,Form("Actual value of the AliDielectronBtoJPSItoEleCDFfitFCN function == %f \n", f));
+
+       return;
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::SetParamStartValues(Double_t inputparamvalues[20])
+{
+       for(Int_t index=0; index < 20; index++) fParamStartValues[index] = inputparamvalues[index];
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::SetResolutionConstants(Double_t* resolutionConst)
+{
+       //
+       // Sets constants for the resolution function
+       //
+       fLikely->SetResolutionConstants(resolutionConst);
+
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::SetCrystalBallFunction(Bool_t okCB) 
+{
+       //
+       // Sets the CB as the parametrization for the signal invariant mass spectrum 
+       // (otherwise Landau is chosen)
+       //
+       fLikely->SetCrystalBallFunction(okCB);
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::SetMassWndHigh(Double_t limit) 
+{ 
+       //
+       // Sets upper limit for the invariant mass window (under J/PSI mass peak)
+       //
+       fLikely->SetMassWndHigh(limit);
+}
+//_______________________________________________________________________________________
+void AliDielectronBtoJPSItoEleCDFfitHandler::SetMassWndLow(Double_t limit)
+{
+       //
+       // Sets lower limit for the invariant mass window (under J/PSI mass peak)
+       //
+       fLikely->SetMassWndLow(limit);
+}
+
diff --git a/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h b/PWG3/dielectron/AliDielectronBtoJPSItoEleCDFfitHandler.h
new file mode 100644 (file)
index 0000000..7c62e60
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H\r
+#define ALIDIELECTRONBTOJPSITOELECDFFITHANDLER_H\r
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice                               */\r
+\r
+//___________________________________________________________________________\r
+//                  Class AliDielectronBtoJPSItoEleCDFfitHandler\r
+//            Class to perform unbinned log-likelihood fit\r
+//      \r
+//                         Origin: C. Di Giglio\r
+//     Contact: Carmelo.Digiglio@ba.infn.it; Giuseppe.Bruno@ba.infn.it\r
+//____________________________________________________________________________\r
+\r
+#include <TNamed.h>\r
+#include <TBits.h>\r
+\r
+class AliDielectronBtoJPSItoEleCDFfitFCN;\r
+\r
+class AliDielectronBtoJPSItoEleCDFfitHandler : public TNamed {\r
+       public:\r
+               //\r
+               AliDielectronBtoJPSItoEleCDFfitHandler();\r
+               AliDielectronBtoJPSItoEleCDFfitHandler& operator= (const  AliDielectronBtoJPSItoEleCDFfitHandler& c);\r
+               AliDielectronBtoJPSItoEleCDFfitHandler(const AliDielectronBtoJPSItoEleCDFfitHandler& c);\r
+               AliDielectronBtoJPSItoEleCDFfitHandler(Double_t* decaytime, Double_t* invariantmass, Int_t ncand);\r
+               ~AliDielectronBtoJPSItoEleCDFfitHandler(); \r
+               Double_t Up() const { return fUp; }\r
+               void SetErrorDef(Double_t up) {fUp = up;}\r
+               void SetPrintStatus(Bool_t okPrintStatus) { fPrintStatus = okPrintStatus; } \r
+               Bool_t GetPrintStatus() const { return fPrintStatus ; }\r
+               void SetParamStartValues (Double_t*);\r
+               Double_t* GetStartParamValues() { return fParamStartValues; }\r
+               TBits GetFixedParamList() const { return fIsParamFixed; }\r
+               void FixParam(UInt_t param, Bool_t value) { fIsParamFixed.SetBitNumber(param,value); }\r
+               void FixAllParam(Bool_t value) { for(UInt_t par=0;par<20;par++) fIsParamFixed.SetBitNumber(par,value); }\r
+               Bool_t IsParamFixed(UInt_t param) { return fIsParamFixed.TestBitNumber(param); }\r
+               void SetResolutionConstants(Double_t* resolutionConst);\r
+               void SetCrystalBallFunction(Bool_t okCB);\r
+               void SetMassWndHigh(Double_t limit);\r
+               void SetMassWndLow(Double_t limit);\r
+\r
+               Double_t operator()(const Double_t* par) const ;\r
+               void CdfFCN(Int_t & /* npar */, Double_t * /* gin */, Double_t &f, Double_t *par, Int_t /* iflag */);\r
+\r
+               Double_t* Decaytime() const         { return fX; }\r
+               Double_t* InvariantMass() const     { return fM; }\r
+               AliDielectronBtoJPSItoEleCDFfitFCN* LikelihoodPointer() const { return fLikely; }\r
+               Int_t DoMinimization();\r
+\r
+       private:\r
+               //\r
+               TBits fIsParamFixed;                               //array of bits: 0 = param free; 1 = param fixed;\r
+               Bool_t fPrintStatus;                               //flag to enable the prit out of the algorithm at each step\r
+               Double_t fParamStartValues[20];                    //array of parameters input value\r
+               Double_t fUp;                                      //error definition \r
+               Double_t* fX;                                //pseudo-proper decay time X\r
+               Double_t* fM;                                      //invariant mass M\r
+               AliDielectronBtoJPSItoEleCDFfitFCN* fLikely;                 //Log likelihood function\r
+               Int_t fNcand;                                      //number of candidates\r
+               //\r
+               ClassDef(AliDielectronBtoJPSItoEleCDFfitHandler,1);\r
+\r
+}; \r
+#endif\r
index 21de564..4a4ec9d 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //       Dielectron Correction framework manager                         //
 //                                                                       //
@@ -47,6 +45,7 @@
 #include "AliDielectronCF.h"
 #include "AliDielectronMC.h"
 #include "AliDielectronPair.h"
+#include "AliDielectronSignalMC.h"
 
 ClassImp(AliDielectronCF)
 
@@ -69,6 +68,7 @@ AliDielectronCF::AliDielectronCF() :
   fStepsForBackground(kFALSE),
   fNStepMasks(0),
   fPdgMother(-1),
+  fSignalsMC(0x0),
   fCfContainer(0x0),
   fHasMC(kFALSE),
   fNAddSteps(0)
@@ -106,6 +106,7 @@ AliDielectronCF::AliDielectronCF(const char* name, const char* title) :
   fStepsForBackground(kFALSE),
   fNStepMasks(0),
   fPdgMother(-1),
+  fSignalsMC(0x0),
   fCfContainer(0x0),
   fHasMC(kFALSE),
   fNAddSteps(0)
@@ -218,7 +219,7 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
   fHasMC=AliDielectronMC::Instance()->HasMC();
   fNAddSteps=1;
   if (fHasMC){
-    if (fStepsForSignal) ++fNAddSteps;
+    if (fStepsForSignal && fSignalsMC) fNAddSteps+=fSignalsMC->GetEntries();
     if (fStepsForBackground) ++fNAddSteps;
   } else {
     //if 
@@ -229,8 +230,8 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
   }
     
   fNSteps=0;
-  if (fStepForMCtruth) ++fNSteps;
-  if (fStepForNoCutsMCmotherPid) ++fNSteps;
+  if (fStepForMCtruth && fSignalsMC) fNSteps+=fSignalsMC->GetEntries();
+  if (fStepForNoCutsMCmotherPid && fSignalsMC) fNSteps+=fSignalsMC->GetEntries();
   if (fStepForAfterAllCuts) fNSteps+=fNAddSteps;
 
   if (fStepsForEachCut&&fNCuts>1)        fNSteps+=(fNAddSteps*fNCuts);     //one step for each cut + Signal (MC)
@@ -288,13 +289,15 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
   Int_t step=0;
 
   //Pure MC truth
-  if (fStepForMCtruth){
-    fCfContainer->SetStepTitle(step++,"MC truth");
+  if(fStepForMCtruth && fSignalsMC) {
+    for(Int_t i=0; i<fSignalsMC->GetEntries(); i++)
+      fCfContainer->SetStepTitle(step++, Form("MC truth (Signal: %s)", fSignalsMC->At(i)->GetTitle()));
   }
 
   //before cuts (MC truth)
-  if (fStepForNoCutsMCmotherPid){
-    fCfContainer->SetStepTitle(step++,"No cuts (Signal)");
+  if (fStepForNoCutsMCmotherPid && fSignalsMC){
+    for(Int_t i=0; i<fSignalsMC->GetEntries(); i++)
+      fCfContainer->SetStepTitle(step++,Form("No cuts (Signal: %s)",fSignalsMC->At(i)->GetTitle()));
   }
   
   TString cutName;
@@ -306,9 +309,12 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
       fCfContainer->SetStepTitle(step++, cutName.Data()); //Step for the cut
       
       if (fHasMC){
-        if (fStepsForSignal)
-          fCfContainer->SetStepTitle(step++, (cutName+" (Signal)").Data()); //Step for the cut with MC truth
-        if (fStepsForBackground)
+       if (fStepsForSignal && fSignalsMC) {
+         for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) {
+           fCfContainer->SetStepTitle(step++, Form("%s (Signal: %s)", cutName.Data(), fSignalsMC->At(i)->GetTitle())); //Step for the cut with MC truth
+         }
+       }
+       if (fStepsForBackground)
           fCfContainer->SetStepTitle(step++, (cutName+" (Background)").Data()); //Step for the cut with MC truth
       }
     }
@@ -324,8 +330,10 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
       fCfContainer->SetStepTitle(step++, cutName.Data()); //Step for the cut
       
       if (fHasMC){
-        if (fStepsForSignal)
-          fCfContainer->SetStepTitle(step++, (cutName+" (Signal)").Data()); //Step for the cut with MC truth
+       if (fStepsForSignal && fSignalsMC)
+         for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) {
+           fCfContainer->SetStepTitle(step++, Form("%s (Signal: %s)", cutName.Data(), fSignalsMC->At(i)->GetTitle())); //Step for the cut with MC truth
+         }
         if (fStepsForBackground)
           fCfContainer->SetStepTitle(step++, (cutName+" (Background)").Data()); //Step for the cut with MC truth
       }
@@ -350,8 +358,10 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
     fCfContainer->SetStepTitle(step++, cutName.Data()); //Step for the cut
     
     if (fHasMC){
-      if (fStepsForSignal)
-        fCfContainer->SetStepTitle(step++, (cutName+" (Signal)").Data()); //Step for the cut with MC truth
+      if (fStepsForSignal && fSignalsMC)
+       for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) {
+         fCfContainer->SetStepTitle(step++, Form("%s (Signal: %s)", cutName.Data(), fSignalsMC->At(i)->GetTitle())); //Step for the cut with MC truth
+       }
       if (fStepsForBackground)
         fCfContainer->SetStepTitle(step++, (cutName+" (Background)").Data()); //Step for the cut with MC truth
     }
@@ -369,8 +379,10 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
     }
     fCfContainer->SetStepTitle(step++, cutName.Data()); //Step for the cut
     if (fHasMC){
-      if (fStepsForSignal)
-        fCfContainer->SetStepTitle(step++, (cutName+" (Signal)").Data()); //Step for the cut with MC truth
+      if (fStepsForSignal && fSignalsMC)
+       for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) {
+         fCfContainer->SetStepTitle(step++, Form("%s (Signal: %s)", cutName.Data(), fSignalsMC->At(i)->GetTitle())); //Step for the cut with MC truth
+       }
       if (fStepsForBackground)
         fCfContainer->SetStepTitle(step++, (cutName+" (Background)").Data()); //Step for the cut with MC truth
     }
@@ -381,8 +393,10 @@ void AliDielectronCF::InitialiseContainer(const AliAnalysisFilter& filter)
     cutName="PreFilter";
     fCfContainer->SetStepTitle(step++, cutName.Data()); //Step for the cut
     if (fHasMC){
-      if (fStepsForSignal)
-        fCfContainer->SetStepTitle(step++, (cutName+" (Signal)").Data()); //Step for the cut with MC truth
+      if (fStepsForSignal && fSignalsMC)
+       for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) {
+         fCfContainer->SetStepTitle(step++, Form("%s (Signal %s)", cutName.Data(), fSignalsMC->At(i)->GetTitle())); //Step for the cut with MC truth
+       }
       if (fStepsForBackground)
         fCfContainer->SetStepTitle(step++, (cutName+" (Background)").Data()); //Step for the cut with MC truth
     }
@@ -402,9 +416,23 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
   // Fill the containers
   //
 
-  Bool_t isMCTruth=kFALSE;
-  if (fHasMC) isMCTruth=AliDielectronMC::Instance()->IsMotherPdg(particle,fPdgMother);
+  // Check the MC truths
+  Bool_t* isMCTruth=0x0;
+  if(fHasMC && fSignalsMC && fSignalsMC->GetEntries()>0) {
+    isMCTruth=new Bool_t[fSignalsMC->GetEntries()]; 
+    for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) isMCTruth[i]=kFALSE;
+  }
 
+  Bool_t isBackground = kFALSE;
+  if(fHasMC && isMCTruth) {
+    for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) { 
+      isMCTruth[i] = AliDielectronMC::Instance()->IsMCTruth(particle, (AliDielectronSignalMC*)fSignalsMC->At(i));
+      isBackground = (isBackground || isMCTruth[i]);
+    }
+    // background is considered that pair which does not fulfill any of the signals
+    isBackground = !isBackground;
+  }
+  
   Double_t valuesPair[AliDielectronVarManager::kNMaxValues];
   AliDielectronVarManager::Fill(particle,valuesPair);
 
@@ -431,14 +459,18 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
   //============//
   // Fill steps //
   //============//
-  // step 0 would be full MC truth and is handled in FillMC
+  // Pure MC steps are handled in FillMC
   Int_t step=0;
-  if (fStepForMCtruth) ++step;
+  if (fStepForMCtruth && isMCTruth) step+=fSignalsMC->GetEntries();
   
   //No cuts (MC truth)
-  if (fStepForNoCutsMCmotherPid){
-    if (isMCTruth) fCfContainer->Fill(fValues,step);
-    ++step;
+  if (fStepForNoCutsMCmotherPid && isMCTruth){
+    for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+      if(isMCTruth[i]) {
+       fCfContainer->Fill(fValues,step);
+      }
+      ++step;
+    }
   }
   
   //Steps for each of the cuts
@@ -449,12 +481,16 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
         ++step;
 
         if (fHasMC){
-          if ( fStepsForSignal){
-            if (isMCTruth) fCfContainer->Fill(fValues,step);
-            ++step;
+          if ( fStepsForSignal && isMCTruth){
+           for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+             if(isMCTruth[i]) {
+               fCfContainer->Fill(fValues,step);
+             }
+             ++step;
+           }
           }
           if ( fStepsForBackground ){
-            if (!isMCTruth) fCfContainer->Fill(fValues,step);
+            if (isBackground) fCfContainer->Fill(fValues,step);
             ++step;
           }
         }
@@ -473,12 +509,16 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
         ++step;
         
         if (fHasMC){
-          if ( fStepsForSignal){
-            if (isMCTruth) fCfContainer->Fill(fValues,step);
-            ++step;
+         if ( fStepsForSignal && isMCTruth){
+           for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+             if(isMCTruth[i]) {
+               fCfContainer->Fill(fValues,step);
+             }
+             ++step;
+           }
           }
           if ( fStepsForBackground ){
-            if (!isMCTruth) fCfContainer->Fill(fValues,step);
+            if (isBackground) fCfContainer->Fill(fValues,step);
             ++step;
           }
         }
@@ -496,12 +536,16 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
       ++step;
       
       if (fHasMC){
-        if ( fStepsForSignal){
-          if (isMCTruth) fCfContainer->Fill(fValues,step);
-          ++step;
+        if ( fStepsForSignal && isMCTruth){
+         for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+           if(isMCTruth[i]) {
+             fCfContainer->Fill(fValues,step);
+           }
+           ++step;
+         }
         }
         if ( fStepsForBackground ){
-          if (!isMCTruth) fCfContainer->Fill(fValues,step);
+          if (isBackground) fCfContainer->Fill(fValues,step);
           ++step;
         }
       }
@@ -517,12 +561,16 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
       ++step;
       
       if (fHasMC){
-        if ( fStepsForSignal){
-          if (isMCTruth) fCfContainer->Fill(fValues,step);
-          ++step;
+        if ( fStepsForSignal && isMCTruth){
+         for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+           if(isMCTruth[i]) {
+             fCfContainer->Fill(fValues,step);
+           }
+           ++step;
+         }
         }
         if ( fStepsForBackground ){
-          if (!isMCTruth) fCfContainer->Fill(fValues,step);
+          if (isBackground) fCfContainer->Fill(fValues,step);
           ++step;
         }
       }
@@ -536,14 +584,18 @@ void AliDielectronCF::Fill(UInt_t mask, const AliDielectronPair *particle)
          ++step;
 
          if (fHasMC){
-               if ( fStepsForSignal){
-                 if (isMCTruth) fCfContainer->Fill(fValues,step);
-                 ++step;
-               }
-               if ( fStepsForBackground ){
-                 if (!isMCTruth) fCfContainer->Fill(fValues,step);
-                 ++step;
+           if ( fStepsForSignal && isMCTruth){
+             for(Int_t i=0; i<fSignalsMC->GetEntries(); ++i) {
+               if(isMCTruth[i]) {
+                 fCfContainer->Fill(fValues,step);
                }
+               ++step;
+             }
+           }
+           if ( fStepsForBackground ){
+             if (isBackground) fCfContainer->Fill(fValues,step);
+             ++step;
+           }
          }
        }
        else {
@@ -605,6 +657,69 @@ void AliDielectronCF::FillMC(const TObject *particle)
   fCfContainer->Fill(fValues,0);
 }
 
+
+//________________________________________________________________
+void AliDielectronCF::FillMC(Int_t label1, Int_t label2, Int_t nSignal) {
+  //
+  // fill the pure MC part of the container starting from a pair of 2 particles (part1 and part2 are legs)
+  //
+  if (!fStepForMCtruth) return;
+
+  AliVParticle* part1 = AliDielectronMC::Instance()->GetMCTrackFromMCEvent(label1);
+  AliVParticle* part2 = AliDielectronMC::Instance()->GetMCTrackFromMCEvent(label2);
+
+  AliDielectronMC* dieMC = AliDielectronMC::Instance();
+
+  Int_t mLabel1 = dieMC->GetMothersLabel(label1);    // should work for both ESD and AOD
+  Int_t mLabel2 = dieMC->GetMothersLabel(label2);
+  // check the same mother option
+  AliDielectronSignalMC* sigMC = (AliDielectronSignalMC*)fSignalsMC->At(nSignal);
+  if(sigMC->GetMothersRelation()==AliDielectronSignalMC::kSame && mLabel1!=mLabel2) return;
+  if(sigMC->GetMothersRelation()==AliDielectronSignalMC::kDifferent && mLabel1==mLabel2) return;
+    
+  // fill the leg variables
+  if (fNVarsLeg>0){
+    Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues];
+    Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues];
+    if (part1->Pt()>part2->Pt()){
+      AliDielectronVarManager::Fill(part1,valuesLeg1);
+      AliDielectronVarManager::Fill(part2,valuesLeg2);
+    } else {
+      AliDielectronVarManager::Fill(part2,valuesLeg1);
+      AliDielectronVarManager::Fill(part1,valuesLeg2);
+    }
+    
+    for (Int_t iVar=0; iVar<fNVarsLeg; ++iVar){
+      Int_t var=fVariablesLeg[iVar];
+      fValues[iVar+fNVars]=valuesLeg1[var];
+      fValues[iVar+fNVars+fNVarsLeg]=valuesLeg2[var];
+    }
+  }
+
+  Double_t valuesPair[AliDielectronVarManager::kNMaxValues];
+  AliDielectronVarManager::FillVarMCParticle2(part1,part2,valuesPair);
+
+  valuesPair[AliDielectronVarManager::kThetaHE]=AliDielectronPair::ThetaPhiCM(part1,part2,kTRUE,kTRUE);
+  valuesPair[AliDielectronVarManager::kPhiHE]=AliDielectronPair::ThetaPhiCM(part1,part2,kTRUE,kFALSE);
+  valuesPair[AliDielectronVarManager::kThetaCS]=AliDielectronPair::ThetaPhiCM(part1,part2,kFALSE,kTRUE);
+  valuesPair[AliDielectronVarManager::kPhiCS]=AliDielectronPair::ThetaPhiCM(part1,part2,kFALSE,kFALSE);
+
+  if(part1->Charge()*part2->Charge()<0)
+    valuesPair[AliDielectronVarManager::kPairType]=1;
+  else if(part1->Charge()>0)
+    valuesPair[AliDielectronVarManager::kPairType]=0;
+  else
+    valuesPair[AliDielectronVarManager::kPairType]=2;
+
+  for(Int_t iVar=0; iVar<fNVars; ++iVar){
+    Int_t var=fVariables[iVar];
+    fValues[iVar]=valuesPair[var];
+  }
+
+  fCfContainer->Fill(fValues,nSignal);
+}
+
+
 //_____________________________________________________________________________
 TVectorD* AliDielectronCF::MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax) const
 {
index e941e8c..5b277f3 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           #
 //#             Class AliDielectronCF                         #
@@ -42,6 +40,7 @@ public:
   virtual ~AliDielectronCF();
 
   void SetStepForMCtruth(Bool_t steps=kTRUE)           { fStepForMCtruth=steps;           }
+  Bool_t GetStepForMCtruth() const                     { return fStepForMCtruth;          }
   void SetStepForNoCutsMCmotherPid(Bool_t steps=kTRUE) { fStepForNoCutsMCmotherPid=steps; }
   void SetStepForAfterAllCuts(Bool_t steps=kTRUE)      { fStepForAfterAllCuts=steps;      }
   void SetStepForPreFilter(Bool_t steps=kTRUE)         { fStepForPreFilter=steps;         }
@@ -51,6 +50,7 @@ public:
   void SetStepsForBackground(Bool_t steps=kTRUE)       { fStepsForBackground=steps;       }
   
   void SetPdgMother(Int_t pdg) { fPdgMother=pdg; }
+  void SetSignalsMC(TObjArray* array)    {fSignalsMC = array;}
   
   void AddStepMask(UInt_t mask)                  { fStepMasks[fNStepMasks++]=mask; }
   
@@ -64,7 +64,8 @@ public:
 //   void Fill(UInt_t mask, const TObject *particle);
   void Fill(UInt_t mask, const AliDielectronPair *particle);
   void FillMC(const TObject *particle);
-  
+  void FillMC(Int_t label1, Int_t label2, Int_t nSignal);
+
   AliCFContainer* GetContainer() const { return fCfContainer; }
   
 private:
@@ -97,6 +98,7 @@ private:
   UInt_t fNStepMasks;                    //number of configured step masks
 
   Int_t fPdgMother;                      //Pdg code of MCtruth validation
+  TObjArray* fSignalsMC;                 //! array of MC signals to be studied
   AliCFContainer* fCfContainer;          //the CF container
 
   Bool_t fHasMC;                         //if MC info is available
index 28f4581..5944809 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //       Dielectron Correction framework draw helper                     //
 //                                                                       //
@@ -177,12 +175,14 @@ void AliDielectronCFdraw::SetRangeUser(Int_t ivar, Double_t min, Double_t max, c
   // Set range of cut steps defined in slices
   // Steps may be separated by one the the characteres ,;:
   //
+  if (ivar==-1) return;
   TObjArray *arr=TString(slices).Tokenize(",:;");
 
   if (arr->GetEntriesFast()==0){
     // all slices in case of 0 entries
     for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
       fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
+      fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
     }
   } else {
     TIter next(arr);
@@ -190,6 +190,7 @@ void AliDielectronCFdraw::SetRangeUser(Int_t ivar, Double_t min, Double_t max, c
     while ( (ostr=static_cast<TObjString*>(next())) ) {
       Int_t istep=ostr->GetString().Atoi();
       fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
+      fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
     }
   }
   delete arr;
@@ -202,6 +203,7 @@ void AliDielectronCFdraw::UnsetRangeUser(Int_t ivar, const char* slices)
   // Unset range of cut steps defined in slices
   // Steps may be separated by one the the characteres ,;:
   //
+  if (ivar==-1) return;
   TObjArray *arr=TString(slices).Tokenize(",:;");
   
   if (arr->GetEntriesFast()==0){
@@ -256,6 +258,41 @@ void AliDielectronCFdraw::Draw(const Option_t* varnames, const char* opt, const
 }
 
 //________________________________________________________________
+TObjArray* AliDielectronCFdraw::CollectHistosProj(const Option_t* varnames, const char* slices)
+{
+  //
+  // Collect histos with 'variables' of 'slices'
+  // for multidimensional histograms, variables may be separated by a ':'
+  // slice numbers may be separated by any of ,:;
+  //
+  // variables may be called by either their name or number
+  //
+  
+  TObjArray *arrVars=TString(varnames).Tokenize(":");
+  Int_t entries=arrVars->GetEntriesFast();
+  if (entries<1||entries>3){
+    AliError("Wrong number of variables, supported are 1 - 3 dimensions");
+    delete arrVars;
+    return 0x0;
+  }
+  
+  TIter next(arrVars);
+  TObjString *ostr=0x0;
+  Int_t ivar[3]={-1,-1,-1};
+  for (Int_t i=entries-1; i>=0; --i){
+    ostr=static_cast<TObjString*>(next());
+    if (ostr->GetString().IsDigit()){
+      ivar[i]=ostr->GetString().Atoi();
+    } else {
+      ivar[i]=fCfContainer->GetVar(ostr->GetName());
+    }
+  }
+  delete arrVars;
+  
+  return CollectHistosProj(ivar,slices);
+}
+
+//________________________________________________________________
 void AliDielectronCFdraw::Draw(Int_t var, const char* opt, const char* slices)
 {
   //
index 27821b1..d5ee6ac 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           #
 //#             Class AliDielectronCF                         #
@@ -63,6 +61,7 @@ public:
   void Draw(Int_t var0, Int_t var1, const char* opt="", const char* slices="");
   void Draw(Int_t var0, Int_t var1, Int_t var2, const char* opt="", const char* slices="");
 
+  TObjArray* CollectHistosProj(const Option_t* varnames, const char* slices);
   TObjArray* CollectHistosProj(const Int_t vars[3], const char* slices);
   TH1* Project(const Int_t vars[3], Int_t slice);
   TH1* Project(const Option_t* var, Int_t slice);
index f6b3ddc..90a6bd8 100644 (file)
@@ -13,8 +13,6 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
-
 //////////////////////////////////////////////////////////////////////////
 //                           CutGroup                                   //
 //                                                                      //
index c193808..92adfd2 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#################################################################
 //#                                                               #
 //#             Class AliDielectronCutGroup                       #
index 7ada17c..6b36d22 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                Dielectron DebugTree                                  //
 //                                                                       //
@@ -114,6 +112,7 @@ void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
   TObjString fileName;
   Int_t eventInFile=-1;
   Int_t runNumber=-1;
+  UInt_t eventTime=0;
   
   TTree *t=man->GetTree();
   if (t) {
@@ -126,6 +125,7 @@ void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
     AliESDEvent *ev=dynamic_cast<AliESDEvent*>(han->GetEvent());
     eventInFile=ev->GetEventNumberInFile();
     runNumber=ev->GetRunNumber();
+    eventTime=ev->GetTimeStamp();
   }
   
   if (!fStreamer) fStreamer=new TTreeSRedirector(fFileName.Data());
@@ -137,7 +137,8 @@ void AliDielectronDebugTree::Fill(AliDielectronPair *pair)
     << "EventInFile=" << eventInFile
     << "Run="         << runNumber
     << "Leg1_ID="     << id1
-    << "Leg2_ID="     << id2;
+    << "Leg2_ID="     << id2
+    << "EventTime="    << eventTime;
   
   //Fill MC information
   Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
index 1925187..a4c003f 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronDebugTree                     #
index d93ad23..9c11c26 100644 (file)
@@ -29,6 +29,7 @@ Detailed description
 #include <AliESDVertex.h>
 #include <AliESDEvent.h>
 #include <AliMultiplicity.h>
+#include <AliCentrality.h>
 
 #include "AliDielectronEventCuts.h"
 
@@ -41,6 +42,8 @@ AliDielectronEventCuts::AliDielectronEventCuts() :
   fRequireVtx(kFALSE),
   fMinVtxContributors(0),
   fMultITSTPC(kFALSE),
+  fCentMin(1.),
+  fCentMax(0.),
   fVtxType(kVtxTracks),
   fRequireV0and(0),
   fTriggerAnalysis(0x0),
@@ -60,6 +63,8 @@ AliDielectronEventCuts::AliDielectronEventCuts(const char* name, const char* tit
   fRequireVtx(kFALSE),
   fMinVtxContributors(0),
   fMultITSTPC(kFALSE),
+  fCentMin(1.),
+  fCentMax(0.),
   fVtxType(kVtxTracks),
   fRequireV0and(0),
   fTriggerAnalysis(0x0),
@@ -89,6 +94,13 @@ Bool_t AliDielectronEventCuts::IsSelected(TObject* event)
   AliESDEvent *ev=dynamic_cast<AliESDEvent*>(event);
   if (!ev) return kFALSE;
 
+  if (fCentMin<fCentMax){
+    AliCentrality *centrality=ev->GetCentrality();
+    Double_t centralityF=-1;
+    if (centrality) centralityF = centrality->GetCentralityPercentile("V0M");
+    if (centralityF<fCentMin || centralityF>=fCentMax) return kFALSE;
+  }
+
   fkVertex=0x0;
   switch(fVtxType){
   case kVtxTracks:
@@ -102,16 +114,25 @@ Bool_t AliDielectronEventCuts::IsSelected(TObject* event)
 
   if ((fRequireVtx||fVtxZmin<fVtxZmax||fMinVtxContributors>0)&&!fkVertex) return kFALSE;
   
-  if (fVtxZmin<fVtxZmax){
-    Double_t zvtx=fkVertex->GetZv();
-    if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
-  }
 
   if (fMinVtxContributors>0){
     Int_t nCtrb = fkVertex->GetNContributors();
-    if (nCtrb<fMinVtxContributors) return kFALSE;
+    if (nCtrb<fMinVtxContributors){
+      if (fVtxType==kVtxTracksOrSPD){
+        fkVertex=ev->GetPrimaryVertexSPD();
+        nCtrb = fkVertex->GetNContributors();
+        if (nCtrb<fMinVtxContributors) return kFALSE;
+      } else {
+        return kFALSE;
+      }
+    }
   }
 
+  if (fVtxZmin<fVtxZmax){
+    Double_t zvtx=fkVertex->GetZv();
+    if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
+  }
+  
   if (fRequireV0and){
     if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
     Bool_t v0AND = kFALSE;
@@ -136,6 +157,7 @@ Bool_t AliDielectronEventCuts::IsSelected(TObject* event)
     if ( vtxESDTPC && multESD && vtxESDTPC->GetNContributors() < (-10.+0.25*multESD->GetNumberOfITSClusters(0)) )
       return kFALSE;
   }
+
   
   return kTRUE;
 }
index dacc610..8722d5a 100644 (file)
@@ -40,6 +40,7 @@ public:
   void SetRequireV0and(UChar_t type=1)          { fRequireV0and=type;           }
   void SetMinVtxContributors(Int_t min=1)       { fMinVtxContributors=min;      }
   void SetCutOnMultipicityITSTPC(Bool_t mult=kTRUE) { fMultITSTPC=mult;         }
+  void SetCentralityRange(Double_t min, Double_t max) { fCentMin=min; fCentMax=max; }
   //
   //Analysis cuts interface
   //
@@ -54,6 +55,8 @@ private:
   Bool_t   fRequireVtx;             // require a vertex
   Int_t    fMinVtxContributors;     // min number of vertex contributors
   Bool_t   fMultITSTPC;             // if to cut on the ITS TPC multiplicity correlation (Pb-Pb)
+  Double_t fCentMin;               // minimum multiplity percentile
+  Double_t fCentMax;               // maximum multiplity percentile
   EVtxType fVtxType;                // vertex type
 
   UChar_t fRequireV0and;             // use V0and triggered events only
index 9f4223e..5733344 100644 (file)
@@ -19,6 +19,7 @@
 //
 // Authors: 
 //   Jens Wiechula <Jens.Wiechula@cern.ch> 
+//   Frederick Kramer <Frederick.Kramer@cern.ch> 
 // 
 
 
 #include <TVectorD.h>
 
 #include <AliVEvent.h>
+#include <AliVParticle.h>
 #include <AliKFParticle.h>
+#include <AliESDtrackCuts.h>
+#include <AliESDEvent.h>
+#include <AliMCEvent.h>
+#include <AliAODEvent.h>
+#include <AliAODTracklets.h>
+#include <AliMultiplicity.h>
+#include <AliStack.h>
 
 #include "AliDielectronHelper.h"
 
@@ -114,6 +123,97 @@ TVectorD* AliDielectronHelper::MakeArbitraryBinning(const char* bins)
   return binLimits;
 }
 
+
+//_____________________________________________________________________________
+Int_t AliDielectronHelper::GetNch(const AliMCEvent *ev, Double_t etaRange){
+  // determination of Nch
+  if (!ev || ev->IsA()!=AliMCEvent::Class()) return -1;
+
+  AliStack *stack = ((AliMCEvent*)ev)->Stack();
+
+  if (!stack) return -1;
+
+  Int_t nParticles = stack->GetNtrack();
+  Int_t nCh = 0;
+
+  // count..
+  for (Int_t iMc = 0; iMc < nParticles; ++iMc) {
+    if (!stack->IsPhysicalPrimary(iMc)) continue;
+
+    TParticle* particle = stack->Particle(iMc);
+    if (!particle) continue;
+    if (particle->GetPDG()->Charge() == 0) continue;
+
+    Float_t eta = particle->Eta();
+    if (TMath::Abs(eta) < TMath::Abs(etaRange)) nCh++;
+  }
+
+  return nCh;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliDielectronHelper::GetNaccTrcklts(const AliVEvent *ev){
+  // Compute the collision multiplicity based on AOD or ESD tracklets
+  // Code taken from: AliAnalysisTaskMuonCollisionMultiplicity::ComputeMultiplicity()
+
+  if (!ev) return -1;
+
+  Int_t nTracklets = 0;
+  Int_t nAcc = 0;
+  Double_t etaRange = 1.6;
+  
+  if (ev->IsA() == AliAODEvent::Class()) {
+    AliAODTracklets *tracklets = ((AliAODEvent*)ev)->GetTracklets();
+    nTracklets = tracklets->GetNumberOfTracklets();
+    for (Int_t nn = 0; nn < nTracklets; nn++) {
+      Double_t theta = tracklets->GetTheta(nn);
+      Double_t eta = -TMath::Log(TMath::Tan(theta/2.0));
+      if (TMath::Abs(eta) < etaRange) nAcc++;
+    }
+  } else if (ev->IsA() == AliESDEvent::Class()) {
+    nTracklets = ((AliESDEvent*)ev)->GetMultiplicity()->GetNumberOfTracklets();
+    for (Int_t nn = 0; nn < nTracklets; nn++) {
+      Double_t eta = ((AliESDEvent*)ev)->GetMultiplicity()->GetEta(nn);
+      if (TMath::Abs(eta) < etaRange) nAcc++;
+    }
+  } else return -1;
+
+  return nAcc;
+}
+
+
+//_____________________________________________________________________________
+Int_t AliDielectronHelper::GetNacc(const AliVEvent *ev){
+  // put a robust Nacc definition here
+
+  return -1;
+  if (!ev || ev->IsA()!=AliESDEvent::Class()) return -1;
+  
+  // basic track cuts for the N_acc definition
+  AliESDtrackCuts esdTC;
+  esdTC.SetMaxDCAToVertexZ(3.0);
+  esdTC.SetMaxDCAToVertexXY(1.0);
+  esdTC.SetEtaRange( -0.9 , 0.9 );
+  esdTC.SetAcceptKinkDaughters(kFALSE);
+  esdTC.SetRequireITSRefit(kTRUE);
+  esdTC.SetRequireTPCRefit(kTRUE);
+  esdTC.SetMinNClustersTPC(70);
+  esdTC.SetMaxChi2PerClusterTPC(4);
+  esdTC.SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
+
+  Int_t nRecoTracks = ev->GetNumberOfTracks();
+  Int_t nAcc = 0;
+
+  for (Int_t iTrack = 0; iTrack < nRecoTracks; iTrack++) {
+    AliVParticle* candidate = ev->GetTrack(iTrack);
+    if (esdTC.IsSelected(candidate)) nAcc++;
+  }
+
+  return nAcc;
+}
+
+
 //_____________________________________________________________________________
 void AliDielectronHelper::RotateKFParticle(AliKFParticle * kfParticle,Double_t angle, const AliVEvent * const ev){
   // Before rotate needs to be moved to position 0,0,0, ; move back after rotation
index e5d2de9..7cc7a97 100644 (file)
@@ -18,6 +18,7 @@
 
 class AliKFParticle;
 class AliVEvent;
+class AliMCEvent;
 
 namespace AliDielectronHelper
 {
@@ -28,6 +29,10 @@ TVectorD* MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax);
 TVectorD* MakeLinBinning(Int_t nbinsX, Double_t xmin, Double_t xmax);
 TVectorD* MakeArbitraryBinning(const char* bins);
 
+Int_t GetNch(const AliMCEvent *ev=0x0, Double_t eta=0.9);
+Int_t GetNacc(const AliVEvent *ev=0x0);
+Int_t GetNaccTrcklts(const AliVEvent *ev=0x0);
+
 void RotateKFParticle(AliKFParticle * kfParticle,Double_t angle, const AliVEvent * const ev=0x0);
 
 
index ed788aa..24e4b34 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 //
 // Generic Histogram container with support for groups and filling of groups by passing
 // a vector of data
index 0c0ab64..977e295 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 ///////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                       //
 // Generic Histogram container with support for groups and filling of groups by passing  //
index b4e37bd..a372029 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 //#####################################################
 //#                                                   # 
 //#              Class AliDielectronMC                #
@@ -40,6 +38,8 @@
 #include <AliLog.h>
 
 #include <TClonesArray.h>
+
+#include "AliDielectronSignalMC.h"
 #include "AliDielectronMC.h"
 
 AliDielectronMC* AliDielectronMC::fgInstance=0x0;
@@ -650,6 +650,362 @@ void AliDielectronMC::GetDaughters(const TObject *mother, AliVParticle* &d1, Ali
    }
 }
 
+
+//________________________________________________________________________________
+Int_t AliDielectronMC::GetMothersLabel(Int_t daughterLabel) {
+  //
+  //  Get the label of the mother for particle with label daughterLabel
+  //
+  if(daughterLabel<0) return -1;
+  if (fAnaType==kAOD) {
+    if(!fMcArray) return -1;
+    return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
+  } else if(fAnaType==kESD) {
+    if (!fMCEvent) return -1;
+    return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
+  }
+  return -1;
+}
+
+
+//________________________________________________________________________________
+Int_t AliDielectronMC::GetPdgFromLabel(Int_t label) {
+  //
+  //  Get particle code using the label from stack
+  //
+  if(label<0) return 0;
+  if(fAnaType==kAOD) {
+    if(!fMcArray) return 0;
+    return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
+  } else if(fAnaType==kESD) {
+    if (!fMCEvent) return 0;
+    return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
+  }
+  return 0;
+}
+
+
+//________________________________________________________________________________
+Bool_t AliDielectronMC::ComparePDG(Int_t particlePDG, Int_t requiredPDG, Bool_t checkBothCharges) const {
+  //
+  //  Test the PDG codes of particles with the required ones
+  //
+  Bool_t result = kTRUE;
+  Int_t absRequiredPDG = TMath::Abs(requiredPDG);
+  switch(absRequiredPDG) {
+  case 0:
+    result = kTRUE;    // PDG not required (any code will do fine)
+    break;
+  case 100:     // all light flavoured mesons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=100 && TMath::Abs(particlePDG)<=299;
+    else {
+      if(requiredPDG>0) result = particlePDG>=100 && particlePDG<=299;
+      if(requiredPDG<0) result = particlePDG>=-299 && particlePDG<=-100;
+    }
+    break;
+  case 1000:     // all light flavoured baryons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=1000 && TMath::Abs(particlePDG)<=2999;
+    else {
+      if(requiredPDG>0) result = particlePDG>=1000 && particlePDG<=2999;
+      if(requiredPDG<0) result = particlePDG>=-2999 && particlePDG<=-1000;
+    }
+    break;
+  case 200:     // all light flavoured mesons  (as for the 100 case)
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=100 && TMath::Abs(particlePDG)<=299;
+    else {
+      if(requiredPDG>0)result = particlePDG>=100 && particlePDG<=299;
+      if(requiredPDG<0)result = particlePDG>=-299 && particlePDG<=-100;
+    }
+    break;
+  case 2000:     // all light flavoured baryons (as for the 1000 case)
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=1000 && TMath::Abs(particlePDG)<=2999;
+    else {
+      if(requiredPDG>0) result = particlePDG>=1000 && particlePDG<=2999;
+      if(requiredPDG<0) result = particlePDG>=-2999 && particlePDG<=-1000;
+    }
+    break;
+  case 300:     // all strange mesons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=300 && TMath::Abs(particlePDG)<=399;
+    else {
+      if(requiredPDG>0) result = particlePDG>=300 && particlePDG<=399;
+      if(requiredPDG<0) result = particlePDG>=-399 && particlePDG<=-300;
+    }
+    break;
+  case 3000:     // all strange baryons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=3000 && TMath::Abs(particlePDG)<=3999;
+    else {
+      if(requiredPDG>0) result = particlePDG>=3000 && particlePDG<=3999;
+      if(requiredPDG<0) result = particlePDG>=-3999 && particlePDG<=-3000;
+    }
+    break;
+  case 400:     // all charmed mesons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=499;
+    else {
+      if(requiredPDG>0) result = particlePDG>=400 && particlePDG<=499;
+      if(requiredPDG<0) result = particlePDG>=-499 && particlePDG<=-400;
+    }
+    break;
+  case 4000:     // all charmed baryons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4999;
+    else {
+      if(requiredPDG>0) result = particlePDG>=4000 && particlePDG<=4999;
+      if(requiredPDG<0) result = particlePDG>=-4999 && particlePDG<=-4000;
+    }
+    break;
+  case 500:      // all beauty mesons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=599;
+    else {
+      if(requiredPDG>0) result = particlePDG>=500 && particlePDG<=599;
+      if(requiredPDG<0) result = particlePDG>=-599 && particlePDG<=-500;
+    }
+    break;
+  case 5000:      // all beauty baryons
+    if(checkBothCharges)
+      result = TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5999;
+    else {
+      if(requiredPDG>0) result = particlePDG>=5000 && particlePDG<=5999;
+      if(requiredPDG<0) result = particlePDG>=-5999 && particlePDG<=-5000;
+    }
+    break;
+  default:          // all specific cases
+    if(checkBothCharges)
+      result = (absRequiredPDG==TMath::Abs(particlePDG));
+    else
+      result = (requiredPDG==particlePDG);
+  }
+
+  return result;
+}
+
+
+//________________________________________________________________________________
+Bool_t AliDielectronMC::CheckParticleSource(Int_t label, AliDielectronSignalMC::ESource source) {
+  //
+  //  Check the source for the particle 
+  //
+
+  switch (source) {
+    case AliDielectronSignalMC::kDontCare :
+      return kTRUE;
+    break;
+    case AliDielectronSignalMC::kPrimary :
+      if(label>=0 && label<GetNPrimary()) return kTRUE;
+      else return kFALSE;
+    break;
+    case AliDielectronSignalMC::kSecondary :
+      if(label>=GetNPrimary()) return kTRUE;
+      else return kFALSE;
+    break;
+    case AliDielectronSignalMC::kDirect :
+      if(label>=0 && GetMothersLabel(label)<0) return kTRUE;
+      else return kFALSE;
+    break;
+    case AliDielectronSignalMC::kDecayProduct :
+      if(label>=0 && GetMothersLabel(label)>=0) return kTRUE;
+      else return kFALSE;
+    break;
+    default :
+      return kFALSE;
+  }
+  return kFALSE;
+}
+
+
+//________________________________________________________________________________
+Bool_t AliDielectronMC::IsMCTruth(Int_t label, AliDielectronSignalMC* signalMC, Int_t branch) {
+  //
+  // Check if the particle corresponds to the MC truth in signalMC in the branch specified
+  //
+  
+  // NOTE:  Some particles have the sign of the label flipped. It is related to the quality of matching
+  //        between the ESD and the MC track. The negative labels indicate a poor matching quality
+  //if(label<0) return kFALSE;
+  if(label<0) label *= -1; 
+  AliVParticle* part = GetMCTrackFromMCEvent(label);
+  // check the leg
+  if(!ComparePDG(part->PdgCode(),signalMC->GetLegPDG(branch),signalMC->GetCheckBothChargesLegs(branch))) return kFALSE;
+  if(!CheckParticleSource(label, signalMC->GetLegSource(branch))) return kFALSE;
+
+  // check the mother
+  AliVParticle* mcMother=0x0;
+  Int_t mLabel = -1;
+  if(signalMC->GetMotherPDG(branch)!=0 || signalMC->GetMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
+    if(part) {
+      mLabel = GetMothersLabel(label);
+      mcMother = GetMCTrackFromMCEvent(mLabel);
+    }
+    if(!mcMother) return kFALSE;
+
+    if(!ComparePDG(mcMother->PdgCode(),signalMC->GetMotherPDG(branch),signalMC->GetCheckBothChargesMothers(branch))) return kFALSE;
+    if(!CheckParticleSource(mLabel, signalMC->GetMotherSource(branch))) return kFALSE;
+  }
+
+  // check the grandmother
+  if(signalMC->GetGrandMotherPDG(branch)!=0 || signalMC->GetGrandMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
+    AliVParticle* mcGrandMother=0x0;
+    Int_t gmLabel = -1;
+    if(mcMother) {
+      gmLabel = GetMothersLabel(mLabel);
+      mcGrandMother = static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(gmLabel));
+    }
+    if(!mcGrandMother) return kFALSE;
+    
+    if(!ComparePDG(mcGrandMother->PdgCode(),signalMC->GetGrandMotherPDG(branch),signalMC->GetCheckBothChargesGrandMothers(branch))) return kFALSE;
+    if(!CheckParticleSource(gmLabel, signalMC->GetGrandMotherSource(branch))) return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+
+//________________________________________________________________________________
+Bool_t AliDielectronMC::IsMCTruth(const AliDielectronPair* pair, AliDielectronSignalMC* signalMC) {
+  //
+  // Check if the pair corresponds to the MC truth in signalMC 
+  //
+  // legs (daughters)
+  const AliVParticle * mcD1 = pair->GetFirstDaughter();
+  const AliVParticle * mcD2 = pair->GetSecondDaughter();
+  Int_t labelD1 = (mcD1 ? mcD1->GetLabel() : -1);
+  Int_t labelD2 = (mcD2 ? mcD2->GetLabel() : -1);
+  if(labelD1<0) labelD1 *= -1;
+  if(labelD2<0) labelD2 *= -1;
+  Int_t d1Pdg = 0;
+  Int_t d2Pdg = 0;
+  d1Pdg=GetPdgFromLabel(labelD1);
+  d2Pdg=GetPdgFromLabel(labelD2);
+  
+  // mothers
+  AliVParticle* mcM1=0x0;
+  AliVParticle* mcM2=0x0;
+  
+  // grand-mothers
+  AliVParticle* mcG1 = 0x0;
+  AliVParticle* mcG2 = 0x0;
+  
+  // make direct(1-1 and 2-2) and cross(1-2 and 2-1) comparisons for the whole branch
+  Bool_t directTerm = kTRUE;
+  // daughters
+  directTerm = directTerm && mcD1 && ComparePDG(d1Pdg,signalMC->GetLegPDG(1),signalMC->GetCheckBothChargesLegs(1)) 
+               && CheckParticleSource(labelD1, signalMC->GetLegSource(1));
+    
+  directTerm = directTerm && mcD2 && ComparePDG(d2Pdg,signalMC->GetLegPDG(2),signalMC->GetCheckBothChargesLegs(2))
+               && CheckParticleSource(labelD2, signalMC->GetLegSource(2));
+    
+  // mothers
+  Int_t labelM1 = -1;
+  if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
+    labelM1 = GetMothersLabel(labelD1);
+    if(labelD1>-1 && labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);
+    directTerm = directTerm && mcM1 
+                 && ComparePDG(mcM1->PdgCode(),signalMC->GetMotherPDG(1),signalMC->GetCheckBothChargesMothers(1))
+                 && CheckParticleSource(labelM1, signalMC->GetMotherSource(1));
+  }
+  
+  Int_t labelM2 = -1;
+  if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
+    labelM2 = GetMothersLabel(labelD2);
+    if(labelD2>-1 && labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
+    directTerm = directTerm && mcM2 
+                 && ComparePDG(mcM2->PdgCode(),signalMC->GetMotherPDG(2),signalMC->GetCheckBothChargesMothers(2))
+                 && CheckParticleSource(labelM2, signalMC->GetMotherSource(2));
+  }
+  // grand-mothers
+  Int_t labelG1 = -1;
+  if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
+    labelG1 = GetMothersLabel(labelM1);
+    if(mcM1 && labelG1>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
+    directTerm = directTerm && mcG1 
+                 && ComparePDG(mcG1->PdgCode(),signalMC->GetGrandMotherPDG(1),signalMC->GetCheckBothChargesGrandMothers(1))
+                 && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(1));
+  }
+
+  Int_t labelG2 = -1;
+  if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
+    labelG2 = GetMothersLabel(labelM2);
+    if(mcM2 && labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
+    directTerm = directTerm && mcG2 
+                 && ComparePDG(mcG2->PdgCode(),signalMC->GetGrandMotherPDG(2),signalMC->GetCheckBothChargesGrandMothers(2))
+                 && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(2));
+  }
+
+  // Cross term
+  Bool_t crossTerm = kTRUE;
+  // daughters
+  crossTerm = crossTerm && mcD2 
+              && ComparePDG(d2Pdg,signalMC->GetLegPDG(1),signalMC->GetCheckBothChargesLegs(1))
+              && CheckParticleSource(labelD2, signalMC->GetLegSource(1));
+    
+  crossTerm = crossTerm && mcD1 
+              && ComparePDG(d1Pdg,signalMC->GetLegPDG(2),signalMC->GetCheckBothChargesLegs(2))
+              && CheckParticleSource(labelD1, signalMC->GetLegSource(2));
+  
+  // mothers  
+  if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
+    if(!mcM2 && labelD2>-1) {
+      labelM2 = GetMothersLabel(labelD2);
+      if(labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
+    }
+    crossTerm = crossTerm && mcM2 
+                && ComparePDG(mcM2->PdgCode(),signalMC->GetMotherPDG(1),signalMC->GetCheckBothChargesMothers(1))
+                && CheckParticleSource(labelM2, signalMC->GetMotherSource(1));
+  }
+  
+  if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
+    if(!mcM1 && labelD1>-1) {
+      labelM1 = GetMothersLabel(labelD1);
+      if(labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);  
+    }
+    crossTerm = crossTerm && mcM1 
+                && ComparePDG(mcM1->PdgCode(),signalMC->GetMotherPDG(2),signalMC->GetCheckBothChargesMothers(2))
+                && CheckParticleSource(labelM1, signalMC->GetMotherSource(2));
+  }
+
+  // grand-mothers
+  if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
+    if(!mcG2 && mcM2) {
+      labelG2 = GetMothersLabel(labelM2);
+      if(labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
+    }
+    crossTerm = crossTerm && mcG2 
+                && ComparePDG(mcG2->PdgCode(),signalMC->GetGrandMotherPDG(1),signalMC->GetCheckBothChargesGrandMothers(1))
+                && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(1));
+  }
+
+  if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
+    if(!mcG1 && mcM1) {
+      labelG1 = GetMothersLabel(labelM1);
+      if(labelG2>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
+    }
+    crossTerm = crossTerm && mcG1 
+                && ComparePDG(mcG1->PdgCode(),signalMC->GetGrandMotherPDG(2),signalMC->GetCheckBothChargesGrandMothers(2))
+                && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(2));
+  }
+
+  Bool_t motherRelation = kTRUE;
+  if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kSame) {
+    motherRelation = motherRelation && HaveSameMother(pair);
+  }
+  if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kDifferent) {
+    motherRelation = motherRelation && !HaveSameMother(pair);
+  }
+  return ((directTerm || crossTerm) && motherRelation);
+}
+
+
+
 //____________________________________________________________
 Bool_t AliDielectronMC::HaveSameMother(const AliDielectronPair * pair)
 {
index 6be9d96..a8207c4 100644 (file)
@@ -3,8 +3,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#####################################################
 //#                                                   # 
 //#              Class AliDielectronMC                #
@@ -27,6 +25,7 @@ class TParticle;
 class AliMCParticle;
 class AliAODMCParticle;
 
+#include "AliDielectronSignalMC.h"
 #include "AliDielectronPair.h"
 
 class AliDielectronMC : public TObject{
@@ -64,6 +63,10 @@ public:
   Bool_t IsMotherPdg(const AliDielectronPair* pair, Int_t pdgMother);
   Bool_t IsMotherPdg(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother);
   Bool_t IsMCMotherToEE(const AliVParticle *particle, Int_t pdgMother);
+  Bool_t IsMCTruth(const AliDielectronPair* pair, AliDielectronSignalMC* signalMC);
+  Bool_t IsMCTruth(Int_t ipart, AliDielectronSignalMC* signalMC, Int_t branch);
+  Int_t GetMothersLabel(Int_t daughterLabel);
+  Int_t GetPdgFromLabel(Int_t label);
 
   Bool_t HaveSameMother(const AliDielectronPair *pair);
   
@@ -90,6 +93,8 @@ public:
   void GetDaughters(const TObject *mother, AliVParticle* &d1, AliVParticle* &d2);
   Int_t IsJpsiPrimary(const AliDielectronPair * pair);
   Int_t IsJpsiPrimary(const AliVParticle * pair);
+
+  AliMCEvent* GetMCEvent() { return fMCEvent; }         // return the AliMCEvent
   
 private:
   AliMCEvent    *fMCEvent;  // MC event object
@@ -111,6 +116,8 @@ private:
   Int_t GetLabelMotherWithPdgESD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother);
   Int_t GetLabelMotherWithPdgAOD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother);
   
+  Bool_t ComparePDG(Int_t particlePDG, Int_t requiredPDG, Bool_t checkBothCharges) const;
+  Bool_t CheckParticleSource(Int_t label, AliDielectronSignalMC::ESource source);
   ClassDef(AliDielectronMC, 0)
 };
 
index b70f9fe..4cb68da 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                Dielectron PID                                  //
 //                                                                       //
@@ -422,13 +420,34 @@ void AliDielectronPID::SetDefaults(Int_t def){
     lowerCut->SetParameters(-2.65,-0.6757);
     AddCut(kTPC,AliPID::kElectron,lowerCut,4.);
     AddCut(kTOF,AliPID::kElectron,-5,5,0,200,kFALSE,AliDielectronPID::kIfAvailable);
+
   } else if (def==10) {
     AddCut(kTOF,AliPID::kElectron,-5,5,0,200,kFALSE,AliDielectronPID::kIfAvailable);
     AddCut(kTPC,AliPID::kElectron,3.);
     AddCut(kTPC,AliPID::kPion,-3.,3.,0.,0.,kTRUE);
     AddCut(kTPC,AliPID::kProton,-3.,3.,0.,0.,kTRUE);
     
+  } else if (def==11) {
+    // lower cut TPC: parametrisation by HFE
+    // only use from period d on !!
+    // upper cut TPC: 3 sigma
+    // TOF ele band 3sigma 0<p<2.0GeV
+    TF1 *lowerCut=new TF1("lowerCut", "[0] * TMath::Exp([1]*x)+[2]", 0, 100);
+    lowerCut->SetParameters(-3.718,-0.4,0.27);
+    AddCut(kTPC,AliPID::kElectron,lowerCut,3.);
+    AddCut(kTOF,AliPID::kElectron,-3,3,0,2.);
+  } else if (def==12) {
+    // lower cut TPC: parametrisation by HFE
+    // only use from period d on !!
+    // upper cut TPC: 3 sigma
+    // TOF 5 sigma inclusion if TOFpid available
+    // this should reduce K,p,Pi to a large extent
+    TF1 *lowerCut=new TF1("lowerCut", "[0] * TMath::Exp([1]*x)+[2]", 0, 100);
+    lowerCut->SetParameters(-3.718,-0.4,0.27);
+    AddCut(kTPC,AliPID::kElectron,lowerCut,4.);
+    AddCut(kTOF,AliPID::kElectron,-5,5,0,200,kFALSE,AliDielectronPID::kIfAvailable);
   }
+
 }
 
 //______________________________________________
index 7758920..8ffe33c 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronPID                     #
index e4262bd..8d1eb3d 100644 (file)
 ///////////////////////////////////////////////////////////////////////////
 
 
+#include <TDatabasePDG.h>
+#include <AliVTrack.h>
+#include <AliVVertex.h>
+#include <AliPID.h>
+
 #include "AliDielectronPair.h"
-#include "AliVTrack.h"
-#include "AliPID.h"
 
 ClassImp(AliDielectronPair)
 
@@ -330,3 +333,24 @@ Double_t AliDielectronPair::ThetaPhiCM(const Bool_t isHE, const Bool_t isTheta)
       return TMath::ATan2((p2Mom.Vect()).Dot(yAxis), (p2Mom.Vect()).Dot(xAxis));
   }
 }
+
+//______________________________________________
+Double_t AliDielectronPair::GetLXY(const AliVVertex * const vtx) const
+{
+  //
+  // Calculate the decay length in XY taking into account the primary vertex position
+  //
+  if(!vtx) return 0;
+  return ( (Xv()-vtx->GetX()) * Px() + (Yv()-vtx->GetY()) * Py() )/Pt()  ;
+}
+
+//______________________________________________
+Double_t AliDielectronPair::GetPseudoProperTime(const AliVVertex * const vtx) const
+{
+  //
+  // Calculate the pseudo proper time
+  //
+  Double_t lxy=GetLXY(vtx);
+  Double_t psProperDecayLength = lxy*(TDatabasePDG::Instance()->GetParticle(443)->Mass())/Pt();
+  return psProperDecayLength;
+}
index ca4344d..8c22e09 100644 (file)
@@ -27,6 +27,7 @@
 #include <AliKFParticle.h>
 #include <AliVParticle.h>
 
+class AliVVertex;
 class AliVTrack;
 
 //TODO
@@ -90,12 +91,17 @@ public:
   virtual const Double_t *PID() const { return 0;} //TODO: check
   // Dummy
   Int_t PdgCode() const {return 0;}
+  //
+  Double_t GetLXY(const AliVVertex * const vtx) const;
+  Double_t GetPseudoProperTime(const AliVVertex * const vtx) const;
 
 
   UChar_t GetType() const { return fType; }
   void SetType(Char_t type) { fType=type; }
 
   void SetLabel(Int_t label) {fLabel=label;}
+
+  void SetProductionVertex(const AliKFParticle &Vtx) { fPair.SetProductionVertex(Vtx); }
   
   //inter leg information
   Double_t OpeningAngle()         const { return fD1.GetAngle(fD2);                             }
index 0920b38..0c62499 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //   Cut class providing cuts for both legs in the AliDielectronPair     //
 //                                                                       //
index c56156d..2e10a8d 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronPairLegCuts                    #
index 8cc640d..da3cc99 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                Dielectron SignalBase                                  //
 //                                                                       //
index dd021f3..5f937f6 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronSignalBase                       #
index 88e0329..35801b4 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 //                      Dielectron SignalExt                             //
@@ -199,6 +197,13 @@ void AliDielectronSignalExt::ProcessRotation(TObjArray* const arrhist)
     fHistDataPM=0x0;
     return;
   }
+  fHistBackground->Sumw2();
+
+  // rebin the histograms
+  if (fRebin>1) {
+    fHistDataPM->Rebin(fRebin);
+    fHistBackground->Rebin(fRebin);
+  }
 
   //scale histograms to match integral between fScaleMin and fScaleMax
   if (fScaleMax>fScaleMin) fScaleFactor=ScaleHistograms(fHistDataPM,fHistBackground,fScaleMin,fScaleMax);
index a100117..7af43d1 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#           Class AliDielectronSignalExt                    #
index 4bd7a7d..17c34a1 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                Dielectron SignalFunc                                  //
 //                                                                       //
index d034ad9..3797350 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronSignalFunc                     #
diff --git a/PWG3/dielectron/AliDielectronSignalMC.cxx b/PWG3/dielectron/AliDielectronSignalMC.cxx
new file mode 100644 (file)
index 0000000..991500b
--- /dev/null
@@ -0,0 +1,101 @@
+/*************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//                Dielectron MC signal description container             //
+//                                                                       //
+//                                                                       //
+/*
+ * A container to describe the decay of a two body process
+ * 
+ * 
+ * 
+ * 
+ * 
+ */
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include "AliDielectronSignalMC.h"
+
+ClassImp(AliDielectronSignalMC)
+
+//_________________________________________________________________________
+AliDielectronSignalMC::AliDielectronSignalMC() :
+  TNamed("AliDielectronSignalMC", "AliDielectronSignalMC"),
+  fLeg1(0),
+  fLeg2(0),
+  fMother1(0),
+  fMother2(0),
+  fGrandMother1(0),
+  fGrandMother2(0),
+  fLeg1Source(kDontCare),
+  fLeg2Source(kDontCare),
+  fMother1Source(kDontCare),
+  fMother2Source(kDontCare),
+  fGrandMother1Source(kDontCare),
+  fGrandMother2Source(kDontCare),
+  fCheckBothChargesLeg1(kFALSE),
+  fCheckBothChargesLeg2(kFALSE),
+  fCheckBothChargesMother1(kFALSE),
+  fCheckBothChargesMother2(kFALSE),
+  fCheckBothChargesGrandMother1(kFALSE),
+  fCheckBothChargesGrandMother2(kFALSE),
+  fMothersRelation(kUndefined),
+  fFillPureMCStep(kFALSE) {
+
+  //
+  // Default constructor
+  //
+}
+
+
+//_________________________________________________________________________
+AliDielectronSignalMC::AliDielectronSignalMC(const Char_t* name, const Char_t* title) :
+  TNamed(name, title),
+  fLeg1(0),
+  fLeg2(0),
+  fMother1(0),
+  fMother2(0),
+  fGrandMother1(0),
+  fGrandMother2(0),
+  fLeg1Source(kDontCare),
+  fLeg2Source(kDontCare),
+  fMother1Source(kDontCare),
+  fMother2Source(kDontCare),
+  fGrandMother1Source(kDontCare),
+  fGrandMother2Source(kDontCare),
+  fCheckBothChargesLeg1(kFALSE),
+  fCheckBothChargesLeg2(kFALSE),
+  fCheckBothChargesMother1(kFALSE),
+  fCheckBothChargesMother2(kFALSE),
+  fCheckBothChargesGrandMother1(kFALSE),
+  fCheckBothChargesGrandMother2(kFALSE),
+  fMothersRelation(kUndefined),
+  fFillPureMCStep(kFALSE) {
+
+  //
+  // Named constructor
+  //
+}
+
+
+
+//_________________________________________________________________________
+AliDielectronSignalMC::~AliDielectronSignalMC() {
+  //
+  //  Destructor
+  //
+}
diff --git a/PWG3/dielectron/AliDielectronSignalMC.h b/PWG3/dielectron/AliDielectronSignalMC.h
new file mode 100644 (file)
index 0000000..fe72655
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef ALIDIELECTRONSIGNALMC_H
+#define ALIDIELECTRONSIGNALMC_H
+
+#include <TNamed.h>
+
+
+/*
+   Monte Carlo signal definition:
+      Leg #1  <-- Mother #1  <--  Grandmother #1
+                      |
+      Leg #2  <-- Mother #2  <--  Grandmother #2
+   All particles can be classified as:
+     1. Primary   - particle originating in the physics event
+     2. Secondary - particle created during the GEANT propagation due to interaction of primaries with the material
+     3. Direct    - particle directly created in the collision (has no mother)
+     4. Secondary - particle which is the product of the decay or reinteraction of another particle
+   The 2 legs can originate from the same or different mother particles.
+*/
+
+
+//__________________________________________________________________
+class AliDielectronSignalMC : public TNamed {
+  
+ public:
+  enum EBranchRelation {kUndefined=0, kSame, kDifferent};
+  enum ESource {kDontCare=0, kPrimary, kSecondary, kDirect, kDecayProduct};
+  
+  AliDielectronSignalMC();
+  AliDielectronSignalMC(const Char_t* name, const Char_t* title);
+  virtual ~AliDielectronSignalMC();
+  
+  void SetLegPDGs(Int_t pdg1, Int_t pdg2)                 {fLeg1 = pdg1; fLeg2 = pdg2;}
+  void SetMotherPDGs(Int_t pdg1, Int_t pdg2)              {fMother1 = pdg1; fMother2 = pdg2;}
+  void SetGrandMotherPDGs(Int_t pdg1, Int_t pdg2)         {fGrandMother1 = pdg1; fGrandMother2 = pdg2;}
+  void SetLegSources(ESource s1, ESource s2)              {fLeg1Source = s1; fLeg2Source = s2;}
+  void SetMotherSources(ESource s1, ESource s2)           {fMother1Source = s1; fMother2Source = s2;}
+  void SetGrandMotherSources(ESource s1, ESource s2)      {fGrandMother1Source = s1; fGrandMother2Source = s2;}
+  void SetCheckBothChargesLegs(Bool_t flag1, Bool_t flag2) {fCheckBothChargesLeg1 = flag1; fCheckBothChargesLeg2 = flag2;}
+  void SetCheckBothChargesMothers(Bool_t flag1, Bool_t flag2) {fCheckBothChargesMother1 = flag1; fCheckBothChargesMother2 = flag2;}
+  void SetCheckBothChargesGrandMothers(Bool_t flag1, Bool_t flag2) {fCheckBothChargesGrandMother1 = flag1; fCheckBothChargesGrandMother2 = flag2;}
+  void SetMothersRelation(EBranchRelation relation)       {fMothersRelation = relation;}
+  void SetFillPureMCStep(Bool_t fill=kTRUE)               {fFillPureMCStep = fill;}
+
+  Int_t GetLegPDG(Int_t branch) const                     {return (branch==1 ? fLeg1 : fLeg2);}
+  Int_t GetMotherPDG(Int_t branch) const                  {return (branch==1 ? fMother1 : fMother2);}
+  Int_t GetGrandMotherPDG(Int_t branch) const             {return (branch==1 ? fGrandMother1 : fGrandMother2);}
+  ESource GetLegSource(Int_t branch) const                {return (branch==1 ? fLeg1Source : fLeg2Source);}
+  ESource GetMotherSource(Int_t branch) const             {return (branch==1 ? fMother1Source : fMother2Source);}
+  ESource GetGrandMotherSource(Int_t branch) const        {return (branch==1 ? fGrandMother1Source : fGrandMother2Source);}
+  Bool_t GetCheckBothChargesLegs(Int_t branch) const      {return (branch==1 ? fCheckBothChargesLeg1 : fCheckBothChargesLeg2);}
+  Bool_t GetCheckBothChargesMothers(Int_t branch) const   {return (branch==1 ? fCheckBothChargesMother1 : fCheckBothChargesMother2);}
+  Bool_t GetCheckBothChargesGrandMothers(Int_t branch) const   {return (branch==1 ? fCheckBothChargesGrandMother1 : fCheckBothChargesGrandMother2);}
+  EBranchRelation GetMothersRelation() const              {return fMothersRelation;}
+  Bool_t GetFillPureMCStep() const                        {return fFillPureMCStep;}
+
+ private:
+  Int_t fLeg1;                        // leg 1 PDG
+  Int_t fLeg2;                        // leg 2 PDG
+  Int_t fMother1;                     // mother 1 PDG
+  Int_t fMother2;                     // mother 2 PDG
+  Int_t fGrandMother1;                // grandmother 1 PDG
+  Int_t fGrandMother2;                // grandmother 2 PDG
+    
+  ESource fLeg1Source;                // leg 1 source
+  ESource fLeg2Source;                // leg 2 source
+  ESource fMother1Source;             // mother 1 source
+  ESource fMother2Source;             // mother 2 source
+  ESource fGrandMother1Source;        // grandmother 1 source
+  ESource fGrandMother2Source;        // grandmother 2 source
+
+  Bool_t fCheckBothChargesLeg1;         // check both charges of the legs pdg
+  Bool_t fCheckBothChargesLeg2;         //                leg2
+  Bool_t fCheckBothChargesMother1;      //                mother 1
+  Bool_t fCheckBothChargesMother2;      //                mother 2
+  Bool_t fCheckBothChargesGrandMother1; //              grand mother 1
+  Bool_t fCheckBothChargesGrandMother2; //              grand mother 2
+  
+  EBranchRelation fMothersRelation;   // mother 1&2 relation (same, different or whatever)
+  
+  Bool_t fFillPureMCStep;             // check and fill the pure MC step
+  
+  ClassDef(AliDielectronSignalMC,1);
+};
+
+#endif
index 2bef9d5..ed4ae10 100644 (file)
@@ -14,8 +14,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //                Add general description                                 //
 //                                                                       //
index f728bf8..265221f 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronSpectrum                       #
diff --git a/PWG3/dielectron/AliDielectronTRDpidCut.cxx b/PWG3/dielectron/AliDielectronTRDpidCut.cxx
new file mode 100644 (file)
index 0000000..2bbd63f
--- /dev/null
@@ -0,0 +1,397 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Class for TRD PID
+// Class further contains TRD specific cuts and QA histograms 
+//  
+// Authors:
+//   Jens Wiechula <Jens.Wiechula@cern.ch>
+//   Markus Fasel <M.Fasel@gsi.de>  
+// 
+#include <TList.h>
+#include <TString.h>
+
+#include <AliVParticle.h>
+#include <AliESDtrack.h>
+#include <AliLog.h>
+#include <AliPID.h>
+
+#include "AliDielectronTRDpidCut.h"
+
+ClassImp(AliDielectronTRDpidCut)
+
+const Double_t AliDielectronTRDpidCut::fgkVerySmall = 1e-12;
+
+//___________________________________________________________________
+AliDielectronTRDpidCut::AliDielectronTRDpidCut() :
+    AliAnalysisCuts()
+  , fMinP(1.)
+  , fElectronEfficiency(0.91)
+  , fPIDMethod(kNN)
+  , fRequirePIDbit(0)
+{
+  //
+  // default  constructor
+  // 
+  memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
+  SetUseDefaultParameters();
+}
+
+//___________________________________________________________________
+AliDielectronTRDpidCut::AliDielectronTRDpidCut(const char* name) :
+    AliAnalysisCuts(name,name)
+  , fMinP(1.)
+  , fElectronEfficiency(0.91)
+  , fPIDMethod(kNN)
+  , fRequirePIDbit(0)
+{
+  //
+  // default  constructor
+  // 
+  memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
+  SetUseDefaultParameters();
+}
+
+//___________________________________________________________________
+AliDielectronTRDpidCut::AliDielectronTRDpidCut(const AliDielectronTRDpidCut &ref):
+    AliAnalysisCuts(ref.GetName(),ref.GetTitle())
+  , fMinP(ref.fMinP)
+  , fElectronEfficiency(ref.fElectronEfficiency)
+  , fPIDMethod(ref.fPIDMethod)
+  , fRequirePIDbit(ref.fRequirePIDbit)
+{
+  //
+  // Copy constructor
+  //
+  memset(fThreshParams, 0, sizeof(Double_t) * kThreshParams);
+  ref.Copy(*this);
+}
+
+//___________________________________________________________________
+AliDielectronTRDpidCut &AliDielectronTRDpidCut::operator=(const AliDielectronTRDpidCut &ref){
+  //
+  // Assignment operator
+  //
+  if(this != &ref){
+    ref.Copy(*this);
+  }
+  return *this;
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::Copy(TObject &ref) const {
+  //
+  // Performs the copying of the object
+  //
+  AliDielectronTRDpidCut &target = dynamic_cast<AliDielectronTRDpidCut &>(ref);
+  
+  Bool_t defaultParameters = UseDefaultParameters();
+  target.SetUseDefaultParameters(defaultParameters);
+  target.fMinP = fMinP;
+  target.fPIDMethod = fPIDMethod;
+  target.fRequirePIDbit = fRequirePIDbit;
+  target.fElectronEfficiency = fElectronEfficiency;
+  memcpy(target.fThreshParams, fThreshParams, sizeof(Double_t) * kThreshParams);
+  AliAnalysisCuts::Copy(ref);
+}
+
+//___________________________________________________________________
+AliDielectronTRDpidCut::~AliDielectronTRDpidCut(){
+  //
+  // Destructor
+  //
+}
+
+//______________________________________________________
+Bool_t AliDielectronTRDpidCut::InitializePID(){
+  //
+  // InitializePID: Load TRD thresholds and create the electron efficiency axis
+  // to navigate 
+  //
+  if(UseDefaultParameters()){
+    if(fPIDMethod == kLQ)
+      InitParameters1DLQ();
+    else
+      InitParameters();
+  }
+  return kTRUE;
+}
+
+//______________________________________________________
+Bool_t AliDielectronTRDpidCut::IsSelected(TObject *track) {
+  //
+  // Does PID for TRD alone:
+  // PID thresholds based on 90% Electron Efficiency level approximated by a linear 
+  // step function
+  //
+  const AliESDtrack *part = dynamic_cast<const AliESDtrack *>(track);
+  
+  if (fRequirePIDbit==AliDielectronTRDpidCut::kRequire&&!(part->GetStatus()&AliESDtrack::kTRDpid)) return kFALSE;
+  if (fRequirePIDbit==AliDielectronTRDpidCut::kIfAvailable&&!(part->GetStatus()&AliESDtrack::kTRDpid)) return kTRUE;
+  
+  Double_t p = GetP((AliVParticle*)track);
+  if(p < fMinP){ 
+    AliDebug(1, Form("Track momentum below %f", fMinP));
+    if(fRequirePIDbit==AliDielectronTRDpidCut::kRequire) return kFALSE;
+       if(fRequirePIDbit==AliDielectronTRDpidCut::kIfAvailable) return kTRUE;
+  }
+
+  Double_t electronLike = GetElectronLikelihood((AliVParticle*)track);
+  Double_t threshold = GetTRDthresholds(fElectronEfficiency, p);
+  AliDebug(1, Form("Threshold: %f\n", threshold));
+  if(electronLike > threshold){
+    return kTRUE;
+  }
+  return kFALSE;
+
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetTRDthresholds(Double_t electronEff, Double_t p) const {
+  //
+  // Return momentum dependent and electron efficiency dependent TRD thresholds
+  // 
+  Double_t params[4];
+  GetParameters(electronEff, params);
+  Double_t threshold = 1. - params[0] - params[1] * p - params[2] * TMath::Exp(-params[3] * p);
+  return TMath::Max(TMath::Min(threshold, 0.99), 0.2); // truncate the threshold upperwards to 0.999 and lowerwards to 0.2 and exclude unphysical values
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::SetThresholdParameters(Double_t electronEff, Double_t *params){
+  //
+  // Set threshold parameters for the given bin
+  //
+  if(electronEff >= 1. || electronEff < 0.7) return;
+  Int_t effbin = static_cast<Int_t>((electronEff - 0.7)/0.05); 
+  memcpy(&fThreshParams[effbin * 4], params, sizeof(Double_t) * 4); 
+  SetUseDefaultParameters(kFALSE);
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::InitParameters(){
+  //
+  // Fill the Parameters into an array
+  //
+
+  AliDebug(2, "Loading threshold Parameter");
+  // Parameters for 6 Layers
+  fThreshParams[0] = -0.001839; // 0.7 electron eff
+  fThreshParams[1] = 0.000276;
+  fThreshParams[2] = 0.044902; 
+  fThreshParams[3] = 1.726751;
+  fThreshParams[4] = -0.002405; // 0.75 electron eff
+  fThreshParams[5] = 0.000372;
+  fThreshParams[6] = 0.061775;
+  fThreshParams[7] = 1.739371;
+  fThreshParams[8] = -0.003178; // 0.8 electron eff
+  fThreshParams[9] = 0.000521;
+  fThreshParams[10] = 0.087585;
+  fThreshParams[11] = 1.749154;
+  fThreshParams[12] = -0.004058; // 0.85 electron eff
+  fThreshParams[13] = 0.000748;
+  fThreshParams[14] = 0.129583;
+  fThreshParams[15] = 1.782323;
+  fThreshParams[16] = -0.004967; // 0.9 electron eff
+  fThreshParams[17] = 0.001216;
+  fThreshParams[18] = 0.210128;
+  fThreshParams[19] = 1.807665;
+  fThreshParams[20] = -0.000996; // 0.95 electron eff
+  fThreshParams[21] = 0.002627;
+  fThreshParams[22] = 0.409099;
+  fThreshParams[23] = 1.787076;
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::InitParameters1DLQ(){
+  //
+  // Init Parameters for 1DLQ PID (M. Fasel, Sept. 6th, 2010)
+  //
+
+  // Parameters for 6 Layers
+  AliDebug(2, Form("Loading threshold parameter for Method 1DLQ"));
+  fThreshParams[0] = -0.02241; // 0.7 electron eff
+  fThreshParams[1] = 0.05043;
+  fThreshParams[2] = 0.7925; 
+  fThreshParams[3] = 2.625;
+  fThreshParams[4] = 0.07438; // 0.75 electron eff
+  fThreshParams[5] = 0.05158;
+  fThreshParams[6] = 2.864;
+  fThreshParams[7] = 4.356;
+  fThreshParams[8] = 0.1977; // 0.8 electron eff
+  fThreshParams[9] = 0.05956;
+  fThreshParams[10] = 2.853;
+  fThreshParams[11] = 3.713;
+  fThreshParams[12] = 0.5206; // 0.85 electron eff
+  fThreshParams[13] = 0.03077;
+  fThreshParams[14] = 2.966;
+  fThreshParams[15] = 4.07;
+  fThreshParams[16] = 0.8808; // 0.9 electron eff
+  fThreshParams[17] = 0.002092;
+  fThreshParams[18] = 1.17;
+  fThreshParams[19] = 4.506;
+  fThreshParams[20] = 1.; // 0.95 electron eff
+  fThreshParams[21] = 0.;
+  fThreshParams[22] = 0.;
+  fThreshParams[23] = 0.;
+
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::RenormalizeElPi(const Double_t *likein, Double_t *likeout) const {
+  //
+  // Renormalize likelihoods for electrons and pions neglecting the 
+  // likelihoods for protons, kaons and muons
+  //
+  memset(likeout, 0, sizeof(Double_t) * AliPID::kSPECIES);
+  Double_t norm = likein[AliPID::kElectron] + likein[AliPID::kPion];
+  if(norm == 0.) norm = 1.;   // Safety
+  likeout[AliPID::kElectron] = likein[AliPID::kElectron] / norm;
+  likeout[AliPID::kPion] = likein[AliPID::kPion] / norm;
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::GetParameters(Double_t electronEff, Double_t *parameters) const {
+  //
+  // return parameter set for the given efficiency bin
+  //
+  Int_t effbin = static_cast<Int_t>((electronEff - 0.7)/0.05);
+  memcpy(parameters, fThreshParams + effbin * 4, sizeof(Double_t) * 4);
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetElectronLikelihood(const AliVParticle *track) const {
+  //
+  // Get TRD likelihoods for ESD respectively AOD tracks
+  //
+  Double_t pidProbs[AliPID::kSPECIES]; memset(pidProbs, 0, sizeof(Double_t) * AliPID::kSPECIES);
+  const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
+  if(esdtrack) esdtrack->GetTRDpid(pidProbs);
+  if(!IsRenormalizeElPi()) return pidProbs[AliPID::kElectron];
+  Double_t probsNew[AliPID::kSPECIES];
+  RenormalizeElPi(pidProbs, probsNew);
+  return probsNew[AliPID::kElectron];
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetP(const AliVParticle *track) const {
+  //
+  // Get the Momentum in the TRD
+  //
+  Double_t p = 0.;
+  const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
+  if(esdtrack) p = esdtrack->GetOuterParam() ? esdtrack->GetOuterParam()->P() : esdtrack->P();
+  return p;
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetChargeLayer(const AliVParticle *track, UInt_t layer) const {
+  //
+  // Get the Charge in a single TRD layer
+  //
+  if(layer >= 6) return 0.;
+  Double_t charge = 0.;
+  const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
+  if(esdtrack)
+    for(Int_t islice = 0; islice < esdtrack->GetNumberOfTRDslices(); islice++)
+      charge += esdtrack->GetTRDslice(static_cast<UInt_t>(layer), islice);
+  return charge;
+}
+
+//___________________________________________________________________
+void AliDielectronTRDpidCut::GetTRDmomenta(const AliVParticle *track, Double_t *mom) const {
+  //
+  // Fill Array with momentum information at the TRD tracklet
+  //
+  const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
+  if(esdtrack)
+    for(Int_t itl = 0; itl < 6; itl++)
+      mom[itl] = esdtrack->GetTRDmomentum(itl);
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetTRDSignalV1(const AliESDtrack *track, Float_t truncation) const {
+  //
+  // Calculation of the TRD Signal via truncated mean
+  // Method 1: Take all Slices available
+  // cut out 0s
+  // Order them in increasing order
+  // Cut out the upper third
+  // Calculate mean over the last 2/3 slices
+  //
+  const Int_t kNSlices = 48;
+  const Int_t kSlicePerLayer = 7;
+  // Weight the slice to equalize the MPV of the dQ/dl-distribution per slice to the one in the first slice
+  // Pions are used as reference for the equalization
+  const Double_t kWeightSlice[8] = {1., 2.122, 1.8, 1.635, 1.595, 1.614, 1.16, 7.0};
+  AliDebug(3, Form("Number of Tracklets: %d\n", track->GetTRDntrackletsPID()));
+  Double_t trdSlices[kNSlices], tmp[kNSlices];
+  Int_t indices[48];
+  Int_t icnt = 0;
+  for(Int_t idet = 0; idet < 6; idet++)
+    for(Int_t islice = 0; islice < kSlicePerLayer; islice++){
+      AliDebug(2, Form("Chamber[%d], Slice[%d]: TRDSlice = %f", idet, islice, track->GetTRDslice(idet, islice)));
+      if(TMath::Abs(track->GetTRDslice(idet, islice)) < fgkVerySmall) continue;;
+      trdSlices[icnt++] = track->GetTRDslice(idet, islice) * kWeightSlice[islice];
+    }
+  AliDebug(1, Form("Number of Slices: %d\n", icnt));
+  if(icnt < 6) return 0.;   // We need at least 6 Slices for the truncated mean
+  TMath::Sort(icnt, trdSlices, indices, kFALSE);
+  memcpy(tmp, trdSlices, sizeof(Double_t) * icnt);
+  for(Int_t ien = 0; ien < icnt; ien++)
+    trdSlices[ien] = tmp[indices[ien]];
+  Double_t trdSignal = TMath::Mean(static_cast<Int_t>(static_cast<Float_t>(icnt) * truncation), trdSlices);
+  Double_t mom = track->GetOuterParam() ? track->GetOuterParam()->P() : -1;
+  AliDebug(3, Form("PID Meth. 1: p[%f], TRDSignal[%f]", mom, trdSignal));
+  return trdSignal;
+}
+
+//___________________________________________________________________
+Double_t AliDielectronTRDpidCut::GetTRDSignalV2(const AliESDtrack *track, Float_t truncation) const {
+  //
+  // Calculation of the TRD Signal via truncated mean
+  // Method 2: Take only first 5 slices per chamber
+  // Order them in increasing order
+  // Cut out upper half 
+  // Now do mean with the reamining 3 slices per chamber
+  //
+  const Double_t kWeightSlice[8] = {1., 2.122, 1.8, 1.635, 1.595, 1.614, 1.16, 7.0};
+  const Int_t kLayers = 6;
+  const Int_t kSlicesLow = 6;
+  const Int_t kSlicesHigh = 1;
+  Double_t trdSlicesLowTime[kLayers*kSlicesLow], trdSlicesRemaining[kLayers*(kSlicesHigh + kSlicesLow)];
+  Int_t indices[kLayers*kSlicesLow];
+  Int_t cntLowTime=0, cntRemaining = 0;
+  for(Int_t idet = 0; idet < 6; idet++)
+    for(Int_t islice = 0; islice < kSlicesLow+kSlicesHigh; islice++){
+      if(TMath::Abs(track->GetTRDslice(idet, islice)) < fgkVerySmall) continue;;
+      if(islice < kSlicesLow){
+        AliDebug(3, Form("Part 1, Det[%d], Slice[%d], TRDSlice: %f", idet, islice, track->GetTRDslice(idet, islice)));
+        trdSlicesLowTime[cntLowTime++] = track->GetTRDslice(idet, islice) * kWeightSlice[islice];
+      } else{
+        AliDebug(3, Form("Part 1, Det[%d], Slice[%d], TRDSlice: %f", idet, islice, track->GetTRDslice(idet, islice)));
+        trdSlicesRemaining[cntRemaining++] = track->GetTRDslice(idet, islice) * kWeightSlice[islice];
+      }
+    }
+  if(cntLowTime < 4 || cntRemaining < 2) return 0.; // Min. Number of Slices at high time is 2 (matches with 1 layer), for the truncated mean we need at least 4 Slices
+  TMath::Sort(cntLowTime, trdSlicesLowTime, indices, kFALSE);
+  // Fill the second array with the lower half of the first time bins
+  for(Int_t ien = 0; ien < static_cast<Int_t>(static_cast<Float_t>(cntLowTime) * truncation); ien++)
+    trdSlicesRemaining[cntRemaining++] = trdSlicesLowTime[indices[ien]];
+  Double_t trdSignal = TMath::Mean(cntRemaining, trdSlicesRemaining);
+  Double_t mom = track->GetOuterParam() ? track->GetOuterParam()->P() : -1;
+  AliDebug(3, Form("PID Meth. 2: p[%f], TRDSignal[%f]", mom, trdSignal));
+  return trdSignal;
+}
diff --git a/PWG3/dielectron/AliDielectronTRDpidCut.h b/PWG3/dielectron/AliDielectronTRDpidCut.h
new file mode 100644 (file)
index 0000000..8e0cc1e
--- /dev/null
@@ -0,0 +1,103 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// TRD PID Cut Class
+// Does PID either on a x% electron efficiency basis or on dE/dx
+// For more information please check the implementation file
+//
+#ifndef ALIDIELECTRONTRDPIDCUT_H
+#define ALIDIELECTRONTRDPIDCUT_H
+
+#include <AliAnalysisCuts.h>
+
+class AliESDtrack;
+class AliVParticle;
+
+class AliDielectronTRDpidCut : public AliAnalysisCuts{
+public:
+  typedef enum{
+    kLQ = 0,
+    kNN = 1
+  } PIDMethodTRD_t;
+  enum{
+    kThreshParams = 24
+  };
+  enum{
+    kHistTRDlikeBefore = 0,
+    kHistTRDlikeAfter = 1,
+    kHistTRDthresholds = 2,
+    kHistTRDSigV1 = 3,
+    kHistTRDSigV2 = 4,
+    kHistOverallSpecies = 5
+  };
+  enum PIDbitType {kIgnore=0, kRequire, kIfAvailable};
+  AliDielectronTRDpidCut();
+  AliDielectronTRDpidCut(const Char_t *name);
+  AliDielectronTRDpidCut(const AliDielectronTRDpidCut &ref);
+  AliDielectronTRDpidCut& operator=(const AliDielectronTRDpidCut &ref);
+  virtual ~AliDielectronTRDpidCut();
+
+  virtual Bool_t InitializePID();
+
+  Double_t GetTRDSignalV1(const AliESDtrack *track, Float_t truncation = 0.7) const;
+  Double_t GetTRDSignalV2(const AliESDtrack *track, Float_t trucation = 0.7) const;
+
+  Bool_t IsCalculateTRDSignals() const { return TestBit(kTRDsignals); }
+  Bool_t IsRenormalizeElPi() const { return TestBit(kTRDrenormalize); }
+  void SetPIDBitType(UInt_t pidBitType=AliDielectronTRDpidCut::kRequire) { fRequirePIDbit = pidBitType; };
+  void SetPIDMethod(PIDMethodTRD_t method) { fPIDMethod = method; };
+  void SetRenormalizeElPi(Bool_t doRenorm = kTRUE) { if(doRenorm) SetBit(kTRDrenormalize, kTRUE); else SetBit(kTRDrenormalize, kFALSE);}
+  void SetElectronEfficiency(Double_t electronEfficiency) { fElectronEfficiency = electronEfficiency; }
+  void SetThresholdParameters(Double_t electronEff, Double_t *params);
+  void SetMinP(Double_t p) { fMinP = p; }
+  void CalculateTRDSignals(Bool_t docalc) { SetBit(kTRDsignals, docalc); }
+
+  Double_t GetElectronLikelihood(const AliVParticle *track) const;
+  void     GetTRDmomenta(const AliVParticle *track, Double_t *mom) const;
+  Double_t GetP(const AliVParticle *track) const;
+  Double_t GetTRDthresholds(Double_t electronEff, Double_t p) const;
+  Double_t GetChargeLayer(const AliVParticle *track, UInt_t layer) const;
+
+  //
+  //Analysis cuts interface
+  //
+  virtual Bool_t IsSelected(TObject* track);
+  virtual Bool_t IsSelected(TList*   /* list */ ) {return kFALSE;}
+  
+protected:
+  enum{
+    kTRDsignals = BIT(16),
+    kTRDdefaultThresholds = BIT(17),
+    kTRDrenormalize = BIT(18)
+  };
+  void Copy(TObject &ref) const;
+  void InitParameters();
+  void InitParameters1DLQ();
+  void GetParameters(Double_t electronEff, Double_t *parameters) const;
+  void SetUseDefaultParameters(Bool_t useDefault = kTRUE) { SetBit(kTRDdefaultThresholds, useDefault); }
+  Bool_t UseDefaultParameters() const { return TestBit(kTRDdefaultThresholds); }
+  void RenormalizeElPi(const Double_t *likein, Double_t *likeout) const;
+
+private:
+  static const Double_t fgkVerySmall;                     // Check for 0
+  Double_t fMinP;                                         // Minimum momentum above which TRD PID is applied
+  Double_t fElectronEfficiency;                           // Cut on electron efficiency
+  PIDMethodTRD_t fPIDMethod;                              // PID Method: 2D Likelihood or Neural Network
+  UChar_t  fRequirePIDbit;                                //How to make use of the pid bit (see)
+  Double_t fThreshParams[kThreshParams];                  // Threshold parametrisation
+  ClassDef(AliDielectronTRDpidCut, 1)     // TRD electron ID class
+};
+
+#endif
index 45e3caf..04e3272 100644 (file)
@@ -13,9 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
-
 ///////////////////////////////////////////////////////////////////////////
 //                Dielectron TrackCuts                                  //
 //                                                                       //
index 9b54b79..42cf9fa 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronTrackCuts                     #
diff --git a/PWG3/dielectron/AliDielectronVarContainer.cxx b/PWG3/dielectron/AliDielectronVarContainer.cxx
new file mode 100644 (file)
index 0000000..7394ac5
--- /dev/null
@@ -0,0 +1,217 @@
+/*************************************************************************
+* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//                Dielectron Variables Container Class                   //
+//                                                                       //
+/*
+
+*/
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include "AliDielectronVarContainer.h"
+
+ClassImp(AliDielectronVarContainer)
+
+const char* AliDielectronVarContainer::fgkParticleNames[AliDielectronVarContainer::kNMaxValues] = {
+  // Leg specific variables
+  "Px",
+  "Py",
+  "Pz",
+  "Pt",
+  "P",
+  "Xv",
+  "Yv",
+  "Zv",
+  "OneOverPt",
+  "Phi",
+  "Theta",
+  "Eta",
+  "Y",
+  "E",
+  "M",
+  "Charge",
+  "NclsITS",
+  "NclsTPC",
+  "NclsTPCiter1",
+  "NFclsTPC",
+  "NFclsTPCrobust",
+  "NFclsTPCrobustFraction",
+  "TPCsignalN",
+  "TPCsignalNfrac",
+  "TPCchi2PerCluster",
+  "TrackStatus",
+  "NclsTRD",
+  "TRDntracklets",
+  "TRDpidQuality",
+  "TRDpidProb_Electrons",
+  "TRDpidProb_Pions",
+  "ImpactParXY",
+  "ImpactParZ",
+  "TrackLength",
+  "ITS_signal",
+  "SSD1_signal",
+  "SSD2_signal",
+  "SDD1_signal",
+  "SDD2_signal",
+  "ITS_clusterMap",
+  "ITS_nSigma_Electrons",
+  "ITS_nSigma_Pions",
+  "ITS_nSigma_Muons",
+  "ITS_nSigma_Kaons",
+  "ITS_nSigma_Protons",
+  "P_InnerParam",
+  "TPC_signal",
+  "TOF_signal",
+  "TOF_beta",
+  "TPC_nSigma_Electrons",
+  "TPC_nSigma_Pions",
+  "TPC_nSigma_Muons",
+  "TPC_nSigma_Kaons",
+  "TPC_nSigma_Protons",
+  "TOF_nSigma_Electrons",
+  "TOF_nSigma_Pions",
+  "TOF_nSigma_Muons",
+  "TOF_nSigma_Kaons",
+  "TOF_nSigma_Protons",
+  "KinkIndex0",
+  // Pair specific variables
+  "Chi2NDF",
+  "DecayLength",
+  "R",
+  "OpeningAngle",
+  "ThetaHE",
+  "PhiHE",
+  "ThetaCS",
+  "PhiCS",
+  "LegDistance",
+  "LegDistanceXY",
+  "DeltaEta",
+  "DeltaPhi",
+  "Merr",
+  "DCA",
+  "PairType",
+  "PseudoProperTime",
+  // Event specific variables
+  "X",
+  "Y",
+  "Z",
+  "XRes",
+  "YRes",
+  "ZRes",
+  "NContributors",
+  "BzkG",
+  "NTrk",
+  "Nacc",
+  "kNaccTrcklts",
+  "Centrality",
+  "Nevents"
+};
+
+
+const char* AliDielectronVarContainer::fgkParticleNamesMC[AliDielectronVarContainer::kNMaxValues_MC] = {
+  // Leg specific variables
+  "Px_MC",
+  "Py_MC",
+  "Pz_MC",
+  "Pt_MC",
+  "P_MC",
+  "Xv_MC",
+  "Yv_MC",
+  "Zv_MC",
+  "OneOverPt_MC",
+  "Phi_MC",
+  "Theta_MC",
+  "Eta_MC",
+  "Y_MC",
+  "E_MC",
+  "M_MC",
+  "Charge_MC",
+  "ImpactParXY_MC",
+  "ImpactParZ_MC",
+  "PdgCode",
+  "PdgCodeMother",
+  "PdgCodeGrandMother",
+  "NumberOfDaughters",
+  "HaveSameMother",
+  "IsJpsiPrimary",
+  // Pair specific variables
+  "DecayLength_MC",
+  "R_MC",
+  "OpeningAngle_MC",
+  "ThetaHE_MC",
+  "PhiHE_MC",
+  "ThetaCS_MC",
+  "PhiCS_MC",
+  "LegDistance_MC",
+  "LegDistanceXY_MC",
+  "DeltaEta_MC",
+  "DeltaPhi_MC",
+  "DCA_MC",
+  "PairType_MC",
+  "PseudoProperTime_MC",
+  // Event specific variables
+  "X_MC",
+  "Y_MC",
+  "Z_MC",
+  "kNch",
+  "Centrality_MC",
+  "Nevents"
+};
+
+
+AliPIDResponse* AliDielectronVarContainer::fgPIDResponse = 0x0;
+AliKFVertex*    AliDielectronVarContainer::fgKFVertex    = 0x0;
+AliAODVertex*   AliDielectronVarContainer::fgAODVertex   = 0x0;
+Double_t        AliDielectronVarContainer::fgData[AliDielectronVarContainer::kNMaxValues] = {};
+Double_t        AliDielectronVarContainer::fgDataMC[AliDielectronVarContainer::kNMaxValues_MC] = {};
+
+
+//________________________________________________________________
+AliDielectronVarContainer::AliDielectronVarContainer() :
+  TNamed("AliDielectronVarContainer","AliDielectronVarContainer")
+{
+  //
+  // Default constructor
+  //
+}
+
+
+//________________________________________________________________
+AliDielectronVarContainer::AliDielectronVarContainer(const char* name, const char* title) :
+  TNamed(name,title)
+{
+  //
+  // Named constructor
+  //
+}
+
+
+//________________________________________________________________
+AliDielectronVarContainer::~AliDielectronVarContainer()
+{
+  //
+  // Default destructor
+  //
+
+  if (fgKFVertex) delete fgKFVertex;
+  fgKFVertex = 0x0;
+  if (fgAODVertex) delete fgAODVertex;
+  fgAODVertex = 0x0;
+  if (fgPIDResponse) delete fgPIDResponse;
+  fgPIDResponse = 0x0;
+}
+
diff --git a/PWG3/dielectron/AliDielectronVarContainer.h b/PWG3/dielectron/AliDielectronVarContainer.h
new file mode 100644 (file)
index 0000000..7b51c80
--- /dev/null
@@ -0,0 +1,923 @@
+#ifndef ALIDIELECTRONVARCONTAINER_H
+#define ALIDIELECTRONVARCONTAINER_H
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//#############################################################
+//#                                                           # 
+//#         Class AliDielectronVarContainer                   #
+//#         Class for management of available variables       #
+//#                                                           #
+//#  Authors:                                                 #
+//#   Anton     Andronic, GSI / A.Andronic@gsi.de             #
+//#   Ionut C.  Arsene,   GSI / I.C.Arsene@gsi.de             #
+//#   Julian    Book,     Uni Ffm / Julian.Book@cern.ch       #
+//#   Markus    K√∂hler,   GSI / M.Koehler@gsi.de              #
+//#   Frederick Kramer,   Uni Ffm / Frederick.Kramer@cern.ch  #
+//#   Magnus    Mager,    CERN / Magnus.Mager@cern.ch         #
+//#   WooJin J. Park,     GSI / W.J.Park@gsi.de               #
+//#   Jens      Wiechula, Uni HD / Jens.Wiechula@cern.ch      #
+//#                                                           #
+//#############################################################
+
+
+#include <TNamed.h>
+#include <TDatabasePDG.h>
+
+#include <AliVEvent.h>
+#include <AliESDEvent.h>
+#include <AliAODEvent.h>
+#include <AliMCEvent.h>
+#include <AliESDVertex.h>
+#include <AliAODVertex.h>
+
+#include <AliVParticle.h>
+#include <AliESDtrack.h>
+#include <AliAODTrack.h>
+#include <AliAODPid.h>
+#include <AliKFParticle.h>
+#include <AliKFVertex.h>
+#include <AliMCParticle.h>
+#include <AliAODMCParticle.h>
+#include <AliVTrack.h>  // ?
+
+#include <AliExternalTrackParam.h>
+#include <AliESDpid.h>
+#include <AliCentrality.h>
+#include <AliAODpidUtil.h>
+#include <AliPID.h>
+#include <AliPIDResponse.h>
+
+#include "AliDielectronPair.h"
+#include "AliDielectronMC.h"
+#include "AliDielectronPID.h"
+#include "AliDielectronHelper.h"
+
+class AliVEvent;
+
+//________________________________________________________________
+class AliDielectronVarContainer : public TNamed {
+  
+public:
+
+  enum ValueTypes {
+    // Leg specific variables
+    kPx = 0,                 // px
+    kPy,                     // py
+    kPz,                     // pz
+    kPt,                     // transverse momentum
+    kP,                      // momentum
+    kXv,                     // vertex position in x
+    kYv,                     // vertex position in y
+    kZv,                     // vertex position in z
+    kOneOverPt,              // 1/pt
+    kPhi,                    // phi angle
+    kTheta,                  // theta angle
+    kEta,                    // pseudo-rapidity
+    kY,                      // rapidity
+    kE,                      // energy
+    kM,                      // mass
+    kCharge,                 // charge
+    kNclsITS,                // number of clusters assigned in the ITS
+    kNclsTPC,                // number of clusters assigned in the TPC
+    kNclsTPCiter1,           // number of clusters assigned in the TPC after first iteration
+    kNFclsTPC,               // number of findable clusters in the TPC
+    kNFclsTPCr,              // number of findable clusters in the TPC with more robust definition
+    kNFclsTPCrFrac,          // number of found/findable clusters in the TPC with more robust definition
+    kTPCsignalN,             // number of points used for dEdx
+    kTPCsignalNfrac,         // fraction of points used for dEdx / cluster used for tracking
+    kTPCchi2Cl,              // chi2/cl in TPC
+    kTrackStatus,            // track status bits
+    kNclsTRD,                // number of clusters assigned in the TRD
+    kTRDntracklets,          // number of TRD tracklets used for tracking/PID TODO: correct getter
+    kTRDpidQuality,          // number of TRD tracklets used for PID
+    kTRDprobEle,             // TRD electron pid probability
+    kTRDprobPio,             // TRD electron pid probability
+    kImpactParXY,            // Impact parameter in XY plane
+    kImpactParZ,             // Impact parameter in Z
+    kTrackLength,            // Track length
+    kITSsignal,                           // ITS dE/dx signal
+    kITSsignalSSD1,             // SSD1 dE/dx signal
+    kITSsignalSSD2,             // SSD2 dE/dx signal
+    kITSsignalSDD1,             // SDD1 dE/dx signal
+    kITSsignalSDD2,             // SDD2 dE/dx signal
+    kITSclusterMap,          // ITS cluster map
+    kITSnSigmaEle,           // number of sigmas to the dE/dx electron line in the ITS
+    kITSnSigmaPio,           // number of sigmas to the dE/dx pion line in the ITS
+    kITSnSigmaMuo,           // number of sigmas to the dE/dx muon line in the ITS
+    kITSnSigmaKao,           // number of sigmas to the dE/dx kaon line in the ITS
+    kITSnSigmaPro,           // number of sigmas to the dE/dx proton line in the ITS
+    kPIn,                    // momentum at inner wall of TPC (if available), used for PID
+    kTPCsignal,              // TPC dE/dx signal
+       kTOFsignal,              // TOF signal
+         kTOFbeta,                // TOF beta
+    kTPCnSigmaEle,           // number of sigmas to the dE/dx electron line in the TPC
+    kTPCnSigmaPio,           // number of sigmas to the dE/dx pion line in the TPC
+    kTPCnSigmaMuo,           // number of sigmas to the dE/dx muon line in the TPC
+    kTPCnSigmaKao,           // number of sigmas to the dE/dx kaon line in the TPC
+    kTPCnSigmaPro,           // number of sigmas to the dE/dx proton line in the TPC
+         kTOFnSigmaEle,           // number of sigmas to the pion line in the TOF
+    kTOFnSigmaPio,           // number of sigmas to the pion line in the TOF
+    kTOFnSigmaMuo,           // number of sigmas to the muon line in the TOF
+    kTOFnSigmaKao,           // number of sigmas to the kaon line in the TOF
+    kTOFnSigmaPro,           // number of sigmas to the proton line in the TOF
+    kKinkIndex0,             // kink index 0
+    kParticleMax,            // TODO: kRNClusters ??
+
+    // Pair specific variables
+    kChi2NDF = kParticleMax, // Chi^2/NDF
+    kDecayLength,            // decay length
+    kR,                      // distance to the origin
+    kOpeningAngle,           // opening angle
+    // Helicity picture: Z-axis is considered the direction of the mother's 3-momentum vector
+    kThetaHE,                // theta in mother's rest frame in the helicity picture 
+    kPhiHE,                  // phi in mother's rest frame in the helicity picture
+    // Collins-Soper picture: Z-axis is considered the direction of the vectorial difference between 
+    // the 3-mom vectors of target and projectile beams
+    kThetaCS,                // theta in mother's rest frame in Collins-Soper picture
+    kPhiCS,                  // phi in mother's rest frame in Collins-Soper picture
+    kLegDist,                // distance of the legs
+    kLegDistXY,              // distance of the legs in XY
+    kDeltaEta,               // Absolute value of Delta Eta for the legs
+    kDeltaPhi,               // Absolute value of Delta Phi for the legs
+    kMerr,                   // error of mass calculation
+    kDCA,                    // distance of closest approach TODO: not implemented yet
+    kPairType,               // type of the pair, like like sign ++ unlikesign ...
+    kPseudoProperTime,       // pseudo proper time
+    kPairMax,                //
+
+    // Event specific variables
+    kXvPrim = kPairMax,      // prim vertex x
+    kYvPrim,                 // prim vertex y
+    kZvPrim,                 // prim vertex z
+    kXRes,                   // primary vertex x-resolution
+    kYRes,                   // primary vertex y-resolution
+    kZRes,                   // primary vertex z-resolution
+    kNContrib,               // Number of vertex contributors
+    kBzkG,                   // z componenent of field in kG
+    kNTrk,                   // number of tracks
+    kNacc,                   // Number of accepted tracks
+    kNaccTrcklts,            // Number of accepted tracklets (MUON definition)
+    kCentrality,             // event centrality fraction
+    kNevents,                // event counter
+    kNMaxValues              // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
+  };
+
+
+  enum ValueTypesMC {
+    // Leg specific variables
+    kPx_MC = 0,              // px
+    kPy_MC,                  // py
+    kPz_MC,                  // pz
+    kPt_MC,                  // transverse momentum
+    kP_MC,                   // momentum
+    kXv_MC,                  // vertex position in x
+    kYv_MC,                  // vertex position in y
+    kZv_MC,                  // vertex position in z
+    kOneOverPt_MC,           // 1/pt
+    kPhi_MC,                 // phi angle
+    kTheta_MC,               // theta angle
+    kEta_MC,                 // pseudo-rapidity
+    kY_MC,                   // rapidity
+    kE_MC,                   // energy
+    kM_MC,                   // mass
+    kCharge_MC,              // charge
+    kImpactParXY_MC,         // Impact parameter in XY plane
+    kImpactParZ_MC,          // Impact parameter in Z
+    kPdgCode,                // PDG code
+    kPdgCodeMother,          // PDG code of the mother
+    kPdgCodeGrandMother,     // PDG code of the grand mother
+    kNumberOfDaughters,      // number of daughters
+    kHaveSameMother,         // check that particles have the same mother (MC)
+    kIsJpsiPrimary,          // check if the particle is primary (MC)
+    kParticleMax_MC,         //
+
+// Pair specific variables
+    kDecayLengthv_MC = kParticleMax_MC, // decay length
+    kR_MC,                      // distance to the origin
+    kOpeningAngle_MC,           // opening angle
+    // Helicity picture: Z-axis is considered the direction of the mother's 3-momentum vector
+    kThetaHE_MC,                // theta in mother's rest frame in the helicity picture 
+    kPhiHE_MC,                  // phi in mother's rest frame in the helicity picture
+    // Collins-Soper picture: Z-axis is considered the direction of the vectorial difference between 
+    // the 3-mom vectors of target and projectile beams
+    kThetaCS_MC,                // theta in mother's rest frame in Collins-Soper picture
+    kPhiCS_MC,                  // phi in mother's rest frame in Collins-Soper picture
+    kLegDist_MC,                // distance of the legs
+    kLegDistXY_MC,              // distance of the legs in XY
+    kDeltaEta_MC,               // Absolute value of Delta Eta for the legs
+    kDeltaPhi_MC,               // Absolute value of Delta Phi for the legs
+    kDCA_MC,                    // distance of closest approach TODO: not implemented yet
+    kPairType_MC,               // type of the pair, like like sign ++ unlikesign ...
+    kPseudoProperTime_MC,       // pseudo proper time
+    kPairMax_MC,                //
+
+// Event specific variables
+    kXvPrim_MC = kPairMax_MC,   // prim vertex x
+    kYvPrim_MC,                 // prim vertex y
+    kZvPrim_MC,                 // prim vertex z
+    kNch,                       // Number of charged MC tracks
+    kCentrality_MC,             // event centrality fraction
+    kNevents_MC,                // event counter
+    kNMaxValues_MC              // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
+  };
+
+
+
+  AliDielectronVarContainer();
+  AliDielectronVarContainer(const char* name, const char* title);
+  virtual ~AliDielectronVarContainer();
+
+  static void Fill(const TObject* object);
+  static void InitESDpid(Int_t type=0);
+  static void InitAODpidUtil(Int_t type=0);
+
+  static void SetESDpid(AliESDpid * const pid)            { fgPIDResponse=pid;                                   }
+  static void SetPIDResponse(AliPIDResponse *pidResponse) { fgPIDResponse=pidResponse;                           }
+  static void SetEvent(AliVEvent * const event); // TODO: needed?
+
+  static AliESDpid* GetESDpid()                           { return (AliESDpid*)fgPIDResponse;                    }
+  static AliAODpidUtil* GetAODpidUtil()                   { return (AliAODpidUtil*)fgPIDResponse;                }
+  static const AliKFVertex* GetKFVertex()                 { return fgKFVertex;                                   }
+  static const char* GetValueName(Int_t i)                { return (i>=0&&i<kNMaxValues)?fgkParticleNames[i]:""; }
+  static const Double_t* GetData()                        { return fgData;                                       }
+  static const Double_t* GetDataMC()                      { return fgDataMC;                                     }
+  static Double_t GetValue(ValueTypes val)                { return fgData[val];                                  }
+  static Double_t GetValueMC(ValueTypesMC val)            { return fgDataMC[val];                                }
+  static Bool_t GetDCA(const AliAODTrack *track, Double_t d0z0[2]);
+
+private:
+
+  static Double_t fgData[kNMaxValues];                   //! data
+  static Double_t fgDataMC[kNMaxValues_MC];              //! MC data
+  static const char* fgkParticleNames[kNMaxValues];      // variable names
+  static const char* fgkParticleNamesMC[kNMaxValues_MC]; // MC variable names
+
+  static void FillVarVParticle(const AliVParticle *particle);
+  static void FillVarVParticleMC(const AliVParticle *particle);
+  static void FillVarESDtrack(const AliESDtrack *particle);
+  static void FillVarAODTrack(const AliAODTrack *particle);
+  static void FillVarMCParticle(const AliMCParticle *particle);
+  static void FillVarAODMCParticle(const AliAODMCParticle *particle);
+  static void FillVarDielectronPair(const AliDielectronPair *pair);
+  static void FillVarKFParticle(const AliKFParticle *pair);
+  
+  static void FillVarVEvent(const AliVEvent *event);
+  static void FillVarESDEvent(const AliESDEvent *event);
+  static void FillVarAODEvent(const AliAODEvent *event);
+  static void FillVarMCEvent(const AliMCEvent *event);
+  static void ResetArrayData(Int_t to);
+  static void ResetArrayDataMC(Int_t to);
+
+  static Double_t GetPseudoProperTime(const AliDielectronPair *pair);
+  
+  static AliPIDResponse *fgPIDResponse;        // PID response object
+  static AliKFVertex     *fgKFVertex;          // KF vertex
+  static AliAODVertex    *fgAODVertex;         // AOD vertex
+
+  
+  AliDielectronVarContainer(const AliDielectronVarContainer &c);
+  AliDielectronVarContainer &operator=(const AliDielectronVarContainer &c);
+  
+  ClassDef(AliDielectronVarContainer,1);
+};
+
+
+//Inline functions
+inline void AliDielectronVarContainer::Fill(const TObject* object)
+{
+  //
+  // Main function to fill all available variables according to the type of particle
+  //
+
+  // Protect
+  if (!object) return;
+
+  if      (object->IsA() == AliESDtrack::Class())       FillVarESDtrack(static_cast<const AliESDtrack*>(object));
+  else if (object->IsA() == AliAODTrack::Class())       FillVarAODTrack(static_cast<const AliAODTrack*>(object));
+  else if (object->IsA() == AliMCParticle::Class())     FillVarMCParticle(static_cast<const AliMCParticle*>(object));
+  else if (object->IsA() == AliAODMCParticle::Class())  FillVarAODMCParticle(static_cast<const AliAODMCParticle*>(object));
+  else if (object->IsA() == AliDielectronPair::Class()) FillVarDielectronPair(static_cast<const AliDielectronPair*>(object));
+  else if (object->IsA() == AliKFParticle::Class())     FillVarKFParticle(static_cast<const AliKFParticle*>(object));
+  //else if (object->IsA() == TParticle::Class())         FillVarTParticle(static_cast<const TParticle*>(object));
+
+  // Main function to fill all available variables according to the type of event
+  else if (object->IsA() == AliVEvent::Class())         FillVarVEvent(static_cast<const AliVEvent*>(object));
+  else if (object->IsA() == AliESDEvent::Class())       FillVarESDEvent(static_cast<const AliESDEvent*>(object));
+  else if (object->IsA() == AliAODEvent::Class())       FillVarAODEvent(static_cast<const AliAODEvent*>(object));
+  else if (object->IsA() == AliMCEvent::Class())        FillVarMCEvent(static_cast<const AliMCEvent*>(object));
+//   else printf(Form("AliDielectronVarContainer::Fill: Type %s is not supported by AliDielectronVarContainer!", object->ClassName())); //TODO: implement without object needed
+}
+
+
+
+inline void AliDielectronVarContainer::ResetArrayData(Int_t to)
+{
+  // Protect
+  if (to >= AliDielectronVarContainer::kNMaxValues) return;
+  // Reset
+  for (Int_t i=0; i<to; ++i) fgData[i] = 0.;
+
+  fgData[AliDielectronVarContainer::kTPCchi2Cl] = -1;
+}
+
+
+inline void AliDielectronVarContainer::ResetArrayDataMC(Int_t to)
+{
+  // Protect
+  if (to >= AliDielectronVarContainer::kNMaxValues_MC) return;
+  // Reset
+  //for (Int_t i=0; i<to; ++i) fgDataMC[i] = 0.;
+
+  //fgDataMC[AliDielectronVarContainer::kPdgCode]            = -1.;
+  //fgDataMC[AliDielectronVarContainer::kPdgCodeMother]      = -1.;
+  //fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = -1.;
+  //fgDataMC[AliDielectronVarContainer::kNumberOfDaughters]  = -999.;
+}
+
+
+inline void AliDielectronVarContainer::FillVarVParticle(const AliVParticle *particle)
+{
+  //
+  // Fill track information available in AliVParticle into array
+  //
+
+  // Protect
+  if (!particle) return;
+
+  // Reset
+  ResetArrayData(AliDielectronVarContainer::kPairMax);
+
+  // Set
+  fgData[AliDielectronVarContainer::kPx]        = particle->Px();
+  fgData[AliDielectronVarContainer::kPy]        = particle->Py();
+  fgData[AliDielectronVarContainer::kPz]        = particle->Pz();
+  fgData[AliDielectronVarContainer::kPt]        = particle->Pt();
+  fgData[AliDielectronVarContainer::kP]         = particle->P();
+  fgData[AliDielectronVarContainer::kXv]        = particle->Xv();
+  fgData[AliDielectronVarContainer::kYv]        = particle->Yv();
+  fgData[AliDielectronVarContainer::kZv]        = particle->Zv();
+  fgData[AliDielectronVarContainer::kOneOverPt] = particle->OneOverPt();
+  fgData[AliDielectronVarContainer::kPhi]       = particle->Phi();
+  fgData[AliDielectronVarContainer::kTheta]     = particle->Theta();
+  fgData[AliDielectronVarContainer::kEta]       = particle->Eta();
+  fgData[AliDielectronVarContainer::kY]         = particle->Y();
+  fgData[AliDielectronVarContainer::kE]         = particle->E();
+  fgData[AliDielectronVarContainer::kM]         = particle->M();
+  fgData[AliDielectronVarContainer::kCharge]    = particle->Charge();
+  fgData[AliDielectronVarContainer::kPdgCode]   = particle->PdgCode();
+}
+
+
+inline void AliDielectronVarContainer::FillVarVParticleMC(const AliVParticle *particle)
+{
+  //
+  // Fill MC track information available in AliVParticle into array
+  //
+
+  // Protect
+  if (!particle) return;
+
+  // Get the MC interface if available
+  AliDielectronMC *mc = AliDielectronMC::Instance();
+  if (!mc->HasMC()) return;
+
+  // Reset
+  ResetArrayDataMC(AliDielectronVarContainer::kPairMax_MC);
+
+  // If called for a reco track, get the MC track first
+  if (particle->IsA() == AliESDtrack::Class()) particle = mc->GetMCTrack((AliESDtrack*)particle);
+  if (particle->IsA() == AliAODTrack::Class()) particle = mc->GetMCTrack((AliAODTrack*)particle);
+  if (!particle) return;
+
+  // Set the AliDielectronMC specific info
+  if (particle->IsA() == AliMCParticle::Class()) {
+    AliMCParticle* mcParticle = (AliMCParticle*)particle;
+    if (mc->GetMCTrackMother(mcParticle)) {
+      fgDataMC[AliDielectronVarContainer::kPdgCodeMother] = mc->GetMCTrackMother(mcParticle)->PdgCode();
+      if (mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle)))
+        fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle))->PdgCode();;
+    }
+    fgDataMC[AliDielectronVarContainer::kNumberOfDaughters] = mc->NumberOfDaughters(mcParticle);
+  } else if (particle->IsA() == AliAODMCParticle::Class()) {
+    AliAODMCParticle* mcParticle = (AliAODMCParticle*)particle;
+    if (mc->GetMCTrackMother(mcParticle)) {
+      fgDataMC[AliDielectronVarContainer::kPdgCodeMother] = mc->GetMCTrackMother(mcParticle)->PdgCode();
+      if (mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle)))
+        fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle))->PdgCode();;
+    }
+    fgDataMC[AliDielectronVarContainer::kNumberOfDaughters] = mc->NumberOfDaughters(mcParticle);
+  }
+
+
+  // Set the common info
+  fgData[AliDielectronVarContainer::kIsJpsiPrimary]       = mc->IsJpsiPrimary(particle);
+  fgDataMC[AliDielectronVarContainer::kPdgCode]           = particle->PdgCode();
+  fgDataMC[AliDielectronVarContainer::kPx_MC]             = particle->Px();
+  fgDataMC[AliDielectronVarContainer::kPy_MC]             = particle->Py();
+  fgDataMC[AliDielectronVarContainer::kPz_MC]             = particle->Pz();
+  fgDataMC[AliDielectronVarContainer::kPt_MC]             = particle->Pt();
+  fgDataMC[AliDielectronVarContainer::kP_MC]              = particle->P();
+  fgDataMC[AliDielectronVarContainer::kXv_MC]             = particle->Xv();
+  fgDataMC[AliDielectronVarContainer::kYv_MC]             = particle->Yv();
+  fgDataMC[AliDielectronVarContainer::kZv_MC]             = particle->Zv();
+  fgDataMC[AliDielectronVarContainer::kOneOverPt_MC]      = particle->OneOverPt();
+  fgDataMC[AliDielectronVarContainer::kPhi_MC]            = particle->Phi();
+  fgDataMC[AliDielectronVarContainer::kTheta_MC]          = particle->Theta();
+  fgDataMC[AliDielectronVarContainer::kEta_MC]            = particle->Eta();
+  fgDataMC[AliDielectronVarContainer::kY_MC]              = particle->Y();
+  fgDataMC[AliDielectronVarContainer::kE_MC]              = particle->E();
+  fgDataMC[AliDielectronVarContainer::kM_MC]              = particle->M();
+  fgDataMC[AliDielectronVarContainer::kCharge_MC]         = particle->Charge();
+}
+
+
+inline void AliDielectronVarContainer::FillVarESDtrack(const AliESDtrack *particle)
+{
+  //
+  // Fill AliESDtrack interface specific information
+  //
+
+  // Fill common AliVParticle interface information
+  FillVarVParticle(particle);
+  // Fill common MC information if available
+  FillVarVParticleMC(particle);
+
+  Double_t tpcNcls=particle->GetTPCNcls();
+  Double_t tpcSignalN=particle->GetTPCsignalN();
+  fgData[AliDielectronVarContainer::kNclsITS]       = particle->GetNcls(0); // TODO: get rid of the plain numbers
+  fgData[AliDielectronVarContainer::kNclsTPC]       = tpcNcls; // TODO: get rid of the plain numbers
+  fgData[AliDielectronVarContainer::kNclsTPCiter1]  = particle->GetTPCNclsIter1(); // TODO: get rid of the plain numbers
+  fgData[AliDielectronVarContainer::kNFclsTPC]      = particle->GetTPCNclsF();
+  fgData[AliDielectronVarContainer::kNFclsTPCr]     = particle->GetTPCClusterInfo(2,1);
+  fgData[AliDielectronVarContainer::kNFclsTPCrFrac] = particle->GetTPCClusterInfo(2);
+  fgData[AliDielectronVarContainer::kTPCsignalN]    = tpcSignalN;
+  fgData[AliDielectronVarContainer::kTPCsignalNfrac]= tpcNcls>0?tpcSignalN/tpcNcls:0;
+  fgData[AliDielectronVarContainer::kNclsTRD]       = particle->GetNcls(2); // TODO: get rid of the plain numbers
+  fgData[AliDielectronVarContainer::kTRDntracklets] = particle->GetTRDntracklets(); // TODO: GetTRDtracklets/GetTRDntracklets?
+  fgData[AliDielectronVarContainer::kTRDpidQuality] = particle->GetTRDpidQuality();
+  fgData[AliDielectronVarContainer::kTrackStatus]   = (Double_t)particle->GetStatus();
+  if (tpcNcls>0) fgData[AliDielectronVarContainer::kTPCchi2Cl] = particle->GetTPCchi2() / tpcNcls;
+
+  //TRD pidProbs
+  Double_t pidProbs[AliPID::kSPECIES];
+  particle->GetTRDpid(pidProbs);
+  fgData[AliDielectronVarContainer::kTRDprobEle]    = pidProbs[AliPID::kElectron];
+  fgData[AliDielectronVarContainer::kTRDprobPio]    = pidProbs[AliPID::kPion];
+
+  fgData[AliDielectronVarContainer::kKinkIndex0]    = particle->GetKinkIndex(0);
+  
+  Float_t impactParXY, impactParZ;
+  particle->GetImpactParameters(impactParXY, impactParZ);
+  fgData[AliDielectronVarContainer::kImpactParXY]   = impactParXY;
+  fgData[AliDielectronVarContainer::kImpactParZ]    = impactParZ;
+
+  fgData[AliDielectronVarContainer::kITSsignal]       = particle->GetITSsignal();
+  
+  Double_t itsdEdx[4];
+  particle->GetITSdEdxSamples(itsdEdx);
+
+  fgData[AliDielectronVarContainer::kITSsignalSSD1]   = itsdEdx[0];
+  fgData[AliDielectronVarContainer::kITSsignalSSD2]   = itsdEdx[1];
+  fgData[AliDielectronVarContainer::kITSsignalSDD1]   = itsdEdx[2];
+  fgData[AliDielectronVarContainer::kITSsignalSDD2]   = itsdEdx[3];
+  fgData[AliDielectronVarContainer::kITSclusterMap]   = particle->GetITSClusterMap();
+  
+  fgData[AliDielectronVarContainer::kTrackLength]     = particle->GetIntegratedLength();
+
+  //dEdx information
+  Double_t mom = particle->GetP();
+  const AliExternalTrackParam *in=particle->GetInnerParam();
+  if (in) mom = in->GetP();
+  fgData[AliDielectronVarContainer::kPIn]=mom;
+  fgData[AliDielectronVarContainer::kTPCsignal]       = particle->GetTPCsignal();
+  fgData[AliDielectronVarContainer::kTOFsignal]       = particle->GetTOFsignal();
+  
+  Double_t l = particle->GetIntegratedLength();  // cm
+  Double_t t = particle->GetTOFsignal();
+  Double_t t0 = fgPIDResponse->GetTOFResponse().GetTimeZero(); // ps
+
+  if( (l < 360. || l > 800.) || (t <= 0.) || (t0 >999990.0) ) {
+         fgData[AliDielectronVarContainer::kTOFbeta]=0.0;
+  } else {
+    t -= t0; // subtract the T0
+    l *= 0.01;  // cm ->m
+    t *= 1e-12; //ps -> s
+
+    Double_t v = l / t;
+    Float_t beta = v / TMath::C();
+    fgData[AliDielectronVarContainer::kTOFbeta] = beta;
+  }
+
+  // nsigma to Electron band
+  // TODO: for the moment we set the bethe bloch parameters manually
+  //       this should be changed in future!
+  
+  fgData[AliDielectronVarContainer::kTPCnSigmaEle]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron)-AliDielectronPID::GetCorrVal();
+  fgData[AliDielectronVarContainer::kTPCnSigmaPio]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
+  fgData[AliDielectronVarContainer::kTPCnSigmaMuo]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
+  fgData[AliDielectronVarContainer::kTPCnSigmaKao]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
+  fgData[AliDielectronVarContainer::kTPCnSigmaPro]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
+
+  fgData[AliDielectronVarContainer::kITSnSigmaEle]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kElectron);
+  fgData[AliDielectronVarContainer::kITSnSigmaPio]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kPion);
+  fgData[AliDielectronVarContainer::kITSnSigmaMuo]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kMuon);
+  fgData[AliDielectronVarContainer::kITSnSigmaKao]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kKaon);
+  fgData[AliDielectronVarContainer::kITSnSigmaPro]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kProton);
+
+  fgData[AliDielectronVarContainer::kTOFnSigmaEle]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kElectron);
+  fgData[AliDielectronVarContainer::kTOFnSigmaPio]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kPion);
+  fgData[AliDielectronVarContainer::kTOFnSigmaMuo]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kMuon);
+  fgData[AliDielectronVarContainer::kTOFnSigmaKao]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kKaon);
+  fgData[AliDielectronVarContainer::kTOFnSigmaPro]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kProton);
+}
+
+inline void AliDielectronVarContainer::FillVarAODTrack(const AliAODTrack *particle)
+{
+  //
+  // Fill track information available for histogramming into an array
+  //
+
+  // Fill common AliVParticle interface information
+  FillVarVParticle(particle);
+  // Fill common MC information if available
+  FillVarVParticleMC(particle);
+
+  Double_t tpcNcls=particle->GetTPCNcls();
+  // Reset AliESDtrack interface specific information
+  fgData[AliDielectronVarContainer::kNclsTPC]       = tpcNcls;
+  fgData[AliDielectronVarContainer::kNclsTPCiter1]  = tpcNcls; // not really available in AOD
+  fgData[AliDielectronVarContainer::kTrackStatus]   = (Double_t)particle->GetStatus();
+  
+  //TODO: set TRD pidProbs correctly
+  
+  // Fill AliAODTrack interface information
+  //
+  Double_t d0z0[2];
+  GetDCA(particle, d0z0);
+  fgData[AliDielectronVarContainer::kImpactParXY]   = d0z0[0];
+  fgData[AliDielectronVarContainer::kImpactParZ]    = d0z0[1];
+  fgData[AliDielectronVarContainer::kITSclusterMap] = particle->GetITSClusterMap();
+  
+  AliAODPid *pid=particle->GetDetPid();
+  if (pid){
+    Double_t mom =pid->GetTPCmomentum();
+    Double_t tpcSignalN=pid->GetTPCsignalN();
+    fgData[AliDielectronVarContainer::kTPCsignalN] = tpcSignalN;
+    fgData[AliDielectronVarContainer::kTPCsignalN] = tpcNcls>0?tpcSignalN/tpcNcls:0;
+    Double_t tpcNsigmaEle=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron);
+    Double_t tpcNsigmaPio=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
+    Double_t tpcNsigmaMuo=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
+    Double_t tpcNsigmaKao=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
+    Double_t tpcNsigmaPro=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
+    
+    fgData[AliDielectronVarContainer::kPIn]=mom;
+    fgData[AliDielectronVarContainer::kTPCsignal]=pid->GetTPCsignal();
+
+    fgData[AliDielectronVarContainer::kTPCnSigmaEle]=tpcNsigmaEle;
+    fgData[AliDielectronVarContainer::kTPCnSigmaPio]=tpcNsigmaPio;
+    fgData[AliDielectronVarContainer::kTPCnSigmaMuo]=tpcNsigmaMuo;
+    fgData[AliDielectronVarContainer::kTPCnSigmaKao]=tpcNsigmaKao;
+    fgData[AliDielectronVarContainer::kTPCnSigmaPro]=tpcNsigmaPro;
+  }
+}
+
+
+inline void AliDielectronVarContainer::FillVarMCParticle(const AliMCParticle *particle)
+{
+  //
+  // Fill track information available for histogramming into an array
+  //
+
+  // Fill common AliVParticle interface information
+  FillVarVParticle(particle);
+  // Fill common MC information if available
+  FillVarVParticleMC(particle);
+
+
+  // Fill AliMCParticle interface specific information
+
+}
+
+inline void AliDielectronVarContainer::FillVarAODMCParticle(const AliAODMCParticle *particle)
+{
+  //
+  // Fill track information available for histogramming into an array
+  //
+
+  // Fill common AliVParticle interface information
+  FillVarVParticle(particle);
+  // Fill common MC information if available
+  FillVarVParticleMC(particle);
+
+  // Fill AliAODMCParticle interface specific information
+
+}
+
+inline void AliDielectronVarContainer::FillVarDielectronPair(const AliDielectronPair *pair)
+{
+  //
+  // Fill pair information available for histogramming into an array
+  //
+  
+  // Fill common AliVParticle interface information
+  FillVarVParticle(pair);
+  // Reset MC array
+  ResetArrayDataMC(AliDielectronVarContainer::kPairMax_MC);
+
+  // Fill AliDielectronPair specific information
+  const AliKFParticle &kfPair = pair->GetKFParticle();
+
+  Double_t thetaHE=0;
+  Double_t phiHE=0;
+  Double_t thetaCS=0;
+  Double_t phiCS=0;
+
+  pair->GetThetaPhiCM(thetaHE,phiHE,thetaCS,phiCS);
+    
+  fgData[AliDielectronVarContainer::kChi2NDF]          = kfPair.GetChi2()/kfPair.GetNDF();
+  fgData[AliDielectronVarContainer::kDecayLength]      = kfPair.GetDecayLength();
+  fgData[AliDielectronVarContainer::kR]                = kfPair.GetR();
+  fgData[AliDielectronVarContainer::kOpeningAngle]     = pair->OpeningAngle();
+  fgData[AliDielectronVarContainer::kThetaHE]          = thetaHE;
+  fgData[AliDielectronVarContainer::kPhiHE]            = phiHE;
+  fgData[AliDielectronVarContainer::kThetaCS]          = thetaCS;
+  fgData[AliDielectronVarContainer::kPhiCS]            = phiCS;
+  fgData[AliDielectronVarContainer::kLegDist]          = pair->DistanceDaughters();
+  fgData[AliDielectronVarContainer::kLegDistXY]        = pair->DistanceDaughtersXY();
+  fgData[AliDielectronVarContainer::kDeltaEta]         = pair->DeltaEta();
+  fgData[AliDielectronVarContainer::kDeltaPhi]         = pair->DeltaPhi();
+  fgData[AliDielectronVarContainer::kMerr]             = kfPair.GetErrMass()>1e-30&&kfPair.GetMass()>1e-30?kfPair.GetErrMass()/kfPair.GetMass():1000000;
+  fgData[AliDielectronVarContainer::kPairType]         = pair->GetType();
+  fgData[AliDielectronVarContainer::kPseudoProperTime] = GetPseudoProperTime(pair);
+
+  
+  AliDielectronMC *mc=AliDielectronMC::Instance();
+  if (mc->HasMC()){
+    Bool_t samemother =  mc->HaveSameMother(pair);
+    fgDataMC[AliDielectronVarContainer::kIsJpsiPrimary] = mc->IsJpsiPrimary(pair);
+    fgDataMC[AliDielectronVarContainer::kHaveSameMother] = samemother ;
+  }
+
+}
+
+
+inline void AliDielectronVarContainer::FillVarKFParticle(const AliKFParticle *particle)
+{
+  //
+  // Fill track information available in AliKFParticle into an array
+  //
+
+  // Reset data array
+  ResetArrayData(AliDielectronVarContainer::kPairMax);
+  // Reset MC array
+  ResetArrayDataMC(AliDielectronVarContainer::kPairMax_MC);
+
+
+  fgData[AliDielectronVarContainer::kPx]        = particle->GetPx();
+  fgData[AliDielectronVarContainer::kPy]        = particle->GetPy();
+  fgData[AliDielectronVarContainer::kPz]        = particle->GetPz();
+  fgData[AliDielectronVarContainer::kPt]        = particle->GetPt();
+  fgData[AliDielectronVarContainer::kP]         = particle->GetP();
+  fgData[AliDielectronVarContainer::kXv]        = particle->GetX();
+  fgData[AliDielectronVarContainer::kYv]        = particle->GetY();
+  fgData[AliDielectronVarContainer::kZv]        = particle->GetZ();
+  fgData[AliDielectronVarContainer::kPhi]       = particle->GetPhi();
+  fgData[AliDielectronVarContainer::kEta]       = particle->GetEta();
+  fgData[AliDielectronVarContainer::kY]         = ((particle->GetE()*particle->GetE()-particle->GetPx()*particle->GetPx()-particle->GetPy()*particle->GetPy()-particle->GetPz()*particle->GetPz())>0.) ? TLorentzVector(particle->GetPx(),particle->GetPy(),particle->GetPz(),particle->GetE()).Rapidity() : -1111.;
+  fgData[AliDielectronVarContainer::kE]         = particle->GetE();
+  fgData[AliDielectronVarContainer::kM]         = particle->GetMass();
+  fgData[AliDielectronVarContainer::kCharge]    = particle->GetQ();
+}
+
+
+inline void AliDielectronVarContainer::FillVarVEvent(const AliVEvent *event)
+{
+  //
+  // Fill event information available for histogramming into an array
+  //
+  
+  // Reset data array
+  ResetArrayData(AliDielectronVarContainer::kNMaxValues);
+  // Reset MC array
+  ResetArrayDataMC(AliDielectronVarContainer::kNMaxValues_MC);
+
+  // set the KF vertex
+  if (fgKFVertex) delete fgKFVertex;
+  fgKFVertex = 0x0;
+  if (!event->GetPrimaryVertex()) return;
+  fgKFVertex = new AliKFVertex(*event->GetPrimaryVertex());
+
+
+  fgData[AliDielectronVarContainer::kXvPrim]       = event->GetPrimaryVertex()->GetX();
+  fgData[AliDielectronVarContainer::kYvPrim]       = event->GetPrimaryVertex()->GetY();
+  fgData[AliDielectronVarContainer::kZvPrim]       = event->GetPrimaryVertex()->GetZ();
+  fgData[AliDielectronVarContainer::kNContrib]     = event->GetPrimaryVertex()->GetNContributors();
+  //fgData[AliDielectronVarContainer::kChi2NDF]      = event->GetPrimaryVertex()->GetChi2perNDF(); // This is the pair value!
+  fgData[AliDielectronVarContainer::kNTrk]         = event->GetNumberOfTracks();
+  fgData[AliDielectronVarContainer::kBzkG]         = event->GetMagneticField();
+  fgData[AliDielectronVarContainer::kNacc]         = AliDielectronHelper::GetNacc(event);
+  fgData[AliDielectronVarContainer::kNaccTrcklts]  = AliDielectronHelper::GetNaccTrcklts(event);
+}
+
+
+inline void AliDielectronVarContainer::FillVarESDEvent(const AliESDEvent *event)
+{
+  //
+  // Fill event information available for histogramming into an array
+  // 
+  
+  // Fill common AliVEvent interface information
+  FillVarVEvent(event);
+
+  Double_t centralityF=-1;
+  AliCentrality *esdCentrality = const_cast<AliESDEvent*>(event)->GetCentrality();
+  if (esdCentrality) centralityF = esdCentrality->GetCentralityPercentile("V0M");
+  
+  // Fill AliESDEvent interface specific information
+  const AliESDVertex *esdVtx = event->GetPrimaryVertex();
+  fgData[AliDielectronVarContainer::kXRes]       = esdVtx->GetXRes();
+  fgData[AliDielectronVarContainer::kYRes]       = esdVtx->GetYRes();
+  fgData[AliDielectronVarContainer::kZRes]       = esdVtx->GetZRes();
+  fgData[AliDielectronVarContainer::kCentrality] = centralityF;
+}
+
+
+inline void AliDielectronVarContainer::FillVarAODEvent(const AliAODEvent *event)
+{
+  //
+  // Fill event information available for histogramming into an array
+  //   
+
+  // Fill common AliVEvent interface information
+  FillVarVEvent(event);
+
+  // Fill AliAODEvent interface specific information
+  // set the AOD vertex
+  if (fgAODVertex) delete fgAODVertex;
+  fgAODVertex = 0x0;
+  if (!event->GetPrimaryVertex()) return;
+  fgAODVertex = new AliAODVertex(*event->GetPrimaryVertex());
+
+}
+
+
+inline void AliDielectronVarContainer::FillVarMCEvent(const AliMCEvent *event)
+{ 
+  //
+  // Fill event information available for histogramming into an array
+  //   
+        
+  // Fill common AliVEvent interface information
+  FillVarVEvent(event);
+
+  // Fill AliMCEvent interface specific information
+  fgDataMC[AliDielectronVarContainer::kNch] = AliDielectronHelper::GetNch(event, 1.6);
+} 
+
+
+inline Double_t AliDielectronVarContainer::GetPseudoProperTime(const AliDielectronPair *pair) 
+{
+  //
+  // Calculate the pseudo proper time
+  //
+
+  if(!pair) return 0.;
+
+  Double_t pt  = pair->Pt();
+  Double_t dx  = pair->Xv() - fgData[AliDielectronVarContainer::kXvPrim];
+  Double_t dy  = pair->Yv() - fgData[AliDielectronVarContainer::kYvPrim];
+  Double_t lxy = ((dx * pair->Px()) + (dy * pair->Py()))/pt;
+  Double_t ppt = lxy * (TDatabasePDG::Instance()->GetParticle(443)->Mass())/pt;
+
+  return ppt;
+}
+
+
+inline void AliDielectronVarContainer::SetEvent(AliVEvent * const event)
+{
+  //
+  // Set the event
+  //
+
+  FillVarVEvent(event);
+}
+
+
+inline void AliDielectronVarContainer::InitESDpid(Int_t type)
+{
+  //
+  // initialize PID parameters
+  // type=0 is simulation
+  // type=1 is data
+
+  if (!fgPIDResponse) fgPIDResponse=new AliESDpid((Bool_t)(type==0));
+  Double_t alephParameters[5];
+  // simulation
+  alephParameters[0] = 2.15898e+00/50.;
+  alephParameters[1] = 1.75295e+01;
+  alephParameters[2] = 3.40030e-09;
+  alephParameters[3] = 1.96178e+00;
+  alephParameters[4] = 3.91720e+00;
+  fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
+  
+  // data
+  if (type==1){    
+    alephParameters[0] = 0.0283086/0.97;
+    alephParameters[1] = 2.63394e+01;
+    alephParameters[2] = 5.04114e-11;
+    alephParameters[3] = 2.12543e+00;
+    alephParameters[4] = 4.88663e+00;
+    fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
+    fgPIDResponse->GetTPCResponse().SetMip(50.);
+  }
+
+  fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
+    alephParameters[0],alephParameters[1],alephParameters[2],
+    alephParameters[3],alephParameters[4]);
+  
+  fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+}
+
+inline void AliDielectronVarContainer::InitAODpidUtil(Int_t type)
+{
+  if (!fgPIDResponse) fgPIDResponse=new AliAODpidUtil;
+  Double_t alephParameters[5];
+  // simulation
+  alephParameters[0] = 2.15898e+00/50.;
+  alephParameters[1] = 1.75295e+01;
+  alephParameters[2] = 3.40030e-09;
+  alephParameters[3] = 1.96178e+00;
+  alephParameters[4] = 3.91720e+00;
+  fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
+  
+  // data
+  if (type==1){
+    alephParameters[0] = 0.0283086/0.97;
+    alephParameters[1] = 2.63394e+01;
+    alephParameters[2] = 5.04114e-11;
+    alephParameters[3] = 2.12543e+00;
+    alephParameters[4] = 4.88663e+00;
+    fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
+    fgPIDResponse->GetTPCResponse().SetMip(50.);
+  }
+  
+  fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
+    alephParameters[0],alephParameters[1],alephParameters[2],
+    alephParameters[3],alephParameters[4]);
+  
+  fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+}
+
+
+inline Bool_t AliDielectronVarContainer::GetDCA(const AliAODTrack *track, Double_t d0z0[2])
+{
+  if(track->TestBit(AliAODTrack::kIsDCA)){
+    d0z0[0]=track->DCA();
+    d0z0[1]=track->ZAtDCA();
+    return kTRUE;
+  }
+  
+  Double_t covd0z0[3];
+  AliAODTrack copy(*track);
+  AliAODVertex *vtx =(AliAODVertex*)fgAODVertex;
+  Bool_t ok = copy.PropagateToDCA(vtx,fgData[AliDielectronVarContainer::kBzkG],kVeryBig,d0z0,covd0z0);
+  if(!ok){
+    d0z0[0]=-999.;
+    d0z0[1]=-999.;
+  }
+  return ok;
+}
+
+/*
+inline void AliDielectronVarContainer::FillVarTParticle(const TParticle *particle)
+{
+  //
+  // Fill TParticle interface information
+  //
+
+  fgData[AliDielectronVarContainer::kPx]        = particle->Px();
+  fgData[AliDielectronVarContainer::kPy]        = particle->Py();
+  fgData[AliDielectronVarContainer::kPz]        = particle->Pz();
+  fgData[AliDielectronVarContainer::kPt]        = particle->Pt();
+  fgData[AliDielectronVarContainer::kP]         = particle->P();
+  fgData[AliDielectronVarContainer::kXv]        = particle->Vx();
+  fgData[AliDielectronVarContainer::kYv]        = particle->Vy();
+  fgData[AliDielectronVarContainer::kZv]        = particle->Vz();
+  fgData[AliDielectronVarContainer::kOneOverPt] = 1./particle->Pt();
+  fgData[AliDielectronVarContainer::kPhi]       = particle->Phi();
+  fgData[AliDielectronVarContainer::kTheta]     = particle->Theta();
+  fgData[AliDielectronVarContainer::kEta]       = particle->Eta();
+  fgData[AliDielectronVarContainer::kY]         = particle->Y();
+  fgData[AliDielectronVarContainer::kE]         = particle->Energy();
+  fgData[AliDielectronVarContainer::kM]         = particle->GetMass();
+  fgData[AliDielectronVarContainer::kCharge]    = particle->GetPDG()->Charge()/3;
+}
+*/
+
+
+
+
+#endif
+
index d4ca429..d1ebc86 100644 (file)
@@ -13,8 +13,6 @@
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
 
-/* $Id$ */
-
 ///////////////////////////////////////////////////////////////////////////
 //   Cut class providing cuts to all infomation                          //
 //     available for the AliVParticle interface                          //                                                     //
index cd38bc0..a5c089b 100644 (file)
@@ -4,8 +4,6 @@
 /* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */ 
-
 //#############################################################
 //#                                                           # 
 //#         Class AliDielectronVarCuts                        #
index f3f6141..9fc405e 100644 (file)
@@ -50,6 +50,7 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   "NFclsTPCrobust",
   "NFclsTPCrobustFraction",
   "TPCsignalN",
+  "TPCsignalNfrac",
   "TPCchi2PerCluster",
   "TrackStatus",
     
@@ -64,7 +65,8 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   "PdgCode",
 
   "PdgCodeMother",
-
+  "PdgCodeGrandMother",
+    
   "NumberOfDaughters",
   "HaveSameMother",
   "IsJpsiPrimary",
@@ -82,6 +84,9 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
 
   "P_InnerParam",
   "TPC_signal",
+  "TOF_signal",
+  "TOF_beta",
+  
   "TPC_nSigma_Electrons",
   "TPC_nSigma_Pions",
   "TPC_nSigma_Muons",
@@ -111,6 +116,7 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   "Merr",
   "DCA",
   "PairType",
+  "PseudoProperTime",
   //
   "X",
   "Y",
@@ -120,14 +126,17 @@ const char* AliDielectronVarManager::fgkParticleNames[AliDielectronVarManager::k
   "ZRes",
   "NTrk",
   "Tracks",
+  "Nacc",
+  "kNaccTrcklts",
+  "kNch",
   "Centrality",
   "Nevents"
 };
 
-AliESDpid* AliDielectronVarManager::fgESDpid = 0x0;
-AliAODpidUtil* AliDielectronVarManager::fgAODpidUtil = 0x0;
-AliVEvent* AliDielectronVarManager::fgEvent  = 0x0;
-AliKFVertex* AliDielectronVarManager::fgKFVertex  = 0x0;
+AliPIDResponse* AliDielectronVarManager::fgPIDResponse = 0x0;
+AliVEvent*      AliDielectronVarManager::fgEvent       = 0x0;
+AliKFVertex*    AliDielectronVarManager::fgKFVertex    = 0x0;
+Double_t        AliDielectronVarManager::fgData[AliDielectronVarManager::kNMaxValues] = {};
 //________________________________________________________________
 AliDielectronVarManager::AliDielectronVarManager() :
   TNamed("AliDielectronVarManager","AliDielectronVarManager")
index f579c92..752e181 100644 (file)
 #include <AliCentrality.h>
 #include <AliAODpidUtil.h>
 #include <AliPID.h>
+#include <AliPIDResponse.h>
 
 #include "AliDielectronPair.h"
 #include "AliDielectronMC.h"
 #include "AliDielectronPID.h"
+#include "AliDielectronHelper.h"
 
 class AliVEvent;
 
@@ -82,6 +84,7 @@ public:
     kNFclsTPCr,              // number of findable clusters in the TPC with more robust definition
     kNFclsTPCrFrac,          // number of found/findable clusters in the TPC with more robust definition
     kTPCsignalN,             // number of points used for dEdx
+    kTPCsignalNfrac,         // fraction of points used for dEdx / cluster used for tracking
     kTPCchi2Cl,              // chi2/cl in TPC
     kTrackStatus,            // track status bits
     
@@ -97,7 +100,8 @@ public:
     kPdgCode,                // PDG code
 
     kPdgCodeMother,          // PDG code of the mother
-
+    kPdgCodeGrandMother,          // PDG code of the mother
+      
     kNumberOfDaughters,      // number of daughters
     kHaveSameMother,         // check that particles have the same mother (MC)
     kIsJpsiPrimary,          // check if the particle is primary (MC)
@@ -115,14 +119,17 @@ public:
 
     kPIn,                    // momentum at inner wall of TPC (if available), used for PID
     kTPCsignal,              // TPC dE/dx signal
-      
+    
+       kTOFsignal,              // TOF signal
+       kTOFbeta,                // TOF beta
+       
     kTPCnSigmaEle,           // number of sigmas to the dE/dx electron line in the TPC
     kTPCnSigmaPio,           // number of sigmas to the dE/dx pion line in the TPC
     kTPCnSigmaMuo,           // number of sigmas to the dE/dx muon line in the TPC
     kTPCnSigmaKao,           // number of sigmas to the dE/dx kaon line in the TPC
     kTPCnSigmaPro,           // number of sigmas to the dE/dx proton line in the TPC
       
-    kTOFnSigmaEle,           // number of sigmas to the pion line in the TOF
+       kTOFnSigmaEle,           // number of sigmas to the pion line in the TOF
     kTOFnSigmaPio,           // number of sigmas to the pion line in the TOF
     kTOFnSigmaMuo,           // number of sigmas to the muon line in the TOF
     kTOFnSigmaKao,           // number of sigmas to the kaon line in the TOF
@@ -151,6 +158,7 @@ public:
     kMerr,                   // error of mass calculation
     kDCA,                    // distance of closest approach TODO: not implemented yet
     kPairType,               // type of the pair, like like sign ++ unlikesign ...
+    kPseudoProperTime,       // pseudo proper time
     kPairMax,                 //
   // Event specific variables
     kXvPrim=kPairMax,        // prim vertex
@@ -159,8 +167,11 @@ public:
     kXRes,                   // primary vertex x-resolution
     kYRes,                   // primary vertex y-resolution
     kZRes,                   // primary vertex z-resolution
-    kNTrk,                   // number of tracks (or tracklets)
-    kTracks,                 // ESD tracks
+    kNTrk,                   // number of tracks (or tracklets) TODO: ambiguous
+    kTracks,                 // ESD tracks TODO: ambiguous
+    kNacc,                   // Number of accepted tracks
+    kNaccTrcklts,            // Number of accepted tracklets (MUON definition)
+    kNch,                    // Number of charged MC tracks
     kCentrality,             // event centrality fraction
     kNevents,                // event counter
     kNMaxValues              //
@@ -172,16 +183,24 @@ public:
   AliDielectronVarManager(const char* name, const char* title);
   virtual ~AliDielectronVarManager();
   static void Fill(const TObject* particle, Double_t * const values);
+  static void FillVarMCParticle2(const AliVParticle *p1, const AliVParticle *p2, Double_t * const values);
 
   static void InitESDpid(Int_t type=0);
   static void InitAODpidUtil(Int_t type=0);
-  static void SetESDpid(AliESDpid * const pid) {fgESDpid=pid;}
-  static AliESDpid* GetESDpid() {return fgESDpid;}
-  static AliAODpidUtil* GetAODpidUtil() {return fgAODpidUtil;}
+  static void SetESDpid(AliESDpid * const pid) {fgPIDResponse=pid;}
+  static AliESDpid* GetESDpid() {return (AliESDpid*)fgPIDResponse;}
+  static AliAODpidUtil* GetAODpidUtil() {return (AliAODpidUtil*)fgPIDResponse;}
+  static void SetPIDResponse(AliPIDResponse *pidResponse) {fgPIDResponse=pidResponse;}
   static void SetEvent(AliVEvent * const ev);
   static Bool_t GetDCA(const AliAODTrack *track, Double_t d0z0[2]);
-    
+
+  static const AliKFVertex* GetKFVertex() {return fgKFVertex;}
+  
   static const char* GetValueName(Int_t i) { return (i>=0&&i<kNMaxValues)?fgkParticleNames[i]:""; }
+
+  static const Double_t* GetData() {return fgData;}
+
+  static Double_t GetValue(ValueTypes val) {return fgData[val];}
 private:
 
   static const char* fgkParticleNames[kNMaxValues];  //variable names
@@ -199,10 +218,11 @@ private:
   static void FillVarAODEvent(const AliAODEvent *event,              Double_t * const values);
   static void FillVarMCEvent(const AliMCEvent *event,                Double_t * const values);
   
-  static AliESDpid     *fgESDpid;             // ESD pid object
-  static AliAODpidUtil *fgAODpidUtil;         // AOD pid object
-  static AliVEvent     *fgEvent;              // current event pointer
-  static AliKFVertex   *fgKFVertex;           // kf vertex
+  static AliPIDResponse  *fgPIDResponse;        // PID response object
+  static AliVEvent       *fgEvent;              // current event pointer
+  static AliKFVertex     *fgKFVertex;           // kf vertex
+
+  static Double_t fgData[kNMaxValues];        //! data
   
   AliDielectronVarManager(const AliDielectronVarManager &c);
   AliDielectronVarManager &operator=(const AliDielectronVarManager &c);
@@ -247,7 +267,7 @@ inline void AliDielectronVarManager::FillVarVParticle(const AliVParticle *partic
   values[AliDielectronVarManager::kYv]        = particle->Yv();
   values[AliDielectronVarManager::kZv]        = particle->Zv();
 
-  values[AliDielectronVarManager::kOneOverPt] = particle->OneOverPt();
+  values[AliDielectronVarManager::kOneOverPt] = (particle->Pt()>1.0e-3 ? particle->OneOverPt() : 0.0);
   values[AliDielectronVarManager::kPhi]       = particle->Phi();
   values[AliDielectronVarManager::kTheta]     = particle->Theta();
   values[AliDielectronVarManager::kEta]       = particle->Eta();
@@ -259,7 +279,9 @@ inline void AliDielectronVarManager::FillVarVParticle(const AliVParticle *partic
   
   values[AliDielectronVarManager::kPdgCode]   = particle->PdgCode();
     
-  if ( fgEvent ) AliDielectronVarManager::Fill(fgEvent, values);
+//   if ( fgEvent ) AliDielectronVarManager::Fill(fgEvent, values);
+  for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues; ++i)
+    values[i]=fgData[i];
 }
 
 inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle, Double_t * const values)
@@ -274,13 +296,15 @@ inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle
   Double_t pidProbs[AliPID::kSPECIES];
   // Fill AliESDtrack interface specific information
   Double_t tpcNcls=particle->GetTPCNcls();
+  Double_t tpcSignalN=particle->GetTPCsignalN();
   values[AliDielectronVarManager::kNclsITS]       = particle->GetNcls(0); // TODO: get rid of the plain numbers
   values[AliDielectronVarManager::kNclsTPC]       = tpcNcls; // TODO: get rid of the plain numbers
   values[AliDielectronVarManager::kNclsTPCiter1]  = particle->GetTPCNclsIter1(); // TODO: get rid of the plain numbers
   values[AliDielectronVarManager::kNFclsTPC]      = particle->GetTPCNclsF();
   values[AliDielectronVarManager::kNFclsTPCr]     = particle->GetTPCClusterInfo(2,1);
   values[AliDielectronVarManager::kNFclsTPCrFrac] = particle->GetTPCClusterInfo(2);
-  values[AliDielectronVarManager::kTPCsignalN]    = particle->GetTPCsignalN();
+  values[AliDielectronVarManager::kTPCsignalN]    = tpcSignalN;
+  values[AliDielectronVarManager::kTPCsignalNfrac]= tpcNcls>0?tpcSignalN/tpcNcls:0;
   values[AliDielectronVarManager::kNclsTRD]       = particle->GetNcls(2); // TODO: get rid of the plain numbers
   values[AliDielectronVarManager::kTRDntracklets] = particle->GetTRDntracklets(); // TODO: GetTRDtracklets/GetTRDntracklets?
   values[AliDielectronVarManager::kTRDpidQuality] = particle->GetTRDpidQuality();
@@ -302,22 +326,26 @@ inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle
   values[AliDielectronVarManager::kImpactParZ]    = impactParZ;
 
 
-  values[AliDielectronVarManager::kPdgCode]=0;
-  values[AliDielectronVarManager::kPdgCodeMother]=0;
-
+  values[AliDielectronVarManager::kPdgCode]=-1;
+  values[AliDielectronVarManager::kPdgCodeMother]=-1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother]=-1;
+  
   values[AliDielectronVarManager::kNumberOfDaughters]=-999;
   
   AliDielectronMC *mc=AliDielectronMC::Instance();
   
   if (mc->HasMC()){
     if (mc->GetMCTrack(particle))
-      values[AliDielectronVarManager::kPdgCode]=
-      mc->GetMCTrack(particle)->PdgCode();
+      values[AliDielectronVarManager::kPdgCode]=mc->GetMCTrack(particle)->PdgCode();
     
-    Int_t pdgMother=mc->GetMotherPDG(particle);
-    if (pdgMother!=-999)
-      values[AliDielectronVarManager::kPdgCodeMother]=pdgMother;
-
+    AliMCParticle *motherMC=mc->GetMCTrackMother(particle); //mother
+    if (motherMC){
+      values[AliDielectronVarManager::kPdgCodeMother]=motherMC->PdgCode();
+      
+      motherMC=mc->GetMCTrackMother(motherMC);  //grand motherMC
+      if (motherMC) values[AliDielectronVarManager::kPdgCodeGrandMother]=motherMC->PdgCode();;
+    }
+      
     values[AliDielectronVarManager::kNumberOfDaughters]=mc->NumberOfDaughters(particle);
   } //if(mc->HasMC())
   
@@ -341,28 +369,47 @@ inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle
   if (in) mom = in->GetP();
   values[AliDielectronVarManager::kPIn]=mom;
   values[AliDielectronVarManager::kTPCsignal]=particle->GetTPCsignal();
+  
+  values[AliDielectronVarManager::kTOFsignal]=particle->GetTOFsignal();
+  
+  Double_t l = particle->GetIntegratedLength();  // cm
+  Double_t t = particle->GetTOFsignal();
+  Double_t t0 = fgPIDResponse->GetTOFResponse().GetTimeZero(); // ps
+
+  if( (l < 360. || l > 800.) || (t <= 0.) || (t0 >999990.0) ) {
+       values[AliDielectronVarManager::kTOFbeta]=0.0;
+  }
+  else {
+       t -= t0; // subtract the T0
+       l *= 0.01;  // cm ->m
+       t *= 1e-12; //ps -> s
+    
+       Double_t v = l / t;
+       Float_t beta = v / TMath::C();
+       values[AliDielectronVarManager::kTOFbeta]=beta;
+  }
+  
   // nsigma to Electron band
   // TODO: for the moment we set the bethe bloch parameters manually
   //       this should be changed in future!
   
-  values[AliDielectronVarManager::kTPCnSigmaEle]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kElectron)-AliDielectronPID::GetCorrVal();
-  values[AliDielectronVarManager::kTPCnSigmaPio]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kPion);
-  values[AliDielectronVarManager::kTPCnSigmaMuo]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kMuon);
-  values[AliDielectronVarManager::kTPCnSigmaKao]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kKaon);
-  values[AliDielectronVarManager::kTPCnSigmaPro]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kProton);
-
-  values[AliDielectronVarManager::kITSnSigmaEle]=fgESDpid->NumberOfSigmasITS(particle,AliPID::kElectron);
-  values[AliDielectronVarManager::kITSnSigmaPio]=fgESDpid->NumberOfSigmasITS(particle,AliPID::kPion);
-  values[AliDielectronVarManager::kITSnSigmaMuo]=fgESDpid->NumberOfSigmasITS(particle,AliPID::kMuon);
-  values[AliDielectronVarManager::kITSnSigmaKao]=fgESDpid->NumberOfSigmasITS(particle,AliPID::kKaon);
-  values[AliDielectronVarManager::kITSnSigmaPro]=fgESDpid->NumberOfSigmasITS(particle,AliPID::kProton);
-
-  Double_t t0=fgESDpid->GetTOFResponse().GetTimeZero();
-  values[AliDielectronVarManager::kTOFnSigmaEle]=fgESDpid->NumberOfSigmasTOF(particle,AliPID::kElectron,t0);
-  values[AliDielectronVarManager::kTOFnSigmaPio]=fgESDpid->NumberOfSigmasTOF(particle,AliPID::kPion,t0);
-  values[AliDielectronVarManager::kTOFnSigmaMuo]=fgESDpid->NumberOfSigmasTOF(particle,AliPID::kMuon,t0);
-  values[AliDielectronVarManager::kTOFnSigmaKao]=fgESDpid->NumberOfSigmasTOF(particle,AliPID::kKaon,t0);
-  values[AliDielectronVarManager::kTOFnSigmaPro]=fgESDpid->NumberOfSigmasTOF(particle,AliPID::kProton,t0);
+  values[AliDielectronVarManager::kTPCnSigmaEle]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron)-AliDielectronPID::GetCorrVal();
+  values[AliDielectronVarManager::kTPCnSigmaPio]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
+  values[AliDielectronVarManager::kTPCnSigmaMuo]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
+  values[AliDielectronVarManager::kTPCnSigmaKao]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
+  values[AliDielectronVarManager::kTPCnSigmaPro]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
+
+  values[AliDielectronVarManager::kITSnSigmaEle]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kElectron);
+  values[AliDielectronVarManager::kITSnSigmaPio]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kPion);
+  values[AliDielectronVarManager::kITSnSigmaMuo]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kMuon);
+  values[AliDielectronVarManager::kITSnSigmaKao]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kKaon);
+  values[AliDielectronVarManager::kITSnSigmaPro]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kProton);
+
+  values[AliDielectronVarManager::kTOFnSigmaEle]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kElectron);
+  values[AliDielectronVarManager::kTOFnSigmaPio]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kPion);
+  values[AliDielectronVarManager::kTOFnSigmaMuo]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kMuon);
+  values[AliDielectronVarManager::kTOFnSigmaKao]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kKaon);
+  values[AliDielectronVarManager::kTOFnSigmaPro]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kProton);
 }
 
 inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle, Double_t * const values)
@@ -373,11 +420,12 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
 
   // Fill common AliVParticle interface information
   FillVarVParticle(particle, values);
-  
+
+  Double_t tpcNcls=particle->GetTPCNcls();
   // Reset AliESDtrack interface specific information
   values[AliDielectronVarManager::kNclsITS]       = 0;
-  values[AliDielectronVarManager::kNclsTPC]       = particle->GetTPCNcls();
-  values[AliDielectronVarManager::kNclsTPCiter1]  = particle->GetTPCNcls(); // not really available in AOD
+  values[AliDielectronVarManager::kNclsTPC]       = tpcNcls;
+  values[AliDielectronVarManager::kNclsTPCiter1]  = tpcNcls; // not really available in AOD
   values[AliDielectronVarManager::kNFclsTPC]      = 0;
   values[AliDielectronVarManager::kNFclsTPCr]     = 0;
   values[AliDielectronVarManager::kNFclsTPCrFrac] = 0;
@@ -393,8 +441,8 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
   values[AliDielectronVarManager::kTRDprobEle]    = 0;
   values[AliDielectronVarManager::kTRDprobPio]    = 0;
   
-  //TODO: This is only an approximation!!!
   values[AliDielectronVarManager::kTPCsignalN]    = 0;
+  values[AliDielectronVarManager::kTPCsignalNfrac]= 0;
   
   // Fill AliAODTrack interface information
   //
@@ -405,6 +453,9 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
 
   values[AliDielectronVarManager::kPIn]=0;
   values[AliDielectronVarManager::kTPCsignal]=0;
+  
+  values[AliDielectronVarManager::kTOFsignal]=0;
+  values[AliDielectronVarManager::kTOFbeta]=0;
 
   values[AliDielectronVarManager::kTPCnSigmaEle]=0;
   values[AliDielectronVarManager::kTPCnSigmaPio]=0;
@@ -417,12 +468,14 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
   AliAODPid *pid=particle->GetDetPid();
   if (pid){
     Double_t mom =pid->GetTPCmomentum();
-    values[AliDielectronVarManager::kTPCsignalN] = pid->GetTPCsignalN();
-    Double_t tpcNsigmaEle=fgAODpidUtil->NumberOfSigmasTPC(particle,AliPID::kElectron);
-    Double_t tpcNsigmaPio=fgAODpidUtil->NumberOfSigmasTPC(particle,AliPID::kPion);
-    Double_t tpcNsigmaMuo=fgAODpidUtil->NumberOfSigmasTPC(particle,AliPID::kMuon);
-    Double_t tpcNsigmaKao=fgAODpidUtil->NumberOfSigmasTPC(particle,AliPID::kKaon);
-    Double_t tpcNsigmaPro=fgAODpidUtil->NumberOfSigmasTPC(particle,AliPID::kProton);
+    Double_t tpcSignalN=pid->GetTPCsignalN();
+    values[AliDielectronVarManager::kTPCsignalN] = tpcSignalN;
+    values[AliDielectronVarManager::kTPCsignalN] = tpcNcls>0?tpcSignalN/tpcNcls:0;
+    Double_t tpcNsigmaEle=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron);
+    Double_t tpcNsigmaPio=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
+    Double_t tpcNsigmaMuo=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
+    Double_t tpcNsigmaKao=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
+    Double_t tpcNsigmaPro=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
     
     values[AliDielectronVarManager::kPIn]=mom;
     values[AliDielectronVarManager::kTPCsignal]=pid->GetTPCsignal();
@@ -437,6 +490,30 @@ inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle
     values[AliDielectronVarManager::kTRDpidQuality] = 0;
     
   }
+
+  values[AliDielectronVarManager::kPdgCode]=-1;
+  values[AliDielectronVarManager::kPdgCodeMother]=-1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother]=-1;
+  
+  values[AliDielectronVarManager::kNumberOfDaughters]=-999;
+  
+  AliDielectronMC *mc=AliDielectronMC::Instance();
+  
+  if (mc->HasMC()){
+    if (mc->GetMCTrack(particle))
+      values[AliDielectronVarManager::kPdgCode]=mc->GetMCTrack(particle)->PdgCode();
+    
+    AliAODMCParticle *motherMC=mc->GetMCTrackMother(particle); //mother
+    if (motherMC){
+      values[AliDielectronVarManager::kPdgCodeMother]=motherMC->PdgCode();
+      
+      motherMC=mc->GetMCTrackMother(motherMC);  //grand motherMC
+      if (motherMC) values[AliDielectronVarManager::kPdgCodeGrandMother]=motherMC->PdgCode();;
+    }
+    
+    values[AliDielectronVarManager::kNumberOfDaughters]=mc->NumberOfDaughters(particle);
+  } //if(mc->HasMC())
+  
 }
 
 inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *particle, Double_t * const values)
@@ -459,10 +536,13 @@ inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *part
   values[AliDielectronVarManager::kTRDprobEle]    = 0;
   values[AliDielectronVarManager::kTRDprobPio]    = 0;
   values[AliDielectronVarManager::kTPCsignalN]    = 0;
+  values[AliDielectronVarManager::kTPCsignalNfrac]    = 0;
   values[AliDielectronVarManager::kImpactParXY]   = 0;
   values[AliDielectronVarManager::kImpactParZ]    = 0;
   values[AliDielectronVarManager::kPIn]           = 0;
   values[AliDielectronVarManager::kTPCsignal]     = 0;
+  values[AliDielectronVarManager::kTOFsignal]     = 0;
+  values[AliDielectronVarManager::kTOFbeta]       = 0;
   values[AliDielectronVarManager::kTPCnSigmaEle]  = 0;
   values[AliDielectronVarManager::kTPCnSigmaPio]  = 0;
   values[AliDielectronVarManager::kTPCnSigmaMuo]  = 0;
@@ -470,8 +550,9 @@ inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *part
   values[AliDielectronVarManager::kTPCnSigmaPro]  = 0;
   values[AliDielectronVarManager::kITSclusterMap] = 0;
   
-  values[AliDielectronVarManager::kPdgCode]       = 0;
-  values[AliDielectronVarManager::kPdgCodeMother] = 0;
+  values[AliDielectronVarManager::kPdgCode]       = -1;
+  values[AliDielectronVarManager::kPdgCodeMother] = -1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother] = -1;
   
   // Fill common AliVParticle interface information
   FillVarVParticle(particle, values);
@@ -481,13 +562,94 @@ inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *part
   // Fill AliMCParticle interface specific information
   values[AliDielectronVarManager::kPdgCode] = particle->PdgCode();
 
-  AliMCParticle *mother = mc->GetMCTrackMother(particle);
-  if (mother) values[AliDielectronVarManager::kPdgCodeMother] = mother->PdgCode();
-
+  AliMCParticle *motherMC = mc->GetMCTrackMother(particle);
+  if (motherMC){
+    values[AliDielectronVarManager::kPdgCodeMother]=motherMC->PdgCode();
+    motherMC=mc->GetMCTrackMother(motherMC);  //grand mother
+    if (motherMC) values[AliDielectronVarManager::kPdgCodeGrandMother]=motherMC->PdgCode();;
+  }
+  
   values[AliDielectronVarManager::kIsJpsiPrimary] = mc->IsJpsiPrimary(particle);
   values[AliDielectronVarManager::kNumberOfDaughters]=mc->NumberOfDaughters(particle);
 }
 
+
+inline void AliDielectronVarManager::FillVarMCParticle2(const AliVParticle *p1, const AliVParticle *p2, Double_t * const values) {
+  //
+  // fill 2 track information starting from MC legs
+  //
+
+  values[AliDielectronVarManager::kNclsITS]       = 0;
+  values[AliDielectronVarManager::kNclsTPC]       = 0;
+  values[AliDielectronVarManager::kNclsTPCiter1]  = 0; 
+  values[AliDielectronVarManager::kNFclsTPC]      = 0;
+  values[AliDielectronVarManager::kNFclsTPCr]     = 0;
+  values[AliDielectronVarManager::kNFclsTPCrFrac] = 0;
+  values[AliDielectronVarManager::kNclsTRD]       = 0;
+  values[AliDielectronVarManager::kTRDntracklets] = 0;
+  values[AliDielectronVarManager::kTRDpidQuality] = 0;
+  values[AliDielectronVarManager::kTPCchi2Cl]     = 0;
+  values[AliDielectronVarManager::kTrackStatus]   = 0;
+  values[AliDielectronVarManager::kTRDprobEle]    = 0;
+  values[AliDielectronVarManager::kTRDprobPio]    = 0;
+  values[AliDielectronVarManager::kTPCsignalN]    = 0;
+  values[AliDielectronVarManager::kTPCsignalNfrac]    = 0;
+  values[AliDielectronVarManager::kImpactParXY]   = 0;
+  values[AliDielectronVarManager::kImpactParZ]    = 0;
+  values[AliDielectronVarManager::kPIn]           = 0;
+  values[AliDielectronVarManager::kTPCsignal]     = 0;
+  values[AliDielectronVarManager::kTPCnSigmaEle]  = 0;
+  values[AliDielectronVarManager::kTPCnSigmaPio]  = 0;
+  values[AliDielectronVarManager::kTPCnSigmaMuo]  = 0;
+  values[AliDielectronVarManager::kTPCnSigmaKao]  = 0;
+  values[AliDielectronVarManager::kTPCnSigmaPro]  = 0;
+  values[AliDielectronVarManager::kITSclusterMap] = 0;
+  
+  values[AliDielectronVarManager::kPdgCode]       = 0;
+  values[AliDielectronVarManager::kPdgCodeMother] = 0;
+
+  AliDielectronMC *mc=AliDielectronMC::Instance();
+  AliVParticle* mother=0x0;
+  Int_t mLabel1 = mc->GetMothersLabel(p1->GetLabel());
+  Int_t mLabel2 = mc->GetMothersLabel(p2->GetLabel());
+  if(mLabel1==mLabel2)
+    mother = mc->GetMCTrackFromMCEvent(mLabel1);
+  if(mother)     // same mother
+    FillVarVParticle(mother, values);
+  else {         // the 2 particles come from different mothers so 2-particles quantities are calculated here
+    // AliVParticle part
+    values[AliDielectronVarManager::kPx]        = p1->Px()+p2->Px();
+    values[AliDielectronVarManager::kPy]        = p1->Py()+p2->Py();
+    values[AliDielectronVarManager::kPz]        = p1->Pz()+p2->Pz();
+    values[AliDielectronVarManager::kPt]        = TMath::Sqrt(values[AliDielectronVarManager::kPx]*
+                                                             values[AliDielectronVarManager::kPx]+
+                                                             values[AliDielectronVarManager::kPy]*
+                                                             values[AliDielectronVarManager::kPy]);
+    values[AliDielectronVarManager::kP]         = TMath::Sqrt(values[AliDielectronVarManager::kPt]*
+                                                             values[AliDielectronVarManager::kPt]+
+                                                             values[AliDielectronVarManager::kPz]*
+                                                             values[AliDielectronVarManager::kPz]);
+    
+    values[AliDielectronVarManager::kXv]        = 0;
+    values[AliDielectronVarManager::kYv]        = 0;
+    values[AliDielectronVarManager::kZv]        = 0;
+    
+    values[AliDielectronVarManager::kOneOverPt] = (values[AliDielectronVarManager::kPt]>1.0e-6 ? 1.0/values[AliDielectronVarManager::kPt] : 0.0);
+    values[AliDielectronVarManager::kPhi]       = TMath::ATan2(values[AliDielectronVarManager::kPy],values[AliDielectronVarManager::kPx]);
+    values[AliDielectronVarManager::kTheta]     = TMath::ATan2(values[AliDielectronVarManager::kPt],values[AliDielectronVarManager::kPz]);
+    values[AliDielectronVarManager::kEta]       = ((values[AliDielectronVarManager::kP]-values[AliDielectronVarManager::kPz])>1.0e-6 && (values[AliDielectronVarManager::kP]+values[AliDielectronVarManager::kPz])>1.0e-6 ? 0.5*TMath::Log((values[AliDielectronVarManager::kP]+values[AliDielectronVarManager::kPz])/(values[AliDielectronVarManager::kP]-values[AliDielectronVarManager::kPz])) : -9999.);
+    values[AliDielectronVarManager::kE]         = p1->E()+p2->E();
+    values[AliDielectronVarManager::kY]         = ((values[AliDielectronVarManager::kE]-values[AliDielectronVarManager::kPz])>1.0e-6 && (values[AliDielectronVarManager::kE]+values[AliDielectronVarManager::kPz])>1.0e-6 ? 0.5*TMath::Log((values[AliDielectronVarManager::kE]+values[AliDielectronVarManager::kPz])/(values[AliDielectronVarManager::kE]-values[AliDielectronVarManager::kPz])) : -9999.);
+    values[AliDielectronVarManager::kCharge]    = p1->Charge()+p2->Charge();
+
+    values[AliDielectronVarManager::kM]         = p1->M()*p1->M()+p2->M()*p2->M()+
+      2.0*(p1->E()*p2->E()-p1->Px()*p2->Px()-p1->Py()*p2->Py()-p1->Pz()*p2->Pz());
+
+    if ( fgEvent ) AliDielectronVarManager::Fill(fgEvent, values);
+  }
+}
+
+
 inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle *particle, Double_t * const values)
 {
   //
@@ -506,6 +668,7 @@ inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle
   values[AliDielectronVarManager::kTRDprobEle]    = 0;
   values[AliDielectronVarManager::kTRDprobPio]    = 0;
   values[AliDielectronVarManager::kTPCsignalN]    = 0;
+  values[AliDielectronVarManager::kTPCsignalNfrac]= 0;
   values[AliDielectronVarManager::kImpactParXY]   = 0;
   values[AliDielectronVarManager::kImpactParZ]    = 0;
   values[AliDielectronVarManager::kPIn]           = 0;
@@ -517,8 +680,9 @@ inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle
   values[AliDielectronVarManager::kTPCnSigmaPro]  = 0;
   values[AliDielectronVarManager::kITSclusterMap] = 0;
   
-  values[AliDielectronVarManager::kPdgCode]       = 0;
-  values[AliDielectronVarManager::kPdgCodeMother] = 0;
+  values[AliDielectronVarManager::kPdgCode]       = -1;
+  values[AliDielectronVarManager::kPdgCodeMother] = -1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother] = -1;
   
   // Fill common AliVParticle interface information
   FillVarVParticle(particle, values);
@@ -529,8 +693,14 @@ inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle
   // Fill AliAODMCParticle interface specific information
   values[AliDielectronVarManager::kPdgCode] = particle->PdgCode();
 
-  AliVParticle *mother = mc->GetMCTrackMother(particle);
-  if (mother) values[AliDielectronVarManager::kPdgCodeMother] = mother->PdgCode();
+  AliAODMCParticle *motherMC = mc->GetMCTrackMother(particle);
+  if (motherMC){
+    values[AliDielectronVarManager::kPdgCodeMother]=motherMC->PdgCode();
+    motherMC=mc->GetMCTrackMother(motherMC);  //grand mother
+    if (motherMC) values[AliDielectronVarManager::kPdgCodeGrandMother]=motherMC->PdgCode();;
+  }
+  
+  
   values[AliDielectronVarManager::kIsJpsiPrimary] = mc->IsJpsiPrimary(particle);
 
   values[AliDielectronVarManager::kNumberOfDaughters]=mc->NumberOfDaughters(particle);
@@ -542,8 +712,9 @@ inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPa
   // Fill pair information available for histogramming into an array
   //
   
-  values[AliDielectronVarManager::kPdgCode]=0;
-  values[AliDielectronVarManager::kPdgCodeMother]=0;
+  values[AliDielectronVarManager::kPdgCode]=-1;
+  values[AliDielectronVarManager::kPdgCodeMother]=-1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother]=-1;
   
   // Fill common AliVParticle interface information
   FillVarVParticle(pair, values);
@@ -572,15 +743,16 @@ inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPa
   values[AliDielectronVarManager::kDeltaPhi]     = pair->DeltaPhi();
   values[AliDielectronVarManager::kMerr]         = kfPair.GetErrMass()>1e-30&&kfPair.GetMass()>1e-30?kfPair.GetErrMass()/kfPair.GetMass():1000000;
   values[AliDielectronVarManager::kPairType]     = pair->GetType();
-
+  values[AliDielectronVarManager::kPseudoProperTime] = pair->GetPseudoProperTime(fgEvent->GetPrimaryVertex());
 
   
   AliDielectronMC *mc=AliDielectronMC::Instance();
   
   if (mc->HasMC()){
-  Bool_t samemother =  mc->HaveSameMother(pair);
-  values[AliDielectronVarManager::kIsJpsiPrimary] = mc->IsJpsiPrimary(pair);
-  values[AliDielectronVarManager::kHaveSameMother] = samemother ;
+    Bool_t samemother =  mc->HaveSameMother(pair);
+    values[AliDielectronVarManager::kIsJpsiPrimary] = mc->IsJpsiPrimary(pair);
+    values[AliDielectronVarManager::kHaveSameMother] = samemother ;
+    
   }//if (mc->HasMC())
 
 
@@ -623,10 +795,13 @@ inline void AliDielectronVarManager::FillVarKFParticle(const AliKFParticle *part
   values[AliDielectronVarManager::kTRDprobEle]    = 0;
   values[AliDielectronVarManager::kTRDprobPio]    = 0;
   values[AliDielectronVarManager::kTPCsignalN]    = 0;
+  values[AliDielectronVarManager::kTPCsignalNfrac]= 0;
   values[AliDielectronVarManager::kImpactParXY]   = 0;
   values[AliDielectronVarManager::kImpactParZ]    = 0;
   values[AliDielectronVarManager::kPIn]           = 0;
   values[AliDielectronVarManager::kTPCsignal]     = 0;
+  values[AliDielectronVarManager::kTOFsignal]     = 0;
+  values[AliDielectronVarManager::kTOFbeta]       = 0;
   values[AliDielectronVarManager::kTPCnSigmaEle]  = 0;
   values[AliDielectronVarManager::kTPCnSigmaPio]  = 0;
   values[AliDielectronVarManager::kTPCnSigmaMuo]  = 0;
@@ -634,8 +809,9 @@ inline void AliDielectronVarManager::FillVarKFParticle(const AliKFParticle *part
   values[AliDielectronVarManager::kTPCnSigmaPro]  = 0;
   values[AliDielectronVarManager::kITSclusterMap] = 0;
   
-  values[AliDielectronVarManager::kPdgCode]       = 0;
-  values[AliDielectronVarManager::kPdgCodeMother] = 0;
+  values[AliDielectronVarManager::kPdgCode]       = -1;
+  values[AliDielectronVarManager::kPdgCodeMother] = -1;
+  values[AliDielectronVarManager::kPdgCodeGrandMother] = -1;
   
   
   if ( fgEvent ) AliDielectronVarManager::Fill(fgEvent, values);
@@ -651,9 +827,11 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
   values[AliDielectronVarManager::kXvPrim]       = 0;
   values[AliDielectronVarManager::kYvPrim]       = 0;
   values[AliDielectronVarManager::kZvPrim]       = 0;
-  values[AliDielectronVarManager::kChi2NDF]      = 0;
+//   values[AliDielectronVarManager::kChi2NDF]      = 0; //This is the pair value!!!
   
   values[AliDielectronVarManager::kNTrk]         = 0;
+  values[AliDielectronVarManager::kNacc]         = 0;
+  values[AliDielectronVarManager::kNaccTrcklts]  = 0;
   values[AliDielectronVarManager::kNevents]      = 0; //always fill bin 0;
 
   if (!primVtx) return;
@@ -661,9 +839,11 @@ inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Doubl
   values[AliDielectronVarManager::kXvPrim]       = primVtx->GetX();
   values[AliDielectronVarManager::kYvPrim]       = primVtx->GetY();
   values[AliDielectronVarManager::kZvPrim]       = primVtx->GetZ();
-  values[AliDielectronVarManager::kChi2NDF]      = primVtx->GetChi2perNDF();
+//   values[AliDielectronVarManager::kChi2NDF]      = primVtx->GetChi2perNDF(); //this is the pair value
 
   values[AliDielectronVarManager::kNTrk]         = event->GetNumberOfTracks();
+  values[AliDielectronVarManager::kNacc]         = AliDielectronHelper::GetNacc(event);
+  values[AliDielectronVarManager::kNaccTrcklts]  = AliDielectronHelper::GetNaccTrcklts(event);
 }
 
 inline void AliDielectronVarManager::FillVarESDEvent(const AliESDEvent *event, Double_t * const values)
@@ -709,6 +889,7 @@ inline void AliDielectronVarManager::FillVarMCEvent(const AliMCEvent *event, Dou
   FillVarVEvent(event, values);
 
   // Fill AliMCEvent interface specific information
+  values[AliDielectronVarManager::kNch] = AliDielectronHelper::GetNch(event, 1.6);
 } 
   
 inline void AliDielectronVarManager::InitESDpid(Int_t type)
@@ -718,7 +899,7 @@ inline void AliDielectronVarManager::InitESDpid(Int_t type)
   // type=0 is simulation
   // type=1 is data
 
-  if (!fgESDpid) fgESDpid=new AliESDpid;
+  if (!fgPIDResponse) fgPIDResponse=new AliESDpid((Bool_t)(type==0));
   Double_t alephParameters[5];
   // simulation
   alephParameters[0] = 2.15898e+00/50.;
@@ -726,7 +907,7 @@ inline void AliDielectronVarManager::InitESDpid(Int_t type)
   alephParameters[2] = 3.40030e-09;
   alephParameters[3] = 1.96178e+00;
   alephParameters[4] = 3.91720e+00;
-  fgESDpid->GetTOFResponse().SetTimeResolution(80.);
+  fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
   
   // data
   if (type==1){    
@@ -735,20 +916,20 @@ inline void AliDielectronVarManager::InitESDpid(Int_t type)
     alephParameters[2] = 5.04114e-11;
     alephParameters[3] = 2.12543e+00;
     alephParameters[4] = 4.88663e+00;
-    fgESDpid->GetTOFResponse().SetTimeResolution(130.);
-    fgESDpid->GetTPCResponse().SetMip(50.);
+    fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
+    fgPIDResponse->GetTPCResponse().SetMip(50.);
   }
 
-  fgESDpid->GetTPCResponse().SetBetheBlochParameters(
+  fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
     alephParameters[0],alephParameters[1],alephParameters[2],
     alephParameters[3],alephParameters[4]);
   
-  fgESDpid->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+  fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
 }
 
 inline void AliDielectronVarManager::InitAODpidUtil(Int_t type)
 {
-  if (!fgAODpidUtil) fgAODpidUtil=new AliAODpidUtil;
+  if (!fgPIDResponse) fgPIDResponse=new AliAODpidUtil;
   Double_t alephParameters[5];
   // simulation
   alephParameters[0] = 2.15898e+00/50.;
@@ -756,7 +937,7 @@ inline void AliDielectronVarManager::InitAODpidUtil(Int_t type)
   alephParameters[2] = 3.40030e-09;
   alephParameters[3] = 1.96178e+00;
   alephParameters[4] = 3.91720e+00;
-  fgAODpidUtil->GetTOFResponse().SetTimeResolution(80.);
+  fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
   
   // data
   if (type==1){
@@ -765,15 +946,15 @@ inline void AliDielectronVarManager::InitAODpidUtil(Int_t type)
     alephParameters[2] = 5.04114e-11;
     alephParameters[3] = 2.12543e+00;
     alephParameters[4] = 4.88663e+00;
-    fgAODpidUtil->GetTOFResponse().SetTimeResolution(130.);
-    fgAODpidUtil->GetTPCResponse().SetMip(50.);
+    fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
+    fgPIDResponse->GetTPCResponse().SetMip(50.);
   }
   
-  fgAODpidUtil->GetTPCResponse().SetBetheBlochParameters(
+  fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
     alephParameters[0],alephParameters[1],alephParameters[2],
     alephParameters[3],alephParameters[4]);
   
-  fgAODpidUtil->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+  fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
 }
 
 
@@ -784,6 +965,9 @@ inline void AliDielectronVarManager::SetEvent(AliVEvent * const ev)
   if (fgKFVertex) delete fgKFVertex;
   fgKFVertex=0x0;
   if (ev && ev->GetPrimaryVertex()) fgKFVertex=new AliKFVertex(*ev->GetPrimaryVertex());
+
+  for (Int_t i=0; i<AliDielectronVarManager::kNMaxValues;++i) fgData[i]=0.;
+  AliDielectronVarManager::Fill(fgEvent, fgData);
 }
 
 
index 6da6afd..b9d96aa 100644 (file)
@@ -36,6 +36,12 @@ AliAnalysisTask *AddTaskJPSI(Bool_t hasMC_aod = kFALSE){
   eventCuts->SetRequireVertex();
   eventCuts->SetMinVtxContributors(1);
   eventCuts->SetVertexZ(-10.,10.);
+
+  // add event filter
+  task->SetEventFilter(eventCuts);
+
+  // pileup rejection
+  task->SetRejectPileup();
   
   //----------------------
   //create data containers
diff --git a/PWG3/dielectron/macros/AddTaskReadAODBranch.C b/PWG3/dielectron/macros/AddTaskReadAODBranch.C
new file mode 100644 (file)
index 0000000..4f571d4
--- /dev/null
@@ -0,0 +1,34 @@
+AliAnalysisTask *AddTaskReadAODBranch(Double_t ptLegCut = 1., Bool_t spdFirstRequired=kFALSE, Int_t numClsTPC=90, Int_t pairType = 1, Double_t ptJpsi = 1.3){
+  
+  Bool_t hasMC = kFALSE;
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskReadAODBranch", "No analysis manager found.");
+    return NULL;
+  }
+
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskReadAODBranch", "This task requires an input event handler");
+    return NULL;
+  }
+
+ AliAnalysisTaskDielectronReadAODBranch *readAODBranch = new AliAnalysisTaskDielectronReadAODBranch("ReadAODBranch");
+ readAODBranch->SetHasMC(hasMC);
+ readAODBranch->SetPtLeg(ptLegCut);
+ readAODBranch->SetSpdFirstRequired(spdFirstRequired);
+ readAODBranch->SetNclsTPC(numClsTPC); 
+ readAODBranch->SetInvMassSignalRegion(2.3,4.);
+ readAODBranch->SetInvMassSidebandRegion(2.9,3.2);
+ readAODBranch->SetPairType(pairType);
+ readAODBranch->SetPtJpsi(ptJpsi);
+
+ mgr->AddTask(readAODBranch);
+
+ AliAnalysisDataContainer *cOutputHist = mgr->CreateContainer("resultAOD",
+                         TList::Class(), AliAnalysisManager::kOutputContainer,"result.root");
+
+ mgr->ConnectInput(readAODBranch,  0, mgr->GetCommonInputContainer());
+ mgr->ConnectOutput(readAODBranch, 1, cOutputHist);
+
+ return readAODBranch;
+}
index 0e6c5da..1343bf0 100644 (file)
@@ -41,7 +41,8 @@ AliDielectron* ConfigJpsi2ee(Int_t cutDefinition, Bool_t isAOD=kFALSE)
   InitCFDieleData(diele, cutDefinition, isAOD);
 
   AliDielectronTrackRotator *rot=new AliDielectronTrackRotator;
-  rot->SetIterations(4);
+  rot->SetConeAnglePhi(TMath::Pi());
+  rot->SetIterations(10);
   diele->SetTrackRotator(rot);
   return diele;
 }
@@ -76,7 +77,7 @@ void SetupTrackCutsDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t i
   //
   if (isAOD){
     // TPC #clusteres cut
-    pt->AddCut(AliDielectronVarManager::kNclsTPC,60.,160.);
+    pt->AddCut(AliDielectronVarManager::kNclsTPC,70.,160.);
     pt->AddCut(AliDielectronVarManager::kEta,-0.9,0.9);
     //TODO: DCA cuts to be investigated!!!
 //       pt->AddCut(AliDielectronVarManager::kImpactParXY,-1.,1.);
@@ -113,26 +114,28 @@ AliESDtrackCuts *SetupESDtrackCutsDieleData(Int_t cutDefinition)
   // Setup default AliESDtrackCuts
   //
   AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts;
-  
+
   // basic track quality cuts  (basicQ)
   esdTrackCuts->SetMaxDCAToVertexZ(3.0);
   esdTrackCuts->SetMaxDCAToVertexXY(1.0);
-  
+
   esdTrackCuts->SetEtaRange( -0.9 , 0.9 );
-  
+
   esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
   esdTrackCuts->SetRequireITSRefit(kTRUE);
   esdTrackCuts->SetRequireTPCRefit(kTRUE);
-  
-  esdTrackCuts->SetMinNClustersTPC(60);
+
+  esdTrackCuts->SetPtRange(.8,1e30);
+
+  esdTrackCuts->SetMinNClustersTPC(70);
   esdTrackCuts->SetMaxChi2PerClusterTPC(4);
 
   // default SPD any
   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
-  
+
   if (cutDefinition==0)
     esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
-  
+
   return esdTrackCuts;
 }
 
@@ -213,21 +216,37 @@ void InitCFDieleData(AliDielectron *diele, Int_t cutDefinition, Bool_t isAOD)
   
   //pair variables
   cf->AddVariable(AliDielectronVarManager::kPt,"0.0, 1.0, 2.0, 3.0, 5., 7.0, 10.0, 100.0");
-  
-  cf->AddVariable(AliDielectronVarManager::kY,"-5,-1,-0.9,-0.8,-0.5,-0.3,0.3,0.5,0.8,0.9,1.0,5");
+
+  cf->AddVariable(AliDielectronVarManager::kY,"-5,-1,-0.9,-0.8,-0.7,-0.5,-0.3,0.3,0.5,0.7,0.8,0.9,1.0,5");
   cf->AddVariable(AliDielectronVarManager::kM,125,0.,125*.04); //40Mev Steps
-  cf->AddVariable(AliDielectronVarManager::kPairType,11,0,11);
+  cf->AddVariable(AliDielectronVarManager::kPairType,"-0.5,0.5,1.5,2.5");
+  cf->AddVariable(AliDielectronVarManager::kThetaHE, "-2.0, -1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, 2.0");
+  cf->AddVariable(AliDielectronVarManager::kThetaCS, "-2.0, -1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, 2.0");
   //leg variables
-  cf->AddVariable(AliDielectronVarManager::kPt,"0.0, 0.8, 1.0, 1.2, 100.0",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kNclsTPC,"0, 70, 80, 90, 100, 120, 160",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kNFclsTPCr,"0, 90, 100, 120, 140, 150, 160",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kNFclsTPCrFrac,"0, .5, .7, .8, .9, .95, 1",kTRUE);
-  cf->AddVariable(AliDielectronVarManager::kEta,"-5,-1,-0.9,-0.8,-0.5,0.5,0.8,0.9,1.0,5",kTRUE);
-  
+  cf->AddVariable(AliDielectronVarManager::kPt,"0.0, 0.8, 0.9, 0.95, 1.0, 1.05, 1.1, 1.2, 100.0",kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kNclsTPC,"0, 70, 75, 80, 85, 90, 100, 120, 160",kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kEta,"-5,-1,-0.9,-0.85,-0.8,-0.75,0.75,0.8,0.85,0.9,1.0,5",kTRUE);
+
 //   cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,"-2.5,-2,-1.5,-1,-0.5,4.",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPio,"3.,3.5,4.,100",kTRUE);
   cf->AddVariable(AliDielectronVarManager::kTPCnSigmaPro,"3.,3.5,4.,100",kTRUE);
-  
+
+  //event variables
+  cf->AddVariable(AliDielectronVarManager::kNaccTrcklts,"0.0, 9.0, 17.0, 25.0, 36.0, 55.0, 500.0");
+
+  if (!isAOD){
+    Bool_t hasMC=(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0);
+    if (hasMC){
+      cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE);
+      cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE);
+      cf->AddVariable(AliDielectronVarManager::kPdgCodeGrandMother,10000,-5000.5,4999.5,kTRUE);
+    }
+  }
+    //only in this case write MC truth info
+  if (cutDefinition==0){
+    cf->SetStepForMCtruth();
+  }
+
   diele->SetCFManagerPair(cf);
   
 }
index 19d992c..180c1e7 100644 (file)
@@ -41,39 +41,45 @@ enum Variables {    // create an enumeration item for every variable from your C
   kNothing = -1,    // kNothing should be always here
   kPt = 0,
   kY,
-  kPairType,
   kThetaCS,
   kThetaHE,
   kM,
+  kPairType,
+  //  kPhi,
+  kLeg1_Pt,
+  kLeg1_NclsTPC,
   kLeg1_Eta,
+  //kLeg1_Phi,
   //  kLeg1_TPC_nSigma_Electrons,
-  kLeg1_Pt,
   //  kLeg1_P,
-  kLeg1_NclsTPC,
-  kLeg2_Eta,
+  //kLeg2_Phi,
   //  kLeg2_TPC_nSigma_Electrons,
   kLeg2_Pt,
   //  kLeg2_P,
   kLeg2_NclsTPC,
+  kLeg2_Eta,
   kNVariables       // kNVariables should be always here!
 };
 const Char_t* gkVarNames[kNVariables] = {     // variable names to be put on histograms axes and titles
   "p_{T} [GeV/c]",
   "y",
-  "Pair type (0=++; 1=+-; 2=--)",
   "cos #theta^{*}_{CS}",
   "cos #theta^{*}_{HE}",
   "M [GeV/c^{2}]",
-  "#eta^{leg1}",
+  "Pair type (0=++; 1=+-; 2=--)",
+  // "#phi(J/#Psi) [rad.]",
+  //"#phi^{leg1}",
   //  "TPC n #sigma electrons (leg1)",
   "p_{T}^{leg1} [GeV/c]",
   //  "P^{leg1} [GeV/c]",
   "# TPC clusters (leg1)",
-  "#eta^{leg2}",
+  "#eta^{leg1}",
+  //"#phi^{leg2}",
   //  "TPC n #sigma electrons (leg2)",
   "p_{T}^{leg2} [GeV/c]",
   //  "P^{leg2} [GeV/c]",
   "# TPC clusters (leg2)"
+  "#eta^{leg2}",
 };
 Int_t gNbins[kNVariables];           // number of bins for every variable --> filled automatically
 Double_t* gBinLimits[kNVariables];   // bin limits for every variable --> filled automatically
@@ -84,78 +90,91 @@ enum Steps {        // step indexes in the CF containers to be analyzed
   kPureMC = 0,
   kESDSPDany = 2,
   kESDSPDfirst = 4,
-  kFullSPDany = 6,
-  kFullSPDfirst = 8,
-  kNSteps = 5        // total number of steps (the number of steps above)
+  kESDv0SPDany = 6,
+  kESDv0SPDfirst = 8,
+  kFullSPDany = 10,
+  kFullSPDfirst = 12,
+  kNSteps = 7        // total number of steps (the number of steps above)
 };
 const Int_t gkStepNumbers[kNSteps] = {   // array with step indexes (all from the enumeration above)
   kPureMC, 
   kESDSPDany, kESDSPDfirst,
+  kESDv0SPDany, kESDv0SPDfirst,
   kFullSPDany, kFullSPDfirst
 };
 const Char_t* gkStepNames[kNSteps][2] = {// names for each CF step
   {"PureMC",         "Pure MC"},         // NOTE: short names go to histo names, long names go to titles
-  {"ESDSPDany",      "ESD track cuts, SPD any, TPCnclus>90"}, 
-  {"ESDSPDfirst",    "ESD track cuts, SPD first, TPCnclus>90"},
+  {"ESDSPDany",      "ESD track cuts, SPD any"}, 
+  {"ESDSPDfirst",    "ESD track cuts, SPD first"},
+  {"ESDv0SPDany",    "ESD track cuts, conv. cuts, SPD any"}, 
+  {"ESDv0SPDfirst",  "ESD track cuts, conv. cuts, SPD first"},
   {"FullSPDany",     "All track cuts (with SPD any) and TPC-PID"},
   {"FullSPDfirst",   "All track cuts (with SPD first) and TPC-PID"}
 };
 //------------------------------------------------------------------------
 
 // Put here info about the cut sets for which projections will be made ---
-const Int_t gkNCutSets = 18;     // number of cut sets for which histos will be filled
+const Int_t gkNCutSets = 10*3;     // number of cut sets for which histos will be filled
 const Char_t* gkCutSetNames[gkNCutSets][2] = {   // short and long names for all the cut sets
   // baseline
-  {"Ycut",                 "|y_{J/#Psi}|<0.88"},
-  {"YcutPt1",              "|y_{J/#Psi}|<0.88 & 0.0<p_{T J/#Psi}<0.8"},
-  {"YcutPt2",              "|y_{J/#Psi}|<0.88 & 0.8<p_{T J/#Psi}<1.4"},
-  {"YcutPt3",              "|y_{J/#Psi}|<0.88 & 1.4<p_{T J/#Psi}<2.8"},
-  {"YcutPt4",              "|y_{J/#Psi}|<0.88 & 2.8<p_{T J/#Psi}<5.0"},
-  {"YcutPt5",              "|y_{J/#Psi}|<0.88 & 5.0<p_{T J/#Psi}<10.0"},
-  // pure kinematic acceptance
-  {"YcutLegsEtaPt1",       "|y_{J/#Psi}|<0.88 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  {"YcutPt1LegsEtaPt1",    "|y_{J/#Psi}|<0.88 & 0.0<p_{T J/#Psi}<0.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  {"YcutPt2LegsEtaPt1",    "|y_{J/#Psi}|<0.88 & 0.8<p_{T J/#Psi}<1.4 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  {"YcutPt3LegsEtaPt1",    "|y_{J/#Psi}|<0.88 & 1.4<p_{T J/#Psi}<2.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  {"YcutPt4LegsEtaPt1",    "|y_{J/#Psi}|<0.88 & 2.8<p_{T J/#Psi}<5.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  {"YcutPt5LegsEtaPt1",    "|y_{J/#Psi}|<0.88 & 5.0<p_{T J/#Psi}<10.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c"},
-  // track quality
-  {"YcutLegsEtaPt1TPC90",     "|y_{J/#Psi}|<0.88 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"},
-  {"YcutPt1LegsEtaPt1TPC90",  "|y_{J/#Psi}|<0.88 & 0.0<p_{T J/#Psi}<0.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"},
-  {"YcutPt2LegsEtaPt1TPC90",  "|y_{J/#Psi}|<0.88 & 0.8<p_{T J/#Psi}<1.4 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"},
-  {"YcutPt3LegsEtaPt1TPC90",  "|y_{J/#Psi}|<0.88 & 1.4<p_{T J/#Psi}<2.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"},
-  {"YcutPt4LegsEtaPt1TPC90",  "|y_{J/#Psi}|<0.88 & 2.8<p_{T J/#Psi}<5.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"},
-  {"YcutPt5LegsEtaPt1TPC90",  "|y_{J/#Psi}|<0.88 & 5.0<p_{T J/#Psi}<10.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90"}
-  // track quality + PID
-  //  {"YcutLegsEtaPt1TPC90PID",     "|y_{J/#Psi}|<0.88 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"},
-  //  {"YcutPt1LegsEtaPt1TPC90PID",  "|y_{J/#Psi}|<0.88 & 0.0<p_{T J/#Psi}<0.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"},
-  //  {"YcutPt2LegsEtaPt1TPC90PID",  "|y_{J/#Psi}|<0.88 & 0.8<p_{T J/#Psi}<1.4 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"},
-  //  {"YcutPt3LegsEtaPt1TPC90PID",  "|y_{J/#Psi}|<0.88 & 1.4<p_{T J/#Psi}<2.8 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"},
-  //  {"YcutPt4LegsEtaPt1TPC90PID",  "|y_{J/#Psi}|<0.88 & 2.8<p_{T J/#Psi}<5.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"},
-  //  {"YcutPt5LegsEtaPt1TPC90PID",  "|y_{J/#Psi}|<0.88 & 5.0<p_{T J/#Psi}<10.0 & |#eta_{legs}|<0.88 & p_{Tlegs}>1.0 GeV/c TPCnclus>90  & TPC pid"}
+  {"Ycut",                 "|y_{J/#Psi}|<0.9 & 0<pt_{J/#Psi}<10.0"},
+  {"Ycut1",                "|y_{J/#Psi}|<0.3 & 0<pt_{J/#Psi}<10.0"},
+  {"Ycut2",                "0.3<y_{J/#Psi}<0.9 & 0<pt_{J/#Psi}<10.0"},
+  {"Ycut3",                "-0.9<y_{J/#Psi}<-0.3 & 0<pt_{J/#Psi}<10.0"},
+  {"YcutPt1",              "|y_{J/#Psi}|<0.9 & 0.0<p_{T J/#Psi}<1.0"},
+  {"YcutPt2",              "|y_{J/#Psi}|<0.9 & 1.0<p_{T J/#Psi}<2.0"},
+  {"YcutPt3",              "|y_{J/#Psi}|<0.9 & 2.0<p_{T J/#Psi}<3.0"},
+  {"YcutPt4",              "|y_{J/#Psi}|<0.9 & 3.0<p_{T J/#Psi}<5.0"},
+  {"YcutPt5",              "|y_{J/#Psi}|<0.9 & 5.0<p_{T J/#Psi}<7.0"},
+  {"YcutPt6",              "|y_{J/#Psi}|<0.9 & 7.0<p_{T J/#Psi}<10.0"},
+  // track cuts
+  {"YcutLegsFull",       "|y_{J/#Psi}|<0.9 & 0<pt_{J/#Psi}<10.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut1LegsFull",      "|y_{J/#Psi}|<0.3 & 0<pt_{J/#Psi}<10.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut2LegsFull",      "0.3<y_{J/#Psi}<0.9 & 0<pt_{J/#Psi}<10.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut3LegsFull",      "-0.9<y_{J/#Psi}<-0.3 & 0<pt_{J/#Psi}<10.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt1LegsFull",    "|y_{J/#Psi}|<0.9 & 0<pt_{J/#Psi}<1.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt2LegsFull",    "|y_{J/#Psi}|<0.9 & 1.0<pt_{J/#Psi}<2.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt3LegsFull",    "|y_{J/#Psi}|<0.9 & 2.0<pt_{J/#Psi}<3.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt4LegsFull",    "|y_{J/#Psi}|<0.9 & 3.0<pt_{J/#Psi}<5.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt5LegsFull",    "|y_{J/#Psi}|<0.9 & 5.0<pt_{J/#Psi}<7.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt6LegsFull",    "|y_{J/#Psi}|<0.9 & 7.0<pt_{J/#Psi}<10.0 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  // track cuts + cut on signal integration range
+  {"YcutMcutLegsFull",       "|y_{J/#Psi}|<0.9 & 0<pt_{J/#Psi}<10.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut1McutLegsFull",      "|y_{J/#Psi}|<0.3 & 0<pt_{J/#Psi}<10.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut2McutLegsFull",      "0.3<y_{J/#Psi}<0.9 & 0<pt_{J/#Psi}<10.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"Ycut3McutLegsFull",      "-0.9<y_{J/#Psi}<-0.3 & 0<pt_{J/#Psi}<10.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt1McutLegsFull",    "|y_{J/#Psi}|<0.9 & 0<pt_{J/#Psi}<1.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt2McutLegsFull",    "|y_{J/#Psi}|<0.9 & 1.0<pt_{J/#Psi}<2.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt3McutLegsFull",    "|y_{J/#Psi}|<0.9 & 2.0<pt_{J/#Psi}<3.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt4McutLegsFull",    "|y_{J/#Psi}|<0.9 & 3.0<pt_{J/#Psi}<5.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt5McutLegsFull",    "|y_{J/#Psi}|<0.9 & 5.0<pt_{J/#Psi}<7.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"},
+  {"YcutPt6McutLegsFull",    "|y_{J/#Psi}|<0.9 & 7.0<pt_{J/#Psi}<10.0 & 2.92<M_{inv}<3.16 & |#eta_{legs}|<0.9 & p_{Tlegs}>1.0 GeV/c & Ncls_TPC>70"}
+  
 };
 // -----------------------------------------------------------------------
 
 // Put here info about the histograms to be filled -----------------------
-const Int_t gkNhistos = 6;                        // how many histograms for every (step,cut set) combination
+const Int_t gkNhistos = 3;                        // how many histograms for every (step,cut set) combination
 const Char_t* gkHistoNames[gkNhistos][2] = {      // short and long names of the histograms
   {"pt","p_{T}(J/#Psi)"},                         // NOTE: short names go to the histo name, long name goes to title
-  {"y","y(J/#Psi)"}, 
-  {"pty","p_{T} vs y(J/#Psi)"}, 
-  //  {"m","e^{+}e^{-} invariant mass"}, 
+  //  {"y","y(J/#Psi)"}, 
+  // {"pty","p_{T} vs y(J/#Psi)"},
+  //  {"phi","#phi(J/#Psi) [rad.]"}, 
+  //{"m","e^{+}e^{-} invariant mass"}, 
   {"ThetaCS","cos #theta^{*}_{CS}"}, 
-  {"ThetaHE","cos #theta^{*}_{HE}"},
-  {"Minv", "Invariant mass"}
+  {"ThetaHE","cos #theta^{*}_{HE}"}
+  // {"Minv", "Invariant mass"}
 };
 const Int_t gkDims[gkNhistos][4] = {      // dimensions and variables for histograms
 // ndim  xVar      yVar      zVar
   {1,    kPt,      kNothing, kNothing},   // pt dependence
-  {1,    kY,       kNothing, kNothing},   // y dependence
-  {2,    kY,       kPt,      kNothing},   // pt,y dependence
+  //  {1,    kY,       kNothing, kNothing},   // y dependence
+  //  {2,    kY,       kPt,      kNothing},   // pt,y dependence
+  //  {1,    kPhi,     kNothing, kNothing},   // phi dependence
   //  {1,    kM,       kNothing, kNothing