]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
bugfix
[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   AliRsnCut(AliRsnCut::kEvent),
18   fAcceptTPC(kFALSE)
19 {
20 //
21 // Default constructor.
22 //
23 }
24
25 //_________________________________________________________________________________________________
26 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
27 (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
28   AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1),
29   fAcceptTPC(acceptTPC)
30 {
31 //
32 // Main constructor.
33 // Defines the cut range between 0 and
34 // the minimum required number of contributors.
35 // The cut will be passed when if the event has a
36 // primary vertex with number of contributors outside this interval.
37 // ---
38 // If the 'acceptTPC' argument is true, events with TPC
39 // primary vertex will be checked, otherwise they will be
40 // rejected by default.
41 // ---
42 // Since the range check uses the '>=' and '<=', the high edge
43 // must be decreased by 1 to get the right behaviour, since this is integer.
44 //
45
46   fMinD = 0.0;
47   fMaxD = maxVz + 1E-6;
48 }
49
50 //_________________________________________________________________________________________________
51 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/)
52 {
53 //
54 // Cut checker
55 //
56
57   static Int_t evNum = 0;
58   evNum++;
59   
60   // retrieve ESD event
61   AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(obj1);
62   if (!rsn) return kFALSE;
63   AliESDEvent *esd = dynamic_cast<AliESDEvent*>(rsn->GetRef());
64   if (!esd) 
65   {
66     AliDebug(AliLog::kDebug+2, "NO ESD");
67     return kFALSE;
68   }
69
70   // get the best primary vertex:
71   // first try the one with tracks
72   const AliESDVertex *vTrk  = esd->GetPrimaryVertexTracks();
73   const AliESDVertex *vSPD  = esd->GetPrimaryVertexSPD();
74   const AliESDVertex *vTPC  = esd->GetPrimaryVertexTPC();
75   Int_t               ncTrk = -1;
76   Int_t               ncSPD = -1;
77   Int_t               ncTPC = -1;
78   Double_t            vzTrk = 2.0 * fMaxD;
79   Double_t            vzSPD = 2.0 * fMaxD;
80   Double_t            vzTPC = 2.0 * fMaxD;
81   if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
82   if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
83   if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
84   if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
85   if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
86   if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
87   if(vTrk && ncTrk > 0)
88   {
89     fCutValueI = ncTrk;
90     fCutValueD = vzTrk;
91   }
92   else if (vSPD && ncSPD > 0)
93   {
94     fCutValueI = ncSPD;
95     fCutValueD = vzSPD;
96   }
97   else if (vTPC && fAcceptTPC && ncTPC > 0)
98   {
99     fCutValueI = ncTPC;
100     fCutValueD = vzTPC;
101   }
102   else
103   {
104     fCutValueI = -1;
105     fCutValueD = 2.0 * fMaxD;
106   }
107   
108   // output
109   Bool_t result = ((!OkRangeI()) && OkRangeD());
110   
111   return result;
112 }
113