ROOT logo
AliRoot » ANALYSIS » AliAnalysisTask

class AliAnalysisTask: public TTask

   AliAnalysysTask - Class representing a basic analysis task. Any
 user-defined task should derive from it and implement the Exec() virtual
 method.


 A specific user analysis task have to derive from this class. The list of
 specific input and output slots have to be defined in the derived class ctor:

   UserTask::UserTask(name, title)
   {
      DefineInput(0, TTree::Class());
      DefineInput(1, TH1::Class());

      DefineOutput(0, TTree::Class());
      DefineOutput(1, MyObject::Class());

   }

 An existing data contaner (AliAnalysisDataContainer) can be connected to the
 input/output slots of an analysis task. Containers should not be defined and
 connected by the derived analysis task, but from the level of AliAnalysisManager:

   AliAnalysisManager::ConnectInput(AliAnalysisTask *task, Int_t islot,
                                   AliAnalysisDataContainer *cont)
   AliAnalysisManager::ConnectOutput(AliAnalysisTask *task, Int_t islot,
                                    AliAnalysisDataContainer *cont)
 To connect a slot to a data container, the data types declared by both must
 match.

 The method ConnectInputData() has to be overloaded by the derived class in order to
 set the branch address or connect to a branch address in case the input
 slots are connected to trees.
 Example:
 MyAnalysisTask::ConnectInputData(Option_t *)
 {
  // One should first check if the branch address was taken by some other task
    char ** address = (char **)GetBranchAddress(0, "ESD");
    if (address) {
      fESD = (AliESD*)(*address);
    } else {
      fESD = new AliESD();
      SetBranchAddress(0, "ESD", &fESD);
    }
 }

 The method LocalInit() may be implemented to call locally (on the client)
 all initialization methods of the class. It is not mandatory and was created
 in order to minimize the complexity and readability of the analysis macro.
 DO NOT create in this method the histigrams or task output objects that will
 go in the task output containers. Use CreateOutputObjects for that.

 The method CreateOutputObjects() has to be implemented an will contain the
 objects that should be created only once per session (e.g. output
 histograms)

 void MyAnalysisTask::CreateOutputObjects()
{
 create histograms
  fhPt = new TH1F("fhPt","This is the Pt distribution",15,0.1,3.1);
  fhPt->SetStats(kTRUE);
  fhPt->GetXaxis()->SetTitle("P_{T} [GeV]");
  fhPt->GetYaxis()->SetTitle("#frac{dN}{dP_{T}}");
  fhPt->GetXaxis()->SetTitleColor(1);
  fhPt->SetMarkerStyle(kFullCircle);
 }

 The method Terminate() will be called by the framework once at the end of
 data processing. Overload this if needed. DO NOT ASSUME that the pointers
 to histograms defined in  CreateOutputObjects() are valid, since this is
 not true in case of PROOF. Restore the pointer values like:

void MyAnalysisTask::Terminate(Option_t *)
{
  fhPt = (TH1F*)GetOutputData(0);

}

Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~AliAnalysisTask()
virtual voidTTask::Abort()MENU
voidTObject::AbstractMethod(const char* method) const
virtual voidTTask::Add(TTask* task)
virtual voidTObject::AppendPad(Option_t* option = "")
Bool_tAreSlotsConnected()
virtual voidTTask::Browse(TBrowser* b)
Bool_tCheckCircularDeps()
voidCheckNotify(Bool_t init = kFALSE)
virtual Bool_tCheckOwnership() const
virtual Bool_tCheckPostData() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTTask::CleanTasks()
virtual voidTTask::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
Bool_tConnectInput(Int_t islot, AliAnalysisDataContainer* cont)
virtual voidConnectInputData(Option_t* option = "")
Bool_tConnectOutput(Int_t islot, AliAnalysisDataContainer* cont)
virtual voidTTask::Continue()MENU
virtual voidTNamed::Copy(TObject& named) const
virtual voidCreateOutputObjects()
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidExec(Option_t* option)
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTTask::ExecuteTask(Option_t* option = "0")MENU
virtual voidTTask::ExecuteTasks(Option_t* option)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual voidFinishTaskOutput()
voidGetBranches(const char* type, TString& result) const
Int_tTTask::GetBreakin() const
Int_tTTask::GetBreakout() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
TObject*GetInputData(Int_t islot) const
AliAnalysisDataSlot*GetInputSlot(Int_t islot) const
TClass*GetInputType(Int_t islot) const
TList*TTask::GetListOfTasks() const
virtual const char*TNamed::GetName() const
Int_tGetNinputs() const
Int_tGetNoutputs() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
TObject*GetOutputData(Int_t islot) const
AliAnalysisDataSlot*GetOutputSlot(Int_t islot) const
TClass*GetOutputType(Int_t islot) const
TObject*GetPublishedData() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
Bool_tHasBranches() const
Bool_tHasExecuted() const
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tTTask::IsActive() const
Bool_tIsChecked() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTTask::IsFolder() const
Bool_tIsInitialized() const
Bool_tTObject::IsOnHeap() const
Bool_tIsOutputReady(Int_t islot) const
Bool_tIsPostEventLoop() const
Bool_tIsReady() const
virtual Bool_tTNamed::IsSortable() const
Bool_tIsUsed() const
Bool_tIsZombie() const
virtual voidLocalInit()
virtual voidTTask::ls(Option_t* option = "*") constMENU
voidTObject::MayNotUse(const char* method) const
virtual Bool_tNotify()
virtual Bool_tNotifyBinChange()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
AliAnalysisTask&operator=(const AliAnalysisTask& task)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
voidPrintContainers(Option_t* option = "all", Int_t indent = 0) const
virtual voidPrintTask(Option_t* option = "all", Int_t indent = 0) const
Bool_tProducersTouched() const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidReset()
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTTask::SetActive(Bool_t active = kTRUE)TOGGLE
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetBranches(const char* names)
voidTTask::SetBreakin(Int_t breakin = 1)TOGGLE
voidTTask::SetBreakout(Int_t breakout = 1)TOGGLE
voidSetChecked(Bool_t flag = kTRUE)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetPostEventLoop(Bool_t flag = kTRUE)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetUsed(Bool_t flag = kTRUE)
voidSetZombie(Bool_t flag = kTRUE)
virtual voidShowMembers(TMemberInspector&)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
virtual voidTerminate(Option_t* option = "")
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
voidDefineInput(Int_t islot, TClass* type)
voidDefineOutput(Int_t islot, TClass* type)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidEnableBranch(Int_t islot, const char* bname) const
char*GetBranchAddress(Int_t islot, const char* branch) const
voidTObject::MakeZombie()
TFile*OpenFile(Int_t iout, Option_t* option = "RECREATE") const
Bool_tPostData(Int_t iout, TObject* data, Option_t* option = "")
Bool_tSetBranchAddress(Int_t islot, const char* branch, void* address) const

Data Members

public:
enum EAnalysisTaskFlags { kTaskUsed
kTaskZombie
kTaskChecked
kTaskPostEventLoop
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
Bool_tTTask::fActivetrue if task is active
TStringfBranchNamesList of input branches that need to be loaded for this task
Int_tTTask::fBreakin=1 if a break point set at task extry
Int_tTTask::fBreakout=1 if a break point set at task exit
Bool_tTTask::fHasExecutedTrue if task has executed
Bool_tfInitializedTrue if Init() was called
TObjArray*fInputsArray of input slots
TStringTNamed::fNameobject identifier
Int_tfNinputsNumber of inputs
Int_tfNoutputsNumber of outputs
TStringTTask::fOptionOption specified in ExecuteTask
Bool_t*fOutputReady[fNoutputs] Flags for output readyness
TObjArray*fOutputsArray of output slots
TObject*fPublishedData! published data
Bool_tfReadyFlag if the task is ready
TList*TTask::fTasksList of Tasks
TStringTNamed::fTitleobject title
static TTask*TTask::fgBeginTaskpointer to task initiator
static TTask*TTask::fgBreakPointpointer to current break point

Class Charts

Inheritance Chart:
TTask
AliAnalysisTask
AliAnaScale
AliAnalysisTaskAddObject
AliAnalysisTaskB2
AliAnalysisTaskDielectronEfficiency
AliAnalysisTaskFilter
AliAnalysisTaskFilterFriend
AliAnalysisTaskFilterFriendSecond
AliAnalysisTaskFilterSteer
AliAnalysisTaskIPInfo
AliAnalysisTaskLUT
 [more...]

Function documentation

~AliAnalysisTask()
 Dtor.
AliAnalysisTask& operator=(const AliAnalysisTask& task)
 Assignment
Bool_t AreSlotsConnected()
 Check if all input/output slots are connected. If this is the case fReady=true
void CheckNotify(Bool_t init = kFALSE)
 Check if data is available from all inputs. Change the status of the task
 accordingly. This method is called automatically for all tasks connected
 to a container where the data was published.
Bool_t CheckPostData() const
 Checks if data was posted to all outputs defined by the task. If task does
 not have output slots this returns always kTRUE.
Bool_t CheckOwnership() const
 Check ownership of containers posted on output slots (1 level only)
Bool_t ConnectInput(Int_t islot, AliAnalysisDataContainer* cont)
 Connect an input slot to a data container.
Bool_t ConnectOutput(Int_t islot, AliAnalysisDataContainer* cont)
 Connect an output slot to a data container.
void DefineInput(Int_t islot, TClass* type)
 Define an input slot and its type.
void DefineOutput(Int_t islot, TClass* type)
 Define an output slot and its type.
TClass * GetInputType(Int_t islot) const
 Retreive type of a given input slot.
TClass * GetOutputType(Int_t islot) const
 Retreive type of a given output slot.
TObject * GetInputData(Int_t islot) const
 Retreive input data for a slot if ready. Normally called by Exec() and
 the object has to be statically cast to the appropriate type.
TObject * GetOutputData(Int_t islot) const
 Retreive output data for a slot. Normally called in UserTask::Terminate to
 get a valid pointer to data even in case of Proof.
char * GetBranchAddress(Int_t islot, const char* branch) const
 Check if a branch with a given name from the specified input is connected
 to some address. Call this in Init() before trying to call SetBranchAddress()
 since the adress may be set by other task.
Bool_t SetBranchAddress(Int_t islot, const char* branch, void* address) const
 Connect an object address to a branch of the specified input.
void EnableBranch(Int_t islot, const char* bname) const
 Call this in ConnectInputData() to enable only the branches needed by this
 task. "*" will enable everything.
void FinishTaskOutput()
 Optional method that is called in SlaveTerminate phase.
 Used for calling aditional methods just after the last event was processed ON
 THE WORKING NODE. The call is made also in local case.
 Do NOT delete output objects here since they will have to be sent for
 merging in PROOF mode - use class destructor for cleanup.
void ConnectInputData(Option_t* option = "")
 Overload and connect your branches here.
void LocalInit()
 The method LocalInit() may be implemented to call locally (on the client)
 all initialization methods of the class. It is not mandatory and was created
 in order to minimize the complexity and readability of the analysis macro.
 DO NOT create in this method the histigrams or task output objects that will
 go in the task output containers. Use CreateOutputObjects for that.
void CreateOutputObjects()
 Called once per task either in PROOF or local mode. Overload to put some
 task initialization and/or create your output objects here.
TFile * OpenFile(Int_t iout, Option_t* option = "RECREATE") const
 This method has to be called INSIDE the user redefined CreateOutputObjects
 method, before creating each object corresponding to the output containers
 that are to be written to a file. This need to be done in general for the big output
 objects that may not fit memory during processing.
 - 'option' is the file opening option.

 NOTE !: The method call will be ignored in PROOF mode, in which case the
 results have to be streamed back to the client and written just before Terminate()


 Example:
 void MyAnaTask::CreateOutputObjects() {
    OpenFile(0);   // Will open the file for the object to be written at output #0
    fAOD = new TTree("AOD for D0toKPi");
    OpenFile(1);
 now some histos that should go in the file of the second output container
    fHist1 = new TH1F("my quality check hist1",...);
    fHist2 = new TH2F("my quality check hist2",...);
 }
Bool_t Notify()
 Overload this IF you need to treat input file change.
Bool_t NotifyBinChange()
 Overload this IF you need to treat bin change in event mixing.
void Terminate(Option_t* option = "")
 Method called by the framework at the end of data processing.
Bool_t PostData(Int_t iout, TObject* data, Option_t* option = "")
 Post output data for a given ouput slot in the corresponding data container.
 Published data becomes owned by the data container.
 If option is specified, the container connected to the output slot must have
 an associated file name defined. The option represents the method to open the file.
void SetUsed(Bool_t flag = kTRUE)
 Set 'used' flag recursively to task and all daughter tasks.
void Reset()
 Clear activity flag. Reset data for exchange containers.
Bool_t CheckCircularDeps()
 Check for illegal circular dependencies, e.g. a daughter task should not have
 a hierarchical parent as subtask.
Bool_t ProducersTouched() const
 Check if all producer containers are in the "touched" state.
void PrintTask(Option_t* option = "all", Int_t indent = 0) const
 Print task info.
void PrintContainers(Option_t* option = "all", Int_t indent = 0) const
 Print containers info.
void SetPostEventLoop(Bool_t flag = kTRUE)
 Set the task execution mode - run after event loop or not. All output
 containers of this task will get the same type.
void GetBranches(const char* type, TString& result) const
 Get the list of branches for a given type (ESD, AOD). The list of branches
 requested by a task has to ve declared in the form:
   SetBranches("ESD:branch1,branch2,...,branchN AOD:branch1,branch2,...,branchM")
Int_t GetNinputs() const
{return fNinputs;}
Int_t GetNoutputs() const
{return fNoutputs;}
TObject * GetPublishedData() const
{return fPublishedData;}
AliAnalysisDataSlot * GetInputSlot(Int_t islot) const
{return (AliAnalysisDataSlot*)fInputs->At(islot);}
AliAnalysisDataSlot * GetOutputSlot(Int_t islot) const
{return (AliAnalysisDataSlot*)fOutputs->At(islot);}
Bool_t IsOutputReady(Int_t islot) const
{return fOutputReady[islot];}
Bool_t IsChecked() const
Bool_t IsPostEventLoop() const
Bool_t IsInitialized() const
{return fInitialized;}
Bool_t IsReady() const
{return fReady;}
Bool_t IsUsed() const
Bool_t IsZombie() const
Bool_t HasBranches() const
{return !fBranchNames.IsNull();}
void SetBranches(const char* names)
{fBranchNames = names;}
void SetChecked(Bool_t flag = kTRUE)
void SetZombie(Bool_t flag = kTRUE)
 Main task execution
IMPLEMENT THIS !!!
void Exec(Option_t* option)
Bool_t HasExecuted() const
 === OVERLOAD THIS IF YOU WANT TO DO SOMETHING WITH THE OUTPUT
{return fHasExecuted;}