]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx
Major upgrade to the package, in order to speed-up the execution and remove some...
[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, 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
47 //_________________________________________________________________________________________________
48 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/)
49 {
50 //
51 // Cut checker
52 //
53
54   // retrieve ESD event
55   AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(obj1);
56   if (!rsn) return kFALSE;
57   AliESDEvent *esd = dynamic_cast<AliESDEvent*>(rsn->GetRef());
58   if (!esd) {
59     AliDebug(AliLog::kDebug+2, "NO ESD");
60     return kFALSE;
61   }
62
63   // get the three possible primary vertexes of the event:
64   // 0 = default one
65   // 1 = SPD
66   // 2 = TPC
67   // then, if the default vertex is TPC, the event is rejected,
68   // otherwise, the event is rejected only if its vertex status is 'false'
69   // get primary vertexes
70   const AliESDVertex *vert[3];
71   vert[0] = esd->GetPrimaryVertex();
72   vert[1] = esd->GetPrimaryVertexSPD();
73   vert[2] = esd->GetPrimaryVertexTPC();
74
75   // if TPC vertexes are rejected by default do this now
76   if (!fAcceptTPC && (vert[0] == vert[2])) {
77     AliDebug(AliLog::kDebug+2, "Rejecting TPC vertex");
78     return kFALSE;
79   }
80
81   // if we are here, vert[0] contains the default primary vertex
82   // in case it is with tracks or SPD, its status must be OK
83   // because otherwise the ESD event returns the lower level vertex
84   // then, we can check just the first element in the array
85   if (!vert[0]->GetStatus()) {
86     AliDebug(AliLog::kDebug+2, "Bad vertex status");
87     return kFALSE;
88   }
89
90   // if we are here, the status of default vertex is OK
91   // and then we check the number of contributors:
92   // it must be *outside* the 'allowed' range
93   fCutValueI = vert[0]->GetNContributors();
94   return /*there is a NOT operator */!/*here*/OkRange();
95 }
96