AliPhysics  b81c3d2 (b81c3d2)

Implementation of task to embed external events. More...

#include <AliAnalysisTaskEmcalEmbeddingHelper.h>

## Public Member Functions

void UserExec (Option_t *option)

void UserCreateOutputObjects ()

void SetPtHardBin (Int_t r)

void SetAnchorRun (Int_t r)

void Terminate (Option_t *option)

AliVEvent * GetExternalEvent () const

TString GetTreeName () const

Bool_t GetRandomEventNumberAccess () const
Randomly start from an entry in the file. Will then loop around so that all entries are made available. More...

Bool_t GetRandomFileAccess () const
Randomly select the first file. Continues sequentially afterwards. More...

TString GetFilePattern () const

Int_t GetStartingFileIndex () const

TString GetFileListFilename () const

void SetESD (const char *treeName="esdTree")

void SetAOD (const char *treeName="aodTree")

void SetRandomEventNumberAccess (Bool_t b)

void SetRandomFileAccess (Bool_t b)

void SetFilePattern (const char *pattern)

void SetStartingFileIndex (Int_t n)

void SetFileListFilename (const char *filename)

Double_t GetZVertexCut () const

Double_t GetMaxVertexDistance () const

void SetZVertexCut (Double_t zVertex)

void SetMaxVertexDistance (Double_t distance)

static const
GetInstance ()

static

## Protected Member Functions

void GetFilenames ()

std::string GenerateUniqueFileListFilename ()

void SetupEmbedding ()

Bool_t SetupInputFiles ()

Bool_t GetNextEntry ()

Bool_t IsEventSelected ()

Bool_t InitEvent ()

void InitTree ()

## Protected Attributes

Double_t fZVertexCut
Z vertex cut on embedded event. More...

Double_t fMaxVertexDist
Max distance between Z vertex of internal and embedded event. More...

bool fInitializedNewFile
! Notes where the entry indices have been initialized for a new tree in the chain More...

bool fInitializedEmbedding
! Notes where the TChain has been initialized for embedding More...

bool fWrappedAroundTree
! Notes whether we have wrapped around the tree, which is important if the offset into the tree is non-zero More...

TString fTreeName
Name of the ESD/AOD tree where the events are to be found. More...

Int_t fAnchorRun
Anchor run for the given pythia production. More...

Int_t fPtHardBin
ptHard bin for the given pythia production More...

Bool_t fRandomEventNumberAccess
If true, it will start embedding from a random entry in the file rather than from the first. More...

Bool_t fRandomFileAccess
If true, it will start embedding from a random file in the input files list. More...

TString fFilePattern
File pattern to select AliEn files. More...

TString fFileListFilename
Name of the file list containing paths to files to embed. More...

Int_t fFilenameIndex
Index of vector containing paths to files to embed. More...

std::vector< std::string > fFilenames
! Paths to the files to embed More...

TFile * fExternalFile
! External file used for embedding More...

TChainfChain
! External TChain (tree) containing the events available for embedding More...

Int_t fCurrentEntry
! Current entry in the current tree More...

Int_t fLowerEntry
! First entry of the current tree to be used for embedding More...

Int_t fUpperEntry
! Last entry of the current tree to be used for embedding More...

Int_t fOffset
! Offset from fLowerEntry where the loop over the tree should start More...

Int_t fMaxNumberOfFiles
! Max number of files that are in the TChain More...

Int_t fFileNumber
! File number corresponding to the current tree More...

AliVEvent * fExternalEvent
! Current external event available for embedding More...

## Static Protected Attributes

static
fgInstance = 0
! Global instance of this class More...

## Detailed Description

Implementation of task to embed external events.

This class derives from AliAnalysisTaskSE and allows the user to open an external ESD or AOD file, providing access to the events.

The capabilities of the task are as follows:

• Open an ESD/AOD file according to certain customizable options, such as production tag, pt hard bin, run number, file pattern, etc.
• It selects an event according to customizable criteria, such as vertex, centrality, high pt track, pt hard bin, etc.
• Load the event in memory: this is the "external" event, as opposed to the "internal" event provided by the analysis manager
• Provide a public method GetExternalEvent() that allows to retrieve a pointer to the external event.

Note that only one instance of this class is allowed in each train (singleton class).

For the user, most of these details are handled by AliEmcalContainer derived tasks. To access the embedded input objects, the user simply needs to set AliEmcalContainer::SetIsEmbedding(Bool_t). This design ensures that usage is nearly seamless. For instance, it will "just work" in an analysis task, and it very nearly "just works" in the (new) EMCal correction framework (it only requires one small change in the normal correction procedure beyond noting that the input objects are embedded).

For further information on usage (including with the EMCal corrections), see the EMCal Embedding Documentation.

Date
Apr 28, 2016

Definition at line 59 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

## Constructor & Destructor Documentation

Default constructor. Needed by ROOT I/O

Definition at line 47 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Standard constructor. Should be used by the user.

Parameters
 [in] name Name of the task

Definition at line 87 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

virtual

Destructor

Deletes the singleton instance and ensures that any open file is closed.

Definition at line 127 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

private

## Member Function Documentation

static

Add task function. This contains the normal AddTask functionality, except in compiled code, making errors easier to spot than in CINT. The AddTask macro still exists for use on the LEGO train, but simply wraps this function.

Returns

Definition at line 661 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

protected

Simple helper function to generate a unique file list filename. This filename will be used to store the filelist locally. It will be of the form fFileListFilename + ".UUID.txt". If fFileListFilename is empty, then the beginning of the filename will be "fileList".

Returns
std::string containing the rest of the file to be appended to fFileListFilename

Definition at line 274 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by GetFilenames().

inline

Definition at line 74 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 83 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Get the names of the files to embed and determine which file to start from. The filenames will be used to initialize a TChain. Filenames can either be specified in a local file with one filename per line or found on AliEn by specifying any pattern that would work in alien_find.

Notes on this function:

• In the case that the passed files contain ".zip", the root file name will be appended. Be certain to set the proper file type (AOD or ESD)!
• In the case of AliEn, the result will be copied into a local file.
• The file to start from can be randomized if requested.

The file pattern can be specified by a number of different options:

• The simplest is pass a fully formed path to a file either locally or on AliEn.
• You could specify a pT hard bin, which will be added into the passed file pattern. For example, "/period/runNumber/%d/aod_archive.root", where the d will the be the pT hard bin.
• You could specify a pT hard bin and anchor run, which will both be added into the passed file pattern. "/period/%d/%d/aod_archive.root", where the first d will the be the anchor run number, and the second d will be the pT hard bin.

NOTE: The file pattern only makes sense in terms of AliEn. Passing a local pattern will not work! NOTE: Exercise care if you set both the file pattern and the filename! Doing so will probably cause your file to be overwritten!

Definition at line 160 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by SetupEmbedding().

inline

Definition at line 81 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inlinestatic

Definition at line 72 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 95 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Get the next event (entry) in the TChain to make it available for embedding. The event will be selected according to the conditions determined in IsEventSelected(). If needed it calls InitTree() to setup the next tree within the TChain. In the case of running of out files to embed, an error is thrown and embedding begins again from the start of the file list.

Returns
kTRUE if successful

Definition at line 296 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by UserExec().

inline

Randomly start from an entry in the file. Will then loop around so that all entries are made available.

Definition at line 78 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Randomly select the first file. Continues sequentially afterwards.

Definition at line 80 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 82 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 76 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 93 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 94 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Initialize the external event by creating an event and then reading the event info from the TChain.

Returns
kTRUE if successful

Definition at line 441 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by SetupInputFiles().

protected

Initializes a new TTree within the TChain by determining the limits of the current TTree within the TChain. By carefully keeping track of the first and lest entry of the current tree in the opened file, we allow a random entry point into the event in the tree without jumping between files, which would not perform well on the grid.

This function sets up a random entry point into the file if requested.

Sets fInitializedNewFile to kTRUE when the new entries in the tree have been initialized.

Definition at line 579 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by GetNextEntry(), and UserExec().

protected

Performs an event selection on the current external event.

Returns
kTRUE if the event successfully passes all criteria.

Definition at line 366 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by GetNextEntry().

private
 void AliAnalysisTaskEmcalEmbeddingHelper::SetAnchorRun ( Int_t r )
inline

Definition at line 69 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetAOD ( const char * treeName = "aodTree" )
inline

Definition at line 86 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetESD ( const char * treeName = "esdTree" )
inline

Definition at line 85 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetFileListFilename ( const char * filename )
inline

Definition at line 91 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetFilePattern ( const char * pattern )
inline

Definition at line 89 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetMaxVertexDistance ( Double_t distance )
inline

Definition at line 99 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetPtHardBin ( Int_t r )
inline

Definition at line 68 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetRandomEventNumberAccess ( Bool_t b )
inline

Definition at line 87 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetRandomFileAccess ( Bool_t b )
inline

Definition at line 88 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::SetStartingFileIndex ( Int_t n )
inline

Definition at line 90 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

inline

Definition at line 97 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Setup embedding by retrieving the file list and then setting up the TChain based on that file list.

Sets fInitializedEmbedding to kTRUE when the initialization is completed.

Definition at line 552 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by UserCreateOutputObjects(), and UserExec().

protected

Use the input files to setup the TChain. This involves accessing the files on AliEn and ensuring that each file actually exists. If the TChain is successfully set up, then embedding is ready to proceed.

Returns
kTRUE if successful in setting up the TChain.

Definition at line 479 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Referenced by SetupEmbedding().

 void AliAnalysisTaskEmcalEmbeddingHelper::SetZVertexCut ( Double_t zVertex )
inline

Definition at line 98 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

 void AliAnalysisTaskEmcalEmbeddingHelper::Terminate ( Option_t * option )

This function is called once at the end of the analysis.

Definition at line 650 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

Performing run-independent initialization to setup embedding.

If the setup is not successful here, it will be repeated in UserExec().

Definition at line 468 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

 void AliAnalysisTaskEmcalEmbeddingHelper::UserExec ( Option_t * option )

Run the main analysis code here. If for some reason the embedding was not successfully set up in UserCreateOutputObjects(), it is set up against before continuing. It also ensures that the current tree is available before attempting to get the next entry.

Definition at line 628 of file AliAnalysisTaskEmcalEmbeddingHelper.cxx.

## Member Data Documentation

protected

Anchor run for the given pythia production.

Definition at line 122 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), and SetAnchorRun().

protected

! External TChain (tree) containing the events available for embedding

Definition at line 132 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), InitEvent(), InitTree(), and SetupInputFiles().

protected

! Current entry in the current tree

Definition at line 133 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().

protected

! Current external event available for embedding

Definition at line 139 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetExternalEvent(), InitEvent(), IsEventSelected(), and ~AliAnalysisTaskEmcalEmbeddingHelper().

protected

! External file used for embedding

Definition at line 131 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Name of the file list containing paths to files to embed.

Definition at line 128 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

Index of vector containing paths to files to embed.

Definition at line 129 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), GetStartingFileIndex(), SetStartingFileIndex(), and SetupInputFiles().

protected

! Paths to the files to embed

Definition at line 130 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), and SetupInputFiles().

protected

! File number corresponding to the current tree

Definition at line 138 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().

protected

File pattern to select AliEn files.

Definition at line 127 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), GetFilePattern(), and SetFilePattern().

staticprotected

! Global instance of this class

Definition at line 141 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

! Notes where the TChain has been initialized for embedding

Definition at line 118 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by SetupEmbedding(), and UserExec().

protected

! Notes where the entry indices have been initialized for a new tree in the chain

Definition at line 117 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by InitTree(), and UserExec().

protected

! First entry of the current tree to be used for embedding

Definition at line 134 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().

protected

! Max number of files that are in the TChain

Definition at line 137 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and SetupInputFiles().

protected

Max distance between Z vertex of internal and embedded event.

Definition at line 115 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetMaxVertexDistance(), IsEventSelected(), and SetMaxVertexDistance().

protected

! Offset from fLowerEntry where the loop over the tree should start

Definition at line 136 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().

protected

ptHard bin for the given pythia production

Definition at line 123 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), and SetPtHardBin().

protected

If true, it will start embedding from a random entry in the file rather than from the first.

Definition at line 124 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetRandomEventNumberAccess(), InitTree(), SetRandomEventNumberAccess(), and SetupEmbedding().

protected

If true, it will start embedding from a random file in the input files list.

Definition at line 125 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), GetRandomFileAccess(), and SetRandomFileAccess().

protected

Name of the ESD/AOD tree where the events are to be found.

Definition at line 121 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetFilenames(), GetTreeName(), InitEvent(), SetAOD(), SetESD(), and SetupInputFiles().

protected

Definition at line 113 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

protected

! Last entry of the current tree to be used for embedding

Definition at line 135 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().

protected

! Notes whether we have wrapped around the tree, which is important if the offset into the tree is non-zero

Definition at line 119 of file AliAnalysisTaskEmcalEmbeddingHelper.h.

Referenced by GetNextEntry(), and InitTree().