Introduced HBT and conversion cuts for standard BF analysis; Move from Vectors to...
[u/mrichter/AliRoot.git] / PWGCF / EBYE / BalanceFunctions / AliAnalysisTaskTriggeredBF.cxx
CommitLineData
f8b2d882 1#include "TChain.h"\r
2#include "TList.h"\r
3#include "TCanvas.h"\r
4#include "TLorentzVector.h"\r
5#include "TGraphErrors.h"\r
6#include "TH1F.h"\r
7#include "TH2F.h"\r
8#include "TArrayF.h"\r
9#include "TF1.h"\r
10#include "TRandom.h"\r
11\r
12#include "AliLog.h"\r
13\r
14#include "AliAnalysisTaskSE.h"\r
15#include "AliAnalysisManager.h"\r
16\r
17#include "AliESDVertex.h"\r
18#include "AliESDEvent.h"\r
19#include "AliESDInputHandler.h"\r
20#include "AliAODEvent.h"\r
21#include "AliAODTrack.h"\r
22#include "AliAODInputHandler.h"\r
23#include "AliGenEventHeader.h"\r
24#include "AliGenHijingEventHeader.h"\r
25#include "AliMCEventHandler.h"\r
26#include "AliMCEvent.h"\r
27#include "AliMixInputEventHandler.h"\r
28#include "AliStack.h"\r
29\r
30#include "TH2D.h" \r
31#include "AliTHn.h" \r
32\r
33#include "AliAnalysisTaskTriggeredBF.h"\r
34#include "AliBalanceTriggered.h"\r
35\r
36\r
37// Analysis task for the TriggeredBF code\r
38// Authors: Panos.Christakoglou@nikhef.nl, m.weber@cern.ch\r
39\r
40ClassImp(AliAnalysisTaskTriggeredBF)\r
41\r
42//________________________________________________________________________\r
43AliAnalysisTaskTriggeredBF::AliAnalysisTaskTriggeredBF(const char *name) \r
44: AliAnalysisTaskSE(name), \r
45 fBalance(0),\r
46 fRunShuffling(kFALSE),\r
47 fShuffledBalance(0),\r
845fdeca 48 fRunMixing(kFALSE),\r
49 fMixedBalance(0),\r
f8b2d882 50 fList(0),\r
51 fListTriggeredBF(0),\r
52 fListTriggeredBFS(0),\r
53 fHistListPIDQA(0),\r
54 fHistEventStats(0),\r
55 fHistCentStats(0),\r
56 fHistTriggerStats(0),\r
57 fHistTrackStats(0),\r
58 fHistVx(0),\r
59 fHistVy(0),\r
60 fHistVz(0),\r
61 fHistClus(0),\r
62 fHistDCA(0),\r
63 fHistChi2(0),\r
64 fHistPt(0),\r
65 fHistEta(0),\r
66 fHistPhi(0),\r
67 fHistPhiBefore(0),\r
68 fHistPhiAfter(0),\r
69 fHistV0M(0),\r
70 fHistRefTracks(0),\r
71 fCentralityEstimator("V0M"),\r
72 fUseCentrality(kFALSE),\r
73 fCentralityPercentileMin(0.), \r
74 fCentralityPercentileMax(5.),\r
75 fImpactParameterMin(0.),\r
76 fImpactParameterMax(20.),\r
77 fUseMultiplicity(kFALSE),\r
78 fNumberOfAcceptedTracksMin(0),\r
79 fNumberOfAcceptedTracksMax(10000),\r
80 fHistNumberOfAcceptedTracks(0),\r
81 fUseOfflineTrigger(kFALSE),\r
82 fVxMax(0.3),\r
83 fVyMax(0.3),\r
84 fVzMax(10.),\r
85 nAODtrackCutBit(128),\r
86 fPtMin(0.3),\r
87 fPtMax(1.5),\r
88 fEtaMin(-0.8),\r
89 fEtaMax(-0.8),\r
90 fDCAxyCut(-1),\r
91 fDCAzCut(-1),\r
92 fTPCchi2Cut(-1),\r
93 fNClustersTPCCut(-1)\r
94{\r
95 // Constructor\r
96 // Define input and output slots here\r
97 // Input slot #0 works with a TChain\r
98 DefineInput(0, TChain::Class());\r
99 // Output slot #0 writes into a TH1 container\r
100 DefineOutput(1, TList::Class());\r
101 DefineOutput(2, TList::Class());\r
102 DefineOutput(3, TList::Class());\r
103}\r
104\r
105//________________________________________________________________________\r
106AliAnalysisTaskTriggeredBF::~AliAnalysisTaskTriggeredBF() {\r
107\r
108 // Destructor\r
109\r
110}\r
111\r
112//________________________________________________________________________\r
113void AliAnalysisTaskTriggeredBF::UserCreateOutputObjects() {\r
114 // Create histograms\r
115 // Called once\r
116 if(!fBalance) {\r
117 fBalance = new AliBalanceTriggered();\r
118 fBalance->SetAnalysisLevel("AOD");\r
119 }\r
120 if(fRunShuffling) {\r
121 if(!fShuffledBalance) {\r
122 fShuffledBalance = new AliBalanceTriggered();\r
123 fShuffledBalance->SetAnalysisLevel("AOD");\r
124 }\r
125 }\r
845fdeca 126 if(fRunMixing) {\r
127 if(!fMixedBalance) {\r
128 fMixedBalance = new AliBalanceTriggered();\r
129 fMixedBalance->SetAnalysisLevel("AOD");\r
130 }\r
131 }\r
f8b2d882 132\r
133 //QA list\r
134 fList = new TList();\r
135 fList->SetName("listQA");\r
136 fList->SetOwner();\r
137\r
138 //Balance Function list\r
139 fListTriggeredBF = new TList();\r
140 fListTriggeredBF->SetName("listTriggeredBF");\r
141 fListTriggeredBF->SetOwner();\r
142\r
143 if(fRunShuffling) {\r
144 fListTriggeredBFS = new TList();\r
145 fListTriggeredBFS->SetName("listTriggeredBFShuffled");\r
146 fListTriggeredBFS->SetOwner();\r
147 }\r
845fdeca 148 if(fRunMixing) {\r
149 fListTriggeredBFM = new TList();\r
150 fListTriggeredBFM->SetName("listTriggeredBFMixed");\r
151 fListTriggeredBFM->SetOwner();\r
152 }\r
f8b2d882 153 \r
154 \r
155 //Event stats.\r
156 TString gCutName[4] = {"Total","Offline trigger",\r
157 "Vertex","Analyzed"};\r
158 fHistEventStats = new TH1F("fHistEventStats",\r
159 "Event statistics;;N_{events}",\r
160 4,0.5,4.5);\r
161 for(Int_t i = 1; i <= 4; i++)\r
162 fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data());\r
163 fList->Add(fHistEventStats);\r
164 \r
165 TString gCentName[9] = {"V0M","FMD","TRK","TKL","CL0","CL1","V0MvsFMD","TKLvsV0M","ZEMvsZDC"};\r
166 fHistCentStats = new TH2F("fHistCentStats",\r
167 "Centrality statistics;;Cent percentile",\r
168 9,-0.5,8.5,220,-5,105);\r
169 for(Int_t i = 1; i <= 9; i++)\r
170 fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data());\r
171 fList->Add(fHistCentStats);\r
172 \r
173 fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",130,0,130);\r
174 fList->Add(fHistTriggerStats);\r
175 \r
176 fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",130,0,130);\r
177 fList->Add(fHistTrackStats);\r
178\r
179 fHistNumberOfAcceptedTracks = new TH1F("fHistNumberOfAcceptedTracks",";N_{acc.};Entries",4001,-0.5,4000.5);\r
180 fList->Add(fHistNumberOfAcceptedTracks);\r
181\r
182 // Vertex distributions\r
183 fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5);\r
184 fList->Add(fHistVx);\r
185 fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5);\r
186 fList->Add(fHistVy);\r
187 fHistVz = new TH1F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Entries",100,-20.,20.);\r
188 fList->Add(fHistVz);\r
189\r
190 // QA histograms\r
191 fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200);\r
192 fList->Add(fHistClus);\r
193 fHistChi2 = new TH1F("fHistChi2","Chi2/NDF distribution",200,0,10);\r
194 fList->Add(fHistChi2);\r
195 fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5); \r
196 fList->Add(fHistDCA);\r
197 fHistPt = new TH1F("fHistPt","p_{T} distribution",200,0,10);\r
198 fList->Add(fHistPt);\r
199 fHistEta = new TH1F("fHistEta","#eta distribution",200,-2,2);\r
200 fList->Add(fHistEta);\r
201 fHistPhi = new TH1F("fHistPhi","#phi distribution",200,-20,380);\r
202 fList->Add(fHistPhi);\r
203 fHistPhiBefore = new TH1F("fHistPhiBefore","#phi distribution",200,0.,2*TMath::Pi());\r
204 fList->Add(fHistPhiBefore);\r
205 fHistPhiAfter = new TH1F("fHistPhiAfter","#phi distribution",200,0.,2*TMath::Pi());\r
206 fList->Add(fHistPhiAfter);\r
207 fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000);\r
208 fList->Add(fHistV0M);\r
209 TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"};\r
210 fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000);\r
211 for(Int_t i = 1; i <= 6; i++)\r
212 fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data());\r
213 fList->Add(fHistRefTracks);\r
214\r
215\r
216\r
217 // Balance function histograms\r
218 // Initialize histograms if not done yet\r
219 if(!fBalance->GetHistNp()){\r
220 AliWarning("Histograms not yet initialized! --> Will be done now");\r
221 AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction");\r
222 fBalance->InitHistograms();\r
223 }\r
224\r
225 if(fRunShuffling) {\r
226 if(!fShuffledBalance->GetHistNp()) {\r
227 AliWarning("Histograms (shuffling) not yet initialized! --> Will be done now");\r
228 AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction");\r
229 fShuffledBalance->InitHistograms();\r
230 }\r
231 }\r
232\r
845fdeca 233 if(fRunMixing) {\r
234 if(!fMixedBalance->GetHistNp()) {\r
235 AliWarning("Histograms (mixing) not yet initialized! --> Will be done now");\r
236 AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction");\r
237 fMixedBalance->InitHistograms();\r
238 }\r
239 }\r
240\r
f8b2d882 241 fListTriggeredBF->Add(fBalance->GetHistNp());\r
242 fListTriggeredBF->Add(fBalance->GetHistNn());\r
243 fListTriggeredBF->Add(fBalance->GetHistNpn());\r
244 fListTriggeredBF->Add(fBalance->GetHistNnn());\r
245 fListTriggeredBF->Add(fBalance->GetHistNpp());\r
246 fListTriggeredBF->Add(fBalance->GetHistNnp());\r
247 \r
248 if(fRunShuffling) {\r
249 fListTriggeredBFS->Add(fShuffledBalance->GetHistNp());\r
250 fListTriggeredBFS->Add(fShuffledBalance->GetHistNn());\r
251 fListTriggeredBFS->Add(fShuffledBalance->GetHistNpn());\r
252 fListTriggeredBFS->Add(fShuffledBalance->GetHistNnn());\r
253 fListTriggeredBFS->Add(fShuffledBalance->GetHistNpp());\r
254 fListTriggeredBFS->Add(fShuffledBalance->GetHistNnp());\r
255 } \r
256\r
845fdeca 257 if(fRunMixing) {\r
258 fListTriggeredBFM->Add(fMixedBalance->GetHistNp());\r
259 fListTriggeredBFM->Add(fMixedBalance->GetHistNn());\r
260 fListTriggeredBFM->Add(fMixedBalance->GetHistNpn());\r
261 fListTriggeredBFM->Add(fMixedBalance->GetHistNnn());\r
262 fListTriggeredBFM->Add(fMixedBalance->GetHistNpp());\r
263 fListTriggeredBFM->Add(fMixedBalance->GetHistNnp());\r
264 } \r
f8b2d882 265\r
845fdeca 266\r
267 // // event mixing\r
268 // Int_t trackDepth = fMixingTracks; \r
269 // Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager\r
270 \r
271 // Int_t nCentralityBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(1);\r
272 // Double_t* centralityBins = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray();\r
273 \r
274 // Int_t nZvtxBins = 7+1+7;\r
275 // // bins for second buffer are shifted by 100 cm\r
276 // Double_t vertexBins[] = { -7, -5, -3, -1, 1, 3, 5, 7, 93, 95, 97, 99, 101, 103, 105, 107 };\r
277 // Double_t* zvtxbin = vertexBins;\r
278\r
279 // if (fHistos->GetUEHist(2)->GetEventHist()->GetNVar() > 2)\r
280 // {\r
281 // nZvtxBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(2);\r
282 // zvtxbin = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(2, 0)->GetXbins()->GetArray();\r
283 // }\r
284\r
285 // fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centralityBins, nZvtxBins, zvtxbin);\r
f8b2d882 286\r
287 // Post output data.\r
288 PostData(1, fList);\r
289 PostData(2, fListTriggeredBF);\r
290 if(fRunShuffling) PostData(3, fListTriggeredBFS);\r
845fdeca 291 if(fRunMixing) PostData(4, fListTriggeredBFM);\r
f8b2d882 292}\r
293\r
294//________________________________________________________________________\r
295void AliAnalysisTaskTriggeredBF::UserExec(Option_t *) {\r
296 // Main loop\r
297 // Called for each event\r
298\r
299 TString gAnalysisLevel = fBalance->GetAnalysisLevel();\r
845fdeca 300 Float_t fCentrality = 0.; \r
f8b2d882 301\r
302 // ------------------------------------------------------------- \r
303 // AOD analysis (vertex and track cuts also here!!!!)\r
304 if(gAnalysisLevel == "AOD") {\r
845fdeca 305 AliVEvent* eventMain = dynamic_cast<AliVEvent*>(InputEvent()); \r
306 if(!eventMain) {\r
307 AliError("eventMain not available");\r
308 return;\r
309 }\r
310\r
311 // check event cuts and fill event histograms\r
312 if((fCentrality = IsEventAccepted(eventMain)) < 0){\r
f8b2d882 313 return;\r
314 }\r
315 \r
845fdeca 316 // get the accepted tracks in main event\r
317 TObjArray *tracksMain = GetAcceptedTracks(eventMain);\r
318\r
319 // store charges of all accepted tracks, shuffle and reassign (two extra loops!)\r
320 TObjArray* tracksShuffled = NULL;\r
321 if(fRunShuffling){\r
322 tracksShuffled = GetShuffledTracks(tracksMain);\r
323 }\r
f8b2d882 324 \r
845fdeca 325 // if (fFillMixed)\r
326 // {\r
327 // // event mixing\r
f8b2d882 328 \r
845fdeca 329 // // 1. First get an event pool corresponding in mult (cent) and\r
330 // // zvertex to the current event. Once initialized, the pool\r
331 // // should contain nMix (reduced) events. This routine does not\r
332 // // pre-scan the chain. The first several events of every chain\r
333 // // will be skipped until the needed pools are filled to the\r
334 // // specified depth. If the pool categories are not too rare, this\r
335 // // should not be a problem. If they are rare, you could lose\r
336// // statistics.\r
337\r
338// // 2. Collect the whole pool's content of tracks into one TObjArray\r
339// // (bgTracks), which is effectively a single background super-event.\r
340\r
341// // 3. The reduced and bgTracks arrays must both be passed into\r
342// // FillCorrelations(). Also nMix should be passed in, so a weight\r
343// // of 1./nMix can be applied.\r
344\r
345// AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx);\r
f8b2d882 346 \r
845fdeca 347// if (!pool)\r
348// AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centrality, zVtx));\r
f8b2d882 349 \r
845fdeca 350// //pool->SetDebug(1);\r
351 \r
352// if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5) \r
353// {\r
354 \r
355// Int_t nMix = pool->GetCurrentNEvents();\r
356// // cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;\r
f8b2d882 357 \r
845fdeca 358// ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2);\r
359// ((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());\r
360// if (pool->IsReady())\r
361// ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3);\r
362 \r
363// // Fill mixed-event histos here \r
364// for (Int_t jMix=0; jMix<nMix; jMix++) \r
365// {\r
366// TObjArray* bgTracks = pool->GetEvent(jMix);\r
f8b2d882 367 \r
845fdeca 368// if (!fSkipStep6)\r
369// fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracksClone, bgTracks, 1.0 / nMix, (jMix == 0));\r
370\r
371// if (fTwoTrackEfficiencyCut > 0)\r
372// fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracksClone, bgTracks, 1.0 / nMix, (jMix == 0), kTRUE, bSign, fTwoTrackEfficiencyCut);\r
373// }\r
374// }\r
375\r
376 // calculate balance function\r
377 fBalance->FillBalance(fCentrality,tracksMain);//,chargeVectorMixed); // here comes the mixing... in some time\r
378 \r
379 // calculate shuffled balance function\r
380 if(fRunShuffling && tracksShuffled != NULL) {\r
381 fShuffledBalance->FillBalance(fCentrality,tracksShuffled);\r
382 }\r
383 \r
384 \r
385 }//AOD analysis\r
386 else{\r
387 AliError("Triggered Balance Function analysis only for AODs!");\r
388 }\r
389} \r
390\r
391//________________________________________________________________________\r
392Float_t AliAnalysisTaskTriggeredBF::IsEventAccepted(AliVEvent *event){\r
393 // Checks the Event cuts\r
394 // Fills Event statistics histograms\r
395 \r
396 // event selection done in AliAnalysisTaskSE::Exec() --> this is not used\r
397 fHistEventStats->Fill(1); //all events\r
398\r
399 Bool_t isSelectedMain = kTRUE;\r
400 Float_t fCentrality = -1.;\r
401 TString gAnalysisLevel = fBalance->GetAnalysisLevel();\r
402 \r
403 if(fUseOfflineTrigger)\r
404 isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();\r
405 \r
406 if(isSelectedMain) {\r
407 fHistEventStats->Fill(2); //triggered events\r
408 \r
409 //Centrality stuff \r
410 if(fUseCentrality) {\r
411 if(gAnalysisLevel == "AOD") { //centrality in AOD header\r
412 AliAODHeader *header = (AliAODHeader*) event->GetHeader();\r
413 fCentrality = header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data());\r
414\r
f8b2d882 415 // QA for centrality estimators\r
845fdeca 416 fHistCentStats->Fill(0.,header->GetCentralityP()->GetCentralityPercentile("V0M"));\r
417 fHistCentStats->Fill(1.,header->GetCentralityP()->GetCentralityPercentile("FMD"));\r
418 fHistCentStats->Fill(2.,header->GetCentralityP()->GetCentralityPercentile("TRK"));\r
419 fHistCentStats->Fill(3.,header->GetCentralityP()->GetCentralityPercentile("TKL"));\r
420 fHistCentStats->Fill(4.,header->GetCentralityP()->GetCentralityPercentile("CL0"));\r
421 fHistCentStats->Fill(5.,header->GetCentralityP()->GetCentralityPercentile("CL1"));\r
422 fHistCentStats->Fill(6.,header->GetCentralityP()->GetCentralityPercentile("V0MvsFMD"));\r
423 fHistCentStats->Fill(7.,header->GetCentralityP()->GetCentralityPercentile("TKLvsV0M"));\r
424 fHistCentStats->Fill(8.,header->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC"));\r
f8b2d882 425 \r
426 // centrality QA (V0M)\r
845fdeca 427 fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C());\r
f8b2d882 428 \r
429 // centrality QA (reference tracks)\r
845fdeca 430 fHistRefTracks->Fill(0.,header->GetRefMultiplicity());\r
431 fHistRefTracks->Fill(1.,header->GetRefMultiplicityPos());\r
432 fHistRefTracks->Fill(2.,header->GetRefMultiplicityNeg());\r
433 fHistRefTracks->Fill(3.,header->GetTPConlyRefMultiplicity());\r
434 fHistRefTracks->Fill(4.,header->GetNumberOfITSClusters(0));\r
435 fHistRefTracks->Fill(5.,header->GetNumberOfITSClusters(1));\r
436 fHistRefTracks->Fill(6.,header->GetNumberOfITSClusters(2));\r
437 fHistRefTracks->Fill(7.,header->GetNumberOfITSClusters(3));\r
438 fHistRefTracks->Fill(8.,header->GetNumberOfITSClusters(4));\r
f8b2d882 439 }\r
845fdeca 440 }\r
441 \r
442 \r
443 const AliVVertex *vertex = event->GetPrimaryVertex();\r
444 \r
445 if(vertex) {\r
446 Double32_t fCov[6];\r
447 vertex->GetCovarianceMatrix(fCov);\r
448 if(vertex->GetNContributors() > 0) {\r
449 if(fCov[5] != 0) {\r
450 fHistEventStats->Fill(3); //events with a proper vertex\r
451 if(TMath::Abs(vertex->GetX()) < fVxMax) {\r
452 if(TMath::Abs(vertex->GetY()) < fVyMax) {\r
453 if(TMath::Abs(vertex->GetZ()) < fVzMax) {\r
454 fHistEventStats->Fill(4); //analyzed events\r
455 fHistVx->Fill(vertex->GetX());\r
456 fHistVy->Fill(vertex->GetY());\r
457 fHistVz->Fill(vertex->GetZ());\r
458\r
459 // take only events inside centrality class\r
460 if((fCentrality > fCentralityPercentileMin) && (fCentrality < fCentralityPercentileMax)){\r
461 return fCentrality; \r
462 }//centrality class\r
463 }//Vz cut\r
464 }//Vy cut\r
465 }//Vx cut\r
466 }//proper vertex resolution\r
467 }//proper number of contributors\r
468 }//vertex object valid\r
469 }//triggered event \r
470 \r
471 // in all other cases return -1 (event not accepted)\r
472 return -1;\r
473}\r
474\r
475//________________________________________________________________________\r
476TObjArray* AliAnalysisTaskTriggeredBF::GetAcceptedTracks(AliVEvent *event){\r
477 // Returns TObjArray with tracks after all track cuts (only for AOD!)\r
478 // Fills QA histograms\r
479\r
480 //output TObjArray holding all good tracks\r
481 TObjArray* tracksAccepted = new TObjArray;\r
482 tracksAccepted->SetOwner(kTRUE);\r
483\r
484 Double_t v_charge;\r
485 Double_t v_eta;\r
486 Double_t v_phi;\r
487 Double_t v_pt;\r
488 \r
489 // Loop over tracks in event\r
490 for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {\r
491 AliAODTrack* aodTrack = dynamic_cast<AliAODTrack *>(event->GetTrack(iTracks));\r
492 if (!aodTrack) {\r
493 AliError(Form("Could not receive track %d", iTracks));\r
494 continue;\r
495 }\r
496 \r
497 // AOD track cuts\r
498 \r
499 // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C\r
500 // take only TPC only tracks \r
501 fHistTrackStats->Fill(aodTrack->GetFilterMap());\r
502 if(!aodTrack->TestFilterBit(nAODtrackCutBit)) continue;\r
503 \r
504 v_charge = aodTrack->Charge();\r
505 v_eta = aodTrack->Eta();\r
506 v_phi = aodTrack->Phi() * TMath::RadToDeg();\r
507 v_pt = aodTrack->Pt();\r
508 \r
509 Float_t DCAxy = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on)\r
510 Float_t DCAz = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on)\r
511 \r
512 \r
513 // Kinematics cuts from ESD track cuts\r
514 if( v_pt < fPtMin || v_pt > fPtMax) continue;\r
515 if( v_eta < fEtaMin || v_eta > fEtaMax) continue;\r
516 \r
517 // Extra DCA cuts (for systematic studies [!= -1])\r
518 if( fDCAxyCut != -1 && fDCAzCut != -1){\r
519 if(TMath::Sqrt((DCAxy*DCAxy)/(fDCAxyCut*fDCAxyCut)+(DCAz*DCAz)/(fDCAzCut*fDCAzCut)) > 1 ){\r
520 continue; // 2D cut\r
521 }\r
522 }\r
523 \r
524 // Extra TPC cuts (for systematic studies [!= -1])\r
525 if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){\r
526 continue;\r
527 }\r
528 if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){\r
529 continue;\r
530 }\r
531 \r
532 // fill QA histograms\r
533 fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls());\r
534 fHistDCA->Fill(DCAz,DCAxy);\r
535 fHistChi2->Fill(aodTrack->Chi2perNDF());\r
536 fHistPt->Fill(v_pt);\r
537 fHistEta->Fill(v_eta);\r
538 fHistPhi->Fill(v_phi);\r
539 \r
540 // add the track to the TObjArray\r
541 tracksAccepted->Add(new AliBFBasicParticle(v_eta, v_phi, v_pt, v_charge));\r
f8b2d882 542 }\r
845fdeca 543\r
544 return tracksAccepted;\r
545}\r
546\r
547//________________________________________________________________________\r
548TObjArray* AliAnalysisTaskTriggeredBF::GetShuffledTracks(TObjArray *tracks){\r
549 // Clones TObjArray and returns it with tracks after shuffling the charges\r
550\r
551 TObjArray* tracksShuffled = new TObjArray;\r
552 tracksShuffled->SetOwner(kTRUE);\r
553\r
554 vector<Short_t> *chargeVector = new vector<Short_t>; //original charge of accepted tracks \r
555\r
556 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)\r
557 {\r
558 AliVParticle* track = (AliVParticle*) tracks->At(i);\r
559 chargeVector->push_back(track->Charge());\r
560 } \r
561 \r
562 random_shuffle(chargeVector->begin(), chargeVector->end());\r
563 \r
564 for(Int_t i = 0; i < tracks->GetEntriesFast(); i++){\r
565 AliVParticle* track = (AliVParticle*) tracks->At(i);\r
566 tracksShuffled->Add(new AliBFBasicParticle(track->Eta(), track->Phi(), track->Pt(),chargeVector->at(i)));\r
567 }\r
568 \r
569 return tracksShuffled;\r
570}\r
f8b2d882 571\r
572//________________________________________________________________________\r
573void AliAnalysisTaskTriggeredBF::FinishTaskOutput(){\r
574\r
575 if (!fBalance) {\r
576 AliError("fBalance not available");\r
577 return;\r
578 } \r
579 if(fRunShuffling) {\r
580 if (!fShuffledBalance) {\r
581 AliError("fShuffledBalance not available");\r
582 return;\r
583 }\r
584 }\r
585\r
586}\r
587\r
588//________________________________________________________________________\r
589void AliAnalysisTaskTriggeredBF::Terminate(Option_t *) {\r
590 // Called once at the end of the query\r
591\r
592 // not implemented ...\r
593\r
594}\r
595\r
596void AliAnalysisTaskTriggeredBF::UserExecMix(Option_t *)\r
597{\r
598\r
599 // not yet done for event mixing!\r
600 return;\r
601\r
602}\r
603\r