]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/AliRsnCutPrimaryVertex.cxx
Macros for Phi analysis in pPb (Ajay)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPrimaryVertex.cxx
CommitLineData
96ab9736 1//
2// Class AliRsnCutPrimaryVertex
3//
ceaa78d3 4// This cut implementation checks the quality of event primary vertex.
5// It currently works only with ESD events (not AOD).
96ab9736 6//
7// authors: Martin Vala (martin.vala@cern.ch)
8// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9//
96ab9736 10
96ab9736 11#include "AliRsnCutPrimaryVertex.h"
f5098784 12#include "AliAnalysisUtils.h"
96ab9736 13
14ClassImp(AliRsnCutPrimaryVertex)
15
96ab9736 16//_________________________________________________________________________________________________
17AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex
02e8aa99 18(const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC) :
f34f960b 19 AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6),
2a1c7696 20 fAcceptTPC(acceptTPC),
21 fCheckPileUp(kFALSE)
96ab9736 22{
23//
24// Main constructor.
ceaa78d3 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.
29// ---
30// If the 'acceptTPC' argument is true, events with TPC
31// primary vertex will be checked, otherwise they will be
32// rejected by default.
33// ---
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.
96ab9736 36//
37}
38
39//_________________________________________________________________________________________________
32992791 40Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object)
96ab9736 41{
42//
43// Cut checker
44//
99261e24 45 // coherence check
46 // which also fills data member objects
47 if (!TargetOK(object)) return kFALSE;
48
2a1c7696 49 // retrieve ESD event
61f275d1 50 AliESDEvent *esd = dynamic_cast<AliESDEvent *>(fEvent->GetRef());
51 AliAODEvent *aod = dynamic_cast<AliAODEvent *>(fEvent->GetRef());
f5098784 52 AliVEvent *vevt = dynamic_cast<AliVEvent *>(fEvent->GetRef());
53 // pile-up check
54 if (fCheckPileUp) {
55 AliAnalysisUtils * utils = new AliAnalysisUtils();
56 if (utils->IsPileUpSPD(vevt)) return kFALSE;
57 }
58
2a1c7696 59 if (esd) {
2a1c7696 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();
65 Int_t ncTrk = -1;
66 Int_t ncSPD = -1;
67 Int_t ncTPC = -1;
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) {
78 fCutValueI = ncTrk;
79 fCutValueD = vzTrk;
80 } else if (vSPD && ncSPD > 0) {
81 fCutValueI = ncSPD;
82 fCutValueD = vzSPD;
83 } else if (vTPC && ncTPC > 0) {
84 if (!fAcceptTPC)
85 return kFALSE;
86 else {
87 fCutValueI = ncTPC;
88 fCutValueD = vzTPC;
89 }
90 } else
91 return kFALSE;
92 } else if (aod) {
f34f960b 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();
98 if (!aodv) {
99 AliDebugClass(1, "Not found SPD vertex --> TPC only available, skipped");
100 return kFALSE;
101 }
102 // now check primary vertex
61f275d1 103 aodv = (AliAODVertex *)aod->GetPrimaryVertex();
f34f960b 104 if (CheckVertex(aodv)) {
105 AliDebugClass(1, "Vertex TRK is OK");
106 fCutValueD = aodv->GetZ();
110620ce 107 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
f34f960b 108 }
109 else {
110 aodv = aod->GetPrimaryVertexSPD();
111 if (CheckVertex(aodv)) {
112 AliDebugClass(1, "Vertex TRK is BAD, but vertex SPD is OK");
113 fCutValueD = aodv->GetZ();
110620ce 114 fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors();
f34f960b 115 } else {
116 AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD");
117 return kFALSE;
118 }
2a1c7696 119 }
2a1c7696 120 } else
5faf5a07 121 return kFALSE;
a378358c 122
2a1c7696 123 // output
124 Bool_t result = ((!OkRangeI()) && OkRangeD());
125 return result;
96ab9736 126}
aa24e021 127
128//_________________________________________________________________________________________________
129void AliRsnCutPrimaryVertex::Print(const Option_t *) const
130{
131//
132// Print information on this cut
133//
134
2a1c7696 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));
aa24e021 139}
f5098784 140
141//__________________________________________________________________________________________________
142Bool_t AliRsnCutPrimaryVertex::CheckVertex(AliVVertex *vertex)
143{
144//
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
148//
149
150 if (!vertex) return kFALSE;
151 if (vertex->GetNContributors() < 1) return kFALSE;
152 return kTRUE;
153}