]>
Commit | Line | Data |
---|---|---|
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 | |
14 | ClassImp(AliRsnCutPrimaryVertex) | |
15 | ||
96ab9736 | 16 | //_________________________________________________________________________________________________ |
17 | AliRsnCutPrimaryVertex::AliRsnCutPrimaryVertex | |
57b34356 | 18 | (const char *name, Double_t maxVz, Int_t nContributors, Bool_t acceptTPC, Bool_t acceptSPD) : |
f34f960b | 19 | AliRsnCut(name, AliRsnCut::kEvent, 0, nContributors - 1, -maxVz, maxVz + 1E-6), |
2a1c7696 | 20 | fAcceptTPC(acceptTPC), |
57b34356 | 21 | fAcceptSPD(acceptSPD), |
2a1c7696 | 22 | fCheckPileUp(kFALSE) |
96ab9736 | 23 | { |
24 | // | |
25 | // Main constructor. | |
ceaa78d3 | 26 | // Defines the cut range between 0 and |
27 | // the minimum required number of contributors. | |
28 | // The cut will be passed when if the event has a | |
29 | // primary vertex with number of contributors outside this interval. | |
30 | // --- | |
31 | // If the 'acceptTPC' argument is true, events with TPC | |
32 | // primary vertex will be checked, otherwise they will be | |
33 | // rejected by default. | |
34 | // --- | |
35 | // Since the range check uses the '>=' and '<=', the high edge | |
36 | // must be decreased by 1 to get the right behaviour, since this is integer. | |
96ab9736 | 37 | // |
38 | } | |
39 | ||
40 | //_________________________________________________________________________________________________ | |
32992791 | 41 | Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *object) |
96ab9736 | 42 | { |
43 | // | |
44 | // Cut checker | |
45 | // | |
99261e24 | 46 | // coherence check |
47 | // which also fills data member objects | |
48 | if (!TargetOK(object)) return kFALSE; | |
49 | ||
2a1c7696 | 50 | // retrieve ESD event |
61f275d1 | 51 | AliESDEvent *esd = dynamic_cast<AliESDEvent *>(fEvent->GetRef()); |
52 | AliAODEvent *aod = dynamic_cast<AliAODEvent *>(fEvent->GetRef()); | |
f5098784 | 53 | AliVEvent *vevt = dynamic_cast<AliVEvent *>(fEvent->GetRef()); |
54 | // pile-up check | |
55 | if (fCheckPileUp) { | |
56 | AliAnalysisUtils * utils = new AliAnalysisUtils(); | |
57 | if (utils->IsPileUpSPD(vevt)) return kFALSE; | |
58 | } | |
59 | ||
2a1c7696 | 60 | if (esd) { |
2a1c7696 | 61 | // get the best primary vertex: |
62 | // first try the one with tracks | |
63 | const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks(); | |
64 | const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD(); | |
65 | const AliESDVertex *vTPC = esd->GetPrimaryVertexTPC(); | |
66 | Int_t ncTrk = -1; | |
67 | Int_t ncSPD = -1; | |
68 | Int_t ncTPC = -1; | |
69 | Double_t vzTrk = 1000000.0; | |
70 | Double_t vzSPD = 1000000.0; | |
71 | Double_t vzTPC = 1000000.0; | |
e690d4d0 | 72 | if (vTrk) vzTrk = TMath::Abs(vTrk->GetZ()); |
73 | if (vSPD) vzSPD = TMath::Abs(vSPD->GetZ()); | |
74 | if (vTPC) vzTPC = TMath::Abs(vTPC->GetZ()); | |
2a1c7696 | 75 | if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors(); |
76 | if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors(); | |
77 | if (vTPC) ncTPC = (Int_t)vTPC->GetNContributors(); | |
78 | if (vTrk && ncTrk > 0) { | |
79 | fCutValueI = ncTrk; | |
80 | fCutValueD = vzTrk; | |
81 | } else if (vSPD && ncSPD > 0) { | |
57b34356 | 82 | if (!fAcceptSPD) |
83 | return kFALSE; | |
84 | else { | |
2a1c7696 | 85 | fCutValueI = ncSPD; |
86 | fCutValueD = vzSPD; | |
57b34356 | 87 | } |
2a1c7696 | 88 | } else if (vTPC && ncTPC > 0) { |
89 | if (!fAcceptTPC) | |
90 | return kFALSE; | |
91 | else { | |
92 | fCutValueI = ncTPC; | |
93 | fCutValueD = vzTPC; | |
94 | } | |
95 | } else | |
96 | return kFALSE; | |
97 | } else if (aod) { | |
f34f960b | 98 | // in this case, as suggested by Andrea Dainese, |
99 | // we first check if the SPD primary vertex is there | |
100 | // if it is not, then the only available is the TPC | |
101 | // stand-alone primary vertex, which is rejected | |
57b34356 | 102 | |
103 | if(fAcceptSPD){ | |
104 | AliAODVertex *aodv = aod->GetPrimaryVertexSPD(); | |
105 | if (!aodv) { | |
106 | AliDebugClass(1, "Not found SPD vertex --> TPC only available, skipped"); | |
107 | return kFALSE; | |
108 | } | |
109 | // now check primary vertex | |
110 | aodv = (AliAODVertex *)aod->GetPrimaryVertex(); | |
111 | if (CheckVertex(aodv)) { | |
112 | AliDebugClass(1, "Vertex TRK is OK"); | |
113 | fCutValueD = aodv->GetZ(); | |
114 | fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors(); | |
115 | } | |
116 | else { | |
117 | aodv = aod->GetPrimaryVertexSPD(); | |
118 | if (CheckVertex(aodv)) { | |
119 | AliDebugClass(1, "Vertex TRK is BAD, but vertex SPD is OK"); | |
120 | fCutValueD = aodv->GetZ(); | |
121 | fCutValueI = aodv->GetNDaughters(); //aodv->GetNContributors(); | |
122 | } else { | |
123 | AliDebugClass(1, "Vertex TRK is BAD, and vertex SPD is BAD"); | |
124 | return kFALSE; | |
125 | } | |
126 | ||
127 | } | |
128 | } | |
129 | else{ | |
130 | const AliVVertex *vertex = aod->GetPrimaryVertex(); | |
131 | if(!vertex) return kFALSE; | |
132 | else{ | |
133 | TString title=vertex->GetTitle(); | |
134 | if(title.Contains("Z") ) return kFALSE; | |
135 | else if(title.Contains("3D") ) return kFALSE; | |
136 | fCutValueI = vertex->GetNContributors(); | |
137 | fCutValueD = TMath::Abs(vertex->GetZ()); | |
138 | } | |
139 | } | |
140 | ||
141 | } else | |
142 | return kFALSE; | |
a378358c | 143 | |
2a1c7696 | 144 | // output |
145 | Bool_t result = ((!OkRangeI()) && OkRangeD()); | |
146 | return result; | |
96ab9736 | 147 | } |
aa24e021 | 148 | |
149 | //_________________________________________________________________________________________________ | |
150 | void AliRsnCutPrimaryVertex::Print(const Option_t *) const | |
151 | { | |
152 | // | |
153 | // Print information on this cut | |
154 | // | |
155 | ||
2a1c7696 | 156 | AliInfo(Form("Cut name : %s", GetName())); |
157 | AliInfo(Form("Accepting TPC primary vertex : %s", (fAcceptTPC ? "YES" : "NO"))); | |
57b34356 | 158 | AliInfo(Form("Accepting SPD primary vertex : %s", (fAcceptSPD ? "YES" : "NO"))); |
2a1c7696 | 159 | AliInfo(Form("Contributors range (outside) : %d - %d", fMinI, fMaxI)); |
160 | AliInfo(Form("Z-vertex range (inside) : %f - %f", fMinD, fMaxD)); | |
aa24e021 | 161 | } |
f5098784 | 162 | |
163 | //__________________________________________________________________________________________________ | |
164 | Bool_t AliRsnCutPrimaryVertex::CheckVertex(AliVVertex *vertex) | |
165 | { | |
166 | // | |
167 | // Checks if a candidate primary vertex is good, | |
168 | // which is true if it is not null and has at | |
169 | // least one contributor | |
170 | // | |
171 | ||
172 | if (!vertex) return kFALSE; | |
173 | if (vertex->GetNContributors() < 1) return kFALSE; | |
174 | return kTRUE; | |
175 | } |