]>
Commit | Line | Data |
---|---|---|
1 | // | |
2 | // Class AliRsnCutESD2010 | |
3 | // | |
4 | // General implementation of a single cut strategy, which can be: | |
5 | // - a value contained in a given interval [--> IsBetween() ] | |
6 | // - a value equal to a given reference [--> MatchesValue()] | |
7 | // | |
8 | // In all cases, the reference value(s) is (are) given as data members | |
9 | // and each kind of cut requires a given value type (Int, UInt, Double), | |
10 | // but the cut check procedure is then automatized and chosen thanks to | |
11 | // an enumeration of the implemented cut types. | |
12 | // At the end, the user (or any other point which uses this object) has | |
13 | // to use the method IsSelected() to check if this cut has been passed. | |
14 | // | |
15 | // authors: Martin Vala (martin.vala@cern.ch) | |
16 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
17 | // | |
18 | ||
19 | #include <Riostream.h> | |
20 | ||
21 | #include "AliESDpid.h" | |
22 | #include "AliTOFT0maker.h" | |
23 | #include "AliTOFcalib.h" | |
24 | #include "AliCDBManager.h" | |
25 | #include "AliITSPIDResponse.h" | |
26 | ||
27 | #include "AliRsnEvent.h" | |
28 | #include "AliRsnDaughter.h" | |
29 | #include "AliRsnCutESD2010.h" | |
30 | ||
31 | ClassImp(AliRsnCutESD2010) | |
32 | ||
33 | //_________________________________________________________________________________________________ | |
34 | AliRsnCutESD2010::AliRsnCutESD2010() : | |
35 | AliRsnCut(AliRsnCut::kDaughter), | |
36 | fIsMC(kFALSE), | |
37 | fCheckITS(kTRUE), | |
38 | fCheckTPC(kTRUE), | |
39 | fCheckTOF(kTRUE), | |
40 | fUseGlobal(kTRUE), | |
41 | fUseITSSA(kTRUE), | |
42 | fMaxITSband(1E6), | |
43 | fTPCpLimit(0.35), | |
44 | fMinTPCband(-1E6), | |
45 | fMaxTPCband( 1E6), | |
46 | fESDtrackCutsTPC(), | |
47 | fESDtrackCutsITS(), | |
48 | fESDpid(0x0), | |
49 | fTOFmaker(0x0), | |
50 | fTOFcalib(0x0), | |
51 | fTOFcalibrateESD(kFALSE), | |
52 | fTOFcorrectTExp(kFALSE), | |
53 | fTOFuseT0(kFALSE), | |
54 | fTOFtuneMC(kFALSE), | |
55 | fTOFresolution(0.0), | |
56 | fLastRun(-1) | |
57 | { | |
58 | // | |
59 | // Default constructor. | |
60 | // | |
61 | } | |
62 | ||
63 | //_________________________________________________________________________________________________ | |
64 | AliRsnCutESD2010::AliRsnCutESD2010 | |
65 | (const char *name) : | |
66 | AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0), | |
67 | fIsMC(kFALSE), | |
68 | fCheckITS(kTRUE), | |
69 | fCheckTPC(kTRUE), | |
70 | fCheckTOF(kTRUE), | |
71 | fUseGlobal(kTRUE), | |
72 | fUseITSSA(kTRUE), | |
73 | fMaxITSband(1E6), | |
74 | fTPCpLimit(0.35), | |
75 | fMinTPCband(-1E6), | |
76 | fMaxTPCband( 1E6), | |
77 | fESDtrackCutsTPC(), | |
78 | fESDtrackCutsITS(), | |
79 | fESDpid(0x0), | |
80 | fTOFmaker(0x0), | |
81 | fTOFcalib(0x0), | |
82 | fTOFcalibrateESD(kFALSE), | |
83 | fTOFcorrectTExp(kFALSE), | |
84 | fTOFuseT0(kFALSE), | |
85 | fTOFtuneMC(kFALSE), | |
86 | fTOFresolution(0.0), | |
87 | fLastRun(-1) | |
88 | { | |
89 | // | |
90 | // Main constructor. | |
91 | // | |
92 | } | |
93 | ||
94 | //_________________________________________________________________________________________________ | |
95 | AliRsnCutESD2010::AliRsnCutESD2010 | |
96 | (const AliRsnCutESD2010& copy) : | |
97 | AliRsnCut(copy), | |
98 | fIsMC(kFALSE), | |
99 | fCheckITS(copy.fCheckITS), | |
100 | fCheckTPC(copy.fCheckTPC), | |
101 | fCheckTOF(copy.fCheckTOF), | |
102 | fUseGlobal(copy.fUseGlobal), | |
103 | fUseITSSA(copy.fUseITSSA), | |
104 | fMaxITSband(copy.fMaxITSband), | |
105 | fTPCpLimit(copy.fTPCpLimit), | |
106 | fMinTPCband(copy.fMinTPCband), | |
107 | fMaxTPCband(copy.fMaxTPCband), | |
108 | fESDtrackCutsTPC(copy.fESDtrackCutsTPC), | |
109 | fESDtrackCutsITS(copy.fESDtrackCutsITS), | |
110 | fESDpid(0x0), | |
111 | fTOFmaker(0x0), | |
112 | fTOFcalib(0x0), | |
113 | fTOFcalibrateESD(copy.fTOFcalibrateESD), | |
114 | fTOFcorrectTExp(copy.fTOFcorrectTExp), | |
115 | fTOFuseT0(copy.fTOFuseT0), | |
116 | fTOFtuneMC(copy.fTOFtuneMC), | |
117 | fTOFresolution(copy.fTOFresolution), | |
118 | fLastRun(-1) | |
119 | { | |
120 | // | |
121 | // Main constructor. | |
122 | // | |
123 | } | |
124 | ||
125 | //_________________________________________________________________________________________________ | |
126 | void AliRsnCutESD2010::InitializeToDefaults(Bool_t isSim) | |
127 | { | |
128 | // | |
129 | // Main constructor. | |
130 | // | |
131 | ||
132 | // ----> set TPC range for PID and calibration | |
133 | SetTPCrange(5.0, 3.0); | |
134 | SetTPCpLimit(0.35); | |
135 | ||
136 | // ----> set ITS range for PID | |
137 | SetITSband(4.0); | |
138 | ||
139 | // ----> set TPC calibration | |
140 | if (isSim) SetTPCpar(2.15898 / 50.0, 1.75295E1, 3.40030E-9, 1.96178, 3.91720); | |
141 | else SetTPCpar(1.41543 / 50.0, 2.63394E1, 5.0411E-11, 2.12543, 4.88663); | |
142 | ||
143 | // ----> set standard quality cuts for TPC global tracks | |
144 | fESDtrackCutsTPC.SetRequireTPCStandAlone(kTRUE); // require to have the projection at inner TPC wall | |
145 | fESDtrackCutsTPC.SetMinNClustersTPC(70); | |
146 | fESDtrackCutsTPC.SetMaxChi2PerClusterTPC(4); | |
147 | fESDtrackCutsTPC.SetAcceptKinkDaughters(kFALSE); | |
148 | fESDtrackCutsTPC.SetRequireTPCRefit(kTRUE); | |
149 | fESDtrackCutsTPC.SetRequireITSRefit(kTRUE); | |
150 | fESDtrackCutsTPC.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); | |
151 | fESDtrackCutsTPC.SetMaxDCAToVertexXYPtDep("0.0350+0.0420/pt^0.9"); // DCA pt dependent: 7*(0.0050+0.0060/pt0.9) | |
152 | fESDtrackCutsTPC.SetMaxDCAToVertexZ(1e6); // disabled | |
153 | fESDtrackCutsTPC.SetDCAToVertex2D(kFALSE); // each DCA is checked separately | |
154 | fESDtrackCutsTPC.SetRequireSigmaToVertex(kFALSE); | |
155 | ||
156 | // ----> set standard quality cuts for ITS standalone tracks | |
157 | fESDtrackCutsITS.SetRequireITSStandAlone(kTRUE); | |
158 | fESDtrackCutsITS.SetRequireITSRefit(kTRUE); | |
159 | fESDtrackCutsITS.SetMinNClustersITS(4); | |
160 | fESDtrackCutsITS.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); | |
161 | fESDtrackCutsITS.SetMaxChi2PerClusterITS(1.); | |
162 | fESDtrackCutsITS.SetMaxDCAToVertexXYPtDep("0.0595+0.0182/pt^1.55"); // DCA pt dependent | |
163 | fESDtrackCutsITS.SetMaxDCAToVertexZ(1e6); // disabled | |
164 | fESDtrackCutsITS.SetDCAToVertex2D(kFALSE); // each DCA is checked separately | |
165 | ||
166 | // ----> set the TOF calibration depending on type of input (sim/data) | |
167 | SetTOFcorrectTExp(kTRUE); | |
168 | SetTOFuseT0(kTRUE); | |
169 | SetTOFresolution(100.0); | |
170 | if (isSim) | |
171 | { | |
172 | SetTOFcalibrateESD(kFALSE); | |
173 | SetTOFtuneMC(kTRUE); | |
174 | } | |
175 | else | |
176 | { | |
177 | //if (isPass2) SetTOFcalibrateESD(kFALSE); // potrebbe anche essere kFALSE | |
178 | SetTOFcalibrateESD(kTRUE); | |
179 | SetTOFtuneMC(kFALSE); | |
180 | } | |
181 | } | |
182 | ||
183 | //_________________________________________________________________________________________________ | |
184 | void AliRsnCutESD2010::SetEvent(AliRsnEvent *event) | |
185 | { | |
186 | // don't do anything if the event is the same as before | |
187 | if (fEvent != 0x0 && fEvent == event) return; | |
188 | ||
189 | // retrieve the ESD event | |
190 | AliESDEvent *esd = event->GetRefESD(); | |
191 | if (!esd) | |
192 | { | |
193 | fEvent = 0x0; | |
194 | return; | |
195 | } | |
196 | else | |
197 | { | |
198 | fEvent = event; | |
199 | } | |
200 | ||
201 | // if absent, initialize ESD pid responst | |
202 | if (!fESDpid) | |
203 | { | |
204 | fESDpid = new AliESDpid; | |
205 | fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); | |
206 | } | |
207 | ||
208 | // initialize DB to current run | |
209 | Int_t run = esd->GetRunNumber(); | |
210 | if (run != fLastRun) | |
211 | { | |
212 | cout << "Run = " << run << " -- LAST = " << fLastRun << endl; | |
213 | fLastRun = run; | |
214 | ||
215 | // setup TOF maker & calibration | |
216 | if (!fTOFcalib) fTOFcalib = new AliTOFcalib; | |
217 | fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); | |
218 | if (!fTOFmaker) fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib); | |
219 | fTOFmaker->SetTimeResolution(fTOFresolution); | |
220 | ||
221 | AliCDBManager *cdb = AliCDBManager::Instance(); | |
222 | cdb->SetDefaultStorage("raw://"); | |
223 | cdb->SetRun(run); | |
224 | fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); | |
225 | fTOFcalib->Init(); | |
226 | } | |
227 | ||
228 | // if required, calibrate the TOF t0 maker with current event | |
229 | if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(esd); | |
230 | if (fTOFtuneMC) fTOFmaker->TuneForMC(esd); | |
231 | if (fTOFuseT0) | |
232 | { | |
233 | fTOFmaker->ComputeT0TOF(esd); | |
234 | fTOFmaker->ApplyT0TOF(esd); | |
235 | fESDpid->MakePID(esd, kFALSE, 0.); | |
236 | } | |
237 | } | |
238 | ||
239 | //_________________________________________________________________________________________________ | |
240 | Bool_t AliRsnCutESD2010::IsSelected(TObject *obj1, TObject* /*obj2*/) | |
241 | { | |
242 | // | |
243 | // Cut checker. | |
244 | // | |
245 | ||
246 | // coherence check: require an ESD track | |
247 | AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(obj1); | |
248 | if (!daughter) return kFALSE; | |
249 | AliESDtrack *track = daughter->GetRefESDtrack(); | |
250 | if (!track) return kFALSE; | |
251 | ||
252 | // if no reference event, skip | |
253 | if (!fEvent) return kFALSE; | |
254 | ||
255 | // ITS stuff #1 create the response function | |
256 | AliITSPIDResponse itsrsp(fIsMC); | |
257 | ||
258 | // TOF: define fixed function for compatibility range | |
259 | Double_t a1 = 0.01, a2 = -0.03; | |
260 | Double_t b1 = 0.25, b2 = 0.25; | |
261 | Double_t c1 = 0.05, c2 = -0.03; | |
262 | Double_t ymax, ymin; | |
263 | ||
264 | ULong_t status; | |
265 | Int_t k, nITS; | |
266 | Double_t times[10], tpcNSigma, tpcMaxNSigma, itsSignal, itsNSigma, mom, tofTime, tofSigma, tofRef, tofRel; | |
267 | Bool_t okQuality, okTOF, okTPC, okITS, okTrack, isTPC, isITSSA; | |
268 | UChar_t itsCluMap; | |
269 | ||
270 | // get commonly used variables | |
271 | status = (ULong_t)track->GetStatus(); | |
272 | mom = track->P(); | |
273 | isTPC = ((status & AliESDtrack::kTPCin) != 0); | |
274 | isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0); | |
275 | ||
276 | // accept only tracks which are TPC+ITS or ITS standalone | |
277 | if (!isTPC && !isITSSA) return kFALSE; | |
278 | if ( isTPC && !fUseGlobal) return kFALSE; | |
279 | if ( isITSSA && !fUseITSSA) return kFALSE; | |
280 | ||
281 | if (isTPC) | |
282 | { | |
283 | // check standard ESD cuts | |
284 | okQuality = fESDtrackCutsTPC.IsSelected(track); | |
285 | //cout << "GLOBAL -- quality = " << (okQuality ? "GOOD" : "BAD") << endl; | |
286 | if (!okQuality) return kFALSE; | |
287 | ||
288 | // check TPC dE/dx | |
289 | if (fCheckTPC) | |
290 | { | |
291 | tpcNSigma = TMath::Abs(fESDpid->NumberOfSigmasTPC(track, AliPID::kKaon)); | |
292 | if (track->GetInnerParam()->P() > fTPCpLimit) tpcMaxNSigma = fMinTPCband; else tpcMaxNSigma = fMaxTPCband; | |
293 | okTPC = (tpcNSigma <= tpcMaxNSigma); | |
294 | //cout << "RSN -- TPC -- nsigma = " << tpcNSigma << ", max = " << tpcMaxNSigma << " --> " << (okTPC ? "OK" : "FAILED") << endl; | |
295 | //cout << "RSNTPC -- " << fTPCpar[0] << ' ' << fTPCpar[1] << ' ' << fTPCpar[2] << ' ' << fTPCpar[3] << ' ' << fTPCpar[4] << endl; | |
296 | } | |
297 | else | |
298 | { | |
299 | okTPC = kTRUE; | |
300 | } | |
301 | ||
302 | // check TOF (only if momentum is large than function asymptote and flags are OK) | |
303 | if (fCheckTOF) | |
304 | { | |
305 | if (((status & AliESDtrack::kTOFout) != 0) && ((status & AliESDtrack::kTIME) != 0) && mom > TMath::Max(b1, b2)) | |
306 | { | |
307 | track->GetIntegratedTimes(times); | |
308 | tofTime = (Double_t)track->GetTOFsignal(); | |
309 | tofSigma = fTOFmaker->GetExpectedSigma(mom, times[AliPID::kKaon], AliPID::ParticleMass(AliPID::kKaon)); | |
310 | tofRef = times[AliPID::kKaon]; | |
311 | if (tofRef > 0.0) | |
312 | { | |
313 | tofRel = (tofTime - tofRef) / tofRef; | |
314 | ymax = a1 / (mom - b1) + c1; | |
315 | ymin = a2 / (mom - b2) + c2; | |
316 | okTOF = (tofRel >= ymin && tofRel <= ymax); | |
317 | //cout << "TOF -- diff = " << tofDiff << ", rel diff = " << tofRel << ", range = " << ymin << " to " << ymax << ", sigma = " << tofSigma << " --> " << (okTOF ? "OK" : "FAILED") << endl; | |
318 | } | |
319 | else | |
320 | { | |
321 | okTOF = kTRUE; | |
322 | if (!fCheckTPC) okTOF = kFALSE; | |
323 | //cout << "TOF -- not checked due to ZERO reference time" << endl; | |
324 | } | |
325 | } | |
326 | else | |
327 | { | |
328 | okTOF = kTRUE; | |
329 | if (!fCheckTPC) okTOF = kFALSE; | |
330 | //cout << "TOF -- not checked because TOF pid absent" << endl; | |
331 | } | |
332 | } | |
333 | else | |
334 | { | |
335 | okTOF = kTRUE; | |
336 | } | |
337 | ||
338 | // combine checks | |
339 | okTrack = okQuality && okTPC && okTOF; | |
340 | //cout << "GLOBAL -- overall = " << (okTrack ? "ACCEPTED" : "REJECTED") << endl; | |
341 | } | |
342 | else | |
343 | { | |
344 | // check standard ESD cuts | |
345 | okQuality = fESDtrackCutsITS.IsSelected(track); | |
346 | //cout << "ITSSA -- quality = " << (okQuality ? "GOOD" : "BAD") << endl; | |
347 | if (!okQuality) return kFALSE; | |
348 | ||
349 | // check dE/dx | |
350 | if (fCheckITS) | |
351 | { | |
352 | itsSignal = track->GetITSsignal(); | |
353 | itsCluMap = track->GetITSClusterMap(); | |
354 | nITS = 0; | |
355 | for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITS; | |
356 | if (nITS < 3) | |
357 | { | |
358 | okITS = kFALSE; | |
359 | //cout << "ITS -- not checked due to too few PID clusters" << endl; | |
360 | } | |
361 | else | |
362 | { | |
363 | itsNSigma = itsrsp.GetNumberOfSigmas(mom, itsSignal, AliPID::kKaon, nITS, kTRUE); | |
364 | okITS = (TMath::Abs(itsNSigma) <= fMaxITSband); | |
365 | //cout << "ITS -- nsigma = " << itsNSigma << ", max = " << fMaxITSband << " --> " << (okITS ? "OK" : "FAILED") << endl; | |
366 | } | |
367 | } | |
368 | else | |
369 | { | |
370 | okITS = kTRUE; | |
371 | } | |
372 | ||
373 | okTrack = okQuality && okITS; | |
374 | //cout << "ITSSA -- overall = " << (okTrack ? "ACCEPTED" : "REJECTED") << endl; | |
375 | } | |
376 | ||
377 | return okTrack; | |
378 | } |