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