9#include "KVDataAnalyser.h"
10#include "KVDataAnalysisTask.h"
11#include "KVDataSetManager.h"
16#include "KVBatchSystemManager.h"
69 if (gDataAnalyser ==
this)gDataAnalyser =
nullptr;
217 cout <<
"============> Warning <=============" << endl;
219 cout <<
"Analysis aborted." << endl;
220 cout <<
"====================================" << endl;
298 if (!curIncDir.
Contains(
id.Data())) {
299 cout <<
"Include path \"" <<
id.
Data() <<
"\" added." << endl;
334 while (!slib.
End() && !loaded) {
337 Info(
"SetUserLibraries",
"%s already load",
id.Data());
343 Info(
"SetUserLibraries",
"Library \"%s\"added.",
id.Data());
364 cout <<
"Give the number of events to read [<RET>=all]:" << endl;
375 Data() <<
"\" is not a number. Please retry." << endl;
413 cout <<
"Give the name of the analysis class derived from " <<
fTask->
GetUserBaseClass() <<
":" << endl;
579 Info(
"GetInstanceOfUserClass",
"Class %s is unknown and no source files available",
585 Info(
"GetInstanceOfUserClass",
"Compilation of class %s failed. Correct the mistakes and try again",
591 if (alternative_base_class ==
"") {
592 Info(
"GetInstanceOfUserClass",
"Class %s does not inherit from correct base class (%s), or compilation of class %s failed. Correct the mistakes and try again",
597 bool got_good_base =
false;
599 alternative_base_class.
Begin(
",");
600 while (!alternative_base_class.
End()) {
601 good_base = alternative_base_class.
Next(
kTRUE);
602 if (cl->GetBaseClass(good_base)) {
603 got_good_base =
true;
608 Info(
"GetInstanceOfUserClass",
"Class %s inherits from alternative base class %s: OK!",
611 Info(
"GetInstanceOfUserClass",
"Class %s does not inherit from task-defined base class (%s) or any provided alternative base classes (%s), or compilation of class %s failed. Correct the mistakes and try again",
620 Info(
"GetInstanceOfUserClass",
"Found plugin handler for class %s",
625 Info(
"GetInstanceOfUserClass",
"KVBase::LoadPlugin failed for %s",
fUserClass.
Data());
691 Warning(
"WriteBatchEnvFile",
"Source files for user class %s do not exist. Job will not work.",
739 if (!gDataSetManager) {
741 gDataSetManager->
Init();
745 Error(
"ReadBatchEnvFile",
"Name of analysis task not given");
749 Error(
"ReadBatchEnvFile",
"Analysis task \"%s\"not found for dataset %s",
760 if (strcmp(
fBatchEnv->GetValue(
"BatchSystem",
""),
"")) {
771 Error(
"ReadBatchEnvFile",
"Name of user class not given");
778 Error(
"ReadBatchEnvFile",
"Name of user class implementation file not given");
783 Error(
"ReadBatchEnvFile",
"Name of user class header file not given");
858 Info(
"SubmitTask",
"fTask->GetDataAnalyser()=%s", task_data_analyser.
Data());
859 unique_ptr<KVDataAnalyser> the_analyser;
860 if (task_data_analyser ==
"UserClass") {
866 if (!the_analyser.get())
867 Fatal(
"SubmitTask",
"the_analyser is 0x0, go to crash");
879 the_analyser->CheckTaskVariables();
888 gDataAnalyser = the_analyser.get();
927 static TString keywords =
"Will be expanded: $Date, $User, $UserClass";
1003 stats.
SetValue(
"TotalEvents", totev);
1004 stats.
SetValue(
"EventsRead", evread);
1005 disk.
Remove(TString::kTrailing,
'\t');
1006 disk.
Remove(TString::kTrailing,
' ');
1007 disk.
Remove(TString::kTrailing,
'\t');
1050 cout <<
" +++ " << nevents <<
" events processed +++ " << endl;
1053 cout <<
" ------------- Process infos -------------" << endl;
1054 printf(
" CpuSys = %f s. CpuUser = %f s. ResMem = %f MB VirtMem = %f MB\n",
1077 cout << endl <<
"Run in Interactive or Batch mode (I or B) ? : ";
1079 }
while (tmp !=
"i" && tmp !=
"I" && tmp !=
"b" && tmp !=
"B");
1086 cout << endl <<
"Choose the batch system to use : " << endl;
1087 gBatchSystemManager->
Print();
1089 cout <<
"(enter a number) : " << endl;
1107 if (*
ls)
delete(*ls);
1130 while ((
file = next_new_file())) {
1141 Info(
"CopyAnalysisResultsToLaunchDirectory",
"Copying analysis results file :\n%s ---> %s",
1145 Info(
"CopyAnalysisResultsToLaunchDirectory",
"File copied correctly");
1147 Info(
"CopyAnalysisResultsToLaunchDirectory",
" **** ERROR copying file !!! ");
1168 tt->GetUserInfo()->Add(
new TEnv());
1169 TEnv* kvenv = (
TEnv*)
tt->GetUserInfo()->FindObject(
"TEnv");
1185#ifdef WITH_BZR_INFOS
1186 kvenv->
SetValue(
"KVBase::bzrRevisionId()", KVBase::bzrRevisionId(),
kEnvUser);
1187 kvenv->
SetValue(
"KVBase::bzrRevisionDate()", KVBase::bzrRevisionDate(),
kEnvUser);
1188 kvenv->
SetValue(
"KVBase::bzrBranchNick()", KVBase::bzrBranchNick(),
kEnvUser);
1189 kvenv->
SetValue(
"KVBase::bzrRevisionNumber()", KVBase::bzrRevisionNumber());
1190 kvenv->
SetValue(
"KVBase::bzrIsBranchClean()", KVBase::bzrIsBranchClean());
1192#ifdef WITH_GIT_INFOS
1241 ::Warning(
"KVDataAnalyser::RunAnalyser",
"No plugin %s found for KVDataAnalyser",
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 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 Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
char * Form(const char *fmt,...)
void AssignAndDelete(TString &target, char *tobedeleted)
R__EXTERN TSystem * gSystem
static Bool_t FindClassSourceFiles(const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
static const Char_t * GetKVBuildDate()
Returns KaliVeda build date.
static const Char_t * gitCommit()
Returns last git commit of sources.
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
static const Char_t * gitBranch()
Returns git branch of sources.
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
virtual const Char_t * GetType() const
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
Handles list of all available batch systems for processing non-interactive data analysis tasks.
void Print(Option_t *opt="") const
KVBatchSystem * GetBatchSystem(const Char_t *name)
Get batch system by name.
virtual void SubmitTask(KVDataAnalyser *da)
virtual void WriteBatchEnvFile(TEnv *)
void cd()
Make this the default batch system.
virtual const Char_t * GetJobName() const
virtual void Print(Option_t *="") const
virtual void SetAnalyser(KVDataAnalyser *da)
virtual void ReadBatchEnvFile(TEnv *)
virtual void Clear(Option_t *opt="")
Manager class which sets up and runs data analysis tasks.
const Char_t * GetACliCMode()
KVString fUserClass
user's analysis class
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)
Bool_t fUseBaseClassSubmitTask
const Char_t * GetBatchName()
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
std::unique_ptr< TEnv > fBatchEnv
batch environment file
virtual void AddJobDescriptionList(TList *)
KVDataAnalyser * fParent
holds address of parent analyser which created this one
virtual void WriteBatchEnvFile(const TString &, Bool_t sav=kTRUE)
void ChooseNbEventToRead()
Ask user to set number of events to read.
Bool_t RunningInLaunchDirectory()
KVString fLibraries
user's libraries
void SetUserLibraries(const Char_t *libs=0)
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="")
virtual Bool_t NeedToChooseWhatToAnalyse() const
const Char_t * GetUserClass()
Bool_t fBatch
set to kTRUE when used in a non-interactive environment
TString GetPathToFileInLaunchDirectory(const TString &) const
KVDataAnalysisTask * GetAnalysisTask() const
void WriteBatchInfo(TTree *)
virtual void RunMenus()
Run data analyser in menu-driven mode.
virtual Bool_t CheckTaskVariables()
Bool_t DoUserClassFilesExist()
const Char_t * GetLaunchDirectory() const
void SetAnalysisTask(KVDataAnalysisTask *at)
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()
virtual void SubmitTask()
const Char_t * GetBatchStatusFileName() const
Returns full path to file used to store status of running batch jobs.
virtual void ChooseWhatToAnalyse()
TO IMPLEMENT ?
KVString fUserClassImp
user's analysis class implementation file
TList * fWorkDirInit
list of files in working directory before task runs
KVDataAnalyser()
Default constructor.
static Bool_t fCleanAbort
flag to force abort of processing
KVString fUserClassDec
user's analysis class header file
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()
Bool_t fMenus
set to kTRUE in menu-driven mode
virtual ~KVDataAnalyser()
Default destructor.
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
Long64_t GetNbEventToRead(void) const
void CopyAnalysisResultsToLaunchDirectory()
virtual Bool_t ReadBatchEnvFile(const TString &)
void DeleteBatchStatusFile() const
Delete batch status file (and backup - '.bak') for batch job.
void SetUserIncludes(const Char_t *incDirs=0)
virtual void ChooseWhatToDo()
TO IMPLEMENT ?
void OpenBatchInfoFile(const TString &filename)
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
Bool_t fChoseRunMode
set to kTRUE once running mode has been set/chosen
TObject * GetInstanceOfUserClass(const KVString &alternative_base_class="")
TEnv * GetBatchInfoFile() const
KVString fDataType
datatype chosen by user
KVDataAnalysisTask * fTask
task chosen by user
void SetNbEventToRead(Long64_t nb=0)
Define and manage data analysis tasks.
virtual Bool_t CheckUserBaseClassIsLoaded()
virtual const Char_t * GetDataAnalyser() const
virtual const Char_t * GetUserBaseClass() const
virtual Bool_t WithUserClass() const
virtual Long64_t GetStatusUpdateInterval() const
virtual const Char_t * GetPrereq() const
Manage all datasets contained in a given data repository.
virtual Bool_t Init(KVDataRepository *=0)
KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) const
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
const char * AsSQLString() const
THashList * GetTable() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
virtual void SaveLevel(EEnvLevel level)
TObject * FindObject(const char *name) const override
TObject * At(Int_t idx) const override
const char * GetName() const override
const TString & GetString() const
virtual const char * GetName() const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Fatal(const char *method, const char *msgfmt,...) const
virtual void ls(Option_t *option="") const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
std::istream & ReadToDelim(std::istream &str, char delim='\n')
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
virtual TList * GetListOfFiles() const
virtual const char * GetBuildNode() const
virtual const char * GetBuildCompilerVersion() const
virtual const char * GetBuildDir() const
virtual void AddIncludePath(const char *includePath)
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
virtual const char * Getenv(const char *env)
virtual const char * GetIncludePath()
virtual char * ConcatFileName(const char *dir, const char *name)
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual int GetProcInfo(ProcInfo_t *info) const
virtual const char * HostName()
virtual const char * WorkingDirectory()
virtual const char * GetBuildCompiler() const
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
virtual const char * GetBuildArch() const
virtual int Unlink(const char *name)