3 #include "AlidNdEtaCorrectionTask.h"
12 #include <TParticle.h>
13 #include <TParticlePDG.h>
14 #include <TDatabasePDG.h>
18 #include <AliESDVertex.h>
19 #include <AliESDEvent.h>
20 #include <AliESDRun.h>
22 #include <AliHeader.h>
23 #include <AliGenEventHeader.h>
24 #include <AliMultiplicity.h>
25 #include <AliAnalysisManager.h>
26 #include <AliMCEventHandler.h>
27 #include <AliMCEvent.h>
28 #include <AliESDInputHandler.h>
30 #include "AliESDtrackCuts.h"
31 #include "AliPWG0Helper.h"
32 #include "dNdEta/dNdEtaAnalysis.h"
33 #include "dNdEta/AlidNdEtaCorrection.h"
34 #include "AliTriggerAnalysis.h"
35 #include "AliPhysicsSelection.h"
37 ClassImp(AlidNdEtaCorrectionTask)
39 AlidNdEtaCorrectionTask::AlidNdEtaCorrectionTask() :
44 fAnalysisMode((AliPWG0Helper::AnalysisMode) (AliPWG0Helper::kTPC | AliPWG0Helper::kFieldOn)),
45 fTrigger(AliTriggerAnalysis::kMB1),
49 fMultAxisEta1(kFALSE),
50 fDiffTreatment(AliPWG0Helper::kMCFlags),
52 fOnlyPrimaries(kFALSE),
54 fSystSkipParticles(kFALSE),
58 fdNdEtaAnalysisESD(0),
61 fVertexCorrelation(0),
62 fVertexCorrelationShift(0),
67 fEtaCorrelationShift(0),
70 fDeltaPhiCorrelation(0),
80 fEsdTrackCutsCheck(0),
81 fEtaCorrelationAllESD(0),
83 fpTCorrelationShift(0),
84 fpTCorrelationAllESD(0),
85 fpTCorrelationShiftAllESD(0),
95 fWeightSecondaries(kFALSE)
98 // Constructor. Initialization of pointers
101 for (Int_t i=0; i<4; i++)
102 fdNdEtaCorrectionSpecial[i] = 0;
104 for (Int_t i=0; i<8; i++)
107 AliLog::SetClassDebugLevel("AlidNdEtaCorrectionTask", AliLog::kWarning);
110 AlidNdEtaCorrectionTask::AlidNdEtaCorrectionTask(const char* opt) :
111 AliAnalysisTask("AlidNdEtaCorrectionTask", ""),
115 fAnalysisMode((AliPWG0Helper::AnalysisMode) (AliPWG0Helper::kTPC | AliPWG0Helper::kFieldOn)),
116 fTrigger(AliTriggerAnalysis::kMB1),
120 fMultAxisEta1(kFALSE),
121 fDiffTreatment(AliPWG0Helper::kMCFlags),
123 fOnlyPrimaries(kFALSE),
125 fSystSkipParticles(kFALSE),
127 fdNdEtaCorrection(0),
128 fdNdEtaAnalysisMC(0),
129 fdNdEtaAnalysisESD(0),
132 fVertexCorrelation(0),
133 fVertexCorrelationShift(0),
138 fEtaCorrelationShift(0),
141 fDeltaPhiCorrelation(0),
143 fEsdTrackCutsPrim(0),
151 fEsdTrackCutsCheck(0),
152 fEtaCorrelationAllESD(0),
154 fpTCorrelationShift(0),
155 fpTCorrelationAllESD(0),
156 fpTCorrelationShiftAllESD(0),
166 fWeightSecondaries(kFALSE)
169 // Constructor. Initialization of pointers
172 // Define input and output slots here
173 DefineInput(0, TChain::Class());
174 DefineOutput(0, TList::Class());
176 for (Int_t i=0; i<4; i++)
177 fdNdEtaCorrectionSpecial[i] = 0;
179 for (Int_t i=0; i<8; i++)
182 AliLog::SetClassDebugLevel("AlidNdEtaCorrectionTask", AliLog::kWarning);
185 AlidNdEtaCorrectionTask::~AlidNdEtaCorrectionTask()
191 // histograms are in the output list and deleted when the output
192 // list is deleted by the TSelector dtor
194 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
201 //________________________________________________________________________
202 void AlidNdEtaCorrectionTask::ConnectInputData(Option_t *)
207 Printf("AlidNdEtaCorrectionTask::ConnectInputData called");
209 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
212 Printf("ERROR: Could not get ESDInputHandler");
214 fESD = esdH->GetEvent();
216 // Enable only the needed branches
217 esdH->SetActiveBranches("AliESDHeader Vertex");
219 if (fAnalysisMode & AliPWG0Helper::kSPD)
220 esdH->SetActiveBranches("AliESDHeader Vertex AliMultiplicity");
222 if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS) {
223 esdH->SetActiveBranches("AliESDHeader Vertex Tracks");
227 // disable info messages of AliMCEvent (per event)
228 AliLog::SetClassDebugLevel("AliMCEvent", AliLog::kWarning - AliLog::kDebug + 1);
231 void AlidNdEtaCorrectionTask::CreateOutputObjects()
233 // create result objects and add to output list
235 AliDebug(2,Form("*********************************** fOption = %s", fOption.Data()));
236 if (fOption.Contains("only-positive"))
238 Printf("INFO: Processing only positive particles.");
241 else if (fOption.Contains("only-negative"))
243 Printf("INFO: Processing only negative particles.");
247 if (fOption.Contains("stat-error-1"))
249 Printf("INFO: Evaluation statistical errors. Mode: 1.");
252 else if (fOption.Contains("stat-error-2"))
254 Printf("INFO: Evaluation statistical errors. Mode: 2.");
261 fdNdEtaCorrection = new AlidNdEtaCorrection("dndeta_correction", "dndeta_correction", fAnalysisMode);
262 fOutput->Add(fdNdEtaCorrection);
264 fPIDParticles = new TH1F("fPIDParticles", "PID of generated primary particles", 10001, -5000.5, 5000.5);
265 fOutput->Add(fPIDParticles);
267 fPIDTracks = new TH1F("fPIDTracks", "MC PID of reconstructed tracks", 10001, -5000.5, 5000.5);
268 fOutput->Add(fPIDTracks);
270 fdNdEtaAnalysisMC = new dNdEtaAnalysis("dndetaMC", "dndetaMC", fAnalysisMode);
271 fOutput->Add(fdNdEtaAnalysisMC);
273 fdNdEtaAnalysisESD = new dNdEtaAnalysis("dndetaESD", "dndetaESD", fAnalysisMode);
274 fOutput->Add(fdNdEtaAnalysisESD);
278 fEsdTrackCutsPrim = static_cast<AliESDtrackCuts*> (fEsdTrackCuts->Clone("fEsdTrackCutsPrim"));
279 fEsdTrackCutsSec = static_cast<AliESDtrackCuts*> (fEsdTrackCuts->Clone("fEsdTrackCutsSec"));
280 fEsdTrackCutsCheck = static_cast<AliESDtrackCuts*> (fEsdTrackCuts->Clone("fEsdTrackCutsCheck"));
281 fEsdTrackCutsCheck->SetPtRange(0.15);
282 fEsdTrackCutsCheck->SetEtaRange(-1.,1.);
283 fOutput->Add(fEsdTrackCutsPrim);
284 fOutput->Add(fEsdTrackCutsSec);
287 if (fOption.Contains("process-types")) {
288 fdNdEtaCorrectionSpecial[0] = new AlidNdEtaCorrection("dndeta_correction_ND", "dndeta_correction_ND", fAnalysisMode);
289 fdNdEtaCorrectionSpecial[1] = new AlidNdEtaCorrection("dndeta_correction_SD", "dndeta_correction_SD", fAnalysisMode);
290 fdNdEtaCorrectionSpecial[2] = new AlidNdEtaCorrection("dndeta_correction_DD", "dndeta_correction_DD", fAnalysisMode);
292 fOutput->Add(fdNdEtaCorrectionSpecial[0]);
293 fOutput->Add(fdNdEtaCorrectionSpecial[1]);
294 fOutput->Add(fdNdEtaCorrectionSpecial[2]);
297 if (fOption.Contains("particle-species")) {
298 fdNdEtaCorrectionSpecial[0] = new AlidNdEtaCorrection("dndeta_correction_pi", "dndeta_correction_pi", fAnalysisMode);
299 fdNdEtaCorrectionSpecial[1] = new AlidNdEtaCorrection("dndeta_correction_K", "dndeta_correction_K", fAnalysisMode);
300 fdNdEtaCorrectionSpecial[2] = new AlidNdEtaCorrection("dndeta_correction_p", "dndeta_correction_p", fAnalysisMode);
301 fdNdEtaCorrectionSpecial[3] = new AlidNdEtaCorrection("dndeta_correction_other", "dndeta_correction_other", fAnalysisMode);
303 for (Int_t i=0; i<4; i++)
304 fOutput->Add(fdNdEtaCorrectionSpecial[i]);
308 //fTemp1 = new TH2F("fTemp1", "fTemp1", 4, 0.5, 4.5, 101, -1.5, 99.5); // nsd study
309 fTemp1 = new TH2F("fTemp1", "fTemp1", 300, -15, 15, 80, -2.0, 2.0);
310 fOutput->Add(fTemp1);
312 fTemp2 = new TH2F("fTemp2", "fTemp2", 300, -15, 15, 80, -2.0, 2.0);
313 fOutput->Add(fTemp2);
315 fVertexCorrelation = new TH2F("fVertexCorrelation", "fVertexCorrelation;MC z-vtx;ESD z-vtx", 120, -30, 30, 120, -30, 30);
316 fOutput->Add(fVertexCorrelation);
317 fVertexCorrelationShift = new TH3F("fVertexCorrelationShift", "fVertexCorrelationShift;MC z-vtx;MC z-vtx - ESD z-vtx;rec. tracks", 120, -30, 30, 100, -1, 1, 100, -0.5, 99.5);
318 fOutput->Add(fVertexCorrelationShift);
319 fVertexProfile = new TProfile("fVertexProfile", "fVertexProfile;MC z-vtx;MC z-vtx - ESD z-vtx", 40, -20, 20);
320 fOutput->Add(fVertexProfile);
321 fVertexShift = new TH1F("fVertexShift", "fVertexShift;(MC z-vtx - ESD z-vtx);Entries", 201, -2, 2);
322 fOutput->Add(fVertexShift);
323 fVertexShiftNorm = new TH2F("fVertexShiftNorm", "fVertexShiftNorm;(MC z-vtx - ESD z-vtx);rec. tracks;Entries", 200, -100, 100, 100, -0.5, 99.5);
324 fOutput->Add(fVertexShiftNorm);
326 fEtaCorrelation = new TH2F("fEtaCorrelation", "fEtaCorrelation;MC #eta;ESD #eta", 120, -3, 3, 120, -3, 3);
327 fOutput->Add(fEtaCorrelation);
328 fEtaCorrelationAllESD = new TH2F("fEtaCorrelationAllESD", "fEtaCorrelationAllESD;MC #eta;ESD #eta", 120, -3, 3, 120, -3, 3);
329 fOutput->Add(fEtaCorrelationAllESD);
330 fEtaCorrelationShift = new TH2F("fEtaCorrelationShift", "fEtaCorrelationShift;MC #eta;MC #eta - ESD #eta", 120, -3, 3, 100, -0.1, 0.1);
331 fOutput->Add(fEtaCorrelationShift);
332 fEtaProfile = new TProfile("fEtaProfile", "fEtaProfile;MC #eta;MC #eta - ESD #eta", 120, -3, 3);
333 fOutput->Add(fEtaProfile);
334 fEtaResolution = new TH1F("fEtaResolution", "fEtaResolution;MC #eta - ESD #eta", 201, -0.2, 0.2);
335 fOutput->Add(fEtaResolution);
337 fpTResolution = new TH2F("fpTResolution", ";MC p_{T} (GeV/c);(MC p_{T} - ESD p_{T}) / MC p_{T}", 160, 0, 20, 201, -0.2, 0.2);
338 fOutput->Add(fpTResolution);
340 fpTCorrelation = new TH2F("fpTCorrelation", "fpTCorrelation;MC p_{T} (GeV/c);ESD p_{T}", 160, 0, 20, 160, 0, 20);
341 fOutput->Add(fpTCorrelation);
342 fpTCorrelationShift = new TH2F("fpTCorrelationShift", "fpTCorrelationShift;MC p_{T} (GeV/c);MC p_{T} - ESD p_{T}", 160, 0, 20, 100, -1, 1);
343 fOutput->Add(fpTCorrelationShift);
344 fpTCorrelationAllESD = new TH2F("fpTCorrelationAllESD", "fpTCorrelationAllESD;MC p_{T} (GeV/c);ESD p_{T}", 160, 0, 20, 160, 0, 20);
345 fOutput->Add(fpTCorrelationAllESD);
346 fpTCorrelationShiftAllESD = new TH2F("fpTCorrelationShiftAllESD", "fpTCorrelationShiftAllESD;MC p_{T} (GeV/c);MC p_{T} - ESD p_{T}", 160, 0, 20, 100, -1, 1);
347 fOutput->Add(fpTCorrelationShiftAllESD);
349 fMultAll = new TH1F("fMultAll", "fMultAll", 500, -0.5, 499.5);
350 fOutput->Add(fMultAll);
351 fMultVtx = new TH1F("fMultVtx", "fMultVtx", 500, -0.5, 499.5);
352 fOutput->Add(fMultVtx);
353 fMultTr = new TH1F("fMultTr", "fMultTr", 500, -0.5, 499.5);
354 fOutput->Add(fMultTr);
356 for (Int_t i=0; i<8; i++)
358 fDeltaPhi[i] = new TH2F(Form("fDeltaPhi_%d", i), ";#Delta phi;#phi;Entries", 2000, -0.1, 0.1, 18 * 5, 0, TMath::TwoPi());
359 fOutput->Add(fDeltaPhi[i]);
362 fEventStats = new TH2F("fEventStats", "fEventStats;event type;status;count", 109, -6.5, 102.5, 4, -0.5, 3.5);
363 fOutput->Add(fEventStats);
364 fEventStats->GetXaxis()->SetBinLabel(1, "INEL"); // x = -5
365 fEventStats->GetXaxis()->SetBinLabel(2, "NSD"); // x = -4
366 fEventStats->GetXaxis()->SetBinLabel(3, "ND"); // x = -3
367 fEventStats->GetXaxis()->SetBinLabel(4, "SD"); // x = -2
368 fEventStats->GetXaxis()->SetBinLabel(5, "DD"); // x = -1
370 fEventStats->GetXaxis()->SetBinLabel(108, "INEL=0"); // x = -101
371 fEventStats->GetXaxis()->SetBinLabel(109, "INEL>0"); // x = -102
373 for (Int_t i=-1; i<100; i++)
374 fEventStats->GetXaxis()->SetBinLabel(7+i, Form("%d", i));
376 fEventStats->GetYaxis()->SetBinLabel(1, "nothing");
377 fEventStats->GetYaxis()->SetBinLabel(2, "trg");
378 fEventStats->GetYaxis()->SetBinLabel(3, "vtx");
379 fEventStats->GetYaxis()->SetBinLabel(4, "trgvtx");
383 fEsdTrackCuts->SetName("fEsdTrackCuts");
384 // TODO like this we send an empty object back...
385 fOutput->Add(fEsdTrackCuts->Clone());
387 fPtMC = new TH1F("fPtMC", "Pt from MC for selected tracks;MC p_{T} (GeV/c)", 160, 0, 20);
389 fEtaMC = new TH1F("fEtaMC", "Eta from MC for selected tracks;MC #eta", 120, -3, 3);
390 fOutput->Add(fEtaMC);
391 fPtESD = new TH1F("fPtESD", "Pt from ESD for selected tracks;ESD p_{T} (GeV/c)", 160, 0, 20);
392 fOutput->Add(fPtESD);
393 fEtaESD = new TH1F("fEtaESD", "Eta from ESD for selected tracks;ESD #eta", 120, -3, 3);
394 fOutput->Add(fEtaESD);
396 fVtxMC = new TH1F("fVtxMC", "Vtx,z from MC for all events;MC vtx_z (cm)", 100, -30, 30);
397 fOutput->Add(fVtxMC);
399 fNumberEventMC = new TH1F("fNumberEventMC","Number of event accepted at MC level",600000,-0.5,600000-0.5);
400 fOutput->Add(fNumberEventMC);
402 fNumberEvent = new TH1F("fNumberEvent","Number of event accepted at Reco level",600000,-0.5,600000-0.5);
403 fOutput->Add(fNumberEvent);
406 void AlidNdEtaCorrectionTask::Exec(Option_t*)
411 // Check prerequisites
414 AliDebug(AliLog::kError, "ESD branch not available");
419 Printf("WARNING: Processing only primaries. For systematical studies only!");
422 Printf("WARNING: Statistical error evaluation active!");
424 AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
427 Printf("ERROR: Could not receive input handler");
431 Bool_t eventTriggered = inputHandler->IsEventSelected();
433 static AliTriggerAnalysis* triggerAnalysis = 0;
434 if (!triggerAnalysis)
436 AliPhysicsSelection* physicsSelection = dynamic_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());
437 if (physicsSelection)
438 triggerAnalysis = physicsSelection->GetTriggerAnalysis();
442 eventTriggered = triggerAnalysis->IsTriggerFired(fESD, fTrigger);
445 Printf("No trigger");
447 // post the data already here
448 PostData(0, fOutput);
451 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
453 Printf("ERROR: Could not retrieve MC event handler");
457 AliMCEvent* mcEvent = eventHandler->MCEvent();
459 Printf("ERROR: Could not retrieve MC event");
463 AliStack* stack = mcEvent->Stack();
466 AliDebug(AliLog::kError, "Stack not available");
470 AliHeader* header = mcEvent->Header();
473 AliDebug(AliLog::kError, "Header not available");
478 Int_t processType = AliPWG0Helper::GetEventProcessType(fESD, header, stack, fDiffTreatment);
480 AliDebug(AliLog::kDebug+1, Form("Found process type %d", processType));
482 if (processType == AliPWG0Helper::kInvalidProcess)
484 AliDebug(AliLog::kWarning, "Unknown process type. Setting to ND");
485 processType = AliPWG0Helper::kND;
489 AliGenEventHeader* genHeader = header->GenEventHeader();
491 genHeader->PrimaryVertex(vtxMC);
492 fVtxMC->Fill(vtxMC[2]);
493 AliDebug(2,Form("MC vtx: x = %.6f, y = %.6f, z = %.6f",vtxMC[0],vtxMC[1],vtxMC[2]));
495 // get the ESD vertex
496 Bool_t eventVertex = kFALSE;
498 const AliESDVertex* vtxESD = AliPWG0Helper::GetVertex(fESD, fAnalysisMode);
499 if (vtxESD && AliPWG0Helper::TestVertex(vtxESD, fAnalysisMode))
504 // remove vertices outside +- 15 cm
505 if (TMath::Abs(vtx[2]) > 15)
507 eventVertex = kFALSE;
514 // create list of (label, eta, pt) tuples
515 Int_t inputCount = 0;
517 Int_t* labelArr2 = 0; // only for case of SPD
519 Float_t* thirdDimArr = 0;
520 Float_t* deltaPhiArr = 0;
521 if (fAnalysisMode & AliPWG0Helper::kSPD)
526 const AliMultiplicity* mult = fESD->GetMultiplicity();
529 AliDebug(AliLog::kError, "AliMultiplicity not available");
533 labelArr = new Int_t[mult->GetNumberOfTracklets()];
534 labelArr2 = new Int_t[mult->GetNumberOfTracklets()];
535 etaArr = new Float_t[mult->GetNumberOfTracklets()];
536 thirdDimArr = new Float_t[mult->GetNumberOfTracklets()];
537 deltaPhiArr = new Float_t[mult->GetNumberOfTracklets()];
539 Bool_t foundInEta10 = kFALSE;
541 // get multiplicity from SPD tracklets
542 for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i)
544 //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i));
546 Float_t phi = mult->GetPhi(i);
548 phi += TMath::Pi() * 2;
549 Float_t deltaPhi = mult->GetDeltaPhi(i);
551 if (TMath::Abs(deltaPhi) > 1)
552 printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi);
555 if (mult->GetLabel(i, 0) < 0 || mult->GetLabel(i, 0) != mult->GetLabel(i, 1) || !stack->IsPhysicalPrimary(mult->GetLabel(i, 0)))
558 if (fDeltaPhiCut > 0 && (TMath::Abs(deltaPhi) > fDeltaPhiCut || TMath::Abs(mult->GetDeltaTheta(i)) > fDeltaPhiCut / 0.08 * 0.025))
561 if (fSystSkipParticles && gRandom->Uniform() < 0.0153)
563 Printf("Skipped tracklet!");
567 // TEST exclude potentially inefficient phi region
568 //if (phi > 5.70 || phi < 0.06)
571 // we have to repeat the trigger here, because the tracklet might have been kicked out fSystSkipParticles
572 if (TMath::Abs(mult->GetEta(i)) < 1)
573 foundInEta10 = kTRUE;
575 etaArr[inputCount] = mult->GetEta(i);
577 etaArr[inputCount] = TMath::Abs(etaArr[inputCount]);
578 labelArr[inputCount] = mult->GetLabel(i, 0);
579 labelArr2[inputCount] = mult->GetLabel(i, 1);
580 thirdDimArr[inputCount] = phi;
581 deltaPhiArr[inputCount] = deltaPhi;
586 for (Int_t i=0; i<mult->GetNumberOfSingleClusters(); ++i)
588 if (TMath::Abs(TMath::Log(TMath::Tan(mult->GetThetaSingle(i)/2.))) < 1);
590 foundInEta10 = kTRUE;
596 if (fSystSkipParticles && (fTrigger & AliTriggerAnalysis::kOneParticle) && !foundInEta10)
597 eventTriggered = kFALSE;
600 else if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS)
604 AliDebug(AliLog::kError, "fESDTrackCuts not available");
608 Bool_t foundInEta10 = kFALSE;
612 // control histograms on pT
613 Int_t nfromstack = stack->GetNtrack();
614 AliDebug(3,Form(" from stack we have %d tracks\n",nfromstack));
615 for (Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){
616 AliESDtrack* esdTrackcheck = dynamic_cast<AliESDtrack*> (fESD->GetTrack(itrack));
618 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", itrack));
622 Int_t label = TMath::Abs(esdTrackcheck->GetLabel());
623 AliDebug(4,Form("label = %d\n",label));
624 if (label == 0 || label > nfromstack) continue;
625 if (stack->IsPhysicalPrimary(label) == kFALSE) continue;
628 Int_t label = TMath::Abs(esdTrackcheck->GetLabel());
629 if (label == 0 || label > nfromstack) continue;
630 if (!stack->Particle(label)){
631 AliDebug(4,Form("WARNING: No particle for %d", label));
634 if (!fEsdTrackCuts->AcceptTrack(esdTrackcheck)){
635 TParticle* particle = stack->Particle(label);
636 if (fEsdTrackCutsCheck->AcceptTrack(esdTrackcheck)){
637 //if (TMath::Abs(particle->Eta() < 0.8) && particle->Pt() > fPtMin){
638 Float_t ptMC = particle->Pt();
639 Float_t etaMC = particle->Eta();
640 Float_t ptESD = esdTrackcheck->Pt();
641 Float_t etaESD = esdTrackcheck->Eta();
642 fEtaCorrelationAllESD->Fill(etaMC,etaESD);
643 fpTCorrelationAllESD->Fill(ptMC,ptESD);
644 fpTCorrelationShiftAllESD->Fill(ptMC,ptMC-ptESD);
648 } // end loop over all ESDs
650 // get multiplicity from ESD tracks
651 TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD, (fAnalysisMode & AliPWG0Helper::kTPC));
652 Int_t nGoodTracks = list->GetEntries();
654 Printf("Accepted %d tracks", nGoodTracks);
656 labelArr = new Int_t[nGoodTracks];
657 labelArr2 = new Int_t[nGoodTracks];
658 etaArr = new Float_t[nGoodTracks];
659 thirdDimArr = new Float_t[nGoodTracks];
660 deltaPhiArr = new Float_t[nGoodTracks];
662 // loop over esd tracks
663 for (Int_t i=0; i<nGoodTracks; i++)
665 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(i));
668 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", i));
672 AliDebug(3,Form("particle %d: pt = %.6f, eta = %.6f",i,esdTrack->Pt(), esdTrack->Eta()));
673 // 2 Options for INEL>0 trigger - choose one
675 //if (esdTrack->Pt() < 0.15)
676 // foundInEta10 = kTRUE;
677 // 2. MB Working Group definition
678 if (esdTrack->Pt() < fPtMin)
683 Int_t label = TMath::Abs(esdTrack->GetLabel());
687 if (stack->IsPhysicalPrimary(label) == kFALSE)
691 Int_t label = TMath::Abs(esdTrack->GetLabel());
692 if (!stack->Particle(label)){
693 AliDebug(3,Form("WARNING: No particle for %d", label));
696 TParticle* particle = stack->Particle(label);
697 Float_t ptMC = particle->Pt();
698 Float_t etaMC = particle->Eta();
701 fPtESD->Fill(esdTrack->Pt());
702 fEtaESD->Fill(esdTrack->Eta());
705 // 2 Options for INEL>0 trigger - choose one
707 //if (TMath::Abs(esdTrack->Eta()) < 1 && esdTrack->Pt() > 0.15)
708 // foundInEta10 = kTRUE;
709 // 2. MB Working Group definition
710 if (TMath::Abs(esdTrack->Eta()) < 0.8 && esdTrack->Pt() > fPtMin)
711 foundInEta10 = kTRUE;
713 etaArr[inputCount] = esdTrack->Eta();
715 etaArr[inputCount] = TMath::Abs(etaArr[inputCount]);
716 labelArr[inputCount] = TMath::Abs(esdTrack->GetLabel());
717 labelArr2[inputCount] = labelArr[inputCount]; // no second label for tracks
718 thirdDimArr[inputCount] = esdTrack->Pt();
719 deltaPhiArr[inputCount] = 0; // no delta phi for tracks
725 // TODO this code crashes for TPCITS because particles are requested from the stack for some labels that are out of bound
726 if (0 && eventTriggered)
728 // collect values for primaries and secondaries
729 for (Int_t iTrack = 0; iTrack < fESD->GetNumberOfTracks(); iTrack++)
731 AliESDtrack* track = 0;
733 if (fAnalysisMode & AliPWG0Helper::kTPC)
734 track = AliESDtrackCuts::GetTPCOnlyTrack(fESD, iTrack);
735 else if (fAnalysisMode & AliPWG0Helper::kTPCITS)
736 track = fESD->GetTrack(iTrack);
741 Int_t label = TMath::Abs(track->GetLabel());
742 if (!stack->Particle(label) || !stack->Particle(label)->GetPDG())
744 Printf("WARNING: No particle for %d", label);
745 if (stack->Particle(label))
746 stack->Particle(label)->Print();
750 if (stack->Particle(label)->GetPDG()->Charge() == 0)
753 if (TMath::Abs(track->Eta()) < 0.8 && track->Pt() > 0.15)
755 if (stack->IsPhysicalPrimary(label))
758 if (fEsdTrackCutsPrim->AcceptTrack(track))
760 // if (AliESDtrackCuts::GetSigmaToVertex(track) > 900)
762 // Printf("Track %d has nsigma of %f. Printing track and vertex...", iTrack, AliESDtrackCuts::GetSigmaToVertex(track));
765 // track->GetImpactParameters(b, r);
766 // Printf("Impact parameter %f %f and resolution: %f %f %f", b[0], b[1], r[0], r[1], r[2]);
776 fEsdTrackCutsSec->AcceptTrack(track);
780 // TODO mem leak in the continue statements above
781 if (fAnalysisMode & AliPWG0Helper::kTPC)
788 eventTriggered = kFALSE;
790 //Printf("The event triggered. Its number in file is %d",fESD->GetEventNumberInFile());
791 fNumberEvent->Fill(fESD->GetEventNumberInFile());
798 Int_t biny = (Int_t) eventTriggered + 2 * (Int_t) eventVertex;
800 fEventStats->Fill(-6, biny);
802 if (processType != AliPWG0Helper::kSD)
803 fEventStats->Fill(-5, biny);
805 if (processType == AliPWG0Helper::kND)
806 fEventStats->Fill(-4, biny);
807 if (processType == AliPWG0Helper::kSD)
808 fEventStats->Fill(-3, biny);
809 if (processType == AliPWG0Helper::kDD)
810 fEventStats->Fill(-2, biny);
812 // loop over mc particles
813 Int_t nPrim = stack->GetNprimary();
816 Bool_t oneParticleEvent = kFALSE;
817 for (Int_t iMc = 0; iMc < nPrim; ++iMc)
819 //Printf("Getting particle %d", iMc);
820 TParticle* particle = stack->Particle(iMc);
825 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
828 // for INEL > 0, MB Working Group definition use the second option
830 //if (TMath::Abs(particle->Eta()) < 1.0)
831 // 2. MB Working Group definition
832 if (TMath::Abs(particle->Eta()) < 0.8 && particle->Pt() > fPtMin)
834 oneParticleEvent = kTRUE;
835 fNumberEventMC->Fill(fESD->GetEventNumberInFile());
840 if (TMath::Abs(vtxMC[2]) < 5.5)
842 if (oneParticleEvent)
843 fEventStats->Fill(102, biny);
845 fEventStats->Fill(101, biny);
848 for (Int_t iMc = 0; iMc < nPrim; ++iMc)
850 //Printf("Getting particle %d", iMc);
851 TParticle* particle = stack->Particle(iMc);
856 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
858 //if (TMath::Abs(particle->GetPdgCode()) > 3000 && TMath::Abs(particle->Eta()) < 1.0)
859 // fPIDParticles->Fill(particle->GetPdgCode());
863 if (SignOK(particle->GetPDG()) == kFALSE)
866 // for INEL > 0, MB Working Group definition use the second option
868 //if (fPIDParticles && TMath::Abs(particle->Eta()) < 1.0)
869 // 2. MB Working Group definition
870 if (fPIDParticles && TMath::Abs(particle->Eta()) < 0.8 && particle->Pt() > fPtMin)
871 fPIDParticles->Fill(particle->GetPdgCode());
873 Float_t eta = particle->Eta();
875 eta = TMath::Abs(eta);
877 Float_t thirdDim = -1;
878 if (fAnalysisMode & AliPWG0Helper::kSPD)
882 thirdDim = particle->Phi();
885 thirdDim = inputCount;
888 thirdDim = particle->Pt();
891 //Float_t y = 0.5 * TMath::Log((particle->Energy() + particle->Pz()) / (particle->Energy() - particle->Pz()));
895 Int_t processType2 = processType;
896 if (oneParticleEvent)
897 processType2 |= AliPWG0Helper::kOnePart;
899 fdNdEtaCorrection->FillMCParticle(vtxMC[2], eta, thirdDim, eventTriggered, eventVertex, processType2);
901 if (fOption.Contains("process-types"))
904 if (processType==AliPWG0Helper::kND)
905 fdNdEtaCorrectionSpecial[0]->FillMCParticle(vtxMC[2], eta, thirdDim, eventTriggered, eventVertex, processType2);
907 // single diffractive
908 if (processType==AliPWG0Helper::kSD)
909 fdNdEtaCorrectionSpecial[1]->FillMCParticle(vtxMC[2], eta, thirdDim, eventTriggered, eventVertex, processType2);
911 // double diffractive
912 if (processType==AliPWG0Helper::kDD)
913 fdNdEtaCorrectionSpecial[2]->FillMCParticle(vtxMC[2], eta, thirdDim, eventTriggered, eventVertex, processType2);
916 if (fOption.Contains("particle-species"))
919 switch (TMath::Abs(particle->GetPdgCode()))
921 case 211: id = 0; break;
922 case 321: id = 1; break;
923 case 2212: id = 2; break;
924 default: id = 3; break;
926 fdNdEtaCorrectionSpecial[id]->FillMCParticle(vtxMC[2], eta, thirdDim, eventTriggered, eventVertex, processType2);
931 fdNdEtaAnalysisMC->FillTrack(vtxMC[2], eta, thirdDim);
933 // TODO this value might be needed lower for the SPD study (only used for control histograms anyway)
934 if (TMath::Abs(eta) < 1.5) // && pt > 0.2)
938 if (AliPWG0Helper::GetLastProcessType() >= -1)
939 fEventStats->Fill(AliPWG0Helper::GetLastProcessType(), biny);
941 fMultAll->Fill(nAccepted);
942 if (eventTriggered) {
943 fMultTr->Fill(nAccepted);
945 fMultVtx->Fill(nAccepted);
950 Bool_t* primCount = 0;
953 primCount = new Bool_t[nPrim];
954 for (Int_t i=0; i<nPrim; ++i)
955 primCount[i] = kFALSE;
960 for (Int_t i=0; i<inputCount; ++i)
962 if (TMath::Abs(etaArr[i]) < 0.5)
964 if (TMath::Abs(etaArr[i]) < 1.0)
968 for (Int_t i=0; i<inputCount; ++i)
970 Int_t label = labelArr[i];
971 Int_t label2 = labelArr2[i];
975 Printf("WARNING: cannot find corresponding mc particle for track(let) %d with label %d.", i, label);
979 TParticle* particle = stack->Particle(label);
982 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label));
986 // for INEL > 0, MB Working Group definition use the second option
988 //if (TMath::Abs(particle->Eta()) < 1.0)
989 // 2. INEL > 0 MB Working Group definition
990 if (TMath::Abs(particle->Eta()) < 0.8 && particle->Pt()>fPtMin)
991 fPIDTracks->Fill(particle->GetPdgCode());
993 // find particle that is filled in the correction map
994 // this should be the particle that has been reconstructed
995 // for TPC this is clear and always identified by the track's label
996 // for SPD the labels might not be identical. In this case the particle closest to the beam line that is a primary is taken:
997 // L1 L2 (P = primary, S = secondary)
1003 if (label != label2 && label2 >= 0)
1005 if (stack->IsPhysicalPrimary(label) == kFALSE && stack->IsPhysicalPrimary(label2))
1007 particle = stack->Particle(label2);
1010 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (track loop).", label2));
1016 if (eventTriggered && eventVertex)
1018 if (SignOK(particle->GetPDG()) == kFALSE)
1025 fEtaResolution->Fill(TMath::Abs(particle->Eta()) - etaArr[i]);
1027 fEtaResolution->Fill(particle->Eta() - etaArr[i]);
1029 if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS){
1030 // for INEL > 0, MB Working Group definition use the second option
1032 //if (TMath::Abs(particle->Eta() < 0.9) && particle->Pt() > 0)
1033 // 2. INEL > 0 MB WOrking Group definition
1034 if (TMath::Abs(particle->Eta() < 0.8) && particle->Pt() > 0){
1035 fpTResolution->Fill(particle->Pt(), (particle->Pt() - thirdDimArr[i]) / particle->Pt());
1036 fpTCorrelation->Fill(particle->Pt(),thirdDimArr[i]);
1037 fpTCorrelationShift->Fill(particle->Pt(),particle->Pt()-thirdDimArr[i]);
1042 Float_t thirdDim = -1;
1044 Bool_t firstIsPrim = stack->IsPhysicalPrimary(label);
1045 // in case of same label the MC values are filled, otherwise (background) the reconstructed values
1046 if (label == label2)
1048 eta = particle->Eta();
1050 eta = TMath::Abs(eta);
1052 if (fAnalysisMode & AliPWG0Helper::kSPD)
1056 thirdDim = particle->Phi();
1059 thirdDim = inputCount;
1062 thirdDim = particle->Pt();
1066 if (fAnalysisMode & AliPWG0Helper::kSPD && !fFillPhi)
1068 thirdDim = (fMultAxisEta1) ? nEta10 : inputCount;
1071 thirdDim = thirdDimArr[i];
1076 Bool_t fillTrack = kTRUE;
1078 // statistical error evaluation active?
1081 Bool_t statErrorDecision = kFALSE;
1083 // primary and not yet counted
1084 if (label == label2 && firstIsPrim && !primCount[label])
1086 statErrorDecision = kTRUE;
1087 primCount[label] = kTRUE;
1090 // in case of 1 we count only unique primaries, in case of 2 all the rest
1091 if (fStatError == 1)
1093 fillTrack = statErrorDecision;
1095 else if (fStatError == 2)
1096 fillTrack = !statErrorDecision;
1101 Double_t weight = 1.;
1102 if (fWeightSecondaries){
1104 weight = GetSecondaryCorrection(thirdDim);
1107 fdNdEtaCorrection->FillTrackedParticle(vtxMC[2], eta, thirdDim, weight);
1108 fTemp2->Fill(vtxMC[2], eta);
1111 // eta comparison for tracklets with the same label (others are background)
1112 if (label == label2)
1114 Float_t eta2 = particle->Eta();
1116 eta2 = TMath::Abs(eta2);
1118 fEtaProfile->Fill(eta2, eta2 - etaArr[i]);
1119 fEtaCorrelation->Fill(eta2, etaArr[i]);
1120 fEtaCorrelationShift->Fill(eta2, eta2 - etaArr[i]);
1124 fdNdEtaAnalysisESD->FillTrack(vtxMC[2], TMath::Abs(particle->Eta()), thirdDim);
1126 fdNdEtaAnalysisESD->FillTrack(vtxMC[2], particle->Eta(), thirdDim);
1128 if (fOption.Contains("process-types"))
1131 if (processType == AliPWG0Helper::kND)
1132 fdNdEtaCorrectionSpecial[0]->FillTrackedParticle(vtxMC[2], eta, thirdDim);
1134 // single diffractive
1135 if (processType == AliPWG0Helper::kSD)
1136 fdNdEtaCorrectionSpecial[1]->FillTrackedParticle(vtxMC[2], eta, thirdDim);
1138 // double diffractive
1139 if (processType == AliPWG0Helper::kDD)
1140 fdNdEtaCorrectionSpecial[2]->FillTrackedParticle(vtxMC[2], eta, thirdDim);
1143 if (fOption.Contains("particle-species"))
1145 // find mother first
1146 TParticle* mother = AliPWG0Helper::FindPrimaryMother(stack, label);
1149 switch (TMath::Abs(mother->GetPdgCode()))
1151 case 211: id = 0; break;
1152 case 321: id = 1; break;
1153 case 2212: id = 2; break;
1154 default: id = 3; break;
1156 fdNdEtaCorrectionSpecial[id]->FillTrackedParticle(vtxMC[2], eta, thirdDim);
1159 // control histograms
1161 if (label == label2)
1170 else if (label2 >= 0)
1172 Bool_t secondIsPrim = stack->IsPhysicalPrimary(label2);
1173 if (firstIsPrim && secondIsPrim)
1177 else if (firstIsPrim && !secondIsPrim)
1181 // check if secondary is caused by the primary or it is a fake combination
1182 //Printf("PS case --> Label 1 is %d, label 2 is %d", label, label2);
1183 Int_t mother = label2;
1184 while (stack->Particle(mother) && stack->Particle(mother)->GetMother(0) >= 0)
1186 //Printf(" %d created by %d, %d", mother, stack->Particle(mother)->GetMother(0), stack->Particle(mother)->GetMother(1));
1187 if (stack->Particle(mother)->GetMother(0) == label)
1189 /*Printf("The untraceable decay was:");
1192 Printf(" to (status code %d):", stack->Particle(mother)->GetStatusCode());
1193 stack->Particle(mother)->Print();*/
1196 mother = stack->Particle(mother)->GetMother(0);
1199 else if (!firstIsPrim && secondIsPrim)
1203 else if (!firstIsPrim && !secondIsPrim)
1212 fDeltaPhi[hist]->Fill(deltaPhiArr[i], thirdDimArr[i]);
1222 if (processed < inputCount)
1223 Printf("Only %d out of %d track(let)s were used", processed, inputCount);
1225 if (eventTriggered && eventVertex)
1227 Double_t diff = vtxMC[2] - vtx[2];
1228 fVertexShift->Fill(diff);
1230 fVertexCorrelation->Fill(vtxMC[2], vtx[2]);
1231 fVertexCorrelationShift->Fill(vtxMC[2], vtxMC[2] - vtx[2], inputCount);
1232 fVertexProfile->Fill(vtxMC[2], vtxMC[2] - vtx[2]);
1234 if (vtxESD->IsFromVertexerZ() && inputCount > 0)
1235 fVertexShiftNorm->Fill(diff, vtxESD->GetNContributors());
1238 Int_t multAxis = inputCount;
1242 if (eventTriggered && eventVertex)
1244 fdNdEtaAnalysisMC->FillEvent(vtxMC[2], multAxis);
1245 fdNdEtaAnalysisESD->FillEvent(vtxMC[2], multAxis);
1248 Int_t processType2 = processType;
1249 if (oneParticleEvent)
1250 processType2 |= AliPWG0Helper::kOnePart;
1252 // stuff regarding the vertex reco correction and trigger bias correction
1253 fdNdEtaCorrection->FillEvent(vtxMC[2], multAxis, eventTriggered, eventVertex, processType2);
1255 if (fOption.Contains("process-types"))
1258 if (processType == AliPWG0Helper::kND)
1259 fdNdEtaCorrectionSpecial[0]->FillEvent(vtxMC[2], multAxis, eventTriggered, eventVertex, processType2);
1261 // single diffractive
1262 if (processType == AliPWG0Helper::kSD)
1263 fdNdEtaCorrectionSpecial[1]->FillEvent(vtxMC[2], multAxis, eventTriggered, eventVertex, processType2);
1265 // double diffractive
1266 if (processType == AliPWG0Helper::kDD)
1267 fdNdEtaCorrectionSpecial[2]->FillEvent(vtxMC[2], multAxis, eventTriggered, eventVertex, processType2);
1270 if (fOption.Contains("particle-species"))
1271 for (Int_t id=0; id<4; id++)
1272 fdNdEtaCorrectionSpecial[id]->FillEvent(vtxMC[2], multAxis, eventTriggered, eventVertex, processType2);
1281 delete[] thirdDimArr;
1283 delete[] deltaPhiArr;
1286 void AlidNdEtaCorrectionTask::Terminate(Option_t *)
1288 // The Terminate() function is the last function to be called during
1289 // a query. It always runs on the client, it can be used to present
1290 // the results graphically or save the results to file.
1292 fOutput = dynamic_cast<TList*> (GetOutputData(0));
1294 Printf("ERROR: fOutput not available");
1298 fdNdEtaCorrection = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction"));
1299 fdNdEtaAnalysisMC = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndetaMC"));
1300 fdNdEtaAnalysisESD = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndetaESD"));
1301 if (!fdNdEtaCorrection || !fdNdEtaAnalysisMC || !fdNdEtaAnalysisESD)
1303 AliDebug(AliLog::kError, "Could not read object from output list");
1307 fdNdEtaCorrection->Finish();
1310 fileName.Form("correction_map%s.root", fOption.Data());
1311 TFile* fout = new TFile(fileName, "RECREATE");
1313 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fOutput->FindObject("fEsdTrackCuts"));
1315 fEsdTrackCuts->SaveHistograms("esd_track_cuts");
1317 fEsdTrackCutsPrim = dynamic_cast<AliESDtrackCuts*> (fOutput->FindObject("fEsdTrackCutsPrim"));
1318 if (fEsdTrackCutsPrim)
1319 fEsdTrackCutsPrim->SaveHistograms("esd_track_cuts_primaries");
1321 fEsdTrackCutsSec = dynamic_cast<AliESDtrackCuts*> (fOutput->FindObject("fEsdTrackCutsSec"));
1322 if (fEsdTrackCutsSec)
1323 fEsdTrackCutsSec->SaveHistograms("esd_track_cuts_secondaries");
1325 fdNdEtaCorrection->SaveHistograms();
1326 fdNdEtaAnalysisMC->SaveHistograms();
1327 fdNdEtaAnalysisESD->SaveHistograms();
1329 if (fOutput->FindObject("dndeta_correction_ND"))
1331 fdNdEtaCorrectionSpecial[0] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_ND"));
1332 fdNdEtaCorrectionSpecial[1] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_SD"));
1333 fdNdEtaCorrectionSpecial[2] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_DD"));
1337 fdNdEtaCorrectionSpecial[0] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_pi"));
1338 fdNdEtaCorrectionSpecial[1] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_K"));
1339 fdNdEtaCorrectionSpecial[2] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_p"));
1340 fdNdEtaCorrectionSpecial[3] = dynamic_cast<AlidNdEtaCorrection*> (fOutput->FindObject("dndeta_correction_other"));
1342 for (Int_t i=0; i<4; ++i)
1343 if (fdNdEtaCorrectionSpecial[i])
1344 fdNdEtaCorrectionSpecial[i]->SaveHistograms();
1346 fTemp1 = dynamic_cast<TH1*> (fOutput->FindObject("fTemp1"));
1349 fTemp2 = dynamic_cast<TH1*> (fOutput->FindObject("fTemp2"));
1353 fVertexCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fVertexCorrelation"));
1354 if (fVertexCorrelation)
1355 fVertexCorrelation->Write();
1356 fVertexCorrelationShift = dynamic_cast<TH3F*> (fOutput->FindObject("fVertexCorrelationShift"));
1357 if (fVertexCorrelationShift)
1359 ((TH2*) fVertexCorrelationShift->Project3D("yx"))->FitSlicesY();
1360 fVertexCorrelationShift->Write();
1362 fVertexProfile = dynamic_cast<TProfile*> (fOutput->FindObject("fVertexProfile"));
1364 fVertexProfile->Write();
1365 fVertexShift = dynamic_cast<TH1F*> (fOutput->FindObject("fVertexShift"));
1367 fVertexShift->Write();
1368 fVertexShiftNorm = dynamic_cast<TH2F*> (fOutput->FindObject("fVertexShiftNorm"));
1369 if (fVertexShiftNorm)
1371 fVertexShiftNorm->ProjectionX();
1372 fVertexShiftNorm->Write();
1375 fEtaCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fEtaCorrelation"));
1376 if (fEtaCorrelation)
1377 fEtaCorrelation->Write();
1378 fEtaCorrelationAllESD = dynamic_cast<TH2F*> (fOutput->FindObject("fEtaCorrelationAllESD"));
1379 if (fEtaCorrelationAllESD)
1380 fEtaCorrelationAllESD->Write();
1381 fEtaCorrelationShift = dynamic_cast<TH2F*> (fOutput->FindObject("fEtaCorrelationShift"));
1382 if (fEtaCorrelationShift)
1384 fEtaCorrelationShift->FitSlicesY();
1385 fEtaCorrelationShift->Write();
1387 fEtaProfile = dynamic_cast<TProfile*> (fOutput->FindObject("fEtaProfile"));
1389 fEtaProfile->Write();
1390 fEtaResolution = dynamic_cast<TH1F*> (fOutput->FindObject("fEtaResolution"));
1392 fEtaResolution->Write();
1393 fpTCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fpTCorrelation"));
1395 fpTCorrelation->Write();
1396 fpTCorrelationShift = dynamic_cast<TH2F*> (fOutput->FindObject("fpTCorrelationShift"));
1397 if (fpTCorrelationShift)
1399 fpTCorrelationShift->FitSlicesY();
1400 fpTCorrelationShift->Write();
1402 fpTResolution = dynamic_cast<TH2F*> (fOutput->FindObject("fpTResolution"));
1405 fpTResolution->FitSlicesY();
1406 fpTResolution->Write();
1409 fpTCorrelationAllESD = dynamic_cast<TH2F*> (fOutput->FindObject("fpTCorrelationAllESD"));
1410 if (fpTCorrelationAllESD)
1411 fpTCorrelationAllESD->Write();
1412 fpTCorrelationShiftAllESD = dynamic_cast<TH2F*> (fOutput->FindObject("fpTCorrelationShiftAllESD"));
1413 if (fpTCorrelationShiftAllESD)
1415 fpTCorrelationShiftAllESD->FitSlicesY();
1416 fpTCorrelationShiftAllESD->Write();
1418 fMultAll = dynamic_cast<TH1F*> (fOutput->FindObject("fMultAll"));
1422 fMultTr = dynamic_cast<TH1F*> (fOutput->FindObject("fMultTr"));
1426 fMultVtx = dynamic_cast<TH1F*> (fOutput->FindObject("fMultVtx"));
1430 for (Int_t i=0; i<8; ++i)
1432 fDeltaPhi[i] = dynamic_cast<TH2*> (fOutput->FindObject(Form("fDeltaPhi_%d", i)));
1434 fDeltaPhi[i]->Write();
1437 fEventStats = dynamic_cast<TH2F*> (fOutput->FindObject("fEventStats"));
1439 fEventStats->Write();
1441 fPIDParticles = dynamic_cast<TH1F*> (fOutput->FindObject("fPIDParticles"));
1443 fPIDParticles->Write();
1445 fPIDTracks = dynamic_cast<TH1F*> (fOutput->FindObject("fPIDTracks"));
1447 fPIDTracks->Write();
1449 fPtMC = dynamic_cast<TH1F*> (fOutput->FindObject("fPtMC"));
1452 fEtaMC = dynamic_cast<TH1F*> (fOutput->FindObject("fEtaMC"));
1455 fPtESD = dynamic_cast<TH1F*> (fOutput->FindObject("fPtESD"));
1458 fEtaESD = dynamic_cast<TH1F*> (fOutput->FindObject("fEtaESD"));
1461 fVtxMC = dynamic_cast<TH1F*> (fOutput->FindObject("fVtxMC"));
1465 fNumberEventMC = dynamic_cast<TH1F*> (fOutput->FindObject("fNumberEventMC"));
1467 fNumberEventMC->Write();
1468 fNumberEvent = dynamic_cast<TH1F*> (fOutput->FindObject("fNumberEvent"));
1470 fNumberEvent->Write();
1472 //fdNdEtaCorrection->DrawHistograms();
1474 Printf("Writing result to %s", fileName.Data());
1476 if (fPIDParticles && fPIDTracks)
1478 TDatabasePDG* pdgDB = new TDatabasePDG;
1480 for (Int_t i=0; i <= fPIDParticles->GetNbinsX()+1; ++i)
1481 if (fPIDParticles->GetBinContent(i) > 0)
1483 TObject* pdgParticle = pdgDB->GetParticle((Int_t) fPIDParticles->GetBinCenter(i));
1484 printf("PDG = %d (%s): generated: %d, reconstructed: %d, ratio: %f\n", (Int_t) fPIDParticles->GetBinCenter(i), (pdgParticle) ? pdgParticle->GetName() : "not found", (Int_t) fPIDParticles->GetBinContent(i), (Int_t) fPIDTracks->GetBinContent(i), ((fPIDTracks->GetBinContent(i) > 0) ? fPIDParticles->GetBinContent(i) / fPIDTracks->GetBinContent(i) : -1));
1495 Bool_t AlidNdEtaCorrectionTask::SignOK(TParticlePDG* particle)
1497 // returns if a particle with this sign should be counted
1498 // this is determined by the value of fSignMode, which should have the same sign
1500 // if fSignMode is 0 all particles are counted
1507 printf("WARNING: not counting a particle that does not have a pdg particle\n");
1511 Double_t charge = particle->Charge();
1524 Double_t AlidNdEtaCorrectionTask::GetSecondaryCorrection(Double_t pt){
1526 // getting the data driven correction factor to correct for
1527 // the underestimate of secondaries in Pythia
1528 // (A. Dainese + J. Otwinowski
1530 if (pt <= 0.17) return 1.0;
1531 if (pt <= 0.4) return GetLinearInterpolationValue(0.17,1.0,0.4,1.07, pt);
1532 if (pt <= 0.6) return GetLinearInterpolationValue(0.4,1.07,0.6,1.25, pt);
1533 if (pt <= 1.2) return GetLinearInterpolationValue(0.6,1.25,1.2,1.5, pt);
1538 Double_t AlidNdEtaCorrectionTask::GetLinearInterpolationValue(Double_t const x1, Double_t const y1, Double_t const x2, Double_t const y2, const Double_t pt)
1542 // linear interpolation to be used to get the secondary correction (see AlidNdEtaCorrectionTask::GetSecondaryCorrection)
1545 return ((y2-y1)/(x2-x1))*pt+(y2-(((y2-y1)/(x2-x1))*x2));