Reduced events
authorrbailhac <rbailhac@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Feb 2013 12:17:37 +0000 (12:17 +0000)
committerrbailhac <rbailhac@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Feb 2013 12:17:37 +0000 (12:17 +0000)
14 files changed:
PWGHF/CMakelibPWGHFhfe.pkg
PWGHF/PWGHFhfeLinkDef.h
PWGHF/hfe/AliHFEBeautySpectrum.h
PWGHF/hfe/AliHFEreducedEvent.cxx [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedEvent.h [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedEventCreatorAOD.cxx [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedEventCreatorAOD.h [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedEventCreatorESD.cxx [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedEventCreatorESD.h [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedMCParticle.cxx [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedMCParticle.h [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedTrack.cxx [new file with mode: 0644]
PWGHF/hfe/AliHFEreducedTrack.h [new file with mode: 0644]
PWGHF/hfe/macros/AddTaskHFEreducedEvent.C [new file with mode: 0644]

index e4f651d..7a4fb5d 100644 (file)
@@ -89,6 +89,11 @@ set (SRCS
     hfe/AliHFEBeautySpectrumQA.cxx 
     hfe/AliHFEsmearDCA.cxx
     hfe/AliAnalysisTaskFlowTPCEMCalQCSP.cxx
+    hfe/AliHFEreducedEventCreatorAOD.cxx
+    hfe/AliHFEreducedEventCreatorESD.cxx
+    hfe/AliHFEreducedEvent.cxx
+    hfe/AliHFEreducedTrack.cxx
+    hfe/AliHFEreducedMCParticle.cxx
     )
 
 string (REPLACE ".cxx" ".h" HDRS "${SRCS}")
index e8a1e2d..7a278e4 100644 (file)
 #pragma link C++ class  AliHFEsmearDCA+;
 #pragma link C++ class  AliAnalysisTaskFlowTPCEMCalQCSP+;
 
+#pragma link C++ class  AliHFEreducedEventCreatorAOD+;
+#pragma link C++ class  AliHFEreducedEventCreatorESD+;
+#pragma link C++ class  AliHFEreducedEvent+;
+#pragma link C++ class  AliHFEreducedTrack+;
+#pragma link C++ class  AliHFEreducedMCParticle+;
+
 #endif
index 7a208bb..e33b632 100644 (file)
@@ -172,6 +172,6 @@ class AliHFEBeautySpectrum : public AliHFECorrectSpectrumBase{
   Bool_t fUnfoldBG;             // flag to unfold backgroud
   
   ClassDef(AliHFEBeautySpectrum, 1) 
-};
+    };
 #endif
 
diff --git a/PWGHF/hfe/AliHFEreducedEvent.cxx b/PWGHF/hfe/AliHFEreducedEvent.cxx
new file mode 100644 (file)
index 0000000..a01a827
--- /dev/null
@@ -0,0 +1,161 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug event
+// the tree is represented as reduced events
+// 
+// Authors:
+//   M.Fasel <M.Fasel@gsi.de>
+//
+
+#include "TObjArray.h"
+#include "AliHFEreducedTrack.h"
+#include "AliHFEreducedMCParticle.h"
+#include "AliHFEreducedEvent.h"
+
+ClassImp(AliHFEreducedEvent)
+
+//_______________________________________
+AliHFEreducedEvent::AliHFEreducedEvent():
+TObject(),
+  fTracks(NULL),
+  fMCparticles(NULL),
+  fNtracks(0),
+  fNmcparticles(0),
+  fRunNumber(0),
+  fTrigger(0),
+  fVX(0.),
+  fVY(0.),
+  fVZ(0.),
+  fNContrib(0),
+  fSPDMultiplicity(0)
+{
+  //
+  // Default constructor
+  //
+  fTracks = new TObjArray;
+  fTracks->SetOwner();
+  fMCparticles = new TObjArray;
+  fMCparticles->SetOwner();
+  memset(fCentrality, 0, sizeof(Float_t) * 6);
+  memset(fV0Multiplicity, 0, sizeof(Float_t) * 2);
+  memset(fZDCEnergy, 0, sizeof(Float_t) * 4);
+}
+
+//_______________________________________
+AliHFEreducedEvent::AliHFEreducedEvent(const AliHFEreducedEvent &ref):
+  TObject(ref),
+  fTracks(NULL),
+  fMCparticles(NULL),
+  fNtracks(ref.fNtracks),
+  fNmcparticles(ref.fNmcparticles),
+  fRunNumber(ref.fRunNumber),
+  fTrigger(ref.fTrigger),
+  fVX(ref.fVX),
+  fVY(ref.fVY),
+  fVZ(ref.fVZ),
+  fNContrib(ref.fNContrib),
+  fSPDMultiplicity(ref.fSPDMultiplicity)
+{
+  //
+  // Copy constructor
+  //
+  fTracks = new TObjArray;
+  fTracks->SetOwner();
+  for(int itrk = 0; itrk < ref.GetNumberOfTracks(); itrk++)
+    fTracks->Add(new AliHFEreducedTrack(*(ref.GetTrack(itrk))));
+  fMCparticles = new TObjArray;
+  fMCparticles->SetOwner();
+  for(int iprt = 0; iprt < ref.GetNumberOfMCParticles(); iprt++)
+    fMCparticles->Add(new AliHFEreducedMCParticle(*(ref.GetMCParticle(iprt))));
+  memcpy(fCentrality, ref.fCentrality, sizeof(Float_t) * 6);
+  memcpy(fV0Multiplicity, ref.fV0Multiplicity, sizeof(Float_t) * 2);
+  memcpy(fZDCEnergy, ref.fZDCEnergy, sizeof(Float_t) *4);
+}
+
+//_______________________________________
+AliHFEreducedEvent &AliHFEreducedEvent::operator=(const AliHFEreducedEvent &ref){
+  //
+  // Assignment operator
+  //
+  if(&ref != this){
+    TObject::operator=(ref);
+    fTracks->SetOwner();
+    fTracks->Clear();
+    for(int itrk = 0; itrk < ref.GetNumberOfTracks(); itrk++)
+      fTracks->Add(new AliHFEreducedTrack(*(ref.GetTrack(itrk))));
+    fMCparticles->Clear();
+    fMCparticles->SetOwner();
+    for(int iprt = 0; iprt < ref.GetNumberOfMCParticles(); iprt++)
+      fMCparticles->Add(new AliHFEreducedMCParticle(*(ref.GetMCParticle(iprt))));
+    fNtracks = ref.fNtracks;
+    fNmcparticles = ref.fNmcparticles;
+    fRunNumber = ref.fRunNumber;
+    fTrigger = ref.fTrigger;
+    fVX = ref.fVX;
+    fVY = ref.fVY;
+    fVZ = ref.fVZ;
+    fSPDMultiplicity = ref.fSPDMultiplicity;
+    memcpy(fCentrality, ref.fCentrality, sizeof(Float_t) * 6);
+    memcpy(fV0Multiplicity, ref.fV0Multiplicity, sizeof(Float_t) * 2);
+    memcpy(fZDCEnergy, ref.fZDCEnergy, sizeof(Float_t) *4);
+  }
+  return *this;
+}
+
+//_______________________________________
+AliHFEreducedEvent::~AliHFEreducedEvent(){
+  //
+  // Destructor: Clear tracks an MC particles
+  //
+  delete fTracks;
+  delete fMCparticles;
+}
+
+//_______________________________________
+void AliHFEreducedEvent::AddTrack(const AliHFEreducedTrack *track){
+  //
+  // Add track to the event
+  //
+  fTracks->Add(new AliHFEreducedTrack(*track));
+  fNtracks++;
+}
+
+//_______________________________________
+const AliHFEreducedTrack *AliHFEreducedEvent::GetTrack(Int_t itrk) const {
+  //
+  // Get Track
+  //
+  if(itrk < 0 || itrk >= fNtracks) return NULL;
+  return dynamic_cast<const AliHFEreducedTrack *>(fTracks->At(itrk));
+}
+
+//_______________________________________
+void AliHFEreducedEvent::AddMCParticle(const AliHFEreducedMCParticle *track){
+  //
+  // Add MC particle to the Event
+  //
+  fMCparticles->Add(new AliHFEreducedMCParticle(*track));
+  fNmcparticles++;
+}
+
+//_______________________________________
+const AliHFEreducedMCParticle *AliHFEreducedEvent::GetMCParticle(Int_t itrk) const {
+  //
+  // Get MC particle
+  //
+  if(itrk < 0 || itrk >= fNmcparticles) return NULL;
+  return dynamic_cast<const AliHFEreducedMCParticle *>(fMCparticles->At(itrk));
+}
diff --git a/PWGHF/hfe/AliHFEreducedEvent.h b/PWGHF/hfe/AliHFEreducedEvent.h
new file mode 100644 (file)
index 0000000..fc479d0
--- /dev/null
@@ -0,0 +1,140 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug event to look at the distribution of the variable we are cutting on
+//
+//
+#ifndef ALIHFEREDUCEDEVENT_H
+#define ALIHFEREDUCEDEVENT_H
+
+#include <TObject.h>
+
+class TObjArray;
+class AliHFEreducedTrack;
+class AliHFEreducedMCParticle;
+
+class AliHFEreducedEvent : public TObject{
+ public:
+  AliHFEreducedEvent();
+  AliHFEreducedEvent(const AliHFEreducedEvent &ref);
+  AliHFEreducedEvent &operator=(const AliHFEreducedEvent &ref);
+  ~AliHFEreducedEvent();
+  
+  void AddTrack(const AliHFEreducedTrack *track);
+  const AliHFEreducedTrack *GetTrack(int itrk) const;
+  Int_t GetNumberOfTracks() const { return fNtracks; }
+  void AddMCParticle(const AliHFEreducedMCParticle *mctrack);
+  const AliHFEreducedMCParticle *GetMCParticle(int itrk) const;
+  Int_t GetNumberOfMCParticles() const { return fNmcparticles; }
+  
+  Double_t GetVX() const { return fVX; }
+  Double_t GetVY() const { return fVY; }
+  Double_t GetVZ() const { return fVZ; }
+  Int_t GetNContribVertex() const { return fNContrib; }
+  Int_t GetRunNumber() const { return fRunNumber; }
+  Double_t GetCentrality() const { return fCentrality[0]; }
+  Double_t GetCentralityV0M() const { return fCentrality[0]; }
+  Double_t GetCentralityV0A() const { return fCentrality[1]; }
+  Double_t GetCentralityV0C() const { return fCentrality[2]; }
+  Double_t GetCentralityTracklets() const { return fCentrality[3]; }
+  Double_t GetCentralityTracks() const { return fCentrality[4]; }
+  Double_t GetCentralityZNA() const { return fCentrality[5]; }
+  Float_t GetV0AMultiplicity() const { return fV0Multiplicity[0]; }
+  Float_t GetV0CMultiplicity() const { return fV0Multiplicity[1]; }
+  Float_t GetV0MMultiplicity() const { return fV0Multiplicity[0] + fV0Multiplicity[1]; }
+  Float_t GetZNAEnergy() const { return fZDCEnergy[0]; }
+  Float_t GetZNCEnergy() const { return fZDCEnergy[1]; }
+  Float_t GetZPAEnergy() const { return fZDCEnergy[2]; }
+  Float_t GetZPCEnergy() const { return fZDCEnergy[3]; }
+  Float_t GetZDCNEnergySum() const { return fZDCEnergy[0] + fZDCEnergy[1]; }
+  Float_t GetZDCNEnergyDifference() const { return fZDCEnergy[0] - fZDCEnergy[1]; }
+  Float_t GetZDCNEnergyAsymmetry() const { return fZDCEnergy[0] + fZDCEnergy[1] != 0 ? (fZDCEnergy[0] - fZDCEnergy[1])/(fZDCEnergy[0] + fZDCEnergy[1]) : 1.; }
+  Float_t GetZDCPEnergySum() const { return fZDCEnergy[2] + fZDCEnergy[3]; }
+  Float_t GetZDCPEnergyDifference() const { return fZDCEnergy[2] - fZDCEnergy[3]; }
+  Float_t GetZDCPEnergyAsymmetry() const { return fZDCEnergy[2] + fZDCEnergy[3] != 0 ? (fZDCEnergy[2] - fZDCEnergy[3])/(fZDCEnergy[2] + fZDCEnergy[3]) : 1.; }
+  Int_t   GetSPDMultiplicity() const { return fSPDMultiplicity; }
+  
+  void SetVX(Double_t vx) { fVX = vx; }
+  void SetVY(Double_t vy) { fVY = vy; }
+  void SetVZ(Double_t vz) { fVZ = vz; }
+  void SetRunNumber(Int_t runnumber) { fRunNumber = runnumber; }
+  inline void SetCentrality(Float_t centV0M, Float_t centV0A, Float_t centV0C, Float_t centTLS, Float_t centTrks, Float_t centZNA);
+  void SetNContribVertex(Int_t ncontrib) { fNContrib = ncontrib; }
+  
+  Bool_t IsMBTrigger() const { return TESTBIT(fTrigger, kMB); }
+  Bool_t IsSemiCentralTrigger() const { return TESTBIT(fTrigger, kSemiCentral); }
+  Bool_t IsCentralTrigger() const { return TESTBIT(fTrigger, kCentral); }
+  Bool_t IsEMCalTrigger() const { return TESTBIT(fTrigger, kEMCAL); }
+  Bool_t IsTRDSETrigger() const { return TESTBIT(fTrigger, kTRDSE); }
+  Bool_t IsTRDDQTrigger() const { return TESTBIT(fTrigger, kTRDDQ); }
+  
+  void SetMBTrigger() { SETBIT(fTrigger, kMB); }
+  void SetSemiCentralTrigger() { SETBIT(fTrigger, kSemiCentral); }
+  void SetCentralTrigger() { SETBIT(fTrigger, kCentral); }
+  void SetEMCALTrigger() { SETBIT(fTrigger, kEMCAL); }
+  void SetTRDSETrigger() { SETBIT(fTrigger, kTRDSE); }
+  void SetTRDDQTrigger() { SETBIT(fTrigger, kTRDDQ); }
+  
+  void SetV0Multiplicity(Float_t v0A, Float_t v0C) {
+    fV0Multiplicity[0] = v0A;
+    fV0Multiplicity[1] = v0C;
+  }
+  inline void SetZDCEnergy(Float_t zna, Float_t znc, Float_t zpa, Float_t zpc);
+  void SetSPDMultiplicity(Int_t mult) { fSPDMultiplicity = mult; }
+  
+ private:
+  typedef enum{
+    kMB = 0,
+    kSemiCentral = 1,
+    kCentral = 2,
+    kEMCAL = 3,
+    kTRDSE = 4,
+    kTRDDQ = 5
+  } Trigger_t;
+  TObjArray *fTracks;           // Array with reconstructed tracks
+  TObjArray *fMCparticles;      // Array with MC particles
+  Int_t fNtracks;               // Number of tracks
+  Int_t fNmcparticles;          // Number of MC Particles
+  Int_t fRunNumber;             // Run Number
+  Float_t  fCentrality[6];      // Centrality (V0M, V0A, V0C, TLS, TRK, ZNA)
+  Int_t fTrigger;               // Trigger bits
+  Double_t fVX;                 // Vertex X
+  Double_t fVY;                 // Vertex Y
+  Double_t fVZ;                 // Vertex Z
+  Int_t    fNContrib;           // Number of vertex contributors
+  Float_t  fV0Multiplicity[2];  // V0 multiplicity
+  Float_t  fZDCEnergy[4];       // ZDC Energy (n,p)
+  Int_t    fSPDMultiplicity;    // SPD tracklet multiplicity
+  
+  ClassDef(AliHFEreducedEvent, 1)
+};
+
+//____________________________________________________________
+void AliHFEreducedEvent::SetCentrality(Float_t centV0M, Float_t centV0A, Float_t centV0C, Float_t centTLS, Float_t centTrks, Float_t centZNA) { 
+    fCentrality[0] = centV0M; 
+    fCentrality[1] = centV0A; 
+    fCentrality[2] = centV0C; 
+    fCentrality[3] = centTLS; 
+    fCentrality[4] = centTrks; 
+    fCentrality[5] = centZNA; 
+}
+//_________________________________________________________
+void AliHFEreducedEvent::SetZDCEnergy(Float_t zna, Float_t znc, Float_t zpa, Float_t zpc){
+  fZDCEnergy[0] = zna;
+  fZDCEnergy[1] = znc;
+  fZDCEnergy[2] = zpa;
+  fZDCEnergy[3] = zpc;
+}
+#endif
diff --git a/PWGHF/hfe/AliHFEreducedEventCreatorAOD.cxx b/PWGHF/hfe/AliHFEreducedEventCreatorAOD.cxx
new file mode 100644 (file)
index 0000000..4dfae37
--- /dev/null
@@ -0,0 +1,539 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree task
+// the tree is represented as reduced events
+// 
+// Authors:
+//   M.Fasel <M.Fasel@gsi.de>
+//
+#include <TArrayI.h>
+#include <TBits.h>
+#include <TFile.h>
+#include <TString.h>
+#include <TTree.h>
+
+#include "AliAnalysisManager.h"
+#include "AliAnalysisUtils.h"
+#include "AliAODEvent.h"
+#include "AliAODMCHeader.h"
+#include "AliAODMCParticle.h"
+#include "AliAODPid.h"
+#include "AliAODTrack.h"
+#include "AliAODTracklets.h"
+#include "AliAODVertex.h"
+#include "AliCentrality.h"
+#include "AliInputEventHandler.h"
+#include "AliHFEcuts.h"
+#include "AliHFEextraCuts.h"
+#include "AliHFEpidTPC.h"
+#include "AliHFEreducedEvent.h"
+#include "AliHFEreducedTrack.h"
+#include "AliHFEreducedMCParticle.h"
+#include "AliHFEsignalCuts.h"
+#include "AliLog.h"
+#include "AliMCEvent.h"
+#include "AliPIDResponse.h"
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVCluster.h"
+#include "AliVVZERO.h"
+#include "AliVZDC.h"
+#include "TTreeStream.h"
+
+#include "AliHFEreducedEventCreatorAOD.h"
+
+ClassImp(AliHFEreducedEventCreatorAOD)
+
+AliHFEreducedEventCreatorAOD::AliHFEreducedEventCreatorAOD():
+  AliAnalysisTaskSE(),
+  fAODMCHeader(NULL),
+  fAODArrayMCInfo(NULL),
+  fHFEtree(NULL),
+  fAnalysisUtils(NULL),
+  fHFEevent(NULL),
+  fTrackCuts(NULL),
+  fExtraCuts(NULL),
+  fSignalCuts(NULL),
+  fTPCpid(NULL),
+  fEventNumber(0),
+  fNclustersTPC(70),
+  fNclustersTPCPID(0),
+  fNclustersITS(2),
+  fRemoveFirstEvent(kFALSE)
+{
+  //
+  // Default constructor
+  //
+}
+
+AliHFEreducedEventCreatorAOD::AliHFEreducedEventCreatorAOD(const char *name):
+  AliAnalysisTaskSE(name),
+  fAODMCHeader(NULL),
+  fAODArrayMCInfo(NULL),
+  fHFEtree(NULL),
+  fAnalysisUtils(NULL),
+  fHFEevent(NULL),
+  fTrackCuts(NULL),
+  fExtraCuts(NULL),
+  fSignalCuts(NULL),
+  fTPCpid(NULL),
+  fEventNumber(0),
+  fNclustersTPC(70),
+  fNclustersTPCPID(0),
+  fNclustersITS(2),
+  fRemoveFirstEvent(kFALSE)
+{
+  //
+  // Default constructor
+  //
+  fTPCpid = new AliHFEpidTPC("QAtpcPID");
+  fAnalysisUtils = new AliAnalysisUtils;
+  DefineOutput(1, TTree::Class());
+}
+
+AliHFEreducedEventCreatorAOD::~AliHFEreducedEventCreatorAOD(){
+  //
+  // Default destructor
+  //
+    if(fTPCpid) delete fTPCpid;
+    if(fAnalysisUtils) delete fAnalysisUtils;
+    if(fHFEevent) delete fHFEevent;
+}
+
+void AliHFEreducedEventCreatorAOD::UserCreateOutputObjects(){
+  //
+  // Create debug tree, signal cuts and track cuts
+  //
+
+  //printf("test\n");
+
+ // printf("testa\n");
+  fSignalCuts = new AliHFEsignalCuts("HFEsignalCuts", "HFE MC Signal definition");
+  //printf("testb\n");
+  
+  fTrackCuts = new AliHFEcuts("fTrackCuts", "Basic HFE track cuts");
+  fTrackCuts->CreateStandardCuts();
+  fTrackCuts->SetAOD();
+  // Track cuts
+  fTrackCuts->SetMinNClustersTPC(fNclustersTPC);
+  fTrackCuts->SetMinRatioTPCclusters(0);
+  fTrackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); 
+  fTrackCuts->SetMinNClustersTPCPID(fNclustersTPCPID);
+  fTrackCuts->SetMinNClustersITS(fNclustersITS);
+  // Event cuts
+  fTrackCuts->SetUseMixedVertex(kTRUE);
+  fTrackCuts->SetVertexRange(10.);
+  //printf("testa\n");
+  fTrackCuts->Initialize();
+  //printf("testb\n");
+
+  fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
+
+  fHFEevent = new AliHFEreducedEvent;
+  OpenFile(1);
+  fHFEtree = new TTree("HFEtree", "HFE event tree");
+  fHFEtree->Branch("HFEevent", "AliHFEreducedEvent", fHFEevent,128000,0);
+  PostData(1, fHFEtree);
+}
+
+void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
+  //
+  // User Exec: Fill debug Tree
+  // 
+
+  // Get PID response
+  AliPIDResponse *pid = NULL;
+  AliInputEventHandler *handler = dynamic_cast<AliInputEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  if(handler){
+//    printf("testb\n");
+    pid = handler->GetPIDResponse();
+  } else {
+    AliError("No Handler");
+  }
+  if(!pid){
+ //   printf("testc\n");
+    AliError("No PID response");
+    return;
+  }
+  if(!fInputEvent) {
+    AliError("No Input event");
+    return;
+  }
+
+  if(fRemoveFirstEvent){
+    if(fAnalysisUtils->IsFirstEventInChunk(fInputEvent)) return;
+  }
+
+  AliAODTrack copyTrack;
+
+  // MC info
+  Bool_t mcthere = kTRUE;
+  AliAODEvent *aodE = dynamic_cast<AliAODEvent *>(fInputEvent);
+  if(!aodE){
+  //  printf("testd\n");
+    AliError("No AOD Event");
+    return;
+  }
+  fAODMCHeader = dynamic_cast<AliAODMCHeader *>(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName()));
+  if(!fAODMCHeader){ 
+      mcthere = kFALSE;
+  //   return;
+  }
+  fAODArrayMCInfo = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+  if(!fAODArrayMCInfo){ 
+      mcthere = kFALSE;
+  //  return;
+  }
+  else {
+    fSignalCuts->SetMCAODInfo(fAODArrayMCInfo);
+    fTrackCuts->SetMCEvent(aodE);
+  }
+
+  // Set for track cuts
+  if(mcthere){
+    // Check Monte-Carlo events for AODs
+    AliDebug(1, Form("Monte-Carlo Event: %p\n", fMCEvent));
+    if(fMCEvent){
+      AliDebug(1, Form("Available! Number of particles: %d\n", fMCEvent->GetNumberOfTracks()));
+    }
+  }
+  fTrackCuts->SetRecEvent(fInputEvent);
+
+  if(!fTrackCuts->CheckEventCuts("fCutsEvRec", fInputEvent)){
+    AliDebug(1, "Event rejected by the event cuts\n");
+    return;
+  }
+  if(!fExtraCuts){
+    fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
+  }
+  fExtraCuts->SetRecEventInfo(fInputEvent);
+
+  // Make Reduced Event 
+  //AliHFEreducedEvent hfeevent;
+  fHFEevent->~AliHFEreducedEvent();
+  new(fHFEevent)AliHFEreducedEvent();
+
+  // Get run number
+  fHFEevent->SetRunNumber(fInputEvent->GetRunNumber());
+
+  // Derive trigger 
+  UInt_t trigger = fInputHandler->IsEventSelected();
+  if(trigger & AliVEvent::kMB) fHFEevent->SetMBTrigger();
+  if(trigger & AliVEvent::kCentral) fHFEevent->SetCentralTrigger();
+  if(trigger & AliVEvent::kSemiCentral) fHFEevent->SetCentralTrigger();
+  if(trigger & AliVEvent::kEMCEJE) fHFEevent->SetEMCALTrigger();
+
+  // Get Primary Vertex
+  const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
+  Double_t vtx[3];
+  vertex->GetXYZ(vtx);
+  fHFEevent->SetVX(vtx[0]);
+  fHFEevent->SetVY(vtx[1]);
+  fHFEevent->SetVZ(vtx[2]);
+  Int_t ncontrib(fInputEvent->GetPrimaryVertex()->GetNContributors());
+  fHFEevent->SetNContribVertex(ncontrib);
+
+  // Get centrality
+  AliCentrality *hicent = fInputEvent->GetCentrality();
+  fHFEevent->SetCentrality(
+    hicent->GetCentralityPercentile("V0M"),
+    hicent->GetCentralityPercentile("V0A"),
+    hicent->GetCentralityPercentile("V0C"),
+    hicent->GetCentralityPercentile("TKL"),
+    hicent->GetCentralityPercentile("TRK"),
+    hicent->GetCentralityPercentile("ZNA")
+  );
+
+  // Get VZERO Information
+  AliVVZERO *vzeroinfo = fInputEvent->GetVZEROData();
+  if(vzeroinfo) fHFEevent->SetV0Multiplicity(vzeroinfo->GetMTotV0A(), vzeroinfo->GetMTotV0C());
+
+  // Get ZDC Information
+  AliVZDC *zdcinfo = fInputEvent->GetZDCData();
+  if(zdcinfo) fHFEevent->SetZDCEnergy(zdcinfo->GetZNAEnergy(), zdcinfo->GetZNCEnergy(), zdcinfo->GetZPAEnergy(), zdcinfo->GetZPCEnergy()); 
+  
+  // Set SPD multiplicity
+  AliAODTracklets *tls = aodE->GetTracklets();
+  if(tls) fHFEevent->SetSPDMultiplicity(tls->GetNumberOfTracklets());
+
+  // Look for kink mother
+  Int_t numberofvertices = aodE->GetNumberOfVertices();
+  Double_t listofmotherkink[numberofvertices];
+  Int_t numberofmotherkink = 0;
+  //printf("Number of vertices %d\n",numberofvertices);
+  for(Int_t ivertex=0; ivertex < numberofvertices; ivertex++) {
+    AliAODVertex *aodvertex = aodE->GetVertex(ivertex);
+    if(!aodvertex) continue;
+    //printf("Type %d\n",aodvertex->GetType());
+    if(aodvertex->GetType()==AliAODVertex::kKink) {
+      //printf("Find one kink\n");
+      AliAODTrack *mother = (AliAODTrack *) aodvertex->GetParent();
+      if(!mother) continue;
+      Int_t idmother = mother->GetID();
+      listofmotherkink[numberofmotherkink] = idmother;
+      //printf("ID %d\n",idmother);
+      numberofmotherkink++;
+    }
+  }
+  //printf("Number of kink mother in the events %d\n",numberofmotherkink);
+
+  //
+  // Loop on MC tracks only
+  //
+  AliAODMCParticle *mctrack(NULL);
+  // Monte-Carlo info
+  Int_t source(5);
+  if(mcthere){
+    for(Int_t itrack = 0; itrack < fAODArrayMCInfo->GetEntriesFast(); itrack++) {
+      mctrack = (AliAODMCParticle *)(fAODArrayMCInfo->At(itrack));
+      if(!mctrack) continue;
+      AliHFEreducedMCParticle hfemcpart;
+      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfemcpart.SetSignal();
+      // Kinematics
+      hfemcpart.SetSignedPt(mctrack->Pt(), mctrack->Charge() > 0.);
+      hfemcpart.SetP(mctrack->P());
+      hfemcpart.SetEta(mctrack->Eta());
+      hfemcpart.SetPhi(mctrack->Phi());
+      hfemcpart.SetPdg(mctrack->GetPdgCode());
+      
+      // Get Production Vertex in radial direction
+      hfemcpart.SetProductionVertex(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
+
+      // Get Mother PDG code of the particle
+      Int_t motherlabel = TMath::Abs(mctrack->GetMother());
+      if(motherlabel >= 0 && motherlabel < fAODArrayMCInfo->GetEntriesFast()){
+        AliAODMCParticle *mother = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(motherlabel));
+        if(mother) hfemcpart.SetMotherPdg(mother->GetPdgCode());
+      }
+      
+      // derive source
+      source = 5;
+      if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
+      else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
+      else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
+      else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
+      else if(TMath::Abs(mctrack->GetPdgCode()) == 11) source = 4;
+      else source = 5;
+      hfemcpart.SetSource(source);
+
+      fHFEevent->AddMCParticle(&hfemcpart);
+    }
+  }
+  
+  //
+  // Loop on reconstructed tracks
+  //
+  TArrayI arraytrack(fInputEvent->GetNumberOfTracks());
+  Int_t counterdc=0;
+  
+  AliAODTrack *track = 0x0;
+  for(Int_t itrack = 0; itrack < fInputEvent->GetNumberOfTracks(); itrack++){
+    // Run track loop
+    track = dynamic_cast<AliAODTrack *>(fInputEvent->GetTrack(itrack));
+    if(!track) continue;
+    // Cut track (Only basic track cuts)
+    // printf("testv\n");
+    if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC, track)) continue;
+    //
+    //printf("testu\n");
+
+    // Kinematics
+    AliHFEreducedTrack hfetrack;
+    hfetrack.SetSignedPt(track->Pt(), track->Charge() > 0);
+    hfetrack.SetP(track->P());
+    hfetrack.SetEta(track->Eta());
+    hfetrack.SetPhi(track->Phi());
+    hfetrack.SetTPCmomentum(track->GetDetPid() ? track->GetDetPid()->GetTPCmomentum() : track->P());
+
+    // Track ID
+    hfetrack.SetTrackID(track->GetID());
+
+    // status
+    ULong_t status = track->GetStatus();
+    if((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) hfetrack.SetITSrefit();
+    if((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) hfetrack.SetTPCrefit();
+    if((status & AliVTrack::kTOFpid) == AliVTrack::kTOFpid) hfetrack.SetTOFpid();
+    //if((status & AliVTrack::kTOFmismatch) == AliVTrack::kTOFmismatch) hfetrack.SetTOFmismatch();
+    if(IsTOFmismatch(track, pid)) hfetrack.SetTOFmismatch(); // New version suggested by Pietro Antonioli
+    if(track->IsEMCAL()) hfetrack.SetEMCALpid();
+    // Filter
+    for(Int_t k=0; k<20; k++) {
+      Int_t u = 1<<k;     
+      if((track->TestFilterBit(u))) {
+             hfetrack.SetFilterBit(k);
+      } 
+    }
+
+    if(mcthere){
+      // Fill Monte-Carlo Information
+      Int_t label = TMath::Abs(track->GetLabel());
+      if(label && label < fAODArrayMCInfo->GetEntriesFast())
+        mctrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(label));
+      if(!mctrack) continue;
+      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfetrack.SetMCSignal();
+      // Kinematics
+      hfetrack.SetMCSignedPt(mctrack->Pt(),mctrack->Charge() > 0.);
+      hfetrack.SetMCP(mctrack->P());
+      hfetrack.SetMCEta(mctrack->Eta());
+      hfetrack.SetMCPhi(mctrack->Phi());
+      hfetrack.SetMCPDG(mctrack->GetPdgCode());
+      
+      // Get Production Vertex in radial direction
+      hfetrack.SetMCProdVtx(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
+      
+      // Get Mother PDG code of the particle
+      Int_t motherlabel = TMath::Abs(mctrack->GetMother());
+      if(motherlabel >= 0 && motherlabel < fAODArrayMCInfo->GetEntriesFast()){
+        AliAODMCParticle *mother = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(motherlabel));
+        if(mother) hfetrack.SetMCMotherPdg(mother->GetPdgCode());
+      }
+      
+      // derive source
+      source = 5;
+      if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
+      else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
+      else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
+      else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
+      else if(TMath::Abs(mctrack->GetPdgCode()) == 11) source = 4;
+      else source = 5;
+      hfetrack.SetMCSource(source); 
+    }
+
+    // HFE DCA
+    Float_t dcaxy = -999.,
+            dcaz = -999.;
+    fExtraCuts->GetImpactParameters((AliVTrack *)track,dcaxy,dcaz);
+    hfetrack.SetDCA(dcaxy, dcaz);
+
+    // Different number of clusters definitions
+    Int_t nclustersITS(track->GetITSNcls()),
+          nclustersTPC(track->GetTPCNcls()),
+          nclustersTPCall(track->GetTPCClusterMap().CountBits()),
+          nclustersTPCshared(0);
+    UChar_t nfindableTPC = track->GetTPCNclsF();
+    const TBits &sharedTPC = track->GetTPCSharedMap();
+    for(Int_t ibit = 0; ibit < 160; ibit++) if(sharedTPC.TestBitNumber(ibit)) nclustersTPCshared++;
+    hfetrack.SetITSnclusters(nclustersITS);
+    hfetrack.SetTPCnclusters(track->GetTPCNcls());
+    hfetrack.SetTRDnclusters(track->GetTRDncls());
+    hfetrack.SetTPCnclustersPID(track->GetTPCsignalN());
+    hfetrack.SetTPCcrossedRows(track->GetTPCNCrossedRows());
+    hfetrack.SetTPCnclustersAll(nclustersTPCall);
+    hfetrack.SetTPCsharedClusters(nclustersTPCshared);
+    hfetrack.SetTPCclusterRatio(nfindableTPC ? static_cast<Float_t>(nclustersTPC)/static_cast<Float_t>(nfindableTPC) : 0);
+    hfetrack.SetTPCclusterRatioAll(nfindableTPC ? static_cast<Float_t>(nclustersTPCall)/static_cast<Float_t>(nfindableTPC) : 0);
+    UChar_t itsPixel = track->GetITSClusterMap();
+    for(int ily = 0; ily < 6; ily++) 
+            if(TESTBIT(itsPixel, ily)) hfetrack.SetITScluster(ily);
+   
+    // TRD related quantities (Yvonne)
+    hfetrack.SetTRDntrackletsPID(track->GetTRDntrackletsPID());
+    hfetrack.SetTRDnslices(track->GetDetPid()->GetTRDnSlices());
+    hfetrack.SetTRDchi2(track->GetTRDchi2());
+    AliAODPid* aodpid= track->GetDetPid();
+    Double_t* arraytrdsignals;
+    arraytrdsignals=aodpid->GetTRDslices();
+    Int_t nslicetemp=0;
+    for(Int_t iplane = 0; iplane < 6; iplane++){
+           nslicetemp=0;
+           for(Int_t b=(iplane*8);b<((iplane*8)+8);b++){
+             if(track->GetTRDntrackletsPID()>0){
+                     if(arraytrdsignals[b]>0.001) nslicetemp++;
+             }
+           }
+           if(nslicetemp > 0) hfetrack.SetTRDstatus(iplane);
+    }
+
+
+    // Kink
+    Int_t kink = 0;
+    if(fExtraCuts->IsKinkDaughter(track)) kink = 1;
+
+    // kink mother
+    Int_t kinkmotherpass = 0;
+    for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {
+      if(track->GetID() == listofmotherkink[kinkmother]) {
+             kinkmotherpass = 1;
+             continue;
+      }
+    }
+    
+    // Double counted
+    Int_t id(track->GetID());
+    for(Int_t l=0; l < counterdc; l++){
+      Int_t iTrack2 = arraytrack.At(l);
+      if(iTrack2==id){
+         hfetrack.SetDoubleCounted();
+         break;
+      }
+    }
+    // Add the id at this place
+    arraytrack.AddAt(id,counterdc);
+    counterdc++;
+
+    // PID
+    hfetrack.SetTPCdEdx(track->GetDetPid() ? track->GetDetPid()->GetTPCsignal() : 0.);
+    hfetrack.SetTPCsigmaEl(pid->NumberOfSigmasTPC(track, AliPID::kElectron));
+    hfetrack.SetTOFsigmaEl(pid->NumberOfSigmasTOF(track, AliPID::kElectron));
+    hfetrack.SetTOFmismatchProbability(pid->GetTOFMismatchProbability(track));
+    // Eta correction
+    copyTrack.~AliAODTrack();
+    new(&copyTrack) AliAODTrack(*track);
+    if(fTPCpid->HasCentralityCorrection()) fTPCpid->ApplyCentralityCorrection(&copyTrack, static_cast<Double_t>(ncontrib),AliHFEpidObject::kAODanalysis);
+    if(fTPCpid->HasEtaCorrection()) fTPCpid->ApplyEtaCorrection(&copyTrack, AliHFEpidObject::kAODanalysis);
+    hfetrack.SetTPCsigmaElCorrected(pid->NumberOfSigmasTPC(&copyTrack, AliPID::kElectron));
+    hfetrack.SetTPCdEdxCorrected(copyTrack.GetDetPid() ? copyTrack.GetDetPid()->GetTPCsignal() : 0.);
+    if(track->IsEMCAL()){
+      // EMCAL cluster
+      Double_t emcalEnergyOverP = -1.,
+               showershape[4] = {0.,0.,0.,0.};
+      hfetrack.SetEMCALSigmaEl(pid->NumberOfSigmasEMCAL(track, AliPID::kElectron, emcalEnergyOverP, &showershape[0]));
+      hfetrack.SetEMCALEoverP(emcalEnergyOverP);
+      hfetrack.SetEMCALShowerShape(showershape);
+    }
+
+    // Track finished, add NOW to the Event
+    fHFEevent->AddTrack(&hfetrack);
+    //printf("after\n");
+  }
+  
+  // Fill the debug tree
+  AliInfo(Form("Number of tracks: %d\n", fHFEevent->GetNumberOfTracks()));
+  AliInfo(Form("Number of MC particles: %d\n", fHFEevent->GetNumberOfMCParticles()));
+  fHFEtree->Fill();
+
+  fEventNumber++;
+  PostData(1, fHFEtree);
+}
+
+void AliHFEreducedEventCreatorAOD::Terminate(Option_t *){
+  //
+  // Terminate
+  //
+  AliInfo("terminating...\n");
+
+}
+
+Bool_t AliHFEreducedEventCreatorAOD::IsTOFmismatch(const AliVTrack *const track, const AliPIDResponse *const pid) const {
+  //
+  // is TOF mismatch
+  //
+  Double_t probs[AliPID::kSPECIESC];
+  AliPIDResponse::EDetPidStatus status = pid->ComputeTOFProbability(track, AliPID::kSPECIESC, probs);
+  return status == AliPIDResponse::kDetMismatch;
+}
+
diff --git a/PWGHF/hfe/AliHFEreducedEventCreatorAOD.h b/PWGHF/hfe/AliHFEreducedEventCreatorAOD.h
new file mode 100644 (file)
index 0000000..84ec692
--- /dev/null
@@ -0,0 +1,77 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree to look at the distribution of the variable we are cutting on
+//
+//
+#ifndef ALIHFEREDUCEDEVENTCREATORAOD_H
+#define ALIHFEREDUCEDEVENTCREATORAOD_H
+
+#include "AliAnalysisTaskSE.h"
+
+class TClonesArray;
+class TString;
+class TTree;
+class AliAODMCHeader;
+class AliAnalysisUtils;
+class AliPIDResponse;
+class AliHFEcuts;
+class AliHFEextraCuts;
+class AliHFEpidTPC;
+class AliHFEsignalCuts;
+class AliHFEreducedEvent;
+
+class AliHFEreducedEventCreatorAOD : public AliAnalysisTaskSE{
+  public:
+    AliHFEreducedEventCreatorAOD();
+    AliHFEreducedEventCreatorAOD(const char *name);
+    virtual ~AliHFEreducedEventCreatorAOD();
+
+    virtual void UserCreateOutputObjects();
+    virtual void UserExec(Option_t *);
+    virtual void Terminate(Option_t *);
+
+    // Setters for cuts
+    void SetMinNclustersTPC(Int_t mincl) { fNclustersTPC = mincl; };
+    void SetMinNclustersTPCPID(Int_t mincl) { fNclustersTPCPID = mincl; };
+    void SetMinNclustersITS(Int_t mincl) { fNclustersITS = mincl; };
+    AliHFEpidTPC *GetTPCResponse() { return fTPCpid; }
+
+    Bool_t IsTOFmismatch(const AliVTrack *const track, const AliPIDResponse *const pid) const;
+    
+  private:
+    AliHFEreducedEventCreatorAOD(const AliHFEreducedEventCreatorAOD &);
+    AliHFEreducedEventCreatorAOD &operator=(const AliHFEreducedEventCreatorAOD &);
+
+    AliAODMCHeader *fAODMCHeader;     // ! MC info AOD
+    TClonesArray *fAODArrayMCInfo;    // ! MC info particle AOD
+    TTree *fHFEtree;                  // HFE tree 
+    AliAnalysisUtils *fAnalysisUtils; // Analysis Utils
+    AliHFEreducedEvent *fHFEevent;    // hfe event
+    AliHFEcuts *fTrackCuts;           // Track
+    AliHFEextraCuts *fExtraCuts;      // HFE IP info
+    AliHFEsignalCuts *fSignalCuts;    // Signal Cuts
+    AliHFEpidTPC *fTPCpid;            // TPC PID
+    Int_t fEventNumber;               // Event Number
+    Int_t fNclustersTPC;              // Min Number of clusters in TPC
+    Int_t fNclustersTPCPID;           // Min Number of clusters for TPC PID
+    Int_t fNclustersITS;              // Min Number of clusters in ITS
+    Bool_t fRemoveFirstEvent;         // Remove first event from chunk
+  
+    ClassDef(AliHFEreducedEventCreatorAOD, 1)
+};
+#endif
+
+
diff --git a/PWGHF/hfe/AliHFEreducedEventCreatorESD.cxx b/PWGHF/hfe/AliHFEreducedEventCreatorESD.cxx
new file mode 100644 (file)
index 0000000..8037b0d
--- /dev/null
@@ -0,0 +1,497 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree task
+// the tree is represented as reduced events
+// 
+// Authors:
+//   M.Fasel <M.Fasel@gsi.de>
+//
+//
+#include <TArrayI.h>
+#include <TBits.h>
+#include <TFile.h>
+#include <TParticle.h>
+#include <TString.h>
+#include <TTree.h>
+
+#include "AliAnalysisManager.h"
+#include "AliAODMCHeader.h"
+#include "AliAnalysisUtils.h"
+#include "AliCentrality.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliInputEventHandler.h"
+#include "AliHFEcuts.h"
+#include "AliHFEextraCuts.h"
+#include "AliHFEpidTPC.h"
+#include "AliHFEreducedEvent.h"
+#include "AliHFEreducedTrack.h"
+#include "AliHFEreducedMCParticle.h"
+#include "AliHFEsignalCuts.h"
+#include "AliLog.h"
+#include "AliMCEvent.h"
+#include "AliMCParticle.h"
+#include "AliMCEventHandler.h"
+#include "AliMultiplicity.h"
+#include "AliPIDResponse.h"
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVCluster.h"
+#include "AliVVZERO.h"
+#include "AliVZDC.h"
+#include "TTreeStream.h"
+
+#include "AliHFEreducedEventCreatorESD.h"
+
+ClassImp(AliHFEreducedEventCreatorESD)
+
+AliHFEreducedEventCreatorESD::AliHFEreducedEventCreatorESD():
+  AliAnalysisTaskSE(),
+  fHFEtree(NULL),
+  fAnalysisUtils(NULL),
+  fHFEevent(NULL),
+  fTrackCuts(NULL),
+  fExtraCuts(NULL),
+  fSignalCuts(NULL),
+  fTPCpid(NULL),
+  fEventNumber(0),
+  fNclustersTPC(70),
+  fNclustersTPCPID(0),
+  fNclustersITS(2),
+  fRemoveFirstEvent(kFALSE)
+{
+  //
+  // Default constructor
+  //
+}
+
+AliHFEreducedEventCreatorESD::AliHFEreducedEventCreatorESD(const char *name):
+  AliAnalysisTaskSE(name),
+  fHFEtree(NULL),
+  fAnalysisUtils(NULL),
+  fHFEevent(NULL),
+  fTrackCuts(NULL),
+  fExtraCuts(NULL),
+  fSignalCuts(NULL),
+  fTPCpid(NULL),
+  fEventNumber(0),
+  fNclustersTPC(70),
+  fNclustersTPCPID(0),
+  fNclustersITS(2),
+  fRemoveFirstEvent(kFALSE)
+{
+  //
+  // Default constructor
+  //
+  fTPCpid = new AliHFEpidTPC("QAtpcPID");
+  fAnalysisUtils = new AliAnalysisUtils;
+  DefineOutput(1, TTree::Class());
+}
+
+AliHFEreducedEventCreatorESD::~AliHFEreducedEventCreatorESD(){
+  //
+  // Default destructor
+  //
+  if(fAnalysisUtils) delete fAnalysisUtils;
+  if(fTPCpid) delete fTPCpid;
+  if(fHFEevent) delete fHFEevent;
+  if(fSignalCuts) delete fSignalCuts;
+  if(fTrackCuts) delete fTrackCuts;
+}
+
+void AliHFEreducedEventCreatorESD::UserCreateOutputObjects(){
+  //
+  // Create debug tree, signal cuts and track cuts
+  //
+
+  //printf("test\n");
+
+ // printf("testa\n");
+  fSignalCuts = new AliHFEsignalCuts("HFEsignalCuts", "HFE MC Signal definition");
+  //printf("testb\n");
+  
+  fTrackCuts = new AliHFEcuts("fTrackCuts", "Basic HFE track cuts");
+  fTrackCuts->CreateStandardCuts();
+  // Track cuts
+  fTrackCuts->SetMinNClustersTPC(fNclustersTPC);
+  fTrackCuts->SetMinRatioTPCclusters(0);
+  fTrackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable); 
+  fTrackCuts->SetMinNClustersTPCPID(fNclustersTPCPID);
+  fTrackCuts->SetMinNClustersITS(fNclustersITS);
+  // Event cuts
+  fTrackCuts->SetUseMixedVertex(kTRUE);
+  fTrackCuts->SetVertexRange(10.);
+  //printf("testa\n");
+  fTrackCuts->Initialize();
+  //printf("testb\n");
+
+  fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
+
+  fHFEevent = new AliHFEreducedEvent;
+  OpenFile(1);
+  fHFEtree = new TTree("HFEtree", "HFE event tree");
+  fHFEtree->Branch("HFEevent", "AliHFEreducedEvent", fHFEevent,128000,0);
+  PostData(1, fHFEtree);
+}
+
+void AliHFEreducedEventCreatorESD::UserExec(Option_t *){
+  //
+  // User Exec: Fill debug Tree
+  // 
+
+  // Get PID response
+  AliPIDResponse *pid = NULL;
+  AliInputEventHandler *handler = dynamic_cast<AliInputEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  if(handler){
+//    printf("testb\n");
+    pid = handler->GetPIDResponse();
+  } else {
+    AliError("No Handler");
+  }
+  if(!pid){
+ //   printf("testc\n");
+    AliError("No PID response");
+    return;
+  }
+  if(!fInputEvent) {
+    AliError("No Input event");
+    return;
+  }
+
+  if(fRemoveFirstEvent){
+    if(fAnalysisUtils->IsFirstEventInChunk(fInputEvent)) return;
+  }
+
+  AliDebug(1, "Event Selected");
+
+  AliESDtrack copyTrack;
+
+  // MC info
+  Bool_t mcthere = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()) != NULL;
+  if(mcthere){ 
+    fTrackCuts->SetMCEvent(fMCEvent);
+    fSignalCuts->SetMCEvent(fMCEvent);
+  }  
+
+  fTrackCuts->SetRecEvent(fInputEvent);
+
+  if(!fTrackCuts->CheckEventCuts("fCutsEvRec", fInputEvent)){
+    AliDebug(1, "Event rejected by the event cuts\n");
+    return;
+  }
+  
+  // reject pile up in case of pp
+  AliESDEvent *event = dynamic_cast<AliESDEvent *>(fInputEvent);
+  if(event) {
+    TString beamtype = event->GetBeamType();
+    //printf("beamtype %s\n",(const char*)beamtype);
+    if (strstr(beamtype,"p-p")) {
+      //printf("Reject\n");
+      if(fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5)){
+       AliDebug(1, "Event flagged as pileup\n");
+       return;
+      }
+    }
+  }
+
+  if(!fExtraCuts){
+    fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
+  }
+  fExtraCuts->SetRecEventInfo(fInputEvent);
+
+
+  // Make Reduced Event 
+  //AliHFEreducedEvent hfeevent;
+  fHFEevent->~AliHFEreducedEvent();
+  new(fHFEevent)AliHFEreducedEvent();
+
+  // Get run number
+  fHFEevent->SetRunNumber(fInputEvent->GetRunNumber());
+
+  // Derive trigger 
+  UInt_t trigger = fInputHandler->IsEventSelected();
+  if(trigger & AliVEvent::kMB) fHFEevent->SetMBTrigger();
+  if(trigger & AliVEvent::kCentral) fHFEevent->SetCentralTrigger();
+  if(trigger & AliVEvent::kSemiCentral) fHFEevent->SetCentralTrigger();
+  if(trigger & AliVEvent::kEMCEJE) fHFEevent->SetEMCALTrigger();
+
+  // Get Primary Vertex
+  const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
+  Double_t vtx[3];
+  vertex->GetXYZ(vtx);
+  fHFEevent->SetVX(vtx[0]);
+  fHFEevent->SetVY(vtx[1]);
+  fHFEevent->SetVZ(vtx[2]);
+  Int_t ncontrib(fInputEvent->GetPrimaryVertex()->GetNContributors());
+  fHFEevent->SetNContribVertex(ncontrib);
+
+  // Get centrality
+  AliCentrality *hicent = fInputEvent->GetCentrality();
+  fHFEevent->SetCentrality(
+    hicent->GetCentralityPercentile("V0M"),
+    hicent->GetCentralityPercentile("V0A"),
+    hicent->GetCentralityPercentile("V0C"),
+    hicent->GetCentralityPercentile("TKL"),
+    hicent->GetCentralityPercentile("TRK"),
+    hicent->GetCentralityPercentile("ZNA")
+  );
+  
+  // Get VZERO Information
+  AliVVZERO *vzeroinfo = fInputEvent->GetVZEROData();
+  if(vzeroinfo) fHFEevent->SetV0Multiplicity(vzeroinfo->GetMTotV0A(), vzeroinfo->GetMTotV0C());
+
+  // Get ZDC Information
+  AliVZDC *zdcinfo = fInputEvent->GetZDCData();
+  if(zdcinfo) fHFEevent->SetZDCEnergy(zdcinfo->GetZNAEnergy(), zdcinfo->GetZNCEnergy(), zdcinfo->GetZPAEnergy(), zdcinfo->GetZPCEnergy()); 
+
+  // Set SPD multiplicity
+  const AliMultiplicity *mult = event->GetMultiplicity();
+  if(mult) fHFEevent->SetSPDMultiplicity(mult->GetNumberOfTracklets());
+
+  //
+  // Loop on MC tracks only
+  //
+  AliMCParticle *mctrack(NULL);
+  // Monte-Carlo info
+  Int_t source(5);
+  if(mcthere){
+    for(Int_t itrack = 0; itrack < fMCEvent->GetNumberOfTracks(); itrack++) {
+      mctrack = (AliMCParticle *)(fMCEvent->GetTrack(itrack));
+      if(!mctrack) continue;
+      AliHFEreducedMCParticle hfemcpart;
+      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfemcpart.SetSignal();
+      // Kinematics
+      hfemcpart.SetSignedPt(mctrack->Pt(), mctrack->Charge() > 0.);
+      hfemcpart.SetP(mctrack->P());
+      hfemcpart.SetEta(mctrack->Eta());
+      hfemcpart.SetPhi(mctrack->Phi());
+      hfemcpart.SetPdg(mctrack->PdgCode());
+      
+      // Get Production Vertex in radial direction
+      hfemcpart.SetProductionVertex(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
+
+      // Get Mother PDG code of the particle
+      Int_t motherlabel = TMath::Abs(mctrack->GetMother());
+      if(motherlabel >= 0 && motherlabel < fMCEvent->GetNumberOfTracks()){
+        AliMCParticle *mother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(motherlabel));
+        if(mother) hfemcpart.SetMotherPdg(mother->PdgCode());
+      }
+      
+      // derive source
+      source = 5;
+      if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
+      else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
+      else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
+      else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
+      else if(TMath::Abs(mctrack->PdgCode()) == 11) source = 4;
+      else source = 5;
+      hfemcpart.SetSource(source);
+
+      fHFEevent->AddMCParticle(&hfemcpart);
+    }
+  }
+  
+  //
+  // Loop on reconstructed tracks
+  //
+  TArrayI arraytrack(fInputEvent->GetNumberOfTracks());
+  Int_t counterdc=0;
+  
+  AliESDtrack *track = 0x0;
+  for(Int_t itrack = 0; itrack < fInputEvent->GetNumberOfTracks(); itrack++){
+    // Run track loop
+    track = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(itrack));
+    if(!track) continue;
+    // Cut track (Only basic track cuts)
+    // printf("testv\n");
+    if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC, track)) continue;
+    //
+    //printf("testu\n");
+
+    // Kinematics
+    AliHFEreducedTrack hfetrack;
+    hfetrack.SetSignedPt(track->Pt(), track->Charge() > 0);
+    hfetrack.SetP(track->P());
+    hfetrack.SetEta(track->Eta());
+    hfetrack.SetPhi(track->Phi());
+    hfetrack.SetTPCmomentum(track->GetTPCmomentum());
+
+    // Track ID
+    hfetrack.SetTrackID(track->GetID());
+
+    // status
+    ULong_t status = track->GetStatus();
+    if((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) hfetrack.SetITSrefit();
+    if((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) hfetrack.SetTPCrefit();
+    if((status & AliVTrack::kTOFpid) == AliVTrack::kTOFpid) hfetrack.SetTOFpid();
+    //if((status & AliVTrack::kTOFmismatch) == AliVTrack::kTOFmismatch) hfetrack.SetTOFmismatch();
+    if(IsTOFmismatch(track, pid)) hfetrack.SetTOFmismatch(); // New version suggested by Pietro Antonioli
+    if(track->IsEMCAL()) hfetrack.SetEMCALpid();
+    // no filter bits available for ESDs
+
+    if(mcthere){
+      // Fill Monte-Carlo Information
+      Int_t label = TMath::Abs(track->GetLabel());
+      if(label && label < fMCEvent->GetNumberOfTracks())
+        mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(label));
+      if(!mctrack) continue;
+      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfetrack.SetMCSignal();
+      // Kinematics
+      hfetrack.SetMCSignedPt(mctrack->Pt(),mctrack->Charge() > 0.);
+      hfetrack.SetMCP(mctrack->P());
+      hfetrack.SetMCEta(mctrack->Eta());
+      hfetrack.SetMCPhi(mctrack->Phi());
+      hfetrack.SetMCPDG(mctrack->PdgCode());
+      
+      // Get Production Vertex in radial direction
+      hfetrack.SetMCProdVtx(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
+      
+      // Get Mother PDG code of the particle
+      Int_t motherlabel = TMath::Abs(mctrack->GetMother());
+      if(motherlabel >= 0 && motherlabel < fMCEvent->GetNumberOfTracks()){
+        AliMCParticle *mother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(motherlabel));
+        if(mother) hfetrack.SetMCMotherPdg(mother->PdgCode());
+      }
+      
+      // derive source
+      source = 5;
+      if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
+      else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
+      else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
+      else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
+      else if(TMath::Abs(mctrack->PdgCode()) == 11) source = 4;
+      else source = 5;
+      hfetrack.SetMCSource(source); 
+    }
+
+    // HFE DCA
+    Float_t dcaxy = -999.,
+            dcaz = -999.;
+    fExtraCuts->GetImpactParameters((AliVTrack *)track,dcaxy,dcaz);
+    hfetrack.SetDCA(dcaxy, dcaz);
+
+    // Different number of clusters definitions
+    Int_t nclustersITS(track->GetITSclusters(NULL)),
+          nclustersTPC(track->GetTPCNcls()),
+          nclustersTPCall(track->GetTPCClusterMap().CountBits()),
+          nclustersTPCshared(0);
+    UChar_t nfindableTPC = track->GetTPCNclsF();
+    const TBits &sharedTPC = track->GetTPCSharedMap();
+    for(Int_t ibit = 0; ibit < 160; ibit++) if(sharedTPC.TestBitNumber(ibit)) nclustersTPCshared++;
+    hfetrack.SetITSnclusters(nclustersITS);
+    hfetrack.SetTPCnclusters(nclustersTPC);
+    hfetrack.SetTRDnclusters(track->GetTRDncls());
+    hfetrack.SetTPCnclustersPID(track->GetTPCsignalN());
+    hfetrack.SetTPCcrossedRows(track->GetTPCCrossedRows());
+    hfetrack.SetTPCnclustersAll(nclustersTPCall);
+    hfetrack.SetTPCsharedClusters(nclustersTPCshared);
+    hfetrack.SetTPCclusterRatio(nfindableTPC ? static_cast<Float_t>(nclustersTPC)/static_cast<Float_t>(nfindableTPC) : 0);
+    hfetrack.SetTPCclusterRatioAll(nfindableTPC ? static_cast<Float_t>(nclustersTPCall)/static_cast<Float_t>(nfindableTPC) : 0);
+    UChar_t itsPixel = track->GetITSClusterMap();
+    for(int ily = 0; ily < 6; ily++) 
+            if(TESTBIT(itsPixel, ily)) hfetrack.SetITScluster(ily);
+   
+    // TRD related quantities (Yvonne)
+    Int_t nslices = track->GetNumberOfTRDslices();
+    hfetrack.SetTRDntrackletsPID(track->GetTRDntrackletsPID());
+    hfetrack.SetTRDnslices(nslices);
+    hfetrack.SetTRDchi2(track->GetTRDchi2());
+    Int_t nslicetemp=0;
+    for(Int_t iplane = 0; iplane < 6; iplane++){
+           nslicetemp=0;
+           for(Int_t isl = 0; isl < nslices; isl++){
+             if(track->GetTRDntrackletsPID()>0){
+                     if(track->GetTRDslice(iplane, isl)>0.001) nslicetemp++;
+             }
+           }
+           if(nslicetemp > 0) hfetrack.SetTRDstatus(iplane);
+    }
+
+
+    // Kink
+    Int_t kink = 0;
+    if(fExtraCuts->IsKinkDaughter(track)) kink = 1;
+
+    // kink mother
+    Int_t kinkmotherpass = 0;
+    if(track->GetKinkIndex(0) != 0 && !kink) kinkmotherpass = 1;
+    
+    // Double counted
+    Int_t id(track->GetID());
+    for(Int_t l=0; l < counterdc; l++){
+      Int_t iTrack2 = arraytrack.At(l);
+      if(iTrack2==id){
+         hfetrack.SetDoubleCounted();
+         break;
+      }
+    }
+    // Add the id at this place
+    arraytrack.AddAt(id,counterdc);
+    counterdc++;
+
+    // PID
+    hfetrack.SetTPCdEdx(track->GetTPCsignal());
+    hfetrack.SetTPCsigmaEl(pid->NumberOfSigmasTPC(track, AliPID::kElectron));
+    hfetrack.SetTOFsigmaEl(pid->NumberOfSigmasTOF(track, AliPID::kElectron));
+    hfetrack.SetTOFmismatchProbability(pid->GetTOFMismatchProbability(track));
+    // Eta correction
+    copyTrack.~AliESDtrack();
+    new(&copyTrack) AliESDtrack(*track);
+    if(fTPCpid->HasCentralityCorrection()) fTPCpid->ApplyCentralityCorrection(&copyTrack, static_cast<Double_t>(ncontrib),AliHFEpidObject::kESDanalysis);
+    if(fTPCpid->HasEtaCorrection()) fTPCpid->ApplyEtaCorrection(&copyTrack, AliHFEpidObject::kESDanalysis);
+    hfetrack.SetTPCsigmaElCorrected(pid->NumberOfSigmasTPC(&copyTrack, AliPID::kElectron));
+    hfetrack.SetTPCdEdxCorrected(copyTrack.GetTPCsignal());
+    if(track->IsEMCAL()){
+      // EMCAL cluster
+      Double_t emcalEnergyOverP = -1.,
+               showershape[4] = {0.,0.,0.,0.};
+      hfetrack.SetEMCALSigmaEl(pid->NumberOfSigmasEMCAL(track, AliPID::kElectron, emcalEnergyOverP, &showershape[0]));
+      hfetrack.SetEMCALEoverP(emcalEnergyOverP);
+      hfetrack.SetEMCALShowerShape(showershape);
+    }
+
+    // Track finished, add NOW to the Event
+    fHFEevent->AddTrack(&hfetrack);
+    //printf("after\n");
+  }
+  
+  // Fill the debug tree
+  //AliInfo(Form("Number of tracks: %d\n", fHFEevent->GetNumberOfTracks()));
+  //AliInfo(Form("Number of MC particles: %d\n", fHFEevent->GetNumberOfMCParticles()));
+  fHFEtree->Fill();
+
+  fEventNumber++;
+  PostData(1, fHFEtree);
+}
+
+void AliHFEreducedEventCreatorESD::Terminate(Option_t *){
+  //
+  // Terminate
+  //
+  AliInfo("terminating...\n");
+
+}
+
+Bool_t AliHFEreducedEventCreatorESD::IsTOFmismatch(const AliVTrack *const track, const AliPIDResponse *const pid) const {
+  //
+  // Is TOF mismatch
+  //
+  Double_t probs[AliPID::kSPECIESC];
+  AliPIDResponse::EDetPidStatus status = pid->ComputeTOFProbability(track, AliPID::kSPECIESC, probs);
+  return status == AliPIDResponse::kDetMismatch;
+}
+
diff --git a/PWGHF/hfe/AliHFEreducedEventCreatorESD.h b/PWGHF/hfe/AliHFEreducedEventCreatorESD.h
new file mode 100644 (file)
index 0000000..65a6e05
--- /dev/null
@@ -0,0 +1,74 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree to look at the distribution of the variable we are cutting on
+//
+//
+#ifndef ALIHFEREDUCEDEVENTCREATORESD_H
+#define ALIHFEREDUCEDEVENTCREATORESD_H
+
+#include "AliAnalysisTaskSE.h"
+
+class TString;
+class TTree;
+class AliAnalysisUtils;
+class AliPIDResponse;
+class AliHFEcuts;
+class AliHFEextraCuts;
+class AliHFEpidTPC;
+class AliHFEsignalCuts;
+class AliHFEreducedEvent;
+
+class AliHFEreducedEventCreatorESD : public AliAnalysisTaskSE{
+  public:
+    AliHFEreducedEventCreatorESD();
+    AliHFEreducedEventCreatorESD(const char *name);
+    virtual ~AliHFEreducedEventCreatorESD();
+
+    virtual void UserCreateOutputObjects();
+    virtual void UserExec(Option_t *);
+    virtual void Terminate(Option_t *);
+
+    // Setters for cuts
+    void SetMinNclustersTPC(Int_t mincl) { fNclustersTPC = mincl; };
+    void SetMinNclustersTPCPID(Int_t mincl) { fNclustersTPCPID = mincl; };
+    void SetMinNclustersITS(Int_t mincl) { fNclustersITS = mincl; };
+    void SetRemoveFirstEventFromChunk() { fRemoveFirstEvent = kTRUE; }
+    AliHFEpidTPC *GetTPCResponse() { return fTPCpid; }
+
+    Bool_t IsTOFmismatch(const AliVTrack *const track, const AliPIDResponse *const pid) const;
+    
+  private:
+    AliHFEreducedEventCreatorESD(const AliHFEreducedEventCreatorESD &);
+    AliHFEreducedEventCreatorESD &operator=(const AliHFEreducedEventCreatorESD &);
+    
+    TTree *fHFEtree;                  // HFE tree 
+    AliAnalysisUtils *fAnalysisUtils; // Analysis Utils
+    AliHFEreducedEvent *fHFEevent;    // hfe event
+    AliHFEcuts *fTrackCuts;           // Track
+    AliHFEextraCuts *fExtraCuts;      // HFE IP info
+    AliHFEsignalCuts *fSignalCuts;    // Signal Cuts
+    AliHFEpidTPC *fTPCpid;            // TPC PID
+    Int_t fEventNumber;               // Event Number
+    Int_t fNclustersTPC;              // Min Number of clusters in TPC
+    Int_t fNclustersTPCPID;           // Min Number of clusters for TPC PID
+    Int_t fNclustersITS;              // Min Number of clusters in ITS
+    Bool_t fRemoveFirstEvent;         // Remove first event from chunk
+    
+    ClassDef(AliHFEreducedEventCreatorESD, 1)
+      };
+#endif
+
+
diff --git a/PWGHF/hfe/AliHFEreducedMCParticle.cxx b/PWGHF/hfe/AliHFEreducedMCParticle.cxx
new file mode 100644 (file)
index 0000000..85ec63f
--- /dev/null
@@ -0,0 +1,84 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug MC particle
+// the tree is represented as reduced events
+// 
+// Authors:
+//   M.Fasel <M.Fasel@gsi.de>
+//
+#include "TObjArray.h"
+#include <cstring>
+
+#include "AliHFEreducedMCParticle.h"
+
+ClassImp(AliHFEreducedMCParticle)
+
+//_______________________________________
+AliHFEreducedMCParticle::AliHFEreducedMCParticle():
+TObject(),
+  fSignedPt(0.),
+  fP(0.),
+  fEta(0.),
+  fPhi(0.),
+  fPdg(0),
+  fMotherPdg(0),
+  fSource(5),
+  fSignal(kFALSE)
+{
+  //
+  // Default constructor
+  //
+        memset(fProductionVertex, 0, sizeof(Double_t) *3);      // Initialise production vertex array
+}
+
+//_______________________________________
+AliHFEreducedMCParticle::AliHFEreducedMCParticle(const AliHFEreducedMCParticle &ref):
+  TObject(ref),
+  fSignedPt(ref.fSignedPt),
+  fP(ref.fP),
+  fEta(ref.fEta),
+  fPhi(ref.fPhi),
+  fPdg(ref.fPdg),
+  fMotherPdg(ref.fMotherPdg),
+  fSource(ref.fSource),
+  fSignal(ref.fSignal)
+{
+  //
+  // Copy constructor
+  //
+  memcpy(fProductionVertex, ref.fProductionVertex, sizeof(Double_t) *3);      // Port production vertex array
+}
+
+//_______________________________________
+AliHFEreducedMCParticle &AliHFEreducedMCParticle::operator=(const AliHFEreducedMCParticle &ref){
+  // 
+  // Assignment operator
+  //
+  if(&ref != this){
+    TObject::operator=(ref);
+    fSignedPt = ref.fSignedPt;
+    fP= ref.fP;
+    fEta = ref.fEta;
+    fPhi = ref.fPhi;
+    fPdg = ref.fPdg;
+    fMotherPdg = ref.fMotherPdg;
+    fSource = ref.fSource;
+    fSignal = ref.fSignal;
+    memcpy(fProductionVertex, ref.fProductionVertex, sizeof(Double_t) *3); 
+  }
+  return *this;
+}
+
diff --git a/PWGHF/hfe/AliHFEreducedMCParticle.h b/PWGHF/hfe/AliHFEreducedMCParticle.h
new file mode 100644 (file)
index 0000000..ea510e0
--- /dev/null
@@ -0,0 +1,80 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree to look at the distribution of the variable we are cutting on
+//
+//
+#ifndef ALIHFEREDUCEDMCPARTICLE_H
+#define ALIHFEREDUCEDMCPARTICLE_H
+
+#include <TObject.h>
+#include <TMath.h>
+
+class AliHFEreducedMCParticle : public TObject{
+ public:
+  AliHFEreducedMCParticle();
+  AliHFEreducedMCParticle(const AliHFEreducedMCParticle &ref);
+  AliHFEreducedMCParticle &operator=(const AliHFEreducedMCParticle &ref);
+  ~AliHFEreducedMCParticle() {}
+  
+  Double_t Pt() const { return TMath::Abs(fSignedPt); }
+  Double_t P() const { return fP; }
+  Double_t Eta() const { return fEta; }
+  Double_t Phi() const { return fPhi; }
+  Int_t Charge() const { 
+    if(fSignedPt > 0) return 1; 
+    else return -1;
+  }
+  Int_t Pdg() const { return fPdg; }
+  Int_t MotherPdg() const { return fMotherPdg; }
+  Int_t Source() const { return static_cast<Int_t>(fSource); }
+  Bool_t IsSignal() const { return fSignal; }
+  Double_t RadialProductionVertex() const { return TMath::Abs(fProductionVertex[0]*fProductionVertex[0]+fProductionVertex[1]*fProductionVertex[1]); }
+  Double_t VX() const { return fProductionVertex[0]; }
+  Double_t VY() const { return fProductionVertex[1]; }
+  Double_t VZ() const { return fProductionVertex[2]; }
+  
+  void SetSignedPt(Double_t pt, Bool_t positiveCharge){
+    double chargesign = positiveCharge ? 1. : -1.;
+    fSignedPt = pt * chargesign;
+  }
+  void SetP(Double_t p) { fP = p; }
+  void SetEta(Double_t eta) { fEta = eta; }
+  void SetPhi(Double_t phi) { fPhi = phi; }
+  void SetPdg(Int_t pdg) { fPdg = pdg; }
+  void SetMotherPdg(Int_t pdg) { fPdg = pdg; }
+  void SetSource(Int_t source) { fSource = static_cast<Char_t>(source); }
+  void SetSignal() { fSignal = kTRUE; }
+  void SetProductionVertex(Double_t vx, Double_t vy, Double_t vz) {
+    fProductionVertex[0] = vx;
+    fProductionVertex[1] = vy;
+    fProductionVertex[2] = vz;
+  }
+  
+ private:
+  Double_t  fSignedPt;              // signed pt
+  Double_t  fP;                     // p
+  Double_t  fEta;                   // eta
+  Double_t  fPhi;                   // phi
+  Int_t     fPdg;                   // pdg
+  Int_t     fMotherPdg;             // mother pdg
+  Char_t    fSource;                // source
+  Bool_t    fSignal;                // signal
+  Double_t  fProductionVertex[3];   // production vertex
+  
+  ClassDef(AliHFEreducedMCParticle, 1)
+  
+};
+#endif
diff --git a/PWGHF/hfe/AliHFEreducedTrack.cxx b/PWGHF/hfe/AliHFEreducedTrack.cxx
new file mode 100644 (file)
index 0000000..fac48e4
--- /dev/null
@@ -0,0 +1,186 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug track
+// the tree is represented as reduced events
+// 
+// Authors:
+//   M.Fasel <M.Fasel@gsi.de>
+//
+
+#include <cstring>
+
+#include "AliHFEreducedTrack.h"
+
+ClassImp(AliHFEreducedTrack)
+
+
+//_______________________________________
+AliHFEreducedTrack::AliHFEreducedTrack():
+TObject(),
+  fSignedPt(0.),
+  fP(0.),
+  fEta(0.),
+  fPhi(0.),
+  fTPCmomentum(0.),
+  fFilterBit(20),
+  fTrackID(0),
+  fMCSignedPt(0.),
+  fMCP(0.),
+  fMCEta(0.),
+  fMCPhi(0.),
+  fMCPDG(0),
+  fMCMotherPdg(0),
+  fMCSignal(kFALSE),
+  fMCSource(5),
+  fTrackStatus(8),
+  fNclustersITS(0),
+  fNclustersTPC(0),
+  fNclustersTRD(0),
+  fITSclusterMap(6),
+  fITSstatusMap(6),
+  fNclustersTPCPID(0),
+  fNclustersTPCAll(0),
+  fTPCcrossedRows(0),
+  fTPCsharedClusters(0),
+  fTPCclusterRatio(0.),
+  fTPCclusterRatioAll(0.),
+  fTRDtrackletsPID(0),
+  fTRDnslices(0),
+  fTRDlayer(6),
+  fTRDchi2(0.),
+  fTPCdEdx(0.),
+  fTPCdEdxCorrected(0.),
+  fTPCsigmaEl(-1000.),
+  fTPCsigmaElCorrected(-1000.),
+  fTOFsigmaEl(-1000.),
+  fTOFmismatchProb(0.),
+  fEoverP(0.),
+  fEMCALsigmaEl(-1000.),
+  fV0PID(kV0undef)
+{
+  // 
+  // Default Constuctor
+  //
+  memset(fMCProdVtx, 0, sizeof(Double_t)*3);
+  memset(fShowerShape, 0, sizeof(Double_t)*4);
+  memset(fDCA, 0, sizeof(Float_t)*2);
+}
+
+//_______________________________________
+AliHFEreducedTrack::AliHFEreducedTrack(const AliHFEreducedTrack &ref):
+  TObject(ref),
+  fSignedPt(ref.fSignedPt),
+  fP(ref.fP),
+  fEta(ref.fEta),
+  fPhi(ref.fPhi),
+  fTPCmomentum(ref.fTPCmomentum),
+  fFilterBit(ref.fFilterBit),
+  fTrackID(ref.fTrackID),
+  fMCSignedPt(ref.fMCSignedPt),
+  fMCP(ref.fMCP),
+  fMCEta(ref.fMCEta),
+  fMCPhi(ref.fMCPhi),
+  fMCPDG(ref.fMCPDG),
+  fMCMotherPdg(ref.fMCMotherPdg),
+  fMCSignal(ref.fMCSignal),
+  fMCSource(ref.fMCSource),
+  fTrackStatus(ref.fTrackStatus),
+  fNclustersITS(ref.fNclustersITS),
+  fNclustersTPC(ref.fNclustersTPC),
+  fNclustersTRD(ref.fNclustersTRD),
+  fITSclusterMap(ref.fITSclusterMap),
+  fITSstatusMap(ref.fITSstatusMap),
+  fNclustersTPCPID(ref.fNclustersTPCPID),
+  fNclustersTPCAll(ref.fNclustersTPCAll),
+  fTPCcrossedRows(ref.fTPCcrossedRows),
+  fTPCsharedClusters(ref.fTPCsharedClusters),
+  fTPCclusterRatio(ref.fTPCclusterRatio),
+  fTPCclusterRatioAll(ref.fTPCclusterRatioAll),
+  fTRDtrackletsPID(ref.fTRDtrackletsPID),
+  fTRDnslices(ref.fTRDnslices),
+  fTRDlayer(ref.fTRDlayer),
+  fTRDchi2(ref.fTRDchi2),
+  fTPCdEdx(ref.fTPCdEdx),
+  fTPCdEdxCorrected(ref.fTPCdEdxCorrected),
+  fTPCsigmaEl(ref.fTPCsigmaEl),
+  fTPCsigmaElCorrected(ref.fTPCsigmaElCorrected),
+  fTOFsigmaEl(ref.fTOFsigmaEl),
+  fTOFmismatchProb(ref.fTOFmismatchProb),
+  fEoverP(ref.fEoverP),
+  fEMCALsigmaEl(ref.fEMCALsigmaEl),
+  fV0PID(ref.fV0PID)
+{
+  // 
+  // Copy Constuctor
+  //
+  memcpy(fMCProdVtx, ref.fMCProdVtx, sizeof(Double_t) *3);
+  memcpy(fShowerShape, ref.fShowerShape, sizeof(Double_t)*4);
+  memcpy(fDCA, ref.fDCA, sizeof(Float_t)*2);
+}
+
+//_______________________________________
+AliHFEreducedTrack &AliHFEreducedTrack::operator=(const AliHFEreducedTrack &ref){
+  //
+  // Assignment Operator
+  //
+  if(&ref != this){
+    TObject::operator=(ref);
+    fSignedPt = ref.fSignedPt;
+    fP = ref.fP;
+    fEta = ref.fEta;
+    fPhi = ref.fPhi;
+    fTPCmomentum = ref.fTPCmomentum;
+    fFilterBit = ref.fFilterBit;
+    fTrackID = ref.fTrackID;
+    fMCSignedPt = ref.fMCSignedPt;
+    fMCP = ref.fMCP;
+    fMCEta = ref.fMCEta;
+    fMCPhi = ref.fMCPhi;
+    fMCPDG = ref.fMCPDG;
+    fMCMotherPdg = ref.fMCMotherPdg;
+    fMCSignal = ref.fMCSignal;
+    fMCSource = ref.fMCSource;
+    memcpy(fMCProdVtx, ref.fMCProdVtx, sizeof(Double_t) *3);
+    fTrackStatus =ref.fTrackStatus;
+    fNclustersITS = ref.fNclustersITS;
+    fNclustersTPC = ref.fNclustersTPC;
+    fNclustersTRD = ref.fNclustersTRD;
+    fITSclusterMap = ref.fITSclusterMap;
+    fITSstatusMap = ref.fITSstatusMap;
+    fNclustersTPCPID = ref.fNclustersTPCPID;
+    fNclustersTPCAll = ref.fNclustersTPCAll;
+    fTPCcrossedRows = ref.fTPCcrossedRows;
+    fTPCsharedClusters = ref.fTPCsharedClusters;
+    fTPCclusterRatio = ref.fTPCclusterRatio;
+    fTPCclusterRatioAll = ref.fTPCclusterRatioAll;
+    fTRDtrackletsPID = ref.fTRDtrackletsPID;
+    fTRDnslices = ref.fTRDnslices;
+    fTRDlayer = ref.fTRDlayer;
+    fTRDchi2 = ref.fTRDchi2;
+    fTPCdEdx = ref.fTPCdEdx;
+    fTPCdEdxCorrected = ref.fTPCdEdxCorrected;
+    fTPCsigmaEl = ref.fTPCsigmaEl;
+    fTPCsigmaElCorrected = ref.fTPCsigmaElCorrected;
+    fTOFsigmaEl = ref.fTOFsigmaEl;
+    fTOFmismatchProb = ref.fTOFmismatchProb;
+    fEoverP = ref.fEoverP;
+    fEMCALsigmaEl = ref.fEMCALsigmaEl;
+    fV0PID = ref.fV0PID;
+    memcpy(fShowerShape, ref.fShowerShape, sizeof(Double_t)*4);
+    memcpy(fDCA, ref.fDCA, sizeof(Float_t)*2);
+  }
+  return *this;
+}
diff --git a/PWGHF/hfe/AliHFEreducedTrack.h b/PWGHF/hfe/AliHFEreducedTrack.h
new file mode 100644 (file)
index 0000000..2cddbfc
--- /dev/null
@@ -0,0 +1,256 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Debug tree to look at the distribution of the variable we are cutting on
+//
+//
+#ifndef ALIHFEREDUCEDTRACK_H
+#define ALIHFEREDUCEDTRACK_H
+
+#include <TObject.h>
+#include <TMath.h>
+#include <TBits.h>
+
+class AliHFEreducedTrack : public TObject{
+ public:
+  typedef enum{
+    kV0electron = 0,
+    kV0proton = 1,
+    kV0pion = 2,
+    kV0undef = 3
+  } EV0PID_t;
+  AliHFEreducedTrack();
+  AliHFEreducedTrack(const AliHFEreducedTrack &ref);
+  AliHFEreducedTrack &operator=(const AliHFEreducedTrack &ref);
+  ~AliHFEreducedTrack() {}
+  
+  // -------------- Getters ------------------------
+  Double_t Pt() const { return TMath::Abs(fSignedPt); }
+  Double_t P() const { return fP; }
+  Double_t TPCmomentum() const { return fTPCmomentum; }
+  Double_t Eta() const { return fEta; }
+  Double_t Phi() const { return fPhi; }
+  Int_t Charge() const {
+    if(fSignedPt >= 0.) return 1.;
+    return -1;
+  }
+  
+  Double_t MCPt() const { return TMath::Abs(fMCSignedPt); }
+  Double_t MCP() const { return fMCP; }
+  Double_t MCEta() const { return fMCEta; }
+  Double_t MCPhi() const { return fMCPhi; }
+  Int_t MCCharge() const {
+    if(fMCSignedPt >= 0.) return 1.;
+    return -1;
+  }
+  Int_t MCPDG() const { return fMCPDG; }
+  Int_t MCMotherPdg() const { return fMCMotherPdg; }
+  Bool_t MCSignal() const { return fMCSignal; }
+  Int_t MCSource() const { return fMCSource; }
+  Double_t MCProdVtxX() const { return fMCProdVtx[0]; }
+  Double_t MCProdVtxY() const { return fMCProdVtx[1]; }
+  Double_t MCProdVtxZ() const { return fMCProdVtx[2]; }
+  Double_t MCProdRadius() const { return TMath::Sqrt(fMCProdVtx[0]*fMCProdVtx[0]+fMCProdVtx[1]*fMCProdVtx[1]); }
+  
+  Double_t DCAr() const { return fDCA[0]; }
+  Double_t DCAz() const { return fDCA[1]; }
+  
+  Bool_t TestFilterBit(Int_t ibit) const { return fFilterBit.TestBitNumber(ibit); }
+  Int_t GetTrackID() const { return fTrackID; }
+  Bool_t HasITSrefit() const { return fTrackStatus.TestBitNumber(kITSrefit); }
+  Bool_t HasTPCrefit() const { return fTrackStatus.TestBitNumber(kTPCrefit); }
+  Bool_t HasTOFpid() const { return fTrackStatus.TestBitNumber(kTOFpid); }
+  Bool_t IsTOFmismatch() const { return fTrackStatus.TestBitNumber(kTOFmismatch); }
+  Bool_t HasEMCALpid() const { return fTrackStatus.TestBitNumber(kEMCALpid); }
+  Bool_t IsDoubleCounted() const { return fTrackStatus.TestBitNumber(kDoubleCounted); }
+  
+  Int_t GetITSnclusters() const { return static_cast<Int_t>(fNclustersITS); }
+  Int_t GetTPCnclusters() const { return static_cast<Int_t>(fNclustersTPC); }
+  Int_t GetTRDnclusters() const { return static_cast<Int_t>(fNclustersTRD); }
+  Bool_t HasITScluster(int nly) const { 
+    if(nly > 5) return kFALSE;
+    return fITSclusterMap.TestBitNumber(nly);
+  }
+  Bool_t GetITSlayerStatus(int nly) const { 
+    if(nly > 5) return kFALSE;
+    return fITSstatusMap.TestBitNumber(nly);
+  }
+  Int_t GetTPCnclusterPID() const { return static_cast<Int_t>(fNclustersTPCPID); }
+  Int_t GetTPCnclustersAll() const { return static_cast<Int_t>(fNclustersTPCAll); }
+  Int_t GetTPCcrossedRows() const { return static_cast<Int_t>(fTPCcrossedRows); }
+  Int_t GetTPCsharedClusters() const { return static_cast<Int_t>(fTPCsharedClusters); }
+  Float_t GetTPCclusterRatio() const { return fTPCclusterRatio; }
+  Float_t GetTPCclusterRatioAll() const { return fTPCclusterRatioAll; }
+  Int_t GetTRDntrackletsPID() const { return static_cast<UChar_t>(fTRDtrackletsPID); }
+  Int_t GetTRDnslices() const { return static_cast<Int_t>(fTRDnslices); }
+  Bool_t GetTRDstatus(Int_t layer) const { 
+    if(layer > 5) return kFALSE;
+    return fTRDlayer.TestBitNumber(layer); 
+  }
+  Float_t GetTRDchi2() const { return fTRDchi2; }
+  
+  Double_t GetTPCdEdx() const { return fTPCdEdx; }
+  Double_t GetTPCdEdxCorrected() const { return fTPCdEdxCorrected; }
+  Double_t GetTPCsigmaEl() const { return fTPCsigmaEl; }
+  Double_t GetTPCsigmaElCorrected() const { return fTPCsigmaElCorrected; }
+  Double_t GetTOFsigmaEl() const { return fTOFsigmaEl; }
+  Float_t GetTOFmismatchProb() const { return fTOFmismatchProb; }
+  Double_t GetEMCALEoverP() const { return fEoverP; }
+  Double_t GetEMCALSigmaEl() const { return fEMCALsigmaEl; }
+  void GetEMCALShowerShape(Double_t showershape[4]) const{
+    for(Int_t is = 0; is < 4; is++) showershape[is] = fShowerShape[is]; 
+  }
+  
+  Bool_t IsV0electron() const { return fV0PID == kV0electron; }
+  Bool_t IsV0pion() const { return fV0PID == kV0pion; }
+  Bool_t IsV0proton() const { return fV0PID == kV0proton; }
+  
+  
+  // -------------- Setters ------------------------
+  void SetSignedPt(Double_t abspt, Bool_t positivecharge) { 
+    Double_t charge = positivecharge ? 1. : -1;
+    fSignedPt = abspt * charge;
+  }
+  void SetP(Double_t p) { fP = p; }
+  void SetTPCmomentum(Double_t p) { fTPCmomentum = p; }
+  void SetEta(Double_t eta) { fEta = eta; }
+  void SetPhi(Double_t phi) { fPhi = phi; }
+  
+  void SetFilterBit(Int_t ibit) { fFilterBit.SetBitNumber(ibit); }
+  void SetTrackID(Int_t trackID) { fTrackID = trackID; }
+  void SetITSrefit() { fTrackStatus.SetBitNumber(kITSrefit); }
+  void SetTPCrefit() { fTrackStatus.SetBitNumber(kTPCrefit); }
+  void SetTOFpid() { fTrackStatus.SetBitNumber(kTOFpid); }
+  void SetTOFmismatch() { fTrackStatus.SetBitNumber(kTOFmismatch); }
+  void SetEMCALpid() { fTrackStatus.SetBitNumber(kEMCALpid); }
+  void SetDoubleCounted() { fTrackStatus.SetBitNumber(kDoubleCounted); }
+  
+  void SetMCSignedPt(Double_t abspt, Bool_t positivecharge){
+    Double_t charge = positivecharge ? 1. : -1;
+    fSignedPt = abspt * charge;
+  }
+  void SetMCP(Double_t mcp) { fMCP = mcp; }
+  void SetMCEta(Double_t mceta) { fMCEta = mceta; }
+  void SetMCPhi(Double_t mcphi) { fMCPhi = mcphi; }
+  void SetMCPDG(Int_t mcpdg) {fMCPDG = mcpdg; }
+  void SetMCMotherPdg(Int_t pdg) { fMCMotherPdg = pdg; }
+  void SetMCSignal() { fMCSignal = kTRUE; }
+  void SetMCSource(Int_t mcsource) { fMCSource = mcsource; }
+  void SetMCProdVtx(Double_t vx, Double_t vy, Double_t vz){
+    fMCProdVtx[0] = vx;
+    fMCProdVtx[1] = vy;
+    fMCProdVtx[2] = vz;
+  }
+  
+  void SetDCA(Float_t dcaR, Float_t dcaZ){
+    fDCA[0] = dcaR;
+    fDCA[1] = dcaZ;
+  }
+  
+  void SetITSnclusters(int ncls) { fNclustersITS = ncls; }
+  void SetTPCnclusters(int ncls) { fNclustersTPC = ncls; }
+  void SetTRDnclusters(int ncls) { fNclustersTRD = ncls; }
+  void SetITScluster(UInt_t ly){
+    if(ly > 5) return;
+    fITSclusterMap.SetBitNumber(ly); 
+  }
+  void SetITSstatus(UInt_t ly){
+    if(ly > 5) return;
+    fITSstatusMap.SetBitNumber(ly); 
+  }
+  void SetTPCnclustersPID(Int_t ncls) { fNclustersTPCPID = static_cast<UChar_t>(ncls); }
+  void SetTPCnclustersAll(Int_t ncls) { fNclustersTPCAll = static_cast<UChar_t>(ncls); }
+  void SetTPCcrossedRows(int nrows) { fTPCcrossedRows = static_cast<UChar_t>(nrows); }
+  void SetTPCsharedClusters(Int_t ncls) { fTPCsharedClusters = static_cast<UChar_t>(ncls); }
+  void SetTPCclusterRatio(Float_t ratio) { fTPCclusterRatio = ratio; }
+  void SetTPCclusterRatioAll(Float_t ratio) { fTPCclusterRatioAll = ratio; }
+  void SetTRDntrackletsPID(Int_t ntracklets) { fTRDtrackletsPID = static_cast<UChar_t>(ntracklets); }
+  void SetTRDnslices(Int_t nslices) { fTRDnslices = static_cast<UChar_t>(nslices); }
+  void SetTRDstatus(Int_t layer) { 
+    if(layer > 5) return;
+    fTRDlayer.SetBitNumber(static_cast<UInt_t>(layer)); 
+  }
+  void SetTRDchi2(Float_t chi2) { fTRDchi2 = chi2; }
+  
+  void SetTPCdEdx(Double_t dEdx) { fTPCdEdx = dEdx; }
+  void SetTPCdEdxCorrected(Double_t dEdx) { fTPCdEdxCorrected = dEdx; }
+  void SetTPCsigmaEl(Double_t sigma) { fTPCsigmaEl = sigma; }
+  void SetTPCsigmaElCorrected(Double_t sigma) { fTPCsigmaElCorrected = sigma; }
+  void SetTOFsigmaEl(Double_t sigma) { fTOFsigmaEl = sigma; }
+  void SetTOFmismatchProbability(Float_t mismatchProb) { fTOFmismatchProb = mismatchProb; }
+  void SetEMCALEoverP(Double_t eop) { fEoverP = eop; }
+  void SetEMCALSigmaEl(Double_t sigma) { fEMCALsigmaEl = sigma; }
+  void SetEMCALShowerShape(Double_t showershape[4]){
+    for(Int_t is = 0; is < 4; is++) fShowerShape[is] = showershape[is]; 
+  }
+  void SetV0PID(AliHFEreducedTrack::EV0PID_t v0pid) { fV0PID = v0pid; }
+  
+ private:
+  typedef enum{
+    kITSrefit = 0,
+    kTPCrefit = 1,
+    kTOFpid   = 2,
+    kTOFmismatch = 3,
+    kEMCALpid =4,
+    kDoubleCounted = 5,
+    kKink = 6
+  } TrackStatus_t;
+  Double_t fSignedPt;                     // signed pt
+  Double_t fP;                            // p
+  Double_t fEta;                          // eta
+  Double_t fPhi;                          // phi
+  Double_t fTPCmomentum;                  // TPC p
+  TBits    fFilterBit;                    // filterbit
+  Int_t    fTrackID;                      // trackID
+  Double_t fMCSignedPt;                   // MCSignedPt
+  Double_t fMCP;                          // MCP
+  Double_t fMCEta;                        // MCEta
+  Double_t fMCPhi;                        // MCPhi
+  Int_t    fMCPDG;                        // MCPDG
+  Int_t    fMCMotherPdg;                  // MCMP
+  Bool_t   fMCSignal;                     // MCSignal
+  Int_t    fMCSource;                     // MCSource
+  Double_t fMCProdVtx[3];                 // MC prod Vtx
+  TBits    fTrackStatus;                  // Track Status
+  UChar_t  fNclustersITS;                 // ITS nb cls
+  UChar_t  fNclustersTPC;                 // TPC nb cls
+  UChar_t  fNclustersTRD;                 // TRD nb cls
+  TBits    fITSclusterMap;                // ITS maps
+  TBits    fITSstatusMap;                 // ITS status map
+  UChar_t  fNclustersTPCPID;              // TPC PID nb cls
+  UChar_t  fNclustersTPCAll;              // TPC all nb cls
+  UChar_t  fTPCcrossedRows;               // TPC crossed rows
+  UChar_t  fTPCsharedClusters;            // TPC shared clusters
+  Float_t  fTPCclusterRatio;              // TPC cls ratio
+  Float_t  fTPCclusterRatioAll;           // TPC cls ratio all
+  UChar_t  fTRDtrackletsPID;              // TRD tracklet PID
+  UChar_t  fTRDnslices;                   // TRD nslices
+  TBits    fTRDlayer;                     // TRD layer
+  Float_t  fTRDchi2;                      // TRD chi2
+  Double_t fTPCdEdx;                      // TPC dedx
+  Double_t fTPCdEdxCorrected;             // TPC dedx corrected
+  Double_t fTPCsigmaEl;                   // TPC sigma el
+  Double_t fTPCsigmaElCorrected;          // TPC sigma el corrected
+  Double_t fTOFsigmaEl;                   // TOF sigma el
+  Float_t  fTOFmismatchProb;              // TOF mismatch prob
+  Double_t fEoverP;                       // Eoverp
+  Double_t fEMCALsigmaEl;                 // EMCAl sigmal el
+  Double_t fShowerShape[4];               // showershape
+  Float_t fDCA[2];                        // dca
+  EV0PID_t fV0PID;                        // V0pid
+  
+  ClassDef(AliHFEreducedTrack, 1)
+};
+#endif
diff --git a/PWGHF/hfe/macros/AddTaskHFEreducedEvent.C b/PWGHF/hfe/macros/AddTaskHFEreducedEvent.C
new file mode 100644 (file)
index 0000000..47e8fb2
--- /dev/null
@@ -0,0 +1,49 @@
+AliAnalysisTask *AddTaskHFEreducedEvent(UInt_t trigger=131073,Int_t minnbTPC=30,Int_t minnbTPCPID=80,Int_t minnbITS=2){
+
+  //
+  // Produce reduced events
+  //
+  
+
+  // Name
+  TString appendixx("HFEreducedEvent");
+  
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+  // task
+  AliHFEreducedEventCreatorAOD *reducedEventCreator = new AliHFEreducedEventCreatorAOD("HFEreducedEventCreator");
+  reducedEventCreator->SetMinNclustersTPC(minnbTPC);
+  reducedEventCreator->SetMinNclustersTPCPID(minnbTPCPID);
+  reducedEventCreator->SetMinNclustersITS(minnbITS);
+  reducedEventCreator->SelectCollisionCandidates(trigger); 
+
+  //AliHFEpidTPC *tpcpid = reducedEventCreator->GetTPCResponse();
+
+  /*
+  TF1 *etaCorrection = GetEtaCorrection();
+  if(etaCorrection){
+    tpcpid->SetEtaCorrection(etaCorrection);
+  }
+  */
+  /*
+  TF1 *centralityCorrection = new TF1("centralityCorrection", "pol1", 0., 10000.);
+  centralityCorrection->SetParameter(0, 1.0);
+  centralityCorrection->SetParameter(1, -0.00002);
+  tpcpid->SetCentralityCorrection(centralityCorrection);
+  */
+
+  mgr->AddTask(reducedEventCreator);
+  
+  TString containerName = mgr->GetCommonFileName();
+  containerName += ":";
+  containerName += appendixx.Data();
+
+  AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+  mgr->ConnectOutput(reducedEventCreator,1, mgr->CreateContainer(Form("list_%s",appendixx.Data()), TTree::Class(),AliAnalysisManager::kOutputContainer,containerName.Data()));
+  mgr->ConnectInput(reducedEventCreator,0, cinput );    
+
+  return NULL;
+
+  
+}