KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVDataAnalysisTask.cpp
1/*
2$Id: KVDataAnalysisTask.cpp,v 1.10 2009/01/14 16:01:38 franklan Exp $
3$Revision: 1.10 $
4$Date: 2009/01/14 16:01:38 $
5$Author: franklan $
6*/
7
8#include "KVDataAnalysisTask.h"
9#include "TSystem.h"
10#include "Riostream.h"
11#include "TObjString.h"
12#include "TClass.h"
13#include "TPluginManager.h"
14
15using namespace std;
16
18
19
20
22
24{
25 //Default ctor.
26 fUserClass = kFALSE;
27 fBaseIsPlugin = kFALSE;
28 fStatusUpdateInterval = 1000;
29}
30
31
32
35
37{
38 //Copy ctor
39#if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
40 obj.Copy(*this);
41#else
42 ((KVDataAnalysisTask&) obj).Copy(*this);
43#endif
44}
45
46
47#if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
48
52
54#else
56#endif
57{
58 //Copy this to obj
59 //Redefinition of KVBase::Copy
60
61 KVBase::Copy(obj);
62 ((KVDataAnalysisTask&) obj).fPrereq = fPrereq;
63 ((KVDataAnalysisTask&) obj).fAnalyser = fAnalyser;
64 ((KVDataAnalysisTask&) obj).fBaseClass = fBaseClass;
65 ((KVDataAnalysisTask&) obj).fUserClass = fUserClass;
66 ((KVDataAnalysisTask&) obj).fBaseIsPlugin = fBaseIsPlugin;
67 ((KVDataAnalysisTask&) obj).fPluginBase = fPluginBase;
68 ((KVDataAnalysisTask&) obj).fPluginURI = fPluginURI;
69 ((KVDataAnalysisTask&) obj).fExtraAClicIncludes = fExtraAClicIncludes;
70 ((KVDataAnalysisTask&) obj).fStatusUpdateInterval = fStatusUpdateInterval;
71}
72
73
74
76
80
81
82
85
87{
88 //Print analysis task information
89 cout << "KVDataAnalysisTask : ";
90 cout << GetName() << " : ";
91 cout << GetTitle();
92 cout << " (pre-req = " << GetPrereq();
93 cout << ", analyser = " << GetDataAnalyser();
94 if (fUserClass) cout << ", base class for user analysis = " << GetUserBaseClass();
95 else if (fBaseClass != "") cout << ", default class for analysis = " << GetUserBaseClass();
96 cout << ")" << endl;
97}
98
99
100
127
129{
130 // Set the class from which user's analysis class must derive.
131 // This is normally read in from the following environment variable:
132 //
133 // TaskName.DataAnalysisTask.UserClass.Base: [base_name]
134 //
135 // If base_name is not the name of a known (i.e. currently contained in the ROOT
136 // dictionary class table) class, it is assumed to be the uri of a plugin class.
137 // By default, we assume that the plugin extends the KVDataAnalyser class, but
138 // this can be changed using the following syntax:
139 //
140 // TaskName.DataAnalysisTask.UserClass.Base: [uri]/[base class]
141 //
142 // Example 1:
143 // The user analysis class for task "RawAnalysis" must derive from class
144 // KVIVRawDataAnalyser which is defined in library libVAMOS.so (not loaded by default):
145 //
146 // RawAnalysis.DataAnalysisTask.UserClass.Base: IVRawDataAnalyser
147 // +Plugin.KVDataAnalyser: IVRawDataAnalyser KVIVRawDataAnalyser VAMOS "KVIVRawDataAnalyser()"
148 //
149 // Example 2:
150 // The user analysis class for task "ReconIdent" must derive from class
151 // KVIVReconIdent (itself derived from TSelector) which is defined in library libVAMOS.so (not loaded by default):
152 //
153 // ReconIdent.DataAnalysisTask.UserClass.Base: IVReconIdent/TSelector
154 // +Plugin.TSelector: IVReconIdent KVIVReconIdent VAMOS "KVIVReconIdent()"
155
156 fBaseClass = base_name;
157 if (fBaseClass != "" && !TClass::GetClass(base_name)) {
158 // Base class is not in dictionary. Assume that base_name is a plugin.
160 KVString _base(base_name);
161 TObjArray* toks = _base.Tokenize("/");
162 if (toks->GetEntries() > 1) {
163 // base_name = uri/base
164 fPluginURI = ((TObjString*)toks->At(0))->String();
165 fPluginBase = ((TObjString*)toks->At(1))->String();
166 }
167 else {
168 // base_name = uri. default plugin base class is KVDataAnalyser
169 fPluginURI = base_name;
170 fPluginBase = "KVDataAnalyser";
171 }
172 delete toks;
173 // check plugin exists
175 if (!ph) {
176 Error("SetUserBaseClass", "Analysis task=%s :\nNo plugin found with URI=%s for base class %s",
178 return;
179 }
180 // get name of plugin base class that user's analysis must derive from
181 fBaseClass = ph->GetClass();
182 if (gDebug > 1) Info("SetUserBaseClass", "Analysis task=%s :\nUser analysis class derives from %s, extension of %s in plugin %s",
184 }
185}
186
187
188
195
197{
198 // This method checks that the base class for the user's analysis class is loaded.
199 // If this base class requires a plugin library to be loaded, it will be loaded.
200 // First we add any required extra ACliC include paths (taken from DataAnalysisTask.UserClass.ExtraACliCIncludes)
201 // If all is OK, returns kTRUE.
202 // Returns kFALSE if plugin cannot be loaded or class is simply unknown
203
204 if (fExtraAClicIncludes != "") {
206 Info("CheckUserBaseClassIsLoaded", "Added ACliC include path: %s", fExtraAClicIncludes.Data());
207 }
208 TClass* cl = TClass::GetClass(fBaseClass.Data()); // class in dictionary already ?
209 if (cl) return kTRUE;
210 if (fBaseIsPlugin) {
211 // base class is in a plugin library. load it now.
213 if (ph) return kTRUE;
214 Error("CheckUserBaseClassIsLoaded", "Analysis task=%s : Failed to load plugin class=%s base=%s uri=%s",
216 }
217 else {
218 Error("CheckUserBaseClassIsLoaded", "Analysis task=%s : User analysis base class %s is unknown",
219 GetName(), fBaseClass.Data());
220 }
221 return kFALSE;
222}
223
224
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
const char Option_t
R__EXTERN TPluginManager * gPluginMgr
Int_t gDebug
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
Definition KVBase.h:142
virtual void Copy(TObject &) const
Make a copy of this object.
Definition KVBase.cpp:394
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition KVBase.cpp:793
Define and manage data analysis tasks.
Bool_t fBaseIsPlugin
true if base class for user analysis is in a plugin library
KVString fPluginBase
known base class extended by plugin library
KVString fPluginURI
uri of the plugin library containing user base class
KVString fExtraAClicIncludes
to be added to AClic include paths before compilation
virtual Bool_t CheckUserBaseClassIsLoaded()
KVString fBaseClass
base class for user analysis
virtual const Char_t * GetDataAnalyser() const
virtual void Copy(TObject &) const
virtual const Char_t * GetUserBaseClass() const
KVDataAnalysisTask()
Default ctor.
virtual const Char_t * GetPrereq() const
virtual void ls(Option_t *opt="") const
Print analysis task information.
Bool_t fUserClass
true if analysis task requires user-supplied class (derived from fBaseClass)
virtual void SetUserBaseClass(const Char_t *d)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
const char * GetName() const override
const char * GetTitle() const override
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * GetClass() const
TPluginHandler * FindHandler(const char *base, const char *uri=nullptr)
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
virtual void AddIncludePath(const char *includePath)
const char * String
ClassImp(TPyArg)