2 // Class AliRsnCutPrimaryVertex
4 // This cut implementation checks the quality of event primary vertex.
5 // It currently works only with ESD events (not AOD).
7 // authors: Martin Vala (martin.vala@cern.ch)
8 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 #include "AliRsnCutPrimaryVertex.h"
13 ClassImp(AliRsnCutPrimaryVertex)
15 //_________________________________________________________________________________________________
16 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex() :
17 AliRsnCut(AliRsnCut::kEvent),
21 // Default constructor.
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),
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.
38 // If the 'acceptTPC' argument is true, events with TPC
39 // primary vertex will be checked, otherwise they will be
40 // rejected by default.
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.
50 //_________________________________________________________________________________________________
51 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/)
57 static Int_t evNum = 0;
61 AliRsnEvent *rsn = dynamic_cast<AliRsnEvent*>(obj1);
62 if (!rsn) return kFALSE;
63 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(rsn->GetRef());
64 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(rsn->GetRef());
68 // get the best primary vertex:
69 // first try the one with tracks
70 const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks();
71 const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD();
72 const AliESDVertex *vTPC = esd->GetPrimaryVertexTPC();
76 Double_t vzTrk = 2.0 * fMaxD;
77 Double_t vzSPD = 2.0 * fMaxD;
78 Double_t vzTPC = 2.0 * fMaxD;
79 if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
80 if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
81 if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
82 if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
83 if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
84 if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
90 else if (vSPD && ncSPD > 0)
95 else if (vTPC && fAcceptTPC && ncTPC > 0)
103 fCutValueD = 2.0 * fMaxD;
108 AliAODVertex *prim = aod->GetPrimaryVertex();
109 if (!prim || prim->GetNContributors() < 1) prim = aod->GetPrimaryVertexSPD();
110 if (!prim || prim->GetNContributors() < 1) return kFALSE;
111 fCutValueI = prim->GetNContributors();
112 fCutValueD = prim->GetZ();
118 Bool_t result = ((!OkRangeI()) && OkRangeD());