KaliVeda
Toolkit for HIC analysis
KVDataAnalyser.h
1 /*
2 $Id: KVDataAnalyser.h,v 1.18 2009/04/01 09:28:34 franklan Exp $
3 $Revision: 1.18 $
4 $Date: 2009/04/01 09:28:34 $
5 $Author: franklan $
6 */
7 
8 #ifndef __KVDATAANALYSER_H
9 #define __KVDATAANALYSER_H
10 
11 #include "TObject.h"
12 #include "TTree.h"
13 #include "KVList.h"
14 #include "KVBatchSystem.h"
15 #include "KVString.h"
16 #include "KVNumberList.h"
17 #include "TEnv.h"
18 #include "KV2Body.h"
19 #include "KVDBSystem.h"
20 #include "KVDBRun.h"
21 class KVDataAnalysisTask;
22 
61 class KVDataAnalyser : public TObject {
62 
63 private:
69 
73 
82 
84 
85  std::unique_ptr<TEnv> fBatchEnv;
88 
92 
94 
95 protected:
99 
100  virtual Bool_t CheckIfUserClassIsValid(const KVString& alternative_base_class = "");
101  TObject* GetInstanceOfUserClass(const KVString& alternative_base_class = "");
102 
103  const Char_t* GetACliCMode();
104 
105  void OpenBatchInfoFile(const TString& filename)
106  {
110 
111  if (!fBatchEnv || filename != fBatchEnv->GetRcName()) {
112  fBatchEnv.reset(new TEnv(filename));
113  }
114  }
116  {
117  return fBatchEnv.get();
118  }
120  {
121  return kTRUE;
122  }
123  virtual void PostRunReset();
124  virtual Bool_t NeedToChooseWhatToDo() const
125  {
126  return !GetAnalysisTask();
127  }
129  {
130  AbstractMethod("NeedToChooseWhatToAnalyse");
131  return kTRUE;
132  }
133  virtual void ChooseWhatToAnalyse();
134  virtual void ChooseWhatToDo();
136 
137  virtual void set_up_analyser_for_task(KVDataAnalyser* the_analyser);
138 
139 public:
140  enum EProofMode {
143  Proof
144  };
145 private:
147 public:
149  {
150  fProofMode = e;
151  }
153  {
154  return fProofMode;
155  }
156 
157  static void SetAbortProcessingLoop(Bool_t now = kTRUE)
158  {
160  fCleanAbort = now;
161  }
163  {
164  return fCleanAbort;
165  }
166 
167  KVDataAnalyser();
168  virtual ~ KVDataAnalyser();
169 
170  void SetUserClass(const Char_t* kvs, Bool_t check = kTRUE);
172  {
173  return fUserClass.Data();
174  }
176  {
177  return fUserClassIsOK;
178  }
179 
181  {
182  return 0;
183  }
184 
185  virtual void Run();
186  virtual void RunMenus();
187  void ChooseUserClass();
188  void ChooseRunningMode();
189  virtual void SubmitTask();
190  virtual Bool_t CheckTaskVariables();
192 
193  void SetBatchMode(Bool_t on = kTRUE)
194  {
195  fBatch = on;
196  }
198  {
199  return fBatch;
200  }
201  void SetBatchName(const Char_t* batchname)
202  {
203  fBatchName = batchname;
204  }
206  {
207  return fBatchName.Data();
208  }
210  {
211  fBatchSystem = bs;
213  if (bs) fBatchSystem->cd();
214  }
215  virtual const KVBatchSystem* GetBatchSystem()
216  {
217  return fBatchSystem;
218  }
220 
221  const Char_t* GetLaunchDirectory() const;
223  const Char_t* GetBatchStatusFileName() const;
224  void UpdateBatchStatusFile(Int_t totev, Int_t evread, TString disk) const;
225  void DeleteBatchStatusFile() const;
227  {
228  return 0;
229  }
230  virtual Bool_t CheckStatusUpdateInterval(Long64_t nevents) const;
231  void SetStatusUpdateInterval(double t)
232  {
234  }
236  {
237  return fStatusUpdateInterval;
238  }
239 
240  void DoStatusUpdate(Long64_t nevents) const;
241 
243  {
244  return fTask;
245  }
246  const KVString& GetDataType() const
247  {
248  return fDataType;
249  }
250  const KVString& GetUserIncludes() const
251  {
252  return fIncludes;
253  }
254  const KVString& GetUserLibraries() const
255  {
256  return fLibraries;
257  }
258  virtual void SetFileList(TList*)
259  {
260  AbstractMethod("SetFileList(TList*)");
261  }
262  virtual void SetAuxFileList(TList*)
263  {
264  AbstractMethod("SetAuxFileList(TList*)");
265  }
266 
268  {
269  nbEventToRead = nb;
270  }
271 
273  {
274  return nbEventToRead;
275  }
276 
277  void ChooseNbEventToRead();
279  void SetDataType(const Char_t* name)
280  {
281  fDataType = name;
282  }
283 
284  void SetUserIncludes(const Char_t* incDirs = 0);
285  void SetUserLibraries(const Char_t* libs = 0);
286 
287  virtual void Reset();
288 
290  {
291  fParent = da;
292  }
294  {
295  return fParent;
296  }
297 
298  const KVString& GetUserClassImp() const
299  {
300  return fUserClassImp;
301  }
302  const KVString& GetUserClassDec() const
303  {
304  return fUserClassDec;
305  }
306 
307  static KVDataAnalyser* GetAnalyser(const Char_t* plugin);
308  virtual Bool_t ReadBatchEnvFile(const TString&);
309  virtual void WriteBatchEnvFile(const TString&, Bool_t sav = kTRUE);
310 
311  virtual TString ExpandAutoBatchName(const Char_t* format) const;
312 
313  /* methods which can be used to customise analysis class behaviour.
314  they can be called from the analysis class using the global
315  pointer to the current data analyser, gDataAnalyser */
316  virtual void preInitAnalysis() {}
317  virtual void postInitAnalysis() {}
318  virtual void preInitRun() {}
319  virtual void postInitRun() {}
320  virtual void preAnalysis() {}
321  virtual void postAnalysis() {}
322  virtual void preEndRun() {}
323  virtual void postEndRun() {}
324  virtual void preEndAnalysis() {}
325  virtual void postEndAnalysis() {}
326 
327  void WriteBatchInfo(TTree*);
328 
329  virtual void RegisterUserClass(TObject*) {}
330 
331  void SetUserClassOptions(const Char_t* o = "")
332  {
333  fUserClassOptions = o;
334  }
336  {
337  return fUserClassOptions;
338  }
339 
340  static void RunAnalyser(const Char_t* plugin = "");
341 
343 
344  virtual void AddJobDescriptionList(TList*);
345 
346  void SetMenus(Bool_t on = kTRUE)
347  {
348  fMenus = on;
349  }
350  Bool_t IsMenus() const
351  {
352  return fMenus;
353  }
354  void SetQuit(Bool_t yes = kTRUE)
355  {
356  fQuit = yes;
357  }
358  Bool_t IsQuit() const
359  {
360  return fQuit;
361  }
362  void SetSubmit(Bool_t yes = kTRUE)
363  {
364  fSubmit = yes;
365  }
366  Bool_t IsSubmit() const
367  {
368  return fSubmit;
369  }
371  {
372  AbstractMethod("GetRootDirectoryOfDataToAnalyse");
373  return "";
374  }
375  virtual const Char_t* GetRecognisedAutoBatchNameKeywords() const;
377  {
379  }
383  virtual const KV2Body* GetKinematics() const
384  {
385  return nullptr;
386  }
387  virtual KVDBSystem* GetAnalysedSystem() const
388  {
389  return nullptr;
390  }
391  virtual KVDBRun* GetAnalysedRun() const
392  {
393  return nullptr;
394  }
395  virtual void SetTriggerConditionsForRun(int) {}
396 
397  virtual void SetAnalysedTree(TTree*) {}
398  virtual TTree* GetAnalysedTree() const
399  {
404 
405  return nullptr;
406  }
407 
408  ClassDef(KVDataAnalyser, 0) //For submitting & performing data analysis tasks
409 };
410 
412 R__EXTERN KVDataAnalyser* gDataAnalyser;
413 
414 #endif
int Int_t
#define R__EXTERN
#define e(i)
bool Bool_t
char Char_t
double Double_t
constexpr Bool_t kTRUE
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Relativistic binary kinematics calculator.
Definition: KV2Body.h:166
Base class for interface to a batch job management system.
Definition: KVBatchSystem.h:78
void cd()
Make this the default batch system.
Description of an experimental run in database ,,.
Definition: KVDBRun.h:36
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
Manager class which sets up and runs data analysis tasks.
virtual void SetTriggerConditionsForRun(int)
virtual void SetAnalysedTree(TTree *)
const Char_t * GetACliCMode()
virtual void postEndRun()
virtual TTree * GetAnalysedTree() const
Bool_t IsMenus() const
Double_t GetStatusUpdateInterval() const
virtual KVDBRun * GetAnalysedRun() const
KVString fUserClass
user's analysis class
void UseBaseClassSubmitTask()
void DoStatusUpdate(Long64_t nevents) const
Print infos on events treated, disk usage, memory usage.
virtual TString ExpandAutoBatchName(const Char_t *format) const
void SetParent(KVDataAnalyser *da)
const KVString & GetUserLibraries() const
Bool_t fUseBaseClassSubmitTask
Long64_t nbEventToRead
virtual void PostRunReset()
virtual void Run()
Check all task variables, then run analyser.
Bool_t fSubmit
set to kTRUE when user wants to submit task
virtual void Reset()
virtual void SetAuxFileList(TList *)
std::unique_ptr< TEnv > fBatchEnv
batch environment file
virtual void AddJobDescriptionList(TList *)
KVDataAnalyser * fParent
holds address of parent analyser which created this one
const KVString & GetUserClassImp() const
virtual void WriteBatchEnvFile(const TString &, Bool_t sav=kTRUE)
void SetBatchSystem(KVBatchSystem *bs)
void ChooseNbEventToRead()
Ask user to set number of events to read.
virtual void preInitAnalysis()
void SetUserClassOptions(const Char_t *o="")
Bool_t RunningInLaunchDirectory()
virtual const KVBatchSystem * GetBatchSystem()
KVString fLibraries
user's libraries
virtual void postAnalysis()
void SetBatchMode(Bool_t on=kTRUE)
virtual ~ KVDataAnalyser()
const KVString & GetDataType() const
void SetUserLibraries(const Char_t *libs=0)
static void SetAbortProcessingLoop(Bool_t now=kTRUE)
KVString fUserClassOptions
options to be passed to user analysis class
void SetUserClass(const Char_t *kvs, Bool_t check=kTRUE)
virtual Bool_t CheckIfUserClassIsValid(const KVString &alternative_base_class="")
KVDataAnalyser * GetParent() const
virtual Bool_t NeedToChooseWhatToAnalyse() const
Bool_t fBatch
set to kTRUE when used in a non-interactive environment
void SetBatchName(const Char_t *batchname)
TString GetPathToFileInLaunchDirectory(const TString &) const
void WriteBatchInfo(TTree *)
virtual const KV2Body * GetKinematics() const
virtual void RunMenus()
Run data analyser in menu-driven mode.
virtual Bool_t CheckTaskVariables()
void SetSubmit(Bool_t yes=kTRUE)
Bool_t DoUserClassFilesExist()
const Char_t * GetBatchName()
const Char_t * GetLaunchDirectory() const
EProofMode fProofMode
void SetAnalysisTask(KVDataAnalysisTask *at)
KVString fBatchName
name of batch job when used in a non-interactive environment
void SetProofMode(EProofMode e)
const KVString & GetUserIncludes() const
Bool_t fUserClassIsOK
set once user class has been validated
virtual const Char_t * GetRecognisedAutoBatchNameKeywords() const
virtual void set_up_analyser_for_task(KVDataAnalyser *the_analyser)
virtual Bool_t NeedToChooseWhatToDo() const
virtual Bool_t CheckStatusUpdateInterval(Long64_t nevents) const
virtual Bool_t CheckWhatToAnalyseAndHow()
void SetQuit(Bool_t yes=kTRUE)
virtual void SubmitTask()
const Char_t * GetBatchStatusFileName() const
Returns full path to file used to store status of running batch jobs.
virtual void preAnalysis()
virtual void SetFileList(TList *)
virtual void ChooseWhatToAnalyse()
TO IMPLEMENT ?
KVString fUserClassImp
user's analysis class implementation file
TList * fWorkDirInit
list of files in working directory before task runs
virtual Long64_t GetTotalEntriesToRead() const
KVDataAnalyser()
Default constructor.
virtual Int_t GetNumberOfFilesToAnalyse() const
static Bool_t fCleanAbort
flag to force abort of processing
KVString fUserClassDec
user's analysis class header file
const KVString & GetUserClassOptions() const
const Char_t * GetUserClass()
virtual Bool_t PreSubmitCheck()
static KVDataAnalyser * GetAnalyser(const Char_t *plugin)
KVString fIncludes
user's include directories
Bool_t fQuit
set to kTRUE when user wants to quit
EProofMode GetProofMode() const
static Bool_t IsRunningBatchAnalysis()
void SetDataType(const Char_t *name)
virtual KVString GetRootDirectoryOfDataToAnalyse() const
Bool_t fMenus
set to kTRUE in menu-driven mode
virtual void preEndRun()
virtual void postInitRun()
KVString fUserClassAlternativeBaseClass
alternative base class for user's analysis class
static void RunAnalyser(const Char_t *plugin="")
void ScanWorkingDirectory(TList **)
void ChooseUserClass()
Choose the user's analysis class.
TList * fWorkDirEnd
list of files in working directory after task runs
static Bool_t AbortProcessingLoop()
Long64_t GetNbEventToRead(void) const
virtual void postEndAnalysis()
virtual void preEndAnalysis()
void SetMenus(Bool_t on=kTRUE)
const KVString & GetUserClassDec() const
void CopyAnalysisResultsToLaunchDirectory()
virtual Bool_t ReadBatchEnvFile(const TString &)
void DeleteBatchStatusFile() const
Delete batch status file (and backup - '.bak') for batch job.
void SetStatusUpdateInterval(double t)
virtual void preInitRun()
virtual void RegisterUserClass(TObject *)
void SetUserIncludes(const Char_t *incDirs=0)
virtual void ChooseWhatToDo()
TO IMPLEMENT ?
Bool_t IsUserClassValid() const
KVDataAnalysisTask * GetAnalysisTask() const
Bool_t BatchMode() const
virtual void postInitAnalysis()
void OpenBatchInfoFile(const TString &filename)
virtual KVDBSystem * GetAnalysedSystem() const
Bool_t IsSubmit() const
void UpdateBatchStatusFile(Int_t totev, Int_t evread, TString disk) const
Update infos in batch status file.
KVBatchSystem * fBatchSystem
batch system to use for submission of job
TEnv * GetBatchInfoFile() const
Bool_t IsQuit() const
Bool_t fChoseRunMode
set to kTRUE once running mode has been set/chosen
TObject * GetInstanceOfUserClass(const KVString &alternative_base_class="")
KVString fDataType
datatype chosen by user
KVDataAnalysisTask * fTask
task chosen by user
Double_t fStatusUpdateInterval
void SetNbEventToRead(Long64_t nb=0)
Define and manage data analysis tasks.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void AbstractMethod(const char *method) const
const char * Data() const
long long Long64_t