]>
Commit | Line | Data |
---|---|---|
77c42b43 | 1 | #include "AliVEvent.h" |
2 | #include "AliESDEvent.h" | |
3 | #include "AliAODEvent.h" | |
4 | #include "AliVVertex.h" | |
5 | #include "AliLog.h" | |
6 | #include "AliAODVertex.h" | |
c9df49b3 | 7 | #include "AliVTrack.h" |
8 | #include "AliVEvent.h" | |
9 | #include <TMatrixDSym.h> | |
10 | #include <TMath.h> | |
8c379b7c | 11 | #include "AliVMultiplicity.h" |
beb31786 | 12 | #include "AliPPVsMultUtils.h" |
77c42b43 | 13 | |
14 | #include "AliAnalysisUtils.h" | |
15 | ||
16 | ClassImp(AliAnalysisUtils) | |
17 | ||
18 | //______________________________________________________________________ | |
19 | AliAnalysisUtils::AliAnalysisUtils():TObject(), | |
20 | fisAOD(kTRUE), | |
21 | fMinVtxContr(0), | |
22 | fMaxVtxZ(10.), | |
c9df49b3 | 23 | fCutOnZVertexSPD(kTRUE), |
24 | fUseMVPlpSelection(kFALSE), | |
25 | fUseOutOfBunchPileUp(kFALSE), | |
26 | fMinPlpContribMV(5), | |
27 | fMaxPlpChi2MV(5.), | |
28 | fMinWDistMV(15.), | |
29 | fCheckPlpFromDifferentBCMV(kFALSE), | |
30 | fMinPlpContribSPD(5), | |
31 | fMinPlpZdistSPD(0.8), | |
32 | fnSigmaPlpZdistSPD(3.), | |
33 | fnSigmaPlpDiamXYSPD(2.), | |
34 | fnSigmaPlpDiamZSPD(5.), | |
8c379b7c | 35 | fUseSPDCutInMultBins(kFALSE), |
36 | fASPDCvsTCut(65.), | |
beb31786 | 37 | fBSPDCvsTCut(4.), |
38 | fPPVsMultUtils(0x0) | |
77c42b43 | 39 | { |
40 | // Default contructor | |
41 | } | |
42 | ||
43 | //______________________________________________________________________ | |
44 | Bool_t AliAnalysisUtils::IsVertexSelected2013pA(AliVEvent *event) | |
45 | { | |
46 | Bool_t accept = kFALSE; | |
c9df49b3 | 47 | |
77c42b43 | 48 | // Check whether the event is of AOD or ESD type |
49 | AliAODEvent *aod = 0x0; | |
50 | AliESDEvent *esd = 0x0; | |
51 | aod = dynamic_cast<AliAODEvent*>(event); | |
52 | esd = dynamic_cast<AliESDEvent*>(event); | |
53 | ||
54 | if(aod) { | |
55 | fisAOD = kTRUE; | |
56 | } else { | |
57 | fisAOD = kFALSE; | |
58 | if(!esd) { | |
59 | AliFatal("Event is neither of AOD nor ESD type"); | |
60 | return accept; | |
61 | } | |
62 | } | |
63 | ||
64 | const AliVVertex *trkVtx = fisAOD ? | |
65 | dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertex()) : | |
66 | dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertex()) ; | |
67 | if(!trkVtx || trkVtx->GetNContributors()<=fMinVtxContr){ | |
68 | accept = kFALSE; | |
69 | return accept; | |
70 | } | |
71 | ||
72 | TString vtxTtl = trkVtx->GetTitle(); | |
73 | if (!vtxTtl.Contains("VertexerTracks")) return accept; | |
74 | ||
75 | Float_t zvtx = trkVtx->GetZ(); | |
76 | const AliVVertex* spdVtx = fisAOD ? | |
77 | dynamic_cast<const AliVVertex*>(aod->GetPrimaryVertexSPD()) : | |
78 | dynamic_cast<const AliVVertex*>(esd->GetPrimaryVertexSPD()) ; | |
79 | if (spdVtx->GetNContributors()<=fMinVtxContr) return accept; | |
80 | ||
81 | TString vtxTyp = spdVtx->GetTitle(); | |
82 | Double_t cov[6]={0}; | |
83 | spdVtx->GetCovarianceMatrix(cov); | |
84 | Double_t zRes = TMath::Sqrt(cov[5]); | |
85 | if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return accept; | |
86 | if (fCutOnZVertexSPD && TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return accept; | |
87 | ||
88 | if (TMath::Abs(zvtx) > fMaxVtxZ) return accept; | |
89 | ||
90 | return kTRUE; | |
91 | } | |
92 | ||
93 | //______________________________________________________________________ | |
94 | Bool_t AliAnalysisUtils::IsFirstEventInChunk(AliVEvent *event) | |
95 | { | |
96 | ||
97 | Bool_t accept = kFALSE; | |
98 | ||
99 | // Check whether the event is of AOD or ESD type | |
100 | AliAODEvent *aod = 0x0; | |
101 | AliESDEvent *esd = 0x0; | |
102 | aod = dynamic_cast<AliAODEvent*>(event); | |
103 | esd = dynamic_cast<AliESDEvent*>(event); | |
104 | ||
105 | if(aod) { | |
106 | fisAOD = kTRUE; | |
107 | } else { | |
108 | fisAOD = kFALSE; | |
109 | if(!esd) { | |
110 | AliFatal("Event is neither of AOD nor ESD type"); | |
111 | return accept; | |
112 | } | |
113 | } | |
114 | ||
115 | if(fisAOD){ | |
116 | AliAODHeader *aodheader = 0x0; | |
117 | aodheader = aod->GetHeader(); | |
118 | if(!aodheader){ | |
119 | AliFatal("AOD header not there ?!"); | |
120 | return kFALSE; | |
121 | } | |
122 | if(aodheader->GetEventNumberESDFile()==0) accept = kTRUE; | |
123 | } else { | |
124 | if(esd->GetEventNumberInFile()==0) accept = kTRUE; | |
125 | } | |
c9df49b3 | 126 | |
77c42b43 | 127 | return accept; |
128 | } | |
c9df49b3 | 129 | |
130 | //______________________________________________________________________ | |
131 | Bool_t AliAnalysisUtils::IsPileUpEvent(AliVEvent *event) | |
132 | { | |
133 | Bool_t isPileUp=kFALSE; | |
134 | //check for multiple vertices | |
135 | if(fUseMVPlpSelection)isPileUp=IsPileUpMV(event); | |
136 | else isPileUp=IsPileUpSPD(event); | |
137 | //check for different BC | |
138 | if(fUseOutOfBunchPileUp && IsOutOfBunchPileUp(event))isPileUp=kTRUE; | |
139 | ||
140 | return isPileUp; | |
141 | } | |
142 | ||
143 | //______________________________________________________________________ | |
144 | Bool_t AliAnalysisUtils::IsPileUpMV(AliVEvent *event) | |
145 | { | |
146 | // check for multi-vertexer pile-up | |
147 | const AliAODEvent *aod = dynamic_cast<const AliAODEvent*>(event); | |
148 | const AliESDEvent *esd = dynamic_cast<const AliESDEvent*>(event); | |
149 | // | |
150 | if (!aod && !esd) { | |
151 | AliFatal("Event is neither of AOD nor ESD type"); | |
152 | return kFALSE; | |
153 | } | |
154 | // | |
155 | const AliVVertex* vtPrm = 0; | |
156 | const AliVVertex* vtPlp = 0; | |
157 | Int_t nPlp = 0; | |
158 | // | |
159 | if (aod) { | |
160 | if ( !(nPlp=aod->GetNumberOfPileupVerticesTracks()) ) return kFALSE; | |
161 | vtPrm = aod->GetPrimaryVertex(); | |
162 | if (vtPrm == aod->GetPrimaryVertexSPD()) return kTRUE; // there are pile-up vertices but no primary | |
163 | } | |
164 | else { | |
165 | if ( !(nPlp=esd->GetNumberOfPileupVerticesTracks())) return kFALSE; | |
166 | vtPrm = esd->GetPrimaryVertexTracks(); | |
167 | if (((AliESDVertex*)vtPrm)->GetStatus()!=1) return kTRUE; // there are pile-up vertices but no primary | |
168 | } | |
169 | Int_t bcPrim = vtPrm->GetBC(); | |
170 | // | |
171 | for (Int_t ipl=0;ipl<nPlp;ipl++) { | |
172 | vtPlp = aod ? (const AliVVertex*)aod->GetPileupVertexTracks(ipl) : (const AliVVertex*)esd->GetPileupVertexTracks(ipl); | |
173 | // | |
174 | if (vtPlp->GetNContributors() < fMinPlpContribMV) continue; | |
175 | if (vtPlp->GetChi2perNDF() > fMaxPlpChi2MV) continue; | |
176 | if(fCheckPlpFromDifferentBCMV) | |
177 | { | |
178 | Int_t bcPlp = vtPlp->GetBC(); | |
179 | if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2) return kTRUE; // pile-up from other BC | |
180 | } | |
181 | // | |
182 | Double_t wDst = GetWDist(vtPrm,vtPlp); | |
183 | if (wDst<fMinWDistMV) continue; | |
184 | // | |
185 | return kTRUE; // pile-up: well separated vertices | |
186 | } | |
187 | // | |
188 | return kFALSE; | |
189 | // | |
190 | } | |
191 | ||
192 | //______________________________________________________________________ | |
193 | Bool_t AliAnalysisUtils::IsPileUpSPD(AliVEvent *event) | |
194 | { | |
195 | // check for SPD pile-up | |
196 | const AliAODEvent *aod = dynamic_cast<const AliAODEvent*>(event); | |
197 | const AliESDEvent *esd = dynamic_cast<const AliESDEvent*>(event); | |
198 | // | |
199 | if (!aod && !esd) { | |
200 | AliFatal("Event is neither of AOD nor ESD type"); | |
201 | return kFALSE; | |
202 | } | |
203 | // | |
204 | if (aod) return (fUseSPDCutInMultBins)?aod->IsPileupFromSPDInMultBins():aod->IsPileupFromSPD(fMinPlpContribSPD,fMinPlpZdistSPD,fnSigmaPlpZdistSPD,fnSigmaPlpDiamXYSPD,fnSigmaPlpDiamZSPD); | |
205 | else return (fUseSPDCutInMultBins)?esd->IsPileupFromSPDInMultBins():esd->IsPileupFromSPD(fMinPlpContribSPD,fMinPlpZdistSPD,fnSigmaPlpZdistSPD,fnSigmaPlpDiamXYSPD,fnSigmaPlpDiamZSPD); | |
206 | } | |
207 | ||
208 | //______________________________________________________________________ | |
209 | Bool_t AliAnalysisUtils::IsOutOfBunchPileUp(AliVEvent *event) | |
210 | { | |
211 | // check for SPD pile-up | |
212 | const AliAODEvent *aod = dynamic_cast<const AliAODEvent*>(event); | |
213 | const AliESDEvent *esd = dynamic_cast<const AliESDEvent*>(event); | |
214 | // | |
215 | if (!aod && !esd) { | |
216 | AliFatal("Event is neither of AOD nor ESD type"); | |
217 | return kFALSE; | |
218 | } | |
219 | Int_t bc2 = (aod)?aod->GetHeader()->GetIRInt2ClosestInteractionMap():esd->GetHeader()->GetIRInt2ClosestInteractionMap(); | |
220 | if (bc2 != 0) | |
221 | return kTRUE; | |
222 | ||
223 | Int_t bc1 = (aod)?aod->GetHeader()->GetIRInt1ClosestInteractionMap():esd->GetHeader()->GetIRInt1ClosestInteractionMap(); | |
224 | if (bc1 != 0) | |
225 | return kTRUE; | |
226 | ||
227 | return kFALSE; | |
228 | } | |
229 | ||
8c379b7c | 230 | |
231 | //______________________________________________________________________ | |
232 | Bool_t AliAnalysisUtils::IsSPDClusterVsTrackletBG(AliVEvent *event){ | |
233 | Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0); | |
234 | Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1); | |
235 | Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets(); | |
236 | if (nClustersLayer0 + nClustersLayer1 > fASPDCvsTCut + nTracklets*fBSPDCvsTCut) return kTRUE; | |
237 | return kFALSE; | |
238 | } | |
239 | ||
240 | ||
c9df49b3 | 241 | //______________________________________________________________________ |
242 | Double_t AliAnalysisUtils::GetWDist(const AliVVertex* v0, const AliVVertex* v1) | |
243 | { | |
244 | // calculate sqrt of weighted distance to other vertex | |
245 | if (!v0 || !v1) { | |
246 | printf("One of vertices is not valid\n"); | |
247 | return 0; | |
248 | } | |
249 | static TMatrixDSym vVb(3); | |
250 | Double_t dist = -1; | |
251 | Double_t dx = v0->GetX()-v1->GetX(); | |
252 | Double_t dy = v0->GetY()-v1->GetY(); | |
253 | Double_t dz = v0->GetZ()-v1->GetZ(); | |
254 | Double_t cov0[6],cov1[6]; | |
255 | v0->GetCovarianceMatrix(cov0); | |
256 | v1->GetCovarianceMatrix(cov1); | |
257 | vVb(0,0) = cov0[0]+cov1[0]; | |
258 | vVb(1,1) = cov0[2]+cov1[2]; | |
259 | vVb(2,2) = cov0[5]+cov1[5]; | |
260 | vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1]; | |
261 | vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.; | |
262 | vVb.InvertFast(); | |
263 | if (!vVb.IsValid()) {printf("Singular Matrix\n"); return dist;} | |
264 | dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz | |
265 | + 2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz; | |
266 | return dist>0 ? TMath::Sqrt(dist) : -1; | |
267 | ||
268 | } | |
8c379b7c | 269 | |
beb31786 | 270 | //______________________________________________________________________ |
271 | Float_t AliAnalysisUtils::GetMultiplicityPercentile(AliVEvent *event, TString lMethod ){ | |
272 | if(!fPPVsMultUtils) | |
273 | fPPVsMultUtils=new AliPPVsMultUtils(); | |
274 | if( (event->InheritsFrom("AliAODEvent")) || (event->InheritsFrom("AliESDEvent")) ) return fPPVsMultUtils->GetMultiplicityPercentile(event,lMethod); | |
275 | else { | |
276 | AliFatal("Event is neither of AOD nor ESD type"); | |
277 | return -999.; | |
278 | } | |
279 | } |