NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcJob Class Reference

Base class for top level job in a task based procedure. More...

#include "NcJob.h"

Inheritance diagram for NcJob:
IceCal2Root IceDB2Root IceF2k IceRawTWR IceRoot IceRootx RnoConvert

Detailed Description

Base class for top level job in a task based procedure.


Copyright(c) 2005 NCFS/IIHE, All Rights Reserved. *
*
Authors: The Netherlands Center for Fundamental Studies (NCFS). *
The Inter-university Institute for High Energies (IIHE). *
Website : http://www.iihe.ac.be *
Contact : Nick van Eijndhoven (nickve.nl@gmail.com) *
*
Contributors are mentioned in the code where appropriate. *
*
No part of this software may be used, copied, modified or distributed *
by any means nor transmitted or translated into machine language for *
commercial purposes without written permission by the IIHE representative. *
Permission to use the software strictly for non-commercial purposes *
is hereby granted without fee, provided that the above copyright notice *
appears in all copies and that both the copyright notice and this *
permission notice appear in the supporting documentation. *
This software is provided "as is" without express or implied warranty. *
The authors make no claims that this software is free of error, or is *
consistent with any particular standard of merchantability, or that it *
will meet your requirements for any particular application, other than *
indicated in the corresponding documentation. *
This software should not be relied on for solving a problem whose *
incorrect solution could result in injury to a person or loss of property. *
If you do use this software in such a manner, it is at your own risk. *
The authors disclaim all liability for direct or consequential damage *
resulting from your use of this software. *

// Class NcJob
// Base class for the top level processor class in a task based procedure.
// It allows stepwise invokation of various sub-tasks by the derived
// (user defined) top level processor, based on looping over a certain
// main object structure (e.g. NcEvent for event-by-event processing).
// The main object structure (if needed) may be specified by the derived
// top level processor class and will be stored automatically in the
// working environment (see below).
//
// However, being designed as a base class for a user defined top level
// processor, this class can also be used as a "hook" to specify
// various sub-tasks in an (interactive) user environment.
// Usage of the memberfunction ProcessObject() allows an (interactive)
// event-by-event processing of the various specified subtasks.
//
// This base class provides a working environment for the derived
// (user defined) processor class and all of its subtasks.
//
// The default working environment consists of :
//
// * An array containing pointers to the objects which are stored
// via the AddObject() facility of this NcJob class.
// From this storage the objects can be directly accessed via the
// GetObject() and GetObjects() memberfunctions.
// * A pointer to the main object structure during job processing.
// This pointer can be initiated/updated only by the derived top level
// processor via the SetMainObject() facility but all sub-tasks can access
// it via the above array facilities or the GetMainObject() memberfunction.
// The latter provides faster access to the main object structure than
// the GetObject (search) based procedures.
//
// Optionally one may invoke the MakeFolder() memberfunction or use the
// "mode" argument of ExecuteJob (see below) to provide in addition to the above
// the following job-specific folder structure :
//
// * A folder which may serve as a whiteboard for transferring pointers to
// objects which are posted there by the top level processor or any
// of its subtasks.
// Objects can be posted in the job folder via the AddObject() facility
// of this NcJob class.
// Access to the job folder is obtained via the GetFolder() memberfunction
// and from this the various objects can be accessed via the usual TFolder
// FindObject and/or iterator facilities.
//
// Notes :
// -------
// 1) This NcJob class is derived from TTask, which implies that every
// (user defined) top level processor class is itself also a TTask.
// This allows sub-tasks to be introduced to the top level processor
// using the standard TTask facilities.
//
// 2) Only references to the various introduced objects are stored.
// It is the user's responsibility to delete all introduced objects,
// either in the Exec() or destructor of the derived top level processor class
// or via Clear() facility as provided by the TTask machinery.
//
// 3) The top level processor instance is entered into the standard ROOT
// ListOfTasks under the name which was provided by the user in the
// constructor of the top level processor.
// The name of the top level processor is passed automatically as the
// opt argument to the Exec(Option_t* opt) memberfunctions of the
// various sub-tasks by the ExecuteJob() memberfunction (see below).
// This allows all sub-tasks to obtain the pointer to the top level
// processor instance from its name via the statement :
//
// NcJob* parent=(NcJob*)gROOT->GetListOfTasks()->FindObject(opt)
//
// 4) If selected, the job-specific folder will be created in the generic folder
// called "NcJob-folders" as a sub-folder under the same name as the one
// introduced in the constructor of the derived top level processor class.
// The folder will only be created if the MakeFolder() member function has been
// invoked or when selected explicitly by the "mode" argument of ExecuteJob().
// Actual creation of the folder environment (and internal array storage as well)
// only takes place when the first object is posted via the AddObject()
// or SetMainObject() facilities.
//
// Execution of the (user defined) top level processor has to be invoked via
// the memberfunction ExecuteJob() of this NcJob base class.
// This will set the default gROOT as the global working directory and then
// invoke the (user written) Exec() memberfunction of the top level
// processor class with as argument the name of the top level processor instance
// as specified by the user in the top level processor constructor.
// This will allow stepwise (e.g. event-by-event) execution of the various sub-tasks.
// In addition the "mode" argument of ExecuteJob() may be used to select/overrule
// creation of the folder environment for the complete job.
// See the docs of ExecuteJob() for further details.
//
// It is the user's responsibility to invoke the sub-tasks via the
// ExecuteTasks() statement at the appropriate location in the top level
// processor class if auto-execution was not explicitly selected via the
// "mode" argument of the ExecuteJob() memberfunction.
//
//--- Author: Nick van Eijndhoven 07-may-2005 Utrecht University
//- Modified: Nick van Eijndhoven, IIHE-VUB, Brussel, January 7, 2022 11:39Z

Definition at line 17 of file NcJob.h.

Public Member Functions

 NcJob (const char *name="NcJob", const char *title="")
 
virtual ~NcJob ()
 
void AddObject (TObject *obj)
 
void AddObjects (TObjArray *arr)
 
void ExecuteJob (Int_t mode=0)
 
TFolder * GetFolder () const
 
TObject * GetMainObject () const
 
TObject * GetObject (const char *classname) const
 
TObject * GetObject (Int_t j) const
 
TObjArray * GetObjects () const
 
TObjArray * GetObjects (const char *classname)
 
void ListEnvironment ()
 
void MakeFolder ()
 
void ProcessObject (TObject *obj)
 
void RemoveObject (TObject *obj)
 
void RemoveObjects (const char *classname)
 

Protected Member Functions

void SetMainObject (TObject *obj)
 

Protected Attributes

TFolder * fFolder
 
TObject * fMainObject
 
Int_t fMakefolder
 
TObjArray * fObjects
 
TObjArray * fSelect
 ! Temp. array of pointers to user-selected stored objects
 

Constructor & Destructor Documentation

◆ NcJob()

NcJob::NcJob ( const char * name = "NcJob",
const char * title = "" )
// Default constructor.
// Initialise the working environment for general data access
// by the derived task and its subtasks.

Definition at line 139 of file NcJob.cxx.

◆ ~NcJob()

NcJob::~NcJob ( )
virtual
// Default destructor.
// The internal array and job specific folder (if any) holding the various
// references are deleted.
// Note : The objects belonging to the various pointers in the array/folder
// and the main processing object are NOT deleted by this base class.

Definition at line 163 of file NcJob.cxx.

Member Function Documentation

◆ AddObject()

void NcJob::AddObject ( TObject * obj)
// Store pointer of specified object in the working environment.

Definition at line 320 of file NcJob.cxx.

◆ AddObjects()

void NcJob::AddObjects ( TObjArray * arr)
// Store pointers of all the array objects individually in the working environment.

Definition at line 366 of file NcJob.cxx.

◆ ExecuteJob()

void NcJob::ExecuteJob ( Int_t mode = 0)
// Invokation of the top level processor via its Exec() memberfunction.
// The input argument "mode" can be used to explicitly specify the
// (de)selection of the folder environment creation and automatic
// invokation of all subtasks after execution of the top level
// Exec() memberfunction.
// The latter is convenient if an NcJob instance is used directly
// by the user (e.g. in a ROOT macro) in order to provide a hook
// for event-by-event processing of various subtasks.
// An even more convenient alternative to achieve this is invokation of the
// memberfunction ProcessObject().
//
// mode = -1 : Explicitly prohibit folder creation for the complete job
// 0 : Folder creation selection steered by MakeFolder()
// 1 : Explicitly select creation of the folder environment
// for the complete job.
// -11 : Same as mode=-1 but also auto-execution of subtasks after Exec()
// 10 : Same as mode=0 but also auto-execution of subtasks after Exec()
// 11 : Same as mode=1 but also auto-execution of subtasks after Exec()
//
// The default is mode=0.
//
// Note : Before execution gROOT is set as the global working directory.

Definition at line 226 of file NcJob.cxx.

◆ GetFolder()

TFolder * NcJob::GetFolder ( ) const
// Provide pointer to the whiteboard folder.

Definition at line 283 of file NcJob.cxx.

◆ GetMainObject()

TObject * NcJob::GetMainObject ( ) const
// Provide pointer to the main object structure.

Definition at line 294 of file NcJob.cxx.

◆ GetObject() [1/2]

TObject * NcJob::GetObject ( const char * classname) const
// Provide pointer to the first stored object which inherits from classname.

Definition at line 456 of file NcJob.cxx.

◆ GetObject() [2/2]

TObject * NcJob::GetObject ( Int_t j) const
// Provide pointer to j-th stored object.
// Note : j=1 indicates the first object.

Definition at line 439 of file NcJob.cxx.

◆ GetObjects() [1/2]

TObjArray * NcJob::GetObjects ( ) const
// Provide pointers of all the stored objects.

Definition at line 479 of file NcJob.cxx.

◆ GetObjects() [2/2]

TObjArray * NcJob::GetObjects ( const char * classname)
// Provide pointers to all stored objects inheriting from classname.

Definition at line 490 of file NcJob.cxx.

◆ ListEnvironment()

void NcJob::ListEnvironment ( )
// Provide listing of the job environment.

Definition at line 205 of file NcJob.cxx.

◆ MakeFolder()

void NcJob::MakeFolder ( )
// Select creation of the folder structure in addition to the internal
// array storage of objects.
// Creation of the folder structure is only activated if it was not
// explicitly forbidden by the specified "mode" on invokation of the
// ExecuteJob() memberfunction.

Definition at line 268 of file NcJob.cxx.

◆ ProcessObject()

void NcJob::ProcessObject ( TObject * obj)
// Invokation of all user defined sub-tasks for the specified object.
// This facility is very convenient when performing a task based
// event-by-event analysis in an (interactive) user application.
//
// Note :
// ------
// Before processing gROOT is set as the global working directory.
// The specified object will be added to the job's object list
// as main object before the processing starts.
// This will allow the various sub-tasks to access the object in the
// usual way.
// After the processing of this object has been performed, the object
// will be removed from the object list and the main object pointer will
// be set to zero.

Definition at line 517 of file NcJob.cxx.

◆ RemoveObject()

void NcJob::RemoveObject ( TObject * obj)
// Remove pointer of specified object from the working environment.
// In case the specified object is also the main object, the main object
// pointer will be set to 0 as well.

Definition at line 384 of file NcJob.cxx.

◆ RemoveObjects()

void NcJob::RemoveObjects ( const char * classname)
// Remove all stored objects inheriting from classname.
// In case one of the removed objects is also the main object, the main object
// pointer will be set to 0 as well.

Definition at line 409 of file NcJob.cxx.

◆ SetMainObject()

void NcJob::SetMainObject ( TObject * obj)
protected
// Store pointer to the main object structure.

Definition at line 305 of file NcJob.cxx.

Member Data Documentation

◆ fFolder

TFolder* NcJob::fFolder
protected

Definition at line 39 of file NcJob.h.

◆ fMainObject

TObject* NcJob::fMainObject
protected

Definition at line 40 of file NcJob.h.

◆ fMakefolder

Int_t NcJob::fMakefolder
protected

Definition at line 38 of file NcJob.h.

◆ fObjects

TObjArray* NcJob::fObjects
protected

Definition at line 41 of file NcJob.h.

◆ fSelect

TObjArray* NcJob::fSelect
protected

! Temp. array of pointers to user-selected stored objects

Definition at line 42 of file NcJob.h.


The documentation for this class was generated from the following files: