GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoadWatchers.C
Go to the documentation of this file.
1 
2 
3 
4 
5 void LoadWatchers_AGATA();
7 void LoadWatchers_GSI();
8 void BeginLoadWatchers();
9 void EndLoadWatchers();
10 
11 namespace __LoadWatchers__ {
12  // to modify to Aclic compilation's options
13  // .L toto.C+[CompOpt] with CompOpt = "" or "+" or "+g"
14  const Char_t *CompOpt = "";
15 
16  TString tmp;
17 
18  // path to agapro
19  TString AGAPRO;
20 }
21 using namespace __LoadWatchers__ ;
22 
24 
42 void LoadWatchers(const Char_t *path_to_agapro = "")
43 {
44  tmp = CompOpt;
45  if ( tmp.Contains("g") ) {
46  gSystem->SetAclicMode(TSystem::kDebug);
47  }
48 
49  // keep path to agapro to set up WatcherConfig.h so that is knows AGAPRO
50  AGAPRO = path_to_agapro;
51 
53 
54  tmp = Form(".L EmulatorControl.C+%s",CompOpt);
55  gROOT->ProcessLine(tmp.Data());
56 
60 
61  // Special to watchers
62  tmp = Form(".L MyWatchers/MyTree.C+%s",CompOpt);
63  gROOT->ProcessLine(tmp.Data());
64 
66 }
67 
68 #include <fstream>
69 
71 {
72  // ---> GammaWare PART /////////////////////////
73  printf("******************************************************************** \n") ;
74  printf(" Messages from LoadWatchers.C \n") ;
75  printf("******************************************************************** \n") ;
76 
77  // to add to ROOT the Gw path to look for macros
78  TString tmp, macroPATH;
79 
80  macroPATH = gROOT->GetMacroPath(); tmp = Gw::Env::GetPath("MacrosPath");
81  if ( macroPATH.Contains(tmp.Data()) == false ) {
82  printf("- Add %s to the macros path \n",tmp.Data());
83  tmp += ":";
84  macroPATH.Prepend(tmp.Data()); gROOT->SetMacroPath(macroPATH.Data());
85  }
86 
87  // add GammaWare include path to ROOT for compilation
88  tmp = Gw::Env::GetPath("IncludePath"); printf("- Add %s to the include path \n",tmp.Data());
89  tmp.Prepend(" .include ");
90  gROOT->ProcessLine(tmp.Data());
91 
92  // load the different Gw libraries needed
93  gSystem->Load("libGWCORE.so");
94  gSystem->Load("libGWADF.so");
95  gSystem->Load("libGWADFE.so");
96  gSystem->Load("libGWTOOLS.so");
97 
98  if ( AGAPRO.Contains("/") ) {
99 
100  AGAPRO.Append("/include"); printf("- Add path to AGAPRO includes [%s] to the include path \n",AGAPRO.Data());
101  AGAPRO.Prepend(" .include ");
102  gROOT->ProcessLine(AGAPRO.Data());
103 
104  gSystem->Load("libAgaProCommon.so");
105  gSystem->Load("libCrystalProducer.so");
106  gSystem->Load("libPreprocessingFilter.so");
107  gSystem->Load("libTrackingFilter.so");
108  }
109 
110 
111  // compile and load the different watchers
112  tmp = "./MyWatchers" ; printf("- Add %s to the include path \n",tmp.Data());
113  tmp.Prepend(" .include ");
114  gROOT->ProcessLine(tmp.Data());
115  tmp = "./DefaultWatchers" ; printf("- Add %s to the include path \n",tmp.Data());
116  tmp.Prepend(" .include ");
117  gROOT->ProcessLine(tmp.Data());
118 
119  // basic setup not defined, take the default
120  if ( gSystem->AccessPathName("./SetupWatchers.C") ) { // does not exist
121  cout << "- Standard configuration (Default setup, SetupWatchers.C) installed " << endl;
122  //
123  gSystem->CopyFile("Macros/SetupWatchers.C","./SetupWatchers.C");
124  }
125  // depending on ancillary it set WatchersConfig.h
126  TString isprisma = gSystem->Getenv("PRISMA_PREPROC"), isprespec = gSystem->Getenv("PRESPEC"), isgo4 = gSystem->Getenv("GOSYS");
127  std::ofstream fdefs("WatchersConfig.h",ios::out | ios::trunc);
128  if ( fdefs.is_open() ) {
129  fdefs << "// enable / disable prisma " << std::endl;
130  if ( isprisma == "" ) { // no prisma
131  fdefs << "//" ;
132  }
133  fdefs << "#define HAS_PRISMA " << std::endl;
134 
135  fdefs << "// enable / disable prespec " << std::endl;
136  if ( isprespec == "" ) {
137  fdefs << "//" ;
138  }
139  fdefs << "#define HAS_PRESPEC " << std::endl;
140 
141  fdefs << "// enable / disable go4 " << std::endl;
142  if ( isgo4 == "" ) {
143  fdefs << "//" ;
144  }
145  fdefs << "#define HAS_GO4 " << std::endl;
146 
147  if ( AGAPRO.Contains("/") ) {
148  fdefs << "#define HAS_AGAPROCONFIG " << std::endl;
149  }
150  }
151  // basic setup not defined, take the default
152  if ( gSystem->AccessPathName("./OnlineWatchersLLP.C") ) { // does not exist
153  cout << "- Customisable default OnlineWatchersLLP.C installed " << endl;
154  gSystem->CopyFile("Macros/OnlineWatchersLLP.C","./OnlineWatchersLLP.C");
155  }
156  // basic setup not defined, take the default
157  if ( gSystem->AccessPathName("./OnlineWatchersGLP.C") ) { // does not exist
158  cout << "- Customisable default OnlineWatchersGLP.C installed " << endl;
159  gSystem->CopyFile("Macros/OnlineWatchersGLP.C","./OnlineWatchersGLP.C");
160  }
161  // basic setup not defined, take the default
162  if ( gSystem->AccessPathName("./OfflineWatchers.C") ) { // does not exist
163  cout << "- Customisable default OfflineWatchers.C installed" << endl;
164  gSystem->CopyFile("Macros/OfflineWatchers.C","./OfflineWatchers.C");
165  }
166 
167  // Add personnal watchers in MyWatchers
168  if ( gSystem->AccessPathName("MyWatchers") ) { // does not exist
169  cout << "- Add personnal customisable watchers " << endl;
170  gSystem->mkdir("./MyWatchers");
171  gSystem->CopyFile("Macros/MyTree.h","MyWatchers/MyTree.h");
172  gSystem->CopyFile("Macros/MyTree.C","MyWatchers/MyTree.C");
173  }
174 }
175 
177 {
178  // Gives some command that can be run
179  cout << endl;
180  cout << " To start online (Local Level) Watchers : " << endl;
181  cout << " .L OnlineWatchersLLP.C+ " << endl;
182  cout << " - to watch only one selected actor " << endl;
183  cout << " OnlineWatchersLLP() or OnlineWatchersLLP(new TFile(\"MySpectra.root\",\"UPDATE\"),new TFile(\"MyTagSpectra.root\",\"UPDATE\"))" << endl;
184  cout << " - to watch simultaneously all the actors " << endl;
185  cout << " OnlineWatchersLLP(0x0,0x0,true) or OnlineWatchersLLP(new TFile(\"MySpectra.root\",\"UPDATE\"),new TFile(\"MyTagSpectra.root\",\"UPDATE\"),true)" << endl;
186  cout << " To start online (Global Level) Watchers : " << endl;
187  cout << " .L OnlineWatchersGLP.C+ " << endl;
188  cout << " OnlineWatchersGLP() or OnlineWatchersGLP(new TFile(\"MySpectra.root\",\"UPDATE\"),new TFile(\"MyTagSpectra.root\",\"UPDATE\"))" << endl;
189  cout << " Then start the watching from the ROOT Browser " << endl << endl;
190  cout << " To start offline Watchers : " << endl;
191  cout << " 1 - Configure OfflineWatcher.C (it could be a copy of of the one in DefaultWatchers)" << endl;
192  cout << " 2 - Compile/Run the Watchers with : " << endl;
193  cout << " .L OfflineWatchers.C+" << endl;
194  cout << " OfflineWatchers() or OfflineWatchers(new TFile(\"MySpectra.root\",\"UPDATE\"))" << endl;
195  cout << endl;
196 
197  // check whether or not ADF_CONF_PATH has been set !
198  TString adf_path = gSystem->Getenv("ADF_CONF_PATH");
199  if ( adf_path == "" ) {
200  if ( ! gSystem->AccessPathName("./ADF.conf") ) { // does exist
201  // get the current directory
202  TString pwd_path = gSystem->Getenv("PWD");
203  // set ADF_CONF_PATH to the current directory
204  gSystem->Setenv("ADF_CONF_PATH",pwd_path.Data());
205 
206  printf("\n [Info] ADF_CONF_PATH has been set to %s \n\n ",pwd_path.Data());
207  }
208  else
209  cout << "\n ** [WARNING] ** , ADF_CONF_PATH not set ! " << endl << endl;
210  }
211  else printf("\n [Info] ADF_CONF_PATH is %s \n\n ",adf_path.Data());
212 
213  // start a ROOT TBrowser
214  TBrowser *b = new TBrowser();
215 }
216 
218 {
219  // Load the watchers
220  tmp = Form(".L DefaultWatchers/ADFWatchers.C+%s",CompOpt);
221  gROOT->ProcessLine(tmp.Data());
222  tmp = Form(".L DefaultWatchers/WatcherClient.C+%s",CompOpt);
223  gROOT->ProcessLine(tmp.Data());
224  tmp = Form(".L DefaultWatchers/MetaWatchers.C+%s",CompOpt);
225  gROOT->ProcessLine(tmp.Data());
226  tmp = Form(".L DefaultWatchers/TrackedWatchers.C+%s",CompOpt);
227  gROOT->ProcessLine(tmp.Data());
228  tmp = Form(".L DefaultWatchers/EventPSAWatchers.C+%s",CompOpt);
229  gROOT->ProcessLine(tmp.Data());
230  tmp = Form(".L DefaultWatchers/PSAWatchers.C+%s",CompOpt);
231  gROOT->ProcessLine(tmp.Data());
232  tmp = Form(".L DefaultWatchers/CrystalWatchers.C+%s",CompOpt);
233  gROOT->ProcessLine(tmp.Data());
234  tmp = Form(".L DefaultWatchers/RancLegnaroWatchers.C+%s",CompOpt);
235  gROOT->ProcessLine(tmp.Data());
236  tmp = Form(".L DefaultWatchers/EventWatchers.C+%s",CompOpt);
237  gROOT->ProcessLine(tmp.Data());
238  tmp = Form(".L DefaultWatchers/DanteWatchers.C+%s",CompOpt);
239  gROOT->ProcessLine(tmp.Data());
240  tmp = Form(".L DefaultWatchers/LLaBr3Watchers.C+%s",CompOpt);
241  gROOT->ProcessLine(tmp.Data());
242 }
243 
246 {
247  // check if PRISMA_PREPROC is defined
248  TString prisma = gSystem->Getenv("PRISMA_PREPROC");
249  if ( prisma == "" ) {
250  return;
251  }
252 
253  // Directory where are the includes of the ancillary part for compilation
254  tmp = prisma + "/src/lib_prisma/include/"; printf("- Add %s to the include path \n",tmp.Data());
255  tmp.Prepend(" .include ");
256  gROOT->ProcessLine(tmp.Data());
257 
258  // ---> the prisma library
259  gSystem->Load( Form("%s/lib/libPRISMA.so",prisma.Data()) );
260 
261  // ---> Compile and load the watchers for PRISMA
262  if ( gSystem->AccessPathName("MyWatchers/PrismaWatchers.h") )
263  gSystem->CopyFile("Macros/PrismaWatchers.h","MyWatchers/PrismaWatchers.h");
264  if ( gSystem->AccessPathName("MyWatchers/PrismaWatchers.C") )
265  gSystem->CopyFile("Macros/PrismaWatchers.C","MyWatchers/PrismaWatchers.C");
266 
267  tmp = Form(".L MyWatchers/PrismaWatchers.C+%s",CompOpt);
268  gROOT->ProcessLine(tmp.Data());
269 }
270 
273 {
274  // check prespec is defined
275  TString prespec = gSystem->Getenv("PRESPEC"), go4 = gSystem->Getenv("GOSYS"), path_to_libs;
276  if ( prespec == "" ) {
277  // to be done : check id libs and includes exists in case of agapro
278  if ( AGAPRO.Contains("/") ) {
279  prespec = AGAPRO; path_to_libs = AGAPRO;
280  }
281  else return;
282  }
283  else {
284  // manual configuration
285  tmp = CompOpt;
286  if ( tmp.Contains("g") ) {
287  path_to_libs = Form("%s/debug/lib/",prespec.Data());
288  }
289  else {
290  path_to_libs = Form("%s/release/lib/",prespec.Data());
291  }
292  }
293 
294  // make sure some GSI Watchers are in MyWatchers
295  if ( gSystem->AccessPathName("MyWatchers/GSIWatchers.h") )
296  gSystem->CopyFile("Macros/GSIWatchers.h","MyWatchers/GSIWatchers.h");
297  if ( gSystem->AccessPathName("MyWatchers/GSIWatchers.C") )
298  gSystem->CopyFile("Macros/GSIWatchers.C","MyWatchers/GSIWatchers.C");
299 
300  if ( gSystem->AccessPathName("MyWatchers/GSIPrespecWatchers.h") )
301  gSystem->CopyFile("Macros/GSIPrespecWatchers.h","MyWatchers/GSIPrespecWatchers.h");
302  if ( gSystem->AccessPathName("MyWatchers/GSIPrespecWatchers.C") )
303  gSystem->CopyFile("Macros/GSIPrespecWatchers.C","MyWatchers/GSIPrespecWatchers.C");
304 
305  if ( gSystem->AccessPathName("MyWatchers/GSIGO4Watchers.h") )
306  gSystem->CopyFile("Macros/GSIGO4Watchers.h","MyWatchers/GSIGO4Watchers.h");
307  if ( gSystem->AccessPathName("MyWatchers/GSIGO4Watchers.C") )
308  gSystem->CopyFile("Macros/GSIGO4Watchers.C","MyWatchers/GSIGO4Watchers.C");
309 
310  // external includes / define / libraries
311  tmp = Form("-I%s",prespec.Data());
312  gSystem->AddIncludePath(tmp.Data()); //To include Prespec path
313  tmp = Form("-I%s/eventapiV50",prespec.Data());
314  gSystem->AddIncludePath(tmp.Data()); //To include Go4 path
315 
316  tmp = Form("%s/libgsievt.so",path_to_libs.Data());
317  gSystem->Load(tmp.Data()) ;
318  tmp = Form("%s/lib_prespec.so",path_to_libs.Data());
319  gSystem->Load(tmp.Data()) ;
320 
321  // ---> Compile and load the watchers for GSI
322  tmp = Form(".L MyWatchers/GSIWatchers.C+%s",CompOpt);
323  gROOT->ProcessLine(tmp.Data());
324  //
325  if ( go4 == "" ) {
326  tmp = Form(".L MyWatchers/GSIPrespecWatchers.C+%s",CompOpt);
327  gROOT->ProcessLine(tmp.Data());
328  }
329  else {
330  std::cout << "GO4 Watchers not yet defined ! " << std::endl;
331  }
332 
333 }
334 
TBrowser * b
printf("******************************************************************** \n")
void BeginLoadWatchers()
Definition: LoadWatchers.C:70
TString macroPATH
void LoadWatchers_GSI()
Load watchers for ancillaries @ GSI.
Definition: LoadWatchers.C:272
void EndLoadWatchers()
Definition: LoadWatchers.C:176
ADF::LogMessage & endl(ADF::LogMessage &log)
void LoadWatchers_Legnaro()
Load watchers for ancillaries @ Legnaro i.e. Prisma LIB.
Definition: LoadWatchers.C:245
void LoadWatchers_AGATA()
Definition: LoadWatchers.C:217
void LoadWatchers(const Char_t *path_to_agapro="")
Definition: LoadWatchers.C:42
static const char * GetPath(const char *)
to get a particular GW environment variable
Definition: Env.cpp:47