]>
Commit | Line | Data |
---|---|---|
6aecf4fd | 1 | // |
2 | // Implementation file for implementation of data analysis aft 900 GeV | |
3 | // | |
4 | // Author: A. Pulvirenti | |
5 | // | |
6 | ||
7 | #include "Riostream.h" | |
8 | #include <iomanip> | |
9 | ||
10 | #include "TH1.h" | |
11 | #include "TTree.h" | |
12 | #include "TParticle.h" | |
13 | #include "TRandom.h" | |
14 | #include "TLorentzVector.h" | |
15 | ||
16 | #include "AliLog.h" | |
17 | #include "AliESDpid.h" | |
18 | #include "AliESDEvent.h" | |
19 | #include "AliESDVertex.h" | |
20 | #include "AliESDtrack.h" | |
21 | #include "AliStack.h" | |
22 | #include "AliMCEvent.h" | |
23 | #include "AliTOFT0maker.h" | |
24 | #include "AliTOFcalib.h" | |
25 | #include "AliCDBManager.h" | |
26 | #include "AliITSPIDResponse.h" | |
27 | #include "AliRsnMonitorTrack.h" | |
69fbb331 | 28 | #include "AliRsnDaughter.h" |
29 | #include "AliRsnEvent.h" | |
6aecf4fd | 30 | |
31 | #include "AliRsnAnalysisMonitorTask.h" | |
32 | ||
2941485c | 33 | ClassImp(AliRsnAnalysisMonitorTask) |
34 | ||
6aecf4fd | 35 | //__________________________________________________________________________________________________ |
36 | AliRsnAnalysisMonitorTask::AliRsnAnalysisMonitorTask(const char *name) : | |
37 | AliAnalysisTaskSE(name), | |
6aecf4fd | 38 | fOut(0x0), |
e8d3678d | 39 | fTrack(0x0), |
6aecf4fd | 40 | fESDpid(0x0), |
41 | fTOFmaker(0x0), | |
42 | fTOFcalib(0x0), | |
43 | fTOFcalibrateESD(kFALSE), | |
44 | fTOFcorrectTExp(kFALSE), | |
45 | fTOFuseT0(kFALSE), | |
46 | fTOFtuneMC(kFALSE), | |
69fbb331 | 47 | fTOFresolution(0.0), |
48 | fEventCuts("eventCuts", AliRsnCut::kEvent), | |
49 | fTrackCuts("trackCuts", AliRsnCut::kDaughter) | |
6aecf4fd | 50 | |
51 | { | |
52 | // | |
53 | // Constructor | |
54 | // | |
55 | ||
56 | DefineOutput(1, TTree::Class()); | |
57 | } | |
58 | ||
59 | //__________________________________________________________________________________________________ | |
60 | AliRsnAnalysisMonitorTask::AliRsnAnalysisMonitorTask(const AliRsnAnalysisMonitorTask& copy) : | |
61 | AliAnalysisTaskSE(copy), | |
6aecf4fd | 62 | fOut(0x0), |
e8d3678d | 63 | fTrack(0x0), |
6aecf4fd | 64 | fESDpid(0x0), |
65 | fTOFmaker(0x0), | |
66 | fTOFcalib(0x0), | |
67 | fTOFcalibrateESD(kFALSE), | |
68 | fTOFcorrectTExp(kFALSE), | |
69 | fTOFuseT0(kFALSE), | |
70 | fTOFtuneMC(kFALSE), | |
69fbb331 | 71 | fTOFresolution(0.0), |
72 | fEventCuts(copy.fEventCuts), | |
73 | fTrackCuts(copy.fTrackCuts) | |
6aecf4fd | 74 | { |
75 | // | |
76 | // Copy constructor | |
77 | // | |
78 | } | |
79 | ||
80 | //__________________________________________________________________________________________________ | |
81 | AliRsnAnalysisMonitorTask& AliRsnAnalysisMonitorTask::operator=(const AliRsnAnalysisMonitorTask& copy) | |
82 | { | |
83 | // | |
84 | // Assignment operator | |
85 | // | |
86 | ||
6aecf4fd | 87 | fTOFcalibrateESD = copy.fTOFcalibrateESD; |
88 | fTOFcorrectTExp = copy.fTOFcorrectTExp; | |
89 | fTOFuseT0 = copy.fTOFuseT0; | |
90 | fTOFtuneMC = copy.fTOFtuneMC; | |
91 | fTOFresolution = copy.fTOFresolution; | |
92 | ||
93 | return (*this); | |
94 | } | |
95 | ||
96 | //__________________________________________________________________________________________________ | |
97 | AliRsnAnalysisMonitorTask::~AliRsnAnalysisMonitorTask() | |
98 | { | |
99 | // | |
100 | // Destructor | |
101 | // | |
102 | ||
103 | if (fOut) delete fOut; | |
104 | if (fESDpid) delete fESDpid; | |
e8d3678d | 105 | if (fTrack) delete fTrack; |
6aecf4fd | 106 | } |
107 | ||
108 | //__________________________________________________________________________________________________ | |
109 | void AliRsnAnalysisMonitorTask::UserCreateOutputObjects() | |
110 | { | |
111 | // | |
112 | // Create the output data container | |
113 | // | |
114 | ||
115 | // setup TPC response | |
116 | fESDpid = new AliESDpid; | |
117 | fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0], fTPCpar[1], fTPCpar[2], fTPCpar[3], fTPCpar[4]); | |
118 | ||
119 | // setup TOF maker & calibration | |
120 | fTOFcalib = new AliTOFcalib; | |
121 | fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib); | |
122 | fTOFmaker->SetTimeResolution(fTOFresolution); | |
123 | ||
e8d3678d | 124 | // create output branch object |
125 | fTrack = new AliRsnMonitorTrack; | |
126 | ||
6aecf4fd | 127 | // create output tree |
128 | OpenFile(1); | |
129 | fOut = new TTree("rsnMonitor", "Informations on single tracks for cut checking"); | |
e8d3678d | 130 | fOut->Branch("tracks", "AliRsnMonitorTrack", &fTrack); |
6aecf4fd | 131 | } |
132 | ||
133 | //__________________________________________________________________________________________________ | |
134 | void AliRsnAnalysisMonitorTask::UserExec(Option_t *) | |
135 | { | |
136 | // | |
137 | // Main execution function. | |
138 | // Fills the fHEvents data member with the following legenda: | |
139 | // 0 -- event OK, prim vertex with tracks | |
140 | // 1 -- event OK, prim vertex with SPD | |
141 | // 2 -- event OK but vz large | |
142 | // 3 -- event bad | |
143 | // | |
144 | ||
6aecf4fd | 145 | // retrieve ESD event and related stack (if available) |
146 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fInputEvent); | |
96e9d35d | 147 | AliStack *stack = 0x0; |
148 | ||
149 | // skip NULL events | |
150 | if (!esd) return; | |
151 | if (fMCEvent) stack = fMCEvent->Stack(); | |
6aecf4fd | 152 | |
e8d3678d | 153 | // create interface objects to AliRsnEvent to check event cuts |
154 | AliRsnEvent event; | |
a378358c | 155 | event.SetRef(esd); |
156 | event.SetRefMC(fMCEvent); | |
e8d3678d | 157 | if (!fEventCuts.IsSelected(&event)) return; |
158 | ||
6aecf4fd | 159 | // check the event |
e8d3678d | 160 | Int_t type = EventEval(esd); |
6aecf4fd | 161 | |
162 | // if processable, then process it | |
e8d3678d | 163 | if (type == 0) ProcessESD(esd, esd->GetPrimaryVertexTracks(), stack); |
164 | else if (type == 1) ProcessESD(esd, esd->GetPrimaryVertexSPD() , stack); | |
165 | else return; | |
6aecf4fd | 166 | |
167 | // update histogram container | |
168 | PostData(1, fOut); | |
169 | } | |
170 | ||
171 | //__________________________________________________________________________________________________ | |
172 | void AliRsnAnalysisMonitorTask::Terminate(Option_t *) | |
173 | { | |
174 | // | |
175 | // Terminate | |
176 | // | |
177 | } | |
178 | ||
179 | //__________________________________________________________________________________________________ | |
e8d3678d | 180 | Int_t AliRsnAnalysisMonitorTask::EventEval(AliESDEvent *esd) |
6aecf4fd | 181 | { |
182 | // | |
183 | // Checks if the event is good for analysis. | |
e8d3678d | 184 | // Returns: |
6aecf4fd | 185 | // ---> 0 if a good primary vertex with tracks was found, |
186 | // ---> 1 if a good SPD primary vertex was found | |
187 | // ---> 2 otherwise (event to be rejected) | |
188 | // In any case, adds an entry to the TTree, to keep trace of all events. | |
189 | // | |
6aecf4fd | 190 | |
191 | // get the best primary vertex: | |
192 | // first try that with tracks, then the SPD one | |
193 | const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks(); | |
194 | const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD(); | |
195 | if(vTrk->GetNContributors() > 0) | |
196 | { | |
e8d3678d | 197 | return 0; |
6aecf4fd | 198 | } |
199 | else if (vSPD->GetNContributors() > 0) | |
200 | { | |
e8d3678d | 201 | return 1; |
6aecf4fd | 202 | } |
203 | else | |
204 | { | |
e8d3678d | 205 | return 2; |
6aecf4fd | 206 | } |
207 | } | |
208 | ||
209 | //__________________________________________________________________________________________________ | |
210 | void AliRsnAnalysisMonitorTask::ProcessESD | |
211 | (AliESDEvent *esd, const AliESDVertex *v, AliStack *stack) | |
212 | { | |
213 | // | |
214 | // Process the ESD container, to read all tracks and copy their useful values. | |
215 | // All info are stored into an AliRsnMonitorTrack object and saved into the | |
216 | // TClonesArray which is one of the branches of the output TTree. | |
217 | // | |
218 | ||
69fbb331 | 219 | // create interfacr objects |
220 | AliRsnEvent event; | |
221 | AliRsnDaughter daughter; | |
a378358c | 222 | event.SetRef(esd); |
223 | event.SetRefMC(fMCEvent); | |
6aecf4fd | 224 | |
225 | // ITS stuff #1 | |
226 | // create the response function and initialize it to MC or not | |
227 | // depending if the AliStack object is there or not | |
228 | Bool_t isMC = (stack != 0x0); | |
229 | AliITSPIDResponse itsrsp(isMC); | |
230 | ||
231 | // TOF stuff #1: init OCDB | |
232 | Int_t run = esd->GetRunNumber(); | |
233 | AliCDBManager *cdb = AliCDBManager::Instance(); | |
234 | cdb->SetDefaultStorage("raw://"); | |
235 | cdb->SetRun(run); | |
236 | // TOF stuff #2: init calibration | |
237 | fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); | |
238 | fTOFcalib->Init(); | |
239 | // TOF stuff #3: calibrate | |
240 | if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(esd); | |
241 | if (fTOFtuneMC) fTOFmaker->TuneForMC(esd); | |
242 | if (fTOFuseT0) | |
243 | { | |
244 | fTOFmaker->ComputeT0TOF(esd); | |
245 | fTOFmaker->ApplyT0TOF(esd); | |
246 | fESDpid->MakePID(esd, kFALSE, 0.); | |
247 | } | |
6aecf4fd | 248 | |
249 | // loop on all tracks | |
e8d3678d | 250 | Int_t i, k, nITS, ntracks = esd->GetNumberOfTracks();; |
251 | Bool_t isTPC, isITSSA, isTOF; | |
6aecf4fd | 252 | Float_t b[2], bCov[3]; |
e8d3678d | 253 | Double_t time[10]; |
6aecf4fd | 254 | |
e8d3678d | 255 | for (i = 0; i < ntracks; i++) |
6aecf4fd | 256 | { |
257 | AliESDtrack *track = esd->GetTrack(i); | |
69fbb331 | 258 | event.SetDaughter(daughter, i, AliRsnDaughter::kTrack); |
6aecf4fd | 259 | |
69fbb331 | 260 | // reset the output object |
261 | // 'usable' flag will need to be set to 'ok' | |
e8d3678d | 262 | fTrack->Reset(); |
69fbb331 | 263 | |
264 | // check cuts | |
e8d3678d | 265 | fTrack->CutsPassed() = fTrackCuts.IsSelected(&daughter); |
69fbb331 | 266 | |
6aecf4fd | 267 | // skip NULL pointers, kink daughters and tracks which |
268 | // cannot be propagated to primary vertex | |
269 | if (!track) continue; | |
270 | if ((Int_t)track->GetKinkIndex(0) > 0) continue; | |
271 | if (!track->RelateToVertex(v, esd->GetMagneticField(), kVeryBig)) continue; | |
272 | ||
19a7d46c | 273 | // get MC info if possible |
e8d3678d | 274 | if (stack) fTrack->AdoptMC(TMath::Abs(track->GetLabel()), stack); |
19a7d46c | 275 | |
6aecf4fd | 276 | // copy general info |
e8d3678d | 277 | fTrack->Status() = (UInt_t)track->GetStatus(); |
278 | fTrack->Length() = (Double_t)track->GetIntegratedLength(); | |
279 | fTrack->Charge() = (Int_t)track->Charge(); | |
280 | fTrack->PrecX() = (Double_t)track->Px(); | |
281 | fTrack->PrecY() = (Double_t)track->Py(); | |
282 | fTrack->PrecZ() = (Double_t)track->Pz(); | |
6aecf4fd | 283 | |
284 | // evaluate some flags from the status to decide what to do next in some points | |
e8d3678d | 285 | isTPC = ((fTrack->Status() & AliESDtrack::kTPCin) != 0); |
286 | isITSSA = ((fTrack->Status() & AliESDtrack::kTPCin) == 0 && (fTrack->Status() & AliESDtrack::kITSrefit) != 0 && (fTrack->Status() & AliESDtrack::kITSpureSA) == 0 && (fTrack->Status() & AliESDtrack::kITSpid) != 0); | |
287 | isTOF = ((fTrack->Status() & AliESDtrack::kTOFout) != 0 && (fTrack->Status() & AliESDtrack::kTIME) != 0); | |
6aecf4fd | 288 | |
289 | // accept only tracks which are TPC+ITS or ITS standalone | |
e8d3678d | 290 | if (isITSSA) |
291 | { | |
292 | fTrack->ITSsa() = kTRUE; | |
293 | fTrack->TOFok() = kFALSE; | |
294 | } | |
295 | else if (isTPC) | |
296 | { | |
297 | fTrack->ITSsa() = kFALSE; | |
298 | fTrack->TOFok() = isTOF; | |
299 | } | |
300 | else | |
301 | continue; | |
6aecf4fd | 302 | |
303 | // get DCA to primary vertex | |
304 | track->GetImpactParameters(b, bCov); | |
e8d3678d | 305 | fTrack->DCAr() = (Double_t)b[0]; |
306 | fTrack->DCAz() = (Double_t)b[1]; | |
6aecf4fd | 307 | |
308 | // get ITS info | |
6bd0f88c | 309 | for (k = 0; k < 6; k++) |
310 | { | |
311 | fTrack->ITSmap(k) = track->HasPointOnITSLayer(k); | |
312 | } | |
e8d3678d | 313 | if (isITSSA) |
6aecf4fd | 314 | { |
e8d3678d | 315 | fTrack->ITSchi2() = track->GetITSchi2(); |
316 | fTrack->ITSsignal() = track->GetITSsignal(); | |
317 | nITS = fTrack->SSDcount() + fTrack->SDDcount(); | |
318 | for (k = 0; k < AliPID::kSPECIES; k++) | |
319 | { | |
320 | fTrack->ITSnsigma(k) = itsrsp.GetNumberOfSigmas(fTrack->Prec(), fTrack->ITSsignal(), (AliPID::EParticleType)k, nITS, kTRUE); | |
321 | } | |
6aecf4fd | 322 | } |
323 | ||
324 | // get TPC info | |
c8ec81d6 | 325 | if (isTPC) |
6aecf4fd | 326 | { |
e8d3678d | 327 | fTrack->TPCcount() = (Int_t)track->GetTPCclusters(0); |
328 | fTrack->TPCchi2() = (Double_t)track->GetTPCchi2(); | |
329 | fTrack->TPCsignal() = (Double_t)track->GetTPCsignal(); | |
330 | fTrack->PtpcX() = fTrack->PtpcY() = fTrack->PtpcZ() = 1E10; | |
c8ec81d6 | 331 | if (track->GetInnerParam()) |
332 | { | |
e8d3678d | 333 | fTrack->PtpcX() = track->GetInnerParam()->Px(); |
334 | fTrack->PtpcY() = track->GetInnerParam()->Py(); | |
335 | fTrack->PtpcZ() = track->GetInnerParam()->Pz(); | |
336 | for (k = 0; k < AliPID::kSPECIES; k++) | |
337 | { | |
338 | fTrack->TPCnsigma(k) = fESDpid->NumberOfSigmasTPC(track, (AliPID::EParticleType)k); | |
339 | } | |
c8ec81d6 | 340 | } |
6aecf4fd | 341 | } |
342 | ||
343 | // get TOF info | |
e8d3678d | 344 | if (isTOF) |
6aecf4fd | 345 | { |
e8d3678d | 346 | track->GetIntegratedTimes(time); |
347 | fTrack->TOFsignal() = (Double_t)track->GetTOFsignal(); | |
348 | for (k = 0; k < AliPID::kSPECIES; k++) | |
349 | { | |
350 | fTrack->TOFref(k) = time[k]; | |
351 | fTrack->TOFsigma(k) = (Double_t)fTOFmaker->GetExpectedSigma(fTrack->Prec(), time[k], AliPID::ParticleMass(k)); | |
352 | } | |
6aecf4fd | 353 | } |
354 | ||
e8d3678d | 355 | // add entry to TTree |
356 | fOut->Fill(); | |
6aecf4fd | 357 | } |
358 | } |