1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, proviyaded that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purapose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
19 // Analysis for identified charged hadron spectra. //
22 ///////////////////////////////////////////////////////////////////////////
24 #include "Riostream.h"
33 #include "TObjArray.h"
37 #include "AliAnalysisTaskSE.h"
38 #include "AliAnalysisManager.h"
40 #include "AliHeader.h"
41 #include "AliGenPythiaEventHeader.h"
42 #include "AliGenCocktailEventHeader.h"
45 #include "AliESDtrackCuts.h"
46 #include "AliESDVertex.h"
47 #include "AliESDEvent.h"
48 #include "AliESDInputHandler.h"
49 #include "AliESDtrack.h"
50 #include "AliESDpid.h"
51 #include "AliCentrality.h"
52 #include "AliESDUtils.h"
53 #include "AliMultiplicity.h"
55 #include "AliMCEventHandler.h"
56 #include "AliMCEvent.h"
61 #include "AliAnalysisCombinedHadronSpectra.h"
64 ClassImp(AliAnalysisCombinedHadronSpectra)
66 //________________________________________________________________________
67 AliAnalysisCombinedHadronSpectra::AliAnalysisCombinedHadronSpectra()
68 : AliAnalysisTaskSE("TaskChargedHadron"), fESD(0), fListHist(0), fESDtrackCuts(0),fESDTrackCutsMult(0),fESDpid(0),
71 fUseHBTmultiplicity(0),
87 // default Constructor
88 /* fast compilation test
89 gSystem->Load("libANALYSIS");
90 gSystem->Load("libANALYSISalice");
91 .L /d/alice09/akalweit/train/trunk/akalweit_hadronSpectra/AliAnalysisCombinedHadronSpectra.cxx++
96 //________________________________________________________________________
97 AliAnalysisCombinedHadronSpectra::AliAnalysisCombinedHadronSpectra(const char *name)
98 : AliAnalysisTaskSE(name), fESD(0), fListHist(0), fESDtrackCuts(0),fESDTrackCutsMult(0),fESDpid(0),
101 fUseHBTmultiplicity(0),
102 fUseTPConlyTracks(0),
106 fTPCnSigmaCutHigh(0),
118 // standard constructur which should be used
120 Printf("*** CONSTRUCTOR CALLED ****");
124 fUseHBTmultiplicity = kTRUE;
125 fUseTPConlyTracks = kFALSE;
127 fSmallTHnSparse = kFALSE;
128 fTPCnSigmaCutLow = -3.;
129 fTPCnSigmaCutHigh = 3.;
130 fRapidityCutLow = -0.2;
131 fRapidityCutHigh = 0.2;
132 fEvenDCAbinning = kFALSE;
135 fAlephParameters[0] = 0.0283086;
136 fAlephParameters[1] = 2.63394e+01;
137 fAlephParameters[2] = 5.04114e-11;
138 fAlephParameters[3] = 2.12543e+00;
139 fAlephParameters[4] = 4.88663e+00;
141 // initialize PID object
143 //fESDpid = new AliESDpid();
147 fESDtrackCuts = new AliESDtrackCuts("AliESDtrackCuts","AliESDtrackCuts");
150 // Output slot #0 writes into a TList container
151 DefineOutput(1, TList::Class());
156 //________________________________________________________________________
157 void AliAnalysisCombinedHadronSpectra::Initialize()
160 // updating parameters in case of changes
164 //fESDpid->GetTPCResponse().SetBetheBlochParameters(fAlephParameters[0],fAlephParameters[1],fAlephParameters[2],fAlephParameters[3],fAlephParameters[4]);
169 fESDtrackCuts->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2); // BEWARE STANDARD VALUES ARE: 2, 2, 0.5, 0.5, 2
170 fESDtrackCuts->SetMaxNsigmaToVertex(3);
171 fESDtrackCuts->SetRequireSigmaToVertex(kTRUE);
172 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
173 fESDtrackCuts->SetMinNClustersTPC(70);
174 fESDtrackCuts->SetMaxChi2PerClusterTPC(4);
175 fESDtrackCuts->SetMaxDCAToVertexXY(3);
176 fESDtrackCuts->SetMaxDCAToVertexZ(3);
177 fESDtrackCuts->SetRequireTPCRefit(kTRUE);
178 fESDtrackCuts->SetRequireITSRefit(kTRUE);
179 fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); //TEMPORARY <-> REMOVE
180 fESDtrackCuts->SetMinNClustersITS(3);
182 //fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE); // kTRUE = sel. primaries --> patch for the moment, do TFractionFitter later
185 if (!fUseTPConlyTracks) {
186 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE);
187 fESDtrackCuts->SetMaxDCAToVertexXY(3);
188 fESDtrackCuts->SetMaxDCAToVertexZ(2);
189 fESDtrackCuts->SetEtaRange(-0.9,0.9);
192 //fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
193 fESDtrackCuts->SetMinNClustersTPC(70);
194 fESDtrackCuts->SetMaxChi2PerClusterTPC(4);
195 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
196 fESDtrackCuts->SetRequireTPCRefit(kFALSE);
198 fESDtrackCuts->SetMaxDCAToVertexXY(15);
199 fESDtrackCuts->SetMaxDCAToVertexZ(6);
200 fESDtrackCuts->SetDCAToVertex2D(kFALSE);
201 fESDtrackCuts->SetRequireSigmaToVertex(kFALSE);
203 fESDtrackCuts->SetEtaRange(-0.9,0.9);
209 fESDTrackCutsMult = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
210 fESDTrackCutsMult->SetEtaRange(-1.2,+1.2);
211 fESDTrackCutsMult->SetPtRange(0.15,1e10);
216 //________________________________________________________________________
217 void AliAnalysisCombinedHadronSpectra::UserCreateOutputObjects()
221 fListHist = new TList();
222 fListHist->SetOwner(kTRUE);
224 const Int_t kPtBins = 35;
225 const Int_t kMultBins = 11;
227 Int_t kDcaBinsTemp = 76;
228 if (fEvenDCAbinning) kDcaBinsTemp = 150;
229 const Int_t kDcaBins = (const Int_t) kDcaBinsTemp;
231 const Float_t kDcaBinsTPConlyFactor = 5; //need to change binning of DCA plot for tpconly
233 Double_t binsPt[77] = {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};
235 Double_t binsDca[77] = {-3,-2.85,-2.7,-2.55,-2.4,-2.25,-2.1,-1.95,-1.8,-1.65,-1.5,-1.35,-1.2,-1.05,-0.9,-0.75,-0.6,-0.45,-0.3,-0.285,-0.27,-0.255,-0.24,-0.225,-0.21,-0.195,-0.18,-0.165,-0.15,-0.135,-0.12,-0.105,-0.09,-0.075,-0.06,-0.045,-0.03,-0.015,0,0.015,0.03,0.045,0.06,0.075,0.09,0.105,0.12,0.135,0.15,0.165,0.18,0.195,0.21,0.225,0.24,0.255,0.27,0.285,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.5,1.65,1.8,1.95,2.1,2.25,2.4,2.55,2.7,2.85,3};
237 // DCA bins borders get multiplied by constant factor for TPConlyTracks
238 Double_t binsDcaTPConly[77];
239 for (Int_t i = 0; i< 77; i++) {
240 binsDcaTPConly[i] = kDcaBinsTPConlyFactor * binsDca[i];
244 // create the histograms with all necessary information --> it is filled 4x for each particle assumption
246 // (0.) assumed particle: 0. pion, 1. kaon, 2. proton, 3. deuteron
247 // (1.) multiplicity or centrality -- number of accepted ESD tracks per events (deprecated), but now classes from 1 to 10, 0: Min. Bias
250 // (4.) rapidity --> filled 4x
251 // (5.) pull TPC dEx --> filled 4x
252 // (6.) has valid TOF pid signal
253 // (7.) nsigma TOF --> filled 4x
255 // (9.) CODE -- only MC 0-generated, 1-true rec. primaries, 2-misident prim, 3-second weak, 4-second material, 5-misident sec, 6-sec. K0, 7-sec. lambda, 8-sec sigma+
258 //dimensions of standard THnSparse
259 // 0, 1, 2, 3, 4, 5, 6, 7, 8
260 Int_t binsHistReal[9] = { 3, kMultBins, kPtBins, 2, 10, 50, 2, 80, kDcaBins};
261 Double_t xminHistReal[9] = {-0.5, -0.5, 0, -2, -0.5, -5, -0.5, -8, -3};
262 Double_t xmaxHistReal[9] = { 2.5, 10.5, 3, 2, 0.5, 5, 1.5, 8, 3};
264 //dimensions of small THnSparse
265 // 0, 1, 2, 3, 4, 5, 6
266 Int_t binsHistRealSm[7] = { 3, kMultBins, kPtBins, 2, /* 10, 50,*/ 2, 80, kDcaBins};
267 Double_t xminHistRealSm[7] = {-0.5, -0.5, 0, -2, /* -0.5, -5,*/ -0.5, -8, -3};
268 Double_t xmaxHistRealSm[7] = { 2.5, 10.5, 3, 2, /* 0.5, 5,*/ 1.5, 8, 3};
270 if (!fSmallTHnSparse) fHistRealTracks = new THnSparseF("fHistRealTracks","real tracks",9,binsHistReal,xminHistReal,xmaxHistReal);
271 else fHistRealTracks = new THnSparseF("fHistRealTracks","real tracks",7,binsHistRealSm,xminHistRealSm,xmaxHistRealSm);
273 fHistRealTracks->GetAxis(2)->Set(kPtBins, binsPt);
275 //different DCAxy binning for TPConlyTracks
277 Int_t dcaAxisNumber = 8;
278 if (fSmallTHnSparse) dcaAxisNumber = 6;
280 if (!fUseTPConlyTracks){
281 if (fEvenDCAbinning) fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins,-3.,3.);
282 else fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
285 if (fEvenDCAbinning) fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins,-15.,15.);
286 else fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
288 fListHist->Add(fHistRealTracks);
290 // 0.ptot,1.tpcSig,2.hasTOF, 3. assumed part., 4. nclDedx, 5. nSigmaTPC (4x), 6. nSigmaTOF (4x), 7. centrality
291 fHistPidQA = new TH3D("fHistPidQA","PID QA",500,0.1,10,1000,0,1000,2,-2,2);
292 BinLogAxis(fHistPidQA);
293 fListHist->Add(fHistPidQA);
295 // dimensions of standard THnSparse
296 // 0, 1, 2, 3, 4, 5, 6, 7, 8., 9.
297 Int_t binsHistMC[10] = { 3, kMultBins, kPtBins, 2, 10, 50, 2, 80, kDcaBins, 6};
298 Double_t xminHistMC[10] = {-0.5, -0.5, 0, -2, -0.5, -5, -0.5, -8, -3, -0.5};
299 Double_t xmaxHistMC[10] = { 2.5, 10.5, 3, 2, 0.5, 5, 1.5, 8, 3, 5.5};
301 //dimensions of small THnSparse
302 // 0, 1, 2, 3, 4, 5, 6., 7.
303 Int_t binsHistMCSm[8] = { 3, kMultBins, kPtBins, 2, /* 10, 50,*/ 2, 80, kDcaBins, 6};
304 Double_t xminHistMCSm[8] = {-0.5, -0.5, 0, -2, /* -0.5, -5,*/ -0.5, -8, -3, -0.5};
305 Double_t xmaxHistMCSm[8] = { 2.5, 10.5, 3, 2, /* 0.5, 5,*/ 1.5, 8, 3, 5.5};
307 //different binning for CODE axis, if we want to save motherPDG
308 if (fSaveMotherPDG) {
312 xmaxHistMCSm[7] = 8.5;
316 if (!fSmallTHnSparse) fHistMCparticles = new THnSparseF("fHistMCparticles","MC histogram",10,binsHistMC,xminHistMC,xmaxHistMC);
317 else fHistMCparticles = new THnSparseF("fHistMCparticles","MC histogram",8,binsHistMCSm,xminHistMCSm,xmaxHistMCSm);
320 fHistMCparticles->GetAxis(2)->Set(kPtBins, binsPt);
323 //different DCAxy binning for TPConlyTracks
324 if (!fEvenDCAbinning){
325 if (!fUseTPConlyTracks) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
326 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
330 if (!fUseTPConlyTracks){
331 if (fEvenDCAbinning) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins,-3.,3.);
332 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
335 if (fEvenDCAbinning) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins,-15.,15.);
336 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
341 fListHist->Add(fHistMCparticles);
343 fHistMult = new TH2D("fHistMult", "control histogram to count number of events", 502, -2.5, 499.5,4,-0.5,3.5);
344 fHistCentrality = new TH1D("fHistCentrality", "control histogram to count number of events", 22, -1.5, 20.5);
345 fListHist->Add(fHistMult);
346 fListHist->Add(fHistCentrality);
350 //________________________________________________________________________
351 void AliAnalysisCombinedHadronSpectra::UserExec(Option_t *)
356 if (!fESDpid) fESDpid = ((AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetESDpid();
358 fESDpid = new AliESDpid(); // HACK FOR MC PBPB --> PLEASE REMOVE AS SOON AS POSSIBLE
359 fESDpid->GetTPCResponse().SetBetheBlochParameters(1.28778e+00/50., 3.13539e+01, TMath::Exp(-3.16327e+01), 1.87901e+00, 6.41583e+00);
361 //AliLog::SetGlobalLogLevel(AliLog::kError);
363 // Check Monte Carlo information and other access first:
365 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
367 //Printf("ERROR: Could not retrieve MC event handler");
371 AliMCEvent* mcEvent = 0x0;
372 AliStack* stack = 0x0;
373 if (eventHandler) mcEvent = eventHandler->MCEvent();
375 //Printf("ERROR: Could not retrieve MC event");
379 stack = mcEvent->Stack();
383 fESD = dynamic_cast<AliESDEvent*>( InputEvent() );
385 //Printf("ERROR: fESD not available");
389 if (!fESDtrackCuts) {
390 Printf("ERROR: fESDtrackCuts not available");
394 // check if event is selected by physics selection class
396 Bool_t isSelected = kTRUE; // for reasons of backward compatibility --> check is now in AddTask macro
398 Bool_t isSelected = kFALSE;
399 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB) == AliVEvent::kMB;
402 // monitor vertex position
404 const AliESDVertex *vertex = fESD->GetPrimaryVertexTracks();
405 if(vertex->GetNContributors()<1) {
407 vertex = fESD->GetPrimaryVertexSPD();
408 if(vertex->GetNContributors()<1) vertex = 0x0;
411 // small track loop to determine trigger Pt, multiplicity or centrality
413 Double_t triggerPt = 0;
414 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
415 AliESDtrack *track =fESD->GetTrack(i);
416 if (!fESDTrackCutsMult->AcceptTrack(track)) continue;
417 if (track->Pt() > triggerPt) triggerPt = track->Pt();
419 Int_t trackCounter = fESDTrackCutsMult->CountAcceptedTracks(fESD);
421 // 2nd multiplicity estimator SPD hits; replaces multiplicity from HBT
423 Float_t spdCorr = -1;
424 const AliMultiplicity *mult = fESD->GetMultiplicity();
425 Float_t nClusters[6]={0.0,0.0,0.0,0.0,0.0,0.0};
426 for(Int_t ilay=0; ilay<6; ilay++) nClusters[ilay] = (Float_t)mult->GetNumberOfITSClusters(ilay);
427 if (vertex) spdCorr = AliESDUtils::GetCorrSPD2(nClusters[1],vertex->GetZ());
429 Float_t centrality = -1;
431 // IMPORTANT CENTRALITY DEFINITION FOR pp
433 if (!fUseHBTmultiplicity) {
434 // test binning to check if multiplicity-dependence is due to diffractive events being s
435 if (trackCounter >= 0 && trackCounter <= 0) centrality = 0;
436 if (trackCounter >= 1 && trackCounter <= 1) centrality = 1;
437 if (trackCounter >= 2 && trackCounter <= 2) centrality = 2;
438 if (trackCounter >= 3 && trackCounter <= 3) centrality = 3;
439 if (trackCounter >= 4 && trackCounter <= 4) centrality = 4;
440 if (trackCounter >= 5 && trackCounter <= 5) centrality = 5;
441 // this was all the original bin 1 being [0..5]
442 if (trackCounter >= 6 && trackCounter <= 9) centrality = 6;
443 if (trackCounter >= 10 && trackCounter <= 14) centrality = 7;
444 if (trackCounter >= 15 && trackCounter <= 22) centrality = 8;
445 if (trackCounter >= 23 && trackCounter <= 32) centrality = 9;
446 if (trackCounter >= 33 && trackCounter <= 42) centrality = 10;
448 if (trackCounter >= 43 && trackCounter <= 52) centrality = 7
449 if (trackCounter >= 53 && trackCounter <= 62) centrality = 8;
450 if (trackCounter >= 63 && trackCounter <= 72) centrality = 9;
451 if (trackCounter >= 73 && trackCounter <= 82) centrality = 10;
454 if (spdCorr >= 0 && spdCorr <= 2) centrality = 0;
455 if (spdCorr >= 3 && spdCorr <= 5) centrality = 1;
456 if (spdCorr >= 6 && spdCorr <= 8) centrality = 2;
457 if (spdCorr >= 9 && spdCorr <= 11) centrality = 3;
458 if (spdCorr >= 12 && spdCorr <= 14) centrality = 4;
459 if (spdCorr >= 15 && spdCorr <= 16) centrality = 5;
460 // this was all the original bin 1 being [0..16]
461 if (spdCorr >= 17 && spdCorr <= 30) centrality = 6;
462 if (spdCorr >= 31 && spdCorr <= 45) centrality = 7;
463 if (spdCorr >= 46 && spdCorr <= 68) centrality = 8;
464 if (spdCorr >= 69 && spdCorr <= 97) centrality = 9;
465 if (spdCorr >= 98) centrality = 10;
467 if (spdCorr >= 17 && spdCorr <= 30) centrality = 2;
468 if (spdCorr >= 31 && spdCorr <= 45) centrality = 3;
469 if (spdCorr >= 46 && spdCorr <= 68) centrality = 4;
470 if (spdCorr >= 69 && spdCorr <= 97) centrality = 5;
471 if (spdCorr >= 98) centrality = 6;
475 Int_t rootS = fESD->GetBeamEnergy() < 1000 ? 0 : 1;
476 if (fESD->GetEventSpecie() == 4) { // PbPb
478 AliCentrality *esdCentrality = fESD->GetCentrality();
479 centrality = esdCentrality->GetCentralityClass10("V0M") + 1; // centrality percentile determined with V0
480 if (TMath::Abs(centrality - 1) < 1e-5) {
481 centrality = esdCentrality->GetCentralityClass5("V0M");
484 Int_t nContributors = 0;
485 if (fESD->GetPrimaryVertexTPC()) nContributors = fESD->GetPrimaryVertexTPC()->GetNContributors();
487 Int_t processtype = 0;
488 Int_t processCode = 0;
490 // important change: fill generated only after vertex cut in case of heavy-ions
492 if (!vertex && fESD->GetEventSpecie() == 4) {
493 fHistMult->Fill(-1, processCode);
494 PostData(1, fListHist);
497 if (TMath::Abs(vertex->GetZ()) > 10 && fESD->GetEventSpecie() == 4) {
498 fHistMult->Fill(-1, processCode);
499 PostData(1, fListHist);
508 AliHeader * header = mcEvent->Header();
509 processtype = GetPythiaEventProcessType(header);
511 if (processtype !=92 && processtype !=93 && processtype != 94) processCode = 1;
512 // single diffractive
513 if ((processtype == 92 || processtype == 93)) processCode = 2;
514 // double diffractive
515 if (processtype == 94) processCode = 3;
517 for(Int_t i = 0; i < stack->GetNtrack(); i++) {
518 TParticle * trackMC = stack->Particle(i);
519 Int_t pdg = trackMC->GetPdgCode();
521 Double_t xv = trackMC->Vx();
522 Double_t yv = trackMC->Vy();
523 Double_t zv = trackMC->Vz();
525 dxy = TMath::Sqrt(xv*xv + yv*yv); // so stupid to avoid warnings
527 dz = TMath::Abs(zv); // so stupid to avoid warnings
529 // vertex cut - selection of primaries
531 //if (dxy > 3 || dz > 10) continue; // fixed cut at 3cm in r
533 if (!stack->IsPhysicalPrimary(i)) continue;
535 // fill MC histograms here...
537 Double_t rap = trackMC->Y();
538 Double_t pT = trackMC->Pt();
539 Int_t sign = pdg < 0 ? -1 : 1; // only works for charged pi,K,p !!
540 // Double_t transMass = TMath::Sqrt(trackMC->Pt()*trackMC->Pt() + trackMC->GetMass()*trackMC->GetMass()) - trackMC->GetMass();
543 if (TMath::Abs(pdg) == 211) iPart = 0; // select Pi+/Pi- only
544 if (TMath::Abs(pdg) == 321) iPart = 1; // select K+/K- only
545 if (TMath::Abs(pdg) == 2212) iPart = 2; // select p+/p- only
546 if (iPart == -1) continue;
549 if (!fSmallTHnSparse){
550 Double_t vecHistMC[10] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), rap, 0, 1, 0, dxy, 0};
551 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
554 if (rap>fRapidityCutLow && rap<fRapidityCutHigh){
555 Double_t vecHistMC[8] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), 1, 0, dxy, 0};
556 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
562 if (!isSelected && !fOnlyQA) {
563 PostData(1, fListHist);
568 fHistMult->Fill(-1, processCode);
569 PostData(1, fListHist);
572 if (TMath::Abs(vertex->GetZ()) > 10) {
573 fHistMult->Fill(-1, processCode);
574 PostData(1, fListHist);
579 // count events after physics selection and after vertex selection
581 //cout << "MULTIPLICITY " << trackCounter << " " << fESD->GetEventNumberInFile() <<endl;
582 fHistMult->Fill(trackCounter, processCode);
583 fHistCentrality->Fill(centrality);
586 //***************************************************
588 //***************************************************
589 //const Float_t kNsigmaCut = 3;
590 //const Float_t k2sigmaCorr = 1/(0.5*(TMath::Erf(kNsigmaCut/sqrt(2))-TMath::Erf(-kNsigmaCut/sqrt(2))))/*1/0.9545*/;
592 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z for the vertex cut
594 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
596 AliESDtrack *track = 0;
597 AliESDtrack *trackForTOF = 0; //normal track for all TOF information needed when using tpconly-tracks
599 //normal tracks, if tpconly flag is set, use tpconlytracks
600 if (!fUseTPConlyTracks){
601 track =fESD->GetTrack(i);
604 track = fESDtrackCuts->GetTPCOnlyTrack(fESD,i);
605 if (!track) continue;
606 trackForTOF = fESD->GetTrack(i);
609 if (!track->GetInnerParam()) {
610 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
613 Double_t ptot = track->GetInnerParam()->GetP(); // momentum for dEdx determination
614 Double_t pT = track->Pt();
615 track->GetImpactParameters(dca, cov);
618 // cut for dead regions in the detector
619 // if (track->Eta() > 0.1 && (track->Eta() < 0.2 && track->Phi() > 0.1 && track->Phi() < 0.1) continue;
621 // 2.a) apply some standard track cuts according to general recommendations
623 if (!fESDtrackCuts->AcceptTrack(track)) {
624 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
629 if (!fUseTPConlyTracks) status = track->GetStatus();
630 else status = trackForTOF->GetStatus();
631 Bool_t hasTOFout = status&AliESDtrack::kTOFout;
632 Bool_t hasTOFtime = status&AliESDtrack::kTIME;
633 Bool_t hasTOFpid = status&AliESDtrack::kTOFpid;
634 Bool_t hasTOF = kFALSE;
635 if (hasTOFout && hasTOFtime && hasTOFpid) hasTOF = kTRUE;
637 if (!fUseTPConlyTracks) length = track->GetIntegratedLength();
638 else length = trackForTOF->GetIntegratedLength();
640 if (length < 350.) hasTOF = kFALSE;
642 // calculate rapidities and kinematics
646 track->GetPxPyPz(pvec);
647 Double_t energyPion = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion));
648 Double_t energyKaon = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon));
649 Double_t energyProton = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
650 Double_t energyDeuteron = TMath::Sqrt(track->GetP()*track->GetP() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
652 Double_t rapPion = 0.5*TMath::Log((energyPion + pvec[2])/(energyPion - pvec[2]));
653 Double_t rapKaon = 0.5*TMath::Log((energyKaon + pvec[2])/(energyKaon - pvec[2]));
654 Double_t rapProton = 0.5*TMath::Log((energyProton + pvec[2])/(energyProton - pvec[2]));
655 Double_t rapDeuteron = 0.5*TMath::Log((energyDeuteron + pvec[2])/(energyDeuteron - pvec[2]));
657 // Double_t transMassPion = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion)) - AliPID::ParticleMass(AliPID::kPion);
658 // Double_t transMassKaon = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon)) - AliPID::ParticleMass(AliPID::kKaon);
659 // Double_t transMassProton = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - AliPID::ParticleMass(AliPID::kProton);
660 // Double_t transMassDeuteron = TMath::Sqrt(track->Pt()*track->Pt() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - 2*AliPID::ParticleMass(AliPID::kProton);
664 Double_t sign = track->GetSign();
665 Double_t tpcSignal = track->GetTPCsignal();
668 // 3.a. calculate expected signals in nsigma
671 // (0.) assumed particle: 0. pion, 1. kaon, 2. proton, 3. deuteron
672 // (1.) multiplicity or centrality -- number of accepted ESD tracks per events (deprecated), but now classes from 1 to 10, 0: Min. Bias
675 // (4.) rapidity --> filled 4x
676 // (5.) pull TPC dEx --> filled 4x
677 // (6.) has valid TOF pid signal
678 // (7.) nsigma TOF --> filled 4x
680 // (9.) CODE -- only MC 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
682 // Double_t transMass[4] = {transMassPion,transMassKaon,transMassProton,transMassDeuteron};
683 Double_t rap[4] = {rapPion,rapKaon,rapProton,rapDeuteron};
684 Double_t pullsTPC[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
685 fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
686 fESDpid->NumberOfSigmasTPC(track,AliPID::kProton),
687 0}; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!
688 Float_t time0 = fESDpid->GetTOFResponse().GetTimeZero();
689 //fESDpid->GetTOFResponse().SetTimeResolution(130.);
690 Double_t pullsTOF[4] ={0.,0.,0.,0.};
691 if (!fUseTPConlyTracks) {
692 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
693 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
694 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
695 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
698 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
699 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
700 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
701 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
705 // Double_t tpcQA[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kElectron),
706 // fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
707 // fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
708 // fESDpid->NumberOfSigmasTPC(track,AliPID::kProton)};
710 Double_t tofQA[4] = {0.,0.,0.,0.};
711 if (!fUseTPConlyTracks) {
712 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kElectron, time0);
713 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
714 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
715 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
718 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kElectron, time0);
719 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
720 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
721 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
725 //save information for every particle type // loop over assumed particle type
726 for(Int_t iPart = 0; iPart < 3; iPart++) {
728 if (!fSmallTHnSparse) {
729 Double_t vecHistReal[9] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), rap[iPart], pullsTPC[iPart], static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0]};
730 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
733 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
734 Double_t vecHistReal[7] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0]};
735 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
740 // using MC truth for precise efficiencies...
742 if (fMCtrue && !fOnlyQA) {
743 Int_t code = 9; // code: 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
744 Int_t assumedPdg = 0;//2212(proton); 321(Kaon); 211(pion);
745 Int_t motherCode = -1;
746 if (iPart == 0) assumedPdg = 211;
747 if (iPart == 1) assumedPdg = 321;
748 if (iPart == 2) assumedPdg = 2212;
751 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
752 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
754 if (pdg != assumedPdg && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 2;
755 if (pdg != assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 5;
756 if (pdg == assumedPdg && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
757 if (pdg == assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) {
760 TParticle *trackMother = stack->Particle(TMath::Abs(trackMC->GetFirstMother()));
761 if (trackMother->GetPdgCode() == 310) motherCode = 6; //K0
762 if (trackMother->GetPdgCode() == 3122) motherCode = 7; //Lambda
763 if (trackMother->GetPdgCode() == 3222) motherCode = 8; //Sigma+
766 if (pdg == assumedPdg && stack->IsSecondaryFromMaterial(TMath::Abs(track->GetLabel()))) code = 4;
769 // muons need special treatment, because they are indistinguishable from pions
771 if (iPart == 0 && pdg == 13 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
772 if (iPart == 0 && pdg == 13 && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 3;
774 // check TOF mismatch on MC basis with TOF label
777 if (!fUseTPConlyTracks) track->GetTOFLabel(tofLabel);
778 else trackForTOF->GetTOFLabel(tofLabel);
779 if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
781 // IMPORTANT BIG PROBLEM HERE THE PROBABLILITY TO HAVE A PID SIGNAL MUST BE IN !!!!!!!!!!!!
783 if (!fSmallTHnSparse){
784 Double_t vectorHistMC[10] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), rap[iPart], pullsTPC[iPart], static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0], static_cast<Double_t>(code)};
786 fHistMCparticles->Fill(vectorHistMC);
787 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
788 Double_t vectorHistMCmother[10] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), rap[iPart], pullsTPC[iPart], static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0], static_cast<Double_t>(motherCode)};
789 fHistMCparticles->Fill(vectorHistMCmother);
794 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
795 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
796 Double_t vectorHistMC[8] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0], static_cast<Double_t>(code)};
798 fHistMCparticles->Fill(vectorHistMC);
799 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
800 Double_t vectorHistMCmother[8] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), static_cast<Double_t>(hasTOF), pullsTOF[iPart], dca[0], static_cast<Double_t>(motherCode)};
801 fHistMCparticles->Fill(vectorHistMCmother);
809 Int_t tpcShared = track->GetTPCnclsS();
810 if (TMath::Abs(track->Eta()) < 0.8 && iPart == 0 && tpcShared < 4) fHistPidQA->Fill(ptot,tpcSignal,sign);
811 } // end loop over assumed particle type
813 //need to delete tpconlytrack
814 if (fUseTPConlyTracks){
819 } // end of track loop
822 PostData(1, fListHist);
827 //________________________________________________________________________
828 void AliAnalysisCombinedHadronSpectra::Terminate(Option_t *)
830 // Draw result to the screen
831 // Called once at the end of the query
832 Printf("*** CONSTRUCTOR CALLED ****");
837 //________________________________________________________________________
838 Bool_t AliAnalysisCombinedHadronSpectra::SelectOnImpPar(AliESDtrack* t) {
840 // cut on transverse impact parameter // DEPRECATED
842 Float_t d0z0[2],covd0z0[3];
843 t->GetImpactParameters(d0z0,covd0z0);
844 Float_t sigma= 0.0050+0.0060/TMath::Power(t->Pt(),0.9);
845 Float_t d0max = 7.*sigma;
847 Float_t sigmaZ = 0.0146+0.0070/TMath::Power(t->Pt(),1.114758);
848 if (t->Pt() > 1) sigmaZ = 0.0216;
849 Float_t d0maxZ = 5.*sigmaZ;
851 if(TMath::Abs(d0z0[0]) < d0max && TMath::Abs(d0z0[1]) < d0maxZ) return kTRUE;
856 //________________________________________________________________________
857 void AliAnalysisCombinedHadronSpectra::BinLogAxis(const TH1 *h) {
859 // Method for the correct logarithmic binning of histograms
861 TAxis *axis = const_cast<TAxis*>(h->GetXaxis());
862 int bins = axis->GetNbins();
864 Double_t from = axis->GetXmin();
865 Double_t to = axis->GetXmax();
866 Double_t *newBins = new Double_t[bins + 1];
869 Double_t factor = pow(to/from, 1./bins);
871 for (int i = 1; i <= bins; i++) {
872 newBins[i] = factor * newBins[i-1];
874 axis->Set(bins, newBins);
880 //________________________________________________________________________
881 Int_t AliAnalysisCombinedHadronSpectra::GetPythiaEventProcessType(const AliHeader* aHeader, Bool_t adebug) const {
883 // get the process type of the event.
886 // can only read pythia headers, either directly or from cocktalil header
887 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
889 if (!pythiaGenHeader) {
891 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
892 if (!genCocktailHeader) {
893 //printf("AliAnalysisCombinedHadronSpectra::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
897 TList* headerList = genCocktailHeader->GetHeaders();
902 for (Int_t i=0; i<headerList->GetEntries(); i++) {
903 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
908 if (!pythiaGenHeader) {
909 //printf("AliAnalysisCombinedHadronSpectra::GetProcessType : Could not find Pythia header. \n");
915 //printf("AliAnalysisCombinedHadronSpectra::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
918 return pythiaGenHeader->ProcessType();