]>
Commit | Line | Data |
---|---|---|
0f67a57c | 1 | /* $Id$ */ |
2 | ||
3 | #include "AlidNdEtaCorrectionTask.h" | |
4 | ||
54b096ef | 5 | #include <TROOT.h> |
0f67a57c | 6 | #include <TCanvas.h> |
7 | #include <TChain.h> | |
8 | #include <TFile.h> | |
9 | #include <TH1F.h> | |
54b096ef | 10 | #include <TH2F.h> |
11 | #include <TProfile.h> | |
0f67a57c | 12 | #include <TParticle.h> |
13 | ||
14 | #include <AliLog.h> | |
15 | #include <AliESDVertex.h> | |
16 | #include <AliESDEvent.h> | |
17 | #include <AliStack.h> | |
18 | #include <AliHeader.h> | |
19 | #include <AliGenEventHeader.h> | |
20 | #include <AliMultiplicity.h> | |
21 | #include <AliAnalysisManager.h> | |
22 | #include <AliMCEventHandler.h> | |
23 | #include <AliMCEvent.h> | |
24 | #include <AliESDInputHandler.h> | |
25 | ||
26 | #include "esdTrackCuts/AliESDtrackCuts.h" | |
27 | #include "AliPWG0Helper.h" | |
28 | //#include "AliCorrection.h" | |
29 | //#include "AliCorrectionMatrix3D.h" | |
30 | #include "dNdEta/dNdEtaAnalysis.h" | |
31 | #include "dNdEta/AlidNdEtaCorrection.h" | |
54b096ef | 32 | #include "AliVertexerTracks.h" |
0f67a57c | 33 | |
34 | ClassImp(AlidNdEtaCorrectionTask) | |
35 | ||
36 | AlidNdEtaCorrectionTask::AlidNdEtaCorrectionTask(const char* opt) : | |
37 | AliAnalysisTask("AlidNdEtaCorrectionTask", ""), | |
38 | fESD(0), | |
39 | fOutput(0), | |
40 | fOption(opt), | |
770a1f1d | 41 | fAnalysisMode(AliPWG0Helper::kTPC), |
0fc41645 | 42 | fTrigger(AliPWG0Helper::kMB1), |
0f67a57c | 43 | fSignMode(0), |
3d7758c1 | 44 | fOnlyPrimaries(kFALSE), |
0f67a57c | 45 | fEsdTrackCuts(0), |
46 | fdNdEtaCorrection(0), | |
47 | fdNdEtaAnalysisMC(0), | |
48 | fdNdEtaAnalysisESD(0), | |
49 | fPIDParticles(0), | |
96fcc8a7 | 50 | fPIDTracks(0), |
54b096ef | 51 | fVertexCorrelation(0), |
52 | fVertexProfile(0), | |
53 | fVertexShiftNorm(0), | |
3d7758c1 | 54 | fEtaCorrelation(0), |
55 | fEtaProfile(0), | |
96fcc8a7 | 56 | fSigmaVertexTracks(0), |
4ef701a0 | 57 | fSigmaVertexPrim(0), |
58 | fMultAll(0), | |
59 | fMultTr(0), | |
50ec344d | 60 | fMultVtx(0), |
61 | fEventStats(0) | |
0f67a57c | 62 | { |
63 | // | |
64 | // Constructor. Initialization of pointers | |
65 | // | |
66 | ||
67 | // Define input and output slots here | |
68 | DefineInput(0, TChain::Class()); | |
69 | DefineOutput(0, TList::Class()); | |
96fcc8a7 | 70 | |
71 | for (Int_t i=0; i<2; i++) | |
72 | fdNdEtaCorrectionProcessType[i] = 0; | |
4ef701a0 | 73 | |
3d7758c1 | 74 | for (Int_t i=0; i<8; i++) |
4ef701a0 | 75 | fDeltaPhi[i] = 0; |
0f67a57c | 76 | } |
77 | ||
78 | AlidNdEtaCorrectionTask::~AlidNdEtaCorrectionTask() | |
79 | { | |
80 | // | |
81 | // Destructor | |
82 | // | |
83 | ||
84 | // histograms are in the output list and deleted when the output | |
85 | // list is deleted by the TSelector dtor | |
86 | ||
87 | if (fOutput) { | |
88 | delete fOutput; | |
89 | fOutput = 0; | |
90 | } | |
91 | } | |
92 | ||
93 | //________________________________________________________________________ | |
94 | void AlidNdEtaCorrectionTask::ConnectInputData(Option_t *) | |
95 | { | |
96 | // Connect ESD | |
97 | // Called once | |
98 | ||
99 | Printf("AlidNdEtaCorrectionTask::ConnectInputData called"); | |
100 | ||
101 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
102 | if (!tree) { | |
103 | Printf("ERROR: Could not read tree from input slot 0"); | |
104 | } else { | |
105 | // Disable all branches and enable only the needed ones | |
96fcc8a7 | 106 | //tree->SetBranchStatus("*", 0); |
0f67a57c | 107 | |
108 | tree->SetBranchStatus("fTriggerMask", 1); | |
109 | tree->SetBranchStatus("fSPDVertex*", 1); | |
770a1f1d | 110 | // PrimaryVertex |
0f67a57c | 111 | |
770a1f1d | 112 | if (fAnalysisMode == AliPWG0Helper::kSPD) |
0f67a57c | 113 | tree->SetBranchStatus("fSPDMult*", 1); |
114 | ||
770a1f1d | 115 | if (fAnalysisMode == AliPWG0Helper::kTPC || fAnalysisMode == AliPWG0Helper::kTPCITS) { |
0f67a57c | 116 | AliESDtrackCuts::EnableNeededBranches(tree); |
117 | tree->SetBranchStatus("fTracks.fLabel", 1); | |
118 | } | |
119 | ||
0f67a57c | 120 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
121 | ||
122 | if (!esdH) { | |
123 | Printf("ERROR: Could not get ESDInputHandler"); | |
124 | } else | |
125 | fESD = esdH->GetEvent(); | |
126 | } | |
96fcc8a7 | 127 | |
128 | // disable info messages of AliMCEvent (per event) | |
129 | AliLog::SetClassDebugLevel("AliMCEvent", AliLog::kWarning - AliLog::kDebug + 1); | |
0f67a57c | 130 | } |
131 | ||
132 | void AlidNdEtaCorrectionTask::CreateOutputObjects() | |
133 | { | |
134 | // create result objects and add to output list | |
135 | ||
136 | if (fOption.Contains("only-positive")) | |
137 | { | |
138 | Printf("INFO: Processing only positive particles."); | |
139 | fSignMode = 1; | |
140 | } | |
141 | else if (fOption.Contains("only-negative")) | |
142 | { | |
143 | Printf("INFO: Processing only negative particles."); | |
144 | fSignMode = -1; | |
145 | } | |
146 | ||
0f67a57c | 147 | fOutput = new TList; |
148 | fOutput->SetOwner(); | |
149 | ||
770a1f1d | 150 | fdNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction", fAnalysisMode); |
0f67a57c | 151 | fOutput->Add(fdNdEtaCorrection); |
152 | ||
153 | fPIDParticles = new TH1F("pid_particles", "PID of generated primary particles", 10001, -5000.5, 5000.5); | |
154 | fOutput->Add(fPIDParticles); | |
155 | ||
156 | fPIDTracks = new TH1F("pid_tracks", "MC PID of reconstructed tracks", 10001, -5000.5, 5000.5); | |
157 | fOutput->Add(fPIDTracks); | |
158 | ||
770a1f1d | 159 | fdNdEtaAnalysisMC = new dNdEtaAnalysis("dndetaMC", "dndetaMC", fAnalysisMode); |
0f67a57c | 160 | fOutput->Add(fdNdEtaAnalysisMC); |
161 | ||
770a1f1d | 162 | fdNdEtaAnalysisESD = new dNdEtaAnalysis("dndetaESD", "dndetaESD", fAnalysisMode); |
0f67a57c | 163 | fOutput->Add(fdNdEtaAnalysisESD); |
96fcc8a7 | 164 | |
165 | if (fOption.Contains("process-types")) { | |
54b096ef | 166 | fdNdEtaCorrectionProcessType[0] = new AlidNdEtaCorrection("dndeta_correction_ND", "dndeta_correction_ND", fAnalysisMode); |
167 | fdNdEtaCorrectionProcessType[1] = new AlidNdEtaCorrection("dndeta_correction_SD", "dndeta_correction_SD", fAnalysisMode); | |
168 | fdNdEtaCorrectionProcessType[2] = new AlidNdEtaCorrection("dndeta_correction_DD", "dndeta_correction_DD", fAnalysisMode); | |
96fcc8a7 | 169 | |
170 | fOutput->Add(fdNdEtaCorrectionProcessType[0]); | |
171 | fOutput->Add(fdNdEtaCorrectionProcessType[1]); | |
172 | fOutput->Add(fdNdEtaCorrectionProcessType[2]); | |
173 | } | |
174 | ||
175 | if (fOption.Contains("sigma-vertex")) | |
176 | { | |
177 | fSigmaVertexTracks = new TH1F("fSigmaVertexTracks", "fSigmaVertexTracks;Nsigma2vertex;NacceptedTracks", 60, 0.05, 6.05); | |
178 | fSigmaVertexPrim = new TH1F("fSigmaVertexPrim", "fSigmaVertexPrim;Nsigma2vertex;NacceptedPrimaries", 60, 0.05, 6.05); | |
179 | fOutput->Add(fSigmaVertexTracks); | |
180 | fOutput->Add(fSigmaVertexPrim); | |
181 | Printf("WARNING: sigma-vertex analysis enabled. This will produce weird results in the AliESDtrackCuts histograms"); | |
182 | } | |
54b096ef | 183 | |
0fc41645 | 184 | fVertexCorrelation = new TH2F("fVertexCorrelation", "fVertexCorrelation;MC z-vtx;ESD z-vtx", 120, -30, 30, 120, -30, 30); |
185 | fOutput->Add(fVertexCorrelation); | |
54b096ef | 186 | fVertexProfile = new TProfile("fVertexProfile", "fVertexProfile;MC z-vtx;MC z-vtx - ESD z-vtx", 40, -20, 20); |
0fc41645 | 187 | fOutput->Add(fVertexProfile); |
54b096ef | 188 | fVertexShiftNorm = new TH1F("fVertexShiftNorm", "fVertexShiftNorm;(MC z-vtx - ESD z-vtx) / #sigma_{ESD z-vtx};Entries", 200, -100, 100); |
0fc41645 | 189 | fOutput->Add(fVertexShiftNorm); |
190 | ||
3d7758c1 | 191 | fEtaCorrelation = new TH2F("fEtaCorrelation", "fEtaCorrelation;MC #eta;ESD #eta", 120, -3, 3, 120, -3, 3); |
0fc41645 | 192 | fOutput->Add(fEtaCorrelation); |
3d7758c1 | 193 | fEtaProfile = new TProfile("fEtaProfile", "fEtaProfile;MC #eta;MC #eta - ESD #eta", 120, -3, 3); |
0fc41645 | 194 | fOutput->Add(fEtaProfile); |
3d7758c1 | 195 | |
4ef701a0 | 196 | fMultAll = new TH1F("fMultAll", "fMultAll", 500, -0.5, 499.5); |
0fc41645 | 197 | fOutput->Add(fMultAll); |
4ef701a0 | 198 | fMultVtx = new TH1F("fMultVtx", "fMultVtx", 500, -0.5, 499.5); |
0fc41645 | 199 | fOutput->Add(fMultVtx); |
4ef701a0 | 200 | fMultTr = new TH1F("fMultTr", "fMultTr", 500, -0.5, 499.5); |
0fc41645 | 201 | fOutput->Add(fMultTr); |
4ef701a0 | 202 | |
3d7758c1 | 203 | for (Int_t i=0; i<8; i++) |
0fc41645 | 204 | { |
3d7758c1 | 205 | fDeltaPhi[i] = new TH1F(Form("fDeltaPhi_%d", i), ";#Delta phi;Entries", 2000, -0.1, 0.1); |
0fc41645 | 206 | fOutput->Add(fDeltaPhi[i]); |
207 | } | |
50ec344d | 208 | |
209 | fEventStats = new TH2F("fEventStats", "fEventStats;event type;status;count", 2, -0.5, 1.5, 4, -0.5, 3.5); | |
0fc41645 | 210 | fOutput->Add(fEventStats); |
50ec344d | 211 | fEventStats->GetXaxis()->SetBinLabel(1, "INEL"); |
212 | fEventStats->GetXaxis()->SetBinLabel(2, "NSD"); | |
213 | ||
214 | fEventStats->GetYaxis()->SetBinLabel(1, "nothing"); | |
215 | fEventStats->GetYaxis()->SetBinLabel(2, "trg"); | |
216 | fEventStats->GetYaxis()->SetBinLabel(3, "vtx"); | |
217 | fEventStats->GetYaxis()->SetBinLabel(4, "trgvtx"); | |
0f67a57c | 218 | } |
219 | ||
220 | void AlidNdEtaCorrectionTask::Exec(Option_t*) | |
221 | { | |
222 | // process the event | |
223 | ||
224 | // Check prerequisites | |
225 | if (!fESD) | |
226 | { | |
227 | AliDebug(AliLog::kError, "ESD branch not available"); | |
228 | return; | |
229 | } | |
230 | ||
3d7758c1 | 231 | if (fOnlyPrimaries) |
232 | Printf("WARNING: Processing only primaries. For systematical studies only!"); | |
233 | ||
0f67a57c | 234 | // trigger definition |
0fc41645 | 235 | Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD->GetTriggerMask(), fTrigger); |
54b096ef | 236 | |
3d7758c1 | 237 | if (!eventTriggered) |
238 | Printf("No trigger"); | |
239 | ||
54b096ef | 240 | // post the data already here |
241 | PostData(0, fOutput); | |
242 | ||
243 | // MC info | |
244 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
245 | if (!eventHandler) { | |
246 | Printf("ERROR: Could not retrieve MC event handler"); | |
247 | return; | |
248 | } | |
249 | ||
250 | AliMCEvent* mcEvent = eventHandler->MCEvent(); | |
251 | if (!mcEvent) { | |
252 | Printf("ERROR: Could not retrieve MC event"); | |
253 | return; | |
254 | } | |
255 | ||
256 | AliStack* stack = mcEvent->Stack(); | |
257 | if (!stack) | |
258 | { | |
259 | AliDebug(AliLog::kError, "Stack not available"); | |
260 | return; | |
261 | } | |
262 | ||
263 | AliHeader* header = mcEvent->Header(); | |
264 | if (!header) | |
265 | { | |
266 | AliDebug(AliLog::kError, "Header not available"); | |
267 | return; | |
268 | } | |
269 | ||
270 | // get process type; NB: this only works for Pythia | |
271 | Int_t processType = AliPWG0Helper::GetPythiaEventProcessType(header); | |
272 | AliDebug(AliLog::kDebug+1, Form("Found pythia process type %d", processType)); | |
273 | ||
274 | if (processType<0) | |
275 | AliDebug(AliLog::kError, Form("Unknown Pythia process type %d.", processType)); | |
276 | ||
277 | // get the MC vertex | |
278 | AliGenEventHeader* genHeader = header->GenEventHeader(); | |
279 | TArrayF vtxMC(3); | |
280 | genHeader->PrimaryVertex(vtxMC); | |
281 | ||
282 | // get the ESD vertex | |
283 | const AliESDVertex* vtxESD = AliPWG0Helper::GetVertex(fESD, fAnalysisMode); | |
0f67a57c | 284 | |
770a1f1d | 285 | Bool_t eventVertex = kFALSE; |
54b096ef | 286 | Double_t vtx[3]; |
287 | if (vtxESD) | |
288 | { | |
289 | vtxESD->GetXYZ(vtx); | |
770a1f1d | 290 | eventVertex = kTRUE; |
54b096ef | 291 | |
292 | Double_t diff = vtxMC[2] - vtx[2]; | |
293 | if (vtxESD->GetZRes() > 0) | |
294 | fVertexShiftNorm->Fill(diff / vtxESD->GetZRes()); | |
295 | } | |
296 | else | |
297 | Printf("No vertex found"); | |
0f67a57c | 298 | |
50ec344d | 299 | // fill process type |
300 | Int_t biny = (Int_t) eventTriggered + 2 * (Int_t) eventVertex; | |
301 | // INEL | |
302 | fEventStats->Fill(0.0, biny); | |
303 | // NDS | |
304 | if (processType != 92 && processType != 93) | |
305 | fEventStats->Fill(1.0, biny); | |
306 | ||
0f67a57c | 307 | // create list of (label, eta, pt) tuples |
308 | Int_t inputCount = 0; | |
309 | Int_t* labelArr = 0; | |
3d7758c1 | 310 | Int_t* labelArr2 = 0; // only for case of SPD |
0f67a57c | 311 | Float_t* etaArr = 0; |
312 | Float_t* ptArr = 0; | |
4ef701a0 | 313 | Float_t* deltaPhiArr = 0; |
770a1f1d | 314 | if (fAnalysisMode == AliPWG0Helper::kSPD) |
0f67a57c | 315 | { |
316 | // get tracklets | |
317 | const AliMultiplicity* mult = fESD->GetMultiplicity(); | |
318 | if (!mult) | |
319 | { | |
320 | AliDebug(AliLog::kError, "AliMultiplicity not available"); | |
321 | return; | |
322 | } | |
323 | ||
324 | labelArr = new Int_t[mult->GetNumberOfTracklets()]; | |
3d7758c1 | 325 | labelArr2 = new Int_t[mult->GetNumberOfTracklets()]; |
0f67a57c | 326 | etaArr = new Float_t[mult->GetNumberOfTracklets()]; |
327 | ptArr = new Float_t[mult->GetNumberOfTracklets()]; | |
4ef701a0 | 328 | deltaPhiArr = new Float_t[mult->GetNumberOfTracklets()]; |
0f67a57c | 329 | |
330 | // get multiplicity from ITS tracklets | |
331 | for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i) | |
332 | { | |
333 | //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i)); | |
334 | ||
4ef701a0 | 335 | Float_t deltaPhi = mult->GetDeltaPhi(i); |
336 | // prevent values to be shifted by 2 Pi() | |
337 | if (deltaPhi < -TMath::Pi()) | |
338 | deltaPhi += TMath::Pi() * 2; | |
339 | if (deltaPhi > TMath::Pi()) | |
340 | deltaPhi -= TMath::Pi() * 2; | |
341 | ||
342 | if (TMath::Abs(deltaPhi) > 1) | |
343 | printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi); | |
0f67a57c | 344 | |
3d7758c1 | 345 | if (fOnlyPrimaries) |
346 | if (mult->GetLabel(i, 0) < 0 || mult->GetLabel(i, 0) != mult->GetLabel(i, 1) || !stack->IsPhysicalPrimary(mult->GetLabel(i, 0))) | |
347 | continue; | |
348 | ||
0f67a57c | 349 | etaArr[inputCount] = mult->GetEta(i); |
3d7758c1 | 350 | labelArr[inputCount] = mult->GetLabel(i, 0); |
351 | labelArr2[inputCount] = mult->GetLabel(i, 1); | |
0f67a57c | 352 | ptArr[inputCount] = 0; // no pt for tracklets |
4ef701a0 | 353 | deltaPhiArr[inputCount] = deltaPhi; |
0f67a57c | 354 | ++inputCount; |
355 | } | |
356 | } | |
770a1f1d | 357 | else if (fAnalysisMode == AliPWG0Helper::kTPC || fAnalysisMode == AliPWG0Helper::kTPCITS) |
0f67a57c | 358 | { |
359 | if (!fEsdTrackCuts) | |
360 | { | |
361 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
362 | return; | |
363 | } | |
364 | ||
365 | // get multiplicity from ESD tracks | |
366 | TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD); | |
367 | Int_t nGoodTracks = list->GetEntries(); | |
368 | ||
54b096ef | 369 | Printf("Accepted %d tracks", nGoodTracks); |
370 | ||
0f67a57c | 371 | labelArr = new Int_t[nGoodTracks]; |
3d7758c1 | 372 | labelArr2 = new Int_t[nGoodTracks]; |
0f67a57c | 373 | etaArr = new Float_t[nGoodTracks]; |
374 | ptArr = new Float_t[nGoodTracks]; | |
4ef701a0 | 375 | deltaPhiArr = new Float_t[nGoodTracks]; |
0f67a57c | 376 | |
377 | // loop over esd tracks | |
378 | for (Int_t i=0; i<nGoodTracks; i++) | |
379 | { | |
380 | AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(i)); | |
381 | if (!esdTrack) | |
382 | { | |
383 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", i)); | |
384 | continue; | |
385 | } | |
386 | ||
387 | etaArr[inputCount] = esdTrack->Eta(); | |
388 | labelArr[inputCount] = TMath::Abs(esdTrack->GetLabel()); | |
3d7758c1 | 389 | labelArr2[inputCount] = labelArr[inputCount]; // no second label for tracks |
0f67a57c | 390 | ptArr[inputCount] = esdTrack->Pt(); |
4ef701a0 | 391 | deltaPhiArr[inputCount] = 0; // no delta phi for tracks |
0f67a57c | 392 | ++inputCount; |
393 | } | |
0f67a57c | 394 | |
54b096ef | 395 | delete list; |
0f67a57c | 396 | } |
54b096ef | 397 | else |
0f67a57c | 398 | return; |
0f67a57c | 399 | |
54b096ef | 400 | if (eventTriggered && eventVertex) |
0f67a57c | 401 | { |
54b096ef | 402 | fVertexCorrelation->Fill(vtxMC[2], vtx[2]); |
403 | fVertexProfile->Fill(vtxMC[2], vtxMC[2] - vtx[2]); | |
0f67a57c | 404 | } |
405 | ||
0f67a57c | 406 | |
407 | // loop over mc particles | |
408 | Int_t nPrim = stack->GetNprimary(); | |
4ef701a0 | 409 | Int_t nAccepted = 0; |
0f67a57c | 410 | |
411 | for (Int_t iMc = 0; iMc < nPrim; ++iMc) | |
412 | { | |
413 | //Printf("Getting particle %d", iMc); | |
414 | TParticle* particle = stack->Particle(iMc); | |
415 | ||
416 | if (!particle) | |
417 | continue; | |
418 | ||
419 | if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE) | |
420 | continue; | |
421 | ||
422 | if (SignOK(particle->GetPDG()) == kFALSE) | |
423 | continue; | |
424 | ||
425 | Float_t eta = particle->Eta(); | |
426 | Float_t pt = particle->Pt(); | |
427 | ||
428 | fdNdEtaCorrection->FillMCParticle(vtxMC[2], eta, pt, eventTriggered, eventVertex, processType); | |
429 | ||
96fcc8a7 | 430 | if (fdNdEtaCorrectionProcessType[0]) |
431 | { | |
432 | // non diffractive | |
433 | if (processType!=92 && processType!=93 && processType!=94) | |
434 | fdNdEtaCorrectionProcessType[0]->FillMCParticle(vtxMC[2], eta, pt, eventTriggered, eventVertex, processType); | |
435 | ||
436 | // single diffractive | |
437 | if (processType==92 || processType==93) | |
438 | fdNdEtaCorrectionProcessType[1]->FillMCParticle(vtxMC[2], eta, pt, eventTriggered, eventVertex, processType); | |
439 | ||
440 | // double diffractive | |
441 | if (processType==94) | |
442 | fdNdEtaCorrectionProcessType[2]->FillMCParticle(vtxMC[2], eta, pt, eventTriggered, eventVertex, processType); | |
443 | } | |
444 | ||
0f67a57c | 445 | if (eventTriggered) |
446 | if (eventVertex) | |
447 | fdNdEtaAnalysisMC->FillTrack(vtxMC[2], eta, pt); | |
4ef701a0 | 448 | |
0fc41645 | 449 | // TODO this value might be needed lower for the SPD study (only used for control histograms anyway) |
4ef701a0 | 450 | if (TMath::Abs(eta) < 1 && pt > 0.2) |
451 | nAccepted++; | |
452 | } | |
453 | ||
454 | fMultAll->Fill(nAccepted); | |
455 | if (eventTriggered) { | |
456 | fMultTr->Fill(nAccepted); | |
457 | if (eventVertex) | |
458 | fMultVtx->Fill(nAccepted); | |
0f67a57c | 459 | } |
460 | ||
3d7758c1 | 461 | Int_t processed = 0; |
462 | ||
0f67a57c | 463 | for (Int_t i=0; i<inputCount; ++i) |
464 | { | |
465 | Int_t label = labelArr[i]; | |
3d7758c1 | 466 | Int_t label2 = labelArr2[i]; |
0f67a57c | 467 | |
468 | if (label < 0) | |
469 | { | |
0fc41645 | 470 | Printf("WARNING: cannot find corresponding mc particle for track(let) %d with label %d.", i, label); |
0f67a57c | 471 | continue; |
472 | } | |
473 | ||
474 | TParticle* particle = stack->Particle(label); | |
475 | if (!particle) | |
476 | { | |
477 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label)); | |
478 | continue; | |
479 | } | |
3d7758c1 | 480 | |
481 | // find particle that is filled in the correction map | |
482 | // this should be the particle that has been reconstructed | |
483 | // for TPC this is clear and always identified by the track's label | |
484 | // for SPD the labels might not be identical. In this case the particle closest to the beam line that is a primary is taken: | |
485 | // L1 L2 (P = primary, S = secondary) | |
486 | // P P' : --> P | |
487 | // P S : --> P | |
488 | // S P : --> P | |
489 | // S S' : --> S | |
490 | ||
491 | if (label != label2 && label2 >= 0) | |
492 | { | |
493 | if (stack->IsPhysicalPrimary(label) == kFALSE && stack->IsPhysicalPrimary(label2)) | |
494 | { | |
495 | particle = stack->Particle(label2); | |
496 | if (!particle) | |
497 | { | |
498 | AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label2)); | |
499 | continue; | |
500 | } | |
501 | } | |
502 | } | |
0f67a57c | 503 | |
504 | if (eventTriggered && eventVertex) | |
505 | { | |
3d7758c1 | 506 | if (SignOK(particle->GetPDG()) == kFALSE) |
507 | continue; | |
508 | ||
509 | processed++; | |
510 | ||
511 | Bool_t firstIsPrim = stack->IsPhysicalPrimary(label); | |
512 | // in case of primary the MC values are filled, otherwise (background) the reconstructed values | |
513 | if (label == label2 && firstIsPrim) | |
514 | { | |
515 | fdNdEtaCorrection->FillTrackedParticle(vtxMC[2], particle->Eta(), particle->Pt()); | |
516 | } | |
517 | else | |
518 | { | |
519 | fdNdEtaCorrection->FillTrackedParticle(vtxMC[2], etaArr[i], ptArr[i]); | |
520 | fEtaProfile->Fill(particle->Eta(), particle->Eta() - etaArr[i]); | |
521 | } | |
522 | ||
0f67a57c | 523 | fdNdEtaAnalysisESD->FillTrack(vtxMC[2], particle->Eta(), particle->Pt()); |
3d7758c1 | 524 | |
525 | fEtaCorrelation->Fill(etaArr[i], particle->Eta()); | |
526 | ||
0f67a57c | 527 | if (particle->Pt() > 0.1 && particle->Pt() < 0.2) |
528 | { | |
529 | fPIDTracks->Fill(particle->GetPdgCode()); | |
530 | } | |
96fcc8a7 | 531 | |
532 | if (fdNdEtaCorrectionProcessType[0]) | |
533 | { | |
534 | // non diffractive | |
535 | if (processType!=92 && processType!=93 && processType!=94) | |
536 | fdNdEtaCorrectionProcessType[0]->FillTrackedParticle(vtxMC[2], particle->Eta(), particle->Pt()); | |
537 | ||
538 | // single diffractive | |
539 | if (processType==92 || processType==93) | |
540 | fdNdEtaCorrectionProcessType[1]->FillTrackedParticle(vtxMC[2], particle->Eta(), particle->Pt()); | |
541 | ||
542 | // double diffractive | |
543 | if (processType==94) | |
544 | fdNdEtaCorrectionProcessType[2]->FillTrackedParticle(vtxMC[2], particle->Eta(), particle->Pt()); | |
545 | } | |
4ef701a0 | 546 | |
3d7758c1 | 547 | Int_t hist = -1; |
548 | if (label == label2) | |
4ef701a0 | 549 | { |
3d7758c1 | 550 | if (firstIsPrim) |
551 | { | |
552 | hist = 0; | |
553 | } | |
554 | else | |
555 | hist = 1; | |
556 | } | |
557 | else if (label2 >= 0) | |
558 | { | |
559 | Bool_t secondIsPrim = stack->IsPhysicalPrimary(label2); | |
560 | if (firstIsPrim && secondIsPrim) | |
561 | { | |
562 | hist = 2; | |
563 | } | |
564 | else if (firstIsPrim && !secondIsPrim) | |
565 | { | |
566 | hist = 3; | |
567 | ||
568 | // check if secondary is caused by the primary or it is a fake combination | |
569 | //Printf("PS case --> Label 1 is %d, label 2 is %d", label, label2); | |
570 | Int_t mother = label2; | |
571 | while (stack->Particle(mother) && stack->Particle(mother)->GetMother(0) >= 0) | |
572 | { | |
573 | //Printf(" %d created by %d, %d", mother, stack->Particle(mother)->GetMother(0), stack->Particle(mother)->GetMother(1)); | |
574 | if (stack->Particle(mother)->GetMother(0) == label) | |
575 | { | |
576 | /*Printf("The untraceable decay was:"); | |
577 | Printf(" from:"); | |
578 | particle->Print(); | |
579 | Printf(" to (status code %d):", stack->Particle(mother)->GetStatusCode()); | |
580 | stack->Particle(mother)->Print();*/ | |
581 | hist = 4; | |
582 | } | |
583 | mother = stack->Particle(mother)->GetMother(0); | |
584 | } | |
585 | } | |
586 | else if (!firstIsPrim && secondIsPrim) | |
587 | { | |
588 | hist = 5; | |
589 | } | |
590 | else if (!firstIsPrim && !secondIsPrim) | |
591 | { | |
592 | hist = 6; | |
593 | } | |
594 | ||
4ef701a0 | 595 | } |
596 | else | |
3d7758c1 | 597 | hist = 7; |
598 | ||
599 | fDeltaPhi[hist]->Fill(deltaPhiArr[i]); | |
0f67a57c | 600 | } |
601 | } | |
602 | ||
3d7758c1 | 603 | if (processed < inputCount) |
604 | Printf("Only %d out of %d track(let)s were used", processed, inputCount); | |
605 | ||
0f67a57c | 606 | if (eventTriggered && eventVertex) |
96fcc8a7 | 607 | { |
0f67a57c | 608 | fdNdEtaAnalysisMC->FillEvent(vtxMC[2], inputCount); |
96fcc8a7 | 609 | fdNdEtaAnalysisESD->FillEvent(vtxMC[2], inputCount); |
610 | } | |
0f67a57c | 611 | |
96fcc8a7 | 612 | // stuff regarding the vertex reco correction and trigger bias correction |
0f67a57c | 613 | fdNdEtaCorrection->FillEvent(vtxMC[2], inputCount, eventTriggered, eventVertex, processType); |
96fcc8a7 | 614 | |
615 | if (fdNdEtaCorrectionProcessType[0]) | |
616 | { | |
617 | // non diffractive | |
618 | if (processType!=92 && processType!=93 && processType!=94) | |
619 | fdNdEtaCorrectionProcessType[0]->FillEvent(vtxMC[2], inputCount, eventTriggered, eventVertex, processType); | |
620 | ||
621 | // single diffractive | |
622 | if (processType==92 || processType==93) | |
623 | fdNdEtaCorrectionProcessType[1]->FillEvent(vtxMC[2], inputCount, eventTriggered, eventVertex, processType); | |
624 | ||
625 | // double diffractive | |
626 | if (processType==94) | |
627 | fdNdEtaCorrectionProcessType[2]->FillEvent(vtxMC[2], inputCount, eventTriggered, eventVertex, processType); | |
0f67a57c | 628 | } |
629 | ||
630 | delete[] etaArr; | |
631 | delete[] labelArr; | |
3d7758c1 | 632 | delete[] labelArr2; |
0f67a57c | 633 | delete[] ptArr; |
4ef701a0 | 634 | delete[] deltaPhiArr; |
96fcc8a7 | 635 | |
636 | // fills the fSigmaVertex histogram (systematic study) | |
637 | if (fSigmaVertexTracks) | |
638 | { | |
639 | // save the old value | |
640 | Float_t oldSigmaVertex = fEsdTrackCuts->GetMinNsigmaToVertex(); | |
641 | ||
642 | // set to maximum | |
643 | fEsdTrackCuts->SetMinNsigmaToVertex(6); | |
644 | ||
645 | TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD); | |
646 | Int_t nGoodTracks = list->GetEntries(); | |
647 | ||
648 | // loop over esd tracks | |
649 | for (Int_t i=0; i<nGoodTracks; i++) | |
650 | { | |
651 | AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(i)); | |
652 | if (!esdTrack) | |
653 | { | |
654 | AliError(Form("ERROR: Could not retrieve track %d.", i)); | |
655 | continue; | |
656 | } | |
657 | ||
658 | Float_t sigma2Vertex = fEsdTrackCuts->GetSigmaToVertex(esdTrack); | |
659 | ||
660 | for (Double_t nSigma = 0.1; nSigma < 6.05; nSigma += 0.1) | |
661 | { | |
662 | if (sigma2Vertex < nSigma) | |
663 | { | |
664 | fSigmaVertexTracks->Fill(nSigma); | |
665 | ||
666 | Int_t label = TMath::Abs(esdTrack->GetLabel()); | |
667 | TParticle* particle = stack->Particle(label); | |
668 | if (!particle || label >= nPrim) | |
669 | continue; | |
670 | ||
671 | if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim)) | |
672 | fSigmaVertexPrim->Fill(nSigma); | |
673 | } | |
674 | } | |
675 | } | |
676 | ||
677 | delete list; | |
678 | list = 0; | |
679 | ||
680 | // set back the old value | |
681 | fEsdTrackCuts->SetMinNsigmaToVertex(oldSigmaVertex); | |
682 | } | |
0f67a57c | 683 | } |
684 | ||
685 | void AlidNdEtaCorrectionTask::Terminate(Option_t *) | |
686 | { | |
687 | // The Terminate() function is the last function to be called during | |
688 | // a query. It always runs on the client, it can be used to present | |
689 | // the results graphically or save the results to file. | |
690 | ||
691 | fOutput = dynamic_cast<TList*> (GetOutputData(0)); | |
692 | if (!fOutput) { | |
693 | Printf("ERROR: fOutput not available"); | |
694 | return; | |
695 | } | |
696 | ||
697 | fdNdEtaCorrection = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction")); | |
698 | fdNdEtaAnalysisMC = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndetaMC")); | |
699 | fdNdEtaAnalysisESD = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndetaESD")); | |
700 | if (!fdNdEtaCorrection || !fdNdEtaAnalysisMC || !fdNdEtaAnalysisESD) | |
701 | { | |
702 | AliDebug(AliLog::kError, "Could not read object from output list"); | |
703 | return; | |
704 | } | |
705 | ||
706 | fdNdEtaCorrection->Finish(); | |
707 | ||
708 | TString fileName; | |
709 | fileName.Form("correction_map%s.root", fOption.Data()); | |
710 | TFile* fout = new TFile(fileName, "RECREATE"); | |
711 | ||
712 | if (fEsdTrackCuts) | |
713 | fEsdTrackCuts->SaveHistograms("esd_track_cuts"); | |
714 | fdNdEtaCorrection->SaveHistograms(); | |
715 | fdNdEtaAnalysisMC->SaveHistograms(); | |
716 | fdNdEtaAnalysisESD->SaveHistograms(); | |
717 | ||
96fcc8a7 | 718 | fdNdEtaCorrectionProcessType[0] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_ND")); |
719 | fdNdEtaCorrectionProcessType[1] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_SD")); | |
720 | fdNdEtaCorrectionProcessType[2] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_DD")); | |
721 | for (Int_t i=0; i<3; ++i) | |
722 | if (fdNdEtaCorrectionProcessType[i]) | |
723 | fdNdEtaCorrectionProcessType[i]->SaveHistograms(); | |
724 | ||
725 | fSigmaVertexTracks = dynamic_cast<TH1F*> (fOutput->FindObject("fSigmaVertexTracks")); | |
726 | if (fSigmaVertexTracks) | |
727 | fSigmaVertexTracks->Write(); | |
728 | fSigmaVertexPrim = dynamic_cast<TH1F*> (fOutput->FindObject("fSigmaVertexPrim")); | |
729 | if (fSigmaVertexPrim) | |
730 | fSigmaVertexPrim->Write(); | |
731 | ||
0fc41645 | 732 | fVertexCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fVertexCorrelation")); |
54b096ef | 733 | if (fVertexCorrelation) |
734 | fVertexCorrelation->Write(); | |
0fc41645 | 735 | fVertexProfile = dynamic_cast<TProfile*> (fOutput->FindObject("fVertexProfile")); |
54b096ef | 736 | if (fVertexProfile) |
737 | fVertexProfile->Write(); | |
0fc41645 | 738 | fVertexShiftNorm = dynamic_cast<TH1F*> (fOutput->FindObject("fVertexShiftNorm")); |
54b096ef | 739 | if (fVertexShiftNorm) |
740 | fVertexShiftNorm->Write(); | |
3d7758c1 | 741 | |
0fc41645 | 742 | fEtaCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fEtaCorrelation")); |
3d7758c1 | 743 | if (fEtaCorrelation) |
744 | fEtaCorrelation->Write(); | |
0fc41645 | 745 | fEtaProfile = dynamic_cast<TProfile*> (fOutput->FindObject("fEtaProfile")); |
3d7758c1 | 746 | if (fEtaProfile) |
747 | fEtaProfile->Write(); | |
748 | ||
0fc41645 | 749 | fMultAll = dynamic_cast<TH1F*> (fOutput->FindObject("fMultAll")); |
4ef701a0 | 750 | if (fMultAll) |
751 | fMultAll->Write(); | |
752 | ||
0fc41645 | 753 | fMultTr = dynamic_cast<TH1F*> (fOutput->FindObject("fMultTr")); |
4ef701a0 | 754 | if (fMultTr) |
755 | fMultTr->Write(); | |
0fc41645 | 756 | |
757 | fMultVtx = dynamic_cast<TH1F*> (fOutput->FindObject("fMultVtx")); | |
4ef701a0 | 758 | if (fMultVtx) |
759 | fMultVtx->Write(); | |
760 | ||
3d7758c1 | 761 | for (Int_t i=0; i<8; ++i) |
0fc41645 | 762 | { |
763 | fDeltaPhi[i] = dynamic_cast<TH1F*> (fOutput->FindObject(Form("fDeltaPhi_%d", i))); | |
4ef701a0 | 764 | if (fDeltaPhi[i]) |
765 | fDeltaPhi[i]->Write(); | |
0fc41645 | 766 | } |
54b096ef | 767 | |
0fc41645 | 768 | fEventStats = dynamic_cast<TH2F*> (fOutput->FindObject("fEventStats")); |
50ec344d | 769 | if (fEventStats) |
770 | fEventStats->Write(); | |
771 | ||
0f67a57c | 772 | fout->Write(); |
773 | fout->Close(); | |
774 | ||
54b096ef | 775 | //fdNdEtaCorrection->DrawHistograms(); |
0f67a57c | 776 | |
96fcc8a7 | 777 | Printf("Writting result to %s", fileName.Data()); |
778 | ||
0f67a57c | 779 | if (fPIDParticles && fPIDTracks) |
780 | { | |
781 | new TCanvas("pidcanvas", "pidcanvas", 500, 500); | |
782 | ||
783 | fPIDParticles->Draw(); | |
784 | fPIDTracks->SetLineColor(2); | |
785 | fPIDTracks->Draw("SAME"); | |
786 | ||
787 | TDatabasePDG* pdgDB = new TDatabasePDG; | |
788 | ||
789 | for (Int_t i=0; i <= fPIDParticles->GetNbinsX()+1; ++i) | |
790 | if (fPIDParticles->GetBinContent(i) > 0) | |
791 | printf("PDG = %d (%s): generated: %d, reconstructed: %d, ratio: %f\n", (Int_t) fPIDParticles->GetBinCenter(i), pdgDB->GetParticle((Int_t) fPIDParticles->GetBinCenter(i))->GetName(), (Int_t) fPIDParticles->GetBinContent(i), (Int_t) fPIDTracks->GetBinContent(i), ((fPIDTracks->GetBinContent(i) > 0) ? fPIDParticles->GetBinContent(i) / fPIDTracks->GetBinContent(i) : -1)); | |
792 | ||
793 | delete pdgDB; | |
794 | pdgDB = 0; | |
795 | } | |
0f67a57c | 796 | } |
797 | ||
798 | Bool_t AlidNdEtaCorrectionTask::SignOK(TParticlePDG* particle) | |
799 | { | |
800 | // returns if a particle with this sign should be counted | |
801 | // this is determined by the value of fSignMode, which should have the same sign | |
802 | // as the charge | |
803 | // if fSignMode is 0 all particles are counted | |
804 | ||
805 | if (fSignMode == 0) | |
806 | return kTRUE; | |
807 | ||
808 | if (!particle) | |
809 | { | |
810 | printf("WARNING: not counting a particle that does not have a pdg particle\n"); | |
811 | return kFALSE; | |
812 | } | |
813 | ||
814 | Double_t charge = particle->Charge(); | |
815 | ||
816 | if (fSignMode > 0) | |
817 | if (charge < 0) | |
818 | return kFALSE; | |
819 | ||
820 | if (fSignMode < 0) | |
821 | if (charge > 0) | |
822 | return kFALSE; | |
823 | ||
824 | return kTRUE; | |
825 | } | |
96fcc8a7 | 826 |