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 = (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 */
462 TString vertexType = vertex->GetTitle();
463 if (vertexType.Contains("vertexer: Z") && (vertex->GetDispersion() > 0.04 || vertex->GetZRes() > 0.25)) isVertexOk = kFALSE; //vertex = 0x0; //
464 if (vertex->GetNContributors()<1) isVertexOk = kFALSE; //vertex = 0x0; //
469 // small track loop to determine trigger Pt, multiplicity or centrality
471 Double_t triggerPt = 0;
472 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
473 AliESDtrack *track =fESD->GetTrack(i);
474 if (!fESDTrackCutsMult->AcceptTrack(track)) continue;
475 if (track->Pt() > triggerPt) triggerPt = track->Pt();
477 Int_t trackCounter = fESDTrackCutsMult->CountAcceptedTracks(fESD);
479 // 2nd multiplicity estimator SPD hits; replaces multiplicity from HBT
481 Float_t spdCorr = -1;
482 const AliMultiplicity *mult = fESD->GetMultiplicity();
483 Float_t nClusters[6]={0.0,0.0,0.0,0.0,0.0,0.0};
484 for(Int_t ilay=0; ilay<6; ilay++) nClusters[ilay] = (Float_t)mult->GetNumberOfITSClusters(ilay);
485 if (vertex) spdCorr = AliESDUtils::GetCorrSPD2(nClusters[1],vertex->GetZ());
487 Float_t centrality = -99;
489 // IMPORTANT CENTRALITY DEFINITION FOR pp
491 if (!fUseHBTmultiplicity) {
492 // test binning to check if multiplicity-dependence is due to diffractive events being s
493 if (trackCounter >= 0 && trackCounter <= 0) centrality = 0;
494 if (trackCounter >= 1 && trackCounter <= 1) centrality = 1;
495 if (trackCounter >= 2 && trackCounter <= 2) centrality = 2;
496 if (trackCounter >= 3 && trackCounter <= 3) centrality = 3;
497 if (trackCounter >= 4 && trackCounter <= 4) centrality = 4;
498 if (trackCounter >= 5 && trackCounter <= 5) centrality = 5;
499 // this was all the original bin 1 being [0..5]
500 if (trackCounter >= 6 && trackCounter <= 9) centrality = 6;
501 if (trackCounter >= 10 && trackCounter <= 14) centrality = 7;
502 if (trackCounter >= 15 && trackCounter <= 22) centrality = 8;
503 if (trackCounter >= 23 && trackCounter <= 32) centrality = 9;
504 if (trackCounter >= 33 && trackCounter <= 42) centrality = 10;
506 if (trackCounter >= 43 && trackCounter <= 52) centrality = 7
507 if (trackCounter >= 53 && trackCounter <= 62) centrality = 8;
508 if (trackCounter >= 63 && trackCounter <= 72) centrality = 9;
509 if (trackCounter >= 73 && trackCounter <= 82) centrality = 10;
512 if (spdCorr >= 0 && spdCorr <= 2) centrality = 0;
513 if (spdCorr >= 3 && spdCorr <= 5) centrality = 1;
514 if (spdCorr >= 6 && spdCorr <= 8) centrality = 2;
515 if (spdCorr >= 9 && spdCorr <= 11) centrality = 3;
516 if (spdCorr >= 12 && spdCorr <= 14) centrality = 4;
517 if (spdCorr >= 15 && spdCorr <= 16) centrality = 5;
518 // this was all the original bin 1 being [0..16]
519 if (spdCorr >= 17 && spdCorr <= 30) centrality = 6;
520 if (spdCorr >= 31 && spdCorr <= 45) centrality = 7;
521 if (spdCorr >= 46 && spdCorr <= 68) centrality = 8;
522 if (spdCorr >= 69 && spdCorr <= 97) centrality = 9;
523 if (spdCorr >= 98) centrality = 10;
525 if (spdCorr >= 17 && spdCorr <= 30) centrality = 2;
526 if (spdCorr >= 31 && spdCorr <= 45) centrality = 3;
527 if (spdCorr >= 46 && spdCorr <= 68) centrality = 4;
528 if (spdCorr >= 69 && spdCorr <= 97) centrality = 5;
529 if (spdCorr >= 98) centrality = 6;
533 //Int_t rootS = fESD->GetBeamEnergy() < 1000 ? 0 : 1;
534 if (fESD->GetEventSpecie() == 4) { // PbPb
536 AliCentrality *esdCentrality = fESD->GetCentrality();
537 centrality = esdCentrality->GetCentralityClass10("V0M") + 1; // centrality percentile determined with V0
538 if (TMath::Abs(centrality - 1) < 1e-5) {
539 centrality = esdCentrality->GetCentralityClass5("V0M");
544 AliCentrality *esdCentrality = fESD->GetCentrality();
545 Float_t pApercentile = esdCentrality->GetCentralityPercentile(fCentEst.Data()); // centrality percentile determined with V0M
546 if (pApercentile >= 0. && pApercentile < 5.) centrality = -1;
547 else if (pApercentile >= 5. && pApercentile < 10.) centrality = 0;
548 else if (pApercentile >= 10. && pApercentile < 20.) centrality = 1;
549 else if (pApercentile >= 20. && pApercentile < 30.) centrality = 2;
550 else if (pApercentile >= 30. && pApercentile < 40.) centrality = 3;
551 else if (pApercentile >= 40. && pApercentile < 50.) centrality = 4;
552 else if (pApercentile >= 50. && pApercentile < 60.) centrality = 5;
553 else if (pApercentile >= 60. && pApercentile < 70.) centrality = 6;
554 else if (pApercentile >= 70. && pApercentile < 80.) centrality = 7;
555 else if (pApercentile >= 80. && pApercentile < 90.) centrality = 8;
556 else if (pApercentile >= 90. && pApercentile <= 100.) centrality = 9;
557 else centrality = -99;
560 cout << "*****************ispA switch works***************************" << endl;
561 cout << "centrality estimator is: " << fCentEst.Data() << endl;
562 cout << "centrality percentile is: " << pApercentile << endl;
563 cout << "*************************************************************" << endl;
570 //Int_t nContributors = 0;
571 //if (fESD->GetPrimaryVertexTPC()) nContributors = fESD->GetPrimaryVertexTPC()->GetNContributors();
574 // Int_t processtype = 0;
575 Int_t processCode = 0;
577 // important change: fill generated only after vertex cut in case of heavy-ions
581 if (!vertex || !isVertexOk) {
582 fHistMult->Fill(-1, processCode);
583 PostData(1, fListHist);
586 if (TMath::Abs(vertex->GetZ()) > 10) {
587 fHistMult->Fill(-1, processCode);
588 PostData(1, fListHist);
601 AliHeader * header = mcEvent->Header();
602 processtype = GetPythiaEventProcessType(header);
604 if (processtype !=92 && processtype !=93 && processtype != 94) processCode = 1;
605 // single diffractive
606 if ((processtype == 92 || processtype == 93)) processCode = 2;
607 // double diffractive
608 if (processtype == 94) processCode = 3;
612 for(Int_t i = 0; i < stack->GetNtrack(); i++) {
613 TParticle * trackMC = stack->Particle(i);
614 Int_t pdg = trackMC->GetPdgCode();
616 Double_t xv = trackMC->Vx();
617 Double_t yv = trackMC->Vy();
618 //Double_t zv = trackMC->Vz();
620 dxy = TMath::Sqrt(xv*xv + yv*yv); // so stupid to avoid warnings
622 //dz = TMath::Abs(zv); // so stupid to avoid warnings
624 // vertex cut - selection of primaries
626 //if (dxy > 3 || dz > 10) continue; // fixed cut at 3cm in r
628 if (!stack->IsPhysicalPrimary(i)) continue;
630 // fill MC histograms here...
632 Double_t rap = trackMC->Y();
633 if (fRapCMS) rap = rap + 0.465;
634 Double_t pT = trackMC->Pt();
635 Int_t sign = pdg < 0 ? -1 : 1; // only works for charged pi,K,p !!
636 // Double_t transMass = TMath::Sqrt(trackMC->Pt()*trackMC->Pt() + trackMC->GetMass()*trackMC->GetMass()) - trackMC->GetMass();
639 if (TMath::Abs(pdg) == 211) iPart = 0; // select Pi+/Pi- only
640 if (TMath::Abs(pdg) == 321) iPart = 1; // select K+/K- only
641 if (TMath::Abs(pdg) == 2212) iPart = 2; // select p+/p- only
642 if (iPart == -1) continue;
645 if (!fSmallTHnSparse){
646 Double_t vecHistMC[10] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), rap, 0, 1, 0, dxy, 0};
647 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
650 if (rap>fRapidityCutLow && rap<fRapidityCutHigh){
651 Double_t vecHistMC[8] = {static_cast<Double_t>(iPart), centrality, pT, static_cast<Double_t>(sign), 1, 0, dxy, 0};
652 if (!fOnlyQA) fHistMCparticles->Fill(vecHistMC);
658 if (!isSelected && !fOnlyQA) {
659 PostData(1, fListHist);
663 if (!vertex || !isVertexOk) {
664 fHistMult->Fill(-1, processCode);
665 PostData(1, fListHist);
668 if (TMath::Abs(vertex->GetZ()) > 10) {
669 fHistMult->Fill(-1, processCode);
670 PostData(1, fListHist);
675 // count events after physics selection and after vertex selection
677 //cout << "MULTIPLICITY " << trackCounter << " " << fESD->GetEventNumberInFile() <<endl;
678 fHistMult->Fill(trackCounter, processCode);
679 fHistCentrality->Fill(centrality);
682 //***************************************************
684 //***************************************************
685 //const Float_t kNsigmaCut = 3;
686 //const Float_t k2sigmaCorr = 1/(0.5*(TMath::Erf(kNsigmaCut/sqrt(2))-TMath::Erf(-kNsigmaCut/sqrt(2))))/*1/0.9545*/;
688 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z for the vertex cut
690 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
692 AliESDtrack *track = 0;
693 AliESDtrack *trackForTOF = 0; //normal track for all TOF information needed when using tpconly-tracks
695 //normal tracks, if tpconly flag is set, use tpconlytracks
696 if (!fUseTPConlyTracks){
697 track =fESD->GetTrack(i);
700 track = fESDtrackCuts->GetTPCOnlyTrack(fESD,i);
701 if (!track) continue;
702 trackForTOF = fESD->GetTrack(i);
705 if (!track->GetInnerParam()) {
706 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
709 Double_t ptot = track->GetInnerParam()->GetP(); // momentum for dEdx determination
710 Double_t pT = track->Pt();
711 track->GetImpactParameters(dca, cov);
714 // cut for dead regions in the detector
715 // if (track->Eta() > 0.1 && (track->Eta() < 0.2 && track->Phi() > 0.1 && track->Phi() < 0.1) continue;
717 // 2.a) apply some standard track cuts according to general recommendations
719 if (!fESDtrackCuts->AcceptTrack(track)) {
720 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
725 if (!fUseTPConlyTracks) status = track->GetStatus();
726 else status = trackForTOF->GetStatus();
727 Bool_t hasTOFout = status&AliESDtrack::kTOFout;
728 Bool_t hasTOFtime = status&AliESDtrack::kTIME;
729 Bool_t hasTOFpid = status&AliESDtrack::kTOFpid;
730 //Bool_t hasTOFmismatch = status&AliESDtrack::kTOFmismatch;
731 Bool_t hasTOF = kFALSE;
732 if (hasTOFout && hasTOFtime && hasTOFpid) hasTOF = kTRUE;
735 //check if TRD contributed to tracking and throw track away if fTRDinReject flag is set
736 Bool_t hasTRDin = status&AliESDtrack::kTRDin;
737 if (hasTRDin && fTRDinReject) {
739 if (fUseTPConlyTracks) {delete track; track = 0;} //need to delete tpconlytrack
745 Float_t dxTOF = track->GetTOFsignalDx();
746 Float_t dzTOF = track->GetTOFsignalDz();
748 if (hasTOF) fHistTOFwindow->Fill(dxTOF,dzTOF);
750 //******************************************
751 //*******NEEDS PROPER CUT SETTER************
752 //******************************************
753 //cut on TOF window here
754 if (TMath::Abs(dxTOF) > fTOFwindow || TMath::Abs(dzTOF) > fTOFwindow) hasTOF = kFALSE;
759 if (!fUseTPConlyTracks) length = track->GetIntegratedLength();
760 else length = trackForTOF->GetIntegratedLength();
762 if (length < 350.) hasTOF = kFALSE;
765 // calculate rapidities and kinematics
769 track->GetPxPyPz(pvec);
770 Double_t energyPion = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion));
771 Double_t energyKaon = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon));
772 Double_t energyProton = TMath::Sqrt(track->GetP()*track->GetP() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
773 Double_t energyDeuteron = TMath::Sqrt(track->GetP()*track->GetP() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton));
775 Double_t rapPion = 0.5*TMath::Log((energyPion + pvec[2])/(energyPion - pvec[2]));
776 Double_t rapKaon = 0.5*TMath::Log((energyKaon + pvec[2])/(energyKaon - pvec[2]));
777 Double_t rapProton = 0.5*TMath::Log((energyProton + pvec[2])/(energyProton - pvec[2]));
778 Double_t rapDeuteron = 0.5*TMath::Log((energyDeuteron + pvec[2])/(energyDeuteron - pvec[2]));
781 rapPion = rapPion + 0.465;
782 rapKaon = rapKaon + 0.465;
783 rapProton = rapProton + 0.465;
784 rapDeuteron = rapDeuteron + 0.465;
789 // Double_t transMassPion = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kPion)*AliPID::ParticleMass(AliPID::kPion)) - AliPID::ParticleMass(AliPID::kPion);
790 // Double_t transMassKaon = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kKaon)*AliPID::ParticleMass(AliPID::kKaon)) - AliPID::ParticleMass(AliPID::kKaon);
791 // Double_t transMassProton = TMath::Sqrt(track->Pt()*track->Pt() + AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - AliPID::ParticleMass(AliPID::kProton);
792 // Double_t transMassDeuteron = TMath::Sqrt(track->Pt()*track->Pt() + 4*AliPID::ParticleMass(AliPID::kProton)*AliPID::ParticleMass(AliPID::kProton)) - 2*AliPID::ParticleMass(AliPID::kProton);
796 Double_t sign = track->GetSign();
797 Double_t tpcSignal = track->GetTPCsignal();
800 // 3.a. calculate expected signals in nsigma
803 // (0.) assumed particle: 0. pion, 1. kaon, 2. proton, 3. deuteron
804 // (1.) multiplicity or centrality -- number of accepted ESD tracks per events (deprecated), but now classes from 1 to 10, 0: Min. Bias
807 // (4.) rapidity --> filled 4x
808 // (5.) pull TPC dEx --> filled 4x
809 // (6.) has valid TOF pid signal
810 // (7.) nsigma TOF --> filled 4x
812 // (9.) CODE -- only MC 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
814 // Double_t transMass[4] = {transMassPion,transMassKaon,transMassProton,transMassDeuteron};
815 Double_t rap[4] = {rapPion,rapKaon,rapProton,rapDeuteron};
816 Double_t pullsTPC[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
817 fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
818 fESDpid->NumberOfSigmasTPC(track,AliPID::kProton),
819 0}; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!
822 Float_t time0 = fESDpid->GetTOFResponse().GetStartTime(track->P());
823 //Float_t time0 = fESDpid->GetTOFResponse().GetTimeZero(); //old way of getting time0
824 //fESDpid->GetTOFResponse().SetTimeResolution(130.);
825 Double_t pullsTOF[4] ={0.,0.,0.,0.};
826 if (!fUseTPConlyTracks) {
827 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
828 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
829 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
830 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
833 pullsTOF[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
834 pullsTOF[1] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
835 pullsTOF[2] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
836 pullsTOF[3] = 0; // ASK FOR PUTTING THE DEUTERON TO AliPID !!!!!!!!!!!!!!;
840 // Double_t tpcQA[4] = {fESDpid->NumberOfSigmasTPC(track,AliPID::kElectron),
841 // fESDpid->NumberOfSigmasTPC(track,AliPID::kPion),
842 // fESDpid->NumberOfSigmasTPC(track,AliPID::kKaon),
843 // fESDpid->NumberOfSigmasTPC(track,AliPID::kProton)};
846 Double_t tofQA[4] = {0.,0.,0.,0.};
847 if (!fUseTPConlyTracks) {
848 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kElectron, time0);
849 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kPion, time0);
850 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kKaon, time0);
851 tofQA[0] = fESDpid->NumberOfSigmasTOF(track,AliPID::kProton, time0);
854 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kElectron, time0);
855 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kPion, time0);
856 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kKaon, time0);
857 tofQA[0] = fESDpid->NumberOfSigmasTOF(trackForTOF,AliPID::kProton, time0);
861 //save information for every particle type // loop over assumed particle type
862 for(Int_t iPart = 0; iPart < 3; iPart++) {
864 if (!fSmallTHnSparse) {
865 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]};
866 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
869 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
870 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]};
871 if (!fOnlyQA) fHistRealTracks->Fill(vecHistReal);
876 // using MC truth for precise efficiencies...
878 if (fMCtrue && !fOnlyQA) {
879 Int_t code = 9; // code: 0-generated, 1-true rec. primaries, 2-misident, 3-second weak, 4-second material
880 Int_t assumedPdg = 0;//2212(proton); 321(Kaon); 211(pion);
881 Int_t motherCode = -1;
882 if (iPart == 0) assumedPdg = 211;
883 if (iPart == 1) assumedPdg = 321;
884 if (iPart == 2) assumedPdg = 2212;
887 TParticle *trackMC = stack->Particle(TMath::Abs(track->GetLabel()));
888 Int_t pdg = TMath::Abs(trackMC->GetPdgCode());
890 if (pdg != assumedPdg) code = 2;
891 //if (pdg != assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 5;
892 if (pdg == assumedPdg && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
893 if (pdg == assumedPdg && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) {
896 TParticle *trackMother = stack->Particle(TMath::Abs(trackMC->GetFirstMother()));
897 if (trackMother->GetPdgCode() == 310) motherCode = 6; //K0
898 if (trackMother->GetPdgCode() == 3122) motherCode = 7; //Lambda
899 if (trackMother->GetPdgCode() == 3222) motherCode = 8; //Sigma+
904 //FILL MATERIAL TEMPLATE FOR KAONS WITH ELECTRONS
906 if (pdg == assumedPdg && stack->IsSecondaryFromMaterial(TMath::Abs(track->GetLabel()))) code = 4;
909 if (pdg == 11) code = 4;
910 //cout << "got an electron for kaons!" << endl;
914 // muons need special treatment, because they are indistinguishable from pions
916 if (iPart == 0 && pdg == 13 && stack->IsPhysicalPrimary(TMath::Abs(track->GetLabel()))) code = 1;
917 if (iPart == 0 && pdg == 13 && stack->IsSecondaryFromWeakDecay(TMath::Abs(track->GetLabel()))) code = 3;
919 // check TOF mismatch on MC basis with TOF label
922 if (!fUseTPConlyTracks) track->GetTOFLabel(tofLabel);
923 else trackForTOF->GetTOFLabel(tofLabel);
927 //0: do NOT check at all
929 //2: in case of decays, check if mother label matches --> if yes, assign hasTOF = kTRUE
931 if (fTOFmisMatch == 0) {
932 //if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
934 if (fTOFmisMatch == 1) {
935 if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
937 if (fTOFmisMatch == 2) {
938 if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) hasTOF = kFALSE;
939 TParticle *matchedTrack = stack->Particle(TMath::Abs(tofLabel[0]));
940 if (TMath::Abs(matchedTrack->GetFirstMother()) == TMath::Abs(track->GetLabel())) hasTOF = kTRUE;
946 // IMPORTANT BIG PROBLEM HERE THE PROBABLILITY TO HAVE A PID SIGNAL MUST BE IN !!!!!!!!!!!!
948 if (!fSmallTHnSparse){
949 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)};
951 fHistMCparticles->Fill(vectorHistMC);
952 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
953 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)};
954 fHistMCparticles->Fill(vectorHistMCmother);
959 if (pullsTPC[iPart]>fTPCnSigmaCutLow && pullsTPC[iPart]<fTPCnSigmaCutHigh && rap[iPart]>fRapidityCutLow && rap[iPart]<fRapidityCutHigh) {
960 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
961 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)};
963 fHistMCparticles->Fill(vectorHistMC);
964 if (motherCode != -1 && fSaveMotherPDG) { //if mother of weak decay is K0, lambda or sigma+ add track again with this information
965 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)};
966 fHistMCparticles->Fill(vectorHistMCmother);
974 Int_t tpcShared = track->GetTPCnclsS();
975 if (TMath::Abs(track->Eta()) < 0.8 && iPart == 0 && tpcShared < 4) fHistPidQA->Fill(ptot,tpcSignal,sign);
976 } // end loop over assumed particle type
978 //need to delete tpconlytrack
979 if (fUseTPConlyTracks){
984 } // end of track loop
987 PostData(1, fListHist);
992 //________________________________________________________________________
993 void AliAnalysisTPCTOFpA::Terminate(Option_t *)
995 // Draw result to the screen
996 // Called once at the end of the query
997 Printf("*** CONSTRUCTOR CALLED ****");
1002 //________________________________________________________________________
1003 Bool_t AliAnalysisTPCTOFpA::SelectOnImpPar(AliESDtrack* t) {
1005 // cut on transverse impact parameter // DEPRECATED
1007 Float_t d0z0[2],covd0z0[3];
1008 t->GetImpactParameters(d0z0,covd0z0);
1009 Float_t sigma= 0.0050+0.0060/TMath::Power(t->Pt(),0.9);
1010 Float_t d0max = 7.*sigma;
1012 Float_t sigmaZ = 0.0146+0.0070/TMath::Power(t->Pt(),1.114758);
1013 if (t->Pt() > 1) sigmaZ = 0.0216;
1014 Float_t d0maxZ = 5.*sigmaZ;
1016 if(TMath::Abs(d0z0[0]) < d0max && TMath::Abs(d0z0[1]) < d0maxZ) return kTRUE;
1021 //________________________________________________________________________
1022 void AliAnalysisTPCTOFpA::BinLogAxis(const TH1 *h) {
1024 // Method for the correct logarithmic binning of histograms
1026 TAxis *axis = const_cast<TAxis*>(h->GetXaxis());
1027 int bins = axis->GetNbins();
1029 Double_t from = axis->GetXmin();
1030 Double_t to = axis->GetXmax();
1031 Double_t *newBins = new Double_t[bins + 1];
1034 Double_t factor = pow(to/from, 1./bins);
1036 for (int i = 1; i <= bins; i++) {
1037 newBins[i] = factor * newBins[i-1];
1039 axis->Set(bins, newBins);
1045 //________________________________________________________________________
1046 Int_t AliAnalysisTPCTOFpA::GetPythiaEventProcessType(const AliHeader* aHeader, const Bool_t adebug) const {
1048 // get the process type of the event.
1051 // can only read pythia headers, either directly or from cocktalil header
1052 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
1054 if (!pythiaGenHeader) {
1056 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
1057 if (!genCocktailHeader) {
1058 //printf("AliAnalysisTPCTOFpA::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
1062 TList* headerList = genCocktailHeader->GetHeaders();
1067 for (Int_t i=0; i<headerList->GetEntries(); i++) {
1068 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
1069 if (pythiaGenHeader)
1073 if (!pythiaGenHeader) {
1074 //printf("AliAnalysisTPCTOFpA::GetProcessType : Could not find Pythia header. \n");
1080 //printf("AliAnalysisTPCTOFpA::GetProcessType : Pythia process type found: %d \n",pythiaGenHeader->ProcessType());
1083 return pythiaGenHeader->ProcessType();