Added loop for extraction of clusters really attached to its track.
[u/mrichter/AliRoot.git] / PWGPP / AliAnalysisTaskFilteredTree.cxx
CommitLineData
1059f583 1/**************************************************************************\r
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3* *\r
4* Author: The ALICE Off-line Project. *\r
5* Contributors are mentioned in the code where appropriate. *\r
6* *\r
7* Permission to use, copy, modify and distribute this software and its *\r
8* documentation strictly for non-commercial purposes is hereby granted *\r
9* without fee, provided that the above copyright notice appears in all *\r
10* copies and that both the copyright notice and this permission notice *\r
11* appear in the supporting documentation. The authors make no claims *\r
12* about the suitability of this software for any purpose. It is *\r
13* provided "as is" without express or implied warranty. *\r
14**************************************************************************/\r
15\r
16#include "iostream"\r
17\r
18#include <TPDGCode.h>\r
19#include <TDatabasePDG.h>\r
20\r
21#include "TChain.h"\r
22#include "TTreeStream.h"\r
23#include "TTree.h"\r
24#include "TH1F.h"\r
30530964 25#include "TH3.h"\r
1059f583 26#include "TCanvas.h"\r
27#include "TList.h"\r
28#include "TObjArray.h"\r
29#include "TFile.h"\r
30#include "TMatrixD.h"\r
31#include "TRandom3.h"\r
32\r
33#include "AliHeader.h" \r
34#include "AliGenEventHeader.h" \r
35#include "AliInputEventHandler.h" \r
36#include "AliStack.h" \r
37#include "AliTrackReference.h" \r
38\r
39#include "AliPhysicsSelection.h"\r
40#include "AliAnalysisTask.h"\r
41#include "AliAnalysisManager.h"\r
42#include "AliESDEvent.h"\r
43#include "AliESDfriend.h"\r
44#include "AliMCEvent.h"\r
45#include "AliESDInputHandler.h"\r
46#include "AliESDVertex.h"\r
47#include "AliTracker.h"\r
2fcfa418 48#include "AliVTrack.h"\r
1059f583 49#include "AliGeomManager.h"\r
50\r
51#include "AliCentrality.h"\r
52#include "AliESDVZERO.h"\r
53#include "AliMultiplicity.h"\r
54\r
55#include "AliESDtrackCuts.h"\r
56#include "AliMCEventHandler.h"\r
57#include "AliFilteredTreeEventCuts.h"\r
58#include "AliFilteredTreeAcceptanceCuts.h"\r
59\r
60#include "AliAnalysisTaskFilteredTree.h"\r
61#include "AliKFParticle.h"\r
62#include "AliESDv0.h"\r
63\r
64using namespace std;\r
65\r
66ClassImp(AliAnalysisTaskFilteredTree)\r
67\r
68//_____________________________________________________________________________\r
69AliAnalysisTaskFilteredTree::AliAnalysisTaskFilteredTree(const char *name) \r
70 : AliAnalysisTaskSE(name)\r
71 , fESD(0)\r
72 , fMC(0)\r
73 , fESDfriend(0)\r
74 , fOutput(0)\r
75 , fPitList(0)\r
76 , fUseMCInfo(kFALSE)\r
77 , fUseESDfriends(kFALSE)\r
2fcfa418 78 , fReducePileUp(kTRUE)\r
30530964 79 , fFillTree(kTRUE)\r
1059f583 80 , fFilteredTreeEventCuts(0)\r
81 , fFilteredTreeAcceptanceCuts(0)\r
82 , fFilteredTreeRecAcceptanceCuts(0)\r
83 , fEsdTrackCuts(0)\r
84 , fTrigger(AliTriggerAnalysis::kMB1) \r
85 , fAnalysisMode(kTPCAnalysisMode) \r
86 , fTreeSRedirector(0)\r
87 , fCentralityEstimator(0)\r
88 , fLowPtTrackDownscaligF(0)\r
89 , fLowPtV0DownscaligF(0)\r
90 , fProcessAll(kFALSE)\r
91 , fProcessCosmics(kFALSE)\r
92 , fHighPtTree(0)\r
93 , fV0Tree(0)\r
94 , fdEdxTree(0)\r
95 , fLaserTree(0)\r
96 , fMCEffTree(0)\r
97 , fCosmicPairsTree(0)\r
30530964 98 , fPtResPhiPtTPC(0)\r
99 , fPtResPhiPtTPCc(0)\r
100 , fPtResPhiPtTPCITS(0)\r
101 , fPtResEtaPtTPC(0)\r
102 , fPtResEtaPtTPCc(0)\r
103 , fPtResEtaPtTPCITS(0)\r
104 , fPtResCentPtTPC(0)\r
105 , fPtResCentPtTPCc(0)\r
106 , fPtResCentPtTPCITS(0)\r
1059f583 107{\r
108 // Constructor\r
109\r
110 // Define input and output slots here\r
111 DefineOutput(1, TTree::Class());\r
112 DefineOutput(2, TTree::Class());\r
113 DefineOutput(3, TTree::Class());\r
114 DefineOutput(4, TTree::Class());\r
115 DefineOutput(5, TTree::Class());\r
116 DefineOutput(6, TTree::Class());\r
30530964 117 DefineOutput(7, TList::Class());\r
1059f583 118}\r
119\r
120//_____________________________________________________________________________\r
121AliAnalysisTaskFilteredTree::~AliAnalysisTaskFilteredTree()\r
122{\r
a1419baa 123 //the output trees not to be deleted in case of proof analysis\r
6d15a846 124 //Bool_t deleteTrees=kTRUE;\r
b4c82bc9 125 //if ((AliAnalysisManager::GetAnalysisManager()))\r
126 //{\r
127 // if (AliAnalysisManager::GetAnalysisManager()->GetAnalysisType() == \r
128 // AliAnalysisManager::kProofAnalysis)\r
129 // deleteTrees=kFALSE;\r
130 //}\r
131 //if (deleteTrees) delete fTreeSRedirector;\r
e4aa7a8e 132\r
a1419baa 133 delete fFilteredTreeEventCuts;\r
134 delete fFilteredTreeAcceptanceCuts;\r
135 delete fFilteredTreeRecAcceptanceCuts;\r
136 delete fEsdTrackCuts;\r
1059f583 137}\r
138\r
139//____________________________________________________________________________\r
140Bool_t AliAnalysisTaskFilteredTree::Notify()\r
141{\r
142 static Int_t count = 0;\r
143 count++;\r
144 TTree *chain = (TChain*)GetInputData(0);\r
145 if(chain)\r
146 {\r
147 Printf("Processing %d. file: %s", count, chain->GetCurrentFile()->GetName());\r
148 }\r
149\r
150return kTRUE;\r
151}\r
152\r
153//_____________________________________________________________________________\r
154void AliAnalysisTaskFilteredTree::UserCreateOutputObjects()\r
155{\r
156 // Create histograms\r
157 // Called once\r
1059f583 158\r
159 //\r
a1419baa 160 //get the output file to make sure the trees will be associated to it\r
161 OpenFile(1);\r
162 fTreeSRedirector = new TTreeSRedirector();\r
1059f583 163 \r
1059f583 164 //\r
165 // Create trees\r
a1419baa 166 fV0Tree = ((*fTreeSRedirector)<<"V0s").GetTree();\r
167 fHighPtTree = ((*fTreeSRedirector)<<"highPt").GetTree();\r
168 fdEdxTree = ((*fTreeSRedirector)<<"dEdx").GetTree();\r
169 fLaserTree = ((*fTreeSRedirector)<<"Laser").GetTree();\r
170 fMCEffTree = ((*fTreeSRedirector)<<"MCEffTree").GetTree();\r
171 fCosmicPairsTree = ((*fTreeSRedirector)<<"CosmicPairs").GetTree();\r
172\r
30530964 173\r
174\r
175\r
176 // histogram booking\r
177\r
178 Double_t minPt = 0.1; \r
179 Double_t maxPt = 100.; \r
180 Int_t nbinsPt = 30; \r
181\r
182 Double_t logminPt = TMath::Log10(minPt);\r
183 Double_t logmaxPt = TMath::Log10(maxPt);\r
184 Double_t binwidth = (logmaxPt-logminPt)/nbinsPt;\r
185 Double_t *binsPt = new Double_t[nbinsPt+1];\r
186 binsPt[0] = minPt;\r
187 for (Int_t i=1;i<=nbinsPt;i++) {\r
188 binsPt[i] = minPt + TMath::Power(10,logminPt+i*binwidth);\r
189 }\r
190\r
191 // 1pT resol cov matrix bins\r
192 Double_t min1PtRes = 0.; \r
193 Double_t max1PtRes = 0.3; \r
194 Int_t nbins1PtRes = 300; \r
195 Double_t bins1PtRes[301];\r
196 for (Int_t i=0;i<=nbins1PtRes;i++) {\r
197 bins1PtRes[i] = min1PtRes + i*(max1PtRes-min1PtRes)/nbins1PtRes;\r
198 }\r
199\r
200 // phi bins\r
201 Double_t minPhi = 0.; \r
202 Double_t maxPhi = 6.5; \r
203 Int_t nbinsPhi = 100; \r
204 Double_t binsPhi[101];\r
205 for (Int_t i=0;i<=nbinsPhi;i++) {\r
206 binsPhi[i] = minPhi + i*(maxPhi-minPhi)/nbinsPhi;\r
207 }\r
208\r
209 // eta bins\r
210 Double_t minEta = -1.;\r
211 Double_t maxEta = 1.;\r
212 Int_t nbinsEta = 20;\r
213 Double_t binsEta[21];\r
214 for (Int_t i=0;i<=nbinsEta;i++) {\r
215 binsEta[i] = minEta + i*(maxEta-minEta)/nbinsEta;\r
216 }\r
217\r
218 // mult bins\r
219 Double_t minCent = 0.;\r
220 Double_t maxCent = 100;\r
221 Int_t nbinsCent = 20;\r
222 Double_t binsCent[101];\r
223 for (Int_t i=0;i<=nbinsCent;i++) {\r
224 binsCent[i] = minCent + i*(maxCent-minCent)/nbinsCent;\r
225 }\r
226 \r
227 fPtResPhiPtTPC = new TH3D("fPtResPhiPtTPC","pt rel. resolution from cov. matrix TPC tracks",nbinsPt,binsPt,nbinsPhi,binsPhi,nbins1PtRes,bins1PtRes);\r
228 fPtResPhiPtTPCc = new TH3D("fPtResPhiPtTPCc","pt rel. resolution from cov. matrix TPC constrained tracks",nbinsPt,binsPt,nbinsPhi,binsPhi,nbins1PtRes,bins1PtRes);\r
229 fPtResPhiPtTPCITS = new TH3D("fPtResPhiPtTPCITS","pt rel. resolution from cov. matrix TPC+ITS tracks",nbinsPt,binsPt,nbinsPhi,binsPhi,nbins1PtRes,bins1PtRes);\r
230 \r
231fPtResEtaPtTPC = new TH3D("fPtResEtaPtTPC","pt rel. resolution from cov. matrix TPC tracks",nbinsPt,binsPt,nbinsEta,binsEta,nbins1PtRes,bins1PtRes);\r
232 fPtResEtaPtTPCc = new TH3D("fPtResEtaPtTPCc","pt rel. resolution from cov. matrix TPC constrained tracks",nbinsPt,binsPt,nbinsEta,binsEta,nbins1PtRes,bins1PtRes);\r
233 fPtResEtaPtTPCITS = new TH3D("fPtResEtaPtTPCITS","pt rel. resolution from cov. matrix TPC+ITS tracks",nbinsPt,binsPt,nbinsEta,binsEta,nbins1PtRes,bins1PtRes);\r
234 \r
235fPtResCentPtTPC = new TH3D("fPtResCentPtTPC","pt rel. resolution from cov. matrix TPC tracks",nbinsPt,binsPt,nbinsCent,binsCent,nbins1PtRes,bins1PtRes);\r
236 fPtResCentPtTPCc = new TH3D("fPtResCentPtTPCc","pt rel. resolution from cov. matrix TPC constrained tracks",nbinsPt,binsPt,nbinsCent,binsCent,nbins1PtRes,bins1PtRes);\r
237 fPtResCentPtTPCITS = new TH3D("fPtResCentPtTPCITS","pt rel. resolution from cov. matrix TPC+ITS tracks",nbinsPt,binsPt,nbinsCent,binsCent,nbins1PtRes,bins1PtRes);\r
238\r
239 \r
240 fOutput = new TList; \r
30530964 241 if(!fOutput) return;\r
03c3e7d9 242 fOutput->SetOwner();\r
30530964 243\r
244 fOutput->Add(fPtResPhiPtTPC);\r
245 fOutput->Add(fPtResPhiPtTPCc);\r
246 fOutput->Add(fPtResPhiPtTPCITS);\r
247 fOutput->Add(fPtResEtaPtTPC);\r
248 fOutput->Add(fPtResEtaPtTPCc);\r
249 fOutput->Add(fPtResEtaPtTPCITS);\r
250 fOutput->Add(fPtResCentPtTPC);\r
251 fOutput->Add(fPtResCentPtTPCc);\r
252 fOutput->Add(fPtResCentPtTPCITS);\r
253\r
254 // post data to outputs\r
255\r
a1419baa 256 PostData(1,fV0Tree);\r
257 PostData(2,fHighPtTree);\r
1059f583 258 PostData(3,fdEdxTree);\r
259 PostData(4,fLaserTree);\r
260 PostData(5,fMCEffTree);\r
261 PostData(6,fCosmicPairsTree);\r
30530964 262\r
263 PostData(7,fOutput);\r
1059f583 264}\r
265\r
266//_____________________________________________________________________________\r
267void AliAnalysisTaskFilteredTree::UserExec(Option_t *) \r
268{\r
269 //\r
270 // Called for each event\r
271 //\r
272\r
273 // ESD event\r
274 fESD = (AliESDEvent*) (InputEvent());\r
275 if (!fESD) {\r
276 Printf("ERROR: ESD event not available");\r
277 return;\r
278 }\r
279\r
b4c82bc9 280 //// MC event\r
281 //if(fUseMCInfo) {\r
282 // fMC = MCEvent();\r
283 // if (!fMC) {\r
284 // Printf("ERROR: MC event not available");\r
285 // return;\r
286 // }\r
287 //}\r
288 \r
289 //if MC info available - use it.\r
290 fMC = MCEvent();\r
1059f583 291\r
292 if(fUseESDfriends) {\r
293 fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r
294 if(!fESDfriend) {\r
295 Printf("ERROR: ESD friends not available");\r
296 }\r
297 }\r
298\r
299 //\r
300 if(fProcessAll) { \r
301 ProcessAll(fESD,fMC,fESDfriend); // all track stages and MC\r
302 }\r
303 else {\r
304 Process(fESD,fMC,fESDfriend); // only global and TPC tracks\r
305 }\r
306\r
307 //\r
308 ProcessV0(fESD,fMC,fESDfriend);\r
309 ProcessLaser(fESD,fMC,fESDfriend);\r
310 ProcessdEdx(fESD,fMC,fESDfriend);\r
311\r
312 if (fProcessCosmics) { ProcessCosmics(fESD); }\r
6d15a846 313 if(fMC) { ProcessMCEff(fESD,fMC,fESDfriend);}\r
1059f583 314}\r
315\r
316//_____________________________________________________________________________\r
317void AliAnalysisTaskFilteredTree::ProcessCosmics(AliESDEvent *const event)\r
318{\r
319 //\r
320 // Select real events with high-pT tracks \r
321 //\r
322 if(!event) {\r
323 AliDebug(AliLog::kError, "event not available");\r
324 return;\r
325 }\r
326\r
327 // \r
328 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
329 if (!inputHandler)\r
330 {\r
331 Printf("ERROR: Could not receive input handler");\r
332 return;\r
333 }\r
334 \r
335 // get file name\r
336 TTree *chain = (TChain*)GetInputData(0);\r
337 if(!chain) { \r
338 Printf("ERROR: Could not receive input chain");\r
339 return;\r
340 }\r
341 TObjString fileName(chain->GetCurrentFile()->GetName());\r
342\r
343\r
344 // check for cosmic pairs\r
345 //\r
346 // find cosmic pairs trigger by random trigger\r
347 //\r
348 //\r
349 AliESDVertex *vertexSPD = (AliESDVertex *)event->GetPrimaryVertexSPD();\r
350 AliESDVertex *vertexTPC = (AliESDVertex *)event->GetPrimaryVertexTPC(); \r
351 const Double_t kMinPt=0.8;\r
352 const Double_t kMinPtMax=0.8;\r
353 const Double_t kMinNcl=50;\r
354 const Double_t kMaxDelta[5]={2,600,0.02,0.02,0.1};\r
355 Int_t ntracks=event->GetNumberOfTracks(); \r
356 // Float_t dcaTPC[2]={0,0};\r
357 // Float_t covTPC[3]={0,0,0};\r
358\r
359 UInt_t specie = event->GetEventSpecie(); // skip laser events\r
360 if (specie==AliRecoParam::kCalib) return;\r
361 \r
362\r
363\r
364 for (Int_t itrack0=0;itrack0<ntracks;itrack0++) {\r
365 AliESDtrack *track0 = event->GetTrack(itrack0);\r
366 if (!track0) continue;\r
367 if (!track0->IsOn(AliESDtrack::kTPCrefit)) continue;\r
368\r
369 if (TMath::Abs(AliTracker::GetBz())>1 && track0->Pt() < kMinPt) continue;\r
370 if (track0->Pt() < kMinPt) continue;\r
371 if (track0->GetTPCncls() < kMinNcl) continue;\r
372 if (TMath::Abs(track0->GetY())<kMaxDelta[0]) continue; \r
373 if (track0->GetKinkIndex(0)>0) continue;\r
374 const Double_t * par0=track0->GetParameter(); //track param at rhe DCA\r
375 //rm primaries\r
376 //\r
377 //track0->GetImpactParametersTPC(dcaTPC,covTPC);\r
378 //if (TMath::Abs(dcaTPC[0])<kMaxDelta[0]) continue;\r
379 //if (TMath::Abs(dcaTPC[1])<kMaxDelta[0]*2) continue;\r
380 // const AliExternalTrackParam * trackIn0 = track0->GetInnerParam();\r
381 for (Int_t itrack1=itrack0+1;itrack1<ntracks;itrack1++) {\r
382 AliESDtrack *track1 = event->GetTrack(itrack1);\r
383 if (!track1) continue; \r
384 if (!track1->IsOn(AliESDtrack::kTPCrefit)) continue;\r
385 if (track1->GetKinkIndex(0)>0) continue;\r
386 if ((TMath::Abs(AliTracker::GetBz())>1) && (track1->Pt() < kMinPt)) continue;\r
387 if (track1->Pt() < kMinPt) continue;\r
388 if (track1->GetTPCncls()<kMinNcl) continue;\r
389 if (TMath::Abs(AliTracker::GetBz())>1 && TMath::Max(track1->Pt(), track0->Pt())<kMinPtMax) continue;\r
390 if (TMath::Abs(track1->GetY())<kMaxDelta[0]) continue;\r
391 //track1->GetImpactParametersTPC(dcaTPC,covTPC);\r
392 // if (TMath::Abs(dcaTPC[0])<kMaxDelta[0]) continue;\r
393 //if (TMath::Abs(dcaTPC[1])<kMaxDelta[0]*2) continue;\r
394 //\r
395 const Double_t* par1=track1->GetParameter(); //track param at rhe DCA\r
396 //\r
397 Bool_t isPair=kTRUE;\r
398 for (Int_t ipar=0; ipar<5; ipar++){\r
399 if (ipar==4&&TMath::Abs(AliTracker::GetBz())<1) continue; // 1/pt not defined for B field off\r
400 if (TMath::Abs(TMath::Abs(par0[ipar])-TMath::Abs(par1[ipar]))>kMaxDelta[ipar]) isPair=kFALSE;\r
401 }\r
402 if (!isPair) continue;\r
403 if (TMath::Abs(TMath::Abs(track0->GetAlpha()-track1->GetAlpha())-TMath::Pi())>kMaxDelta[2]) isPair=kFALSE;\r
404 //delta with correct sign\r
405 /*\r
406 TCut cut0="abs(t1.fP[0]+t0.fP[0])<2"\r
407 TCut cut3="abs(t1.fP[3]+t0.fP[3])<0.02"\r
408 TCut cut4="abs(t1.fP[4]+t0.fP[4])<0.2"\r
409 */\r
410 if (TMath::Abs(par0[0]+par1[0])>kMaxDelta[0]) isPair=kFALSE; //delta y opposite sign\r
411 if (TMath::Abs(par0[3]+par1[3])>kMaxDelta[3]) isPair=kFALSE; //delta tgl opposite sign\r
412 if (TMath::Abs(AliTracker::GetBz())>1 && TMath::Abs(par0[4]+par1[4])>kMaxDelta[4]) isPair=kFALSE; //delta 1/pt opposite sign\r
413 if (!isPair) continue;\r
414 TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());\r
415 Int_t eventNumber = event->GetEventNumberInFile(); \r
416 //Bool_t hasFriend = kFALSE;\r
417 //Bool_t hasITS=(track0->GetNcls(0)+track1->GetNcls(0)>4);\r
418 //printf("DUMPHPTCosmic:%s|%f|%d|%d|%d\n",filename.Data(),(TMath::Min(track0->Pt(),track1->Pt())), eventNumber,hasFriend,hasITS);\r
419 // const AliExternalTrackParam * trackIn1 = track1->GetInnerParam(); \r
420 //\r
421 // \r
422 Int_t ntracksSPD = vertexSPD->GetNContributors();\r
423 Int_t ntracksTPC = vertexTPC->GetNContributors(); \r
424 Int_t runNumber = event->GetRunNumber(); \r
425 Int_t timeStamp = event->GetTimeStamp();\r
426 ULong64_t triggerMask = event->GetTriggerMask();\r
427 Float_t magField = event->GetMagneticField();\r
428 TObjString triggerClass = event->GetFiredTriggerClasses().Data();\r
429 \r
430 //\r
431 // Dump to the tree \r
432 // vertex\r
433 // TPC-ITS tracks\r
434 //\r
a1419baa 435\r
436 //fCosmicPairsTree->Branch("fileName",&fileName,32000,0);\r
437 //fCosmicPairsTree->Branch("runNumber",&runNumber,"runNumber/I");\r
438 //fCosmicPairsTree->Branch("timeStamp",&timeStamp,"timeStamp/I");\r
439 //fCosmicPairsTree->Branch("eventNumber",&eventNumber,"eventNumber/I");\r
440 //fCosmicPairsTree->Branch("triggerMask",&triggerMask,32000,0);\r
441 //fCosmicPairsTree->Branch("triggerClass",&triggerClass,32000,0);\r
442 //fCosmicPairsTree->Branch("magField",&magField,"magField/F");\r
443 //fCosmicPairsTree->Branch("ntracksSPD",&ntracksSPD,"ntracksSPD/I");\r
444 //fCosmicPairsTree->Branch("ntracksTPC",&ntracksTPC,"ntracksTPC/I");\r
445 //fCosmicPairsTree->Branch("vertexSPD",vertexSPD,32000,0);\r
446 //fCosmicPairsTree->Branch("vertexTPC",vertexTPC,32000,0);\r
447 //fCosmicPairsTree->Branch("track0",track0,32000,0);\r
448 //fCosmicPairsTree->Branch("track1",track1,32000,0);\r
449 //\r
450 //fCosmicPairsTree->Fill();\r
451\r
30530964 452 if(!fFillTree) return;\r
1059f583 453 if(!fTreeSRedirector) return;\r
454 (*fTreeSRedirector)<<"CosmicPairs"<<\r
455 "fileName.="<<&fileName<< // file name\r
456 "runNumber="<<runNumber<< // run number \r
457 "evtTimeStamp="<<timeStamp<< // time stamp of event\r
458 "evtNumberInFile="<<eventNumber<< // event number \r
459 "trigger="<<triggerMask<< // trigger\r
04fe1e30 460 "triggerClass="<<&triggerClass<< // trigger\r
1059f583 461 "Bz="<<magField<< // magnetic field\r
462 //\r
463 "multSPD="<<ntracksSPD<<\r
464 "multTPC="<<ntracksTPC<<\r
465 "vertSPD.="<<vertexSPD<< //primary vertex -SPD\r
466 "vertTPC.="<<vertexTPC<< //primary vertex -TPC\r
467 "t0.="<<track0<< //track0\r
468 "t1.="<<track1<< //track1\r
469 "\n"; \r
470 }\r
471 }\r
472}\r
473\r
474\r
475//_____________________________________________________________________________\r
476void AliAnalysisTaskFilteredTree::Process(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const /*esdFriend*/)\r
477{\r
478 //\r
479 // Select real events with high-pT tracks \r
480 //\r
481 if(!esdEvent) {\r
482 AliDebug(AliLog::kError, "esdEvent not available");\r
483 return;\r
484 }\r
485\r
486 // get selection cuts\r
487 AliFilteredTreeEventCuts *evtCuts = GetEventCuts(); \r
488 AliFilteredTreeAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
489 AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
490\r
491 if(!evtCuts || !accCuts || !esdTrackCuts) {\r
492 Printf("ERROR cuts not available");\r
493 return;\r
494 }\r
495\r
496 // trigger selection\r
497 Bool_t isEventTriggered = kTRUE;\r
498 AliPhysicsSelection *physicsSelection = NULL;\r
499 AliTriggerAnalysis* triggerAnalysis = NULL;\r
500\r
501 // \r
502 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
503 if (!inputHandler)\r
504 {\r
505 Printf("ERROR: Could not receive input handler");\r
506 return;\r
507 }\r
508 \r
509 // get file name\r
510 TTree *chain = (TChain*)GetInputData(0);\r
511 if(!chain) { \r
512 Printf("ERROR: Could not receive input chain");\r
513 return;\r
514 }\r
515 TObjString fileName(chain->GetCurrentFile()->GetName());\r
516\r
517 // trigger\r
518 if(evtCuts->IsTriggerRequired()) \r
519 {\r
520 // always MB\r
521 isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
522\r
523 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
524 if(!physicsSelection) return;\r
525 //SetPhysicsTriggerSelection(physicsSelection);\r
526\r
527 if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
528 // set trigger (V0AND)\r
529 triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
530 if(!triggerAnalysis) return;\r
531 isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
532 }\r
533 }\r
534\r
535 // centrality determination\r
536 Float_t centralityF = -1;\r
537 AliCentrality *esdCentrality = esdEvent->GetCentrality();\r
538 centralityF = esdCentrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
539\r
540 // use MC information\r
541 AliHeader* header = 0;\r
542 AliGenEventHeader* genHeader = 0;\r
543 AliStack* stack = 0;\r
544 TArrayF vtxMC(3);\r
545\r
546 Int_t multMCTrueTracks = 0;\r
6d15a846 547 if(mcEvent)\r
1059f583 548 {\r
1059f583 549 // get MC event header\r
550 header = mcEvent->Header();\r
551 if (!header) {\r
552 AliDebug(AliLog::kError, "Header not available");\r
553 return;\r
554 }\r
555 // MC particle stack\r
556 stack = mcEvent->Stack();\r
557 if (!stack) {\r
558 AliDebug(AliLog::kError, "Stack not available");\r
559 return;\r
560 }\r
561\r
562 // get MC vertex\r
563 genHeader = header->GenEventHeader();\r
564 if (!genHeader) {\r
565 AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
566 return;\r
567 }\r
568 genHeader->PrimaryVertex(vtxMC);\r
569\r
570 // multipliticy of all MC primary tracks\r
571 // in Zv, pt and eta ranges)\r
572 multMCTrueTracks = GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
1059f583 573 } // end bUseMC\r
574\r
575 // get reconstructed vertex \r
576 //const AliESDVertex* vtxESD = 0; \r
577 AliESDVertex* vtxESD = 0; \r
578 if(GetAnalysisMode() == kTPCAnalysisMode) {\r
579 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTPC();\r
580 }\r
581 else if(GetAnalysisMode() == kTPCITSAnalysisMode) {\r
582 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTracks();\r
583 }\r
584 else {\r
585 return;\r
586 }\r
587\r
588 if(!vtxESD) return;\r
589\r
590 Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
591 //printf("isEventOK %d, isEventTriggered %d, status %d, vz %f \n",isEventOK, isEventTriggered, vtxESD->GetStatus(), vtxESD->GetZv());\r
592 //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
2fcfa418 593 Int_t ntracks = esdEvent->GetNumberOfTracks();\r
1059f583 594\r
595 // check event cuts\r
596 if(isEventOK && isEventTriggered)\r
597 {\r
598\r
599 //\r
600 // get IR information\r
601 //\r
602 AliESDHeader *esdHeader = 0;\r
603 esdHeader = esdEvent->GetHeader();\r
604 if(!esdHeader) return;\r
605 //Int_t ir1 = esdHeader->GetTriggerIREntries(); //all ir-s\r
606 //Int_t ir2 = esdHeader->GetTriggerIREntries(-1,1); // int2 set, 180 ms time interval\r
607\r
608 // Use when Peter commit the changes in the header\r
609 Int_t ir1 = 0;\r
610 Int_t ir2 = 0;\r
611\r
612 //\r
613 Double_t vert[3] = {0}; \r
614 vert[0] = vtxESD->GetXv();\r
615 vert[1] = vtxESD->GetYv();\r
616 vert[2] = vtxESD->GetZv();\r
617 Int_t mult = vtxESD->GetNContributors();\r
a1419baa 618 Float_t bz = esdEvent->GetMagneticField();\r
619 Int_t runNumber = esdEvent->GetRunNumber();\r
620 Int_t evtTimeStamp = esdEvent->GetTimeStamp();\r
1059f583 621 Int_t evtNumberInFile = esdEvent->GetEventNumberInFile();\r
622\r
623 // high pT tracks\r
624 for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
625 {\r
626 AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
627 if(!track) continue;\r
628 if(track->Charge()==0) continue;\r
629 if(!esdTrackCuts->AcceptTrack(track)) continue;\r
630 if(!accCuts->AcceptTrack(track)) continue;\r
631 \r
632 // downscale low-pT tracks\r
633 Double_t scalempt= TMath::Min(track->Pt(),10.);\r
634 Double_t downscaleF = gRandom->Rndm();\r
635 downscaleF *= fLowPtTrackDownscaligF;\r
636 if(TMath::Exp(2*scalempt)<downscaleF) continue;\r
637 //printf("TMath::Exp(2*scalempt) %e, downscaleF %e \n",TMath::Exp(2*scalempt), downscaleF);\r
638\r
639 AliExternalTrackParam * tpcInner = (AliExternalTrackParam *)(track->GetTPCInnerParam());\r
640 if (!tpcInner) continue;\r
641 // transform to the track reference frame \r
642 Bool_t isOK = kFALSE;\r
643 isOK = tpcInner->Rotate(track->GetAlpha());\r
644 isOK = tpcInner->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
645 if(!isOK) continue;\r
646\r
647 // Dump to the tree \r
648 // vertex\r
649 // TPC-ITS tracks\r
650 //\r
04fe1e30 651 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
a1419baa 652\r
653 //fHighPtTree->Branch("fileName",&fileName,32000,0);\r
654 //fHighPtTree->Branch("runNumber",&runNumber,"runNumber/I");\r
655 //fHighPtTree->Branch("evtTimeStamp",&evtTimeStamp,"evtTimeStamp/I");\r
656 //fHighPtTree->Branch("evtNumberInFile",&evtNumberInFile,"evtNumberInFile/I");\r
657 //fHighPtTree->Branch("triggerClass",&triggerClass,32000,0);\r
658 //fHighPtTree->Branch("Bz",&bz,"Bz/F");\r
659 //fHighPtTree->Branch("vtxESD",vtxESD,32000,0);\r
660 //fHighPtTree->Branch("IRtot",&ir1,"IRtot/I");\r
661 //fHighPtTree->Branch("IRint2",&ir2,"IRint2/I");\r
662 //fHighPtTree->Branch("mult",&mult,"mult/I");\r
663 //fHighPtTree->Branch("esdTrack",track,32000,0);\r
664 //fHighPtTree->Branch("centralityF",&centralityF,"centralityF/F");\r
665\r
666 //fHighPtTree->Fill();\r
667\r
668 //Double_t vtxX=vtxESD->GetX();\r
669 //Double_t vtxY=vtxESD->GetY();\r
670 //Double_t vtxZ=vtxESD->GetZ();\r
30530964 671 if(!fFillTree) return;\r
1059f583 672 if(!fTreeSRedirector) return;\r
673 (*fTreeSRedirector)<<"highPt"<<\r
2fcfa418 674 "fileName.="<<&fileName<< \r
1059f583 675 "runNumber="<<runNumber<<\r
676 "evtTimeStamp="<<evtTimeStamp<<\r
677 "evtNumberInFile="<<evtNumberInFile<<\r
04fe1e30 678 "triggerClass="<<&triggerClass<< // trigger\r
2fcfa418 679 "Bz="<<bz<< // magnetic field\r
1059f583 680 "vtxESD.="<<vtxESD<<\r
2fcfa418 681 "ntracksESD="<<ntracks<< // number of tracks in the ESD\r
a1419baa 682 // "vtxESDx="<<vtxX<<\r
683 // "vtxESDy="<<vtxY<<\r
684 // "vtxESDz="<<vtxZ<<\r
2fcfa418 685 "IRtot="<<ir1<< // interaction record history info\r
1059f583 686 "IRint2="<<ir2<<\r
2fcfa418 687 "mult="<<mult<< // multiplicity of tracks pointing to the primary vertex\r
1059f583 688 "esdTrack.="<<track<<\r
2fcfa418 689 "centralityF="<<centralityF<< \r
1059f583 690 "\n";\r
691 }\r
692 }\r
693 \r
694}\r
695\r
696\r
697//_____________________________________________________________________________\r
698void AliAnalysisTaskFilteredTree::ProcessLaser(AliESDEvent *const esdEvent, AliMCEvent * const /*mcEvent*/, AliESDfriend *const /*esdFriend*/)\r
699{\r
700 //\r
701 // Process laser events\r
702 //\r
703 if(!esdEvent) {\r
704 AliDebug(AliLog::kError, "esdEvent not available");\r
705 return;\r
706 }\r
707\r
708 // get file name\r
709 TTree *chain = (TChain*)GetInputData(0);\r
710 if(!chain) { \r
711 Printf("ERROR: Could not receive input chain");\r
712 return;\r
713 }\r
714 TObjString fileName(chain->GetCurrentFile()->GetName());\r
715\r
716 // laser events \r
717 const AliESDHeader* esdHeader = esdEvent->GetHeader();\r
718 if(esdHeader && esdHeader->GetEventSpecie()==AliRecoParam::kCalib) \r
719 {\r
720 Int_t countLaserTracks = 0;\r
721 for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
722 {\r
723 AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
724 if(!track) continue;\r
725\r
726 if(track->GetTPCInnerParam()) countLaserTracks++;\r
727 }\r
728 \r
729 if(countLaserTracks > 100) \r
730 { \r
a1419baa 731 Int_t runNumber = esdEvent->GetRunNumber();\r
732 Int_t evtTimeStamp = esdEvent->GetTimeStamp();\r
1059f583 733 Int_t evtNumberInFile = esdEvent->GetEventNumberInFile();\r
a1419baa 734 Float_t bz = esdEvent->GetMagneticField();\r
04fe1e30 735 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
1059f583 736\r
a1419baa 737 //fLaserTree->Branch("fileName",&fileName,32000,0);\r
738 //fLaserTree->Branch("runNumber",&runNumber,"runNumber/I");\r
739 //fLaserTree->Branch("evtTimeStamp",&evtTimeStamp,"evtTimeStamp/I");\r
740 //fLaserTree->Branch("evtNumberInFile",&evtNumberInFile,"evtNumberInFile/I");\r
741 //fLaserTree->Branch("triggerClass",&triggerClass,32000,0);\r
742 //fLaserTree->Branch("Bz",&bz,"Bz/F");\r
743 //fLaserTree->Branch("multTPCtracks",&countLaserTracks,"multTPCtracks/I");\r
744\r
745 //fLaserTree->Fill();\r
746\r
30530964 747 if(!fFillTree) return;\r
1059f583 748 if(!fTreeSRedirector) return;\r
749 (*fTreeSRedirector)<<"Laser"<<\r
750 "fileName.="<<&fileName<<\r
751 "runNumber="<<runNumber<<\r
752 "evtTimeStamp="<<evtTimeStamp<<\r
753 "evtNumberInFile="<<evtNumberInFile<<\r
04fe1e30 754 "triggerClass="<<&triggerClass<< // trigger\r
1059f583 755 "Bz="<<bz<<\r
756 "multTPCtracks="<<countLaserTracks<<\r
757 "\n";\r
758 }\r
759 }\r
760}\r
761\r
762//_____________________________________________________________________________\r
763void AliAnalysisTaskFilteredTree::ProcessAll(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const esdFriend)\r
764{\r
765 //\r
766 // Select real events with high-pT tracks\r
767 // Calculate and stor in the output tree:\r
768 // TPC constrained tracks\r
769 // InnerParams constrained tracks\r
770 // TPC-ITS tracks\r
771 // ITSout-InnerParams tracks\r
772 // chi2 distance between TPC constrained and TPC-ITS tracks\r
773 // chi2 distance between TPC refitted constrained and TPC-ITS tracks\r
774 // chi2 distance between ITSout and InnerParams tracks\r
775 // MC information: \r
776 // track references at ITSin, TPCin; InnerParam at first TPC track reference, \r
777 // particle ID, mother ID, production mechanism ...\r
778 // \r
779\r
780 if(!esdEvent) {\r
781 AliDebug(AliLog::kError, "esdEvent not available");\r
782 return;\r
783 }\r
784\r
785 // get selection cuts\r
786 AliFilteredTreeEventCuts *evtCuts = GetEventCuts(); \r
787 AliFilteredTreeAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
788 AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
789\r
790 if(!evtCuts || !accCuts || !esdTrackCuts) {\r
791 AliDebug(AliLog::kError, "cuts not available");\r
792 return;\r
793 }\r
794\r
795 // trigger selection\r
796 Bool_t isEventTriggered = kTRUE;\r
797 AliPhysicsSelection *physicsSelection = NULL;\r
798 AliTriggerAnalysis* triggerAnalysis = NULL;\r
799\r
800 // \r
801 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
802 if (!inputHandler)\r
803 {\r
804 Printf("ERROR: Could not receive input handler");\r
805 return;\r
806 }\r
807 \r
808 // get file name\r
809 TTree *chain = (TChain*)GetInputData(0);\r
810 if(!chain) { \r
811 Printf("ERROR: Could not receive input chain");\r
812 return;\r
813 }\r
814 TObjString fileName(chain->GetCurrentFile()->GetName());\r
815\r
816 // trigger\r
817 if(evtCuts->IsTriggerRequired()) \r
818 {\r
819 // always MB\r
820 isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
821\r
822 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
6d15a846 823 if(!physicsSelection) {AliInfo("no physics selection"); return;}\r
1059f583 824 //SetPhysicsTriggerSelection(physicsSelection);\r
825\r
826 if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
827 // set trigger (V0AND)\r
828 triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
6d15a846 829 if(!triggerAnalysis) {AliInfo("no trigger analysis");return;}\r
1059f583 830 isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
831 }\r
832 }\r
833\r
834 // centrality determination\r
835 Float_t centralityF = -1;\r
836 AliCentrality *esdCentrality = esdEvent->GetCentrality();\r
837 centralityF = esdCentrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
838\r
839 // use MC information\r
840 AliHeader* header = 0;\r
841 AliGenEventHeader* genHeader = 0;\r
842 AliStack* stack = 0;\r
843 TArrayF vtxMC(3);\r
1d924a2e 844 Int_t mcStackSize=0;\r
1059f583 845\r
846 Int_t multMCTrueTracks = 0;\r
6d15a846 847 if(mcEvent)\r
1059f583 848 {\r
1059f583 849 // get MC event header\r
850 header = mcEvent->Header();\r
851 if (!header) {\r
852 AliDebug(AliLog::kError, "Header not available");\r
853 return;\r
854 }\r
855 // MC particle stack\r
856 stack = mcEvent->Stack();\r
857 if (!stack) {\r
858 AliDebug(AliLog::kError, "Stack not available");\r
859 return;\r
860 }\r
1d924a2e 861 mcStackSize=stack->GetNtrack();\r
1059f583 862\r
863 // get MC vertex\r
864 genHeader = header->GenEventHeader();\r
865 if (!genHeader) {\r
866 AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
867 return;\r
868 }\r
869 genHeader->PrimaryVertex(vtxMC);\r
870\r
871 // multipliticy of all MC primary tracks\r
872 // in Zv, pt and eta ranges)\r
873 multMCTrueTracks = GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
874\r
875 } // end bUseMC\r
876\r
877 // get reconstructed vertex \r
878 //const AliESDVertex* vtxESD = 0; \r
879 AliESDVertex* vtxESD = 0; \r
880 if(GetAnalysisMode() == kTPCAnalysisMode) {\r
881 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTPC();\r
882 }\r
883 else if(GetAnalysisMode() == kTPCITSAnalysisMode) {\r
884 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTracks();\r
885 }\r
886 else {\r
6d15a846 887 AliInfo("no ESD vertex");\r
1059f583 888 return;\r
889 }\r
890\r
891 if(!vtxESD) return;\r
892\r
893 Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
894 //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
895 //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
896\r
897\r
898 // check event cuts\r
899 if(isEventOK && isEventTriggered)\r
900 {\r
901 //\r
902 // get IR information\r
903 //\r
904 AliESDHeader *esdHeader = 0;\r
905 esdHeader = esdEvent->GetHeader();\r
6d15a846 906 if(!esdHeader) {AliInfo("no esdHeader");return;}\r
1059f583 907 //Int_t ir1 = esdHeader->GetTriggerIREntries(); //all ir-s\r
908 //Int_t ir2 = esdHeader->GetTriggerIREntries(-1,1); // int2 set, 180 ms time interval\r
909 //\r
910 Int_t ir1 = 0;\r
911 Int_t ir2 = 0;\r
912\r
913 //\r
914 Double_t vert[3] = {0}; \r
915 vert[0] = vtxESD->GetXv();\r
916 vert[1] = vtxESD->GetYv();\r
917 vert[2] = vtxESD->GetZv();\r
918 Int_t mult = vtxESD->GetNContributors();\r
a1419baa 919 Float_t bz = esdEvent->GetMagneticField();\r
920 Int_t runNumber = esdEvent->GetRunNumber();\r
921 Int_t evtTimeStamp = esdEvent->GetTimeStamp();\r
1059f583 922 Int_t evtNumberInFile = esdEvent->GetEventNumberInFile();\r
923\r
924 // high pT tracks\r
925 for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
926 {\r
927 AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
928 if(!track) continue;\r
929 if(track->Charge()==0) continue;\r
930 if(!esdTrackCuts->AcceptTrack(track)) continue;\r
931 if(!accCuts->AcceptTrack(track)) continue;\r
932 \r
933 // downscale low-pT tracks\r
934 Double_t scalempt= TMath::Min(track->Pt(),10.);\r
935 Double_t downscaleF = gRandom->Rndm();\r
936 downscaleF *= fLowPtTrackDownscaligF;\r
937 if(TMath::Exp(2*scalempt)<downscaleF) continue;\r
938 //printf("TMath::Exp(2*scalempt) %e, downscaleF %e \n",TMath::Exp(2*scalempt), downscaleF);\r
939\r
940 // Dump to the tree \r
941 // vertex\r
942 // TPC constrained tracks\r
943 // InnerParams constrained tracks\r
944 // TPC-ITS tracks\r
945 // ITSout-InnerParams tracks\r
946 // chi2 distance between TPC constrained and TPC-ITS tracks\r
947 // chi2 distance between TPC refitted constrained and TPC-ITS tracks\r
948 // chi2 distance between ITSout and InnerParams tracks\r
949 // MC information\r
950 \r
951 Double_t x[3]; track->GetXYZ(x);\r
952 Double_t b[3]; AliTracker::GetBxByBz(x,b);\r
953\r
954 //\r
955 // Transform TPC inner params to track reference frame\r
956 //\r
957 Bool_t isOKtpcInner = kFALSE;\r
958 AliExternalTrackParam * tpcInner = (AliExternalTrackParam *)(track->GetTPCInnerParam());\r
959 if (tpcInner) {\r
960 // transform to the track reference frame \r
961 isOKtpcInner = tpcInner->Rotate(track->GetAlpha());\r
962 isOKtpcInner = tpcInner->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
963 }\r
964\r
965 //\r
966 // Constrain TPC inner to vertex\r
967 // clone TPCinner has to be deleted\r
968 //\r
969 Bool_t isOKtpcInnerC = kFALSE;\r
970 AliExternalTrackParam * tpcInnerC = new AliExternalTrackParam(*(track->GetTPCInnerParam()));\r
971 if (tpcInnerC) {\r
972 isOKtpcInnerC = ConstrainTPCInner(tpcInnerC,vtxESD,b);\r
973 isOKtpcInnerC = tpcInnerC->Rotate(track->GetAlpha());\r
974 isOKtpcInnerC = tpcInnerC->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
975 }\r
976\r
977 //\r
978 // Constrain TPC refitted tracks at inner TPC wall (InnerParams) to vertex \r
979 // Clone track InnerParams has to be deleted\r
980 //\r
981 Bool_t isOKtrackInnerC = kFALSE;\r
982 AliExternalTrackParam * trackInnerC = new AliExternalTrackParam(*(track->GetInnerParam()));\r
983 if (trackInnerC) {\r
984 isOKtrackInnerC = ConstrainTrackInner(trackInnerC,vtxESD,track->GetMass(),b);\r
985 isOKtrackInnerC = trackInnerC->Rotate(track->GetAlpha());\r
986 isOKtrackInnerC = trackInnerC->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
987 } \r
988 \r
989 //\r
990 // calculate chi2 between vi and vj vectors\r
991 // with covi and covj covariance matrices\r
992 // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)\r
993 //\r
994 TMatrixD deltaT(5,1), deltaTtrackC(5,1);\r
995 TMatrixD delta(1,5), deltatrackC(1,5);\r
996 TMatrixD covarM(5,5), covarMtrackC(5,5);\r
997 TMatrixD chi2(1,1);\r
998 TMatrixD chi2trackC(1,1);\r
999\r
1000 if(isOKtpcInnerC && isOKtrackInnerC) \r
1001 {\r
1002 for (Int_t ipar=0; ipar<5; ipar++) {\r
1003 deltaT(ipar,0)=tpcInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
1004 delta(0,ipar)=tpcInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
1005\r
1006 deltaTtrackC(ipar,0)=trackInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
1007 deltatrackC(0,ipar)=trackInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
1008\r
1009 for (Int_t jpar=0; jpar<5; jpar++) {\r
1010 Int_t index=track->GetIndex(ipar,jpar);\r
1011 covarM(ipar,jpar)=track->GetCovariance()[index]+tpcInnerC->GetCovariance()[index];\r
1012 covarMtrackC(ipar,jpar)=track->GetCovariance()[index]+trackInnerC->GetCovariance()[index];\r
1013 }\r
1014 }\r
1015\r
1016 // chi2 distance TPC constrained and TPC+ITS\r
1017 TMatrixD covarMInv = covarM.Invert();\r
1018 TMatrixD mat2 = covarMInv*deltaT;\r
1019 chi2 = delta*mat2; \r
1020 //chi2.Print();\r
1021\r
1022 // chi2 distance TPC refitted constrained and TPC+ITS\r
1023 TMatrixD covarMInvtrackC = covarMtrackC.Invert();\r
1024 TMatrixD mat2trackC = covarMInvtrackC*deltaTtrackC;\r
1025 chi2trackC = deltatrackC*mat2trackC; \r
1026 //chi2trackC.Print();\r
1027 }\r
1028\r
1029\r
1030 //\r
1031 // Propagate ITSout to TPC inner wall \r
1032 // and calculate chi2 distance to track (InnerParams)\r
1033 //\r
1034 const Double_t kTPCRadius=85; \r
1035 const Double_t kStep=3; \r
1036\r
1037 // clone track InnerParams has to be deleted\r
1038 Bool_t isOKtrackInnerC2 = kFALSE;\r
1039 AliExternalTrackParam *trackInnerC2 = new AliExternalTrackParam(*(track->GetInnerParam()));\r
1040 if (trackInnerC2) {\r
1041 isOKtrackInnerC2 = AliTracker::PropagateTrackToBxByBz(trackInnerC2,kTPCRadius,track->GetMass(),kStep,kFALSE);\r
1042 }\r
1043\r
1044 Bool_t isOKouterITSc = kFALSE;\r
1045 AliExternalTrackParam *outerITSc = NULL;\r
1046 TMatrixD chi2OuterITS(1,1);\r
1047\r
1048 if(esdFriend && esdFriend->TestSkipBit()==kFALSE) \r
1049 {\r
1050 // propagate ITSout to TPC inner wall\r
1051 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(iTrack);\r
1052\r
1053 if(friendTrack) \r
1054 {\r
1055 outerITSc = new AliExternalTrackParam(*friendTrack->GetITSOut());\r
1056 if(outerITSc) \r
1057 {\r
1058 isOKouterITSc = AliTracker::PropagateTrackToBxByBz(outerITSc,kTPCRadius,track->GetMass(),kStep,kFALSE);\r
1059 isOKouterITSc = outerITSc->Rotate(trackInnerC2->GetAlpha());\r
1060 isOKouterITSc = outerITSc->PropagateTo(trackInnerC2->GetX(),esdEvent->GetMagneticField());\r
1061\r
1062 //\r
1063 // calculate chi2 between outerITS and innerParams\r
1064 // cov without z-coordinate at the moment\r
1065 //\r
1066 TMatrixD deltaTouterITS(4,1);\r
1067 TMatrixD deltaouterITS(1,4);\r
1068 TMatrixD covarMouterITS(4,4);\r
1069\r
1070 if(isOKtrackInnerC2 && isOKouterITSc) {\r
1071 Int_t kipar = 0;\r
1072 Int_t kjpar = 0;\r
1073 for (Int_t ipar=0; ipar<5; ipar++) {\r
1074 if(ipar!=1) {\r
1075 deltaTouterITS(kipar,0)=outerITSc->GetParameter()[ipar]-trackInnerC2->GetParameter()[ipar];\r
1076 deltaouterITS(0,kipar)=outerITSc->GetParameter()[ipar]-trackInnerC2->GetParameter()[ipar];\r
1077 }\r
1078\r
1079 kjpar=0;\r
1080 for (Int_t jpar=0; jpar<5; jpar++) {\r
1081 Int_t index=outerITSc->GetIndex(ipar,jpar);\r
1082 if(ipar !=1 || jpar!=1) {\r
1083 covarMouterITS(kipar,kjpar)=outerITSc->GetCovariance()[index]+trackInnerC2->GetCovariance()[index];\r
1084 }\r
1085 if(jpar!=1) kjpar++;\r
1086 }\r
1087 if(ipar!=1) kipar++;\r
1088 }\r
1089\r
1090 // chi2 distance ITSout and InnerParams\r
1091 TMatrixD covarMInvouterITS = covarMouterITS.Invert();\r
1092 TMatrixD mat2outerITS = covarMInvouterITS*deltaTouterITS;\r
1093 chi2OuterITS = deltaouterITS*mat2outerITS; \r
1094 //chi2OuterITS.Print();\r
1095 } \r
1096 }\r
1097 }\r
1098 }\r
1099\r
1100 //\r
1101 // MC info\r
1102 //\r
1103 TParticle *particle=NULL, *particleTPC=NULL, *particleITS=NULL;\r
1104 TParticle *particleMother=NULL, *particleMotherTPC=NULL, *particleMotherITS=NULL;\r
1105 Int_t mech=-1, mechTPC=-1, mechITS=-1;\r
1106 Bool_t isPrim=kFALSE, isPrimTPC=kFALSE, isPrimITS=kFALSE;\r
1107 Bool_t isFromStrangess=kFALSE, isFromStrangessTPC=kFALSE, isFromStrangessITS=kFALSE;\r
1108 Bool_t isFromConversion=kFALSE, isFromConversionTPC=kFALSE, isFromConversionITS=kFALSE;\r
1109 Bool_t isFromMaterial=kFALSE, isFromMaterialTPC=kFALSE, isFromMaterialITS=kFALSE;\r
1110\r
1111 AliTrackReference *refTPCIn = NULL;\r
651d71ea 1112 AliTrackReference *refTPCOut = NULL;\r
1059f583 1113 AliTrackReference *refITS = NULL;\r
651d71ea 1114 AliTrackReference *refTRD = NULL;\r
1115 AliTrackReference *refTOF = NULL;\r
1116 AliTrackReference *refEMCAL = NULL;\r
1117 AliTrackReference *refPHOS = NULL;\r
1118 Int_t nrefTPC=0, nrefTRD=0, nrefTOF=0, nrefITS=0, nrefEMCAL=0, nrefPHOS=0;\r
1059f583 1119\r
1120 Bool_t isOKtrackInnerC3 = kFALSE;\r
1121 AliExternalTrackParam *trackInnerC3 = new AliExternalTrackParam(*(track->GetInnerParam()));\r
1122\r
6d15a846 1123 if(mcEvent) \r
1059f583 1124 {\r
1125 if(!stack) return;\r
1126\r
1127 //\r
1128 // global track\r
1129 //\r
1130 Int_t label = TMath::Abs(track->GetLabel()); \r
1d924a2e 1131 if (label >= mcStackSize) continue;\r
1059f583 1132 particle = stack->Particle(label);\r
1133 if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0.)\r
1134 {\r
1135 particleMother = GetMother(particle,stack);\r
1136 mech = particle->GetUniqueID();\r
1137 isPrim = stack->IsPhysicalPrimary(label);\r
1138 isFromStrangess = IsFromStrangeness(label,stack);\r
1139 isFromConversion = IsFromConversion(label,stack);\r
1140 isFromMaterial = IsFromMaterial(label,stack);\r
1141 }\r
1142\r
1143 //\r
1144 // TPC track\r
1145 //\r
1146 Int_t labelTPC = TMath::Abs(track->GetTPCLabel()); \r
1147 particleTPC = stack->Particle(labelTPC);\r
1148 if(particleTPC && particleTPC->GetPDG() && particleTPC->GetPDG()->Charge()!=0.)\r
1149 {\r
1150 particleMotherTPC = GetMother(particleTPC,stack);\r
1151 mechTPC = particleTPC->GetUniqueID();\r
1152 isPrimTPC = stack->IsPhysicalPrimary(labelTPC);\r
1153 isFromStrangessTPC = IsFromStrangeness(labelTPC,stack);\r
1154 isFromConversionTPC = IsFromConversion(labelTPC,stack);\r
1155 isFromMaterialTPC = IsFromMaterial(labelTPC,stack);\r
1156 }\r
1157\r
1158 //\r
1159 // store first track reference\r
1160 // for TPC track\r
1161 //\r
1162 TParticle *part=0;\r
1163 TClonesArray *trefs=0;\r
651d71ea 1164 Int_t status = mcEvent->GetParticleAndTR(TMath::Abs(track->GetTPCLabel()), part, trefs);\r
1059f583 1165\r
1166 if(status>0 && part && trefs && part->GetPDG() && part->GetPDG()->Charge()!=0.) \r
1167 {\r
1168 Int_t nTrackRef = trefs->GetEntries();\r
1169 //printf("nTrackRef %d \n",nTrackRef);\r
1170\r
1171 Int_t countITS = 0;\r
1172 for (Int_t iref = 0; iref < nTrackRef; iref++) \r
1173 {\r
1174 AliTrackReference *ref = (AliTrackReference *)trefs->At(iref);\r
1175\r
1176 // Ref. in the middle ITS \r
651d71ea 1177 if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kITS)\r
1059f583 1178 {\r
651d71ea 1179 nrefITS++;\r
1059f583 1180 if(!refITS && countITS==2) {\r
1181 refITS = ref;\r
1182 //printf("refITS %p \n",refITS);\r
1183 }\r
1184 countITS++;\r
1185 }\r
1186\r
1187 // TPC\r
651d71ea 1188 if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kTPC)\r
1059f583 1189 {\r
651d71ea 1190 nrefTPC++;\r
1191 refTPCOut=ref;\r
1059f583 1192 if(!refTPCIn) {\r
1193 refTPCIn = ref;\r
1194 //printf("refTPCIn %p \n",refTPCIn);\r
1195 //break;\r
1196 }\r
1197 }\r
651d71ea 1198 // TRD\r
1199 if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kTRD)\r
1200 {\r
1201 nrefTRD++;\r
1202 if(!refTRD) {\r
1203 refTRD = ref;\r
1204 }\r
1205 }\r
1206 // TOF\r
1207 if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kTOF)\r
1208 {\r
1209 nrefTOF++;\r
1210 if(!refTOF) {\r
1211 refTOF = ref;\r
1212 }\r
1213 }\r
1214 // EMCAL\r
1215 if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kEMCAL)\r
1216 {\r
1217 nrefEMCAL++;\r
1218 if(!refEMCAL) {\r
1219 refEMCAL = ref;\r
1220 }\r
1221 }\r
1222 // PHOS\r
1223 // if(ref && ref->Label()==label && ref->DetectorId()==AliTrackReference::kPHOS)\r
1224// {\r
1225// nrefPHOS++;\r
1226// if(!refPHOS) {\r
1227// refPHOS = ref;\r
1228// }\r
1229// }\r
1059f583 1230 }\r
1231\r
1232 // transform inner params to TrackRef\r
1233 // reference frame\r
1234 if(refTPCIn && trackInnerC3) \r
1235 {\r
1236 Double_t kRefPhi = TMath::ATan2(refTPCIn->Y(),refTPCIn->X());\r
1237 isOKtrackInnerC3 = trackInnerC3->Rotate(kRefPhi);\r
1238 isOKtrackInnerC3 = AliTracker::PropagateTrackToBxByBz(trackInnerC3,refTPCIn->R(),track->GetMass(),kStep,kFALSE);\r
1239 }\r
1240 }\r
1241\r
1242 //\r
1243 // ITS track\r
1244 //\r
1245 Int_t labelITS = TMath::Abs(track->GetITSLabel()); \r
1246 particleITS = stack->Particle(labelITS);\r
1247 if(particleITS && particleITS->GetPDG() && particleITS->GetPDG()->Charge()!=0.)\r
1248 {\r
1249 particleMotherITS = GetMother(particleITS,stack);\r
1250 mechITS = particleITS->GetUniqueID();\r
1251 isPrimITS = stack->IsPhysicalPrimary(labelITS);\r
1252 isFromStrangessITS = IsFromStrangeness(labelITS,stack);\r
1253 isFromConversionITS = IsFromConversion(labelITS,stack);\r
1254 isFromMaterialITS = IsFromMaterial(labelITS,stack);\r
1255 }\r
1256 }\r
1257\r
1258 //\r
1259 Bool_t dumpToTree=kFALSE;\r
1260 \r
1261 if(isOKtpcInnerC && isOKtrackInnerC) dumpToTree = kTRUE;\r
1262 if(fUseESDfriends && isOKtrackInnerC2 && isOKouterITSc) dumpToTree = kTRUE;\r
6d15a846 1263 if(mcEvent && isOKtrackInnerC3) dumpToTree = kTRUE;\r
04fe1e30 1264 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
2fcfa418 1265 if (fReducePileUp){ \r
1266 //\r
1267 // 18.03 - Reduce pile-up chunks, done outside of the ESDTrackCuts for 2012/2013 data pile-up about 95 % of tracks\r
1268 // Done only in case no MC info \r
1269 //\r
1270 Float_t dcaTPC[2];\r
1271 track->GetImpactParametersTPC(dcaTPC[0],dcaTPC[1]);\r
1272 Bool_t isRoughPrimary = TMath::Abs(dcaTPC[1])<10;\r
1273 Bool_t hasOuter=(track->IsOn(AliVTrack::kITSin))||(track->IsOn(AliVTrack::kTOFout))||(track->IsOn(AliVTrack::kTRDin));\r
1274 Bool_t keepPileUp=gRandom->Rndm()<0.05;\r
1275 if ( (!hasOuter) && (!isRoughPrimary) && (!keepPileUp)){\r
1276 dumpToTree=kFALSE;\r
1277 }\r
1278 }\r
a1419baa 1279 /////////////////\r
1280 //book keeping of created dummy objects (to avoid NULL in trees)\r
1281 Bool_t newvtxESD=kFALSE;\r
1282 Bool_t newtrack=kFALSE;\r
1283 Bool_t newtpcInnerC=kFALSE;\r
1284 Bool_t newtrackInnerC=kFALSE;\r
1285 Bool_t newtrackInnerC2=kFALSE;\r
1286 Bool_t newouterITSc=kFALSE;\r
1287 Bool_t newtrackInnerC3=kFALSE;\r
1288 Bool_t newrefTPCIn=kFALSE;\r
1289 Bool_t newrefITS=kFALSE;\r
1290 Bool_t newparticle=kFALSE;\r
1291 Bool_t newparticleMother=kFALSE;\r
1292 Bool_t newparticleTPC=kFALSE;\r
1293 Bool_t newparticleMotherTPC=kFALSE;\r
1294 Bool_t newparticleITS=kFALSE;\r
1295 Bool_t newparticleMotherITS=kFALSE;\r
1296 \r
1297 //check that the vertex is there and that it is OK, \r
1298 //i.e. no null member arrays, otherwise a problem with merging\r
1299 //later on.\r
1300 //this is a very ugly hack!\r
1301 if (!vtxESD)\r
1302 {\r
1303 AliInfo("fixing the ESD vertex for streaming");\r
1304 vtxESD=new AliESDVertex(); \r
1305 //vtxESD->SetNContributors(1);\r
1306 //UShort_t pindices[1]; pindices[0]=0;\r
1307 //vtxESD->SetIndices(1,pindices);\r
1308 //vtxESD->SetNContributors(0);\r
1309 newvtxESD=kTRUE;\r
1310 }\r
1059f583 1311 //\r
a1419baa 1312 if (!track) {track=new AliESDtrack();newtrack=kTRUE;}\r
1313 if (!tpcInnerC) {tpcInnerC=new AliExternalTrackParam();newtpcInnerC=kTRUE;}\r
1314 if (!trackInnerC) {trackInnerC=new AliExternalTrackParam();newtrackInnerC=kTRUE;}\r
1315 if (!trackInnerC2) {trackInnerC2=new AliExternalTrackParam();newtrackInnerC2=kTRUE;}\r
1316 if (!outerITSc) {outerITSc=new AliExternalTrackParam();newouterITSc=kTRUE;}\r
1317 if (!trackInnerC3) {trackInnerC3=new AliExternalTrackParam();newtrackInnerC3=kTRUE;}\r
6d15a846 1318 if (mcEvent)\r
a1419baa 1319 {\r
1320 if (!refTPCIn) {refTPCIn=new AliTrackReference(); newrefTPCIn=kTRUE;}\r
1321 if (!refITS) {refITS=new AliTrackReference();newrefITS=kTRUE;}\r
1322 if (!particle) {particle=new TParticle(); newparticle=kTRUE;}\r
1323 if (!particleMother) {particleMother=new TParticle();newparticleMother=kTRUE;}\r
1324 if (!particleTPC) {particleTPC=new TParticle();newparticleTPC=kTRUE;}\r
1325 if (!particleMotherTPC) {particleMotherTPC=new TParticle();newparticleMotherTPC=kTRUE;}\r
1326 if (!particleITS) {particleITS=new TParticle();newparticleITS=kTRUE;}\r
1327 if (!particleMotherITS) {particleMotherITS=new TParticle();newparticleMotherITS=kTRUE;}\r
1328 }\r
1329 /////////////////////////\r
1330\r
1331 //Double_t vtxX=vtxESD->GetX();\r
1332 //Double_t vtxY=vtxESD->GetY();\r
1333 //Double_t vtxZ=vtxESD->GetZ();\r
1334\r
1335 AliESDVertex* pvtxESD = (AliESDVertex*)vtxESD->Clone();\r
1336 AliESDtrack* ptrack=(AliESDtrack*)track->Clone();\r
1337 AliExternalTrackParam* ptpcInnerC = (AliExternalTrackParam*)tpcInnerC->Clone();\r
1338 AliExternalTrackParam* ptrackInnerC = (AliExternalTrackParam*)trackInnerC->Clone();\r
1339 AliExternalTrackParam* ptrackInnerC2 = (AliExternalTrackParam*)trackInnerC2->Clone();\r
1340 AliExternalTrackParam* pouterITSc = (AliExternalTrackParam*)outerITSc->Clone();\r
1341 AliExternalTrackParam* ptrackInnerC3 = (AliExternalTrackParam*)trackInnerC3->Clone();\r
2fcfa418 1342 Int_t ntracks = esdEvent->GetNumberOfTracks();\r
1343 \r
30530964 1344 // fill histograms\r
1345 FillHistograms(ptrack, ptpcInnerC, mult, (Double_t)chi2(0,0));\r
1346\r
1347 if(fTreeSRedirector && dumpToTree && fFillTree) \r
1059f583 1348 {\r
a1419baa 1349\r
1059f583 1350 (*fTreeSRedirector)<<"highPt"<<\r
2fcfa418 1351 "fileName.="<<&fileName<< // name of the chunk file (hopefully full)\r
1352 "runNumber="<<runNumber<< // runNumber\r
1353 "evtTimeStamp="<<evtTimeStamp<< // time stamp of event (in seconds)\r
1354 "evtNumberInFile="<<evtNumberInFile<< // event number\r
1355 "triggerClass="<<&triggerClass<< // trigger class as a string\r
1356 "Bz="<<bz<< // solenoid magnetic field in the z direction (in kGaus)\r
1357 "vtxESD.="<<pvtxESD<< // vertexer ESD tracks (can be biased by TPC pileup tracks)\r
1358 //"vtxESDx="<<vtxX<<\r
1359 //"vtxESDy="<<vtxY<<\r
1360 //"vtxESDz="<<vtxZ<<\r
1361 "IRtot="<<ir1<< // interaction record (trigger) counters - coutner 1\r
1362 "IRint2="<<ir2<< // interaction record (trigger) coutners - counter 2\r
1363 "mult="<<mult<< // multiplicity of tracks pointing to the primary vertex\r
1364 "ntracks="<<ntracks<< // number of the esd tracks (to take into account the pileup in the TPC)\r
1365 "esdTrack.="<<ptrack<< // esdTrack as used in the physical analysis\r
1366 "extTPCInnerC.="<<ptpcInnerC<< // ??? \r
1367 "extInnerParamC.="<<ptrackInnerC<< // ???\r
1368 "extInnerParam.="<<ptrackInnerC2<< // ???\r
1369 "extOuterITS.="<<pouterITSc<< // ???\r
1370 "extInnerParamRef.="<<ptrackInnerC3<< // ???\r
1371 "chi2TPCInnerC="<<chi2(0,0)<< // chi2 of tracks ???\r
1372 "chi2InnerC="<<chi2trackC(0,0)<< // chi2s of tracks TPCinner to the combined\r
1373 "chi2OuterITS="<<chi2OuterITS(0,0)<< // chi2s of tracks TPC at inner wall to the ITSout\r
1374 "centralityF="<<centralityF;\r
6d15a846 1375 if (mcEvent)\r
a1419baa 1376 {\r
651d71ea 1377 AliTrackReference refDummy;\r
1378 if (!refITS) refITS = &refDummy;\r
1379 if (!refTRD) refTRD = &refDummy;\r
1380 if (!refTOF) refTOF = &refDummy;\r
1381 if (!refEMCAL) refEMCAL = &refDummy;\r
1382 if (!refPHOS) refPHOS = &refDummy;\r
1383 (*fTreeSRedirector)<<"highPt"<< \r
1384 "nrefITS="<<nrefITS<< // number of track references in the ITS\r
1385 "nrefTPC="<<nrefTPC<< // number of track references in the TPC\r
1386 "nrefTRD="<<nrefTRD<< // number of track references in the TRD\r
1387 "nrefTOF="<<nrefTOF<< // number of track references in the TOF\r
1388 "nrefEMCAL="<<nrefEMCAL<< // number of track references in the TOF\r
1389 "nrefPHOS="<<nrefPHOS<< // number of track references in the TOF\r
1390 "refTPCIn.="<<refTPCIn<<\r
1391 "refTPCOut.="<<refTPCOut<<\r
1392 "refITS.="<<refITS<< \r
1393 "refTRD.="<<refTRD<< \r
1394 "refTOF.="<<refTOF<< \r
1395 "refEMCAL.="<<refEMCAL<< \r
1396 "refPHOS.="<<refPHOS<< \r
1397 "particle.="<<particle<<\r
1398 "particleMother.="<<particleMother<<\r
1399 "mech="<<mech<<\r
1400 "isPrim="<<isPrim<<\r
1401 "isFromStrangess="<<isFromStrangess<<\r
1402 "isFromConversion="<<isFromConversion<<\r
1403 "isFromMaterial="<<isFromMaterial<<\r
1404 "particleTPC.="<<particleTPC<<\r
1405 "particleMotherTPC.="<<particleMotherTPC<<\r
1406 "mechTPC="<<mechTPC<<\r
1407 "isPrimTPC="<<isPrimTPC<<\r
1408 "isFromStrangessTPC="<<isFromStrangessTPC<<\r
1409 "isFromConversionTPC="<<isFromConversionTPC<<\r
1410 "isFromMaterialTPC="<<isFromMaterialTPC<<\r
1411 "particleITS.="<<particleITS<<\r
1412 "particleMotherITS.="<<particleMotherITS<<\r
1413 "mechITS="<<mechITS<<\r
1414 "isPrimITS="<<isPrimITS<<\r
1415 "isFromStrangessITS="<<isFromStrangessITS<<\r
1416 "isFromConversionITS="<<isFromConversionITS<<\r
1417 "isFromMaterialITS="<<isFromMaterialITS;\r
1059f583 1418 }\r
a1419baa 1419 //finish writing the entry\r
6d15a846 1420 AliInfo("writing tree highPt");\r
a1419baa 1421 (*fTreeSRedirector)<<"highPt"<<"\n";\r
1422 }\r
1423\r
1424 delete pvtxESD;\r
1425 delete ptrack;\r
1426 delete ptpcInnerC;\r
1427 delete ptrackInnerC;\r
1428 delete ptrackInnerC2;\r
1429 delete pouterITSc;\r
1430 delete ptrackInnerC3;\r
1431\r
1432 ////////////////////\r
1433 //delete the dummy objects we might have created.\r
1434 if (newvtxESD) {delete vtxESD; vtxESD=NULL;}\r
1435 if (newtrack) {delete track; track=NULL;}\r
1436 if (newtpcInnerC) {delete tpcInnerC; tpcInnerC=NULL;}\r
1437 if (newtrackInnerC) {delete trackInnerC; trackInnerC=NULL;}\r
1438 if (newtrackInnerC2) {delete trackInnerC2; trackInnerC2=NULL;}\r
1439 if (newouterITSc) {delete outerITSc; outerITSc=NULL;}\r
1440 if (newtrackInnerC3) {delete trackInnerC3; trackInnerC3=NULL;}\r
1441 if (newrefTPCIn) {delete refTPCIn; refTPCIn=NULL;}\r
1442 if (newrefITS) {delete refITS; refITS=NULL;}\r
1443 if (newparticle) {delete particle; particle=NULL;}\r
1444 if (newparticleMother) {delete particleMother; particleMother=NULL;}\r
1445 if (newparticleTPC) {delete particleTPC; particleTPC=NULL;}\r
1446 if (newparticleMotherTPC) {delete particleMotherTPC; particleMotherTPC=NULL;}\r
1447 if (newparticleITS) {delete particleITS; particleITS=NULL;}\r
1448 if (newparticleMotherITS) {delete particleMotherITS; particleMotherITS=NULL;}\r
1449 ///////////////\r
1450\r
1451 delete tpcInnerC;\r
1452 delete trackInnerC;\r
1453 delete trackInnerC2;\r
1454 delete outerITSc;\r
1455 delete trackInnerC3;\r
1059f583 1456 }\r
1457 }\r
a1419baa 1458\r
1059f583 1459}\r
1460\r
1461\r
1462//_____________________________________________________________________________\r
1463void AliAnalysisTaskFilteredTree::ProcessMCEff(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const /*esdFriend*/)\r
1464{\r
1465 //\r
1466 // Fill tree for efficiency studies MC only\r
b4c82bc9 1467 AliInfo("we start!");\r
1059f583 1468\r
1469 if(!esdEvent) {\r
1470 AliDebug(AliLog::kError, "esdEvent not available");\r
1471 return;\r
1472 }\r
1473\r
b4c82bc9 1474 if(!mcEvent) {\r
1059f583 1475 AliDebug(AliLog::kError, "mcEvent not available");\r
1476 return;\r
1477 }\r
1478\r
1479 // get selection cuts\r
1480 AliFilteredTreeEventCuts *evtCuts = GetEventCuts(); \r
1481 AliFilteredTreeAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
1482 AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
1483\r
1484 if(!evtCuts || !accCuts || !esdTrackCuts) {\r
1485 AliDebug(AliLog::kError, "cuts not available");\r
1486 return;\r
1487 }\r
1488\r
1489 // trigger selection\r
1490 Bool_t isEventTriggered = kTRUE;\r
1491 AliPhysicsSelection *physicsSelection = NULL;\r
1492 AliTriggerAnalysis* triggerAnalysis = NULL;\r
1493\r
1494 // \r
1495 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
1496 if (!inputHandler)\r
1497 {\r
1498 Printf("ERROR: Could not receive input handler");\r
1499 return;\r
1500 }\r
b4c82bc9 1501\r
1059f583 1502 // get file name\r
1503 TTree *chain = (TChain*)GetInputData(0);\r
1504 if(!chain) { \r
1505 Printf("ERROR: Could not receive input chain");\r
1506 return;\r
1507 }\r
1508 TObjString fileName(chain->GetCurrentFile()->GetName());\r
1509\r
1510 // trigger\r
1511 if(evtCuts->IsTriggerRequired()) \r
1512 {\r
1513 // always MB\r
1514 isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
1515\r
1516 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
1517 if(!physicsSelection) return;\r
1518\r
1519 if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
1520 // set trigger (V0AND)\r
1521 triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
1522 if(!triggerAnalysis) return;\r
1523 isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
1524 }\r
1525 }\r
1526\r
1527 // centrality determination\r
1528 Float_t centralityF = -1;\r
1529 AliCentrality *esdCentrality = esdEvent->GetCentrality();\r
1530 centralityF = esdCentrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
1531\r
1532 // use MC information\r
1533 AliHeader* header = 0;\r
1534 AliGenEventHeader* genHeader = 0;\r
1535 AliStack* stack = 0;\r
1d924a2e 1536 Int_t mcStackSize=0;\r
1059f583 1537 TArrayF vtxMC(3);\r
1538\r
1539 Int_t multMCTrueTracks = 0;\r
b4c82bc9 1540 //\r
1541 if(!mcEvent) {\r
1542 AliDebug(AliLog::kError, "mcEvent not available");\r
1543 return;\r
1544 }\r
1545 // get MC event header\r
1546 header = mcEvent->Header();\r
1547 if (!header) {\r
1548 AliDebug(AliLog::kError, "Header not available");\r
1549 return;\r
1550 }\r
1551 // MC particle stack\r
1552 stack = mcEvent->Stack();\r
1553 if (!stack) {\r
1554 AliDebug(AliLog::kError, "Stack not available");\r
1555 return;\r
1556 }\r
1d924a2e 1557 mcStackSize=stack->GetNtrack();\r
1059f583 1558\r
b4c82bc9 1559 // get MC vertex\r
1560 genHeader = header->GenEventHeader();\r
1561 if (!genHeader) {\r
1562 AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
1563 return;\r
1564 }\r
1565 genHeader->PrimaryVertex(vtxMC);\r
1059f583 1566\r
b4c82bc9 1567 // multipliticy of all MC primary tracks\r
1568 // in Zv, pt and eta ranges)\r
1569 multMCTrueTracks = GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
1059f583 1570\r
1059f583 1571\r
1572 // get reconstructed vertex \r
1573 //const AliESDVertex* vtxESD = 0; \r
1574 AliESDVertex* vtxESD = 0; \r
1575 if(GetAnalysisMode() == kTPCAnalysisMode) {\r
b4c82bc9 1576 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTPC();\r
1059f583 1577 }\r
1578 else if(GetAnalysisMode() == kTPCITSAnalysisMode) {\r
b4c82bc9 1579 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTracks();\r
1059f583 1580 }\r
1581 else {\r
b4c82bc9 1582 return;\r
1059f583 1583 }\r
1584\r
1585 if(!vtxESD) return;\r
1586\r
1587 Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
1588 //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
1589 //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
1590\r
04fe1e30 1591 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
1592\r
1059f583 1593 // check event cuts\r
1594 if(isEventOK && isEventTriggered)\r
1595 {\r
a8e25717 1596 //if(!stack) return;\r
b4c82bc9 1597\r
1598 //\r
1599 // MC info\r
1600 //\r
1601 TParticle *particle=NULL;\r
1602 TParticle *particleMother=NULL;\r
1603 Int_t mech=-1;\r
1604\r
1605 // reco event info\r
1606 Double_t vert[3] = {0}; \r
1607 vert[0] = vtxESD->GetXv();\r
1608 vert[1] = vtxESD->GetYv();\r
1609 vert[2] = vtxESD->GetZv();\r
1610 Int_t mult = vtxESD->GetNContributors();\r
1611 Double_t bz = esdEvent->GetMagneticField();\r
1612 Double_t runNumber = esdEvent->GetRunNumber();\r
1613 Double_t evtTimeStamp = esdEvent->GetTimeStamp();\r
1614 Int_t evtNumberInFile = esdEvent->GetEventNumberInFile();\r
1615\r
1616 // loop over MC stack\r
1d924a2e 1617 for (Int_t iMc = 0; iMc < mcStackSize; ++iMc) \r
1059f583 1618 {\r
b4c82bc9 1619 particle = stack->Particle(iMc);\r
1620 if (!particle)\r
1621 continue;\r
1622\r
1623 // only charged particles\r
1624 if(!particle->GetPDG()) continue;\r
1625 Double_t charge = particle->GetPDG()->Charge()/3.;\r
1626 if (TMath::Abs(charge) < 0.001)\r
1627 continue;\r
1628\r
1629 // only primary particles\r
1630 Bool_t prim = stack->IsPhysicalPrimary(iMc);\r
1631 if(!prim) continue;\r
1632\r
1633 // downscale low-pT particles\r
1634 Double_t scalempt= TMath::Min(particle->Pt(),10.);\r
1635 Double_t downscaleF = gRandom->Rndm();\r
1636 downscaleF *= fLowPtTrackDownscaligF;\r
1637 if(TMath::Exp(2*scalempt)<downscaleF) continue;\r
1059f583 1638\r
b4c82bc9 1639 // is particle in acceptance\r
1640 if(!accCuts->AcceptTrack(particle)) continue;\r
1059f583 1641\r
b4c82bc9 1642 // check if particle reconstructed\r
1643 Bool_t isRec = kFALSE;\r
1644 Int_t trackIndex = -1;\r
1645 for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
1059f583 1646 {\r
b4c82bc9 1647\r
1648 AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
1649 if(!track) continue;\r
1650 if(track->Charge()==0) continue;\r
1651 if(esdTrackCuts->AcceptTrack(track) && accCuts->AcceptTrack(track)) \r
1652 {\r
1653 Int_t label = TMath::Abs(track->GetLabel());\r
1d924a2e 1654 if (label >= mcStackSize) continue;\r
b4c82bc9 1655 if(label == iMc) {\r
1656 isRec = kTRUE;\r
1657 trackIndex = iTrack;\r
1658 break;\r
1659 }\r
1660 } \r
1059f583 1661 }\r
b4c82bc9 1662\r
1663 // Store information in the output tree\r
1664 AliESDtrack *recTrack = NULL; \r
1665 if(trackIndex>-1) { \r
1666 recTrack = esdEvent->GetTrack(trackIndex); \r
1667 } else {\r
1668 recTrack = new AliESDtrack(); \r
1669 } \r
1670\r
1671 particleMother = GetMother(particle,stack);\r
1672 mech = particle->GetUniqueID();\r
1673\r
1674 //MC particle track length\r
1675 Double_t tpcTrackLength = 0.;\r
1676 AliMCParticle *mcParticle = (AliMCParticle*) mcEvent->GetTrack(iMc);\r
1677 if(mcParticle) {\r
1678 Int_t counter;\r
1679 tpcTrackLength = mcParticle->GetTPCTrackLength(bz,0.05,counter,3.0);\r
1680 } \r
1681\r
1682\r
1683 //\r
30530964 1684 if(fTreeSRedirector && fFillTree) {\r
b4c82bc9 1685 (*fTreeSRedirector)<<"MCEffTree"<<\r
1686 "fileName.="<<&fileName<<\r
1687 "triggerClass.="<<&triggerClass<<\r
1688 "runNumber="<<runNumber<<\r
1689 "evtTimeStamp="<<evtTimeStamp<<\r
1690 "evtNumberInFile="<<evtNumberInFile<<\r
1691 "Bz="<<bz<<\r
1692 "vtxESD.="<<vtxESD<<\r
1693 "mult="<<mult<<\r
1694 "esdTrack.="<<recTrack<<\r
1695 "isRec="<<isRec<<\r
1696 "tpcTrackLength="<<tpcTrackLength<<\r
1697 "particle.="<<particle<<\r
1698 "particleMother.="<<particleMother<<\r
1699 "mech="<<mech<<\r
1700 "\n";\r
1701 }\r
1702\r
1703 if(trackIndex <0 && recTrack) delete recTrack; recTrack=0;\r
1059f583 1704 }\r
1705 }\r
b4c82bc9 1706\r
1059f583 1707}\r
1708\r
1709//_____________________________________________________________________________\r
1710Bool_t AliAnalysisTaskFilteredTree::IsHighDeDxParticle(AliESDtrack * track) {\r
1711 //\r
1712 // check if particle is Z > 1 \r
1713 //\r
1714 if (track->GetTPCNcls() < 60) return kFALSE;\r
1715 Double_t mom = track->GetInnerParam()->GetP();\r
1716 if (mom < 0.2) return kFALSE; // protection against unexpected behavior of Aleph parameterization\r
1717 Float_t dca[2], bCov[3];\r
1718 track->GetImpactParameters(dca,bCov);\r
1719 //\r
1720\r
1721 Double_t triggerDeDx = 4*AliExternalTrackParam::BetheBlochAleph((mom*2)/(0.938*3),1.0288,31.9806,5.04114e-11,2.13096,2.38541);\r
1722\r
1723 if (track->GetTPCsignal() > triggerDeDx && track->GetTPCsignal()<1000 && TMath::Abs(dca[0])<3.) return kTRUE;\r
1724\r
1725 return kFALSE;\r
1726}\r
1727\r
1728//_____________________________________________________________________________\r
1729void AliAnalysisTaskFilteredTree::ProcessV0(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const /*esdFriend*/)\r
1730{\r
1731 //\r
2fcfa418 1732 // Select real events with V0 (K0s and Lambda and Gamma) high-pT candidates\r
1059f583 1733 //\r
1734 if(!esdEvent) {\r
1735 AliDebug(AliLog::kError, "esdEvent not available");\r
1736 return;\r
1737 }\r
1738\r
1739 // get selection cuts\r
1740 AliFilteredTreeEventCuts *evtCuts = GetEventCuts(); \r
1741 AliFilteredTreeAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
1742 AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
1743\r
1744 if(!evtCuts || !accCuts || !esdTrackCuts) {\r
1745 AliDebug(AliLog::kError, "cuts not available");\r
1746 return;\r
1747 }\r
1748\r
1749 // trigger selection\r
1750 Bool_t isEventTriggered = kTRUE;\r
1751 AliPhysicsSelection *physicsSelection = NULL;\r
1752 AliTriggerAnalysis* triggerAnalysis = NULL;\r
1753\r
1754 // \r
1755 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
1756 if (!inputHandler)\r
1757 {\r
1758 Printf("ERROR: Could not receive input handler");\r
1759 return;\r
1760 }\r
1761 \r
1762 // get file name\r
1763 TTree *chain = (TChain*)GetInputData(0);\r
1764 if(!chain) { \r
1765 Printf("ERROR: Could not receive input chain");\r
1766 return;\r
1767 }\r
1768 TObjString fileName(chain->GetCurrentFile()->GetName());\r
1769\r
1770 // trigger\r
1771 if(evtCuts->IsTriggerRequired()) \r
1772 {\r
1773 // always MB\r
1774 isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
1775\r
1776 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
1777 if(!physicsSelection) return;\r
1778 //SetPhysicsTriggerSelection(physicsSelection);\r
1779\r
1780 if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
1781 // set trigger (V0AND)\r
1782 triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
1783 if(!triggerAnalysis) return;\r
1784 isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
1785 }\r
1786 }\r
1787\r
1788 // centrality determination\r
1789 Float_t centralityF = -1;\r
1790 AliCentrality *esdCentrality = esdEvent->GetCentrality();\r
1791 centralityF = esdCentrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
1792\r
1793\r
1794 // get reconstructed vertex \r
1795 //const AliESDVertex* vtxESD = 0; \r
1796 AliESDVertex* vtxESD = 0; \r
1797 if(GetAnalysisMode() == kTPCAnalysisMode) {\r
1798 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTPC();\r
1799 }\r
1800 else if(GetAnalysisMode() == kTPCITSAnalysisMode) {\r
1801 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTracks();\r
1802 }\r
1803 else {\r
1804 return;\r
1805 }\r
1806\r
1807 if(!vtxESD) return;\r
1808\r
1809 Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
1810 //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
1811 //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
1812\r
1813 // check event cuts\r
1814 if(isEventOK && isEventTriggered) {\r
1815 //\r
1816 // Dump the pt downscaled V0 into the tree\r
1817 // \r
1818 Int_t ntracks = esdEvent->GetNumberOfTracks();\r
1819 Int_t nV0s = esdEvent->GetNumberOfV0s();\r
1820 Int_t run = esdEvent->GetRunNumber();\r
1821 Int_t time= esdEvent->GetTimeStamp();\r
1822 Int_t evNr=esdEvent->GetEventNumberInFile();\r
1823 Double_t bz = esdEvent->GetMagneticField();\r
1824\r
1825\r
1826 for (Int_t iv0=0; iv0<nV0s; iv0++){\r
1827 AliESDv0 * v0 = esdEvent->GetV0(iv0);\r
1828 if (!v0) continue;\r
1829 AliESDtrack * track0 = esdEvent->GetTrack(v0->GetIndex(0));\r
1830 AliESDtrack * track1 = esdEvent->GetTrack(v0->GetIndex(1));\r
1831 if (!track0) continue;\r
1832 if (!track1) continue;\r
1833 if (track0->GetSign()<0) {\r
1834 track1 = esdEvent->GetTrack(v0->GetIndex(0));\r
1835 track0 = esdEvent->GetTrack(v0->GetIndex(1));\r
1836 }\r
1837 //\r
1838 Bool_t isDownscaled = IsV0Downscaled(v0);\r
1839 if (isDownscaled) continue;\r
1840 AliKFParticle kfparticle; //\r
1841 Int_t type=GetKFParticle(v0,esdEvent,kfparticle);\r
1842 if (type==0) continue; \r
04fe1e30 1843 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
1059f583 1844\r
30530964 1845 if(!fFillTree) return;\r
1059f583 1846 if(!fTreeSRedirector) return;\r
1847 (*fTreeSRedirector)<<"V0s"<<\r
1848 "isDownscaled="<<isDownscaled<<\r
04fe1e30 1849 "triggerClass="<<&triggerClass<< // trigger\r
1059f583 1850 "Bz="<<bz<<\r
1851 "fileName.="<<&fileName<<\r
1852 "runNumber="<<run<<\r
1853 "evtTimeStamp="<<time<<\r
1854 "evtNumberInFile="<<evNr<<\r
1855 "type="<<type<<\r
1856 "ntracks="<<ntracks<<\r
1857 "v0.="<<v0<<\r
1858 "kf.="<<&kfparticle<<\r
1859 "track0.="<<track0<<\r
1860 "track1.="<<track1<<\r
1861 "centralityF="<<centralityF<<\r
1862 "\n";\r
1863 }\r
1864 }\r
1865}\r
1866\r
1867//_____________________________________________________________________________\r
1868void AliAnalysisTaskFilteredTree::ProcessdEdx(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const /*esdFriend*/)\r
1869{\r
1870 //\r
1871 // Select real events with large TPC dEdx signal\r
1872 //\r
1873 if(!esdEvent) {\r
1874 AliDebug(AliLog::kError, "esdEvent not available");\r
1875 return;\r
1876 }\r
1877\r
1878 // get selection cuts\r
1879 AliFilteredTreeEventCuts *evtCuts = GetEventCuts(); \r
1880 AliFilteredTreeAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
1881 AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
1882\r
1883 if(!evtCuts || !accCuts || !esdTrackCuts) {\r
1884 AliDebug(AliLog::kError, "cuts not available");\r
1885 return;\r
1886 }\r
1887\r
1888 // get file name\r
1889 TTree *chain = (TChain*)GetInputData(0);\r
1890 if(!chain) { \r
1891 Printf("ERROR: Could not receive input chain");\r
1892 return;\r
1893 }\r
1894 TObjString fileName(chain->GetCurrentFile()->GetName());\r
1895\r
1896 // trigger\r
1897 Bool_t isEventTriggered = kTRUE;\r
1898 AliPhysicsSelection *physicsSelection = NULL;\r
1899 AliTriggerAnalysis* triggerAnalysis = NULL;\r
1900\r
1901 // \r
1902 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
1903 if (!inputHandler)\r
1904 {\r
1905 Printf("ERROR: Could not receive input handler");\r
1906 return;\r
1907 }\r
1908\r
1909 if(evtCuts->IsTriggerRequired()) \r
1910 {\r
1911 // always MB\r
1912 isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
1913\r
1914 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
1915 if(!physicsSelection) return;\r
1916\r
1917 if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
1918 // set trigger (V0AND)\r
1919 triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
1920 if(!triggerAnalysis) return;\r
1921 isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
1922 }\r
1923 }\r
1924\r
1925 // get reconstructed vertex \r
1926 AliESDVertex* vtxESD = 0; \r
1927 if(GetAnalysisMode() == kTPCAnalysisMode) {\r
1928 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTPC();\r
1929 }\r
1930 else if(GetAnalysisMode() == kTPCITSAnalysisMode) {\r
1931 vtxESD = (AliESDVertex*)esdEvent->GetPrimaryVertexTracks();\r
1932 }\r
1933 else {\r
1934 return;\r
1935 }\r
1936 if(!vtxESD) return;\r
1937\r
1938 Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
1939 //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
1940 //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
1941\r
1942\r
1943 // check event cuts\r
1944 if(isEventOK && isEventTriggered)\r
1945 {\r
1946 Double_t vert[3] = {0}; \r
1947 vert[0] = vtxESD->GetXv();\r
1948 vert[1] = vtxESD->GetYv();\r
1949 vert[2] = vtxESD->GetZv();\r
1950 Int_t mult = vtxESD->GetNContributors();\r
1951 Double_t bz = esdEvent->GetMagneticField();\r
1952 Double_t runNumber = esdEvent->GetRunNumber();\r
1953 Double_t evtTimeStamp = esdEvent->GetTimeStamp();\r
1954 Int_t evtNumberInFile = esdEvent->GetEventNumberInFile();\r
1955\r
1956 // large dEdx\r
1957 for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
1958 {\r
1959 AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
1960 if(!track) continue;\r
1961 if(track->Charge()==0) continue;\r
1962 if(!esdTrackCuts->AcceptTrack(track)) continue;\r
1963 if(!accCuts->AcceptTrack(track)) continue;\r
1964\r
1965 if(!IsHighDeDxParticle(track)) continue;\r
04fe1e30 1966 TObjString triggerClass = esdEvent->GetFiredTriggerClasses().Data();\r
1967\r
30530964 1968 if(!fFillTree) return;\r
1059f583 1969 if(!fTreeSRedirector) return;\r
1970 (*fTreeSRedirector)<<"dEdx"<<\r
1971 "fileName.="<<&fileName<<\r
1972 "runNumber="<<runNumber<<\r
1973 "evtTimeStamp="<<evtTimeStamp<<\r
1974 "evtNumberInFile="<<evtNumberInFile<<\r
04fe1e30 1975 "triggerClass="<<&triggerClass<< // trigger\r
1059f583 1976 "Bz="<<bz<<\r
1977 "vtxESD.="<<vtxESD<<\r
1978 "mult="<<mult<<\r
1979 "esdTrack.="<<track<<\r
1980 "\n";\r
1981 }\r
1982 }\r
1983}\r
1984\r
1985//_____________________________________________________________________________\r
1986Int_t AliAnalysisTaskFilteredTree::GetKFParticle(AliESDv0 *const v0, AliESDEvent * const event, AliKFParticle & kfparticle)\r
1987{\r
1988 //\r
1989 // Create KF particle in case the V0 fullfill selection criteria\r
1990 //\r
1991 // Selection criteria\r
1992 // 0. algorithm cut\r
1993 // 1. track cut\r
1994 // 3. chi2 cut\r
1995 // 4. rough mass cut\r
1996 // 5. Normalized pointing angle cut\r
1997 //\r
1998 const Double_t cutMass=0.2;\r
1999 const Double_t kSigmaDCACut=3;\r
2000 //\r
2001 // 0.) algo cut - accept only on the fly\r
2002 //\r
2003 if (v0->GetOnFlyStatus() ==kFALSE) return 0; \r
2004 //\r
2005 // 1.) track cut\r
2006 // \r
2007 AliESDtrack * track0 = event->GetTrack(v0->GetIndex(0));\r
2008 AliESDtrack * track1 = event->GetTrack(v0->GetIndex(1));\r
2009 /*\r
2010 TCut cutD="abs(track0.fD/sqrt(track0.fCdd))>2&&abs(track1.fD/sqrt(track1.fCdd))>2";\r
2011 TCut cutTheta="abs(track0.fP[3])<1&&abs(track1.fP[3])<1";\r
2012 TCut cutNcl="track0.GetTPCClusterInfo(2,1)>100&&track1.GetTPCClusterInfo(2,1)>100";\r
2013 */ \r
2014 if (TMath::Abs(track0->GetTgl())>1) return 0;\r
2015 if (TMath::Abs(track1->GetTgl())>1) return 0;\r
2016 if ((track0->GetTPCClusterInfo(2,1))<100) return 0;\r
2017 if ((track1->GetTPCClusterInfo(2,1))<100) return 0;\r
2018 //if ((track0->GetITSclusters(0))<2) return 0;\r
2019 //if ((track1->GetITSclusters(0))<2) return 0; \r
2020 Float_t pos0[2]={0}, cov0[3]={0};\r
2021 Float_t pos1[2]={0}, cov1[3]={0};\r
2022 track0->GetImpactParameters(pos0,cov0);\r
2023 track0->GetImpactParameters(pos1,cov1);\r
2024 //\r
2025 if (TMath::Abs(pos0[0])<kSigmaDCACut*TMath::Sqrt(cov0[0])) return 0;\r
2026 if (TMath::Abs(pos1[0])<kSigmaDCACut*TMath::Sqrt(cov1[0])) return 0;\r
2027 // \r
2028 //\r
2029 // 3.) Chi2 cut\r
2030 //\r
2031 Double_t chi2KF = v0->GetKFInfo(2,2,2);\r
2032 if (chi2KF>25) return 0;\r
2033 //\r
2034 // 4.) Rough mass cut - 0.200 GeV\r
2035 //\r
2036 static Double_t masses[2]={-1};\r
2037 if (masses[0]<0){\r
2038 masses[0] = TDatabasePDG::Instance()->GetParticle("K_S0")->Mass();\r
2039 masses[1] = TDatabasePDG::Instance()->GetParticle("Lambda0")->Mass();\r
2040 }\r
2041 Double_t mass00= v0->GetEffMass(0,0);\r
2042 Double_t mass22= v0->GetEffMass(2,2);\r
2043 Double_t mass42= v0->GetEffMass(4,2);\r
2044 Double_t mass24= v0->GetEffMass(2,4);\r
2045 Bool_t massOK=kFALSE;\r
2046 Int_t type=0;\r
2047 Int_t ptype=0;\r
2048 Double_t dmass=1;\r
2049 Int_t p1=0, p2=0;\r
2050 if (TMath::Abs(mass00-0)<cutMass) {\r
2051 massOK=kTRUE; type+=1; \r
2052 if (TMath::Abs(mass00-0)<dmass) {\r
2053 ptype=1;\r
2054 dmass=TMath::Abs(mass00-0); \r
2055 p1=0; p2=0;\r
2056 } \r
2057 }\r
2058 if (TMath::Abs(mass24-masses[1])<cutMass) {\r
2059 massOK=kTRUE; type+=2; \r
2060 if (TMath::Abs(mass24-masses[1])<dmass){\r
2061 dmass = TMath::Abs(mass24-masses[1]);\r
2062 ptype=2;\r
2063 p1=2; p2=4;\r
2064 }\r
2065 }\r
2066 if (TMath::Abs(mass42-masses[1])<cutMass) {\r
2067 massOK=kTRUE; type+=4;\r
2068 if (TMath::Abs(mass42-masses[1])<dmass){\r
2069 dmass = TMath::Abs(mass42-masses[1]);\r
2070 ptype=4;\r
2071 p1=4; p2=2;\r
2072 }\r
2073 }\r
2074 if (TMath::Abs(mass22-masses[0])<cutMass) {\r
2075 massOK=kTRUE; type+=8;\r
2076 if (TMath::Abs(mass22-masses[0])<dmass){\r
2077 dmass = TMath::Abs(mass22-masses[0]);\r
2078 ptype=8;\r
2079 p1=2; p2=2;\r
2080 }\r
2081 }\r
2082 if (type==0) return 0;\r
2083 //\r
2084 const Int_t spdg[5]={kPositron,kMuonPlus,kPiPlus, kKPlus, kProton};\r
2085 const AliExternalTrackParam *paramP = v0->GetParamP();\r
2086 const AliExternalTrackParam *paramN = v0->GetParamN();\r
2087 if (paramP->GetSign()<0){\r
2088 paramP=v0->GetParamP();\r
2089 paramN=v0->GetParamN();\r
2090 }\r
2091 //Double_t *pparam1 = (Double_t*)paramP->GetParameter();\r
2092 //Double_t *pparam2 = (Double_t*)paramN->GetParameter();\r
2093 //\r
2094 AliKFParticle kfp1( *paramP, spdg[p1] );\r
2095 AliKFParticle kfp2( *paramN, -1 *spdg[p2] );\r
2096 AliKFParticle V0KF;\r
2097 (V0KF)+=kfp1;\r
2098 (V0KF)+=kfp2;\r
2099 kfparticle=V0KF;\r
2100 //\r
2101 // Pointing angle\r
2102 //\r
2103 Double_t errPhi = V0KF.GetErrPhi();\r
2104 Double_t pointAngle= TMath::ACos(v0->GetV0CosineOfPointingAngle());\r
2105 if (pointAngle/errPhi>10) return 0; \r
2106 //\r
2107 return ptype; \r
2108}\r
2109\r
2110//_____________________________________________________________________________\r
2111Bool_t AliAnalysisTaskFilteredTree::IsV0Downscaled(AliESDv0 *const v0)\r
2112{\r
2113 //\r
2114 // Downscale randomly low pt V0\r
2115 //\r
2116 //return kFALSE;\r
2117 Double_t maxPt= TMath::Max(v0->GetParamP()->Pt(), v0->GetParamN()->Pt());\r
2118 Double_t scalempt= TMath::Min(maxPt,10.);\r
2119 Double_t downscaleF = gRandom->Rndm();\r
2120 downscaleF *= fLowPtV0DownscaligF;\r
2fcfa418 2121 //\r
2122 // Special treatment of the gamma conversion pt spectra is softer - \r
2123 Double_t mass00= v0->GetEffMass(0,0);\r
2124 const Double_t cutMass=0.2;\r
2125 if (TMath::Abs(mass00-0)<cutMass){\r
2126 downscaleF/=10.; // 10 times smaller downscaling for the gamma concersion candidate\r
2127 }\r
1059f583 2128 //printf("V0 TMath::Exp(2*scalempt) %e, downscaleF %e \n",TMath::Exp(2*scalempt), downscaleF);\r
2129 if (TMath::Exp(2*scalempt)<downscaleF) return kTRUE;\r
2130 return kFALSE;\r
2131\r
2132 /*\r
2133 TH1F his1("his1","his1",100,0,10);\r
2134 TH1F his2("his2","his2",100,0,10);\r
2135 {for (Int_t i=0; i<10000; i++){\r
2136 Double_t rnd=gRandom->Exp(1);\r
2137 Bool_t isDownscaled =TMath::Exp(rnd)<100*gRandom->Rndm();\r
2138 his1->Fill(rnd); \r
2139 if (!isDownscaled) his2->Fill(rnd); \r
2140 }}\r
2141\r
2142 */\r
2143\r
2144}\r
2145\r
2146\r
2147\r
2148//_____________________________________________________________________________\r
2149Bool_t AliAnalysisTaskFilteredTree::ConstrainTPCInner(AliExternalTrackParam *const tpcInnerC, const AliESDVertex* vtx, Double_t b[3])\r
2150{\r
2151 // Constrain TPC inner params constrained\r
2152 //\r
2153 if(!tpcInnerC) return kFALSE; \r
2154 if(!vtx) return kFALSE;\r
2155\r
2156 Double_t dz[2],cov[3];\r
2157 //AliESDVertex *vtx= (AliESDVertex *)esdEvent->GetPrimaryVertex();\r
2158 //if(!tpcInnerC->PropagateToDCA(vtx, esdEvent->GetMagneticField(), 3, dz, cov)) return kFALSE; \r
2159 //if(!tpcInnerC->PropagateToDCA(vtx, Bz, 3, dz, cov)) return kFALSE; \r
2160 if(!tpcInnerC->PropagateToDCABxByBz(vtx, b, 3, dz, cov)) return kFALSE; \r
2161\r
2162\r
2163 Double_t covar[6]; vtx->GetCovMatrix(covar);\r
2164 Double_t p[2]={tpcInnerC->GetParameter()[0]-dz[0],tpcInnerC->GetParameter()[1]-dz[1]};\r
2165 Double_t c[3]={covar[2],0.,covar[5]};\r
2166 Double_t chi2C=tpcInnerC->GetPredictedChi2(p,c);\r
2167 if (chi2C>kVeryBig) return kFALSE; \r
2168\r
2169 if(!tpcInnerC->Update(p,c)) return kFALSE;\r
2170\r
2171 return kTRUE;\r
2172}\r
2173\r
2174//_____________________________________________________________________________\r
2175Bool_t AliAnalysisTaskFilteredTree::ConstrainTrackInner(AliExternalTrackParam *const trackInnerC, const AliESDVertex* vtx, Double_t mass, Double_t b[3])\r
2176{\r
2177 // Constrain TPC inner params constrained\r
2178 //\r
2179 if(!trackInnerC) return kFALSE; \r
2180 if(!vtx) return kFALSE;\r
2181\r
2182 const Double_t kRadius = 2.8; \r
2183 const Double_t kMaxStep = 1.0; \r
2184\r
2185 Double_t dz[2],cov[3];\r
2186\r
2187 //AliESDVertex *vtx= (AliESDVertex *)esdEvent->GetPrimaryVertex();\r
2188 //if(!trackInnerC->PropagateToDCA(vtx, esdEvent->GetMagneticField(), 3, dz, cov)) return kFALSE; \r
2189 //if(!trackInnerC->PropagateToDCA(vtx, Bz, 3, dz, cov)) return kFALSE; \r
2190\r
2191 if(!AliTracker::PropagateTrackToBxByBz(trackInnerC,kRadius,mass,kMaxStep,kFALSE)) return kFALSE;\r
2192 if(!trackInnerC->PropagateToDCABxByBz(vtx, b, 3, dz, cov)) return kFALSE; \r
2193\r
2194 //\r
2195 Double_t covar[6]; vtx->GetCovMatrix(covar);\r
2196 Double_t p[2]={trackInnerC->GetParameter()[0]-dz[0],trackInnerC->GetParameter()[1]-dz[1]};\r
2197 Double_t c[3]={covar[2],0.,covar[5]};\r
2198 Double_t chi2C=trackInnerC->GetPredictedChi2(p,c);\r
2199 if (chi2C>kVeryBig) return kFALSE; \r
2200\r
2201 if(!trackInnerC->Update(p,c)) return kFALSE;\r
2202\r
2203 return kTRUE;\r
2204}\r
2205\r
2206\r
2207//_____________________________________________________________________________\r
2208TParticle *AliAnalysisTaskFilteredTree::GetMother(TParticle *const particle, AliStack *const stack) \r
2209{\r
2210 if(!particle) return NULL;\r
2211 if(!stack) return NULL;\r
2212\r
2213 Int_t motherLabel = TMath::Abs(particle->GetMother(0)); \r
2214 TParticle* mother = NULL; \r
2215 mother = stack->Particle(motherLabel); \r
2216\r
2217return mother;\r
2218}\r
2219\r
2220//_____________________________________________________________________________\r
2221Bool_t AliAnalysisTaskFilteredTree::IsFromConversion(const Int_t label, AliStack *const stack) \r
2222{\r
2223 Bool_t isFromConversion = kFALSE;\r
2224\r
2225 if(stack) {\r
2226 TParticle* particle = stack->Particle(label);\r
2227\r
2228 if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
2229 {\r
2230 Int_t mech = particle->GetUniqueID(); // production mechanism \r
2231 Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
2232\r
2233 Int_t motherLabel = TMath::Abs(particle->GetMother(0)); \r
2234 TParticle* mother = stack->Particle(motherLabel); \r
2235 if(mother) {\r
2236 Int_t motherPdg = mother->GetPdgCode();\r
2237\r
2238 if(!isPrim && mech==5 && motherPdg==kGamma) { \r
2239 isFromConversion=kTRUE; \r
2240 }\r
2241 }\r
2242 } \r
2243 } \r
2244\r
2245 return isFromConversion;\r
2246}\r
2247\r
2248//_____________________________________________________________________________\r
2249Bool_t AliAnalysisTaskFilteredTree::IsFromMaterial(const Int_t label, AliStack *const stack) \r
2250{\r
2251 Bool_t isFromMaterial = kFALSE;\r
2252\r
2253 if(stack) {\r
2254 TParticle* particle = stack->Particle(label);\r
2255\r
2256 if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
2257 {\r
2258 Int_t mech = particle->GetUniqueID(); // production mechanism \r
2259 Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
2260\r
2261 Int_t motherLabel = TMath::Abs(particle->GetMother(0)); \r
2262 TParticle* mother = stack->Particle(motherLabel); \r
2263 if(mother) {\r
2264 if(!isPrim && mech==13) { \r
2265 isFromMaterial=kTRUE; \r
2266 }\r
2267 }\r
2268 } \r
2269 } \r
2270\r
2271 return isFromMaterial;\r
2272}\r
2273\r
2274//_____________________________________________________________________________\r
2275Bool_t AliAnalysisTaskFilteredTree::IsFromStrangeness(const Int_t label, AliStack *const stack) \r
2276{\r
2277 Bool_t isFromStrangeness = kFALSE;\r
2278\r
2279 if(stack) {\r
2280 TParticle* particle = stack->Particle(label);\r
2281\r
2282 if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
2283 {\r
2284 Int_t mech = particle->GetUniqueID(); // production mechanism \r
2285 Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
2286\r
2287 Int_t motherLabel = TMath::Abs(particle->GetMother(0)); \r
2288 TParticle* mother = stack->Particle(motherLabel); \r
2289 if(mother) {\r
2290 Int_t motherPdg = mother->GetPdgCode();\r
2291\r
2292 // K+-, lambda, antilambda, K0s decays\r
2293 if(!isPrim && mech==4 && \r
2294 (TMath::Abs(motherPdg)==kKPlus || TMath::Abs(motherPdg)==kLambda0 || motherPdg==kK0Short))\r
2295 {\r
2296 isFromStrangeness = kTRUE;\r
2297 } \r
2298 }\r
2299 } \r
2300 } \r
2301\r
2302 return isFromStrangeness;\r
2303}\r
2304\r
2305\r
2306//_____________________________________________________________________________\r
2307void AliAnalysisTaskFilteredTree::FinishTaskOutput() \r
2308{\r
2309 //\r
2310 // Called one at the end \r
2311 // locally on working node\r
2312 //\r
2313\r
a1419baa 2314 //// must be deleted to store trees\r
2315 //if(fTreeSRedirector) delete fTreeSRedirector; fTreeSRedirector=0;\r
2316\r
2317 //// open temporary file and copy trees to the ouptut container\r
2318\r
2319 //TChain* chain = 0;\r
2320 ////\r
2321 //chain = new TChain("highPt");\r
2322 //if(chain) { \r
2323 // chain->Add("jotwinow_Temp_Trees.root");\r
2324 // fHighPtTree = chain->CopyTree("1");\r
2325 // delete chain; chain=0; \r
2326 //}\r
2327 //if(fHighPtTree) fHighPtTree->Print();\r
2328\r
2329 ////\r
2330 //chain = new TChain("V0s");\r
2331 //if(chain) { \r
2332 // chain->Add("jotwinow_Temp_Trees.root");\r
2333 // fV0Tree = chain->CopyTree("1");\r
2334 // delete chain; chain=0; \r
2335 //}\r
2336 //if(fV0Tree) fV0Tree->Print();\r
2337\r
2338 ////\r
2339 //chain = new TChain("dEdx");\r
2340 //if(chain) { \r
2341 // chain->Add("jotwinow_Temp_Trees.root");\r
2342 // fdEdxTree = chain->CopyTree("1");\r
2343 // delete chain; chain=0; \r
2344 //}\r
2345 //if(fdEdxTree) fdEdxTree->Print();\r
2346\r
2347 ////\r
2348 //chain = new TChain("Laser");\r
2349 //if(chain) { \r
2350 // chain->Add("jotwinow_Temp_Trees.root");\r
2351 // fLaserTree = chain->CopyTree("1");\r
2352 // delete chain; chain=0; \r
2353 //}\r
2354 //if(fLaserTree) fLaserTree->Print();\r
2355\r
2356 ////\r
2357 //chain = new TChain("MCEffTree");\r
2358 //if(chain) { \r
2359 // chain->Add("jotwinow_Temp_Trees.root");\r
2360 // fMCEffTree = chain->CopyTree("1");\r
2361 // delete chain; chain=0; \r
2362 //}\r
2363 //if(fMCEffTree) fMCEffTree->Print();\r
2364\r
2365 ////\r
2366 //chain = new TChain("CosmicPairs");\r
2367 //if(chain) { \r
2368 // chain->Add("jotwinow_Temp_Trees.root");\r
2369 // fCosmicPairsTree = chain->CopyTree("1");\r
2370 // delete chain; chain=0; \r
2371 //}\r
2372 //if(fCosmicPairsTree) fCosmicPairsTree->Print(); \r
2373\r
6d15a846 2374 Bool_t deleteTrees=kTRUE;\r
2375 if ((AliAnalysisManager::GetAnalysisManager()))\r
2376 {\r
2377 if (AliAnalysisManager::GetAnalysisManager()->GetAnalysisType() == \r
2378 AliAnalysisManager::kProofAnalysis)\r
2379 deleteTrees=kFALSE;\r
2380 }\r
2381 if (deleteTrees) delete fTreeSRedirector;\r
2382 fTreeSRedirector=NULL;\r
a1419baa 2383\r
2384 //OpenFile(1);\r
1059f583 2385\r
2386 // Post output data.\r
a1419baa 2387 //PostData(1, fHighPtTree);\r
2388 //PostData(2, fV0Tree);\r
2389 //PostData(3, fdEdxTree);\r
2390 //PostData(4, fLaserTree);\r
2391 //PostData(5, fMCEffTree);\r
2392 //PostData(6, fCosmicPairsTree);\r
1059f583 2393}\r
2394\r
2395//_____________________________________________________________________________\r
2396void AliAnalysisTaskFilteredTree::Terminate(Option_t *) \r
2397{\r
2398 // Called one at the end \r
2399 /*\r
2400 fOutputSummary = dynamic_cast<TTree*> (GetOutputData(1));\r
2401 if(fOutputSummary) delete fOutputSummary; fOutputSummary=0;\r
2402 TChain* chain = new TChain("highPt");\r
2403 if(!chain) return;\r
2404 chain->Add("jotwinow_HighPt_TrackAndV0_Trees.root");\r
2405 TTree *tree = chain->CopyTree("1");\r
2406 if (chain) { delete chain; chain=0; }\r
2407 if(!tree) return;\r
2408 tree->Print();\r
2409 fOutputSummary = tree;\r
2410\r
2411 if (!fOutputSummary) {\r
2412 Printf("ERROR: AliAnalysisTaskFilteredTree::Terminate(): Output data not avaiable %p \n", GetOutputData(1));\r
2413 return;\r
2414 }\r
2415 */\r
b4c82bc9 2416 \r
1059f583 2417}\r
2418\r
2419//_____________________________________________________________________________\r
2420Int_t AliAnalysisTaskFilteredTree::GetMCTrueTrackMult(AliMCEvent *const mcEvent, AliFilteredTreeEventCuts *const evtCuts, AliFilteredTreeAcceptanceCuts *const accCuts)\r
2421{\r
2422 //\r
2423 // calculate mc event true track multiplicity\r
2424 //\r
2425 if(!mcEvent) return 0;\r
2426\r
2427 AliStack* stack = 0;\r
2428 Int_t mult = 0;\r
2429\r
2430 // MC particle stack\r
2431 stack = mcEvent->Stack();\r
2432 if (!stack) return 0;\r
2433\r
2434 //\r
2435 //printf("minZv %f, maxZv %f \n", evtCuts->GetMinZv(), evtCuts->GetMaxZv());\r
2436 //\r
2437\r
2438 Bool_t isEventOK = evtCuts->AcceptMCEvent(mcEvent);\r
2439 if(!isEventOK) return 0; \r
2440\r
2441 Int_t nPart = stack->GetNtrack();\r
2442 for (Int_t iMc = 0; iMc < nPart; ++iMc) \r
2443 {\r
2444 TParticle* particle = stack->Particle(iMc);\r
2445 if (!particle)\r
2446 continue;\r
2447\r
2448 // only charged particles\r
2449 if(!particle->GetPDG()) continue;\r
2450 Double_t charge = particle->GetPDG()->Charge()/3.;\r
2451 if (TMath::Abs(charge) < 0.001)\r
2452 continue;\r
2453 \r
2454 // physical primary\r
2455 Bool_t prim = stack->IsPhysicalPrimary(iMc);\r
2456 if(!prim) continue;\r
2457\r
2458 // checked accepted without pt cut\r
2459 //if(accCuts->AcceptTrack(particle)) \r
2460 if( particle->Eta() > accCuts->GetMinEta() && particle->Eta() < accCuts->GetMaxEta() ) \r
2461 {\r
2462 mult++;\r
2463 }\r
2464 }\r
2465\r
2466return mult; \r
2467}\r
2468\r
30530964 2469//_____________________________________________________________________________\r
2470void AliAnalysisTaskFilteredTree::FillHistograms(AliESDtrack* const ptrack, AliExternalTrackParam* const ptpcInnerC, const Double_t centralityF, const Double_t chi2TPCInnerC) \r
2471{\r
2472//\r
2473// Fill pT relative resolution histograms for \r
2474// TPC only, TPC only constrained to vertex and TPC+ITS tracking\r
2475//\r
2476 if(!ptrack) return; \r
2477 if(!ptpcInnerC) return; \r
2478\r
2479 const AliExternalTrackParam * innerParam = (AliExternalTrackParam *) ptrack->GetInnerParam();\r
2480 if(!innerParam) return;\r
2481\r
2482 Float_t dxy, dz;\r
2483 ptrack->GetImpactParameters(dxy,dz);\r
2484\r
2485// TPC+ITS primary tracks \r
2486if( abs(ptrack->Eta())<0.8 && \r
2487 ptrack->GetTPCClusterInfo(3,1)>130 && \r
2488 ptrack->IsOn(0x40) && \r
2489 ptrack->GetTPCclusters(0)>0.0 && \r
2490 ptrack->GetTPCnclsS()/ptrack->GetTPCclusters(0)<0.2 && \r
2491 abs(innerParam->GetX())>0.0 && \r
2492 abs(innerParam->GetY()/innerParam->GetX())<0.14 && \r
2493 abs(innerParam->GetTgl())<0.85 && \r
2494 ptrack->IsOn(0x0004) && \r
2495 ptrack->GetNcls(0)>0 &&\r
2496 ptrack->GetITSchi2()>0 && \r
2497 sqrt(ptrack->GetITSchi2()/ptrack->GetNcls(0))<6 &&\r
2498 sqrt(chi2TPCInnerC)<6 &&\r
2499 abs(dz)<2.0 && \r
2500 abs(dxy)<(0.018+0.035*abs(ptrack->GetSigned1Pt())) )\r
2501 {\r
2502 fPtResPhiPtTPCITS->Fill(ptrack->Pt(),ptrack->Phi(),1./abs(ptrack->GetSigned1Pt())*TMath::Sqrt(ptrack->GetSigma1Pt2()));\r
2503 fPtResEtaPtTPCITS->Fill(ptrack->Pt(),ptrack->Eta(),1./abs(ptrack->GetSigned1Pt())*TMath::Sqrt(ptrack->GetSigma1Pt2()));\r
2504 fPtResCentPtTPCITS->Fill(ptrack->Pt(),centralityF,1./abs(ptrack->GetSigned1Pt())*TMath::Sqrt(ptrack->GetSigma1Pt2()));\r
2505 }\r
2506\r
2507// TPC primary tracks \r
2508// and TPC constrained primary tracks \r
2509\r
2510 AliExternalTrackParam *ptpcInner = (AliExternalTrackParam *) ptrack->GetTPCInnerParam(); \r
2511 if(!ptpcInner) return;\r
2512\r
1059f583 2513\r
30530964 2514 Float_t dxyTPC, dzTPC;\r
2515 ptrack->GetImpactParametersTPC(dxyTPC,dzTPC);\r
2516\r
2517if( abs(ptrack->Eta())<0.8 && \r
2518 ptrack->GetTPCClusterInfo(3,1)>130 && \r
2519 ptrack->IsOn(0x40)&& \r
2520 ptrack->GetTPCclusters(0)>0.0 && \r
2521 ptrack->GetTPCnclsS()/ptrack->GetTPCclusters(0)<0.2 && \r
2522 abs(innerParam->GetX())>0.0 && \r
2523 abs(innerParam->GetY()/innerParam->GetX())<0.14 && \r
2524 abs(innerParam->GetTgl())<0.85 && \r
2525 abs(dzTPC)<3.2 && \r
2526 abs(dxyTPC)<2.4 )\r
2527 {\r
2528 // TPC only\r
2529 fPtResPhiPtTPC->Fill(ptpcInner->Pt(),ptpcInner->Phi(),1./abs(ptpcInner->GetSigned1Pt())*TMath::Sqrt(ptpcInner->GetSigma1Pt2()));\r
2530 fPtResEtaPtTPC->Fill(ptpcInner->Pt(),ptpcInner->Eta(),1./abs(ptpcInner->GetSigned1Pt())*TMath::Sqrt(ptpcInner->GetSigma1Pt2()));\r
2531 fPtResCentPtTPC->Fill(ptpcInner->Pt(),centralityF,1./abs(ptpcInner->GetSigned1Pt())*TMath::Sqrt(ptpcInner->GetSigma1Pt2()));\r
2532\r
2533 // TPC constrained to vertex \r
2534 fPtResPhiPtTPCc->Fill(ptpcInnerC->Pt(),ptpcInnerC->Phi(),1./abs(ptpcInnerC->GetSigned1Pt())*TMath::Sqrt(ptpcInnerC->GetSigma1Pt2()));\r
2535 fPtResEtaPtTPCc->Fill(ptpcInnerC->Pt(),ptpcInnerC->Eta(),1./abs(ptpcInnerC->GetSigned1Pt())*TMath::Sqrt(ptpcInnerC->GetSigma1Pt2()));\r
2536 fPtResCentPtTPCc->Fill(ptpcInnerC->Pt(),centralityF,1./abs(ptpcInnerC->GetSigned1Pt())*TMath::Sqrt(ptpcInnerC->GetSigma1Pt2()));\r
2537 }\r
2538}\r