In AliMUONCheck:
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisTaskLeadingTrackUE.cxx
CommitLineData
a75aacd6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id:$ */
17
18#include <TROOT.h>
19#include <TChain.h>
20#include <TFile.h>
21#include <TList.h>
22#include <TMath.h>
23#include <TTree.h>
24#include <TH2F.h>
25#include <TRandom.h>
26//#include <TVector3.h>
27
28#include "AliAnalysisTaskLeadingTrackUE.h"
29#include "AliAnalyseLeadingTrackUE.h"
30#include "AliUEHistograms.h"
31#include "AliUEHist.h"
32
33#include "AliAnalysisHelperJetTasks.h"
34#include "AliAnalysisManager.h"
35#include "AliAODHandler.h"
36#include "AliAODInputHandler.h"
37#include "AliAODMCParticle.h"
38#include "AliGenPythiaEventHeader.h"
39#include "AliInputEventHandler.h"
40#include "AliLog.h"
41#include "AliMCEventHandler.h"
42#include "AliVParticle.h"
43
44
45////////////////////////////////////////////////////////////////////////
46//
47// Analysis class for Underlying Event studies w.r.t. leading track
48//
49// Look for correlations on the tranverse regions w.r.t
50// the leading track in the event
51//
52// This class needs input AODs.
53// The output is a list of analysis-specific containers.
54//
55// The AOD can be either connected to the InputEventHandler
56// for a chain of AOD files
57// or
58// to the OutputEventHandler
59// for a chain of ESD files,
60// in this case the class should be in the train after the jet-finder
61//
62// Authors:
63// Arian Abrahantes Quintana
64// Jan Fiete Grosse-Oetringhaus
65// Ernesto Lopez Torres
66// Sara Vallero
67//
68////////////////////////////////////////////////////////////////////////
69
70
71ClassImp( AliAnalysisTaskLeadingTrackUE )
72
73// Define global pointer
74AliAnalysisTaskLeadingTrackUE* AliAnalysisTaskLeadingTrackUE::fgTaskLeadingTrackUE=NULL;
75
76//____________________________________________________________________
77AliAnalysisTaskLeadingTrackUE:: AliAnalysisTaskLeadingTrackUE(const char* name):
78AliAnalysisTask(name,""),
79// general configuration
80fDebug(0),
81fMode(0),
82// pointers to UE classes
83fAnalyseUE(0x0),
84fHistosUE(0x0),
144bd037 85fkTrackingEfficiency(0x0),
a75aacd6 86// handlers and events
87fAOD(0x0),
88fArrayMC(0x0),
89fInputHandler(0x0),
90fMcEvent(0x0),
91fMcHandler(0x0),
92// histogram settings
93fListOfHistos(0x0),
94fBinsPtInHist(30),
95fMinJetPtInHist(0.),
96fMaxJetPtInHist(300.),
97// event QA
144bd037 98fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
99fZVertex(10.),
a75aacd6 100// track cuts
101fTrackEtaCut(0.8),
102fLeadingTrackEtaCut(0.8),
103fFilterBit(0xFF),
144bd037 104fSelectBit(0),
a75aacd6 105fUseChargeHadrons(kFALSE),
106//For MC weighting
107fAvgTrials(1)
108{
109 // Default constructor
110 // Define input and output slots here
111 // Input slot #0 works with a TChain
112 DefineInput(0, TChain::Class());
113 // Output slot #0 writes into a TList container
114 DefineOutput(0, TList::Class());
115
116}
117
118
119/************** INTERFACE METHODS *****************************/
120
121//______________________________________________________________
122Bool_t AliAnalysisTaskLeadingTrackUE::Notify()
123{
124
125 // Implemented Notify() to read the cross sections
126 // and number of trials from pyxsec.root.
127 // This will be used when merging different MC samples.
128 // (Copied from AliAnalysisTaskJFSystematics)
129
130 fAvgTrials = 1;
131 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
132 Float_t xsection = 0;
133 Float_t trials = 1;
134 if(tree){
135 TFile *curfile = tree->GetCurrentFile();
136 if (!curfile) {
137 Error("Notify","No current file");
138 return kFALSE;
139 }
140
141 AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,trials);
142
143 //TO-DO
144 //fHistosUE->GetXsec()->Fill("<#sigma>",xsection);
145
146 // construct average trials
147 Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
148 if(trials>=nEntries && nEntries>0.)fAvgTrials = trials/nEntries;
149 }
150
151 return kTRUE;
152}
153
154//____________________________________________________________________
155void AliAnalysisTaskLeadingTrackUE::ConnectInputData(Option_t* /*option*/)
156{
157
158 // Connect the input data
159 if (fDebug > 1) AliInfo("ConnectInputData() ");
160
161 // Since AODs can either be connected to the InputEventHandler
162 // or to the OutputEventHandler ( the AOD is created by a previus task in the train )
163 // we need to get the pointer to the AODEvent correctly.
164
165 // Delta AODs are also accepted.
166
167 TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
168
169 if( handler && handler->InheritsFrom("AliAODInputHandler") ) { // input AOD
170 fAOD = ((AliAODInputHandler*)handler)->GetEvent();
171 if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODInputHandler");
172 } else { //output AOD
173 handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
174 if( handler && handler->InheritsFrom("AliAODHandler") ) {
175 fAOD = ((AliAODHandler*)handler)->GetAOD();
176 if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODHandler");
177 } else { // no AOD
178 AliFatal("I can't get any AOD Event Handler");
179 return;
180 }
181 }
182
183 // Initialize common pointers
184 Initialize();
185
186}
187
188//____________________________________________________________________
189void AliAnalysisTaskLeadingTrackUE::CreateOutputObjects()
190{
191 // Create the output container
192
193 if (fDebug > 1) AliInfo("CreateOutputObjects()");
194
195 // Initialize class with main algorithms, event and track selection.
196 fAnalyseUE = new AliAnalyseLeadingTrackUE();
197 fAnalyseUE->SetParticleSelectionCriteria(fFilterBit, fUseChargeHadrons, fLeadingTrackEtaCut);
198 fAnalyseUE->SetDebug(fDebug);
199
200 // Initialize output list of containers
201 if (fListOfHistos != NULL){
202 delete fListOfHistos;
203 fListOfHistos = NULL;
204 }
205 if (!fListOfHistos){
206 fListOfHistos = new TList();
207 fListOfHistos->SetOwner(kTRUE);
208 }
209
210 // Initialize class to handle histograms
211 fHistosUE = new AliUEHistograms;
212
213 // add histograms to list
214 fListOfHistos->Add(fHistosUE);
215
216 //fListOfHistos->Add(new TH2F("multVsLeadStep5", ";multiplicity;leading pT", 100, -0.5, 99.5, 20, 0, 10));
217
218 // Add task configuration to output list
219 AddSettingsTree();
220
221
222 PostData(0,fListOfHistos);
223}
224
225//____________________________________________________________________
226void AliAnalysisTaskLeadingTrackUE::Exec(Option_t */*option*/)
227{
228 // array of MC particles
229 if (fMcHandler){
230 fArrayMC = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
231 if (!fArrayMC)AliFatal("No array of MC particles found !!!");
232 }
233
234 // Get number of trials from MC header
235 Float_t nTrials = 1;
236 if (fMcHandler) {
237 fMcEvent = fMcHandler->MCEvent();
238 if (fMcEvent) {
239 // TO-DO: extend to PHOJET
240 AliGenPythiaEventHeader* pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(fMcEvent);
241 if(pythiaGenHeader){
242 nTrials = pythiaGenHeader->Trials();
243 }
244 }
245 }
246
247 // TO-DO
248 //fHistosUE->GetTrials()->Fill("#sum{ntrials}",fAvgTrials);
249
250 // Analyse the event
251 if (fMode) AnalyseCorrectionMode();
252 else AnalyseDataMode();
253
254 PostData(0,fListOfHistos);
255}
256
257//____________________________________________________________________
258void AliAnalysisTaskLeadingTrackUE::Terminate(Option_t */*option*/)
259{
260
261 // Terminate analysis
262 if( fDebug > 1 ) AliInfo("End analysis");
263
264 if (!gROOT->IsBatch()){
265 fListOfHistos = dynamic_cast<TList*> (GetOutputData(0));
266 if (!fListOfHistos){
267 AliError("Histogram List is not available");
268 return;
269 }else{
270 // Draw something
271 }
272 } else {
273 AliInfo(" Batch mode, not histograms will be shown...");
274 }
275
276}
277
278
279/******************** ANALYSIS METHODS *****************************/
280
281//____________________________________________________________________
282void AliAnalysisTaskLeadingTrackUE::AddSettingsTree()
283{
284 //Write settings to output list
285 TTree *settingsTree = new TTree("UEAnalysisSettings","Analysis Settings in UE estimation");
286 settingsTree->Branch("fFilterBit", &fFilterBit,"FilterBit/I");
144bd037 287 settingsTree->Branch("fSelectBit", &fSelectBit,"EventSelectionBit/I");
a75aacd6 288 settingsTree->Branch("fLeadingTrackEtaCut", &fLeadingTrackEtaCut, "LeadingTrackEtaCut/D");
289 settingsTree->Branch("fUseChargeHadrons", &fUseChargeHadrons,"UseChHadrons/O");
290 settingsTree->Fill();
291 fListOfHistos->Add(settingsTree);
292}
293
294//____________________________________________________________________
295void AliAnalysisTaskLeadingTrackUE::AnalyseCorrectionMode()
296{
297
298 // Run the analysis on MC to get the correction maps
299
300 PostData(0,fListOfHistos);
301
302 if ( fDebug > 3 ) AliInfo( " Processing event in Corrections mode ..." );
303
304 //PROCESS TYPE (ND,SD,DD)
305 AliAnalysisHelperJetTasks::MCProcessType eventId = AliAnalysisHelperJetTasks::kInvalidProcess;
306 if (fMcHandler && fMcEvent) {
307 AliGenEventHeader* genHeader = fMcEvent->GenEventHeader();
308 eventId = AliAnalysisHelperJetTasks::GetPythiaEventProcessType(genHeader,kFALSE);
309 if (eventId<0){
310 eventId = AliAnalysisHelperJetTasks::GetDPMjetEventProcessType(genHeader,kFALSE);
311 }
312 if (eventId<0 && fDebug>1)AliInfo("No Pythia or Phojet Header retrived!");
313 }
314 Int_t fillId=-1;
315 if (eventId == AliAnalysisHelperJetTasks::kND)fillId = 0;
316 if (eventId == AliAnalysisHelperJetTasks::kSD)fillId = 1;
317 if (eventId == AliAnalysisHelperJetTasks::kDD)fillId = 2;
318
319 // count all events
320 fHistosUE->FillEvent(fillId, -1);
321
322 // Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex
323 if (!fAnalyseUE->VertexSelection(fMcEvent, 0, fZVertex))
324 return;
325
326 // Get MC-true leading particle (but do not cut out events!)
327 TObjArray *ltMC = (TObjArray*)fAnalyseUE->FindLeadingObjects(fArrayMC);
328 AliVParticle* leadingMC = 0;
329 if (ltMC)
330 leadingMC = (AliVParticle*) ltMC->At(0);
331
332 // it can happen that there is no MC leading particle in the acceptance required (|eta|<0.8)
333 // and we do not want to base the event slection on MC information
334
335 // Sort MC-true charged particles
336 // as output you get an array of 3 lists of particles belonging to different regions:
337 // - at 0: towards
338 // - at 1: away
339 // - at 2: transverse MIN
340 // - at 3: transverse MAX
341 TObjArray *regionSortedParticlesMC = (TObjArray*)fAnalyseUE->SortRegions(leadingMC, fArrayMC, 0x0);
342 TObjArray *regionsMinMaxMC = (TObjArray*)fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesMC->At(2),(TList*)regionSortedParticlesMC->At(3));
343 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
344 // (MC-true leading particle and MC-true all particles)
345 // STEP 0
346 fHistosUE->Fill(fillId,AliUEHist::kCFStepAll,leadingMC,(TList*)regionSortedParticlesMC->At(0),(TList*)regionSortedParticlesMC->At(1),(TList*)regionsMinMaxMC->At(0),(TList*)regionsMinMaxMC->At(1));
347
348 // Trigger selection ************************************************
349 if (fAnalyseUE->TriggerSelection(fInputHandler))
350 {
144bd037 351 // PILEUP-CUT
352 Bool_t select = kTRUE;
353 if (fSelectBit) select = AliAnalysisHelperJetTasks::TestSelectInfo(fSelectBit);
354 if (!select)
355 fHistosUE->FillEvent(fillId, -2);
356 else
357 {
358
359 // Count events that pass AliPhysicsSelection
a75aacd6 360
144bd037 361 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
362 // (MC-true leading particle and MC-true all particles)
363 // STEP 1
364 fHistosUE->Fill(fillId,AliUEHist::kCFStepTriggered,leadingMC,(TList*)regionSortedParticlesMC->At(0),(TList*)regionSortedParticlesMC->At(1),(TList*)regionsMinMaxMC->At(0),(TList*)regionsMinMaxMC->At(1));
365
366 // count number of MC tracks above 150 MeV/c
367 Int_t nMCTracks = 0;
368 if (leadingMC && leadingMC->Pt() > 0.15)
369 nMCTracks++;
370 for (Int_t i=0; i<4; i++)
371 for (Int_t j=0; j<((TList*)regionSortedParticlesMC->At(i))->GetEntries(); j++)
372 if (((AliVParticle*) ((TList*)regionSortedParticlesMC->At(i))->At(j))->Pt() > 0.15)
373 nMCTracks++;
a75aacd6 374
144bd037 375 //((TH2F*)fListOfHistos->FindObject("multVsLeadStep5"))->Fill(nMCTracks, leadingMC->Pt());
a75aacd6 376
144bd037 377 // Vertex selection *************************************************
378 if (fAnalyseUE->VertexSelection(fAOD, fnTracksVertex, fZVertex))
379 {
380 // Count events that pass Vertex selection
a75aacd6 381
144bd037 382 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
383 // (MC-true leading particle and MC-true all particles)
384 // STEP 2
385 fHistosUE->Fill(fillId,AliUEHist::kCFStepVertex,leadingMC,(TList*)regionSortedParticlesMC->At(0),(TList*)regionSortedParticlesMC->At(1),(TList*)regionsMinMaxMC->At(0),(TList*)regionsMinMaxMC->At(1));
a75aacd6 386
144bd037 387
388
389 // Get Reconstructed leading particle *******************************
390 TObjArray *ltRECO = fAnalyseUE->FindLeadingObjects(fAOD);
391 if (ltRECO)
392 {
393 // Count events where a reconstructed track was found in |eta|<0.8
394 // the pT cut will be set when projecting output containers
395 // for leading particle correlation plots
396 if (leadingMC) {
397 fHistosUE->Fill(leadingMC, (AliVParticle*)ltRECO->At(0));
398 }
a75aacd6 399
144bd037 400 // If there is no MC leading track the container is not filled, so the number of entries in the container might be different
401 // from the number of events after the selection, since the selection is based on RECO tracks
402 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
403 // (MC-true leading particle and MC-true all particles)
404 // STEP 3
405 fHistosUE->Fill(fillId,AliUEHist::kCFStepAnaTopology,leadingMC,(TList*)regionSortedParticlesMC->At(0),(TList*)regionSortedParticlesMC->At(1),(TList*)regionsMinMaxMC->At(0),(TList*)regionsMinMaxMC->At(1));
a75aacd6 406
144bd037 407 //Sort RECO particles w.r.t. MC-leading and return matched (primary) MC particle
408 // (you cannot sort tracks w.r.t. RECO-leading and plot it vs. MC-leading ...)
409 TObjArray *regionSortedParticlesRECOLTMC = (TObjArray*)fAnalyseUE->SortRegions(leadingMC, fAOD, fArrayMC);
410 TObjArray *regionsMinMaxRECOLTMC = (TObjArray*)fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesRECOLTMC->At(2),(TList*)regionSortedParticlesRECOLTMC->At(3));
411 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
412 // (MC leading particle and RECO-matched (quantities from MC particle) all particles)
413 // STEP 4
414 fHistosUE->Fill(fillId,AliUEHist::kCFStepTrackedOnlyPrim,leadingMC,(TList*)regionSortedParticlesRECOLTMC->At(0),(TList*)regionSortedParticlesRECOLTMC->At(1),(TList*)regionsMinMaxRECOLTMC->At(0),(TList*)regionsMinMaxRECOLTMC->At(1));
415 // comparing this step with step 3 (for all-tracks observables) you get the tracking efficiency
a75aacd6 416
144bd037 417 //Sort RECO particles w.r.t. MC-leading and return matched (primary+secondary) MC particle
418 // (you cannot sort tracks w.r.t. RECO-leading and plot it vs. MC-leading ...)
419 TObjArray *regionSortedParticlesRECOLTMC2 = (TObjArray*)fAnalyseUE->SortRegions(leadingMC, fAOD, fArrayMC,kFALSE);
420 TObjArray *regionsMinMaxRECOLTMC2 = (TObjArray*)fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesRECOLTMC2->At(2),(TList*)regionSortedParticlesRECOLTMC2->At(3));
a75aacd6 421
144bd037 422 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
423 // (MC leading particle and RECO-matched (quantities from MC particle) all particles)
424 // STEP 5
425 fHistosUE->Fill(fillId,AliUEHist::kCFStepTracked,leadingMC,(TList*)regionSortedParticlesRECOLTMC2->At(0),(TList*)regionSortedParticlesRECOLTMC2->At(1),(TList*)regionsMinMaxRECOLTMC2->At(0),(TList*)regionsMinMaxRECOLTMC2->At(1));
426 // comparing this step with step 3 (for all-tracks observables) you get the tracking efficiency
a75aacd6 427
144bd037 428 // SWITCH TO RECONSTRUCTED TRACKS ************************************
429 // The next steps correspond to track selections
430 // Sort RECO particles w.r.t. RECO-leading and return RECO particle
431 TObjArray *regionSortedParticlesRECO = (TObjArray*)fAnalyseUE->SortRegions((AliVParticle*)ltRECO->At(0), fAOD,0);
432 TObjArray *regionsMinMaxRECO = (TObjArray*)fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesRECO->At(2),(TList*)regionSortedParticlesRECO->At(3));
433 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
434 // (RECO leading particle and RECO all particles)
435 // STEP 6
436 fHistosUE->Fill(fillId,AliUEHist::kCFStepReconstructed,(AliVParticle*)ltRECO->At(0),(TList*)regionSortedParticlesRECO->At(0),(TList*)regionSortedParticlesRECO->At(1),(TList*)regionsMinMaxRECO->At(0),(TList*)regionsMinMaxRECO->At(1));
a75aacd6 437
144bd037 438 // STEP 8 for reduced efficiency study
439 FillReducedEfficiency(fillId, AliUEHist::kCFStepBiasStudy, ltRECO, kFALSE);
440 FillReducedEfficiency(fillId, AliUEHist::kCFStepBiasStudy2, ltRECO, kTRUE);
a75aacd6 441
144bd037 442 // count number of reco tracks above 150 MeV/c
443 Int_t nRecoTracks = 0;
444 if (((AliVParticle*) ltRECO->At(0))->Pt() > 0.15)
445 nRecoTracks++;
446 for (Int_t i=0; i<4; i++)
447 for (Int_t j=0; j<((TList*)regionSortedParticlesRECO->At(i))->GetEntries(); j++)
448 if (((AliVParticle*) ((TList*)regionSortedParticlesRECO->At(i))->At(j))->Pt() > 0.15)
449 nRecoTracks++;
450
451 if (leadingMC && leadingMC->Pt() > 0.5)
452 fHistosUE->GetCorrelationMultiplicity()->Fill(nMCTracks, nRecoTracks);
a75aacd6 453
144bd037 454 if (leadingMC)
455 {
456 // Match reco leading track with true *********************************
457 Int_t recoLabel = ((AliAODTrack*)ltRECO->At(0))->GetLabel();
458 Int_t mcLabel = ((AliAODMCParticle*)leadingMC)->GetLabel();
459 if (recoLabel != mcLabel)
460 return;
a75aacd6 461
144bd037 462 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
463 // (RECO-MATCHED leading particle and RECO all particles)
464 // STEP 7
465 fHistosUE->Fill(fillId,AliUEHist::kCFStepRealLeading,(AliVParticle*)ltRECO->At(0),(TList*)regionSortedParticlesRECO->At(0),(TList*)regionSortedParticlesRECO->At(1),(TList*)regionsMinMaxRECO->At(0),(TList*)regionsMinMaxRECO->At(1));
466 // comparing this step with step 6 (for leading-track observables) you get the efficiency to reconstruct the leading track
467 // comparing this step with step 6 (for all-tracks observables) you see how leading-track misidentification affects the final distributions
468 }
a75aacd6 469
144bd037 470 delete regionSortedParticlesRECOLTMC;
471 delete regionsMinMaxRECOLTMC;
472 delete regionSortedParticlesRECOLTMC2;
473 delete regionsMinMaxRECOLTMC2;
474 delete regionSortedParticlesRECO;
475 delete regionsMinMaxRECO;
476 delete ltRECO;
477 } // lt reco
478 } // vertex
479 } // pileup
480 } //phyiscs selection
a75aacd6 481
482 if (ltMC)
483 delete ltMC;
484 delete regionSortedParticlesMC;
485 delete regionsMinMaxMC;
486}
487
488//____________________________________________________________________
489void AliAnalysisTaskLeadingTrackUE::AnalyseDataMode()
490{
491
492 // Run the analysis on DATA or MC to get raw distributions
493
494 PostData(0,fListOfHistos);
495
496 if ( fDebug > 3 ) AliInfo( " Processing event in Data mode ..." );
497 Int_t eventId = 0;
498
499 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
500 fHistosUE->FillEvent(eventId, AliUEHist::kCFStepAll);
501
502 // Trigger selection ************************************************
503 if (!fAnalyseUE->TriggerSelection(fInputHandler)) return;
144bd037 504 // PILEUP-CUT
505 Bool_t select = kTRUE;
506 if (fSelectBit) select = AliAnalysisHelperJetTasks::TestSelectInfo(fSelectBit);
507 if (!select)
508 {
509 fHistosUE->FillEvent(eventId, -2);
510 return;
511 }
a75aacd6 512 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
513 fHistosUE->FillEvent(eventId, AliUEHist::kCFStepTriggered);
514
515 // Vertex selection *************************************************
516 if(!fAnalyseUE->VertexSelection(fAOD, fnTracksVertex, fZVertex)) return;
517 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
518 fHistosUE->FillEvent(eventId, AliUEHist::kCFStepVertex);
519 // comparing this step with previous one you get the vertex selection efficiency from data (?)
144bd037 520
521
a75aacd6 522 // Get Reconstructed leading particle *******************************
523 TObjArray *ltRECO = fAnalyseUE->FindLeadingObjects(fAOD);
524 if (!ltRECO) return;
525
526 // fill control distributions
527 fHistosUE->Fill(0, (AliVParticle*)ltRECO->At(0));
528
529 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
530 fHistosUE->FillEvent(eventId, AliUEHist::kCFStepAnaTopology);
531
532 // Switch to reconstructed tracks ************************************
533 // Sort RECO particles w.r.t. RECO-leading and return RECO particle
534 TObjArray *regionSortedParticlesRECO = (TObjArray*)fAnalyseUE->SortRegions((AliVParticle*)ltRECO->At(0), fAOD,0);
535 TObjArray *regionsMinMaxRECO = (TObjArray*)fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesRECO->At(2),(TList*)regionSortedParticlesRECO->At(3));
536 // Fill UE containers (step, leading track, towards particles, away particles, transverse MIN and MAX particles)
537 // (RECO leading particle and RECO all particles)
538 // STEP 6
539 fHistosUE->Fill(eventId,AliUEHist::kCFStepReconstructed,(AliVParticle*)ltRECO->At(0),(TList*)regionSortedParticlesRECO->At(0),(TList*)regionSortedParticlesRECO->At(1),(TList*)regionsMinMaxRECO->At(0),(TList*)regionsMinMaxRECO->At(1));
540
541 // STEP 8 and 9 for reduced efficiency study
542 FillReducedEfficiency(eventId, AliUEHist::kCFStepBiasStudy, ltRECO, kFALSE);
543 FillReducedEfficiency(eventId, AliUEHist::kCFStepBiasStudy2, ltRECO, kTRUE);
544
545 delete ltRECO;
546 delete regionSortedParticlesRECO;
547 delete regionsMinMaxRECO;
548}
549
550//____________________________________________________________________
144bd037 551void AliAnalysisTaskLeadingTrackUE::FillReducedEfficiency(Int_t eventId, AliUEHist::CFStep step, const TObjArray* ltRECO, Bool_t twoStep)
a75aacd6 552{
144bd037 553 // remove leading particle using fkTrackingEfficiency and use subleading particle to fill the histograms
a75aacd6 554 //
555 // if twoStep is kTRUE, do a two step procedure where in each step only 50% of the loss due to the tracking efficiency is applied
556
144bd037 557 if (!fkTrackingEfficiency)
a75aacd6 558 return;
559
560 TObjArray* particleList = (TObjArray*) ltRECO->Clone();
561 AliVParticle* leading = (AliVParticle*) particleList->At(0);
562 if (!leading)
563 return;
564
565 // remove particles depending on tracking efficiency
566 Int_t count = (twoStep) ? 2 : 1;
567
568 for (Int_t i=0; i<count; i++)
569 {
144bd037 570 Float_t trackingEff = fkTrackingEfficiency->GetBinContent(fkTrackingEfficiency->GetXaxis()->FindBin(leading->Pt()));
a75aacd6 571 if (twoStep)
572 trackingEff = 0.5 * (trackingEff + 1);
573
574 if (gRandom->Uniform() > trackingEff)
575 {
576 //Printf("LOWEFF: Removing leading particle");
577 particleList->RemoveAt(0);
578 particleList->Compress();
579 }
580
581 if (particleList->GetEntries() == 0)
582 {
583 delete particleList;
584 return;
585 }
586
587 leading = (AliVParticle*) particleList->At(0);
588 }
589
590 TObjArray *regionSortedParticlesRECOLowEff = fAnalyseUE->SortRegions(leading, particleList, 0);
591 TObjArray *regionsMinMaxRECOLowEff = fAnalyseUE->GetMinMaxRegion((TList*)regionSortedParticlesRECOLowEff->At(2), (TList*)regionSortedParticlesRECOLowEff->At(3));
592
593 fHistosUE->Fill(eventId,step,leading,(TList*)regionSortedParticlesRECOLowEff->At(0), (TList*)regionSortedParticlesRECOLowEff->At(1), (TList*)regionsMinMaxRECOLowEff->At(0), (TList*)regionsMinMaxRECOLowEff->At(1));
594
595 delete regionSortedParticlesRECOLowEff;
596 delete regionsMinMaxRECOLowEff;
597 delete particleList;
598}
599
600//____________________________________________________________________
601void AliAnalysisTaskLeadingTrackUE::Initialize()
602{
603 // input handler
604 fInputHandler = (AliInputEventHandler*)
605 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
606 // MC handler
607 fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
608}
609
610
611
612
613
614