First implementation of helper class to gather common methods used for data analysis
authorzconesa <zconesa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 8 Feb 2013 15:16:18 +0000 (15:16 +0000)
committerzconesa <zconesa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 8 Feb 2013 15:16:18 +0000 (15:16 +0000)
ANALYSIS/ANALYSISaliceLinkDef.h
ANALYSIS/AliAnalysisUtils.cxx [new file with mode: 0644]
ANALYSIS/AliAnalysisUtils.h [new file with mode: 0644]
ANALYSIS/CMakelibANALYSISalice.pkg

index 3511a88..3c42490 100644 (file)
@@ -49,6 +49,8 @@
 #pragma link C++ class AliEventPoolManager+;
 #pragma link C++ class AliUnfolding+;
 
+#pragma link C++ class AliAnalysisUtils+;
+
 #ifdef WITHXML
 #pragma link C++ class AliTagAnalysis+;
 #pragma link C++ class AliXMLCollection+;
diff --git a/ANALYSIS/AliAnalysisUtils.cxx b/ANALYSIS/AliAnalysisUtils.cxx
new file mode 100644 (file)
index 0000000..988c960
--- /dev/null
@@ -0,0 +1,107 @@
+#include "AliVEvent.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliVVertex.h"
+#include "AliLog.h"
+#include "AliAODVertex.h"
+
+#include "AliAnalysisUtils.h"
+
+ClassImp(AliAnalysisUtils)
+
+//______________________________________________________________________
+AliAnalysisUtils::AliAnalysisUtils():TObject(),
+  fisAOD(kTRUE),
+  fMinVtxContr(0),
+  fMaxVtxZ(10.),
+  fCutOnZVertexSPD(kTRUE)
+{
+  // Default contructor
+}
+
+//______________________________________________________________________
+Bool_t AliAnalysisUtils::IsVertexSelected2013pA(AliVEvent *event)
+{
+  Bool_t accept = kFALSE;
+
+  // Check whether the event is of AOD or ESD type
+  AliAODEvent *aod = 0x0;
+  AliESDEvent *esd = 0x0;
+  aod = dynamic_cast<AliAODEvent*>(event);
+  esd = dynamic_cast<AliESDEvent*>(event);
+
+  if(aod) { 
+    fisAOD = kTRUE; 
+  } else {
+    fisAOD = kFALSE;
+    if(!esd) {
+      AliFatal("Event is neither of AOD nor ESD type");
+      return accept;
+    }
+  }
+
+  const AliVVertex *trkVtx = fisAOD ? 
+    dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertex()) : 
+    dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertex()) ;
+  if(!trkVtx || trkVtx->GetNContributors()<=fMinVtxContr){
+    accept = kFALSE;
+    return accept;
+  }
+
+  TString vtxTtl = trkVtx->GetTitle();
+  if (!vtxTtl.Contains("VertexerTracks")) return accept;
+
+  Float_t zvtx = trkVtx->GetZ();
+  const AliVVertex* spdVtx = fisAOD ? 
+    dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertexSPD()) : 
+    dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertexSPD()) ;
+  if (spdVtx->GetNContributors()<=fMinVtxContr) return accept;
+
+  TString vtxTyp = spdVtx->GetTitle();
+  Double_t cov[6]={0};
+  spdVtx->GetCovarianceMatrix(cov);
+  Double_t zRes = TMath::Sqrt(cov[5]);
+  if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return accept;
+  if (fCutOnZVertexSPD && TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return accept;
+
+  if (TMath::Abs(zvtx) > fMaxVtxZ) return accept;
+
+  return kTRUE;
+}
+
+//______________________________________________________________________
+Bool_t AliAnalysisUtils::IsFirstEventInChunk(AliVEvent *event)
+{
+
+  Bool_t accept = kFALSE;
+
+  // Check whether the event is of AOD or ESD type
+  AliAODEvent *aod = 0x0;
+  AliESDEvent *esd = 0x0;
+  aod = dynamic_cast<AliAODEvent*>(event);
+  esd = dynamic_cast<AliESDEvent*>(event);
+
+  if(aod) { 
+    fisAOD = kTRUE; 
+  } else {
+    fisAOD = kFALSE;
+    if(!esd) {
+      AliFatal("Event is neither of AOD nor ESD type");
+      return accept;
+    }
+  }
+
+  if(fisAOD){
+    AliAODHeader *aodheader = 0x0;
+    aodheader = aod->GetHeader();
+    if(!aodheader){
+      AliFatal("AOD header not there ?!");
+      return kFALSE;
+    }
+    if(aodheader->GetEventNumberESDFile()==0) accept = kTRUE;
+  } else {
+    if(esd->GetEventNumberInFile()==0) accept = kTRUE;
+  }
+
+  return accept;
+}
diff --git a/ANALYSIS/AliAnalysisUtils.h b/ANALYSIS/AliAnalysisUtils.h
new file mode 100644 (file)
index 0000000..6f3480d
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALIANALYSISUTILS_H
+#define ALIANALYSISUTILS_H
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// Class with functions useful for different analyses                       //
+// - vertex selection                                                       //
+//    * 2013 pA default cuts                                                //
+// - identification of the fist event of the chunk                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+
+class AliVEvent;
+
+class AliAnalysisUtils : public TObject {
+
+ public:
+
+  AliAnalysisUtils();
+  virtual ~AliAnalysisUtils(){};
+
+  Bool_t IsVertexSelected2013pA(AliVEvent *event);
+  Bool_t IsFirstEventInChunk(AliVEvent *event);
+
+  void SetMinVtxContr(Int_t contr=1) {fMinVtxContr=contr;}
+  void SetMaxVtxZ(Float_t z=1e6) {fMaxVtxZ=z;}
+  void SetCutOnZVertexSPD(Bool_t iscut=true) { fCutOnZVertexSPD = iscut; }
+
+ private:
+
+  Bool_t fisAOD; // flag for AOD:1 or ESD:0
+
+  Int_t fMinVtxContr; // minimum vertex contributors
+  Float_t fMaxVtxZ;   // maximum |z| of primary vertex
+
+  Bool_t fCutOnZVertexSPD; // 0: no cut, 1: |zvtx-SPD - zvtx-TPC|<0.5cm
+
+  ClassDef(AliAnalysisUtils,0) // base helper class
+};
+#endif
index fdc2703..56dec6b 100644 (file)
@@ -62,6 +62,7 @@ set ( SRCS
     AliEventPoolManager.cxx
     AliAnalysisTaskPIDCombined.cxx
     AliUnfolding.cxx
+    AliAnalysisUtils.cxx
     )
 
 if( ROOTHASALIEN STREQUAL "yes")