]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Added check of pileup in event cuts
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPrimaryVertex.cxx
1 //
2 // Class AliRsnCutPrimaryVertex
3 //
4 // This cut implementation checks the quality of event primary vertex.
5 // It currently works only with ESD events (not AOD).
6 //
7 // authors: Martin Vala (martin.vala@cern.ch)
8 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 //
10
11 #include "AliRsnCutPrimaryVertex.h"
12
13 ClassImp(AliRsnCutPrimaryVertex)
14
15 //_________________________________________________________________________________________________
16 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
17 (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
18   AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, 0.0, maxVz),
19   fAcceptTPC(acceptTPC),
20   fCheckPileUp(kFALSE)
21 {
22 //
23 // Main constructor.
24 // Defines the cut range between 0 and
25 // the minimum required number of contributors.
26 // The cut will be passed when if the event has a
27 // primary vertex with number of contributors outside this interval.
28 // ---
29 // If the 'acceptTPC' argument is true, events with TPC
30 // primary vertex will be checked, otherwise they will be
31 // rejected by default.
32 // ---
33 // Since the range check uses the '>=' and '<=', the high edge
34 // must be decreased by 1 to get the right behaviour, since this is integer.
35 //
36
37   fMinD = 0.0;
38   fMaxD = maxVz + 1E-6;
39 }
40
41 //_________________________________________________________________________________________________
42 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
43 {
44 //
45 // Cut checker
46 //
47
48   static Int_t evNum = 0;
49   evNum++;
50   
51   // retrieve ESD event
52   AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(object);
53   if (!rsn) return kFALSE;
54   AliESDEvent *esd = rsn->GetRefESD();
55   AliAODEvent *aod = rsn->GetRefAOD();
56   
57   if (esd)
58   {
59     // pile-up check
60     if (fCheckPileUp)
61     {
62       if (esd->IsPileupFromSPD()) return kFALSE;
63     }
64     
65     // get the best primary vertex:
66     // first try the one with tracks
67     const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
68     const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
69     const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
70     Int_t               ncTrk = -1;
71     Int_t               ncSPD = -1;
72     Int_t               ncTPC = -1;
73     Double_t            vzTrk = 2.0 * fMaxD;
74     Double_t            vzSPD = 2.0 * fMaxD;
75     Double_t            vzTPC = 2.0 * fMaxD;
76     if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
77     if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
78     if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
79     if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
80     if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
81     if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
82     if(vTrk && ncTrk > 0)
83     {
84       fCutValueI = ncTrk;
85       fCutValueD = vzTrk;
86     }
87     else if (vSPD && ncSPD > 0)
88     {
89       fCutValueI = ncSPD;
90       fCutValueD = vzSPD;
91     }
92     else if (vTPC && fAcceptTPC && ncTPC > 0)
93     {
94       fCutValueI = ncTPC;
95       fCutValueD = vzTPC;
96     }
97     else
98     {
99       fCutValueI = -1;
100       fCutValueD = 2.0 * fMaxD;
101     }
102   }
103   else if (aod)
104   {
105     // pile-up check is not yet available for AODs
106     
107     // lines suggested by Andrea to reject TPC-only events
108     if(!fAcceptTPC)
109     {
110       if (!aod->GetPrimaryVertexSPD()) return kFALSE;
111       else if(aod->GetPrimaryVertexSPD()->GetNContributors() < 1) return kFALSE;
112     }
113     
114     AliAODVertex *prim = (AliAODVertex*)aod->GetPrimaryVertex();
115     if (!prim) return kFALSE;
116
117     fCutValueI = prim->GetNContributors();
118     fCutValueD = prim->GetZ();
119   }
120   else
121     return kFALSE;
122     
123   // output
124   Bool_t result = ((!OkRangeI()) && OkRangeD());
125   return result;
126 }