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