]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisUtils.cxx
removing new class from compiled code because it breaks compilation on some systems
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisUtils.cxx
1 #include "AliVEvent.h"
2 #include "AliESDEvent.h"
3 #include "AliAODEvent.h"
4 #include "AliVVertex.h"
5 #include "AliLog.h"
6 #include "AliAODVertex.h"
7
8 #include "AliAnalysisUtils.h"
9
10 ClassImp(AliAnalysisUtils)
11
12 //______________________________________________________________________
13 AliAnalysisUtils::AliAnalysisUtils():TObject(),
14   fisAOD(kTRUE),
15   fMinVtxContr(0),
16   fMaxVtxZ(10.),
17   fCutOnZVertexSPD(kTRUE)
18 {
19   // Default contructor
20 }
21
22 //______________________________________________________________________
23 Bool_t AliAnalysisUtils::IsVertexSelected2013pA(AliVEvent *event)
24 {
25   Bool_t accept = kFALSE;
26
27   // Check whether the event is of AOD or ESD type
28   AliAODEvent *aod = 0x0;
29   AliESDEvent *esd = 0x0;
30   aod = dynamic_cast<AliAODEvent*>(event);
31   esd = dynamic_cast<AliESDEvent*>(event);
32
33   if(aod) { 
34     fisAOD = kTRUE; 
35   } else {
36     fisAOD = kFALSE;
37     if(!esd) {
38       AliFatal("Event is neither of AOD nor ESD type");
39       return accept;
40     }
41   }
42
43   const AliVVertex *trkVtx = fisAOD ? 
44     dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertex()) : 
45     dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertex()) ;
46   if(!trkVtx || trkVtx->GetNContributors()<=fMinVtxContr){
47     accept = kFALSE;
48     return accept;
49   }
50
51   TString vtxTtl = trkVtx->GetTitle();
52   if (!vtxTtl.Contains("VertexerTracks")) return accept;
53
54   Float_t zvtx = trkVtx->GetZ();
55   const AliVVertex* spdVtx = fisAOD ? 
56     dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertexSPD()) : 
57     dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertexSPD()) ;
58   if (spdVtx->GetNContributors()<=fMinVtxContr) return accept;
59
60   TString vtxTyp = spdVtx->GetTitle();
61   Double_t cov[6]={0};
62   spdVtx->GetCovarianceMatrix(cov);
63   Double_t zRes = TMath::Sqrt(cov[5]);
64   if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return accept;
65   if (fCutOnZVertexSPD && TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return accept;
66
67   if (TMath::Abs(zvtx) > fMaxVtxZ) return accept;
68
69   return kTRUE;
70 }
71
72 //______________________________________________________________________
73 Bool_t AliAnalysisUtils::IsFirstEventInChunk(AliVEvent *event)
74 {
75
76   Bool_t accept = kFALSE;
77
78   // Check whether the event is of AOD or ESD type
79   AliAODEvent *aod = 0x0;
80   AliESDEvent *esd = 0x0;
81   aod = dynamic_cast<AliAODEvent*>(event);
82   esd = dynamic_cast<AliESDEvent*>(event);
83
84   if(aod) { 
85     fisAOD = kTRUE; 
86   } else {
87     fisAOD = kFALSE;
88     if(!esd) {
89       AliFatal("Event is neither of AOD nor ESD type");
90       return accept;
91     }
92   }
93
94   if(fisAOD){
95     AliAODHeader *aodheader = 0x0;
96     aodheader = aod->GetHeader();
97     if(!aodheader){
98       AliFatal("AOD header not there ?!");
99       return kFALSE;
100     }
101     if(aodheader->GetEventNumberESDFile()==0) accept = kTRUE;
102   } else {
103     if(esd->GetEventNumberInFile()==0) accept = kTRUE;
104   }
105
106   return accept;
107 }