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 in pPb. //
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 "AliAnalysisTPCTOFpA.h"
64 ClassImp(AliAnalysisTPCTOFpA)
66 //________________________________________________________________________
67 AliAnalysisTPCTOFpA::AliAnalysisTPCTOFpA()
68 : AliAnalysisTaskSE("TaskChargedHadron"), fESD(0), fListHist(0), fESDtrackCuts(0),fESDTrackCutsMult(0),fESDpid(0),
71 fUseHBTmultiplicity(0),
83 fRatioRowsClusters(0),
97 // default Constructor
98 /* fast compilation test
99 gSystem->Load("libANALYSIS");
100 gSystem->Load("libANALYSISalice");
101 .L /d/alice09/akalweit/train/trunk/akalweit_hadronSpectra/AliAnalysisTPCTOFpA.cxx++
106 //________________________________________________________________________
107 AliAnalysisTPCTOFpA::AliAnalysisTPCTOFpA(const char *name)
108 : AliAnalysisTaskSE(name), fESD(0), fListHist(0), fESDtrackCuts(0),fESDTrackCutsMult(0),fESDpid(0),
111 fUseHBTmultiplicity(0),
112 fUseTPConlyTracks(0),
123 fRatioRowsClusters(0),
125 fTPCnSigmaCutHigh(0),
138 // standard constructur which should be used
140 Printf("*** CONSTRUCTOR CALLED ****");
144 fUseHBTmultiplicity = kTRUE;
145 fUseTPConlyTracks = kFALSE;
148 fUseTPConlyTracks =kFALSE;
149 fSaveMotherPDG = kFALSE;
150 fSmallTHnSparse = kTRUE;
151 fTPCnSigmaCutLow = -3.;
152 fTPCnSigmaCutHigh = 3.;
153 fRapidityCutLow = 0.;
154 fRapidityCutHigh = 0.5;
155 fEvenDCAbinning = kFALSE;
159 fEvenDCAbinning = kFALSE;
161 fTRDinReject = kFALSE;
165 fRatioRowsClusters = 0.8;
170 fAlephParameters[0] = 0.0283086;
171 fAlephParameters[1] = 2.63394e+01;
172 fAlephParameters[2] = 5.04114e-11;
173 fAlephParameters[3] = 2.12543e+00;
174 fAlephParameters[4] = 4.88663e+00;
176 // initialize PID object
178 //fESDpid = new AliESDpid();
182 fESDtrackCuts = new AliESDtrackCuts("AliESDtrackCuts","AliESDtrackCuts");
185 // Output slot #0 writes into a TList container
186 DefineOutput(1, TList::Class());
191 //________________________________________________________________________
192 void AliAnalysisTPCTOFpA::Initialize()
195 // updating parameters in case of changes
199 //fESDpid->GetTPCResponse().SetBetheBlochParameters(fAlephParameters[0],fAlephParameters[1],fAlephParameters[2],fAlephParameters[3],fAlephParameters[4]);
204 fESDtrackCuts->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2); // BEWARE STANDARD VALUES ARE: 2, 2, 0.5, 0.5, 2
205 fESDtrackCuts->SetMaxNsigmaToVertex(3);
206 fESDtrackCuts->SetRequireSigmaToVertex(kTRUE);
207 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
208 fESDtrackCuts->SetMinNClustersTPC(70);
209 fESDtrackCuts->SetMaxChi2PerClusterTPC(4);
210 fESDtrackCuts->SetMaxDCAToVertexXY(3);
211 fESDtrackCuts->SetMaxDCAToVertexZ(3);
212 fESDtrackCuts->SetRequireTPCRefit(kTRUE);
213 fESDtrackCuts->SetRequireITSRefit(kTRUE);
214 fESDtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); //TEMPORARY <-> REMOVE
215 fESDtrackCuts->SetMinNClustersITS(3);
217 //fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE); // kTRUE = sel. primaries --> patch for the moment, do TFractionFitter later
220 if (!fUseTPConlyTracks) {
221 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE,kTRUE);
222 fESDtrackCuts->SetMaxDCAToVertexXY(3);
223 //fESDtrackCuts->SetMaxDCAToVertexZ(2);
224 fESDtrackCuts->SetEtaRange(-0.8,0.8);
227 //fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
228 fESDtrackCuts->SetMinNClustersTPC(70);
229 fESDtrackCuts->SetMaxChi2PerClusterTPC(4);
230 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
231 fESDtrackCuts->SetRequireTPCRefit(kFALSE);
233 fESDtrackCuts->SetMaxDCAToVertexXY(15);
234 fESDtrackCuts->SetMaxDCAToVertexZ(6);
235 fESDtrackCuts->SetDCAToVertex2D(kFALSE);
236 fESDtrackCuts->SetRequireSigmaToVertex(kFALSE);
238 fESDtrackCuts->SetEtaRange(-0.9,0.9);
242 //change DCA z cut here with flags set before:
243 fESDtrackCuts->SetMaxDCAToVertexZ(fDCAzCut);
244 fESDtrackCuts->SetMinNCrossedRowsTPC(fCrossedRows);
245 fESDtrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(fRatioRowsClusters);
251 fESDTrackCutsMult = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
252 fESDTrackCutsMult->SetEtaRange(-1.2,+1.2);
253 fESDTrackCutsMult->SetPtRange(0.15,1e10);
258 //________________________________________________________________________
259 void AliAnalysisTPCTOFpA::UserCreateOutputObjects()
263 fListHist = new TList();
264 fListHist->SetOwner(kTRUE);
266 const Int_t kPtBins = 35;
267 const Int_t kMultBins = 11;
269 Int_t kDcaBinsTemp = 76;
270 if (fEvenDCAbinning) kDcaBinsTemp = 150;
271 const Int_t kDcaBins = (const Int_t) kDcaBinsTemp;
273 const Float_t kDcaBinsTPConlyFactor = 5; //need to change binning of DCA plot for tpconly
275 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};
277 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};
279 // DCA bins borders get multiplied by constant factor for TPConlyTracks
280 Double_t binsDcaTPConly[77];
281 for (Int_t i = 0; i< 77; i++) {
282 binsDcaTPConly[i] = kDcaBinsTPConlyFactor * binsDca[i];
286 // create the histograms with all necessary information --> it is filled 4x for each particle assumption
288 // (0.) assumed particle: 0. pion, 1. kaon, 2. proton, 3. deuteron
289 // (1.) multiplicity or centrality -- number of accepted ESD tracks per events (deprecated), but now classes from 1 to 10, 0: Min. Bias
292 // (4.) rapidity --> filled 4x
293 // (5.) pull TPC dEx --> filled 4x
294 // (6.) has valid TOF pid signal
295 // (7.) nsigma TOF --> filled 4x
297 // (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+
300 //dimensions of standard THnSparse
301 // 0, 1, 2, 3, 4, 5, 6, 7, 8
302 Int_t binsHistReal[9] = { 3, kMultBins, kPtBins, 2, 20, 50, 2, 16, kDcaBins};
303 Double_t xminHistReal[9] = {-0.5, -1.5, 0, -2, -1.0, -5, -0.5, -8, -3};
304 Double_t xmaxHistReal[9] = { 2.5, 9.5, 3, 2, 1.0, 5, 1.5, 8, 3};
306 //dimensions of small THnSparse
307 // 0, 1, 2, 3, 4, 5, 6
308 Int_t binsHistRealSm[7] = { 3, kMultBins, kPtBins, 2, /* 10, 50,*/ 2, 80, kDcaBins};
309 Double_t xminHistRealSm[7] = {-0.5, -1.5, 0, -2, /* -0.5, -5,*/ -0.5, -8, -3};
310 Double_t xmaxHistRealSm[7] = { 2.5, 9.5, 3, 2, /* 0.5, 5,*/ 1.5, 8, 3};
312 if (!fSmallTHnSparse) fHistRealTracks = new THnSparseF("fHistRealTracks","real tracks",9,binsHistReal,xminHistReal,xmaxHistReal);
313 else fHistRealTracks = new THnSparseF("fHistRealTracks","real tracks",7,binsHistRealSm,xminHistRealSm,xmaxHistRealSm);
315 fHistRealTracks->GetAxis(2)->Set(kPtBins, binsPt);
317 //different DCAxy binning for TPConlyTracks
319 Int_t dcaAxisNumber = 8;
320 if (fSmallTHnSparse) dcaAxisNumber = 6;
322 if (!fUseTPConlyTracks){
323 if (fEvenDCAbinning) fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins,-3.,3.);
324 else fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
327 if (fEvenDCAbinning) fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins,-15.,15.);
328 else fHistRealTracks->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
330 fListHist->Add(fHistRealTracks);
332 // 0.ptot,1.tpcSig,2.hasTOF, 3. assumed part., 4. nclDedx, 5. nSigmaTPC (4x), 6. nSigmaTOF (4x), 7. centrality
333 fHistPidQA = new TH3D("fHistPidQA","PID QA",500,0.1,10,1000,0,1000,2,-2,2);
334 BinLogAxis(fHistPidQA);
335 fListHist->Add(fHistPidQA);
337 // dimensions of standard THnSparse
338 // 0, 1, 2, 3, 4, 5, 6, 7, 8., 9.
339 Int_t binsHistMC[10] = { 3, kMultBins, kPtBins, 2, 20, 50, 2, 16, kDcaBins, 6};
340 Double_t xminHistMC[10] = {-0.5, -1.5, 0, -2, -1.0, -5, -0.5, -8, -3, -0.5};
341 Double_t xmaxHistMC[10] = { 2.5, 9.5, 3, 2, 1.0, 5, 1.5, 8, 3, 5.5};
343 //dimensions of small THnSparse
344 // 0, 1, 2, 3, 4, 5, 6., 7.
345 Int_t binsHistMCSm[8] = { 3, kMultBins, kPtBins, 2, /* 10, 50,*/ 2, 80, kDcaBins, 6};
346 Double_t xminHistMCSm[8] = {-0.5, -1.5, 0, -2, /* -0.5, -5,*/ -0.5, -8, -3, -0.5};
347 Double_t xmaxHistMCSm[8] = { 2.5, 9.5, 3, 2, /* 0.5, 5,*/ 1.5, 8, 3, 5.5};
349 //different binning for CODE axis, if we want to save motherPDG
350 if (fSaveMotherPDG) {
354 xmaxHistMCSm[7] = 8.5;
358 if (!fSmallTHnSparse) fHistMCparticles = new THnSparseF("fHistMCparticles","MC histogram",10,binsHistMC,xminHistMC,xmaxHistMC);
359 else fHistMCparticles = new THnSparseF("fHistMCparticles","MC histogram",8,binsHistMCSm,xminHistMCSm,xmaxHistMCSm);
362 fHistMCparticles->GetAxis(2)->Set(kPtBins, binsPt);
365 //different DCAxy binning for TPConlyTracks
366 if (!fEvenDCAbinning){
367 if (!fUseTPConlyTracks) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
368 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
372 if (!fUseTPConlyTracks){
373 if (fEvenDCAbinning) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins,-3.,3.);
374 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDca);
377 if (fEvenDCAbinning) fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins,-15.,15.);
378 else fHistMCparticles->GetAxis(dcaAxisNumber)->Set(kDcaBins, binsDcaTPConly);
383 fListHist->Add(fHistMCparticles);
385 fHistMult = new TH2D("fHistMult", "control histogram to count number of events", 502, -2.5, 499.5,4,-0.5,3.5);
386 fHistCentrality = new TH1D("fHistCentrality", "control histogram to count number of events", 22, -1.5, 20.5);
387 fHistTOFwindow = new TH2D("fHistTOFwindow", "control hisogram for TOF window",160,-10.,10.,160,-10.,10.);
388 fHistTOFwindow->GetXaxis()->SetTitle("dx");
389 fHistTOFwindow->GetYaxis()->SetTitle("dz");
390 fListHist->Add(fHistMult);
391 fListHist->Add(fHistCentrality);
392 fListHist->Add(fHistTOFwindow);
394 PostData(1, fListHist);
398 //________________________________________________________________________
399 void AliAnalysisTPCTOFpA::UserExec(Option_t *)
404 if (!fESDpid) fESDpid = ((AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetESDpid();
406 fESDpid = new AliESDpid(); // HACK FOR MC PBPB --> PLEASE REMOVE AS SOON AS POSSIBLE
407 fESDpid->GetTPCResponse().SetBetheBlochParameters(1.28778e+00/50., 3.13539e+01, TMath::Exp(-3.16327e+01), 1.87901e+00, 6.41583e+00);
409 //AliLog::SetGlobalLogLevel(AliLog::kError);
411 // Check Monte Carlo information and other access first:
413 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
415 //Printf("ERROR: Could not retrieve MC event handler");
419 AliMCEvent* mcEvent = 0x0;
420 AliStack* stack = 0x0;
421 if (eventHandler) mcEvent = eventHandler->MCEvent();
423 //Printf("ERROR: Could not retrieve MC event");
427 stack = mcEvent->Stack();
431 fESD = dynamic_cast<AliESDEvent*>( InputEvent() );
433 //Printf("ERROR: fESD not available");
437 if (!fESDtrackCuts) {
438 Printf("ERROR: fESDtrackCuts not available");
442 // check if event is selected by physics selection class
444 Bool_t isSelected = kTRUE; // for reasons of backward compatibility --> check is now in AddTask macro
446 Bool_t isSelected = kFALSE;
447 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB) == AliVEvent::kMB;
450 // monitor vertex position
452 Bool_t isVertexOk = kTRUE;
453 const AliESDVertex *vertex = fESD->GetPrimaryVertexTracks();
454 if(vertex->GetNContributors()<1) {
456 vertex = fESD->GetPrimaryVertexSPD();
457 /* quality checks on SPD-vertex */
458 TString vertexType = vertex->GetTitle();
459 if (vertexType.Contains("vertexer: Z") && (vertex->GetDispersion() > 0.04 || vertex->GetZRes() > 0.25)) isVertexOk = kFALSE; //vertex = 0x0; //
460 if (vertex->GetNContributors()<1) isVertexOk = kFALSE; //vertex = 0x0; //
463 // small track loop to determine trigger Pt, multiplicity or centrality
465 Double_t triggerPt = 0;
466 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
467 AliESDtrack *track =fESD->GetTrack(i);
468 if (!fESDTrackCutsMult->AcceptTrack(track)) continue;
469 if (track->Pt() > triggerPt) triggerPt = track->Pt();
471 Int_t trackCounter = fESDTrackCutsMult->CountAcceptedTracks(fESD);
473 // 2nd multiplicity estimator SPD hits; replaces multiplicity from HBT
475 Float_t spdCorr = -1;
476 const AliMultiplicity *mult = fESD->GetMultiplicity();
477 Float_t nClusters[6]={0.0,0.0,0.0,0.0,0.0,0.0};
478 for(Int_t ilay=0; ilay<6; ilay++) nClusters[ilay] = (Float_t)mult->GetNumberOfITSClusters(ilay);
479 if (vertex) spdCorr = AliESDUtils::GetCorrSPD2(nClusters[1],vertex->GetZ());
481 Float_t centrality = -1;
483 // IMPORTANT CENTRALITY DEFINITION FOR pp
485 if (!fUseHBTmultiplicity) {
486 // test binning to check if multiplicity-dependence is due to diffractive events being s
487 if (trackCounter >= 0 && trackCounter <= 0) centrality = 0;
488 if (trackCounter >= 1 && trackCounter <= 1) centrality = 1;
489 if (trackCounter >= 2 && trackCounter <= 2) centrality = 2;
490 if (trackCounter >= 3 && trackCounter <= 3) centrality = 3;
491 if (trackCounter >= 4 && trackCounter <= 4) centrality = 4;
492 if (trackCounter >= 5 && trackCounter <= 5) centrality = 5;
493 // this was all the original bin 1 being [0..5]
494 if (trackCounter >= 6 && trackCounter <= 9) centrality = 6;
495 if (trackCounter >= 10 && trackCounter <= 14) centrality = 7;
496 if (trackCounter >= 15 && trackCounter <= 22) centrality = 8;
497 if (trackCounter >= 23 && trackCounter <= 32) centrality = 9;
498 if (trackCounter >= 33 && trackCounter <= 42) centrality = 10;
500 if (trackCounter >= 43 && trackCounter <= 52) centrality = 7
501 if (trackCounter >= 53 && trackCounter <= 62) centrality = 8;
502 if (trackCounter >= 63 && trackCounter <= 72) centrality = 9;
503 if (trackCounter >= 73 && trackCounter <= 82) centrality = 10;
506 if (spdCorr >= 0 && spdCorr <= 2) centrality = 0;
507 if (spdCorr >= 3 && spdCorr <= 5) centrality = 1;
508 if (spdCorr >= 6 && spdCorr <= 8) centrality = 2;
509 if (spdCorr >= 9 && spdCorr <= 11) centrality = 3;
510 if (spdCorr >= 12 && spdCorr <= 14) centrality = 4;
511 if (spdCorr >= 15 && spdCorr <= 16) centrality = 5;
512 // this was all the original bin 1 being [0..16]
513 if (spdCorr >= 17 && spdCorr <= 30) centrality = 6;
514 if (spdCorr >= 31 && spdCorr <= 45) centrality = 7;
515 if (spdCorr >= 46 && spdCorr <= 68) centrality = 8;
516 if (spdCorr >= 69 && spdCorr <= 97) centrality = 9;
517 if (spdCorr >= 98) centrality = 10;
519 if (spdCorr >= 17 && spdCorr <= 30) centrality = 2;
520 if (spdCorr >= 31 && spdCorr <= 45) centrality = 3;
521 if (spdCorr >= 46 && spdCorr <= 68) centrality = 4;
522 if (spdCorr >= 69 && spdCorr <= 97) centrality = 5;
523 if (spdCorr >= 98) centrality = 6;
527 Int_t rootS = fESD->GetBeamEnergy() < 1000 ? 0 : 1;
528 if (fESD->GetEventSpecie() == 4) { // PbPb
530 AliCentrality *esdCentrality = fESD->GetCentrality();
531 centrality = esdCentrality->GetCentralityClass10("V0M") + 1; // centrality percentile determined with V0
532 if (TMath::Abs(centrality - 1) < 1e-5) {
533 centrality = esdCentrality->GetCentralityClass5("V0M");
538 AliCentrality *esdCentrality = fESD->GetCentrality();
539 Float_t pApercentile = esdCentrality->GetCentralityPercentile(fCentEst.Data()); // centrality percentile determined with V0M
540 if (pApercentile >= 0. && pApercentile < 5.) centrality = -1;
541 if (pApercentile >= 5. && pApercentile < 10.) centrality = 0;
542 if (pApercentile >= 10. && pApercentile < 20.) centrality = 1;
543 if (pApercentile >= 20. && pApercentile < 30.) centrality = 2;
544 if (pApercentile >= 30. && pApercentile < 40.) centrality = 3;
545 if (pApercentile >= 40. && pApercentile < 50.) centrality = 4;
546 if (pApercentile >= 50. && pApercentile < 60.) centrality = 5;
547 if (pApercentile >= 60. && pApercentile < 70.) centrality = 6;
548 if (pApercentile >= 70. && pApercentile < 80.) centrality = 7;
549 if (pApercentile >= 80. && pApercentile < 90.) centrality = 8;
550 if (pApercentile >= 90. && pApercentile <= 100.) centrality = 9;
553 cout << "*****************ispA switch works***************************" << endl;
554 cout << "centrality estimator is: " << fCentEst.Data() << endl;
555 cout << "centrality percentile is: " << pApercentile << endl;
556 cout << "*************************************************************" << endl;
563 Int_t nContributors = 0;
564 if (fESD->GetPrimaryVertexTPC()) nContributors = fESD->GetPrimaryVertexTPC()->GetNContributors();
567 Int_t processtype = 0;
568 Int_t processCode = 0;
570 // important change: fill generated only after vertex cut in case of heavy-ions
574 if (!vertex || !isVertexOk) {
575 fHistMult->Fill(-1, processCode);
576 PostData(1, fListHist);
579 if (TMath::Abs(vertex->GetZv()) > 10) {
580 fHistMult->Fill(-1, processCode);
581 PostData(1, fListHist);
594 AliHeader * header = mcEvent->Header();
595 processtype = GetPythiaEventProcessType(header);
597 if (processtype !=92 && processtype !=93 && processtype != 94) processCode = 1;
598 // single diffractive
599 if ((processtype == 92 || processtype == 93)) processCode = 2;
600 // double diffractive
601 if (processtype == 94) processCode = 3;
605 for(Int_t i = 0; i < stack->GetNtrack(); i++) {
606 TParticle * trackMC = stack->Particle(i);
607 Int_t pdg = trackMC->GetPdgCode();
609 Double_t xv = trackMC->Vx();
610 Double_t yv = trackMC->Vy();
611 Double_t zv = trackMC->Vz();
613 dxy = TMath::Sqrt(xv*xv + yv*yv); // so stupid to avoid warnings
615 dz = TMath::Abs(zv); // so stupid to avoid warnings
617 // vertex cut - selection of primaries
619 //if (dxy > 3 || dz > 10) continue; // fixed cut at 3cm in r
621 if (!stack->IsPhysicalPrimary(i)) continue;
623 // fill MC histograms here...
625 Double_t rap = trackMC->Y();
626 if (fRapCMS) rap = rap + 0.465;
627 Double_t pT = trackMC->Pt();
628 Int_t sign = pdg < 0 ? -1 : 1; // only works for charged pi,K,p !!
629 // Double_t transMass = TMath::Sqrt(trackMC->Pt()*trackMC->Pt() + trackMC->GetMass()*trackMC->GetMass()) - trackMC->GetMass();
632 if (TMath::Abs(pdg) == 211) iPart = 0; // select Pi+/Pi- only
633 if (TMath::Abs(pdg) == 321) iPart = 1; // select K+/K- only
634 if (TMath::Abs(pdg) == 2212) iPart = 2; // select p+/p- only
635 if (iPart == -1) continue;
638 if (!fSmallTHnSparse){
639 Double_t vecHistMC[10] = {iPart, centrality, pT, sign, rap, 0, 1, 0, dxy, 0};
640 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
643 if (rap>fRapidityCutLow && rap<fRapidityCutHigh){
644 Double_t vecHistMC[8] = {iPart, centrality, pT, sign, 1, 0, dxy, 0};
645 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
651 if (!isSelected && !fOnlyQA) {
652 PostData(1, fListHist);
656 if (!vertex || !isVertexOk) {
657 fHistMult->Fill(-1, processCode);
658 PostData(1, fListHist);
661 if (TMath::Abs(vertex->GetZv()) > 10) {
662 fHistMult->Fill(-1, processCode);
663 PostData(1, fListHist);
668 // count events after physics selection and after vertex selection
670 //cout << "MULTIPLICITY " << trackCounter << " " << fESD->GetEventNumberInFile() <<endl;
671 fHistMult->Fill(trackCounter, processCode);
672 fHistCentrality->Fill(centrality);
675 //***************************************************
677 //***************************************************
678 //const Float_t kNsigmaCut = 3;
679 //const Float_t k2sigmaCorr = 1/(0.5*(TMath::Erf(kNsigmaCut/sqrt(2))-TMath::Erf(-kNsigmaCut/sqrt(2))))/*1/0.9545*/;
681 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z for the vertex cut
683 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
685 AliESDtrack *track = 0;
686 AliESDtrack *trackForTOF = 0; //normal track for all TOF information needed when using tpconly-tracks
688 //normal tracks, if tpconly flag is set, use tpconlytracks
689 if (!fUseTPConlyTracks){
690 track =fESD->GetTrack(i);
693 track = fESDtrackCuts->GetTPCOnlyTrack(fESD,i);
694 if (!track) continue;
695 trackForTOF = fESD->GetTrack(i);
698 if (!track->GetInnerParam()) {
699 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
702 Double_t ptot = track->GetInnerParam()->GetP(); // momentum for dEdx determination
703 Double_t pT = track->Pt();
704 track->GetImpactParameters(dca, cov);
707 // cut for dead regions in the detector
708 // if (track->Eta() > 0.1 && (track->Eta() < 0.2 && track->Phi() > 0.1 && track->Phi() < 0.1) continue;
710 // 2.a) apply some standard track cuts according to general recommendations
712 if (!fESDtrackCuts->AcceptTrack(track)) {
713 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
718 if (!fUseTPConlyTracks) status = track->GetStatus();
719 else status = trackForTOF->GetStatus();
720 Bool_t hasTOFout = status&AliESDtrack::kTOFout;
721 Bool_t hasTOFtime = status&AliESDtrack::kTIME;
722 Bool_t hasTOFpid = status&AliESDtrack::kTOFpid;
723 Bool_t hasTOFmismatch = status&AliESDtrack::kTOFmismatch;
724 Bool_t hasTOF = kFALSE;
725 if (hasTOFout && hasTOFtime && hasTOFpid) hasTOF = kTRUE;
728 //check if TRD contributed to tracking and throw track away if fTRDinReject flag is set
729 Bool_t hasTRDin = status&AliESDtrack::kTRDin;
730 if (hasTRDin && fTRDinReject) {
732 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
738 Float_t dxTOF = track->GetTOFsignalDx();
739 Float_t dzTOF = track->GetTOFsignalDz();
741 if (hasTOF) fHistTOFwindow->Fill(dxTOF,dzTOF);
743 //******************************************
744 //*******NEEDS PROPER CUT SETTER************
745 //******************************************
746 //cut on TOF window here
747 if (TMath::Abs(dxTOF) > fTOFwindow || TMath::Abs(dzTOF) > fTOFwindow) hasTOF = kFALSE;
752 if (!fUseTPConlyTracks) length = track->GetIntegratedLength();
753 else length = trackForTOF->GetIntegratedLength();
755 if (length < 350.) hasTOF = kFALSE;
758 // calculate rapidities and kinematics
762 track->GetPxPyPz(pvec);
763 Double_t energyPion = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion));
764 Double_t energyKaon = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon));
765 Double_t energyProton = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
766 Double_t energyDeuteron = TMath::Sqrt(track->GetP()*track->GetP() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
768 Double_t rapPion = 0.5*TMath::Log((energyPion + pvec[2])/(energyPion - pvec[2]));
769 Double_t rapKaon = 0.5*TMath::Log((energyKaon + pvec[2])/(energyKaon - pvec[2]));
770 Double_t rapProton = 0.5*TMath::Log((energyProton + pvec[2])/(energyProton - pvec[2]));
771 Double_t rapDeuteron = 0.5*TMath::Log((energyDeuteron + pvec[2])/(energyDeuteron - pvec[2]));
774 rapPion = rapPion + 0.465;
775 rapKaon = rapKaon + 0.465;
776 rapProton = rapProton + 0.465;
777 rapDeuteron = rapDeuteron + 0.465;
782 // Double_t transMassPion = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion)) - AliPID::ParticleMass(AliPID::kPion);
783 // Double_t transMassKaon = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon)) - AliPID::ParticleMass(AliPID::kKaon);
784 // Double_t transMassProton = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - AliPID::ParticleMass(AliPID::kProton);
785 // Double_t transMassDeuteron = TMath::Sqrt(track->Pt()*track->Pt() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - 2*AliPID::ParticleMass(AliPID::kProton);
789 Double_t sign = track->GetSign();
790 Double_t tpcSignal = track->GetTPCsignal();
793 // 3.a. calculate expected signals in nsigma
796 // (0.) assumed particle: 0. pion, 1. kaon, 2. proton, 3. deuteron
797 // (1.) multiplicity or centrality -- number of accepted ESD tracks per events (deprecated), but now classes from 1 to 10, 0: Min. Bias
800 // (4.) rapidity --> filled 4x
801 // (5.) pull TPC dEx --> filled 4x
802 // (6.) has valid TOF pid signal
803 // (7.) nsigma TOF --> filled 4x
805 // (9.) CODE -- only MC 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
807 // Double_t transMass[4] = {transMassPion,transMassKaon,transMassProton,transMassDeuteron};
808 Double_t rap[4] = {rapPion,rapKaon,rapProton,rapDeuteron};
809 Double_t pullsTPC[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
810 fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
811 fESDpid->NumberOfSigmasTPC(track,AliPID::kProton),
812 0}; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!
815 Float_t time0 = fESDpid->GetTOFResponse().GetStartTime(track->P());
816 //Float_t time0 = fESDpid->GetTOFResponse().GetTimeZero(); //old way of getting time0
817 //fESDpid->GetTOFResponse().SetTimeResolution(130.);
818 Double_t pullsTOF[4] ={0.,0.,0.,0.};
819 if (!fUseTPConlyTracks) {
820 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
821 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
822 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
823 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
826 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
827 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
828 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
829 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
833 // Double_t tpcQA[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kElectron),
834 // fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
835 // fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
836 // fESDpid->NumberOfSigmasTPC(track,AliPID::kProton)};
838 Double_t tofQA[4] = {0.,0.,0.,0.};
839 if (!fUseTPConlyTracks) {
840 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kElectron, time0);
841 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
842 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
843 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
846 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kElectron, time0);
847 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
848 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
849 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
853 //save information for every particle type // loop over assumed particle type
854 for(Int_t iPart = 0; iPart < 3; iPart++) {
856 if (!fSmallTHnSparse) {
857 Double_t vecHistReal[9] = {iPart, centrality, pT, sign, rap[iPart], pullsTPC[iPart], hasTOF, pullsTOF[iPart], dca[0]};
858 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
861 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
862 Double_t vecHistReal[7] = {iPart, centrality, pT, sign, hasTOF, pullsTOF[iPart], dca[0]};
863 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
868 // using MC truth for precise efficiencies...
870 if (fMCtrue && !fOnlyQA) {
871 Int_t code = 9; // code: 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
872 Int_t assumedPdg = 0;//2212(proton); 321(Kaon); 211(pion);
873 Int_t motherCode = -1;
874 if (iPart == 0) assumedPdg = 211;
875 if (iPart == 1) assumedPdg = 321;
876 if (iPart == 2) assumedPdg = 2212;
879 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
880 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
882 if (pdg != assumedPdg && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 2;
883 if (pdg != assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 5;
884 if (pdg == assumedPdg && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
885 if (pdg == assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) {
888 TParticle *trackMother = stack->Particle(TMath::Abs(trackMC->GetFirstMother()));
889 if (trackMother->GetPdgCode() == 310) motherCode = 6; //K0
890 if (trackMother->GetPdgCode() == 3122) motherCode = 7; //Lambda
891 if (trackMother->GetPdgCode() == 3222) motherCode = 8; //Sigma+
894 if (pdg == assumedPdg && stack->IsSecondaryFromMaterial(TMath::Abs(track->GetLabel()))) code = 4;
897 // muons need special treatment, because they are indistinguishable from pions
899 if (iPart == 0 && pdg == 13 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
900 if (iPart == 0 && pdg == 13 && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 3;
902 // check TOF mismatch on MC basis with TOF label
905 if (!fUseTPConlyTracks) track->GetTOFLabel(tofLabel);
906 else trackForTOF->GetTOFLabel(tofLabel);
910 //0: do NOT check at all
912 //2: in case of decays, check if mother label matches --> if yes, assign hasTOF = kTRUE
914 if (fTOFmisMatch == 0) {
915 //if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
917 if (fTOFmisMatch == 1) {
918 if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
920 if (fTOFmisMatch == 2) {
921 if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
922 TParticle *matchedTrack = stack->Particle(TMath::Abs(tofLabel[0]));
923 if (TMath::Abs(matchedTrack->GetFirstMother()) == TMath::Abs(track->GetLabel())) hasTOF = kTRUE;
929 // IMPORTANT BIG PROBLEM HERE THE PROBABLILITY TO HAVE A PID SIGNAL MUST BE IN !!!!!!!!!!!!
931 if (!fSmallTHnSparse){
932 Double_t vectorHistMC[10] = {iPart, centrality, pT, sign, rap[iPart], pullsTPC[iPart], hasTOF, pullsTOF[iPart], dca[0], code};
934 fHistMCparticles->Fill(vectorHistMC);
935 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
936 Double_t vectorHistMCmother[10] = {iPart, centrality, pT, sign, rap[iPart], pullsTPC[iPart], hasTOF, pullsTOF[iPart], dca[0], motherCode};
937 fHistMCparticles->Fill(vectorHistMCmother);
942 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
943 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
944 Double_t vectorHistMC[8] = {iPart, centrality, pT, sign, hasTOF, pullsTOF[iPart], dca[0], code};
946 fHistMCparticles->Fill(vectorHistMC);
947 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
948 Double_t vectorHistMCmother[8] = {iPart, centrality, pT, sign, hasTOF, pullsTOF[iPart], dca[0], motherCode};
949 fHistMCparticles->Fill(vectorHistMCmother);
957 Int_t tpcShared = track->GetTPCnclsS();
958 if (TMath::Abs(track->Eta()) < 0.8 && iPart == 0 && tpcShared < 4) fHistPidQA->Fill(ptot,tpcSignal,sign);
959 } // end loop over assumed particle type
961 //need to delete tpconlytrack
962 if (fUseTPConlyTracks){
967 } // end of track loop
970 PostData(1, fListHist);
975 //________________________________________________________________________
976 void AliAnalysisTPCTOFpA::Terminate(Option_t *)
978 // Draw result to the screen
979 // Called once at the end of the query
980 Printf("*** CONSTRUCTOR CALLED ****");
985 //________________________________________________________________________
986 Bool_t AliAnalysisTPCTOFpA::SelectOnImpPar(AliESDtrack* t) {
988 // cut on transverse impact parameter // DEPRECATED
990 Float_t d0z0[2],covd0z0[3];
991 t->GetImpactParameters(d0z0,covd0z0);
992 Float_t sigma= 0.0050+0.0060/TMath::Power(t->Pt(),0.9);
993 Float_t d0max = 7.*sigma;
995 Float_t sigmaZ = 0.0146+0.0070/TMath::Power(t->Pt(),1.114758);
996 if (t->Pt() > 1) sigmaZ = 0.0216;
997 Float_t d0maxZ = 5.*sigmaZ;
999 if(TMath::Abs(d0z0[0]) < d0max && TMath::Abs(d0z0[1]) < d0maxZ) return kTRUE;
1004 //________________________________________________________________________
1005 void AliAnalysisTPCTOFpA::BinLogAxis(const TH1 *h) {
1007 // Method for the correct logarithmic binning of histograms
1009 TAxis *axis = h->GetXaxis();
1010 int bins = axis->GetNbins();
1012 Double_t from = axis->GetXmin();
1013 Double_t to = axis->GetXmax();
1014 Double_t *newBins = new Double_t[bins + 1];
1017 Double_t factor = pow(to/from, 1./bins);
1019 for (int i = 1; i <= bins; i++) {
1020 newBins[i] = factor * newBins[i-1];
1022 axis->Set(bins, newBins);
1028 //________________________________________________________________________
1029 Int_t AliAnalysisTPCTOFpA::GetPythiaEventProcessType(const AliHeader* aHeader, const Bool_t adebug) const {
1031 // get the process type of the event.
1034 // can only read pythia headers, either directly or from cocktalil header
1035 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
1037 if (!pythiaGenHeader) {
1039 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
1040 if (!genCocktailHeader) {
1041 //printf("AliAnalysisTPCTOFpA::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
1045 TList* headerList = genCocktailHeader->GetHeaders();
1050 for (Int_t i=0; i<headerList->GetEntries(); i++) {
1051 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
1052 if (pythiaGenHeader)
1056 if (!pythiaGenHeader) {
1057 //printf("AliAnalysisTPCTOFpA::GetProcessType : Could not find Pythia header. \n");
1063 //printf("AliAnalysisTPCTOFpA::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
1066 return pythiaGenHeader->ProcessType();