// main object structure (e.g. AliEvent 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).
+// 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 latter provides faster access to the main object structure than
// the GetObject (search) based procedures.
//
-// Optionally one may invoke the MakeFolder() memberfunction to provide
-// in addition to the above the following job-specific folder structure :
+// 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
// called "AliJob-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 explicitly and when the first object is posted via the AddObject()
+// 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
// 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.
+// 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: NvE $Date$ Utrecht University
// Note : The objects belonging to the various pointers in the array/folder
// and the main processing object are NOT deleted by this base class.
+ // Remove this AliJob based instance into the ROOT task list
+ TSeqCollection* tasks=gROOT->GetListOfTasks();
+ if (tasks) tasks->Remove(this);
+
if (fObjects)
{
delete fObjects;
cout << endl;
}
///////////////////////////////////////////////////////////////////////////
-void AliJob::ExecuteJob()
+void AliJob::ExecuteJob(Int_t mode)
{
// 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 AliJob 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.
+
+ if (mode<0) fMakefolder=-1;
+ if (mode==1 || mode==11) fMakefolder=1;
+
gROOT->cd();
Exec(GetName());
+
+ if (abs(mode)>9)
+ {
+ CleanTasks();
+ ExecuteTasks(GetName());
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliJob::MakeFolder()
{
// Select creation of the folder structure in addition to the internal
// array storage of objects.
- fMakefolder=1;
+// Creation of the folder structure is only activated if it was not
+// explicitly forbidden by the specified "mode" on invokation of the
+// ExecuteJob() memberfunction.
+
+ if (!fMakefolder) fMakefolder=1;
}
///////////////////////////////////////////////////////////////////////////
TFolder* AliJob::GetFolder() const
if (!fObjects) fObjects=new TObjArray();
- if (fMakefolder && !fFolder)
+ if (fMakefolder>0 && !fFolder)
{
// Create the top level environment folder for all AliJobs if needed
TList* list=gROOT->GetListOfBrowsables();
return fSelect;
}
///////////////////////////////////////////////////////////////////////////
+void AliJob::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.
+
+ if (!obj) return;
+
+ SetMainObject(obj);
+
+ gROOT->cd();
+ CleanTasks();
+ ExecuteTasks(GetName());
+
+ RemoveObject(obj);
+}
+///////////////////////////////////////////////////////////////////////////