- removed old double-gap analysis task by Xian-Guo Lu
authorfreidt <freidt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 23 Sep 2012 15:52:45 +0000 (15:52 +0000)
committerfreidt <freidt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 23 Sep 2012 15:52:45 +0000 (15:52 +0000)
- added new example-analysis task based on the old version, which is intended to be a common basis for future analyses on double-gap events and central diffraction

13 files changed:
PWGUD/CMakelibPWGUDdiffractive.pkg
PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.cxx [deleted file]
PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.h [deleted file]
PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.cxx [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.h [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.cxx [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.h [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.cxx [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.h [new file with mode: 0644]
PWGUD/DIFFRACTIVE/example/runEx.C [new file with mode: 0644]
PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.cxx [new file with mode: 0644]
PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.h [new file with mode: 0644]
PWGUD/PWGUDdiffractiveLinkDef.h

index 2867740..27f4a19 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: CMake -*-
 #--------------------------------------------------------------------------------#
-# Package File for PWGUDdiffractive                                               #
-# Author : Felix Reidt (felix.reidt@cern.ch)                                     # 
+# Package File for PWGUDdiffractive                                              #
+# Author : Felix Reidt (felix.reidt@cern.ch)                                     #
 # Variables Defined :                                                            #
 #                                                                                #
 # SRCS - C++ source files                                                        #
 # SHLIBS - Shared Libraries and objects for linking (Executables only)           #
 #--------------------------------------------------------------------------------#
 
-set ( SRCS DIFFRACTIVE/AliAnalysisTaskDDMeson.cxx)
+set ( SRCS
+  DIFFRACTIVE/example/AliAnalysisTaskCDex.cxx
+  DIFFRACTIVE/example/AliCDMesonUtilsStripped.cxx
+  DIFFRACTIVE/example/AliCDMesonBaseStripped.cxx
+  DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.cxx)
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
-set ( EINCLUDE  PWGUD/DIFFRACTIVE ITS PWGPP/ITS STEER/STEER STEER/CDB STEER/STEERBase)
+set ( EINCLUDE PWGUD/DIFFRACTIVE/example PWGUD/DIFFRACTIVE/xsAndTwoProng ITS PWGPP/ITS STEER/STEER STEER/CDB STEER/STEERBase VZERO )
 
 set ( DHDR PWGUDdiffractiveLinkDef.h )
diff --git a/PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.cxx b/PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.cxx
deleted file mode 100644 (file)
index cd991d6..0000000
+++ /dev/null
@@ -1,1009 +0,0 @@
-/**************************************************************************
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
-*                                                                        *
-* Author: The ALICE Off-line Project.                                    *
-* Contributors are mentioned in the code where appropriate.              *
-*                                                                        *
-* Permission to use, copy, modify and distribute this software and its   *
-* documentation strictly for non-commercial purposes is hereby granted   *
-* without fee, provided that the above copyright notice appears in all   *
-* copies and that both the copyright notice and this permission notice   *
-* appear in the supporting documentation. The authors make no claims     *
-* about the suitability of this software for any purpose. It is          *
-* provided "as is" without express or implied warranty.                  *
-**************************************************************************/
-//
-// Reconstruct mesons 
-// in central diffractive event 
-// in pp collisions
-//
-// Authors:
-//  Xianguo Lu <lu@physi.uni-heidelberg.de>
-//
-
-#include <TH1I.h>
-#include <TH2I.h>
-#include <TH2D.h>
-#include <TList.h>
-#include <TLorentzVector.h>
-#include <TRandom3.h>
-#include <THnSparse.h>
-
-#include "AliCDBManager.h"
-#include "AliCDBEntry.h"
-#include "AliESDInputHandler.h"
-#include "AliESDtrackCuts.h"
-#include "AliGeomManager.h"
-#include "AliITSAlignMille2Module.h"
-#include "AliITSsegmentationSPD.h"
-#include "AliKFParticle.h"
-#include "AliMultiplicity.h"
-#include "AliPID.h"
-#include "AliSPDUtils.h"
-#include "AliTriggerAnalysis.h"
-
-#include "AliAnalysisTaskDDMeson.h"
-
-void AliAnalysisTaskDDMeson::IniTask()
-{
-  //
-  //initialize values used in many places
-  //
-  fnmass = 512;
-  fmass1 = 0.01 * fnmass;
-
-  fnptv = 10;
-  fptv1 = 0.2 * fnptv;
-
-  fnpta = 51*2;
-  fpta1 = 0.05 * fnpta;
-
-  fneta = 64;
-  feta = 0.04 * fneta/2.;
-
-  fnnsel = 2;
-  fnsel1 = 2+fnnsel;
-
-  fncts = 10;
-  fnctlab = 20;
-
-  fCHECKVBA = 2;
-  fCHECKVBC = 4;
-
-  //------------------
-  fOpt.ToUpper();
-}
-
-AliAnalysisTaskDDMeson::AliAnalysisTaskDDMeson(const TString opt):
-  AliAnalysisTaskSE("DDMeson")
-  , fOpt(opt)
-  , fESD(0x0)
-
-  , fnmass(-999)
-  , fmass1(-999)
-  , fnptv(-999)
-  , fptv1(-999)
-  , fnpta(-999)
-  , fpta1(-999)
-  , fneta(-999)
-  , feta(-999)
-  , fnnsel(-999)
-  , fnsel1(-999)
-  , fncts(-999)
-  , fnctlab(-999)
-  , fCHECKVBA(-999)
-  , fCHECKVBC(-999)
-
-  , fHBIT(0x0)
-  , fBitcg(0)
-
-  , fRun(-999)
-  , fat(0x0)
-  , fct(0x0)
-  , fbt(0x0)
-  , fnt(0x0)
-  , ftt(0x0)
-
-  , fv0ntrk(0x0)
-  , frsntrk(0x0)
-
-  , fhps(0x0)
-  , fhfo(0x0)
-  , fhspd(0x0)
-  , fhv0fmd(0x0)
-  , fhpriv(0x0)
-  , fhntrk(0x0)
-
-  , fHist(0x0)
-  , fThnMass(0x0)
-  , fThnDPt(0x0)
-  , fThnDEta(0x0)
-  , fThnKF(0x0)
-{
-  //
-  // Dummy constructor
-  //
-  //slot in TaskSE must start from 1
-  DefineOutput(1, TList::Class());
-  DefineOutput(2, THnSparse::Class());
-  DefineOutput(3, THnSparse::Class());
-  DefineOutput(4, THnSparse::Class());
-  DefineOutput(5, THnSparse::Class());
-  IniTask();
-}
-
-AliAnalysisTaskDDMeson::AliAnalysisTaskDDMeson(const AliAnalysisTaskDDMeson  &p):
-  AliAnalysisTaskSE("DDMeson")
-  , fOpt(p.fOpt)
-  , fESD(p.fESD)
-
-  , fnmass(p.fnmass)
-  , fmass1(p.fmass1)
-  , fnptv(p.fnptv)
-  , fptv1(p.fptv1)
-  , fnpta(p.fnpta)
-  , fpta1(p.fpta1)
-  , fneta(p.fneta)
-  , feta(p.feta)
-  , fnnsel(p.fnnsel)
-  , fnsel1(p.fnsel1)
-  , fncts(p.fncts)
-  , fnctlab(p.fnctlab)
-  , fCHECKVBA(p.fCHECKVBA)
-  , fCHECKVBC(p.fCHECKVBC)
-
-  , fHBIT(p.fHBIT)
-  , fBitcg(p.fBitcg)
-
-  , fRun(p.fRun)
-  , fat(p.fat)
-  , fct(p.fct)
-  , fbt(p.fbt)
-  , fnt(p.fnt)
-  , ftt(p.ftt)
-
-  , fv0ntrk(p.fv0ntrk)
-  , frsntrk(p.frsntrk)
-
-  , fhps(p.fhps)
-  , fhfo(p.fhfo)
-  , fhspd(p.fhspd)
-  , fhv0fmd(p.fhv0fmd)
-  , fhpriv(p.fhpriv)
-  , fhntrk(p.fhntrk)
-
-  , fHist(p.fHist)
-  , fThnMass(p.fThnMass)
-  , fThnDPt(p.fThnDPt)
-  , fThnDEta(p.fThnDEta)
-  , fThnKF(p.fThnKF)
-{
-  //
-  // Copy constructor
-  //
-
-  IniTask();
-}
-
-AliAnalysisTaskDDMeson & AliAnalysisTaskDDMeson::operator=(const AliAnalysisTaskDDMeson  &p)
-{
-  //
-  // overload =
-  //
-  if(&p == this) return *this;
-  AliAnalysisTaskSE::operator=(p);
-
-  fESD = p.fESD;
-
-  fnmass = p.fnmass;
-  fmass1 = p.fmass1;
-  fnptv = p.fnptv;
-  fptv1 = p.fptv1;
-  fnpta = p.fnpta;
-  fpta1 = p.fpta1;
-  fneta = p.fneta;
-  feta = p.feta;
-  fnnsel = p.fnnsel;
-  fnsel1 = p.fnsel1;
-  fncts = p.fncts;
-  fnctlab = p.fnctlab;
-  fCHECKVBA = p.fCHECKVBA;
-  fCHECKVBC = p.fCHECKVBC;
-  
-  fHBIT = p.fHBIT;
-  fBitcg = p.fBitcg;
-
-  fRun = p.fRun;
-
-  fat = p.fat;
-  fct = p.fct;
-  fbt = p.fbt;
-  fnt = p.fnt;
-  ftt = p.ftt;
-
-  fv0ntrk = p.fv0ntrk;
-  frsntrk = p.frsntrk;
-
-  fhps = p.fhps;
-  fhfo = p.fhfo;
-  fhspd = p.fhspd;
-  fhv0fmd = p.fhv0fmd;
-  fhpriv = p.fhpriv;
-  fhntrk = p.fhntrk;
-
-  fHist = p.fHist;
-  fThnMass = p.fThnMass;
-  fThnDPt = p.fThnDPt;
-  fThnDEta = p.fThnDEta;
-  fThnKF = p.fThnKF;
-
-  IniTask();
-
-  return *this;
-}
-
-AliAnalysisTaskDDMeson::~AliAnalysisTaskDDMeson()
-{
-  //
-  //Destructor
-  //
-  if(fESD) delete fESD;
-
-  delete fHBIT;
-  delete fat;
-  delete fct;
-  delete fbt;
-  delete fnt;
-  delete ftt;
-
-  delete fv0ntrk;
-  delete frsntrk;
-
-  delete fhps;
-  delete fhfo;
-  delete fhspd;
-  delete fhv0fmd;
-  delete fhpriv;
-  delete fhntrk;
-
-  delete fThnMass;
-  delete fThnDPt;
-  delete fThnDEta;
-  delete fThnKF;
-
-  fHist->Clear();
-  delete fHist;  
-}
-
-void AliAnalysisTaskDDMeson::CheckRange(Double_t &ptv, Double_t &pta, Double_t &etaa
-                                        , Double_t &mpi
-                                        ) const 
-{
-  //
-  //save over/under flow bins
-  //
-
-  const Double_t eps = 1e-6;
-  if(ptv>=fptv1) ptv = fptv1 - eps;
-  if(pta>=fpta1) pta = fpta1 - eps;
-
-  if(etaa >= feta) etaa = feta - eps;
-
-  if(etaa <= -feta) etaa = -feta + eps;
-
-  if(mpi >= fmass1) mpi = fmass1 - eps;
-
-}
-
-void AliAnalysisTaskDDMeson::UserCreateOutputObjects()
-{
-  //
-  //CreateOutputObjects
-  //
-  //=======================================
-  const Double_t kvz0=1, kvz1=5;
-  const Int_t nkvz=(Int_t)(kvz1-kvz0);
-
-  const Double_t charge0=1, charge1=4;
-  const Int_t ncharge=(Int_t)(charge1-charge0);
-  
-  const Double_t mass0 = 0;
-  //=======================================
-  //total momentum and pt in lab frame:
-  const Double_t p0=0;
-  //=======================================
-  const Double_t nsel0 = 2;
-
-  //=======================================
-  const Double_t cts0=0, cts1=1;
-
-  //=======================================
-  const Double_t ctlab0 = -1, ctlab1 = 1;
-
-  //=======================================
-  //------- Mass
-  const Int_t    nparPtMass = 7;
-  const Int_t    nbinPtMass[]     ={fnnsel, nkvz, ncharge,  fnmass, fnptv, fncts, fnctlab};
-  const Double_t xminPtMass[]     ={nsel0,  kvz0, charge0,   mass0,    p0,  cts0,  ctlab0};
-  const Double_t xmaxPtMass[]     ={fnsel1, kvz1, charge1,  fmass1, fptv1,  cts1,  ctlab1};
-  fThnMass = new THnSparseD("DDMeson_Mass","nsel, kvz, charge, Mpipi, ptv, cts, ctlab", nparPtMass, nbinPtMass, xminPtMass, xmaxPtMass);
-  //------- DPt
-  const Int_t    nparDPt = 4;
-  const Int_t    nbinDPt[] ={fnnsel, nkvz, ncharge,  fnpta};
-  const Double_t xminDPt[] ={nsel0, kvz0, charge0,  p0};
-  const Double_t xmaxDPt[] ={fnsel1, kvz1, charge1,  fpta1};
-  fThnDPt = new THnSparseD("DDMeson_DPt","nsel, kvz, charge, pt1", nparDPt, nbinDPt, xminDPt, xmaxDPt);
-  //------- DEta
-  const Int_t    nparDEta = 4;
-  const Int_t    nbinDEta[] ={fnnsel, nkvz, ncharge,  fneta};
-  const Double_t xminDEta[] ={nsel0, kvz0, charge0,  -feta};
-  const Double_t xmaxDEta[] ={fnsel1, kvz1, charge1,  feta};
-  fThnDEta = new THnSparseD("DDMeson_DEta"," nsel, kvz, charge, eta1", nparDEta, nbinDEta, xminDEta, xmaxDEta);
-
-  //------- KF
-  const Double_t mks = 0.494;
-  const Double_t dks = 0.024;
-  const Int_t nparKF = 4;
-  const Int_t nbinKF[] = {nkvz, 200, 200, 200};
-  const Double_t xminKF[] ={kvz0, mks-dks, mks-dks, 0};
-  const Double_t xmaxKF[] ={kvz1, mks+dks, mks+dks, 10};
-  fThnKF = new THnSparseD("DDMeson_KF","kvz, rawks, kfks, chi2", nparKF, nbinKF, xminKF, xmaxKF);
-  //=======================================
-  //=======================================
-  fHBIT = new TH1I("HBIT","",32,1,33);
-
-  const Int_t runb0 = 114650; //runa1=114649, runb1=117630, runc0=117631, runc1=121526, rund0=121527, rund1=126460, rune0=126461, rune1 = 130930; //runf0=130931, all checked on elog
-  const Int_t runf1 = 133900;//02OCT2010
-  const Int_t run0 = runb0-1, run1 = runf1+1;
-  const Int_t nrun = (Int_t)(run1-run0);
-
-  fat = new TH1I("at","",nrun,run0,run1);
-  fct = new TH1I("ct","",nrun,run0,run1);
-  fbt = new TH1I("bt","",nrun,run0,run1);
-  fnt = new TH1I("nt","",nrun,run0,run1);
-  ftt = new TH1I("tt","",nrun,run0,run1);
-  
-  fv0ntrk = new TH2D("c_v0ntrk","",80,0,80, 4, 1, 5);//x: ntrk; y: GetV0
-  frsntrk = new TH2D("c_rsntrk","",1000,0,1000, 200, 0,200);
-  fhps =    new TH1I("a000_ps",    "", 20, 0,20);
-  fhfo =    new TH2I("a010_fo",    "", 50, 0, 50, 50, 0, 50);
-  fhspd =   new TH1I("a011_spd",   "", 50, 0, 50);
-  fhv0fmd = new TH2I("a020_v0fmd", "", 4, 0, 4, 4, 0, 4);
-  fhpriv =  new TH1I("a100_priv",  "", 2, 0,2);
-  fhntrk =  new TH1I("a110_ntrk",  "", (Int_t)fnsel1, 0, (Int_t)fnsel1);
-
-  //------
-
-  fHist = new TList;
-
-  //------>>> Very important!!!!!!!
-  fHist->SetOwner();
-
-  fHist->Add(fat);
-  fHist->Add(fct);
-  fHist->Add(fbt);
-  fHist->Add(fnt);
-  fHist->Add(ftt);
-
-  fHist->Add(fv0ntrk);
-  fHist->Add(frsntrk);
-  fHist->Add(fhps);
-  fHist->Add(fhfo);
-  fHist->Add(fhspd);
-  fHist->Add(fhv0fmd);
-  fHist->Add(fhpriv);
-  fHist->Add(fhntrk);
-}
-
-void AliAnalysisTaskDDMeson::UserExec(Option_t *)
-{
-  //
-  //Execute
-  // 
-  //----------------------------------- general protection
-  if(!CheckESD())
-    return;
-
-  //----------------------------------- trigger bits
-  if(!CheckBit())
-    return;  
-
-  //----------------------------------- track cuts
-  const Int_t ntrk0 = fESD->GetNumberOfTracks();
-  const AliESDtrack * trks[ntrk0];
-  for(Int_t ii=0; ii<ntrk0; ii++){
-    trks[ii] = 0x0;
-  }
-  const Int_t nsel = CutESD(trks);
-  if(nsel<2)
-    return;
-
-  for(Int_t ii=0; ii<nsel; ii++){
-    for(Int_t jj=ii+1; jj<nsel; jj++){
-      const AliESDtrack * trkpair[2]={trks[ii], trks[jj]};
-
-      //----------------------------------- tracks initailization
-      TRandom3 tmprd(0);
-      if(tmprd.Rndm()>0.5){
-        SwapTrack(trkpair);
-      }
-  
-      //------------------------------------------------------------------------
-      const Int_t pipdg = 211;
-      const AliKFParticle daughter0(*(trkpair[0]), pipdg);
-      const AliKFParticle daughter1(*(trkpair[1]), pipdg);
-
-      const AliKFParticle parent(daughter0, daughter1);
-      const Double_t kfchi2 = parent.GetChi2();
-      const Double_t kfmass = parent.GetMass();
-
-      //------------------------------------------------------------------------
-      const Int_t kvz = GetV0();
-
-      const AliESDtrack * trk1=trkpair[0];
-      const AliESDtrack * trk2=trkpair[1];
-  
-      const Double_t ch1 = trk1->GetSign();
-      const Double_t ch2 = trk2->GetSign();
-      const Int_t combch = GetCombCh(ch1, ch2);
-      
-      Double_t pta  = trk1->Pt();
-      Double_t etaa = trk1->Eta();
-      
-      Double_t tmpp1[3], tmpp2[3];
-      trk1->GetPxPyPz(tmpp1);
-      trk2->GetPxPyPz(tmpp2);
-  
-      //------------------------------------------------------------------------
-      //------------------------------------------------------------------------
-      const Double_t ctlab = GetCtlab(tmpp1, tmpp2);
-
-      Double_t cts = -999;
-      const Double_t masspi = AliPID::ParticleMass(AliPID::kPion);
-      const TLorentzVector sumv = GetKinematics(tmpp1, tmpp2, masspi, masspi, cts);
-      Double_t pipi = sumv.Mag();
-      Double_t ptv = sumv.Pt();
-
-      CheckRange(ptv, pta, etaa, pipi);
-      
-      const Double_t varMass[]  ={nsel, kvz, combch
-                                       , pipi, ptv, cts
-                                       , ctlab
-      };
-      const Double_t varDPt[]        ={nsel, kvz, combch, pta};
-      const Double_t varDEta[]       ={nsel, kvz, combch, etaa};
-      fThnMass->Fill(varMass);
-      fThnDPt->Fill(varDPt);
-      fThnDEta->Fill(varDEta);
-
-      const Double_t varKF[] = {kvz, pipi, kfmass, kfchi2};
-      if(nsel==2 && combch==3)
-        fThnKF->Fill(varKF);
-    }
-  }
-  //------------------------------------------------------------------------
-  //------------------------------------------------------------------------
-
-  PostData(1, fHist);
-  PostData(2, fThnMass);
-  PostData(3, fThnDPt);
-  PostData(4, fThnDEta);
-  PostData(5, fThnKF);
-}
-//=======================================================================
-//=======================================================================
-    
-void AliAnalysisTaskDDMeson::Terminate(Option_t *)
-{
-  //
-  //fillbit before leaving
-  //
-  FillBit();
-}
-
-void AliAnalysisTaskDDMeson::FillBit()
-{
-  //
-  //save the bit count in f*t 
-  //
-  Double_t tot[5];
-  CalcBit(fHBIT, tot);
-
-  const Int_t bin = fat->FindBin(fRun);
-  fat->AddBinContent(bin, tot[0]);
-  fct->AddBinContent(bin, tot[1]);
-  fbt->AddBinContent(bin, tot[2]);
-  fnt->AddBinContent(bin, tot[3]);
-  ftt->AddBinContent(bin, tot[4]);
-}
-
-void AliAnalysisTaskDDMeson::CalcBit(TH1I *hc, Double_t tot[]) const
-{
-  //
-  //calculate the bit count in f*t 
-  //
-  if(hc->GetBinLowEdge(1)!=1){
-    printf("xlulog hc defined incorrectly!! %f\n",hc->GetBinLowEdge(1));
-    return;
-  }
-  if(hc->GetBinContent(0)){
-    printf("\nxlulog hc !!!!!!!!!!!!!!!!!!! underflow!!!!!!!!!!!!!!!!! %f\n\n", hc->GetBinContent(0));
-    return;
-  }
-  if(hc->GetBinContent(hc->GetNbinsX())){
-    printf("\nxlulog hc !!!!!!!!!!!!!!!!! OVERflow!!!!!!!!!!!!!! %f\n\n", hc->GetBinContent(hc->GetNbinsX()));
-    return;
-  }
-
-
-  Double_t atot=0, ctot=0, btot=0, ntot=0;
-  for(Int_t ib=1; ib<=hc->GetNbinsX(); ib++){
-    const Double_t cont = hc->GetBinContent(ib);
-    if(       (ib & fCHECKVBA) && !(ib & fCHECKVBC) ){
-      atot += cont;
-    }
-    else if( !(ib & fCHECKVBA) &&  (ib & fCHECKVBC) ){
-      ctot += cont;
-    }
-    else if(  (ib & fCHECKVBA) &&  (ib & fCHECKVBC) ){
-      btot += cont;
-    }
-    else{
-      ntot += cont;
-    }
-  }
-
-  const Double_t ttot   = atot + ctot + btot + ntot;
-  
-  tot[0]=atot;
-  tot[1]=ctot;
-  tot[2]=btot;
-  tot[3]=ntot;
-  tot[4]=ttot;
-
-  //---
-  char fullname[5][20];
-  strncpy(fullname[0],"V0A-ONLY",19);
-  strncpy(fullname[1],"V0C-ONLY",19);
-  strncpy(fullname[2],"V0A & V0C",19);
-  strncpy(fullname[3],"!V0A & !V0C",19);
-  strncpy(fullname[4],"TOTAL",19);
-  for (Int_t ii=0;ii<5;ii++){
-    fullname[ii][19] = '\0';
-  }
-
-  for(Int_t ii=0;ii<5;ii++){
-    printf("xlulog %s CTP-L0: %s\tTOT: %10.0f\n",fOpt.Data(), fullname[ii],tot[ii]);
-  }
-
-  //---
-
-  const Int_t nb=hc->GetNbinsX();
-  for(Int_t ib=0; ib<=nb+1; ib++){
-    hc->SetBinContent(ib, 0);
-  }
-}
-
-//====================================================================================
-
-Bool_t AliAnalysisTaskDDMeson::CheckESD()
-{
-  //
-  //general protection
-  //
-  const AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler *>(fInputHandler);
-  if(esdH)  
-    fESD = esdH->GetEvent();
-  if(!fESD){
-    AliError("xlulog No ESD Event");
-    return 0;
-  }
-  
-  if(fabs(fESD->GetMagneticField())<1){
-    printf("xlulog strange Bfield! %f\n", fESD->GetMagneticField());
-    return 0;
-  }
-
-  const Int_t tmprun = fESD->GetRunNumber();
-
-  if(fRun!=tmprun){
-    if(fRun>0){
-      printf("xlulog run changed during exec!! %d %d\n", tmprun, fRun);
-      FillBit();
-    }
-    fRun = tmprun;
-    if(fOpt.Contains("SPD")){
-      SPDLoadGeom();
-    }
-  }
-
-  return 1;  
-}
-
-void AliAnalysisTaskDDMeson::SPDLoadGeom() const 
-{
-  //method to get the gGeomanager
-  // it is called at the CreatedOutputObject stage
-  // to comply with the CAF environment
-  AliCDBManager *man = AliCDBManager::Instance();
-  TString cdbpath("local:///lustre/alice/alien/alice/data/2010/OCDB");
-  man->SetDefaultStorage(cdbpath);
-  man->SetRun(fRun);  
-  man->SetSpecificStorage("ITS/Align/Data",cdbpath);
-  man->SetSpecificStorage("GRP/Geometry/Data",cdbpath);
-  
-  AliCDBEntry* obj = man->Get(AliCDBPath("GRP", "Geometry", "Data"));
-  if (obj != NULL) {
-    AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
-    AliGeomManager::ApplyAlignObjsFromCDB("ITS"); 
-    printf("xlulog DDMeson %s Geom Loaded for run %d !\n", fOpt.Data(), fRun);
-  }
-  else {
-    printf("xlulog DDMeson %s was unable to load Geom for run %d !\n", fOpt.Data(), fRun);
-  }
-}
-
-Bool_t AliAnalysisTaskDDMeson::SPDLoc2Glo(const Int_t id, const Double_t *loc, Double_t *glo) const 
-{
-  //
-  //SPDLoc2Glo
-  //
-
-  static TGeoHMatrix mat;
-  Int_t vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(id);
-  if (vid<0) {
-    printf("xlulog Did not find module with such ID %d\n",id);
-    return kFALSE;
-  }
-  AliITSAlignMille2Module::SensVolMatrix(vid,&mat);
-  mat.LocalToMaster(loc,glo);
-  return kTRUE;
-}
-
-Bool_t AliAnalysisTaskDDMeson::CheckChipEta(const Int_t chipKey) const 
-{
-  //
-  //CheckChipEta
-  //
-
-  //no eta cut 
-  if(fOpt.Contains("SPD0"))
-    return kTRUE;
-
-  const Double_t etacut = 1.0;
-
-  UInt_t module=999, offchip=999;
-  AliSPDUtils::GetOfflineFromOfflineChipKey(chipKey,module,offchip);
-  UInt_t hs = AliSPDUtils::GetOnlineHSFromOffline(module);
-  if(hs<2) offchip = 4 - offchip; // inversion  in the inner layer... 
-  
-  const Int_t col[]={
-    hs<2? 0 : 31, 
-    hs<2? 31 : 0, 
-    hs<2? 31 : 0, 
-    hs<2? 0 : 31};
-  const Int_t aa[]={0, 0, 255, 255};
-  const AliITSsegmentationSPD seg;
-
-  for(Int_t ic=0; ic<4; ic++){
-    Float_t localchip[3]={0.,0.,0.};
-    seg.DetToLocal(aa[ic],col[ic]+32*offchip,localchip[0],localchip[2]); // local coordinate of the chip center
-    //printf("local coordinates %d %d: %f %f \n",chipKey, ic, localchip[0],localchip[2]);
-    const Double_t local[3] = {localchip[0],localchip[1],localchip[2]};
-    Double_t glochip[3]={0.,0.,0.};
-    if(!SPDLoc2Glo(module,local,glochip)){
-      return kFALSE;
-    }
-
-    const TVector3 pos(glochip[0],glochip[1],glochip[2]);
-    //pos.Print();
-
-    if(fabs(pos.Eta()) > etacut)
-      return kFALSE;
-  }
-
-  return kTRUE;
-}
-
-void AliAnalysisTaskDDMeson::GetNFO(Int_t &ni, Int_t &no) const 
-{
-  //
-  //GetNFO
-  //
-
-  const AliMultiplicity *mult = fESD->GetMultiplicity();
-  Int_t nFOinner=0;
-  Int_t nFOouter=0;
-  for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
-    if(mult->TestFastOrFiredChips(iChipKey) && CheckChipEta(iChipKey)){ // here you check if the FastOr bit is 1 or 0
-      if(iChipKey<400) 
-        nFOinner++;  // here you count the FastOr bits in the inner layer
-      else 
-        nFOouter++;  // here you count the FastOr bits in the outer layer
-    }
-  }
-
-  ni = nFOinner;
-  no = nFOouter;
-}
-
-Bool_t AliAnalysisTaskDDMeson::CheckBit()
-{
-  //
-  //get offline trigger
-  //
-  fhps->Fill(1);
-
-  AliTriggerAnalysis triggerAnalysis;
-
-  //hardware 1: hw 0: offline
-  const Bool_t khw = kFALSE;
-  const Bool_t v0A       = (triggerAnalysis.V0Trigger(fESD, AliTriggerAnalysis::kASide, khw) == AliTriggerAnalysis::kV0BB);
-  const Bool_t v0C       = (triggerAnalysis.V0Trigger(fESD, AliTriggerAnalysis::kCSide, khw) == AliTriggerAnalysis::kV0BB);
-
-  /*
-    const Bool_t v0ABG     = (triggerAnalysis.V0Trigger(fESD, AliTriggerAnalysis::kASide, khw) == AliTriggerAnalysis::kV0BG);
-    const Bool_t v0CBG     = (triggerAnalysis.V0Trigger(fESD, AliTriggerAnalysis::kCSide, khw) == AliTriggerAnalysis::kV0BG);
-    const Bool_t v0BG      = v0ABG || v0CBG;
-    const Int_t fastOROffline = triggerAnalysis.SPDFiredChips(fESD, 0); // SPD number of chips from clusters (!)        
-
-    //http://alisoft.cern.ch/viewvc/trunk/ANALYSIS/AliPhysicsSelection.cxx?view=markup&root=AliRoot
-    //Bool_t mb1 = (fastOROffline > 0 || v0A || v0C) && (!v0BG);
-   */
-
-  const Bool_t fmdA = triggerAnalysis.FMDTrigger(fESD, AliTriggerAnalysis::kASide);
-  const Bool_t fmdC = triggerAnalysis.FMDTrigger(fESD, AliTriggerAnalysis::kCSide);
-
-  Bool_t bitA = kFALSE, bitC = kFALSE;
-  if(fOpt.Contains("V0")){
-    bitA = bitA || v0A;
-    bitC = bitC || v0C;
-  }
-  if(fOpt.Contains("FMD")){
-    bitA = bitA || fmdA;
-    bitC = bitC || fmdC;
-  }
-  
-  //---------------------------------------------------------------------------------------------
-  //---------------------------------------------------------------------------------------------
-  //considering the efficiency per chip, nfo and fastORhw is required only to have non-0 count!!  
-
-  //simulate SPD _hardware_ trigger in eta range
-  if(fOpt.Contains("SPD")){
-    Int_t ni=-999, no = -999;
-    GetNFO(ni, no);
-    if(!bitA && !bitC){
-      fhfo->Fill(ni, no);
-    }
-    if(ni<2 || no<2)
-      return 0;
-  }
-
-  //simulate MB condition, since for double gap SPD is definitely fired, fastORhw>0 to reduce GA, GC, NG
-  //http://alisoft.cern.ch/viewvc/trunk/ANALYSIS/AliTriggerAnalysis.cxx?view=markup&root=AliRoot
-  //Int_t AliTriggerAnalysis::SPDFiredChips(const AliESDEvent* aEsd, Int_t origin, Bool_t fillHists, Int_t layer)
-  // returns the number of fired chips in the SPD
-  // origin = 0 --> aEsd->GetMultiplicity()->GetNumberOfFiredChips() (filled from clusters)
-  // origin = 1 --> aEsd->GetMultiplicity()->TestFastOrFiredChips() (from hardware bits)
-  const Int_t fastORhw = triggerAnalysis.SPDFiredChips(fESD, 1);
-  fhspd->Fill(fastORhw);
-  if(fastORhw<1)
-    return 0;
-
-  //---------------------------------------------------------------------------------------------
-  //---------------------------------------------------------------------------------------------
-    
-  const Int_t iv0 = v0A + 2*v0C;
-  const Int_t ifmd = fmdA + 2*fmdC;
-  fhv0fmd->Fill(iv0, ifmd);
-
-  //---------------------------------------------------------------------------------------------
-  //---------------------------------------------------------------------------------------------
-  
-  //need a base number to distringuish from null entry; fHBit starts from 1; important!!
-  fBitcg=1; 
-
-  if(bitA)
-    fBitcg += fCHECKVBA;
-  if(bitC)
-    fBitcg += fCHECKVBC;
-
-  fHBIT->Fill( fBitcg );
-  
-  return 1;
-}
-
-Int_t AliAnalysisTaskDDMeson::CutESD(const AliESDtrack *outtrk[])
-{
-  //
-  //track cuts
-  //
-  
-  //collision vertex cut
-  //A cut in XY is implicitly done during the reconstruction by constraining the vertex to the beam diamond.
-
-  // Primary vertex
-  Bool_t kpr0 = kTRUE;
-  const AliESDVertex *vertex = fESD->GetPrimaryVertexTracks();
-  if(vertex->GetNContributors()<1) {
-    // SPD vertex
-    vertex = fESD->GetPrimaryVertexSPD();
-    if(vertex->GetNContributors()<1) {
-      // NO GOOD VERTEX, SKIP EVENT 
-      kpr0 = kFALSE;
-    }
-  }
-  const Bool_t kpriv = kpr0 && ( fabs(fESD->GetPrimaryVertex()->GetZ())<10 ); 
-  fhpriv->Fill(kpriv);
-  if(!kpriv)  
-    return 0;
-  
-  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts;//::GetStandardITSTPCTrackCuts2010(kTRUE);
-
-  //--->
-  // TPC  
-  esdTrackCuts->SetMinNClustersTPC(70);
-  esdTrackCuts->SetMaxChi2PerClusterTPC(4);
-  esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
-  esdTrackCuts->SetRequireTPCRefit(kTRUE);
-  // ITS
-  esdTrackCuts->SetRequireITSRefit(kTRUE);
-  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
-                                        AliESDtrackCuts::kAny);
-  // 7*(0.0026+0.0050/pt^1.01)
-  esdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
-
-  esdTrackCuts->SetMaxDCAToVertexZ(2);
-  esdTrackCuts->SetDCAToVertex2D(kFALSE);
-  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
-  //---<
-
-  esdTrackCuts->SetEtaRange(-0.9, 0.9);
-  
-  const TObjArray* seltrk = esdTrackCuts->GetAcceptedTracks(fESD);
-  const Int_t n0=seltrk->GetEntries();
-  const AliESDtrack * trks[n0];
-  Int_t nsel=0;
-  for(Int_t ii=0; ii<n0; ii++){
-    trks[ii]=0x0;
-    const AliESDtrack *esdtrack = (AliESDtrack *)(seltrk->At(ii));
-
-    /*
-    if(!CutTrack(esdtrack))
-      continue;
-    */
-
-    trks[nsel++]=esdtrack;
-  }
-
-  delete seltrk;
-  delete esdTrackCuts;
-
-  fv0ntrk->Fill(nsel,GetV0());
-
-  fhntrk->Fill(nsel);
-
-  frsntrk->Fill(fESD->GetNumberOfTracks(), nsel);
-
-  if(nsel>=fnsel1)
-    return 0;
-
-  for(Int_t ii=0; ii<nsel; ii++){
-    outtrk[ii]=trks[ii];
-  }
-
-  return nsel;
-}
-
-/*
-Bool_t AliAnalysisTaskDDMeson::CutTrack(const AliESDtrack *  esdtrack) const 
-{
-  //
-  //track cut
-  //  
-
-  return kTRUE;
-}
-*/
-
-//=================================================================================
-
-void AliAnalysisTaskDDMeson::SwapTrack(const AliESDtrack * trks[]) const 
-{
-  //
-  //swap two esdtracks
-  //
-  const AliESDtrack * tmpt = trks[0];
-  trks[0]=trks[1];
-  trks[1]=tmpt;
-}
-
-Int_t AliAnalysisTaskDDMeson::GetV0() const
-{
-  //
-  //V0 bit combination
-  //
-
-  const Bool_t ka = (fBitcg & fCHECKVBA);
-  const Bool_t kc = (fBitcg & fCHECKVBC);
-  
-
-  //a1c0 a0c1 must be adjacent so that a cut for signal gas can be eaily applied
-  const Int_t a0c0 = 1;
-  const Int_t a1c0 = 2;
-  const Int_t a0c1 = 3;
-  const Int_t a1c1 = 4;
-
-  if(!ka && !kc)
-    return a0c0;
-  else{
-    if(ka && kc)
-      return a1c1;
-    else if(ka)
-      return a1c0;
-    else 
-      return a0c1;
-  }
-}
-
-Int_t AliAnalysisTaskDDMeson::GetCombCh(const Double_t s1, const Double_t s2) const
-{
-  //
-  //get combination of charges
-  //
-  const Int_t combPP = 1;
-  const Int_t combMM = 2;
-  const Int_t combPM = 3;
-
-  if(s1*s2<0){
-    return combPM;
-  }
-  else if(s1>0)
-    return combPP;
-  else
-    return combMM;
-}
-
-//==========================================================================
-
-TLorentzVector AliAnalysisTaskDDMeson::GetKinematics(const Double_t *pa, const Double_t *pb, const Double_t ma, const Double_t mb, Double_t & cts) const
-{
-  //
-  //get kinematics, cts = cos(theta_{#star})
-  //
-  TLorentzVector va, vb, sumv;
-  va.SetXYZM(pa[0], pa[1], pa[2], ma);
-  vb.SetXYZM(pb[0], pb[1], pb[2], mb);
-  sumv = va+vb;
-
-  const TVector3 bv = -sumv.BoostVector();
-
-  va.Boost(bv);
-  vb.Boost(bv);
-  //printf("test a %f %f %f -- %f %f\n", va.X(), va.Y(), va.Z(), va.Theta(), va.Phi());
-  //printf("test b %f %f %f -- %f %f\n", vb.X(), vb.Y(), vb.Z(), vb.Theta(), vb.Phi());
-
-  cts = fabs(cos(va.Theta()));
-
-  return sumv;
-}
-
-Double_t AliAnalysisTaskDDMeson::GetCtlab(const Double_t *pa, const Double_t *pb) const 
-{
-  //
-  //cos(theat_lab)
-  //
-
-  TVector3 va, vb;
-  va.SetXYZ(pa[0], pa[1], pa[2]);
-  vb.SetXYZ(pb[0], pb[1], pb[2]);
-
-  const TVector3 ua = va.Unit();
-  const TVector3 ub = vb.Unit();
-
-  return ua.Dot(ub);
-}
diff --git a/PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.h b/PWGUD/DIFFRACTIVE/AliAnalysisTaskDDMeson.h
deleted file mode 100644 (file)
index 8cff2a2..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*************************************************************************
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
-*                                                                        *
-* Author: The ALICE Off-line Project.                                    *
-* Contributors are mentioned in the code where appropriate.              *
-*                                                                        *
-* Permission to use, copy, modify and distribute this software and its   *
-* documentation strictly for non-commercial purposes is hereby granted   *
-* without fee, provided that the above copyright notice appears in all   *
-* copies and that both the copyright notice and this permission notice   *
-* appear in the supporting documentation. The authors make no claims     *
-* about the suitability of this software for any purpose. It is          *
-* provided "as is" without express or implied warranty.                  *
-**************************************************************************/
-//
-// Select events accroding to L0 trigger input
-// Reconstruct 2pi mass
-// save charge, Armenteros' x and y,  pid, momentum
-//
-
-#ifndef ALIANALYSISTASKDDMESON_H
-#define ALIANALYSISTASKDDMESON_H
-
-#ifndef ALIANALYSISTASK_H
-#include "AliAnalysisTaskSE.h"
-#endif
-
-class AliESDEvent; 
-class AliESDtrack;
-
-class TH1I;
-class TH2I;
-class TH2D;
-class TList; 
-class THnSparse;
-class TLorentzVector;
-
-class AliAnalysisTaskDDMeson : public AliAnalysisTaskSE{
-  public:
-
-    AliAnalysisTaskDDMeson(const TString opt);
-    AliAnalysisTaskDDMeson(const AliAnalysisTaskDDMeson  &p);
-    AliAnalysisTaskDDMeson& operator=(const AliAnalysisTaskDDMeson  &p);
-    virtual ~AliAnalysisTaskDDMeson();
-    
-    virtual void UserCreateOutputObjects();
-    virtual void UserExec(Option_t *);
-    virtual void Terminate(Option_t *);
-
-    void IniTask();
-
-    Bool_t CheckESD();
-    Bool_t CheckBit();
-    Int_t CutESD(const AliESDtrack *outtrk[]);
-    //Bool_t CutTrack(const AliESDtrack * esdtrack) const;
-
-    //------
-    void SwapTrack(const AliESDtrack * trks[]) const;
-
-    Int_t GetV0() const;
-    Int_t GetCombCh(const Double_t s1, const Double_t s2) const;
-
-    TLorentzVector GetKinematics(const Double_t *pa, const Double_t *pb, const Double_t ma, const Double_t mb, Double_t & cts) const;
-    Double_t GetCtlab(const Double_t *pa, const Double_t *pb) const;
-
-    void CheckRange(Double_t &ptv, Double_t &pta, Double_t &etaa
-                    , Double_t &mpi
-                    ) const;
-
-    void FillBit();
-    void CalcBit(TH1I *hc, Double_t tot[]) const;
-
-    //---
-    void SPDLoadGeom() const;
-    Bool_t SPDLoc2Glo(const Int_t id, const Double_t *loc, Double_t *glo) const;
-    Bool_t CheckChipEta(const Int_t chipKey) const;
-    void GetNFO(Int_t &ni, Int_t &no) const;
-
- private:
-    TString fOpt;                            //option
-    AliESDEvent *fESD;                          //esd event                    
-    //------
-
-    Int_t fnmass;                          //nbins for mass
-    Double_t fmass1;                       //upper edge of axis   
-
-    Int_t fnptv;                             //nbins for p
-    Double_t fptv1;                         //upper edge of axis  
-
-    Int_t fnpta;                             //nbins for p
-    Double_t fpta1;                         //upper edge of axis  
-
-    Int_t fneta;                           //nbins for eta
-    Double_t feta;                        //upper edge of axis
-
-    Int_t fnnsel;                           //nbins for nsel
-    Double_t fnsel1;                        //upper edge of axis
-
-    Int_t fncts;                            //nbins for cts
-    Int_t fnctlab;                           //nbins for ctlab
-
-    //------
-    Int_t fCHECKVBA;                       //V0A bit
-    Int_t fCHECKVBC;                       //V0C bit
-
-    TH1I *fHBIT;                                //histogram of bits
-    Int_t fBitcg;                                 //trigger bit configuration
-    Int_t fRun;                                   //run number
-    TH1I *fat;                                  //V0A-only
-    TH1I *fct;                                  //V0C-only
-    TH1I *fbt;                                  //V0A & V0C
-    TH1I *fnt;                                  //!V0A & !V0C
-    TH1I *ftt;                                  //TOTAL
-
-    //------
-    TH2D *fv0ntrk;                               //v0bit vs. nch
-    TH2D *frsntrk;                               //raw vs. sel
-
-    TH1I *fhps;                                 //V0 BG
-    TH2I *fhfo; //SPD fastor hardware, in eta acceptance
-    TH1I *fhspd;//SPD fastor offline
-    TH2I *fhv0fmd; //v0 vs fmd
-    TH1I *fhpriv;                               //primary vertex cut effect
-    TH1I *fhntrk;                               //n-trk-after-cut effect
-
-    //------
-    TList *fHist;                             //output list
-    THnSparse *fThnMass;                    //ThnSparse for mother pt and Mass
-    THnSparse *fThnDPt;                    //ThnSparse for pt and eta of daughter
-    THnSparse *fThnDEta;                    //ThnSparse for pt and eta of daughter
-    THnSparse *fThnKF; //kf
-    ClassDef(AliAnalysisTaskDDMeson, 1);
-};
-
-
-#endif
-
diff --git a/PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.cxx b/PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.cxx
new file mode 100644 (file)
index 0000000..32ad0f6
--- /dev/null
@@ -0,0 +1,434 @@
+/*************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Example analysis for diffractive studies
+//
+// Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TList.h>
+
+
+#include "AliAODInputHandler.h"
+#include "AliAODHandler.h"
+#include "AliESDInputHandler.h"
+#include "AliPIDResponse.h"
+#include "AliPhysicsSelection.h"
+
+#include "AliCDMesonBaseStripped.h"
+#include "AliCDMesonUtilsStripped.h"
+#include "AliCDMesonTracks.h"
+#include "AliAnalysisTaskCDex.h"
+
+
+//------------------------------------------------------------------------------
+AliAnalysisTaskCDex::AliAnalysisTaskCDex(const char* name):
+       AliAnalysisTaskSE(name)
+       , fDoAOD(kFALSE)
+       , fMaxVtxDst(0.5) // value to be checked with the vertex study histograms
+
+       , fESDEvent(0x0)
+       , fAODEvent(0x0)
+       , fPIDResponse(0x0)
+       , fTracks(new AliCDMesonTracks())
+       , fVtxDst(-1.)
+       , fVtxZ(-20)
+       , fResidualTracks(0)
+       , fResidualTracklets(0)
+       , fMCprocessType(0)
+       , fMCprocess(-1)
+
+       , fRun(-999)
+       , fCurrentGapCondition(0)
+
+       , fHist(0x0)
+
+       , fv0ntrk(0x0)
+       , fv0fmdntrk(0x0)
+       , fv0fmdspdntrk(0x0)
+       , fv0fmdspdtpcntrk(0x0)
+
+       , fhStatsFlow(0x0)
+{
+       //
+       // standard constructor
+       //
+       // slot in TaskSE must start from 1
+       DefineOutput(1, TList::Class());
+
+       // initialize gap information
+       for (Int_t iGap = 0; iGap < kMax; ++iGap) {
+               fGapInformation[iGap] = 0;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+AliAnalysisTaskCDex::~AliAnalysisTaskCDex()
+{
+       //
+       // destructor
+       //
+
+       if (fHist) {
+               fHist->Clear();
+               delete fHist;
+               fHist = 0x0;
+       }
+
+       if (fTracks) {
+               delete fTracks;
+               fTracks = 0x0;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+void AliAnalysisTaskCDex::UserCreateOutputObjects()
+{
+       //
+       // createOutputObjects
+       //
+
+       //= TList for Histograms =====================================================
+       fHist = new TList;
+       fHist->SetOwner(); // ensures that the histograms are all deleted on exit!
+
+       //= MULTIPLICITY PER GAP CONDITION =
+       fv0ntrk = new TH2D("b00_v0ntrk", ";number of tracks;gap condition",
+                          80, 0., 80., 4, 1., 5.);
+       //x: ntrk; y: V0
+       fHist->Add(fv0ntrk);
+
+       fv0fmdntrk = new TH2D("b01_v0fmdntrk", ";number of tracks;gap condition",
+                                     80, 0., 80., 4, 1., 5.);
+       //x: ntrk; y: V0FMD
+       fHist->Add(fv0fmdntrk);
+
+       fv0fmdspdntrk =
+               new TH2D("b02_v0fmdspdntrk", ";number of tracks;gap condition",
+                        80, 0., 80., 4, 1., 5.);
+       //x: ntrk; y: V0FMDSPD
+       fHist->Add(fv0fmdspdntrk);
+
+       fv0fmdspdtpcntrk =
+               new TH2D("b03_v0fmdspdtpcntrk", ";number of tracks;gap condition",
+                        80, 0., 80., 4, 1., 5.);
+       //x: ntrk; y: V0FMDSPDTPC
+       fHist->Add(fv0fmdspdtpcntrk);
+
+
+       //= STATISTICS FLOW =
+       fhStatsFlow = AliCDMesonBaseStripped::GetHistStatsFlow();
+       fHist->Add(fhStatsFlow);
+}
+
+
+//------------------------------------------------------------------------------
+void AliAnalysisTaskCDex::UserExec(Option_t *)
+{
+       //
+       // executed for every event which passed the physics selection
+       //
+       // in order to select only correct minimum bias events,
+       // SetCollisionCandidates(AliVEvent::kMB) should be used
+
+       fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinTotalInput); // stats flow
+
+       //= INPUT DATA SANITY TESTS ==================================================
+       if(!CheckInput()) {
+               PostOutputs();
+               return;
+       }
+
+       fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinGoodInput); // stats flow
+
+       //= EVENT SELECTION ==========================================================
+       Bool_t eventIsValid = (fDoAOD) ?
+               AliCDMesonUtilsStripped::CutEvent(fAODEvent) :
+               AliCDMesonUtilsStripped::CutEvent(fESDEvent);
+       if (!eventIsValid) {
+               PostOutputs();
+               return;
+       }
+
+       fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinEventsAfterCuts); // stats flow
+
+       //= PILE UP ==================================================================
+       const Bool_t isPileup = (fDoAOD) ?
+               fAODEvent->IsPileupFromSPD(2, 0.8, 3., 2., 5.) :
+               fESDEvent->IsPileupFromSPD(2, 0.8, 3., 2., 5.);
+       // using only 2 instead of three contributors
+
+       if (isPileup) {
+               PostOutputs();
+               return;
+       }
+
+       fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinEventsWithOutPileUp);
+
+       //= GAP ======================================================================
+       // determine the complete gap configuration (for all gap-tagging detectors)
+       if (!DetermineGap()) {
+               PostOutputs();
+               return;
+       }
+
+       //= VERTEX COINCIDENCE AND POSITION ==========================================
+       AnalyzeVtx();
+       if (!(abs(fVtxZ) < 4.)) { // vertex from tracks within +/-4cm
+               //PostOutputs();
+               //return;
+       }
+
+       //= TRACK CUTS ===============================================================
+       fTracks->ProcessEvent(fAODEvent, fESDEvent, kTRUE);
+       // apply cuts (including soft)
+       DoMultiplicityStudy(); // fill corresponding histograms
+
+       // is multiplicity within the desired range of  2 to 3?
+       Int_t nch = fTracks->GetTracks();
+       Int_t ncombined = fTracks->GetCombinedTracks();
+
+       //============================================================================
+       //=== USER ANALYSIS CODE =====================================================
+       //============================================================================
+       for (Int_t iTrack = 0; iTrack < ncombined; ++iTrack) { // including soft
+               AliVTrack* trk = fTracks->GetTrack(iTrack);
+               trk->GetID(); // prevent warning...
+       }
+       for (Int_t iTrack = 0; iTrack < nch; ++iTrack) { // excluding soft tracks
+               AliVTrack* trk = fTracks->GetTrack(iTrack);
+               trk->GetID(); // prevent warning...
+       }
+
+       if (fGapInformation[kV0FMDSPDTPC] == AliCDMesonBaseStripped::kBinDG) {
+               // event is a full double gap event
+       }
+
+       //============================================================================
+       PostOutputs();
+}
+
+
+//------------------------------------------------------------------------------
+void AliAnalysisTaskCDex::PostOutputs()
+{
+       //
+       // PostData
+       //
+       // this function is main of use with multiple output containers
+
+       PostData(1, fHist);
+}
+
+
+//------------------------------------------------------------------------------
+Bool_t AliAnalysisTaskCDex::CheckInput()
+{
+       //
+       // general protection of the task against malicious input data
+       //
+       if (const AliESDInputHandler *esdH =
+           dynamic_cast<AliESDInputHandler*>(fInputHandler)){
+               fESDEvent = esdH->GetEvent();
+       }
+       else if (const AliAODInputHandler *aodH =
+                dynamic_cast<AliAODInputHandler*>(fInputHandler)){
+               fAODEvent = aodH->GetEvent();
+               fDoAOD = kTRUE;
+       }
+       fPIDResponse = (AliPIDResponse*)fInputHandler->GetPIDResponse();
+
+       if(!fESDEvent && !fAODEvent){
+               printf("AliAnalysisTaskex - No valid event\n");
+               return kFALSE;
+       }
+
+       if(!fPIDResponse){
+               printf("AliAnalysisTaskex -  No PIDd\n");
+               // PID is fixed to unknown
+               //return kFALSE;
+       }
+
+       if(fDoAOD && fabs(fAODEvent->GetMagneticField())<1){
+               printf("AliAnalysisTaskex - strange Bfield! %f\n",
+                      fAODEvent->GetMagneticField());
+               return kFALSE;
+       }
+       else if((!fDoAOD) && fabs(fESDEvent->GetMagneticField())<1){
+               printf("AliAnalysisTaskex - strange Bfield! %f\n",
+                      fESDEvent->GetMagneticField());
+               return kFALSE;
+       }
+
+       Int_t tmprun = 0;
+       if (fDoAOD) {
+               tmprun = fAODEvent->GetRunNumber();
+       }
+       else {
+               tmprun = fESDEvent->GetRunNumber();
+       }
+
+       if(fRun!=tmprun){
+               fRun = tmprun;
+               AliCDMesonUtilsStripped::SPDLoadGeom(fRun);
+       }
+
+       return kTRUE;
+}
+
+
+//------------------------------------------------------------------------------
+Bool_t AliAnalysisTaskCDex::DetermineGap()
+{
+       // determines the gap configuration for all gap tagging detectors based on the
+       // data set which is available
+       //
+
+       if (fDoAOD) {
+               AliAODHandler* aodHandler =
+                       (AliAODHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+               TTree *aodTree = aodHandler->GetTree();
+               aodTree->SetBranchAddress("gapCondition", &fCurrentGapCondition);
+               aodTree->GetEvent(Entry()); // seems to be needed! (loads current event)
+               if (!fCurrentGapCondition) {
+                       fCurrentGapCondition = 0xfffe;
+                       puts("freidtlog - error while gap condition determination using AODs\n");
+                       return kFALSE;
+               }
+       }
+       else {
+               // gap determination from detector information
+               fCurrentGapCondition = AliCDMesonUtilsStripped::GetGapConfig(fESDEvent);
+
+               // gap determination from preprocessed detector information
+               /*
+               AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+               TTree* esdTree = am->GetInputEventHandler()->GetTree(); // get ESD tree
+               if (esdTree) {
+                       esdTree->SetBranchAddress("gapCondition", &fCurrentGapCondition);
+                       esdTree->GetEvent(Entry()); // seems to be needed! (loads current event)
+               }
+               */
+
+               if (!fCurrentGapCondition) {
+                       fCurrentGapCondition = 0xfffe;
+                       puts("freidtlog - error while gap condition determination using ESDs\n");
+                       return kFALSE;
+               }
+       }
+
+       // disentagle the contributions to the gap conditions of different "tightness"
+       fGapInformation[kV0] =
+               AliCDMesonBaseStripped::GetGapBin("V0", fCurrentGapCondition);
+       fGapInformation[kV0FMD] =
+               AliCDMesonBaseStripped::GetGapBin("V0FMD", fCurrentGapCondition);
+       fGapInformation[kV0FMDSPD] =
+               AliCDMesonBaseStripped::GetGapBin("V0FMDSPD", fCurrentGapCondition);
+       fGapInformation[kV0FMDSPDTPC] =
+               AliCDMesonBaseStripped::GetGapBin("V0FMDSPDTPC", fCurrentGapCondition);
+       fGapInformation[kFMD] =
+               AliCDMesonBaseStripped::GetGapBin("FMD",fCurrentGapCondition);
+       fGapInformation[kSPD] =
+               AliCDMesonBaseStripped::GetGapBin("SPD",fCurrentGapCondition);
+       fGapInformation[kTPC] =
+               AliCDMesonBaseStripped::GetGapBin("TPC",fCurrentGapCondition);
+
+       return kTRUE;
+}
+
+
+//------------------------------------------------------------------------------
+void AliAnalysisTaskCDex::DoMultiplicityStudy()
+{
+       // stores the multiplicity distributions for different gap conditions and
+       // adds some information to the statsFlow histogram
+       //
+
+       // retrieve values from the track object
+       Int_t ntrk0 = fTracks->GetTracksBeforeCuts(); // number of tracks before cuts
+       //Int_t nch = fTracks->GetTracks(); // number of good ITS-TPC primaries
+       Int_t ncombined = fTracks->GetCombinedTracks(); // number ITSTPC and ITS only
+       Int_t nITSpureSA = fTracks->GetITSpureSACount(); // number ITS standalone
+
+       // determine the residual tracks / tracklets
+       fResidualTracks = ntrk0 - ncombined - nITSpureSA;
+       fResidualTracklets = fTracks->GetRemainingTrackletsCentralBarrel();
+
+       // multiplicity distributions for different gaps
+       fv0ntrk->Fill(ncombined, fGapInformation[kV0]);
+       fv0fmdntrk->Fill(ncombined, fGapInformation[kV0FMD]);
+       fv0fmdspdntrk->Fill(ncombined, fGapInformation[kV0FMDSPD]);
+       fv0fmdspdtpcntrk->Fill(ncombined, fGapInformation[kV0FMDSPDTPC]);
+
+       if (fGapInformation[kV0] == AliCDMesonBaseStripped::kBinDG) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0Gap);
+       }
+       if (fGapInformation[kV0FMD] == AliCDMesonBaseStripped::kBinDG) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdGap);
+       }
+       if (fGapInformation[kV0FMDSPD] == AliCDMesonBaseStripped::kBinDG) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdspdGap);
+       }
+       if (fGapInformation[kV0FMDSPDTPC] == AliCDMesonBaseStripped::kBinDG) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdspdtpcGap);
+       }
+
+       // event cleanliness
+       if (fResidualTracks == 0) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinResidualTracks);
+       }
+       if (fResidualTracklets == 0) {
+               fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinResidualTracklets);
+       }
+}
+
+
+//--------------------------------------------------------------------------
+void AliAnalysisTaskCDex::AnalyzeVtx()
+{
+       // calculates the distance between the vertex obtain from tracks and the
+       // vertex obtain from spd tracklets
+       // stores the z position of the primary vertex from tracks
+
+       fVtxDst = 0.; // reset distance
+
+       // retrieve the pointers of the current primary vertices
+       AliVVertex* trackVtx = (fDoAOD) ?
+               (AliVVertex*)fAODEvent->GetPrimaryVertex() :
+               (AliVVertex*)fESDEvent->GetPrimaryVertexTracks();
+       AliVVertex* spdVtx = (fDoAOD) ?
+               (AliVVertex*)fAODEvent->GetPrimaryVertexSPD() :
+               (AliVVertex*)fESDEvent->GetPrimaryVertexSPD();
+
+       fVtxZ = trackVtx->GetZ(); // store the vertex z position
+
+       if (fDoAOD && (trackVtx == spdVtx)) { // no primary track vertex in the AOD
+               fVtxDst = -5; // set arbitrary distance (counted in underflow bin!)
+       }
+       else { // do proper calculation of the geometrical distance
+               fVtxDst += (trackVtx->GetX()-spdVtx->GetX())
+                       * (trackVtx->GetX()-spdVtx->GetX());
+               fVtxDst += (trackVtx->GetY()-spdVtx->GetY())
+                       * (trackVtx->GetY()-spdVtx->GetY());
+               fVtxDst += (trackVtx->GetZ()-spdVtx->GetZ())
+                       * (trackVtx->GetZ()-spdVtx->GetZ());
+               fVtxDst = TMath::Sqrt(fVtxDst);
+       }
+}
diff --git a/PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.h b/PWGUD/DIFFRACTIVE/example/AliAnalysisTaskCDex.h
new file mode 100644 (file)
index 0000000..9ee678e
--- /dev/null
@@ -0,0 +1,122 @@
+/*************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Example analysis for diffractive studies
+//
+// Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#ifndef ALIANALYSISTASKCDEX_H
+#define ALIANALYSISTASKCDEX_H
+
+#ifndef ALIANALYSISTASK_H
+#include "AliAnalysisTaskSE.h"
+#endif
+
+class AliESDEvent;
+class AliVTrack;
+class AliPIDResponse;
+class AliPhysicsSelection;
+
+class TH1I;
+class TH1F;
+class TH2I;
+class TH2F;
+class TH2D;
+class TList;
+class THnSparse;
+class TObjString;
+
+class AliCDMesonTracks;
+
+class AliAnalysisTaskCDex : public AliAnalysisTaskSE
+{
+public:
+
+       AliAnalysisTaskCDex(const char* name);
+       virtual ~AliAnalysisTaskCDex();
+
+       virtual void UserCreateOutputObjects();
+       virtual void UserExec(Option_t *);
+
+private:
+       enum { //
+               kV0 = 0,
+               kFMD,
+               kSPD,
+               kTPC,
+               kV0FMD,
+               kV0FMDSPD,
+               kV0FMDSPDTPC,
+               kMax
+       };
+
+       AliAnalysisTaskCDex(const AliAnalysisTaskCDex  &p);
+       AliAnalysisTaskCDex& operator=(const AliAnalysisTaskCDex  &p);
+
+       void FillEtaPhiMaps() const; // controls which event contributes to which map
+
+
+       // functions called by the UserExec(...), not to be called elsewhere!
+       //-------------------------------------------------------------------
+       Bool_t CheckInput();
+       void PostOutputs(); // cares about posting the output before exiting UserExec,
+       // WARNING: PostOutputs should only be used directly in the UserExec!!
+       Bool_t DetermineGap(); // determines the gap of all available detectors
+       void AnalyzeVtx(); // calcs the distance of the pri. vertex from tracks and SPD
+       void DoMultiplicityStudy(); // multiplicity distributions for different gaps
+
+       // analysis task status
+       //---------------------
+       Bool_t fDoAOD; // true for running on AODs
+       Double_t fMaxVtxDst; // maximum distance of the track and SPD vertex
+
+       // event information
+       //------------------
+       AliESDEvent *fESDEvent; // esd event object
+       AliAODEvent *fAODEvent; // esd event object
+       AliPIDResponse *fPIDResponse; // pid object (for ESDs and AODs)
+       AliCDMesonTracks *fTracks; // object taking care about the track cuts
+       Double_t fVtxDst; // distance of the primary vertex from tracks and from SPD
+       Double_t fVtxZ; // z-position of the primary vertex from tracks
+       Int_t fResidualTracks; // tracks rejected by cuts within the event
+       Int_t fResidualTracklets; // SPD tracklets not assigned to tracks
+       Int_t fMCprocessType; // MC process type, 0 for data
+       Int_t fMCprocess; // detailed MC sub process information
+
+       Int_t fRun; // number of the run which is about to be processed
+       Int_t fCurrentGapCondition; // gap condition of the current event
+       Int_t fGapInformation[kMax]; // gap condition for different detectors
+                                    // individually and their combinations
+
+       // output objects
+       //---------------
+
+       TList *fHist; // output list (contains all histograms)
+
+       // Multiplicity distributions for the different gap conditions
+       TH2D *fv0ntrk; //v0bit vs. nch
+       TH2D *fv0fmdntrk; //v0fmdbit vs. nch
+       TH2D *fv0fmdspdntrk; //v0fmdspdbit vs. nch
+       TH2D *fv0fmdspdtpcntrk; //v0fmdspdtpcbit vs. nch
+
+       // Statistics flow diagrams
+       TH1F *fhStatsFlow; // stepwise statistics flow
+
+       ClassDef(AliAnalysisTaskCDex, 1);
+};
+
+
+#endif
diff --git a/PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.cxx b/PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.cxx
new file mode 100644 (file)
index 0000000..ca8cf46
--- /dev/null
@@ -0,0 +1,95 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonBaseStripped
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#include "TH1F.h"
+#include "TString.h"
+
+#include "AliCDMesonBaseStripped.h"
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonBaseStripped::GetGapBin(TString tag, const Int_t gapcg)
+{
+       //
+       // retrieve gap topology for a given string
+       //
+
+       tag.ToUpper();
+
+       Bool_t ka = kFALSE, kc = kFALSE;
+
+       if(tag.Contains("V0")){
+               ka = ka || (gapcg & kBitV0A);
+               kc = kc || (gapcg & kBitV0C);
+       }
+       if(tag.Contains("FMD")){
+               ka = ka || (gapcg & kBitFMDA);
+               kc = kc || (gapcg & kBitFMDC);
+       }
+       if(tag.Contains("SPD")){
+               ka = ka || (gapcg & kBitSPDA);
+               kc = kc || (gapcg & kBitSPDC);
+       }
+       if(tag.Contains("TPC")){
+               ka = ka || (gapcg & kBitTPCA);
+               kc = kc || (gapcg & kBitTPCC);
+       }
+       if(ka && kc)
+               return kBinNG;
+       else{
+               if(!ka && !kc)
+                       return kBinDG;
+               else if(!kc)
+                       return kBinGC;
+               else
+                       return kBinGA;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+TH1F* AliCDMesonBaseStripped::GetHistStatsFlow()
+{
+       //
+       // setup the stats flow histogram
+       //
+
+       TH1F *hist = new TH1F("c00_statsFlow", "",
+                             AliCDMesonBaseStripped::kBinLastValue,
+                             0, AliCDMesonBaseStripped::kBinLastValue);
+       TAxis* axis = hist->GetXaxis();
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinTotalInput+1, "total Input");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinGoodInput+1, "good ESDs");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinEventsAfterCuts+1,"after cuts");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinEventsWithOutPileUp+1,
+                         "w/o pile up");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinv0Gap+1, "with V0 DG gap");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinv0fmdGap+1,
+                         "with V0-FMD DG gap");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinv0fmdspdGap+1,
+                         "with V0-FMD-SPD DG gap");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinv0fmdspdtpcGap+1,
+                         "with V0-FMD-SPD-TPC DG gap");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinResidualTracks+1,
+                         "without residual tracks");
+       axis->SetBinLabel(AliCDMesonBaseStripped::kBinResidualTracklets+1,
+                         "without residual tracklets");
+       return hist;
+}
diff --git a/PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.h b/PWGUD/DIFFRACTIVE/example/AliCDMesonBaseStripped.h
new file mode 100644 (file)
index 0000000..06071ce
--- /dev/null
@@ -0,0 +1,69 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonBaseStripped
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#ifndef ALICDMESONBASESTRIPPED_H
+#define ALICDMESONBASESTRIPPED_H
+
+class TH1F;
+
+class AliCDMesonBaseStripped
+{
+public:
+       enum{
+               // gap Conditions
+               kBinDG = 1, // double gap
+               kBinGC, // single gap c side
+               kBinGA, // single gap a side
+               kBinNG, // no gap
+
+               // StatsFlow histogram entries
+               // names for the bins are specified in the .cxx-file
+               kBinTotalInput = 0,
+               kBinGoodInput,
+               kBinEventsAfterCuts,
+               kBinEventsWithOutPileUp,
+               kBinv0Gap,
+               kBinv0fmdGap,
+               kBinv0fmdspdGap,
+               kBinv0fmdspdtpcGap,
+               kBinResidualTracks,
+               kBinResidualTracklets,
+               kBinLastValue, // used to specify the correct histogram width
+
+
+               // gap-condition bits used in AliAnalysisTaskCDMeson::fGapRun
+               kBitBaseLine = (1<<0),
+
+               kBitV0A  = (1<<1),
+               kBitV0C  = (1<<2),
+               kBitFMDA = (1<<3),
+               kBitFMDC = (1<<4),
+
+               kBitSPDA  = (1<<5),
+               kBitSPDC  = (1<<6),
+               kBitTPCA  = (1<<7),
+               kBitTPCC  = (1<<8),
+       };
+
+       static Int_t GetGapBin(const TString tag, const Int_t gapcg);
+       static TH1F* GetHistStatsFlow();
+};
+
+#endif
diff --git a/PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.cxx b/PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.cxx
new file mode 100644 (file)
index 0000000..8bcfbed
--- /dev/null
@@ -0,0 +1,413 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonUtilsStripped
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TGeoMatrix.h>
+#include <THnSparse.h>
+#include <TLorentzVector.h>
+#include <TRandom3.h>
+#include <TParticle.h>
+
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliCDBStorage.h"
+#include "AliESDEvent.h"
+#include "AliPIDResponse.h"
+#include "AliVTrack.h"
+#include "AliVParticle.h"
+#include "AliESDtrack.h"
+#include "AliESDFMD.h"
+#include "AliGeomManager.h"
+#include "AliITSAlignMille2Module.h"
+#include "AliITSsegmentationSPD.h"
+#include "AliMultiplicity.h"
+#include "AliPIDResponse.h"
+#include "AliSPDUtils.h"
+#include "AliTriggerAnalysis.h"
+
+#include "AliAODTracklets.h"
+#include "AliAODEvent.h"
+
+#include "AliCDMesonBaseStripped.h"
+#include "AliCDMesonTracks.h"
+
+#include "AliCDMesonUtilsStripped.h"
+
+
+//==============================================================================
+//------------------------------------------------------------------------------
+Bool_t AliCDMesonUtilsStripped::CutEvent(const AliESDEvent *ESDEvent)
+{
+       //
+       // CutEvent
+       //
+
+       AliTriggerAnalysis triggerAnalysis;
+
+       // collision vertex cut
+       // A cut in XY is implicitly done during the reconstruction by constraining
+       // the vertex to the beam diamond.
+
+       // Primary vertex
+       Bool_t kpr0 = kTRUE;
+       const AliESDVertex *vertex = ESDEvent->GetPrimaryVertexTracks();
+       if(vertex->GetNContributors()<1) {
+               // SPD vertex
+               vertex = ESDEvent->GetPrimaryVertexSPD();
+               if(vertex->GetNContributors()<1) {
+                       // NO GOOD VERTEX, SKIP EVENT
+                       kpr0 = kFALSE;
+               }
+       }
+       const Bool_t kpriv = kpr0 && (fabs(ESDEvent->GetPrimaryVertex()->GetZ())<10.);
+       // 10 is the common value, unit: cm
+       if(!kpriv)
+               return kFALSE;
+
+       return kTRUE;
+}
+
+//------------------------------------------------------------------------------
+Bool_t AliCDMesonUtilsStripped::CutEvent(const AliAODEvent *AODEvent)
+{
+       //
+       // Cut Event for AOD Events, to be combined with the ESD Track Cut
+       //
+
+       // TODO: no idea about fast or yet, to be thought of
+
+       // Primary vertex
+       Bool_t kpr0 = kTRUE;
+       const AliAODVertex *vertex = AODEvent->GetPrimaryVertex();
+       if(vertex->GetNContributors()<1) {
+               // SPD vertex
+               vertex = AODEvent->GetPrimaryVertexSPD();
+               if(vertex->GetNContributors()<1) {
+                       // NO GOOD VERTEX, SKIP EVENT
+                       kpr0 = kFALSE;
+               }
+       }
+       const Bool_t kpriv = kpr0 && (fabs(AODEvent->GetPrimaryVertex()->GetZ())<10.);
+       // 10 is the common value, unit: cm
+
+       if(!kpriv)
+               return kFALSE;
+
+       return kTRUE;
+}
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::GetGapConfig(const AliESDEvent *ESDEvent)
+{
+       //
+       // GetGapConfigAndTracks
+       //
+       // retrieves the gap configuration of a track and returns it as
+       // an bit vector
+       // kBaseLine ensures, that this event is valid
+       // + is equivalent to | in this case
+       return AliCDMesonBaseStripped::kBitBaseLine
+               + GetV0(ESDEvent) + GetFMD(ESDEvent) + GetSPD(ESDEvent) + GetTPC(ESDEvent);
+}
+
+
+//==============================================================================
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::GetV0(const AliESDEvent * ESDEvent)
+{
+       //
+       //GetV0
+       //
+
+       AliTriggerAnalysis triggerAnalysis;
+       const Bool_t khw = kFALSE;
+       const Bool_t v0A =
+               (triggerAnalysis.V0Trigger(ESDEvent, AliTriggerAnalysis::kASide, khw) ==
+                AliTriggerAnalysis::kV0BB);
+       const Bool_t v0C =
+               (triggerAnalysis.V0Trigger(ESDEvent, AliTriggerAnalysis::kCSide, khw) ==
+                AliTriggerAnalysis::kV0BB);
+
+       return v0A * AliCDMesonBaseStripped::kBitV0A
+               + v0C * AliCDMesonBaseStripped::kBitV0C;
+}
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::GetFMD(const AliESDEvent *ESDEvent)
+{
+       //
+       // GetFMD
+       //
+
+       AliTriggerAnalysis triggerAnalysis;
+       triggerAnalysis.SetFMDThreshold(0.3, 0.5); // parameters got from FMD
+       const Bool_t fmdA =
+               triggerAnalysis.FMDTrigger(ESDEvent, AliTriggerAnalysis::kASide);
+       const Bool_t fmdC =
+               triggerAnalysis.FMDTrigger(ESDEvent, AliTriggerAnalysis::kCSide);
+
+       return fmdA * AliCDMesonBaseStripped::kBitFMDA
+               + fmdC * AliCDMesonBaseStripped::kBitFMDC;
+}
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::GetSPD(const AliESDEvent *ESDEvent)
+{
+       //
+       // GetSPD
+       //
+
+       Int_t nfoctr[10];
+       GetNFO(ESDEvent, "]0.9[", nfoctr);
+       // get multiplicity from fastOR and fill corresponding hit maps
+
+
+       const Int_t ipA = nfoctr[kIPA]; // inner layer A side
+       const Int_t ipC = nfoctr[kIPC]; // inner layer C side
+       const Int_t opA = nfoctr[kOPA]; // outer layer A side
+       const Int_t opC = nfoctr[kOPC]; // outer layer C side
+
+       const Bool_t spdA = ipA + opA; // A side hit?
+       const Bool_t spdC = ipC + opC; // C side hit?
+
+       return spdA * AliCDMesonBaseStripped::kBitSPDA
+               + spdC * AliCDMesonBaseStripped::kBitSPDC;
+}
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::GetTPC(const AliESDEvent * ESDEvent)
+{
+       //
+       //GetTPC
+       //
+
+       const Double_t etacut = 0.9;
+       Int_t nA = 0;
+       Int_t nC = 0;
+       for(Int_t itrack = 0; itrack < ESDEvent->GetNumberOfTracks(); itrack++){
+               const AliESDtrack* esdtrack = ESDEvent->GetTrack(itrack);
+               if( esdtrack->Eta() > etacut ){
+                       nA ++;
+               }
+               else if( esdtrack->Eta() < -etacut ){
+                       nC ++;
+               }
+       }
+
+       const Bool_t tpcA = nA;
+       const Bool_t tpcC = nC;
+
+       return tpcA * AliCDMesonBaseStripped::kBitTPCA
+               + tpcC * AliCDMesonBaseStripped::kBitTPCC;
+}
+
+//==============================================================================
+//------------------------------------------------------------------------------
+void AliCDMesonUtilsStripped::SPDLoadGeom(const Int_t run)
+{
+       // method to get the gGeomanager
+       // it is called at the CreatedOutputObject stage
+       // to comply with the CAF environment
+
+       AliCDBManager *man = AliCDBManager::Instance();
+       // WARNING THE OCDB PATH SHOULD BE ADJUSTED TO THE RUNNING CONDITIONS
+
+
+       TString cdbpath;
+       if (man->IsDefaultStorageSet()) {
+               const AliCDBStorage *dsto = man->GetDefaultStorage();
+               cdbpath = TString(dsto->GetBaseFolder());
+       }
+       else {
+               man->SetDefaultStorage("raw://");
+               cdbpath = "raw://";
+       }
+
+       man->SetSpecificStorage("ITS/Align/Data",cdbpath);
+       man->SetSpecificStorage("GRP/Geometry/Data",cdbpath);
+       man->SetRun(run);
+
+       AliCDBEntry* obj = man->Get(AliCDBPath("GRP", "Geometry", "Data"));
+       if (!obj) {
+               printf("freidtlog failed loading geometry object\n");
+               return;
+       }
+       AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());
+       AliGeomManager::ApplyAlignObjsFromCDB("ITS");
+}
+
+//------------------------------------------------------------------------------
+Bool_t AliCDMesonUtilsStripped::SPDLoc2Glo(const Int_t id, const Double_t *loc,
+                                           Double_t *glo)
+{
+       //
+       //SPDLoc2Glo, do not touch
+       //
+
+       static TGeoHMatrix mat;
+       Int_t vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(id);
+       if (vid<0) {
+               printf("freidtlog Did not find module with such ID %d\n",id);
+               return kFALSE;
+       }
+       AliITSAlignMille2Module::SensVolMatrix(vid,&mat);
+       mat.LocalToMaster(loc,glo);
+       return kTRUE;
+}
+
+
+//------------------------------------------------------------------------------
+Int_t AliCDMesonUtilsStripped::CheckChipEta(const Int_t chipKey,
+                                            const TString scut,
+                                            const Double_t vtxPos[])
+{
+       //
+       //CheckChipEta
+       //
+
+       // retrieves the position in eta for a given chip and applies the cut
+       // results:
+       // 0 <= out of range
+       // -1 <= negative pseudo-rapidity position, in range (C-Side)
+       // 1 <= positive pseudo-rapidity position, in range (A-Side)
+       //
+       // scut: "[0.9" or "]0.9", only 3 digits for the value!!
+
+
+       const Bool_t kincl = (scut[0] == '[');
+       const TString cutval = scut(1,3);
+       const Double_t etacut = fabs(cutval.Atof());
+
+       //no eta cut, save time
+       if(kincl && etacut>=2)
+               return kTRUE;
+
+       Int_t etaside = 1;
+       //------------------------------- NOT TO TOUCH ------------------------>>
+       UInt_t module=999, offchip=999;
+       AliSPDUtils::GetOfflineFromOfflineChipKey(chipKey,module,offchip);
+       UInt_t hs = AliSPDUtils::GetOnlineHSFromOffline(module);
+       if(hs<2) offchip = 4 - offchip; // inversion  in the inner layer...
+
+       const Int_t col[]={
+               hs<2? 0 : 31,
+               hs<2? 31 : 0,
+               hs<2? 31 : 0,
+               hs<2? 0 : 31};
+       const Int_t aa[]={0, 0, 255, 255};
+       const AliITSsegmentationSPD seg;
+
+       for(Int_t ic=0; ic<4; ic++){
+               Float_t localchip[3]={0.,0.,0.};
+               seg.DetToLocal(aa[ic],col[ic]+32*offchip,localchip[0],localchip[2]);
+               // local coordinate of the chip center
+               //printf("local coordinates %d %d: %f %f \n",chipKey, ic, localchip[0],localchip[2]);
+               const Double_t local[3] = {localchip[0],localchip[1],localchip[2]};
+               Double_t glochip[3]={0.,0.,0.};
+               if(!SPDLoc2Glo(module,local,glochip)){
+                       return kFALSE;
+               }
+
+               //-------------------------------------------------------------------<<
+
+               const TVector3 pos(glochip[0]-vtxPos[0], glochip[1]-vtxPos[1],
+                                  glochip[2]-vtxPos[2]);
+               //pos.Print();
+
+               if( kincl && fabs(pos.Eta()) > etacut)
+                       return kFALSE;
+
+               if(!kincl){
+                       if(fabs(pos.Eta()) < etacut)
+                               return kFALSE;
+                       else if(pos.Eta()<0)
+                               etaside = -1;
+                       else
+                               etaside = 1;
+               }
+       }
+
+       return etaside;
+}
+
+
+//------------------------------------------------------------------------------
+void AliCDMesonUtilsStripped::GetNFO(const AliESDEvent *ESDEvent,
+                                     const TString etacut, Int_t ctr[])
+{
+       //
+       // GetNFO
+       //
+       // analyzes the SPD fastOR for a given eta range and returns
+       // an array with the number of hits in:
+
+       Int_t ninner=0; // inner layer
+       Int_t nouter=0; // outer layer
+       Int_t ipA = 0; // inner layer A side
+       Int_t ipC = 0; // inner layer C side
+       Int_t opA = 0; // outer layer A side
+       Int_t opC = 0; // outer layer C side
+
+       const AliMultiplicity *mult = ESDEvent->GetMultiplicity();
+
+       // position of the primary vertex
+       Double_t tmp[3] = { 0., 0., 0. };
+       ESDEvent->GetPrimaryVertex()->GetXYZ(tmp);
+       Double_t vtxPos[3] = { tmp[0], tmp[1], tmp[2] };
+
+
+       for(Int_t iChipKey=0; iChipKey < 1200; iChipKey++){
+               if(mult->TestFastOrFiredChips(iChipKey)){
+                       // here you check if the FastOr bit is 1 or 0
+                       const Int_t iseta = CheckChipEta(iChipKey, etacut, vtxPos);
+                       if(iseta==0)
+                               continue;
+
+                       if(iChipKey<400) {
+                               ninner++;  // here you count the FastOr bits in the inner layer
+                               if(iseta>0)
+                                       ipA ++;
+                               else
+                                       ipC ++;
+                       }
+                       else {
+                               nouter++;  // here you count the FastOr bits in the outer layer
+                               if(iseta>0)
+                                       opA ++;
+                               else
+                                       opC ++;
+                       }
+               }
+       }
+
+       ctr[kInnerPixel]= ninner;
+       ctr[kOuterPixel]= nouter;
+       ctr[kIPA]= ipA;
+       ctr[kIPC]= ipC;
+       ctr[kOPA]= opA;
+       ctr[kOPC]= opC;
+
+       return;
+}
diff --git a/PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.h b/PWGUD/DIFFRACTIVE/example/AliCDMesonUtilsStripped.h
new file mode 100644 (file)
index 0000000..6a68320
--- /dev/null
@@ -0,0 +1,89 @@
+/*************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonUtilsStripped
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#ifndef ALICDMESONUTILSSTRIPPED_H
+#define ALICDMESONUTILSSTRIPPED_H
+
+class TH1;
+class TH2;
+class TLorentzVector;
+
+class AliESDEvent;
+class AliAODEvent;
+class AliESDtrack;
+class AliESDtrackCuts;
+class AliVTrack;
+class AliPIDResponse;
+
+class AliCDMesonTracks;
+
+class AliCDMesonUtilsStripped
+{
+public:
+       enum{
+               kInnerPixel = 0,
+               kOuterPixel,
+               kIPA,
+               kIPC,
+               kOPA,
+               kOPC
+       };
+
+       // ESD only
+       //---------
+
+       // cuts for ESD analysis
+       static Bool_t CutEvent(const AliESDEvent *ESDEvent);
+
+       // gap determination
+       static Int_t GetGapConfig(const AliESDEvent *ESDEvent);
+
+       static void SPDLoadGeom(const Int_t run); // only needed for ESDs, not in AODs
+
+       // AOD only
+       //---------
+       static Bool_t CutEvent(const AliAODEvent *AODEvent);
+
+private:
+       // ESD only
+       //---------
+
+       // Gap determination functions
+       static Int_t GetV0(const AliESDEvent *ESDEvent);
+       static Int_t GetFMD(const AliESDEvent *ESDEvent);
+       static Int_t GetSPD(const AliESDEvent *ESDEvent);
+       static Int_t GetTPC(const AliESDEvent *ESDEvent);
+       static Int_t GetZDC(const AliESDEvent *ESDEvent); // not used so far
+
+       // helpers for the SPD gap determination
+       static Bool_t SPDLoc2Glo(const Int_t id, const Double_t *loc, Double_t *glo);
+       static Int_t CheckChipEta(const Int_t chipKey, const TString scut,
+                                 const Double_t vtxPos[]);
+       static void GetNFO(const AliESDEvent *ESDEvent, const TString etacut,
+                          Int_t ctr[]);
+       // AOD only
+       //---------
+
+
+       // independent
+       //----------
+};
+
+#endif
diff --git a/PWGUD/DIFFRACTIVE/example/runEx.C b/PWGUD/DIFFRACTIVE/example/runEx.C
new file mode 100644 (file)
index 0000000..f51d2d5
--- /dev/null
@@ -0,0 +1,314 @@
+// runEx.C
+//
+// run macro for central diffractive example analysis
+//
+// Author: Felix Reidt <felix.reidt@cern.ch>
+//
+// based on:
+// ---
+// Template run macro for AliBasicTask.cxx/.h with example layout of
+// physics selections and options, in macro and task.
+//
+// Author: Arvinder Palaha
+//
+class AliAnalysisGrid;
+
+//______________________________________________________________________________
+void runEx(
+             const char* runtype = "proof", // local, proof or grid
+             const char *gridmode = "full", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
+             const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
+             const Long64_t nentries = 2000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
+             const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
+             const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
+             const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode
+             const char *taskname = "CDex" // sets name of grid generated macros
+             )
+{
+       // check run type
+       if(runtype != "local" && runtype != "proof" && runtype != "grid"){
+               Printf("\n\tIncorrect run option, check first argument of run macro");
+               Printf("\tint runtype = local, proof or grid\n");
+               return;
+       }
+       Printf("%s analysis chosen",runtype);
+
+       // load libraries (to be optimized)
+       gSystem->Load("libCore.so");
+       gSystem->Load("libTree.so");
+       gSystem->Load("libPhysics");
+       gSystem->Load("libMinuit");
+       gSystem->Load("libProof");
+       gSystem->Load("libmicrocern");
+       gSystem->Load("liblhapdf");
+       gSystem->Load("libpythia6");
+       gSystem->Load("libEG");
+       gSystem->Load("libGeom");
+       gSystem->Load("libVMC");
+       gSystem->Load("libEGPythia6");
+       gSystem->Load("libSTEERBase");
+       gSystem->Load("libESD");
+       gSystem->Load("libCDB");
+       gSystem->Load("libRAWDatabase");
+       gSystem->Load("libRAWDatarec");
+       gSystem->Load("libAOD");
+       gSystem->Load("libANALYSIS");
+       gSystem->Load("libANALYSISalice");
+       gSystem->Load("libSTEER");
+       gSystem->Load("libTENDER");
+       gSystem->Load("libRAWDatasim");
+       gSystem->Load("libFASTSIM");
+       gSystem->Load("libEVGEN");
+       gSystem->Load("libAliPythia6");
+       gSystem->Load("libSTAT");
+       gSystem->Load("libhijing");
+       gSystem->Load("libTHijing");
+       gSystem->Load("libSTRUCT");
+       gSystem->Load("libPHOSUtils");
+       gSystem->Load("libPHOSbase");
+       gSystem->Load("libPHOSsim");
+       gSystem->Load("libPHOSrec");
+       gSystem->Load("libMUONcore");
+       gSystem->Load("libMUONmapping");
+       gSystem->Load("libMUONgeometry");
+       gSystem->Load("libMUONcalib");
+       gSystem->Load("libMUONraw");
+       gSystem->Load("libMUONtrigger");
+       gSystem->Load("libMUONbase");
+       gSystem->Load("libMUONsim");
+       gSystem->Load("libMUONrec");
+       gSystem->Load("libMUONevaluation");
+       gSystem->Load("libFMDbase");
+       gSystem->Load("libFMDsim");
+       gSystem->Load("libFMDrec");
+       gSystem->Load("libPMDbase");
+       gSystem->Load("libPMDsim");
+       gSystem->Load("libPMDrec");
+       gSystem->Load("libHMPIDbase");
+       gSystem->Load("libHMPIDsim");
+       gSystem->Load("libHMPIDrec");
+       gSystem->Load("libT0base");
+       gSystem->Load("libT0sim");
+       gSystem->Load("libT0rec");
+       gSystem->Load("libZDCbase");
+       gSystem->Load("libZDCsim");
+       gSystem->Load("libZDCrec");
+       gSystem->Load("libACORDEbase");
+       gSystem->Load("libACORDErec");
+       gSystem->Load("libACORDEsim");
+       gSystem->Load("libVZERObase");
+       gSystem->Load("libVZEROrec");
+       gSystem->Load("libVZEROsim");
+       gSystem->Load("libEMCALraw");
+       gSystem->Load("libEMCALUtils");
+       gSystem->Load("libEMCALbase");
+       gSystem->Load("libEMCALsim");
+       gSystem->Load("libEMCALrec");
+       gSystem->Load("libTPCbase");
+       gSystem->Load("libTPCrec");
+       gSystem->Load("libTPCsim");
+       gSystem->Load("libTPCfast");
+       gSystem->Load("libITSbase");
+       gSystem->Load("libITSsim");
+       gSystem->Load("libITSrec");
+       gSystem->Load("libTRDbase");
+       gSystem->Load("libTRDsim");
+       gSystem->Load("libTRDrec");
+       gSystem->Load("libTOFbase");
+       gSystem->Load("libTOFrec");
+       gSystem->Load("libTOFsim");
+       gSystem->Load("libHLTbase");
+       gSystem->Load("libHLTinterface");
+       gSystem->Load("libHLTsim");
+       gSystem->Load("libHLTrec");
+       gSystem->Load("libPWGPP");
+
+       // add aliroot include path
+       gROOT->ProcessLine(Form(".include %s/include",
+                               gSystem->ExpandPathName("$ALICE_ROOT")));
+       gROOT->ProcessLine(Form(".include $ALICE_ROOT/include",
+                               gSystem->ExpandPathName("$ALICE_ROOT")));
+       gROOT->ProcessLine(Form(".include $ALICE_ROOT/ITS",
+                               gSystem->ExpandPathName("$ALICE_ROOT")));
+       gROOT->ProcessLine(Form(".include $ALICE_ROOT/PWGPP/ITS",
+                               gSystem->ExpandPathName("$ALICE_ROOT")));
+
+       gROOT->SetStyle("Plain");
+
+       // create the alien handler and attach it to the manager
+       AliAnalysisGrid *plugin =
+               CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
+
+       // analysis manager
+       AliAnalysisManager* mgr = new AliAnalysisManager("CDMeson-Manager");
+       mgr->SetGridHandler(plugin);
+
+       AliESDInputHandler* esdH = new AliESDInputHandler();
+       mgr->SetInputEventHandler(esdH);
+
+       // === Physics Selection Task ===
+       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+       AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
+       if(!physSelTask) { Printf("no physSelTask"); return; }
+
+       // === create user task ===
+       gROOT->LoadMacro("AliCDMesonBaseStripped.cxx+g");
+       gROOT->LoadMacro("AliCDMesonTracks.cxx+g");
+       gROOT->LoadMacro("AliCDMesonUtilsStripped.cxx+g");
+       gROOT->LoadMacro("AliAnalysisTaskCDex.cxx+g");
+
+       AliAnalysisTaskSE* task = new AliAnalysisTaskCDex(taskname);
+       task->SelectCollisionCandidates(AliVEvent::kMB);
+       mgr->AddTask(task);
+
+       // INPUT ---------------------------------------------------------------------
+       AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+       mgr->ConnectInput(task,  0, cinput );
+
+       // OUTPUT --------------------------------------------------------------------
+       // output filename
+       Char_t foutname[100];
+       sprintf(foutname,"freidt_%s.root",taskname);
+
+       // output containers
+       // in AnalysisTaskSE, slot 0 reserved, must start from 1
+       AliAnalysisDataContainer* output =
+               mgr->CreateContainer("freidt_Hist", TList::Class(),
+                                    AliAnalysisManager::kOutputContainer,foutname);
+       task->ConnectOutput(1, output);
+
+       // enable debug printouts
+       mgr->SetDebugLevel(2);
+       //mgr->SetNSysInfo(100);
+       if (!mgr->InitAnalysis()) return;
+       mgr->PrintStatus();
+
+       // start analysis
+       Printf("Starting Analysis....");
+       mgr->StartAnalysis(runtype); //,nentries,firstentry);
+}
+
+//______________________________________________________________________________
+AliAnalysisGrid* CreateAlienHandler(const char *taskname,
+                                    const char *gridmode,
+                                    const char *proofcluster,
+                                    const char *proofdataset)
+{
+       AliAnalysisAlien *plugin = new AliAnalysisAlien();
+       // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
+       plugin->SetOverwriteMode();
+       plugin->SetRunMode(gridmode);
+
+       plugin->SetMergeViaJDL(kTRUE);
+
+       // Set versions of used packages
+       plugin->SetAPIVersion("V1.1x");
+       plugin->SetROOTVersion("v5-33-02b");
+       plugin->SetAliROOTVersion("v5-02-Rev-09");
+
+       // Declare input data to be processed.
+       //plugin->SetCheckCopy(kFALSE);
+
+       // Method 1: Create automatically XML collections using alien 'find' command.
+       // Define production directory LFN
+       plugin->SetGridDataDir("/alice/data/2010/LHC10b");
+       // On real reconstructed data:
+       // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
+       // Set data search pattern
+       //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
+       // Data pattern for reconstructed data
+       plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
+       //    plugin->SetDataPattern("ESDs/pass2/AOD038/*AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
+       plugin->SetRunPrefix("000");   // real data
+       // ...then add run numbers to be considered
+
+       //Int_t runlist[15]={117039, 146859, 146858, 146856, 146824, 146817, 146806, 146805, 146804, 146803, 146802, 146801, 146748, 146747, 146746};  
+       //for (Int_t ind=0; ind<1; ind++) {
+       //      plugin->AddRunNumber(runlist[ind]);
+       //}
+       //plugin->SetRunRange(114917,115322);
+       plugin->AddRunNumber(117050);
+
+       plugin->SetNrunsPerMaster(1);
+
+       // Define alien work directory where all files will be copied. Relative to alien $HOME.
+       plugin->SetGridWorkingDir(taskname);
+
+       // Declare alien output directory. Relative to working directory.
+       plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
+
+       // Declare the analysis source files names separated by blancs. To be compiled runtime
+       // using ACLiC on the worker nodes.
+       plugin->SetAnalysisSource("AliCDMesonBaseStripped.cxx AliCDMesonTracks.cxx AliCDMesonUtilsStripped.cxx AliAnalysisTaskCDex.cxx");
+
+       // Declare all libraries (other than the default ones for the framework. These will be
+       // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
+       plugin->SetAdditionalLibs("libGui.so libCore.so libTree.so libPhysics.so libMinuit.so libProof.so libmicrocern.so liblhapdf.so libpythia6.so libEG.so libGeom.so libVMC.so libEGPythia6.so libSTEERBase.so libESD.so libRAWDatabase.so libRAWDatarec.so libAOD.so libANALYSIS.so libANALYSISalice.so libCDB.so libSTEER.so libRAWDatasim.so libFASTSIM.so libEVGEN.so libAliPythia6.so libSTAT.so libhijing.so libTHijing.so libSTRUCT.so libPHOSUtils.so libPHOSbase.so libPHOSsim.so libPHOSrec.so libMUONcore.so libMUONmapping.so libMUONgeometry.so libMUONcalib.so libMUONraw.so libMUONtrigger.so libMUONbase.so libMUONsim.so libMUONrec.so libMUONevaluation.so libFMDbase.so libFMDsim.so libFMDrec.so libPMDbase.so libPMDsim.so libPMDrec.so libHMPIDbase.so libHMPIDsim.so libHMPIDrec.so libT0base.so libT0sim.so libT0rec.so libZDCbase.so libZDCsim.so libZDCrec.so libACORDEbase.so libACORDErec.so libACORDEsim.so libVZERObase.so libVZEROrec.so libVZEROsim.so libEMCALraw.so libEMCALUtils.so libEMCALbase.so libEMCALsim.so libEMCALrec.so libTPCbase.so libTPCrec.so libTPCsim.so libTPCfast.so libITSbase.so libITSsim.so libITSrec.so libTRDbase.so libTRDsim.so libTRDrec.so libTOFbase.so libTOFrec.so libTOFsim.so libHLTbase.so libHLTinterface.so libHLTsim.so libHLTrec.so AliCDMesonBaseStripped.h AliCDMesonBaseStripped.cxx AliCDMesonTracks.h AliCDMesonTracks.cxx AliCDMesonUtilsStripped.h AliCDMesonUtilsStripped.cxx AliAnalysisTaskCDex.h AliAnalysisTaskCDex.cxx");
+
+       plugin->AddIncludePath("-I$ALICE_ROOT/ITS -I$ALICE_ROOT/PWGPP/ITS");
+
+       // Declare the output file names separated by blancs.
+       // (can be like: file.root or file.root@ALICE::Niham::File)
+       // To only save certain files, use SetDefaultOutputs(kFALSE), and then
+       // SetOutputFiles("list.root other.filename") to choose which files to save
+       plugin->SetDefaultOutputs();
+
+       // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
+       plugin->SetAnalysisMacro("CDMeson.C");
+
+       // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
+       plugin->SetSplitMaxInputFileNumber(100);
+
+       // Optionally modify the executable name (default analysis.sh)
+       plugin->SetExecutable("CDMeson.sh");
+
+       // set number of test files to use in "test" mode
+       plugin->SetNtestFiles(1);
+
+       // Optionally resubmit threshold.
+       //plugin->SetMasterResubmitThreshold(90);
+
+       // Optionally set time to live (default 30000 sec)
+       //plugin->SetTTL(30000);
+
+       // Optionally set input format (default xml-single)
+       //plugin->SetInputFormat("xml-single");
+
+       // Optionally modify the name of the generated JDL (default analysis.jdl)
+       plugin->SetJDLName("CDMeson.jdl");
+
+       // Optionally modify job price (default 1)
+       plugin->SetPrice(1);
+
+       // Optionally modify split mode (default 'se')
+       plugin->SetSplitMode("se");
+
+       //----------------------------------------------------------
+       //---      PROOF MODE SPECIFIC SETTINGS         ------------
+       //----------------------------------------------------------
+       // Proof cluster
+       plugin->SetProofCluster(proofcluster);
+       // Dataset to be used
+       plugin->SetProofDataSet(proofdataset);
+       // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
+       plugin->SetProofReset(0);
+       // May limit number of workers
+       plugin->SetNproofWorkers(0);
+       // May limit the number of workers per slave
+       plugin->SetNproofWorkersPerSlave(1);
+       // May use a specific version of root installed in proof
+       plugin->SetRootVersionForProof("current");
+       // May set the aliroot mode. Check http://aaf.cern.ch/node/83
+       plugin->SetAliRootMode("default"); // Loads AF libs by default
+       // May request ClearPackages (individual ClearPackage not supported)
+       plugin->SetClearPackages(kFALSE);
+       // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
+       plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
+       // Request connection to alien upon connection to grid
+       plugin->SetProofConnectGrid(kFALSE);
+       // Other PROOF specific parameters
+       plugin->SetProofParameter("PROOF_UseMergers","-1");
+       printf("Using: PROOF_UseMergers   : %s\n", plugin->GetProofParameter("PROOF_UseMergers"));
+
+       return plugin;
+}
diff --git a/PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.cxx b/PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.cxx
new file mode 100644 (file)
index 0000000..ae6e74b
--- /dev/null
@@ -0,0 +1,454 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonTracks
+// for
+// AliAnalysisTaskCDMeson
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+//
+// class applies the track cuts and provides access to the tracks
+//
+//
+
+// ROOT classes
+#include "TObjArray.h"
+
+// AliRoot classes
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliESDtrackCuts.h"
+#include "AliVTrack.h"
+#include "AliMultiplicity.h"
+
+// header of the class itsself
+#include "AliCDMesonTracks.h"
+
+
+//------------------------------------------------------------------------------
+AliCDMesonTracks::AliCDMesonTracks()
+       : fAODEvent(0x0)
+       , fESDEvent(0x0)
+       , fDoAOD(kFALSE)
+       , fDoSoft(kTRUE)
+       , fIsValid(kFALSE)
+       , fNTrk0(-999)
+       , fNch(-999)
+       , fNsoft(-999)
+       , fNcombined(-999)
+       , fNITSpureSA(-999)
+       , fNtrackletsCentralBarrel(-999)
+       , fNtrackletsForward(-999)
+       , fTracks(0x0)
+       , fSoftTracks(0x0)
+{
+       //
+       // constructor
+       //
+}
+
+
+//------------------------------------------------------------------------------
+AliCDMesonTracks::AliCDMesonTracks(const AliCDMesonTracks& tracks)
+       : fAODEvent(tracks.fAODEvent)
+       , fESDEvent(tracks.fESDEvent)
+       , fDoAOD(tracks.fDoAOD)
+       , fDoSoft(tracks.fDoSoft)
+       , fIsValid(tracks.fIsValid)
+       , fNTrk0(tracks.fNTrk0)
+       , fNch(tracks.fNch)
+       , fNsoft(tracks.fNsoft)
+       , fNcombined(tracks.fNcombined)
+       , fNITSpureSA(tracks.fNITSpureSA)
+       , fNtrackletsCentralBarrel(tracks.fNtrackletsCentralBarrel)
+       , fNtrackletsForward(tracks.fNtrackletsForward)
+       , fTracks(tracks.fTracks)
+       , fSoftTracks(tracks.fSoftTracks)
+{
+       //
+       // copy constructor
+       //
+}
+
+
+//------------------------------------------------------------------------------
+AliCDMesonTracks& AliCDMesonTracks::operator=(const AliCDMesonTracks& tracks)
+{
+       //
+       // assignment operator
+       //
+
+                       if (this != &tracks) {
+                       // create deep copy ...
+               }
+               return *this;
+}
+
+
+//------------------------------------------------------------------------------
+AliCDMesonTracks::~AliCDMesonTracks()
+{
+       //
+       // destructor
+       //
+
+       if (fTracks) {
+               fTracks->SetOwner(kTRUE);
+               fTracks->Clear();
+               delete fTracks;
+               fTracks = 0x0;
+       }
+       if (fSoftTracks) {
+               fSoftTracks->SetOwner(kTRUE);
+               fSoftTracks->Clear();
+               delete fSoftTracks;
+               fSoftTracks = 0x0;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+Bool_t AliCDMesonTracks::ProcessEvent(AliAODEvent* aodEvent,
+                                      AliESDEvent* esdEvent,
+                                      Bool_t doSoft /* = kTRUE */)
+{
+       //
+       // this function controlls the processing of an event, after the processing is
+       // done, the results can be used via the getters
+       //
+
+       if ((aodEvent && esdEvent) || (!aodEvent && !esdEvent)) {
+               // only one event type is allowed, no event type is also not allowed
+               return fIsValid = fDoAOD = kFALSE;
+       }
+       else if (aodEvent) {
+               fAODEvent = aodEvent;
+               fESDEvent = 0x0;
+               fDoAOD = kTRUE;
+       }
+       else if (esdEvent) {
+               fAODEvent = 0x0;
+               fESDEvent = esdEvent;
+               fDoAOD = kFALSE;
+       }
+       fDoSoft = doSoft;
+
+       ApplyCuts();
+       if (!fDoAOD) GetRemainingTracklets();
+       fIsValid = kTRUE;
+       return kTRUE;
+}
+
+
+//------------------------------------------------------------------------------
+AliVTrack* AliCDMesonTracks::GetTrack(UInt_t index) const
+{
+       //
+       // provides access to the selected tracks, normal tracks have lower indices
+       // than soft tracks
+       //
+
+       if (!fIsValid) return 0x0; // cut selection wasn't properly done
+
+       if ((((Int_t)index >= fNch) && !fDoSoft) || // soft not enabled
+           ((Int_t)index >= fNcombined)) return 0x0; // soft enabled
+       // index out of range
+
+       if ((Int_t)index < fNch) return (AliVTrack*)((*fTracks)[index]);
+       else if ((Int_t)index < fNcombined) {
+               return (AliVTrack*)((*fSoftTracks)[index - fNch]);
+       }
+       else return 0x0; // something went wrong
+}
+
+
+//------------------------------------------------------------------------------
+Double_t AliCDMesonTracks::GetInvariantMass(Bool_t includeSoftTracks /*=kTRUE*/)
+{
+       //
+       // compute the invariant mass of all accepted tracks in the event
+       //
+
+       TLorentzVector sum;
+       for (Int_t iTrack = 0; iTrack < fTracks->GetEntriesFast(); ++iTrack) {
+               AliVTrack* track = (AliVTrack*)fTracks->UncheckedAt(iTrack);
+               TLorentzVector temp(track->Px(), track->Py(), track->Pz(), track->E());
+               sum += temp;
+       }
+       if (includeSoftTracks) {
+               for (Int_t iSoftTrack = 0; iSoftTrack < fSoftTracks->GetEntriesFast();
+                    ++iSoftTrack) {
+                       AliVTrack* track = (AliVTrack*)fSoftTracks->UncheckedAt(iSoftTrack);
+                       TLorentzVector temp(track->Px(), track->Py(), track->Pz(), track->E());
+                       sum += temp;
+               }
+       }
+       return sum.M();
+}
+
+
+//------------------------------------------------------------------------------
+void AliCDMesonTracks::ApplyCuts()
+{
+       //
+       // steers the track selection process
+       //
+
+       fNTrk0 = (fDoAOD) ?
+               fAODEvent->GetNumberOfTracks() : fESDEvent->GetNumberOfTracks();
+
+       fNch = -999;
+       fNsoft = -999;
+       fNcombined = -999;
+       fNITSpureSA = -999;
+
+       if (fDoAOD) {
+               CutTrack(fAODEvent); // ordinary tracks
+               CutTrack(fAODEvent, 2); // kITSpureSA
+       }
+       else {
+               CutTrack(fESDEvent); // ordinary tracks
+               CutTrack(fESDEvent, 2); // kITSpureSA
+       }
+
+       if (fDoSoft) { // do soft tracks
+               if (fDoAOD) {
+                       CutTrack(fAODEvent, 1);
+               }
+               else {
+                       CutTrack(fESDEvent, 1);
+               }
+
+               fNcombined = fNch + fNsoft;
+               for (Int_t iSoft = 0; iSoft < fNsoft; iSoft++) {
+                       Int_t iTrk = 0;
+                       while (iTrk < fNch) {
+                               // TODO find some criterion to match them properly!
+                               // check whether they are really complementary if not
+                               // an error will be raised
+                               // already contained in both arrays, exit loop
+                               ++iTrk; // next track
+                       }
+               }
+       }
+       else { // do not care about soft tracks
+               fNcombined = fNch;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+void AliCDMesonTracks::CutTrack(AliESDEvent *ESDEvent, Int_t mode /* = 0 */)
+{
+       //
+       //CutTrack to be combined with the AOD function // TODO
+       //
+
+       const Double_t etacut = 0.9;
+
+       AliESDtrackCuts esdTrackCuts;
+
+       if (mode == 0) { // default mode
+               // cuts for normal tracks (ITS + TPC)
+               // i.e. GetStandardITSTPCTrackCuts2010(kTRUE);
+               // (same, just typed in full detail...)
+
+               if (fTracks) {
+                       fTracks->Clear();
+                       delete fTracks;
+                       fTracks = 0x0;
+               }
+
+               // TPC
+               esdTrackCuts.SetMinNClustersTPC(70);
+               //esdTrackCuts.SetMinNCrossedRowsTPC(70);
+               //esdTrackCuts.SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
+
+               esdTrackCuts.SetMaxChi2PerClusterTPC(4);
+               esdTrackCuts.SetAcceptKinkDaughters(kFALSE);
+               esdTrackCuts.SetRequireTPCRefit(kTRUE);
+               // ITS
+               esdTrackCuts.SetRequireITSRefit(kTRUE);
+               esdTrackCuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+                                                     AliESDtrackCuts::kAny);
+               // 7*(0.0026+0.0050/pt^1.01)
+               esdTrackCuts.SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
+
+               esdTrackCuts.SetMaxDCAToVertexZ(2);
+               esdTrackCuts.SetDCAToVertex2D(kFALSE);
+               esdTrackCuts.SetRequireSigmaToVertex(kFALSE);
+
+               esdTrackCuts.SetEtaRange(-etacut, etacut);
+
+               fTracks = esdTrackCuts.GetAcceptedTracks(ESDEvent);
+               fNch = fTracks->GetEntriesFast();
+       }
+       else if (mode == 1) {
+               // cuts for soft tracks (ITS only - kITSsa)
+
+               if (fSoftTracks) {
+                       fSoftTracks->Clear();
+                       delete fSoftTracks;
+                       fSoftTracks = 0x0;
+               }
+
+               esdTrackCuts.SetRequireITSStandAlone(kTRUE);
+               esdTrackCuts.SetRequireITSPureStandAlone(kFALSE);
+               esdTrackCuts.SetRequireITSRefit(kTRUE);
+               esdTrackCuts.SetMinNClustersITS(4);
+               esdTrackCuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD,
+                                                     AliESDtrackCuts::kAny);
+               esdTrackCuts.SetMaxChi2PerClusterITS(1.);
+               esdTrackCuts.SetMaxDCAToVertexXYPtDep("0.0595+0.0182/pt^1.55");
+
+               esdTrackCuts.SetEtaRange(-etacut, etacut);
+
+               fSoftTracks = esdTrackCuts.GetAcceptedTracks(ESDEvent);
+               fNsoft = fSoftTracks->GetEntriesFast();
+       }
+       else {
+               // cuts for ITSpureSA tracks used in order to get rid of them for noise
+               // studies
+
+               // selection according to cuts
+               esdTrackCuts.SetRequireITSPureStandAlone(kTRUE);
+
+               // do selection according to status bits (never tested!!!)
+               //for(Int_t itrack = 0; itrack < ESDEvent->GetNumberOfTracks(); itrack++){
+               //      const AliESDtrack* esdtrack = ESDEvent->GetTrack(itrack);
+               //      UInt64 status = esdtrack->GetStatus();
+               //      if ((status & kITSpureSA) && !(status & kITSsa)){
+               //      }
+               //}
+               TObjArray* arr = esdTrackCuts.GetAcceptedTracks(ESDEvent);
+               fNITSpureSA = arr->GetEntriesFast();
+               delete arr;
+               arr = 0x0;
+       }
+}
+
+
+//------------------------------------------------------------------------------
+void AliCDMesonTracks::CutTrack(AliAODEvent *AODEvent, Int_t mode /* = 0 */)
+{
+       //
+       // CutTrack for AODs
+       //
+
+       UInt_t bit = 0x0;
+       TObjArray* trks = 0x0;
+       Int_t* ntrks = 0x0;
+
+       if (mode == 0) { // default mode
+               // cuts for normal tracks (ITS + TPC)
+               // i.e. GetStandardITSTPCTrackCuts2010(kTRUE);
+               // (same, just typed in full detail...)
+               bit = 0x1 << 14;
+
+               // prepare storage
+               if (fTracks) {
+                       fTracks->SetOwner(kTRUE);
+                       fTracks->Clear();
+               }
+               else {
+                       fTracks = new TObjArray();
+                       fTracks->SetOwner(kTRUE);
+               }
+
+               // store where to put selected tracks
+               trks = fTracks;
+               ntrks = &fNch;
+       }
+       else if (mode == 1) {
+               // cuts for soft tracks (ITS only - kITSsa)
+               bit = 0x1 << 15;
+
+               if (fSoftTracks) {
+                       fSoftTracks->SetOwner(kTRUE);
+                       fSoftTracks->Clear();
+               }
+               else {
+                       fSoftTracks = new TObjArray();
+                       fSoftTracks->SetOwner(kTRUE);
+               }
+
+               // sotre where to put selected tracks
+               trks = fSoftTracks;
+               ntrks = &fNsoft;
+       }
+       else {
+               // cuts for ITSpureSA tracks used in order to get rid of them for noise
+               // studies
+               bit = 0x1 << 16;
+
+               // do not store tracks, just count them =>
+               trks = 0x0;
+               ntrks = &fNITSpureSA;
+       }
+
+       for (Int_t iTrk = 0; iTrk < AODEvent->GetNumberOfTracks(); iTrk++) {
+               const AliAODTrack* trk = AODEvent->GetTrack(iTrk);
+
+               if (trk->TestFilterBit(bit)) {
+                       // test whether track was selected by that filter
+
+                       if (trks) { // add tracks to TObjArray
+                               trks->Add((TObject*)trk);
+                       }
+                       else { // just count them
+                               ++(*ntrks);
+                       }
+               }
+       }
+
+       if (trks) {
+               (*ntrks) = trks->GetEntriesFast();
+       }
+}
+
+
+//------------------------------------------------------------------------------
+void AliCDMesonTracks::GetRemainingTracklets()
+{
+       // determines the number of tracklets in an event, which are not assigned to
+       // tracks
+       // this is only possible running on ESDs, for AODs this information has to be
+       // preprocessed
+
+       if (!fESDEvent) return;
+       const AliMultiplicity *mult = fESDEvent->GetMultiplicity();
+
+       if (mult) {
+               // reset values
+               fNtrackletsCentralBarrel = 0;
+               fNtrackletsForward = 0;
+
+               for (Int_t iTracklet = 0; iTracklet < mult->GetNumberOfTracklets();
+                    iTracklet++) {
+                       Int_t id1 = -1, id2 = -1;
+                       if (!mult->GetTrackletTrackIDs(iTracklet, 0, id1, id2)) {
+                               float_t eta = mult->GetEta(iTracklet);
+
+                               if ((eta < -0.9) || (eta < 0.9)) {
+                                       ++fNtrackletsForward;
+                               }
+                               else {
+                                       ++fNtrackletsCentralBarrel;
+                               }
+                       }
+               }
+       }
+}
diff --git a/PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.h b/PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.h
new file mode 100644 (file)
index 0000000..482d8b5
--- /dev/null
@@ -0,0 +1,90 @@
+
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//
+// AliCDMesonTracks
+// for 
+// AliAnalysisTaskCDMeson
+//
+// see AliCDMesonTracks.cxx for description
+//
+//  Author:
+//  Felix Reidt <Felix.Reidt@cern.ch>
+
+#ifndef ALICDMESONTRACKS_H
+#define ALICDMESONTRACKS_H
+
+class TObjArray;
+
+class AliAODEvent;
+class AliESDEvent;
+class AliVTrack;
+
+class AliCDMesonTracks
+{
+public: 
+       AliCDMesonTracks(); // constructor
+       ~AliCDMesonTracks(); // destructor
+
+       Bool_t ProcessEvent(AliAODEvent* aodEvent, AliESDEvent* esdEvent,
+                           Bool_t doSoft = kTRUE);
+
+       Int_t GetTracksBeforeCuts() const { return (fIsValid) ? fNTrk0 : -1; }
+       Int_t GetTracks() const { return (fIsValid) ? fNch : -1; }
+       Int_t GetSoftTracks() const { return (fIsValid && fDoSoft) ? fNsoft : -1; }
+       Int_t GetCombinedTracks() const { return (fIsValid) ? fNcombined : -1; }
+       Int_t GetITSpureSACount() const { return (fIsValid) ? fNITSpureSA : -1; }
+       Int_t GetRemainingTrackletsCentralBarrel() const {
+               return (fIsValid) ? fNtrackletsCentralBarrel : -1;
+       }
+       Int_t GetRemainingTrackletsForward() const {
+               return (fIsValid) ? fNtrackletsForward : -1;
+       }
+       AliVTrack* GetTrack(UInt_t index) const;
+
+       Double_t GetInvariantMass(Bool_t includeSoftTracks = kTRUE);
+protected:
+       void ApplyCuts();
+       void CutTrack(AliESDEvent *ESDEvent, Int_t mode = 0);
+       void CutTrack(AliAODEvent *AODEvent, Int_t mode = 0);
+       void GetRemainingTracklets();
+
+       AliAODEvent* fAODEvent; // AOD event to analyze
+       AliESDEvent* fESDEvent; // ESD event to analyze
+       Bool_t fDoAOD; // is active for AOD processing, inactive for ESDs
+       Bool_t fDoSoft; // process soft tracks
+       Bool_t fIsValid; // are the stored results valid
+
+       Int_t fNTrk0; // number of tracks before cuts
+       Int_t fNch; // number of charged ITSTPC tracks after cuts
+       Int_t fNsoft; // number of soft ITS standalone tracks (complementary to fNch)
+       Int_t fNcombined; // fNch+fNsoft
+       Int_t fNITSpureSA; // number of ITSpureSA tracks leading double counting
+
+       Int_t fNtrackletsCentralBarrel; // tracklets not assigned to tracks within
+                                       // |eta| < 0.9
+       Int_t fNtrackletsForward; // tracklets not assigned to tracks with |eta| > 0.9
+
+       TObjArray* fTracks; // storage for the standard tracks
+       TObjArray* fSoftTracks; // storage for the soft tracks
+private:
+       // following functions are only implemented to obey the coding conventions,
+       // they are not functional and hence should not be used
+       AliCDMesonTracks(const AliCDMesonTracks& tracks);
+       // copy constructor
+       AliCDMesonTracks& operator=(const AliCDMesonTracks& tracks);
+};
+
+#endif // ALICDMESONTRACKS_H
index 240aefe..af4eb1f 100644 (file)
@@ -4,6 +4,9 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class AliAnalysisTaskDDMeson+;
+#pragma link C++ class AliAnalysisTaskCDex+;
+#pragma link C++ class AliCDMesonBaseStripped+;
+#pragma link C++ class AliCDMesonTracks+;
+#pragma link C++ class AliCDMesonUtilsStripped+;
 
 #endif