2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////
20 // Analysis for identified particle spectra measured with TPC dE/dx. //
23 ///////////////////////////////////////////////////////////////////////////
25 #include "Riostream.h"
34 #include "TObjArray.h"
38 #include "AliAnalysisTaskSE.h"
39 #include "AliAnalysisManager.h"
41 #include "AliHeader.h"
42 #include "AliGenPythiaEventHeader.h"
43 #include "AliGenCocktailEventHeader.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliESDVertex.h"
48 #include "AliESDEvent.h"
49 #include "AliESDInputHandler.h"
50 #include "AliESDtrack.h"
51 #include "AliTPCpidESD.h"
53 #include "AliMCEventHandler.h"
54 #include "AliMCEvent.h"
59 #include "AliAnalysisTaskChargedHadronSpectra.h"
62 ClassImp(AliAnalysisTaskChargedHadronSpectra)
64 //________________________________________________________________________
65 AliAnalysisTaskChargedHadronSpectra::AliAnalysisTaskChargedHadronSpectra()
66 : AliAnalysisTaskSE("TaskChargedHadron"), fESD(0), fListHist(0), fESDtrackCuts(0),fPidObject(0),
75 fHistPtEtaKaonNoKink(0),
77 fHistPtEtaProtonDCA(0),
79 fHistPtEtaElectron(0),
81 fHistClassicProton(0),
83 fHistClassicElectron(0),
85 fHistTrackPerEvent(0),
86 fHistTrackPerEventMC(0),
98 // default Constructor
102 //________________________________________________________________________
103 AliAnalysisTaskChargedHadronSpectra::AliAnalysisTaskChargedHadronSpectra(const char *name)
104 : AliAnalysisTaskSE(name), fESD(0), fListHist(0), fESDtrackCuts(0),fPidObject(0),
110 fHistPtMCElectron(0),
113 fHistPtEtaKaonNoKink(0),
115 fHistPtEtaProtonDCA(0),
117 fHistPtEtaElectron(0),
119 fHistClassicProton(0),
121 fHistClassicElectron(0),
123 fHistTrackPerEvent(0),
124 fHistTrackPerEventMC(0),
130 fHistEffProtonDCA(0),
137 // standard constructur which should be used - PID objects is initialized
140 fMCtrue = kTRUE; // change two things for processing real data: 1. set this to false! / 2. change ALEPH parameters
141 fAlephParameters[0] = 4.23232575531564326e+00;//50*0.76176e-1;
142 fAlephParameters[1] = 8.68482806165147636e+00;//10.632;
143 fAlephParameters[2] = 1.34000000000000005e-05;//0.13279e-4;
144 fAlephParameters[3] = 2.30445734159456084e+00;//1.8631;
145 fAlephParameters[4] = 2.25624744086878559e+00;//1.9479;
147 fPidObject = new AliTPCpidESD();
148 fPidObject->SetBetheBlochParameters(fAlephParameters[0]/50.,fAlephParameters[1],fAlephParameters[2],fAlephParameters[3],fAlephParameters[4]);
151 Printf("*** CONSTRUCTOR CALLED ****");
152 // Define input and output slots here
153 // Input slot #0 works with a TChain
154 //DefineInput(0, TChain::Class()); <-> not needed in AliAnalysisTaskSE
156 // Output slot #0 writes into a TList container
157 DefineOutput(1, TList::Class());
164 //________________________________________________________________________
165 void AliAnalysisTaskChargedHadronSpectra::UserCreateOutputObjects()
169 fListHist = new TList();
170 //fListHist->SetOwner(); // Whoever knows how the data handling is ...?
172 const Int_t kPtBins = 2*56;
173 const Double_t kPtMax = 16.0;
174 const Int_t kEtaBins = 4;
175 const Double_t kEtaMax = 0.8;
176 const Int_t kDeDxBins = 200;
177 const Double_t kDeDxMax = 1;
178 const Int_t kMultBins = 10;
179 const Int_t kMultMax = 300;
182 Double_t binsPtDummy[kPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, -0.05, -0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7, -0.75, -0.8, -0.85, -0.9, -0.95, -1.0, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2.0, -2.2, -2.4, -2.6, -2.8, -3.0, -3.2, -3.4, -3.6, -3.8, -4.0, -4.5, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0};
183 Int_t indexes[kPtBins+1];
184 TMath::Sort(kPtBins+1,binsPtDummy,indexes,kFALSE);
185 Double_t binsPt[kPtBins+1];
186 for(Int_t i=0; i<kPtBins+1; i++) binsPt[i] = binsPtDummy[indexes[i]];
190 fHistPtMCKaon = new TH3F("HistPtMCKaon", "PtEtaKaon; mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
191 fHistPtMCProton = new TH3F("HistPtMCProton", "PtEtaProton;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
192 fHistPtMCPion = new TH3F("HistPtMCPion", "PtEtaPion;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
193 fHistPtMCElectron = new TH3F("HistPtMCElectron", "PtEtaElectron;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
194 fHistPtMCMuon = new TH3F("HistPtMCMuon", "PtEtaMuon;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
196 fHistPtMCKaon->GetZaxis()->Set(kPtBins, binsPt);
197 fHistPtMCProton->GetZaxis()->Set(kPtBins, binsPt);
198 fHistPtMCPion->GetZaxis()->Set(kPtBins, binsPt);
199 fHistPtMCElectron->GetZaxis()->Set(kPtBins, binsPt);
200 fHistPtMCMuon->GetZaxis()->Set(kPtBins, binsPt);
202 fListHist->Add(fHistPtMCKaon);
203 fListHist->Add(fHistPtMCProton);
204 fListHist->Add(fHistPtMCPion);
205 fListHist->Add(fHistPtMCElectron);
206 fListHist->Add(fHistPtMCMuon);
208 // reconstructed particle histograms
209 fHistPtEtaKaon = new TH3F("HistPtEtaKaon", "PtEtaKaon;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
210 fHistPtEtaKaonNoKink = new TH3F("HistPtEtaKaonNoKink", "PtEtaKaonNoKink;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
211 fHistPtEtaProton = new TH3F("HistPtEtaProton", "PtEtaProton;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
212 fHistPtEtaProtonDCA = new TH3F("HistPtEtaProtonDCA", "PtEtaProton;DCA (cm); #eta; p_{T} (GeV)",200,0,15,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
213 fHistPtEtaPion = new TH3F("HistPtEtaPion", "PtEtaPion;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
214 fHistPtEtaElectron = new TH3F("HistPtEtaElectron", "PtEtaElectron;mult; #eta; p_{T} (GeV)",kMultBins,-0.5,kMultMax,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
216 fHistPtEtaKaon->GetZaxis()->Set(kPtBins, binsPt);
217 fHistPtEtaKaonNoKink->GetZaxis()->Set(kPtBins, binsPt);
218 fHistPtEtaProton->GetZaxis()->Set(kPtBins, binsPt);
219 fHistPtEtaProtonDCA->GetZaxis()->Set(kPtBins, binsPt);
220 fHistPtEtaPion->GetZaxis()->Set(kPtBins, binsPt);
221 fHistPtEtaElectron->GetZaxis()->Set(kPtBins, binsPt);
223 fListHist->Add(fHistPtEtaKaon);
224 fListHist->Add(fHistPtEtaKaonNoKink);
225 fListHist->Add(fHistPtEtaProton);
226 fListHist->Add(fHistPtEtaProtonDCA);
227 fListHist->Add(fHistPtEtaPion);
228 fListHist->Add(fHistPtEtaElectron);
230 // histograms for the classical analysis
231 fHistClassicKaon = new TH3F("HistClassicKaon", "PtEtaKaon;p_{T} (GeV);#eta;delta dEdx",kPtBins,-kPtMax,kPtMax,kEtaBins,0,kEtaMax,kDeDxBins,-kDeDxMax,kDeDxMax);
232 fHistClassicProton = new TH3F("HistClassicProton", "PtEtaProton;p_{T} (GeV);#eta;delta dEdx",kPtBins,-kPtMax,kPtMax,kEtaBins,0,kEtaMax,kDeDxBins,-kDeDxMax,kDeDxMax);
233 fHistClassicPion = new TH3F("HistClassicPion", "PtEtaPion;p_{T} (GeV);#eta;delta dEdx",kPtBins,-kPtMax,kPtMax,kEtaBins,0,kEtaMax,kDeDxBins,-kDeDxMax,kDeDxMax);
234 fHistClassicElectron = new TH3F("HistClassicElectron", "PtEtaElectron;p_{T} (GeV);#eta;delta dEdx",kPtBins,-kPtMax,kPtMax,kEtaBins,0,kEtaMax,kDeDxBins,-kDeDxMax,kDeDxMax);
236 fHistClassicKaon->GetXaxis()->Set(kPtBins, binsPt);
237 fHistClassicProton->GetXaxis()->Set(kPtBins, binsPt);
238 fHistClassicPion->GetXaxis()->Set(kPtBins, binsPt);
239 fHistClassicElectron->GetXaxis()->Set(kPtBins, binsPt);
241 fListHist->Add(fHistClassicKaon);
242 fListHist->Add(fHistClassicProton);
243 fListHist->Add(fHistClassicPion);
244 fListHist->Add(fHistClassicElectron);
246 // histograms of general interest
247 fDeDx = new TH2F("DeDx","dEdx; momentum p (GeV); TPC signal (a.u.)",500,0.01,20.,1000,0.,500);
249 fListHist->Add(fDeDx);
250 fHistTrackPerEvent = new TH1F("HistTrackPerEvent", "Tracks per event;Number of Tracks;Number of Events",101,-0.5,100);
251 fListHist->Add(fHistTrackPerEvent);
252 fHistTrackPerEventMC = new TH2F("HistTrackPerEventMC", "Tracks per event;Number of Tracks;Number of Events",10,-0.5,9,101,-0.5,100);
253 fListHist->Add(fHistTrackPerEventMC);
254 fSecProtons = new TH2F("SecProtons", "xy;x;y",100,-10,10,100,-10,10);
255 fListHist->Add(fSecProtons);
256 fVertexZ = new TH1F("VertexZ", "vertex position;z (cm);counts",200,-50,50);
257 fListHist->Add(fVertexZ);
259 fHistEtaNcls = new TH2F("HistEtaNcls", "EtaNcls;#eta;Ncls",100,-1.5,1.5,80,0,160);
260 fListHist->Add(fHistEtaNcls);
261 fHistEtaPhi = new TH2F("HistEtaPhi", "EtaNcls;#eta;#phi",100,-1.5,1.5,100,0,2*TMath::Pi());
262 fListHist->Add(fHistEtaPhi);
264 // histograms for a refined efficiency study
265 fHistEffProton = new TH3F("HistEffProton", "Eff;p_{T} (GeV); code",10,-0.5,9.5,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
266 fListHist->Add(fHistEffProton);
267 fHistEffProtonDCA = new TH3F("HistEffProtonDCA", "Eff;p_{T} (GeV); code",10,-0.5,9.5,200,0,15,kPtBins,-kPtMax,kPtMax);
268 fListHist->Add(fHistEffProtonDCA);
269 fHistEffPion = new TH3F("HistEffPion", "Eff;p_{T} (GeV); code",10,-0.5,9.5,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
270 fListHist->Add(fHistEffPion);
271 fHistEffKaon = new TH3F("HistEffKaon", "Eff;p_{T} (GeV); code",10,-0.5,9.5,kEtaBins,0,kEtaMax,kPtBins,-kPtMax,kPtMax);
272 fListHist->Add(fHistEffKaon);
274 fHistEffProton->GetZaxis()->Set(kPtBins, binsPt);
275 fHistEffProtonDCA->GetZaxis()->Set(kPtBins, binsPt);
276 fHistEffPion->GetZaxis()->Set(kPtBins, binsPt);
277 fHistEffKaon->GetZaxis()->Set(kPtBins, binsPt);
281 // histograms for dN/dpT
282 fHighPtElectrons = new TH1F("HistHighPtElectrons", "backgr;p_{T} (GeV); electron contamination (%)",15,2,15);
283 fListHist->Add(fHighPtElectrons);
284 fHighPtHadrons = new TH1F("HistHighPtHadrons", "backgr;p_{T} (GeV); electron contamination (%)",15,2,15);
285 fListHist->Add(fHighPtHadrons);
288 // Create Objects which are needed for the rest of the analysis
290 fESDtrackCuts = new AliESDtrackCuts("AliESDtrackCuts","AliESDtrackCuts");
291 fESDtrackCuts->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2); // BEWARE STANDARD VALUES ARE: 2, 2, 0.5, 0.5, 2
292 fESDtrackCuts->SetMaxNsigmaToVertex(3);
293 fESDtrackCuts->SetRequireSigmaToVertex(kTRUE);
294 fESDtrackCuts->SetRequireTPCRefit(kFALSE);
295 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
296 fESDtrackCuts->SetMinNClustersTPC(100);
297 fESDtrackCuts->SetMaxChi2PerClusterTPC(3.5);
298 //fESDtrackCuts->SetMaxDCAToVertex(3);
300 fListHist->Add(fESDtrackCuts);
306 //________________________________________________________________________
307 void AliAnalysisTaskChargedHadronSpectra::UserExec(Option_t *)
311 AliLog::SetGlobalLogLevel(AliLog::kError);
313 // Check Monte Carlo information and other access first:
315 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
317 //Printf("ERROR: Could not retrieve MC event handler");
321 AliMCEvent* mcEvent = eventHandler->MCEvent();
323 //Printf("ERROR: Could not retrieve MC event");
327 fESD = dynamic_cast<AliESDEvent*>( InputEvent() );
329 //Printf("ERROR: fESD not available");
333 if (!fESDtrackCuts) {
334 Printf("ERROR: fESDtrackCuts not available");
338 Int_t trackCounter = 0;
340 // monitor vertex position
341 const AliESDVertex *vertex = fESD->GetPrimaryVertexTPC();
343 fHistTrackPerEvent->Fill(trackCounter);
344 PostData(1, fListHist);
347 if (vertex->GetZv() != 0) fVertexZ->Fill(vertex->GetZv());
348 if (TMath::Abs(vertex->GetZv()) > 10) {
349 fHistTrackPerEvent->Fill(trackCounter);
350 PostData(1, fListHist);
357 // 1st track loop to determine multiplicities
358 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
359 AliESDtrack *track = AliESDtrackCuts::GetTPCOnlyTrack(fESD,i);
360 if (!track) continue;
361 if (fESDtrackCuts->AcceptTrack(track) && TMath::Abs(track->Eta())< 0.9) {
370 AliStack* stack = mcEvent->Stack();
376 AliHeader * header = mcEvent->Header();
377 Int_t processtype = GetPythiaEventProcessType(header);
379 if (processtype !=92 && processtype !=93 && processtype != 94) fHistTrackPerEventMC->Fill(1., trackCounter);
380 // single diffractive
381 if ((processtype == 92 || processtype == 93)) fHistTrackPerEventMC->Fill(2., trackCounter);
382 // double diffractive
383 if (processtype == 94) fHistTrackPerEventMC->Fill(3., trackCounter);
385 Int_t mult = trackCounter;//stack->GetNprimary();
386 fHistTrackPerEventMC->Fill(0., trackCounter);
388 for(Int_t i = 0; i < stack->GetNtrack(); i++) {
389 TParticle * trackMC = stack->Particle(i);
390 Int_t pdg = trackMC->GetPdgCode();
392 Double_t xv = trackMC->Vx();
393 Double_t yv = trackMC->Vy();
394 Double_t zv = trackMC->Vz();
396 dxy = TMath::Sqrt(xv*xv + yv*yv); // so stupid to avoid warnings
398 dz = TMath::Abs(zv); // so stupid to avoid warnings
400 // vertex cut - selection of primaries
402 //if (dxy > 3 || dz > 10) continue; // fixed cut at 3cm in r
403 if (pdg == 11) fHistPtMCElectron->Fill(mult, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // select e- only; before vertex
404 if (pdg == -11) fHistPtMCElectron->Fill(mult, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // select e+ only; before vertex
406 if (!stack->IsPhysicalPrimary(i)) continue;
408 if (pdg == 321) fHistPtMCKaon->Fill(mult, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // select K+ only
409 if (pdg == 211) fHistPtMCPion->Fill(mult, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // select Pi+ only
410 if (pdg == 2212) fHistPtMCProton->Fill(mult, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // select p+ only
411 if (pdg == -13) fHistPtMCMuon->Fill(mult, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // select mu+ only
413 if (pdg == -321) fHistPtMCKaon->Fill(mult, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // select K- only
414 if (pdg == -211) fHistPtMCPion->Fill(mult, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // select Pi- only
415 if (pdg == -2212) fHistPtMCProton->Fill(mult, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // select p- only
416 if (pdg == 13) fHistPtMCMuon->Fill(mult, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // select mu- only
418 // special Kaon checks - those which decay before entering the TPC fiducial volume
420 if (TMath::Abs(pdg)==321) {
421 TParticle * trackDaughterMC = stack->Particle(TMath::Abs(trackMC->GetFirstDaughter()));
422 Int_t pdgDaughter = trackDaughterMC->GetPdgCode();
423 if (pdgDaughter == TMath::Abs(13) && pdg == 321) fHistEffKaon->Fill(5, TMath::Abs(trackMC->Eta()), trackMC->Pt()); // Kaon control hist
424 if (pdgDaughter == TMath::Abs(13) && pdg == -321) fHistEffKaon->Fill(5, TMath::Abs(trackMC->Eta()), -trackMC->Pt()); // Kaon control hist
433 // definition of PID functions --> to be put to CreateOutputObjects()
435 TF1 foProton("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.93827,[0],[1],[2],[3],[4])",0.05,20);
436 TF1 foPion("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.13957,[0],[1],[2],[3],[4])",0.05,20);
437 TF1 foElec("foElec", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.05,20);
438 TF1 foKaon("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.493677,[0],[1],[2],[3],[4])",0.05,20);
439 TF1 foMuon("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.105658,[0],[1],[2],[3],[4])",0.05,20);
441 foProton.SetParameters(fAlephParameters);
442 foPion.SetParameters(fAlephParameters);
443 foElec.SetParameters(fAlephParameters);
444 foKaon.SetParameters(fAlephParameters);
445 foMuon.SetParameters(fAlephParameters);
447 const Float_t k2sigmaCorr = 1/0.9545;
449 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z for the vertex cut
451 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
453 // 1. select TPC tracks only and propagate them to the primary vertex determined with the TPC standalone
455 AliESDtrack *track = AliESDtrackCuts::GetTPCOnlyTrack(fESD,i);
456 if (!track) continue;
457 AliESDtrack *trackDummy = fESD->GetTrack(i);
458 if (!trackDummy->GetInnerParam()) { // DEBUG DEBUG
462 AliExternalTrackParam trackIn(*trackDummy->GetInnerParam());
463 Double_t ptot = trackIn.GetP(); // momentum for dEdx determination
464 Double_t pT = track->Pt();
465 Double_t eta = TMath::Abs(track->Eta());
467 fHistEtaNcls->Fill(track->Eta(),track->GetTPCNcls());
468 fHistEtaPhi->Fill(track->Eta(),track->Phi());
469 // cut for dead regions in the detector
470 // if (track->Eta() > 0.1 && (track->Eta() < 0.2 && track->Phi() > 0.1 && track->Phi() < 0.1) continue;
472 // 2.a) apply some standard track cuts according to general recommendations
475 if (!fESDtrackCuts->AcceptTrack(track)) {
478 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
479 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
480 if (pdg == 321 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) fHistEffKaon->Fill(6,eta,track->GetSign()*pT); // Kaon control hist
490 Double_t sign = track->GetSign();
492 Double_t tpcSignal = track->GetTPCsignal();
494 fDeDx->Fill(ptot, tpcSignal);
498 fHistClassicKaon->Fill(sign*pT,eta,(tpcSignal-foKaon.Eval(ptot))/foKaon.Eval(ptot));
499 fHistClassicProton->Fill(sign*pT,eta,(tpcSignal-foProton.Eval(ptot))/foProton.Eval(ptot));
500 fHistClassicPion->Fill(sign*pT,eta,(tpcSignal-foPion.Eval(ptot))/foPion.Eval(ptot));
501 fHistClassicElectron->Fill(sign*pT,eta,(tpcSignal-foElec.Eval(ptot))/foElec.Eval(ptot));
503 // fill histograms for dNdpT
506 fHighPtHadrons->Fill(pT);
507 Double_t delta = (tpcSignal - foElec.Eval(ptot))/foElec.Eval(ptot);
508 if (delta > 0) fHighPtElectrons->Fill(pT);
511 /* 2sigma PID with 2sigma eff correction! */
513 if (TMath::Abs(fPidObject->GetNumberOfSigmas(track,AliPID::kPion)) < 2) {
514 fHistPtEtaPion->Fill(trackCounter, eta, sign*pT, k2sigmaCorr);
516 if (trackCounter < 300 && fMCtrue) {
517 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
518 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
519 if (pdg == 211 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) fHistEffPion->Fill(0,eta,sign*pT,k2sigmaCorr);
520 if (pdg == 211 && !stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) {
521 fHistEffPion->Fill(1,eta,sign*pT,k2sigmaCorr);
522 TParticle *trackMother = stack->Particle(trackMC->GetFirstMother());
523 Int_t code = TMath::Abs(trackMother->GetPdgCode());
524 if (code==3122||code==3222||code==3212||code==3112||code==3322||code==3312||code==3332||code==130||code==310) fHistEffPion->Fill(3,eta,sign*pT,k2sigmaCorr);
526 if (TMath::Abs(trackMC->GetPdgCode()) != 211) fHistEffPion->Fill(2,eta,sign*pT,k2sigmaCorr);
527 if (TMath::Abs(trackMC->GetPdgCode()) == 13) fHistEffPion->Fill(4,eta,sign*pT,k2sigmaCorr);
531 if (TMath::Abs(fPidObject->GetNumberOfSigmas(track,AliPID::kKaon)) < 2) {
532 fHistPtEtaKaon->Fill(trackCounter, eta, sign*pT, k2sigmaCorr);
534 if (trackCounter < 300 && fMCtrue) {
535 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
536 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
537 if (pdg == 321 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) fHistEffKaon->Fill(0,eta,sign*pT,k2sigmaCorr);
538 if (pdg == 321 && !stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) {
539 fHistEffKaon->Fill(1,eta,sign*pT,k2sigmaCorr);
540 TParticle *trackMother = stack->Particle(trackMC->GetFirstMother());
541 Int_t code = TMath::Abs(trackMother->GetPdgCode());
542 if (code==3122||code==3222||code==3212||code==3112||code==3322||code==3312||code==3332||code==130||code==310) fHistEffKaon->Fill(3,eta,sign*pT,k2sigmaCorr);
544 if (TMath::Abs(trackMC->GetPdgCode()) != 321) fHistEffKaon->Fill(2,eta,sign*pT,k2sigmaCorr);
548 if (TMath::Abs(fPidObject->GetNumberOfSigmas(track,AliPID::kKaon)) < 2 && track->GetKinkIndex(0)==0) fHistPtEtaKaonNoKink->Fill(trackCounter, eta, sign*pT, k2sigmaCorr);
550 if (TMath::Abs(fPidObject->GetNumberOfSigmas(track,AliPID::kProton)) < 2) {
551 fHistPtEtaProton->Fill(trackCounter, eta, sign*pT, k2sigmaCorr);
553 track->GetImpactParameters(dca,cov);
554 Float_t primVtxDCA = TMath::Sqrt(dca[0]*dca[0] + dca[1]*dca[1]);
555 fHistPtEtaProtonDCA->Fill(primVtxDCA, eta, sign*pT, k2sigmaCorr);
557 if (trackCounter < 300 && fMCtrue) {
558 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
559 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
560 if (pdg == 2212 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) {
561 fHistEffProton->Fill(0.,eta,sign*pT,k2sigmaCorr);
562 if (eta < 0.15) fHistEffProtonDCA->Fill(0.,primVtxDCA,sign*pT,k2sigmaCorr);
564 if (pdg == 2212 && !stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) {
565 fHistEffProton->Fill(1,eta,sign*pT,k2sigmaCorr);
566 if (eta < 0.15) fHistEffProtonDCA->Fill(1,primVtxDCA,sign*pT,k2sigmaCorr);
567 TParticle *trackMother = stack->Particle(trackMC->GetFirstMother());
568 Int_t code = TMath::Abs(trackMother->GetPdgCode());
569 if (code==3122||code==3222||code==3212||code==3112||code==3322||code==3312||code==3332||code==130||code==310) {
570 fHistEffProton->Fill(3,eta,sign*pT,k2sigmaCorr);
571 if (eta < 0.15) fHistEffProtonDCA->Fill(3,primVtxDCA,sign*pT,k2sigmaCorr);
573 if (code!=3122&&code!=3222&&code!=3212&&code!=3112&&code!=3322&&code!=3312&&code!=3332&&code!=130&&code!=310) fSecProtons->Fill(trackMC->Vx(),trackMC->Vy());
575 if (TMath::Abs(trackMC->GetPdgCode()) != 2212) fHistEffProton->Fill(2,eta,sign*pT,k2sigmaCorr);
579 if (TMath::Abs(fPidObject->GetNumberOfSigmas(track,AliPID::kElectron))) fHistPtEtaElectron->Fill(trackCounter, eta, sign*pT, k2sigmaCorr);
583 } // end of track loop
585 fHistTrackPerEvent->Fill(trackCounter);
590 PostData(1, fListHist);
595 //________________________________________________________________________
596 void AliAnalysisTaskChargedHadronSpectra::Terminate(Option_t *)
598 // Draw result to the screen
599 // Called once at the end of the query
600 cout << "*** TERMINATE ***" << endl;
607 //________________________________________________________________________
608 void AliAnalysisTaskChargedHadronSpectra::BinLogX(const TH1 *h) {
610 // Method for the correct logarithmic binning of histograms
612 TAxis *axis = h->GetXaxis();
613 int bins = axis->GetNbins();
615 Double_t from = axis->GetXmin();
616 Double_t to = axis->GetXmax();
617 Double_t *newBins = new Double_t[bins + 1];
620 Double_t factor = pow(to/from, 1./bins);
622 for (int i = 1; i <= bins; i++) {
623 newBins[i] = factor * newBins[i-1];
625 axis->Set(bins, newBins);
631 //________________________________________________________________________
632 Int_t AliAnalysisTaskChargedHadronSpectra::GetPythiaEventProcessType(const AliHeader* aHeader, const Bool_t adebug) const {
634 // get the process type of the event.
637 // can only read pythia headers, either directly or from cocktalil header
638 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
640 if (!pythiaGenHeader) {
642 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
643 if (!genCocktailHeader) {
644 //printf("AliAnalysisTaskChargedHadronSpectra::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
648 TList* headerList = genCocktailHeader->GetHeaders();
653 for (Int_t i=0; i<headerList->GetEntries(); i++) {
654 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
659 if (!pythiaGenHeader) {
660 //printf("AliAnalysisTaskChargedHadronSpectra::GetProcessType : Could not find Pythia header. \n");
666 //printf("AliAnalysisTaskChargedHadronSpectra::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
669 return pythiaGenHeader->ProcessType();
673 //________________________________________________________________________
674 TH1D * AliAnalysisTaskChargedHadronSpectra::AnalyseClassicProton(const TH3F * input, Int_t EtaBin, const Double_t * AlephParams) {
676 // The multiple Gauss fitting is happening here...
677 // input histogram is of the form (Pt, eta, difference in dEdx)
680 TF1 *foProton = new TF1("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.93827,[0],[1],[2],[3],[4])",0.05,20);
681 TF1 *foPion = new TF1("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.13957,[0],[1],[2],[3],[4])",0.05,20);
682 TF1 *foElec = new TF1("foElec", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.05,20);
683 TF1 *foKaon = new TF1("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.493677,[0],[1],[2],[3],[4])",0.05,20);
684 TF1 *foMuon = new TF1("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.105658,[0],[1],[2],[3],[4])",0.05,20);
686 foProton->SetParameters(AlephParams);
687 foPion->SetParameters(AlephParams);
688 foElec->SetParameters(AlephParams);
689 foKaon->SetParameters(AlephParams);
690 foMuon->SetParameters(AlephParams);
693 const Double_t kSigma = 0.06; // expected resolution (roughly)
695 const Int_t kPtBins = 2*56/*input->GetXaxis()->GetNbins()*/;
696 const Double_t kPtMax = input->GetXaxis()->GetXmax();
697 const Int_t kEtaBins = input->GetYaxis()->GetNbins();
699 TH1D * histPt = new TH1D("histPt", "Pt; pT (Gev); dN",kPtBins,-kPtMax,kPtMax);
701 Double_t binsPtDummy[kPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, -0.05, -0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7, -0.75, -0.8, -0.85, -0.9, -0.95, -1.0, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2.0, -2.2, -2.4, -2.6, -2.8, -3.0, -3.2, -3.4, -3.6, -3.8, -4.0, -4.5, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0};
702 Int_t indexes[kPtBins+1];
703 TMath::Sort(kPtBins+1,binsPtDummy,indexes,kFALSE);
704 Double_t binsPt[kPtBins+1];
705 for(Int_t i=0; i<kPtBins+1; i++) binsPt[i] = binsPtDummy[indexes[i]];
706 histPt->GetXaxis()->Set(kPtBins, binsPt);
709 TCanvas * canvMany = new TCanvas("canvManyProton","canvManyProton");
710 canvMany->Print("canvManyProton.ps[");
712 for(Int_t x=1; x < kPtBins+1; x++) {
713 Double_t pT = input->GetXaxis()->GetBinCenter(x);
714 for(Int_t y=1; y < kEtaBins+1; y++) {
715 Double_t eta = input->GetYaxis()->GetBinCenter(y);
716 Double_t theta = 2*TMath::ATan(TMath::Exp(-eta));
717 Double_t ptot = TMath::Abs(pT/TMath::Sin(theta));
718 TH1D *histDeDx = input->ProjectionZ(Form("dedx_%i_%i",x,y),x,x,y,y);
719 histDeDx->SetTitle(Form("pt_%f",pT));
720 Float_t maxYield = histDeDx->GetEntries()/(TMath::Sqrt(2*TMath::Pi())*0.04/histDeDx->GetBinWidth(1));
722 TF1 * gausFit = new TF1("gausFit", "gaus(0) + gaus(3) + gaus(6) + gaus(9)",-1/*-7*kSigma*/,1/*7*kSigma*/);
723 Double_t parameters[12] = {maxYield/2.,0,kSigma,maxYield/2.,(foPion->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot),kSigma,maxYield/2.,(foElec->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot),kSigma,maxYield/2.,(foKaon->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot),kSigma};
724 gausFit->SetParameters(parameters);
725 gausFit->SetParLimits(0,0.,maxYield);
726 gausFit->SetParLimits(1,-0.05,0.05);
727 gausFit->SetParLimits(2,0.04,0.08);
729 Double_t pionPosition = (foPion->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot);
730 gausFit->SetParLimits(0,0.,maxYield);
731 gausFit->SetParLimits(4, 0.95*pionPosition, 1.05*pionPosition);
732 gausFit->SetParLimits(5,0.8*kSigma*(foPion->Eval(ptot)/foProton->Eval(ptot)),1.2*kSigma*(foPion->Eval(ptot)/foProton->Eval(ptot)));
734 Double_t elecPosition = (foElec->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot);
735 gausFit->SetParLimits(0,0.,maxYield);
736 gausFit->SetParLimits(7, 0.95*elecPosition, 1.05*elecPosition);
737 gausFit->SetParLimits(8,0.8*kSigma*(foElec->Eval(ptot)/foProton->Eval(ptot)),1.2*kSigma*(foElec->Eval(ptot)/foProton->Eval(ptot)));
739 Double_t kaonPosition = (foKaon->Eval(ptot)-foProton->Eval(ptot))/foProton->Eval(ptot);
740 gausFit->SetParLimits(0,0.,maxYield);
741 gausFit->SetParLimits(10, 0.95*kaonPosition, 1.05*kaonPosition);
742 gausFit->SetParLimits(11,0.8*kSigma*(foKaon->Eval(ptot)/foProton->Eval(ptot)),1.2*kSigma*(foKaon->Eval(ptot)/foProton->Eval(ptot)));
743 histDeDx->Fit("gausFit","QNR");
744 gausFit->GetParameters(parameters);
749 histDeDx->SetMarkerStyle(21);
750 histDeDx->SetMarkerSize(0.7);
752 gausFit->SetLineWidth(2);
753 gausFit->Draw("same");
755 TF1 gausFit0("gausFit0", "gaus(0)",-1,1);
756 TF1 gausFit1("gausFit1", "gaus(0)",-1,1);
757 TF1 gausFit2("gausFit2", "gaus(0)",-1,1);
758 TF1 gausFit3("gausFit3", "gaus(0)",-1,1);
759 gausFit0.SetParameters(parameters[0],parameters[1],parameters[2]);
760 gausFit1.SetParameters(parameters[3],parameters[4],parameters[5]);
761 gausFit2.SetParameters(parameters[6],parameters[7],parameters[8]);
762 gausFit3.SetParameters(parameters[9],parameters[10],parameters[11]);
764 gausFit0.SetLineColor(4);
765 gausFit1.SetLineColor(2);
766 gausFit2.SetLineColor(6);
767 gausFit3.SetLineColor(8);
769 gausFit0.SetLineWidth(1);
770 gausFit1.SetLineWidth(1);
771 gausFit2.SetLineWidth(1);
772 gausFit3.SetLineWidth(1);
774 gausFit0.Draw("same");
775 gausFit1.Draw("same");
776 gausFit2.Draw("same");
777 gausFit3.Draw("same");
778 canvMany->Print("canvManyProton.ps");
781 Double_t yield = gausFit->GetParameter(0)*TMath::Sqrt(2*TMath::Pi())*gausFit->GetParameter(2)/histDeDx->GetBinWidth(1); // area of the gaus fit
784 // stupid solution --> remove as soon as possible
786 TF1 * gausYield = new TF1("gausYield", "gaus(0)",-5*kSigma,5*kSigma);
787 gausYield->SetParameters(gausFit->GetParameter(0),gausFit->GetParameter(1),gausFit->GetParameter(2));
788 for(Int_t i=1; i < histDeDx->GetXaxis()->GetNbins(); i++) {
789 Double_t delta = histDeDx->GetXaxis()->GetBinCenter(i);
790 yield += gausYield->Eval(delta);
793 if (y == EtaBin && yield > 0) histPt->Fill(pT,yield);
797 canvMany->Print("canvManyProton.ps]");
799 TCanvas * canvPt = new TCanvas();
808 //________________________________________________________________________
809 TH1D * AliAnalysisTaskChargedHadronSpectra::AnalyseClassicPion(const TH3F * input, Int_t EtaBin,const Double_t * AlephParams) {
811 // The multiple Gauss fitting is happening here...
814 TF1 *foProton = new TF1("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.93827,[0],[1],[2],[3],[4])",0.05,20);
815 TF1 *foPion = new TF1("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.13957,[0],[1],[2],[3],[4])",0.05,20);
816 TF1 *foElec = new TF1("foElec", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.05,20);
817 TF1 *foKaon = new TF1("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.493677,[0],[1],[2],[3],[4])",0.05,20);
818 TF1 *foMuon = new TF1("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.105658,[0],[1],[2],[3],[4])",0.05,20);
820 foProton->SetParameters(AlephParams);
821 foPion->SetParameters(AlephParams);
822 foElec->SetParameters(AlephParams);
823 foKaon->SetParameters(AlephParams);
824 foMuon->SetParameters(AlephParams);
826 // input histogram is of the form (Pt, eta, difference in dEdx)
828 const Double_t kSigma = 0.06; // expected resolution (roughly)
830 const Int_t kPtBins = 2*56/*input->GetXaxis()->GetNbins()*/;
831 const Double_t kPtMax = input->GetXaxis()->GetXmax();
832 const Int_t kEtaBins = input->GetYaxis()->GetNbins();
834 TH1D * histPt = new TH1D("histPt", "Pt; pT (Gev); dN",kPtBins,-kPtMax,kPtMax);
836 Double_t binsPtDummy[kPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, -0.05, -0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7, -0.75, -0.8, -0.85, -0.9, -0.95, -1.0, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2.0, -2.2, -2.4, -2.6, -2.8, -3.0, -3.2, -3.4, -3.6, -3.8, -4.0, -4.5, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0};
837 Int_t indexes[kPtBins+1];
838 TMath::Sort(kPtBins+1,binsPtDummy,indexes,kFALSE);
839 Double_t binsPt[kPtBins+1];
840 for(Int_t i=0; i<kPtBins+1; i++) binsPt[i] = binsPtDummy[indexes[i]];
841 histPt->GetXaxis()->Set(kPtBins, binsPt);
844 TCanvas * canvMany = new TCanvas();
845 canvMany->Divide(8,5);
847 for(Int_t x=1; x < kPtBins+1; x++) {
848 Double_t pT = input->GetXaxis()->GetBinCenter(x);
849 for(Int_t y=1; y < kEtaBins+1; y++) {
850 Double_t eta = input->GetYaxis()->GetBinCenter(y);
851 Double_t theta = 2*TMath::ATan(TMath::Exp(-eta));
852 Double_t ptot = TMath::Abs(pT/TMath::Sin(theta));
853 TH1D *histDeDx = input->ProjectionZ(Form("dedx_%i_%i",x,y),x,x,y,y);
855 TF1 * gausFit = new TF1("gausFit", "gaus(0) + gaus(3) + gaus(6) + gaus(9)",-5*kSigma,5*kSigma);
856 //Double_t parameters[12] = {100,0,kSigma,100,TMath::Log(foProton->Eval(ptot)/foPion->Eval(ptot)),kSigma,100,TMath::Log(foElec->Eval(ptot)/foPion->Eval(ptot)),kSigma,100,TMath::Log(foKaon->Eval(ptot)/foPion->Eval(ptot)),kSigma};
857 Double_t parameters[12] = {100,0,kSigma,100,(foProton->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot),kSigma,100,(foElec->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot),kSigma,100,(foKaon->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot),kSigma};
858 gausFit->SetParameters(parameters);
859 gausFit->SetParLimits(1,-0.05,0.05);//gausFit->FixParameter(1,0); DEBUG DEBUG DEBUG
860 gausFit->SetParLimits(2,0.04,0.08);//gausFit->FixParameter(2,kSigma); DEBUG DEBUG DEBUG
862 gausFit->FixParameter(4,(foProton->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot));
863 gausFit->FixParameter(5,kSigma);
864 gausFit->FixParameter(7,(foElec->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot));
865 gausFit->FixParameter(8,kSigma);
866 gausFit->FixParameter(10,(foKaon->Eval(ptot)-foPion->Eval(ptot))/foPion->Eval(ptot));
867 gausFit->FixParameter(11,kSigma);
868 histDeDx->Fit("gausFit","Q0");
869 if (y == EtaBin && pT < 0) {
873 gausFit->Draw("same");
875 Double_t yield = gausFit->GetParameter(0)*TMath::Sqrt(2*TMath::Pi())*gausFit->GetParameter(2); // area of the gaus fit
876 // stupid solution --> remove as soon as possible
878 TF1 * gausYield = new TF1("gausYield", "gaus(0)",-5*kSigma,5*kSigma);
879 gausYield->SetParameters(gausFit->GetParameter(0),gausFit->GetParameter(1),gausFit->GetParameter(2));
880 for(Int_t i=1; i < histDeDx->GetXaxis()->GetNbins(); i++) {
881 Double_t delta = histDeDx->GetXaxis()->GetBinCenter(i);
882 yield += gausYield->Eval(delta);
885 if (y == EtaBin && yield > 0) histPt->Fill(pT,yield);
891 TCanvas * canvPt = new TCanvas();
900 //________________________________________________________________________
901 TH1D * AliAnalysisTaskChargedHadronSpectra::AnalyseClassicKaon(const TH3F * input, Int_t EtaBin,const Double_t * AlephParams) {
903 // The multiple Gauss fitting is happening here...
906 TF1 *foProton = new TF1("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.93827,[0],[1],[2],[3],[4])",0.05,20);
907 TF1 *foPion = new TF1("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.13957,[0],[1],[2],[3],[4])",0.05,20);
908 TF1 *foElec = new TF1("foElec", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.05,20);
909 TF1 *foKaon = new TF1("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.493677,[0],[1],[2],[3],[4])",0.05,20);
910 TF1 *foMuon = new TF1("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.105658,[0],[1],[2],[3],[4])",0.05,20);
912 foProton->SetParameters(AlephParams);
913 foPion->SetParameters(AlephParams);
914 foElec->SetParameters(AlephParams);
915 foKaon->SetParameters(AlephParams);
916 foMuon->SetParameters(AlephParams);
918 const Double_t kSigma = 0.06; // expected resolution (roughly)
920 const Int_t kPtBins = 2*56/*input->GetXaxis()->GetNbins()*/;
921 const Double_t kPtMax = input->GetXaxis()->GetXmax();
922 const Int_t kEtaBins = input->GetYaxis()->GetNbins();
924 TH1D * histPt = new TH1D("histPt", "Pt; pT (Gev); dN",kPtBins,-kPtMax,kPtMax);
926 Double_t binsPtDummy[kPtBins+1] = {0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, -0.05, -0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7, -0.75, -0.8, -0.85, -0.9, -0.95, -1.0, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2.0, -2.2, -2.4, -2.6, -2.8, -3.0, -3.2, -3.4, -3.6, -3.8, -4.0, -4.5, -5.0, -5.5, -6.0, -6.5, -7.0, -7.5, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0};
927 Int_t indexes[kPtBins+1];
928 TMath::Sort(kPtBins+1,binsPtDummy,indexes,kFALSE);
929 Double_t binsPt[kPtBins+1];
930 for(Int_t i=0; i<kPtBins+1; i++) binsPt[i] = binsPtDummy[indexes[i]];
931 histPt->GetXaxis()->Set(kPtBins, binsPt);
934 TCanvas * canvMany = new TCanvas();
935 canvMany->Divide(8,5);
937 for(Int_t x=1; x < kPtBins+1; x++) {
938 Double_t pT = input->GetXaxis()->GetBinCenter(x);
939 for(Int_t y=1; y < kEtaBins+1; y++) {
940 Double_t eta = input->GetYaxis()->GetBinCenter(y);
941 Double_t theta = 2*TMath::ATan(TMath::Exp(-eta));
942 Double_t ptot = TMath::Abs(pT/TMath::Sin(theta));
943 TH1D *histDeDx = input->ProjectionZ(Form("dedx_%i_%i",x,y),x,x,y,y);
945 TF1 * gausFit = new TF1("gausFit", "gaus(0) + gaus(3) + gaus(6) + gaus(9)",-5*kSigma,5*kSigma);
946 //Double_t parameters[12] = {100,0,kSigma,100,TMath::Log(foProton->Eval(ptot)/foKaon->Eval(ptot)),kSigma,100,TMath::Log(foElec->Eval(ptot)/foKaon->Eval(ptot)),kSigma,100,TMath::Log(foPion->Eval(ptot)/foPion->Eval(ptot)),kSigma};
947 Double_t parameters[12] = {100,0,kSigma,100,(foProton->Eval(ptot)-foKaon->Eval(ptot))/foKaon->Eval(ptot),kSigma,100,(foElec->Eval(ptot)-foKaon->Eval(ptot))/foKaon->Eval(ptot),kSigma,100,(foPion->Eval(ptot)-foKaon->Eval(ptot))/foPion->Eval(ptot),kSigma};
948 gausFit->SetParameters(parameters);
949 gausFit->SetParLimits(1,-0.05,0.05);//gausFit->FixParameter(1,0); DEBUG DEBUG DEBUG
950 gausFit->SetParLimits(2,0.04,0.08);//gausFit->FixParameter(2,kSigma); DEBUG DEBUG DEBUG
952 gausFit->FixParameter(4,(foProton->Eval(ptot)-foKaon->Eval(ptot))/foKaon->Eval(ptot));
953 gausFit->FixParameter(5,kSigma);
954 gausFit->FixParameter(7,(foElec->Eval(ptot)-foKaon->Eval(ptot))/foKaon->Eval(ptot));
955 gausFit->FixParameter(8,kSigma);
956 gausFit->FixParameter(10,(foPion->Eval(ptot)- foKaon->Eval(ptot))/foKaon->Eval(ptot));
957 gausFit->FixParameter(11,kSigma);
958 histDeDx->Fit("gausFit","Q0");
959 if (y == EtaBin && pT < 0) {
963 gausFit->Draw("same");
965 Double_t yield = gausFit->GetParameter(0)*TMath::Sqrt(2*TMath::Pi())*gausFit->GetParameter(2); // area of the gaus fit
966 // stupid solution --> remove as soon as possible
968 TF1 * gausYield = new TF1("gausYield", "gaus(0)",-5*kSigma,5*kSigma);
969 gausYield->SetParameters(gausFit->GetParameter(0),gausFit->GetParameter(1),gausFit->GetParameter(2));
970 for(Int_t i=1; i < histDeDx->GetXaxis()->GetNbins(); i++) {
971 Double_t delta = histDeDx->GetXaxis()->GetBinCenter(i);
972 yield += gausYield->Eval(delta);
975 if (y == EtaBin && yield > 0) histPt->Fill(pT,yield);
981 TCanvas * canvPt = new TCanvas();
990 //________________________________________________________________________
991 void AliAnalysisTaskChargedHadronSpectra::Postprocess(const TList * ListOfHistogramsMC,const TList * ListOfHistogramsData, const Char_t *filename) {
994 const Int_t kMultLow = 1;
995 const Int_t kMultHigh = 10;
997 const Int_t kEtaHigh = 4;
999 // Extract histograms for the MC efficiency study
1000 TH3F* histPtMCKaonEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtMCKaon");
1001 TH3F* histPtMCProtonEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtMCProton");
1002 TH3F* histPtMCPionEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtMCPion");
1004 TH3F* histPtEtaKaonEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtEtaKaon");
1005 TH3F* histPtEtaProtonEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtEtaProton");
1006 TH3F* histPtEtaPionEff = ( TH3F *)ListOfHistogramsMC->FindObject("HistPtEtaPion");
1008 TH3F* histEffProton = ( TH3F *)ListOfHistogramsMC->FindObject("HistEffProton");
1009 TH3F* histEffKaon = ( TH3F *)ListOfHistogramsMC->FindObject("HistEffKaon");
1010 TH3F* histEffPion = ( TH3F *)ListOfHistogramsMC->FindObject("HistEffPion");
1012 // Extract data for the final spectra
1013 TH3F* histPtEtaKaon = ( TH3F *)ListOfHistogramsData->FindObject("HistPtEtaKaon");
1014 TH3F* histPtEtaProton = ( TH3F *)ListOfHistogramsData->FindObject("HistPtEtaProton");
1015 TH3F* histPtEtaPion = ( TH3F *)ListOfHistogramsData->FindObject("HistPtEtaPion");
1017 // "MC" of the real data for consistency checks
1018 TH3F* histPtMCKaonData = ( TH3F *)ListOfHistogramsData->FindObject("HistPtMCKaon");
1019 TH3F* histPtMCProtonData = ( TH3F *)ListOfHistogramsData->FindObject("HistPtMCProton");
1020 TH3F* histPtMCPionData = ( TH3F *)ListOfHistogramsData->FindObject("HistPtMCPion");
1022 TFile spectraFile(filename,"RECREATE");
1025 for(Int_t iEta = 1; iEta < kEtaHigh+1; iEta++) {
1026 TH1D *protonRaw = histPtEtaProtonEff->ProjectionZ(Form("ProtonRawTot_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // red crosses
1028 TH1D *protonMC = histPtMCProtonEff->ProjectionZ(Form("McProton_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // solid black line
1030 TH1D *protonRawPrim = histEffProton->ProjectionZ(Form("ProtonRawPrim_%i",iEta),1,1,iEta,iEta); // thin red line
1031 protonRawPrim->Sumw2();
1032 TH1D *protonSecReac = histEffProton->ProjectionZ(Form("ProtonSecReac_%i",iEta),2,2,iEta,iEta); // blue line
1033 protonSecReac->Sumw2();
1034 TH1D *protonSecWeak = histEffProton->ProjectionZ(Form("ProtonSecWeak_%i",iEta),4,4,iEta,iEta); // green line
1035 protonSecWeak->Sumw2();
1036 TH1D *protonMis = histEffProton->ProjectionZ(Form("ProtonMis_%i",iEta),3,3,iEta,iEta); // thin black line
1038 protonSecReac->Add(protonSecWeak,-1);
1040 // 1. total (physical) efficiency
1042 TH1D *protonEffTot = new TH1D(*protonRaw);
1043 protonEffTot->Divide(protonRaw,protonMC);
1044 protonEffTot->SetName(Form("ProtonEffTot_%i",iEta));
1045 protonEffTot->Write();
1047 // 2. contributions from secondaries created by interactions
1049 TH1D *protonEffSecReac = new TH1D(*protonRaw);
1050 TH1D *dummy = new TH1D(*protonRaw);
1051 dummy->Add(protonSecReac,-1);
1052 protonEffSecReac->Divide(protonRaw,dummy);
1053 protonEffSecReac->SetName(Form("ProtonEffSecReac_%i",iEta));
1054 protonEffSecReac->Write();
1057 // 3. contributions from secondaries from weak decays
1059 TH1D *protonEffSecWeak = new TH1D(*protonRaw);
1060 TH1D *dummy2 = new TH1D(*protonRaw);
1061 dummy2->Add(protonSecWeak,-1);
1062 protonEffSecWeak->Divide(protonRaw,dummy2);
1063 protonEffSecWeak->SetName(Form("ProtonEffSecWeak_%i",iEta));
1064 protonEffSecWeak->Write();
1067 // 4. decay (Kaon,pion) and detector absorption (energy loss and multiple scattering)
1069 TH1D *protonEffAbs = new TH1D(*protonRaw);
1070 protonEffAbs->Divide(protonRawPrim,protonMC);
1071 protonEffAbs->SetName(Form("ProtonEffAbs_%i",iEta));
1072 protonEffAbs->Write();
1076 TH1D *protonEffMis = new TH1D(*protonMis);
1077 protonEffMis->Divide(protonMis,protonRaw);
1078 protonEffMis->SetName(Form("ProtonContam_%i",iEta));
1079 protonEffMis->Write();
1082 // PROCESS THE REAL DATA FROM HERE ON
1084 TH1D *histPtProtonEta = histPtEtaProton->ProjectionZ(Form("HistPtProtonEtaRaw_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1085 histPtProtonEta->Write();
1087 // Apply corrections as you would like them to have...
1089 TH1D *protonFinal = new TH1D(*histPtProtonEta);
1090 protonFinal->SetName(Form("HistPtProtonEtaFinal_%i",iEta));
1091 protonFinal->Sumw2();
1092 protonFinal->Divide(protonEffTot); // enable or disable specific corrections here...
1093 protonFinal->Write();
1095 // if available save also the MC truth for consistency checks
1097 TH1D *histPtProtonEtaMcData = histPtMCProtonData->ProjectionZ(Form("HistPtProtonEtaMcData_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1098 histPtProtonEtaMcData->Write();
1102 for(Int_t iEta = 1; iEta < kEtaHigh+1; iEta++) {
1103 TH1D *kaonRaw = histPtEtaKaonEff->ProjectionZ(Form("KaonRawTot_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // red crosses
1105 TH1D *kaonMC = histPtMCKaonEff->ProjectionZ(Form("McKaon_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // solid black line
1107 TH1D *kaonRawPrim = histEffKaon->ProjectionZ(Form("KaonRawPrim_%i",iEta),1,1,iEta,iEta); // thin red line
1108 kaonRawPrim->Sumw2();
1109 TH1D *kaonSecReac = histEffKaon->ProjectionZ(Form("KaonSecReac_%i",iEta),2,2,iEta,iEta); // blue line
1110 kaonSecReac->Sumw2();
1111 TH1D *kaonSecWeak = histEffKaon->ProjectionZ(Form("KaonSecWeak_%i",iEta),4,4,iEta,iEta); // green line
1112 kaonSecWeak->Sumw2();
1113 TH1D *kaonMis = histEffKaon->ProjectionZ(Form("KaonMis_%i",iEta),3,3,iEta,iEta); // thin black line
1115 kaonSecReac->Add(kaonSecWeak,-1);
1117 // 1. total (physical) efficiency
1119 TH1D *kaonEffTot = new TH1D(*kaonRaw);
1120 kaonEffTot->Divide(kaonRaw,kaonMC);
1121 kaonEffTot->SetName(Form("KaonEffTot_%i",iEta));
1122 kaonEffTot->Write();
1124 // 2. contributions from secondaries created by interactions
1126 TH1D *kaonEffSecReac = new TH1D(*kaonRaw);
1127 TH1D *dummy = new TH1D(*kaonRaw);
1128 dummy->Add(kaonSecReac,-1);
1129 kaonEffSecReac->Divide(kaonRaw,dummy);
1130 kaonEffSecReac->SetName(Form("KaonEffSecReac_%i",iEta));
1131 kaonEffSecReac->Write();
1134 // 3. contributions from secondaries from weak decays
1136 TH1D *kaonEffSecWeak = new TH1D(*kaonRaw);
1137 TH1D *dummy2 = new TH1D(*kaonRaw);
1138 dummy2->Add(kaonSecWeak,-1);
1139 kaonEffSecWeak->Divide(kaonRaw,dummy2);
1140 kaonEffSecWeak->SetName(Form("KaonEffSecWeak_%i",iEta));
1141 kaonEffSecWeak->Write();
1144 // 4. decay (Kaon,pion) and detector absorption (energy loss and multiple scattering)
1146 TH1D *kaonEffAbs = new TH1D(*kaonRaw);
1147 kaonEffAbs->Divide(kaonRawPrim,kaonMC);
1148 kaonEffAbs->SetName(Form("KaonEffAbs_%i",iEta));
1149 kaonEffAbs->Write();
1153 TH1D *kaonEffMis = new TH1D(*kaonMis);
1154 kaonEffMis->Divide(kaonMis,kaonRaw);
1155 kaonEffMis->SetName(Form("KaonContam_%i",iEta));
1156 kaonEffMis->Write();
1159 // PROCESS THE REAL DATA FROM HERE ON
1161 TH1D *histPtKaonEta = histPtEtaKaon->ProjectionZ(Form("HistPtKaonEtaRaw_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1162 histPtKaonEta->Write();
1164 // Apply corrections as you would like them to have...
1166 TH1D *kaonFinal = new TH1D(*histPtKaonEta);
1167 kaonFinal->SetName(Form("HistPtKaonEtaFinal_%i",iEta));
1169 kaonFinal->Divide(kaonEffTot); // enable or disable specific corrections here...
1172 // if available save also the MC truth for consistency checks
1174 TH1D *histPtKaonEtaMcData = histPtMCKaonData->ProjectionZ(Form("HistPtKaonEtaMcData_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1175 histPtKaonEtaMcData->Write();
1180 for(Int_t iEta = 1; iEta < kEtaHigh+1; iEta++) {
1181 TH1D *pionRaw = histPtEtaPionEff->ProjectionZ(Form("PionRawTot_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // red crosses
1183 TH1D *pionMC = histPtMCPionEff->ProjectionZ(Form("McPion_%i",iEta),kMultLow,kMultHigh,iEta,iEta); // solid black line
1185 TH1D *pionRawPrim = histEffPion->ProjectionZ(Form("PionRawPrim_%i",iEta),1,1,iEta,iEta); // thin red line
1186 pionRawPrim->Sumw2();
1187 TH1D *pionSecReac = histEffPion->ProjectionZ(Form("PionSecReac_%i",iEta),2,2,iEta,iEta); // blue line
1188 pionSecReac->Sumw2();
1189 TH1D *pionSecWeak = histEffPion->ProjectionZ(Form("PionSecWeak_%i",iEta),4,4,iEta,iEta); // green line
1190 pionSecWeak->Sumw2();
1191 TH1D *pionMis = histEffPion->ProjectionZ(Form("PionMis_%i",iEta),3,3,iEta,iEta); // thin black line
1193 pionSecReac->Add(pionSecWeak,-1);
1195 // 1. total (physical) efficiency
1197 TH1D *pionEffTot = new TH1D(*pionRaw);
1198 pionEffTot->Divide(pionRaw,pionMC);
1199 pionEffTot->SetName(Form("PionEffTot_%i",iEta));
1200 pionEffTot->Write();
1202 // 2. contributions from secondaries created by interactions
1204 TH1D *pionEffSecReac = new TH1D(*pionRaw);
1205 TH1D *dummy = new TH1D(*pionRaw);
1206 dummy->Add(pionSecReac,-1);
1207 pionEffSecReac->Divide(pionRaw,dummy);
1208 pionEffSecReac->SetName(Form("PionEffSecReac_%i",iEta));
1209 pionEffSecReac->Write();
1212 // 3. contributions from secondaries from weak decays
1214 TH1D *pionEffSecWeak = new TH1D(*pionRaw);
1215 TH1D *dummy2 = new TH1D(*pionRaw);
1216 dummy2->Add(pionSecWeak,-1);
1217 pionEffSecWeak->Divide(pionRaw,dummy2);
1218 pionEffSecWeak->SetName(Form("PionEffSecWeak_%i",iEta));
1219 pionEffSecWeak->Write();
1222 // 4. decay (Kaon,pion) and detector absorption (energy loss and multiple scattering)
1224 TH1D *pionEffAbs = new TH1D(*pionRaw);
1225 pionEffAbs->Divide(pionRawPrim,pionMC);
1226 pionEffAbs->SetName(Form("PionEffAbs_%i",iEta));
1227 pionEffAbs->Write();
1231 TH1D *pionEffMis = new TH1D(*pionMis);
1232 pionEffMis->Divide(pionMis,pionRaw);
1233 pionEffMis->SetName(Form("PionContam_%i",iEta));
1234 pionEffMis->Write();
1237 // PROCESS THE REAL DATA FROM HERE ON
1239 TH1D *histPtPionEta = histPtEtaPion->ProjectionZ(Form("HistPtPionEtaRaw_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1240 histPtPionEta->Write();
1242 // Apply corrections as you would like them to have...
1244 TH1D *pionFinal = new TH1D(*histPtPionEta);
1245 pionFinal->SetName(Form("HistPtPionEtaFinal_%i",iEta));
1247 pionFinal->Divide(pionEffTot); // enable or disable specific corrections here...
1250 // if available save also the MC truth for consistency checks
1252 TH1D *histPtPionEtaMcData = histPtMCPionData->ProjectionZ(Form("HistPtPionEtaMcData_%i",iEta),kMultLow,kMultHigh,iEta,iEta);
1253 histPtPionEtaMcData->Write();
1258 // Close the file after everthing is done
1260 spectraFile.Close();