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"
12 #include "AliAnalysisUtils.h"
14 ClassImp(AliRsnCutPrimaryVertex)
16 //_________________________________________________________________________________________________
17 AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
18 (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
19 AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6),
20 fAcceptTPC(acceptTPC),
25 // Defines the cut range between 0 and
26 // the minimum required number of contributors.
27 // The cut will be passed when if the event has a
28 // primary vertex with number of contributors outside this interval.
30 // If the 'acceptTPC' argument is true, events with TPC
31 // primary vertex will be checked, otherwise they will be
32 // rejected by default.
34 // Since the range check uses the '>=' and '<=', the high edge
35 // must be decreased by 1 to get the right behaviour, since this is integer.
39 //_________________________________________________________________________________________________
40 Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
46 // which also fills data member objects
47 if (!TargetOK(object)) return kFALSE;
50 AliESDEvent *esd = dynamic_cast<AliESDEvent *>(fEvent->GetRef());
51 AliAODEvent *aod = dynamic_cast<AliAODEvent *>(fEvent->GetRef());
52 AliVEvent *vevt = dynamic_cast<AliVEvent *>(fEvent->GetRef());
55 AliAnalysisUtils * utils = new AliAnalysisUtils();
56 if (utils->IsPileUpSPD(vevt)) return kFALSE;
60 // get the best primary vertex:
61 // first try the one with tracks
62 const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks();
63 const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD();
64 const AliESDVertex *vTPC = esd->GetPrimaryVertexTPC();
68 Double_t vzTrk = 1000000.0;
69 Double_t vzSPD = 1000000.0;
70 Double_t vzTPC = 1000000.0;
71 if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
72 if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
73 if (vTPC) vzTPC = TMath::Abs(vTPC->GetZv());
74 if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
75 if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
76 if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors();
77 if (vTrk && ncTrk > 0) {
80 } else if (vSPD && ncSPD > 0) {
83 } else if (vTPC && ncTPC > 0) {
93 // in this case, as suggested by Andrea Dainese,
94 // we first check if the SPD primary vertex is there
95 // if it is not, then the only available is the TPC
96 // stand-alone primary vertex, which is rejected
97 AliAODVertex *aodv = aod->GetPrimaryVertexSPD();
99 AliDebugClass(1, "Not found SPD vertex --> TPC only available, skipped");
102 // now check primary vertex
103 aodv = (AliAODVertex *)aod->GetPrimaryVertex();
104 if (CheckVertex(aodv)) {
105 AliDebugClass(1, "Vertex TRK is OK");
106 fCutValueD = aodv->GetZ();
107 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
110 aodv = aod->GetPrimaryVertexSPD();
111 if (CheckVertex(aodv)) {
112 AliDebugClass(1, "Vertex TRK is BAD, but vertex SPD is OK");
113 fCutValueD = aodv->GetZ();
114 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
116 AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD");
124 Bool_t result = ((!OkRangeI()) && OkRangeD());
128 //_________________________________________________________________________________________________
129 void AliRsnCutPrimaryVertex::Print(const Option_t *) const
132 // Print information on this cut
135 AliInfo(Form("Cut name : %s", GetName()));
136 AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO")));
137 AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI));
138 AliInfo(Form("Z-vertex range (inside) : %f - %f", fMinD, fMaxD));
141 //__________________________________________________________________________________________________
142 Bool_t AliRsnCutPrimaryVertex::CheckVertex(AliVVertex *vertex)
145 // Checks if a candidate primary vertex is good,
146 // which is true if it is not null and has at
147 // least one contributor
150 if (!vertex) return kFALSE;
151 if (vertex->GetNContributors() < 1) return kFALSE;