adding first version of Taku's task
authorcbaumann <cbaumann@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 25 Jun 2012 15:25:02 +0000 (15:25 +0000)
committercbaumann <cbaumann@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 25 Jun 2012 15:25:02 +0000 (15:25 +0000)
PWGDQ/CMakelibPWGDQdielectron.pkg
PWGDQ/PWGDQdielectronLinkDef.h
PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.cxx [new file with mode: 0644]
PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.h [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/AddTask_taku_LMEEPbPb2011.C [new file with mode: 0644]
PWGDQ/dielectron/macrosLMEE/ConfigTakuLMEEPbPb2011.C [new file with mode: 0644]

index c8f04e2..f85ccc2 100644 (file)
@@ -39,6 +39,7 @@ set ( SRCS
       dielectron/AliAnalysisTaskDielectronFilter.cxx
       dielectron/AliAnalysisTaskDielectronEfficiency.cxx
       dielectron/AliAnalysisTaskMultiDielectron.cxx
+      dielectron/AliAnalysisTaskMultiDielectronTG.cxx
       dielectron/AliAnalysisTaskDielectronReadAODBranch.cxx
       dielectron/AliAnalysisTaskSingleParticle.cxx
       dielectron/AliDielectronVarCuts.cxx
index 6c74f06..0edd255 100644 (file)
@@ -18,6 +18,8 @@
 #pragma link C++ class AliAnalysisTaskDielectronFilter+;
 #pragma link C++ class AliAnalysisTaskDielectronEfficiency+;
 #pragma link C++ class AliAnalysisTaskMultiDielectron+;
+#pragma link C++ class AliDielectronSingleTG+;
+#pragma link C++ class AliAnalysisTaskMultiDielectronTG+;
 #pragma link C++ class AliAnalysisTaskDielectronReadAODBranch+;
 #pragma link C++ class AliAnalysisTaskSingleParticle+;
 #pragma link C++ class AliDielectronVarCuts+;
diff --git a/PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.cxx b/PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.cxx
new file mode 100644 (file)
index 0000000..ccc6184
--- /dev/null
@@ -0,0 +1,1052 @@
+/*************************************************************************
+* 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.                  *
+**************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+//                        Basic Analysis Task                            //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include <TChain.h>
+#include <TH1D.h>
+
+#include <AliCFContainer.h>
+#include <AliInputEventHandler.h>
+#include <AliESDInputHandler.h>
+#include <AliAODInputHandler.h>
+#include <AliAnalysisManager.h>
+#include <AliVEvent.h>
+#include <AliTriggerAnalysis.h>
+#include <AliPIDResponse.h>
+#include <AliTPCPIDResponse.h>
+
+#include "AliDielectron.h"
+#include "AliDielectronHistos.h"
+#include "AliDielectronCF.h"
+#include "AliDielectronMC.h"
+#include "AliDielectronMixingHandler.h"
+#include "AliAnalysisTaskMultiDielectronTG.h"
+
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+
+#include "AliLog.h"
+
+#include <vector>
+#include <deque>
+#include <cstdlib> 
+#include <TRandom.h>
+
+const char* fgkPairClassNamesTG[7] = {
+  "unlike",
+  "like_pp",
+  "like_ee",
+  "mixunlike_pe",
+  "mixunlike_ep",
+  "mixlike_pp",
+  "mixlike_ee"
+};
+
+
+ClassImp(AliDielectronSingleTG)
+ClassImp(AliAnalysisTaskMultiDielectronTG)
+
+//_________________________________________________________________________________
+AliAnalysisTaskMultiDielectronTG::AliAnalysisTaskMultiDielectronTG() :
+  AliAnalysisTaskSE(),
+  fListDielectron(),
+  fListHistos(),
+  fListCF(),
+  tQAElectron(),
+  fSelectPhysics(kFALSE),
+  fTriggerMask(AliVEvent::kMB),
+  fExcludeTriggerMask(0),
+  fTriggerOnV0AND(kFALSE),
+  fRejectPileup(kFALSE),
+  fTriggerLogic(kAny),
+  fTriggerAnalysis(0x0),
+  fEventFilter(0x0),
+  fCutsMother(0x0),   
+  fEventStat(0x0),
+  fEvent(0x0),
+  fdEdXvsPt(0x0),
+  fdEdXnSigmaElecvsPt(0x0),
+  fdEdXvsPtTOF(0x0),
+  fdEdXnSigmaElecvsPtTOF(0x0),
+  fTOFbetavsPt(0x0),
+  fTOFnSigmaElecvsPt(0x0),
+  hNCrossedRowsTPC(0x0),
+  hChi2ClusTPC(0x0),
+  hRatioCrossClusTPC(0x0),
+  vem(0x0),
+  vep(0x0),
+  vem_tmp(0x0),
+  vep_tmp(0x0),
+  d_conv_phiv(acos(-1.0)),
+  bz(0),
+  d_v0_mixing(kTRUE)
+{
+  //
+  // Constructor
+  //
+}
+
+//_________________________________________________________________________________
+AliAnalysisTaskMultiDielectronTG::AliAnalysisTaskMultiDielectronTG(const char *name) :
+  AliAnalysisTaskSE(name),
+  fListDielectron(),
+  fListHistos(),
+  fListCF(),
+  tQAElectron(),
+  fSelectPhysics(kFALSE),
+  fTriggerMask(AliVEvent::kMB),
+  fExcludeTriggerMask(0),
+  fTriggerOnV0AND(kFALSE),
+  fRejectPileup(kFALSE),
+  fTriggerLogic(kAny),
+  fTriggerAnalysis(0x0),
+  fEventFilter(0x0),
+  fCutsMother(0x0),   
+  fEventStat(0x0),
+  fEvent(0x0),
+  fdEdXvsPt(0x0),
+  fdEdXnSigmaElecvsPt(0x0),
+  fdEdXvsPtTOF(0x0),
+  fdEdXnSigmaElecvsPtTOF(0x0),
+  fTOFbetavsPt(0x0),
+  fTOFnSigmaElecvsPt(0x0),
+  hNCrossedRowsTPC(0x0),
+  hChi2ClusTPC(0x0),
+  hRatioCrossClusTPC(0x0),
+  vem(0x0),
+  vep(0x0),
+  vem_tmp(0x0),
+  vep_tmp(0x0),
+  d_conv_phiv(acos(-1.0)),
+  bz(0),
+  d_v0_mixing(kTRUE)
+{
+  //
+  // Constructor
+  //
+  DefineInput(0,TChain::Class());
+  DefineOutput(1, TList::Class());
+  DefineOutput(2, TList::Class());
+  DefineOutput(3, TH1D::Class());
+  fListHistos.SetName("Dielectron_Histos_Multi");
+  fListCF.SetName("Dielectron_CF_Multi");
+  fListDielectron.SetOwner();
+  fListHistos.SetOwner();
+  fListCF.SetOwner();
+
+  ///////////////
+  for(int i=0;i<NDIE; i++){
+    for(int j=0;j<NZBIN;j++){
+      for(int k=0;k<NCENT;k++){
+       for(int l=0; l<NRPBIN; l++){
+         d_ibuf[i][j][k][l] = 0;
+         d_poolp[i][j][k][l].clear();
+         d_poolm[i][j][k][l].clear();
+         for(int ib=0;ib<NBUF; ib++){
+           d_vep[ib][i][j][k][l].clear();
+           d_vem[ib][i][j][k][l].clear();
+         }
+       }
+      }
+    }
+  }
+
+
+
+}
+
+//_________________________________________________________________________________
+AliAnalysisTaskMultiDielectronTG::~AliAnalysisTaskMultiDielectronTG()
+{
+  //
+  // Destructor
+  //
+
+  //histograms and CF are owned by the dielectron framework.
+  //however they are streamed to file, so in the first place the
+  //lists need to be owner...
+  fListHistos.SetOwner(kFALSE);
+  fListCF.SetOwner(kFALSE);
+  
+  for(int i=0;i<NDIE; i++){
+    for(int j=0;j<NZBIN;j++){
+      for(int k=0;k<NCENT;k++){
+       for(int l=0; l<NRPBIN; l++){
+         d_ibuf[i][j][k][l] = 0;
+         d_poolp[i][j][k][l].clear();
+         d_poolm[i][j][k][l].clear();
+         for(int ib=0;ib<NBUF; ib++){
+           d_vep[ib][i][j][k][l].clear();
+           d_vem[ib][i][j][k][l].clear();
+         }
+       }
+      }
+    }
+  }
+}
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::UserCreateOutputObjects()
+{
+  //
+  // Add all histogram manager histogram lists to the output TList
+  //
+
+  if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised
+
+//   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+//   Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class();
+//   Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
+  
+  TIter nextDie(&fListDielectron);
+  AliDielectron *die=0;
+  while ( (die=static_cast<AliDielectron*>(nextDie())) ){
+    die->Init();
+    if (die->GetHistogramList()) fListHistos.Add(const_cast<THashList*>(die->GetHistogramList()));
+    if (die->GetCFManagerPair()) fListCF.Add(const_cast<AliCFContainer*>(die->GetCFManagerPair()->GetContainer()));
+  }
+
+  Int_t cuts=fListDielectron.GetEntries();
+  Int_t nbins=kNbinsEvent+2*cuts;
+  if (!fEventStat){
+    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) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers");
+    if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter");
+    if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection");
+    
+    for (Int_t i=0; i<cuts; ++i){
+      fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+1)+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName()));
+      fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+2)+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName()));
+    }
+  }
+
+  if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
+  fTriggerAnalysis->EnableHistograms();
+  fTriggerAnalysis->SetAnalyzeMC(AliDielectronMC::Instance()->HasMC());
+  
+
+  
+  int nbinx=400;
+  float max_x=20;
+  float min_x=0.2;
+  float binw = (TMath::Log(max_x)-TMath::Log(min_x))/nbinx;
+  double xbin[401];
+  for(int ii=0;ii<nbinx+1;ii++){
+    xbin[ii] = TMath::Exp(TMath::Log(min_x) + 0.5*binw+binw*ii);
+  }
+
+  
+  tQAElectron = new TList();
+  tQAElectron->SetName("QAElectron");
+  tQAElectron->SetOwner();
+
+
+  fEvent = new TH1D("Event","centrality",   100,0,100);
+  tQAElectron->Add(fEvent);
+  fdEdXvsPt = new TH2D("dEdXvsPt","dE/dX vs. PT of TPC", nbinx, xbin, 2000,0,200);
+  tQAElectron->Add(fdEdXvsPt);
+  fdEdXnSigmaElecvsPt = new TH2D("fdEdXnSigmaElecvsPt"," dE/dX normalized to electron vs. pT of TPC",
+                                 nbinx, xbin, 2000, -10, 10);
+  tQAElectron->Add(fdEdXnSigmaElecvsPt);
+
+  fdEdXvsPtTOF = new TH2D("dEdXvsPtTOF","dE/dX vs. PT of TPC", nbinx, xbin, 2000,0,200);
+  tQAElectron->Add(fdEdXvsPtTOF);
+  fdEdXnSigmaElecvsPtTOF = new TH2D("fdEdXnSigmaElecvsPtTOF"," dE/dX normalized to electron vs. pT of TPC",
+                                 nbinx, xbin, 2000, -10, 10);
+  tQAElectron->Add(fdEdXnSigmaElecvsPtTOF);
+
+
+
+  fTOFbetavsPt = new TH2D("fTOFbetavsPt","TOF beta vs. p", 400, 0, 20, 1200, 0, 1.2);
+  tQAElectron->Add(fTOFbetavsPt);
+  fTOFnSigmaElecvsPt = new TH2D("fTOFnSigmaElecvsPt","TOF nsigma for electron", 400, 0, 20, 2000, -10, 10);
+  tQAElectron->Add(fTOFnSigmaElecvsPt);
+
+  hNCrossedRowsTPC = new TH2F("hNCrossedRowsTPC", "TPC nCrossed Rows vs. pT", 200, 0, 20, 200, 0, 200);
+  tQAElectron->Add(hNCrossedRowsTPC);
+  hChi2ClusTPC = new TH2F("hChi2ClusTPC", "hChi2ClusTPC vs. pT", 200, 0, 20, 200, 0, 10);
+  tQAElectron->Add(hChi2ClusTPC);
+  
+  hRatioCrossClusTPC = new TH2F("hRatioCrossClusTPC", "hRatioCrossClusTPC vs. pT", 200, 0, 20, 200, 0, 10);     
+  tQAElectron->Add(hRatioCrossClusTPC);
+
+  fListHistos.Add(tQAElectron);
+
+  fListHistos.SetOwner();  
+  
+  PostData(1, &fListHistos);
+  PostData(2, &fListCF);
+  PostData(3, fEventStat);
+
+  fCutsMother = new AliESDtrackCuts;
+  fCutsMother->SetDCAToVertex2D(kTRUE);
+  fCutsMother->SetMaxDCAToVertexZ(3.0);
+  fCutsMother->SetMaxDCAToVertexXY(1.0);
+  fCutsMother->SetPtRange(  0.05 , 200.0);
+  fCutsMother->SetEtaRange( -0.84 , 0.84 );
+  fCutsMother->SetAcceptKinkDaughters(kFALSE);
+  fCutsMother->SetRequireITSRefit(kTRUE);
+  fCutsMother->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kFirst);
+  fCutsMother->SetMinNClustersITS(3);
+  fCutsMother->SetRequireTPCRefit(kTRUE);
+
+
+}
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::UserExec(Option_t *)
+{
+  //
+  // Main loop. Called for every event
+  //
+
+  if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return;
+
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class();
+  Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
+  
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if (!inputHandler) return;
+  
+//   AliPIDResponse *pidRes=inputHandler->GetPIDResponse();
+  if ( inputHandler->GetPIDResponse() ){
+    // for the 2.76 pass2 MC private train. Together with a sigma shift of -0.169
+//    pidRes->GetTPCResponse().SetSigma(4.637e-3,2.41332105409873257e+04);
+    AliDielectronVarManager::SetPIDResponse( inputHandler->GetPIDResponse() );
+  } else {
+    AliFatal("This task needs the PID response attached to the input event handler!");
+  }
+  
+  // Was event selected ?
+  ULong64_t isSelected = AliVEvent::kAny;
+  Bool_t isRejected = kFALSE;
+  if( fSelectPhysics && inputHandler){
+    if((isESD && inputHandler->GetEventSelection()) || isAOD){
+      isSelected = inputHandler->IsEventSelected();
+      if (fExcludeTriggerMask && (isSelected&fExcludeTriggerMask)) isRejected=kTRUE;
+      if (fTriggerLogic==kAny) isSelected&=fTriggerMask;
+      else if (fTriggerLogic==kExact) isSelected=((isSelected&fTriggerMask)==fTriggerMask);
+    }
+   }
+  //Before physics selection
+  fEventStat->Fill(kAllEvents);
+  if (isSelected==0||isRejected) {
+    PostData(3,fEventStat);
+    return;
+  }
+  //after physics selection
+  fEventStat->Fill(kSelectedEvents);
+
+  //V0and
+  if(fTriggerOnV0AND){
+  if(isESD){if (!fTriggerAnalysis->IsOfflineTriggerFired(static_cast<AliESDEvent*>(InputEvent()), AliTriggerAnalysis::kV0AND))
+            return;}
+  if(isAOD){if(!((static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0ADecision() == AliVVZERO::kV0BB &&
+            (static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0CDecision() == AliVVZERO::kV0BB) )
+            return;}
+   }
+  
+
+  fEventStat->Fill(kV0andEvents);
+
+  //Fill Event histograms before the event filter
+  TIter nextDie(&fListDielectron);
+  AliDielectron *die=0;
+  Double_t values[AliDielectronVarManager::kNMaxValues]={0};
+  Double_t valuesMC[AliDielectronVarManager::kNMaxValues]={0};
+  AliDielectronVarManager::SetEvent(InputEvent());
+  AliDielectronVarManager::Fill(InputEvent(),values);
+  AliDielectronVarManager::Fill(InputEvent(),valuesMC);
+  Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
+  if (hasMC) {
+    if (AliDielectronMC::Instance()->ConnectMCEvent())
+      AliDielectronVarManager::Fill(AliDielectronMC::Instance()->GetMCEvent(),valuesMC);
+  }
+
+  while ( (die=static_cast<AliDielectron*>(nextDie())) ){
+    AliDielectronHistos *h=die->GetHistoManager();
+    if (h){
+      if (h->GetHistogramList()->FindObject("Event_noCuts"))
+        h->FillClass("Event_noCuts",AliDielectronVarManager::kNMaxValues,values);
+      if (hasMC && h->GetHistogramList()->FindObject("MCEvent_noCuts"))
+        h->FillClass("Event_noCuts",AliDielectronVarManager::kNMaxValues,valuesMC);
+    }
+  }
+  nextDie.Reset();
+  
+  //event filter
+  if (fEventFilter) {
+    if (!fEventFilter->IsSelected(InputEvent())) return;
+  }
+  fEventStat->Fill(kFilteredEvents);
+  
+  //pileup
+  if (fRejectPileup){
+    if (InputEvent()->IsPileupFromSPD(3,0.8,3.,2.,5.)) return;
+  }
+  fEventStat->Fill(kPileupEvents);
+  
+  //bz for AliKF
+  bz = InputEvent()->GetMagneticField();
+  AliKFParticle::SetField( bz );
+
+  AliDielectronPID::SetCorrVal((Double_t)InputEvent()->GetRunNumber());
+  
+  //Process event in all AliDielectron instances
+  //   TIter nextDie(&fListDielectron);
+  //   AliDielectron *die=0;
+  Int_t idie=0;
+  while ( (die=static_cast<AliDielectron*>(nextDie())) ){
+    //AliInfo(" **************** die->Process(InputEvent()) **************************");
+    die->SetDontClearArrays(kTRUE);
+    die->Process(InputEvent());
+    if (die->HasCandidates()){
+      Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast();
+      if (ncandidates==1) fEventStat->Fill((kNbinsEvent)+2*idie);
+      else if (ncandidates>1) fEventStat->Fill((kNbinsEvent+1)+2*idie);
+    }
+
+
+    AliDielectronVarManager::Fill(InputEvent(), fgValues);
+    for (Int_t ii=0; ii<2; ++ii){ 
+      TObjArray *obj = (TObjArray*)die->GetTrackArray(ii);
+      Int_t ntracks=obj->GetEntriesFast();
+      //AliInfo(Form(" ************** # of tracks = %d", ntracks));
+      for (Int_t itrack=0; itrack<ntracks; ++itrack){
+       
+       ////////////////////////////////////////////////////////////////////
+       AliDielectronVarManager::Fill(obj->UncheckedAt(itrack), fgValues);
+        ////////////////////////////////////////////////////////////////////
+
+       if(fgValues[AliDielectronVarManager::kCharge]>0){
+         vep_tmp.push_back(new  AliDielectronSingleTG(1, 
+                                                      fgValues[AliDielectronVarManager::kCentrality],
+                                                      fgValues[AliDielectronVarManager::kXv],
+                                                      fgValues[AliDielectronVarManager::kYv],
+                                                      fgValues[AliDielectronVarManager::kZv],
+                                                      fgValues[AliDielectronVarManager::kPx],
+                                                      fgValues[AliDielectronVarManager::kPy],
+                                                      fgValues[AliDielectronVarManager::kPz],
+                                                      fgValues[AliDielectronVarManager::kPt],
+                                                      fgValues[AliDielectronVarManager::kEta],
+                                                      fgValues[AliDielectronVarManager::kPhi],
+                                                      fgValues[AliDielectronVarManager::kTheta],
+                                                      1, 1, static_cast<AliVTrack*>(obj->UncheckedAt(itrack)))
+                           );
+       }else if(fgValues[AliDielectronVarManager::kCharge]<0){
+         vem_tmp.push_back(new  AliDielectronSingleTG(-1, 
+                                                      fgValues[AliDielectronVarManager::kCentrality],
+                                                      fgValues[AliDielectronVarManager::kXv],
+                                                      fgValues[AliDielectronVarManager::kYv],
+                                                      fgValues[AliDielectronVarManager::kZv],
+                                                      fgValues[AliDielectronVarManager::kPx],
+                                                      fgValues[AliDielectronVarManager::kPy],
+                                                      fgValues[AliDielectronVarManager::kPz],
+                                                      fgValues[AliDielectronVarManager::kPt],
+                                                      fgValues[AliDielectronVarManager::kEta],
+                                                      fgValues[AliDielectronVarManager::kPhi],
+                                                      fgValues[AliDielectronVarManager::kTheta],
+                                                      1, 1, static_cast<AliVTrack*>(obj->UncheckedAt(itrack)))
+                           );
+       }
+      }
+    }
+    //AliInfo(Form("size of e and p = %d %d", (int)vep_tmp.size(), (int)vem_tmp.size()));
+
+
+    check_ghost_pairs(vep_tmp);
+    check_ghost_pairs(vem_tmp);
+    randomize_pool(vep_tmp, vem_tmp);    
+    calc_pair(vep, vem, die, idie);
+
+    //    AliInfo(Form("size of e and p (after) = %d %d", (int)vep.size(), (int)vem.size()));
+
+    double dw_cent = 100.0/NCENT;
+    double dw_iz = 20.0/NZBIN;
+    double dw_rp = acos(-1.0)/NRPBIN;
+
+    int icent = (int)(fgValues[AliDielectronVarManager::kCentrality]/dw_cent);
+    int izbin = (int)((fgValues[AliDielectronVarManager::kZvPrim]+10)/dw_iz);
+    int irp = (int)((fgValues[AliDielectronVarManager::kV0ACrpH2])/dw_rp);
+    
+    if(icent<0) icent=0;
+    if(icent>=NCENT) icent=NCENT-1;
+    if(izbin<0) izbin=0;
+    if(izbin>=NZBIN) izbin=NZBIN-1;
+    if(irp<0) irp=0;
+    if(irp>=NRPBIN) irp=NRPBIN-1;
+    
+    d_vep[d_ibuf[idie][izbin][icent][irp]][idie][izbin][icent][irp].clear();
+    for(int iep = 0; iep<(int)vep.size();iep++) {
+      d_vep[d_ibuf[idie][izbin][icent][irp]][idie][izbin][icent][irp].push_back(vep[iep]);
+      d_poolp[idie][izbin][icent][irp].push_back(vep[iep]);
+      if(d_poolp[idie][izbin][icent][irp].size()>MAXPOOL) {
+       d_poolp[idie][izbin][icent][irp].pop_front();
+      }
+    }
+    d_vem[d_ibuf[idie][izbin][icent][irp]][idie][izbin][icent][irp].clear();
+    for(int iem = 0; iem<(int)vem.size();iem++) {
+      d_vem[d_ibuf[idie][izbin][icent][irp]][idie][izbin][icent][irp].push_back(vem[iem]);
+      d_poolm[idie][izbin][icent][irp].push_back(vem[iem]);
+      if(d_poolm[idie][izbin][icent][irp].size()>MAXPOOL) {
+       d_poolm[idie][izbin][icent][irp].pop_front();
+      }
+    }
+
+
+    d_ibuf[idie][izbin][icent][irp]++;
+    if(d_ibuf[idie][izbin][icent][irp]>= NBUF) d_ibuf[idie][izbin][icent][irp]=0; 
+
+
+    vep_tmp.clear();
+    vem_tmp.clear();
+    vep.clear();
+    vem.clear();
+
+
+    ++idie;
+  }
+
+
+  AliESDEvent *fESD = dynamic_cast<AliESDEvent*>(InputEvent());
+  fEvent->Fill(values[AliDielectronVarManager::kCentrality]);
+  for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
+    AliESDtrack* track = fESD->GetTrack(iTracks);
+    if (!track) {
+      Printf("ERROR: Could not receive track %d", iTracks);
+      continue;
+    }
+    if(!fCutsMother->AcceptTrack(track)) continue;
+    fdEdXvsPt->Fill(track->GetTPCmomentum(), track->GetTPCsignal());
+    fdEdXnSigmaElecvsPt->Fill(track->GetTPCmomentum(), 
+                              AliDielectronVarManager::GetPIDResponse()->NumberOfSigmasTPC(track,
+                                                                                      AliPID::kElectron)
+                              -AliDielectronPID::GetCorrVal());
+    /// for beta caliculaton 
+    Double_t l = track->GetIntegratedLength();  // cm
+    Double_t t = track->GetTOFsignal();
+    Double_t t0 = AliDielectronVarManager::GetPIDResponse()->GetTOFResponse().GetTimeZero(); // ps
+    Double_t beta = 0;
+    if( (l < 360. || l > 800.) || (t <= 0.) || (t0 >999990.0) ) {
+      beta=-9999;
+    }
+    else {
+      t -= t0; // subtract the T0
+      l *= 0.01;  // cm ->m
+      t *= 1e-12; //ps -> s
+    
+      Double_t v = l / t;
+      beta = v / TMath::C();
+    }
+
+    fTOFbetavsPt->Fill(track->GetTPCmomentum(), beta);
+    fTOFnSigmaElecvsPt->Fill(track->GetTPCmomentum(), 
+                             AliDielectronVarManager::GetPIDResponse()->NumberOfSigmasTOF(track,
+                                                                                     AliPID::kElectron));
+    ////rough PID is required 
+    if( fabs(AliDielectronVarManager::GetPIDResponse()->NumberOfSigmasTOF(track, AliPID::kElectron))<3){
+      fdEdXvsPtTOF->Fill(track->GetTPCmomentum(), track->GetTPCsignal());
+      fdEdXnSigmaElecvsPtTOF->Fill(track->GetTPCmomentum(), 
+                                  AliDielectronVarManager::GetPIDResponse()->NumberOfSigmasTPC(track,
+                                                                                               AliPID::kElectron)
+                                  -AliDielectronPID::GetCorrVal());
+
+      
+      if(track->GetTPCsignal()>70 && track->GetTPCsignal()<90){
+       hNCrossedRowsTPC->Fill(track->GetTPCmomentum(), track->GetTPCCrossedRows());
+       hChi2ClusTPC->Fill(track->GetTPCmomentum(), track->GetTPCchi2()/track->GetTPCNcls());
+       hRatioCrossClusTPC->Fill(track->GetTPCmomentum(), track->GetTPCCrossedRows()/track->GetTPCNclsF());
+      }
+    }
+  }
+  
+  PostData(1, &fListHistos);
+  PostData(2, &fListCF);
+  PostData(3,fEventStat);
+}
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::FinishTaskOutput()
+{
+  //
+  // Write debug tree
+  //
+  TIter nextDie(&fListDielectron);
+  AliDielectron *die=0;
+  while ( (die=static_cast<AliDielectron*>(nextDie())) ){
+    die->SaveDebugTree();
+    AliDielectronMixingHandler *mix=die->GetMixingHandler();
+//    printf("\n\n\n===============\ncall mix in Terminate: %p (%p)\n=================\n\n",mix,die);
+    if (mix) mix->MixRemaining(die);
+  }
+  PostData(1, &fListHistos);
+  PostData(2, &fListCF);
+}
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::check_ghost_pairs(vector<AliDielectronSingleTG*> e1){
+  bool reject = false;
+  if(e1.size()>1){
+    for(int i1=0; i1<(int)e1.size(); i1++){
+      reject = false;
+      for(int i2=i1+1; i2<(int)e1.size(); i2++){
+        if( fabs(e1[i1]->Phi() - e1[i2]->Phi())<0.01 ){
+          reject = true;
+          e1[i2]->SetGstFlag(0);
+        }
+      }
+      if(reject==true)e1[i1]->SetGstFlag(0);
+    }
+  }
+}
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::randomize_pool(vector<AliDielectronSingleTG*> e1, vector<AliDielectronSingleTG*> e2){
+  
+  int size1 = e1.size();
+  int used_index[1000];
+  for(int i=0;i<1000;i++){
+    used_index[i] = -1;
+  }
+  for(int i=0;i<size1;i++){
+    used_index[i] = 0;
+  }
+
+  for(int i=0;i<size1;i++){
+    int j = (int)(gRandom->Uniform(0,size1));
+    while(used_index[j]==1){
+      j = (int)(gRandom->Uniform(0,size1));
+    }
+    if( (e1[j]->GetGstFlag()==1) &&
+       (e1[j]->GetConvFlag()==1)
+        ){
+      vep.push_back(e1[j]);
+    }
+    used_index[j] = 1;
+  }
+  
+
+  int size2 = e2.size();
+  for(int i=0;i<1000;i++){
+    used_index[i] = -1;
+  }
+  for(int i=0;i<size2;i++){
+    used_index[i] = 0;
+  }
+
+  for(int i=0;i<size2;i++){
+    int j = (int)(gRandom->Uniform(0,size2));
+    while(used_index[j]==1){
+      j = (int)(gRandom->Uniform(0,size2));
+    }
+    if( (e2[j]->GetGstFlag()==1) &&
+       (e2[j]->GetConvFlag()==1)
+        ){
+      vem.push_back(e2[j]);
+    }
+    used_index[j] = 1;
+  }
+}
+
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::calc_pair(vector<AliDielectronSingleTG*> ve1, 
+                                               vector<AliDielectronSingleTG*> ve2, AliDielectron *die, Int_t idie){
+
+  for(int i1=0; i1<(int)ve1.size(); i1++){
+    for(int i2=0; i2<(int)ve2.size(); i2++){
+      fill_pair(ve1[i1], ve2[i2], 0, die);  
+    }    
+  }
+
+  for(int i1=0; i1<(int)ve1.size(); i1++){
+    for(int i2=i1+1; i2<(int)ve1.size(); i2++){
+      fill_pair(ve1[i1], ve1[i2], 1, die);  
+    }    
+  }
+
+  for(int i1=0; i1<(int)ve2.size(); i1++){
+    for(int i2=i1+1; i2<(int)ve2.size(); i2++){
+      fill_pair(ve2[i1], ve2[i2], 2, die);  
+    }    
+  }
+
+
+  double dw_cent = 100.0/NCENT;
+  double dw_iz = 20.0/NZBIN;
+  double dw_rp = acos(-1.0)/NRPBIN;
+
+  int icent = (int)(fgValues[AliDielectronVarManager::kCentrality]/dw_cent);
+  int izbin = (int)((fgValues[AliDielectronVarManager::kZvPrim]+10)/dw_iz);
+  int irp = (int)((fgValues[AliDielectronVarManager::kV0ACrpH2])/dw_rp);
+
+  if(icent<0) icent=0;
+  if(icent>=NCENT) icent=NCENT-1;
+  if(izbin<0) izbin=0;
+  if(izbin>=NZBIN) izbin=NZBIN-1;
+  if(irp<0) irp=0;
+  if(irp>=NRPBIN) irp=NRPBIN-1;
+
+  int nmixed;
+  if(ve1.size()>0) {
+    //
+    // Now mixed event for +- pairs
+    //
+    nmixed = 0;
+    for(int ibuf=0;(nmixed<NMix);ibuf++) {
+      int ntry = 0;
+      while(ntry<MAX_TRY) {
+        reshuffle_buffer(d_vem[ibuf][idie][izbin][icent][irp],d_poolm[idie][izbin][icent][irp]);
+        ntry++;
+      }
+      for(int i1=0; i1<(int)ve1.size(); i1++){
+       for(int i2=0; i2<(int)d_vem[ibuf][idie][izbin][icent][irp].size(); i2++){
+          fill_pair(ve1[i1],d_vem[ibuf][idie][izbin][icent][irp][i2], 3, die);
+        }
+      }
+      ++nmixed;
+    }//for(ibuf)
+  }
+  if(ve2.size()>0) {
+    //
+    // Now mixed event for +- pairs
+    //
+    nmixed = 0;
+    for(int ibuf=0;(nmixed<NMix);ibuf++) {
+      int ntry = 0;
+      while(ntry<MAX_TRY) {
+        reshuffle_buffer(d_vep[ibuf][idie][izbin][icent][irp],d_poolp[idie][izbin][icent][irp]);
+        ntry++;
+      }
+      for(int i1=0; i1<(int)ve2.size(); i1++){
+        for(int i2=0; i2<(int)d_vep[ibuf][idie][izbin][icent][irp].size(); i2++){
+          fill_pair(ve2[i1],d_vep[ibuf][idie][izbin][icent][irp][i2],4, die);
+        }
+      }
+      ++nmixed;
+    }//for(ibuf)
+  }
+
+  if(ve1.size()>0) {
+    //
+    // Now mixed event for ++ pairs
+    //
+    nmixed = 0;
+    for(int ibuf=0;(nmixed<NMix);ibuf++) {
+      int ntry = 0;
+      while(ntry<MAX_TRY) {
+        reshuffle_buffer(d_vep[ibuf][idie][izbin][icent][irp],d_poolp[idie][izbin][icent][irp]);
+        ntry++;
+      }
+      for(int i1=0; i1<(int)ve1.size(); i1++){
+        for(int i2=0;i2<(int)d_vep[ibuf][idie][izbin][icent][irp].size(); i2++){
+          fill_pair(ve1[i1],d_vep[ibuf][idie][izbin][icent][irp][i2], 5, die);
+        }
+      }
+      ++nmixed;
+    }//for(ibuf)
+  }
+
+  if(ve2.size()>0) {
+    //
+    // Now mixed event for +- pairs
+    //
+    nmixed = 0;
+    for(int ibuf=0;(nmixed<NMix);ibuf++) {
+      int ntry = 0;
+      while(ntry<MAX_TRY) {
+        reshuffle_buffer(d_vem[ibuf][idie][izbin][icent][irp],d_poolm[idie][izbin][icent][irp]);
+        ntry++;
+      }
+      for(int i1=0; i1<(int)ve2.size(); i1++){
+        for(int i2=0; i2<(int)d_vem[ibuf][idie][izbin][icent][irp].size(); i2++){
+          fill_pair(ve2[i1],d_vem[ibuf][idie][izbin][icent][irp][i2],6, die);
+        }
+      }
+      ++nmixed;
+    }//for(ibuf)
+  }
+
+}
+
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::fill_pair(AliDielectronSingleTG *iep, 
+                                               AliDielectronSingleTG *iem, int type, AliDielectron *die){                      
+  
+  double d_mass, d_phiv, d_pxpair, d_pypair, d_pzpair;
+  double d_ptpair, d_epair, d_phipair, d_etapair, d_cos, d_psi;
+
+  calc_vars(iep, iem, d_mass, d_phiv, d_pxpair, d_pypair, d_pzpair, 
+            d_ptpair, d_epair, d_phipair, d_etapair, d_cos, d_psi);
+
+
+  double d_openingangle =  -9999;
+  double d_v0_mass =  -9999;
+  double d_v0_pxpair = -9999;
+  double d_v0_pypair = -9999;
+  double d_v0_pzpair = -9999;
+  double d_v0_ptpair = -9999;
+  double d_v0_epair = -9999;
+  double d_v0_xv_pair = -9999;
+  double d_v0_yv_pair = -9999;
+  double d_v0_zv_pair = -9999;
+  double d_v0_phipair = -9999;
+  double d_v0_etapair = -9999;
+  double d_v0_r_pair = -9999;
+  double d_psi_pair =  -9999;
+
+  ////////////////////////////
+  ///// calculate v0 ////////
+  ///////////////////////////
+  Bool_t V0OFF=kFALSE;
+  /// for the moment, this doesn't work for MC
+  if(d_v0_mixing == kFALSE && (type==3 || type==4 || type==5 || type==6)){
+    V0OFF = kTRUE;
+  }
+  if(die->GetHasMC()==kTRUE && (type==3 || type==4 || type==5 || type==6)){
+    V0OFF = kTRUE;
+  }
+  if(type==0 || type==1 || type==2){
+    V0OFF = kFALSE;
+  }
+  
+
+  if(V0OFF==kFALSE){
+    AliVTrack* trackob1= iep->GetTrack();    
+    AliVTrack* trackob2= iem->GetTrack();    
+
+    if(!trackob1 || !trackob2){
+      return; 
+    }
+
+    AliDielectronPair candidate;
+    candidate.SetTracks(trackob1, (int)(11*iep->Charge()), 
+                       trackob2, (int)(11*iem->Charge()));
+    
+    if(trackob1==trackob2){
+      AliInfo("Same Objects!!");
+      return; 
+    }
+    const AliKFParticle &kfPair = candidate.GetKFParticle();
+    d_openingangle = candidate.OpeningAngle();
+    d_v0_mass = candidate.M();
+    d_v0_pxpair = candidate.Px();
+    d_v0_pypair = candidate.Py();
+    d_v0_pzpair = candidate.Pz();
+    d_v0_ptpair = candidate.Pt();
+    d_v0_epair = candidate.E();
+    d_v0_xv_pair = candidate.Xv();
+    d_v0_yv_pair = candidate.Yv();
+    d_v0_zv_pair = candidate.Zv();
+    d_v0_phipair = candidate.Phi();
+    // d_v0_theta_pair = candidate.Theta();
+    d_v0_etapair = candidate.Eta();
+    d_v0_r_pair =  kfPair.GetR();
+    
+    d_psi_pair = candidate.PsiPair(bz);
+  }
+
+  Double_t values[AliDielectronVarManager::kNMaxValues];
+  TString  className1;
+  TString  className2;
+  className1.Form("MyPair_%s",fgkPairClassNamesTG[type]);
+  className2.Form("MyPairV0_%s",fgkPairClassNamesTG[type]);
+  
+  AliDielectronHistos *fHistos = die->GetHistoManager();
+  Bool_t pairClass1=fHistos->GetHistogramList()->FindObject(className1.Data())!=0x0;
+  Bool_t pairClass2=fHistos->GetHistogramList()->FindObject(className2.Data())!=0x0;
+
+  if (pairClass1 && PairTrackcut(d_phiv)==true){
+    ///import pair variables to values!!
+    values[AliDielectronVarManager::kPx] = d_pxpair;
+    values[AliDielectronVarManager::kPy] = d_pypair;
+    values[AliDielectronVarManager::kPz] = d_pzpair;
+    values[AliDielectronVarManager::kPt] = d_ptpair;
+    values[AliDielectronVarManager::kXv] = d_v0_xv_pair;
+    values[AliDielectronVarManager::kYv] = d_v0_yv_pair;
+    values[AliDielectronVarManager::kZv] = d_v0_zv_pair;
+    values[AliDielectronVarManager::kR] = d_v0_r_pair;
+    values[AliDielectronVarManager::kE] = d_epair;
+    values[AliDielectronVarManager::kEta] = d_etapair;
+    values[AliDielectronVarManager::kM] = d_mass;
+    values[AliDielectronVarManager::kPsiPair] = d_phiv;
+    values[AliDielectronVarManager::kPhi]  = d_phipair;
+    values[AliDielectronVarManager::kOpeningAngle]  = d_cos;
+    fHistos->FillClass(className1, AliDielectronVarManager::kNMaxValues, values);
+  }
+
+
+  if (pairClass2 && PairTrackcut(d_phiv)==true){
+    values[AliDielectronVarManager::kPx] = d_v0_pxpair;
+    values[AliDielectronVarManager::kPy] = d_v0_pypair;
+    values[AliDielectronVarManager::kPz] = d_v0_pzpair;
+    values[AliDielectronVarManager::kPt] = d_v0_ptpair;
+    values[AliDielectronVarManager::kXv] = d_v0_xv_pair;
+    values[AliDielectronVarManager::kYv] = d_v0_yv_pair;
+    values[AliDielectronVarManager::kZv] = d_v0_zv_pair;
+    values[AliDielectronVarManager::kR] = d_v0_r_pair;
+    values[AliDielectronVarManager::kE] = d_v0_epair;
+    values[AliDielectronVarManager::kEta] = d_v0_etapair;
+    values[AliDielectronVarManager::kM] = d_v0_mass;
+    values[AliDielectronVarManager::kPsiPair] = d_psi_pair;
+    values[AliDielectronVarManager::kPhi]  = d_v0_phipair;
+    values[AliDielectronVarManager::kOpeningAngle]  = d_openingangle;
+    fHistos->FillClass(className2, AliDielectronVarManager::kNMaxValues, values);
+  }
+
+
+  
+}
+
+//_________________________________________________________________________________
+bool AliAnalysisTaskMultiDielectronTG::PairTrackcut(double phiv){
+  
+
+  bool pairOK = true;
+
+  //var is phiv for the moment 
+  if(bz>0 && phiv>d_conv_phiv){
+    pairOK = false;
+  }else if(bz<0 && phiv<acos(-1.0)-d_conv_phiv){
+    pairOK = false;
+  }
+
+  return pairOK;
+
+}
+
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::calc_vars(AliDielectronSingleTG *iep, AliDielectronSingleTG *iem, 
+                                               double &mass, double &phiv, double &px, double &py, double&pz,
+                                               double &pt, double &e, double &phi, 
+                                               double &eta, double &cos, double &psi){
+
+  px = iep->Px()+iem->Px();
+  py = iep->Py()+iem->Py();
+  pz = iep->Pz()+iem->Pz();
+  pt = sqrt(px*px+py*py);
+  double d_ppair = sqrt(pt*pt+pz*pz);
+  static const double me=0.0005109989;
+  e = sqrt(me*me+iep->Px()*iep->Px()+iep->Py()*iep->Py()+iep->Pz()*iep->Pz())
+    + sqrt(me*me+iem->Px()*iem->Px()+iem->Py()*iem->Py()+iem->Pz()*iem->Pz());
+  
+  mass =  e*e-px*px-py*py-pz*pz;
+  if(mass<0){
+    mass = mass;
+  }else{
+    mass = sqrt(mass);
+  }
+   
+  
+  phi = atan2(py, px);
+  eta = -0.5*TMath::Log((d_ppair+pz)/(d_ppair-pz));
+  double p1 = sqrt(pow(iep->Px(),2)+pow(iep->Py(),2)+pow(iep->Pz(),2));
+  double p2 = sqrt(pow(iem->Px(),2)+pow(iem->Py(),2)+pow(iem->Pz(),2));
+  cos = acos((iep->Px()*iem->Px()+iep->Py()*iem->Py()+iep->Pz()*iem->Pz())/(p1*p2));
+
+  double dtheta = iep->Theta()-iem->Theta();
+  psi = asin(dtheta/cos);
+
+
+  //unit vector of (pep+pem) 
+  double pl = d_ppair;
+  double ux = px/pl;
+  double uy = py/pl;
+  double uz = pz/pl;
+  double ax = uy/sqrt(ux*ux+uy*uy);
+  double ay = -ux/sqrt(ux*ux+uy*uy); 
+  
+  //momentum of e+ and e- in (ax,ay,az) axis. Note that az=0 by 
+  //definition. 
+  //double ptep = iep->Px()*ax + iep->Py()*ay; 
+  //double ptem = iem->Px()*ax + iem->Py()*ay; 
+  
+  double pxep = iep->Px();
+  double pyep = iep->Py();
+  double pzep = iep->Pz();
+  double pxem = iem->Px();
+  double pyem = iem->Py();
+  double pzem = iem->Pz();
+  
+  
+  //vector product of pep X pem 
+  double vpx = pyep*pzem - pzep*pyem; 
+  double vpy = pzep*pxem - pxep*pzem; 
+  double vpz = pxep*pyem - pyep*pxem; 
+  double vp = sqrt(vpx*vpx+vpy*vpy+vpz*vpz); 
+  //double thev = acos(vpz/vp); 
+  
+  //unit vector of pep X pem 
+  double vx = vpx/vp; 
+  double vy = vpy/vp; 
+  double vz = vpz/vp; 
+
+  //The third axis defined by vector product (ux,uy,uz)X(vx,vy,vz) 
+  double wx = uy*vz - uz*vy; 
+  double wy = uz*vx - ux*vz; 
+  double wz = ux*vy - uy*vx; 
+  double wl = sqrt(wx*wx+wy*wy+wz*wz); 
+  // by construction, (wx,wy,wz) must be a unit vector. 
+  if(fabs(wl - 1.0) > 0.00001) std::cout << "Calculation error in W vector"<<std::endl; 
+  // measure angle between (wx,wy,wz) and (ax,ay,0). The angle between them 
+  // should be small if the pair is conversion 
+  //
+  double cosPhiV = wx*ax + wy*ay; 
+  phiv = acos(cosPhiV); 
+  
+}
+
+//_________________________________________________________________________________
+void AliAnalysisTaskMultiDielectronTG::reshuffle_buffer(vector<AliDielectronSingleTG*> ve, deque<AliDielectronSingleTG*> pool){
+  //If there is not enough electron in the pool, give up
+
+  unsigned int ne = ve.size();
+  unsigned int poolsize = pool.size();
+  int used[MAXPOOL];
+  for(int i=0;i<(int)MAXPOOL;i++){
+    used[i]=0;
+  }
+
+  if(poolsize < ne) {
+    std::cout <<" pool size="<<poolsize<<" ne"<<ne<<std::endl;
+    return;
+  }
+  for(unsigned int ie=0; ie < ne; ie++) {
+    int j = rand()%poolsize;
+    while(used[j]==1){
+      j = rand()%poolsize;    
+    }
+    ve[ie] = pool[j];
+    used[j]=1;
+  }
+
+}
diff --git a/PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.h b/PWGDQ/dielectron/AliAnalysisTaskMultiDielectronTG.h
new file mode 100644 (file)
index 0000000..c6c9320
--- /dev/null
@@ -0,0 +1,235 @@
+#ifndef ALIANALYSISTASKMULTIDIELECTRONTG_H
+#define ALIANALYSISTASKMULTIDIELECTRONTG_H
+/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//#####################################################
+//#                                                   # 
+//#        Basic Analysis task for Dielectron         #
+//#          single event analysis                    #
+//#                                                   #
+//#  by WooJin J. Park, GSI / W.J.Park@gsi.de         #
+//#     Ionut C. Arsene, GSI / I.C.Arsene@gsi.de      #
+//#     Magnus Mager, CERN / Magnus.Mager@cern.ch     #
+//#     Jens Wiechula, Uni HD / Jens.Wiechula@cern.ch #
+//#                                                   #
+//#####################################################
+
+#include "TList.h"
+
+#include "AliAnalysisTaskSE.h"
+
+#include <vector>
+#include <deque>
+#include <cstdlib>
+
+
+// #include "AliDielectronPID.h"
+
+class AliDielectron;
+class TH1D;
+class AliAnalysisCuts;
+class AliTriggerAnalysis;
+class AliESDtrackCuts;
+
+class AliDielectronSingleTG : public TObject 
+{
+ public:
+  AliDielectronSingleTG():
+    fCharge(0),
+    fCentrality(0),
+    fXv(0),
+    fYv(0),
+    fZv(0),
+    fPx(0),
+    fPy(0),
+    fPz(0),
+    fPt(0),
+    fEta(0),
+    fPhi(0),
+    fTheta(0),
+    fConv(0),
+    fGst(0),
+    Obj(0x0)
+      {;
+      }
+    
+    AliDielectronSingleTG(Int_t charge, Double_t cent, 
+                         Double_t xv, Double_t yv, Double_t zv, 
+                         Double_t px, Double_t py, Double_t pz, Double_t pt,
+                         Double_t eta, Double_t phi, Double_t theta,
+                         Int_t conv, Int_t ghost, AliVTrack *trk)
+      : 
+      fCharge(charge), 
+      fCentrality(cent), 
+      fXv(xv),
+      fYv(yv),
+      fZv(zv),
+      fPx(px),
+      fPy(py),
+      fPz(pz),
+      fPt(pt),
+      fEta(eta),
+      fPhi(phi),
+      fTheta(theta),
+      fConv(conv),
+      fGst(ghost), Obj(0x0)
+       {
+         SetTrack(trk);
+         ;
+       }
+
+      ~AliDielectronSingleTG() {;}
+
+      
+      void SetTrack(AliVTrack *trk) { Obj = trk;}
+      Int_t Charge(void){ return fCharge;}
+      Double_t  Phi(void){ return fPhi;}
+      Double_t  Theta(void){ return fTheta;}
+      Double_t  Px(void){ return fPx;}
+      Double_t  Py(void){ return fPy;}
+      Double_t  Pz(void){ return fPz;}
+      Double_t  Xv(void){ return fPx;}
+      Double_t  Yv(void){ return fPy;}
+      Double_t  Zv(void){ return fPz;}
+      Double_t  Pt(void){ return fPt;}
+      AliVTrack *GetTrack(void){ return Obj;}
+      void SetConvFlag(Int_t val){ fConv = val;}
+      void SetGstFlag(Int_t val){ fGst = val;}
+      Int_t GetConvFlag(void){ return fConv;}
+      Int_t GetGstFlag(void){ return fGst;}
+      
+ protected:
+      Int_t fCharge; 
+      Double_t fCentrality; 
+      Double_t fXv; 
+      Double_t fYv;
+      Double_t fZv;
+      Double_t fPx;
+      Double_t fPy;
+      Double_t fPz;
+      Double_t fPt;
+      Double_t fEta;
+      Double_t fPhi;
+      Double_t fTheta;
+      Int_t fConv;
+      Int_t fGst;
+      AliVTrack *Obj;
+      
+      ClassDef(AliDielectronSingleTG, 2) // Event pool class              
+
+};
+
+
+
+class AliAnalysisTaskMultiDielectronTG : public AliAnalysisTaskSE {
+  
+public:
+  AliAnalysisTaskMultiDielectronTG();
+  AliAnalysisTaskMultiDielectronTG(const char *name);
+  virtual ~AliAnalysisTaskMultiDielectronTG();
+
+  enum ETriggerLogig {kAny, kExact};
+
+  virtual void UserExec(Option_t *option);
+  virtual void UserCreateOutputObjects();
+  virtual void FinishTaskOutput();
+  //temporary
+//   virtual void NotifyRun(){AliDielectronPID::SetCorrVal((Double_t)fCurrentRunNumber);}
+  
+  void UsePhysicsSelection(Bool_t phy=kTRUE) {fSelectPhysics=phy;}
+  void SetTriggerMask(ULong64_t mask) {fTriggerMask=mask;}
+  UInt_t GetTriggerMask() const { return fTriggerMask; }
+  void SetExcludeTriggerMask(ULong64_t mask) {fExcludeTriggerMask=mask;}
+  UInt_t GetExcludeTriggerMask() const { return fExcludeTriggerMask; }
+  void SetTriggerLogic(ETriggerLogig log) {fTriggerLogic=log;}
+  ETriggerLogig GetTriggerLogic() const {return fTriggerLogic;}
+
+  void SetEventFilter(AliAnalysisCuts * const filter) {fEventFilter=filter;}
+  void SetTriggerOnV0AND(Bool_t v0and=kTRUE)    { fTriggerOnV0AND=v0and;    }
+  void SetRejectPileup(Bool_t pileup=kTRUE)     { fRejectPileup=pileup;     }
+  void AddDielectron(AliDielectron * const die) { fListDielectron.Add(die); }
+
+
+  void reject_conversion(double val){d_conv_phiv = val;}
+  void enable_v0mixing(Bool_t val){d_v0_mixing = val;}
+  void check_ghost_pairs(vector<AliDielectronSingleTG*> e1);
+  void fill_pair(AliDielectronSingleTG* e1, AliDielectronSingleTG* e2, int type, AliDielectron *die);
+  bool PairTrackcut(double var1);
+  void calc_vars(AliDielectronSingleTG* e1, AliDielectronSingleTG* e2, 
+                double &mass, double &phiv, double &px, double &py, double&pz,
+                double &pt, double &e, double &phi, double &eta, double &cos, double &psi);
+  void calc_pair(vector<AliDielectronSingleTG*> e1, vector<AliDielectronSingleTG*> e2, AliDielectron *die, Int_t idie);
+  void randomize_pool(vector<AliDielectronSingleTG*> e1, vector<AliDielectronSingleTG*> e2);        
+  void reshuffle_buffer(vector<AliDielectronSingleTG*> ve, deque<AliDielectronSingleTG*> pool);
+
+protected:
+  enum {kAllEvents=0, kSelectedEvents, kV0andEvents, kFilteredEvents, kPileupEvents, kNbinsEvent};
+  TList fListDielectron;             // List of dielectron framework instances
+  TList fListHistos;                 //! List of histogram manager lists in the framework classes
+  TList fListCF;                     //! List with CF Managers
+  TList *tQAElectron;                     //! List with CF Managers
+  
+
+  Bool_t fSelectPhysics;             // Whether to use physics selection
+  UInt_t fTriggerMask;               // Event trigger mask
+  UInt_t fExcludeTriggerMask;        // Triggers to exclude from the analysis
+  Bool_t fTriggerOnV0AND;            // if to trigger on V0and
+  Bool_t fRejectPileup;              // pileup rejection wanted
+
+  ETriggerLogig fTriggerLogic;       // trigger logic: any or all bits need to be matching
+  
+  AliTriggerAnalysis *fTriggerAnalysis; //! trigger analysis class
+
+  AliAnalysisCuts *fEventFilter;     // event filter
+
+  AliESDtrackCuts *fCutsMother;   
+
+  TH1D *fEventStat;                  //! Histogram with event statistics
+  TH1D *fEvent;
+  TH2D *fdEdXvsPt;
+  TH2D *fdEdXnSigmaElecvsPt;
+  TH2D *fdEdXvsPtTOF;
+  TH2D *fdEdXnSigmaElecvsPtTOF;
+  TH2D *fTOFbetavsPt;
+  TH2D *fTOFnSigmaElecvsPt;
+  TH2F *hNCrossedRowsTPC; 
+  TH2F *hChi2ClusTPC;
+  TH2F *hRatioCrossClusTPC;
+
+  Double_t fgValues[AliDielectronVarManager::kNMaxValues];
+  std::vector<AliDielectronSingleTG*>  vem;
+  std::vector<AliDielectronSingleTG*>  vep;
+  std::vector<AliDielectronSingleTG*>  vem_tmp;
+  std::vector<AliDielectronSingleTG*>  vep_tmp;
+  Double_t d_conv_phiv; 
+  Double_t bz;
+  Bool_t d_v0_mixing;
+
+
+  //Buffer for event mixing
+  static const int NBUF=100; //depth of buffer
+  static const int NMix=40; //# of events mixed (for +-)
+  //static const int NMix=2; //# of events mixed (for +-)
+  
+  
+  static const int NRPBIN=12;
+  static const int NZBIN=10;
+  static const int NCENT=10;
+  static const int NDIE=10;
+  int d_ibuf[NDIE][NZBIN][NCENT][NRPBIN];
+  std::vector<AliDielectronSingleTG*> d_vep[NBUF][NDIE][NZBIN][NCENT][NRPBIN];
+  std::vector<AliDielectronSingleTG*> d_vem[NBUF][NDIE][NZBIN][NCENT][NRPBIN];
+  
+  static const unsigned int MAXPOOL=500;
+  //static const unsigned int MAXPOOL=50;
+  static const int MAX_TRY=3;
+  std::deque<AliDielectronSingleTG*> d_poolp[NDIE][NZBIN][NCENT][NRPBIN];
+  std::deque<AliDielectronSingleTG*> d_poolm[NDIE][NZBIN][NCENT][NRPBIN]; 
+  
+  AliAnalysisTaskMultiDielectronTG(const AliAnalysisTaskMultiDielectronTG &c);
+  AliAnalysisTaskMultiDielectronTG& operator= (const AliAnalysisTaskMultiDielectronTG &c);
+  
+  ClassDef(AliAnalysisTaskMultiDielectronTG, 2); //Analysis Task handling multiple instances of AliDielectron
+};
+#endif
diff --git a/PWGDQ/dielectron/macrosLMEE/AddTask_taku_LMEEPbPb2011.C b/PWGDQ/dielectron/macrosLMEE/AddTask_taku_LMEEPbPb2011.C
new file mode 100644 (file)
index 0000000..f320ce8
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+  in real data. argument should be kFALSE, kFALSE, kFALSE,
+  in siml data. argument should be kFALSE, kTRUE, kTRUE,
+
+*/
+AliAnalysisTask *AddTask_taku_LMEEPbPb2011(Bool_t runRejection=kFALSE, Bool_t setMC=kFALSE,Bool_t enableCF=kFALSE){
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTask_taku_LMEEPbPb2011", "No analysis manager found.");
+    return 0;
+  }
+
+  //create config File names: TRAIN_ROOT is for running on GSI train, 
+  // ALICE_ROOT for CERN Lego trains
+  TString configBasePath("$TRAIN_ROOT/cbaumann_dielectron/");
+  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");                                                                            
+  if (trainRoot.IsNull()) configBasePath= "$ALICE_ROOT/PWGDQ/dielectron/macrosLMEE/";
+  TString configFile("ConfigTakuLMEEPbPb2011.C");
+  TString configLMEECutLib("LMEECutLib.C");
+
+  TString configFilePath(configBasePath+configFile);
+  TString configLMEECutLibPath(configBasePath+configLMEECutLib);
+
+  //AOD Usage currently tested with separate task, to be merged
+  if (mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()){
+    ::Info("AddTaskLMEEPbPb2011", "no dedicated AOD configuration");
+  }
+
+  //Do we have an MC handler?
+  Bool_t hasMC=setMC;
+  if (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()!=0x0){
+    hasMC=kTRUE;
+    enableCF=kTRUE;
+  }
+  
+
+
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configLMEECutLib.Data()))
+    gROOT->LoadMacro(configLMEECutLibPath.Data());
+  if (!gROOT->GetListOfGlobalFunctions()->FindObject(configFile.Data()))
+    gROOT->LoadMacro(configFilePath.Data());
+
+  LMEECutLib* cutlib = new LMEECutLib();
+  cutlib->SetMCFlag(hasMC);
+  AliAnalysisTaskMultiDielectronTG *task=new AliAnalysisTaskMultiDielectronTG("MultiDiEData");
+
+  if (!hasMC){ 
+    task->UsePhysicsSelection();
+  }
+  task->SetTriggerMask(AliVEvent::kMB+AliVEvent::kCentral+AliVEvent::kSemiCentral);
+  task->SetEventFilter(cutlib->GetEventCuts(LMEECutLib::kPbPb2011TPCandTOF)); //
+  task->reject_conversion(2.0);
+  task->enable_v0mixing(kFALSE);
+
+  //load dielectron configuration file
+  //add dielectron analysis with different cuts to the task
+  if (runRejection) {
+    AliDielectron *lowmass4=ConfigTakuLMEEPbPb2011(4,hasMC,enableCF);
+    task->AddDielectron(lowmass4);
+    printf("add: %s\n",lowmass4->GetName());
+  }
+  else {
+    AliDielectron *lowmass3=ConfigTakuLMEEPbPb2011(3,hasMC,enableCF);
+    task->AddDielectron(lowmass3);
+    printf("add: %s\n",lowmass3->GetName());
+
+    AliDielectron *lowmass1=ConfigTakuLMEEPbPb2011(1,hasMC,enableCF);
+    task->AddDielectron(lowmass1);
+    printf("add: %s\n",lowmass1->GetName());
+
+    AliDielectron *lowmass7=ConfigTakuLMEEPbPb2011(7,hasMC,enableCF);
+    task->AddDielectron(lowmass7);
+    printf("add: %s\n",lowmass7->GetName());
+
+    AliDielectron *lowmass2=ConfigTakuLMEEPbPb2011(2,hasMC,enableCF);
+    task->AddDielectron(lowmass2);
+    printf("add: %s\n",lowmass2->GetName());
+  }
+
+  mgr->AddTask(task);
+
+  //create output container
+  AliAnalysisDataContainer *coutput1 =
+    mgr->CreateContainer("taku_LMEEPbPb2011_tree",
+       TTree::Class(),
+       AliAnalysisManager::kExchangeContainer,
+       "taku_LMEEPbPb2011_default.root");
+
+  AliAnalysisDataContainer *cOutputHist1 =
+    mgr->CreateContainer("taku_LMEEPbPb2011_out",
+       TList::Class(),
+       AliAnalysisManager::kOutputContainer,
+       "taku_LMEEPbPb2011_out.root");
+  
+  AliAnalysisDataContainer *cOutputHist2 = 0x0;
+  if (enableCF) {
+    cOutputHist2 = 
+      mgr->CreateContainer("taku_LMEEPbPb2011_CF",
+         TList::Class(),
+         AliAnalysisManager::kOutputContainer,
+         "taku_LMEEPbPb2011_out.root");
+
+  }
+  AliAnalysisDataContainer *cOutputHist3 =
+    mgr->CreateContainer("taku_EventStatPbPb2011",
+       TH1D::Class(),
+       AliAnalysisManager::kOutputContainer,
+       "taku_LMEEPbPb2011_out.root");
+
+
+  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 0, coutput1 );
+  mgr->ConnectOutput(task, 1, cOutputHist1);
+  if (enableCF) {
+    mgr->ConnectOutput(task, 2, cOutputHist2);
+  }
+  mgr->ConnectOutput(task, 3, cOutputHist3);
+
+  return task;
+}
diff --git a/PWGDQ/dielectron/macrosLMEE/ConfigTakuLMEEPbPb2011.C b/PWGDQ/dielectron/macrosLMEE/ConfigTakuLMEEPbPb2011.C
new file mode 100644 (file)
index 0000000..e852333
--- /dev/null
@@ -0,0 +1,644 @@
+void InitHistograms(AliDielectron *die, Int_t cutDefinition);
+void InitCF(AliDielectron* die, Int_t cutDefinition);
+void EnableMC();
+void SetSignals(AliDielectron *die);
+
+TString names=("noPairing;TPCTOFCentnoRej;TPCTOFSemiCentnoRej;TPCTOFPerinoRej;TPCTOFCent;TPCTOFSemiCent;TPCTOFPeri;TPCTOFCentnoRejTight;TPCTOFCentTight");
+TObjArray *arrNames=names.Tokenize(";");
+const Int_t nDie=arrNames->GetEntries();
+
+Bool_t MCenabled=kFALSE;
+
+
+AliDielectron* ConfigTakuLMEEPbPb2011(Int_t cutDefinition, Bool_t withMC=kFALSE, Bool_t CFenable=kFALSE)
+{
+
+  Int_t selectedPID=-1;
+  Int_t selectedCentrality=-1;
+  Bool_t rejectionStep=kFALSE;
+  LMEECutLib*  LMCL = new LMEECutLib();
+
+  //
+  // Setup the instance of AliDielectron
+  //
+
+  MCenabled=withMC;
+  // create the actual framework object
+
+  TString name=Form("%02d",cutDefinition);
+  if ((cutDefinition)<arrNames->GetEntriesFast()){
+       name=arrNames->At((cutDefinition))->GetName();
+  }
+
+  //thisCut only relevant for MC:
+  AliDielectron *die =
+       new AliDielectron(Form
+                         ("%s",name.Data()),
+                         Form("Track cuts: %s",name.Data()));
+  
+
+  if (MCenabled){
+    die->SetHasMC(kTRUE);
+    if(CFenable==kFALSE){
+      CFenable=kTRUE;
+    }
+  }
+  
+  //Setup AnalysisSelection:
+  if (cutDefinition==0) {
+       //not yet implemented
+  }
+  else if (cutDefinition==1) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011Central;
+    rejectionStep = kFALSE;
+  }
+  else if (cutDefinition==2) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011SemiCentral;
+    rejectionStep = kFALSE;
+  }
+  else if (cutDefinition==3) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011Peripheral;
+    rejectionStep = kFALSE;
+  }
+  else if (cutDefinition==4) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011Central;
+    rejectionStep = kTRUE;
+  }
+  else if (cutDefinition==5) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011SemiCentral;
+    rejectionStep = kTRUE;
+  }
+  else if (cutDefinition==6) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOFwide;
+    selectedCentrality = LMEECutLib::kPbPb2011Peripheral;
+    rejectionStep = kTRUE;
+  }
+
+//Legacy cuts, check consistence w/ 1 & 4, then remove
+  else if (cutDefinition==7) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOF;
+    selectedCentrality = LMEECutLib::kPbPb2011Central;
+    rejectionStep = kFALSE;
+  }
+  else if (cutDefinition==8) {
+    selectedPID = LMEECutLib::kPbPb2011TPCandTOF;
+    selectedCentrality = LMEECutLib::kPbPb2011Central;
+    rejectionStep = kTRUE;
+  }
+
+  else Semi{
+    cout << " =============================== " << endl;
+    cout << " ==== INVALID CONFIGURATION ==== " << endl;
+    cout << " =============================== " << endl;
+  }
+
+
+  //Now configure task
+
+  //Apply correct Pre-Filter Scheme, if necessary
+  die->SetPreFilterAllSigns();
+  //die->SetNoPairing(kTRUE);
+
+  if (rejectionStep) {
+    die->GetTrackFilter().AddCuts(LMCL->GetPIDCutsPre(selectedPID) );
+    die->GetPairPreFilterLegs().AddCuts(LMCL->GetPIDCutsAna(selectedPID) );
+    die->GetPairPreFilter().AddCuts(LMCL->GetPairCuts(selectedPID) );
+  }
+  else { //No Prefilter, no Pairfilter
+    die->GetTrackFilter().AddCuts( LMCL->GetPIDCutsAna(selectedPID) );
+  }
+  //Introduce NULL-check for pp?
+  die->GetEventFilter().AddCuts(LMCL->GetCentralityCuts(selectedCentrality));
+
+
+
+
+  AliDielectronTrackRotator *rot= 0x0;
+  /*AliDielectronTrackRotator *rot= LMCL->GetTrackRotator(selectedPID);
+  die->SetTrackRotator(rot);
+   */
+  AliDielectronMixingHandler *mix=LMCL->GetMixingHandler(selectedPID);
+  die->SetMixingHandler(mix);
+
+  // histogram setup
+  // only if an AliDielectronHistos object is attached to the
+  // dielectron framework histograms will be filled
+  //
+  InitHistograms(die,cutDefinition);
+
+  // the last definition uses no cuts and only the QA histograms should be filled!
+  if (CFenable) {
+    InitCF(die,cutDefinition);
+  }
+  return die;
+}
+
+//______________________________________________________________________________________
+
+void InitHistograms(AliDielectron *die, Int_t cutDefinition)
+{
+  //
+  // Initialise the histograms
+  //
+
+  //Setup histogram Manager
+  AliDielectronHistos *histos=
+       new AliDielectronHistos(die->GetName(),
+               die->GetTitle());
+  //Initialise histogram classes
+  histos->SetReservedWords("Track;Pair;Pre;RejTrack;RejPair:MyPair:MyPairV0");
+
+  //Event class
+//  if (cutDefinition==nDie-1) 
+  histos->AddClass("Event");
+
+  //Track classes
+  //to fill also track info from 2nd event loop until 2
+  for (Int_t i=0; i<2; ++i){
+    histos->AddClass(Form("Track_%s",AliDielectron::TrackClassName(i)));
+  }
+  
+  //Pair classes
+  // to fill also mixed event histograms loop until 10
+  for (Int_t i=0; i<3; ++i){
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(i)));
+  }
+  
+  //ME and track rot
+  if (die->GetMixingHandler()) {
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(3)));
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(4)));
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(6)));
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(7)));
+  }
+  if (die->GetTrackRotator()) {
+    histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(10)));
+  }
+  
+  //PreFilter Classes
+  //to fill also track info from 2nd event loop until 2
+  for (Int_t i=0; i<2; ++i){
+    histos->AddClass(Form("Pre_%s",AliDielectron::TrackClassName(i)));
+  }
+  
+  
+  //Create Classes for Rejected Tracks/Pairs:
+  for (Int_t i=0; i<2; ++i){
+    histos->AddClass(Form("RejTrack_%s",AliDielectron::TrackClassName(i)));
+  }
+  for (Int_t i=0; i<3; ++i){
+    histos->AddClass(Form("RejPair_%s",AliDielectron::PairClassName(i)));
+  }
+  
+  
+  //My Pair classes
+  // to fill also mixed event histograms loop until 10
+
+  const char* fgkPairClassNames[7] = {
+    "unlike",
+    "like_pp",
+    "like_ee",
+    "mixunlike_pe",
+    "mixunlike_ep",
+    "mixlike_pp",
+    "mixlike_ee"
+  };
+  for (Int_t i=0; i<7; ++i){
+    histos->AddClass(Form("MyPair_%s",fgkPairClassNames[i]));
+  }
+  for (Int_t i=0; i<7; ++i){
+    histos->AddClass(Form("MyPairV0_%s",fgkPairClassNames[i]));
+  }
+
+
+  /*
+  //track rotation
+
+  histos->AddClass(Form("Pair_%s",AliDielectron::PairClassName(AliDielectron::kEv1PMRot)));
+  histos->AddClass(Form("Track_Legs_%s",AliDielectron::PairClassName(AliDielectron::kEv1PMRot)));
+  */
+  //add histograms to event class
+  histos->UserHistogram("Event","nEvents","Number of processed events after cuts;Number events",
+                       1,0.,1.,AliDielectronVarManager::kNevents);
+  //histos->UserHistogram("Event","Centrality","Centrality;Centrality [%]","0,10,20,40,80,100,101",
+  //AliDielectronVarManager::kCentrality);
+  histos->UserHistogram("Event","Centrality","Centrality;Centrality [%]",100, 0, 100,
+                       AliDielectronVarManager::kCentrality);
+  
+
+  //add histograms to Track classes, also fills RejTrack
+  histos->UserHistogram("Track","Pt","Pt;Pt [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPt);
+  histos->UserHistogram("Track","NclsSFracTPC","NclsSFracTPC; NclsSFracTPC;#tracks",200,0,10.,AliDielectronVarManager::kNclsSFracTPC);
+  histos->UserHistogram("Track","TPCclsDiff","TPCclsDiff; TPCclsDiff;#tracks",200,0,10.,AliDielectronVarManager::kTPCclsDiff);
+
+  histos->UserHistogram("Track","ITS_dEdx_P","ITS_dEdx;P [GeV];ITS signal (arb units);#tracks",
+         400,0.0,20.,1000,0.,1000.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal,kTRUE);
+
+  histos->UserHistogram("Track","dEdx_P","dEdx;P [GeV];TPC signal (arb units);#tracks",
+         400,0.0,20.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
+
+  histos->UserHistogram("Track","TPCnSigmaEle_P","TPC number of sigmas Electrons;P [GeV];TPC number of sigmas Electrons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+  histos->UserHistogram("Track","TPCnSigmaKao_P","TPC number of sigmas Kaons;P [GeV];TPC number of sigmas Kaons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaKao,kTRUE);
+  histos->UserHistogram("Track","TPCnSigmaPio_P","TPC number of sigmas Pions;P [GeV];TPC number of sigmas Pions;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
+
+  histos->UserHistogram("Track","TRDpidPobEle_P","TRD PID probability Electrons;P [GeV];TRD prob Electrons;#tracks",
+         400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobEle,kTRUE);
+  histos->UserHistogram("Track","TRDpidPobPio_P","TRD PID probability Pions;P [GeV];TRD prob Pions;#tracks",
+         400,0.0,20.,100,0.,1.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTRDprobPio,kTRUE);
+
+  histos->UserHistogram("Track","TOFnSigmaKao_P","TOF number of sigmas Kaons;P [GeV];TOF number of sigmas Kaons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaKao,kTRUE);
+  histos->UserHistogram("Track","TOFnSigmaPro_P","TOF number of sigmas Protons;P [GeV];TOF number of sigmas Protons;#tracks",
+         400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTOFnSigmaPro,kTRUE);
+
+  histos->UserHistogram("Track","Eta_Phi","Eta Phi Map; Eta; Phi;#tracks",
+         200,-2,2,200,0,3.15,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
+
+  histos->UserHistogram("Track","dXY","dXY;dXY [cm];#tracks",200,-2.,2.,AliDielectronVarManager::kImpactParXY);
+
+  histos->UserHistogram("Track","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",159,0.,159.,AliDielectronVarManager::kNclsTPC);
+
+  histos->UserHistogram("Track","TPCnCls_kNFclsTPCr","nTPC vs nTPCr;nTPC vs nTPCr;#tracks",159,0.,159.,159,0.,159.,AliDielectronVarManager::kNclsTPC,AliDielectronVarManager::kNFclsTPCr);
+
+  histos->UserHistogram("Track","kNFclsTPCr_pT","nTPCr vs pt;nTPCr vs pt;#tracks",159,0.,159.,200,0.,20.,AliDielectronVarManager::kNFclsTPCr,AliDielectronVarManager::kPt);
+
+  //add histograms to Pair classes, also fills RejPair
+  histos->UserHistogram("Pair","InvMass","Inv.Mass;Inv. Mass [GeV];#pairs",
+                       1000,0.0,5.00,AliDielectronVarManager::kM);
+  histos->UserHistogram("Pair","Rapidity","Rapidity;Rapidity;#pairs",
+                       100,-2.,2.,AliDielectronVarManager::kY);
+  histos->UserHistogram("Pair","OpeningAngle","Opening angle;angle",
+                       100,0.,3.15,AliDielectronVarManager::kOpeningAngle);
+  //2D Histo Plot
+  histos->UserHistogram("Pair","InvMassPairPt","Inv.Mass vs PairPt;Inv. Mass [GeV], pT [GeV];#pairs",
+                       1000,0.0,5.0,500,0.,50.,AliDielectronVarManager::kM,AliDielectronVarManager::kPt);
+
+  histos->UserHistogram("Pair","InvMassOpeningAngle","Opening Angle vs Inv.Mass;Inv. Mass [GeV];#pairs",
+                       1000,0.0,5.0,200,0.,6.3,AliDielectronVarManager::kM,AliDielectronVarManager::kOpeningAngle);
+
+  //add histograms to Track classes
+  histos->UserHistogram("Pre","Pt","Pt;Pt [GeV];#tracks",200,0,20.,AliDielectronVarManager::kPt);
+
+  histos->UserHistogram("Pre","ITS_dEdx_P","ITS_dEdx;P [GeV];ITS signal (arb units);#tracks",
+         400,0.0,20.,1000,0.,1000.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kITSsignal,kTRUE);
+
+  histos->UserHistogram("Pre","dEdx_P","dEdx;P [GeV];TPC signal (arb units);#tracks",
+         400,0.0,20.,200,0.,200.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCsignal,kTRUE);
+
+  histos->UserHistogram("Pre","Eta_Phi","Eta Phi Map; Eta; Phi;#tracks",
+         200,-2,2,200,0,3.15,AliDielectronVarManager::kEta,AliDielectronVarManager::kPhi);
+
+  histos->UserHistogram("Pre","dXY","dXY;dXY [cm];#tracks",200,-2.,2.,AliDielectronVarManager::kImpactParXY);
+
+  histos->UserHistogram("Pre","ZVertex ","ZVertex ;ZVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kZv);
+  histos->UserHistogram("Pre","XVertex ","XVertex ;XVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kXv);
+  histos->UserHistogram("Pre","YVertex ","YVertex ;YVertex[cm];#tracks",20,-20,20,AliDielectronVarManager::kYv);
+
+  histos->UserHistogram("Pre","TPCnSigmaEle_P","TPC number of sigmas Electrons;P [GeV];TPC number of sigmas Electrons;#tracks",
+                       400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaEle,kTRUE);
+  histos->UserHistogram("Pre","TPCnSigmaKao_P","TPC number of sigmas Kaons;P [GeV];TPC number of sigmas Kaons;#tracks",
+                       400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaKao,kTRUE);
+  histos->UserHistogram("Pre","TPCnSigmaPio_P","TPC number of sigmas Pions;P [GeV];TPC number of sigmas Pions;#tracks",
+                       400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPio,kTRUE);
+  histos->UserHistogram("Pre","TPCnSigmaPro_P","TPC number of sigmas Proton;P [GeV];TPC number of sigmas Pions;#tracks",
+                       400,0.0,20.,100,-5.,5.,AliDielectronVarManager::kPIn,AliDielectronVarManager::kTPCnSigmaPro,kTRUE);
+
+
+//  histos->UserHistogram("Pre","TPCnCls","Number of Clusters TPC;TPC number clusteres;#tracks",159,0.,159.,AliDielectronVarManager::kNclsTPC);
+
+
+  ////////////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////////////
+  ////// my own histograms 
+  histos->UserHistogram("MyPair","InvMyMassPairPt","Inv.MyMass vs PairPt;Inv. MyMass [GeV]; pT [GeV]",
+                       1000,0.0,5.0,200,0.,20.,AliDielectronVarManager::kM,AliDielectronVarManager::kPt);
+
+  histos->UserHistogram("MyPair","InvMyMassOpeningAngle","Opening Angle vs Inv.MyMass;Inv. MyMass [GeV] ; OpeningAngle[rad]",
+                       1000,0.0,5.0,200,0.,6.3,AliDielectronVarManager::kM,AliDielectronVarManager::kOpeningAngle);
+
+  histos->UserHistogram("MyPair","InvMyMassPsiPair","PsiPair vs Inv.MyMass;Inv. MyMass [GeV]; Phiv",
+                       1000,0.0,5.0,200,0.,4,AliDielectronVarManager::kM,AliDielectronVarManager::kPsiPair);
+
+  histos->UserHistogram("MyPair","InvMyMassR","R vs Inv.MyMass;Inv. MyMass [GeV]; R[cm]",
+                       1000,0.0,5.0,200,0.,30,AliDielectronVarManager::kM,AliDielectronVarManager::kR);
+
+  histos->UserHistogram("MyPair","PhivR","R vs Phiv; R[cm]; Phiv[rad]",
+                       200,0.,30, 200,0,4, AliDielectronVarManager::kR,AliDielectronVarManager::kPsiPair);
+  
+
+  histos->UserHistogram("MyPairV0","InvV0MyMassPairPt","Inv.MyMass vs PairPt;Inv. MyMass [GeV]; pT [GeV]",
+                       1000,0.0,5.0,200,0.,20.,AliDielectronVarManager::kM,AliDielectronVarManager::kPt);
+
+  histos->UserHistogram("MyPairV0","InvV0MyMassOpeningAngle","Opening Angle vs Inv.MyMass;Inv. MyMass [GeV]; OA[rad]",
+                       1000,0.0,5.0,200,0.,6.3,AliDielectronVarManager::kM,AliDielectronVarManager::kOpeningAngle);
+
+  histos->UserHistogram("MyPairV0","InvV0MyMassPsiPair","PsiPair vs Inv.MyMass;Inv. MyMass [GeV]; Psi[rad]",
+                       1000,0.0,5.0,200,0.,4,AliDielectronVarManager::kM,AliDielectronVarManager::kPsiPair);
+
+  histos->UserHistogram("MyPairV0","InvV0MyMassR","R vs Inv.MyMass;Inv. MyMass [GeV]; R[cm]",
+                       1000,0.0,5.0,200,0.,30,AliDielectronVarManager::kM,AliDielectronVarManager::kR);
+  histos->UserHistogram("MyPairV0","PsiPairR","R vs PsiPair; R[cm]; PsiPair[rad]",
+                       200,0.,30, 200,0,4, AliDielectronVarManager::kR,AliDielectronVarManager::kPsiPair);
+  
+  ////////////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////////////
+
+
+
+
+
+
+  die->SetHistogramManager(histos);
+}
+
+
+void InitCF(AliDielectron* die, Int_t cutDefinition)
+{
+  //
+  // Setupd the CF Manager if needed
+  //
+
+  AliDielectronCF *cf=new AliDielectronCF(die->GetName(),die->GetTitle());
+
+  //pair variables
+  cf->AddVariable(AliDielectronVarManager::kP,200,0,20);
+  cf->AddVariable(AliDielectronVarManager::kPt,200,0,20);
+  cf->AddVariable(AliDielectronVarManager::kM, 1000,0,5.00); //5Mev Steps
+  cf->AddVariable(AliDielectronVarManager::kY,100,-2.,2.);
+  cf->AddVariable(AliDielectronVarManager::kPairType,10,0,10);
+
+  cf->AddVariable(AliDielectronVarManager::kCentrality,100, 0, 100);
+  cf->AddVariable(AliDielectronVarManager::kOpeningAngle,320,0.,3.2);
+  cf->AddVariable(AliDielectronVarManager::kPsiPair,320,0.,3.2);
+  //leg variables
+  cf->AddVariable(AliDielectronVarManager::kP,200,0.,20.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kPt,200,0.,20.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kITSsignal,1000,0.0.,1000.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kTPCsignal,500,0.0.,500.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kTPCnSigmaEle,100,-10.0.,10.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kITSnSigmaEle,100,-10.0.,10.,kTRUE);
+  cf->AddVariable(AliDielectronVarManager::kY,100,-2.,2.,kTRUE);
+  //only in this case write MC truth info
+  if (MCenabled) {
+    cf->SetStepForMCtruth();
+    //cf->SetStepsForMCtruthOnly();
+    cf->SetStepForAfterAllCuts();
+    cf->AddVariable(AliDielectronVarManager::kHaveSameMother,5,-2,2);
+    //cf->AddVariable(AliDielectronVarManager::kPdgCode,10000,-5000.5,4999.5,kTRUE);
+    //cf->AddVariable(AliDielectronVarManager::kPdgCodeMother,10000,-5000.5,4999.5,kTRUE);
+  }
+
+  cf->SetStepsForSignal();
+  die->SetCFManagerPair(cf);
+
+
+  /*
+ AliDielectronSignalMC* lowMassDiele=new
+    AliDielectronSignalMC("lowMassDiele","low mass dielectron pairs");
+  lowMassDiele->SetLegPDGs(11,-11);
+  lowMassDiele->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  lowMassDiele->SetLegSources(AliDielectronSignalMC::kPrimary,
+      AliDielectronSignalMC::kPrimary);
+  lowMassDiele->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(lowMassDiele);
+
+  AliDielectronSignalMC* secondary=new
+    AliDielectronSignalMC("secondary","secondary electrons pairs");
+  secondary->SetLegPDGs(11,-11);
+  secondary->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  secondary->SetLegSources(AliDielectronSignalMC::kSecondary,
+      AliDielectronSignalMC::kSecondary);
+  die->AddSignalMC(secondary);
+
+
+  AliDielectronSignalMC* finalState=new
+    AliDielectronSignalMC("finalState","finalState electrons pairs");
+  finalState->SetLegPDGs(11,-11);
+  finalState->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  finalState->SetLegSources(AliDielectronSignalMC::kFinalState,
+      AliDielectronSignalMC::kFinalState);
+  die->AddSignalMC(finalState);
+  */
+
+}
+
+//--------------------------------------
+void EnableMC() {
+  MCenabled=kTRUE;
+}
+
+
+//--------------------------------------
+void SetSignals(AliDielectron *die)
+{
+
+
+  AliDielectronSignalMC* promptJpsi = new AliDielectronSignalMC("promptJpsi","Prompt J/psi");   // prompt J/psi (not from beauty decays)
+  promptJpsi->SetLegPDGs(11,-11);
+  promptJpsi->SetMotherPDGs(443,443);
+  promptJpsi->SetGrandMotherPDGs(503,503,kTRUE,kTRUE);   // not from beauty hadrons
+  promptJpsi->SetMothersRelation(AliDielectronSignalMC::kSame);
+  promptJpsi->SetFillPureMCStep(kTRUE);
+  promptJpsi->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  promptJpsi->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  promptJpsi->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  promptJpsi->SetCheckBothChargesGrandMothers(kTRUE,kTRUE);
+  die->AddSignalMC(promptJpsi);
+
+  // physical backgrounds (electrons from other sources)
+  AliDielectronSignalMC* diEleContinuum = new AliDielectronSignalMC("diEleContinuum","di-electron continuum");     // all di-electrons originating in the collision
+  diEleContinuum->SetLegPDGs(11,-11);
+  diEleContinuum->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  diEleContinuum->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(diEleContinuum);
+  
+  AliDielectronSignalMC* diEleCharm = new AliDielectronSignalMC("diEleCharm","di-electrons from charm");  // dielectrons originating from charm hadrons (not neccessary from same mother)
+  diEleCharm->SetLegPDGs(11,-11);
+  diEleCharm->SetMotherPDGs(403,403);
+  diEleCharm->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  diEleCharm->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  diEleCharm->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  die->AddSignalMC(diEleCharm);
+
+  AliDielectronSignalMC* diEleOpenCharm = new AliDielectronSignalMC("diEleOpenCharm","di-electrons from open charm");  // dielectrons originating from open charm hadrons
+  diEleOpenCharm->SetLegPDGs(11,-11);
+  diEleOpenCharm->SetMotherPDGs(402,402);
+  diEleOpenCharm->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  diEleOpenCharm->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  diEleOpenCharm->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  die->AddSignalMC(diEleOpenCharm);
+
+
+  // background from secondary electrons
+  AliDielectronSignalMC* secondaryElectrons = new AliDielectronSignalMC("secondaryElectrons","Secondary electrons");   // all di-electrons from secondary electrons (interaction with detector)
+  secondaryElectrons->SetLegPDGs(11,-11);
+  secondaryElectrons->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary);
+  secondaryElectrons->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(secondaryElectrons);
+
+  /*
+  AliDielectronSignalMC* primarySecElePairs = new AliDielectronSignalMC("primarySecElePairs","Primary+Secondary electron pairs");  // primary-secondary pairs
+  primarySecElePairs->SetLegPDGs(11,-11);
+  primarySecElePairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  primarySecElePairs->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kSecondary);
+  die->AddSignalMC(primarySecElePairs);
+  */
+
+  AliDielectronSignalMC* conversionElePairs = new AliDielectronSignalMC("conversionElePairs","conversion electron pairs");      // pairs made from conversion (may be also from 2 different conversions)
+  conversionElePairs->SetLegPDGs(11,-11);
+  conversionElePairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  conversionElePairs->SetLegSources(AliDielectronSignalMC::kSecondary, AliDielectronSignalMC::kSecondary);
+  conversionElePairs->SetMotherPDGs(22,22);
+  die->AddSignalMC(conversionElePairs);
+
+  // misidentification
+  /*
+  AliDielectronSignalMC* allEleMisIdPairs = new AliDielectronSignalMC("allEleMisIdPairs","all electron+misid. pairs");  // one true electron + a mis-id electron (all sources included)
+  allEleMisIdPairs->SetLegPDGs(11,11,kFALSE,kTRUE);
+  allEleMisIdPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(allEleMisIdPairs);
+
+  AliDielectronSignalMC* allMisIdMisIdPairs = new AliDielectronSignalMC("allMisIdMisIdPairs","all misid.+misid. pairs");  // mis-id + mis-id
+  allMisIdMisIdPairs->SetLegPDGs(11,11,kTRUE,kTRUE);
+  allMisIdMisIdPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(allMisIdMisIdPairs);
+
+  AliDielectronSignalMC* elePionPairs = new AliDielectronSignalMC("elePionPairs","electron+pion pairs");    // true electron + mis-id pion
+  elePionPairs->SetLegPDGs(11,211);
+  elePionPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(elePionPairs);
+
+  AliDielectronSignalMC* eleKaonPairs = new AliDielectronSignalMC("eleKaonPairs","electron+kaon pairs");   // true electron + mis-id kaon
+  eleKaonPairs->SetLegPDGs(11,321);
+  eleKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(eleKaonPairs);
+
+  AliDielectronSignalMC* eleProtonPairs = new AliDielectronSignalMC("eleProtonPairs","Electron+proton pairs");  // true electron + mis-id proton
+  eleProtonPairs->SetLegPDGs(11,2212);
+  eleProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(eleProtonPairs);
+
+  AliDielectronSignalMC* piPiPairs = new AliDielectronSignalMC("piPiPairs","pion+pion pairs");    // mis-id pion + mis-id pion
+  piPiPairs->SetLegPDGs(211,211);
+  piPiPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(piPiPairs);
+
+  AliDielectronSignalMC* piKaonPairs = new AliDielectronSignalMC("piKaonPairs","pion+kaon pairs");  // mis-id pion + mis-id kaon
+  piKaonPairs->SetLegPDGs(211,321);
+  piKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(piKaonPairs);
+
+  AliDielectronSignalMC* piProtonPairs = new AliDielectronSignalMC("piProtonPairs","pion+proton pairs");  // mis-id pion + mis-id proton
+  piProtonPairs->SetLegPDGs(211,2212);
+  piProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(piProtonPairs);
+
+  AliDielectronSignalMC* kaonKaonPairs = new AliDielectronSignalMC("kaonKaonPairs","kaon+kaon pairs");  // mis-id kaon + mis-id kaon
+  kaonKaonPairs->SetLegPDGs(321,321);
+  kaonKaonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(kaonKaonPairs);
+
+  AliDielectronSignalMC* kaonProtonPairs = new AliDielectronSignalMC("kaonProtonPairs","kaon+proton pairs");   // mis-id kaon + mis-id proton
+  kaonProtonPairs->SetLegPDGs(321,2212);
+  kaonProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(kaonProtonPairs);
+
+  AliDielectronSignalMC* protonProtonPairs = new AliDielectronSignalMC("protonProtonPairs","proton+proton pairs");  // mis-id proton + mis-id proton
+  protonProtonPairs->SetLegPDGs(2212,2212);
+  protonProtonPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(protonProtonPairs);
+
+  AliDielectronSignalMC* muonAllPairs = new AliDielectronSignalMC("muonAllPairs","muon+everything pairs");        // mis-id muon + something else (electron, pion, kaon, proton)
+  muonAllPairs->SetLegPDGs(13,13,kFALSE,kTRUE);
+  muonAllPairs->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  die->AddSignalMC(muonAllPairs);
+  */
+
+
+  AliDielectronSignalMC* pi0Sig = new AliDielectronSignalMC("pi0", "pi0Signal"); ///pi0 dalitz pairs 
+  pi0Sig->SetLegPDGs(11,-11);
+  pi0Sig->SetMotherPDGs(111,111);
+  pi0Sig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  pi0Sig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  pi0Sig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  pi0Sig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  pi0Sig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  pi0Sig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(pi0Sig);
+
+
+  AliDielectronSignalMC* etaSig = new AliDielectronSignalMC("Eta", "etaSignal"); ///eta dalitz pairs 
+  etaSig->SetLegPDGs(11,-11);
+  etaSig->SetMotherPDGs(221,221);
+  etaSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  etaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  etaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  etaSig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  etaSig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  etaSig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(etaSig);
+
+
+  AliDielectronSignalMC* etaprimeSig = new AliDielectronSignalMC("Etaprime", "etaprimeSignal"); ///etaprime pairs 
+  etaprimeSig->SetLegPDGs(11,-11);
+  etaprimeSig->SetMotherPDGs(331,331);
+  etaprimeSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  etaprimeSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  etaprimeSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  etaprimeSig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  etaprimeSig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  etaprimeSig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(etaprimeSig);
+
+
+  AliDielectronSignalMC* rhoSig = new AliDielectronSignalMC("Rho", "rhoSignal"); ///rho pairs 
+  rhoSig->SetLegPDGs(11,-11);
+  rhoSig->SetMotherPDGs(113,113);
+  rhoSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  rhoSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  rhoSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  rhoSig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  rhoSig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  rhoSig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(rhoSig);
+
+  AliDielectronSignalMC* omegaSig = new AliDielectronSignalMC("Omega", "omegaSignal"); ///omega pairs 
+  omegaSig->SetLegPDGs(11,-11);
+  omegaSig->SetMotherPDGs(223,223);
+  omegaSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  omegaSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  omegaSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  omegaSig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  omegaSig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  omegaSig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(omegaSig);
+  
+  AliDielectronSignalMC* phiSig = new AliDielectronSignalMC("Phi", "phiSignal"); ///phi pairs 
+  phiSig->SetLegPDGs(11,-11);
+  phiSig->SetMotherPDGs(333,333);
+  phiSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  phiSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState);
+  phiSig->SetMotherSources(AliDielectronSignalMC::kPrimary, AliDielectronSignalMC::kPrimary);
+  phiSig->SetCheckBothChargesLegs(kTRUE,kTRUE);
+  phiSig->SetCheckBothChargesMothers(kTRUE,kTRUE);
+  phiSig->SetFillPureMCStep(kTRUE);
+  die->AddSignalMC(phiSig);
+
+  /*
+  AliDielectronSignalMC* convSig = new AliDielectronSignalMC("conv", "convSignal");
+  convSig->SetLegPDGs(11,-11);
+  convSig->SetMothersRelation(AliDielectronSignalMC::kSame);
+  convSig->SetLegSources(AliDielectronSignalMC::kFinalState, AliDielectronSignalMC::kFinalState); //in this case, ee needs to be true=IsPhysicalPrimary(label)
+  convSig->SetCheckBothChargesLegs(kFALSE,kFALSE);
+  die->AddSignalMC(convSig);
+  */
+}
+